diff --git a/dist/phaser-arcade-physics.js b/dist/phaser-arcade-physics.js index 3401422cf..dc9feea99 100644 --- a/dist/phaser-arcade-physics.js +++ b/dist/phaser-arcade-physics.js @@ -7,7 +7,7 @@ exports["Phaser"] = factory(); else root["Phaser"] = factory(); -})(typeof self !== 'undefined' ? self : this, function() { +})(window, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; @@ -54,6 +54,11 @@ return /******/ (function(modules) { // webpackBootstrap /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -69,8 +74,9 @@ return /******/ (function(modules) { // webpackBootstrap /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ +/******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 1005); +/******/ return __webpack_require__(__webpack_require__.s = 972); /******/ }) /************************************************************************/ /******/ ([ @@ -322,9 +328,9 @@ module.exports = Class; */ var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var DataManager = __webpack_require__(79); -var EventEmitter = __webpack_require__(14); +var Components = __webpack_require__(13); +var DataManager = __webpack_require__(103); +var EventEmitter = __webpack_require__(15); /** * @classdesc @@ -334,7 +340,7 @@ var EventEmitter = __webpack_require__(14); * * @class GameObject * @memberOf Phaser.GameObjects - * @extends EventEmitter + * @extends Phaser.Events.EventEmitter * @constructor * @since 3.0.0 * @@ -474,7 +480,7 @@ var GameObject = new Class({ * @since 3.0.0 * * @param {boolean} value - True if this Game Object should be set as active, false if not. - * + * * @return {Phaser.GameObjects.GameObject} This GameObject. */ setActive: function (value) @@ -492,7 +498,7 @@ var GameObject = new Class({ * @since 3.0.0 * * @param {string} value - The name to be given to this Game Object. - * + * * @return {Phaser.GameObjects.GameObject} This GameObject. */ setName: function (value) @@ -528,8 +534,8 @@ var GameObject = new Class({ * @since 3.0.0 * * @param {string} key - The key of the property to be stored. - * @param {any} value - The value to store with the key. Can be a string, number, array or object. - * + * @param {*} value - The value to store with the key. Can be a string, number, array or object. + * * @return {Phaser.GameObjects.GameObject} This GameObject. */ setData: function (key, value) @@ -551,8 +557,8 @@ var GameObject = new Class({ * @since 3.0.0 * * @param {string} key - The key of the property to be retrieved. - * - * @return {any} The data, if present in the Data Store. + * + * @return {*} The data, if present in the Data Store. */ getData: function (key) { @@ -570,10 +576,10 @@ var GameObject = new Class({ * @method Phaser.GameObjects.GameObject#setInteractive * @since 3.0.0 * - * @param {any} [shape] - A geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. - * @param {function} [callback] - A callback to be invoked when the Game Object is interacted with. + * @param {*} [shape] - A geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. + * @param {HitAreaCallback} [callback] - A callback to be invoked when the Game Object is interacted with. * @param {boolean} [dropZone=false] - Should this Game Object be treated as a drop zone target? - * + * * @return {Phaser.GameObjects.GameObject} This GameObject. */ setInteractive: function (shape, callback, dropZone) @@ -599,7 +605,7 @@ var GameObject = new Class({ * @method Phaser.GameObjects.GameObject#toJSON * @since 3.0.0 * - * @return {object} A JSON representation of the Game Object. + * @return {JSONGameObject} A JSON representation of the Game Object. */ toJSON: function () { @@ -622,13 +628,13 @@ var GameObject = new Class({ /** * Destroys this Game Object removing it from the Display List and Update List and * severing all ties to parent resources. - * + * * Also removes itself from the Input Manager and Physics Manager if previously enabled. - * + * * Use this to remove a Game Object from your game if you don't ever plan to use it again. * As long as no reference to it exists within your own code it should become free for * garbage collection by the browser. - * + * * If you just want to temporarily disable an object then look at using the * Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected. * @@ -648,6 +654,8 @@ var GameObject = new Class({ this.preDestroy.call(this); } + this.emit('destroy', this); + var sys = this.scene.sys; sys.displayList.remove(this); @@ -680,8 +688,6 @@ var GameObject = new Class({ this.scene = undefined; - this.emit('destroy'); - this.removeAllListeners(); } @@ -721,9 +727,9 @@ module.exports = GameObject; * * @param {object} source - [description] * @param {string} key - [description] - * @param {any} defaultValue - [description] + * @param {*} [defaultValue] - [description] * - * @return {any} [description] + * @return {*} [description] */ var GetFastValue = function (source, key, defaultValue) { @@ -775,77 +781,6 @@ module.exports = NOOP; /***/ }), /* 4 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Source object -// The key as a string, or an array of keys, i.e. 'banner', or 'banner.hideBanner' -// The default value to use if the key doesn't exist - -/** - * [description] - * - * @function Phaser.Utils.Object.GetValue - * @since 3.0.0 - * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {any} defaultValue - [description] - * - * @return {any} [description] - */ -var GetValue = function (source, key, defaultValue) -{ - if (!source || typeof source === 'number') - { - return defaultValue; - } - else if (source.hasOwnProperty(key)) - { - return source[key]; - } - else if (key.indexOf('.')) - { - var keys = key.split('.'); - var parent = source; - var value = defaultValue; - - // Use for loop here so we can break early - for (var i = 0; i < keys.length; i++) - { - if (parent.hasOwnProperty(keys[i])) - { - // Yes it has a key property, let's carry on down - value = parent[keys[i]]; - - parent = parent[keys[i]]; - } - else - { - // Can't go any further, so reset to default - value = defaultValue; - break; - } - } - - return value; - } - else - { - return defaultValue; - } -}; - -module.exports = GetValue; - - -/***/ }), -/* 5 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -925,6 +860,77 @@ var Point = new Class({ module.exports = Point; +/***/ }), +/* 5 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Source object +// The key as a string, or an array of keys, i.e. 'banner', or 'banner.hideBanner' +// The default value to use if the key doesn't exist + +/** + * [description] + * + * @function Phaser.Utils.Object.GetValue + * @since 3.0.0 + * + * @param {object} source - [description] + * @param {string} key - [description] + * @param {*} defaultValue - [description] + * + * @return {*} [description] + */ +var GetValue = function (source, key, defaultValue) +{ + if (!source || typeof source === 'number') + { + return defaultValue; + } + else if (source.hasOwnProperty(key)) + { + return source[key]; + } + else if (key.indexOf('.')) + { + var keys = key.split('.'); + var parent = source; + var value = defaultValue; + + // Use for loop here so we can break early + for (var i = 0; i < keys.length; i++) + { + if (parent.hasOwnProperty(keys[i])) + { + // Yes it has a key property, let's carry on down + value = parent[keys[i]]; + + parent = parent[keys[i]]; + } + else + { + // Can't go any further, so reset to default + value = defaultValue; + break; + } + } + + return value; + } + else + { + return defaultValue; + } +}; + +module.exports = GetValue; + + /***/ }), /* 6 */ /***/ (function(module, exports, __webpack_require__) { @@ -935,11 +941,18 @@ module.exports = Point; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji // and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl var Class = __webpack_require__(0); +/** + * @typedef {object} Vector2Like + * + * @property {number} x - [description] + * @property {number} y - [description] + */ + /** * @classdesc * [description] @@ -966,6 +979,7 @@ var Vector2 = new Class({ * @default 0 * @since 3.0.0 */ + this.x = 0; /** * The y component of this Vector. @@ -975,6 +989,7 @@ var Vector2 = new Class({ * @default 0 * @since 3.0.0 */ + this.y = 0; if (typeof x === 'object') { @@ -1009,7 +1024,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#copy * @since 3.0.0 * - * @param {Phaser.Math.Vector2|object} src - [description] + * @param {Phaser.Math.Vector2} src - [description] * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1027,7 +1042,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#setFromObject * @since 3.0.0 * - * @param {[type]} obj - [description] + * @param {Vector2Like} obj - [description] * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1045,8 +1060,8 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#set * @since 3.0.0 * - * @param {[type]} x - [description] - * @param {[type]} y - [description] + * @param {number} x - [description] + * @param {number} [y=x] - [description] * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1060,17 +1075,14 @@ var Vector2 = new Class({ return this; }, - // Sets the `x` and `y` values of this object from a given polar coordinate. - // @param {number} azimuth - The angular coordinate, in radians. - // @param {number} [radius=1] - The radial coordinate (length). /** - * [description] + * Sets the `x` and `y` values of this object from a given polar coordinate. * * @method Phaser.Math.Vector2#setToPolar * @since 3.0.0 * - * @param {[type]} azimuth - [description] - * @param {[type]} radius - [description] + * @param {float} azimuth - The angular coordinate, in radians. + * @param {float} [radius=1] - The radial coordinate (length). * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1090,7 +1102,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#equals * @since 3.0.0 * - * @param {[type]} v - [description] + * @param {Phaser.Math.Vector2} v - [description] * * @return {boolean} [description] */ @@ -1127,7 +1139,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#add * @since 3.0.0 * - * @param {[type]} src - [description] + * @param {Phaser.Math.Vector2} src - [description] * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1145,7 +1157,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#subtract * @since 3.0.0 * - * @param {[type]} src - [description] + * @param {Phaser.Math.Vector2} src - [description] * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1163,7 +1175,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#multiply * @since 3.0.0 * - * @param {[type]} src - [description] + * @param {Phaser.Math.Vector2} src - [description] * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1181,7 +1193,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#scale * @since 3.0.0 * - * @param {[type]} value - [description] + * @param {number} value - [description] * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1207,7 +1219,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#divide * @since 3.0.0 * - * @param {[type]} src - [description] + * @param {Phaser.Math.Vector2} src - [description] * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1241,7 +1253,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#distance * @since 3.0.0 * - * @param {[type]} src - [description] + * @param {Phaser.Math.Vector2} src - [description] * * @return {number} [description] */ @@ -1259,7 +1271,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#distanceSq * @since 3.0.0 * - * @param {[type]} src - [description] + * @param {Phaser.Math.Vector2} src - [description] * * @return {number} [description] */ @@ -1323,7 +1335,7 @@ var Vector2 = new Class({ this.x = x * len; this.y = y * len; } - + return this; }, @@ -1354,7 +1366,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#dot * @since 3.0.0 * - * @param {[type]} src - [description] + * @param {Phaser.Math.Vector2} src - [description] * * @return {number} [description] */ @@ -1369,7 +1381,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#cross * @since 3.0.0 * - * @param {[type]} src - [description] + * @param {Phaser.Math.Vector2} src - [description] * * @return {number} [description] */ @@ -1384,8 +1396,8 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#lerp * @since 3.0.0 * - * @param {[type]} src - [description] - * @param {[type]} t - [description] + * @param {Phaser.Math.Vector2} src - [description] + * @param {number} [t=0] - [description] * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1408,7 +1420,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#transformMat3 * @since 3.0.0 * - * @param {[type]} mat - [description] + * @param {Phaser.Math.Matrix3} mat - [description] * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1430,7 +1442,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#transformMat4 * @since 3.0.0 * - * @param {[type]} mat - [description] + * @param {Phaser.Math.Matrix4} mat - [description] * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1524,450 +1536,80 @@ module.exports = FileTypesManager; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Contains = __webpack_require__(33); -var GetPoint = __webpack_require__(107); -var GetPoints = __webpack_require__(187); -var Random = __webpack_require__(108); +var MATH = __webpack_require__(16); +var GetValue = __webpack_require__(5); + +// Allowed types: + +// Implicit +// { +// x: 4 +// } +// +// From function +// { +// x: function () +// } +// +// Randomly pick one element from the array +// { +// x: [a, b, c, d, e, f] +// } +// +// Random integer between min and max: +// { +// x: { randInt: [min, max] } +// } +// +// Random float between min and max: +// { +// x: { randFloat: [min, max] } +// } /** - * @classdesc - * Encapsulates a 2D rectangle defined by its corner point in the top-left and its extends in x (width) and y (height) + * [description] * - * @class Rectangle - * @memberOf Phaser.Geom - * @constructor + * @function Phaser.Utils.Object.GetAdvancedValue * @since 3.0.0 * - * @param {number} [x] - [description] - * @param {number} [y] - [description] - * @param {number} [width] - [description] - * @param {number} [height] - [description] + * @param {object} source - [description] + * @param {string} key - [description] + * @param {*} defaultValue - [description] + * + * @return {*} [description] */ -var Rectangle = new Class({ +var GetAdvancedValue = function (source, key, defaultValue) +{ + var value = GetValue(source, key, null); - initialize: - - function Rectangle (x, y, width, height) + if (value === null) { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (width === undefined) { width = 0; } - if (height === undefined) { height = 0; } - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x = x; - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y = y; - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#width - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.width = width; - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#height - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.height = height; - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#contains - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - contains: function (x, y) + return defaultValue; + } + else if (Array.isArray(value)) { - return Contains(this, x, y); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#getPoint - * @since 3.0.0 - * - * @param {[type]} position - [description] - * @param {[type]} output - [description] - * - * @return {[type]} [description] - */ - getPoint: function (position, output) + return MATH.RND.pick(value); + } + else if (typeof value === 'object') { - return GetPoint(this, position, output); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#getPoints - * @since 3.0.0 - * - * @param {[type]} quantity - [description] - * @param {[type]} stepRate - [description] - * @param {[type]} output - [description] - * - * @return {[type]} [description] - */ - getPoints: function (quantity, stepRate, output) - { - return GetPoints(this, quantity, stepRate, output); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#getRandomPoint - * @since 3.0.0 - * - * @param {[type]} point - [description] - * - * @return {[type]} [description] - */ - getRandomPoint: function (point) - { - return Random(this, point); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#setTo - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} width - [description] - * @param {[type]} height - [description] - * - * @return {Phaser.Geom.Rectangle} This Rectangle object. - */ - setTo: function (x, y, width, height) - { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#setEmpty - * @since 3.0.0 - * - * @return {Phaser.Geom.Rectangle} This Rectangle object. - */ - setEmpty: function () - { - return this.setTo(0, 0, 0, 0); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#setPosition - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {Phaser.Geom.Rectangle} This Rectangle object. - */ - setPosition: function (x, y) - { - if (y === undefined) { y = x; } - - this.x = x; - this.y = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#setSize - * @since 3.0.0 - * - * @param {[type]} width - [description] - * @param {[type]} height - [description] - * - * @return {Phaser.Geom.Rectangle} This Rectangle object. - */ - setSize: function (width, height) - { - if (height === undefined) { height = width; } - - this.width = width; - this.height = height; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#isEmpty - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isEmpty: function () - { - return (this.width <= 0 || this.height <= 0); - }, - - // TOP - /** - * [description] - * - * @method Phaser.Geom.Rectangle#getLineA - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getLineA: function () - { - return { x1: this.x, y1: this.y, x2: this.right, y2: this.y }; - }, - - // RIGHT - /** - * [description] - * - * @method Phaser.Geom.Rectangle#getLineB - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getLineB: function () - { - return { x1: this.right, y1: this.y, x2: this.right, y2: this.bottom }; - }, - - // BOTTOM - /** - * [description] - * - * @method Phaser.Geom.Rectangle#getLineC - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getLineC: function () - { - return { x1: this.right, y1: this.bottom, x2: this.x, y2: this.bottom }; - }, - - // LEFT - /** - * [description] - * - * @method Phaser.Geom.Rectangle#getLineD - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getLineD: function () - { - return { x1: this.x, y1: this.bottom, x2: this.x, y2: this.y }; - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#left - * @type {number} - * @since 3.0.0 - */ - left: { - - get: function () + if (value.hasOwnProperty('randInt')) { - return this.x; - }, - - set: function (value) - { - if (value >= this.right) - { - this.width = 0; - } - else - { - this.width = this.right - value; - } - - this.x = value; + return MATH.RND.integerInRange(value.randInt[0], value.randInt[1]); } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#right - * @type {number} - * @since 3.0.0 - */ - right: { - - get: function () + else if (value.hasOwnProperty('randFloat')) { - return this.x + this.width; - }, - - set: function (value) - { - if (value <= this.x) - { - this.width = 0; - } - else - { - this.width = value - this.x; - } + return MATH.RND.realInRange(value.randFloat[0], value.randFloat[1]); } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#top - * @type {number} - * @since 3.0.0 - */ - top: { - - get: function () - { - return this.y; - }, - - set: function (value) - { - if (value >= this.bottom) - { - this.height = 0; - } - else - { - this.height = (this.bottom - value); - } - - this.y = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#bottom - * @type {number} - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return this.y + this.height; - }, - - set: function (value) - { - if (value <= this.y) - { - this.height = 0; - } - else - { - this.height = value - this.y; - } - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#centerX - * @type {number} - * @since 3.0.0 - */ - centerX: { - - get: function () - { - return this.x + (this.width / 2); - }, - - set: function (value) - { - this.x = value - (this.width / 2); - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#centerY - * @type {number} - * @since 3.0.0 - */ - centerY: { - - get: function () - { - return this.y + (this.height / 2); - }, - - set: function (value) - { - this.y = value - (this.height / 2); - } - + } + else if (typeof value === 'function') + { + return value(key); } -}); + return value; +}; -module.exports = Rectangle; +module.exports = GetAdvancedValue; /***/ }), @@ -2123,11 +1765,11 @@ var GameObjectFactory = new Class({ // Static method called directly by the Game Object factory functions -GameObjectFactory.register = function (type, factoryFunction) +GameObjectFactory.register = function (factoryType, factoryFunction) { - if (!GameObjectFactory.prototype.hasOwnProperty(type)) + if (!GameObjectFactory.prototype.hasOwnProperty(factoryType)) { - GameObjectFactory.prototype[type] = factoryFunction; + GameObjectFactory.prototype[factoryType] = factoryFunction; } }; @@ -2146,80 +1788,471 @@ module.exports = GameObjectFactory; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var MATH = __webpack_require__(16); -var GetValue = __webpack_require__(4); - -// Allowed types: - -// Implicit -// { -// x: 4 -// } -// -// From function -// { -// x: function () -// } -// -// Randomly pick one element from the array -// { -// x: [a, b, c, d, e, f] -// } -// -// Random integer between min and max: -// { -// x: { randInt: [min, max] } -// } -// -// Random float between min and max: -// { -// x: { randFloat: [min, max] } -// } +var Class = __webpack_require__(0); +var Contains = __webpack_require__(27); +var GetPoint = __webpack_require__(166); +var GetPoints = __webpack_require__(352); +var Line = __webpack_require__(104); +var Random = __webpack_require__(163); /** - * [description] + * @classdesc + * Encapsulates a 2D rectangle defined by its corner point in the top-left and its extends in x (width) and y (height) * - * @function Phaser.Utils.Object.GetAdvancedValue + * @class Rectangle + * @memberOf Phaser.Geom + * @constructor * @since 3.0.0 * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {any} defaultValue - [description] - * - * @return {any} [description] + * @param {number} [x] - [description] + * @param {number} [y] - [description] + * @param {number} [width] - [description] + * @param {number} [height] - [description] */ -var GetAdvancedValue = function (source, key, defaultValue) -{ - var value = GetValue(source, key, null); +var Rectangle = new Class({ - if (value === null) + initialize: + + function Rectangle (x, y, width, height) { - return defaultValue; - } - else if (Array.isArray(value)) + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 0; } + if (height === undefined) { height = 0; } + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = x; + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = y; + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#width + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.width = width; + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#height + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.height = height; + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#contains + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ + contains: function (x, y) { - return MATH.RND.pick(value); - } - else if (typeof value === 'object') + return Contains(this, x, y); + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#getPoint + * @since 3.0.0 + * + * @param {float} position - [description] + * @param {(Phaser.Geom.Point|object)} output - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ + getPoint: function (position, output) { - if (value.hasOwnProperty('randInt')) + return GetPoint(this, position, output); + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#getPoints + * @since 3.0.0 + * + * @param {integer} quantity - [description] + * @param {number} [stepRate] - [description] + * @param {(array|Phaser.Geom.Point[])} [output] - [description] + * + * @return {(array|Phaser.Geom.Point[])} [description] + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#getRandomPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * + * @return {Phaser.Geom.Point} [description] + */ + getRandomPoint: function (point) + { + return Random(this, point); + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#setTo + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setTo: function (x, y, width, height) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#setEmpty + * @since 3.0.0 + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setEmpty: function () + { + return this.setTo(0, 0, 0, 0); + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#setPosition + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setPosition: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#setSize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} [height=width] - [description] + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setSize: function (width, height) + { + if (height === undefined) { height = width; } + + this.width = width; + this.height = height; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#isEmpty + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isEmpty: function () + { + return (this.width <= 0 || this.height <= 0); + }, + + /** + * Returns a Line object that corresponds to the top of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineA + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the top of this Rectangle. + */ + getLineA: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x, this.y, this.right, this.y); + + return line; + }, + + /** + * Returns a Line object that corresponds to the right of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineB + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the right of this Rectangle. + */ + getLineB: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.right, this.y, this.right, this.bottom); + + return line; + }, + + /** + * Returns a Line object that corresponds to the bottom of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineC + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the bottom of this Rectangle. + */ + getLineC: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.right, this.bottom, this.x, this.bottom); + + return line; + }, + + /** + * Returns a Line object that corresponds to the left of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineD + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the left of this Rectangle. + */ + getLineD: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x, this.bottom, this.x, this.y); + + return line; + }, + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () { - return MATH.RND.integerInRange(value.randInt[0], value.randInt[1]); - } - else if (value.hasOwnProperty('randFloat')) + return this.x; + }, + + set: function (value) { - return MATH.RND.realInRange(value.randFloat[0], value.randFloat[1]); + if (value >= this.right) + { + this.width = 0; + } + else + { + this.width = this.right - value; + } + + this.x = value; } - } - else if (typeof value === 'function') - { - return value(key); + + }, + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return this.x + this.width; + }, + + set: function (value) + { + if (value <= this.x) + { + this.width = 0; + } + else + { + this.width = value - this.x; + } + } + + }, + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return this.y; + }, + + set: function (value) + { + if (value >= this.bottom) + { + this.height = 0; + } + else + { + this.height = (this.bottom - value); + } + + this.y = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return this.y + this.height; + }, + + set: function (value) + { + if (value <= this.y) + { + this.height = 0; + } + else + { + this.height = value - this.y; + } + } + + }, + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#centerX + * @type {number} + * @since 3.0.0 + */ + centerX: { + + get: function () + { + return this.x + (this.width / 2); + }, + + set: function (value) + { + this.x = value - (this.width / 2); + } + + }, + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#centerY + * @type {number} + * @since 3.0.0 + */ + centerY: { + + get: function () + { + return this.y + (this.height / 2); + }, + + set: function (value) + { + this.y = value - (this.height / 2); + } + } - return value; -}; +}); -module.exports = GetAdvancedValue; +module.exports = Rectangle; /***/ }), @@ -2232,34 +2265,134 @@ module.exports = GetAdvancedValue; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var PluginManager = __webpack_require__(12); + /** - * @namespace Phaser.GameObjects.Components + * @classdesc + * The Game Object Creator is a Scene plugin that allows you to quickly create many common + * types of Game Objects and return them. Unlike the Game Object Factory, they are not automatically + * added to the Scene. + * + * Game Objects directly register themselves with the Creator and inject their own creation + * methods into the class. + * + * @class GameObjectCreator + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object Factory belongs. */ +var GameObjectCreator = new Class({ -module.exports = { + initialize: - Alpha: __webpack_require__(391), - Animation: __webpack_require__(365), - BlendMode: __webpack_require__(392), - ComputedSize: __webpack_require__(393), - Depth: __webpack_require__(394), - Flip: __webpack_require__(395), - GetBounds: __webpack_require__(396), - MatrixStack: __webpack_require__(397), - Origin: __webpack_require__(398), - Pipeline: __webpack_require__(189), - ScaleMode: __webpack_require__(399), - ScrollFactor: __webpack_require__(400), - Size: __webpack_require__(401), - Texture: __webpack_require__(402), - Tint: __webpack_require__(403), - ToJSON: __webpack_require__(404), - Transform: __webpack_require__(405), - TransformMatrix: __webpack_require__(190), - Visible: __webpack_require__(406) + function GameObjectCreator (scene) + { + /** + * The Scene to which this Game Object Creator belongs. + * + * @name Phaser.GameObjects.GameObjectCreator#scene + * @type {Phaser.Scene} + * @protected + * @since 3.0.0 + */ + this.scene = scene; + /** + * A reference to the Scene.Systems. + * + * @name Phaser.GameObjects.GameObjectCreator#systems + * @type {Phaser.Scenes.Systems} + * @protected + * @since 3.0.0 + */ + this.systems = scene.sys; + + if (!scene.sys.settings.isBooted) + { + scene.sys.events.once('boot', this.boot, this); + } + + /** + * A reference to the Scene Display List. + * + * @name Phaser.GameObjects.GameObjectCreator#displayList + * @type {Phaser.GameObjects.DisplayList} + * @protected + * @since 3.0.0 + */ + this.displayList; + + /** + * A reference to the Scene Update List. + * + * @name Phaser.GameObjects.GameObjectCreator#updateList; + * @type {Phaser.GameObjects.UpdateList} + * @protected + * @since 3.0.0 + */ + this.updateList; + }, + + /** + * Boots the plugin. + * + * @method Phaser.GameObjects.GameObjectCreator#boot + * @private + * @since 3.0.0 + */ + boot: function () + { + this.displayList = this.systems.displayList; + this.updateList = this.systems.updateList; + + var eventEmitter = this.systems.events; + + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); + }, + + /** + * Shuts this plugin down. + * + * @method Phaser.GameObjects.GameObjectCreator#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + }, + + /** + * Destroys this plugin. + * + * @method Phaser.GameObjects.GameObjectCreator#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.scene = null; + this.displayList = null; + this.updateList = null; + } + +}); + +// Static method called directly by the Game Object creator functions + +GameObjectCreator.register = function (factoryType, factoryFunction) +{ + if (!GameObjectCreator.prototype.hasOwnProperty(factoryType)) + { + GameObjectCreator.prototype[factoryType] = factoryFunction; + } }; +PluginManager.register('GameObjectCreator', GameObjectCreator, 'make'); + +module.exports = GameObjectCreator; + /***/ }), /* 12 */ @@ -2453,139 +2586,128 @@ module.exports = PluginManager; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var PluginManager = __webpack_require__(12); - /** - * @classdesc - * The Game Object Creator is a Scene plugin that allows you to quickly create many common - * types of Game Objects and return them. Unlike the Game Object Factory, they are not automatically - * added to the Scene. - * - * Game Objects directly register themselves with the Creator and inject their own creation - * methods into the class. - * - * @class GameObjectCreator - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object Factory belongs. + * @namespace Phaser.GameObjects.Components */ -var GameObjectCreator = new Class({ - initialize: +module.exports = { - function GameObjectCreator (scene) - { - /** - * The Scene to which this Game Object Creator belongs. - * - * @name Phaser.GameObjects.GameObjectCreator#scene - * @type {Phaser.Scene} - * @protected - * @since 3.0.0 - */ - this.scene = scene; + Alpha: __webpack_require__(937), + Animation: __webpack_require__(381), + BlendMode: __webpack_require__(936), + ComputedSize: __webpack_require__(935), + Depth: __webpack_require__(934), + Flip: __webpack_require__(933), + GetBounds: __webpack_require__(932), + MatrixStack: __webpack_require__(931), + Origin: __webpack_require__(930), + Pipeline: __webpack_require__(349), + ScaleMode: __webpack_require__(929), + ScrollFactor: __webpack_require__(928), + Size: __webpack_require__(927), + Texture: __webpack_require__(926), + Tint: __webpack_require__(925), + ToJSON: __webpack_require__(924), + Transform: __webpack_require__(923), + TransformMatrix: __webpack_require__(348), + Visible: __webpack_require__(922) - /** - * A reference to the Scene.Systems. - * - * @name Phaser.GameObjects.GameObjectCreator#systems - * @type {Phaser.Scenes.Systems} - * @protected - * @since 3.0.0 - */ - this.systems = scene.sys; - - if (!scene.sys.settings.isBooted) - { - scene.sys.events.once('boot', this.boot, this); - } - - /** - * A reference to the Scene Display List. - * - * @name Phaser.GameObjects.GameObjectCreator#displayList - * @type {Phaser.GameObjects.DisplayList} - * @protected - * @since 3.0.0 - */ - this.displayList; - - /** - * A reference to the Scene Update List. - * - * @name Phaser.GameObjects.GameObjectCreator#updateList; - * @type {Phaser.GameObjects.UpdateList} - * @protected - * @since 3.0.0 - */ - this.updateList; - }, - - /** - * Boots the plugin. - * - * @method Phaser.GameObjects.GameObjectCreator#boot - * @private - * @since 3.0.0 - */ - boot: function () - { - this.displayList = this.systems.displayList; - this.updateList = this.systems.updateList; - - var eventEmitter = this.systems.events; - - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); - }, - - /** - * Shuts this plugin down. - * - * @method Phaser.GameObjects.GameObjectCreator#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - }, - - /** - * Destroys this plugin. - * - * @method Phaser.GameObjects.GameObjectCreator#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.scene = null; - this.displayList = null; - this.updateList = null; - } - -}); - -// Static method called directly by the Game Object creator functions - -GameObjectCreator.register = function (type, factoryFunction) -{ - if (!GameObjectCreator.prototype.hasOwnProperty(type)) - { - GameObjectCreator.prototype[type] = factoryFunction; - } }; -PluginManager.register('GameObjectCreator', GameObjectCreator, 'make'); - -module.exports = GameObjectCreator; - /***/ }), /* 14 */ /***/ (function(module, exports, __webpack_require__) { +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(2); + +/** + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * + * @function Phaser.Tilemaps.Components.GetTilesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. + */ +var GetTilesWithin = function (tileX, tileY, width, height, filteringOptions, layer) +{ + if (tileX === undefined) { tileX = 0; } + if (tileY === undefined) { tileY = 0; } + if (width === undefined) { width = layer.width; } + if (height === undefined) { height = layer.height; } + + var isNotEmpty = GetFastValue(filteringOptions, 'isNotEmpty', false); + var isColliding = GetFastValue(filteringOptions, 'isColliding', false); + var hasInterestingFace = GetFastValue(filteringOptions, 'hasInterestingFace', false); + + // Clip x, y to top left of map, while shrinking width/height to match. + if (tileX < 0) + { + width += tileX; + tileX = 0; + } + if (tileY < 0) + { + height += tileY; + tileY = 0; + } + + // Clip width and height to bottom right of map. + if (tileX + width > layer.width) + { + width = Math.max(layer.width - tileX, 0); + } + if (tileY + height > layer.height) + { + height = Math.max(layer.height - tileY, 0); + } + + var results = []; + + for (var ty = tileY; ty < tileY + height; ty++) + { + for (var tx = tileX; tx < tileX + width; tx++) + { + var tile = layer.data[ty][tx]; + if (tile !== null) + { + if (isNotEmpty && tile.index === -1) { continue; } + if (isColliding && !tile.collides) { continue; } + if (hasInterestingFace && !tile.hasInterestingFace) { continue; } + results.push(tile); + } + } + } + + return results; +}; + +module.exports = GetTilesWithin; + + +/***/ }), +/* 15 */ +/***/ (function(module, exports, __webpack_require__) { + "use strict"; @@ -2925,95 +3047,6 @@ if (true) { } -/***/ }), -/* 15 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetFastValue = __webpack_require__(2); - -/** - * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. - * - * @function Phaser.Tilemaps.Components.GetTilesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. - */ -var GetTilesWithin = function (tileX, tileY, width, height, filteringOptions, layer) -{ - if (tileX === undefined) { tileX = 0; } - if (tileY === undefined) { tileY = 0; } - if (width === undefined) { width = layer.width; } - if (height === undefined) { height = layer.height; } - - var isNotEmpty = GetFastValue(filteringOptions, 'isNotEmpty', false); - var isColliding = GetFastValue(filteringOptions, 'isColliding', false); - var hasInterestingFace = GetFastValue(filteringOptions, 'hasInterestingFace', false); - - // Clip x, y to top left of map, while shrinking width/height to match. - if (tileX < 0) - { - width += tileX; - tileX = 0; - } - if (tileY < 0) - { - height += tileY; - tileY = 0; - } - - // Clip width and height to bottom right of map. - if (tileX + width > layer.width) - { - width = Math.max(layer.width - tileX, 0); - } - if (tileY + height > layer.height) - { - height = Math.max(layer.height - tileY, 0); - } - - var results = []; - - for (var ty = tileY; ty < tileY + height; ty++) - { - for (var tx = tileX; tx < tileX + width; tx++) - { - var tile = layer.data[ty][tx]; - if (tile !== null) - { - if (isNotEmpty && tile.index === -1) { continue; } - if (isColliding && !tile.collides) { continue; } - if (hasInterestingFace && !tile.hasInterestingFace) { continue; } - results.push(tile); - } - } - } - - return results; -}; - -module.exports = GetTilesWithin; - - /***/ }), /* 16 */ /***/ (function(module, exports, __webpack_require__) { @@ -3024,7 +3057,7 @@ module.exports = GetTilesWithin; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RND = __webpack_require__(390); +var RND = __webpack_require__(938); var MATH_CONST = { @@ -3270,6 +3303,105 @@ module.exports = FILE_CONST; /* 18 */ /***/ (function(module, exports, __webpack_require__) { +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var IsPlainObject = __webpack_require__(368); + +// @param {boolean} deep - Perform a deep copy? +// @param {object} target - The target object to copy to. +// @return {object} The extended object. + +/** + * This is a slightly modified version of http://api.jquery.com/jQuery.extend/ + * + * @function Phaser.Utils.Object.Extend + * @since 3.0.0 + * + * @return {object} [description] + */ +var Extend = function () +{ + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if (typeof target === 'boolean') + { + deep = target; + target = arguments[1] || {}; + + // skip the boolean and the target + i = 2; + } + + // extend Phaser if only one argument is passed + if (length === i) + { + target = this; + --i; + } + + for (; i < length; i++) + { + // Only deal with non-null/undefined values + if ((options = arguments[i]) != null) + { + // Extend the base object + for (name in options) + { + src = target[name]; + copy = options[name]; + + // Prevent never-ending loop + if (target === copy) + { + continue; + } + + // Recurse if we're merging plain objects or arrays + if (deep && copy && (IsPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) + { + if (copyIsArray) + { + copyIsArray = false; + clone = src && Array.isArray(src) ? src : []; + } + else + { + clone = src && IsPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[name] = Extend(deep, clone, copy); + + // Don't bring in undefined values + } + else if (copy !== undefined) + { + target[name] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +module.exports = Extend; + + +/***/ }), +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { + /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. @@ -3279,10 +3411,29 @@ module.exports = FILE_CONST; var Class = __webpack_require__(0); var CONST = __webpack_require__(17); var GetFastValue = __webpack_require__(2); -var GetURL = __webpack_require__(150); -var MergeXHRSettings = __webpack_require__(151); -var XHRLoader = __webpack_require__(315); -var XHRSettings = __webpack_require__(90); +var GetURL = __webpack_require__(122); +var MergeXHRSettings = __webpack_require__(121); +var XHRLoader = __webpack_require__(226); +var XHRSettings = __webpack_require__(94); + +/** + * @callback FileProcessCallback + * + * @param {Phaser.Loader.File} file - [description] + */ + +/** + * @typedef {object} FileConfig + * + * @property {(string|false)} [type=false] - The file type string (image, json, etc) for sorting within the Loader. + * @property {(string|false)} [key=false] - Unique cache key (unique within its file type) + * @property {string} [url] - The URL of the file, not including baseURL. + * @property {string} [path=''] - [description] + * @property {string} [extension=''] - [description] + * @property {XMLHttpRequestResponseType} [responseType] - [description] + * @property {(XHRSettingsObject|false)} [xhrSettings=false] - [description] + * @property {object} [config] - A config object that can be used by file types to store transitional data. + */ /** * @classdesc @@ -3293,7 +3444,7 @@ var XHRSettings = __webpack_require__(90); * @constructor * @since 3.0.0 * - * @param {object} fileConfig - [description] + * @param {FileConfig} fileConfig - [description] */ var File = new Class({ @@ -3303,7 +3454,7 @@ var File = new Class({ { /** * The file type string (image, json, etc) for sorting within the Loader. - * + * * @name Phaser.Loader.File#type * @type {string} * @since 3.0.0 @@ -3355,7 +3506,7 @@ var File = new Class({ * The merged XHRSettings for this file. * * @name Phaser.Loader.File#xhrSettings - * @type {Phaser.Loader.XHRSettings} + * @type {XHRSettingsObject} * @since 3.0.0 */ this.xhrSettings = XHRSettings(GetFastValue(fileConfig, 'responseType', undefined)); @@ -3430,7 +3581,7 @@ var File = new Class({ * If this is undefined then the File will check BaseLoader.crossOrigin and use that (if set) * * @name Phaser.Loader.File#crossOrigin - * @type {string|undefined} + * @type {(string|undefined)} * @since 3.0.0 */ this.crossOrigin = undefined; @@ -3439,7 +3590,7 @@ var File = new Class({ * The processed file data, stored in here after the file has loaded. * * @name Phaser.Loader.File#data - * @type {any} + * @type {*} * @since 3.0.0 */ this.data = undefined; @@ -3491,7 +3642,7 @@ var File = new Class({ * * @method Phaser.Loader.File#setLinkFile * @since 3.0.0 - * + * * @param {Phaser.Loader.File} fileB - The linked file. * @param {string} linkType - The type of association. */ @@ -3514,9 +3665,12 @@ var File = new Class({ */ resetXHR: function () { - this.xhrLoader.onload = undefined; - this.xhrLoader.onerror = undefined; - this.xhrLoader.onprogress = undefined; + if (this.xhrLoader) + { + this.xhrLoader.onload = undefined; + this.xhrLoader.onerror = undefined; + this.xhrLoader.onprogress = undefined; + } }, /** @@ -3619,7 +3773,7 @@ var File = new Class({ * @method Phaser.Loader.File#onProcess * @since 3.0.0 * - * @param {function} callback - The callback to invoke to process this File. + * @param {FileProcessCallback} callback - The callback to invoke to process this File. */ onProcess: function (callback) { @@ -3713,7 +3867,72 @@ module.exports = File; /***/ }), -/* 19 */ +/* 20 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes an array of Game Objects, or any objects that have a public property as defined in `key`, + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `PropertyValueSet(group.getChildren(), key, value, step)` + * + * @function Phaser.Actions.PropertyValueSet + * @since 3.3.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {string} key - The property to be updated. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var PropertyValueSet = function (items, key, value, step, index, direction) +{ + if (step === undefined) { step = 0; } + if (index === undefined) { index = 0; } + if (direction === undefined) { direction = 1; } + + var i; + var t = 0; + var end = items.length; + + if (direction === 1) + { + // Start to End + for (i = index; i < end; i++) + { + items[i][key] = value + (t * step); + t++; + } + } + else + { + // End to Start + for (i = index; i >= 0; i--) + { + items[i][key] = value + (t * step); + t++; + } + } + + return items; +}; + +module.exports = PropertyValueSet; + + +/***/ }), +/* 21 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -3731,11 +3950,11 @@ var CONST = { * @type {string} * @since 3.0.0 */ - VERSION: '3.2.1', + VERSION: '3.3.0', - BlendModes: __webpack_require__(45), + BlendModes: __webpack_require__(62), - ScaleModes: __webpack_require__(63), + ScaleModes: __webpack_require__(80), /** * AUTO Detect Renderer. @@ -3834,7 +4053,7 @@ module.exports = CONST; /***/ }), -/* 20 */ +/* 22 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -3843,19 +4062,39 @@ module.exports = CONST; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BlendModes = __webpack_require__(45); -var GetAdvancedValue = __webpack_require__(10); -var ScaleModes = __webpack_require__(63); +var BlendModes = __webpack_require__(62); +var GetAdvancedValue = __webpack_require__(8); +var ScaleModes = __webpack_require__(80); + +/** + * @typedef {object} GameObjectConfig + * + * @property {number} [x=0] - [description] + * @property {number} [y=0] - [description] + * @property {number} [depth=0] - [description] + * @property {boolean} [flipX=false] - [description] + * @property {boolean} [flipY=false] - [description] + * @property {?(number|object)} [scale=null] - [description] + * @property {?(number|object)} [scrollFactor=null] - [description] + * @property {number} [rotation=0] - [description] + * @property {?number} [angle=null] - [description] + * @property {number} [alpha=1] - [description] + * @property {?(number|object)} [origin=null] - [description] + * @property {number} [scaleMode=ScaleModes.DEFAULT] - [description] + * @property {number} [blendMode=BlendModes.DEFAULT] - [description] + * @property {boolean} [visible=true] - [description] + * @property {boolean} [add=true] - [description] + */ /** * Builds a Game Object using the provided configuration object. * - * @function Phaser.Gameobjects.BuildGameObject + * @function Phaser.GameObjects.BuildGameObject * @since 3.0.0 * * @param {Phaser.Scene} scene - [description] * @param {Phaser.GameObjects.GameObject} gameObject - [description] - * @param {object} config - [description] + * @param {GameObjectConfig} config - [description] * * @return {Phaser.GameObjects.GameObject} The built Game Object. */ @@ -3967,7 +4206,7 @@ module.exports = BuildGameObject; /***/ }), -/* 21 */ +/* 23 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -3976,8 +4215,8 @@ module.exports = BuildGameObject; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CONST = __webpack_require__(19); -var Smoothing = __webpack_require__(121); +var CONST = __webpack_require__(21); +var Smoothing = __webpack_require__(151); // The pool into which the canvas elements are placed. var pool = []; @@ -3992,7 +4231,7 @@ var _disableContextSmoothing = false; * before a Phaser.Game instance has even been created. * Which means all instances of Phaser Games on the same page * can share the one single pool - * + * * @namespace Phaser.Display.Canvas.CanvasPool * @since 3.0.0 */ @@ -4003,29 +4242,29 @@ var CanvasPool = function () * * @function Phaser.Display.Canvas.CanvasPool.create * @since 3.0.0 - * - * @param {any} parent - [description] - * @param {integer} [width=1] - [description] - * @param {integer} [height=1] - [description] - * @param {integer} [type] - [description] - * + * + * @param {*} parent - The parent of the Canvas object. + * @param {integer} [width=1] - The width of the Canvas. + * @param {integer} [height=1] - The height of the Canvas. + * @param {integer} [canvasType=Phaser.CANVAS] - The type of the Canvas. Either `Phaser.CANVAS` or `Phaser.WEBGL`. + * * @return {HTMLCanvasElement} [description] */ - var create = function (parent, width, height, type) + var create = function (parent, width, height, canvasType) { if (width === undefined) { width = 1; } if (height === undefined) { height = 1; } - if (type === undefined) { type = CONST.CANVAS; } + if (canvasType === undefined) { canvasType = CONST.CANVAS; } var canvas; - var container = first(type); + var container = first(canvasType); if (container === null) { container = { parent: parent, canvas: document.createElement('canvas'), - type: type + type: canvasType }; pool.push(container); @@ -4042,11 +4281,11 @@ var CanvasPool = function () canvas.width = width; canvas.height = height; - if (_disableContextSmoothing && type === CONST.CANVAS) + if (_disableContextSmoothing && canvasType === CONST.CANVAS) { Smoothing.disable(canvas.getContext('2d')); } - + return canvas; }; @@ -4055,11 +4294,11 @@ var CanvasPool = function () * * @function Phaser.Display.Canvas.CanvasPool.create2D * @since 3.0.0 - * - * @param {any} parent - [description] - * @param {integer} [width=1] - [description] - * @param {integer} [height=1] - [description] - * + * + * @param {*} parent - The parent of the Canvas object. + * @param {integer} [width=1] - The width of the Canvas. + * @param {integer} [height=1] - The height of the Canvas. + * * @return {HTMLCanvasElement} [description] */ var create2D = function (parent, width, height) @@ -4072,11 +4311,11 @@ var CanvasPool = function () * * @function Phaser.Display.Canvas.CanvasPool.createWebGL * @since 3.0.0 - * - * @param {any} parent - [description] - * @param {integer} [width=1] - [description] - * @param {integer} [height=1] - [description] - * + * + * @param {*} parent - The parent of the Canvas object. + * @param {integer} [width=1] - The width of the Canvas. + * @param {integer} [height=1] - The height of the Canvas. + * * @return {HTMLCanvasElement} [description] */ var createWebGL = function (parent, width, height) @@ -4089,18 +4328,18 @@ var CanvasPool = function () * * @function Phaser.Display.Canvas.CanvasPool.first * @since 3.0.0 - * - * @param {integer} [type] - [description] - * + * + * @param {integer} [canvasType=Phaser.CANVAS] - The type of the Canvas. Either `Phaser.CANVAS` or `Phaser.WEBGL`. + * * @return {HTMLCanvasElement} [description] */ - var first = function (type) + var first = function (canvasType) { - if (type === undefined) { type = CONST.CANVAS; } + if (canvasType === undefined) { canvasType = CONST.CANVAS; } pool.forEach(function (container) { - if (!container.parent && container.type === type) + if (!container.parent && container.type === canvasType) { return container; } @@ -4115,8 +4354,8 @@ var CanvasPool = function () * * @function Phaser.Display.Canvas.CanvasPool.remove * @since 3.0.0 - * - * @param {any} parent - [description] + * + * @param {*} parent - [description] */ var remove = function (parent) { @@ -4140,7 +4379,7 @@ var CanvasPool = function () * * @function Phaser.Display.Canvas.CanvasPool.total * @since 3.0.0 - * + * * @return {integer} [description] */ var total = function () @@ -4163,7 +4402,7 @@ var CanvasPool = function () * * @function Phaser.Display.Canvas.CanvasPool.free * @since 3.0.0 - * + * * @return {integer} [description] */ var free = function () @@ -4212,7 +4451,7 @@ module.exports = CanvasPool(); /***/ }), -/* 22 */ +/* 24 */ /***/ (function(module, exports) { /** @@ -4266,133 +4505,6 @@ module.exports = { }; -/***/ }), -/* 23 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var IsPlainObject = __webpack_require__(170); - -// @param {boolean} deep - Perform a deep copy? -// @param {object} target - The target object to copy to. -// @return {object} The extended object. - -/** - * This is a slightly modified version of http://api.jquery.com/jQuery.extend/ - * - * @function Phaser.Utils.Object.Extend - * @since 3.0.0 - * - * @return {object} [description] - */ -var Extend = function () -{ - var options, name, src, copy, copyIsArray, clone, - target = arguments[0] || {}, - i = 1, - length = arguments.length, - deep = false; - - // Handle a deep copy situation - if (typeof target === 'boolean') - { - deep = target; - target = arguments[1] || {}; - - // skip the boolean and the target - i = 2; - } - - // extend Phaser if only one argument is passed - if (length === i) - { - target = this; - --i; - } - - for (; i < length; i++) - { - // Only deal with non-null/undefined values - if ((options = arguments[i]) != null) - { - // Extend the base object - for (name in options) - { - src = target[name]; - copy = options[name]; - - // Prevent never-ending loop - if (target === copy) - { - continue; - } - - // Recurse if we're merging plain objects or arrays - if (deep && copy && (IsPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) - { - if (copyIsArray) - { - copyIsArray = false; - clone = src && Array.isArray(src) ? src : []; - } - else - { - clone = src && IsPlainObject(src) ? src : {}; - } - - // Never move original objects, clone them - target[name] = Extend(deep, clone, copy); - - // Don't bring in undefined values - } - else if (copy !== undefined) - { - target[name] = copy; - } - } - } - } - - // Return the modified object - return target; -}; - -module.exports = Extend; - - -/***/ }), -/* 24 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the bottom coordinate from the bounds of the Game Object. - * - * @function Phaser.Display.Bounds.GetBottom - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The bottom coordinate of the bounds of the Game Object. - */ -var GetBottom = function (gameObject) -{ - return (gameObject.y + gameObject.height) - (gameObject.height * gameObject.originY); -}; - -module.exports = GetBottom; - - /***/ }), /* 25 */ /***/ (function(module, exports) { @@ -4404,281 +4516,62 @@ module.exports = GetBottom; */ /** - * Positions the Game Object so that the bottom of its bounds aligns with the given coordinate. + * Takes an array of Game Objects, or any objects that have a public property as defined in `key`, + * and then adds the given value to it. * - * @function Phaser.Display.Bounds.SetBottom - * @since 3.0.0 + * The optional `step` property is applied incrementally, multiplied by each item in the array. * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} value - The coordinate to position the Game Object bounds on. + * To use this with a Group: `PropertyValueInc(group.getChildren(), key, value, step)` * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + * @function Phaser.Actions.PropertyValueInc + * @since 3.3.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {string} key - The property to be updated. + * @param {number} value - The amount to be added to the property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. */ -var SetBottom = function (gameObject, value) +var PropertyValueInc = function (items, key, value, step, index, direction) { - gameObject.y = (value - gameObject.height) + (gameObject.height * gameObject.originY); + if (step === undefined) { step = 0; } + if (index === undefined) { index = 0; } + if (direction === undefined) { direction = 1; } - return gameObject; + var i; + var t = 0; + var end = items.length; + + if (direction === 1) + { + // Start to End + for (i = index; i < end; i++) + { + items[i][key] += value + (t * step); + t++; + } + } + else + { + // End to Start + for (i = index; i >= 0; i--) + { + items[i][key] += value + (t * step); + t++; + } + } + + return items; }; -module.exports = SetBottom; +module.exports = PropertyValueInc; /***/ }), /* 26 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the left coordinate from the bounds of the Game Object. - * - * @function Phaser.Display.Bounds.GetLeft - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The left coordinate of the bounds of the Game Object. - */ -var GetLeft = function (gameObject) -{ - return gameObject.x - (gameObject.width * gameObject.originX); -}; - -module.exports = GetLeft; - - -/***/ }), -/* 27 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Positions the Game Object so that the left of its bounds aligns with the given coordinate. - * - * @function Phaser.Display.Bounds.SetLeft - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} value - The coordinate to position the Game Object bounds on. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. - */ -var SetLeft = function (gameObject, value) -{ - gameObject.x = value + (gameObject.width * gameObject.originX); - - return gameObject; -}; - -module.exports = SetLeft; - - -/***/ }), -/* 28 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the right coordinate from the bounds of the Game Object. - * - * @function Phaser.Display.Bounds.GetRight - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The right coordinate of the bounds of the Game Object. - */ -var GetRight = function (gameObject) -{ - return (gameObject.x + gameObject.width) - (gameObject.width * gameObject.originX); -}; - -module.exports = GetRight; - - -/***/ }), -/* 29 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Positions the Game Object so that the left of its bounds aligns with the given coordinate. - * - * @function Phaser.Display.Bounds.SetRight - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} value - The coordinate to position the Game Object bounds on. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. - */ -var SetRight = function (gameObject, value) -{ - gameObject.x = (value - gameObject.width) + (gameObject.width * gameObject.originX); - - return gameObject; -}; - -module.exports = SetRight; - - -/***/ }), -/* 30 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the top coordinate from the bounds of the Game Object. - * - * @function Phaser.Display.Bounds.GetTop - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The top coordinate of the bounds of the Game Object. - */ -var GetTop = function (gameObject) -{ - return gameObject.y - (gameObject.height * gameObject.originY); -}; - -module.exports = GetTop; - - -/***/ }), -/* 31 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Positions the Game Object so that the top of its bounds aligns with the given coordinate. - * - * @function Phaser.Display.Bounds.SetTop - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} value - The coordinate to position the Game Object bounds on. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. - */ -var SetTop = function (gameObject, value) -{ - gameObject.y = value + (gameObject.height * gameObject.originY); - - return gameObject; -}; - -module.exports = SetTop; - - -/***/ }), -/* 32 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Check to see if the Circle contains the given x / y coordinates. - * - * @function Phaser.Geom.Circle.Contains - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to check. - * @param {number} x - The x coordinate to check within the circle. - * @param {number} y - The y coordinate to check within the circle. - * - * @return {boolean} True if the coordinates are within the circle, otherwise false. - */ -var Contains = function (circle, x, y) -{ - // Check if x/y are within the bounds first - if (circle.radius > 0 && x >= circle.left && x <= circle.right && y >= circle.top && y <= circle.bottom) - { - var dx = (circle.x - x) * (circle.x - x); - var dy = (circle.y - y) * (circle.y - y); - - return (dx + dy) <= (circle.radius * circle.radius); - } - else - { - return false; - } -}; - -module.exports = Contains; - - -/***/ }), -/* 33 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Contains - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ -var Contains = function (rect, x, y) -{ - if (rect.width <= 0 || rect.height <= 0) - { - return false; - } - - return (rect.x <= x && rect.x + rect.width >= x && rect.y <= y && rect.y + rect.height >= y); -}; - -module.exports = Contains; - - -/***/ }), -/* 34 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -4687,8 +4580,8 @@ module.exports = Contains; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetTileAt = __webpack_require__(97); -var GetTilesWithin = __webpack_require__(15); +var GetTileAt = __webpack_require__(87); +var GetTilesWithin = __webpack_require__(14); /** * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the @@ -4743,8 +4636,8 @@ module.exports = CalculateFacesWithin; /***/ }), -/* 35 */ -/***/ (function(module, exports, __webpack_require__) { +/* 27 */ +/***/ (function(module, exports) { /** * @author Richard Davey @@ -4752,28 +4645,413 @@ module.exports = CalculateFacesWithin; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CONST = __webpack_require__(16); - /** * [description] * - * @function Phaser.Math.DegToRad + * @function Phaser.Geom.Rectangle.Contains * @since 3.0.0 * - * @param {integer} degrees - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} x - [description] + * @param {number} y - [description] * - * @return {float} [description] + * @return {boolean} [description] */ -var DegToRad = function (degrees) +var Contains = function (rect, x, y) { - return degrees * CONST.DEG_TO_RAD; + if (rect.width <= 0 || rect.height <= 0) + { + return false; + } + + return (rect.x <= x && rect.x + rect.width >= x && rect.y <= y && rect.y + rect.height >= y); }; -module.exports = DegToRad; +module.exports = Contains; + + +/***/ }), +/* 28 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Check to see if the Circle contains the given x / y coordinates. + * + * @function Phaser.Geom.Circle.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to check. + * @param {number} x - The x coordinate to check within the circle. + * @param {number} y - The y coordinate to check within the circle. + * + * @return {boolean} True if the coordinates are within the circle, otherwise false. + */ +var Contains = function (circle, x, y) +{ + // Check if x/y are within the bounds first + if (circle.radius > 0 && x >= circle.left && x <= circle.right && y >= circle.top && y <= circle.bottom) + { + var dx = (circle.x - x) * (circle.x - x); + var dy = (circle.y - y) * (circle.y - y); + + return (dx + dy) <= (circle.radius * circle.radius); + } + else + { + return false; + } +}; + +module.exports = Contains; + + +/***/ }), +/* 29 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the top of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetTop + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetTop = function (gameObject, value) +{ + gameObject.y = value + (gameObject.height * gameObject.originY); + + return gameObject; +}; + +module.exports = SetTop; + + +/***/ }), +/* 30 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the top coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetTop + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The top coordinate of the bounds of the Game Object. + */ +var GetTop = function (gameObject) +{ + return gameObject.y - (gameObject.height * gameObject.originY); +}; + +module.exports = GetTop; + + +/***/ }), +/* 31 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the left of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetRight + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetRight = function (gameObject, value) +{ + gameObject.x = (value - gameObject.width) + (gameObject.width * gameObject.originX); + + return gameObject; +}; + +module.exports = SetRight; + + +/***/ }), +/* 32 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the right coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetRight + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The right coordinate of the bounds of the Game Object. + */ +var GetRight = function (gameObject) +{ + return (gameObject.x + gameObject.width) - (gameObject.width * gameObject.originX); +}; + +module.exports = GetRight; + + +/***/ }), +/* 33 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the left of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetLeft + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetLeft = function (gameObject, value) +{ + gameObject.x = value + (gameObject.width * gameObject.originX); + + return gameObject; +}; + +module.exports = SetLeft; + + +/***/ }), +/* 34 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the left coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetLeft + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The left coordinate of the bounds of the Game Object. + */ +var GetLeft = function (gameObject) +{ + return gameObject.x - (gameObject.width * gameObject.originX); +}; + +module.exports = GetLeft; + + +/***/ }), +/* 35 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the bottom of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetBottom + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetBottom = function (gameObject, value) +{ + gameObject.y = (value - gameObject.height) + (gameObject.height * gameObject.originY); + + return gameObject; +}; + +module.exports = SetBottom; /***/ }), /* 36 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the bottom coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetBottom + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The bottom coordinate of the bounds of the Game Object. + */ +var GetBottom = function (gameObject) +{ + return (gameObject.y + gameObject.height) - (gameObject.height * gameObject.originY); +}; + +module.exports = GetBottom; + + +/***/ }), +/* 37 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layer's position, scale and scroll. + * + * @function Phaser.Tilemaps.Components.WorldToTileY + * @since 3.0.0 + * + * @param {number} worldY - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {number} The Y location in tile units. + */ +var WorldToTileY = function (worldY, snapToFloor, camera, layer) +{ + if (snapToFloor === undefined) { snapToFloor = true; } + + var tileHeight = layer.baseTileHeight; + var tilemapLayer = layer.tilemapLayer; + + if (tilemapLayer) + { + if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } + + // Find the world position relative to the static or dynamic layer's top left origin, + // factoring in the camera's vertical scroll + worldY = worldY - (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY)); + + tileHeight *= tilemapLayer.scaleY; + } + + return snapToFloor + ? Math.floor(worldY / tileHeight) + : worldY / tileHeight; +}; + +module.exports = WorldToTileY; + + +/***/ }), +/* 38 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layer's position, scale and scroll. + * + * @function Phaser.Tilemaps.Components.WorldToTileX + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {number} The X location in tile units. + */ +var WorldToTileX = function (worldX, snapToFloor, camera, layer) +{ + if (snapToFloor === undefined) { snapToFloor = true; } + + var tileWidth = layer.baseTileWidth; + var tilemapLayer = layer.tilemapLayer; + + if (tilemapLayer) + { + if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } + + // Find the world position relative to the static or dynamic layer's top left origin, + // factoring in the camera's horizontal scroll + worldX = worldX - (tilemapLayer.x + camera.scrollX * (1 - tilemapLayer.scrollFactorX)); + + tileWidth *= tilemapLayer.scaleX; + } + + return snapToFloor + ? Math.floor(worldX / tileWidth) + : worldX / tileWidth; +}; + +module.exports = WorldToTileX; + + +/***/ }), +/* 39 */, +/* 40 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -4783,8 +5061,162 @@ module.exports = DegToRad; */ var Class = __webpack_require__(0); -var GetColor = __webpack_require__(117); -var GetColor32 = __webpack_require__(204); +var Components = __webpack_require__(13); +var GameObject = __webpack_require__(1); +var SpriteRender = __webpack_require__(870); + +/** + * @classdesc + * A Sprite Game Object. + * + * A Sprite Game Object is used for the display of both static and animated images in your game. + * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled + * and animated. + * + * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. + * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation + * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. + * + * @class Sprite + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.Animation + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var Sprite = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Size, + Components.Texture, + Components.Tint, + Components.Transform, + Components.Visible, + SpriteRender + ], + + initialize: + + function Sprite (scene, x, y, texture, frame) + { + GameObject.call(this, scene, 'Sprite'); + + /** + * [description] + * + * @name Phaser.GameObjects.Sprite#anims + * @type {Phaser.GameObjects.Components.Animation} + * @since 3.0.0 + */ + this.anims = new Components.Animation(this); + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.setSizeToFrame(); + this.setOriginFromFrame(); + this.initPipeline('TextureTintPipeline'); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Sprite#preUpdate + * @since 3.0.0 + * + * @param {number} time - [description] + * @param {number} delta - [description] + */ + preUpdate: function (time, delta) + { + this.anims.update(time, delta); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Sprite#play + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {boolean} ignoreIfPlaying - [description] + * @param {(integer|string)} startFrame - [description] + * + * @return {Phaser.GameObjects.Sprite} This Game Object. + */ + play: function (key, ignoreIfPlaying, startFrame) + { + this.anims.play(key, ignoreIfPlaying, startFrame); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Sprite#toJSON + * @since 3.0.0 + * + * @return {object} [description] + */ + toJSON: function () + { + var data = Components.ToJSON(this); + + // Extra Sprite data is added here + + return data; + } + +}); + +module.exports = Sprite; + + +/***/ }), +/* 41 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetColor = __webpack_require__(155); +var GetColor32 = __webpack_require__(335); /** * @classdesc @@ -4859,7 +5291,7 @@ var Color = new Class({ * An array containing the calculated color values for WebGL use. * * @name Phaser.Display.Color#gl - * @type {array} + * @type {number[]} * @since 3.0.0 */ this.gl = [ 0, 0, 0, 1 ]; @@ -4903,7 +5335,7 @@ var Color = new Class({ /** * Sets this color to be transparent. Sets all values to zero. * - * @method Phaser.Curves.Color#transparent + * @method Phaser.Display.Color#transparent * @since 3.0.0 * * @return {Phaser.Display.Color} This Color object. @@ -4921,7 +5353,7 @@ var Color = new Class({ /** * Sets the color of this Color component. * - * @method Phaser.Curves.Color#setTo + * @method Phaser.Display.Color#setTo * @since 3.0.0 * * @param {integer} red - The red color value. A number between 0 and 255. @@ -4946,7 +5378,7 @@ var Color = new Class({ /** * Sets the red, green, blue and alpha GL values of this Color component. * - * @method Phaser.Curves.Color#setGLTo + * @method Phaser.Display.Color#setGLTo * @since 3.0.0 * * @param {float} red - The red color value. A number between 0 and 1. @@ -4971,10 +5403,10 @@ var Color = new Class({ /** * Sets the color based on the color object given. * - * @method Phaser.Curves.Color#setFromRGB + * @method Phaser.Display.Color#setFromRGB * @since 3.0.0 * - * @param {object} color - An object containing `r`, `g`, `b` and optionally `a` values in the range 0 to 255. + * @param {InputColorObject} color - An object containing `r`, `g`, `b` and optionally `a` values in the range 0 to 255. * * @return {Phaser.Display.Color} This Color object. */ @@ -4995,7 +5427,7 @@ var Color = new Class({ /** * Updates the internal cache values. * - * @method Phaser.Curves.Color#update + * @method Phaser.Display.Color#update * @since 3.0.0 * * @return {Phaser.Display.Color} This Color object. @@ -5012,7 +5444,7 @@ var Color = new Class({ /** * Returns a new Color component using the values from this one. * - * @method Phaser.Curves.Color#clone + * @method Phaser.Display.Color#clone * @since 3.0.0 * * @return {Phaser.Display.Color} A new Color object. @@ -5024,7 +5456,7 @@ var Color = new Class({ /** * The color of this Color component, not including the alpha channel. - * + * * @name Phaser.Display.Color#color * @type {number} * @readOnly @@ -5041,7 +5473,7 @@ var Color = new Class({ /** * The color of this Color component, including the alpha channel. - * + * * @name Phaser.Display.Color#color32 * @type {number} * @readOnly @@ -5058,7 +5490,7 @@ var Color = new Class({ /** * The color of this Color component as a string which can be used in CSS color values. - * + * * @name Phaser.Display.Color#rgba * @type {string} * @readOnly @@ -5075,7 +5507,7 @@ var Color = new Class({ /** * The red color value, normalized to the range 0 to 1. - * + * * @name Phaser.Display.Color#redGL * @type {float} * @since 3.0.0 @@ -5100,7 +5532,7 @@ var Color = new Class({ /** * The green color value, normalized to the range 0 to 1. - * + * * @name Phaser.Display.Color#greenGL * @type {float} * @since 3.0.0 @@ -5125,7 +5557,7 @@ var Color = new Class({ /** * The blue color value, normalized to the range 0 to 1. - * + * * @name Phaser.Display.Color#blueGL * @type {float} * @since 3.0.0 @@ -5150,7 +5582,7 @@ var Color = new Class({ /** * The alpha color value, normalized to the range 0 to 1. - * + * * @name Phaser.Display.Color#alphaGL * @type {float} * @since 3.0.0 @@ -5175,9 +5607,9 @@ var Color = new Class({ /** * The red color value, normalized to the range 0 to 255. - * + * * @name Phaser.Display.Color#red - * @type {float} + * @type {number} * @since 3.0.0 */ red: { @@ -5202,9 +5634,9 @@ var Color = new Class({ /** * The green color value, normalized to the range 0 to 255. - * + * * @name Phaser.Display.Color#green - * @type {float} + * @type {number} * @since 3.0.0 */ green: { @@ -5229,9 +5661,9 @@ var Color = new Class({ /** * The blue color value, normalized to the range 0 to 255. - * + * * @name Phaser.Display.Color#blue - * @type {float} + * @type {number} * @since 3.0.0 */ blue: { @@ -5256,9 +5688,9 @@ var Color = new Class({ /** * The alpha color value, normalized to the range 0 to 255. - * + * * @name Phaser.Display.Color#alpha - * @type {float} + * @type {number} * @since 3.0.0 */ alpha: { @@ -5287,7 +5719,7 @@ module.exports = Color; /***/ }), -/* 37 */ +/* 42 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -5296,153 +5728,28 @@ module.exports = Color; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var GameObject = __webpack_require__(1); -var SpriteRender = __webpack_require__(457); +var CONST = __webpack_require__(16); /** - * @classdesc - * A Sprite Game Object. + * [description] * - * A Sprite Game Object is used for the display of both static and animated images in your game. - * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled - * and animated. - * - * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. - * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation - * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. - * - * @class Sprite - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor + * @function Phaser.Math.DegToRad * @since 3.0.0 * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.Animation - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible + * @param {integer} degrees - [description] * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @return {float} [description] */ -var Sprite = new Class({ +var DegToRad = function (degrees) +{ + return degrees * CONST.DEG_TO_RAD; +}; - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Size, - Components.Texture, - Components.Tint, - Components.Transform, - Components.Visible, - SpriteRender - ], - - initialize: - - function Sprite (scene, x, y, texture, frame) - { - GameObject.call(this, scene, 'Sprite'); - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite#anims - * @type {[type]} - * @since 3.0.0 - */ - this.anims = new Components.Animation(this); - - this.setTexture(texture, frame); - this.setPosition(x, y); - this.setSizeToFrame(); - this.setOriginFromFrame(); - this.initPipeline('TextureTintPipeline'); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Sprite#preUpdate - * @since 3.0.0 - * - * @param {number} time - [description] - * @param {number} delta - [description] - */ - preUpdate: function (time, delta) - { - this.anims.update(time, delta); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Sprite#play - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {boolean} ignoreIfPlaying - [description] - * @param {integer|string} startFrame - [description] - * - * @return {Phaser.GameObjects.Sprite} This Game Object. - */ - play: function (key, ignoreIfPlaying, startFrame) - { - this.anims.play(key, ignoreIfPlaying, startFrame); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Sprite#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - var data = Components.ToJSON(this); - - // Extra Sprite data is added here - - return data; - } - -}); - -module.exports = Sprite; +module.exports = DegToRad; /***/ }), -/* 38 */, -/* 39 */ +/* 43 */ /***/ (function(module, exports) { /** @@ -5452,99 +5759,29 @@ module.exports = Sprite; */ /** - * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the - * layer's position, scale and scroll. + * [description] * - * @function Phaser.Tilemaps.Components.WorldToTileX + * @function Phaser.Math.Wrap * @since 3.0.0 * - * @param {number} worldX - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {number} The X location in tile units. + * @param {number} value - [description] + * @param {number} min - [description] + * @param {number} max - [description] + * + * @return {number} [description] */ -var WorldToTileX = function (worldX, snapToFloor, camera, layer) +var Wrap = function (value, min, max) { - if (snapToFloor === undefined) { snapToFloor = true; } + var range = max - min; - var tileWidth = layer.baseTileWidth; - var tilemapLayer = layer.tilemapLayer; - - if (tilemapLayer) - { - if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } - - // Find the world position relative to the static or dynamic layer's top left origin, - // factoring in the camera's horizontal scroll - worldX = worldX - (tilemapLayer.x + camera.scrollX * (1 - tilemapLayer.scrollFactorX)); - - tileWidth *= tilemapLayer.scaleX; - } - - return snapToFloor - ? Math.floor(worldX / tileWidth) - : worldX / tileWidth; + return (min + ((((value - min) % range) + range) % range)); }; -module.exports = WorldToTileX; +module.exports = Wrap; /***/ }), -/* 40 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the - * layer's position, scale and scroll. - * - * @function Phaser.Tilemaps.Components.WorldToTileY - * @since 3.0.0 - * - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {number} The Y location in tile units. - */ -var WorldToTileY = function (worldY, snapToFloor, camera, layer) -{ - if (snapToFloor === undefined) { snapToFloor = true; } - - var tileHeight = layer.baseTileHeight; - var tilemapLayer = layer.tilemapLayer; - - if (tilemapLayer) - { - if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } - - // Find the world position relative to the static or dynamic layer's top left origin, - // factoring in the camera's vertical scroll - worldY = worldY - (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY)); - - tileHeight *= tilemapLayer.scaleY; - } - - return snapToFloor - ? Math.floor(worldY / tileHeight) - : worldY / tileHeight; -}; - -module.exports = WorldToTileY; - - -/***/ }), -/* 41 */ +/* 44 */ /***/ (function(module, exports) { /** @@ -5675,76 +5912,7 @@ module.exports = { /***/ }), -/* 42 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Distance.Between - * @since 3.0.0 - * - * @param {number} x1 - [description] - * @param {number} y1 - [description] - * @param {number} x2 - [description] - * @param {number} y2 - [description] - * - * @return {number} [description] - */ -var DistanceBetween = function (x1, y1, x2, y2) -{ - var dx = x1 - x2; - var dy = y1 - y2; - - return Math.sqrt(dx * dx + dy * dy); -}; - -module.exports = DistanceBetween; - - -/***/ }), -/* 43 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Internally used method to set the colliding state of a tile. This does not recalculate - * interesting faces. - * - * @function Phaser.Tilemaps.Components.SetTileCollision - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.Tile} tile - [description] - * @param {boolean} [collides=true] - [description] - */ -var SetTileCollision = function (tile, collides) -{ - if (collides) - { - tile.setCollision(true, true, true, true, false); - } - else - { - tile.resetCollision(false); - } -}; - -module.exports = SetTileCollision; - - -/***/ }), -/* 44 */ +/* 45 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -5754,8 +5922,8 @@ module.exports = SetTileCollision; */ var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var Rectangle = __webpack_require__(307); +var Components = __webpack_require__(13); +var Rectangle = __webpack_require__(234); /** * @classdesc @@ -5767,7 +5935,7 @@ var Rectangle = __webpack_require__(307); * @memberOf Phaser.Tilemaps * @constructor * @since 3.0.0 - * + * * @extends Phaser.GameObjects.Components.Alpha * @extends Phaser.GameObjects.Components.Flip * @extends Phaser.GameObjects.Components.Visible @@ -5799,7 +5967,7 @@ var Tile = new Class({ { /** * The LayerData in the Tilemap data that this tile belongs to. - * + * * @name Phaser.Tilemaps.Tile#layer * @type {Phaser.Tilemaps.LayerData} * @since 3.0.0 @@ -5809,7 +5977,7 @@ var Tile = new Class({ /** * The index of this tile within the map data corresponding to the tileset, or -1 if this * represents a blank tile. - * + * * @name Phaser.Tilemaps.Tile#index * @type {integer} * @since 3.0.0 @@ -5818,7 +5986,7 @@ var Tile = new Class({ /** * The x map coordinate of this tile in tile units. - * + * * @name Phaser.Tilemaps.Tile#x * @type {integer} * @since 3.0.0 @@ -5827,7 +5995,7 @@ var Tile = new Class({ /** * The y map coordinate of this tile in tile units. - * + * * @name Phaser.Tilemaps.Tile#y * @type {integer} * @since 3.0.0 @@ -5836,7 +6004,7 @@ var Tile = new Class({ /** * The width of the tile in pixels. - * + * * @name Phaser.Tilemaps.Tile#width * @type {integer} * @since 3.0.0 @@ -5845,7 +6013,7 @@ var Tile = new Class({ /** * The height of the tile in pixels. - * + * * @name Phaser.Tilemaps.Tile#height * @type {integer} * @since 3.0.0 @@ -5855,7 +6023,7 @@ var Tile = new Class({ /** * The map's base width of a tile in pixels. Tiled maps support multiple tileset sizes * within one map, but they are still placed at intervals of the base tile size. - * + * * @name Phaser.Tilemaps.Tile#baseWidth * @type {integer} * @since 3.0.0 @@ -5865,7 +6033,7 @@ var Tile = new Class({ /** * The map's base height of a tile in pixels. Tiled maps support multiple tileset sizes * within one map, but they are still placed at intervals of the base tile size. - * + * * @name Phaser.Tilemaps.Tile#baseHeight * @type {integer} * @since 3.0.0 @@ -5876,7 +6044,7 @@ var Tile = new Class({ * The x coordinate of the top left of this tile in pixels. This is relative to the top left * of the layer this tile is being rendered within. This property does NOT factor in camera * scroll, layer scale or layer position. - * + * * @name Phaser.Tilemaps.Tile#pixelX * @type {number} * @since 3.0.0 @@ -5887,7 +6055,7 @@ var Tile = new Class({ * The y coordinate of the top left of this tile in pixels. This is relative to the top left * of the layer this tile is being rendered within. This property does NOT factor in camera * scroll, layer scale or layer position. - * + * * @name Phaser.Tilemaps.Tile#pixelY * @type {number} * @since 3.0.0 @@ -5898,7 +6066,7 @@ var Tile = new Class({ /** * Tile specific properties. These usually come from Tiled. - * + * * @name Phaser.Tilemaps.Tile#properties * @type {object} * @since 3.0.0 @@ -5907,7 +6075,7 @@ var Tile = new Class({ /** * The rotation angle of this tile. - * + * * @name Phaser.Tilemaps.Tile#rotation * @type {number} * @since 3.0.0 @@ -5916,7 +6084,7 @@ var Tile = new Class({ /** * Whether the tile should collide with any object on the left side. - * + * * @name Phaser.Tilemaps.Tile#collideLeft * @type {boolean} * @since 3.0.0 @@ -5925,7 +6093,7 @@ var Tile = new Class({ /** * Whether the tile should collide with any object on the right side. - * + * * @name Phaser.Tilemaps.Tile#collideRight * @type {boolean} * @since 3.0.0 @@ -5934,7 +6102,7 @@ var Tile = new Class({ /** * Whether the tile should collide with any object on the top side. - * + * * @name Phaser.Tilemaps.Tile#collideUp * @type {boolean} * @since 3.0.0 @@ -5943,7 +6111,7 @@ var Tile = new Class({ /** * Whether the tile should collide with any object on the bottom side. - * + * * @name Phaser.Tilemaps.Tile#collideDown * @type {boolean} * @since 3.0.0 @@ -5952,7 +6120,7 @@ var Tile = new Class({ /** * Whether the tile's left edge is interesting for collisions. - * + * * @name Phaser.Tilemaps.Tile#faceLeft * @type {boolean} * @since 3.0.0 @@ -5961,7 +6129,7 @@ var Tile = new Class({ /** * Whether the tile's right edge is interesting for collisions. - * + * * @name Phaser.Tilemaps.Tile#faceRight * @type {boolean} * @since 3.0.0 @@ -5970,7 +6138,7 @@ var Tile = new Class({ /** * Whether the tile's top edge is interesting for collisions. - * + * * @name Phaser.Tilemaps.Tile#faceTop * @type {boolean} * @since 3.0.0 @@ -5979,7 +6147,7 @@ var Tile = new Class({ /** * Whether the tile's bottom edge is interesting for collisions. - * + * * @name Phaser.Tilemaps.Tile#faceBottom * @type {boolean} * @since 3.0.0 @@ -5988,7 +6156,7 @@ var Tile = new Class({ /** * Tile collision callback. - * + * * @name Phaser.Tilemaps.Tile#collisionCallback * @type {function} * @since 3.0.0 @@ -5997,7 +6165,7 @@ var Tile = new Class({ /** * The context in which the collision callback will be called. - * + * * @name Phaser.Tilemaps.Tile#collisionCallbackContext * @type {object} * @since 3.0.0 @@ -6007,7 +6175,7 @@ var Tile = new Class({ /** * The tint to apply to this tile. Note: tint is currently a single color value instead of * the 4 corner tint component on other GameObjects. - * + * * @name Phaser.Tilemaps.Tile#tint * @type {number} * @default @@ -6017,7 +6185,7 @@ var Tile = new Class({ /** * An empty object where physics-engine specific information (e.g. bodies) may be stored. - * + * * @name Phaser.Tilemaps.Tile#physics * @type {object} * @since 3.0.0 @@ -6031,10 +6199,10 @@ var Tile = new Class({ * * @method Phaser.Tilemaps.Tile#containsPoint * @since 3.0.0 - * + * * @param {number} x - The x coordinate to test. * @param {number} y - The y coordinate to test. - * + * * @return {boolean} True if the coordinates are within this Tile, otherwise false. */ containsPoint: function (x, y) @@ -6048,9 +6216,9 @@ var Tile = new Class({ * * @method Phaser.Tilemaps.Tile#containsPoint * @since 3.0.0 - * + * * @param {Phaser.Tilemaps.Tile} tile - The tile to copy from. - * + * * @return {Phaser.Tilemaps.Tile} This Tile object. */ copy: function (tile) @@ -6076,11 +6244,11 @@ var Tile = new Class({ * The collision group for this Tile, defined within the Tileset. This returns a reference to * the collision group stored within the Tileset, so any modification of the returned object * will impact all tiles that have the same index as this tile. - * + * * @method Phaser.Tilemaps.Tile#getCollisionGroup * @since 3.0.0 - * - * @return {object|null} tileset + * + * @return {?object} tileset */ getCollisionGroup: function () { @@ -6092,11 +6260,11 @@ var Tile = new Class({ * collision data, tile animations and terrain information. This returns a reference to the tile * data stored within the Tileset, so any modification of the returned object will impact all * tiles that have the same index as this tile. - * + * * @method Phaser.Tilemaps.Tile#getTileData * @since 3.0.0 - * - * @return {object|null} tileset + * + * @return {?object} tileset */ getTileData: function () { @@ -6106,12 +6274,12 @@ var Tile = new Class({ /** * Gets the world X position of the left side of the tile, factoring in the layers position, * scale and scroll. - * + * * @method Phaser.Tilemaps.Tile#getLeft * @since 3.0.0 - * + * * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to use to perform the check. - * + * * @return {number} */ getLeft: function (camera) @@ -6124,12 +6292,12 @@ var Tile = new Class({ /** * Gets the world X position of the right side of the tile, factoring in the layer's position, * scale and scroll. - * + * * @method Phaser.Tilemaps.Tile#getRight * @since 3.0.0 - * + * * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to use to perform the check. - * + * * @return {number} */ getRight: function (camera) @@ -6142,12 +6310,12 @@ var Tile = new Class({ /** * Gets the world Y position of the top side of the tile, factoring in the layer's position, * scale and scroll. - * + * * @method Phaser.Tilemaps.Tile#getTop * @since 3.0.0 - * + * * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to use to perform the check. - * + * * @return {number} */ getTop: function (camera) @@ -6168,9 +6336,9 @@ var Tile = new Class({ * @method Phaser.Tilemaps.Tile#getBottom * @since 3.0.0 - * + * * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to use to perform the check. - * + * * @return {number} */ getBottom: function (camera) @@ -6185,14 +6353,14 @@ var Tile = new Class({ /** * Gets the world rectangle bounding box for the tile, factoring in the layers position, * scale and scroll. - * + * * @method Phaser.Tilemaps.Tile#getBounds * @since 3.0.0 - * + * * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to use to perform the check. * @param {object} [output] - [description] - * - * @return {Phaser.Geom.Rectangle|object} + * + * @return {(Phaser.Geom.Rectangle|object)} */ getBounds: function (camera, output) { @@ -6209,12 +6377,12 @@ var Tile = new Class({ /** * Gets the world X position of the center of the tile, factoring in the layer's position, * scale and scroll. - * + * * @method Phaser.Tilemaps.Tile#getCenterX * @since 3.0.0 - * + * * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to use to perform the check. - * + * * @return {number} */ getCenterX: function (camera) @@ -6225,12 +6393,12 @@ var Tile = new Class({ /** * Gets the world Y position of the center of the tile, factoring in the layer's position, * scale and scroll. - * + * * @method Phaser.Tilemaps.Tile#getCenterY * @since 3.0.0 - * + * * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to use to perform the check. - * + * * @return {number} */ getCenterY: function (camera) @@ -6240,7 +6408,7 @@ var Tile = new Class({ /** * Clean up memory. - * + * * @method Phaser.Tilemaps.Tile#destroy * @since 3.0.0 */ @@ -6257,12 +6425,12 @@ var Tile = new Class({ * * @method Phaser.Tilemaps.Tile#intersects * @since 3.0.0 - * + * * @param {number} x - The x axis in pixels. * @param {number} y - The y axis in pixels. * @param {number} right - The right point. * @param {number} bottom - The bottom point. - * + * * @return {boolean} */ intersects: function (x, y, right, bottom) @@ -6275,13 +6443,13 @@ var Tile = new Class({ /** * Checks if the tile is interesting. - * + * * @method Phaser.Tilemaps.Tile#isInteresting * @since 3.0.0 * * @param {boolean} collides - If true, will consider the tile interesting if it collides on any side. * @param {boolean} faces - If true, will consider the tile interesting if it has an interesting face. - * + * * @return {boolean} True if the Tile is interesting, otherwise false. */ isInteresting: function (collides, faces) @@ -6297,9 +6465,9 @@ var Tile = new Class({ * * @method Phaser.Tilemaps.Tile#resetCollision * @since 3.0.0 - * + * * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate interesting faces for this tile and its neighbors. - * + * * @return {Phaser.Tilemaps.Tile} This Tile object. */ resetCollision: function (recalculateFaces) @@ -6331,7 +6499,7 @@ var Tile = new Class({ /** * Reset faces. - * + * * @method Phaser.Tilemaps.Tile#resetFaces * @since 3.0.0 * @@ -6349,7 +6517,7 @@ var Tile = new Class({ /** * Sets the collision flags for each side of this tile and updates the interesting faces list. - * + * * @method Phaser.Tilemaps.Tile#setCollision * @since 3.0.0 * @@ -6359,7 +6527,7 @@ var Tile = new Class({ * @param {boolean} [down] - Indicating collide with any object on the bottom. * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate interesting faces * for this tile and its neighbors. - * + * * @return {Phaser.Tilemaps.Tile} This Tile object. */ setCollision: function (left, right, up, down, recalculateFaces) @@ -6395,13 +6563,13 @@ var Tile = new Class({ /** * Set a callback to be called when this tile is hit by an object. The callback must true for * collision processing to take place. - * + * * @method Phaser.Tilemaps.Tile#setCollisionCallback * @since 3.0.0 * * @param {function} callback - Callback function. * @param {object} context - Callback will be called within this context. - * + * * @return {Phaser.Tilemaps.Tile} This Tile object. */ setCollisionCallback: function (callback, context) @@ -6422,7 +6590,7 @@ var Tile = new Class({ /** * Sets the size of the tile and updates its pixelX and pixelY. - * + * * @method Phaser.Tilemaps.Tile#setSize * @since 3.0.0 * @@ -6430,7 +6598,7 @@ var Tile = new Class({ * @param {integer} tileHeight - The height of the tile in pixels. * @param {integer} baseWidth - The base width a tile in the map (in pixels). * @param {integer} baseHeight - The base height of the tile in pixels (in pixels). - * + * * @return {Phaser.Tilemaps.Tile} This Tile object. */ setSize: function (tileWidth, tileHeight, baseWidth, baseHeight) @@ -6447,7 +6615,7 @@ var Tile = new Class({ /** * Used internally. Updates the tile's world XY position based on the current tile size. - * + * * @method Phaser.Tilemaps.Tile#updatePixelXY * @since 3.0.0 * @@ -6466,7 +6634,7 @@ var Tile = new Class({ /** * True if this tile can collide on any of its faces or has a collision callback set. - * + * * @name Phaser.Tilemaps.Tile#canCollide * @type {boolean} * @readOnly @@ -6481,7 +6649,7 @@ var Tile = new Class({ /** * True if this tile can collide on any of its faces. - * + * * @name Phaser.Tilemaps.Tile#collides * @type {boolean} * @readOnly @@ -6496,7 +6664,7 @@ var Tile = new Class({ /** * True if this tile has any interesting faces. - * + * * @name Phaser.Tilemaps.Tile#hasInterestingFace * @type {boolean} * @readOnly @@ -6512,7 +6680,7 @@ var Tile = new Class({ /** * The tileset that contains this Tile. This will only return null if accessed from a LayerData * instance before the tile is placed within a StaticTilemapLayer or DynamicTilemapLayer. - * + * * @name Phaser.Tilemaps.Tile#tileset * @type {?Phaser.Tilemaps.Tileset} * @readOnly @@ -6530,9 +6698,9 @@ var Tile = new Class({ * The tilemap layer that contains this Tile. This will only return null if accessed from a * LayerData instance before the tile is placed within a StaticTilemapLayer or * DynamicTilemapLayer. - * + * * @name Phaser.Tilemaps.Tile#tilemapLayer - * @type {Phaser.Tilemaps.StaticTilemapLayer|Phaser.Tilemaps.DynamicTilemapLayer|null} + * @type {?Phaser.Tilemaps.StaticTilemapLayer|Phaser.Tilemaps.DynamicTilemapLayer} * @readOnly * @since 3.0.0 */ @@ -6546,7 +6714,7 @@ var Tile = new Class({ /** * The tilemap that contains this Tile. This will only return null if accessed from a LayerData * instance before the tile is placed within a StaticTilemapLayer or DynamicTilemapLayer. - * + * * @name Phaser.Tilemaps.Tile#tilemap * @type {?Phaser.Tilemaps.Tilemap} * @readOnly @@ -6565,187 +6733,6 @@ var Tile = new Class({ module.exports = Tile; -/***/ }), -/* 45 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.BlendModes - */ - -module.exports = { - - /** - * Skips the Blend Mode check in the renderer. - * - * @name Phaser.BlendModes.SKIP_CHECK - * @type {integer} - * @since 3.0.0 - */ - SKIP_CHECK: -1, - - /** - * Normal blend mode. - * - * @name Phaser.BlendModes.NORMAL - * @type {integer} - * @since 3.0.0 - */ - NORMAL: 0, - - /** - * Add blend mode. - * - * @name Phaser.BlendModes.ADD - * @type {integer} - * @since 3.0.0 - */ - ADD: 1, - - /** - * Multiply blend mode. - * - * @name Phaser.BlendModes.MULTIPLY - * @type {integer} - * @since 3.0.0 - */ - MULTIPLY: 2, - - /** - * Screen blend mode. - * - * @name Phaser.BlendModes.SCREEN - * @type {integer} - * @since 3.0.0 - */ - SCREEN: 3, - - /** - * Overlay blend mode. - * - * @name Phaser.BlendModes.OVERLAY - * @type {integer} - * @since 3.0.0 - */ - OVERLAY: 4, - - /** - * Darken blend mode. - * - * @name Phaser.BlendModes.DARKEN - * @type {integer} - * @since 3.0.0 - */ - DARKEN: 5, - - /** - * Lighten blend mode. - * - * @name Phaser.BlendModes.LIGHTEN - * @type {integer} - * @since 3.0.0 - */ - LIGHTEN: 6, - - /** - * Color Dodge blend mode. - * - * @name Phaser.BlendModes.COLOR_DODGE - * @type {integer} - * @since 3.0.0 - */ - COLOR_DODGE: 7, - - /** - * Color Burn blend mode. - * - * @name Phaser.BlendModes.COLOR_BURN - * @type {integer} - * @since 3.0.0 - */ - COLOR_BURN: 8, - - /** - * Hard Light blend mode. - * - * @name Phaser.BlendModes.HARD_LIGHT - * @type {integer} - * @since 3.0.0 - */ - HARD_LIGHT: 9, - - /** - * Soft Light blend mode. - * - * @name Phaser.BlendModes.SOFT_LIGHT - * @type {integer} - * @since 3.0.0 - */ - SOFT_LIGHT: 10, - - /** - * Difference blend mode. - * - * @name Phaser.BlendModes.DIFFERENCE - * @type {integer} - * @since 3.0.0 - */ - DIFFERENCE: 11, - - /** - * Exclusion blend mode. - * - * @name Phaser.BlendModes.EXCLUSION - * @type {integer} - * @since 3.0.0 - */ - EXCLUSION: 12, - - /** - * Hue blend mode. - * - * @name Phaser.BlendModes.HUE - * @type {integer} - * @since 3.0.0 - */ - HUE: 13, - - /** - * Saturation blend mode. - * - * @name Phaser.BlendModes.SATURATION - * @type {integer} - * @since 3.0.0 - */ - SATURATION: 14, - - /** - * Color blend mode. - * - * @name Phaser.BlendModes.COLOR - * @type {integer} - * @since 3.0.0 - */ - COLOR: 15, - - /** - * Luminosity blend mode. - * - * @name Phaser.BlendModes.LUMINOSITY - * @type {integer} - * @since 3.0.0 - */ - LUMINOSITY: 16 - -}; - - /***/ }), /* 46 */ /***/ (function(module, exports) { @@ -6757,21 +6744,28 @@ module.exports = { */ /** - * Returns the center x coordinate from the bounds of the Game Object. + * Internally used method to set the colliding state of a tile. This does not recalculate + * interesting faces. * - * @function Phaser.Display.Bounds.GetCenterX + * @function Phaser.Tilemaps.Components.SetTileCollision * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The center x coordinate of the bounds of the Game Object. + * @param {Phaser.Tilemaps.Tile} tile - [description] + * @param {boolean} [collides=true] - [description] */ -var GetCenterX = function (gameObject) +var SetTileCollision = function (tile, collides) { - return gameObject.x - (gameObject.width * gameObject.originX) + (gameObject.width * 0.5); + if (collides) + { + tile.setCollision(true, true, true, true, false); + } + else + { + tile.resetCollision(false); + } }; -module.exports = GetCenterX; +module.exports = SetTileCollision; /***/ }), @@ -6784,94 +6778,96 @@ module.exports = GetCenterX; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * Positions the Game Object so that the center top of its bounds aligns with the given coordinate. - * - * @function Phaser.Display.Bounds.SetCenterX - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} x - The coordinate to position the Game Object bounds on. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. - */ -var SetCenterX = function (gameObject, x) -{ - var offsetX = gameObject.width * gameObject.originX; +module.exports = { - gameObject.x = (x + offsetX) - (gameObject.width * 0.5); + /** + * [description] + * + * @name Phaser.Physics.Arcade.DYNAMIC_BODY + * @type {number} + * @since 3.0.0 + */ + DYNAMIC_BODY: 0, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.STATIC_BODY + * @type {number} + * @since 3.0.0 + */ + STATIC_BODY: 1, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.GROUP + * @type {number} + * @since 3.0.0 + */ + GROUP: 2, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.TILEMAPLAYER + * @type {number} + * @since 3.0.0 + */ + TILEMAPLAYER: 3, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.FACING_NONE + * @type {number} + * @since 3.0.0 + */ + FACING_NONE: 10, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.FACING_UP + * @type {number} + * @since 3.0.0 + */ + FACING_UP: 11, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.FACING_DOWN + * @type {number} + * @since 3.0.0 + */ + FACING_DOWN: 12, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.FACING_LEFT + * @type {number} + * @since 3.0.0 + */ + FACING_LEFT: 13, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.FACING_RIGHT + * @type {number} + * @since 3.0.0 + */ + FACING_RIGHT: 14 - return gameObject; }; -module.exports = SetCenterX; - /***/ }), /* 48 */ /***/ (function(module, exports) { -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Positions the Game Object so that the center top of its bounds aligns with the given coordinate. - * - * @function Phaser.Display.Bounds.SetCenterY - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} y - The coordinate to position the Game Object bounds on. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. - */ -var SetCenterY = function (gameObject, y) -{ - var offsetY = gameObject.height * gameObject.originY; - - gameObject.y = (y + offsetY) - (gameObject.height * 0.5); - - return gameObject; -}; - -module.exports = SetCenterY; - - -/***/ }), -/* 49 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the center y coordinate from the bounds of the Game Object. - * - * @function Phaser.Display.Bounds.GetCenterY - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The center y coordinate of the bounds of the Game Object. - */ -var GetCenterY = function (gameObject) -{ - return gameObject.y - (gameObject.height * gameObject.originY) + (gameObject.height * 0.5); -}; - -module.exports = GetCenterY; - - -/***/ }), -/* 50 */ -/***/ (function(module, exports) { - /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. @@ -6881,23 +6877,198 @@ module.exports = GetCenterY; /** * [description] * - * @function Phaser.Math.Wrap + * @function Phaser.Math.Distance.Between * @since 3.0.0 * - * @param {number} value - [description] - * @param {number} min - [description] - * @param {number} max - [description] + * @param {number} x1 - [description] + * @param {number} y1 - [description] + * @param {number} x2 - [description] + * @param {number} y2 - [description] * * @return {number} [description] */ -var Wrap = function (value, min, max) +var DistanceBetween = function (x1, y1, x2, y2) { - var range = max - min; + var dx = x1 - x2; + var dy = y1 - y2; - return (min + ((((value - min) % range) + range) % range)); + return Math.sqrt(dx * dx + dy * dy); }; -module.exports = Wrap; +module.exports = DistanceBetween; + + +/***/ }), +/* 49 */, +/* 50 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); + +/** + * @classdesc + * [description] + * + * @class ImageFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * @param {object} config - [description] + */ +var ImageFile = new Class({ + + Extends: File, + + initialize: + + // this.load.image('pic', 'assets/pics/taikodrummaster.jpg'); + // this.load.image({ key: 'pic', file: 'assets/pics/taikodrummaster.jpg' }); + // this.load.image({ + // key: 'bunny', + // file: 'assets/sprites/bunny.png', + // xhr: { + // user: 'root', + // password: 'th3G1bs0n', + // timeout: 30, + // header: 'Content-Type', + // headerValue: 'text/xml' + // } + // }); + // this.load.image({ key: 'bunny' }); + // this.load.image({ key: 'bunny', extension: 'jpg' }); + + function ImageFile (key, url, path, xhrSettings, config) + { + var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); + + var fileConfig = { + type: 'image', + extension: GetFastValue(key, 'extension', 'png'), + responseType: 'blob', + key: fileKey, + url: GetFastValue(key, 'file', url), + path: path, + xhrSettings: GetFastValue(key, 'xhr', xhrSettings), + config: GetFastValue(key, 'config', config) + }; + + File.call(this, fileConfig); + }, + + onProcess: function (callback) + { + this.state = CONST.FILE_PROCESSING; + + this.data = new Image(); + + this.data.crossOrigin = this.crossOrigin; + + var _this = this; + + this.data.onload = function () + { + File.revokeObjectURL(_this.data); + + _this.onComplete(); + + callback(_this); + }; + + this.data.onerror = function () + { + File.revokeObjectURL(_this.data); + + _this.state = CONST.FILE_ERRORED; + + callback(_this); + }; + + File.createObjectURL(this.data, this.xhrLoader.response, 'image/png'); + } + +}); + +/** + * Adds an Image file to the current load queue. + * + * Note: This method will only be available if the Image File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#image + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('image', function (key, url, xhrSettings) +{ + var urls; + var fileA; + var fileB; + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + urls = GetFastValue(key[i], 'file', url); + + if (Array.isArray(urls) && urls.length === 2) + { + fileA = this.addFile(new ImageFile(key[i], urls[0], this.path, xhrSettings)); + fileB = this.addFile(new ImageFile(key[i], urls[1], this.path, xhrSettings)); + + fileA.setLinkFile(fileB, 'dataimage'); + } + else + { + this.addFile(new ImageFile(key[i], url, this.path, xhrSettings)); + } + } + } + else + { + urls = GetFastValue(key, 'file', url); + + if (Array.isArray(urls) && urls.length === 2) + { + fileA = this.addFile(new ImageFile(key, urls[0], this.path, xhrSettings)); + fileB = this.addFile(new ImageFile(key, urls[1], this.path, xhrSettings)); + + fileA.setLinkFile(fileB, 'dataimage'); + } + else + { + this.addFile(new ImageFile(key, url, this.path, xhrSettings)); + } + } + + // For method chaining + return this; +}); + +module.exports = ImageFile; /***/ }), @@ -6910,778 +7081,110 @@ module.exports = Wrap; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji -// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl - var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); /** * @classdesc * [description] * - * @class Vector3 - * @memberOf Phaser.Math + * @class JSONFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * - * @param {number} [x] - [description] - * @param {number} [y] - [description] - * @param {number} [z] - [description] + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {XHRSettingsObject} xhrSettings - [description] */ -var Vector3 = new Class({ +var JSONFile = new Class({ + + Extends: File, initialize: - function Vector3 (x, y, z) + // url can either be a string, in which case it is treated like a proper url, or an object, in which case it is treated as a ready-made JS Object + + function JSONFile (key, url, path, xhrSettings) { - /** - * The x component of this Vector. - * - * @name Phaser.Math.Vector3#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ + var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); - /** - * The y component of this Vector. - * - * @name Phaser.Math.Vector3#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ + var fileConfig = { + type: 'json', + extension: GetFastValue(key, 'extension', 'json'), + responseType: 'text', + key: fileKey, + url: GetFastValue(key, 'file', url), + path: path, + xhrSettings: GetFastValue(key, 'xhr', xhrSettings) + }; - /** - * The z component of this Vector. - * - * @name Phaser.Math.Vector3#z - * @type {number} - * @default 0 - * @since 3.0.0 - */ + File.call(this, fileConfig); - if (typeof x === 'object') + if (typeof fileConfig.url === 'object') { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; + // Object provided instead of a URL, so no need to actually load it (populate data with value) + this.data = fileConfig.url; + + this.state = CONST.FILE_POPULATED; } }, - /** - * [description] - * - * @method Phaser.Math.Vector3#up - * @since 3.0.0 - * - * @return {[type]} [description] - */ - up: function () + onProcess: function (callback) { - this.x = 0; - this.y = 1; - this.z = 0; + this.state = CONST.FILE_PROCESSING; - return this; - }, + this.data = JSON.parse(this.xhrLoader.responseText); - /** - * [description] - * - * @method Phaser.Math.Vector3#clone - * @since 3.0.0 - * - * @return {[type]} [description] - */ - clone: function () - { - return new Vector3(this.x, this.y, this.z); - }, + this.onComplete(); - /** - * [description] - * - * @method Phaser.Math.Vector3#crossVectors - * @since 3.0.0 - * - * @param {[type]} a - [description] - * @param {[type]} b - [description] - * - * @return {[type]} [description] - */ - crossVectors: function (a, b) - { - var ax = a.x; - var ay = a.y; - var az = a.z; - var bx = b.x; - var by = b.y; - var bz = b.z; - - this.x = ay * bz - az * by; - this.y = az * bx - ax * bz; - this.z = ax * by - ay * bx; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#equals - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - equals: function (v) - { - return ((this.x === v.x) && (this.y === v.y) && (this.z === v.z)); - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#copy - * @since 3.0.0 - * - * @param {[type]} src - [description] - * - * @return {[type]} [description] - */ - copy: function (src) - { - this.x = src.x; - this.y = src.y; - this.z = src.z || 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#set - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} z - [description] - * - * @return {[type]} [description] - */ - set: function (x, y, z) - { - if (typeof x === 'object') - { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#add - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - add: function (v) - { - this.x += v.x; - this.y += v.y; - this.z += v.z || 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#subtract - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - subtract: function (v) - { - this.x -= v.x; - this.y -= v.y; - this.z -= v.z || 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#multiply - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - multiply: function (v) - { - this.x *= v.x; - this.y *= v.y; - this.z *= v.z || 1; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#scale - * @since 3.0.0 - * - * @param {[type]} scale - [description] - * - * @return {[type]} [description] - */ - scale: function (scale) - { - if (isFinite(scale)) - { - this.x *= scale; - this.y *= scale; - this.z *= scale; - } - else - { - this.x = 0; - this.y = 0; - this.z = 0; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#divide - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - divide: function (v) - { - this.x /= v.x; - this.y /= v.y; - this.z /= v.z || 1; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#negate - * @since 3.0.0 - * - * @return {[type]} [description] - */ - negate: function () - { - this.x = -this.x; - this.y = -this.y; - this.z = -this.z; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#distance - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - distance: function (v) - { - var dx = v.x - this.x; - var dy = v.y - this.y; - var dz = v.z - this.z || 0; - - return Math.sqrt(dx * dx + dy * dy + dz * dz); - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#distanceSq - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - distanceSq: function (v) - { - var dx = v.x - this.x; - var dy = v.y - this.y; - var dz = v.z - this.z || 0; - - return dx * dx + dy * dy + dz * dz; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#length - * @since 3.0.0 - * - * @return {[type]} [description] - */ - length: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - - return Math.sqrt(x * x + y * y + z * z); - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#lengthSq - * @since 3.0.0 - * - * @return {[type]} [description] - */ - lengthSq: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - - return x * x + y * y + z * z; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#normalize - * @since 3.0.0 - * - * @return {[type]} [description] - */ - normalize: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var len = x * x + y * y + z * z; - - if (len > 0) - { - len = 1 / Math.sqrt(len); - - this.x = x * len; - this.y = y * len; - this.z = z * len; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#dot - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - dot: function (v) - { - return this.x * v.x + this.y * v.y + this.z * v.z; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#cross - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - cross: function (v) - { - var ax = this.x; - var ay = this.y; - var az = this.z; - var bx = v.x; - var by = v.y; - var bz = v.z; - - this.x = ay * bz - az * by; - this.y = az * bx - ax * bz; - this.z = ax * by - ay * bx; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#lerp - * @since 3.0.0 - * - * @param {[type]} v - [description] - * @param {[type]} t - [description] - * - * @return {[type]} [description] - */ - lerp: function (v, t) - { - if (t === undefined) { t = 0; } - - var ax = this.x; - var ay = this.y; - var az = this.z; - - this.x = ax + t * (v.x - ax); - this.y = ay + t * (v.y - ay); - this.z = az + t * (v.z - az); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#transformMat3 - * @since 3.0.0 - * - * @param {[type]} mat - [description] - * - * @return {[type]} [description] - */ - transformMat3: function (mat) - { - var x = this.x; - var y = this.y; - var z = this.z; - var m = mat.val; - - this.x = x * m[0] + y * m[3] + z * m[6]; - this.y = x * m[1] + y * m[4] + z * m[7]; - this.z = x * m[2] + y * m[5] + z * m[8]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#transformMat4 - * @since 3.0.0 - * - * @param {[type]} mat - [description] - * - * @return {[type]} [description] - */ - transformMat4: function (mat) - { - var x = this.x; - var y = this.y; - var z = this.z; - var m = mat.val; - - this.x = m[0] * x + m[4] * y + m[8] * z + m[12]; - this.y = m[1] * x + m[5] * y + m[9] * z + m[13]; - this.z = m[2] * x + m[6] * y + m[10] * z + m[14]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#transformCoordinates - * @since 3.0.0 - * - * @param {[type]} mat - [description] - * - * @return {[type]} [description] - */ - transformCoordinates: function (mat) - { - var x = this.x; - var y = this.y; - var z = this.z; - var m = mat.val; - - var tx = (x * m[0]) + (y * m[4]) + (z * m[8]) + m[12]; - var ty = (x * m[1]) + (y * m[5]) + (z * m[9]) + m[13]; - var tz = (x * m[2]) + (y * m[6]) + (z * m[10]) + m[14]; - var tw = (x * m[3]) + (y * m[7]) + (z * m[11]) + m[15]; - - this.x = tx / tw; - this.y = ty / tw; - this.z = tz / tw; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#transformQuat - * @since 3.0.0 - * - * @param {[type]} q - [description] - * - * @return {[type]} [description] - */ - transformQuat: function (q) - { - // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations - var x = this.x; - var y = this.y; - var z = this.z; - var qx = q.x; - var qy = q.y; - var qz = q.z; - var qw = q.w; - - // calculate quat * vec - var ix = qw * x + qy * z - qz * y; - var iy = qw * y + qz * x - qx * z; - var iz = qw * z + qx * y - qy * x; - var iw = -qx * x - qy * y - qz * z; - - // calculate result * inverse quat - this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; - this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; - this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; - - return this; - }, - - /** - * Multiplies this Vector3 by the specified matrix, - * applying a W divide. This is useful for projection, - * e.g. unprojecting a 2D point into 3D space. - * - * @method project - * @param {Matrix4} the 4x4 matrix to multiply with - * @return {Vector3} this object for chaining - */ - /** - * [description] - * - * @method Phaser.Math.Vector3#project - * @since 3.0.0 - * - * @param {[type]} mat - [description] - * - * @return {[type]} [description] - */ - project: function (mat) - { - var x = this.x; - var y = this.y; - var z = this.z; - var m = mat.val; - - var a00 = m[0]; - var a01 = m[1]; - var a02 = m[2]; - var a03 = m[3]; - var a10 = m[4]; - var a11 = m[5]; - var a12 = m[6]; - var a13 = m[7]; - var a20 = m[8]; - var a21 = m[9]; - var a22 = m[10]; - var a23 = m[11]; - var a30 = m[12]; - var a31 = m[13]; - var a32 = m[14]; - var a33 = m[15]; - - var lw = 1 / (x * a03 + y * a13 + z * a23 + a33); - - this.x = (x * a00 + y * a10 + z * a20 + a30) * lw; - this.y = (x * a01 + y * a11 + z * a21 + a31) * lw; - this.z = (x * a02 + y * a12 + z * a22 + a32) * lw; - - return this; - }, - - /** - * Unproject this point from 2D space to 3D space. - * The point should have its x and y properties set to - * 2D screen space, and the z either at 0 (near plane) - * or 1 (far plane). The provided matrix is assumed to already - * be combined, i.e. projection * view * model. - * - * After this operation, this vector's (x, y, z) components will - * represent the unprojected 3D coordinate. - * - * @param {Vector4} viewport screen x, y, width and height in pixels - * @param {Matrix4} invProjectionView combined projection and view matrix - * @return {Vector3} this object, for chaining - */ - /** - * [description] - * - * @method Phaser.Math.Vector3#unproject - * @since 3.0.0 - * - * @param {[type]} viewport - [description] - * @param {[type]} invProjectionView - [description] - * - * @return {[type]} [description] - */ - unproject: function (viewport, invProjectionView) - { - var viewX = viewport.x; - var viewY = viewport.y; - var viewWidth = viewport.z; - var viewHeight = viewport.w; - - var x = this.x - viewX; - var y = (viewHeight - this.y - 1) - viewY; - var z = this.z; - - this.x = (2 * x) / viewWidth - 1; - this.y = (2 * y) / viewHeight - 1; - this.z = 2 * z - 1; - - return this.project(invProjectionView); - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#reset - * @since 3.0.0 - * - * @return {[type]} [description] - */ - reset: function () - { - this.x = 0; - this.y = 0; - this.z = 0; - - return this; + callback(this); } }); -/* -Vector3.Zero = function () +/** + * Adds a JSON file to the current load queue. + * + * Note: This method will only be available if the JSON File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#json + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('json', function (key, url, xhrSettings) { - return new Vector3(0, 0, 0); -}; + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new JSONFile(key[i], url, this.path, xhrSettings)); + } + } + else + { + this.addFile(new JSONFile(key, url, this.path, xhrSettings)); + } -Vector3.Up = function () -{ - return new Vector3(0, 1.0, 0); -}; + // For method chaining + return this; +}); -Vector3.Copy = function (source) -{ - return new Vector3(source.x, source.y, source.z); -}; - -Vector3.TransformCoordinates = function (vector, transformation) -{ - var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + (vector.z * transformation.m[8]) + transformation.m[12]; - var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + (vector.z * transformation.m[9]) + transformation.m[13]; - var z = (vector.x * transformation.m[2]) + (vector.y * transformation.m[6]) + (vector.z * transformation.m[10]) + transformation.m[14]; - var w = (vector.x * transformation.m[3]) + (vector.y * transformation.m[7]) + (vector.z * transformation.m[11]) + transformation.m[15]; - - return new Vector3(x / w, y / w, z / w); -}; - -Vector3.TransformNormal = function (vector, transformation) -{ - var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + (vector.z * transformation.m[8]); - var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + (vector.z * transformation.m[9]); - var z = (vector.x * transformation.m[2]) + (vector.y * transformation.m[6]) + (vector.z * transformation.m[10]); - - return new Vector3(x, y, z); -}; - -Vector3.Dot = function (left, right) -{ - return (left.x * right.x + left.y * right.y + left.z * right.z); -}; - -Vector3.Cross = function (left, right) -{ - var x = left.y * right.z - left.z * right.y; - var y = left.z * right.x - left.x * right.z; - var z = left.x * right.y - left.y * right.x; - - return new Vector3(x, y, z); -}; - -Vector3.Normalize = function (vector) -{ - var newVector = Vector3.Copy(vector); - newVector.normalize(); - - return newVector; -}; - -Vector3.Distance = function (value1, value2) -{ - return Math.sqrt(Vector3.DistanceSquared(value1, value2)); -}; - -Vector3.DistanceSquared = function (value1, value2) -{ - var x = value1.x - value2.x; - var y = value1.y - value2.y; - var z = value1.z - value2.z; - - return (x * x) + (y * y) + (z * z); -}; -*/ - -module.exports = Vector3; +module.exports = JSONFile; /***/ }), @@ -7695,8 +7198,554 @@ module.exports = Vector3; */ var Class = __webpack_require__(0); -var FromPoints = __webpack_require__(122); -var Rectangle = __webpack_require__(8); +var Contains = __webpack_require__(54); +var GetPoint = __webpack_require__(232); +var GetPoints = __webpack_require__(231); +var Line = __webpack_require__(104); +var Random = __webpack_require__(161); + +/** + * @classdesc + * A triangle is a plane created by connecting three points. + * The first two arguments specify the first point, the middle two arguments + * specify the second point, and the last two arguments specify the third point. + * + * @class Triangle + * @memberOf Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x1=0] - [description] + * @param {number} [y1=0] - [description] + * @param {number} [x2=0] - [description] + * @param {number} [y2=0] - [description] + * @param {number} [x3=0] - [description] + * @param {number} [y3=0] - [description] + */ +var Triangle = new Class({ + + initialize: + + function Triangle (x1, y1, x2, y2, x3, y3) + { + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 0; } + if (y2 === undefined) { y2 = 0; } + if (x3 === undefined) { x3 = 0; } + if (y3 === undefined) { y3 = 0; } + + /** + * [description] + * + * @name Phaser.Geom.Triangle#x1 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x1 = x1; + + /** + * [description] + * + * @name Phaser.Geom.Triangle#y1 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y1 = y1; + + /** + * [description] + * + * @name Phaser.Geom.Triangle#x2 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x2 = x2; + + /** + * [description] + * + * @name Phaser.Geom.Triangle#y2 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y2 = y2; + + /** + * [description] + * + * @name Phaser.Geom.Triangle#x3 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x3 = x3; + + /** + * [description] + * + * @name Phaser.Geom.Triangle#y3 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y3 = y3; + }, + + /** + * [description] + * + * @method Phaser.Geom.Triangle#contains + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ + contains: function (x, y) + { + return Contains(this, x, y); + }, + + /** + * [description] + * + * @method Phaser.Geom.Triangle#getPoint + * @since 3.0.0 + * + * @param {float} position - [description] + * @param {(Phaser.Geom.Point|object)} output - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ + getPoint: function (position, output) + { + return GetPoint(this, position, output); + }, + + /** + * [description] + * + * @method Phaser.Geom.Triangle#getPoints + * @since 3.0.0 + * + * @param {integer} quantity - [description] + * @param {number} [stepRate] - [description] + * @param {(array|Phaser.Geom.Point[])} [output] - [description] + * + * @return {(array|Phaser.Geom.Point[])} [description] + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * [description] + * + * @method Phaser.Geom.Triangle#getRandomPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * + * @return {Phaser.Geom.Point} [description] + */ + getRandomPoint: function (point) + { + return Random(this, point); + }, + + /** + * [description] + * + * @method Phaser.Geom.Triangle#setTo + * @since 3.0.0 + * + * @param {number} [x1=0] - [description] + * @param {number} [y1=0] - [description] + * @param {number} [x2=0] - [description] + * @param {number} [y2=0] - [description] + * @param {number} [x3=0] - [description] + * @param {number} [y3=0] - [description] + * + * @return {Phaser.Geom.Triangle} This Triangle object. + */ + setTo: function (x1, y1, x2, y2, x3, y3) + { + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 0; } + if (y2 === undefined) { y2 = 0; } + if (x3 === undefined) { x3 = 0; } + if (y3 === undefined) { y3 = 0; } + + this.x1 = x1; + this.y1 = y1; + + this.x2 = x2; + this.y2 = y2; + + this.x3 = x3; + this.y3 = y3; + + return this; + }, + + /** + * Returns a Line object that corresponds to Line A of this Triangle. + * + * @method Phaser.Geom.Triangle#getLineA + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to line A of this Triangle. + */ + getLineA: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x1, this.y1, this.x2, this.y2); + + return line; + }, + + /** + * Returns a Line object that corresponds to Line B of this Triangle. + * + * @method Phaser.Geom.Triangle#getLineB + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to line B of this Triangle. + */ + getLineB: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x2, this.y2, this.x3, this.y3); + + return line; + }, + + /** + * Returns a Line object that corresponds to Line C of this Triangle. + * + * @method Phaser.Geom.Triangle#getLineC + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to line C of this Triangle. + */ + getLineC: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x3, this.y3, this.x1, this.y1); + + return line; + }, + + /** + * [description] + * + * @name Phaser.Geom.Triangle#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () + { + return Math.min(this.x1, this.x2, this.x3); + }, + + set: function (value) + { + var diff = 0; + + if (this.x1 <= this.x2 && this.x1 <= this.x3) + { + diff = this.x1 - value; + } + else if (this.x2 <= this.x1 && this.x2 <= this.x3) + { + diff = this.x2 - value; + } + else + { + diff = this.x3 - value; + } + + this.x1 -= diff; + this.x2 -= diff; + this.x3 -= diff; + } + + }, + + /** + * [description] + * + * @name Phaser.Geom.Triangle#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return Math.max(this.x1, this.x2, this.x3); + }, + + set: function (value) + { + var diff = 0; + + if (this.x1 >= this.x2 && this.x1 >= this.x3) + { + diff = this.x1 - value; + } + else if (this.x2 >= this.x1 && this.x2 >= this.x3) + { + diff = this.x2 - value; + } + else + { + diff = this.x3 - value; + } + + this.x1 -= diff; + this.x2 -= diff; + this.x3 -= diff; + } + + }, + + /** + * [description] + * + * @name Phaser.Geom.Triangle#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return Math.min(this.y1, this.y2, this.y3); + }, + + set: function (value) + { + var diff = 0; + + if (this.y1 <= this.y2 && this.y1 <= this.y3) + { + diff = this.y1 - value; + } + else if (this.y2 <= this.y1 && this.y2 <= this.y3) + { + diff = this.y2 - value; + } + else + { + diff = this.y3 - value; + } + + this.y1 -= diff; + this.y2 -= diff; + this.y3 -= diff; + } + + }, + + /** + * [description] + * + * @name Phaser.Geom.Triangle#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return Math.max(this.y1, this.y2, this.y3); + }, + + set: function (value) + { + var diff = 0; + + if (this.y1 >= this.y2 && this.y1 >= this.y3) + { + diff = this.y1 - value; + } + else if (this.y2 >= this.y1 && this.y2 >= this.y3) + { + diff = this.y2 - value; + } + else + { + diff = this.y3 - value; + } + + this.y1 -= diff; + this.y2 -= diff; + this.y3 -= diff; + } + + } + +}); + +module.exports = Triangle; + + +/***/ }), +/* 53 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Line.Angle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * + * @return {number} [description] + */ +var Angle = function (line) +{ + return Math.atan2(line.y2 - line.y1, line.x2 - line.x1); +}; + +module.exports = Angle; + + +/***/ }), +/* 54 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// http://www.blackpawn.com/texts/pointinpoly/ + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ +var Contains = function (triangle, x, y) +{ + var v0x = triangle.x3 - triangle.x1; + var v0y = triangle.y3 - triangle.y1; + + var v1x = triangle.x2 - triangle.x1; + var v1y = triangle.y2 - triangle.y1; + + var v2x = x - triangle.x1; + var v2y = y - triangle.y1; + + var dot00 = (v0x * v0x) + (v0y * v0y); + var dot01 = (v0x * v1x) + (v0y * v1y); + var dot02 = (v0x * v2x) + (v0y * v2y); + var dot11 = (v1x * v1x) + (v1y * v1y); + var dot12 = (v1x * v2x) + (v1y * v2y); + + // Compute barycentric coordinates + var b = ((dot00 * dot11) - (dot01 * dot01)); + var inv = (b === 0) ? 0 : (1 / b); + var u = ((dot11 * dot02) - (dot01 * dot12)) * inv; + var v = ((dot00 * dot12) - (dot01 * dot02)) * inv; + + return (u >= 0 && v >= 0 && (u + v < 1)); +}; + +module.exports = Contains; + + +/***/ }), +/* 55 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Shallow Object Clone. Will not clone nested objects. + * + * @function Phaser.Utils.Object.Clone + * @since 3.0.0 + * + * @param {object} obj - [description] + * + * @return {object} [description] + */ +var Clone = function (obj) +{ + var clone = {}; + + for (var key in obj) + { + if (Array.isArray(obj[key])) + { + clone[key] = obj[key].slice(0); + } + else + { + clone[key] = obj[key]; + } + } + + return clone; +}; + +module.exports = Clone; + + +/***/ }), +/* 56 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var FromPoints = __webpack_require__(150); +var Rectangle = __webpack_require__(10); var Vector2 = __webpack_require__(6); /** @@ -7751,7 +7800,7 @@ var Curve = new Class({ * An array of cached arc length values. * * @name Phaser.Curves.Curve#cacheArcLengths - * @type {array} + * @type {number[]} * @default [] * @since 3.0.0 */ @@ -7800,7 +7849,7 @@ var Curve = new Class({ /** * Draws this curve on the given Graphics object. - * + * * The curve is drawn using `Graphics.strokePoints` so will be drawn at whatever the present Graphics stroke color is. * The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it. * @@ -7829,10 +7878,10 @@ var Curve = new Class({ * @method Phaser.Curves.Curve#getBounds * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} out - The Rectangle to store the bounds in. If falsey a new object will be created. + * @param {Phaser.Geom.Rectangle} [out] - The Rectangle to store the bounds in. If falsey a new object will be created. * @param {integer} [accuracy=16] - The accuracy of the bounds calculations. * - * @return {Phaser.Geom.Rectangle} A Rectangle containing the bounds values of this Curve. + * @return {Phaser.Geom.Rectangle} A Rectangle object holding the bounds of this curve. If `out` was given it will be this object. */ getBounds: function (out, accuracy) { @@ -8247,533 +8296,6 @@ var Curve = new Class({ module.exports = Curve; -/***/ }), -/* 53 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Shallow Object Clone. Will not clone nested objects. - * - * @function Phaser.Utils.Object.Clone - * @since 3.0.0 - * - * @param {object} obj - [description] - * - * @return {object} [description] - */ -var Clone = function (obj) -{ - var clone = {}; - - for (var key in obj) - { - if (Array.isArray(obj[key])) - { - clone[key] = obj[key].slice(0); - } - else - { - clone[key] = obj[key]; - } - } - - return clone; -}; - -module.exports = Clone; - - -/***/ }), -/* 54 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// http://www.blackpawn.com/texts/pointinpoly/ - -/** - * [description] - * - * @function Phaser.Geom.Triangle.Contains - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ -var Contains = function (triangle, x, y) -{ - var v0x = triangle.x3 - triangle.x1; - var v0y = triangle.y3 - triangle.y1; - - var v1x = triangle.x2 - triangle.x1; - var v1y = triangle.y2 - triangle.y1; - - var v2x = x - triangle.x1; - var v2y = y - triangle.y1; - - var dot00 = (v0x * v0x) + (v0y * v0y); - var dot01 = (v0x * v1x) + (v0y * v1y); - var dot02 = (v0x * v2x) + (v0y * v2y); - var dot11 = (v1x * v1x) + (v1y * v1y); - var dot12 = (v1x * v2x) + (v1y * v2y); - - // Compute barycentric coordinates - var b = ((dot00 * dot11) - (dot01 * dot01)); - var inv = (b === 0) ? 0 : (1 / b); - var u = ((dot11 * dot02) - (dot01 * dot12)) * inv; - var v = ((dot00 * dot12) - (dot01 * dot02)) * inv; - - return (u >= 0 && v >= 0 && (u + v < 1)); -}; - -module.exports = Contains; - - -/***/ }), -/* 55 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Angle - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var Angle = function (line) -{ - return Math.atan2(line.y2 - line.y1, line.x2 - line.x1); -}; - -module.exports = Angle; - - -/***/ }), -/* 56 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Contains = __webpack_require__(54); -var GetPoint = __webpack_require__(309); -var GetPoints = __webpack_require__(310); -var Random = __webpack_require__(112); - -/** - * @classdesc - * A triangle is a plane created by connecting three points. - * The first two arguments specify the first point, the middle two arguments - * specify the second point, and the last two arguments specify the third point. - * - * @class Triangle - * @memberOf Phaser.Geom - * @constructor - * @since 3.0.0 - * - * @param {number} [x1=0] - [description] - * @param {number} [y1=0] - [description] - * @param {number} [x2=0] - [description] - * @param {number} [y2=0] - [description] - * @param {number} [x3=0] - [description] - * @param {number} [y3=0] - [description] - */ -var Triangle = new Class({ - - initialize: - - function Triangle (x1, y1, x2, y2, x3, y3) - { - if (x1 === undefined) { x1 = 0; } - if (y1 === undefined) { y1 = 0; } - if (x2 === undefined) { x2 = 0; } - if (y2 === undefined) { y2 = 0; } - if (x3 === undefined) { x3 = 0; } - if (y3 === undefined) { y3 = 0; } - - /** - * [description] - * - * @name Phaser.Geom.Triangle#x1 - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x1 = x1; - - /** - * [description] - * - * @name Phaser.Geom.Triangle#y1 - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y1 = y1; - - /** - * [description] - * - * @name Phaser.Geom.Triangle#x2 - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x2 = x2; - - /** - * [description] - * - * @name Phaser.Geom.Triangle#y2 - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y2 = y2; - - /** - * [description] - * - * @name Phaser.Geom.Triangle#x3 - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x3 = x3; - - /** - * [description] - * - * @name Phaser.Geom.Triangle#y3 - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y3 = y3; - }, - - /** - * [description] - * - * @method Phaser.Geom.Triangle#contains - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - contains: function (x, y) - { - return Contains(this, x, y); - }, - - /** - * [description] - * - * @method Phaser.Geom.Triangle#getPoint - * @since 3.0.0 - * - * @param {[type]} position - [description] - * @param {[type]} output - [description] - * - * @return {[type]} [description] - */ - getPoint: function (position, output) - { - return GetPoint(this, position, output); - }, - - /** - * [description] - * - * @method Phaser.Geom.Triangle#getPoints - * @since 3.0.0 - * - * @param {[type]} quantity - [description] - * @param {[type]} stepRate - [description] - * @param {[type]} output - [description] - * - * @return {[type]} [description] - */ - getPoints: function (quantity, stepRate, output) - { - return GetPoints(this, quantity, stepRate, output); - }, - - /** - * [description] - * - * @method Phaser.Geom.Triangle#getRandomPoint - * @since 3.0.0 - * - * @param {[type]} point - [description] - * - * @return {[type]} [description] - */ - getRandomPoint: function (point) - { - return Random(this, point); - }, - - /** - * [description] - * - * @method Phaser.Geom.Triangle#setTo - * @since 3.0.0 - * - * @param {[type]} x1 - [description] - * @param {[type]} y1 - [description] - * @param {[type]} x2 - [description] - * @param {[type]} y2 - [description] - * @param {[type]} x3 - [description] - * @param {[type]} y3 - [description] - * - * @return {Phaser.Geom.Triangle} This Triangle object. - */ - setTo: function (x1, y1, x2, y2, x3, y3) - { - if (x1 === undefined) { x1 = 0; } - if (y1 === undefined) { y1 = 0; } - if (x2 === undefined) { x2 = 0; } - if (y2 === undefined) { y2 = 0; } - if (x3 === undefined) { x3 = 0; } - if (y3 === undefined) { y3 = 0; } - - this.x1 = x1; - this.y1 = y1; - - this.x2 = x2; - this.y2 = y2; - - this.x3 = x3; - this.y3 = y3; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Geom.Triangle#getLineA - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getLineA: function () - { - return { x1: this.x1, y1: this.y1, x2: this.x2, y2: this.y2 }; - }, - - /** - * [description] - * - * @method Phaser.Geom.Triangle#getLineB - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getLineB: function () - { - return { x1: this.x2, y1: this.y2, x2: this.x3, y2: this.y3 }; - }, - - /** - * [description] - * - * @method Phaser.Geom.Triangle#getLineC - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getLineC: function () - { - return { x1: this.x3, y1: this.y3, x2: this.x1, y2: this.y1 }; - }, - - /** - * [description] - * - * @name Phaser.Geom.Triangle#left - * @type {number} - * @since 3.0.0 - */ - left: { - - get: function () - { - return Math.min(this.x1, this.x2, this.x3); - }, - - set: function (value) - { - var diff = 0; - - if (this.x1 <= this.x2 && this.x1 <= this.x3) - { - diff = this.x1 - value; - } - else if (this.x2 <= this.x1 && this.x2 <= this.x3) - { - diff = this.x2 - value; - } - else - { - diff = this.x3 - value; - } - - this.x1 -= diff; - this.x2 -= diff; - this.x3 -= diff; - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Triangle#right - * @type {number} - * @since 3.0.0 - */ - right: { - - get: function () - { - return Math.max(this.x1, this.x2, this.x3); - }, - - set: function (value) - { - var diff = 0; - - if (this.x1 >= this.x2 && this.x1 >= this.x3) - { - diff = this.x1 - value; - } - else if (this.x2 >= this.x1 && this.x2 >= this.x3) - { - diff = this.x2 - value; - } - else - { - diff = this.x3 - value; - } - - this.x1 -= diff; - this.x2 -= diff; - this.x3 -= diff; - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Triangle#top - * @type {number} - * @since 3.0.0 - */ - top: { - - get: function () - { - return Math.min(this.y1, this.y2, this.y3); - }, - - set: function (value) - { - var diff = 0; - - if (this.y1 <= this.y2 && this.y1 <= this.y3) - { - diff = this.y1 - value; - } - else if (this.y2 <= this.y1 && this.y2 <= this.y3) - { - diff = this.y2 - value; - } - else - { - diff = this.y3 - value; - } - - this.y1 -= diff; - this.y2 -= diff; - this.y3 -= diff; - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Triangle#bottom - * @type {number} - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return Math.max(this.y1, this.y2, this.y3); - }, - - set: function (value) - { - var diff = 0; - - if (this.y1 >= this.y2 && this.y1 >= this.y3) - { - diff = this.y1 - value; - } - else if (this.y2 >= this.y1 && this.y2 >= this.y3) - { - diff = this.y2 - value; - } - else - { - diff = this.y3 - value; - } - - this.y1 -= diff; - this.y2 -= diff; - this.y3 -= diff; - } - - } - -}); - -module.exports = Triangle; - - /***/ }), /* 57 */ /***/ (function(module, exports, __webpack_require__) { @@ -8784,115 +8306,770 @@ module.exports = Triangle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(2); /** * @classdesc * [description] * - * @class JSONFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @class Vector3 + * @memberOf Phaser.Math * @constructor * @since 3.0.0 * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {object} xhrSettings - [description] + * @param {number} [x] - [description] + * @param {number} [y] - [description] + * @param {number} [z] - [description] */ -var JSONFile = new Class({ - - Extends: File, +var Vector3 = new Class({ initialize: - // url can either be a string, in which case it is treated like a proper url, or an object, in which case it is treated as a ready-made JS Object - - function JSONFile (key, url, path, xhrSettings) + function Vector3 (x, y, z) { - var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); + /** + * The x component of this Vector. + * + * @name Phaser.Math.Vector3#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ - var fileConfig = { - type: 'json', - extension: GetFastValue(key, 'extension', 'json'), - responseType: 'text', - key: fileKey, - url: GetFastValue(key, 'file', url), - path: path, - xhrSettings: GetFastValue(key, 'xhr', xhrSettings) - }; + /** + * The y component of this Vector. + * + * @name Phaser.Math.Vector3#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ - File.call(this, fileConfig); + /** + * The z component of this Vector. + * + * @name Phaser.Math.Vector3#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ - if (typeof fileConfig.url === 'object') + if (typeof x === 'object') { - // Object provided instead of a URL, so no need to actually load it (populate data with value) - this.data = fileConfig.url; - - this.state = CONST.FILE_POPULATED; + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; } }, - onProcess: function (callback) + /** + * [description] + * + * @method Phaser.Math.Vector3#up + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + up: function () { - this.state = CONST.FILE_PROCESSING; + this.x = 0; + this.y = 1; + this.z = 0; - this.data = JSON.parse(this.xhrLoader.responseText); + return this; + }, - this.onComplete(); - - callback(this); - } - -}); - -/** - * Adds a JSON file to the current load queue. - * - * Note: This method will only be available if the JSON File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#json - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('json', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) + /** + * [description] + * + * @method Phaser.Math.Vector3#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} A new Vector3 object containing this Vectors values. + */ + clone: function () { - for (var i = 0; i < key.length; i++) + return new Vector3(this.x, this.y, this.z); + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#crossVectors + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} a - [description] + * @param {Phaser.Math.Vector3} b - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + crossVectors: function (a, b) + { + var ax = a.x; + var ay = a.y; + var az = a.z; + var bx = b.x; + var by = b.y; + var bz = b.z; + + this.x = ay * bz - az * by; + this.y = az * bx - ax * bz; + this.z = ax * by - ay * bx; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#equals + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - The Vector3 to compare against. + * + * @return {boolean} True if the two vectors strictly match, otherwise false. + */ + equals: function (v) + { + return ((this.x === v.x) && (this.y === v.y) && (this.z === v.z)); + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#copy + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} src - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + copy: function (src) + { + this.x = src.x; + this.y = src.y; + this.z = src.z || 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#set + * @since 3.0.0 + * + * @param {(number|object)} x - [description] + * @param {number} [y] - [description] + * @param {number} [z] - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + set: function (x, y, z) + { + if (typeof x === 'object') { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new JSONFile(key[i], url, this.path, xhrSettings)); + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; } - } - else + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#add + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + add: function (v) { - this.addFile(new JSONFile(key, url, this.path, xhrSettings)); + this.x += v.x; + this.y += v.y; + this.z += v.z || 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#subtract + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + subtract: function (v) + { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z || 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#multiply + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + multiply: function (v) + { + this.x *= v.x; + this.y *= v.y; + this.z *= v.z || 1; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#scale + * @since 3.0.0 + * + * @param {float} scale - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + scale: function (scale) + { + if (isFinite(scale)) + { + this.x *= scale; + this.y *= scale; + this.z *= scale; + } + else + { + this.x = 0; + this.y = 0; + this.z = 0; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#divide + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + divide: function (v) + { + this.x /= v.x; + this.y /= v.y; + this.z /= v.z || 1; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#negate + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + negate: function () + { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#distance + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - [description] + * + * @return {number} [description] + */ + distance: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + + return Math.sqrt(dx * dx + dy * dy + dz * dz); + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#distanceSq + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - [description] + * + * @return {number} [description] + */ + distanceSq: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + + return dx * dx + dy * dy + dz * dz; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#length + * @since 3.0.0 + * + * @return {number} [description] + */ + length: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + + return Math.sqrt(x * x + y * y + z * z); + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#lengthSq + * @since 3.0.0 + * + * @return {number} [description] + */ + lengthSq: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + + return x * x + y * y + z * z; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#normalize + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + normalize: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var len = x * x + y * y + z * z; + + if (len > 0) + { + len = 1 / Math.sqrt(len); + + this.x = x * len; + this.y = y * len; + this.z = z * len; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#dot + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - [description] + * + * @return {number} [description] + */ + dot: function (v) + { + return this.x * v.x + this.y * v.y + this.z * v.z; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#cross + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + cross: function (v) + { + var ax = this.x; + var ay = this.y; + var az = this.z; + var bx = v.x; + var by = v.y; + var bz = v.z; + + this.x = ay * bz - az * by; + this.y = az * bx - ax * bz; + this.z = ax * by - ay * bx; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#lerp + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - [description] + * @param {number} [t=0] - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + lerp: function (v, t) + { + if (t === undefined) { t = 0; } + + var ax = this.x; + var ay = this.y; + var az = this.z; + + this.x = ax + t * (v.x - ax); + this.y = ay + t * (v.y - ay); + this.z = az + t * (v.z - az); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#transformMat3 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} mat - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + transformMat3: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + this.x = x * m[0] + y * m[3] + z * m[6]; + this.y = x * m[1] + y * m[4] + z * m[7]; + this.z = x * m[2] + y * m[5] + z * m[8]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#transformMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + transformMat4: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + this.x = m[0] * x + m[4] * y + m[8] * z + m[12]; + this.y = m[1] * x + m[5] * y + m[9] * z + m[13]; + this.z = m[2] * x + m[6] * y + m[10] * z + m[14]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#transformCoordinates + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + transformCoordinates: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + var tx = (x * m[0]) + (y * m[4]) + (z * m[8]) + m[12]; + var ty = (x * m[1]) + (y * m[5]) + (z * m[9]) + m[13]; + var tz = (x * m[2]) + (y * m[6]) + (z * m[10]) + m[14]; + var tw = (x * m[3]) + (y * m[7]) + (z * m[11]) + m[15]; + + this.x = tx / tw; + this.y = ty / tw; + this.z = tz / tw; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#transformQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + transformQuat: function (q) + { + // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations + var x = this.x; + var y = this.y; + var z = this.z; + var qx = q.x; + var qy = q.y; + var qz = q.z; + var qw = q.w; + + // calculate quat * vec + var ix = qw * x + qy * z - qz * y; + var iy = qw * y + qz * x - qx * z; + var iz = qw * z + qx * y - qy * x; + var iw = -qx * x - qy * y - qz * z; + + // calculate result * inverse quat + this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; + this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; + this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; + + return this; + }, + + /** + * Multiplies this Vector3 by the specified matrix, applying a W divide. This is useful for projection, + * e.g. unprojecting a 2D point into 3D space. + * + * @method Phaser.Math.Vector3#project + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + project: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + var a00 = m[0]; + var a01 = m[1]; + var a02 = m[2]; + var a03 = m[3]; + var a10 = m[4]; + var a11 = m[5]; + var a12 = m[6]; + var a13 = m[7]; + var a20 = m[8]; + var a21 = m[9]; + var a22 = m[10]; + var a23 = m[11]; + var a30 = m[12]; + var a31 = m[13]; + var a32 = m[14]; + var a33 = m[15]; + + var lw = 1 / (x * a03 + y * a13 + z * a23 + a33); + + this.x = (x * a00 + y * a10 + z * a20 + a30) * lw; + this.y = (x * a01 + y * a11 + z * a21 + a31) * lw; + this.z = (x * a02 + y * a12 + z * a22 + a32) * lw; + + return this; + }, + + /** + * Unproject this point from 2D space to 3D space. + * The point should have its x and y properties set to + * 2D screen space, and the z either at 0 (near plane) + * or 1 (far plane). The provided matrix is assumed to already + * be combined, i.e. projection * view * model. + * + * After this operation, this vector's (x, y, z) components will + * represent the unprojected 3D coordinate. + * + * @method Phaser.Math.Vector3#unproject + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} viewport - Screen x, y, width and height in pixels. + * @param {Phaser.Math.Matrix4} invProjectionView - Combined projection and view matrix. + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + unproject: function (viewport, invProjectionView) + { + var viewX = viewport.x; + var viewY = viewport.y; + var viewWidth = viewport.z; + var viewHeight = viewport.w; + + var x = this.x - viewX; + var y = (viewHeight - this.y - 1) - viewY; + var z = this.z; + + this.x = (2 * x) / viewWidth - 1; + this.y = (2 * y) / viewHeight - 1; + this.z = 2 * z - 1; + + return this.project(invProjectionView); + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#reset + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + reset: function () + { + this.x = 0; + this.y = 0; + this.z = 0; + + return this; } - // For method chaining - return this; }); -module.exports = JSONFile; +/* +Vector3.Zero = function () +{ + return new Vector3(0, 0, 0); +}; + +Vector3.Up = function () +{ + return new Vector3(0, 1.0, 0); +}; + +Vector3.Copy = function (source) +{ + return new Vector3(source.x, source.y, source.z); +}; + +Vector3.TransformCoordinates = function (vector, transformation) +{ + var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + (vector.z * transformation.m[8]) + transformation.m[12]; + var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + (vector.z * transformation.m[9]) + transformation.m[13]; + var z = (vector.x * transformation.m[2]) + (vector.y * transformation.m[6]) + (vector.z * transformation.m[10]) + transformation.m[14]; + var w = (vector.x * transformation.m[3]) + (vector.y * transformation.m[7]) + (vector.z * transformation.m[11]) + transformation.m[15]; + + return new Vector3(x / w, y / w, z / w); +}; + +Vector3.TransformNormal = function (vector, transformation) +{ + var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + (vector.z * transformation.m[8]); + var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + (vector.z * transformation.m[9]); + var z = (vector.x * transformation.m[2]) + (vector.y * transformation.m[6]) + (vector.z * transformation.m[10]); + + return new Vector3(x, y, z); +}; + +Vector3.Dot = function (left, right) +{ + return (left.x * right.x + left.y * right.y + left.z * right.z); +}; + +Vector3.Cross = function (left, right) +{ + var x = left.y * right.z - left.z * right.y; + var y = left.z * right.x - left.x * right.z; + var z = left.x * right.y - left.y * right.x; + + return new Vector3(x, y, z); +}; + +Vector3.Normalize = function (vector) +{ + var newVector = Vector3.Copy(vector); + newVector.normalize(); + + return newVector; +}; + +Vector3.Distance = function (value1, value2) +{ + return Math.sqrt(Vector3.DistanceSquared(value1, value2)); +}; + +Vector3.DistanceSquared = function (value1, value2) +{ + var x = value1.x - value2.x; + var y = value1.y - value2.y; + var z = value1.z - value2.z; + + return (x * x) + (y * y) + (z * z); +}; +*/ + +module.exports = Vector3; /***/ }), /* 58 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -8900,166 +9077,22 @@ module.exports = JSONFile; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(2); - /** - * @classdesc - * [description] + * Returns the center y coordinate from the bounds of the Game Object. * - * @class ImageFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor + * @function Phaser.Display.Bounds.GetCenterY * @since 3.0.0 * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {object} xhrSettings - [description] - * @param {object} config - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The center y coordinate of the bounds of the Game Object. */ -var ImageFile = new Class({ - - Extends: File, - - initialize: - - // this.load.image('pic', 'assets/pics/taikodrummaster.jpg'); - // this.load.image({ key: 'pic', file: 'assets/pics/taikodrummaster.jpg' }); - // this.load.image({ - // key: 'bunny', - // file: 'assets/sprites/bunny.png', - // xhr: { - // user: 'root', - // password: 'th3G1bs0n', - // timeout: 30, - // header: 'Content-Type', - // headerValue: 'text/xml' - // } - // }); - // this.load.image({ key: 'bunny' }); - // this.load.image({ key: 'bunny', extension: 'jpg' }); - - function ImageFile (key, url, path, xhrSettings, config) - { - var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); - - var fileConfig = { - type: 'image', - extension: GetFastValue(key, 'extension', 'png'), - responseType: 'blob', - key: fileKey, - url: GetFastValue(key, 'file', url), - path: path, - xhrSettings: GetFastValue(key, 'xhr', xhrSettings), - config: GetFastValue(key, 'config', config) - }; - - File.call(this, fileConfig); - }, - - onProcess: function (callback) - { - this.state = CONST.FILE_PROCESSING; - - this.data = new Image(); - - this.data.crossOrigin = this.crossOrigin; - - var _this = this; - - this.data.onload = function () - { - File.revokeObjectURL(_this.data); - - _this.onComplete(); - - callback(_this); - }; - - this.data.onerror = function () - { - File.revokeObjectURL(_this.data); - - _this.state = CONST.FILE_ERRORED; - - callback(_this); - }; - - File.createObjectURL(this.data, this.xhrLoader.response, 'image/png'); - } - -}); - -/** - * Adds an Image file to the current load queue. - * - * Note: This method will only be available if the Image File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#image - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('image', function (key, url, xhrSettings) +var GetCenterY = function (gameObject) { - var urls; - var fileA; - var fileB; + return gameObject.y - (gameObject.height * gameObject.originY) + (gameObject.height * 0.5); +}; - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - urls = GetFastValue(key[i], 'file', url); - - if (Array.isArray(urls) && urls.length === 2) - { - fileA = this.addFile(new ImageFile(key[i], urls[0], this.path, xhrSettings)); - fileB = this.addFile(new ImageFile(key[i], urls[1], this.path, xhrSettings)); - - fileA.setLinkFile(fileB, 'dataimage'); - } - else - { - this.addFile(new ImageFile(key[i], url, this.path, xhrSettings)); - } - } - } - else - { - urls = GetFastValue(key, 'file', url); - - if (Array.isArray(urls) && urls.length === 2) - { - fileA = this.addFile(new ImageFile(key, urls[0], this.path, xhrSettings)); - fileB = this.addFile(new ImageFile(key, urls[1], this.path, xhrSettings)); - - fileA.setLinkFile(fileB, 'dataimage'); - } - else - { - this.addFile(new ImageFile(key, url, this.path, xhrSettings)); - } - } - - // For method chaining - return this; -}); - -module.exports = ImageFile; +module.exports = GetCenterY; /***/ }), @@ -9072,94 +9105,63 @@ module.exports = ImageFile; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -module.exports = { +/** + * Positions the Game Object so that the center top of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetCenterY + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} y - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetCenterY = function (gameObject, y) +{ + var offsetY = gameObject.height * gameObject.originY; - /** - * [description] - * - * @name Phaser.Physics.Arcade.DYNAMIC_BODY - * @type {number} - * @since 3.0.0 - */ - DYNAMIC_BODY: 0, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.STATIC_BODY - * @type {number} - * @since 3.0.0 - */ - STATIC_BODY: 1, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.GROUP - * @type {number} - * @since 3.0.0 - */ - GROUP: 2, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.TILEMAPLAYER - * @type {number} - * @since 3.0.0 - */ - TILEMAPLAYER: 3, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.FACING_NONE - * @type {number} - * @since 3.0.0 - */ - FACING_NONE: 10, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.FACING_UP - * @type {number} - * @since 3.0.0 - */ - FACING_UP: 11, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.FACING_DOWN - * @type {number} - * @since 3.0.0 - */ - FACING_DOWN: 12, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.FACING_LEFT - * @type {number} - * @since 3.0.0 - */ - FACING_LEFT: 13, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.FACING_RIGHT - * @type {number} - * @since 3.0.0 - */ - FACING_RIGHT: 14 + gameObject.y = (y + offsetY) - (gameObject.height * 0.5); + return gameObject; }; +module.exports = SetCenterY; + + +/***/ }), +/* 60 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the center top of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetCenterX + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} x - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetCenterX = function (gameObject, x) +{ + var offsetX = gameObject.width * gameObject.originX; + + gameObject.x = (x + offsetX) - (gameObject.width * 0.5); + + return gameObject; +}; + +module.exports = SetCenterX; + /***/ }), -/* 60 */, /* 61 */ /***/ (function(module, exports) { @@ -9170,27 +9172,206 @@ module.exports = { */ /** - * Force a value within the boundaries by clamping it to the range `min`, `max`. + * Returns the center x coordinate from the bounds of the Game Object. * - * @function Phaser.Math.Clamp + * @function Phaser.Display.Bounds.GetCenterX * @since 3.0.0 * - * @param {number} value - The value to be clamped. - * @param {number} min - The minimum bounds. - * @param {number} max - The maximum bounds. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. * - * @return {number} The clamped value. + * @return {number} The center x coordinate of the bounds of the Game Object. */ -var Clamp = function (value, min, max) +var GetCenterX = function (gameObject) { - return Math.max(min, Math.min(max, value)); + return gameObject.x - (gameObject.width * gameObject.originX) + (gameObject.width * 0.5); }; -module.exports = Clamp; +module.exports = GetCenterX; /***/ }), /* 62 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.BlendModes + */ + +module.exports = { + + /** + * Skips the Blend Mode check in the renderer. + * + * @name Phaser.BlendModes.SKIP_CHECK + * @type {integer} + * @since 3.0.0 + */ + SKIP_CHECK: -1, + + /** + * Normal blend mode. + * + * @name Phaser.BlendModes.NORMAL + * @type {integer} + * @since 3.0.0 + */ + NORMAL: 0, + + /** + * Add blend mode. + * + * @name Phaser.BlendModes.ADD + * @type {integer} + * @since 3.0.0 + */ + ADD: 1, + + /** + * Multiply blend mode. + * + * @name Phaser.BlendModes.MULTIPLY + * @type {integer} + * @since 3.0.0 + */ + MULTIPLY: 2, + + /** + * Screen blend mode. + * + * @name Phaser.BlendModes.SCREEN + * @type {integer} + * @since 3.0.0 + */ + SCREEN: 3, + + /** + * Overlay blend mode. + * + * @name Phaser.BlendModes.OVERLAY + * @type {integer} + * @since 3.0.0 + */ + OVERLAY: 4, + + /** + * Darken blend mode. + * + * @name Phaser.BlendModes.DARKEN + * @type {integer} + * @since 3.0.0 + */ + DARKEN: 5, + + /** + * Lighten blend mode. + * + * @name Phaser.BlendModes.LIGHTEN + * @type {integer} + * @since 3.0.0 + */ + LIGHTEN: 6, + + /** + * Color Dodge blend mode. + * + * @name Phaser.BlendModes.COLOR_DODGE + * @type {integer} + * @since 3.0.0 + */ + COLOR_DODGE: 7, + + /** + * Color Burn blend mode. + * + * @name Phaser.BlendModes.COLOR_BURN + * @type {integer} + * @since 3.0.0 + */ + COLOR_BURN: 8, + + /** + * Hard Light blend mode. + * + * @name Phaser.BlendModes.HARD_LIGHT + * @type {integer} + * @since 3.0.0 + */ + HARD_LIGHT: 9, + + /** + * Soft Light blend mode. + * + * @name Phaser.BlendModes.SOFT_LIGHT + * @type {integer} + * @since 3.0.0 + */ + SOFT_LIGHT: 10, + + /** + * Difference blend mode. + * + * @name Phaser.BlendModes.DIFFERENCE + * @type {integer} + * @since 3.0.0 + */ + DIFFERENCE: 11, + + /** + * Exclusion blend mode. + * + * @name Phaser.BlendModes.EXCLUSION + * @type {integer} + * @since 3.0.0 + */ + EXCLUSION: 12, + + /** + * Hue blend mode. + * + * @name Phaser.BlendModes.HUE + * @type {integer} + * @since 3.0.0 + */ + HUE: 13, + + /** + * Saturation blend mode. + * + * @name Phaser.BlendModes.SATURATION + * @type {integer} + * @since 3.0.0 + */ + SATURATION: 14, + + /** + * Color blend mode. + * + * @name Phaser.BlendModes.COLOR + * @type {integer} + * @since 3.0.0 + */ + COLOR: 15, + + /** + * Luminosity blend mode. + * + * @name Phaser.BlendModes.LUMINOSITY + * @type {integer} + * @since 3.0.0 + */ + LUMINOSITY: 16 + +}; + + +/***/ }), +/* 63 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -9201,6 +9382,15 @@ module.exports = Clamp; var Class = __webpack_require__(0); +/** + * @callback EachSetCallback + * + * @param {*} entry - [description] + * @param {number} index - [description] + * + * @return {?boolean} [description] + */ + /** * @classdesc * A Set is a collection of unique elements. @@ -9243,7 +9433,7 @@ var Set = new Class({ * @method Phaser.Structs.Set#set * @since 3.0.0 * - * @param {any} value - [description] + * @param {*} value - [description] * * @return {Phaser.Structs.Set} This Set object. */ @@ -9264,9 +9454,9 @@ var Set = new Class({ * @since 3.0.0 * * @param {string} property - [description] - * @param {any} value - [description] + * @param {*} value - [description] * - * @return {any} [description] + * @return {*} [description] */ get: function (property, value) { @@ -9300,7 +9490,7 @@ var Set = new Class({ * @method Phaser.Structs.Set#delete * @since 3.0.0 * - * @param {any} value - [description] + * @param {*} value - [description] * * @return {Phaser.Structs.Set} This Set object. */ @@ -9343,7 +9533,7 @@ var Set = new Class({ * @method Phaser.Structs.Set#each * @since 3.0.0 * - * @param {function} callback - [description] + * @param {EachSetCallback} callback - [description] * @param {object} callbackScope - [description] * * @return {Phaser.Structs.Set} This Set object. @@ -9384,7 +9574,7 @@ var Set = new Class({ * @method Phaser.Structs.Set#iterate * @since 3.0.0 * - * @param {function} callback - [description] + * @param {EachSetCallback} callback - [description] * @param {object} callbackScope - [description] * * @return {Phaser.Structs.Set} This Set object. @@ -9472,7 +9662,7 @@ var Set = new Class({ * @method Phaser.Structs.Set#contains * @since 3.0.0 * - * @param {any} value - [description] + * @param {*} value - [description] * * @return {boolean} [description] */ @@ -9585,7 +9775,7 @@ module.exports = Set; /***/ }), -/* 63 */ +/* 64 */ /***/ (function(module, exports) { /** @@ -9595,2005 +9785,29 @@ module.exports = Set; */ /** - * @namespace Phaser.ScaleModes - */ - -module.exports = { - - /** - * Default Scale Mode (Linear). - * - * @name Phaser.ScaleModes.DEFAULT - * @type {integer} - * @since 3.0.0 - */ - DEFAULT: 0, - - /** - * Linear Scale Mode. - * - * @name Phaser.ScaleModes.LINEAR - * @type {integer} - * @since 3.0.0 - */ - LINEAR: 0, - - /** - * Nearest Scale Mode. - * - * @name Phaser.ScaleModes.NEAREST - * @type {integer} - * @since 3.0.0 - */ - NEAREST: 1 - -}; - - -/***/ }), -/* 64 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Contains = __webpack_require__(32); -var GetPoint = __webpack_require__(184); -var GetPoints = __webpack_require__(185); -var Random = __webpack_require__(106); - -/** - * @classdesc - * A Circle object. + * Force a value within the boundaries by clamping it to the range `min`, `max`. * - * This is a geometry object, containing numerical values and related methods to inspect and modify them. - * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. - * To render a Circle you should look at the capabilities of the Graphics class. - * - * @class Circle - * @memberOf Phaser.Geom - * @constructor + * @function Phaser.Math.Clamp * @since 3.0.0 * - * @param {number} [x=0] - The x position of the center of the circle. - * @param {number} [y=0] - The y position of the center of the circle. - * @param {number} [radius=0] - The radius of the circle. + * @param {number} value - The value to be clamped. + * @param {number} min - The minimum bounds. + * @param {number} max - The maximum bounds. + * + * @return {number} The clamped value. */ -var Circle = new Class({ +var Clamp = function (value, min, max) +{ + return Math.max(min, Math.min(max, value)); +}; - initialize: - - function Circle (x, y, radius) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (radius === undefined) { radius = 0; } - - /** - * The x position of the center of the circle. - * - * @name Phaser.Geom.Circle#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x = x; - - /** - * The y position of the center of the circle. - * - * @name Phaser.Geom.Circle#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y = y; - - /** - * The internal radius of the circle. - * - * @name Phaser.Geom.Circle#_radius - * @type {number} - * @private - * @since 3.0.0 - */ - this._radius = radius; - - /** - * The internal diameter of the circle. - * - * @name Phaser.Geom.Circle#_diameter - * @type {number} - * @private - * @since 3.0.0 - */ - this._diameter = radius * 2; - }, - - /** - * Check to see if the Circle contains the given x / y coordinates. - * - * @method Phaser.Geom.Circle#contains - * @since 3.0.0 - * - * @param {number} x - The x coordinate to check within the circle. - * @param {number} y - The y coordinate to check within the circle. - * - * @return {boolean} True if the coordinates are within the circle, otherwise false. - */ - contains: function (x, y) - { - return Contains(this, x, y); - }, - - /** - * Returns a Point object containing the coordinates of a point on the circumference of the Circle - * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point - * at 180 degrees around the circle. - * - * @method Phaser.Geom.Circle#getPoint - * @since 3.0.0 - * - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. - * @param {Phaser.Geom.Point|object} [out] - An object to store the return values in. If not given a Point object will be created. - * - * @return {Phaser.Geom.Point|object} A Point, or point-like object, containing the coordinates of the point around the circle. - */ - getPoint: function (position, point) - { - return GetPoint(this, position, point); - }, - - /** - * Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, - * based on the given quantity or stepRate values. - * - * @method Phaser.Geom.Circle#getPoints - * @since 3.0.0 - * - * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param {number} [stepRate] - Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. - * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. - * - * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the circumference of the circle. - */ - getPoints: function (quantity, stepRate, output) - { - return GetPoints(this, quantity, stepRate, output); - }, - - /** - * Returns a uniformly distributed random point from anywhere within the Circle. - * - * @method Phaser.Geom.Circle#getRandomPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Point|object} [point] - A Point or point-like object to set the random `x` and `y` values in. - * - * @return {Phaser.Geom.Point|object} A Point object with the random values set in the `x` and `y` properties. - */ - getRandomPoint: function (point) - { - return Random(this, point); - }, - - /** - * Sets the x, y and radius of this circle. - * - * @method Phaser.Geom.Circle#setTo - * @since 3.0.0 - * - * @param {number} [x=0] - The x position of the center of the circle. - * @param {number} [y=0] - The y position of the center of the circle. - * @param {number} [radius=0] - The radius of the circle. - * - * @return {Phaser.Geom.Circle} This Circle object. - */ - setTo: function (x, y, radius) - { - this.x = x; - this.y = y; - this._radius = radius; - this._diameter = radius * 2; - - return this; - }, - - /** - * Sets this Circle to be empty with a radius of zero. - * Does not change its position. - * - * @method Phaser.Geom.Circle#setEmpty - * @since 3.0.0 - * - * @return {Phaser.Geom.Circle} This Circle object. - */ - setEmpty: function () - { - this._radius = 0; - this._diameter = 0; - - return this; - }, - - /** - * Sets the position of this Circle. - * - * @method Phaser.Geom.Circle#setPosition - * @since 3.0.0 - * - * @param {number} [x=0] - The x position of the center of the circle. - * @param {number} [y=0] - The y position of the center of the circle. - * - * @return {Phaser.Geom.Circle} This Circle object. - */ - setPosition: function (x, y) - { - if (y === undefined) { y = x; } - - this.x = x; - this.y = y; - - return this; - }, - - /** - * Checks to see if the Circle is empty: has a radius of zero. - * - * @method Phaser.Geom.Circle#isEmpty - * @since 3.0.0 - * - * @return {boolean} True if the Circle is empty, otherwise false. - */ - isEmpty: function () - { - return (this._radius <= 0); - }, - - /** - * The radius of the Circle. - * - * @name Phaser.Geom.Circle#radius - * @type {number} - * @since 3.0.0 - */ - radius: { - - get: function () - { - return this._radius; - }, - - set: function (value) - { - this._radius = value; - this._diameter = value * 2; - } - - }, - - /** - * The diameter of the Circle. - * - * @name Phaser.Geom.Circle#diameter - * @type {number} - * @since 3.0.0 - */ - diameter: { - - get: function () - { - return this._diameter; - }, - - set: function (value) - { - this._diameter = value; - this._radius = value * 0.5; - } - - }, - - /** - * The left position of the Circle. - * - * @name Phaser.Geom.Circle#left - * @type {number} - * @since 3.0.0 - */ - left: { - - get: function () - { - return this.x - this._radius; - }, - - set: function (value) - { - this.x = value + this._radius; - } - - }, - - /** - * The right position of the Circle. - * - * @name Phaser.Geom.Circle#right - * @type {number} - * @since 3.0.0 - */ - right: { - - get: function () - { - return this.x + this._radius; - }, - - set: function (value) - { - this.x = value - this._radius; - } - - }, - - /** - * The top position of the Circle. - * - * @name Phaser.Geom.Circle#top - * @type {number} - * @since 3.0.0 - */ - top: { - - get: function () - { - return this.y - this._radius; - }, - - set: function (value) - { - this.y = value + this._radius; - } - - }, - - /** - * The bottom position of the Circle. - * - * @name Phaser.Geom.Circle#bottom - * @type {number} - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return this.y + this._radius; - }, - - set: function (value) - { - this.y = value - this._radius; - } - - } - -}); - -module.exports = Circle; +module.exports = Clamp; /***/ }), /* 65 */ /***/ (function(module, exports, __webpack_require__) { -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clamp = __webpack_require__(61); - -/** - * Return a value based on the range between `min` and `max` and the percentage given. - * - * @function Phaser.Math.FromPercent - * @since 3.0.0 - * - * @param {float} percent - A value between 0 and 1 representing the percentage. - * @param {number} min - [description] - * @param {number} [max] - [description] - * - * @return {number} [description] - */ -var FromPercent = function (percent, min, max) -{ - percent = Clamp(percent, 0, 1); - - return (max - min) * percent; -}; - -module.exports = FromPercent; - - -/***/ }), -/* 66 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Length - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var Length = function (line) -{ - return Math.sqrt((line.x2 - line.x1) * (line.x2 - line.x1) + (line.y2 - line.y1) * (line.y2 - line.y1)); -}; - -module.exports = Length; - - -/***/ }), -/* 67 */ -/***/ (function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(process) {/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Determines the operating system of the device running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.os` from within any Scene. - * - * @name Phaser.Device.OS - * @since 3.0.0 - * - * @type {object} - * @property {boolean} android - Is running on android? - * @property {boolean} chromeOS - Is running on chromeOS? - * @property {boolean} cocoonJS - Is the game running under CocoonJS? - * @property {boolean} cocoonJSApp - Is this game running with CocoonJS.App? - * @property {boolean} cordova - Is the game running under Apache Cordova? - * @property {boolean} crosswalk - Is the game running under the Intel Crosswalk XDK? - * @property {boolean} desktop - Is running on a desktop? - * @property {boolean} ejecta - Is the game running under Ejecta? - * @property {boolean} electron - Is the game running under GitHub Electron? - * @property {boolean} iOS - Is running on iOS? - * @property {boolean} iPad - Is running on iPad? - * @property {boolean} iPhone - Is running on iPhone? - * @property {boolean} kindle - Is running on an Amazon Kindle? - * @property {boolean} linux - Is running on linux? - * @property {boolean} macOS - Is running on macOS? - * @property {boolean} node - Is the game running under Node.js? - * @property {boolean} nodeWebkit - Is the game running under Node-Webkit? - * @property {boolean} webApp - Set to true if running as a WebApp, i.e. within a WebView - * @property {boolean} windows - Is running on windows? - * @property {boolean} windowsPhone - Is running on a Windows Phone? - * @property {number} iOSVersion - If running in iOS this will contain the major version number. - * @property {number} pixelRatio - PixelRatio of the host device? - */ -var OS = { - - android: false, - chromeOS: false, - cocoonJS: false, - cocoonJSApp: false, - cordova: false, - crosswalk: false, - desktop: false, - ejecta: false, - electron: false, - iOS: false, - iOSVersion: 0, - iPad: false, - iPhone: false, - kindle: false, - linux: false, - macOS: false, - node: false, - nodeWebkit: false, - pixelRatio: 1, - webApp: false, - windows: false, - windowsPhone: false - -}; - -function init () -{ - var ua = navigator.userAgent; - - if (/Windows/.test(ua)) - { - OS.windows = true; - } - else if (/Mac OS/.test(ua)) - { - OS.macOS = true; - } - else if (/Linux/.test(ua)) - { - OS.linux = true; - } - else if (/Android/.test(ua)) - { - OS.android = true; - } - else if (/iP[ao]d|iPhone/i.test(ua)) - { - OS.iOS = true; - (navigator.appVersion).match(/OS (\d+)/); - OS.iOSVersion = parseInt(RegExp.$1, 10); - } - else if (/Kindle/.test(ua) || (/\bKF[A-Z][A-Z]+/).test(ua) || (/Silk.*Mobile Safari/).test(ua)) - { - OS.kindle = true; - - // This will NOT detect early generations of Kindle Fire, I think there is no reliable way... - // E.g. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-80) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true" - } - else if (/CrOS/.test(ua)) - { - OS.chromeOS = true; - } - - if (/Windows Phone/i.test(ua) || (/IEMobile/i).test(ua)) - { - OS.android = false; - OS.iOS = false; - OS.macOS = false; - OS.windows = true; - OS.windowsPhone = true; - } - - var silk = (/Silk/).test(ua); - - if (OS.windows || OS.macOS || (OS.linux && !silk) || OS.chromeOS) - { - OS.desktop = true; - } - - // Windows Phone / Table reset - if (OS.windowsPhone || ((/Windows NT/i.test(ua)) && (/Touch/i.test(ua)))) - { - OS.desktop = false; - } - - // WebApp mode in iOS - if (navigator.standalone) - { - OS.webApp = true; - } - - if (window.cordova !== undefined) - { - OS.cordova = true; - } - - if ((typeof process !== 'undefined') && (typeof process.versions.node !== 'undefined')) - { - OS.node = true; - } - - if (OS.node && typeof process.versions === 'object') - { - OS.nodeWebkit = !!process.versions['node-webkit']; - - OS.electron = !!process.versions.electron; - } - - if (navigator.isCocoonJS) - { - OS.cocoonJS = true; - - try - { - OS.cocoonJSApp = (typeof CocoonJS !== 'undefined'); - } - catch (error) - { - OS.cocoonJSApp = false; - } - } - - if (window.ejecta !== undefined) - { - OS.ejecta = true; - } - - if ((/Crosswalk/).test(ua)) - { - OS.crosswalk = true; - } - - OS.iPhone = ua.toLowerCase().indexOf('iphone') !== -1; - OS.iPad = ua.toLowerCase().indexOf('ipad') !== -1; - - OS.pixelRatio = window['devicePixelRatio'] || 1; - - return OS; -} - -module.exports = init(); - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(506))) - -/***/ }), -/* 68 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Check to see if the Ellipse contains the given x / y coordinates. - * - * @function Phaser.Geom.Ellipse.Contains - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. - * @param {number} x - The x coordinate to check within the ellipse. - * @param {number} y - The y coordinate to check within the ellipse. - * - * @return {boolean} True if the coordinates are within the ellipse, otherwise false. - */ -var Contains = function (ellipse, x, y) -{ - if (ellipse.width <= 0 || ellipse.height <= 0) - { - return false; - } - - // Normalize the coords to an ellipse with center 0,0 and a radius of 0.5 - var normx = ((x - ellipse.x) / ellipse.width); - var normy = ((y - ellipse.y) / ellipse.height); - - normx *= normx; - normy *= normy; - - return (normx + normy < 0.25); -}; - -module.exports = Contains; - - -/***/ }), -/* 69 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Actions = __webpack_require__(171); -var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(2); -var GetValue = __webpack_require__(4); -var Range = __webpack_require__(275); -var Set = __webpack_require__(62); -var Sprite = __webpack_require__(37); - -/** - * @classdesc - * [description] - * - * children can be either an array of children, or a config object - * config can be either a config object, or undefined if passed as the children argument instead - * - * @class Group - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {array} children - [description] - * @param {object} config - [description] - */ -var Group = new Class({ - - initialize: - - function Group (scene, children, config) - { - if (config === undefined && !Array.isArray(children) && typeof children === 'object') - { - config = children; - children = null; - } - - /** - * [description] - * - * @name Phaser.GameObjects.Group#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.GameObjects.Group#children - * @type {Phaser.Structs.Set} - * @since 3.0.0 - */ - this.children = new Set(children); - - /** - * [description] - * - * @name Phaser.GameObjects.Group#isParent - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.isParent = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Group#classType - * @type {object} - * @since 3.0.0 - */ - this.classType = GetFastValue(config, 'classType', Sprite); - - /** - * [description] - * - * @name Phaser.GameObjects.Group#active - * @type {boolean} - * @since 3.0.0 - */ - this.active = GetFastValue(config, 'active', true); - - /** - * [description] - * - * @name Phaser.GameObjects.Group#maxSize - * @type {integer} - * @since 3.0.0 - */ - this.maxSize = GetFastValue(config, 'maxSize', -1); - - /** - * [description] - * - * @name Phaser.GameObjects.Group#defaultKey - * @type {string} - * @since 3.0.0 - */ - this.defaultKey = GetFastValue(config, 'defaultKey', null); - - /** - * [description] - * - * @name Phaser.GameObjects.Group#defaultFrame - * @type {string|integer} - * @since 3.0.0 - */ - this.defaultFrame = GetFastValue(config, 'defaultFrame', null); - - /** - * [description] - * - * @name Phaser.GameObjects.Group#runChildUpdate - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.runChildUpdate = GetFastValue(config, 'runChildUpdate', false); - - /** - * [description] - * - * @name Phaser.GameObjects.Group#createCallback - * @type {?function} - * @since 3.0.0 - */ - this.createCallback = GetFastValue(config, 'createCallback', null); - - /** - * [description] - * - * @name Phaser.GameObjects.Group#removeCallback - * @type {?function} - * @since 3.0.0 - */ - this.removeCallback = GetFastValue(config, 'removeCallback', null); - - /** - * [description] - * - * @name Phaser.GameObjects.Group#createMultipleCallback - * @type {?function} - * @since 3.0.0 - */ - this.createMultipleCallback = GetFastValue(config, 'createMultipleCallback', null); - - if (config) - { - this.createMultiple(config); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#create - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * @param {boolean} [visible=true] - [description] - * - * @return {Phaser.GameObjects.GameObject} [description] - */ - create: function (x, y, key, frame, visible) - { - if (key === undefined) { key = this.defaultKey; } - if (frame === undefined) { frame = this.defaultFrame; } - if (visible === undefined) { visible = true; } - - // Pool? - if (this.isFull()) - { - return null; - } - - var child = new this.classType(this.scene, x, y, key, frame); - - this.scene.sys.displayList.add(child); - - if (child.preUpdate) - { - this.scene.sys.updateList.add(child); - } - - child.visible = visible; - - this.add(child); - - return child; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#createMultiple - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.GameObject[]} [description] - */ - createMultiple: function (config) - { - if (!Array.isArray(config)) - { - config = [ config ]; - } - - var output = []; - - for (var i = 0; i < config.length; i++) - { - var entries = this.createFromConfig(config[i]); - - output = output.concat(entries); - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#createFromConfig - * @since 3.0.0 - * - * @param {object} options - [description] - * - * @return {Phaser.GameObjects.GameObject[]} [description] - */ - createFromConfig: function (options) - { - this.classType = GetFastValue(options, 'classType', this.classType); - - var key = GetFastValue(options, 'key', undefined); - var frame = GetFastValue(options, 'frame', null); - var visible = GetFastValue(options, 'visible', true); - - var entries = []; - - // Can't do anything without at least a key - if (key === undefined) - { - return entries; - } - else - { - if (!Array.isArray(key)) - { - key = [ key ]; - } - - if (!Array.isArray(frame)) - { - frame = [ frame ]; - } - } - - // Build an array of key frame pairs to loop through - - var repeat = GetFastValue(options, 'repeat', 0); - var randomKey = GetFastValue(options, 'randomKey', false); - var randomFrame = GetFastValue(options, 'randomFrame', false); - var yoyo = GetFastValue(options, 'yoyo', false); - var quantity = GetFastValue(options, 'frameQuantity', 1); - var max = GetFastValue(options, 'max', 0); - - // If a grid is set we use that to override the quantity? - - var range = Range(key, frame, { - max: max, - qty: quantity, - random: randomKey, - randomB: randomFrame, - repeat: repeat, - yoyo: yoyo - }); - - for (var c = 0; c < range.length; c++) - { - entries.push(this.create(0, 0, range[c].a, range[c].b, visible)); - } - - // Post-creation options (applied only to those items created in this call): - - var x = GetValue(options, 'setXY.x', 0); - var y = GetValue(options, 'setXY.y', 0); - var stepX = GetValue(options, 'setXY.stepX', 0); - var stepY = GetValue(options, 'setXY.stepY', 0); - - Actions.SetXY(entries, x, y, stepX, stepY); - - var rotation = GetValue(options, 'setRotation.value', 0); - var stepRotation = GetValue(options, 'setRotation.step', 0); - - Actions.SetRotation(entries, rotation, stepRotation); - - var scaleX = GetValue(options, 'setScale.x', 1); - var scaleY = GetValue(options, 'setScale.y', scaleX); - var stepScaleX = GetValue(options, 'setScale.stepX', 0); - var stepScaleY = GetValue(options, 'setScale.stepY', 0); - - Actions.SetScale(entries, scaleX, scaleY, stepScaleX, stepScaleY); - - var alpha = GetValue(options, 'setAlpha.value', 1); - var stepAlpha = GetValue(options, 'setAlpha.step', 0); - - Actions.SetAlpha(entries, alpha, stepAlpha); - - var hitArea = GetFastValue(options, 'hitArea', null); - var hitAreaCallback = GetFastValue(options, 'hitAreaCallback', null); - - if (hitArea) - { - Actions.SetHitArea(entries, hitArea, hitAreaCallback); - } - - var grid = GetFastValue(options, 'gridAlign', false); - - if (grid) - { - Actions.GridAlign(entries, grid); - } - - if (this.createMultipleCallback) - { - this.createMultipleCallback.call(this, entries); - } - - return entries; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#preUpdate - * @since 3.0.0 - * - * @param {number} time - [description] - * @param {number} delta - [description] - */ - preUpdate: function (time, delta) - { - if (!this.runChildUpdate || this.children.size === 0) - { - return; - } - - // Because a Group child may mess with the length of the Group during its update - var temp = this.children.entries.slice(); - - for (var i = 0; i < temp.length; i++) - { - var item = temp[i]; - - if (item.active) - { - item.update(time, delta); - } - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#add - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - * @param {boolean} [addToScene=false] - [description] - * - * @return {Phaser.GameObjects.Group} This Group object. - */ - add: function (child, addToScene) - { - if (addToScene === undefined) { addToScene = false; } - - this.children.set(child); - - if (this.createCallback) - { - this.createCallback.call(this, child); - } - - if (addToScene) - { - this.scene.sys.displayList.add(child); - - if (child.preUpdate) - { - this.scene.sys.updateList.add(child); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#addMultiple - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject[]} children - [description] - * @param {boolean} [addToScene=false] - [description] - * - * @return {Phaser.GameObjects.Group} This Group object. - */ - addMultiple: function (children, addToScene) - { - if (addToScene === undefined) { addToScene = false; } - - if (Array.isArray(children)) - { - for (var i = 0; i < children.length; i++) - { - this.add(children[i], addToScene); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#remove - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - * @param {boolean} [removeFromScene=false] - [description] - * - * @return {Phaser.GameObjects.Group} This Group object. - */ - remove: function (child, removeFromScene) - { - if (removeFromScene === undefined) { removeFromScene = false; } - - this.children.delete(child); - - if (removeFromScene) - { - this.scene.sys.displayList.remove(child); - - if (child.preUpdate) - { - this.scene.sys.updateList.remove(child); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#clear - * @since 3.0.0 - * - * @param {boolean} [removeFromScene=false] - [description] - * - * @return {Phaser.GameObjects.Group} This Group object. - */ - clear: function (removeFromScene) - { - if (removeFromScene === undefined) { removeFromScene = false; } - - if (removeFromScene) - { - var children = this.children; - - for (var i = 0; i < children.size; i++) - { - var gameObject = children.entries[i]; - - this.scene.sys.displayList.remove(gameObject); - - if (gameObject.preUpdate) - { - this.scene.sys.updateList.remove(gameObject); - } - } - } - - this.children.clear(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#contains - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - * - * @return {boolean} [description] - */ - contains: function (child) - { - return this.children.contains(child); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#getChildren - * @since 3.0.0 - * - * @return {Phaser.GameObjects.GameObject[]} [description] - */ - getChildren: function () - { - return this.children.entries; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#getLength - * @since 3.0.0 - * - * @return {integer} [description] - */ - getLength: function () - { - return this.children.size; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#getFirst - * @since 3.0.0 - * - * @param {boolean} [state=false] - [description] - * @param {boolean} [createIfNull=false] - [description] - * @param {number} [x] - The horizontal position of this Game Object in the world. - * @param {number} [y] - The vertical position of this Game Object in the world. - * @param {string} [texture] - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * @param {boolean} [visible] - [description] - * - * @return {Phaser.GameObjects.GameObject|null} [description] - */ - getFirst: function (state, createIfNull, x, y, key, frame, visible) - { - if (state === undefined) { state = false; } - if (createIfNull === undefined) { createIfNull = false; } - - var gameObject; - - var children = this.children.entries; - - for (var i = 0; i < children.length; i++) - { - gameObject = children[i]; - - if (gameObject.active === state) - { - if (typeof(x) === 'number') - { - gameObject.x = x; - } - - if (typeof(y) === 'number') - { - gameObject.y = y; - } - - return gameObject; - } - } - - // Got this far? We need to create or bail - if (createIfNull) - { - return this.create(x, y, key, frame, visible); - } - else - { - return null; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#get - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * @param {boolean} visible - [description] - * - * @return {Phaser.GameObjects.GameObject} [description] - */ - get: function (x, y, key, frame, visible) - { - return this.getFirst(false, true, x, y, key, frame, visible); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#getFirstAlive - * @since 3.0.0 - * - * @param {boolean} createIfNull - [description] - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * @param {boolean} visible - [description] - * - * @return {Phaser.GameObjects.GameObject} [description] - */ - getFirstAlive: function (createIfNull, x, y, key, frame, visible) - { - return this.getFirst(true, createIfNull, x, y, key, frame, visible); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#getFirstDead - * @since 3.0.0 - * - * @param {boolean} createIfNull - [description] - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * @param {boolean} visible - [description] - * - * @return {Phaser.GameObjects.GameObject} [description] - */ - getFirstDead: function (createIfNull, x, y, key, frame, visible) - { - return this.getFirst(false, createIfNull, x, y, key, frame, visible); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#playAnimation - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} startFrame - [description] - * - * @return {Phaser.GameObjects.Group} This Group object. - */ - playAnimation: function (key, startFrame) - { - Actions.PlayAnimation(this.children.entries, key, startFrame); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#isFull - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isFull: function () - { - if (this.maxSize === -1) - { - return false; - } - else - { - return (this.children.size === this.maxSize); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#countActive - * @since 3.0.0 - * - * @param {boolean} [value=true] - [description] - * - * @return {integer} [description] - */ - countActive: function (value) - { - if (value === undefined) { value = true; } - - var total = 0; - - for (var i = 0; i < this.children.size; i++) - { - if (this.children.entries[i].active === value) - { - total++; - } - } - - return total; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#getTotalUsed - * @since 3.0.0 - * - * @return {integer} [description] - */ - getTotalUsed: function () - { - return this.countActive(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#getTotalFree - * @since 3.0.0 - * - * @return {integer} [description] - */ - getTotalFree: function () - { - var used = this.getTotalUsed(); - var capacity = (this.maxSize === -1) ? 999999999999 : this.maxSize; - - return (capacity - used); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#setDepth - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} step - [description] - * - * @return {Phaser.GameObjects.Group} This Group object. - */ - setDepth: function (value, step) - { - Actions.SetDepth(this.children.entries, value, step); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#kill - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - */ - kill: function (gameObject) - { - if (this.children.contains(gameObject)) - { - gameObject.setActive(false); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#killAndHide - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - */ - killAndHide: function (gameObject) - { - if (this.children.contains(gameObject)) - { - gameObject.setActive(false); - gameObject.setVisible(false); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#toggleVisible - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Group} This Group object. - */ - toggleVisible: function () - { - Actions.ToggleVisible(this.children.entries); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.children.clear(); - - this.scene = undefined; - this.children = undefined; - } - -}); - -module.exports = Group; - - -/***/ }), -/* 70 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var GameObject = __webpack_require__(1); -var ImageRender = __webpack_require__(570); - -/** - * @classdesc - * An Image Game Object. - * - * An Image is a light-weight Game Object useful for the display of static images in your game, - * such as logos, backgrounds, scenery or other non-animated elements. Images can have input - * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an - * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. - * - * @class Image - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var Image = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Size, - Components.Texture, - Components.Tint, - Components.Transform, - Components.Visible, - ImageRender - ], - - initialize: - - function Image (scene, x, y, texture, frame) - { - GameObject.call(this, scene, 'Image'); - - this.setTexture(texture, frame); - this.setPosition(x, y); - this.setSizeToFrame(); - this.setOriginFromFrame(); - this.initPipeline('TextureTintPipeline'); - } - -}); - -module.exports = Image; - - -/***/ }), -/* 71 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var EaseMap = __webpack_require__(578); - -/** - * [description] - * - * @function Phaser.Tweens.Builders.GetEaseFunction - * @since 3.0.0 - * - * @param {string|function} ease - [description] - * @param {array} easeParams - [description] - * - * @return {function} [description] - */ -var GetEaseFunction = function (ease, easeParams) -{ - if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease)) - { - if (easeParams) - { - var cloneParams = easeParams.slice(0); - - cloneParams.unshift(0); - - return function (v) - { - cloneParams[0] = v; - - return EaseMap[ease].apply(this, cloneParams); - }; - } - else - { - // String based look-up - return EaseMap[ease]; - } - } - else if (typeof ease === 'function') - { - // Custom function - return ease; - } - else if (Array.isArray(ease) && ease.length === 4) - { - // Bezier function (TODO) - } - - return EaseMap.Power0; -}; - -module.exports = GetEaseFunction; - - -/***/ }), -/* 72 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Utils.Object.HasValue - * @since 3.0.0 - * - * @param {object} source - [description] - * @param {string} key - [description] - * - * @return {boolean} [description] - */ -var HasValue = function (source, key) -{ - return (source.hasOwnProperty(key)); -}; - -module.exports = HasValue; - - -/***/ }), -/* 73 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Tweens.Builders.GetBoolean - * @since 3.0.0 - * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {any} defaultValue - [description] - * - * @return {any} [description] - */ -var GetBoolean = function (source, key, defaultValue) -{ - if (!source) - { - return defaultValue; - } - else if (source.hasOwnProperty(key)) - { - return source[key]; - } - else - { - return defaultValue; - } -}; - -module.exports = GetBoolean; - - -/***/ }), -/* 74 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Checks if the given tile coordinates are within the bounds of the layer. - * - * @function Phaser.Tilemaps.Components.IsInLayerBounds - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {boolean} - */ -var IsInLayerBounds = function (tileX, tileY, layer) -{ - return (tileX >= 0 && tileX < layer.width && tileY >= 0 && tileY < layer.height); -}; - -module.exports = IsInLayerBounds; - - -/***/ }), -/* 75 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(2); - -/** - * @classdesc - * A class for representing data about about a layer in a map. Maps are parsed from CSV, Tiled, - * etc. into this format. Tilemap, StaticTilemapLayer and DynamicTilemapLayer have a reference - * to this data and use it to look up and perform operations on tiles. - * - * @class LayerData - * @memberOf Phaser.Tilemaps - * @constructor - * @since 3.0.0 - * - * @param {object} [config] - [description] - */ -var LayerData = new Class({ - - initialize: - - function LayerData (config) - { - if (config === undefined) { config = {}; } - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#name - * @type {string} - * @since 3.0.0 - */ - this.name = GetFastValue(config, 'name', 'layer'); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#x - * @type {number} - * @since 3.0.0 - */ - this.x = GetFastValue(config, 'x', 0); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#y - * @type {number} - * @since 3.0.0 - */ - this.y = GetFastValue(config, 'y', 0); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#width - * @type {number} - * @since 3.0.0 - */ - this.width = GetFastValue(config, 'width', 0); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#height - * @type {number} - * @since 3.0.0 - */ - this.height = GetFastValue(config, 'height', 0); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#tileWidth - * @type {number} - * @since 3.0.0 - */ - this.tileWidth = GetFastValue(config, 'tileWidth', 0); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#tileHeight - * @type {number} - * @since 3.0.0 - */ - this.tileHeight = GetFastValue(config, 'tileHeight', 0); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#baseTileWidth - * @type {number} - * @since 3.0.0 - */ - this.baseTileWidth = GetFastValue(config, 'baseTileWidth', this.tileWidth); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#baseTileHeight - * @type {number} - * @since 3.0.0 - */ - this.baseTileHeight = GetFastValue(config, 'baseTileHeight', this.tileHeight); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#widthInPixels - * @type {number} - * @since 3.0.0 - */ - this.widthInPixels = GetFastValue(config, 'widthInPixels', this.width * this.baseTileWidth); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#heightInPixels - * @type {number} - * @since 3.0.0 - */ - this.heightInPixels = GetFastValue(config, 'heightInPixels', this.height * this.baseTileHeight); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#alpha - * @type {float} - * @since 3.0.0 - */ - this.alpha = GetFastValue(config, 'alpha', 1); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#visible - * @type {boolean} - * @since 3.0.0 - */ - this.visible = GetFastValue(config, 'visible', true); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#properties - * @type {object} - * @since 3.0.0 - */ - this.properties = GetFastValue(config, 'properties', {}); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#indexes - * @type {array} - * @since 3.0.0 - */ - this.indexes = GetFastValue(config, 'indexes', []); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#collideIndexes - * @type {array} - * @since 3.0.0 - */ - this.collideIndexes = GetFastValue(config, 'collideIndexes', []); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#callbacks - * @type {array} - * @since 3.0.0 - */ - this.callbacks = GetFastValue(config, 'callbacks', []); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#bodies - * @type {array} - * @since 3.0.0 - */ - this.bodies = GetFastValue(config, 'bodies', []); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#data - * @type {array} - * @since 3.0.0 - */ - this.data = GetFastValue(config, 'data', []); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#tilemapLayer - * @type {Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer} - * @since 3.0.0 - */ - this.tilemapLayer = GetFastValue(config, 'tilemapLayer', null); - } - -}); - -module.exports = LayerData; - - -/***/ }), -/* 76 */ -/***/ (function(module, exports, __webpack_require__) { - /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. @@ -11793,7 +10007,7 @@ module.exports = MapData; /***/ }), -/* 77 */ +/* 66 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -11802,287 +10016,420 @@ module.exports = MapData; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BlendModes = __webpack_require__(45); -var Circle = __webpack_require__(64); -var CircleContains = __webpack_require__(32); var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var GameObject = __webpack_require__(1); -var Rectangle = __webpack_require__(8); -var RectangleContains = __webpack_require__(33); +var GetFastValue = __webpack_require__(2); /** * @classdesc - * A Zone Game Object. + * A class for representing data about about a layer in a map. Maps are parsed from CSV, Tiled, + * etc. into this format. Tilemap, StaticTilemapLayer and DynamicTilemapLayer have a reference + * to this data and use it to look up and perform operations on tiles. * - * A Zone is a non-rendering rectangular Game Object that has a position and size. - * It has no texture and never displays, but does live on the display list and - * can be moved, scaled and rotated like any other Game Object. - * - * Its primary use is for creating Drop Zones and Input Hit Areas and it has a couple of helper methods - * specifically for this. It is also useful for object overlap checks, or as a base for your own - * non-displaying Game Objects. - - * The default origin is 0.5, the center of the Zone, the same as with Game Objects. - * - * @class Zone - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects + * @class LayerData + * @memberOf Phaser.Tilemaps * @constructor * @since 3.0.0 * - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - [description] - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {number} [width=1] - The width of the Game Object. - * @param {number} [height=1] - The height of the Game Object. + * @param {object} [config] - [description] */ -var Zone = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Depth, - Components.GetBounds, - Components.Origin, - Components.ScaleMode, - Components.Transform, - Components.ScrollFactor, - Components.Visible - ], +var LayerData = new Class({ initialize: - function Zone (scene, x, y, width, height) + function LayerData (config) { - if (width === undefined) { width = 1; } - if (height === undefined) { height = width; } - - GameObject.call(this, scene, 'Zone'); - - this.setPosition(x, y); + if (config === undefined) { config = {}; } /** - * The native (un-scaled) width of this Game Object. + * [description] * - * @name Phaser.GameObjects.Zone#width + * @name Phaser.Tilemaps.LayerData#name + * @type {string} + * @since 3.0.0 + */ + this.name = GetFastValue(config, 'name', 'layer'); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#x * @type {number} * @since 3.0.0 */ - this.width = width; + this.x = GetFastValue(config, 'x', 0); /** - * The native (un-scaled) height of this Game Object. + * [description] * - * @name Phaser.GameObjects.Zone#height + * @name Phaser.Tilemaps.LayerData#y * @type {number} * @since 3.0.0 */ - this.height = height; + this.y = GetFastValue(config, 'y', 0); /** - * The Blend Mode of the Game Object. - * Although a Zone never renders, it still has a blend mode to allow it to fit seamlessly into - * display lists without causing a batch flush. + * [description] * - * @name Phaser.GameObjects.Zone#blendMode - * @type {integer} + * @name Phaser.Tilemaps.LayerData#width + * @type {number} * @since 3.0.0 */ - this.blendMode = BlendModes.NORMAL; - }, + this.width = GetFastValue(config, 'width', 0); - /** - * The displayed width of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Zone#displayWidth - * @type {number} - * @since 3.0.0 - */ - displayWidth: { + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#height + * @type {number} + * @since 3.0.0 + */ + this.height = GetFastValue(config, 'height', 0); - get: function () - { - return this.scaleX * this.width; - }, + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#tileWidth + * @type {number} + * @since 3.0.0 + */ + this.tileWidth = GetFastValue(config, 'tileWidth', 0); - set: function (value) - { - this.scaleX = value / this.width; - } + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#tileHeight + * @type {number} + * @since 3.0.0 + */ + this.tileHeight = GetFastValue(config, 'tileHeight', 0); - }, + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#baseTileWidth + * @type {number} + * @since 3.0.0 + */ + this.baseTileWidth = GetFastValue(config, 'baseTileWidth', this.tileWidth); - /** - * The displayed height of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Zone#displayHeight - * @type {number} - * @since 3.0.0 - */ - displayHeight: { + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#baseTileHeight + * @type {number} + * @since 3.0.0 + */ + this.baseTileHeight = GetFastValue(config, 'baseTileHeight', this.tileHeight); - get: function () - { - return this.scaleY * this.height; - }, + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#widthInPixels + * @type {number} + * @since 3.0.0 + */ + this.widthInPixels = GetFastValue(config, 'widthInPixels', this.width * this.baseTileWidth); - set: function (value) - { - this.scaleY = value / this.height; - } + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#heightInPixels + * @type {number} + * @since 3.0.0 + */ + this.heightInPixels = GetFastValue(config, 'heightInPixels', this.height * this.baseTileHeight); - }, + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#alpha + * @type {float} + * @since 3.0.0 + */ + this.alpha = GetFastValue(config, 'alpha', 1); - /** - * Sets the size of this Game Object. - * - * @method Phaser.GameObjects.Zone#setSize - * @since 3.0.0 - * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. - * @param {boolean} [resizeInput=true] - If this Zone has a Rectangle for a hit area this argument will resize the hit area as well. - * - * @return {Phaser.GameObjects.Zone} This Game Object. - */ - setSize: function (width, height, resizeInput) - { - if (resizeInput === undefined) { resizeInput = true; } + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#visible + * @type {boolean} + * @since 3.0.0 + */ + this.visible = GetFastValue(config, 'visible', true); - this.width = width; - this.height = height; + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#properties + * @type {object} + * @since 3.0.0 + */ + this.properties = GetFastValue(config, 'properties', {}); - if (resizeInput && this.input && this.input.hitArea instanceof Rectangle) - { - this.input.hitArea.width = width; - this.input.hitArea.height = height; - } + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#indexes + * @type {array} + * @since 3.0.0 + */ + this.indexes = GetFastValue(config, 'indexes', []); - return this; - }, + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#collideIndexes + * @type {array} + * @since 3.0.0 + */ + this.collideIndexes = GetFastValue(config, 'collideIndexes', []); - /** - * Sets the display size of this Game Object. - * Calling this will adjust the scale. - * - * @method Phaser.GameObjects.Zone#setDisplaySize - * @since 3.0.0 - * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. - * - * @return {Phaser.GameObjects.Zone} This Game Object. - */ - setDisplaySize: function (width, height) - { - this.displayWidth = width; - this.displayHeight = height; + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#callbacks + * @type {array} + * @since 3.0.0 + */ + this.callbacks = GetFastValue(config, 'callbacks', []); - return this; - }, + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#bodies + * @type {array} + * @since 3.0.0 + */ + this.bodies = GetFastValue(config, 'bodies', []); - /** - * Sets this Zone to be a Circular Drop Zone. - * The circle is centered on this Zones `x` and `y` coordinates. - * - * @method Phaser.GameObjects.Zone#setCircleDropZone - * @since 3.0.0 - * - * @param {number} radius - The radius of the Circle that will form the Drop Zone. - * - * @return {Phaser.GameObjects.Zone} This Game Object. - */ - setCircleDropZone: function (radius) - { - return this.setDropZone(new Circle(0, 0, radius), CircleContains); - }, + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#data + * @type {array} + * @since 3.0.0 + */ + this.data = GetFastValue(config, 'data', []); - /** - * Sets this Zone to be a Rectangle Drop Zone. - * The rectangle is centered on this Zones `x` and `y` coordinates. - * - * @method Phaser.GameObjects.Zone#setRectangleDropZone - * @since 3.0.0 - * - * @param {number} width - The width of the rectangle drop zone. - * @param {number} height - The height of the rectangle drop zone. - * - * @return {Phaser.GameObjects.Zone} This Game Object. - */ - setRectangleDropZone: function (width, height) - { - var x = -(width / 2); - var y = -(height / 2); - - return this.setDropZone(new Rectangle(x, y, width, height), RectangleContains); - }, - - /** - * Allows you to define your own Geometry shape to be used as a Drop Zone. - * - * @method Phaser.GameObjects.Zone#setDropZone - * @since 3.0.0 - * - * @param {object} shape - A Geometry shape instance, such as Phaser.Geom.Ellipse, or your own custom shape. - * @param {function} callback - A function that will return `true` if the given x/y coords it is sent are within the shape. - * - * @return {Phaser.GameObjects.Zone} This Game Object. - */ - setDropZone: function (shape, callback) - { - if (shape === undefined) - { - this.setRectangleDropZone(this.width, this.height); - } - else - if (!this.input) - { - this.setInteractive(shape, callback, true); - } - - return this; - }, - - /** - * A Zone does not render. - * - * @method Phaser.GameObjects.Zone#renderCanvas - * @private - * @since 3.0.0 - */ - renderCanvas: function () - { - }, - - /** - * A Zone does not render. - * - * @method Phaser.GameObjects.Zone#renderWebGL - * @private - * @since 3.0.0 - */ - renderWebGL: function () - { + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#tilemapLayer + * @type {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} + * @since 3.0.0 + */ + this.tilemapLayer = GetFastValue(config, 'tilemapLayer', null); } }); -module.exports = Zone; +module.exports = LayerData; /***/ }), -/* 78 */ +/* 67 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Checks if the given tile coordinates are within the bounds of the layer. + * + * @function Phaser.Tilemaps.Components.IsInLayerBounds + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {boolean} + */ +var IsInLayerBounds = function (tileX, tileY, layer) +{ + return (tileX >= 0 && tileX < layer.width && tileY >= 0 && tileY < layer.height); +}; + +module.exports = IsInLayerBounds; + + +/***/ }), +/* 68 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TWEEN_CONST = { + + /** + * TweenData state. + * + * @name Phaser.Tweens.CREATED + * @type {integer} + * @since 3.0.0 + */ + CREATED: 0, + + /** + * TweenData state. + * + * @name Phaser.Tweens.INIT + * @type {integer} + * @since 3.0.0 + */ + INIT: 1, + + /** + * TweenData state. + * + * @name Phaser.Tweens.DELAY + * @type {integer} + * @since 3.0.0 + */ + DELAY: 2, + + /** + * TweenData state. + * + * @name Phaser.Tweens.OFFSET_DELAY + * @type {integer} + * @since 3.0.0 + */ + OFFSET_DELAY: 3, + + /** + * TweenData state. + * + * @name Phaser.Tweens.PENDING_RENDER + * @type {integer} + * @since 3.0.0 + */ + PENDING_RENDER: 4, + + /** + * TweenData state. + * + * @name Phaser.Tweens.PLAYING_FORWARD + * @type {integer} + * @since 3.0.0 + */ + PLAYING_FORWARD: 5, + + /** + * TweenData state. + * + * @name Phaser.Tweens.PLAYING_BACKWARD + * @type {integer} + * @since 3.0.0 + */ + PLAYING_BACKWARD: 6, + + /** + * TweenData state. + * + * @name Phaser.Tweens.HOLD_DELAY + * @type {integer} + * @since 3.0.0 + */ + HOLD_DELAY: 7, + + /** + * TweenData state. + * + * @name Phaser.Tweens.REPEAT_DELAY + * @type {integer} + * @since 3.0.0 + */ + REPEAT_DELAY: 8, + + /** + * TweenData state. + * + * @name Phaser.Tweens.COMPLETE + * @type {integer} + * @since 3.0.0 + */ + COMPLETE: 9, + + // Tween specific (starts from 20 to cleanly allow extra TweenData consts in the future) + + /** + * Tween state. + * + * @name Phaser.Tweens.PENDING_ADD + * @type {integer} + * @since 3.0.0 + */ + PENDING_ADD: 20, + + /** + * Tween state. + * + * @name Phaser.Tweens.PAUSED + * @type {integer} + * @since 3.0.0 + */ + PAUSED: 21, + + /** + * Tween state. + * + * @name Phaser.Tweens.LOOP_DELAY + * @type {integer} + * @since 3.0.0 + */ + LOOP_DELAY: 22, + + /** + * Tween state. + * + * @name Phaser.Tweens.ACTIVE + * @type {integer} + * @since 3.0.0 + */ + ACTIVE: 23, + + /** + * Tween state. + * + * @name Phaser.Tweens.COMPLETE_DELAY + * @type {integer} + * @since 3.0.0 + */ + COMPLETE_DELAY: 24, + + /** + * Tween state. + * + * @name Phaser.Tweens.PENDING_REMOVE + * @type {integer} + * @since 3.0.0 + */ + PENDING_REMOVE: 25, + + /** + * Tween state. + * + * @name Phaser.Tweens.REMOVED + * @type {integer} + * @since 3.0.0 + */ + REMOVED: 26 + +}; + +module.exports = TWEEN_CONST; + + +/***/ }), +/* 69 */ /***/ (function(module, exports) { /** @@ -12094,450 +10441,36 @@ module.exports = Zone; /** * [description] * - * @function Phaser.Geom.Rectangle.Perimeter + * @function Phaser.Tweens.Builders.GetBoolean * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {object} source - [description] + * @param {string} key - [description] + * @param {*} defaultValue - [description] * - * @return {number} [description] + * @return {*} [description] */ -var Perimeter = function (rect) +var GetBoolean = function (source, key, defaultValue) { - return 2 * (rect.width + rect.height); + if (!source) + { + return defaultValue; + } + else if (source.hasOwnProperty(key)) + { + return source[key]; + } + else + { + return defaultValue; + } }; -module.exports = Perimeter; +module.exports = GetBoolean; /***/ }), -/* 79 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin. - * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter, - * or have a property called `events` that is an instance of it. - * - * @class DataManager - * @memberOf Phaser.Data - * @constructor - * @since 3.0.0 - * - * @param {any} parent - [description] - * @param {any} eventEmitter - [description] - */ -var DataManager = new Class({ - - initialize: - - function DataManager (parent, eventEmitter) - { - /** - * [description] - * - * @name Phaser.Data.DataManager#parent - * @type {any} - * @since 3.0.0 - */ - this.parent = parent; - - /** - * [description] - * - * @name Phaser.Data.DataManager#events - * @type {EventEmitter} - * @since 3.0.0 - */ - this.events = eventEmitter; - - if (!eventEmitter) - { - this.events = (parent.events) ? parent.events : parent; - } - - /** - * [description] - * - * @name Phaser.Data.DataManager#list - * @type {object} - * @default {} - * @since 3.0.0 - */ - this.list = {}; - - /** - * [description] - * - * @name Phaser.Data.DataManager#blockSet - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.blockSet = false; - - /** - * [description] - * - * @name Phaser.Data.DataManager#_frozen - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this._frozen = false; - - this.events.once('destroy', this.destroy, this); - }, - - /** - * Retrieves the value for the given key, or undefined if it doesn't exist. - * - * @method Phaser.Data.DataManager#get - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {any} [description] - */ - get: function (key) - { - return this.list[key]; - }, - - /** - * [description] - * - * @method Phaser.Data.DataManager#getAll - * @since 3.0.0 - * - * @return {object} [description] - */ - getAll: function () - { - var results = {}; - - for (var key in this.list) - { - results[key] = this.list[key]; - } - - return results; - }, - - /** - * [description] - * - * @method Phaser.Data.DataManager#query - * @since 3.0.0 - * - * @param {string} search - [description] - * - * @return {object} [description] - */ - query: function (search) - { - var results = {}; - - for (var key in this.list) - { - if (key.match(search)) - { - results[key] = this.list[key]; - } - } - - return results; - }, - - /** - * [description] - * - * @method Phaser.Data.DataManager#set - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {any} data - [description] - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - set: function (key, data) - { - if (this._frozen) - { - return this; - } - - if (this.events.listenerCount('changedata') > 0) - { - this.blockSet = false; - - var _this = this; - - var resetFunction = function (value) - { - _this.blockSet = true; - _this.list[key] = value; - _this.events.emit('setdata', _this.parent, key, value); - }; - - this.events.emit('changedata', this.parent, key, data, resetFunction); - - // One of the listeners blocked this update from being set, so abort - if (this.blockSet) - { - return this; - } - } - - this.list[key] = data; - - this.events.emit('setdata', this.parent, key, data); - - return this; - }, - - /** - * Passes all data entries to the given callback. Stores the result of the callback. - * - * @method Phaser.Data.DataManager#each - * @since 3.0.0 - * - * @param {function} callback - The function to call. - * @param {object} [scope] - Value to use as `this` when executing callback. - * @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the game object, key, and data. - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - each: function (callback, scope) - { - var args = [ this.parent, null, undefined ]; - - for (var i = 1; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - for (var key in this.list) - { - args[1] = key; - args[2] = this.list[key]; - - callback.apply(scope, args); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Data.DataManager#merge - * @since 3.0.0 - * - * @param {object} data - [description] - * @param {boolean} overwrite - [description] - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - merge: function (data, overwrite) - { - if (overwrite === undefined) { overwrite = true; } - - // Merge data from another component into this one - for (var key in data) - { - if (overwrite || (!overwrite && !this.has(key))) - { - this.list[key] = data; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Data.DataManager#remove - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - remove: function (key) - { - if (!this._frozen && this.has(key)) - { - var data = this.list[key]; - - delete this.list[key]; - - this.events.emit('removedata', this, key, data); - } - - return this; - }, - - /** - * Gets the data associated with the given 'key', deletes it from this Data store, then returns it. - * - * @method Phaser.Data.DataManager#pop - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {any} [description] - */ - pop: function (key) - { - var data = undefined; - - if (!this._frozen && this.has(key)) - { - data = this.list[key]; - - delete this.list[key]; - - this.events.emit('removedata', this, key, data); - } - - return data; - }, - - /** - * [description] - * - * @method Phaser.Data.DataManager#has - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {boolean} [description] - */ - has: function (key) - { - return this.list.hasOwnProperty(key); - }, - - /** - * [description] - * - * @method Phaser.Data.DataManager#setFreeze - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - setFreeze: function (value) - { - this._frozen = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Data.DataManager#reset - * @since 3.0.0 - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - reset: function () - { - for (var key in this.list) - { - delete this.list[key]; - } - - this.blockSet = false; - this._frozen = false; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Data.DataManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.reset(); - - this.events.off('changedata'); - this.events.off('setdata'); - this.events.off('removedata'); - - this.parent = null; - }, - - /** - * Freeze this Data component, so no changes can be written to it. - * - * @name Phaser.Data.DataManager#freeze - * @type {boolean} - * @since 3.0.0 - */ - freeze: { - - get: function () - { - return this._frozen; - }, - - set: function (value) - { - this._frozen = (value) ? true : false; - } - - }, - - /** - * Return the total number of entries in this Data component. - * - * @name Phaser.Data.DataManager#count - * @type {integer} - * @since 3.0.0 - */ - count: { - - get: function () - { - var i = 0; - - for (var key in this.list) - { - if (this.list[key] !== undefined) - { - i++; - } - } - - return i; - } - - } - -}); - -module.exports = DataManager; - - -/***/ }), -/* 80 */ +/* 70 */ /***/ (function(module, exports) { /** @@ -12547,35 +10480,88 @@ module.exports = DataManager; */ /** - * Shuffles the contents of the given array using the Fisher-Yates implementation. + * [description] * - * The original array is modified directly and returned. - * - * @function Phaser.Utils.Array.Shuffle + * @function Phaser.Utils.Object.HasValue * @since 3.0.0 * - * @param {array} array - The array to shuffle. This array is modified in place. + * @param {object} source - [description] + * @param {string} key - [description] * - * @return {array} The shuffled array. + * @return {boolean} [description] */ -var Shuffle = function (array) +var HasValue = function (source, key) { - for (var i = array.length - 1; i > 0; i--) - { - var j = Math.floor(Math.random() * (i + 1)); - var temp = array[i]; - array[i] = array[j]; - array[j] = temp; - } - - return array; + return (source.hasOwnProperty(key)); }; -module.exports = Shuffle; +module.exports = HasValue; /***/ }), -/* 81 */ +/* 71 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var EaseMap = __webpack_require__(749); + +/** + * [description] + * + * @function Phaser.Tweens.Builders.GetEaseFunction + * @since 3.0.0 + * + * @param {(string|function)} ease - [description] + * @param {array} easeParams - [description] + * + * @return {function} [description] + */ +var GetEaseFunction = function (ease, easeParams) +{ + if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease)) + { + if (easeParams) + { + var cloneParams = easeParams.slice(0); + + cloneParams.unshift(0); + + return function (v) + { + cloneParams[0] = v; + + return EaseMap[ease].apply(this, cloneParams); + }; + } + else + { + // String based look-up + return EaseMap[ease]; + } + } + else if (typeof ease === 'function') + { + // Custom function + return ease; + } + else if (Array.isArray(ease) && ease.length === 4) + { + // Bezier function (TODO) + } + + return EaseMap.Power0; +}; + +module.exports = GetEaseFunction; + + +/***/ }), +/* 72 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -12585,263 +10571,88 @@ module.exports = Shuffle; */ var Class = __webpack_require__(0); +var Components = __webpack_require__(13); var GameObject = __webpack_require__(1); -var Sprite = __webpack_require__(37); -var Vector2 = __webpack_require__(6); -var Vector4 = __webpack_require__(120); +var ImageRender = __webpack_require__(757); /** * @classdesc - * A Sprite 3D Game Object. + * An Image Game Object. * - * The Sprite 3D object is an encapsulation of a standard Sprite object, with additional methods to allow - * it to be rendered by a 3D Camera. The Sprite can be positioned anywhere within 3D space. + * An Image is a light-weight Game Object useful for the display of static images in your game, + * such as logos, backgrounds, scenery or other non-animated elements. Images can have input + * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an + * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. * - * @class Sprite3D + * @class Image * @extends Phaser.GameObjects.GameObject * @memberOf Phaser.GameObjects * @constructor * @since 3.0.0 * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The x position of this Game Object. - * @param {number} y - The y position of this Game Object. - * @param {number} z - The z position of this Game Object. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. */ -var Sprite3D = new Class({ +var Image = new Class({ Extends: GameObject, + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Size, + Components.Texture, + Components.Tint, + Components.Transform, + Components.Visible, + ImageRender + ], + initialize: - function Sprite3D (scene, x, y, z, texture, frame) + function Image (scene, x, y, texture, frame) { - GameObject.call(this, scene, 'Sprite3D'); - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#gameObject - * @type {Phaser.GameObjects.GameObject} - * @since 3.0.0 - */ - this.gameObject = new Sprite(scene, 0, 0, texture, frame); - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#position - * @type {Phaser.Math.Vector4} - * @since 3.0.0 - */ - this.position = new Vector4(x, y, z); - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#size - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.size = new Vector2(this.gameObject.width, this.gameObject.height); - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#scale - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.scale = new Vector2(1, 1); - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#adjustScaleX - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.adjustScaleX = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#adjustScaleY - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.adjustScaleY = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#_visible - * @type {boolean} - * @default true - * @private - * @since 3.0.0 - */ - this._visible = true; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Sprite3D#project - * @since 3.0.0 - * - * @param {Phaser.Cameras.Sprite3D.Camera} camera - The 3D Camera onto which to project this Sprite. - */ - project: function (camera) - { - var pos = this.position; - - var gameObject = this.gameObject; - - camera.project(pos, gameObject); - - camera.getPointSize(pos, this.size, this.scale); - - if (this.scale.x <= 0 || this.scale.y <= 0) - { - gameObject.setVisible(false); - } - else - { - if (!gameObject.visible) - { - gameObject.setVisible(true); - } - - if (this.adjustScaleX) - { - gameObject.scaleX = this.scale.x; - } - - if (this.adjustScaleY) - { - gameObject.scaleY = this.scale.y; - } - - gameObject.setDepth(gameObject.z * -1); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Sprite3D#setVisible - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {Phaser.GameObjects.Sprite3D} This Sprite3D Object. - */ - setVisible: function (value) - { - this.visible = value; - - return this; - }, - - /** - * The visible state of the Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - * - * @name Phaser.GameObjects.Sprite3D#visible - * @type {boolean} - * @since 3.0.0 - */ - visible: { - - get: function () - { - return this._visible; - }, - - set: function (value) - { - this._visible = value; - this.gameObject.visible = value; - } - - }, - - /** - * The x position of this Game Object. - * - * @name Phaser.GameObjects.Sprite3D#x - * @type {number} - * @since 3.0.0 - */ - x: { - - get: function () - { - return this.position.x; - }, - - set: function (value) - { - this.position.x = value; - } - - }, - - /** - * The y position of this Game Object. - * - * @name Phaser.GameObjects.Sprite3D#y - * @type {number} - * @since 3.0.0 - */ - y: { - - get: function () - { - return this.position.y; - }, - - set: function (value) - { - this.position.y = value; - } - - }, - - /** - * The z position of this Game Object. - * - * @name Phaser.GameObjects.Sprite3D#z - * @type {number} - * @since 3.0.0 - */ - z: { - - get: function () - { - return this.position.z; - }, - - set: function (value) - { - this.position.z = value; - } + GameObject.call(this, scene, 'Image'); + this.setTexture(texture, frame); + this.setPosition(x, y); + this.setSizeToFrame(); + this.setOriginFromFrame(); + this.initPipeline('TextureTintPipeline'); } }); -module.exports = Sprite3D; +module.exports = Image; /***/ }), -/* 82 */ +/* 73 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -12850,109 +10661,954 @@ module.exports = Sprite3D; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var OS = __webpack_require__(67); +var Actions = __webpack_require__(367); +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(2); +var GetValue = __webpack_require__(5); +var Range = __webpack_require__(264); +var Set = __webpack_require__(63); +var Sprite = __webpack_require__(40); /** - * Determines the browser type and version running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.browser` from within any Scene. - * - * @name Phaser.Device.Browser + * @callback GroupCallback + * + * @param {Phaser.GameObjects.GameObject} item - [description] + */ + +/** + * @callback GroupMultipleCreateCallback + * + * @param {Phaser.GameObjects.GameObject[]} items - [description] + */ + +/** + * @typedef {object} GroupConfig + * + * @property {object} [classType=Sprite] - [description] + * @property {boolean} [active=true] - [description] + * @property {number} [maxSize=-1] - [description] + * @property {?string} [defaultKey=null] - [description] + * @property {?(string|integer)} [defaultFrame=null] - [description] + * @property {boolean} [runChildUpdate=false] - [description] + * @property {?GroupCallback} [createCallback=null] - [description] + * @property {?GroupCallback} [removeCallback=null] - [description] + * @property {?GroupMultipleCreateCallback} [createMultipleCallback=null] - [description] + */ + +/** + * @typedef {object} GroupCreateConfig + * + * @property {object} [classType] - [description] + * @property {string} [key] - [description] + * @property {?(string|integer)} [frame=null] - [description] + * @property {boolean} [visible=true] - [description] + * @property {boolean} [active=true] - [description] + * @property {number} [repeat=0] - [description] + * @property {boolean} [randomKey=false] - [description] + * @property {boolean} [randomFrame=false] - [description] + * @property {boolean} [yoyo=false] - [description] + * @property {number} [frameQuantity=1] - [description] + * @property {number} [max=1] - [description] + * @property {object} [setXY] - [description] + * @property {number} [setXY.x=0] - [description] + * @property {number} [setXY.y=0] - [description] + * @property {number} [setXY.stepX=0] - [description] + * @property {number} [setXY.stepY=0] - [description] + * @property {object} [setRotation] - [description] + * @property {number} [setRotation.value=0] - [description] + * @property {number} [setRotation.step=0] - [description] + * @property {object} [setScale] - [description] + * @property {number} [setScale.x=0] - [description] + * @property {number} [setScale.y=0] - [description] + * @property {number} [setScale.stepX=0] - [description] + * @property {number} [setScale.stepY=0] - [description] + * @property {object} [setAlpha] - [description] + * @property {number} [setAlpha.value=0] - [description] + * @property {number} [setAlpha.step=0] - [description] + * @property {*} [hitArea] - [description] + * @property {HitAreaCallback} [hitAreaCallback] - [description] + * @property {(false|GridAlignConfig)} [gridAlign=false] - [description] + */ + +/** + * @classdesc + * [description] + * + * children can be either an array of children, or a config object + * config can be either a config object, or undefined if passed as the children argument instead + * + * @class Group + * @memberOf Phaser.GameObjects + * @constructor * @since 3.0.0 * - * @type {object} - * @property {boolean} chrome - Set to true if running in Chrome. - * @property {boolean} edge - Set to true if running in Microsoft Edge browser. - * @property {boolean} firefox - Set to true if running in Firefox. - * @property {boolean} ie - Set to true if running in Internet Explorer 11 or less (not Edge). - * @property {boolean} mobileSafari - Set to true if running in Mobile Safari. - * @property {boolean} opera - Set to true if running in Opera. - * @property {boolean} safari - Set to true if running in Safari. - * @property {boolean} silk - Set to true if running in the Silk browser (as used on the Amazon Kindle) - * @property {boolean} trident - Set to true if running a Trident version of Internet Explorer (IE11+) - * @property {number} chromeVersion - If running in Chrome this will contain the major version number. - * @property {number} firefoxVersion - If running in Firefox this will contain the major version number. - * @property {number} ieVersion - If running in Internet Explorer this will contain the major version number. Beyond IE10 you should use Browser.trident and Browser.tridentVersion. - * @property {number} safariVersion - If running in Safari this will contain the major version number. - * @property {number} tridentVersion - If running in Internet Explorer 11 this will contain the major version number. See {@link http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx} + * @param {Phaser.Scene} scene - [description] + * @param {array} children - [description] + * @param {GroupConfig} config - [description] */ -var Browser = { +var Group = new Class({ - chrome: false, - chromeVersion: 0, - edge: false, - firefox: false, - firefoxVersion: 0, - ie: false, - ieVersion: 0, - mobileSafari: false, - opera: false, - safari: false, - safariVersion: 0, - silk: false, - trident: false, - tridentVersion: 0 + initialize: -}; + function Group (scene, children, config) + { + if (config === undefined && !Array.isArray(children) && typeof children === 'object') + { + config = children; + children = null; + } -function init () -{ - var ua = navigator.userAgent; + /** + * [description] + * + * @name Phaser.GameObjects.Group#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; - if (/Edge\/\d+/.test(ua)) + /** + * [description] + * + * @name Phaser.GameObjects.Group#children + * @type {Phaser.Structs.Set} + * @since 3.0.0 + */ + this.children = new Set(children); + + /** + * [description] + * + * @name Phaser.GameObjects.Group#isParent + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.isParent = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Group#classType + * @type {object} + * @since 3.0.0 + */ + this.classType = GetFastValue(config, 'classType', Sprite); + + /** + * [description] + * + * @name Phaser.GameObjects.Group#active + * @type {boolean} + * @since 3.0.0 + */ + this.active = GetFastValue(config, 'active', true); + + /** + * [description] + * + * @name Phaser.GameObjects.Group#maxSize + * @type {integer} + * @since 3.0.0 + */ + this.maxSize = GetFastValue(config, 'maxSize', -1); + + /** + * [description] + * + * @name Phaser.GameObjects.Group#defaultKey + * @type {string} + * @since 3.0.0 + */ + this.defaultKey = GetFastValue(config, 'defaultKey', null); + + /** + * [description] + * + * @name Phaser.GameObjects.Group#defaultFrame + * @type {(string|integer)} + * @since 3.0.0 + */ + this.defaultFrame = GetFastValue(config, 'defaultFrame', null); + + /** + * [description] + * + * @name Phaser.GameObjects.Group#runChildUpdate + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.runChildUpdate = GetFastValue(config, 'runChildUpdate', false); + + /** + * [description] + * + * @name Phaser.GameObjects.Group#createCallback + * @type {?GroupCallback} + * @since 3.0.0 + */ + this.createCallback = GetFastValue(config, 'createCallback', null); + + /** + * [description] + * + * @name Phaser.GameObjects.Group#removeCallback + * @type {?GroupCallback} + * @since 3.0.0 + */ + this.removeCallback = GetFastValue(config, 'removeCallback', null); + + /** + * [description] + * + * @name Phaser.GameObjects.Group#createMultipleCallback + * @type {?GroupMultipleCreateCallback} + * @since 3.0.0 + */ + this.createMultipleCallback = GetFastValue(config, 'createMultipleCallback', null); + + if (config) + { + this.createMultiple(config); + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#create + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {boolean} [visible=true] - The {@link Phaser.GameObjects.Components.Visible#visible} state of this Game Object. + * @param {boolean} [active=true] - The {@link Phaser.GameObjects.GameObject#active} state of this Game Object. + * + * @return {Phaser.GameObjects.GameObject} [description] + */ + create: function (x, y, key, frame, visible, active) { - Browser.edge = true; - } - else if ((/Chrome\/(\d+)/).test(ua) && !OS.windowsPhone) + if (key === undefined) { key = this.defaultKey; } + if (frame === undefined) { frame = this.defaultFrame; } + if (visible === undefined) { visible = true; } + if (active === undefined) { active = true; } + + // Pool? + if (this.isFull()) + { + return null; + } + + var child = new this.classType(this.scene, x, y, key, frame); + + this.scene.sys.displayList.add(child); + + if (child.preUpdate) + { + this.scene.sys.updateList.add(child); + } + + child.visible = visible; + child.setActive(active); + + this.add(child); + + return child; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#createMultiple + * @since 3.0.0 + * + * @param {GroupCreateConfig} config - [description] + * + * @return {Phaser.GameObjects.GameObject[]} [description] + */ + createMultiple: function (config) { - Browser.chrome = true; - Browser.chromeVersion = parseInt(RegExp.$1, 10); - } - else if ((/Firefox\D+(\d+)/).test(ua)) + if (!Array.isArray(config)) + { + config = [ config ]; + } + + var output = []; + + for (var i = 0; i < config.length; i++) + { + var entries = this.createFromConfig(config[i]); + + output = output.concat(entries); + } + + return output; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#createFromConfig + * @since 3.0.0 + * + * @param {GroupCreateConfig} options - [description] + * + * @return {Phaser.GameObjects.GameObject[]} [description] + */ + createFromConfig: function (options) { - Browser.firefox = true; - Browser.firefoxVersion = parseInt(RegExp.$1, 10); - } - else if ((/AppleWebKit/).test(ua) && OS.iOS) + this.classType = GetFastValue(options, 'classType', this.classType); + + var key = GetFastValue(options, 'key', undefined); + var frame = GetFastValue(options, 'frame', null); + var visible = GetFastValue(options, 'visible', true); + var active = GetFastValue(options, 'active', true); + + var entries = []; + + // Can't do anything without at least a key + if (key === undefined) + { + return entries; + } + else + { + if (!Array.isArray(key)) + { + key = [ key ]; + } + + if (!Array.isArray(frame)) + { + frame = [ frame ]; + } + } + + // Build an array of key frame pairs to loop through + + var repeat = GetFastValue(options, 'repeat', 0); + var randomKey = GetFastValue(options, 'randomKey', false); + var randomFrame = GetFastValue(options, 'randomFrame', false); + var yoyo = GetFastValue(options, 'yoyo', false); + var quantity = GetFastValue(options, 'frameQuantity', 1); + var max = GetFastValue(options, 'max', 0); + + // If a grid is set we use that to override the quantity? + + var range = Range(key, frame, { + max: max, + qty: quantity, + random: randomKey, + randomB: randomFrame, + repeat: repeat, + yoyo: yoyo + }); + + for (var c = 0; c < range.length; c++) + { + entries.push(this.create(0, 0, range[c].a, range[c].b, visible, active)); + } + + // Post-creation options (applied only to those items created in this call): + + var x = GetValue(options, 'setXY.x', 0); + var y = GetValue(options, 'setXY.y', 0); + var stepX = GetValue(options, 'setXY.stepX', 0); + var stepY = GetValue(options, 'setXY.stepY', 0); + + Actions.SetXY(entries, x, y, stepX, stepY); + + var rotation = GetValue(options, 'setRotation.value', 0); + var stepRotation = GetValue(options, 'setRotation.step', 0); + + Actions.SetRotation(entries, rotation, stepRotation); + + var scaleX = GetValue(options, 'setScale.x', 1); + var scaleY = GetValue(options, 'setScale.y', scaleX); + var stepScaleX = GetValue(options, 'setScale.stepX', 0); + var stepScaleY = GetValue(options, 'setScale.stepY', 0); + + Actions.SetScale(entries, scaleX, scaleY, stepScaleX, stepScaleY); + + var alpha = GetValue(options, 'setAlpha.value', 1); + var stepAlpha = GetValue(options, 'setAlpha.step', 0); + + Actions.SetAlpha(entries, alpha, stepAlpha); + + var hitArea = GetFastValue(options, 'hitArea', null); + var hitAreaCallback = GetFastValue(options, 'hitAreaCallback', null); + + if (hitArea) + { + Actions.SetHitArea(entries, hitArea, hitAreaCallback); + } + + var grid = GetFastValue(options, 'gridAlign', false); + + if (grid) + { + Actions.GridAlign(entries, grid); + } + + if (this.createMultipleCallback) + { + this.createMultipleCallback.call(this, entries); + } + + return entries; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#preUpdate + * @since 3.0.0 + * + * @param {number} time - [description] + * @param {number} delta - [description] + */ + preUpdate: function (time, delta) { - Browser.mobileSafari = true; - } - else if ((/MSIE (\d+\.\d+);/).test(ua)) + if (!this.runChildUpdate || this.children.size === 0) + { + return; + } + + // Because a Group child may mess with the length of the Group during its update + var temp = this.children.entries.slice(); + + for (var i = 0; i < temp.length; i++) + { + var item = temp[i]; + + if (item.active) + { + item.update(time, delta); + } + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#add + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - [description] + * @param {boolean} [addToScene=false] - [description] + * + * @return {Phaser.GameObjects.Group} This Group object. + */ + add: function (child, addToScene) { - Browser.ie = true; - Browser.ieVersion = parseInt(RegExp.$1, 10); - } - else if ((/Opera/).test(ua)) + if (addToScene === undefined) { addToScene = false; } + + this.children.set(child); + + if (this.createCallback) + { + this.createCallback.call(this, child); + } + + if (addToScene) + { + this.scene.sys.displayList.add(child); + + if (child.preUpdate) + { + this.scene.sys.updateList.add(child); + } + } + + child.on('destroy', this.remove, this); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#addMultiple + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject[]} children - [description] + * @param {boolean} [addToScene=false] - [description] + * + * @return {Phaser.GameObjects.Group} This Group object. + */ + addMultiple: function (children, addToScene) { - Browser.opera = true; - } - else if ((/Safari/).test(ua) && !OS.windowsPhone) + if (addToScene === undefined) { addToScene = false; } + + if (Array.isArray(children)) + { + for (var i = 0; i < children.length; i++) + { + this.add(children[i], addToScene); + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#remove + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - [description] + * @param {boolean} [removeFromScene=false] - [description] + * + * @return {Phaser.GameObjects.Group} This Group object. + */ + remove: function (child, removeFromScene) { - Browser.safari = true; - } - else if ((/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/).test(ua)) + if (removeFromScene === undefined) { removeFromScene = false; } + + this.children.delete(child); + + if (this.removeCallback) + { + this.removeCallback.call(this, child); + } + + if (removeFromScene) + { + this.scene.sys.displayList.remove(child); + + if (child.preUpdate) + { + this.scene.sys.updateList.remove(child); + } + } + + child.off('destroy', this.remove, this); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#clear + * @since 3.0.0 + * + * @param {boolean} [removeFromScene=false] - [description] + * + * @return {Phaser.GameObjects.Group} This Group object. + */ + clear: function (removeFromScene) { - Browser.ie = true; - Browser.trident = true; - Browser.tridentVersion = parseInt(RegExp.$1, 10); - Browser.ieVersion = parseInt(RegExp.$3, 10); + if (removeFromScene === undefined) { removeFromScene = false; } + + var children = this.children; + + for (var i = 0; i < children.size; i++) + { + var gameObject = children.entries[i]; + + gameObject.off('destroy', this.remove, this); + + if (removeFromScene) + { + this.scene.sys.displayList.remove(gameObject); + + if (gameObject.preUpdate) + { + this.scene.sys.updateList.remove(gameObject); + } + } + } + + this.children.clear(); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#contains + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - [description] + * + * @return {boolean} [description] + */ + contains: function (child) + { + return this.children.contains(child); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#getChildren + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject[]} [description] + */ + getChildren: function () + { + return this.children.entries; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#getLength + * @since 3.0.0 + * + * @return {integer} [description] + */ + getLength: function () + { + return this.children.size; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#getFirst + * @since 3.0.0 + * + * @param {boolean} [state=false] - [description] + * @param {boolean} [createIfNull=false] - [description] + * @param {number} [x] - The horizontal position of this Game Object in the world. + * @param {number} [y] - The vertical position of this Game Object in the world. + * @param {string} [texture] - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {boolean} [visible] - [description] + * + * @return {?Phaser.GameObjects.GameObject} [description] + */ + getFirst: function (state, createIfNull, x, y, key, frame, visible) + { + if (state === undefined) { state = false; } + if (createIfNull === undefined) { createIfNull = false; } + + var gameObject; + + var children = this.children.entries; + + for (var i = 0; i < children.length; i++) + { + gameObject = children[i]; + + if (gameObject.active === state) + { + if (typeof(x) === 'number') + { + gameObject.x = x; + } + + if (typeof(y) === 'number') + { + gameObject.y = y; + } + + return gameObject; + } + } + + // Got this far? We need to create or bail + if (createIfNull) + { + return this.create(x, y, key, frame, visible); + } + else + { + return null; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#get + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {boolean} visible - [description] + * + * @return {Phaser.GameObjects.GameObject} [description] + */ + get: function (x, y, key, frame, visible) + { + return this.getFirst(false, true, x, y, key, frame, visible); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#getFirstAlive + * @since 3.0.0 + * + * @param {boolean} createIfNull - [description] + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {boolean} visible - [description] + * + * @return {Phaser.GameObjects.GameObject} [description] + */ + getFirstAlive: function (createIfNull, x, y, key, frame, visible) + { + return this.getFirst(true, createIfNull, x, y, key, frame, visible); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#getFirstDead + * @since 3.0.0 + * + * @param {boolean} createIfNull - [description] + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {boolean} visible - [description] + * + * @return {Phaser.GameObjects.GameObject} [description] + */ + getFirstDead: function (createIfNull, x, y, key, frame, visible) + { + return this.getFirst(false, createIfNull, x, y, key, frame, visible); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#playAnimation + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} startFrame - [description] + * + * @return {Phaser.GameObjects.Group} This Group object. + */ + playAnimation: function (key, startFrame) + { + Actions.PlayAnimation(this.children.entries, key, startFrame); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#isFull + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isFull: function () + { + if (this.maxSize === -1) + { + return false; + } + else + { + return (this.children.size === this.maxSize); + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#countActive + * @since 3.0.0 + * + * @param {boolean} [value=true] - [description] + * + * @return {integer} [description] + */ + countActive: function (value) + { + if (value === undefined) { value = true; } + + var total = 0; + + for (var i = 0; i < this.children.size; i++) + { + if (this.children.entries[i].active === value) + { + total++; + } + } + + return total; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#getTotalUsed + * @since 3.0.0 + * + * @return {integer} [description] + */ + getTotalUsed: function () + { + return this.countActive(); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#getTotalFree + * @since 3.0.0 + * + * @return {integer} [description] + */ + getTotalFree: function () + { + var used = this.getTotalUsed(); + var capacity = (this.maxSize === -1) ? 999999999999 : this.maxSize; + + return (capacity - used); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#setDepth + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} step - [description] + * + * @return {Phaser.GameObjects.Group} This Group object. + */ + setDepth: function (value, step) + { + Actions.SetDepth(this.children.entries, value, step); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#kill + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + */ + kill: function (gameObject) + { + if (this.children.contains(gameObject)) + { + gameObject.setActive(false); + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#killAndHide + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + */ + killAndHide: function (gameObject) + { + if (this.children.contains(gameObject)) + { + gameObject.setActive(false); + gameObject.setVisible(false); + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#toggleVisible + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Group} This Group object. + */ + toggleVisible: function () + { + Actions.ToggleVisible(this.children.entries); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.children.clear(); + + this.scene = undefined; + this.children = undefined; } - // Silk gets its own if clause because its ua also contains 'Safari' - if ((/Silk/).test(ua)) - { - Browser.silk = true; - } +}); - return Browser; -} - -module.exports = init(); +module.exports = Group; /***/ }), -/* 83 */ +/* 74 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Check to see if the Ellipse contains the given x / y coordinates. + * + * @function Phaser.Geom.Ellipse.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. + * @param {number} x - The x coordinate to check within the ellipse. + * @param {number} y - The y coordinate to check within the ellipse. + * + * @return {boolean} True if the coordinates are within the ellipse, otherwise false. + */ +var Contains = function (ellipse, x, y) +{ + if (ellipse.width <= 0 || ellipse.height <= 0) + { + return false; + } + + // Normalize the coords to an ellipse with center 0,0 and a radius of 0.5 + var normx = ((x - ellipse.x) / ellipse.width); + var normy = ((y - ellipse.y) / ellipse.height); + + normx *= normx; + normy *= normy; + + return (normx + normy < 0.25); +}; + +module.exports = Contains; + + +/***/ }), +/* 75 */ /***/ (function(module, exports) { /** @@ -13057,6 +11713,920 @@ module.exports = { }; +/***/ }), +/* 76 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(process) {/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Determines the operating system of the device running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.os` from within any Scene. + * + * @name Phaser.Device.OS + * @since 3.0.0 + * + * @type {object} + * @property {boolean} android - Is running on android? + * @property {boolean} chromeOS - Is running on chromeOS? + * @property {boolean} cocoonJS - Is the game running under CocoonJS? + * @property {boolean} cocoonJSApp - Is this game running with CocoonJS.App? + * @property {boolean} cordova - Is the game running under Apache Cordova? + * @property {boolean} crosswalk - Is the game running under the Intel Crosswalk XDK? + * @property {boolean} desktop - Is running on a desktop? + * @property {boolean} ejecta - Is the game running under Ejecta? + * @property {boolean} electron - Is the game running under GitHub Electron? + * @property {boolean} iOS - Is running on iOS? + * @property {boolean} iPad - Is running on iPad? + * @property {boolean} iPhone - Is running on iPhone? + * @property {boolean} kindle - Is running on an Amazon Kindle? + * @property {boolean} linux - Is running on linux? + * @property {boolean} macOS - Is running on macOS? + * @property {boolean} node - Is the game running under Node.js? + * @property {boolean} nodeWebkit - Is the game running under Node-Webkit? + * @property {boolean} webApp - Set to true if running as a WebApp, i.e. within a WebView + * @property {boolean} windows - Is running on windows? + * @property {boolean} windowsPhone - Is running on a Windows Phone? + * @property {number} iOSVersion - If running in iOS this will contain the major version number. + * @property {number} pixelRatio - PixelRatio of the host device? + */ +var OS = { + + android: false, + chromeOS: false, + cocoonJS: false, + cocoonJSApp: false, + cordova: false, + crosswalk: false, + desktop: false, + ejecta: false, + electron: false, + iOS: false, + iOSVersion: 0, + iPad: false, + iPhone: false, + kindle: false, + linux: false, + macOS: false, + node: false, + nodeWebkit: false, + pixelRatio: 1, + webApp: false, + windows: false, + windowsPhone: false + +}; + +function init () +{ + var ua = navigator.userAgent; + + if (/Windows/.test(ua)) + { + OS.windows = true; + } + else if (/Mac OS/.test(ua)) + { + OS.macOS = true; + } + else if (/Linux/.test(ua)) + { + OS.linux = true; + } + else if (/Android/.test(ua)) + { + OS.android = true; + } + else if (/iP[ao]d|iPhone/i.test(ua)) + { + OS.iOS = true; + (navigator.appVersion).match(/OS (\d+)/); + OS.iOSVersion = parseInt(RegExp.$1, 10); + } + else if (/Kindle/.test(ua) || (/\bKF[A-Z][A-Z]+/).test(ua) || (/Silk.*Mobile Safari/).test(ua)) + { + OS.kindle = true; + + // This will NOT detect early generations of Kindle Fire, I think there is no reliable way... + // E.g. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-80) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true" + } + else if (/CrOS/.test(ua)) + { + OS.chromeOS = true; + } + + if (/Windows Phone/i.test(ua) || (/IEMobile/i).test(ua)) + { + OS.android = false; + OS.iOS = false; + OS.macOS = false; + OS.windows = true; + OS.windowsPhone = true; + } + + var silk = (/Silk/).test(ua); + + if (OS.windows || OS.macOS || (OS.linux && !silk) || OS.chromeOS) + { + OS.desktop = true; + } + + // Windows Phone / Table reset + if (OS.windowsPhone || ((/Windows NT/i.test(ua)) && (/Touch/i.test(ua)))) + { + OS.desktop = false; + } + + // WebApp mode in iOS + if (navigator.standalone) + { + OS.webApp = true; + } + + if (window.cordova !== undefined) + { + OS.cordova = true; + } + + if ((typeof process !== 'undefined') && (typeof process.versions.node !== 'undefined')) + { + OS.node = true; + } + + if (OS.node && typeof process.versions === 'object') + { + OS.nodeWebkit = !!process.versions['node-webkit']; + + OS.electron = !!process.versions.electron; + } + + if (navigator.isCocoonJS) + { + OS.cocoonJS = true; + + try + { + OS.cocoonJSApp = (typeof CocoonJS !== 'undefined'); + } + catch (error) + { + OS.cocoonJSApp = false; + } + } + + if (window.ejecta !== undefined) + { + OS.ejecta = true; + } + + if ((/Crosswalk/).test(ua)) + { + OS.crosswalk = true; + } + + OS.iPhone = ua.toLowerCase().indexOf('iphone') !== -1; + OS.iPad = ua.toLowerCase().indexOf('ipad') !== -1; + + OS.pixelRatio = window['devicePixelRatio'] || 1; + + return OS; +} + +module.exports = init(); + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(821))) + +/***/ }), +/* 77 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Line.Length + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * + * @return {number} [description] + */ +var Length = function (line) +{ + return Math.sqrt((line.x2 - line.x1) * (line.x2 - line.x1) + (line.y2 - line.y1) * (line.y2 - line.y1)); +}; + +module.exports = Length; + + +/***/ }), +/* 78 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(64); + +/** + * Return a value based on the range between `min` and `max` and the percentage given. + * + * @function Phaser.Math.FromPercent + * @since 3.0.0 + * + * @param {float} percent - A value between 0 and 1 representing the percentage. + * @param {number} min - [description] + * @param {number} [max] - [description] + * + * @return {number} [description] + */ +var FromPercent = function (percent, min, max) +{ + percent = Clamp(percent, 0, 1); + + return (max - min) * percent; +}; + +module.exports = FromPercent; + + +/***/ }), +/* 79 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Contains = __webpack_require__(28); +var GetPoint = __webpack_require__(355); +var GetPoints = __webpack_require__(354); +var Random = __webpack_require__(167); + +/** + * @classdesc + * A Circle object. + * + * This is a geometry object, containing numerical values and related methods to inspect and modify them. + * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. + * To render a Circle you should look at the capabilities of the Graphics class. + * + * @class Circle + * @memberOf Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of the center of the circle. + * @param {number} [y=0] - The y position of the center of the circle. + * @param {number} [radius=0] - The radius of the circle. + */ +var Circle = new Class({ + + initialize: + + function Circle (x, y, radius) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (radius === undefined) { radius = 0; } + + /** + * The x position of the center of the circle. + * + * @name Phaser.Geom.Circle#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = x; + + /** + * The y position of the center of the circle. + * + * @name Phaser.Geom.Circle#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = y; + + /** + * The internal radius of the circle. + * + * @name Phaser.Geom.Circle#_radius + * @type {number} + * @private + * @since 3.0.0 + */ + this._radius = radius; + + /** + * The internal diameter of the circle. + * + * @name Phaser.Geom.Circle#_diameter + * @type {number} + * @private + * @since 3.0.0 + */ + this._diameter = radius * 2; + }, + + /** + * Check to see if the Circle contains the given x / y coordinates. + * + * @method Phaser.Geom.Circle#contains + * @since 3.0.0 + * + * @param {number} x - The x coordinate to check within the circle. + * @param {number} y - The y coordinate to check within the circle. + * + * @return {boolean} True if the coordinates are within the circle, otherwise false. + */ + contains: function (x, y) + { + return Contains(this, x, y); + }, + + /** + * Returns a Point object containing the coordinates of a point on the circumference of the Circle + * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point + * at 180 degrees around the circle. + * + * @method Phaser.Geom.Circle#getPoint + * @since 3.0.0 + * + * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. + * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. + * + * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the circle. + */ + getPoint: function (position, point) + { + return GetPoint(this, position, point); + }, + + /** + * Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, + * based on the given quantity or stepRate values. + * + * @method Phaser.Geom.Circle#getPoints + * @since 3.0.0 + * + * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. + * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. + * + * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the circumference of the circle. + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * Returns a uniformly distributed random point from anywhere within the Circle. + * + * @method Phaser.Geom.Circle#getRandomPoint + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} [point] - A Point or point-like object to set the random `x` and `y` values in. + * + * @return {(Phaser.Geom.Point|object)} A Point object with the random values set in the `x` and `y` properties. + */ + getRandomPoint: function (point) + { + return Random(this, point); + }, + + /** + * Sets the x, y and radius of this circle. + * + * @method Phaser.Geom.Circle#setTo + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of the center of the circle. + * @param {number} [y=0] - The y position of the center of the circle. + * @param {number} [radius=0] - The radius of the circle. + * + * @return {Phaser.Geom.Circle} This Circle object. + */ + setTo: function (x, y, radius) + { + this.x = x; + this.y = y; + this._radius = radius; + this._diameter = radius * 2; + + return this; + }, + + /** + * Sets this Circle to be empty with a radius of zero. + * Does not change its position. + * + * @method Phaser.Geom.Circle#setEmpty + * @since 3.0.0 + * + * @return {Phaser.Geom.Circle} This Circle object. + */ + setEmpty: function () + { + this._radius = 0; + this._diameter = 0; + + return this; + }, + + /** + * Sets the position of this Circle. + * + * @method Phaser.Geom.Circle#setPosition + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of the center of the circle. + * @param {number} [y=0] - The y position of the center of the circle. + * + * @return {Phaser.Geom.Circle} This Circle object. + */ + setPosition: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * Checks to see if the Circle is empty: has a radius of zero. + * + * @method Phaser.Geom.Circle#isEmpty + * @since 3.0.0 + * + * @return {boolean} True if the Circle is empty, otherwise false. + */ + isEmpty: function () + { + return (this._radius <= 0); + }, + + /** + * The radius of the Circle. + * + * @name Phaser.Geom.Circle#radius + * @type {number} + * @since 3.0.0 + */ + radius: { + + get: function () + { + return this._radius; + }, + + set: function (value) + { + this._radius = value; + this._diameter = value * 2; + } + + }, + + /** + * The diameter of the Circle. + * + * @name Phaser.Geom.Circle#diameter + * @type {number} + * @since 3.0.0 + */ + diameter: { + + get: function () + { + return this._diameter; + }, + + set: function (value) + { + this._diameter = value; + this._radius = value * 0.5; + } + + }, + + /** + * The left position of the Circle. + * + * @name Phaser.Geom.Circle#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () + { + return this.x - this._radius; + }, + + set: function (value) + { + this.x = value + this._radius; + } + + }, + + /** + * The right position of the Circle. + * + * @name Phaser.Geom.Circle#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return this.x + this._radius; + }, + + set: function (value) + { + this.x = value - this._radius; + } + + }, + + /** + * The top position of the Circle. + * + * @name Phaser.Geom.Circle#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return this.y - this._radius; + }, + + set: function (value) + { + this.y = value + this._radius; + } + + }, + + /** + * The bottom position of the Circle. + * + * @name Phaser.Geom.Circle#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return this.y + this._radius; + }, + + set: function (value) + { + this.y = value - this._radius; + } + + } + +}); + +module.exports = Circle; + + +/***/ }), +/* 80 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.ScaleModes + */ + +module.exports = { + + /** + * Default Scale Mode (Linear). + * + * @name Phaser.ScaleModes.DEFAULT + * @type {integer} + * @since 3.0.0 + */ + DEFAULT: 0, + + /** + * Linear Scale Mode. + * + * @name Phaser.ScaleModes.LINEAR + * @type {integer} + * @since 3.0.0 + */ + LINEAR: 0, + + /** + * Nearest Scale Mode. + * + * @name Phaser.ScaleModes.NEAREST + * @type {integer} + * @since 3.0.0 + */ + NEAREST: 1 + +}; + + +/***/ }), +/* 81 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the routine from {@link http://jsfiddle.net/MrPolywhirl/NH42z/}. + +var CheckMatrix = __webpack_require__(109); +var TransposeMatrix = __webpack_require__(177); + +/** + * [description] + * + * @function Phaser.Utils.Array.Matrix.RotateMatrix + * @since 3.0.0 + * + * @param {array} matrix - The array to rotate. + * @param {(number|string)} [direction=90] - The amount to rotate the matrix by. The value can be given in degrees: 90, -90, 270, -270 or 180, or a string command: `rotateLeft`, `rotateRight` or `rotate180`. + * + * @return {array} The rotated matrix array. The source matrix should be discard for the returned matrix. + */ +var RotateMatrix = function (matrix, direction) +{ + if (direction === undefined) { direction = 90; } + + if (!CheckMatrix(matrix)) + { + return null; + } + + if (typeof direction !== 'string') + { + direction = ((direction % 360) + 360) % 360; + } + + if (direction === 90 || direction === -270 || direction === 'rotateLeft') + { + matrix = TransposeMatrix(matrix); + matrix.reverse(); + } + else if (direction === -90 || direction === 270 || direction === 'rotateRight') + { + matrix.reverse(); + matrix = TransposeMatrix(matrix); + } + else if (Math.abs(direction) === 180 || direction === 'rotate180') + { + for (var i = 0; i < matrix.length; i++) + { + matrix[i].reverse(); + } + + matrix.reverse(); + } + + return matrix; +}; + +module.exports = RotateMatrix; + + +/***/ }), +/* 82 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Defaults = __webpack_require__(112); +var GetAdvancedValue = __webpack_require__(8); +var GetBoolean = __webpack_require__(69); +var GetEaseFunction = __webpack_require__(71); +var GetNewValue = __webpack_require__(83); +var GetProps = __webpack_require__(182); +var GetTargets = __webpack_require__(114); +var GetValue = __webpack_require__(5); +var GetValueOp = __webpack_require__(113); +var Tween = __webpack_require__(111); +var TweenData = __webpack_require__(110); + +/** + * [description] + * + * @function Phaser.Tweens.Builders.TweenBuilder + * @since 3.0.0 + * + * @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - [description] + * @param {object} config - [description] + * @param {Phaser.Tweens.TweenConfigDefaults} defaults - [description] + * + * @return {Phaser.Tweens.Tween} [description] + */ +var TweenBuilder = function (parent, config, defaults) +{ + if (defaults === undefined) + { + defaults = Defaults; + } + + // Create arrays of the Targets and the Properties + var targets = (defaults.targets) ? defaults.targets : GetTargets(config); + + // var props = (defaults.props) ? defaults.props : GetProps(config); + var props = GetProps(config); + + // Default Tween values + var delay = GetNewValue(config, 'delay', defaults.delay); + var duration = GetNewValue(config, 'duration', defaults.duration); + var easeParams = GetValue(config, 'easeParams', defaults.easeParams); + var ease = GetEaseFunction(GetValue(config, 'ease', defaults.ease), easeParams); + var hold = GetNewValue(config, 'hold', defaults.hold); + var repeat = GetNewValue(config, 'repeat', defaults.repeat); + var repeatDelay = GetNewValue(config, 'repeatDelay', defaults.repeatDelay); + var yoyo = GetBoolean(config, 'yoyo', defaults.yoyo); + var flipX = GetBoolean(config, 'flipX', defaults.flipX); + var flipY = GetBoolean(config, 'flipY', defaults.flipY); + + var data = []; + + // Loop through every property defined in the Tween, i.e.: props { x, y, alpha } + for (var p = 0; p < props.length; p++) + { + var key = props[p].key; + var value = props[p].value; + + // Create 1 TweenData per target, per property + for (var t = 0; t < targets.length; t++) + { + var ops = GetValueOp(key, value); + + var tweenData = TweenData( + targets[t], + key, + ops.getEnd, + ops.getStart, + GetEaseFunction(GetValue(value, 'ease', ease), easeParams), + GetNewValue(value, 'delay', delay), + GetNewValue(value, 'duration', duration), + GetBoolean(value, 'yoyo', yoyo), + GetNewValue(value, 'hold', hold), + GetNewValue(value, 'repeat', repeat), + GetNewValue(value, 'repeatDelay', repeatDelay), + GetBoolean(value, 'flipX', flipX), + GetBoolean(value, 'flipY', flipY) + ); + + data.push(tweenData); + } + } + + var tween = new Tween(parent, data, targets); + + tween.offset = GetAdvancedValue(config, 'offset', null); + tween.completeDelay = GetAdvancedValue(config, 'completeDelay', 0); + tween.loop = Math.round(GetAdvancedValue(config, 'loop', 0)); + tween.loopDelay = Math.round(GetAdvancedValue(config, 'loopDelay', 0)); + tween.paused = GetBoolean(config, 'paused', false); + tween.useFrames = GetBoolean(config, 'useFrames', false); + + // Set the Callbacks + var scope = GetValue(config, 'callbackScope', tween); + + // Callback parameters: 0 = a reference to the Tween itself, 1 = the target/s of the Tween, ... your own params + var tweenArray = [ tween, null ]; + + var callbacks = Tween.TYPES; + + for (var i = 0; i < callbacks.length; i++) + { + var type = callbacks[i]; + + var callback = GetValue(config, type, false); + + if (callback) + { + var callbackScope = GetValue(config, type + 'Scope', scope); + var callbackParams = GetValue(config, type + 'Params', []); + + // The null is reset to be the Tween target + tween.setCallback(type, callback, tweenArray.concat(callbackParams), callbackScope); + } + } + + return tween; +}; + +module.exports = TweenBuilder; + + +/***/ }), +/* 83 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Tweens.Builders.GetNewValue + * @since 3.0.0 + * + * @param {object} source - [description] + * @param {string} key - [description] + * @param {*} defaultValue - [description] + * + * @return {function} [description] + */ +var GetNewValue = function (source, key, defaultValue) +{ + var valueCallback; + + if (source.hasOwnProperty(key)) + { + var t = typeof(source[key]); + + if (t === 'function') + { + valueCallback = function (index, totalTargets, target) + { + return source[key](index, totalTargets, target); + }; + } + else + { + valueCallback = function () + { + return source[key]; + }; + } + } + else if (typeof defaultValue === 'function') + { + valueCallback = defaultValue; + } + else + { + valueCallback = function () + { + return defaultValue; + }; + } + + return valueCallback; +}; + +module.exports = GetNewValue; + + /***/ }), /* 84 */ /***/ (function(module, exports, __webpack_require__) { @@ -13066,1122 +12636,601 @@ module.exports = { * @copyright 2018 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ + var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(14); -var NOOP = __webpack_require__(3); /** * @classdesc - * The sound manager is responsible for playing back audio via Web Audio API or HTML Audio tag as fallback. - * The audio file type and the encoding of those files are extremely important. - * Not all browsers can play all audio formats. - * There is a good guide to what's supported [here](https://developer.mozilla.org/en-US/Apps/Fundamentals/Audio_and_video_delivery/Cross-browser_audio_basics#Audio_Codec_Support). + * A Tileset is a combination of an image containing the tiles and a container for data about + * each tile. * - * @class BaseSoundManager - * @extends EventEmitter - * @memberOf Phaser.Sound + * @class Tileset + * @memberOf Phaser.Tilemaps * @constructor - * @author Pavle Goloskokovic (http://prunegames.com) * @since 3.0.0 * - * @param {Phaser.Game} game - Reference to the current game instance. + * @param {string} name - The name of the tileset in the map data. + * @param {integer} firstgid - The first tile index this tileset contains. + * @param {integer} [tileWidth=32] - Width of each tile (in pixels). + * @param {integer} [tileHeight=32] - Height of each tile (in pixels). + * @param {integer} [tileMargin=0] - The margin around all tiles in the sheet (in pixels). + * @param {integer} [tileSpacing=0] - The spacing between each tile in the sheet (in pixels). + * @param {object} [tileProperties={}] - Custom properties defined per tile in the Tileset. + * These typically are custom properties created in Tiled when editing a tileset. + * @param {object} [tileData={}] - Data stored per tile. These typically are created in Tiled + * when editing a tileset, e.g. from Tiled's tile collision editor or terrain editor. */ -var BaseSoundManager = new Class({ - Extends: EventEmitter, - initialize: function BaseSoundManager (game) +var Tileset = new Class({ + + initialize: + + function Tileset (name, firstgid, tileWidth, tileHeight, tileMargin, tileSpacing, tileProperties, tileData) { - EventEmitter.call(this); + if (tileWidth === undefined || tileWidth <= 0) { tileWidth = 32; } + if (tileHeight === undefined || tileHeight <= 0) { tileHeight = 32; } + if (tileMargin === undefined) { tileMargin = 0; } + if (tileSpacing === undefined) { tileSpacing = 0; } + if (tileProperties === undefined) { tileProperties = {}; } + if (tileData === undefined) { tileData = {}; } /** - * Local reference to game. + * The name of the Tileset. * - * @name Phaser.Sound.BaseSoundManager#game - * @type {Phaser.Game} + * @name Phaser.Tilemaps.Tileset#name + * @type {string} + * @since 3.0.0 + */ + this.name = name; + + /** + * The starting index of the first tile index this Tileset contains. + * + * @name Phaser.Tilemaps.Tileset#firstgid + * @type {integer} + * @since 3.0.0 + */ + this.firstgid = firstgid; + + /** + * The width of each tile (in pixels). Use setTileSize to change. + * + * @name Phaser.Tilemaps.Tileset#tileWidth + * @type {integer} * @readOnly * @since 3.0.0 */ - this.game = game; + this.tileWidth = tileWidth; /** - * An array containing all added sounds. + * The height of each tile (in pixels). Use setTileSize to change. * - * @name Phaser.Sound.BaseSoundManager#sounds - * @type {Phaser.Sound.BaseSound[]} - * @default [] - * @private - * @since 3.0.0 - */ - this.sounds = []; - - /** - * Global mute setting. - * - * @name Phaser.Sound.BaseSoundManager#mute - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.mute = false; - - /** - * Global volume setting. - * - * @name Phaser.Sound.BaseSoundManager#volume - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.volume = 1; - - /** - * Flag indicating if sounds should be paused when game looses focus, - * for instance when user switches to another tab/program/app. - * - * @name Phaser.Sound.BaseSoundManager#pauseOnBlur - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.pauseOnBlur = true; - - game.events.on('blur', function () - { - if (this.pauseOnBlur) - { - this.onBlur(); - } - }, this); - - game.events.on('focus', function () - { - if (this.pauseOnBlur) - { - this.onFocus(); - } - }, this); - - game.events.once('destroy', this.destroy, this); - - /** - * Property that actually holds the value of global playback rate. - * - * @name Phaser.Sound.BaseSoundManager#_rate - * @type {number} - * @private - * @default 1 - * @since 3.0.0 - */ - this._rate = 1; - - /** - * Property that actually holds the value of global detune. - * - * @name Phaser.Sound.BaseSoundManager#_detune - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._detune = 0; - - /** - * Mobile devices require sounds to be triggered from an explicit user action, - * such as a tap, before any sound can be loaded/played on a web page. - * Set to true if the audio system is currently locked awaiting user interaction. - * - * @name Phaser.Sound.BaseSoundManager#locked - * @type {boolean} + * @name Phaser.Tilemaps.Tileset#tileHeight + * @type {integer} * @readOnly * @since 3.0.0 */ - this.locked = this.locked || false; + this.tileHeight = tileHeight; /** - * Flag used internally for handling when the audio system - * has been unlocked, if there ever was a need for it. + * The margin around the tiles in the sheet (in pixels). Use `setSpacing` to change. * - * @name Phaser.Sound.BaseSoundManager#unlocked - * @type {boolean} - * @default false - * @private + * @name Phaser.Tilemaps.Tileset#tileMargin + * @type {integer} + * @readOnly * @since 3.0.0 */ - this.unlocked = false; - - if (this.locked) - { - this.unlock(); - } - }, - - /** - * Adds a new sound into the sound manager. - * - * @method Phaser.Sound.BaseSoundManager#add - * @override - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - * - * @return {Phaser.Sound.BaseSound} The new sound instance. - */ - add: NOOP, - - /** - * Audio sprite sound type. - * - * @typedef {Phaser.Sound.BaseSound} AudioSpriteSound - * - * @property {object} spritemap - Local reference to 'spritemap' object form json file generated by audiosprite tool. - */ - /** - * Adds a new audio sprite sound into the sound manager. - * - * @method Phaser.Sound.BaseSoundManager#addAudioSprite - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - * - * @return {AudioSpriteSound} The new audio sprite sound instance. - */ - addAudioSprite: function (key, config) - { - var sound = this.add(key, config); - sound.spritemap = this.game.cache.json.get(key).spritemap; - for (var markerName in sound.spritemap) - { - if (!sound.spritemap.hasOwnProperty(markerName)) - { - continue; - } - var marker = sound.spritemap[markerName]; - sound.addMarker({ - name: markerName, - start: marker.start, - duration: marker.end - marker.start, - config: config - }); - } - return sound; - }, - - /** - * Enables playing sound on the fly without the need to keep a reference to it. - * Sound will auto destroy once its playback ends. - * - * @method Phaser.Sound.BaseSoundManager#play - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {SoundConfig|SoundMarker} [extra] - An optional additional object containing settings to be applied to the sound. It could be either config or marker object. - * - * @return {boolean} Whether the sound started playing successfully. - */ - play: function (key, extra) - { - var sound = this.add(key); - sound.once('ended', sound.destroy, sound); - if (extra) - { - if (extra.name) - { - sound.addMarker(extra); - return sound.play(extra.name); - } - else - { - return sound.play(extra); - } - } - else - { - return sound.play(); - } - }, - - /** - * Enables playing audio sprite sound on the fly without the need to keep a reference to it. - * Sound will auto destroy once its playback ends. - * - * @method Phaser.Sound.BaseSoundManager#playAudioSprite - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {string} spriteName - The name of the sound sprite to play. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - * - * @return {boolean} Whether the audio sprite sound started playing successfully. - */ - playAudioSprite: function (key, spriteName, config) - { - var sound = this.addAudioSprite(key); - sound.once('ended', sound.destroy, sound); - return sound.play(spriteName, config); - }, - - /** - * Removes a sound from the sound manager. - * The removed sound is destroyed before removal. - * - * @method Phaser.Sound.BaseSoundManager#remove - * @since 3.0.0 - * - * @param {Phaser.Sound.BaseSound} sound - The sound object to remove. - * - * @return {boolean} True if the sound was removed successfully, otherwise false. - */ - remove: function (sound) - { - var index = this.sounds.indexOf(sound); - if (index !== -1) - { - sound.destroy(); - this.sounds.splice(index, 1); - return true; - } - return false; - }, - - /** - * Removes all sounds from the sound manager that have an asset key matching the given value. - * The removed sounds are destroyed before removal. - * - * @method Phaser.Sound.BaseSoundManager#removeByKey - * @since 3.0.0 - * - * @param {string} key - The key to match when removing sound objects. - * - * @return {number} The number of matching sound objects that were removed. - */ - removeByKey: function (key) - { - var removed = 0; - for (var i = this.sounds.length - 1; i >= 0; i--) - { - var sound = this.sounds[i]; - if (sound.key === key) - { - sound.destroy(); - this.sounds.splice(i, 1); - removed++; - } - } - return removed; - }, - - /** - * Pauses all the sounds in the game. - * - * @method Phaser.Sound.BaseSoundManager#pauseAll - * @since 3.0.0 - */ - pauseAll: function () - { - this.forEachActiveSound(function (sound) - { - sound.pause(); - }); + this.tileMargin = tileMargin; /** - * @event Phaser.Sound.BaseSoundManager#pauseall - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + * The spacing between each the tile in the sheet (in pixels). Use `setSpacing` to change. + * + * @name Phaser.Tilemaps.Tileset#tileSpacing + * @type {integer} + * @readOnly + * @since 3.0.0 */ - this.emit('pauseall', this); - }, - - /** - * Resumes all the sounds in the game. - * - * @method Phaser.Sound.BaseSoundManager#resumeAll - * @since 3.0.0 - */ - resumeAll: function () - { - this.forEachActiveSound(function (sound) - { - sound.resume(); - }); + this.tileSpacing = tileSpacing; /** - * @event Phaser.Sound.BaseSoundManager#resumeall - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + * Tileset-specific properties per tile that are typically defined in the Tiled editor in the + * Tileset editor. + * + * @name Phaser.Tilemaps.Tileset#tileProperties + * @type {object} + * @since 3.0.0 */ - this.emit('resumeall', this); - }, - - /** - * Stops all the sounds in the game. - * - * @method Phaser.Sound.BaseSoundManager#stopAll - * @since 3.0.0 - */ - stopAll: function () - { - this.forEachActiveSound(function (sound) - { - sound.stop(); - }); + this.tileProperties = tileProperties; /** - * @event Phaser.Sound.BaseSoundManager#stopall - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + * Tileset-specific data per tile that are typically defined in the Tiled editor, e.g. within + * the Tileset collision editor. This is where collision objects and terrain are stored. + * + * @name Phaser.Tilemaps.Tileset#tileData + * @type {object} + * @since 3.0.0 */ - this.emit('stopall', this); + this.tileData = tileData; + + /** + * The cached image that contains the individual tiles. Use setImage to set. + * + * @name Phaser.Tilemaps.Tileset#image + * @type {?Phaser.Textures.Texture} + * @readOnly + * @since 3.0.0 + */ + this.image = null; + + /** + * The number of tile rows in the the tileset. + * + * @name Phaser.Tilemaps.Tileset#rows + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + this.rows = 0; + + /** + * The number of tile columns in the tileset. + * + * @name Phaser.Tilemaps.Tileset#columns + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + this.columns = 0; + + /** + * The total number of tiles in the tileset. + * + * @name Phaser.Tilemaps.Tileset#total + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + this.total = 0; + + /** + * The look-up table to specific tile image texture coordinates (UV in pixels). Each element + * contains the coordinates for a tile in an object of the form {x, y}. + * + * @name Phaser.Tilemaps.Tileset#texCoordinates + * @type {object[]} + * @readOnly + * @since 3.0.0 + */ + this.texCoordinates = []; }, /** - * Method used internally for unlocking audio playback on devices that - * require user interaction before any sound can be played on a web page. + * Get a tiles properties that are stored in the Tileset. Returns null if tile index is not + * contained in this Tileset. This is typically defined in Tiled under the Tileset editor. * - * Read more about how this issue is handled here in [this article](https://medium.com/@pgoloskokovic/unlocking-web-audio-the-smarter-way-8858218c0e09). - * - * @method Phaser.Sound.BaseSoundManager#unlock - * @override - * @protected - * @since 3.0.0 - */ - unlock: NOOP, - - /** - * Method used internally for pausing sound manager if - * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.BaseSoundManager#onBlur - * @override - * @protected - * @since 3.0.0 - */ - onBlur: NOOP, - - /** - * Method used internally for resuming sound manager if - * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.BaseSoundManager#onFocus - * @override - * @protected - * @since 3.0.0 - */ - onFocus: NOOP, - - /** - * Update method called on every game step. - * Removes destroyed sounds and updates every active sound in the game. - * - * @method Phaser.Sound.BaseSoundManager#update - * @protected + * @method Phaser.Tilemaps.Tileset#getTileProperties * @since 3.0.0 * - * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {number} delta - The delta time elapsed since the last frame. + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {?(object|undefined)} */ - update: function (time, delta) + getTileProperties: function (tileIndex) { - if (this.unlocked) - { - this.unlocked = false; - this.locked = false; + if (!this.containsTileIndex(tileIndex)) { return null; } - /** - * @event Phaser.Sound.BaseSoundManager#unlocked - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - */ - this.emit('unlocked', this); - } - for (var i = this.sounds.length - 1; i >= 0; i--) + return this.tileProperties[tileIndex - this.firstgid]; + }, + + /** + * Get a tile's data that is stored in the Tileset. Returns null if tile index is not contained + * in this Tileset. This is typically defined in Tiled and will contain both Tileset collision + * info and terrain mapping. + * + * @method Phaser.Tilemaps.Tileset#getTileData + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {?object|undefined} + */ + getTileData: function (tileIndex) + { + if (!this.containsTileIndex(tileIndex)) { return null; } + + return this.tileData[tileIndex - this.firstgid]; + }, + + /** + * Get a tile's collision group that is stored in the Tileset. Returns null if tile index is not + * contained in this Tileset. This is typically defined within Tiled's tileset collision editor. + * + * @method Phaser.Tilemaps.Tileset#getTileCollisionGroup + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {?object} + */ + getTileCollisionGroup: function (tileIndex) + { + var data = this.getTileData(tileIndex); + + return (data && data.objectgroup) ? data.objectgroup : null; + }, + + /** + * Returns true if and only if this Tileset contains the given tile index. + * + * @method Phaser.Tilemaps.Tileset#containsTileIndex + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {boolean} + */ + containsTileIndex: function (tileIndex) + { + return ( + tileIndex >= this.firstgid && + tileIndex < (this.firstgid + this.total) + ); + }, + + /** + * Returns the texture coordinates (UV in pixels) in the Tileset image for the given tile index. + * Returns null if tile index is not contained in this Tileset. + * + * @method Phaser.Tilemaps.Tileset#getTileTextureCoordinates + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {?object} Object in the form { x, y } representing the top-left UV coordinate + * within the Tileset image. + */ + getTileTextureCoordinates: function (tileIndex) + { + if (!this.containsTileIndex(tileIndex)) { return null; } + + return this.texCoordinates[tileIndex - this.firstgid]; + }, + + /** + * Sets the image associated with this Tileset and updates the tile data (rows, columns, etc.). + * + * @method Phaser.Tilemaps.Tileset#setImage + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The image that contains the tiles. + * + * @return {Phaser.Tilemaps.Tileset} This Tileset object. + */ + setImage: function (texture) + { + this.image = texture; + + this.updateTileData(this.image.source[0].width, this.image.source[0].height); + + return this; + }, + + /** + * Sets the tile width & height and updates the tile data (rows, columns, etc.). + * + * @method Phaser.Tilemaps.Tileset#setTileSize + * @since 3.0.0 + * + * @param {integer} [tileWidth] - The width of a tile in pixels. + * @param {integer} [tileHeight] - The height of a tile in pixels. + * + * @return {Phaser.Tilemaps.Tileset} This Tileset object. + */ + setTileSize: function (tileWidth, tileHeight) + { + if (tileWidth !== undefined) { this.tileWidth = tileWidth; } + if (tileHeight !== undefined) { this.tileHeight = tileHeight; } + + if (this.image) { - if (this.sounds[i].pendingRemove) + this.updateTileData(this.image.source[0].width, this.image.source[0].height); + } + + return this; + }, + + /** + * Sets the tile margin & spacing and updates the tile data (rows, columns, etc.). + * + * @method Phaser.Tilemaps.Tileset#setSpacing + * @since 3.0.0 + * + * @param {integer} [margin] - The margin around the tiles in the sheet (in pixels). + * @param {integer} [spacing] - The spacing between the tiles in the sheet (in pixels). + * + * @return {Phaser.Tilemaps.Tileset} This Tileset object. + */ + setSpacing: function (margin, spacing) + { + if (margin !== undefined) { this.tileMargin = margin; } + if (spacing !== undefined) { this.tileSpacing = spacing; } + + if (this.image) + { + this.updateTileData(this.image.source[0].width, this.image.source[0].height); + } + + return this; + }, + + /** + * Updates tile texture coordinates and tileset data. + * + * @method Phaser.Tilemaps.Tileset#updateTileData + * @since 3.0.0 + * + * @param {integer} imageWidth - The (expected) width of the image to slice. + * @param {integer} imageHeight - The (expected) height of the image to slice. + * + * @return {Phaser.Tilemaps.Tileset} This Tileset object. + */ + updateTileData: function (imageWidth, imageHeight) + { + var rowCount = (imageHeight - this.tileMargin * 2 + this.tileSpacing) / (this.tileHeight + this.tileSpacing); + var colCount = (imageWidth - this.tileMargin * 2 + this.tileSpacing) / (this.tileWidth + this.tileSpacing); + + if (rowCount % 1 !== 0 || colCount % 1 !== 0) + { + console.warn('Tileset ' + this.name + ' image tile area is not an even multiple of tile size'); + } + + // In Tiled a tileset image that is not an even multiple of the tile dimensions is truncated + // - hence the floor when calculating the rows/columns. + rowCount = Math.floor(rowCount); + colCount = Math.floor(colCount); + + this.rows = rowCount; + this.columns = colCount; + + // In Tiled, "empty" spaces in a tileset count as tiles and hence count towards the gid + this.total = rowCount * colCount; + + this.texCoordinates.length = 0; + + var tx = this.tileMargin; + var ty = this.tileMargin; + + for (var y = 0; y < this.rows; y++) + { + for (var x = 0; x < this.columns; x++) { - this.sounds.splice(i, 1); + this.texCoordinates.push({ x: tx, y: ty }); + tx += this.tileWidth + this.tileSpacing; } - } - this.sounds.forEach(function (sound) - { - sound.update(time, delta); - }); - }, - /** - * Destroys all the sounds in the game and all associated events. - * - * @method Phaser.Sound.BaseSoundManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.removeAllListeners(); - this.forEachActiveSound(function (sound) - { - sound.destroy(); - }); - this.sounds.length = 0; - this.sounds = null; - this.game = null; - }, - - /** - * Method used internally for iterating only over active sounds and skipping sounds that are marked for removal. - * - * @method Phaser.Sound.BaseSoundManager#forEachActiveSound - * @private - * @since 3.0.0 - * - * @param {function} callbackfn - Callback function. (sound: ISound, index: number, array: ISound[]) => void - * @param {object} [scope] - Callback context. - */ - forEachActiveSound: function (callbackfn, scope) - { - var _this = this; - this.sounds.forEach(function (sound, index) - { - if (!sound.pendingRemove) - { - callbackfn.call(scope || _this, sound, index, _this.sounds); - } - }); - }, - - /** - * Global playback rate at which all the sounds will be played. - * Value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed - * and 2.0 doubles the audio's playback speed. - * - * @name Phaser.Sound.BaseSoundManager#rate - * @type {number} - * @default 1 - * @since 3.0.0 - */ - rate: { - - get: function () - { - return this._rate; - }, - - set: function (value) - { - this._rate = value; - - this.forEachActiveSound(function (sound) - { - sound.setRate(); - }); - - /** - * @event Phaser.Sound.BaseSoundManager#rate - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - * @param {number} value - An updated value of Phaser.Sound.BaseSoundManager#rate property. - */ - this.emit('rate', this, value); - } - - }, - - /** - * Global detuning of all sounds in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - * - * @name Phaser.Sound.BaseSoundManager#detune - * @type {number} - * @default 0 - * @since 3.0.0 - */ - detune: { - - get: function () - { - return this._detune; - }, - - set: function (value) - { - this._detune = value; - - this.forEachActiveSound(function (sound) - { - sound.setRate(); - }); - - /** - * @event Phaser.Sound.BaseSoundManager#detune - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - * @param {number} value - An updated value of Phaser.Sound.BaseSoundManager#detune property. - */ - this.emit('detune', this, value); + tx = this.tileMargin; + ty += this.tileHeight + this.tileSpacing; } + return this; } }); -module.exports = BaseSoundManager; +module.exports = Tileset; /***/ }), /* 85 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(14); -var Extend = __webpack_require__(23); -var NOOP = __webpack_require__(3); /** - * @classdesc - * Class containing all the shared state and behaviour of a sound object, independent of the implementation. + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layer's position, scale and scroll. * - * @class BaseSound - * @extends EventEmitter - * @memberOf Phaser.Sound - * @constructor - * @author Pavle Goloskokovic (http://prunegames.com) + * @function Phaser.Tilemaps.Components.TileToWorldY * @since 3.0.0 * - * @param {Phaser.Sound.BaseSoundManager} manager - Reference to the current sound manager instance. - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * @param {integer} tileY - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {number} */ -var BaseSound = new Class({ - Extends: EventEmitter, - initialize: function BaseSound (manager, key, config) +var TileToWorldY = function (tileY, camera, layer) +{ + var tileHeight = layer.baseTileHeight; + var tilemapLayer = layer.tilemapLayer; + var layerWorldY = 0; + + if (tilemapLayer) { - EventEmitter.call(this); + if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } - /** - * Local reference to the sound manager. - * - * @name Phaser.Sound.BaseSound#manager - * @type {Phaser.Sound.BaseSoundManager} - * @private - * @since 3.0.0 - */ - this.manager = manager; + layerWorldY = (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY)); - /** - * Asset key for the sound. - * - * @name Phaser.Sound.BaseSound#key - * @type {string} - * @readOnly - * @since 3.0.0 - */ - this.key = key; - - /** - * Flag indicating if sound is currently playing. - * - * @name Phaser.Sound.BaseSound#isPlaying - * @type {boolean} - * @default false - * @readOnly - * @since 3.0.0 - */ - this.isPlaying = false; - - /** - * Flag indicating if sound is currently paused. - * - * @name Phaser.Sound.BaseSound#isPaused - * @type {boolean} - * @default false - * @readOnly - * @since 3.0.0 - */ - this.isPaused = false; - - /** - * A property that holds the value of sound's actual playback rate, - * after its rate and detune values has been combined with global - * rate and detune values. - * - * @name Phaser.Sound.BaseSound#totalRate - * @type {number} - * @default 1 - * @readOnly - * @since 3.0.0 - */ - this.totalRate = 1; - - /** - * A value representing the duration, in seconds. - * It could be total sound duration or a marker duration. - * - * @name Phaser.Sound.BaseSound#duration - * @type {number} - * @readOnly - * @since 3.0.0 - */ - this.duration = this.duration || 0; - - /** - * The total duration of the sound in seconds. - * - * @name Phaser.Sound.BaseSound#totalDuration - * @type {number} - * @readOnly - * @since 3.0.0 - */ - this.totalDuration = this.totalDuration || 0; - - /** - * A config object used to store default sound settings' values. - * Default values will be set by properties' setters. - * - * @name Phaser.Sound.BaseSound#config - * @type {SoundConfig} - * @private - * @since 3.0.0 - */ - this.config = { - /** - * Initializing delay config setting - */ - delay: 0 - }; - - /** - * Reference to the currently used config. - * It could be default config or marker config. - * - * @name Phaser.Sound.BaseSound#currentConfig - * @type {SoundConfig} - * @private - * @since 3.0.0 - */ - this.currentConfig = this.config; - - /** - * Boolean indicating whether the sound is muted or not. - * Gets or sets the muted state of this sound. - * - * @name Phaser.Sound.BaseSound#mute - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.mute = false; - - /** - * Gets or sets the volume of this sound, - * a value between 0 (silence) and 1 (full volume). - * - * @name Phaser.Sound.BaseSound#volume - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.volume = 1; - - /** - * Defines the speed at which the audio asset will be played. - * Value of 1.0 plays the audio at full speed, 0.5 plays the audio - * at half speed and 2.0 doubles the audio's playback speed. - * This value gets multiplied by global rate to have the final playback speed. - * - * @name Phaser.Sound.BaseSound#rate - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.rate = 1; - - /** - * Represents detuning of sound in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - * - * @name Phaser.Sound.BaseSound#detune - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.detune = 0; - - /** - * Property representing the position of playback for this sound, in seconds. - * Setting it to a specific value moves current playback to that position. - * The value given is clamped to the range 0 to current marker duration. - * Setting seek of a stopped sound has no effect. - * - * @name Phaser.Sound.BaseSound#seek - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.seek = 0; - - /** - * Flag indicating whether or not the sound or current sound marker will loop. - * - * @name Phaser.Sound.BaseSound#loop - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.loop = false; - this.config = Extend(this.config, config); - - /** - * Object containing markers definitions (Object.). - * - * @name Phaser.Sound.BaseSound#markers - * @type {object} - * @default {} - * @readOnly - * @since 3.0.0 - */ - this.markers = {}; - - /** - * Currently playing marker. - * 'null' if whole sound is playing. - * - * @name Phaser.Sound.BaseSound#currentMarker - * @type {SoundMarker} - * @default null - * @readOnly - * @since 3.0.0 - */ - this.currentMarker = null; - - /** - * Flag indicating if destroy method was called on this sound. - * - * @name Phaser.Sound.BaseSound#pendingRemove - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this.pendingRemove = false; - }, - - /** - * Adds a marker into the current sound. A marker is represented by name, start time, duration, and optionally config object. - * This allows you to bundle multiple sounds together into a single audio file and use markers to jump between them for playback. - * - * @method Phaser.Sound.BaseSound#addMarker - * @since 3.0.0 - * - * @param {SoundMarker} marker - Marker object. - * - * @return {boolean} Whether the marker was added successfully. - */ - addMarker: function (marker) - { - if (!marker || !marker.name || typeof marker.name !== 'string') - { - return false; - } - if (this.markers[marker.name]) - { - // eslint-disable-next-line no-console - console.error('addMarker - Marker with name \'' + marker.name + '\' already exists for sound \'' + this.key + '\'!'); - return false; - } - marker = Extend(true, { - name: '', - start: 0, - duration: this.totalDuration - (marker.start || 0), - config: { - mute: false, - volume: 1, - rate: 1, - detune: 0, - seek: 0, - loop: false, - delay: 0 - } - }, marker); - this.markers[marker.name] = marker; - return true; - }, - - /** - * Updates previously added marker. - * - * @method Phaser.Sound.BaseSound#updateMarker - * @since 3.0.0 - * - * @param {SoundMarker} marker - Marker object with updated values. - * - * @return {boolean} Whether the marker was updated successfully. - */ - updateMarker: function (marker) - { - if (!marker || !marker.name || typeof marker.name !== 'string') - { - return false; - } - if (!this.markers[marker.name]) - { - // eslint-disable-next-line no-console - console.error('updateMarker - Marker with name \'' + marker.name + '\' does not exist for sound \'' + this.key + '\'!'); - return false; - } - this.markers[marker.name] = Extend(true, this.markers[marker.name], marker); - return true; - }, - - /** - * Removes a marker from the sound. - * - * @method Phaser.Sound.BaseSound#removeMarker - * @since 3.0.0 - * - * @param {string} markerName - The name of the marker to remove. - * - * @return {SoundMarker|null} Removed marker object or 'null' if there was no marker with provided name. - */ - removeMarker: function (markerName) - { - var marker = this.markers[markerName]; - if (!marker) - { - return null; - } - this.markers[markerName] = null; - return marker; - }, - - /** - * Play this sound, or a marked section of it. - * It always plays the sound from the start. If you want to start playback from a specific time - * you can set 'seek' setting of the config object, provided to this call, to that value. - * - * @method Phaser.Sound.BaseSound#play - * @since 3.0.0 - * - * @param {string} [markerName=''] - If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. - * @param {SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. - * - * @return {boolean} Whether the sound started playing successfully. - */ - play: function (markerName, config) - { - if (markerName === void 0) { markerName = ''; } - if (typeof markerName === 'object') - { - config = markerName; - markerName = ''; - } - if (typeof markerName !== 'string') - { - // eslint-disable-next-line no-console - console.error('Sound marker name has to be a string!'); - return false; - } - if (!markerName) - { - this.currentMarker = null; - this.currentConfig = this.config; - this.duration = this.totalDuration; - } - else - { - if (!this.markers[markerName]) - { - // eslint-disable-next-line no-console - console.error('No marker with name \'' + markerName + '\' found for sound \'' + this.key + '\'!'); - return false; - } - this.currentMarker = this.markers[markerName]; - this.currentConfig = this.currentMarker.config; - this.duration = this.currentMarker.duration; - } - this.resetConfig(); - this.currentConfig = Extend(this.currentConfig, config); - this.isPlaying = true; - this.isPaused = false; - return true; - }, - - /** - * Pauses the sound. - * - * @method Phaser.Sound.BaseSound#pause - * @since 3.0.0 - * - * @return {boolean} Whether the sound was paused successfully. - */ - pause: function () - { - if (this.isPaused || !this.isPlaying) - { - return false; - } - this.isPlaying = false; - this.isPaused = true; - return true; - }, - - /** - * Resumes the sound. - * - * @method Phaser.Sound.BaseSound#resume - * @since 3.0.0 - * - * @return {boolean} Whether the sound was resumed successfully. - */ - resume: function () - { - if (!this.isPaused || this.isPlaying) - { - return false; - } - this.isPlaying = true; - this.isPaused = false; - return true; - }, - - /** - * Stop playing this sound. - * - * @method Phaser.Sound.BaseSound#stop - * @since 3.0.0 - * - * @return {boolean} Whether the sound was stopped successfully. - */ - stop: function () - { - if (!this.isPaused && !this.isPlaying) - { - return false; - } - this.isPlaying = false; - this.isPaused = false; - this.resetConfig(); - return true; - }, - - /** - * Method used internally for applying config values to some of the sound properties. - * - * @method Phaser.Sound.BaseSound#applyConfig - * @protected - * @since 3.0.0 - */ - applyConfig: function () - { - this.mute = this.currentConfig.mute; - this.volume = this.currentConfig.volume; - this.rate = this.currentConfig.rate; - this.detune = this.currentConfig.detune; - this.loop = this.currentConfig.loop; - }, - - /** - * Method used internally for resetting values of some of the config properties. - * - * @method Phaser.Sound.BaseSound#resetConfig - * @protected - * @since 3.0.0 - */ - resetConfig: function () - { - this.currentConfig.seek = 0; - this.currentConfig.delay = 0; - }, - - /** - * Update method called automatically by sound manager on every game step. - * - * @method Phaser.Sound.BaseSound#update - * @override - * @protected - * @since 3.0.0 - * - * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {number} delta - The delta time elapsed since the last frame. - */ - update: NOOP, - - /** - * Destroys this sound and all associated events and marks it for removal from the sound manager. - * - * @method Phaser.Sound.BaseSound#destroy - * @since 3.0.0 - */ - destroy: function () - { - if (this.pendingRemove) - { - return; - } - this.pendingRemove = true; - this.manager = null; - this.key = ''; - this.removeAllListeners(); - this.isPlaying = false; - this.isPaused = false; - this.config = null; - this.currentConfig = null; - this.markers = null; - this.currentMarker = null; - }, - - /** - * Method used internally to calculate total playback rate of the sound. - * - * @method Phaser.Sound.BaseSound#setRate - * @protected - * @since 3.0.0 - */ - setRate: function () - { - var cent = 1.0005777895065548; // Math.pow(2, 1/1200); - var totalDetune = this.currentConfig.detune + this.manager.detune; - var detuneRate = Math.pow(cent, totalDetune); - this.totalRate = this.currentConfig.rate * this.manager.rate * detuneRate; + tileHeight *= tilemapLayer.scaleY; } -}); -Object.defineProperty(BaseSound.prototype, 'rate', { - get: function () - { - return this.currentConfig.rate; - }, - set: function (value) - { - this.currentConfig.rate = value; - this.setRate(); - /** - * @event Phaser.Sound.BaseSound#rate - * @param {Phaser.Sound.BaseSound} sound - Reference to the sound that emitted event. - * @param {number} value - An updated value of Phaser.Sound.BaseSound#rate property. - */ - this.emit('rate', this, value); - } -}); -Object.defineProperty(BaseSound.prototype, 'detune', { - get: function () - { - return this.currentConfig.detune; - }, - set: function (value) - { - this.currentConfig.detune = value; - this.setRate(); + return layerWorldY + tileY * tileHeight; +}; - /** - * @event Phaser.Sound.BaseSound#detune - * @param {Phaser.Sound.BaseSound} sound - Reference to the sound that emitted event. - * @param {number} value - An updated value of Phaser.Sound.BaseSound#detune property. - */ - this.emit('detune', this, value); - } -}); -module.exports = BaseSound; +module.exports = TileToWorldY; /***/ }), /* 86 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layer's position, scale and scroll. + * + * @function Phaser.Tilemaps.Components.TileToWorldX + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {number} + */ +var TileToWorldX = function (tileX, camera, layer) +{ + var tileWidth = layer.baseTileWidth; + var tilemapLayer = layer.tilemapLayer; + var layerWorldX = 0; + + if (tilemapLayer) + { + if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } + + layerWorldX = tilemapLayer.x + camera.scrollX * (1 - tilemapLayer.scrollFactorX); + + tileWidth *= tilemapLayer.scaleX; + } + + return layerWorldX + tileX * tileWidth; +}; + +module.exports = TileToWorldX; + + +/***/ }), +/* 87 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var IsInLayerBounds = __webpack_require__(67); + +/** + * Gets a tile at the given tile coordinates from the given layer. + * + * @function Phaser.Tilemaps.Components.GetTileAt + * @since 3.0.0 + * + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). + * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile + * object with an index of -1. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates + * were invalid. + */ +var GetTileAt = function (tileX, tileY, nonNull, layer) +{ + if (nonNull === undefined) { nonNull = false; } + + if (IsInLayerBounds(tileX, tileY, layer)) + { + var tile = layer.data[tileY][tileX]; + if (tile === null) + { + return null; + } + else if (tile.index === -1) + { + return nonNull ? tile : null; + } + else + { + return tile; + } + } + else + { + return null; + } +}; + +module.exports = GetTileAt; + + +/***/ }), +/* 88 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Tilemaps.Components + */ + +module.exports = { + + CalculateFacesAt: __webpack_require__(119), + CalculateFacesWithin: __webpack_require__(26), + Copy: __webpack_require__(454), + CreateFromTiles: __webpack_require__(453), + CullTiles: __webpack_require__(452), + Fill: __webpack_require__(451), + FilterTiles: __webpack_require__(450), + FindByIndex: __webpack_require__(449), + FindTile: __webpack_require__(448), + ForEachTile: __webpack_require__(447), + GetTileAt: __webpack_require__(87), + GetTileAtWorldXY: __webpack_require__(446), + GetTilesWithin: __webpack_require__(14), + GetTilesWithinShape: __webpack_require__(445), + GetTilesWithinWorldXY: __webpack_require__(444), + HasTileAt: __webpack_require__(196), + HasTileAtWorldXY: __webpack_require__(443), + IsInLayerBounds: __webpack_require__(67), + PutTileAt: __webpack_require__(118), + PutTileAtWorldXY: __webpack_require__(442), + PutTilesAt: __webpack_require__(441), + Randomize: __webpack_require__(440), + RemoveTileAt: __webpack_require__(195), + RemoveTileAtWorldXY: __webpack_require__(439), + RenderDebug: __webpack_require__(438), + ReplaceByIndex: __webpack_require__(197), + SetCollision: __webpack_require__(437), + SetCollisionBetween: __webpack_require__(436), + SetCollisionByExclusion: __webpack_require__(435), + SetCollisionByProperty: __webpack_require__(434), + SetCollisionFromCollisionGroup: __webpack_require__(433), + SetTileIndexCallback: __webpack_require__(432), + SetTileLocationCallback: __webpack_require__(431), + Shuffle: __webpack_require__(430), + SwapByIndex: __webpack_require__(429), + TileToWorldX: __webpack_require__(86), + TileToWorldXY: __webpack_require__(428), + TileToWorldY: __webpack_require__(85), + WeightedRandomize: __webpack_require__(427), + WorldToTileX: __webpack_require__(38), + WorldToTileXY: __webpack_require__(426), + WorldToTileY: __webpack_require__(37) + +}; + + +/***/ }), +/* 89 */, +/* 90 */, +/* 91 */, +/* 92 */, +/* 93 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -14191,6 +13240,422 @@ module.exports = BaseSound; */ var Class = __webpack_require__(0); +var Components = __webpack_require__(213); +var Sprite = __webpack_require__(40); + +/** + * @classdesc + * An Arcade Physics Sprite Game Object. + * + * A Sprite Game Object is used for the display of both static and animated images in your game. + * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled + * and animated. + * + * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. + * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation + * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. + * + * @class Sprite + * @extends Phaser.GameObjects.Sprite + * @memberOf Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @extends Phaser.Physics.Arcade.Components.Acceleration + * @extends Phaser.Physics.Arcade.Components.Angular + * @extends Phaser.Physics.Arcade.Components.Bounce + * @extends Phaser.Physics.Arcade.Components.Debug + * @extends Phaser.Physics.Arcade.Components.Drag + * @extends Phaser.Physics.Arcade.Components.Enable + * @extends Phaser.Physics.Arcade.Components.Friction + * @extends Phaser.Physics.Arcade.Components.Gravity + * @extends Phaser.Physics.Arcade.Components.Immovable + * @extends Phaser.Physics.Arcade.Components.Mass + * @extends Phaser.Physics.Arcade.Components.Size + * @extends Phaser.Physics.Arcade.Components.Velocity + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.Animation + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var ArcadeSprite = new Class({ + + Extends: Sprite, + + Mixins: [ + Components.Acceleration, + Components.Angular, + Components.Bounce, + Components.Debug, + Components.Drag, + Components.Enable, + Components.Friction, + Components.Gravity, + Components.Immovable, + Components.Mass, + Components.Size, + Components.Velocity + ], + + initialize: + + function ArcadeSprite (scene, x, y, texture, frame) + { + Sprite.call(this, scene, x, y, texture, frame); + } + +}); + +module.exports = ArcadeSprite; + + +/***/ }), +/* 94 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} XHRSettingsObject + * + * @property {XMLHttpRequestResponseType} responseType - [description] + * @property {boolean} async - [description] + * @property {string} user - [description] + * @property {string} password - [description] + * @property {number} timeout - [description] + * @property {?string} header - [description] + * @property {?string} headerValue - [description] + * @property {(string|undefined)} overrideMimeType - [description] + */ + +/** + * Creates an XHRSettings Object with default values. + * + * @function Phaser.Loader.XHRSettings + * @since 3.0.0 + * + * @param {XMLHttpRequestResponseType} [responseType=''] - The responseType, such as 'text'. + * @param {boolean} [async=true] - Should the XHR request use async or not? + * @param {string} [user=''] - Optional username for the XHR request. + * @param {string} [password=''] - Optional password for the XHR request. + * @param {integer} [timeout=0] - Optional XHR timeout value. + * + * @return {XHRSettingsObject} The XHRSettings object as used by the Loader. + */ +var XHRSettings = function (responseType, async, user, password, timeout) +{ + if (responseType === undefined) { responseType = ''; } + if (async === undefined) { async = true; } + if (user === undefined) { user = ''; } + if (password === undefined) { password = ''; } + if (timeout === undefined) { timeout = 0; } + + // Before sending a request, set the xhr.responseType to "text", + // "arraybuffer", "blob", or "document", depending on your data needs. + // Note, setting xhr.responseType = '' (or omitting) will default the response to "text". + + return { + + // Ignored by the Loader, only used by File. + responseType: responseType, + + async: async, + + // credentials + user: user, + password: password, + + // timeout in ms (0 = no timeout) + timeout: timeout, + + // setRequestHeader + header: undefined, + headerValue: undefined, + + // overrideMimeType + overrideMimeType: undefined + + }; +}; + +module.exports = XHRSettings; + + +/***/ }), +/* 95 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +// This is based off an explanation and expanded math presented by Paul Bourke: +// See http:'local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/ + +/** + * [description] + * + * @function Phaser.Geom.Intersects.LineToLine + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line1 - [description] + * @param {Phaser.Geom.Line} line2 - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {boolean} [description] + */ +var LineToLine = function (line1, line2, out) +{ + if (out === undefined) { out = new Point(); } + + var x1 = line1.x1; + var y1 = line1.y1; + var x2 = line1.x2; + var y2 = line1.y2; + + var x3 = line2.x1; + var y3 = line2.y1; + var x4 = line2.x2; + var y4 = line2.y2; + + var numA = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3); + var numB = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3); + var deNom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); + + // Make sure there is not a division by zero - this also indicates that the lines are parallel. + // If numA and numB were both equal to zero the lines would be on top of each other (coincidental). + // This check is not done because it is not necessary for this implementation (the parallel check accounts for this). + + if (deNom === 0) + { + return false; + } + + // Calculate the intermediate fractional point that the lines potentially intersect. + + var uA = numA / deNom; + var uB = numB / deNom; + + // The fractional point will be between 0 and 1 inclusive if the lines intersect. + // If the fractional calculation is larger than 1 or smaller than 0 the lines would need to be longer to intersect. + + if (uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1) + { + out.x = x1 + (uA * (x2 - x1)); + out.y = y1 + (uA * (y2 - y1)); + + return true; + } + + return false; +}; + +module.exports = LineToLine; + + +/***/ }), +/* 96 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var GameObject = __webpack_require__(1); +var MeshRender = __webpack_require__(670); + +/** + * @classdesc + * A Mesh Game Object. + * + * @class Mesh + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor + * @webglOnly + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * @extends Phaser.GameObjects.Components.ScrollFactor + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {array} vertices - An array containing the vertices data for this Mesh. + * @param {array} uv - An array containing the uv data for this Mesh. + * @param {array} colors - An array containing the color data for this Mesh. + * @param {array} alphas - An array containing the alpha data for this Mesh. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var Mesh = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.Size, + Components.Texture, + Components.Transform, + Components.Visible, + Components.ScrollFactor, + MeshRender + ], + + initialize: + + function Mesh (scene, x, y, vertices, uv, colors, alphas, texture, frame) + { + GameObject.call(this, scene, 'Mesh'); + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.setSizeToFrame(); + this.setOrigin(); + this.initPipeline('TextureTintPipeline'); + + if (vertices.length !== uv.length) + { + throw new Error('Mesh Vertex count must match UV count'); + } + + var verticesUB = (vertices.length / 2) | 0; + + if (colors.length > 0 && colors.length < verticesUB) + { + throw new Error('Mesh Color count must match Vertex count'); + } + + if (alphas.length > 0 && alphas.length < verticesUB) + { + throw new Error('Mesh Alpha count must match Vertex count'); + } + + var i; + + if (colors.length === 0) + { + for (i = 0; i < verticesUB; ++i) + { + colors[i] = 0xFFFFFF; + } + } + + if (alphas.length === 0) + { + for (i = 0; i < verticesUB; ++i) + { + alphas[i] = 1.0; + } + } + + /** + * [description] + * + * @name Phaser.GameObjects.Mesh#vertices + * @type {Float32Array} + * @since 3.0.0 + */ + this.vertices = new Float32Array(vertices); + + /** + * [description] + * + * @name Phaser.GameObjects.Mesh#uv + * @type {Float32Array} + * @since 3.0.0 + */ + this.uv = new Float32Array(uv); + + /** + * [description] + * + * @name Phaser.GameObjects.Mesh#colors + * @type {Uint32Array} + * @since 3.0.0 + */ + this.colors = new Uint32Array(colors); + + /** + * [description] + * + * @name Phaser.GameObjects.Mesh#alphas + * @type {Float32Array} + * @since 3.0.0 + */ + this.alphas = new Float32Array(alphas); + } + +}); + +module.exports = Mesh; + + +/***/ }), +/* 97 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @callback EachListCallback + * + * @param {*} item - [description] + * @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the child. + */ /** * @classdesc @@ -14201,7 +13666,7 @@ var Class = __webpack_require__(0); * @constructor * @since 3.0.0 * - * @param {any} parent - [description] + * @param {*} parent - [description] */ var List = new Class({ @@ -14213,7 +13678,7 @@ var List = new Class({ * The parent of this list. * * @name Phaser.Structs.List#parent - * @type {any} + * @type {*} * @since 3.0.0 */ this.parent = parent; @@ -14403,9 +13868,9 @@ var List = new Class({ * @since 3.0.0 * * @param {string} property - The property to check against the value. - * @param {any} value - The value to check if the property strictly equals. + * @param {*} value - The value to check if the property strictly equals. * - * @return {any} The item that was found, or null if nothing matched. + * @return {*} The item that was found, or null if nothing matched. */ getByKey: function (property, value) { @@ -14430,7 +13895,7 @@ var List = new Class({ * * @param {string} name - The name to search for. * - * @return {any} The first child with a matching name, or null if none were found. + * @return {*} The first child with a matching name, or null if none were found. */ getByName: function (name) { @@ -14446,7 +13911,7 @@ var List = new Class({ * @param {integer} [startIndex=0] - Offset from the front of the group (lowest child). * @param {integer} [length=(to top)] - Restriction on the number of values you want to randomly select from. * - * @return {any} A random child of this Group. + * @return {*} A random child of this Group. */ getRandom: function (startIndex, length) { @@ -14469,12 +13934,12 @@ var List = new Class({ * @method Phaser.Structs.List#getFirst * @since 3.0.0 * - * @param {[type]} property - [description] - * @param {[type]} value - [description] - * @param {[type]} startIndex - [description] - * @param {[type]} endIndex - [description] + * @param {string} property - [description] + * @param {*} value - [description] + * @param {number} [startIndex=0] - [description] + * @param {number} [endIndex] - [description] * - * @return {[type]} [description] + * @return {*} [description] */ getFirst: function (property, value, startIndex, endIndex) { @@ -14509,7 +13974,7 @@ var List = new Class({ * @since 3.0.0 * * @param {string} [property] - An optional property to test against the value argument. - * @param {any} [value] - If property is set then Child.property must strictly equal this value to be included in the results. + * @param {*} [value] - If property is set then Child.property must strictly equal this value to be included in the results. * @param {integer} [startIndex=0] - The first child index to start the search from. * @param {integer} [endIndex] - The last child index to search up until. * @@ -14549,7 +14014,7 @@ var List = new Class({ * @since 3.0.0 * * @param {string} property - [description] - * @param {any} value - [description] + * @param {*} value - [description] * * @return {integer} [description] */ @@ -14645,7 +14110,7 @@ var List = new Class({ { this.list.splice(index, 1); } - + return child; }, @@ -14904,7 +14369,7 @@ var List = new Class({ * @since 3.0.0 * * @param {string} key - [description] - * @param {any} value - [description] + * @param {*} value - [description] */ setAll: function (key, value) { @@ -14923,7 +14388,7 @@ var List = new Class({ * @method Phaser.Structs.List#each * @since 3.0.0 * - * @param {function} callback - The function to call. + * @param {EachListCallback} callback - The function to call. * @param {object} [thisArg] - Value to use as `this` when executing callback. * @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the child. */ @@ -15096,781 +14561,1326 @@ module.exports = List; /***/ }), -/* 87 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var TWEEN_CONST = { - - /** - * TweenData state. - * - * @name Phaser.Tweens.CREATED - * @type {integer} - * @since 3.0.0 - */ - CREATED: 0, - - /** - * TweenData state. - * - * @name Phaser.Tweens.INIT - * @type {integer} - * @since 3.0.0 - */ - INIT: 1, - - /** - * TweenData state. - * - * @name Phaser.Tweens.DELAY - * @type {integer} - * @since 3.0.0 - */ - DELAY: 2, - - /** - * TweenData state. - * - * @name Phaser.Tweens.OFFSET_DELAY - * @type {integer} - * @since 3.0.0 - */ - OFFSET_DELAY: 3, - - /** - * TweenData state. - * - * @name Phaser.Tweens.PENDING_RENDER - * @type {integer} - * @since 3.0.0 - */ - PENDING_RENDER: 4, - - /** - * TweenData state. - * - * @name Phaser.Tweens.PLAYING_FORWARD - * @type {integer} - * @since 3.0.0 - */ - PLAYING_FORWARD: 5, - - /** - * TweenData state. - * - * @name Phaser.Tweens.PLAYING_BACKWARD - * @type {integer} - * @since 3.0.0 - */ - PLAYING_BACKWARD: 6, - - /** - * TweenData state. - * - * @name Phaser.Tweens.HOLD_DELAY - * @type {integer} - * @since 3.0.0 - */ - HOLD_DELAY: 7, - - /** - * TweenData state. - * - * @name Phaser.Tweens.REPEAT_DELAY - * @type {integer} - * @since 3.0.0 - */ - REPEAT_DELAY: 8, - - /** - * TweenData state. - * - * @name Phaser.Tweens.COMPLETE - * @type {integer} - * @since 3.0.0 - */ - COMPLETE: 9, - - // Tween specific (starts from 20 to cleanly allow extra TweenData consts in the future) - - /** - * Tween state. - * - * @name Phaser.Tweens.PENDING_ADD - * @type {integer} - * @since 3.0.0 - */ - PENDING_ADD: 20, - - /** - * Tween state. - * - * @name Phaser.Tweens.PAUSED - * @type {integer} - * @since 3.0.0 - */ - PAUSED: 21, - - /** - * Tween state. - * - * @name Phaser.Tweens.LOOP_DELAY - * @type {integer} - * @since 3.0.0 - */ - LOOP_DELAY: 22, - - /** - * Tween state. - * - * @name Phaser.Tweens.ACTIVE - * @type {integer} - * @since 3.0.0 - */ - ACTIVE: 23, - - /** - * Tween state. - * - * @name Phaser.Tweens.COMPLETE_DELAY - * @type {integer} - * @since 3.0.0 - */ - COMPLETE_DELAY: 24, - - /** - * Tween state. - * - * @name Phaser.Tweens.PENDING_REMOVE - * @type {integer} - * @since 3.0.0 - */ - PENDING_REMOVE: 25, - - /** - * Tween state. - * - * @name Phaser.Tweens.REMOVED - * @type {integer} - * @since 3.0.0 - */ - REMOVED: 26 - -}; - -module.exports = TWEEN_CONST; - - -/***/ }), -/* 88 */ +/* 98 */ /***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey + * @author Pavle Goloskokovic (http://prunegames.com) * @copyright 2018 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var GameObject = __webpack_require__(1); -var MeshRender = __webpack_require__(657); +var EventEmitter = __webpack_require__(15); +var Extend = __webpack_require__(18); +var NOOP = __webpack_require__(3); /** * @classdesc - * A Mesh Game Object. + * Class containing all the shared state and behaviour of a sound object, independent of the implementation. * - * @class Mesh - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects + * @class BaseSound + * @extends EventEmitter + * @memberOf Phaser.Sound * @constructor - * @webglOnly * @since 3.0.0 * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * @extends Phaser.GameObjects.Components.ScrollFactor - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {array} vertices - An array containing the vertices data for this Mesh. - * @param {array} uv - An array containing the uv data for this Mesh. - * @param {array} colors - An array containing the color data for this Mesh. - * @param {array} alphas - An array containing the alpha data for this Mesh. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {Phaser.Sound.BaseSoundManager} manager - Reference to the current sound manager instance. + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. */ -var Mesh = new Class({ +var BaseSound = new Class({ - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.Size, - Components.Texture, - Components.Transform, - Components.Visible, - Components.ScrollFactor, - MeshRender - ], + Extends: EventEmitter, initialize: - function Mesh (scene, x, y, vertices, uv, colors, alphas, texture, frame) + function BaseSound (manager, key, config) { - GameObject.call(this, scene, 'Mesh'); + EventEmitter.call(this); - this.setTexture(texture, frame); - this.setPosition(x, y); - this.setSizeToFrame(); - this.setOrigin(); - this.initPipeline('TextureTintPipeline'); + /** + * Local reference to the sound manager. + * + * @name Phaser.Sound.BaseSound#manager + * @type {Phaser.Sound.BaseSoundManager} + * @private + * @since 3.0.0 + */ + this.manager = manager; - if (vertices.length !== uv.length) + /** + * Asset key for the sound. + * + * @name Phaser.Sound.BaseSound#key + * @type {string} + * @readOnly + * @since 3.0.0 + */ + this.key = key; + + /** + * Flag indicating if sound is currently playing. + * + * @name Phaser.Sound.BaseSound#isPlaying + * @type {boolean} + * @default false + * @readOnly + * @since 3.0.0 + */ + this.isPlaying = false; + + /** + * Flag indicating if sound is currently paused. + * + * @name Phaser.Sound.BaseSound#isPaused + * @type {boolean} + * @default false + * @readOnly + * @since 3.0.0 + */ + this.isPaused = false; + + /** + * A property that holds the value of sound's actual playback rate, + * after its rate and detune values has been combined with global + * rate and detune values. + * + * @name Phaser.Sound.BaseSound#totalRate + * @type {number} + * @default 1 + * @readOnly + * @since 3.0.0 + */ + this.totalRate = 1; + + /** + * A value representing the duration, in seconds. + * It could be total sound duration or a marker duration. + * + * @name Phaser.Sound.BaseSound#duration + * @type {number} + * @readOnly + * @since 3.0.0 + */ + this.duration = this.duration || 0; + + /** + * The total duration of the sound in seconds. + * + * @name Phaser.Sound.BaseSound#totalDuration + * @type {number} + * @readOnly + * @since 3.0.0 + */ + this.totalDuration = this.totalDuration || 0; + + /** + * A config object used to store default sound settings' values. + * Default values will be set by properties' setters. + * + * @name Phaser.Sound.BaseSound#config + * @type {SoundConfig} + * @private + * @since 3.0.0 + */ + this.config = { + /** + * Initializing delay config setting + */ + delay: 0 + }; + + /** + * Reference to the currently used config. + * It could be default config or marker config. + * + * @name Phaser.Sound.BaseSound#currentConfig + * @type {SoundConfig} + * @private + * @since 3.0.0 + */ + this.currentConfig = this.config; + + /** + * Boolean indicating whether the sound is muted or not. + * Gets or sets the muted state of this sound. + * + * @name Phaser.Sound.BaseSound#mute + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.mute = false; + + /** + * Gets or sets the volume of this sound, + * a value between 0 (silence) and 1 (full volume). + * + * @name Phaser.Sound.BaseSound#volume + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.volume = 1; + + /** + * Defines the speed at which the audio asset will be played. + * Value of 1.0 plays the audio at full speed, 0.5 plays the audio + * at half speed and 2.0 doubles the audio's playback speed. + * This value gets multiplied by global rate to have the final playback speed. + * + * @name Phaser.Sound.BaseSound#rate + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.rate = 1; + + /** + * Represents detuning of sound in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @name Phaser.Sound.BaseSound#detune + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.detune = 0; + + /** + * Property representing the position of playback for this sound, in seconds. + * Setting it to a specific value moves current playback to that position. + * The value given is clamped to the range 0 to current marker duration. + * Setting seek of a stopped sound has no effect. + * + * @name Phaser.Sound.BaseSound#seek + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.seek = 0; + + /** + * Flag indicating whether or not the sound or current sound marker will loop. + * + * @name Phaser.Sound.BaseSound#loop + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.loop = false; + this.config = Extend(this.config, config); + + /** + * Object containing markers definitions. + * + * @name Phaser.Sound.BaseSound#markers + * @type {Object.} + * @default {} + * @readOnly + * @since 3.0.0 + */ + this.markers = {}; + + /** + * Currently playing marker. + * 'null' if whole sound is playing. + * + * @name Phaser.Sound.BaseSound#currentMarker + * @type {SoundMarker} + * @default null + * @readOnly + * @since 3.0.0 + */ + this.currentMarker = null; + + /** + * Flag indicating if destroy method was called on this sound. + * + * @name Phaser.Sound.BaseSound#pendingRemove + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this.pendingRemove = false; + }, + + /** + * Adds a marker into the current sound. A marker is represented by name, start time, duration, and optionally config object. + * This allows you to bundle multiple sounds together into a single audio file and use markers to jump between them for playback. + * + * @method Phaser.Sound.BaseSound#addMarker + * @since 3.0.0 + * + * @param {SoundMarker} marker - Marker object. + * + * @return {boolean} Whether the marker was added successfully. + */ + addMarker: function (marker) + { + if (!marker || !marker.name || typeof marker.name !== 'string') { - throw new Error('Mesh Vertex count must match UV count'); + return false; } - var verticesUB = (vertices.length / 2) | 0; - - if (colors.length > 0 && colors.length < verticesUB) + if (this.markers[marker.name]) { - throw new Error('Mesh Color count must match Vertex count'); + // eslint-disable-next-line no-console + console.error('addMarker - Marker with name \'' + marker.name + '\' already exists for sound \'' + this.key + '\'!'); + + return false; } - if (alphas.length > 0 && alphas.length < verticesUB) - { - throw new Error('Mesh Alpha count must match Vertex count'); - } - - var i; - - if (colors.length === 0) - { - for (i = 0; i < verticesUB; ++i) - { - colors[i] = 0xFFFFFF; + marker = Extend(true, { + name: '', + start: 0, + duration: this.totalDuration - (marker.start || 0), + config: { + mute: false, + volume: 1, + rate: 1, + detune: 0, + seek: 0, + loop: false, + delay: 0 } - } + }, marker); - if (alphas.length === 0) - { - for (i = 0; i < verticesUB; ++i) - { - alphas[i] = 1.0; - } - } - - /** - * [description] - * - * @name Phaser.GameObjects.Mesh#vertices - * @type {Float32Array} - * @since 3.0.0 - */ - this.vertices = new Float32Array(vertices); - - /** - * [description] - * - * @name Phaser.GameObjects.Mesh#uv - * @type {Float32Array} - * @since 3.0.0 - */ - this.uv = new Float32Array(uv); - - /** - * [description] - * - * @name Phaser.GameObjects.Mesh#colors - * @type {Uint32Array} - * @since 3.0.0 - */ - this.colors = new Uint32Array(colors); - - /** - * [description] - * - * @name Phaser.GameObjects.Mesh#alphas - * @type {Float32Array} - * @since 3.0.0 - */ - this.alphas = new Float32Array(alphas); - } - -}); - -module.exports = Mesh; - - -/***/ }), -/* 89 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -// This is based off an explanation and expanded math presented by Paul Bourke: -// See http:'local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/ - -/** - * [description] - * - * @function Phaser.Geom.Intersects.LineToLine - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line1 - [description] - * @param {Phaser.Geom.Line} line2 - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {boolean} [description] - */ -var LineToLine = function (line1, line2, out) -{ - if (out === undefined) { out = new Point(); } - - var x1 = line1.x1; - var y1 = line1.y1; - var x2 = line1.x2; - var y2 = line1.y2; - - var x3 = line2.x1; - var y3 = line2.y1; - var x4 = line2.x2; - var y4 = line2.y2; - - var numA = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3); - var numB = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3); - var deNom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); - - // Make sure there is not a division by zero - this also indicates that the lines are parallel. - // If numA and numB were both equal to zero the lines would be on top of each other (coincidental). - // This check is not done because it is not necessary for this implementation (the parallel check accounts for this). - - if (deNom === 0) - { - return false; - } - - // Calculate the intermediate fractional point that the lines potentially intersect. - - var uA = numA / deNom; - var uB = numB / deNom; - - // The fractional point will be between 0 and 1 inclusive if the lines intersect. - // If the fractional calculation is larger than 1 or smaller than 0 the lines would need to be longer to intersect. - - if (uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1) - { - out.x = x1 + (uA * (x2 - x1)); - out.y = y1 + (uA * (y2 - y1)); + this.markers[marker.name] = marker; return true; - } + }, - return false; -}; - -module.exports = LineToLine; - - -/***/ }), -/* 90 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Creates an XHRSettings Object with default values. - * - * @function Phaser.Loader.XHRSettings - * @since 3.0.0 - * - * @param {string} [responseType] - The responseType, such as 'text'. - * @param {boolean} [async=true] - Should the XHR request use async or not? - * @param {string} [user] - Optional username for the XHR request. - * @param {string} [password] - Optional password for the XHR request. - * @param {integer} [timeout=0] - Optional XHR timeout value. - * - * @return {Phaser.Loader.XHRSettings} The XHRSettings object as used by the Loader. - */ -var XHRSettings = function (responseType, async, user, password, timeout) -{ - if (responseType === undefined) { responseType = ''; } - if (async === undefined) { async = true; } - if (user === undefined) { user = ''; } - if (password === undefined) { password = ''; } - if (timeout === undefined) { timeout = 0; } - - // Before sending a request, set the xhr.responseType to "text", - // "arraybuffer", "blob", or "document", depending on your data needs. - // Note, setting xhr.responseType = '' (or omitting) will default the response to "text". - - return { - - // Ignored by the Loader, only used by File. - responseType: responseType, - - async: async, - - // credentials - user: user, - password: password, - - // timeout in ms (0 = no timeout) - timeout: timeout, - - // setRequestHeader - header: undefined, - headerValue: undefined, - - // overrideMimeType - overrideMimeType: undefined - - }; -}; - -module.exports = XHRSettings; - - -/***/ }), -/* 91 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(328); -var Sprite = __webpack_require__(37); - -/** - * @classdesc - * An Arcade Physics Sprite Game Object. - * - * A Sprite Game Object is used for the display of both static and animated images in your game. - * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled - * and animated. - * - * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. - * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation - * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. - * - * @class Sprite - * @extends Phaser.GameObjects.Sprite - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @extends Phaser.Physics.Arcade.Components.Acceleration - * @extends Phaser.Physics.Arcade.Components.Angular - * @extends Phaser.Physics.Arcade.Components.Bounce - * @extends Phaser.Physics.Arcade.Components.Debug - * @extends Phaser.Physics.Arcade.Components.Drag - * @extends Phaser.Physics.Arcade.Components.Enable - * @extends Phaser.Physics.Arcade.Components.Friction - * @extends Phaser.Physics.Arcade.Components.Gravity - * @extends Phaser.Physics.Arcade.Components.Immovable - * @extends Phaser.Physics.Arcade.Components.Mass - * @extends Phaser.Physics.Arcade.Components.Size - * @extends Phaser.Physics.Arcade.Components.Velocity - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.Animation - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var ArcadeSprite = new Class({ - - Extends: Sprite, - - Mixins: [ - Components.Acceleration, - Components.Angular, - Components.Bounce, - Components.Debug, - Components.Drag, - Components.Enable, - Components.Friction, - Components.Gravity, - Components.Immovable, - Components.Mass, - Components.Size, - Components.Velocity - ], - - initialize: - - function ArcadeSprite (scene, x, y, texture, frame) + /** + * Updates previously added marker. + * + * @method Phaser.Sound.BaseSound#updateMarker + * @since 3.0.0 + * + * @param {SoundMarker} marker - Marker object with updated values. + * + * @return {boolean} Whether the marker was updated successfully. + */ + updateMarker: function (marker) { - Sprite.call(this, scene, x, y, texture, frame); - } + if (!marker || !marker.name || typeof marker.name !== 'string') + { + return false; + } -}); + if (!this.markers[marker.name]) + { + // eslint-disable-next-line no-console + console.error('updateMarker - Marker with name \'' + marker.name + '\' does not exist for sound \'' + this.key + '\'!'); -module.exports = ArcadeSprite; + return false; + } + this.markers[marker.name] = Extend(true, this.markers[marker.name], marker); -/***/ }), -/* 92 */, -/* 93 */, -/* 94 */, -/* 95 */, -/* 96 */ -/***/ (function(module, exports, __webpack_require__) { + return true; + }, -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Tilemaps.Components - */ - -module.exports = { - - CalculateFacesAt: __webpack_require__(153), - CalculateFacesWithin: __webpack_require__(34), - Copy: __webpack_require__(874), - CreateFromTiles: __webpack_require__(875), - CullTiles: __webpack_require__(876), - Fill: __webpack_require__(877), - FilterTiles: __webpack_require__(878), - FindByIndex: __webpack_require__(879), - FindTile: __webpack_require__(880), - ForEachTile: __webpack_require__(881), - GetTileAt: __webpack_require__(97), - GetTileAtWorldXY: __webpack_require__(882), - GetTilesWithin: __webpack_require__(15), - GetTilesWithinShape: __webpack_require__(883), - GetTilesWithinWorldXY: __webpack_require__(884), - HasTileAt: __webpack_require__(345), - HasTileAtWorldXY: __webpack_require__(885), - IsInLayerBounds: __webpack_require__(74), - PutTileAt: __webpack_require__(154), - PutTileAtWorldXY: __webpack_require__(886), - PutTilesAt: __webpack_require__(887), - Randomize: __webpack_require__(888), - RemoveTileAt: __webpack_require__(346), - RemoveTileAtWorldXY: __webpack_require__(889), - RenderDebug: __webpack_require__(890), - ReplaceByIndex: __webpack_require__(344), - SetCollision: __webpack_require__(891), - SetCollisionBetween: __webpack_require__(892), - SetCollisionByExclusion: __webpack_require__(893), - SetCollisionByProperty: __webpack_require__(894), - SetCollisionFromCollisionGroup: __webpack_require__(895), - SetTileIndexCallback: __webpack_require__(896), - SetTileLocationCallback: __webpack_require__(897), - Shuffle: __webpack_require__(898), - SwapByIndex: __webpack_require__(899), - TileToWorldX: __webpack_require__(98), - TileToWorldXY: __webpack_require__(900), - TileToWorldY: __webpack_require__(99), - WeightedRandomize: __webpack_require__(901), - WorldToTileX: __webpack_require__(39), - WorldToTileXY: __webpack_require__(902), - WorldToTileY: __webpack_require__(40) - -}; - - -/***/ }), -/* 97 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var IsInLayerBounds = __webpack_require__(74); - -/** - * Gets a tile at the given tile coordinates from the given layer. - * - * @function Phaser.Tilemaps.Components.GetTileAt - * @since 3.0.0 - * - * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). - * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). - * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates - * were invalid. - */ -var GetTileAt = function (tileX, tileY, nonNull, layer) -{ - if (nonNull === undefined) { nonNull = false; } - - if (IsInLayerBounds(tileX, tileY, layer)) + /** + * Removes a marker from the sound. + * + * @method Phaser.Sound.BaseSound#removeMarker + * @since 3.0.0 + * + * @param {string} markerName - The name of the marker to remove. + * + * @return {?SoundMarker} Removed marker object or 'null' if there was no marker with provided name. + */ + removeMarker: function (markerName) { - var tile = layer.data[tileY][tileX]; - if (tile === null) + var marker = this.markers[markerName]; + + if (!marker) { return null; } - else if (tile.index === -1) + + this.markers[markerName] = null; + + return marker; + }, + + /** + * Play this sound, or a marked section of it. + * It always plays the sound from the start. If you want to start playback from a specific time + * you can set 'seek' setting of the config object, provided to this call, to that value. + * + * @method Phaser.Sound.BaseSound#play + * @since 3.0.0 + * + * @param {string} [markerName=''] - If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. + * @param {SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. + * + * @return {boolean} Whether the sound started playing successfully. + */ + play: function (markerName, config) + { + if (markerName === undefined) { markerName = ''; } + + if (typeof markerName === 'object') { - return nonNull ? tile : null; + config = markerName; + markerName = ''; + } + + if (typeof markerName !== 'string') + { + // eslint-disable-next-line no-console + console.error('Sound marker name has to be a string!'); + + return false; + } + + if (!markerName) + { + this.currentMarker = null; + this.currentConfig = this.config; + this.duration = this.totalDuration; } else { - return tile; + if (!this.markers[markerName]) + { + // eslint-disable-next-line no-console + console.error('No marker with name \'' + markerName + '\' found for sound \'' + this.key + '\'!'); + + return false; + } + + this.currentMarker = this.markers[markerName]; + this.currentConfig = this.currentMarker.config; + this.duration = this.currentMarker.duration; } - } - else + + this.resetConfig(); + + this.currentConfig = Extend(this.currentConfig, config); + + this.isPlaying = true; + this.isPaused = false; + + return true; + }, + + /** + * Pauses the sound. + * + * @method Phaser.Sound.BaseSound#pause + * @since 3.0.0 + * + * @return {boolean} Whether the sound was paused successfully. + */ + pause: function () { - return null; - } -}; + if (this.isPaused || !this.isPlaying) + { + return false; + } -module.exports = GetTileAt; + this.isPlaying = false; + this.isPaused = true; + return true; + }, -/***/ }), -/* 98 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the - * layer's position, scale and scroll. - * - * @function Phaser.Tilemaps.Components.TileToWorldX - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {number} - */ -var TileToWorldX = function (tileX, camera, layer) -{ - var tileWidth = layer.baseTileWidth; - var tilemapLayer = layer.tilemapLayer; - var layerWorldX = 0; - - if (tilemapLayer) + /** + * Resumes the sound. + * + * @method Phaser.Sound.BaseSound#resume + * @since 3.0.0 + * + * @return {boolean} Whether the sound was resumed successfully. + */ + resume: function () { - if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } + if (!this.isPaused || this.isPlaying) + { + return false; + } - layerWorldX = tilemapLayer.x + camera.scrollX * (1 - tilemapLayer.scrollFactorX); + this.isPlaying = true; + this.isPaused = false; - tileWidth *= tilemapLayer.scaleX; + return true; + }, + + /** + * Stop playing this sound. + * + * @method Phaser.Sound.BaseSound#stop + * @since 3.0.0 + * + * @return {boolean} Whether the sound was stopped successfully. + */ + stop: function () + { + if (!this.isPaused && !this.isPlaying) + { + return false; + } + + this.isPlaying = false; + this.isPaused = false; + + this.resetConfig(); + + return true; + }, + + /** + * Method used internally for applying config values to some of the sound properties. + * + * @method Phaser.Sound.BaseSound#applyConfig + * @protected + * @since 3.0.0 + */ + applyConfig: function () + { + this.mute = this.currentConfig.mute; + this.volume = this.currentConfig.volume; + this.rate = this.currentConfig.rate; + this.detune = this.currentConfig.detune; + this.loop = this.currentConfig.loop; + }, + + /** + * Method used internally for resetting values of some of the config properties. + * + * @method Phaser.Sound.BaseSound#resetConfig + * @protected + * @since 3.0.0 + */ + resetConfig: function () + { + this.currentConfig.seek = 0; + this.currentConfig.delay = 0; + }, + + /** + * Update method called automatically by sound manager on every game step. + * + * @method Phaser.Sound.BaseSound#update + * @override + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time elapsed since the last frame. + */ + update: NOOP, + + /** + * Method used internally to calculate total playback rate of the sound. + * + * @method Phaser.Sound.BaseSound#calculateRate + * @protected + * @since 3.0.0 + */ + calculateRate: function () + { + var cent = 1.0005777895065548; // Math.pow(2, 1/1200); + var totalDetune = this.currentConfig.detune + this.manager.detune; + var detuneRate = Math.pow(cent, totalDetune); + + this.totalRate = this.currentConfig.rate * this.manager.rate * detuneRate; + }, + + /** + * @event Phaser.Sound.BaseSound#rate + * @param {Phaser.Sound.BaseSound} sound - Reference to the sound that emitted the event. + * @param {number} value - An updated value of Phaser.Sound.BaseSound#rate property. + */ + + /** + * Sets the playback rate of this Sound. + * + * For example, a value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed + * and 2.0 doubles the audios playback speed. + * + * @method Phaser.Sound.BaseSound#setRate + * @fires Phaser.Sound.BaseSound#rate + * @since 3.3.0 + * + * @param {number} value - The playback rate at of this Sound. + * + * @return {Phaser.Sound.BaseSound} This Sound. + */ + setRate: function (value) + { + this.rate = value; + + return this; + }, + + /** + * Rate at which this Sound will be played. + * Value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed + * and 2.0 doubles the audios playback speed. + * + * @name Phaser.Sound.BaseSound#rate + * @type {number} + * @default 1 + * @since 3.0.0 + */ + rate: { + + get: function () + { + return this.currentConfig.rate; + }, + + set: function (value) + { + this.currentConfig.rate = value; + + this.calculateRate(); + + this.emit('rate', this, value); + } + + }, + + /** + * Sets the detune value of this Sound, given in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @method Phaser.Sound.BaseSound#setDetune + * @fires Phaser.Sound.BaseSound#detune + * @since 3.3.0 + * + * @param {number} value - The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @return {Phaser.Sound.BaseSound} This Sound. + */ + setDetune: function (value) + { + this.detune = value; + + return this; + }, + + /** + * @event Phaser.Sound.BaseSound#detune + * @param {Phaser.Sound.BaseSound} sound - Reference to the Sound that emitted event. + * @param {number} value - An updated value of Phaser.Sound.BaseSound#detune property. + */ + + /** + * The detune value of this Sound, given in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @name Phaser.Sound.BaseSound#detune + * @type {number} + * @default 0 + * @since 3.0.0 + */ + detune: { + + get: function () + { + return this.currentConfig.detune; + }, + + set: function (value) + { + this.currentConfig.detune = value; + + this.calculateRate(); + + this.emit('detune', this, value); + } + + }, + + /** + * Destroys this sound and all associated events and marks it for removal from the sound manager. + * + * @method Phaser.Sound.BaseSound#destroy + * @since 3.0.0 + */ + destroy: function () + { + if (this.pendingRemove) + { + return; + } + + this.pendingRemove = true; + this.manager = null; + this.key = ''; + this.removeAllListeners(); + this.isPlaying = false; + this.isPaused = false; + this.config = null; + this.currentConfig = null; + this.markers = null; + this.currentMarker = null; } - return layerWorldX + tileX * tileWidth; -}; +}); -module.exports = TileToWorldX; +module.exports = BaseSound; /***/ }), /* 99 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey + * @author Pavle Goloskokovic (http://prunegames.com) * @copyright 2018 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(15); +var NOOP = __webpack_require__(3); + /** - * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layer's position, scale and scroll. + * @callback EachActiveSoundCallback * - * @function Phaser.Tilemaps.Components.TileToWorldY + * @param {Phaser.Sound.BaseSoundManager} manager - [description] + * @param {Phaser.Sound.BaseSound} sound - [description] + * @param {number} index - [description] + * @param {Phaser.Sound.BaseSound[]} sounds - [description] + */ + +/** + * Audio sprite sound type. + * + * @typedef {Phaser.Sound.BaseSound} AudioSpriteSound + * + * @property {object} spritemap - Local reference to 'spritemap' object form json file generated by audiosprite tool. + */ + + +/** + * @classdesc + * The sound manager is responsible for playing back audio via Web Audio API or HTML Audio tag as fallback. + * The audio file type and the encoding of those files are extremely important. + * + * Not all browsers can play all audio formats. + * + * There is a good guide to what's supported [here](https://developer.mozilla.org/en-US/Apps/Fundamentals/Audio_and_video_delivery/Cross-browser_audio_basics#Audio_Codec_Support). + * + * @class BaseSoundManager + * @extends EventEmitter + * @memberOf Phaser.Sound + * @constructor * @since 3.0.0 * - * @param {integer} tileY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {number} + * @param {Phaser.Game} game - Reference to the current game instance. */ -var TileToWorldY = function (tileY, camera, layer) -{ - var tileHeight = layer.baseTileHeight; - var tilemapLayer = layer.tilemapLayer; - var layerWorldY = 0; +var BaseSoundManager = new Class({ - if (tilemapLayer) + Extends: EventEmitter, + + initialize: + + function BaseSoundManager (game) { - if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } + EventEmitter.call(this); - layerWorldY = (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY)); + /** + * Local reference to game. + * + * @name Phaser.Sound.BaseSoundManager#game + * @type {Phaser.Game} + * @readOnly + * @since 3.0.0 + */ + this.game = game; + + /** + * An array containing all added sounds. + * + * @name Phaser.Sound.BaseSoundManager#sounds + * @type {Phaser.Sound.BaseSound[]} + * @default [] + * @private + * @since 3.0.0 + */ + this.sounds = []; + + /** + * Global mute setting. + * + * @name Phaser.Sound.BaseSoundManager#mute + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.mute = false; + + /** + * Global volume setting. + * + * @name Phaser.Sound.BaseSoundManager#volume + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.volume = 1; + + /** + * Flag indicating if sounds should be paused when game looses focus, + * for instance when user switches to another tab/program/app. + * + * @name Phaser.Sound.BaseSoundManager#pauseOnBlur + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.pauseOnBlur = true; + + game.events.on('blur', function () + { + if (this.pauseOnBlur) + { + this.onBlur(); + } + }, this); + + game.events.on('focus', function () + { + if (this.pauseOnBlur) + { + this.onFocus(); + } + }, this); + + game.events.once('destroy', this.destroy, this); + + /** + * Property that actually holds the value of global playback rate. + * + * @name Phaser.Sound.BaseSoundManager#_rate + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + this._rate = 1; + + /** + * Property that actually holds the value of global detune. + * + * @name Phaser.Sound.BaseSoundManager#_detune + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._detune = 0; + + /** + * Mobile devices require sounds to be triggered from an explicit user action, + * such as a tap, before any sound can be loaded/played on a web page. + * Set to true if the audio system is currently locked awaiting user interaction. + * + * @name Phaser.Sound.BaseSoundManager#locked + * @type {boolean} + * @readOnly + * @since 3.0.0 + */ + this.locked = this.locked || false; + + /** + * Flag used internally for handling when the audio system + * has been unlocked, if there ever was a need for it. + * + * @name Phaser.Sound.BaseSoundManager#unlocked + * @type {boolean} + * @default false + * @private + * @since 3.0.0 + */ + this.unlocked = false; + + if (this.locked) + { + this.unlock(); + } + }, + + /** + * Adds a new sound into the sound manager. + * + * @method Phaser.Sound.BaseSoundManager#add + * @override + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * + * @return {Phaser.Sound.BaseSound} The new sound instance. + */ + add: NOOP, + + /** + * Adds a new audio sprite sound into the sound manager. + * + * @method Phaser.Sound.BaseSoundManager#addAudioSprite + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * + * @return {AudioSpriteSound} The new audio sprite sound instance. + */ + addAudioSprite: function (key, config) + { + var sound = this.add(key, config); + + sound.spritemap = this.game.cache.json.get(key).spritemap; + + for (var markerName in sound.spritemap) + { + if (!sound.spritemap.hasOwnProperty(markerName)) + { + continue; + } + + var marker = sound.spritemap[markerName]; + + sound.addMarker({ + name: markerName, + start: marker.start, + duration: marker.end - marker.start, + config: config + }); + } + + return sound; + }, + + /** + * Enables playing sound on the fly without the need to keep a reference to it. + * Sound will auto destroy once its playback ends. + * + * @method Phaser.Sound.BaseSoundManager#play + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {(SoundConfig|SoundMarker)} [extra] - An optional additional object containing settings to be applied to the sound. It could be either config or marker object. + * + * @return {boolean} Whether the sound started playing successfully. + */ + play: function (key, extra) + { + var sound = this.add(key); + + sound.once('ended', sound.destroy, sound); + + if (extra) + { + if (extra.name) + { + sound.addMarker(extra); + + return sound.play(extra.name); + } + else + { + return sound.play(extra); + } + } + else + { + return sound.play(); + } + }, + + /** + * Enables playing audio sprite sound on the fly without the need to keep a reference to it. + * Sound will auto destroy once its playback ends. + * + * @method Phaser.Sound.BaseSoundManager#playAudioSprite + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {string} spriteName - The name of the sound sprite to play. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * + * @return {boolean} Whether the audio sprite sound started playing successfully. + */ + playAudioSprite: function (key, spriteName, config) + { + var sound = this.addAudioSprite(key); + + sound.once('ended', sound.destroy, sound); + + return sound.play(spriteName, config); + }, + + /** + * Removes a sound from the sound manager. + * The removed sound is destroyed before removal. + * + * @method Phaser.Sound.BaseSoundManager#remove + * @since 3.0.0 + * + * @param {Phaser.Sound.BaseSound} sound - The sound object to remove. + * + * @return {boolean} True if the sound was removed successfully, otherwise false. + */ + remove: function (sound) + { + var index = this.sounds.indexOf(sound); + + if (index !== -1) + { + sound.destroy(); + + this.sounds.splice(index, 1); + + return true; + } + + return false; + }, + + /** + * Removes all sounds from the sound manager that have an asset key matching the given value. + * The removed sounds are destroyed before removal. + * + * @method Phaser.Sound.BaseSoundManager#removeByKey + * @since 3.0.0 + * + * @param {string} key - The key to match when removing sound objects. + * + * @return {number} The number of matching sound objects that were removed. + */ + removeByKey: function (key) + { + var removed = 0; + + for (var i = this.sounds.length - 1; i >= 0; i--) + { + var sound = this.sounds[i]; + + if (sound.key === key) + { + sound.destroy(); + + this.sounds.splice(i, 1); + + removed++; + } + } + + return removed; + }, + + /** + * @event Phaser.Sound.BaseSoundManager#pauseall + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + */ + + /** + * Pauses all the sounds in the game. + * + * @method Phaser.Sound.BaseSoundManager#pauseAll + * @fires Phaser.Sound.BaseSoundManager#pauseall + * @since 3.0.0 + */ + pauseAll: function () + { + this.forEachActiveSound(function (sound) + { + sound.pause(); + }); + + this.emit('pauseall', this); + }, + + /** + * @event Phaser.Sound.BaseSoundManager#resumeall + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + */ + + /** + * Resumes all the sounds in the game. + * + * @method Phaser.Sound.BaseSoundManager#resumeAll + * @fires Phaser.Sound.BaseSoundManager#resumeall + * @since 3.0.0 + */ + resumeAll: function () + { + this.forEachActiveSound(function (sound) + { + sound.resume(); + }); + + this.emit('resumeall', this); + }, + + /** + * @event Phaser.Sound.BaseSoundManager#stopall + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + */ + + /** + * Stops all the sounds in the game. + * + * @method Phaser.Sound.BaseSoundManager#stopAll + * @fires Phaser.Sound.BaseSoundManager#stopall + * @since 3.0.0 + */ + stopAll: function () + { + this.forEachActiveSound(function (sound) + { + sound.stop(); + }); + + this.emit('stopall', this); + }, + + /** + * Method used internally for unlocking audio playback on devices that + * require user interaction before any sound can be played on a web page. + * + * Read more about how this issue is handled here in [this article](https://medium.com/@pgoloskokovic/unlocking-web-audio-the-smarter-way-8858218c0e09). + * + * @method Phaser.Sound.BaseSoundManager#unlock + * @override + * @protected + * @since 3.0.0 + */ + unlock: NOOP, + + /** + * Method used internally for pausing sound manager if + * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.BaseSoundManager#onBlur + * @override + * @protected + * @since 3.0.0 + */ + onBlur: NOOP, + + /** + * Method used internally for resuming sound manager if + * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.BaseSoundManager#onFocus + * @override + * @protected + * @since 3.0.0 + */ + onFocus: NOOP, + + /** + * Update method called on every game step. + * Removes destroyed sounds and updates every active sound in the game. + * + * @method Phaser.Sound.BaseSoundManager#update + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time elapsed since the last frame. + */ + update: function (time, delta) + { + if (this.unlocked) + { + this.unlocked = false; + this.locked = false; + + /** + * @event Phaser.Sound.BaseSoundManager#unlocked + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + */ + this.emit('unlocked', this); + } + + for (var i = this.sounds.length - 1; i >= 0; i--) + { + if (this.sounds[i].pendingRemove) + { + this.sounds.splice(i, 1); + } + } + + this.sounds.forEach(function (sound) + { + sound.update(time, delta); + }); + }, + + /** + * Destroys all the sounds in the game and all associated events. + * + * @method Phaser.Sound.BaseSoundManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.removeAllListeners(); + + this.forEachActiveSound(function (sound) + { + sound.destroy(); + }); + + this.sounds.length = 0; + this.sounds = null; + + this.game = null; + }, + + /** + * Method used internally for iterating only over active sounds and skipping sounds that are marked for removal. + * + * @method Phaser.Sound.BaseSoundManager#forEachActiveSound + * @private + * @since 3.0.0 + * + * @param {EachActiveSoundCallback} callback - Callback function. (sound: ISound, index: number, array: ISound[]) => void + * @param {*} [scope] - Callback context. + */ + forEachActiveSound: function (callback, scope) + { + var _this = this; + + this.sounds.forEach(function (sound, index) + { + if (!sound.pendingRemove) + { + callback.call(scope || _this, sound, index, _this.sounds); + } + }); + }, + + /** + * @event Phaser.Sound.BaseSoundManager#rate + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + * @param {number} value - An updated value of Phaser.Sound.BaseSoundManager#rate property. + */ + + /** + * Sets the global playback rate at which all the sounds will be played. + * + * For example, a value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed + * and 2.0 doubles the audios playback speed. + * + * @method Phaser.Sound.BaseSoundManager#setRate + * @fires Phaser.Sound.BaseSoundManager#rate + * @since 3.3.0 + * + * @param {number} value - Global playback rate at which all the sounds will be played. + * + * @return {Phaser.Sound.BaseSoundManager} This Sound Manager. + */ + setRate: function (value) + { + this.rate = value; + + return this; + }, + + /** + * Global playback rate at which all the sounds will be played. + * Value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed + * and 2.0 doubles the audio's playback speed. + * + * @name Phaser.Sound.BaseSoundManager#rate + * @type {number} + * @default 1 + * @since 3.0.0 + */ + rate: { + + get: function () + { + return this._rate; + }, + + set: function (value) + { + this._rate = value; + + this.forEachActiveSound(function (sound) + { + sound.setRate(); + }); + + this.emit('rate', this, value); + } + + }, + + /** + * Sets the global detuning of all sounds in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @method Phaser.Sound.BaseSoundManager#setDetune + * @fires Phaser.Sound.BaseSoundManager#detune + * @since 3.3.0 + * + * @param {number} value - The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @return {Phaser.Sound.BaseSoundManager} This Sound Manager. + */ + setDetune: function (value) + { + this.detune = value; + + return this; + }, + + /** + * @event Phaser.Sound.BaseSoundManager#detune + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + * @param {number} value - An updated value of Phaser.Sound.BaseSoundManager#detune property. + */ + + /** + * Global detuning of all sounds in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @name Phaser.Sound.BaseSoundManager#detune + * @type {number} + * @default 0 + * @since 3.0.0 + */ + detune: { + + get: function () + { + return this._detune; + }, + + set: function (value) + { + this._detune = value; + + this.forEachActiveSound(function (sound) + { + sound.setRate(); + }); + + this.emit('detune', this, value); + } - tileHeight *= tilemapLayer.scaleY; } - return layerWorldY + tileY * tileHeight; -}; +}); -module.exports = TileToWorldY; +module.exports = BaseSoundManager; /***/ }), @@ -15883,390 +15893,375 @@ module.exports = TileToWorldY; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); +var OS = __webpack_require__(76); /** - * @classdesc - * A Tileset is a combination of an image containing the tiles and a container for data about - * each tile. - * - * @class Tileset - * @memberOf Phaser.Tilemaps - * @constructor + * Determines the browser type and version running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.browser` from within any Scene. + * + * @name Phaser.Device.Browser * @since 3.0.0 * - * @param {string} name - The name of the tileset in the map data. - * @param {integer} firstgid - The first tile index this tileset contains. - * @param {integer} [tileWidth=32] - Width of each tile (in pixels). - * @param {integer} [tileHeight=32] - Height of each tile (in pixels). - * @param {integer} [tileMargin=0] - The margin around all tiles in the sheet (in pixels). - * @param {integer} [tileSpacing=0] - The spacing between each tile in the sheet (in pixels). - * @param {object} [tileProperties={}] - Custom properties defined per tile in the Tileset. - * These typically are custom properties created in Tiled when editing a tileset. - * @param {object} [tileData={}] - Data stored per tile. These typically are created in Tiled - * when editing a tileset, e.g. from Tiled's tile collision editor or terrain editor. + * @type {object} + * @property {boolean} chrome - Set to true if running in Chrome. + * @property {boolean} edge - Set to true if running in Microsoft Edge browser. + * @property {boolean} firefox - Set to true if running in Firefox. + * @property {boolean} ie - Set to true if running in Internet Explorer 11 or less (not Edge). + * @property {boolean} mobileSafari - Set to true if running in Mobile Safari. + * @property {boolean} opera - Set to true if running in Opera. + * @property {boolean} safari - Set to true if running in Safari. + * @property {boolean} silk - Set to true if running in the Silk browser (as used on the Amazon Kindle) + * @property {boolean} trident - Set to true if running a Trident version of Internet Explorer (IE11+) + * @property {number} chromeVersion - If running in Chrome this will contain the major version number. + * @property {number} firefoxVersion - If running in Firefox this will contain the major version number. + * @property {number} ieVersion - If running in Internet Explorer this will contain the major version number. Beyond IE10 you should use Browser.trident and Browser.tridentVersion. + * @property {number} safariVersion - If running in Safari this will contain the major version number. + * @property {number} tridentVersion - If running in Internet Explorer 11 this will contain the major version number. See {@link http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx} */ -var Tileset = new Class({ +var Browser = { - initialize: + chrome: false, + chromeVersion: 0, + edge: false, + firefox: false, + firefoxVersion: 0, + ie: false, + ieVersion: 0, + mobileSafari: false, + opera: false, + safari: false, + safariVersion: 0, + silk: false, + trident: false, + tridentVersion: 0 - function Tileset (name, firstgid, tileWidth, tileHeight, tileMargin, tileSpacing, tileProperties, tileData) +}; + +function init () +{ + var ua = navigator.userAgent; + + if (/Edge\/\d+/.test(ua)) { - if (tileWidth === undefined || tileWidth <= 0) { tileWidth = 32; } - if (tileHeight === undefined || tileHeight <= 0) { tileHeight = 32; } - if (tileMargin === undefined) { tileMargin = 0; } - if (tileSpacing === undefined) { tileSpacing = 0; } - if (tileProperties === undefined) { tileProperties = {}; } - if (tileData === undefined) { tileData = {}; } - - /** - * The name of the Tileset. - * - * @name Phaser.Tilemaps.Tileset#name - * @type {string} - * @since 3.0.0 - */ - this.name = name; - - /** - * The starting index of the first tile index this Tileset contains. - * - * @name Phaser.Tilemaps.Tileset#firstgid - * @type {integer} - * @since 3.0.0 - */ - this.firstgid = firstgid; - - /** - * The width of each tile (in pixels). Use setTileSize to change. - * - * @name Phaser.Tilemaps.Tileset#tileWidth - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.tileWidth = tileWidth; - - /** - * The height of each tile (in pixels). Use setTileSize to change. - * - * @name Phaser.Tilemaps.Tileset#tileHeight - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.tileHeight = tileHeight; - - /** - * The margin around the tiles in the sheet (in pixels). Use `setSpacing` to change. - * - * @name Phaser.Tilemaps.Tileset#tileMargin - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.tileMargin = tileMargin; - - /** - * The spacing between each the tile in the sheet (in pixels). Use `setSpacing` to change. - * - * @name Phaser.Tilemaps.Tileset#tileSpacing - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.tileSpacing = tileSpacing; - - /** - * Tileset-specific properties per tile that are typically defined in the Tiled editor in the - * Tileset editor. - * - * @name Phaser.Tilemaps.Tileset#tileProperties - * @type {object} - * @since 3.0.0 - */ - this.tileProperties = tileProperties; - - /** - * Tileset-specific data per tile that are typically defined in the Tiled editor, e.g. within - * the Tileset collision editor. This is where collision objects and terrain are stored. - * - * @name Phaser.Tilemaps.Tileset#tileData - * @type {object} - * @since 3.0.0 - */ - this.tileData = tileData; - - /** - * The cached image that contains the individual tiles. Use setImage to set. - * - * @name Phaser.Tilemaps.Tileset#image - * @type {Phaser.Textures.Texture|null} - * @readOnly - * @since 3.0.0 - */ - this.image = null; - - /** - * The number of tile rows in the the tileset. - * - * @name Phaser.Tilemaps.Tileset#rows - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.rows = 0; - - /** - * The number of tile columns in the tileset. - * - * @name Phaser.Tilemaps.Tileset#columns - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.columns = 0; - - /** - * The total number of tiles in the tileset. - * - * @name Phaser.Tilemaps.Tileset#total - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.total = 0; - - /** - * The look-up table to specific tile image texture coordinates (UV in pixels). Each element - * contains the coordinates for a tile in an object of the form {x, y}. - * - * @name Phaser.Tilemaps.Tileset#texCoordinates - * @type {object[]} - * @readOnly - * @since 3.0.0 - */ - this.texCoordinates = []; - }, - - /** - * Get a tiles properties that are stored in the Tileset. Returns null if tile index is not - * contained in this Tileset. This is typically defined in Tiled under the Tileset editor. - * - * @method Phaser.Tilemaps.Tileset#getTileProperties - * @since 3.0.0 - * - * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. - * - * @return {object|undefined|null} - */ - getTileProperties: function (tileIndex) + Browser.edge = true; + } + else if ((/Chrome\/(\d+)/).test(ua) && !OS.windowsPhone) { - if (!this.containsTileIndex(tileIndex)) { return null; } - - return this.tileProperties[tileIndex - this.firstgid]; - }, - - /** - * Get a tile's data that is stored in the Tileset. Returns null if tile index is not contained - * in this Tileset. This is typically defined in Tiled and will contain both Tileset collision - * info and terrain mapping. - * - * @method Phaser.Tilemaps.Tileset#getTileData - * @since 3.0.0 - * - * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. - * - * @return {object|undefined|null} - */ - getTileData: function (tileIndex) + Browser.chrome = true; + Browser.chromeVersion = parseInt(RegExp.$1, 10); + } + else if ((/Firefox\D+(\d+)/).test(ua)) { - if (!this.containsTileIndex(tileIndex)) { return null; } - - return this.tileData[tileIndex - this.firstgid]; - }, - - /** - * Get a tile's collision group that is stored in the Tileset. Returns null if tile index is not - * contained in this Tileset. This is typically defined within Tiled's tileset collision editor. - * - * @method Phaser.Tilemaps.Tileset#getTileCollisionGroup - * @since 3.0.0 - * - * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. - * - * @return {object|null} - */ - getTileCollisionGroup: function (tileIndex) + Browser.firefox = true; + Browser.firefoxVersion = parseInt(RegExp.$1, 10); + } + else if ((/AppleWebKit/).test(ua) && OS.iOS) { - var data = this.getTileData(tileIndex); - - return (data && data.objectgroup) ? data.objectgroup : null; - }, - - /** - * Returns true if and only if this Tileset contains the given tile index. - * - * @method Phaser.Tilemaps.Tileset#containsTileIndex - * @since 3.0.0 - * - * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. - * - * @return {boolean} - */ - containsTileIndex: function (tileIndex) + Browser.mobileSafari = true; + } + else if ((/MSIE (\d+\.\d+);/).test(ua)) { - return ( - tileIndex >= this.firstgid && - tileIndex < (this.firstgid + this.total) - ); - }, - - /** - * Returns the texture coordinates (UV in pixels) in the Tileset image for the given tile index. - * Returns null if tile index is not contained in this Tileset. - * - * @method Phaser.Tilemaps.Tileset#getTileTextureCoordinates - * @since 3.0.0 - * - * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. - * - * @return {object|null} Object in the form { x, y } representing the top-left UV coordinate - * within the Tileset image. - */ - getTileTextureCoordinates: function (tileIndex) + Browser.ie = true; + Browser.ieVersion = parseInt(RegExp.$1, 10); + } + else if ((/Opera/).test(ua)) { - if (!this.containsTileIndex(tileIndex)) { return null; } - - return this.texCoordinates[tileIndex - this.firstgid]; - }, - - /** - * Sets the image associated with this Tileset and updates the tile data (rows, columns, etc.). - * - * @method Phaser.Tilemaps.Tileset#setImage - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The image that contains the tiles. - * - * @return {Phaser.Tilemaps.Tileset} This Tileset object. - */ - setImage: function (texture) + Browser.opera = true; + } + else if ((/Safari/).test(ua) && !OS.windowsPhone) { - this.image = texture; - - this.updateTileData(this.image.source[0].width, this.image.source[0].height); - - return this; - }, - - /** - * Sets the tile width & height and updates the tile data (rows, columns, etc.). - * - * @method Phaser.Tilemaps.Tileset#setTileSize - * @since 3.0.0 - * - * @param {integer} [tileWidth] - The width of a tile in pixels. - * @param {integer} [tileHeight] - The height of a tile in pixels. - * - * @return {Phaser.Tilemaps.Tileset} This Tileset object. - */ - setTileSize: function (tileWidth, tileHeight) + Browser.safari = true; + } + else if ((/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/).test(ua)) { - if (tileWidth !== undefined) { this.tileWidth = tileWidth; } - if (tileHeight !== undefined) { this.tileHeight = tileHeight; } - - if (this.image) - { - this.updateTileData(this.image.source[0].width, this.image.source[0].height); - } - - return this; - }, - - /** - * Sets the tile margin & spacing and updates the tile data (rows, columns, etc.). - * - * @method Phaser.Tilemaps.Tileset#setSpacing - * @since 3.0.0 - * - * @param {integer} [margin] - The margin around the tiles in the sheet (in pixels). - * @param {integer} [spacing] - The spacing between the tiles in the sheet (in pixels). - * - * @return {Phaser.Tilemaps.Tileset} This Tileset object. - */ - setSpacing: function (margin, spacing) - { - if (margin !== undefined) { this.tileMargin = margin; } - if (spacing !== undefined) { this.tileSpacing = spacing; } - - if (this.image) - { - this.updateTileData(this.image.source[0].width, this.image.source[0].height); - } - - return this; - }, - - /** - * Updates tile texture coordinates and tileset data. - * - * @method Phaser.Tilemaps.Tileset#updateTileData - * @since 3.0.0 - * - * @param {integer} imageWidth - The (expected) width of the image to slice. - * @param {integer} imageHeight - The (expected) height of the image to slice. - * - * @return {Phaser.Tilemaps.Tileset} This Tileset object. - */ - updateTileData: function (imageWidth, imageHeight) - { - var rowCount = (imageHeight - this.tileMargin * 2 + this.tileSpacing) / (this.tileHeight + this.tileSpacing); - var colCount = (imageWidth - this.tileMargin * 2 + this.tileSpacing) / (this.tileWidth + this.tileSpacing); - - if (rowCount % 1 !== 0 || colCount % 1 !== 0) - { - console.warn('Tileset ' + this.name + ' image tile area is not an even multiple of tile size'); - } - - // In Tiled a tileset image that is not an even multiple of the tile dimensions is truncated - // - hence the floor when calculating the rows/columns. - rowCount = Math.floor(rowCount); - colCount = Math.floor(colCount); - - this.rows = rowCount; - this.columns = colCount; - - // In Tiled, "empty" spaces in a tileset count as tiles and hence count towards the gid - this.total = rowCount * colCount; - - this.texCoordinates.length = 0; - - var tx = this.tileMargin; - var ty = this.tileMargin; - - for (var y = 0; y < this.rows; y++) - { - for (var x = 0; x < this.columns; x++) - { - this.texCoordinates.push({ x: tx, y: ty }); - tx += this.tileWidth + this.tileSpacing; - } - - tx = this.tileMargin; - ty += this.tileHeight + this.tileSpacing; - } - - return this; + Browser.ie = true; + Browser.trident = true; + Browser.tridentVersion = parseInt(RegExp.$1, 10); + Browser.ieVersion = parseInt(RegExp.$3, 10); } -}); + // Silk gets its own if clause because its ua also contains 'Safari' + if ((/Silk/).test(ua)) + { + Browser.silk = true; + } -module.exports = Tileset; + return Browser; +} + +module.exports = init(); /***/ }), /* 101 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GameObject = __webpack_require__(1); +var Sprite = __webpack_require__(40); +var Vector2 = __webpack_require__(6); +var Vector4 = __webpack_require__(152); + +/** + * @classdesc + * A Sprite 3D Game Object. + * + * The Sprite 3D object is an encapsulation of a standard Sprite object, with additional methods to allow + * it to be rendered by a 3D Camera. The Sprite can be positioned anywhere within 3D space. + * + * @class Sprite3D + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The x position of this Game Object. + * @param {number} y - The y position of this Game Object. + * @param {number} z - The z position of this Game Object. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var Sprite3D = new Class({ + + Extends: GameObject, + + initialize: + + function Sprite3D (scene, x, y, z, texture, frame) + { + GameObject.call(this, scene, 'Sprite3D'); + + /** + * [description] + * + * @name Phaser.GameObjects.Sprite3D#gameObject + * @type {Phaser.GameObjects.GameObject} + * @since 3.0.0 + */ + this.gameObject = new Sprite(scene, 0, 0, texture, frame); + + /** + * [description] + * + * @name Phaser.GameObjects.Sprite3D#position + * @type {Phaser.Math.Vector4} + * @since 3.0.0 + */ + this.position = new Vector4(x, y, z); + + /** + * [description] + * + * @name Phaser.GameObjects.Sprite3D#size + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.size = new Vector2(this.gameObject.width, this.gameObject.height); + + /** + * [description] + * + * @name Phaser.GameObjects.Sprite3D#scale + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.scale = new Vector2(1, 1); + + /** + * [description] + * + * @name Phaser.GameObjects.Sprite3D#adjustScaleX + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.adjustScaleX = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Sprite3D#adjustScaleY + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.adjustScaleY = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Sprite3D#_visible + * @type {boolean} + * @default true + * @private + * @since 3.0.0 + */ + this._visible = true; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Sprite3D#project + * @since 3.0.0 + * + * @param {Phaser.Cameras.Sprite3D.Camera} camera - The 3D Camera onto which to project this Sprite. + */ + project: function (camera) + { + var pos = this.position; + + var gameObject = this.gameObject; + + camera.project(pos, gameObject); + + camera.getPointSize(pos, this.size, this.scale); + + if (this.scale.x <= 0 || this.scale.y <= 0) + { + gameObject.setVisible(false); + } + else + { + if (!gameObject.visible) + { + gameObject.setVisible(true); + } + + if (this.adjustScaleX) + { + gameObject.scaleX = this.scale.x; + } + + if (this.adjustScaleY) + { + gameObject.scaleY = this.scale.y; + } + + gameObject.setDepth(gameObject.z * -1); + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Sprite3D#setVisible + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.GameObjects.Sprite3D} This Sprite3D Object. + */ + setVisible: function (value) + { + this.visible = value; + + return this; + }, + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * + * @name Phaser.GameObjects.Sprite3D#visible + * @type {boolean} + * @since 3.0.0 + */ + visible: { + + get: function () + { + return this._visible; + }, + + set: function (value) + { + this._visible = value; + this.gameObject.visible = value; + } + + }, + + /** + * The x position of this Game Object. + * + * @name Phaser.GameObjects.Sprite3D#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.position.x; + }, + + set: function (value) + { + this.position.x = value; + } + + }, + + /** + * The y position of this Game Object. + * + * @name Phaser.GameObjects.Sprite3D#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.position.y; + }, + + set: function (value) + { + this.position.y = value; + } + + }, + + /** + * The z position of this Game Object. + * + * @name Phaser.GameObjects.Sprite3D#z + * @type {number} + * @since 3.0.0 + */ + z: { + + get: function () + { + return this.position.z; + }, + + set: function (value) + { + this.position.z = value; + } + + } + +}); + +module.exports = Sprite3D; + + +/***/ }), +/* 102 */ /***/ (function(module, exports) { /** @@ -16276,187 +16271,31 @@ module.exports = Tileset; */ /** - * [description] + * Shuffles the contents of the given array using the Fisher-Yates implementation. * - * @function Phaser.Tweens.Builders.GetNewValue + * The original array is modified directly and returned. + * + * @function Phaser.Utils.Array.Shuffle * @since 3.0.0 * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {any} defaultValue - [description] + * @param {array} array - The array to shuffle. This array is modified in place. * - * @return {function} [description] + * @return {array} The shuffled array. */ -var GetNewValue = function (source, key, defaultValue) +var Shuffle = function (array) { - var valueCallback; - - if (source.hasOwnProperty(key)) + for (var i = array.length - 1; i > 0; i--) { - var t = typeof(source[key]); - - if (t === 'function') - { - valueCallback = function (index, totalTargets, target) - { - return source[key](index, totalTargets, target); - }; - } - else - { - valueCallback = function () - { - return source[key]; - }; - } - } - else if (typeof defaultValue === 'function') - { - valueCallback = defaultValue; - } - else - { - valueCallback = function () - { - return defaultValue; - }; + var j = Math.floor(Math.random() * (i + 1)); + var temp = array[i]; + array[i] = array[j]; + array[j] = temp; } - return valueCallback; + return array; }; -module.exports = GetNewValue; - - -/***/ }), -/* 102 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Defaults = __webpack_require__(160); -var GetAdvancedValue = __webpack_require__(10); -var GetBoolean = __webpack_require__(73); -var GetEaseFunction = __webpack_require__(71); -var GetNewValue = __webpack_require__(101); -var GetProps = __webpack_require__(359); -var GetTargets = __webpack_require__(158); -var GetValue = __webpack_require__(4); -var GetValueOp = __webpack_require__(159); -var Tween = __webpack_require__(161); -var TweenData = __webpack_require__(162); - -/** - * [description] - * - * @function Phaser.Tweens.Builders.TweenBuilder - * @since 3.0.0 - * - * @param {Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline} parent - [description] - * @param {object} config - [description] - * @param {Phaser.Tweens.Tween~ConfigDefaults} defaults - [description] - * - * @return {Phaser.Tweens.Tween} [description] - */ -var TweenBuilder = function (parent, config, defaults) -{ - if (defaults === undefined) - { - defaults = Defaults; - } - - // Create arrays of the Targets and the Properties - var targets = (defaults.targets) ? defaults.targets : GetTargets(config); - - // var props = (defaults.props) ? defaults.props : GetProps(config); - var props = GetProps(config); - - // Default Tween values - var delay = GetNewValue(config, 'delay', defaults.delay); - var duration = GetNewValue(config, 'duration', defaults.duration); - var easeParams = GetValue(config, 'easeParams', defaults.easeParams); - var ease = GetEaseFunction(GetValue(config, 'ease', defaults.ease), easeParams); - var hold = GetNewValue(config, 'hold', defaults.hold); - var repeat = GetNewValue(config, 'repeat', defaults.repeat); - var repeatDelay = GetNewValue(config, 'repeatDelay', defaults.repeatDelay); - var yoyo = GetBoolean(config, 'yoyo', defaults.yoyo); - var flipX = GetBoolean(config, 'flipX', defaults.flipX); - var flipY = GetBoolean(config, 'flipY', defaults.flipY); - - var data = []; - - // Loop through every property defined in the Tween, i.e.: props { x, y, alpha } - for (var p = 0; p < props.length; p++) - { - var key = props[p].key; - var value = props[p].value; - - // Create 1 TweenData per target, per property - for (var t = 0; t < targets.length; t++) - { - var ops = GetValueOp(key, value); - - var tweenData = TweenData( - targets[t], - key, - ops.getEnd, - ops.getStart, - GetEaseFunction(GetValue(value, 'ease', ease), easeParams), - GetNewValue(value, 'delay', delay), - GetNewValue(value, 'duration', duration), - GetBoolean(value, 'yoyo', yoyo), - GetNewValue(value, 'hold', hold), - GetNewValue(value, 'repeat', repeat), - GetNewValue(value, 'repeatDelay', repeatDelay), - GetBoolean(value, 'flipX', flipX), - GetBoolean(value, 'flipY', flipY) - ); - - data.push(tweenData); - } - } - - var tween = new Tween(parent, data, targets); - - tween.offset = GetAdvancedValue(config, 'offset', null); - tween.completeDelay = GetAdvancedValue(config, 'completeDelay', 0); - tween.loop = Math.round(GetAdvancedValue(config, 'loop', 0)); - tween.loopDelay = Math.round(GetAdvancedValue(config, 'loopDelay', 0)); - tween.paused = GetBoolean(config, 'paused', false); - tween.useFrames = GetBoolean(config, 'useFrames', false); - - // Set the Callbacks - var scope = GetValue(config, 'callbackScope', tween); - - // Callback parameters: 0 = a reference to the Tween itself, 1 = the target/s of the Tween, ... your own params - var tweenArray = [ tween, null ]; - - var callbacks = Tween.TYPES; - - for (var i = 0; i < callbacks.length; i++) - { - var type = callbacks[i]; - - var callback = GetValue(config, type, false); - - if (callback) - { - var callbackScope = GetValue(config, type + 'Scope', scope); - var callbackParams = GetValue(config, type + 'Params', []); - - // The null is reset to be the Tween target - tween.setCallback(type, callback, tweenArray.concat(callbackParams), callbackScope); - } - } - - return tween; -}; - -module.exports = TweenBuilder; +module.exports = Shuffle; /***/ }), @@ -16470,7 +16309,1115 @@ module.exports = TweenBuilder; */ var Class = __webpack_require__(0); -var Utils = __webpack_require__(41); + +/** + * @callback DataEachCallback + * + * @param {*} parent - [description] + * @param {string} key - [description] + * @param {*} value - [description] + * @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the game object, key, and data. + */ + +/** + * @classdesc + * The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin. + * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter, + * or have a property called `events` that is an instance of it. + * + * @class DataManager + * @memberOf Phaser.Data + * @constructor + * @since 3.0.0 + * + * @param {*} parent - [description] + * @param {EventEmitter} eventEmitter - [description] + */ +var DataManager = new Class({ + + initialize: + + function DataManager (parent, eventEmitter) + { + /** + * [description] + * + * @name Phaser.Data.DataManager#parent + * @type {*} + * @since 3.0.0 + */ + this.parent = parent; + + /** + * [description] + * + * @name Phaser.Data.DataManager#events + * @type {EventEmitter} + * @since 3.0.0 + */ + this.events = eventEmitter; + + if (!eventEmitter) + { + this.events = (parent.events) ? parent.events : parent; + } + + /** + * [description] + * + * @name Phaser.Data.DataManager#list + * @type {Object.} + * @default {} + * @since 3.0.0 + */ + this.list = {}; + + /** + * [description] + * + * @name Phaser.Data.DataManager#blockSet + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.blockSet = false; + + /** + * [description] + * + * @name Phaser.Data.DataManager#_frozen + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._frozen = false; + + this.events.once('destroy', this.destroy, this); + }, + + /** + * Retrieves the value for the given key, or undefined if it doesn't exist. + * + * @method Phaser.Data.DataManager#get + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {*} [description] + */ + get: function (key) + { + return this.list[key]; + }, + + /** + * [description] + * + * @method Phaser.Data.DataManager#getAll + * @since 3.0.0 + * + * @return {Object.} [description] + */ + getAll: function () + { + var results = {}; + + for (var key in this.list) + { + if(this.list.hasOwnProperty(key)) + { + results[key] = this.list[key]; + } + } + + return results; + }, + + /** + * [description] + * + * @method Phaser.Data.DataManager#query + * @since 3.0.0 + * + * @param {string} search - [description] + * + * @return {Object.} [description] + */ + query: function (search) + { + var results = {}; + + for (var key in this.list) + { + if (this.list.hasOwnProperty(key) && key.match(search)) + { + results[key] = this.list[key]; + } + } + + return results; + }, + + /** + * [description] + * + * @method Phaser.Data.DataManager#set + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {*} data - [description] + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + set: function (key, data) + { + if (this._frozen) + { + return this; + } + + if (this.events.listenerCount('changedata') > 0) + { + this.blockSet = false; + + var _this = this; + + var resetFunction = function (value) + { + _this.blockSet = true; + _this.list[key] = value; + _this.events.emit('setdata', _this.parent, key, value); + }; + + this.events.emit('changedata', this.parent, key, data, resetFunction); + + // One of the listeners blocked this update from being set, so abort + if (this.blockSet) + { + return this; + } + } + + this.list[key] = data; + + this.events.emit('setdata', this.parent, key, data); + + return this; + }, + + /** + * Passes all data entries to the given callback. Stores the result of the callback. + * + * @method Phaser.Data.DataManager#each + * @since 3.0.0 + * + * @param {DataEachCallback} callback - The function to call. + * @param {object} [scope] - Value to use as `this` when executing callback. + * @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the game object, key, and data. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + each: function (callback, scope) + { + var args = [ this.parent, null, undefined ]; + + for (var i = 1; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (var key in this.list) + { + args[1] = key; + args[2] = this.list[key]; + + callback.apply(scope, args); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Data.DataManager#merge + * @since 3.0.0 + * + * @param {Object.} data - [description] + * @param {boolean} overwrite - [description] + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + merge: function (data, overwrite) + { + if (overwrite === undefined) { overwrite = true; } + + // Merge data from another component into this one + for (var key in data) + { + if (data.hasOwnProperty(key) && (overwrite || (!overwrite && !this.has(key)))) + { + this.list[key] = data[key]; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Data.DataManager#remove + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + remove: function (key) + { + if (!this._frozen && this.has(key)) + { + var data = this.list[key]; + + delete this.list[key]; + + this.events.emit('removedata', this, key, data); + } + + return this; + }, + + /** + * Gets the data associated with the given 'key', deletes it from this Data store, then returns it. + * + * @method Phaser.Data.DataManager#pop + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {*} [description] + */ + pop: function (key) + { + var data = undefined; + + if (!this._frozen && this.has(key)) + { + data = this.list[key]; + + delete this.list[key]; + + this.events.emit('removedata', this, key, data); + } + + return data; + }, + + /** + * [description] + * + * @method Phaser.Data.DataManager#has + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {boolean} [description] + */ + has: function (key) + { + return this.list.hasOwnProperty(key); + }, + + /** + * [description] + * + * @method Phaser.Data.DataManager#setFreeze + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + setFreeze: function (value) + { + this._frozen = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Data.DataManager#reset + * @since 3.0.0 + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + reset: function () + { + for (var key in this.list) + { + delete this.list[key]; + } + + this.blockSet = false; + this._frozen = false; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Data.DataManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.reset(); + + this.events.off('changedata'); + this.events.off('setdata'); + this.events.off('removedata'); + + this.parent = null; + }, + + /** + * Freeze this Data component, so no changes can be written to it. + * + * @name Phaser.Data.DataManager#freeze + * @type {boolean} + * @since 3.0.0 + */ + freeze: { + + get: function () + { + return this._frozen; + }, + + set: function (value) + { + this._frozen = (value) ? true : false; + } + + }, + + /** + * Return the total number of entries in this Data component. + * + * @name Phaser.Data.DataManager#count + * @type {integer} + * @since 3.0.0 + */ + count: { + + get: function () + { + var i = 0; + + for (var key in this.list) + { + if (this.list[key] !== undefined) + { + i++; + } + } + + return i; + } + + } + +}); + +module.exports = DataManager; + + +/***/ }), +/* 104 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetPoint = __webpack_require__(351); +var GetPoints = __webpack_require__(165); +var Random = __webpack_require__(164); +var Vector2 = __webpack_require__(6); + +/** + * @classdesc + * Defines a Line segment, a part of a line between two endpoints. + * + * @class Line + * @memberOf Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x1] - [description] + * @param {number} [y1] - [description] + * @param {number} [x2] - [description] + * @param {number} [y2] - [description] + */ +var Line = new Class({ + + initialize: + + function Line (x1, y1, x2, y2) + { + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 0; } + if (y2 === undefined) { y2 = 0; } + + /** + * [description] + * + * @name Phaser.Geom.Line#x1 + * @type {number} + * @since 3.0.0 + */ + this.x1 = x1; + + /** + * [description] + * + * @name Phaser.Geom.Line#y1 + * @type {number} + * @since 3.0.0 + */ + this.y1 = y1; + + /** + * [description] + * + * @name Phaser.Geom.Line#x2 + * @type {number} + * @since 3.0.0 + */ + this.x2 = x2; + + /** + * [description] + * + * @name Phaser.Geom.Line#y2 + * @type {number} + * @since 3.0.0 + */ + this.y2 = y2; + }, + + /** + * [description] + * + * @method Phaser.Geom.Line#getPoint + * @since 3.0.0 + * + * @param {float} position - [description] + * @param {(Phaser.Geom.Point|object)} [output] - [description] + * + * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the ellipse. + */ + getPoint: function (position, output) + { + return GetPoint(this, position, output); + }, + + /** + * [description] + * + * @method Phaser.Geom.Line#getPoints + * @since 3.0.0 + * + * @param {integer} quantity - [description] + * @param {integer} [stepRate] - [description] + * @param {(array|Phaser.Geom.Point[])} [output] - [description] + * + * @return {(array|Phaser.Geom.Point[])} [description] + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * [description] + * + * @method Phaser.Geom.Line#getRandomPoint + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point - [description] + * + * @return {Phaser.Geom.Point} [description] + */ + getRandomPoint: function (point) + { + return Random(this, point); + }, + + /** + * [description] + * + * @method Phaser.Geom.Line#setTo + * @since 3.0.0 + * + * @param {number} [x1=0] - [description] + * @param {number} [y1=0] - [description] + * @param {number} [x2=0] - [description] + * @param {number} [y2=0] - [description] + * + * @return {Phaser.Geom.Line} This Line object. + */ + setTo: function (x1, y1, x2, y2) + { + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 0; } + if (y2 === undefined) { y2 = 0; } + + this.x1 = x1; + this.y1 = y1; + + this.x2 = x2; + this.y2 = y2; + + return this; + }, + + /** + * Returns a Vector2 object that corresponds to the start of this Line. + * + * @method Phaser.Geom.Line#getPointA + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. + * + * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the start of this Line. + */ + getPointA: function (vec2) + { + if (vec2 === undefined) { vec2 = new Vector2(); } + + vec2.setTo(this.x1, this.y1); + + return vec2; + }, + + /** + * Returns a Vector2 object that corresponds to the start of this Line. + * + * @method Phaser.Geom.Line#getPointB + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. + * + * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the start of this Line. + */ + getPointB: function (vec2) + { + if (vec2 === undefined) { vec2 = new Vector2(); } + + vec2.setTo(this.x2, this.y2); + + return vec2; + }, + + /** + * The left position of the Line. + * + * @name Phaser.Geom.Line#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () + { + return Math.min(this.x1, this.x2); + }, + + set: function (value) + { + if (this.x1 <= this.x2) + { + this.x1 = value; + } + else + { + this.x2 = value; + } + } + + }, + + /** + * The right position of the Line. + * + * @name Phaser.Geom.Line#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return Math.max(this.x1, this.x2); + }, + + set: function (value) + { + if (this.x1 > this.x2) + { + this.x1 = value; + } + else + { + this.x2 = value; + } + } + + }, + + /** + * The top position of the Line. + * + * @name Phaser.Geom.Line#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return Math.min(this.y1, this.y2); + }, + + set: function (value) + { + if (this.y1 <= this.y2) + { + this.y1 = value; + } + else + { + this.y2 = value; + } + } + + }, + + /** + * The bottom position of the Line. + * + * @name Phaser.Geom.Line#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return Math.max(this.y1, this.y2); + }, + + set: function (value) + { + if (this.y1 > this.y2) + { + this.y1 = value; + } + else + { + this.y2 = value; + } + } + + } + +}); + +module.exports = Line; + + +/***/ }), +/* 105 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Perimeter + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {number} [description] + */ +var Perimeter = function (rect) +{ + return 2 * (rect.width + rect.height); +}; + +module.exports = Perimeter; + + +/***/ }), +/* 106 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BlendModes = __webpack_require__(62); +var Circle = __webpack_require__(79); +var CircleContains = __webpack_require__(28); +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var GameObject = __webpack_require__(1); +var Rectangle = __webpack_require__(10); +var RectangleContains = __webpack_require__(27); + +/** + * @classdesc + * A Zone Game Object. + * + * A Zone is a non-rendering rectangular Game Object that has a position and size. + * It has no texture and never displays, but does live on the display list and + * can be moved, scaled and rotated like any other Game Object. + * + * Its primary use is for creating Drop Zones and Input Hit Areas and it has a couple of helper methods + * specifically for this. It is also useful for object overlap checks, or as a base for your own + * non-displaying Game Objects. + + * The default origin is 0.5, the center of the Zone, the same as with Game Objects. + * + * @class Zone + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - [description] + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number} [width=1] - The width of the Game Object. + * @param {number} [height=1] - The height of the Game Object. + */ +var Zone = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Depth, + Components.GetBounds, + Components.Origin, + Components.ScaleMode, + Components.Transform, + Components.ScrollFactor, + Components.Visible + ], + + initialize: + + function Zone (scene, x, y, width, height) + { + if (width === undefined) { width = 1; } + if (height === undefined) { height = width; } + + GameObject.call(this, scene, 'Zone'); + + this.setPosition(x, y); + + /** + * The native (un-scaled) width of this Game Object. + * + * @name Phaser.GameObjects.Zone#width + * @type {number} + * @since 3.0.0 + */ + this.width = width; + + /** + * The native (un-scaled) height of this Game Object. + * + * @name Phaser.GameObjects.Zone#height + * @type {number} + * @since 3.0.0 + */ + this.height = height; + + /** + * The Blend Mode of the Game Object. + * Although a Zone never renders, it still has a blend mode to allow it to fit seamlessly into + * display lists without causing a batch flush. + * + * @name Phaser.GameObjects.Zone#blendMode + * @type {integer} + * @since 3.0.0 + */ + this.blendMode = BlendModes.NORMAL; + }, + + /** + * The displayed width of this Game Object. + * This value takes into account the scale factor. + * + * @name Phaser.GameObjects.Zone#displayWidth + * @type {number} + * @since 3.0.0 + */ + displayWidth: { + + get: function () + { + return this.scaleX * this.width; + }, + + set: function (value) + { + this.scaleX = value / this.width; + } + + }, + + /** + * The displayed height of this Game Object. + * This value takes into account the scale factor. + * + * @name Phaser.GameObjects.Zone#displayHeight + * @type {number} + * @since 3.0.0 + */ + displayHeight: { + + get: function () + { + return this.scaleY * this.height; + }, + + set: function (value) + { + this.scaleY = value / this.height; + } + + }, + + /** + * Sets the size of this Game Object. + * + * @method Phaser.GameObjects.Zone#setSize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * @param {boolean} [resizeInput=true] - If this Zone has a Rectangle for a hit area this argument will resize the hit area as well. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setSize: function (width, height, resizeInput) + { + if (resizeInput === undefined) { resizeInput = true; } + + this.width = width; + this.height = height; + + if (resizeInput && this.input && this.input.hitArea instanceof Rectangle) + { + this.input.hitArea.width = width; + this.input.hitArea.height = height; + } + + return this; + }, + + /** + * Sets the display size of this Game Object. + * Calling this will adjust the scale. + * + * @method Phaser.GameObjects.Zone#setDisplaySize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setDisplaySize: function (width, height) + { + this.displayWidth = width; + this.displayHeight = height; + + return this; + }, + + /** + * Sets this Zone to be a Circular Drop Zone. + * The circle is centered on this Zones `x` and `y` coordinates. + * + * @method Phaser.GameObjects.Zone#setCircleDropZone + * @since 3.0.0 + * + * @param {number} radius - The radius of the Circle that will form the Drop Zone. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setCircleDropZone: function (radius) + { + return this.setDropZone(new Circle(0, 0, radius), CircleContains); + }, + + /** + * Sets this Zone to be a Rectangle Drop Zone. + * The rectangle is centered on this Zones `x` and `y` coordinates. + * + * @method Phaser.GameObjects.Zone#setRectangleDropZone + * @since 3.0.0 + * + * @param {number} width - The width of the rectangle drop zone. + * @param {number} height - The height of the rectangle drop zone. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setRectangleDropZone: function (width, height) + { + var x = -(width / 2); + var y = -(height / 2); + + return this.setDropZone(new Rectangle(x, y, width, height), RectangleContains); + }, + + /** + * Allows you to define your own Geometry shape to be used as a Drop Zone. + * + * @method Phaser.GameObjects.Zone#setDropZone + * @since 3.0.0 + * + * @param {object} shape - A Geometry shape instance, such as Phaser.Geom.Ellipse, or your own custom shape. + * @param {HitAreaCallback} callback - A function that will return `true` if the given x/y coords it is sent are within the shape. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setDropZone: function (shape, callback) + { + if (shape === undefined) + { + this.setRectangleDropZone(this.width, this.height); + } + else + if (!this.input) + { + this.setInteractive(shape, callback, true); + } + + return this; + }, + + /** + * A Zone does not render. + * + * @method Phaser.GameObjects.Zone#renderCanvas + * @private + * @since 3.0.0 + */ + renderCanvas: function () + { + }, + + /** + * A Zone does not render. + * + * @method Phaser.GameObjects.Zone#renderWebGL + * @private + * @since 3.0.0 + */ + renderWebGL: function () + { + } + +}); + +module.exports = Zone; + + +/***/ }), +/* 107 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clone = __webpack_require__(55); + +/** + * Creates a new Object using all values from obj1 and obj2. + * If a value exists in both obj1 and obj2, the value in obj1 is used. + * + * @function Phaser.Utils.Object.Merge + * @since 3.0.0 + * + * @param {object} obj1 - [description] + * @param {object} obj2 - [description] + * + * @return {object} [description] + */ +var Merge = function (obj1, obj2) +{ + var clone = Clone(obj1); + + for (var key in obj2) + { + if (!clone.hasOwnProperty(key)) + { + clone[key] = obj2[key]; + } + } + + return clone; +}; + +module.exports = Merge; + + +/***/ }), +/* 108 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Utils = __webpack_require__(44); /** * @classdesc @@ -16670,10 +17617,10 @@ var WebGLPipeline = new Class({ * @since 3.2.0 * * @param {string} name - [description] - * @param {int} size - [description] - * @param {int} type - [description] + * @param {integer} size - [description] + * @param {integer} type - [description] * @param {boolean} normalized - [description] - * @param {int} offset - [description] + * @param {integer} offset - [description] * * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] */ @@ -16960,7 +17907,7 @@ var WebGLPipeline = new Class({ * @since 3.2.0 * * @param {string} name - [description] - * @param {int} x - [description] + * @param {integer} x - [description] * * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] */ @@ -16977,8 +17924,8 @@ var WebGLPipeline = new Class({ * @since 3.2.0 * * @param {string} name - [description] - * @param {int} x - [description] - * @param {int} y - [description] + * @param {integer} x - [description] + * @param {integer} y - [description] * * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] */ @@ -16995,9 +17942,9 @@ var WebGLPipeline = new Class({ * @since 3.2.0 * * @param {string} name - [description] - * @param {int} x - [description] - * @param {int} y - [description] - * @param {int} z - [description] + * @param {integer} x - [description] + * @param {integer} y - [description] + * @param {integer} z - [description] * * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] */ @@ -17014,10 +17961,10 @@ var WebGLPipeline = new Class({ * @since 3.2.0 * * @param {string} name - [description] - * @param {int} x - [description] - * @param {int} y - [description] - * @param {int} z - [description] - * @param {int} w - [description] + * @param {integer} x - [description] + * @param {integer} y - [description] + * @param {integer} z - [description] + * @param {integer} w - [description] * * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] */ @@ -17086,241 +18033,9 @@ var WebGLPipeline = new Class({ module.exports = WebGLPipeline; -/***/ }), -/* 104 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clone = __webpack_require__(53); - -/** - * Creates a new Object using all values from obj1 and obj2. - * If a value exists in both obj1 and obj2, the value in obj1 is used. - * - * @function Phaser.Utils.Object.Merge - * @since 3.0.0 - * - * @param {object} obj1 - [description] - * @param {object} obj2 - [description] - * - * @return {object} [description] - */ -var Merge = function (obj1, obj2) -{ - var clone = Clone(obj1); - - for (var key in obj2) - { - if (!clone.hasOwnProperty(key)) - { - clone[key] = obj2[key]; - } - } - - return clone; -}; - -module.exports = Merge; - - -/***/ }), -/* 105 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle. - * - * @function Phaser.Geom.Circle.CircumferencePoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on. - * @param {number} angle - The angle from the center of the Circle to the circumference to return the point from. Given in radians. - * @param {Phaser.Geom.Point|object} [out] - A Point, or point-like object, to store the results in. If not given a Point will be created. - * - * @return {Phaser.Geom.Point|object} A Point object where the `x` and `y` properties are the point on the circumference. - */ -var CircumferencePoint = function (circle, angle, out) -{ - if (out === undefined) { out = new Point(); } - - out.x = circle.x + (circle.radius * Math.cos(angle)); - out.y = circle.y + (circle.radius * Math.sin(angle)); - - return out; -}; - -module.exports = CircumferencePoint; - - -/***/ }), -/* 106 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * Returns a uniformly distributed random point from anywhere within the given Circle. - * - * @function Phaser.Geom.Circle.Random - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to get a random point from. - * @param {Phaser.Geom.Point|object} [point] - A Point or point-like object to set the random `x` and `y` values in. - * - * @return {Phaser.Geom.Point|object} A Point object with the random values set in the `x` and `y` properties. - */ -var Random = function (circle, out) -{ - if (out === undefined) { out = new Point(); } - - var t = 2 * Math.PI * Math.random(); - var u = Math.random() + Math.random(); - var r = (u > 1) ? 2 - u : u; - var x = r * Math.cos(t); - var y = r * Math.sin(t); - - out.x = circle.x + (x * circle.radius); - out.y = circle.y + (y * circle.radius); - - return out; -}; - -module.exports = Random; - - -/***/ }), -/* 107 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Perimeter = __webpack_require__(78); -var Point = __webpack_require__(5); - -/** - * Position is a value between 0 and 1 where 0 = the top-left of the rectangle and 0.5 = the bottom right. - * - * @function Phaser.Geom.Rectangle.GetPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rectangle - [description] - * @param {float} position - [description] - * @param {Phaser.Geom.Point|object} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var GetPoint = function (rectangle, position, out) -{ - if (out === undefined) { out = new Point(); } - - if (position <= 0 || position >= 1) - { - out.x = rectangle.x; - out.y = rectangle.y; - - return out; - } - - var p = Perimeter(rectangle) * position; - - if (position > 0.5) - { - p -= (rectangle.width + rectangle.height); - - if (p <= rectangle.width) - { - // Face 3 - out.x = rectangle.right - p; - out.y = rectangle.bottom; - } - else - { - // Face 4 - out.x = rectangle.x; - out.y = rectangle.bottom - (p - rectangle.width); - } - } - else if (p <= rectangle.width) - { - // Face 1 - out.x = rectangle.x + p; - out.y = rectangle.y; - } - else - { - // Face 2 - out.x = rectangle.right; - out.y = rectangle.y + (p - rectangle.width); - } - - return out; -}; - -module.exports = GetPoint; - - -/***/ }), -/* 108 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Random - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Point} out - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Random = function (rect, out) -{ - if (out === undefined) { out = new Point(); } - - out.x = rect.x + (Math.random() * rect.width); - out.y = rect.y + (Math.random() * rect.height); - - return out; -}; - -module.exports = Random; - - /***/ }), /* 109 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -17328,57 +18043,57 @@ module.exports = Random; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Length = __webpack_require__(66); -var Point = __webpack_require__(5); +/** +* A Matrix is simply an array of arrays, where each sub-array (the rows) have the same length: +* +* let matrix2 = [ +* [ 1, 1, 1, 1, 1, 1 ], +* [ 2, 0, 0, 0, 0, 4 ], +* [ 2, 0, 1, 2, 0, 4 ], +* [ 2, 0, 3, 4, 0, 4 ], +* [ 2, 0, 0, 0, 0, 4 ], +* [ 3, 3, 3, 3, 3, 3 ] +*]; +*/ /** * [description] * - * @function Phaser.Geom.Line.GetPoints + * @function Phaser.Utils.Array.Matrix.CheckMatrix * @since 3.0.0 * - * @param {Phaser.Geom.Line} line - [description] - * @param {integer} quantity - [description] - * @param {integer} [stepRate] - [description] - * @param {array} out - [description] + * @param {array} matrix - [description] * - * @return {array} [description] + * @return {boolean} [description] */ -var GetPoints = function (line, quantity, stepRate, out) +var CheckMatrix = function (matrix) { - if (out === undefined) { out = []; } - - // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. - if (!quantity) + if (!Array.isArray(matrix) || matrix.length < 2 || !Array.isArray(matrix[0])) { - quantity = Length(line) / stepRate; + return false; } - var x1 = line.x1; - var y1 = line.y1; + // How long is the first row? + var size = matrix[0].length; - var x2 = line.x2; - var y2 = line.y2; - - for (var i = 0; i < quantity; i++) + // Validate the rest of the rows are the same length + for (var i = 1; i < matrix.length; i++) { - var position = i / quantity; - - var x = x1 + (x2 - x1) * position; - var y = y1 + (y2 - y1) * position; - - out.push(new Point(x, y)); + if (matrix[i].length !== size) + { + return false; + } } - return out; + return true; }; -module.exports = GetPoints; +module.exports = CheckMatrix; /***/ }), /* 110 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -17386,33 +18101,147 @@ module.exports = GetPoints; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); +/** + * @typedef {object} TweenDataGenConfig + * + * @property {function} delay - [description] + * @property {function} duration - [description] + * @property {function} hold - [description] + * @property {function} repeat - [description] + * @property {function} repeatDelay - [description] + */ /** - * Returns a uniformly distributed random point from anywhere within the given Ellipse. + * @typedef {object} Phaser.Tweens.TweenDataConfig * - * @function Phaser.Geom.Ellipse.Random + * @property {object} target - The target to tween. + * @property {string} key - The property of the target being tweened. + * @property {function} getEndValue - The returned value sets what the property will be at the END of the Tween. + * @property {function} getStartValue - The returned value sets what the property will be at the START of the Tween. + * @property {function} ease - The ease function this tween uses. + * @property {number} [duration=0] - Duration of the tween in ms/frames, excludes time for yoyo or repeats. + * @property {number} [totalDuration=0] - The total calculated duration of this TweenData (based on duration, repeat, delay and yoyo) + * @property {number} [delay=0] - Time in ms/frames before tween will start. + * @property {boolean} [yoyo=false] - Cause the tween to return back to its start value after hold has expired. + * @property {number} [hold=0] - Time in ms/frames the tween will pause before running the yoyo or starting a repeat. + * @property {integer} [repeat=0] - Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. + * @property {number} [repeatDelay=0] - Time in ms/frames before the repeat will start. + * @property {boolean} [flipX=false] - Automatically call toggleFlipX when the TweenData yoyos or repeats + * @property {boolean} [flipY=false] - Automatically call toggleFlipY when the TweenData yoyos or repeats + * @property {float} [progress=0] - Between 0 and 1 showing completion of this TweenData. + * @property {float} [elapsed=0] - Delta counter + * @property {integer} [repeatCounter=0] - How many repeats are left to run? + * @property {number} [start=0] - Ease value data. + * @property {number} [current=0] - Ease value data. + * @property {number} [end=0] - Ease value data. + * @property {number} [t1=0] - Time duration 1. + * @property {number} [t2=0] - Time duration 2. + * @property {TweenDataGenConfig} [gen] - LoadValue generation functions. + * @property {integer} [state=0] - TWEEN_CONST.CREATED + */ + +/** + * [description] + * + * @function Phaser.Tweens.TweenData * @since 3.0.0 * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get a random point from. - * @param {Phaser.Geom.Point|object} [point] - A Point or point-like object to set the random `x` and `y` values in. + * @param {object} target - [description] + * @param {string} key - [description] + * @param {function} getEnd - [description] + * @param {function} getStart - [description] + * @param {function} ease - [description] + * @param {number} delay - [description] + * @param {number} duration - [description] + * @param {boolean} yoyo - [description] + * @param {number} hold - [description] + * @param {number} repeat - [description] + * @param {number} repeatDelay - [description] + * @param {boolean} flipX - [description] + * @param {boolean} flipY - [description] * - * @return {Phaser.Geom.Point|object} A Point object with the random values set in the `x` and `y` properties. + * @return {TweenDataConfig} [description] */ -var Random = function (ellipse, out) +var TweenData = function (target, key, getEnd, getStart, ease, delay, duration, yoyo, hold, repeat, repeatDelay, flipX, flipY) { - if (out === undefined) { out = new Point(); } + return { - var p = Math.random() * Math.PI * 2; - var s = Math.sqrt(Math.random()); + // The target to tween + target: target, - out.x = ellipse.x + ((s * Math.cos(p)) * ellipse.width / 2); - out.y = ellipse.y + ((s * Math.sin(p)) * ellipse.height / 2); + // The property of the target to tween + key: key, - return out; + // The returned value sets what the property will be at the END of the Tween. + getEndValue: getEnd, + + // The returned value sets what the property will be at the START of the Tween. + getStartValue: getStart, + + // The ease function this tween uses. + ease: ease, + + // Duration of the tween in ms/frames, excludes time for yoyo or repeats. + duration: 0, + + // The total calculated duration of this TweenData (based on duration, repeat, delay and yoyo) + totalDuration: 0, + + // Time in ms/frames before tween will start. + delay: 0, + + // Cause the tween to return back to its start value after hold has expired. + yoyo: yoyo, + + // Time in ms/frames the tween will pause before running the yoyo or starting a repeat. + hold: 0, + + // Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. + repeat: 0, + + // Time in ms/frames before the repeat will start. + repeatDelay: 0, + + // Automatically call toggleFlipX when the TweenData yoyos or repeats + flipX: flipX, + + // Automatically call toggleFlipY when the TweenData yoyos or repeats + flipY: flipY, + + // Between 0 and 1 showing completion of this TweenData. + progress: 0, + + // Delta counter. + elapsed: 0, + + // How many repeats are left to run? + repeatCounter: 0, + + // Ease Value Data: + + start: 0, + current: 0, + end: 0, + + // Time Durations + t1: 0, + t2: 0, + + // LoadValue generation functions + gen: { + delay: delay, + duration: duration, + hold: hold, + repeat: repeat, + repeatDelay: repeatDelay + }, + + // TWEEN_CONST.CREATED + state: 0 + }; }; -module.exports = Random; +module.exports = TweenData; /***/ }), @@ -17425,37 +18254,1378 @@ module.exports = Random; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); +var Class = __webpack_require__(0); +var GameObjectCreator = __webpack_require__(11); +var GameObjectFactory = __webpack_require__(9); +var TWEEN_CONST = __webpack_require__(68); /** + * @classdesc * [description] * - * @function Phaser.Geom.Line.Random + * @class Tween + * @memberOf Phaser.Tweens + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Line} line - [description] - * @param {Phaser.Geom.Point|object} [out] - [description] - * - * @return {Phaser.Geom.Point|object} [description] + * @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - [description] + * @param {Phaser.Tweens.TweenDataConfig[]} data - [description] + * @param {array} targets - [description] */ -var Random = function (line, out) +var Tween = new Class({ + + initialize: + + function Tween (parent, data, targets) + { + /** + * [description] + * + * @name Phaser.Tweens.Tween#parent + * @type {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} + * @since 3.0.0 + */ + this.parent = parent; + + /** + * Is the parent of this Tween a Timeline? + * + * @name Phaser.Tweens.Tween#parentIsTimeline + * @type {boolean} + * @since 3.0.0 + */ + this.parentIsTimeline = parent.hasOwnProperty('isTimeline'); + + /** + * An array of TweenData objects, each containing a unique property and target being tweened. + * + * @name Phaser.Tweens.Tween#data + * @type {Phaser.Tweens.TweenDataConfig[]} + * @since 3.0.0 + */ + this.data = data; + + /** + * data array doesn't change, so we can cache the length + * + * @name Phaser.Tweens.Tween#totalData + * @type {integer} + * @since 3.0.0 + */ + this.totalData = data.length; + + /** + * An array of references to the target/s this Tween is operating on + * + * @name Phaser.Tweens.Tween#targets + * @type {object[]} + * @since 3.0.0 + */ + this.targets = targets; + + /** + * Cached target total (not necessarily the same as the data total) + * + * @name Phaser.Tweens.Tween#totalTargets + * @type {integer} + * @since 3.0.0 + */ + this.totalTargets = targets.length; + + /** + * If true then duration, delay, etc values are all frame totals. + * + * @name Phaser.Tweens.Tween#useFrames + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.useFrames = false; + + /** + * Scales the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. + * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. + * + * @name Phaser.Tweens.Tween#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * Loop this tween? Can be -1 for an infinite loop, or an integer. + * When enabled it will play through ALL TweenDatas again (use TweenData.repeat to loop a single TD) + * + * @name Phaser.Tweens.Tween#loop + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loop = 0; + + /** + * Time in ms/frames before the tween loops. + * + * @name Phaser.Tweens.Tween#loopDelay + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loopDelay = 0; + + /** + * How many loops are left to run? + * + * @name Phaser.Tweens.Tween#loopCounter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loopCounter = 0; + + /** + * Time in ms/frames before the 'onComplete' event fires. This never fires if loop = -1 (as it never completes) + * + * @name Phaser.Tweens.Tween#completeDelay + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.completeDelay = 0; + + /** + * Countdown timer (used by timeline offset, loopDelay and completeDelay) + * + * @name Phaser.Tweens.Tween#countdown + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.countdown = 0; + + /** + * Set only if this Tween is part of a Timeline. + * + * @name Phaser.Tweens.Tween#offset + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.offset = 0; + + /** + * Set only if this Tween is part of a Timeline. The calculated offset amount. + * + * @name Phaser.Tweens.Tween#calculatedOffset + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.calculatedOffset = 0; + + /** + * The current state of the tween + * + * @name Phaser.Tweens.Tween#state + * @type {integer} + * @since 3.0.0 + */ + this.state = TWEEN_CONST.PENDING_ADD; + + /** + * The state of the tween when it was paused (used by Resume) + * + * @name Phaser.Tweens.Tween#_pausedState + * @type {integer} + * @private + * @since 3.0.0 + */ + this._pausedState = TWEEN_CONST.PENDING_ADD; + + /** + * Does the Tween start off paused? (if so it needs to be started with Tween.play) + * + * @name Phaser.Tweens.Tween#paused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.paused = false; + + /** + * Elapsed time in ms/frames of this run through the Tween. + * + * @name Phaser.Tweens.Tween#elapsed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.elapsed = 0; + + /** + * Total elapsed time in ms/frames of the entire Tween, including looping. + * + * @name Phaser.Tweens.Tween#totalElapsed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalElapsed = 0; + + /** + * Time in ms/frames for the whole Tween to play through once, excluding loop amounts and loop delays. + * + * @name Phaser.Tweens.Tween#duration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.duration = 0; + + /** + * Value between 0 and 1. The amount through the Tween, excluding loops. + * + * @name Phaser.Tweens.Tween#progress + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.progress = 0; + + /** + * Time in ms/frames for the Tween to complete (including looping) + * + * @name Phaser.Tweens.Tween#totalDuration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalDuration = 0; + + /** + * Value between 0 and 1. The amount through the entire Tween, including looping. + * + * @name Phaser.Tweens.Tween#totalProgress + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalProgress = 0; + + /** + * An object containing the various Tween callback references. + * + * @name Phaser.Tweens.Tween#callbacks + * @type {object} + * @default 0 + * @since 3.0.0 + */ + this.callbacks = { + onComplete: null, + onLoop: null, + onRepeat: null, + onStart: null, + onUpdate: null, + onYoyo: null + }; + + this.callbackScope; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#getValue + * @since 3.0.0 + * + * @return {number} [description] + */ + getValue: function () + { + return this.data[0].current; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#setTimeScale + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + setTimeScale: function (value) + { + this.timeScale = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#getTimeScale + * @since 3.0.0 + * + * @return {number} [description] + */ + getTimeScale: function () + { + return this.timeScale; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#isPlaying + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isPlaying: function () + { + return (this.state === TWEEN_CONST.ACTIVE); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#isPaused + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isPaused: function () + { + return (this.state === TWEEN_CONST.PAUSED); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#hasTarget + * @since 3.0.0 + * + * @param {object} target - [description] + * + * @return {boolean} [description] + */ + hasTarget: function (target) + { + return (this.targets.indexOf(target) !== -1); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#updateTo + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {*} value - [description] + * @param {boolean} startToCurrent - [description] + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + updateTo: function (key, value, startToCurrent) + { + for (var i = 0; i < this.totalData; i++) + { + var tweenData = this.data[i]; + + if (tweenData.key === key) + { + tweenData.end = value; + + if (startToCurrent) + { + tweenData.start = tweenData.current; + } + + break; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#restart + * @since 3.0.0 + */ + restart: function () + { + this.stop(); + this.play(); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#calcDuration + * @since 3.0.0 + */ + calcDuration: function () + { + var max = 0; + + var data = this.data; + + for (var i = 0; i < this.totalData; i++) + { + var tweenData = data[i]; + + // Set t1 (duration + hold + yoyo) + tweenData.t1 = tweenData.duration + tweenData.hold; + + if (tweenData.yoyo) + { + tweenData.t1 += tweenData.duration; + } + + // Set t2 (repeatDelay + duration + hold + yoyo) + tweenData.t2 = tweenData.t1 + tweenData.repeatDelay; + + // Total Duration + tweenData.totalDuration = tweenData.delay + tweenData.t1; + + if (tweenData.repeat === -1) + { + tweenData.totalDuration += (tweenData.t2 * 999999999999); + } + else if (tweenData.repeat > 0) + { + tweenData.totalDuration += (tweenData.t2 * tweenData.repeat); + } + + if (tweenData.totalDuration > max) + { + // Get the longest TweenData from the Tween, used to calculate the Tween TD + max = tweenData.totalDuration; + } + } + + // Excludes loop values + this.duration = max; + + this.loopCounter = (this.loop === -1) ? 999999999999 : this.loop; + + if (this.loopCounter > 0) + { + this.totalDuration = this.duration + this.completeDelay + ((this.duration + this.loopDelay) * this.loopCounter); + } + else + { + this.totalDuration = this.duration + this.completeDelay; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#init + * @since 3.0.0 + * + * @return {boolean} Returns `true` if this Tween should be moved from the pending list to the active list by the Tween Manager. + */ + init: function () + { + var data = this.data; + var totalTargets = this.totalTargets; + + for (var i = 0; i < this.totalData; i++) + { + var tweenData = data[i]; + var target = tweenData.target; + var gen = tweenData.gen; + + tweenData.delay = gen.delay(i, totalTargets, target); + tweenData.duration = gen.duration(i, totalTargets, target); + tweenData.hold = gen.hold(i, totalTargets, target); + tweenData.repeat = gen.repeat(i, totalTargets, target); + tweenData.repeatDelay = gen.repeatDelay(i, totalTargets, target); + } + + this.calcDuration(); + + this.progress = 0; + this.totalProgress = 0; + this.elapsed = 0; + this.totalElapsed = 0; + + // You can't have a paused Tween if it's part of a Timeline + if (this.paused && !this.parentIsTimeline) + { + this.state = TWEEN_CONST.PENDING_ADD; + + return false; + } + else + { + this.state = TWEEN_CONST.INIT; + + return true; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#nextState + * @since 3.0.0 + */ + nextState: function () + { + if (this.loopCounter > 0) + { + this.elapsed = 0; + this.progress = 0; + this.loopCounter--; + + var onLoop = this.callbacks.onLoop; + + if (onLoop) + { + onLoop.params[1] = this.targets; + + onLoop.func.apply(onLoop.scope, onLoop.params); + } + + this.resetTweenData(true); + + if (this.loopDelay > 0) + { + this.countdown = this.loopDelay; + this.state = TWEEN_CONST.LOOP_DELAY; + } + else + { + this.state = TWEEN_CONST.ACTIVE; + } + } + else if (this.completeDelay > 0) + { + this.countdown = this.completeDelay; + this.state = TWEEN_CONST.COMPLETE_DELAY; + } + else + { + var onComplete = this.callbacks.onComplete; + + if (onComplete) + { + onComplete.params[1] = this.targets; + + onComplete.func.apply(onComplete.scope, onComplete.params); + } + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#pause + * @since 3.0.0 + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + pause: function () + { + if (this.state === TWEEN_CONST.PAUSED) + { + return; + } + + this.paused = true; + + this._pausedState = this.state; + + this.state = TWEEN_CONST.PAUSED; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#play + * @since 3.0.0 + * + * @param {boolean} resetFromTimeline - [description] + */ + play: function (resetFromTimeline) + { + if (this.state === TWEEN_CONST.ACTIVE) + { + return; + } + else if (this.state === TWEEN_CONST.PENDING_REMOVE || this.state === TWEEN_CONST.REMOVED) + { + this.init(); + this.parent.makeActive(this); + resetFromTimeline = true; + } + + var onStart = this.callbacks.onStart; + + if (this.parentIsTimeline) + { + this.resetTweenData(resetFromTimeline); + + if (this.calculatedOffset === 0) + { + if (onStart) + { + onStart.params[1] = this.targets; + + onStart.func.apply(onStart.scope, onStart.params); + } + + this.state = TWEEN_CONST.ACTIVE; + } + else + { + this.countdown = this.calculatedOffset; + + this.state = TWEEN_CONST.OFFSET_DELAY; + } + } + else if (this.paused) + { + this.paused = false; + + this.parent.makeActive(this); + } + else + { + this.resetTweenData(resetFromTimeline); + + this.state = TWEEN_CONST.ACTIVE; + + if (onStart) + { + onStart.params[1] = this.targets; + + onStart.func.apply(onStart.scope, onStart.params); + } + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#resetTweenData + * @since 3.0.0 + * + * @param {boolean} resetFromLoop - [description] + */ + resetTweenData: function (resetFromLoop) + { + var data = this.data; + + for (var i = 0; i < this.totalData; i++) + { + var tweenData = data[i]; + + tweenData.progress = 0; + tweenData.elapsed = 0; + + tweenData.repeatCounter = (tweenData.repeat === -1) ? 999999999999 : tweenData.repeat; + + if (resetFromLoop) + { + tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); + + tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.end); + + tweenData.current = tweenData.start; + + tweenData.state = TWEEN_CONST.PLAYING_FORWARD; + } + else if (tweenData.delay > 0) + { + tweenData.elapsed = tweenData.delay; + tweenData.state = TWEEN_CONST.DELAY; + } + else + { + tweenData.state = TWEEN_CONST.PENDING_RENDER; + } + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#resume + * @since 3.0.0 + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + resume: function () + { + if (this.state === TWEEN_CONST.PAUSED) + { + this.paused = false; + + this.state = this._pausedState; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#seek + * @since 3.0.0 + * + * @param {float} toPosition - A value between 0 and 1. + */ + seek: function (toPosition) + { + var data = this.data; + + for (var i = 0; i < this.totalData; i++) + { + // This won't work with loop > 0 yet + var ms = this.totalDuration * toPosition; + + var tweenData = data[i]; + var progress = 0; + var elapsed = 0; + + if (ms <= tweenData.delay) + { + progress = 0; + elapsed = 0; + } + else if (ms >= tweenData.totalDuration) + { + progress = 1; + elapsed = tweenData.duration; + } + else if (ms > tweenData.delay && ms <= tweenData.t1) + { + // Keep it zero bound + ms = Math.max(0, ms - tweenData.delay); + + // Somewhere in the first playthru range + progress = ms / tweenData.t1; + elapsed = tweenData.duration * progress; + } + else if (ms > tweenData.t1 && ms < tweenData.totalDuration) + { + // Somewhere in repeat land + ms -= tweenData.delay; + ms -= tweenData.t1; + + // var repeats = Math.floor(ms / tweenData.t2); + + // remainder + ms = ((ms / tweenData.t2) % 1) * tweenData.t2; + + if (ms > tweenData.repeatDelay) + { + progress = ms / tweenData.t1; + elapsed = tweenData.duration * progress; + } + } + + tweenData.progress = progress; + tweenData.elapsed = elapsed; + + var v = tweenData.ease(tweenData.progress); + + tweenData.current = tweenData.start + ((tweenData.end - tweenData.start) * v); + + // console.log(tweenData.key, 'Seek', tweenData.target[tweenData.key], 'to', tweenData.current, 'pro', tweenData.progress, 'marker', toPosition, progress); + + // if (tweenData.current === 0) + // { + // console.log('zero', tweenData.start, tweenData.end, v, 'progress', progress); + // } + + tweenData.target[tweenData.key] = tweenData.current; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#setCallback + * @since 3.0.0 + * + * @param {string} type - [description] + * @param {function} callback - [description] + * @param {array} [params] - [description] + * @param {object} [scope] - [description] + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + setCallback: function (type, callback, params, scope) + { + this.callbacks[type] = { func: callback, scope: scope, params: params }; + + return this; + }, + + /** + * Flags the Tween as being complete, whatever stage of progress it is at. + * + * If an onComplete callback has been defined it will automatically invoke it, unless a `delay` + * argument is provided, in which case the Tween will delay for that period of time before calling the callback. + * + * If you don't need a delay, or have an onComplete callback, then call `Tween.stop` instead. + * + * @method Phaser.Tweens.Tween#complete + * @since 3.2.0 + * + * @param {number} [delay=0] - The time to wait before invoking the complete callback. If zero it will fire immediately. + */ + complete: function (delay) + { + if (delay === undefined) { delay = 0; } + + if (delay) + { + this.countdown = delay; + this.state = TWEEN_CONST.COMPLETE_DELAY; + } + else + { + var onComplete = this.callbacks.onComplete; + + if (onComplete) + { + onComplete.params[1] = this.targets; + + onComplete.func.apply(onComplete.scope, onComplete.params); + } + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + }, + + /** + * Stops the Tween immediately, whatever stage of progress it is at and flags it for removal by the TweenManager. + * + * @method Phaser.Tweens.Tween#stop + * @since 3.0.0 + * + * @param {float} [resetTo] - A value between 0 and 1. + */ + stop: function (resetTo) + { + if (this.state === TWEEN_CONST.ACTIVE) + { + if (resetTo !== undefined) + { + this.seek(resetTo); + } + } + + if (this.state !== TWEEN_CONST.REMOVED) + { + this.state = TWEEN_CONST.PENDING_REMOVE; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#update + * @since 3.0.0 + * + * @param {number} timestamp - [description] + * @param {number} delta - [description] + * + * @return {boolean} Returns `true` if this Tween has finished and should be removed from the Tween Manager, otherwise returns `false`. + */ + update: function (timestamp, delta) + { + if (this.state === TWEEN_CONST.PAUSED) + { + return false; + } + + if (this.useFrames) + { + delta = 1 * this.parent.timeScale; + } + + delta *= this.timeScale; + + this.elapsed += delta; + this.progress = Math.min(this.elapsed / this.duration, 1); + + this.totalElapsed += delta; + this.totalProgress = Math.min(this.totalElapsed / this.totalDuration, 1); + + switch (this.state) + { + case TWEEN_CONST.ACTIVE: + + var stillRunning = false; + + for (var i = 0; i < this.totalData; i++) + { + if (this.updateTweenData(this, this.data[i], delta)) + { + stillRunning = true; + } + } + + // Anything still running? If not, we're done + if (!stillRunning) + { + this.nextState(); + } + + break; + + case TWEEN_CONST.LOOP_DELAY: + + this.countdown -= delta; + + if (this.countdown <= 0) + { + this.state = TWEEN_CONST.ACTIVE; + } + + break; + + case TWEEN_CONST.OFFSET_DELAY: + + this.countdown -= delta; + + if (this.countdown <= 0) + { + var onStart = this.callbacks.onStart; + + if (onStart) + { + onStart.params[1] = this.targets; + + onStart.func.apply(onStart.scope, onStart.params); + } + + this.state = TWEEN_CONST.ACTIVE; + } + + break; + + case TWEEN_CONST.COMPLETE_DELAY: + + this.countdown -= delta; + + if (this.countdown <= 0) + { + var onComplete = this.callbacks.onComplete; + + if (onComplete) + { + onComplete.func.apply(onComplete.scope, onComplete.params); + } + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + + break; + } + + return (this.state === TWEEN_CONST.PENDING_REMOVE); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#setStateFromEnd + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] + * @param {number} diff - [description] + * + * @return {integer} The state of this Tween. + */ + setStateFromEnd: function (tween, tweenData, diff) + { + if (tweenData.yoyo) + { + // We've hit the end of a Playing Forward TweenData and we have a yoyo + + // Account for any extra time we got from the previous frame + tweenData.elapsed = diff; + tweenData.progress = diff / tweenData.duration; + + if (tweenData.flipX) + { + tweenData.target.toggleFlipX(); + } + + // Problem: The flip and callback and so on gets called for every TweenData that triggers it at the same time. + // If you're tweening several properties it can fire for all of them, at once. + + if (tweenData.flipY) + { + tweenData.target.toggleFlipY(); + } + + var onYoyo = tween.callbacks.onYoyo; + + if (onYoyo) + { + // Element 1 is reserved for the target of the yoyo (and needs setting here) + onYoyo.params[1] = tweenData.target; + + onYoyo.func.apply(onYoyo.scope, onYoyo.params); + } + + tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); + + return TWEEN_CONST.PLAYING_BACKWARD; + } + else if (tweenData.repeatCounter > 0) + { + // We've hit the end of a Playing Forward TweenData and we have a Repeat. + // So we're going to go right back to the start to repeat it again. + + tweenData.repeatCounter--; + + // Account for any extra time we got from the previous frame + tweenData.elapsed = diff; + tweenData.progress = diff / tweenData.duration; + + if (tweenData.flipX) + { + tweenData.target.toggleFlipX(); + } + + if (tweenData.flipY) + { + tweenData.target.toggleFlipY(); + } + + var onRepeat = tween.callbacks.onRepeat; + + if (onRepeat) + { + // Element 1 is reserved for the target of the repeat (and needs setting here) + onRepeat.params[1] = tweenData.target; + + onRepeat.func.apply(onRepeat.scope, onRepeat.params); + } + + tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); + + tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); + + // Delay? + if (tweenData.repeatDelay > 0) + { + tweenData.elapsed = tweenData.repeatDelay - diff; + + tweenData.current = tweenData.start; + + tweenData.target[tweenData.key] = tweenData.current; + + return TWEEN_CONST.REPEAT_DELAY; + } + else + { + return TWEEN_CONST.PLAYING_FORWARD; + } + } + + return TWEEN_CONST.COMPLETE; + }, + + /** + * Was PLAYING_BACKWARD and has hit the start. + * + * @method Phaser.Tweens.Tween#setStateFromStart + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] + * @param {number} diff - [description] + * + * @return {integer} The state of this Tween. + */ + setStateFromStart: function (tween, tweenData, diff) + { + if (tweenData.repeatCounter > 0) + { + tweenData.repeatCounter--; + + // Account for any extra time we got from the previous frame + tweenData.elapsed = diff; + tweenData.progress = diff / tweenData.duration; + + if (tweenData.flipX) + { + tweenData.target.toggleFlipX(); + } + + if (tweenData.flipY) + { + tweenData.target.toggleFlipY(); + } + + var onRepeat = tween.callbacks.onRepeat; + + if (onRepeat) + { + // Element 1 is reserved for the target of the repeat (and needs setting here) + onRepeat.params[1] = tweenData.target; + + onRepeat.func.apply(onRepeat.scope, onRepeat.params); + } + + tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); + + // Delay? + if (tweenData.repeatDelay > 0) + { + tweenData.elapsed = tweenData.repeatDelay - diff; + + tweenData.current = tweenData.start; + + tweenData.target[tweenData.key] = tweenData.current; + + return TWEEN_CONST.REPEAT_DELAY; + } + else + { + return TWEEN_CONST.PLAYING_FORWARD; + } + } + + return TWEEN_CONST.COMPLETE; + }, + + // + /** + * [description] + * + * @method Phaser.Tweens.Tween#updateTweenData + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] + * @param {number} delta - Either a value in ms, or 1 if Tween.useFrames is true + * + * @return {boolean} [description] + */ + updateTweenData: function (tween, tweenData, delta) + { + switch (tweenData.state) + { + case TWEEN_CONST.PLAYING_FORWARD: + case TWEEN_CONST.PLAYING_BACKWARD: + + if (!tweenData.target) + { + tweenData.state = TWEEN_CONST.COMPLETE; + break; + } + + var elapsed = tweenData.elapsed; + var duration = tweenData.duration; + var diff = 0; + + elapsed += delta; + + if (elapsed > duration) + { + diff = elapsed - duration; + elapsed = duration; + } + + var forward = (tweenData.state === TWEEN_CONST.PLAYING_FORWARD); + var progress = elapsed / duration; + + var v; + + if (forward) + { + v = tweenData.ease(progress); + } + else + { + v = tweenData.ease(1 - progress); + } + + tweenData.current = tweenData.start + ((tweenData.end - tweenData.start) * v); + + tweenData.target[tweenData.key] = tweenData.current; + + tweenData.elapsed = elapsed; + tweenData.progress = progress; + + var onUpdate = tween.callbacks.onUpdate; + + if (onUpdate) + { + onUpdate.params[1] = tweenData.target; + + onUpdate.func.apply(onUpdate.scope, onUpdate.params); + } + + if (progress === 1) + { + if (forward) + { + if (tweenData.hold > 0) + { + tweenData.elapsed = tweenData.hold - diff; + + tweenData.state = TWEEN_CONST.HOLD_DELAY; + } + else + { + tweenData.state = this.setStateFromEnd(tween, tweenData, diff); + } + } + else + { + tweenData.state = this.setStateFromStart(tween, tweenData, diff); + } + } + + break; + + case TWEEN_CONST.DELAY: + + tweenData.elapsed -= delta; + + if (tweenData.elapsed <= 0) + { + tweenData.elapsed = Math.abs(tweenData.elapsed); + + tweenData.state = TWEEN_CONST.PENDING_RENDER; + } + + break; + + case TWEEN_CONST.REPEAT_DELAY: + + tweenData.elapsed -= delta; + + if (tweenData.elapsed <= 0) + { + tweenData.elapsed = Math.abs(tweenData.elapsed); + + tweenData.state = TWEEN_CONST.PLAYING_FORWARD; + } + + break; + + case TWEEN_CONST.HOLD_DELAY: + + tweenData.elapsed -= delta; + + if (tweenData.elapsed <= 0) + { + tweenData.state = this.setStateFromEnd(tween, tweenData, Math.abs(tweenData.elapsed)); + } + + break; + + case TWEEN_CONST.PENDING_RENDER: + + if (tweenData.target) + { + tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.target[tweenData.key]); + + tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); + + tweenData.current = tweenData.start; + + tweenData.target[tweenData.key] = tweenData.start; + + tweenData.state = TWEEN_CONST.PLAYING_FORWARD; + } + else + { + tweenData.state = TWEEN_CONST.COMPLETE; + } + + break; + } + + // Return TRUE if this TweenData still playing, otherwise return FALSE + return (tweenData.state !== TWEEN_CONST.COMPLETE); + } + +}); + +Tween.TYPES = [ + 'onComplete', + 'onLoop', + 'onRepeat', + 'onStart', + 'onUpdate', + 'onYoyo' +]; + +/** + * Creates a new Tween object. + * + * Note: This method will only be available Tweens have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#tween + * @since 3.0.0 + * + * @param {object} config - The Tween configuration. + * + * @return {Phaser.Tweens.Tween} The Tween that was created. + */ +GameObjectFactory.register('tween', function (config) { - if (out === undefined) { out = new Point(); } + return this.scene.sys.tweens.add(config); +}); - var t = Math.random(); +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns - out.x = line.x1 + t * (line.x2 - line.x1); - out.y = line.y1 + t * (line.y2 - line.y1); +/** + * Creates a new Tween object and returns it. + * + * Note: This method will only be available if Tweens have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#tween + * @since 3.0.0 + * + * @param {object} config - The Tween configuration. + * + * @return {Phaser.Tweens.Tween} The Tween that was created. + */ +GameObjectCreator.register('tween', function (config) +{ + return this.scene.sys.tweens.create(config); +}); - return out; -}; +// When registering a factory function 'this' refers to the GameObjectCreator context. -module.exports = Random; +module.exports = Tween; /***/ }), /* 112 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -17463,48 +19633,37 @@ module.exports = Random; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); - /** - * [description] - * - * @function Phaser.Geom.Triangle.Random - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] + * @typedef {object} Phaser.Tweens.TweenConfigDefaults + * + * @property {(object|object[])} targets - [description] + * @property {number} [delay=0] - [description] + * @property {number} [duration=1000] - [description] + * @property {string} [ease='Power0'] - [description] + * @property {array} [easeParams] - [description] + * @property {number} [hold=0] - [description] + * @property {number} [repeat=0] - [description] + * @property {number} [repeatDelay=0] - [description] + * @property {boolean} [yoyo=false] - [description] + * @property {boolean} [flipX=false] - [description] + * @property {boolean} [flipY=false] - [description] */ -var Random = function (triangle, out) -{ - if (out === undefined) { out = new Point(); } - // Basis vectors - var ux = triangle.x2 - triangle.x1; - var uy = triangle.y2 - triangle.y1; - - var vx = triangle.x3 - triangle.x1; - var vy = triangle.y3 - triangle.y1; - - // Random point within the unit square - var r = Math.random(); - var s = Math.random(); - - // Point outside the triangle? Remap it. - if (r + s >= 1) - { - r = 1 - r; - s = 1 - s; - } - - out.x = triangle.x1 + ((ux * r) + (vx * s)); - out.y = triangle.y1 + ((uy * r) + (vy * s)); - - return out; +var TWEEN_DEFAULTS = { + targets: null, + delay: 0, + duration: 1000, + ease: 'Power0', + easeParams: null, + hold: 0, + repeat: 0, + repeatDelay: 0, + yoyo: false, + flipX: false, + flipY: false }; -module.exports = Random; +module.exports = TWEEN_DEFAULTS; /***/ }), @@ -17517,31 +19676,167 @@ module.exports = Random; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +function hasGetStart (def) +{ + return (!!def.getStart && typeof def.getStart === 'function'); +} + +function hasGetEnd (def) +{ + return (!!def.getEnd && typeof def.getEnd === 'function'); +} + +function hasGetters (def) +{ + return hasGetStart(def) || hasGetEnd(def); +} + /** * [description] * - * @function Phaser.Math.RotateAroundDistance + * @function Phaser.Tweens.Builders.GetValueOp * @since 3.0.0 * - * @param {Phaser.Geom.Point|object} point - The Point to be rotated. - * @param {number} x - The horizontal coordinate to rotate around. - * @param {number} y - The vertical coordinate to rotate around. - * @param {number} angle - The angle of rotation in radians. - * @param {number} distance - [description] + * @param {string} key - [description] + * @param {*} propertyValue - [description] * - * @return {Phaser.Geom.Point} [description] + * @return {function} [description] */ -var RotateAroundDistance = function (point, x, y, angle, distance) +var GetValueOp = function (key, propertyValue) { - var t = angle + Math.atan2(point.y - y, point.x - x); + var callbacks; - point.x = x + (distance * Math.cos(t)); - point.y = y + (distance * Math.sin(t)); + // The returned value sets what the property will be at the END of the Tween (usually called at the start of the Tween) + var getEnd = function (target, key, value) { return value; }; - return point; + // The returned value sets what the property will be at the START of the Tween (usually called at the end of the Tween) + var getStart = function (target, key, value) { return value; }; + + var t = typeof(propertyValue); + + if (t === 'number') + { + // props: { + // x: 400, + // y: 300 + // } + + getEnd = function () + { + return propertyValue; + }; + } + else if (t === 'string') + { + // props: { + // x: '+=400', + // y: '-=300', + // z: '*=2', + // w: '/=2' + // } + + var op = propertyValue[0]; + var num = parseFloat(propertyValue.substr(2)); + + switch (op) + { + case '+': + getEnd = function (target, key, value) + { + return value + num; + }; + break; + + case '-': + getEnd = function (target, key, value) + { + return value - num; + }; + break; + + case '*': + getEnd = function (target, key, value) + { + return value * num; + }; + break; + + case '/': + getEnd = function (target, key, value) + { + return value / num; + }; + break; + + default: + getEnd = function () + { + return parseFloat(propertyValue); + }; + } + } + else if (t === 'function') + { + // The same as setting just the getEnd function and no getStart + + // props: { + // x: function (target, key, value) { return value + 50); }, + // } + + getEnd = propertyValue; + } + else if (t === 'object' && hasGetters(propertyValue)) + { + /* + x: { + // Called at the start of the Tween. The returned value sets what the property will be at the END of the Tween. + getEnd: function (target, key, value) + { + return value; + }, + + // Called at the end of the Tween. The returned value sets what the property will be at the START of the Tween. + getStart: function (target, key, value) + { + return value; + } + } + */ + + if (hasGetEnd(propertyValue)) + { + getEnd = propertyValue.getEnd; + } + + if (hasGetStart(propertyValue)) + { + getStart = propertyValue.getStart; + } + } + else if (propertyValue.hasOwnProperty('value')) + { + // Value may still be a string, function or a number + // props: { + // x: { value: 400, ... }, + // y: { value: 300, ... } + // } + + callbacks = GetValueOp(key, propertyValue.value); + } + + // If callback not set by the else if block above then set it here and return it + if (!callbacks) + { + callbacks = { + getEnd: getEnd, + getStart: getStart + }; + } + + return callbacks; }; -module.exports = RotateAroundDistance; +module.exports = GetValueOp; /***/ }), @@ -17554,321 +19849,41 @@ module.exports = RotateAroundDistance; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); +var GetValue = __webpack_require__(5); /** - * @classdesc - * The keys of a Map can be arbitrary values. - * var map = new Map([ - * [ 1, 'one' ], - * [ 2, 'two' ], - * [ 3, 'three' ] - * ]); + * [description] * - * @class Map - * @memberOf Phaser.Structs - * @constructor + * @function Phaser.Tweens.Builders.GetTargets * @since 3.0.0 * - * @param {array} elements - [description] + * @param {object} config - [description] + * + * @return {array} [description] */ -var Map = new Class({ +var GetTargets = function (config) +{ + var targets = GetValue(config, 'targets', null); - initialize: - - function Map (elements) + if (targets === null) { - /** - * [description] - * - * @name Phaser.Structs.Map#entries - * @type {object} - * @default {} - * @since 3.0.0 - */ - this.entries = {}; - - /** - * [description] - * - * @name Phaser.Structs.Map#size - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.size = 0; - - if (Array.isArray(elements)) - { - for (var i = 0; i < elements.length; i++) - { - this.set(elements[i][0], elements[i][1]); - } - } - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#set - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {any} value - [description] - * - * @return {Phaser.Structs.Map} This Map object. - */ - set: function (key, value) - { - if (!this.has(key)) - { - this.entries[key] = value; - this.size++; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#get - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {any} [description] - */ - get: function (key) - { - if (this.has(key)) - { - return this.entries[key]; - } - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#getArray - * @since 3.0.0 - * - * @return {array} [description] - */ - getArray: function () - { - var output = []; - var entries = this.entries; - - for (var key in entries) - { - output.push(entries[key]); - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#has - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {boolean} [description] - */ - has: function (key) - { - return (this.entries.hasOwnProperty(key)); - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#delete - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Structs.Map} This Map object. - */ - delete: function (key) - { - if (this.has(key)) - { - delete this.entries[key]; - this.size--; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#clear - * @since 3.0.0 - * - * @return {Phaser.Structs.Map} This Map object. - */ - clear: function () - { - Object.keys(this.entries).forEach(function (prop) - { - delete this.entries[prop]; - - }, this); - - this.size = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#keys - * @since 3.0.0 - * - * @return {[type]} [description] - */ - keys: function () - { - return Object.keys(this.entries); - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#values - * @since 3.0.0 - * - * @return {array} [description] - */ - values: function () - { - var output = []; - var entries = this.entries; - - for (var key in entries) - { - output.push(entries[key]); - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#dump - * @since 3.0.0 - */ - dump: function () - { - var entries = this.entries; - - // eslint-disable-next-line no-console - console.group('Map'); - - for (var key in entries) - { - console.log(key, entries[key]); - } - - // eslint-disable-next-line no-console - console.groupEnd(); - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#each - * @since 3.0.0 - * - * @param {function} callback - [description] - * - * @return {Phaser.Structs.Map} This Map object. - */ - each: function (callback) - { - var entries = this.entries; - - for (var key in entries) - { - if (callback(key, entries[key]) === false) - { - break; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#contains - * @since 3.0.0 - * - * @param {any} value - [description] - * - * @return {boolean} [description] - */ - contains: function (value) - { - var entries = this.entries; - - for (var key in entries) - { - if (entries[key] === value) - { - return true; - } - } - - return false; - }, - - /** - * Merges all new keys from the given Map into this one - * If it encounters a key that already exists it will be skipped - * unless override = true. - * - * @method Phaser.Structs.Map#merge - * @since 3.0.0 - * - * @param {Phaser.Structs.Map} map - [description] - * @param {boolean} [override=false] - [description] - * - * @return {Phaser.Structs.Map} This Map object. - */ - merge: function (map, override) - { - if (override === undefined) { override = false; } - - var local = this.entries; - var source = map.entries; - - for (var key in source) - { - if (local.hasOwnProperty(key) && override) - { - local[key] = source[key]; - } - else - { - this.set(key, source[key]); - } - } - - return this; + return targets; } -}); + if (typeof targets === 'function') + { + targets = targets.call(); + } -module.exports = Map; + if (!Array.isArray(targets)) + { + targets = [ targets ]; + } + + return targets; +}; + +module.exports = GetTargets; /***/ }), @@ -17881,1352 +19896,80 @@ module.exports = Map; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var DegToRad = __webpack_require__(35); -var Rectangle = __webpack_require__(8); -var TransformMatrix = __webpack_require__(190); -var ValueToColor = __webpack_require__(116); -var Vector2 = __webpack_require__(6); +var Formats = __webpack_require__(24); +var MapData = __webpack_require__(65); +var Parse = __webpack_require__(194); +var Tilemap = __webpack_require__(186); /** - * @classdesc - * [description] + * Create a Tilemap from the given key or data. If neither is given, make a blank Tilemap. When + * loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing from + * a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map data. For + * an empty map, you should specify tileWidth, tileHeight, width & height. * - * @class Camera - * @memberOf Phaser.Cameras.Scene2D - * @constructor + * @function Phaser.Tilemaps.ParseToTilemap * @since 3.0.0 - * - * @param {number} x - The x position of the Camera, relative to the top-left of the game canvas. - * @param {number} y - The y position of the Camera, relative to the top-left of the game canvas. - * @param {number} width - The width of the Camera, in pixels. - * @param {number} height - The height of the Camera, in pixels. + * + * @param {Phaser.Scene} scene - The Scene to which this Tilemap belongs. + * @param {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data. + * @param {integer} [tileWidth=32] - The width of a tile in pixels. + * @param {integer} [tileHeight=32] - The height of a tile in pixels. + * @param {integer} [width=10] - The width of the map in tiles. + * @param {integer} [height=10] - The height of the map in tiles. + * @param {integer[][]} [data] - Instead of loading from the cache, you can also load directly from + * a 2D array of tile indexes. + * @param {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, in the + * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + * + * @return {Phaser.Tilemaps.Tilemap} */ -var Camera = new Class({ +var ParseToTilemap = function (scene, key, tileWidth, tileHeight, width, height, data, insertNull) +{ + if (tileWidth === undefined) { tileWidth = 32; } + if (tileHeight === undefined) { tileHeight = 32; } + if (width === undefined) { width = 10; } + if (height === undefined) { height = 10; } + if (insertNull === undefined) { insertNull = false; } - initialize: + var mapData = null; - function Camera (x, y, width, height) + if (Array.isArray(data)) { - /** - * A reference to the Scene this camera belongs to. - * - * @name Phaser.Cameras.Scene2D.Camera#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene; - - /** - * The name of the Camera. This is left empty for your own use. - * - * @name Phaser.Cameras.Scene2D.Camera#name - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.name = ''; - - /** - * The x position of the Camera, relative to the top-left of the game canvas. - * - * @name Phaser.Cameras.Scene2D.Camera#x - * @type {number} - * @since 3.0.0 - */ - this.x = x; - - /** - * The y position of the Camera, relative to the top-left of the game canvas. - * - * @name Phaser.Cameras.Scene2D.Camera#y - * @type {number} - * @since 3.0.0 - */ - this.y = y; - - /** - * The width of the Camera, in pixels. - * - * @name Phaser.Cameras.Scene2D.Camera#width - * @type {number} - * @since 3.0.0 - */ - this.width = width; - - /** - * The height of the Camera, in pixels. - * - * @name Phaser.Cameras.Scene2D.Camera#height - * @type {number} - * @since 3.0.0 - */ - this.height = height; - - /** - * Should this camera round its pixel values to integers? - * - * @name Phaser.Cameras.Scene2D.Camera#roundPixels - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.roundPixels = false; - - /** - * Is this Camera using a bounds to restrict scrolling movement? - * Set this property along with the bounds via `Camera.setBounds`. - * - * @name Phaser.Cameras.Scene2D.Camera#useBounds - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.useBounds = false; - - /** - * The bounds the camera is restrained to during scrolling. - * - * @name Phaser.Cameras.Scene2D.Camera#_bounds - * @type {Phaser.Geom.Rectangle} - * @private - * @since 3.0.0 - */ - this._bounds = new Rectangle(); - - /** - * Does this Camera allow the Game Objects it renders to receive input events? - * - * @name Phaser.Cameras.Scene2D.Camera#inputEnabled - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.inputEnabled = true; - - /** - * The horizontal scroll position of this camera. - * Optionally restricted via the Camera bounds. - * - * @name Phaser.Cameras.Scene2D.Camera#scrollX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.scrollX = 0; - - /** - * The vertical scroll position of this camera. - * Optionally restricted via the Camera bounds. - * - * @name Phaser.Cameras.Scene2D.Camera#scrollY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.scrollY = 0; - - /** - * The Camera zoom value. Change this value to zoom in, or out of, a Scene. - * Set to 1 to return to the default zoom level. - * - * @name Phaser.Cameras.Scene2D.Camera#zoom - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.zoom = 1; - - /** - * The rotation of the Camera. This influences the rendering of all Game Objects visible by this camera. - * - * @name Phaser.Cameras.Scene2D.Camera#rotation - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.rotation = 0; - - /** - * A local transform matrix used for internal calculations. - * - * @name Phaser.Cameras.Scene2D.Camera#matrix - * @type {TransformMatrix} - * @since 3.0.0 - */ - this.matrix = new TransformMatrix(1, 0, 0, 1, 0, 0); - - /** - * Does this Camera have a transparent background? - * - * @name Phaser.Cameras.Scene2D.Camera#transparent - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.transparent = true; - - /** - * TODO - * - * @name Phaser.Cameras.Scene2D.Camera#clearBeforeRender - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.clearBeforeRender = true; - - /** - * The background color of this Camera. Only used if `transparent` is `false`. - * - * @name Phaser.Cameras.Scene2D.Camera#backgroundColor - * @type {Phaser.Display.Color} - * @since 3.0.0 - */ - this.backgroundColor = ValueToColor('rgba(0,0,0,0)'); - - /** - * Should the camera cull Game Objects before rendering? - * In some special cases it may be beneficial to disable this. - * - * @name Phaser.Cameras.Scene2D.Camera#disableCull - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.disableCull = false; - - /** - * A temporary array of culled objects. - * - * @name Phaser.Cameras.Scene2D.Camera#culledObjects - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.culledObjects = []; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_shakeDuration - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._shakeDuration = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_shakeIntensity - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._shakeIntensity = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_shakeOffsetX - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._shakeOffsetX = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_shakeOffsetY - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._shakeOffsetY = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_fadeDuration - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._fadeDuration = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_fadeRed - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._fadeRed = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_fadeGreen - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._fadeGreen = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_fadeBlue - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._fadeBlue = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_fadeAlpha - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._fadeAlpha = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_flashDuration - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._flashDuration = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_flashRed - * @type {number} - * @private - * @default 1 - * @since 3.0.0 - */ - this._flashRed = 1; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_flashGreen - * @type {number} - * @private - * @default 1 - * @since 3.0.0 - */ - this._flashGreen = 1; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_flashBlue - * @type {number} - * @private - * @default 1 - * @since 3.0.0 - */ - this._flashBlue = 1; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_flashAlpha - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._flashAlpha = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_follow - * @type {?any} - * @private - * @default null - * @since 3.0.0 - */ - this._follow = null; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_id - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - this._id = 0; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#centerToBounds - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - centerToBounds: function () + var name = key !== undefined ? key : 'map'; + mapData = Parse(name, Formats.ARRAY_2D, data, tileWidth, tileHeight, insertNull); + } + else if (key !== undefined) { - this.scrollX = (this._bounds.width * 0.5) - (this.width * 0.5); - this.scrollY = (this._bounds.height * 0.5) - (this.height * 0.5); + var tilemapData = scene.cache.tilemap.get(key); - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#centerToSize - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - centerToSize: function () - { - this.scrollX = this.width * 0.5; - this.scrollY = this.height * 0.5; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#cull - * @since 3.0.0 - * - * @param {array} renderableObjects - [description] - * - * @return {array} [description] - */ - cull: function (renderableObjects) - { - if (this.disableCull) + if (!tilemapData) { - return renderableObjects; - } - - var cameraMatrix = this.matrix.matrix; - - var mva = cameraMatrix[0]; - var mvb = cameraMatrix[1]; - var mvc = cameraMatrix[2]; - var mvd = cameraMatrix[3]; - - /* First Invert Matrix */ - var determinant = (mva * mvd) - (mvb * mvc); - - if (!determinant) - { - return renderableObjects; - } - - var mve = cameraMatrix[4]; - var mvf = cameraMatrix[5]; - - var scrollX = this.scrollX; - var scrollY = this.scrollY; - var cameraW = this.width; - var cameraH = this.height; - var culledObjects = this.culledObjects; - var length = renderableObjects.length; - - determinant = 1 / determinant; - - culledObjects.length = 0; - - for (var index = 0; index < length; ++index) - { - var object = renderableObjects[index]; - - if (!object.hasOwnProperty('width')) - { - culledObjects.push(object); - continue; - } - - var objectW = object.width; - var objectH = object.height; - var objectX = (object.x - (scrollX * object.scrollFactorX)) - (objectW * object.originX); - var objectY = (object.y - (scrollY * object.scrollFactorY)) - (objectH * object.originY); - var tx = (objectX * mva + objectY * mvc + mve); - var ty = (objectX * mvb + objectY * mvd + mvf); - var tw = ((objectX + objectW) * mva + (objectY + objectH) * mvc + mve); - var th = ((objectX + objectW) * mvb + (objectY + objectH) * mvd + mvf); - var cullW = cameraW + objectW; - var cullH = cameraH + objectH; - - if (tx > -objectW || ty > -objectH || tx < cullW || ty < cullH || - tw > -objectW || th > -objectH || tw < cullW || th < cullH) - { - culledObjects.push(object); - } - } - - return culledObjects; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#cullHitTest - * @since 3.0.0 - * - * @param {array} interactiveObjects - [description] - * - * @return {array} [description] - */ - cullHitTest: function (interactiveObjects) - { - if (this.disableCull) - { - return interactiveObjects; - } - - var cameraMatrix = this.matrix.matrix; - - var mva = cameraMatrix[0]; - var mvb = cameraMatrix[1]; - var mvc = cameraMatrix[2]; - var mvd = cameraMatrix[3]; - - /* First Invert Matrix */ - var determinant = (mva * mvd) - (mvb * mvc); - - if (!determinant) - { - return interactiveObjects; - } - - var mve = cameraMatrix[4]; - var mvf = cameraMatrix[5]; - - var scrollX = this.scrollX; - var scrollY = this.scrollY; - var cameraW = this.width; - var cameraH = this.height; - var length = interactiveObjects.length; - - determinant = 1 / determinant; - - var culledObjects = []; - - for (var index = 0; index < length; ++index) - { - var object = interactiveObjects[index].gameObject; - - if (!object.hasOwnProperty('width')) - { - culledObjects.push(interactiveObjects[index]); - continue; - } - - var objectW = object.width; - var objectH = object.height; - var objectX = (object.x - (scrollX * object.scrollFactorX)) - (objectW * object.originX); - var objectY = (object.y - (scrollY * object.scrollFactorY)) - (objectH * object.originY); - var tx = (objectX * mva + objectY * mvc + mve); - var ty = (objectX * mvb + objectY * mvd + mvf); - var tw = ((objectX + objectW) * mva + (objectY + objectH) * mvc + mve); - var th = ((objectX + objectW) * mvb + (objectY + objectH) * mvd + mvf); - var cullW = cameraW + objectW; - var cullH = cameraH + objectH; - - if (tx > -objectW || ty > -objectH || tx < cullW || ty < cullH || - tw > -objectW || th > -objectH || tw < cullW || th < cullH) - { - culledObjects.push(interactiveObjects[index]); - } - } - - return culledObjects; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#cullTilemap - * @since 3.0.0 - * - * @param {array} tilemap - [description] - * - * @return {array} [description] - */ - cullTilemap: function (tilemap) - { - var cameraMatrix = this.matrix.matrix; - - var mva = cameraMatrix[0]; - var mvb = cameraMatrix[1]; - var mvc = cameraMatrix[2]; - var mvd = cameraMatrix[3]; - - /* First Invert Matrix */ - var determinant = (mva * mvd) - (mvb * mvc); - - if (!determinant) - { - return tiles; - } - - var mve = cameraMatrix[4]; - var mvf = cameraMatrix[5]; - var tiles = tilemap.tiles; - var scrollX = this.scrollX; - var scrollY = this.scrollY; - var cameraW = this.width; - var cameraH = this.height; - var culledObjects = this.culledObjects; - var length = tiles.length; - var tileW = tilemap.tileWidth; - var tileH = tilemap.tileHeight; - var cullW = cameraW + tileW; - var cullH = cameraH + tileH; - var scrollFactorX = tilemap.scrollFactorX; - var scrollFactorY = tilemap.scrollFactorY; - - determinant = 1 / determinant; - - culledObjects.length = 0; - - for (var index = 0; index < length; ++index) - { - var tile = tiles[index]; - var tileX = (tile.x - (scrollX * scrollFactorX)); - var tileY = (tile.y - (scrollY * scrollFactorY)); - var tx = (tileX * mva + tileY * mvc + mve); - var ty = (tileX * mvb + tileY * mvd + mvf); - var tw = ((tileX + tileW) * mva + (tileY + tileH) * mvc + mve); - var th = ((tileX + tileW) * mvb + (tileY + tileH) * mvd + mvf); - - if (tx > -tileW && ty > -tileH && tw < cullW && th < cullH) - { - culledObjects.push(tile); - } - } - - return culledObjects; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#fade - * @since 3.0.0 - * - * @param {number} duration - [description] - * @param {number} red - [description] - * @param {number} green - [description] - * @param {number} blue - [description] - * @param {number} force - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - fade: function (duration, red, green, blue, force) - { - if (red === undefined) { red = 0; } - if (green === undefined) { green = 0; } - if (blue === undefined) { blue = 0; } - - if (!force && this._fadeAlpha > 0) - { - return this; - } - - this._fadeRed = red; - this._fadeGreen = green; - this._fadeBlue = blue; - - if (duration <= 0) - { - duration = Number.MIN_VALUE; - } - - this._fadeDuration = duration; - this._fadeAlpha = Number.MIN_VALUE; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#flash - * @since 3.0.0 - * - * @param {number} duration - [description] - * @param {number} red - [description] - * @param {number} green - [description] - * @param {number} blue - [description] - * @param {number} force - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - flash: function (duration, red, green, blue, force) - { - if (!force && this._flashAlpha > 0.0) - { - return this; - } - - if (red === undefined) { red = 1.0; } - if (green === undefined) { green = 1.0; } - if (blue === undefined) { blue = 1.0; } - - this._flashRed = red; - this._flashGreen = green; - this._flashBlue = blue; - - if (duration <= 0) - { - duration = Number.MIN_VALUE; - } - - this._flashDuration = duration; - this._flashAlpha = 1.0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#getWorldPoint - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {object|Phaser.Math.Vector2} output - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - getWorldPoint: function (x, y, output) - { - if (output === undefined) { output = new Vector2(); } - - var cameraMatrix = this.matrix.matrix; - - var mva = cameraMatrix[0]; - var mvb = cameraMatrix[1]; - var mvc = cameraMatrix[2]; - var mvd = cameraMatrix[3]; - var mve = cameraMatrix[4]; - var mvf = cameraMatrix[5]; - - /* First Invert Matrix */ - var determinant = (mva * mvd) - (mvb * mvc); - - if (!determinant) - { - output.x = x; - output.y = y; - - return output; - } - - determinant = 1 / determinant; - - var ima = mvd * determinant; - var imb = -mvb * determinant; - var imc = -mvc * determinant; - var imd = mva * determinant; - var ime = (mvc * mvf - mvd * mve) * determinant; - var imf = (mvb * mve - mva * mvf) * determinant; - - var c = Math.cos(this.rotation); - var s = Math.sin(this.rotation); - - var zoom = this.zoom; - - var scrollX = this.scrollX; - var scrollY = this.scrollY; - - var sx = x + ((scrollX * c - scrollY * s) * zoom); - var sy = y + ((scrollX * s + scrollY * c) * zoom); - - /* Apply transform to point */ - output.x = (sx * ima + sy * imc + ime); - output.y = (sx * imb + sy * imd + imf); - - return output; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#ignore - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} gameObjectOrArray - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - ignore: function (gameObjectOrArray) - { - if (gameObjectOrArray instanceof Array) - { - for (var index = 0; index < gameObjectOrArray.length; ++index) - { - gameObjectOrArray[index].cameraFilter |= this._id; - } + console.warn('No map data found for key ' + key); } else { - gameObjectOrArray.cameraFilter |= this._id; + mapData = Parse(key, tilemapData.format, tilemapData.data, tileWidth, tileHeight, insertNull); } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#preRender - * @since 3.0.0 - * - * @param {number} baseScale - [description] - * @param {number} resolution - [description] - * - */ - preRender: function (baseScale, resolution) - { - var width = this.width; - var height = this.height; - var zoom = this.zoom * baseScale; - var matrix = this.matrix; - var originX = width / 2; - var originY = height / 2; - var follow = this._follow; - - if (follow !== null) - { - originX = follow.x; - originY = follow.y; - - this.scrollX = (originX - width * 0.5) / zoom; - this.scrollY = (originY - height * 0.5) / zoom; - } - - if (this.useBounds) - { - var bounds = this._bounds; - - var bw = Math.max(0, bounds.right - width); - var bh = Math.max(0, bounds.bottom - height); - - if (this.scrollX < bounds.x) - { - this.scrollX = bounds.x; - } - else if (this.scrollX > bw) - { - this.scrollX = bw; - } - - if (this.scrollY < bounds.y) - { - this.scrollY = bounds.y; - } - else if (this.scrollY > bh) - { - this.scrollY = bh; - } - } - - if (this.roundPixels) - { - this.scrollX = Math.round(this.scrollX); - this.scrollY = Math.round(this.scrollY); - } - - matrix.loadIdentity(); - matrix.scale(resolution, resolution); - matrix.translate(this.x + originX, this.y + originY); - matrix.rotate(this.rotation); - matrix.scale(zoom, zoom); - matrix.translate(-originX, -originY); - matrix.translate(this._shakeOffsetX, this._shakeOffsetY); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#removeBounds - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - removeBounds: function () - { - this.useBounds = false; - - this._bounds.setEmpty(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setAngle - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setAngle: function (value) - { - if (value === undefined) { value = 0; } - - this.rotation = DegToRad(value); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setBackgroundColor - * @since 3.0.0 - * - * @param {integer} color - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setBackgroundColor: function (color) - { - if (color === undefined) { color = 'rgba(0,0,0,0)'; } - - this.backgroundColor = ValueToColor(color); - - this.transparent = (this.backgroundColor.alpha === 0); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setBounds - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setBounds: function (x, y, width, height) - { - this._bounds.setTo(x, y, width, height); - - this.useBounds = true; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setName - * @since 3.0.0 - * - * @param {string} value - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setName: function (value) - { - if (value === undefined) { value = ''; } - - this.name = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setPosition - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setPosition: function (x, y) - { - if (y === undefined) { y = x; } - - this.x = x; - this.y = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setRotation - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setRotation: function (value) - { - if (value === undefined) { value = 0; } - - this.rotation = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setRoundPixels - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setRoundPixels: function (value) - { - this.roundPixels = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setScene - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setScene: function (scene) - { - this.scene = scene; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setScroll - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setScroll: function (x, y) - { - if (y === undefined) { y = x; } - - this.scrollX = x; - this.scrollY = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setSize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setSize: function (width, height) - { - if (height === undefined) { height = width; } - - this.width = width; - this.height = height; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setViewport - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setViewport: function (x, y, width, height) - { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setZoom - * @since 3.0.0 - * - * @param {float} value - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setZoom: function (value) - { - if (value === undefined) { value = 1; } - - this.zoom = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#shake - * @since 3.0.0 - * - * @param {number} duration - [description] - * @param {number} intensity - [description] - * @param {number} force - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - shake: function (duration, intensity, force) - { - if (intensity === undefined) { intensity = 0.05; } - - if (!force && (this._shakeOffsetX !== 0 || this._shakeOffsetY !== 0)) - { - return this; - } - - this._shakeDuration = duration; - this._shakeIntensity = intensity; - this._shakeOffsetX = 0; - this._shakeOffsetY = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#startFollow - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject|object} gameObjectOrPoint - [description] - * @param {boolean} roundPx - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - startFollow: function (gameObjectOrPoint, roundPx) - { - this._follow = gameObjectOrPoint; - - if (roundPx !== undefined) - { - this.roundPixels = roundPx; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#stopFollow - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - stopFollow: function () - { - this._follow = null; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - var output = { - name: this.name, - x: this.x, - y: this.y, - width: this.width, - height: this.height, - zoom: this.zoom, - rotation: this.rotation, - roundPixels: this.roundPixels, - scrollX: this.scrollX, - scrollY: this.scrollY, - backgroundColor: this.backgroundColor.rgba - }; - - if (this.useBounds) - { - output['bounds'] = { - x: this._bounds.x, - y: this._bounds.y, - width: this._bounds.width, - height: this._bounds.height - }; - } - - return output; - }, - - /** - * Resets any active FX, such as a fade, flash or shake. Useful to call after a fade in order to - * remove the fade. - * - * @method Phaser.Cameras.Scene2D.Camera#resetFX - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - resetFX: function () - { - this._flashAlpha = 0; - this._fadeAlpha = 0; - this._shakeOffsetX = 0.0; - this._shakeOffsetY = 0.0; - this._shakeDuration = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#update - * @since 3.0.0 - * - * @param {[type]} timestep - [description] - * @param {[type]} delta - [description] - */ - update: function (timestep, delta) - { - if (this._flashAlpha > 0.0) - { - this._flashAlpha -= delta / this._flashDuration; - - if (this._flashAlpha < 0.0) - { - this._flashAlpha = 0.0; - } - } - - if (this._fadeAlpha > 0.0 && this._fadeAlpha < 1.0) - { - this._fadeAlpha += delta / this._fadeDuration; - - if (this._fadeAlpha >= 1.0) - { - this._fadeAlpha = 1.0; - } - } - - if (this._shakeDuration > 0.0) - { - var intensity = this._shakeIntensity; - - this._shakeDuration -= delta; - - if (this._shakeDuration <= 0.0) - { - this._shakeOffsetX = 0.0; - this._shakeOffsetY = 0.0; - } - else - { - this._shakeOffsetX = (Math.random() * intensity * this.width * 2 - intensity * this.width) * this.zoom; - this._shakeOffsetY = (Math.random() * intensity * this.height * 2 - intensity * this.height) * this.zoom; - - if (this.roundPixels) - { - this._shakeOffsetX |= 0; - this._shakeOffsetY |= 0; - } - } - } - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#destroy - * @since 3.0.0 - */ - destroy: function () - { - this._bounds = undefined; - this.matrix = undefined; - this.culledObjects = []; - this.scene = undefined; } -}); + if (mapData === null) + { + mapData = new MapData({ + tileWidth: tileWidth, + tileHeight: tileHeight, + width: width, + height: height + }); + } -module.exports = Camera; + return new Tilemap(scene, mapData); +}; + +module.exports = ParseToTilemap; /***/ }), @@ -19239,50 +19982,86 @@ module.exports = Camera; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var HexStringToColor = __webpack_require__(203); -var IntegerToColor = __webpack_require__(205); -var ObjectToColor = __webpack_require__(207); -var RGBStringToColor = __webpack_require__(208); +var Formats = __webpack_require__(24); +var LayerData = __webpack_require__(66); +var MapData = __webpack_require__(65); +var Tile = __webpack_require__(45); /** - * Converts the given source color value into an instance of a Color class. - * The value can be either a string, prefixed with `rgb` or a hex string, a number or an Object. + * Parses a 2D array of tile indexes into a new MapData object with a single layer. * - * @function Phaser.Display.Color.ValueToColor + * @function Phaser.Tilemaps.Parsers.Parse2DArray * @since 3.0.0 * - * @param {string|number|object} input - The source color value to convert. + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {integer[][]} data - 2D array, CSV string or Tiled JSON object. + * @param {integer} tileWidth - The width of a tile in pixels. + * @param {integer} tileHeight - The height of a tile in pixels. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. * - * @return {Phaser.Display.Color} A Color object. + * @return {Phaser.Tilemaps.MapData} [description] */ -var ValueToColor = function (input) +var Parse2DArray = function (name, data, tileWidth, tileHeight, insertNull) { - var t = typeof input; + var layerData = new LayerData({ + tileWidth: tileWidth, + tileHeight: tileHeight + }); - switch (t) + var mapData = new MapData({ + name: name, + tileWidth: tileWidth, + tileHeight: tileHeight, + format: Formats.ARRAY_2D, + layers: [ layerData ] + }); + + var tiles = []; + var height = data.length; + var width = 0; + + for (var y = 0; y < data.length; y++) { - case 'string': + tiles[y] = []; + var row = data[y]; - if (input.substr(0, 3).toLowerCase() === 'rgb') + for (var x = 0; x < row.length; x++) + { + var tileIndex = parseInt(row[x], 10); + + if (Number.isNaN(tileIndex) || tileIndex === -1) { - return RGBStringToColor(input); + tiles[y][x] = insertNull + ? null + : new Tile(layerData, -1, x, y, tileWidth, tileHeight); } else { - return HexStringToColor(input); + tiles[y][x] = new Tile(layerData, tileIndex, x, y, tileWidth, tileHeight); } + } - case 'number': - - return IntegerToColor(input); - - case 'object': - - return ObjectToColor(input); + if (width === 0) + { + width = row.length; + } } + + mapData.width = layerData.width = width; + mapData.height = layerData.height = height; + mapData.widthInPixels = layerData.widthInPixels = width * tileWidth; + mapData.heightInPixels = layerData.heightInPixels = height * tileHeight; + layerData.data = tiles; + + return mapData; }; -module.exports = ValueToColor; +module.exports = Parse2DArray; /***/ }), @@ -19296,23 +20075,31 @@ module.exports = ValueToColor; */ /** - * Given 3 separate color values this will return an integer representation of it. + * Internally used method to keep track of the tile indexes that collide within a layer. This + * updates LayerData.collideIndexes to either contain or not contain the given `tileIndex`. * - * @function Phaser.Display.Color.GetColor + * @function Phaser.Tilemaps.Components.SetLayerCollisionIndex * @since 3.0.0 * - * @param {integer} red - The red color value. A number between 0 and 255. - * @param {integer} green - The green color value. A number between 0 and 255. - * @param {integer} blue - The blue color value. A number between 0 and 255. - * - * @return {number} The combined color value. + * @param {integer} tileIndex - [description] + * @param {boolean} [collides=true] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. */ -var GetColor = function (red, green, blue) +var SetLayerCollisionIndex = function (tileIndex, collides, layer) { - return red << 16 | green << 8 | blue; + var loc = layer.collideIndexes.indexOf(tileIndex); + + if (collides && loc === -1) + { + layer.collideIndexes.push(tileIndex); + } + else if (!collides && loc !== -1) + { + layer.collideIndexes.splice(loc, 1); + } }; -module.exports = GetColor; +module.exports = SetLayerCollisionIndex; /***/ }), @@ -19325,1062 +20112,73 @@ module.exports = GetColor; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Matrix4 = __webpack_require__(119); -var RandomXYZ = __webpack_require__(209); -var RandomXYZW = __webpack_require__(210); -var RotateVec3 = __webpack_require__(211); -var Set = __webpack_require__(62); -var Sprite3D = __webpack_require__(81); -var Vector2 = __webpack_require__(6); -var Vector3 = __webpack_require__(51); -var Vector4 = __webpack_require__(120); - -// Local cache vars -var tmpVec3 = new Vector3(); -var tmpVec4 = new Vector4(); -var dirvec = new Vector3(); -var rightvec = new Vector3(); -var billboardMatrix = new Matrix4(); - -// @author attribute https://github.com/mattdesl/cam3d/wiki +var Tile = __webpack_require__(45); +var IsInLayerBounds = __webpack_require__(67); +var CalculateFacesAt = __webpack_require__(119); +var SetTileCollision = __webpack_require__(46); /** - * @classdesc - * [description] + * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index + * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified + * location. If you pass in an index, only the index at the specified location will be changed. + * Collision information will be recalculated at the specified location. * - * @class Camera - * @memberOf Phaser.Cameras.Sprite3D - * @constructor + * @function Phaser.Tilemaps.Components.PutTileAt * @since 3.0.0 * - * @param {Phaser.Scene} scene - [description] + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map. */ -var Camera = new Class({ +var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer) +{ + if (!IsInLayerBounds(tileX, tileY, layer)) { return null; } + if (recalculateFaces === undefined) { recalculateFaces = true; } - initialize: + var oldTile = layer.data[tileY][tileX]; + var oldTileCollides = oldTile && oldTile.collides; - function Camera (scene) + if (tile instanceof Tile) { - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#displayList - * @type {Phaser.GameObjects.DisplayList} - * @since 3.0.0 - */ - this.displayList = scene.sys.displayList; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#updateList - * @type {Phaser.GameObjects.UpdateList} - * @since 3.0.0 - */ - this.updateList = scene.sys.updateList; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#name - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.name = ''; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#direction - * @type {Phaser.Math.Vector3} - * @since 3.0.0 - */ - this.direction = new Vector3(0, 0, -1); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#up - * @type {Phaser.Math.Vector3} - * @since 3.0.0 - */ - this.up = new Vector3(0, 1, 0); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#position - * @type {Phaser.Math.Vector3} - * @since 3.0.0 - */ - this.position = new Vector3(); - - // The mapping from 3D size units to pixels. - // In the default case 1 3D unit = 128 pixels. So a sprite that is - // 256 x 128 px in size will be 2 x 1 units. - // Change to whatever best fits your game assets. - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#pixelScale - * @type {number} - * @since 3.0.0 - */ - this.pixelScale = 128; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#projection - * @type {Phaser.Math.Matrix4} - * @since 3.0.0 - */ - this.projection = new Matrix4(); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#view - * @type {Phaser.Math.Matrix4} - * @since 3.0.0 - */ - this.view = new Matrix4(); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#combined - * @type {Phaser.Math.Matrix4} - * @since 3.0.0 - */ - this.combined = new Matrix4(); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#invProjectionView - * @type {Phaser.Math.Matrix4} - * @since 3.0.0 - */ - this.invProjectionView = new Matrix4(); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#near - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.near = 1; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#far - * @type {number} - * @since 3.0.0 - */ - this.far = 100; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#ray - * @type {[type]} - * @since 3.0.0 - */ - this.ray = { - origin: new Vector3(), - direction: new Vector3() - }; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#viewportWidth - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.viewportWidth = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#viewportHeight - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.viewportHeight = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#billboardMatrixDirty - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.billboardMatrixDirty = true; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#children - * @type {Phaser.Structs.Set} - * @since 3.0.0 - */ - this.children = new Set(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setPosition - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} z - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setPosition: function (x, y, z) - { - this.position.set(x, y, z); - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setScene - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setScene: function (scene) - { - this.scene = scene; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setPixelScale - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setPixelScale: function (value) - { - this.pixelScale = value; - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#add - * @since 3.0.0 - * - * @param {[type]} sprite3D - [description] - * - * @return {[type]} [description] - */ - add: function (sprite3D) - { - this.children.set(sprite3D); - - this.updateChildren(); - - return sprite3D; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#remove - * @since 3.0.0 - * - * @param {[type]} child - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - remove: function (child) - { - this.displayList.remove(child.gameObject); - this.updateList.remove(child.gameObject); - - this.children.delete(child); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#clear - * @since 3.0.0 - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - clear: function () - { - var children = this.getChildren(); - - for (var i = 0; i < children.length; i++) + if (layer.data[tileY][tileX] === null) { - this.remove(children[i]); + layer.data[tileY][tileX] = new Tile(layer, tile.index, tileX, tileY, tile.width, tile.height); } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#getChildren - * @since 3.0.0 - * - * @return {array} [description] - */ - getChildren: function () + layer.data[tileY][tileX].copy(tile); + } + else { - return this.children.entries; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#create - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} z - [description] - * @param {[type]} key - [description] - * @param {[type]} frame - [description] - * @param {[type]} visible - [description] - * - * @return {[type]} [description] - */ - create: function (x, y, z, key, frame, visible) - { - if (visible === undefined) { visible = true; } - - var child = new Sprite3D(this.scene, x, y, z, key, frame); - - this.displayList.add(child.gameObject); - this.updateList.add(child.gameObject); - - child.visible = visible; - - this.children.set(child); - - this.updateChildren(); - - return child; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#createMultiple - * @since 3.0.0 - * - * @param {[type]} quantity - [description] - * @param {[type]} key - [description] - * @param {[type]} frame - [description] - * @param {[type]} visible - [description] - * - * @return {[type]} [description] - */ - createMultiple: function (quantity, key, frame, visible) - { - if (visible === undefined) { visible = true; } - - var output = []; - - for (var i = 0; i < quantity; i++) + var index = tile; + if (layer.data[tileY][tileX] === null) { - var child = new Sprite3D(this.scene, 0, 0, 0, key, frame); - - this.displayList.add(child.gameObject); - this.updateList.add(child.gameObject); - - child.visible = visible; - - this.children.set(child); - - output.push(child); - } - - return output; - }, - - // Create a bunch of Sprite3D objects in a rectangle - // size and spacing are Vec3s (or if integers are converted to vec3s) - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#createRect - * @since 3.0.0 - * - * @param {[type]} size - [description] - * @param {[type]} spacing - [description] - * @param {[type]} key - [description] - * @param {[type]} frame - [description] - * - * @return {[type]} [description] - */ - createRect: function (size, spacing, key, frame) - { - if (typeof size === 'number') { size = { x: size, y: size, z: size }; } - if (typeof spacing === 'number') { spacing = { x: spacing, y: spacing, z: spacing }; } - - var quantity = size.x * size.y * size.z; - - var sprites = this.createMultiple(quantity, key, frame); - - var i = 0; - - for (var z = 0.5 - (size.z / 2); z < (size.z / 2); z++) - { - for (var y = 0.5 - (size.y / 2); y < (size.y / 2); y++) - { - for (var x = 0.5 - (size.x / 2); x < (size.x / 2); x++) - { - var bx = (x * spacing.x); - var by = (y * spacing.y); - var bz = (z * spacing.z); - - sprites[i].position.set(bx, by, bz); - - i++; - } - } - } - - this.update(); - - return sprites; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#randomSphere - * @since 3.0.0 - * - * @param {[type]} radius - [description] - * @param {[type]} sprites - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - randomSphere: function (radius, sprites) - { - if (sprites === undefined) { sprites = this.getChildren(); } - - for (var i = 0; i < sprites.length; i++) - { - RandomXYZ(sprites[i].position, radius); - } - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#randomCube - * @since 3.0.0 - * - * @param {[type]} scale - [description] - * @param {[type]} sprites - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - randomCube: function (scale, sprites) - { - if (sprites === undefined) { sprites = this.getChildren(); } - - for (var i = 0; i < sprites.length; i++) - { - RandomXYZW(sprites[i].position, scale); - } - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#translateChildren - * @since 3.0.0 - * - * @param {[type]} vec3 - [description] - * @param {[type]} sprites - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - translateChildren: function (vec3, sprites) - { - if (sprites === undefined) { sprites = this.getChildren(); } - - for (var i = 0; i < sprites.length; i++) - { - sprites[i].position.add(vec3); - } - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#transformChildren - * @since 3.0.0 - * - * @param {[type]} mat4 - [description] - * @param {[type]} sprites - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - transformChildren: function (mat4, sprites) - { - if (sprites === undefined) { sprites = this.getChildren(); } - - for (var i = 0; i < sprites.length; i++) - { - sprites[i].position.transformMat4(mat4); - } - - return this.update(); - }, - - /** - * Sets the width and height of the viewport. Does not update any matrices. - * - * @method Phaser.Cameras.Sprite3D.Camera#setViewport - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setViewport: function (width, height) - { - this.viewportWidth = width; - this.viewportHeight = height; - - return this.update(); - }, - - /** - * Translates this camera by a specified Vector3 object - * or x, y, z parameters. Any undefined x y z values will - * default to zero, leaving that component unaffected. - * If you wish to set the camera position directly call setPosition instead. - * - * @method Phaser.Cameras.Sprite3D.Camera#translate - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} z - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - translate: function (x, y, z) - { - if (typeof x === 'object') - { - this.position.x += x.x || 0; - this.position.y += x.y || 0; - this.position.z += x.z || 0; + layer.data[tileY][tileX] = new Tile(layer, index, tileX, tileY, layer.tileWidth, layer.tileHeight); } else { - this.position.x += x || 0; - this.position.y += y || 0; - this.position.z += z || 0; - } - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#lookAt - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} z - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - lookAt: function (x, y, z) - { - var dir = this.direction; - var up = this.up; - - if (typeof x === 'object') - { - dir.copy(x); - } - else - { - dir.set(x, y, z); - } - - dir.subtract(this.position).normalize(); - - // Calculate right vector - tmpVec3.copy(dir).cross(up).normalize(); - - // Calculate up vector - up.copy(tmpVec3).cross(dir).normalize(); - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#rotate - * @since 3.0.0 - * - * @param {[type]} radians - [description] - * @param {[type]} axis - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - rotate: function (radians, axis) - { - RotateVec3(this.direction, axis, radians); - RotateVec3(this.up, axis, radians); - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#rotateAround - * @since 3.0.0 - * - * @param {[type]} point - [description] - * @param {[type]} radians - [description] - * @param {[type]} axis - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - rotateAround: function (point, radians, axis) - { - tmpVec3.copy(point).subtract(this.position); - - this.translate(tmpVec3); - this.rotate(radians, axis); - this.translate(tmpVec3.negate()); - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#project - * @since 3.0.0 - * - * @param {[type]} vec - [description] - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - project: function (vec, out) - { - if (out === undefined) { out = new Vector4(); } - - // TODO: support viewport XY - var viewportWidth = this.viewportWidth; - var viewportHeight = this.viewportHeight; - var n = Camera.NEAR_RANGE; - var f = Camera.FAR_RANGE; - - // For useful Z and W values we should do the usual steps: clip space -> NDC -> window coords - - // Implicit 1.0 for w component - tmpVec4.set(vec.x, vec.y, vec.z, 1.0); - - // Transform into clip space - tmpVec4.transformMat4(this.combined); - - // Avoid divide by zero when 0x0x0 camera projects to a 0x0x0 vec3 - if (tmpVec4.w === 0) - { - tmpVec4.w = 1; - } - - // Now into NDC - tmpVec4.x = tmpVec4.x / tmpVec4.w; - tmpVec4.y = tmpVec4.y / tmpVec4.w; - tmpVec4.z = tmpVec4.z / tmpVec4.w; - - // And finally into window coordinates - out.x = viewportWidth / 2 * tmpVec4.x + (0 + viewportWidth / 2); - out.y = viewportHeight / 2 * tmpVec4.y + (0 + viewportHeight / 2); - out.z = (f - n) / 2 * tmpVec4.z + (f + n) / 2; - - // If the out vector has a fourth component, we also store (1/clip.w), same idea as gl_FragCoord.w - if (out.w === 0 || out.w) - { - out.w = 1 / tmpVec4.w; - } - - return out; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#unproject - * @since 3.0.0 - * - * @param {[type]} vec - [description] - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - unproject: function (vec, out) - { - if (out === undefined) { out = new Vector3(); } - - var viewport = tmpVec4.set(0, 0, this.viewportWidth, this.viewportHeight); - - return out.copy(vec).unproject(viewport, this.invProjectionView); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#getPickRay - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - getPickRay: function (x, y) - { - var origin = this.ray.origin.set(x, y, 0); - var direction = this.ray.direction.set(x, y, 1); - var viewport = tmpVec4.set(0, 0, this.viewportWidth, this.viewportHeight); - var mtx = this.invProjectionView; - - origin.unproject(viewport, mtx); - - direction.unproject(viewport, mtx); - - direction.subtract(origin).normalize(); - - return this.ray; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#updateChildren - * @since 3.0.0 - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - updateChildren: function () - { - var children = this.children.entries; - - for (var i = 0; i < children.length; i++) - { - children[i].project(this); - } - - return this; - }, - - // Overriden by subclasses - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#update - * @since 3.0.0 - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - update: function () - { - return this.updateChildren(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#updateBillboardMatrix - * @since 3.0.0 - */ - updateBillboardMatrix: function () - { - var dir = dirvec.set(this.direction).negate(); - - // Better view-aligned billboards might use this: - // var dir = tmp.set(camera.position).subtract(p).normalize(); - - var right = rightvec.set(this.up).cross(dir).normalize(); - var up = tmpVec3.set(dir).cross(right).normalize(); - - var out = billboardMatrix.val; - - out[0] = right.x; - out[1] = right.y; - out[2] = right.z; - out[3] = 0; - - out[4] = up.x; - out[5] = up.y; - out[6] = up.z; - out[7] = 0; - - out[8] = dir.x; - out[9] = dir.y; - out[10] = dir.z; - out[11] = 0; - - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - - this.billboardMatrixDirty = false; - }, - - /** - * This is a utility function for canvas 3D rendering, - * which determines the "point size" of a camera-facing - * sprite billboard given its 3D world position - * (origin at center of sprite) and its world width - * and height in x/y. - * - * We place into the output Vector2 the scaled width - * and height. If no `out` is specified, a new Vector2 - * will be created for convenience (this should be avoided - * in tight loops). - * - * @method Phaser.Cameras.Sprite3D.Camera#getPointSize - * @since 3.0.0 - * - * @param {[type]} vec - The position of the 3D Sprite. - * @param {[type]} size - The x and y dimensions. - * @param {[type]} out - The result, scaled x and y dimensions. - * - * @return {[type]} [description] - */ - getPointSize: function (vec, size, out) - { - if (out === undefined) { out = new Vector2(); } - - // TODO: optimize this with a simple distance calculation: - // https://developer.valvesoftware.com/wiki/Field_of_View - - if (this.billboardMatrixDirty) - { - this.updateBillboardMatrix(); - } - - var tmp = tmpVec3; - - var dx = (size.x / this.pixelScale) / 2; - var dy = (size.y / this.pixelScale) / 2; - - tmp.set(-dx, -dy, 0).transformMat4(billboardMatrix).add(vec); - - this.project(tmp, tmp); - - var tlx = tmp.x; - var tly = tmp.y; - - tmp.set(dx, dy, 0).transformMat4(billboardMatrix).add(vec); - - this.project(tmp, tmp); - - var brx = tmp.x; - var bry = tmp.y; - - // var w = Math.abs(brx - tlx); - // var h = Math.abs(bry - tly); - - // Allow the projection to get negative ... - var w = brx - tlx; - var h = bry - tly; - - return out.set(w, h); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.children.clear(); - - this.scene = undefined; - this.children = undefined; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setX - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setX: function (value) - { - this.position.x = value; - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setY - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setY: function (value) - { - this.position.y = value; - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setZ - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setZ: function (value) - { - this.position.z = value; - - return this.update(); - }, - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.Camera#x - * @type {number} - * @since 3.0.0 - */ - x: { - get: function () - { - return this.position.x; - }, - - set: function (value) - { - this.position.x = value; - this.update(); - } - }, - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.Camera#y - * @type {number} - * @since 3.0.0 - */ - y: { - get: function () - { - return this.position.y; - }, - - set: function (value) - { - this.position.y = value; - this.update(); - } - }, - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.Camera#z - * @type {number} - * @since 3.0.0 - */ - z: { - get: function () - { - return this.position.z; - }, - - set: function (value) - { - this.position.z = value; - this.update(); + layer.data[tileY][tileX].index = index; } } -}); + // Updating colliding flag on the new tile + var newTile = layer.data[tileY][tileX]; + var collides = layer.collideIndexes.indexOf(newTile.index) !== -1; + SetTileCollision(newTile, collides); -Camera.FAR_RANGE = 1.0; -Camera.NEAR_RANGE = 0.0; + // Recalculate faces only if the colliding flag at (tileX, tileY) has changed + if (recalculateFaces && (oldTileCollides !== newTile.collides)) + { + CalculateFacesAt(tileX, tileY, layer); + } + + return newTile; +}; + +module.exports = PutTileAt; -module.exports = Camera; /***/ }), @@ -20393,1439 +20191,74 @@ module.exports = Camera; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji -// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl - -var Class = __webpack_require__(0); - -var EPSILON = 0.000001; +var GetTileAt = __webpack_require__(87); /** - * @classdesc - * [description] + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. * - * @class Matrix4 - * @memberOf Phaser.Math - * @constructor + * @function Phaser.Tilemaps.Components.CalculateFacesAt * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} [m] - [description] + * + * @param {integer} tileX - The x coordinate. + * @param {integer} tileY - The y coordinate. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. */ -var Matrix4 = new Class({ +var CalculateFacesAt = function (tileX, tileY, layer) +{ + var tile = GetTileAt(tileX, tileY, true, layer); + var above = GetTileAt(tileX, tileY - 1, true, layer); + var below = GetTileAt(tileX, tileY + 1, true, layer); + var left = GetTileAt(tileX - 1, tileY, true, layer); + var right = GetTileAt(tileX + 1, tileY, true, layer); + var tileCollides = tile && tile.collides; - initialize: - - function Matrix4 (m) + // Assume the changed tile has all interesting edges + if (tileCollides) { - /** - * [description] - * - * @name Phaser.Math.Matrix4#val - * @type {Float32Array} - * @since 3.0.0 - */ - this.val = new Float32Array(16); - - if (m) - { - // Assume Matrix4 with val: - this.copy(m); - } - else - { - // Default to identity - this.identity(); - } - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#clone - * @since 3.0.0 - * - * @return {[type]} [description] - */ - clone: function () - { - return new Matrix4(this); - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#set - * @since 3.0.0 - * - * @param {[type]} src - [description] - * - * @return {[type]} [description] - */ - set: function (src) - { - return this.copy(src); - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#copy - * @since 3.0.0 - * - * @param {[type]} src - [description] - * - * @return {[type]} [description] - */ - copy: function (src) - { - var out = this.val; - var a = src.val; - - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - out[9] = a[9]; - out[10] = a[10]; - out[11] = a[11]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#fromArray - * @since 3.0.0 - * - * @param {[type]} a - [description] - * - * @return {[type]} [description] - */ - fromArray: function (a) - { - var out = this.val; - - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - out[9] = a[9]; - out[10] = a[10]; - out[11] = a[11]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#zero - * @since 3.0.0 - * - * @return {[type]} [description] - */ - zero: function () - { - var out = this.val; - - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = 0; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = 0; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#xyz - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} z - [description] - * - * @return {[type]} [description] - */ - xyz: function (x, y, z) - { - this.identity(); - - var out = this.val; - - out[12] = x; - out[13] = y; - out[14] = z; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#scaling - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} z - [description] - * - * @return {[type]} [description] - */ - scaling: function (x, y, z) - { - this.zero(); - - var out = this.val; - - out[0] = x; - out[5] = y; - out[10] = z; - out[15] = 1; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#identity - * @since 3.0.0 - * - * @return {[type]} [description] - */ - identity: function () - { - var out = this.val; - - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = 1; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = 1; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#transpose - * @since 3.0.0 - * - * @return {[type]} [description] - */ - transpose: function () - { - var a = this.val; - - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - var a12 = a[6]; - var a13 = a[7]; - var a23 = a[11]; - - a[1] = a[4]; - a[2] = a[8]; - a[3] = a[12]; - a[4] = a01; - a[6] = a[9]; - a[7] = a[13]; - a[8] = a02; - a[9] = a12; - a[11] = a[14]; - a[12] = a03; - a[13] = a13; - a[14] = a23; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#invert - * @since 3.0.0 - * - * @return {[type]} [description] - */ - invert: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - var a30 = a[12]; - var a31 = a[13]; - var a32 = a[14]; - var a33 = a[15]; - - var b00 = a00 * a11 - a01 * a10; - var b01 = a00 * a12 - a02 * a10; - var b02 = a00 * a13 - a03 * a10; - var b03 = a01 * a12 - a02 * a11; - - var b04 = a01 * a13 - a03 * a11; - var b05 = a02 * a13 - a03 * a12; - var b06 = a20 * a31 - a21 * a30; - var b07 = a20 * a32 - a22 * a30; - - var b08 = a20 * a33 - a23 * a30; - var b09 = a21 * a32 - a22 * a31; - var b10 = a21 * a33 - a23 * a31; - var b11 = a22 * a33 - a23 * a32; - - - // Calculate the determinant - var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; - - if (!det) - { - return null; - } - - det = 1 / det; - - a[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; - a[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; - a[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; - a[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; - a[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; - a[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; - a[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; - a[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; - a[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; - a[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; - a[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; - a[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; - a[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; - a[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; - a[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; - a[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#adjoint - * @since 3.0.0 - * - * @return {[type]} [description] - */ - adjoint: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - var a30 = a[12]; - var a31 = a[13]; - var a32 = a[14]; - var a33 = a[15]; - - a[0] = (a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22)); - a[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22)); - a[2] = (a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12)); - a[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12)); - a[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22)); - a[5] = (a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22)); - a[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12)); - a[7] = (a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12)); - a[8] = (a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21)); - a[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21)); - a[10] = (a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11)); - a[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11)); - a[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21)); - a[13] = (a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21)); - a[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11)); - a[15] = (a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11)); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#determinant - * @since 3.0.0 - * - * @return {[type]} [description] - */ - determinant: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - var a30 = a[12]; - var a31 = a[13]; - var a32 = a[14]; - var a33 = a[15]; - - var b00 = a00 * a11 - a01 * a10; - var b01 = a00 * a12 - a02 * a10; - var b02 = a00 * a13 - a03 * a10; - var b03 = a01 * a12 - a02 * a11; - var b04 = a01 * a13 - a03 * a11; - var b05 = a02 * a13 - a03 * a12; - var b06 = a20 * a31 - a21 * a30; - var b07 = a20 * a32 - a22 * a30; - var b08 = a20 * a33 - a23 * a30; - var b09 = a21 * a32 - a22 * a31; - var b10 = a21 * a33 - a23 * a31; - var b11 = a22 * a33 - a23 * a32; - - // Calculate the determinant - return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#multiply - * @since 3.0.0 - * - * @param {[type]} src - [description] - * - * @return {[type]} [description] - */ - multiply: function (src) - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - var a30 = a[12]; - var a31 = a[13]; - var a32 = a[14]; - var a33 = a[15]; - - var b = src.val; - - // Cache only the current line of the second matrix - var b0 = b[0]; - var b1 = b[1]; - var b2 = b[2]; - var b3 = b[3]; - - a[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - a[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - a[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - a[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - - b0 = b[4]; - b1 = b[5]; - b2 = b[6]; - b3 = b[7]; - - a[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - a[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - a[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - a[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - - b0 = b[8]; - b1 = b[9]; - b2 = b[10]; - b3 = b[11]; - - a[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - a[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - a[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - a[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - - b0 = b[12]; - b1 = b[13]; - b2 = b[14]; - b3 = b[15]; - - a[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - a[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - a[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - a[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#multiplyLocal - * @since 3.0.0 - * - * @param {[type]} src - [description] - * - * @return {[type]} [description] - */ - multiplyLocal: function (src) - { - var a = []; - var m1 = this.val; - var m2 = src.val; - - a[0] = m1[0] * m2[0] + m1[1] * m2[4] + m1[2] * m2[8] + m1[3] * m2[12]; - a[1] = m1[0] * m2[1] + m1[1] * m2[5] + m1[2] * m2[9] + m1[3] * m2[13]; - a[2] = m1[0] * m2[2] + m1[1] * m2[6] + m1[2] * m2[10] + m1[3] * m2[14]; - a[3] = m1[0] * m2[3] + m1[1] * m2[7] + m1[2] * m2[11] + m1[3] * m2[15]; - - a[4] = m1[4] * m2[0] + m1[5] * m2[4] + m1[6] * m2[8] + m1[7] * m2[12]; - a[5] = m1[4] * m2[1] + m1[5] * m2[5] + m1[6] * m2[9] + m1[7] * m2[13]; - a[6] = m1[4] * m2[2] + m1[5] * m2[6] + m1[6] * m2[10] + m1[7] * m2[14]; - a[7] = m1[4] * m2[3] + m1[5] * m2[7] + m1[6] * m2[11] + m1[7] * m2[15]; - - a[8] = m1[8] * m2[0] + m1[9] * m2[4] + m1[10] * m2[8] + m1[11] * m2[12]; - a[9] = m1[8] * m2[1] + m1[9] * m2[5] + m1[10] * m2[9] + m1[11] * m2[13]; - a[10] = m1[8] * m2[2] + m1[9] * m2[6] + m1[10] * m2[10] + m1[11] * m2[14]; - a[11] = m1[8] * m2[3] + m1[9] * m2[7] + m1[10] * m2[11] + m1[11] * m2[15]; - - a[12] = m1[12] * m2[0] + m1[13] * m2[4] + m1[14] * m2[8] + m1[15] * m2[12]; - a[13] = m1[12] * m2[1] + m1[13] * m2[5] + m1[14] * m2[9] + m1[15] * m2[13]; - a[14] = m1[12] * m2[2] + m1[13] * m2[6] + m1[14] * m2[10] + m1[15] * m2[14]; - a[15] = m1[12] * m2[3] + m1[13] * m2[7] + m1[14] * m2[11] + m1[15] * m2[15]; - - return this.fromArray(a); - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#translate - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - translate: function (v) - { - var x = v.x; - var y = v.y; - var z = v.z; - var a = this.val; - - a[12] = a[0] * x + a[4] * y + a[8] * z + a[12]; - a[13] = a[1] * x + a[5] * y + a[9] * z + a[13]; - a[14] = a[2] * x + a[6] * y + a[10] * z + a[14]; - a[15] = a[3] * x + a[7] * y + a[11] * z + a[15]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#scale - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - scale: function (v) - { - var x = v.x; - var y = v.y; - var z = v.z; - var a = this.val; - - a[0] = a[0] * x; - a[1] = a[1] * x; - a[2] = a[2] * x; - a[3] = a[3] * x; - - a[4] = a[4] * y; - a[5] = a[5] * y; - a[6] = a[6] * y; - a[7] = a[7] * y; - - a[8] = a[8] * z; - a[9] = a[9] * z; - a[10] = a[10] * z; - a[11] = a[11] * z; - - return this; - }, - - // Axis = vec3, angle = radians - /** - * [description] - * - * @method Phaser.Math.Matrix4#makeRotationAxis - * @since 3.0.0 - * - * @param {[type]} axis - [description] - * @param {[type]} angle - [description] - * - * @return {[type]} [description] - */ - makeRotationAxis: function (axis, angle) - { - // Based on http://www.gamedev.net/reference/articles/article1199.asp - - var c = Math.cos(angle); - var s = Math.sin(angle); - var t = 1 - c; - var x = axis.x; - var y = axis.y; - var z = axis.z; - var tx = t * x; - var ty = t * y; - - this.set( - tx * x + c, tx * y - s * z, tx * z + s * y, 0, - tx * y + s * z, ty * y + c, ty * z - s * x, 0, - tx * z - s * y, ty * z + s * x, t * z * z + c, 0, - 0, 0, 0, 1 - ); - - return this; - }, - - // aka rotationAxis - /** - * [description] - * - * @method Phaser.Math.Matrix4#rotate - * @since 3.0.0 - * - * @param {[type]} rad - [description] - * @param {[type]} axis - [description] - * - * @return {[type]} [description] - */ - rotate: function (rad, axis) - { - var a = this.val; - var x = axis.x; - var y = axis.y; - var z = axis.z; - var len = Math.sqrt(x * x + y * y + z * z); - - if (Math.abs(len) < EPSILON) - { - return null; - } - - len = 1 / len; - x *= len; - y *= len; - z *= len; - - var s = Math.sin(rad); - var c = Math.cos(rad); - var t = 1 - c; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - // Construct the elements of the rotation matrix - var b00 = x * x * t + c; - var b01 = y * x * t + z * s; - var b02 = z * x * t - y * s; - - var b10 = x * y * t - z * s; - var b11 = y * y * t + c; - var b12 = z * y * t + x * s; - - var b20 = x * z * t + y * s; - var b21 = y * z * t - x * s; - var b22 = z * z * t + c; - - // Perform rotation-specific matrix multiplication - a[0] = a00 * b00 + a10 * b01 + a20 * b02; - a[1] = a01 * b00 + a11 * b01 + a21 * b02; - a[2] = a02 * b00 + a12 * b01 + a22 * b02; - a[3] = a03 * b00 + a13 * b01 + a23 * b02; - a[4] = a00 * b10 + a10 * b11 + a20 * b12; - a[5] = a01 * b10 + a11 * b11 + a21 * b12; - a[6] = a02 * b10 + a12 * b11 + a22 * b12; - a[7] = a03 * b10 + a13 * b11 + a23 * b12; - a[8] = a00 * b20 + a10 * b21 + a20 * b22; - a[9] = a01 * b20 + a11 * b21 + a21 * b22; - a[10] = a02 * b20 + a12 * b21 + a22 * b22; - a[11] = a03 * b20 + a13 * b21 + a23 * b22; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#rotateX - * @since 3.0.0 - * - * @param {[type]} rad - [description] - * - * @return {[type]} [description] - */ - rotateX: function (rad) - { - var a = this.val; - var s = Math.sin(rad); - var c = Math.cos(rad); - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - // Perform axis-specific matrix multiplication - a[4] = a10 * c + a20 * s; - a[5] = a11 * c + a21 * s; - a[6] = a12 * c + a22 * s; - a[7] = a13 * c + a23 * s; - a[8] = a20 * c - a10 * s; - a[9] = a21 * c - a11 * s; - a[10] = a22 * c - a12 * s; - a[11] = a23 * c - a13 * s; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#rotateY - * @since 3.0.0 - * - * @param {[type]} rad - [description] - * - * @return {[type]} [description] - */ - rotateY: function (rad) - { - var a = this.val; - var s = Math.sin(rad); - var c = Math.cos(rad); - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - // Perform axis-specific matrix multiplication - a[0] = a00 * c - a20 * s; - a[1] = a01 * c - a21 * s; - a[2] = a02 * c - a22 * s; - a[3] = a03 * c - a23 * s; - a[8] = a00 * s + a20 * c; - a[9] = a01 * s + a21 * c; - a[10] = a02 * s + a22 * c; - a[11] = a03 * s + a23 * c; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#rotateZ - * @since 3.0.0 - * - * @param {[type]} rad - [description] - * - * @return {[type]} [description] - */ - rotateZ: function (rad) - { - var a = this.val; - var s = Math.sin(rad); - var c = Math.cos(rad); - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - // Perform axis-specific matrix multiplication - a[0] = a00 * c + a10 * s; - a[1] = a01 * c + a11 * s; - a[2] = a02 * c + a12 * s; - a[3] = a03 * c + a13 * s; - a[4] = a10 * c - a00 * s; - a[5] = a11 * c - a01 * s; - a[6] = a12 * c - a02 * s; - a[7] = a13 * c - a03 * s; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#fromRotationTranslation - * @since 3.0.0 - * - * @param {[type]} q - [description] - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - fromRotationTranslation: function (q, v) - { - // Quaternion math - var out = this.val; - - var x = q.x; - var y = q.y; - var z = q.z; - var w = q.w; - - var x2 = x + x; - var y2 = y + y; - var z2 = z + z; - - var xx = x * x2; - var xy = x * y2; - var xz = x * z2; - - var yy = y * y2; - var yz = y * z2; - var zz = z * z2; - - var wx = w * x2; - var wy = w * y2; - var wz = w * z2; - - out[0] = 1 - (yy + zz); - out[1] = xy + wz; - out[2] = xz - wy; - out[3] = 0; - - out[4] = xy - wz; - out[5] = 1 - (xx + zz); - out[6] = yz + wx; - out[7] = 0; - - out[8] = xz + wy; - out[9] = yz - wx; - out[10] = 1 - (xx + yy); - out[11] = 0; - - out[12] = v.x; - out[13] = v.y; - out[14] = v.z; - out[15] = 1; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#fromQuat - * @since 3.0.0 - * - * @param {[type]} q - [description] - * - * @return {[type]} [description] - */ - fromQuat: function (q) - { - var out = this.val; - - var x = q.x; - var y = q.y; - var z = q.z; - var w = q.w; - - var x2 = x + x; - var y2 = y + y; - var z2 = z + z; - - var xx = x * x2; - var xy = x * y2; - var xz = x * z2; - - var yy = y * y2; - var yz = y * z2; - var zz = z * z2; - - var wx = w * x2; - var wy = w * y2; - var wz = w * z2; - - out[0] = 1 - (yy + zz); - out[1] = xy + wz; - out[2] = xz - wy; - out[3] = 0; - - out[4] = xy - wz; - out[5] = 1 - (xx + zz); - out[6] = yz + wx; - out[7] = 0; - - out[8] = xz + wy; - out[9] = yz - wx; - out[10] = 1 - (xx + yy); - out[11] = 0; - - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - - return this; - }, - - /** - * Generates a frustum matrix with the given bounds - * - * @param {Number} left Left bound of the frustum - * @param {Number} right Right bound of the frustum - * @param {Number} bottom Bottom bound of the frustum - * @param {Number} top Top bound of the frustum - * @param {Number} near Near bound of the frustum - * @param {Number} far Far bound of the frustum - * @returns {Matrix4} this for chaining - */ - /** - * [description] - * - * @method Phaser.Math.Matrix4#frustum - * @since 3.0.0 - * - * @param {[type]} left - [description] - * @param {[type]} right - [description] - * @param {[type]} bottom - [description] - * @param {[type]} top - [description] - * @param {[type]} near - [description] - * @param {[type]} far - [description] - * - * @return {[type]} [description] - */ - frustum: function (left, right, bottom, top, near, far) - { - var out = this.val; - - var rl = 1 / (right - left); - var tb = 1 / (top - bottom); - var nf = 1 / (near - far); - - out[0] = (near * 2) * rl; - out[1] = 0; - out[2] = 0; - out[3] = 0; - - out[4] = 0; - out[5] = (near * 2) * tb; - out[6] = 0; - out[7] = 0; - - out[8] = (right + left) * rl; - out[9] = (top + bottom) * tb; - out[10] = (far + near) * nf; - out[11] = -1; - - out[12] = 0; - out[13] = 0; - out[14] = (far * near * 2) * nf; - out[15] = 0; - - return this; - }, - - /** - * Generates a perspective projection matrix with the given bounds. - * perspective fov lh - * - * @param {number} fovy Vertical field of view in radians - * @param {number} aspect Aspect ratio. typically viewport width/height - * @param {number} near Near bound of the frustum - * @param {number} far Far bound of the frustum - * @returns {Matrix4} this for chaining - */ - /** - * [description] - * - * @method Phaser.Math.Matrix4#perspective - * @since 3.0.0 - * - * @param {[type]} fovy - [description] - * @param {[type]} aspect - [description] - * @param {[type]} near - [description] - * @param {[type]} far - [description] - * - * @return {[type]} [description] - */ - perspective: function (fovy, aspect, near, far) - { - var out = this.val; - var f = 1.0 / Math.tan(fovy / 2); - var nf = 1 / (near - far); - - out[0] = f / aspect; - out[1] = 0; - out[2] = 0; - out[3] = 0; - - out[4] = 0; - out[5] = f; - out[6] = 0; - out[7] = 0; - - out[8] = 0; - out[9] = 0; - out[10] = (far + near) * nf; - out[11] = -1; - - out[12] = 0; - out[13] = 0; - out[14] = (2 * far * near) * nf; - out[15] = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#perspectiveLH - * @since 3.0.0 - * - * @param {[type]} width - [description] - * @param {[type]} height - [description] - * @param {[type]} near - [description] - * @param {[type]} far - [description] - * - * @return {[type]} [description] - */ - perspectiveLH: function (width, height, near, far) - { - var out = this.val; - - out[0] = (2 * near) / width; - out[1] = 0; - out[2] = 0; - out[3] = 0; - - out[4] = 0; - out[5] = (2 * near) / height; - out[6] = 0; - out[7] = 0; - - out[8] = 0; - out[9] = 0; - out[10] = -far / (near - far); - out[11] = 1; - - out[12] = 0; - out[13] = 0; - out[14] = (near * far) / (near - far); - out[15] = 0; - - return this; - }, - - /** - * Generates a orthogonal projection matrix with the given bounds - * - * @param {number} left Left bound of the frustum - * @param {number} right Right bound of the frustum - * @param {number} bottom Bottom bound of the frustum - * @param {number} top Top bound of the frustum - * @param {number} near Near bound of the frustum - * @param {number} far Far bound of the frustum - * @returns {Matrix4} this for chaining - */ - /** - * [description] - * - * @method Phaser.Math.Matrix4#ortho - * @since 3.0.0 - * - * @param {[type]} left - [description] - * @param {[type]} right - [description] - * @param {[type]} bottom - [description] - * @param {[type]} top - [description] - * @param {[type]} near - [description] - * @param {[type]} far - [description] - * - * @return {[type]} [description] - */ - ortho: function (left, right, bottom, top, near, far) - { - var out = this.val; - var lr = left - right; - var bt = bottom - top; - var nf = near - far; - - // Avoid division by zero - lr = (lr === 0) ? lr : 1 / lr; - bt = (bt === 0) ? bt : 1 / bt; - nf = (nf === 0) ? nf : 1 / nf; - - out[0] = -2 * lr; - out[1] = 0; - out[2] = 0; - out[3] = 0; - - out[4] = 0; - out[5] = -2 * bt; - out[6] = 0; - out[7] = 0; - - out[8] = 0; - out[9] = 0; - out[10] = 2 * nf; - out[11] = 0; - - out[12] = (left + right) * lr; - out[13] = (top + bottom) * bt; - out[14] = (far + near) * nf; - out[15] = 1; - - return this; - }, - - /** - * Generates a look-at matrix with the given eye position, focal point, and up axis - * - * @param {Vector3} eye Position of the viewer - * @param {Vector3} center Point the viewer is looking at - * @param {Vector3} up vec3 pointing up - * @returns {Matrix4} this for chaining - */ - /** - * [description] - * - * @method Phaser.Math.Matrix4#lookAt - * @since 3.0.0 - * - * @param {[type]} eye - [description] - * @param {[type]} center - [description] - * @param {[type]} up - [description] - * - * @return {[type]} [description] - */ - lookAt: function (eye, center, up) - { - var out = this.val; - - var eyex = eye.x; - var eyey = eye.y; - var eyez = eye.z; - - var upx = up.x; - var upy = up.y; - var upz = up.z; - - var centerx = center.x; - var centery = center.y; - var centerz = center.z; - - if (Math.abs(eyex - centerx) < EPSILON && - Math.abs(eyey - centery) < EPSILON && - Math.abs(eyez - centerz) < EPSILON) - { - return this.identity(); - } - - var z0 = eyex - centerx; - var z1 = eyey - centery; - var z2 = eyez - centerz; - - var len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2); - - z0 *= len; - z1 *= len; - z2 *= len; - - var x0 = upy * z2 - upz * z1; - var x1 = upz * z0 - upx * z2; - var x2 = upx * z1 - upy * z0; - - len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2); - - if (!len) - { - x0 = 0; - x1 = 0; - x2 = 0; - } - else - { - len = 1 / len; - x0 *= len; - x1 *= len; - x2 *= len; - } - - var y0 = z1 * x2 - z2 * x1; - var y1 = z2 * x0 - z0 * x2; - var y2 = z0 * x1 - z1 * x0; - - len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2); - - if (!len) - { - y0 = 0; - y1 = 0; - y2 = 0; - } - else - { - len = 1 / len; - y0 *= len; - y1 *= len; - y2 *= len; - } - - out[0] = x0; - out[1] = y0; - out[2] = z0; - out[3] = 0; - - out[4] = x1; - out[5] = y1; - out[6] = z1; - out[7] = 0; - - out[8] = x2; - out[9] = y2; - out[10] = z2; - out[11] = 0; - - out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez); - out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez); - out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez); - out[15] = 1; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#yawPitchRoll - * @since 3.0.0 - * - * @param {[type]} yaw - [description] - * @param {[type]} pitch - [description] - * @param {[type]} roll - [description] - * - * @return {[type]} [description] - */ - yawPitchRoll: function (yaw, pitch, roll) - { - this.zero(); - _tempMat1.zero(); - _tempMat2.zero(); - - var m0 = this.val; - var m1 = _tempMat1.val; - var m2 = _tempMat2.val; - - // Rotate Z - var s = Math.sin(roll); - var c = Math.cos(roll); - - m0[10] = 1; - m0[15] = 1; - m0[0] = c; - m0[1] = s; - m0[4] = -s; - m0[5] = c; - - // Rotate X - s = Math.sin(pitch); - c = Math.cos(pitch); - - m1[0] = 1; - m1[15] = 1; - m1[5] = c; - m1[10] = c; - m1[9] = -s; - m1[6] = s; - - // Rotate Y - s = Math.sin(yaw); - c = Math.cos(yaw); - - m2[5] = 1; - m2[15] = 1; - m2[0] = c; - m2[2] = -s; - m2[8] = s; - m2[10] = c; - - this.multiplyLocal(_tempMat1); - this.multiplyLocal(_tempMat2); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#setWorldMatrix - * @since 3.0.0 - * - * @param {[type]} rotation - [description] - * @param {[type]} position - [description] - * @param {[type]} scale - [description] - * @param {[type]} viewMatrix - [description] - * @param {[type]} projectionMatrix - [description] - * - * @return {[type]} [description] - */ - setWorldMatrix: function (rotation, position, scale, viewMatrix, projectionMatrix) - { - this.yawPitchRoll(rotation.y, rotation.x, rotation.z); - - _tempMat1.scaling(scale.x, scale.y, scale.z); - _tempMat2.xyz(position.x, position.y, position.z); - - this.multiplyLocal(_tempMat1); - this.multiplyLocal(_tempMat2); - - if (viewMatrix !== undefined) - { - this.multiplyLocal(viewMatrix); - } - - if (projectionMatrix !== undefined) - { - this.multiplyLocal(projectionMatrix); - } - - return this; + tile.faceTop = true; + tile.faceBottom = true; + tile.faceLeft = true; + tile.faceRight = true; } -}); + // Reset edges that are shared between tile and its neighbors + if (above && above.collides) + { + if (tileCollides) { tile.faceTop = false; } + above.faceBottom = !tileCollides; + } -var _tempMat1 = new Matrix4(); -var _tempMat2 = new Matrix4(); + if (below && below.collides) + { + if (tileCollides) { tile.faceBottom = false; } + below.faceTop = !tileCollides; + } -module.exports = Matrix4; + if (left && left.collides) + { + if (tileCollides) { tile.faceLeft = false; } + left.faceRight = !tileCollides; + } + + if (right && right.collides) + { + if (tileCollides) { tile.faceRight = false; } + right.faceLeft = !tileCollides; + } + + if (tile && !tile.collides) { tile.resetFaces(); } + + return tile; +}; + +module.exports = CalculateFacesAt; /***/ }), -/* 120 */ +/* 120 */, +/* 121 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -21834,527 +20267,46 @@ module.exports = Matrix4; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji -// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl - -var Class = __webpack_require__(0); +var Extend = __webpack_require__(18); +var XHRSettings = __webpack_require__(94); /** - * @classdesc - * [description] + * Takes two XHRSettings Objects and creates a new XHRSettings object from them. * - * @class Vector4 - * @memberOf Phaser.Math - * @constructor + * The new object is seeded by the values given in the global settings, but any setting in + * the local object overrides the global ones. + * + * @function Phaser.Loader.MergeXHRSettings * @since 3.0.0 * - * @param {number} [x] - [description] - * @param {number} [y] - [description] - * @param {number} [z] - [description] - * @param {number} [w] - [description] + * @param {XHRSettingsObject} global - The global XHRSettings object. + * @param {XHRSettingsObject} local - The local XHRSettings object. + * + * @return {XHRSettingsObject} A newly formed XHRSettings object. */ -var Vector4 = new Class({ +var MergeXHRSettings = function (global, local) +{ + var output = (global === undefined) ? XHRSettings() : Extend({}, global); - initialize: - - function Vector4 (x, y, z, w) + if (local) { - /** - * The x component of this Vector. - * - * @name Phaser.Math.Vector4#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - /** - * The y component of this Vector. - * - * @name Phaser.Math.Vector4#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - /** - * The z component of this Vector. - * - * @name Phaser.Math.Vector4#z - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - /** - * The w component of this Vector. - * - * @name Phaser.Math.Vector4#w - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - if (typeof x === 'object') + for (var setting in local) { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - this.w = x.w || 0; + if (local[setting] !== undefined) + { + output[setting] = local[setting]; + } } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - this.w = w || 0; - } - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#clone - * @since 3.0.0 - * - * @return {Phaser.Math.Vector4} [description] - */ - clone: function () - { - return new Vector4(this.x, this.y, this.z, this.w); - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#copy - * @since 3.0.0 - * - * @param {Phaser.Math.Vector4} src - [description] - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - copy: function (src) - { - this.x = src.x; - this.y = src.y; - this.z = src.z || 0; - this.w = src.w || 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#equals - * @since 3.0.0 - * - * @param {Phaser.Math.Vector4} v - [description] - * - * @return {boolean} [description] - */ - equals: function (v) - { - return ((this.x === v.x) && (this.y === v.y) && (this.z === v.z) && (this.w === v.w)); - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#set - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} z - [description] - * @param {number} w - [description] - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - set: function (x, y, z, w) - { - if (typeof x === 'object') - { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - this.w = x.w || 0; - } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - this.w = w || 0; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#add - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4} v - [description] - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - add: function (v) - { - this.x += v.x; - this.y += v.y; - this.z += v.z || 0; - this.w += v.w || 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#subtract - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4} v - [description] - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - subtract: function (v) - { - this.x -= v.x; - this.y -= v.y; - this.z -= v.z || 0; - this.w -= v.w || 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#scale - * @since 3.0.0 - * - * @param {number} scale - [description] - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - scale: function (scale) - { - this.x *= scale; - this.y *= scale; - this.z *= scale; - this.w *= scale; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#length - * @since 3.0.0 - * - * @return {number} [description] - */ - length: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - - return Math.sqrt(x * x + y * y + z * z + w * w); - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#lengthSq - * @since 3.0.0 - * - * @return {number} [description] - */ - lengthSq: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - - return x * x + y * y + z * z + w * w; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#normalize - * @since 3.0.0 - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - normalize: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - var len = x * x + y * y + z * z + w * w; - - if (len > 0) - { - len = 1 / Math.sqrt(len); - - this.x = x * len; - this.y = y * len; - this.z = z * len; - this.w = w * len; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#dot - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {number} [description] - */ - dot: function (v) - { - return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#lerp - * @since 3.0.0 - * - * @param {[type]} v - [description] - * @param {[type]} t - [description] - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - lerp: function (v, t) - { - if (t === undefined) { t = 0; } - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - this.x = ax + t * (v.x - ax); - this.y = ay + t * (v.y - ay); - this.z = az + t * (v.z - az); - this.w = aw + t * (v.w - aw); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#multiply - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - multiply: function (v) - { - this.x *= v.x; - this.y *= v.y; - this.z *= v.z || 1; - this.w *= v.w || 1; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#divide - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - divide: function (v) - { - this.x /= v.x; - this.y /= v.y; - this.z /= v.z || 1; - this.w /= v.w || 1; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#distance - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {number} [description] - */ - distance: function (v) - { - var dx = v.x - this.x; - var dy = v.y - this.y; - var dz = v.z - this.z || 0; - var dw = v.w - this.w || 0; - - return Math.sqrt(dx * dx + dy * dy + dz * dz + dw * dw); - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#distanceSq - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {number} [description] - */ - distanceSq: function (v) - { - var dx = v.x - this.x; - var dy = v.y - this.y; - var dz = v.z - this.z || 0; - var dw = v.w - this.w || 0; - - return dx * dx + dy * dy + dz * dz + dw * dw; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#negate - * @since 3.0.0 - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - negate: function () - { - this.x = -this.x; - this.y = -this.y; - this.z = -this.z; - this.w = -this.w; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#transformMat4 - * @since 3.0.0 - * - * @param {[type]} mat - [description] - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - transformMat4: function (mat) - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - var m = mat.val; - - this.x = m[0] * x + m[4] * y + m[8] * z + m[12] * w; - this.y = m[1] * x + m[5] * y + m[9] * z + m[13] * w; - this.z = m[2] * x + m[6] * y + m[10] * z + m[14] * w; - this.w = m[3] * x + m[7] * y + m[11] * z + m[15] * w; - - return this; - }, - - // TODO: is this really the same as Vector3? - // Also, what about this: http://molecularmusings.wordpress.com/2013/05/24/a-faster-quaternion-vector-multiplication/ - /** - * [description] - * - * @method Phaser.Math.Vector4#transformQuat - * @since 3.0.0 - * - * @param {[type]} q - [description] - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - transformQuat: function (q) - { - // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations - var x = this.x; - var y = this.y; - var z = this.z; - var qx = q.x; - var qy = q.y; - var qz = q.z; - var qw = q.w; - - // calculate quat * vec - var ix = qw * x + qy * z - qz * y; - var iy = qw * y + qz * x - qx * z; - var iz = qw * z + qx * y - qy * x; - var iw = -qx * x - qy * y - qz * z; - - // calculate result * inverse quat - this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; - this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; - this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#reset - * @since 3.0.0 - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - reset: function () - { - this.x = 0; - this.y = 0; - this.z = 0; - this.w = 0; - - return this; } -}); + return output; +}; -// TODO: Check if these are required internally, if not, remove. -Vector4.prototype.sub = Vector4.prototype.subtract; -Vector4.prototype.mul = Vector4.prototype.multiply; -Vector4.prototype.div = Vector4.prototype.divide; -Vector4.prototype.dist = Vector4.prototype.distance; -Vector4.prototype.distSq = Vector4.prototype.distanceSq; -Vector4.prototype.len = Vector4.prototype.length; -Vector4.prototype.lenSq = Vector4.prototype.lengthSq; - -module.exports = Vector4; +module.exports = MergeXHRSettings; /***/ }), -/* 121 */ +/* 122 */ /***/ (function(module, exports) { /** @@ -22363,209 +20315,35 @@ module.exports = Vector4; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Browser specific prefix, so not going to change between contexts, only between browsers -var prefix = ''; - /** - * @namespace Phaser.Display.Canvas.Smoothing - * @since 3.0.0 - */ -var Smoothing = function () -{ - /** - * Gets the Smoothing Enabled vendor prefix being used on the given context, or null if not set. - * - * @function Phaser.Display.Canvas.Smoothing.getPrefix - * @since 3.0.0 - * - * @param {[type]} context - [description] - * - * @return {string} [description] - */ - var getPrefix = function (context) - { - var vendors = [ 'i', 'webkitI', 'msI', 'mozI', 'oI' ]; - - for (var i = 0; i < vendors.length; i++) - { - var s = vendors[i] + 'mageSmoothingEnabled'; - - if (s in context) - { - return s; - } - } - - return null; - }; - - /** - * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. - * By default browsers have image smoothing enabled, which isn't always what you visually want, especially - * when using pixel art in a game. Note that this sets the property on the context itself, so that any image - * drawn to the context will be affected. This sets the property across all current browsers but support is - * patchy on earlier browsers, especially on mobile. - * - * @function Phaser.Display.Canvas.Smoothing.enable - * @since 3.0.0 - * - * @param {[type]} context - [description] - * - * @return {[type]} [description] - */ - var enable = function (context) - { - if (prefix === '') - { - prefix = getPrefix(context); - } - - if (prefix) - { - context[prefix] = true; - } - - return context; - }; - - /** - * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. - * By default browsers have image smoothing enabled, which isn't always what you visually want, especially - * when using pixel art in a game. Note that this sets the property on the context itself, so that any image - * drawn to the context will be affected. This sets the property across all current browsers but support is - * patchy on earlier browsers, especially on mobile. - * - * @function Phaser.Display.Canvas.Smoothing.disable - * @since 3.0.0 - * - * @param {[type]} context - [description] - * - * @return {[type]} [description] - */ - var disable = function (context) - { - if (prefix === '') - { - prefix = getPrefix(context); - } - - if (prefix) - { - context[prefix] = false; - } - - return context; - }; - - /** - * Returns `true` if the given context has image smoothing enabled, otherwise returns `false`. - * Returns null if no smoothing prefix is available. - * - * @function Phaser.Display.Canvas.Smoothing.isEnabled - * @since 3.0.0 - * - * @param {[type]} context - [description] - * - * @return {boolean} [description] - */ - var isEnabled = function (context) - { - return (prefix !== null) ? context[prefix] : null; - }; - - return { - disable: disable, - enable: enable, - getPrefix: getPrefix, - isEnabled: isEnabled - }; - -}; - -module.exports = Smoothing(); - - -/***/ }), -/* 122 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(8); - -// points is an array of Point-like objects, -// either 2 dimensional arrays, or objects with public x/y properties: -// var points = [ -// [100, 200], -// [200, 400], -// { x: 30, y: 60 } -// ] - -/** - * [description] + * Given a File and a baseURL value this returns the URL the File will use to download from. * - * @function Phaser.Geom.Rectangle.FromPoints + * @function Phaser.Loader.GetURL * @since 3.0.0 * - * @param {[type]} points - [description] - * @param {Phaser.Geom.Rectangle} out - [description] + * @param {Phaser.Loader.File} file - The File object. + * @param {string} baseURL - A default base URL. * - * @return {Phaser.Geom.Rectangle} [description] + * @return {string} The URL the File will use. */ -var FromPoints = function (points, out) +var GetURL = function (file, baseURL) { - if (out === undefined) { out = new Rectangle(); } - - if (points.length === 0) + if (!file.url) { - return out; + return false; } - var minX = Number.MAX_VALUE; - var minY = Number.MAX_VALUE; - - var maxX = Number.MIN_SAFE_INTEGER; - var maxY = Number.MIN_SAFE_INTEGER; - - var p; - var px; - var py; - - for (var i = 0; i < points.length; i++) + if (file.url.match(/^(?:blob:|data:|http:\/\/|https:\/\/|\/\/)/)) { - p = points[i]; - - if (Array.isArray(p)) - { - px = p[0]; - py = p[1]; - } - else - { - px = p.x; - py = p.y; - } - - minX = Math.min(minX, px); - minY = Math.min(minY, py); - - maxX = Math.max(maxX, px); - maxY = Math.max(maxY, py); + return file.url; + } + else + { + return baseURL + file.url; } - - out.x = minX; - out.y = minY; - out.width = maxX - minX; - out.height = maxY - minY; - - return out; }; -module.exports = FromPoints; +module.exports = GetURL; /***/ }), @@ -22581,28 +20359,43 @@ module.exports = FromPoints; /** * [description] * - * @function Phaser.Math.CatmullRom + * @function Phaser.Geom.Triangle.RotateAroundXY * @since 3.0.0 * - * @param {number} t - [description] - * @param {number} p0 - [description] - * @param {number} p1 - [description] - * @param {number} p2 - [description] - * @param {number} p3 - [description] + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} angle - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Triangle} [description] */ -var CatmullRom = function (t, p0, p1, p2, p3) +var RotateAroundXY = function (triangle, x, y, angle) { - var v0 = (p2 - p0) * 0.5; - var v1 = (p3 - p1) * 0.5; - var t2 = t * t; - var t3 = t * t2; + var c = Math.cos(angle); + var s = Math.sin(angle); - return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; + var tx = triangle.x1 - x; + var ty = triangle.y1 - y; + + triangle.x1 = tx * c - ty * s + x; + triangle.y1 = tx * s + ty * c + y; + + tx = triangle.x2 - x; + ty = triangle.y2 - y; + + triangle.x2 = tx * c - ty * s + x; + triangle.y2 = tx * s + ty * c + y; + + tx = triangle.x3 - x; + ty = triangle.y3 - y; + + triangle.x3 = tx * c - ty * s + x; + triangle.y3 = tx * s + ty * c + y; + + return triangle; }; -module.exports = CatmullRom; +module.exports = RotateAroundXY; /***/ }), @@ -22618,21 +20411,19 @@ module.exports = CatmullRom; /** * [description] * - * @function Phaser.Math.Linear + * @function Phaser.Geom.Rectangle.GetAspectRatio * @since 3.0.0 * - * @param {number} p0 - [description] - * @param {number} p1 - [description] - * @param {float} t - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] * * @return {number} [description] */ -var Linear = function (p0, p1, t) +var GetAspectRatio = function (rect) { - return (p1 - p0) * t + p0; + return (rect.height === 0) ? NaN : rect.width / rect.height; }; -module.exports = Linear; +module.exports = GetAspectRatio; /***/ }), @@ -22645,61 +20436,48 @@ module.exports = Linear; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +// Checks whether the x and y coordinates are contained within this polygon. +// Adapted from http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html by Jonas Raoni Soares Silva + /** - * Adds the given element to the DOM. If a parent is provided the element is added as a child of the parent, providing it was able to access it. - * If no parent was given or falls back to using `document.body`. + * [description] * - * @function Phaser.DOM.AddToDOM + * @function Phaser.Geom.Polygon.Contains * @since 3.0.0 * - * @param {object} element - The element to be added to the DOM. Usually a Canvas object. - * @param {string|object} [parent] - The parent in which to add the element. Can be a string which is passed to `getElementById` or an actual DOM object. - * @param {boolean} [overflowHidden=true] - [description] + * @param {Phaser.Geom.Polygon} polygon - [description] + * @param {number} x - [description] + * @param {number} y - [description] * - * @return {object} The element that was added to the DOM. + * @return {boolean} [description] */ -var AddToDOM = function (element, parent, overflowHidden) +var Contains = function (polygon, x, y) { - if (overflowHidden === undefined) { overflowHidden = true; } + var inside = false; - var target; - - if (parent) + for (var i = -1, j = polygon.points.length - 1; ++i < polygon.points.length; j = i) { - if (typeof parent === 'string') + var ix = polygon.points[i].x; + var iy = polygon.points[i].y; + + var jx = polygon.points[j].x; + var jy = polygon.points[j].y; + + if (((iy <= y && y < jy) || (jy <= y && y < iy)) && (x < (jx - ix) * (y - iy) / (jy - iy) + ix)) { - // Hopefully an element ID - target = document.getElementById(parent); - } - else if (typeof parent === 'object' && parent.nodeType === 1) - { - // Quick test for a HTMLelement - target = parent; + inside = !inside; } } - // Fallback, covers an invalid ID and a non HTMLelement object - if (!target) - { - target = document.body; - } - - if (overflowHidden && target.style) - { - target.style.overflow = 'hidden'; - } - - target.appendChild(element); - - return element; + return inside; }; -module.exports = AddToDOM; +module.exports = Contains; /***/ }), /* 126 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -22707,192 +20485,40 @@ module.exports = AddToDOM; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var OS = __webpack_require__(67); -var Browser = __webpack_require__(82); -var CanvasPool = __webpack_require__(21); - /** - * Determines the features of the browser running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.features` from within any Scene. - * - * @name Phaser.Device.Features + * [description] + * + * @function Phaser.Geom.Line.RotateAroundXY * @since 3.0.0 - * - * @type {object} - * @property {?boolean} canvasBitBltShift - True if canvas supports a 'copy' bitblt onto itself when the source and destination regions overlap. - * @property {boolean} canvas - Is canvas available? - * @property {boolean} file - Is file available? - * @property {boolean} fileSystem - Is fileSystem available? - * @property {boolean} getUserMedia - Does the device support the getUserMedia API? - * @property {boolean} littleEndian - Is the device big or little endian? (only detected if the browser supports TypedArrays) - * @property {boolean} localStorage - Is localStorage available? - * @property {boolean} pointerLock - Is Pointer Lock available? - * @property {boolean} support32bit - Does the device context support 32bit pixel manipulation using array buffer views? - * @property {boolean} vibration - Does the device support the Vibration API? - * @property {boolean} webGL - Is webGL available? - * @property {boolean} worker - Is worker available? + * + * @param {Phaser.Geom.Line} line - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} angle - [description] + * + * @return {Phaser.Geom.Line} [description] */ -var Features = { +var RotateAroundXY = function (line, x, y, angle) +{ + var c = Math.cos(angle); + var s = Math.sin(angle); - canvas: false, - canvasBitBltShift: null, - file: false, - fileSystem: false, - getUserMedia: true, - littleEndian: false, - localStorage: false, - pointerLock: false, - support32bit: false, - vibration: false, - webGL: false, - worker: false + var tx = line.x1 - x; + var ty = line.y1 - y; + line.x1 = tx * c - ty * s + x; + line.y1 = tx * s + ty * c + y; + + tx = line.x2 - x; + ty = line.y2 - y; + + line.x2 = tx * c - ty * s + x; + line.y2 = tx * s + ty * c + y; + + return line; }; -// Check Little or Big Endian system. -// @author Matt DesLauriers (@mattdesl) -function checkIsLittleEndian () -{ - var a = new ArrayBuffer(4); - var b = new Uint8Array(a); - var c = new Uint32Array(a); - - b[0] = 0xa1; - b[1] = 0xb2; - b[2] = 0xc3; - b[3] = 0xd4; - - if (c[0] === 0xd4c3b2a1) - { - return true; - } - - if (c[0] === 0xa1b2c3d4) - { - return false; - } - else - { - // Could not determine endianness - return null; - } -} - -function init () -{ - Features.canvas = !!window['CanvasRenderingContext2D'] || OS.cocoonJS; - - try - { - Features.localStorage = !!localStorage.getItem; - } - catch (error) - { - Features.localStorage = false; - } - - Features.file = !!window['File'] && !!window['FileReader'] && !!window['FileList'] && !!window['Blob']; - Features.fileSystem = !!window['requestFileSystem']; - - var isUint8 = false; - - var testWebGL = function () - { - if (window['WebGLRenderingContext']) - { - try - { - var canvas = CanvasPool.createWebGL(this); - - if (OS.cocoonJS) - { - canvas.screencanvas = false; - } - - var ctx = canvas.getContext('webgl') || canvas.getContext('experimental-webgl'); - - var canvas2D = CanvasPool.create2D(this); - - var ctx2D = canvas2D.getContext('2d'); - - // Can't be done on a webgl context - var image = ctx2D.createImageData(1, 1); - - // Test to see if ImageData uses CanvasPixelArray or Uint8ClampedArray. - // @author Matt DesLauriers (@mattdesl) - isUint8 = image.data instanceof Uint8ClampedArray; - - CanvasPool.remove(canvas); - CanvasPool.remove(canvas2D); - - return !!ctx; - } - catch (e) - { - return false; - } - } - - return false; - }; - - Features.webGL = testWebGL(); - - Features.worker = !!window['Worker']; - - Features.pointerLock = 'pointerLockElement' in document || 'mozPointerLockElement' in document || 'webkitPointerLockElement' in document; - - navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia; - - window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL; - - Features.getUserMedia = Features.getUserMedia && !!navigator.getUserMedia && !!window.URL; - - // Older versions of firefox (< 21) apparently claim support but user media does not actually work - if (Browser.firefox && Browser.firefoxVersion < 21) - { - Features.getUserMedia = false; - } - - // Excludes iOS versions as they generally wrap UIWebView (eg. Safari WebKit) and it - // is safer to not try and use the fast copy-over method. - if (!OS.iOS && (Browser.ie || Browser.firefox || Browser.chrome)) - { - Features.canvasBitBltShift = true; - } - - // Known not to work - if (Browser.safari || Browser.mobileSafari) - { - Features.canvasBitBltShift = false; - } - - navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate; - - if (navigator.vibrate) - { - Features.vibration = true; - } - - if (typeof ArrayBuffer !== 'undefined' && typeof Uint8Array !== 'undefined' && typeof Uint32Array !== 'undefined') - { - Features.littleEndian = checkIsLittleEndian(); - } - - Features.support32bit = ( - typeof ArrayBuffer !== 'undefined' && - typeof Uint8ClampedArray !== 'undefined' && - typeof Int32Array !== 'undefined' && - Features.littleEndian !== null && - isUint8 - ); - - return Features; -} - -module.exports = init(); +module.exports = RotateAroundXY; /***/ }), @@ -22905,28 +20531,2297 @@ module.exports = init(); * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +// http://www.blackpawn.com/texts/pointinpoly/ + +// points is an array of Point-like objects with public x/y properties +// returns an array containing all points that are within the triangle, or an empty array if none +// if 'returnFirst' is true it will return after the first point within the triangle is found + /** - * Checks if the given `width` and `height` are a power of two. - * Useful for checking texture dimensions. + * [description] * - * @function Phaser.Math.Pow2.IsSizePowerOfTwo + * @function Phaser.Geom.Triangle.ContainsArray * @since 3.0.0 * - * @param {number} width - The width. - * @param {number} height - The height. + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Point[]} points - [description] + * @param {boolean} [returnFirst] - [description] + * @param {array} [out] - [description] * - * @return {boolean} `true` if `width` and `height` are a power of two, otherwise `false`. + * @return {Phaser.Geom.Point[]} [description] */ -var IsSizePowerOfTwo = function (width, height) +var ContainsArray = function (triangle, points, returnFirst, out) { - return (width > 0 && (width & (width - 1)) === 0 && height > 0 && (height & (height - 1)) === 0); + if (returnFirst === undefined) { returnFirst = false; } + if (out === undefined) { out = []; } + + var v0x = triangle.x3 - triangle.x1; + var v0y = triangle.y3 - triangle.y1; + + var v1x = triangle.x2 - triangle.x1; + var v1y = triangle.y2 - triangle.y1; + + var dot00 = (v0x * v0x) + (v0y * v0y); + var dot01 = (v0x * v1x) + (v0y * v1y); + var dot11 = (v1x * v1x) + (v1y * v1y); + + // Compute barycentric coordinates + var b = ((dot00 * dot11) - (dot01 * dot01)); + var inv = (b === 0) ? 0 : (1 / b); + + var u; + var v; + var v2x; + var v2y; + var dot02; + var dot12; + + var x1 = triangle.x1; + var y1 = triangle.y1; + + for (var i = 0; i < points.length; i++) + { + v2x = points[i].x - x1; + v2y = points[i].y - y1; + + dot02 = (v0x * v2x) + (v0y * v2y); + dot12 = (v1x * v2x) + (v1y * v2y); + + u = ((dot11 * dot02) - (dot01 * dot12)) * inv; + v = ((dot00 * dot12) - (dot01 * dot02)) * inv; + + if (u >= 0 && v >= 0 && (u + v < 1)) + { + out.push({ x: points[i].x, y: points[i].y }); + + if (returnFirst) + { + break; + } + } + } + + return out; }; -module.exports = IsSizePowerOfTwo; +module.exports = ContainsArray; /***/ }), /* 128 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Mesh = __webpack_require__(96); + +/** + * @classdesc + * A Quad Game Object. + * + * A Quad is a Mesh Game Object pre-configured with two triangles arranged into a rectangle, with a single + * texture spread across them. + * + * You can manipulate the corner points of the quad via the getters and setters such as `topLeftX`, and also + * change their alpha and color values. The quad itself can be moved by adjusting the `x` and `y` properties. + * + * @class Quad + * @extends Phaser.GameObjects.Mesh + * @memberOf Phaser.GameObjects + * @constructor + * @webglOnly + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var Quad = new Class({ + + Extends: Mesh, + + initialize: + + function Quad (scene, x, y, texture, frame) + { + // 0----3 + // |\ B| + // | \ | + // | \ | + // | A \| + // | \ + // 1----2 + + var vertices = [ + 0, 0, // tl + 0, 0, // bl + 0, 0, // br + 0, 0, // tl + 0, 0, // br + 0, 0 // tr + ]; + var uv = [ + 0, 0, // tl + 0, 1, // bl + 1, 1, // br + 0, 0, // tl + 1, 1, // br + 1, 0 // tr + ]; + var colors = [ + 0xffffff, // tl + 0xffffff, // bl + 0xffffff, // br + 0xffffff, // tl + 0xffffff, // br + 0xffffff // tr + ]; + var alphas = [ + 1, // tl + 1, // bl + 1, // br + 1, // tl + 1, // br + 1 // tr + ]; + + Mesh.call(this, scene, x, y, vertices, uv, colors, alphas, texture, frame); + + this.resetPosition(); + }, + + /** + * The top-left x vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#topLeftX + * @type {number} + * @since 3.0.0 + */ + topLeftX: { + + get: function () + { + return this.x + this.vertices[0]; + }, + + set: function (value) + { + this.vertices[0] = value - this.x; + this.vertices[6] = value - this.x; + } + + }, + + /** + * The top-left y vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#topLeftY + * @type {number} + * @since 3.0.0 + */ + topLeftY: { + + get: function () + { + return this.y + this.vertices[1]; + }, + + set: function (value) + { + this.vertices[1] = value - this.y; + this.vertices[7] = value - this.y; + } + + }, + + /** + * The top-right x vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#topRightX + * @type {number} + * @since 3.0.0 + */ + topRightX: { + + get: function () + { + return this.x + this.vertices[10]; + }, + + set: function (value) + { + this.vertices[10] = value - this.x; + } + + }, + + /** + * The top-right y vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#topRightY + * @type {number} + * @since 3.0.0 + */ + topRightY: { + + get: function () + { + return this.y + this.vertices[11]; + }, + + set: function (value) + { + this.vertices[11] = value - this.y; + } + + }, + + /** + * The bottom-left x vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomLeftX + * @type {number} + * @since 3.0.0 + */ + bottomLeftX: { + + get: function () + { + return this.x + this.vertices[2]; + }, + + set: function (value) + { + this.vertices[2] = value - this.x; + } + + }, + + /** + * The bottom-left y vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomLeftY + * @type {number} + * @since 3.0.0 + */ + bottomLeftY: { + + get: function () + { + return this.y + this.vertices[3]; + }, + + set: function (value) + { + this.vertices[3] = value - this.y; + } + + }, + + /** + * The bottom-right x vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomRightX + * @type {number} + * @since 3.0.0 + */ + bottomRightX: { + + get: function () + { + return this.x + this.vertices[4]; + }, + + set: function (value) + { + this.vertices[4] = value - this.x; + this.vertices[8] = value - this.x; + } + + }, + + /** + * The bottom-right y vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomRightY + * @type {number} + * @since 3.0.0 + */ + bottomRightY: { + + get: function () + { + return this.y + this.vertices[5]; + }, + + set: function (value) + { + this.vertices[5] = value - this.y; + this.vertices[9] = value - this.y; + } + + }, + + /** + * The top-left alpha value of this Quad. + * + * @name Phaser.GameObjects.Quad#topLeftAlpha + * @type {float} + * @since 3.0.0 + */ + topLeftAlpha: { + + get: function () + { + return this.alphas[0]; + }, + + set: function (value) + { + this.alphas[0] = value; + this.alphas[3] = value; + } + + }, + + /** + * The top-right alpha value of this Quad. + * + * @name Phaser.GameObjects.Quad#topRightAlpha + * @type {float} + * @since 3.0.0 + */ + topRightAlpha: { + + get: function () + { + return this.alphas[5]; + }, + + set: function (value) + { + this.alphas[5] = value; + } + + }, + + /** + * The bottom-left alpha value of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomLeftAlpha + * @type {float} + * @since 3.0.0 + */ + bottomLeftAlpha: { + + get: function () + { + return this.alphas[1]; + }, + + set: function (value) + { + this.alphas[1] = value; + } + + }, + + /** + * The bottom-right alpha value of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomRightAlpha + * @type {float} + * @since 3.0.0 + */ + bottomRightAlpha: { + + get: function () + { + return this.alphas[2]; + }, + + set: function (value) + { + this.alphas[2] = value; + this.alphas[4] = value; + } + + }, + + /** + * The top-left color value of this Quad. + * + * @name Phaser.GameObjects.Quad#topLeftColor + * @type {number} + * @since 3.0.0 + */ + topLeftColor: { + + get: function () + { + return this.colors[0]; + }, + + set: function (value) + { + this.colors[0] = value; + this.colors[3] = value; + } + + }, + + /** + * The top-right color value of this Quad. + * + * @name Phaser.GameObjects.Quad#topRightColor + * @type {number} + * @since 3.0.0 + */ + topRightColor: { + + get: function () + { + return this.colors[5]; + }, + + set: function (value) + { + this.colors[5] = value; + } + + }, + + /** + * The bottom-left color value of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomLeftColor + * @type {number} + * @since 3.0.0 + */ + bottomLeftColor: { + + get: function () + { + return this.colors[1]; + }, + + set: function (value) + { + this.colors[1] = value; + } + + }, + + /** + * The bottom-right color value of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomRightColor + * @type {number} + * @since 3.0.0 + */ + bottomRightColor: { + + get: function () + { + return this.colors[2]; + }, + + set: function (value) + { + this.colors[2] = value; + this.colors[4] = value; + } + + }, + + /** + * Sets the top-left vertex position of this Quad. + * + * @method Phaser.GameObjects.Quad#setTopLeft + * @since 3.0.0 + * + * @param {number} x - The horizontal coordinate of the vertex. + * @param {number} y - The vertical coordinate of the vertex. + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + setTopLeft: function (x, y) + { + this.topLeftX = x; + this.topLeftY = y; + + return this; + }, + + /** + * Sets the top-right vertex position of this Quad. + * + * @method Phaser.GameObjects.Quad#setTopRight + * @since 3.0.0 + * + * @param {number} x - The horizontal coordinate of the vertex. + * @param {number} y - The vertical coordinate of the vertex. + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + setTopRight: function (x, y) + { + this.topRightX = x; + this.topRightY = y; + + return this; + }, + + /** + * Sets the bottom-left vertex position of this Quad. + * + * @method Phaser.GameObjects.Quad#setBottomLeft + * @since 3.0.0 + * + * @param {number} x - The horizontal coordinate of the vertex. + * @param {number} y - The vertical coordinate of the vertex. + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + setBottomLeft: function (x, y) + { + this.bottomLeftX = x; + this.bottomLeftY = y; + + return this; + }, + + /** + * Sets the bottom-right vertex position of this Quad. + * + * @method Phaser.GameObjects.Quad#setBottomRight + * @since 3.0.0 + * + * @param {number} x - The horizontal coordinate of the vertex. + * @param {number} y - The vertical coordinate of the vertex. + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + setBottomRight: function (x, y) + { + this.bottomRightX = x; + this.bottomRightY = y; + + return this; + }, + + /** + * Resets the positions of the four corner vertices of this Quad. + * + * @method Phaser.GameObjects.Quad#resetPosition + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + resetPosition: function () + { + var x = this.x; + var y = this.y; + var halfWidth = Math.floor(this.width / 2); + var halfHeight = Math.floor(this.height / 2); + + this.setTopLeft(x - halfWidth, y - halfHeight); + this.setTopRight(x + halfWidth, y - halfHeight); + this.setBottomLeft(x - halfWidth, y + halfHeight); + this.setBottomRight(x + halfWidth, y + halfHeight); + + return this; + }, + + /** + * Resets the alpha values used by this Quad back to 1. + * + * @method Phaser.GameObjects.Quad#resetAlpha + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + resetAlpha: function () + { + var alphas = this.alphas; + + alphas[0] = 1; + alphas[1] = 1; + alphas[2] = 1; + alphas[3] = 1; + alphas[4] = 1; + alphas[5] = 1; + + return this; + }, + + /** + * Resets the color values used by this Quad back to 0xffffff. + * + * @method Phaser.GameObjects.Quad#resetColors + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + resetColors: function () + { + var colors = this.colors; + + colors[0] = 0xffffff; + colors[1] = 0xffffff; + colors[2] = 0xffffff; + colors[3] = 0xffffff; + colors[4] = 0xffffff; + colors[5] = 0xffffff; + + return this; + }, + + /** + * Resets the position, alpha and color values used by this Quad. + * + * @method Phaser.GameObjects.Quad#reset + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + reset: function () + { + this.resetPosition(); + + this.resetAlpha(); + + return this.resetColors(); + } + +}); + +module.exports = Quad; + + +/***/ }), +/* 129 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasPool = __webpack_require__(23); +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var CONST = __webpack_require__(21); +var GameObject = __webpack_require__(1); +var GetPowerOfTwo = __webpack_require__(248); +var TileSpriteRender = __webpack_require__(700); + +/** + * @classdesc + * [description] + * + * @class TileSprite + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number} width - The width of the Game Object. + * @param {number} height - The height of the Game Object. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var TileSprite = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Size, + Components.Texture, + Components.Tint, + Components.Transform, + Components.Visible, + TileSpriteRender + ], + + initialize: + + function TileSprite (scene, x, y, width, height, texture, frame) + { + var renderer = scene.sys.game.renderer; + + GameObject.call(this, scene, 'TileSprite'); + + /** + * [description] + * + * @name Phaser.GameObjects.TileSprite#tilePositionX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.tilePositionX = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.TileSprite#tilePositionY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.tilePositionY = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.TileSprite#dirty + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.dirty = true; + + /** + * [description] + * + * @name Phaser.GameObjects.TileSprite#tileTexture + * @type {?WebGLTexture} + * @default null + * @since 3.0.0 + */ + this.tileTexture = null; + + /** + * [description] + * + * @name Phaser.GameObjects.TileSprite#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.0.0 + */ + this.renderer = renderer; + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.setSize(width, height); + this.setOriginFromFrame(); + this.initPipeline('TextureTintPipeline'); + + /** + * The next power of two value from the width of the Frame. + * + * @name Phaser.GameObjects.TileSprite#potWidth + * @type {integer} + * @since 3.0.0 + */ + this.potWidth = GetPowerOfTwo(this.frame.width); + + /** + * The next power of two value from the height of the Frame. + * + * @name Phaser.GameObjects.TileSprite#potHeight + * @type {integer} + * @since 3.0.0 + */ + this.potHeight = GetPowerOfTwo(this.frame.height); + + /** + * [description] + * + * @name Phaser.GameObjects.TileSprite#canvasPattern + * @type {?CanvasPattern} + * @default null + * @since 3.0.0 + */ + this.canvasPattern = null; + + /** + * [description] + * + * @name Phaser.GameObjects.TileSprite#canvasBuffer + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvasBuffer = CanvasPool.create2D(null, this.potWidth, this.potHeight); + + /** + * [description] + * + * @name Phaser.GameObjects.TileSprite#canvasBufferCtx + * @type {CanvasRenderingContext2D} + * @since 3.0.0 + */ + this.canvasBufferCtx = this.canvasBuffer.getContext('2d'); + + this.oldFrame = null; + + this.updateTileTexture(); + + if (scene.sys.game.config.renderType === CONST.WEBGL) + { + scene.sys.game.renderer.onContextRestored(function (renderer) + { + var gl = renderer.gl; + + this.tileTexture = null; + this.dirty = true; + this.tileTexture = renderer.createTexture2D(0, gl.LINEAR, gl.LINEAR, gl.REPEAT, gl.REPEAT, gl.RGBA, this.canvasBuffer, this.potWidth, this.potHeight); + }, this); + } + }, + + /** + * Sets {@link Phaser.GameObjects.TileSprite#tilePositionX} and {@link Phaser.GameObjects.TileSprite#tilePositionY}. + * + * @method Phaser.GameObjects.TileSprite#setTilePosition + * @since 3.3.0 + * + * @param {number} [x] - The x position of this sprite's tiling texture. + * @param {number} [y] - The y position of this sprite's tiling texture. + * + * @return {Phaser.GameObjects.TileSprite} This Tile Sprite instance. + */ + setTilePosition: function (x, y) + { + if (x !== undefined) + { + this.tilePositionX = x; + } + + if (y !== undefined) + { + this.tilePositionY = y; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.TileSprite#updateTileTexture + * @since 3.0.0 + */ + updateTileTexture: function () + { + if (!this.dirty && this.oldFrame === this.frame) + { + return; + } + + this.oldFrame = this.frame; + + this.canvasBufferCtx.clearRect(0, 0, this.canvasBuffer.width, this.canvasBuffer.height); + + if (this.renderer.gl) + { + this.canvasBufferCtx.drawImage( + this.frame.source.image, + this.frame.cutX, this.frame.cutY, + this.frame.cutWidth, this.frame.cutHeight, + 0, 0, + this.potWidth, this.potHeight + ); + + this.tileTexture = this.renderer.canvasToTexture(this.canvasBuffer, this.tileTexture, (this.tileTexture === null), this.scaleMode); + } + else + { + this.canvasBuffer.width = this.frame.cutWidth; + this.canvasBuffer.height = this.frame.cutHeight; + this.canvasBufferCtx.drawImage( + this.frame.source.image, + this.frame.cutX, this.frame.cutY, + this.frame.cutWidth, this.frame.cutHeight, + 0, 0, + this.frame.cutWidth, this.frame.cutHeight + ); + + this.canvasPattern = this.canvasBufferCtx.createPattern(this.canvasBuffer, 'repeat'); + } + + this.dirty = false; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.TileSprite#destroy + * @since 3.0.0 + */ + destroy: function () + { + if (this.renderer) + { + this.renderer.deleteTexture(this.tileTexture); + } + + CanvasPool.remove(this.canvasBuffer); + + this.canvasPattern = null; + this.canvasBufferCtx = null; + this.canvasBuffer = null; + + this.renderer = null; + this.visible = false; + } + +}); + +module.exports = TileSprite; + + +/***/ }), +/* 130 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var AddToDOM = __webpack_require__(147); +var CanvasPool = __webpack_require__(23); +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var CONST = __webpack_require__(21); +var GameObject = __webpack_require__(1); +var GetTextSize = __webpack_require__(706); +var GetValue = __webpack_require__(5); +var RemoveFromDOM = __webpack_require__(305); +var TextRender = __webpack_require__(705); +var TextStyle = __webpack_require__(702); + +/** + * @classdesc + * [description] + * + * @class Text + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {(string|string[])} text - The text this Text object will display. + * @param {object} style - The text style configuration object. + */ +var Text = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Tint, + Components.Transform, + Components.Visible, + TextRender + ], + + initialize: + + function Text (scene, x, y, text, style) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + GameObject.call(this, scene, 'Text'); + + this.setPosition(x, y); + this.setOrigin(0, 0); + this.initPipeline('TextureTintPipeline'); + + /** + * The canvas element that the text is rendered to. + * + * @name Phaser.GameObjects.Text#canvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvas = CanvasPool.create(this); + + /** + * The context of the canvas element that the text is rendered to. + * + * @name Phaser.GameObjects.Text#context + * @type {CanvasRenderingContext2D} + * @since 3.0.0 + */ + this.context = this.canvas.getContext('2d'); + + /** + * [description] + * + * @name Phaser.GameObjects.Text#style + * @type {Phaser.GameObjects.Components.TextStyle} + * @since 3.0.0 + */ + this.style = new TextStyle(this, style); + + /** + * [description] + * + * @name Phaser.GameObjects.Text#autoRound + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.autoRound = true; + + /** + * The Regular Expression that is used to split the text up into lines, in + * multi-line text. By default this is `/(?:\r\n|\r|\n)/`. + * You can change this RegExp to be anything else that you may need. + * + * @name Phaser.GameObjects.Text#splitRegExp + * @type {object} + * @since 3.0.0 + */ + this.splitRegExp = /(?:\r\n|\r|\n)/; + + /** + * [description] + * + * @name Phaser.GameObjects.Text#text + * @type {string} + * @since 3.0.0 + */ + this.text = ''; + + /** + * [description] + * + * @name Phaser.GameObjects.Text#resolution + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.resolution = 1; + + /** + * Specify a padding value which is added to the line width and height when calculating the Text size. + * Allows you to add extra spacing if the browser is unable to accurately determine the true font dimensions. + * + * @name Phaser.GameObjects.Text#padding + * @type {{left:number,right:number,top:number,bottom:number}} + * @since 3.0.0 + */ + this.padding = { left: 0, right: 0, top: 0, bottom: 0 }; + + /** + * [description] + * + * @name Phaser.GameObjects.Text#width + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.width = 1; + + /** + * [description] + * + * @name Phaser.GameObjects.Text#height + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.height = 1; + + /** + * [description] + * + * @name Phaser.GameObjects.Text#canvasTexture + * @type {HTMLCanvasElement} + * @default null + * @since 3.0.0 + */ + this.canvasTexture = null; + + /** + * [description] + * + * @name Phaser.GameObjects.Text#dirty + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.dirty = false; + + this.initRTL(); + + if (style && style.padding) + { + this.setPadding(style.padding); + } + + if (style && style.lineSpacing) + { + this._lineSpacing = style.lineSpacing; + } + + this.setText(text); + + if (scene.sys.game.config.renderType === CONST.WEBGL) + { + scene.sys.game.renderer.onContextRestored(function () + { + this.canvasTexture = null; + this.dirty = true; + }, this); + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#initRTL + * @since 3.0.0 + */ + initRTL: function () + { + if (!this.style.rtl) + { + return; + } + + // Here is where the crazy starts. + // + // Due to browser implementation issues, you cannot fillText BiDi text to a canvas + // that is not part of the DOM. It just completely ignores the direction property. + + this.canvas.dir = 'rtl'; + + // Experimental atm, but one day ... + this.context.direction = 'rtl'; + + // Add it to the DOM, but hidden within the parent canvas. + this.canvas.style.display = 'none'; + + AddToDOM(this.canvas, this.scene.sys.canvas); + + // And finally we set the x origin + this.originX = 1; + }, + + /** + * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal + * bounds. + * + * @method Phaser.GameObjects.Text#runWordWrap + * @since 3.0.0 + * + * @param {string} text - The text to perform word wrap detection against. + * + * @return {string} The text after wrapping has been applied. + */ + runWordWrap: function (text) + { + var style = this.style; + + if (style.wordWrapCallback) + { + var wrappedLines = style.wordWrapCallback.call(style.wordWrapCallbackScope, text, this); + + if (Array.isArray(wrappedLines)) + { + wrappedLines = wrappedLines.join('\n'); + } + + return wrappedLines; + } + else if (style.wordWrapWidth) + { + if (style.wordWrapUseAdvanced) + { + return this.advancedWordWrap(text, this.context, this.style.wordWrapWidth); + } + else + { + return this.basicWordWrap(text, this.context, this.style.wordWrapWidth); + } + } + else + { + return text; + } + }, + + /** + * Advanced wrapping algorithm that will wrap words as the line grows longer than its horizontal + * bounds. Consecutive spaces will be collapsed and replaced with a single space. Lines will be + * trimmed of white space before processing. Throws an error if wordWrapWidth is less than a + * single character. + * + * @method Phaser.GameObjects.Text#advancedWordWrap + * @since 3.0.0 + * + * @param {string} text - The text to perform word wrap detection against. + * @param {CanvasRenderingContext2D} context - [description] + * @param {number} wordWrapWidth - [description] + * + * @return {string} The wrapped text. + */ + advancedWordWrap: function (text, context, wordWrapWidth) + { + var output = ''; + + // Condense consecutive spaces and split into lines + var lines = text + .replace(/ +/gi, ' ') + .split(this.splitRegExp); + + var linesCount = lines.length; + + for (var i = 0; i < linesCount; i++) + { + var line = lines[i]; + var out = ''; + + // Trim whitespace + line = line.replace(/^ *|\s*$/gi, ''); + + // If entire line is less than wordWrapWidth append the entire line and exit early + var lineWidth = context.measureText(line).width; + + if (lineWidth < wordWrapWidth) + { + output += line + '\n'; + continue; + } + + // Otherwise, calculate new lines + var currentLineWidth = wordWrapWidth; + + // Split into words + var words = line.split(' '); + + for (var j = 0; j < words.length; j++) + { + var word = words[j]; + var wordWithSpace = word + ' '; + var wordWidth = context.measureText(wordWithSpace).width; + + if (wordWidth > currentLineWidth) + { + // Break word + if (j === 0) + { + // Shave off letters from word until it's small enough + var newWord = wordWithSpace; + + while (newWord.length) + { + newWord = newWord.slice(0, -1); + wordWidth = context.measureText(newWord).width; + + if (wordWidth <= currentLineWidth) + { + break; + } + } + + // If wordWrapWidth is too small for even a single letter, shame user + // failure with a fatal error + if (!newWord.length) + { + throw new Error('This text\'s wordWrapWidth setting is less than a single character!'); + } + + // Replace current word in array with remainder + var secondPart = word.substr(newWord.length); + + words[j] = secondPart; + + // Append first piece to output + out += newWord; + } + + // If existing word length is 0, don't include it + var offset = (words[j].length) ? j : j + 1; + + // Collapse rest of sentence and remove any trailing white space + var remainder = words.slice(offset).join(' ') + .replace(/[ \n]*$/gi, ''); + + // Prepend remainder to next line + lines[i + 1] = remainder + ' ' + (lines[i + 1] || ''); + linesCount = lines.length; + + break; // Processing on this line + + // Append word with space to output + } + else + { + out += wordWithSpace; + currentLineWidth -= wordWidth; + } + } + + // Append processed line to output + output += out.replace(/[ \n]*$/gi, '') + '\n'; + } + + // Trim the end of the string + output = output.replace(/[\s|\n]*$/gi, ''); + + return output; + }, + + /** + * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal + * bounds. Spaces are not collapsed and whitespace is not trimmed. + * + * @method Phaser.GameObjects.Text#basicWordWrap + * @since 3.0.0 + * + * @param {string} text - The text to perform word wrap detection against. + * @param {CanvasRenderingContext2D} context - [description] + * @param {number} wordWrapWidth - [description] + * + * @return {string} The wrapped text. + */ + basicWordWrap: function (text, context, wordWrapWidth) + { + var result = ''; + var lines = text.split(this.splitRegExp); + + for (var i = 0; i < lines.length; i++) + { + var spaceLeft = wordWrapWidth; + var words = lines[i].split(' '); + + for (var j = 0; j < words.length; j++) + { + var wordWidth = context.measureText(words[j]).width; + var wordWidthWithSpace = wordWidth + context.measureText(' ').width; + + if (wordWidthWithSpace > spaceLeft) + { + // Skip printing the newline if it's the first word of the line that is greater + // than the word wrap width. + if (j > 0) + { + result += '\n'; + } + result += words[j] + ' '; + spaceLeft = wordWrapWidth - wordWidth; + } + else + { + spaceLeft -= wordWidthWithSpace; + result += words[j] + ' '; + } + } + + if (i < lines.length - 1) + { + result += '\n'; + } + } + + return result; + }, + + /** + * Runs the given text through this Text objects word wrapping and returns the results as an + * array, where each element of the array corresponds to a wrapped line of text. + * + * @method Phaser.GameObjects.Text#getWrappedText + * @since 3.0.0 + * + * @param {string} text - The text for which the wrapping will be calculated. If unspecified, the Text objects current text will be used. + * + * @return {string[]} An array of strings with the pieces of wrapped text. + */ + getWrappedText: function (text) + { + if (text === undefined) { text = this.text; } + + this.style.syncFont(this.canvas, this.context); + + var wrappedLines = this.runWordWrap(text); + + return wrappedLines.split(this.splitRegExp); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setText + * @since 3.0.0 + * + * @param {(string|string[])} value - The string, or array of strings, to be set as the content of this Text object. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setText: function (value) + { + if (!value && value !== 0) + { + value = ''; + } + + if (Array.isArray(value)) + { + value = value.join('\n'); + } + + if (value !== this.text) + { + this.text = value.toString(); + + this.updateText(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setStyle + * @since 3.0.0 + * + * @param {object} style - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setStyle: function (style) + { + return this.style.setStyle(style); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setFont + * @since 3.0.0 + * + * @param {string} font - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFont: function (font) + { + return this.style.setFont(font); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setFontFamily + * @since 3.0.0 + * + * @param {string} family - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFontFamily: function (family) + { + return this.style.setFontFamily(family); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setFontSize + * @since 3.0.0 + * + * @param {number} size - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFontSize: function (size) + { + return this.style.setFontSize(size); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setFontStyle + * @since 3.0.0 + * + * @param {string} style - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFontStyle: function (style) + { + return this.style.setFontStyle(style); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setFixedSize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFixedSize: function (width, height) + { + return this.style.setFixedSize(width, height); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setBackgroundColor + * @since 3.0.0 + * + * @param {string} color - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setBackgroundColor: function (color) + { + return this.style.setBackgroundColor(color); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setFill + * @since 3.0.0 + * + * @param {string} color - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFill: function (color) + { + return this.style.setFill(color); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setColor + * @since 3.0.0 + * + * @param {string} color - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setColor: function (color) + { + return this.style.setColor(color); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setStroke + * @since 3.0.0 + * + * @param {string} color - [description] + * @param {number} thickness - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setStroke: function (color, thickness) + { + return this.style.setStroke(color, thickness); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setShadow + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {string} color - [description] + * @param {number} blur - [description] + * @param {boolean} shadowStroke - [description] + * @param {boolean} shadowFill - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadow: function (x, y, color, blur, shadowStroke, shadowFill) + { + return this.style.setShadow(x, y, color, blur, shadowStroke, shadowFill); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setShadowOffset + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowOffset: function (x, y) + { + return this.style.setShadowOffset(x, y); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setShadowColor + * @since 3.0.0 + * + * @param {string} color - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowColor: function (color) + { + return this.style.setShadowColor(color); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setShadowBlur + * @since 3.0.0 + * + * @param {number} blur - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowBlur: function (blur) + { + return this.style.setShadowBlur(blur); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setShadowStroke + * @since 3.0.0 + * + * @param {boolean} enabled - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowStroke: function (enabled) + { + return this.style.setShadowStroke(enabled); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setShadowFill + * @since 3.0.0 + * + * @param {boolean} enabled - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowFill: function (enabled) + { + return this.style.setShadowFill(enabled); + }, + + /** + * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width. + * + * @method Phaser.GameObjects.Text#setWordWrapWidth + * @since 3.0.0 + * + * @param {?number} width - The maximum width of a line in pixels. Set to null to remove wrapping. + * @param {boolean} [useAdvancedWrap=false] - Whether or not to use the advanced wrapping + * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, + * spaces and whitespace are left as is. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setWordWrapWidth: function (width, useAdvancedWrap) + { + return this.style.setWordWrapWidth(width, useAdvancedWrap); + }, + + /** + * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback. + * + * @method Phaser.GameObjects.Text#setWordWrapCallback + * @since 3.0.0 + * + * @param {TextStyleWordWrapCallback} callback - A custom function that will be responsible for wrapping the + * text. It will receive two arguments: text (the string to wrap), textObject (this Text + * instance). It should return the wrapped lines either as an array of lines or as a string with + * newline characters in place to indicate where breaks should happen. + * @param {object} [scope=null] - The scope that will be applied when the callback is invoked. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setWordWrapCallback: function (callback, scope) + { + return this.style.setWordWrapCallback(callback, scope); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setAlign + * @since 3.0.0 + * + * @param {string} align - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setAlign: function (align) + { + return this.style.setAlign(align); + }, + + /** + * 'left' can be an object. + * If only 'left' and 'top' are given they are treated as 'x' and 'y' + * + * @method Phaser.GameObjects.Text#setPadding + * @since 3.0.0 + * + * @param {(number|object)} left - [description] + * @param {number} top - [description] + * @param {number} right - [description] + * @param {number} bottom - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setPadding: function (left, top, right, bottom) + { + if (typeof left === 'object') + { + var config = left; + + // If they specify x and/or y this applies to all + var x = GetValue(config, 'x', null); + + if (x !== null) + { + left = x; + right = x; + } + else + { + left = GetValue(config, 'left', 0); + right = GetValue(config, 'right', left); + } + + var y = GetValue(config, 'y', null); + + if (y !== null) + { + top = y; + bottom = y; + } + else + { + top = GetValue(config, 'top', 0); + bottom = GetValue(config, 'bottom', top); + } + } + else + { + if (left === undefined) { left = 0; } + if (top === undefined) { top = left; } + if (right === undefined) { right = left; } + if (bottom === undefined) { bottom = top; } + } + + this.padding.left = left; + this.padding.top = top; + this.padding.right = right; + this.padding.bottom = bottom; + + return this.updateText(); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setMaxLines + * @since 3.0.0 + * + * @param {integer} [max=0] - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setMaxLines: function (max) + { + return this.style.setMaxLines(max); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#updateText + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + updateText: function () + { + var canvas = this.canvas; + var context = this.context; + var style = this.style; + var resolution = this.resolution; + var size = style.metrics; + + style.syncFont(canvas, context); + + var outputText = this.text; + + if (style.wordWrapWidth || style.wordWrapCallback) + { + outputText = this.runWordWrap(this.text); + } + + // Split text into lines + var lines = outputText.split(this.splitRegExp); + + var textSize = GetTextSize(this, size, lines); + + var padding = this.padding; + + var w = textSize.width + padding.left + padding.right; + var h = textSize.height + padding.top + padding.bottom; + + if (style.fixedWidth === 0) + { + this.width = w; + } + + if (style.fixedHeight === 0) + { + this.height = h; + } + + this.updateDisplayOrigin(); + + w *= resolution; + h *= resolution; + + w = Math.max(w, 1); + h = Math.max(h, 1); + + if (canvas.width !== w || canvas.height !== h) + { + canvas.width = w; + canvas.height = h; + style.syncFont(canvas, context); // Resizing resets the context + } + else + { + context.clearRect(0, 0, w, h); + } + + context.save(); + + // context.scale(resolution, resolution); + + if (style.backgroundColor) + { + context.fillStyle = style.backgroundColor; + context.fillRect(0, 0, w, h); + } + + style.syncStyle(canvas, context); + + context.textBaseline = 'alphabetic'; + + // Apply padding + context.translate(padding.left, padding.top); + + var linePositionX; + var linePositionY; + + // Draw text line by line + for (var i = 0; i < textSize.lines; i++) + { + linePositionX = style.strokeThickness / 2; + linePositionY = (style.strokeThickness / 2 + i * textSize.lineHeight) + size.ascent; + + if (i > 0) + { + linePositionY += (textSize.lineSpacing * i); + } + + if (style.rtl) + { + linePositionX = w - linePositionX; + } + else if (style.align === 'right') + { + linePositionX += textSize.width - textSize.lineWidths[i]; + } + else if (style.align === 'center') + { + linePositionX += (textSize.width - textSize.lineWidths[i]) / 2; + } + + if (this.autoRound) + { + linePositionX = Math.round(linePositionX); + linePositionY = Math.round(linePositionY); + } + + if (style.strokeThickness) + { + this.style.syncShadow(context, style.shadowStroke); + + context.strokeText(lines[i], linePositionX, linePositionY); + } + + if (style.color) + { + this.style.syncShadow(context, style.shadowFill); + + context.fillText(lines[i], linePositionX, linePositionY); + } + } + + context.restore(); + + this.dirty = true; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#getTextMetrics + * @since 3.0.0 + * + * @return {object} [description] + */ + getTextMetrics: function () + { + return this.style.getTextMetrics(); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#toJSON + * @since 3.0.0 + * + * @return {object} [description] + */ + toJSON: function () + { + var out = Components.ToJSON(this); + + // Extra Text data is added here + + var data = { + autoRound: this.autoRound, + text: this.text, + style: this.style.toJSON(), + resolution: this.resolution, + padding: { + left: this.padding.left, + right: this.padding.right, + top: this.padding.top, + bottom: this.padding.bottom + } + }; + + out.data = data; + + return out; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#preDestroy + * @since 3.0.0 + */ + preDestroy: function () + { + if (this.style.rtl) + { + RemoveFromDOM(this.canvas); + } + + CanvasPool.remove(this.canvas); + } + +}); + +module.exports = Text; + + +/***/ }), +/* 131 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasPool = __webpack_require__(23); +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var CONST = __webpack_require__(21); +var GameObject = __webpack_require__(1); +var Render = __webpack_require__(711); +var RenderTextureCanvas = __webpack_require__(708); +var RenderTextureWebGL = __webpack_require__(707); + +/** + * @classdesc + * A Render Texture. + * + * @class RenderTexture + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.2.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.MatrixStack + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {integer} [width=32] - The width of the Render Texture. + * @param {integer} [height=32] - The height of the Render Texture. + */ +var RenderTexture = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.MatrixStack, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Size, + Components.Tint, + Components.Transform, + Components.Visible, + Render + ], + + initialize: + + function RenderTexture (scene, x, y, width, height) + { + if (width === undefined) { width = 32; } + if (height === undefined) { height = 32; } + + GameObject.call(this, scene, 'RenderTexture'); + + this.initMatrixStack(); + + this.renderer = scene.sys.game.renderer; + this.globalTint = 0xffffff; + this.globalAlpha = 1.0; + + if (this.renderer.type === CONST.WEBGL) + { + var gl = this.renderer.gl; + this.gl = gl; + this.fill = RenderTextureWebGL.fill; + this.clear = RenderTextureWebGL.clear; + this.draw = RenderTextureWebGL.draw; + this.drawFrame = RenderTextureWebGL.drawFrame; + this.texture = this.renderer.createTexture2D(0, gl.NEAREST, gl.NEAREST, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE, gl.RGBA, null, width, height, false); + this.framebuffer = this.renderer.createFramebuffer(width, height, this.texture, false); + } + else if (this.renderer.type === CONST.CANVAS) + { + this.fill = RenderTextureCanvas.fill; + this.clear = RenderTextureCanvas.clear; + this.draw = RenderTextureCanvas.draw; + this.drawFrame = RenderTextureCanvas.drawFrame; + this.canvas = CanvasPool.create2D(null, width, height); + this.context = this.canvas.getContext('2d'); + } + + this.setPosition(x, y); + this.setSize(width, height); + this.initPipeline('TextureTintPipeline'); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.RenderTexture#destroy + * @since 3.2.0 + */ + destroy: function () + { + GameObject.destroy.call(this); + + if (this.renderer.type === CONST.WEBGL) + { + this.renderer.deleteTexture(this.texture); + this.renderer.deleteFramebuffer(this.framebuffer); + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.RenderTexture#setGlobalTint + * @since 3.2.0 + * + * @param {integer} tint [description] + * + * @return {Phaser.GameObjects.RenderTexture} [description] + */ + setGlobalTint: function (tint) + { + this.globalTint = tint; + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.RenderTexture#setGlobalAlpha + * @since 3.2.0 + * + * @param {float} alpha [description] + * + * @return {Phaser.GameObjects.RenderTexture} [description] + */ + setGlobalAlpha: function (alpha) + { + this.globalAlpha = alpha; + return this; + } + + /** + * Fills the Render Texture with the given color. + * + * @method Phaser.GameObjects.RenderTexture#fill + * @since 3.2.0 + * + * @param {number} rgb - The color to fill the Render Texture with. + * + * @return {Phaser.GameObjects.RenderTexture} This Game Object. + */ + + /** + * Clears the Render Texture. + * + * @method Phaser.GameObjects.RenderTexture#clear + * @since 3.2.0 + * + * @return {Phaser.GameObjects.RenderTexture} This Game Object. + */ + + /** + * Draws a texture frame to the Render Texture at the given position. + * + * @method Phaser.GameObjects.RenderTexture#draw + * @since 3.2.0 + * + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {number} x - The x position to draw the frame at. + * @param {number} y - The y position to draw the frame at. + * + * @return {Phaser.GameObjects.RenderTexture} This Game Object. + */ + +}); + +module.exports = RenderTexture; + + +/***/ }), +/* 132 */ /***/ (function(module, exports) { /** @@ -22936,36 +22831,4171 @@ module.exports = IsSizePowerOfTwo; */ /** - * @namespace Phaser.GameObjects.Graphics.Commands + * [description] + * + * @function Phaser.Utils.Array.GetRandomElement + * @since 3.0.0 + * + * @param {array} array - The array to select the random entry from. + * @param {integer} [start=0] - [description] + * @param {integer} [length=array.length] - [description] + * + * @return {object} A random element from the array, or `null` if no element could be found in the range given. */ +var GetRandomElement = function (array, start, length) +{ + if (start === undefined) { start = 0; } + if (length === undefined) { length = array.length; } -module.exports = { - - ARC: 0, - BEGIN_PATH: 1, - CLOSE_PATH: 2, - FILL_RECT: 3, - LINE_TO: 4, - MOVE_TO: 5, - LINE_STYLE: 6, - FILL_STYLE: 7, - FILL_PATH: 8, - STROKE_PATH: 9, - FILL_TRIANGLE: 10, - STROKE_TRIANGLE: 11, - LINE_FX_TO: 12, - MOVE_FX_TO: 13, - SAVE: 14, - RESTORE: 15, - TRANSLATE: 16, - SCALE: 17, - ROTATE: 18 + var randomIndex = start + Math.floor(Math.random() * length); + return (array[randomIndex] === undefined) ? null : array[randomIndex]; }; +module.exports = GetRandomElement; + /***/ }), -/* 129 */ +/* 133 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var GameObject = __webpack_require__(1); +var GravityWell = __webpack_require__(754); +var List = __webpack_require__(97); +var ParticleEmitter = __webpack_require__(753); +var Render = __webpack_require__(714); + +/** + * @classdesc + * [description] + * + * @class ParticleEmitterManager + * @extends Phaser.GameObjects.Particles.GameObject + * @memberOf Phaser.GameObjects.Particles + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Particles.Components.Depth + * @extends Phaser.GameObjects.Particles.Components.Visible + * @extends Phaser.GameObjects.Particles.Components.Pipeline + * + * @param {Phaser.Scene} scene - [description] + * @param {string} texture - [description] + * @param {(string|integer)} frame - [description] + * @param {Phaser.GameObjects.Particles.ParticleEmitter[]} emitters - [description] + */ +var ParticleEmitterManager = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Depth, + Components.Visible, + Components.Pipeline, + Render + ], + + initialize: + + // frame is optional and can contain the emitters array or object if skipped + function ParticleEmitterManager (scene, texture, frame, emitters) + { + GameObject.call(this, scene, 'ParticleEmitterManager'); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#blendMode + * @type {number} + * @default -1 + * @private + * @since 3.0.0 + */ + this.blendMode = -1; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#timeScale + * @type {float} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#texture + * @type {Phaser.Textures.Texture} + * @default null + * @since 3.0.0 + */ + this.texture = null; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#frame + * @type {Phaser.Textures.Frame} + * @default null + * @since 3.0.0 + */ + this.frame = null; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#frameNames + * @type {Phaser.Textures.Frame[]} + * @since 3.0.0 + */ + this.frameNames = []; + + // frame is optional and can contain the emitters array or object if skipped + if (frame !== null && (typeof frame === 'object' || Array.isArray(frame))) + { + emitters = frame; + frame = null; + } + + this.setTexture(texture, frame); + + this.initPipeline('TextureTintPipeline'); + + /** + * A list of Emitters being managed by this Emitter Manager. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#emitters + * @type {Phaser.Structs.List} + * @since 3.0.0 + */ + this.emitters = new List(this); + + /** + * A list of Gravity Wells being managed by this Emitter Manager. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#wells + * @type {Phaser.Structs.List} + * @since 3.0.0 + */ + this.wells = new List(this); + + if (emitters) + { + // An array of emitter configs? + if (!Array.isArray(emitters)) + { + emitters = [ emitters ]; + } + + for (var i = 0; i < emitters.length; i++) + { + this.createEmitter(emitters[i]); + } + } + }, + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setTexture + * @since 3.0.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. + */ + setTexture: function (key, frame) + { + this.texture = this.scene.sys.textures.get(key); + + return this.setFrame(frame); + }, + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setFrame + * @since 3.0.0 + * + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. + */ + setFrame: function (frame) + { + this.frame = this.texture.get(frame); + + this.frameNames = this.texture.getFramesFromTextureSource(this.frame.sourceIndex); + + this.defaultFrame = this.frame; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setEmitterFrames + * @since 3.0.0 + * + * @param {(Phaser.Textures.Frame|Phaser.Textures.Frame[])} frames - [description] + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. + */ + setEmitterFrames: function (frames, emitter) + { + if (!Array.isArray(frames)) + { + frames = [ frames ]; + } + + var out = emitter.frames; + + out.length = 0; + + for (var i = 0; i < frames.length; i++) + { + var frame = frames[i]; + + if (this.frameNames.indexOf(frame) !== -1) + { + out.push(this.texture.get(frame)); + } + } + + if (out.length > 0) + { + emitter.defaultFrame = out[0]; + } + else + { + emitter.defaultFrame = this.defaultFrame; + } + + return this; + }, + + /** + * Adds an existing Particle Emitter to this Manager. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#addEmitter + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Particle Emitter to add to this Emitter Manager. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} The Particle Emitter that was added to this Emitter Manager. + */ + addEmitter: function (emitter) + { + return this.emitters.add(emitter); + }, + + /** + * Creates a new Particle Emitter object, adds it to this Manager and returns a reference to it. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#createEmitter + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} The Particle Emitter that was created. + */ + createEmitter: function (config) + { + return this.addEmitter(new ParticleEmitter(this, config)); + }, + + /** + * Adds an existing Gravity Well object to this Manager. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#addGravityWell + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.GravityWell} well - The Gravity Well to add to this Emitter Manager. + * + * @return {Phaser.GameObjects.Particles.GravityWell} The Gravity Well that was added to this Emitter Manager. + */ + addGravityWell: function (well) + { + return this.wells.add(well); + }, + + /** + * Creates a new Gravity Well, adds it to this Manager and returns a reference to it. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#createGravityWell + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Particles.GravityWell} The Gravity Well that was created. + */ + createGravityWell: function (config) + { + return this.addGravityWell(new GravityWell(config)); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#emitParticle + * @since 3.0.0 + * + * @param {integer} count - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. + */ + emitParticle: function (count, x, y) + { + var emitters = this.emitters.list; + + for (var i = 0; i < emitters.length; i++) + { + var emitter = emitters[i]; + + if (emitter.active) + { + emitter.emitParticle(count, x, y); + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#emitParticleAt + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {integer} count - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. + */ + emitParticleAt: function (x, y, count) + { + return this.emitParticle(count, x, y); + }, + + /** + * Pauses this Emitter Manager. + * + * This has the effect of pausing all emitters, and all particles of those emitters, currently under its control. + * + * The particles will still render, but they will not have any of their logic updated. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#pause + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. + */ + pause: function () + { + this.active = false; + + return this; + }, + + /** + * Resumes this Emitter Manager, should it have been previously paused. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#resume + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. + */ + resume: function () + { + this.active = true; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#getProcessors + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.GravityWell[]} [description] + */ + getProcessors: function () + { + return this.wells.getAll('active', true); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#preUpdate + * @since 3.0.0 + * + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + preUpdate: function (time, delta) + { + // Scale the delta + delta *= this.timeScale; + + var emitters = this.emitters.list; + + for (var i = 0; i < emitters.length; i++) + { + var emitter = emitters[i]; + + if (emitter.active) + { + emitter.preUpdate(time, delta); + } + } + } + +}); + +module.exports = ParticleEmitterManager; + + +/***/ }), +/* 134 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +/** + * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse based on the given angle. + * + * @function Phaser.Geom.Ellipse.CircumferencePoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on. + * @param {number} angle - The angle from the center of the Ellipse to the circumference to return the point from. Given in radians. + * @param {(Phaser.Geom.Point|object)} [out] - A Point, or point-like object, to store the results in. If not given a Point will be created. + * + * @return {(Phaser.Geom.Point|object)} A Point object where the `x` and `y` properties are the point on the circumference. + */ +var CircumferencePoint = function (ellipse, angle, out) +{ + if (out === undefined) { out = new Point(); } + + var halfWidth = ellipse.width / 2; + var halfHeight = ellipse.height / 2; + + out.x = ellipse.x + halfWidth * Math.cos(angle); + out.y = ellipse.y + halfHeight * Math.sin(angle); + + return out; +}; + +module.exports = CircumferencePoint; + + +/***/ }), +/* 135 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Contains = __webpack_require__(74); +var GetPoint = __webpack_require__(268); +var GetPoints = __webpack_require__(267); +var Random = __webpack_require__(162); + +/** + * @classdesc + * An Ellipse object. + * + * This is a geometry object, containing numerical values and related methods to inspect and modify them. + * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. + * To render an Ellipse you should look at the capabilities of the Graphics class. + * + * @class Ellipse + * @memberOf Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of the center of the ellipse. + * @param {number} [y=0] - The y position of the center of the ellipse. + * @param {number} [width=0] - The width of the ellipse. + * @param {number} [height=0] - The height of the ellipse. + */ +var Ellipse = new Class({ + + initialize: + + function Ellipse (x, y, width, height) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 0; } + if (height === undefined) { height = 0; } + + /** + * The x position of the center of the ellipse. + * + * @name Phaser.Geom.Ellipse#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = x; + + /** + * The y position of the center of the ellipse. + * + * @name Phaser.Geom.Ellipse#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = y; + + /** + * The width of the ellipse. + * + * @name Phaser.Geom.Ellipse#width + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.width = width; + + /** + * The height of the ellipse. + * + * @name Phaser.Geom.Ellipse#height + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.height = height; + }, + + /** + * Check to see if the Ellipse contains the given x / y coordinates. + * + * @method Phaser.Geom.Ellipse#contains + * @since 3.0.0 + * + * @param {number} x - The x coordinate to check within the ellipse. + * @param {number} y - The y coordinate to check within the ellipse. + * + * @return {boolean} True if the coordinates are within the ellipse, otherwise false. + */ + contains: function (x, y) + { + return Contains(this, x, y); + }, + + /** + * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse + * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point + * at 180 degrees around the circle. + * + * @method Phaser.Geom.Ellipse#getPoint + * @since 3.0.0 + * + * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. + * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. + * + * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the ellipse. + */ + getPoint: function (position, point) + { + return GetPoint(this, position, point); + }, + + /** + * Returns an array of Point objects containing the coordinates of the points around the circumference of the Ellipse, + * based on the given quantity or stepRate values. + * + * @method Phaser.Geom.Ellipse#getPoints + * @since 3.0.0 + * + * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate. + * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. + * + * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the circumference of the ellipse. + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * Returns a uniformly distributed random point from anywhere within the given Ellipse. + * + * @method Phaser.Geom.Ellipse#getRandomPoint + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} [point] - A Point or point-like object to set the random `x` and `y` values in. + * + * @return {(Phaser.Geom.Point|object)} A Point object with the random values set in the `x` and `y` properties. + */ + getRandomPoint: function (point) + { + return Random(this, point); + }, + + /** + * Sets the x, y, width and height of this ellipse. + * + * @method Phaser.Geom.Ellipse#setTo + * @since 3.0.0 + * + * @param {number} x - The x position of the center of the ellipse. + * @param {number} y - The y position of the center of the ellipse. + * @param {number} width - The width of the ellipse. + * @param {number} height - The height of the ellipse. + * + * @return {Phaser.Geom.Ellipse} This Ellipse object. + */ + setTo: function (x, y, width, height) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + + return this; + }, + + /** + * Sets this Ellipse to be empty with a width and height of zero. + * Does not change its position. + * + * @method Phaser.Geom.Ellipse#setEmpty + * @since 3.0.0 + * + * @return {Phaser.Geom.Ellipse} This Ellipse object. + */ + setEmpty: function () + { + this.width = 0; + this.height = 0; + + return this; + }, + + /** + * Sets the position of this Ellipse. + * + * @method Phaser.Geom.Ellipse#setPosition + * @since 3.0.0 + * + * @param {number} x - The x position of the center of the ellipse. + * @param {number} y - The y position of the center of the ellipse. + * + * @return {Phaser.Geom.Ellipse} This Ellipse object. + */ + setPosition: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * Sets the size of this Ellipse. + * Does not change its position. + * + * @method Phaser.Geom.Ellipse#setSize + * @since 3.0.0 + * + * @param {number} width - The width of the ellipse. + * @param {number} [height=width] - The height of the ellipse. + * + * @return {Phaser.Geom.Ellipse} This Ellipse object. + */ + setSize: function (width, height) + { + if (height === undefined) { height = width; } + + this.width = width; + this.height = height; + + return this; + }, + + /** + * Checks to see if the Ellipse is empty: has a width or height equal to zero. + * + * @method Phaser.Geom.Ellipse#isEmpty + * @since 3.0.0 + * + * @return {boolean} True if the Ellipse is empty, otherwise false. + */ + isEmpty: function () + { + return (this.width <= 0 || this.height <= 0); + }, + + /** + * Returns the minor radius of the ellipse. Also known as the Semi Minor Axis. + * + * @method Phaser.Geom.Ellipse#getMinorRadius + * @since 3.0.0 + * + * @return {number} The minor radius. + */ + getMinorRadius: function () + { + return Math.min(this.width, this.height) / 2; + }, + + /** + * Returns the major radius of the ellipse. Also known as the Semi Major Axis. + * + * @method Phaser.Geom.Ellipse#getMajorRadius + * @since 3.0.0 + * + * @return {number} The major radius. + */ + getMajorRadius: function () + { + return Math.max(this.width, this.height) / 2; + }, + + /** + * The left position of the Ellipse. + * + * @name Phaser.Geom.Ellipse#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () + { + return this.x - (this.width / 2); + }, + + set: function (value) + { + this.x = value + (this.width / 2); + } + + }, + + /** + * The right position of the Ellipse. + * + * @name Phaser.Geom.Ellipse#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return this.x + (this.width / 2); + }, + + set: function (value) + { + this.x = value - (this.width / 2); + } + + }, + + /** + * The top position of the Ellipse. + * + * @name Phaser.Geom.Ellipse#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return this.y - (this.height / 2); + }, + + set: function (value) + { + this.y = value + (this.height / 2); + } + + }, + + /** + * The bottom position of the Ellipse. + * + * @name Phaser.Geom.Ellipse#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return this.y + (this.height / 2); + }, + + set: function (value) + { + this.y = value - (this.height / 2); + } + + } + +}); + +module.exports = Ellipse; + + +/***/ }), +/* 136 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Camera = __webpack_require__(157); +var Class = __webpack_require__(0); +var Commands = __webpack_require__(144); +var Components = __webpack_require__(13); +var Ellipse = __webpack_require__(269); +var GameObject = __webpack_require__(1); +var GetValue = __webpack_require__(5); +var MATH_CONST = __webpack_require__(16); +var Render = __webpack_require__(759); + +/** + * @classdesc + * [description] + * + * @class Graphics + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * @extends Phaser.GameObjects.Components.ScrollFactor + * + * @param {Phaser.Scene} scene - [description] + * @param {object} options - [description] + */ +var Graphics = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Pipeline, + Components.Transform, + Components.Visible, + Components.ScrollFactor, + Render + ], + + initialize: + + function Graphics (scene, options) + { + var x = GetValue(options, 'x', 0); + var y = GetValue(options, 'y', 0); + + GameObject.call(this, scene, 'Graphics'); + + this.setPosition(x, y); + this.initPipeline('FlatTintPipeline'); + + /** + * [description] + * + * @name Phaser.GameObjects.Graphics#displayOriginX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.displayOriginX = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.Graphics#displayOriginY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.displayOriginY = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.Graphics#commandBuffer + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.commandBuffer = []; + + /** + * [description] + * + * @name Phaser.GameObjects.Graphics#defaultFillColor + * @type {number} + * @default -1 + * @since 3.0.0 + */ + this.defaultFillColor = -1; + + /** + * [description] + * + * @name Phaser.GameObjects.Graphics#defaultFillAlpha + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.defaultFillAlpha = 1; + + /** + * [description] + * + * @name Phaser.GameObjects.Graphics#defaultStrokeWidth + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.defaultStrokeWidth = 1; + + /** + * [description] + * + * @name Phaser.GameObjects.Graphics#defaultStrokeColor + * @type {number} + * @default -1 + * @since 3.0.0 + */ + this.defaultStrokeColor = -1; + + /** + * [description] + * + * @name Phaser.GameObjects.Graphics#defaultStrokeAlpha + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.defaultStrokeAlpha = 1; + + /** + * [description] + * + * @name Phaser.GameObjects.Graphics#_lineWidth + * @type {number} + * @private + * @since 3.0.0 + */ + this._lineWidth = 1.0; + + this.setDefaultStyles(options); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#setDefaultStyles + * @since 3.0.0 + * + * @param {object} options - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + setDefaultStyles: function (options) + { + if (GetValue(options, 'lineStyle', null)) + { + this.defaultStrokeWidth = GetValue(options, 'lineStyle.width', 1); + this.defaultStrokeColor = GetValue(options, 'lineStyle.color', 0xffffff); + this.defaultStrokeAlpha = GetValue(options, 'lineStyle.alpha', 1); + + this.lineStyle(this.defaultStrokeWidth, this.defaultStrokeColor, this.defaultStrokeAlpha); + } + + if (GetValue(options, 'fillStyle', null)) + { + this.defaultFillColor = GetValue(options, 'fillStyle.color', 0xffffff); + this.defaultFillAlpha = GetValue(options, 'fillStyle.alpha', 1); + + this.fillStyle(this.defaultFillColor, this.defaultFillAlpha); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#lineStyle + * @since 3.0.0 + * + * @param {number} lineWidth - [description] + * @param {number} color - [description] + * @param {float} [alpha=1] - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + lineStyle: function (lineWidth, color, alpha) + { + if (alpha === undefined) { alpha = 1; } + + this.commandBuffer.push( + Commands.LINE_STYLE, + lineWidth, color, alpha + ); + + this._lineWidth = lineWidth; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillStyle + * @since 3.0.0 + * + * @param {number} color - [description] + * @param {float} [alpha=1] - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillStyle: function (color, alpha) + { + if (alpha === undefined) { alpha = 1; } + + this.commandBuffer.push( + Commands.FILL_STYLE, + color, alpha + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#beginPath + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + beginPath: function () + { + this.commandBuffer.push( + Commands.BEGIN_PATH + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#closePath + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + closePath: function () + { + this.commandBuffer.push( + Commands.CLOSE_PATH + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillPath + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillPath: function () + { + this.commandBuffer.push( + Commands.FILL_PATH + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#strokePath + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokePath: function () + { + this.commandBuffer.push( + Commands.STROKE_PATH + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillCircleShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillCircleShape: function (circle) + { + return this.fillCircle(circle.x, circle.y, circle.radius); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#strokeCircleShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeCircleShape: function (circle) + { + return this.strokeCircle(circle.x, circle.y, circle.radius); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillCircle + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} radius - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillCircle: function (x, y, radius) + { + this.beginPath(); + this.arc(x, y, radius, 0, MATH_CONST.PI2); + this.fillPath(); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#strokeCircle + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} radius - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeCircle: function (x, y, radius) + { + this.beginPath(); + this.arc(x, y, radius, 0, MATH_CONST.PI2); + this.strokePath(); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillRectShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillRectShape: function (rect) + { + return this.fillRect(rect.x, rect.y, rect.width, rect.height); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#strokeRectShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeRectShape: function (rect) + { + return this.strokeRect(rect.x, rect.y, rect.width, rect.height); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillRect + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillRect: function (x, y, width, height) + { + this.commandBuffer.push( + Commands.FILL_RECT, + x, y, width, height + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#strokeRect + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeRect: function (x, y, width, height) + { + var lineWidthHalf = this._lineWidth / 2; + var minx = x - lineWidthHalf; + var maxx = x + lineWidthHalf; + + this.beginPath(); + this.moveTo(x, y); + this.lineTo(x, y + height); + this.strokePath(); + + this.beginPath(); + this.moveTo(x + width, y); + this.lineTo(x + width, y + height); + this.strokePath(); + + this.beginPath(); + this.moveTo(minx, y); + this.lineTo(maxx + width, y); + this.strokePath(); + + this.beginPath(); + this.moveTo(minx, y + height); + this.lineTo(maxx + width, y + height); + this.strokePath(); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillPointShape + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} point - [description] + * @param {number} [size=1] - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillPointShape: function (point, size) + { + return this.fillPoint(point.x, point.y, size); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillPoint + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} [size=1] - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillPoint: function (x, y, size) + { + if (!size || size < 1) + { + size = 1; + } + else + { + x -= (size / 2); + y -= (size / 2); + } + + this.commandBuffer.push( + Commands.FILL_RECT, + x, y, size, size + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillTriangleShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillTriangleShape: function (triangle) + { + return this.fillTriangle(triangle.x1, triangle.y1, triangle.x2, triangle.y2, triangle.x3, triangle.y3); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#strokeTriangleShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeTriangleShape: function (triangle) + { + return this.strokeTriangle(triangle.x1, triangle.y1, triangle.x2, triangle.y2, triangle.x3, triangle.y3); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillTriangle + * @since 3.0.0 + * + * @param {number} x0 - [description] + * @param {number} y0 - [description] + * @param {number} x1 - [description] + * @param {number} y1 - [description] + * @param {number} x2 - [description] + * @param {number} y2 - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillTriangle: function (x0, y0, x1, y1, x2, y2) + { + this.commandBuffer.push( + Commands.FILL_TRIANGLE, + x0, y0, x1, y1, x2, y2 + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#strokeTriangle + * @since 3.0.0 + * + * @param {number} x0 - [description] + * @param {number} y0 - [description] + * @param {number} x1 - [description] + * @param {number} y1 - [description] + * @param {number} x2 - [description] + * @param {number} y2 - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeTriangle: function (x0, y0, x1, y1, x2, y2) + { + this.commandBuffer.push( + Commands.STROKE_TRIANGLE, + x0, y0, x1, y1, x2, y2 + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#strokeLineShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeLineShape: function (line) + { + return this.lineBetween(line.x1, line.y1, line.x2, line.y2); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#lineBetween + * @since 3.0.0 + * + * @param {number} x1 - [description] + * @param {number} y1 - [description] + * @param {number} x2 - [description] + * @param {number} y2 - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + lineBetween: function (x1, y1, x2, y2) + { + this.beginPath(); + this.moveTo(x1, y1); + this.lineTo(x2, y2); + this.strokePath(); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#lineTo + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + lineTo: function (x, y) + { + this.commandBuffer.push( + Commands.LINE_TO, + x, y + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#moveTo + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + moveTo: function (x, y) + { + this.commandBuffer.push( + Commands.MOVE_TO, + x, y + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#lineFxTo + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} rgb - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + lineFxTo: function (x, y, width, rgb) + { + this.commandBuffer.push( + Commands.LINE_FX_TO, + x, y, width, rgb, 1 + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#moveFxTo + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} rgb - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + moveFxTo: function (x, y, width, rgb) + { + this.commandBuffer.push( + Commands.MOVE_FX_TO, + x, y, width, rgb, 1 + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#strokePoints + * @since 3.0.0 + * + * @param {(array|Phaser.Geom.Point[])} points - [description] + * @param {boolean} [autoClose=false] - [description] + * @param {integer} [endIndex] - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokePoints: function (points, autoClose, endIndex) + { + if (autoClose === undefined) { autoClose = false; } + if (endIndex === undefined) { endIndex = points.length; } + + this.beginPath(); + + this.moveTo(points[0].x, points[0].y); + + for (var i = 1; i < endIndex; i++) + { + this.lineTo(points[i].x, points[i].y); + } + + if (autoClose) + { + this.lineTo(points[0].x, points[0].y); + } + + this.strokePath(); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillPoints + * @since 3.0.0 + * + * @param {(array|Phaser.Geom.Point[])} points - [description] + * @param {boolean} [autoClose=false] - [description] + * @param {integer} [endIndex] - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillPoints: function (points, autoClose, endIndex) + { + if (autoClose === undefined) { autoClose = false; } + if (endIndex === undefined) { endIndex = points.length; } + + this.beginPath(); + + this.moveTo(points[0].x, points[0].y); + + for (var i = 1; i < endIndex; i++) + { + this.lineTo(points[i].x, points[i].y); + } + + if (autoClose) + { + this.lineTo(points[0].x, points[0].y); + } + + this.fillPath(); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#strokeEllipseShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - [description] + * @param {integer} [smoothness=32] - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeEllipseShape: function (ellipse, smoothness) + { + if (smoothness === undefined) { smoothness = 32; } + + var points = ellipse.getPoints(smoothness); + + return this.strokePoints(points, true); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#strokeEllipse + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {integer} [smoothness=32] - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeEllipse: function (x, y, width, height, smoothness) + { + if (smoothness === undefined) { smoothness = 32; } + + var ellipse = new Ellipse(x, y, width, height); + + var points = ellipse.getPoints(smoothness); + + return this.strokePoints(points, true); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillEllipseShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - [description] + * @param {integer} [smoothness=32] - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillEllipseShape: function (ellipse, smoothness) + { + if (smoothness === undefined) { smoothness = 32; } + + var points = ellipse.getPoints(smoothness); + + return this.fillPoints(points, true); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillEllipse + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {integer} [smoothness=32] - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillEllipse: function (x, y, width, height, smoothness) + { + if (smoothness === undefined) { smoothness = 32; } + + var ellipse = new Ellipse(x, y, width, height); + + var points = ellipse.getPoints(smoothness); + + return this.fillPoints(points, true); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#arc + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} radius - [description] + * @param {number} startAngle - [description] + * @param {number} endAngle - [description] + * @param {boolean} anticlockwise - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + arc: function (x, y, radius, startAngle, endAngle, anticlockwise) + { + this.commandBuffer.push( + Commands.ARC, + x, y, radius, startAngle, endAngle, anticlockwise + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#save + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + save: function () + { + this.commandBuffer.push( + Commands.SAVE + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#restore + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + restore: function () + { + this.commandBuffer.push( + Commands.RESTORE + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#translate + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + translate: function (x, y) + { + this.commandBuffer.push( + Commands.TRANSLATE, + x, y + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#scale + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + scale: function (x, y) + { + this.commandBuffer.push( + Commands.SCALE, + x, y + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#rotate + * @since 3.0.0 + * + * @param {number} radians - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + rotate: function (radians) + { + this.commandBuffer.push( + Commands.ROTATE, + radians + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#clear + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + clear: function () + { + this.commandBuffer.length = 0; + + if (this.defaultFillColor > -1) + { + this.fillStyle(this.defaultFillColor, this.defaultFillAlpha); + } + + if (this.defaultStrokeColor > -1) + { + this.lineStyle(this.defaultStrokeWidth, this.defaultStrokeColor, this.defaultStrokeAlpha); + } + + return this; + }, + + /** + * If key is a string it'll generate a new texture using it and add it into the + * Texture Manager (assuming no key conflict happens). + * + * If key is a Canvas it will draw the texture to that canvas context. Note that it will NOT + * automatically upload it to the GPU in WebGL mode. + * + * @method Phaser.GameObjects.Graphics#generateTexture + * @since 3.0.0 + * + * @param {(string|HTMLCanvasElement)} key - [description] + * @param {integer} [width] - [description] + * @param {integer} [height] - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + generateTexture: function (key, width, height) + { + var sys = this.scene.sys; + + if (width === undefined) { width = sys.game.config.width; } + if (height === undefined) { height = sys.game.config.height; } + + Graphics.TargetCamera.setViewport(0, 0, width, height); + Graphics.TargetCamera.scrollX = this.x; + Graphics.TargetCamera.scrollY = this.y; + + var texture; + var ctx; + + if (typeof key === 'string') + { + if (sys.textures.exists(key)) + { + // Key is a string, it DOES exist in the Texture Manager AND is a canvas, so draw to it + + texture = sys.textures.get(key); + + var src = texture.getSourceImage(); + + if (src instanceof HTMLCanvasElement) + { + ctx = src.getContext('2d'); + } + } + else + { + // Key is a string and doesn't exist in the Texture Manager, so generate and save it + + texture = sys.textures.createCanvas(key, width, height); + + ctx = texture.getSourceImage().getContext('2d'); + } + } + else if (key instanceof HTMLCanvasElement) + { + // Key is a Canvas, so draw to it + + ctx = key.getContext('2d'); + } + + if (ctx) + { + this.renderCanvas(sys.game.renderer, this, 0, Graphics.TargetCamera, ctx); + + if (sys.game.renderer.gl && texture) + { + texture.source[0].glTexture = sys.game.renderer.canvasToTexture(ctx.canvas, texture.source[0].glTexture, true, 0); + } + } + + return this; + } + +}); + +/** + * A Camera used specifically by the Graphics system for rendering to textures. + * + * @name Phaser.GameObjects.Graphics.TargetCamera + * @type {Phaser.Cameras.Scene2D.Camera} + * @since 3.1.0 + */ +Graphics.TargetCamera = new Camera(0, 0, 0, 0); + +module.exports = Graphics; + + +/***/ }), +/* 137 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var GameObject = __webpack_require__(1); +var GetBitmapTextSize = __webpack_require__(271); +var Render = __webpack_require__(771); + +/** + * @callback DisplayCallback + * + * @param {object} display - [description] + * @param {{topLeft:number,topRight:number,bottomLeft:number,bottomRight:number}} display.tint - [description] + * @param {number} display.index - [description] + * @param {number} display.charCode - [description] + * @param {number} display.x - [description] + * @param {number} display.y - [description] + * @param {number} display.scale - [description] + * @param {number} display.rotation - [description] + * @param {[type]} display.data - [description] + */ + +/** + * @classdesc + * [description] + * + * @class DynamicBitmapText + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. + * @param {number} [x=0] - The x coordinate of this Game Object in world space. + * @param {number} [y=0] - The y coordinate of this Game Object in world space. + * @param {string} font - [description] + * @param {(string|string[])} [text] - [description] + * @param {number} [size] - [description] + */ +var DynamicBitmapText = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Origin, + Components.Pipeline, + Components.ScrollFactor, + Components.Texture, + Components.Tint, + Components.Transform, + Components.Visible, + Render + ], + + initialize: + + function DynamicBitmapText (scene, x, y, font, text, size) + { + if (text === undefined) { text = ''; } + + GameObject.call(this, scene, 'DynamicBitmapText'); + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#font + * @type {string} + * @since 3.0.0 + */ + this.font = font; + + var entry = this.scene.sys.cache.bitmapFont.get(font); + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#fontData + * @type {object} + * @since 3.0.0 + */ + this.fontData = entry.data; + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#text + * @type {string} + * @since 3.0.0 + */ + this.text = (Array.isArray(text)) ? text.join('\n') : text; + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#fontSize + * @type {number} + * @since 3.0.0 + */ + this.fontSize = size || this.fontData.size; + + this.setTexture(entry.texture, entry.frame); + this.setPosition(x, y); + this.setOrigin(0, 0); + this.initPipeline('TextureTintPipeline'); + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#_bounds + * @type {TextBounds} + * @private + * @since 3.0.0 + */ + this._bounds = this.getTextBounds(); + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#scrollX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.scrollX = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#scrollY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.scrollY = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#cropWidth + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.cropWidth = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#cropHeight + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.cropHeight = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#displayCallback; + * @type {DisplayCallback} + * @since 3.0.0 + */ + this.displayCallback; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.DynamicBitmapText#setSize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setSize: function (width, height) + { + this.cropWidth = width; + this.cropHeight = height; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.DynamicBitmapText#setDisplayCallback + * @since 3.0.0 + * + * @param {DisplayCallback} callback - [description] + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setDisplayCallback: function (callback) + { + this.displayCallback = callback; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.DynamicBitmapText#setFontSize + * @since 3.0.0 + * + * @param {number} size - [description] + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setFontSize: function (size) + { + this.fontSize = size; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.DynamicBitmapText#setText + * @since 3.0.0 + * + * @param {(string|string[])} value - The string, or array of strings, to be set as the content of this BitmapText. + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setText: function (value) + { + if (!value && value !== 0) + { + value = ''; + } + + if (Array.isArray(value)) + { + value = value.join('\n'); + } + + if (value !== this.text) + { + this.text = value.toString(); + + this.updateDisplayOrigin(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.DynamicBitmapText#setScrollX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setScrollX: function (value) + { + this.scrollX = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.DynamicBitmapText#setScrollY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setScrollY: function (value) + { + this.scrollY = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.DynamicBitmapText#getTextBounds + * @since 3.0.0 + * + * @param {boolean} round - [description] + * + * @return {TextBounds} [description] + */ + getTextBounds: function (round) + { + // local = the BitmapText based on fontSize and 0x0 coords + // global = the BitmapText, taking into account scale and world position + + this._bounds = GetBitmapTextSize(this, round); + + return this._bounds; + }, + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#width + * @type {number} + * @since 3.0.0 + */ + width: { + + get: function () + { + this.getTextBounds(false); + return this._bounds.global.width; + } + + }, + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#height + * @type {number} + * @since 3.0.0 + */ + height: { + + get: function () + { + this.getTextBounds(false); + return this._bounds.global.height; + } + + }, + + /** + * [description] + * + * @method Phaser.GameObjects.DynamicBitmapText#toJSON + * @since 3.0.0 + * + * @return {JSONGameObject.} [description] + */ + toJSON: function () + { + var out = Components.ToJSON(this); + + // Extra data is added here + + var data = { + font: this.font, + text: this.text, + fontSize: this.fontSize + }; + + out.data = data; + + return out; + } + +}); + +module.exports = DynamicBitmapText; + + +/***/ }), +/* 138 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BlitterRender = __webpack_require__(775); +var Bob = __webpack_require__(772); +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var Frame = __webpack_require__(141); +var GameObject = __webpack_require__(1); +var List = __webpack_require__(97); + +/** + * @callback BlitterFromCallback + * + * @param {Phaser.GameObjects.Blitter} blitter - [description] + * @param {integer} index - [description] + */ + +/** + * @classdesc + * A Blitter Game Object. + * + * The Blitter Game Object is a special kind of container that creates, updates and manages Bob objects. + * Bobs are designed for rendering speed rather than flexibility. They consist of a texture, or frame from a texture, + * a position and an alpha value. You cannot scale or rotate them. They use a batched drawing method for speed + * during rendering. + * + * A Blitter Game Object has one texture bound to it. Bobs created by the Blitter can use any Frame from this + * Texture to render with, but they cannot use any other Texture. It is this single texture-bind that allows + * them their speed. + * + * If you have a need to blast a large volume of frames around the screen then Blitter objects are well worth + * investigating. They are especially useful for using as a base for your own special effects systems. + * + * @class Blitter + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. + * @param {number} [x=0] - The x coordinate of this Game Object in world space. + * @param {number} [y=0] - The y coordinate of this Game Object in world space. + * @param {string} [texture='__DEFAULT'] - The key of the texture this Game Object will use for rendering. The Texture must already exist in the Texture Manager. + * @param {(string|integer)} [frame=0] - The Frame of the Texture that this Game Object will use. Only set if the Texture has multiple frames, such as a Texture Atlas or Sprite Sheet. + */ +var Blitter = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Size, + Components.Texture, + Components.Transform, + Components.Visible, + BlitterRender + ], + + initialize: + + function Blitter (scene, x, y, texture, frame) + { + GameObject.call(this, scene, 'Blitter'); + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.initPipeline('TextureTintPipeline'); + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter#children + * @type {Phaser.Structs.List} + * @since 3.0.0 + */ + this.children = new List(); + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter#renderList + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.renderList = []; + + this.dirty = false; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter#create + * @since 3.0.0 + * + * @param {number} x - The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param {number} y - The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param {(string|integer|Phaser.Textures.Frame)} [frame] - The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. + * @param {boolean} [visible=true] - Should the created Bob render or not? + * @param {integer} [index] - The position in the Blitters Display List to add the new Bob at. Defaults to the top of the list. + * + * @return {Phaser.GameObjects.Blitter.Bob} The newly created Bob object. + */ + create: function (x, y, frame, visible, index) + { + if (visible === undefined) { visible = true; } + if (index === undefined) { index = this.children.length; } + + if (frame === undefined) + { + frame = this.frame; + } + else if (!(frame instanceof Frame)) + { + frame = this.texture.get(frame); + } + + var bob = new Bob(this, x, y, frame, visible); + + this.children.addAt(bob, index, false); + + this.dirty = true; + + return bob; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter#createFromCallback + * @since 3.0.0 + * + * @param {BlitterFromCallback} callback - The callback to invoke after creating a bob. It will be sent two arguments: The Bob and the index of the Bob. + * @param {integer} quantity - The quantity of Bob objects to create. + * @param {string} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture. + * @param {boolean} [visible=true] - [description] + * + * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that were created. + */ + createFromCallback: function (callback, quantity, frame, visible) + { + var bobs = this.createMultiple(quantity, frame, visible); + + for (var i = 0; i < bobs.length; i++) + { + var bob = bobs[i]; + + callback.call(this, bob, i); + } + + return bobs; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter#createMultiple + * @since 3.0.0 + * + * @param {integer} quantity - The quantity of Bob objects to create. + * @param {string} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture. + * @param {boolean} [visible=true] - [description] + * + * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that were created. + */ + createMultiple: function (quantity, frame, visible) + { + if (frame === undefined) { frame = this.frame.name; } + if (visible === undefined) { visible = true; } + + if (!Array.isArray(frame)) + { + frame = [ frame ]; + } + + var bobs = []; + var _this = this; + + frame.forEach(function (singleFrame) + { + for (var i = 0; i < quantity; i++) + { + bobs.push(_this.create(0, 0, singleFrame, visible)); + } + }); + + return bobs; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter#childCanRender + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Blitter.Bob} child - [description] + * + * @return {boolean} [description] + */ + childCanRender: function (child) + { + return (child.visible && child.alpha > 0); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter#getRenderList + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that will be rendered this frame. + */ + getRenderList: function () + { + if (this.dirty) + { + this.renderList = this.children.list.filter(this.childCanRender, this); + this.dirty = false; + } + + return this.renderList; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter#clear + * @since 3.0.0 + */ + clear: function () + { + this.children.removeAll(); + this.dirty = true; + } + +}); + +module.exports = Blitter; + + +/***/ }), +/* 139 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var GameObject = __webpack_require__(1); +var GetBitmapTextSize = __webpack_require__(271); +var ParseFromAtlas = __webpack_require__(780); +var ParseRetroFont = __webpack_require__(779); +var Render = __webpack_require__(778); + +/** + * @typedef {object} TextBounds + * + * @property {object} local - [description] + * @property {number} local.x - [description] + * @property {number} local.y - [description] + * @property {number} local.width - [description] + * @property {number} local.height - [description] + * @property {object} global - [description] + * @property {number} global.x - [description] + * @property {number} global.y - [description] + * @property {number} global.width - [description] + * @property {number} global.height - [description] + */ + +/** + * @typedef {object} JSONBitmapText + * + * @property {string} font - [description] + * @property {string} text - [description] + * @property {number} fontSize - [description] + */ + +/** + * @classdesc + * [description] + * + * @class BitmapText + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. + * @param {number} [x=0] - The x coordinate of this Game Object in world space. + * @param {number} [y=0] - The y coordinate of this Game Object in world space. + * @param {string} font - [description] + * @param {(string|string[])} [text] - [description] + * @param {number} [size] - [description] + */ +var BitmapText = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Texture, + Components.Tint, + Components.Transform, + Components.Visible, + Render + ], + + initialize: + + function BitmapText (scene, x, y, font, text, size) + { + if (text === undefined) { text = ''; } + + GameObject.call(this, scene, 'BitmapText'); + + /** + * [description] + * + * @name Phaser.GameObjects.BitmapText#font + * @type {string} + * @since 3.0.0 + */ + this.font = font; + + var entry = this.scene.sys.cache.bitmapFont.get(font); + + /** + * [description] + * + * @name Phaser.GameObjects.BitmapText#fontData + * @type {object} + * @since 3.0.0 + */ + this.fontData = entry.data; + + /** + * [description] + * + * @name Phaser.GameObjects.BitmapText#text + * @type {string} + * @since 3.0.0 + */ + this.text = (Array.isArray(text)) ? text.join('\n') : text; + + /** + * [description] + * + * @name Phaser.GameObjects.BitmapText#fontSize + * @type {number} + * @since 3.0.0 + */ + this.fontSize = size || this.fontData.size; + + this.setTexture(entry.texture, entry.frame); + this.setPosition(x, y); + this.setOrigin(0, 0); + this.initPipeline('TextureTintPipeline'); + + /** + * [description] + * + * @name Phaser.GameObjects.BitmapText#_bounds + * @type {TextBounds} + * @private + * @since 3.0.0 + */ + this._bounds = this.getTextBounds(); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.BitmapText#setFontSize + * @since 3.0.0 + * + * @param {number} size - [description] + * + * @return {Phaser.GameObjects.BitmapText} This Game Object. + */ + setFontSize: function (size) + { + this.fontSize = size; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.BitmapText#setText + * @since 3.0.0 + * + * @param {(string|string[])} value - The string, or array of strings, to be set as the content of this BitmapText. + * + * @return {Phaser.GameObjects.BitmapText} This Game Object. + */ + setText: function (value) + { + if (!value && value !== 0) + { + value = ''; + } + + if (Array.isArray(value)) + { + value = value.join('\n'); + } + + if (value !== this.text) + { + this.text = value.toString(); + + this.updateDisplayOrigin(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.BitmapText#getTextBounds + * @since 3.0.0 + * + * @param {boolean} round - [description] + * + * @return {TextBounds} [description] + */ + getTextBounds: function (round) + { + // local = the BitmapText based on fontSize and 0x0 coords + // global = the BitmapText, taking into account scale and world position + + this._bounds = GetBitmapTextSize(this, round); + + return this._bounds; + }, + + /** + * [description] + * + * @name Phaser.GameObjects.BitmapText#width + * @type {number} + * @since 3.0.0 + */ + width: { + + get: function () + { + this.getTextBounds(false); + + return this._bounds.global.width; + } + + }, + + /** + * [description] + * + * @name Phaser.GameObjects.BitmapText#height + * @type {number} + * @since 3.0.0 + */ + height: { + + get: function () + { + this.getTextBounds(false); + + return this._bounds.global.height; + } + + }, + + /** + * [description] + * + * @method Phaser.GameObjects.BitmapText#toJSON + * @since 3.0.0 + * + * @return {JSONGameObject.} [description] + */ + toJSON: function () + { + var out = Components.ToJSON(this); + + // Extra data is added here + + var data = { + font: this.font, + text: this.text, + fontSize: this.fontSize + }; + + out.data = data; + + return out; + } + +}); + +BitmapText.ParseRetroFont = ParseRetroFont; +BitmapText.ParseFromAtlas = ParseFromAtlas; + +module.exports = BitmapText; + + +/***/ }), +/* 140 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetAdvancedValue = __webpack_require__(8); + +/** + * Adds an Animation component to a Sprite and populates it based on the given config. + * + * @function Phaser.GameObjects.BuildGameObjectAnimation + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Sprite} sprite - [description] + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Sprite} The updated Sprite. + */ +var BuildGameObjectAnimation = function (sprite, config) +{ + var animConfig = GetAdvancedValue(config, 'anims', null); + + if (animConfig === null) + { + return sprite; + } + + if (typeof animConfig === 'string') + { + // { anims: 'key' } + sprite.anims.play(animConfig); + } + else if (typeof animConfig === 'object') + { + // { anims: { + // key: string + // startFrame: [string|integer] + // delay: [float] + // repeat: [integer] + // repeatDelay: [float] + // yoyo: [boolean] + // play: [boolean] + // delayedPlay: [boolean] + // } + // } + + var anims = sprite.anims; + + var key = GetAdvancedValue(animConfig, 'key', undefined); + var startFrame = GetAdvancedValue(animConfig, 'startFrame', undefined); + + var delay = GetAdvancedValue(animConfig, 'delay', 0); + var repeat = GetAdvancedValue(animConfig, 'repeat', 0); + var repeatDelay = GetAdvancedValue(animConfig, 'repeatDelay', 0); + var yoyo = GetAdvancedValue(animConfig, 'yoyo', false); + + var play = GetAdvancedValue(animConfig, 'play', false); + var delayedPlay = GetAdvancedValue(animConfig, 'delayedPlay', 0); + + anims.delay(delay); + anims.repeat(repeat); + anims.repeatDelay(repeatDelay); + anims.yoyo(yoyo); + + if (play) + { + anims.play(key, startFrame); + } + else if (delayedPlay > 0) + { + anims.delayedPlay(delayedPlay, key, startFrame); + } + else + { + anims.load(key); + } + } + + return sprite; +}; + +module.exports = BuildGameObjectAnimation; + + +/***/ }), +/* 141 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Extend = __webpack_require__(18); + +/** + * @classdesc + * A Frame is a section of a Texture. + * + * @class Frame + * @memberOf Phaser.Textures + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture this Frame is a part of. + * @param {(integer|string)} name - The name of this Frame. The name is unique within the Texture. + * @param {integer} sourceIndex - The index of the TextureSource that this Frame is a part of. + * @param {number} x - The x coordinate of the top-left of this Frame. + * @param {number} y - The y coordinate of the top-left of this Frame. + * @param {number} width - The width of this Frame. + * @param {number} height - The height of this Frame. + */ +var Frame = new Class({ + + initialize: + + function Frame (texture, name, sourceIndex, x, y, width, height) + { + /** + * The Texture this Frame is a part of. + * + * @name Phaser.Textures.Frame#texture + * @type {Phaser.Textures.Texture} + * @since 3.0.0 + */ + this.texture = texture; + + /** + * The name of this Frame. + * The name is unique within the Texture. + * + * @name Phaser.Textures.Frame#name + * @type {string} + * @since 3.0.0 + */ + this.name = name; + + /** + * The TextureSource this Frame is part of. + * + * @name Phaser.Textures.Frame#source + * @type {Phaser.Textures.TextureSource} + * @since 3.0.0 + */ + this.source = texture.source[sourceIndex]; + + /** + * The index of the TextureSource in the Texture sources array. + * + * @name Phaser.Textures.Frame#sourceIndex + * @type {integer} + * @since 3.0.0 + */ + this.sourceIndex = sourceIndex; + + /** + * X position within the source image to cut from. + * + * @name Phaser.Textures.Frame#cutX + * @type {integer} + * @since 3.0.0 + */ + this.cutX = x; + + /** + * Y position within the source image to cut from. + * + * @name Phaser.Textures.Frame#cutY + * @type {integer} + * @since 3.0.0 + */ + this.cutY = y; + + /** + * The width of the area in the source image to cut. + * + * @name Phaser.Textures.Frame#cutWidth + * @type {integer} + * @since 3.0.0 + */ + this.cutWidth = width; + + /** + * The height of the area in the source image to cut. + * + * @name Phaser.Textures.Frame#cutHeight + * @type {integer} + * @since 3.0.0 + */ + this.cutHeight = height; + + /** + * The X rendering offset of this Frame, taking trim into account. + * + * @name Phaser.Textures.Frame#x + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.x = 0; + + /** + * The Y rendering offset of this Frame, taking trim into account. + * + * @name Phaser.Textures.Frame#y + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.y = 0; + + /** + * The rendering width of this Frame, taking trim into account. + * + * @name Phaser.Textures.Frame#width + * @type {integer} + * @since 3.0.0 + */ + this.width = width; + + /** + * The rendering height of this Frame, taking trim into account. + * + * @name Phaser.Textures.Frame#height + * @type {integer} + * @since 3.0.0 + */ + this.height = height; + + /** + * Half the width, floored. + * Precalculated for the renderer. + * + * @name Phaser.Textures.Frame#halfWidth + * @type {integer} + * @since 3.0.0 + */ + this.halfWidth = Math.floor(width * 0.5); + + /** + * Half the height, floored. + * Precalculated for the renderer. + * + * @name Phaser.Textures.Frame#halfHeight + * @type {integer} + * @since 3.0.0 + */ + this.halfHeight = Math.floor(height * 0.5); + + /** + * The x center of this frame, floored. + * + * @name Phaser.Textures.Frame#centerX + * @type {integer} + * @since 3.0.0 + */ + this.centerX = Math.floor(width / 2); + + /** + * The y center of this frame, floored. + * + * @name Phaser.Textures.Frame#centerY + * @type {integer} + * @since 3.0.0 + */ + this.centerY = Math.floor(height / 2); + + /** + * The horizontal pivot point of this Frame. + * + * @name Phaser.Textures.Frame#pivotX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.pivotX = 0; + + /** + * The vertical pivot point of this Frame. + * + * @name Phaser.Textures.Frame#pivotY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.pivotY = 0; + + /** + * Does this Frame have a custom pivot point? + * + * @name Phaser.Textures.Frame#customPivot + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customPivot = false; + + /** + * **CURRENTLY UNSUPPORTED** + * + * Is this frame is rotated or not in the Texture? + * Rotation allows you to use rotated frames in texture atlas packing. + * It has nothing to do with Sprite rotation. + * + * @name Phaser.Textures.Frame#rotated + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.rotated = false; + + /** + * Over-rides the Renderer setting. + * -1 = use Renderer Setting + * 0 = No rounding + * 1 = Round + * + * @name Phaser.Textures.Frame#autoRound + * @type {integer} + * @default -1 + * @since 3.0.0 + */ + this.autoRound = -1; + + /** + * Any Frame specific custom data can be stored here. + * + * @name Phaser.Textures.Frame#customData + * @type {object} + * @since 3.0.0 + */ + this.customData = {}; + + /** + * The un-modified source frame, trim and UV data. + * + * @name Phaser.Textures.Frame#data + * @type {object} + * @private + * @since 3.0.0 + */ + this.data = { + cut: { + x: x, + y: y, + w: width, + h: height, + r: x + width, + b: y + height + }, + trim: false, + sourceSize: { + w: width, + h: height + }, + spriteSourceSize: { + x: 0, + y: 0, + w: width, + h: height + }, + uvs: { + x0: 0, + y0: 0, + x1: 0, + y1: 0, + x2: 0, + y2: 0, + x3: 0, + y3: 0 + }, + radius: 0.5 * Math.sqrt(width * width + height * height), + drawImage: { + sx: x, + sy: y, + sWidth: width, + sHeight: height, + dWidth: width, + dHeight: height + } + }; + + this.updateUVs(); + }, + + /** + * If the frame was trimmed when added to the Texture Atlas, this records the trim and source data. + * + * @method Phaser.Textures.Frame#setTrim + * @since 3.0.0 + * + * @param {number} actualWidth - The width of the frame before being trimmed. + * @param {number} actualHeight - The height of the frame before being trimmed. + * @param {number} destX - The destination X position of the trimmed frame for display. + * @param {number} destY - The destination Y position of the trimmed frame for display. + * @param {number} destWidth - The destination width of the trimmed frame for display. + * @param {number} destHeight - The destination height of the trimmed frame for display. + * + * @return {Phaser.Textures.Frame} This Frame object. + */ + setTrim: function (actualWidth, actualHeight, destX, destY, destWidth, destHeight) + { + var data = this.data; + var ss = data.spriteSourceSize; + + // Store actual values + + data.trim = true; + + data.sourceSize.w = actualWidth; + data.sourceSize.h = actualHeight; + + ss.x = destX; + ss.y = destY; + ss.w = destWidth; + ss.h = destHeight; + + // Adjust properties + this.x = destX; + this.y = destY; + + this.width = destWidth; + this.height = destHeight; + + this.halfWidth = destWidth * 0.5; + this.halfHeight = destHeight * 0.5; + + this.centerX = Math.floor(destWidth / 2); + this.centerY = Math.floor(destHeight / 2); + + return this.updateUVs(); + }, + + /** + * Updates the internal WebGL UV cache and the drawImage cache. + * + * @method Phaser.Textures.Frame#updateUVs + * @since 3.0.0 + * + * @return {Phaser.Textures.Frame} This Frame object. + */ + updateUVs: function () + { + var cx = this.cutX; + var cy = this.cutY; + var cw = this.cutWidth; + var ch = this.cutHeight; + + // Canvas data + + var cd = this.data.drawImage; + + cd.sWidth = cw; + cd.sHeight = ch; + cd.dWidth = cw; + cd.dHeight = ch; + + // WebGL data + + var tw = this.source.width; + var th = this.source.height; + var uvs = this.data.uvs; + + uvs.x0 = cx / tw; + uvs.y0 = cy / th; + + uvs.x1 = cx / tw; + uvs.y1 = (cy + ch) / th; + + uvs.x2 = (cx + cw) / tw; + uvs.y2 = (cy + ch) / th; + + uvs.x3 = (cx + cw) / tw; + uvs.y3 = cy / th; + + return this; + }, + + /** + * Updates the internal WebGL UV cache. + * + * @method Phaser.Textures.Frame#updateUVsInverted + * @since 3.0.0 + * + * @return {Phaser.Textures.Frame} This Frame object. + */ + updateUVsInverted: function () + { + var tw = this.source.width; + var th = this.source.height; + var uvs = this.data.uvs; + + uvs.x3 = (this.cutX + this.cutHeight) / tw; + uvs.y3 = (this.cutY + this.cutWidth) / th; + + uvs.x2 = this.cutX / tw; + uvs.y2 = (this.cutY + this.cutWidth) / th; + + uvs.x1 = this.cutX / tw; + uvs.y1 = this.cutY / th; + + uvs.x0 = (this.cutX + this.cutHeight) / tw; + uvs.y0 = this.cutY / th; + + return this; + }, + + /** + * Clones this Frame into a new Frame object. + * + * @method Phaser.Textures.Frame#clone + * @since 3.0.0 + * + * @return {Phaser.Textures.Frame} A clone of this Frame. + */ + clone: function () + { + var clone = new Frame(this.texture, this.name, this.sourceIndex); + + clone.cutX = this.cutX; + clone.cutY = this.cutY; + clone.cutWidth = this.cutWidth; + clone.cutHeight = this.cutHeight; + + clone.x = this.x; + clone.y = this.y; + + clone.width = this.width; + clone.height = this.height; + + clone.halfWidth = this.halfWidth; + clone.halfHeight = this.halfHeight; + + clone.centerX = this.centerX; + clone.centerY = this.centerY; + + clone.rotated = this.rotated; + + clone.data = Extend(true, clone.data, this.data); + + clone.updateUVs(); + + return clone; + }, + + /** + * Destroys this Frames references. + * + * @method Phaser.Textures.Frame#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.texture = null; + + this.source = null; + }, + + /** + * The width of the Frame in its un-trimmed, un-padded state, as prepared in the art package, + * before being packed. + * + * @name Phaser.Textures.Frame#realWidth + * @type {number} + * @readOnly + * @since 3.0.0 + */ + realWidth: { + + get: function () + { + return this.data.sourceSize.w; + } + + }, + + /** + * The height of the Frame in its un-trimmed, un-padded state, as prepared in the art package, + * before being packed. + * + * @name Phaser.Textures.Frame#realHeight + * @type {number} + * @readOnly + * @since 3.0.0 + */ + realHeight: { + + get: function () + { + return this.data.sourceSize.h; + } + + }, + + /** + * The UV data for this Frame. + * + * @name Phaser.Textures.Frame#uvs + * @type {object} + * @readOnly + * @since 3.0.0 + */ + uvs: { + + get: function () + { + return this.data.uvs; + } + + }, + + /** + * The radius of the Frame (derived from sqrt(w * w + h * h) / 2) + * + * @name Phaser.Textures.Frame#radius + * @type {number} + * @readOnly + * @since 3.0.0 + */ + radius: { + + get: function () + { + return this.data.radius; + } + + }, + + /** + * Is the Frame trimmed or not? + * + * @name Phaser.Textures.Frame#trimmed + * @type {boolean} + * @readOnly + * @since 3.0.0 + */ + trimmed: { + + get: function () + { + return this.data.trim; + } + + }, + + /** + * The Canvas drawImage data object. + * + * @name Phaser.Textures.Frame#canvasData + * @type {object} + * @readOnly + * @since 3.0.0 + */ + canvasData: { + + get: function () + { + return this.data.drawImage; + } + + } + +}); + +module.exports = Frame; + + +/***/ }), +/* 142 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(75); +var GetPhysicsPlugins = __webpack_require__(797); +var GetScenePlugins = __webpack_require__(796); +var Plugins = __webpack_require__(303); +var Settings = __webpack_require__(284); + +/** + * @classdesc + * The Scene Systems class. + * + * This class is available from within a Scene under the property `sys`. + * It is responsible for managing all of the plugins a Scene has running, including the display list, and + * handling the update step and renderer. It also contains references to global systems belonging to Game. + * + * @class Systems + * @memberOf Phaser.Scenes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene that owns this Systems instance. + * @param {(string|SettingsConfig)} config - Scene specific configuration settings. + */ +var Systems = new Class({ + + initialize: + + function Systems (scene, config) + { + /** + * [description] + * + * @name Phaser.Scenes.Systems#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#config + * @type {(string|SettingsConfig)} + * @since 3.0.0 + */ + this.config = config; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#settings + * @type {SettingsObject} + * @since 3.0.0 + */ + this.settings = Settings.create(config); + + /** + * A handy reference to the Scene canvas / context. + * + * @name Phaser.Scenes.Systems#canvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvas; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#context + * @type {CanvasRenderingContext2D} + * @since 3.0.0 + */ + this.context; + + // Global Systems - these are single-instance global managers that belong to Game + + /** + * [description] + * + * @name Phaser.Scenes.Systems#anims + * @type {Phaser.Animations.AnimationManager} + * @since 3.0.0 + */ + this.anims; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#cache + * @type {Phaser.Cache.CacheManager} + * @since 3.0.0 + */ + this.cache; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#plugins + * @type {Phaser.Plugins.PluginManager} + * @since 3.0.0 + */ + this.plugins; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#registry + * @type {Phaser.Data.DataManager} + * @since 3.0.0 + */ + this.registry; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#sound + * @type {Phaser.Sound.BaseSoundManager} + * @since 3.0.0 + */ + this.sound; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#textures + * @type {Phaser.Textures.TextureManager} + * @since 3.0.0 + */ + this.textures; + + // Core Plugins - these are non-optional Scene plugins, needed by lots of the other systems + + /** + * [description] + * + * @name Phaser.Scenes.Systems#add + * @type {Phaser.GameObjects.GameObjectFactory} + * @since 3.0.0 + */ + this.add; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#cameras + * @type {Phaser.Cameras.Scene2D.CameraManager} + * @since 3.0.0 + */ + this.cameras; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#displayList + * @type {null} + * @since 3.0.0 + */ + this.displayList; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#events + * @type {EventEmitter} + * @since 3.0.0 + */ + this.events; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#make + * @type {Phaser.GameObjects.GameObjectCreator} + * @since 3.0.0 + */ + this.make; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#scenePlugin + * @type {Phaser.Scenes.ScenePlugin} + * @since 3.0.0 + */ + this.scenePlugin; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#updateList + * @type {Phaser.GameObjects.UpdateList} + * @since 3.0.0 + */ + this.updateList; + }, + + /** + * [description] + * + * @method Phaser.Scenes.Systems#init + * @since 3.0.0 + * + * @param {Phaser.Game} game - A reference to the Phaser Game + */ + init: function (game) + { + this.settings.status = CONST.INIT; + + this.game = game; + + this.canvas = game.canvas; + this.context = game.context; + + var pluginManager = game.plugins; + + this.plugins = pluginManager; + + pluginManager.installGlobal(this, Plugins.Global); + + pluginManager.installLocal(this, Plugins.CoreScene); + + pluginManager.installLocal(this, GetScenePlugins(this)); + + pluginManager.installLocal(this, GetPhysicsPlugins(this)); + + this.events.emit('boot', this); + + this.settings.isBooted = true; + }, + + /** + * [description] + * + * @method Phaser.Scenes.Systems#install + * @private + * @since 3.0.0 + * + * @param {array} plugin - An array of plugins to install into this Scene. + */ + install: function (plugin) + { + if (!Array.isArray(plugin)) + { + plugin = [ plugin ]; + } + + this.plugins.installLocal(this, plugin); + }, + + /** + * [description] + * + * @method Phaser.Scenes.Systems#step + * @since 3.0.0 + * + * @param {number} time - [description] + * @param {number} delta - [description] + */ + step: function (time, delta) + { + this.events.emit('preupdate', time, delta); + + this.events.emit('update', time, delta); + + this.scene.update.call(this.scene, time, delta); + + this.events.emit('postupdate', time, delta); + }, + + /** + * [description] + * + * @method Phaser.Scenes.Systems#render + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + */ + render: function (renderer) + { + var displayList = this.displayList; + + displayList.depthSort(); + + this.cameras.render(renderer, displayList); + + this.events.emit('render', renderer); + }, + + /** + * Force a sort of the display list on the next render. + * + * @method Phaser.Scenes.Systems#queueDepthSort + * @since 3.0.0 + */ + queueDepthSort: function () + { + this.displayList.queueDepthSort(); + }, + + /** + * Immediately sorts the display list if the flag is set. + * + * @method Phaser.Scenes.Systems#depthSort + * @since 3.0.0 + */ + depthSort: function () + { + this.displayList.depthSort(); + }, + + /** + * Pause this Scene. + * A paused Scene still renders, it just doesn't run ANY of its update handlers or systems. + * + * @method Phaser.Scenes.Systems#pause + * @since 3.0.0 + * + * @return {Phaser.Scenes.Systems} This Systems object. + */ + pause: function () + { + if (this.settings.active) + { + this.settings.status = CONST.PAUSED; + + this.settings.active = false; + + this.events.emit('pause', this); + } + + return this; + }, + + /** + * Resume this Scene. + * + * @method Phaser.Scenes.Systems#resume + * @since 3.0.0 + * + * @return {Phaser.Scenes.Systems} This Systems object. + */ + resume: function () + { + if (!this.settings.active) + { + this.settings.status = CONST.RUNNING; + + this.settings.active = true; + + this.events.emit('resume', this); + } + + return this; + }, + + /** + * Send this Scene to sleep. + * + * A sleeping Scene doesn't run it's update step or render anything, but it also isn't destroyed, + * or have any of its systems or children removed, meaning it can be re-activated at any point. + * + * @method Phaser.Scenes.Systems#sleep + * @since 3.0.0 + * + * @return {Phaser.Scenes.Systems} This Systems object. + */ + sleep: function () + { + this.settings.status = CONST.SLEEPING; + + this.settings.active = false; + this.settings.visible = false; + + this.events.emit('sleep', this); + + return this; + }, + + /** + * Wake-up this Scene if it was previously asleep. + * + * @method Phaser.Scenes.Systems#wake + * @since 3.0.0 + * + * @return {Phaser.Scenes.Systems} This Systems object. + */ + wake: function () + { + this.settings.status = CONST.RUNNING; + + this.settings.active = true; + this.settings.visible = true; + + this.events.emit('wake', this); + + return this; + }, + + /** + * Is this Scene sleeping? + * + * @method Phaser.Scenes.Systems#isSleeping + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isSleeping: function () + { + return (this.settings.status === CONST.SLEEPING); + }, + + /** + * Is this Scene active? + * + * @method Phaser.Scenes.Systems#isActive + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isActive: function () + { + return (this.settings.status === CONST.RUNNING); + }, + + /** + * Is this Scene visible and rendering? + * + * @method Phaser.Scenes.Systems#isVisible + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isVisible: function () + { + return this.settings.visible; + }, + + /** + * [description] + * + * @method Phaser.Scenes.Systems#setVisible + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.Scenes.Systems} This Systems object. + */ + setVisible: function (value) + { + this.settings.visible = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.Systems#setActive + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.Scenes.Systems} This Systems object. + */ + setActive: function (value) + { + if (value) + { + return this.resume(); + } + else + { + return this.pause(); + } + }, + + /** + * Start this Scene running and rendering. + * + * @method Phaser.Scenes.Systems#start + * @since 3.0.0 + * + * @param {object} data - [description] + */ + start: function (data) + { + this.settings.status = CONST.START; + + this.settings.data = data; + + this.settings.active = true; + this.settings.visible = true; + + this.events.emit('start', this); + }, + + /** + * Called automatically by the SceneManager if the Game resizes. + * Dispatches an event you can respond to in your game code. + * + * @method Phaser.Scenes.Systems#resize + * @since 3.2.0 + * + * @param {number} width - The new width of the game. + * @param {number} height - The new height of the game. + */ + resize: function (width, height) + { + this.events.emit('resize', width, height); + }, + + /** + * Shutdown this Scene and send a shutdown event to all of its systems. + * + * @method Phaser.Scenes.Systems#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.settings.status = CONST.SHUTDOWN; + + this.settings.active = false; + this.settings.visible = false; + + this.events.emit('shutdown', this); + }, + + /** + * Destroy this Scene and send a destroy event all of its systems. + * + * @method Phaser.Scenes.Systems#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.settings.status = CONST.DESTROYED; + + this.settings.active = false; + this.settings.visible = false; + + this.events.emit('destroy', this); + } + +}); + +module.exports = Systems; + + +/***/ }), +/* 143 */ /***/ (function(module, exports) { /** @@ -23540,4132 +27570,7 @@ module.exports = { /***/ }), -/* 130 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(83); -var GetPhysicsPlugins = __webpack_require__(530); -var GetScenePlugins = __webpack_require__(531); -var Plugins = __webpack_require__(236); -var Settings = __webpack_require__(255); - -/** - * @classdesc - * The Scene Systems class. - * - * This class is available from within a Scene under the property `sys`. - * It is responsible for managing all of the plugins a Scene has running, including the display list, and - * handling the update step and renderer. It also contains references to global systems belonging to Game. - * - * @class Systems - * @memberOf Phaser.Scenes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene that owns this Systems instance. - * @param {object} config - Scene specific configuration settings. - */ -var Systems = new Class({ - - initialize: - - function Systems (scene, config) - { - /** - * [description] - * - * @name Phaser.Scenes.Systems#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#config - * @type {object} - * @since 3.0.0 - */ - this.config = config; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#settings - * @type {[type]} - * @since 3.0.0 - */ - this.settings = Settings.create(config); - - /** - * A handy reference to the Scene canvas / context. - * - * @name Phaser.Scenes.Systems#canvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.canvas; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#context - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.context; - - // Global Systems - these are single-instance global managers that belong to Game - - /** - * [description] - * - * @name Phaser.Scenes.Systems#anims - * @type {Phaser.Animations.AnimationManager} - * @since 3.0.0 - */ - this.anims; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#cache - * @type {Phaser.Cache.CacheManager} - * @since 3.0.0 - */ - this.cache; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#plugins - * @type {Phaser.Plugins.PluginManager} - * @since 3.0.0 - */ - this.plugins; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#registry - * @type {[type]} - * @since 3.0.0 - */ - this.registry; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#sound - * @type {Phaser.Sound.BaseSoundManager} - * @since 3.0.0 - */ - this.sound; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#textures - * @type {Phaser.Textures.TextureManager} - * @since 3.0.0 - */ - this.textures; - - // Core Plugins - these are non-optional Scene plugins, needed by lots of the other systems - - /** - * [description] - * - * @name Phaser.Scenes.Systems#add - * @type {Phaser.GameObjects.GameObjectFactory} - * @since 3.0.0 - */ - this.add; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#cameras - * @type {Phaser.Cameras.Scene2D.CameraManager} - * @since 3.0.0 - */ - this.cameras; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#displayList - * @type {null} - * @since 3.0.0 - */ - this.displayList; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#events - * @type {EventEmitter} - * @since 3.0.0 - */ - this.events; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#make - * @type {Phaser.GameObjects.GameObjectCreator} - * @since 3.0.0 - */ - this.make; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#scenePlugin - * @type {Phaser.Scenes.ScenePlugin} - * @since 3.0.0 - */ - this.scenePlugin; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#updateList - * @type {[type]} - * @since 3.0.0 - */ - this.updateList; - }, - - /** - * [description] - * - * @method Phaser.Scenes.Systems#init - * @since 3.0.0 - * - * @param {Phaser.Game} game - A reference to the Phaser Game - */ - init: function (game) - { - this.settings.status = CONST.INIT; - - this.game = game; - - this.canvas = game.canvas; - this.context = game.context; - - var pluginManager = game.plugins; - - this.plugins = pluginManager; - - pluginManager.installGlobal(this, Plugins.Global); - - pluginManager.installLocal(this, Plugins.CoreScene); - - pluginManager.installLocal(this, GetScenePlugins(this)); - - pluginManager.installLocal(this, GetPhysicsPlugins(this)); - - this.events.emit('boot', this); - - this.settings.isBooted = true; - }, - - /** - * [description] - * - * @method Phaser.Scenes.Systems#install - * @private - * @since 3.0.0 - * - * @param {array} plugin - An array of plugins to install into this Scene. - */ - install: function (plugin) - { - if (!Array.isArray(plugin)) - { - plugin = [ plugin ]; - } - - this.plugins.installLocal(this, plugin); - }, - - /** - * [description] - * - * @method Phaser.Scenes.Systems#step - * @since 3.0.0 - * - * @param {number} time - [description] - * @param {number} delta - [description] - */ - step: function (time, delta) - { - this.events.emit('preupdate', time, delta); - - this.events.emit('update', time, delta); - - this.scene.update.call(this.scene, time, delta); - - this.events.emit('postupdate', time, delta); - }, - - /** - * [description] - * - * @method Phaser.Scenes.Systems#render - * @since 3.0.0 - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer} renderer - [description] - */ - render: function (renderer) - { - var displayList = this.displayList; - - displayList.depthSort(); - - this.cameras.render(renderer, displayList); - - this.events.emit('render', renderer); - }, - - /** - * Force a sort of the display list on the next render. - * - * @method Phaser.Scenes.Systems#queueDepthSort - * @since 3.0.0 - */ - queueDepthSort: function () - { - this.displayList.queueDepthSort(); - }, - - /** - * Immediately sorts the display list if the flag is set. - * - * @method Phaser.Scenes.Systems#depthSort - * @since 3.0.0 - */ - depthSort: function () - { - this.displayList.depthSort(); - }, - - /** - * Pause this Scene. - * A paused Scene still renders, it just doesn't run ANY of its update handlers or systems. - * - * @method Phaser.Scenes.Systems#pause - * @since 3.0.0 - * - * @return {Phaser.Scenes.Systems} This Systems object. - */ - pause: function () - { - if (this.settings.active) - { - this.settings.status = CONST.PAUSED; - - this.settings.active = false; - - this.events.emit('pause', this); - } - - return this; - }, - - /** - * Resume this Scene. - * - * @method Phaser.Scenes.Systems#resume - * @since 3.0.0 - * - * @return {Phaser.Scenes.Systems} This Systems object. - */ - resume: function () - { - if (!this.settings.active) - { - this.settings.status = CONST.RUNNING; - - this.settings.active = true; - - this.events.emit('resume', this); - } - - return this; - }, - - /** - * Send this Scene to sleep. - * - * A sleeping Scene doesn't run it's update step or render anything, but it also isn't destroyed, - * or have any of its systems or children removed, meaning it can be re-activated at any point. - * - * @method Phaser.Scenes.Systems#sleep - * @since 3.0.0 - * - * @return {Phaser.Scenes.Systems} This Systems object. - */ - sleep: function () - { - this.settings.status = CONST.SLEEPING; - - this.settings.active = false; - this.settings.visible = false; - - this.events.emit('sleep', this); - - return this; - }, - - /** - * Wake-up this Scene if it was previously asleep. - * - * @method Phaser.Scenes.Systems#wake - * @since 3.0.0 - * - * @return {Phaser.Scenes.Systems} This Systems object. - */ - wake: function () - { - this.settings.status = CONST.RUNNING; - - this.settings.active = true; - this.settings.visible = true; - - this.events.emit('wake', this); - - return this; - }, - - /** - * Is this Scene sleeping? - * - * @method Phaser.Scenes.Systems#isSleeping - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isSleeping: function () - { - return (this.settings.status === CONST.SLEEPING); - }, - - /** - * Is this Scene active? - * - * @method Phaser.Scenes.Systems#isActive - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isActive: function () - { - return (this.settings.status === CONST.RUNNING); - }, - - /** - * Is this Scene visible and rendering? - * - * @method Phaser.Scenes.Systems#isVisible - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isVisible: function () - { - return this.settings.visible; - }, - - /** - * [description] - * - * @method Phaser.Scenes.Systems#setVisible - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {Phaser.Scenes.Systems} This Systems object. - */ - setVisible: function (value) - { - this.settings.visible = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.Systems#setActive - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {Phaser.Scenes.Systems} This Systems object. - */ - setActive: function (value) - { - if (value) - { - return this.resume(); - } - else - { - return this.pause(); - } - }, - - /** - * Start this Scene running and rendering. - * - * @method Phaser.Scenes.Systems#start - * @since 3.0.0 - * - * @param {object} data - [description] - */ - start: function (data) - { - this.settings.status = CONST.START; - - this.settings.data = data; - - this.settings.active = true; - this.settings.visible = true; - - this.events.emit('start', this); - }, - - /** - * Called automatically by the SceneManager if the Game resizes. - * Dispatches an event you can respond to in your game code. - * - * @method Phaser.Scenes.Systems#resize - * @since 3.2.0 - * - * @param {number} width - The new width of the game. - * @param {number} height - The new height of the game. - */ - resize: function (width, height) - { - this.events.emit('resize', width, height); - }, - - /** - * Shutdown this Scene and send a shutdown event to all of its systems. - * - * @method Phaser.Scenes.Systems#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this.settings.status = CONST.SHUTDOWN; - - this.settings.active = false; - this.settings.visible = false; - - this.events.emit('shutdown', this); - }, - - /** - * Destroy this Scene and send a destroy event all of its systems. - * - * @method Phaser.Scenes.Systems#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.settings.status = CONST.DESTROYED; - - this.settings.active = false; - this.settings.visible = false; - - this.events.emit('destroy', this); - } - -}); - -module.exports = Systems; - - -/***/ }), -/* 131 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Extend = __webpack_require__(23); - -/** - * @classdesc - * A Frame is a section of a Texture. - * - * @class Frame - * @memberOf Phaser.Textures - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture this Frame is a part of. - * @param {integer|string} name - The name of this Frame. The name is unique within the Texture. - * @param {integer} sourceIndex - The index of the TextureSource that this Frame is a part of. - * @param {number} x - The x coordinate of the top-left of this Frame. - * @param {number} y - The y coordinate of the top-left of this Frame. - * @param {number} width - The width of this Frame. - * @param {number} height - The height of this Frame. - */ -var Frame = new Class({ - - initialize: - - function Frame (texture, name, sourceIndex, x, y, width, height) - { - /** - * The Texture this Frame is a part of. - * - * @name Phaser.Textures.Frame#texture - * @type {Phaser.Textures.Texture} - * @since 3.0.0 - */ - this.texture = texture; - - /** - * The name of this Frame. - * The name is unique within the Texture. - * - * @name Phaser.Textures.Frame#name - * @type {string} - * @since 3.0.0 - */ - this.name = name; - - /** - * The TextureSource this Frame is part of. - * - * @name Phaser.Textures.Frame#source - * @type {Phaser.Textures.TextureSource} - * @since 3.0.0 - */ - this.source = texture.source[sourceIndex]; - - /** - * The index of the TextureSource in the Texture sources array. - * - * @name Phaser.Textures.Frame#sourceIndex - * @type {integer} - * @since 3.0.0 - */ - this.sourceIndex = sourceIndex; - - /** - * X position within the source image to cut from. - * - * @name Phaser.Textures.Frame#cutX - * @type {integer} - * @since 3.0.0 - */ - this.cutX = x; - - /** - * Y position within the source image to cut from. - * - * @name Phaser.Textures.Frame#cutY - * @type {integer} - * @since 3.0.0 - */ - this.cutY = y; - - /** - * The width of the area in the source image to cut. - * - * @name Phaser.Textures.Frame#cutWidth - * @type {integer} - * @since 3.0.0 - */ - this.cutWidth = width; - - /** - * The height of the area in the source image to cut. - * - * @name Phaser.Textures.Frame#cutHeight - * @type {integer} - * @since 3.0.0 - */ - this.cutHeight = height; - - /** - * The X rendering offset of this Frame, taking trim into account. - * - * @name Phaser.Textures.Frame#x - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.x = 0; - - /** - * The Y rendering offset of this Frame, taking trim into account. - * - * @name Phaser.Textures.Frame#y - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.y = 0; - - /** - * The rendering width of this Frame, taking trim into account. - * - * @name Phaser.Textures.Frame#width - * @type {integer} - * @since 3.0.0 - */ - this.width = width; - - /** - * The rendering height of this Frame, taking trim into account. - * - * @name Phaser.Textures.Frame#height - * @type {integer} - * @since 3.0.0 - */ - this.height = height; - - /** - * Half the width, floored. - * Precalculated for the renderer. - * - * @name Phaser.Textures.Frame#halfWidth - * @type {integer} - * @since 3.0.0 - */ - this.halfWidth = Math.floor(width * 0.5); - - /** - * Half the height, floored. - * Precalculated for the renderer. - * - * @name Phaser.Textures.Frame#halfHeight - * @type {integer} - * @since 3.0.0 - */ - this.halfHeight = Math.floor(height * 0.5); - - /** - * The x center of this frame, floored. - * - * @name Phaser.Textures.Frame#centerX - * @type {integer} - * @since 3.0.0 - */ - this.centerX = Math.floor(width / 2); - - /** - * The y center of this frame, floored. - * - * @name Phaser.Textures.Frame#centerY - * @type {integer} - * @since 3.0.0 - */ - this.centerY = Math.floor(height / 2); - - /** - * The horizontal pivot point of this Frame. - * - * @name Phaser.Textures.Frame#pivotX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.pivotX = 0; - - /** - * The vertical pivot point of this Frame. - * - * @name Phaser.Textures.Frame#pivotY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.pivotY = 0; - - /** - * Does this Frame have a custom pivot point? - * - * @name Phaser.Textures.Frame#customPivot - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.customPivot = false; - - /** - * **CURRENTLY UNSUPPORTED** - * - * Is this frame is rotated or not in the Texture? - * Rotation allows you to use rotated frames in texture atlas packing. - * It has nothing to do with Sprite rotation. - * - * @name Phaser.Textures.Frame#rotated - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.rotated = false; - - /** - * Over-rides the Renderer setting. - * -1 = use Renderer Setting - * 0 = No rounding - * 1 = Round - * - * @name Phaser.Textures.Frame#autoRound - * @type {integer} - * @default -1 - * @since 3.0.0 - */ - this.autoRound = -1; - - /** - * Any Frame specific custom data can be stored here. - * - * @name Phaser.Textures.Frame#customData - * @type {object} - * @since 3.0.0 - */ - this.customData = {}; - - /** - * The un-modified source frame, trim and UV data. - * - * @name Phaser.Textures.Frame#data - * @type {object} - * @private - * @since 3.0.0 - */ - this.data = { - cut: { - x: x, - y: y, - w: width, - h: height, - r: x + width, - b: y + height - }, - trim: false, - sourceSize: { - w: width, - h: height - }, - spriteSourceSize: { - x: 0, - y: 0, - w: width, - h: height - }, - uvs: { - x0: 0, - y0: 0, - x1: 0, - y1: 0, - x2: 0, - y2: 0, - x3: 0, - y3: 0 - }, - radius: 0.5 * Math.sqrt(width * width + height * height), - drawImage: { - sx: x, - sy: y, - sWidth: width, - sHeight: height, - dWidth: width, - dHeight: height - } - }; - - this.updateUVs(); - }, - - /** - * If the frame was trimmed when added to the Texture Atlas, this records the trim and source data. - * - * @method Phaser.Textures.Frame#setTrim - * @since 3.0.0 - * - * @param {number} actualWidth - The width of the frame before being trimmed. - * @param {number} actualHeight - The height of the frame before being trimmed. - * @param {number} destX - The destination X position of the trimmed frame for display. - * @param {number} destY - The destination Y position of the trimmed frame for display. - * @param {number} destWidth - The destination width of the trimmed frame for display. - * @param {number} destHeight - The destination height of the trimmed frame for display. - * - * @return {Phaser.Textures.Frame} This Frame object. - */ - setTrim: function (actualWidth, actualHeight, destX, destY, destWidth, destHeight) - { - var data = this.data; - var ss = data.spriteSourceSize; - - // Store actual values - - data.trim = true; - - data.sourceSize.w = actualWidth; - data.sourceSize.h = actualHeight; - - ss.x = destX; - ss.y = destY; - ss.w = destWidth; - ss.h = destHeight; - - // Adjust properties - this.x = destX; - this.y = destY; - - this.width = destWidth; - this.height = destHeight; - - this.halfWidth = destWidth * 0.5; - this.halfHeight = destHeight * 0.5; - - this.centerX = Math.floor(destWidth / 2); - this.centerY = Math.floor(destHeight / 2); - - return this.updateUVs(); - }, - - /** - * Updates the internal WebGL UV cache and the drawImage cache. - * - * @method Phaser.Textures.Frame#updateUVs - * @since 3.0.0 - * - * @return {Phaser.Textures.Frame} This Frame object. - */ - updateUVs: function () - { - var cx = this.cutX; - var cy = this.cutY; - var cw = this.cutWidth; - var ch = this.cutHeight; - - // Canvas data - - var cd = this.data.drawImage; - - cd.sWidth = cw; - cd.sHeight = ch; - cd.dWidth = cw; - cd.dHeight = ch; - - // WebGL data - - var tw = this.source.width; - var th = this.source.height; - var uvs = this.data.uvs; - - uvs.x0 = cx / tw; - uvs.y0 = cy / th; - - uvs.x1 = cx / tw; - uvs.y1 = (cy + ch) / th; - - uvs.x2 = (cx + cw) / tw; - uvs.y2 = (cy + ch) / th; - - uvs.x3 = (cx + cw) / tw; - uvs.y3 = cy / th; - - return this; - }, - - /** - * Updates the internal WebGL UV cache. - * - * @method Phaser.Textures.Frame#updateUVsInverted - * @since 3.0.0 - * - * @return {Phaser.Textures.Frame} This Frame object. - */ - updateUVsInverted: function () - { - var tw = this.source.width; - var th = this.source.height; - var uvs = this.data.uvs; - - uvs.x3 = (this.cutX + this.cutHeight) / tw; - uvs.y3 = (this.cutY + this.cutWidth) / th; - - uvs.x2 = this.cutX / tw; - uvs.y2 = (this.cutY + this.cutWidth) / th; - - uvs.x1 = this.cutX / tw; - uvs.y1 = this.cutY / th; - - uvs.x0 = (this.cutX + this.cutHeight) / tw; - uvs.y0 = this.cutY / th; - - return this; - }, - - /** - * Clones this Frame into a new Frame object. - * - * @method Phaser.Textures.Frame#clone - * @since 3.0.0 - * - * @return {Phaser.Textures.Frame} A clone of this Frame. - */ - clone: function () - { - var clone = new Frame(this.texture, this.name, this.sourceIndex); - - clone.cutX = this.cutX; - clone.cutY = this.cutY; - clone.cutWidth = this.cutWidth; - clone.cutHeight = this.cutHeight; - - clone.x = this.x; - clone.y = this.y; - - clone.width = this.width; - clone.height = this.height; - - clone.halfWidth = this.halfWidth; - clone.halfHeight = this.halfHeight; - - clone.centerX = this.centerX; - clone.centerY = this.centerY; - - clone.rotated = this.rotated; - - clone.data = Extend(true, clone.data, this.data); - - clone.updateUVs(); - - return clone; - }, - - /** - * Destroys this Frames references. - * - * @method Phaser.Textures.Frame#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.texture = null; - - this.source = null; - }, - - /** - * The width of the Frame in its un-trimmed, un-padded state, as prepared in the art package, - * before being packed. - * - * @name Phaser.Textures.Frame#realWidth - * @type {number} - * @readOnly - * @since 3.0.0 - */ - realWidth: { - - get: function () - { - return this.data.sourceSize.w; - } - - }, - - /** - * The height of the Frame in its un-trimmed, un-padded state, as prepared in the art package, - * before being packed. - * - * @name Phaser.Textures.Frame#realHeight - * @type {number} - * @readOnly - * @since 3.0.0 - */ - realHeight: { - - get: function () - { - return this.data.sourceSize.h; - } - - }, - - /** - * The UV data for this Frame. - * - * @name Phaser.Textures.Frame#uvs - * @type {object} - * @readOnly - * @since 3.0.0 - */ - uvs: { - - get: function () - { - return this.data.uvs; - } - - }, - - /** - * The radius of the Frame (derived from sqrt(w * w + h * h) / 2) - * - * @name Phaser.Textures.Frame#radius - * @type {number} - * @readOnly - * @since 3.0.0 - */ - radius: { - - get: function () - { - return this.data.radius; - } - - }, - - /** - * Is the Frame trimmed or not? - * - * @name Phaser.Textures.Frame#trimmed - * @type {boolean} - * @readOnly - * @since 3.0.0 - */ - trimmed: { - - get: function () - { - return this.data.trim; - } - - }, - - /** - * The Canvas drawImage data object. - * - * @name Phaser.Textures.Frame#canvasData - * @type {object} - * @readOnly - * @since 3.0.0 - */ - canvasData: { - - get: function () - { - return this.data.drawImage; - } - - } - -}); - -module.exports = Frame; - - -/***/ }), -/* 132 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetAdvancedValue = __webpack_require__(10); - -/** - * Adds an Animation component to a Sprite and populates it based on the given config. - * - * @function Phaser.Gameobjects.BuildGameObjectAnimation - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Sprite} sprite - [description] - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Sprite} The updated Sprite. - */ -var BuildGameObjectAnimation = function (sprite, config) -{ - var animConfig = GetAdvancedValue(config, 'anims', null); - - if (animConfig === null) - { - return sprite; - } - - if (typeof animConfig === 'string') - { - // { anims: 'key' } - sprite.anims.play(animConfig); - } - else if (typeof animConfig === 'object') - { - // { anims: { - // key: string - // startFrame: [string|integer] - // delay: [float] - // repeat: [integer] - // repeatDelay: [float] - // yoyo: [boolean] - // play: [boolean] - // delayedPlay: [boolean] - // } - // } - - var anims = sprite.anims; - - var key = GetAdvancedValue(animConfig, 'key', undefined); - var startFrame = GetAdvancedValue(animConfig, 'startFrame', undefined); - - var delay = GetAdvancedValue(animConfig, 'delay', 0); - var repeat = GetAdvancedValue(animConfig, 'repeat', 0); - var repeatDelay = GetAdvancedValue(animConfig, 'repeatDelay', 0); - var yoyo = GetAdvancedValue(animConfig, 'yoyo', false); - - var play = GetAdvancedValue(animConfig, 'play', false); - var delayedPlay = GetAdvancedValue(animConfig, 'delayedPlay', 0); - - anims.delay(delay); - anims.repeat(repeat); - anims.repeatDelay(repeatDelay); - anims.yoyo(yoyo); - - if (play) - { - anims.play(key, startFrame); - } - else if (delayedPlay > 0) - { - anims.delayedPlay(delayedPlay, key, startFrame); - } - else - { - anims.load(key); - } - } - - return sprite; -}; - -module.exports = BuildGameObjectAnimation; - - -/***/ }), -/* 133 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var GameObject = __webpack_require__(1); -var GetBitmapTextSize = __webpack_require__(268); -var ParseFromAtlas = __webpack_require__(547); -var ParseRetroFont = __webpack_require__(548); -var Render = __webpack_require__(549); - -/** - * @classdesc - * [description] - * - * @class BitmapText - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * @extends Phaser.GameObjects.Components.ScrollFactor - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. - * @param {number} [x=0] - The x coordinate of this Game Object in world space. - * @param {number} [y=0] - The y coordinate of this Game Object in world space. - * @param {string} font - [description] - * @param {string|string[]} [text] - [description] - * @param {number} [size] - [description] - */ -var BitmapText = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.Texture, - Components.Tint, - Components.Transform, - Components.Visible, - Components.ScrollFactor, - Render - ], - - initialize: - - function BitmapText (scene, x, y, font, text, size) - { - if (text === undefined) { text = ''; } - - GameObject.call(this, scene, 'BitmapText'); - - /** - * [description] - * - * @name Phaser.GameObjects.BitmapText#font - * @type {string} - * @since 3.0.0 - */ - this.font = font; - - var entry = this.scene.sys.cache.bitmapFont.get(font); - - /** - * [description] - * - * @name Phaser.GameObjects.BitmapText#fontData - * @type {object} - * @since 3.0.0 - */ - this.fontData = entry.data; - - /** - * [description] - * - * @name Phaser.GameObjects.BitmapText#text - * @type {string} - * @since 3.0.0 - */ - this.text = (Array.isArray(text)) ? text.join('\n') : text; - - /** - * [description] - * - * @name Phaser.GameObjects.BitmapText#fontSize - * @type {number} - * @since 3.0.0 - */ - this.fontSize = size || this.fontData.size; - - this.setTexture(entry.texture, entry.frame); - this.setPosition(x, y); - this.setOrigin(0, 0); - this.initPipeline('TextureTintPipeline'); - - /** - * [description] - * - * @name Phaser.GameObjects.BitmapText#_bounds - * @type {object} - * @private - * @since 3.0.0 - */ - this._bounds = this.getTextBounds(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.BitmapText#setFontSize - * @since 3.0.0 - * - * @param {number} size - [description] - * - * @return {Phaser.GameObjects.BitmapText} This Game Object. - */ - setFontSize: function (size) - { - this.fontSize = size; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.BitmapText#setText - * @since 3.0.0 - * - * @param {string|string[]} value - The string, or array of strings, to be set as the content of this BitmapText. - * - * @return {Phaser.GameObjects.BitmapText} This Game Object. - */ - setText: function (value) - { - if (!value && value !== 0) - { - value = ''; - } - - if (Array.isArray(value)) - { - value = value.join('\n'); - } - - if (value !== this.text) - { - this.text = value.toString(); - - this.updateDisplayOrigin(); - } - - return this; - }, - - // { - // local: { - // x, - // y, - // width, - // height - // }, - // global: { - // x, - // y, - // width, - // height - // } - // } - - /** - * [description] - * - * @method Phaser.GameObjects.BitmapText#getTextBounds - * @since 3.0.0 - * - * @param {boolean} round - [description] - * - * @return {object} [description] - */ - getTextBounds: function (round) - { - // local = the BitmapText based on fontSize and 0x0 coords - // global = the BitmapText, taking into account scale and world position - - this._bounds = GetBitmapTextSize(this, round); - - return this._bounds; - }, - - /** - * [description] - * - * @name Phaser.GameObjects.BitmapText#width - * @type {number} - * @since 3.0.0 - */ - width: { - - get: function () - { - this.getTextBounds(false); - - return this._bounds.global.width; - } - - }, - - /** - * [description] - * - * @name Phaser.GameObjects.BitmapText#height - * @type {number} - * @since 3.0.0 - */ - height: { - - get: function () - { - this.getTextBounds(false); - - return this._bounds.global.height; - } - - }, - - /** - * [description] - * - * @method Phaser.GameObjects.BitmapText#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - var out = Components.ToJSON(this); - - // Extra data is added here - - var data = { - font: this.font, - text: this.text, - fontSize: this.fontSize - }; - - out.data = data; - - return out; - } - -}); - -BitmapText.ParseRetroFont = ParseRetroFont; -BitmapText.ParseFromAtlas = ParseFromAtlas; - -module.exports = BitmapText; - - -/***/ }), -/* 134 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BlitterRender = __webpack_require__(552); -var Bob = __webpack_require__(555); -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var Frame = __webpack_require__(131); -var GameObject = __webpack_require__(1); -var List = __webpack_require__(86); - -/** - * @classdesc - * A Blitter Game Object. - * - * The Blitter Game Object is a special kind of container that creates, updates and manages Bob objects. - * Bobs are designed for rendering speed rather than flexibility. They consist of a texture, or frame from a texture, - * a position and an alpha value. You cannot scale or rotate them. They use a batched drawing method for speed - * during rendering. - * - * A Blitter Game Object has one texture bound to it. Bobs created by the Blitter can use any Frame from this - * Texture to render with, but they cannot use any other Texture. It is this single texture-bind that allows - * them their speed. - * - * If you have a need to blast a large volume of frames around the screen then Blitter objects are well worth - * investigating. They are especially useful for using as a base for your own special effects systems. - * - * @class Blitter - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. - * @param {number} [x=0] - The x coordinate of this Game Object in world space. - * @param {number} [y=0] - The y coordinate of this Game Object in world space. - * @param {string} [texture='__DEFAULT'] - The key of the texture this Game Object will use for rendering. The Texture must already exist in the Texture Manager. - * @param {string|integer} [frame=0] - The Frame of the Texture that this Game Object will use. Only set if the Texture has multiple frames, such as a Texture Atlas or Sprite Sheet. - */ -var Blitter = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Size, - Components.Texture, - Components.Transform, - Components.Visible, - BlitterRender - ], - - initialize: - - function Blitter (scene, x, y, texture, frame) - { - GameObject.call(this, scene, 'Blitter'); - - this.setTexture(texture, frame); - this.setPosition(x, y); - this.initPipeline('TextureTintPipeline'); - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter#children - * @type {Phaser.Structs.List} - * @since 3.0.0 - */ - this.children = new List(); - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter#renderList - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.renderList = []; - - this.dirty = false; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter#create - * @since 3.0.0 - * - * @param {number} x - The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. - * @param {number} y - The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. - * @param {string|integer|Phaser.Textures.Frame} [frame] - The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. - * @param {boolean} [visible=true] - Should the created Bob render or not? - * @param {integer} [index] - The position in the Blitters Display List to add the new Bob at. Defaults to the top of the list. - * - * @return {Phaser.GameObjects.Blitter.Bob} The newly created Bob object. - */ - create: function (x, y, frame, visible, index) - { - if (visible === undefined) { visible = true; } - if (index === undefined) { index = this.children.length; } - - if (frame === undefined) - { - frame = this.frame; - } - else if (!(frame instanceof Frame)) - { - frame = this.texture.get(frame); - } - - var bob = new Bob(this, x, y, frame, visible); - - this.children.addAt(bob, index, false); - - this.dirty = true; - - return bob; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter#createFromCallback - * @since 3.0.0 - * - * @param {function} callback - The callback to invoke after creating a bob. It will be sent two arguments: The Bob and the index of the Bob. - * @param {integer} quantity - The quantity of Bob objects to create. - * @param {string} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture. - * @param {boolean} [visible=true] - [description] - * - * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that were created. - */ - createFromCallback: function (callback, quantity, frame, visible) - { - var bobs = this.createMultiple(quantity, frame, visible); - - for (var i = 0; i < bobs.length; i++) - { - var bob = bobs[i]; - - callback.call(this, bob, i); - } - - return bobs; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter#createMultiple - * @since 3.0.0 - * - * @param {integer} quantity - The quantity of Bob objects to create. - * @param {string} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture. - * @param {boolean} [visible=true] - [description] - * - * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that were created. - */ - createMultiple: function (quantity, frame, visible) - { - if (frame === undefined) { frame = this.frame.name; } - if (visible === undefined) { visible = true; } - - if (!Array.isArray(frame)) - { - frame = [ frame ]; - } - - var bobs = []; - var _this = this; - - frame.forEach(function (singleFrame) - { - for (var i = 0; i < quantity; i++) - { - bobs.push(_this.create(0, 0, singleFrame, visible)); - } - }); - - return bobs; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter#childCanRender - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter.Bob} child - [description] - * - * @return {boolean} [description] - */ - childCanRender: function (child) - { - return (child.visible && child.alpha > 0); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter#getRenderList - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that will be rendered this frame. - */ - getRenderList: function () - { - if (this.dirty) - { - this.renderList = this.children.list.filter(this.childCanRender, this); - this.dirty = false; - } - - return this.renderList; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter#clear - * @since 3.0.0 - */ - clear: function () - { - this.children.removeAll(); - this.dirty = true; - } - -}); - -module.exports = Blitter; - - -/***/ }), -/* 135 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var GameObject = __webpack_require__(1); -var GetBitmapTextSize = __webpack_require__(268); -var Render = __webpack_require__(556); - -/** - * @classdesc - * [description] - * - * @class DynamicBitmapText - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * @extends Phaser.GameObjects.Components.ScrollFactor - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. - * @param {number} [x=0] - The x coordinate of this Game Object in world space. - * @param {number} [y=0] - The y coordinate of this Game Object in world space. - * @param {string} font - [description] - * @param {string|string[]} [text] - [description] - * @param {number} [size] - [description] - */ -var DynamicBitmapText = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Origin, - Components.Pipeline, - Components.Texture, - Components.Tint, - Components.Transform, - Components.Visible, - Components.ScrollFactor, - Render - ], - - initialize: - - function DynamicBitmapText (scene, x, y, font, text, size) - { - if (text === undefined) { text = ''; } - - GameObject.call(this, scene, 'DynamicBitmapText'); - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#font - * @type {string} - * @since 3.0.0 - */ - this.font = font; - - var entry = this.scene.sys.cache.bitmapFont.get(font); - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#fontData - * @type {object} - * @since 3.0.0 - */ - this.fontData = entry.data; - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#text - * @type {string} - * @since 3.0.0 - */ - this.text = (Array.isArray(text)) ? text.join('\n') : text; - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#fontSize - * @type {number} - * @since 3.0.0 - */ - this.fontSize = size || this.fontData.size; - - this.setTexture(entry.texture, entry.frame); - this.setPosition(x, y); - this.setOrigin(0, 0); - this.initPipeline('TextureTintPipeline'); - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#_bounds - * @type {object} - * @private - * @since 3.0.0 - */ - this._bounds = this.getTextBounds(); - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#scrollX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.scrollX = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#scrollY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.scrollY = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#cropWidth - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.cropWidth = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#cropHeight - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.cropHeight = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#displayCallback; - * @type {function} - * @since 3.0.0 - */ - this.displayCallback; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.DynamicBitmapText#setSize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setSize: function (width, height) - { - this.cropWidth = width; - this.cropHeight = height; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.DynamicBitmapText#setDisplayCallback - * @since 3.0.0 - * - * @param {function} callback - [description] - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setDisplayCallback: function (callback) - { - this.displayCallback = callback; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.DynamicBitmapText#setFontSize - * @since 3.0.0 - * - * @param {number} size - [description] - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setFontSize: function (size) - { - this.fontSize = size; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.DynamicBitmapText#setText - * @since 3.0.0 - * - * @param {string|string[]} value - The string, or array of strings, to be set as the content of this BitmapText. - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setText: function (value) - { - if (!value && value !== 0) - { - value = ''; - } - - if (Array.isArray(value)) - { - value = value.join('\n'); - } - - if (value !== this.text) - { - this.text = value.toString(); - - this.updateDisplayOrigin(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.DynamicBitmapText#setScrollX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setScrollX: function (value) - { - this.scrollX = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.DynamicBitmapText#setScrollY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setScrollY: function (value) - { - this.scrollY = value; - - return this; - }, - - // { - // local: { - // x, - // y, - // width, - // height - // }, - // global: { - // x, - // y, - // width, - // height - // } - // } - - /** - * [description] - * - * @method Phaser.GameObjects.DynamicBitmapText#getTextBounds - * @since 3.0.0 - * - * @param {boolean} round - [description] - * - * @return {object} [description] - */ - getTextBounds: function (round) - { - // local = the BitmapText based on fontSize and 0x0 coords - // global = the BitmapText, taking into account scale and world position - - this._bounds = GetBitmapTextSize(this, round); - - return this._bounds; - }, - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#width - * @type {number} - * @since 3.0.0 - */ - width: { - - get: function () - { - this.getTextBounds(false); - return this._bounds.global.width; - } - - }, - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#height - * @type {number} - * @since 3.0.0 - */ - height: { - - get: function () - { - this.getTextBounds(false); - return this._bounds.global.height; - } - - }, - - /** - * [description] - * - * @method Phaser.GameObjects.DynamicBitmapText#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - var out = Components.ToJSON(this); - - // Extra data is added here - - var data = { - font: this.font, - text: this.text, - fontSize: this.fontSize - }; - - out.data = data; - - return out; - } - -}); - -module.exports = DynamicBitmapText; - - -/***/ }), -/* 136 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Camera = __webpack_require__(115); -var Class = __webpack_require__(0); -var Commands = __webpack_require__(128); -var Components = __webpack_require__(11); -var Ellipse = __webpack_require__(270); -var GameObject = __webpack_require__(1); -var GetValue = __webpack_require__(4); -var MATH_CONST = __webpack_require__(16); -var Render = __webpack_require__(568); - -/** - * @classdesc - * [description] - * - * @class Graphics - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * @extends Phaser.GameObjects.Components.ScrollFactor - * - * @param {Phaser.Scene} scene - [description] - * @param {object} options - [description] - */ -var Graphics = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Pipeline, - Components.Transform, - Components.Visible, - Components.ScrollFactor, - Render - ], - - initialize: - - function Graphics (scene, options) - { - var x = GetValue(options, 'x', 0); - var y = GetValue(options, 'y', 0); - - GameObject.call(this, scene, 'Graphics'); - - this.setPosition(x, y); - this.initPipeline('FlatTintPipeline'); - - /** - * [description] - * - * @name Phaser.GameObjects.Graphics#displayOriginX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.displayOriginX = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Graphics#displayOriginY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.displayOriginY = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Graphics#commandBuffer - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.commandBuffer = []; - - /** - * [description] - * - * @name Phaser.GameObjects.Graphics#defaultFillColor - * @type {number} - * @default -1 - * @since 3.0.0 - */ - this.defaultFillColor = -1; - - /** - * [description] - * - * @name Phaser.GameObjects.Graphics#defaultFillAlpha - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.defaultFillAlpha = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Graphics#defaultStrokeWidth - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.defaultStrokeWidth = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Graphics#defaultStrokeColor - * @type {number} - * @default -1 - * @since 3.0.0 - */ - this.defaultStrokeColor = -1; - - /** - * [description] - * - * @name Phaser.GameObjects.Graphics#defaultStrokeAlpha - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.defaultStrokeAlpha = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Graphics#_lineWidth - * @type {number} - * @private - * @since 3.0.0 - */ - this._lineWidth = 1.0; - - this.setDefaultStyles(options); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#setDefaultStyles - * @since 3.0.0 - * - * @param {object} options - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - setDefaultStyles: function (options) - { - if (GetValue(options, 'lineStyle', null)) - { - this.defaultStrokeWidth = GetValue(options, 'lineStyle.width', 1); - this.defaultStrokeColor = GetValue(options, 'lineStyle.color', 0xffffff); - this.defaultStrokeAlpha = GetValue(options, 'lineStyle.alpha', 1); - - this.lineStyle(this.defaultStrokeWidth, this.defaultStrokeColor, this.defaultStrokeAlpha); - } - - if (GetValue(options, 'fillStyle', null)) - { - this.defaultFillColor = GetValue(options, 'fillStyle.color', 0xffffff); - this.defaultFillAlpha = GetValue(options, 'fillStyle.alpha', 1); - - this.fillStyle(this.defaultFillColor, this.defaultFillAlpha); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#lineStyle - * @since 3.0.0 - * - * @param {number} lineWidth - [description] - * @param {number} color - [description] - * @param {float} [alpha=1] - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - lineStyle: function (lineWidth, color, alpha) - { - if (alpha === undefined) { alpha = 1; } - - this.commandBuffer.push( - Commands.LINE_STYLE, - lineWidth, color, alpha - ); - - this._lineWidth = lineWidth; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillStyle - * @since 3.0.0 - * - * @param {number} color - [description] - * @param {float} [alpha=1] - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillStyle: function (color, alpha) - { - if (alpha === undefined) { alpha = 1; } - - this.commandBuffer.push( - Commands.FILL_STYLE, - color, alpha - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#beginPath - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - beginPath: function () - { - this.commandBuffer.push( - Commands.BEGIN_PATH - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#closePath - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - closePath: function () - { - this.commandBuffer.push( - Commands.CLOSE_PATH - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillPath - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillPath: function () - { - this.commandBuffer.push( - Commands.FILL_PATH - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#strokePath - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokePath: function () - { - this.commandBuffer.push( - Commands.STROKE_PATH - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillCircleShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillCircleShape: function (circle) - { - return this.fillCircle(circle.x, circle.y, circle.radius); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#strokeCircleShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeCircleShape: function (circle) - { - return this.strokeCircle(circle.x, circle.y, circle.radius); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillCircle - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} radius - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillCircle: function (x, y, radius) - { - this.beginPath(); - this.arc(x, y, radius, 0, MATH_CONST.PI2); - this.fillPath(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#strokeCircle - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} radius - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeCircle: function (x, y, radius) - { - this.beginPath(); - this.arc(x, y, radius, 0, MATH_CONST.PI2); - this.strokePath(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillRectShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillRectShape: function (rect) - { - return this.fillRect(rect.x, rect.y, rect.width, rect.height); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#strokeRectShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeRectShape: function (rect) - { - return this.strokeRect(rect.x, rect.y, rect.width, rect.height); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillRect - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillRect: function (x, y, width, height) - { - this.commandBuffer.push( - Commands.FILL_RECT, - x, y, width, height - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#strokeRect - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeRect: function (x, y, width, height) - { - var lineWidthHalf = this._lineWidth / 2; - var minx = x - lineWidthHalf; - var maxx = x + lineWidthHalf; - - this.beginPath(); - this.moveTo(x, y); - this.lineTo(x, y + height); - this.strokePath(); - - this.beginPath(); - this.moveTo(x + width, y); - this.lineTo(x + width, y + height); - this.strokePath(); - - this.beginPath(); - this.moveTo(minx, y); - this.lineTo(maxx + width, y); - this.strokePath(); - - this.beginPath(); - this.moveTo(minx, y + height); - this.lineTo(maxx + width, y + height); - this.strokePath(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillPointShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Point|Phaser.Math.Vector2|object} point - [description] - * @param {number} [size=1] - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillPointShape: function (point, size) - { - return this.fillPoint(point.x, point.y, size); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillPoint - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} [size=1] - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillPoint: function (x, y, size) - { - if (!size || size < 1) - { - size = 1; - } - else - { - x -= (size / 2); - y -= (size / 2); - } - - this.commandBuffer.push( - Commands.FILL_RECT, - x, y, size, size - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillTriangleShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillTriangleShape: function (triangle) - { - return this.fillTriangle(triangle.x1, triangle.y1, triangle.x2, triangle.y2, triangle.x3, triangle.y3); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#strokeTriangleShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeTriangleShape: function (triangle) - { - return this.strokeTriangle(triangle.x1, triangle.y1, triangle.x2, triangle.y2, triangle.x3, triangle.y3); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillTriangle - * @since 3.0.0 - * - * @param {number} x0 - [description] - * @param {number} y0 - [description] - * @param {number} x1 - [description] - * @param {number} y1 - [description] - * @param {number} x2 - [description] - * @param {number} y2 - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillTriangle: function (x0, y0, x1, y1, x2, y2) - { - this.commandBuffer.push( - Commands.FILL_TRIANGLE, - x0, y0, x1, y1, x2, y2 - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#strokeTriangle - * @since 3.0.0 - * - * @param {number} x0 - [description] - * @param {number} y0 - [description] - * @param {number} x1 - [description] - * @param {number} y1 - [description] - * @param {number} x2 - [description] - * @param {number} y2 - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeTriangle: function (x0, y0, x1, y1, x2, y2) - { - this.commandBuffer.push( - Commands.STROKE_TRIANGLE, - x0, y0, x1, y1, x2, y2 - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#strokeLineShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeLineShape: function (line) - { - return this.lineBetween(line.x1, line.y1, line.x2, line.y2); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#lineBetween - * @since 3.0.0 - * - * @param {number} x1 - [description] - * @param {number} y1 - [description] - * @param {number} x2 - [description] - * @param {number} y2 - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - lineBetween: function (x1, y1, x2, y2) - { - this.beginPath(); - this.moveTo(x1, y1); - this.lineTo(x2, y2); - this.strokePath(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#lineTo - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - lineTo: function (x, y) - { - this.commandBuffer.push( - Commands.LINE_TO, - x, y - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#moveTo - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - moveTo: function (x, y) - { - this.commandBuffer.push( - Commands.MOVE_TO, - x, y - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#lineFxTo - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} rgb - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - lineFxTo: function (x, y, width, rgb) - { - this.commandBuffer.push( - Commands.LINE_FX_TO, - x, y, width, rgb, 1 - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#moveFxTo - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} rgb - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - moveFxTo: function (x, y, width, rgb) - { - this.commandBuffer.push( - Commands.MOVE_FX_TO, - x, y, width, rgb, 1 - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#strokePoints - * @since 3.0.0 - * - * @param {array|Phaser.Geom.Point[]} points - [description] - * @param {boolean} [autoClose=false] - [description] - * @param {integer} [endIndex] - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokePoints: function (points, autoClose, endIndex) - { - if (autoClose === undefined) { autoClose = false; } - if (endIndex === undefined) { endIndex = points.length; } - - this.beginPath(); - - this.moveTo(points[0].x, points[0].y); - - for (var i = 1; i < endIndex; i++) - { - this.lineTo(points[i].x, points[i].y); - } - - if (autoClose) - { - this.lineTo(points[0].x, points[0].y); - } - - this.strokePath(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillPoints - * @since 3.0.0 - * - * @param {array|Phaser.Geom.Point[]} points - [description] - * @param {boolean} [autoClose=false] - [description] - * @param {integer} [endIndex] - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillPoints: function (points, autoClose, endIndex) - { - if (autoClose === undefined) { autoClose = false; } - if (endIndex === undefined) { endIndex = points.length; } - - this.beginPath(); - - this.moveTo(points[0].x, points[0].y); - - for (var i = 1; i < endIndex; i++) - { - this.lineTo(points[i].x, points[i].y); - } - - if (autoClose) - { - this.lineTo(points[0].x, points[0].y); - } - - this.fillPath(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#strokeEllipseShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - [description] - * @param {integer} [smoothness=32] - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeEllipseShape: function (ellipse, smoothness) - { - if (smoothness === undefined) { smoothness = 32; } - - var points = ellipse.getPoints(smoothness); - - return this.strokePoints(points, true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#strokeEllipse - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {integer} [smoothness=32] - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeEllipse: function (x, y, width, height, smoothness) - { - if (smoothness === undefined) { smoothness = 32; } - - var ellipse = new Ellipse(x, y, width, height); - - var points = ellipse.getPoints(smoothness); - - return this.strokePoints(points, true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillEllipseShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - [description] - * @param {integer} [smoothness=32] - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillEllipseShape: function (ellipse, smoothness) - { - if (smoothness === undefined) { smoothness = 32; } - - var points = ellipse.getPoints(smoothness); - - return this.fillPoints(points, true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillEllipse - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {integer} [smoothness=32] - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillEllipse: function (x, y, width, height, smoothness) - { - if (smoothness === undefined) { smoothness = 32; } - - var ellipse = new Ellipse(x, y, width, height); - - var points = ellipse.getPoints(smoothness); - - return this.fillPoints(points, true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#arc - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} radius - [description] - * @param {number} startAngle - [description] - * @param {number} endAngle - [description] - * @param {boolean} anticlockwise - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - arc: function (x, y, radius, startAngle, endAngle, anticlockwise) - { - this.commandBuffer.push( - Commands.ARC, - x, y, radius, startAngle, endAngle, anticlockwise - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#save - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - save: function () - { - this.commandBuffer.push( - Commands.SAVE - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#restore - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - restore: function () - { - this.commandBuffer.push( - Commands.RESTORE - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#translate - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - translate: function (x, y) - { - this.commandBuffer.push( - Commands.TRANSLATE, - x, y - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#scale - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - scale: function (x, y) - { - this.commandBuffer.push( - Commands.SCALE, - x, y - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#rotate - * @since 3.0.0 - * - * @param {number} radians - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - rotate: function (radians) - { - this.commandBuffer.push( - Commands.ROTATE, - radians - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#clear - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - clear: function () - { - this.commandBuffer.length = 0; - - if (this.defaultFillColor > -1) - { - this.fillStyle(this.defaultFillColor, this.defaultFillAlpha); - } - - if (this.defaultStrokeColor > -1) - { - this.lineStyle(this.defaultStrokeWidth, this.defaultStrokeColor, this.defaultStrokeAlpha); - } - - return this; - }, - - /** - * If key is a string it'll generate a new texture using it and add it into the - * Texture Manager (assuming no key conflict happens). - * - * If key is a Canvas it will draw the texture to that canvas context. Note that it will NOT - * automatically upload it to the GPU in WebGL mode. - * - * @method Phaser.GameObjects.Graphics#generateTexture - * @since 3.0.0 - * - * @param {string|HTMLCanvasElement} key - [description] - * @param {integer} [width] - [description] - * @param {integer} [height] - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - generateTexture: function (key, width, height) - { - var sys = this.scene.sys; - - if (width === undefined) { width = sys.game.config.width; } - if (height === undefined) { height = sys.game.config.height; } - - Graphics.TargetCamera.setViewport(0, 0, width, height); - Graphics.TargetCamera.scrollX = this.x; - Graphics.TargetCamera.scrollY = this.y; - - var texture; - var ctx; - - if (typeof key === 'string') - { - if (sys.textures.exists(key)) - { - // Key is a string, it DOES exist in the Texture Manager AND is a canvas, so draw to it - - texture = sys.textures.get(key); - - var src = texture.getSourceImage(); - - if (src instanceof HTMLCanvasElement) - { - ctx = src.getContext('2d'); - } - } - else - { - // Key is a string and doesn't exist in the Texture Manager, so generate and save it - - texture = sys.textures.createCanvas(key, width, height); - - ctx = texture.getSourceImage().getContext('2d'); - } - } - else if (key instanceof HTMLCanvasElement) - { - // Key is a Canvas, so draw to it - - ctx = key.getContext('2d'); - } - - if (ctx) - { - this.renderCanvas(sys.game.renderer, this, 0, Graphics.TargetCamera, ctx); - - if (sys.game.renderer.gl && texture) - { - texture.source[0].glTexture = sys.game.renderer.canvasToTexture(ctx.canvas, texture.source[0].glTexture, true, 0); - } - } - - return this; - } - -}); - -/** - * A Camera used specifically by the Graphics system for rendering to textures. - * - * @name Phaser.GameObjects.Graphics.TargetCamera - * @type {Phaser.Cameras.Scene2D.Camera} - * @since 3.1.0 - */ -Graphics.TargetCamera = new Camera(0, 0, 0, 0); - -module.exports = Graphics; - - -/***/ }), -/* 137 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Contains = __webpack_require__(68); -var GetPoint = __webpack_require__(271); -var GetPoints = __webpack_require__(272); -var Random = __webpack_require__(110); - -/** - * @classdesc - * An Ellipse object. - * - * This is a geometry object, containing numerical values and related methods to inspect and modify them. - * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. - * To render an Ellipse you should look at the capabilities of the Graphics class. - * - * @class Ellipse - * @memberOf Phaser.Geom - * @constructor - * @since 3.0.0 - * - * @param {number} [x=0] - The x position of the center of the ellipse. - * @param {number} [y=0] - The y position of the center of the ellipse. - * @param {number} [width=0] - The width of the ellipse. - * @param {number} [height=0] - The height of the ellipse. - */ -var Ellipse = new Class({ - - initialize: - - function Ellipse (x, y, width, height) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (width === undefined) { width = 0; } - if (height === undefined) { height = 0; } - - /** - * The x position of the center of the ellipse. - * - * @name Phaser.Geom.Ellipse#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x = x; - - /** - * The y position of the center of the ellipse. - * - * @name Phaser.Geom.Ellipse#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y = y; - - /** - * The width of the ellipse. - * - * @name Phaser.Geom.Ellipse#width - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.width = width; - - /** - * The height of the ellipse. - * - * @name Phaser.Geom.Ellipse#height - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.height = height; - }, - - /** - * Check to see if the Ellipse contains the given x / y coordinates. - * - * @method Phaser.Geom.Ellipse#contains - * @since 3.0.0 - * - * @param {number} x - The x coordinate to check within the ellipse. - * @param {number} y - The y coordinate to check within the ellipse. - * - * @return {boolean} True if the coordinates are within the ellipse, otherwise false. - */ - contains: function (x, y) - { - return Contains(this, x, y); - }, - - /** - * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse - * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point - * at 180 degrees around the circle. - * - * @method Phaser.Geom.Ellipse#getPoint - * @since 3.0.0 - * - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. - * @param {Phaser.Geom.Point|object} [out] - An object to store the return values in. If not given a Point object will be created. - * - * @return {Phaser.Geom.Point|object} A Point, or point-like object, containing the coordinates of the point around the ellipse. - */ - getPoint: function (position, point) - { - return GetPoint(this, position, point); - }, - - /** - * Returns an array of Point objects containing the coordinates of the points around the circumference of the Ellipse, - * based on the given quantity or stepRate values. - * - * @method Phaser.Geom.Ellipse#getPoints - * @since 3.0.0 - * - * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param {number} [stepRate] - Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate. - * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. - * - * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the circumference of the ellipse. - */ - getPoints: function (quantity, stepRate, output) - { - return GetPoints(this, quantity, stepRate, output); - }, - - /** - * Returns a uniformly distributed random point from anywhere within the given Ellipse. - * - * @method Phaser.Geom.Ellipse#getRandomPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Point|object} [point] - A Point or point-like object to set the random `x` and `y` values in. - * - * @return {Phaser.Geom.Point|object} A Point object with the random values set in the `x` and `y` properties. - */ - getRandomPoint: function (point) - { - return Random(this, point); - }, - - /** - * Sets the x, y, width and height of this ellipse. - * - * @method Phaser.Geom.Ellipse#setTo - * @since 3.0.0 - * - * @param {number} x - The x position of the center of the ellipse. - * @param {number} y - The y position of the center of the ellipse. - * @param {number} width - The width of the ellipse. - * @param {number} height - The height of the ellipse. - * - * @return {Phaser.Geom.Ellipse} This Ellipse object. - */ - setTo: function (x, y, width, height) - { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - - return this; - }, - - /** - * Sets this Ellipse to be empty with a width and height of zero. - * Does not change its position. - * - * @method Phaser.Geom.Ellipse#setEmpty - * @since 3.0.0 - * - * @return {Phaser.Geom.Ellipse} This Ellipse object. - */ - setEmpty: function () - { - this.width = 0; - this.height = 0; - - return this; - }, - - /** - * Sets the position of this Ellipse. - * - * @method Phaser.Geom.Ellipse#setPosition - * @since 3.0.0 - * - * @param {number} x - The x position of the center of the ellipse. - * @param {number} y - The y position of the center of the ellipse. - * - * @return {Phaser.Geom.Ellipse} This Ellipse object. - */ - setPosition: function (x, y) - { - if (y === undefined) { y = x; } - - this.x = x; - this.y = y; - - return this; - }, - - /** - * Sets the size of this Ellipse. - * Does not change its position. - * - * @method Phaser.Geom.Ellipse#setSize - * @since 3.0.0 - * - * @param {number} width - The width of the ellipse. - * @param {number} [height=width] - The height of the ellipse. - * - * @return {Phaser.Geom.Ellipse} This Ellipse object. - */ - setSize: function (width, height) - { - if (height === undefined) { height = width; } - - this.width = width; - this.height = height; - - return this; - }, - - /** - * Checks to see if the Ellipse is empty: has a width or height equal to zero. - * - * @method Phaser.Geom.Ellipse#isEmpty - * @since 3.0.0 - * - * @return {boolean} True if the Ellipse is empty, otherwise false. - */ - isEmpty: function () - { - return (this.width <= 0 || this.height <= 0); - }, - - /** - * Returns the minor radius of the ellipse. Also known as the Semi Minor Axis. - * - * @method Phaser.Geom.Ellipse#getMinorRadius - * @since 3.0.0 - * - * @return {number} The minor radius. - */ - getMinorRadius: function () - { - return Math.min(this.width, this.height) / 2; - }, - - /** - * Returns the major radius of the ellipse. Also known as the Semi Major Axis. - * - * @method Phaser.Geom.Ellipse#getMajorRadius - * @since 3.0.0 - * - * @return {number} The major radius. - */ - getMajorRadius: function () - { - return Math.max(this.width, this.height) / 2; - }, - - /** - * The left position of the Ellipse. - * - * @name Phaser.Geom.Ellipse#left - * @type {number} - * @since 3.0.0 - */ - left: { - - get: function () - { - return this.x - (this.width / 2); - }, - - set: function (value) - { - this.x = value + (this.width / 2); - } - - }, - - /** - * The right position of the Ellipse. - * - * @name Phaser.Geom.Ellipse#right - * @type {number} - * @since 3.0.0 - */ - right: { - - get: function () - { - return this.x + (this.width / 2); - }, - - set: function (value) - { - this.x = value - (this.width / 2); - } - - }, - - /** - * The top position of the Ellipse. - * - * @name Phaser.Geom.Ellipse#top - * @type {number} - * @since 3.0.0 - */ - top: { - - get: function () - { - return this.y - (this.height / 2); - }, - - set: function (value) - { - this.y = value + (this.height / 2); - } - - }, - - /** - * The bottom position of the Ellipse. - * - * @name Phaser.Geom.Ellipse#bottom - * @type {number} - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return this.y + (this.height / 2); - }, - - set: function (value) - { - this.y = value - (this.height / 2); - } - - } - -}); - -module.exports = Ellipse; - - -/***/ }), -/* 138 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse based on the given angle. - * - * @function Phaser.Geom.Ellipse.CircumferencePoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on. - * @param {number} angle - The angle from the center of the Ellipse to the circumference to return the point from. Given in radians. - * @param {Phaser.Geom.Point|object} [out] - A Point, or point-like object, to store the results in. If not given a Point will be created. - * - * @return {Phaser.Geom.Point|object} A Point object where the `x` and `y` properties are the point on the circumference. - */ -var CircumferencePoint = function (ellipse, angle, out) -{ - if (out === undefined) { out = new Point(); } - - var halfWidth = ellipse.width / 2; - var halfHeight = ellipse.height / 2; - - out.x = ellipse.x + halfWidth * Math.cos(angle); - out.y = ellipse.y + halfHeight * Math.sin(angle); - - return out; -}; - -module.exports = CircumferencePoint; - - -/***/ }), -/* 139 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var GameObject = __webpack_require__(1); -var GravityWell = __webpack_require__(573); -var List = __webpack_require__(86); -var ParticleEmitter = __webpack_require__(574); -var Render = __webpack_require__(613); - -/** - * @classdesc - * [description] - * - * @class ParticleEmitterManager - * @extends Phaser.GameObjects.Particles.GameObject - * @memberOf Phaser.GameObjects.Particles - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Particles.Components.Depth - * @extends Phaser.GameObjects.Particles.Components.Visible - * @extends Phaser.GameObjects.Particles.Components.Pipeline - * - * @param {Phaser.Scene} scene - [description] - * @param {string} texture - [description] - * @param {string|integer} frame - [description] - * @param {[type]} emitters - [description] - */ -var ParticleEmitterManager = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Depth, - Components.Visible, - Components.Pipeline, - Render - ], - - initialize: - - // frame is optional and can contain the emitters array or object if skipped - function ParticleEmitterManager (scene, texture, frame, emitters) - { - GameObject.call(this, scene, 'ParticleEmitterManager'); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#blendMode - * @type {number} - * @default -1 - * @private - * @since 3.0.0 - */ - this.blendMode = -1; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#timeScale - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#texture - * @type {Phaser.Textures.Texture} - * @default null - * @since 3.0.0 - */ - this.texture = null; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#frame - * @type {Phaser.Textures.Frame} - * @default null - * @since 3.0.0 - */ - this.frame = null; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#frameNames - * @type {array} - * @since 3.0.0 - */ - this.frameNames = []; - - // frame is optional and can contain the emitters array or object if skipped - if (frame !== null && (typeof frame === 'object' || Array.isArray(frame))) - { - emitters = frame; - frame = null; - } - - this.setTexture(texture, frame); - - this.initPipeline('TextureTintPipeline'); - - /** - * A list of Emitters being managed by this Emitter Manager. - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#emitters - * @type {Phaser.Structs.List} - * @since 3.0.0 - */ - this.emitters = new List(this); - - /** - * A list of Gravity Wells being managed by this Emitter Manager. - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#wells - * @type {Phaser.Structs.List} - * @since 3.0.0 - */ - this.wells = new List(this); - - if (emitters) - { - // An array of emitter configs? - if (!Array.isArray(emitters)) - { - emitters = [ emitters ]; - } - - for (var i = 0; i < emitters.length; i++) - { - this.createEmitter(emitters[i]); - } - } - }, - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setTexture - * @since 3.0.0 - * - * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. - * @param {string|integer} [frame] - The name or index of the frame within the Texture. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. - */ - setTexture: function (key, frame) - { - this.texture = this.scene.sys.textures.get(key); - - return this.setFrame(frame); - }, - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * It can be either a string or an index. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setFrame - * @since 3.0.0 - * - * @param {string|integer} [frame] - The name or index of the frame within the Texture. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. - */ - setFrame: function (frame) - { - this.frame = this.texture.get(frame); - - this.frameNames = this.texture.getFramesFromTextureSource(this.frame.sourceIndex); - - this.defaultFrame = this.frame; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setEmitterFrames - * @since 3.0.0 - * - * @param {[type]} frames - [description] - * @param {[type]} emitter - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. - */ - setEmitterFrames: function (frames, emitter) - { - if (!Array.isArray(frames)) - { - frames = [ frames ]; - } - - var out = emitter.frames; - - out.length = 0; - - for (var i = 0; i < frames.length; i++) - { - var frame = frames[i]; - - if (this.frameNames.indexOf(frame) !== -1) - { - out.push(this.texture.get(frame)); - } - } - - if (out.length > 0) - { - emitter.defaultFrame = out[0]; - } - else - { - emitter.defaultFrame = this.defaultFrame; - } - - return this; - }, - - /** - * Adds an existing Particle Emitter to this Manager. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#addEmitter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Particle Emitter to add to this Emitter Manager. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} The Particle Emitter that was added to this Emitter Manager. - */ - addEmitter: function (emitter) - { - return this.emitters.add(emitter); - }, - - /** - * Creates a new Particle Emitter object, adds it to this Manager and returns a reference to it. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#createEmitter - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} The Particle Emitter that was created. - */ - createEmitter: function (config) - { - return this.addEmitter(new ParticleEmitter(this, config)); - }, - - /** - * Adds an existing Gravity Well object to this Manager. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#addGravityWell - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.GravityWell} well - The Gravity Well to add to this Emitter Manager. - * - * @return {Phaser.GameObjects.Particles.GravityWell} The Gravity Well that was added to this Emitter Manager. - */ - addGravityWell: function (well) - { - return this.wells.add(well); - }, - - /** - * Creates a new Gravity Well, adds it to this Manager and returns a reference to it. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#createGravityWell - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Particles.GravityWell} The Gravity Well that was created. - */ - createGravityWell: function (config) - { - return this.addGravityWell(new GravityWell(config)); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#emitParticle - * @since 3.0.0 - * - * @param {integer} count - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. - */ - emitParticle: function (count, x, y) - { - var emitters = this.emitters.list; - - for (var i = 0; i < emitters.length; i++) - { - var emitter = emitters[i]; - - if (emitter.active) - { - emitter.emitParticle(count, x, y); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#emitParticleAt - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {integer} count - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. - */ - emitParticleAt: function (x, y, count) - { - return this.emitParticle(count, x, y); - }, - - /** - * Pauses this Emitter Manager. - * - * This has the effect of pausing all emitters, and all particles of those emitters, currently under its control. - * - * The particles will still render, but they will not have any of their logic updated. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#pause - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. - */ - pause: function () - { - this.active = false; - - return this; - }, - - /** - * Resumes this Emitter Manager, should it have been previously paused. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#resume - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. - */ - resume: function () - { - this.active = true; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#getProcessors - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getProcessors: function () - { - return this.wells.getAll('active', true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#preUpdate - * @since 3.0.0 - * - * @param {[type]} time - [description] - * @param {[type]} delta - [description] - */ - preUpdate: function (time, delta) - { - // Scale the delta - delta *= this.timeScale; - - var emitters = this.emitters.list; - - for (var i = 0; i < emitters.length; i++) - { - var emitter = emitters[i]; - - if (emitter.active) - { - emitter.preUpdate(time, delta); - } - } - } - -}); - -module.exports = ParticleEmitterManager; - - -/***/ }), -/* 140 */ +/* 144 */ /***/ (function(module, exports) { /** @@ -27675,2212 +27580,33 @@ module.exports = ParticleEmitterManager; */ /** - * [description] - * - * @function Phaser.Utils.Array.GetRandomElement - * @since 3.0.0 - * - * @param {array} array - The array to select the random entry from. - * @param {integer} [start=0] - [description] - * @param {integer} [length=array.length] - [description] - * - * @return {object} A random element from the array, or `null` if no element could be found in the range given. + * @namespace Phaser.GameObjects.Graphics.Commands */ -var GetRandomElement = function (array, start, length) -{ - if (start === undefined) { start = 0; } - if (length === undefined) { length = array.length; } - var randomIndex = start + Math.floor(Math.random() * length); +module.exports = { + + ARC: 0, + BEGIN_PATH: 1, + CLOSE_PATH: 2, + FILL_RECT: 3, + LINE_TO: 4, + MOVE_TO: 5, + LINE_STYLE: 6, + FILL_STYLE: 7, + FILL_PATH: 8, + STROKE_PATH: 9, + FILL_TRIANGLE: 10, + STROKE_TRIANGLE: 11, + LINE_FX_TO: 12, + MOVE_FX_TO: 13, + SAVE: 14, + RESTORE: 15, + TRANSLATE: 16, + SCALE: 17, + ROTATE: 18 - return (array[randomIndex] === undefined) ? null : array[randomIndex]; }; -module.exports = GetRandomElement; - - -/***/ }), -/* 141 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CanvasPool = __webpack_require__(21); -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var CONST = __webpack_require__(19); -var GameObject = __webpack_require__(1); -var Render = __webpack_require__(616); -var RenderTextureCanvas = __webpack_require__(619); -var RenderTextureWebGL = __webpack_require__(620); - -/** - * @classdesc - * A Render Texture. - * - * @class RenderTexture - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.2.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.MatrixStack - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {integer} [width=32] - The width of the Render Texture. - * @param {integer} [height=32] - The height of the Render Texture. - */ -var RenderTexture = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.MatrixStack, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Size, - Components.Tint, - Components.Transform, - Components.Visible, - Render - ], - - initialize: - - function RenderTexture (scene, x, y, width, height) - { - if (width === undefined) { width = 32; } - if (height === undefined) { height = 32; } - - GameObject.call(this, scene, 'RenderTexture'); - - this.initMatrixStack(); - - this.renderer = scene.sys.game.renderer; - this.globalTint = 0xffffff; - this.globalAlpha = 1.0; - - if (this.renderer.type === CONST.WEBGL) - { - var gl = this.renderer.gl; - this.gl = gl; - this.fill = RenderTextureWebGL.fill; - this.clear = RenderTextureWebGL.clear; - this.draw = RenderTextureWebGL.draw; - this.drawFrame = RenderTextureWebGL.drawFrame; - this.texture = this.renderer.createTexture2D(0, gl.NEAREST, gl.NEAREST, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE, gl.RGBA, null, width, height, false); - this.framebuffer = this.renderer.createFramebuffer(width, height, this.texture, false); - } - else if (this.renderer.type === CONST.CANVAS) - { - this.fill = RenderTextureCanvas.fill; - this.clear = RenderTextureCanvas.clear; - this.draw = RenderTextureCanvas.draw; - this.drawFrame = RenderTextureCanvas.drawFrame; - this.canvas = CanvasPool.create2D(null, width, height); - this.context = this.canvas.getContext('2d'); - } - - this.setPosition(x, y); - this.setSize(width, height); - this.initPipeline('TextureTintPipeline'); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.RenderTexture#destroy - * @since 3.2.0 - */ - destroy: function () - { - GameObject.destroy.call(this); - - if (this.renderer.type === CONST.WEBGL) - { - this.renderer.deleteTexture(this.texture); - this.renderer.deleteFramebuffer(this.framebuffer); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.RenderTexture#setGlobalTint - * @since 3.2.0 - * - * @param {int} tint [description] - * - * @return {Phaser.GameObjects.RenderTexture} [description] - */ - setGlobalTint: function (tint) - { - this.globalTint = tint; - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.RenderTexture#setGlobalAlpha - * @since 3.2.0 - * - * @param {float} alpha [description] - * - * @return {Phaser.GameObjects.RenderTexture} [description] - */ - setGlobalAlpha: function (alpha) - { - this.globalAlpha = alpha; - return this; - } - - /** - * Fills the Render Texture with the given color. - * - * @method Phaser.GameObjects.RenderTexture#fill - * @since 3.2.0 - * - * @param {number} rgb - The color to fill the Render Texture with. - * - * @return {Phaser.GameObjects.RenderTexture} This Game Object. - */ - - /** - * Clears the Render Texture. - * - * @method Phaser.GameObjects.RenderTexture#clear - * @since 3.2.0 - * - * @return {Phaser.GameObjects.RenderTexture} This Game Object. - */ - - /** - * Draws a texture frame to the Render Texture at the given position. - * - * @method Phaser.GameObjects.RenderTexture#draw - * @since 3.2.0 - * - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * @param {number} x - The x position to draw the frame at. - * @param {number} y - The y position to draw the frame at. - * - * @return {Phaser.GameObjects.RenderTexture} This Game Object. - */ - -}); - -module.exports = RenderTexture; - - -/***/ }), -/* 142 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var AddToDOM = __webpack_require__(125); -var CanvasPool = __webpack_require__(21); -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var CONST = __webpack_require__(19); -var GameObject = __webpack_require__(1); -var GetTextSize = __webpack_require__(621); -var GetValue = __webpack_require__(4); -var RemoveFromDOM = __webpack_require__(234); -var TextRender = __webpack_require__(622); -var TextStyle = __webpack_require__(625); - -/** - * @classdesc - * [description] - * - * @class Text - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string|string[]} text - The text this Text object will display. - * @param {object} style - The text style configuration object. - */ -var Text = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Tint, - Components.Transform, - Components.Visible, - TextRender - ], - - initialize: - - function Text (scene, x, y, text, style) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - - GameObject.call(this, scene, 'Text'); - - this.setPosition(x, y); - this.setOrigin(0, 0); - this.initPipeline('TextureTintPipeline'); - - /** - * The canvas element that the text is rendered to. - * - * @name Phaser.GameObjects.Text#canvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.canvas = CanvasPool.create(this); - - /** - * The context of the canvas element that the text is rendered to. - * - * @name Phaser.GameObjects.Text#context - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.context = this.canvas.getContext('2d'); - - /** - * [description] - * - * @name Phaser.GameObjects.Text#style - * @type {Phaser.GameObjects.Components.TextStyle} - * @since 3.0.0 - */ - this.style = new TextStyle(this, style); - - /** - * [description] - * - * @name Phaser.GameObjects.Text#autoRound - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.autoRound = true; - - /** - * The Regular Expression that is used to split the text up into lines, in - * multi-line text. By default this is `/(?:\r\n|\r|\n)/`. - * You can change this RegExp to be anything else that you may need. - * - * @name Phaser.GameObjects.Text#splitRegExp - * @type {object} - * @since 3.0.0 - */ - this.splitRegExp = /(?:\r\n|\r|\n)/; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#text - * @type {string} - * @since 3.0.0 - */ - this.text = ''; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#resolution - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.resolution = 1; - - /** - * Specify a padding value which is added to the line width and height when calculating the Text size. - * Allows you to add extra spacing if the browser is unable to accurately determine the true font dimensions. - * - * @name Phaser.GameObjects.Text#padding - * @type {object} - * @since 3.0.0 - */ - this.padding = { left: 0, right: 0, top: 0, bottom: 0 }; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#width - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.width = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#height - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.height = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#canvasTexture - * @type {?[type]} - * @default null - * @since 3.0.0 - */ - this.canvasTexture = null; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#dirty - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.dirty = false; - - this.initRTL(); - - if (style && style.padding) - { - this.setPadding(style.padding); - } - - if (style && style.lineSpacing) - { - this._lineSpacing = style.lineSpacing; - } - - this.setText(text); - - if (scene.sys.game.config.renderType === CONST.WEBGL) - { - scene.sys.game.renderer.onContextRestored(function () - { - this.canvasTexture = null; - this.dirty = true; - }, this); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#initRTL - * @since 3.0.0 - */ - initRTL: function () - { - if (!this.style.rtl) - { - return; - } - - // Here is where the crazy starts. - // - // Due to browser implementation issues, you cannot fillText BiDi text to a canvas - // that is not part of the DOM. It just completely ignores the direction property. - - this.canvas.dir = 'rtl'; - - // Experimental atm, but one day ... - this.context.direction = 'rtl'; - - // Add it to the DOM, but hidden within the parent canvas. - this.canvas.style.display = 'none'; - - AddToDOM(this.canvas, this.scene.sys.canvas); - - // And finally we set the x origin - this.originX = 1; - }, - - /** - * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal - * bounds. - * - * @method Phaser.GameObjects.Text#runWordWrap - * @since 3.0.0 - * - * @param {string} text - The text to perform word wrap detection against. - * - * @return {string} The text after wrapping has been applied. - */ - runWordWrap: function (text) - { - var style = this.style; - - if (style.wordWrapCallback) - { - var wrappedLines = style.wordWrapCallback.call(style.wordWrapCallbackScope, text, this); - - if (Array.isArray(wrappedLines)) - { - wrappedLines = wrappedLines.join('\n'); - } - - return wrappedLines; - } - else if (style.wordWrapWidth) - { - if (style.wordWrapUseAdvanced) - { - return this.advancedWordWrap(text, this.context, this.style.wordWrapWidth); - } - else - { - return this.basicWordWrap(text, this.context, this.style.wordWrapWidth); - } - } - else - { - return text; - } - }, - - /** - * Advanced wrapping algorithm that will wrap words as the line grows longer than its horizontal - * bounds. Consecutive spaces will be collapsed and replaced with a single space. Lines will be - * trimmed of white space before processing. Throws an error if wordWrapWidth is less than a - * single character. - * - * @method Phaser.GameObjects.Text#advancedWordWrap - * @since 3.0.0 - * - * @param {string} text - The text to perform word wrap detection against. - * @param {CanvasRenderingContext2D} context - [description] - * @param {number} wordWrapWidth - [description] - * - * @return {string} The wrapped text. - */ - advancedWordWrap: function (text, context, wordWrapWidth) - { - var output = ''; - - // Condense consecutive spaces and split into lines - var lines = text - .replace(/ +/gi, ' ') - .split(this.splitRegExp); - - var linesCount = lines.length; - - for (var i = 0; i < linesCount; i++) - { - var line = lines[i]; - var out = ''; - - // Trim whitespace - line = line.replace(/^ *|\s*$/gi, ''); - - // If entire line is less than wordWrapWidth append the entire line and exit early - var lineWidth = context.measureText(line).width; - - if (lineWidth < wordWrapWidth) - { - output += line + '\n'; - continue; - } - - // Otherwise, calculate new lines - var currentLineWidth = wordWrapWidth; - - // Split into words - var words = line.split(' '); - - for (var j = 0; j < words.length; j++) - { - var word = words[j]; - var wordWithSpace = word + ' '; - var wordWidth = context.measureText(wordWithSpace).width; - - if (wordWidth > currentLineWidth) - { - // Break word - if (j === 0) - { - // Shave off letters from word until it's small enough - var newWord = wordWithSpace; - - while (newWord.length) - { - newWord = newWord.slice(0, -1); - wordWidth = context.measureText(newWord).width; - - if (wordWidth <= currentLineWidth) - { - break; - } - } - - // If wordWrapWidth is too small for even a single letter, shame user - // failure with a fatal error - if (!newWord.length) - { - throw new Error('This text\'s wordWrapWidth setting is less than a single character!'); - } - - // Replace current word in array with remainder - var secondPart = word.substr(newWord.length); - - words[j] = secondPart; - - // Append first piece to output - out += newWord; - } - - // If existing word length is 0, don't include it - var offset = (words[j].length) ? j : j + 1; - - // Collapse rest of sentence and remove any trailing white space - var remainder = words.slice(offset).join(' ') - .replace(/[ \n]*$/gi, ''); - - // Prepend remainder to next line - lines[i + 1] = remainder + ' ' + (lines[i + 1] || ''); - linesCount = lines.length; - - break; // Processing on this line - - // Append word with space to output - } - else - { - out += wordWithSpace; - currentLineWidth -= wordWidth; - } - } - - // Append processed line to output - output += out.replace(/[ \n]*$/gi, '') + '\n'; - } - - // Trim the end of the string - output = output.replace(/[\s|\n]*$/gi, ''); - - return output; - }, - - /** - * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal - * bounds. Spaces are not collapsed and whitespace is not trimmed. - * - * @method Phaser.GameObjects.Text#basicWordWrap - * @since 3.0.0 - * - * @param {string} text - The text to perform word wrap detection against. - * @param {CanvasRenderingContext2D} context - [description] - * @param {number} wordWrapWidth - [description] - * - * @return {string} The wrapped text. - */ - basicWordWrap: function (text, context, wordWrapWidth) - { - var result = ''; - var lines = text.split(this.splitRegExp); - - for (var i = 0; i < lines.length; i++) - { - var spaceLeft = wordWrapWidth; - var words = lines[i].split(' '); - - for (var j = 0; j < words.length; j++) - { - var wordWidth = context.measureText(words[j]).width; - var wordWidthWithSpace = wordWidth + context.measureText(' ').width; - - if (wordWidthWithSpace > spaceLeft) - { - // Skip printing the newline if it's the first word of the line that is greater - // than the word wrap width. - if (j > 0) - { - result += '\n'; - } - result += words[j] + ' '; - spaceLeft = wordWrapWidth - wordWidth; - } - else - { - spaceLeft -= wordWidthWithSpace; - result += words[j] + ' '; - } - } - - if (i < lines.length - 1) - { - result += '\n'; - } - } - - return result; - }, - - /** - * Runs the given text through this Text objects word wrapping and returns the results as an - * array, where each element of the array corresponds to a wrapped line of text. - * - * @method Phaser.GameObjects.Text#getWrappedText - * @since 3.0.0 - * - * @param {string} text - The text for which the wrapping will be calculated. If unspecified, the Text objects current text will be used. - * - * @return {string[]} An array of strings with the pieces of wrapped text. - */ - getWrappedText: function (text) - { - if (text === undefined) { text = this.text; } - - var wrappedLines = this.runWordWrap(text); - - return wrappedLines.split(this.splitRegExp); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setText - * @since 3.0.0 - * - * @param {string|string[]} value - The string, or array of strings, to be set as the content of this Text object. - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setText: function (value) - { - if (!value && value !== 0) - { - value = ''; - } - - if (Array.isArray(value)) - { - value = value.join('\n'); - } - - if (value !== this.text) - { - this.text = value.toString(); - - this.updateText(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setStyle - * @since 3.0.0 - * - * @param {object} style - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setStyle: function (style) - { - return this.style.setStyle(style); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFont - * @since 3.0.0 - * - * @param {string} font - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFont: function (font) - { - return this.style.setFont(font); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFontFamily - * @since 3.0.0 - * - * @param {string} family - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFontFamily: function (family) - { - return this.style.setFontFamily(family); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFontSize - * @since 3.0.0 - * - * @param {number} size - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFontSize: function (size) - { - return this.style.setFontSize(size); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFontStyle - * @since 3.0.0 - * - * @param {string} style - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFontStyle: function (style) - { - return this.style.setFontStyle(style); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFixedSize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFixedSize: function (width, height) - { - return this.style.setFixedSize(width, height); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setBackgroundColor - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setBackgroundColor: function (color) - { - return this.style.setBackgroundColor(color); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFill - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFill: function (color) - { - return this.style.setFill(color); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setColor - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setColor: function (color) - { - return this.style.setColor(color); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setStroke - * @since 3.0.0 - * - * @param {string} color - [description] - * @param {number} thickness - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setStroke: function (color, thickness) - { - return this.style.setStroke(color, thickness); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadow - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {string} color - [description] - * @param {number} blur - [description] - * @param {boolean} shadowStroke - [description] - * @param {boolean} shadowFill - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadow: function (x, y, color, blur, shadowStroke, shadowFill) - { - return this.style.setShadow(x, y, color, blur, shadowStroke, shadowFill); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowOffset - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowOffset: function (x, y) - { - return this.style.setShadowOffset(x, y); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowColor - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowColor: function (color) - { - return this.style.setShadowColor(color); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowBlur - * @since 3.0.0 - * - * @param {number} blur - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowBlur: function (blur) - { - return this.style.setShadowBlur(blur); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowStroke - * @since 3.0.0 - * - * @param {boolean} enabled - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowStroke: function (enabled) - { - return this.style.setShadowStroke(enabled); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowFill - * @since 3.0.0 - * - * @param {boolean} enabled - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowFill: function (enabled) - { - return this.style.setShadowFill(enabled); - }, - - /** - * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width. - * - * @method Phaser.GameObjects.Text#setWordWrapWidth - * @since 3.0.0 - * - * @param {number|null} width - The maximum width of a line in pixels. Set to null to remove wrapping. - * @param {boolean} [useAdvancedWrap=false] - Whether or not to use the advanced wrapping - * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, - * spaces and whitespace are left as is. - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setWordWrapWidth: function (width, useAdvancedWrap) - { - return this.style.setWordWrapWidth(width, useAdvancedWrap); - }, - - /** - * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback. - * - * @method Phaser.GameObjects.Text#setWordWrapCallback - * @since 3.0.0 - * - * @param {function} callback - A custom function that will be responsible for wrapping the - * text. It will receive two arguments: text (the string to wrap), textObject (this Text - * instance). It should return the wrapped lines either as an array of lines or as a string with - * newline characters in place to indicate where breaks should happen. - * @param {object} [scope=null] - The scope that will be applied when the callback is invoked. - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setWordWrapCallback: function (callback, scope) - { - return this.style.setWordWrapCallback(callback, scope); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setAlign - * @since 3.0.0 - * - * @param {string} align - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setAlign: function (align) - { - return this.style.setAlign(align); - }, - - /** - * 'left' can be an object. - * If only 'left' and 'top' are given they are treated as 'x' and 'y' - * - * @method Phaser.GameObjects.Text#setPadding - * @since 3.0.0 - * - * @param {number|object} left - [description] - * @param {number} top - [description] - * @param {number} right - [description] - * @param {number} bottom - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setPadding: function (left, top, right, bottom) - { - if (typeof left === 'object') - { - var config = left; - - // If they specify x and/or y this applies to all - var x = GetValue(config, 'x', null); - - if (x !== null) - { - left = x; - right = x; - } - else - { - left = GetValue(config, 'left', 0); - right = GetValue(config, 'right', left); - } - - var y = GetValue(config, 'y', null); - - if (y !== null) - { - top = y; - bottom = y; - } - else - { - top = GetValue(config, 'top', 0); - bottom = GetValue(config, 'bottom', top); - } - } - else - { - if (left === undefined) { left = 0; } - if (top === undefined) { top = left; } - if (right === undefined) { right = left; } - if (bottom === undefined) { bottom = top; } - } - - this.padding.left = left; - this.padding.top = top; - this.padding.right = right; - this.padding.bottom = bottom; - - return this.updateText(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setMaxLines - * @since 3.0.0 - * - * @param {integer} [max=0] - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setMaxLines: function (max) - { - return this.style.setMaxLines(max); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#updateText - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - updateText: function () - { - var canvas = this.canvas; - var context = this.context; - var style = this.style; - var resolution = this.resolution; - var size = style.metrics; - - style.syncFont(canvas, context); - - var outputText = this.text; - - if (style.wordWrapWidth || style.wordWrapCallback) - { - outputText = this.runWordWrap(this.text); - } - - // Split text into lines - var lines = outputText.split(this.splitRegExp); - - var textSize = GetTextSize(this, size, lines); - - var padding = this.padding; - - var w = textSize.width + padding.left + padding.right; - var h = textSize.height + padding.top + padding.bottom; - - if (style.fixedWidth === 0) - { - this.width = w; - } - - if (style.fixedHeight === 0) - { - this.height = h; - } - - this.updateDisplayOrigin(); - - w *= resolution; - h *= resolution; - - w = Math.max(w, 1); - h = Math.max(h, 1); - - if (canvas.width !== w || canvas.height !== h) - { - canvas.width = w; - canvas.height = h; - style.syncFont(canvas, context); // Resizing resets the context - } - else - { - context.clearRect(0, 0, w, h); - } - - context.save(); - - // context.scale(resolution, resolution); - - if (style.backgroundColor) - { - context.fillStyle = style.backgroundColor; - context.fillRect(0, 0, w, h); - } - - style.syncStyle(canvas, context); - - context.textBaseline = 'alphabetic'; - - // Apply padding - context.translate(padding.left, padding.top); - - var linePositionX; - var linePositionY; - - // Draw text line by line - for (var i = 0; i < textSize.lines; i++) - { - linePositionX = style.strokeThickness / 2; - linePositionY = (style.strokeThickness / 2 + i * textSize.lineHeight) + size.ascent; - - if (i > 0) - { - linePositionY += (textSize.lineSpacing * i); - } - - if (style.rtl) - { - linePositionX = w - linePositionX; - } - else if (style.align === 'right') - { - linePositionX += textSize.width - textSize.lineWidths[i]; - } - else if (style.align === 'center') - { - linePositionX += (textSize.width - textSize.lineWidths[i]) / 2; - } - - if (this.autoRound) - { - linePositionX = Math.round(linePositionX); - linePositionY = Math.round(linePositionY); - } - - if (style.strokeThickness) - { - this.style.syncShadow(context, style.shadowStroke); - - context.strokeText(lines[i], linePositionX, linePositionY); - } - - if (style.color) - { - this.style.syncShadow(context, style.shadowFill); - - context.fillText(lines[i], linePositionX, linePositionY); - } - } - - context.restore(); - - this.dirty = true; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#getTextMetrics - * @since 3.0.0 - * - * @return {object} [description] - */ - getTextMetrics: function () - { - return this.style.getTextMetrics(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - var out = Components.ToJSON(this); - - // Extra Text data is added here - - var data = { - autoRound: this.autoRound, - text: this.text, - style: this.style.toJSON(), - resolution: this.resolution, - padding: { - left: this.padding.left, - right: this.padding.right, - top: this.padding.top, - bottom: this.padding.bottom - } - }; - - out.data = data; - - return out; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#preDestroy - * @since 3.0.0 - */ - preDestroy: function () - { - if (this.style.rtl) - { - RemoveFromDOM(this.canvas); - } - - CanvasPool.remove(this.canvas); - } - -}); - -module.exports = Text; - - -/***/ }), -/* 143 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CanvasPool = __webpack_require__(21); -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var CONST = __webpack_require__(19); -var GameObject = __webpack_require__(1); -var GetPowerOfTwo = __webpack_require__(291); -var TileSpriteRender = __webpack_require__(627); - -/** - * @classdesc - * [description] - * - * @class TileSprite - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {number} width - The width of the Game Object. - * @param {number} height - The height of the Game Object. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var TileSprite = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Size, - Components.Texture, - Components.Tint, - Components.Transform, - Components.Visible, - TileSpriteRender - ], - - initialize: - - function TileSprite (scene, x, y, width, height, texture, frame) - { - var renderer = scene.sys.game.renderer; - - GameObject.call(this, scene, 'TileSprite'); - - /** - * [description] - * - * @name Phaser.GameObjects.TileSprite#tilePositionX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.tilePositionX = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.TileSprite#tilePositionY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.tilePositionY = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.TileSprite#dirty - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.dirty = true; - - /** - * [description] - * - * @name Phaser.GameObjects.TileSprite#tileTexture - * @type {?[type]} - * @default null - * @since 3.0.0 - */ - this.tileTexture = null; - - /** - * [description] - * - * @name Phaser.GameObjects.TileSprite#renderer - * @type {[type]} - * @since 3.0.0 - */ - this.renderer = renderer; - - this.setTexture(texture, frame); - this.setPosition(x, y); - this.setSize(width, height); - this.setOriginFromFrame(); - this.initPipeline('TextureTintPipeline'); - - /** - * The next power of two value from the width of the Frame. - * - * @name Phaser.GameObjects.TileSprite#potWidth - * @type {integer} - * @since 3.0.0 - */ - this.potWidth = GetPowerOfTwo(this.frame.width); - - /** - * The next power of two value from the height of the Frame. - * - * @name Phaser.GameObjects.TileSprite#potHeight - * @type {integer} - * @since 3.0.0 - */ - this.potHeight = GetPowerOfTwo(this.frame.height); - - /** - * [description] - * - * @name Phaser.GameObjects.TileSprite#canvasPattern - * @type {?CanvasPattern} - * @default null - * @since 3.0.0 - */ - this.canvasPattern = null; - - /** - * [description] - * - * @name Phaser.GameObjects.TileSprite#canvasBuffer - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.canvasBuffer = CanvasPool.create2D(null, this.potWidth, this.potHeight); - - /** - * [description] - * - * @name Phaser.GameObjects.TileSprite#canvasBufferCtx - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.canvasBufferCtx = this.canvasBuffer.getContext('2d'); - - this.oldFrame = null; - - this.updateTileTexture(); - - if (scene.sys.game.config.renderType === CONST.WEBGL) - { - scene.sys.game.renderer.onContextRestored(function (renderer) - { - var gl = renderer.gl; - - this.tileTexture = null; - this.dirty = true; - this.tileTexture = renderer.createTexture2D(0, gl.LINEAR, gl.LINEAR, gl.REPEAT, gl.REPEAT, gl.RGBA, this.canvasBuffer, this.potWidth, this.potHeight); - }, this); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.TileSprite#updateTileTexture - * @since 3.0.0 - */ - updateTileTexture: function () - { - if (!this.dirty && this.oldFrame === this.frame) - { - return; - } - - this.oldFrame = this.frame; - - this.canvasBufferCtx.clearRect(0, 0, this.canvasBuffer.width, this.canvasBuffer.height); - - if (this.renderer.gl) - { - this.canvasBufferCtx.drawImage( - this.frame.source.image, - this.frame.cutX, this.frame.cutY, - this.frame.cutWidth, this.frame.cutHeight, - 0, 0, - this.potWidth, this.potHeight - ); - - this.tileTexture = this.renderer.canvasToTexture(this.canvasBuffer, this.tileTexture, (this.tileTexture === null), this.scaleMode); - } - else - { - this.canvasBuffer.width = this.frame.cutWidth; - this.canvasBuffer.height = this.frame.cutHeight; - this.canvasBufferCtx.drawImage( - this.frame.source.image, - this.frame.cutX, this.frame.cutY, - this.frame.cutWidth, this.frame.cutHeight, - 0, 0, - this.frame.cutWidth, this.frame.cutHeight - ); - - this.canvasPattern = this.canvasBufferCtx.createPattern(this.canvasBuffer, 'repeat'); - } - - this.dirty = false; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.TileSprite#destroy - * @since 3.0.0 - */ - destroy: function () - { - if (this.renderer) - { - this.renderer.deleteTexture(this.tileTexture); - } - - CanvasPool.remove(this.canvasBuffer); - - this.canvasPattern = null; - this.canvasBufferCtx = null; - this.canvasBuffer = null; - - this.renderer = null; - this.visible = false; - } - -}); - -module.exports = TileSprite; - - -/***/ }), -/* 144 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Mesh = __webpack_require__(88); - -/** - * @classdesc - * A Quad Game Object. - * - * A Quad is a Mesh Game Object pre-configured with two triangles arranged into a rectangle, with a single - * texture spread across them. - * - * You can manipulate the corner points of the quad via the getters and setters such as `topLeftX`, and also - * change their alpha and color values. The quad itself can be moved by adjusting the `x` and `y` properties. - * - * @class Quad - * @extends Phaser.GameObjects.Mesh - * @memberOf Phaser.GameObjects - * @constructor - * @webglOnly - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var Quad = new Class({ - - Extends: Mesh, - - initialize: - - function Quad (scene, x, y, texture, frame) - { - // 0----3 - // |\ B| - // | \ | - // | \ | - // | A \| - // | \ - // 1----2 - - var vertices = [ - 0, 0, // tl - 0, 0, // bl - 0, 0, // br - 0, 0, // tl - 0, 0, // br - 0, 0 // tr - ]; - var uv = [ - 0, 0, // tl - 0, 1, // bl - 1, 1, // br - 0, 0, // tl - 1, 1, // br - 1, 0 // tr - ]; - var colors = [ - 0xffffff, // tl - 0xffffff, // bl - 0xffffff, // br - 0xffffff, // tl - 0xffffff, // br - 0xffffff // tr - ]; - var alphas = [ - 1, // tl - 1, // bl - 1, // br - 1, // tl - 1, // br - 1 // tr - ]; - - Mesh.call(this, scene, x, y, vertices, uv, colors, alphas, texture, frame); - - this.resetPosition(); - }, - - /** - * The top-left x vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#topLeftX - * @type {number} - * @since 3.0.0 - */ - topLeftX: { - - get: function () - { - return this.x + this.vertices[0]; - }, - - set: function (value) - { - this.vertices[0] = value - this.x; - this.vertices[6] = value - this.x; - } - - }, - - /** - * The top-left y vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#topLeftY - * @type {number} - * @since 3.0.0 - */ - topLeftY: { - - get: function () - { - return this.y + this.vertices[1]; - }, - - set: function (value) - { - this.vertices[1] = value - this.y; - this.vertices[7] = value - this.y; - } - - }, - - /** - * The top-right x vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#topRightX - * @type {number} - * @since 3.0.0 - */ - topRightX: { - - get: function () - { - return this.x + this.vertices[10]; - }, - - set: function (value) - { - this.vertices[10] = value - this.x; - } - - }, - - /** - * The top-right y vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#topRightY - * @type {number} - * @since 3.0.0 - */ - topRightY: { - - get: function () - { - return this.y + this.vertices[11]; - }, - - set: function (value) - { - this.vertices[11] = value - this.y; - } - - }, - - /** - * The bottom-left x vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomLeftX - * @type {number} - * @since 3.0.0 - */ - bottomLeftX: { - - get: function () - { - return this.x + this.vertices[2]; - }, - - set: function (value) - { - this.vertices[2] = value - this.x; - } - - }, - - /** - * The bottom-left y vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomLeftY - * @type {number} - * @since 3.0.0 - */ - bottomLeftY: { - - get: function () - { - return this.y + this.vertices[3]; - }, - - set: function (value) - { - this.vertices[3] = value - this.y; - } - - }, - - /** - * The bottom-right x vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomRightX - * @type {number} - * @since 3.0.0 - */ - bottomRightX: { - - get: function () - { - return this.x + this.vertices[4]; - }, - - set: function (value) - { - this.vertices[4] = value - this.x; - this.vertices[8] = value - this.x; - } - - }, - - /** - * The bottom-right y vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomRightY - * @type {number} - * @since 3.0.0 - */ - bottomRightY: { - - get: function () - { - return this.y + this.vertices[5]; - }, - - set: function (value) - { - this.vertices[5] = value - this.y; - this.vertices[9] = value - this.y; - } - - }, - - /** - * The top-left alpha value of this Quad. - * - * @name Phaser.GameObjects.Quad#topLeftAlpha - * @type {float} - * @since 3.0.0 - */ - topLeftAlpha: { - - get: function () - { - return this.alphas[0]; - }, - - set: function (value) - { - this.alphas[0] = value; - this.alphas[3] = value; - } - - }, - - /** - * The top-right alpha value of this Quad. - * - * @name Phaser.GameObjects.Quad#topRightAlpha - * @type {float} - * @since 3.0.0 - */ - topRightAlpha: { - - get: function () - { - return this.alphas[5]; - }, - - set: function (value) - { - this.alphas[5] = value; - } - - }, - - /** - * The bottom-left alpha value of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomLeftAlpha - * @type {float} - * @since 3.0.0 - */ - bottomLeftAlpha: { - - get: function () - { - return this.alphas[1]; - }, - - set: function (value) - { - this.alphas[1] = value; - } - - }, - - /** - * The bottom-right alpha value of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomRightAlpha - * @type {float} - * @since 3.0.0 - */ - bottomRightAlpha: { - - get: function () - { - return this.alphas[2]; - }, - - set: function (value) - { - this.alphas[2] = value; - this.alphas[4] = value; - } - - }, - - /** - * The top-left color value of this Quad. - * - * @name Phaser.GameObjects.Quad#topLeftColor - * @type {number} - * @since 3.0.0 - */ - topLeftColor: { - - get: function () - { - return this.colors[0]; - }, - - set: function (value) - { - this.colors[0] = value; - this.colors[3] = value; - } - - }, - - /** - * The top-right color value of this Quad. - * - * @name Phaser.GameObjects.Quad#topRightColor - * @type {number} - * @since 3.0.0 - */ - topRightColor: { - - get: function () - { - return this.colors[5]; - }, - - set: function (value) - { - this.colors[5] = value; - } - - }, - - /** - * The bottom-left color value of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomLeftColor - * @type {number} - * @since 3.0.0 - */ - bottomLeftColor: { - - get: function () - { - return this.colors[1]; - }, - - set: function (value) - { - this.colors[1] = value; - } - - }, - - /** - * The bottom-right color value of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomRightColor - * @type {number} - * @since 3.0.0 - */ - bottomRightColor: { - - get: function () - { - return this.colors[2]; - }, - - set: function (value) - { - this.colors[2] = value; - this.colors[4] = value; - } - - }, - - /** - * Sets the top-left vertex position of this Quad. - * - * @method Phaser.GameObjects.Quad#setTopLeft - * @since 3.0.0 - * - * @param {number} x - The horizontal coordinate of the vertex. - * @param {number} y - The vertical coordinate of the vertex. - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - setTopLeft: function (x, y) - { - this.topLeftX = x; - this.topLeftY = y; - - return this; - }, - - /** - * Sets the top-right vertex position of this Quad. - * - * @method Phaser.GameObjects.Quad#setTopRight - * @since 3.0.0 - * - * @param {number} x - The horizontal coordinate of the vertex. - * @param {number} y - The vertical coordinate of the vertex. - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - setTopRight: function (x, y) - { - this.topRightX = x; - this.topRightY = y; - - return this; - }, - - /** - * Sets the bottom-left vertex position of this Quad. - * - * @method Phaser.GameObjects.Quad#setBottomLeft - * @since 3.0.0 - * - * @param {number} x - The horizontal coordinate of the vertex. - * @param {number} y - The vertical coordinate of the vertex. - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - setBottomLeft: function (x, y) - { - this.bottomLeftX = x; - this.bottomLeftY = y; - - return this; - }, - - /** - * Sets the bottom-right vertex position of this Quad. - * - * @method Phaser.GameObjects.Quad#setBottomRight - * @since 3.0.0 - * - * @param {number} x - The horizontal coordinate of the vertex. - * @param {number} y - The vertical coordinate of the vertex. - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - setBottomRight: function (x, y) - { - this.bottomRightX = x; - this.bottomRightY = y; - - return this; - }, - - /** - * Resets the positions of the four corner vertices of this Quad. - * - * @method Phaser.GameObjects.Quad#resetPosition - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - resetPosition: function () - { - var x = this.x; - var y = this.y; - var halfWidth = Math.floor(this.width / 2); - var halfHeight = Math.floor(this.height / 2); - - this.setTopLeft(x - halfWidth, y - halfHeight); - this.setTopRight(x + halfWidth, y - halfHeight); - this.setBottomLeft(x - halfWidth, y + halfHeight); - this.setBottomRight(x + halfWidth, y + halfHeight); - - return this; - }, - - /** - * Resets the alpha values used by this Quad back to 1. - * - * @method Phaser.GameObjects.Quad#resetAlpha - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - resetAlpha: function () - { - var alphas = this.alphas; - - alphas[0] = 1; - alphas[1] = 1; - alphas[2] = 1; - alphas[3] = 1; - alphas[4] = 1; - alphas[5] = 1; - - return this; - }, - - /** - * Resets the color values used by this Quad back to 0xffffff. - * - * @method Phaser.GameObjects.Quad#resetColors - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - resetColors: function () - { - var colors = this.colors; - - colors[0] = 0xffffff; - colors[1] = 0xffffff; - colors[2] = 0xffffff; - colors[3] = 0xffffff; - colors[4] = 0xffffff; - colors[5] = 0xffffff; - - return this; - }, - - /** - * Resets the position, alpha and color values used by this Quad. - * - * @method Phaser.GameObjects.Quad#reset - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - reset: function () - { - this.resetPosition(); - - this.resetAlpha(); - - return this.resetColors(); - } - -}); - -module.exports = Quad; - /***/ }), /* 145 */ @@ -29892,85 +27618,29 @@ module.exports = Quad; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// http://www.blackpawn.com/texts/pointinpoly/ - -// points is an array of Point-like objects with public x/y properties -// returns an array containing all points that are within the triangle, or an empty array if none -// if 'returnFirst' is true it will return after the first point within the triangle is found - /** - * [description] + * Checks if the given `width` and `height` are a power of two. + * Useful for checking texture dimensions. * - * @function Phaser.Geom.Triangle.ContainsArray + * @function Phaser.Math.Pow2.IsSizePowerOfTwo * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point[]} points - [description] - * @param {boolean} [returnFirst] - [description] - * @param {array} [out] - [description] + * @param {number} width - The width. + * @param {number} height - The height. * - * @return {Phaser.Geom.Point[]} [description] + * @return {boolean} `true` if `width` and `height` are a power of two, otherwise `false`. */ -var ContainsArray = function (triangle, points, returnFirst, out) +var IsSizePowerOfTwo = function (width, height) { - if (returnFirst === undefined) { returnFirst = false; } - if (out === undefined) { out = []; } - - var v0x = triangle.x3 - triangle.x1; - var v0y = triangle.y3 - triangle.y1; - - var v1x = triangle.x2 - triangle.x1; - var v1y = triangle.y2 - triangle.y1; - - var dot00 = (v0x * v0x) + (v0y * v0y); - var dot01 = (v0x * v1x) + (v0y * v1y); - var dot11 = (v1x * v1x) + (v1y * v1y); - - // Compute barycentric coordinates - var b = ((dot00 * dot11) - (dot01 * dot01)); - var inv = (b === 0) ? 0 : (1 / b); - - var u; - var v; - var v2x; - var v2y; - var dot02; - var dot12; - - var x1 = triangle.x1; - var y1 = triangle.y1; - - for (var i = 0; i < points.length; i++) - { - v2x = points[i].x - x1; - v2y = points[i].y - y1; - - dot02 = (v0x * v2x) + (v0y * v2y); - dot12 = (v1x * v2x) + (v1y * v2y); - - u = ((dot11 * dot02) - (dot01 * dot12)) * inv; - v = ((dot00 * dot12) - (dot01 * dot02)) * inv; - - if (u >= 0 && v >= 0 && (u + v < 1)) - { - out.push({ x: points[i].x, y: points[i].y }); - - if (returnFirst) - { - break; - } - } - } - - return out; + return (width > 0 && (width & (width - 1)) === 0 && height > 0 && (height & (height - 1)) === 0); }; -module.exports = ContainsArray; +module.exports = IsSizePowerOfTwo; /***/ }), /* 146 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -29978,40 +27648,192 @@ module.exports = ContainsArray; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var OS = __webpack_require__(76); +var Browser = __webpack_require__(100); +var CanvasPool = __webpack_require__(23); + /** - * [description] - * - * @function Phaser.Geom.Line.RotateAroundXY + * Determines the features of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.features` from within any Scene. + * + * @name Phaser.Device.Features * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Line} [description] + * + * @type {object} + * @property {?boolean} canvasBitBltShift - True if canvas supports a 'copy' bitblt onto itself when the source and destination regions overlap. + * @property {boolean} canvas - Is canvas available? + * @property {boolean} file - Is file available? + * @property {boolean} fileSystem - Is fileSystem available? + * @property {boolean} getUserMedia - Does the device support the getUserMedia API? + * @property {boolean} littleEndian - Is the device big or little endian? (only detected if the browser supports TypedArrays) + * @property {boolean} localStorage - Is localStorage available? + * @property {boolean} pointerLock - Is Pointer Lock available? + * @property {boolean} support32bit - Does the device context support 32bit pixel manipulation using array buffer views? + * @property {boolean} vibration - Does the device support the Vibration API? + * @property {boolean} webGL - Is webGL available? + * @property {boolean} worker - Is worker available? */ -var RotateAroundXY = function (line, x, y, angle) -{ - var c = Math.cos(angle); - var s = Math.sin(angle); +var Features = { - var tx = line.x1 - x; - var ty = line.y1 - y; + canvas: false, + canvasBitBltShift: null, + file: false, + fileSystem: false, + getUserMedia: true, + littleEndian: false, + localStorage: false, + pointerLock: false, + support32bit: false, + vibration: false, + webGL: false, + worker: false - line.x1 = tx * c - ty * s + x; - line.y1 = tx * s + ty * c + y; - - tx = line.x2 - x; - ty = line.y2 - y; - - line.x2 = tx * c - ty * s + x; - line.y2 = tx * s + ty * c + y; - - return line; }; -module.exports = RotateAroundXY; +// Check Little or Big Endian system. +// @author Matt DesLauriers (@mattdesl) +function checkIsLittleEndian () +{ + var a = new ArrayBuffer(4); + var b = new Uint8Array(a); + var c = new Uint32Array(a); + + b[0] = 0xa1; + b[1] = 0xb2; + b[2] = 0xc3; + b[3] = 0xd4; + + if (c[0] === 0xd4c3b2a1) + { + return true; + } + + if (c[0] === 0xa1b2c3d4) + { + return false; + } + else + { + // Could not determine endianness + return null; + } +} + +function init () +{ + Features.canvas = !!window['CanvasRenderingContext2D'] || OS.cocoonJS; + + try + { + Features.localStorage = !!localStorage.getItem; + } + catch (error) + { + Features.localStorage = false; + } + + Features.file = !!window['File'] && !!window['FileReader'] && !!window['FileList'] && !!window['Blob']; + Features.fileSystem = !!window['requestFileSystem']; + + var isUint8 = false; + + var testWebGL = function () + { + if (window['WebGLRenderingContext']) + { + try + { + var canvas = CanvasPool.createWebGL(this); + + if (OS.cocoonJS) + { + canvas.screencanvas = false; + } + + var ctx = canvas.getContext('webgl') || canvas.getContext('experimental-webgl'); + + var canvas2D = CanvasPool.create2D(this); + + var ctx2D = canvas2D.getContext('2d'); + + // Can't be done on a webgl context + var image = ctx2D.createImageData(1, 1); + + // Test to see if ImageData uses CanvasPixelArray or Uint8ClampedArray. + // @author Matt DesLauriers (@mattdesl) + isUint8 = image.data instanceof Uint8ClampedArray; + + CanvasPool.remove(canvas); + CanvasPool.remove(canvas2D); + + return !!ctx; + } + catch (e) + { + return false; + } + } + + return false; + }; + + Features.webGL = testWebGL(); + + Features.worker = !!window['Worker']; + + Features.pointerLock = 'pointerLockElement' in document || 'mozPointerLockElement' in document || 'webkitPointerLockElement' in document; + + navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia; + + window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL; + + Features.getUserMedia = Features.getUserMedia && !!navigator.getUserMedia && !!window.URL; + + // Older versions of firefox (< 21) apparently claim support but user media does not actually work + if (Browser.firefox && Browser.firefoxVersion < 21) + { + Features.getUserMedia = false; + } + + // Excludes iOS versions as they generally wrap UIWebView (eg. Safari WebKit) and it + // is safer to not try and use the fast copy-over method. + if (!OS.iOS && (Browser.ie || Browser.firefox || Browser.chrome)) + { + Features.canvasBitBltShift = true; + } + + // Known not to work + if (Browser.safari || Browser.mobileSafari) + { + Features.canvasBitBltShift = false; + } + + navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate; + + if (navigator.vibrate) + { + Features.vibration = true; + } + + if (typeof ArrayBuffer !== 'undefined' && typeof Uint8Array !== 'undefined' && typeof Uint32Array !== 'undefined') + { + Features.littleEndian = checkIsLittleEndian(); + } + + Features.support32bit = ( + typeof ArrayBuffer !== 'undefined' && + typeof Uint8ClampedArray !== 'undefined' && + typeof Int32Array !== 'undefined' && + Features.littleEndian !== null && + isUint8 + ); + + return Features; +} + +module.exports = init(); /***/ }), @@ -30024,43 +27846,56 @@ module.exports = RotateAroundXY; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Checks whether the x and y coordinates are contained within this polygon. -// Adapted from http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html by Jonas Raoni Soares Silva - /** - * [description] + * Adds the given element to the DOM. If a parent is provided the element is added as a child of the parent, providing it was able to access it. + * If no parent was given or falls back to using `document.body`. * - * @function Phaser.Geom.Polygon.Contains + * @function Phaser.DOM.AddToDOM * @since 3.0.0 * - * @param {Phaser.Geom.Polygon} polygon - [description] - * @param {number} x - [description] - * @param {number} y - [description] + * @param {HTMLElement} element - The element to be added to the DOM. Usually a Canvas object. + * @param {(string|HTMLElement)} [parent] - The parent in which to add the element. Can be a string which is passed to `getElementById` or an actual DOM object. + * @param {boolean} [overflowHidden=true] - [description] * - * @return {boolean} [description] + * @return {HTMLElement} The element that was added to the DOM. */ -var Contains = function (polygon, x, y) +var AddToDOM = function (element, parent, overflowHidden) { - var inside = false; + if (overflowHidden === undefined) { overflowHidden = true; } - for (var i = -1, j = polygon.points.length - 1; ++i < polygon.points.length; j = i) + var target; + + if (parent) { - var ix = polygon.points[i].x; - var iy = polygon.points[i].y; - - var jx = polygon.points[j].x; - var jy = polygon.points[j].y; - - if (((iy <= y && y < jy) || (jy <= y && y < iy)) && (x < (jx - ix) * (y - iy) / (jy - iy) + ix)) + if (typeof parent === 'string') { - inside = !inside; + // Hopefully an element ID + target = document.getElementById(parent); + } + else if (typeof parent === 'object' && parent.nodeType === 1) + { + // Quick test for a HTMLelement + target = parent; } } - return inside; + // Fallback, covers an invalid ID and a non HTMLelement object + if (!target) + { + target = document.body; + } + + if (overflowHidden && target.style) + { + target.style.overflow = 'hidden'; + } + + target.appendChild(element); + + return element; }; -module.exports = Contains; +module.exports = AddToDOM; /***/ }), @@ -30076,19 +27911,21 @@ module.exports = Contains; /** * [description] * - * @function Phaser.Geom.Rectangle.GetAspectRatio + * @function Phaser.Math.Linear * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} p0 - [description] + * @param {number} p1 - [description] + * @param {float} t - [description] * * @return {number} [description] */ -var GetAspectRatio = function (rect) +var Linear = function (p0, p1, t) { - return (rect.height === 0) ? NaN : rect.width / rect.height; + return (p1 - p0) * t + p0; }; -module.exports = GetAspectRatio; +module.exports = Linear; /***/ }), @@ -30104,88 +27941,32 @@ module.exports = GetAspectRatio; /** * [description] * - * @function Phaser.Geom.Triangle.RotateAroundXY + * @function Phaser.Math.CatmullRom * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} angle - [description] + * @param {number} t - [description] + * @param {number} p0 - [description] + * @param {number} p1 - [description] + * @param {number} p2 - [description] + * @param {number} p3 - [description] * - * @return {Phaser.Geom.Triangle} [description] + * @return {number} [description] */ -var RotateAroundXY = function (triangle, x, y, angle) +var CatmullRom = function (t, p0, p1, p2, p3) { - var c = Math.cos(angle); - var s = Math.sin(angle); + var v0 = (p2 - p0) * 0.5; + var v1 = (p3 - p1) * 0.5; + var t2 = t * t; + var t3 = t * t2; - var tx = triangle.x1 - x; - var ty = triangle.y1 - y; - - triangle.x1 = tx * c - ty * s + x; - triangle.y1 = tx * s + ty * c + y; - - tx = triangle.x2 - x; - ty = triangle.y2 - y; - - triangle.x2 = tx * c - ty * s + x; - triangle.y2 = tx * s + ty * c + y; - - tx = triangle.x3 - x; - ty = triangle.y3 - y; - - triangle.x3 = tx * c - ty * s + x; - triangle.y3 = tx * s + ty * c + y; - - return triangle; + return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; }; -module.exports = RotateAroundXY; +module.exports = CatmullRom; /***/ }), /* 150 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Given a File and a baseURL value this returns the URL the File will use to download from. - * - * @function Phaser.Loader.GetURL - * @since 3.0.0 - * - * @param {Phaser.Loader.File} file - The File object. - * @param {string} baseURL - A default base URL. - * - * @return {string} The URL the File will use. - */ -var GetURL = function (file, baseURL) -{ - if (!file.url) - { - return false; - } - - if (file.url.match(/^(?:blob:|data:|http:\/\/|https:\/\/|\/\/)/)) - { - return file.url; - } - else - { - return baseURL + file.url; - } -}; - -module.exports = GetURL; - - -/***/ }), -/* 151 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -30194,46 +27975,742 @@ module.exports = GetURL; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Extend = __webpack_require__(23); -var XHRSettings = __webpack_require__(90); +var Rectangle = __webpack_require__(10); + +// points is an array of Point-like objects, +// either 2 dimensional arrays, or objects with public x/y properties: +// var points = [ +// [100, 200], +// [200, 400], +// { x: 30, y: 60 } +// ] /** - * Takes two XHRSettings Objects and creates a new XHRSettings object from them. + * [description] * - * The new object is seeded by the values given in the global settings, but any setting in - * the local object overrides the global ones. - * - * @function Phaser.Loader.MergeXHRSettings + * @function Phaser.Geom.Rectangle.FromPoints * @since 3.0.0 * - * @param {Phaser.Loader.XHRSettings} global - The global XHRSettings object. - * @param {Phaser.Loader.XHRSettings} local - The local XHRSettings object. + * @param {array} points - [description] + * @param {Phaser.Geom.Rectangle} out - [description] * - * @return {Phaser.Loader.XHRSettings} A newly formed XHRSettings object. + * @return {Phaser.Geom.Rectangle} [description] */ -var MergeXHRSettings = function (global, local) +var FromPoints = function (points, out) { - var output = (global === undefined) ? XHRSettings() : Extend({}, global); + if (out === undefined) { out = new Rectangle(); } - if (local) + if (points.length === 0) { - for (var setting in local) - { - if (local[setting] !== undefined) - { - output[setting] = local[setting]; - } - } + return out; } - return output; + var minX = Number.MAX_VALUE; + var minY = Number.MAX_VALUE; + + var maxX = Number.MIN_SAFE_INTEGER; + var maxY = Number.MIN_SAFE_INTEGER; + + var p; + var px; + var py; + + for (var i = 0; i < points.length; i++) + { + p = points[i]; + + if (Array.isArray(p)) + { + px = p[0]; + py = p[1]; + } + else + { + px = p.x; + py = p.y; + } + + minX = Math.min(minX, px); + minY = Math.min(minY, py); + + maxX = Math.max(maxX, px); + maxY = Math.max(maxY, py); + } + + out.x = minX; + out.y = minY; + out.width = maxX - minX; + out.height = maxY - minY; + + return out; }; -module.exports = MergeXHRSettings; +module.exports = FromPoints; + + +/***/ }), +/* 151 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Browser specific prefix, so not going to change between contexts, only between browsers +var prefix = ''; + +/** + * @namespace Phaser.Display.Canvas.Smoothing + * @since 3.0.0 + */ +var Smoothing = function () +{ + /** + * Gets the Smoothing Enabled vendor prefix being used on the given context, or null if not set. + * + * @function Phaser.Display.Canvas.Smoothing.getPrefix + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * + * @return {string} [description] + */ + var getPrefix = function (context) + { + var vendors = [ 'i', 'webkitI', 'msI', 'mozI', 'oI' ]; + + for (var i = 0; i < vendors.length; i++) + { + var s = vendors[i] + 'mageSmoothingEnabled'; + + if (s in context) + { + return s; + } + } + + return null; + }; + + /** + * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. + * By default browsers have image smoothing enabled, which isn't always what you visually want, especially + * when using pixel art in a game. Note that this sets the property on the context itself, so that any image + * drawn to the context will be affected. This sets the property across all current browsers but support is + * patchy on earlier browsers, especially on mobile. + * + * @function Phaser.Display.Canvas.Smoothing.enable + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * + * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} [description] + */ + var enable = function (context) + { + if (prefix === '') + { + prefix = getPrefix(context); + } + + if (prefix) + { + context[prefix] = true; + } + + return context; + }; + + /** + * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. + * By default browsers have image smoothing enabled, which isn't always what you visually want, especially + * when using pixel art in a game. Note that this sets the property on the context itself, so that any image + * drawn to the context will be affected. This sets the property across all current browsers but support is + * patchy on earlier browsers, especially on mobile. + * + * @function Phaser.Display.Canvas.Smoothing.disable + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * + * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} [description] + */ + var disable = function (context) + { + if (prefix === '') + { + prefix = getPrefix(context); + } + + if (prefix) + { + context[prefix] = false; + } + + return context; + }; + + /** + * Returns `true` if the given context has image smoothing enabled, otherwise returns `false`. + * Returns null if no smoothing prefix is available. + * + * @function Phaser.Display.Canvas.Smoothing.isEnabled + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * + * @return {?boolean} [description] + */ + var isEnabled = function (context) + { + return (prefix !== null) ? context[prefix] : null; + }; + + return { + disable: disable, + enable: enable, + getPrefix: getPrefix, + isEnabled: isEnabled + }; + +}; + +module.exports = Smoothing(); + + +/***/ }), +/* 152 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); + +/** + * @classdesc + * [description] + * + * @class Vector4 + * @memberOf Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {number} [x] - [description] + * @param {number} [y] - [description] + * @param {number} [z] - [description] + * @param {number} [w] - [description] + */ +var Vector4 = new Class({ + + initialize: + + function Vector4 (x, y, z, w) + { + /** + * The x component of this Vector. + * + * @name Phaser.Math.Vector4#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The y component of this Vector. + * + * @name Phaser.Math.Vector4#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The z component of this Vector. + * + * @name Phaser.Math.Vector4#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The w component of this Vector. + * + * @name Phaser.Math.Vector4#w + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Vector4} [description] + */ + clone: function () + { + return new Vector4(this.x, this.y, this.z, this.w); + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#copy + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} src - [description] + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + copy: function (src) + { + this.x = src.x; + this.y = src.y; + this.z = src.z || 0; + this.w = src.w || 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#equals + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} v - [description] + * + * @return {boolean} [description] + */ + equals: function (v) + { + return ((this.x === v.x) && (this.y === v.y) && (this.z === v.z) && (this.w === v.w)); + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#set + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} z - [description] + * @param {number} w - [description] + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + set: function (x, y, z, w) + { + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#add + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + add: function (v) + { + this.x += v.x; + this.y += v.y; + this.z += v.z || 0; + this.w += v.w || 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#subtract + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + subtract: function (v) + { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z || 0; + this.w -= v.w || 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#scale + * @since 3.0.0 + * + * @param {number} scale - [description] + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + scale: function (scale) + { + this.x *= scale; + this.y *= scale; + this.z *= scale; + this.w *= scale; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#length + * @since 3.0.0 + * + * @return {number} [description] + */ + length: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return Math.sqrt(x * x + y * y + z * z + w * w); + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#lengthSq + * @since 3.0.0 + * + * @return {number} [description] + */ + lengthSq: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return x * x + y * y + z * z + w * w; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#normalize + * @since 3.0.0 + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + normalize: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + var len = x * x + y * y + z * z + w * w; + + if (len > 0) + { + len = 1 / Math.sqrt(len); + + this.x = x * len; + this.y = y * len; + this.z = z * len; + this.w = w * len; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#dot + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} v - [description] + * + * @return {number} [description] + */ + dot: function (v) + { + return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#lerp + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} v - [description] + * @param {number} [t=0] - [description] + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + lerp: function (v, t) + { + if (t === undefined) { t = 0; } + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + this.x = ax + t * (v.x - ax); + this.y = ay + t * (v.y - ay); + this.z = az + t * (v.z - az); + this.w = aw + t * (v.w - aw); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#multiply + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + multiply: function (v) + { + this.x *= v.x; + this.y *= v.y; + this.z *= v.z || 1; + this.w *= v.w || 1; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#divide + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + divide: function (v) + { + this.x /= v.x; + this.y /= v.y; + this.z /= v.z || 1; + this.w /= v.w || 1; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#distance + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] + * + * @return {number} [description] + */ + distance: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + var dw = v.w - this.w || 0; + + return Math.sqrt(dx * dx + dy * dy + dz * dz + dw * dw); + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#distanceSq + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] + * + * @return {number} [description] + */ + distanceSq: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + var dw = v.w - this.w || 0; + + return dx * dx + dy * dy + dz * dz + dw * dw; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#negate + * @since 3.0.0 + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + negate: function () + { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + this.w = -this.w; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#transformMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - [description] + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + transformMat4: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + var m = mat.val; + + this.x = m[0] * x + m[4] * y + m[8] * z + m[12] * w; + this.y = m[1] * x + m[5] * y + m[9] * z + m[13] * w; + this.z = m[2] * x + m[6] * y + m[10] * z + m[14] * w; + this.w = m[3] * x + m[7] * y + m[11] * z + m[15] * w; + + return this; + }, + + // TODO: is this really the same as Vector3? + // Also, what about this: http://molecularmusings.wordpress.com/2013/05/24/a-faster-quaternion-vector-multiplication/ + + /** + * [description] + * + * @method Phaser.Math.Vector4#transformQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - [description] + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + transformQuat: function (q) + { + // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations + var x = this.x; + var y = this.y; + var z = this.z; + var qx = q.x; + var qy = q.y; + var qz = q.z; + var qw = q.w; + + // calculate quat * vec + var ix = qw * x + qy * z - qz * y; + var iy = qw * y + qz * x - qx * z; + var iz = qw * z + qx * y - qy * x; + var iw = -qx * x - qy * y - qz * z; + + // calculate result * inverse quat + this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; + this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; + this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#reset + * @since 3.0.0 + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + reset: function () + { + this.x = 0; + this.y = 0; + this.z = 0; + this.w = 0; + + return this; + } + +}); + +// TODO: Check if these are required internally, if not, remove. +Vector4.prototype.sub = Vector4.prototype.subtract; +Vector4.prototype.mul = Vector4.prototype.multiply; +Vector4.prototype.div = Vector4.prototype.divide; +Vector4.prototype.dist = Vector4.prototype.distance; +Vector4.prototype.distSq = Vector4.prototype.distanceSq; +Vector4.prototype.len = Vector4.prototype.length; +Vector4.prototype.lenSq = Vector4.prototype.lengthSq; + +module.exports = Vector4; /***/ }), -/* 152 */, /* 153 */ /***/ (function(module, exports, __webpack_require__) { @@ -30243,69 +28720,1396 @@ module.exports = MergeXHRSettings; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetTileAt = __webpack_require__(97); +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); + +var EPSILON = 0.000001; /** - * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting - * faces are used internally for optimizing collisions against tiles. This method is mostly used - * internally to optimize recalculating faces when only one tile has been changed. + * @classdesc + * [description] * - * @function Phaser.Tilemaps.Components.CalculateFacesAt + * @class Matrix4 + * @memberOf Phaser.Math + * @constructor * @since 3.0.0 - * - * @param {integer} tileX - The x coordinate. - * @param {integer} tileY - The y coordinate. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @param {Phaser.Math.Matrix4} [m] - [description] */ -var CalculateFacesAt = function (tileX, tileY, layer) -{ - var tile = GetTileAt(tileX, tileY, true, layer); - var above = GetTileAt(tileX, tileY - 1, true, layer); - var below = GetTileAt(tileX, tileY + 1, true, layer); - var left = GetTileAt(tileX - 1, tileY, true, layer); - var right = GetTileAt(tileX + 1, tileY, true, layer); - var tileCollides = tile && tile.collides; +var Matrix4 = new Class({ - // Assume the changed tile has all interesting edges - if (tileCollides) + initialize: + + function Matrix4 (m) { - tile.faceBottom = true; - tile.faceBottom = true; - tile.faceLeft = true; - tile.faceRight = true; + /** + * [description] + * + * @name Phaser.Math.Matrix4#val + * @type {Float32Array} + * @since 3.0.0 + */ + this.val = new Float32Array(16); + + if (m) + { + // Assume Matrix4 with val: + this.copy(m); + } + else + { + // Default to identity + this.identity(); + } + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} A new Matrix4 object. + */ + clone: function () + { + return new Matrix4(this); + }, + + // TODO - Should work with basic values + + /** + * [description] + * + * @method Phaser.Math.Matrix4#set + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + set: function (src) + { + return this.copy(src); + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#copy + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + copy: function (src) + { + var out = this.val; + var a = src.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#fromArray + * @since 3.0.0 + * + * @param {array} a - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + fromArray: function (a) + { + var out = this.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#zero + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + zero: function () + { + var out = this.val; + + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 0; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#xyz + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} z - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + xyz: function (x, y, z) + { + this.identity(); + + var out = this.val; + + out[12] = x; + out[13] = y; + out[14] = z; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#scaling + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} z - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + scaling: function (x, y, z) + { + this.zero(); + + var out = this.val; + + out[0] = x; + out[5] = y; + out[10] = z; + out[15] = 1; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#identity + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + identity: function () + { + var out = this.val; + + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 1; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 1; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#transpose + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + transpose: function () + { + var a = this.val; + + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + var a12 = a[6]; + var a13 = a[7]; + var a23 = a[11]; + + a[1] = a[4]; + a[2] = a[8]; + a[3] = a[12]; + a[4] = a01; + a[6] = a[9]; + a[7] = a[13]; + a[8] = a02; + a[9] = a12; + a[11] = a[14]; + a[12] = a03; + a[13] = a13; + a[14] = a23; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#invert + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + invert: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + + if (!det) + { + return null; + } + + det = 1 / det; + + a[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + a[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + a[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + a[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; + a[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + a[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + a[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + a[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; + a[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + a[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + a[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; + a[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; + a[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; + a[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; + a[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; + a[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#adjoint + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + adjoint: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + a[0] = (a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22)); + a[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22)); + a[2] = (a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12)); + a[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12)); + a[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22)); + a[5] = (a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22)); + a[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12)); + a[7] = (a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12)); + a[8] = (a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21)); + a[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21)); + a[10] = (a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11)); + a[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11)); + a[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21)); + a[13] = (a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21)); + a[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11)); + a[15] = (a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11)); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#determinant + * @since 3.0.0 + * + * @return {number} [description] + */ + determinant: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#multiply + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + multiply: function (src) + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b = src.val; + + // Cache only the current line of the second matrix + var b0 = b[0]; + var b1 = b[1]; + var b2 = b[2]; + var b3 = b[3]; + + a[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[4]; + b1 = b[5]; + b2 = b[6]; + b3 = b[7]; + + a[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[8]; + b1 = b[9]; + b2 = b[10]; + b3 = b[11]; + + a[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[12]; + b1 = b[13]; + b2 = b[14]; + b3 = b[15]; + + a[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#multiplyLocal + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + multiplyLocal: function (src) + { + var a = []; + var m1 = this.val; + var m2 = src.val; + + a[0] = m1[0] * m2[0] + m1[1] * m2[4] + m1[2] * m2[8] + m1[3] * m2[12]; + a[1] = m1[0] * m2[1] + m1[1] * m2[5] + m1[2] * m2[9] + m1[3] * m2[13]; + a[2] = m1[0] * m2[2] + m1[1] * m2[6] + m1[2] * m2[10] + m1[3] * m2[14]; + a[3] = m1[0] * m2[3] + m1[1] * m2[7] + m1[2] * m2[11] + m1[3] * m2[15]; + + a[4] = m1[4] * m2[0] + m1[5] * m2[4] + m1[6] * m2[8] + m1[7] * m2[12]; + a[5] = m1[4] * m2[1] + m1[5] * m2[5] + m1[6] * m2[9] + m1[7] * m2[13]; + a[6] = m1[4] * m2[2] + m1[5] * m2[6] + m1[6] * m2[10] + m1[7] * m2[14]; + a[7] = m1[4] * m2[3] + m1[5] * m2[7] + m1[6] * m2[11] + m1[7] * m2[15]; + + a[8] = m1[8] * m2[0] + m1[9] * m2[4] + m1[10] * m2[8] + m1[11] * m2[12]; + a[9] = m1[8] * m2[1] + m1[9] * m2[5] + m1[10] * m2[9] + m1[11] * m2[13]; + a[10] = m1[8] * m2[2] + m1[9] * m2[6] + m1[10] * m2[10] + m1[11] * m2[14]; + a[11] = m1[8] * m2[3] + m1[9] * m2[7] + m1[10] * m2[11] + m1[11] * m2[15]; + + a[12] = m1[12] * m2[0] + m1[13] * m2[4] + m1[14] * m2[8] + m1[15] * m2[12]; + a[13] = m1[12] * m2[1] + m1[13] * m2[5] + m1[14] * m2[9] + m1[15] * m2[13]; + a[14] = m1[12] * m2[2] + m1[13] * m2[6] + m1[14] * m2[10] + m1[15] * m2[14]; + a[15] = m1[12] * m2[3] + m1[13] * m2[7] + m1[14] * m2[11] + m1[15] * m2[15]; + + return this.fromArray(a); + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#translate + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + translate: function (v) + { + var x = v.x; + var y = v.y; + var z = v.z; + var a = this.val; + + a[12] = a[0] * x + a[4] * y + a[8] * z + a[12]; + a[13] = a[1] * x + a[5] * y + a[9] * z + a[13]; + a[14] = a[2] * x + a[6] * y + a[10] * z + a[14]; + a[15] = a[3] * x + a[7] * y + a[11] * z + a[15]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#scale + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + scale: function (v) + { + var x = v.x; + var y = v.y; + var z = v.z; + var a = this.val; + + a[0] = a[0] * x; + a[1] = a[1] * x; + a[2] = a[2] * x; + a[3] = a[3] * x; + + a[4] = a[4] * y; + a[5] = a[5] * y; + a[6] = a[6] * y; + a[7] = a[7] * y; + + a[8] = a[8] * z; + a[9] = a[9] * z; + a[10] = a[10] * z; + a[11] = a[11] * z; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#makeRotationAxis + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} axis - [description] + * @param {float} angle - The angle of rotation in radians. + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + makeRotationAxis: function (axis, angle) + { + // Based on http://www.gamedev.net/reference/articles/article1199.asp + + var c = Math.cos(angle); + var s = Math.sin(angle); + var t = 1 - c; + var x = axis.x; + var y = axis.y; + var z = axis.z; + var tx = t * x; + var ty = t * y; + + this.set( + tx * x + c, tx * y - s * z, tx * z + s * y, 0, + tx * y + s * z, ty * y + c, ty * z - s * x, 0, + tx * z - s * y, ty * z + s * x, t * z * z + c, 0, + 0, 0, 0, 1 + ); + + return this; + }, + + // aka rotationAxis + /** + * [description] + * + * @method Phaser.Math.Matrix4#rotate + * @since 3.0.0 + * + * @param {float} rad - [description] + * @param {Phaser.Math.Vector3} axis - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + rotate: function (rad, axis) + { + var a = this.val; + var x = axis.x; + var y = axis.y; + var z = axis.z; + var len = Math.sqrt(x * x + y * y + z * z); + + if (Math.abs(len) < EPSILON) + { + return null; + } + + len = 1 / len; + x *= len; + y *= len; + z *= len; + + var s = Math.sin(rad); + var c = Math.cos(rad); + var t = 1 - c; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + // Construct the elements of the rotation matrix + var b00 = x * x * t + c; + var b01 = y * x * t + z * s; + var b02 = z * x * t - y * s; + + var b10 = x * y * t - z * s; + var b11 = y * y * t + c; + var b12 = z * y * t + x * s; + + var b20 = x * z * t + y * s; + var b21 = y * z * t - x * s; + var b22 = z * z * t + c; + + // Perform rotation-specific matrix multiplication + a[0] = a00 * b00 + a10 * b01 + a20 * b02; + a[1] = a01 * b00 + a11 * b01 + a21 * b02; + a[2] = a02 * b00 + a12 * b01 + a22 * b02; + a[3] = a03 * b00 + a13 * b01 + a23 * b02; + a[4] = a00 * b10 + a10 * b11 + a20 * b12; + a[5] = a01 * b10 + a11 * b11 + a21 * b12; + a[6] = a02 * b10 + a12 * b11 + a22 * b12; + a[7] = a03 * b10 + a13 * b11 + a23 * b12; + a[8] = a00 * b20 + a10 * b21 + a20 * b22; + a[9] = a01 * b20 + a11 * b21 + a21 * b22; + a[10] = a02 * b20 + a12 * b21 + a22 * b22; + a[11] = a03 * b20 + a13 * b21 + a23 * b22; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#rotateX + * @since 3.0.0 + * + * @param {float} rad - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + rotateX: function (rad) + { + var a = this.val; + var s = Math.sin(rad); + var c = Math.cos(rad); + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + // Perform axis-specific matrix multiplication + a[4] = a10 * c + a20 * s; + a[5] = a11 * c + a21 * s; + a[6] = a12 * c + a22 * s; + a[7] = a13 * c + a23 * s; + a[8] = a20 * c - a10 * s; + a[9] = a21 * c - a11 * s; + a[10] = a22 * c - a12 * s; + a[11] = a23 * c - a13 * s; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#rotateY + * @since 3.0.0 + * + * @param {float} rad - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + rotateY: function (rad) + { + var a = this.val; + var s = Math.sin(rad); + var c = Math.cos(rad); + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + // Perform axis-specific matrix multiplication + a[0] = a00 * c - a20 * s; + a[1] = a01 * c - a21 * s; + a[2] = a02 * c - a22 * s; + a[3] = a03 * c - a23 * s; + a[8] = a00 * s + a20 * c; + a[9] = a01 * s + a21 * c; + a[10] = a02 * s + a22 * c; + a[11] = a03 * s + a23 * c; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#rotateZ + * @since 3.0.0 + * + * @param {float} rad - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + rotateZ: function (rad) + { + var a = this.val; + var s = Math.sin(rad); + var c = Math.cos(rad); + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + // Perform axis-specific matrix multiplication + a[0] = a00 * c + a10 * s; + a[1] = a01 * c + a11 * s; + a[2] = a02 * c + a12 * s; + a[3] = a03 * c + a13 * s; + a[4] = a10 * c - a00 * s; + a[5] = a11 * c - a01 * s; + a[6] = a12 * c - a02 * s; + a[7] = a13 * c - a03 * s; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#fromRotationTranslation + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - [description] + * @param {Phaser.Math.Vector3} v - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + fromRotationTranslation: function (q, v) + { + // Quaternion math + var out = this.val; + + var x = q.x; + var y = q.y; + var z = q.z; + var w = q.w; + + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + + out[0] = 1 - (yy + zz); + out[1] = xy + wz; + out[2] = xz - wy; + out[3] = 0; + + out[4] = xy - wz; + out[5] = 1 - (xx + zz); + out[6] = yz + wx; + out[7] = 0; + + out[8] = xz + wy; + out[9] = yz - wx; + out[10] = 1 - (xx + yy); + out[11] = 0; + + out[12] = v.x; + out[13] = v.y; + out[14] = v.z; + out[15] = 1; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#fromQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + fromQuat: function (q) + { + var out = this.val; + + var x = q.x; + var y = q.y; + var z = q.z; + var w = q.w; + + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + + out[0] = 1 - (yy + zz); + out[1] = xy + wz; + out[2] = xz - wy; + out[3] = 0; + + out[4] = xy - wz; + out[5] = 1 - (xx + zz); + out[6] = yz + wx; + out[7] = 0; + + out[8] = xz + wy; + out[9] = yz - wx; + out[10] = 1 - (xx + yy); + out[11] = 0; + + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + + return this; + }, + + /** + * Generates a frustum matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#frustum + * @since 3.0.0 + * + * @param {number} left - The left bound of the frustum. + * @param {number} right - The right bound of the frustum. + * @param {number} bottom - The bottom bound of the frustum. + * @param {number} top - The top bound of the frustum. + * @param {number} near - The near bound of the frustum. + * @param {number} far - The far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + frustum: function (left, right, bottom, top, near, far) + { + var out = this.val; + + var rl = 1 / (right - left); + var tb = 1 / (top - bottom); + var nf = 1 / (near - far); + + out[0] = (near * 2) * rl; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = (near * 2) * tb; + out[6] = 0; + out[7] = 0; + + out[8] = (right + left) * rl; + out[9] = (top + bottom) * tb; + out[10] = (far + near) * nf; + out[11] = -1; + + out[12] = 0; + out[13] = 0; + out[14] = (far * near * 2) * nf; + out[15] = 0; + + return this; + }, + + /** + * Generates a perspective projection matrix with the given bounds. + * perspective fov lh + * + * @method Phaser.Math.Matrix4#perspective + * @since 3.0.0 + * + * @param {number} fovy - Vertical field of view in radians + * @param {number} aspect - Aspect ratio. Typically viewport width /height. + * @param {number} near - Near bound of the frustum. + * @param {number} far - Far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + perspective: function (fovy, aspect, near, far) + { + var out = this.val; + var f = 1.0 / Math.tan(fovy / 2); + var nf = 1 / (near - far); + + out[0] = f / aspect; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = f; + out[6] = 0; + out[7] = 0; + + out[8] = 0; + out[9] = 0; + out[10] = (far + near) * nf; + out[11] = -1; + + out[12] = 0; + out[13] = 0; + out[14] = (2 * far * near) * nf; + out[15] = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#perspectiveLH + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * @param {number} near - Near bound of the frustum. + * @param {number} far - Far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + perspectiveLH: function (width, height, near, far) + { + var out = this.val; + + out[0] = (2 * near) / width; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = (2 * near) / height; + out[6] = 0; + out[7] = 0; + + out[8] = 0; + out[9] = 0; + out[10] = -far / (near - far); + out[11] = 1; + + out[12] = 0; + out[13] = 0; + out[14] = (near * far) / (near - far); + out[15] = 0; + + return this; + }, + + /** + * Generates a orthogonal projection matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#ortho + * @since 3.0.0 + * + * @param {number} left - The left bound of the frustum. + * @param {number} right - The right bound of the frustum. + * @param {number} bottom - The bottom bound of the frustum. + * @param {number} top - The top bound of the frustum. + * @param {number} near - The near bound of the frustum. + * @param {number} far - The far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + ortho: function (left, right, bottom, top, near, far) + { + var out = this.val; + var lr = left - right; + var bt = bottom - top; + var nf = near - far; + + // Avoid division by zero + lr = (lr === 0) ? lr : 1 / lr; + bt = (bt === 0) ? bt : 1 / bt; + nf = (nf === 0) ? nf : 1 / nf; + + out[0] = -2 * lr; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = -2 * bt; + out[6] = 0; + out[7] = 0; + + out[8] = 0; + out[9] = 0; + out[10] = 2 * nf; + out[11] = 0; + + out[12] = (left + right) * lr; + out[13] = (top + bottom) * bt; + out[14] = (far + near) * nf; + out[15] = 1; + + return this; + }, + + /** + * Generates a look-at matrix with the given eye position, focal point, and up axis. + * + * @method Phaser.Math.Matrix4#lookAt + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} eye - Position of the viewer + * @param {Phaser.Math.Vector3} center - Point the viewer is looking at + * @param {Phaser.Math.Vector3} up - vec3 pointing up. + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + lookAt: function (eye, center, up) + { + var out = this.val; + + var eyex = eye.x; + var eyey = eye.y; + var eyez = eye.z; + + var upx = up.x; + var upy = up.y; + var upz = up.z; + + var centerx = center.x; + var centery = center.y; + var centerz = center.z; + + if (Math.abs(eyex - centerx) < EPSILON && + Math.abs(eyey - centery) < EPSILON && + Math.abs(eyez - centerz) < EPSILON) + { + return this.identity(); + } + + var z0 = eyex - centerx; + var z1 = eyey - centery; + var z2 = eyez - centerz; + + var len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2); + + z0 *= len; + z1 *= len; + z2 *= len; + + var x0 = upy * z2 - upz * z1; + var x1 = upz * z0 - upx * z2; + var x2 = upx * z1 - upy * z0; + + len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2); + + if (!len) + { + x0 = 0; + x1 = 0; + x2 = 0; + } + else + { + len = 1 / len; + x0 *= len; + x1 *= len; + x2 *= len; + } + + var y0 = z1 * x2 - z2 * x1; + var y1 = z2 * x0 - z0 * x2; + var y2 = z0 * x1 - z1 * x0; + + len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2); + + if (!len) + { + y0 = 0; + y1 = 0; + y2 = 0; + } + else + { + len = 1 / len; + y0 *= len; + y1 *= len; + y2 *= len; + } + + out[0] = x0; + out[1] = y0; + out[2] = z0; + out[3] = 0; + + out[4] = x1; + out[5] = y1; + out[6] = z1; + out[7] = 0; + + out[8] = x2; + out[9] = y2; + out[10] = z2; + out[11] = 0; + + out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez); + out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez); + out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez); + out[15] = 1; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#yawPitchRoll + * @since 3.0.0 + * + * @param {number} yaw - [description] + * @param {number} pitch - [description] + * @param {number} roll - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + yawPitchRoll: function (yaw, pitch, roll) + { + this.zero(); + _tempMat1.zero(); + _tempMat2.zero(); + + var m0 = this.val; + var m1 = _tempMat1.val; + var m2 = _tempMat2.val; + + // Rotate Z + var s = Math.sin(roll); + var c = Math.cos(roll); + + m0[10] = 1; + m0[15] = 1; + m0[0] = c; + m0[1] = s; + m0[4] = -s; + m0[5] = c; + + // Rotate X + s = Math.sin(pitch); + c = Math.cos(pitch); + + m1[0] = 1; + m1[15] = 1; + m1[5] = c; + m1[10] = c; + m1[9] = -s; + m1[6] = s; + + // Rotate Y + s = Math.sin(yaw); + c = Math.cos(yaw); + + m2[5] = 1; + m2[15] = 1; + m2[0] = c; + m2[2] = -s; + m2[8] = s; + m2[10] = c; + + this.multiplyLocal(_tempMat1); + this.multiplyLocal(_tempMat2); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#setWorldMatrix + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} rotation - [description] + * @param {Phaser.Math.Vector3} position - [description] + * @param {Phaser.Math.Vector3} scale - [description] + * @param {Phaser.Math.Matrix4} [viewMatrix] - [description] + * @param {Phaser.Math.Matrix4} [projectionMatrix] - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + setWorldMatrix: function (rotation, position, scale, viewMatrix, projectionMatrix) + { + this.yawPitchRoll(rotation.y, rotation.x, rotation.z); + + _tempMat1.scaling(scale.x, scale.y, scale.z); + _tempMat2.xyz(position.x, position.y, position.z); + + this.multiplyLocal(_tempMat1); + this.multiplyLocal(_tempMat2); + + if (viewMatrix !== undefined) + { + this.multiplyLocal(viewMatrix); + } + + if (projectionMatrix !== undefined) + { + this.multiplyLocal(projectionMatrix); + } + + return this; } - // Reset edges that are shared between tile and its neighbors - if (above && above.collides) - { - if (tileCollides) { tile.faceTop = false; } - above.faceBottom = !tileCollides; - } +}); - if (below && below.collides) - { - if (tileCollides) { tile.faceBottom = false; } - below.faceTop = !tileCollides; - } +var _tempMat1 = new Matrix4(); +var _tempMat2 = new Matrix4(); - if (left && left.collides) - { - if (tileCollides) { tile.faceLeft = false; } - left.faceRight = !tileCollides; - } - - if (right && right.collides) - { - if (tileCollides) { tile.faceRight = false; } - right.faceLeft = !tileCollides; - } - - if (tile && !tile.collides) { tile.resetFaces(); } - - return tile; -}; - -module.exports = CalculateFacesAt; +module.exports = Matrix4; /***/ }), @@ -30318,73 +30122,1069 @@ module.exports = CalculateFacesAt; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Tile = __webpack_require__(44); -var IsInLayerBounds = __webpack_require__(74); -var CalculateFacesAt = __webpack_require__(153); -var SetTileCollision = __webpack_require__(43); +var Class = __webpack_require__(0); +var Matrix4 = __webpack_require__(153); +var RandomXYZ = __webpack_require__(330); +var RandomXYZW = __webpack_require__(329); +var RotateVec3 = __webpack_require__(328); +var Set = __webpack_require__(63); +var Sprite3D = __webpack_require__(101); +var Vector2 = __webpack_require__(6); +var Vector3 = __webpack_require__(57); +var Vector4 = __webpack_require__(152); + +// Local cache vars +var tmpVec3 = new Vector3(); +var tmpVec4 = new Vector4(); +var dirvec = new Vector3(); +var rightvec = new Vector3(); +var billboardMatrix = new Matrix4(); + +// @author attribute https://github.com/mattdesl/cam3d/wiki /** - * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index - * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified - * location. If you pass in an index, only the index at the specified location will be changed. - * Collision information will be recalculated at the specified location. + * @typedef {object} RayDef * - * @function Phaser.Tilemaps.Components.PutTileAt + * @property {Phaser.Math.Vector3} origin - [description] + * @property {Phaser.Math.Vector3} direction - [description] + */ + +/** + * @classdesc + * [description] + * + * @class Camera + * @memberOf Phaser.Cameras.Sprite3D + * @constructor * @since 3.0.0 * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map. + * @param {Phaser.Scene} scene - [description] */ -var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer) -{ - if (!IsInLayerBounds(tileX, tileY, layer)) { return null; } - if (recalculateFaces === undefined) { recalculateFaces = true; } +var Camera = new Class({ - var oldTile = layer.data[tileY][tileX]; - var oldTileCollides = oldTile && oldTile.collides; + initialize: - if (tile instanceof Tile) + function Camera (scene) { - if (layer.data[tileY][tileX] === null) + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#displayList + * @type {Phaser.GameObjects.DisplayList} + * @since 3.0.0 + */ + this.displayList = scene.sys.displayList; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#updateList + * @type {Phaser.GameObjects.UpdateList} + * @since 3.0.0 + */ + this.updateList = scene.sys.updateList; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#direction + * @type {Phaser.Math.Vector3} + * @since 3.0.0 + */ + this.direction = new Vector3(0, 0, -1); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#up + * @type {Phaser.Math.Vector3} + * @since 3.0.0 + */ + this.up = new Vector3(0, 1, 0); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#position + * @type {Phaser.Math.Vector3} + * @since 3.0.0 + */ + this.position = new Vector3(); + + // The mapping from 3D size units to pixels. + // In the default case 1 3D unit = 128 pixels. So a sprite that is + // 256 x 128 px in size will be 2 x 1 units. + // Change to whatever best fits your game assets. + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#pixelScale + * @type {number} + * @since 3.0.0 + */ + this.pixelScale = 128; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#projection + * @type {Phaser.Math.Matrix4} + * @since 3.0.0 + */ + this.projection = new Matrix4(); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#view + * @type {Phaser.Math.Matrix4} + * @since 3.0.0 + */ + this.view = new Matrix4(); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#combined + * @type {Phaser.Math.Matrix4} + * @since 3.0.0 + */ + this.combined = new Matrix4(); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#invProjectionView + * @type {Phaser.Math.Matrix4} + * @since 3.0.0 + */ + this.invProjectionView = new Matrix4(); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#near + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.near = 1; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#far + * @type {number} + * @since 3.0.0 + */ + this.far = 100; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#ray + * @type {RayDef} + * @since 3.0.0 + */ + this.ray = { + origin: new Vector3(), + direction: new Vector3() + }; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#viewportWidth + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.viewportWidth = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#viewportHeight + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.viewportHeight = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#billboardMatrixDirty + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.billboardMatrixDirty = true; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#children + * @type {Phaser.Structs.Set} + * @since 3.0.0 + */ + this.children = new Set(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#setPosition + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} z - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + setPosition: function (x, y, z) + { + this.position.set(x, y, z); + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#setScene + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + setScene: function (scene) + { + this.scene = scene; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#setPixelScale + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + setPixelScale: function (value) + { + this.pixelScale = value; + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#add + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Sprite3D} sprite3D - [description] + * + * @return {Phaser.GameObjects.Sprite3D} [description] + */ + add: function (sprite3D) + { + this.children.set(sprite3D); + + this.updateChildren(); + + return sprite3D; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#remove + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + remove: function (child) + { + this.displayList.remove(child.gameObject); + this.updateList.remove(child.gameObject); + + this.children.delete(child); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#clear + * @since 3.0.0 + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + clear: function () + { + var children = this.getChildren(); + + for (var i = 0; i < children.length; i++) { - layer.data[tileY][tileX] = new Tile(layer, tile.index, tileX, tileY, tile.width, tile.height); + this.remove(children[i]); } - layer.data[tileY][tileX].copy(tile); - } - else + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#getChildren + * @since 3.0.0 + * + * @return {array} [description] + */ + getChildren: function () { - var index = tile; - if (layer.data[tileY][tileX] === null) + return this.children.entries; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#create + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} z - [description] + * @param {string} key - [description] + * @param {(string|number)} frame - [description] + * @param {boolean} [visible=true] - [description] + * + * @return {Phaser.GameObjects.Sprite3D} [description] + */ + create: function (x, y, z, key, frame, visible) + { + if (visible === undefined) { visible = true; } + + var child = new Sprite3D(this.scene, x, y, z, key, frame); + + this.displayList.add(child.gameObject); + this.updateList.add(child.gameObject); + + child.visible = visible; + + this.children.set(child); + + this.updateChildren(); + + return child; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#createMultiple + * @since 3.0.0 + * + * @param {number} quantity - [description] + * @param {string} key - [description] + * @param {(string|number)} frame - [description] + * @param {boolean} [visible=true] - [description] + * + * @return {Phaser.GameObjects.Sprite3D[]} [description] + */ + createMultiple: function (quantity, key, frame, visible) + { + if (visible === undefined) { visible = true; } + + var output = []; + + for (var i = 0; i < quantity; i++) { - layer.data[tileY][tileX] = new Tile(layer, index, tileX, tileY, layer.tileWidth, layer.tileHeight); + var child = new Sprite3D(this.scene, 0, 0, 0, key, frame); + + this.displayList.add(child.gameObject); + this.updateList.add(child.gameObject); + + child.visible = visible; + + this.children.set(child); + + output.push(child); + } + + return output; + }, + + // Create a bunch of Sprite3D objects in a rectangle + // size and spacing are Vec3s (or if integers are converted to vec3s) + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#createRect + * @since 3.0.0 + * + * @param {(number|{x:number,y:number})} size - [description] + * @param {(number|{x:number,y:number,z:number})} spacing - [description] + * @param {string} key - [description] + * @param {(string|number)} [frame] - [description] + * + * @return {Phaser.GameObjects.Sprite3D[]} [description] + */ + createRect: function (size, spacing, key, frame) + { + if (typeof size === 'number') { size = { x: size, y: size, z: size }; } + if (typeof spacing === 'number') { spacing = { x: spacing, y: spacing, z: spacing }; } + + var quantity = size.x * size.y * size.z; + + var sprites = this.createMultiple(quantity, key, frame); + + var i = 0; + + for (var z = 0.5 - (size.z / 2); z < (size.z / 2); z++) + { + for (var y = 0.5 - (size.y / 2); y < (size.y / 2); y++) + { + for (var x = 0.5 - (size.x / 2); x < (size.x / 2); x++) + { + var bx = (x * spacing.x); + var by = (y * spacing.y); + var bz = (z * spacing.z); + + sprites[i].position.set(bx, by, bz); + + i++; + } + } + } + + this.update(); + + return sprites; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#randomSphere + * @since 3.0.0 + * + * @param {number} [radius=1] - [description] + * @param {Phaser.GameObjects.Sprite3D[]} [sprites] - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + randomSphere: function (radius, sprites) + { + if (sprites === undefined) { sprites = this.getChildren(); } + + for (var i = 0; i < sprites.length; i++) + { + RandomXYZ(sprites[i].position, radius); + } + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#randomCube + * @since 3.0.0 + * + * @param {float} [scale=1] - [description] + * @param {Phaser.GameObjects.Sprite3D[]} [sprites] - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + randomCube: function (scale, sprites) + { + if (sprites === undefined) { sprites = this.getChildren(); } + + for (var i = 0; i < sprites.length; i++) + { + RandomXYZW(sprites[i].position, scale); + } + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#translateChildren + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} vec3 - [description] + * @param {Phaser.GameObjects.Sprite3D[]} sprites - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + translateChildren: function (vec3, sprites) + { + if (sprites === undefined) { sprites = this.getChildren(); } + + for (var i = 0; i < sprites.length; i++) + { + sprites[i].position.add(vec3); + } + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#transformChildren + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat4 - [description] + * @param {Phaser.GameObjects.Sprite3D[]} sprites - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + transformChildren: function (mat4, sprites) + { + if (sprites === undefined) { sprites = this.getChildren(); } + + for (var i = 0; i < sprites.length; i++) + { + sprites[i].position.transformMat4(mat4); + } + + return this.update(); + }, + + /** + * Sets the width and height of the viewport. Does not update any matrices. + * + * @method Phaser.Cameras.Sprite3D.Camera#setViewport + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + setViewport: function (width, height) + { + this.viewportWidth = width; + this.viewportHeight = height; + + return this.update(); + }, + + /** + * Translates this camera by a specified Vector3 object + * or x, y, z parameters. Any undefined x y z values will + * default to zero, leaving that component unaffected. + * If you wish to set the camera position directly call setPosition instead. + * + * @method Phaser.Cameras.Sprite3D.Camera#translate + * @since 3.0.0 + * + * @param {(number|object)} x - [description] + * @param {number} [y] - [description] + * @param {number} [z] - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + translate: function (x, y, z) + { + if (typeof x === 'object') + { + this.position.x += x.x || 0; + this.position.y += x.y || 0; + this.position.z += x.z || 0; } else { - layer.data[tileY][tileX].index = index; + this.position.x += x || 0; + this.position.y += y || 0; + this.position.z += z || 0; + } + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#lookAt + * @since 3.0.0 + * + * @param {(number|object)} x - [description] + * @param {number} [y] - [description] + * @param {number} [z] - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + lookAt: function (x, y, z) + { + var dir = this.direction; + var up = this.up; + + if (typeof x === 'object') + { + dir.copy(x); + } + else + { + dir.set(x, y, z); + } + + dir.subtract(this.position).normalize(); + + // Calculate right vector + tmpVec3.copy(dir).cross(up).normalize(); + + // Calculate up vector + up.copy(tmpVec3).cross(dir).normalize(); + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#rotate + * @since 3.0.0 + * + * @param {float} radians - [description] + * @param {Phaser.Math.Vector3} axis - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + rotate: function (radians, axis) + { + RotateVec3(this.direction, axis, radians); + RotateVec3(this.up, axis, radians); + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#rotateAround + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} point - [description] + * @param {float} radians - [description] + * @param {Phaser.Math.Vector3} axis - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + rotateAround: function (point, radians, axis) + { + tmpVec3.copy(point).subtract(this.position); + + this.translate(tmpVec3); + this.rotate(radians, axis); + this.translate(tmpVec3.negate()); + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#project + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} vec - [description] + * @param {Phaser.Math.Vector4} out - [description] + * + * @return {Phaser.Math.Vector4} [description] + */ + project: function (vec, out) + { + if (out === undefined) { out = new Vector4(); } + + // TODO: support viewport XY + var viewportWidth = this.viewportWidth; + var viewportHeight = this.viewportHeight; + var n = Camera.NEAR_RANGE; + var f = Camera.FAR_RANGE; + + // For useful Z and W values we should do the usual steps: clip space -> NDC -> window coords + + // Implicit 1.0 for w component + tmpVec4.set(vec.x, vec.y, vec.z, 1.0); + + // Transform into clip space + tmpVec4.transformMat4(this.combined); + + // Avoid divide by zero when 0x0x0 camera projects to a 0x0x0 vec3 + if (tmpVec4.w === 0) + { + tmpVec4.w = 1; + } + + // Now into NDC + tmpVec4.x = tmpVec4.x / tmpVec4.w; + tmpVec4.y = tmpVec4.y / tmpVec4.w; + tmpVec4.z = tmpVec4.z / tmpVec4.w; + + // And finally into window coordinates + out.x = viewportWidth / 2 * tmpVec4.x + (0 + viewportWidth / 2); + out.y = viewportHeight / 2 * tmpVec4.y + (0 + viewportHeight / 2); + out.z = (f - n) / 2 * tmpVec4.z + (f + n) / 2; + + // If the out vector has a fourth component, we also store (1/clip.w), same idea as gl_FragCoord.w + if (out.w === 0 || out.w) + { + out.w = 1 / tmpVec4.w; + } + + return out; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#unproject + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} vec - [description] + * @param {Phaser.Math.Vector3} out - [description] + * + * @return {Phaser.Math.Vector3} [description] + */ + unproject: function (vec, out) + { + if (out === undefined) { out = new Vector3(); } + + var viewport = tmpVec4.set(0, 0, this.viewportWidth, this.viewportHeight); + + return out.copy(vec).unproject(viewport, this.invProjectionView); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#getPickRay + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y] - [description] + * + * @return {RayDef} [description] + */ + getPickRay: function (x, y) + { + var origin = this.ray.origin.set(x, y, 0); + var direction = this.ray.direction.set(x, y, 1); + var viewport = tmpVec4.set(0, 0, this.viewportWidth, this.viewportHeight); + var mtx = this.invProjectionView; + + origin.unproject(viewport, mtx); + + direction.unproject(viewport, mtx); + + direction.subtract(origin).normalize(); + + return this.ray; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#updateChildren + * @since 3.0.0 + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + updateChildren: function () + { + var children = this.children.entries; + + for (var i = 0; i < children.length; i++) + { + children[i].project(this); + } + + return this; + }, + + // Overriden by subclasses + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#update + * @since 3.0.0 + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + update: function () + { + return this.updateChildren(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#updateBillboardMatrix + * @since 3.0.0 + */ + updateBillboardMatrix: function () + { + var dir = dirvec.set(this.direction).negate(); + + // Better view-aligned billboards might use this: + // var dir = tmp.set(camera.position).subtract(p).normalize(); + + var right = rightvec.set(this.up).cross(dir).normalize(); + var up = tmpVec3.set(dir).cross(right).normalize(); + + var out = billboardMatrix.val; + + out[0] = right.x; + out[1] = right.y; + out[2] = right.z; + out[3] = 0; + + out[4] = up.x; + out[5] = up.y; + out[6] = up.z; + out[7] = 0; + + out[8] = dir.x; + out[9] = dir.y; + out[10] = dir.z; + out[11] = 0; + + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + + this.billboardMatrixDirty = false; + }, + + /** + * This is a utility function for canvas 3D rendering, + * which determines the "point size" of a camera-facing + * sprite billboard given its 3D world position + * (origin at center of sprite) and its world width + * and height in x/y. + * + * We place into the output Vector2 the scaled width + * and height. If no `out` is specified, a new Vector2 + * will be created for convenience (this should be avoided + * in tight loops). + * + * @method Phaser.Cameras.Sprite3D.Camera#getPointSize + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} vec - The position of the 3D Sprite. + * @param {Phaser.Math.Vector2} size - The x and y dimensions. + * @param {Phaser.Math.Vector2} out - The result, scaled x and y dimensions. + * + * @return {Phaser.Math.Vector2} [description] + */ + getPointSize: function (vec, size, out) + { + if (out === undefined) { out = new Vector2(); } + + // TODO: optimize this with a simple distance calculation: + // https://developer.valvesoftware.com/wiki/Field_of_View + + if (this.billboardMatrixDirty) + { + this.updateBillboardMatrix(); + } + + var tmp = tmpVec3; + + var dx = (size.x / this.pixelScale) / 2; + var dy = (size.y / this.pixelScale) / 2; + + tmp.set(-dx, -dy, 0).transformMat4(billboardMatrix).add(vec); + + this.project(tmp, tmp); + + var tlx = tmp.x; + var tly = tmp.y; + + tmp.set(dx, dy, 0).transformMat4(billboardMatrix).add(vec); + + this.project(tmp, tmp); + + var brx = tmp.x; + var bry = tmp.y; + + // var w = Math.abs(brx - tlx); + // var h = Math.abs(bry - tly); + + // Allow the projection to get negative ... + var w = brx - tlx; + var h = bry - tly; + + return out.set(w, h); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.children.clear(); + + this.scene = undefined; + this.children = undefined; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#setX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + setX: function (value) + { + this.position.x = value; + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#setY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + setY: function (value) + { + this.position.y = value; + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#setZ + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + setZ: function (value) + { + this.position.z = value; + + return this.update(); + }, + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.Camera#x + * @type {number} + * @since 3.0.0 + */ + x: { + get: function () + { + return this.position.x; + }, + + set: function (value) + { + this.position.x = value; + this.update(); + } + }, + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.Camera#y + * @type {number} + * @since 3.0.0 + */ + y: { + get: function () + { + return this.position.y; + }, + + set: function (value) + { + this.position.y = value; + this.update(); + } + }, + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.Camera#z + * @type {number} + * @since 3.0.0 + */ + z: { + get: function () + { + return this.position.z; + }, + + set: function (value) + { + this.position.z = value; + this.update(); } } - // Updating colliding flag on the new tile - var newTile = layer.data[tileY][tileX]; - var collides = layer.collideIndexes.indexOf(newTile.index) !== -1; - SetTileCollision(newTile, collides); +}); - // Recalculate faces only if the colliding flag at (tileX, tileY) has changed - if (recalculateFaces && (oldTileCollides !== newTile.collides)) - { - CalculateFacesAt(tileX, tileY, layer); - } - - return newTile; -}; - -module.exports = PutTileAt; +Camera.FAR_RANGE = 1.0; +Camera.NEAR_RANGE = 0.0; +module.exports = Camera; /***/ }), @@ -30398,31 +31198,23 @@ module.exports = PutTileAt; */ /** - * Internally used method to keep track of the tile indexes that collide within a layer. This - * updates LayerData.collideIndexes to either contain or not contain the given `tileIndex`. + * Given 3 separate color values this will return an integer representation of it. * - * @function Phaser.Tilemaps.Components.SetLayerCollisionIndex + * @function Phaser.Display.Color.GetColor * @since 3.0.0 * - * @param {integer} tileIndex - [description] - * @param {boolean} [collides=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * @param {integer} red - The red color value. A number between 0 and 255. + * @param {integer} green - The green color value. A number between 0 and 255. + * @param {integer} blue - The blue color value. A number between 0 and 255. + * + * @return {number} The combined color value. */ -var SetLayerCollisionIndex = function (tileIndex, collides, layer) +var GetColor = function (red, green, blue) { - var loc = layer.collideIndexes.indexOf(tileIndex); - - if (collides && loc === -1) - { - layer.collideIndexes.push(tileIndex); - } - else if (!collides && loc !== -1) - { - layer.collideIndexes.splice(loc, 1); - } + return red << 16 | green << 8 | blue; }; -module.exports = SetLayerCollisionIndex; +module.exports = GetColor; /***/ }), @@ -30435,86 +31227,50 @@ module.exports = SetLayerCollisionIndex; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Formats = __webpack_require__(22); -var LayerData = __webpack_require__(75); -var MapData = __webpack_require__(76); -var Tile = __webpack_require__(44); +var HexStringToColor = __webpack_require__(336); +var IntegerToColor = __webpack_require__(334); +var ObjectToColor = __webpack_require__(332); +var RGBStringToColor = __webpack_require__(331); /** - * Parses a 2D array of tile indexes into a new MapData object with a single layer. + * Converts the given source color value into an instance of a Color class. + * The value can be either a string, prefixed with `rgb` or a hex string, a number or an Object. * - * @function Phaser.Tilemaps.Parsers.Parse2DArray + * @function Phaser.Display.Color.ValueToColor * @since 3.0.0 - * - * @param {string} name - The name of the tilemap, used to set the name on the MapData. - * @param {integer[][]} data - 2D array, CSV string or Tiled JSON object. - * @param {integer} tileWidth - The width of a tile in pixels. - * @param {integer} tileHeight - The height of a tile in pixels. - * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {[type]} [description] + * + * @param {(string|number|InputColorObject)} input - The source color value to convert. + * + * @return {Phaser.Display.Color} A Color object. */ -var Parse2DArray = function (name, data, tileWidth, tileHeight, insertNull) +var ValueToColor = function (input) { - var layerData = new LayerData({ - tileWidth: tileWidth, - tileHeight: tileHeight - }); + var t = typeof input; - var mapData = new MapData({ - name: name, - tileWidth: tileWidth, - tileHeight: tileHeight, - format: Formats.ARRAY_2D, - layers: [ layerData ] - }); - - var tiles = []; - var height = data.length; - var width = 0; - - for (var y = 0; y < data.length; y++) + switch (t) { - tiles[y] = []; - var row = data[y]; + case 'string': - for (var x = 0; x < row.length; x++) - { - var tileIndex = parseInt(row[x], 10); - - if (Number.isNaN(tileIndex) || tileIndex === -1) + if (input.substr(0, 3).toLowerCase() === 'rgb') { - tiles[y][x] = insertNull - ? null - : new Tile(layerData, -1, x, y, tileWidth, tileHeight); + return RGBStringToColor(input); } else { - tiles[y][x] = new Tile(layerData, tileIndex, x, y, tileWidth, tileHeight); + return HexStringToColor(input); } - } - if (width === 0) - { - width = row.length; - } + case 'number': + + return IntegerToColor(input); + + case 'object': + + return ObjectToColor(input); } - - mapData.width = layerData.width = width; - mapData.height = layerData.height = height; - mapData.widthInPixels = layerData.widthInPixels = width * tileWidth; - mapData.heightInPixels = layerData.heightInPixels = height * tileHeight; - layerData.data = tiles; - - return mapData; }; -module.exports = Parse2DArray; +module.exports = ValueToColor; /***/ }), @@ -30527,131 +31283,1489 @@ module.exports = Parse2DArray; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Formats = __webpack_require__(22); -var MapData = __webpack_require__(76); -var Parse = __webpack_require__(347); -var Tilemap = __webpack_require__(355); +var Class = __webpack_require__(0); +var DegToRad = __webpack_require__(42); +var Rectangle = __webpack_require__(10); +var TransformMatrix = __webpack_require__(348); +var ValueToColor = __webpack_require__(156); +var Vector2 = __webpack_require__(6); /** - * Create a Tilemap from the given key or data. If neither is given, make a blank Tilemap. When - * loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing from - * a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map data. For - * an empty map, you should specify tileWidth, tileHeight, width & height. + * @typedef {object} JSONCamera * - * @function Phaser.Tilemaps.ParseToTilemap - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene to which this Tilemap belongs. - * @param {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data. - * @param {integer} [tileWidth=32] - The width of a tile in pixels. - * @param {integer} [tileHeight=32] - The height of a tile in pixels. - * @param {integer} [width=10] - The width of the map in tiles. - * @param {integer} [height=10] - The height of the map in tiles. - * @param {integer[][]} [data] - Instead of loading from the cache, you can also load directly from - * a 2D array of tile indexes. - * @param {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, in the - * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {Phaser.Tilemaps.Tilemap} + * @property {string} name - The name of the camera + * @property {number} x - The horizontal position of camera + * @property {number} y - The vertical position of camera + * @property {number} width - The width size of camera + * @property {number} height - The height size of camera + * @property {number} zoom - The zoom of camera + * @property {number} rotation - The rotation of camera + * @property {boolean} roundPixels - The round pixels st status of camera + * @property {number} scrollX - The horizontal scroll of camera + * @property {number} scrollY - The vertical scroll of camera + * @property {string} backgroundColor - The background color of camera + * @property {object} [bounds] - The bounds of camera + * @property {number} [bounds.x] - The horizontal position of bounds of camera + * @property {number} [bounds.y] - The vertical position of bounds of camera + * @property {number} [bounds.width] - The width of the bounds of camera + * @property {number} [bounds.height] - The height of the bounds of camera */ -var ParseToTilemap = function (scene, key, tileWidth, tileHeight, width, height, data, insertNull) -{ - if (tileWidth === undefined) { tileWidth = 32; } - if (tileHeight === undefined) { tileHeight = 32; } - if (width === undefined) { width = 10; } - if (height === undefined) { height = 10; } - if (insertNull === undefined) { insertNull = false; } - var mapData = null; +/** + * @classdesc + * [description] + * + * @class Camera + * @memberOf Phaser.Cameras.Scene2D + * @constructor + * @since 3.0.0 + * + * @param {number} x - The x position of the Camera, relative to the top-left of the game canvas. + * @param {number} y - The y position of the Camera, relative to the top-left of the game canvas. + * @param {number} width - The width of the Camera, in pixels. + * @param {number} height - The height of the Camera, in pixels. + */ +var Camera = new Class({ - if (Array.isArray(data)) + initialize: + + function Camera (x, y, width, height) { - var name = key !== undefined ? key : 'map'; - mapData = Parse(name, Formats.ARRAY_2D, data, tileWidth, tileHeight, insertNull); - } - else if (key !== undefined) - { - var tilemapData = scene.cache.tilemap.get(key); + /** + * A reference to the Scene this camera belongs to. + * + * @name Phaser.Cameras.Scene2D.Camera#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene; - if (!tilemapData) + /** + * The name of the Camera. This is left empty for your own use. + * + * @name Phaser.Cameras.Scene2D.Camera#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * The x position of the Camera, relative to the top-left of the game canvas. + * + * @name Phaser.Cameras.Scene2D.Camera#x + * @type {number} + * @since 3.0.0 + */ + this.x = x; + + /** + * The y position of the Camera, relative to the top-left of the game canvas. + * + * @name Phaser.Cameras.Scene2D.Camera#y + * @type {number} + * @since 3.0.0 + */ + this.y = y; + + /** + * The width of the Camera, in pixels. + * + * @name Phaser.Cameras.Scene2D.Camera#width + * @type {number} + * @since 3.0.0 + */ + this.width = width; + + /** + * The height of the Camera, in pixels. + * + * @name Phaser.Cameras.Scene2D.Camera#height + * @type {number} + * @since 3.0.0 + */ + this.height = height; + + /** + * Should this camera round its pixel values to integers? + * + * @name Phaser.Cameras.Scene2D.Camera#roundPixels + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.roundPixels = false; + + /** + * Is this Camera using a bounds to restrict scrolling movement? + * Set this property along with the bounds via `Camera.setBounds`. + * + * @name Phaser.Cameras.Scene2D.Camera#useBounds + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.useBounds = false; + + /** + * The bounds the camera is restrained to during scrolling. + * + * @name Phaser.Cameras.Scene2D.Camera#_bounds + * @type {Phaser.Geom.Rectangle} + * @private + * @since 3.0.0 + */ + this._bounds = new Rectangle(); + + /** + * Does this Camera allow the Game Objects it renders to receive input events? + * + * @name Phaser.Cameras.Scene2D.Camera#inputEnabled + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.inputEnabled = true; + + /** + * The horizontal scroll position of this camera. + * Optionally restricted via the Camera bounds. + * + * @name Phaser.Cameras.Scene2D.Camera#scrollX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.scrollX = 0; + + /** + * The vertical scroll position of this camera. + * Optionally restricted via the Camera bounds. + * + * @name Phaser.Cameras.Scene2D.Camera#scrollY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.scrollY = 0; + + /** + * The Camera zoom value. Change this value to zoom in, or out of, a Scene. + * Set to 1 to return to the default zoom level. + * + * @name Phaser.Cameras.Scene2D.Camera#zoom + * @type {float} + * @default 1 + * @since 3.0.0 + */ + this.zoom = 1; + + /** + * The rotation of the Camera. This influences the rendering of all Game Objects visible by this camera. + * + * @name Phaser.Cameras.Scene2D.Camera#rotation + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.rotation = 0; + + /** + * A local transform matrix used for internal calculations. + * + * @name Phaser.Cameras.Scene2D.Camera#matrix + * @type {TransformMatrix} + * @since 3.0.0 + */ + this.matrix = new TransformMatrix(1, 0, 0, 1, 0, 0); + + /** + * Does this Camera have a transparent background? + * + * @name Phaser.Cameras.Scene2D.Camera#transparent + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.transparent = true; + + /** + * TODO + * + * @name Phaser.Cameras.Scene2D.Camera#clearBeforeRender + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.clearBeforeRender = true; + + /** + * The background color of this Camera. Only used if `transparent` is `false`. + * + * @name Phaser.Cameras.Scene2D.Camera#backgroundColor + * @type {Phaser.Display.Color} + * @since 3.0.0 + */ + this.backgroundColor = ValueToColor('rgba(0,0,0,0)'); + + /** + * Should the camera cull Game Objects before rendering? + * In some special cases it may be beneficial to disable this. + * + * @name Phaser.Cameras.Scene2D.Camera#disableCull + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.disableCull = false; + + /** + * A temporary array of culled objects. + * + * @name Phaser.Cameras.Scene2D.Camera#culledObjects + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.culledObjects = []; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_shakeDuration + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._shakeDuration = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_shakeIntensity + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._shakeIntensity = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_shakeOffsetX + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._shakeOffsetX = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_shakeOffsetY + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._shakeOffsetY = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_shakeCallback + * @type {function} + * @private + * @default null + * @since 3.3.0 + */ + this._shakeCallback = null; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_fadeDuration + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._fadeDuration = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_fadeRed + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._fadeRed = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_fadeGreen + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._fadeGreen = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_fadeBlue + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._fadeBlue = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_fadeAlpha + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._fadeAlpha = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_fadeCallback + * @type {function} + * @private + * @default null + * @since 3.3.0 + */ + this._fadeCallback = null; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_flashDuration + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._flashDuration = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_flashRed + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + this._flashRed = 1; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_flashGreen + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + this._flashGreen = 1; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_flashBlue + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + this._flashBlue = 1; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_flashAlpha + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._flashAlpha = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_flashCallback + * @type {function} + * @private + * @default null + * @since 3.3.0 + */ + this._flashCallback = null; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_follow + * @type {?any} + * @private + * @default null + * @since 3.0.0 + */ + this._follow = null; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_id + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + this._id = 0; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#centerToBounds + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + centerToBounds: function () + { + this.scrollX = (this._bounds.width * 0.5) - (this.width * 0.5); + this.scrollY = (this._bounds.height * 0.5) - (this.height * 0.5); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#centerToSize + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + centerToSize: function () + { + this.scrollX = this.width * 0.5; + this.scrollY = this.height * 0.5; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#cull + * @since 3.0.0 + * + * @param {array} renderableObjects - [description] + * + * @return {array} [description] + */ + cull: function (renderableObjects) + { + if (this.disableCull) { - console.warn('No map data found for key ' + key); + return renderableObjects; + } + + var cameraMatrix = this.matrix.matrix; + + var mva = cameraMatrix[0]; + var mvb = cameraMatrix[1]; + var mvc = cameraMatrix[2]; + var mvd = cameraMatrix[3]; + + /* First Invert Matrix */ + var determinant = (mva * mvd) - (mvb * mvc); + + if (!determinant) + { + return renderableObjects; + } + + var mve = cameraMatrix[4]; + var mvf = cameraMatrix[5]; + + var scrollX = this.scrollX; + var scrollY = this.scrollY; + var cameraW = this.width; + var cameraH = this.height; + var culledObjects = this.culledObjects; + var length = renderableObjects.length; + + determinant = 1 / determinant; + + culledObjects.length = 0; + + for (var index = 0; index < length; ++index) + { + var object = renderableObjects[index]; + + if (!object.hasOwnProperty('width')) + { + culledObjects.push(object); + continue; + } + + var objectW = object.width; + var objectH = object.height; + var objectX = (object.x - (scrollX * object.scrollFactorX)) - (objectW * object.originX); + var objectY = (object.y - (scrollY * object.scrollFactorY)) - (objectH * object.originY); + var tx = (objectX * mva + objectY * mvc + mve); + var ty = (objectX * mvb + objectY * mvd + mvf); + var tw = ((objectX + objectW) * mva + (objectY + objectH) * mvc + mve); + var th = ((objectX + objectW) * mvb + (objectY + objectH) * mvd + mvf); + var cullW = cameraW + objectW; + var cullH = cameraH + objectH; + + if (tx > -objectW || ty > -objectH || tx < cullW || ty < cullH || + tw > -objectW || th > -objectH || tw < cullW || th < cullH) + { + culledObjects.push(object); + } + } + + return culledObjects; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#cullHitTest + * @since 3.0.0 + * + * @param {array} interactiveObjects - [description] + * + * @return {array} [description] + */ + cullHitTest: function (interactiveObjects) + { + if (this.disableCull) + { + return interactiveObjects; + } + + var cameraMatrix = this.matrix.matrix; + + var mva = cameraMatrix[0]; + var mvb = cameraMatrix[1]; + var mvc = cameraMatrix[2]; + var mvd = cameraMatrix[3]; + + /* First Invert Matrix */ + var determinant = (mva * mvd) - (mvb * mvc); + + if (!determinant) + { + return interactiveObjects; + } + + var mve = cameraMatrix[4]; + var mvf = cameraMatrix[5]; + + var scrollX = this.scrollX; + var scrollY = this.scrollY; + var cameraW = this.width; + var cameraH = this.height; + var length = interactiveObjects.length; + + determinant = 1 / determinant; + + var culledObjects = []; + + for (var index = 0; index < length; ++index) + { + var object = interactiveObjects[index].gameObject; + + if (!object.hasOwnProperty('width')) + { + culledObjects.push(interactiveObjects[index]); + continue; + } + + var objectW = object.width; + var objectH = object.height; + var objectX = (object.x - (scrollX * object.scrollFactorX)) - (objectW * object.originX); + var objectY = (object.y - (scrollY * object.scrollFactorY)) - (objectH * object.originY); + var tx = (objectX * mva + objectY * mvc + mve); + var ty = (objectX * mvb + objectY * mvd + mvf); + var tw = ((objectX + objectW) * mva + (objectY + objectH) * mvc + mve); + var th = ((objectX + objectW) * mvb + (objectY + objectH) * mvd + mvf); + var cullW = cameraW + objectW; + var cullH = cameraH + objectH; + + if (tx > -objectW || ty > -objectH || tx < cullW || ty < cullH || + tw > -objectW || th > -objectH || tw < cullW || th < cullH) + { + culledObjects.push(interactiveObjects[index]); + } + } + + return culledObjects; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#cullTilemap + * @since 3.0.0 + * + * @param {array} tilemap - [description] + * + * @return {array} [description] + */ + cullTilemap: function (tilemap) + { + var cameraMatrix = this.matrix.matrix; + + var mva = cameraMatrix[0]; + var mvb = cameraMatrix[1]; + var mvc = cameraMatrix[2]; + var mvd = cameraMatrix[3]; + + /* First Invert Matrix */ + var determinant = (mva * mvd) - (mvb * mvc); + + if (!determinant) + { + return tiles; + } + + var mve = cameraMatrix[4]; + var mvf = cameraMatrix[5]; + var tiles = tilemap.tiles; + var scrollX = this.scrollX; + var scrollY = this.scrollY; + var cameraW = this.width; + var cameraH = this.height; + var culledObjects = this.culledObjects; + var length = tiles.length; + var tileW = tilemap.tileWidth; + var tileH = tilemap.tileHeight; + var cullW = cameraW + tileW; + var cullH = cameraH + tileH; + var scrollFactorX = tilemap.scrollFactorX; + var scrollFactorY = tilemap.scrollFactorY; + + determinant = 1 / determinant; + + culledObjects.length = 0; + + for (var index = 0; index < length; ++index) + { + var tile = tiles[index]; + var tileX = (tile.x - (scrollX * scrollFactorX)); + var tileY = (tile.y - (scrollY * scrollFactorY)); + var tx = (tileX * mva + tileY * mvc + mve); + var ty = (tileX * mvb + tileY * mvd + mvf); + var tw = ((tileX + tileW) * mva + (tileY + tileH) * mvc + mve); + var th = ((tileX + tileW) * mvb + (tileY + tileH) * mvd + mvf); + + if (tx > -tileW && ty > -tileH && tw < cullW && th < cullH) + { + culledObjects.push(tile); + } + } + + return culledObjects; + }, + + /** + * Fades the Camera in from the given color over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#fadeIn + * @since 3.3.0 + * + * @param {number} duration - The duration of the effect in milliseconds. + * @param {function} [callback] - An optional callback to invoke when the fade completes. Will be sent one argument - a reference to this camera. + * @param {number} [red=0] - The value to fade the red channel from. A value between 0 and 1. + * @param {number} [green=0] - The value to fade the green channel from. A value between 0 and 1. + * @param {number} [blue=0] - The value to fade the blue channel from. A value between 0 and 1. + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + fadeIn: function (duration, callback, red, green, blue) + { + if (red === undefined) { red = 0; } + if (green === undefined) { green = 0; } + if (blue === undefined) { blue = 0; } + + return this.flash(duration, red, green, blue, true, callback); + }, + + /** + * Fades the Camera out to the given color over the duration specified. + * This is an alias for Camera.fade that forces the fade to start, regardless of existing fades. + * + * @method Phaser.Cameras.Scene2D.Camera#fadeOut + * @since 3.3.0 + * + * @param {number} duration - The duration of the effect in milliseconds. + * @param {function} [callback] - An optional callback to invoke when the fade completes. Will be sent one argument - a reference to this camera. + * @param {number} [red=0] - The value to fade the red channel from. A value between 0 and 1. + * @param {number} [green=0] - The value to fade the green channel from. A value between 0 and 1. + * @param {number} [blue=0] - The value to fade the blue channel from. A value between 0 and 1. + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + fadeOut: function (duration, callback, red, green, blue) + { + if (red === undefined) { red = 0; } + if (green === undefined) { green = 0; } + if (blue === undefined) { blue = 0; } + + return this.fade(duration, red, green, blue, true, callback); + }, + + /** + * Fades the Camera to the given color over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#fade + * @since 3.0.0 + * + * @param {number} duration - The duration of the effect in milliseconds. + * @param {number} [red=0] - The value to fade the red channel to. A value between 0 and 1. + * @param {number} [green=0] - The value to fade the green channel to. A value between 0 and 1. + * @param {number} [blue=0] - The value to fade the blue channel to. A value between 0 and 1. + * @param {boolean} [force=false] - Force the fade effect to start immediately, even if already running. + * @param {function} [callback] - An optional callback to invoke when the fade completes. Will be sent one argument - a reference to this camera. + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + fade: function (duration, red, green, blue, force, callback) + { + if (!duration) { duration = Number.MIN_VALUE; } + if (red === undefined) { red = 0; } + if (green === undefined) { green = 0; } + if (blue === undefined) { blue = 0; } + if (force === undefined) { force = false; } + if (callback === undefined) { callback = null; } + + if (!force && this._fadeAlpha > 0) + { + return this; + } + + this._fadeRed = red; + this._fadeGreen = green; + this._fadeBlue = blue; + this._fadeCallback = callback; + this._fadeDuration = duration; + this._fadeAlpha = Number.MIN_VALUE; + + return this; + }, + + /** + * Flashes the Camera to the given color over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#flash + * @since 3.0.0 + * + * @param {number} duration - The duration of the effect in milliseconds. + * @param {number} [red=1] - The value to flash the red channel to. A value between 0 and 1. + * @param {number} [green=1] - The value to flash the green channel to. A value between 0 and 1. + * @param {number} [blue=1] - The value to flash the blue channel to. A value between 0 and 1. + * @param {boolean} [force=false] - Force the flash effect to start immediately, even if already running. + * @param {function} [callback] - An optional callback to invoke when the flash completes. Will be sent one argument - a reference to this camera. + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + flash: function (duration, red, green, blue, force, callback) + { + if (!duration) { duration = Number.MIN_VALUE; } + if (red === undefined) { red = 1; } + if (green === undefined) { green = 1; } + if (blue === undefined) { blue = 1; } + if (force === undefined) { force = false; } + if (callback === undefined) { callback = null; } + + if (!force && this._flashAlpha > 0) + { + return this; + } + + this._flashRed = red; + this._flashGreen = green; + this._flashBlue = blue; + this._flashCallback = callback; + this._flashDuration = duration; + this._flashAlpha = 1; + + return this; + }, + + /** + * Shakes the Camera by the given intensity over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#shake + * @since 3.0.0 + * + * @param {number} duration - The duration of the effect in milliseconds. + * @param {number} [intensity=0.05] - The intensity of the shake. + * @param {boolean} [force=false] - Force the shake effect to start immediately, even if already running. + * @param {function} [callback] - An optional callback to invoke when the shake completes. Will be sent one argument - a reference to this camera. + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + shake: function (duration, intensity, force, callback) + { + if (!duration) { duration = Number.MIN_VALUE; } + if (intensity === undefined) { intensity = 0.05; } + if (force === undefined) { force = false; } + if (callback === undefined) { callback = null; } + + if (!force && (this._shakeOffsetX !== 0 || this._shakeOffsetY !== 0)) + { + return this; + } + + this._shakeDuration = duration; + this._shakeIntensity = intensity; + this._shakeOffsetX = 0; + this._shakeOffsetY = 0; + this._shakeCallback = callback; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#getWorldPoint + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {(object|Phaser.Math.Vector2)} output - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + getWorldPoint: function (x, y, output) + { + if (output === undefined) { output = new Vector2(); } + + var cameraMatrix = this.matrix.matrix; + + var mva = cameraMatrix[0]; + var mvb = cameraMatrix[1]; + var mvc = cameraMatrix[2]; + var mvd = cameraMatrix[3]; + var mve = cameraMatrix[4]; + var mvf = cameraMatrix[5]; + + /* First Invert Matrix */ + var determinant = (mva * mvd) - (mvb * mvc); + + if (!determinant) + { + output.x = x; + output.y = y; + + return output; + } + + determinant = 1 / determinant; + + var ima = mvd * determinant; + var imb = -mvb * determinant; + var imc = -mvc * determinant; + var imd = mva * determinant; + var ime = (mvc * mvf - mvd * mve) * determinant; + var imf = (mvb * mve - mva * mvf) * determinant; + + var c = Math.cos(this.rotation); + var s = Math.sin(this.rotation); + + var zoom = this.zoom; + + var scrollX = this.scrollX; + var scrollY = this.scrollY; + + var sx = x + ((scrollX * c - scrollY * s) * zoom); + var sy = y + ((scrollX * s + scrollY * c) * zoom); + + /* Apply transform to point */ + output.x = (sx * ima + sy * imc + ime); + output.y = (sx * imb + sy * imd + imf); + + return output; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#ignore + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjectOrArray - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + ignore: function (gameObjectOrArray) + { + if (gameObjectOrArray instanceof Array) + { + for (var index = 0; index < gameObjectOrArray.length; ++index) + { + gameObjectOrArray[index].cameraFilter |= this._id; + } } else { - mapData = Parse(key, tilemapData.format, tilemapData.data, tileWidth, tileHeight, insertNull); + gameObjectOrArray.cameraFilter |= this._id; } - } - if (mapData === null) + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#preRender + * @since 3.0.0 + * + * @param {number} baseScale - [description] + * @param {number} resolution - [description] + * + */ + preRender: function (baseScale, resolution) { - mapData = new MapData({ - tileWidth: tileWidth, - tileHeight: tileHeight, - width: width, - height: height - }); + var width = this.width; + var height = this.height; + var zoom = this.zoom * baseScale; + var matrix = this.matrix; + var originX = width / 2; + var originY = height / 2; + var follow = this._follow; + + if (follow !== null) + { + originX = follow.x; + originY = follow.y; + + this.scrollX = (originX - width * 0.5) / zoom; + this.scrollY = (originY - height * 0.5) / zoom; + } + + if (this.useBounds) + { + var bounds = this._bounds; + + var bw = Math.max(0, bounds.right - width); + var bh = Math.max(0, bounds.bottom - height); + + if (this.scrollX < bounds.x) + { + this.scrollX = bounds.x; + } + else if (this.scrollX > bw) + { + this.scrollX = bw; + } + + if (this.scrollY < bounds.y) + { + this.scrollY = bounds.y; + } + else if (this.scrollY > bh) + { + this.scrollY = bh; + } + } + + if (this.roundPixels) + { + this.scrollX = Math.round(this.scrollX); + this.scrollY = Math.round(this.scrollY); + } + + matrix.loadIdentity(); + matrix.scale(resolution, resolution); + matrix.translate(this.x + originX, this.y + originY); + matrix.rotate(this.rotation); + matrix.scale(zoom, zoom); + matrix.translate(-originX, -originY); + matrix.translate(this._shakeOffsetX, this._shakeOffsetY); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#removeBounds + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + removeBounds: function () + { + this.useBounds = false; + + this._bounds.setEmpty(); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setAngle + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setAngle: function (value) + { + if (value === undefined) { value = 0; } + + this.rotation = DegToRad(value); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setBackgroundColor + * @since 3.0.0 + * + * @param {(string|number|InputColorObject)} color - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setBackgroundColor: function (color) + { + if (color === undefined) { color = 'rgba(0,0,0,0)'; } + + this.backgroundColor = ValueToColor(color); + + this.transparent = (this.backgroundColor.alpha === 0); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setBounds + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setBounds: function (x, y, width, height) + { + this._bounds.setTo(x, y, width, height); + + this.useBounds = true; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setName + * @since 3.0.0 + * + * @param {string} value - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setName: function (value) + { + if (value === undefined) { value = ''; } + + this.name = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setPosition + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setPosition: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setRotation + * @since 3.0.0 + * + * @param {number} [value=0] - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setRotation: function (value) + { + if (value === undefined) { value = 0; } + + this.rotation = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setRoundPixels + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setRoundPixels: function (value) + { + this.roundPixels = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setScene + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setScene: function (scene) + { + this.scene = scene; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setScroll + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setScroll: function (x, y) + { + if (y === undefined) { y = x; } + + this.scrollX = x; + this.scrollY = y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setSize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} [height=width] - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setSize: function (width, height) + { + if (height === undefined) { height = width; } + + this.width = width; + this.height = height; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setViewport + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setViewport: function (x, y, width, height) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setZoom + * @since 3.0.0 + * + * @param {float} [value=1] - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setZoom: function (value) + { + if (value === undefined) { value = 1; } + + this.zoom = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#startFollow + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|object)} target - [description] + * @param {boolean} roundPx - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + startFollow: function (target, roundPx) + { + if (roundPx === undefined) { roundPx = false; } + + this._follow = target; + + this.roundPixels = roundPx; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#stopFollow + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + stopFollow: function () + { + this._follow = null; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#toJSON + * @since 3.0.0 + * + * @return {JSONCamera} [description] + */ + toJSON: function () + { + var output = { + name: this.name, + x: this.x, + y: this.y, + width: this.width, + height: this.height, + zoom: this.zoom, + rotation: this.rotation, + roundPixels: this.roundPixels, + scrollX: this.scrollX, + scrollY: this.scrollY, + backgroundColor: this.backgroundColor.rgba + }; + + if (this.useBounds) + { + output['bounds'] = { + x: this._bounds.x, + y: this._bounds.y, + width: this._bounds.width, + height: this._bounds.height + }; + } + + return output; + }, + + /** + * Resets any active FX, such as a fade, flash or shake. Useful to call after a fade in order to + * remove the fade. + * + * @method Phaser.Cameras.Scene2D.Camera#resetFX + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + resetFX: function () + { + this._flashAlpha = 0; + this._fadeAlpha = 0; + this._shakeOffsetX = 0; + this._shakeOffsetY = 0; + this._shakeDuration = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#update + * @since 3.0.0 + * + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + update: function (time, delta) + { + if (this._flashAlpha > 0) + { + this._flashAlpha -= delta / this._flashDuration; + + if (this._flashAlpha <= 0) + { + this._flashAlpha = 0; + + if (this._flashCallback) + { + // Do this in case the callback flashes again (otherwise we'd overwrite the new callback) + var flashCallback = this._flashCallback; + + this._flashCallback = null; + + flashCallback(this); + } + } + } + + if (this._fadeAlpha > 0 && this._fadeAlpha < 1) + { + this._fadeAlpha += delta / this._fadeDuration; + + if (this._fadeAlpha >= 1) + { + this._fadeAlpha = 1; + + if (this._fadeCallback) + { + // Do this in case the callback fades again (otherwise we'd overwrite the new callback) + var fadeCallback = this._fadeCallback; + + this._fadeCallback = null; + + fadeCallback(this); + } + } + } + + if (this._shakeDuration > 0) + { + var intensity = this._shakeIntensity; + + this._shakeDuration -= delta; + + if (this._shakeDuration <= 0) + { + this._shakeOffsetX = 0; + this._shakeOffsetY = 0; + + if (this._shakeCallback) + { + // Do this in case the callback shakes again (otherwise we'd overwrite the new callback) + var shakeCallback = this._shakeCallback; + + this._shakeCallback = null; + + shakeCallback(this); + } + } + else + { + this._shakeOffsetX = (Math.random() * intensity * this.width * 2 - intensity * this.width) * this.zoom; + this._shakeOffsetY = (Math.random() * intensity * this.height * 2 - intensity * this.height) * this.zoom; + + if (this.roundPixels) + { + this._shakeOffsetX |= 0; + this._shakeOffsetY |= 0; + } + } + } + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#destroy + * @since 3.0.0 + */ + destroy: function () + { + this._bounds = undefined; + this.matrix = undefined; + this.culledObjects = []; + this.scene = undefined; } - return new Tilemap(scene, mapData); -}; +}); -module.exports = ParseToTilemap; +module.exports = Camera; /***/ }), /* 158 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetValue = __webpack_require__(4); - -/** - * [description] - * - * @function Phaser.Tweens.Builders.GetTargets - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {array} [description] - */ -var GetTargets = function (config) -{ - var targets = GetValue(config, 'targets', null); - - if (targets === null) - { - return targets; - } - - if (typeof targets === 'function') - { - targets = targets.call(); - } - - if (!Array.isArray(targets)) - { - targets = [ targets ]; - } - - return targets; -}; - -module.exports = GetTargets; - - -/***/ }), -/* 159 */ /***/ (function(module, exports) { /** @@ -30660,167 +32774,406 @@ module.exports = GetTargets; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -function hasGetStart (def) -{ - return (!!def.getStart && typeof def.getStart === 'function'); -} - -function hasGetEnd (def) -{ - return (!!def.getEnd && typeof def.getEnd === 'function'); -} - -function hasGetters (def) -{ - return hasGetStart(def) || hasGetEnd(def); -} - /** - * [description] + * Takes the given string and pads it out, to the length required, using the character + * specified. For example if you need a string to be 6 characters long, you can call: * - * @function Phaser.Tweens.Builders.GetValueOp + * `pad('bob', 6, '-', 2)` + * + * This would return: `bob---` as it has padded it out to 6 characters, using the `-` on the right. + * + * You can also use it to pad numbers (they are always returned as strings): + * + * `pad(512, 6, '0', 1)` + * + * Would return: `000512` with the string padded to the left. + * + * If you don't specify a direction it'll pad to both sides: + * + * `pad('c64', 7, '*')` + * + * Would return: `**c64**` + * + * @function Phaser.Utils.String.Pad * @since 3.0.0 * - * @param {string} key - [description] - * @param {any} propertyValue - [description] - * - * @return {function} [description] + * @param {string} str - The target string. `toString()` will be called on the string, which means you can also pass in common data types like numbers. + * @param {integer} [len=0] - The number of characters to be added. + * @param {string} [pad=" "] - The string to pad it out with (defaults to a space). + * @param {integer} [dir=3] - The direction dir = 1 (left), 2 (right), 3 (both). + * + * @return {string} The padded string. */ -var GetValueOp = function (key, propertyValue) +var Pad = function (str, len, pad, dir) { - var callbacks; + if (len === undefined) { len = 0; } + if (pad === undefined) { pad = ' '; } + if (dir === undefined) { dir = 3; } - // The returned value sets what the property will be at the END of the Tween (usually called at the start of the Tween) - var getEnd = function (target, key, value) { return value; }; + str = str.toString(); - // The returned value sets what the property will be at the START of the Tween (usually called at the end of the Tween) - var getStart = function (target, key, value) { return value; }; + var padlen = 0; - var t = typeof(propertyValue); - - if (t === 'number') + if (len + 1 >= str.length) { - // props: { - // x: 400, - // y: 300 - // } - - getEnd = function () + switch (dir) { - return propertyValue; - }; - } - else if (t === 'string') - { - // props: { - // x: '+=400', - // y: '-=300', - // z: '*=2', - // w: '/=2' - // } - - var op = propertyValue[0]; - var num = parseFloat(propertyValue.substr(2)); - - switch (op) - { - case '+': - getEnd = function (target, key, value) - { - return value + num; - }; + case 1: + str = new Array(len + 1 - str.length).join(pad) + str; break; - case '-': - getEnd = function (target, key, value) - { - return value - num; - }; - break; - - case '*': - getEnd = function (target, key, value) - { - return value * num; - }; - break; - - case '/': - getEnd = function (target, key, value) - { - return value / num; - }; + case 3: + var right = Math.ceil((padlen = len - str.length) / 2); + var left = padlen - right; + str = new Array(left + 1).join(pad) + str + new Array(right + 1).join(pad); break; default: - getEnd = function () - { - return parseFloat(propertyValue); - }; + str = str + new Array(len + 1 - str.length).join(pad); + break; } } - else if (t === 'function') - { - // The same as setting just the getEnd function and no getStart - // props: { - // x: function (target, key, value) { return value + 50); }, - // } - - getEnd = propertyValue; - } - else if (t === 'object' && hasGetters(propertyValue)) - { - /* - x: { - // Called at the start of the Tween. The returned value sets what the property will be at the END of the Tween. - getEnd: function (target, key, value) - { - return value; - }, - - // Called at the end of the Tween. The returned value sets what the property will be at the START of the Tween. - getStart: function (target, key, value) - { - return value; - } - } - */ - - if (hasGetEnd(propertyValue)) - { - getEnd = propertyValue.getEnd; - } - - if (hasGetStart(propertyValue)) - { - getStart = propertyValue.getStart; - } - } - else if (propertyValue.hasOwnProperty('value')) - { - // Value may still be a string, function or a number - // props: { - // x: { value: 400, ... }, - // y: { value: 300, ... } - // } - - callbacks = GetValueOp(key, propertyValue.value); - } - - // If callback not set by the else if block above then set it here and return it - if (!callbacks) - { - callbacks = { - getEnd: getEnd, - getStart: getStart - }; - } - - return callbacks; + return str; }; -module.exports = GetValueOp; +module.exports = Pad; + + +/***/ }), +/* 159 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @callback EachMapCallback + * + * @param {string} key - [description] + * @param {*} entry - [description] + * + * @return {?boolean} [description] + */ + +/** + * @classdesc + * The keys of a Map can be arbitrary values. + * var map = new Map([ + * [ 1, 'one' ], + * [ 2, 'two' ], + * [ 3, 'three' ] + * ]); + * + * @class Map + * @memberOf Phaser.Structs + * @constructor + * @since 3.0.0 + * + * @param {array} elements - [description] + */ +var Map = new Class({ + + initialize: + + function Map (elements) + { + /** + * [description] + * + * @name Phaser.Structs.Map#entries + * @type {Object.} + * @default {} + * @since 3.0.0 + */ + this.entries = {}; + + /** + * [description] + * + * @name Phaser.Structs.Map#size + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.size = 0; + + if (Array.isArray(elements)) + { + for (var i = 0; i < elements.length; i++) + { + this.set(elements[i][0], elements[i][1]); + } + } + }, + + /** + * [description] + * + * @method Phaser.Structs.Map#set + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {*} value - [description] + * + * @return {Phaser.Structs.Map} This Map object. + */ + set: function (key, value) + { + if (!this.has(key)) + { + this.entries[key] = value; + this.size++; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.Map#get + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {*} [description] + */ + get: function (key) + { + if (this.has(key)) + { + return this.entries[key]; + } + }, + + /** + * [description] + * + * @method Phaser.Structs.Map#getArray + * @since 3.0.0 + * + * @return {array} [description] + */ + getArray: function () + { + var output = []; + var entries = this.entries; + + for (var key in entries) + { + output.push(entries[key]); + } + + return output; + }, + + /** + * [description] + * + * @method Phaser.Structs.Map#has + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {boolean} [description] + */ + has: function (key) + { + return (this.entries.hasOwnProperty(key)); + }, + + /** + * [description] + * + * @method Phaser.Structs.Map#delete + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Structs.Map} This Map object. + */ + delete: function (key) + { + if (this.has(key)) + { + delete this.entries[key]; + this.size--; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.Map#clear + * @since 3.0.0 + * + * @return {Phaser.Structs.Map} This Map object. + */ + clear: function () + { + Object.keys(this.entries).forEach(function (prop) + { + delete this.entries[prop]; + + }, this); + + this.size = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.Map#keys + * @since 3.0.0 + * + * @return {string[]} [description] + */ + keys: function () + { + return Object.keys(this.entries); + }, + + /** + * [description] + * + * @method Phaser.Structs.Map#values + * @since 3.0.0 + * + * @return {array} [description] + */ + values: function () + { + var output = []; + var entries = this.entries; + + for (var key in entries) + { + output.push(entries[key]); + } + + return output; + }, + + /** + * [description] + * + * @method Phaser.Structs.Map#dump + * @since 3.0.0 + */ + dump: function () + { + var entries = this.entries; + + // eslint-disable-next-line no-console + console.group('Map'); + + for (var key in entries) + { + console.log(key, entries[key]); + } + + // eslint-disable-next-line no-console + console.groupEnd(); + }, + + /** + * [description] + * + * @method Phaser.Structs.Map#each + * @since 3.0.0 + * + * @param {EachMapCallback} callback - [description] + * + * @return {Phaser.Structs.Map} This Map object. + */ + each: function (callback) + { + var entries = this.entries; + + for (var key in entries) + { + if (callback(key, entries[key]) === false) + { + break; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.Map#contains + * @since 3.0.0 + * + * @param {*} value - [description] + * + * @return {boolean} [description] + */ + contains: function (value) + { + var entries = this.entries; + + for (var key in entries) + { + if (entries[key] === value) + { + return true; + } + } + + return false; + }, + + /** + * Merges all new keys from the given Map into this one + * If it encounters a key that already exists it will be skipped + * unless override = true. + * + * @method Phaser.Structs.Map#merge + * @since 3.0.0 + * + * @param {Phaser.Structs.Map} map - [description] + * @param {boolean} [override=false] - [description] + * + * @return {Phaser.Structs.Map} This Map object. + */ + merge: function (map, override) + { + if (override === undefined) { override = false; } + + var local = this.entries; + var source = map.entries; + + for (var key in source) + { + if (local.hasOwnProperty(key) && override) + { + local[key] = source[key]; + } + else + { + this.set(key, source[key]); + } + } + + return this; + } + +}); + +module.exports = Map; /***/ }), @@ -30834,35 +33187,30 @@ module.exports = GetValueOp; */ /** - * @typedef {object} Phaser.Tweens.Tween~ConfigDefaults - * @property {object|object[]} targets - [description] - * @property {number} [delay=0] - [description] - * @property {number} [duration=1000] - [description] - * @property {string} [ease='Power0'] - [description] - * @property {array} [easeParams] - [description] - * @property {number} [hold=0] - [description] - * @property {number} [repeat=0] - [description] - * @property {number} [repeatDelay=0] - [description] - * @property {boolean} [yoyo=false] - [description] - * @property {boolean} [flipX=false] - [description] - * @property {boolean} [flipY=false] - [description] + * [description] + * + * @function Phaser.Math.RotateAroundDistance + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point - The Point to be rotated. + * @param {number} x - The horizontal coordinate to rotate around. + * @param {number} y - The vertical coordinate to rotate around. + * @param {number} angle - The angle of rotation in radians. + * @param {number} distance - [description] + * + * @return {Phaser.Geom.Point} [description] */ +var RotateAroundDistance = function (point, x, y, angle, distance) +{ + var t = angle + Math.atan2(point.y - y, point.x - x); -var TWEEN_DEFAULTS = { - targets: null, - delay: 0, - duration: 1000, - ease: 'Power0', - easeParams: null, - hold: 0, - repeat: 0, - repeatDelay: 0, - yoyo: false, - flipX: false, - flipY: false + point.x = x + (distance * Math.cos(t)); + point.y = y + (distance * Math.sin(t)); + + return point; }; -module.exports = TWEEN_DEFAULTS; +module.exports = RotateAroundDistance; /***/ }), @@ -30875,1370 +33223,53 @@ module.exports = TWEEN_DEFAULTS; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var GameObjectCreator = __webpack_require__(13); -var GameObjectFactory = __webpack_require__(9); -var TWEEN_CONST = __webpack_require__(87); +var Point = __webpack_require__(4); /** - * @classdesc * [description] * - * @class Tween - * @memberOf Phaser.Tweens - * @constructor + * @function Phaser.Geom.Triangle.Random * @since 3.0.0 * - * @param {Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline} parent - [description] - * @param {Phaser.Tweens.TweenData[]} data - [description] - * @param {array} targets - [description] + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] */ -var Tween = new Class({ +var Random = function (triangle, out) +{ + if (out === undefined) { out = new Point(); } - initialize: + // Basis vectors + var ux = triangle.x2 - triangle.x1; + var uy = triangle.y2 - triangle.y1; - function Tween (parent, data, targets) + var vx = triangle.x3 - triangle.x1; + var vy = triangle.y3 - triangle.y1; + + // Random point within the unit square + var r = Math.random(); + var s = Math.random(); + + // Point outside the triangle? Remap it. + if (r + s >= 1) { - /** - * [description] - * - * @name Phaser.Tweens.Tween#parent - * @type {Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline} - * @since 3.0.0 - */ - this.parent = parent; - - /** - * Is the parent of this Tween a Timeline? - * - * @name Phaser.Tweens.Tween#parentIsTimeline - * @type {boolean} - * @since 3.0.0 - */ - this.parentIsTimeline = parent.hasOwnProperty('isTimeline'); - - /** - * An array of TweenData objects, each containing a unique property and target being tweened. - * - * @name Phaser.Tweens.Tween#data - * @type {Phaser.Tweens.TweenData[]} - * @since 3.0.0 - */ - this.data = data; - - /** - * data array doesn't change, so we can cache the length - * - * @name Phaser.Tweens.Tween#totalData - * @type {integer} - * @since 3.0.0 - */ - this.totalData = data.length; - - /** - * An array of references to the target/s this Tween is operating on - * - * @name Phaser.Tweens.Tween#targets - * @type {object[]} - * @since 3.0.0 - */ - this.targets = targets; - - /** - * Cached target total (not necessarily the same as the data total) - * - * @name Phaser.Tweens.Tween#totalTargets - * @type {integer} - * @since 3.0.0 - */ - this.totalTargets = targets.length; - - /** - * If true then duration, delay, etc values are all frame totals. - * - * @name Phaser.Tweens.Tween#useFrames - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.useFrames = false; - - /** - * Scales the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. - * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. - * - * @name Phaser.Tweens.Tween#timeScale - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * Loop this tween? Can be -1 for an infinite loop, or an integer. - * When enabled it will play through ALL TweenDatas again (use TweenData.repeat to loop a single TD) - * - * @name Phaser.Tweens.Tween#loop - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loop = 0; - - /** - * Time in ms/frames before the tween loops. - * - * @name Phaser.Tweens.Tween#loopDelay - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loopDelay = 0; - - /** - * How many loops are left to run? - * - * @name Phaser.Tweens.Tween#loopCounter - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loopCounter = 0; - - /** - * Time in ms/frames before the 'onComplete' event fires. This never fires if loop = -1 (as it never completes) - * - * @name Phaser.Tweens.Tween#completeDelay - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.completeDelay = 0; - - /** - * Countdown timer (used by timeline offset, loopDelay and completeDelay) - * - * @name Phaser.Tweens.Tween#countdown - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.countdown = 0; - - /** - * Set only if this Tween is part of a Timeline. - * - * @name Phaser.Tweens.Tween#offset - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.offset = 0; - - /** - * Set only if this Tween is part of a Timeline. The calculated offset amount. - * - * @name Phaser.Tweens.Tween#calculatedOffset - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.calculatedOffset = 0; - - /** - * The current state of the tween - * - * @name Phaser.Tweens.Tween#state - * @type {integer} - * @since 3.0.0 - */ - this.state = TWEEN_CONST.PENDING_ADD; - - /** - * The state of the tween when it was paused (used by Resume) - * - * @name Phaser.Tweens.Tween#_pausedState - * @type {integer} - * @private - * @since 3.0.0 - */ - this._pausedState = TWEEN_CONST.PENDING_ADD; - - /** - * Does the Tween start off paused? (if so it needs to be started with Tween.play) - * - * @name Phaser.Tweens.Tween#paused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.paused = false; - - /** - * Elapsed time in ms/frames of this run through the Tween. - * - * @name Phaser.Tweens.Tween#elapsed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.elapsed = 0; - - /** - * Total elapsed time in ms/frames of the entire Tween, including looping. - * - * @name Phaser.Tweens.Tween#totalElapsed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalElapsed = 0; - - /** - * Time in ms/frames for the whole Tween to play through once, excluding loop amounts and loop delays. - * - * @name Phaser.Tweens.Tween#duration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.duration = 0; - - /** - * Value between 0 and 1. The amount through the Tween, excluding loops. - * - * @name Phaser.Tweens.Tween#progress - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.progress = 0; - - /** - * Time in ms/frames for the Tween to complete (including looping) - * - * @name Phaser.Tweens.Tween#totalDuration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalDuration = 0; - - /** - * Value between 0 and 1. The amount through the entire Tween, including looping. - * - * @name Phaser.Tweens.Tween#totalProgress - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalProgress = 0; - - /** - * An object containing the various Tween callback references. - * - * @name Phaser.Tweens.Tween#callbacks - * @type {object} - * @default 0 - * @since 3.0.0 - */ - this.callbacks = { - onComplete: null, - onLoop: null, - onRepeat: null, - onStart: null, - onUpdate: null, - onYoyo: null - }; - - this.callbackScope; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#getValue - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getValue: function () - { - return this.data[0].current; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#setTimeScale - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - setTimeScale: function (value) - { - this.timeScale = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#getTimeScale - * @since 3.0.0 - * - * @return {number} [description] - */ - getTimeScale: function () - { - return this.timeScale; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#isPlaying - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isPlaying: function () - { - return (this.state === TWEEN_CONST.ACTIVE); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#isPaused - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isPaused: function () - { - return (this.state === TWEEN_CONST.PAUSED); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#hasTarget - * @since 3.0.0 - * - * @param {object} target - [description] - * - * @return {boolean} [description] - */ - hasTarget: function (target) - { - return (this.targets.indexOf(target) !== -1); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#updateTo - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {any} value - [description] - * @param {boolean} startToCurrent - [description] - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - updateTo: function (key, value, startToCurrent) - { - for (var i = 0; i < this.totalData; i++) - { - var tweenData = this.data[i]; - - if (tweenData.key === key) - { - tweenData.end = value; - - if (startToCurrent) - { - tweenData.start = tweenData.current; - } - - break; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#restart - * @since 3.0.0 - */ - restart: function () - { - this.stop(); - this.play(); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#calcDuration - * @since 3.0.0 - */ - calcDuration: function () - { - var max = 0; - - var data = this.data; - - for (var i = 0; i < this.totalData; i++) - { - var tweenData = data[i]; - - // Set t1 (duration + hold + yoyo) - tweenData.t1 = tweenData.duration + tweenData.hold; - - if (tweenData.yoyo) - { - tweenData.t1 += tweenData.duration; - } - - // Set t2 (repeatDelay + duration + hold + yoyo) - tweenData.t2 = tweenData.t1 + tweenData.repeatDelay; - - // Total Duration - tweenData.totalDuration = tweenData.delay + tweenData.t1; - - if (tweenData.repeat === -1) - { - tweenData.totalDuration += (tweenData.t2 * 999999999999); - } - else if (tweenData.repeat > 0) - { - tweenData.totalDuration += (tweenData.t2 * tweenData.repeat); - } - - if (tweenData.totalDuration > max) - { - // Get the longest TweenData from the Tween, used to calculate the Tween TD - max = tweenData.totalDuration; - } - } - - // Excludes loop values - this.duration = max; - - this.loopCounter = (this.loop === -1) ? 999999999999 : this.loop; - - if (this.loopCounter > 0) - { - this.totalDuration = this.duration + this.completeDelay + ((this.duration + this.loopDelay) * this.loopCounter); - } - else - { - this.totalDuration = this.duration + this.completeDelay; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#init - * @since 3.0.0 - * - * @return {boolean} Returns `true` if this Tween should be moved from the pending list to the active list by the Tween Manager. - */ - init: function () - { - var data = this.data; - var totalTargets = this.totalTargets; - - for (var i = 0; i < this.totalData; i++) - { - var tweenData = data[i]; - var target = tweenData.target; - var gen = tweenData.gen; - - tweenData.delay = gen.delay(i, totalTargets, target); - tweenData.duration = gen.duration(i, totalTargets, target); - tweenData.hold = gen.hold(i, totalTargets, target); - tweenData.repeat = gen.repeat(i, totalTargets, target); - tweenData.repeatDelay = gen.repeatDelay(i, totalTargets, target); - } - - this.calcDuration(); - - this.progress = 0; - this.totalProgress = 0; - this.elapsed = 0; - this.totalElapsed = 0; - - // You can't have a paused Tween if it's part of a Timeline - if (this.paused && !this.parentIsTimeline) - { - this.state = TWEEN_CONST.PAUSED; - - return false; - } - else - { - return true; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#nextState - * @since 3.0.0 - */ - nextState: function () - { - if (this.loopCounter > 0) - { - this.elapsed = 0; - this.progress = 0; - this.loopCounter--; - - var onLoop = this.callbacks.onLoop; - - if (onLoop) - { - onLoop.params[1] = this.targets; - - onLoop.func.apply(onLoop.scope, onLoop.params); - } - - this.resetTweenData(true); - - if (this.loopDelay > 0) - { - this.countdown = this.loopDelay; - this.state = TWEEN_CONST.LOOP_DELAY; - } - else - { - this.state = TWEEN_CONST.ACTIVE; - } - } - else if (this.completeDelay > 0) - { - this.countdown = this.completeDelay; - this.state = TWEEN_CONST.COMPLETE_DELAY; - } - else - { - var onComplete = this.callbacks.onComplete; - - if (onComplete) - { - onComplete.params[1] = this.targets; - - onComplete.func.apply(onComplete.scope, onComplete.params); - } - - this.state = TWEEN_CONST.PENDING_REMOVE; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#pause - * @since 3.0.0 - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - pause: function () - { - if (this.state === TWEEN_CONST.PAUSED) - { - return; - } - - this.paused = true; - - this._pausedState = this.state; - - this.state = TWEEN_CONST.PAUSED; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#play - * @since 3.0.0 - * - * @param {boolean} resetFromTimeline - [description] - */ - play: function (resetFromTimeline) - { - if (this.state === TWEEN_CONST.ACTIVE) - { - return; - } - else if (this.state === TWEEN_CONST.PENDING_REMOVE || this.state === TWEEN_CONST.REMOVED) - { - this.init(); - this.parent.makeActive(this); - resetFromTimeline = true; - } - - var onStart = this.callbacks.onStart; - - if (this.parentIsTimeline) - { - this.resetTweenData(resetFromTimeline); - - if (this.calculatedOffset === 0) - { - if (onStart) - { - onStart.params[1] = this.targets; - - onStart.func.apply(onStart.scope, onStart.params); - } - - this.state = TWEEN_CONST.ACTIVE; - } - else - { - this.countdown = this.calculatedOffset; - - this.state = TWEEN_CONST.OFFSET_DELAY; - } - } - else if (this.paused) - { - this.paused = false; - - this.parent.makeActive(this); - } - else - { - this.resetTweenData(resetFromTimeline); - - this.state = TWEEN_CONST.ACTIVE; - - if (onStart) - { - onStart.params[1] = this.targets; - - onStart.func.apply(onStart.scope, onStart.params); - } - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#resetTweenData - * @since 3.0.0 - * - * @param {boolean} resetFromLoop - [description] - */ - resetTweenData: function (resetFromLoop) - { - var data = this.data; - - for (var i = 0; i < this.totalData; i++) - { - var tweenData = data[i]; - - tweenData.progress = 0; - tweenData.elapsed = 0; - - tweenData.repeatCounter = (tweenData.repeat === -1) ? 999999999999 : tweenData.repeat; - - if (resetFromLoop) - { - tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); - - tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.end); - - tweenData.current = tweenData.start; - - tweenData.state = TWEEN_CONST.PLAYING_FORWARD; - } - else if (tweenData.delay > 0) - { - tweenData.elapsed = tweenData.delay; - tweenData.state = TWEEN_CONST.DELAY; - } - else - { - tweenData.state = TWEEN_CONST.PENDING_RENDER; - } - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#resume - * @since 3.0.0 - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - resume: function () - { - if (this.state === TWEEN_CONST.PAUSED) - { - this.paused = false; - - this.state = this._pausedState; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#seek - * @since 3.0.0 - * - * @param {float} toPosition - A value between 0 and 1. - */ - seek: function (toPosition) - { - var data = this.data; - - for (var i = 0; i < this.totalData; i++) - { - // This won't work with loop > 0 yet - var ms = this.totalDuration * toPosition; - - var tweenData = data[i]; - var progress = 0; - var elapsed = 0; - - if (ms <= tweenData.delay) - { - progress = 0; - elapsed = 0; - } - else if (ms >= tweenData.totalDuration) - { - progress = 1; - elapsed = tweenData.duration; - } - else if (ms > tweenData.delay && ms <= tweenData.t1) - { - // Keep it zero bound - ms = Math.max(0, ms - tweenData.delay); - - // Somewhere in the first playthru range - progress = ms / tweenData.t1; - elapsed = tweenData.duration * progress; - } - else if (ms > tweenData.t1 && ms < tweenData.totalDuration) - { - // Somewhere in repeat land - ms -= tweenData.delay; - ms -= tweenData.t1; - - // var repeats = Math.floor(ms / tweenData.t2); - - // remainder - ms = ((ms / tweenData.t2) % 1) * tweenData.t2; - - if (ms > tweenData.repeatDelay) - { - progress = ms / tweenData.t1; - elapsed = tweenData.duration * progress; - } - } - - tweenData.progress = progress; - tweenData.elapsed = elapsed; - - var v = tweenData.ease(tweenData.progress); - - tweenData.current = tweenData.start + ((tweenData.end - tweenData.start) * v); - - // console.log(tweenData.key, 'Seek', tweenData.target[tweenData.key], 'to', tweenData.current, 'pro', tweenData.progress, 'marker', toPosition, progress); - - // if (tweenData.current === 0) - // { - // console.log('zero', tweenData.start, tweenData.end, v, 'progress', progress); - // } - - tweenData.target[tweenData.key] = tweenData.current; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#setCallback - * @since 3.0.0 - * - * @param {string} type - [description] - * @param {function} callback - [description] - * @param {array} [params] - [description] - * @param {object} [scope] - [description] - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - setCallback: function (type, callback, params, scope) - { - this.callbacks[type] = { func: callback, scope: scope, params: params }; - - return this; - }, - - /** - * Flags the Tween as being complete, whatever stage of progress it is at. - * - * If an onComplete callback has been defined it will automatically invoke it, unless a `delay` - * argument is provided, in which case the Tween will delay for that period of time before calling the callback. - * - * If you don't need a delay, or have an onComplete callback, then call `Tween.stop` instead. - * - * @method Phaser.Tweens.Tween#complete - * @since 3.2.0 - * - * @param {number} [delay=0] - The time to wait before invoking the complete callback. If zero it will fire immediately. - */ - complete: function (delay) - { - if (delay === undefined) { delay = 0; } - - if (delay) - { - this.countdown = delay; - this.state = TWEEN_CONST.COMPLETE_DELAY; - } - else - { - var onComplete = this.callbacks.onComplete; - - if (onComplete) - { - onComplete.params[1] = this.targets; - - onComplete.func.apply(onComplete.scope, onComplete.params); - } - - this.state = TWEEN_CONST.PENDING_REMOVE; - } - }, - - /** - * Stops the Tween immediately, whatever stage of progress it is at and flags it for removal by the TweenManager. - * - * @method Phaser.Tweens.Tween#stop - * @since 3.0.0 - * - * @param {float} [resetTo] - A value between 0 and 1. - */ - stop: function (resetTo) - { - if (resetTo !== undefined) - { - this.seek(resetTo); - } - - this.state = TWEEN_CONST.PENDING_REMOVE; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#update - * @since 3.0.0 - * - * @param {number} timestamp - [description] - * @param {number} delta - [description] - * - * @return {boolean} Returns `true` if this Tween has finished and should be removed from the Tween Manager, otherwise returns `false`. - */ - update: function (timestamp, delta) - { - if (this.state === TWEEN_CONST.PAUSED) - { - return false; - } - - if (this.useFrames) - { - delta = 1 * this.parent.timeScale; - } - - delta *= this.timeScale; - - this.elapsed += delta; - this.progress = Math.min(this.elapsed / this.duration, 1); - - this.totalElapsed += delta; - this.totalProgress = Math.min(this.totalElapsed / this.totalDuration, 1); - - switch (this.state) - { - case TWEEN_CONST.ACTIVE: - - var stillRunning = false; - - for (var i = 0; i < this.totalData; i++) - { - if (this.updateTweenData(this, this.data[i], delta)) - { - stillRunning = true; - } - } - - // Anything still running? If not, we're done - if (!stillRunning) - { - this.nextState(); - } - - break; - - case TWEEN_CONST.LOOP_DELAY: - - this.countdown -= delta; - - if (this.countdown <= 0) - { - this.state = TWEEN_CONST.ACTIVE; - } - - break; - - case TWEEN_CONST.OFFSET_DELAY: - - this.countdown -= delta; - - if (this.countdown <= 0) - { - var onStart = this.callbacks.onStart; - - if (onStart) - { - onStart.params[1] = this.targets; - - onStart.func.apply(onStart.scope, onStart.params); - } - - this.state = TWEEN_CONST.ACTIVE; - } - - break; - - case TWEEN_CONST.COMPLETE_DELAY: - - this.countdown -= delta; - - if (this.countdown <= 0) - { - var onComplete = this.callbacks.onComplete; - - if (onComplete) - { - onComplete.func.apply(onComplete.scope, onComplete.params); - } - - this.state = TWEEN_CONST.PENDING_REMOVE; - } - - break; - } - - return (this.state === TWEEN_CONST.PENDING_REMOVE); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#setStateFromEnd - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * @param {Phaser.Tweens.TweenData} tweenData - [description] - * @param {number} diff - [description] - * - * @return {integer} The state of this Tween. - */ - setStateFromEnd: function (tween, tweenData, diff) - { - if (tweenData.yoyo) - { - // We've hit the end of a Playing Forward TweenData and we have a yoyo - - // Account for any extra time we got from the previous frame - tweenData.elapsed = diff; - tweenData.progress = diff / tweenData.duration; - - if (tweenData.flipX) - { - tweenData.target.toggleFlipX(); - } - - // Problem: The flip and callback and so on gets called for every TweenData that triggers it at the same time. - // If you're tweening several properties it can fire for all of them, at once. - - if (tweenData.flipY) - { - tweenData.target.toggleFlipY(); - } - - var onYoyo = tween.callbacks.onYoyo; - - if (onYoyo) - { - // Element 1 is reserved for the target of the yoyo (and needs setting here) - onYoyo.params[1] = tweenData.target; - - onYoyo.func.apply(onYoyo.scope, onYoyo.params); - } - - tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); - - return TWEEN_CONST.PLAYING_BACKWARD; - } - else if (tweenData.repeatCounter > 0) - { - // We've hit the end of a Playing Forward TweenData and we have a Repeat. - // So we're going to go right back to the start to repeat it again. - - tweenData.repeatCounter--; - - // Account for any extra time we got from the previous frame - tweenData.elapsed = diff; - tweenData.progress = diff / tweenData.duration; - - if (tweenData.flipX) - { - tweenData.target.toggleFlipX(); - } - - if (tweenData.flipY) - { - tweenData.target.toggleFlipY(); - } - - var onRepeat = tween.callbacks.onRepeat; - - if (onRepeat) - { - // Element 1 is reserved for the target of the repeat (and needs setting here) - onRepeat.params[1] = tweenData.target; - - onRepeat.func.apply(onRepeat.scope, onRepeat.params); - } - - tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); - - tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); - - // Delay? - if (tweenData.repeatDelay > 0) - { - tweenData.elapsed = tweenData.repeatDelay - diff; - - tweenData.current = tweenData.start; - - tweenData.target[tweenData.key] = tweenData.current; - - return TWEEN_CONST.REPEAT_DELAY; - } - else - { - return TWEEN_CONST.PLAYING_FORWARD; - } - } - - return TWEEN_CONST.COMPLETE; - }, - - /** - * Was PLAYING_BACKWARD and has hit the start. - * - * @method Phaser.Tweens.Tween#setStateFromStart - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * @param {Phaser.Tweens.TweenData} tweenData - [description] - * @param {number} diff - [description] - * - * @return {integer} The state of this Tween. - */ - setStateFromStart: function (tween, tweenData, diff) - { - if (tweenData.repeatCounter > 0) - { - tweenData.repeatCounter--; - - // Account for any extra time we got from the previous frame - tweenData.elapsed = diff; - tweenData.progress = diff / tweenData.duration; - - if (tweenData.flipX) - { - tweenData.target.toggleFlipX(); - } - - if (tweenData.flipY) - { - tweenData.target.toggleFlipY(); - } - - var onRepeat = tween.callbacks.onRepeat; - - if (onRepeat) - { - // Element 1 is reserved for the target of the repeat (and needs setting here) - onRepeat.params[1] = tweenData.target; - - onRepeat.func.apply(onRepeat.scope, onRepeat.params); - } - - tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); - - // Delay? - if (tweenData.repeatDelay > 0) - { - tweenData.elapsed = tweenData.repeatDelay - diff; - - tweenData.current = tweenData.start; - - tweenData.target[tweenData.key] = tweenData.current; - - return TWEEN_CONST.REPEAT_DELAY; - } - else - { - return TWEEN_CONST.PLAYING_FORWARD; - } - } - - return TWEEN_CONST.COMPLETE; - }, - - // - /** - * [description] - * - * @method Phaser.Tweens.Tween#updateTweenData - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * @param {Phaser.Tweens.TweenData} tweenData - [description] - * @param {number} delta - Either a value in ms, or 1 if Tween.useFrames is true - * - * @return {boolean} [description] - */ - updateTweenData: function (tween, tweenData, delta) - { - switch (tweenData.state) - { - case TWEEN_CONST.PLAYING_FORWARD: - case TWEEN_CONST.PLAYING_BACKWARD: - - if (!tweenData.target) - { - tweenData.state = TWEEN_CONST.COMPLETE; - break; - } - - var elapsed = tweenData.elapsed; - var duration = tweenData.duration; - var diff = 0; - - elapsed += delta; - - if (elapsed > duration) - { - diff = elapsed - duration; - elapsed = duration; - } - - var forward = (tweenData.state === TWEEN_CONST.PLAYING_FORWARD); - var progress = elapsed / duration; - - var v; - - if (forward) - { - v = tweenData.ease(progress); - } - else - { - v = tweenData.ease(1 - progress); - } - - tweenData.current = tweenData.start + ((tweenData.end - tweenData.start) * v); - - tweenData.target[tweenData.key] = tweenData.current; - - tweenData.elapsed = elapsed; - tweenData.progress = progress; - - var onUpdate = tween.callbacks.onUpdate; - - if (onUpdate) - { - onUpdate.params[1] = tweenData.target; - - onUpdate.func.apply(onUpdate.scope, onUpdate.params); - } - - if (progress === 1) - { - if (forward) - { - if (tweenData.hold > 0) - { - tweenData.elapsed = tweenData.hold - diff; - - tweenData.state = TWEEN_CONST.HOLD_DELAY; - } - else - { - tweenData.state = this.setStateFromEnd(tween, tweenData, diff); - } - } - else - { - tweenData.state = this.setStateFromStart(tween, tweenData, diff); - } - } - - break; - - case TWEEN_CONST.DELAY: - - tweenData.elapsed -= delta; - - if (tweenData.elapsed <= 0) - { - tweenData.elapsed = Math.abs(tweenData.elapsed); - - tweenData.state = TWEEN_CONST.PENDING_RENDER; - } - - break; - - case TWEEN_CONST.REPEAT_DELAY: - - tweenData.elapsed -= delta; - - if (tweenData.elapsed <= 0) - { - tweenData.elapsed = Math.abs(tweenData.elapsed); - - tweenData.state = TWEEN_CONST.PLAYING_FORWARD; - } - - break; - - case TWEEN_CONST.HOLD_DELAY: - - tweenData.elapsed -= delta; - - if (tweenData.elapsed <= 0) - { - tweenData.state = this.setStateFromEnd(tween, tweenData, Math.abs(tweenData.elapsed)); - } - - break; - - case TWEEN_CONST.PENDING_RENDER: - - if (tweenData.target) - { - tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.target[tweenData.key]); - - tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); - - tweenData.current = tweenData.start; - - tweenData.target[tweenData.key] = tweenData.start; - - tweenData.state = TWEEN_CONST.PLAYING_FORWARD; - } - else - { - tweenData.state = TWEEN_CONST.COMPLETE; - } - - break; - } - - // Return TRUE if this TweenData still playing, otherwise return FALSE - return (tweenData.state !== TWEEN_CONST.COMPLETE); + r = 1 - r; + s = 1 - s; } -}); + out.x = triangle.x1 + ((ux * r) + (vx * s)); + out.y = triangle.y1 + ((uy * r) + (vy * s)); -Tween.TYPES = [ - 'onComplete', - 'onLoop', - 'onRepeat', - 'onStart', - 'onUpdate', - 'onYoyo' -]; + return out; +}; -/** - * Creates a new Tween object. - * - * Note: This method will only be available Tweens have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#tween - * @since 3.0.0 - * - * @param {object} config - The Tween configuration. - * - * @return {Phaser.Tweens.Tween} The Tween that was created. - */ -GameObjectFactory.register('tween', function (config) -{ - return this.scene.sys.tweens.add(config); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - -/** - * Creates a new Tween object and returns it. - * - * Note: This method will only be available if Tweens have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#tween - * @since 3.0.0 - * - * @param {object} config - The Tween configuration. - * - * @return {Phaser.Tweens.Tween} The Tween that was created. - */ -GameObjectCreator.register('tween', function (config) -{ - return this.scene.sys.tweens.create(config); -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - -module.exports = Tween; +module.exports = Random; /***/ }), /* 162 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -32246,108 +33277,33 @@ module.exports = Tween; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Point = __webpack_require__(4); + /** - * [description] + * Returns a uniformly distributed random point from anywhere within the given Ellipse. * - * @function Phaser.Tweens.TweenData + * @function Phaser.Geom.Ellipse.Random * @since 3.0.0 * - * @param {object} target - [description] - * @param {string} key - [description] - * @param {function} getEnd - [description] - * @param {function} getStart - [description] - * @param {function} ease - [description] - * @param {number} delay - [description] - * @param {number} duration - [description] - * @param {boolean} yoyo - [description] - * @param {number} hold - [description] - * @param {number} repeat - [description] - * @param {number} repeatDelay - [description] - * @param {boolean} flipX - [description] - * @param {boolean} flipY - [description] + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get a random point from. + * @param {(Phaser.Geom.Point|object)} [point] - A Point or point-like object to set the random `x` and `y` values in. * - * @return {Phaser.Tweens.TweenData} [description] + * @return {(Phaser.Geom.Point|object)} A Point object with the random values set in the `x` and `y` properties. */ -var TweenData = function (target, key, getEnd, getStart, ease, delay, duration, yoyo, hold, repeat, repeatDelay, flipX, flipY) +var Random = function (ellipse, out) { - return { + if (out === undefined) { out = new Point(); } - // The target to tween - target: target, + var p = Math.random() * Math.PI * 2; + var s = Math.sqrt(Math.random()); - // The property of the target to tween - key: key, + out.x = ellipse.x + ((s * Math.cos(p)) * ellipse.width / 2); + out.y = ellipse.y + ((s * Math.sin(p)) * ellipse.height / 2); - // The returned value sets what the property will be at the END of the Tween. - getEndValue: getEnd, - - // The returned value sets what the property will be at the START of the Tween. - getStartValue: getStart, - - // The ease function this tween uses. - ease: ease, - - // Duration of the tween in ms/frames, excludes time for yoyo or repeats. - duration: 0, - - // The total calculated duration of this TweenData (based on duration, repeat, delay and yoyo) - totalDuration: 0, - - // Time in ms/frames before tween will start. - delay: 0, - - // Cause the tween to return back to its start value after hold has expired. - yoyo: yoyo, - - // Time in ms/frames the tween will pause before running the yoyo or starting a repeat. - hold: 0, - - // Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. - repeat: 0, - - // Time in ms/frames before the repeat will start. - repeatDelay: 0, - - // Automatically call toggleFlipX when the TweenData yoyos or repeats - flipX: flipX, - - // Automatically call toggleFlipY when the TweenData yoyos or repeats - flipY: flipY, - - // Between 0 and 1 showing completion of this TweenData. - progress: 0, - - // Delta counter. - elapsed: 0, - - // How many repeats are left to run? - repeatCounter: 0, - - // Ease Value Data: - - start: 0, - current: 0, - end: 0, - - // Time Durations - t1: 0, - t2: 0, - - // LoadValue generation functions - gen: { - delay: delay, - duration: duration, - hold: hold, - repeat: repeat, - repeatDelay: repeatDelay - }, - - // TWEEN_CONST.CREATED - state: 0 - }; + return out; }; -module.exports = TweenData; +module.exports = Random; /***/ }), @@ -32360,24 +33316,30 @@ module.exports = TweenData; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var MathWrap = __webpack_require__(50); +var Point = __webpack_require__(4); /** * [description] * - * @function Phaser.Math.Angle.Wrap + * @function Phaser.Geom.Rectangle.Random * @since 3.0.0 * - * @param {number} angle - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Point} out - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Point} [description] */ -var Wrap = function (angle) +var Random = function (rect, out) { - return MathWrap(angle, -Math.PI, Math.PI); + if (out === undefined) { out = new Point(); } + + out.x = rect.x + (Math.random() * rect.width); + out.y = rect.y + (Math.random() * rect.height); + + return out; }; -module.exports = Wrap; +module.exports = Random; /***/ }), @@ -32390,24 +33352,32 @@ module.exports = Wrap; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Wrap = __webpack_require__(50); +var Point = __webpack_require__(4); /** * [description] * - * @function Phaser.Math.Angle.WrapDegrees + * @function Phaser.Geom.Line.Random * @since 3.0.0 * - * @param {number} angle - [description] + * @param {Phaser.Geom.Line} line - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] * - * @return {number} [description] + * @return {(Phaser.Geom.Point|object)} [description] */ -var WrapDegrees = function (angle) +var Random = function (line, out) { - return Wrap(angle, -180, 180); + if (out === undefined) { out = new Point(); } + + var t = Math.random(); + + out.x = line.x1 + t * (line.x2 - line.x1); + out.y = line.y1 + t * (line.y2 - line.y1); + + return out; }; -module.exports = WrapDegrees; +module.exports = Random; /***/ }), @@ -32420,402 +33390,348 @@ module.exports = WrapDegrees; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var ShaderSourceFS = __webpack_require__(515); -var TextureTintPipeline = __webpack_require__(166); - -var LIGHT_COUNT = 10; +var Length = __webpack_require__(77); +var Point = __webpack_require__(4); /** - * @classdesc * [description] * - * @class ForwardDiffuseLightPipeline - * @extends Phaser.Renderer.WebGL.TextureTintPipeline - * @memberOf Phaser.Renderer.WebGL - * @constructor + * @function Phaser.Geom.Line.GetPoints * @since 3.0.0 * - * @param {object} config - [description] + * @param {Phaser.Geom.Line} line - [description] + * @param {integer} quantity - [description] + * @param {integer} [stepRate] - [description] + * @param {array} out - [description] + * + * @return {array} [description] */ -var ForwardDiffuseLightPipeline = new Class({ +var GetPoints = function (line, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } - Extends: TextureTintPipeline, - - initialize: - - function ForwardDiffuseLightPipeline (config) + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) { - config.fragShader = ShaderSourceFS.replace('%LIGHT_COUNT%', LIGHT_COUNT.toString()); - - TextureTintPipeline.call(this, config); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#onBind - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline} [description] - */ - onBind: function () - { - TextureTintPipeline.prototype.onBind.call(this); - - var renderer = this.renderer; - var program = this.program; - - this.mvpUpdate(); - - renderer.setInt1(program, 'uNormSampler', 1); - renderer.setFloat2(program, 'uResolution', this.width, this.height); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#onRender - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - * @return {Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline} [description] - */ - onRender: function (scene, camera) - { - var lightManager = scene.sys.lights; - - if (!lightManager) - { - return this; - } - - lightManager.culledLights.length = 0; - - if (lightManager.lights.length <= 0 || !lightManager.active) - { - return this; // If not visible lights just passthrough - } - - var renderer = this.renderer; - var program = this.program; - var lights = lightManager.cull(camera); - var lightCount = Math.min(lights.length, LIGHT_COUNT); - var cameraMatrix = camera.matrix; - var point = {x: 0, y: 0}; - var height = renderer.height; - var index; - - for (index = 0; index < LIGHT_COUNT; ++index) - { - renderer.setFloat1(program, 'uLights[' + index + '].radius', 0); // reset lights - } - - if (lightCount <= 0) { return this; } - - renderer.setFloat4(program, 'uCamera', camera.x, camera.y, camera.rotation, camera.zoom); - renderer.setFloat3(program, 'uAmbientLightColor', lightManager.ambientColor.r, lightManager.ambientColor.g, lightManager.ambientColor.b); - - for (index = 0; index < lightCount; ++index) - { - var light = lights[index]; - var lightName = 'uLights[' + index + '].'; - cameraMatrix.transformPoint(light.x, light.y, point); - renderer.setFloat2(program, lightName + 'position', point.x - (camera.scrollX * light.scrollFactorX * camera.zoom), height - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom)); - renderer.setFloat3(program, lightName + 'color', light.r, light.g, light.b); - renderer.setFloat1(program, lightName + 'intensity', light.intensity); - renderer.setFloat1(program, lightName + 'radius', light.radius); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#drawStaticTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.StaticTilemapLayer} tilemap - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - */ - drawStaticTilemapLayer: function (tilemap, camera) - { - var normalTexture = tilemap.texture.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.drawStaticTilemapLayer.call(this, tilemap, camera); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. StaticTilemapLayer rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.drawStaticTilemapLayer(tilemap, camera); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#drawEmitterManager - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - */ - drawEmitterManager: function (emitterManager, camera) - { - var normalTexture = emitterManager.texture.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.drawEmitterManager.call(this, emitterManager, camera); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. EmitterManager rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.drawEmitterManager(emitterManager, camera); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#drawBlitter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter} blitter - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - */ - drawBlitter: function (blitter, camera) - { - var normalTexture = blitter.texture.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.drawBlitter.call(this, blitter, camera); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. Blitter rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.drawBlitter(blitter, camera); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Sprite} sprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - */ - batchSprite: function (sprite, camera) - { - var normalTexture = sprite.texture.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchSprite.call(this, sprite, camera); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. Sprite rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchSprite(sprite, camera); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchMesh - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Mesh} mesh - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - */ - batchMesh: function (mesh, camera) - { - var normalTexture = mesh.texture.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchMesh.call(this, mesh, camera); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. Mesh rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchMesh(mesh, camera); - - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.BitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - */ - batchBitmapText: function (bitmapText, camera) - { - var normalTexture = bitmapText.texture.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchBitmapText.call(this, bitmapText, camera); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. BitmapText rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchBitmapText(bitmapText, camera); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchDynamicBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.DynamicBitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - */ - batchDynamicBitmapText: function (bitmapText, camera) - { - var normalTexture = bitmapText.texture.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchDynamicBitmapText.call(this, bitmapText, camera); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. DynamicBitmapText rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchDynamicBitmapText(bitmapText, camera); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Text} text - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - */ - batchText: function (text, camera) - { - var normalTexture = text.texture.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchText.call(this, text, camera); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. Text rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchText(text, camera); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchDynamicTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.DynamicTilemapLayer} tilemapLayer - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - */ - batchDynamicTilemapLayer: function (tilemapLayer, camera) - { - var normalTexture = tilemapLayer.texture.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchDynamicTilemapLayer.call(this, tilemapLayer, camera); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. DynamicTilemapLayer rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchDynamicTilemapLayer(tilemapLayer, camera); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchTileSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.TileSprite} tileSprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - */ - batchTileSprite: function (tileSprite, camera) - { - var normalTexture = tileSprite.texture.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchTileSprite.call(this, tileSprite, camera); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. TileSprite rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchTileSprite(tileSprite, camera); - } + quantity = Length(line) / stepRate; } -}); + var x1 = line.x1; + var y1 = line.y1; -ForwardDiffuseLightPipeline.LIGHT_COUNT = LIGHT_COUNT; + var x2 = line.x2; + var y2 = line.y2; -module.exports = ForwardDiffuseLightPipeline; + for (var i = 0; i < quantity; i++) + { + var position = i / quantity; + + var x = x1 + (x2 - x1) * position; + var y = y1 + (y2 - y1) * position; + + out.push(new Point(x, y)); + } + + return out; +}; + +module.exports = GetPoints; /***/ }), /* 166 */ /***/ (function(module, exports, __webpack_require__) { +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Perimeter = __webpack_require__(105); +var Point = __webpack_require__(4); + +/** + * Position is a value between 0 and 1 where 0 = the top-left of the rectangle and 0.5 = the bottom right. + * + * @function Phaser.Geom.Rectangle.GetPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rectangle - [description] + * @param {float} position - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var GetPoint = function (rectangle, position, out) +{ + if (out === undefined) { out = new Point(); } + + if (position <= 0 || position >= 1) + { + out.x = rectangle.x; + out.y = rectangle.y; + + return out; + } + + var p = Perimeter(rectangle) * position; + + if (position > 0.5) + { + p -= (rectangle.width + rectangle.height); + + if (p <= rectangle.width) + { + // Face 3 + out.x = rectangle.right - p; + out.y = rectangle.bottom; + } + else + { + // Face 4 + out.x = rectangle.x; + out.y = rectangle.bottom - (p - rectangle.width); + } + } + else if (p <= rectangle.width) + { + // Face 1 + out.x = rectangle.x + p; + out.y = rectangle.y; + } + else + { + // Face 2 + out.x = rectangle.right; + out.y = rectangle.y + (p - rectangle.width); + } + + return out; +}; + +module.exports = GetPoint; + + +/***/ }), +/* 167 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +/** + * Returns a uniformly distributed random point from anywhere within the given Circle. + * + * @function Phaser.Geom.Circle.Random + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to get a random point from. + * @param {(Phaser.Geom.Point|object)} [point] - A Point or point-like object to set the random `x` and `y` values in. + * + * @return {(Phaser.Geom.Point|object)} A Point object with the random values set in the `x` and `y` properties. + */ +var Random = function (circle, out) +{ + if (out === undefined) { out = new Point(); } + + var t = 2 * Math.PI * Math.random(); + var u = Math.random() + Math.random(); + var r = (u > 1) ? 2 - u : u; + var x = r * Math.cos(t); + var y = r * Math.sin(t); + + out.x = circle.x + (x * circle.radius); + out.y = circle.y + (y * circle.radius); + + return out; +}; + +module.exports = Random; + + +/***/ }), +/* 168 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +/** + * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle. + * + * @function Phaser.Geom.Circle.CircumferencePoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on. + * @param {number} angle - The angle from the center of the Circle to the circumference to return the point from. Given in radians. + * @param {(Phaser.Geom.Point|object)} [out] - A Point, or point-like object, to store the results in. If not given a Point will be created. + * + * @return {(Phaser.Geom.Point|object)} A Point object where the `x` and `y` properties are the point on the circumference. + */ +var CircumferencePoint = function (circle, angle, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = circle.x + (circle.radius * Math.cos(angle)); + out.y = circle.y + (circle.radius * Math.sin(angle)); + + return out; +}; + +module.exports = CircumferencePoint; + + +/***/ }), +/* 169 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ALIGN_CONST = { + + /** + * A constant representing a top-left alignment or position. + * @constant + * @name Phaser.Display.Align.TOP_LEFT + * @since 3.0.0 + * @type {integer} + */ + TOP_LEFT: 0, + + /** + * A constant representing a top-center alignment or position. + * @constant + * @name Phaser.Display.Align.TOP_CENTER + * @since 3.0.0 + * @type {integer} + */ + TOP_CENTER: 1, + + /** + * A constant representing a top-right alignment or position. + * @constant + * @name Phaser.Display.Align.TOP_RIGHT + * @since 3.0.0 + * @type {integer} + */ + TOP_RIGHT: 2, + + /** + * A constant representing a left-top alignment or position. + * @constant + * @name Phaser.Display.Align.LEFT_TOP + * @since 3.0.0 + * @type {integer} + */ + LEFT_TOP: 3, + + /** + * A constant representing a left-center alignment or position. + * @constant + * @name Phaser.Display.Align.LEFT_CENTER + * @since 3.0.0 + * @type {integer} + */ + LEFT_CENTER: 4, + + /** + * A constant representing a left-bottom alignment or position. + * @constant + * @name Phaser.Display.Align.LEFT_BOTTOM + * @since 3.0.0 + * @type {integer} + */ + LEFT_BOTTOM: 5, + + /** + * A constant representing a center alignment or position. + * @constant + * @name Phaser.Display.Align.CENTER + * @since 3.0.0 + * @type {integer} + */ + CENTER: 6, + + /** + * A constant representing a right-top alignment or position. + * @constant + * @name Phaser.Display.Align.RIGHT_TOP + * @since 3.0.0 + * @type {integer} + */ + RIGHT_TOP: 7, + + /** + * A constant representing a right-center alignment or position. + * @constant + * @name Phaser.Display.Align.RIGHT_CENTER + * @since 3.0.0 + * @type {integer} + */ + RIGHT_CENTER: 8, + + /** + * A constant representing a right-bottom alignment or position. + * @constant + * @name Phaser.Display.Align.RIGHT_BOTTOM + * @since 3.0.0 + * @type {integer} + */ + RIGHT_BOTTOM: 9, + + /** + * A constant representing a bottom-left alignment or position. + * @constant + * @name Phaser.Display.Align.BOTTOM_LEFT + * @since 3.0.0 + * @type {integer} + */ + BOTTOM_LEFT: 10, + + /** + * A constant representing a bottom-center alignment or position. + * @constant + * @name Phaser.Display.Align.BOTTOM_CENTER + * @since 3.0.0 + * @type {integer} + */ + BOTTOM_CENTER: 11, + + /** + * A constant representing a bottom-right alignment or position. + * @constant + * @name Phaser.Display.Align.BOTTOM_RIGHT + * @since 3.0.0 + * @type {integer} + */ + BOTTOM_RIGHT: 12 + +}; + +module.exports = ALIGN_CONST; + + +/***/ }), +/* 170 */, +/* 171 */, +/* 172 */ +/***/ (function(module, exports, __webpack_require__) { + /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. @@ -32823,11 +33739,11 @@ module.exports = ForwardDiffuseLightPipeline; */ var Class = __webpack_require__(0); -var ModelViewProjection = __webpack_require__(239); -var ShaderSourceFS = __webpack_require__(516); -var ShaderSourceVS = __webpack_require__(517); -var Utils = __webpack_require__(41); -var WebGLPipeline = __webpack_require__(103); +var ModelViewProjection = __webpack_require__(300); +var ShaderSourceFS = __webpack_require__(811); +var ShaderSourceVS = __webpack_require__(810); +var Utils = __webpack_require__(44); +var WebGLPipeline = __webpack_require__(108); /** * @classdesc @@ -34645,37 +35561,8 @@ module.exports = TextureTintPipeline; /***/ }), -/* 167 */, -/* 168 */, -/* 169 */ -/***/ (function(module, exports) { - -var g; - -// This works in non-strict mode -g = (function() { - return this; -})(); - -try { - // This works if eval is allowed (see CSP) - g = g || Function("return this")() || (1,eval)("this"); -} catch(e) { - // This works if the window reference is available - if(typeof window === "object") - g = window; -} - -// g can still be undefined, but nothing to do about it... -// We return undefined, instead of nothing here, so it's -// easier to handle this case. if(!global) { ...} - -module.exports = g; - - -/***/ }), -/* 170 */ -/***/ (function(module, exports) { +/* 173 */ +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -34683,296 +35570,396 @@ module.exports = g; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var ShaderSourceFS = __webpack_require__(812); +var TextureTintPipeline = __webpack_require__(172); + +var LIGHT_COUNT = 10; + /** - * This is a slightly modified version of jQuery.isPlainObject. - * A plain object is an object whose internal class property is [object Object]. + * @classdesc + * [description] * - * @function Phaser.Utils.Object.IsPlainObject + * @class ForwardDiffuseLightPipeline + * @extends Phaser.Renderer.WebGL.TextureTintPipeline + * @memberOf Phaser.Renderer.WebGL + * @constructor * @since 3.0.0 * - * @param {object} obj - The object to inspect. - * - * @return {boolean} `true` if the object is plain, otherwise `false`. + * @param {object} config - [description] */ -var IsPlainObject = function (obj) -{ - // Not plain objects: - // - Any object or value whose internal [[Class]] property is not "[object Object]" - // - DOM nodes - // - window - if (typeof(obj) !== 'object' || obj.nodeType || obj === obj.window) - { - return false; - } +var ForwardDiffuseLightPipeline = new Class({ - // Support: Firefox <20 - // The try/catch suppresses exceptions thrown when attempting to access - // the "constructor" property of certain host objects, ie. |window.location| - // https://bugzilla.mozilla.org/show_bug.cgi?id=814622 - try + Extends: TextureTintPipeline, + + initialize: + + function ForwardDiffuseLightPipeline (config) { - if (obj.constructor && !({}).hasOwnProperty.call(obj.constructor.prototype, 'isPrototypeOf')) + config.fragShader = ShaderSourceFS.replace('%LIGHT_COUNT%', LIGHT_COUNT.toString()); + + TextureTintPipeline.call(this, config); + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#onBind + * @since 3.0.0 + * + * @return {Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline} [description] + */ + onBind: function () + { + TextureTintPipeline.prototype.onBind.call(this); + + var renderer = this.renderer; + var program = this.program; + + this.mvpUpdate(); + + renderer.setInt1(program, 'uNormSampler', 1); + renderer.setFloat2(program, 'uResolution', this.width, this.height); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#onRender + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + * @return {Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline} [description] + */ + onRender: function (scene, camera) + { + var lightManager = scene.sys.lights; + + if (!lightManager) { - return false; + return this; + } + + lightManager.culledLights.length = 0; + + if (lightManager.lights.length <= 0 || !lightManager.active) + { + return this; // If not visible lights just passthrough + } + + var renderer = this.renderer; + var program = this.program; + var lights = lightManager.cull(camera); + var lightCount = Math.min(lights.length, LIGHT_COUNT); + var cameraMatrix = camera.matrix; + var point = {x: 0, y: 0}; + var height = renderer.height; + var index; + + for (index = 0; index < LIGHT_COUNT; ++index) + { + renderer.setFloat1(program, 'uLights[' + index + '].radius', 0); // reset lights + } + + if (lightCount <= 0) { return this; } + + renderer.setFloat4(program, 'uCamera', camera.x, camera.y, camera.rotation, camera.zoom); + renderer.setFloat3(program, 'uAmbientLightColor', lightManager.ambientColor.r, lightManager.ambientColor.g, lightManager.ambientColor.b); + + for (index = 0; index < lightCount; ++index) + { + var light = lights[index]; + var lightName = 'uLights[' + index + '].'; + cameraMatrix.transformPoint(light.x, light.y, point); + renderer.setFloat2(program, lightName + 'position', point.x - (camera.scrollX * light.scrollFactorX * camera.zoom), height - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom)); + renderer.setFloat3(program, lightName + 'color', light.r, light.g, light.b); + renderer.setFloat1(program, lightName + 'intensity', light.intensity); + renderer.setFloat1(program, lightName + 'radius', light.radius); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#drawStaticTilemapLayer + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.StaticTilemapLayer} tilemap - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + */ + drawStaticTilemapLayer: function (tilemap, camera) + { + var normalTexture = tilemap.texture.dataSource[0]; + + if (normalTexture) + { + this.renderer.setPipeline(this); + this.setTexture2D(normalTexture.glTexture, 1); + TextureTintPipeline.prototype.drawStaticTilemapLayer.call(this, tilemap, camera); + } + else + { + console.warn('Normal map texture missing for using Light2D pipeline. StaticTilemapLayer rendered with default pipeline.'); + this.renderer.pipelines.TextureTintPipeline.drawStaticTilemapLayer(tilemap, camera); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#drawEmitterManager + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + */ + drawEmitterManager: function (emitterManager, camera) + { + var normalTexture = emitterManager.texture.dataSource[0]; + + if (normalTexture) + { + this.renderer.setPipeline(this); + this.setTexture2D(normalTexture.glTexture, 1); + TextureTintPipeline.prototype.drawEmitterManager.call(this, emitterManager, camera); + } + else + { + console.warn('Normal map texture missing for using Light2D pipeline. EmitterManager rendered with default pipeline.'); + this.renderer.pipelines.TextureTintPipeline.drawEmitterManager(emitterManager, camera); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#drawBlitter + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Blitter} blitter - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + */ + drawBlitter: function (blitter, camera) + { + var normalTexture = blitter.texture.dataSource[0]; + + if (normalTexture) + { + this.renderer.setPipeline(this); + this.setTexture2D(normalTexture.glTexture, 1); + TextureTintPipeline.prototype.drawBlitter.call(this, blitter, camera); + } + else + { + console.warn('Normal map texture missing for using Light2D pipeline. Blitter rendered with default pipeline.'); + this.renderer.pipelines.TextureTintPipeline.drawBlitter(blitter, camera); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchSprite + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Sprite} sprite - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + */ + batchSprite: function (sprite, camera) + { + var normalTexture = sprite.texture.dataSource[0]; + + if (normalTexture) + { + this.renderer.setPipeline(this); + this.setTexture2D(normalTexture.glTexture, 1); + TextureTintPipeline.prototype.batchSprite.call(this, sprite, camera); + } + else + { + console.warn('Normal map texture missing for using Light2D pipeline. Sprite rendered with default pipeline.'); + this.renderer.pipelines.TextureTintPipeline.batchSprite(sprite, camera); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchMesh + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Mesh} mesh - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + */ + batchMesh: function (mesh, camera) + { + var normalTexture = mesh.texture.dataSource[0]; + + if (normalTexture) + { + this.renderer.setPipeline(this); + this.setTexture2D(normalTexture.glTexture, 1); + TextureTintPipeline.prototype.batchMesh.call(this, mesh, camera); + } + else + { + console.warn('Normal map texture missing for using Light2D pipeline. Mesh rendered with default pipeline.'); + this.renderer.pipelines.TextureTintPipeline.batchMesh(mesh, camera); + + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchBitmapText + * @since 3.0.0 + * + * @param {Phaser.GameObjects.BitmapText} bitmapText - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + */ + batchBitmapText: function (bitmapText, camera) + { + var normalTexture = bitmapText.texture.dataSource[0]; + + if (normalTexture) + { + this.renderer.setPipeline(this); + this.setTexture2D(normalTexture.glTexture, 1); + TextureTintPipeline.prototype.batchBitmapText.call(this, bitmapText, camera); + } + else + { + console.warn('Normal map texture missing for using Light2D pipeline. BitmapText rendered with default pipeline.'); + this.renderer.pipelines.TextureTintPipeline.batchBitmapText(bitmapText, camera); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchDynamicBitmapText + * @since 3.0.0 + * + * @param {Phaser.GameObjects.DynamicBitmapText} bitmapText - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + */ + batchDynamicBitmapText: function (bitmapText, camera) + { + var normalTexture = bitmapText.texture.dataSource[0]; + + if (normalTexture) + { + this.renderer.setPipeline(this); + this.setTexture2D(normalTexture.glTexture, 1); + TextureTintPipeline.prototype.batchDynamicBitmapText.call(this, bitmapText, camera); + } + else + { + console.warn('Normal map texture missing for using Light2D pipeline. DynamicBitmapText rendered with default pipeline.'); + this.renderer.pipelines.TextureTintPipeline.batchDynamicBitmapText(bitmapText, camera); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchText + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Text} text - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + */ + batchText: function (text, camera) + { + var normalTexture = text.texture.dataSource[0]; + + if (normalTexture) + { + this.renderer.setPipeline(this); + this.setTexture2D(normalTexture.glTexture, 1); + TextureTintPipeline.prototype.batchText.call(this, text, camera); + } + else + { + console.warn('Normal map texture missing for using Light2D pipeline. Text rendered with default pipeline.'); + this.renderer.pipelines.TextureTintPipeline.batchText(text, camera); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchDynamicTilemapLayer + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.DynamicTilemapLayer} tilemapLayer - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + */ + batchDynamicTilemapLayer: function (tilemapLayer, camera) + { + var normalTexture = tilemapLayer.texture.dataSource[0]; + + if (normalTexture) + { + this.renderer.setPipeline(this); + this.setTexture2D(normalTexture.glTexture, 1); + TextureTintPipeline.prototype.batchDynamicTilemapLayer.call(this, tilemapLayer, camera); + } + else + { + console.warn('Normal map texture missing for using Light2D pipeline. DynamicTilemapLayer rendered with default pipeline.'); + this.renderer.pipelines.TextureTintPipeline.batchDynamicTilemapLayer(tilemapLayer, camera); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchTileSprite + * @since 3.0.0 + * + * @param {Phaser.GameObjects.TileSprite} tileSprite - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + */ + batchTileSprite: function (tileSprite, camera) + { + var normalTexture = tileSprite.texture.dataSource[0]; + + if (normalTexture) + { + this.renderer.setPipeline(this); + this.setTexture2D(normalTexture.glTexture, 1); + TextureTintPipeline.prototype.batchTileSprite.call(this, tileSprite, camera); + } + else + { + console.warn('Normal map texture missing for using Light2D pipeline. TileSprite rendered with default pipeline.'); + this.renderer.pipelines.TextureTintPipeline.batchTileSprite(tileSprite, camera); } } - catch (e) - { - return false; - } - // If the function hasn't returned already, we're confident that - // |obj| is a plain object, created by {} or constructed with new Object - return true; -}; +}); -module.exports = IsPlainObject; +ForwardDiffuseLightPipeline.LIGHT_COUNT = LIGHT_COUNT; - -/***/ }), -/* 171 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Actions - */ - -module.exports = { - - Angle: __webpack_require__(386), - Call: __webpack_require__(387), - GetFirst: __webpack_require__(388), - GridAlign: __webpack_require__(389), - IncAlpha: __webpack_require__(407), - IncX: __webpack_require__(408), - IncXY: __webpack_require__(409), - IncY: __webpack_require__(410), - PlaceOnCircle: __webpack_require__(411), - PlaceOnEllipse: __webpack_require__(412), - PlaceOnLine: __webpack_require__(413), - PlaceOnRectangle: __webpack_require__(414), - PlaceOnTriangle: __webpack_require__(415), - PlayAnimation: __webpack_require__(416), - RandomCircle: __webpack_require__(417), - RandomEllipse: __webpack_require__(418), - RandomLine: __webpack_require__(419), - RandomRectangle: __webpack_require__(420), - RandomTriangle: __webpack_require__(421), - Rotate: __webpack_require__(422), - RotateAround: __webpack_require__(423), - RotateAroundDistance: __webpack_require__(424), - ScaleX: __webpack_require__(425), - ScaleXY: __webpack_require__(426), - ScaleY: __webpack_require__(427), - SetAlpha: __webpack_require__(428), - SetBlendMode: __webpack_require__(429), - SetDepth: __webpack_require__(430), - SetHitArea: __webpack_require__(431), - SetOrigin: __webpack_require__(432), - SetRotation: __webpack_require__(433), - SetScale: __webpack_require__(434), - SetScaleX: __webpack_require__(435), - SetScaleY: __webpack_require__(436), - SetTint: __webpack_require__(437), - SetVisible: __webpack_require__(438), - SetX: __webpack_require__(439), - SetXY: __webpack_require__(440), - SetY: __webpack_require__(441), - ShiftPosition: __webpack_require__(442), - Shuffle: __webpack_require__(443), - SmootherStep: __webpack_require__(444), - SmoothStep: __webpack_require__(445), - Spread: __webpack_require__(446), - ToggleVisible: __webpack_require__(447) - -}; - - -/***/ }), -/* 172 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ALIGN_CONST = __webpack_require__(173); - -var AlignInMap = []; - -AlignInMap[ALIGN_CONST.BOTTOM_CENTER] = __webpack_require__(174); -AlignInMap[ALIGN_CONST.BOTTOM_LEFT] = __webpack_require__(175); -AlignInMap[ALIGN_CONST.BOTTOM_RIGHT] = __webpack_require__(176); -AlignInMap[ALIGN_CONST.CENTER] = __webpack_require__(177); -AlignInMap[ALIGN_CONST.LEFT_CENTER] = __webpack_require__(179); -AlignInMap[ALIGN_CONST.RIGHT_CENTER] = __webpack_require__(180); -AlignInMap[ALIGN_CONST.TOP_CENTER] = __webpack_require__(181); -AlignInMap[ALIGN_CONST.TOP_LEFT] = __webpack_require__(182); -AlignInMap[ALIGN_CONST.TOP_RIGHT] = __webpack_require__(183); - -/** - * Takes given Game Object and aligns it so that it is positioned relative to the other. - * The alignment used is based on the `position` argument, which is an `ALIGN_CONST` value, such as `LEFT_CENTER` or `TOP_RIGHT`. - * - * @function Phaser.Display.Align.In.QuickSet - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {integer} position - The position to align the Game Object with. This is an align constant, such as `ALIGN_CONST.LEFT_CENTER`. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var QuickSet = function (child, alignIn, position, offsetX, offsetY) -{ - return AlignInMap[position](child, alignIn, offsetX, offsetY); -}; - -module.exports = QuickSet; - - -/***/ }), -/* 173 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ALIGN_CONST = { - - /** - * A constant representing a top-left alignment or position. - * @constant - * @name Phaser.Display.Align.TOP_LEFT - * @since 3.0.0 - * @type {integer} - */ - TOP_LEFT: 0, - - /** - * A constant representing a top-center alignment or position. - * @constant - * @name Phaser.Display.Align.TOP_CENTER - * @since 3.0.0 - * @type {integer} - */ - TOP_CENTER: 1, - - /** - * A constant representing a top-right alignment or position. - * @constant - * @name Phaser.Display.Align.TOP_RIGHT - * @since 3.0.0 - * @type {integer} - */ - TOP_RIGHT: 2, - - /** - * A constant representing a left-top alignment or position. - * @constant - * @name Phaser.Display.Align.LEFT_TOP - * @since 3.0.0 - * @type {integer} - */ - LEFT_TOP: 3, - - /** - * A constant representing a left-center alignment or position. - * @constant - * @name Phaser.Display.Align.LEFT_CENTER - * @since 3.0.0 - * @type {integer} - */ - LEFT_CENTER: 4, - - /** - * A constant representing a left-bottom alignment or position. - * @constant - * @name Phaser.Display.Align.LEFT_BOTTOM - * @since 3.0.0 - * @type {integer} - */ - LEFT_BOTTOM: 5, - - /** - * A constant representing a center alignment or position. - * @constant - * @name Phaser.Display.Align.CENTER - * @since 3.0.0 - * @type {integer} - */ - CENTER: 6, - - /** - * A constant representing a right-top alignment or position. - * @constant - * @name Phaser.Display.Align.RIGHT_TOP - * @since 3.0.0 - * @type {integer} - */ - RIGHT_TOP: 7, - - /** - * A constant representing a right-center alignment or position. - * @constant - * @name Phaser.Display.Align.RIGHT_CENTER - * @since 3.0.0 - * @type {integer} - */ - RIGHT_CENTER: 8, - - /** - * A constant representing a right-bottom alignment or position. - * @constant - * @name Phaser.Display.Align.RIGHT_BOTTOM - * @since 3.0.0 - * @type {integer} - */ - RIGHT_BOTTOM: 9, - - /** - * A constant representing a bottom-left alignment or position. - * @constant - * @name Phaser.Display.Align.BOTTOM_LEFT - * @since 3.0.0 - * @type {integer} - */ - BOTTOM_LEFT: 10, - - /** - * A constant representing a bottom-center alignment or position. - * @constant - * @name Phaser.Display.Align.BOTTOM_CENTER - * @since 3.0.0 - * @type {integer} - */ - BOTTOM_CENTER: 11, - - /** - * A constant representing a bottom-right alignment or position. - * @constant - * @name Phaser.Display.Align.BOTTOM_RIGHT - * @since 3.0.0 - * @type {integer} - */ - BOTTOM_RIGHT: 12 - -}; - -module.exports = ALIGN_CONST; +module.exports = ForwardDiffuseLightPipeline; /***/ }), @@ -34985,36 +35972,24 @@ module.exports = ALIGN_CONST; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetBottom = __webpack_require__(24); -var GetCenterX = __webpack_require__(46); -var SetBottom = __webpack_require__(25); -var SetCenterX = __webpack_require__(47); +var Wrap = __webpack_require__(43); /** - * Takes given Game Object and aligns it so that it is positioned in the bottom center of the other. + * [description] * - * @function Phaser.Display.Align.In.BottomCenter + * @function Phaser.Math.Angle.WrapDegrees * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. + * @param {number} angle - [description] * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + * @return {number} [description] */ -var BottomCenter = function (gameObject, alignIn, offsetX, offsetY) +var WrapDegrees = function (angle) { - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetCenterX(gameObject, GetCenterX(alignIn) + offsetX); - SetBottom(gameObject, GetBottom(alignIn) + offsetY); - - return gameObject; + return Wrap(angle, -180, 180); }; -module.exports = BottomCenter; +module.exports = WrapDegrees; /***/ }), @@ -35027,41 +36002,29 @@ module.exports = BottomCenter; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetBottom = __webpack_require__(24); -var GetLeft = __webpack_require__(26); -var SetBottom = __webpack_require__(25); -var SetLeft = __webpack_require__(27); +var MathWrap = __webpack_require__(43); /** - * Takes given Game Object and aligns it so that it is positioned in the bottom left of the other. + * [description] * - * @function Phaser.Display.Align.In.BottomLeft + * @function Phaser.Math.Angle.Wrap * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. + * @param {number} angle - [description] * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + * @return {number} [description] */ -var BottomLeft = function (gameObject, alignIn, offsetX, offsetY) +var Wrap = function (angle) { - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetLeft(alignIn) - offsetX); - SetBottom(gameObject, GetBottom(alignIn) + offsetY); - - return gameObject; + return MathWrap(angle, -Math.PI, Math.PI); }; -module.exports = BottomLeft; +module.exports = Wrap; /***/ }), /* 176 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -35069,41 +36032,46 @@ module.exports = BottomLeft; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetBottom = __webpack_require__(24); -var GetRight = __webpack_require__(28); -var SetBottom = __webpack_require__(25); -var SetRight = __webpack_require__(29); +// Based on code by Mike Reinstein /** - * Takes given Game Object and aligns it so that it is positioned in the bottom right of the other. + * Removes a single item from an array and returns it without creating gc (like the native splice does) * - * @function Phaser.Display.Align.In.BottomRight + * @function Phaser.Utils.Array.SpliceOne * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. + * @param {array} array - [description] + * @param {integer} index - [description] * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + * @return {*} [description] */ -var BottomRight = function (gameObject, alignIn, offsetX, offsetY) +var SpliceOne = function (array, index) { - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } + if (index >= array.length) + { + return; + } - SetRight(gameObject, GetRight(alignIn) + offsetX); - SetBottom(gameObject, GetBottom(alignIn) + offsetY); + var len = array.length - 1; - return gameObject; + var item = array[index]; + + for (var i = index; i < len; i++) + { + array[i] = array[i + 1]; + } + + array.length = len; + + return item; }; -module.exports = BottomRight; +module.exports = SpliceOne; /***/ }), /* 177 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -35111,34 +36079,40 @@ module.exports = BottomRight; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CenterOn = __webpack_require__(178); -var GetCenterX = __webpack_require__(46); -var GetCenterY = __webpack_require__(49); +// Transposes the elements of the given matrix (array of arrays). +// The transpose of a matrix is a new matrix whose rows are the columns of the original. /** - * Takes given Game Object and aligns it so that it is positioned in the center of the other. + * [description] * - * @function Phaser.Display.Align.In.Center + * @function Phaser.Utils.Array.Matrix.TransposeMatrix * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. + * @param {array} array - The array matrix to transpose. * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + * @return {array} A new array matrix which is a transposed version of the given array. */ -var Center = function (gameObject, alignIn, offsetX, offsetY) +var TransposeMatrix = function (array) { - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } + var sourceRowCount = array.length; + var sourceColCount = array[0].length; - CenterOn(gameObject, GetCenterX(alignIn) + offsetX, GetCenterY(alignIn) + offsetY); + var result = new Array(sourceColCount); - return gameObject; + for (var i = 0; i < sourceColCount; i++) + { + result[i] = new Array(sourceRowCount); + + for (var j = sourceRowCount - 1; j > -1; j--) + { + result[i][j] = array[j][i]; + } + } + + return result; }; -module.exports = Center; +module.exports = TransposeMatrix; /***/ }), @@ -35151,29 +36125,863 @@ module.exports = Center; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var SetCenterX = __webpack_require__(47); -var SetCenterY = __webpack_require__(48); +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(15); +var TweenBuilder = __webpack_require__(82); +var TWEEN_CONST = __webpack_require__(68); /** - * Positions the Game Object so that it is centered on the given coordinates. + * @classdesc + * [description] * - * @function Phaser.Display.Bounds.CenterOn + * @class Timeline + * @memberOf Phaser.Tweens + * @extends EventEmitter + * @constructor * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} x - The horizontal coordinate to position the Game Object on. - * @param {number} y - The vertical coordinate to position the Game Object on. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + * @param {Phaser.Tweens.TweenManager} manager - [description] */ -var CenterOn = function (gameObject, x, y) -{ - SetCenterX(gameObject, x); +var Timeline = new Class({ - return SetCenterY(gameObject, y); -}; + Extends: EventEmitter, -module.exports = CenterOn; + initialize: + + function Timeline (manager) + { + EventEmitter.call(this); + + /** + * [description] + * + * @name Phaser.Tweens.Timeline#manager + * @type {Phaser.Tweens.TweenManager} + * @since 3.0.0 + */ + this.manager = manager; + + /** + * [description] + * + * @name Phaser.Tweens.Timeline#isTimeline + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.isTimeline = true; + + /** + * An array of Tween objects, each containing a unique property and target being tweened. + * + * @name Phaser.Tweens.Timeline#data + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.data = []; + + /** + * data array doesn't usually change, so we can cache the length + * + * @name Phaser.Tweens.Timeline#totalData + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalData = 0; + + /** + * If true then duration, delay, etc values are all frame totals. + * + * @name Phaser.Tweens.Timeline#useFrames + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.useFrames = false; + + /** + * Scales the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. + * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. + * + * @name Phaser.Tweens.Timeline#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * Loop this tween? Can be -1 for an infinite loop, or an integer. + * When enabled it will play through ALL TweenDatas again (use TweenData.repeat to loop a single TD) + * + * @name Phaser.Tweens.Timeline#loop + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loop = 0; + + /** + * Time in ms/frames before the tween loops. + * + * @name Phaser.Tweens.Timeline#loopDelay + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loopDelay = 0; + + /** + * How many loops are left to run? + * + * @name Phaser.Tweens.Timeline#loopCounter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loopCounter = 0; + + /** + * Time in ms/frames before the 'onComplete' event fires. This never fires if loop = true (as it never completes) + * + * @name Phaser.Tweens.Timeline#completeDelay + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.completeDelay = 0; + + /** + * Countdown timer (used by loopDelay and completeDelay) + * + * @name Phaser.Tweens.Timeline#countdown + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.countdown = 0; + + /** + * The current state of the tween + * + * @name Phaser.Tweens.Timeline#state + * @type {integer} + * @since 3.0.0 + */ + this.state = TWEEN_CONST.PENDING_ADD; + + /** + * The state of the tween when it was paused (used by Resume) + * + * @name Phaser.Tweens.Timeline#_pausedState + * @type {integer} + * @private + * @since 3.0.0 + */ + this._pausedState = TWEEN_CONST.PENDING_ADD; + + /** + * Does the Tween start off paused? (if so it needs to be started with Tween.play) + * + * @name Phaser.Tweens.Timeline#paused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.paused = false; + + /** + * Elapsed time in ms/frames of this run through the Tween. + * + * @name Phaser.Tweens.Timeline#elapsed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.elapsed = 0; + + /** + * Total elapsed time in ms/frames of the entire Tween, including looping. + * + * @name Phaser.Tweens.Timeline#totalElapsed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalElapsed = 0; + + /** + * Time in ms/frames for the whole Tween to play through once, excluding loop amounts and loop delays. + * + * @name Phaser.Tweens.Timeline#duration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.duration = 0; + + /** + * Value between 0 and 1. The amount through the Tween, excluding loops. + * + * @name Phaser.Tweens.Timeline#progress + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.progress = 0; + + /** + * Time in ms/frames for all Tweens to complete (including looping) + * + * @name Phaser.Tweens.Timeline#totalDuration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalDuration = 0; + + /** + * Value between 0 and 1. The amount through the entire Tween, including looping. + * + * @name Phaser.Tweens.Timeline#totalProgress + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalProgress = 0; + + this.callbacks = { + onComplete: null, + onLoop: null, + onStart: null, + onUpdate: null, + onYoyo: null + }; + + this.callbackScope; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#setTimeScale + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Tweens.Timeline} This Timeline object. + */ + setTimeScale: function (value) + { + this.timeScale = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#getTimeScale + * @since 3.0.0 + * + * @return {number} [description] + */ + getTimeScale: function () + { + return this.timeScale; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#isPlaying + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isPlaying: function () + { + return (this.state === TWEEN_CONST.ACTIVE); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#add + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.Tweens.Timeline} This Timeline object. + */ + add: function (config) + { + return this.queue(TweenBuilder(this, config)); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#queue + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * + * @return {Phaser.Tweens.Timeline} This Timeline object. + */ + queue: function (tween) + { + if (!this.isPlaying()) + { + tween.parent = this; + tween.parentIsTimeline = true; + + this.data.push(tween); + + this.totalData = this.data.length; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#hasOffset + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * + * @return {boolean} [description] + */ + hasOffset: function (tween) + { + return (tween.offset !== null); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#isOffsetAbsolute + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {boolean} [description] + */ + isOffsetAbsolute: function (value) + { + return (typeof(value) === 'number'); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#isOffsetRelative + * @since 3.0.0 + * + * @param {string} value - [description] + * + * @return {boolean} [description] + */ + isOffsetRelative: function (value) + { + var t = typeof(value); + + if (t === 'string') + { + var op = value[0]; + + if (op === '-' || op === '+') + { + return true; + } + } + + return false; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#getRelativeOffset + * @since 3.0.0 + * + * @param {string} value - [description] + * @param {number} base - [description] + * + * @return {number} [description] + */ + getRelativeOffset: function (value, base) + { + var op = value[0]; + var num = parseFloat(value.substr(2)); + var result = base; + + switch (op) + { + case '+': + result += num; + break; + + case '-': + result -= num; + break; + } + + // Cannot ever be < 0 + return Math.max(0, result); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#calcDuration + * @since 3.0.0 + */ + calcDuration: function () + { + var prevEnd = 0; + var totalDuration = 0; + var offsetDuration = 0; + + for (var i = 0; i < this.totalData; i++) + { + var tween = this.data[i]; + + tween.init(); + + if (this.hasOffset(tween)) + { + if (this.isOffsetAbsolute(tween.offset)) + { + // An actual number, so it defines the start point from the beginning of the timeline + tween.calculatedOffset = tween.offset; + + if (tween.offset === 0) + { + offsetDuration = 0; + } + } + else if (this.isOffsetRelative(tween.offset)) + { + // A relative offset (i.e. '-=1000', so starts at 'offset' ms relative to the PREVIOUS Tweens ending time) + tween.calculatedOffset = this.getRelativeOffset(tween.offset, prevEnd); + } + } + else + { + // Sequential + tween.calculatedOffset = offsetDuration; + } + + prevEnd = tween.totalDuration + tween.calculatedOffset; + + totalDuration += tween.totalDuration; + offsetDuration += tween.totalDuration; + } + + // Excludes loop values + this.duration = totalDuration; + + this.loopCounter = (this.loop === -1) ? 999999999999 : this.loop; + + if (this.loopCounter > 0) + { + this.totalDuration = this.duration + this.completeDelay + ((this.duration + this.loopDelay) * this.loopCounter); + } + else + { + this.totalDuration = this.duration + this.completeDelay; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#init + * @since 3.0.0 + * + * @return {boolean} [description] + */ + init: function () + { + this.calcDuration(); + + this.progress = 0; + this.totalProgress = 0; + + if (this.paused) + { + this.state = TWEEN_CONST.PAUSED; + + return false; + } + else + { + return true; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#resetTweens + * @since 3.0.0 + * + * @param {boolean} resetFromLoop - [description] + */ + resetTweens: function (resetFromLoop) + { + for (var i = 0; i < this.totalData; i++) + { + var tween = this.data[i]; + + tween.play(resetFromLoop); + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#setCallback + * @since 3.0.0 + * + * @param {string} type - [description] + * @param {function} callback - [description] + * @param {array} [params] - [description] + * @param {object} [scope] - [description] + * + * @return {Phaser.Tweens.Timeline} This Timeline object. + */ + setCallback: function (type, callback, params, scope) + { + if (Timeline.TYPES.indexOf(type) !== -1) + { + this.callbacks[type] = { func: callback, scope: scope, params: params }; + } + + return this; + }, + + /** + * Delegates #makeActive to the Tween manager. + * + * @method Phaser.Tweens.Timeline#makeActive + * @since 3.3.0 + * + * @param {Phaser.Tweens.Tween} tween - The tween object to make active. + * + * @return {Phaser.Tweens.TweenManager} The Timeline's Tween Manager object. + */ + makeActive: function (tween) + { + return this.manager.makeActive(tween); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#play + * @since 3.0.0 + */ + play: function () + { + if (this.state === TWEEN_CONST.ACTIVE) + { + return; + } + + if (this.paused) + { + this.paused = false; + + this.manager.makeActive(this); + + return; + } + else + { + this.resetTweens(false); + + this.state = TWEEN_CONST.ACTIVE; + } + + var onStart = this.callbacks.onStart; + + if (onStart) + { + onStart.func.apply(onStart.scope, onStart.params); + } + + this.emit('start', this); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#nextState + * @since 3.0.0 + */ + nextState: function () + { + if (this.loopCounter > 0) + { + // Reset the elapsed time + // TODO: Probably ought to be set to the remainder from elapsed - duration + // as the tweens nearly always over-run by a few ms due to rAf + + this.elapsed = 0; + this.progress = 0; + + this.loopCounter--; + + var onLoop = this.callbacks.onLoop; + + if (onLoop) + { + onLoop.func.apply(onLoop.scope, onLoop.params); + } + + this.emit('loop', this, this.loopCounter); + + this.resetTweens(true); + + if (this.loopDelay > 0) + { + this.countdown = this.loopDelay; + this.state = TWEEN_CONST.LOOP_DELAY; + } + else + { + this.state = TWEEN_CONST.ACTIVE; + } + } + else if (this.completeDelay > 0) + { + this.countdown = this.completeDelay; + this.state = TWEEN_CONST.COMPLETE_DELAY; + } + else + { + var onComplete = this.callbacks.onComplete; + + if (onComplete) + { + onComplete.func.apply(onComplete.scope, onComplete.params); + } + + this.emit('complete', this); + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + }, + + /** + * Returns 'true' if this Timeline has finished and should be removed from the Tween Manager. + * Otherwise, returns false. + * + * @method Phaser.Tweens.Timeline#update + * @since 3.0.0 + * + * @param {number} timestamp - [description] + * @param {number} delta - [description] + * + * @return {boolean} Returns `true` if this Timeline has finished and should be removed from the Tween Manager. + */ + update: function (timestamp, delta) + { + if (this.state === TWEEN_CONST.PAUSED) + { + return; + } + + var rawDelta = delta; + + if (this.useFrames) + { + delta = 1 * this.manager.timeScale; + } + + delta *= this.timeScale; + + this.elapsed += delta; + this.progress = Math.min(this.elapsed / this.duration, 1); + + this.totalElapsed += delta; + this.totalProgress = Math.min(this.totalElapsed / this.totalDuration, 1); + + switch (this.state) + { + case TWEEN_CONST.ACTIVE: + + var stillRunning = this.totalData; + + for (var i = 0; i < this.totalData; i++) + { + var tween = this.data[i]; + + if (tween.update(timestamp, rawDelta)) + { + stillRunning--; + } + } + + var onUpdate = this.callbacks.onUpdate; + + if (onUpdate) + { + onUpdate.func.apply(onUpdate.scope, onUpdate.params); + } + + this.emit('update', this); + + // Anything still running? If not, we're done + if (stillRunning === 0) + { + this.nextState(); + } + + break; + + case TWEEN_CONST.LOOP_DELAY: + + this.countdown -= delta; + + if (this.countdown <= 0) + { + this.state = TWEEN_CONST.ACTIVE; + } + + break; + + case TWEEN_CONST.COMPLETE_DELAY: + + this.countdown -= delta; + + if (this.countdown <= 0) + { + var onComplete = this.callbacks.onComplete; + + if (onComplete) + { + onComplete.func.apply(onComplete.scope, onComplete.params); + } + + this.emit('complete', this); + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + + break; + } + + return (this.state === TWEEN_CONST.PENDING_REMOVE); + }, + + /** + * Stops the Tween immediately, whatever stage of progress it is at and flags it for removal by the TweenManager. + * + * @method Phaser.Tweens.Timeline#stop + * @since 3.0.0 + */ + stop: function () + { + this.state = TWEEN_CONST.PENDING_REMOVE; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#pause + * @since 3.0.0 + * + * @return {Phaser.Tweens.Timeline} This Timeline object. + */ + pause: function () + { + if (this.state === TWEEN_CONST.PAUSED) + { + return; + } + + this.paused = true; + + this._pausedState = this.state; + + this.state = TWEEN_CONST.PAUSED; + + this.emit('pause', this); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#resume + * @since 3.0.0 + * + * @return {Phaser.Tweens.Timeline} This Timeline object. + */ + resume: function () + { + if (this.state === TWEEN_CONST.PAUSED) + { + this.paused = false; + + this.state = this._pausedState; + } + + this.emit('resume', this); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#hasTarget + * @since 3.0.0 + * + * @param {object} target - [description] + * + * @return {boolean} [description] + */ + hasTarget: function (target) + { + for (var i = 0; i < this.data.length; i++) + { + if (this.data[i].hasTarget(target)) + { + return true; + } + } + + return false; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#destroy + * @since 3.0.0 + */ + destroy: function () + { + for (var i = 0; i < this.data.length; i++) + { + this.data[i].destroy(); + } + + } +}); + +Timeline.TYPES = [ 'onStart', 'onUpdate', 'onLoop', 'onComplete', 'onYoyo' ]; + +module.exports = Timeline; /***/ }), @@ -35186,36 +36994,146 @@ module.exports = CenterOn; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetCenterY = __webpack_require__(49); -var GetLeft = __webpack_require__(26); -var SetCenterY = __webpack_require__(48); -var SetLeft = __webpack_require__(27); +var Clone = __webpack_require__(55); +var Defaults = __webpack_require__(112); +var GetAdvancedValue = __webpack_require__(8); +var GetBoolean = __webpack_require__(69); +var GetEaseFunction = __webpack_require__(71); +var GetNewValue = __webpack_require__(83); +var GetTargets = __webpack_require__(114); +var GetTweens = __webpack_require__(181); +var GetValue = __webpack_require__(5); +var Timeline = __webpack_require__(178); +var TweenBuilder = __webpack_require__(82); /** - * Takes given Game Object and aligns it so that it is positioned in the left center of the other. + * [description] * - * @function Phaser.Display.Align.In.LeftCenter + * @function Phaser.Tweens.Builders.TimelineBuilder * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. + * @param {Phaser.Tweens.TweenManager} manager - [description] + * @param {object} config - [description] * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + * @return {Phaser.Tweens.Timeline} [description] */ -var LeftCenter = function (gameObject, alignIn, offsetX, offsetY) +var TimelineBuilder = function (manager, config) { - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } + var timeline = new Timeline(manager); - SetLeft(gameObject, GetLeft(alignIn) - offsetX); - SetCenterY(gameObject, GetCenterY(alignIn) + offsetY); + var tweens = GetTweens(config); - return gameObject; + if (tweens.length === 0) + { + timeline.paused = true; + + return timeline; + } + + var defaults = Clone(Defaults); + + defaults.targets = GetTargets(config); + + // totalDuration: If specified each tween in the Timeline is given an equal portion of the totalDuration + + var totalDuration = GetAdvancedValue(config, 'totalDuration', 0); + + if (totalDuration > 0) + { + defaults.duration = Math.floor(totalDuration / tweens.length); + } + else + { + defaults.duration = GetNewValue(config, 'duration', defaults.duration); + } + + defaults.delay = GetNewValue(config, 'delay', defaults.delay); + defaults.easeParams = GetValue(config, 'easeParams', defaults.easeParams); + defaults.ease = GetEaseFunction(GetValue(config, 'ease', defaults.ease), defaults.easeParams); + defaults.hold = GetNewValue(config, 'hold', defaults.hold); + defaults.repeat = GetNewValue(config, 'repeat', defaults.repeat); + defaults.repeatDelay = GetNewValue(config, 'repeatDelay', defaults.repeatDelay); + defaults.yoyo = GetBoolean(config, 'yoyo', defaults.yoyo); + defaults.flipX = GetBoolean(config, 'flipX', defaults.flipX); + defaults.flipY = GetBoolean(config, 'flipY', defaults.flipY); + + // Create the Tweens + for (var i = 0; i < tweens.length; i++) + { + timeline.queue(TweenBuilder(timeline, tweens[i], defaults)); + } + + timeline.completeDelay = GetAdvancedValue(config, 'completeDelay', 0); + timeline.loop = Math.round(GetAdvancedValue(config, 'loop', 0)); + timeline.loopDelay = Math.round(GetAdvancedValue(config, 'loopDelay', 0)); + timeline.paused = GetBoolean(config, 'paused', false); + timeline.useFrames = GetBoolean(config, 'useFrames', false); + + // Callbacks + + var scope = GetValue(config, 'callbackScope', timeline); + + var timelineArray = [ timeline ]; + + var onStart = GetValue(config, 'onStart', false); + + // The Start of the Timeline + if (onStart) + { + var onStartScope = GetValue(config, 'onStartScope', scope); + var onStartParams = GetValue(config, 'onStartParams', []); + + timeline.setCallback('onStart', onStart, timelineArray.concat(onStartParams), onStartScope); + } + + var onUpdate = GetValue(config, 'onUpdate', false); + + // Every time the Timeline updates (regardless which Tweens are running) + if (onUpdate) + { + var onUpdateScope = GetValue(config, 'onUpdateScope', scope); + var onUpdateParams = GetValue(config, 'onUpdateParams', []); + + timeline.setCallback('onUpdate', onUpdate, timelineArray.concat(onUpdateParams), onUpdateScope); + } + + var onLoop = GetValue(config, 'onLoop', false); + + // Called when the whole Timeline loops + if (onLoop) + { + var onLoopScope = GetValue(config, 'onLoopScope', scope); + var onLoopParams = GetValue(config, 'onLoopParams', []); + + timeline.setCallback('onLoop', onLoop, timelineArray.concat(onLoopParams), onLoopScope); + } + + var onYoyo = GetValue(config, 'onYoyo', false); + + // Called when a Timeline yoyos + if (onYoyo) + { + var onYoyoScope = GetValue(config, 'onYoyoScope', scope); + var onYoyoParams = GetValue(config, 'onYoyoParams', []); + + timeline.setCallback('onYoyo', onYoyo, timelineArray.concat(null, onYoyoParams), onYoyoScope); + } + + var onComplete = GetValue(config, 'onComplete', false); + + // Called when the Timeline completes, after the completeDelay, etc. + if (onComplete) + { + var onCompleteScope = GetValue(config, 'onCompleteScope', scope); + var onCompleteParams = GetValue(config, 'onCompleteParams', []); + + timeline.setCallback('onComplete', onComplete, timelineArray.concat(onCompleteParams), onCompleteScope); + } + + return timeline; }; -module.exports = LeftCenter; +module.exports = TimelineBuilder; /***/ }), @@ -35228,36 +37146,122 @@ module.exports = LeftCenter; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetCenterY = __webpack_require__(49); -var GetRight = __webpack_require__(28); -var SetCenterY = __webpack_require__(48); -var SetRight = __webpack_require__(29); +var Defaults = __webpack_require__(112); +var GetAdvancedValue = __webpack_require__(8); +var GetBoolean = __webpack_require__(69); +var GetEaseFunction = __webpack_require__(71); +var GetNewValue = __webpack_require__(83); +var GetValue = __webpack_require__(5); +var GetValueOp = __webpack_require__(113); +var Tween = __webpack_require__(111); +var TweenData = __webpack_require__(110); /** - * Takes given Game Object and aligns it so that it is positioned in the right center of the other. + * [description] * - * @function Phaser.Display.Align.In.RightCenter + * @function Phaser.Tweens.Builders.NumberTweenBuilder * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. + * @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - [description] + * @param {object} config - [description] + * @param {Phaser.Tweens.TweenConfigDefaults} defaults - [description] * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + * @return {Phaser.Tweens.Tween} [description] */ -var RightCenter = function (gameObject, alignIn, offsetX, offsetY) +var NumberTweenBuilder = function (parent, config, defaults) { - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } + if (defaults === undefined) + { + defaults = Defaults; + } - SetRight(gameObject, GetRight(alignIn) + offsetX); - SetCenterY(gameObject, GetCenterY(alignIn) + offsetY); + // var tween = this.tweens.addCounter({ + // from: 100, + // to: 200, + // ... (normal tween properties) + // }) + // + // Then use it in your game via: + // + // tween.getValue() - return gameObject; + var from = GetValue(config, 'from', 0); + var to = GetValue(config, 'to', 1); + + var targets = [ { value: from } ]; + + var delay = GetNewValue(config, 'delay', defaults.delay); + var duration = GetNewValue(config, 'duration', defaults.duration); + var easeParams = GetValue(config, 'easeParams', defaults.easeParams); + var ease = GetEaseFunction(GetValue(config, 'ease', defaults.ease), easeParams); + var hold = GetNewValue(config, 'hold', defaults.hold); + var repeat = GetNewValue(config, 'repeat', defaults.repeat); + var repeatDelay = GetNewValue(config, 'repeatDelay', defaults.repeatDelay); + var yoyo = GetBoolean(config, 'yoyo', defaults.yoyo); + + var data = []; + + var ops = GetValueOp('value', to); + + var tweenData = TweenData( + targets[0], + 'value', + ops.getEnd, + ops.getStart, + ease, + delay, + duration, + yoyo, + hold, + repeat, + repeatDelay, + false, + false + ); + + tweenData.start = from; + tweenData.current = from; + tweenData.to = to; + + data.push(tweenData); + + var tween = new Tween(parent, data, targets); + + tween.offset = GetAdvancedValue(config, 'offset', null); + tween.completeDelay = GetAdvancedValue(config, 'completeDelay', 0); + tween.loop = Math.round(GetAdvancedValue(config, 'loop', 0)); + tween.loopDelay = Math.round(GetAdvancedValue(config, 'loopDelay', 0)); + tween.paused = GetBoolean(config, 'paused', false); + tween.useFrames = GetBoolean(config, 'useFrames', false); + + // Set the Callbacks + var scope = GetValue(config, 'callbackScope', tween); + + // Callback parameters: 0 = a reference to the Tween itself, 1 = the target/s of the Tween, ... your own params + var tweenArray = [ tween, null ]; + + var callbacks = Tween.TYPES; + + for (var i = 0; i < callbacks.length; i++) + { + var type = callbacks[i]; + + var callback = GetValue(config, type, false); + + if (callback) + { + var callbackScope = GetValue(config, type + 'Scope', scope); + var callbackParams = GetValue(config, type + 'Params', []); + + // The null is reset to be the Tween target + tween.setCallback(type, callback, tweenArray.concat(callbackParams), callbackScope); + } + } + + return tween; }; -module.exports = RightCenter; +module.exports = NumberTweenBuilder; /***/ }), @@ -35270,36 +37274,40 @@ module.exports = RightCenter; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetCenterX = __webpack_require__(46); -var GetTop = __webpack_require__(30); -var SetCenterX = __webpack_require__(47); -var SetTop = __webpack_require__(31); +var GetValue = __webpack_require__(5); /** - * Takes given Game Object and aligns it so that it is positioned in the top center of the other. + * [description] * - * @function Phaser.Display.Align.In.TopCenter + * @function Phaser.Tweens.Builders.GetTweens * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. + * @param {object} config - [description] * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + * @return {array} [description] */ -var TopCenter = function (gameObject, alignIn, offsetX, offsetY) +var GetTweens = function (config) { - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } + var tweens = GetValue(config, 'tweens', null); - SetCenterX(gameObject, GetCenterX(alignIn) + offsetX); - SetTop(gameObject, GetTop(alignIn) - offsetY); + if (tweens === null) + { + return []; + } + else if (typeof tweens === 'function') + { + tweens = tweens.call(); + } - return gameObject; + if (!Array.isArray(tweens)) + { + tweens = [ tweens ]; + } + + return tweens; }; -module.exports = TopCenter; +module.exports = GetTweens; /***/ }), @@ -35312,36 +37320,52 @@ module.exports = TopCenter; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetLeft = __webpack_require__(26); -var GetTop = __webpack_require__(30); -var SetLeft = __webpack_require__(27); -var SetTop = __webpack_require__(31); +var RESERVED = __webpack_require__(402); /** - * Takes given Game Object and aligns it so that it is positioned in the top left of the other. + * [description] * - * @function Phaser.Display.Align.In.TopLeft + * @function Phaser.Tweens.Builders.GetProps * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. + * @param {object} config - [description] * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + * @return {array} [description] */ -var TopLeft = function (gameObject, alignIn, offsetX, offsetY) +var GetProps = function (config) { - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } + var key; + var keys = []; - SetLeft(gameObject, GetLeft(alignIn) - offsetX); - SetTop(gameObject, GetTop(alignIn) - offsetY); + // First see if we have a props object - return gameObject; + if (config.hasOwnProperty('props')) + { + for (key in config.props) + { + // Skip any property that starts with an underscore + if (key.substr(0, 1) !== '_') + { + keys.push({ key: key, value: config.props[key] }); + } + } + } + else + { + for (key in config) + { + // Skip any property that is in the ReservedProps list or that starts with an underscore + if (RESERVED.indexOf(key) === -1 && key.substr(0, 1) !== '_') + { + keys.push({ key: key, value: config[key] }); + } + } + } + + return keys; }; -module.exports = TopLeft; +module.exports = GetProps; /***/ }), @@ -35354,36 +37378,311 @@ module.exports = TopLeft; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetRight = __webpack_require__(28); -var GetTop = __webpack_require__(30); -var SetRight = __webpack_require__(29); -var SetTop = __webpack_require__(31); +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(2); /** - * Takes given Game Object and aligns it so that it is positioned in the top right of the other. + * @typedef {object} TimerEventConfig * - * @function Phaser.Display.Align.In.TopRight + * @property {number} [delay=0] - [description] + * @property {number} [repeat=0] - [description] + * @property {boolean} [loop=false] - [description] + * @property {function} [callback] - [description] + * @property {*} [callbackScope] - [description] + * @property {Array.<*>} [args] - [description] + * @property {number} [timeScale=1] - [description] + * @property {number} [startAt=1] - [description] + * @property {boolean} [paused=false] - [description] + */ + +/** + * @classdesc + * [description] + * + * @class TimerEvent + * @memberOf Phaser.Time + * @constructor * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + * @param {TimerEventConfig} config - [description] */ -var TopRight = function (gameObject, alignIn, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } +var TimerEvent = new Class({ - SetRight(gameObject, GetRight(alignIn) + offsetX); - SetTop(gameObject, GetTop(alignIn) - offsetY); + initialize: - return gameObject; -}; + function TimerEvent (config) + { + /** + * The delay in ms at which this TimerEvent fires. + * + * @name Phaser.Time.TimerEvent#delay + * @type {number} + * @default 0 + * @readOnly + * @since 3.0.0 + */ + this.delay = 0; -module.exports = TopRight; + /** + * The total number of times this TimerEvent will repeat before finishing. + * + * @name Phaser.Time.TimerEvent#repeat + * @type {number} + * @default 0 + * @readOnly + * @since 3.0.0 + */ + this.repeat = 0; + + /** + * If repeating this contains the current repeat count. + * + * @name Phaser.Time.TimerEvent#repeatCount + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.repeatCount = 0; + + /** + * True if this TimerEvent loops, otherwise false. + * + * @name Phaser.Time.TimerEvent#loop + * @type {boolean} + * @default false + * @readOnly + * @since 3.0.0 + */ + this.loop = false; + + /** + * The callback that will be called when the TimerEvent occurs. + * + * @name Phaser.Time.TimerEvent#callback + * @type {function} + * @since 3.0.0 + */ + this.callback; + + /** + * The scope in which the callback will be called. + * + * @name Phaser.Time.TimerEvent#callbackScope + * @type {object} + * @since 3.0.0 + */ + this.callbackScope; + + /** + * Additional arguments to be passed to the callback. + * + * @name Phaser.Time.TimerEvent#args + * @type {array} + * @since 3.0.0 + */ + this.args; + + /** + * Scale the time causing this TimerEvent to update. + * + * @name Phaser.Time.TimerEvent#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * Start this many MS into the elapsed (useful if you want a long duration with repeat, but for the first loop to fire quickly) + * + * @name Phaser.Time.TimerEvent#startAt + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.startAt = 0; + + /** + * [description] + * + * @name Phaser.Time.TimerEvent#elapsed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.elapsed = 0; + + /** + * [description] + * + * @name Phaser.Time.TimerEvent#paused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.paused = false; + + /** + * [description] + * + * @name Phaser.Time.TimerEvent#hasDispatched + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.hasDispatched = false; + + this.reset(config); + }, + + /** + * [description] + * + * @method Phaser.Time.TimerEvent#reset + * @since 3.0.0 + * + * @param {TimerEventConfig} config - [description] + * + * @return {Phaser.Time.TimerEvent} This TimerEvent object. + */ + reset: function (config) + { + this.delay = GetFastValue(config, 'delay', 0); + + // Can also be set to -1 for an infinite loop (same as setting loop: true) + this.repeat = GetFastValue(config, 'repeat', 0); + + this.loop = GetFastValue(config, 'loop', false); + + this.callback = GetFastValue(config, 'callback', undefined); + + this.callbackScope = GetFastValue(config, 'callbackScope', this.callback); + + this.args = GetFastValue(config, 'args', []); + + this.timeScale = GetFastValue(config, 'timeScale', 1); + + this.startAt = GetFastValue(config, 'startAt', 0); + + this.paused = GetFastValue(config, 'paused', false); + + this.elapsed = this.startAt; + this.hasDispatched = false; + this.repeatCount = (this.repeat === -1 || this.loop) ? 999999999999 : this.repeat; + + return this; + }, + + /** + * Gets the progress of the current iteration, not factoring in repeats. + * + * @method Phaser.Time.TimerEvent#getProgress + * @since 3.0.0 + * + * @return {number} [description] + */ + getProgress: function () + { + return (this.elapsed / this.delay); + }, + + /** + * Gets the progress of the timer overall, factoring in repeats. + * + * @method Phaser.Time.TimerEvent#getOverallProgress + * @since 3.0.0 + * + * @return {number} [description] + */ + getOverallProgress: function () + { + if (this.repeat > 0) + { + var totalDuration = this.delay + (this.delay * this.repeat); + var totalElapsed = this.elapsed + (this.delay * (this.repeat - this.repeatCount)); + + return (totalElapsed / totalDuration); + } + else + { + return this.getProgress(); + } + }, + + /** + * [description] + * + * @method Phaser.Time.TimerEvent#getRepeatCount + * @since 3.0.0 + * + * @return {number} [description] + */ + getRepeatCount: function () + { + return this.repeatCount; + }, + + /** + * [description] + * + * @method Phaser.Time.TimerEvent#getElapsed + * @since 3.0.0 + * + * @return {number} [description] + */ + getElapsed: function () + { + return this.elapsed; + }, + + /** + * [description] + * + * @method Phaser.Time.TimerEvent#getElapsedSeconds + * @since 3.0.0 + * + * @return {number} [description] + */ + getElapsedSeconds: function () + { + return this.elapsed * 0.001; + }, + + /** + * [description] + * + * @method Phaser.Time.TimerEvent#remove + * @since 3.0.0 + * + * @param {function} dispatchCallback - [description] + */ + remove: function (dispatchCallback) + { + if (dispatchCallback === undefined) { dispatchCallback = false; } + + this.elapsed = this.delay; + + this.hasDispatched = !dispatchCallback; + + this.repeatCount = 0; + }, + + /** + * [description] + * + * @method Phaser.Time.TimerEvent#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.callback = undefined; + this.callbackScope = undefined; + this.args = []; + } + +}); + +module.exports = TimerEvent; /***/ }), @@ -35396,35 +37695,1023 @@ module.exports = TopRight; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CircumferencePoint = __webpack_require__(105); -var FromPercent = __webpack_require__(65); -var MATH_CONST = __webpack_require__(16); -var Point = __webpack_require__(5); +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var CONST = __webpack_require__(21); +var GameObject = __webpack_require__(1); +var StaticTilemapLayerRender = __webpack_require__(411); +var TilemapComponents = __webpack_require__(88); +var Utils = __webpack_require__(44); /** - * Returns a Point object containing the coordinates of a point on the circumference of the Circle - * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point - * at 180 degrees around the circle. + * @classdesc + * A StaticTilemapLayer is a game object that renders LayerData from a Tilemap. A + * StaticTilemapLayer can only render tiles from a single tileset. * - * @function Phaser.Geom.Circle.GetPoint + * A StaticTilemapLayer is optimized for speed over flexibility. You cannot apply per-tile + * effects like tint or alpha. You cannot change the tiles in a StaticTilemapLayer. Use this + * over a DynamicTilemapLayer when you don't need either of those features. + * + * @class StaticTilemapLayer + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.Tilemaps + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on. - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. - * @param {Phaser.Geom.Point|object} [out] - An object to store the return values in. If not given a Point object will be created. + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * @extends Phaser.GameObjects.Components.ScrollFactor * - * @return {Phaser.Geom.Point|object} A Point, or point-like object, containing the coordinates of the point around the circle. + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Tilemaps.Tilemap} tilemap - The Tilemap this layer is a part of. + * @param {integer} layerIndex - The index of the LayerData associated with this layer. + * @param {Phaser.Tilemaps.Tileset} tileset - The tileset used to render the tiles in this layer. + * @param {number} [x=0] - The world x position where the top left of this layer will be placed. + * @param {number} [y=0] - The world y position where the top left of this layer will be placed. */ -var GetPoint = function (circle, position, out) -{ - if (out === undefined) { out = new Point(); } +var StaticTilemapLayer = new Class({ - var angle = FromPercent(position, 0, MATH_CONST.PI2); + Extends: GameObject, - return CircumferencePoint(circle, angle, out); -}; + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.Size, + Components.Transform, + Components.Visible, + Components.ScrollFactor, + StaticTilemapLayerRender + ], -module.exports = GetPoint; + initialize: + + function StaticTilemapLayer (scene, tilemap, layerIndex, tileset, x, y) + { + GameObject.call(this, scene, 'StaticTilemapLayer'); + + /** + * Used internally by physics system to perform fast type checks. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#isTilemap + * @type {boolean} + * @readOnly + * @since 3.0.0 + */ + this.isTilemap = true; + + /** + * The Tilemap that this layer is a part of. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#tilemap + * @type {Phaser.Tilemaps.Tilemap} + * @since 3.0.0 + */ + this.tilemap = tilemap; + + /** + * The index of the LayerData associated with this layer. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#layerIndex + * @type {integer} + * @since 3.0.0 + */ + this.layerIndex = layerIndex; + + /** + * The LayerData associated with this layer. LayerData can only be associated with one + * tilemap layer. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#layer + * @type {Phaser.Tilemaps.LayerData} + * @since 3.0.0 + */ + this.layer = tilemap.layers[layerIndex]; + + this.layer.tilemapLayer = this; // Link the LayerData with this static tilemap layer + + /** + * The Tileset associated with this layer. A tilemap layer can only render from one Tileset. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#tileset + * @type {Phaser.Tilemaps.Tileset} + * @since 3.0.0 + */ + this.tileset = tileset; + + /** + * Used internally with the canvas render. This holds the tiles that are visible within the + * camera. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#culledTiles + * @type {array} + * @since 3.0.0 + */ + this.culledTiles = []; + + /** + * @name Phaser.Tilemaps.StaticTilemapLayer#vertexBuffer + * @type {array} + * @private + * @since 3.0.0 + */ + this.vertexBuffer = null; + + /** + * @name Phaser.Tilemaps.StaticTilemapLayer#renderer + * @type {(Phaser.Renderer.CanvasRenderer|Phaser.Renderer.WebGLRenderer)} + * @private + * @since 3.0.0 + */ + this.renderer = scene.sys.game.renderer; + + /** + * @name Phaser.Tilemaps.StaticTilemapLayer#bufferData + * @type {ArrayBuffer} + * @private + * @since 3.0.0 + */ + this.bufferData = null; + + /** + * @name Phaser.Tilemaps.StaticTilemapLayer#vertexViewF32 + * @type {Float32Array} + * @private + * @since 3.0.0 + */ + this.vertexViewF32 = null; + + /** + * @name Phaser.Tilemaps.StaticTilemapLayer#vertexViewU32 + * @type {Uint32Array} + * @private + * @since 3.0.0 + */ + this.vertexViewU32 = null; + + /** + * @name Phaser.Tilemaps.StaticTilemapLayer#dirty + * @type {boolean} + * @private + * @since 3.0.0 + */ + this.dirty = true; + + /** + * @name Phaser.Tilemaps.StaticTilemapLayer#vertexCount + * @type {integer} + * @private + * @since 3.0.0 + */ + this.vertexCount = 0; + + this.setAlpha(this.layer.alpha); + this.setPosition(x, y); + this.setOrigin(); + this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height); + + this.initPipeline('TextureTintPipeline'); + + if (scene.sys.game.config.renderType === CONST.WEBGL) + { + scene.sys.game.renderer.onContextRestored(function () + { + this.dirty = true; + this.vertexBuffer = null; + }, this); + } + }, + + /** + * Upload the tile data to a VBO. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#upload + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to render to. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + upload: function (camera) + { + var tileset = this.tileset; + var mapWidth = this.layer.width; + var mapHeight = this.layer.height; + var width = tileset.image.get().width; + var height = tileset.image.get().height; + var mapData = this.layer.data; + var renderer = this.renderer; + var tile; + var row; + var col; + var texCoords; + + if (renderer.gl) + { + var pipeline = renderer.pipelines.TextureTintPipeline; + + if (this.dirty) + { + var gl = renderer.gl; + var vertexBuffer = this.vertexBuffer; + var bufferData = this.bufferData; + var voffset = 0; + var vertexCount = 0; + var bufferSize = (mapWidth * mapHeight) * pipeline.vertexSize * 6; + + if (bufferData === null) + { + bufferData = new ArrayBuffer(bufferSize); + this.bufferData = bufferData; + this.vertexViewF32 = new Float32Array(bufferData); + this.vertexViewU32 = new Uint32Array(bufferData); + } + + var vertexViewF32 = this.vertexViewF32; + var vertexViewU32 = this.vertexViewU32; + + for (row = 0; row < mapHeight; ++row) + { + for (col = 0; col < mapWidth; ++col) + { + tile = mapData[row][col]; + if (tile === null || tile.index === -1) { continue; } + + var tx = tile.pixelX; + var ty = tile.pixelY; + var txw = tx + tile.width; + var tyh = ty + tile.height; + + texCoords = tileset.getTileTextureCoordinates(tile.index); + if (texCoords === null) { continue; } + + var u0 = texCoords.x / width; + var v0 = texCoords.y / height; + var u1 = (texCoords.x + tile.width) / width; + var v1 = (texCoords.y + tile.height) / height; + + var tx0 = tx; + var ty0 = ty; + var tx1 = tx; + var ty1 = tyh; + var tx2 = txw; + var ty2 = tyh; + var tx3 = txw; + var ty3 = ty; + var tint = Utils.getTintAppendFloatAlpha(0xffffff, this.alpha * tile.alpha); + + vertexViewF32[voffset + 0] = tx0; + vertexViewF32[voffset + 1] = ty0; + vertexViewF32[voffset + 2] = u0; + vertexViewF32[voffset + 3] = v0; + vertexViewU32[voffset + 4] = tint; + vertexViewF32[voffset + 5] = tx1; + vertexViewF32[voffset + 6] = ty1; + vertexViewF32[voffset + 7] = u0; + vertexViewF32[voffset + 8] = v1; + vertexViewU32[voffset + 9] = tint; + vertexViewF32[voffset + 10] = tx2; + vertexViewF32[voffset + 11] = ty2; + vertexViewF32[voffset + 12] = u1; + vertexViewF32[voffset + 13] = v1; + vertexViewU32[voffset + 14] = tint; + vertexViewF32[voffset + 15] = tx0; + vertexViewF32[voffset + 16] = ty0; + vertexViewF32[voffset + 17] = u0; + vertexViewF32[voffset + 18] = v0; + vertexViewU32[voffset + 19] = tint; + vertexViewF32[voffset + 20] = tx2; + vertexViewF32[voffset + 21] = ty2; + vertexViewF32[voffset + 22] = u1; + vertexViewF32[voffset + 23] = v1; + vertexViewU32[voffset + 24] = tint; + vertexViewF32[voffset + 25] = tx3; + vertexViewF32[voffset + 26] = ty3; + vertexViewF32[voffset + 27] = u1; + vertexViewF32[voffset + 28] = v0; + vertexViewU32[voffset + 29] = tint; + + voffset += 30; + vertexCount += 6; + } + } + + this.vertexCount = vertexCount; + this.dirty = false; + if (vertexBuffer === null) + { + vertexBuffer = renderer.createVertexBuffer(bufferData, gl.STATIC_DRAW); + this.vertexBuffer = vertexBuffer; + } + else + { + renderer.setVertexBuffer(vertexBuffer); + gl.bufferSubData(gl.ARRAY_BUFFER, 0, bufferData); + } + } + + pipeline.modelIdentity(); + pipeline.modelTranslate(this.x - (camera.scrollX * this.scrollFactorX), this.y - (camera.scrollY * this.scrollFactorY), 0.0); + pipeline.modelScale(this.scaleX, this.scaleY, 1.0); + pipeline.viewLoad2D(camera.matrix.matrix); + } + + return this; + }, + + /** + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#calculateFacesAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate. + * @param {integer} tileY - The y coordinate. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + calculateFacesAt: function (tileX, tileY) + { + TilemapComponents.CalculateFacesAt(tileX, tileY, this.layer); + + return this; + }, + + /** + * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the + * layer. Interesting faces are used internally for optimizing collisions against tiles. This method + * is mostly used internally. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#calculateFacesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + calculateFacesWithin: function (tileX, tileY, width, height) + { + TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#createFromTiles + * @since 3.0.0 + * + * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. + * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted + * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a + * one-to-one mapping with the indexes array. + * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. + * scene.make.sprite). + * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY + * + * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. + */ + createFromTiles: function (indexes, replacements, spriteConfig, scene, camera) + { + return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, this.layer); + }, + + /** + * Returns the tiles in the given layer that are within the cameras viewport. + * This is used internally. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#cull + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + cull: function (camera) + { + return TilemapComponents.CullTiles(this.layer, camera, this.culledTiles); + }, + + /** + * Destroys this StaticTilemapLayer and removes its link to the associated LayerData. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#destroy + * @since 3.0.0 + */ + destroy: function () + { + // Uninstall this layer only if it is still installed on the LayerData object + if (this.layer.tilemapLayer === this) + { + this.layer.tilemapLayer = undefined; + } + + this.tilemap = undefined; + this.layer = undefined; + this.tileset = undefined; + + GameObject.prototype.destroy.call(this); + }, + + /** + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#findByIndex + * @since 3.0.0 + * + * @param {integer} index - The tile index value to search for. + * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. + * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the + * bottom-right. Otherwise it scans from the top-left. + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + findByIndex: function (findIndex, skip, reverse) + { + return TilemapComponents.FindByIndex(findIndex, skip, reverse, this.layer); + }, + + /** + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#findTile + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {?Phaser.Tilemaps.Tile} + */ + findTile: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#filterTiles + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#forEachTile + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + + return this; + }, + + /** + * Gets a tile at the given tile coordinates from the given layer. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTileAt + * @since 3.0.0 + * + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). + * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile + * object with an index of -1. + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates were invalid. + */ + getTileAt: function (tileX, tileY, nonNull) + { + return TilemapComponents.GetTileAt(tileX, tileY, nonNull, this.layer); + }, + + /** + * Gets a tile at the given world coordinates from the given layer. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - X position to get the tile from (given in pixels) + * @param {number} worldY - Y position to get the tile from (given in pixels) + * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile + * object with an index of -1. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates + * were invalid. + */ + getTileAtWorldXY: function (worldX, worldY, nonNull, camera) + { + return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, this.layer); + }, + + /** + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithin: function (tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithinWorldXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera) + { + return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, this.layer); + }, + + /** + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithinShape + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithinShape: function (shape, filteringOptions, camera) + { + return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, this.layer); + }, + + /** + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#hasTileAt + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * + * @return {boolean} + */ + hasTileAt: function (tileX, tileY) + { + return TilemapComponents.HasTileAt(tileX, tileY, this.layer); + }, + + /** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#hasTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {boolean} + */ + hasTileAtWorldXY: function (worldX, worldY, camera) + { + return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, this.layer); + }, + + /** + * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#renderDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. + * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. + * @param {?Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at + * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. + * @param {?Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled + * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. + * @param {?Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting + * tile faces. If set to null, interesting tile faces will not be drawn. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + renderDebug: function (graphics, styleConfig) + { + TilemapComponents.RenderDebug(graphics, styleConfig, this.layer); + + return this; + }, + + /** + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollision + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollision: function (indexes, collides, recalculateFaces) + { + TilemapComponents.SetCollision(indexes, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionBetween + * @since 3.0.0 + * + * @param {integer} start - The first index of the tile to be set for collision. + * @param {integer} stop - The last index of the tile to be set for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollisionBetween: function (start, stop, collides, recalculateFaces) + { + TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionByProperty + * @since 3.0.0 + * + * @param {object} properties - An object with tile properties and corresponding values that should + * be checked. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollisionByProperty: function (properties, collides, recalculateFaces) + { + TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionByExclusion + * @since 3.0.0 + * + * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollisionByExclusion: function (indexes, collides, recalculateFaces) + { + TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see setTileLocationCallback. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setTileIndexCallback + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a + * collision callback set for. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setTileIndexCallback: function (indexes, callback, callbackContext) + { + TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, this.layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking each tiles collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tiles collision group, the tile's colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionFromCollisionGroup + * @since 3.0.0 + * + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollisionFromCollisionGroup: function (collides, recalculateFaces) + { + TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setTileLocationCallback + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext) + { + TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, this.layer); + + return this; + }, + + /** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldX + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + tileToWorldX: function (tileX, camera) + { + return TilemapComponents.TileToWorldX(tileX, camera, this.layer); + }, + + /** + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldY + * @since 3.0.0 + * + * @param {integer} tileY - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + tileToWorldY: function (tileY, camera) + { + return TilemapComponents.TileToWorldY(tileY, camera, this.layer); + }, + + /** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldXY + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {Phaser.Math.Vector2} [point] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Math.Vector2} + */ + tileToWorldXY: function (tileX, tileY, point, camera) + { + return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, this.layer); + }, + + /** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileX + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + worldToTileX: function (worldX, snapToFloor, camera) + { + return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, this.layer); + }, + + /** + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileXY + * @since 3.0.0 + * + * @param {number} worldY - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + worldToTileY: function (worldY, snapToFloor, camera) + { + return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, this.layer); + }, + + /** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Math.Vector2} [point] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Math.Vector2} + */ + worldToTileXY: function (worldX, worldY, snapToFloor, point, camera) + { + return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, this.layer); + } + +}); + +module.exports = StaticTilemapLayer; /***/ }), @@ -35437,51 +38724,1117 @@ module.exports = GetPoint; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Circumference = __webpack_require__(186); -var CircumferencePoint = __webpack_require__(105); -var FromPercent = __webpack_require__(65); -var MATH_CONST = __webpack_require__(16); +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var DynamicTilemapLayerRender = __webpack_require__(414); +var GameObject = __webpack_require__(1); +var TilemapComponents = __webpack_require__(88); /** - * Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, - * based on the given quantity or stepRate values. + * @classdesc + * A DynamicTilemapLayer is a game object that renders LayerData from a Tilemap. A + * DynamicTilemapLayer can only render tiles from a single tileset. * - * @function Phaser.Geom.Circle.GetPoints + * A DynamicTilemapLayer trades some speed for being able to apply powerful effects. Unlike a + * StaticTilemapLayer, you can apply per-tile effects like tint or alpha, and you can change the + * tiles in a DynamicTilemapLayer. Use this over a StaticTilemapLayer when you need those + * features. + * + * @class DynamicTilemapLayer + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.Tilemaps + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Circle} circle - The Circle to get the points from. - * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param {number} [stepRate] - Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. - * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * @extends Phaser.GameObjects.Components.ScrollFactor * - * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the circumference of the circle. + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Tilemaps.Tilemap} tilemap - The Tilemap this layer is a part of. + * @param {integer} layerIndex - The index of the LayerData associated with this layer. + * @param {Phaser.Tilemaps.Tileset} tileset - The tileset used to render the tiles in this layer. + * @param {number} [x=0] - The world x position where the top left of this layer will be placed. + * @param {number} [y=0] - The world y position where the top left of this layer will be placed. */ -var GetPoints = function (circle, quantity, stepRate, out) -{ - if (out === undefined) { out = []; } +var DynamicTilemapLayer = new Class({ - // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. - if (!quantity) + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.Size, + Components.Transform, + Components.Visible, + Components.ScrollFactor, + DynamicTilemapLayerRender + ], + + initialize: + + function DynamicTilemapLayer (scene, tilemap, layerIndex, tileset, x, y) { - quantity = Circumference(circle) / stepRate; + GameObject.call(this, scene, 'DynamicTilemapLayer'); + + /** + * Used internally by physics system to perform fast type checks. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#isTilemap + * @type {boolean} + * @readOnly + * @since 3.0.0 + */ + this.isTilemap = true; + + /** + * The Tilemap that this layer is a part of. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#tilemap + * @type {Phaser.Tilemaps.Tilemap} + * @since 3.0.0 + */ + this.tilemap = tilemap; + + /** + * The index of the LayerData associated with this layer. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#layerIndex + * @type {integer} + * @since 3.0.0 + */ + this.layerIndex = layerIndex; + + /** + * The LayerData associated with this layer. LayerData can only be associated with one + * tilemap layer. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#layer + * @type {Phaser.Tilemaps.LayerData} + * @since 3.0.0 + */ + this.layer = tilemap.layers[layerIndex]; + + this.layer.tilemapLayer = this; // Link the LayerData with this static tilemap layer + + /** + * The Tileset associated with this layer. A tilemap layer can only render from one Tileset. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#tileset + * @type {Phaser.Tilemaps.Tileset} + * @since 3.0.0 + */ + this.tileset = tileset; + + /** + * Used internally with the canvas render. This holds the tiles that are visible within the + * camera. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#culledTiles + * @type {array} + * @since 3.0.0 + */ + this.culledTiles = []; + + this.setAlpha(this.layer.alpha); + this.setPosition(x, y); + this.setOrigin(); + this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height); + + this.initPipeline('TextureTintPipeline'); + }, + + /** + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#calculateFacesAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate. + * @param {integer} tileY - The y coordinate. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + calculateFacesAt: function (tileX, tileY) + { + TilemapComponents.CalculateFacesAt(tileX, tileY, this.layer); + + return this; + }, + + /** + * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the + * layer. Interesting faces are used internally for optimizing collisions against tiles. This method + * is mostly used internally. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#calculateFacesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + calculateFacesWithin: function (tileX, tileY, width, height) + { + TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#createFromTiles + * @since 3.0.0 + * + * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. + * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted + * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a + * one-to-one mapping with the indexes array. + * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. + * scene.make.sprite). + * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY + * + * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. + */ + createFromTiles: function (indexes, replacements, spriteConfig, scene, camera) + { + return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, this.layer); + }, + + /** + * Returns the tiles in the given layer that are within the cameras viewport. + * This is used internally. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#cull + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + cull: function (camera) + { + return TilemapComponents.CullTiles(this.layer, camera, this.culledTiles); + }, + + /** + * Copies the tiles in the source rectangular area to a new destination (all specified in tile + * coordinates) within the layer. This copies all tile properties & recalculates collision + * information in the destination region. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#copy + * @since 3.0.0 + * + * @param {integer} srcTileX - [description] + * @param {integer} srcTileY - [description] + * @param {integer} width - [description] + * @param {integer} height - [description] + * @param {integer} destTileX - [description] + * @param {integer} destTileY - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces) + { + TilemapComponents.Copy(srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, this.layer); + + return this; + }, + + /** + * Destroys this DynamicTilemapLayer and removes its link to the associated LayerData. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#destroy + * @since 3.0.0 + */ + destroy: function () + { + // Uninstall this layer only if it is still installed on the LayerData object + if (this.layer.tilemapLayer === this) + { + this.layer.tilemapLayer = undefined; + } + + this.tilemap = undefined; + this.layer = undefined; + this.tileset = undefined; + this.culledTiles.length = 0; + + GameObject.prototype.destroy.call(this); + }, + + /** + * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the + * specified index. Tiles will be set to collide if the given index is a colliding index. + * Collision information in the region will be recalculated. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#fill + * @since 3.0.0 + * + * @param {integer} index - [description] + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + fill: function (index, tileX, tileY, width, height, recalculateFaces) + { + TilemapComponents.Fill(index, tileX, tileY, width, height, recalculateFaces, this.layer); + + return this; + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#filterTiles + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#findByIndex + * @since 3.0.0 + * + * @param {integer} index - The tile index value to search for. + * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. + * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the + * bottom-right. Otherwise it scans from the top-left. + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + findByIndex: function (findIndex, skip, reverse) + { + return TilemapComponents.FindByIndex(findIndex, skip, reverse, this.layer); + }, + + /** + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#findTile + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {?Phaser.Tilemaps.Tile} + */ + findTile: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#forEachTile + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + + return this; + }, + + /** + * Gets a tile at the given tile coordinates from the given layer. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTileAt + * @since 3.0.0 + * + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). + * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile + * object with an index of -1. + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates were invalid. + */ + getTileAt: function (tileX, tileY, nonNull) + { + return TilemapComponents.GetTileAt(tileX, tileY, nonNull, this.layer); + }, + + /** + * Gets a tile at the given world coordinates from the given layer. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - X position to get the tile from (given in pixels) + * @param {number} worldY - Y position to get the tile from (given in pixels) + * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile + * object with an index of -1. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates + * were invalid. + */ + getTileAtWorldXY: function (worldX, worldY, nonNull, camera) + { + return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, this.layer); + }, + + /** + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithin: function (tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithinShape + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithinShape: function (shape, filteringOptions, camera) + { + return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, this.layer); + }, + + /** + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithinWorldXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera) + { + return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, this.layer); + }, + + /** + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#hasTileAt + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * + * @return {boolean} + */ + hasTileAt: function (tileX, tileY) + { + return TilemapComponents.HasTileAt(tileX, tileY, this.layer); + }, + + /** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#hasTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {boolean} + */ + hasTileAtWorldXY: function (worldX, worldY, camera) + { + return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, this.layer); + }, + + /** + * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index + * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified + * location. If you pass in an index, only the index at the specified location will be changed. + * Collision information will be recalculated at the specified location. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#putTileAt + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + putTileAt: function (tile, tileX, tileY, recalculateFaces) + { + return TilemapComponents.PutTileAt(tile, tileX, tileY, recalculateFaces, this.layer); + }, + + /** + * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either + * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the + * specified location. If you pass in an index, only the index at the specified location will be + * changed. Collision information will be recalculated at the specified location. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#putTileAtWorldXY + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} worldX - [description] + * @param {integer} worldY - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - [description] + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + putTileAtWorldXY: function (tile, worldX, worldY, recalculateFaces, camera) + { + return TilemapComponents.PutTileAtWorldXY(tile, worldX, worldY, recalculateFaces, camera, this.layer); + }, + + /** + * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified + * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, + * all attributes will be copied over to the specified location. If you pass in an index, only the + * index at the specified location will be changed. Collision information will be recalculated + * within the region tiles were changed. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#putTilesAt + * @since 3.0.0 + * + * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles + * or tile indexes to place. + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + putTilesAt: function (tilesArray, tileX, tileY, recalculateFaces) + { + TilemapComponents.PutTilesAt(tilesArray, tileX, tileY, recalculateFaces, this.layer); + + return this; + }, + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then + * those will be used for randomly assigning new tile indexes. If an array is not provided, the + * indexes found within the region (excluding -1) will be used for randomly assigning new tile + * indexes. This method only modifies tile indexes and does not change collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#randomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + randomize: function (tileX, tileY, width, height, indexes) + { + TilemapComponents.Randomize(tileX, tileY, width, height, indexes, this.layer); + + return this; + }, + + /** + * Removes the tile at the given tile coordinates in the specified layer and updates the layer's + * collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#removeTileAt + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified + * location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - [description] + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + removeTileAt: function (tileX, tileY, replaceWithNull, recalculateFaces) + { + return TilemapComponents.RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, this.layer); + }, + + /** + * Removes the tile at the given world coordinates in the specified layer and updates the layer's + * collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#removeTileAtWorldXY + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified + * location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + removeTileAtWorldXY: function (worldX, worldY, replaceWithNull, recalculateFaces, camera) + { + return TilemapComponents.RemoveTileAtWorldXY(worldX, worldY, replaceWithNull, recalculateFaces, camera, this.layer); + }, + + /** + * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#renderDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. + * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. + * @param {?Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at + * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. + * @param {?Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled + * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. + * @param {?Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting + * tile faces. If set to null, interesting tile faces will not be drawn. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + renderDebug: function (graphics, styleConfig) + { + TilemapComponents.RenderDebug(graphics, styleConfig, this.layer); + + return this; + }, + + /** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does + * not change collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#replaceByIndex + * @since 3.0.0 + * + * @param {integer} findIndex - [description] + * @param {integer} newIndex - [description] + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + replaceByIndex: function (findIndex, newIndex, tileX, tileY, width, height) + { + TilemapComponents.ReplaceByIndex(findIndex, newIndex, tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollision + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollision: function (indexes, collides, recalculateFaces) + { + TilemapComponents.SetCollision(indexes, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionBetween + * @since 3.0.0 + * + * @param {integer} start - The first index of the tile to be set for collision. + * @param {integer} stop - The last index of the tile to be set for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollisionBetween: function (start, stop, collides, recalculateFaces) + { + TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionByProperty + * @since 3.0.0 + * + * @param {object} properties - An object with tile properties and corresponding values that should + * be checked. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollisionByProperty: function (properties, collides, recalculateFaces) + { + TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionByExclusion + * @since 3.0.0 + * + * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollisionByExclusion: function (indexes, collides, recalculateFaces) + { + TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking each tiles collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tiles collision group, the tile's colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionFromCollisionGroup + * @since 3.0.0 + * + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollisionFromCollisionGroup: function (collides, recalculateFaces) + { + TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see setTileLocationCallback. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setTileIndexCallback + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a + * collision callback set for. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setTileIndexCallback: function (indexes, callback, callbackContext) + { + TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, this.layer); + + return this; + }, + + /** + * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setTileLocationCallback + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext) + { + TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, this.layer); + + return this; + }, + + /** + * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given + * layer. It will only randomize the tiles in that area, so if they're all the same nothing will + * appear to have changed! This method only modifies tile indexes and does not change collision + * information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#shuffle + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + shuffle: function (tileX, tileY, width, height) + { + TilemapComponents.Shuffle(tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision + * information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#swapByIndex + * @since 3.0.0 + * + * @param {integer} tileA - First tile index. + * @param {integer} tileB - Second tile index. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + swapByIndex: function (indexA, indexB, tileX, tileY, width, height) + { + TilemapComponents.SwapByIndex(indexA, indexB, tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldX + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + tileToWorldX: function (tileX, camera) + { + return TilemapComponents.TileToWorldX(tileX, camera, this.layer); + }, + + /** + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldY + * @since 3.0.0 + * + * @param {integer} tileY - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + tileToWorldY: function (tileY, camera) + { + return TilemapComponents.TileToWorldY(tileY, camera, this.layer); + }, + + /** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldXY + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {Phaser.Math.Vector2} [point] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Math.Vector2} + */ + tileToWorldXY: function (tileX, tileY, point, camera) + { + return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, this.layer); + }, + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will recieve a new index. New indexes are drawn from the given + * weightedIndexes array. An example weighted array: + * + * [ + * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 + * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 + * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 + * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 + * ] + * + * The probability of any index being choose is (the index's weight) / (sum of all weights). This + * method only modifies tile indexes and does not change collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#weightedRandomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during + * randomization. They should be in the form: { index: 0, weight: 4 } or + * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + weightedRandomize: function (tileX, tileY, width, height, weightedIndexes) + { + TilemapComponents.WeightedRandomize(tileX, tileY, width, height, weightedIndexes, this.layer); + + return this; + }, + + /** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileX + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + worldToTileX: function (worldX, snapToFloor, camera) + { + return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, this.layer); + }, + + /** + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileXY + * @since 3.0.0 + * + * @param {number} worldY - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + worldToTileY: function (worldY, snapToFloor, camera) + { + return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, this.layer); + }, + + /** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Math.Vector2} [point] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Math.Vector2} + */ + worldToTileXY: function (worldX, worldY, snapToFloor, point, camera) + { + return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, this.layer); } - for (var i = 0; i < quantity; i++) - { - var angle = FromPercent(i / quantity, 0, MATH_CONST.PI2); +}); - out.push(CircumferencePoint(circle, angle)); - } - - return out; -}; - -module.exports = GetPoints; +module.exports = DynamicTilemapLayer; /***/ }), /* 186 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -35489,22 +39842,2273 @@ module.exports = GetPoints; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var DegToRad = __webpack_require__(42); +var DynamicTilemapLayer = __webpack_require__(185); +var Extend = __webpack_require__(18); +var Formats = __webpack_require__(24); +var LayerData = __webpack_require__(66); +var Rotate = __webpack_require__(217); +var StaticTilemapLayer = __webpack_require__(184); +var Tile = __webpack_require__(45); +var TilemapComponents = __webpack_require__(88); +var Tileset = __webpack_require__(84); + /** - * Returns the circumference of the given Circle. + * @callback TilemapFilterCallback * - * @function Phaser.Geom.Circle.Circumference + * @param {Phaser.GameObjects.GameObject} value - [description] + * @param {number} index - [description] + * @param {Phaser.GameObjects.GameObject[]} array - [description] + * + * @return {Phaser.GameObjects.GameObject} [description] + */ + +/** + * @callback TilemapFindCallback + * + * @param {Phaser.GameObjects.GameObject} value - [description] + * @param {number} index - [description] + * @param {Phaser.GameObjects.GameObject[]} array - [description] + * + * @return {boolean} [description] + */ + +/** + * @classdesc + * A Tilemap is a container for Tilemap data. This isn't a display object, rather, it holds data + * about the map and allows you to add tilesets and tilemap layers to it. A map can have one or + * more tilemap layers (StaticTilemapLayer or DynamicTilemapLayer), which are the display + * objects that actually render tiles. + * + * The Tilemap data be parsed from a Tiled JSON file, a CSV file or a 2D array. Tiled is a free + * software package specifically for creating tile maps, and is available from: + * http://www.mapeditor.org + * + * A Tilemap has handy methods for getting & manipulating the tiles within a layer. You can only + * use the methods that change tiles (e.g. removeTileAt) on a DynamicTilemapLayer. + * + * Note that all Tilemaps use a base tile size to calculate dimensions from, but that a + * StaticTilemapLayer or DynamicTilemapLayer may have its own unique tile size that overrides + * it. + * + * @class Tilemap + * @memberOf Phaser.Tilemaps + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference of. - * - * @return {number} The circumference of the Circle. + * @param {Phaser.Scene} scene - The Scene to which this Tilemap belongs. + * @param {Phaser.Tilemaps.MapData} mapData - A MapData instance containing Tilemap data. */ -var Circumference = function (circle) -{ - return 2 * (Math.PI * circle.radius); -}; +var Tilemap = new Class({ -module.exports = Circumference; + initialize: + + function Tilemap (scene, mapData) + { + /** + * @name Phaser.Tilemaps.Tilemap#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * The base width of a tile in pixels. Note that individual layers may have a different tile + * width. + * + * @name Phaser.Tilemaps.Tilemap#tileWidth + * @type {integer} + * @since 3.0.0 + */ + this.tileWidth = mapData.tileWidth; + + /** + * The base height of a tile in pixels. Note that individual layers may have a different + * tile height. + * + * @name Phaser.Tilemaps.Tilemap#tileHeight + * @type {integer} + * @since 3.0.0 + */ + this.tileHeight = mapData.tileHeight; + + /** + * The width of the map (in tiles). + * + * @name Phaser.Tilemaps.Tilemap#width + * @type {number} + * @since 3.0.0 + */ + this.width = mapData.width; + + /** + * The height of the map (in tiles). + * + * @name Phaser.Tilemaps.Tilemap#height + * @type {number} + * @since 3.0.0 + */ + this.height = mapData.height; + + /** + * The orientation of the map data (as specified in Tiled), usually 'orthogonal'. + * + * @name Phaser.Tilemaps.Tilemap#orientation + * @type {string} + * @since 3.0.0 + */ + this.orientation = mapData.orientation; + + /** + * The format of the map data. + * + * @name Phaser.Tilemaps.Tilemap#format + * @type {number} + * @since 3.0.0 + */ + this.format = mapData.format; + + /** + * The version of the map data (as specified in Tiled, usually 1). + * + * @name Phaser.Tilemaps.Tilemap#version + * @type {number} + * @since 3.0.0 + */ + this.version = mapData.version; + + /** + * Map specific properties as specified in Tiled. + * + * @name Phaser.Tilemaps.Tilemap#properties + * @type {object} + * @since 3.0.0 + */ + this.properties = mapData.properties; + + /** + * The width of the map in pixels based on width * tileWidth. + * + * @name Phaser.Tilemaps.Tilemap#widthInPixels + * @type {number} + * @since 3.0.0 + */ + this.widthInPixels = mapData.widthInPixels; + + /** + * The height of the map in pixels based on height * tileHeight. + * + * @name Phaser.Tilemaps.Tilemap#heightInPixels + * @type {number} + * @since 3.0.0 + */ + this.heightInPixels = mapData.heightInPixels; + + /** + * + * @name Phaser.Tilemaps.Tilemap#imageCollections + * @type {Phaser.Tilemaps.ImageCollection[]} + * @since 3.0.0 + */ + this.imageCollections = mapData.imageCollections; + + /** + * An array of Tiled Image Layers. + * + * @name Phaser.Tilemaps.Tilemap#images + * @type {array} + * @since 3.0.0 + */ + this.images = mapData.images; + + /** + * An array of Tilemap layer data. + * + * @name Phaser.Tilemaps.Tilemap#layers + * @type {Phaser.Tilemaps.LayerData[]} + * @since 3.0.0 + */ + this.layers = mapData.layers; + + /** + * An array of Tilesets used in the map. + * + * @name Phaser.Tilemaps.Tilemap#tilesets + * @type {Phaser.Tilemaps.Tileset[]} + * @since 3.0.0 + */ + this.tilesets = mapData.tilesets; + + /** + * An array of ObjectLayer instances parsed from Tiled object layers. + * + * @name Phaser.Tilemaps.Tilemap#objects + * @type {Phaser.Tilemaps.ObjectLayer[]} + * @since 3.0.0 + */ + this.objects = mapData.objects; + + /** + * The index of the currently selected LayerData object. + * + * @name Phaser.Tilemaps.Tilemap#currentLayerIndex + * @type {integer} + * @since 3.0.0 + */ + this.currentLayerIndex = 0; + }, + + /** + * Adds an image to the map to be used as a tileset. A single map may use multiple tilesets. + * Note that the tileset name can be found in the JSON file exported from Tiled, or in the Tiled + * editor. + * + * @method Phaser.Tilemaps.Tilemap#addTilesetImage + * @since 3.0.0 + * + * @param {string} tilesetName - The name of the tileset as specified in the map data. + * @param {string} [key] - The key of the Phaser.Cache image used for this tileset. If + * `undefined` or `null` it will look for an image with a key matching the tileset parameter. + * @param {integer} [tileWidth] - The width of the tile (in pixels) in the Tileset Image. If not + * given it will default to the map's tileWidth value, or the tileWidth specified in the Tiled + * JSON file. + * @param {integer} [tileHeight] - The height of the tiles (in pixels) in the Tileset Image. If + * not given it will default to the map's tileHeight value, or the tileHeight specified in the + * Tiled JSON file. + * @param {integer} [tileMargin] - The margin around the tiles in the sheet (in pixels). If not + * specified, it will default to 0 or the value specified in the Tiled JSON file. + * @param {integer} [tileSpacing] - The spacing between each the tile in the sheet (in pixels). + * If not specified, it will default to 0 or the value specified in the Tiled JSON file. + * @param {integer} [gid=0] - If adding multiple tilesets to a blank map, specify the starting + * GID this set will use here. + * + * @return {?Phaser.Tilemaps.Tileset} Returns the Tileset object that was created or updated, or null if it + * failed. + */ + addTilesetImage: function (tilesetName, key, tileWidth, tileHeight, tileMargin, tileSpacing, gid) + { + if (tilesetName === undefined) { return null; } + if (key === undefined || key === null) { key = tilesetName; } + + if (!this.scene.sys.textures.exists(key)) + { + console.warn('Invalid image key given for tileset: "' + key + '"'); + return null; + } + + var texture = this.scene.sys.textures.get(key); + + var index = this.getTilesetIndex(tilesetName); + + if (index === null && this.format === Formats.TILED_JSON) + { + console.warn('No data found in the JSON tilemap from Tiled matching the tileset name: "' + tilesetName + '"'); + return null; + } + + if (this.tilesets[index]) + { + this.tilesets[index].setTileSize(tileWidth, tileHeight); + this.tilesets[index].setSpacing(tileMargin, tileSpacing); + this.tilesets[index].setImage(texture); + return this.tilesets[index]; + } + + if (tileWidth === undefined) { tileWidth = this.tileWidth; } + if (tileHeight === undefined) { tileHeight = this.tileHeight; } + if (tileMargin === undefined) { tileMargin = 0; } + if (tileSpacing === undefined) { tileSpacing = 0; } + if (gid === undefined) { gid = 0; } + + var tileset = new Tileset(tilesetName, gid, tileWidth, tileHeight, tileMargin, tileSpacing); + tileset.setImage(texture); + this.tilesets.push(tileset); + + return tileset; + }, + + /** + * Turns the StaticTilemapLayer associated with the given layer into a DynamicTilemapLayer. If + * no layer specified, the map's current layer is used. This is useful if you want to manipulate + * a map at the start of a scene, but then make it non-manipulable and optimize it for speed. + * Note: the DynamicTilemapLayer passed in is destroyed, so make sure to store the value + * returned from this method if you want to manipulate the new StaticTilemapLayer. + * + * @method Phaser.Tilemaps.Tilemap#convertLayerToStatic + * @since 3.0.0 + * + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer)} [layer] - The name of the layer from Tiled, the + * index of the layer in the map, or a DynamicTilemapLayer. + * + * @return {?Phaser.Tilemaps.StaticTilemapLayer} Returns the new layer that was created, or null if it + * failed. + */ + convertLayerToStatic: function (layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + var dynamicLayer = layer.tilemapLayer; + + if (!dynamicLayer || !(dynamicLayer instanceof DynamicTilemapLayer)) + { + return null; + } + + var staticLayer = new StaticTilemapLayer( + dynamicLayer.scene, + dynamicLayer.tilemap, + dynamicLayer.layerIndex, + dynamicLayer.tileset, + dynamicLayer.x, + dynamicLayer.y + ); + + this.scene.sys.displayList.add(staticLayer); + + dynamicLayer.destroy(); + + return staticLayer; + }, + + /** + * See component documentation. If no layer specified, the map's current layer is used. This + * cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#copy + * @since 3.0.0 + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'copy')) { return this; } + + if (layer !== null) + { + TilemapComponents.Copy( + srcTileX, srcTileY, + width, height, + destTileX, destTileY, + recalculateFaces, layer + ); + } + + return this; + }, + + /** + * Creates a new and empty DynamicTilemapLayer. The currently selected layer in the map is set + * to this new layer. + * + * @method Phaser.Tilemaps.Tilemap#createBlankDynamicLayer + * @since 3.0.0 + * + * @param {string} name - The name of this layer. Must be unique within the map. + * @param {Phaser.Tilemaps.Tileset} tileset - The tileset the new layer will use. + * @param {integer} width - The width of the layer in tiles. If not specified, it will default + * to the map's width. + * @param {integer} height - The height of the layer in tiles. If not specified, it will default + * to the map's height. + * @param {integer} tileWidth - The width of the tiles the layer uses for calculations. If not + * specified, it will default to the map's tileWidth. + * @param {integer} tileHeight - The height of the tiles the layer uses for calculations. If not + * specified, it will default to the map's tileHeight. + * @return {?Phaser.Tilemaps.DynamicTilemapLayer} Returns the new layer was created, or null if it failed. + */ + createBlankDynamicLayer: function (name, tileset, x, y, width, height, tileWidth, tileHeight) + { + if (tileWidth === undefined) { tileWidth = tileset.tileWidth; } + if (tileHeight === undefined) { tileHeight = tileset.tileHeight; } + if (width === undefined) { width = this.width; } + if (height === undefined) { height = this.height; } + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + var index = this.getLayerIndex(name); + + if (index !== null) + { + console.warn('Cannot create blank layer: layer with matching name already exists ' + name); + return null; + } + + var layerData = new LayerData({ + name: name, + tileWidth: tileWidth, + tileHeight: tileHeight, + width: width, + height: height + }); + + var row; + + for (var tileY = 0; tileY < height; tileY++) + { + row = []; + + for (var tileX = 0; tileX < width; tileX++) + { + row.push(new Tile(layerData, -1, tileX, tileY, tileWidth, tileHeight, this.tileWidth, this.tileHeight)); + } + + layerData.data.push(row); + } + + this.layers.push(layerData); + this.currentLayerIndex = this.layers.length - 1; + + var dynamicLayer = new DynamicTilemapLayer(this.scene, this, this.currentLayerIndex, tileset, x, y); + this.scene.sys.displayList.add(dynamicLayer); + + return dynamicLayer; + }, + + /** + * Creates a new DynamicTilemapLayer that renders the LayerData associated with the given + * `layerID`. The currently selected layer in the map is set to this new layer. + * + * The `layerID` is important. If you've created your map in Tiled then you can get this by + * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and + * look at the layers[].name value. Either way it must match. + * + * Unlike a static layer, a dynamic layer can be modified. See DynamicTilemapLayer for more + * information. + * + * @method Phaser.Tilemaps.Tilemap#createDynamicLayer + * @since 3.0.0 + * + * @param {(integer|string)} layerID - The layer array index value, or if a string is given, the + * layer name from Tiled. + * @param {Phaser.Tilemaps.Tileset} tileset - The tileset the new layer will use. + * @param {number} x - The x position to place the layer in the world. If not specified, it will + * default to the layer offset from Tiled or 0. + * @param {number} y - The y position to place the layer in the world. If not specified, it will + * default to the layer offset from Tiled or 0. + * + * @return {?Phaser.Tilemaps.DynamicTilemapLayer} Returns the new layer was created, or null if it failed. + */ + createDynamicLayer: function (layerID, tileset, x, y) + { + var index = this.getLayerIndex(layerID); + + if (index === null) + { + console.warn('Cannot create tilemap layer, invalid layer ID given: ' + layerID); + return null; + } + + var layerData = this.layers[index]; + + // Check for an associated static or dynamic tilemap layer + if (layerData.tilemapLayer) + { + console.warn('Cannot create dynamic tilemap layer since a static or dynamic tilemap layer exists for layer ID:' + layerID); + return null; + } + + this.currentLayerIndex = index; + + // Make sure that all the LayerData & the tiles have the correct tile size. They usually + // are, but wouldn't match if you try to load a 2x or 4x res tileset when the map was made + // with a 1x res tileset. + if (layerData.tileWidth !== tileset.tileWidth || layerData.tileHeight !== tileset.tileHeight) + { + this.setLayerTileSize(tileset.tileWidth, tileset.tileHeight, index); + } + + // Default the x/y position to match Tiled layer offset, if it exists. + if (x === undefined && this.layers[index].x) { x = this.layers[index].x; } + if (y === undefined && this.layers[index].y) { y = this.layers[index].y; } + + var layer = new DynamicTilemapLayer(this.scene, this, index, tileset, x, y); + this.scene.sys.displayList.add(layer); + + return layer; + }, + + /** + * Creates a Sprite for every object matching the given gid in the map data. All properties from + * the map data objectgroup are copied into the `spriteConfig`, so you can use this as an easy + * way to configure Sprite properties from within the map editor. For example giving an object a + * property of alpha: 0.5 in the map editor will duplicate that when the Sprite is created. + * + * @method Phaser.Tilemaps.Tilemap#createFromObjects + * @since 3.0.0 + * + * @param {string} name - The name of the object layer (from Tiled) to create Sprites from. + * @param {(integer|string)} id - Either the id (object), gid (tile object) or name (object or + * tile object) from Tiled. Ids are unique in Tiled, but a gid is shared by all tile objects + * with the same graphic. The same name can be used on multiple objects. + * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. + * scene.make.sprite). + * @param {Phaser.Scene} [scene=the scene the map is within] - The Scene to create the Sprites within. + * + * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. + */ + createFromObjects: function (name, id, spriteConfig, scene) + { + if (spriteConfig === undefined) { spriteConfig = {}; } + if (scene === undefined) { scene = this.scene; } + + var objectLayer = this.getObjectLayer(name); + if (!objectLayer) + { + console.warn('Cannot create from object. Invalid objectgroup name given: ' + name); + return; + } + + var objects = objectLayer.objects; + var sprites = []; + + for (var i = 0; i < objects.length; i++) + { + var found = false; + var obj = objects[i]; + + if (obj.gid !== undefined && typeof id === 'number' && obj.gid === id || + obj.id !== undefined && typeof id === 'number' && obj.id === id || + obj.name !== undefined && typeof id === 'string' && obj.name === id) + { + found = true; + } + + if (found) + { + var config = Extend({}, spriteConfig, obj.properties); + + config.x = obj.x; + config.y = obj.y; + + var sprite = this.scene.make.sprite(config); + + sprite.name = obj.name; + + if (obj.width) { sprite.displayWidth = obj.width; } + if (obj.height) { sprite.displayHeight = obj.height; } + + // Origin is (0, 1) in Tiled, so find the offset that matches the Sprite's origin. + var offset = { + x: sprite.originX * sprite.displayWidth, + y: (sprite.originY - 1) * sprite.displayHeight + }; + + // If the object is rotated, then the origin offset also needs to be rotated. + if (obj.rotation) + { + var angle = DegToRad(obj.rotation); + Rotate(offset, angle); + sprite.rotation = angle; + } + + sprite.x += offset.x; + sprite.y += offset.y; + + if (obj.flippedHorizontal !== undefined || obj.flippedVertical !== undefined) + { + sprite.setFlip(obj.flippedHorizontal, obj.flippedVertical); + } + + if (!obj.visible) { sprite.visible = false; } + + sprites.push(sprite); + } + } + + return sprites; + }, + + /** + * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. + * + * @method Phaser.Tilemaps.Tilemap#createFromTiles + * @since 3.0.0 + * + * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. + * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted + * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a + * one-to-one mapping with the indexes array. + * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. + * scene.make.sprite). + * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.GameObjects.Sprite[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + createFromTiles: function (indexes, replacements, spriteConfig, scene, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, layer); + }, + + /** + * Creates a new StaticTilemapLayer that renders the LayerData associated with the given + * `layerID`. The currently selected layer in the map is set to this new layer. + * + * The `layerID` is important. If you've created your map in Tiled then you can get this by + * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and + * look at the layers[].name value. Either way it must match. + * + * It's important to remember that a static layer cannot be modified. See StaticTilemapLayer for + * more information. + * + * @method Phaser.Tilemaps.Tilemap#createStaticLayer + * @since 3.0.0 + * + * @param {(integer|string)} layerID - The layer array index value, or if a string is given, the + * layer name from Tiled. + * @param {Phaser.Tilemaps.Tileset} tileset - The tileset the new layer will use. + * @param {number} x - The x position to place the layer in the world. If not specified, it will + * default to the layer offset from Tiled or 0. + * @param {number} y - The y position to place the layer in the world. If not specified, it will + * default to the layer offset from Tiled or 0. + * + * @return {?Phaser.Tilemaps.StaticTilemapLayer} Returns the new layer was created, or null if it failed. + */ + createStaticLayer: function (layerID, tileset, x, y) + { + var index = this.getLayerIndex(layerID); + + if (index === null) + { + console.warn('Cannot create tilemap layer, invalid layer ID given: ' + layerID); + return null; + } + + var layerData = this.layers[index]; + + // Check for an associated static or dynamic tilemap layer + if (layerData.tilemapLayer) + { + console.warn('Cannot create static tilemap layer since a static or dynamic tilemap layer exists for layer ID:' + layerID); + return null; + } + + this.currentLayerIndex = index; + + // Make sure that all the LayerData & the tiles have the correct tile size. They usually + // are, but wouldn't match if you try to load a 2x or 4x res tileset when the map was made + // with a 1x res tileset. + if (layerData.tileWidth !== tileset.tileWidth || layerData.tileHeight !== tileset.tileHeight) + { + this.setLayerTileSize(tileset.tileWidth, tileset.tileHeight, index); + } + + // Default the x/y position to match Tiled layer offset, if it exists. + if (x === undefined && this.layers[index].x) { x = this.layers[index].x; } + if (y === undefined && this.layers[index].y) { y = this.layers[index].y; } + + var layer = new StaticTilemapLayer(this.scene, this, index, tileset, x, y); + this.scene.sys.displayList.add(layer); + + return layer; + }, + + /** + * Removes all layer data from this Tilemap and nulls the scene reference. This will destroy any + * StaticTilemapLayers or DynamicTilemapLayers that have been linked to LayerData. + * + * @method Phaser.Tilemaps.Tilemap#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.removeAllLayers(); + this.tilesets.length = 0; + this.objects.length = 0; + this.scene = undefined; + }, + + /** + * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the + * specified index. Tiles will be set to collide if the given index is a colliding index. + * Collision information in the region will be recalculated. + * + * If no layer specified, the map's current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#fill + * @since 3.0.0 + * + * @param {integer} index - [description] + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + fill: function (index, tileX, tileY, width, height, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'fill')) { return this; } + + if (layer !== null) + { + TilemapComponents.Fill(index, tileX, tileY, width, height, recalculateFaces, layer); + } + + return this; + }, + + /** + * For each object in the given object layer, run the given filter callback function. Any + * objects that pass the filter test (i.e. where the callback returns true) will returned as a + * new array. Similar to Array.prototype.Filter in vanilla JS. + * + * @method Phaser.Tilemaps.Tilemap#filterObjects + * @since 3.0.0 + * + * @param {(Phaser.Tilemaps.ObjectLayer|string)} [objectLayer] - The name of an object layer (from Tiled) or an + * ObjectLayer instance. + * @param {TilemapFilterCallback} callback - The callback. Each object in the given area will be passed to + * this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * + * @return {?Phaser.GameObjects.GameObject[]} An array of object that match the search, or null if the objectLayer + * given was invalid. + */ + filterObjects: function (objectLayer, callback, context) + { + if (typeof objectLayer === 'string') + { + var name = objectLayer; + + objectLayer = this.getObjectLayer(objectLayer); + + if (!objectLayer) + { + console.warn('No object layer found with the name: ' + name); + return null; + } + } + + return objectLayer.objects.filter(callback, context); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#filterTiles + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, layer); + }, + + /** + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#findByIndex + * @since 3.0.0 + * + * @param {integer} index - The tile index value to search for. + * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. + * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the + * bottom-right. Otherwise it scans from the top-left. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tiles, or null if the layer given was invalid. + */ + findByIndex: function (findIndex, skip, reverse, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.FindByIndex(findIndex, skip, reverse, layer); + }, + + /** + * Find the first object in the given object layer that satisfies the provided testing function. + * I.e. finds the first object for which `callback` returns true. Similar to + * Array.prototype.find in vanilla JS. + * + * @method Phaser.Tilemaps.Tilemap#findObject + * @since 3.0.0 + * + * @param {(Phaser.Tilemaps.ObjectLayer|string)} [objectLayer] - The name of an object layer (from Tiled) or an + * ObjectLayer instance. + * @param {TilemapFindCallback} callback - The callback. Each object in the given area will be passed to + * this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * + * @return {?Phaser.GameObjects.GameObject} An object that matches the search, or null if no object found + */ + findObject: function (objectLayer, callback, context) + { + if (typeof objectLayer === 'string') + { + var name = objectLayer; + + objectLayer = this.getObjectLayer(objectLayer); + + if (!objectLayer) + { + console.warn('No object layer found with the name: ' + name); + return null; + } + } + + return objectLayer.objects.find(callback, context) || null; + }, + + /** + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#findTile + * @since 3.0.0 + * + * @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tiles, or null if the layer given was invalid. + */ + findTile: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, layer); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#forEachTile + * @since 3.0.0 + * + * @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) + { + layer = this.getLayer(layer); + + if (layer !== null) + { + TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, layer); + } + + return this; + }, + + /** + * Gets the image layer index based on its name. + * + * @method Phaser.Tilemaps.Tilemap#getImageIndex + * @since 3.0.0 + * + * @param {string} name - The name of the image to get. + * + * @return {integer} The index of the image in this tilemap, or null if not found. + */ + getImageIndex: function (name) + { + return this.getIndex(this.images, name); + }, + + /** + * Internally used. Returns the index of the object in one of the Tilemaps arrays whose name + * property matches the given `name`. + * + * @method Phaser.Tilemaps.Tilemap#getIndex + * @since 3.0.0 + * + * @param {array} location - The Tilemap array to search. + * @param {string} name - The name of the array element to get. + * + * @return {number} The index of the element in the array, or null if not found. + */ + getIndex: function (location, name) + { + for (var i = 0; i < location.length; i++) + { + if (location[i].name === name) + { + return i; + } + } + + return null; + }, + + /** + * Gets the LayerData from this.layers that is associated with `layer`, or null if an invalid + * `layer` is given. + * + * @method Phaser.Tilemaps.Tilemap#getLayer + * @since 3.0.0 + * + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the maps current layer index. + * + * @return {Phaser.Tilemaps.LayerData} The corresponding LayerData within this.layers. + */ + getLayer: function (layer) + { + var index = this.getLayerIndex(layer); + + return index !== null ? this.layers[index] : null; + }, + + /** + * Gets the ObjectLayer from this.objects that has the given `name`, or null if no ObjectLayer + * is found with that name. + * + * @method Phaser.Tilemaps.Tilemap#getObjectLayer + * @since 3.0.0 + * + * @param {string} [name] - The name of the object layer from Tiled. + * + * @return {?Phaser.Tilemaps.ObjectLayer} The corresponding ObjectLayer within this.objects or null. + */ + getObjectLayer: function (name) + { + var index = this.getIndex(this.objects, name); + + return index !== null ? this.objects[index] : null; + }, + + /** + * Gets the LayerData index of the given `layer` within this.layers, or null if an invalid + * `layer` is given. + * + * @method Phaser.Tilemaps.Tilemap#getLayerIndex + * @since 3.0.0 + * + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the map's current layer index. + * + * @return {integer} The LayerData index within this.layers. + */ + getLayerIndex: function (layer) + { + if (layer === undefined) + { + return this.currentLayerIndex; + } + else if (typeof layer === 'string') + { + return this.getLayerIndexByName(layer); + } + else if (typeof layer === 'number' && layer < this.layers.length) + { + return layer; + } + else if (layer instanceof StaticTilemapLayer || layer instanceof DynamicTilemapLayer) + { + return layer.layerIndex; + } + else + { + return null; + } + }, + + /** + * Gets the index of the LayerData within this.layers that has the given `name`, or null if an + * invalid `name` is given. + * + * @method Phaser.Tilemaps.Tilemap#getLayerIndexByName + * @since 3.0.0 + * + * @param {string} name - The name of the layer to get. + * + * @return {integer} The LayerData index within this.layers. + */ + getLayerIndexByName: function (name) + { + return this.getIndex(this.layers, name); + }, + + /** + * Gets a tile at the given tile coordinates from the given layer. + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTileAt + * @since 3.0.0 + * + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). + * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile + * object with an index of -1. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + getTileAt: function (tileX, tileY, nonNull, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.GetTileAt(tileX, tileY, nonNull, layer); + }, + + /** + * Gets a tile at the given world coordinates from the given layer. + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - X position to get the tile from (given in pixels) + * @param {number} worldY - Y position to get the tile from (given in pixels) + * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile + * object with an index of -1. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + getTileAtWorldXY: function (worldX, worldY, nonNull, camera, layer) + { + layer = this.getLayer(layer); + + + if (layer === null) { return null; } + + return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, layer); + }, + + /** + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTilesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + getTilesWithin: function (tileX, tileY, width, height, filteringOptions, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); + }, + + /** + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTilesWithinShape + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + getTilesWithinShape: function (shape, filteringOptions, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, layer); + }, + + /** + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTilesWithinWorldXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, layer); + }, + + /** + * Gets the index of the Tileset within this.tilesets that has the given `name`, or null if an + * invalid `name` is given. + * + * @method Phaser.Tilemaps.Tilemap#getTilesetIndex + * @since 3.0.0 + * + * @param {string} name - The name of the Tileset to get. + * + * @return {integer} The Tileset index within this.tilesets. + */ + getTilesetIndex: function (name) + { + return this.getIndex(this.tilesets, name); + }, + + /** + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#hasTileAt + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?boolean} Returns a boolean, or null if the layer given was invalid. + */ + hasTileAt: function (tileX, tileY, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.HasTileAt(tileX, tileY, layer); + }, + + /** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#hasTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?boolean} Returns a boolean, or null if the layer given was invalid. + */ + hasTileAtWorldXY: function (worldX, worldY, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, layer); + }, + + /** + * The LayerData object that is currently selected in the map. You can set this property using + * any type supported by setLayer. + * + * @name Phaser.Tilemaps.Tilemap#layer + * @type {Phaser.Tilemaps.LayerData} + * @since 3.0.0 + */ + layer: { + get: function () + { + return this.layers[this.currentLayerIndex]; + }, + + set: function (layer) + { + this.setLayer(layer); + } + }, + + /** + * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index + * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified + * location. If you pass in an index, only the index at the specified location will be changed. + * Collision information will be recalculated at the specified location. + * + * If no layer specified, the maps current layer is used. + * + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#putTileAt + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + putTileAt: function (tile, tileX, tileY, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'putTileAt')) { return null; } + + if (layer === null) { return null; } + + return TilemapComponents.PutTileAt(tile, tileX, tileY, recalculateFaces, layer); + }, + + /** + * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either + * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the + * specified location. If you pass in an index, only the index at the specified location will be + * changed. Collision information will be recalculated at the specified location. + * + * If no layer specified, the maps current layer is used. This + * cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#putTileAtWorldXY + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} worldX - [description] + * @param {integer} worldY - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + putTileAtWorldXY: function (tile, worldX, worldY, recalculateFaces, camera, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'putTileAtWorldXY')) { return null; } + + if (layer === null) { return null; } + + return TilemapComponents.PutTileAtWorldXY(tile, worldX, worldY, recalculateFaces, camera, layer); + }, + + /** + * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified + * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, + * all attributes will be copied over to the specified location. If you pass in an index, only the + * index at the specified location will be changed. Collision information will be recalculated + * within the region tiles were changed. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#putTilesAt + * @since 3.0.0 + * + * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles + * or tile indexes to place. + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + putTilesAt: function (tilesArray, tileX, tileY, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'putTilesAt')) { return this; } + + if (layer !== null) + { + TilemapComponents.PutTilesAt(tilesArray, tileX, tileY, recalculateFaces, layer); + } + + return this; + }, + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will recieve a new index. If an array of indexes is passed in, then + * those will be used for randomly assigning new tile indexes. If an array is not provided, the + * indexes found within the region (excluding -1) will be used for randomly assigning new tile + * indexes. This method only modifies tile indexes and does not change collision information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#randomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + randomize: function (tileX, tileY, width, height, indexes, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'randomize')) { return this; } + + if (layer !== null) + { + TilemapComponents.Randomize(tileX, tileY, width, height, indexes, layer); + } + + return this; + }, + + /** + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#calculateFacesAt + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + calculateFacesAt: function (tileX, tileY, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.CalculateFacesAt(tileX, tileY, layer); + + return this; + }, + + /** + * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the + * layer. Interesting faces are used internally for optimizing collisions against tiles. This method + * is mostly used internally. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#calculateFacesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + calculateFacesWithin: function (tileX, tileY, width, height, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, layer); + + return this; + }, + + /** + * Removes all layers from this Tilemap and destroys any associated StaticTilemapLayers or + * DynamicTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#removeAllLayers + * @since 3.0.0 + * + * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. + */ + removeAllLayers: function () + { + // Destroy any StaticTilemapLayers or DynamicTilemapLayers that are stored in LayerData + for (var i = 0; i < this.layers.length; i++) + { + if (this.layers[i].tilemapLayer) + { + this.layers[i].tilemapLayer.destroy(); + } + } + + this.layers.length = 0; + this.currentLayerIndex = 0; + + return this; + }, + + /** + * Removes the tile at the given tile coordinates in the specified layer and updates the layer's + * collision information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#removeTileAt + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified + * location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + removeTileAt: function (tileX, tileY, replaceWithNull, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'removeTileAt')) { return null; } + + if (layer === null) { return null; } + + return TilemapComponents.RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, layer); + }, + + /** + * Removes the tile at the given world coordinates in the specified layer and updates the layer's + * collision information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#removeTileAtWorldXY + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified + * location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + removeTileAtWorldXY: function (worldX, worldY, replaceWithNull, recalculateFaces, camera, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'removeTileAtWorldXY')) { return null; } + + if (layer === null) { return null; } + + return TilemapComponents.RemoveTileAtWorldXY(worldX, worldY, replaceWithNull, recalculateFaces, camera, layer); + }, + + /** + * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#renderDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. + * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. + * @param {?Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at + * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. + * @param {?Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled + * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. + * @param {?Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting + * tile faces. If set to null, interesting tile faces will not be drawn. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + renderDebug: function (graphics, styleConfig, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.RenderDebug(graphics, styleConfig, layer); + + return this; + }, + + /** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does + * not change collision information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#replaceByIndex + * @since 3.0.0 + * + * @param {integer} findIndex - [description] + * @param {integer} newIndex - [description] + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + replaceByIndex: function (findIndex, newIndex, tileX, tileY, width, height, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'replaceByIndex')) { return this; } + + if (layer !== null) + { + TilemapComponents.ReplaceByIndex(findIndex, newIndex, tileX, tileY, width, height, layer); + } + + return this; + }, + + /** + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollision + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollision: function (indexes, collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollision(indexes, collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollisionBetween + * @since 3.0.0 + * + * @param {integer} start - The first index of the tile to be set for collision. + * @param {integer} stop - The last index of the tile to be set for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollisionBetween: function (start, stop, collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollisionByProperty + * @since 3.0.0 + * + * @param {object} properties - An object with tile properties and corresponding values that should + * be checked. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollisionByProperty: function (properties, collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollisionByExclusion + * @since 3.0.0 + * + * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollisionByExclusion: function (indexes, collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking each tile's collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tile's collision group, the tile's colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollisionFromCollisionGroup + * @since 3.0.0 + * + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollisionFromCollisionGroup: function (collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see setTileLocationCallback. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setTileIndexCallback + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a + * collision callback set for. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setTileIndexCallback: function (indexes, callback, callbackContext, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, layer); + + return this; + }, + + /** + * Sets a collision callback for the given rectangular area (in tile coordindates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setTileLocationCallback + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, layer); + + return this; + }, + + /** + * Sets the current layer to the LayerData associated with `layer`. + * + * @method Phaser.Tilemaps.Tilemap#setLayer + * @since 3.0.0 + * + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the map's current layer index. + * + * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. + */ + setLayer: function (layer) + { + var index = this.getLayerIndex(layer); + + if (index !== null) + { + this.currentLayerIndex = index; + } + + return this; + }, + + /** + * Sets the base tile size for the map. Note: this does not necessarily match the tileWidth and + * tileHeight for all layers. This also updates the base size on all tiles across all layers. + * + * @method Phaser.Tilemaps.Tilemap#setBaseTileSize + * @since 3.0.0 + * + * @param {integer} tileWidth - The width of the tiles the map uses for calculations. + * @param {integer} tileHeight - The height of the tiles the map uses for calculations. + * + * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. + */ + setBaseTileSize: function (tileWidth, tileHeight) + { + this.tileWidth = tileWidth; + this.tileHeight = tileHeight; + this.widthInPixels = this.width * tileWidth; + this.heightInPixels = this.height * tileHeight; + + // Update the base tile size on all layers & tiles + for (var i = 0; i < this.layers.length; i++) + { + this.layers[i].baseWidth = tileWidth; + this.layers[i].baseHeight = tileHeight; + + var mapData = this.layers[i].data; + var mapWidth = this.layers[i].width; + var mapHeight = this.layers[i].height; + + for (var row = 0; row < mapHeight; ++row) + { + for (var col = 0; col < mapWidth; ++col) + { + var tile = mapData[row][col]; + + if (tile !== null) + { + tile.setSize(undefined, undefined, tileWidth, tileHeight); + } + } + } + } + + return this; + }, + + /** + * Sets the tile size for a specific `layer`. Note: this does not necessarily match the map's + * tileWidth and tileHeight for all layers. This will set the tile size for the layer and any + * tiles the layer has. + * + * @method Phaser.Tilemaps.Tilemap#setLayerTileSize + * @since 3.0.0 + * + * @param {integer} tileWidth - The width of the tiles (in pixels) in the layer. + * @param {integer} tileHeight - The height of the tiles (in pixels) in the layer. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the map's current layer index. + * + * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. + */ + setLayerTileSize: function (tileWidth, tileHeight, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + layer.tileWidth = tileWidth; + layer.tileHeight = tileHeight; + + var mapData = layer.data; + var mapWidth = layer.width; + var mapHeight = layer.height; + + for (var row = 0; row < mapHeight; ++row) + { + for (var col = 0; col < mapWidth; ++col) + { + var tile = mapData[row][col]; + + if (tile !== null) { tile.setSize(tileWidth, tileHeight); } + } + } + + return this; + }, + + /** + * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given + * layer. It will only randomize the tiles in that area, so if they're all the same nothing will + * appear to have changed! This method only modifies tile indexes and does not change collision + * information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#shuffle + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + shuffle: function (tileX, tileY, width, height, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'shuffle')) { return this; } + + if (layer !== null) + { + TilemapComponents.Shuffle(tileX, tileY, width, height, layer); + } + + return this; + }, + + /** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision + * information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#swapByIndex + * @since 3.0.0 + * + * @param {integer} tileA - First tile index. + * @param {integer} tileB - Second tile index. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + swapByIndex: function (indexA, indexB, tileX, tileY, width, height, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'swapByIndex')) { return this; } + + if (layer !== null) + { + TilemapComponents.SwapByIndex(indexA, indexB, tileX, tileY, width, height, layer); + } + + return this; + }, + + /** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#tileToWorldX + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?number} Returns a number, or null if the layer given was invalid. + */ + tileToWorldX: function (tileX, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.TileToWorldX(tileX, camera, layer); + }, + + /** + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#tileToWorldY + * @since 3.0.0 + * + * @param {integer} tileY - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?number} Returns a number, or null if the layer given was invalid. + */ + tileToWorldY: function (tileX, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.TileToWorldY(tileX, camera, layer); + }, + + /** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#tileToWorldXY + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {Phaser.Math.Vector2} [point] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Math.Vector2} Returns a point, or null if the layer given was invalid. + */ + tileToWorldXY: function (tileX, tileY, point, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, layer); + }, + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. New indexes are drawn from the given + * weightedIndexes array. An example weighted array: + * + * [ + * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 + * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 + * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 + * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 + * ] + * + * The probability of any index being choose is (the index's weight) / (sum of all weights). This + * method only modifies tile indexes and does not change collision information. + * + * If no layer specified, the map's current layer is used. This + * cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#weightedRandomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during + * randomization. They should be in the form: { index: 0, weight: 4 } or + * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + weightedRandomize: function (tileX, tileY, width, height, weightedIndexes, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'weightedRandomize')) { return this; } + + if (layer !== null) + { + TilemapComponents.WeightedRandomize(tileX, tileY, width, height, weightedIndexes, layer); + } + + return this; + }, + + /** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#worldToTileX + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?number} Returns a number, or null if the layer given was invalid. + */ + worldToTileX: function (worldX, snapToFloor, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, layer); + }, + + /** + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#worldToTileY + * @since 3.0.0 + * + * @param {number} worldY - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?number} Returns a number, or null if the layer given was invalid. + */ + worldToTileY: function (worldY, snapToFloor, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, layer); + }, + + /** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#worldToTileXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Math.Vector2} [point] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Math.Vector2} Returns a point, or null if the layer given was invalid. + */ + worldToTileXY: function (worldX, worldY, snapToFloor, point, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, layer); + }, + + /** + * Used internally to check if a layer is static and prints out a warning. + * + * @method Phaser.Tilemaps.Tilemap#_isStaticCall + * @private + * @since 3.0.0 + * + * @return {boolean} + */ + _isStaticCall: function (layer, functionName) + { + if (layer.tilemapLayer instanceof StaticTilemapLayer) + { + console.warn(functionName + ': You cannot change the tiles in a static tilemap layer'); + return true; + } + else + { + return false; + } + } + +}); + +module.exports = Tilemap; /***/ }), @@ -35517,51 +42121,66 @@ module.exports = Circumference; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetPoint = __webpack_require__(107); -var Perimeter = __webpack_require__(78); - -// Return an array of points from the perimeter of the rectangle -// each spaced out based on the quantity or step required +var Formats = __webpack_require__(24); +var MapData = __webpack_require__(65); +var ParseTileLayers = __webpack_require__(416); +var ParseTilesets = __webpack_require__(415); /** - * [description] + * Parses a Weltmeister JSON object into a new MapData object. * - * @function Phaser.Geom.Rectangle.GetPoints + * @function Phaser.Tilemaps.Parsers.Impact.ParseWeltmeister * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rectangle - [description] - * @param {number} step - [description] - * @param {integer} quantity - [description] - * @param {array} [out] - [description] + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {object} json - The Weltmeister JSON object. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. * - * @return {Phaser.Geom.Point[]} [description] + * @return {?object} [description] */ -var GetPoints = function (rectangle, quantity, stepRate, out) +var ParseWeltmeister = function (name, json, insertNull) { - if (out === undefined) { out = []; } - - // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. - if (!quantity) + if (json.layer.length === 0) { - quantity = Perimeter(rectangle) / stepRate; + console.warn('No layers found in the Weltmeister map: ' + name); + return null; } - for (var i = 0; i < quantity; i++) - { - var position = i / quantity; + var width = 0; + var height = 0; - out.push(GetPoint(rectangle, position)); + for (var i = 0; i < json.layer.length; i++) + { + if (json.layer[i].width > width) { width = json.layer[i].width; } + if (json.layer[i].height > height) { height = json.layer[i].height; } } - return out; + var mapData = new MapData({ + width: width, + height: height, + name: name, + tileWidth: json.layer[0].tilesize, + tileHeight: json.layer[0].tilesize, + format: Formats.WELTMEISTER + }); + + mapData.layers = ParseTileLayers(json, insertNull); + mapData.tilesets = ParseTilesets(json); + + return mapData; }; -module.exports = GetPoints; +module.exports = ParseWeltmeister; /***/ }), /* 188 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -35569,39 +42188,105 @@ module.exports = GetPoints; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(2); + /** - * [description] + * @classdesc + * A class for representing a Tiled object layer in a map. This mirrors the structure of a Tiled + * object layer, except: + * - "x" & "y" properties are ignored since these cannot be changed in Tiled. + * - "offsetx" & "offsety" are applied to the individual object coordinates directly, so they + * are ignored as well. + * - "draworder" is ignored. * - * @function Phaser.Math.RotateAround + * @class ObjectLayer + * @memberOf Phaser.Tilemaps + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Point|object} point - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Point} [description] + * @param {object} [config] - [description] */ -var RotateAround = function (point, x, y, angle) -{ - var c = Math.cos(angle); - var s = Math.sin(angle); +var ObjectLayer = new Class({ - var tx = point.x - x; - var ty = point.y - y; + initialize: - point.x = tx * c - ty * s + x; - point.y = tx * s + ty * c + y; + function ObjectLayer (config) + { + if (config === undefined) { config = {}; } - return point; -}; + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#name + * @type {string} + * @since 3.0.0 + */ + this.name = GetFastValue(config, 'name', 'object layer'); -module.exports = RotateAround; + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#opacity + * @type {number} + * @since 3.0.0 + */ + this.opacity = GetFastValue(config, 'opacity', 1); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#properties + * @type {object} + * @since 3.0.0 + */ + this.properties = GetFastValue(config, 'properties', {}); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#propertyTypes + * @type {object} + * @since 3.0.0 + */ + this.propertyTypes = GetFastValue(config, 'propertytypes', {}); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#type + * @type {string} + * @since 3.0.0 + */ + this.type = GetFastValue(config, 'type', 'objectgroup'); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#visible + * @type {boolean} + * @since 3.0.0 + */ + this.visible = GetFastValue(config, 'visible', true); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#objects + * @type {Phaser.GameObjects.GameObject[]} + * @since 3.0.0 + */ + this.objects = GetFastValue(config, 'objects', []); + } + +}); + +module.exports = ObjectLayer; /***/ }), /* 189 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -35609,123 +42294,76 @@ module.exports = RotateAround; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Pick = __webpack_require__(420); +var ParseGID = __webpack_require__(191); + +var copyPoints = function (p) { return { x: p.x, y: p.y }; }; + +var commonObjectProps = [ 'id', 'name', 'type', 'rotation', 'properties', 'visible', 'x', 'y', 'width', 'height' ]; + /** - * Provides methods used for setting the WebGL rendering pipeline of a Game Object. - * - * @name Phaser.GameObjects.Components.Pipeline - * @webglOnly + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseObject * @since 3.0.0 + * + * @param {object} tiledObject - [description] + * @param {number} [offsetX=0] - [description] + * @param {number} [offsetY=0] - [description] + * + * @return {object} [description] */ +var ParseObject = function (tiledObject, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } -var Pipeline = { - - /** - * [description] - * - * @name Phaser.GameObjects.Components.Pipeline#defaultPipeline - * @type {Phaser.Renderer.WebGL.WebGLPipeline} - * @default null - * @webglOnly - * @since 3.0.0 - */ - defaultPipeline: null, + var parsedObject = Pick(tiledObject, commonObjectProps); - /** - * [description] - * - * @name Phaser.GameObjects.Components.Pipeline#pipeline - * @type {Phaser.Renderer.WebGL.WebGLPipeline} - * @default null - * @webglOnly - * @since 3.0.0 - */ - pipeline: null, + parsedObject.x += offsetX; + parsedObject.y += offsetY; - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * - * @method Phaser.GameObjects.Components.Pipeline#initPipeline - * @webglOnly - * @since 3.0.0 - * - * @param {string} pipelineName - The name of the pipeline to set on this Game Object. - * - * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. - */ - initPipeline: function (pipelineName) + if (tiledObject.gid) { - var renderer = this.scene.sys.game.renderer; - - if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) - { - this.defaultPipeline = renderer.getPipeline(pipelineName); - this.pipeline = this.defaultPipeline; - - return true; - } - - return false; - }, - - /** - * Sets the active WebGL Pipeline of this Game Object. - * - * @method Phaser.GameObjects.Components.Pipeline#setPipeline - * @webglOnly - * @since 3.0.0 - * - * @param {string} pipelineName - The name of the pipeline to set on this Game Object. - * - * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. - */ - setPipeline: function (pipelineName) + // Object tiles + var gidInfo = ParseGID(tiledObject.gid); + parsedObject.gid = gidInfo.gid; + parsedObject.flippedHorizontal = gidInfo.flippedHorizontal; + parsedObject.flippedVertical = gidInfo.flippedVertical; + parsedObject.flippedAntiDiagonal = gidInfo.flippedAntiDiagonal; + } + else if (tiledObject.polyline) { - var renderer = this.scene.sys.game.renderer; - - if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) - { - this.pipeline = renderer.getPipeline(pipelineName); - - return true; - } - - return false; - }, - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - * - * @method Phaser.GameObjects.Components.Pipeline#resetPipeline - * @webglOnly - * @since 3.0.0 - * - * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. - */ - resetPipeline: function () + parsedObject.polyline = tiledObject.polyline.map(copyPoints); + } + else if (tiledObject.polygon) { - this.pipeline = this.defaultPipeline; - - return (this.pipeline !== null); - }, - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - * - * @method Phaser.GameObjects.Components.Pipeline#getPipelineName - * @webglOnly - * @since 3.0.0 - * - * @return {string} The string-based name of the pipeline being used by this Game Object. - */ - getPipelineName: function () + parsedObject.polygon = tiledObject.polygon.map(copyPoints); + } + else if (tiledObject.ellipse) { - return this.pipeline.name; + parsedObject.ellipse = tiledObject.ellipse; + parsedObject.width = tiledObject.width; + parsedObject.height = tiledObject.height; + } + else if (tiledObject.text) + { + parsedObject.width = tiledObject.width; + parsedObject.height = tiledObject.height; + parsedObject.text = tiledObject.text; + } + else + { + // Otherwise, assume it is a rectangle + parsedObject.rectangle = true; + parsedObject.width = tiledObject.width; + parsedObject.height = tiledObject.height; } + return parsedObject; }; -module.exports = Pipeline; +module.exports = ParseObject; /***/ }), @@ -35742,387 +42380,256 @@ var Class = __webpack_require__(0); /** * @classdesc - * [description] + * An Image Collection is a special Tile Set containing multiple images, with no slicing into each image. * - * @class TransformMatrix - * @memberOf Phaser.GameObjects.Components + * Image Collections are normally created automatically when Tiled data is loaded. + * + * @class ImageCollection + * @memberOf Phaser.Tilemaps * @constructor * @since 3.0.0 - * - * @param {number} [a=1] - [description] - * @param {number} [b=0] - [description] - * @param {number} [c=0] - [description] - * @param {number} [d=1] - [description] - * @param {number} [tx=0] - [description] - * @param {number} [ty=0] - [description] + * + * @param {string} name - The name of the image collection in the map data. + * @param {integer} firstgid - The first image index this image collection contains. + * @param {integer} [width=32] - Width of widest image (in pixels). + * @param {integer} [height=32] - Height of tallest image (in pixels). + * @param {integer} [margin=0] - The margin around all images in the collection (in pixels). + * @param {integer} [spacing=0] - The spacing between each image in the collection (in pixels). + * @param {object} [properties={}] - Custom Image Collection properties. */ -var TransformMatrix = new Class({ +var ImageCollection = new Class({ initialize: - function TransformMatrix (a, b, c, d, tx, ty) + function ImageCollection (name, firstgid, width, height, margin, spacing, properties) { - if (a === undefined) { a = 1; } - if (b === undefined) { b = 0; } - if (c === undefined) { c = 0; } - if (d === undefined) { d = 1; } - if (tx === undefined) { tx = 0; } - if (ty === undefined) { ty = 0; } + if (width === undefined || width <= 0) { width = 32; } + if (height === undefined || height <= 0) { height = 32; } + if (margin === undefined) { margin = 0; } + if (spacing === undefined) { spacing = 0; } /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#matrix - * @type {Float32Array} + * The name of the Image Collection. + * + * @name Phaser.Tilemaps.ImageCollection#name + * @type {string} + * @since 3.0.0 + */ + this.name = name; + + /** + * The Tiled firstgid value. + * This is the starting index of the first image index this Image Collection contains. + * + * @name Phaser.Tilemaps.ImageCollection#firstgid + * @type {integer} * @since 3.0.0 */ - this.matrix = new Float32Array([ a, b, c, d, tx, ty, 0, 0, 1 ]); + this.firstgid = firstgid | 0; /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#decomposedMatrix + * The width of the widest image (in pixels). + * + * @name Phaser.Tilemaps.ImageCollection#imageWidth + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + this.imageWidth = width | 0; + + /** + * The height of the tallest image (in pixels). + * + * @name Phaser.Tilemaps.ImageCollection#imageHeight + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + this.imageHeight = height | 0; + + /** + * The margin around the images in the collection (in pixels). + * Use `setSpacing` to change. + * + * @name Phaser.Tilemaps.ImageCollection#imageMarge + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + this.imageMargin = margin | 0; + + /** + * The spacing between each image in the collection (in pixels). + * Use `setSpacing` to change. + * + * @name Phaser.Tilemaps.ImageCollection#imageSpacing + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + this.imageSpacing = spacing | 0; + + /** + * Image Collection-specific properties that are typically defined in the Tiled editor. + * + * @name Phaser.Tilemaps.ImageCollection#properties * @type {object} * @since 3.0.0 */ - this.decomposedMatrix = { - translateX: 0, - translateY: 0, - scaleX: 1, - scaleY: 1, - rotation: 0 - }; + this.properties = properties || {}; + + /** + * The cached images that are a part of this collection. + * + * @name Phaser.Tilemaps.ImageCollection#images + * @type {array} + * @readOnly + * @since 3.0.0 + */ + this.images = []; + + /** + * The total number of images in the image collection. + * + * @name Phaser.Tilemaps.ImageCollection#total + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + this.total = 0; }, /** - * [description] + * Returns true if and only if this image collection contains the given image index. * - * @method Phaser.GameObjects.Components.TransformMatrix#loadIdentity + * @method Phaser.Tilemaps.ImageCollection#containsImageIndex * @since 3.0.0 - * - * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. + * + * @param {integer} imageIndex - The image index to search for. + * + * @return {boolean} True if this Image Collection contains the given index. */ - loadIdentity: function () + containsImageIndex: function (imageIndex) { - var matrix = this.matrix; - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 1; - matrix[4] = 0; - matrix[5] = 0; - - return this; + return (imageIndex >= this.firstgid && imageIndex < (this.firstgid + this.total)); }, /** - * [description] + * Add an image to this Image Collection. * - * @method Phaser.GameObjects.Components.TransformMatrix#translate + * @method Phaser.Tilemaps.ImageCollection#addImage * @since 3.0.0 + * + * @param {integer} gid - The gid of the image in the Image Collection. + * @param {string} image - The the key of the image in the Image Collection and in the cache. * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. + * @return {Phaser.Tilemaps.ImageCollection} This ImageCollection object. */ - translate: function (x, y) + addImage: function (gid, image) { - var matrix = this.matrix; - - matrix[4] = matrix[0] * x + matrix[2] * y + matrix[4]; - matrix[5] = matrix[1] * x + matrix[3] * y + matrix[5]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#scale - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. - */ - scale: function (x, y) - { - var matrix = this.matrix; - - matrix[0] *= x; - matrix[1] *= x; - matrix[2] *= y; - matrix[3] *= y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#rotate - * @since 3.0.0 - * - * @param {number} radian - [description] - * - * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. - */ - rotate: function (radian) - { - var radianSin = Math.sin(radian); - var radianCos = Math.cos(radian); - - return this.transform(radianCos, radianSin, -radianSin, radianCos, 0, 0); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#multiply - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.TransformMatrix} rhs - [description] - * - * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. - */ - multiply: function (rhs) - { - var matrix = this.matrix; - var otherMatrix = rhs.matrix; - - var a0 = matrix[0]; - var b0 = matrix[1]; - var c0 = matrix[2]; - var d0 = matrix[3]; - var tx0 = matrix[4]; - var ty0 = matrix[5]; - - var a1 = otherMatrix[0]; - var b1 = otherMatrix[1]; - var c1 = otherMatrix[2]; - var d1 = otherMatrix[3]; - var tx1 = otherMatrix[4]; - var ty1 = otherMatrix[5]; - - matrix[0] = a1 * a0 + b1 * c0; - matrix[1] = a1 * b0 + b1 * d0; - matrix[2] = c1 * a0 + d1 * c0; - matrix[3] = c1 * b0 + d1 * d0; - matrix[4] = tx1 * a0 + ty1 * c0 + tx0; - matrix[5] = tx1 * b0 + ty1 * d0 + ty0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#transform - * @since 3.0.0 - * - * @param {number} a - [description] - * @param {number} b - [description] - * @param {number} c - [description] - * @param {number} d - [description] - * @param {number} tx - [description] - * @param {number} ty - [description] - * - * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. - */ - transform: function (a, b, c, d, tx, ty) - { - var matrix = this.matrix; - - var a0 = matrix[0]; - var b0 = matrix[1]; - var c0 = matrix[2]; - var d0 = matrix[3]; - var tx0 = matrix[4]; - var ty0 = matrix[5]; - - matrix[0] = a * a0 + b * c0; - matrix[1] = a * b0 + b * d0; - matrix[2] = c * a0 + d * c0; - matrix[3] = c * b0 + d * d0; - matrix[4] = tx * a0 + ty * c0 + tx0; - matrix[5] = tx * b0 + ty * d0 + ty0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#transformPoint - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {Phaser.Geom.Point|Phaser.Math.Vec2|object} point - [description] - * - * @return {Phaser.Geom.Point|Phaser.Math.Vec2|object} [description] - */ - transformPoint: function (x, y, point) - { - if (point === undefined) { point = { x: 0, y: 0 }; } - - var matrix = this.matrix; - - var a = matrix[0]; - var b = matrix[1]; - var c = matrix[2]; - var d = matrix[3]; - var tx = matrix[4]; - var ty = matrix[5]; - - point.x = x * a + y * c + tx; - point.y = x * b + y * d + ty; - - return point; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#invert - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. - */ - invert: function () - { - var matrix = this.matrix; - - var a = matrix[0]; - var b = matrix[1]; - var c = matrix[2]; - var d = matrix[3]; - var tx = matrix[4]; - var ty = matrix[5]; - - var n = a * d - b * c; - - matrix[0] = d / n; - matrix[1] = -b / n; - matrix[2] = -c / n; - matrix[3] = a / n; - matrix[4] = (c * ty - d * tx) / n; - matrix[5] = -(a * ty - b * tx) / n; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#setTransform - * @since 3.0.0 - * - * @param {number} a - [description] - * @param {number} b - [description] - * @param {number} c - [description] - * @param {number} d - [description] - * @param {number} tx - [description] - * @param {number} ty - [description] - * - * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. - */ - setTransform: function (a, b, c, d, tx, ty) - { - var matrix = this.matrix; - - matrix[0] = a; - matrix[1] = b; - matrix[2] = c; - matrix[3] = d; - matrix[4] = tx; - matrix[5] = ty; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#decomposeMatrix - * @since 3.0.0 - * - * @return {object} [description] - */ - decomposeMatrix: function () - { - var decomposedMatrix = this.decomposedMatrix; - - var matrix = this.matrix; - - var a = matrix[0]; - var b = matrix[1]; - var c = matrix[2]; - var d = matrix[3]; - - var a2 = a * a; - var b2 = b * b; - var c2 = c * c; - var d2 = d * d; - - var sx = Math.sqrt(a2 + c2); - var sy = Math.sqrt(b2 + d2); - - decomposedMatrix.translateX = matrix[4]; - decomposedMatrix.translateY = matrix[5]; - - decomposedMatrix.scaleX = sx; - decomposedMatrix.scaleY = sy; - - decomposedMatrix.rotation = Math.acos(a / sx) * (Math.atan(-c / a) < 0 ? -1 : 1); - - return decomposedMatrix; - }, - - /** - * Identity + Translate + Rotate + Scale - * - * @method Phaser.GameObjects.Components.TransformMatrix#applyITRS - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} rotation - [description] - * @param {number} scaleX - [description] - * @param {number} scaleY - [description] - * - * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. - */ - applyITRS: function (x, y, rotation, scaleX, scaleY) - { - var matrix = this.matrix; - - var sr = Math.sin(rotation); - var cr = Math.cos(rotation); - - // Translate - matrix[4] = x; - matrix[5] = y; - - // Rotate and Scale - matrix[0] = cr * scaleX; - matrix[1] = -sr * scaleX; - matrix[2] = sr * scaleY; - matrix[3] = cr * scaleY; + this.images.push({ gid: gid, image: image }); + this.total++; return this; } }); -module.exports = TransformMatrix; +module.exports = ImageCollection; /***/ }), /* 191 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FLIPPED_HORIZONTAL = 0x80000000; +var FLIPPED_VERTICAL = 0x40000000; +var FLIPPED_ANTI_DIAGONAL = 0x20000000; // Top-right is swapped with bottom-left corners + +/** + * See Tiled documentation on tile flipping: + * http://docs.mapeditor.org/en/latest/reference/tmx-map-format/ + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseGID + * @since 3.0.0 + * + * @param {number} gid - [description] + * + * @return {object} [description] + */ +var ParseGID = function (gid) +{ + var flippedHorizontal = Boolean(gid & FLIPPED_HORIZONTAL); + var flippedVertical = Boolean(gid & FLIPPED_VERTICAL); + var flippedAntiDiagonal = Boolean(gid & FLIPPED_ANTI_DIAGONAL); + gid = gid & ~(FLIPPED_HORIZONTAL | FLIPPED_VERTICAL | FLIPPED_ANTI_DIAGONAL); + + // Parse the flip flags into something Phaser can use + var rotation = 0; + var flipped = false; + + if (flippedHorizontal && flippedVertical && flippedAntiDiagonal) + { + rotation = Math.PI / 2; + flipped = true; + } + else if (flippedHorizontal && flippedVertical && !flippedAntiDiagonal) + { + rotation = Math.PI; + flipped = false; + } + else if (flippedHorizontal && !flippedVertical && flippedAntiDiagonal) + { + rotation = Math.PI / 2; + flipped = false; + } + else if (flippedHorizontal && !flippedVertical && !flippedAntiDiagonal) + { + rotation = 0; + flipped = true; + } + else if (!flippedHorizontal && flippedVertical && flippedAntiDiagonal) + { + rotation = 3 * Math.PI / 2; + flipped = false; + } + else if (!flippedHorizontal && flippedVertical && !flippedAntiDiagonal) + { + rotation = Math.PI; + flipped = true; + } + else if (!flippedHorizontal && !flippedVertical && flippedAntiDiagonal) + { + rotation = 3 * Math.PI / 2; + flipped = true; + } + else if (!flippedHorizontal && !flippedVertical && !flippedAntiDiagonal) + { + rotation = 0; + flipped = false; + } + + return { + gid: gid, + flippedHorizontal: flippedHorizontal, + flippedVertical: flippedVertical, + flippedAntiDiagonal: flippedAntiDiagonal, + rotation: rotation, + flipped: flipped + }; +}; + +module.exports = ParseGID; + + +/***/ }), +/* 192 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -36131,157 +42638,75 @@ module.exports = TransformMatrix; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Perimeter = __webpack_require__(78); -var Point = __webpack_require__(5); - -// Return an array of points from the perimeter of the rectangle -// each spaced out based on the quantity or step required +var Formats = __webpack_require__(24); +var MapData = __webpack_require__(65); +var ParseTileLayers = __webpack_require__(424); +var ParseImageLayers = __webpack_require__(422); +var ParseTilesets = __webpack_require__(421); +var ParseObjectLayers = __webpack_require__(419); +var BuildTilesetIndex = __webpack_require__(418); +var AssignTileProperties = __webpack_require__(417); /** - * [description] + * Parses a Tiled JSON object into a new MapData object. * - * @function Phaser.Geom.Rectangle.MarchingAnts + * @function Phaser.Tilemaps.Parsers.Tiled.ParseJSONTiled * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} step - [description] - * @param {integer} quantity - [description] - * @param {array} [out] - [description] + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {object} json - The Tiled JSON object. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. * - * @return {Phaser.Geom.Point[]} [description] + * @return {?Phaser.Tilemaps.MapData} [description] */ -var MarchingAnts = function (rect, step, quantity, out) +var ParseJSONTiled = function (name, json, insertNull) { - if (out === undefined) { out = []; } - - if (!step && !quantity) + if (json.orientation !== 'orthogonal') { - // Bail out - return out; + console.warn('Only orthogonal map types are supported in this version of Phaser'); + return null; } - // If step is a falsey value (false, null, 0, undefined, etc) then we calculate - // it based on the quantity instead, otherwise we always use the step value - if (!step) - { - step = Perimeter(rect) / quantity; - } - else - { - quantity = Math.round(Perimeter(rect) / step); - } + // Map data will consist of: layers, objects, images, tilesets, sizes + var mapData = new MapData({ + width: json.width, + height: json.height, + name: name, + tileWidth: json.tilewidth, + tileHeight: json.tileheight, + orientation: json.orientation, + format: Formats.TILED_JSON, + version: json.version, + properties: json.properties + }); - var x = rect.x; - var y = rect.y; - var face = 0; + mapData.layers = ParseTileLayers(json, insertNull); + mapData.images = ParseImageLayers(json); - // Loop across each face of the rectangle + var sets = ParseTilesets(json); + mapData.tilesets = sets.tilesets; + mapData.imageCollections = sets.imageCollections; - for (var i = 0; i < quantity; i++) - { - out.push(new Point(x, y)); + mapData.objects = ParseObjectLayers(json); - switch (face) - { + mapData.tiles = BuildTilesetIndex(mapData); - // Top face - case 0: - x += step; + AssignTileProperties(mapData); - if (x >= rect.right) - { - face = 1; - y += (x - rect.right); - x = rect.right; - } - break; - - // Right face - case 1: - y += step; - - if (y >= rect.bottom) - { - face = 2; - x -= (y - rect.bottom); - y = rect.bottom; - } - break; - - // Bottom face - case 2: - x -= step; - - if (x <= rect.left) - { - face = 3; - y -= (rect.left - x); - x = rect.left; - } - break; - - // Left face - case 3: - y -= step; - - if (y <= rect.top) - { - face = 0; - y = rect.top; - } - break; - } - } - - return out; + return mapData; }; -module.exports = MarchingAnts; - - -/***/ }), -/* 192 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Moves the element at the start of the array to the end, shifting all items in the process. - * The "rotation" happens to the left. - * - * @function Phaser.Utils.Array.RotateLeft - * @since 3.0.0 - * - * @param {array} array - The array to shift to the left. This array is modified in place. - * @param {integer} [total=1] - The number of times to shift the array. - * - * @return {any} The most recently shifted element. - */ -var RotateLeft = function (array, total) -{ - if (total === undefined) { total = 1; } - - var element = null; - - for (var i = 0; i < total; i++) - { - element = array.shift(); - array.push(element); - } - - return element; -}; - -module.exports = RotateLeft; +module.exports = ParseJSONTiled; /***/ }), /* 193 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -36289,39 +42714,47 @@ module.exports = RotateLeft; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Formats = __webpack_require__(24); +var Parse2DArray = __webpack_require__(116); + /** - * Moves the element at the end of the array to the start, shifting all items in the process. - * The "rotation" happens to the right. + * Parses a CSV string of tile indexes into a new MapData object with a single layer. * - * @function Phaser.Utils.Array.RotateRight + * @function Phaser.Tilemaps.Parsers.ParseCSV * @since 3.0.0 * - * @param {array} array - The array to shift to the right. This array is modified in place. - * @param {integer} [total=1] - The number of times to shift the array. + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {string} data - CSV string of tile indexes. + * @param {integer} tileWidth - The width of a tile in pixels. + * @param {integer} tileHeight - The height of a tile in pixels. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. * - * @return {any} The most recently shifted element. + * @return {Phaser.Tilemaps.MapData} [description] */ -var RotateRight = function (array, total) +var ParseCSV = function (name, data, tileWidth, tileHeight, insertNull) { - if (total === undefined) { total = 1; } + var array2D = data + .trim() + .split('\n') + .map(function (row) { return row.split(','); }); - var element = null; + var map = Parse2DArray(name, array2D, tileWidth, tileHeight, insertNull); + map.format = Formats.CSV; - for (var i = 0; i < total; i++) - { - element = array.pop(); - array.unshift(element); - } - - return element; + return map; }; -module.exports = RotateRight; +module.exports = ParseCSV; /***/ }), /* 194 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -36329,72 +42762,69 @@ module.exports = RotateRight; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Formats = __webpack_require__(24); +var Parse2DArray = __webpack_require__(116); +var ParseCSV = __webpack_require__(193); +var ParseJSONTiled = __webpack_require__(192); +var ParseWeltmeister = __webpack_require__(187); + /** - * Using Bresenham's line algorithm this will return an array of all coordinates on this line. - * The start and end points are rounded before this runs as the algorithm works on integers. + * Parses raw data of a given Tilemap format into a new MapData object. If no recognized data format + * is found, returns `null`. When loading from CSV or a 2D array, you should specify the tileWidth & + * tileHeight. When parsing from a map from Tiled, the tileWidth & tileHeight will be pulled from + * the map data. * - * @function Phaser.Geom.Line.BresenhamPoints + * @function Phaser.Tilemaps.Parsers.Parse * @since 3.0.0 * - * @param {Phaser.Geom.Line} line - [description] - * @param {integer} [stepRate=1] - [description] - * @param {array} [results] - [description] + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {integer} mapFormat - See ../Formats.js. + * @param {(integer[][]|string|object)} data - 2D array, CSV string or Tiled JSON object. + * @param {integer} tileWidth - The width of a tile in pixels. Required for 2D array and CSV, but + * ignored for Tiled JSON. + * @param {integer} tileHeight - The height of a tile in pixels. Required for 2D array and CSV, but + * ignored for Tiled JSON. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. * - * @return {array} [description] + * @return {Phaser.Tilemaps.MapData} [description] */ -var BresenhamPoints = function (line, stepRate, results) +var Parse = function (name, mapFormat, data, tileWidth, tileHeight, insertNull) { - if (stepRate === undefined) { stepRate = 1; } - if (results === undefined) { results = []; } + var newMap; - var x1 = Math.round(line.x1); - var y1 = Math.round(line.y1); - var x2 = Math.round(line.x2); - var y2 = Math.round(line.y2); - - var dx = Math.abs(x2 - x1); - var dy = Math.abs(y2 - y1); - var sx = (x1 < x2) ? 1 : -1; - var sy = (y1 < y2) ? 1 : -1; - var err = dx - dy; - - results.push({ x: x1, y: y1 }); - - var i = 1; - - while (!((x1 === x2) && (y1 === y2))) + switch (mapFormat) { - var e2 = err << 1; - - if (e2 > -dy) - { - err -= dy; - x1 += sx; - } - - if (e2 < dx) - { - err += dx; - y1 += sy; - } - - if (i % stepRate === 0) - { - results.push({ x: x1, y: y1 }); - } - - i++; + case (Formats.ARRAY_2D): + newMap = Parse2DArray(name, data, tileWidth, tileHeight, insertNull); + break; + case (Formats.CSV): + newMap = ParseCSV(name, data, tileWidth, tileHeight, insertNull); + break; + case (Formats.TILED_JSON): + newMap = ParseJSONTiled(name, data, insertNull); + break; + case (Formats.WELTMEISTER): + newMap = ParseWeltmeister(name, data, insertNull); + break; + default: + console.warn('Unrecognized tilemap data format: ' + mapFormat); + newMap = null; } - return results; + return newMap; }; -module.exports = BresenhamPoints; +module.exports = Parse; /***/ }), /* 195 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -36402,31 +42832,60 @@ module.exports = BresenhamPoints; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Tile = __webpack_require__(45); +var IsInLayerBounds = __webpack_require__(67); +var CalculateFacesAt = __webpack_require__(119); + /** - * [description] + * Removes the tile at the given tile coordinates in the specified layer and updates the layer's + * collision information. * - * @function Phaser.Math.SmootherStep + * @function Phaser.Tilemaps.Components.RemoveTileAt * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} min - [description] - * @param {number} max - [description] + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified + * location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * - * @return {number} [description] + * @return {Phaser.Tilemaps.Tile} The Tile object that was removed. */ -var SmootherStep = function (x, min, max) +var RemoveTileAt = function (tileX, tileY, replaceWithNull, recalculateFaces, layer) { - x = Math.max(0, Math.min(1, (x - min) / (max - min))); + if (replaceWithNull === undefined) { replaceWithNull = false; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + if (!IsInLayerBounds(tileX, tileY, layer)) { return null; } - return x * x * x * (x * (x * 6 - 15) + 10); + var tile = layer.data[tileY][tileX]; + if (tile === null) + { + return null; + } + else + { + layer.data[tileY][tileX] = replaceWithNull + ? null + : new Tile(layer, -1, tileX, tileY, tile.width, tile.height); + } + + // Recalculate faces only if the removed tile was a colliding tile + if (recalculateFaces && tile && tile.collides) + { + CalculateFacesAt(tileX, tileY, layer); + } + + return tile; }; -module.exports = SmootherStep; +module.exports = RemoveTileAt; /***/ }), /* 196 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -36434,26 +42893,36 @@ module.exports = SmootherStep; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var IsInLayerBounds = __webpack_require__(67); + /** - * [description] + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. * - * @function Phaser.Math.SmoothStep + * @function Phaser.Tilemaps.Components.HasTileAt * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} min - [description] - * @param {number} max - [description] - * - * @return {number} [description] + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {boolean} */ -var SmoothStep = function (x, min, max) +var HasTileAt = function (tileX, tileY, layer) { - x = Math.max(0, Math.min(1, (x - min) / (max - min))); + if (IsInLayerBounds(tileX, tileY, layer)) + { + var tile = layer.data[tileY][tileX]; + return (tile !== null && tile.index > -1); + } + else + { + return false; + } - return x * x * (3 - 2 * x); }; -module.exports = SmoothStep; +module.exports = HasTileAt; /***/ }), @@ -36466,1758 +42935,43 @@ module.exports = SmoothStep; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Frame = __webpack_require__(198); -var GetValue = __webpack_require__(4); +var GetTilesWithin = __webpack_require__(14); /** - * @classdesc - * A Frame based Animation. - * - * This consists of a key, some default values (like the frame rate) and a bunch of Frame objects. - * - * The Animation Manager creates these. Game Objects don't own an instance of these directly. - * Game Objects have the Animation Component, which are like playheads to global Animations (these objects) - * So multiple Game Objects can have playheads all pointing to this one Animation instance. + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does + * not change collision information. * - * @class Animation - * @memberOf Phaser.Animations - * @constructor + * @function Phaser.Tilemaps.Components.ReplaceByIndex * @since 3.0.0 * - * @param {Phaser.Animations.AnimationManager} manager - [description] - * @param {string} key - [description] - * @param {object} config - [description] + * @param {integer} findIndex - [description] + * @param {integer} newIndex - [description] + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. */ -var Animation = new Class({ - - initialize: - - function Animation (manager, key, config) - { - /** - * [description] - * - * @name Phaser.Animations.Animation#manager - * @type {Phaser.Animations.AnimationManager} - * @since 3.0.0 - */ - this.manager = manager; - - /** - * [description] - * - * @name Phaser.Animations.Animation#key - * @type {string} - * @since 3.0.0 - */ - this.key = key; - - /** - * A frame based animation (as opposed to a bone based animation) - * - * @name Phaser.Animations.Animation#type - * @type {string} - * @default frame - * @since 3.0.0 - */ - this.type = 'frame'; - - /** - * Extract all the frame data into the frames array - * - * @name Phaser.Animations.Animation#frames - * @type {array} - * @since 3.0.0 - */ - this.frames = this.getFrames( - manager.textureManager, - GetValue(config, 'frames', []), - GetValue(config, 'defaultTextureKey', null) - ); - - /** - * The frame rate of playback in frames per second (default 24 if duration is null) - * - * @name Phaser.Animations.Animation#frameRate - * @type {integer} - * @default 24 - * @since 3.0.0 - */ - this.frameRate = GetValue(config, 'frameRate', null); - - /** - * How long the animation should play for. - * If frameRate is set it overrides this value otherwise frameRate is derived from duration. - * - * @name Phaser.Animations.Animation#duration - * @type {integer} - * @since 3.0.0 - */ - this.duration = GetValue(config, 'duration', null); - - if (this.duration === null && this.frameRate === null) - { - // No duration or frameRate given, use default frameRate of 24fps - this.frameRate = 24; - this.duration = this.frameRate / this.frames.length; - } - else if (this.duration && this.frameRate === null) - { - // Duration given but no frameRate, so set the frameRate based on duration - // I.e. 12 frames in the animation, duration = 4 (4000 ms) - // So frameRate is 12 / 4 = 3 fps - this.frameRate = this.frames.length / this.duration; - } - else - { - // frameRate given, derive duration from it (even if duration also specified) - // I.e. 15 frames in the animation, frameRate = 30 fps - // So duration is 15 / 30 = 0.5 (half a second) - this.duration = this.frames.length / this.frameRate; - } - - /** - * ms per frame (without including frame specific modifiers) - * - * @name Phaser.Animations.Animation#msPerFrame - * @type {integer} - * @since 3.0.0 - */ - this.msPerFrame = 1000 / this.frameRate; - - /** - * Skip frames if the time lags, or always advanced anyway? - * - * @name Phaser.Animations.Animation#skipMissedFrames - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.skipMissedFrames = GetValue(config, 'skipMissedFrames', true); - - /** - * Delay before starting playback (in seconds) - * - * @name Phaser.Animations.Animation#delay - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.delay = GetValue(config, 'delay', 0); - - /** - * Number of times to repeat the animation (-1 for infinity) - * - * @name Phaser.Animations.Animation#repeat - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.repeat = GetValue(config, 'repeat', 0); - - /** - * Delay before the repeat starts (in seconds) - * - * @name Phaser.Animations.Animation#repeatDelay - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.repeatDelay = GetValue(config, 'repeatDelay', 0); - - /** - * Should the animation yoyo? (reverse back down to the start) before repeating? - * - * @name Phaser.Animations.Animation#yoyo - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.yoyo = GetValue(config, 'yoyo', false); - - /** - * Should sprite.visible = true when the animation starts to play? - * - * @name Phaser.Animations.Animation#showOnStart - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.showOnStart = GetValue(config, 'showOnStart', false); - - /** - * Should sprite.visible = false when the animation finishes? - * - * @name Phaser.Animations.Animation#hideOnComplete - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.hideOnComplete = GetValue(config, 'hideOnComplete', false); - - /** - * [description] - * - * @name Phaser.Animations.Animation#callbackScope - * @type {object} - * @since 3.0.0 - */ - this.callbackScope = GetValue(config, 'callbackScope', this); - - /** - * [description] - * - * @name Phaser.Animations.Animation#onStart - * @type {function} - * @since 3.0.0 - */ - this.onStart = GetValue(config, 'onStart', false); - - /** - * [description] - * - * @name Phaser.Animations.Animation#onStartParams - * @type {array} - * @since 3.0.0 - */ - this.onStartParams = GetValue(config, 'onStartParams', []); - - /** - * [description] - * - * @name Phaser.Animations.Animation#onRepeat - * @type {function} - * @since 3.0.0 - */ - this.onRepeat = GetValue(config, 'onRepeat', false); - - /** - * [description] - * - * @name Phaser.Animations.Animation#onRepeatParams - * @type {array} - * @since 3.0.0 - */ - this.onRepeatParams = GetValue(config, 'onRepeatParams', []); - - /** - * Called for EVERY frame of the animation. - * See AnimationFrame.onUpdate for a frame specific callback. - * - * @name Phaser.Animations.Animation#onUpdate - * @type {function} - * @since 3.0.0 - */ - this.onUpdate = GetValue(config, 'onUpdate', false); - - /** - * [description] - * - * @name Phaser.Animations.Animation#onUpdateParams - * @type {array} - * @since 3.0.0 - */ - this.onUpdateParams = GetValue(config, 'onUpdateParams', []); - - /** - * [description] - * - * @name Phaser.Animations.Animation#onComplete - * @type {function} - * @since 3.0.0 - */ - this.onComplete = GetValue(config, 'onComplete', false); - - /** - * [description] - * - * @name Phaser.Animations.Animation#onCompleteParams - * @type {array} - * @since 3.0.0 - */ - this.onCompleteParams = GetValue(config, 'onCompleteParams', []); - - /** - * Global pause, effects all Game Objects using this Animation instance - * - * @name Phaser.Animations.Animation#paused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.paused = false; - - this.manager.on('pauseall', this.pause.bind(this)); - this.manager.on('resumeall', this.resume.bind(this)); - }, - - // config = Array of Animation config objects, like: - // [ - // { key: 'gems', frame: 'diamond0001', [duration], [visible], [onUpdate] } - // ] - - // Add frames to the end of the animation - - /** - * [description] - * - * @method Phaser.Animations.Animation#addFrame - * @since 3.0.0 - * - * @param {[type]} config - [description] - * - * @return {Phaser.Animations.Animation} This Animation object. - */ - addFrame: function (config) - { - return this.addFrameAt(this.frames.length, config); - }, - - // config = Array of Animation config objects, like: - // [ - // { key: 'gems', frame: 'diamond0001', [duration], [visible], [onUpdate] } - // ] - - // Add frame/s into the animation - - /** - * [description] - * - * @method Phaser.Animations.Animation#addFrameAt - * @since 3.0.0 - * - * @param {integer} index - [description] - * @param {[type]} config - [description] - * - * @return {Phaser.Animations.Animation} This Animation object. - */ - addFrameAt: function (index, config) - { - var newFrames = this.getFrames(this.manager.textureManager, config); - - if (newFrames.length > 0) - { - if (index === 0) - { - this.frames = newFrames.concat(this.frames); - } - else if (index === this.frames.length) - { - this.frames = this.frames.concat(newFrames); - } - else - { - var pre = this.frames.slice(0, index); - var post = this.frames.slice(index); - - this.frames = pre.concat(newFrames, post); - } - - this.updateFrameSequence(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#checkFrame - * @since 3.0.0 - * - * @param {integer} index - [description] - * - * @return {boolean} [description] - */ - checkFrame: function (index) - { - return (index < this.frames.length); - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#completeAnimation - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - [description] - */ - completeAnimation: function (component) - { - if (this.hideOnComplete) - { - component.parent.visible = false; - } - - component.stop(true); - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#getFirstTick - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - [description] - * @param {boolean} [includeDelay=true] - [description] - */ - getFirstTick: function (component, includeDelay) - { - if (includeDelay === undefined) { includeDelay = true; } - - // When is the first update due? - component.accumulator = 0; - component.nextTick = component.msPerFrame + component.currentFrame.duration; - - if (includeDelay) - { - component.nextTick += (component._delay * 1000); - } - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#getFrameAt - * @since 3.0.0 - * - * @param {integer} index - [description] - * - * @return {Phaser.Animations.AnimationFrame} [description] - */ - getFrameAt: function (index) - { - return this.frames[index]; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#getFrames - * @since 3.0.0 - * - * @param {[type]} textureManager - [description] - * @param {[type]} frames - [description] - * - * @return {Phaser.Animations.AnimationFrame[]} [description] - */ - getFrames: function (textureManager, frames, defaultTextureKey) - { - // frames: [ - // { key: textureKey, frame: textureFrame }, - // { key: textureKey, frame: textureFrame, duration: float }, - // { key: textureKey, frame: textureFrame, onUpdate: function } - // { key: textureKey, frame: textureFrame, visible: boolean } - // ], - - var out = []; - var prev; - var animationFrame; - var index = 1; - var i; - var textureKey; - - // if frames is a string, we'll get all the frames from the texture manager as if it's a sprite sheet - if (typeof frames === 'string') - { - textureKey = frames; - - var texture = textureManager.get(textureKey); - var frameKeys = texture.getFrameNames(); - - frames = []; - - frameKeys.forEach(function (idx, value) - { - frames.push({ key: textureKey, frame: value }); - }); - } - - if (!Array.isArray(frames) || frames.length === 0) - { - return out; - } - - for (i = 0; i < frames.length; i++) - { - var item = frames[i]; - - var key = GetValue(item, 'key', defaultTextureKey); - - if (!key) - { - continue; - } - - // Could be an integer or a string - var frame = GetValue(item, 'frame', 0); - - // The actual texture frame - var textureFrame = textureManager.getFrame(key, frame); - - animationFrame = new Frame(key, frame, index, textureFrame); - - animationFrame.duration = GetValue(item, 'duration', 0); - animationFrame.onUpdate = GetValue(item, 'onUpdate', null); - - animationFrame.isFirst = (!prev); - - // The previously created animationFrame - if (prev) - { - prev.nextFrame = animationFrame; - - animationFrame.prevFrame = prev; - } - - out.push(animationFrame); - - prev = animationFrame; - - index++; - } - - if (out.length > 0) - { - animationFrame.isLast = true; - - // Link them end-to-end, so they loop - animationFrame.nextFrame = out[0]; - - out[0].prevFrame = animationFrame; - - // Generate the progress data - - var slice = 1 / (out.length - 1); - - for (i = 0; i < out.length; i++) - { - out[i].progress = i * slice; - } - } - - return out; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#getNextTick - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - [description] - */ - getNextTick: function (component) - { - // accumulator += delta * _timeScale - // after a large delta surge (perf issue for example) we need to adjust for it here - - // When is the next update due? - component.accumulator -= component.nextTick; - - component.nextTick = component.msPerFrame + component.currentFrame.duration; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#load - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - [description] - * @param {integer} startFrame - [description] - */ - load: function (component, startFrame) - { - if (startFrame >= this.frames.length) - { - startFrame = 0; - } - - if (component.currentAnim !== this) - { - component.currentAnim = this; - - component._timeScale = 1; - component.frameRate = this.frameRate; - component.duration = this.duration; - component.msPerFrame = this.msPerFrame; - component.skipMissedFrames = this.skipMissedFrames; - component._delay = this.delay; - component._repeat = this.repeat; - component._repeatDelay = this.repeatDelay; - component._yoyo = this.yoyo; - component._callbackArgs[1] = this; - component._updateParams = component._callbackArgs.concat(this.onUpdateParams); - } - - component.updateFrame(this.frames[startFrame]); - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#nextFrame - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - [description] - */ - nextFrame: function (component) - { - var frame = component.currentFrame; - - // TODO: Add frame skip support - - if (frame.isLast) - { - // We're at the end of the animation - - // Yoyo? (happens before repeat) - if (this.yoyo) - { - component.forward = false; - - component.updateFrame(frame.prevFrame); - - // Delay for the current frame - this.getNextTick(component); - } - else if (component.repeatCounter > 0) - { - // Repeat (happens before complete) - this.repeatAnimation(component); - } - else - { - this.completeAnimation(component); - } - } - else - { - component.updateFrame(frame.nextFrame); - - this.getNextTick(component); - } - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#previousFrame - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - [description] - */ - previousFrame: function (component) - { - var frame = component.currentFrame; - - // TODO: Add frame skip support - - if (frame.isFirst) - { - // We're at the start of the animation - - if (component.repeatCounter > 0) - { - // Repeat (happens before complete) - this.repeatAnimation(component); - } - else - { - this.completeAnimation(component); - } - } - else - { - component.updateFrame(frame.prevFrame); - - this.getNextTick(component); - } - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#removeFrame - * @since 3.0.0 - * - * @param {Phaser.Animations.AnimationFrame} frame - [description] - * - * @return {Phaser.Animations.Animation} This Animation object. - */ - removeFrame: function (frame) - { - var index = this.frames.indexOf(frame); - - if (index !== -1) - { - this.removeFrameAt(index); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#removeFrameAt - * @since 3.0.0 - * - * @param {integer} index - [description] - * - * @return {Phaser.Animations.Animation} This Animation object. - */ - removeFrameAt: function (index) - { - this.frames.splice(index, 1); - - this.updateFrameSequence(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#repeatAnimation - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - [description] - */ - repeatAnimation: function (component) - { - if (component._repeatDelay > 0 && component.pendingRepeat === false) - { - component.pendingRepeat = true; - component.accumulator -= component.nextTick; - component.nextTick += (component._repeatDelay * 1000); - } - else - { - component.repeatCounter--; - - component.forward = true; - - component.updateFrame(component.currentFrame.nextFrame); - - this.getNextTick(component); - - component.pendingRepeat = false; - - if (this.onRepeat) - { - this.onRepeat.apply(this.callbackScope, component._callbackArgs.concat(this.onRepeatParams)); - } - } - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#setFrame - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - [description] - */ - setFrame: function (component) - { - // Work out which frame should be set next on the child, and set it - if (component.forward) - { - this.nextFrame(component); - } - else - { - this.previousFrame(component); - } - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - var output = { - key: this.key, - type: this.type, - frames: [], - frameRate: this.frameRate, - duration: this.duration, - skipMissedFrames: this.skipMissedFrames, - delay: this.delay, - repeat: this.repeat, - repeatDelay: this.repeatDelay, - yoyo: this.yoyo, - showOnStart: this.showOnStart, - hideOnComplete: this.hideOnComplete - }; - - this.frames.forEach(function (frame) - { - output.frames.push(frame.toJSON()); - }); - - return output; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#updateFrameSequence - * @since 3.0.0 - * - * @return {Phaser.Animations.Animation} This Animation object. - */ - updateFrameSequence: function () - { - var len = this.frames.length; - var slice = 1 / (len - 1); - - for (var i = 0; i < len; i++) - { - var frame = this.frames[i]; - - frame.index = i + 1; - frame.isFirst = false; - frame.isLast = false; - frame.progress = i * slice; - - if (i === 0) - { - frame.isFirst = true; - frame.isLast = (len === 1); - frame.prevFrame = this.frames[len - 1]; - frame.nextFrame = this.frames[i + 1]; - } - else if (i === len - 1) - { - frame.isLast = true; - frame.prevFrame = this.frames[len - 2]; - frame.nextFrame = this.frames[0]; - } - else if (len > 1) - { - frame.prevFrame = this.frames[i - 1]; - frame.nextFrame = this.frames[i + 1]; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#pause - * @since 3.0.0 - * - * @return {Phaser.Animations.Animation} This Animation object. - */ - pause: function () - { - this.paused = true; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#resume - * @since 3.0.0 - * - * @return {Phaser.Animations.Animation} This Animation object. - */ - resume: function () - { - this.paused = false; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#destroy - * @since 3.0.0 - */ - destroy: function () - { - // TODO - } - -}); - -module.exports = Animation; - - -/***/ }), -/* 198 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * A single frame in an Animation sequence. - * - * An AnimationFrame consists of a reference to the Texture it uses for rendering, references to other - * frames in the animation, and index data. It also has the ability to fire its own `onUpdate` callback - * and modify the animation timing. - * - * AnimationFrames are generated automatically by the Animation class. - * - * @class AnimationFrame - * @memberOf Phaser.Animations - * @constructor - * @since 3.0.0 - * - * @param {string} textureKey - The key of the Texture this AnimationFrame uses. - * @param {string|integer} textureFrame - The key of the Frame within the Texture that this AnimationFrame uses. - * @param {integer} index - The index of this AnimationFrame within the Animation sequence. - * @param {Phaser.Textures.Frame} frame - A reference to the Texture Frame this AnimationFrame uses for rendering. - */ -var AnimationFrame = new Class({ - - initialize: - - function AnimationFrame (textureKey, textureFrame, index, frame) - { - /** - * The key of the Texture this AnimationFrame uses. - * - * @name Phaser.Animations.AnimationFrame#textureKey - * @type {string} - * @since 3.0.0 - */ - this.textureKey = textureKey; - - /** - * The key of the Frame within the Texture that this AnimationFrame uses. - * - * @name Phaser.Animations.AnimationFrame#textureFrame - * @type {string|integer} - * @since 3.0.0 - */ - this.textureFrame = textureFrame; - - /** - * The index of this AnimationFrame within the Animation sequence. - * - * @name Phaser.Animations.AnimationFrame#index - * @type {integer} - * @since 3.0.0 - */ - this.index = index; - - /** - * A reference to the Texture Frame this AnimationFrame uses for rendering. - * - * @name Phaser.Animations.AnimationFrame#frame - * @type {Phaser.Textures.Frame} - * @since 3.0.0 - */ - this.frame = frame; - - /** - * Is this the first frame in an animation sequence? - * - * @name Phaser.Animations.AnimationFrame#isFirst - * @type {boolean} - * @default false - * @readOnly - * @since 3.0.0 - */ - this.isFirst = false; - - /** - * Is this the last frame in an animation sequence? - * - * @name Phaser.Animations.AnimationFrame#isLast - * @type {boolean} - * @default false - * @readOnly - * @since 3.0.0 - */ - this.isLast = false; - - /** - * A reference to the AnimationFrame that comes before this one in the animation, if any. - * - * @name Phaser.Animations.AnimationFrame#prevFrame - * @type {?Phaser.Animations.AnimationFrame} - * @default null - * @readOnly - * @since 3.0.0 - */ - this.prevFrame = null; - - /** - * A reference to the AnimationFrame that comes after this one in the animation, if any. - * - * @name Phaser.Animations.AnimationFrame#nextFrame - * @type {?Phaser.Animations.AnimationFrame} - * @default null - * @readOnly - * @since 3.0.0 - */ - this.nextFrame = null; - - /** - * Additional time (in ms) that this frame should appear for during playback. - * The value is added onto the msPerFrame set by the animation. - * - * @name Phaser.Animations.AnimationFrame#duration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.duration = 0; - - /** - * What % through the animation does this frame come? - * This value is generated when the animation is created and cached here. - * - * @name Phaser.Animations.AnimationFrame#progress - * @type {number} - * @default 0 - * @readOnly - * @since 3.0.0 - */ - this.progress = 0; - - /** - * A frame specific callback, invoked if this frame gets displayed and the callback is set. - * - * @name Phaser.Animations.AnimationFrame#onUpdate - * @type {?function} - * @default null - * @since 3.0.0 - */ - this.onUpdate = null; - }, - - /** - * Generates a JavaScript object suitable for converting to JSON. - * - * @method Phaser.Animations.AnimationFrame#toJSON - * @since 3.0.0 - * - * @return {object} The AnimationFrame data. - */ - toJSON: function () - { - return { - key: this.textureKey, - frame: this.textureFrame, - duration: this.duration - }; - }, - - /** - * Destroys this object by removing references to external resources and callbacks. - * - * @method Phaser.Animations.AnimationFrame#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.frame = undefined; - this.onUpdate = undefined; - } - -}); - -module.exports = AnimationFrame; - - -/***/ }), -/* 199 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Animation = __webpack_require__(197); -var Class = __webpack_require__(0); -var CustomMap = __webpack_require__(114); -var EventEmitter = __webpack_require__(14); -var GetValue = __webpack_require__(4); -var Pad = __webpack_require__(200); - -/** - * @classdesc - * The Animation Manager. - * - * Animations are managed by the global Animation Manager. This is a singleton class that is - * responsible for creating and delivering animations and their corresponding data to all Game Objects. - * Unlike plugins it is owned by the Game instance, not the Scene. - * - * Sprites and other Game Objects get the data they need from the AnimationManager. - * - * @class AnimationManager - * @extends EventEmitter - * @memberOf Phaser.Animations - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - [description] - */ -var AnimationManager = new Class({ - - Extends: EventEmitter, - - initialize: - - function AnimationManager (game) - { - EventEmitter.call(this); - - /** - * [description] - * - * @name Phaser.Animations.AnimationManager#game - * @type {Phaser.Game} - * @protected - * @since 3.0.0 - */ - this.game = game; - - /** - * [description] - * - * @name Phaser.Animations.AnimationManager#textureManager - * @type {Phaser.Textures.TextureManager} - * @protected - * @since 3.0.0 - */ - this.textureManager = null; - - /** - * [description] - * - * @name Phaser.Animations.AnimationManager#globalTimeScale - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.globalTimeScale = 1; - - /** - * [description] - * - * @name Phaser.Animations.AnimationManager#anims - * @type {Phaser.Structs.Map} - * @protected - * @since 3.0.0 - */ - this.anims = new CustomMap(); - - /** - * [description] - * - * @name Phaser.Animations.AnimationManager#paused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.paused = false; - - /** - * [description] - * - * @name Phaser.Animations.AnimationManager#name - * @type {string} - * @since 3.0.0 - */ - this.name = 'AnimationManager'; - - game.events.once('boot', this.boot, this); - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#boot - * @since 3.0.0 - */ - boot: function () - { - this.textureManager = this.game.textures; - - this.game.events.once('destroy', this.destroy, this); - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#add - * @fires AddAnimationEvent - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {Phaser.Animations.Animation} animation - [description] - * - * @return {Phaser.Animations.AnimationManager} This Animation Manager. - */ - add: function (key, animation) - { - if (this.anims.has(key)) - { - console.warn('Animation with key', key, 'already exists'); - return; - } - - animation.key = key; - - this.anims.set(key, animation); - - this.emit('add', key, animation); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#create - * @fires AddAnimationEvent - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.Animations.Animation} The Animation that was created. - */ - create: function (config) - { - var key = config.key; - - if (!key || this.anims.has(key)) - { - console.warn('Invalid Animation Key, or Key already in use: ' + key); - return; - } - - var anim = new Animation(this, key, config); - - this.anims.set(key, anim); - - this.emit('add', key, anim); - - return anim; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#fromJSON - * @since 3.0.0 - * - * @param {string|object} data - [description] - * @param {boolean} [clearCurrentAnimations=false] - [description] - * - * @return {Phaser.Animations.Animation[]} An array containing all of the Animation objects that were created as a result of this call. - */ - fromJSON: function (data, clearCurrentAnimations) - { - if (clearCurrentAnimations === undefined) { clearCurrentAnimations = false; } - - if (clearCurrentAnimations) - { - this.anims.clear(); - } - - // Do we have a String (i.e. from JSON, or an Object?) - if (typeof data === 'string') - { - data = JSON.parse(data); - } - - var output = []; - - // Array of animations, or a single animation? - if (data.hasOwnProperty('anims') && Array.isArray(data.anims)) - { - for (var i = 0; i < data.anims.length; i++) - { - output.push(this.create(data.anims[i])); - } - - if (data.hasOwnProperty('globalTimeScale')) - { - this.globalTimeScale = data.globalTimeScale; - } - } - else if (data.hasOwnProperty('key') && data.type === 'frame') - { - output.push(this.create(data)); - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#generateFrameNames - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {object} config - [description] - * @param {string} [config.prefix=''] - [description] - * @param {integer} [config.start=0] - [description] - * @param {integer} [config.end=0] - [description] - * @param {string} [config.suffix=''] - [description] - * @param {integer} [config.zeroPad=0] - [description] - * @param {array} [config.outputArray=[]] - [description] - * @param {boolean} [config.frames=false] - [description] - * - * @return {object[]} [description] - */ - generateFrameNames: function (key, config) - { - var prefix = GetValue(config, 'prefix', ''); - var start = GetValue(config, 'start', 0); - var end = GetValue(config, 'end', 0); - var suffix = GetValue(config, 'suffix', ''); - var zeroPad = GetValue(config, 'zeroPad', 0); - var out = GetValue(config, 'outputArray', []); - var frames = GetValue(config, 'frames', false); - - var texture = this.textureManager.get(key); - - if (!texture) - { - return out; - } - - var diff = (start < end) ? 1 : -1; - - // Adjust because we use i !== end in the for loop - end += diff; - - var i; - var frame; - - // Have they provided their own custom frame sequence array? - if (Array.isArray(frames)) - { - for (i = 0; i < frames.length; i++) - { - frame = prefix + Pad(frames[i], zeroPad, '0', 1) + suffix; - - if (texture.has(frame)) - { - out.push({ key: key, frame: frame }); - } - } - } - else - { - for (i = start; i !== end; i += diff) - { - frame = prefix + Pad(i, zeroPad, '0', 1) + suffix; - - if (texture.has(frame)) - { - out.push({ key: key, frame: frame }); - } - } - } - - return out; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#generateFrameNumbers - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {object} config - [description] - * @param {integer} [config.start=0] - [description] - * @param {integer} [config.end=-1] - [description] - * @param {boolean} [config.first=false] - [description] - * @param {array} [config.outputArray=[]] - [description] - * @param {boolean} [config.frames=false] - [description] - * - * @return {object[]} [description] - */ - generateFrameNumbers: function (key, config) - { - var startFrame = GetValue(config, 'start', 0); - var endFrame = GetValue(config, 'end', -1); - var firstFrame = GetValue(config, 'first', false); - var out = GetValue(config, 'outputArray', []); - var frames = GetValue(config, 'frames', false); - - var texture = this.textureManager.get(key); - - if (!texture) - { - return out; - } - - if (firstFrame && texture.has(firstFrame)) - { - out.push({ key: key, frame: firstFrame }); - } - - var i; - - // Have they provided their own custom frame sequence array? - if (Array.isArray(frames)) - { - for (i = 0; i < frames.length; i++) - { - if (texture.has(frames[i])) - { - out.push({ key: key, frame: frames[i] }); - } - } - } - else - { - // No endFrame then see if we can get it - - if (endFrame === -1) - { - endFrame = texture.frameTotal; - } - - for (i = startFrame; i <= endFrame; i++) - { - if (texture.has(i)) - { - out.push({ key: key, frame: i }); - } - } - } - - return out; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#get - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Animations.Animation} [description] - */ - get: function (key) - { - return this.anims.get(key); - }, - - /** - * Load an Animation into a Game Objects Animation Component. - * - * @method Phaser.Animations.AnimationManager#load - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - * @param {string} key - [description] - * @param {string|integer} [startFrame] - [description] - * - * @return {Phaser.GameObjects.GameObject} [description] - */ - load: function (child, key, startFrame) - { - var anim = this.get(key); - - if (anim) - { - anim.load(child, startFrame); - } - - return child; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#pauseAll - * @fires PauseAllAnimationEvent - * @since 3.0.0 - * - * @return {Phaser.Animations.AnimationManager} This Animation Manager. - */ - pauseAll: function () - { - if (!this.paused) - { - this.paused = true; - - this.emit('pauseall'); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#play - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {Phaser.GameObjects.GameObject} child - [description] - * - * @return {Phaser.Animations.AnimationManager} This Animation Manager. - */ - play: function (key, child) - { - if (!Array.isArray(child)) - { - child = [ child ]; - } - - var anim = this.get(key); - - if (!anim) - { - return; - } - - for (var i = 0; i < child.length; i++) - { - child[i].anims.play(key); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#remove - * @fires RemoveAnimationEvent - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Animations.Animation} [description] - */ - remove: function (key) - { - var anim = this.get(key); - - if (anim) - { - this.emit('remove', key, anim); - - this.anims.delete(key); - } - - return anim; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#resumeAll - * @fires ResumeAllAnimationEvent - * @since 3.0.0 - * - * @return {Phaser.Animations.AnimationManager} This Animation Manager. - */ - resumeAll: function () - { - if (this.paused) - { - this.paused = false; - - this.emit('resumeall'); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#staggerPlay - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {Phaser.GameObjects.GameObject} child - [description] - * @param {number} [stagger=0] - [description] - * - * @return {Phaser.Animations.AnimationManager} This Animation Manager. - */ - staggerPlay: function (key, child, stagger) - { - if (stagger === undefined) { stagger = 0; } - - if (!Array.isArray(child)) - { - child = [ child ]; - } - - var anim = this.get(key); - - if (!anim) - { - return; - } - - for (var i = 0; i < child.length; i++) - { - child[i].anims.delayedPlay(stagger * i, key); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#toJSON - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {object} [description] - */ - toJSON: function (key) - { - if (key !== undefined && key !== '') - { - return this.anims.get(key).toJSON(); - } - else - { - var output = { - anims: [], - globalTimeScale: this.globalTimeScale - }; - - this.anims.each(function (animationKey, animation) - { - output.anims.push(animation.toJSON()); - }); - - return output; - } - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.anims.clear(); - - this.textureManager = null; - - this.game = null; - } - -}); - -module.exports = AnimationManager; - - -/***/ }), -/* 200 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Takes the given string and pads it out, to the length required, using the character - * specified. For example if you need a string to be 6 characters long, you can call: - * - * `pad('bob', 6, '-', 2)` - * - * This would return: `bob---` as it has padded it out to 6 characters, using the `-` on the right. - * - * You can also use it to pad numbers (they are always returned as strings): - * - * `pad(512, 6, '0', 1)` - * - * Would return: `000512` with the string padded to the left. - * - * If you don't specify a direction it'll pad to both sides: - * - * `pad('c64', 7, '*')` - * - * Would return: `**c64**` - * - * @function Phaser.Utils.String.Pad - * @since 3.0.0 - * - * @param {string} str - The target string. `toString()` will be called on the string, which means you can also pass in common data types like numbers. - * @param {integer} [len=0] - The number of characters to be added. - * @param {string} [pad=" "] - The string to pad it out with (defaults to a space). - * @param {integer} [dir=3] - The direction dir = 1 (left), 2 (right), 3 (both). - * - * @return {string} The padded string. - */ -var Pad = function (str, len, pad, dir) +var ReplaceByIndex = function (findIndex, newIndex, tileX, tileY, width, height, layer) { - if (len === undefined) { len = 0; } - if (pad === undefined) { pad = ' '; } - if (dir === undefined) { dir = 3; } - - str = str.toString(); - - var padlen = 0; - - if (len + 1 >= str.length) + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + for (var i = 0; i < tiles.length; i++) { - switch (dir) + if (tiles[i] && tiles[i].index === findIndex) { - case 1: - str = new Array(len + 1 - str.length).join(pad) + str; - break; - - case 3: - var right = Math.ceil((padlen = len - str.length) / 2); - var left = padlen - right; - str = new Array(left + 1).join(pad) + str + new Array(right + 1).join(pad); - break; - - default: - str = str + new Array(len + 1 - str.length).join(pad); - break; + tiles[i].index = newIndex; } } - - return str; }; -module.exports = Pad; +module.exports = ReplaceByIndex; /***/ }), +/* 198 */, +/* 199 */, +/* 200 */, /* 201 */ /***/ (function(module, exports, __webpack_require__) { @@ -38227,452 +42981,854 @@ module.exports = Pad; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var CircleContains = __webpack_require__(28); var Class = __webpack_require__(0); -var CustomMap = __webpack_require__(114); -var EventEmitter = __webpack_require__(14); +var CONST = __webpack_require__(47); +var RectangleContains = __webpack_require__(27); +var Vector2 = __webpack_require__(6); /** * @classdesc - * The BaseCache is a base Cache class that can be used for storing references to any kind of data. + * [description] * - * Data can be added, retrieved and removed based on the given keys. - * - * Keys are string-based. - * - * @class BaseCache - * @memberOf Phaser.Cache + * @class StaticBody + * @memberOf Phaser.Physics.Arcade * @constructor * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - [description] */ -var BaseCache = new Class({ +var StaticBody = new Class({ initialize: - function BaseCache () + function StaticBody (world, gameObject) { /** - * The Map in which the cache objects are stored. + * [description] * - * You can query the Map directly or use the BaseCache methods. - * - * @name Phaser.Cache.BaseCache#entries - * @type {Phaser.Structs.Map} + * @name Phaser.Physics.Arcade.StaticBody#world + * @type {Phaser.Physics.Arcade.World} * @since 3.0.0 */ - this.entries = new CustomMap(); + this.world = world; /** - * An instance of EventEmitter used by the cache to emit related events. + * [description] * - * @name Phaser.Cache.BaseCache#events - * @type {EventEmitter} + * @name Phaser.Physics.Arcade.StaticBody#gameObject + * @type {Phaser.GameObjects.GameObject} * @since 3.0.0 */ - this.events = new EventEmitter(); + this.gameObject = gameObject; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#debugShowBody + * @type {boolean} + * @since 3.0.0 + */ + this.debugShowBody = world.defaults.debugShowStaticBody; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#debugBodyColor + * @type {integer} + * @since 3.0.0 + */ + this.debugBodyColor = world.defaults.staticBodyDebugColor; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#enable + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.enable = true; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#isCircle + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isCircle = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#radius + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.radius = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#offset + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.offset = new Vector2(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#position + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.position = new Vector2(gameObject.x - gameObject.displayOriginX, gameObject.y - gameObject.displayOriginY); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#width + * @type {number} + * @since 3.0.0 + */ + this.width = gameObject.displayWidth; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#height + * @type {number} + * @since 3.0.0 + */ + this.height = gameObject.displayHeight; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#halfWidth + * @type {number} + * @since 3.0.0 + */ + this.halfWidth = Math.abs(this.width / 2); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#halfHeight + * @type {number} + * @since 3.0.0 + */ + this.halfHeight = Math.abs(this.height / 2); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#center + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#velocity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.velocity = Vector2.ZERO; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#allowGravity + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.allowGravity = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#gravity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.gravity = Vector2.ZERO; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#bounce + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.bounce = Vector2.ZERO; + + // If true this Body will dispatch events + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#onWorldBounds + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.onWorldBounds = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#onCollide + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.onCollide = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#onOverlap + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.onOverlap = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#mass + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.mass = 1; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#immovable + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.immovable = true; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#customSeparateX + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customSeparateX = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#customSeparateY + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customSeparateY = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#overlapX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapX = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#overlapY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapY = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#overlapR + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapR = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#embedded + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.embedded = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#collideWorldBounds + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.collideWorldBounds = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#checkCollision + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.checkCollision = { none: false, up: true, down: true, left: true, right: true }; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#touching + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.touching = { none: true, up: false, down: false, left: false, right: false }; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#wasTouching + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.wasTouching = { none: true, up: false, down: false, left: false, right: false }; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#blocked + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.blocked = { none: true, up: false, down: false, left: false, right: false }; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#physicsType + * @type {integer} + * @since 3.0.0 + */ + this.physicsType = CONST.STATIC_BODY; }, /** - * Cache add event. + * Changes the Game Object this Body is bound to. + * First it removes its reference from the old Game Object, then sets the new one. + * You can optionally update the position and dimensions of this Body to reflect that of the new Game Object. * - * This event is fired by the Cache each time a new object is added to it. + * @method Phaser.Physics.Arcade.StaticBody#setGameObject + * @since 3.1.0 * - * @event Phaser.Cache.BaseCache#addEvent - * @param {Phaser.Cache.BaseCache} The BaseCache to which the object was added. - * @param {string} The key of the object added to the cache. - * @param {any} A reference to the object added to the cache. + * @param {Phaser.GameObjects.GameObject} gameObject - The new Game Object that will own this Body. + * @param {boolean} [update=true] - Reposition and resize this Body to match the new Game Object? + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. */ - - /** - * Adds an item to this cache. The item is referenced by a unique string, which you are responsible - * for setting and keeping track of. The item can only be retrieved by using this string. - * - * @method Phaser.Cache.BaseCache#add - * @fires Phaser.Cache.BaseCache#addEvent - * @since 3.0.0 - * - * @param {string} key - The unique key by which the data added to the cache will be referenced. - * @param {any} data - The data to be stored in the cache. - * - * @return {Phaser.Cache.BaseCache} This BaseCache object. - */ - add: function (key, data) + setGameObject: function (gameObject, update) { - this.entries.set(key, data); - - this.events.emit('add', this, key, data); - - return this; - }, - - /** - * Checks if this cache contains an item matching the given key. - * - * @method Phaser.Cache.BaseCache#has - * @since 3.0.0 - * - * @param {string} key - The unique key of the item to be checked in this cache. - * - * @return {boolean} Returns `true` if the cache contains an item matching the given key, otherwise `false`. - */ - has: function (key) - { - return this.entries.has(key); - }, - - /** - * Gets an item from this cache based on the given key. - * - * @method Phaser.Cache.BaseCache#get - * @since 3.0.0 - * - * @param {string} key - The unique key of the item to be retrieved from this cache. - * - * @return {any} The item in the cache, or `null` if no item matching the given key was found. - */ - get: function (key) - { - return this.entries.get(key); - }, - - /** - * Cache remove event. - * - * This event is fired by the Cache each time an object is removed from it. - * - * @event Phaser.Cache.BaseCache#removeEvent - * @param {Phaser.Cache.BaseCache} The BaseCache from which the object was removed. - * @param {string} The key of the object removed from the cache. - * @param {any} The object that was removed from the cache. - */ - - /** - * Removes and item from this cache based on the given key. - * - * If an entry matching the key is found it is removed from the cache and a `remove` event emitted. - * No additional checks are done on the item removed. If other systems or parts of your game code - * are relying on this item, it is up to you to sever those relationships prior to removing the item. - * - * @method Phaser.Cache.BaseCache#remove - * @fires Phaser.Cache.BaseCache#removeEvent - * @since 3.0.0 - * - * @param {string} key - The unique key of the item to remove from the cache. - * - * @return {Phaser.Cache.BaseCache} This BaseCache object. - */ - remove: function (key) - { - var entry = this.get(key); - - if (entry) + if (gameObject && gameObject !== this.gameObject) { - this.entries.delete(key); + // Remove this body from the old game object + this.gameObject.body = null; - this.events.emit('remove', this, key, entry.data); + gameObject.body = this; + + // Update our reference + this.gameObject = gameObject; + } + + if (update) + { + this.updateFromGameObject(); } return this; }, /** - * Destroys this cache and all items within it. + * Updates this Static Body so that its position and dimensions are updated + * based on the current Game Object it is bound to. * - * @method Phaser.Cache.BaseCache#destroy + * @method Phaser.Physics.Arcade.StaticBody#updateFromGameObject + * @since 3.1.0 + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + updateFromGameObject: function () + { + this.world.staticTree.remove(this); + + var gameObject = this.gameObject; + + gameObject.getTopLeft(this.position); + + this.width = gameObject.displayWidth; + this.height = gameObject.displayHeight; + + this.halfWidth = Math.abs(this.width / 2); + this.halfHeight = Math.abs(this.height / 2); + + this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); + + this.world.staticTree.insert(this); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#setSize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * @param {number} [offsetX] - [description] + * @param {number} [offsetY] - [description] + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + setSize: function (width, height, offsetX, offsetY) + { + if (offsetX === undefined) { offsetX = this.offset.x; } + if (offsetY === undefined) { offsetY = this.offset.y; } + + this.world.staticTree.remove(this); + + this.width = width; + this.height = height; + + this.halfWidth = Math.floor(width / 2); + this.halfHeight = Math.floor(height / 2); + + this.offset.set(offsetX, offsetY); + + this.updateCenter(); + + this.isCircle = false; + this.radius = 0; + + this.world.staticTree.insert(this); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#setCircle + * @since 3.0.0 + * + * @param {number} radius - [description] + * @param {number} [offsetX] - [description] + * @param {number} [offsetY] - [description] + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + setCircle: function (radius, offsetX, offsetY) + { + if (offsetX === undefined) { offsetX = this.offset.x; } + if (offsetY === undefined) { offsetY = this.offset.y; } + + if (radius > 0) + { + this.world.staticTree.remove(this); + + this.isCircle = true; + + this.radius = radius; + + this.width = radius * 2; + this.height = radius * 2; + + this.halfWidth = Math.floor(this.width / 2); + this.halfHeight = Math.floor(this.height / 2); + + this.offset.set(offsetX, offsetY); + + this.updateCenter(); + + this.world.staticTree.insert(this); + } + else + { + this.isCircle = false; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#updateCenter + * @since 3.0.0 + */ + updateCenter: function () + { + this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#reset + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + */ + reset: function (x, y) + { + var gameObject = this.gameObject; + + if (x === undefined) { x = gameObject.x; } + if (y === undefined) { y = gameObject.y; } + + this.world.staticTree.remove(this); + + gameObject.getTopLeft(this.position); + + this.updateCenter(); + + this.world.staticTree.insert(this); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#stop + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + stop: function () + { + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#getBounds + * @since 3.0.0 + * + * @param {ArcadeBodyBounds} obj - [description] + * + * @return {ArcadeBodyBounds} [description] + */ + getBounds: function (obj) + { + obj.x = this.x; + obj.y = this.y; + obj.right = this.right; + obj.bottom = this.bottom; + + return obj; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#hitTest + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ + hitTest: function (x, y) + { + return (this.isCircle) ? CircleContains(this, x, y) : RectangleContains(this, x, y); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#deltaAbsX + * @since 3.0.0 + * + * @return {number} [description] + */ + deltaAbsX: function () + { + return 0; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#deltaAbsY + * @since 3.0.0 + * + * @return {number} [description] + */ + deltaAbsY: function () + { + return 0; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#deltaX + * @since 3.0.0 + * + * @return {number} [description] + */ + deltaX: function () + { + return 0; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#deltaY + * @since 3.0.0 + * + * @return {number} [description] + */ + deltaY: function () + { + return 0; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#deltaZ + * @since 3.0.0 + * + * @return {number} [description] + */ + deltaZ: function () + { + return 0; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#destroy * @since 3.0.0 */ destroy: function () { - this.entries.clear(); - this.events.removeAllListeners(); + this.enable = false; + + this.world.pendingDestroy.set(this); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#drawDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphic - [description] + */ + drawDebug: function (graphic) + { + var pos = this.position; + + if (this.debugShowBody) + { + graphic.lineStyle(1, this.debugBodyColor, 1); + graphic.strokeRect(pos.x, pos.y, this.width, this.height); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#willDrawDebug + * @since 3.0.0 + * + * @return {boolean} [description] + */ + willDrawDebug: function () + { + return this.debugShowBody; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#setMass + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + setMass: function (value) + { + if (value <= 0) + { + // Causes havoc otherwise + value = 0.1; + } + + this.mass = value; + + return this; + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.position.x; + }, + + set: function (value) + { + this.world.staticTree.remove(this); + + this.position.x = value; + + this.world.staticTree.insert(this); + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.position.y; + }, + + set: function (value) + { + this.world.staticTree.remove(this); + + this.position.y = value; + + this.world.staticTree.insert(this); + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#left + * @type {number} + * @readOnly + * @since 3.0.0 + */ + left: { + + get: function () + { + return this.position.x; + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#right + * @type {number} + * @readOnly + * @since 3.0.0 + */ + right: { + + get: function () + { + return this.position.x + this.width; + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#top + * @type {number} + * @readOnly + * @since 3.0.0 + */ + top: { + + get: function () + { + return this.position.y; + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#bottom + * @type {number} + * @readOnly + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return this.position.y + this.height; + } - this.entries = null; - this.events = null; } }); -module.exports = BaseCache; +module.exports = StaticBody; /***/ }), /* 202 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BaseCache = __webpack_require__(201); -var Class = __webpack_require__(0); - -/** - * @classdesc - * The Cache Manager is the global cache owned and maintained by the Game instance. - * - * Various systems, such as the file Loader, rely on this cache in order to store the files - * it has loaded. The manager itself doesn't store any files, but instead owns multiple BaseCache - * instances, one per type of file. You can also add your own custom caches. - * - * @class CacheManager - * @memberOf Phaser.Cache - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - A reference to the Phaser.Game instance that owns this CacheManager. - */ -var CacheManager = new Class({ - - initialize: - - function CacheManager (game) - { - /** - * A reference to the Phaser.Game instance that owns this CacheManager. - * - * @name Phaser.Cache.CacheManager#game - * @type {Phaser.Game} - * @protected - * @since 3.0.0 - */ - this.game = game; - - /** - * A Cache storing all binary files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#binary - * @type {Phaser.Cache.BaseCache} - * @protected - * @since 3.0.0 - */ - this.binary = new BaseCache(); - - /** - * A Cache storing all bitmap font data files, typically added via the Loader. - * Only the font data is stored in this cache, the textures are part of the Texture Manager. - * - * @name Phaser.Cache.CacheManager#bitmapFont - * @type {Phaser.Cache.BaseCache} - * @protected - * @since 3.0.0 - */ - this.bitmapFont = new BaseCache(); - - /** - * A Cache storing all JSON data files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#json - * @type {Phaser.Cache.BaseCache} - * @protected - * @since 3.0.0 - */ - this.json = new BaseCache(); - - /** - * A Cache storing all physics data files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#physics - * @type {Phaser.Cache.BaseCache} - * @protected - * @since 3.0.0 - */ - this.physics = new BaseCache(); - - /** - * A Cache storing all shader source files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#shader - * @type {Phaser.Cache.BaseCache} - * @protected - * @since 3.0.0 - */ - this.shader = new BaseCache(); - - /** - * A Cache storing all non-streaming audio files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#audio - * @type {Phaser.Cache.BaseCache} - * @protected - * @since 3.0.0 - */ - this.audio = new BaseCache(); - - /** - * A Cache storing all text files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#text - * @type {Phaser.Cache.BaseCache} - * @protected - * @since 3.0.0 - */ - this.text = new BaseCache(); - - /** - * A Cache storing all WaveFront OBJ files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#obj - * @type {Phaser.Cache.BaseCache} - * @protected - * @since 3.0.0 - */ - this.obj = new BaseCache(); - - /** - * A Cache storing all tilemap data files, typically added via the Loader. - * Only the data is stored in this cache, the textures are part of the Texture Manager. - * - * @name Phaser.Cache.CacheManager#tilemap - * @type {Phaser.Cache.BaseCache} - * @protected - * @since 3.0.0 - */ - this.tilemap = new BaseCache(); - - /** - * A Cache storing all xml data files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#xml - * @type {Phaser.Cache.BaseCache} - * @protected - * @since 3.0.0 - */ - this.xml = new BaseCache(); - - /** - * An object that contains your own custom BaseCache entries. - * Add to this via the `addCustom` method. - * - * @name Phaser.Cache.CacheManager#custom - * @type {object.} - * @protected - * @since 3.0.0 - */ - this.custom = {}; - - this.game.events.once('destroy', this.destroy, this); - }, - - /** - * Add your own custom Cache for storing your own files. - * The cache will be available under `Cache.custom.key`. - * The cache will only be created if the key is not already in use. - * - * @method Phaser.Cache.CacheManager#addCustom - * @since 3.0.0 - * - * @param {string} key - The unique key of your custom cache. - * - * @return {Phaser.Cache.BaseCache} A reference to the BaseCache that was created. If the key was already in use, a reference to the existing cache is returned instead. - */ - addCustom: function (key) - { - if (!this.custom.hasOwnProperty(key)) - { - this.custom[key] = new BaseCache(); - } - - return this.custom[key]; - }, - - /** - * Removes all entries from all BaseCaches and destroys all custom caches. - * - * @method Phaser.Cache.CacheManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - var keys = [ - 'binary', - 'bitmapFont', - 'json', - 'physics', - 'shader', - 'audio', - 'text', - 'obj', - 'tilemap', - 'xml' - ]; - - for (var i = 0; i < keys.length; i++) - { - this[keys[i]].destroy(); - this[keys[i]] = null; - } - - for (var key in this.custom) - { - this.custom[key].destroy(); - } - - this.custom = null; - - this.game = null; - } - -}); - -module.exports = CacheManager; - - -/***/ }), -/* 203 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Color = __webpack_require__(36); - -/** - * Converts a hex string into a Phaser Color object. - * - * The hex string can supplied as `'#0033ff'` or the short-hand format of `'#03f'`; it can begin with an optional "#" or "0x", or be unprefixed. - * - * An alpha channel is _not_ supported. - * - * @function Phaser.Display.Color.HexStringToColor - * @since 3.0.0 - * - * @param {string} hex - The hex color value to convert, such as `#0033ff` or the short-hand format: `#03f`. - * - * @return {Phaser.Display.Color} A Color object populated by the values of the given string. - */ -var HexStringToColor = function (hex) -{ - var color = new Color(); - - // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") - hex = hex.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) - { - return r + r + g + g + b + b; - }); - - var result = (/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i).exec(hex); - - if (result) - { - var r = parseInt(result[1], 16); - var g = parseInt(result[2], 16); - var b = parseInt(result[3], 16); - - color.setTo(r, g, b); - } - - return color; -}; - -module.exports = HexStringToColor; - - -/***/ }), -/* 204 */ /***/ (function(module, exports) { /** @@ -38682,24 +43838,757 @@ module.exports = HexStringToColor; */ /** - * Given an alpha and 3 color values this will return an integer representation of it. + * [description] * - * @function Phaser.Display.Color.GetColor32 + * @function Phaser.Physics.Arcade.Tilemap.TileIntersectsBody * @since 3.0.0 * - * @param {integer} red - The red color value. A number between 0 and 255. - * @param {integer} green - The green color value. A number between 0 and 255. - * @param {integer} blue - The blue color value. A number between 0 and 255. - * @param {integer} alpha - The alpha color value. A number between 0 and 255. + * @param {{ left: number, right: number, top: number, bottom: number }} tileWorldRect - [description] + * @param {Phaser.Physics.Arcade.Body} body - [description] * - * @return {number} The combined color value. + * @return {boolean} [description] */ -var GetColor32 = function (red, green, blue, alpha) +var TileIntersectsBody = function (tileWorldRect, body) { - return alpha << 24 | red << 16 | green << 8 | blue; + // Currently, all bodies are treated as rectangles when colliding with a Tile. Eventually, this + // should support circle bodies when those are less buggy in v3. + + return !( + body.right <= tileWorldRect.left || + body.bottom <= tileWorldRect.top || + body.position.x >= tileWorldRect.right || + body.position.y >= tileWorldRect.bottom + ); }; -module.exports = GetColor32; +module.exports = TileIntersectsBody; + + +/***/ }), +/* 203 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// This is from the quickselect npm package: https://www.npmjs.com/package/quickselect +// Coded by https://www.npmjs.com/~mourner (Vladimir Agafonkin) + +// https://en.wikipedia.org/wiki/Floyd%E2%80%93Rivest_algorithm + +// Floyd-Rivest selection algorithm: +// Rearrange items so that all items in the [left, k] range are smaller than all items in (k, right]; +// The k-th element will have the (k - left + 1)th smallest value in [left, right] + +/** + * [description] + * + * @function Phaser.Utils.Array.QuickSelect + * @since 3.0.0 + * + * @param {array} arr - [description] + * @param {number} k - [description] + * @param {number} left - [description] + * @param {number} right - [description] + * @param {function} compare - [description] + */ +var QuickSelect = function (arr, k, left, right, compare) +{ + left = left || 0; + right = right || (arr.length - 1); + compare = compare || defaultCompare; + + while (right > left) + { + if (right - left > 600) + { + var n = right - left + 1; + var m = k - left + 1; + var z = Math.log(n); + var s = 0.5 * Math.exp(2 * z / 3); + var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1); + var newLeft = Math.max(left, Math.floor(k - m * s / n + sd)); + var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd)); + + QuickSelect(arr, k, newLeft, newRight, compare); + } + + var t = arr[k]; + var i = left; + var j = right; + + swap(arr, left, k); + + if (compare(arr[right], t) > 0) + { + swap(arr, left, right); + } + + while (i < j) + { + swap(arr, i, j); + + i++; + j--; + + while (compare(arr[i], t) < 0) + { + i++; + } + + while (compare(arr[j], t) > 0) + { + j--; + } + } + + if (compare(arr[left], t) === 0) + { + swap(arr, left, j); + } + else + { + j++; + swap(arr, j, right); + } + + if (j <= k) + { + left = j + 1; + } + + if (k <= j) + { + right = j - 1; + } + } +}; + +function swap (arr, i, j) +{ + var tmp = arr[i]; + arr[i] = arr[j]; + arr[j] = tmp; +} + +function defaultCompare (a, b) +{ + return a < b ? -1 : a > b ? 1 : 0; +} + +module.exports = QuickSelect; + + +/***/ }), +/* 204 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var quickselect = __webpack_require__(203); + +/** + * @classdesc + * RBush is a high-performance JavaScript library for 2D spatial indexing of points and rectangles. + * It's based on an optimized R-tree data structure with bulk insertion support. + * + * Spatial index is a special data structure for points and rectangles that allows you to perform queries like + * "all items within this bounding box" very efficiently (e.g. hundreds of times faster than looping over all items). + * + * @class RTree + * @memberOf Phaser.Structs + * @constructor + * @since 3.0.0 + */ + +function rbush (maxEntries, format) +{ + if (!(this instanceof rbush)) return new rbush(maxEntries, format); + + // max entries in a node is 9 by default; min node fill is 40% for best performance + this._maxEntries = Math.max(4, maxEntries || 9); + this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)); + + if (format) + { + this._initFormat(format); + } + + this.clear(); +} + +rbush.prototype = { + + all: function () + { + return this._all(this.data, []); + }, + + search: function (bbox) + { + var node = this.data, + result = [], + toBBox = this.toBBox; + + if (!intersects(bbox, node)) return result; + + var nodesToSearch = [], + i, len, child, childBBox; + + while (node) { + for (i = 0, len = node.children.length; i < len; i++) { + + child = node.children[i]; + childBBox = node.leaf ? toBBox(child) : child; + + if (intersects(bbox, childBBox)) { + if (node.leaf) result.push(child); + else if (contains(bbox, childBBox)) this._all(child, result); + else nodesToSearch.push(child); + } + } + node = nodesToSearch.pop(); + } + + return result; + }, + + collides: function (bbox) + { + var node = this.data, + toBBox = this.toBBox; + + if (!intersects(bbox, node)) return false; + + var nodesToSearch = [], + i, len, child, childBBox; + + while (node) { + for (i = 0, len = node.children.length; i < len; i++) { + + child = node.children[i]; + childBBox = node.leaf ? toBBox(child) : child; + + if (intersects(bbox, childBBox)) { + if (node.leaf || contains(bbox, childBBox)) return true; + nodesToSearch.push(child); + } + } + node = nodesToSearch.pop(); + } + + return false; + }, + + load: function (data) + { + if (!(data && data.length)) return this; + + if (data.length < this._minEntries) { + for (var i = 0, len = data.length; i < len; i++) { + this.insert(data[i]); + } + return this; + } + + // recursively build the tree with the given data from scratch using OMT algorithm + var node = this._build(data.slice(), 0, data.length - 1, 0); + + if (!this.data.children.length) { + // save as is if tree is empty + this.data = node; + + } else if (this.data.height === node.height) { + // split root if trees have the same height + this._splitRoot(this.data, node); + + } else { + if (this.data.height < node.height) { + // swap trees if inserted one is bigger + var tmpNode = this.data; + this.data = node; + node = tmpNode; + } + + // insert the small tree into the large tree at appropriate level + this._insert(node, this.data.height - node.height - 1, true); + } + + return this; + }, + + insert: function (item) + { + if (item) this._insert(item, this.data.height - 1); + return this; + }, + + clear: function () + { + this.data = createNode([]); + return this; + }, + + remove: function (item, equalsFn) + { + if (!item) return this; + + var node = this.data, + bbox = this.toBBox(item), + path = [], + indexes = [], + i, parent, index, goingUp; + + // depth-first iterative tree traversal + while (node || path.length) { + + if (!node) { // go up + node = path.pop(); + parent = path[path.length - 1]; + i = indexes.pop(); + goingUp = true; + } + + if (node.leaf) { // check current node + index = findItem(item, node.children, equalsFn); + + if (index !== -1) { + // item found, remove the item and condense tree upwards + node.children.splice(index, 1); + path.push(node); + this._condense(path); + return this; + } + } + + if (!goingUp && !node.leaf && contains(node, bbox)) { // go down + path.push(node); + indexes.push(i); + i = 0; + parent = node; + node = node.children[0]; + + } else if (parent) { // go right + i++; + node = parent.children[i]; + goingUp = false; + + } else node = null; // nothing found + } + + return this; + }, + + toBBox: function (item) { return item; }, + + compareMinX: compareNodeMinX, + compareMinY: compareNodeMinY, + + toJSON: function () { return this.data; }, + + fromJSON: function (data) + { + this.data = data; + return this; + }, + + _all: function (node, result) + { + var nodesToSearch = []; + while (node) { + if (node.leaf) result.push.apply(result, node.children); + else nodesToSearch.push.apply(nodesToSearch, node.children); + + node = nodesToSearch.pop(); + } + return result; + }, + + _build: function (items, left, right, height) + { + var N = right - left + 1, + M = this._maxEntries, + node; + + if (N <= M) { + // reached leaf level; return leaf + node = createNode(items.slice(left, right + 1)); + calcBBox(node, this.toBBox); + return node; + } + + if (!height) { + // target height of the bulk-loaded tree + height = Math.ceil(Math.log(N) / Math.log(M)); + + // target number of root entries to maximize storage utilization + M = Math.ceil(N / Math.pow(M, height - 1)); + } + + node = createNode([]); + node.leaf = false; + node.height = height; + + // split the items into M mostly square tiles + + var N2 = Math.ceil(N / M), + N1 = N2 * Math.ceil(Math.sqrt(M)), + i, j, right2, right3; + + multiSelect(items, left, right, N1, this.compareMinX); + + for (i = left; i <= right; i += N1) { + + right2 = Math.min(i + N1 - 1, right); + + multiSelect(items, i, right2, N2, this.compareMinY); + + for (j = i; j <= right2; j += N2) { + + right3 = Math.min(j + N2 - 1, right2); + + // pack each entry recursively + node.children.push(this._build(items, j, right3, height - 1)); + } + } + + calcBBox(node, this.toBBox); + + return node; + }, + + _chooseSubtree: function (bbox, node, level, path) + { + var i, len, child, targetNode, area, enlargement, minArea, minEnlargement; + + while (true) { + path.push(node); + + if (node.leaf || path.length - 1 === level) break; + + minArea = minEnlargement = Infinity; + + for (i = 0, len = node.children.length; i < len; i++) { + child = node.children[i]; + area = bboxArea(child); + enlargement = enlargedArea(bbox, child) - area; + + // choose entry with the least area enlargement + if (enlargement < minEnlargement) { + minEnlargement = enlargement; + minArea = area < minArea ? area : minArea; + targetNode = child; + + } else if (enlargement === minEnlargement) { + // otherwise choose one with the smallest area + if (area < minArea) { + minArea = area; + targetNode = child; + } + } + } + + node = targetNode || node.children[0]; + } + + return node; + }, + + _insert: function (item, level, isNode) + { + var toBBox = this.toBBox, + bbox = isNode ? item : toBBox(item), + insertPath = []; + + // find the best node for accommodating the item, saving all nodes along the path too + var node = this._chooseSubtree(bbox, this.data, level, insertPath); + + // put the item into the node + node.children.push(item); + extend(node, bbox); + + // split on node overflow; propagate upwards if necessary + while (level >= 0) { + if (insertPath[level].children.length > this._maxEntries) { + this._split(insertPath, level); + level--; + } else break; + } + + // adjust bboxes along the insertion path + this._adjustParentBBoxes(bbox, insertPath, level); + }, + + // split overflowed node into two + _split: function (insertPath, level) + { + var node = insertPath[level], + M = node.children.length, + m = this._minEntries; + + this._chooseSplitAxis(node, m, M); + + var splitIndex = this._chooseSplitIndex(node, m, M); + + var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex)); + newNode.height = node.height; + newNode.leaf = node.leaf; + + calcBBox(node, this.toBBox); + calcBBox(newNode, this.toBBox); + + if (level) insertPath[level - 1].children.push(newNode); + else this._splitRoot(node, newNode); + }, + + _splitRoot: function (node, newNode) + { + // split root node + this.data = createNode([node, newNode]); + this.data.height = node.height + 1; + this.data.leaf = false; + calcBBox(this.data, this.toBBox); + }, + + _chooseSplitIndex: function (node, m, M) + { + var i, bbox1, bbox2, overlap, area, minOverlap, minArea, index; + + minOverlap = minArea = Infinity; + + for (i = m; i <= M - m; i++) { + bbox1 = distBBox(node, 0, i, this.toBBox); + bbox2 = distBBox(node, i, M, this.toBBox); + + overlap = intersectionArea(bbox1, bbox2); + area = bboxArea(bbox1) + bboxArea(bbox2); + + // choose distribution with minimum overlap + if (overlap < minOverlap) { + minOverlap = overlap; + index = i; + + minArea = area < minArea ? area : minArea; + + } else if (overlap === minOverlap) { + // otherwise choose distribution with minimum area + if (area < minArea) { + minArea = area; + index = i; + } + } + } + + return index; + }, + + // sorts node children by the best axis for split + _chooseSplitAxis: function (node, m, M) + { + var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX, + compareMinY = node.leaf ? this.compareMinY : compareNodeMinY, + xMargin = this._allDistMargin(node, m, M, compareMinX), + yMargin = this._allDistMargin(node, m, M, compareMinY); + + // if total distributions margin value is minimal for x, sort by minX, + // otherwise it's already sorted by minY + if (xMargin < yMargin) node.children.sort(compareMinX); + }, + + // total margin of all possible split distributions where each node is at least m full + _allDistMargin: function (node, m, M, compare) + { + node.children.sort(compare); + + var toBBox = this.toBBox, + leftBBox = distBBox(node, 0, m, toBBox), + rightBBox = distBBox(node, M - m, M, toBBox), + margin = bboxMargin(leftBBox) + bboxMargin(rightBBox), + i, child; + + for (i = m; i < M - m; i++) { + child = node.children[i]; + extend(leftBBox, node.leaf ? toBBox(child) : child); + margin += bboxMargin(leftBBox); + } + + for (i = M - m - 1; i >= m; i--) { + child = node.children[i]; + extend(rightBBox, node.leaf ? toBBox(child) : child); + margin += bboxMargin(rightBBox); + } + + return margin; + }, + + _adjustParentBBoxes: function (bbox, path, level) + { + // adjust bboxes along the given tree path + for (var i = level; i >= 0; i--) { + extend(path[i], bbox); + } + }, + + _condense: function (path) + { + // go through the path, removing empty nodes and updating bboxes + for (var i = path.length - 1, siblings; i >= 0; i--) { + if (path[i].children.length === 0) { + if (i > 0) { + siblings = path[i - 1].children; + siblings.splice(siblings.indexOf(path[i]), 1); + + } else this.clear(); + + } else calcBBox(path[i], this.toBBox); + } + }, + + _initFormat: function (format) + { + // data format (minX, minY, maxX, maxY accessors) + + // uses eval-type function compilation instead of just accepting a toBBox function + // because the algorithms are very sensitive to sorting functions performance, + // so they should be dead simple and without inner calls + + var compareArr = ['return a', ' - b', ';']; + + this.compareMinX = new Function('a', 'b', compareArr.join(format[0])); + this.compareMinY = new Function('a', 'b', compareArr.join(format[1])); + + this.toBBox = new Function('a', + 'return {minX: a' + format[0] + + ', minY: a' + format[1] + + ', maxX: a' + format[2] + + ', maxY: a' + format[3] + '};'); + } +}; + +function findItem (item, items, equalsFn) +{ + if (!equalsFn) return items.indexOf(item); + + for (var i = 0; i < items.length; i++) { + if (equalsFn(item, items[i])) return i; + } + return -1; +} + +// calculate node's bbox from bboxes of its children +function calcBBox (node, toBBox) +{ + distBBox(node, 0, node.children.length, toBBox, node); +} + +// min bounding rectangle of node children from k to p-1 +function distBBox (node, k, p, toBBox, destNode) +{ + if (!destNode) destNode = createNode(null); + destNode.minX = Infinity; + destNode.minY = Infinity; + destNode.maxX = -Infinity; + destNode.maxY = -Infinity; + + for (var i = k, child; i < p; i++) { + child = node.children[i]; + extend(destNode, node.leaf ? toBBox(child) : child); + } + + return destNode; +} + +function extend (a, b) +{ + a.minX = Math.min(a.minX, b.minX); + a.minY = Math.min(a.minY, b.minY); + a.maxX = Math.max(a.maxX, b.maxX); + a.maxY = Math.max(a.maxY, b.maxY); + return a; +} + +function compareNodeMinX (a, b) { return a.minX - b.minX; } +function compareNodeMinY (a, b) { return a.minY - b.minY; } + +function bboxArea (a) { return (a.maxX - a.minX) * (a.maxY - a.minY); } +function bboxMargin (a) { return (a.maxX - a.minX) + (a.maxY - a.minY); } + +function enlargedArea (a, b) +{ + return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) * + (Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY)); +} + +function intersectionArea (a, b) +{ + var minX = Math.max(a.minX, b.minX), + minY = Math.max(a.minY, b.minY), + maxX = Math.min(a.maxX, b.maxX), + maxY = Math.min(a.maxY, b.maxY); + + return Math.max(0, maxX - minX) * + Math.max(0, maxY - minY); +} + +function contains (a, b) +{ + return a.minX <= b.minX && + a.minY <= b.minY && + b.maxX <= a.maxX && + b.maxY <= a.maxY; +} + +function intersects (a, b) +{ + return b.minX <= a.maxX && + b.minY <= a.maxY && + b.maxX >= a.minX && + b.maxY >= a.minY; +} + +function createNode (children) +{ + return { + children: children, + height: 1, + leaf: true, + minX: Infinity, + minY: Infinity, + maxX: -Infinity, + maxY: -Infinity + }; +} + +// sort an array so that items come in groups of n unsorted items, with groups sorted between each other; +// combines selection algorithm with binary divide & conquer approach + +function multiSelect (arr, left, right, n, compare) +{ + var stack = [left, right], + mid; + + while (stack.length) + { + right = stack.pop(); + left = stack.pop(); + + if (right - left <= n) continue; + + mid = left + Math.ceil((right - left) / n / 2) * n; + quickselect(arr, mid, left, right, compare); + + stack.push(left, mid, mid, right); + } +} + +module.exports = rbush; /***/ }), @@ -38712,27 +44601,192 @@ module.exports = GetColor32; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Color = __webpack_require__(36); -var IntegerToRGB = __webpack_require__(206); +var Class = __webpack_require__(0); /** - * Converts the given color value into an instance of a Color object. + * @classdesc + * [description] * - * @function Phaser.Display.Color.IntegerToColor + * @class ProcessQueue + * @memberOf Phaser.Structs + * @constructor * @since 3.0.0 - * - * @param {integer} input - The color value to convert into a Color object. - * - * @return {Phaser.Display.Color} A Color object. */ -var IntegerToColor = function (input) -{ - var rgb = IntegerToRGB(input); +var ProcessQueue = new Class({ - return new Color(rgb.r, rgb.g, rgb.b, rgb.a); -}; + initialize: -module.exports = IntegerToColor; + function ProcessQueue () + { + /** + * [description] + * + * @name Phaser.Structs.ProcessQueue#_pending + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this._pending = []; + + /** + * [description] + * + * @name Phaser.Structs.ProcessQueue#_active + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this._active = []; + + /** + * [description] + * + * @name Phaser.Structs.ProcessQueue#_destroy + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this._destroy = []; + + /** + * [description] + * + * @name Phaser.Structs.ProcessQueue#_toProcess + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + this._toProcess = 0; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#add + * @since 3.0.0 + * + * @param {*} item - [description] + * + * @return {Phaser.Structs.ProcessQueue} This Process Queue object. + */ + add: function (item) + { + this._pending.push(item); + + this._toProcess++; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#remove + * @since 3.0.0 + * + * @param {*} item - [description] + * + * @return {Phaser.Structs.ProcessQueue} This Process Queue object. + */ + remove: function (item) + { + this._destroy.push(item); + + this._toProcess++; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#update + * @since 3.0.0 + * + * @return {array} [description] + */ + update: function () + { + if (this._toProcess === 0) + { + // Quick bail + return this._active; + } + + var list = this._destroy; + var active = this._active; + var i; + var item; + + // Clear the 'destroy' list + for (i = 0; i < list.length; i++) + { + item = list[i]; + + // Remove from the 'active' array + var idx = active.indexOf(item); + + if (idx !== -1) + { + active.splice(idx, 1); + } + } + + list.length = 0; + + // Process the pending addition list + // This stops callbacks and out of sync events from populating the active array mid-way during an update + + list = this._pending; + + for (i = 0; i < list.length; i++) + { + item = list[i]; + + this._active.push(item); + } + + list.length = 0; + + this._toProcess = 0; + + // The owner of this queue can now safely do whatever it needs to with the active list + return this._active; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#getActive + * @since 3.0.0 + * + * @return {array} [description] + */ + getActive: function () + { + return this._active; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#destroy + * @since 3.0.0 + */ + destroy: function () + { + this._pending = []; + this._active = []; + this._destroy = []; + } + +}); + +module.exports = ProcessQueue; /***/ }), @@ -38746,46 +44800,77 @@ module.exports = IntegerToColor; */ /** - * Return the component parts of a color as an Object with the properties alpha, red, green, blue. + * [description] * - * Alpha will only be set if it exists in the given color (0xAARRGGBB) - * - * @function Phaser.Display.Color.IntegerToRGB + * @function Phaser.Physics.Arcade.GetOverlapY * @since 3.0.0 * - * @param {integer} input - The color value to convert into a Color object. + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {boolean} overlapOnly - [description] + * @param {number} bias - [description] * - * @return {ColorObject} An object with the red, green and blue values set in the r, g and b properties. + * @return {number} [description] */ -var IntegerToRGB = function (color) +var GetOverlapY = function (body1, body2, overlapOnly, bias) { - if (color > 16777215) + var overlap = 0; + var maxOverlap = body1.deltaAbsY() + body2.deltaAbsY() + bias; + + if (body1.deltaY() === 0 && body2.deltaY() === 0) { - // The color value has an alpha component - return { - a: color >>> 24, - r: color >> 16 & 0xFF, - g: color >> 8 & 0xFF, - b: color & 0xFF - }; + // They overlap but neither of them are moving + body1.embedded = true; + body2.embedded = true; } - else + else if (body1.deltaY() > body2.deltaY()) { - return { - a: 255, - r: color >> 16 & 0xFF, - g: color >> 8 & 0xFF, - b: color & 0xFF - }; + // Body1 is moving down and/or Body2 is moving up + overlap = body1.bottom - body2.y; + + if ((overlap > maxOverlap && !overlapOnly) || body1.checkCollision.down === false || body2.checkCollision.up === false) + { + overlap = 0; + } + else + { + body1.touching.none = false; + body1.touching.down = true; + body2.touching.none = false; + body2.touching.up = true; + } } + else if (body1.deltaY() < body2.deltaY()) + { + // Body1 is moving up and/or Body2 is moving down + overlap = body1.y - body2.bottom; + + if ((-overlap > maxOverlap && !overlapOnly) || body1.checkCollision.up === false || body2.checkCollision.down === false) + { + overlap = 0; + } + else + { + body1.touching.none = false; + body1.touching.up = true; + body2.touching.none = false; + body2.touching.down = true; + } + } + + // Resets the overlapY to zero if there is no overlap, or to the actual pixel value if there is + body1.overlapY = overlap; + body2.overlapY = overlap; + + return overlap; }; -module.exports = IntegerToRGB; +module.exports = GetOverlapY; /***/ }), /* 207 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -38793,24 +44878,73 @@ module.exports = IntegerToRGB; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Color = __webpack_require__(36); - /** - * Converts an object containing `r`, `g`, `b` and `a` properties into a Color class instance. + * [description] * - * @function Phaser.Display.Color.ObjectToColor + * @function Phaser.Physics.Arcade.GetOverlapX * @since 3.0.0 * - * @param {object} input - An object containing `r`, `g`, `b` and `a` properties in the range 0 to 255. + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {boolean} overlapOnly - [description] + * @param {number} bias - [description] * - * @return {Phaser.Display.Color} A Color object. + * @return {number} [description] */ -var ObjectToColor = function (input) +var GetOverlapX = function (body1, body2, overlapOnly, bias) { - return new Color(input.r, input.g, input.b, input.a); + var overlap = 0; + var maxOverlap = body1.deltaAbsX() + body2.deltaAbsX() + bias; + + if (body1.deltaX() === 0 && body2.deltaX() === 0) + { + // They overlap but neither of them are moving + body1.embedded = true; + body2.embedded = true; + } + else if (body1.deltaX() > body2.deltaX()) + { + // Body1 is moving right and / or Body2 is moving left + overlap = body1.right - body2.x; + + if ((overlap > maxOverlap && !overlapOnly) || body1.checkCollision.right === false || body2.checkCollision.left === false) + { + overlap = 0; + } + else + { + body1.touching.none = false; + body1.touching.right = true; + body2.touching.none = false; + body2.touching.left = true; + } + } + else if (body1.deltaX() < body2.deltaX()) + { + // Body1 is moving left and/or Body2 is moving right + overlap = body1.x - body2.width - body2.x; + + if ((-overlap > maxOverlap && !overlapOnly) || body1.checkCollision.left === false || body2.checkCollision.right === false) + { + overlap = 0; + } + else + { + body1.touching.none = false; + body1.touching.left = true; + body2.touching.none = false; + body2.touching.right = true; + } + } + + // Resets the overlapX to zero if there is no overlap, or to the actual pixel value if there is + body1.overlapX = overlap; + body2.overlapX = overlap; + + return overlap; }; -module.exports = ObjectToColor; +module.exports = GetOverlapX; /***/ }), @@ -38823,121 +44957,178 @@ module.exports = ObjectToColor; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Color = __webpack_require__(36); +var Class = __webpack_require__(0); /** - * Converts a CSS 'web' string into a Phaser Color object. - * - * The web string can be in the format `'rgb(r,g,b)'` or `'rgba(r,g,b,a)'` where r/g/b are in the range [0..255] and a is in the range [0..1]. + * @classdesc + * [description] * - * @function Phaser.Display.Color.RGBStringToColor + * @class Collider + * @memberOf Phaser.Physics.Arcade + * @constructor * @since 3.0.0 * - * @param {string} rgb - The CSS format color string, using the `rgb` or `rgba` format. - * - * @return {Phaser.Display.Color} A Color object. + * @param {Phaser.Physics.Arcade.World} world - [description] + * @param {boolean} overlapOnly - [description] + * @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for collision. + * @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for collision. + * @param {ArcadePhysicsCallback} collideCallback - The callback to invoke when the two objects collide. + * @param {ArcadePhysicsCallback} processCallback - The callback to invoke when the two objects collide. Must return a boolean. + * @param {object} callbackContext - The scope in which to call the callbacks. */ -var RGBStringToColor = function (rgb) -{ - var color = new Color(); +var Collider = new Class({ - var result = (/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/).exec(rgb.toLowerCase()); + initialize: - if (result) + function Collider (world, overlapOnly, object1, object2, collideCallback, processCallback, callbackContext) { - var r = parseInt(result[1], 10); - var g = parseInt(result[2], 10); - var b = parseInt(result[3], 10); - var a = (result[4] !== undefined) ? parseFloat(result[4]) : 1; + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; - color.setTo(r, g, b, a * 255); + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#name + * @type {string} + * @since 3.1.0 + */ + this.name = ''; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#overlapOnly + * @type {boolean} + * @since 3.0.0 + */ + this.overlapOnly = overlapOnly; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#object1 + * @type {Phaser.Physics.Arcade.Body} + * @since 3.0.0 + */ + this.object1 = object1; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#object2 + * @type {Phaser.Physics.Arcade.Body} + * @since 3.0.0 + */ + this.object2 = object2; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#collideCallback + * @type {ArcadePhysicsCallback} + * @since 3.0.0 + */ + this.collideCallback = collideCallback; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#processCallback + * @type {ArcadePhysicsCallback} + * @since 3.0.0 + */ + this.processCallback = processCallback; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#callbackContext + * @type {object} + * @since 3.0.0 + */ + this.callbackContext = callbackContext; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Collider#setName + * @since 3.1.0 + * + * @param {string} name - [description] + * + * @return {Phaser.Physics.Arcade.Collider} [description] + */ + setName: function (name) + { + this.name = name; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Collider#update + * @since 3.0.0 + */ + update: function () + { + this.world.collideObjects( + this.object1, + this.object2, + this.collideCallback, + this.processCallback, + this.callbackContext, + this.overlapOnly + ); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Collider#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.world.removeCollider(this); + + this.active = false; + + this.world = null; + + this.object1 = null; + this.object2 = null; + + this.collideCallback = null; + this.processCallback = null; + this.callbackContext = null; } - return color; -}; +}); -module.exports = RGBStringToColor; +module.exports = Collider; /***/ }), /* 209 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Position Vector randomly in a spherical area defined by the given radius -/** - * [description] - * - * @function Phaser.Math.RandomXYZ - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} vec3 - [description] - * @param {number} [radius=1] - [description] - * - * @return {Phaser.Math.Vector3} [description] - */ -var RandomXYZ = function (vec3, radius) -{ - if (radius === undefined) { radius = 1; } - - var r = Math.random() * 2 * Math.PI; - var z = (Math.random() * 2) - 1; - var zScale = Math.sqrt(1 - z * z) * radius; - - vec3.x = Math.cos(r) * zScale; - vec3.y = Math.sin(r) * zScale; - vec3.z = z * radius; - - return vec3; -}; - -module.exports = RandomXYZ; - - -/***/ }), -/* 210 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.RandomXYZW - * @since 3.0.0 - * - * @param {Phaser.Math.Vector4} vec4 - [description] - * @param {float} [scale=1] - [description] - * - * @return {Phaser.Math.Vector4} [description] - */ -var RandomXYZW = function (vec4, scale) -{ - if (scale === undefined) { scale = 1; } - - // Not spherical; should fix this for more uniform distribution - vec4.x = (Math.random() * 2 - 1) * scale; - vec4.y = (Math.random() * 2 - 1) * scale; - vec4.z = (Math.random() * 2 - 1) * scale; - vec4.w = (Math.random() * 2 - 1) * scale; - - return vec4; -}; - -module.exports = RandomXYZW; - - -/***/ }), -/* 211 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -38946,8261 +45137,601 @@ module.exports = RandomXYZW; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Vector3 = __webpack_require__(51); -var Matrix4 = __webpack_require__(119); -var Quaternion = __webpack_require__(212); - -var tmpMat4 = new Matrix4(); -var tmpQuat = new Quaternion(); -var tmpVec3 = new Vector3(); - -/** - * Rotates a vector in place by axis angle. - * - * This is the same as transforming a point by an - * axis-angle quaternion, but it has higher precision. - * - * @function Phaser.Math.RotateVec3 - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} vec - [description] - * @param {Phaser.Math.Vector3} axis - [description] - * @param {float} radians - [description] - * - * @return {Phaser.Math.Vector3} [description] - */ -var RotateVec3 = function (vec, axis, radians) -{ - // Set the quaternion to our axis angle - tmpQuat.setAxisAngle(axis, radians); - - // Create a rotation matrix from the axis angle - tmpMat4.fromRotationTranslation(tmpQuat, tmpVec3.set(0, 0, 0)); - - // Multiply our vector by the rotation matrix - return vec.transformMat4(tmpMat4); -}; - -module.exports = RotateVec3; - - -/***/ }), -/* 212 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji -// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl - +var CircleContains = __webpack_require__(28); var Class = __webpack_require__(0); -var Vector3 = __webpack_require__(51); -var Matrix3 = __webpack_require__(213); - -var EPSILON = 0.000001; - -// Some shared 'private' arrays -var siNext = new Int8Array([ 1, 2, 0 ]); -var tmp = new Float32Array([ 0, 0, 0 ]); - -var xUnitVec3 = new Vector3(1, 0, 0); -var yUnitVec3 = new Vector3(0, 1, 0); - -var tmpvec = new Vector3(); -var tmpMat3 = new Matrix3(); - -/** - * @classdesc - * [description] - * - * @class Quaternion - * @memberOf Phaser.Math - * @constructor - * @since 3.0.0 - * - * @param {number} [x] - [description] - * @param {number} [y] - [description] - * @param {number} [z] - [description] - * @param {number} [w] - [description] - */ -var Quaternion = new Class({ - - initialize: - - function Quaternion (x, y, z, w) - { - /** - * The x component of this Quaternion. - * - * @name Phaser.Math.Quaternion#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - /** - * The y component of this Quaternion. - * - * @name Phaser.Math.Quaternion#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - /** - * The z component of this Quaternion. - * - * @name Phaser.Math.Quaternion#z - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - /** - * The w component of this Quaternion. - * - * @name Phaser.Math.Quaternion#w - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - if (typeof x === 'object') - { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - this.w = x.w || 0; - } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - this.w = w || 0; - } - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#copy - * @since 3.0.0 - * - * @param {[type]} src - [description] - * - * @return {[type]} [description] - */ - copy: function (src) - { - this.x = src.x; - this.y = src.y; - this.z = src.z; - this.w = src.w; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#set - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} z - [description] - * @param {[type]} w - [description] - * - * @return {[type]} [description] - */ - set: function (x, y, z, w) - { - if (typeof x === 'object') - { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - this.w = x.w || 0; - } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - this.w = w || 0; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#add - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - add: function (v) - { - this.x += v.x; - this.y += v.y; - this.z += v.z; - this.w += v.w; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#subtract - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - subtract: function (v) - { - this.x -= v.x; - this.y -= v.y; - this.z -= v.z; - this.w -= v.w; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#scale - * @since 3.0.0 - * - * @param {[type]} scale - [description] - * - * @return {[type]} [description] - */ - scale: function (scale) - { - this.x *= scale; - this.y *= scale; - this.z *= scale; - this.w *= scale; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#length - * @since 3.0.0 - * - * @return {[type]} [description] - */ - length: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - - return Math.sqrt(x * x + y * y + z * z + w * w); - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#lengthSq - * @since 3.0.0 - * - * @return {[type]} [description] - */ - lengthSq: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - - return x * x + y * y + z * z + w * w; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#normalize - * @since 3.0.0 - * - * @return {[type]} [description] - */ - normalize: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - var len = x * x + y * y + z * z + w * w; - - if (len > 0) - { - len = 1 / Math.sqrt(len); - - this.x = x * len; - this.y = y * len; - this.z = z * len; - this.w = w * len; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#dot - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - dot: function (v) - { - return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#lerp - * @since 3.0.0 - * - * @param {[type]} v - [description] - * @param {[type]} t - [description] - * - * @return {[type]} [description] - */ - lerp: function (v, t) - { - if (t === undefined) { t = 0; } - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - this.x = ax + t * (v.x - ax); - this.y = ay + t * (v.y - ay); - this.z = az + t * (v.z - az); - this.w = aw + t * (v.w - aw); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#rotationTo - * @since 3.0.0 - * - * @param {[type]} a - [description] - * @param {[type]} b - [description] - * - * @return {[type]} [description] - */ - rotationTo: function (a, b) - { - var dot = a.x * b.x + a.y * b.y + a.z * b.z; - - if (dot < -0.999999) - { - if (tmpvec.copy(xUnitVec3).cross(a).length() < EPSILON) - { - tmpvec.copy(yUnitVec3).cross(a); - } - - tmpvec.normalize(); - - return this.setAxisAngle(tmpvec, Math.PI); - - } - else if (dot > 0.999999) - { - this.x = 0; - this.y = 0; - this.z = 0; - this.w = 1; - - return this; - } - else - { - tmpvec.copy(a).cross(b); - - this.x = tmpvec.x; - this.y = tmpvec.y; - this.z = tmpvec.z; - this.w = 1 + dot; - - return this.normalize(); - } - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#setAxes - * @since 3.0.0 - * - * @param {[type]} view - [description] - * @param {[type]} right - [description] - * @param {[type]} up - [description] - * - * @return {[type]} [description] - */ - setAxes: function (view, right, up) - { - var m = tmpMat3.val; - - m[0] = right.x; - m[3] = right.y; - m[6] = right.z; - - m[1] = up.x; - m[4] = up.y; - m[7] = up.z; - - m[2] = -view.x; - m[5] = -view.y; - m[8] = -view.z; - - return this.fromMat3(tmpMat3).normalize(); - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#identity - * @since 3.0.0 - * - * @return {[type]} [description] - */ - identity: function () - { - this.x = 0; - this.y = 0; - this.z = 0; - this.w = 1; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#setAxisAngle - * @since 3.0.0 - * - * @param {[type]} axis - [description] - * @param {[type]} rad - [description] - * - * @return {[type]} [description] - */ - setAxisAngle: function (axis, rad) - { - rad = rad * 0.5; - - var s = Math.sin(rad); - - this.x = s * axis.x; - this.y = s * axis.y; - this.z = s * axis.z; - this.w = Math.cos(rad); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#multiply - * @since 3.0.0 - * - * @param {[type]} b - [description] - * - * @return {[type]} [description] - */ - multiply: function (b) - { - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - var bx = b.x; - var by = b.y; - var bz = b.z; - var bw = b.w; - - this.x = ax * bw + aw * bx + ay * bz - az * by; - this.y = ay * bw + aw * by + az * bx - ax * bz; - this.z = az * bw + aw * bz + ax * by - ay * bx; - this.w = aw * bw - ax * bx - ay * by - az * bz; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#slerp - * @since 3.0.0 - * - * @param {[type]} b - [description] - * @param {[type]} t - [description] - * - * @return {[type]} [description] - */ - slerp: function (b, t) - { - // benchmarks: http://jsperf.com/quaternion-slerp-implementations - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - var bx = b.x; - var by = b.y; - var bz = b.z; - var bw = b.w; - - // calc cosine - var cosom = ax * bx + ay * by + az * bz + aw * bw; - - // adjust signs (if necessary) - if (cosom < 0) - { - cosom = -cosom; - bx = - bx; - by = - by; - bz = - bz; - bw = - bw; - } - - // "from" and "to" quaternions are very close - // ... so we can do a linear interpolation - var scale0 = 1 - t; - var scale1 = t; - - // calculate coefficients - if ((1 - cosom) > EPSILON) - { - // standard case (slerp) - var omega = Math.acos(cosom); - var sinom = Math.sin(omega); - - scale0 = Math.sin((1.0 - t) * omega) / sinom; - scale1 = Math.sin(t * omega) / sinom; - } - - // calculate final values - this.x = scale0 * ax + scale1 * bx; - this.y = scale0 * ay + scale1 * by; - this.z = scale0 * az + scale1 * bz; - this.w = scale0 * aw + scale1 * bw; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#invert - * @since 3.0.0 - * - * @return {[type]} [description] - */ - invert: function () - { - var a0 = this.x; - var a1 = this.y; - var a2 = this.z; - var a3 = this.w; - - var dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3; - var invDot = (dot) ? 1 / dot : 0; - - // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0 - - this.x = -a0 * invDot; - this.y = -a1 * invDot; - this.z = -a2 * invDot; - this.w = a3 * invDot; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#conjugate - * @since 3.0.0 - * - * @return {[type]} [description] - */ - conjugate: function () - { - this.x = -this.x; - this.y = -this.y; - this.z = -this.z; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#rotateX - * @since 3.0.0 - * - * @param {[type]} rad - [description] - * - * @return {[type]} [description] - */ - rotateX: function (rad) - { - rad *= 0.5; - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - var bx = Math.sin(rad); - var bw = Math.cos(rad); - - this.x = ax * bw + aw * bx; - this.y = ay * bw + az * bx; - this.z = az * bw - ay * bx; - this.w = aw * bw - ax * bx; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#rotateY - * @since 3.0.0 - * - * @param {[type]} rad - [description] - * - * @return {[type]} [description] - */ - rotateY: function (rad) - { - rad *= 0.5; - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - var by = Math.sin(rad); - var bw = Math.cos(rad); - - this.x = ax * bw - az * by; - this.y = ay * bw + aw * by; - this.z = az * bw + ax * by; - this.w = aw * bw - ay * by; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#rotateZ - * @since 3.0.0 - * - * @param {[type]} rad - [description] - * - * @return {[type]} [description] - */ - rotateZ: function (rad) - { - rad *= 0.5; - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - var bz = Math.sin(rad); - var bw = Math.cos(rad); - - this.x = ax * bw + ay * bz; - this.y = ay * bw - ax * bz; - this.z = az * bw + aw * bz; - this.w = aw * bw - az * bz; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#calculateW - * @since 3.0.0 - * - * @return {[type]} [description] - */ - calculateW: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - - this.w = -Math.sqrt(Math.abs(1.0 - x * x - y * y - z * z)); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#fromMat3 - * @since 3.0.0 - * - * @param {[type]} mat - [description] - * - * @return {[type]} [description] - */ - fromMat3: function (mat) - { - // benchmarks: - // http://jsperf.com/typed-array-access-speed - // http://jsperf.com/conversion-of-3x3-matrix-to-quaternion - - // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes - // article "Quaternion Calculus and Fast Animation". - var m = mat.val; - var fTrace = m[0] + m[4] + m[8]; - var fRoot; - - if (fTrace > 0) - { - // |w| > 1/2, may as well choose w > 1/2 - fRoot = Math.sqrt(fTrace + 1.0); // 2w - - this.w = 0.5 * fRoot; - - fRoot = 0.5 / fRoot; // 1/(4w) - - this.x = (m[7] - m[5]) * fRoot; - this.y = (m[2] - m[6]) * fRoot; - this.z = (m[3] - m[1]) * fRoot; - } - else - { - // |w| <= 1/2 - var i = 0; - - if (m[4] > m[0]) - { - i = 1; - } - - if (m[8] > m[i * 3 + i]) - { - i = 2; - } - - var j = siNext[i]; - var k = siNext[j]; - - // This isn't quite as clean without array access - fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1); - tmp[i] = 0.5 * fRoot; - - fRoot = 0.5 / fRoot; - - tmp[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot; - tmp[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot; - - this.x = tmp[0]; - this.y = tmp[1]; - this.z = tmp[2]; - this.w = (m[k * 3 + j] - m[j * 3 + k]) * fRoot; - } - - return this; - } - -}); - -module.exports = Quaternion; - - -/***/ }), -/* 213 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji -// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class Matrix3 - * @memberOf Phaser.Math - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix3} [m] - [description] - */ - -var Matrix3 = new Class({ - - initialize: - - function Matrix3 (m) - { - /** - * [description] - * - * @name Phaser.Math.Matrix3#val - * @type {Float32Array} - * @since 3.0.0 - */ - this.val = new Float32Array(9); - - if (m) - { - // Assume Matrix3 with val: - this.copy(m); - } - else - { - // Default to identity - this.identity(); - } - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#clone - * @since 3.0.0 - * - * @return {[type]} [description] - */ - clone: function () - { - return new Matrix3(this); - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#set - * @since 3.0.0 - * - * @param {[type]} src - [description] - * - * @return {[type]} [description] - */ - set: function (src) - { - return this.copy(src); - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#copy - * @since 3.0.0 - * - * @param {[type]} src - [description] - * - * @return {[type]} [description] - */ - copy: function (src) - { - var out = this.val; - var a = src.val; - - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#fromMat4 - * @since 3.0.0 - * - * @param {[type]} m - [description] - * - * @return {[type]} [description] - */ - fromMat4: function (m) - { - var a = m.val; - var out = this.val; - - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[4]; - out[4] = a[5]; - out[5] = a[6]; - out[6] = a[8]; - out[7] = a[9]; - out[8] = a[10]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#fromArray - * @since 3.0.0 - * - * @param {[type]} a - [description] - * - * @return {[type]} [description] - */ - fromArray: function (a) - { - var out = this.val; - - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#identity - * @since 3.0.0 - * - * @return {[type]} [description] - */ - identity: function () - { - var out = this.val; - - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 1; - out[5] = 0; - out[6] = 0; - out[7] = 0; - out[8] = 1; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#transpose - * @since 3.0.0 - * - * @return {[type]} [description] - */ - transpose: function () - { - var a = this.val; - var a01 = a[1]; - var a02 = a[2]; - var a12 = a[5]; - - a[1] = a[3]; - a[2] = a[6]; - a[3] = a01; - a[5] = a[7]; - a[6] = a02; - a[7] = a12; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#invert - * @since 3.0.0 - * - * @return {[type]} [description] - */ - invert: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a10 = a[3]; - var a11 = a[4]; - var a12 = a[5]; - var a20 = a[6]; - var a21 = a[7]; - var a22 = a[8]; - - var b01 = a22 * a11 - a12 * a21; - var b11 = -a22 * a10 + a12 * a20; - var b21 = a21 * a10 - a11 * a20; - - // Calculate the determinant - var det = a00 * b01 + a01 * b11 + a02 * b21; - - if (!det) - { - return null; - } - - det = 1 / det; - - a[0] = b01 * det; - a[1] = (-a22 * a01 + a02 * a21) * det; - a[2] = (a12 * a01 - a02 * a11) * det; - a[3] = b11 * det; - a[4] = (a22 * a00 - a02 * a20) * det; - a[5] = (-a12 * a00 + a02 * a10) * det; - a[6] = b21 * det; - a[7] = (-a21 * a00 + a01 * a20) * det; - a[8] = (a11 * a00 - a01 * a10) * det; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#adjoint - * @since 3.0.0 - * - * @return {[type]} [description] - */ - adjoint: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a10 = a[3]; - var a11 = a[4]; - var a12 = a[5]; - var a20 = a[6]; - var a21 = a[7]; - var a22 = a[8]; - - a[0] = (a11 * a22 - a12 * a21); - a[1] = (a02 * a21 - a01 * a22); - a[2] = (a01 * a12 - a02 * a11); - a[3] = (a12 * a20 - a10 * a22); - a[4] = (a00 * a22 - a02 * a20); - a[5] = (a02 * a10 - a00 * a12); - a[6] = (a10 * a21 - a11 * a20); - a[7] = (a01 * a20 - a00 * a21); - a[8] = (a00 * a11 - a01 * a10); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#determinant - * @since 3.0.0 - * - * @return {[type]} [description] - */ - determinant: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a10 = a[3]; - var a11 = a[4]; - var a12 = a[5]; - var a20 = a[6]; - var a21 = a[7]; - var a22 = a[8]; - - return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20); - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#multiply - * @since 3.0.0 - * - * @param {[type]} src - [description] - * - * @return {[type]} [description] - */ - multiply: function (src) - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a10 = a[3]; - var a11 = a[4]; - var a12 = a[5]; - var a20 = a[6]; - var a21 = a[7]; - var a22 = a[8]; - - var b = src.val; - - var b00 = b[0]; - var b01 = b[1]; - var b02 = b[2]; - var b10 = b[3]; - var b11 = b[4]; - var b12 = b[5]; - var b20 = b[6]; - var b21 = b[7]; - var b22 = b[8]; - - a[0] = b00 * a00 + b01 * a10 + b02 * a20; - a[1] = b00 * a01 + b01 * a11 + b02 * a21; - a[2] = b00 * a02 + b01 * a12 + b02 * a22; - - a[3] = b10 * a00 + b11 * a10 + b12 * a20; - a[4] = b10 * a01 + b11 * a11 + b12 * a21; - a[5] = b10 * a02 + b11 * a12 + b12 * a22; - - a[6] = b20 * a00 + b21 * a10 + b22 * a20; - a[7] = b20 * a01 + b21 * a11 + b22 * a21; - a[8] = b20 * a02 + b21 * a12 + b22 * a22; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#translate - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - translate: function (v) - { - var a = this.val; - var x = v.x; - var y = v.y; - - a[6] = x * a[0] + y * a[3] + a[6]; - a[7] = x * a[1] + y * a[4] + a[7]; - a[8] = x * a[2] + y * a[5] + a[8]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#rotate - * @since 3.0.0 - * - * @param {[type]} rad - [description] - * - * @return {[type]} [description] - */ - rotate: function (rad) - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a10 = a[3]; - var a11 = a[4]; - var a12 = a[5]; - - var s = Math.sin(rad); - var c = Math.cos(rad); - - a[0] = c * a00 + s * a10; - a[1] = c * a01 + s * a11; - a[2] = c * a02 + s * a12; - - a[3] = c * a10 - s * a00; - a[4] = c * a11 - s * a01; - a[5] = c * a12 - s * a02; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#scale - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - scale: function (v) - { - var a = this.val; - var x = v.x; - var y = v.y; - - a[0] = x * a[0]; - a[1] = x * a[1]; - a[2] = x * a[2]; - - a[3] = y * a[3]; - a[4] = y * a[4]; - a[5] = y * a[5]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#fromQuat - * @since 3.0.0 - * - * @param {[type]} q - [description] - * - * @return {[type]} [description] - */ - fromQuat: function (q) - { - var x = q.x; - var y = q.y; - var z = q.z; - var w = q.w; - - var x2 = x + x; - var y2 = y + y; - var z2 = z + z; - - var xx = x * x2; - var xy = x * y2; - var xz = x * z2; - - var yy = y * y2; - var yz = y * z2; - var zz = z * z2; - - var wx = w * x2; - var wy = w * y2; - var wz = w * z2; - - var out = this.val; - - out[0] = 1 - (yy + zz); - out[3] = xy + wz; - out[6] = xz - wy; - - out[1] = xy - wz; - out[4] = 1 - (xx + zz); - out[7] = yz + wx; - - out[2] = xz + wy; - out[5] = yz - wx; - out[8] = 1 - (xx + yy); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#normalFromMat4 - * @since 3.0.0 - * - * @param {[type]} m - [description] - * - * @return {[type]} [description] - */ - normalFromMat4: function (m) - { - var a = m.val; - var out = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - var a30 = a[12]; - var a31 = a[13]; - var a32 = a[14]; - var a33 = a[15]; - - var b00 = a00 * a11 - a01 * a10; - var b01 = a00 * a12 - a02 * a10; - var b02 = a00 * a13 - a03 * a10; - var b03 = a01 * a12 - a02 * a11; - - var b04 = a01 * a13 - a03 * a11; - var b05 = a02 * a13 - a03 * a12; - var b06 = a20 * a31 - a21 * a30; - var b07 = a20 * a32 - a22 * a30; - - var b08 = a20 * a33 - a23 * a30; - var b09 = a21 * a32 - a22 * a31; - var b10 = a21 * a33 - a23 * a31; - var b11 = a22 * a33 - a23 * a32; - - // Calculate the determinant - var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; - - if (!det) - { - return null; - } - - det = 1 / det; - - out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; - out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det; - out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det; - - out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det; - out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det; - out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det; - - out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det; - out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det; - out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det; - - return this; - } - -}); - -module.exports = Matrix3; - - -/***/ }), -/* 214 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Camera = __webpack_require__(118); -var Class = __webpack_require__(0); -var Vector3 = __webpack_require__(51); - -// Local cache vars -var tmpVec3 = new Vector3(); - -/** - * @classdesc - * [description] - * - * @class OrthographicCamera - * @extends Phaser.Cameras.Sprite3D.Camera - * @memberOf Phaser.Cameras.Sprite3D - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {integer} viewportWidth - [description] - * @param {integer} viewportHeight - [description] - */ -var OrthographicCamera = new Class({ - - Extends: Camera, - - initialize: - - function OrthographicCamera (scene, viewportWidth, viewportHeight) - { - if (viewportWidth === undefined) { viewportWidth = 0; } - if (viewportHeight === undefined) { viewportHeight = 0; } - - Camera.call(this, scene); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.OrthographicCamera#viewportWidth - * @type {integer} - * @since 3.0.0 - */ - this.viewportWidth = viewportWidth; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.OrthographicCamera#viewportHeight - * @type {integer} - * @since 3.0.0 - */ - this.viewportHeight = viewportHeight; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.OrthographicCamera#_zoom - * @type {float} - * @private - * @since 3.0.0 - */ - this._zoom = 1.0; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.OrthographicCamera#near - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.near = 0; - - this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.OrthographicCamera#setToOrtho - * @since 3.0.0 - * - * @param {[type]} yDown - [description] - * @param {[type]} viewportWidth - [description] - * @param {[type]} viewportHeight - [description] - * - * @return {[type]} [description] - */ - setToOrtho: function (yDown, viewportWidth, viewportHeight) - { - if (viewportWidth === undefined) { viewportWidth = this.viewportWidth; } - if (viewportHeight === undefined) { viewportHeight = this.viewportHeight; } - - var zoom = this.zoom; - - this.up.set(0, (yDown) ? -1 : 1, 0); - this.direction.set(0, 0, (yDown) ? 1 : -1); - this.position.set(zoom * viewportWidth / 2, zoom * viewportHeight / 2, 0); - - this.viewportWidth = viewportWidth; - this.viewportHeight = viewportHeight; - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.OrthographicCamera#update - * @since 3.0.0 - * - * @return {[type]} [description] - */ - update: function () - { - var w = this.viewportWidth; - var h = this.viewportHeight; - var near = Math.abs(this.near); - var far = Math.abs(this.far); - var zoom = this.zoom; - - if (w === 0 || h === 0) - { - // What to do here... hmm? - return this; - } - - this.projection.ortho( - zoom * -w / 2, zoom * w / 2, - zoom * -h / 2, zoom * h / 2, - near, - far - ); - - // Build the view matrix - tmpVec3.copy(this.position).add(this.direction); - - this.view.lookAt(this.position, tmpVec3, this.up); - - // Projection * view matrix - this.combined.copy(this.projection).multiply(this.view); - - // Invert combined matrix, used for unproject - this.invProjectionView.copy(this.combined).invert(); - - this.billboardMatrixDirty = true; - - this.updateChildren(); - - return this; - }, - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.OrthographicCamera#zoom - * @type {number} - * @since 3.0.0 - */ - zoom: { - - get: function () - { - return this._zoom; - }, - - set: function (value) - { - this._zoom = value; - this.update(); - } - } - -}); - -module.exports = OrthographicCamera; - - -/***/ }), -/* 215 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Camera = __webpack_require__(118); -var Class = __webpack_require__(0); -var Vector3 = __webpack_require__(51); - -// Local cache vars -var tmpVec3 = new Vector3(); - -/** - * @classdesc - * [description] - * - * @class PerspectiveCamera - * @extends Phaser.Cameras.Sprite3D.Camera - * @memberOf Phaser.Cameras.Sprite3D - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {integer} fieldOfView - [description] - * @param {integer} viewportWidth - [description] - * @param {integer} viewportHeight - [description] - */ -var PerspectiveCamera = new Class({ - - Extends: Camera, - - // FOV is converted to radians automatically - initialize: - - function PerspectiveCamera (scene, fieldOfView, viewportWidth, viewportHeight) - { - if (fieldOfView === undefined) { fieldOfView = 80; } - if (viewportWidth === undefined) { viewportWidth = 0; } - if (viewportHeight === undefined) { viewportHeight = 0; } - - Camera.call(this, scene); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.PerspectiveCamera#viewportWidth - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.viewportWidth = viewportWidth; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.PerspectiveCamera#viewportHeight - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.viewportHeight = viewportHeight; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.PerspectiveCamera#fieldOfView - * @type {integer} - * @default 80 - * @since 3.0.0 - */ - this.fieldOfView = fieldOfView * Math.PI / 180; - - this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.PerspectiveCamera#setFOV - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setFOV: function (value) - { - this.fieldOfView = value * Math.PI / 180; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.PerspectiveCamera#update - * @since 3.0.0 - * - * @return {[type]} [description] - */ - update: function () - { - var aspect = this.viewportWidth / this.viewportHeight; - - // Create a perspective matrix for our camera - this.projection.perspective( - this.fieldOfView, - aspect, - Math.abs(this.near), - Math.abs(this.far) - ); - - // Build the view matrix - tmpVec3.copy(this.position).add(this.direction); - - this.view.lookAt(this.position, tmpVec3, this.up); - - // Projection * view matrix - this.combined.copy(this.projection).multiply(this.view); - - // Invert combined matrix, used for unproject - this.invProjectionView.copy(this.combined).invert(); - - this.billboardMatrixDirty = true; - - this.updateChildren(); - - return this; - } - -}); - -module.exports = PerspectiveCamera; - - -/***/ }), -/* 216 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Arne16 = __webpack_require__(217); -var CanvasPool = __webpack_require__(21); -var GetValue = __webpack_require__(4); - -/** - * [description] - * - * @function Phaser.Create.GenerateTexture - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {HTMLCanvasElement} [description] - */ -var GenerateTexture = function (config) -{ - var data = GetValue(config, 'data', []); - var canvas = GetValue(config, 'canvas', null); - var palette = GetValue(config, 'palette', Arne16); - var pixelWidth = GetValue(config, 'pixelWidth', 1); - var pixelHeight = GetValue(config, 'pixelHeight', pixelWidth); - var resizeCanvas = GetValue(config, 'resizeCanvas', true); - var clearCanvas = GetValue(config, 'clearCanvas', true); - var preRender = GetValue(config, 'preRender', null); - var postRender = GetValue(config, 'postRender', null); - - var width = Math.floor(Math.abs(data[0].length * pixelWidth)); - var height = Math.floor(Math.abs(data.length * pixelHeight)); - - if (!canvas) - { - canvas = CanvasPool.create2D(this, width, height); - resizeCanvas = false; - clearCanvas = false; - } - - if (resizeCanvas) - { - canvas.width = width; - canvas.height = height; - } - - var ctx = canvas.getContext('2d'); - - if (clearCanvas) - { - ctx.clearRect(0, 0, width, height); - } - - // preRender Callback? - if (preRender) - { - preRender(canvas, ctx); - } - - // Draw it - for (var y = 0; y < data.length; y++) - { - var row = data[y]; - - for (var x = 0; x < row.length; x++) - { - var d = row[x]; - - if (d !== '.' && d !== ' ') - { - ctx.fillStyle = palette[d]; - ctx.fillRect(x * pixelWidth, y * pixelHeight, pixelWidth, pixelHeight); - } - } - } - - // postRender Callback? - if (postRender) - { - postRender(canvas, ctx); - } - - return canvas; -}; - -module.exports = GenerateTexture; - - -/***/ }), -/* 217 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * A 16 color palette by [Arne](http://androidarts.com/palette/16pal.htm) - * - * @name Phaser.Create.Palettes.ARNE16 - * @since 3.0.0 - * - * @type {object} - * @property {string} 0 - Color value 1. - * @property {string} 1 - Color value 2. - * @property {string} 2 - Color value 3. - * @property {string} 3 - Color value 4. - * @property {string} 4 - Color value 5. - * @property {string} 5 - Color value 6. - * @property {string} 6 - Color value 7. - * @property {string} 7 - Color value 8. - * @property {string} 8 - Color value 9. - * @property {string} 9 - Color value 10. - * @property {string} A - Color value 11. - * @property {string} B - Color value 12. - * @property {string} C - Color value 13. - * @property {string} D - Color value 14. - * @property {string} E - Color value 15. - * @property {string} F - Color value 16. - */ -module.exports = { - 0: '#000', - 1: '#9D9D9D', - 2: '#FFF', - 3: '#BE2633', - 4: '#E06F8B', - 5: '#493C2B', - 6: '#A46422', - 7: '#EB8931', - 8: '#F7E26B', - 9: '#2F484E', - A: '#44891A', - B: '#A3CE27', - C: '#1B2632', - D: '#005784', - E: '#31A2F2', - F: '#B2DCEF' -}; - - -/***/ }), -/* 218 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) - -var Class = __webpack_require__(0); -var CubicBezier = __webpack_require__(219); -var Curve = __webpack_require__(52); +var CONST = __webpack_require__(47); +var Rectangle = __webpack_require__(10); +var RectangleContains = __webpack_require__(27); var Vector2 = __webpack_require__(6); /** - * @classdesc - * [description] + * @typedef {object} ArcadeBodyBounds * - * @class CubicBezierCurve - * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2|Phaser.Math.Vector2[]} p0 - Start point, or an array of point pairs. - * @param {Phaser.Math.Vector2} p1 - Control Point 1. - * @param {Phaser.Math.Vector2} p2 - Control Point 2. - * @param {Phaser.Math.Vector2} p3 - End Point. + * @property {number} x - [description] + * @property {number} y - [description] + * @property {number} right - [description] + * @property {number} bottom - [description] */ -var CubicBezierCurve = new Class({ - - Extends: Curve, - - initialize: - - function CubicBezierCurve (p0, p1, p2, p3) - { - Curve.call(this, 'CubicBezierCurve'); - - if (Array.isArray(p0)) - { - p3 = new Vector2(p0[6], p0[7]); - p2 = new Vector2(p0[4], p0[5]); - p1 = new Vector2(p0[2], p0[3]); - p0 = new Vector2(p0[0], p0[1]); - } - - /** - * [description] - * - * @name Phaser.Curves.CubicBezierCurve#p0 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p0 = p0; - - /** - * [description] - * - * @name Phaser.Curves.CubicBezierCurve#p1 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p1 = p1; - - /** - * [description] - * - * @name Phaser.Curves.CubicBezierCurve#p2 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p2 = p2; - - /** - * [description] - * - * @name Phaser.Curves.CubicBezierCurve#p3 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p3 = p3; - }, - - /** - * [description] - * - * @method Phaser.Curves.CubicBezierCurve#getStartPoint - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} out - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - getStartPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return out.copy(this.p0); - }, - - /** - * [description] - * - * @method Phaser.Curves.CubicBezierCurve#getResolution - * @since 3.0.0 - * - * @param {[type]} divisions - [description] - * - * @return {[type]} [description] - */ - getResolution: function (divisions) - { - return divisions; - }, - - /** - * [description] - * - * @method Phaser.Curves.CubicBezierCurve#getPoint - * @since 3.0.0 - * - * @param {[type]} t - [description] - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - var p0 = this.p0; - var p1 = this.p1; - var p2 = this.p2; - var p3 = this.p3; - - return out.set(CubicBezier(t, p0.x, p1.x, p2.x, p3.x), CubicBezier(t, p0.y, p1.y, p2.y, p3.y)); - }, - - /** - * [description] - * - * @method Phaser.Curves.CubicBezierCurve#draw - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - [description] - * @param {integer} [pointsTotal=32] - [description] - * - * @return {Phaser.GameObjects.Graphics} [description] - */ - draw: function (graphics, pointsTotal) - { - if (pointsTotal === undefined) { pointsTotal = 32; } - - var points = this.getPoints(pointsTotal); - - graphics.beginPath(); - graphics.moveTo(this.p0.x, this.p0.y); - - for (var i = 1; i < points.length; i++) - { - graphics.lineTo(points[i].x, points[i].y); - } - - graphics.strokePath(); - - // So you can chain graphics calls - return graphics; - }, - - /** - * [description] - * - * @method Phaser.Curves.CubicBezierCurve#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - return { - type: this.type, - points: [ - this.p0.x, this.p0.y, - this.p1.x, this.p1.y, - this.p2.x, this.p2.y, - this.p3.x, this.p3.y - ] - }; - } - -}); - -CubicBezierCurve.fromJSON = function (data) -{ - var points = data.points; - - var p0 = new Vector2(points[0], points[1]); - var p1 = new Vector2(points[2], points[3]); - var p2 = new Vector2(points[4], points[5]); - var p3 = new Vector2(points[6], points[7]); - - return new CubicBezierCurve(p0, p1, p2, p3); -}; - -module.exports = CubicBezierCurve; - - -/***/ }), -/* 219 */ -/***/ (function(module, exports) { /** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -function P0 (t, p) -{ - var k = 1 - t; - - return k * k * k * p; -} - -function P1 (t, p) -{ - var k = 1 - t; - - return 3 * k * k * t * p; -} - -function P2 (t, p) -{ - return 3 * (1 - t) * t * t * p; -} - -function P3 (t, p) -{ - return t * t * t * p; -} - -// p0 = start point -// p1 = control point 1 -// p2 = control point 2 -// p3 = end point - -// https://medium.com/@adrian_cooney/bezier-interpolation-13b68563313a - -/** - * [description] + * @typedef {object} ArcadeBodyCollision * - * @function Phaser.Math.Interpolation.CubicBezier - * @since 3.0.0 - * - * @param {float} t - [description] - * @param {number} p0 - [description] - * @param {number} p1 - [description] - * @param {number} p2 - [description] - * @param {number} p3 - [description] - * - * @return {number} [description] + * @property {boolean} none - [description] + * @property {boolean} up - [description] + * @property {boolean} down - [description] + * @property {boolean} left - [description] + * @property {boolean} right - [description] */ -var CubicBezierInterpolation = function (t, p0, p1, p2, p3) -{ - return P0(t, p0) + P1(t, p1) + P2(t, p2) + P3(t, p3); -}; - -module.exports = CubicBezierInterpolation; - - -/***/ }), -/* 220 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) - -var Class = __webpack_require__(0); -var Curve = __webpack_require__(52); -var DegToRad = __webpack_require__(35); -var GetValue = __webpack_require__(4); -var RadToDeg = __webpack_require__(221); -var Vector2 = __webpack_require__(6); /** * @classdesc * [description] * - * @class EllipseCurve - * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves + * @class Body + * @memberOf Phaser.Physics.Arcade * @constructor * @since 3.0.0 * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] - * @param {number} [xRadius=0] - [description] - * @param {number} [yRadius=0] - [description] - * @param {number} [startAngle=0] - [description] - * @param {number} [endAngle=360] - [description] - * @param {boolean} [clockwise=false] - [description] - * @param {number} [rotation=0] - [description] + * @param {Phaser.Physics.Arcade.World} world - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - [description] */ -var EllipseCurve = new Class({ - - Extends: Curve, +var Body = new Class({ initialize: - function EllipseCurve (x, y, xRadius, yRadius, startAngle, endAngle, clockwise, rotation) + function Body (world, gameObject) { - if (typeof x === 'object') - { - var config = x; - - x = GetValue(config, 'x', 0); - y = GetValue(config, 'y', 0); - xRadius = GetValue(config, 'xRadius', 0); - yRadius = GetValue(config, 'yRadius', xRadius); - startAngle = GetValue(config, 'startAngle', 0); - endAngle = GetValue(config, 'endAngle', 360); - clockwise = GetValue(config, 'clockwise', false); - rotation = GetValue(config, 'rotation', 0); - } - else - { - if (yRadius === undefined) { yRadius = xRadius; } - if (startAngle === undefined) { startAngle = 0; } - if (endAngle === undefined) { endAngle = 360; } - if (clockwise === undefined) { clockwise = false; } - if (rotation === undefined) { rotation = 0; } - } - - Curve.call(this, 'EllipseCurve'); - - // Center point + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; /** * [description] * - * @name {Phaser.MathPhaser.Curves.EllipseCurve#p0 - * @type {Phaser.Math.Vector2} + * @name Phaser.Physics.Arcade.Body#gameObject + * @type {Phaser.GameObjects.GameObject} * @since 3.0.0 */ - this.p0 = new Vector2(x, y); + this.gameObject = gameObject; /** * [description] * - * @name Phaser.Curves.EllipseCurve#_xRadius - * @type {number} - * @private - * @since 3.0.0 - */ - this._xRadius = xRadius; - - /** - * [description] - * - * @name Phaser.Curves.EllipseCurve#_yRadius - * @type {number} - * @private - * @since 3.0.0 - */ - this._yRadius = yRadius; - - // Radians - - /** - * [description] - * - * @name Phaser.Curves.EllipseCurve#_startAngle - * @type {number} - * @private - * @since 3.0.0 - */ - this._startAngle = DegToRad(startAngle); - - /** - * [description] - * - * @name Phaser.Curves.EllipseCurve#_endAngle - * @type {number} - * @private - * @since 3.0.0 - */ - this._endAngle = DegToRad(endAngle); - - /** - * Anti-clockwise direction. - * - * @name Phaser.Curves.EllipseCurve#_clockwise + * @name Phaser.Physics.Arcade.Body#debugShowBody * @type {boolean} - * @private * @since 3.0.0 */ - this._clockwise = clockwise; + this.debugShowBody = world.defaults.debugShowBody; /** - * The rotation of the arc. + * [description] * - * @name Phaser.Curves.EllipseCurve#_rotation - * @type {number} - * @private + * @name Phaser.Physics.Arcade.Body#debugShowVelocity + * @type {boolean} * @since 3.0.0 */ - this._rotation = DegToRad(rotation); - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#getStartPoint - * @since 3.0.0 - * - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - getStartPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return this.getPoint(0, out); - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#getResolution - * @since 3.0.0 - * - * @param {[type]} divisions - [description] - * - * @return {[type]} [description] - */ - getResolution: function (divisions) - { - return divisions * 2; - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#getPoint - * @since 3.0.0 - * - * @param {[type]} t - [description] - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - var twoPi = Math.PI * 2; - var deltaAngle = this._endAngle - this._startAngle; - var samePoints = Math.abs(deltaAngle) < Number.EPSILON; - - // ensures that deltaAngle is 0 .. 2 PI - while (deltaAngle < 0) - { - deltaAngle += twoPi; - } - - while (deltaAngle > twoPi) - { - deltaAngle -= twoPi; - } - - if (deltaAngle < Number.EPSILON) - { - if (samePoints) - { - deltaAngle = 0; - } - else - { - deltaAngle = twoPi; - } - } - - if (this._clockwise && !samePoints) - { - if (deltaAngle === twoPi) - { - deltaAngle = - twoPi; - } - else - { - deltaAngle = deltaAngle - twoPi; - } - } - - var angle = this._startAngle + t * deltaAngle; - var x = this.p0.x + this._xRadius * Math.cos(angle); - var y = this.p0.y + this._yRadius * Math.sin(angle); - - if (this._rotation !== 0) - { - var cos = Math.cos(this._rotation); - var sin = Math.sin(this._rotation); - - var tx = x - this.p0.x; - var ty = y - this.p0.y; - - // Rotate the point about the center of the ellipse. - x = tx * cos - ty * sin + this.p0.x; - y = tx * sin + ty * cos + this.p0.y; - } - - return out.set(x, y); - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#setXRadius - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setXRadius: function (value) - { - this.xRadius = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#setYRadius - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setYRadius: function (value) - { - this.yRadius = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#setWidth - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setWidth: function (value) - { - this.xRadius = value * 2; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#setHeight - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setHeight: function (value) - { - this.yRadius = value * 2; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#setStartAngle - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setStartAngle: function (value) - { - this.startAngle = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#setEndAngle - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setEndAngle: function (value) - { - this.endAngle = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#setClockwise - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setClockwise: function (value) - { - this.clockwise = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#setRotation - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setRotation: function (value) - { - this.rotation = value; - - return this; - }, - - /** - * [description] - * - * @name Phaser.Curves.EllipseCurve#x - * @type {number} - * @since 3.0.0 - */ - x: { - - get: function () - { - return this.p0.x; - }, - - set: function (value) - { - this.p0.x = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.EllipseCurve#y - * @type {number} - * @since 3.0.0 - */ - y: { - - get: function () - { - return this.p0.y; - }, - - set: function (value) - { - this.p0.y = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.EllipseCurve#xRadius - * @type {number} - * @since 3.0.0 - */ - xRadius: { - - get: function () - { - return this._xRadius; - }, - - set: function (value) - { - this._xRadius = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.EllipseCurve#yRadius - * @type {number} - * @since 3.0.0 - */ - yRadius: { - - get: function () - { - return this._yRadius; - }, - - set: function (value) - { - this._yRadius = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.EllipseCurve#startAngle - * @type {number} - * @since 3.0.0 - */ - startAngle: { - - get: function () - { - return RadToDeg(this._startAngle); - }, - - set: function (value) - { - this._startAngle = DegToRad(value); - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.EllipseCurve#endAngle - * @type {number} - * @since 3.0.0 - */ - endAngle: { - - get: function () - { - return RadToDeg(this._endAngle); - }, - - set: function (value) - { - this._endAngle = DegToRad(value); - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.EllipseCurve#clockwise - * @type {number} - * @since 3.0.0 - */ - clockwise: { - - get: function () - { - return this._clockwise; - }, - - set: function (value) - { - this._clockwise = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.EllipseCurve#rotation - * @type {number} - * @since 3.0.0 - */ - rotation: { - - get: function () - { - return this._rotation; - }, - - set: function (value) - { - this._rotation = DegToRad(value); - } - - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - return { - type: this.type, - x: this.p0.x, - y: this.p0.y, - xRadius: this._xRadius, - yRadius: this._yRadius, - startAngle: RadToDeg(this._startAngle), - endAngle: RadToDeg(this._endAngle), - clockwise: this._clockwise, - rotation: RadToDeg(this._rotation) - }; - } - -}); - -EllipseCurve.fromJSON = function (data) -{ - return new EllipseCurve(data); -}; - -module.exports = EllipseCurve; - - -/***/ }), -/* 221 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(16); - -/** - * [description] - * - * @function Phaser.Math.RadToDeg - * @since 3.0.0 - * - * @param {float} radians - [description] - * - * @return {integer} [description] - */ -var RadToDeg = function (radians) -{ - return radians * CONST.RAD_TO_DEG; -}; - -module.exports = RadToDeg; - - -/***/ }), -/* 222 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) - -var Class = __webpack_require__(0); -var Curve = __webpack_require__(52); -var FromPoints = __webpack_require__(122); -var Rectangle = __webpack_require__(8); -var Vector2 = __webpack_require__(6); - -var tmpVec2 = new Vector2(); - -/** - * @classdesc - * [description] - * - * @class LineCurve - * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} p0 - [description] - * @param {Phaser.Math.Vector2} p1 - [description] - */ -var LineCurve = new Class({ - - Extends: Curve, - - initialize: - - // vec2s or array - function LineCurve (p0, p1) - { - Curve.call(this, 'LineCurve'); - - if (Array.isArray(p0)) - { - p1 = new Vector2(p0[2], p0[3]); - p0 = new Vector2(p0[0], p0[1]); - } + this.debugShowVelocity = world.defaults.debugShowVelocity; /** * [description] * - * @name Phaser.Curves.LineCurve#p0 - * @type {Phaser.Math.Vector2} + * @name Phaser.Physics.Arcade.Body#debugBodyColor + * @type {integer} * @since 3.0.0 */ - this.p0 = p0; + this.debugBodyColor = world.defaults.bodyDebugColor; /** * [description] * - * @property Phaser.Curves.LineCurve#p1 - * @type {Phaser.Math.Vector2} + * @name Phaser.Physics.Arcade.Body#enable + * @type {boolean} + * @default true * @since 3.0.0 */ - this.p1 = p1; - }, - - /** - * [description] - * - * @method Phaser.Curves.LineCurve#getBounds - * @since 3.0.0 - * - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - getBounds: function (out) - { - if (out === undefined) { out = new Rectangle(); } - - return FromPoints([ this.p0, this.p1 ], out); - }, - - /** - * [description] - * - * @method Phaser.Curves.LineCurve#getStartPoint - * @since 3.0.0 - * - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - getStartPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return out.copy(this.p0); - }, - - /** - * [description] - * - * @method Phaser.Curves.LineCurve#getResolution - * @since 3.0.0 - * - * @return {integer} [description] - */ - getResolution: function () - { - return 1; - }, - - /** - * [description] - * - * @method Phaser.Curves.LineCurve#getPoint - * @since 3.0.0 - * - * @param {[type]} t - [description] - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - if (t === 1) - { - return out.copy(this.p1); - } - - out.copy(this.p1).subtract(this.p0).scale(t).add(this.p0); - - return out; - }, - - // Line curve is linear, so we can overwrite default getPointAt - /** - * [description] - * - * @method Phaser.Curves.LineCurve#getPointAt - * @since 3.0.0 - * - * @param {[type]} u - [description] - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - getPointAt: function (u, out) - { - return this.getPoint(u, out); - }, - - /** - * [description] - * - * @method Phaser.Curves.LineCurve#getTangent - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getTangent: function () - { - var tangent = tmpVec2.copy(this.p1).subtract(this.p0); - - return tangent.normalize(); - }, - - // Override default Curve.draw because this is better than calling getPoints on a line! - /** - * [description] - * - * @method Phaser.Curves.LineCurve#draw - * @since 3.0.0 - * - * @param {[type]} graphics - [description] - * - * @return {[type]} [description] - */ - draw: function (graphics) - { - graphics.lineBetween(this.p0.x, this.p0.y, this.p1.x, this.p1.y); - - // So you can chain graphics calls - return graphics; - }, - - /** - * [description] - * - * @method Phaser.Curves.LineCurve#toJSON - * @since 3.0.0 - * - * @return {[type]} [description] - */ - toJSON: function () - { - return { - type: this.type, - points: [ - this.p0.x, this.p0.y, - this.p1.x, this.p1.y - ] - }; - } - -}); - -LineCurve.fromJSON = function (data) -{ - var points = data.points; - - var p0 = new Vector2(points[0], points[1]); - var p1 = new Vector2(points[2], points[3]); - - return new LineCurve(p0, p1); -}; - -module.exports = LineCurve; - - -/***/ }), -/* 223 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Curve = __webpack_require__(52); -var QuadraticBezierInterpolation = __webpack_require__(224); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * [description] - * - * @class QuadraticBezier - * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves - * @constructor - * @since 3.2.0 - * - * @param {Phaser.Math.Vector2|Phaser.Math.Vector2[]} p0 - Start point, or an array of point pairs. - * @param {Phaser.Math.Vector2} p1 - Control Point 1. - * @param {Phaser.Math.Vector2} p2 - Control Point 2. - */ -var QuadraticBezier = new Class({ - - Extends: Curve, - - initialize: - - function QuadraticBezier (p0, p1, p2) - { - Curve.call(this, 'QuadraticBezier'); - - if (Array.isArray(p0)) - { - p2 = new Vector2(p0[4], p0[5]); - p1 = new Vector2(p0[2], p0[3]); - p0 = new Vector2(p0[0], p0[1]); - } + this.enable = true; /** * [description] * - * @name Phaser.Curves.QuadraticBezier#p0 - * @type {Phaser.Math.Vector2} - * @since 3.2.0 - */ - this.p0 = p0; - - /** - * [description] - * - * @name Phaser.Curves.QuadraticBezier#p1 - * @type {Phaser.Math.Vector2} - * @since 3.2.0 - */ - this.p1 = p1; - - /** - * [description] - * - * @name Phaser.Curves.QuadraticBezier#p2 - * @type {Phaser.Math.Vector2} - * @since 3.2.0 - */ - this.p2 = p2; - }, - - /** - * [description] - * - * @method Phaser.Curves.QuadraticBezier#getStartPoint - * @since 3.2.0 - * - * @param {Phaser.Math.Vector2} out - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - getStartPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return out.copy(this.p0); - }, - - /** - * [description] - * - * @method Phaser.Curves.QuadraticBezier#getResolution - * @since 3.2.0 - * - * @param {number} divisions - [description] - * - * @return {number} [description] - */ - getResolution: function (divisions) - { - return divisions; - }, - - /** - * [description] - * - * @method Phaser.Curves.QuadraticBezier#getPoint - * @since 3.2.0 - * - * @param {number} t - [description] - * @param {Phaser.Math.Vector2} [out] - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - var p0 = this.p0; - var p1 = this.p1; - var p2 = this.p2; - - return out.set( - QuadraticBezierInterpolation(t, p0.x, p1.x, p2.x), - QuadraticBezierInterpolation(t, p0.y, p1.y, p2.y) - ); - }, - - /** - * [description] - * - * @method Phaser.Curves.QuadraticBezier#draw - * @since 3.2.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - [description] - * @param {integer} [pointsTotal=32] - [description] - * - * @return {Phaser.GameObjects.Graphics} [description] - */ - draw: function (graphics, pointsTotal) - { - if (pointsTotal === undefined) { pointsTotal = 32; } - - var points = this.getPoints(pointsTotal); - - graphics.beginPath(); - graphics.moveTo(this.p0.x, this.p0.y); - - for (var i = 1; i < points.length; i++) - { - graphics.lineTo(points[i].x, points[i].y); - } - - graphics.strokePath(); - - // So you can chain graphics calls - return graphics; - }, - - /** - * [description] - * - * @method Phaser.Curves.QuadraticBezier#toJSON - * @since 3.2.0 - * - * @return {object} [description] - */ - toJSON: function () - { - return { - type: this.type, - points: [ - this.p0.x, this.p0.y, - this.p1.x, this.p1.y, - this.p2.x, this.p2.y - ] - }; - } - -}); - -QuadraticBezier.fromJSON = function (data) -{ - var points = data.points; - - var p0 = new Vector2(points[0], points[1]); - var p1 = new Vector2(points[2], points[3]); - var p2 = new Vector2(points[4], points[5]); - - return new QuadraticBezier(p0, p1, p2); -}; - -module.exports = QuadraticBezier; - - -/***/ }), -/* 224 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -function P0 (t, p) -{ - var k = 1 - t; - - return k * k * p; -} - -function P1 (t, p) -{ - return 2 * (1 - t) * t * p; -} - -function P2 (t, p) -{ - return t * t * p; -} - -// p0 = start point -// p1 = control point 1 -// p2 = end point - -// https://github.com/mrdoob/three.js/blob/master/src/extras/core/Interpolations.js - -/** - * [description] - * - * @function Phaser.Math.Interpolation.QuadraticBezier - * @since 3.2.0 - * - * @param {float} t - [description] - * @param {number} p0 - [description] - * @param {number} p1 - [description] - * @param {number} p2 - [description] - * - * @return {number} [description] - */ -var QuadraticBezierInterpolation = function (t, p0, p1, p2) -{ - return P0(t, p0) + P1(t, p1) + P2(t, p2); -}; - -module.exports = QuadraticBezierInterpolation; - - -/***/ }), -/* 225 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) - -var CatmullRom = __webpack_require__(123); -var Class = __webpack_require__(0); -var Curve = __webpack_require__(52); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * [description] - * - * @class SplineCurve - * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2[]} [points] - [description] - */ -var SplineCurve = new Class({ - - Extends: Curve, - - initialize: - - function SplineCurve (points) - { - if (points === undefined) { points = []; } - - Curve.call(this, 'SplineCurve'); - - /** - * [description] - * - * @name Phaser.Curves.SplineCurve#points - * @type {Phaser.Math.Vector2[]} - * @default [] - * @since 3.0.0 - */ - this.points = []; - - this.addPoints(points); - }, - - /** - * [description] - * - * @method Phaser.Curves.SplineCurve#addPoints - * @since 3.0.0 - * - * @param {[type]} points - [description] - * - * @return {[type]} [description] - */ - addPoints: function (points) - { - for (var i = 0; i < points.length; i++) - { - var p = new Vector2(); - - if (typeof points[i] === 'number') - { - p.x = points[i]; - p.y = points[i + 1]; - i++; - } - else if (Array.isArray(points[i])) - { - // An array of arrays? - p.x = points[i][0]; - p.y = points[i][1]; - } - else - { - p.x = points[i].x; - p.y = points[i].y; - } - - this.points.push(p); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Curves.SplineCurve#addPoint - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - addPoint: function (x, y) - { - var vec = new Vector2(x, y); - - this.points.push(vec); - - return vec; - }, - - /** - * [description] - * - * @method Phaser.Curves.SplineCurve#getStartPoint - * @since 3.0.0 - * - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - getStartPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return out.copy(this.points[0]); - }, - - /** - * [description] - * - * @method Phaser.Curves.SplineCurve#getResolution - * @since 3.0.0 - * - * @param {[type]} divisions - [description] - * - * @return {[type]} [description] - */ - getResolution: function (divisions) - { - return divisions * this.points.length; - }, - - /** - * [description] - * - * @method Phaser.Curves.SplineCurve#getPoint - * @since 3.0.0 - * - * @param {[type]} t - [description] - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - var points = this.points; - - var point = (points.length - 1) * t; - - var intPoint = Math.floor(point); - - var weight = point - intPoint; - - var p0 = points[(intPoint === 0) ? intPoint : intPoint - 1]; - var p1 = points[intPoint]; - var p2 = points[(intPoint > points.length - 2) ? points.length - 1 : intPoint + 1]; - var p3 = points[(intPoint > points.length - 3) ? points.length - 1 : intPoint + 2]; - - return out.set(CatmullRom(weight, p0.x, p1.x, p2.x, p3.x), CatmullRom(weight, p0.y, p1.y, p2.y, p3.y)); - }, - - /** - * [description] - * - * @method Phaser.Curves.SplineCurve#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - var points = []; - - for (var i = 0; i < this.points.length; i++) - { - points.push(this.points[i].x); - points.push(this.points[i].y); - } - - return { - type: this.type, - points: points - }; - } - -}); - -SplineCurve.fromJSON = function (data) -{ - return new SplineCurve(data.points); -}; - -module.exports = SplineCurve; - - -/***/ }), -/* 226 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Canvas.CanvasInterpolation - * @since 3.0.0 - */ -var CanvasInterpolation = { - - /** - * Sets the CSS image-rendering property on the given canvas to be 'crisp' (aka 'optimize contrast' on webkit). - * - * @function Phaser.Display.Canvas.CanvasInterpolation.setCrisp - * @since 3.0.0 - * - * @param {HTMLCanvasElement} canvas - The canvas object to have the style set on. - * - * @return {HTMLCanvasElement} The canvas. - */ - setCrisp: function (canvas) - { - var types = [ 'optimizeSpeed', 'crisp-edges', '-moz-crisp-edges', '-webkit-optimize-contrast', 'optimize-contrast', 'pixelated' ]; - - types.forEach(function (type) - { - canvas.style['image-rendering'] = type; - }); - - canvas.style.msInterpolationMode = 'nearest-neighbor'; - - return canvas; - }, - - /** - * Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto'). - * - * @function Phaser.Display.Canvas.CanvasInterpolation.setBicubic - * @since 3.0.0 - * - * @param {HTMLCanvasElement} canvas - The canvas object to have the style set on. - * - * @return {HTMLCanvasElement} The canvas. - */ - setBicubic: function (canvas) - { - canvas.style['image-rendering'] = 'auto'; - canvas.style.msInterpolationMode = 'bicubic'; - - return canvas; - } - -}; - -module.exports = CanvasInterpolation; - - -/***/ }), -/* 227 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Color - */ - -var Color = __webpack_require__(36); - -Color.ColorToRGBA = __webpack_require__(494); -Color.ComponentToHex = __webpack_require__(228); -Color.GetColor = __webpack_require__(117); -Color.GetColor32 = __webpack_require__(204); -Color.HexStringToColor = __webpack_require__(203); -Color.HSLToColor = __webpack_require__(495); -Color.HSVColorWheel = __webpack_require__(497); -Color.HSVToRGB = __webpack_require__(230); -Color.HueToComponent = __webpack_require__(229); -Color.IntegerToColor = __webpack_require__(205); -Color.IntegerToRGB = __webpack_require__(206); -Color.Interpolate = __webpack_require__(498); -Color.ObjectToColor = __webpack_require__(207); -Color.RandomRGB = __webpack_require__(499); -Color.RGBStringToColor = __webpack_require__(208); -Color.RGBToHSV = __webpack_require__(500); -Color.RGBToString = __webpack_require__(501); -Color.ValueToColor = __webpack_require__(116); - -module.exports = Color; - - -/***/ }), -/* 228 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns a string containing a hex representation of the given color component. - * - * @function Phaser.Display.Color.ComponentToHex - * @since 3.0.0 - * - * @param {integer} color - The color channel to get the hex value for, must be a value between 0 and 255. - * - * @return {string} A string of length 2 characters, i.e. 255 = ff, 100 = 64. - */ -var ComponentToHex = function (color) -{ - var hex = color.toString(16); - - return (hex.length === 1) ? '0' + hex : hex; -}; - -module.exports = ComponentToHex; - - -/***/ }), -/* 229 */ -/***/ (function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(module) {/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Converts a hue to an RGB color. - * Based on code by Michael Jackson (https://github.com/mjijackson) - * - * @function Phaser.Display.Color.HueToComponent - * @since 3.0.0 - * - * @param {number} p - * @param {number} q - * @param {number} t - * - * @return {number} The combined color value. - */ -var HueToComponent = function (p, q, t) -{ - if (t < 0) - { - t += 1; - } - - if (t > 1) - { - t -= 1; - } - - if (t < 1 / 6) - { - return p + (q - p) * 6 * t; - } - - if (t < 1 / 2) - { - return q; - } - - if (t < 2 / 3) - { - return p + (q - p) * (2 / 3 - t) * 6; - } - - return p; -}; - -module.export = HueToComponent; - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(496)(module))) - -/***/ }), -/* 230 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetColor = __webpack_require__(117); - -/** - * Converts an HSV (hue, saturation and value) color value to RGB. - * Conversion formula from http://en.wikipedia.org/wiki/HSL_color_space. - * Assumes HSV values are contained in the set [0, 1]. - * Based on code by Michael Jackson (https://github.com/mjijackson) - * - * @function Phaser.Display.Color.HSVToRGB - * @since 3.0.0 - * - * @param {number} h - The hue, in the range 0 - 1. - * @param {number} s - The saturation, in the range 0 - 1. - * @param {number} v - The value, in the range 0 - 1. - * - * @return {ColorObject} An object with the red, green and blue values set in the r, g and b properties. - */ -var HSVToRGB = function (h, s, v) -{ - if (s === undefined) { s = 1; } - if (v === undefined) { v = 1; } - - var i = Math.floor(h * 6); - var f = h * 6 - i; - - var p = Math.floor((v * (1 - s)) * 255); - var q = Math.floor((v * (1 - f * s)) * 255); - var t = Math.floor((v * (1 - (1 - f) * s)) * 255); - - v = Math.floor(v *= 255); - - var output = { r: v, g: v, b: v, color: 0 }; - - var r = i % 6; - - if (r === 0) - { - output.g = t; - output.b = p; - } - else if (r === 1) - { - output.r = q; - output.b = p; - } - else if (r === 2) - { - output.r = p; - output.b = t; - } - else if (r === 3) - { - output.r = p; - output.g = q; - } - else if (r === 4) - { - output.r = t; - output.g = p; - } - else if (r === 5) - { - output.g = p; - output.b = q; - } - - output.color = GetColor(output.r, output.g, output.b); - - return output; -}; - -module.exports = HSVToRGB; - - -/***/ }), -/* 231 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Between - * @since 3.0.0 - * - * @param {integer} min - [description] - * @param {integer} max - [description] - * - * @return {integer} [description] - */ -var Between = function (min, max) -{ - return Math.floor(Math.random() * (max - min + 1) + min); -}; - -module.exports = Between; - - -/***/ }), -/* 232 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var OS = __webpack_require__(67); - -/** - * Inspects the readyState of the document. If the document is already complete then it invokes the given callback. - * If not complete it sets up several event listeners such as `deviceready`, and once those fire, it invokes the callback. - * Called automatically by the Phaser.Game instance. Should not usually be accessed directly. - * - * @function Phaser.DOM.DOMContentLoaded - * @since 3.0.0 - * - * @param {function} callback - The callback to be invoked when the device is ready and the DOM content is loaded. - */ -var DOMContentLoaded = function (callback) -{ - if (document.readyState === 'complete' || document.readyState === 'interactive') - { - callback(); - - return; - } - - var check = function () - { - document.removeEventListener('deviceready', check, true); - document.removeEventListener('DOMContentLoaded', check, true); - window.removeEventListener('load', check, true); - - callback(); - }; - - if (!document.body) - { - window.setTimeout(check, 20); - } - else if (OS.cordova && !OS.cocoonJS) - { - // Ref. http://docs.phonegap.com/en/3.5.0/cordova_events_events.md.html#deviceready - document.addEventListener('deviceready', check, false); - } - else - { - document.addEventListener('DOMContentLoaded', check, true); - window.addEventListener('load', check, true); - } -}; - -module.exports = DOMContentLoaded; - - -/***/ }), -/* 233 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Takes the given data string and parses it as XML. - * First tries to use the window.DOMParser and reverts to the Microsoft.XMLDOM if that fails. - * The parsed XML object is returned, or `null` if there was an error while parsing the data. - * - * @function Phaser.DOM.ParseXML - * @since 3.0.0 - * - * @param {string} data - The XML source stored in a string. - * - * @return {any} The parsed XML data, or `null` if the data could not be parsed. - */ -var ParseXML = function (data) -{ - var xml = ''; - - try - { - if (window['DOMParser']) - { - var domparser = new DOMParser(); - xml = domparser.parseFromString(data, 'text/xml'); - } - else - { - xml = new ActiveXObject('Microsoft.XMLDOM'); - xml.loadXML(data); - } - } - catch (e) - { - xml = null; - } - - if (!xml || !xml.documentElement || xml.getElementsByTagName('parsererror').length) - { - return null; - } - else - { - return xml; - } -}; - -module.exports = ParseXML; - - -/***/ }), -/* 234 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Attempts to remove the element from its parentNode in the DOM. - * - * @function Phaser.DOM.RemoveFromDOM - * @since 3.0.0 - * - * @param {any} element - The DOM element to remove from its parent node. - */ -var RemoveFromDOM = function (element) -{ - if (element.parentNode) - { - element.parentNode.removeChild(element); - } -}; - -module.exports = RemoveFromDOM; - - -/***/ }), -/* 235 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var NOOP = __webpack_require__(3); - -/** - * @classdesc - * Abstracts away the use of RAF or setTimeOut for the core game update loop. - * This is invoked automatically by the Phaser.Game instance. - * - * @class RequestAnimationFrame - * @memberOf Phaser.DOM - * @constructor - * @since 3.0.0 - */ -var RequestAnimationFrame = new Class({ - - initialize: - - function RequestAnimationFrame () - { - /** - * True if RequestAnimationFrame is running, otherwise false. - * - * @name Phaser.DOM.RequestAnimationFrame#isRunning + * @name Phaser.Physics.Arcade.Body#isCircle * @type {boolean} * @default false * @since 3.0.0 */ - this.isRunning = false; + this.isCircle = false; /** - * The callback to be invoked each step. + * [description] * - * @name Phaser.DOM.RequestAnimationFrame#callback - * @type {function} - * @since 3.0.0 - */ - this.callback = NOOP; - - /** - * The most recent timestamp. Either a DOMHighResTimeStamp under RAF or `Date.now` under SetTimeout. - * - * @name Phaser.DOM.RequestAnimationFrame#tick - * @type {DOMHighResTimeStamp|number} + * @name Phaser.Physics.Arcade.Body#radius + * @type {number} * @default 0 * @since 3.0.0 */ - this.tick = 0; + this.radius = 0; /** - * True if the step is using setTimeout instead of RAF. + * [description] * - * @name Phaser.DOM.RequestAnimationFrame#isSetTimeOut - * @type {boolean} - * @default false + * @name Phaser.Physics.Arcade.Body#offset + * @type {Phaser.Math.Vector2} * @since 3.0.0 */ - this.isSetTimeOut = false; + this.offset = new Vector2(); /** - * The setTimeout or RAF callback ID used when canceling them. + * [description] * - * @name Phaser.DOM.RequestAnimationFrame#timeOutID - * @type {?number} + * @name Phaser.Physics.Arcade.Body#position + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.position = new Vector2(gameObject.x, gameObject.y); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#prev + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.prev = new Vector2(this.position.x, this.position.y); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#allowRotation + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.allowRotation = true; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#rotation + * @type {number} + * @since 3.0.0 + */ + this.rotation = gameObject.angle; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#preRotation + * @type {number} + * @since 3.0.0 + */ + this.preRotation = gameObject.angle; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#width + * @type {number} + * @since 3.0.0 + */ + this.width = gameObject.width; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#height + * @type {number} + * @since 3.0.0 + */ + this.height = gameObject.height; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#sourceWidth + * @type {number} + * @since 3.0.0 + */ + this.sourceWidth = gameObject.width; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#sourceHeight + * @type {number} + * @since 3.0.0 + */ + this.sourceHeight = gameObject.height; + + if (gameObject.frame) + { + this.sourceWidth = gameObject.frame.realWidth; + this.sourceHeight = gameObject.frame.realHeight; + } + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#halfWidth + * @type {number} + * @since 3.0.0 + */ + this.halfWidth = Math.abs(gameObject.width / 2); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#halfHeight + * @type {number} + * @since 3.0.0 + */ + this.halfHeight = Math.abs(gameObject.height / 2); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#center + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#velocity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.velocity = new Vector2(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#newVelocity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.newVelocity = new Vector2(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#deltaMax + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.deltaMax = new Vector2(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#acceleration + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.acceleration = new Vector2(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#allowDrag + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.allowDrag = true; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#drag + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.drag = new Vector2(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#allowGravity + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.allowGravity = true; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#gravity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.gravity = new Vector2(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#bounce + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.bounce = new Vector2(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#worldBounce + * @type {?Phaser.Math.Vector2} * @default null * @since 3.0.0 */ - this.timeOutID = null; + this.worldBounce = null; + + // If true this Body will dispatch events /** - * The previous time the step was called. + * Emit a `worldbounds` event when this body collides with the world bounds (and `collideWorldBounds` is also true). * - * @name Phaser.DOM.RequestAnimationFrame#lastTime - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.lastTime = 0; - - var _this = this; - - /** - * The RAF step function. - * Updates the local tick value, invokes the callback and schedules another call to requestAnimationFrame. - * - * @name Phaser.DOM.RequestAnimationFrame#step - * @type {function} - * @since 3.0.0 - */ - this.step = function step (timestamp) - { - // DOMHighResTimeStamp - _this.lastTime = _this.tick; - - _this.tick = timestamp; - - _this.callback(timestamp); - - _this.timeOutID = window.requestAnimationFrame(step); - }; - - /** - * The SetTimeout step function. - * Updates the local tick value, invokes the callback and schedules another call to setTimeout. - * - * @name Phaser.DOM.RequestAnimationFrame#stepTimeout - * @type {function} - * @since 3.0.0 - */ - this.stepTimeout = function stepTimeout () - { - var d = Date.now(); - - var delay = Math.max(16 + _this.lastTime - d, 0); - - _this.lastTime = _this.tick; - - _this.tick = d; - - _this.callback(d); - - _this.timeOutID = window.setTimeout(stepTimeout, delay); - }; - }, - - /** - * Starts the requestAnimationFrame or setTimeout process running. - * - * @method Phaser.DOM.RequestAnimationFrame#start - * @since 3.0.0 - * - * @param {function} callback - The callback to invoke each step. - * @param {boolean} forceSetTimeOut - Should it use SetTimeout, even if RAF is available? - */ - start: function (callback, forceSetTimeOut) - { - if (this.isRunning) - { - return; - } - - this.callback = callback; - - this.isSetTimeOut = forceSetTimeOut; - - this.isRunning = true; - - this.timeOutID = (forceSetTimeOut) ? window.setTimeout(this.stepTimeout, 0) : window.requestAnimationFrame(this.step); - }, - - /** - * Stops the requestAnimationFrame or setTimeout from running. - * - * @method Phaser.DOM.RequestAnimationFrame#stop - * @since 3.0.0 - */ - stop: function () - { - this.isRunning = false; - - if (this.isSetTimeOut) - { - clearTimeout(this.timeOutID); - } - else - { - window.cancelAnimationFrame(this.timeOutID); - } - }, - - /** - * Stops the step from running and clears the callback reference. - * - * @method Phaser.DOM.RequestAnimationFrame#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.stop(); - - this.callback = NOOP; - } - -}); - -module.exports = RequestAnimationFrame; - - -/***/ }), -/* 236 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Plugins - */ -var Plugins = { - - /** - * These are the Global Managers that are created by the Phaser.Game instance. - * They are referenced from Scene.Systems so that plugins can use them. - * - * @name Phaser.Plugins.Global - * @type {array} - * @since 3.0.0 - */ - Global: [ - - 'anims', - 'cache', - 'registry', - 'sound', - 'textures' - - ], - - /** - * These are the core plugins that are installed into every Scene.Systems instance, no matter what. - * They are optionally exposed in the Scene as well (see the InjectionMap for details) - * - * They are created in the order in which they appear in this array and EventEmitter is always first. - * - * @name Phaser.Plugins.CoreScene - * @type {array} - * @since 3.0.0 - */ - CoreScene: [ - - 'EventEmitter', - - 'CameraManager', - 'GameObjectCreator', - 'GameObjectFactory', - 'ScenePlugin', - 'DisplayList', - 'UpdateList' - - ], - - /** - * These plugins are created in Scene.Systems in addition to the CoreScenePlugins. - * - * You can elect not to have these plugins by either creating a DefaultPlugins object as part - * of the Game Config, by creating a Plugins object as part of a Scene Config, or by modifying this array - * and building your own bundle. - * - * They are optionally exposed in the Scene as well (see the InjectionMap for details) - * - * They are always created in the order in which they appear in the array. - * - * @name Phaser.Plugins.DefaultScene - * @type {array} - * @since 3.0.0 - */ - DefaultScene: [ - - 'CameraManager3D', - 'Clock', - 'DataManagerPlugin', - 'InputPlugin', - 'Loader', - 'TweenManager', - 'LightsPlugin' - - ] - -}; - -/* - * "Sometimes, the elegant implementation is just a function. - * Not a method. Not a class. Not a framework. Just a function." - * -- John Carmack - */ - -module.exports = Plugins; - - -/***/ }), -/* 237 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CanvasPool = __webpack_require__(21); - -/** - * Determines the canvas features of the browser running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.canvasFeatures` from within any Scene. - * - * @name Phaser.Device.CanvasFeatures - * @since 3.0.0 - * - * @type {object} - * @property {boolean} supportInverseAlpha - Set to true if the browser supports inversed alpha. - * @property {boolean} supportNewBlendModes - Set to true if the browser supports new canvas blend modes. - */ -var CanvasFeatures = { - - supportInverseAlpha: false, - supportNewBlendModes: false - -}; - -function checkBlendMode () -{ - var pngHead = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/'; - var pngEnd = 'AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg=='; - - var magenta = new Image(); - - magenta.onload = function () - { - var yellow = new Image(); - - yellow.onload = function () - { - var canvas = CanvasPool.create(yellow, 6, 1); - var context = canvas.getContext('2d'); - - context.globalCompositeOperation = 'multiply'; - - context.drawImage(magenta, 0, 0); - context.drawImage(yellow, 2, 0); - - if (!context.getImageData(2, 0, 1, 1)) - { - return false; - } - - var data = context.getImageData(2, 0, 1, 1).data; - - CanvasPool.remove(yellow); - - CanvasFeatures.supportNewBlendModes = (data[0] === 255 && data[1] === 0 && data[2] === 0); - }; - - yellow.src = pngHead + '/wCKxvRF' + pngEnd; - }; - - magenta.src = pngHead + 'AP804Oa6' + pngEnd; - - return false; -} - -function checkInverseAlpha () -{ - var canvas = CanvasPool.create(this, 2, 1); - var context = canvas.getContext('2d'); - - context.fillStyle = 'rgba(10, 20, 30, 0.5)'; - - // Draw a single pixel - context.fillRect(0, 0, 1, 1); - - // Get the color values - var s1 = context.getImageData(0, 0, 1, 1); - - if (s1 === null) - { - return false; - } - - // Plot them to x2 - context.putImageData(s1, 1, 0); - - // Get those values - var s2 = context.getImageData(1, 0, 1, 1); - - // Compare and return - return (s2.data[0] === s1.data[0] && s2.data[1] === s1.data[1] && s2.data[2] === s1.data[2] && s2.data[3] === s1.data[3]); -} - -function init () -{ - if (document !== undefined) - { - CanvasFeatures.supportNewBlendModes = checkBlendMode(); - CanvasFeatures.supportInverseAlpha = checkInverseAlpha(); - } - - return CanvasFeatures; -} - -module.exports = init(); - - -/***/ }), -/* 238 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// 2.1.1 (Mar 17, 2016) - -/* -ISC License - -Copyright (c) 2016, Mapbox - -Permission to use, copy, modify, and/or distribute this software for any purpose -with or without fee is hereby granted, provided that the above copyright notice -and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS -OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - */ - - - -module.exports = earcut; - -/* -vertices is a flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...]. -holes is an array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). -dimensions is the number of coordinates per vertice in the input array (2 by default). -Each group of three vertice indices in the resulting array forms a triangle. - */ - -function earcut(data, holeIndices, dim) { - - dim = dim || 2; - - var hasHoles = holeIndices && holeIndices.length, - outerLen = hasHoles ? holeIndices[0] * dim : data.length, - outerNode = linkedList(data, 0, outerLen, dim, true), - triangles = []; - - if (!outerNode) return triangles; - - var minX, minY, maxX, maxY, x, y, size; - - if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim); - - // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox - if (data.length > 80 * dim) { - minX = maxX = data[0]; - minY = maxY = data[1]; - - for (var i = dim; i < outerLen; i += dim) { - x = data[i]; - y = data[i + 1]; - if (x < minX) minX = x; - if (y < minY) minY = y; - if (x > maxX) maxX = x; - if (y > maxY) maxY = y; - } - - // minX, minY and size are later used to transform coords into integers for z-order calculation - size = Math.max(maxX - minX, maxY - minY); - } - - earcutLinked(outerNode, triangles, dim, minX, minY, size); - - return triangles; -} - -// create a circular doubly linked list from polygon points in the specified winding order -function linkedList(data, start, end, dim, clockwise) { - var i, last; - - if (clockwise === (signedArea(data, start, end, dim) > 0)) { - for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last); - } else { - for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last); - } - - if (last && equals(last, last.next)) { - removeNode(last); - last = last.next; - } - - return last; -} - -// eliminate colinear or duplicate points -function filterPoints(start, end) { - if (!start) return start; - if (!end) end = start; - - var p = start, - again; - do { - again = false; - - if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) { - removeNode(p); - p = end = p.prev; - if (p === p.next) return null; - again = true; - - } else { - p = p.next; - } - } while (again || p !== end); - - return end; -} - -// main ear slicing loop which triangulates a polygon (given as a linked list) -function earcutLinked(ear, triangles, dim, minX, minY, size, pass) { - if (!ear) return; - - // interlink polygon nodes in z-order - if (!pass && size) indexCurve(ear, minX, minY, size); - - var stop = ear, - prev, next; - - // iterate through ears, slicing them one by one - while (ear.prev !== ear.next) { - prev = ear.prev; - next = ear.next; - - if (size ? isEarHashed(ear, minX, minY, size) : isEar(ear)) { - // cut off the triangle - triangles.push(prev.i / dim); - triangles.push(ear.i / dim); - triangles.push(next.i / dim); - - removeNode(ear); - - // skipping the next vertice leads to less sliver triangles - ear = next.next; - stop = next.next; - - continue; - } - - ear = next; - - // if we looped through the whole remaining polygon and can't find any more ears - if (ear === stop) { - // try filtering points and slicing again - if (!pass) { - earcutLinked(filterPoints(ear), triangles, dim, minX, minY, size, 1); - - // if this didn't work, try curing all small self-intersections locally - } else if (pass === 1) { - ear = cureLocalIntersections(ear, triangles, dim); - earcutLinked(ear, triangles, dim, minX, minY, size, 2); - - // as a last resort, try splitting the remaining polygon into two - } else if (pass === 2) { - splitEarcut(ear, triangles, dim, minX, minY, size); - } - - break; - } - } -} - -// check whether a polygon node forms a valid ear with adjacent nodes -function isEar(ear) { - var a = ear.prev, - b = ear, - c = ear.next; - - if (area(a, b, c) >= 0) return false; // reflex, can't be an ear - - // now make sure we don't have other points inside the potential ear - var p = ear.next.next; - - while (p !== ear.prev) { - if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && - area(p.prev, p, p.next) >= 0) return false; - p = p.next; - } - - return true; -} - -function isEarHashed(ear, minX, minY, size) { - var a = ear.prev, - b = ear, - c = ear.next; - - if (area(a, b, c) >= 0) return false; // reflex, can't be an ear - - // triangle bbox; min & max are calculated like this for speed - var minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : (b.x < c.x ? b.x : c.x), - minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : (b.y < c.y ? b.y : c.y), - maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : (b.x > c.x ? b.x : c.x), - maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : (b.y > c.y ? b.y : c.y); - - // z-order range for the current triangle bbox; - var minZ = zOrder(minTX, minTY, minX, minY, size), - maxZ = zOrder(maxTX, maxTY, minX, minY, size); - - // first look for points inside the triangle in increasing z-order - var p = ear.nextZ; - - while (p && p.z <= maxZ) { - if (p !== ear.prev && p !== ear.next && - pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && - area(p.prev, p, p.next) >= 0) return false; - p = p.nextZ; - } - - // then look for points in decreasing z-order - p = ear.prevZ; - - while (p && p.z >= minZ) { - if (p !== ear.prev && p !== ear.next && - pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && - area(p.prev, p, p.next) >= 0) return false; - p = p.prevZ; - } - - return true; -} - -// go through all polygon nodes and cure small local self-intersections -function cureLocalIntersections(start, triangles, dim) { - var p = start; - do { - var a = p.prev, - b = p.next.next; - - if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) { - - triangles.push(a.i / dim); - triangles.push(p.i / dim); - triangles.push(b.i / dim); - - // remove two nodes involved - removeNode(p); - removeNode(p.next); - - p = start = b; - } - p = p.next; - } while (p !== start); - - return p; -} - -// try splitting polygon into two and triangulate them independently -function splitEarcut(start, triangles, dim, minX, minY, size) { - // look for a valid diagonal that divides the polygon into two - var a = start; - do { - var b = a.next.next; - while (b !== a.prev) { - if (a.i !== b.i && isValidDiagonal(a, b)) { - // split the polygon in two by the diagonal - var c = splitPolygon(a, b); - - // filter colinear points around the cuts - a = filterPoints(a, a.next); - c = filterPoints(c, c.next); - - // run earcut on each half - earcutLinked(a, triangles, dim, minX, minY, size); - earcutLinked(c, triangles, dim, minX, minY, size); - return; - } - b = b.next; - } - a = a.next; - } while (a !== start); -} - -// link every hole into the outer loop, producing a single-ring polygon without holes -function eliminateHoles(data, holeIndices, outerNode, dim) { - var queue = [], - i, len, start, end, list; - - for (i = 0, len = holeIndices.length; i < len; i++) { - start = holeIndices[i] * dim; - end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; - list = linkedList(data, start, end, dim, false); - if (list === list.next) list.steiner = true; - queue.push(getLeftmost(list)); - } - - queue.sort(compareX); - - // process holes from left to right - for (i = 0; i < queue.length; i++) { - eliminateHole(queue[i], outerNode); - outerNode = filterPoints(outerNode, outerNode.next); - } - - return outerNode; -} - -function compareX(a, b) { - return a.x - b.x; -} - -// find a bridge between vertices that connects hole with an outer ring and and link it -function eliminateHole(hole, outerNode) { - outerNode = findHoleBridge(hole, outerNode); - if (outerNode) { - var b = splitPolygon(outerNode, hole); - filterPoints(b, b.next); - } -} - -// David Eberly's algorithm for finding a bridge between hole and outer polygon -function findHoleBridge(hole, outerNode) { - var p = outerNode, - hx = hole.x, - hy = hole.y, - qx = -Infinity, - m; - - // find a segment intersected by a ray from the hole's leftmost point to the left; - // segment's endpoint with lesser x will be potential connection point - do { - if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) { - var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y); - if (x <= hx && x > qx) { - qx = x; - if (x === hx) { - if (hy === p.y) return p; - if (hy === p.next.y) return p.next; - } - m = p.x < p.next.x ? p : p.next; - } - } - p = p.next; - } while (p !== outerNode); - - if (!m) return null; - - if (hx === qx) return m.prev; // hole touches outer segment; pick lower endpoint - - // look for points inside the triangle of hole point, segment intersection and endpoint; - // if there are no points found, we have a valid connection; - // otherwise choose the point of the minimum angle with the ray as connection point - - var stop = m, - mx = m.x, - my = m.y, - tanMin = Infinity, - tan; - - p = m.next; - - while (p !== stop) { - if (hx >= p.x && p.x >= mx && hx !== p.x && - pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) { - - tan = Math.abs(hy - p.y) / (hx - p.x); // tangential - - if ((tan < tanMin || (tan === tanMin && p.x > m.x)) && locallyInside(p, hole)) { - m = p; - tanMin = tan; - } - } - - p = p.next; - } - - return m; -} - -// interlink polygon nodes in z-order -function indexCurve(start, minX, minY, size) { - var p = start; - do { - if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, size); - p.prevZ = p.prev; - p.nextZ = p.next; - p = p.next; - } while (p !== start); - - p.prevZ.nextZ = null; - p.prevZ = null; - - sortLinked(p); -} - -// Simon Tatham's linked list merge sort algorithm -// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html -function sortLinked(list) { - var i, p, q, e, tail, numMerges, pSize, qSize, - inSize = 1; - - do { - p = list; - list = null; - tail = null; - numMerges = 0; - - while (p) { - numMerges++; - q = p; - pSize = 0; - for (i = 0; i < inSize; i++) { - pSize++; - q = q.nextZ; - if (!q) break; - } - qSize = inSize; - - while (pSize > 0 || (qSize > 0 && q)) { - - if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) { - e = p; - p = p.nextZ; - pSize--; - } else { - e = q; - q = q.nextZ; - qSize--; - } - - if (tail) tail.nextZ = e; - else list = e; - - e.prevZ = tail; - tail = e; - } - - p = q; - } - - tail.nextZ = null; - inSize *= 2; - - } while (numMerges > 1); - - return list; -} - -// z-order of a point given coords and size of the data bounding box -function zOrder(x, y, minX, minY, size) { - // coords are transformed into non-negative 15-bit integer range - x = 32767 * (x - minX) / size; - y = 32767 * (y - minY) / size; - - x = (x | (x << 8)) & 0x00FF00FF; - x = (x | (x << 4)) & 0x0F0F0F0F; - x = (x | (x << 2)) & 0x33333333; - x = (x | (x << 1)) & 0x55555555; - - y = (y | (y << 8)) & 0x00FF00FF; - y = (y | (y << 4)) & 0x0F0F0F0F; - y = (y | (y << 2)) & 0x33333333; - y = (y | (y << 1)) & 0x55555555; - - return x | (y << 1); -} - -// find the leftmost node of a polygon ring -function getLeftmost(start) { - var p = start, - leftmost = start; - do { - if (p.x < leftmost.x) leftmost = p; - p = p.next; - } while (p !== start); - - return leftmost; -} - -// check if a point lies within a convex triangle -function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) { - return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && - (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && - (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0; -} - -// check if a diagonal between two polygon nodes is valid (lies in polygon interior) -function isValidDiagonal(a, b) { - return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && - locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b); -} - -// signed area of a triangle -function area(p, q, r) { - return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); -} - -// check if two points are equal -function equals(p1, p2) { - return p1.x === p2.x && p1.y === p2.y; -} - -// check if two segments intersect -function intersects(p1, q1, p2, q2) { - if ((equals(p1, q1) && equals(p2, q2)) || - (equals(p1, q2) && equals(p2, q1))) return true; - return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 && - area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0; -} - -// check if a polygon diagonal intersects any polygon segments -function intersectsPolygon(a, b) { - var p = a; - do { - if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && - intersects(p, p.next, a, b)) return true; - p = p.next; - } while (p !== a); - - return false; -} - -// check if a polygon diagonal is locally inside the polygon -function locallyInside(a, b) { - return area(a.prev, a, a.next) < 0 ? - area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : - area(a, b, a.prev) < 0 || area(a, a.next, b) < 0; -} - -// check if the middle point of a polygon diagonal is inside the polygon -function middleInside(a, b) { - var p = a, - inside = false, - px = (a.x + b.x) / 2, - py = (a.y + b.y) / 2; - do { - if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y && - (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)) - inside = !inside; - p = p.next; - } while (p !== a); - - return inside; -} - -// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two; -// if one belongs to the outer ring and another to a hole, it merges it into a single ring -function splitPolygon(a, b) { - var a2 = new Node(a.i, a.x, a.y), - b2 = new Node(b.i, b.x, b.y), - an = a.next, - bp = b.prev; - - a.next = b; - b.prev = a; - - a2.next = an; - an.prev = a2; - - b2.next = a2; - a2.prev = b2; - - bp.next = b2; - b2.prev = bp; - - return b2; -} - -// create a node and optionally link it with previous one (in a circular doubly linked list) -function insertNode(i, x, y, last) { - var p = new Node(i, x, y); - - if (!last) { - p.prev = p; - p.next = p; - - } else { - p.next = last.next; - p.prev = last; - last.next.prev = p; - last.next = p; - } - return p; -} - -function removeNode(p) { - p.next.prev = p.prev; - p.prev.next = p.next; - - if (p.prevZ) p.prevZ.nextZ = p.nextZ; - if (p.nextZ) p.nextZ.prevZ = p.prevZ; -} - -function Node(i, x, y) { - // vertice index in coordinates array - this.i = i; - - // vertex coordinates - this.x = x; - this.y = y; - - // previous and next vertice nodes in a polygon ring - this.prev = null; - this.next = null; - - // z-order curve value - this.z = null; - - // previous and next nodes in z-order - this.prevZ = null; - this.nextZ = null; - - // indicates whether this is a steiner point - this.steiner = false; -} - -// return a percentage difference between the polygon area and its triangulation area; -// used to verify correctness of triangulation -earcut.deviation = function (data, holeIndices, dim, triangles) { - var hasHoles = holeIndices && holeIndices.length; - var outerLen = hasHoles ? holeIndices[0] * dim : data.length; - - var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim)); - if (hasHoles) { - for (var i = 0, len = holeIndices.length; i < len; i++) { - var start = holeIndices[i] * dim; - var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; - polygonArea -= Math.abs(signedArea(data, start, end, dim)); - } - } - - var trianglesArea = 0; - for (i = 0; i < triangles.length; i += 3) { - var a = triangles[i] * dim; - var b = triangles[i + 1] * dim; - var c = triangles[i + 2] * dim; - trianglesArea += Math.abs( - (data[a] - data[c]) * (data[b + 1] - data[a + 1]) - - (data[a] - data[b]) * (data[c + 1] - data[a + 1])); - } - - return polygonArea === 0 && trianglesArea === 0 ? 0 : - Math.abs((trianglesArea - polygonArea) / polygonArea); -}; - -function signedArea(data, start, end, dim) { - var sum = 0; - for (var i = start, j = end - dim; i < end; i += dim) { - sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]); - j = i; - } - return sum; -} - -// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts -earcut.flatten = function (data) { - var dim = data[0][0].length, - result = {vertices: [], holes: [], dimensions: dim}, - holeIndex = 0; - - for (var i = 0; i < data.length; i++) { - for (var j = 0; j < data[i].length; j++) { - for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]); - } - if (i > 0) { - holeIndex += data[i - 1].length; - result.holes.push(holeIndex); - } - } - return result; -}; - -/***/ }), -/* 239 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ModelViewProjection = { - - modelMatrixDirty: false, - viewMatrixDirty: false, - projectionMatrixDirty: false, - modelMatrix: null, - viewMatrix: null, - projectionMatrix: null, - - mvpInit: function () - { - this.modelMatrixDirty = true; - this.viewMatrixDirty = true; - this.projectionMatrixDirty = true; - - this.modelMatrix = new Float32Array([ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 - ]); - - this.viewMatrix = new Float32Array([ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 - ]); - - this.projectionMatrix = new Float32Array([ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 - ]); - - return this; - }, - - mvpUpdate: function () - { - var program = this.program; - - if (this.modelMatrixDirty) - { - this.renderer.setMatrix4(program, 'uModelMatrix', false, this.modelMatrix); - this.modelMatrixDirty = false; - } - - if (this.viewMatrixDirty) - { - this.renderer.setMatrix4(program, 'uViewMatrix', false, this.viewMatrix); - this.viewMatrixDirty = false; - } - - if (this.projectionMatrixDirty) - { - this.renderer.setMatrix4(program, 'uProjectionMatrix', false, this.projectionMatrix); - this.projectionMatrixDirty = false; - } - - return this; - }, - - modelIdentity: function () - { - var modelMatrix = this.modelMatrix; - - modelMatrix[0] = 1; - modelMatrix[1] = 0; - modelMatrix[2] = 0; - modelMatrix[3] = 0; - modelMatrix[4] = 0; - modelMatrix[5] = 1; - modelMatrix[6] = 0; - modelMatrix[7] = 0; - modelMatrix[8] = 0; - modelMatrix[9] = 0; - modelMatrix[10] = 1; - modelMatrix[11] = 0; - modelMatrix[12] = 0; - modelMatrix[13] = 0; - modelMatrix[14] = 0; - modelMatrix[15] = 1; - - this.modelMatrixDirty = true; - - return this; - }, - - modelScale: function (x, y, z) - { - var modelMatrix = this.modelMatrix; - - modelMatrix[0] = modelMatrix[0] * x; - modelMatrix[1] = modelMatrix[1] * x; - modelMatrix[2] = modelMatrix[2] * x; - modelMatrix[3] = modelMatrix[3] * x; - modelMatrix[4] = modelMatrix[4] * y; - modelMatrix[5] = modelMatrix[5] * y; - modelMatrix[6] = modelMatrix[6] * y; - modelMatrix[7] = modelMatrix[7] * y; - modelMatrix[8] = modelMatrix[8] * z; - modelMatrix[9] = modelMatrix[9] * z; - modelMatrix[10] = modelMatrix[10] * z; - modelMatrix[11] = modelMatrix[11] * z; - - this.modelMatrixDirty = true; - - return this; - }, - - modelTranslate: function (x, y, z) - { - var modelMatrix = this.modelMatrix; - - modelMatrix[12] = modelMatrix[0] * x + modelMatrix[4] * y + modelMatrix[8] * z + modelMatrix[12]; - modelMatrix[13] = modelMatrix[1] * x + modelMatrix[5] * y + modelMatrix[9] * z + modelMatrix[13]; - modelMatrix[14] = modelMatrix[2] * x + modelMatrix[6] * y + modelMatrix[10] * z + modelMatrix[14]; - modelMatrix[15] = modelMatrix[3] * x + modelMatrix[7] * y + modelMatrix[11] * z + modelMatrix[15]; - - this.modelMatrixDirty = true; - - return this; - }, - - modelRotateX: function (radians) - { - var modelMatrix = this.modelMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a10 = modelMatrix[4]; - var a11 = modelMatrix[5]; - var a12 = modelMatrix[6]; - var a13 = modelMatrix[7]; - var a20 = modelMatrix[8]; - var a21 = modelMatrix[9]; - var a22 = modelMatrix[10]; - var a23 = modelMatrix[11]; - - modelMatrix[4] = a10 * c + a20 * s; - modelMatrix[5] = a11 * c + a21 * s; - modelMatrix[6] = a12 * c + a22 * s; - modelMatrix[7] = a13 * c + a23 * s; - modelMatrix[8] = a20 * c - a10 * s; - modelMatrix[9] = a21 * c - a11 * s; - modelMatrix[10] = a22 * c - a12 * s; - modelMatrix[11] = a23 * c - a13 * s; - - this.modelMatrixDirty = true; - - return this; - }, - - modelRotateY: function (radians) - { - var modelMatrix = this.modelMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a00 = modelMatrix[0]; - var a01 = modelMatrix[1]; - var a02 = modelMatrix[2]; - var a03 = modelMatrix[3]; - var a20 = modelMatrix[8]; - var a21 = modelMatrix[9]; - var a22 = modelMatrix[10]; - var a23 = modelMatrix[11]; - - modelMatrix[0] = a00 * c - a20 * s; - modelMatrix[1] = a01 * c - a21 * s; - modelMatrix[2] = a02 * c - a22 * s; - modelMatrix[3] = a03 * c - a23 * s; - modelMatrix[8] = a00 * s + a20 * c; - modelMatrix[9] = a01 * s + a21 * c; - modelMatrix[10] = a02 * s + a22 * c; - modelMatrix[11] = a03 * s + a23 * c; - - this.modelMatrixDirty = true; - - return this; - }, - - modelRotateZ: function (radians) - { - var modelMatrix = this.modelMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a00 = modelMatrix[0]; - var a01 = modelMatrix[1]; - var a02 = modelMatrix[2]; - var a03 = modelMatrix[3]; - var a10 = modelMatrix[4]; - var a11 = modelMatrix[5]; - var a12 = modelMatrix[6]; - var a13 = modelMatrix[7]; - - modelMatrix[0] = a00 * c + a10 * s; - modelMatrix[1] = a01 * c + a11 * s; - modelMatrix[2] = a02 * c + a12 * s; - modelMatrix[3] = a03 * c + a13 * s; - modelMatrix[4] = a10 * c - a00 * s; - modelMatrix[5] = a11 * c - a01 * s; - modelMatrix[6] = a12 * c - a02 * s; - modelMatrix[7] = a13 * c - a03 * s; - - this.modelMatrixDirty = true; - - return this; - }, - - viewIdentity: function () - { - var viewMatrix = this.viewMatrix; - - viewMatrix[0] = 1; - viewMatrix[1] = 0; - viewMatrix[2] = 0; - viewMatrix[3] = 0; - viewMatrix[4] = 0; - viewMatrix[5] = 1; - viewMatrix[6] = 0; - viewMatrix[7] = 0; - viewMatrix[8] = 0; - viewMatrix[9] = 0; - viewMatrix[10] = 1; - viewMatrix[11] = 0; - viewMatrix[12] = 0; - viewMatrix[13] = 0; - viewMatrix[14] = 0; - viewMatrix[15] = 1; - - this.viewMatrixDirty = true; - - return this; - }, - - viewScale: function (x, y, z) - { - var viewMatrix = this.viewMatrix; - - viewMatrix[0] = viewMatrix[0] * x; - viewMatrix[1] = viewMatrix[1] * x; - viewMatrix[2] = viewMatrix[2] * x; - viewMatrix[3] = viewMatrix[3] * x; - viewMatrix[4] = viewMatrix[4] * y; - viewMatrix[5] = viewMatrix[5] * y; - viewMatrix[6] = viewMatrix[6] * y; - viewMatrix[7] = viewMatrix[7] * y; - viewMatrix[8] = viewMatrix[8] * z; - viewMatrix[9] = viewMatrix[9] * z; - viewMatrix[10] = viewMatrix[10] * z; - viewMatrix[11] = viewMatrix[11] * z; - - this.viewMatrixDirty = true; - - return this; - }, - - viewTranslate: function (x, y, z) - { - var viewMatrix = this.viewMatrix; - - viewMatrix[12] = viewMatrix[0] * x + viewMatrix[4] * y + viewMatrix[8] * z + viewMatrix[12]; - viewMatrix[13] = viewMatrix[1] * x + viewMatrix[5] * y + viewMatrix[9] * z + viewMatrix[13]; - viewMatrix[14] = viewMatrix[2] * x + viewMatrix[6] * y + viewMatrix[10] * z + viewMatrix[14]; - viewMatrix[15] = viewMatrix[3] * x + viewMatrix[7] * y + viewMatrix[11] * z + viewMatrix[15]; - - this.viewMatrixDirty = true; - - return this; - }, - - viewRotateX: function (radians) - { - var viewMatrix = this.viewMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a10 = viewMatrix[4]; - var a11 = viewMatrix[5]; - var a12 = viewMatrix[6]; - var a13 = viewMatrix[7]; - var a20 = viewMatrix[8]; - var a21 = viewMatrix[9]; - var a22 = viewMatrix[10]; - var a23 = viewMatrix[11]; - - viewMatrix[4] = a10 * c + a20 * s; - viewMatrix[5] = a11 * c + a21 * s; - viewMatrix[6] = a12 * c + a22 * s; - viewMatrix[7] = a13 * c + a23 * s; - viewMatrix[8] = a20 * c - a10 * s; - viewMatrix[9] = a21 * c - a11 * s; - viewMatrix[10] = a22 * c - a12 * s; - viewMatrix[11] = a23 * c - a13 * s; - - this.viewMatrixDirty = true; - - return this; - }, - - viewRotateY: function (radians) - { - var viewMatrix = this.viewMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a00 = viewMatrix[0]; - var a01 = viewMatrix[1]; - var a02 = viewMatrix[2]; - var a03 = viewMatrix[3]; - var a20 = viewMatrix[8]; - var a21 = viewMatrix[9]; - var a22 = viewMatrix[10]; - var a23 = viewMatrix[11]; - - viewMatrix[0] = a00 * c - a20 * s; - viewMatrix[1] = a01 * c - a21 * s; - viewMatrix[2] = a02 * c - a22 * s; - viewMatrix[3] = a03 * c - a23 * s; - viewMatrix[8] = a00 * s + a20 * c; - viewMatrix[9] = a01 * s + a21 * c; - viewMatrix[10] = a02 * s + a22 * c; - viewMatrix[11] = a03 * s + a23 * c; - - this.viewMatrixDirty = true; - - return this; - }, - - viewRotateZ: function (radians) - { - var viewMatrix = this.viewMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a00 = viewMatrix[0]; - var a01 = viewMatrix[1]; - var a02 = viewMatrix[2]; - var a03 = viewMatrix[3]; - var a10 = viewMatrix[4]; - var a11 = viewMatrix[5]; - var a12 = viewMatrix[6]; - var a13 = viewMatrix[7]; - - viewMatrix[0] = a00 * c + a10 * s; - viewMatrix[1] = a01 * c + a11 * s; - viewMatrix[2] = a02 * c + a12 * s; - viewMatrix[3] = a03 * c + a13 * s; - viewMatrix[4] = a10 * c - a00 * s; - viewMatrix[5] = a11 * c - a01 * s; - viewMatrix[6] = a12 * c - a02 * s; - viewMatrix[7] = a13 * c - a03 * s; - - this.viewMatrixDirty = true; - - return this; - }, - - viewLoad2D: function (matrix2D) - { - var vm = this.viewMatrix; - - vm[0] = matrix2D[0]; - vm[1] = matrix2D[1]; - vm[2] = 0.0; - vm[3] = 0.0; - vm[4] = matrix2D[2]; - vm[5] = matrix2D[3]; - vm[6] = 0.0; - vm[7] = 0.0; - vm[8] = matrix2D[4]; - vm[9] = matrix2D[5]; - vm[10] = 1.0; - vm[11] = 0.0; - vm[12] = 0.0; - vm[13] = 0.0; - vm[14] = 0.0; - vm[15] = 1.0; - - this.viewMatrixDirty = true; - - return this; - }, - - viewLoad: function (matrix) - { - var vm = this.viewMatrix; - - vm[0] = matrix[0]; - vm[1] = matrix[1]; - vm[2] = matrix[2]; - vm[3] = matrix[3]; - vm[4] = matrix[4]; - vm[5] = matrix[5]; - vm[6] = matrix[6]; - vm[7] = matrix[7]; - vm[8] = matrix[8]; - vm[9] = matrix[9]; - vm[10] = matrix[10]; - vm[11] = matrix[11]; - vm[12] = matrix[12]; - vm[13] = matrix[13]; - vm[14] = matrix[14]; - vm[15] = matrix[15]; - - this.viewMatrixDirty = true; - - return this; - }, - - projIdentity: function () - { - var projectionMatrix = this.projectionMatrix; - - projectionMatrix[0] = 1; - projectionMatrix[1] = 0; - projectionMatrix[2] = 0; - projectionMatrix[3] = 0; - projectionMatrix[4] = 0; - projectionMatrix[5] = 1; - projectionMatrix[6] = 0; - projectionMatrix[7] = 0; - projectionMatrix[8] = 0; - projectionMatrix[9] = 0; - projectionMatrix[10] = 1; - projectionMatrix[11] = 0; - projectionMatrix[12] = 0; - projectionMatrix[13] = 0; - projectionMatrix[14] = 0; - projectionMatrix[15] = 1; - - this.projectionMatrixDirty = true; - - return this; - }, - - projOrtho: function (left, right, bottom, top, near, far) - { - var projectionMatrix = this.projectionMatrix; - var leftRight = 1.0 / (left - right); - var bottomTop = 1.0 / (bottom - top); - var nearFar = 1.0 / (near - far); - - projectionMatrix[0] = -2.0 * leftRight; - projectionMatrix[1] = 0.0; - projectionMatrix[2] = 0.0; - projectionMatrix[3] = 0.0; - projectionMatrix[4] = 0.0; - projectionMatrix[5] = -2.0 * bottomTop; - projectionMatrix[6] = 0.0; - projectionMatrix[7] = 0.0; - projectionMatrix[8] = 0.0; - projectionMatrix[9] = 0.0; - projectionMatrix[10] = 2.0 * nearFar; - projectionMatrix[11] = 0.0; - projectionMatrix[12] = (left + right) * leftRight; - projectionMatrix[13] = (top + bottom) * bottomTop; - projectionMatrix[14] = (far + near) * nearFar; - projectionMatrix[15] = 1.0; - - this.projectionMatrixDirty = true; - return this; - }, - - projPersp: function (fovy, aspectRatio, near, far) - { - var projectionMatrix = this.projectionMatrix; - var fov = 1.0 / Math.tan(fovy / 2.0); - var nearFar = 1.0 / (near - far); - - projectionMatrix[0] = fov / aspectRatio; - projectionMatrix[1] = 0.0; - projectionMatrix[2] = 0.0; - projectionMatrix[3] = 0.0; - projectionMatrix[4] = 0.0; - projectionMatrix[5] = fov; - projectionMatrix[6] = 0.0; - projectionMatrix[7] = 0.0; - projectionMatrix[8] = 0.0; - projectionMatrix[9] = 0.0; - projectionMatrix[10] = (far + near) * nearFar; - projectionMatrix[11] = -1.0; - projectionMatrix[12] = 0.0; - projectionMatrix[13] = 0.0; - projectionMatrix[14] = (2.0 * far * near) * nearFar; - projectionMatrix[15] = 0.0; - - this.projectionMatrixDirty = true; - return this; - } -}; - -module.exports = ModelViewProjection; - - -/***/ }), -/* 240 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(14); -var Gamepad = __webpack_require__(241); -var Keyboard = __webpack_require__(245); -var Mouse = __webpack_require__(248); -var Pointer = __webpack_require__(249); -var Rectangle = __webpack_require__(8); -var Touch = __webpack_require__(250); -var TransformXY = __webpack_require__(251); - -/** - * @classdesc - * [description] - * - * @class InputManager - * @memberOf Phaser.Input - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - [description] - * @param {object} config - [description] - */ -var InputManager = new Class({ - - initialize: - - function InputManager (game, config) - { - /** - * [description] - * - * @name Phaser.Input.InputManager#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game = game; - - /** - * [description] - * - * @name Phaser.Input.InputManager#canvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.canvas; - - /** - * [description] - * - * @name Phaser.Input.InputManager#config - * @type {object} - * @since 3.0.0 - */ - this.config = config; - - /** - * [description] - * - * @name Phaser.Input.InputManager#enabled - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.enabled = true; - - /** - * [description] - * - * @name Phaser.Input.InputManager#events - * @type {EventEmitter} - * @since 3.0.0 - */ - this.events = new EventEmitter(); - - /** - * Standard FIFO queue. - * - * @name Phaser.Input.InputManager#queue - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.queue = []; - - /** - * [description] - * - * @name Phaser.Input.InputManager#keyboard - * @type {Phaser.Input.Keyboard.KeyboardManager} - * @since 3.0.0 - */ - this.keyboard = new Keyboard(this); - - /** - * [description] - * - * @name Phaser.Input.InputManager#mouse - * @type {Phaser.Input.Mouse.MouseManager} - * @since 3.0.0 - */ - this.mouse = new Mouse(this); - - /** - * [description] - * - * @name Phaser.Input.InputManager#touch - * @type {Phaser.Input.Touch.TouchManager} - * @since 3.0.0 - */ - this.touch = new Touch(this); - - /** - * [description] - * - * @name Phaser.Input.InputManager#gamepad - * @type {Phaser.Input.Gamepad.GamepadManager} - * @since 3.0.0 - */ - this.gamepad = new Gamepad(this); - - /** - * [description] - * - * @name Phaser.Input.InputManager#activePointer - * @type {[type]} - * @since 3.0.0 - */ - this.activePointer = new Pointer(this, 0); - - /** - * [description] - * - * @name Phaser.Input.InputManager#scale - * @type {object} - * @since 3.0.0 - */ - this.scale = { x: 1, y: 1 }; - - /** - * If the top-most Scene in the Scene List receives an input it will stop input from - * propagating any lower down the scene list, i.e. if you have a UI Scene at the top - * and click something on it, that click will not then be passed down to any other - * Scene below. Disable this to have input events passed through all Scenes, all the time. - * - * @name Phaser.Input.InputManager#globalTopOnly - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.globalTopOnly = true; - - /** - * [description] - * - * @name Phaser.Input.InputManager#ignoreEvents + * @name Phaser.Physics.Arcade.Body#onWorldBounds * @type {boolean} * @default false * @since 3.0.0 */ - this.ignoreEvents = false; + this.onWorldBounds = false; /** * [description] * - * @name Phaser.Input.InputManager#bounds - * @type {Phaser.Geom.Rectangle} - * @since 3.0.0 - */ - this.bounds = new Rectangle(); - - /** - * [description] - * - * @name Phaser.Input.InputManager#_tempPoint - * @type {object} - * @private - * @since 3.0.0 - */ - this._tempPoint = { x: 0, y: 0 }; - - /** - * [description] - * - * @name Phaser.Input.InputManager#_tempHitTest - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._tempHitTest = []; - - game.events.once('boot', this.boot, this); - }, - - /** - * The Boot handler is called by Phaser.Game when it first starts up. - * The renderer is available by now. - * - * @method Phaser.Input.InputManager#boot - * @since 3.0.0 - */ - boot: function () - { - this.canvas = this.game.canvas; - - this.updateBounds(); - - this.keyboard.boot(); - this.mouse.boot(); - this.touch.boot(); - this.gamepad.boot(); - - this.game.events.once('destroy', this.destroy, this); - }, - - /** - * [description] - * - * @method Phaser.Input.InputManager#updateBounds - * @since 3.0.0 - */ - updateBounds: function () - { - var bounds = this.bounds; - - var clientRect = this.canvas.getBoundingClientRect(); - - bounds.x = clientRect.left + window.pageXOffset - document.documentElement.clientLeft; - bounds.y = clientRect.top + window.pageYOffset - document.documentElement.clientTop; - bounds.width = clientRect.width; - bounds.height = clientRect.height; - }, - - /** - * [description] - * - * @method Phaser.Input.InputManager#resize - * @since 3.2.0 - */ - resize: function () - { - this.updateBounds(); - - // Game config size - var gw = this.game.config.width; - var gh = this.game.config.height; - - // Actual canvas size - var bw = this.bounds.width; - var bh = this.bounds.height; - - // Scale factor - this.scale.x = gw / bw; - this.scale.y = gh / bh; - }, - - /** - * [description] - * - * @method Phaser.Input.InputManager#update - * @since 3.0.0 - * - * @param {number} time - [description] - */ - update: function (time) - { - this.keyboard.update(); - this.gamepad.update(); - - this.ignoreEvents = false; - - var len = this.queue.length; - - // Currently just 1 pointer supported - var pointer = this.activePointer; - - pointer.reset(); - - if (!this.enabled || len === 0) - { - return; - } - - this.updateBounds(); - - this.scale.x = this.game.config.width / this.bounds.width; - this.scale.y = this.game.config.height / this.bounds.height; - - // Clears the queue array, and also means we don't work on array data that could potentially - // be modified during the processing phase - var queue = this.queue.splice(0, len); - - // Process the event queue, dispatching all of the events that have stored up - for (var i = 0; i < len; i++) - { - var event = queue[i]; - - // TODO: Move to CONSTs so we can do integer comparisons instead of strings. - switch (event.type) - { - case 'mousemove': - - pointer.move(event, time); - break; - - case 'mousedown': - - pointer.down(event, time); - break; - - case 'mouseup': - - pointer.up(event, time); - break; - - case 'touchmove': - - pointer.touchmove(event, time); - break; - - case 'touchstart': - - pointer.touchstart(event, time); - break; - - case 'touchend': - - pointer.touchend(event, time); - break; - - case 'pointerlockchange': - - this.events.emit('pointerlockchange', event, this.mouse.locked); - break; - } - } - }, - - /** - * Will always return an array. - * Array contains matching Interactive Objects. - * Array will be empty if no objects were matched. - * x/y = pointer x/y (un-translated) - * - * @method Phaser.Input.InputManager#hitTest - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {array} gameObjects - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {array} output - [description] - * - * @return {array} [description] - */ - hitTest: function (x, y, gameObjects, camera, output) - { - if (output === undefined) { output = this._tempHitTest; } - - var tempPoint = this._tempPoint; - var cameraW = camera.width; - var cameraH = camera.height; - - output.length = 0; - - if (!(x >= camera.x && y >= camera.y && x <= camera.x + cameraW && y <= camera.y + cameraH)) - { - return output; - } - - // Stores the world point inside of tempPoint - camera.getWorldPoint(x, y, tempPoint); - - var culledGameObjects = camera.cull(gameObjects); - - var point = { x: 0, y: 0 }; - - for (var i = 0; i < culledGameObjects.length; i++) - { - var gameObject = culledGameObjects[i]; - - if (!gameObject.input || !gameObject.input.enabled || !gameObject.willRender()) - { - continue; - } - - var px = tempPoint.x + (camera.scrollX * gameObject.scrollFactorX) - camera.scrollX; - var py = tempPoint.y + (camera.scrollY * gameObject.scrollFactorY) - camera.scrollY; - - TransformXY(px, py, gameObject.x, gameObject.y, gameObject.rotation, gameObject.scaleX, gameObject.scaleY, point); - - if (this.pointWithinHitArea(gameObject, point.x, point.y)) - { - output.push(gameObject); - } - } - - return output; - }, - - /** - * x/y MUST be translated before being passed to this function, - * unless the gameObject is guaranteed to not be rotated or scaled in any way. - * - * @method Phaser.Input.InputManager#pointWithinHitArea - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ - pointWithinHitArea: function (gameObject, x, y) - { - var input = gameObject.input; - - // Normalize the origin - x += gameObject.displayOriginX; - y += gameObject.displayOriginY; - - if (input.hitAreaCallback(input.hitArea, x, y, gameObject)) - { - input.localX = x; - input.localY = y; - - return true; - } - else - { - return false; - } - }, - - /** - * x/y MUST be translated before being passed to this function, - * unless the gameObject is guaranteed to not be rotated or scaled in any way. - * - * @method Phaser.Input.InputManager#pointWithinInteractiveObject - * @since 3.0.0 - * - * @param {Phaser.Input.InteractiveObject} object - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ - pointWithinInteractiveObject: function (object, x, y) - { - if (!object.hitArea) - { - return false; - } - - // Normalize the origin - x += object.gameObject.displayOriginX; - y += object.gameObject.displayOriginY; - - object.localX = x; - object.localY = y; - - return object.hitAreaCallback(object.hitArea, x, y, object); - }, - - /** - * [description] - * - * @method Phaser.Input.InputManager#transformX - * @since 3.0.0 - * - * @param {number} pageX - [description] - * - * @return {number} [description] - */ - transformX: function (pageX) - { - return (pageX - this.bounds.left) * this.scale.x; - }, - - /** - * [description] - * - * @method Phaser.Input.InputManager#transformY - * @since 3.0.0 - * - * @param {number} pageY - [description] - * - * @return {number} [description] - */ - transformY: function (pageY) - { - return (pageY - this.bounds.top) * this.scale.y; - }, - - /** - * [description] - * - * @method Phaser.Input.InputManager#getOffsetX - * @since 3.0.0 - * - * @return {number} [description] - */ - getOffsetX: function () - { - return this.bounds.left; - }, - - /** - * [description] - * - * @method Phaser.Input.InputManager#getOffsetY - * @since 3.0.0 - * - * @return {number} [description] - */ - getOffsetY: function () - { - return this.bounds.top; - }, - - /** - * [description] - * - * @method Phaser.Input.InputManager#getScaleX - * @since 3.0.0 - * - * @return {number} [description] - */ - getScaleX: function () - { - return this.game.config.width / this.bounds.width; - }, - - /** - * [description] - * - * @method Phaser.Input.InputManager#getScaleY - * @since 3.0.0 - * - * @return {number} [description] - */ - getScaleY: function () - { - return this.game.config.height / this.bounds.height; - }, - - /** - * [description] - * - * @method Phaser.Input.InputManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.events.removeAllListeners(); - - this.keyboard.destroy(); - this.mouse.destroy(); - this.touch.destroy(); - this.gamepad.destroy(); - - this.activePointer.destroy(); - - this.queue = []; - - this.game = null; - } - -}); - -module.exports = InputManager; - - -/***/ }), -/* 241 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Gamepad = __webpack_require__(242); - -// https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API -// https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API -// https://www.smashingmagazine.com/2015/11/gamepad-api-in-web-games/ -// http://html5gamepad.com/ - -/** - * @classdesc - * [description] - * - * @class GamepadManager - * @memberOf Phaser.Input.Gamepad - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Input.InputManager} inputManager - [description] - */ -var GamepadManager = new Class({ - - initialize: - - function GamepadManager (inputManager) - { - /** - * [description] - * - * @name Phaser.Input.Gamepad.GamepadManager#manager - * @type {Phaser.Input.InputManager} - * @since 3.0.0 - */ - this.manager = inputManager; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.GamepadManager#events - * @type {[type]} - * @since 3.0.0 - */ - this.events = inputManager.events; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.GamepadManager#enabled + * @name Phaser.Physics.Arcade.Body#onCollide * @type {boolean} * @default false * @since 3.0.0 */ - this.enabled = false; + this.onCollide = false; /** * [description] * - * @name Phaser.Input.Gamepad.GamepadManager#target - * @type {null} - * @since 3.0.0 - */ - this.target; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.GamepadManager#handler - * @type {null} - * @since 3.0.0 - */ - this.handler; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.GamepadManager#gamepads - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.gamepads = []; - - /** - * Standard FIFO queue. - * - * @name Phaser.Input.Gamepad.GamepadManager#queue - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.queue = []; - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.GamepadManager#boot - * @since 3.0.0 - */ - boot: function () - { - var config = this.manager.config; - - this.enabled = config.inputGamepad && this.manager.game.device.input.gamepads; - - this.target = window; - - if (this.enabled) - { - this.startListeners(); - } - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.GamepadManager#startListeners - * @since 3.0.0 - * - * @return {[type]} [description] - */ - startListeners: function () - { - var queue = this.queue; - - var handler = function handler (event) - { - if (event.defaultPrevented) - { - // Do nothing if event already handled - return; - } - - queue.push(event); - }; - - this.handler = handler; - - var target = this.target; - - target.addEventListener('gamepadconnected', handler, false); - target.addEventListener('gamepaddisconnected', handler, false); - - // FF only for now: - target.addEventListener('gamepadbuttondown', handler, false); - target.addEventListener('gamepadbuttonup', handler, false); - target.addEventListener('gamepadaxismove', handler, false); - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.GamepadManager#stopListeners - * @since 3.0.0 - */ - stopListeners: function () - { - var target = this.target; - var handler = this.handler; - - target.removeEventListener('gamepadconnected', handler); - target.removeEventListener('gamepaddisconnected', handler); - - target.removeEventListener('gamepadbuttondown', handler); - target.removeEventListener('gamepadbuttonup', handler); - target.removeEventListener('gamepadaxismove', handler); - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.GamepadManager#disconnectAll - * @since 3.0.0 - */ - disconnectAll: function () - { - for (var i = 0; i < this.gamepads.length; i++) - { - this.gamepads.connected = false; - } - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.GamepadManager#addPad - * @since 3.0.0 - * - * @param {[type]} pad - [description] - * - * @return {[type]} [description] - */ - addPad: function (pad) - { - var gamepad = new Gamepad(this, pad.id, pad.index); - - this.gamepads[pad.index] = gamepad; - - return gamepad; - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.GamepadManager#removePad - * @since 3.0.0 - * @todo Code this feature - * - * @param {[type]} index - [description] - * @param {[type]} pad - [description] - */ - removePad: function () - { - // TODO - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.GamepadManager#refreshPads - * @since 3.0.0 - * - * @param {[type]} pads - [description] - */ - refreshPads: function (pads) - { - if (!pads) - { - this.disconnectAll(); - } - else - { - for (var i = 0; i < pads.length; i++) - { - var pad = pads[i]; - - if (!pad) - { - // removePad? - continue; - } - - if (this.gamepads[pad.index] === undefined) - { - this.addPad(pad); - } - - this.gamepads[pad.index].update(pad); - } - } - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.GamepadManager#getAll - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getAll: function () - { - var out = []; - - for (var i = 0; i < this.gamepads.length; i++) - { - if (this.gamepads[i]) - { - out.push(this.gamepads[i]); - } - } - - return out; - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.GamepadManager#getPad - * @since 3.0.0 - * - * @param {[type]} index - [description] - * - * @return {[type]} [description] - */ - getPad: function (index) - { - for (var i = 0; i < this.gamepads.length; i++) - { - if (this.gamepads[i].index === index) - { - return this.gamepads[i]; - } - } - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.GamepadManager#update - * @since 3.0.0 - * - * @return {[type]} [description] - */ - update: function () - { - if (!this.enabled) - { - return; - } - - this.refreshPads(navigator.getGamepads()); - - var len = this.queue.length; - - if (len === 0) - { - return; - } - - var queue = this.queue.splice(0, len); - - // Process the event queue, dispatching all of the events that have stored up - for (var i = 0; i < len; i++) - { - var event = queue[i]; - var pad; - - switch (event.type) - { - case 'gamepadconnected': - - pad = this.getPad(event.gamepad.index); - - this.events.emit('connected', pad, event); - - break; - - case 'gamepaddisconnected': - - pad = this.getPad(event.gamepad.index); - - this.events.emit('disconnected', pad, event); - - break; - } - } - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.GamepadManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.stopListeners(); - this.disconnectAll(); - - this.gamepads = []; - }, - - /** - * The total number of connected game pads. - * - * @name Phaser.Input.Gamepad.GamepadManager#total - * @type {number} - * @since 3.0.0 - */ - total: { - - get: function () - { - return this.gamepads.length; - } - - } - -}); - -module.exports = GamepadManager; - - -/***/ }), -/* 242 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Axis = __webpack_require__(243); -var Button = __webpack_require__(244); -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class Gamepad - * @memberOf Phaser.Input.Gamepad - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Input.Gamepad.GamepadManager} manager - [description] - * @param {[type]} id - [description] - * @param {[type]} index - [description] - */ -var Gamepad = new Class({ - - initialize: - - function Gamepad (manager, id, index) - { - /** - * [description] - * - * @name Phaser.Input.Gamepad.Gamepad#manager - * @type {Phaser.Input.Gamepad.GamepadManager} - * @since 3.0.0 - */ - this.manager = manager; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.Gamepad#events - * @type {[type]} - * @since 3.0.0 - */ - this.events = manager.events; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.Gamepad#id - * @type {[type]} - * @since 3.0.0 - */ - this.id = id; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.Gamepad#index - * @type {[type]} - * @since 3.0.0 - */ - this.index = index; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.Gamepad#connected - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.connected = true; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.Gamepad#timestamp - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.timestamp = 0; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.Gamepad#buttons - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.buttons = []; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.Gamepad#axes - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.axes = []; - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.Gamepad#update - * @since 3.0.0 - * - * @param {[type]} data - [description] - */ - update: function (data) - { - this.timestamp = data.timestamp; - this.connected = data.connected; - - var i; - - var axes = this.axes; - var buttons = this.buttons; - - for (i = 0; i < data.buttons.length; i++) - { - var buttonData = data.buttons[i]; - - if (buttons[i] === undefined) - { - buttons[i] = new Button(this, i); - } - - buttons[i].update(buttonData); - } - - // Axes - for (i = 0; i < data.axes.length; i++) - { - var axisData = data.axes[i]; - - if (axes[i] === undefined) - { - axes[i] = new Axis(this, i); - } - - axes[i].update(axisData); - } - } - -}); - -module.exports = Gamepad; - - -/***/ }), -/* 243 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class Axis - * @memberOf Phaser.Input.Gamepad - * @constructor - * @since 3.0.0 - * - * @param {[type]} pad - [description] - * @param {integer} index - [description] - */ -var Axis = new Class({ - - initialize: - - function Axis (pad, index) - { - /** - * [description] - * - * @name Phaser.Input.Gamepad.Axis#pad - * @type {Phaser.Input.Gamepad.Gamepad} - * @since 3.0.0 - */ - this.pad = pad; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.Axis#events - * @type {[type]} - * @since 3.0.0 - */ - this.events = pad.events; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.Axis#index - * @type {integer} - * @since 3.0.0 - */ - this.index = index; - - /** - * Between -1 and 1 with 0 being dead center. - * - * @name Phaser.Input.Gamepad.Axis#value - * @type {float} - * @default 0 - * @since 3.0.0 - */ - this.value = 0; - - this.threshold = 0.05; - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.Axis#update - * @since 3.0.0 - * - * @param {[type]} value - [description] - */ - update: function (value) - { - this.value = value; - }, - - /** - * Applies threshold to the value and returns it. - * - * @method Phaser.Input.Gamepad.Axis#getValue - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getValue: function () - { - var percentage = (Math.abs(this.value) - this.threshold) / (1 - this.threshold); - - if (percentage < 0) - { - percentage = 0; - } - - return percentage * (this.value > 0 ? 1 : -1); - } - -}); - -module.exports = Axis; - - -/***/ }), -/* 244 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class Button - * @memberOf Phaser.Input.Gamepad - * @constructor - * @since 3.0.0 - * - * @param {[type]} pad - [description] - * @param {integer} index - [description] - */ -var Button = new Class({ - - initialize: - - function Button (pad, index) - { - /** - * [description] - * - * @name Phaser.Input.Gamepad.Button#pad - * @type {[type]} - * @since 3.0.0 - */ - this.pad = pad; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.Button#events - * @type {[type]} - * @since 3.0.0 - */ - this.events = pad.events; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.Button#index - * @type {integer} - * @since 3.0.0 - */ - this.index = index; - - /** - * Between 0 and 1. - * - * @name Phaser.Input.Gamepad.Button#value - * @type {float} - * @default 0 - * @since 3.0.0 - */ - this.value = 0; - - /** - * Can be set for Analogue buttons to enable a 'pressure' threshold before considered as 'pressed'. - * - * @name Phaser.Input.Gamepad.Button#threshold - * @type {float} - * @default 0 - * @since 3.0.0 - */ - this.threshold = 0; - - /** - * Is the Button being pressed down or not? - * - * @name Phaser.Input.Gamepad.Button#pressed + * @name Phaser.Physics.Arcade.Body#onOverlap * @type {boolean} * @default false * @since 3.0.0 */ - this.pressed = false; - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.Button#update - * @since 3.0.0 - * - * @param {[type]} data - [description] - */ - update: function (data) - { - this.value = data.value; - - if (this.value >= this.threshold) - { - if (!this.pressed) - { - this.pressed = true; - this.events.emit('down', this.pad, this, this.value, data); - } - } - else if (this.pressed) - { - this.pressed = false; - this.events.emit('up', this.pad, this, this.value, data); - } - } - -}); - -module.exports = Button; - - -/***/ }), -/* 245 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(14); -var Key = __webpack_require__(246); -var KeyCodes = __webpack_require__(129); -var KeyCombo = __webpack_require__(247); -var KeyMap = __webpack_require__(527); -var ProcessKeyDown = __webpack_require__(528); -var ProcessKeyUp = __webpack_require__(529); - -/** - * @classdesc - * The Keyboard class monitors keyboard input and dispatches keyboard events. - * - * _Note_: many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. - * See http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/ for more details. - * - * Also please be aware that certain browser extensions can disable or override Phaser keyboard handling. - * For example the Chrome extension vimium is known to disable Phaser from using the D key. And there are others. - * So please check your extensions before opening Phaser issues. - * - * @class KeyboardManager - * @extends EventEmitter - * @memberOf Phaser.Input.Keyboard - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Input.InputManager} inputManager - [description] - */ -var KeyboardManager = new Class({ - - Extends: EventEmitter, - - initialize: - - function KeyboardManager (inputManager) - { - EventEmitter.call(this); + this.onOverlap = false; /** * [description] * - * @name Phaser.Input.Keyboard.KeyboardManager#manager - * @type {Phaser.Input.InputManager} - * @since 3.0.0 - */ - this.manager = inputManager; - - /** - * [description] - * - * @name Phaser.Input.Keyboard.KeyboardManager#enabled - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.enabled = false; - - /** - * [description] - * - * @name Phaser.Input.Keyboard.KeyboardManager#target - * @type {null} - * @since 3.0.0 - */ - this.target; - - /** - * [description] - * - * @name Phaser.Input.Keyboard.KeyboardManager#keys - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.keys = []; - - /** - * [description] - * - * @name Phaser.Input.Keyboard.KeyboardManager#combos - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.combos = []; - - /** - * [description] - * - * @name Phaser.Input.Keyboard.KeyboardManager#captures - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.captures = []; - - /** - * [description] - * - * @name Phaser.Input.Keyboard.KeyboardManager#queue - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.queue = []; - - /** - * [description] - * - * @name Phaser.Input.Keyboard.KeyboardManager#handler - * @type {any} - * @since 3.0.0 - */ - this.handler; - }, - - /** - * The Boot handler is called by Phaser.Game when it first starts up. - * - * @method Phaser.Input.Keyboard.KeyboardManager#boot - * @since 3.0.0 - */ - boot: function () - { - var config = this.manager.config; - - this.enabled = config.inputKeyboard; - this.target = config.inputKeyboardEventTarget; - - if (this.enabled) - { - this.startListeners(); - } - }, - - /** - * [description] - * - * @method Phaser.Input.Keyboard.KeyboardManager#startListeners - * @since 3.0.0 - * - * @return {[type]} [description] - */ - startListeners: function () - { - var queue = this.queue; - var captures = this.captures; - - var handler = function (event) - { - if (event.defaultPrevented) - { - // Do nothing if event already handled - return; - } - - queue.push(event); - - if (captures[event.keyCode]) - { - event.preventDefault(); - } - }; - - this.handler = handler; - - this.target.addEventListener('keydown', handler, false); - this.target.addEventListener('keyup', handler, false); - }, - - /** - * [description] - * - * @method Phaser.Input.Keyboard.KeyboardManager#stopListeners - * @since 3.0.0 - */ - stopListeners: function () - { - this.target.removeEventListener('keydown', this.handler); - this.target.removeEventListener('keyup', this.handler); - }, - - /** - * Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right, and also space and shift. - * - * @method Phaser.Input.Keyboard.KeyboardManager#createCursorKeys - * @since 3.0.0 - * - * @return {[type]} [description] - */ - createCursorKeys: function () - { - return this.addKeys({ - up: KeyCodes.UP, - down: KeyCodes.DOWN, - left: KeyCodes.LEFT, - right: KeyCodes.RIGHT, - space: KeyCodes.SPACE, - shift: KeyCodes.SHIFT - }); - }, - - /** - * A practical way to create an object containing user selected hotkeys. - * - * For example, - * - * addKeys( { 'up': Phaser.KeyCode.W, 'down': Phaser.KeyCode.S, 'left': Phaser.KeyCode.A, 'right': Phaser.KeyCode.D } ); - * - * would return an object containing properties (`up`, `down`, `left` and `right`) referring to {@link Phaser.Key} object. - * - * @method Phaser.Input.Keyboard.KeyboardManager#addKeys - * @since 3.0.0 - * - * @param {[type]} keys - [description] - * - * @return {[type]} [description] - */ - addKeys: function (keys) - { - var output = {}; - - for (var key in keys) - { - output[key] = this.addKey(keys[key]); - } - - return output; - }, - - /** - * If you need more fine-grained control over a Key you can create a new Phaser.Key object via this method. - * The Key object can then be polled, have events attached to it, etc. - * - * @method Phaser.Input.Keyboard.KeyboardManager#addKey - * @since 3.0.0 - * - * @param {[type]} keyCode - [description] - * - * @return {[type]} [description] - */ - addKey: function (keyCode) - { - var keys = this.keys; - - if (!keys[keyCode]) - { - keys[keyCode] = new Key(keyCode); - this.captures[keyCode] = true; - } - - return keys[keyCode]; - }, - - /** - * Removes a Key object from the Keyboard manager. - * - * @method Phaser.Input.Keyboard.KeyboardManager#removeKey - * @since 3.0.0 - * - * @param {[type]} keyCode - [description] - */ - removeKey: function (keyCode) - { - if (this.keys[keyCode]) - { - this.keys[keyCode] = undefined; - this.captures[keyCode] = false; - } - }, - - /** - * [description] - * - * @method Phaser.Input.Keyboard.KeyboardManager#addKeyCapture - * @since 3.0.0 - * - * @param {[type]} keyCodes - [description] - */ - addKeyCapture: function (keyCodes) - { - if (!Array.isArray(keyCodes)) - { - keyCodes = [ keyCodes ]; - } - - for (var i = 0; i < keyCodes.length; i++) - { - this.captures[keyCodes[i]] = true; - } - }, - - /** - * [description] - * - * @method Phaser.Input.Keyboard.KeyboardManager#removeKeyCapture - * @since 3.0.0 - * - * @param {[type]} keyCodes - [description] - */ - removeKeyCapture: function (keyCodes) - { - if (!Array.isArray(keyCodes)) - { - keyCodes = [ keyCodes ]; - } - - for (var i = 0; i < keyCodes.length; i++) - { - this.captures[keyCodes[i]] = false; - } - }, - - /** - * [description] - * - * @method Phaser.Input.Keyboard.KeyboardManager#createCombo - * @since 3.0.0 - * - * @param {[type]} keys - [description] - * @param {[type]} config - [description] - * - * @return {[type]} [description] - */ - createCombo: function (keys, config) - { - return new KeyCombo(this, keys, config); - }, - - /** - * [description] - * - * @method Phaser.Input.Keyboard.KeyboardManager#update - * @since 3.0.0 - * - * @return {[type]} [description] - */ - update: function () - { - var len = this.queue.length; - - if (!this.enabled || len === 0) - { - return; - } - - // Clears the queue array, and also means we don't work on array data that could potentially - // be modified during the processing phase - var queue = this.queue.splice(0, len); - - var keys = this.keys; - - // Process the event queue, dispatching all of the events that have stored up - for (var i = 0; i < len; i++) - { - var event = queue[i]; - var code = event.keyCode; - - if (event.type === 'keydown') - { - if (KeyMap[code] && (keys[code] === undefined || keys[code].isDown === false)) - { - // Will emit a keyboard or keyup event - this.emit(event.type, event); - - this.emit('keydown_' + KeyMap[code], event); - } - - if (keys[code]) - { - ProcessKeyDown(keys[code], event); - } - } - else - { - // Will emit a keyboard or keyup event - this.emit(event.type, event); - - this.emit('keyup_' + KeyMap[code], event); - - if (keys[code]) - { - ProcessKeyUp(keys[code], event); - } - } - } - }, - - /** - * [description] - * - * @method Phaser.Input.Keyboard.KeyboardManager#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this.removeAllListeners(); - }, - - /** - * [description] - * - * @method Phaser.Input.Keyboard.KeyboardManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.stopListeners(); - - this.removeAllListeners(); - - this.keys = []; - this.combos = []; - this.captures = []; - this.queue = []; - this.handler = undefined; - - this.manager = null; - } - -}); - -module.exports = KeyboardManager; - - -/***/ }), -/* 246 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * A generic Key object which can be passed to the Process functions (and so on) - * keycode must be an integer - * - * @class Key - * @memberOf Phaser.Input.Keyboard - * @constructor - * @since 3.0.0 - * - * @param {integer} keyCode - The keycode of this key. - */ -var Key = new Class({ - - initialize: - - function Key (keyCode) - { - /** - * The keycode of this key. - * - * @name Phaser.Input.Keyboard.Key#keyCode - * @type {integer} - * @since 3.0.0 - */ - this.keyCode = keyCode; - - /** - * The original DOM event. - * - * @name Phaser.Input.Keyboard.Key#originalEvent - * @type {KeyboardEvent} - * @since 3.0.0 - */ - this.originalEvent = undefined; - - /** - * Should this Key prevent event propagation? - * - * @name Phaser.Input.Keyboard.Key#preventDefault - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.preventDefault = true; - - /** - * Can this Key be processed? - * - * @name Phaser.Input.Keyboard.Key#enabled - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.enabled = true; - - /** - * The "down" state of the key. This will remain `true` for as long as the keyboard thinks this key is held down. - * - * @name Phaser.Input.Keyboard.Key#isDown - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isDown = false; - - /** - * The "up" state of the key. This will remain `true` for as long as the keyboard thinks this key is up. - * - * @name Phaser.Input.Keyboard.Key#isUp - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.isUp = true; - - /** - * The down state of the ALT key, if pressed at the same time as this key. - * - * @name Phaser.Input.Keyboard.Key#altKey - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.altKey = false; - - /** - * The down state of the CTRL key, if pressed at the same time as this key. - * - * @name Phaser.Input.Keyboard.Key#ctrlKey - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.ctrlKey = false; - - /** - * The down state of the SHIFT key, if pressed at the same time as this key. - * - * @name Phaser.Input.Keyboard.Key#shiftKey - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.shiftKey = false; - - /** - * The location of the modifier key. 0 for standard (or unknown), 1 for left, 2 for right, 3 for numpad. - * - * @name Phaser.Input.Keyboard.Key#location - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.location = 0; - - /** - * The timestamp when the key was last pressed down. - * - * @name Phaser.Input.Keyboard.Key#timeDown - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.timeDown = 0; - - /** - * The number of milliseconds this key has been held down for. - * If the key is down this value holds the duration of that key press and is constantly updated. - * If the key is up it holds the duration of the previous down session. - * - * @name Phaser.Input.Keyboard.Key#duration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.duration = 0; - - /** - * The timestamp when the key was last released. - * - * @name Phaser.Input.Keyboard.Key#timeUp - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.timeUp = 0; - - /** - * If a key is held down this holds down the number of times the key has 'repeated'. - * - * @name Phaser.Input.Keyboard.Key#repeats - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.repeats = 0; - - /** - * True if the key has just been pressed (NOTE: requires to be reset, see justDown getter) - * - * @name Phaser.Input.Keyboard.Key#_justDown - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this._justDown = false; - - /** - * True if the key has just been pressed (NOTE: requires to be reset, see justDown getter) - * - * @name Phaser.Input.Keyboard.Key#_justUp - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this._justUp = false; - } - -}); - -module.exports = Key; - - -/***/ }), -/* 247 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(2); -var ProcessKeyCombo = __webpack_require__(524); -var ResetKeyCombo = __webpack_require__(526); - -/** - * @classdesc - * [description] - * - * `keys` argument can be: - * - * A string (ATARI) - * An array of either integers (key codes) or strings, or a mixture of both - * An array of objects (such as Key objects) with a public 'keyCode' property - * - * @class KeyCombo - * @memberOf Phaser.Input.Keyboard - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Input.Keyboard.KeyboardManager} keyboardManager - [description] - * @param {string|integers[]|object[]} keys - [description] - * @param {object} [config] - [description] - */ -var KeyCombo = new Class({ - - initialize: - - function KeyCombo (keyboardManager, keys, config) - { - if (config === undefined) { config = {}; } - - // Can't have a zero or single length combo (string or array based) - if (keys.length < 2) - { - return false; - } - - /** - * [description] - * - * @name Phaser.Input.Keyboard.KeyCombo#manager - * @type {Phaser.Input.Keyboard.KeyboardManager} - * @since 3.0.0 - */ - this.manager = keyboardManager; - - /** - * [description] - * - * @name Phaser.Input.Keyboard.KeyCombo#enabled - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.enabled = true; - - /** - * [description] - * - * @name Phaser.Input.Keyboard.KeyCombo#keyCodes - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.keyCodes = []; - - // if 'keys' is a string we need to get the keycode of each character in it - - for (var i = 0; i < keys.length; i++) - { - var char = keys[i]; - - if (typeof char === 'string') - { - this.keyCodes.push(char.toUpperCase().charCodeAt(0)); - } - else if (typeof char === 'number') - { - this.keyCodes.push(char); - } - else if (char.hasOwnProperty('keyCode')) - { - this.keyCodes.push(char.keyCode); - } - } - - /** - * The current keyCode the combo is waiting for. - * - * @name Phaser.Input.Keyboard.KeyCombo#current - * @type {integer} - * @since 3.0.0 - */ - this.current = this.keyCodes[0]; - - /** - * The current index of the key being waited for in the 'keys' string. - * - * @name Phaser.Input.Keyboard.KeyCombo#index - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.index = 0; - - /** - * The length of this combo (in keycodes) - * - * @name Phaser.Input.Keyboard.KeyCombo#size - * @type {[type]} - * @since 3.0.0 - */ - this.size = this.keyCodes.length; - - /** - * The time the previous key in the combo was matched. - * - * @name Phaser.Input.Keyboard.KeyCombo#timeLastMatched - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.timeLastMatched = 0; - - /** - * Has this Key Combo been matched yet? - * - * @name Phaser.Input.Keyboard.KeyCombo#matched - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.matched = false; - - /** - * The time the entire combo was matched. - * - * @name Phaser.Input.Keyboard.KeyCombo#timeMatched - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.timeMatched = 0; - - /** - * If they press the wrong key do we reset the combo? - * - * @name Phaser.Input.Keyboard.KeyCombo#resetOnWrongKey - * @type {boolean} - * @default 0 - * @since 3.0.0 - */ - this.resetOnWrongKey = GetFastValue(config, 'resetOnWrongKey', true); - - /** - * The max delay in ms between each key press. Above this the combo is reset. 0 means disabled. - * - * @name Phaser.Input.Keyboard.KeyCombo#maxKeyDelay - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.maxKeyDelay = GetFastValue(config, 'maxKeyDelay', 0); - - /** - * If previously matched and they press Key 1 again, will it reset? - * - * @name Phaser.Input.Keyboard.KeyCombo#resetOnMatch - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.resetOnMatch = GetFastValue(config, 'resetOnMatch', false); - - /** - * If the combo matches, will it delete itself? - * - * @name Phaser.Input.Keyboard.KeyCombo#deleteOnMatch - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.deleteOnMatch = GetFastValue(config, 'deleteOnMatch', false); - - var _this = this; - - var onKeyDownHandler = function (event) - { - if (_this.matched || !_this.enabled) - { - return; - } - - var matched = ProcessKeyCombo(event, _this); - - if (matched) - { - _this.manager.emit('keycombomatch', _this, event); - - if (_this.resetOnMatch) - { - ResetKeyCombo(_this); - } - else if (_this.deleteOnMatch) - { - _this.destroy(); - } - } - }; - - /** - * [description] - * - * @name Phaser.Input.Keyboard.KeyCombo#onKeyDown - * @type {function} - * @since 3.0.0 - */ - this.onKeyDown = onKeyDownHandler; - - this.manager.on('keydown', onKeyDownHandler); - }, - - /** - * How far complete is this combo? A value between 0 and 1. - * - * @name Phaser.Input.Keyboard.KeyCombo#progress - * @type {number} - * @readOnly - * @since 3.0.0 - */ - progress: { - - get: function () - { - return this.index / this.size; - } - - }, - - /** - * [description] - * - * @method Phaser.Input.Keyboard.KeyCombo#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.enabled = false; - this.keyCodes = []; - - this.manager.off('keydown', this.onKeyDown); - this.manager = undefined; - } - -}); - -module.exports = KeyCombo; - - -/***/ }), -/* 248 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Features = __webpack_require__(126); - -// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent -// https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md - -/** - * @classdesc - * [description] - * - * @class MouseManager - * @memberOf Phaser.Input.Mouse - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Input.InputManager} inputManager - [description] - */ -var MouseManager = new Class({ - - initialize: - - function MouseManager (inputManager) - { - /** - * [description] - * - * @name Phaser.Input.Mouse.MouseManager#manager - * @type {Phaser.Input.InputManager} - * @since 3.0.0 - */ - this.manager = inputManager; - - /** - * If true the DOM mouse events will have event.preventDefault applied to them, if false they will propagate fully. - * - * @name Phaser.Input.Mouse.MouseManager#capture - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.capture = true; - - /** - * [description] - * - * @name Phaser.Input.Mouse.MouseManager#enabled - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.enabled = false; - - /** - * [description] - * - * @name Phaser.Input.Mouse.MouseManager#target - * @type {null} - * @since 3.0.0 - */ - this.target; - - /** - * [description] - * - * @name Phaser.Input.Mouse.MouseManager#handler - * @type {null} - * @since 3.0.0 - */ - this.handler; - - /** - * If the mouse has been pointer locked successfully this will be set to true. - * - * @name Phaser.Input.Mouse.MouseManager#locked - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.locked = false; - }, - - /** - * [description] - * - * @method Phaser.Input.Mouse.MouseManager#boot - * @since 3.0.0 - */ - boot: function () - { - var config = this.manager.config; - - this.enabled = config.inputMouse; - this.target = config.inputMouseEventTarget; - this.capture = config.inputMouseCapture; - - if (!this.target) - { - this.target = this.manager.game.canvas; - } - - if (config.disableContextMenu) - { - this.disableContextMenu(); - } - - if (this.enabled) - { - this.startListeners(); - } - }, - - /** - * [description] - * - * @method Phaser.Input.Mouse.MouseManager#disableContextMenu - * @since 3.0.0 - * - * @return {Phaser.Input.Mouse.MouseManager} [description] - */ - disableContextMenu: function () - { - document.body.addEventListener('contextmenu', function (event) - { - event.preventDefault(); - return false; - }); - - return this; - }, - - /** - * If the browser supports it, you can request that the pointer be locked to the browser window. - * - * This is classically known as 'FPS controls', where the pointer can't leave the browser until - * the user presses an exit key. - * - * If the browser successfully enters a locked state, a `POINTER_LOCK_CHANGE_EVENT` will be dispatched, - * from the games Input Manager, with an `isPointerLocked` property. - * - * It is important to note that pointer lock can only be enabled after an 'engagement gesture', - * see: https://w3c.github.io/pointerlock/#dfn-engagement-gesture. - * - * @method Phaser.Input.Mouse.MouseManager#requestPointerLock - * @since 3.0.0 - */ - requestPointerLock: function () - { - if (Features.pointerLock) - { - var element = this.target; - element.requestPointerLock = element.requestPointerLock || element.mozRequestPointerLock || element.webkitRequestPointerLock; - element.requestPointerLock(); - } - }, - - /** - * Internal pointerLockChange handler. - * - * @method Phaser.Input.Mouse.MouseManager#pointerLockChange - * @since 3.0.0 - * - * @param {Event} event - The native event from the browser. - */ - pointerLockChange: function (event) - { - var element = this.target; - - this.locked = (document.pointerLockElement === element || document.mozPointerLockElement === element || document.webkitPointerLockElement === element) ? true : false; - - this.manager.queue.push(event); - }, - - /** - * If the browser supports pointer lock, this will request that the pointer lock is released. If - * the browser successfully enters a locked state, a 'POINTER_LOCK_CHANGE_EVENT' will be - * dispatched - from the game's input manager - with an `isPointerLocked` property. - * - * @method Phaser.Input.Mouse.MouseManager#releasePointerLock - * @since 3.0.0 - */ - releasePointerLock: function () - { - if (Features.pointerLock) - { - document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock || document.webkitExitPointerLock; - document.exitPointerLock(); - } - }, - - /** - * [description] - * - * @method Phaser.Input.Mouse.MouseManager#startListeners - * @since 3.0.0 - */ - startListeners: function () - { - var queue = this.manager.queue; - var target = this.target; - - var passive = { passive: true }; - var nonPassive = { passive: false }; - - var handler; - - if (this.capture) - { - handler = function (event) - { - if (event.defaultPrevented) - { - // Do nothing if event already handled - return; - } - - // console.log('mouse', event); - - queue.push(event); - - event.preventDefault(); - }; - - target.addEventListener('mousemove', handler, nonPassive); - target.addEventListener('mousedown', handler, nonPassive); - target.addEventListener('mouseup', handler, nonPassive); - } - else - { - handler = function (event) - { - if (event.defaultPrevented) - { - // Do nothing if event already handled - return; - } - - queue.push(event); - }; - - target.addEventListener('mousemove', handler, passive); - target.addEventListener('mousedown', handler, passive); - target.addEventListener('mouseup', handler, passive); - } - - this.handler = handler; - - if (Features.pointerLock) - { - this.pointerLockChange = this.pointerLockChange.bind(this); - - document.addEventListener('pointerlockchange', this.pointerLockChange, true); - document.addEventListener('mozpointerlockchange', this.pointerLockChange, true); - document.addEventListener('webkitpointerlockchange', this.pointerLockChange, true); - } - }, - - /** - * [description] - * - * @method Phaser.Input.Mouse.MouseManager#stopListeners - * @since 3.0.0 - */ - stopListeners: function () - { - var target = this.target; - - target.removeEventListener('mousemove', this.handler); - target.removeEventListener('mousedown', this.handler); - target.removeEventListener('mouseup', this.handler); - - if (Features.pointerLock) - { - document.removeEventListener('pointerlockchange', this.pointerLockChange, true); - document.removeEventListener('mozpointerlockchange', this.pointerLockChange, true); - document.removeEventListener('webkitpointerlockchange', this.pointerLockChange, true); - } - }, - - /** - * [description] - * - * @method Phaser.Input.Mouse.MouseManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.stopListeners(); - - this.manager = null; - } - -}); - -module.exports = MouseManager; - - -/***/ }), -/* 249 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Vector2 = __webpack_require__(6); - -// DOM event button value: -// A number representing a given button: -// 0: Main button pressed, usually the left button or the un-initialized state -// 1: Auxiliary button pressed, usually the wheel button or the middle button (if present) -// 2: Secondary button pressed, usually the right button -// 3: Fourth button, typically the Browser Back button -// 4: Fifth button, typically the Browser Forward button -// For a mouse configured for left-handed use, the button actions are reversed. In this case, the values are read from right to left. - -/** - * @classdesc - * [description] - * - * @class Pointer - * @memberOf Phaser.Input - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Input.InputManager} manager - [description] - * @param {integer} id - [description] - */ -var Pointer = new Class({ - - initialize: - - function Pointer (manager, id) - { - /** - * [description] - * - * @name Phaser.Input.Pointer#manager - * @type {Phaser.Input.InputManager} - * @since 3.0.0 - */ - this.manager = manager; - - /** - * [description] - * - * @name Phaser.Input.Pointer#id - * @type {integer} - * @since 3.0.0 - */ - this.id = id; - - /** - * [description] - * - * @name Phaser.Input.Pointer#event - * @type {null} - * @since 3.0.0 - */ - this.event; - - /** - * The camera the Pointer interacted with during its last update. - * A Pointer can only ever interact with one camera at once, which will be the top-most camera - * in the list should multiple cameras be positioned on-top of each other. - * - * @name Phaser.Input.Pointer#camera - * @type {Phaser.Cameras.Scene2D.Camera} - * @default null - * @since 3.0.0 - */ - this.camera = null; - - /** - * 0: No button or un-initialized - * 1: Left button - * 2: Right button - * 4: Wheel button or middle button - * 8: 4th button (typically the "Browser Back" button) - * 16: 5th button (typically the "Browser Forward" button) - * - * @name Phaser.Input.Pointer#buttons - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.buttons = 0; - - /** - * [description] - * - * @name Phaser.Input.Pointer#position + * @name Phaser.Physics.Arcade.Body#maxVelocity * @type {Phaser.Math.Vector2} * @since 3.0.0 */ - this.position = new Vector2(); - - /** - * X coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. - * - * @name Phaser.Input.Pointer#downX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.downX = 0; - - /** - * Y coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. - * - * @name Phaser.Input.Pointer#downY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.downY = 0; - - /** - * Time when Button 1 (left button), or Touch, was pressed, used for dragging objects. - * - * @name Phaser.Input.Pointer#downTime - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.downTime = 0; - - /** - * X coordinate of the Pointer when Button 1 (left button), or Touch, was released, used for dragging objects. - * - * @name Phaser.Input.Pointer#upX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.upX = 0; - - /** - * Y coordinate of the Pointer when Button 1 (left button), or Touch, was released, used for dragging objects. - * - * @name Phaser.Input.Pointer#upY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.upY = 0; - - /** - * Time when Button 1 (left button), or Touch, was released, used for dragging objects. - * - * @name Phaser.Input.Pointer#upTime - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.upTime = 0; - - /** - * Is the primary button down? (usually button 0, the left mouse button) - * - * @name Phaser.Input.Pointer#primaryDown - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.primaryDown = false; - - - /** - * The Drag State of the Pointer: - * - * 0 = Not dragging anything - * 1 = Being checked if dragging - * 2 = Dragging something - * - * @name Phaser.Input.Pointer#dragState - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.dragState = 0; - - /** - * Is _any_ button on this pointer considered as being down? - * - * @name Phaser.Input.Pointer#isDown - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isDown = false; + this.maxVelocity = new Vector2(10000, 10000); /** * [description] * - * @name Phaser.Input.Pointer#dirty + * @name Phaser.Physics.Arcade.Body#friction + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.friction = new Vector2(1, 0); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#angularVelocity + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angularVelocity = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#angularAcceleration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angularAcceleration = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#angularDrag + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angularDrag = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#maxAngular + * @type {number} + * @default 1000 + * @since 3.0.0 + */ + this.maxAngular = 1000; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#mass + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.mass = 1; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#angle + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angle = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#speed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.speed = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#facing + * @type {integer} + * @since 3.0.0 + */ + this.facing = CONST.FACING_NONE; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#immovable + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.immovable = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#moves + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.moves = true; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#customSeparateX + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customSeparateX = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#customSeparateY + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customSeparateY = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#overlapX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapX = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#overlapY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapY = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#overlapR + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapR = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#embedded + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.embedded = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#collideWorldBounds + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.collideWorldBounds = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#checkCollision + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.checkCollision = { none: false, up: true, down: true, left: true, right: true }; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#touching + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.touching = { none: true, up: false, down: false, left: false, right: false }; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#wasTouching + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.wasTouching = { none: true, up: false, down: false, left: false, right: false }; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#blocked + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.blocked = { none: true, up: false, down: false, left: false, right: false }; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#dirty * @type {boolean} * @default false * @since 3.0.0 @@ -47210,87 +45741,1159 @@ var Pointer = new Class({ /** * [description] * - * @name Phaser.Input.Pointer#justDown + * @name Phaser.Physics.Arcade.Body#syncBounds * @type {boolean} * @default false * @since 3.0.0 */ - this.justDown = false; + this.syncBounds = false; /** * [description] * - * @name Phaser.Input.Pointer#justUp + * @name Phaser.Physics.Arcade.Body#isMoving * @type {boolean} * @default false * @since 3.0.0 */ - this.justUp = false; + this.isMoving = false; /** * [description] * - * @name Phaser.Input.Pointer#justMoved + * @name Phaser.Physics.Arcade.Body#stopVelocityOnCollide * @type {boolean} - * @default false + * @default true * @since 3.0.0 */ - this.justMoved = false; + this.stopVelocityOnCollide = true; + + // read-only /** - * Did the previous input event come from a Touch input (true) or Mouse? (false) + * [description] * - * @name Phaser.Input.Pointer#wasTouch - * @type {boolean} - * @default false + * @name Phaser.Physics.Arcade.Body#physicsType + * @type {integer} + * @readOnly * @since 3.0.0 */ - this.wasTouch = false; + this.physicsType = CONST.DYNAMIC_BODY; /** - * If the mouse is locked, the horizontal relative movement of the Pointer in pixels since last frame. + * [description] * - * @name Phaser.Input.Pointer#movementX + * @name Phaser.Physics.Arcade.Body#_reset + * @type {boolean} + * @private + * @default true + * @since 3.0.0 + */ + this._reset = true; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#_sx * @type {number} + * @private + * @since 3.0.0 + */ + this._sx = gameObject.scaleX; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#_sy + * @type {number} + * @private + * @since 3.0.0 + */ + this._sy = gameObject.scaleY; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#_dx + * @type {number} + * @private * @default 0 * @since 3.0.0 */ - this.movementX = 0; + this._dx = 0; /** - * If the mouse is locked, the vertical relative movement of the Pointer in pixels since last frame. + * [description] * - * @name Phaser.Input.Pointer#movementY + * @name Phaser.Physics.Arcade.Body#_dy * @type {number} + * @private * @default 0 * @since 3.0.0 */ - this.movementY = 0; + this._dy = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#_bounds + * @type {Phaser.Geom.Rectangle} + * @private + * @since 3.0.0 + */ + this._bounds = new Rectangle(); }, /** * [description] * - * @method Phaser.Input.Pointer#positionToCamera + * @method Phaser.Physics.Arcade.Body#updateBounds + * @since 3.0.0 + */ + updateBounds: function () + { + var sprite = this.gameObject; + + if (this.syncBounds) + { + var b = sprite.getBounds(this._bounds); + + if (b.width !== this.width || b.height !== this.height) + { + this.width = b.width; + this.height = b.height; + this._reset = true; + } + } + else + { + var asx = Math.abs(sprite.scaleX); + var asy = Math.abs(sprite.scaleY); + + if (asx !== this._sx || asy !== this._sy) + { + this.width = this.sourceWidth * asx; + this.height = this.sourceHeight * asy; + this._sx = asx; + this._sy = asy; + this._reset = true; + } + } + + if (this._reset) + { + this.halfWidth = Math.floor(this.width / 2); + this.halfHeight = Math.floor(this.height / 2); + this.updateCenter(); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#updateCenter + * @since 3.0.0 + */ + updateCenter: function () + { + this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#update * @since 3.0.0 * - * @param {[type]} camera - [description] - * @param {[type]} output - [description] - * - * @return {[type]} [description] + * @param {number} delta - [description] */ - positionToCamera: function (camera, output) + update: function (delta) { - return camera.getWorldPoint(this.x, this.y, output); + this.dirty = true; + + // Store and reset collision flags + this.wasTouching.none = this.touching.none; + this.wasTouching.up = this.touching.up; + this.wasTouching.down = this.touching.down; + this.wasTouching.left = this.touching.left; + this.wasTouching.right = this.touching.right; + + this.touching.none = true; + this.touching.up = false; + this.touching.down = false; + this.touching.left = false; + this.touching.right = false; + + this.blocked.none = true; + this.blocked.up = false; + this.blocked.down = false; + this.blocked.left = false; + this.blocked.right = false; + + this.overlapR = 0; + this.overlapX = 0; + this.overlapY = 0; + + this.embedded = false; + + this.updateBounds(); + + var sprite = this.gameObject; + + this.position.x = sprite.x + sprite.scaleX * (this.offset.x - sprite.displayOriginX); + this.position.y = sprite.y + sprite.scaleY * (this.offset.y - sprite.displayOriginY); + + this.updateCenter(); + + this.rotation = sprite.angle; + + this.preRotation = this.rotation; + + if (this._reset) + { + this.prev.x = this.position.x; + this.prev.y = this.position.y; + } + + if (this.moves) + { + this.world.updateMotion(this); + + this.newVelocity.set(this.velocity.x * delta, this.velocity.y * delta); + + this.position.x += this.newVelocity.x; + this.position.y += this.newVelocity.y; + + this.updateCenter(); + + if (this.position.x !== this.prev.x || this.position.y !== this.prev.y) + { + this.angle = Math.atan2(this.velocity.y, this.velocity.x); + } + + this.speed = Math.sqrt(this.velocity.x * this.velocity.x + this.velocity.y * this.velocity.y); + + // Now the State update will throw collision checks at the Body + // And finally we'll integrate the new position back to the Sprite in postUpdate + + if (this.collideWorldBounds && this.checkWorldBounds() && this.onWorldBounds) + { + this.world.emit('worldbounds', this, this.blocked.up, this.blocked.down, this.blocked.left, this.blocked.right); + } + } + + this._dx = this.deltaX(); + this._dy = this.deltaY(); + + this._reset = false; + }, + + /** + * Feeds the body results back into the parent gameobject. + * + * @method Phaser.Physics.Arcade.Body#postUpdate + * @since 3.0.0 + */ + postUpdate: function () + { + // Only allow postUpdate to be called once per frame + if (!this.enable || !this.dirty) + { + return; + } + + this.dirty = false; + + this._dx = this.deltaX(); + this._dy = this.deltaY(); + + if (this._dx < 0) + { + this.facing = CONST.FACING_LEFT; + } + else if (this._dx > 0) + { + this.facing = CONST.FACING_RIGHT; + } + + if (this._dy < 0) + { + this.facing = CONST.FACING_UP; + } + else if (this._dy > 0) + { + this.facing = CONST.FACING_DOWN; + } + + if (this.moves) + { + if (this.deltaMax.x !== 0 && this._dx !== 0) + { + if (this._dx < 0 && this._dx < -this.deltaMax.x) + { + this._dx = -this.deltaMax.x; + } + else if (this._dx > 0 && this._dx > this.deltaMax.x) + { + this._dx = this.deltaMax.x; + } + } + + if (this.deltaMax.y !== 0 && this._dy !== 0) + { + if (this._dy < 0 && this._dy < -this.deltaMax.y) + { + this._dy = -this.deltaMax.y; + } + else if (this._dy > 0 && this._dy > this.deltaMax.y) + { + this._dy = this.deltaMax.y; + } + } + + this.gameObject.x += this._dx; + this.gameObject.y += this._dy; + + this._reset = true; + } + + this.updateCenter(); + + if (this.allowRotation) + { + this.gameObject.angle += this.deltaZ(); + } + + this.prev.x = this.position.x; + this.prev.y = this.position.y; }, /** * [description] - * - * @name Phaser.Input.Pointer#x + * + * @method Phaser.Physics.Arcade.Body#checkWorldBounds + * @since 3.0.0 + * + * @return {boolean} [description] + */ + checkWorldBounds: function () + { + var pos = this.position; + var bounds = this.world.bounds; + var check = this.world.checkCollision; + + var bx = (this.worldBounce) ? -this.worldBounce.x : -this.bounce.x; + var by = (this.worldBounce) ? -this.worldBounce.y : -this.bounce.y; + + if (pos.x < bounds.x && check.left) + { + pos.x = bounds.x; + this.velocity.x *= bx; + this.blocked.left = true; + this.blocked.none = false; + } + else if (this.right > bounds.right && check.right) + { + pos.x = bounds.right - this.width; + this.velocity.x *= bx; + this.blocked.right = true; + this.blocked.none = false; + } + + if (pos.y < bounds.y && check.up) + { + pos.y = bounds.y; + this.velocity.y *= by; + this.blocked.up = true; + this.blocked.none = false; + } + else if (this.bottom > bounds.bottom && check.down) + { + pos.y = bounds.bottom - this.height; + this.velocity.y *= by; + this.blocked.down = true; + this.blocked.none = false; + } + + return !this.blocked.none; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setOffset + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setOffset: function (x, y) + { + if (y === undefined) { y = x; } + + this.offset.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setSize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * @param {boolean} [center=true] - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setSize: function (width, height, center) + { + if (center === undefined) { center = true; } + + var gameObject = this.gameObject; + + this.sourceWidth = width; + this.sourceHeight = height; + + this.width = this.sourceWidth * this._sx; + this.height = this.sourceHeight * this._sy; + + this.halfWidth = Math.floor(this.width / 2); + this.halfHeight = Math.floor(this.height / 2); + + this.updateCenter(); + + if (center && gameObject.getCenter) + { + var ox = gameObject.displayWidth / 2; + var oy = gameObject.displayHeight / 2; + + this.offset.set(ox - this.halfWidth, oy - this.halfHeight); + } + + this.isCircle = false; + this.radius = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setCircle + * @since 3.0.0 + * + * @param {number} radius - [description] + * @param {number} [offsetX] - [description] + * @param {number} [offsetY] - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setCircle: function (radius, offsetX, offsetY) + { + if (offsetX === undefined) { offsetX = this.offset.x; } + if (offsetY === undefined) { offsetY = this.offset.y; } + + if (radius > 0) + { + this.isCircle = true; + this.radius = radius; + + this.sourceWidth = radius * 2; + this.sourceHeight = radius * 2; + + this.width = this.sourceWidth * this._sx; + this.height = this.sourceHeight * this._sy; + + this.halfWidth = Math.floor(this.width / 2); + this.halfHeight = Math.floor(this.height / 2); + + this.offset.set(offsetX, offsetY); + + this.updateCenter(); + } + else + { + this.isCircle = false; + } + + return this; + }, + + /** + * Resets this Body to the given coordinates. Also positions its parent Game Object to the same coordinates. + * If the body had any velocity or acceleration it is lost as a result of calling this. + * + * @method Phaser.Physics.Arcade.Body#reset + * @since 3.0.0 + * + * @param {number} x - The horizontal position to place the Game Object and Body. + * @param {number} y - The vertical position to place the Game Object and Body. + */ + reset: function (x, y) + { + this.stop(); + + var gameObject = this.gameObject; + + gameObject.setPosition(x, y); + + gameObject.getTopLeft(this.position); + + this.prev.copy(this.position); + + this.rotation = gameObject.angle; + this.preRotation = gameObject.angle; + + this.updateBounds(); + this.updateCenter(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#stop + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + stop: function () + { + this.velocity.set(0); + this.acceleration.set(0); + this.speed = 0; + this.angularVelocity = 0; + this.angularAcceleration = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#getBounds + * @since 3.0.0 + * + * @param {ArcadeBodyBounds} obj - [description] + * + * @return {ArcadeBodyBounds} [description] + */ + getBounds: function (obj) + { + obj.x = this.x; + obj.y = this.y; + obj.right = this.right; + obj.bottom = this.bottom; + + return obj; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#hitTest + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ + hitTest: function (x, y) + { + return (this.isCircle) ? CircleContains(this, x, y) : RectangleContains(this, x, y); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#onFloor + * @since 3.0.0 + * + * @return {boolean} [description] + */ + onFloor: function () + { + return this.blocked.down; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#onCeiling + * @since 3.0.0 + * + * @return {boolean} [description] + */ + onCeiling: function () + { + return this.blocked.up; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#onWall + * @since 3.0.0 + * + * @return {boolean} [description] + */ + onWall: function () + { + return (this.blocked.left || this.blocked.right); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#deltaAbsX + * @since 3.0.0 + * + * @return {number} [description] + */ + deltaAbsX: function () + { + return (this.deltaX() > 0) ? this.deltaX() : -this.deltaX(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#deltaAbsY + * @since 3.0.0 + * + * @return {number} [description] + */ + deltaAbsY: function () + { + return (this.deltaY() > 0) ? this.deltaY() : -this.deltaY(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#deltaX + * @since 3.0.0 + * + * @return {number} [description] + */ + deltaX: function () + { + return this.position.x - this.prev.x; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#deltaY + * @since 3.0.0 + * + * @return {number} [description] + */ + deltaY: function () + { + return this.position.y - this.prev.y; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#deltaZ + * @since 3.0.0 + * + * @return {number} [description] + */ + deltaZ: function () + { + return this.rotation - this.preRotation; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.enable = false; + + this.world.pendingDestroy.set(this); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#drawDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphic - [description] + */ + drawDebug: function (graphic) + { + var pos = this.position; + var x = pos.x + this.halfWidth; + var y = pos.y + this.halfHeight; + + if (this.debugShowBody) + { + graphic.lineStyle(1, this.debugBodyColor); + + if (this.isCircle) + { + graphic.strokeCircle(x, y, this.width / 2); + } + else + { + graphic.strokeRect(pos.x, pos.y, this.width, this.height); + } + } + + if (this.debugShowVelocity) + { + graphic.lineStyle(1, this.world.defaults.velocityDebugColor, 1); + graphic.lineBetween(x, y, x + this.velocity.x / 2, y + this.velocity.y / 2); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#willDrawDebug + * @since 3.0.0 + * + * @return {boolean} [description] + */ + willDrawDebug: function () + { + return (this.debugShowBody || this.debugShowVelocity); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setCollideWorldBounds + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setCollideWorldBounds: function (value) + { + this.collideWorldBounds = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setVelocity + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setVelocity: function (x, y) + { + this.velocity.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setVelocityX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setVelocityX: function (value) + { + this.velocity.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setVelocityY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setVelocityY: function (value) + { + this.velocity.y = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setBounce + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setBounce: function (x, y) + { + this.bounce.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setBounceX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setBounceX: function (value) + { + this.bounce.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setBounceY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setBounceY: function (value) + { + this.bounce.y = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setAcceleration + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAcceleration: function (x, y) + { + this.acceleration.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setAccelerationX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAccelerationX: function (value) + { + this.acceleration.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setAccelerationY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAccelerationY: function (value) + { + this.acceleration.y = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setDrag + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setDrag: function (x, y) + { + this.drag.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setDragX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setDragX: function (value) + { + this.drag.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setDragY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setDragY: function (value) + { + this.drag.y = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setGravity + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setGravity: function (x, y) + { + this.gravity.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setGravityX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setGravityX: function (value) + { + this.gravity.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setGravityY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setGravityY: function (value) + { + this.gravity.y = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setFriction + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setFriction: function (x, y) + { + this.friction.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setFrictionX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setFrictionX: function (value) + { + this.friction.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setFrictionY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setFrictionY: function (value) + { + this.friction.y = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setAngularVelocity + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAngularVelocity: function (value) + { + this.angularVelocity = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setAngularAcceleration + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAngularAcceleration: function (value) + { + this.angularAcceleration = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setAngularDrag + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAngularDrag: function (value) + { + this.angularDrag = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setMass + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setMass: function (value) + { + this.mass = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setImmovable + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setImmovable: function (value) + { + this.immovable = value; + + return this; + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#x * @type {number} * @since 3.0.0 - */ + */ x: { get: function () @@ -47307,11 +46910,11 @@ var Pointer = new Class({ /** * [description] - * - * @name Phaser.Input.Pointer#y + * + * @name Phaser.Physics.Arcade.Body#y * @type {number} * @since 3.0.0 - */ + */ y: { get: function () @@ -47329,317 +46932,2393 @@ var Pointer = new Class({ /** * [description] * - * @method Phaser.Input.Pointer#reset + * @name Phaser.Physics.Arcade.Body#left + * @type {number} + * @readOnly * @since 3.0.0 */ - reset: function () - { - // this.buttons = 0; + left: { - this.dirty = false; - - this.justDown = false; - this.justUp = false; - this.justMoved = false; - - this.movementX = 0; - this.movementY = 0; - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#touchmove - * @since 3.0.0 - * - * @param {[type]} event - [description] - * @param {[type]} time - [description] - */ - touchmove: function (event) - { - this.event = event; - - this.x = this.manager.transformX(event.changedTouches[0].pageX); - this.y = this.manager.transformY(event.changedTouches[0].pageY); - - this.justMoved = true; - - this.dirty = true; - - this.wasTouch = true; - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#move - * @since 3.0.0 - * - * @param {[type]} event - [description] - * @param {[type]} time - [description] - */ - move: function (event) - { - if (event.buttons) + get: function () { - this.buttons = event.buttons; + return this.position.x; } - this.event = event; + }, - this.x = this.manager.transformX(event.pageX); - this.y = this.manager.transformY(event.pageY); + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#right + * @type {number} + * @readOnly + * @since 3.0.0 + */ + right: { - if (this.manager.mouse.locked) + get: function () { - // Multiple DOM events may occur within one frame, but only one Phaser event will fire - this.movementX += event.movementX || event.mozMovementX || event.webkitMovementX || 0; - this.movementY += event.movementY || event.mozMovementY || event.webkitMovementY || 0; + return this.position.x + this.width; } - this.justMoved = true; - - this.dirty = true; - - this.wasTouch = false; }, /** * [description] * - * @method Phaser.Input.Pointer#down + * @name Phaser.Physics.Arcade.Body#top + * @type {number} + * @readOnly * @since 3.0.0 - * - * @param {[type]} event - [description] - * @param {[type]} time - [description] */ - down: function (event, time) - { - if (event.buttons) + top: { + + get: function () { - this.buttons = event.buttons; + return this.position.y; } - this.event = event; + }, - this.x = this.manager.transformX(event.pageX); - this.y = this.manager.transformY(event.pageY); + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#bottom + * @type {number} + * @readOnly + * @since 3.0.0 + */ + bottom: { - // 0: Main button pressed, usually the left button or the un-initialized state - if (event.button === 0) + get: function () { - this.primaryDown = true; - this.downX = this.x; - this.downY = this.y; - this.downTime = time; + return this.position.y + this.height; } - this.justDown = true; - this.isDown = true; - - this.dirty = true; - - this.wasTouch = false; - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#touchstart - * @since 3.0.0 - * - * @param {[type]} event - [description] - * @param {[type]} time - [description] - */ - touchstart: function (event, time) - { - this.buttons = 1; - - this.event = event; - - this.x = this.manager.transformX(event.changedTouches[0].pageX); - this.y = this.manager.transformY(event.changedTouches[0].pageY); - - this.primaryDown = true; - this.downX = this.x; - this.downY = this.y; - this.downTime = time; - - this.justDown = true; - this.isDown = true; - - this.dirty = true; - - this.wasTouch = true; - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#up - * @since 3.0.0 - * - * @param {[type]} event - [description] - * @param {[type]} time - [description] - */ - up: function (event, time) - { - if (event.buttons) - { - this.buttons = event.buttons; - } - - this.event = event; - - this.x = this.manager.transformX(event.pageX); - this.y = this.manager.transformY(event.pageY); - - // 0: Main button pressed, usually the left button or the un-initialized state - if (event.button === 0) - { - this.primaryDown = false; - this.upX = this.x; - this.upY = this.y; - this.upTime = time; - } - - this.justUp = true; - this.isDown = false; - - this.dirty = true; - - this.wasTouch = false; - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#touchend - * @since 3.0.0 - * - * @param {[type]} event - [description] - * @param {[type]} time - [description] - */ - touchend: function (event, time) - { - this.buttons = 0; - - this.event = event; - - this.x = this.manager.transformX(event.changedTouches[0].pageX); - this.y = this.manager.transformY(event.changedTouches[0].pageY); - - this.primaryDown = false; - this.upX = this.x; - this.upY = this.y; - this.upTime = time; - - this.justUp = true; - this.isDown = false; - - this.dirty = true; - - this.wasTouch = true; - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#noButtonDown - * @since 3.0.0 - * - * @return {boolean} [description] - */ - noButtonDown: function () - { - return (this.buttons === 0); - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#leftButtonDown - * @since 3.0.0 - * - * @return {boolean} [description] - */ - leftButtonDown: function () - { - return (this.buttons & 1); - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#rightButtonDown - * @since 3.0.0 - * - * @return {boolean} [description] - */ - rightButtonDown: function () - { - return (this.buttons & 2); - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#middleButtonDown - * @since 3.0.0 - * - * @return {boolean} [description] - */ - middleButtonDown: function () - { - return (this.buttons & 4); - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#backButtonDown - * @since 3.0.0 - * - * @return {boolean} [description] - */ - backButtonDown: function () - { - return (this.buttons & 8); - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#forwardButtonDown - * @since 3.0.0 - * - * @return {boolean} [description] - */ - forwardButtonDown: function () - { - return (this.buttons & 16); - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.camera = null; - this.manager = null; - this.position = null; } }); -module.exports = Pointer; +module.exports = Body; /***/ }), -/* 250 */ +/* 210 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Body = __webpack_require__(209); +var Clamp = __webpack_require__(64); +var Class = __webpack_require__(0); +var Collider = __webpack_require__(208); +var CONST = __webpack_require__(47); +var DistanceBetween = __webpack_require__(48); +var EventEmitter = __webpack_require__(15); +var GetOverlapX = __webpack_require__(207); +var GetOverlapY = __webpack_require__(206); +var GetValue = __webpack_require__(5); +var ProcessQueue = __webpack_require__(205); +var ProcessTileCallbacks = __webpack_require__(477); +var Rectangle = __webpack_require__(10); +var RTree = __webpack_require__(204); +var SeparateTile = __webpack_require__(476); +var SeparateX = __webpack_require__(471); +var SeparateY = __webpack_require__(470); +var Set = __webpack_require__(63); +var StaticBody = __webpack_require__(201); +var TileIntersectsBody = __webpack_require__(202); +var Vector2 = __webpack_require__(6); +var Wrap = __webpack_require__(43); + +/** + * @typedef {object} ArcadeWorldConfig + * + * @property {object} [gravity] - [description] + * @property {number} [gravity.x=0] - [description] + * @property {number} [gravity.y=0] - [description] + * @property {number} [x=0] - [description] + * @property {number} [y=0] - [description] + * @property {number} [width=0] - [description] + * @property {number} [height=0] - [description] + * @property {object} [checkCollision] - [description] + * @property {boolean} [checkCollision.up=true] - [description] + * @property {boolean} [checkCollision.down=true] - [description] + * @property {boolean} [checkCollision.left=true] - [description] + * @property {boolean} [checkCollision.right=true] - [description] + * @property {number} [overlapBias=4] - [description] + * @property {number} [tileBias=16] - [description] + * @property {boolean} [forceX=false] - [description] + * @property {boolean} [isPaused=false] - [description] + * @property {boolean} [debug=false] - [description] + * @property {boolean} [debugShowBody=true] - [description] + * @property {boolean} [debugShowStaticBody=true] - [description] + * @property {boolean} [debugShowVelocity=true] - [description] + * @property {number} [debugBodyColor=0xff00ff] - [description] + * @property {number} [debugStaticBodyColor=0x0000ff] - [description] + * @property {number} [debugVelocityColor=0x00ff00] - [description] + * @property {number} [maxEntries=16] - [description] + */ + +/** + * @typedef {object} CheckCollisionObject + * + * @property {boolean} up - [description] + * @property {boolean} down - [description] + * @property {boolean} left - [description] + * @property {boolean} right - [description] + */ + +/** + * @typedef {object} ArcadeWorldDefaults + * + * @property {boolean} debugShowBody - [description] + * @property {boolean} debugShowStaticBody - [description] + * @property {boolean} debugShowVelocity - [description] + * @property {number} bodyDebugColor - [description] + * @property {number} staticBodyDebugColor - [description] + * @property {number} velocityDebugColor - [description] + */ + +/** + * @typedef {object} ArcadeWorldTreeMinMax + * + * @property {number} minX - [description] + * @property {number} minY - [description] + * @property {number} maxX - [description] + * @property {number} maxY - [description] + */ + +/** + * @classdesc + * [description] + * + * @class World + * @extends EventEmitter + * @memberOf Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {ArcadeWorldConfig} config - [description] + */ +var World = new Class({ + + Extends: EventEmitter, + + initialize: + + function World (scene, config) + { + EventEmitter.call(this); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * Dynamic Bodies + * + * @name Phaser.Physics.Arcade.World#bodies + * @type {Phaser.Structs.Set} + * @since 3.0.0 + */ + this.bodies = new Set(); + + /** + * Static Bodies + * + * @name Phaser.Physics.Arcade.World#staticBodies + * @type {Phaser.Structs.Set} + * @since 3.0.0 + */ + this.staticBodies = new Set(); + + /** + * Static Bodies + * + * @name Phaser.Physics.Arcade.World#pendingDestroy + * @type {Phaser.Structs.Set} + * @since 3.1.0 + */ + this.pendingDestroy = new Set(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#colliders + * @type {Phaser.Structs.ProcessQueue} + * @since 3.0.0 + */ + this.colliders = new ProcessQueue(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#gravity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.gravity = new Vector2(GetValue(config, 'gravity.x', 0), GetValue(config, 'gravity.y', 0)); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#bounds + * @type {Phaser.Geom.Rectangle} + * @since 3.0.0 + */ + this.bounds = new Rectangle( + GetValue(config, 'x', 0), + GetValue(config, 'y', 0), + GetValue(config, 'width', scene.sys.game.config.width), + GetValue(config, 'height', scene.sys.game.config.height) + ); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#checkCollision + * @type {CheckCollisionObject} + * @since 3.0.0 + */ + this.checkCollision = { + up: GetValue(config, 'checkCollision.up', true), + down: GetValue(config, 'checkCollision.down', true), + left: GetValue(config, 'checkCollision.left', true), + right: GetValue(config, 'checkCollision.right', true) + }; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#OVERLAP_BIAS + * @type {number} + * @default 4 + * @since 3.0.0 + */ + this.OVERLAP_BIAS = GetValue(config, 'overlapBias', 4); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#TILE_BIAS + * @type {number} + * @default 16 + * @since 3.0.0 + */ + this.TILE_BIAS = GetValue(config, 'tileBias', 16); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#forceX + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.forceX = GetValue(config, 'forceX', false); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#isPaused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isPaused = GetValue(config, 'isPaused', false); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#_total + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._total = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#drawDebug + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.drawDebug = GetValue(config, 'debug', false); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#debugGraphic + * @type {Phaser.GameObjects.Graphics} + * @since 3.0.0 + */ + this.debugGraphic; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#defaults + * @type {ArcadeWorldDefaults} + * @since 3.0.0 + */ + this.defaults = { + debugShowBody: GetValue(config, 'debugShowBody', true), + debugShowStaticBody: GetValue(config, 'debugShowStaticBody', true), + debugShowVelocity: GetValue(config, 'debugShowVelocity', true), + bodyDebugColor: GetValue(config, 'debugBodyColor', 0xff00ff), + staticBodyDebugColor: GetValue(config, 'debugStaticBodyColor', 0x0000ff), + velocityDebugColor: GetValue(config, 'debugVelocityColor', 0x00ff00) + }; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#maxEntries + * @type {integer} + * @default 16 + * @since 3.0.0 + */ + this.maxEntries = GetValue(config, 'maxEntries', 16); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#tree + * @type {Phaser.Structs.RTree} + * @since 3.0.0 + */ + this.tree = new RTree(this.maxEntries, [ '.left', '.top', '.right', '.bottom' ]); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#staticTree + * @type {Phaser.Structs.RTree} + * @since 3.0.0 + */ + this.staticTree = new RTree(this.maxEntries, [ '.left', '.top', '.right', '.bottom' ]); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#treeMinMax + * @type {ArcadeWorldTreeMinMax} + * @since 3.0.0 + */ + this.treeMinMax = { minX: 0, minY: 0, maxX: 0, maxY: 0 }; + + if (this.drawDebug) + { + this.createDebugGraphic(); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#enable + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} object - [description] + * @param {integer} [bodyType] - The type of Body to create. Either `DYNAMIC_BODY` or `STATIC_BODY`. + */ + enable: function (object, bodyType) + { + if (bodyType === undefined) { bodyType = CONST.DYNAMIC_BODY; } + + var i = 1; + + if (Array.isArray(object)) + { + i = object.length; + + while (i--) + { + if (object[i].hasOwnProperty('children')) + { + // If it's a Group then we do it on the children regardless + this.enable(object[i].children.entries, bodyType); + } + else + { + this.enableBody(object[i], bodyType); + } + } + } + else if (object.hasOwnProperty('children')) + { + // If it's a Group then we do it on the children regardless + this.enable(object.children.entries, bodyType); + } + else + { + this.enableBody(object, bodyType); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#enableBody + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} object - [description] + * @param {integer} [bodyType] - The type of Body to create. Either `DYNAMIC_BODY` or `STATIC_BODY`. + * + * @return {Phaser.GameObjects.GameObject} [description] + */ + enableBody: function (object, bodyType) + { + if (object.body === null) + { + if (bodyType === CONST.DYNAMIC_BODY) + { + object.body = new Body(this, object); + + this.bodies.set(object.body); + } + else if (bodyType === CONST.STATIC_BODY) + { + object.body = new StaticBody(this, object); + + this.staticBodies.set(object.body); + + this.staticTree.insert(object.body); + } + } + + return object; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#remove + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} object - [description] + */ + remove: function (object) + { + this.disableBody(object); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#disable + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} object - [description] + */ + disable: function (object) + { + var i = 1; + + if (Array.isArray(object)) + { + i = object.length; + + while (i--) + { + if (object[i].hasOwnProperty('children')) + { + // If it's a Group then we do it on the children regardless + this.disable(object[i].children.entries); + } + else + { + this.disableGameObjectBody(object[i]); + } + } + } + else if (object.hasOwnProperty('children')) + { + // If it's a Group then we do it on the children regardless + this.disable(object.children.entries); + } + else + { + this.disableGameObjectBody(object); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#disableGameObjectBody + * @since 3.1.0 + * + * @param {Phaser.GameObjects.GameObject} object - [description] + * + * @return {Phaser.GameObjects.GameObject} [description] + */ + disableGameObjectBody: function (object) + { + if (object.body) + { + if (object.body.physicsType === CONST.DYNAMIC_BODY) + { + this.bodies.delete(object.body); + } + else if (object.body.physicsType === CONST.STATIC_BODY) + { + this.staticBodies.delete(object.body); + this.staticTree.remove(object.body); + } + + object.body.enable = false; + } + + return object; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#disableBody + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - [description] + */ + disableBody: function (body) + { + if (body.physicsType === CONST.DYNAMIC_BODY) + { + this.tree.remove(body); + this.bodies.delete(body); + } + else if (body.physicsType === CONST.STATIC_BODY) + { + this.staticBodies.delete(body); + this.staticTree.remove(body); + } + + body.enable = false; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#createDebugGraphic + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} [description] + */ + createDebugGraphic: function () + { + var graphic = this.scene.sys.add.graphics({ x: 0, y: 0 }); + + graphic.setDepth(Number.MAX_VALUE); + + this.debugGraphic = graphic; + + this.drawDebug = true; + + return graphic; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#setBounds + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {boolean} [checkLeft] - [description] + * @param {boolean} [checkRight] - [description] + * @param {boolean} [checkUp] - [description] + * @param {boolean} [checkDown] - [description] + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + setBounds: function (x, y, width, height, checkLeft, checkRight, checkUp, checkDown) + { + this.bounds.setTo(x, y, width, height); + + if (checkLeft !== undefined) + { + this.setBoundsCollision(checkLeft, checkRight, checkUp, checkDown); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#setBoundsCollision + * @since 3.0.0 + * + * @param {boolean} [left=true] - [description] + * @param {boolean} [right=true] - [description] + * @param {boolean} [up=true] - [description] + * @param {boolean} [down=true] - [description] + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + setBoundsCollision: function (left, right, up, down) + { + if (left === undefined) { left = true; } + if (right === undefined) { right = true; } + if (up === undefined) { up = true; } + if (down === undefined) { down = true; } + + this.checkCollision.left = left; + this.checkCollision.right = right; + this.checkCollision.up = up; + this.checkCollision.down = down; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#pause + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + pause: function () + { + this.isPaused = true; + + this.emit('pause'); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#resume + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + resume: function () + { + this.isPaused = false; + + this.emit('resume'); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#addCollider + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for collision. + * @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for collision. + * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects collide. Must return a boolean. + * @param {*} [callbackContext] - The scope in which to call the callbacks. + * + * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. + */ + addCollider: function (object1, object2, collideCallback, processCallback, callbackContext) + { + if (collideCallback === undefined) { collideCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = collideCallback; } + + var collider = new Collider(this, false, object1, object2, collideCallback, processCallback, callbackContext); + + this.colliders.add(collider); + + return collider; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#addOverlap + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for overlap. + * @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for overlap. + * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects overlap. + * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects overlap. Must return a boolean. + * @param {*} [callbackContext] - The scope in which to call the callbacks. + * + * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. + */ + addOverlap: function (object1, object2, collideCallback, processCallback, callbackContext) + { + if (collideCallback === undefined) { collideCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = collideCallback; } + + var collider = new Collider(this, true, object1, object2, collideCallback, processCallback, callbackContext); + + this.colliders.add(collider); + + return collider; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#removeCollider + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Collider} collider - [description] + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + removeCollider: function (collider) + { + this.colliders.remove(collider); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#update + * @since 3.0.0 + * + * @param {number} time - [description] + * @param {number} delta - [description] + */ + update: function (time, delta) + { + if (this.isPaused || this.bodies.size === 0) + { + return; + } + + // this.delta = Math.min(delta / 1000, this.maxStep) * this.timeScale; + delta /= 1000; + + this.delta = delta; + + // Update all active bodies + + var i; + var body; + var bodies = this.bodies.entries; + var len = bodies.length; + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.enable) + { + body.update(delta); + } + } + + // Populate our dynamic collision tree + this.tree.clear(); + this.tree.load(bodies); + + // Process any colliders + var colliders = this.colliders.update(); + + for (i = 0; i < colliders.length; i++) + { + var collider = colliders[i]; + + if (collider.active) + { + collider.update(); + } + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#postUpdate + * @since 3.0.0 + */ + postUpdate: function () + { + var i; + var body; + + var dynamic = this.bodies; + var staticBodies = this.staticBodies; + var pending = this.pendingDestroy; + + var bodies = dynamic.entries; + var len = bodies.length; + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.enable) + { + body.postUpdate(); + } + } + + if (this.drawDebug) + { + var graphics = this.debugGraphic; + + graphics.clear(); + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.willDrawDebug()) + { + body.drawDebug(graphics); + } + } + + bodies = staticBodies.entries; + len = bodies.length; + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.willDrawDebug()) + { + body.drawDebug(graphics); + } + } + } + + if (pending.size > 0) + { + var dynamicTree = this.tree; + var staticTree = this.staticTree; + + bodies = pending.entries; + len = bodies.length; + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.physicsType === CONST.DYNAMIC_BODY) + { + dynamicTree.remove(body); + dynamic.delete(body); + } + else if (body.physicsType === CONST.STATIC_BODY) + { + staticTree.remove(body); + staticBodies.delete(body); + } + + body.world = undefined; + body.gameObject = undefined; + } + + pending.clear(); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#updateMotion + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - [description] + */ + updateMotion: function (body) + { + if (body.allowRotation) + { + var velocityDelta = this.computeVelocity(0, body, body.angularVelocity, body.angularAcceleration, body.angularDrag, body.maxAngular) - body.angularVelocity; + + body.angularVelocity += velocityDelta; + body.rotation += (body.angularVelocity * this.delta); + } + + body.velocity.x = this.computeVelocity(1, body, body.velocity.x, body.acceleration.x, body.drag.x, body.maxVelocity.x); + body.velocity.y = this.computeVelocity(2, body, body.velocity.y, body.acceleration.y, body.drag.y, body.maxVelocity.y); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#computeVelocity + * @since 3.0.0 + * + * @param {integer} axis - [description] + * @param {Phaser.Physics.Arcade.Body} body - [description] + * @param {number} velocity - [description] + * @param {number} acceleration - [description] + * @param {number} drag - [description] + * @param {number} max - [description] + * + * @return {number} [description] + */ + computeVelocity: function (axis, body, velocity, acceleration, drag, max) + { + if (max === undefined) { max = 10000; } + + if (axis === 1 && body.allowGravity) + { + velocity += (this.gravity.x + body.gravity.x) * this.delta; + } + else if (axis === 2 && body.allowGravity) + { + velocity += (this.gravity.y + body.gravity.y) * this.delta; + } + + if (acceleration) + { + velocity += acceleration * this.delta; + } + else if (drag && body.allowDrag) + { + drag *= this.delta; + + if (velocity - drag > 0) + { + velocity -= drag; + } + else if (velocity + drag < 0) + { + velocity += drag; + } + else + { + velocity = 0; + } + } + + if (velocity > max) + { + velocity = max; + } + else if (velocity < -max) + { + velocity = -max; + } + + return velocity; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#separate + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {ArcadePhysicsCallback} [processCallback] - [description] + * @param {*} [callbackContext] - [description] + * @param {boolean} [overlapOnly] - [description] + * + * @return {boolean} [description] + */ + separate: function (body1, body2, processCallback, callbackContext, overlapOnly) + { + if ( + !body1.enable || + !body2.enable || + body1.checkCollision.none || + body2.checkCollision.none || + !this.intersects(body1, body2)) + { + return false; + } + + // They overlap. Is there a custom process callback? If it returns true then we can carry on, otherwise we should abort. + if (processCallback && processCallback.call(callbackContext, body1.gameObject, body2.gameObject) === false) + { + return false; + } + + // Circle vs. Circle quick bail out + if (body1.isCircle && body2.isCircle) + { + return this.separateCircle(body1, body2, overlapOnly); + } + + // We define the behavior of bodies in a collision circle and rectangle + // If a collision occurs in the corner points of the rectangle, the body behave like circles + + // Either body1 or body2 is a circle + if (body1.isCircle !== body2.isCircle) + { + var bodyRect = (body1.isCircle) ? body2 : body1; + var bodyCircle = (body1.isCircle) ? body1 : body2; + + var rect = { + x: bodyRect.x, + y: bodyRect.y, + right: bodyRect.right, + bottom: bodyRect.bottom + }; + + var circle = bodyCircle.center; + + if (circle.y < rect.y || circle.y > rect.bottom) + { + if (circle.x < rect.x || circle.x > rect.right) + { + return this.separateCircle(body1, body2, overlapOnly); + } + } + } + + var resultX = false; + var resultY = false; + + // Do we separate on x or y first? + if (this.forceX || Math.abs(this.gravity.y + body1.gravity.y) < Math.abs(this.gravity.x + body1.gravity.x)) + { + resultX = SeparateX(body1, body2, overlapOnly, this.OVERLAP_BIAS); + + // Are they still intersecting? Let's do the other axis then + if (this.intersects(body1, body2)) + { + resultY = SeparateY(body1, body2, overlapOnly, this.OVERLAP_BIAS); + } + } + else + { + resultY = SeparateY(body1, body2, overlapOnly, this.OVERLAP_BIAS); + + // Are they still intersecting? Let's do the other axis then + if (this.intersects(body1, body2)) + { + resultX = SeparateX(body1, body2, overlapOnly, this.OVERLAP_BIAS); + } + } + + var result = (resultX || resultY); + + if (result) + { + if (overlapOnly && (body1.onOverlap || body2.onOverlap)) + { + this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2); + } + else if (body1.onCollide || body2.onCollide) + { + this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); + } + } + + return result; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#separateCircle + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {boolean} overlapOnly - [description] + * @param {number} bias - [description] + * + * @return {boolean} [description] + */ + separateCircle: function (body1, body2, overlapOnly, bias) + { + // Set the bounding box overlap values into the bodies themselves (hence we don't use the return values here) + GetOverlapX(body1, body2, false, bias); + GetOverlapY(body1, body2, false, bias); + + var dx = body2.center.x - body1.center.x; + var dy = body2.center.y - body1.center.y; + + var angleCollision = Math.atan2(dy, dx); + + var overlap = 0; + + if (body1.isCircle !== body2.isCircle) + { + var rect = { + x: (body2.isCircle) ? body1.position.x : body2.position.x, + y: (body2.isCircle) ? body1.position.y : body2.position.y, + right: (body2.isCircle) ? body1.right : body2.right, + bottom: (body2.isCircle) ? body1.bottom : body2.bottom + }; + + var circle = { + x: (body1.isCircle) ? body1.center.x : body2.center.x, + y: (body1.isCircle) ? body1.center.y : body2.center.y, + radius: (body1.isCircle) ? body1.halfWidth : body2.halfWidth + }; + + if (circle.y < rect.y) + { + if (circle.x < rect.x) + { + overlap = DistanceBetween(circle.x, circle.y, rect.x, rect.y) - circle.radius; + } + else if (circle.x > rect.right) + { + overlap = DistanceBetween(circle.x, circle.y, rect.right, rect.y) - circle.radius; + } + } + else if (circle.y > rect.bottom) + { + if (circle.x < rect.x) + { + overlap = DistanceBetween(circle.x, circle.y, rect.x, rect.bottom) - circle.radius; + } + else if (circle.x > rect.right) + { + overlap = DistanceBetween(circle.x, circle.y, rect.right, rect.bottom) - circle.radius; + } + } + + overlap *= -1; + } + else + { + overlap = (body1.halfWidth + body2.halfWidth) - DistanceBetween(body1.center.x, body1.center.y, body2.center.x, body2.center.y); + } + + // Can't separate two immovable bodies, or a body with its own custom separation logic + if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateX || body2.customSeparateX) + { + if (overlap !== 0 && (body1.onOverlap || body2.onOverlap)) + { + this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2); + } + + // return true if there was some overlap, otherwise false + return (overlap !== 0); + } + + // Transform the velocity vector to the coordinate system oriented along the direction of impact. + // This is done to eliminate the vertical component of the velocity + + var b1vx = body1.velocity.x; + var b1vy = body1.velocity.y; + var b1mass = body1.mass; + + var b2vx = body2.velocity.x; + var b2vy = body2.velocity.y; + var b2mass = body2.mass; + + var v1 = { + x: b1vx * Math.cos(angleCollision) + b1vy * Math.sin(angleCollision), + y: b1vx * Math.sin(angleCollision) - b1vy * Math.cos(angleCollision) + }; + + var v2 = { + x: b2vx * Math.cos(angleCollision) + b2vy * Math.sin(angleCollision), + y: b2vx * Math.sin(angleCollision) - b2vy * Math.cos(angleCollision) + }; + + // We expect the new velocity after impact + var tempVel1 = ((b1mass - b2mass) * v1.x + 2 * b2mass * v2.x) / (b1mass + b2mass); + var tempVel2 = (2 * b1mass * v1.x + (b2mass - b1mass) * v2.x) / (b1mass + b2mass); + + // We convert the vector to the original coordinate system and multiplied by factor of rebound + if (!body1.immovable) + { + body1.velocity.x = (tempVel1 * Math.cos(angleCollision) - v1.y * Math.sin(angleCollision)) * body1.bounce.x; + body1.velocity.y = (v1.y * Math.cos(angleCollision) + tempVel1 * Math.sin(angleCollision)) * body1.bounce.y; + + // Reset local var + b1vx = body1.velocity.x; + b1vy = body1.velocity.y; + } + + if (!body2.immovable) + { + body2.velocity.x = (tempVel2 * Math.cos(angleCollision) - v2.y * Math.sin(angleCollision)) * body2.bounce.x; + body2.velocity.y = (v2.y * Math.cos(angleCollision) + tempVel2 * Math.sin(angleCollision)) * body2.bounce.y; + + // Reset local var + b2vx = body2.velocity.x; + b2vy = body2.velocity.y; + } + + // When the collision angle is almost perpendicular to the total initial velocity vector + // (collision on a tangent) vector direction can be determined incorrectly. + // This code fixes the problem + + if (Math.abs(angleCollision) < Math.PI / 2) + { + if ((b1vx > 0) && !body1.immovable && (b2vx > b1vx)) + { + body1.velocity.x *= -1; + } + else if ((b2vx < 0) && !body2.immovable && (b1vx < b2vx)) + { + body2.velocity.x *= -1; + } + else if ((b1vy > 0) && !body1.immovable && (b2vy > b1vy)) + { + body1.velocity.y *= -1; + } + else if ((b2vy < 0) && !body2.immovable && (b1vy < b2vy)) + { + body2.velocity.y *= -1; + } + } + else if (Math.abs(angleCollision) > Math.PI / 2) + { + if ((b1vx < 0) && !body1.immovable && (b2vx < b1vx)) + { + body1.velocity.x *= -1; + } + else if ((b2vx > 0) && !body2.immovable && (b1vx > b2vx)) + { + body2.velocity.x *= -1; + } + else if ((b1vy < 0) && !body1.immovable && (b2vy < b1vy)) + { + body1.velocity.y *= -1; + } + else if ((b2vy > 0) && !body2.immovable && (b1vx > b2vy)) + { + body2.velocity.y *= -1; + } + } + + if (!body1.immovable) + { + body1.x += (body1.velocity.x * this.delta) - overlap * Math.cos(angleCollision); + body1.y += (body1.velocity.y * this.delta) - overlap * Math.sin(angleCollision); + } + + if (!body2.immovable) + { + body2.x += (body2.velocity.x * this.delta) + overlap * Math.cos(angleCollision); + body2.y += (body2.velocity.y * this.delta) + overlap * Math.sin(angleCollision); + } + + if (body1.onCollide || body2.onCollide) + { + this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); + } + + return true; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#intersects + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * + * @return {boolean} [description] + */ + intersects: function (body1, body2) + { + if (body1 === body2) + { + return false; + } + + if (body1.isCircle) + { + if (body2.isCircle) + { + // Circle vs. Circle + return DistanceBetween(body1.center.x, body1.center.y, body2.center.x, body2.center.y) <= (body1.halfWidth + body2.halfWidth); + } + else + { + // Circle vs. Rect + return this.circleBodyIntersects(body1, body2); + } + } + else if (body2.isCircle) + { + // Rect vs. Circle + return this.circleBodyIntersects(body2, body1); + } + else + { + // Rect vs. Rect + if (body1.right <= body2.position.x) + { + return false; + } + + if (body1.bottom <= body2.position.y) + { + return false; + } + + if (body1.position.x >= body2.right) + { + return false; + } + + if (body1.position.y >= body2.bottom) + { + return false; + } + + return true; + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#circleBodyIntersects + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} circle - [description] + * @param {Phaser.Physics.Arcade.Body} body - [description] + * + * @return {boolean} [description] + */ + circleBodyIntersects: function (circle, body) + { + var x = Clamp(circle.center.x, body.left, body.right); + var y = Clamp(circle.center.y, body.top, body.bottom); + + var dx = (circle.center.x - x) * (circle.center.x - x); + var dy = (circle.center.y - y) * (circle.center.y - y); + + return (dx + dy) <= (circle.halfWidth * circle.halfWidth); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#overlap + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} object1 - [description] + * @param {Phaser.GameObjects.GameObject} object2 - [description] + * @param {ArcadePhysicsCallback} [overlapCallback] - [description] + * @param {ArcadePhysicsCallback} [processCallback] - [description] + * @param {*} [callbackContext] - [description] + * + * @return {boolean} [description] + */ + overlap: function (object1, object2, overlapCallback, processCallback, callbackContext) + { + if (overlapCallback === undefined) { overlapCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = overlapCallback; } + + return this.collideObjects(object1, object2, overlapCallback, processCallback, callbackContext, true); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#collide + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} object1 - [description] + * @param {Phaser.GameObjects.GameObject} object2 - [description] + * @param {ArcadePhysicsCallback} [collideCallback] - [description] + * @param {ArcadePhysicsCallback} [processCallback] - [description] + * @param {*} [callbackContext] - [description] + * + * @return {boolean} [description] + */ + collide: function (object1, object2, collideCallback, processCallback, callbackContext) + { + if (collideCallback === undefined) { collideCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = collideCallback; } + + return this.collideObjects(object1, object2, collideCallback, processCallback, callbackContext, false); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#collideObjects + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} object1 - [description] + * @param {Phaser.GameObjects.GameObject} object2 - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - [description] + * + * @return {boolean} [description] + */ + collideObjects: function (object1, object2, collideCallback, processCallback, callbackContext, overlapOnly) + { + var i; + object1 = object1.isParent && typeof(object1.physicsType) === 'undefined' ? object1.children.entries : object1; + object2 = object2.isParent && typeof(object2.physicsType) === 'undefined' ? object2.children.entries : object2; + var object1isArray = Array.isArray(object1); + var object2isArray = Array.isArray(object2); + + this._total = 0; + + if (!object1isArray && !object2isArray) + { + // Neither of them are arrays - do this first as it's the most common use-case + this.collideHandler(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (!object1isArray && object2isArray) + { + // Object 2 is an Array + for (i = 0; i < object2.length; i++) + { + this.collideHandler(object1, object2[i], collideCallback, processCallback, callbackContext, overlapOnly); + } + } + else if (object1isArray && !object2isArray) + { + // Object 1 is an Array + for (i = 0; i < object1.length; i++) + { + this.collideHandler(object1[i], object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + } + else + { + // They're both arrays + for (i = 0; i < object1.length; i++) + { + for (var j = 0; j < object2.length; j++) + { + this.collideHandler(object1[i], object2[j], collideCallback, processCallback, callbackContext, overlapOnly); + } + } + } + + return (this._total > 0); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#collideHandler + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} object1 - [description] + * @param {Phaser.GameObjects.GameObject} object2 - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - [description] + * + * @return {boolean} [description] + */ + collideHandler: function (object1, object2, collideCallback, processCallback, callbackContext, overlapOnly) + { + // Collide Group with Self + // Only collide valid objects + if (object2 === undefined && object1.isParent) + { + return this.collideGroupVsGroup(object1, object1, collideCallback, processCallback, callbackContext, overlapOnly); + } + + // If neither of the objects are set then bail out + if (!object1 || !object2) + { + return false; + } + + // A Body + if (object1.body) + { + if (object2.body) + { + return this.collideSpriteVsSprite(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isParent) + { + return this.collideSpriteVsGroup(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isTilemap) + { + return this.collideSpriteVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + } + + // GROUPS + else if (object1.isParent) + { + if (object2.body) + { + return this.collideSpriteVsGroup(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isParent) + { + return this.collideGroupVsGroup(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isTilemap) + { + return this.collideGroupVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + } + + // TILEMAP LAYERS + else if (object1.isTilemap) + { + if (object2.body) + { + return this.collideSpriteVsTilemapLayer(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isParent) + { + return this.collideGroupVsTilemapLayer(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); + } + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#collideSpriteVsSprite + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} sprite1 - [description] + * @param {Phaser.GameObjects.GameObject} sprite2 - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - [description] + * + * @return {boolean} [description] + */ + collideSpriteVsSprite: function (sprite1, sprite2, collideCallback, processCallback, callbackContext, overlapOnly) + { + if (!sprite1.body || !sprite2.body) + { + return false; + } + + if (this.separate(sprite1.body, sprite2.body, processCallback, callbackContext, overlapOnly)) + { + if (collideCallback) + { + collideCallback.call(callbackContext, sprite1, sprite2); + } + + this._total++; + } + + return true; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#collideSpriteVsGroup + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} sprite - [description] + * @param {Phaser.GameObjects.Group} group - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - [description] + * + * @return {boolean} [description] + */ + collideSpriteVsGroup: function (sprite, group, collideCallback, processCallback, callbackContext, overlapOnly) + { + var bodyA = sprite.body; + + if (group.length === 0 || !bodyA) + { + return; + } + + // Does sprite collide with anything? + + var minMax = this.treeMinMax; + + minMax.minX = bodyA.left; + minMax.minY = bodyA.top; + minMax.maxX = bodyA.right; + minMax.maxY = bodyA.bottom; + + var results = (group.physicsType === CONST.DYNAMIC_BODY) ? this.tree.search(minMax) : this.staticTree.search(minMax); + + if (results.length === 0) + { + return; + } + + var children = group.getChildren(); + + for (var i = 0; i < children.length; i++) + { + var bodyB = children[i].body; + + if (!bodyB || bodyA === bodyB || results.indexOf(bodyB) === -1) + { + continue; + } + + if (this.separate(bodyA, bodyB, processCallback, callbackContext, overlapOnly)) + { + if (collideCallback) + { + collideCallback.call(callbackContext, bodyA.gameObject, bodyB.gameObject); + } + + this._total++; + } + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#collideGroupVsTilemapLayer + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Group} group - [description] + * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - [description] + * + * @return {boolean} [description] + */ + collideGroupVsTilemapLayer: function (group, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) + { + var children = group.getChildren(); + + if (children.length === 0) + { + return false; + } + + var didCollide = false; + + for (var i = 0; i < children.length; i++) + { + if (children[i].body) + { + if (this.collideSpriteVsTilemapLayer(children[i], tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly)) + { + didCollide = true; + } + } + } + + return didCollide; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#collideSpriteVsTilemapLayer + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} sprite - [description] + * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - [description] + * + * @return {boolean} [description] + */ + collideSpriteVsTilemapLayer: function (sprite, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) + { + var body = sprite.body; + + if (!body.enable) + { + return false; + } + + var x = body.position.x; + var y = body.position.y; + var w = body.width; + var h = body.height; + + // TODO: this logic should be encapsulated within the Tilemap API at some point. + // If the maps base tile size differs from the layer's tile size, we need to adjust the + // selection area by the difference between the two. + var layerData = tilemapLayer.layer; + + if (layerData.tileWidth > layerData.baseTileWidth) + { + // The x origin of a tile is the left side, so x and width need to be adjusted. + var xDiff = (layerData.tileWidth - layerData.baseTileWidth) * tilemapLayer.scaleX; + x -= xDiff; + w += xDiff; + } + + if (layerData.tileHeight > layerData.baseTileHeight) + { + // The y origin of a tile is the bottom side, so just the height needs to be adjusted. + var yDiff = (layerData.tileHeight - layerData.baseTileHeight) * tilemapLayer.scaleY; + h += yDiff; + } + + var mapData = tilemapLayer.getTilesWithinWorldXY(x, y, w, h); + + if (mapData.length === 0) + { + return false; + } + + var tile; + var tileWorldRect = { left: 0, right: 0, top: 0, bottom: 0 }; + + for (var i = 0; i < mapData.length; i++) + { + tile = mapData[i]; + tileWorldRect.left = tilemapLayer.tileToWorldX(tile.x); + tileWorldRect.top = tilemapLayer.tileToWorldY(tile.y); + + // If the map's base tile size differs from the layer's tile size, only the top of the rect + // needs to be adjusted since it's origin is (0, 1). + if (tile.baseHeight !== tile.height) + { + tileWorldRect.top -= (tile.height - tile.baseHeight) * tilemapLayer.scaleY; + } + + tileWorldRect.right = tileWorldRect.left + tile.width * tilemapLayer.scaleX; + tileWorldRect.bottom = tileWorldRect.top + tile.height * tilemapLayer.scaleY; + + if (TileIntersectsBody(tileWorldRect, body) + && (!processCallback || processCallback.call(callbackContext, sprite, tile)) + && ProcessTileCallbacks(tile, sprite) + && (overlapOnly || SeparateTile(i, body, tile, tileWorldRect, tilemapLayer, this.TILE_BIAS))) + { + this._total++; + + if (collideCallback) + { + collideCallback.call(callbackContext, sprite, tile); + } + + if (overlapOnly && body.onOverlap) + { + sprite.emit('overlap', body.gameObject, tile, body, null); + } + else if (body.onCollide) + { + sprite.emit('collide', body.gameObject, tile, body, null); + } + } + } + }, + + /** + * TODO! + * + * @method Phaser.Physics.Arcade.World#collideGroupVsGroup + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Group} group1 - [description] + * @param {Phaser.GameObjects.Group} group2 - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - [description] + * + * @return {boolean} [description] + */ + collideGroupVsGroup: function (group1, group2, collideCallback, processCallback, callbackContext, overlapOnly) + { + if (group1.length === 0 || group2.length === 0) + { + return; + } + + var children = group1.getChildren(); + + for (var i = 0; i < children.length; i++) + { + this.collideSpriteVsGroup(children[i], group2, collideCallback, processCallback, callbackContext, overlapOnly); + } + }, + + /** + * Wrap an object's coordinates (or several objects' coordinates) within {@link Phaser.Physics.Arcade.World#bounds}. + * + * If the object is outside any boundary edge (left, top, right, bottom), it will be moved to the same offset from the opposite edge (the interior). + * + * @method Phaser.Physics.Arcade.World#wrap + * @since 3.3.0 + * + * @param {*} object - A Game Object, a Group, an object with `x` and `y` coordinates, or an array of such objects. + * @param {number} [padding=0] - An amount added to each boundary edge during the operation. + */ + wrap: function (object, padding) + { + if (object.body) + { + this.wrapObject(object, padding); + } + else if (object.getChildren) + { + this.wrapArray(object.getChildren(), padding); + } + else if (Array.isArray(object)) + { + this.wrapArray(object, padding); + } + else + { + this.wrapObject(object, padding); + } + }, + + + /** + * Wrap each object's coordinates within {@link Phaser.Physics.Arcade.World#bounds}. + * + * @method Phaser.Physics.Arcade.World#wrapArray + * @since 3.3.0 + * + * @param {Array.<*>} arr + * @param {number} [padding=0] - An amount added to the boundary. + */ + wrapArray: function (arr, padding) + { + if (arr.length === 0) + { + return; + } + + for (var i = 0, len = arr.length; i < len; i++) + { + this.wrapObject(arr[i], padding); + } + }, + + /** + * Wrap an object's coordinates within {@link Phaser.Physics.Arcade.World#bounds}. + * + * @method Phaser.Physics.Arcade.World#wrapObject + * @since 3.3.0 + * + * @param {*} object - A Game Object, a Physics Body, or any object with `x` and `y` coordinates + * @param {number} [padding=0] - An amount added to the boundary. + */ + wrapObject: function (object, padding) + { + if (padding === undefined) + { + padding = 0; + } + + object.x = Wrap(object.x, this.bounds.left - padding, this.bounds.right + padding); + object.y = Wrap(object.y, this.bounds.top - padding, this.bounds.bottom + padding); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.removeAllListeners(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.tree.clear(); + this.staticTree.clear(); + this.bodies.clear(); + this.staticBodies.clear(); + this.colliders.destroy(); + + this.removeAllListeners(); + } + +}); + +module.exports = World; + + +/***/ }), +/* 211 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Phaser.Physics.Arcade.StaticGroup + +var ArcadeSprite = __webpack_require__(93); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(47); +var Group = __webpack_require__(73); + +/** + * @classdesc + * [description] + * + * @class StaticGroup + * @extends Phaser.GameObjects.Group + * @memberOf Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - [description] + * @param {Phaser.Scene} scene - [description] + * @param {array} children - [description] + * @param {GroupConfig} config - [description] + */ +var StaticPhysicsGroup = new Class({ + + Extends: Group, + + initialize: + + function StaticPhysicsGroup (world, scene, children, config) + { + if (config === undefined && !Array.isArray(children) && typeof children === 'object') + { + config = children; + children = null; + } + else if (config === undefined) + { + config = {}; + } + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticGroup#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + config.createCallback = this.createCallback; + config.removeCallback = this.removeCallback; + config.createMultipleCallback = this.createMultipleCallback; + + config.classType = ArcadeSprite; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticGroup#physicsType + * @type {integer} + * @since 3.0.0 + */ + this.physicsType = CONST.STATIC_BODY; + + Group.call(this, scene, children, config); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticGroup#createCallback + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - [description] + */ + createCallback: function (child) + { + if (!child.body) + { + this.world.enableBody(child, CONST.STATIC_BODY); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticGroup#removeCallback + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - [description] + */ + removeCallback: function (child) + { + if (child.body) + { + this.world.disableBody(child); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticGroup#createMultipleCallback + * @since 3.0.0 + * + * @param {object} entries - [description] + */ + createMultipleCallback: function () + { + this.refresh(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticGroup#refresh + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.StaticGroup} [description] + */ + refresh: function () + { + var children = this.children.entries; + + for (var i = 0; i < children.length; i++) + { + children[i].body.reset(); + } + + return this; + } + +}); + +module.exports = StaticPhysicsGroup; + + +/***/ }), +/* 212 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArcadeSprite = __webpack_require__(93); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(47); +var GetFastValue = __webpack_require__(2); +var Group = __webpack_require__(73); + +/** + * @typedef {object} PhysicsGroupConfig + * @extends GroupConfig + * + * @property {[type]} [collideWorldBounds=false] - [description] + * @property {number} [accelerationX=0] - [description] + * @property {number} [accelerationY=0] - [description] + * @property {number} [bounceX=0] - [description] + * @property {number} [bounceY=0] - [description] + * @property {number} [dragX=0] - [description] + * @property {number} [dragY=0] - [description] + * @property {number} [gravityX=0] - [description] + * @property {number} [gravityY=0] - [description] + * @property {number} [frictionX=0] - [description] + * @property {number} [frictionY=0] - [description] + * @property {number} [velocityX=0] - [description] + * @property {number} [velocityY=0] - [description] + * @property {number} [angularVelocity=0] - [description] + * @property {number} [angularAcceleration=0] - [description] + * @property {number} [angularDrag=0] - [description] + * @property {number} [mass=0] - [description] + * @property {boolean} [immovable=false] - [description] + */ + +/** + * @typedef {object} PhysicsGroupDefaults + * + * @property {[type]} setCollideWorldBounds - [description] + * @property {number} setAccelerationX - [description] + * @property {number} setAccelerationY - [description] + * @property {number} setBounceX - [description] + * @property {number} setBounceY - [description] + * @property {number} setDragX - [description] + * @property {number} setDragY - [description] + * @property {number} setGravityX - [description] + * @property {number} setGravityY - [description] + * @property {number} setFrictionX - [description] + * @property {number} setFrictionY - [description] + * @property {number} setVelocityX - [description] + * @property {number} setVelocityY - [description] + * @property {number} setAngularVelocity - [description] + * @property {number} setAngularAcceleration - [description] + * @property {number} setAngularDrag - [description] + * @property {number} setMass - [description] + * @property {boolean} setImmovable - [description] + */ + +/** + * @classdesc + * An Arcade Physics Group object. + * + * All Game Objects created by this Group will automatically be dynamic Arcade Physics objects. + * + * @class Group + * @extends Phaser.GameObjects.Group + * @memberOf Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - [description] + * @param {Phaser.Scene} scene - [description] + * @param {array} children - [description] + * @param {PhysicsGroupConfig} [config] - [description] + */ +var PhysicsGroup = new Class({ + + Extends: Group, + + initialize: + + function PhysicsGroup (world, scene, children, config) + { + if (config === undefined && !Array.isArray(children) && typeof children === 'object') + { + config = children; + children = null; + } + else if (config === undefined) + { + config = {}; + } + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Group#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + config.createCallback = this.createCallback; + config.removeCallback = this.removeCallback; + + config.classType = GetFastValue(config, 'classType', ArcadeSprite); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Group#physicsType + * @type {integer} + * @since 3.0.0 + */ + this.physicsType = CONST.DYNAMIC_BODY; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Group#defaults + * @type {PhysicsGroupDefaults} + * @since 3.0.0 + */ + this.defaults = { + setCollideWorldBounds: GetFastValue(config, 'collideWorldBounds', false), + setAccelerationX: GetFastValue(config, 'accelerationX', 0), + setAccelerationY: GetFastValue(config, 'accelerationY', 0), + setBounceX: GetFastValue(config, 'bounceX', 0), + setBounceY: GetFastValue(config, 'bounceY', 0), + setDragX: GetFastValue(config, 'dragX', 0), + setDragY: GetFastValue(config, 'dragY', 0), + setGravityX: GetFastValue(config, 'gravityX', 0), + setGravityY: GetFastValue(config, 'gravityY', 0), + setFrictionX: GetFastValue(config, 'frictionX', 0), + setFrictionY: GetFastValue(config, 'frictionY', 0), + setVelocityX: GetFastValue(config, 'velocityX', 0), + setVelocityY: GetFastValue(config, 'velocityY', 0), + setAngularVelocity: GetFastValue(config, 'angularVelocity', 0), + setAngularAcceleration: GetFastValue(config, 'angularAcceleration', 0), + setAngularDrag: GetFastValue(config, 'angularDrag', 0), + setMass: GetFastValue(config, 'mass', 1), + setImmovable: GetFastValue(config, 'immovable', false) + }; + + Group.call(this, scene, children, config); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Group#createCallback + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - [description] + */ + createCallback: function (child) + { + if (!child.body) + { + this.world.enableBody(child, CONST.DYNAMIC_BODY); + } + + var body = child.body; + + for (var key in this.defaults) + { + body[key](this.defaults[key]); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Group#removeCallback + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - [description] + */ + removeCallback: function (child) + { + if (child.body) + { + this.world.disableBody(child); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Group#setVelocity + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} step - [description] + * + * @return {Phaser.Physics.Arcade.Group} This Physics Group object. + */ + setVelocity: function (x, y, step) + { + if (step === undefined) { step = 0; } + + var items = this.getChildren(); + + for (var i = 0; i < items.length; i++) + { + items[i].body.velocity.set(x + (i * step), y + (i * step)); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Group#setVelocityX + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} step - [description] + * + * @return {Phaser.Physics.Arcade.Group} This Physics Group object. + */ + setVelocityX: function (value, step) + { + if (step === undefined) { step = 0; } + + var items = this.getChildren(); + + for (var i = 0; i < items.length; i++) + { + items[i].body.velocity.x = value + (i * step); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Group#setVelocityY + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} step - [description] + * + * @return {Phaser.Physics.Arcade.Group} This Physics Group object. + */ + setVelocityY: function (value, step) + { + if (step === undefined) { step = 0; } + + var items = this.getChildren(); + + for (var i = 0; i < items.length; i++) + { + items[i].body.velocity.y = value + (i * step); + } + + return this; + } + +}); + +module.exports = PhysicsGroup; + + +/***/ }), +/* 213 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Physics.Arcade.Body.Components + */ + +module.exports = { + + Acceleration: __webpack_require__(489), + Angular: __webpack_require__(488), + Bounce: __webpack_require__(487), + Debug: __webpack_require__(486), + Drag: __webpack_require__(485), + Enable: __webpack_require__(484), + Friction: __webpack_require__(483), + Gravity: __webpack_require__(482), + Immovable: __webpack_require__(481), + Mass: __webpack_require__(480), + Size: __webpack_require__(479), + Velocity: __webpack_require__(478) + +}; + + +/***/ }), +/* 214 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -47649,190 +49328,3390 @@ module.exports = Pointer; */ var Class = __webpack_require__(0); +var Components = __webpack_require__(213); +var Image = __webpack_require__(72); -// https://developer.mozilla.org/en-US/docs/Web/API/Touch_events -// https://patrickhlauke.github.io/touch/tests/results/ -// https://www.html5rocks.com/en/mobile/touch/ +/** + * @classdesc + * An Arcade Physics Image Game Object. + * + * An Image is a light-weight Game Object useful for the display of static images in your game, + * such as logos, backgrounds, scenery or other non-animated elements. Images can have input + * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an + * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. + * + * @class Image + * @extends Phaser.GameObjects.Image + * @memberOf Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @extends Phaser.Physics.Arcade.Components.Acceleration + * @extends Phaser.Physics.Arcade.Components.Angular + * @extends Phaser.Physics.Arcade.Components.Bounce + * @extends Phaser.Physics.Arcade.Components.Debug + * @extends Phaser.Physics.Arcade.Components.Drag + * @extends Phaser.Physics.Arcade.Components.Enable + * @extends Phaser.Physics.Arcade.Components.Friction + * @extends Phaser.Physics.Arcade.Components.Gravity + * @extends Phaser.Physics.Arcade.Components.Immovable + * @extends Phaser.Physics.Arcade.Components.Mass + * @extends Phaser.Physics.Arcade.Components.Size + * @extends Phaser.Physics.Arcade.Components.Velocity + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var ArcadeImage = new Class({ + + Extends: Image, + + Mixins: [ + Components.Acceleration, + Components.Angular, + Components.Bounce, + Components.Debug, + Components.Drag, + Components.Enable, + Components.Friction, + Components.Gravity, + Components.Immovable, + Components.Mass, + Components.Size, + Components.Velocity + ], + + initialize: + + function ArcadeImage (scene, x, y, texture, frame) + { + Image.call(this, scene, x, y, texture, frame); + } + +}); + +module.exports = ArcadeImage; + + +/***/ }), +/* 215 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArcadeImage = __webpack_require__(214); +var ArcadeSprite = __webpack_require__(93); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(47); +var PhysicsGroup = __webpack_require__(212); +var StaticPhysicsGroup = __webpack_require__(211); + +/** + * @classdesc + * The Arcade Physics Factory allows you to easily create Arcade Physics enabled Game Objects. + * Objects that are created by this Factory are automatically added to the physics world. + * + * @class Factory + * @memberOf Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - The Arcade Physics World instance. + */ +var Factory = new Class({ + + initialize: + + function Factory (world) + { + /** + * A reference to the Arcade Physics World. + * + * @name Phaser.Physics.Arcade.Factory#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * A reference to the Scene this Arcade Physics instance belongs to. + * + * @name Phaser.Physics.Arcade.Factory#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = world.scene; + + /** + * A reference to the Scene.Systems this Arcade Physics instance belongs to. + * + * @name Phaser.Physics.Arcade.Factory#sys + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.sys = world.scene.sys; + }, + + /** + * Create a new Arcade Physics Collider object. + * + * @method Phaser.Physics.Arcade.Factory#collider + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for collision. + * @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for collision. + * @param {ArcadePhysicsCallback} collideCallback - The callback to invoke when the two objects collide. + * @param {ArcadePhysicsCallback} processCallback - The callback to invoke when the two objects collide. Must return a boolean. + * @param {*} callbackContext - The scope in which to call the callbacks. + * + * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. + */ + collider: function (object1, object2, collideCallback, processCallback, callbackContext) + { + return this.world.addCollider(object1, object2, collideCallback, processCallback, callbackContext); + }, + + /** + * Create a new Arcade Physics Collider Overlap object. + * + * @method Phaser.Physics.Arcade.Factory#overlap + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for overlap. + * @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for overlap. + * @param {ArcadePhysicsCallback} collideCallback - The callback to invoke when the two objects collide. + * @param {ArcadePhysicsCallback} processCallback - The callback to invoke when the two objects collide. Must return a boolean. + * @param {*} callbackContext - The scope in which to call the callbacks. + * + * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. + */ + overlap: function (object1, object2, collideCallback, processCallback, callbackContext) + { + return this.world.addOverlap(object1, object2, collideCallback, processCallback, callbackContext); + }, + + /** + * Adds an Arcade Physics Body to the given Game Object. + * + * @method Phaser.Physics.Arcade.Factory#existing + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * @param {boolean} [isStatic=false] - Set to true to create a Static body, otherwise it will create a Dynamic body. + * + * @return {Phaser.GameObjects.GameObject} The Game Object. + */ + existing: function (gameObject, isStatic) + { + var type = (isStatic) ? CONST.STATIC_BODY : CONST.DYNAMIC_BODY; + + this.world.enableBody(gameObject, type); + + return gameObject; + }, + + /** + * Creates a new Arcade Image object with a Static body. + * + * @method Phaser.Physics.Arcade.Factory#staticImage + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Arcade.Image} The Image object that was created. + */ + staticImage: function (x, y, key, frame) + { + var image = new ArcadeImage(this.scene, x, y, key, frame); + + this.sys.displayList.add(image); + + this.world.enableBody(image, CONST.STATIC_BODY); + + return image; + }, + + /** + * Creates a new Arcade Image object with a Dynamic body. + * + * @method Phaser.Physics.Arcade.Factory#image + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Arcade.Image} The Image object that was created. + */ + image: function (x, y, key, frame) + { + var image = new ArcadeImage(this.scene, x, y, key, frame); + + this.sys.displayList.add(image); + + this.world.enableBody(image, CONST.DYNAMIC_BODY); + + return image; + }, + + /** + * Creates a new Arcade Sprite object with a Static body. + * + * @method Phaser.Physics.Arcade.Factory#staticSprite + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Arcade.Sprite} The Sprite object that was created. + */ + staticSprite: function (x, y, key, frame) + { + var sprite = new ArcadeSprite(this.scene, x, y, key, frame); + + this.sys.displayList.add(sprite); + this.sys.updateList.add(sprite); + + this.world.enableBody(sprite, CONST.STATIC_BODY); + + return sprite; + }, + + /** + * Creates a new Arcade Sprite object with a Dynamic body. + * + * @method Phaser.Physics.Arcade.Factory#sprite + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Arcade.Sprite} The Sprite object that was created. + */ + sprite: function (x, y, key, frame) + { + var sprite = new ArcadeSprite(this.scene, x, y, key, frame); + + this.sys.displayList.add(sprite); + this.sys.updateList.add(sprite); + + this.world.enableBody(sprite, CONST.DYNAMIC_BODY); + + return sprite; + }, + + /** + * Creates a Static Physics Group object. + * All Game Objects created by this Group will automatically be static Arcade Physics objects. + * + * @method Phaser.Physics.Arcade.Factory#staticGroup + * @since 3.0.0 + * + * @param {array} [children] - [description] + * @param {GroupConfig} [config] - [description] + * + * @return {Phaser.Physics.Arcade.StaticGroup} The Static Group object that was created. + */ + staticGroup: function (children, config) + { + return this.sys.updateList.add(new StaticPhysicsGroup(this.world, this.world.scene, children, config)); + }, + + /** + * Creates a Physics Group object. + * All Game Objects created by this Group will automatically be dynamic Arcade Physics objects. + * + * @method Phaser.Physics.Arcade.Factory#group + * @since 3.0.0 + * + * @param {array} [children] - [description] + * @param {PhysicsGroupConfig} [config] - [description] + * + * @return {Phaser.Physics.Arcade.Group} The Group object that was created. + */ + group: function (children, config) + { + return this.sys.updateList.add(new PhysicsGroup(this.world, this.world.scene, children, config)); + } + +}); + +module.exports = Factory; + + +/***/ }), +/* 216 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.RoundAwayFromZero + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {number} [description] + */ +var RoundAwayFromZero = function (value) +{ + // "Opposite" of truncate. + return (value > 0) ? Math.ceil(value) : Math.floor(value); +}; + +module.exports = RoundAwayFromZero; + + +/***/ }), +/* 217 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Rotate + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point - [description] + * @param {number} angle - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Rotate = function (point, angle) +{ + var x = point.x; + var y = point.y; + + point.x = (x * Math.cos(angle)) - (y * Math.sin(angle)); + point.y = (x * Math.sin(angle)) + (y * Math.cos(angle)); + + return point; +}; + +module.exports = Rotate; + + +/***/ }), +/* 218 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Factorial + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {number} [description] + */ +var Factorial = function (value) +{ + if (value === 0) + { + return 1; + } + + var res = value; + + while (--value) + { + res *= value; + } + + return res; +}; + +module.exports = Factorial; + + +/***/ }), +/* 219 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Factorial = __webpack_require__(218); + +/** + * [description] + * + * @function Phaser.Math.Bernstein + * @since 3.0.0 + * + * @param {number} n - [description] + * @param {number} i - [description] + * + * @return {number} [description] + */ +var Bernstein = function (n, i) +{ + return Factorial(n) / Factorial(i) / Factorial(n - i); +}; + +module.exports = Bernstein; + + +/***/ }), +/* 220 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Angle.Normalize + * @since 3.0.0 + * + * @param {number} angle - [description] + * + * @return {number} [description] + */ +var Normalize = function (angle) +{ + angle = angle % (2 * Math.PI); + + if (angle >= 0) + { + return angle; + } + else + { + return angle + 2 * Math.PI; + } +}; + +module.exports = Normalize; + + +/***/ }), +/* 221 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); /** * @classdesc * [description] * - * @class TouchManager - * @memberOf Phaser.Input.Touch + * @class TextFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * - * @param {Phaser.Input.InputManager} inputManager - [description] + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {XHRSettingsObject} xhrSettings - [description] */ -var TouchManager = new Class({ +var TextFile = new Class({ + + Extends: File, initialize: - function TouchManager (inputManager) + function TextFile (key, url, path, xhrSettings) { - /** - * [description] - * - * @name Phaser.Input.Touch.TouchManager#manager - * @type {Phaser.Input.InputManager} - * @since 3.0.0 - */ - this.manager = inputManager; + var fileConfig = { + type: 'text', + extension: 'txt', + responseType: 'text', + key: key, + url: url, + path: path, + xhrSettings: xhrSettings + }; - /** - * If true the DOM events will have event.preventDefault applied to them, if false they will propagate fully. - * - * @name Phaser.Input.Touch.TouchManager#capture - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.capture = true; - - /** - * [description] - * - * @name Phaser.Input.Touch.TouchManager#enabled - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.enabled = false; - - /** - * [description] - * - * @name Phaser.Input.Touch.TouchManager#target - * @type {null} - * @since 3.0.0 - */ - this.target; - - /** - * [description] - * - * @name Phaser.Input.Touch.TouchManager#handler - * @type {function} - * @since 3.0.0 - */ - this.handler; + File.call(this, fileConfig); }, - /** - * [description] - * - * @method Phaser.Input.Touch.TouchManager#boot - * @since 3.0.0 - */ - boot: function () + onProcess: function (callback) { - var config = this.manager.config; + this.state = CONST.FILE_PROCESSING; - this.enabled = config.inputTouch; - this.target = config.inputTouchEventTarget; - this.capture = config.inputTouchCapture; + this.data = this.xhrLoader.responseText; - if (!this.target) - { - this.target = this.manager.game.canvas; - } + this.onComplete(); - if (this.enabled) - { - this.startListeners(); - } - }, - - /** - * [description] - * - * @method Phaser.Input.Touch.TouchManager#startListeners - * @since 3.0.0 - */ - startListeners: function () - { - var queue = this.manager.queue; - var target = this.target; - - var passive = { passive: true }; - var nonPassive = { passive: false }; - - var handler; - - if (this.capture) - { - handler = function (event) - { - if (event.defaultPrevented) - { - // Do nothing if event already handled - return; - } - - // console.log('touch', event); - - queue.push(event); - - event.preventDefault(); - }; - - target.addEventListener('touchstart', handler, nonPassive); - target.addEventListener('touchmove', handler, nonPassive); - target.addEventListener('touchend', handler, nonPassive); - } - else - { - handler = function (event) - { - if (event.defaultPrevented) - { - // Do nothing if event already handled - return; - } - - queue.push(event); - }; - - target.addEventListener('touchstart', handler, passive); - target.addEventListener('touchmove', handler, passive); - target.addEventListener('touchend', handler, passive); - } - - this.handler = handler; - }, - - /** - * [description] - * - * @method Phaser.Input.Touch.TouchManager#stopListeners - * @since 3.0.0 - */ - stopListeners: function () - { - var target = this.target; - - target.removeEventListener('touchstart', this.handler); - target.removeEventListener('touchmove', this.handler); - target.removeEventListener('touchend', this.handler); - }, - - /** - * [description] - * - * @method Phaser.Input.Touch.TouchManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.stopListeners(); - - this.manager = null; + callback(this); } }); -module.exports = TouchManager; +/** + * Adds a Text file to the current load queue. + * + * Note: This method will only be available if the Text File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#text + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('text', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new TextFile(key[i], url, this.path, xhrSettings)); + } + } + else + { + this.addFile(new TextFile(key, url, this.path, xhrSettings)); + } + + // For method chaining + return this; +}); + +module.exports = TextFile; + + +/***/ }), +/* 222 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Create an array representing the range of numbers (usually integers), between, and inclusive of, + * the given `start` and `end` arguments. For example: + * + * `var array = numberArray(2, 4); // array = [2, 3, 4]` + * `var array = numberArray(0, 9); // array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]` + * + * This is equivalent to `numberArrayStep(start, end, 1)`. + * + * You can optionally provide a prefix and / or suffix string. If given the array will contain + * strings, not integers. For example: + * + * `var array = numberArray(1, 4, 'Level '); // array = ["Level 1", "Level 2", "Level 3", "Level 4"]` + * `var array = numberArray(5, 7, 'HD-', '.png'); // array = ["HD-5.png", "HD-6.png", "HD-7.png"]` + * + * @function Phaser.Utils.Array.NumberArray + * @since 3.0.0 + * + * @param {number} start - The minimum value the array starts with. + * @param {number} end - The maximum value the array contains. + * @param {string} [prefix] - Optional prefix to place before the number. If provided the array will contain strings, not integers. + * @param {string} [suffix] - Optional suffix to place after the number. If provided the array will contain strings, not integers. + * + * @return {(number[]|string[])} The array of number values, or strings if a prefix or suffix was provided. + */ +var NumberArray = function (start, end, prefix, suffix) +{ + var result = []; + + for (var i = start; i <= end; i++) + { + if (prefix || suffix) + { + var key = (prefix) ? prefix + i.toString() : i.toString(); + + if (suffix) + { + key = key.concat(suffix); + } + + result.push(key); + } + else + { + result.push(i); + } + } + + return result; +}; + +module.exports = NumberArray; + + +/***/ }), +/* 223 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var ParseXML = __webpack_require__(306); + +/** + * @classdesc + * [description] + * + * @class XMLFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + */ +var XMLFile = new Class({ + + Extends: File, + + initialize: + + function XMLFile (key, url, path, xhrSettings) + { + var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); + + var fileConfig = { + type: 'xml', + extension: GetFastValue(key, 'extension', 'xml'), + responseType: 'text', + key: fileKey, + url: GetFastValue(key, 'file', url), + path: path, + xhrSettings: GetFastValue(key, 'xhr', xhrSettings) + }; + + File.call(this, fileConfig); + }, + + onProcess: function (callback) + { + this.state = CONST.FILE_PROCESSING; + + this.data = ParseXML(this.xhrLoader.responseText); + + if (this.data === null) + { + throw new Error('XMLFile: Invalid XML'); + } + + this.onComplete(); + + callback(this); + } + +}); + +/** + * Adds an XML file to the current load queue. + * + * Note: This method will only be available if the XML File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#xml + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('xml', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new XMLFile(key[i], url, this.path, xhrSettings)); + } + } + else + { + this.addFile(new XMLFile(key, url, this.path, xhrSettings)); + } + + // For method chaining + return this; +}); + +module.exports = XMLFile; + + +/***/ }), +/* 224 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var File = __webpack_require__(19); +var GetFastValue = __webpack_require__(2); +var GetURL = __webpack_require__(122); + +/** + * @classdesc + * [description] + * + * @class HTML5AudioFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {Phaser.Loader.XHRSettingsConfig} config - [description] + * @param {boolean} locked - [description] + */ +var HTML5AudioFile = new Class({ + + Extends: File, + + initialize: + + function HTML5AudioFile (key, url, path, config, locked) + { + this.locked = locked; + + this.loaded = false; + + var fileConfig = { + type: 'audio', + extension: GetFastValue(url, 'type', ''), + key: key, + url: GetFastValue(url, 'uri', url), + path: path, + config: config + }; + + File.call(this, fileConfig); + }, + + onLoad: function () + { + if(this.loaded) + { + return; + } + + this.loaded = true; + + this.loader.nextFile(this, true); + }, + + onError: function () + { + for (var i = 0; i < this.data.length; i++) + { + var audio = this.data[i]; + audio.oncanplaythrough = null; + audio.onerror = null; + } + + this.loader.nextFile(this, false); + }, + + onProgress: function (event) + { + var audio = event.target; + audio.oncanplaythrough = null; + audio.onerror = null; + + this.filesLoaded++; + + this.percentComplete = Math.min((this.filesLoaded / this.filesTotal), 1); + + this.loader.emit('fileprogress', this, this.percentComplete); + + if(this.filesLoaded === this.filesTotal) + { + this.onLoad(); + } + }, + + // Called by the Loader, starts the actual file downloading + load: function (loader) + { + this.loader = loader; + + this.data = []; + + var instances = (this.config && this.config.instances) || 1; + + this.filesTotal = instances; + this.filesLoaded = 0; + this.percentComplete = 0; + + for(var i = 0; i < instances; i++) + { + var audio = new Audio(); + audio.dataset.name = this.key + ('0' + i).slice(-2); // Useful for debugging + audio.dataset.used = 'false'; + + if (!this.locked) + { + audio.preload = 'auto'; + audio.oncanplaythrough = this.onProgress.bind(this); + audio.onerror = this.onError.bind(this); + } + + this.data.push(audio); + } + + for (i = 0; i < this.data.length; i++) + { + audio = this.data[i]; + audio.src = GetURL(this, loader.baseURL); + + if (!this.locked) + { + audio.load(); + } + } + + if (this.locked) + { + setTimeout(this.onLoad.bind(this)); + } + } + +}); + +module.exports = HTML5AudioFile; + + +/***/ }), +/* 225 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(21); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var HTML5AudioFile = __webpack_require__(224); + +/** + * @classdesc + * [description] + * + * @class AudioFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * @param {AudioContext} audioContext - [description] + */ +var AudioFile = new Class({ + + Extends: File, + + initialize: + + function AudioFile (key, url, path, xhrSettings, audioContext) + { + /** + * [description] + * + * @property {AudioContext} context + * @since 3.0.0 + */ + this.context = audioContext; + + var fileConfig = { + type: 'audio', + extension: GetFastValue(url, 'type', ''), + responseType: 'arraybuffer', + key: key, + url: GetFastValue(url, 'uri', url), + path: path, + xhrSettings: xhrSettings + }; + + File.call(this, fileConfig); + }, + + /** + * [description] + * + * @method Phaser.Loader.FileTypes.AudioFile#onProcess + * @since 3.0.0 + * + * @param {FileProcessCallback} callback - [description] + */ + onProcess: function (callback) + { + this.state = CONST.FILE_PROCESSING; + + var _this = this; + + // interesting read https://github.com/WebAudio/web-audio-api/issues/1305 + this.context.decodeAudioData(this.xhrLoader.response, + function (audioBuffer) + { + _this.data = audioBuffer; + + _this.onComplete(); + + callback(_this); + }, + function (e) + { + // eslint-disable-next-line no-console + console.error('Error with decoding audio data for \'' + this.key + '\':', e.message); + + _this.state = CONST.FILE_ERRORED; + + callback(_this); + } + ); + + this.context = null; + } + +}); + +AudioFile.create = function (loader, key, urls, config, xhrSettings) +{ + var game = loader.systems.game; + var audioConfig = game.config.audio; + var deviceAudio = game.device.audio; + + if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) + { + // console.info('Skipping loading audio \'' + key + '\' since sounds are disabled.'); + return null; + } + + var url = AudioFile.findAudioURL(game, urls); + + if (!url) + { + // console.warn('No supported url provided for audio \'' + key + '\'!'); + return null; + } + + if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio)) + { + return new AudioFile(key, url, loader.path, xhrSettings, game.sound.context); + } + else + { + return new HTML5AudioFile(key, url, loader.path, config, game.sound.locked); + } +}; + +/** + * Adds an Audio file to the current load queue. + * + * Note: This method will only be available if the Audio File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#audio + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {(string|string[])} urls - [description] + * @param {object} config - [description] + * @param {object} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('audio', function (key, urls, config, xhrSettings) +{ + var audioFile = AudioFile.create(this, key, urls, config, xhrSettings); + + if (audioFile) + { + this.addFile(audioFile); + } + + return this; +}); + +// this.load.audio('sound', 'assets/audio/booom.ogg', config, xhrSettings); +// +// this.load.audio('sound', +// [ +// 'assets/audio/booom.ogg', +// 'assets/audio/booom.m4a', +// 'assets/audio/booom.mp3' +// ], +// config, xhrSettings); +// +// this.load.audio('sound', +// { +// uri: 'assets/audio/boooooom', +// type: 'ogg' +// }, +// config, xhrSettings); +// +// this.load.audio('sound', +// [ +// { +// uri: 'assets/audio/booooooo', +// type: 'ogg' +// }, +// { +// uri: 'assets/audio/boooooom', +// type: 'mp3' +// } +// ], +// config, xhrSettings); +// +// this.load.audio('sound', +// [ +// { +// uri: 'assets/audio/booooooo', +// type: 'ogg' +// }, +// 'assets/audio/booom.m4a', +// { +// uri: 'assets/audio/boooooom', +// type: 'mp3' +// } +// ], +// config, xhrSettings); + +AudioFile.findAudioURL = function (game, urls) +{ + if (urls.constructor !== Array) + { + urls = [ urls ]; + } + + for (var i = 0; i < urls.length; i++) + { + var url = GetFastValue(urls[i], 'uri', urls[i]); + + if (url.indexOf('blob:') === 0 || url.indexOf('data:') === 0) + { + return url; + } + + var audioType = url.match(/\.([a-zA-Z0-9]+)($|\?)/); + + audioType = GetFastValue(urls[i], 'type', (audioType) ? audioType[1] : '').toLowerCase(); + + if (game.device.audio[audioType]) + { + return { + uri: url, + type: audioType + }; + } + } + + return null; +}; + +module.exports = AudioFile; + + +/***/ }), +/* 226 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MergeXHRSettings = __webpack_require__(121); + +/** + * Creates a new XMLHttpRequest (xhr) object based on the given File and XHRSettings + * and starts the download of it. It uses the Files own XHRSettings and merges them + * with the global XHRSettings object to set the xhr values before download. + * + * @function Phaser.Loader.XHRLoader + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - The File to download. + * @param {XHRSettingsObject} globalXHRSettings - The global XHRSettings object. + * + * @return {XMLHttpRequest} The XHR object. + */ +var XHRLoader = function (file, globalXHRSettings) +{ + var config = MergeXHRSettings(globalXHRSettings, file.xhrSettings); + + var xhr = new XMLHttpRequest(); + + xhr.open('GET', file.src, config.async, config.user, config.password); + + xhr.responseType = file.xhrSettings.responseType; + xhr.timeout = config.timeout; + + if (config.header && config.headerValue) + { + xhr.setRequestHeader(config.header, config.headerValue); + } + + if (config.overrideMimeType) + { + xhr.overrideMimeType(config.overrideMimeType); + } + + // After a successful request, the xhr.response property will contain the requested data as a DOMString, ArrayBuffer, Blob, or Document (depending on what was set for responseType.) + + xhr.onload = file.onLoad.bind(file); + xhr.onerror = file.onError.bind(file); + xhr.onprogress = file.onProgress.bind(file); + + // This is the only standard method, the ones above are browser additions (maybe not universal?) + // xhr.onreadystatechange + + xhr.send(); + + return xhr; +}; + +module.exports = XHRLoader; + + +/***/ }), +/* 227 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Phaser.Input.InteractiveObject + +/** + * @callback HitAreaCallback + * + * @param {*} hitArea - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * + * @return {boolean} [description] + */ + +/** + * @typedef {object} InteractiveObject + * + * @property {Phaser.GameObjects.GameObject} gameObject - [description] + * @property {boolean} enabled - [description] + * @property {boolean} draggable - [description] + * @property {boolean} dropZone - [description] + * @property {[type]} target - [description] + * @property {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @property {*} hitArea - [description] + * @property {HitAreaCallback} hitAreaCallback - [description] + * @property {number} localX - [description] + * @property {number} localY - [description] + * @property {(0|1|2)} dragState - [description] + * @property {number} dragStartX - [description] + * @property {number} dragStartY - [description] + * @property {number} dragX - [description] + * @property {number} dragY - [description] + */ + +/** + * [description] + * + * @method Phaser.Input.Pointer#positionToCamera + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * @param {*} hitArea - [description] + * @param {HitAreaCallback} hitAreaCallback - [description] + * + * @return {InteractiveObject} [description] + */ +var InteractiveObject = function (gameObject, hitArea, hitAreaCallback) +{ + return { + + gameObject: gameObject, + + enabled: true, + draggable: false, + dropZone: false, + + target: null, + + camera: null, + + hitArea: hitArea, + hitAreaCallback: hitAreaCallback, + + localX: 0, + localY: 0, + + // 0 = Not being dragged + // 1 = Being checked for dragging + // 2 = Being dragged + dragState: 0, + + dragStartX: 0, + dragStartY: 0, + + dragX: 0, + dragY: 0 + + }; +}; + +module.exports = InteractiveObject; + + +/***/ }), +/* 228 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +// The three angle bisectors of a triangle meet in one point called the incenter. +// It is the center of the incircle, the circle inscribed in the triangle. + +function getLength (x1, y1, x2, y2) +{ + var x = x1 - x2; + var y = y1 - y2; + var magnitude = (x * x) + (y * y); + + return Math.sqrt(magnitude); +} + +/** + * [description] + * + * @function Phaser.Geom.Triangle.InCenter + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var InCenter = function (triangle, out) +{ + if (out === undefined) { out = new Point(); } + + var x1 = triangle.x1; + var y1 = triangle.y1; + + var x2 = triangle.x2; + var y2 = triangle.y2; + + var x3 = triangle.x3; + var y3 = triangle.y3; + + var d1 = getLength(x3, y3, x2, y2); + var d2 = getLength(x1, y1, x3, y3); + var d3 = getLength(x2, y2, x1, y1); + + var p = d1 + d2 + d3; + + out.x = (x1 * d1 + x2 * d2 + x3 * d3) / p; + out.y = (y1 * d1 + y2 * d2 + y3 * d3) / p; + + return out; +}; + +module.exports = InCenter; + + +/***/ }), +/* 229 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Offset + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Geom.Triangle} [description] + */ +var Offset = function (triangle, x, y) +{ + triangle.x1 += x; + triangle.y1 += y; + + triangle.x2 += x; + triangle.y2 += y; + + triangle.x3 += x; + triangle.y3 += y; + + return triangle; +}; + +module.exports = Offset; + + +/***/ }), +/* 230 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +// The three medians (the lines drawn from the vertices to the bisectors of the opposite sides) +// meet in the centroid or center of mass (center of gravity). +// The centroid divides each median in a ratio of 2:1 + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Centroid + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ +var Centroid = function (triangle, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = (triangle.x1 + triangle.x2 + triangle.x3) / 3; + out.y = (triangle.y1 + triangle.y2 + triangle.y3) / 3; + + return out; +}; + +module.exports = Centroid; + + +/***/ }), +/* 231 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Length = __webpack_require__(77); +var Point = __webpack_require__(4); + +/** + * [description] + * + * @function Phaser.Geom.Triangle.GetPoints + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {integer} quantity - [description] + * @param {number} stepRate - [description] + * @param {(array|Phaser.Geom.Point[])} out - [description] + * + * @return {(array|Phaser.Geom.Point[])} [description] + */ +var GetPoints = function (triangle, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + var line1 = triangle.getLineA(); + var line2 = triangle.getLineB(); + var line3 = triangle.getLineC(); + + var length1 = Length(line1); + var length2 = Length(line2); + var length3 = Length(line3); + + var perimeter = length1 + length2 + length3; + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) + { + quantity = perimeter / stepRate; + } + + for (var i = 0; i < quantity; i++) + { + var p = perimeter * (i / quantity); + var localPosition = 0; + + var point = new Point(); + + // Which line is it on? + + if (p < length1) + { + // Line 1 + localPosition = p / length1; + + point.x = line1.x1 + (line1.x2 - line1.x1) * localPosition; + point.y = line1.y1 + (line1.y2 - line1.y1) * localPosition; + } + else if (p > length1 + length2) + { + // Line 3 + p -= length1 + length2; + localPosition = p / length3; + + point.x = line3.x1 + (line3.x2 - line3.x1) * localPosition; + point.y = line3.y1 + (line3.y2 - line3.y1) * localPosition; + } + else + { + // Line 2 + p -= length1; + localPosition = p / length2; + + point.x = line2.x1 + (line2.x2 - line2.x1) * localPosition; + point.y = line2.y1 + (line2.y2 - line2.y1) * localPosition; + } + + out.push(point); + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }), +/* 232 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); +var Length = __webpack_require__(77); + +// Position is a value between 0 and 1 +/** + * [description] + * + * @function Phaser.Geom.Triangle.GetPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {float} position - [description] + * @param {(Phaser.Geom.Point|object)} out - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ +var GetPoint = function (triangle, position, out) +{ + if (out === undefined) { out = new Point(); } + + var line1 = triangle.getLineA(); + var line2 = triangle.getLineB(); + var line3 = triangle.getLineC(); + + if (position <= 0 || position >= 1) + { + out.x = line1.x1; + out.y = line1.y1; + + return out; + } + + var length1 = Length(line1); + var length2 = Length(line2); + var length3 = Length(line3); + + var perimeter = length1 + length2 + length3; + + var p = perimeter * position; + var localPosition = 0; + + // Which line is it on? + + if (p < length1) + { + // Line 1 + localPosition = p / length1; + + out.x = line1.x1 + (line1.x2 - line1.x1) * localPosition; + out.y = line1.y1 + (line1.y2 - line1.y1) * localPosition; + } + else if (p > length1 + length2) + { + // Line 3 + p -= length1 + length2; + localPosition = p / length3; + + out.x = line3.x1 + (line3.x2 - line3.x1) * localPosition; + out.y = line3.y1 + (line3.y2 - line3.y1) * localPosition; + } + else + { + // Line 2 + p -= length1; + localPosition = p / length2; + + out.x = line2.x1 + (line2.x2 - line2.x1) * localPosition; + out.y = line2.y1 + (line2.y2 - line2.y1) * localPosition; + } + + return out; +}; + +module.exports = GetPoint; + + +/***/ }), +/* 233 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Centers this Rectangle so that the center coordinates match the given x and y values. + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.CenterOn + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var CenterOn = function (rect, x, y) +{ + rect.x = x - (rect.width / 2); + rect.y = y - (rect.height / 2); + + return rect; +}; + +module.exports = CenterOn; + + +/***/ }), +/* 234 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(10); + +Rectangle.Area = __webpack_require__(605); +Rectangle.Ceil = __webpack_require__(604); +Rectangle.CeilAll = __webpack_require__(603); +Rectangle.CenterOn = __webpack_require__(233); +Rectangle.Clone = __webpack_require__(602); +Rectangle.Contains = __webpack_require__(27); +Rectangle.ContainsPoint = __webpack_require__(601); +Rectangle.ContainsRect = __webpack_require__(600); +Rectangle.CopyFrom = __webpack_require__(599); +Rectangle.Decompose = __webpack_require__(240); +Rectangle.Equals = __webpack_require__(598); +Rectangle.FitInside = __webpack_require__(597); +Rectangle.FitOutside = __webpack_require__(596); +Rectangle.Floor = __webpack_require__(595); +Rectangle.FloorAll = __webpack_require__(594); +Rectangle.FromPoints = __webpack_require__(150); +Rectangle.GetAspectRatio = __webpack_require__(124); +Rectangle.GetCenter = __webpack_require__(593); +Rectangle.GetPoint = __webpack_require__(166); +Rectangle.GetPoints = __webpack_require__(352); +Rectangle.GetSize = __webpack_require__(592); +Rectangle.Inflate = __webpack_require__(591); +Rectangle.MarchingAnts = __webpack_require__(347); +Rectangle.MergePoints = __webpack_require__(590); +Rectangle.MergeRect = __webpack_require__(589); +Rectangle.MergeXY = __webpack_require__(588); +Rectangle.Offset = __webpack_require__(587); +Rectangle.OffsetPoint = __webpack_require__(586); +Rectangle.Overlaps = __webpack_require__(585); +Rectangle.Perimeter = __webpack_require__(105); +Rectangle.PerimeterPoint = __webpack_require__(584); +Rectangle.Random = __webpack_require__(163); +Rectangle.Scale = __webpack_require__(583); +Rectangle.Union = __webpack_require__(582); + +module.exports = Rectangle; + + +/***/ }), +/* 235 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Contains = __webpack_require__(125); + +/** + * @classdesc + * [description] + * + * @class Polygon + * @memberOf Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Geom.Point[]} [points] - [description] + */ +var Polygon = new Class({ + + initialize: + + function Polygon (points) + { + /** + * The area of this Polygon. + * + * @name Phaser.Geom.Polygon#area + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.area = 0; + + /** + * An array of number pair objects that make up this polygon. I.e. [ {x,y}, {x,y}, {x,y} ] + * + * @name Phaser.Geom.Polygon#points + * @type {Phaser.Geom.Point[]} + * @since 3.0.0 + */ + this.points = []; + + if (points) + { + this.setTo(points); + } + }, + + /** + * [description] + * + * @method Phaser.Geom.Polygon#contains + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ + contains: function (x, y) + { + return Contains(this, x, y); + }, + + /** + * Sets this Polygon to the given points. + * + * The points can be set from a variety of formats: + * + * - An array of Point objects: `[new Phaser.Point(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * + * `setTo` may also be called without any arguments to remove all points. + * + * @method Phaser.Geom.Polygon#setTo + * @since 3.0.0 + * + * @param {array} points - [description] + * + * @return {Phaser.Geom.Polygon} This Polygon object. + */ + setTo: function (points) + { + this.area = 0; + this.points = []; + + if (!Array.isArray(points)) + { + return this; + } + + var entry; + var y0 = Number.MAX_VALUE; + var p; + + // The points argument is an array, so iterate through it + for (var i = 0; i < points.length; i++) + { + p = { x: 0, y: 0 }; + + if (typeof points[i] === 'number') + { + p.x = points[i]; + p.y = points[i + 1]; + i++; + } + else if (Array.isArray(entry)) + { + // An array of arrays? + p.x = points[i][0]; + p.y = points[i][1]; + } + else + { + p.x = points[i].x; + p.y = points[i].y; + } + + this.points.push(p); + + // Lowest boundary + if (p.y < y0) + { + y0 = p.y; + } + } + + this.calculateArea(y0); + + return this; + }, + + /** + * Calculates the area of the Polygon. This is available in the property Polygon.area + * + * @method Phaser.Geom.Polygon#calculateArea + * @since 3.0.0 + * + * @return {number} [description] + */ + calculateArea: function () + { + if (this.points.length < 3) + { + this.area = 0; + + return this.area; + } + + var sum = 0; + var p1; + var p2; + + for (var i = 0; i < this.points.length - 1; i++) + { + p1 = this.points[i]; + p2 = this.points[i + 1]; + + sum += (p2.x - p1.x) * (p1.y + p2.y); + } + + p1 = this.points[0]; + p2 = this.points[this.points.length - 1]; + + sum += (p1.x - p2.x) * (p2.y + p1.y); + + this.area = -sum * 0.5; + + return this.area; + } + +}); + +module.exports = Polygon; + + +/***/ }), +/* 236 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Point.GetMagnitudeSq + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * + * @return {number} [description] + */ +var GetMagnitudeSq = function (point) +{ + return (point.x * point.x) + (point.y * point.y); +}; + +module.exports = GetMagnitudeSq; + + +/***/ }), +/* 237 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Point.GetMagnitude + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * + * @return {number} [description] + */ +var GetMagnitude = function (point) +{ + return Math.sqrt((point.x * point.x) + (point.y * point.y)); +}; + +module.exports = GetMagnitude; + + +/***/ }), +/* 238 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(16); +var Wrap = __webpack_require__(43); +var Angle = __webpack_require__(53); + +/** + * [description] + * + * @function Phaser.Geom.Line.NormalAngle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * + * @return {number} [description] + */ +var NormalAngle = function (line) +{ + var angle = Angle(line) - MATH_CONST.TAU; + + return Wrap(angle, -Math.PI, Math.PI); +}; + +module.exports = NormalAngle; + + +/***/ }), +/* 239 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Decompose + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {array} [out] - [description] + * + * @return {array} [description] + */ +var Decompose = function (triangle, out) +{ + if (out === undefined) { out = []; } + + out.push({ x: triangle.x1, y: triangle.y1 }); + out.push({ x: triangle.x2, y: triangle.y2 }); + out.push({ x: triangle.x3, y: triangle.y3 }); + + return out; +}; + +module.exports = Decompose; + + +/***/ }), +/* 240 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Decompose + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {array} [out] - [description] + * + * @return {array} [description] + */ +var Decompose = function (rect, out) +{ + if (out === undefined) { out = []; } + + out.push({ x: rect.x, y: rect.y }); + out.push({ x: rect.right, y: rect.y }); + out.push({ x: rect.right, y: rect.bottom }); + out.push({ x: rect.x, y: rect.bottom }); + + return out; +}; + +module.exports = Decompose; + + +/***/ }), +/* 241 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Intersects.PointToLine + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * @param {Phaser.Geom.Line} line - [description] + * + * @return {boolean} [description] + */ +var PointToLine = function (point, line) +{ + return ((point.x - line.x1) * (line.y2 - line.y1) === (line.x2 - line.x1) * (point.y - line.y1)); +}; + +module.exports = PointToLine; + + +/***/ }), +/* 242 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on code by Matt DesLauriers +// https://github.com/mattdesl/line-circle-collision/blob/master/LICENSE.md + +var Contains = __webpack_require__(28); +var Point = __webpack_require__(4); + +var tmp = new Point(); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.LineToCircle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {Phaser.Geom.Circle} circle - [description] + * @param {Phaser.Geom.Point} [nearest] - [description] + * + * @return {boolean} [description] + */ +var LineToCircle = function (line, circle, nearest) +{ + if (nearest === undefined) { nearest = tmp; } + + if (Contains(circle, line.x1, line.y1)) + { + nearest.x = line.x1; + nearest.y = line.y1; + + return true; + } + + if (Contains(circle, line.x2, line.y2)) + { + nearest.x = line.x2; + nearest.y = line.y2; + + return true; + } + + var dx = line.x2 - line.x1; + var dy = line.y2 - line.y1; + + var lcx = circle.x - line.x1; + var lcy = circle.y - line.y1; + + // project lc onto d, resulting in vector p + var dLen2 = (dx * dx) + (dy * dy); + var px = dx; + var py = dy; + + if (dLen2 > 0) + { + var dp = ((lcx * dx) + (lcy * dy)) / dLen2; + + px *= dp; + py *= dp; + } + + nearest.x = line.x1 + px; + nearest.y = line.y1 + py; + + // len2 of p + var pLen2 = (px * px) + (py * py); + + return ( + pLen2 <= dLen2 && + ((px * dx) + (py * dy)) >= 0 && + Contains(circle, nearest.x, nearest.y) + ); +}; + +module.exports = LineToCircle; + + +/***/ }), +/* 243 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Intersects.RectangleToRectangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rectA - [description] + * @param {Phaser.Geom.Rectangle} rectB - [description] + * + * @return {boolean} [description] + */ +var RectangleToRectangle = function (rectA, rectB) +{ + if (rectA.width <= 0 || rectA.height <= 0 || rectB.width <= 0 || rectB.height <= 0) + { + return false; + } + + return !(rectA.right < rectB.x || rectA.bottom < rectB.y || rectA.x > rectB.right || rectA.y > rectB.bottom); +}; + +module.exports = RectangleToRectangle; + + +/***/ }), +/* 244 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Geom.Intersects + */ + +module.exports = { + + CircleToCircle: __webpack_require__(652), + CircleToRectangle: __webpack_require__(651), + GetRectangleIntersection: __webpack_require__(650), + LineToCircle: __webpack_require__(242), + LineToLine: __webpack_require__(95), + LineToRectangle: __webpack_require__(649), + PointToLine: __webpack_require__(241), + PointToLineSegment: __webpack_require__(648), + RectangleToRectangle: __webpack_require__(243), + RectangleToTriangle: __webpack_require__(647), + RectangleToValues: __webpack_require__(646), + TriangleToCircle: __webpack_require__(645), + TriangleToLine: __webpack_require__(644), + TriangleToTriangle: __webpack_require__(643) + +}; + + +/***/ }), +/* 245 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Geom + */ + +module.exports = { + + Circle: __webpack_require__(662), + Ellipse: __webpack_require__(269), + Intersects: __webpack_require__(244), + Line: __webpack_require__(642), + Point: __webpack_require__(624), + Polygon: __webpack_require__(610), + Rectangle: __webpack_require__(234), + Triangle: __webpack_require__(581) + +}; + + +/***/ }), +/* 246 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Light = __webpack_require__(247); +var LightPipeline = __webpack_require__(173); +var Utils = __webpack_require__(44); + +/** + * @callback LightForEach + * + * @param {Phaser.GameObjects.Light} light - [description] + */ + +/** + * @classdesc + * [description] + * + * @class LightsManager + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + */ +var LightsManager = new Class({ + + initialize: + + function LightsManager () + { + /** + * [description] + * + * @name Phaser.GameObjects.LightsManager#lightPool + * @type {Phaser.GameObjects.Light[]} + * @default [] + * @since 3.0.0 + */ + this.lightPool = []; + + /** + * [description] + * + * @name Phaser.GameObjects.LightsManager#lights + * @type {Phaser.GameObjects.Light[]} + * @default [] + * @since 3.0.0 + */ + this.lights = []; + + /** + * [description] + * + * @name Phaser.GameObjects.LightsManager#culledLights + * @type {Phaser.GameObjects.Light[]} + * @default [] + * @since 3.0.0 + */ + this.culledLights = []; + + /** + * [description] + * + * @name Phaser.GameObjects.LightsManager#ambientColor + * @type {{ r: float, g: float, b: float }} + * @since 3.0.0 + */ + this.ambientColor = { r: 0.1, g: 0.1, b: 0.1 }; + + /** + * [description] + * + * @name Phaser.GameObjects.LightsManager#active + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.active = false; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsManager#enable + * @since 3.0.0 + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + enable: function () + { + this.active = true; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsManager#disable + * @since 3.0.0 + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + disable: function () + { + this.active = false; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsManager#cull + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + * @return {Phaser.GameObjects.Light[]} [description] + */ + cull: function (camera) + { + var lights = this.lights; + var culledLights = this.culledLights; + var length = lights.length; + var cameraCenterX = camera.x + camera.width / 2.0; + var cameraCenterY = camera.y + camera.height / 2.0; + var cameraRadius = (camera.width + camera.height) / 2.0; + var point = { x: 0, y: 0 }; + var cameraMatrix = camera.matrix; + var viewportHeight = this.systems.game.config.height; + + culledLights.length = 0; + + for (var index = 0; index < length && culledLights.length < LightPipeline.LIGHT_COUNT; ++index) + { + var light = lights[index]; + + cameraMatrix.transformPoint(light.x, light.y, point); + + // We'll just use bounding spheres to test + // if lights should be rendered + var dx = cameraCenterX - (point.x - (camera.scrollX * light.scrollFactorX * camera.zoom)); + var dy = cameraCenterY - (viewportHeight - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom)); + var distance = Math.sqrt(dx * dx + dy * dy); + + if (distance < light.radius + cameraRadius) + { + culledLights.push(lights[index]); + } + } + + return culledLights; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsManager#forEachLight + * @since 3.0.0 + * + * @param {LightForEach} callback - [description] + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + forEachLight: function (callback) + { + if (!callback) + { + return; + } + + var lights = this.lights; + var length = lights.length; + + for (var index = 0; index < length; ++index) + { + callback(lights[index]); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsManager#setAmbientColor + * @since 3.0.0 + * + * @param {number} rgb - [description] + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + setAmbientColor: function (rgb) + { + var color = Utils.getFloatsFromUintRGB(rgb); + + this.ambientColor.r = color[0]; + this.ambientColor.g = color[1]; + this.ambientColor.b = color[2]; + + return this; + }, + + /** + * Returns the maximum number of Lights allowed to appear at once. + * + * @method Phaser.GameObjects.LightsManager#getMaxVisibleLights + * @since 3.0.0 + * + * @return {integer} [description] + */ + getMaxVisibleLights: function () + { + return 10; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsManager#getLightCount + * @since 3.0.0 + * + * @return {integer} [description] + */ + getLightCount: function () + { + return this.lights.length; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsManager#addLight + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} radius - [description] + * @param {number} rgb - [description] + * @param {number} intensity - [description] + * + * @return {Phaser.GameObjects.Light} [description] + */ + addLight: function (x, y, radius, rgb, intensity) + { + var color = null; + var light = null; + + x = (x === undefined) ? 0.0 : x; + y = (y === undefined) ? 0.0 : y; + rgb = (rgb === undefined) ? 0xffffff : rgb; + radius = (radius === undefined) ? 100.0 : radius; + intensity = (intensity === undefined) ? 1.0 : intensity; + + color = Utils.getFloatsFromUintRGB(rgb); + light = null; + + if (this.lightPool.length > 0) + { + light = this.lightPool.pop(); + light.set(x, y, radius, color[0], color[1], color[2], intensity); + } + else + { + light = new Light(x, y, radius, color[0], color[1], color[2], intensity); + } + + this.lights.push(light); + + return light; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsManager#removeLight + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Light} light - [description] + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + removeLight: function (light) + { + var index = this.lights.indexOf(light); + + if (index >= 0) + { + this.lightPool.push(light); + this.lights.splice(index, 1); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsManager#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + while (this.lights.length > 0) + { + this.lightPool.push(this.lights.pop()); + } + + this.ambientColor = { r: 0.1, g: 0.1, b: 0.1 }; + this.culledLights.length = 0; + this.lights.length = 0; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + } + +}); + +module.exports = LightsManager; + + +/***/ }), +/* 247 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Utils = __webpack_require__(44); + +/** + * @classdesc + * [description] + * + * @class Light + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {number} x - The horizontal position of the light. + * @param {number} y - The vertical position of the light. + * @param {number} radius - The radius of the light. + * @param {number} r - The red color. A value between 0 and 1. + * @param {number} g - The green color. A value between 0 and 1. + * @param {number} b - The blue color. A value between 0 and 1. + * @param {number} intensity - The intensity of the light. + */ +var Light = new Class({ + + initialize: + + function Light (x, y, radius, r, g, b, intensity) + { + /** + * [description] + * + * @name Phaser.GameObjects.Light#x + * @type {number} + * @since 3.0.0 + */ + this.x = x; + + /** + * [description] + * + * @name Phaser.GameObjects.Light#y + * @type {number} + * @since 3.0.0 + */ + this.y = y; + + /** + * [description] + * + * @name Phaser.GameObjects.Light#radius + * @type {number} + * @since 3.0.0 + */ + this.radius = radius; + + /** + * [description] + * + * @name Phaser.GameObjects.Light#r + * @type {number} + * @since 3.0.0 + */ + this.r = r; + + /** + * [description] + * + * @name Phaser.GameObjects.Light#g + * @type {number} + * @since 3.0.0 + */ + this.g = g; + + /** + * [description] + * + * @name Phaser.GameObjects.Light#b + * @type {number} + * @since 3.0.0 + */ + this.b = b; + + /** + * [description] + * + * @name Phaser.GameObjects.Light#intensity + * @type {number} + * @since 3.0.0 + */ + this.intensity = intensity; + + /** + * [description] + * + * @name Phaser.GameObjects.Light#scrollFactorX + * @type {number} + * @since 3.0.0 + */ + this.scrollFactorX = 1.0; + + /** + * [description] + * + * @name Phaser.GameObjects.Light#scrollFactorY + * @type {number} + * @since 3.0.0 + */ + this.scrollFactorY = 1.0; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Light#set + * @since 3.0.0 + * + * @param {number} x - The horizontal position of the light. + * @param {number} y - The vertical position of the light. + * @param {number} radius - The radius of the light. + * @param {number} r - The red color. A value between 0 and 1. + * @param {number} g - The green color. A value between 0 and 1. + * @param {number} b - The blue color. A value between 0 and 1. + * @param {number} intensity - The intensity of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + set: function (x, y, radius, r, g, b, intensity) + { + this.x = x; + this.y = y; + + this.radius = radius; + + this.r = r; + this.g = g; + this.b = b; + + this.intensity = intensity; + + this.scrollFactorX = 1; + this.scrollFactorY = 1; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Light#setScrollFactor + * @since 3.0.0 + * + * @param {number} x - The horizontal scroll factor of the light. + * @param {number} y - The vertical scroll factor of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setScrollFactor: function (x, y) + { + if (x === undefined) { x = 1; } + if (y === undefined) { y = x; } + + this.scrollFactorX = x; + this.scrollFactorY = y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Light#setColor + * @since 3.0.0 + * + * @param {number} rgb - [description] + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setColor: function (rgb) + { + var color = Utils.getFloatsFromUintRGB(rgb); + + this.r = color[0]; + this.g = color[1]; + this.b = color[2]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Light#setIntensity + * @since 3.0.0 + * + * @param {number} intensity - [description] + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setIntensity: function (intensity) + { + this.intensity = intensity; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Light#setPosition + * @since 3.0.0 + * + * @param {number} x - The horizontal position of the light. + * @param {number} y - The vertical position of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setPosition: function (x, y) + { + this.x = x; + this.y = y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Light#setRadius + * @since 3.0.0 + * + * @param {number} radius - [description] + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setRadius: function (radius) + { + this.radius = radius; + + return this; + } + +}); + +module.exports = Light; + + +/***/ }), +/* 248 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the nearest power of 2 to the given `value`. + * + * @function Phaser.Math.Pow2.GetPowerOfTwo + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {integer} [description] + */ +var GetPowerOfTwo = function (value) +{ + // Math.log(2) + var index = Math.log(value) / 0.6931471805599453; + + return (1 << Math.ceil(index)); +}; + +module.exports = GetPowerOfTwo; + + +/***/ }), +/* 249 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var DegToRad = __webpack_require__(42); +var GetBoolean = __webpack_require__(69); +var GetValue = __webpack_require__(5); +var Sprite = __webpack_require__(40); +var TWEEN_CONST = __webpack_require__(68); +var Vector2 = __webpack_require__(6); + +/** + * @typedef {object} PathConfig + * + * @property {number} duration - [description] + * @property {number} from - [description] + * @property {number} to - [description] + * @property {boolean} [positionOnPath=false] - [description] + * @property {boolean} [rotateToPath=false] - [description] + * @property {number} [rotationOffset=0] - [description] + * @property {boolean} [verticalAdjust=false] - [description] + */ + +/** + * @classdesc + * A PathFollower Game Object. + * + * A PathFollower is a Sprite Game Object with some extra helpers to allow it to follow a Path automatically. + * + * Anything you can do with a standard Sprite can be done with this PathFollower, such as animate it, tint it, + * scale it and so on. + * + * PathFollowers are bound to a single Path at any one time and can traverse the length of the Path, from start + * to finish, forwards or backwards, or from any given point on the Path to its end. They can optionally rotate + * to face the direction of the path, be offset from the path coordinates or rotate independently of the Path. + * + * @class PathFollower + * @extends Phaser.GameObjects.Sprite + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Curves.Path} path - The Path this PathFollower is following. It can only follow one Path at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var PathFollower = new Class({ + + Extends: Sprite, + + initialize: + + function PathFollower (scene, path, x, y, texture, frame) + { + Sprite.call(this, scene, x, y, texture, frame); + + /** + * The Path this PathFollower is following. It can only follow one Path at a time. + * + * @name Phaser.GameObjects.PathFollower#path + * @type {Phaser.Curves.Path} + * @since 3.0.0 + */ + this.path = path; + + /** + * Should the PathFollower automatically rotate to point in the direction of the Path? + * + * @name Phaser.GameObjects.PathFollower#rotateToPath + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.rotateToPath = false; + + /** + * [description] + * + * @name Phaser.GameObjects.PathFollower#pathRotationVerticalAdjust + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.pathRotationVerticalAdjust = false; + + /** + * If the PathFollower is rotating to match the Path (@see Phaser.GameObjects.PathFollower#rotateToPath) + * this value is added to the rotation value. This allows you to rotate objects to a path but control + * the angle of the rotation as well. + * + * @name Phaser.GameObjects.PathFollower#pathRotationOffset + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.pathRotationOffset = 0; + + /** + * An additional vector to add to the PathFollowers position, allowing you to offset it from the + * Path coordinates. + * + * @name Phaser.GameObjects.PathFollower#pathOffset + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.pathOffset = new Vector2(x, y); + + /** + * [description] + * + * @name Phaser.GameObjects.PathFollower#pathVector + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.pathVector = new Vector2(); + + /** + * [description] + * + * @name Phaser.GameObjects.PathFollower#pathTween + * @type {Phaser.Tweens.Tween} + * @since 3.0.0 + */ + this.pathTween; + + /** + * [description] + * + * @name Phaser.GameObjects.PathFollower#pathConfig + * @type {?PathConfig} + * @default null + * @since 3.0.0 + */ + this.pathConfig = null; + + /** + * Records the direction of the follower so it can change direction. + * + * @name Phaser.GameObjects.PathFollower#_prevDirection + * @type {integer} + * @private + * @since 3.0.0 + */ + this._prevDirection = TWEEN_CONST.PLAYING_FORWARD; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.PathFollower#setPath + * @since 3.0.0 + * + * @param {Phaser.Curves.Path} path - The Path this PathFollower is following. It can only follow one Path at a time. + * @param {PathConfig} [config] - [description] + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + setPath: function (path, config) + { + if (config === undefined) { config = this.pathConfig; } + + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.stop(); + } + + this.path = path; + + if (config) + { + this.start(config); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.PathFollower#setRotateToPath + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} [offset=0] - Rotation offset in degrees. + * @param {boolean} [verticalAdjust=false] - [description] + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + setRotateToPath: function (value, offset, verticalAdjust) + { + if (offset === undefined) { offset = 0; } + if (verticalAdjust === undefined) { verticalAdjust = false; } + + this.rotateToPath = value; + + this.pathRotationOffset = offset; + this.pathRotationVerticalAdjust = verticalAdjust; + + return this; + }, + + /** + * Is this PathFollower actively following a Path or not? + * To be considered as `isFollowing` it must be currently moving on a Path, and not paused. + * + * @method Phaser.GameObjects.PathFollower#isFollowing + * @since 3.0.0 + * + * @return {boolean} `true` is this PathFollower is actively following a Path, otherwise `false`. + */ + isFollowing: function () + { + var tween = this.pathTween; + + return (tween && tween.isPlaying()); + }, + + /** + * Starts this PathFollower following its given Path. + * + * @method Phaser.GameObjects.PathFollower#startFollow + * @since 3.3.0 + * + * @param {(number|PathConfig)} [config={}] - [description] + * @param {number} [startAt=0] - [description] + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + startFollow: function (config, startAt) + { + if (config === undefined) { config = {}; } + if (startAt === undefined) { startAt = 0; } + + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.stop(); + } + + if (typeof config === 'number') + { + config = { duration: config }; + } + + // Override in case they've been specified in the config + config.from = 0; + config.to = 1; + + // Can also read extra values out of the config: + + var positionOnPath = GetBoolean(config, 'positionOnPath', false); + + this.rotateToPath = GetBoolean(config, 'rotateToPath', false); + this.pathRotationOffset = GetValue(config, 'rotationOffset', 0); + this.pathRotationVerticalAdjust = GetBoolean(config, 'verticalAdjust', false); + + this.pathTween = this.scene.sys.tweens.addCounter(config); + + // The starting point of the path, relative to this follower + this.path.getStartPoint(this.pathOffset); + + if (positionOnPath) + { + this.x = this.pathOffset.x; + this.y = this.pathOffset.y; + } + + this.pathOffset.x = this.x - this.pathOffset.x; + this.pathOffset.y = this.y - this.pathOffset.y; + + this._prevDirection = TWEEN_CONST.PLAYING_FORWARD; + + if (this.rotateToPath) + { + // Set the rotation now (in case the tween has a delay on it, etc) + var nextPoint = this.path.getPoint(0.1); + + this.rotation = Math.atan2(nextPoint.y - this.y, nextPoint.x - this.x) + DegToRad(this.pathRotationOffset); + } + + this.pathConfig = config; + + return this; + }, + + /** + * Pauses this PathFollower. It will still continue to render, but it will remain motionless at the + * point on the Path at which you paused it. + * + * @method Phaser.GameObjects.PathFollower#pauseFollow + * @since 3.3.0 + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + pauseFollow: function () + { + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.pause(); + } + + return this; + }, + + /** + * Resumes a previously paused PathFollower. + * If the PathFollower was not paused this has no effect. + * + * @method Phaser.GameObjects.PathFollower#resumeFollow + * @since 3.3.0 + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + resumeFollow: function () + { + var tween = this.pathTween; + + if (tween && tween.isPaused()) + { + tween.resume(); + } + + return this; + }, + + /** + * Stops this PathFollower from following the path any longer. + * This will invoke any 'stop' conditions that may exist on the Path, or for the follower. + * + * @method Phaser.GameObjects.PathFollower#stopFollow + * @since 3.3.0 + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + stopFollow: function () + { + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.stop(); + } + + return this; + }, + + /** + * Internal update handler that advances this PathFollower along the path. + * Called automatically by the Scene step, should not typically be called directly. + * + * @method Phaser.GameObjects.PathFollower#preUpdate + * @protected + * @since 3.0.0 + * + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + preUpdate: function (time, delta) + { + this.anims.update(time, delta); + + var tween = this.pathTween; + + if (tween) + { + var tweenData = tween.data[0]; + + if (tweenData.state !== TWEEN_CONST.PLAYING_FORWARD && tweenData.state !== TWEEN_CONST.PLAYING_BACKWARD) + { + // If delayed, etc then bail out + return; + } + + var pathVector = this.pathVector; + + this.path.getPoint(tween.getValue(), pathVector); + + pathVector.add(this.pathOffset); + + var oldX = this.x; + var oldY = this.y; + + this.setPosition(pathVector.x, pathVector.y); + + var speedX = this.x - oldX; + var speedY = this.y - oldY; + + if (speedX === 0 && speedY === 0) + { + // Bail out early + return; + } + + if (tweenData.state !== this._prevDirection) + { + // We've changed direction, so don't do a rotate this frame + this._prevDirection = tweenData.state; + + return; + } + + if (this.rotateToPath) + { + this.rotation = Math.atan2(speedY, speedX) + DegToRad(this.pathRotationOffset); + + if (this.pathRotationVerticalAdjust) + { + this.flipY = (this.rotation !== 0 && tweenData.state === TWEEN_CONST.PLAYING_BACKWARD); + } + } + } + } + +}); + +module.exports = PathFollower; + + +/***/ }), +/* 250 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Utils.Object.HasAny + * @since 3.0.0 + * + * @param {object} source - [description] + * @param {string[]} keys - [description] + * + * @return {boolean} [description] + */ +var HasAny = function (source, keys) +{ + for (var i = 0; i < keys.length; i++) + { + if (source.hasOwnProperty(keys[i])) + { + return true; + } + } + + return false; +}; + +module.exports = HasAny; /***/ }), @@ -47845,60 +52724,9 @@ module.exports = TouchManager; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Vector2 = __webpack_require__(6); +// Phaser.Math.Easing.Stepped -/** - * Takes the `x` and `y` coordinates and transforms them into the same space as - * defined by the position, rotation and scale values. - * - * @function Phaser.Math.TransformXY - * @since 3.0.0 - * - * @param {number} x - The x coordinate to be transformed. - * @param {number} y - The y coordinate to be transformed. - * @param {number} positionX - Horizontal position of the transform point. - * @param {number} positionY - Vertical position of the transform point. - * @param {number} rotation - Rotation of the transform point, in radians. - * @param {number} scaleX - Horizontal scale of the transform point. - * @param {number} scaleY - Vertical scale of the transform point. - * @param {Vector2|Point|object} [output] - [description] - * - * @return {Vector2|Point|object} The translated point. - */ -var TransformXY = function (x, y, positionX, positionY, rotation, scaleX, scaleY, output) -{ - if (output === undefined) { output = new Vector2(); } - - // ITRS - - var sr = Math.sin(-rotation); - var cr = Math.cos(-rotation); - - var a = cr * scaleX; - var b = -sr * scaleX; - var c = sr * scaleY; - var d = cr * scaleY; - - // Invert - - var n = a * d - b * c; - - var m0 = d / n; - var m1 = -b / n; - var m2 = -c / n; - var m3 = a / n; - var m4 = (c * positionY - d * positionX) / n; - var m5 = -(a * positionY - b * positionX) / n; - - // Transform - - output.x = x * m0 + y * m2 + m4; - output.y = x * m1 + y * m3 + m5; - - return output; -}; - -module.exports = TransformXY; +module.exports = __webpack_require__(717); /***/ }), @@ -47911,1392 +52739,15 @@ module.exports = TransformXY; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var CONST = __webpack_require__(83); -var GetValue = __webpack_require__(4); -var NOOP = __webpack_require__(3); -var Scene = __webpack_require__(253); -var Systems = __webpack_require__(130); +// Phaser.Math.Easing.Sine -/** - * @classdesc - * The Scene Manager. - * - * The Scene Manager is a Game level system, responsible for creating, processing and updating all of the - * Scenes in a Game instance. - * - * - * @class SceneManager - * @memberOf Phaser.Scenes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - The Phaser.Game instance this Scene Manager belongs to. - * @param {object} sceneConfig - Scene specific configuration settings. - */ -var SceneManager = new Class({ +module.exports = { - initialize: + In: __webpack_require__(720), + Out: __webpack_require__(719), + InOut: __webpack_require__(718) - function SceneManager (game, sceneConfig) - { - /** - * [description] - * - * @name Phaser.Scenes.SceneManager#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game = game; - - /** - * An object that maps the keys to the scene so we can quickly get a scene from a key without iteration. - * - * @name Phaser.Scenes.SceneManager#keys - * @type {object} - * @since 3.0.0 - */ - this.keys = {}; - - /** - * The array in which all of the scenes are kept. - * - * @name Phaser.Scenes.SceneManager#scenes - * @type {array} - * @since 3.0.0 - */ - this.scenes = []; - - /** - * Scenes pending to be added are stored in here until the manager has time to add it. - * - * @name Phaser.Scenes.SceneManager#_pending - * @type {array} - * @private - * @since 3.0.0 - */ - this._pending = []; - - /** - * An array of scenes waiting to be started once the game has booted. - * - * @name Phaser.Scenes.SceneManager#_start - * @type {array} - * @private - * @since 3.0.0 - */ - this._start = []; - - /** - * An operations queue, because we don't manipulate the scenes array during processing. - * - * @name Phaser.Scenes.SceneManager#_queue - * @type {array} - * @private - * @since 3.0.0 - */ - this._queue = []; - - /** - * The number of Scenes to process. - * - * @name Phaser.Scenes.SceneManager#_processing - * @type {integer} - * @private - * @since 3.0.0 - */ - this._processing = 0; - - if (sceneConfig) - { - if (!Array.isArray(sceneConfig)) - { - sceneConfig = [ sceneConfig ]; - } - - for (var i = 0; i < sceneConfig.length; i++) - { - // The i === 0 part just autostarts the first Scene given (unless it says otherwise in its config) - this._pending.push({ - key: 'default', - scene: sceneConfig[i], - autoStart: (i === 0), - data: {} - }); - } - - // Only need to wait for the boot event if we've scenes to actually boot - game.events.once('ready', this.bootQueue, this); - } - }, - - /** - * Internal first-time Scene boot handler. - * - * @method Phaser.Scenes.SceneManager#bootQueue - * @private - * @since 3.2.0 - */ - bootQueue: function () - { - var i; - var entry; - var key; - var sceneConfig; - - for (i = 0; i < this._pending.length; i++) - { - entry = this._pending[i]; - - key = entry.key; - sceneConfig = entry.scene; - - var newScene; - - if (sceneConfig instanceof Scene) - { - newScene = this.createSceneFromInstance(key, sceneConfig); - } - else if (typeof sceneConfig === 'object') - { - newScene = this.createSceneFromObject(key, sceneConfig); - } - else if (typeof sceneConfig === 'function') - { - newScene = this.createSceneFromFunction(key, sceneConfig); - } - - // Replace key in case the scene changed it - key = newScene.sys.settings.key; - - this.keys[key] = newScene; - - this.scenes.push(newScene); - - if (entry.autoStart || newScene.sys.settings.active) - { - this._start.push(key); - } - } - - // Clear the pending lists - this._pending.length = 0; - - // _start might have been populated by the above - for (i = 0; i < this._start.length; i++) - { - entry = this._start[i]; - - this.start(entry); - } - - this._start.length = 0; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#processQueue - * @since 3.0.0 - */ - processQueue: function () - { - var pendingLength = this._pending.length; - var queueLength = this._queue.length; - - if (pendingLength === 0 && queueLength === 0) - { - return; - } - - var i; - var entry; - - if (pendingLength) - { - for (i = 0; i < pendingLength; i++) - { - entry = this._pending[i]; - - this.add(entry.key, entry.scene, entry.autoStart); - } - - // _start might have been populated by this.add - for (i = 0; i < this._start.length; i++) - { - entry = this._start[i]; - - this.start(entry); - } - - // Clear the pending lists - this._start.length = 0; - this._pending.length = 0; - - return; - } - - for (i = 0; i < this._queue.length; i++) - { - entry = this._queue[i]; - - this[entry.op](entry.keyA, entry.keyB); - } - - this._queue.length = 0; - }, - - /** - * Adds a new Scene into the SceneManager. - * You must give each Scene a unique key by which you'll identify it. - * - * The `sceneConfig` can be: - * - * * A `Phaser.Scene` object, or an object that extends it. - * * A plain JavaScript object - * * A JavaScript ES6 Class that extends `Phaser.Scene` - * * A JavaScript ES5 prototype based Class - * * A JavaScript function - * - * If a function is given then a new Scene will be created by calling it. - * - * @method Phaser.Scenes.SceneManager#add - * @since 3.0.0 - * - * @param {string} key - A unique key used to reference the Scene, i.e. `MainMenu` or `Level1`. - * @param {Phaser.Scene|object|function} sceneConfig - [description] - * @param {boolean} [autoStart=false] - If `true` the Scene will be started immediately after being added. - * - * @return {Phaser.Scene|null} [description] - */ - add: function (key, sceneConfig, autoStart) - { - if (autoStart === undefined) { autoStart = false; } - - // if not booted, then put scene into a holding pattern - if (this._processing === 1 || !this.game.isBooted) - { - this._pending.push({ - key: key, - scene: sceneConfig, - autoStart: autoStart, - data: {} - }); - - return null; - } - - key = this.getKey(key, sceneConfig); - - var newScene; - - if (sceneConfig instanceof Scene) - { - newScene = this.createSceneFromInstance(key, sceneConfig); - } - else if (typeof sceneConfig === 'object') - { - sceneConfig.key = key; - - newScene = this.createSceneFromObject(key, sceneConfig); - } - else if (typeof sceneConfig === 'function') - { - newScene = this.createSceneFromFunction(key, sceneConfig); - } - - // Replace key in case the scene changed it - key = newScene.sys.settings.key; - - this.keys[key] = newScene; - - this.scenes.push(newScene); - - if (autoStart || newScene.sys.settings.active) - { - if (this.game.isBooted) - { - this.start(key); - } - else - { - this._start.push(key); - } - } - - return newScene; - }, - - /** - * Removes a Scene from the SceneManager. - * - * The Scene is removed from the local scenes array, it's key is cleared from the keys - * cache and Scene.Systems.destroy is then called on it. - * - * If the SceneManager is processing the Scenes when this method is called it wil - * queue the operation for the next update sequence. - * - * @method Phaser.Scenes.SceneManager#remove - * @since 3.2.0 - * - * @param {string|Phaser.Scene} scene - The Scene to be removed. - * - * @return {Phaser.Scenes.SceneManager} This SceneManager. - */ - remove: function (key) - { - if (this._processing) - { - this._queue.push({ op: 'remove', keyA: key, keyB: null }); - } - else - { - var sceneToRemove = this.getScene(key); - - if (!sceneToRemove) - { - return this; - } - - var index = this.scenes.indexOf(sceneToRemove); - var sceneKey = sceneToRemove.sys.settings.key; - - if (index > -1) - { - this.keys[sceneKey] = undefined; - this.scenes.splice(index, 1); - - if (this._start.indexOf(sceneKey) > -1) - { - index = this._start.indexOf(sceneKey); - this._start.splice(index, 1); - } - - sceneToRemove.sys.destroy(); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#bootScene - * @private - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ - bootScene: function (scene) - { - if (scene.init) - { - scene.init.call(scene, scene.sys.settings.data); - } - - var loader; - - if (scene.sys.load) - { - loader = scene.sys.load; - - loader.reset(); - } - - if (loader && scene.preload) - { - scene.preload.call(scene); - - // Is the loader empty? - if (loader.list.size === 0) - { - this.create(scene); - } - else - { - scene.sys.settings.status = CONST.LOADING; - - // Start the loader going as we have something in the queue - loader.once('complete', this.loadComplete, this); - - loader.start(); - } - } - else - { - // No preload? Then there was nothing to load either - this.create(scene); - } - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#loadComplete - * @private - * @since 3.0.0 - * - * @param {object} loader - [description] - */ - loadComplete: function (loader) - { - var scene = loader.scene; - - this.create(scene); - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#payloadComplete - * @private - * @since 3.0.0 - * - * @param {object} loader - [description] - */ - payloadComplete: function (loader) - { - this.bootScene(loader.scene); - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#update - * @since 3.0.0 - * - * @param {number} time - [description] - * @param {number} delta - [description] - */ - update: function (time, delta) - { - this.processQueue(); - - this._processing = 1; - - // Loop through the active scenes in reverse order - for (var i = this.scenes.length - 1; i >= 0; i--) - { - var sys = this.scenes[i].sys; - - if (sys.settings.status === CONST.RUNNING) - { - sys.step(time, delta); - } - } - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#resize - * @since 3.2.0 - * - * @param {number} width - The new width of the game. - * @param {number} height - The new height of the game. - */ - resize: function (width, height) - { - // Loop through the scenes in forward order - for (var i = 0; i < this.scenes.length; i++) - { - var sys = this.scenes[i].sys; - - sys.resize(width, height); - } - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#render - * @since 3.0.0 - * - * @param {any} renderer - [description] - */ - render: function (renderer) - { - // Loop through the scenes in forward order - for (var i = 0; i < this.scenes.length; i++) - { - var sys = this.scenes[i].sys; - - if (sys.settings.visible && sys.settings.status >= CONST.LOADING && sys.settings.status < CONST.SLEEPING) - { - sys.render(renderer); - } - } - - this._processing = 0; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#create - * @private - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ - create: function (scene) - { - if (scene.create) - { - scene.sys.settings.status = CONST.CREATING; - - scene.create.call(scene, scene.sys.settings.data); - } - - scene.sys.settings.status = CONST.RUNNING; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#createSceneFromFunction - * @private - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {function} scene - [description] - * - * @return {Phaser.Scene} [description] - */ - createSceneFromFunction: function (key, scene) - { - var newScene = new scene(); - - if (newScene instanceof Scene) - { - var configKey = newScene.sys.settings.key; - - if (configKey !== '') - { - key = configKey; - } - - if (this.keys.hasOwnProperty(key)) - { - throw new Error('Cannot add a Scene with duplicate key: ' + key); - } - - return this.createSceneFromInstance(key, newScene); - } - else - { - newScene.sys = new Systems(newScene); - - newScene.sys.settings.key = key; - - newScene.sys.init(this.game); - - if (!newScene.update) - { - newScene.update = NOOP; - } - - return newScene; - } - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#createSceneFromInstance - * @private - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {Phaser.Scene} newScene - [description] - * - * @return {Phaser.Scene} [description] - */ - createSceneFromInstance: function (key, newScene) - { - var configKey = newScene.sys.settings.key; - - if (configKey !== '') - { - key = configKey; - } - else - { - newScene.sys.settings.key = key; - } - - newScene.sys.init(this.game); - - return newScene; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#createSceneFromObject - * @private - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {object} sceneConfig - [description] - * - * @return {Phaser.Scene} [description] - */ - createSceneFromObject: function (key, sceneConfig) - { - var newScene = new Scene(sceneConfig); - - var configKey = newScene.sys.settings.key; - - if (configKey !== '') - { - key = configKey; - } - else - { - newScene.sys.settings.key = key; - } - - newScene.sys.init(this.game); - - // Extract callbacks - - var defaults = [ 'init', 'preload', 'create', 'update', 'render', 'shutdown', 'destroy' ]; - - for (var i = 0; i < defaults.length; i++) - { - var sceneCallback = GetValue(sceneConfig, defaults[i], null); - - // Must always have an update function, no matter what (the rest are optional) - if (defaults[i] === 'update' && !sceneCallback) - { - sceneCallback = NOOP; - } - - if (sceneCallback) - { - newScene[defaults[i]] = sceneCallback; - } - } - - // Now let's move across any other functions or properties that may exist in the extend object: - - /* - scene: { - preload: preload, - create: create, - extend: { - hello: 1, - test: 'atari', - addImage: addImage - } - } - */ - - if (sceneConfig.hasOwnProperty('extend')) - { - for (var propertyKey in sceneConfig.extend) - { - newScene[propertyKey] = sceneConfig.extend[propertyKey]; - } - } - - return newScene; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#getKey - * @private - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {Phaser.Scene|object|function} sceneConfig - [description] - * - * @return {string} [description] - */ - getKey: function (key, sceneConfig) - { - if (!key) { key = 'default'; } - - if (typeof sceneConfig === 'function') - { - return key; - } - else if (sceneConfig instanceof Scene) - { - key = sceneConfig.sys.settings.key; - } - else if (typeof sceneConfig === 'object' && sceneConfig.hasOwnProperty('key')) - { - key = sceneConfig.key; - } - - // By this point it's either 'default' or extracted from the Scene - - if (this.keys.hasOwnProperty(key)) - { - throw new Error('Cannot add a Scene with duplicate key: ' + key); - } - else - { - return key; - } - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#getScene - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scene|null} [description] - */ - getScene: function (key) - { - if (typeof key === 'string') - { - if (this.keys[key]) - { - return this.keys[key]; - } - } - else - { - for (var i = 0; i < this.scenes.length; i++) - { - if (key === this.scenes[i]) - { - return key; - } - } - } - - return null; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#isActive - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {boolean} [description] - */ - isActive: function (key) - { - var scene = this.getScene(key); - - if (scene) - { - return scene.sys.isActive(); - } - - return null; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#isVisible - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {boolean} [description] - */ - isVisible: function (key) - { - var scene = this.getScene(key); - - if (scene) - { - return scene.sys.isVisible(); - } - - return null; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#isSleeping - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {boolean} [description] - */ - isSleeping: function (key) - { - var scene = this.getScene(key); - - if (scene) - { - return scene.sys.isSleeping(); - } - - return null; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#pause - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - pause: function (key) - { - var scene = this.getScene(key); - - if (scene) - { - scene.sys.pause(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#resume - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - resume: function (key) - { - var scene = this.getScene(key); - - if (scene) - { - scene.sys.resume(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#sleep - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - sleep: function (key) - { - var scene = this.getScene(key); - - if (scene) - { - scene.sys.sleep(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#wake - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - wake: function (key) - { - var scene = this.getScene(key); - - if (scene) - { - scene.sys.wake(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#start - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {object} [data] - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - start: function (key, data) - { - if (data === undefined) { data = {}; } - - // if not booted, then put scene into a holding pattern - if (!this.game.isBooted) - { - for (var i = 0; i < this._pending.length; i++) - { - var entry = this._pending[i]; - - if (entry.key === key) - { - entry.autoStart = true; - entry.data = data; - } - } - - return this; - } - - var scene = this.getScene(key); - - if (scene) - { - scene.sys.start(data); - - var loader; - - if (scene.sys.load) - { - loader = scene.sys.load; - } - - // Files payload? - if (loader && Array.isArray(scene.sys.settings.files)) - { - loader.reset(); - - if (loader.loadArray(scene.sys.settings.files)) - { - scene.sys.settings.status = CONST.LOADING; - - loader.once('complete', this.payloadComplete, this); - - loader.start(); - - return this; - } - } - - this.bootScene(scene); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#stop - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - stop: function (key) - { - var scene = this.getScene(key); - - if (scene) - { - scene.sys.shutdown(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#switch - * @since 3.0.0 - * - * @param {string} from - [description] - * @param {string} to - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - switch: function (from, to) - { - var sceneA = this.getScene(from); - var sceneB = this.getScene(to); - - if (sceneA && sceneB && sceneA !== sceneB) - { - this.sleep(from); - - if (this.isSleeping(to)) - { - this.wake(to); - } - else - { - this.start(to); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#getAt - * @since 3.0.0 - * - * @param {integer} index - [description] - * - * @return {Phaser.Scene|undefined} [description] - */ - getAt: function (index) - { - return this.scenes[index]; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#getIndex - * @since 3.0.0 - * - * @param {string|Phaser.Scene} key - [description] - * - * @return {integer} [description] - */ - getIndex: function (key) - { - var scene = this.getScene(key); - - return this.scenes.indexOf(scene); - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#bringToTop - * @since 3.0.0 - * - * @param {string|Phaser.Scene} key - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - bringToTop: function (key) - { - if (this._processing) - { - this._queue.push({ op: 'bringToTop', keyA: key, keyB: null }); - } - else - { - var index = this.getIndex(key); - - if (index !== -1 && index < this.scenes.length) - { - var scene = this.getScene(key); - - this.scenes.splice(index, 1); - this.scenes.push(scene); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#sendToBack - * @since 3.0.0 - * - * @param {string|Phaser.Scene} key - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - sendToBack: function (key) - { - if (this._processing) - { - this._queue.push({ op: 'sendToBack', keyA: key, keyB: null }); - } - else - { - var index = this.getIndex(key); - - if (index !== -1 && index > 0) - { - var scene = this.getScene(key); - - this.scenes.splice(index, 1); - this.scenes.unshift(scene); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#moveDown - * @since 3.0.0 - * - * @param {string|Phaser.Scene} key - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - moveDown: function (key) - { - if (this._processing) - { - this._queue.push({ op: 'moveDown', keyA: key, keyB: null }); - } - else - { - var indexA = this.getIndex(key); - - if (indexA > 0) - { - var indexB = indexA - 1; - var sceneA = this.getScene(key); - var sceneB = this.getAt(indexB); - - this.scenes[indexA] = sceneB; - this.scenes[indexB] = sceneA; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#moveUp - * @since 3.0.0 - * - * @param {string|Phaser.Scene} key - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - moveUp: function (key) - { - if (this._processing) - { - this._queue.push({ op: 'moveUp', keyA: key, keyB: null }); - } - else - { - var indexA = this.getIndex(key); - - if (indexA < this.scenes.length - 1) - { - var indexB = indexA + 1; - var sceneA = this.getScene(key); - var sceneB = this.getAt(indexB); - - this.scenes[indexA] = sceneB; - this.scenes[indexB] = sceneA; - } - } - - return this; - }, - - /** - * Moves a Scene so it is immediately above another Scene in the Scenes list. - * This means it will render over the top of the other Scene. - * - * @method Phaser.Scenes.SceneManager#moveAbove - * @since 3.2.0 - * - * @param {string|Phaser.Scene} keyA - The Scene that Scene B will be moved above. - * @param {string|Phaser.Scene} keyB - The Scene to be moved. - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - moveAbove: function (keyA, keyB) - { - if (keyA === keyB) - { - return this; - } - - if (this._processing) - { - this._queue.push({ op: 'moveAbove', keyA: keyA, keyB: keyB }); - } - else - { - var indexA = this.getIndex(keyA); - var indexB = this.getIndex(keyB); - - if (indexA > indexB && indexA !== -1 && indexB !== -1) - { - var tempScene = this.getAt(indexB); - - // Remove - this.scenes.splice(indexB, 1); - - // Add in new location - this.scenes.splice(indexA, 0, tempScene); - } - } - - return this; - }, - - /** - * Moves a Scene so it is immediately below another Scene in the Scenes list. - * This means it will render behind the other Scene. - * - * @method Phaser.Scenes.SceneManager#moveBelow - * @since 3.2.0 - * - * @param {string|Phaser.Scene} keyA - The Scene that Scene B will be moved above. - * @param {string|Phaser.Scene} keyB - The Scene to be moved. - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - moveBelow: function (keyA, keyB) - { - if (keyA === keyB) - { - return this; - } - - if (this._processing) - { - this._queue.push({ op: 'moveBelow', keyA: keyA, keyB: keyB }); - } - else - { - var indexA = this.getIndex(keyA); - var indexB = this.getIndex(keyB); - - if (indexA < indexB && indexA !== -1 && indexB !== -1) - { - var tempScene = this.getAt(indexB); - - // Remove - this.scenes.splice(indexB, 1); - - // Add in new location - this.scenes.splice(indexA, 0, tempScene); - } - } - - return this; - }, - - queueOp: function (op, keyA, keyB) - { - this._queue.push({ op: op, keyA: keyA, keyB: keyB }); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#swapPosition - * @since 3.0.0 - * - * @param {string|Phaser.Scene} keyA - [description] - * @param {string|Phaser.Scene} keyB - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - swapPosition: function (keyA, keyB) - { - if (keyA === keyB) - { - return this; - } - - if (this._processing) - { - this._queue.push({ op: 'swapPosition', keyA: keyA, keyB: keyB }); - } - else - { - var indexA = this.getIndex(keyA); - var indexB = this.getIndex(keyB); - - if (indexA !== indexB && indexA !== -1 && indexB !== -1) - { - var tempScene = this.getAt(indexA); - - this.scenes[indexA] = this.scenes[indexB]; - this.scenes[indexB] = tempScene; - } - } - - return this; - }, - - dump: function () - { - var out = []; - var map = [ 'pending', 'init', 'start', 'loading', 'creating', 'running', 'paused', 'sleeping', 'shutdown', 'destroyed' ]; - - for (var i = 0; i < this.scenes.length; i++) - { - var sys = this.scenes[i].sys; - - var key = (sys.settings.visible && (sys.settings.status === CONST.RUNNING || sys.settings.status === CONST.PAUSED)) ? '[*] ' : '[-] '; - key += sys.settings.key + ' (' + map[sys.settings.status] + ')'; - - out.push(key); - } - - console.log(out.join('\n')); - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - for (var i = this.scenes.length - 1; i >= 0; i--) - { - var sys = this.scenes[i].sys; - - sys.destroy(); - } - - this.scenes = []; - - this._pending = []; - this._start = []; - this._queue = []; - - this.game = null; - } - -}); - -module.exports = SceneManager; +}; /***/ }), @@ -49309,55 +52760,20 @@ module.exports = SceneManager; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Systems = __webpack_require__(130); +// Phaser.Math.Easing.Quintic -/** - * @classdesc - * [description] - * - * @class Scene - * @memberOf Phaser - * @constructor - * @since 3.0.0 - * - * @param {object} config - [description] - */ -var Scene = new Class({ +module.exports = { - initialize: + In: __webpack_require__(723), + Out: __webpack_require__(722), + InOut: __webpack_require__(721) - function Scene (config) - { - /** - * The Scene Systems. You must never overwrite this property, or all hell will break lose. - * - * @name Phaser.Scene#sys - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.sys = new Systems(this, config); - }, - - /** - * Should be overridden by your own Scenes. - * - * @method Phaser.Scene#update - * @override - * @since 3.0.0 - */ - update: function () - { - } - -}); - -module.exports = Scene; +}; /***/ }), /* 254 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -49365,22 +52781,15 @@ module.exports = Scene; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * [description] - * - * @function Phaser.Utils.String.UppercaseFirst - * @since 3.0.0 - * - * @param {string} str - [description] - * - * @return {string} [description] - */ -var UppercaseFirst = function (str) -{ - return str && str[0].toUpperCase() + str.slice(1); -}; +// Phaser.Math.Easing.Quartic -module.exports = UppercaseFirst; +module.exports = { + + In: __webpack_require__(726), + Out: __webpack_require__(725), + InOut: __webpack_require__(724) + +}; /***/ }), @@ -49393,77 +52802,16 @@ module.exports = UppercaseFirst; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CONST = __webpack_require__(83); -var GetValue = __webpack_require__(4); -var InjectionMap = __webpack_require__(532); +// Phaser.Math.Easing.Quadratic -/** - * Takes a Scene configuration object and returns a fully formed Systems object. - * - * @function Phaser.Scenes.Settings.create - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {object} [description] - */ -var Settings = { +module.exports = { - create: function (config) - { - if (typeof config === 'string') - { - config = { key: config }; - } - else if (config === undefined) - { - // Pass the 'hasOwnProperty' checks - config = {}; - } - - return { - - status: CONST.PENDING, - - key: GetValue(config, 'key', ''), - active: GetValue(config, 'active', false), - visible: GetValue(config, 'visible', true), - - isBooted: false, - - // Loader payload array - - data: {}, - - files: GetValue(config, 'files', false), - - // Cameras - - cameras: GetValue(config, 'cameras', null), - - // Scene Property Injection Map - - map: GetValue(config, 'map', InjectionMap), - - // Physics - - physics: GetValue(config, 'physics', {}), - - // Loader - - loader: GetValue(config, 'loader', {}), - - // Plugins - - plugins: GetValue(config, 'plugins', false) - - }; - } + In: __webpack_require__(729), + Out: __webpack_require__(728), + InOut: __webpack_require__(727) }; -module.exports = Settings; - /***/ }), /* 256 */ @@ -49475,42 +52823,9 @@ module.exports = Settings; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var HTML5AudioSoundManager = __webpack_require__(257); -var NoAudioSoundManager = __webpack_require__(259); -var WebAudioSoundManager = __webpack_require__(261); +// Phaser.Math.Easing.Linear -/** - * Creates a Web Audio, HTML5 Audio or No Audio Sound Manager based on config and device settings. - * - * @function Phaser.Sound.SoundManagerCreator - * @author Pavle Goloskokovic (http://prunegames.com) - * @since 3.0.0 - * - * @param {Phaser.Game} game - Reference to the current game instance. - */ -var SoundManagerCreator = { - - create: function (game) - { - var audioConfig = game.config.audio; - var deviceAudio = game.device.audio; - - if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) - { - return new NoAudioSoundManager(game); - } - - if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio)) - { - return new WebAudioSoundManager(game); - } - - return new HTML5AudioSoundManager(game); - } - -}; - -module.exports = SoundManagerCreator; +module.exports = __webpack_require__(730); /***/ }), @@ -49523,388 +52838,15 @@ module.exports = SoundManagerCreator; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BaseSoundManager = __webpack_require__(84); -var Class = __webpack_require__(0); -var HTML5AudioSound = __webpack_require__(258); +// Phaser.Math.Easing.Expo -/** - * HTML5 Audio implementation of the sound manager. - * - * @class HTML5AudioSoundManager - * @extends Phaser.Sound.BaseSoundManager - * @memberOf Phaser.Sound - * @constructor - * @author Pavle Goloskokovic (http://prunegames.com) - * @since 3.0.0 - * - * @param {Phaser.Game} game - Reference to the current game instance. - */ -var HTML5AudioSoundManager = new Class({ +module.exports = { - Extends: BaseSoundManager, + In: __webpack_require__(733), + Out: __webpack_require__(732), + InOut: __webpack_require__(731) - initialize: - - function HTML5AudioSoundManager (game) - { - /** - * Flag indicating whether if there are no idle instances of HTML5 Audio tag, - * for any particular sound, if one of the used tags should be hijacked and used - * for succeeding playback or if succeeding Phaser.Sound.HTML5AudioSound#play - * call should be ignored. - * - * @name Phaser.Sound.HTML5AudioSoundManager#override - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.override = true; - - /** - * Value representing time difference, in seconds, between calling - * play method on an audio tag and when it actually starts playing. - * It is used to achieve more accurate delayed sound playback. - * - * You might need to tweak this value to get the desired results - * since audio play delay varies depending on the browser/platform. - * - * @name Phaser.Sound.HTML5AudioSoundManager#audioPlayDelay - * @type {number} - * @default 0.1 - * @since 3.0.0 - */ - this.audioPlayDelay = 0.1; - - /** - * A value by which we should offset the loop end marker of the - * looping sound to compensate for lag, caused by changing audio - * tag playback position, in order to achieve gapless looping. - * - * You might need to tweak this value to get the desired results - * since loop lag varies depending on the browser/platform. - * - * @name Phaser.Sound.HTML5AudioSoundManager#loopEndOffset - * @type {number} - * @default 0.05 - * @since 3.0.0 - */ - this.loopEndOffset = 0.05; - - /** - * An array for keeping track of all the sounds - * that were paused when game lost focus. - * - * @name Phaser.Sound.HTML5AudioSoundManager#onBlurPausedSounds - * @type {Phaser.Sound.HTML5AudioSound[]} - * @private - * @default [] - * @since 3.0.0 - */ - this.onBlurPausedSounds = []; - - this.locked = 'ontouchstart' in window; - - /** - * A queue of all actions performed on sound objects while audio was locked. - * Once the audio gets unlocked, after an explicit user interaction, - * all actions will be performed in chronological order. - * Array of object types: { sound: Phaser.Sound.HTML5AudioSound, name: string, value?: * } - * - * @name Phaser.Sound.HTML5AudioSoundManager#lockedActionsQueue - * @type {array} - * @private - * @since 3.0.0 - */ - this.lockedActionsQueue = this.locked ? [] : null; - - /** - * Property that actually holds the value of global mute - * for HTML5 Audio sound manager implementation. - * - * @name Phaser.Sound.HTML5AudioSoundManager#_mute - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this._mute = false; - - /** - * Property that actually holds the value of global volume - * for HTML5 Audio sound manager implementation. - * - * @name Phaser.Sound.HTML5AudioSoundManager#_volume - * @type {boolean} - * @private - * @default 1 - * @since 3.0.0 - */ - this._volume = 1; - - BaseSoundManager.call(this, game); - }, - - /** - * Adds a new sound into the sound manager. - * - * @method Phaser.Sound.HTML5AudioSoundManager#add - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - * - * @return {Phaser.Sound.HTML5AudioSound} The new sound instance. - */ - add: function (key, config) - { - var sound = new HTML5AudioSound(this, key, config); - - this.sounds.push(sound); - - return sound; - }, - - /** - * Unlocks HTML5 Audio loading and playback on mobile - * devices on the initial explicit user interaction. - * - * @method Phaser.Sound.HTML5AudioSoundManager#unlock - * @private - * @since 3.0.0 - */ - unlock: function () - { - var _this = this; - - var moved = false; - - var detectMove = function () - { - moved = true; - }; - - var unlock = function () - { - if (!_this.game.cache.audio.entries.size) - { - return; - } - - if (moved) - { - moved = false; - return; - } - - document.body.removeEventListener('touchmove', detectMove); - document.body.removeEventListener('touchend', unlock); - - var allTags = []; - - _this.game.cache.audio.entries.each(function (key, tags) - { - for (var i = 0; i < tags.length; i++) - { - allTags.push(tags[i]); - } - return true; - }); - - var lastTag = allTags[allTags.length - 1]; - - lastTag.oncanplaythrough = function () - { - lastTag.oncanplaythrough = null; - _this.unlocked = true; - }; - - allTags.forEach(function (tag) - { - tag.load(); - }); - }; - - this.once('unlocked', function () - { - this.forEachActiveSound(function (sound) - { - sound.duration = sound.tags[0].duration; - sound.totalDuration = sound.tags[0].duration; - }); - - this.lockedActionsQueue.forEach(function (lockedAction) - { - if (lockedAction.sound[lockedAction.prop].apply) - { - lockedAction.sound[lockedAction.prop].apply(lockedAction.sound, lockedAction.value || []); - } - else - { - lockedAction.sound[lockedAction.prop] = lockedAction.value; - } - }); - - this.lockedActionsQueue.length = 0; - this.lockedActionsQueue = null; - }, this); - - document.body.addEventListener('touchmove', detectMove, false); - document.body.addEventListener('touchend', unlock, false); - }, - - /** - * Method used internally for pausing sound manager if - * Phaser.Sound.HTML5AudioSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.HTML5AudioSoundManager#onBlur - * @protected - * @since 3.0.0 - */ - onBlur: function () - { - this.forEachActiveSound(function (sound) - { - if (sound.isPlaying) - { - this.onBlurPausedSounds.push(sound); - sound.onBlur(); - } - }); - }, - - /** - * Method used internally for resuming sound manager if - * Phaser.Sound.HTML5AudioSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.HTML5AudioSoundManager#onFocus - * @protected - * @since 3.0.0 - */ - onFocus: function () - { - this.onBlurPausedSounds.forEach(function (sound) - { - sound.onFocus(); - }); - - this.onBlurPausedSounds.length = 0; - }, - - /** - * Calls Phaser.Sound.BaseSoundManager#destroy method - * and cleans up all HTML5 Audio related stuff. - * - * @method Phaser.Sound.HTML5AudioSoundManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - BaseSoundManager.prototype.destroy.call(this); - - this.onBlurPausedSounds.length = 0; - this.onBlurPausedSounds = null; - }, - - /** - * Method used internally by Phaser.Sound.HTML5AudioSound class methods and property setters - * to check if sound manager is locked and then either perform action immediately or queue it - * to be performed once the sound manager gets unlocked. - * - * @method Phaser.Sound.HTML5AudioSoundManager#isLocked - * @protected - * @since 3.0.0 - * - * @param {Phaser.Sound.HTML5AudioSound} sound - Sound object on which to perform queued action. - * @param {string} prop - Name of the method to be called or property to be assigned a value to. - * @param {*} [value] - An optional parameter that either holds an array of arguments to be passed to the method call or value to be set to the property. - * - * @return {boolean} Whether the sound manager is locked. - */ - isLocked: function (sound, prop, value) - { - if (this.locked) - { - this.lockedActionsQueue.push({ - sound: sound, - prop: prop, - value: value - }); - - return true; - } - - return false; - }, - - /** - * @event Phaser.Sound.HTML5AudioSoundManager#MuteEvent - * @param {Phaser.Sound.HTML5AudioSoundManager} soundManager - Reference to the sound manager that emitted event. - * @param {boolean} value - An updated value of Phaser.Sound.HTML5AudioSoundManager#mute property. - */ - - /** - * @name Phaser.Sound.HTML5AudioSoundManager#mute - * @type {boolean} - * @fires Phaser.Sound.HTML5AudioSoundManager#MuteEvent - * @since 3.0.0 - */ - mute: { - - get: function () - { - return this._mute; - }, - - set: function (value) - { - this._mute = value; - - this.forEachActiveSound(function (sound) - { - sound.setMute(); - }); - - this.emit('mute', this, value); - } - - }, - - /** - * @event Phaser.Sound.HTML5AudioSoundManager#VolumeEvent - * @param {Phaser.Sound.HTML5AudioSoundManager} soundManager - Reference to the sound manager that emitted event. - * @param {number} value - An updated value of Phaser.Sound.HTML5AudioSoundManager#volume property. - */ - - /** - * @name Phaser.Sound.HTML5AudioSoundManager#volume - * @type {number} - * @fires Phaser.Sound.HTML5AudioSoundManager#VolumeEvent - * @since 3.0.0 - */ - volume: { - - get: function () - { - return this._volume; - }, - - set: function (value) - { - this._volume = value; - - this.forEachActiveSound(function (sound) - { - sound.setVolume(); - }); - - this.emit('volume', this, value); - } - - } - -}); - -module.exports = HTML5AudioSoundManager; +}; /***/ }), @@ -49916,8 +52858,3765 @@ module.exports = HTML5AudioSoundManager; * @copyright 2018 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ + +// Phaser.Math.Easing.Elastic + +module.exports = { + + In: __webpack_require__(736), + Out: __webpack_require__(735), + InOut: __webpack_require__(734) + +}; + + +/***/ }), +/* 259 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Phaser.Math.Easing.Cubic + +module.exports = { + + In: __webpack_require__(739), + Out: __webpack_require__(738), + InOut: __webpack_require__(737) + +}; + + +/***/ }), +/* 260 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Phaser.Math.Easing.Circular + +module.exports = { + + In: __webpack_require__(742), + Out: __webpack_require__(741), + InOut: __webpack_require__(740) + +}; + + +/***/ }), +/* 261 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Phaser.Math.Easing.Bounce + +module.exports = { + + In: __webpack_require__(745), + Out: __webpack_require__(744), + InOut: __webpack_require__(743) + +}; + + +/***/ }), +/* 262 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Phaser.Math.Easing.Back + +module.exports = { + + In: __webpack_require__(748), + Out: __webpack_require__(747), + InOut: __webpack_require__(746) + +}; + + +/***/ }), +/* 263 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.FloatBetween + * @since 3.0.0 + * + * @param {float} min - [description] + * @param {float} max - [description] + * + * @return {float} [description] + */ +var FloatBetween = function (min, max) +{ + return Math.random() * (max - min) + min; +}; + +module.exports = FloatBetween; + + +/***/ }), +/* 264 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetValue = __webpack_require__(5); +var Shuffle = __webpack_require__(102); + +var BuildChunk = function (a, b, qty) +{ + var out = []; + + for (var aIndex = 0; aIndex < a.length; aIndex++) + { + for (var bIndex = 0; bIndex < b.length; bIndex++) + { + for (var i = 0; i < qty; i++) + { + out.push({ a: a[aIndex], b: b[bIndex] }); + } + } + } + + return out; +}; + +// options = repeat, random, randomB, yoyo, max, qty + +// Range ([a,b,c], [1,2,3]) = +// a1, a2, a3, b1, b2, b3, c1, c2, c3 + +// Range ([a,b], [1,2,3], qty = 3) = +// a1, a1, a1, a2, a2, a2, a3, a3, a3, b1, b1, b1, b2, b2, b2, b3, b3, b3 + +// Range ([a,b,c], [1,2,3], repeat x1) = +// a1, a2, a3, b1, b2, b3, c1, c2, c3, a1, a2, a3, b1, b2, b3, c1, c2, c3 + +// Range ([a,b], [1,2], repeat -1 = endless, max = 14) = +// Maybe if max is set then repeat goes to -1 automatically? +// a1, a2, b1, b2, a1, a2, b1, b2, a1, a2, b1, b2, a1, a2 (capped at 14 elements) + +// Range ([a], [1,2,3,4,5], random = true) = +// a4, a1, a5, a2, a3 + +// Range ([a, b], [1,2,3], random = true) = +// b3, a2, a1, b1, a3, b2 + +// Range ([a, b, c], [1,2,3], randomB = true) = +// a3, a1, a2, b2, b3, b1, c1, c3, c2 + +// Range ([a], [1,2,3,4,5], yoyo = true) = +// a1, a2, a3, a4, a5, a5, a4, a3, a2, a1 + +// Range ([a, b], [1,2,3], yoyo = true) = +// a1, a2, a3, b1, b2, b3, b3, b2, b1, a3, a2, a1 + +/** + * [description] + * + * @function Phaser.Utils.Array.Range + * @since 3.0.0 + * + * @param {array} a - [description] + * @param {array} b - [description] + * @param {object} options - [description] + * + * @return {array} [description] + */ +var Range = function (a, b, options) +{ + var max = GetValue(options, 'max', 0); + var qty = GetValue(options, 'qty', 1); + var random = GetValue(options, 'random', false); + var randomB = GetValue(options, 'randomB', false); + var repeat = GetValue(options, 'repeat', 0); + var yoyo = GetValue(options, 'yoyo', false); + + var out = []; + + if (randomB) + { + Shuffle(b); + } + + // Endless repeat, so limit by max + if (repeat === -1) + { + if (max === 0) + { + repeat = 0; + } + else + { + // Work out how many repeats we need + var total = (a.length * b.length) * qty; + + if (yoyo) + { + total *= 2; + } + + repeat = Math.ceil(max / total); + } + } + + for (var i = 0; i <= repeat; i++) + { + var chunk = BuildChunk(a, b, qty); + + if (random) + { + Shuffle(chunk); + } + + out = out.concat(chunk); + + if (yoyo) + { + chunk.reverse(); + + out = out.concat(chunk); + } + } + + if (max) + { + out.splice(max); + } + + return out; +}; + +module.exports = Range; + + +/***/ }), +/* 265 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Commands = __webpack_require__(144); +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Graphics#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Graphics} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {CanvasRenderingContext2D} renderTargetCtx - [description] + * @param {boolean} allowClip - [description] + */ +var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, camera, renderTargetCtx, allowClip) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + var cameraScrollX = camera.scrollX * src.scrollFactorX; + var cameraScrollY = camera.scrollY * src.scrollFactorY; + var srcX = src.x; + var srcY = src.y; + var srcScaleX = src.scaleX; + var srcScaleY = src.scaleY; + var srcRotation = src.rotation; + var commandBuffer = src.commandBuffer; + var ctx = renderTargetCtx || renderer.currentContext; + var lineAlpha = 1.0; + var fillAlpha = 1.0; + var lineColor = 0; + var fillColor = 0; + var lineWidth = 1.0; + var red = 0; + var green = 0; + var blue = 0; + + // Blend Mode + if (renderer.currentBlendMode !== src.blendMode) + { + renderer.currentBlendMode = src.blendMode; + ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; + } + + // Alpha + if (renderer.currentAlpha !== src.alpha) + { + renderer.currentAlpha = src.alpha; + ctx.globalAlpha = src.alpha; + } + + // Smoothing + if (renderer.currentScaleMode !== src.scaleMode) + { + renderer.currentScaleMode = src.scaleMode; + } + + ctx.save(); + ctx.translate(srcX - cameraScrollX, srcY - cameraScrollY); + ctx.rotate(srcRotation); + ctx.scale(srcScaleX, srcScaleY); + ctx.fillStyle = '#fff'; + ctx.globalAlpha = src.alpha; + + for (var index = 0, length = commandBuffer.length; index < length; ++index) + { + var commandID = commandBuffer[index]; + + switch (commandID) + { + case Commands.ARC: + ctx.arc( + commandBuffer[index + 1], + commandBuffer[index + 2], + commandBuffer[index + 3], + commandBuffer[index + 4], + commandBuffer[index + 5], + commandBuffer[index + 6] + ); + index += 6; + break; + + case Commands.LINE_STYLE: + lineWidth = commandBuffer[index + 1]; + lineColor = commandBuffer[index + 2]; + lineAlpha = commandBuffer[index + 3]; + red = ((lineColor & 0xFF0000) >>> 16); + green = ((lineColor & 0xFF00) >>> 8); + blue = (lineColor & 0xFF); + ctx.strokeStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + lineAlpha + ')'; + ctx.lineWidth = lineWidth; + index += 3; + break; + + case Commands.FILL_STYLE: + fillColor = commandBuffer[index + 1]; + fillAlpha = commandBuffer[index + 2]; + red = ((fillColor & 0xFF0000) >>> 16); + green = ((fillColor & 0xFF00) >>> 8); + blue = (fillColor & 0xFF); + ctx.fillStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + fillAlpha + ')'; + index += 2; + break; + + case Commands.BEGIN_PATH: + ctx.beginPath(); + break; + + case Commands.CLOSE_PATH: + ctx.closePath(); + break; + + case Commands.FILL_PATH: + if (!allowClip) + { + ctx.fill(); + } + break; + + case Commands.STROKE_PATH: + if (!allowClip) + { + ctx.stroke(); + } + break; + + case Commands.FILL_RECT: + if (!allowClip) + { + ctx.fillRect( + commandBuffer[index + 1], + commandBuffer[index + 2], + commandBuffer[index + 3], + commandBuffer[index + 4] + ); + } + else + { + ctx.rect( + commandBuffer[index + 1], + commandBuffer[index + 2], + commandBuffer[index + 3], + commandBuffer[index + 4] + ); + } + index += 4; + break; + + case Commands.FILL_TRIANGLE: + ctx.beginPath(); + ctx.moveTo(commandBuffer[index + 1], commandBuffer[index + 2]); + ctx.lineTo(commandBuffer[index + 3], commandBuffer[index + 4]); + ctx.lineTo(commandBuffer[index + 5], commandBuffer[index + 6]); + ctx.closePath(); + if (!allowClip) + { + ctx.fill(); + } + index += 6; + break; + + case Commands.STROKE_TRIANGLE: + ctx.beginPath(); + ctx.moveTo(commandBuffer[index + 1], commandBuffer[index + 2]); + ctx.lineTo(commandBuffer[index + 3], commandBuffer[index + 4]); + ctx.lineTo(commandBuffer[index + 5], commandBuffer[index + 6]); + ctx.closePath(); + if (!allowClip) + { + ctx.stroke(); + } + index += 6; + break; + + case Commands.LINE_TO: + ctx.lineTo( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 2; + break; + + case Commands.MOVE_TO: + ctx.moveTo( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 2; + break; + + case Commands.LINE_FX_TO: + ctx.lineTo( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 5; + break; + + case Commands.MOVE_FX_TO: + ctx.moveTo( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 5; + break; + + case Commands.SAVE: + ctx.save(); + break; + + case Commands.RESTORE: + ctx.restore(); + break; + + case Commands.TRANSLATE: + ctx.translate( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 2; + break; + + case Commands.SCALE: + ctx.scale( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 2; + break; + + case Commands.ROTATE: + ctx.rotate( + commandBuffer[index + 1] + ); + index += 1; + break; + + default: + // console.error('Phaser: Invalid Graphics Command ID ' + commandID); + break; + } + } + + ctx.restore(); +}; + +module.exports = GraphicsCanvasRenderer; + + +/***/ }), +/* 266 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the circumference of the given Ellipse. + * + * @function Phaser.Geom.Ellipse.Circumference + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference of. + * + * @return {number} The circumference of th Ellipse. + */ +var Circumference = function (ellipse) +{ + var rx = ellipse.width / 2; + var ry = ellipse.height / 2; + var h = Math.pow((rx - ry), 2) / Math.pow((rx + ry), 2); + + return (Math.PI * (rx + ry)) * (1 + ((3 * h) / (10 + Math.sqrt(4 - (3 * h))))); +}; + +module.exports = Circumference; + + +/***/ }), +/* 267 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Circumference = __webpack_require__(266); +var CircumferencePoint = __webpack_require__(134); +var FromPercent = __webpack_require__(78); +var MATH_CONST = __webpack_require__(16); + +/** + * Returns an array of Point objects containing the coordinates of the points around the circumference of the Ellipse, + * based on the given quantity or stepRate values. + * + * @function Phaser.Geom.Ellipse.GetPoints + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the points from. + * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate. + * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. + * + * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the circumference of the ellipse. + */ +var GetPoints = function (ellipse, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) + { + quantity = Circumference(ellipse) / stepRate; + } + + for (var i = 0; i < quantity; i++) + { + var angle = FromPercent(i / quantity, 0, MATH_CONST.PI2); + + out.push(CircumferencePoint(ellipse, angle)); + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }), +/* 268 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CircumferencePoint = __webpack_require__(134); +var FromPercent = __webpack_require__(78); +var MATH_CONST = __webpack_require__(16); +var Point = __webpack_require__(4); + +/** + * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse + * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point + * at 180 degrees around the circle. + * + * @function Phaser.Geom.Ellipse.GetPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on. + * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. + * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. + * + * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the ellipse. + */ +var GetPoint = function (ellipse, position, out) +{ + if (out === undefined) { out = new Point(); } + + var angle = FromPercent(position, 0, MATH_CONST.PI2); + + return CircumferencePoint(ellipse, angle, out); +}; + +module.exports = GetPoint; + + +/***/ }), +/* 269 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Ellipse = __webpack_require__(135); + +Ellipse.Area = __webpack_require__(768); +Ellipse.Circumference = __webpack_require__(266); +Ellipse.CircumferencePoint = __webpack_require__(134); +Ellipse.Clone = __webpack_require__(767); +Ellipse.Contains = __webpack_require__(74); +Ellipse.ContainsPoint = __webpack_require__(766); +Ellipse.ContainsRect = __webpack_require__(765); +Ellipse.CopyFrom = __webpack_require__(764); +Ellipse.Equals = __webpack_require__(763); +Ellipse.GetBounds = __webpack_require__(762); +Ellipse.GetPoint = __webpack_require__(268); +Ellipse.GetPoints = __webpack_require__(267); +Ellipse.Offset = __webpack_require__(761); +Ellipse.OffsetPoint = __webpack_require__(760); +Ellipse.Random = __webpack_require__(162); + +module.exports = Ellipse; + + +/***/ }), +/* 270 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @function getValue + * @since 3.0.0 + * @private + */ +function getValue (node, attribute) +{ + return parseInt(node.getAttribute(attribute), 10); +} + +/** + * @function ParseXMLBitmapFont + * @since 3.0.0 + * @private + * + * @param {XMLDocument} xml - [description] + * @param {integer} [xSpacing=0] - [description] + * @param {integer} [ySpacing=0] - [description] + * @param {Phaser.Textures.Frame} [frame] - [description] + */ +var ParseXMLBitmapFont = function (xml, xSpacing, ySpacing, frame) +{ + if (xSpacing === undefined) { xSpacing = 0; } + if (ySpacing === undefined) { ySpacing = 0; } + + var data = {}; + var info = xml.getElementsByTagName('info')[0]; + var common = xml.getElementsByTagName('common')[0]; + + data.font = info.getAttribute('face'); + data.size = getValue(info, 'size'); + data.lineHeight = getValue(common, 'lineHeight') + ySpacing; + data.chars = {}; + + var letters = xml.getElementsByTagName('char'); + + var adjustForTrim = (frame !== undefined && frame.trimmed); + + if (adjustForTrim) + { + var top = frame.height; + var left = frame.width; + } + + for (var i = 0; i < letters.length; i++) + { + var node = letters[i]; + + var charCode = getValue(node, 'id'); + var gx = getValue(node, 'x'); + var gy = getValue(node, 'y'); + var gw = getValue(node, 'width'); + var gh = getValue(node, 'height'); + + // Handle frame trim issues + + if (adjustForTrim) + { + if (gx < left) + { + left = gx; + } + + if (gy < top) + { + top = gy; + } + } + + data.chars[charCode] = + { + x: gx, + y: gy, + width: gw, + height: gh, + centerX: Math.floor(gw / 2), + centerY: Math.floor(gh / 2), + xOffset: getValue(node, 'xoffset'), + yOffset: getValue(node, 'yoffset'), + xAdvance: getValue(node, 'xadvance') + xSpacing, + data: {}, + kerning: {} + }; + } + + if (adjustForTrim && top !== 0 && left !== 0) + { + // console.log('top and left', top, left, frame.x, frame.y); + + // Now we know the top and left coordinates of the glyphs in the original data + // so we can work out how much to adjust the glyphs by + + for (var code in data.chars) + { + var glyph = data.chars[code]; + + glyph.x -= frame.x; + glyph.y -= frame.y; + } + } + + var kernings = xml.getElementsByTagName('kerning'); + + for (i = 0; i < kernings.length; i++) + { + var kern = kernings[i]; + + var first = getValue(kern, 'first'); + var second = getValue(kern, 'second'); + var amount = getValue(kern, 'amount'); + + data.chars[second].kerning[first] = amount; + } + + return data; +}; + +module.exports = ParseXMLBitmapFont; + + +/***/ }), +/* 271 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function GetBitmapTextSize + * @since 3.0.0 + * @private + * + * @param {(Phaser.GameObjects.DynamicBitmapText|Phaser.GameObjects.BitmapText)} src - [description] + * @param {boolean} round - [description] + */ +var GetBitmapTextSize = function (src, round) +{ + var text = src.text; + var textLength = text.length; + + var bx = Number.MAX_VALUE; + var by = Number.MAX_VALUE; + var bw = 0; + var bh = 0; + + var chars = src.fontData.chars; + var lineHeight = src.fontData.lineHeight; + + var xAdvance = 0; + var yAdvance = 0; + + var indexCount = 0; + var charCode = 0; + + var glyph = null; + var glyphW = 0; + var glyphH = 0; + + var x = 0; + var y = 0; + + var lastGlyph = null; + var lastCharCode = 0; + + for (var index = 0; index < textLength; ++index) + { + charCode = text.charCodeAt(index); + + if (charCode === 10) + { + xAdvance = 0; + indexCount = 0; + yAdvance += lineHeight; + lastGlyph = null; + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + glyphW = glyph.width; + glyphH = glyph.height; + + x = indexCount + glyph.xOffset + xAdvance; + y = glyph.yOffset + yAdvance; + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + if (bx > x) + { + bx = x; + } + + if (by > y) + { + by = y; + } + + var gw = x + glyphW - bx; + var gh = y + glyphH - by; + + if (bw < gw) + { + bw = gw; + } + + if (bh < gh) + { + bh = gh; + } + + xAdvance += glyph.xAdvance; + indexCount += 1; + lastGlyph = glyph; + lastCharCode = charCode; + } + + var scale = (src.fontSize / src.fontData.size); + var sx = scale * src.scaleX; + var sy = scale * src.scaleY; + + var out = { + local: { + x: bx * scale, + y: by * scale, + width: bw * scale, + height: bh * scale + }, + global: { + x: src.x + (bx * sx), + y: src.y + (by * sy), + width: bw * sx, + height: bh * sy + } + }; + + if (round) + { + out.local.x = Math.round(out.local.x); + out.local.y = Math.round(out.local.y); + out.local.width = Math.round(out.local.width); + out.local.height = Math.round(out.local.height); + + out.global.x = Math.round(out.global.x); + out.global.y = Math.round(out.global.y); + out.global.width = Math.round(out.global.width); + out.global.height = Math.round(out.global.height); + } + + return out; +}; + +module.exports = GetBitmapTextSize; + + +/***/ }), +/* 272 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +//! stable.js 0.1.6, https://github.com/Two-Screen/stable +//! © 2017 Angry Bytes and contributors. MIT licensed. + +(function() { + +// A stable array sort, because `Array#sort()` is not guaranteed stable. +// This is an implementation of merge sort, without recursion. + +var stable = function(arr, comp) { + return exec(arr.slice(), comp); +}; + +stable.inplace = function(arr, comp) { + var result = exec(arr, comp); + + // This simply copies back if the result isn't in the original array, + // which happens on an odd number of passes. + if (result !== arr) { + pass(result, null, arr.length, arr); + } + + return arr; +}; + +// Execute the sort using the input array and a second buffer as work space. +// Returns one of those two, containing the final result. +function exec(arr, comp) { + if (typeof(comp) !== 'function') { + comp = function(a, b) { + return String(a).localeCompare(b); + }; + } + + // Short-circuit when there's nothing to sort. + var len = arr.length; + if (len <= 1) { + return arr; + } + + // Rather than dividing input, simply iterate chunks of 1, 2, 4, 8, etc. + // Chunks are the size of the left or right hand in merge sort. + // Stop when the left-hand covers all of the array. + var buffer = new Array(len); + for (var chk = 1; chk < len; chk *= 2) { + pass(arr, comp, chk, buffer); + + var tmp = arr; + arr = buffer; + buffer = tmp; + } + + return arr; +} + +// Run a single pass with the given chunk size. +var pass = function(arr, comp, chk, result) { + var len = arr.length; + var i = 0; + // Step size / double chunk size. + var dbl = chk * 2; + // Bounds of the left and right chunks. + var l, r, e; + // Iterators over the left and right chunk. + var li, ri; + + // Iterate over pairs of chunks. + for (l = 0; l < len; l += dbl) { + r = l + chk; + e = r + chk; + if (r > len) r = len; + if (e > len) e = len; + + // Iterate both chunks in parallel. + li = l; + ri = r; + while (true) { + // Compare the chunks. + if (li < r && ri < e) { + // This works for a regular `sort()` compatible comparator, + // but also for a simple comparator like: `a > b` + if (comp(arr[li], arr[ri]) <= 0) { + result[i++] = arr[li++]; + } + else { + result[i++] = arr[ri++]; + } + } + // Nothing to compare, just flush what's left. + else if (li < r) { + result[i++] = arr[li++]; + } + else if (ri < e) { + result[i++] = arr[ri++]; + } + // Both iterators are at the chunk ends. + else { + break; + } + } + } +}; + +// Export using CommonJS or to the window. +if (true) { + module.exports = stable; +} +else {} + +})(); + +/***/ }), +/* 273 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + var Class = __webpack_require__(0); -var BaseSound = __webpack_require__(85); +var CONST = __webpack_require__(21); +var IsSizePowerOfTwo = __webpack_require__(145); +var ScaleModes = __webpack_require__(80); + +/** + * @classdesc + * A Texture Source is the encapsulation of the actual source data for a Texture. + * This is typically an Image Element, loaded from the file system or network, or a Canvas Element. + * + * A Texture can contain multiple Texture Sources, which only happens when a multi-atlas is loaded. + * + * @class TextureSource + * @memberOf Phaser.Textures + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture this TextureSource belongs to. + * @param {(Image|HTMLCanvasElement)} source - The source image data. + * @param {integer} [width] - Optional width of the source image. If not given it's derived from the source itself. + * @param {integer} [height] - Optional height of the source image. If not given it's derived from the source itself. + */ +var TextureSource = new Class({ + + initialize: + + function TextureSource (texture, source, width, height) + { + var game = texture.manager.game; + + /** + * The Texture this TextureSource belongs to. + * + * @name Phaser.Textures.TextureSource#texture + * @type {string} + * @since 3.0.0 + */ + this.texture = texture; + + /** + * The source image data. This is either an Image Element, or a Canvas Element. + * + * @name Phaser.Textures.TextureSource#image + * @type {(HTMLImageElement|HTMLCanvasElement)} + * @since 3.0.0 + */ + this.image = source; + + /** + * Currently un-used. + * + * @name Phaser.Textures.TextureSource#compressionAlgorithm + * @type {integer} + * @default null + * @since 3.0.0 + */ + this.compressionAlgorithm = null; + + /** + * The resolution of the source image. + * + * @name Phaser.Textures.TextureSource#resolution + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.resolution = 1; + + /** + * The width of the source image. If not specified in the constructor it will check + * the `naturalWidth` and then `width` properties of the source image. + * + * @name Phaser.Textures.TextureSource#width + * @type {integer} + * @since 3.0.0 + */ + this.width = width || source.naturalWidth || source.width || 0; + + /** + * The height of the source image. If not specified in the constructor it will check + * the `naturalHeight` and then `height` properties of the source image. + * + * @name Phaser.Textures.TextureSource#height + * @type {integer} + * @since 3.0.0 + */ + this.height = height || source.naturalHeight || source.height || 0; + + /** + * The Scale Mode the image will use when rendering. + * Either Linear or Nearest. + * + * @name Phaser.Textures.TextureSource#scaleMode + * @type {number} + * @since 3.0.0 + */ + this.scaleMode = ScaleModes.DEFAULT; + + /** + * Is the source image a Canvas Element? + * + * @name Phaser.Textures.TextureSource#isCanvas + * @type {boolean} + * @since 3.0.0 + */ + this.isCanvas = (source instanceof HTMLCanvasElement); + + /** + * Are the source image dimensions a power of two? + * + * @name Phaser.Textures.TextureSource#isPowerOf2 + * @type {boolean} + * @since 3.0.0 + */ + this.isPowerOf2 = IsSizePowerOfTwo(this.width, this.height); + + /** + * The WebGL Texture of the source image. + * + * @name Phaser.Textures.TextureSource#glTexture + * @type {?WebGLTexture} + * @default null + * @since 3.0.0 + */ + this.glTexture = null; + + this.init(game); + }, + + /** + * Creates a WebGL Texture, if required, and sets the Texture filter mode. + * + * @method Phaser.Textures.TextureSource#init + * @since 3.0.0 + * + * @param {Phaser.Game} game - A reference to the Phaser Game instance. + */ + init: function (game) + { + if (game.config.renderType === CONST.WEBGL) + { + this.glTexture = game.renderer.createTextureFromSource(this.image, this.width, this.height, this.scaleMode); + } + + if (game.config.pixelArt) + { + this.setFilter(1); + } + }, + + /** + * Sets the Filter Mode for this Texture. + * + * The mode can be either Linear, the default, or Nearest. + * + * For pixel-art you should use Nearest. + * + * @method Phaser.Textures.TextureSource#setFilter + * @since 3.0.0 + * + * @param {(Phaser.Textures.LINEAR|Phaser.Textures.NEAREST)} filterMode - The Filter Mode. + */ + setFilter: function (filterMode) + { + var game = this.texture.manager.game; + + if (game.config.renderType === CONST.WEBGL) + { + game.renderer.setTextureFilter(this.glTexture, filterMode); + } + }, + + /** + * Destroys this Texture Source and nulls the source image reference. + * + * @method Phaser.Textures.TextureSource#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.texture = null; + + this.image = null; + } + +}); + +module.exports = TextureSource; + + +/***/ }), +/* 274 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Frame = __webpack_require__(141); +var TextureSource = __webpack_require__(273); + +/** + * @classdesc + * A Texture consists of a source, usually an Image from the Cache, or a Canvas, and a collection + * of Frames. The Frames represent the different areas of the Texture. For example a texture atlas + * may have many Frames, one for each element within the atlas. Where-as a single image would have + * just one frame, that encompasses the whole image. + * + * Textures are managed by the global TextureManager. This is a singleton class that is + * responsible for creating and delivering Textures and their corresponding Frames to Game Objects. + * + * Sprites and other Game Objects get the texture data they need from the TextureManager. + * + * @class Texture + * @memberOf Phaser.Textures + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Textures.TextureManager} manager - A reference to the Texture Manager this Texture belongs to. + * @param {string} key - The unique string-based key of this Texture. + * @param {(Image|HTMLCanvasElement)} source - The source that is used to create the texture. Usually an Image, but can also be a Canvas. + * @param {number} [width] - The width of the Texture. This is optional and automatically derived from the source images. + * @param {number} [height] - The height of the Texture. This is optional and automatically derived from the source images. + */ +var Texture = new Class({ + + initialize: + + function Texture (manager, key, source, width, height) + { + if (!Array.isArray(source)) + { + source = [ source ]; + } + + /** + * A reference to the Texture Manager this Texture belongs to. + * + * @name Phaser.Textures.Texture#manager + * @type {Phaser.Textures.TextureManager} + * @since 3.0.0 + */ + this.manager = manager; + + /** + * The unique string-based key of this Texture. + * + * @name Phaser.Textures.Texture#key + * @type {string} + * @since 3.0.0 + */ + this.key = key; + + /** + * An array of TextureSource instances. + * These are unique to this Texture and contain the actual Image (or Canvas) data. + * + * @name Phaser.Textures.Texture#source + * @type {Phaser.Textures.TextureSource[]} + * @since 3.0.0 + */ + this.source = []; + + /** + * An array of TextureSource data instances. + * Used to store additional data images, such as normal maps or specular maps. + * + * @name Phaser.Textures.Texture#dataSource + * @type {array} + * @since 3.0.0 + */ + this.dataSource = []; + + /** + * A key-value object pair associating the unique Frame keys with the Frames objects. + * + * @name Phaser.Textures.Texture#frames + * @type {object} + * @since 3.0.0 + */ + this.frames = {}; + + /** + * Any additional data that was set in the source JSON (if any), + * or any extra data you'd like to store relating to this texture + * + * @name Phaser.Textures.Texture#customData + * @type {object} + * @since 3.0.0 + */ + this.customData = {}; + + /** + * The name of the first frame of the Texture. + * + * @name Phaser.Textures.Texture#firstFrame + * @type {string} + * @since 3.0.0 + */ + this.firstFrame = '__BASE'; + + /** + * The total number of Frames in this Texture. + * + * @name Phaser.Textures.Texture#frameTotal + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.frameTotal = 0; + + // Load the Sources + for (var i = 0; i < source.length; i++) + { + this.source.push(new TextureSource(this, source[i], width, height)); + } + }, + + /** + * Adds a new Frame to this Texture. + * + * A Frame is a rectangular region of a TextureSource with a unique index or string-based key. + * + * @method Phaser.Textures.Texture#add + * @since 3.0.0 + * + * @param {(integer|string)} name - The name of this Frame. The name is unique within the Texture. + * @param {integer} sourceIndex - The index of the TextureSource that this Frame is a part of. + * @param {number} x - The x coordinate of the top-left of this Frame. + * @param {number} y - The y coordinate of the top-left of this Frame. + * @param {number} width - The width of this Frame. + * @param {number} height - The height of this Frame. + * + * @return {Phaser.Textures.Frame} The Frame that was added to this Texture. + */ + add: function (name, sourceIndex, x, y, width, height) + { + var frame = new Frame(this, name, sourceIndex, x, y, width, height); + + this.frames[name] = frame; + + // Set the first frame of the Texture (other than __BASE) + // This is used to ensure we don't spam the display with entire + // atlases of sprite sheets, but instead just the first frame of them + // should the dev incorrectly specify the frame index + if (this.frameTotal === 1) + { + this.firstFrame = name; + } + + this.frameTotal++; + + return frame; + }, + + /** + * Checks to see if a Frame matching the given key exists within this Texture. + * + * @method Phaser.Textures.Texture#has + * @since 3.0.0 + * + * @param {string} name - The key of the Frame to check for. + * + * @return {boolean} True if a Frame with the matching key exists in this Texture. + */ + has: function (name) + { + return (this.frames[name]); + }, + + /** + * Gets a Frame from this Texture based on either the key or the index of the Frame. + * + * In a Texture Atlas Frames are typically referenced by a key. + * In a Sprite Sheet Frames are referenced by an index. + * Passing no value for the name returns the base texture. + * + * @method Phaser.Textures.Texture#get + * @since 3.0.0 + * + * @param {(string|integer)} [name] - The string-based name, or integer based index, of the Frame to get from this Texture. + * + * @return {Phaser.Textures.Frame} The Texture Frame. + */ + get: function (name) + { + // null, undefined, empty string, zero + if (!name) + { + name = this.firstFrame; + } + + var frame = this.frames[name]; + + if (!frame) + { + console.warn('No Texture.frame found with name ' + name); + + frame = this.frames[this.firstFrame]; + } + + return frame; + }, + + /** + * Takes the given TextureSource and returns the index of it within this Texture. + * If it's not in this Texture, it returns -1. + * Unless this Texture has multiple TextureSources, such as with a multi-atlas, this + * method will always return zero or -1. + * + * @method Phaser.Textures.Texture#getTextureSourceIndex + * @since 3.0.0 + * + * @param {Phaser.Textures.TextureSource} source - The TextureSource to check. + * + * @return {integer} The index of the TextureSource within this Texture, or -1 if not in this Texture. + */ + getTextureSourceIndex: function (source) + { + for (var i = 0; i < this.source.length; i++) + { + if (this.source[i] === source) + { + return i; + } + } + + return -1; + }, + + /** + * Returns an array of all the Frames in the given TextureSource. + * + * @method Phaser.Textures.Texture#getFramesFromTextureSource + * @since 3.0.0 + * + * @param {integer} sourceIndex - The index of the TextureSource to get the Frames from. + * + * @return {Phaser.Textures.Frame[]} An array of Texture Frames. + */ + getFramesFromTextureSource: function (sourceIndex) + { + var out = []; + + for (var frameName in this.frames) + { + if (frameName === '__BASE') + { + continue; + } + + var frame = this.frames[frameName]; + + if (frame.sourceIndex === sourceIndex) + { + out.push(frame.name); + } + } + + return out; + }, + + /** + * Returns an array with all of the names of the Frames in this Texture. + * + * Useful if you want to randomly assign a Frame to a Game Object, as you can + * pick a random element from the returned array. + * + * @method Phaser.Textures.Texture#getFrameNames + * @since 3.0.0 + * + * @param {boolean} [includeBase=false] - Include the `__BASE` Frame in the output array? + * + * @return {string[]} An array of all Frame names in this Texture. + */ + getFrameNames: function (includeBase) + { + if (includeBase === undefined) { includeBase = false; } + + var out = Object.keys(this.frames); + + if (!includeBase) + { + var idx = out.indexOf('__BASE'); + + if (idx !== -1) + { + out.splice(idx, 1); + } + } + + return out; + }, + + /** + * Given a Frame name, return the source image it uses to render with. + * + * This will return the actual DOM Image or Canvas element. + * + * @method Phaser.Textures.Texture#getSourceImage + * @since 3.0.0 + * + * @param {(string|integer)} [name] - The string-based name, or integer based index, of the Frame to get from this Texture. + * + * @return {(HTMLImageElement|HTMLCanvasElement)} The DOM Image or Canvas Element. + */ + getSourceImage: function (name) + { + if (name === undefined || name === null || this.frameTotal === 1) + { + name = '__BASE'; + } + + var frame = this.frames[name]; + + if (!frame) + { + console.warn('No Texture.frame found with name ' + name); + + return this.frames['__BASE'].source.image; + } + else + { + return frame.source.image; + } + }, + + /** + * Adds a data source image to this Texture. + * + * An example of a data source image would be a normal map, where all of the Frames for this Texture + * equally apply to the normal map. + * + * @method Phaser.Textures.Texture#setDataSource + * @since 3.0.0 + * + * @param {(Image|HTMLCanvasElement)} data - The source image. + */ + setDataSource: function (data) + { + if (!Array.isArray(data)) + { + data = [ data ]; + } + + for (var i = 0; i < data.length; i++) + { + var source = this.source[i]; + + this.dataSource.push(new TextureSource(this, data[i], source.width, source.height)); + } + }, + + /** + * Sets the Filter Mode for this Texture. + * + * The mode can be either Linear, the default, or Nearest. + * + * For pixel-art you should use Nearest. + * + * The mode applies to the entire Texture, not just a specific Frame of it. + * + * @method Phaser.Textures.Texture#setFilter + * @since 3.0.0 + * + * @param {(Phaser.Textures.LINEAR|Phaser.Textures.NEAREST)} filterMode - The Filter Mode. + */ + setFilter: function (filterMode) + { + var i; + + for (i = 0; i < this.source.length; i++) + { + this.source[i].setFilter(filterMode); + } + + for (i = 0; i < this.dataSource.length; i++) + { + this.dataSource[i].setFilter(filterMode); + } + }, + + /** + * Destroys this Texture and releases references to its sources and frames. + * + * @method Phaser.Textures.Texture#destroy + * @since 3.0.0 + */ + destroy: function () + { + var i; + + for (i = 0; i < this.source.length; i++) + { + this.source[i].destroy(); + } + + for (i = 0; i < this.dataSource.length; i++) + { + this.dataSource[i].destroy(); + } + + for (var frameName in this.frames) + { + var frame = this.frames[frameName]; + + frame.destroy(); + } + + this.source = []; + this.dataSource = []; + this.frames = {}; + } + +}); + +module.exports = Texture; + + +/***/ }), +/* 275 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Textures.Parsers + */ + +module.exports = { + + Canvas: __webpack_require__(794), + Image: __webpack_require__(793), + JSONArray: __webpack_require__(792), + JSONHash: __webpack_require__(791), + Pyxel: __webpack_require__(790), + SpriteSheet: __webpack_require__(789), + SpriteSheetFromAtlas: __webpack_require__(788), + StarlingXML: __webpack_require__(787), + UnityYAML: __webpack_require__(786) + +}; + + +/***/ }), +/* 276 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasPool = __webpack_require__(23); +var Class = __webpack_require__(0); +var Color = __webpack_require__(41); +var EventEmitter = __webpack_require__(15); +var GenerateTexture = __webpack_require__(323); +var GetValue = __webpack_require__(5); +var Parser = __webpack_require__(275); +var Texture = __webpack_require__(274); + +/** + * @callback EachTextureCallback + * + * @param {Phaser.Textures.Texture} texture - [description] + * @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the child. + */ + +/** + * @classdesc + * Textures are managed by the global TextureManager. This is a singleton class that is + * responsible for creating and delivering Textures and their corresponding Frames to Game Objects. + * + * Sprites and other Game Objects get the texture data they need from the TextureManager. + * + * Access it via `scene.textures`. + * + * @class TextureManager + * @extends EventEmitter + * @memberOf Phaser.Textures + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - [description] + */ +var TextureManager = new Class({ + + Extends: EventEmitter, + + initialize: + + function TextureManager (game) + { + EventEmitter.call(this); + + /** + * [description] + * + * @name Phaser.Textures.TextureManager#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game = game; + + /** + * [description] + * + * @name Phaser.Textures.TextureManager#name + * @type {string} + * @since 3.0.0 + */ + this.name = 'TextureManager'; + + /** + * [description] + * + * @name Phaser.Textures.TextureManager#list + * @type {object} + * @default {} + * @since 3.0.0 + */ + this.list = {}; + + /** + * [description] + * + * @name Phaser.Textures.TextureManager#_tempCanvas + * @type {HTMLCanvasElement} + * @private + * @since 3.0.0 + */ + this._tempCanvas = CanvasPool.create2D(this, 1, 1); + + /** + * [description] + * + * @name Phaser.Textures.TextureManager#_tempContext + * @type {CanvasRenderingContext2D} + * @private + * @since 3.0.0 + */ + this._tempContext = this._tempCanvas.getContext('2d'); + + /** + * [description] + * + * @name Phaser.Textures.TextureManager#_pending + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + this._pending = 0; + + game.events.once('boot', this.boot, this); + }, + + /** + * [description] + * + * @method Phaser.Textures.TextureManager#boot + * @since 3.0.0 + */ + boot: function () + { + this._pending = 2; + + this.on('onload', this.updatePending, this); + this.on('onerror', this.updatePending, this); + + this.addBase64('__DEFAULT', this.game.config.defaultImage); + this.addBase64('__MISSING', this.game.config.missingImage); + + this.game.events.once('destroy', this.destroy, this); + }, + + /** + * [description] + * + * @method Phaser.Textures.TextureManager#updatePending + * @since 3.0.0 + */ + updatePending: function () + { + this._pending--; + + if (this._pending === 0) + { + this.off('onload'); + this.off('onerror'); + + this.game.events.emit('ready'); + } + }, + + /** + * Adds a new Texture to the Texture Manager created from the given Base64 encoded data. + * + * @method Phaser.Textures.TextureManager#addBase64 + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {*} data - The Base64 encoded data. + */ + addBase64: function (key, data) + { + var _this = this; + + var image = new Image(); + + image.onerror = function () + { + _this.emit('onerror', key); + }; + + image.onload = function () + { + var texture = _this.create(key, image); + + Parser.Image(texture, 0); + + _this.emit('onload', key, texture); + }; + + image.src = data; + }, + + /** + * Adds a new Texture to the Texture Manager created from the given Image element. + * + * @method Phaser.Textures.TextureManager#addImage + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {HTMLImageElement} [dataSource] - An optional data Image element. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + addImage: function (key, source, dataSource) + { + var texture = this.create(key, source); + + Parser.Image(texture, 0); + + if (dataSource) + { + texture.setDataSource(dataSource); + } + + return texture; + }, + + /** + * Creates a new Texture using the given config values. + * Generated textures consist of a Canvas element to which the texture data is drawn. + * See the Phaser.Create function for the more direct way to create textures. + * + * @method Phaser.Textures.TextureManager#generate + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {object} config - [description] + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + generate: function (key, config) + { + var canvas = CanvasPool.create(this, 1, 1); + + config.canvas = canvas; + + GenerateTexture(config); + + return this.addCanvas(key, canvas); + }, + + /** + * Creates a new Texture using a blank Canvas element of the size given. + * + * Canvas elements are automatically pooled and calling this method will + * extract a free canvas from the CanvasPool, or create one if none are available. + * + * @method Phaser.Textures.TextureManager#createCanvas + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {integer} width - The width of the Canvas element. + * @param {integer} height - The height of the Canvas element. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + createCanvas: function (key, width, height) + { + if (width === undefined) { width = 256; } + if (height === undefined) { height = 256; } + + var canvas = CanvasPool.create(this, width, height); + + return this.addCanvas(key, canvas); + }, + + /** + * Creates a new Texture object from an existing Canvas element and adds + * it to this Texture Manager. + * + * @method Phaser.Textures.TextureManager#addCanvas + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLCanvasElement} source - The Canvas element to form the base of the new Texture. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + addCanvas: function (key, source) + { + var texture = this.create(key, source); + + Parser.Canvas(texture, 0); + + return texture; + }, + + /** + * Adds a new Texture Atlas to this Texture Manager. + * It can accept either JSON Array or JSON Hash formats, as exported by Texture Packer and similar software. + * + * @method Phaser.Textures.TextureManager#addAtlas + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {object} data - The Texture Atlas data. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + addAtlas: function (key, source, data) + { + // New Texture Packer format? + if (Array.isArray(data.textures) || Array.isArray(data.frames)) + { + return this.addAtlasJSONArray(key, source, data); + } + else + { + return this.addAtlasJSONHash(key, source, data); + } + }, + + /** + * Adds a Texture Atlas to this Texture Manager. + * The frame data of the atlas must be stored in an Array within the JSON. + * This is known as a JSON Array in software such as Texture Packer. + * + * @method Phaser.Textures.TextureManager#addAtlasJSONArray + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {object} data - The Texture Atlas data. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + addAtlasJSONArray: function (key, source, data) + { + var texture = this.create(key, source); + + if (Array.isArray(data)) + { + var singleAtlasFile = (data.length === 1); // multi-pack with one atlas file for all images + for (var i = 0; i < texture.source.length; i++) + { + var atlasData = singleAtlasFile ? data[0] : data[i]; + Parser.JSONArray(texture, i, atlasData); + } + } + else + { + Parser.JSONArray(texture, 0, data); + } + + return texture; + }, + + /** + * Adds a Texture Atlas to this Texture Manager. + * The frame data of the atlas must be stored in an Object within the JSON. + * This is known as a JSON Hash in software such as Texture Packer. + * + * @method Phaser.Textures.TextureManager#addAtlasJSONHash + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {object} data - The Texture Atlas data. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + addAtlasJSONHash: function (key, source, data) + { + var texture = this.create(key, source); + + if (Array.isArray(data)) + { + for (var i = 0; i < data.length; i++) + { + Parser.JSONHash(texture, i, data[i]); + } + } + else + { + Parser.JSONHash(texture, 0, data); + } + + return texture; + }, + + /** + * Adds a Unity Texture Atlas to this Texture Manager. + * The data must be in the form of a Unity YAML file. + * + * @method Phaser.Textures.TextureManager#addUnityAtlas + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {object} data - The Texture Atlas data. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + addUnityAtlas: function (key, source, data) + { + var texture = this.create(key, source); + + Parser.UnityYAML(texture, 0, data); + + return texture; + }, + + /** + * Adds a Sprite Sheet to this Texture Manager. + * + * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact + * same size and cannot be trimmed or rotated. + * + * @method Phaser.Textures.TextureManager#addSpriteSheet + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {object} config - The configuration object for this Sprite Sheet. + * @param {integer} config.frameWidth - The fixed width of each frame. + * @param {integer} [config.frameHeight] - The fixed height of each frame. If not set it will use the frameWidth as the height. + * @param {integer} [config.startFrame=0] - Skip a number of frames. Useful when there are multiple sprite sheets in one Texture. + * @param {integer} [config.endFrame=-1] - The total number of frames to extract from the Sprite Sheet. The default value of -1 means "extract all frames". + * @param {integer} [config.margin=0] - If the frames have been drawn with a margin, specify the amount here. + * @param {integer} [config.spacing=0] - If the frames have been drawn with spacing between them, specify the amount here. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + addSpriteSheet: function (key, source, config) + { + var texture = this.create(key, source); + + var width = texture.source[0].width; + var height = texture.source[0].height; + + Parser.SpriteSheet(texture, 0, 0, 0, width, height, config); + + return texture; + }, + + /** + * Adds a Sprite Sheet to this Texture Manager, where the Sprite Sheet exists as a Frame within a Texture Atlas. + * + * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact + * same size and cannot be trimmed or rotated. + * + * @method Phaser.Textures.TextureManager#addSpriteSheetFromAtlas + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {object} config - The configuration object for this Sprite Sheet. + * @param {string} config.atlas - The key of the Texture Atlas in which this Sprite Sheet can be found. + * @param {string} config.frame - The key of the Texture Atlas Frame in which this Sprite Sheet can be found. + * @param {integer} config.frameWidth - The fixed width of each frame. + * @param {integer} [config.frameHeight] - The fixed height of each frame. If not set it will use the frameWidth as the height. + * @param {integer} [config.startFrame=0] - Skip a number of frames. Useful when there are multiple sprite sheets in one Texture. + * @param {integer} [config.endFrame=-1] - The total number of frames to extract from the Sprite Sheet. The default value of -1 means "extract all frames". + * @param {integer} [config.margin=0] - If the frames have been drawn with a margin, specify the amount here. + * @param {integer} [config.spacing=0] - If the frames have been drawn with spacing between them, specify the amount here. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + addSpriteSheetFromAtlas: function (key, config) + { + var atlasKey = GetValue(config, 'atlas', null); + var atlasFrame = GetValue(config, 'frame', null); + + if (!atlasKey || !atlasFrame) + { + return; + } + + var atlas = this.get(atlasKey); + var sheet = atlas.get(atlasFrame); + + if (sheet) + { + var texture = this.create(key, sheet.source.image); + + if (sheet.trimmed) + { + // If trimmed we need to help the parser adjust + Parser.SpriteSheetFromAtlas(texture, sheet, config); + } + else + { + Parser.SpriteSheet(texture, 0, sheet.cutX, sheet.cutY, sheet.cutWidth, sheet.cutHeight, config); + } + + return texture; + } + }, + + /** + * Adds a Texture Atlas to this Texture Manager, where the atlas data is given + * in the Starling XML format. + * + * @method Phaser.Textures.TextureManager#addAtlasStarlingXML + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {object} data - The Texture Atlas XML data. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + addAtlasStarlingXML: function (key, source, data) + { + var texture = this.create(key, source); + + if (Array.isArray(data)) + { + for (var i = 0; i < data.length; i++) + { + Parser.StarlingXML(texture, i, data[i]); + } + } + else + { + Parser.StarlingXML(texture, 0, data); + } + + return texture; + }, + + /** + * Adds a Texture Atlas to this Texture Manager, where the atlas data is given + * in the Pyxel JSON format. + * + * @method Phaser.Textures.TextureManager#addAtlasPyxel + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {object} data - The Texture Atlas XML data. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + addAtlasPyxel: function (key, source, data) + { + var texture = this.create(key, source); + + if (Array.isArray(data)) + { + for (var i = 0; i < data.length; i++) + { + Parser.Pyxel(texture, i, data[i]); + } + } + else + { + Parser.Pyxel(texture, 0, data); + } + + return texture; + }, + + /** + * Creates a new Texture using the given source and dimensions. + * + * @method Phaser.Textures.TextureManager#create + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {integer} width - The width of the Texture. + * @param {integer} height - The height of the Texture. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + create: function (key, source, width, height) + { + var texture = new Texture(this, key, source, width, height); + + this.list[key] = texture; + + return texture; + }, + + /** + * Checks the given key to see if a Texture using it exists within this Texture Manager. + * + * @method Phaser.Textures.TextureManager#exists + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * + * @return {boolean} Returns `true` if a Texture matching the given key exists in this Texture Manager. + */ + exists: function (key) + { + return (this.list.hasOwnProperty(key)); + }, + + /** + * Returns a Texture from the Texture Manager that matches the given key. + * If the key is undefined it will return the `__DEFAULT` Texture. + * If the key is given, but not found, it will return the `__MISSING` Texture. + * + * @method Phaser.Textures.TextureManager#get + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + get: function (key) + { + if (key === undefined) { key = '__DEFAULT'; } + + if (this.list[key]) + { + return this.list[key]; + } + else + { + return this.list['__MISSING']; + } + }, + + /** + * Takes a Texture key and Frame name and returns a clone of that Frame if found. + * + * @method Phaser.Textures.TextureManager#cloneFrame + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {(string|integer)} frame - The string or index of the Frame to be cloned. + * + * @return {Phaser.Textures.Frame} A Clone of the given Frame. + */ + cloneFrame: function (key, frame) + { + if (this.list[key]) + { + return this.list[key].get(frame).clone(); + } + }, + + /** + * Takes a Texture key and Frame name and returns a reference to that Frame, if found. + * + * @method Phaser.Textures.TextureManager#getFrame + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {(string|integer)} frame - The string or index of the Frame. + * + * @return {Phaser.Textures.Frame} A Texture Frame object. + */ + getFrame: function (key, frame) + { + if (this.list[key]) + { + return this.list[key].get(frame); + } + }, + + /** + * Returns an array with all of the keys of all Textures in this Texture Manager. + * The output array will exclude the `__DEFAULT` and `__MISSING` keys. + * + * @method Phaser.Textures.TextureManager#getTextureKeys + * @since 3.0.0 + * + * @return {string[]} An array containing all of the Texture keys stored in this Texture Manager. + */ + getTextureKeys: function () + { + var output = []; + + for (var key in this.list) + { + if (key !== '__DEFAULT' && key !== '__MISSING') + { + output.push(key); + } + } + + return output; + }, + + /** + * Given a Texture and an `x` and `y` coordinate this method will return a new + * Color object that has been populated with the color and alpha values of the pixel + * at that location in the Texture. + * + * @method Phaser.Textures.TextureManager#getPixel + * @since 3.0.0 + * + * @param {integer} x - The x coordinate of the pixel within the Texture. + * @param {integer} y - The y coordinate of the pixel within the Texture. + * @param {string} key - The unique string-based key of the Texture. + * @param {(string|integer)} frame - The string or index of the Frame. + * + * @return {?Phaser.Display.Color} A Color object populated with the color values of the requested pixel, + * or `null` if the coordinates were out of bounds. + */ + getPixel: function (x, y, key, frame) + { + var textureFrame = this.getFrame(key, frame); + + if (textureFrame) + { + var source = textureFrame.source.image; + + if (x >= 0 && x <= source.width && y >= 0 && y <= source.height) + { + x += textureFrame.cutX; + y += textureFrame.cutY; + + // if (textureFrame.trimmed) + // { + // x -= this.sprite.texture.trim.x; + // y -= this.sprite.texture.trim.y; + // } + + var context = this._tempContext; + + context.clearRect(0, 0, 1, 1); + context.drawImage(source, x, y, 1, 1, 0, 0, 1, 1); + + var rgb = context.getImageData(0, 0, 1, 1); + + return new Color(rgb.data[0], rgb.data[1], rgb.data[2], rgb.data[3]); + } + } + + return null; + }, + + /** + * Sets the given Game Objects `texture` and `frame` properties so that it uses + * the Texture and Frame specified in the `key` and `frame` arguments to this method. + * + * @method Phaser.Textures.TextureManager#setTexture + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * @param {string} key - The unique string-based key of the Texture. + * @param {(string|integer)} frame - The string or index of the Frame. + * + * @return {Phaser.GameObjects.GameObject} The Game Object the texture was set on. + */ + setTexture: function (gameObject, key, frame) + { + if (this.list[key]) + { + gameObject.texture = this.list[key]; + gameObject.frame = gameObject.texture.get(frame); + } + + return gameObject; + }, + + /** + * Passes all Textures to the given callback. + * + * @method Phaser.Textures.TextureManager#each + * @since 3.0.0 + * + * @param {EachTextureCallback} callback - The callback function to be sent the Textures. + * @param {object} scope - The value to use as `this` when executing the callback. + * @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the child. + */ + each: function (callback, scope) + { + var args = [ null ]; + + for (var i = 1; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (var texture in this.list) + { + args[0] = this.list[texture]; + + callback.apply(scope, args); + } + }, + + /** + * Destroys the Texture Manager and all Textures stored within it. + * + * @method Phaser.Textures.TextureManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + for (var texture in this.list) + { + this.list[texture].destroy(); + } + + this.list = {}; + + this.game = null; + } + +}); + +module.exports = TextureManager; + + +/***/ }), +/* 277 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ +var Class = __webpack_require__(0); +var BaseSound = __webpack_require__(98); + +/** + * @classdesc + * Web Audio API implementation of the sound. + * + * @class WebAudioSound + * @extends Phaser.Sound.BaseSound + * @memberOf Phaser.Sound + * @constructor + * @author Pavle Goloskokovic (http://prunegames.com) + * @since 3.0.0 + * + * @param {Phaser.Sound.WebAudioSoundManager} manager - Reference to the current sound manager instance. + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config={}] - An optional config object containing default sound settings. + */ +var WebAudioSound = new Class({ + Extends: BaseSound, + initialize: function WebAudioSound (manager, key, config) + { + if (config === void 0) { config = {}; } + + /** + * Audio buffer containing decoded data of the audio asset to be played. + * + * @name Phaser.Sound.WebAudioSound#audioBuffer + * @type {AudioBuffer} + * @private + * @since 3.0.0 + */ + this.audioBuffer = manager.game.cache.audio.get(key); + if (!this.audioBuffer) + { + // eslint-disable-next-line no-console + console.error('No audio loaded in cache with key: \'' + key + '\'!'); + return; + } + + /** + * A reference to an audio source node used for playing back audio from + * audio data stored in Phaser.Sound.WebAudioSound#audioBuffer. + * + * @name Phaser.Sound.WebAudioSound#source + * @type {AudioBufferSourceNode} + * @private + * @default null + * @since 3.0.0 + */ + this.source = null; + + /** + * A reference to a second audio source used for gapless looped playback. + * + * @name Phaser.Sound.WebAudioSound#loopSource + * @type {AudioBufferSourceNode} + * @private + * @default null + * @since 3.0.0 + */ + this.loopSource = null; + + /** + * Gain node responsible for controlling this sound's muting. + * + * @name Phaser.Sound.WebAudioSound#muteNode + * @type {GainNode} + * @private + * @since 3.0.0 + */ + this.muteNode = manager.context.createGain(); + + /** + * Gain node responsible for controlling this sound's volume. + * + * @name Phaser.Sound.WebAudioSound#volumeNode + * @type {GainNode} + * @private + * @since 3.0.0 + */ + this.volumeNode = manager.context.createGain(); + + /** + * The time at which the sound should have started playback from the beginning. + * Based on BaseAudioContext.currentTime value. + * + * @name Phaser.Sound.WebAudioSound#playTime + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.playTime = 0; + + /** + * The time at which the sound source should have actually started playback. + * Based on BaseAudioContext.currentTime value. + * + * @name Phaser.Sound.WebAudioSound#startTime + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.startTime = 0; + + /** + * The time at which the sound loop source should actually start playback. + * Based on BaseAudioContext.currentTime value. + * + * @name Phaser.Sound.WebAudioSound#loopTime + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.loopTime = 0; + + /** + * An array where we keep track of all rate updates during playback. + * Array of object types: { time: number, rate: number } + * + * @name Phaser.Sound.WebAudioSound#rateUpdates + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this.rateUpdates = []; + + /** + * Used for keeping track when sound source playback has ended + * so its state can be updated accordingly. + * + * @name Phaser.Sound.WebAudioSound#hasEnded + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this.hasEnded = false; + + /** + * Used for keeping track when sound source has looped + * so its state can be updated accordingly. + * + * @name Phaser.Sound.WebAudioSound#hasLooped + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this.hasLooped = false; + this.muteNode.connect(this.volumeNode); + this.volumeNode.connect(manager.destination); + this.duration = this.audioBuffer.duration; + this.totalDuration = this.audioBuffer.duration; + BaseSound.call(this, manager, key, config); + }, + + /** + * Play this sound, or a marked section of it. + * It always plays the sound from the start. If you want to start playback from a specific time + * you can set 'seek' setting of the config object, provided to this call, to that value. + * + * @method Phaser.Sound.WebAudioSound#play + * @since 3.0.0 + * + * @param {string} [markerName=''] - If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. + * @param {SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. + * + * @return {boolean} Whether the sound started playing successfully. + */ + play: function (markerName, config) + { + if (!BaseSound.prototype.play.call(this, markerName, config)) + { + return false; + } + + // \/\/\/ isPlaying = true, isPaused = false \/\/\/ + this.stopAndRemoveBufferSource(); + this.createAndStartBufferSource(); + + /** + * @event Phaser.Sound.WebAudioSound#play + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + */ + this.emit('play', this); + return true; + }, + + /** + * Pauses the sound. + * + * @method Phaser.Sound.WebAudioSound#pause + * @since 3.0.0 + * + * @return {boolean} Whether the sound was paused successfully. + */ + pause: function () + { + if (this.manager.context.currentTime < this.startTime) + { + return false; + } + if (!BaseSound.prototype.pause.call(this)) + { + return false; + } + + // \/\/\/ isPlaying = false, isPaused = true \/\/\/ + this.currentConfig.seek = this.getCurrentTime(); // Equivalent to setting paused time + this.stopAndRemoveBufferSource(); + + /** + * @event Phaser.Sound.WebAudioSound#pause + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + */ + this.emit('pause', this); + return true; + }, + + /** + * Resumes the sound. + * + * @method Phaser.Sound.WebAudioSound#resume + * @since 3.0.0 + * + * @return {boolean} Whether the sound was resumed successfully. + */ + resume: function () + { + if (this.manager.context.currentTime < this.startTime) + { + return false; + } + if (!BaseSound.prototype.resume.call(this)) + { + return false; + } + + // \/\/\/ isPlaying = true, isPaused = false \/\/\/ + this.createAndStartBufferSource(); + + /** + * @event Phaser.Sound.WebAudioSound#resume + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + */ + this.emit('resume', this); + return true; + }, + + /** + * Stop playing this sound. + * + * @method Phaser.Sound.WebAudioSound#stop + * @since 3.0.0 + * + * @return {boolean} Whether the sound was stopped successfully. + */ + stop: function () + { + if (!BaseSound.prototype.stop.call(this)) + { + return false; + } + + // \/\/\/ isPlaying = false, isPaused = false \/\/\/ + this.stopAndRemoveBufferSource(); + + /** + * @event Phaser.Sound.WebAudioSound#stop + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + */ + this.emit('stop', this); + return true; + }, + + /** + * Used internally to do what the name says. + * + * @method Phaser.Sound.WebAudioSound#createAndStartBufferSource + * @private + * @since 3.0.0 + */ + createAndStartBufferSource: function () + { + var seek = this.currentConfig.seek; + var delay = this.currentConfig.delay; + var when = this.manager.context.currentTime + delay; + var offset = (this.currentMarker ? this.currentMarker.start : 0) + seek; + var duration = this.duration - seek; + this.playTime = when - seek; + this.startTime = when; + this.source = this.createBufferSource(); + this.applyConfig(); + this.source.start(Math.max(0, when), Math.max(0, offset), Math.max(0, duration)); + this.resetConfig(); + }, + + /** + * Used internally to do what the name says. + * + * @method Phaser.Sound.WebAudioSound#createAndStartLoopBufferSource + * @private + * @since 3.0.0 + */ + createAndStartLoopBufferSource: function () + { + var when = this.getLoopTime(); + var offset = this.currentMarker ? this.currentMarker.start : 0; + var duration = this.duration; + this.loopTime = when; + this.loopSource = this.createBufferSource(); + this.loopSource.playbackRate.setValueAtTime(this.totalRate, 0); + this.loopSource.start(Math.max(0, when), Math.max(0, offset), Math.max(0, duration)); + }, + + /** + * Used internally to do what the name says. + * + * @method Phaser.Sound.WebAudioSound#createBufferSource + * @private + * @since 3.0.0 + * + * @return {AudioBufferSourceNode} + */ + createBufferSource: function () + { + var _this = this; + var source = this.manager.context.createBufferSource(); + source.buffer = this.audioBuffer; + source.connect(this.muteNode); + source.onended = function (ev) + { + if (ev.target === _this.source) + { + // sound ended + if (_this.currentConfig.loop) + { + _this.hasLooped = true; + } + else + { + _this.hasEnded = true; + } + } + + // else was stopped + }; + return source; + }, + + /** + * Used internally to do what the name says. + * + * @method Phaser.Sound.WebAudioSound#stopAndRemoveBufferSource + * @private + * @since 3.0.0 + */ + stopAndRemoveBufferSource: function () + { + if (this.source) + { + this.source.stop(); + this.source.disconnect(); + this.source = null; + } + this.playTime = 0; + this.startTime = 0; + this.stopAndRemoveLoopBufferSource(); + }, + + /** + * Used internally to do what the name says. + * + * @method Phaser.Sound.WebAudioSound#stopAndRemoveLoopBufferSource + * @private + * @since 3.0.0 + */ + stopAndRemoveLoopBufferSource: function () + { + if (this.loopSource) + { + this.loopSource.stop(); + this.loopSource.disconnect(); + this.loopSource = null; + } + this.loopTime = 0; + }, + + /** + * Method used internally for applying config values to some of the sound properties. + * + * @method Phaser.Sound.WebAudioSound#applyConfig + * @protected + * @since 3.0.0 + */ + applyConfig: function () + { + this.rateUpdates.length = 0; + this.rateUpdates.push({ + time: 0, + rate: 1 + }); + BaseSound.prototype.applyConfig.call(this); + }, + + /** + * Update method called automatically by sound manager on every game step. + * + * @method Phaser.Sound.WebAudioSound#update + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time elapsed since the last frame. + */ + // eslint-disable-next-line no-unused-vars + update: function (time, delta) + { + if (this.hasEnded) + { + this.hasEnded = false; + BaseSound.prototype.stop.call(this); + this.stopAndRemoveBufferSource(); + + /** + * @event Phaser.Sound.WebAudioSound#ended + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + */ + this.emit('ended', this); + } + else if (this.hasLooped) + { + this.hasLooped = false; + this.source = this.loopSource; + this.loopSource = null; + this.playTime = this.startTime = this.loopTime; + this.rateUpdates.length = 0; + this.rateUpdates.push({ + time: 0, + rate: this.totalRate + }); + this.createAndStartLoopBufferSource(); + + /** + * @event Phaser.Sound.WebAudioSound#looped + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + */ + this.emit('looped', this); + } + }, + + /** + * Calls Phaser.Sound.BaseSound#destroy method + * and cleans up all Web Audio API related stuff. + * + * @method Phaser.Sound.WebAudioSound#destroy + * @since 3.0.0 + */ + destroy: function () + { + BaseSound.prototype.destroy.call(this); + this.audioBuffer = null; + this.stopAndRemoveBufferSource(); + this.muteNode.disconnect(); + this.muteNode = null; + this.volumeNode.disconnect(); + this.volumeNode = null; + this.rateUpdates.length = 0; + this.rateUpdates = null; + }, + + /** + * Method used internally to calculate total playback rate of the sound. + * + * @method Phaser.Sound.WebAudioSound#setRate + * @protected + * @since 3.0.0 + */ + setRate: function () + { + BaseSound.prototype.setRate.call(this); + var now = this.manager.context.currentTime; + if (this.source) + { + this.source.playbackRate.setValueAtTime(this.totalRate, now); + } + if (this.isPlaying) + { + this.rateUpdates.push({ + time: Math.max(this.startTime, now) - this.playTime, + rate: this.totalRate + }); + if (this.loopSource) + { + this.stopAndRemoveLoopBufferSource(); + this.createAndStartLoopBufferSource(); + } + } + }, + + /** + * Method used internally for calculating current playback time of a playing sound. + * + * @method Phaser.Sound.WebAudioSound#getCurrentTime + * @private + * @since 3.0.0 + */ + getCurrentTime: function () + { + var currentTime = 0; + for (var i = 0; i < this.rateUpdates.length; i++) + { + var nextTime = void 0; + if (i < this.rateUpdates.length - 1) + { + nextTime = this.rateUpdates[i + 1].time; + } + else + { + nextTime = this.manager.context.currentTime - this.playTime; + } + currentTime += (nextTime - this.rateUpdates[i].time) * this.rateUpdates[i].rate; + } + return currentTime; + }, + + /** + * Method used internally for calculating the time + * at witch the loop source should start playing. + * + * @method Phaser.Sound.WebAudioSound#getLoopTime + * @private + * @since 3.0.0 + */ + getLoopTime: function () + { + var lastRateUpdateCurrentTime = 0; + for (var i = 0; i < this.rateUpdates.length - 1; i++) + { + lastRateUpdateCurrentTime += + (this.rateUpdates[i + 1].time - this.rateUpdates[i].time) * this.rateUpdates[i].rate; + } + var lastRateUpdate = this.rateUpdates[this.rateUpdates.length - 1]; + return this.playTime + lastRateUpdate.time + + (this.duration - lastRateUpdateCurrentTime) / lastRateUpdate.rate; + } +}); +Object.defineProperty(WebAudioSound.prototype, 'mute', { + get: function () + { + return this.muteNode.gain.value === 0; + }, + set: function (value) + { + this.currentConfig.mute = value; + this.muteNode.gain.setValueAtTime(value ? 0 : 1, 0); + + /** + * @event Phaser.Sound.WebAudioSound#mute + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + * @param {boolean} value - An updated value of Phaser.Sound.WebAudioSound#mute property. + */ + this.emit('mute', this, value); + } +}); +Object.defineProperty(WebAudioSound.prototype, 'volume', { + get: function () + { + return this.volumeNode.gain.value; + }, + set: function (value) + { + this.currentConfig.volume = value; + this.volumeNode.gain.setValueAtTime(value, 0); + + /** + * @event Phaser.Sound.WebAudioSound#volume + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + * @param {number} value - An updated value of Phaser.Sound.WebAudioSound#volume property. + */ + this.emit('volume', this, value); + } +}); +Object.defineProperty(WebAudioSound.prototype, 'seek', { + get: function () + { + if (this.isPlaying) + { + if (this.manager.context.currentTime < this.startTime) + { + return this.startTime - this.playTime; + } + return this.getCurrentTime(); + } + else if (this.isPaused) + { + return this.currentConfig.seek; + } + else + { + return 0; + } + }, + set: function (value) + { + if (this.manager.context.currentTime < this.startTime) + { + return; + } + if (this.isPlaying || this.isPaused) + { + value = Math.min(Math.max(0, value), this.duration); + this.currentConfig.seek = value; + if (this.isPlaying) + { + this.stopAndRemoveBufferSource(); + this.createAndStartBufferSource(); + } + + /** + * @event Phaser.Sound.WebAudioSound#seek + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + * @param {number} value - An updated value of Phaser.Sound.WebAudioSound#seek property. + */ + this.emit('seek', this, value); + } + } +}); +Object.defineProperty(WebAudioSound.prototype, 'loop', { + get: function () + { + return this.currentConfig.loop; + }, + set: function (value) + { + this.currentConfig.loop = value; + if (this.isPlaying) + { + this.stopAndRemoveLoopBufferSource(); + if (value) + { + this.createAndStartLoopBufferSource(); + } + } + + /** + * @event Phaser.Sound.WebAudioSound#loop + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + * @param {boolean} value - An updated value of Phaser.Sound.WebAudioSound#loop property. + */ + this.emit('loop', this, value); + } +}); +module.exports = WebAudioSound; + + +/***/ }), +/* 278 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Pavle Goloskokovic (http://prunegames.com) + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BaseSoundManager = __webpack_require__(99); +var Class = __webpack_require__(0); +var WebAudioSound = __webpack_require__(277); + +/** + * @classdesc + * Web Audio API implementation of the sound manager. + * + * @class WebAudioSoundManager + * @extends Phaser.Sound.BaseSoundManager + * @memberOf Phaser.Sound + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - Reference to the current game instance. + */ +var WebAudioSoundManager = new Class({ + + Extends: BaseSoundManager, + + initialize: + + function WebAudioSoundManager (game) + { + /** + * The AudioContext being used for playback. + * + * @name Phaser.Sound.WebAudioSoundManager#context + * @type {AudioContext} + * @private + * @since 3.0.0 + */ + this.context = this.createAudioContext(game); + + /** + * Gain node responsible for controlling global muting. + * + * @name Phaser.Sound.WebAudioSoundManager#masterMuteNode + * @type {GainNode} + * @private + * @since 3.0.0 + */ + this.masterMuteNode = this.context.createGain(); + + /** + * Gain node responsible for controlling global volume. + * + * @name Phaser.Sound.WebAudioSoundManager#masterVolumeNode + * @type {GainNode} + * @private + * @since 3.0.0 + */ + this.masterVolumeNode = this.context.createGain(); + + this.masterMuteNode.connect(this.masterVolumeNode); + + this.masterVolumeNode.connect(this.context.destination); + + /** + * Destination node for connecting individual sounds to. + * + * @name Phaser.Sound.WebAudioSoundManager#destination + * @type {AudioNode} + * @private + * @since 3.0.0 + */ + this.destination = this.masterMuteNode; + + this.locked = this.context.state === 'suspended' && 'ontouchstart' in window; + + BaseSoundManager.call(this, game); + }, + + /** + * Method responsible for instantiating and returning AudioContext instance. + * If an instance of an AudioContext class was provided trough the game config, + * that instance will be returned instead. This can come in handy if you are reloading + * a Phaser game on a page that never properly refreshes (such as in an SPA project) + * and you want to reuse already instantiated AudioContext. + * + * @method Phaser.Sound.WebAudioSoundManager#createAudioContext + * @private + * @since 3.0.0 + * + * @param {Phaser.Game} game - Reference to the current game instance. + * + * @return {AudioContext} The AudioContext instance to be used for playback. + */ + createAudioContext: function (game) + { + var audioConfig = game.config.audio; + + if (audioConfig && audioConfig.context) + { + audioConfig.context.resume(); + + return audioConfig.context; + } + + return new AudioContext(); + }, + + /** + * Adds a new sound into the sound manager. + * + * @method Phaser.Sound.WebAudioSoundManager#add + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * + * @return {Phaser.Sound.WebAudioSound} The new sound instance. + */ + add: function (key, config) + { + var sound = new WebAudioSound(this, key, config); + + this.sounds.push(sound); + + return sound; + }, + + /** + * Unlocks Web Audio API on iOS devices on the initial touch event. + * + * Read more about how this issue is handled here in [this article](https://medium.com/@pgoloskokovic/unlocking-web-audio-the-smarter-way-8858218c0e09). + * + * @method Phaser.Sound.WebAudioSoundManager#unlock + * @since 3.0.0 + */ + unlock: function () + { + var _this = this; + + var unlock = function () + { + _this.context.resume().then(function () + { + document.body.removeEventListener('touchstart', unlock); + document.body.removeEventListener('touchend', unlock); + _this.unlocked = true; + }); + }; + + document.body.addEventListener('touchstart', unlock, false); + document.body.addEventListener('touchend', unlock, false); + }, + + /** + * Method used internally for pausing sound manager if + * Phaser.Sound.WebAudioSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.WebAudioSoundManager#onBlur + * @protected + * @since 3.0.0 + */ + onBlur: function () + { + this.context.suspend(); + }, + + /** + * Method used internally for resuming sound manager if + * Phaser.Sound.WebAudioSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.WebAudioSoundManager#onFocus + * @protected + * @since 3.0.0 + */ + onFocus: function () + { + this.context.resume(); + }, + + /** + * Calls Phaser.Sound.BaseSoundManager#destroy method + * and cleans up all Web Audio API related stuff. + * + * @method Phaser.Sound.WebAudioSoundManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.destination = null; + this.masterVolumeNode.disconnect(); + this.masterVolumeNode = null; + this.masterMuteNode.disconnect(); + this.masterMuteNode = null; + + if (this.game.config.audio && this.game.config.audio.context) + { + this.context.suspend(); + } + else + { + this.context.close(); + } + + this.context = null; + + BaseSoundManager.prototype.destroy.call(this); + }, + + /** + * @event Phaser.Sound.WebAudioSoundManager#MuteEvent + * @param {Phaser.Sound.WebAudioSoundManager} soundManager - Reference to the sound manager that emitted event. + * @param {boolean} value - An updated value of Phaser.Sound.WebAudioSoundManager#mute property. + */ + + /** + * Sets the muted state of all this Sound Manager. + * + * @method Phaser.Sound.WebAudioSoundManager#setMute + * @fires Phaser.Sound.WebAudioSoundManager#MuteEvent + * @since 3.3.0 + * + * @param {boolean} value - `true` to mute all sounds, `false` to unmute them. + * + * @return {Phaser.Sound.WebAudioSoundManager} This Sound Manager. + */ + setMute: function (value) + { + this.mute = value; + + return this; + }, + + /** + * @name Phaser.Sound.WebAudioSoundManager#mute + * @type {boolean} + * @fires Phaser.Sound.WebAudioSoundManager#MuteEvent + * @since 3.0.0 + */ + mute: { + + get: function () + { + return (this.masterMuteNode.gain.value === 0); + }, + + set: function (value) + { + this.masterMuteNode.gain.setValueAtTime(value ? 0 : 1, 0); + + this.emit('mute', this, value); + } + + }, + + /** + * @event Phaser.Sound.WebAudioSoundManager#VolumeEvent + * @param {Phaser.Sound.WebAudioSoundManager} soundManager - Reference to the sound manager that emitted event. + * @param {number} value - An updated value of Phaser.Sound.WebAudioSoundManager#volume property. + */ + + /** + * Sets the volume of this Sound Manager. + * + * @method Phaser.Sound.WebAudioSoundManager#setVolume + * @fires Phaser.Sound.WebAudioSoundManager#VolumeEvent + * @since 3.3.0 + * + * @param {number} value - The global volume of this Sound Manager. + * + * @return {Phaser.Sound.WebAudioSoundManager} This Sound Manager. + */ + setVolume: function (value) + { + this.volume = value; + + return this; + }, + + /** + * @name Phaser.Sound.WebAudioSoundManager#volume + * @type {number} + * @fires Phaser.Sound.WebAudioSoundManager#VolumeEvent + * @since 3.0.0 + */ + volume: { + + get: function () + { + return this.masterVolumeNode.gain.value; + }, + + set: function (value) + { + this.masterVolumeNode.gain.setValueAtTime(value, 0); + + this.emit('volume', this, value); + } + + } + +}); + +module.exports = WebAudioSoundManager; + + +/***/ }), +/* 279 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ +var BaseSound = __webpack_require__(98); +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(15); +var Extend = __webpack_require__(18); + +/** + * @classdesc + * No audio implementation of the sound. It is used if audio has been + * disabled in the game config or the device doesn't support any audio. + * + * It represents a graceful degradation of sound logic that provides + * minimal functionality and prevents Phaser projects that use audio from + * breaking on devices that don't support any audio playback technologies. + * + * @class NoAudioSound + * @extends Phaser.Sound.BaseSound + * @memberOf Phaser.Sound + * @constructor + * @author Pavle Goloskokovic (http://prunegames.com) + * @since 3.0.0 + * + * @param {Phaser.Sound.NoAudioSoundManager} manager - Reference to the current sound manager instance. + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config={}] - An optional config object containing default sound settings. + */ +var NoAudioSound = new Class({ + Extends: EventEmitter, + initialize: function NoAudioSound (manager, key, config) + { + if (config === void 0) { config = {}; } + EventEmitter.call(this); + this.manager = manager; + this.key = key; + this.isPlaying = false; + this.isPaused = false; + this.totalRate = 1; + this.duration = 0; + this.totalDuration = 0; + this.config = Extend({ + mute: false, + volume: 1, + rate: 1, + detune: 0, + seek: 0, + loop: false, + delay: 0 + }, config); + this.currentConfig = this.config; + this.mute = false; + this.volume = 1; + this.rate = 1; + this.detune = 0; + this.seek = 0; + this.loop = false; + this.markers = {}; + this.currentMarker = null; + this.pendingRemove = false; + }, + // eslint-disable-next-line no-unused-vars + addMarker: function (marker) + { + return false; + }, + // eslint-disable-next-line no-unused-vars + updateMarker: function (marker) + { + return false; + }, + // eslint-disable-next-line no-unused-vars + removeMarker: function (markerName) + { + return null; + }, + // eslint-disable-next-line no-unused-vars + play: function (markerName, config) + { + return false; + }, + pause: function () + { + return false; + }, + resume: function () + { + return false; + }, + stop: function () + { + return false; + }, + destroy: function () + { + this.manager.remove(this); + BaseSound.prototype.destroy.call(this); + } +}); +module.exports = NoAudioSound; + + +/***/ }), +/* 280 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Pavle Goloskokovic (http://prunegames.com) + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BaseSoundManager = __webpack_require__(99); +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(15); +var NoAudioSound = __webpack_require__(279); +var NOOP = __webpack_require__(3); + +/** + * @classdesc + * No audio implementation of the sound manager. It is used if audio has been + * disabled in the game config or the device doesn't support any audio. + * + * It represents a graceful degradation of sound manager logic that provides + * minimal functionality and prevents Phaser projects that use audio from + * breaking on devices that don't support any audio playback technologies. + * + * @class NoAudioSoundManager + * @extends Phaser.Sound.BaseSoundManager + * @memberOf Phaser.Sound + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - Reference to the current game instance. + */ +var NoAudioSoundManager = new Class({ + + Extends: EventEmitter, + + initialize: + + function NoAudioSoundManager (game) + { + EventEmitter.call(this); + + this.game = game; + this.sounds = []; + this.mute = false; + this.volume = 1; + this.rate = 1; + this.detune = 0; + this.pauseOnBlur = true; + this.locked = false; + }, + + add: function (key, config) + { + var sound = new NoAudioSound(this, key, config); + + this.sounds.push(sound); + + return sound; + }, + + addAudioSprite: function (key, config) + { + var sound = this.add(key, config); + + sound.spritemap = {}; + + return sound; + }, + + // eslint-disable-next-line no-unused-vars + play: function (key, extra) + { + return false; + }, + + // eslint-disable-next-line no-unused-vars + playAudioSprite: function (key, spriteName, config) + { + return false; + }, + + remove: function (sound) + { + return BaseSoundManager.prototype.remove.call(this, sound); + }, + + removeByKey: function (key) + { + return BaseSoundManager.prototype.removeByKey.call(this, key); + }, + + pauseAll: NOOP, + resumeAll: NOOP, + stopAll: NOOP, + update: NOOP, + setRate: NOOP, + setDetune: NOOP, + setMute: NOOP, + setVolume: NOOP, + + forEachActiveSound: function (callbackfn, scope) + { + BaseSoundManager.prototype.forEachActiveSound.call(this, callbackfn, scope); + }, + + destroy: function () + { + BaseSoundManager.prototype.destroy.call(this); + } + +}); + +module.exports = NoAudioSoundManager; + + +/***/ }), +/* 281 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ +var Class = __webpack_require__(0); +var BaseSound = __webpack_require__(98); /** * @classdesc @@ -50608,3674 +57307,6 @@ Object.defineProperty(HTML5AudioSound.prototype, 'loop', { module.exports = HTML5AudioSound; -/***/ }), -/* 259 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ -var BaseSoundManager = __webpack_require__(84); -var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(14); -var NoAudioSound = __webpack_require__(260); -var NOOP = __webpack_require__(3); - -/** - * @classdesc - * No audio implementation of the sound manager. It is used if audio has been - * disabled in the game config or the device doesn't support any audio. - * - * It represents a graceful degradation of sound manager logic that provides - * minimal functionality and prevents Phaser projects that use audio from - * breaking on devices that don't support any audio playback technologies. - * - * @class NoAudioSoundManager - * @extends Phaser.Sound.BaseSoundManager - * @memberOf Phaser.Sound - * @constructor - * @author Pavle Goloskokovic (http://prunegames.com) - * @since 3.0.0 - * - * @param {Phaser.Game} game - Reference to the current game instance. - */ -var NoAudioSoundManager = new Class({ - Extends: EventEmitter, - initialize: function NoAudioSoundManager (game) - { - EventEmitter.call(this); - this.game = game; - this.sounds = []; - this.mute = false; - this.volume = 1; - this.rate = 1; - this.detune = 0; - this.pauseOnBlur = true; - this.locked = false; - }, - add: function (key, config) - { - var sound = new NoAudioSound(this, key, config); - this.sounds.push(sound); - return sound; - }, - addAudioSprite: function (key, config) - { - var sound = this.add(key, config); - sound.spritemap = {}; - return sound; - }, - // eslint-disable-next-line no-unused-vars - play: function (key, extra) - { - return false; - }, - // eslint-disable-next-line no-unused-vars - playAudioSprite: function (key, spriteName, config) - { - return false; - }, - remove: function (sound) - { - return BaseSoundManager.prototype.remove.call(this, sound); - }, - removeByKey: function (key) - { - return BaseSoundManager.prototype.removeByKey.call(this, key); - }, - pauseAll: NOOP, - resumeAll: NOOP, - stopAll: NOOP, - update: NOOP, - destroy: function () - { - BaseSoundManager.prototype.destroy.call(this); - }, - forEachActiveSound: function (callbackfn, scope) - { - BaseSoundManager.prototype.forEachActiveSound.call(this, callbackfn, scope); - } -}); -module.exports = NoAudioSoundManager; - - -/***/ }), -/* 260 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ -var BaseSound = __webpack_require__(85); -var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(14); -var Extend = __webpack_require__(23); - -/** - * @classdesc - * No audio implementation of the sound. It is used if audio has been - * disabled in the game config or the device doesn't support any audio. - * - * It represents a graceful degradation of sound logic that provides - * minimal functionality and prevents Phaser projects that use audio from - * breaking on devices that don't support any audio playback technologies. - * - * @class NoAudioSound - * @extends Phaser.Sound.BaseSound - * @memberOf Phaser.Sound - * @constructor - * @author Pavle Goloskokovic (http://prunegames.com) - * @since 3.0.0 - * - * @param {Phaser.Sound.NoAudioSoundManager} manager - Reference to the current sound manager instance. - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config={}] - An optional config object containing default sound settings. - */ -var NoAudioSound = new Class({ - Extends: EventEmitter, - initialize: function NoAudioSound (manager, key, config) - { - if (config === void 0) { config = {}; } - EventEmitter.call(this); - this.manager = manager; - this.key = key; - this.isPlaying = false; - this.isPaused = false; - this.totalRate = 1; - this.duration = 0; - this.totalDuration = 0; - this.config = Extend({ - mute: false, - volume: 1, - rate: 1, - detune: 0, - seek: 0, - loop: false, - delay: 0 - }, config); - this.currentConfig = this.config; - this.mute = false; - this.volume = 1; - this.rate = 1; - this.detune = 0; - this.seek = 0; - this.loop = false; - this.markers = {}; - this.currentMarker = null; - this.pendingRemove = false; - }, - // eslint-disable-next-line no-unused-vars - addMarker: function (marker) - { - return false; - }, - // eslint-disable-next-line no-unused-vars - updateMarker: function (marker) - { - return false; - }, - // eslint-disable-next-line no-unused-vars - removeMarker: function (markerName) - { - return null; - }, - // eslint-disable-next-line no-unused-vars - play: function (markerName, config) - { - return false; - }, - pause: function () - { - return false; - }, - resume: function () - { - return false; - }, - stop: function () - { - return false; - }, - destroy: function () - { - this.manager.remove(this); - BaseSound.prototype.destroy.call(this); - } -}); -module.exports = NoAudioSound; - - -/***/ }), -/* 261 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BaseSoundManager = __webpack_require__(84); -var Class = __webpack_require__(0); -var WebAudioSound = __webpack_require__(262); - -/** - * @classdesc - * Web Audio API implementation of the sound manager. - * - * @class WebAudioSoundManager - * @extends Phaser.Sound.BaseSoundManager - * @memberOf Phaser.Sound - * @constructor - * @author Pavle Goloskokovic (http://prunegames.com) - * @since 3.0.0 - * - * @param {Phaser.Game} game - Reference to the current game instance. - */ -var WebAudioSoundManager = new Class({ - - Extends: BaseSoundManager, - - initialize: - - function WebAudioSoundManager (game) - { - /** - * The AudioContext being used for playback. - * - * @name Phaser.Sound.WebAudioSoundManager#context - * @type {AudioContext} - * @private - * @since 3.0.0 - */ - this.context = this.createAudioContext(game); - - /** - * Gain node responsible for controlling global muting. - * - * @name Phaser.Sound.WebAudioSoundManager#masterMuteNode - * @type {GainNode} - * @private - * @since 3.0.0 - */ - this.masterMuteNode = this.context.createGain(); - - /** - * Gain node responsible for controlling global volume. - * - * @name Phaser.Sound.WebAudioSoundManager#masterVolumeNode - * @type {GainNode} - * @private - * @since 3.0.0 - */ - this.masterVolumeNode = this.context.createGain(); - - this.masterMuteNode.connect(this.masterVolumeNode); - - this.masterVolumeNode.connect(this.context.destination); - - /** - * Destination node for connecting individual sounds to. - * - * @name Phaser.Sound.WebAudioSoundManager#destination - * @type {AudioNode} - * @private - * @since 3.0.0 - */ - this.destination = this.masterMuteNode; - - this.locked = this.context.state === 'suspended' && 'ontouchstart' in window; - - BaseSoundManager.call(this, game); - }, - - /** - * Method responsible for instantiating and returning AudioContext instance. - * If an instance of an AudioContext class was provided trough the game config, - * that instance will be returned instead. This can come in handy if you are reloading - * a Phaser game on a page that never properly refreshes (such as in an SPA project) - * and you want to reuse already instantiated AudioContext. - * - * @method Phaser.Sound.WebAudioSoundManager#createAudioContext - * @private - * @since 3.0.0 - * - * @param {Phaser.Game} game - Reference to the current game instance. - * - * @return {AudioContext} The AudioContext instance to be used for playback. - */ - createAudioContext: function (game) - { - var audioConfig = game.config.audio; - - if (audioConfig && audioConfig.context) - { - audioConfig.context.resume(); - return audioConfig.context; - } - - return new AudioContext(); - }, - - /** - * Adds a new sound into the sound manager. - * - * @method Phaser.Sound.WebAudioSoundManager#add - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - * - * @return {Phaser.Sound.WebAudioSound} The new sound instance. - */ - add: function (key, config) - { - - var sound = new WebAudioSound(this, key, config); - - this.sounds.push(sound); - - return sound; - }, - - /** - * Unlocks Web Audio API on iOS devices on the initial touch event. - * - * Read more about how this issue is handled here in [this article](https://medium.com/@pgoloskokovic/unlocking-web-audio-the-smarter-way-8858218c0e09). - * - * @method Phaser.Sound.WebAudioSoundManager#unlock - * @private - * @since 3.0.0 - */ - unlock: function () - { - var _this = this; - - var unlock = function () - { - _this.context.resume().then(function () - { - document.body.removeEventListener('touchstart', unlock); - document.body.removeEventListener('touchend', unlock); - _this.unlocked = true; - }); - }; - - document.body.addEventListener('touchstart', unlock, false); - document.body.addEventListener('touchend', unlock, false); - }, - - /** - * Method used internally for pausing sound manager if - * Phaser.Sound.WebAudioSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.WebAudioSoundManager#onBlur - * @protected - * @since 3.0.0 - */ - onBlur: function () - { - this.context.suspend(); - }, - - /** - * Method used internally for resuming sound manager if - * Phaser.Sound.WebAudioSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.WebAudioSoundManager#onFocus - * @protected - * @since 3.0.0 - */ - onFocus: function () - { - this.context.resume(); - }, - - /** - * Calls Phaser.Sound.BaseSoundManager#destroy method - * and cleans up all Web Audio API related stuff. - * - * @method Phaser.Sound.WebAudioSoundManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.destination = null; - this.masterVolumeNode.disconnect(); - this.masterVolumeNode = null; - this.masterMuteNode.disconnect(); - this.masterMuteNode = null; - - if (this.game.config.audio && this.game.config.audio.context) - { - this.context.suspend(); - } - else - { - this.context.close(); - } - - this.context = null; - - BaseSoundManager.prototype.destroy.call(this); - }, - - /** - * @event Phaser.Sound.WebAudioSoundManager#MuteEvent - * @param {Phaser.Sound.WebAudioSoundManager} soundManager - Reference to the sound manager that emitted event. - * @param {boolean} value - An updated value of Phaser.Sound.WebAudioSoundManager#mute property. - */ - - /** - * @name Phaser.Sound.WebAudioSoundManager#mute - * @type {boolean} - * @fires Phaser.Sound.WebAudioSoundManager#MuteEvent - * @since 3.0.0 - */ - mute: { - - get: function () - { - return (this.masterMuteNode.gain.value === 0); - }, - - set: function (value) - { - this.masterMuteNode.gain.setValueAtTime(value ? 0 : 1, 0); - - this.emit('mute', this, value); - } - - }, - - /** - * @event Phaser.Sound.WebAudioSoundManager#VolumeEvent - * @param {Phaser.Sound.WebAudioSoundManager} soundManager - Reference to the sound manager that emitted event. - * @param {number} value - An updated value of Phaser.Sound.WebAudioSoundManager#volume property. - */ - - /** - * @name Phaser.Sound.WebAudioSoundManager#volume - * @type {number} - * @fires Phaser.Sound.WebAudioSoundManager#VolumeEvent - * @since 3.0.0 - */ - volume: { - - get: function () - { - return this.masterVolumeNode.gain.value; - }, - - set: function (value) - { - this.masterVolumeNode.gain.setValueAtTime(value, 0); - - this.emit('volume', this, value); - } - - } - -}); - -module.exports = WebAudioSoundManager; - - -/***/ }), -/* 262 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ -var Class = __webpack_require__(0); -var BaseSound = __webpack_require__(85); - -/** - * @classdesc - * Web Audio API implementation of the sound. - * - * @class WebAudioSound - * @extends Phaser.Sound.BaseSound - * @memberOf Phaser.Sound - * @constructor - * @author Pavle Goloskokovic (http://prunegames.com) - * @since 3.0.0 - * - * @param {Phaser.Sound.WebAudioSoundManager} manager - Reference to the current sound manager instance. - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config={}] - An optional config object containing default sound settings. - */ -var WebAudioSound = new Class({ - Extends: BaseSound, - initialize: function WebAudioSound (manager, key, config) - { - if (config === void 0) { config = {}; } - - /** - * Audio buffer containing decoded data of the audio asset to be played. - * - * @name Phaser.Sound.WebAudioSound#audioBuffer - * @type {AudioBuffer} - * @private - * @since 3.0.0 - */ - this.audioBuffer = manager.game.cache.audio.get(key); - if (!this.audioBuffer) - { - // eslint-disable-next-line no-console - console.error('No audio loaded in cache with key: \'' + key + '\'!'); - return; - } - - /** - * A reference to an audio source node used for playing back audio from - * audio data stored in Phaser.Sound.WebAudioSound#audioBuffer. - * - * @name Phaser.Sound.WebAudioSound#source - * @type {AudioBufferSourceNode} - * @private - * @default null - * @since 3.0.0 - */ - this.source = null; - - /** - * A reference to a second audio source used for gapless looped playback. - * - * @name Phaser.Sound.WebAudioSound#loopSource - * @type {AudioBufferSourceNode} - * @private - * @default null - * @since 3.0.0 - */ - this.loopSource = null; - - /** - * Gain node responsible for controlling this sound's muting. - * - * @name Phaser.Sound.WebAudioSound#muteNode - * @type {GainNode} - * @private - * @since 3.0.0 - */ - this.muteNode = manager.context.createGain(); - - /** - * Gain node responsible for controlling this sound's volume. - * - * @name Phaser.Sound.WebAudioSound#volumeNode - * @type {GainNode} - * @private - * @since 3.0.0 - */ - this.volumeNode = manager.context.createGain(); - - /** - * The time at which the sound should have started playback from the beginning. - * Based on BaseAudioContext.currentTime value. - * - * @name Phaser.Sound.WebAudioSound#playTime - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this.playTime = 0; - - /** - * The time at which the sound source should have actually started playback. - * Based on BaseAudioContext.currentTime value. - * - * @name Phaser.Sound.WebAudioSound#startTime - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this.startTime = 0; - - /** - * The time at which the sound loop source should actually start playback. - * Based on BaseAudioContext.currentTime value. - * - * @name Phaser.Sound.WebAudioSound#loopTime - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this.loopTime = 0; - - /** - * An array where we keep track of all rate updates during playback. - * Array of object types: { time: number, rate: number } - * - * @name Phaser.Sound.WebAudioSound#rateUpdates - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this.rateUpdates = []; - - /** - * Used for keeping track when sound source playback has ended - * so its state can be updated accordingly. - * - * @name Phaser.Sound.WebAudioSound#hasEnded - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this.hasEnded = false; - - /** - * Used for keeping track when sound source has looped - * so its state can be updated accordingly. - * - * @name Phaser.Sound.WebAudioSound#hasLooped - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this.hasLooped = false; - this.muteNode.connect(this.volumeNode); - this.volumeNode.connect(manager.destination); - this.duration = this.audioBuffer.duration; - this.totalDuration = this.audioBuffer.duration; - BaseSound.call(this, manager, key, config); - }, - - /** - * Play this sound, or a marked section of it. - * It always plays the sound from the start. If you want to start playback from a specific time - * you can set 'seek' setting of the config object, provided to this call, to that value. - * - * @method Phaser.Sound.WebAudioSound#play - * @since 3.0.0 - * - * @param {string} [markerName=''] - If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. - * @param {SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. - * - * @return {boolean} Whether the sound started playing successfully. - */ - play: function (markerName, config) - { - if (!BaseSound.prototype.play.call(this, markerName, config)) - { - return false; - } - - // \/\/\/ isPlaying = true, isPaused = false \/\/\/ - this.stopAndRemoveBufferSource(); - this.createAndStartBufferSource(); - - /** - * @event Phaser.Sound.WebAudioSound#play - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - */ - this.emit('play', this); - return true; - }, - - /** - * Pauses the sound. - * - * @method Phaser.Sound.WebAudioSound#pause - * @since 3.0.0 - * - * @return {boolean} Whether the sound was paused successfully. - */ - pause: function () - { - if (this.manager.context.currentTime < this.startTime) - { - return false; - } - if (!BaseSound.prototype.pause.call(this)) - { - return false; - } - - // \/\/\/ isPlaying = false, isPaused = true \/\/\/ - this.currentConfig.seek = this.getCurrentTime(); // Equivalent to setting paused time - this.stopAndRemoveBufferSource(); - - /** - * @event Phaser.Sound.WebAudioSound#pause - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - */ - this.emit('pause', this); - return true; - }, - - /** - * Resumes the sound. - * - * @method Phaser.Sound.WebAudioSound#resume - * @since 3.0.0 - * - * @return {boolean} Whether the sound was resumed successfully. - */ - resume: function () - { - if (this.manager.context.currentTime < this.startTime) - { - return false; - } - if (!BaseSound.prototype.resume.call(this)) - { - return false; - } - - // \/\/\/ isPlaying = true, isPaused = false \/\/\/ - this.createAndStartBufferSource(); - - /** - * @event Phaser.Sound.WebAudioSound#resume - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - */ - this.emit('resume', this); - return true; - }, - - /** - * Stop playing this sound. - * - * @method Phaser.Sound.WebAudioSound#stop - * @since 3.0.0 - * - * @return {boolean} Whether the sound was stopped successfully. - */ - stop: function () - { - if (!BaseSound.prototype.stop.call(this)) - { - return false; - } - - // \/\/\/ isPlaying = false, isPaused = false \/\/\/ - this.stopAndRemoveBufferSource(); - - /** - * @event Phaser.Sound.WebAudioSound#stop - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - */ - this.emit('stop', this); - return true; - }, - - /** - * Used internally to do what the name says. - * - * @method Phaser.Sound.WebAudioSound#createAndStartBufferSource - * @private - * @since 3.0.0 - */ - createAndStartBufferSource: function () - { - var seek = this.currentConfig.seek; - var delay = this.currentConfig.delay; - var when = this.manager.context.currentTime + delay; - var offset = (this.currentMarker ? this.currentMarker.start : 0) + seek; - var duration = this.duration - seek; - this.playTime = when - seek; - this.startTime = when; - this.source = this.createBufferSource(); - this.applyConfig(); - this.source.start(Math.max(0, when), Math.max(0, offset), Math.max(0, duration)); - this.resetConfig(); - }, - - /** - * Used internally to do what the name says. - * - * @method Phaser.Sound.WebAudioSound#createAndStartLoopBufferSource - * @private - * @since 3.0.0 - */ - createAndStartLoopBufferSource: function () - { - var when = this.getLoopTime(); - var offset = this.currentMarker ? this.currentMarker.start : 0; - var duration = this.duration; - this.loopTime = when; - this.loopSource = this.createBufferSource(); - this.loopSource.playbackRate.setValueAtTime(this.totalRate, 0); - this.loopSource.start(Math.max(0, when), Math.max(0, offset), Math.max(0, duration)); - }, - - /** - * Used internally to do what the name says. - * - * @method Phaser.Sound.WebAudioSound#createBufferSource - * @private - * @since 3.0.0 - * - * @return {AudioBufferSourceNode} - */ - createBufferSource: function () - { - var _this = this; - var source = this.manager.context.createBufferSource(); - source.buffer = this.audioBuffer; - source.connect(this.muteNode); - source.onended = function (ev) - { - if (ev.target === _this.source) - { - // sound ended - if (_this.currentConfig.loop) - { - _this.hasLooped = true; - } - else - { - _this.hasEnded = true; - } - } - - // else was stopped - }; - return source; - }, - - /** - * Used internally to do what the name says. - * - * @method Phaser.Sound.WebAudioSound#stopAndRemoveBufferSource - * @private - * @since 3.0.0 - */ - stopAndRemoveBufferSource: function () - { - if (this.source) - { - this.source.stop(); - this.source.disconnect(); - this.source = null; - } - this.playTime = 0; - this.startTime = 0; - this.stopAndRemoveLoopBufferSource(); - }, - - /** - * Used internally to do what the name says. - * - * @method Phaser.Sound.WebAudioSound#stopAndRemoveLoopBufferSource - * @private - * @since 3.0.0 - */ - stopAndRemoveLoopBufferSource: function () - { - if (this.loopSource) - { - this.loopSource.stop(); - this.loopSource.disconnect(); - this.loopSource = null; - } - this.loopTime = 0; - }, - - /** - * Method used internally for applying config values to some of the sound properties. - * - * @method Phaser.Sound.WebAudioSound#applyConfig - * @protected - * @since 3.0.0 - */ - applyConfig: function () - { - this.rateUpdates.length = 0; - this.rateUpdates.push({ - time: 0, - rate: 1 - }); - BaseSound.prototype.applyConfig.call(this); - }, - - /** - * Update method called automatically by sound manager on every game step. - * - * @method Phaser.Sound.WebAudioSound#update - * @protected - * @since 3.0.0 - * - * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {number} delta - The delta time elapsed since the last frame. - */ - // eslint-disable-next-line no-unused-vars - update: function (time, delta) - { - if (this.hasEnded) - { - this.hasEnded = false; - BaseSound.prototype.stop.call(this); - this.stopAndRemoveBufferSource(); - - /** - * @event Phaser.Sound.WebAudioSound#ended - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - */ - this.emit('ended', this); - } - else if (this.hasLooped) - { - this.hasLooped = false; - this.source = this.loopSource; - this.loopSource = null; - this.playTime = this.startTime = this.loopTime; - this.rateUpdates.length = 0; - this.rateUpdates.push({ - time: 0, - rate: this.totalRate - }); - this.createAndStartLoopBufferSource(); - - /** - * @event Phaser.Sound.WebAudioSound#looped - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - */ - this.emit('looped', this); - } - }, - - /** - * Calls Phaser.Sound.BaseSound#destroy method - * and cleans up all Web Audio API related stuff. - * - * @method Phaser.Sound.WebAudioSound#destroy - * @since 3.0.0 - */ - destroy: function () - { - BaseSound.prototype.destroy.call(this); - this.audioBuffer = null; - this.stopAndRemoveBufferSource(); - this.muteNode.disconnect(); - this.muteNode = null; - this.volumeNode.disconnect(); - this.volumeNode = null; - this.rateUpdates.length = 0; - this.rateUpdates = null; - }, - - /** - * Method used internally to calculate total playback rate of the sound. - * - * @method Phaser.Sound.WebAudioSound#setRate - * @protected - * @since 3.0.0 - */ - setRate: function () - { - BaseSound.prototype.setRate.call(this); - var now = this.manager.context.currentTime; - if (this.source) - { - this.source.playbackRate.setValueAtTime(this.totalRate, now); - } - if (this.isPlaying) - { - this.rateUpdates.push({ - time: Math.max(this.startTime, now) - this.playTime, - rate: this.totalRate - }); - if (this.loopSource) - { - this.stopAndRemoveLoopBufferSource(); - this.createAndStartLoopBufferSource(); - } - } - }, - - /** - * Method used internally for calculating current playback time of a playing sound. - * - * @method Phaser.Sound.WebAudioSound#getCurrentTime - * @private - * @since 3.0.0 - */ - getCurrentTime: function () - { - var currentTime = 0; - for (var i = 0; i < this.rateUpdates.length; i++) - { - var nextTime = void 0; - if (i < this.rateUpdates.length - 1) - { - nextTime = this.rateUpdates[i + 1].time; - } - else - { - nextTime = this.manager.context.currentTime - this.playTime; - } - currentTime += (nextTime - this.rateUpdates[i].time) * this.rateUpdates[i].rate; - } - return currentTime; - }, - - /** - * Method used internally for calculating the time - * at witch the loop source should start playing. - * - * @method Phaser.Sound.WebAudioSound#getLoopTime - * @private - * @since 3.0.0 - */ - getLoopTime: function () - { - var lastRateUpdateCurrentTime = 0; - for (var i = 0; i < this.rateUpdates.length - 1; i++) - { - lastRateUpdateCurrentTime += - (this.rateUpdates[i + 1].time - this.rateUpdates[i].time) * this.rateUpdates[i].rate; - } - var lastRateUpdate = this.rateUpdates[this.rateUpdates.length - 1]; - return this.playTime + lastRateUpdate.time - + (this.duration - lastRateUpdateCurrentTime) / lastRateUpdate.rate; - } -}); -Object.defineProperty(WebAudioSound.prototype, 'mute', { - get: function () - { - return this.muteNode.gain.value === 0; - }, - set: function (value) - { - this.currentConfig.mute = value; - this.muteNode.gain.setValueAtTime(value ? 0 : 1, 0); - - /** - * @event Phaser.Sound.WebAudioSound#mute - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - * @param {boolean} value - An updated value of Phaser.Sound.WebAudioSound#mute property. - */ - this.emit('mute', this, value); - } -}); -Object.defineProperty(WebAudioSound.prototype, 'volume', { - get: function () - { - return this.volumeNode.gain.value; - }, - set: function (value) - { - this.currentConfig.volume = value; - this.volumeNode.gain.setValueAtTime(value, 0); - - /** - * @event Phaser.Sound.WebAudioSound#volume - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - * @param {number} value - An updated value of Phaser.Sound.WebAudioSound#volume property. - */ - this.emit('volume', this, value); - } -}); -Object.defineProperty(WebAudioSound.prototype, 'seek', { - get: function () - { - if (this.isPlaying) - { - if (this.manager.context.currentTime < this.startTime) - { - return this.startTime - this.playTime; - } - return this.getCurrentTime(); - } - else if (this.isPaused) - { - return this.currentConfig.seek; - } - else - { - return 0; - } - }, - set: function (value) - { - if (this.manager.context.currentTime < this.startTime) - { - return; - } - if (this.isPlaying || this.isPaused) - { - value = Math.min(Math.max(0, value), this.duration); - this.currentConfig.seek = value; - if (this.isPlaying) - { - this.stopAndRemoveBufferSource(); - this.createAndStartBufferSource(); - } - - /** - * @event Phaser.Sound.WebAudioSound#seek - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - * @param {number} value - An updated value of Phaser.Sound.WebAudioSound#seek property. - */ - this.emit('seek', this, value); - } - } -}); -Object.defineProperty(WebAudioSound.prototype, 'loop', { - get: function () - { - return this.currentConfig.loop; - }, - set: function (value) - { - this.currentConfig.loop = value; - if (this.isPlaying) - { - this.stopAndRemoveLoopBufferSource(); - if (value) - { - this.createAndStartLoopBufferSource(); - } - } - - /** - * @event Phaser.Sound.WebAudioSound#loop - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - * @param {boolean} value - An updated value of Phaser.Sound.WebAudioSound#loop property. - */ - this.emit('loop', this, value); - } -}); -module.exports = WebAudioSound; - - -/***/ }), -/* 263 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CanvasPool = __webpack_require__(21); -var Class = __webpack_require__(0); -var Color = __webpack_require__(36); -var EventEmitter = __webpack_require__(14); -var GenerateTexture = __webpack_require__(216); -var GetValue = __webpack_require__(4); -var Parser = __webpack_require__(264); -var Texture = __webpack_require__(265); - -/** - * @classdesc - * Textures are managed by the global TextureManager. This is a singleton class that is - * responsible for creating and delivering Textures and their corresponding Frames to Game Objects. - * - * Sprites and other Game Objects get the texture data they need from the TextureManager. - * - * Access it via `scene.textures`. - * - * @class TextureManager - * @extends EventEmitter - * @memberOf Phaser.Textures - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - [description] - */ -var TextureManager = new Class({ - - Extends: EventEmitter, - - initialize: - - function TextureManager (game) - { - EventEmitter.call(this); - - /** - * [description] - * - * @name Phaser.Textures.TextureManager#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game = game; - - /** - * [description] - * - * @name Phaser.Textures.TextureManager#name - * @type {string} - * @since 3.0.0 - */ - this.name = 'TextureManager'; - - /** - * [description] - * - * @name Phaser.Textures.TextureManager#list - * @type {object} - * @default {} - * @since 3.0.0 - */ - this.list = {}; - - /** - * [description] - * - * @name Phaser.Textures.TextureManager#_tempCanvas - * @type {HTMLCanvasElement} - * @private - * @since 3.0.0 - */ - this._tempCanvas = CanvasPool.create2D(this, 1, 1); - - /** - * [description] - * - * @name Phaser.Textures.TextureManager#_tempContext - * @type {CanvasRenderingContext2D} - * @private - * @since 3.0.0 - */ - this._tempContext = this._tempCanvas.getContext('2d'); - - /** - * [description] - * - * @name Phaser.Textures.TextureManager#_pending - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - this._pending = 0; - - game.events.once('boot', this.boot, this); - }, - - /** - * [description] - * - * @method Phaser.Textures.TextureManager#boot - * @since 3.0.0 - */ - boot: function () - { - this._pending = 2; - - this.on('onload', this.updatePending, this); - this.on('onerror', this.updatePending, this); - - this.addBase64('__DEFAULT', this.game.config.defaultImage); - this.addBase64('__MISSING', this.game.config.missingImage); - - this.game.events.once('destroy', this.destroy, this); - }, - - /** - * [description] - * - * @method Phaser.Textures.TextureManager#updatePending - * @since 3.0.0 - */ - updatePending: function () - { - this._pending--; - - if (this._pending === 0) - { - this.off('onload'); - this.off('onerror'); - - this.game.events.emit('ready'); - } - }, - - /** - * Adds a new Texture to the Texture Manager created from the given Base64 encoded data. - * - * @method Phaser.Textures.TextureManager#addBase64 - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {any} data - The Base64 encoded data. - */ - addBase64: function (key, data) - { - var _this = this; - - var image = new Image(); - - image.onerror = function () - { - _this.emit('onerror', key); - }; - - image.onload = function () - { - var texture = _this.create(key, image); - - Parser.Image(texture, 0); - - _this.emit('onload', key, texture); - }; - - image.src = data; - }, - - /** - * Adds a new Texture to the Texture Manager created from the given Image element. - * - * @method Phaser.Textures.TextureManager#addImage - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {Image} source - The source Image element. - * @param {Image} [dataSource] - An optional data Image element. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - addImage: function (key, source, dataSource) - { - var texture = this.create(key, source); - - Parser.Image(texture, 0); - - if (dataSource) - { - texture.setDataSource(dataSource); - } - - return texture; - }, - - /** - * Creates a new Texture using the given config values. - * Generated textures consist of a Canvas element to which the texture data is drawn. - * See the Phaser.Create function for the more direct way to create textures. - * - * @method Phaser.Textures.TextureManager#generate - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {object} config - [description] - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - generate: function (key, config) - { - var canvas = CanvasPool.create(this, 1, 1); - - config.canvas = canvas; - - GenerateTexture(config); - - return this.addCanvas(key, canvas); - }, - - /** - * Creates a new Texture using a blank Canvas element of the size given. - * - * Canvas elements are automatically pooled and calling this method will - * extract a free canvas from the CanvasPool, or create one if none are available. - * - * @method Phaser.Textures.TextureManager#createCanvas - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {integer} width - The width of the Canvas element. - * @param {integer} height - The height of the Canvas element. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - createCanvas: function (key, width, height) - { - if (width === undefined) { width = 256; } - if (height === undefined) { height = 256; } - - var canvas = CanvasPool.create(this, width, height); - - return this.addCanvas(key, canvas); - }, - - /** - * Creates a new Texture object from an existing Canvas element and adds - * it to this Texture Manager. - * - * @method Phaser.Textures.TextureManager#addCanvas - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {HTMLCanvasElement} source - The Canvas element to form the base of the new Texture. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - addCanvas: function (key, source) - { - var texture = this.create(key, source); - - Parser.Canvas(texture, 0); - - return texture; - }, - - /** - * Adds a new Texture Atlas to this Texture Manager. - * It can accept either JSON Array or JSON Hash formats, as exported by Texture Packer and similar software. - * - * @method Phaser.Textures.TextureManager#addAtlas - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {Image} source - The source Image element. - * @param {object} data - The Texture Atlas data. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - addAtlas: function (key, source, data) - { - // New Texture Packer format? - if (Array.isArray(data.textures) || Array.isArray(data.frames)) - { - return this.addAtlasJSONArray(key, source, data); - } - else - { - return this.addAtlasJSONHash(key, source, data); - } - }, - - /** - * Adds a Texture Atlas to this Texture Manager. - * The frame data of the atlas must be stored in an Array within the JSON. - * This is known as a JSON Array in software such as Texture Packer. - * - * @method Phaser.Textures.TextureManager#addAtlasJSONArray - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {Image} source - The source Image element. - * @param {object} data - The Texture Atlas data. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - addAtlasJSONArray: function (key, source, data) - { - var texture = this.create(key, source); - - if (Array.isArray(data)) - { - var singleAtlasFile = (data.length === 1); // multi-pack with one atlas file for all images - for (var i = 0; i < texture.source.length; i++) - { - var atlasData = singleAtlasFile ? data[0] : data[i]; - Parser.JSONArray(texture, i, atlasData); - } - } - else - { - Parser.JSONArray(texture, 0, data); - } - - return texture; - }, - - /** - * Adds a Texture Atlas to this Texture Manager. - * The frame data of the atlas must be stored in an Object within the JSON. - * This is known as a JSON Hash in software such as Texture Packer. - * - * @method Phaser.Textures.TextureManager#addAtlasJSONHash - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {Image} source - The source Image element. - * @param {object} data - The Texture Atlas data. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - addAtlasJSONHash: function (key, source, data) - { - var texture = this.create(key, source); - - if (Array.isArray(data)) - { - for (var i = 0; i < data.length; i++) - { - Parser.JSONHash(texture, i, data[i]); - } - } - else - { - Parser.JSONHash(texture, 0, data); - } - - return texture; - }, - - /** - * Adds a Unity Texture Atlas to this Texture Manager. - * The data must be in the form of a Unity YAML file. - * - * @method Phaser.Textures.TextureManager#addUnityAtlas - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {Image} source - The source Image element. - * @param {object} data - The Texture Atlas data. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - addUnityAtlas: function (key, source, data) - { - var texture = this.create(key, source); - - Parser.UnityYAML(texture, 0, data); - - return texture; - }, - - /** - * Adds a Sprite Sheet to this Texture Manager. - * - * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact - * same size and cannot be trimmed or rotated. - * - * @method Phaser.Textures.TextureManager#addSpriteSheet - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {Image} source - The source Image element. - * @param {object} config - The configuration object for this Sprite Sheet. - * @param {integer} config.frameWidth - The fixed width of each frame. - * @param {integer} [config.frameHeight] - The fixed height of each frame. If not set it will use the frameWidth as the height. - * @param {integer} [config.startFrame=0] - Skip a number of frames. Useful when there are multiple sprite sheets in one Texture. - * @param {integer} [config.endFrame=-1] - The total number of frames to extract from the Sprite Sheet. The default value of -1 means "extract all frames". - * @param {integer} [config.margin=0] - If the frames have been drawn with a margin, specify the amount here. - * @param {integer} [config.spacing=0] - If the frames have been drawn with spacing between them, specify the amount here. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - addSpriteSheet: function (key, source, config) - { - var texture = this.create(key, source); - - var width = texture.source[0].width; - var height = texture.source[0].height; - - Parser.SpriteSheet(texture, 0, 0, 0, width, height, config); - - return texture; - }, - - /** - * Adds a Sprite Sheet to this Texture Manager, where the Sprite Sheet exists as a Frame within a Texture Atlas. - * - * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact - * same size and cannot be trimmed or rotated. - * - * @method Phaser.Textures.TextureManager#addSpriteSheetFromAtlas - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {object} config - The configuration object for this Sprite Sheet. - * @param {string} config.atlas - The key of the Texture Atlas in which this Sprite Sheet can be found. - * @param {string} config.frame - The key of the Texture Atlas Frame in which this Sprite Sheet can be found. - * @param {integer} config.frameWidth - The fixed width of each frame. - * @param {integer} [config.frameHeight] - The fixed height of each frame. If not set it will use the frameWidth as the height. - * @param {integer} [config.startFrame=0] - Skip a number of frames. Useful when there are multiple sprite sheets in one Texture. - * @param {integer} [config.endFrame=-1] - The total number of frames to extract from the Sprite Sheet. The default value of -1 means "extract all frames". - * @param {integer} [config.margin=0] - If the frames have been drawn with a margin, specify the amount here. - * @param {integer} [config.spacing=0] - If the frames have been drawn with spacing between them, specify the amount here. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - addSpriteSheetFromAtlas: function (key, config) - { - var atlasKey = GetValue(config, 'atlas', null); - var atlasFrame = GetValue(config, 'frame', null); - - if (!atlasKey || !atlasFrame) - { - return; - } - - var atlas = this.get(atlasKey); - var sheet = atlas.get(atlasFrame); - - if (sheet) - { - var texture = this.create(key, sheet.source.image); - - if (sheet.trimmed) - { - // If trimmed we need to help the parser adjust - Parser.SpriteSheetFromAtlas(texture, sheet, config); - } - else - { - Parser.SpriteSheet(texture, 0, sheet.cutX, sheet.cutY, sheet.cutWidth, sheet.cutHeight, config); - } - - return texture; - } - }, - - /** - * Adds a Texture Atlas to this Texture Manager, where the atlas data is given - * in the Starling XML format. - * - * @method Phaser.Textures.TextureManager#addAtlasStarlingXML - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {Image} source - The source Image element. - * @param {object} data - The Texture Atlas XML data. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - addAtlasStarlingXML: function (key, source, data) - { - var texture = this.create(key, source); - - if (Array.isArray(data)) - { - for (var i = 0; i < data.length; i++) - { - Parser.StarlingXML(texture, i, data[i]); - } - } - else - { - Parser.StarlingXML(texture, 0, data); - } - - return texture; - }, - - /** - * Adds a Texture Atlas to this Texture Manager, where the atlas data is given - * in the Pyxel JSON format. - * - * @method Phaser.Textures.TextureManager#addAtlasPyxel - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {Image} source - The source Image element. - * @param {object} data - The Texture Atlas XML data. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - addAtlasPyxel: function (key, source, data) - { - var texture = this.create(key, source); - - if (Array.isArray(data)) - { - for (var i = 0; i < data.length; i++) - { - Parser.Pyxel(texture, i, data[i]); - } - } - else - { - Parser.Pyxel(texture, 0, data); - } - - return texture; - }, - - /** - * Creates a new Texture using the given source and dimensions. - * - * @method Phaser.Textures.TextureManager#create - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {Image} source - The source Image element. - * @param {integer} width - The width of the Texture. - * @param {integer} height - The height of the Texture. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - create: function (key, source, width, height) - { - var texture = new Texture(this, key, source, width, height); - - this.list[key] = texture; - - return texture; - }, - - /** - * Checks the given key to see if a Texture using it exists within this Texture Manager. - * - * @method Phaser.Textures.TextureManager#exists - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * - * @return {boolean} Returns `true` if a Texture matching the given key exists in this Texture Manager. - */ - exists: function (key) - { - return (this.list.hasOwnProperty(key)); - }, - - /** - * Returns a Texture from the Texture Manager that matches the given key. - * If the key is undefined it will return the `__DEFAULT` Texture. - * If the key is given, but not found, it will return the `__MISSING` Texture. - * - * @method Phaser.Textures.TextureManager#get - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - get: function (key) - { - if (key === undefined) { key = '__DEFAULT'; } - - if (this.list[key]) - { - return this.list[key]; - } - else - { - return this.list['__MISSING']; - } - }, - - /** - * Takes a Texture key and Frame name and returns a clone of that Frame if found. - * - * @method Phaser.Textures.TextureManager#cloneFrame - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {string|integer} frame - The string or index of the Frame to be cloned. - * - * @return {Phaser.Textures.Frame} A Clone of the given Frame. - */ - cloneFrame: function (key, frame) - { - if (this.list[key]) - { - return this.list[key].get(frame).clone(); - } - }, - - /** - * Takes a Texture key and Frame name and returns a reference to that Frame, if found. - * - * @method Phaser.Textures.TextureManager#getFrame - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {string|integer} frame - The string or index of the Frame. - * - * @return {Phaser.Textures.Frame} A Texture Frame object. - */ - getFrame: function (key, frame) - { - if (this.list[key]) - { - return this.list[key].get(frame); - } - }, - - /** - * Returns an array with all of the keys of all Textures in this Texture Manager. - * The output array will exclude the `__DEFAULT` and `__MISSING` keys. - * - * @method Phaser.Textures.TextureManager#getTextureKeys - * @since 3.0.0 - * - * @return {string[]} An array containing all of the Texture keys stored in this Texture Manager. - */ - getTextureKeys: function () - { - var output = []; - - for (var key in this.list) - { - if (key !== '__DEFAULT' && key !== '__MISSING') - { - output.push(key); - } - } - - return output; - }, - - /** - * Given a Texture and an `x` and `y` coordinate this method will return a new - * Color object that has been populated with the color and alpha values of the pixel - * at that location in the Texture. - * - * @method Phaser.Textures.TextureManager#getPixel - * @since 3.0.0 - * - * @param {integer} x - The x coordinate of the pixel within the Texture. - * @param {integer} y - The y coordinate of the pixel within the Texture. - * @param {string} key - The unique string-based key of the Texture. - * @param {string|integer} frame - The string or index of the Frame. - * - * @return {Phaser.Display.Color|null} A Color object populated with the color values of the requested pixel, - * or `null` if the coordinates were out of bounds. - */ - getPixel: function (x, y, key, frame) - { - var textureFrame = this.getFrame(key, frame); - - if (textureFrame) - { - var source = textureFrame.source.image; - - if (x >= 0 && x <= source.width && y >= 0 && y <= source.height) - { - x += textureFrame.cutX; - y += textureFrame.cutY; - - // if (textureFrame.trimmed) - // { - // x -= this.sprite.texture.trim.x; - // y -= this.sprite.texture.trim.y; - // } - - var context = this._tempContext; - - context.clearRect(0, 0, 1, 1); - context.drawImage(source, x, y, 1, 1, 0, 0, 1, 1); - - var rgb = context.getImageData(0, 0, 1, 1); - - return new Color(rgb.data[0], rgb.data[1], rgb.data[2], rgb.data[3]); - } - } - - return null; - }, - - /** - * Sets the given Game Objects `texture` and `frame` properties so that it uses - * the Texture and Frame specified in the `key` and `frame` arguments to this method. - * - * @method Phaser.Textures.TextureManager#setTexture - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - * @param {string} key - The unique string-based key of the Texture. - * @param {string|integer} frame - The string or index of the Frame. - * - * @return {Phaser.GameObjects.GameObject} The Game Object the texture was set on. - */ - setTexture: function (gameObject, key, frame) - { - if (this.list[key]) - { - gameObject.texture = this.list[key]; - gameObject.frame = gameObject.texture.get(frame); - } - - return gameObject; - }, - - /** - * Passes all Textures to the given callback. - * - * @method Phaser.Textures.TextureManager#each - * @since 3.0.0 - * - * @param {function} callback - The callback function to be sent the Textures. - * @param {object} scope - The value to use as `this` when executing the callback. - * @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the child. - */ - each: function (callback, scope) - { - var args = [ null ]; - - for (var i = 1; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - for (var texture in this.list) - { - args[0] = this.list[texture]; - - callback.apply(scope, args); - } - }, - - /** - * Destroys the Texture Manager and all Textures stored within it. - * - * @method Phaser.Textures.TextureManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - for (var texture in this.list) - { - this.list[texture].destroy(); - } - - this.list = {}; - - this.game = null; - } - -}); - -module.exports = TextureManager; - - -/***/ }), -/* 264 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Textures.Parsers - */ - -module.exports = { - - Canvas: __webpack_require__(533), - Image: __webpack_require__(534), - JSONArray: __webpack_require__(535), - JSONHash: __webpack_require__(536), - Pyxel: __webpack_require__(537), - SpriteSheet: __webpack_require__(538), - SpriteSheetFromAtlas: __webpack_require__(539), - StarlingXML: __webpack_require__(540), - UnityYAML: __webpack_require__(541) - -}; - - -/***/ }), -/* 265 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Frame = __webpack_require__(131); -var TextureSource = __webpack_require__(266); - -/** - * @classdesc - * A Texture consists of a source, usually an Image from the Cache, or a Canvas, and a collection - * of Frames. The Frames represent the different areas of the Texture. For example a texture atlas - * may have many Frames, one for each element within the atlas. Where-as a single image would have - * just one frame, that encompasses the whole image. - * - * Textures are managed by the global TextureManager. This is a singleton class that is - * responsible for creating and delivering Textures and their corresponding Frames to Game Objects. - * - * Sprites and other Game Objects get the texture data they need from the TextureManager. - * - * @class Texture - * @memberOf Phaser.Textures - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Textures.TextureManager} manager - A reference to the Texture Manager this Texture belongs to. - * @param {string} key - The unique string-based key of this Texture. - * @param {Image|HTMLCanvasElement} source - The source that is used to create the texture. Usually an Image, but can also be a Canvas. - * @param {number} [width] - The width of the Texture. This is optional and automatically derived from the source images. - * @param {number} [height] - The height of the Texture. This is optional and automatically derived from the source images. - */ -var Texture = new Class({ - - initialize: - - function Texture (manager, key, source, width, height) - { - if (!Array.isArray(source)) - { - source = [ source ]; - } - - /** - * A reference to the Texture Manager this Texture belongs to. - * - * @name Phaser.Textures.Texture#manager - * @type {Phaser.Textures.TextureManager} - * @since 3.0.0 - */ - this.manager = manager; - - /** - * The unique string-based key of this Texture. - * - * @name Phaser.Textures.Texture#key - * @type {string} - * @since 3.0.0 - */ - this.key = key; - - /** - * An array of TextureSource instances. - * These are unique to this Texture and contain the actual Image (or Canvas) data. - * - * @name Phaser.Textures.Texture#source - * @type {Phaser.Textures.TextureSource[]} - * @since 3.0.0 - */ - this.source = []; - - /** - * An array of TextureSource data instances. - * Used to store additional data images, such as normal maps or specular maps. - * - * @name Phaser.Textures.Texture#dataSource - * @type {array} - * @since 3.0.0 - */ - this.dataSource = []; - - /** - * A key-value object pair associating the unique Frame keys with the Frames objects. - * - * @name Phaser.Textures.Texture#frames - * @type {object} - * @since 3.0.0 - */ - this.frames = {}; - - /** - * Any additional data that was set in the source JSON (if any), - * or any extra data you'd like to store relating to this texture - * - * @name Phaser.Textures.Texture#customData - * @type {object} - * @since 3.0.0 - */ - this.customData = {}; - - /** - * The name of the first frame of the Texture. - * - * @name Phaser.Textures.Texture#firstFrame - * @type {string} - * @since 3.0.0 - */ - this.firstFrame = '__BASE'; - - /** - * The total number of Frames in this Texture. - * - * @name Phaser.Textures.Texture#frameTotal - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.frameTotal = 0; - - // Load the Sources - for (var i = 0; i < source.length; i++) - { - this.source.push(new TextureSource(this, source[i], width, height)); - } - }, - - /** - * Adds a new Frame to this Texture. - * - * A Frame is a rectangular region of a TextureSource with a unique index or string-based key. - * - * @method Phaser.Textures.Texture#add - * @since 3.0.0 - * - * @param {integer|string} name - The name of this Frame. The name is unique within the Texture. - * @param {integer} sourceIndex - The index of the TextureSource that this Frame is a part of. - * @param {number} x - The x coordinate of the top-left of this Frame. - * @param {number} y - The y coordinate of the top-left of this Frame. - * @param {number} width - The width of this Frame. - * @param {number} height - The height of this Frame. - * - * @return {Phaser.Textures.Frame} The Frame that was added to this Texture. - */ - add: function (name, sourceIndex, x, y, width, height) - { - var frame = new Frame(this, name, sourceIndex, x, y, width, height); - - this.frames[name] = frame; - - // Set the first frame of the Texture (other than __BASE) - // This is used to ensure we don't spam the display with entire - // atlases of sprite sheets, but instead just the first frame of them - // should the dev incorrectly specify the frame index - if (this.frameTotal === 1) - { - this.firstFrame = name; - } - - this.frameTotal++; - - return frame; - }, - - /** - * Checks to see if a Frame matching the given key exists within this Texture. - * - * @method Phaser.Textures.Texture#has - * @since 3.0.0 - * - * @param {string} name - The key of the Frame to check for. - * - * @return {boolean} True if a Frame with the matching key exists in this Texture. - */ - has: function (name) - { - return (this.frames[name]); - }, - - /** - * Gets a Frame from this Texture based on either the key or the index of the Frame. - * - * In a Texture Atlas Frames are typically referenced by a key. - * In a Sprite Sheet Frames are referenced by an index. - * Passing no value for the name returns the base texture. - * - * @method Phaser.Textures.Texture#get - * @since 3.0.0 - * - * @param {string|integer} [name] - The string-based name, or integer based index, of the Frame to get from this Texture. - * - * @return {Phaser.Textures.Frame} The Texture Frame. - */ - get: function (name) - { - // null, undefined, empty string, zero - if (!name) - { - name = this.firstFrame; - } - - var frame = this.frames[name]; - - if (!frame) - { - console.warn('No Texture.frame found with name ' + name); - - frame = this.frames[this.firstFrame]; - } - - return frame; - }, - - /** - * Takes the given TextureSource and returns the index of it within this Texture. - * If it's not in this Texture, it returns -1. - * Unless this Texture has multiple TextureSources, such as with a multi-atlas, this - * method will always return zero or -1. - * - * @method Phaser.Textures.Texture#getTextureSourceIndex - * @since 3.0.0 - * - * @param {Phaser.Textures.TextureSource} source - The TextureSource to check. - * - * @return {integer} The index of the TextureSource within this Texture, or -1 if not in this Texture. - */ - getTextureSourceIndex: function (source) - { - for (var i = 0; i < this.source.length; i++) - { - if (this.source[i] === source) - { - return i; - } - } - - return -1; - }, - - /** - * Returns an array of all the Frames in the given TextureSource. - * - * @method Phaser.Textures.Texture#getFramesFromTextureSource - * @since 3.0.0 - * - * @param {integer} sourceIndex - The index of the TextureSource to get the Frames from. - * - * @return {Phaser.Textures.Frame[]} An array of Texture Frames. - */ - getFramesFromTextureSource: function (sourceIndex) - { - var out = []; - - for (var frameName in this.frames) - { - if (frameName === '__BASE') - { - continue; - } - - var frame = this.frames[frameName]; - - if (frame.sourceIndex === sourceIndex) - { - out.push(frame.name); - } - } - - return out; - }, - - /** - * Returns an array with all of the names of the Frames in this Texture. - * - * Useful if you want to randomly assign a Frame to a Game Object, as you can - * pick a random element from the returned array. - * - * @method Phaser.Textures.Texture#getFrameNames - * @since 3.0.0 - * - * @param {boolean} [includeBase=false] - Include the `__BASE` Frame in the output array? - * - * @return {string[]} An array of all Frame names in this Texture. - */ - getFrameNames: function (includeBase) - { - if (includeBase === undefined) { includeBase = false; } - - var out = Object.keys(this.frames); - - if (!includeBase) - { - var idx = out.indexOf('__BASE'); - - if (idx !== -1) - { - out.splice(idx, 1); - } - } - - return out; - }, - - /** - * Given a Frame name, return the source image it uses to render with. - * - * This will return the actual DOM Image or Canvas element. - * - * @method Phaser.Textures.Texture#getSourceImage - * @since 3.0.0 - * - * @param {string|integer} [name] - The string-based name, or integer based index, of the Frame to get from this Texture. - * - * @return {Image|HTMLCanvasElement} The DOM Image or Canvas Element. - */ - getSourceImage: function (name) - { - if (name === undefined || name === null || this.frameTotal === 1) - { - name = '__BASE'; - } - - var frame = this.frames[name]; - - if (!frame) - { - console.warn('No Texture.frame found with name ' + name); - - return this.frames['__BASE'].source.image; - } - else - { - return frame.source.image; - } - }, - - /** - * Adds a data source image to this Texture. - * - * An example of a data source image would be a normal map, where all of the Frames for this Texture - * equally apply to the normal map. - * - * @method Phaser.Textures.Texture#setDataSource - * @since 3.0.0 - * - * @param {Image|HTMLCanvasElement} data - The source image. - */ - setDataSource: function (data) - { - if (!Array.isArray(data)) - { - data = [ data ]; - } - - for (var i = 0; i < data.length; i++) - { - var source = this.source[i]; - - this.dataSource.push(new TextureSource(this, data[i], source.width, source.height)); - } - }, - - /** - * Sets the Filter Mode for this Texture. - * - * The mode can be either Linear, the default, or Nearest. - * - * For pixel-art you should use Nearest. - * - * The mode applies to the entire Texture, not just a specific Frame of it. - * - * @method Phaser.Textures.Texture#setFilter - * @since 3.0.0 - * - * @param {Phaser.Textures.FilterMode.LINEAR|Phaser.Textures.FilterMode.NEAREST} filterMode - The Filter Mode. - */ - setFilter: function (filterMode) - { - var i; - - for (i = 0; i < this.source.length; i++) - { - this.source[i].setFilter(filterMode); - } - - for (i = 0; i < this.dataSource.length; i++) - { - this.dataSource[i].setFilter(filterMode); - } - }, - - /** - * Destroys this Texture and releases references to its sources and frames. - * - * @method Phaser.Textures.Texture#destroy - * @since 3.0.0 - */ - destroy: function () - { - var i; - - for (i = 0; i < this.source.length; i++) - { - this.source[i].destroy(); - } - - for (i = 0; i < this.dataSource.length; i++) - { - this.dataSource[i].destroy(); - } - - for (var frameName in this.frames) - { - var frame = this.frames[frameName]; - - frame.destroy(); - } - - this.source = []; - this.dataSource = []; - this.frames = {}; - } - -}); - -module.exports = Texture; - - -/***/ }), -/* 266 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(19); -var IsSizePowerOfTwo = __webpack_require__(127); -var ScaleModes = __webpack_require__(63); - -/** - * @classdesc - * A Texture Source is the encapsulation of the actual source data for a Texture. - * This is typically an Image Element, loaded from the file system or network, or a Canvas Element. - * - * A Texture can contain multiple Texture Sources, which only happens when a multi-atlas is loaded. - * - * @class TextureSource - * @memberOf Phaser.Textures - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture this TextureSource belongs to. - * @param {Image|HTMLCanvasElement} source - The source image data. - * @param {integer} [width] - Optional width of the source image. If not given it's derived from the source itself. - * @param {integer} [height] - Optional height of the source image. If not given it's derived from the source itself. - */ -var TextureSource = new Class({ - - initialize: - - function TextureSource (texture, source, width, height) - { - var game = texture.manager.game; - - /** - * The Texture this TextureSource belongs to. - * - * @name Phaser.Textures.TextureSource#texture - * @type {string} - * @since 3.0.0 - */ - this.texture = texture; - - /** - * The source image data. This is either an Image Element, or a Canvas Element. - * - * @name Phaser.Textures.TextureSource#image - * @type {Image|HTMLCanvasElement} - * @since 3.0.0 - */ - this.image = source; - - /** - * Currently un-used. - * - * @name Phaser.Textures.TextureSource#compressionAlgorithm - * @type {integer} - * @default null - * @since 3.0.0 - */ - this.compressionAlgorithm = null; - - /** - * The resolution of the source image. - * - * @name Phaser.Textures.TextureSource#resolution - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.resolution = 1; - - /** - * The width of the source image. If not specified in the constructor it will check - * the `naturalWidth` and then `width` properties of the source image. - * - * @name Phaser.Textures.TextureSource#width - * @type {integer} - * @since 3.0.0 - */ - this.width = width || source.naturalWidth || source.width || 0; - - /** - * The height of the source image. If not specified in the constructor it will check - * the `naturalHeight` and then `height` properties of the source image. - * - * @name Phaser.Textures.TextureSource#height - * @type {integer} - * @since 3.0.0 - */ - this.height = height || source.naturalHeight || source.height || 0; - - /** - * The Scale Mode the image will use when rendering. - * Either Linear or Nearest. - * - * @name Phaser.Textures.TextureSource#scaleMode - * @type {[type]} - * @since 3.0.0 - */ - this.scaleMode = ScaleModes.DEFAULT; - - /** - * Is the source image a Canvas Element? - * - * @name Phaser.Textures.TextureSource#isCanvas - * @type {boolean} - * @since 3.0.0 - */ - this.isCanvas = (source instanceof HTMLCanvasElement); - - /** - * Are the source image dimensions a power of two? - * - * @name Phaser.Textures.TextureSource#isPowerOf2 - * @type {boolean} - * @since 3.0.0 - */ - this.isPowerOf2 = IsSizePowerOfTwo(this.width, this.height); - - /** - * The WebGL Texture of the source image. - * - * @name Phaser.Textures.TextureSource#glTexture - * @type {?[type]} - * @default null - * @since 3.0.0 - */ - this.glTexture = null; - - this.init(game); - }, - - /** - * Creates a WebGL Texture, if required, and sets the Texture filter mode. - * - * @method Phaser.Textures.TextureSource#init - * @since 3.0.0 - * - * @param {Phaser.Game} game - A reference to the Phaser Game instance. - */ - init: function (game) - { - if (game.config.renderType === CONST.WEBGL) - { - this.glTexture = game.renderer.createTextureFromSource(this.image, this.width, this.height, this.scaleMode); - } - - if (game.config.pixelArt) - { - this.setFilter(1); - } - }, - - /** - * Sets the Filter Mode for this Texture. - * - * The mode can be either Linear, the default, or Nearest. - * - * For pixel-art you should use Nearest. - * - * @method Phaser.Textures.TextureSource#setFilter - * @since 3.0.0 - * - * @param {Phaser.Textures.FilterMode.LINEAR|Phaser.Textures.FilterMode.NEAREST} filterMode - The Filter Mode. - */ - setFilter: function (filterMode) - { - var game = this.texture.manager.game; - - if (game.config.renderType === CONST.WEBGL) - { - game.renderer.setTextureFilter(this.glTexture, filterMode); - } - }, - - /** - * Destroys this Texture Source and nulls the source image reference. - * - * @method Phaser.Textures.TextureSource#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.texture = null; - - this.image = null; - } - -}); - -module.exports = TextureSource; - - -/***/ }), -/* 267 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -//! stable.js 0.1.6, https://github.com/Two-Screen/stable -//! © 2017 Angry Bytes and contributors. MIT licensed. - -(function() { - -// A stable array sort, because `Array#sort()` is not guaranteed stable. -// This is an implementation of merge sort, without recursion. - -var stable = function(arr, comp) { - return exec(arr.slice(), comp); -}; - -stable.inplace = function(arr, comp) { - var result = exec(arr, comp); - - // This simply copies back if the result isn't in the original array, - // which happens on an odd number of passes. - if (result !== arr) { - pass(result, null, arr.length, arr); - } - - return arr; -}; - -// Execute the sort using the input array and a second buffer as work space. -// Returns one of those two, containing the final result. -function exec(arr, comp) { - if (typeof(comp) !== 'function') { - comp = function(a, b) { - return String(a).localeCompare(b); - }; - } - - // Short-circuit when there's nothing to sort. - var len = arr.length; - if (len <= 1) { - return arr; - } - - // Rather than dividing input, simply iterate chunks of 1, 2, 4, 8, etc. - // Chunks are the size of the left or right hand in merge sort. - // Stop when the left-hand covers all of the array. - var buffer = new Array(len); - for (var chk = 1; chk < len; chk *= 2) { - pass(arr, comp, chk, buffer); - - var tmp = arr; - arr = buffer; - buffer = tmp; - } - - return arr; -} - -// Run a single pass with the given chunk size. -var pass = function(arr, comp, chk, result) { - var len = arr.length; - var i = 0; - // Step size / double chunk size. - var dbl = chk * 2; - // Bounds of the left and right chunks. - var l, r, e; - // Iterators over the left and right chunk. - var li, ri; - - // Iterate over pairs of chunks. - for (l = 0; l < len; l += dbl) { - r = l + chk; - e = r + chk; - if (r > len) r = len; - if (e > len) e = len; - - // Iterate both chunks in parallel. - li = l; - ri = r; - while (true) { - // Compare the chunks. - if (li < r && ri < e) { - // This works for a regular `sort()` compatible comparator, - // but also for a simple comparator like: `a > b` - if (comp(arr[li], arr[ri]) <= 0) { - result[i++] = arr[li++]; - } - else { - result[i++] = arr[ri++]; - } - } - // Nothing to compare, just flush what's left. - else if (li < r) { - result[i++] = arr[li++]; - } - else if (ri < e) { - result[i++] = arr[ri++]; - } - // Both iterators are at the chunk ends. - else { - break; - } - } - } -}; - -// Export using CommonJS or to the window. -if (true) { - module.exports = stable; -} -else { - window.stable = stable; -} - -})(); - -/***/ }), -/* 268 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - - -var GetBitmapTextSize = function (src, round) -{ - var text = src.text; - var textLength = text.length; - - var bx = Number.MAX_VALUE; - var by = Number.MAX_VALUE; - var bw = 0; - var bh = 0; - - var chars = src.fontData.chars; - var lineHeight = src.fontData.lineHeight; - - var xAdvance = 0; - var yAdvance = 0; - - var indexCount = 0; - var charCode = 0; - - var glyph = null; - var glyphW = 0; - var glyphH = 0; - - var x = 0; - var y = 0; - - var lastGlyph = null; - var lastCharCode = 0; - - for (var index = 0; index < textLength; ++index) - { - charCode = text.charCodeAt(index); - - if (charCode === 10) - { - xAdvance = 0; - indexCount = 0; - yAdvance += lineHeight; - lastGlyph = null; - continue; - } - - glyph = chars[charCode]; - - if (!glyph) - { - continue; - } - - glyphW = glyph.width; - glyphH = glyph.height; - - x = indexCount + glyph.xOffset + xAdvance; - y = glyph.yOffset + yAdvance; - - if (lastGlyph !== null) - { - var kerningOffset = glyph.kerning[lastCharCode]; - x += (kerningOffset !== undefined) ? kerningOffset : 0; - } - - if (bx > x) - { - bx = x; - } - - if (by > y) - { - by = y; - } - - var gw = x + glyphW - bx; - var gh = y + glyphH - by; - - if (bw < gw) - { - bw = gw; - } - - if (bh < gh) - { - bh = gh; - } - - xAdvance += glyph.xAdvance; - indexCount += 1; - lastGlyph = glyph; - lastCharCode = charCode; - } - - var scale = (src.fontSize / src.fontData.size); - var sx = scale * src.scaleX; - var sy = scale * src.scaleY; - - var out = { - local: { - x: bx * scale, - y: by * scale, - width: bw * scale, - height: bh * scale - }, - global: { - x: src.x + (bx * sx), - y: src.y + (by * sy), - width: bw * sx, - height: bh * sy - } - }; - - if (round) - { - out.local.x = Math.round(out.local.x); - out.local.y = Math.round(out.local.y); - out.local.width = Math.round(out.local.width); - out.local.height = Math.round(out.local.height); - - out.global.x = Math.round(out.global.x); - out.global.y = Math.round(out.global.y); - out.global.width = Math.round(out.global.width); - out.global.height = Math.round(out.global.height); - } - - return out; -}; - -module.exports = GetBitmapTextSize; - - -/***/ }), -/* 269 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -function getValue (node, attribute) -{ - return parseInt(node.getAttribute(attribute), 10); -} - -var ParseXMLBitmapFont = function (xml, xSpacing, ySpacing, frame) -{ - if (xSpacing === undefined) { xSpacing = 0; } - if (ySpacing === undefined) { ySpacing = 0; } - - var data = {}; - var info = xml.getElementsByTagName('info')[0]; - var common = xml.getElementsByTagName('common')[0]; - - data.font = info.getAttribute('face'); - data.size = getValue(info, 'size'); - data.lineHeight = getValue(common, 'lineHeight') + ySpacing; - data.chars = {}; - - var letters = xml.getElementsByTagName('char'); - - var adjustForTrim = (frame !== undefined && frame.trimmed); - - if (adjustForTrim) - { - var top = frame.height; - var left = frame.width; - } - - for (var i = 0; i < letters.length; i++) - { - var node = letters[i]; - - var charCode = getValue(node, 'id'); - var gx = getValue(node, 'x'); - var gy = getValue(node, 'y'); - var gw = getValue(node, 'width'); - var gh = getValue(node, 'height'); - - // Handle frame trim issues - - if (adjustForTrim) - { - if (gx < left) - { - left = gx; - } - - if (gy < top) - { - top = gy; - } - } - - data.chars[charCode] = - { - x: gx, - y: gy, - width: gw, - height: gh, - centerX: Math.floor(gw / 2), - centerY: Math.floor(gh / 2), - xOffset: getValue(node, 'xoffset'), - yOffset: getValue(node, 'yoffset'), - xAdvance: getValue(node, 'xadvance') + xSpacing, - data: {}, - kerning: {} - }; - } - - if (adjustForTrim && top !== 0 && left !== 0) - { - // console.log('top and left', top, left, frame.x, frame.y); - - // Now we know the top and left coordinates of the glyphs in the original data - // so we can work out how much to adjust the glyphs by - - for (var code in data.chars) - { - var glyph = data.chars[code]; - - glyph.x -= frame.x; - glyph.y -= frame.y; - } - } - - var kernings = xml.getElementsByTagName('kerning'); - - for (i = 0; i < kernings.length; i++) - { - var kern = kernings[i]; - - var first = getValue(kern, 'first'); - var second = getValue(kern, 'second'); - var amount = getValue(kern, 'amount'); - - data.chars[second].kerning[first] = amount; - } - - return data; -}; - -module.exports = ParseXMLBitmapFont; - - -/***/ }), -/* 270 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Ellipse = __webpack_require__(137); - -Ellipse.Area = __webpack_require__(559); -Ellipse.Circumference = __webpack_require__(273); -Ellipse.CircumferencePoint = __webpack_require__(138); -Ellipse.Clone = __webpack_require__(560); -Ellipse.Contains = __webpack_require__(68); -Ellipse.ContainsPoint = __webpack_require__(561); -Ellipse.ContainsRect = __webpack_require__(562); -Ellipse.CopyFrom = __webpack_require__(563); -Ellipse.Equals = __webpack_require__(564); -Ellipse.GetBounds = __webpack_require__(565); -Ellipse.GetPoint = __webpack_require__(271); -Ellipse.GetPoints = __webpack_require__(272); -Ellipse.Offset = __webpack_require__(566); -Ellipse.OffsetPoint = __webpack_require__(567); -Ellipse.Random = __webpack_require__(110); - -module.exports = Ellipse; - - -/***/ }), -/* 271 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CircumferencePoint = __webpack_require__(138); -var FromPercent = __webpack_require__(65); -var MATH_CONST = __webpack_require__(16); -var Point = __webpack_require__(5); - -/** - * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse - * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point - * at 180 degrees around the circle. - * - * @function Phaser.Geom.Ellipse.GetPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on. - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. - * @param {Phaser.Geom.Point|object} [out] - An object to store the return values in. If not given a Point object will be created. - * - * @return {Phaser.Geom.Point|object} A Point, or point-like object, containing the coordinates of the point around the ellipse. - */ -var GetPoint = function (ellipse, position, out) -{ - if (out === undefined) { out = new Point(); } - - var angle = FromPercent(position, 0, MATH_CONST.PI2); - - return CircumferencePoint(ellipse, angle, out); -}; - -module.exports = GetPoint; - - -/***/ }), -/* 272 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Circumference = __webpack_require__(273); -var CircumferencePoint = __webpack_require__(138); -var FromPercent = __webpack_require__(65); -var MATH_CONST = __webpack_require__(16); - -/** - * Returns an array of Point objects containing the coordinates of the points around the circumference of the Ellipse, - * based on the given quantity or stepRate values. - * - * @function Phaser.Geom.Ellipse.GetPoints - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the points from. - * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param {number} [stepRate] - Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate. - * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. - * - * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the circumference of the ellipse. - */ -var GetPoints = function (ellipse, quantity, stepRate, out) -{ - if (out === undefined) { out = []; } - - // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. - if (!quantity) - { - quantity = Circumference(ellipse) / stepRate; - } - - for (var i = 0; i < quantity; i++) - { - var angle = FromPercent(i / quantity, 0, MATH_CONST.PI2); - - out.push(CircumferencePoint(ellipse, angle)); - } - - return out; -}; - -module.exports = GetPoints; - - -/***/ }), -/* 273 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the circumference of the given Ellipse. - * - * @function Phaser.Geom.Ellipse.Circumference - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference of. - * - * @return {number} The circumference of th Ellipse. - */ -var Circumference = function (ellipse) -{ - var rx = ellipse.width / 2; - var ry = ellipse.height / 2; - var h = Math.pow((rx - ry), 2) / Math.pow((rx + ry), 2); - - return (Math.PI * (rx + ry)) * (1 + ((3 * h) / (10 + Math.sqrt(4 - (3 * h))))); -}; - -module.exports = Circumference; - - -/***/ }), -/* 274 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Commands = __webpack_require__(128); -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Graphics#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Graphics} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {[type]} renderTargetCtx - [description] - * @param {boolean} allowClip - [description] - */ -var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, camera, renderTargetCtx, allowClip) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - var cameraScrollX = camera.scrollX * src.scrollFactorX; - var cameraScrollY = camera.scrollY * src.scrollFactorY; - var srcX = src.x; - var srcY = src.y; - var srcScaleX = src.scaleX; - var srcScaleY = src.scaleY; - var srcRotation = src.rotation; - var commandBuffer = src.commandBuffer; - var ctx = renderTargetCtx || renderer.currentContext; - var lineAlpha = 1.0; - var fillAlpha = 1.0; - var lineColor = 0; - var fillColor = 0; - var lineWidth = 1.0; - var red = 0; - var green = 0; - var blue = 0; - - // Blend Mode - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - ctx.save(); - ctx.translate(srcX - cameraScrollX, srcY - cameraScrollY); - ctx.rotate(srcRotation); - ctx.scale(srcScaleX, srcScaleY); - ctx.fillStyle = '#fff'; - ctx.globalAlpha = src.alpha; - - for (var index = 0, length = commandBuffer.length; index < length; ++index) - { - var commandID = commandBuffer[index]; - - switch (commandID) - { - case Commands.ARC: - ctx.arc( - commandBuffer[index + 1], - commandBuffer[index + 2], - commandBuffer[index + 3], - commandBuffer[index + 4], - commandBuffer[index + 5], - commandBuffer[index + 6] - ); - index += 6; - break; - - case Commands.LINE_STYLE: - lineWidth = commandBuffer[index + 1]; - lineColor = commandBuffer[index + 2]; - lineAlpha = commandBuffer[index + 3]; - red = ((lineColor & 0xFF0000) >>> 16); - green = ((lineColor & 0xFF00) >>> 8); - blue = (lineColor & 0xFF); - ctx.strokeStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + lineAlpha + ')'; - ctx.lineWidth = lineWidth; - index += 3; - break; - - case Commands.FILL_STYLE: - fillColor = commandBuffer[index + 1]; - fillAlpha = commandBuffer[index + 2]; - red = ((fillColor & 0xFF0000) >>> 16); - green = ((fillColor & 0xFF00) >>> 8); - blue = (fillColor & 0xFF); - ctx.fillStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + fillAlpha + ')'; - index += 2; - break; - - case Commands.BEGIN_PATH: - ctx.beginPath(); - break; - - case Commands.CLOSE_PATH: - ctx.closePath(); - break; - - case Commands.FILL_PATH: - if (!allowClip) - { - ctx.fill(); - } - break; - - case Commands.STROKE_PATH: - if (!allowClip) - { - ctx.stroke(); - } - break; - - case Commands.FILL_RECT: - if (!allowClip) - { - ctx.fillRect( - commandBuffer[index + 1], - commandBuffer[index + 2], - commandBuffer[index + 3], - commandBuffer[index + 4] - ); - } - else - { - ctx.rect( - commandBuffer[index + 1], - commandBuffer[index + 2], - commandBuffer[index + 3], - commandBuffer[index + 4] - ); - } - index += 4; - break; - - case Commands.FILL_TRIANGLE: - ctx.beginPath(); - ctx.moveTo(commandBuffer[index + 1], commandBuffer[index + 2]); - ctx.lineTo(commandBuffer[index + 3], commandBuffer[index + 4]); - ctx.lineTo(commandBuffer[index + 5], commandBuffer[index + 6]); - ctx.closePath(); - if (!allowClip) - { - ctx.fill(); - } - index += 6; - break; - - case Commands.STROKE_TRIANGLE: - ctx.beginPath(); - ctx.moveTo(commandBuffer[index + 1], commandBuffer[index + 2]); - ctx.lineTo(commandBuffer[index + 3], commandBuffer[index + 4]); - ctx.lineTo(commandBuffer[index + 5], commandBuffer[index + 6]); - ctx.closePath(); - if (!allowClip) - { - ctx.stroke(); - } - index += 6; - break; - - case Commands.LINE_TO: - ctx.lineTo( - commandBuffer[index + 1], - commandBuffer[index + 2] - ); - index += 2; - break; - - case Commands.MOVE_TO: - ctx.moveTo( - commandBuffer[index + 1], - commandBuffer[index + 2] - ); - index += 2; - break; - - case Commands.LINE_FX_TO: - ctx.lineTo( - commandBuffer[index + 1], - commandBuffer[index + 2] - ); - index += 5; - break; - - case Commands.MOVE_FX_TO: - ctx.moveTo( - commandBuffer[index + 1], - commandBuffer[index + 2] - ); - index += 5; - break; - - case Commands.SAVE: - ctx.save(); - break; - - case Commands.RESTORE: - ctx.restore(); - break; - - case Commands.TRANSLATE: - ctx.translate( - commandBuffer[index + 1], - commandBuffer[index + 2] - ); - index += 2; - break; - - case Commands.SCALE: - ctx.scale( - commandBuffer[index + 1], - commandBuffer[index + 2] - ); - index += 2; - break; - - case Commands.ROTATE: - ctx.rotate( - commandBuffer[index + 1] - ); - index += 1; - break; - - default: - // console.error('Phaser: Invalid Graphics Command ID ' + commandID); - break; - } - } - - ctx.restore(); -}; - -module.exports = GraphicsCanvasRenderer; - - -/***/ }), -/* 275 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetValue = __webpack_require__(4); -var Shuffle = __webpack_require__(80); - -var BuildChunk = function (a, b, qty) -{ - var out = []; - - for (var aIndex = 0; aIndex < a.length; aIndex++) - { - for (var bIndex = 0; bIndex < b.length; bIndex++) - { - for (var i = 0; i < qty; i++) - { - out.push({ a: a[aIndex], b: b[bIndex] }); - } - } - } - - return out; -}; - -// options = repeat, random, randomB, yoyo, max, qty - -// Range ([a,b,c], [1,2,3]) = -// a1, a2, a3, b1, b2, b3, c1, c2, c3 - -// Range ([a,b], [1,2,3], qty = 3) = -// a1, a1, a1, a2, a2, a2, a3, a3, a3, b1, b1, b1, b2, b2, b2, b3, b3, b3 - -// Range ([a,b,c], [1,2,3], repeat x1) = -// a1, a2, a3, b1, b2, b3, c1, c2, c3, a1, a2, a3, b1, b2, b3, c1, c2, c3 - -// Range ([a,b], [1,2], repeat -1 = endless, max = 14) = -// Maybe if max is set then repeat goes to -1 automatically? -// a1, a2, b1, b2, a1, a2, b1, b2, a1, a2, b1, b2, a1, a2 (capped at 14 elements) - -// Range ([a], [1,2,3,4,5], random = true) = -// a4, a1, a5, a2, a3 - -// Range ([a, b], [1,2,3], random = true) = -// b3, a2, a1, b1, a3, b2 - -// Range ([a, b, c], [1,2,3], randomB = true) = -// a3, a1, a2, b2, b3, b1, c1, c3, c2 - -// Range ([a], [1,2,3,4,5], yoyo = true) = -// a1, a2, a3, a4, a5, a5, a4, a3, a2, a1 - -// Range ([a, b], [1,2,3], yoyo = true) = -// a1, a2, a3, b1, b2, b3, b3, b2, b1, a3, a2, a1 - -/** - * [description] - * - * @function Phaser.Utils.Array.Range - * @since 3.0.0 - * - * @param {[type]} a - [description] - * @param {[type]} b - [description] - * @param {[type]} options - [description] - * - * @return {[type]} [description] - */ -var Range = function (a, b, options) -{ - var max = GetValue(options, 'max', 0); - var qty = GetValue(options, 'qty', 1); - var random = GetValue(options, 'random', false); - var randomB = GetValue(options, 'randomB', false); - var repeat = GetValue(options, 'repeat', 0); - var yoyo = GetValue(options, 'yoyo', false); - - var out = []; - - if (randomB) - { - Shuffle(b); - } - - // Endless repeat, so limit by max - if (repeat === -1) - { - if (max === 0) - { - repeat = 0; - } - else - { - // Work out how many repeats we need - var total = (a.length * b.length) * qty; - - if (yoyo) - { - total *= 2; - } - - repeat = Math.ceil(max / total); - } - } - - for (var i = 0; i <= repeat; i++) - { - var chunk = BuildChunk(a, b, qty); - - if (random) - { - Shuffle(chunk); - } - - out = out.concat(chunk); - - if (yoyo) - { - chunk.reverse(); - - out = out.concat(chunk); - } - } - - if (max) - { - out.splice(max); - } - - return out; -}; - -module.exports = Range; - - -/***/ }), -/* 276 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.FloatBetween - * @since 3.0.0 - * - * @param {float} min - [description] - * @param {float} max - [description] - * - * @return {float} [description] - */ -var FloatBetween = function (min, max) -{ - return Math.random() * (max - min) + min; -}; - -module.exports = FloatBetween; - - -/***/ }), -/* 277 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Phaser.Math.Easing.Back - -module.exports = { - - In: __webpack_require__(579), - Out: __webpack_require__(580), - InOut: __webpack_require__(581) - -}; - - -/***/ }), -/* 278 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Phaser.Math.Easing.Bounce - -module.exports = { - - In: __webpack_require__(582), - Out: __webpack_require__(583), - InOut: __webpack_require__(584) - -}; - - -/***/ }), -/* 279 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Phaser.Math.Easing.Circular - -module.exports = { - - In: __webpack_require__(585), - Out: __webpack_require__(586), - InOut: __webpack_require__(587) - -}; - - -/***/ }), -/* 280 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Phaser.Math.Easing.Cubic - -module.exports = { - - In: __webpack_require__(588), - Out: __webpack_require__(589), - InOut: __webpack_require__(590) - -}; - - -/***/ }), -/* 281 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Phaser.Math.Easing.Elastic - -module.exports = { - - In: __webpack_require__(591), - Out: __webpack_require__(592), - InOut: __webpack_require__(593) - -}; - - /***/ }), /* 282 */ /***/ (function(module, exports, __webpack_require__) { @@ -54286,15 +57317,423 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Phaser.Math.Easing.Expo +var BaseSoundManager = __webpack_require__(99); +var Class = __webpack_require__(0); +var HTML5AudioSound = __webpack_require__(281); -module.exports = { +/** + * HTML5 Audio implementation of the sound manager. + * + * @class HTML5AudioSoundManager + * @extends Phaser.Sound.BaseSoundManager + * @memberOf Phaser.Sound + * @constructor + * @author Pavle Goloskokovic (http://prunegames.com) + * @since 3.0.0 + * + * @param {Phaser.Game} game - Reference to the current game instance. + */ +var HTML5AudioSoundManager = new Class({ - In: __webpack_require__(594), - Out: __webpack_require__(595), - InOut: __webpack_require__(596) + Extends: BaseSoundManager, -}; + initialize: + + function HTML5AudioSoundManager (game) + { + /** + * Flag indicating whether if there are no idle instances of HTML5 Audio tag, + * for any particular sound, if one of the used tags should be hijacked and used + * for succeeding playback or if succeeding Phaser.Sound.HTML5AudioSound#play + * call should be ignored. + * + * @name Phaser.Sound.HTML5AudioSoundManager#override + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.override = true; + + /** + * Value representing time difference, in seconds, between calling + * play method on an audio tag and when it actually starts playing. + * It is used to achieve more accurate delayed sound playback. + * + * You might need to tweak this value to get the desired results + * since audio play delay varies depending on the browser/platform. + * + * @name Phaser.Sound.HTML5AudioSoundManager#audioPlayDelay + * @type {number} + * @default 0.1 + * @since 3.0.0 + */ + this.audioPlayDelay = 0.1; + + /** + * A value by which we should offset the loop end marker of the + * looping sound to compensate for lag, caused by changing audio + * tag playback position, in order to achieve gapless looping. + * + * You might need to tweak this value to get the desired results + * since loop lag varies depending on the browser/platform. + * + * @name Phaser.Sound.HTML5AudioSoundManager#loopEndOffset + * @type {number} + * @default 0.05 + * @since 3.0.0 + */ + this.loopEndOffset = 0.05; + + /** + * An array for keeping track of all the sounds + * that were paused when game lost focus. + * + * @name Phaser.Sound.HTML5AudioSoundManager#onBlurPausedSounds + * @type {Phaser.Sound.HTML5AudioSound[]} + * @private + * @default [] + * @since 3.0.0 + */ + this.onBlurPausedSounds = []; + + this.locked = 'ontouchstart' in window; + + /** + * A queue of all actions performed on sound objects while audio was locked. + * Once the audio gets unlocked, after an explicit user interaction, + * all actions will be performed in chronological order. + * Array of object types: { sound: Phaser.Sound.HTML5AudioSound, name: string, value?: * } + * + * @name Phaser.Sound.HTML5AudioSoundManager#lockedActionsQueue + * @type {array} + * @private + * @since 3.0.0 + */ + this.lockedActionsQueue = this.locked ? [] : null; + + /** + * Property that actually holds the value of global mute + * for HTML5 Audio sound manager implementation. + * + * @name Phaser.Sound.HTML5AudioSoundManager#_mute + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._mute = false; + + /** + * Property that actually holds the value of global volume + * for HTML5 Audio sound manager implementation. + * + * @name Phaser.Sound.HTML5AudioSoundManager#_volume + * @type {boolean} + * @private + * @default 1 + * @since 3.0.0 + */ + this._volume = 1; + + BaseSoundManager.call(this, game); + }, + + /** + * Adds a new sound into the sound manager. + * + * @method Phaser.Sound.HTML5AudioSoundManager#add + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * + * @return {Phaser.Sound.HTML5AudioSound} The new sound instance. + */ + add: function (key, config) + { + var sound = new HTML5AudioSound(this, key, config); + + this.sounds.push(sound); + + return sound; + }, + + /** + * Unlocks HTML5 Audio loading and playback on mobile + * devices on the initial explicit user interaction. + * + * @method Phaser.Sound.HTML5AudioSoundManager#unlock + * @since 3.0.0 + */ + unlock: function () + { + var _this = this; + + var moved = false; + + var detectMove = function () + { + moved = true; + }; + + var unlock = function () + { + if (!_this.game.cache.audio.entries.size) + { + return; + } + + if (moved) + { + moved = false; + return; + } + + document.body.removeEventListener('touchmove', detectMove); + document.body.removeEventListener('touchend', unlock); + + var allTags = []; + + _this.game.cache.audio.entries.each(function (key, tags) + { + for (var i = 0; i < tags.length; i++) + { + allTags.push(tags[i]); + } + return true; + }); + + var lastTag = allTags[allTags.length - 1]; + + lastTag.oncanplaythrough = function () + { + lastTag.oncanplaythrough = null; + _this.unlocked = true; + }; + + allTags.forEach(function (tag) + { + tag.load(); + }); + }; + + this.once('unlocked', function () + { + this.forEachActiveSound(function (sound) + { + sound.duration = sound.tags[0].duration; + sound.totalDuration = sound.tags[0].duration; + }); + + this.lockedActionsQueue.forEach(function (lockedAction) + { + if (lockedAction.sound[lockedAction.prop].apply) + { + lockedAction.sound[lockedAction.prop].apply(lockedAction.sound, lockedAction.value || []); + } + else + { + lockedAction.sound[lockedAction.prop] = lockedAction.value; + } + }); + + this.lockedActionsQueue.length = 0; + this.lockedActionsQueue = null; + }, this); + + document.body.addEventListener('touchmove', detectMove, false); + document.body.addEventListener('touchend', unlock, false); + }, + + /** + * Method used internally for pausing sound manager if + * Phaser.Sound.HTML5AudioSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.HTML5AudioSoundManager#onBlur + * @protected + * @since 3.0.0 + */ + onBlur: function () + { + this.forEachActiveSound(function (sound) + { + if (sound.isPlaying) + { + this.onBlurPausedSounds.push(sound); + sound.onBlur(); + } + }); + }, + + /** + * Method used internally for resuming sound manager if + * Phaser.Sound.HTML5AudioSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.HTML5AudioSoundManager#onFocus + * @protected + * @since 3.0.0 + */ + onFocus: function () + { + this.onBlurPausedSounds.forEach(function (sound) + { + sound.onFocus(); + }); + + this.onBlurPausedSounds.length = 0; + }, + + /** + * Calls Phaser.Sound.BaseSoundManager#destroy method + * and cleans up all HTML5 Audio related stuff. + * + * @method Phaser.Sound.HTML5AudioSoundManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + BaseSoundManager.prototype.destroy.call(this); + + this.onBlurPausedSounds.length = 0; + this.onBlurPausedSounds = null; + }, + + /** + * Method used internally by Phaser.Sound.HTML5AudioSound class methods and property setters + * to check if sound manager is locked and then either perform action immediately or queue it + * to be performed once the sound manager gets unlocked. + * + * @method Phaser.Sound.HTML5AudioSoundManager#isLocked + * @protected + * @since 3.0.0 + * + * @param {Phaser.Sound.HTML5AudioSound} sound - Sound object on which to perform queued action. + * @param {string} prop - Name of the method to be called or property to be assigned a value to. + * @param {*} [value] - An optional parameter that either holds an array of arguments to be passed to the method call or value to be set to the property. + * + * @return {boolean} Whether the sound manager is locked. + */ + isLocked: function (sound, prop, value) + { + if (this.locked) + { + this.lockedActionsQueue.push({ + sound: sound, + prop: prop, + value: value + }); + + return true; + } + + return false; + }, + + /** + * @event Phaser.Sound.HTML5AudioSoundManager#MuteEvent + * @param {Phaser.Sound.HTML5AudioSoundManager} soundManager - Reference to the sound manager that emitted event. + * @param {boolean} value - An updated value of Phaser.Sound.HTML5AudioSoundManager#mute property. + */ + + /** + * Sets the muted state of all this Sound Manager. + * + * @method Phaser.Sound.HTML5AudioSoundManager#setMute + * @fires Phaser.Sound.HTML5AudioSoundManager#MuteEvent + * @since 3.3.0 + * + * @param {boolean} value - `true` to mute all sounds, `false` to unmute them. + * + * @return {Phaser.Sound.HTML5AudioSoundManager} This Sound Manager. + */ + setMute: function (value) + { + this.mute = value; + + return this; + }, + + /** + * @name Phaser.Sound.HTML5AudioSoundManager#mute + * @type {boolean} + * @fires Phaser.Sound.HTML5AudioSoundManager#MuteEvent + * @since 3.0.0 + */ + mute: { + + get: function () + { + return this._mute; + }, + + set: function (value) + { + this._mute = value; + + this.forEachActiveSound(function (sound) + { + sound.setMute(); + }); + + this.emit('mute', this, value); + } + + }, + + /** + * @event Phaser.Sound.HTML5AudioSoundManager#VolumeEvent + * @param {Phaser.Sound.HTML5AudioSoundManager} soundManager - Reference to the sound manager that emitted event. + * @param {number} value - An updated value of Phaser.Sound.HTML5AudioSoundManager#volume property. + */ + + /** + * Sets the volume of this Sound Manager. + * + * @method Phaser.Sound.HTML5AudioSoundManager#setVolume + * @fires Phaser.Sound.HTML5AudioSoundManager#VolumeEvent + * @since 3.3.0 + * + * @param {number} value - The global volume of this Sound Manager. + * + * @return {Phaser.Sound.HTML5AudioSoundManager} This Sound Manager. + */ + setVolume: function (value) + { + this.volume = value; + + return this; + }, + + /** + * @name Phaser.Sound.HTML5AudioSoundManager#volume + * @type {number} + * @fires Phaser.Sound.HTML5AudioSoundManager#VolumeEvent + * @since 3.0.0 + */ + volume: { + + get: function () + { + return this._volume; + }, + + set: function (value) + { + this._volume = value; + + this.forEachActiveSound(function (sound) + { + sound.setVolume(); + }); + + this.emit('volume', this, value); + } + + } + +}); + +module.exports = HTML5AudioSoundManager; /***/ }), @@ -54307,9 +57746,42 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Phaser.Math.Easing.Linear +var HTML5AudioSoundManager = __webpack_require__(282); +var NoAudioSoundManager = __webpack_require__(280); +var WebAudioSoundManager = __webpack_require__(278); -module.exports = __webpack_require__(597); +/** + * Creates a Web Audio, HTML5 Audio or No Audio Sound Manager based on config and device settings. + * + * @function Phaser.Sound.SoundManagerCreator + * @author Pavle Goloskokovic (http://prunegames.com) + * @since 3.0.0 + * + * @param {Phaser.Game} game - Reference to the current game instance. + */ +var SoundManagerCreator = { + + create: function (game) + { + var audioConfig = game.config.audio; + var deviceAudio = game.device.audio; + + if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) + { + return new NoAudioSoundManager(game); + } + + if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio)) + { + return new WebAudioSoundManager(game); + } + + return new HTML5AudioSoundManager(game); + } + +}; + +module.exports = SoundManagerCreator; /***/ }), @@ -54322,20 +57794,114 @@ module.exports = __webpack_require__(597); * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Phaser.Math.Easing.Quadratic +var CONST = __webpack_require__(75); +var GetValue = __webpack_require__(5); +var InjectionMap = __webpack_require__(795); -module.exports = { +// TODO 22/03/2018 Fix "plugins" type - In: __webpack_require__(598), - Out: __webpack_require__(599), - InOut: __webpack_require__(600) +/** + * @typedef {object} SettingsConfig + * + * @property {string} [key] - [description] + * @property {boolean} [active=false] - [description] + * @property {boolean} [visible=true] - [description] + * @property {(false|LoaderFileObject[])} [files=false] - [description] + * @property {?(InputJSONCameraObject|InputJSONCameraObject[])} [cameras=null] - [description] + * @property {Object.} [map] - [description] + * @property {object} [physics={}] - [description] + * @property {object} [loader={}] - [description] + * @property {(false|*)} [plugins=false] - [description] + */ + +/** + * @typedef {object} SettingsObject + * + * @property {number} status - [description] + * @property {string} key - [description] + * @property {boolean} active - [description] + * @property {boolean} visible - [description] + * @property {boolean} isBooted - [description] + * @property {object} data - [description] + * @property {(false|LoaderFileObject[])} files - [description] + * @property {?(InputJSONCameraObject|InputJSONCameraObject[])} cameras - [description] + * @property {Object.} map - [description] + * @property {object} physics - [description] + * @property {object} loader - [description] + * @property {(false|*)} plugins - [description] + */ + +var Settings = { + + /** + * Takes a Scene configuration object and returns a fully formed Systems object. + * + * @function Phaser.Scenes.Settings.create + * @since 3.0.0 + * + * @param {(string|SettingsConfig)} config - [description] + * + * @return {SettingsObject} [description] + */ + create: function (config) + { + if (typeof config === 'string') + { + config = { key: config }; + } + else if (config === undefined) + { + // Pass the 'hasOwnProperty' checks + config = {}; + } + + return { + + status: CONST.PENDING, + + key: GetValue(config, 'key', ''), + active: GetValue(config, 'active', false), + visible: GetValue(config, 'visible', true), + + isBooted: false, + + // Loader payload array + + data: {}, + + files: GetValue(config, 'files', false), + + // Cameras + + cameras: GetValue(config, 'cameras', null), + + // Scene Property Injection Map + + map: GetValue(config, 'map', InjectionMap), + + // Physics + + physics: GetValue(config, 'physics', {}), + + // Loader + + loader: GetValue(config, 'loader', {}), + + // Plugins + + plugins: GetValue(config, 'plugins', false) + + }; + } }; +module.exports = Settings; + /***/ }), /* 285 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -54343,16 +57909,23 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Phaser.Math.Easing.Quartic - -module.exports = { - - In: __webpack_require__(601), - Out: __webpack_require__(602), - InOut: __webpack_require__(603) - +/** + * [description] + * + * @function Phaser.Utils.String.UppercaseFirst + * @since 3.0.0 + * + * @param {string} str - [description] + * + * @return {string} [description] + */ +var UppercaseFirst = function (str) +{ + return str && str[0].toUpperCase() + str.slice(1); }; +module.exports = UppercaseFirst; + /***/ }), /* 286 */ @@ -54364,15 +57937,50 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Phaser.Math.Easing.Quintic +var Class = __webpack_require__(0); +var Systems = __webpack_require__(142); -module.exports = { +/** + * @classdesc + * [description] + * + * @class Scene + * @memberOf Phaser + * @constructor + * @since 3.0.0 + * + * @param {(string|SettingsConfig)} config - Scene specific configuration settings. + */ +var Scene = new Class({ - In: __webpack_require__(604), - Out: __webpack_require__(605), - InOut: __webpack_require__(606) + initialize: -}; + function Scene (config) + { + /** + * The Scene Systems. You must never overwrite this property, or all hell will break lose. + * + * @name Phaser.Scene#sys + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.sys = new Systems(this, config); + }, + + /** + * Should be overridden by your own Scenes. + * + * @method Phaser.Scene#update + * @override + * @since 3.0.0 + */ + update: function () + { + } + +}); + +module.exports = Scene; /***/ }), @@ -54385,15 +57993,1392 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Phaser.Math.Easing.Sine +var Class = __webpack_require__(0); +var CONST = __webpack_require__(75); +var GetValue = __webpack_require__(5); +var NOOP = __webpack_require__(3); +var Scene = __webpack_require__(286); +var Systems = __webpack_require__(142); -module.exports = { +/** + * @classdesc + * The Scene Manager. + * + * The Scene Manager is a Game level system, responsible for creating, processing and updating all of the + * Scenes in a Game instance. + * + * + * @class SceneManager + * @memberOf Phaser.Scenes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Phaser.Game instance this Scene Manager belongs to. + * @param {object} sceneConfig - Scene specific configuration settings. + */ +var SceneManager = new Class({ - In: __webpack_require__(607), - Out: __webpack_require__(608), - InOut: __webpack_require__(609) + initialize: -}; + function SceneManager (game, sceneConfig) + { + /** + * [description] + * + * @name Phaser.Scenes.SceneManager#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game = game; + + /** + * An object that maps the keys to the scene so we can quickly get a scene from a key without iteration. + * + * @name Phaser.Scenes.SceneManager#keys + * @type {object} + * @since 3.0.0 + */ + this.keys = {}; + + /** + * The array in which all of the scenes are kept. + * + * @name Phaser.Scenes.SceneManager#scenes + * @type {array} + * @since 3.0.0 + */ + this.scenes = []; + + /** + * Scenes pending to be added are stored in here until the manager has time to add it. + * + * @name Phaser.Scenes.SceneManager#_pending + * @type {array} + * @private + * @since 3.0.0 + */ + this._pending = []; + + /** + * An array of scenes waiting to be started once the game has booted. + * + * @name Phaser.Scenes.SceneManager#_start + * @type {array} + * @private + * @since 3.0.0 + */ + this._start = []; + + /** + * An operations queue, because we don't manipulate the scenes array during processing. + * + * @name Phaser.Scenes.SceneManager#_queue + * @type {array} + * @private + * @since 3.0.0 + */ + this._queue = []; + + /** + * The number of Scenes to process. + * + * @name Phaser.Scenes.SceneManager#_processing + * @type {integer} + * @private + * @since 3.0.0 + */ + this._processing = 0; + + if (sceneConfig) + { + if (!Array.isArray(sceneConfig)) + { + sceneConfig = [ sceneConfig ]; + } + + for (var i = 0; i < sceneConfig.length; i++) + { + // The i === 0 part just autostarts the first Scene given (unless it says otherwise in its config) + this._pending.push({ + key: 'default', + scene: sceneConfig[i], + autoStart: (i === 0), + data: {} + }); + } + + // Only need to wait for the boot event if we've scenes to actually boot + game.events.once('ready', this.bootQueue, this); + } + }, + + /** + * Internal first-time Scene boot handler. + * + * @method Phaser.Scenes.SceneManager#bootQueue + * @private + * @since 3.2.0 + */ + bootQueue: function () + { + var i; + var entry; + var key; + var sceneConfig; + + for (i = 0; i < this._pending.length; i++) + { + entry = this._pending[i]; + + key = entry.key; + sceneConfig = entry.scene; + + var newScene; + + if (sceneConfig instanceof Scene) + { + newScene = this.createSceneFromInstance(key, sceneConfig); + } + else if (typeof sceneConfig === 'object') + { + newScene = this.createSceneFromObject(key, sceneConfig); + } + else if (typeof sceneConfig === 'function') + { + newScene = this.createSceneFromFunction(key, sceneConfig); + } + + // Replace key in case the scene changed it + key = newScene.sys.settings.key; + + this.keys[key] = newScene; + + this.scenes.push(newScene); + + if (entry.autoStart || newScene.sys.settings.active) + { + this._start.push(key); + } + } + + // Clear the pending lists + this._pending.length = 0; + + // _start might have been populated by the above + for (i = 0; i < this._start.length; i++) + { + entry = this._start[i]; + + this.start(entry); + } + + this._start.length = 0; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#processQueue + * @since 3.0.0 + */ + processQueue: function () + { + var pendingLength = this._pending.length; + var queueLength = this._queue.length; + + if (pendingLength === 0 && queueLength === 0) + { + return; + } + + var i; + var entry; + + if (pendingLength) + { + for (i = 0; i < pendingLength; i++) + { + entry = this._pending[i]; + + this.add(entry.key, entry.scene, entry.autoStart); + } + + // _start might have been populated by this.add + for (i = 0; i < this._start.length; i++) + { + entry = this._start[i]; + + this.start(entry); + } + + // Clear the pending lists + this._start.length = 0; + this._pending.length = 0; + + return; + } + + for (i = 0; i < this._queue.length; i++) + { + entry = this._queue[i]; + + this[entry.op](entry.keyA, entry.keyB); + } + + this._queue.length = 0; + }, + + /** + * Adds a new Scene into the SceneManager. + * You must give each Scene a unique key by which you'll identify it. + * + * The `sceneConfig` can be: + * + * * A `Phaser.Scene` object, or an object that extends it. + * * A plain JavaScript object + * * A JavaScript ES6 Class that extends `Phaser.Scene` + * * A JavaScript ES5 prototype based Class + * * A JavaScript function + * + * If a function is given then a new Scene will be created by calling it. + * + * @method Phaser.Scenes.SceneManager#add + * @since 3.0.0 + * + * @param {string} key - A unique key used to reference the Scene, i.e. `MainMenu` or `Level1`. + * @param {(Phaser.Scene|SettingsConfig|function)} sceneConfig - [description] + * @param {boolean} [autoStart=false] - If `true` the Scene will be started immediately after being added. + * + * @return {?Phaser.Scene} [description] + */ + add: function (key, sceneConfig, autoStart) + { + if (autoStart === undefined) { autoStart = false; } + + // if not booted, then put scene into a holding pattern + if (this._processing === 1 || !this.game.isBooted) + { + this._pending.push({ + key: key, + scene: sceneConfig, + autoStart: autoStart, + data: {} + }); + + return null; + } + + key = this.getKey(key, sceneConfig); + + var newScene; + + if (sceneConfig instanceof Scene) + { + newScene = this.createSceneFromInstance(key, sceneConfig); + } + else if (typeof sceneConfig === 'object') + { + sceneConfig.key = key; + + newScene = this.createSceneFromObject(key, sceneConfig); + } + else if (typeof sceneConfig === 'function') + { + newScene = this.createSceneFromFunction(key, sceneConfig); + } + + // Replace key in case the scene changed it + key = newScene.sys.settings.key; + + this.keys[key] = newScene; + + this.scenes.push(newScene); + + if (autoStart || newScene.sys.settings.active) + { + if (this.game.isBooted) + { + this.start(key); + } + else + { + this._start.push(key); + } + } + + return newScene; + }, + + /** + * Removes a Scene from the SceneManager. + * + * The Scene is removed from the local scenes array, it's key is cleared from the keys + * cache and Scene.Systems.destroy is then called on it. + * + * If the SceneManager is processing the Scenes when this method is called it wil + * queue the operation for the next update sequence. + * + * @method Phaser.Scenes.SceneManager#remove + * @since 3.2.0 + * + * @param {(string|Phaser.Scene)} scene - The Scene to be removed. + * + * @return {Phaser.Scenes.SceneManager} This SceneManager. + */ + remove: function (key) + { + if (this._processing) + { + this._queue.push({ op: 'remove', keyA: key, keyB: null }); + } + else + { + var sceneToRemove = this.getScene(key); + + if (!sceneToRemove) + { + return this; + } + + var index = this.scenes.indexOf(sceneToRemove); + var sceneKey = sceneToRemove.sys.settings.key; + + if (index > -1) + { + delete this.keys[sceneKey]; + this.scenes.splice(index, 1); + + if (this._start.indexOf(sceneKey) > -1) + { + index = this._start.indexOf(sceneKey); + this._start.splice(index, 1); + } + + sceneToRemove.sys.destroy(); + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#bootScene + * @private + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ + bootScene: function (scene) + { + if (scene.init) + { + scene.init.call(scene, scene.sys.settings.data); + } + + var loader; + + if (scene.sys.load) + { + loader = scene.sys.load; + + loader.reset(); + } + + if (loader && scene.preload) + { + scene.preload.call(scene); + + // Is the loader empty? + if (loader.list.size === 0) + { + this.create(scene); + } + else + { + scene.sys.settings.status = CONST.LOADING; + + // Start the loader going as we have something in the queue + loader.once('complete', this.loadComplete, this); + + loader.start(); + } + } + else + { + // No preload? Then there was nothing to load either + this.create(scene); + } + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#loadComplete + * @private + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - [description] + */ + loadComplete: function (loader) + { + var scene = loader.scene; + + this.create(scene); + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#payloadComplete + * @private + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - [description] + */ + payloadComplete: function (loader) + { + this.bootScene(loader.scene); + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#update + * @since 3.0.0 + * + * @param {number} time - [description] + * @param {number} delta - [description] + */ + update: function (time, delta) + { + this.processQueue(); + + this._processing = 1; + + // Loop through the active scenes in reverse order + for (var i = this.scenes.length - 1; i >= 0; i--) + { + var sys = this.scenes[i].sys; + + if (sys.settings.status === CONST.RUNNING) + { + sys.step(time, delta); + } + } + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#resize + * @since 3.2.0 + * + * @param {number} width - The new width of the game. + * @param {number} height - The new height of the game. + */ + resize: function (width, height) + { + // Loop through the scenes in forward order + for (var i = 0; i < this.scenes.length; i++) + { + var sys = this.scenes[i].sys; + + sys.resize(width, height); + } + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#render + * @since 3.0.0 + * + * @param {*} renderer - [description] + */ + render: function (renderer) + { + // Loop through the scenes in forward order + for (var i = 0; i < this.scenes.length; i++) + { + var sys = this.scenes[i].sys; + + if (sys.settings.visible && sys.settings.status >= CONST.LOADING && sys.settings.status < CONST.SLEEPING) + { + sys.render(renderer); + } + } + + this._processing = 0; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#create + * @private + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ + create: function (scene) + { + if (scene.create) + { + scene.sys.settings.status = CONST.CREATING; + + scene.create.call(scene, scene.sys.settings.data); + } + + scene.sys.settings.status = CONST.RUNNING; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#createSceneFromFunction + * @private + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {function} scene - [description] + * + * @return {Phaser.Scene} [description] + */ + createSceneFromFunction: function (key, scene) + { + var newScene = new scene(); + + if (newScene instanceof Scene) + { + var configKey = newScene.sys.settings.key; + + if (configKey !== '') + { + key = configKey; + } + + if (this.keys.hasOwnProperty(key)) + { + throw new Error('Cannot add a Scene with duplicate key: ' + key); + } + + return this.createSceneFromInstance(key, newScene); + } + else + { + newScene.sys = new Systems(newScene); + + newScene.sys.settings.key = key; + + newScene.sys.init(this.game); + + if (!newScene.update) + { + newScene.update = NOOP; + } + + return newScene; + } + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#createSceneFromInstance + * @private + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {Phaser.Scene} newScene - [description] + * + * @return {Phaser.Scene} [description] + */ + createSceneFromInstance: function (key, newScene) + { + var configKey = newScene.sys.settings.key; + + if (configKey !== '') + { + key = configKey; + } + else + { + newScene.sys.settings.key = key; + } + + newScene.sys.init(this.game); + + return newScene; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#createSceneFromObject + * @private + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {(string|SettingsConfig)} sceneConfig - [description] + * + * @return {Phaser.Scene} [description] + */ + createSceneFromObject: function (key, sceneConfig) + { + var newScene = new Scene(sceneConfig); + + var configKey = newScene.sys.settings.key; + + if (configKey !== '') + { + key = configKey; + } + else + { + newScene.sys.settings.key = key; + } + + newScene.sys.init(this.game); + + // Extract callbacks + + var defaults = [ 'init', 'preload', 'create', 'update', 'render' ]; + + for (var i = 0; i < defaults.length; i++) + { + var sceneCallback = GetValue(sceneConfig, defaults[i], null); + + // Must always have an update function, no matter what (the rest are optional) + if (defaults[i] === 'update' && !sceneCallback) + { + sceneCallback = NOOP; + } + + if (sceneCallback) + { + newScene[defaults[i]] = sceneCallback; + } + } + + // Now let's move across any other functions or properties that may exist in the extend object: + + /* + scene: { + preload: preload, + create: create, + extend: { + hello: 1, + test: 'atari', + addImage: addImage + } + } + */ + + if (sceneConfig.hasOwnProperty('extend')) + { + for (var propertyKey in sceneConfig.extend) + { + newScene[propertyKey] = sceneConfig.extend[propertyKey]; + } + } + + return newScene; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#getKey + * @private + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {(Phaser.Scene|SettingsConfig|function)} sceneConfig - [description] + * + * @return {string} [description] + */ + getKey: function (key, sceneConfig) + { + if (!key) { key = 'default'; } + + if (typeof sceneConfig === 'function') + { + return key; + } + else if (sceneConfig instanceof Scene) + { + key = sceneConfig.sys.settings.key; + } + else if (typeof sceneConfig === 'object' && sceneConfig.hasOwnProperty('key')) + { + key = sceneConfig.key; + } + + // By this point it's either 'default' or extracted from the Scene + + if (this.keys.hasOwnProperty(key)) + { + throw new Error('Cannot add a Scene with duplicate key: ' + key); + } + else + { + return key; + } + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#getScene + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {?Phaser.Scene} [description] + */ + getScene: function (key) + { + if (typeof key === 'string') + { + if (this.keys[key]) + { + return this.keys[key]; + } + } + else + { + for (var i = 0; i < this.scenes.length; i++) + { + if (key === this.scenes[i]) + { + return key; + } + } + } + + return null; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#isActive + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {boolean} [description] + */ + isActive: function (key) + { + var scene = this.getScene(key); + + if (scene) + { + return scene.sys.isActive(); + } + + return null; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#isVisible + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {boolean} [description] + */ + isVisible: function (key) + { + var scene = this.getScene(key); + + if (scene) + { + return scene.sys.isVisible(); + } + + return null; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#isSleeping + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {boolean} [description] + */ + isSleeping: function (key) + { + var scene = this.getScene(key); + + if (scene) + { + return scene.sys.isSleeping(); + } + + return null; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#pause + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + pause: function (key) + { + var scene = this.getScene(key); + + if (scene) + { + scene.sys.pause(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#resume + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + resume: function (key) + { + var scene = this.getScene(key); + + if (scene) + { + scene.sys.resume(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#sleep + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + sleep: function (key) + { + var scene = this.getScene(key); + + if (scene) + { + scene.sys.sleep(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#wake + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + wake: function (key) + { + var scene = this.getScene(key); + + if (scene) + { + scene.sys.wake(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#start + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {object} [data] - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + start: function (key, data) + { + if (data === undefined) { data = {}; } + + // if not booted, then put scene into a holding pattern + if (!this.game.isBooted) + { + for (var i = 0; i < this._pending.length; i++) + { + var entry = this._pending[i]; + + if (entry.key === key) + { + entry.autoStart = true; + entry.data = data; + } + } + + return this; + } + + var scene = this.getScene(key); + + if (scene) + { + scene.sys.start(data); + + var loader; + + if (scene.sys.load) + { + loader = scene.sys.load; + } + + // Files payload? + if (loader && Array.isArray(scene.sys.settings.files)) + { + loader.reset(); + + if (loader.loadArray(scene.sys.settings.files)) + { + scene.sys.settings.status = CONST.LOADING; + + loader.once('complete', this.payloadComplete, this); + + loader.start(); + + return this; + } + } + + this.bootScene(scene); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#stop + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + stop: function (key) + { + var scene = this.getScene(key); + + if (scene) + { + scene.sys.shutdown(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#switch + * @since 3.0.0 + * + * @param {string} from - [description] + * @param {string} to - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + switch: function (from, to) + { + var sceneA = this.getScene(from); + var sceneB = this.getScene(to); + + if (sceneA && sceneB && sceneA !== sceneB) + { + this.sleep(from); + + if (this.isSleeping(to)) + { + this.wake(to); + } + else + { + this.start(to); + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#getAt + * @since 3.0.0 + * + * @param {integer} index - [description] + * + * @return {(Phaser.Scene|undefined)} [description] + */ + getAt: function (index) + { + return this.scenes[index]; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#getIndex + * @since 3.0.0 + * + * @param {(string|Phaser.Scene)} key - [description] + * + * @return {integer} [description] + */ + getIndex: function (key) + { + var scene = this.getScene(key); + + return this.scenes.indexOf(scene); + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#bringToTop + * @since 3.0.0 + * + * @param {(string|Phaser.Scene)} key - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + bringToTop: function (key) + { + if (this._processing) + { + this._queue.push({ op: 'bringToTop', keyA: key, keyB: null }); + } + else + { + var index = this.getIndex(key); + + if (index !== -1 && index < this.scenes.length) + { + var scene = this.getScene(key); + + this.scenes.splice(index, 1); + this.scenes.push(scene); + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#sendToBack + * @since 3.0.0 + * + * @param {(string|Phaser.Scene)} key - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + sendToBack: function (key) + { + if (this._processing) + { + this._queue.push({ op: 'sendToBack', keyA: key, keyB: null }); + } + else + { + var index = this.getIndex(key); + + if (index !== -1 && index > 0) + { + var scene = this.getScene(key); + + this.scenes.splice(index, 1); + this.scenes.unshift(scene); + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#moveDown + * @since 3.0.0 + * + * @param {(string|Phaser.Scene)} key - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + moveDown: function (key) + { + if (this._processing) + { + this._queue.push({ op: 'moveDown', keyA: key, keyB: null }); + } + else + { + var indexA = this.getIndex(key); + + if (indexA > 0) + { + var indexB = indexA - 1; + var sceneA = this.getScene(key); + var sceneB = this.getAt(indexB); + + this.scenes[indexA] = sceneB; + this.scenes[indexB] = sceneA; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#moveUp + * @since 3.0.0 + * + * @param {(string|Phaser.Scene)} key - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + moveUp: function (key) + { + if (this._processing) + { + this._queue.push({ op: 'moveUp', keyA: key, keyB: null }); + } + else + { + var indexA = this.getIndex(key); + + if (indexA < this.scenes.length - 1) + { + var indexB = indexA + 1; + var sceneA = this.getScene(key); + var sceneB = this.getAt(indexB); + + this.scenes[indexA] = sceneB; + this.scenes[indexB] = sceneA; + } + } + + return this; + }, + + /** + * Moves a Scene so it is immediately above another Scene in the Scenes list. + * This means it will render over the top of the other Scene. + * + * @method Phaser.Scenes.SceneManager#moveAbove + * @since 3.2.0 + * + * @param {(string|Phaser.Scene)} keyA - The Scene that Scene B will be moved above. + * @param {(string|Phaser.Scene)} keyB - The Scene to be moved. + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + moveAbove: function (keyA, keyB) + { + if (keyA === keyB) + { + return this; + } + + if (this._processing) + { + this._queue.push({ op: 'moveAbove', keyA: keyA, keyB: keyB }); + } + else + { + var indexA = this.getIndex(keyA); + var indexB = this.getIndex(keyB); + + if (indexA > indexB && indexA !== -1 && indexB !== -1) + { + var tempScene = this.getAt(indexB); + + // Remove + this.scenes.splice(indexB, 1); + + // Add in new location + this.scenes.splice(indexA, 0, tempScene); + } + } + + return this; + }, + + /** + * Moves a Scene so it is immediately below another Scene in the Scenes list. + * This means it will render behind the other Scene. + * + * @method Phaser.Scenes.SceneManager#moveBelow + * @since 3.2.0 + * + * @param {(string|Phaser.Scene)} keyA - The Scene that Scene B will be moved above. + * @param {(string|Phaser.Scene)} keyB - The Scene to be moved. + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + moveBelow: function (keyA, keyB) + { + if (keyA === keyB) + { + return this; + } + + if (this._processing) + { + this._queue.push({ op: 'moveBelow', keyA: keyA, keyB: keyB }); + } + else + { + var indexA = this.getIndex(keyA); + var indexB = this.getIndex(keyB); + + if (indexA < indexB && indexA !== -1 && indexB !== -1) + { + var tempScene = this.getAt(indexB); + + // Remove + this.scenes.splice(indexB, 1); + + // Add in new location + this.scenes.splice(indexA, 0, tempScene); + } + } + + return this; + }, + + queueOp: function (op, keyA, keyB) + { + this._queue.push({ op: op, keyA: keyA, keyB: keyB }); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#swapPosition + * @since 3.0.0 + * + * @param {(string|Phaser.Scene)} keyA - [description] + * @param {(string|Phaser.Scene)} keyB - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + swapPosition: function (keyA, keyB) + { + if (keyA === keyB) + { + return this; + } + + if (this._processing) + { + this._queue.push({ op: 'swapPosition', keyA: keyA, keyB: keyB }); + } + else + { + var indexA = this.getIndex(keyA); + var indexB = this.getIndex(keyB); + + if (indexA !== indexB && indexA !== -1 && indexB !== -1) + { + var tempScene = this.getAt(indexA); + + this.scenes[indexA] = this.scenes[indexB]; + this.scenes[indexB] = tempScene; + } + } + + return this; + }, + + dump: function () + { + var out = []; + var map = [ 'pending', 'init', 'start', 'loading', 'creating', 'running', 'paused', 'sleeping', 'shutdown', 'destroyed' ]; + + for (var i = 0; i < this.scenes.length; i++) + { + var sys = this.scenes[i].sys; + + var key = (sys.settings.visible && (sys.settings.status === CONST.RUNNING || sys.settings.status === CONST.PAUSED)) ? '[*] ' : '[-] '; + key += sys.settings.key + ' (' + map[sys.settings.status] + ')'; + + out.push(key); + } + + console.log(out.join('\n')); + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + for (var i = this.scenes.length - 1; i >= 0; i--) + { + var sys = this.scenes[i].sys; + + sys.destroy(); + } + + this.scenes = []; + + this._pending = []; + this._start = []; + this._queue = []; + + this.game = null; + } + +}); + +module.exports = SceneManager; /***/ }), @@ -54406,14 +59391,65 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Phaser.Math.Easing.Stepped +var Vector2 = __webpack_require__(6); -module.exports = __webpack_require__(610); +/** + * Takes the `x` and `y` coordinates and transforms them into the same space as + * defined by the position, rotation and scale values. + * + * @function Phaser.Math.TransformXY + * @since 3.0.0 + * + * @param {number} x - The x coordinate to be transformed. + * @param {number} y - The y coordinate to be transformed. + * @param {number} positionX - Horizontal position of the transform point. + * @param {number} positionY - Vertical position of the transform point. + * @param {number} rotation - Rotation of the transform point, in radians. + * @param {number} scaleX - Horizontal scale of the transform point. + * @param {number} scaleY - Vertical scale of the transform point. + * @param {(Phaser.Math.Vector2|Phaser.Geom.Point|object)} [output] - [description] + * + * @return {(Phaser.Math.Vector2|Phaser.Geom.Point|object)} The translated point. + */ +var TransformXY = function (x, y, positionX, positionY, rotation, scaleX, scaleY, output) +{ + if (output === undefined) { output = new Vector2(); } + + // ITRS + + var sr = Math.sin(-rotation); + var cr = Math.cos(-rotation); + + var a = cr * scaleX; + var b = -sr * scaleX; + var c = sr * scaleY; + var d = cr * scaleY; + + // Invert + + var n = a * d - b * c; + + var m0 = d / n; + var m1 = -b / n; + var m2 = -c / n; + var m3 = a / n; + var m4 = (c * positionY - d * positionX) / n; + var m5 = -(a * positionY - b * positionX) / n; + + // Transform + + output.x = x * m0 + y * m2 + m4; + output.y = x * m1 + y * m3 + m5; + + return output; +}; + +module.exports = TransformXY; /***/ }), /* 289 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -54421,31 +59457,197 @@ module.exports = __webpack_require__(610); * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); + +// https://developer.mozilla.org/en-US/docs/Web/API/Touch_events +// https://patrickhlauke.github.io/touch/tests/results/ +// https://www.html5rocks.com/en/mobile/touch/ + /** + * @callback TouchHandler + * + * @param {TouchEvent} event - [description] + */ + +/** + * @classdesc * [description] * - * @function Phaser.Utils.Object.HasAny + * @class TouchManager + * @memberOf Phaser.Input.Touch + * @constructor * @since 3.0.0 * - * @param {object} source - [description] - * @param {string[]} keys - [description] - * - * @return {boolean} [description] + * @param {Phaser.Input.InputManager} inputManager - [description] */ -var HasAny = function (source, keys) -{ - for (var i = 0; i < keys.length; i++) +var TouchManager = new Class({ + + initialize: + + function TouchManager (inputManager) { - if (source.hasOwnProperty(keys[i])) + /** + * [description] + * + * @name Phaser.Input.Touch.TouchManager#manager + * @type {Phaser.Input.InputManager} + * @since 3.0.0 + */ + this.manager = inputManager; + + /** + * If true the DOM events will have event.preventDefault applied to them, if false they will propagate fully. + * + * @name Phaser.Input.Touch.TouchManager#capture + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.capture = true; + + /** + * [description] + * + * @name Phaser.Input.Touch.TouchManager#enabled + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.enabled = false; + + /** + * [description] + * + * @name Phaser.Input.Touch.TouchManager#target + * @type {null} + * @since 3.0.0 + */ + this.target; + + /** + * [description] + * + * @name Phaser.Input.Touch.TouchManager#handler + * @type {TouchHandler} + * @since 3.0.0 + */ + this.handler; + }, + + /** + * [description] + * + * @method Phaser.Input.Touch.TouchManager#boot + * @since 3.0.0 + */ + boot: function () + { + var config = this.manager.config; + + this.enabled = config.inputTouch; + this.target = config.inputTouchEventTarget; + this.capture = config.inputTouchCapture; + + if (!this.target) { - return true; + this.target = this.manager.game.canvas; } + + if (this.enabled) + { + this.startListeners(); + } + }, + + /** + * [description] + * + * @method Phaser.Input.Touch.TouchManager#startListeners + * @since 3.0.0 + */ + startListeners: function () + { + var queue = this.manager.queue; + var target = this.target; + + var passive = { passive: true }; + var nonPassive = { passive: false }; + + var handler; + + if (this.capture) + { + handler = function (event) + { + if (event.defaultPrevented) + { + // Do nothing if event already handled + return; + } + + // console.log('touch', event); + + queue.push(event); + + event.preventDefault(); + }; + + target.addEventListener('touchstart', handler, nonPassive); + target.addEventListener('touchmove', handler, nonPassive); + target.addEventListener('touchend', handler, nonPassive); + } + else + { + handler = function (event) + { + if (event.defaultPrevented) + { + // Do nothing if event already handled + return; + } + + queue.push(event); + }; + + target.addEventListener('touchstart', handler, passive); + target.addEventListener('touchmove', handler, passive); + target.addEventListener('touchend', handler, passive); + } + + this.handler = handler; + }, + + /** + * [description] + * + * @method Phaser.Input.Touch.TouchManager#stopListeners + * @since 3.0.0 + */ + stopListeners: function () + { + var target = this.target; + + target.removeEventListener('touchstart', this.handler); + target.removeEventListener('touchmove', this.handler); + target.removeEventListener('touchend', this.handler); + }, + + /** + * [description] + * + * @method Phaser.Input.Touch.TouchManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.stopListeners(); + + this.manager = null; } - return false; -}; +}); -module.exports = HasAny; +module.exports = TouchManager; /***/ }), @@ -54459,420 +59661,637 @@ module.exports = HasAny; */ var Class = __webpack_require__(0); -var DegToRad = __webpack_require__(35); -var GetBoolean = __webpack_require__(73); -var GetValue = __webpack_require__(4); -var Sprite = __webpack_require__(37); -var TWEEN_CONST = __webpack_require__(87); var Vector2 = __webpack_require__(6); +// DOM event button value: +// A number representing a given button: +// 0: Main button pressed, usually the left button or the un-initialized state +// 1: Auxiliary button pressed, usually the wheel button or the middle button (if present) +// 2: Secondary button pressed, usually the right button +// 3: Fourth button, typically the Browser Back button +// 4: Fifth button, typically the Browser Forward button +// For a mouse configured for left-handed use, the button actions are reversed. In this case, the values are read from right to left. + /** * @classdesc - * A PathFollower Game Object. + * [description] * - * A PathFollower is a Sprite Game Object with some extra helpers to allow it to follow a Path automatically. - * - * Anything you can do with a standard Sprite can be done with this PathFollower, such as animate it, tint it, - * scale it and so on. - * - * PathFollowers are bound to a single Path at any one time and can traverse the length of the Path, from start - * to finish, forwards or backwards, or from any given point on the Path to its end. They can optionally rotate - * to face the direction of the path, be offset from the path coordinates or rotate independently of the Path. - * - * @class PathFollower - * @extends Phaser.GameObjects.Sprite - * @memberOf Phaser.GameObjects + * @class Pointer + * @memberOf Phaser.Input * @constructor * @since 3.0.0 * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.Curves.Path} path - The Path this PathFollower is following. It can only follow one Path at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {Phaser.Input.InputManager} manager - [description] + * @param {integer} id - [description] */ -var PathFollower = new Class({ - - Extends: Sprite, +var Pointer = new Class({ initialize: - function PathFollower (scene, path, x, y, texture, frame) + function Pointer (manager, id) { - Sprite.call(this, scene, x, y, texture, frame); - /** - * The Path this PathFollower is following. It can only follow one Path at a time. + * [description] * - * @name Phaser.GameObjects.PathFollower#path - * @type {Phaser.Curves.Path} + * @name Phaser.Input.Pointer#manager + * @type {Phaser.Input.InputManager} * @since 3.0.0 */ - this.path = path; - - /** - * Should the PathFollower automatically rotate to point in the direction of the Path? - * - * @name Phaser.GameObjects.PathFollower#rotateToPath - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.rotateToPath = false; + this.manager = manager; /** * [description] * - * @name Phaser.GameObjects.PathFollower#pathRotationVerticalAdjust - * @type {boolean} - * @default false + * @name Phaser.Input.Pointer#id + * @type {integer} * @since 3.0.0 */ - this.pathRotationVerticalAdjust = false; + this.id = id; /** - * If the PathFollower is rotating to match the Path (@see Phaser.GameObjects.PathFollower#rotateToPath) - * this value is added to the rotation value. This allows you to rotate objects to a path but control - * the angle of the rotation as well. + * [description] * - * @name Phaser.GameObjects.PathFollower#pathRotationOffset + * @name Phaser.Input.Pointer#event + * @type {null} + * @since 3.0.0 + */ + this.event; + + /** + * The camera the Pointer interacted with during its last update. + * A Pointer can only ever interact with one camera at once, which will be the top-most camera + * in the list should multiple cameras be positioned on-top of each other. + * + * @name Phaser.Input.Pointer#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @default null + * @since 3.0.0 + */ + this.camera = null; + + /** + * 0: No button or un-initialized + * 1: Left button + * 2: Right button + * 4: Wheel button or middle button + * 8: 4th button (typically the "Browser Back" button) + * 16: 5th button (typically the "Browser Forward" button) + * + * @name Phaser.Input.Pointer#buttons * @type {number} * @default 0 * @since 3.0.0 */ - this.pathRotationOffset = 0; + this.buttons = 0; /** - * An additional vector to add to the PathFollowers position, allowing you to offset it from the - * Path coordinates. + * [description] * - * @name Phaser.GameObjects.PathFollower#pathOffset + * @name Phaser.Input.Pointer#position * @type {Phaser.Math.Vector2} * @since 3.0.0 */ - this.pathOffset = new Vector2(x, y); + this.position = new Vector2(); + + /** + * X coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. + * + * @name Phaser.Input.Pointer#downX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.downX = 0; + + /** + * Y coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. + * + * @name Phaser.Input.Pointer#downY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.downY = 0; + + /** + * Time when Button 1 (left button), or Touch, was pressed, used for dragging objects. + * + * @name Phaser.Input.Pointer#downTime + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.downTime = 0; + + /** + * X coordinate of the Pointer when Button 1 (left button), or Touch, was released, used for dragging objects. + * + * @name Phaser.Input.Pointer#upX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.upX = 0; + + /** + * Y coordinate of the Pointer when Button 1 (left button), or Touch, was released, used for dragging objects. + * + * @name Phaser.Input.Pointer#upY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.upY = 0; + + /** + * Time when Button 1 (left button), or Touch, was released, used for dragging objects. + * + * @name Phaser.Input.Pointer#upTime + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.upTime = 0; + + /** + * Is the primary button down? (usually button 0, the left mouse button) + * + * @name Phaser.Input.Pointer#primaryDown + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.primaryDown = false; + + + /** + * The Drag State of the Pointer: + * + * 0 = Not dragging anything + * 1 = Being checked if dragging + * 2 = Dragging something + * + * @name Phaser.Input.Pointer#dragState + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.dragState = 0; + + /** + * Is _any_ button on this pointer considered as being down? + * + * @name Phaser.Input.Pointer#isDown + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isDown = false; /** * [description] * - * @name Phaser.GameObjects.PathFollower#pathVector - * @type {Phaser.Math.Vector2} + * @name Phaser.Input.Pointer#dirty + * @type {boolean} + * @default false * @since 3.0.0 */ - this.pathVector = new Vector2(); + this.dirty = false; /** * [description] * - * @name Phaser.GameObjects.PathFollower#pathTween - * @type {null} + * @name Phaser.Input.Pointer#justDown + * @type {boolean} + * @default false * @since 3.0.0 */ - this.pathTween; + this.justDown = false; /** * [description] * - * @name Phaser.GameObjects.PathFollower#pathConfig - * @type {?[type]} - * @default null + * @name Phaser.Input.Pointer#justUp + * @type {boolean} + * @default false * @since 3.0.0 */ - this.pathConfig = null; + this.justUp = false; /** - * Records the direction of the follower so it can change direction. + * [description] * - * @name Phaser.GameObjects.PathFollower#_prevDirection - * @type {integer} - * @private + * @name Phaser.Input.Pointer#justMoved + * @type {boolean} + * @default false * @since 3.0.0 */ - this._prevDirection = TWEEN_CONST.PLAYING_FORWARD; + this.justMoved = false; + + /** + * Did the previous input event come from a Touch input (true) or Mouse? (false) + * + * @name Phaser.Input.Pointer#wasTouch + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.wasTouch = false; + + /** + * If the mouse is locked, the horizontal relative movement of the Pointer in pixels since last frame. + * + * @name Phaser.Input.Pointer#movementX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.movementX = 0; + + /** + * If the mouse is locked, the vertical relative movement of the Pointer in pixels since last frame. + * + * @name Phaser.Input.Pointer#movementY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.movementY = 0; }, /** * [description] * - * @method Phaser.GameObjects.PathFollower#setPath + * @method Phaser.Input.Pointer#positionToCamera * @since 3.0.0 * - * @param {Phaser.Curves.Path} path - The Path this PathFollower is following. It can only follow one Path at a time. - * @param {[type]} config - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @param {(Phaser.Math.Vector2|object)} output - [description] * - * @return {Phaser.GameObjects.PathFollower} This Game Object. + * @return {(Phaser.Math.Vector2|object)} [description] */ - setPath: function (path, config) + positionToCamera: function (camera, output) { - if (config === undefined) { config = this.pathConfig; } - - var tween = this.pathTween; - - if (tween && tween.isPlaying()) - { - tween.stop(); - } - - this.path = path; - - if (config) - { - this.start(config); - } - - return this; + return camera.getWorldPoint(this.x, this.y, output); }, - // rotation offset in degrees /** * [description] * - * @method Phaser.GameObjects.PathFollower#setRotateToPath + * @name Phaser.Input.Pointer#x + * @type {number} * @since 3.0.0 - * - * @param {[type]} value - [description] - * @param {[type]} offset - [description] - * @param {[type]} verticalAdjust - [description] - * - * @return {Phaser.GameObjects.PathFollower} This Game Object. */ - setRotateToPath: function (value, offset, verticalAdjust) - { - if (offset === undefined) { offset = 0; } - if (verticalAdjust === undefined) { verticalAdjust = false; } + x: { - this.rotateToPath = value; + get: function () + { + return this.position.x; + }, - this.pathRotationOffset = offset; - this.pathRotationVerticalAdjust = verticalAdjust; + set: function (value) + { + this.position.x = value; + } - return this; }, /** - * Is this PathFollower actively following a Path or not? - * To be considered as `isFollowing` it must be currently moving on a Path, and not paused. + * [description] * - * @method Phaser.GameObjects.PathFollower#isFollowing + * @name Phaser.Input.Pointer#y + * @type {number} * @since 3.0.0 - * - * @return {boolean} `true` is this PathFollower is actively following a Path, otherwise `false`. */ - isFollowing: function () - { - var tween = this.pathTween; + y: { + + get: function () + { + return this.position.y; + }, + + set: function (value) + { + this.position.y = value; + } - return (tween && tween.isPlaying()); }, /** - * Starts this PathFollower following its given Path. + * [description] * - * @method Phaser.GameObjects.PathFollower#start + * @method Phaser.Input.Pointer#reset * @since 3.0.0 - * - * @param {object} config - [description] - * @param {number} [startAt=0] - [description] - * - * @return {Phaser.GameObjects.PathFollower} This Game Object. */ - start: function (config, startAt) + reset: function () { - if (config === undefined) { config = {}; } - if (startAt === undefined) { startAt = 0; } + // this.buttons = 0; - var tween = this.pathTween; + this.dirty = false; - if (tween && tween.isPlaying()) - { - tween.stop(); - } + this.justDown = false; + this.justUp = false; + this.justMoved = false; - if (typeof config === 'number') - { - config = { duration: config }; - } - - // Override in case they've been specified in the config - config.from = 0; - config.to = 1; - - // Can also read extra values out of the config: - - var positionOnPath = GetBoolean(config, 'positionOnPath', false); - - this.rotateToPath = GetBoolean(config, 'rotateToPath', false); - this.pathRotationOffset = GetValue(config, 'rotationOffset', 0); - this.pathRotationVerticalAdjust = GetBoolean(config, 'verticalAdjust', false); - - this.pathTween = this.scene.sys.tweens.addCounter(config); - - // The starting point of the path, relative to this follower - this.path.getStartPoint(this.pathOffset); - - if (positionOnPath) - { - this.x = this.pathOffset.x; - this.y = this.pathOffset.y; - } - - this.pathOffset.x = this.x - this.pathOffset.x; - this.pathOffset.y = this.y - this.pathOffset.y; - - this._prevDirection = TWEEN_CONST.PLAYING_FORWARD; - - if (this.rotateToPath) - { - // Set the rotation now (in case the tween has a delay on it, etc) - var nextPoint = this.path.getPoint(0.1); - - this.rotation = Math.atan2(nextPoint.y - this.y, nextPoint.x - this.x) + DegToRad(this.pathRotationOffset); - } - - this.pathConfig = config; - - return this; + this.movementX = 0; + this.movementY = 0; }, /** - * Pauses this PathFollower. It will still continue to render, but it will remain motionless at the - * point on the Path at which you paused it. + * [description] * - * @method Phaser.GameObjects.PathFollower#pause + * @method Phaser.Input.Pointer#touchmove * @since 3.0.0 * - * @return {Phaser.GameObjects.PathFollower} This Game Object. + * @param {TouchEvent} event - [description] + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. */ - pause: function () + touchmove: function (event) { - var tween = this.pathTween; + this.event = event; - if (tween && tween.isPlaying()) - { - tween.pause(); - } + this.x = this.manager.transformX(event.changedTouches[0].pageX); + this.y = this.manager.transformY(event.changedTouches[0].pageY); - return this; + this.justMoved = true; + + this.dirty = true; + + this.wasTouch = true; }, /** - * Resumes a previously paused PathFollower. - * If the PathFollower was not paused this has no effect. + * [description] * - * @method Phaser.GameObjects.PathFollower#resume + * @method Phaser.Input.Pointer#move * @since 3.0.0 * - * @return {Phaser.GameObjects.PathFollower} This Game Object. + * @param {MouseEvent} event - [description] + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. */ - resume: function () + move: function (event) { - var tween = this.pathTween; - - if (tween && tween.isPaused()) + if (event.buttons) { - tween.resume(); + this.buttons = event.buttons; } - return this; + this.event = event; + + this.x = this.manager.transformX(event.pageX); + this.y = this.manager.transformY(event.pageY); + + if (this.manager.mouse.locked) + { + // Multiple DOM events may occur within one frame, but only one Phaser event will fire + this.movementX += event.movementX || event.mozMovementX || event.webkitMovementX || 0; + this.movementY += event.movementY || event.mozMovementY || event.webkitMovementY || 0; + } + + this.justMoved = true; + + this.dirty = true; + + this.wasTouch = false; }, /** - * Stops this PathFollower from following the path any longer. - * This will invoke any 'stop' conditions that may exist on the Path, or for the follower. + * [description] * - * @method Phaser.GameObjects.PathFollower#stop + * @method Phaser.Input.Pointer#down * @since 3.0.0 * - * @return {Phaser.GameObjects.PathFollower} This Game Object. + * @param {MouseEvent} event - [description] + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. */ - stop: function () + down: function (event, time) { - var tween = this.pathTween; - - if (tween && tween.isPlaying()) + if (event.buttons) { - tween.stop(); + this.buttons = event.buttons; } - return this; + this.event = event; + + this.x = this.manager.transformX(event.pageX); + this.y = this.manager.transformY(event.pageY); + + // 0: Main button pressed, usually the left button or the un-initialized state + if (event.button === 0) + { + this.primaryDown = true; + this.downX = this.x; + this.downY = this.y; + this.downTime = time; + } + + this.justDown = true; + this.isDown = true; + + this.dirty = true; + + this.wasTouch = false; }, /** - * Internal update handler that advances this PathFollower along the path. - * Called automatically by the Scene step, should not typically be called directly. + * [description] * - * @method Phaser.GameObjects.PathFollower#preUpdate - * @protected + * @method Phaser.Input.Pointer#touchstart * @since 3.0.0 * - * @param {[type]} time - [description] - * @param {[type]} delta - [description] + * @param {TouchEvent} event - [description] + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. */ - preUpdate: function (time, delta) + touchstart: function (event, time) { - this.anims.update(time, delta); + this.buttons = 1; - var tween = this.pathTween; + this.event = event; - if (tween) + this.x = this.manager.transformX(event.changedTouches[0].pageX); + this.y = this.manager.transformY(event.changedTouches[0].pageY); + + this.primaryDown = true; + this.downX = this.x; + this.downY = this.y; + this.downTime = time; + + this.justDown = true; + this.isDown = true; + + this.dirty = true; + + this.wasTouch = true; + }, + + /** + * [description] + * + * @method Phaser.Input.Pointer#up + * @since 3.0.0 + * + * @param {MouseEvent} event - [description] + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + */ + up: function (event, time) + { + if (event.buttons) { - var tweenData = tween.data[0]; - - if (tweenData.state !== TWEEN_CONST.PLAYING_FORWARD && tweenData.state !== TWEEN_CONST.PLAYING_BACKWARD) - { - // If delayed, etc then bail out - return; - } - - var pathVector = this.pathVector; - - this.path.getPoint(tween.getValue(), pathVector); - - pathVector.add(this.pathOffset); - - var oldX = this.x; - var oldY = this.y; - - this.setPosition(pathVector.x, pathVector.y); - - var speedX = this.x - oldX; - var speedY = this.y - oldY; - - if (speedX === 0 && speedY === 0) - { - // Bail out early - return; - } - - if (tweenData.state !== this._prevDirection) - { - // We've changed direction, so don't do a rotate this frame - this._prevDirection = tweenData.state; - - return; - } - - if (this.rotateToPath) - { - this.rotation = Math.atan2(speedY, speedX) + DegToRad(this.pathRotationOffset); - - if (this.pathRotationVerticalAdjust) - { - this.flipY = (this.rotation !== 0 && tweenData.state === TWEEN_CONST.PLAYING_BACKWARD); - } - } + this.buttons = event.buttons; } + + this.event = event; + + this.x = this.manager.transformX(event.pageX); + this.y = this.manager.transformY(event.pageY); + + // 0: Main button pressed, usually the left button or the un-initialized state + if (event.button === 0) + { + this.primaryDown = false; + this.upX = this.x; + this.upY = this.y; + this.upTime = time; + } + + this.justUp = true; + this.isDown = false; + + this.dirty = true; + + this.wasTouch = false; + }, + + /** + * [description] + * + * @method Phaser.Input.Pointer#touchend + * @since 3.0.0 + * + * @param {TouchEvent} event - [description] + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + */ + touchend: function (event, time) + { + this.buttons = 0; + + this.event = event; + + this.x = this.manager.transformX(event.changedTouches[0].pageX); + this.y = this.manager.transformY(event.changedTouches[0].pageY); + + this.primaryDown = false; + this.upX = this.x; + this.upY = this.y; + this.upTime = time; + + this.justUp = true; + this.isDown = false; + + this.dirty = true; + + this.wasTouch = true; + }, + + /** + * [description] + * + * @method Phaser.Input.Pointer#noButtonDown + * @since 3.0.0 + * + * @return {boolean} [description] + */ + noButtonDown: function () + { + return (this.buttons === 0); + }, + + /** + * [description] + * + * @method Phaser.Input.Pointer#leftButtonDown + * @since 3.0.0 + * + * @return {boolean} [description] + */ + leftButtonDown: function () + { + return (this.buttons & 1); + }, + + /** + * [description] + * + * @method Phaser.Input.Pointer#rightButtonDown + * @since 3.0.0 + * + * @return {boolean} [description] + */ + rightButtonDown: function () + { + return (this.buttons & 2); + }, + + /** + * [description] + * + * @method Phaser.Input.Pointer#middleButtonDown + * @since 3.0.0 + * + * @return {boolean} [description] + */ + middleButtonDown: function () + { + return (this.buttons & 4); + }, + + /** + * [description] + * + * @method Phaser.Input.Pointer#backButtonDown + * @since 3.0.0 + * + * @return {boolean} [description] + */ + backButtonDown: function () + { + return (this.buttons & 8); + }, + + /** + * [description] + * + * @method Phaser.Input.Pointer#forwardButtonDown + * @since 3.0.0 + * + * @return {boolean} [description] + */ + forwardButtonDown: function () + { + return (this.buttons & 16); + }, + + /** + * [description] + * + * @method Phaser.Input.Pointer#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.camera = null; + this.manager = null; + this.position = null; } }); -module.exports = PathFollower; +module.exports = Pointer; /***/ }), /* 291 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -54880,25 +60299,300 @@ module.exports = PathFollower; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var Features = __webpack_require__(146); + +// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent +// https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md + /** - * Returns the nearest power of 2 to the given `value`. + * @classdesc + * [description] * - * @function Phaser.Math.Pow2.GetPowerOfTwo + * @class MouseManager + * @memberOf Phaser.Input.Mouse + * @constructor * @since 3.0.0 * - * @param {number} value - [description] - * - * @return {integer} [description] + * @param {Phaser.Input.InputManager} inputManager - [description] */ -var GetPowerOfTwo = function (value) -{ - // Math.log(2) - var index = Math.log(value) / 0.6931471805599453; +var MouseManager = new Class({ - return (1 << Math.ceil(index)); -}; + initialize: -module.exports = GetPowerOfTwo; + function MouseManager (inputManager) + { + /** + * [description] + * + * @name Phaser.Input.Mouse.MouseManager#manager + * @type {Phaser.Input.InputManager} + * @since 3.0.0 + */ + this.manager = inputManager; + + /** + * If true the DOM mouse events will have event.preventDefault applied to them, if false they will propagate fully. + * + * @name Phaser.Input.Mouse.MouseManager#capture + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.capture = true; + + /** + * [description] + * + * @name Phaser.Input.Mouse.MouseManager#enabled + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.enabled = false; + + /** + * [description] + * + * @name Phaser.Input.Mouse.MouseManager#target + * @type {null} + * @since 3.0.0 + */ + this.target; + + /** + * [description] + * + * @name Phaser.Input.Mouse.MouseManager#handler + * @type {null} + * @since 3.0.0 + */ + this.handler; + + /** + * If the mouse has been pointer locked successfully this will be set to true. + * + * @name Phaser.Input.Mouse.MouseManager#locked + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.locked = false; + }, + + /** + * [description] + * + * @method Phaser.Input.Mouse.MouseManager#boot + * @since 3.0.0 + */ + boot: function () + { + var config = this.manager.config; + + this.enabled = config.inputMouse; + this.target = config.inputMouseEventTarget; + this.capture = config.inputMouseCapture; + + if (!this.target) + { + this.target = this.manager.game.canvas; + } + + if (config.disableContextMenu) + { + this.disableContextMenu(); + } + + if (this.enabled) + { + this.startListeners(); + } + }, + + /** + * [description] + * + * @method Phaser.Input.Mouse.MouseManager#disableContextMenu + * @since 3.0.0 + * + * @return {Phaser.Input.Mouse.MouseManager} [description] + */ + disableContextMenu: function () + { + document.body.addEventListener('contextmenu', function (event) + { + event.preventDefault(); + return false; + }); + + return this; + }, + + /** + * If the browser supports it, you can request that the pointer be locked to the browser window. + * + * This is classically known as 'FPS controls', where the pointer can't leave the browser until + * the user presses an exit key. + * + * If the browser successfully enters a locked state, a `POINTER_LOCK_CHANGE_EVENT` will be dispatched, + * from the games Input Manager, with an `isPointerLocked` property. + * + * It is important to note that pointer lock can only be enabled after an 'engagement gesture', + * see: https://w3c.github.io/pointerlock/#dfn-engagement-gesture. + * + * @method Phaser.Input.Mouse.MouseManager#requestPointerLock + * @since 3.0.0 + */ + requestPointerLock: function () + { + if (Features.pointerLock) + { + var element = this.target; + element.requestPointerLock = element.requestPointerLock || element.mozRequestPointerLock || element.webkitRequestPointerLock; + element.requestPointerLock(); + } + }, + + /** + * Internal pointerLockChange handler. + * + * @method Phaser.Input.Mouse.MouseManager#pointerLockChange + * @since 3.0.0 + * + * @param {Event} event - The native event from the browser. + */ + pointerLockChange: function (event) + { + var element = this.target; + + this.locked = (document.pointerLockElement === element || document.mozPointerLockElement === element || document.webkitPointerLockElement === element) ? true : false; + + this.manager.queue.push(event); + }, + + /** + * If the browser supports pointer lock, this will request that the pointer lock is released. If + * the browser successfully enters a locked state, a 'POINTER_LOCK_CHANGE_EVENT' will be + * dispatched - from the game's input manager - with an `isPointerLocked` property. + * + * @method Phaser.Input.Mouse.MouseManager#releasePointerLock + * @since 3.0.0 + */ + releasePointerLock: function () + { + if (Features.pointerLock) + { + document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock || document.webkitExitPointerLock; + document.exitPointerLock(); + } + }, + + /** + * [description] + * + * @method Phaser.Input.Mouse.MouseManager#startListeners + * @since 3.0.0 + */ + startListeners: function () + { + var queue = this.manager.queue; + var target = this.target; + + var passive = { passive: true }; + var nonPassive = { passive: false }; + + var handler; + + if (this.capture) + { + handler = function (event) + { + if (event.defaultPrevented) + { + // Do nothing if event already handled + return; + } + + // console.log('mouse', event); + + queue.push(event); + + event.preventDefault(); + }; + + target.addEventListener('mousemove', handler, nonPassive); + target.addEventListener('mousedown', handler, nonPassive); + target.addEventListener('mouseup', handler, nonPassive); + } + else + { + handler = function (event) + { + if (event.defaultPrevented) + { + // Do nothing if event already handled + return; + } + + queue.push(event); + }; + + target.addEventListener('mousemove', handler, passive); + target.addEventListener('mousedown', handler, passive); + target.addEventListener('mouseup', handler, passive); + } + + this.handler = handler; + + if (Features.pointerLock) + { + this.pointerLockChange = this.pointerLockChange.bind(this); + + document.addEventListener('pointerlockchange', this.pointerLockChange, true); + document.addEventListener('mozpointerlockchange', this.pointerLockChange, true); + document.addEventListener('webkitpointerlockchange', this.pointerLockChange, true); + } + }, + + /** + * [description] + * + * @method Phaser.Input.Mouse.MouseManager#stopListeners + * @since 3.0.0 + */ + stopListeners: function () + { + var target = this.target; + + target.removeEventListener('mousemove', this.handler); + target.removeEventListener('mousedown', this.handler); + target.removeEventListener('mouseup', this.handler); + + if (Features.pointerLock) + { + document.removeEventListener('pointerlockchange', this.pointerLockChange, true); + document.removeEventListener('mozpointerlockchange', this.pointerLockChange, true); + document.removeEventListener('webkitpointerlockchange', this.pointerLockChange, true); + } + }, + + /** + * [description] + * + * @method Phaser.Input.Mouse.MouseManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.stopListeners(); + + this.manager = null; + } + +}); + +module.exports = MouseManager; /***/ }), @@ -54912,247 +60606,278 @@ module.exports = GetPowerOfTwo; */ var Class = __webpack_require__(0); -var Utils = __webpack_require__(41); +var GetFastValue = __webpack_require__(2); +var ProcessKeyCombo = __webpack_require__(803); +var ResetKeyCombo = __webpack_require__(801); + +/** + * @callback KeyboardKeydownCallback + * + * @param {KeyboardEvent} event - [description] + */ + +/** + * @typedef {object} KeyComboConfig + * + * @property {boolean} [resetOnWrongKey=true] - [description] + * @property {number} [maxKeyDelay=0] - [description] + * @property {boolean} [resetOnMatch=false] - [description] + * @property {boolean} [deleteOnMatch=false] - [description] + */ /** * @classdesc * [description] * - * @class Light - * @memberOf Phaser.GameObjects + * `keys` argument can be: + * + * A string (ATARI) + * An array of either integers (key codes) or strings, or a mixture of both + * An array of objects (such as Key objects) with a public 'keyCode' property + * + * @class KeyCombo + * @memberOf Phaser.Input.Keyboard * @constructor * @since 3.0.0 * - * @param {number} x - The horizontal position of the light. - * @param {number} y - The vertical position of the light. - * @param {number} radius - The radius of the light. - * @param {number} r - The red color. A value between 0 and 1. - * @param {number} g - The green color. A value between 0 and 1. - * @param {number} b - The blue color. A value between 0 and 1. - * @param {number} intensity - The intensity of the light. + * @param {Phaser.Input.Keyboard.KeyboardManager} keyboardManager - [description] + * @param {(string|integer[]|object[])} keys - [description] + * @param {KeyComboConfig} [config] - [description] */ -var Light = new Class({ +var KeyCombo = new Class({ initialize: - function Light (x, y, radius, r, g, b, intensity) + function KeyCombo (keyboardManager, keys, config) { - /** - * [description] - * - * @name Phaser.GameObjects.Light#x - * @type {number} - * @since 3.0.0 - */ - this.x = x; + if (config === undefined) { config = {}; } + + // Can't have a zero or single length combo (string or array based) + if (keys.length < 2) + { + return false; + } /** * [description] * - * @name Phaser.GameObjects.Light#y - * @type {number} + * @name Phaser.Input.Keyboard.KeyCombo#manager + * @type {Phaser.Input.Keyboard.KeyboardManager} * @since 3.0.0 */ - this.y = y; + this.manager = keyboardManager; /** * [description] * - * @name Phaser.GameObjects.Light#radius - * @type {number} + * @name Phaser.Input.Keyboard.KeyCombo#enabled + * @type {boolean} + * @default true * @since 3.0.0 */ - this.radius = radius; + this.enabled = true; /** * [description] * - * @name Phaser.GameObjects.Light#r + * @name Phaser.Input.Keyboard.KeyCombo#keyCodes + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.keyCodes = []; + + // if 'keys' is a string we need to get the keycode of each character in it + + for (var i = 0; i < keys.length; i++) + { + var char = keys[i]; + + if (typeof char === 'string') + { + this.keyCodes.push(char.toUpperCase().charCodeAt(0)); + } + else if (typeof char === 'number') + { + this.keyCodes.push(char); + } + else if (char.hasOwnProperty('keyCode')) + { + this.keyCodes.push(char.keyCode); + } + } + + /** + * The current keyCode the combo is waiting for. + * + * @name Phaser.Input.Keyboard.KeyCombo#current + * @type {integer} + * @since 3.0.0 + */ + this.current = this.keyCodes[0]; + + /** + * The current index of the key being waited for in the 'keys' string. + * + * @name Phaser.Input.Keyboard.KeyCombo#index + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.index = 0; + + /** + * The length of this combo (in keycodes) + * + * @name Phaser.Input.Keyboard.KeyCombo#size * @type {number} * @since 3.0.0 */ - this.r = r; + this.size = this.keyCodes.length; + + /** + * The time the previous key in the combo was matched. + * + * @name Phaser.Input.Keyboard.KeyCombo#timeLastMatched + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.timeLastMatched = 0; + + /** + * Has this Key Combo been matched yet? + * + * @name Phaser.Input.Keyboard.KeyCombo#matched + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.matched = false; + + /** + * The time the entire combo was matched. + * + * @name Phaser.Input.Keyboard.KeyCombo#timeMatched + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.timeMatched = 0; + + /** + * If they press the wrong key do we reset the combo? + * + * @name Phaser.Input.Keyboard.KeyCombo#resetOnWrongKey + * @type {boolean} + * @default 0 + * @since 3.0.0 + */ + this.resetOnWrongKey = GetFastValue(config, 'resetOnWrongKey', true); + + /** + * The max delay in ms between each key press. Above this the combo is reset. 0 means disabled. + * + * @name Phaser.Input.Keyboard.KeyCombo#maxKeyDelay + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.maxKeyDelay = GetFastValue(config, 'maxKeyDelay', 0); + + /** + * If previously matched and they press Key 1 again, will it reset? + * + * @name Phaser.Input.Keyboard.KeyCombo#resetOnMatch + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.resetOnMatch = GetFastValue(config, 'resetOnMatch', false); + + /** + * If the combo matches, will it delete itself? + * + * @name Phaser.Input.Keyboard.KeyCombo#deleteOnMatch + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.deleteOnMatch = GetFastValue(config, 'deleteOnMatch', false); + + var _this = this; + + var onKeyDownHandler = function (event) + { + if (_this.matched || !_this.enabled) + { + return; + } + + var matched = ProcessKeyCombo(event, _this); + + if (matched) + { + _this.manager.emit('keycombomatch', _this, event); + + if (_this.resetOnMatch) + { + ResetKeyCombo(_this); + } + else if (_this.deleteOnMatch) + { + _this.destroy(); + } + } + }; /** * [description] * - * @name Phaser.GameObjects.Light#g - * @type {number} + * @name Phaser.Input.Keyboard.KeyCombo#onKeyDown + * @type {KeyboardKeydownCallback} * @since 3.0.0 */ - this.g = g; + this.onKeyDown = onKeyDownHandler; - /** - * [description] - * - * @name Phaser.GameObjects.Light#b - * @type {number} - * @since 3.0.0 - */ - this.b = b; + this.manager.on('keydown', onKeyDownHandler); + }, - /** - * [description] - * - * @name Phaser.GameObjects.Light#intensity - * @type {number} - * @since 3.0.0 - */ - this.intensity = intensity; + /** + * How far complete is this combo? A value between 0 and 1. + * + * @name Phaser.Input.Keyboard.KeyCombo#progress + * @type {number} + * @readOnly + * @since 3.0.0 + */ + progress: { - /** - * [description] - * - * @name Phaser.GameObjects.Light#scrollFactorX - * @type {number} - * @since 3.0.0 - */ - this.scrollFactorX = 1.0; + get: function () + { + return this.index / this.size; + } - /** - * [description] - * - * @name Phaser.GameObjects.Light#scrollFactorY - * @type {number} - * @since 3.0.0 - */ - this.scrollFactorY = 1.0; }, /** * [description] * - * @method Phaser.GameObjects.Light#set + * @method Phaser.Input.Keyboard.KeyCombo#destroy * @since 3.0.0 - * - * @param {number} x - The horizontal position of the light. - * @param {number} y - The vertical position of the light. - * @param {number} radius - The radius of the light. - * @param {number} r - The red color. A value between 0 and 1. - * @param {number} g - The green color. A value between 0 and 1. - * @param {number} b - The blue color. A value between 0 and 1. - * @param {number} intensity - The intensity of the light. - * - * @return {Phaser.GameObjects.Light} This Light object. */ - set: function (x, y, radius, r, g, b, intensity) + destroy: function () { - this.x = x; - this.y = y; + this.enabled = false; + this.keyCodes = []; - this.radius = radius; - - this.r = r; - this.g = g; - this.b = b; - - this.intensity = intensity; - - this.scrollFactorX = 1; - this.scrollFactorY = 1; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Light#setScrollFactor - * @since 3.0.0 - * - * @param {number} x - The horizontal scroll factor of the light. - * @param {number} y - The vertical scroll factor of the light. - * - * @return {Phaser.GameObjects.Light} This Light object. - */ - setScrollFactor: function (x, y) - { - if (x === undefined) { x = 1; } - if (y === undefined) { y = x; } - - this.scrollFactorX = x; - this.scrollFactorY = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Light#setColor - * @since 3.0.0 - * - * @param {number} rgb - [description] - * - * @return {Phaser.GameObjects.Light} This Light object. - */ - setColor: function (rgb) - { - var color = Utils.getFloatsFromUintRGB(rgb); - - this.r = color[0]; - this.g = color[1]; - this.b = color[2]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Light#setIntensity - * @since 3.0.0 - * - * @param {number} intensity - [description] - * - * @return {Phaser.GameObjects.Light} This Light object. - */ - setIntensity: function (intensity) - { - this.intensity = intensity; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Light#setPosition - * @since 3.0.0 - * - * @param {number} x - The horizontal position of the light. - * @param {number} y - The vertical position of the light. - * - * @return {Phaser.GameObjects.Light} This Light object. - */ - setPosition: function (x, y) - { - this.x = x; - this.y = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Light#setRadius - * @since 3.0.0 - * - * @param {number} radius - [description] - * - * @return {Phaser.GameObjects.Light} This Light object. - */ - setRadius: function (radius) - { - this.radius = radius; - - return this; + this.manager.off('keydown', this.onKeyDown); + this.manager = undefined; } }); -module.exports = Light; +module.exports = KeyCombo; /***/ }), @@ -55166,323 +60891,191 @@ module.exports = Light; */ var Class = __webpack_require__(0); -var Light = __webpack_require__(292); -var LightPipeline = __webpack_require__(165); -var Utils = __webpack_require__(41); /** * @classdesc - * [description] + * A generic Key object which can be passed to the Process functions (and so on) + * keycode must be an integer * - * @class LightsManager - * @memberOf Phaser.GameObjects + * @class Key + * @memberOf Phaser.Input.Keyboard * @constructor * @since 3.0.0 + * + * @param {integer} keyCode - The keycode of this key. */ -var LightsManager = new Class({ +var Key = new Class({ initialize: - function LightsManager () + function Key (keyCode) { /** - * [description] + * The keycode of this key. * - * @name Phaser.GameObjects.LightsManager#lightPool - * @type {array} - * @default [] + * @name Phaser.Input.Keyboard.Key#keyCode + * @type {integer} * @since 3.0.0 */ - this.lightPool = []; + this.keyCode = keyCode; /** - * [description] + * The original DOM event. * - * @name Phaser.GameObjects.LightsManager#lights - * @type {array} - * @default [] + * @name Phaser.Input.Keyboard.Key#originalEvent + * @type {KeyboardEvent} * @since 3.0.0 */ - this.lights = []; + this.originalEvent = undefined; /** - * [description] + * Should this Key prevent event propagation? * - * @name Phaser.GameObjects.LightsManager#culledLights - * @type {array} - * @default [] + * @name Phaser.Input.Keyboard.Key#preventDefault + * @type {boolean} + * @default true * @since 3.0.0 */ - this.culledLights = []; + this.preventDefault = true; /** - * [description] + * Can this Key be processed? * - * @name Phaser.GameObjects.LightsManager#ambientColor - * @type {{ r: float, g: float, b: float }} + * @name Phaser.Input.Keyboard.Key#enabled + * @type {boolean} + * @default true * @since 3.0.0 */ - this.ambientColor = { r: 0.1, g: 0.1, b: 0.1 }; + this.enabled = true; /** - * [description] + * The "down" state of the key. This will remain `true` for as long as the keyboard thinks this key is held down. * - * @name Phaser.GameObjects.LightsManager#active + * @name Phaser.Input.Keyboard.Key#isDown * @type {boolean} * @default false * @since 3.0.0 */ - this.active = false; - }, + this.isDown = false; - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#enable - * @since 3.0.0 - * - * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. - */ - enable: function () - { - this.active = true; + /** + * The "up" state of the key. This will remain `true` for as long as the keyboard thinks this key is up. + * + * @name Phaser.Input.Keyboard.Key#isUp + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.isUp = true; - return this; - }, + /** + * The down state of the ALT key, if pressed at the same time as this key. + * + * @name Phaser.Input.Keyboard.Key#altKey + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.altKey = false; - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#disable - * @since 3.0.0 - * - * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. - */ - disable: function () - { - this.active = false; + /** + * The down state of the CTRL key, if pressed at the same time as this key. + * + * @name Phaser.Input.Keyboard.Key#ctrlKey + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.ctrlKey = false; - return this; - }, + /** + * The down state of the SHIFT key, if pressed at the same time as this key. + * + * @name Phaser.Input.Keyboard.Key#shiftKey + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.shiftKey = false; - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#cull - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - * @return {Phaser.GameObjects.Light[]} [description] - */ - cull: function (camera) - { - var lights = this.lights; - var culledLights = this.culledLights; - var length = lights.length; - var cameraCenterX = camera.x + camera.width / 2.0; - var cameraCenterY = camera.y + camera.height / 2.0; - var cameraRadius = (camera.width + camera.height) / 2.0; - var point = { x: 0, y: 0 }; - var cameraMatrix = camera.matrix; - var viewportHeight = this.systems.game.config.height; + /** + * The location of the modifier key. 0 for standard (or unknown), 1 for left, 2 for right, 3 for numpad. + * + * @name Phaser.Input.Keyboard.Key#location + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.location = 0; - culledLights.length = 0; + /** + * The timestamp when the key was last pressed down. + * + * @name Phaser.Input.Keyboard.Key#timeDown + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.timeDown = 0; - for (var index = 0; index < length && culledLights.length < LightPipeline.LIGHT_COUNT; ++index) - { - var light = lights[index]; + /** + * The number of milliseconds this key has been held down for. + * If the key is down this value holds the duration of that key press and is constantly updated. + * If the key is up it holds the duration of the previous down session. + * + * @name Phaser.Input.Keyboard.Key#duration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.duration = 0; - cameraMatrix.transformPoint(light.x, light.y, point); + /** + * The timestamp when the key was last released. + * + * @name Phaser.Input.Keyboard.Key#timeUp + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.timeUp = 0; - // We'll just use bounding spheres to test - // if lights should be rendered - var dx = cameraCenterX - (point.x - (camera.scrollX * light.scrollFactorX * camera.zoom)); - var dy = cameraCenterY - (viewportHeight - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom)); - var distance = Math.sqrt(dx * dx + dy * dy); + /** + * If a key is held down this holds down the number of times the key has 'repeated'. + * + * @name Phaser.Input.Keyboard.Key#repeats + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.repeats = 0; - if (distance < light.radius + cameraRadius) - { - culledLights.push(lights[index]); - } - } + /** + * True if the key has just been pressed (NOTE: requires to be reset, see justDown getter) + * + * @name Phaser.Input.Keyboard.Key#_justDown + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._justDown = false; - return culledLights; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#forEachLight - * @since 3.0.0 - * - * @param {function} callback - [description] - * - * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. - */ - forEachLight: function (callback) - { - if (!callback) - { - return; - } - - var lights = this.lights; - var length = lights.length; - - for (var index = 0; index < length; ++index) - { - callback(lights[index]); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#setAmbientColor - * @since 3.0.0 - * - * @param {[type]} rgb - [description] - * - * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. - */ - setAmbientColor: function (rgb) - { - var color = Utils.getFloatsFromUintRGB(rgb); - - this.ambientColor.r = color[0]; - this.ambientColor.g = color[1]; - this.ambientColor.b = color[2]; - - return this; - }, - - /** - * Returns the maximum number of Lights allowed to appear at once. - * - * @method Phaser.GameObjects.LightsManager#getMaxVisibleLights - * @since 3.0.0 - * - * @return {integer} [description] - */ - getMaxVisibleLights: function () - { - return 10; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#getLightCount - * @since 3.0.0 - * - * @return {integer} [description] - */ - getLightCount: function () - { - return this.lights.length; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#addLight - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} radius - [description] - * @param {number} rgb - [description] - * @param {number} intensity - [description] - * - * @return {Phaser.GameObjects.Light} [description] - */ - addLight: function (x, y, radius, rgb, intensity) - { - var color = null; - var light = null; - - x = (x === undefined) ? 0.0 : x; - y = (y === undefined) ? 0.0 : y; - rgb = (rgb === undefined) ? 0xffffff : rgb; - radius = (radius === undefined) ? 100.0 : radius; - intensity = (intensity === undefined) ? 1.0 : intensity; - - color = Utils.getFloatsFromUintRGB(rgb); - light = null; - - if (this.lightPool.length > 0) - { - light = this.lightPool.pop(); - light.set(x, y, radius, color[0], color[1], color[2], intensity); - } - else - { - light = new Light(x, y, radius, color[0], color[1], color[2], intensity); - } - - this.lights.push(light); - - return light; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#removeLight - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Light} light - [description] - * - * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. - */ - removeLight: function (light) - { - var index = this.lights.indexOf(light); - - if (index >= 0) - { - this.lightPool.push(light); - this.lights.splice(index, 1); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - while (this.lights.length > 0) - { - this.lightPool.push(this.lights.pop()); - } - - this.ambientColor = { r: 0.1, g: 0.1, b: 0.1 }; - this.culledLights.length = 0; - this.lights.length = 0; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.shutdown(); + /** + * True if the key has just been pressed (NOTE: requires to be reset, see justDown getter) + * + * @name Phaser.Input.Keyboard.Key#_justUp + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._justUp = false; } }); -module.exports = LightsManager; +module.exports = Key; /***/ }), @@ -55495,22 +61088,425 @@ module.exports = LightsManager; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(15); +var Key = __webpack_require__(293); +var KeyCodes = __webpack_require__(143); +var KeyCombo = __webpack_require__(292); +var KeyMap = __webpack_require__(800); +var ProcessKeyDown = __webpack_require__(799); +var ProcessKeyUp = __webpack_require__(798); + /** - * @namespace Phaser.Geom + * @classdesc + * The Keyboard class monitors keyboard input and dispatches keyboard events. + * + * _Note_: many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. + * See http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/ for more details. + * + * Also please be aware that certain browser extensions can disable or override Phaser keyboard handling. + * For example the Chrome extension vimium is known to disable Phaser from using the D key. And there are others. + * So please check your extensions before opening Phaser issues. + * + * @class KeyboardManager + * @extends EventEmitter + * @memberOf Phaser.Input.Keyboard + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Input.InputManager} inputManager - [description] */ +var KeyboardManager = new Class({ -module.exports = { - - Circle: __webpack_require__(665), - Ellipse: __webpack_require__(270), - Intersects: __webpack_require__(295), - Line: __webpack_require__(685), - Point: __webpack_require__(703), - Polygon: __webpack_require__(717), - Rectangle: __webpack_require__(307), - Triangle: __webpack_require__(746) + Extends: EventEmitter, -}; + initialize: + + function KeyboardManager (inputManager) + { + EventEmitter.call(this); + + /** + * [description] + * + * @name Phaser.Input.Keyboard.KeyboardManager#manager + * @type {Phaser.Input.InputManager} + * @since 3.0.0 + */ + this.manager = inputManager; + + /** + * [description] + * + * @name Phaser.Input.Keyboard.KeyboardManager#enabled + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.enabled = false; + + /** + * [description] + * + * @name Phaser.Input.Keyboard.KeyboardManager#target + * @type {?object} + * @since 3.0.0 + */ + this.target; + + /** + * [description] + * + * @name Phaser.Input.Keyboard.KeyboardManager#keys + * @type {Phaser.Input.Keyboard.Key[]} + * @default [] + * @since 3.0.0 + */ + this.keys = []; + + /** + * [description] + * + * @name Phaser.Input.Keyboard.KeyboardManager#combos + * @type {Phaser.Input.Keyboard.KeyCombo[]} + * @default [] + * @since 3.0.0 + */ + this.combos = []; + + /** + * [description] + * + * @name Phaser.Input.Keyboard.KeyboardManager#captures + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.captures = []; + + /** + * [description] + * + * @name Phaser.Input.Keyboard.KeyboardManager#queue + * @type {KeyboardEvent[]} + * @default [] + * @since 3.0.0 + */ + this.queue = []; + + /** + * [description] + * + * @name Phaser.Input.Keyboard.KeyboardManager#handler + * @type {?function} + * @since 3.0.0 + */ + this.handler; + }, + + /** + * The Boot handler is called by Phaser.Game when it first starts up. + * + * @method Phaser.Input.Keyboard.KeyboardManager#boot + * @since 3.0.0 + */ + boot: function () + { + var config = this.manager.config; + + this.enabled = config.inputKeyboard; + this.target = config.inputKeyboardEventTarget; + + if (this.enabled) + { + this.startListeners(); + } + }, + + /** + * [description] + * + * @method Phaser.Input.Keyboard.KeyboardManager#startListeners + * @since 3.0.0 + */ + startListeners: function () + { + var queue = this.queue; + var captures = this.captures; + + var handler = function (event) + { + if (event.defaultPrevented) + { + // Do nothing if event already handled + return; + } + + queue.push(event); + + if (captures[event.keyCode]) + { + event.preventDefault(); + } + }; + + this.handler = handler; + + this.target.addEventListener('keydown', handler, false); + this.target.addEventListener('keyup', handler, false); + }, + + /** + * [description] + * + * @method Phaser.Input.Keyboard.KeyboardManager#stopListeners + * @since 3.0.0 + */ + stopListeners: function () + { + this.target.removeEventListener('keydown', this.handler); + this.target.removeEventListener('keyup', this.handler); + }, + + /** + * Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right, and also space and shift. + * + * @method Phaser.Input.Keyboard.KeyboardManager#createCursorKeys + * @since 3.0.0 + * + * @return {object} [description] + */ + createCursorKeys: function () + { + return this.addKeys({ + up: KeyCodes.UP, + down: KeyCodes.DOWN, + left: KeyCodes.LEFT, + right: KeyCodes.RIGHT, + space: KeyCodes.SPACE, + shift: KeyCodes.SHIFT + }); + }, + + /** + * A practical way to create an object containing user selected hotkeys. + * + * For example, + * + * addKeys( { 'up': Phaser.KeyCode.W, 'down': Phaser.KeyCode.S, 'left': Phaser.KeyCode.A, 'right': Phaser.KeyCode.D } ); + * + * would return an object containing properties (`up`, `down`, `left` and `right`) referring to {@link Phaser.Key} object. + * + * @method Phaser.Input.Keyboard.KeyboardManager#addKeys + * @since 3.0.0 + * + * @param {object} keys - [description] + * + * @return {object} [description] + */ + addKeys: function (keys) + { + var output = {}; + + for (var key in keys) + { + output[key] = this.addKey(keys[key]); + } + + return output; + }, + + /** + * If you need more fine-grained control over a Key you can create a new Phaser.Key object via this method. + * The Key object can then be polled, have events attached to it, etc. + * + * @method Phaser.Input.Keyboard.KeyboardManager#addKey + * @since 3.0.0 + * + * @param {(string|integer)} keyCode - [description] + * + * @return {Phaser.Input.Keyboard.Key} [description] + */ + addKey: function (keyCode) + { + var keys = this.keys; + + if (!keys[keyCode]) + { + keys[keyCode] = new Key(keyCode); + this.captures[keyCode] = true; + } + + return keys[keyCode]; + }, + + /** + * Removes a Key object from the Keyboard manager. + * + * @method Phaser.Input.Keyboard.KeyboardManager#removeKey + * @since 3.0.0 + * + * @param {(string|integer)} keyCode - [description] + */ + removeKey: function (keyCode) + { + if (this.keys[keyCode]) + { + this.keys[keyCode] = undefined; + this.captures[keyCode] = false; + } + }, + + /** + * [description] + * + * @method Phaser.Input.Keyboard.KeyboardManager#addKeyCapture + * @since 3.0.0 + * + * @param {(string|integer|string[]|integer[])} keyCodes - [description] + */ + addKeyCapture: function (keyCodes) + { + if (!Array.isArray(keyCodes)) + { + keyCodes = [ keyCodes ]; + } + + for (var i = 0; i < keyCodes.length; i++) + { + this.captures[keyCodes[i]] = true; + } + }, + + /** + * [description] + * + * @method Phaser.Input.Keyboard.KeyboardManager#removeKeyCapture + * @since 3.0.0 + * + * @param {(string|integer|string[]|integer[])} keyCodes - [description] + */ + removeKeyCapture: function (keyCodes) + { + if (!Array.isArray(keyCodes)) + { + keyCodes = [ keyCodes ]; + } + + for (var i = 0; i < keyCodes.length; i++) + { + this.captures[keyCodes[i]] = false; + } + }, + + /** + * [description] + * + * @method Phaser.Input.Keyboard.KeyboardManager#createCombo + * @since 3.0.0 + * + * @param {(string|integer[]|object[])} keys - [description] + * @param {KeyComboConfig} config - [description] + * + * @return {Phaser.Input.Keyboard.KeyCombo} [description] + */ + createCombo: function (keys, config) + { + return new KeyCombo(this, keys, config); + }, + + /** + * [description] + * + * @method Phaser.Input.Keyboard.KeyboardManager#update + * @since 3.0.0 + */ + update: function () + { + var len = this.queue.length; + + if (!this.enabled || len === 0) + { + return; + } + + // Clears the queue array, and also means we don't work on array data that could potentially + // be modified during the processing phase + var queue = this.queue.splice(0, len); + + var keys = this.keys; + + // Process the event queue, dispatching all of the events that have stored up + for (var i = 0; i < len; i++) + { + var event = queue[i]; + var code = event.keyCode; + + if (event.type === 'keydown') + { + if (KeyMap[code] && (keys[code] === undefined || keys[code].isDown === false)) + { + // Will emit a keyboard or keyup event + this.emit(event.type, event); + + this.emit('keydown_' + KeyMap[code], event); + } + + if (keys[code]) + { + ProcessKeyDown(keys[code], event); + } + } + else + { + // Will emit a keyboard or keyup event + this.emit(event.type, event); + + this.emit('keyup_' + KeyMap[code], event); + + if (keys[code]) + { + ProcessKeyUp(keys[code], event); + } + } + } + }, + + /** + * [description] + * + * @method Phaser.Input.Keyboard.KeyboardManager#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.removeAllListeners(); + }, + + /** + * [description] + * + * @method Phaser.Input.Keyboard.KeyboardManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.stopListeners(); + + this.removeAllListeners(); + + this.keys = []; + this.combos = []; + this.captures = []; + this.queue = []; + this.handler = undefined; + + this.manager = null; + } + +}); + +module.exports = KeyboardManager; /***/ }), @@ -55523,33 +61519,119 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); + /** - * @namespace Phaser.Geom.Intersects + * @classdesc + * [description] + * + * @class Button + * @memberOf Phaser.Input.Gamepad + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Input.Gamepad.Gamepad} pad - [description] + * @param {integer} index - [description] */ +var Button = new Class({ -module.exports = { + initialize: - CircleToCircle: __webpack_require__(675), - CircleToRectangle: __webpack_require__(676), - GetRectangleIntersection: __webpack_require__(677), - LineToCircle: __webpack_require__(297), - LineToLine: __webpack_require__(89), - LineToRectangle: __webpack_require__(678), - PointToLine: __webpack_require__(298), - PointToLineSegment: __webpack_require__(679), - RectangleToRectangle: __webpack_require__(296), - RectangleToTriangle: __webpack_require__(680), - RectangleToValues: __webpack_require__(681), - TriangleToCircle: __webpack_require__(682), - TriangleToLine: __webpack_require__(683), - TriangleToTriangle: __webpack_require__(684) + function Button (pad, index) + { + /** + * [description] + * + * @name Phaser.Input.Gamepad.Button#pad + * @type {Phaser.Input.Gamepad.Gamepad} + * @since 3.0.0 + */ + this.pad = pad; -}; + /** + * [description] + * + * @name Phaser.Input.Gamepad.Button#events + * @type {EventEmitter} + * @since 3.0.0 + */ + this.events = pad.events; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.Button#index + * @type {integer} + * @since 3.0.0 + */ + this.index = index; + + /** + * Between 0 and 1. + * + * @name Phaser.Input.Gamepad.Button#value + * @type {float} + * @default 0 + * @since 3.0.0 + */ + this.value = 0; + + /** + * Can be set for Analogue buttons to enable a 'pressure' threshold before considered as 'pressed'. + * + * @name Phaser.Input.Gamepad.Button#threshold + * @type {float} + * @default 1 + * @since 3.0.0 + */ + this.threshold = 1; + + /** + * Is the Button being pressed down or not? + * + * @name Phaser.Input.Gamepad.Button#pressed + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.pressed = false; + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.Button#update + * @since 3.0.0 + * + * @param {GamepadButton} data - [description] + */ + update: function (data) + { + this.value = data.value; + + if (this.value >= this.threshold) + { + if (!this.pressed) + { + this.pressed = true; + this.events.emit('down', this.pad, this, this.value, data); + } + } + else if (this.pressed) + { + this.pressed = false; + this.events.emit('up', this.pad, this, this.value, data); + } + } + +}); + +module.exports = Button; /***/ }), /* 296 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -55557,28 +61639,102 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); + /** + * @classdesc * [description] * - * @function Phaser.Geom.Intersects.RectangleToRectangle + * @class Axis + * @memberOf Phaser.Input.Gamepad + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] - * - * @return {boolean} [description] + * @param {Phaser.Input.Gamepad.Gamepad} pad - [description] + * @param {integer} index - [description] */ -var RectangleToRectangle = function (rectA, rectB) -{ - if (rectA.width <= 0 || rectA.height <= 0 || rectB.width <= 0 || rectB.height <= 0) +var Axis = new Class({ + + initialize: + + function Axis (pad, index) { - return false; + /** + * [description] + * + * @name Phaser.Input.Gamepad.Axis#pad + * @type {Phaser.Input.Gamepad.Gamepad} + * @since 3.0.0 + */ + this.pad = pad; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.Axis#events + * @type {EventEmitter} + * @since 3.0.0 + */ + this.events = pad.events; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.Axis#index + * @type {integer} + * @since 3.0.0 + */ + this.index = index; + + /** + * Between -1 and 1 with 0 being dead center. + * + * @name Phaser.Input.Gamepad.Axis#value + * @type {float} + * @default 0 + * @since 3.0.0 + */ + this.value = 0; + + this.threshold = 0.05; + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.Axis#update + * @since 3.0.0 + * + * @param {float} value - [description] + */ + update: function (value) + { + this.value = value; + }, + + /** + * Applies threshold to the value and returns it. + * + * @method Phaser.Input.Gamepad.Axis#getValue + * @since 3.0.0 + * + * @return {float} [description] + */ + getValue: function () + { + var percentage = (Math.abs(this.value) - this.threshold) / (1 - this.threshold); + + if (percentage < 0) + { + percentage = 0; + } + + return percentage * (this.value > 0 ? 1 : -1); } - return !(rectA.right < rectB.x || rectA.bottom < rectB.y || rectA.x > rectB.right || rectA.y > rectB.bottom); -}; +}); -module.exports = RectangleToRectangle; +module.exports = Axis; /***/ }), @@ -55591,84 +61747,158 @@ module.exports = RectangleToRectangle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Based on code by Matt DesLauriers -// https://github.com/mattdesl/line-circle-collision/blob/master/LICENSE.md - -var Contains = __webpack_require__(32); -var Point = __webpack_require__(5); - -var tmp = new Point(); +var Axis = __webpack_require__(296); +var Button = __webpack_require__(295); +var Class = __webpack_require__(0); /** + * @classdesc * [description] * - * @function Phaser.Geom.Intersects.LineToCircle + * @class Gamepad + * @memberOf Phaser.Input.Gamepad + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Line} line - [description] - * @param {Phaser.Geom.Circle} circle - [description] - * @param {Phaser.Geom.Point} [nearest] - [description] - * - * @return {boolean} [description] + * @param {Phaser.Input.Gamepad.GamepadManager} manager - [description] + * @param {string} id - [description] + * @param {number} index - [description] */ -var LineToCircle = function (line, circle, nearest) -{ - if (nearest === undefined) { nearest = tmp; } +var Gamepad = new Class({ - if (Contains(circle, line.x1, line.y1)) + initialize: + + function Gamepad (manager, id, index) { - nearest.x = line.x1; - nearest.y = line.y1; + /** + * [description] + * + * @name Phaser.Input.Gamepad.Gamepad#manager + * @type {Phaser.Input.Gamepad.GamepadManager} + * @since 3.0.0 + */ + this.manager = manager; - return true; + /** + * [description] + * + * @name Phaser.Input.Gamepad.Gamepad#events + * @type {EventEmitter} + * @since 3.0.0 + */ + this.events = manager.events; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.Gamepad#id + * @type {string} + * @since 3.0.0 + */ + this.id = id; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.Gamepad#index + * @type {number} + * @since 3.0.0 + */ + this.index = index; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.Gamepad#connected + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.connected = true; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.Gamepad#timestamp + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.timestamp = 0; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.Gamepad#buttons + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.buttons = []; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.Gamepad#axes + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.axes = []; + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.Gamepad#update + * @since 3.0.0 + * + * @param {Gamepad} data - [description] + */ + update: function (data) + { + this.timestamp = data.timestamp; + this.connected = data.connected; + + var i; + + var axes = this.axes; + var buttons = this.buttons; + + for (i = 0; i < data.buttons.length; i++) + { + var buttonData = data.buttons[i]; + + if (buttons[i] === undefined) + { + buttons[i] = new Button(this, i); + } + + buttons[i].update(buttonData); + } + + // Axes + for (i = 0; i < data.axes.length; i++) + { + var axisData = data.axes[i]; + + if (axes[i] === undefined) + { + axes[i] = new Axis(this, i); + } + + axes[i].update(axisData); + } } - if (Contains(circle, line.x2, line.y2)) - { - nearest.x = line.x2; - nearest.y = line.y2; +}); - return true; - } - - var dx = line.x2 - line.x1; - var dy = line.y2 - line.y1; - - var lcx = circle.x - line.x1; - var lcy = circle.y - line.y1; - - // project lc onto d, resulting in vector p - var dLen2 = (dx * dx) + (dy * dy); - var px = dx; - var py = dy; - - if (dLen2 > 0) - { - var dp = ((lcx * dx) + (lcy * dy)) / dLen2; - - px *= dp; - py *= dp; - } - - nearest.x = line.x1 + px; - nearest.y = line.y1 + py; - - // len2 of p - var pLen2 = (px * px) + (py * py); - - return ( - pLen2 <= dLen2 && - ((px * dx) + (py * dy)) >= 0 && - Contains(circle, nearest.x, nearest.y) - ); -}; - -module.exports = LineToCircle; +module.exports = Gamepad; /***/ }), /* 298 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -55676,28 +61906,395 @@ module.exports = LineToCircle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var Gamepad = __webpack_require__(297); + +// https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API +// https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API +// https://www.smashingmagazine.com/2015/11/gamepad-api-in-web-games/ +// http://html5gamepad.com/ + /** + * @typedef {object} Pad + * + * @property {string} id - [description] + * @property {number} index - [description] + */ + +/** + * @classdesc * [description] * - * @function Phaser.Geom.Intersects.PointToLine + * @class GamepadManager + * @memberOf Phaser.Input.Gamepad + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Point} point - [description] - * @param {Phaser.Geom.Line} line - [description] - * - * @return {boolean} [description] + * @param {Phaser.Input.InputManager} inputManager - [description] */ -var PointToLine = function (point, line) -{ - return ((point.x - line.x1) * (line.y2 - line.y1) === (line.x2 - line.x1) * (point.y - line.y1)); -}; +var GamepadManager = new Class({ -module.exports = PointToLine; + initialize: + + function GamepadManager (inputManager) + { + /** + * [description] + * + * @name Phaser.Input.Gamepad.GamepadManager#manager + * @type {Phaser.Input.InputManager} + * @since 3.0.0 + */ + this.manager = inputManager; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.GamepadManager#events + * @type {EventEmitter} + * @since 3.0.0 + */ + this.events = inputManager.events; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.GamepadManager#enabled + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.enabled = false; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.GamepadManager#target + * @type {?object} + * @since 3.0.0 + */ + this.target; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.GamepadManager#handler + * @type {?function} + * @since 3.0.0 + */ + this.handler; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.GamepadManager#gamepads + * @type {Phaser.Input.Gamepad.Gamepad[]} + * @default [] + * @since 3.0.0 + */ + this.gamepads = []; + + /** + * Standard FIFO queue. + * + * @name Phaser.Input.Gamepad.GamepadManager#queue + * @type {GamepadEvent[]} + * @default [] + * @since 3.0.0 + */ + this.queue = []; + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.GamepadManager#boot + * @since 3.0.0 + */ + boot: function () + { + var config = this.manager.config; + + this.enabled = config.inputGamepad && this.manager.game.device.input.gamepads; + + this.target = window; + + if (this.enabled) + { + this.startListeners(); + } + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.GamepadManager#startListeners + * @since 3.0.0 + */ + startListeners: function () + { + var queue = this.queue; + + var handler = function handler (event) + { + if (event.defaultPrevented) + { + // Do nothing if event already handled + return; + } + + queue.push(event); + }; + + this.handler = handler; + + var target = this.target; + + target.addEventListener('gamepadconnected', handler, false); + target.addEventListener('gamepaddisconnected', handler, false); + + // FF only for now: + target.addEventListener('gamepadbuttondown', handler, false); + target.addEventListener('gamepadbuttonup', handler, false); + target.addEventListener('gamepadaxismove', handler, false); + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.GamepadManager#stopListeners + * @since 3.0.0 + */ + stopListeners: function () + { + var target = this.target; + var handler = this.handler; + + target.removeEventListener('gamepadconnected', handler); + target.removeEventListener('gamepaddisconnected', handler); + + target.removeEventListener('gamepadbuttondown', handler); + target.removeEventListener('gamepadbuttonup', handler); + target.removeEventListener('gamepadaxismove', handler); + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.GamepadManager#disconnectAll + * @since 3.0.0 + */ + disconnectAll: function () + { + for (var i = 0; i < this.gamepads.length; i++) + { + this.gamepads.connected = false; + } + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.GamepadManager#addPad + * @since 3.0.0 + * + * @param {Pad} pad - [description] + * + * @return {Phaser.Input.Gamepad.Gamepad} [description] + */ + addPad: function (pad) + { + var gamepad = new Gamepad(this, pad.id, pad.index); + + this.gamepads[pad.index] = gamepad; + + return gamepad; + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.GamepadManager#removePad + * @since 3.0.0 + * @todo Code this feature + * + * @param {number} index - [description] + * @param {Pad} pad - [description] + */ + removePad: function () + { + // TODO + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.GamepadManager#refreshPads + * @since 3.0.0 + * + * @param {Pad[]} pads - [description] + */ + refreshPads: function (pads) + { + if (!pads) + { + this.disconnectAll(); + } + else + { + for (var i = 0; i < pads.length; i++) + { + var pad = pads[i]; + + if (!pad) + { + // removePad? + continue; + } + + if (this.gamepads[pad.index] === undefined) + { + this.addPad(pad); + } + + this.gamepads[pad.index].update(pad); + } + } + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.GamepadManager#getAll + * @since 3.0.0 + * + * @return {Phaser.Input.Gamepad.Gamepad[]} [description] + */ + getAll: function () + { + var out = []; + + for (var i = 0; i < this.gamepads.length; i++) + { + if (this.gamepads[i]) + { + out.push(this.gamepads[i]); + } + } + + return out; + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.GamepadManager#getPad + * @since 3.0.0 + * + * @param {number} index - [description] + * + * @return {Phaser.Input.Gamepad.Gamepad} [description] + */ + getPad: function (index) + { + for (var i = 0; i < this.gamepads.length; i++) + { + if (this.gamepads[i].index === index) + { + return this.gamepads[i]; + } + } + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.GamepadManager#update + * @since 3.0.0 + */ + update: function () + { + if (!this.enabled) + { + return; + } + + this.refreshPads(navigator.getGamepads()); + + var len = this.queue.length; + + if (len === 0) + { + return; + } + + var queue = this.queue.splice(0, len); + + // Process the event queue, dispatching all of the events that have stored up + for (var i = 0; i < len; i++) + { + var event = queue[i]; + var pad; + + switch (event.type) + { + case 'gamepadconnected': + + pad = this.getPad(event.gamepad.index); + + this.events.emit('connected', pad, event); + + break; + + case 'gamepaddisconnected': + + pad = this.getPad(event.gamepad.index); + + this.events.emit('disconnected', pad, event); + + break; + } + } + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.GamepadManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.stopListeners(); + this.disconnectAll(); + + this.gamepads = []; + }, + + /** + * The total number of connected game pads. + * + * @name Phaser.Input.Gamepad.GamepadManager#total + * @type {number} + * @since 3.0.0 + */ + total: { + + get: function () + { + return this.gamepads.length; + } + + } + +}); + +module.exports = GamepadManager; /***/ }), /* 299 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -55705,30 +62302,579 @@ module.exports = PointToLine; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(15); +var Gamepad = __webpack_require__(298); +var Keyboard = __webpack_require__(294); +var Mouse = __webpack_require__(291); +var Pointer = __webpack_require__(290); +var Rectangle = __webpack_require__(10); +var Touch = __webpack_require__(289); +var TransformXY = __webpack_require__(288); + /** + * @classdesc * [description] * - * @function Phaser.Geom.Rectangle.Decompose + * @class InputManager + * @memberOf Phaser.Input + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {array} [out] - [description] - * - * @return {array} [description] + * @param {Phaser.Game} game - [description] + * @param {object} config - [description] */ -var Decompose = function (rect, out) -{ - if (out === undefined) { out = []; } +var InputManager = new Class({ - out.push({ x: rect.x, y: rect.y }); - out.push({ x: rect.right, y: rect.y }); - out.push({ x: rect.right, y: rect.bottom }); - out.push({ x: rect.x, y: rect.bottom }); + initialize: - return out; -}; + function InputManager (game, config) + { + /** + * [description] + * + * @name Phaser.Input.InputManager#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game = game; -module.exports = Decompose; + /** + * [description] + * + * @name Phaser.Input.InputManager#canvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvas; + + /** + * [description] + * + * @name Phaser.Input.InputManager#config + * @type {object} + * @since 3.0.0 + */ + this.config = config; + + /** + * [description] + * + * @name Phaser.Input.InputManager#enabled + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.enabled = true; + + /** + * [description] + * + * @name Phaser.Input.InputManager#events + * @type {EventEmitter} + * @since 3.0.0 + */ + this.events = new EventEmitter(); + + /** + * Standard FIFO queue. + * + * @name Phaser.Input.InputManager#queue + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.queue = []; + + /** + * [description] + * + * @name Phaser.Input.InputManager#keyboard + * @type {Phaser.Input.Keyboard.KeyboardManager} + * @since 3.0.0 + */ + this.keyboard = new Keyboard(this); + + /** + * [description] + * + * @name Phaser.Input.InputManager#mouse + * @type {Phaser.Input.Mouse.MouseManager} + * @since 3.0.0 + */ + this.mouse = new Mouse(this); + + /** + * [description] + * + * @name Phaser.Input.InputManager#touch + * @type {Phaser.Input.Touch.TouchManager} + * @since 3.0.0 + */ + this.touch = new Touch(this); + + /** + * [description] + * + * @name Phaser.Input.InputManager#gamepad + * @type {Phaser.Input.Gamepad.GamepadManager} + * @since 3.0.0 + */ + this.gamepad = new Gamepad(this); + + /** + * [description] + * + * @name Phaser.Input.InputManager#activePointer + * @type {Phaser.Input.Pointer} + * @since 3.0.0 + */ + this.activePointer = new Pointer(this, 0); + + /** + * [description] + * + * @name Phaser.Input.InputManager#scale + * @type {{x:number,y:number}} + * @since 3.0.0 + */ + this.scale = { x: 1, y: 1 }; + + /** + * If the top-most Scene in the Scene List receives an input it will stop input from + * propagating any lower down the scene list, i.e. if you have a UI Scene at the top + * and click something on it, that click will not then be passed down to any other + * Scene below. Disable this to have input events passed through all Scenes, all the time. + * + * @name Phaser.Input.InputManager#globalTopOnly + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.globalTopOnly = true; + + /** + * [description] + * + * @name Phaser.Input.InputManager#ignoreEvents + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.ignoreEvents = false; + + /** + * [description] + * + * @name Phaser.Input.InputManager#bounds + * @type {Phaser.Geom.Rectangle} + * @since 3.0.0 + */ + this.bounds = new Rectangle(); + + /** + * [description] + * + * @name Phaser.Input.InputManager#_tempPoint + * @type {{x:number,y:number}} + * @private + * @since 3.0.0 + */ + this._tempPoint = { x: 0, y: 0 }; + + /** + * [description] + * + * @name Phaser.Input.InputManager#_tempHitTest + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this._tempHitTest = []; + + game.events.once('boot', this.boot, this); + }, + + /** + * The Boot handler is called by Phaser.Game when it first starts up. + * The renderer is available by now. + * + * @method Phaser.Input.InputManager#boot + * @since 3.0.0 + */ + boot: function () + { + this.canvas = this.game.canvas; + + this.updateBounds(); + + this.keyboard.boot(); + this.mouse.boot(); + this.touch.boot(); + this.gamepad.boot(); + + this.game.events.once('destroy', this.destroy, this); + }, + + /** + * [description] + * + * @method Phaser.Input.InputManager#updateBounds + * @since 3.0.0 + */ + updateBounds: function () + { + var bounds = this.bounds; + + var clientRect = this.canvas.getBoundingClientRect(); + + bounds.x = clientRect.left + window.pageXOffset - document.documentElement.clientLeft; + bounds.y = clientRect.top + window.pageYOffset - document.documentElement.clientTop; + bounds.width = clientRect.width; + bounds.height = clientRect.height; + }, + + /** + * [description] + * + * @method Phaser.Input.InputManager#resize + * @since 3.2.0 + */ + resize: function () + { + this.updateBounds(); + + // Game config size + var gw = this.game.config.width; + var gh = this.game.config.height; + + // Actual canvas size + var bw = this.bounds.width; + var bh = this.bounds.height; + + // Scale factor + this.scale.x = gw / bw; + this.scale.y = gh / bh; + }, + + /** + * [description] + * + * @method Phaser.Input.InputManager#update + * @since 3.0.0 + * + * @param {number} time - [description] + */ + update: function (time) + { + this.keyboard.update(); + this.gamepad.update(); + + this.ignoreEvents = false; + + var len = this.queue.length; + + // Currently just 1 pointer supported + var pointer = this.activePointer; + + pointer.reset(); + + if (!this.enabled || len === 0) + { + return; + } + + this.updateBounds(); + + this.scale.x = this.game.config.width / this.bounds.width; + this.scale.y = this.game.config.height / this.bounds.height; + + // Clears the queue array, and also means we don't work on array data that could potentially + // be modified during the processing phase + var queue = this.queue.splice(0, len); + + // Process the event queue, dispatching all of the events that have stored up + for (var i = 0; i < len; i++) + { + var event = queue[i]; + + // TODO: Move to CONSTs so we can do integer comparisons instead of strings. + switch (event.type) + { + case 'mousemove': + + pointer.move(event, time); + break; + + case 'mousedown': + + pointer.down(event, time); + break; + + case 'mouseup': + + pointer.up(event, time); + break; + + case 'touchmove': + + pointer.touchmove(event, time); + break; + + case 'touchstart': + + pointer.touchstart(event, time); + break; + + case 'touchend': + + pointer.touchend(event, time); + break; + + case 'pointerlockchange': + + this.events.emit('pointerlockchange', event, this.mouse.locked); + break; + } + } + }, + + /** + * Will always return an array. + * Array contains matching Interactive Objects. + * Array will be empty if no objects were matched. + * x/y = pointer x/y (un-translated) + * + * @method Phaser.Input.InputManager#hitTest + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {array} gameObjects - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @param {array} output - [description] + * + * @return {array} [description] + */ + hitTest: function (x, y, gameObjects, camera, output) + { + if (output === undefined) { output = this._tempHitTest; } + + var tempPoint = this._tempPoint; + var cameraW = camera.width; + var cameraH = camera.height; + + output.length = 0; + + if (!(x >= camera.x && y >= camera.y && x <= camera.x + cameraW && y <= camera.y + cameraH)) + { + return output; + } + + // Stores the world point inside of tempPoint + camera.getWorldPoint(x, y, tempPoint); + + var culledGameObjects = camera.cull(gameObjects); + + var point = { x: 0, y: 0 }; + + var res = this.game.config.resolution; + + for (var i = 0; i < culledGameObjects.length; i++) + { + var gameObject = culledGameObjects[i]; + + if (!gameObject.input || !gameObject.input.enabled || !gameObject.willRender()) + { + continue; + } + + var px = tempPoint.x * res + (camera.scrollX * gameObject.scrollFactorX) - camera.scrollX; + var py = tempPoint.y * res + (camera.scrollY * gameObject.scrollFactorY) - camera.scrollY; + + TransformXY(px, py, gameObject.x, gameObject.y, gameObject.rotation, gameObject.scaleX, gameObject.scaleY, point); + + if (this.pointWithinHitArea(gameObject, point.x, point.y)) + { + output.push(gameObject); + } + } + + return output; + }, + + /** + * x/y MUST be translated before being passed to this function, + * unless the gameObject is guaranteed to not be rotated or scaled in any way. + * + * @method Phaser.Input.InputManager#pointWithinHitArea + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ + pointWithinHitArea: function (gameObject, x, y) + { + var input = gameObject.input; + + // Normalize the origin + x += gameObject.displayOriginX; + y += gameObject.displayOriginY; + + if (input.hitAreaCallback(input.hitArea, x, y, gameObject)) + { + input.localX = x; + input.localY = y; + + return true; + } + else + { + return false; + } + }, + + /** + * x/y MUST be translated before being passed to this function, + * unless the gameObject is guaranteed to not be rotated or scaled in any way. + * + * @method Phaser.Input.InputManager#pointWithinInteractiveObject + * @since 3.0.0 + * + * @param {Phaser.Input.InteractiveObject} object - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ + pointWithinInteractiveObject: function (object, x, y) + { + if (!object.hitArea) + { + return false; + } + + // Normalize the origin + x += object.gameObject.displayOriginX; + y += object.gameObject.displayOriginY; + + object.localX = x; + object.localY = y; + + return object.hitAreaCallback(object.hitArea, x, y, object); + }, + + /** + * [description] + * + * @method Phaser.Input.InputManager#transformX + * @since 3.0.0 + * + * @param {number} pageX - [description] + * + * @return {number} [description] + */ + transformX: function (pageX) + { + return (pageX - this.bounds.left) * this.scale.x; + }, + + /** + * [description] + * + * @method Phaser.Input.InputManager#transformY + * @since 3.0.0 + * + * @param {number} pageY - [description] + * + * @return {number} [description] + */ + transformY: function (pageY) + { + return (pageY - this.bounds.top) * this.scale.y; + }, + + /** + * [description] + * + * @method Phaser.Input.InputManager#getOffsetX + * @since 3.0.0 + * + * @return {number} [description] + */ + getOffsetX: function () + { + return this.bounds.left; + }, + + /** + * [description] + * + * @method Phaser.Input.InputManager#getOffsetY + * @since 3.0.0 + * + * @return {number} [description] + */ + getOffsetY: function () + { + return this.bounds.top; + }, + + /** + * [description] + * + * @method Phaser.Input.InputManager#getScaleX + * @since 3.0.0 + * + * @return {number} [description] + */ + getScaleX: function () + { + return this.game.config.width / this.bounds.width; + }, + + /** + * [description] + * + * @method Phaser.Input.InputManager#getScaleY + * @since 3.0.0 + * + * @return {number} [description] + */ + getScaleY: function () + { + return this.game.config.height / this.bounds.height; + }, + + /** + * [description] + * + * @method Phaser.Input.InputManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.events.removeAllListeners(); + + this.keyboard.destroy(); + this.mouse.destroy(); + this.touch.destroy(); + this.gamepad.destroy(); + + this.activePointer.destroy(); + + this.queue = []; + + this.game = null; + } + +}); + +module.exports = InputManager; /***/ }), @@ -55741,327 +62887,1173 @@ module.exports = Decompose; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * [description] - * - * @function Phaser.Geom.Triangle.Decompose - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {array} [out] - [description] - * - * @return {array} [description] - */ -var Decompose = function (triangle, out) -{ - if (out === undefined) { out = []; } +var ModelViewProjection = { - out.push({ x: triangle.x1, y: triangle.y1 }); - out.push({ x: triangle.x2, y: triangle.y2 }); - out.push({ x: triangle.x3, y: triangle.y3 }); + modelMatrixDirty: false, + viewMatrixDirty: false, + projectionMatrixDirty: false, + modelMatrix: null, + viewMatrix: null, + projectionMatrix: null, - return out; + mvpInit: function () + { + this.modelMatrixDirty = true; + this.viewMatrixDirty = true; + this.projectionMatrixDirty = true; + + this.modelMatrix = new Float32Array([ + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + ]); + + this.viewMatrix = new Float32Array([ + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + ]); + + this.projectionMatrix = new Float32Array([ + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + ]); + + return this; + }, + + mvpUpdate: function () + { + var program = this.program; + + if (this.modelMatrixDirty) + { + this.renderer.setMatrix4(program, 'uModelMatrix', false, this.modelMatrix); + this.modelMatrixDirty = false; + } + + if (this.viewMatrixDirty) + { + this.renderer.setMatrix4(program, 'uViewMatrix', false, this.viewMatrix); + this.viewMatrixDirty = false; + } + + if (this.projectionMatrixDirty) + { + this.renderer.setMatrix4(program, 'uProjectionMatrix', false, this.projectionMatrix); + this.projectionMatrixDirty = false; + } + + return this; + }, + + modelIdentity: function () + { + var modelMatrix = this.modelMatrix; + + modelMatrix[0] = 1; + modelMatrix[1] = 0; + modelMatrix[2] = 0; + modelMatrix[3] = 0; + modelMatrix[4] = 0; + modelMatrix[5] = 1; + modelMatrix[6] = 0; + modelMatrix[7] = 0; + modelMatrix[8] = 0; + modelMatrix[9] = 0; + modelMatrix[10] = 1; + modelMatrix[11] = 0; + modelMatrix[12] = 0; + modelMatrix[13] = 0; + modelMatrix[14] = 0; + modelMatrix[15] = 1; + + this.modelMatrixDirty = true; + + return this; + }, + + modelScale: function (x, y, z) + { + var modelMatrix = this.modelMatrix; + + modelMatrix[0] = modelMatrix[0] * x; + modelMatrix[1] = modelMatrix[1] * x; + modelMatrix[2] = modelMatrix[2] * x; + modelMatrix[3] = modelMatrix[3] * x; + modelMatrix[4] = modelMatrix[4] * y; + modelMatrix[5] = modelMatrix[5] * y; + modelMatrix[6] = modelMatrix[6] * y; + modelMatrix[7] = modelMatrix[7] * y; + modelMatrix[8] = modelMatrix[8] * z; + modelMatrix[9] = modelMatrix[9] * z; + modelMatrix[10] = modelMatrix[10] * z; + modelMatrix[11] = modelMatrix[11] * z; + + this.modelMatrixDirty = true; + + return this; + }, + + modelTranslate: function (x, y, z) + { + var modelMatrix = this.modelMatrix; + + modelMatrix[12] = modelMatrix[0] * x + modelMatrix[4] * y + modelMatrix[8] * z + modelMatrix[12]; + modelMatrix[13] = modelMatrix[1] * x + modelMatrix[5] * y + modelMatrix[9] * z + modelMatrix[13]; + modelMatrix[14] = modelMatrix[2] * x + modelMatrix[6] * y + modelMatrix[10] * z + modelMatrix[14]; + modelMatrix[15] = modelMatrix[3] * x + modelMatrix[7] * y + modelMatrix[11] * z + modelMatrix[15]; + + this.modelMatrixDirty = true; + + return this; + }, + + modelRotateX: function (radians) + { + var modelMatrix = this.modelMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a10 = modelMatrix[4]; + var a11 = modelMatrix[5]; + var a12 = modelMatrix[6]; + var a13 = modelMatrix[7]; + var a20 = modelMatrix[8]; + var a21 = modelMatrix[9]; + var a22 = modelMatrix[10]; + var a23 = modelMatrix[11]; + + modelMatrix[4] = a10 * c + a20 * s; + modelMatrix[5] = a11 * c + a21 * s; + modelMatrix[6] = a12 * c + a22 * s; + modelMatrix[7] = a13 * c + a23 * s; + modelMatrix[8] = a20 * c - a10 * s; + modelMatrix[9] = a21 * c - a11 * s; + modelMatrix[10] = a22 * c - a12 * s; + modelMatrix[11] = a23 * c - a13 * s; + + this.modelMatrixDirty = true; + + return this; + }, + + modelRotateY: function (radians) + { + var modelMatrix = this.modelMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a00 = modelMatrix[0]; + var a01 = modelMatrix[1]; + var a02 = modelMatrix[2]; + var a03 = modelMatrix[3]; + var a20 = modelMatrix[8]; + var a21 = modelMatrix[9]; + var a22 = modelMatrix[10]; + var a23 = modelMatrix[11]; + + modelMatrix[0] = a00 * c - a20 * s; + modelMatrix[1] = a01 * c - a21 * s; + modelMatrix[2] = a02 * c - a22 * s; + modelMatrix[3] = a03 * c - a23 * s; + modelMatrix[8] = a00 * s + a20 * c; + modelMatrix[9] = a01 * s + a21 * c; + modelMatrix[10] = a02 * s + a22 * c; + modelMatrix[11] = a03 * s + a23 * c; + + this.modelMatrixDirty = true; + + return this; + }, + + modelRotateZ: function (radians) + { + var modelMatrix = this.modelMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a00 = modelMatrix[0]; + var a01 = modelMatrix[1]; + var a02 = modelMatrix[2]; + var a03 = modelMatrix[3]; + var a10 = modelMatrix[4]; + var a11 = modelMatrix[5]; + var a12 = modelMatrix[6]; + var a13 = modelMatrix[7]; + + modelMatrix[0] = a00 * c + a10 * s; + modelMatrix[1] = a01 * c + a11 * s; + modelMatrix[2] = a02 * c + a12 * s; + modelMatrix[3] = a03 * c + a13 * s; + modelMatrix[4] = a10 * c - a00 * s; + modelMatrix[5] = a11 * c - a01 * s; + modelMatrix[6] = a12 * c - a02 * s; + modelMatrix[7] = a13 * c - a03 * s; + + this.modelMatrixDirty = true; + + return this; + }, + + viewIdentity: function () + { + var viewMatrix = this.viewMatrix; + + viewMatrix[0] = 1; + viewMatrix[1] = 0; + viewMatrix[2] = 0; + viewMatrix[3] = 0; + viewMatrix[4] = 0; + viewMatrix[5] = 1; + viewMatrix[6] = 0; + viewMatrix[7] = 0; + viewMatrix[8] = 0; + viewMatrix[9] = 0; + viewMatrix[10] = 1; + viewMatrix[11] = 0; + viewMatrix[12] = 0; + viewMatrix[13] = 0; + viewMatrix[14] = 0; + viewMatrix[15] = 1; + + this.viewMatrixDirty = true; + + return this; + }, + + viewScale: function (x, y, z) + { + var viewMatrix = this.viewMatrix; + + viewMatrix[0] = viewMatrix[0] * x; + viewMatrix[1] = viewMatrix[1] * x; + viewMatrix[2] = viewMatrix[2] * x; + viewMatrix[3] = viewMatrix[3] * x; + viewMatrix[4] = viewMatrix[4] * y; + viewMatrix[5] = viewMatrix[5] * y; + viewMatrix[6] = viewMatrix[6] * y; + viewMatrix[7] = viewMatrix[7] * y; + viewMatrix[8] = viewMatrix[8] * z; + viewMatrix[9] = viewMatrix[9] * z; + viewMatrix[10] = viewMatrix[10] * z; + viewMatrix[11] = viewMatrix[11] * z; + + this.viewMatrixDirty = true; + + return this; + }, + + viewTranslate: function (x, y, z) + { + var viewMatrix = this.viewMatrix; + + viewMatrix[12] = viewMatrix[0] * x + viewMatrix[4] * y + viewMatrix[8] * z + viewMatrix[12]; + viewMatrix[13] = viewMatrix[1] * x + viewMatrix[5] * y + viewMatrix[9] * z + viewMatrix[13]; + viewMatrix[14] = viewMatrix[2] * x + viewMatrix[6] * y + viewMatrix[10] * z + viewMatrix[14]; + viewMatrix[15] = viewMatrix[3] * x + viewMatrix[7] * y + viewMatrix[11] * z + viewMatrix[15]; + + this.viewMatrixDirty = true; + + return this; + }, + + viewRotateX: function (radians) + { + var viewMatrix = this.viewMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a10 = viewMatrix[4]; + var a11 = viewMatrix[5]; + var a12 = viewMatrix[6]; + var a13 = viewMatrix[7]; + var a20 = viewMatrix[8]; + var a21 = viewMatrix[9]; + var a22 = viewMatrix[10]; + var a23 = viewMatrix[11]; + + viewMatrix[4] = a10 * c + a20 * s; + viewMatrix[5] = a11 * c + a21 * s; + viewMatrix[6] = a12 * c + a22 * s; + viewMatrix[7] = a13 * c + a23 * s; + viewMatrix[8] = a20 * c - a10 * s; + viewMatrix[9] = a21 * c - a11 * s; + viewMatrix[10] = a22 * c - a12 * s; + viewMatrix[11] = a23 * c - a13 * s; + + this.viewMatrixDirty = true; + + return this; + }, + + viewRotateY: function (radians) + { + var viewMatrix = this.viewMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a00 = viewMatrix[0]; + var a01 = viewMatrix[1]; + var a02 = viewMatrix[2]; + var a03 = viewMatrix[3]; + var a20 = viewMatrix[8]; + var a21 = viewMatrix[9]; + var a22 = viewMatrix[10]; + var a23 = viewMatrix[11]; + + viewMatrix[0] = a00 * c - a20 * s; + viewMatrix[1] = a01 * c - a21 * s; + viewMatrix[2] = a02 * c - a22 * s; + viewMatrix[3] = a03 * c - a23 * s; + viewMatrix[8] = a00 * s + a20 * c; + viewMatrix[9] = a01 * s + a21 * c; + viewMatrix[10] = a02 * s + a22 * c; + viewMatrix[11] = a03 * s + a23 * c; + + this.viewMatrixDirty = true; + + return this; + }, + + viewRotateZ: function (radians) + { + var viewMatrix = this.viewMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a00 = viewMatrix[0]; + var a01 = viewMatrix[1]; + var a02 = viewMatrix[2]; + var a03 = viewMatrix[3]; + var a10 = viewMatrix[4]; + var a11 = viewMatrix[5]; + var a12 = viewMatrix[6]; + var a13 = viewMatrix[7]; + + viewMatrix[0] = a00 * c + a10 * s; + viewMatrix[1] = a01 * c + a11 * s; + viewMatrix[2] = a02 * c + a12 * s; + viewMatrix[3] = a03 * c + a13 * s; + viewMatrix[4] = a10 * c - a00 * s; + viewMatrix[5] = a11 * c - a01 * s; + viewMatrix[6] = a12 * c - a02 * s; + viewMatrix[7] = a13 * c - a03 * s; + + this.viewMatrixDirty = true; + + return this; + }, + + viewLoad2D: function (matrix2D) + { + var vm = this.viewMatrix; + + vm[0] = matrix2D[0]; + vm[1] = matrix2D[1]; + vm[2] = 0.0; + vm[3] = 0.0; + vm[4] = matrix2D[2]; + vm[5] = matrix2D[3]; + vm[6] = 0.0; + vm[7] = 0.0; + vm[8] = matrix2D[4]; + vm[9] = matrix2D[5]; + vm[10] = 1.0; + vm[11] = 0.0; + vm[12] = 0.0; + vm[13] = 0.0; + vm[14] = 0.0; + vm[15] = 1.0; + + this.viewMatrixDirty = true; + + return this; + }, + + viewLoad: function (matrix) + { + var vm = this.viewMatrix; + + vm[0] = matrix[0]; + vm[1] = matrix[1]; + vm[2] = matrix[2]; + vm[3] = matrix[3]; + vm[4] = matrix[4]; + vm[5] = matrix[5]; + vm[6] = matrix[6]; + vm[7] = matrix[7]; + vm[8] = matrix[8]; + vm[9] = matrix[9]; + vm[10] = matrix[10]; + vm[11] = matrix[11]; + vm[12] = matrix[12]; + vm[13] = matrix[13]; + vm[14] = matrix[14]; + vm[15] = matrix[15]; + + this.viewMatrixDirty = true; + + return this; + }, + + projIdentity: function () + { + var projectionMatrix = this.projectionMatrix; + + projectionMatrix[0] = 1; + projectionMatrix[1] = 0; + projectionMatrix[2] = 0; + projectionMatrix[3] = 0; + projectionMatrix[4] = 0; + projectionMatrix[5] = 1; + projectionMatrix[6] = 0; + projectionMatrix[7] = 0; + projectionMatrix[8] = 0; + projectionMatrix[9] = 0; + projectionMatrix[10] = 1; + projectionMatrix[11] = 0; + projectionMatrix[12] = 0; + projectionMatrix[13] = 0; + projectionMatrix[14] = 0; + projectionMatrix[15] = 1; + + this.projectionMatrixDirty = true; + + return this; + }, + + projOrtho: function (left, right, bottom, top, near, far) + { + var projectionMatrix = this.projectionMatrix; + var leftRight = 1.0 / (left - right); + var bottomTop = 1.0 / (bottom - top); + var nearFar = 1.0 / (near - far); + + projectionMatrix[0] = -2.0 * leftRight; + projectionMatrix[1] = 0.0; + projectionMatrix[2] = 0.0; + projectionMatrix[3] = 0.0; + projectionMatrix[4] = 0.0; + projectionMatrix[5] = -2.0 * bottomTop; + projectionMatrix[6] = 0.0; + projectionMatrix[7] = 0.0; + projectionMatrix[8] = 0.0; + projectionMatrix[9] = 0.0; + projectionMatrix[10] = 2.0 * nearFar; + projectionMatrix[11] = 0.0; + projectionMatrix[12] = (left + right) * leftRight; + projectionMatrix[13] = (top + bottom) * bottomTop; + projectionMatrix[14] = (far + near) * nearFar; + projectionMatrix[15] = 1.0; + + this.projectionMatrixDirty = true; + return this; + }, + + projPersp: function (fovy, aspectRatio, near, far) + { + var projectionMatrix = this.projectionMatrix; + var fov = 1.0 / Math.tan(fovy / 2.0); + var nearFar = 1.0 / (near - far); + + projectionMatrix[0] = fov / aspectRatio; + projectionMatrix[1] = 0.0; + projectionMatrix[2] = 0.0; + projectionMatrix[3] = 0.0; + projectionMatrix[4] = 0.0; + projectionMatrix[5] = fov; + projectionMatrix[6] = 0.0; + projectionMatrix[7] = 0.0; + projectionMatrix[8] = 0.0; + projectionMatrix[9] = 0.0; + projectionMatrix[10] = (far + near) * nearFar; + projectionMatrix[11] = -1.0; + projectionMatrix[12] = 0.0; + projectionMatrix[13] = 0.0; + projectionMatrix[14] = (2.0 * far * near) * nearFar; + projectionMatrix[15] = 0.0; + + this.projectionMatrixDirty = true; + return this; + } }; -module.exports = Decompose; +module.exports = ModelViewProjection; /***/ }), /* 301 */ /***/ (function(module, exports, __webpack_require__) { +"use strict"; /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var GetPoint = __webpack_require__(302); -var GetPoints = __webpack_require__(109); -var Random = __webpack_require__(111); +// 2.1.1 (Mar 17, 2016) -/** - * @classdesc - * Defines a Line segment, a part of a line between two endpoints. - * - * @class Line - * @memberOf Phaser.Geom - * @constructor - * @since 3.0.0 - * - * @param {number} [x1] - [description] - * @param {number} [y1] - [description] - * @param {number} [x2] - [description] - * @param {number} [y2] - [description] +/* +ISC License + +Copyright (c) 2016, Mapbox + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. */ -var Line = new Class({ - initialize: - function Line (x1, y1, x2, y2) - { - if (x1 === undefined) { x1 = 0; } - if (y1 === undefined) { y1 = 0; } - if (x2 === undefined) { x2 = 0; } - if (y2 === undefined) { y2 = 0; } - /** - * [description] - * - * @name Phaser.Geom.Line#x1 - * @type {number} - * @since 3.0.0 - */ - this.x1 = x1; +module.exports = earcut; - /** - * [description] - * - * @name Phaser.Geom.Line#y1 - * @type {number} - * @since 3.0.0 - */ - this.y1 = y1; +/* +vertices is a flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...]. +holes is an array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). +dimensions is the number of coordinates per vertice in the input array (2 by default). +Each group of three vertice indices in the resulting array forms a triangle. + */ - /** - * [description] - * - * @name Phaser.Geom.Line#x2 - * @type {number} - * @since 3.0.0 - */ - this.x2 = x2; +function earcut(data, holeIndices, dim) { - /** - * [description] - * - * @name Phaser.Geom.Line#y2 - * @type {number} - * @since 3.0.0 - */ - this.y2 = y2; - }, + dim = dim || 2; - /** - * [description] - * - * @method Phaser.Geom.Line#getPoint - * @since 3.0.0 - * - * @param {[type]} position - [description] - * @param {[type]} output - [description] - * - * @return {Phaser.Geom.Point|object} A Point, or point-like object, containing the coordinates of the point around the ellipse. - */ - getPoint: function (position, output) - { - return GetPoint(this, position, output); - }, + var hasHoles = holeIndices && holeIndices.length, + outerLen = hasHoles ? holeIndices[0] * dim : data.length, + outerNode = linkedList(data, 0, outerLen, dim, true), + triangles = []; - /** - * [description] - * - * @method Phaser.Geom.Line#getPoints - * @since 3.0.0 - * - * @param {[type]} quantity - [description] - * @param {[type]} stepRate - [description] - * @param {[type]} output - [description] - * - * @return {[type]} [description] - */ - getPoints: function (quantity, stepRate, output) - { - return GetPoints(this, quantity, stepRate, output); - }, + if (!outerNode) return triangles; - /** - * [description] - * - * @method Phaser.Geom.Line#getRandomPoint - * @since 3.0.0 - * - * @param {[type]} point - [description] - * - * @return {[type]} [description] - */ - getRandomPoint: function (point) - { - return Random(this, point); - }, + var minX, minY, maxX, maxY, x, y, size; - /** - * [description] - * - * @method Phaser.Geom.Line#setTo - * @since 3.0.0 - * - * @param {[type]} x1 - [description] - * @param {[type]} y1 - [description] - * @param {[type]} x2 - [description] - * @param {[type]} y2 - [description] - * - * @return {Phaser.Geom.Line} This Line object. - */ - setTo: function (x1, y1, x2, y2) - { - if (x1 === undefined) { x1 = 0; } - if (y1 === undefined) { y1 = 0; } - if (x2 === undefined) { x2 = 0; } - if (y2 === undefined) { y2 = 0; } + if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim); - this.x1 = x1; - this.y1 = y1; + // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox + if (data.length > 80 * dim) { + minX = maxX = data[0]; + minY = maxY = data[1]; - this.x2 = x2; - this.y2 = y2; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Geom.Line#getPointA - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getPointA: function () - { - return { x: this.x1, y: this.y1 }; - }, - - /** - * [description] - * - * @method Phaser.Geom.Line#getPointB - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getPointB: function () - { - return { x: this.x2, y: this.y2 }; - }, - - /** - * The left position of the Line. - * - * @name Phaser.Geom.Line#left - * @type {number} - * @since 3.0.0 - */ - left: { - - get: function () - { - return Math.min(this.x1, this.x2); - }, - - set: function (value) - { - if (this.x1 <= this.x2) - { - this.x1 = value; - } - else - { - this.x2 = value; - } - } - - }, - - /** - * The right position of the Line. - * - * @name Phaser.Geom.Line#right - * @type {number} - * @since 3.0.0 - */ - right: { - - get: function () - { - return Math.max(this.x1, this.x2); - }, - - set: function (value) - { - if (this.x1 > this.x2) - { - this.x1 = value; - } - else - { - this.x2 = value; - } - } - - }, - - /** - * The top position of the Line. - * - * @name Phaser.Geom.Line#top - * @type {number} - * @since 3.0.0 - */ - top: { - - get: function () - { - return Math.min(this.y1, this.y2); - }, - - set: function (value) - { - if (this.y1 <= this.y2) - { - this.y1 = value; - } - else - { - this.y2 = value; - } - } - - }, - - /** - * The bottom position of the Line. - * - * @name Phaser.Geom.Line#bottom - * @type {number} - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return Math.max(this.y1, this.y2); - }, - - set: function (value) - { - if (this.y1 > this.y2) - { - this.y1 = value; - } - else - { - this.y2 = value; - } + for (var i = dim; i < outerLen; i += dim) { + x = data[i]; + y = data[i + 1]; + if (x < minX) minX = x; + if (y < minY) minY = y; + if (x > maxX) maxX = x; + if (y > maxY) maxY = y; } + // minX, minY and size are later used to transform coords into integers for z-order calculation + size = Math.max(maxX - minX, maxY - minY); } -}); + earcutLinked(outerNode, triangles, dim, minX, minY, size); -module.exports = Line; + return triangles; +} +// create a circular doubly linked list from polygon points in the specified winding order +function linkedList(data, start, end, dim, clockwise) { + var i, last; + + if (clockwise === (signedArea(data, start, end, dim) > 0)) { + for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last); + } else { + for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last); + } + + if (last && equals(last, last.next)) { + removeNode(last); + last = last.next; + } + + return last; +} + +// eliminate colinear or duplicate points +function filterPoints(start, end) { + if (!start) return start; + if (!end) end = start; + + var p = start, + again; + do { + again = false; + + if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) { + removeNode(p); + p = end = p.prev; + if (p === p.next) return null; + again = true; + + } else { + p = p.next; + } + } while (again || p !== end); + + return end; +} + +// main ear slicing loop which triangulates a polygon (given as a linked list) +function earcutLinked(ear, triangles, dim, minX, minY, size, pass) { + if (!ear) return; + + // interlink polygon nodes in z-order + if (!pass && size) indexCurve(ear, minX, minY, size); + + var stop = ear, + prev, next; + + // iterate through ears, slicing them one by one + while (ear.prev !== ear.next) { + prev = ear.prev; + next = ear.next; + + if (size ? isEarHashed(ear, minX, minY, size) : isEar(ear)) { + // cut off the triangle + triangles.push(prev.i / dim); + triangles.push(ear.i / dim); + triangles.push(next.i / dim); + + removeNode(ear); + + // skipping the next vertice leads to less sliver triangles + ear = next.next; + stop = next.next; + + continue; + } + + ear = next; + + // if we looped through the whole remaining polygon and can't find any more ears + if (ear === stop) { + // try filtering points and slicing again + if (!pass) { + earcutLinked(filterPoints(ear), triangles, dim, minX, minY, size, 1); + + // if this didn't work, try curing all small self-intersections locally + } else if (pass === 1) { + ear = cureLocalIntersections(ear, triangles, dim); + earcutLinked(ear, triangles, dim, minX, minY, size, 2); + + // as a last resort, try splitting the remaining polygon into two + } else if (pass === 2) { + splitEarcut(ear, triangles, dim, minX, minY, size); + } + + break; + } + } +} + +// check whether a polygon node forms a valid ear with adjacent nodes +function isEar(ear) { + var a = ear.prev, + b = ear, + c = ear.next; + + if (area(a, b, c) >= 0) return false; // reflex, can't be an ear + + // now make sure we don't have other points inside the potential ear + var p = ear.next.next; + + while (p !== ear.prev) { + if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && + area(p.prev, p, p.next) >= 0) return false; + p = p.next; + } + + return true; +} + +function isEarHashed(ear, minX, minY, size) { + var a = ear.prev, + b = ear, + c = ear.next; + + if (area(a, b, c) >= 0) return false; // reflex, can't be an ear + + // triangle bbox; min & max are calculated like this for speed + var minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : (b.x < c.x ? b.x : c.x), + minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : (b.y < c.y ? b.y : c.y), + maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : (b.x > c.x ? b.x : c.x), + maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : (b.y > c.y ? b.y : c.y); + + // z-order range for the current triangle bbox; + var minZ = zOrder(minTX, minTY, minX, minY, size), + maxZ = zOrder(maxTX, maxTY, minX, minY, size); + + // first look for points inside the triangle in increasing z-order + var p = ear.nextZ; + + while (p && p.z <= maxZ) { + if (p !== ear.prev && p !== ear.next && + pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && + area(p.prev, p, p.next) >= 0) return false; + p = p.nextZ; + } + + // then look for points in decreasing z-order + p = ear.prevZ; + + while (p && p.z >= minZ) { + if (p !== ear.prev && p !== ear.next && + pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && + area(p.prev, p, p.next) >= 0) return false; + p = p.prevZ; + } + + return true; +} + +// go through all polygon nodes and cure small local self-intersections +function cureLocalIntersections(start, triangles, dim) { + var p = start; + do { + var a = p.prev, + b = p.next.next; + + if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) { + + triangles.push(a.i / dim); + triangles.push(p.i / dim); + triangles.push(b.i / dim); + + // remove two nodes involved + removeNode(p); + removeNode(p.next); + + p = start = b; + } + p = p.next; + } while (p !== start); + + return p; +} + +// try splitting polygon into two and triangulate them independently +function splitEarcut(start, triangles, dim, minX, minY, size) { + // look for a valid diagonal that divides the polygon into two + var a = start; + do { + var b = a.next.next; + while (b !== a.prev) { + if (a.i !== b.i && isValidDiagonal(a, b)) { + // split the polygon in two by the diagonal + var c = splitPolygon(a, b); + + // filter colinear points around the cuts + a = filterPoints(a, a.next); + c = filterPoints(c, c.next); + + // run earcut on each half + earcutLinked(a, triangles, dim, minX, minY, size); + earcutLinked(c, triangles, dim, minX, minY, size); + return; + } + b = b.next; + } + a = a.next; + } while (a !== start); +} + +// link every hole into the outer loop, producing a single-ring polygon without holes +function eliminateHoles(data, holeIndices, outerNode, dim) { + var queue = [], + i, len, start, end, list; + + for (i = 0, len = holeIndices.length; i < len; i++) { + start = holeIndices[i] * dim; + end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; + list = linkedList(data, start, end, dim, false); + if (list === list.next) list.steiner = true; + queue.push(getLeftmost(list)); + } + + queue.sort(compareX); + + // process holes from left to right + for (i = 0; i < queue.length; i++) { + eliminateHole(queue[i], outerNode); + outerNode = filterPoints(outerNode, outerNode.next); + } + + return outerNode; +} + +function compareX(a, b) { + return a.x - b.x; +} + +// find a bridge between vertices that connects hole with an outer ring and and link it +function eliminateHole(hole, outerNode) { + outerNode = findHoleBridge(hole, outerNode); + if (outerNode) { + var b = splitPolygon(outerNode, hole); + filterPoints(b, b.next); + } +} + +// David Eberly's algorithm for finding a bridge between hole and outer polygon +function findHoleBridge(hole, outerNode) { + var p = outerNode, + hx = hole.x, + hy = hole.y, + qx = -Infinity, + m; + + // find a segment intersected by a ray from the hole's leftmost point to the left; + // segment's endpoint with lesser x will be potential connection point + do { + if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) { + var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y); + if (x <= hx && x > qx) { + qx = x; + if (x === hx) { + if (hy === p.y) return p; + if (hy === p.next.y) return p.next; + } + m = p.x < p.next.x ? p : p.next; + } + } + p = p.next; + } while (p !== outerNode); + + if (!m) return null; + + if (hx === qx) return m.prev; // hole touches outer segment; pick lower endpoint + + // look for points inside the triangle of hole point, segment intersection and endpoint; + // if there are no points found, we have a valid connection; + // otherwise choose the point of the minimum angle with the ray as connection point + + var stop = m, + mx = m.x, + my = m.y, + tanMin = Infinity, + tan; + + p = m.next; + + while (p !== stop) { + if (hx >= p.x && p.x >= mx && hx !== p.x && + pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) { + + tan = Math.abs(hy - p.y) / (hx - p.x); // tangential + + if ((tan < tanMin || (tan === tanMin && p.x > m.x)) && locallyInside(p, hole)) { + m = p; + tanMin = tan; + } + } + + p = p.next; + } + + return m; +} + +// interlink polygon nodes in z-order +function indexCurve(start, minX, minY, size) { + var p = start; + do { + if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, size); + p.prevZ = p.prev; + p.nextZ = p.next; + p = p.next; + } while (p !== start); + + p.prevZ.nextZ = null; + p.prevZ = null; + + sortLinked(p); +} + +// Simon Tatham's linked list merge sort algorithm +// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html +function sortLinked(list) { + var i, p, q, e, tail, numMerges, pSize, qSize, + inSize = 1; + + do { + p = list; + list = null; + tail = null; + numMerges = 0; + + while (p) { + numMerges++; + q = p; + pSize = 0; + for (i = 0; i < inSize; i++) { + pSize++; + q = q.nextZ; + if (!q) break; + } + qSize = inSize; + + while (pSize > 0 || (qSize > 0 && q)) { + + if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) { + e = p; + p = p.nextZ; + pSize--; + } else { + e = q; + q = q.nextZ; + qSize--; + } + + if (tail) tail.nextZ = e; + else list = e; + + e.prevZ = tail; + tail = e; + } + + p = q; + } + + tail.nextZ = null; + inSize *= 2; + + } while (numMerges > 1); + + return list; +} + +// z-order of a point given coords and size of the data bounding box +function zOrder(x, y, minX, minY, size) { + // coords are transformed into non-negative 15-bit integer range + x = 32767 * (x - minX) / size; + y = 32767 * (y - minY) / size; + + x = (x | (x << 8)) & 0x00FF00FF; + x = (x | (x << 4)) & 0x0F0F0F0F; + x = (x | (x << 2)) & 0x33333333; + x = (x | (x << 1)) & 0x55555555; + + y = (y | (y << 8)) & 0x00FF00FF; + y = (y | (y << 4)) & 0x0F0F0F0F; + y = (y | (y << 2)) & 0x33333333; + y = (y | (y << 1)) & 0x55555555; + + return x | (y << 1); +} + +// find the leftmost node of a polygon ring +function getLeftmost(start) { + var p = start, + leftmost = start; + do { + if (p.x < leftmost.x) leftmost = p; + p = p.next; + } while (p !== start); + + return leftmost; +} + +// check if a point lies within a convex triangle +function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) { + return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && + (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && + (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0; +} + +// check if a diagonal between two polygon nodes is valid (lies in polygon interior) +function isValidDiagonal(a, b) { + return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && + locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b); +} + +// signed area of a triangle +function area(p, q, r) { + return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); +} + +// check if two points are equal +function equals(p1, p2) { + return p1.x === p2.x && p1.y === p2.y; +} + +// check if two segments intersect +function intersects(p1, q1, p2, q2) { + if ((equals(p1, q1) && equals(p2, q2)) || + (equals(p1, q2) && equals(p2, q1))) return true; + return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 && + area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0; +} + +// check if a polygon diagonal intersects any polygon segments +function intersectsPolygon(a, b) { + var p = a; + do { + if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && + intersects(p, p.next, a, b)) return true; + p = p.next; + } while (p !== a); + + return false; +} + +// check if a polygon diagonal is locally inside the polygon +function locallyInside(a, b) { + return area(a.prev, a, a.next) < 0 ? + area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : + area(a, b, a.prev) < 0 || area(a, a.next, b) < 0; +} + +// check if the middle point of a polygon diagonal is inside the polygon +function middleInside(a, b) { + var p = a, + inside = false, + px = (a.x + b.x) / 2, + py = (a.y + b.y) / 2; + do { + if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y && + (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)) + inside = !inside; + p = p.next; + } while (p !== a); + + return inside; +} + +// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two; +// if one belongs to the outer ring and another to a hole, it merges it into a single ring +function splitPolygon(a, b) { + var a2 = new Node(a.i, a.x, a.y), + b2 = new Node(b.i, b.x, b.y), + an = a.next, + bp = b.prev; + + a.next = b; + b.prev = a; + + a2.next = an; + an.prev = a2; + + b2.next = a2; + a2.prev = b2; + + bp.next = b2; + b2.prev = bp; + + return b2; +} + +// create a node and optionally link it with previous one (in a circular doubly linked list) +function insertNode(i, x, y, last) { + var p = new Node(i, x, y); + + if (!last) { + p.prev = p; + p.next = p; + + } else { + p.next = last.next; + p.prev = last; + last.next.prev = p; + last.next = p; + } + return p; +} + +function removeNode(p) { + p.next.prev = p.prev; + p.prev.next = p.next; + + if (p.prevZ) p.prevZ.nextZ = p.nextZ; + if (p.nextZ) p.nextZ.prevZ = p.prevZ; +} + +function Node(i, x, y) { + // vertice index in coordinates array + this.i = i; + + // vertex coordinates + this.x = x; + this.y = y; + + // previous and next vertice nodes in a polygon ring + this.prev = null; + this.next = null; + + // z-order curve value + this.z = null; + + // previous and next nodes in z-order + this.prevZ = null; + this.nextZ = null; + + // indicates whether this is a steiner point + this.steiner = false; +} + +// return a percentage difference between the polygon area and its triangulation area; +// used to verify correctness of triangulation +earcut.deviation = function (data, holeIndices, dim, triangles) { + var hasHoles = holeIndices && holeIndices.length; + var outerLen = hasHoles ? holeIndices[0] * dim : data.length; + + var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim)); + if (hasHoles) { + for (var i = 0, len = holeIndices.length; i < len; i++) { + var start = holeIndices[i] * dim; + var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; + polygonArea -= Math.abs(signedArea(data, start, end, dim)); + } + } + + var trianglesArea = 0; + for (i = 0; i < triangles.length; i += 3) { + var a = triangles[i] * dim; + var b = triangles[i + 1] * dim; + var c = triangles[i + 2] * dim; + trianglesArea += Math.abs( + (data[a] - data[c]) * (data[b + 1] - data[a + 1]) - + (data[a] - data[b]) * (data[c + 1] - data[a + 1])); + } + + return polygonArea === 0 && trianglesArea === 0 ? 0 : + Math.abs((trianglesArea - polygonArea) / polygonArea); +}; + +function signedArea(data, start, end, dim) { + var sum = 0; + for (var i = start, j = end - dim; i < end; i += dim) { + sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]); + j = i; + } + return sum; +} + +// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts +earcut.flatten = function (data) { + var dim = data[0][0].length, + result = {vertices: [], holes: [], dimensions: dim}, + holeIndex = 0; + + for (var i = 0; i < data.length; i++) { + for (var j = 0; j < data[i].length; j++) { + for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]); + } + if (i > 0) { + holeIndex += data[i - 1].length; + result.holes.push(holeIndex); + } + } + return result; +}; /***/ }), /* 302 */ @@ -56073,7 +64065,7767 @@ module.exports = Line; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); +var CanvasPool = __webpack_require__(23); + +/** + * Determines the canvas features of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.canvasFeatures` from within any Scene. + * + * @name Phaser.Device.CanvasFeatures + * @since 3.0.0 + * + * @type {object} + * @property {boolean} supportInverseAlpha - Set to true if the browser supports inversed alpha. + * @property {boolean} supportNewBlendModes - Set to true if the browser supports new canvas blend modes. + */ +var CanvasFeatures = { + + supportInverseAlpha: false, + supportNewBlendModes: false + +}; + +function checkBlendMode () +{ + var pngHead = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/'; + var pngEnd = 'AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg=='; + + var magenta = new Image(); + + magenta.onload = function () + { + var yellow = new Image(); + + yellow.onload = function () + { + var canvas = CanvasPool.create(yellow, 6, 1); + var context = canvas.getContext('2d'); + + context.globalCompositeOperation = 'multiply'; + + context.drawImage(magenta, 0, 0); + context.drawImage(yellow, 2, 0); + + if (!context.getImageData(2, 0, 1, 1)) + { + return false; + } + + var data = context.getImageData(2, 0, 1, 1).data; + + CanvasPool.remove(yellow); + + CanvasFeatures.supportNewBlendModes = (data[0] === 255 && data[1] === 0 && data[2] === 0); + }; + + yellow.src = pngHead + '/wCKxvRF' + pngEnd; + }; + + magenta.src = pngHead + 'AP804Oa6' + pngEnd; + + return false; +} + +function checkInverseAlpha () +{ + var canvas = CanvasPool.create(this, 2, 1); + var context = canvas.getContext('2d'); + + context.fillStyle = 'rgba(10, 20, 30, 0.5)'; + + // Draw a single pixel + context.fillRect(0, 0, 1, 1); + + // Get the color values + var s1 = context.getImageData(0, 0, 1, 1); + + if (s1 === null) + { + return false; + } + + // Plot them to x2 + context.putImageData(s1, 1, 0); + + // Get those values + var s2 = context.getImageData(1, 0, 1, 1); + + // Compare and return + return (s2.data[0] === s1.data[0] && s2.data[1] === s1.data[1] && s2.data[2] === s1.data[2] && s2.data[3] === s1.data[3]); +} + +function init () +{ + if (document !== undefined) + { + CanvasFeatures.supportNewBlendModes = checkBlendMode(); + CanvasFeatures.supportInverseAlpha = checkInverseAlpha(); + } + + return CanvasFeatures; +} + +module.exports = init(); + + +/***/ }), +/* 303 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Plugins + */ +var Plugins = { + + /** + * These are the Global Managers that are created by the Phaser.Game instance. + * They are referenced from Scene.Systems so that plugins can use them. + * + * @name Phaser.Plugins.Global + * @type {array} + * @since 3.0.0 + */ + Global: [ + + 'anims', + 'cache', + 'registry', + 'sound', + 'textures' + + ], + + /** + * These are the core plugins that are installed into every Scene.Systems instance, no matter what. + * They are optionally exposed in the Scene as well (see the InjectionMap for details) + * + * They are created in the order in which they appear in this array and EventEmitter is always first. + * + * @name Phaser.Plugins.CoreScene + * @type {array} + * @since 3.0.0 + */ + CoreScene: [ + + 'EventEmitter', + + 'CameraManager', + 'GameObjectCreator', + 'GameObjectFactory', + 'ScenePlugin', + 'DisplayList', + 'UpdateList' + + ], + + /** + * These plugins are created in Scene.Systems in addition to the CoreScenePlugins. + * + * You can elect not to have these plugins by either creating a DefaultPlugins object as part + * of the Game Config, by creating a Plugins object as part of a Scene Config, or by modifying this array + * and building your own bundle. + * + * They are optionally exposed in the Scene as well (see the InjectionMap for details) + * + * They are always created in the order in which they appear in the array. + * + * @name Phaser.Plugins.DefaultScene + * @type {array} + * @since 3.0.0 + */ + DefaultScene: [ + + 'CameraManager3D', + 'Clock', + 'DataManagerPlugin', + 'InputPlugin', + 'Loader', + 'TweenManager', + 'LightsPlugin' + + ] + +}; + +/* + * "Sometimes, the elegant implementation is just a function. + * Not a method. Not a class. Not a framework. Just a function." + * -- John Carmack + */ + +module.exports = Plugins; + + +/***/ }), +/* 304 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var NOOP = __webpack_require__(3); + +/** + * @classdesc + * Abstracts away the use of RAF or setTimeOut for the core game update loop. + * This is invoked automatically by the Phaser.Game instance. + * + * @class RequestAnimationFrame + * @memberOf Phaser.DOM + * @constructor + * @since 3.0.0 + */ +var RequestAnimationFrame = new Class({ + + initialize: + + function RequestAnimationFrame () + { + /** + * True if RequestAnimationFrame is running, otherwise false. + * + * @name Phaser.DOM.RequestAnimationFrame#isRunning + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isRunning = false; + + /** + * The callback to be invoked each step. + * + * @name Phaser.DOM.RequestAnimationFrame#callback + * @type {FrameRequestCallback} + * @since 3.0.0 + */ + this.callback = NOOP; + + /** + * The most recent timestamp. Either a DOMHighResTimeStamp under RAF or `Date.now` under SetTimeout. + * + * @name Phaser.DOM.RequestAnimationFrame#tick + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.tick = 0; + + /** + * True if the step is using setTimeout instead of RAF. + * + * @name Phaser.DOM.RequestAnimationFrame#isSetTimeOut + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isSetTimeOut = false; + + /** + * The setTimeout or RAF callback ID used when canceling them. + * + * @name Phaser.DOM.RequestAnimationFrame#timeOutID + * @type {?number} + * @default null + * @since 3.0.0 + */ + this.timeOutID = null; + + /** + * The previous time the step was called. + * + * @name Phaser.DOM.RequestAnimationFrame#lastTime + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.lastTime = 0; + + var _this = this; + + /** + * The RAF step function. + * Updates the local tick value, invokes the callback and schedules another call to requestAnimationFrame. + * + * @name Phaser.DOM.RequestAnimationFrame#step + * @type {FrameRequestCallback} + * @since 3.0.0 + */ + this.step = function step (timestamp) + { + // DOMHighResTimeStamp + _this.lastTime = _this.tick; + + _this.tick = timestamp; + + _this.callback(timestamp); + + _this.timeOutID = window.requestAnimationFrame(step); + }; + + /** + * The SetTimeout step function. + * Updates the local tick value, invokes the callback and schedules another call to setTimeout. + * + * @name Phaser.DOM.RequestAnimationFrame#stepTimeout + * @type {function} + * @since 3.0.0 + */ + this.stepTimeout = function stepTimeout () + { + var d = Date.now(); + + var delay = Math.max(16 + _this.lastTime - d, 0); + + _this.lastTime = _this.tick; + + _this.tick = d; + + _this.callback(d); + + _this.timeOutID = window.setTimeout(stepTimeout, delay); + }; + }, + + /** + * Starts the requestAnimationFrame or setTimeout process running. + * + * @method Phaser.DOM.RequestAnimationFrame#start + * @since 3.0.0 + * + * @param {FrameRequestCallback} callback - The callback to invoke each step. + * @param {boolean} forceSetTimeOut - Should it use SetTimeout, even if RAF is available? + */ + start: function (callback, forceSetTimeOut) + { + if (this.isRunning) + { + return; + } + + this.callback = callback; + + this.isSetTimeOut = forceSetTimeOut; + + this.isRunning = true; + + this.timeOutID = (forceSetTimeOut) ? window.setTimeout(this.stepTimeout, 0) : window.requestAnimationFrame(this.step); + }, + + /** + * Stops the requestAnimationFrame or setTimeout from running. + * + * @method Phaser.DOM.RequestAnimationFrame#stop + * @since 3.0.0 + */ + stop: function () + { + this.isRunning = false; + + if (this.isSetTimeOut) + { + clearTimeout(this.timeOutID); + } + else + { + window.cancelAnimationFrame(this.timeOutID); + } + }, + + /** + * Stops the step from running and clears the callback reference. + * + * @method Phaser.DOM.RequestAnimationFrame#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.stop(); + + this.callback = NOOP; + } + +}); + +module.exports = RequestAnimationFrame; + + +/***/ }), +/* 305 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Attempts to remove the element from its parentNode in the DOM. + * + * @function Phaser.DOM.RemoveFromDOM + * @since 3.0.0 + * + * @param {HTMLElement} element - The DOM element to remove from its parent node. + */ +var RemoveFromDOM = function (element) +{ + if (element.parentNode) + { + element.parentNode.removeChild(element); + } +}; + +module.exports = RemoveFromDOM; + + +/***/ }), +/* 306 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes the given data string and parses it as XML. + * First tries to use the window.DOMParser and reverts to the Microsoft.XMLDOM if that fails. + * The parsed XML object is returned, or `null` if there was an error while parsing the data. + * + * @function Phaser.DOM.ParseXML + * @since 3.0.0 + * + * @param {string} data - The XML source stored in a string. + * + * @return {?(DOMParser|ActiveXObject)} The parsed XML data, or `null` if the data could not be parsed. + */ +var ParseXML = function (data) +{ + var xml = ''; + + try + { + if (window['DOMParser']) + { + var domparser = new DOMParser(); + xml = domparser.parseFromString(data, 'text/xml'); + } + else + { + xml = new ActiveXObject('Microsoft.XMLDOM'); + xml.loadXML(data); + } + } + catch (e) + { + xml = null; + } + + if (!xml || !xml.documentElement || xml.getElementsByTagName('parsererror').length) + { + return null; + } + else + { + return xml; + } +}; + +module.exports = ParseXML; + + +/***/ }), +/* 307 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var OS = __webpack_require__(76); + +/** + * @callback ContentLoadedCallback + */ + +/** + * Inspects the readyState of the document. If the document is already complete then it invokes the given callback. + * If not complete it sets up several event listeners such as `deviceready`, and once those fire, it invokes the callback. + * Called automatically by the Phaser.Game instance. Should not usually be accessed directly. + * + * @function Phaser.DOM.DOMContentLoaded + * @since 3.0.0 + * + * @param {ContentLoadedCallback} callback - The callback to be invoked when the device is ready and the DOM content is loaded. + */ +var DOMContentLoaded = function (callback) +{ + if (document.readyState === 'complete' || document.readyState === 'interactive') + { + callback(); + + return; + } + + var check = function () + { + document.removeEventListener('deviceready', check, true); + document.removeEventListener('DOMContentLoaded', check, true); + window.removeEventListener('load', check, true); + + callback(); + }; + + if (!document.body) + { + window.setTimeout(check, 20); + } + else if (OS.cordova && !OS.cocoonJS) + { + // Ref. http://docs.phonegap.com/en/3.5.0/cordova_events_events.md.html#deviceready + document.addEventListener('deviceready', check, false); + } + else + { + document.addEventListener('DOMContentLoaded', check, true); + window.addEventListener('load', check, true); + } +}; + +module.exports = DOMContentLoaded; + + +/***/ }), +/* 308 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Between + * @since 3.0.0 + * + * @param {integer} min - [description] + * @param {integer} max - [description] + * + * @return {integer} [description] + */ +var Between = function (min, max) +{ + return Math.floor(Math.random() * (max - min + 1) + min); +}; + +module.exports = Between; + + +/***/ }), +/* 309 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetColor = __webpack_require__(155); + +/** + * Converts an HSV (hue, saturation and value) color value to RGB. + * Conversion formula from http://en.wikipedia.org/wiki/HSL_color_space. + * Assumes HSV values are contained in the set [0, 1]. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * + * @function Phaser.Display.Color.HSVToRGB + * @since 3.0.0 + * + * @param {number} h - The hue, in the range 0 - 1. + * @param {number} s - The saturation, in the range 0 - 1. + * @param {number} v - The value, in the range 0 - 1. + * + * @return {ColorObject} An object with the red, green and blue values set in the r, g and b properties. + */ +var HSVToRGB = function (h, s, v) +{ + if (s === undefined) { s = 1; } + if (v === undefined) { v = 1; } + + var i = Math.floor(h * 6); + var f = h * 6 - i; + + var p = Math.floor((v * (1 - s)) * 255); + var q = Math.floor((v * (1 - f * s)) * 255); + var t = Math.floor((v * (1 - (1 - f) * s)) * 255); + + v = Math.floor(v *= 255); + + var output = { r: v, g: v, b: v, color: 0 }; + + var r = i % 6; + + if (r === 0) + { + output.g = t; + output.b = p; + } + else if (r === 1) + { + output.r = q; + output.b = p; + } + else if (r === 2) + { + output.r = p; + output.b = t; + } + else if (r === 3) + { + output.r = p; + output.g = q; + } + else if (r === 4) + { + output.r = t; + output.g = p; + } + else if (r === 5) + { + output.g = p; + output.b = q; + } + + output.color = GetColor(output.r, output.g, output.b); + + return output; +}; + +module.exports = HSVToRGB; + + +/***/ }), +/* 310 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(module) {/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts a hue to an RGB color. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * + * @function Phaser.Display.Color.HueToComponent + * @since 3.0.0 + * + * @param {number} p + * @param {number} q + * @param {number} t + * + * @return {number} The combined color value. + */ +var HueToComponent = function (p, q, t) +{ + if (t < 0) + { + t += 1; + } + + if (t > 1) + { + t -= 1; + } + + if (t < 1 / 6) + { + return p + (q - p) * 6 * t; + } + + if (t < 1 / 2) + { + return q; + } + + if (t < 2 / 3) + { + return p + (q - p) * (2 / 3 - t) * 6; + } + + return p; +}; + +module.export = HueToComponent; + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(831)(module))) + +/***/ }), +/* 311 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns a string containing a hex representation of the given color component. + * + * @function Phaser.Display.Color.ComponentToHex + * @since 3.0.0 + * + * @param {integer} color - The color channel to get the hex value for, must be a value between 0 and 255. + * + * @return {string} A string of length 2 characters, i.e. 255 = ff, 100 = 64. + */ +var ComponentToHex = function (color) +{ + var hex = color.toString(16); + + return (hex.length === 1) ? '0' + hex : hex; +}; + +module.exports = ComponentToHex; + + +/***/ }), +/* 312 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} InputColorObject + * + * @property {number} [r] - The red color value in the range 0 to 255. + * @property {number} [g] - The green color value in the range 0 to 255. + * @property {number} [b] - The blue color value in the range 0 to 255. + * @property {number} [a] - The alpha color value in the range 0 to 255. + */ + +/** + * @typedef {Object} ColorObject + * @property {number} r - The red color value in the range 0 to 255. + * @property {number} g - The green color value in the range 0 to 255. + * @property {number} b - The blue color value in the range 0 to 255. + * @property {number} a - The alpha color value in the range 0 to 255. + */ + +/** + * @namespace Phaser.Display.Color + */ + +var Color = __webpack_require__(41); + +Color.ColorToRGBA = __webpack_require__(833); +Color.ComponentToHex = __webpack_require__(311); +Color.GetColor = __webpack_require__(155); +Color.GetColor32 = __webpack_require__(335); +Color.HexStringToColor = __webpack_require__(336); +Color.HSLToColor = __webpack_require__(832); +Color.HSVColorWheel = __webpack_require__(830); +Color.HSVToRGB = __webpack_require__(309); +Color.HueToComponent = __webpack_require__(310); +Color.IntegerToColor = __webpack_require__(334); +Color.IntegerToRGB = __webpack_require__(333); +Color.Interpolate = __webpack_require__(829); +Color.ObjectToColor = __webpack_require__(332); +Color.RandomRGB = __webpack_require__(828); +Color.RGBStringToColor = __webpack_require__(331); +Color.RGBToHSV = __webpack_require__(827); +Color.RGBToString = __webpack_require__(826); +Color.ValueToColor = __webpack_require__(156); + +module.exports = Color; + + +/***/ }), +/* 313 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Canvas.CanvasInterpolation + * @since 3.0.0 + */ +var CanvasInterpolation = { + + /** + * Sets the CSS image-rendering property on the given canvas to be 'crisp' (aka 'optimize contrast' on webkit). + * + * @function Phaser.Display.Canvas.CanvasInterpolation.setCrisp + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The canvas object to have the style set on. + * + * @return {HTMLCanvasElement} The canvas. + */ + setCrisp: function (canvas) + { + var types = [ 'optimizeSpeed', 'crisp-edges', '-moz-crisp-edges', '-webkit-optimize-contrast', 'optimize-contrast', 'pixelated' ]; + + types.forEach(function (type) + { + canvas.style['image-rendering'] = type; + }); + + canvas.style.msInterpolationMode = 'nearest-neighbor'; + + return canvas; + }, + + /** + * Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto'). + * + * @function Phaser.Display.Canvas.CanvasInterpolation.setBicubic + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The canvas object to have the style set on. + * + * @return {HTMLCanvasElement} The canvas. + */ + setBicubic: function (canvas) + { + canvas.style['image-rendering'] = 'auto'; + canvas.style.msInterpolationMode = 'bicubic'; + + return canvas; + } + +}; + +module.exports = CanvasInterpolation; + + +/***/ }), +/* 314 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var CatmullRom = __webpack_require__(149); +var Class = __webpack_require__(0); +var Curve = __webpack_require__(56); +var Vector2 = __webpack_require__(6); + +/** + * @classdesc + * [description] + * + * @class SplineCurve + * @extends Phaser.Curves.Curve + * @memberOf Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2[]} [points] - [description] + */ +var SplineCurve = new Class({ + + Extends: Curve, + + initialize: + + function SplineCurve (points) + { + if (points === undefined) { points = []; } + + Curve.call(this, 'SplineCurve'); + + /** + * [description] + * + * @name Phaser.Curves.SplineCurve#points + * @type {Phaser.Math.Vector2[]} + * @default [] + * @since 3.0.0 + */ + this.points = []; + + this.addPoints(points); + }, + + /** + * [description] + * + * @method Phaser.Curves.SplineCurve#addPoints + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2[]} points - [description] + * + * @return {Phaser.Curves.SplineCurve} This curve object. + */ + addPoints: function (points) + { + for (var i = 0; i < points.length; i++) + { + var p = new Vector2(); + + if (typeof points[i] === 'number') + { + p.x = points[i]; + p.y = points[i + 1]; + i++; + } + else if (Array.isArray(points[i])) + { + // An array of arrays? + p.x = points[i][0]; + p.y = points[i][1]; + } + else + { + p.x = points[i].x; + p.y = points[i].y; + } + + this.points.push(p); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Curves.SplineCurve#addPoint + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + addPoint: function (x, y) + { + var vec = new Vector2(x, y); + + this.points.push(vec); + + return vec; + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.SplineCurve#getStartPoint + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.points[0]); + }, + + /** + * [description] + * + * @method Phaser.Curves.SplineCurve#getResolution + * @since 3.0.0 + * + * @param {number} divisions - [description] + * + * @return {number} [description] + */ + getResolution: function (divisions) + { + return divisions * this.points.length; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.SplineCurve#getPoint + * @since 3.0.0 + * + * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var points = this.points; + + var point = (points.length - 1) * t; + + var intPoint = Math.floor(point); + + var weight = point - intPoint; + + var p0 = points[(intPoint === 0) ? intPoint : intPoint - 1]; + var p1 = points[intPoint]; + var p2 = points[(intPoint > points.length - 2) ? points.length - 1 : intPoint + 1]; + var p3 = points[(intPoint > points.length - 3) ? points.length - 1 : intPoint + 2]; + + return out.set(CatmullRom(weight, p0.x, p1.x, p2.x, p3.x), CatmullRom(weight, p0.y, p1.y, p2.y, p3.y)); + }, + + /** + * [description] + * + * @method Phaser.Curves.SplineCurve#toJSON + * @since 3.0.0 + * + * @return {JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + var points = []; + + for (var i = 0; i < this.points.length; i++) + { + points.push(this.points[i].x); + points.push(this.points[i].y); + } + + return { + type: this.type, + points: points + }; + } + +}); + +/** + * [description] + * + * @function Phaser.Curves.SplineCurve.fromJSON + * @since 3.0.0 + * + * @param {JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.SplineCurve} [description] + */ +SplineCurve.fromJSON = function (data) +{ + return new SplineCurve(data.points); +}; + +module.exports = SplineCurve; + + +/***/ }), +/* 315 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +function P0 (t, p) +{ + var k = 1 - t; + + return k * k * p; +} + +function P1 (t, p) +{ + return 2 * (1 - t) * t * p; +} + +function P2 (t, p) +{ + return t * t * p; +} + +// p0 = start point +// p1 = control point 1 +// p2 = end point + +// https://github.com/mrdoob/three.js/blob/master/src/extras/core/Interpolations.js + +/** + * [description] + * + * @function Phaser.Math.Interpolation.QuadraticBezier + * @since 3.2.0 + * + * @param {float} t - [description] + * @param {number} p0 - [description] + * @param {number} p1 - [description] + * @param {number} p2 - [description] + * + * @return {number} [description] + */ +var QuadraticBezierInterpolation = function (t, p0, p1, p2) +{ + return P0(t, p0) + P1(t, p1) + P2(t, p2); +}; + +module.exports = QuadraticBezierInterpolation; + + +/***/ }), +/* 316 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Curve = __webpack_require__(56); +var QuadraticBezierInterpolation = __webpack_require__(315); +var Vector2 = __webpack_require__(6); + +/** + * @classdesc + * [description] + * + * @class QuadraticBezier + * @extends Phaser.Curves.Curve + * @memberOf Phaser.Curves + * @constructor + * @since 3.2.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector2[])} p0 - Start point, or an array of point pairs. + * @param {Phaser.Math.Vector2} p1 - Control Point 1. + * @param {Phaser.Math.Vector2} p2 - Control Point 2. + */ +var QuadraticBezier = new Class({ + + Extends: Curve, + + initialize: + + function QuadraticBezier (p0, p1, p2) + { + Curve.call(this, 'QuadraticBezier'); + + if (Array.isArray(p0)) + { + p2 = new Vector2(p0[4], p0[5]); + p1 = new Vector2(p0[2], p0[3]); + p0 = new Vector2(p0[0], p0[1]); + } + + /** + * [description] + * + * @name Phaser.Curves.QuadraticBezier#p0 + * @type {Phaser.Math.Vector2} + * @since 3.2.0 + */ + this.p0 = p0; + + /** + * [description] + * + * @name Phaser.Curves.QuadraticBezier#p1 + * @type {Phaser.Math.Vector2} + * @since 3.2.0 + */ + this.p1 = p1; + + /** + * [description] + * + * @name Phaser.Curves.QuadraticBezier#p2 + * @type {Phaser.Math.Vector2} + * @since 3.2.0 + */ + this.p2 = p2; + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.QuadraticBezier#getStartPoint + * @since 3.2.0 + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.p0); + }, + + /** + * [description] + * + * @method Phaser.Curves.QuadraticBezier#getResolution + * @since 3.2.0 + * + * @param {number} divisions - [description] + * + * @return {number} [description] + */ + getResolution: function (divisions) + { + return divisions; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.QuadraticBezier#getPoint + * @since 3.2.0 + * + * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var p0 = this.p0; + var p1 = this.p1; + var p2 = this.p2; + + return out.set( + QuadraticBezierInterpolation(t, p0.x, p1.x, p2.x), + QuadraticBezierInterpolation(t, p0.y, p1.y, p2.y) + ); + }, + + /** + * [description] + * + * @method Phaser.Curves.QuadraticBezier#draw + * @since 3.2.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - [description] + * @param {integer} [pointsTotal=32] - [description] + * + * @return {Phaser.GameObjects.Graphics} [description] + */ + draw: function (graphics, pointsTotal) + { + if (pointsTotal === undefined) { pointsTotal = 32; } + + var points = this.getPoints(pointsTotal); + + graphics.beginPath(); + graphics.moveTo(this.p0.x, this.p0.y); + + for (var i = 1; i < points.length; i++) + { + graphics.lineTo(points[i].x, points[i].y); + } + + graphics.strokePath(); + + // So you can chain graphics calls + return graphics; + }, + + /** + * [description] + * + * @method Phaser.Curves.QuadraticBezier#toJSON + * @since 3.2.0 + * + * @return {JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + points: [ + this.p0.x, this.p0.y, + this.p1.x, this.p1.y, + this.p2.x, this.p2.y + ] + }; + } + +}); + +/** + * [description] + * + * @function Phaser.Curves.QuadraticBezier.fromJSON + * @since 3.2.0 + * + * @param {JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.QuadraticBezier} [description] + */ +QuadraticBezier.fromJSON = function (data) +{ + var points = data.points; + + var p0 = new Vector2(points[0], points[1]); + var p1 = new Vector2(points[2], points[3]); + var p2 = new Vector2(points[4], points[5]); + + return new QuadraticBezier(p0, p1, p2); +}; + +module.exports = QuadraticBezier; + + +/***/ }), +/* 317 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var Class = __webpack_require__(0); +var Curve = __webpack_require__(56); +var FromPoints = __webpack_require__(150); +var Rectangle = __webpack_require__(10); +var Vector2 = __webpack_require__(6); + +var tmpVec2 = new Vector2(); + +/** + * @classdesc + * [description] + * + * @class LineCurve + * @extends Phaser.Curves.Curve + * @memberOf Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} p0 - [description] + * @param {Phaser.Math.Vector2} p1 - [description] + */ +var LineCurve = new Class({ + + Extends: Curve, + + initialize: + + // vec2s or array + function LineCurve (p0, p1) + { + Curve.call(this, 'LineCurve'); + + if (Array.isArray(p0)) + { + p1 = new Vector2(p0[2], p0[3]); + p0 = new Vector2(p0[0], p0[1]); + } + + /** + * [description] + * + * @name Phaser.Curves.LineCurve#p0 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p0 = p0; + + /** + * [description] + * + * @property Phaser.Curves.LineCurve#p1 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p1 = p1; + }, + + /** + * Returns a Rectangle where the position and dimensions match the bounds of this Curve. + * + * @method Phaser.Curves.LineCurve#getBounds + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} [out] - A Rectangle object to store the bounds in. If not given a new Rectangle will be created. + * + * @return {Phaser.Geom.Rectangle} A Rectangle object holding the bounds of this curve. If `out` was given it will be this object. + */ + getBounds: function (out) + { + if (out === undefined) { out = new Rectangle(); } + + return FromPoints([ this.p0, this.p1 ], out); + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.LineCurve#getStartPoint + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.p0); + }, + + /** + * [description] + * + * @method Phaser.Curves.LineCurve#getResolution + * @since 3.0.0 + * + * @return {integer} [description] + */ + getResolution: function () + { + return 1; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.LineCurve#getPoint + * @since 3.0.0 + * + * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + if (t === 1) + { + return out.copy(this.p1); + } + + out.copy(this.p1).subtract(this.p0).scale(t).add(this.p0); + + return out; + }, + + // Line curve is linear, so we can overwrite default getPointAt + + /** + * [description] + * + * @method Phaser.Curves.LineCurve#getPointAt + * @since 3.0.0 + * + * @param {float} u - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPointAt: function (u, out) + { + return this.getPoint(u, out); + }, + + /** + * [description] + * + * @method Phaser.Curves.LineCurve#getTangent + * @since 3.0.0 + * + * @return {Phaser.Math.Vector2} [description] + */ + getTangent: function () + { + var tangent = tmpVec2.copy(this.p1).subtract(this.p0); + + return tangent.normalize(); + }, + + // Override default Curve.draw because this is better than calling getPoints on a line! + + /** + * Draws this curve on the given Graphics object. + * + * The curve is drawn using `Graphics.lineBetween` so will be drawn at whatever the present Graphics line color is. + * The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it. + * + * @method Phaser.Curves.LineCurve#draw + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - The Graphics instance onto which this curve will be drawn. + * + * @return {Phaser.GameObjects.Graphics} The Graphics object to which the curve was drawn. + */ + draw: function (graphics) + { + graphics.lineBetween(this.p0.x, this.p0.y, this.p1.x, this.p1.y); + + // So you can chain graphics calls + return graphics; + }, + + /** + * [description] + * + * @method Phaser.Curves.LineCurve#toJSON + * @since 3.0.0 + * + * @return {JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + points: [ + this.p0.x, this.p0.y, + this.p1.x, this.p1.y + ] + }; + } + +}); + +/** + * [description] + * + * @function Phaser.Curves.LineCurve.fromJSON + * @since 3.0.0 + * + * @param {JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.LineCurve} [description] + */ +LineCurve.fromJSON = function (data) +{ + var points = data.points; + + var p0 = new Vector2(points[0], points[1]); + var p1 = new Vector2(points[2], points[3]); + + return new LineCurve(p0, p1); +}; + +module.exports = LineCurve; + + +/***/ }), +/* 318 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(16); + +/** + * [description] + * + * @function Phaser.Math.RadToDeg + * @since 3.0.0 + * + * @param {float} radians - [description] + * + * @return {integer} [description] + */ +var RadToDeg = function (radians) +{ + return radians * CONST.RAD_TO_DEG; +}; + +module.exports = RadToDeg; + + +/***/ }), +/* 319 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var Class = __webpack_require__(0); +var Curve = __webpack_require__(56); +var DegToRad = __webpack_require__(42); +var GetValue = __webpack_require__(5); +var RadToDeg = __webpack_require__(318); +var Vector2 = __webpack_require__(6); + +/** + * @typedef {object} JSONEllipseCurve + * + * @property {string} type - The of the curve. + * @property {number} x - [description] + * @property {number} y - [description] + * @property {number} xRadius - The horizontal radius of ellipse. + * @property {number} yRadius - The vertical radius of ellipse. + * @property {integer} startAngle - The start angle of ellipse. + * @property {integer} endAngle - The end angle of ellipse. + * @property {boolean} clockwise - The clockwise of ellipse. + * @property {integer} rotation - The rotation of ellipse. + */ + +/** + * @classdesc + * [description] + * + * @class EllipseCurve + * @extends Phaser.Curves.Curve + * @memberOf Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - [description] + * @param {number} [y=0] - [description] + * @param {number} [xRadius=0] - [description] + * @param {number} [yRadius=0] - [description] + * @param {number} [startAngle=0] - [description] + * @param {number} [endAngle=360] - [description] + * @param {boolean} [clockwise=false] - [description] + * @param {number} [rotation=0] - [description] + */ +var EllipseCurve = new Class({ + + Extends: Curve, + + initialize: + + function EllipseCurve (x, y, xRadius, yRadius, startAngle, endAngle, clockwise, rotation) + { + if (typeof x === 'object') + { + var config = x; + + x = GetValue(config, 'x', 0); + y = GetValue(config, 'y', 0); + xRadius = GetValue(config, 'xRadius', 0); + yRadius = GetValue(config, 'yRadius', xRadius); + startAngle = GetValue(config, 'startAngle', 0); + endAngle = GetValue(config, 'endAngle', 360); + clockwise = GetValue(config, 'clockwise', false); + rotation = GetValue(config, 'rotation', 0); + } + else + { + if (yRadius === undefined) { yRadius = xRadius; } + if (startAngle === undefined) { startAngle = 0; } + if (endAngle === undefined) { endAngle = 360; } + if (clockwise === undefined) { clockwise = false; } + if (rotation === undefined) { rotation = 0; } + } + + Curve.call(this, 'EllipseCurve'); + + // Center point + + /** + * [description] + * + * @name {Phaser.Curves.EllipseCurve#p0 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p0 = new Vector2(x, y); + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#_xRadius + * @type {number} + * @private + * @since 3.0.0 + */ + this._xRadius = xRadius; + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#_yRadius + * @type {number} + * @private + * @since 3.0.0 + */ + this._yRadius = yRadius; + + // Radians + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#_startAngle + * @type {number} + * @private + * @since 3.0.0 + */ + this._startAngle = DegToRad(startAngle); + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#_endAngle + * @type {number} + * @private + * @since 3.0.0 + */ + this._endAngle = DegToRad(endAngle); + + /** + * Anti-clockwise direction. + * + * @name Phaser.Curves.EllipseCurve#_clockwise + * @type {boolean} + * @private + * @since 3.0.0 + */ + this._clockwise = clockwise; + + /** + * The rotation of the arc. + * + * @name Phaser.Curves.EllipseCurve#_rotation + * @type {number} + * @private + * @since 3.0.0 + */ + this._rotation = DegToRad(rotation); + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.EllipseCurve#getStartPoint + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return this.getPoint(0, out); + }, + + /** + * [description] + * + * @method Phaser.Curves.EllipseCurve#getResolution + * @since 3.0.0 + * + * @param {number} divisions - [description] + * + * @return {number} [description] + */ + getResolution: function (divisions) + { + return divisions * 2; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.EllipseCurve#getPoint + * @since 3.0.0 + * + * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var twoPi = Math.PI * 2; + var deltaAngle = this._endAngle - this._startAngle; + var samePoints = Math.abs(deltaAngle) < Number.EPSILON; + + // ensures that deltaAngle is 0 .. 2 PI + while (deltaAngle < 0) + { + deltaAngle += twoPi; + } + + while (deltaAngle > twoPi) + { + deltaAngle -= twoPi; + } + + if (deltaAngle < Number.EPSILON) + { + if (samePoints) + { + deltaAngle = 0; + } + else + { + deltaAngle = twoPi; + } + } + + if (this._clockwise && !samePoints) + { + if (deltaAngle === twoPi) + { + deltaAngle = - twoPi; + } + else + { + deltaAngle = deltaAngle - twoPi; + } + } + + var angle = this._startAngle + t * deltaAngle; + var x = this.p0.x + this._xRadius * Math.cos(angle); + var y = this.p0.y + this._yRadius * Math.sin(angle); + + if (this._rotation !== 0) + { + var cos = Math.cos(this._rotation); + var sin = Math.sin(this._rotation); + + var tx = x - this.p0.x; + var ty = y - this.p0.y; + + // Rotate the point about the center of the ellipse. + x = tx * cos - ty * sin + this.p0.x; + y = tx * sin + ty * cos + this.p0.y; + } + + return out.set(x, y); + }, + + /** + * Sets the horizontal radius of this curve. + * + * @method Phaser.Curves.EllipseCurve#setXRadius + * @since 3.0.0 + * + * @param {number} value - The horizontal radius of this curve. + * + * @return {Phaser.Curves.EllipseCurve} This curve object. + */ + setXRadius: function (value) + { + this.xRadius = value; + + return this; + }, + + /** + * Sets the vertical radius of this curve. + * + * @method Phaser.Curves.EllipseCurve#setYRadius + * @since 3.0.0 + * + * @param {number} value - The vertical radius of this curve. + * + * @return {Phaser.Curves.EllipseCurve} This curve object. + */ + setYRadius: function (value) + { + this.yRadius = value; + + return this; + }, + + /** + * Sets the width of this curve. + * + * @method Phaser.Curves.EllipseCurve#setWidth + * @since 3.0.0 + * + * @param {number} value - The width of this curve. + * + * @return {Phaser.Curves.EllipseCurve} This curve object. + */ + setWidth: function (value) + { + this.xRadius = value * 2; + + return this; + }, + + /** + * Sets the height of this curve. + * + * @method Phaser.Curves.EllipseCurve#setHeight + * @since 3.0.0 + * + * @param {number} value - The height of this curve. + * + * @return {Phaser.Curves.EllipseCurve} This curve object. + */ + setHeight: function (value) + { + this.yRadius = value * 2; + + return this; + }, + + /** + * Sets the start angle of this curve. + * + * @method Phaser.Curves.EllipseCurve#setStartAngle + * @since 3.0.0 + * + * @param {number} value - The start angle of this curve, in radians. + * + * @return {Phaser.Curves.EllipseCurve} This curve object. + */ + setStartAngle: function (value) + { + this.startAngle = value; + + return this; + }, + + /** + * Sets the end angle of this curve. + * + * @method Phaser.Curves.EllipseCurve#setEndAngle + * @since 3.0.0 + * + * @param {number} value - The end angle of this curve, in radians. + * + * @return {Phaser.Curves.EllipseCurve} This curve object. + */ + setEndAngle: function (value) + { + this.endAngle = value; + + return this; + }, + + /** + * Sets if this curve extends clockwise or anti-clockwise. + * + * @method Phaser.Curves.EllipseCurve#setClockwise + * @since 3.0.0 + * + * @param {boolean} value - The clockwise state of this curve. + * + * @return {Phaser.Curves.EllipseCurve} This curve object. + */ + setClockwise: function (value) + { + this.clockwise = value; + + return this; + }, + + /** + * Sets the rotation of this curve. + * + * @method Phaser.Curves.EllipseCurve#setRotation + * @since 3.0.0 + * + * @param {number} value - The rotation of this curve, in radians. + * + * @return {Phaser.Curves.EllipseCurve} This curve object. + */ + setRotation: function (value) + { + this.rotation = value; + + return this; + }, + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.p0.x; + }, + + set: function (value) + { + this.p0.x = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.p0.y; + }, + + set: function (value) + { + this.p0.y = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#xRadius + * @type {number} + * @since 3.0.0 + */ + xRadius: { + + get: function () + { + return this._xRadius; + }, + + set: function (value) + { + this._xRadius = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#yRadius + * @type {number} + * @since 3.0.0 + */ + yRadius: { + + get: function () + { + return this._yRadius; + }, + + set: function (value) + { + this._yRadius = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#startAngle + * @type {number} + * @since 3.0.0 + */ + startAngle: { + + get: function () + { + return RadToDeg(this._startAngle); + }, + + set: function (value) + { + this._startAngle = DegToRad(value); + } + + }, + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#endAngle + * @type {number} + * @since 3.0.0 + */ + endAngle: { + + get: function () + { + return RadToDeg(this._endAngle); + }, + + set: function (value) + { + this._endAngle = DegToRad(value); + } + + }, + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#clockwise + * @type {boolean} + * @since 3.0.0 + */ + clockwise: { + + get: function () + { + return this._clockwise; + }, + + set: function (value) + { + this._clockwise = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#rotation + * @type {number} + * @since 3.0.0 + */ + rotation: { + + get: function () + { + return this._rotation; + }, + + set: function (value) + { + this._rotation = DegToRad(value); + } + + }, + + /** + * [description] + * + * @method Phaser.Curves.EllipseCurve#toJSON + * @since 3.0.0 + * + * @return {JSONEllipseCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + x: this.p0.x, + y: this.p0.y, + xRadius: this._xRadius, + yRadius: this._yRadius, + startAngle: RadToDeg(this._startAngle), + endAngle: RadToDeg(this._endAngle), + clockwise: this._clockwise, + rotation: RadToDeg(this._rotation) + }; + } + +}); + +/** + * [description] + * + * @function Phaser.Curves.EllipseCurve.fromJSON + * @since 3.0.0 + * + * @param {JSONEllipseCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.EllipseCurve} [description] + */ +EllipseCurve.fromJSON = function (data) +{ + return new EllipseCurve(data); +}; + +module.exports = EllipseCurve; + + +/***/ }), +/* 320 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +function P0 (t, p) +{ + var k = 1 - t; + + return k * k * k * p; +} + +function P1 (t, p) +{ + var k = 1 - t; + + return 3 * k * k * t * p; +} + +function P2 (t, p) +{ + return 3 * (1 - t) * t * t * p; +} + +function P3 (t, p) +{ + return t * t * t * p; +} + +// p0 = start point +// p1 = control point 1 +// p2 = control point 2 +// p3 = end point + +// https://medium.com/@adrian_cooney/bezier-interpolation-13b68563313a + +/** + * [description] + * + * @function Phaser.Math.Interpolation.CubicBezier + * @since 3.0.0 + * + * @param {float} t - [description] + * @param {number} p0 - [description] + * @param {number} p1 - [description] + * @param {number} p2 - [description] + * @param {number} p3 - [description] + * + * @return {number} [description] + */ +var CubicBezierInterpolation = function (t, p0, p1, p2, p3) +{ + return P0(t, p0) + P1(t, p1) + P2(t, p2) + P3(t, p3); +}; + +module.exports = CubicBezierInterpolation; + + +/***/ }), +/* 321 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var Class = __webpack_require__(0); +var CubicBezier = __webpack_require__(320); +var Curve = __webpack_require__(56); +var Vector2 = __webpack_require__(6); + +/** + * @classdesc + * [description] + * + * @class CubicBezierCurve + * @extends Phaser.Curves.Curve + * @memberOf Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector2[])} p0 - Start point, or an array of point pairs. + * @param {Phaser.Math.Vector2} p1 - Control Point 1. + * @param {Phaser.Math.Vector2} p2 - Control Point 2. + * @param {Phaser.Math.Vector2} p3 - End Point. + */ +var CubicBezierCurve = new Class({ + + Extends: Curve, + + initialize: + + function CubicBezierCurve (p0, p1, p2, p3) + { + Curve.call(this, 'CubicBezierCurve'); + + if (Array.isArray(p0)) + { + p3 = new Vector2(p0[6], p0[7]); + p2 = new Vector2(p0[4], p0[5]); + p1 = new Vector2(p0[2], p0[3]); + p0 = new Vector2(p0[0], p0[1]); + } + + /** + * [description] + * + * @name Phaser.Curves.CubicBezierCurve#p0 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p0 = p0; + + /** + * [description] + * + * @name Phaser.Curves.CubicBezierCurve#p1 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p1 = p1; + + /** + * [description] + * + * @name Phaser.Curves.CubicBezierCurve#p2 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p2 = p2; + + /** + * [description] + * + * @name Phaser.Curves.CubicBezierCurve#p3 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p3 = p3; + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.CubicBezierCurve#getStartPoint + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.p0); + }, + + /** + * [description] + * + * @method Phaser.Curves.CubicBezierCurve#getResolution + * @since 3.0.0 + * + * @param {number} divisions - The amount of divisions used by this curve. + * + * @return {number} The resolution of the curve. + */ + getResolution: function (divisions) + { + return divisions; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.CubicBezierCurve#getPoint + * @since 3.0.0 + * + * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var p0 = this.p0; + var p1 = this.p1; + var p2 = this.p2; + var p3 = this.p3; + + return out.set(CubicBezier(t, p0.x, p1.x, p2.x, p3.x), CubicBezier(t, p0.y, p1.y, p2.y, p3.y)); + }, + + /** + * [description] + * + * @method Phaser.Curves.CubicBezierCurve#draw + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - [description] + * @param {integer} [pointsTotal=32] - [description] + * + * @return {Phaser.GameObjects.Graphics} [description] + */ + draw: function (graphics, pointsTotal) + { + if (pointsTotal === undefined) { pointsTotal = 32; } + + var points = this.getPoints(pointsTotal); + + graphics.beginPath(); + graphics.moveTo(this.p0.x, this.p0.y); + + for (var i = 1; i < points.length; i++) + { + graphics.lineTo(points[i].x, points[i].y); + } + + graphics.strokePath(); + + // So you can chain graphics calls + return graphics; + }, + + /** + * [description] + * + * @method Phaser.Curves.CubicBezierCurve#toJSON + * @since 3.0.0 + * + * @return {JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + points: [ + this.p0.x, this.p0.y, + this.p1.x, this.p1.y, + this.p2.x, this.p2.y, + this.p3.x, this.p3.y + ] + }; + } + +}); + +/** + * [description] + * + * @function Phaser.Curves.CubicBezierCurve.fromJSON + * @since 3.0.0 + * + * @param {JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.CubicBezierCurve} [description] + */ +CubicBezierCurve.fromJSON = function (data) +{ + var points = data.points; + + var p0 = new Vector2(points[0], points[1]); + var p1 = new Vector2(points[2], points[3]); + var p2 = new Vector2(points[4], points[5]); + var p3 = new Vector2(points[6], points[7]); + + return new CubicBezierCurve(p0, p1, p2, p3); +}; + +module.exports = CubicBezierCurve; + + +/***/ }), +/* 322 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A 16 color palette by [Arne](http://androidarts.com/palette/16pal.htm) + * + * @name Phaser.Create.Palettes.ARNE16 + * @since 3.0.0 + * + * @type {Palette} + */ +module.exports = { + 0: '#000', + 1: '#9D9D9D', + 2: '#FFF', + 3: '#BE2633', + 4: '#E06F8B', + 5: '#493C2B', + 6: '#A46422', + 7: '#EB8931', + 8: '#F7E26B', + 9: '#2F484E', + A: '#44891A', + B: '#A3CE27', + C: '#1B2632', + D: '#005784', + E: '#31A2F2', + F: '#B2DCEF' +}; + + +/***/ }), +/* 323 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Arne16 = __webpack_require__(322); +var CanvasPool = __webpack_require__(23); +var GetValue = __webpack_require__(5); + +/** + * @callback GenerateTextureRendererCallback + * + * @param {HTMLCanvasElement} canvas - [description] + * @param {CanvasRenderingContext2D} context - [description] + */ + +/** + * @typedef {object} GenerateTextureConfig + * + * @property {array} [data=[]] - [description] + * @property {HTMLCanvasElement} [canvas=null] - [description] + * @property {Palette} [palette=Arne16] - [description] + * @property {number} [pixelWidth=1] - [description] + * @property {number} [pixelHeight=1] - [description] + * @property {boolean} [resizeCanvas=true] - [description] + * @property {boolean} [clearCanvas=true] - [description] + * @property {GenerateTextureRendererCallback} [preRender] - [description] + * @property {GenerateTextureRendererCallback} [postRender] - [description] + */ + +/** + * [description] + * + * @function Phaser.Create.GenerateTexture + * @since 3.0.0 + * + * @param {GenerateTextureConfig} config - [description] + * + * @return {HTMLCanvasElement} [description] + */ +var GenerateTexture = function (config) +{ + var data = GetValue(config, 'data', []); + var canvas = GetValue(config, 'canvas', null); + var palette = GetValue(config, 'palette', Arne16); + var pixelWidth = GetValue(config, 'pixelWidth', 1); + var pixelHeight = GetValue(config, 'pixelHeight', pixelWidth); + var resizeCanvas = GetValue(config, 'resizeCanvas', true); + var clearCanvas = GetValue(config, 'clearCanvas', true); + var preRender = GetValue(config, 'preRender', null); + var postRender = GetValue(config, 'postRender', null); + + var width = Math.floor(Math.abs(data[0].length * pixelWidth)); + var height = Math.floor(Math.abs(data.length * pixelHeight)); + + if (!canvas) + { + canvas = CanvasPool.create2D(this, width, height); + resizeCanvas = false; + clearCanvas = false; + } + + if (resizeCanvas) + { + canvas.width = width; + canvas.height = height; + } + + var ctx = canvas.getContext('2d'); + + if (clearCanvas) + { + ctx.clearRect(0, 0, width, height); + } + + // preRender Callback? + if (preRender) + { + preRender(canvas, ctx); + } + + // Draw it + for (var y = 0; y < data.length; y++) + { + var row = data[y]; + + for (var x = 0; x < row.length; x++) + { + var d = row[x]; + + if (d !== '.' && d !== ' ') + { + ctx.fillStyle = palette[d]; + ctx.fillRect(x * pixelWidth, y * pixelHeight, pixelWidth, pixelHeight); + } + } + } + + // postRender Callback? + if (postRender) + { + postRender(canvas, ctx); + } + + return canvas; +}; + +module.exports = GenerateTexture; + + +/***/ }), +/* 324 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Camera = __webpack_require__(154); +var Class = __webpack_require__(0); +var Vector3 = __webpack_require__(57); + +// Local cache vars +var tmpVec3 = new Vector3(); + +/** + * @classdesc + * [description] + * + * @class PerspectiveCamera + * @extends Phaser.Cameras.Sprite3D.Camera + * @memberOf Phaser.Cameras.Sprite3D + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {integer} fieldOfView - [description] + * @param {integer} viewportWidth - [description] + * @param {integer} viewportHeight - [description] + */ +var PerspectiveCamera = new Class({ + + Extends: Camera, + + // FOV is converted to radians automatically + initialize: + + function PerspectiveCamera (scene, fieldOfView, viewportWidth, viewportHeight) + { + if (fieldOfView === undefined) { fieldOfView = 80; } + if (viewportWidth === undefined) { viewportWidth = 0; } + if (viewportHeight === undefined) { viewportHeight = 0; } + + Camera.call(this, scene); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.PerspectiveCamera#viewportWidth + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.viewportWidth = viewportWidth; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.PerspectiveCamera#viewportHeight + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.viewportHeight = viewportHeight; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.PerspectiveCamera#fieldOfView + * @type {integer} + * @default 80 + * @since 3.0.0 + */ + this.fieldOfView = fieldOfView * Math.PI / 180; + + this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.PerspectiveCamera#setFOV + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description] + */ + setFOV: function (value) + { + this.fieldOfView = value * Math.PI / 180; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.PerspectiveCamera#update + * @since 3.0.0 + * + * @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description] + */ + update: function () + { + var aspect = this.viewportWidth / this.viewportHeight; + + // Create a perspective matrix for our camera + this.projection.perspective( + this.fieldOfView, + aspect, + Math.abs(this.near), + Math.abs(this.far) + ); + + // Build the view matrix + tmpVec3.copy(this.position).add(this.direction); + + this.view.lookAt(this.position, tmpVec3, this.up); + + // Projection * view matrix + this.combined.copy(this.projection).multiply(this.view); + + // Invert combined matrix, used for unproject + this.invProjectionView.copy(this.combined).invert(); + + this.billboardMatrixDirty = true; + + this.updateChildren(); + + return this; + } + +}); + +module.exports = PerspectiveCamera; + + +/***/ }), +/* 325 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Camera = __webpack_require__(154); +var Class = __webpack_require__(0); +var Vector3 = __webpack_require__(57); + +// Local cache vars +var tmpVec3 = new Vector3(); + +/** + * @classdesc + * [description] + * + * @class OrthographicCamera + * @extends Phaser.Cameras.Sprite3D.Camera + * @memberOf Phaser.Cameras.Sprite3D + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {integer} viewportWidth - [description] + * @param {integer} viewportHeight - [description] + */ +var OrthographicCamera = new Class({ + + Extends: Camera, + + initialize: + + function OrthographicCamera (scene, viewportWidth, viewportHeight) + { + if (viewportWidth === undefined) { viewportWidth = 0; } + if (viewportHeight === undefined) { viewportHeight = 0; } + + Camera.call(this, scene); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.OrthographicCamera#viewportWidth + * @type {integer} + * @since 3.0.0 + */ + this.viewportWidth = viewportWidth; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.OrthographicCamera#viewportHeight + * @type {integer} + * @since 3.0.0 + */ + this.viewportHeight = viewportHeight; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.OrthographicCamera#_zoom + * @type {float} + * @private + * @since 3.0.0 + */ + this._zoom = 1.0; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.OrthographicCamera#near + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.near = 0; + + this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.OrthographicCamera#setToOrtho + * @since 3.0.0 + * + * @param {number} yDown - [description] + * @param {number} [viewportWidth] - [description] + * @param {number} [viewportHeight] - [description] + * + * @return {Phaser.Cameras.Sprite3D.OrthographicCamera} [description] + */ + setToOrtho: function (yDown, viewportWidth, viewportHeight) + { + if (viewportWidth === undefined) { viewportWidth = this.viewportWidth; } + if (viewportHeight === undefined) { viewportHeight = this.viewportHeight; } + + var zoom = this.zoom; + + this.up.set(0, (yDown) ? -1 : 1, 0); + this.direction.set(0, 0, (yDown) ? 1 : -1); + this.position.set(zoom * viewportWidth / 2, zoom * viewportHeight / 2, 0); + + this.viewportWidth = viewportWidth; + this.viewportHeight = viewportHeight; + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.OrthographicCamera#update + * @since 3.0.0 + * + * @return {Phaser.Cameras.Sprite3D.OrthographicCamera} [description] + */ + update: function () + { + var w = this.viewportWidth; + var h = this.viewportHeight; + var near = Math.abs(this.near); + var far = Math.abs(this.far); + var zoom = this.zoom; + + if (w === 0 || h === 0) + { + // What to do here... hmm? + return this; + } + + this.projection.ortho( + zoom * -w / 2, zoom * w / 2, + zoom * -h / 2, zoom * h / 2, + near, + far + ); + + // Build the view matrix + tmpVec3.copy(this.position).add(this.direction); + + this.view.lookAt(this.position, tmpVec3, this.up); + + // Projection * view matrix + this.combined.copy(this.projection).multiply(this.view); + + // Invert combined matrix, used for unproject + this.invProjectionView.copy(this.combined).invert(); + + this.billboardMatrixDirty = true; + + this.updateChildren(); + + return this; + }, + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.OrthographicCamera#zoom + * @type {number} + * @since 3.0.0 + */ + zoom: { + + get: function () + { + return this._zoom; + }, + + set: function (value) + { + this._zoom = value; + this.update(); + } + } + +}); + +module.exports = OrthographicCamera; + + +/***/ }), +/* 326 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); + +/** + * @classdesc + * [description] + * + * @class Matrix3 + * @memberOf Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} [m] - [description] + */ + +var Matrix3 = new Class({ + + initialize: + + function Matrix3 (m) + { + /** + * [description] + * + * @name Phaser.Math.Matrix3#val + * @type {Float32Array} + * @since 3.0.0 + */ + this.val = new Float32Array(9); + + if (m) + { + // Assume Matrix3 with val: + this.copy(m); + } + else + { + // Default to identity + this.identity(); + } + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} A new Matrix3 object. + */ + clone: function () + { + return new Matrix3(this); + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#set + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} src - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + set: function (src) + { + return this.copy(src); + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#copy + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} src - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + copy: function (src) + { + var out = this.val; + var a = src.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#fromMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} m - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + fromMat4: function (m) + { + var a = m.val; + var out = this.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[4]; + out[4] = a[5]; + out[5] = a[6]; + out[6] = a[8]; + out[7] = a[9]; + out[8] = a[10]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#fromArray + * @since 3.0.0 + * + * @param {array} a - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + fromArray: function (a) + { + var out = this.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#identity + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + identity: function () + { + var out = this.val; + + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 1; + out[5] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 1; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#transpose + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + transpose: function () + { + var a = this.val; + var a01 = a[1]; + var a02 = a[2]; + var a12 = a[5]; + + a[1] = a[3]; + a[2] = a[6]; + a[3] = a01; + a[5] = a[7]; + a[6] = a02; + a[7] = a12; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#invert + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + invert: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + var b01 = a22 * a11 - a12 * a21; + var b11 = -a22 * a10 + a12 * a20; + var b21 = a21 * a10 - a11 * a20; + + // Calculate the determinant + var det = a00 * b01 + a01 * b11 + a02 * b21; + + if (!det) + { + return null; + } + + det = 1 / det; + + a[0] = b01 * det; + a[1] = (-a22 * a01 + a02 * a21) * det; + a[2] = (a12 * a01 - a02 * a11) * det; + a[3] = b11 * det; + a[4] = (a22 * a00 - a02 * a20) * det; + a[5] = (-a12 * a00 + a02 * a10) * det; + a[6] = b21 * det; + a[7] = (-a21 * a00 + a01 * a20) * det; + a[8] = (a11 * a00 - a01 * a10) * det; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#adjoint + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + adjoint: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + a[0] = (a11 * a22 - a12 * a21); + a[1] = (a02 * a21 - a01 * a22); + a[2] = (a01 * a12 - a02 * a11); + a[3] = (a12 * a20 - a10 * a22); + a[4] = (a00 * a22 - a02 * a20); + a[5] = (a02 * a10 - a00 * a12); + a[6] = (a10 * a21 - a11 * a20); + a[7] = (a01 * a20 - a00 * a21); + a[8] = (a00 * a11 - a01 * a10); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#determinant + * @since 3.0.0 + * + * @return {number} [description] + */ + determinant: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20); + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#multiply + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} src - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + multiply: function (src) + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + var b = src.val; + + var b00 = b[0]; + var b01 = b[1]; + var b02 = b[2]; + var b10 = b[3]; + var b11 = b[4]; + var b12 = b[5]; + var b20 = b[6]; + var b21 = b[7]; + var b22 = b[8]; + + a[0] = b00 * a00 + b01 * a10 + b02 * a20; + a[1] = b00 * a01 + b01 * a11 + b02 * a21; + a[2] = b00 * a02 + b01 * a12 + b02 * a22; + + a[3] = b10 * a00 + b11 * a10 + b12 * a20; + a[4] = b10 * a01 + b11 * a11 + b12 * a21; + a[5] = b10 * a02 + b11 * a12 + b12 * a22; + + a[6] = b20 * a00 + b21 * a10 + b22 * a20; + a[7] = b20 * a01 + b21 * a11 + b22 * a21; + a[8] = b20 * a02 + b21 * a12 + b22 * a22; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#translate + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + translate: function (v) + { + var a = this.val; + var x = v.x; + var y = v.y; + + a[6] = x * a[0] + y * a[3] + a[6]; + a[7] = x * a[1] + y * a[4] + a[7]; + a[8] = x * a[2] + y * a[5] + a[8]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#rotate + * @since 3.0.0 + * + * @param {number} rad - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + rotate: function (rad) + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + + var s = Math.sin(rad); + var c = Math.cos(rad); + + a[0] = c * a00 + s * a10; + a[1] = c * a01 + s * a11; + a[2] = c * a02 + s * a12; + + a[3] = c * a10 - s * a00; + a[4] = c * a11 - s * a01; + a[5] = c * a12 - s * a02; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#scale + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + scale: function (v) + { + var a = this.val; + var x = v.x; + var y = v.y; + + a[0] = x * a[0]; + a[1] = x * a[1]; + a[2] = x * a[2]; + + a[3] = y * a[3]; + a[4] = y * a[4]; + a[5] = y * a[5]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#fromQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + fromQuat: function (q) + { + var x = q.x; + var y = q.y; + var z = q.z; + var w = q.w; + + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + + var out = this.val; + + out[0] = 1 - (yy + zz); + out[3] = xy + wz; + out[6] = xz - wy; + + out[1] = xy - wz; + out[4] = 1 - (xx + zz); + out[7] = yz + wx; + + out[2] = xz + wy; + out[5] = yz - wx; + out[8] = 1 - (xx + yy); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#normalFromMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} m - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + normalFromMat4: function (m) + { + var a = m.val; + var out = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + + if (!det) + { + return null; + } + + det = 1 / det; + + out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + + out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + + out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det; + + return this; + } + +}); + +module.exports = Matrix3; + + +/***/ }), +/* 327 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); +var Vector3 = __webpack_require__(57); +var Matrix3 = __webpack_require__(326); + +var EPSILON = 0.000001; + +// Some shared 'private' arrays +var siNext = new Int8Array([ 1, 2, 0 ]); +var tmp = new Float32Array([ 0, 0, 0 ]); + +var xUnitVec3 = new Vector3(1, 0, 0); +var yUnitVec3 = new Vector3(0, 1, 0); + +var tmpvec = new Vector3(); +var tmpMat3 = new Matrix3(); + +/** + * @classdesc + * [description] + * + * @class Quaternion + * @memberOf Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {number} [x] - [description] + * @param {number} [y] - [description] + * @param {number} [z] - [description] + * @param {number} [w] - [description] + */ +var Quaternion = new Class({ + + initialize: + + function Quaternion (x, y, z, w) + { + /** + * The x component of this Quaternion. + * + * @name Phaser.Math.Quaternion#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The y component of this Quaternion. + * + * @name Phaser.Math.Quaternion#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The z component of this Quaternion. + * + * @name Phaser.Math.Quaternion#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The w component of this Quaternion. + * + * @name Phaser.Math.Quaternion#w + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#copy + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} src - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + copy: function (src) + { + this.x = src.x; + this.y = src.y; + this.z = src.z; + this.w = src.w; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#set + * @since 3.0.0 + * + * @param {(number|object)} [x=0] - [description] + * @param {number} [y=0] - [description] + * @param {number} [z=0] - [description] + * @param {number} [w=0] - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + set: function (x, y, z, w) + { + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#add + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + add: function (v) + { + this.x += v.x; + this.y += v.y; + this.z += v.z; + this.w += v.w; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#subtract + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + subtract: function (v) + { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z; + this.w -= v.w; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#scale + * @since 3.0.0 + * + * @param {number} scale - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + scale: function (scale) + { + this.x *= scale; + this.y *= scale; + this.z *= scale; + this.w *= scale; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#length + * @since 3.0.0 + * + * @return {number} [description] + */ + length: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return Math.sqrt(x * x + y * y + z * z + w * w); + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#lengthSq + * @since 3.0.0 + * + * @return {number} [description] + */ + lengthSq: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return x * x + y * y + z * z + w * w; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#normalize + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + normalize: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + var len = x * x + y * y + z * z + w * w; + + if (len > 0) + { + len = 1 / Math.sqrt(len); + + this.x = x * len; + this.y = y * len; + this.z = z * len; + this.w = w * len; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#dot + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - [description] + * + * @return {number} [description] + */ + dot: function (v) + { + return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#lerp + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - [description] + * @param {number} [t=0] - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + lerp: function (v, t) + { + if (t === undefined) { t = 0; } + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + this.x = ax + t * (v.x - ax); + this.y = ay + t * (v.y - ay); + this.z = az + t * (v.z - az); + this.w = aw + t * (v.w - aw); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#rotationTo + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} a - [description] + * @param {Phaser.Math.Vector3} b - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + rotationTo: function (a, b) + { + var dot = a.x * b.x + a.y * b.y + a.z * b.z; + + if (dot < -0.999999) + { + if (tmpvec.copy(xUnitVec3).cross(a).length() < EPSILON) + { + tmpvec.copy(yUnitVec3).cross(a); + } + + tmpvec.normalize(); + + return this.setAxisAngle(tmpvec, Math.PI); + + } + else if (dot > 0.999999) + { + this.x = 0; + this.y = 0; + this.z = 0; + this.w = 1; + + return this; + } + else + { + tmpvec.copy(a).cross(b); + + this.x = tmpvec.x; + this.y = tmpvec.y; + this.z = tmpvec.z; + this.w = 1 + dot; + + return this.normalize(); + } + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#setAxes + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} view - [description] + * @param {Phaser.Math.Vector3} right - [description] + * @param {Phaser.Math.Vector3} up - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + setAxes: function (view, right, up) + { + var m = tmpMat3.val; + + m[0] = right.x; + m[3] = right.y; + m[6] = right.z; + + m[1] = up.x; + m[4] = up.y; + m[7] = up.z; + + m[2] = -view.x; + m[5] = -view.y; + m[8] = -view.z; + + return this.fromMat3(tmpMat3).normalize(); + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#identity + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + identity: function () + { + this.x = 0; + this.y = 0; + this.z = 0; + this.w = 1; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#setAxisAngle + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} axis - [description] + * @param {number} rad - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + setAxisAngle: function (axis, rad) + { + rad = rad * 0.5; + + var s = Math.sin(rad); + + this.x = s * axis.x; + this.y = s * axis.y; + this.z = s * axis.z; + this.w = Math.cos(rad); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#multiply + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} b - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + multiply: function (b) + { + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bx = b.x; + var by = b.y; + var bz = b.z; + var bw = b.w; + + this.x = ax * bw + aw * bx + ay * bz - az * by; + this.y = ay * bw + aw * by + az * bx - ax * bz; + this.z = az * bw + aw * bz + ax * by - ay * bx; + this.w = aw * bw - ax * bx - ay * by - az * bz; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#slerp + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} b - [description] + * @param {number} t - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + slerp: function (b, t) + { + // benchmarks: http://jsperf.com/quaternion-slerp-implementations + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bx = b.x; + var by = b.y; + var bz = b.z; + var bw = b.w; + + // calc cosine + var cosom = ax * bx + ay * by + az * bz + aw * bw; + + // adjust signs (if necessary) + if (cosom < 0) + { + cosom = -cosom; + bx = - bx; + by = - by; + bz = - bz; + bw = - bw; + } + + // "from" and "to" quaternions are very close + // ... so we can do a linear interpolation + var scale0 = 1 - t; + var scale1 = t; + + // calculate coefficients + if ((1 - cosom) > EPSILON) + { + // standard case (slerp) + var omega = Math.acos(cosom); + var sinom = Math.sin(omega); + + scale0 = Math.sin((1.0 - t) * omega) / sinom; + scale1 = Math.sin(t * omega) / sinom; + } + + // calculate final values + this.x = scale0 * ax + scale1 * bx; + this.y = scale0 * ay + scale1 * by; + this.z = scale0 * az + scale1 * bz; + this.w = scale0 * aw + scale1 * bw; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#invert + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + invert: function () + { + var a0 = this.x; + var a1 = this.y; + var a2 = this.z; + var a3 = this.w; + + var dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3; + var invDot = (dot) ? 1 / dot : 0; + + // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0 + + this.x = -a0 * invDot; + this.y = -a1 * invDot; + this.z = -a2 * invDot; + this.w = a3 * invDot; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#conjugate + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + conjugate: function () + { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#rotateX + * @since 3.0.0 + * + * @param {number} rad - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + rotateX: function (rad) + { + rad *= 0.5; + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bx = Math.sin(rad); + var bw = Math.cos(rad); + + this.x = ax * bw + aw * bx; + this.y = ay * bw + az * bx; + this.z = az * bw - ay * bx; + this.w = aw * bw - ax * bx; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#rotateY + * @since 3.0.0 + * + * @param {number} rad - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + rotateY: function (rad) + { + rad *= 0.5; + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var by = Math.sin(rad); + var bw = Math.cos(rad); + + this.x = ax * bw - az * by; + this.y = ay * bw + aw * by; + this.z = az * bw + ax * by; + this.w = aw * bw - ay * by; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#rotateZ + * @since 3.0.0 + * + * @param {number} rad - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + rotateZ: function (rad) + { + rad *= 0.5; + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bz = Math.sin(rad); + var bw = Math.cos(rad); + + this.x = ax * bw + ay * bz; + this.y = ay * bw - ax * bz; + this.z = az * bw + aw * bz; + this.w = aw * bw - az * bz; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#calculateW + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + calculateW: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + + this.w = -Math.sqrt(Math.abs(1.0 - x * x - y * y - z * z)); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#fromMat3 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} mat - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + fromMat3: function (mat) + { + // benchmarks: + // http://jsperf.com/typed-array-access-speed + // http://jsperf.com/conversion-of-3x3-matrix-to-quaternion + + // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes + // article "Quaternion Calculus and Fast Animation". + var m = mat.val; + var fTrace = m[0] + m[4] + m[8]; + var fRoot; + + if (fTrace > 0) + { + // |w| > 1/2, may as well choose w > 1/2 + fRoot = Math.sqrt(fTrace + 1.0); // 2w + + this.w = 0.5 * fRoot; + + fRoot = 0.5 / fRoot; // 1/(4w) + + this.x = (m[7] - m[5]) * fRoot; + this.y = (m[2] - m[6]) * fRoot; + this.z = (m[3] - m[1]) * fRoot; + } + else + { + // |w| <= 1/2 + var i = 0; + + if (m[4] > m[0]) + { + i = 1; + } + + if (m[8] > m[i * 3 + i]) + { + i = 2; + } + + var j = siNext[i]; + var k = siNext[j]; + + // This isn't quite as clean without array access + fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1); + tmp[i] = 0.5 * fRoot; + + fRoot = 0.5 / fRoot; + + tmp[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot; + tmp[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot; + + this.x = tmp[0]; + this.y = tmp[1]; + this.z = tmp[2]; + this.w = (m[k * 3 + j] - m[j * 3 + k]) * fRoot; + } + + return this; + } + +}); + +module.exports = Quaternion; + + +/***/ }), +/* 328 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Vector3 = __webpack_require__(57); +var Matrix4 = __webpack_require__(153); +var Quaternion = __webpack_require__(327); + +var tmpMat4 = new Matrix4(); +var tmpQuat = new Quaternion(); +var tmpVec3 = new Vector3(); + +/** + * Rotates a vector in place by axis angle. + * + * This is the same as transforming a point by an + * axis-angle quaternion, but it has higher precision. + * + * @function Phaser.Math.RotateVec3 + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} vec - [description] + * @param {Phaser.Math.Vector3} axis - [description] + * @param {float} radians - [description] + * + * @return {Phaser.Math.Vector3} [description] + */ +var RotateVec3 = function (vec, axis, radians) +{ + // Set the quaternion to our axis angle + tmpQuat.setAxisAngle(axis, radians); + + // Create a rotation matrix from the axis angle + tmpMat4.fromRotationTranslation(tmpQuat, tmpVec3.set(0, 0, 0)); + + // Multiply our vector by the rotation matrix + return vec.transformMat4(tmpMat4); +}; + +module.exports = RotateVec3; + + +/***/ }), +/* 329 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.RandomXYZW + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} vec4 - [description] + * @param {float} [scale=1] - [description] + * + * @return {Phaser.Math.Vector4} [description] + */ +var RandomXYZW = function (vec4, scale) +{ + if (scale === undefined) { scale = 1; } + + // Not spherical; should fix this for more uniform distribution + vec4.x = (Math.random() * 2 - 1) * scale; + vec4.y = (Math.random() * 2 - 1) * scale; + vec4.z = (Math.random() * 2 - 1) * scale; + vec4.w = (Math.random() * 2 - 1) * scale; + + return vec4; +}; + +module.exports = RandomXYZW; + + +/***/ }), +/* 330 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Position Vector randomly in a spherical area defined by the given radius +/** + * [description] + * + * @function Phaser.Math.RandomXYZ + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} vec3 - [description] + * @param {number} [radius=1] - [description] + * + * @return {Phaser.Math.Vector3} [description] + */ +var RandomXYZ = function (vec3, radius) +{ + if (radius === undefined) { radius = 1; } + + var r = Math.random() * 2 * Math.PI; + var z = (Math.random() * 2) - 1; + var zScale = Math.sqrt(1 - z * z) * radius; + + vec3.x = Math.cos(r) * zScale; + vec3.y = Math.sin(r) * zScale; + vec3.z = z * radius; + + return vec3; +}; + +module.exports = RandomXYZ; + + +/***/ }), +/* 331 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Color = __webpack_require__(41); + +/** + * Converts a CSS 'web' string into a Phaser Color object. + * + * The web string can be in the format `'rgb(r,g,b)'` or `'rgba(r,g,b,a)'` where r/g/b are in the range [0..255] and a is in the range [0..1]. + * + * @function Phaser.Display.Color.RGBStringToColor + * @since 3.0.0 + * + * @param {string} rgb - The CSS format color string, using the `rgb` or `rgba` format. + * + * @return {Phaser.Display.Color} A Color object. + */ +var RGBStringToColor = function (rgb) +{ + var color = new Color(); + + var result = (/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/).exec(rgb.toLowerCase()); + + if (result) + { + var r = parseInt(result[1], 10); + var g = parseInt(result[2], 10); + var b = parseInt(result[3], 10); + var a = (result[4] !== undefined) ? parseFloat(result[4]) : 1; + + color.setTo(r, g, b, a * 255); + } + + return color; +}; + +module.exports = RGBStringToColor; + + +/***/ }), +/* 332 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Color = __webpack_require__(41); + +/** + * Converts an object containing `r`, `g`, `b` and `a` properties into a Color class instance. + * + * @function Phaser.Display.Color.ObjectToColor + * @since 3.0.0 + * + * @param {InputColorObject} input - An object containing `r`, `g`, `b` and `a` properties in the range 0 to 255. + * + * @return {Phaser.Display.Color} A Color object. + */ +var ObjectToColor = function (input) +{ + return new Color(input.r, input.g, input.b, input.a); +}; + +module.exports = ObjectToColor; + + +/***/ }), +/* 333 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Return the component parts of a color as an Object with the properties alpha, red, green, blue. + * + * Alpha will only be set if it exists in the given color (0xAARRGGBB) + * + * @function Phaser.Display.Color.IntegerToRGB + * @since 3.0.0 + * + * @param {integer} input - The color value to convert into a Color object. + * + * @return {ColorObject} An object with the red, green and blue values set in the r, g and b properties. + */ +var IntegerToRGB = function (color) +{ + if (color > 16777215) + { + // The color value has an alpha component + return { + a: color >>> 24, + r: color >> 16 & 0xFF, + g: color >> 8 & 0xFF, + b: color & 0xFF + }; + } + else + { + return { + a: 255, + r: color >> 16 & 0xFF, + g: color >> 8 & 0xFF, + b: color & 0xFF + }; + } +}; + +module.exports = IntegerToRGB; + + +/***/ }), +/* 334 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Color = __webpack_require__(41); +var IntegerToRGB = __webpack_require__(333); + +/** + * Converts the given color value into an instance of a Color object. + * + * @function Phaser.Display.Color.IntegerToColor + * @since 3.0.0 + * + * @param {integer} input - The color value to convert into a Color object. + * + * @return {Phaser.Display.Color} A Color object. + */ +var IntegerToColor = function (input) +{ + var rgb = IntegerToRGB(input); + + return new Color(rgb.r, rgb.g, rgb.b, rgb.a); +}; + +module.exports = IntegerToColor; + + +/***/ }), +/* 335 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Given an alpha and 3 color values this will return an integer representation of it. + * + * @function Phaser.Display.Color.GetColor32 + * @since 3.0.0 + * + * @param {integer} red - The red color value. A number between 0 and 255. + * @param {integer} green - The green color value. A number between 0 and 255. + * @param {integer} blue - The blue color value. A number between 0 and 255. + * @param {integer} alpha - The alpha color value. A number between 0 and 255. + * + * @return {number} The combined color value. + */ +var GetColor32 = function (red, green, blue, alpha) +{ + return alpha << 24 | red << 16 | green << 8 | blue; +}; + +module.exports = GetColor32; + + +/***/ }), +/* 336 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Color = __webpack_require__(41); + +/** + * Converts a hex string into a Phaser Color object. + * + * The hex string can supplied as `'#0033ff'` or the short-hand format of `'#03f'`; it can begin with an optional "#" or "0x", or be unprefixed. + * + * An alpha channel is _not_ supported. + * + * @function Phaser.Display.Color.HexStringToColor + * @since 3.0.0 + * + * @param {string} hex - The hex color value to convert, such as `#0033ff` or the short-hand format: `#03f`. + * + * @return {Phaser.Display.Color} A Color object populated by the values of the given string. + */ +var HexStringToColor = function (hex) +{ + var color = new Color(); + + // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") + hex = hex.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) + { + return r + r + g + g + b + b; + }); + + var result = (/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i).exec(hex); + + if (result) + { + var r = parseInt(result[1], 16); + var g = parseInt(result[2], 16); + var b = parseInt(result[3], 16); + + color.setTo(r, g, b); + } + + return color; +}; + +module.exports = HexStringToColor; + + +/***/ }), +/* 337 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BaseCache = __webpack_require__(338); +var Class = __webpack_require__(0); + +/** + * @classdesc + * The Cache Manager is the global cache owned and maintained by the Game instance. + * + * Various systems, such as the file Loader, rely on this cache in order to store the files + * it has loaded. The manager itself doesn't store any files, but instead owns multiple BaseCache + * instances, one per type of file. You can also add your own custom caches. + * + * @class CacheManager + * @memberOf Phaser.Cache + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - A reference to the Phaser.Game instance that owns this CacheManager. + */ +var CacheManager = new Class({ + + initialize: + + function CacheManager (game) + { + /** + * A reference to the Phaser.Game instance that owns this CacheManager. + * + * @name Phaser.Cache.CacheManager#game + * @type {Phaser.Game} + * @protected + * @since 3.0.0 + */ + this.game = game; + + /** + * A Cache storing all binary files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#binary + * @type {Phaser.Cache.BaseCache} + * @protected + * @since 3.0.0 + */ + this.binary = new BaseCache(); + + /** + * A Cache storing all bitmap font data files, typically added via the Loader. + * Only the font data is stored in this cache, the textures are part of the Texture Manager. + * + * @name Phaser.Cache.CacheManager#bitmapFont + * @type {Phaser.Cache.BaseCache} + * @protected + * @since 3.0.0 + */ + this.bitmapFont = new BaseCache(); + + /** + * A Cache storing all JSON data files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#json + * @type {Phaser.Cache.BaseCache} + * @protected + * @since 3.0.0 + */ + this.json = new BaseCache(); + + /** + * A Cache storing all physics data files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#physics + * @type {Phaser.Cache.BaseCache} + * @protected + * @since 3.0.0 + */ + this.physics = new BaseCache(); + + /** + * A Cache storing all shader source files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#shader + * @type {Phaser.Cache.BaseCache} + * @protected + * @since 3.0.0 + */ + this.shader = new BaseCache(); + + /** + * A Cache storing all non-streaming audio files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#audio + * @type {Phaser.Cache.BaseCache} + * @protected + * @since 3.0.0 + */ + this.audio = new BaseCache(); + + /** + * A Cache storing all text files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#text + * @type {Phaser.Cache.BaseCache} + * @protected + * @since 3.0.0 + */ + this.text = new BaseCache(); + + /** + * A Cache storing all WaveFront OBJ files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#obj + * @type {Phaser.Cache.BaseCache} + * @protected + * @since 3.0.0 + */ + this.obj = new BaseCache(); + + /** + * A Cache storing all tilemap data files, typically added via the Loader. + * Only the data is stored in this cache, the textures are part of the Texture Manager. + * + * @name Phaser.Cache.CacheManager#tilemap + * @type {Phaser.Cache.BaseCache} + * @protected + * @since 3.0.0 + */ + this.tilemap = new BaseCache(); + + /** + * A Cache storing all xml data files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#xml + * @type {Phaser.Cache.BaseCache} + * @protected + * @since 3.0.0 + */ + this.xml = new BaseCache(); + + /** + * An object that contains your own custom BaseCache entries. + * Add to this via the `addCustom` method. + * + * @name Phaser.Cache.CacheManager#custom + * @type {object.} + * @protected + * @since 3.0.0 + */ + this.custom = {}; + + this.game.events.once('destroy', this.destroy, this); + }, + + /** + * Add your own custom Cache for storing your own files. + * The cache will be available under `Cache.custom.key`. + * The cache will only be created if the key is not already in use. + * + * @method Phaser.Cache.CacheManager#addCustom + * @since 3.0.0 + * + * @param {string} key - The unique key of your custom cache. + * + * @return {Phaser.Cache.BaseCache} A reference to the BaseCache that was created. If the key was already in use, a reference to the existing cache is returned instead. + */ + addCustom: function (key) + { + if (!this.custom.hasOwnProperty(key)) + { + this.custom[key] = new BaseCache(); + } + + return this.custom[key]; + }, + + /** + * Removes all entries from all BaseCaches and destroys all custom caches. + * + * @method Phaser.Cache.CacheManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + var keys = [ + 'binary', + 'bitmapFont', + 'json', + 'physics', + 'shader', + 'audio', + 'text', + 'obj', + 'tilemap', + 'xml' + ]; + + for (var i = 0; i < keys.length; i++) + { + this[keys[i]].destroy(); + this[keys[i]] = null; + } + + for (var key in this.custom) + { + this.custom[key].destroy(); + } + + this.custom = null; + + this.game = null; + } + +}); + +module.exports = CacheManager; + + +/***/ }), +/* 338 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CustomMap = __webpack_require__(159); +var EventEmitter = __webpack_require__(15); + +/** + * @classdesc + * The BaseCache is a base Cache class that can be used for storing references to any kind of data. + * + * Data can be added, retrieved and removed based on the given keys. + * + * Keys are string-based. + * + * @class BaseCache + * @memberOf Phaser.Cache + * @constructor + * @since 3.0.0 + */ +var BaseCache = new Class({ + + initialize: + + function BaseCache () + { + /** + * The Map in which the cache objects are stored. + * + * You can query the Map directly or use the BaseCache methods. + * + * @name Phaser.Cache.BaseCache#entries + * @type {Phaser.Structs.Map} + * @since 3.0.0 + */ + this.entries = new CustomMap(); + + /** + * An instance of EventEmitter used by the cache to emit related events. + * + * @name Phaser.Cache.BaseCache#events + * @type {EventEmitter} + * @since 3.0.0 + */ + this.events = new EventEmitter(); + }, + + /** + * Cache add event. + * + * This event is fired by the Cache each time a new object is added to it. + * + * @event Phaser.Cache.BaseCache#addEvent + * @param {Phaser.Cache.BaseCache} The BaseCache to which the object was added. + * @param {string} The key of the object added to the cache. + * @param {*} A reference to the object added to the cache. + */ + + /** + * Adds an item to this cache. The item is referenced by a unique string, which you are responsible + * for setting and keeping track of. The item can only be retrieved by using this string. + * + * @method Phaser.Cache.BaseCache#add + * @fires Phaser.Cache.BaseCache#addEvent + * @since 3.0.0 + * + * @param {string} key - The unique key by which the data added to the cache will be referenced. + * @param {*} data - The data to be stored in the cache. + * + * @return {Phaser.Cache.BaseCache} This BaseCache object. + */ + add: function (key, data) + { + this.entries.set(key, data); + + this.events.emit('add', this, key, data); + + return this; + }, + + /** + * Checks if this cache contains an item matching the given key. + * + * @method Phaser.Cache.BaseCache#has + * @since 3.0.0 + * + * @param {string} key - The unique key of the item to be checked in this cache. + * + * @return {boolean} Returns `true` if the cache contains an item matching the given key, otherwise `false`. + */ + has: function (key) + { + return this.entries.has(key); + }, + + /** + * Gets an item from this cache based on the given key. + * + * @method Phaser.Cache.BaseCache#get + * @since 3.0.0 + * + * @param {string} key - The unique key of the item to be retrieved from this cache. + * + * @return {*} The item in the cache, or `null` if no item matching the given key was found. + */ + get: function (key) + { + return this.entries.get(key); + }, + + /** + * Cache remove event. + * + * This event is fired by the Cache each time an object is removed from it. + * + * @event Phaser.Cache.BaseCache#removeEvent + * @param {Phaser.Cache.BaseCache} The BaseCache from which the object was removed. + * @param {string} The key of the object removed from the cache. + * @param {*} The object that was removed from the cache. + */ + + /** + * Removes and item from this cache based on the given key. + * + * If an entry matching the key is found it is removed from the cache and a `remove` event emitted. + * No additional checks are done on the item removed. If other systems or parts of your game code + * are relying on this item, it is up to you to sever those relationships prior to removing the item. + * + * @method Phaser.Cache.BaseCache#remove + * @fires Phaser.Cache.BaseCache#removeEvent + * @since 3.0.0 + * + * @param {string} key - The unique key of the item to remove from the cache. + * + * @return {Phaser.Cache.BaseCache} This BaseCache object. + */ + remove: function (key) + { + var entry = this.get(key); + + if (entry) + { + this.entries.delete(key); + + this.events.emit('remove', this, key, entry.data); + } + + return this; + }, + + /** + * Destroys this cache and all items within it. + * + * @method Phaser.Cache.BaseCache#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.entries.clear(); + this.events.removeAllListeners(); + + this.entries = null; + this.events = null; + } + +}); + +module.exports = BaseCache; + + +/***/ }), +/* 339 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Animation = __webpack_require__(341); +var Class = __webpack_require__(0); +var CustomMap = __webpack_require__(159); +var EventEmitter = __webpack_require__(15); +var GetValue = __webpack_require__(5); +var Pad = __webpack_require__(158); + +/** + * @typedef {object} JSONAnimationManager + * + * @property {JSONAnimation[]} anims - [description] + * @property {number} globalTimeScale - [description] + */ + +/** + * @classdesc + * The Animation Manager. + * + * Animations are managed by the global Animation Manager. This is a singleton class that is + * responsible for creating and delivering animations and their corresponding data to all Game Objects. + * Unlike plugins it is owned by the Game instance, not the Scene. + * + * Sprites and other Game Objects get the data they need from the AnimationManager. + * + * @class AnimationManager + * @extends EventEmitter + * @memberOf Phaser.Animations + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - [description] + */ +var AnimationManager = new Class({ + + Extends: EventEmitter, + + initialize: + + function AnimationManager (game) + { + EventEmitter.call(this); + + /** + * [description] + * + * @name Phaser.Animations.AnimationManager#game + * @type {Phaser.Game} + * @protected + * @since 3.0.0 + */ + this.game = game; + + /** + * [description] + * + * @name Phaser.Animations.AnimationManager#textureManager + * @type {Phaser.Textures.TextureManager} + * @protected + * @since 3.0.0 + */ + this.textureManager = null; + + /** + * [description] + * + * @name Phaser.Animations.AnimationManager#globalTimeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.globalTimeScale = 1; + + /** + * [description] + * + * @name Phaser.Animations.AnimationManager#anims + * @type {Phaser.Structs.Map} + * @protected + * @since 3.0.0 + */ + this.anims = new CustomMap(); + + /** + * [description] + * + * @name Phaser.Animations.AnimationManager#paused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.paused = false; + + /** + * [description] + * + * @name Phaser.Animations.AnimationManager#name + * @type {string} + * @since 3.0.0 + */ + this.name = 'AnimationManager'; + + game.events.once('boot', this.boot, this); + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#boot + * @since 3.0.0 + */ + boot: function () + { + this.textureManager = this.game.textures; + + this.game.events.once('destroy', this.destroy, this); + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#add + * @fires AddAnimationEvent + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {Phaser.Animations.Animation} animation - [description] + * + * @return {Phaser.Animations.AnimationManager} This Animation Manager. + */ + add: function (key, animation) + { + if (this.anims.has(key)) + { + console.warn('Animation with key', key, 'already exists'); + return; + } + + animation.key = key; + + this.anims.set(key, animation); + + this.emit('add', key, animation); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#create + * @fires AddAnimationEvent + * @since 3.0.0 + * + * @param {AnimationConfig} config - [description] + * + * @return {Phaser.Animations.Animation} The Animation that was created. + */ + create: function (config) + { + var key = config.key; + + if (!key || this.anims.has(key)) + { + console.warn('Invalid Animation Key, or Key already in use: ' + key); + return; + } + + var anim = new Animation(this, key, config); + + this.anims.set(key, anim); + + this.emit('add', key, anim); + + return anim; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#fromJSON + * @since 3.0.0 + * + * @param {(string|object)} data - [description] + * @param {boolean} [clearCurrentAnimations=false] - [description] + * + * @return {Phaser.Animations.Animation[]} An array containing all of the Animation objects that were created as a result of this call. + */ + fromJSON: function (data, clearCurrentAnimations) + { + if (clearCurrentAnimations === undefined) { clearCurrentAnimations = false; } + + if (clearCurrentAnimations) + { + this.anims.clear(); + } + + // Do we have a String (i.e. from JSON, or an Object?) + if (typeof data === 'string') + { + data = JSON.parse(data); + } + + var output = []; + + // Array of animations, or a single animation? + if (data.hasOwnProperty('anims') && Array.isArray(data.anims)) + { + for (var i = 0; i < data.anims.length; i++) + { + output.push(this.create(data.anims[i])); + } + + if (data.hasOwnProperty('globalTimeScale')) + { + this.globalTimeScale = data.globalTimeScale; + } + } + else if (data.hasOwnProperty('key') && data.type === 'frame') + { + output.push(this.create(data)); + } + + return output; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#generateFrameNames + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {object} config - [description] + * @param {string} [config.prefix=''] - [description] + * @param {integer} [config.start=0] - [description] + * @param {integer} [config.end=0] - [description] + * @param {string} [config.suffix=''] - [description] + * @param {integer} [config.zeroPad=0] - [description] + * @param {array} [config.outputArray=[]] - [description] + * @param {boolean} [config.frames=false] - [description] + * + * @return {AnimationFrameConfig[]} [description] + */ + generateFrameNames: function (key, config) + { + var prefix = GetValue(config, 'prefix', ''); + var start = GetValue(config, 'start', 0); + var end = GetValue(config, 'end', 0); + var suffix = GetValue(config, 'suffix', ''); + var zeroPad = GetValue(config, 'zeroPad', 0); + var out = GetValue(config, 'outputArray', []); + var frames = GetValue(config, 'frames', false); + + var texture = this.textureManager.get(key); + + if (!texture) + { + return out; + } + + var diff = (start < end) ? 1 : -1; + + // Adjust because we use i !== end in the for loop + end += diff; + + var i; + var frame; + + // Have they provided their own custom frame sequence array? + if (Array.isArray(frames)) + { + for (i = 0; i < frames.length; i++) + { + frame = prefix + Pad(frames[i], zeroPad, '0', 1) + suffix; + + if (texture.has(frame)) + { + out.push({ key: key, frame: frame }); + } + } + } + else + { + for (i = start; i !== end; i += diff) + { + frame = prefix + Pad(i, zeroPad, '0', 1) + suffix; + + if (texture.has(frame)) + { + out.push({ key: key, frame: frame }); + } + } + } + + return out; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#generateFrameNumbers + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {object} config - [description] + * @param {integer} [config.start=0] - [description] + * @param {integer} [config.end=-1] - [description] + * @param {boolean} [config.first=false] - [description] + * @param {array} [config.outputArray=[]] - [description] + * @param {boolean} [config.frames=false] - [description] + * + * @return {AnimationFrameConfig[]} [description] + */ + generateFrameNumbers: function (key, config) + { + var startFrame = GetValue(config, 'start', 0); + var endFrame = GetValue(config, 'end', -1); + var firstFrame = GetValue(config, 'first', false); + var out = GetValue(config, 'outputArray', []); + var frames = GetValue(config, 'frames', false); + + var texture = this.textureManager.get(key); + + if (!texture) + { + return out; + } + + if (firstFrame && texture.has(firstFrame)) + { + out.push({ key: key, frame: firstFrame }); + } + + var i; + + // Have they provided their own custom frame sequence array? + if (Array.isArray(frames)) + { + for (i = 0; i < frames.length; i++) + { + if (texture.has(frames[i])) + { + out.push({ key: key, frame: frames[i] }); + } + } + } + else + { + // No endFrame then see if we can get it + + if (endFrame === -1) + { + endFrame = texture.frameTotal; + } + + for (i = startFrame; i <= endFrame; i++) + { + if (texture.has(i)) + { + out.push({ key: key, frame: i }); + } + } + } + + return out; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#get + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Animations.Animation} [description] + */ + get: function (key) + { + return this.anims.get(key); + }, + + /** + * Load an Animation into a Game Objects Animation Component. + * + * @method Phaser.Animations.AnimationManager#load + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - [description] + * @param {string} key - [description] + * @param {(string|integer)} [startFrame] - [description] + * + * @return {Phaser.GameObjects.GameObject} [description] + */ + load: function (child, key, startFrame) + { + var anim = this.get(key); + + if (anim) + { + anim.load(child, startFrame); + } + + return child; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#pauseAll + * @fires PauseAllAnimationEvent + * @since 3.0.0 + * + * @return {Phaser.Animations.AnimationManager} This Animation Manager. + */ + pauseAll: function () + { + if (!this.paused) + { + this.paused = true; + + this.emit('pauseall'); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#play + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {Phaser.GameObjects.GameObject} child - [description] + * + * @return {Phaser.Animations.AnimationManager} This Animation Manager. + */ + play: function (key, child) + { + if (!Array.isArray(child)) + { + child = [ child ]; + } + + var anim = this.get(key); + + if (!anim) + { + return; + } + + for (var i = 0; i < child.length; i++) + { + child[i].anims.play(key); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#remove + * @fires RemoveAnimationEvent + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Animations.Animation} [description] + */ + remove: function (key) + { + var anim = this.get(key); + + if (anim) + { + this.emit('remove', key, anim); + + this.anims.delete(key); + } + + return anim; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#resumeAll + * @fires ResumeAllAnimationEvent + * @since 3.0.0 + * + * @return {Phaser.Animations.AnimationManager} This Animation Manager. + */ + resumeAll: function () + { + if (this.paused) + { + this.paused = false; + + this.emit('resumeall'); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#staggerPlay + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {Phaser.GameObjects.GameObject} child - [description] + * @param {number} [stagger=0] - [description] + * + * @return {Phaser.Animations.AnimationManager} This Animation Manager. + */ + staggerPlay: function (key, child, stagger) + { + if (stagger === undefined) { stagger = 0; } + + if (!Array.isArray(child)) + { + child = [ child ]; + } + + var anim = this.get(key); + + if (!anim) + { + return; + } + + for (var i = 0; i < child.length; i++) + { + child[i].anims.delayedPlay(stagger * i, key); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#toJSON + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {JSONAnimationManager} [description] + */ + toJSON: function (key) + { + if (key !== undefined && key !== '') + { + return this.anims.get(key).toJSON(); + } + else + { + var output = { + anims: [], + globalTimeScale: this.globalTimeScale + }; + + this.anims.each(function (animationKey, animation) + { + output.anims.push(animation.toJSON()); + }); + + return output; + } + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.anims.clear(); + + this.textureManager = null; + + this.game = null; + } + +}); + +module.exports = AnimationManager; + + +/***/ }), +/* 340 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @typedef {object} JSONAnimationFrame + * + * @property {string} key - The key of the Texture this AnimationFrame uses. + * @property {(string|integer)} frame - The key of the Frame within the Texture that this AnimationFrame uses. + * @property {number} duration - Additional time (in ms) that this frame should appear for during playback. + */ + +/** + * @classdesc + * A single frame in an Animation sequence. + * + * An AnimationFrame consists of a reference to the Texture it uses for rendering, references to other + * frames in the animation, and index data. It also has the ability to fire its own `onUpdate` callback + * and modify the animation timing. + * + * AnimationFrames are generated automatically by the Animation class. + * + * @class AnimationFrame + * @memberOf Phaser.Animations + * @constructor + * @since 3.0.0 + * + * @param {string} textureKey - The key of the Texture this AnimationFrame uses. + * @param {(string|integer)} textureFrame - The key of the Frame within the Texture that this AnimationFrame uses. + * @param {integer} index - The index of this AnimationFrame within the Animation sequence. + * @param {Phaser.Textures.Frame} frame - A reference to the Texture Frame this AnimationFrame uses for rendering. + */ +var AnimationFrame = new Class({ + + initialize: + + function AnimationFrame (textureKey, textureFrame, index, frame) + { + /** + * The key of the Texture this AnimationFrame uses. + * + * @name Phaser.Animations.AnimationFrame#textureKey + * @type {string} + * @since 3.0.0 + */ + this.textureKey = textureKey; + + /** + * The key of the Frame within the Texture that this AnimationFrame uses. + * + * @name Phaser.Animations.AnimationFrame#textureFrame + * @type {(string|integer)} + * @since 3.0.0 + */ + this.textureFrame = textureFrame; + + /** + * The index of this AnimationFrame within the Animation sequence. + * + * @name Phaser.Animations.AnimationFrame#index + * @type {integer} + * @since 3.0.0 + */ + this.index = index; + + /** + * A reference to the Texture Frame this AnimationFrame uses for rendering. + * + * @name Phaser.Animations.AnimationFrame#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + this.frame = frame; + + /** + * Is this the first frame in an animation sequence? + * + * @name Phaser.Animations.AnimationFrame#isFirst + * @type {boolean} + * @default false + * @readOnly + * @since 3.0.0 + */ + this.isFirst = false; + + /** + * Is this the last frame in an animation sequence? + * + * @name Phaser.Animations.AnimationFrame#isLast + * @type {boolean} + * @default false + * @readOnly + * @since 3.0.0 + */ + this.isLast = false; + + /** + * A reference to the AnimationFrame that comes before this one in the animation, if any. + * + * @name Phaser.Animations.AnimationFrame#prevFrame + * @type {?Phaser.Animations.AnimationFrame} + * @default null + * @readOnly + * @since 3.0.0 + */ + this.prevFrame = null; + + /** + * A reference to the AnimationFrame that comes after this one in the animation, if any. + * + * @name Phaser.Animations.AnimationFrame#nextFrame + * @type {?Phaser.Animations.AnimationFrame} + * @default null + * @readOnly + * @since 3.0.0 + */ + this.nextFrame = null; + + /** + * Additional time (in ms) that this frame should appear for during playback. + * The value is added onto the msPerFrame set by the animation. + * + * @name Phaser.Animations.AnimationFrame#duration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.duration = 0; + + /** + * What % through the animation does this frame come? + * This value is generated when the animation is created and cached here. + * + * @name Phaser.Animations.AnimationFrame#progress + * @type {number} + * @default 0 + * @readOnly + * @since 3.0.0 + */ + this.progress = 0; + + /** + * A frame specific callback, invoked if this frame gets displayed and the callback is set. + * + * @name Phaser.Animations.AnimationFrame#onUpdate + * @type {?function} + * @default null + * @since 3.0.0 + */ + this.onUpdate = null; + }, + + /** + * Generates a JavaScript object suitable for converting to JSON. + * + * @method Phaser.Animations.AnimationFrame#toJSON + * @since 3.0.0 + * + * @return {JSONAnimationFrame} The AnimationFrame data. + */ + toJSON: function () + { + return { + key: this.textureKey, + frame: this.textureFrame, + duration: this.duration + }; + }, + + /** + * Destroys this object by removing references to external resources and callbacks. + * + * @method Phaser.Animations.AnimationFrame#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.frame = undefined; + this.onUpdate = undefined; + } + +}); + +module.exports = AnimationFrame; + + +/***/ }), +/* 341 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Frame = __webpack_require__(340); +var GetValue = __webpack_require__(5); + +/** + * @typedef {object} JSONAnimation + * + * @property {string} key - [description] + * @property {string} type - A frame based animation (as opposed to a bone based animation) + * @property {JSONAnimationFrame[]} frames - [description] + * @property {integer} frameRate - The frame rate of playback in frames per second (default 24 if duration is null) + * @property {integer} duration - How long the animation should play for. + * @property {boolean} skipMissedFrames - Skip frames if the time lags, or always advanced anyway? + * @property {integer} delay - Delay before starting playback (in seconds) + * @property {integer} repeat - Number of times to repeat the animation (-1 for infinity) + * @property {integer} repeatDelay - Delay before the repeat starts (in seconds) + * @property {boolean} yoyo - Should the animation yoyo? (reverse back down to the start) before repeating? + * @property {boolean} showOnStart - Should sprite.visible = true when the animation starts to play? + * @property {boolean} hideOnComplete - Should sprite.visible = false when the animation finishes? + */ + +/** + * @typedef {object} AnimationFrameConfig + * + * @property {string} key - [description] + * @property {(string|number)} frame - [description] + * @property {float} [duration=0] - [description] + * @property {boolean} [visible] - [description] + * @property {function} [onUpdate] - [description] + */ + +/** + * @typedef {object} AnimationConfig // TODO 19/03/2018 fix type + * + * @property {AnimationFrameConfig[]} [frames] - [description] + * @property {string} [defaultTextureKey=null] - [description] + * @property {integer} [frameRate] - The frame rate of playback in frames per second (default 24 if duration is null) + * @property {integer} [duration] - How long the animation should play for. + * @property {boolean} [skipMissedFrames=true] - Skip frames if the time lags, or always advanced anyway? + * @property {integer} [delay=0] - Delay before starting playback (in seconds) + * @property {integer} [repeat=0] - Number of times to repeat the animation (-1 for infinity) + * @property {integer} [repeatDelay=0] - Delay before the repeat starts (in seconds) + * @property {boolean} [yoyo=false] - Should the animation yoyo? (reverse back down to the start) before repeating? + * @property {boolean} [showOnStart=false] - Should sprite.visible = true when the animation starts to play? + * @property {boolean} [hideOnComplete=false] - Should sprite.visible = false when the animation finishes? + * @property {object} [callbackScope] - [description] + * @property {boolean} [onStart=false] - [description] + * @property {array} [onStartParams] - [description] + * @property {boolean} [onRepeat=false] - [description] + * @property {array} [onRepeatParams] - [description] + * @property {boolean} [onUpdate=false] - [description] + * @property {array} [onUpdateParams] - [description] + * @property {boolean} [onComplete=false] - [description] + * @property {array} [onCompleteParams] - [description] + */ + +/** + * @classdesc + * A Frame based Animation. + * + * This consists of a key, some default values (like the frame rate) and a bunch of Frame objects. + * + * The Animation Manager creates these. Game Objects don't own an instance of these directly. + * Game Objects have the Animation Component, which are like playheads to global Animations (these objects) + * So multiple Game Objects can have playheads all pointing to this one Animation instance. + * + * @class Animation + * @memberOf Phaser.Animations + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationManager} manager - [description] + * @param {string} key - [description] + * @param {AnimationConfig} config - [description] + */ +var Animation = new Class({ + + initialize: + + function Animation (manager, key, config) + { + /** + * [description] + * + * @name Phaser.Animations.Animation#manager + * @type {Phaser.Animations.AnimationManager} + * @since 3.0.0 + */ + this.manager = manager; + + /** + * [description] + * + * @name Phaser.Animations.Animation#key + * @type {string} + * @since 3.0.0 + */ + this.key = key; + + /** + * A frame based animation (as opposed to a bone based animation) + * + * @name Phaser.Animations.Animation#type + * @type {string} + * @default frame + * @since 3.0.0 + */ + this.type = 'frame'; + + /** + * Extract all the frame data into the frames array + * + * @name Phaser.Animations.Animation#frames + * @type {Phaser.Animations.AnimationFrame[]} + * @since 3.0.0 + */ + this.frames = this.getFrames( + manager.textureManager, + GetValue(config, 'frames', []), + GetValue(config, 'defaultTextureKey', null) + ); + + /** + * The frame rate of playback in frames per second (default 24 if duration is null) + * + * @name Phaser.Animations.Animation#frameRate + * @type {integer} + * @default 24 + * @since 3.0.0 + */ + this.frameRate = GetValue(config, 'frameRate', null); + + /** + * How long the animation should play for. + * If frameRate is set it overrides this value otherwise frameRate is derived from duration. + * + * @name Phaser.Animations.Animation#duration + * @type {integer} + * @since 3.0.0 + */ + this.duration = GetValue(config, 'duration', null); + + if (this.duration === null && this.frameRate === null) + { + // No duration or frameRate given, use default frameRate of 24fps + this.frameRate = 24; + this.duration = this.frameRate / this.frames.length; + } + else if (this.duration && this.frameRate === null) + { + // Duration given but no frameRate, so set the frameRate based on duration + // I.e. 12 frames in the animation, duration = 4 (4000 ms) + // So frameRate is 12 / 4 = 3 fps + this.frameRate = this.frames.length / this.duration; + } + else + { + // frameRate given, derive duration from it (even if duration also specified) + // I.e. 15 frames in the animation, frameRate = 30 fps + // So duration is 15 / 30 = 0.5 (half a second) + this.duration = this.frames.length / this.frameRate; + } + + /** + * ms per frame (without including frame specific modifiers) + * + * @name Phaser.Animations.Animation#msPerFrame + * @type {integer} + * @since 3.0.0 + */ + this.msPerFrame = 1000 / this.frameRate; + + /** + * Skip frames if the time lags, or always advanced anyway? + * + * @name Phaser.Animations.Animation#skipMissedFrames + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.skipMissedFrames = GetValue(config, 'skipMissedFrames', true); + + /** + * Delay before starting playback (in seconds) + * + * @name Phaser.Animations.Animation#delay + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.delay = GetValue(config, 'delay', 0); + + /** + * Number of times to repeat the animation (-1 for infinity) + * + * @name Phaser.Animations.Animation#repeat + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.repeat = GetValue(config, 'repeat', 0); + + /** + * Delay before the repeat starts (in seconds) + * + * @name Phaser.Animations.Animation#repeatDelay + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.repeatDelay = GetValue(config, 'repeatDelay', 0); + + /** + * Should the animation yoyo? (reverse back down to the start) before repeating? + * + * @name Phaser.Animations.Animation#yoyo + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.yoyo = GetValue(config, 'yoyo', false); + + /** + * Should sprite.visible = true when the animation starts to play? + * + * @name Phaser.Animations.Animation#showOnStart + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.showOnStart = GetValue(config, 'showOnStart', false); + + /** + * Should sprite.visible = false when the animation finishes? + * + * @name Phaser.Animations.Animation#hideOnComplete + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.hideOnComplete = GetValue(config, 'hideOnComplete', false); + + /** + * [description] + * + * @name Phaser.Animations.Animation#callbackScope + * @type {object} + * @since 3.0.0 + */ + this.callbackScope = GetValue(config, 'callbackScope', this); + + /** + * [description] + * + * @name Phaser.Animations.Animation#onStart + * @type {function} + * @since 3.0.0 + */ + this.onStart = GetValue(config, 'onStart', false); + + /** + * [description] + * + * @name Phaser.Animations.Animation#onStartParams + * @type {array} + * @since 3.0.0 + */ + this.onStartParams = GetValue(config, 'onStartParams', []); + + /** + * [description] + * + * @name Phaser.Animations.Animation#onRepeat + * @type {function} + * @since 3.0.0 + */ + this.onRepeat = GetValue(config, 'onRepeat', false); + + /** + * [description] + * + * @name Phaser.Animations.Animation#onRepeatParams + * @type {array} + * @since 3.0.0 + */ + this.onRepeatParams = GetValue(config, 'onRepeatParams', []); + + /** + * Called for EVERY frame of the animation. + * See AnimationFrame.onUpdate for a frame specific callback. + * + * @name Phaser.Animations.Animation#onUpdate + * @type {function} + * @since 3.0.0 + */ + this.onUpdate = GetValue(config, 'onUpdate', false); + + /** + * [description] + * + * @name Phaser.Animations.Animation#onUpdateParams + * @type {array} + * @since 3.0.0 + */ + this.onUpdateParams = GetValue(config, 'onUpdateParams', []); + + /** + * [description] + * + * @name Phaser.Animations.Animation#onComplete + * @type {function} + * @since 3.0.0 + */ + this.onComplete = GetValue(config, 'onComplete', false); + + /** + * [description] + * + * @name Phaser.Animations.Animation#onCompleteParams + * @type {array} + * @since 3.0.0 + */ + this.onCompleteParams = GetValue(config, 'onCompleteParams', []); + + /** + * Global pause, effects all Game Objects using this Animation instance + * + * @name Phaser.Animations.Animation#paused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.paused = false; + + this.manager.on('pauseall', this.pause.bind(this)); + this.manager.on('resumeall', this.resume.bind(this)); + }, + + // Add frames to the end of the animation + + /** + * [description] + * + * @method Phaser.Animations.Animation#addFrame + * @since 3.0.0 + * + * @param {(string|AnimationFrameConfig[])} config - [description] + * + * @return {Phaser.Animations.Animation} This Animation object. + */ + addFrame: function (config) + { + return this.addFrameAt(this.frames.length, config); + }, + + // Add frame/s into the animation + + /** + * [description] + * + * @method Phaser.Animations.Animation#addFrameAt + * @since 3.0.0 + * + * @param {integer} index - [description] + * @param {(string|AnimationFrameConfig[])} config - [description] + * + * @return {Phaser.Animations.Animation} This Animation object. + */ + addFrameAt: function (index, config) + { + var newFrames = this.getFrames(this.manager.textureManager, config); + + if (newFrames.length > 0) + { + if (index === 0) + { + this.frames = newFrames.concat(this.frames); + } + else if (index === this.frames.length) + { + this.frames = this.frames.concat(newFrames); + } + else + { + var pre = this.frames.slice(0, index); + var post = this.frames.slice(index); + + this.frames = pre.concat(newFrames, post); + } + + this.updateFrameSequence(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#checkFrame + * @since 3.0.0 + * + * @param {integer} index - [description] + * + * @return {boolean} [description] + */ + checkFrame: function (index) + { + return (index < this.frames.length); + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#completeAnimation + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - [description] + */ + completeAnimation: function (component) + { + if (this.hideOnComplete) + { + component.parent.visible = false; + } + + component.stop(true); + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#getFirstTick + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - [description] + * @param {boolean} [includeDelay=true] - [description] + */ + getFirstTick: function (component, includeDelay) + { + if (includeDelay === undefined) { includeDelay = true; } + + // When is the first update due? + component.accumulator = 0; + component.nextTick = component.msPerFrame + component.currentFrame.duration; + + if (includeDelay) + { + component.nextTick += (component._delay * 1000); + } + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#getFrameAt + * @since 3.0.0 + * + * @param {integer} index - [description] + * + * @return {Phaser.Animations.AnimationFrame} [description] + */ + getFrameAt: function (index) + { + return this.frames[index]; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#getFrames + * @since 3.0.0 + * + * @param {Phaser.Textures.TextureManager} textureManager - [description] + * @param {(string|AnimationFrameConfig[])} frames - [description] + * @param {string} [defaultTextureKey] - [description] + * + * @return {Phaser.Animations.AnimationFrame[]} [description] + */ + getFrames: function (textureManager, frames, defaultTextureKey) + { + var out = []; + var prev; + var animationFrame; + var index = 1; + var i; + var textureKey; + + // if frames is a string, we'll get all the frames from the texture manager as if it's a sprite sheet + if (typeof frames === 'string') + { + textureKey = frames; + + var texture = textureManager.get(textureKey); + var frameKeys = texture.getFrameNames(); + + frames = []; + + frameKeys.forEach(function (idx, value) + { + frames.push({ key: textureKey, frame: value }); + }); + } + + if (!Array.isArray(frames) || frames.length === 0) + { + return out; + } + + for (i = 0; i < frames.length; i++) + { + var item = frames[i]; + + var key = GetValue(item, 'key', defaultTextureKey); + + if (!key) + { + continue; + } + + // Could be an integer or a string + var frame = GetValue(item, 'frame', 0); + + // The actual texture frame + var textureFrame = textureManager.getFrame(key, frame); + + animationFrame = new Frame(key, frame, index, textureFrame); + + animationFrame.duration = GetValue(item, 'duration', 0); + animationFrame.onUpdate = GetValue(item, 'onUpdate', null); + + animationFrame.isFirst = (!prev); + + // The previously created animationFrame + if (prev) + { + prev.nextFrame = animationFrame; + + animationFrame.prevFrame = prev; + } + + out.push(animationFrame); + + prev = animationFrame; + + index++; + } + + if (out.length > 0) + { + animationFrame.isLast = true; + + // Link them end-to-end, so they loop + animationFrame.nextFrame = out[0]; + + out[0].prevFrame = animationFrame; + + // Generate the progress data + + var slice = 1 / (out.length - 1); + + for (i = 0; i < out.length; i++) + { + out[i].progress = i * slice; + } + } + + return out; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#getNextTick + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - [description] + */ + getNextTick: function (component) + { + // accumulator += delta * _timeScale + // after a large delta surge (perf issue for example) we need to adjust for it here + + // When is the next update due? + component.accumulator -= component.nextTick; + + component.nextTick = component.msPerFrame + component.currentFrame.duration; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#load + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - [description] + * @param {integer} startFrame - [description] + */ + load: function (component, startFrame) + { + if (startFrame >= this.frames.length) + { + startFrame = 0; + } + + if (component.currentAnim !== this) + { + component.currentAnim = this; + + component._timeScale = 1; + component.frameRate = this.frameRate; + component.duration = this.duration; + component.msPerFrame = this.msPerFrame; + component.skipMissedFrames = this.skipMissedFrames; + component._delay = this.delay; + component._repeat = this.repeat; + component._repeatDelay = this.repeatDelay; + component._yoyo = this.yoyo; + component._callbackArgs[1] = this; + component._updateParams = component._callbackArgs.concat(this.onUpdateParams); + } + + component.updateFrame(this.frames[startFrame]); + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#nextFrame + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - [description] + */ + nextFrame: function (component) + { + var frame = component.currentFrame; + + // TODO: Add frame skip support + + if (frame.isLast) + { + // We're at the end of the animation + + // Yoyo? (happens before repeat) + if (this.yoyo) + { + component.forward = false; + + component.updateFrame(frame.prevFrame); + + // Delay for the current frame + this.getNextTick(component); + } + else if (component.repeatCounter > 0) + { + // Repeat (happens before complete) + this.repeatAnimation(component); + } + else + { + this.completeAnimation(component); + } + } + else + { + component.updateFrame(frame.nextFrame); + + this.getNextTick(component); + } + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#previousFrame + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - [description] + */ + previousFrame: function (component) + { + var frame = component.currentFrame; + + // TODO: Add frame skip support + + if (frame.isFirst) + { + // We're at the start of the animation + + if (component.repeatCounter > 0) + { + // Repeat (happens before complete) + this.repeatAnimation(component); + } + else + { + this.completeAnimation(component); + } + } + else + { + component.updateFrame(frame.prevFrame); + + this.getNextTick(component); + } + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#removeFrame + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationFrame} frame - [description] + * + * @return {Phaser.Animations.Animation} This Animation object. + */ + removeFrame: function (frame) + { + var index = this.frames.indexOf(frame); + + if (index !== -1) + { + this.removeFrameAt(index); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#removeFrameAt + * @since 3.0.0 + * + * @param {integer} index - [description] + * + * @return {Phaser.Animations.Animation} This Animation object. + */ + removeFrameAt: function (index) + { + this.frames.splice(index, 1); + + this.updateFrameSequence(); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#repeatAnimation + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - [description] + */ + repeatAnimation: function (component) + { + if (component._repeatDelay > 0 && component.pendingRepeat === false) + { + component.pendingRepeat = true; + component.accumulator -= component.nextTick; + component.nextTick += (component._repeatDelay * 1000); + } + else + { + component.repeatCounter--; + + component.forward = true; + + component.updateFrame(component.currentFrame.nextFrame); + + this.getNextTick(component); + + component.pendingRepeat = false; + + if (this.onRepeat) + { + this.onRepeat.apply(this.callbackScope, component._callbackArgs.concat(this.onRepeatParams)); + } + } + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#setFrame + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - [description] + */ + setFrame: function (component) + { + // Work out which frame should be set next on the child, and set it + if (component.forward) + { + this.nextFrame(component); + } + else + { + this.previousFrame(component); + } + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#toJSON + * @since 3.0.0 + * + * @return {JSONAnimation} [description] + */ + toJSON: function () + { + var output = { + key: this.key, + type: this.type, + frames: [], + frameRate: this.frameRate, + duration: this.duration, + skipMissedFrames: this.skipMissedFrames, + delay: this.delay, + repeat: this.repeat, + repeatDelay: this.repeatDelay, + yoyo: this.yoyo, + showOnStart: this.showOnStart, + hideOnComplete: this.hideOnComplete + }; + + this.frames.forEach(function (frame) + { + output.frames.push(frame.toJSON()); + }); + + return output; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#updateFrameSequence + * @since 3.0.0 + * + * @return {Phaser.Animations.Animation} This Animation object. + */ + updateFrameSequence: function () + { + var len = this.frames.length; + var slice = 1 / (len - 1); + + for (var i = 0; i < len; i++) + { + var frame = this.frames[i]; + + frame.index = i + 1; + frame.isFirst = false; + frame.isLast = false; + frame.progress = i * slice; + + if (i === 0) + { + frame.isFirst = true; + frame.isLast = (len === 1); + frame.prevFrame = this.frames[len - 1]; + frame.nextFrame = this.frames[i + 1]; + } + else if (i === len - 1) + { + frame.isLast = true; + frame.prevFrame = this.frames[len - 2]; + frame.nextFrame = this.frames[0]; + } + else if (len > 1) + { + frame.prevFrame = this.frames[i - 1]; + frame.nextFrame = this.frames[i + 1]; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#pause + * @since 3.0.0 + * + * @return {Phaser.Animations.Animation} This Animation object. + */ + pause: function () + { + this.paused = true; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#resume + * @since 3.0.0 + * + * @return {Phaser.Animations.Animation} This Animation object. + */ + resume: function () + { + this.paused = false; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#destroy + * @since 3.0.0 + */ + destroy: function () + { + // TODO + } + +}); + +module.exports = Animation; + + +/***/ }), +/* 342 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.SmoothStep + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} min - [description] + * @param {number} max - [description] + * + * @return {number} [description] + */ +var SmoothStep = function (x, min, max) +{ + x = Math.max(0, Math.min(1, (x - min) / (max - min))); + + return x * x * (3 - 2 * x); +}; + +module.exports = SmoothStep; + + +/***/ }), +/* 343 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.SmootherStep + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} min - [description] + * @param {number} max - [description] + * + * @return {number} [description] + */ +var SmootherStep = function (x, min, max) +{ + x = Math.max(0, Math.min(1, (x - min) / (max - min))); + + return x * x * x * (x * (x * 6 - 15) + 10); +}; + +module.exports = SmootherStep; + + +/***/ }), +/* 344 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Using Bresenham's line algorithm this will return an array of all coordinates on this line. + * The start and end points are rounded before this runs as the algorithm works on integers. + * + * @function Phaser.Geom.Line.BresenhamPoints + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {integer} [stepRate=1] - [description] + * @param {array} [results] - [description] + * + * @return {array} [description] + */ +var BresenhamPoints = function (line, stepRate, results) +{ + if (stepRate === undefined) { stepRate = 1; } + if (results === undefined) { results = []; } + + var x1 = Math.round(line.x1); + var y1 = Math.round(line.y1); + var x2 = Math.round(line.x2); + var y2 = Math.round(line.y2); + + var dx = Math.abs(x2 - x1); + var dy = Math.abs(y2 - y1); + var sx = (x1 < x2) ? 1 : -1; + var sy = (y1 < y2) ? 1 : -1; + var err = dx - dy; + + results.push({ x: x1, y: y1 }); + + var i = 1; + + while (!((x1 === x2) && (y1 === y2))) + { + var e2 = err << 1; + + if (e2 > -dy) + { + err -= dy; + x1 += sx; + } + + if (e2 < dx) + { + err += dx; + y1 += sy; + } + + if (i % stepRate === 0) + { + results.push({ x: x1, y: y1 }); + } + + i++; + } + + return results; +}; + +module.exports = BresenhamPoints; + + +/***/ }), +/* 345 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Moves the element at the end of the array to the start, shifting all items in the process. + * The "rotation" happens to the right. + * + * @function Phaser.Utils.Array.RotateRight + * @since 3.0.0 + * + * @param {array} array - The array to shift to the right. This array is modified in place. + * @param {integer} [total=1] - The number of times to shift the array. + * + * @return {*} The most recently shifted element. + */ +var RotateRight = function (array, total) +{ + if (total === undefined) { total = 1; } + + var element = null; + + for (var i = 0; i < total; i++) + { + element = array.pop(); + array.unshift(element); + } + + return element; +}; + +module.exports = RotateRight; + + +/***/ }), +/* 346 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Moves the element at the start of the array to the end, shifting all items in the process. + * The "rotation" happens to the left. + * + * @function Phaser.Utils.Array.RotateLeft + * @since 3.0.0 + * + * @param {array} array - The array to shift to the left. This array is modified in place. + * @param {integer} [total=1] - The number of times to shift the array. + * + * @return {*} The most recently shifted element. + */ +var RotateLeft = function (array, total) +{ + if (total === undefined) { total = 1; } + + var element = null; + + for (var i = 0; i < total; i++) + { + element = array.shift(); + array.push(element); + } + + return element; +}; + +module.exports = RotateLeft; + + +/***/ }), +/* 347 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Perimeter = __webpack_require__(105); +var Point = __webpack_require__(4); + +// Return an array of points from the perimeter of the rectangle +// each spaced out based on the quantity or step required + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.MarchingAnts + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} step - [description] + * @param {integer} quantity - [description] + * @param {array} [out] - [description] + * + * @return {Phaser.Geom.Point[]} [description] + */ +var MarchingAnts = function (rect, step, quantity, out) +{ + if (out === undefined) { out = []; } + + if (!step && !quantity) + { + // Bail out + return out; + } + + // If step is a falsey value (false, null, 0, undefined, etc) then we calculate + // it based on the quantity instead, otherwise we always use the step value + if (!step) + { + step = Perimeter(rect) / quantity; + } + else + { + quantity = Math.round(Perimeter(rect) / step); + } + + var x = rect.x; + var y = rect.y; + var face = 0; + + // Loop across each face of the rectangle + + for (var i = 0; i < quantity; i++) + { + out.push(new Point(x, y)); + + switch (face) + { + + // Top face + case 0: + x += step; + + if (x >= rect.right) + { + face = 1; + y += (x - rect.right); + x = rect.right; + } + break; + + // Right face + case 1: + y += step; + + if (y >= rect.bottom) + { + face = 2; + x -= (y - rect.bottom); + y = rect.bottom; + } + break; + + // Bottom face + case 2: + x -= step; + + if (x <= rect.left) + { + face = 3; + y -= (rect.left - x); + x = rect.left; + } + break; + + // Left face + case 3: + y -= step; + + if (y <= rect.top) + { + face = 0; + y = rect.top; + } + break; + } + } + + return out; +}; + +module.exports = MarchingAnts; + + +/***/ }), +/* 348 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * [description] + * + * @class TransformMatrix + * @memberOf Phaser.GameObjects.Components + * @constructor + * @since 3.0.0 + * + * @param {number} [a=1] - [description] + * @param {number} [b=0] - [description] + * @param {number} [c=0] - [description] + * @param {number} [d=1] - [description] + * @param {number} [tx=0] - [description] + * @param {number} [ty=0] - [description] + */ +var TransformMatrix = new Class({ + + initialize: + + function TransformMatrix (a, b, c, d, tx, ty) + { + if (a === undefined) { a = 1; } + if (b === undefined) { b = 0; } + if (c === undefined) { c = 0; } + if (d === undefined) { d = 1; } + if (tx === undefined) { tx = 0; } + if (ty === undefined) { ty = 0; } + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TransformMatrix#matrix + * @type {Float32Array} + * @since 3.0.0 + */ + this.matrix = new Float32Array([ a, b, c, d, tx, ty, 0, 0, 1 ]); + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TransformMatrix#decomposedMatrix + * @type {object} + * @since 3.0.0 + */ + this.decomposedMatrix = { + translateX: 0, + translateY: 0, + scaleX: 1, + scaleY: 1, + rotation: 0 + }; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TransformMatrix#loadIdentity + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. + */ + loadIdentity: function () + { + var matrix = this.matrix; + + matrix[0] = 1; + matrix[1] = 0; + matrix[2] = 0; + matrix[3] = 1; + matrix[4] = 0; + matrix[5] = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TransformMatrix#translate + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. + */ + translate: function (x, y) + { + var matrix = this.matrix; + + matrix[4] = matrix[0] * x + matrix[2] * y + matrix[4]; + matrix[5] = matrix[1] * x + matrix[3] * y + matrix[5]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TransformMatrix#scale + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. + */ + scale: function (x, y) + { + var matrix = this.matrix; + + matrix[0] *= x; + matrix[1] *= x; + matrix[2] *= y; + matrix[3] *= y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TransformMatrix#rotate + * @since 3.0.0 + * + * @param {number} radian - [description] + * + * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. + */ + rotate: function (radian) + { + var radianSin = Math.sin(radian); + var radianCos = Math.cos(radian); + + return this.transform(radianCos, radianSin, -radianSin, radianCos, 0, 0); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TransformMatrix#multiply + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} rhs - [description] + * + * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. + */ + multiply: function (rhs) + { + var matrix = this.matrix; + var otherMatrix = rhs.matrix; + + var a0 = matrix[0]; + var b0 = matrix[1]; + var c0 = matrix[2]; + var d0 = matrix[3]; + var tx0 = matrix[4]; + var ty0 = matrix[5]; + + var a1 = otherMatrix[0]; + var b1 = otherMatrix[1]; + var c1 = otherMatrix[2]; + var d1 = otherMatrix[3]; + var tx1 = otherMatrix[4]; + var ty1 = otherMatrix[5]; + + matrix[0] = a1 * a0 + b1 * c0; + matrix[1] = a1 * b0 + b1 * d0; + matrix[2] = c1 * a0 + d1 * c0; + matrix[3] = c1 * b0 + d1 * d0; + matrix[4] = tx1 * a0 + ty1 * c0 + tx0; + matrix[5] = tx1 * b0 + ty1 * d0 + ty0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TransformMatrix#transform + * @since 3.0.0 + * + * @param {number} a - [description] + * @param {number} b - [description] + * @param {number} c - [description] + * @param {number} d - [description] + * @param {number} tx - [description] + * @param {number} ty - [description] + * + * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. + */ + transform: function (a, b, c, d, tx, ty) + { + var matrix = this.matrix; + + var a0 = matrix[0]; + var b0 = matrix[1]; + var c0 = matrix[2]; + var d0 = matrix[3]; + var tx0 = matrix[4]; + var ty0 = matrix[5]; + + matrix[0] = a * a0 + b * c0; + matrix[1] = a * b0 + b * d0; + matrix[2] = c * a0 + d * c0; + matrix[3] = c * b0 + d * d0; + matrix[4] = tx * a0 + ty * c0 + tx0; + matrix[5] = tx * b0 + ty * d0 + ty0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TransformMatrix#transformPoint + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} point - [description] + * + * @return {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} [description] + */ + transformPoint: function (x, y, point) + { + if (point === undefined) { point = { x: 0, y: 0 }; } + + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + var tx = matrix[4]; + var ty = matrix[5]; + + point.x = x * a + y * c + tx; + point.y = x * b + y * d + ty; + + return point; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TransformMatrix#invert + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. + */ + invert: function () + { + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + var tx = matrix[4]; + var ty = matrix[5]; + + var n = a * d - b * c; + + matrix[0] = d / n; + matrix[1] = -b / n; + matrix[2] = -c / n; + matrix[3] = a / n; + matrix[4] = (c * ty - d * tx) / n; + matrix[5] = -(a * ty - b * tx) / n; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TransformMatrix#setTransform + * @since 3.0.0 + * + * @param {number} a - [description] + * @param {number} b - [description] + * @param {number} c - [description] + * @param {number} d - [description] + * @param {number} tx - [description] + * @param {number} ty - [description] + * + * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. + */ + setTransform: function (a, b, c, d, tx, ty) + { + var matrix = this.matrix; + + matrix[0] = a; + matrix[1] = b; + matrix[2] = c; + matrix[3] = d; + matrix[4] = tx; + matrix[5] = ty; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TransformMatrix#decomposeMatrix + * @since 3.0.0 + * + * @return {object} [description] + */ + decomposeMatrix: function () + { + var decomposedMatrix = this.decomposedMatrix; + + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + + var a2 = a * a; + var b2 = b * b; + var c2 = c * c; + var d2 = d * d; + + var sx = Math.sqrt(a2 + c2); + var sy = Math.sqrt(b2 + d2); + + decomposedMatrix.translateX = matrix[4]; + decomposedMatrix.translateY = matrix[5]; + + decomposedMatrix.scaleX = sx; + decomposedMatrix.scaleY = sy; + + decomposedMatrix.rotation = Math.acos(a / sx) * (Math.atan(-c / a) < 0 ? -1 : 1); + + return decomposedMatrix; + }, + + /** + * Identity + Translate + Rotate + Scale + * + * @method Phaser.GameObjects.Components.TransformMatrix#applyITRS + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} rotation - [description] + * @param {number} scaleX - [description] + * @param {number} scaleY - [description] + * + * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. + */ + applyITRS: function (x, y, rotation, scaleX, scaleY) + { + var matrix = this.matrix; + + var sr = Math.sin(rotation); + var cr = Math.cos(rotation); + + // Translate + matrix[4] = x; + matrix[5] = y; + + // Rotate and Scale + matrix[0] = cr * scaleX; + matrix[1] = -sr * scaleX; + matrix[2] = sr * scaleY; + matrix[3] = cr * scaleY; + + return this; + } + +}); + +module.exports = TransformMatrix; + + +/***/ }), +/* 349 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for setting the WebGL rendering pipeline of a Game Object. + * + * @name Phaser.GameObjects.Components.Pipeline + * @webglOnly + * @since 3.0.0 + */ + +var Pipeline = { + + /** + * [description] + * + * @name Phaser.GameObjects.Components.Pipeline#defaultPipeline + * @type {Phaser.Renderer.WebGL.WebGLPipeline} + * @default null + * @webglOnly + * @since 3.0.0 + */ + defaultPipeline: null, + + /** + * [description] + * + * @name Phaser.GameObjects.Components.Pipeline#pipeline + * @type {Phaser.Renderer.WebGL.WebGLPipeline} + * @default null + * @webglOnly + * @since 3.0.0 + */ + pipeline: null, + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * + * @method Phaser.GameObjects.Components.Pipeline#initPipeline + * @webglOnly + * @since 3.0.0 + * + * @param {string} pipelineName - The name of the pipeline to set on this Game Object. + * + * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. + */ + initPipeline: function (pipelineName) + { + var renderer = this.scene.sys.game.renderer; + + if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) + { + this.defaultPipeline = renderer.getPipeline(pipelineName); + this.pipeline = this.defaultPipeline; + + return true; + } + + return false; + }, + + /** + * Sets the active WebGL Pipeline of this Game Object. + * + * @method Phaser.GameObjects.Components.Pipeline#setPipeline + * @webglOnly + * @since 3.0.0 + * + * @param {string} pipelineName - The name of the pipeline to set on this Game Object. + * + * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. + */ + setPipeline: function (pipelineName) + { + var renderer = this.scene.sys.game.renderer; + + if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) + { + this.pipeline = renderer.getPipeline(pipelineName); + + return true; + } + + return false; + }, + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + * + * @method Phaser.GameObjects.Components.Pipeline#resetPipeline + * @webglOnly + * @since 3.0.0 + * + * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. + */ + resetPipeline: function () + { + this.pipeline = this.defaultPipeline; + + return (this.pipeline !== null); + }, + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + * + * @method Phaser.GameObjects.Components.Pipeline#getPipelineName + * @webglOnly + * @since 3.0.0 + * + * @return {string} The string-based name of the pipeline being used by this Game Object. + */ + getPipelineName: function () + { + return this.pipeline.name; + } + +}; + +module.exports = Pipeline; + + +/***/ }), +/* 350 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.RotateAround + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} angle - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var RotateAround = function (point, x, y, angle) +{ + var c = Math.cos(angle); + var s = Math.sin(angle); + + var tx = point.x - x; + var ty = point.y - y; + + point.x = tx * c - ty * s + x; + point.y = tx * s + ty * c + y; + + return point; +}; + +module.exports = RotateAround; + + +/***/ }), +/* 351 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); // Get a point on the given line 'progress' percentage along its length. // progress is a value between 0 and 1. @@ -56086,9 +71838,9 @@ var Point = __webpack_require__(5); * * @param {Phaser.Geom.Line} line - [description] * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. - * @param {Phaser.Geom.Point|object} [out] - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] * - * @return {Phaser.Geom.Point|object} [description] + * @return {(Phaser.Geom.Point|object)} [description] */ var GetPoint = function (line, position, out) { @@ -56103,8737 +71855,6 @@ var GetPoint = function (line, position, out) module.exports = GetPoint; -/***/ }), -/* 303 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH_CONST = __webpack_require__(16); -var Wrap = __webpack_require__(50); -var Angle = __webpack_require__(55); - -/** - * [description] - * - * @function Phaser.Geom.Line.NormalAngle - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var NormalAngle = function (line) -{ - var angle = Angle(line) - MATH_CONST.TAU; - - return Wrap(angle, -Math.PI, Math.PI); -}; - -module.exports = NormalAngle; - - -/***/ }), -/* 304 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.GetMagnitude - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} point - [description] - * - * @return {number} [description] - */ -var GetMagnitude = function (point) -{ - return Math.sqrt((point.x * point.x) + (point.y * point.y)); -}; - -module.exports = GetMagnitude; - - -/***/ }), -/* 305 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.GetMagnitudeSq - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} point - [description] - * - * @return {number} [description] - */ -var GetMagnitudeSq = function (point) -{ - return (point.x * point.x) + (point.y * point.y); -}; - -module.exports = GetMagnitudeSq; - - -/***/ }), -/* 306 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Contains = __webpack_require__(147); - -/** - * @classdesc - * [description] - * - * @class Polygon - * @memberOf Phaser.Geom - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Geom.Point[]} [points] - [description] - */ -var Polygon = new Class({ - - initialize: - - function Polygon (points) - { - /** - * The area of this Polygon. - * - * @name Phaser.Geom.Polygon#area - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.area = 0; - - /** - * An array of number pair objects that make up this polygon. I.e. [ {x,y}, {x,y}, {x,y} ] - * - * @name Phaser.Geom.Polygon#points - * @type {Phaser.Geom.Point[]} - * @since 3.0.0 - */ - this.points = []; - - if (points) - { - this.setTo(points); - } - }, - - /** - * [description] - * - * @method Phaser.Geom.Polygon#contains - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - contains: function (x, y) - { - return Contains(this, x, y); - }, - - /** - * Sets this Polygon to the given points. - * - * The points can be set from a variety of formats: - * - * - An array of Point objects: `[new Phaser.Point(x1, y1), ...]` - * - An array of objects with public x/y properties: `[obj1, obj2, ...]` - * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` - * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` - * - * `setTo` may also be called without any arguments to remove all points. - * - * @method Phaser.Geom.Polygon#setTo - * @since 3.0.0 - * - * @param {[type]} points - [description] - * - * @return {Phaser.Geom.Polygon} This Polygon object. - */ - setTo: function (points) - { - this.area = 0; - this.points = []; - - if (!Array.isArray(points)) - { - return this; - } - - var entry; - var y0 = Number.MAX_VALUE; - var p; - - // The points argument is an array, so iterate through it - for (var i = 0; i < points.length; i++) - { - p = { x: 0, y: 0 }; - - if (typeof points[i] === 'number') - { - p.x = points[i]; - p.y = points[i + 1]; - i++; - } - else if (Array.isArray(entry)) - { - // An array of arrays? - p.x = points[i][0]; - p.y = points[i][1]; - } - else - { - p.x = points[i].x; - p.y = points[i].y; - } - - this.points.push(p); - - // Lowest boundary - if (p.y < y0) - { - y0 = p.y; - } - } - - this.calculateArea(y0); - - return this; - }, - - /** - * Calculates the area of the Polygon. This is available in the property Polygon.area - * - * @method Phaser.Geom.Polygon#calculateArea - * @since 3.0.0 - * - * @return {number} [description] - */ - calculateArea: function () - { - if (this.points.length < 3) - { - this.area = 0; - - return this.area; - } - - var sum = 0; - var p1; - var p2; - - for (var i = 0; i < this.points.length - 1; i++) - { - p1 = this.points[i]; - p2 = this.points[i + 1]; - - sum += (p2.x - p1.x) * (p1.y + p2.y); - } - - p1 = this.points[0]; - p2 = this.points[this.points.length - 1]; - - sum += (p1.x - p2.x) * (p2.y + p1.y); - - this.area = -sum * 0.5; - - return this.area; - } - -}); - -module.exports = Polygon; - - -/***/ }), -/* 307 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(8); - -Rectangle.Area = __webpack_require__(722); -Rectangle.Ceil = __webpack_require__(723); -Rectangle.CeilAll = __webpack_require__(724); -Rectangle.CenterOn = __webpack_require__(308); -Rectangle.Clone = __webpack_require__(725); -Rectangle.Contains = __webpack_require__(33); -Rectangle.ContainsPoint = __webpack_require__(726); -Rectangle.ContainsRect = __webpack_require__(727); -Rectangle.CopyFrom = __webpack_require__(728); -Rectangle.Decompose = __webpack_require__(299); -Rectangle.Equals = __webpack_require__(729); -Rectangle.FitInside = __webpack_require__(730); -Rectangle.FitOutside = __webpack_require__(731); -Rectangle.Floor = __webpack_require__(732); -Rectangle.FloorAll = __webpack_require__(733); -Rectangle.FromPoints = __webpack_require__(122); -Rectangle.GetAspectRatio = __webpack_require__(148); -Rectangle.GetCenter = __webpack_require__(734); -Rectangle.GetPoint = __webpack_require__(107); -Rectangle.GetPoints = __webpack_require__(187); -Rectangle.GetSize = __webpack_require__(735); -Rectangle.Inflate = __webpack_require__(736); -Rectangle.MarchingAnts = __webpack_require__(191); -Rectangle.MergePoints = __webpack_require__(737); -Rectangle.MergeRect = __webpack_require__(738); -Rectangle.MergeXY = __webpack_require__(739); -Rectangle.Offset = __webpack_require__(740); -Rectangle.OffsetPoint = __webpack_require__(741); -Rectangle.Overlaps = __webpack_require__(742); -Rectangle.Perimeter = __webpack_require__(78); -Rectangle.PerimeterPoint = __webpack_require__(743); -Rectangle.Random = __webpack_require__(108); -Rectangle.Scale = __webpack_require__(744); -Rectangle.Union = __webpack_require__(745); - -module.exports = Rectangle; - - -/***/ }), -/* 308 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Centers this Rectangle so that the center coordinates match the given x and y values. - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.CenterOn - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var CenterOn = function (rect, x, y) -{ - rect.x = x - (rect.width / 2); - rect.y = y - (rect.height / 2); - - return rect; -}; - -module.exports = CenterOn; - - -/***/ }), -/* 309 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); -var Length = __webpack_require__(66); - -// Position is a value between 0 and 1 -/** - * [description] - * - * @function Phaser.Geom.Triangle.GetPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {float} position - [description] - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ -var GetPoint = function (triangle, position, out) -{ - if (out === undefined) { out = new Point(); } - - var line1 = triangle.getLineA(); - var line2 = triangle.getLineB(); - var line3 = triangle.getLineC(); - - if (position <= 0 || position >= 1) - { - out.x = line1.x1; - out.y = line1.y1; - - return out; - } - - var length1 = Length(line1); - var length2 = Length(line2); - var length3 = Length(line3); - - var perimeter = length1 + length2 + length3; - - var p = perimeter * position; - var localPosition = 0; - - // Which line is it on? - - if (p < length1) - { - // Line 1 - localPosition = p / length1; - - out.x = line1.x1 + (line1.x2 - line1.x1) * localPosition; - out.y = line1.y1 + (line1.y2 - line1.y1) * localPosition; - } - else if (p > length1 + length2) - { - // Line 3 - p -= length1 + length2; - localPosition = p / length3; - - out.x = line3.x1 + (line3.x2 - line3.x1) * localPosition; - out.y = line3.y1 + (line3.y2 - line3.y1) * localPosition; - } - else - { - // Line 2 - p -= length1; - localPosition = p / length2; - - out.x = line2.x1 + (line2.x2 - line2.x1) * localPosition; - out.y = line2.y1 + (line2.y2 - line2.y1) * localPosition; - } - - return out; -}; - -module.exports = GetPoint; - - -/***/ }), -/* 310 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Length = __webpack_require__(66); -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Triangle.GetPoints - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {integer} quantity - [description] - * @param {number} stepRate - [description] - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ -var GetPoints = function (triangle, quantity, stepRate, out) -{ - if (out === undefined) { out = []; } - - var line1 = triangle.getLineA(); - var line2 = triangle.getLineB(); - var line3 = triangle.getLineC(); - - var length1 = Length(line1); - var length2 = Length(line2); - var length3 = Length(line3); - - var perimeter = length1 + length2 + length3; - - // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. - if (!quantity) - { - quantity = perimeter / stepRate; - } - - for (var i = 0; i < quantity; i++) - { - var p = perimeter * (i / quantity); - var localPosition = 0; - - var point = new Point(); - - // Which line is it on? - - if (p < length1) - { - // Line 1 - localPosition = p / length1; - - point.x = line1.x1 + (line1.x2 - line1.x1) * localPosition; - point.y = line1.y1 + (line1.y2 - line1.y1) * localPosition; - } - else if (p > length1 + length2) - { - // Line 3 - p -= length1 + length2; - localPosition = p / length3; - - point.x = line3.x1 + (line3.x2 - line3.x1) * localPosition; - point.y = line3.y1 + (line3.y2 - line3.y1) * localPosition; - } - else - { - // Line 2 - p -= length1; - localPosition = p / length2; - - point.x = line2.x1 + (line2.x2 - line2.x1) * localPosition; - point.y = line2.y1 + (line2.y2 - line2.y1) * localPosition; - } - - out.push(point); - } - - return out; -}; - -module.exports = GetPoints; - - -/***/ }), -/* 311 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -// The three medians (the lines drawn from the vertices to the bisectors of the opposite sides) -// meet in the centroid or center of mass (center of gravity). -// The centroid divides each median in a ratio of 2:1 - -/** - * [description] - * - * @function Phaser.Geom.Triangle.Centroid - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point|object} [out] - [description] - * - * @return {Phaser.Geom.Point|object} [description] - */ -var Centroid = function (triangle, out) -{ - if (out === undefined) { out = new Point(); } - - out.x = (triangle.x1 + triangle.x2 + triangle.x3) / 3; - out.y = (triangle.y1 + triangle.y2 + triangle.y3) / 3; - - return out; -}; - -module.exports = Centroid; - - -/***/ }), -/* 312 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Triangle.Offset - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Geom.Triangle} [description] - */ -var Offset = function (triangle, x, y) -{ - triangle.x1 += x; - triangle.y1 += y; - - triangle.x2 += x; - triangle.y2 += y; - - triangle.x3 += x; - triangle.y3 += y; - - return triangle; -}; - -module.exports = Offset; - - -/***/ }), -/* 313 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -// The three angle bisectors of a triangle meet in one point called the incenter. -// It is the center of the incircle, the circle inscribed in the triangle. - -function getLength (x1, y1, x2, y2) -{ - var x = x1 - x2; - var y = y1 - y2; - var magnitude = (x * x) + (y * y); - - return Math.sqrt(magnitude); -} - -/** - * [description] - * - * @function Phaser.Geom.Triangle.InCenter - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var InCenter = function (triangle, out) -{ - if (out === undefined) { out = new Point(); } - - var x1 = triangle.x1; - var y1 = triangle.y1; - - var x2 = triangle.x2; - var y2 = triangle.y2; - - var x3 = triangle.x3; - var y3 = triangle.y3; - - var d1 = getLength(x3, y3, x2, y2); - var d2 = getLength(x1, y1, x3, y3); - var d3 = getLength(x2, y2, x1, y1); - - var p = d1 + d2 + d3; - - out.x = (x1 * d1 + x2 * d2 + x3 * d3) / p; - out.y = (y1 * d1 + y2 * d2 + y3 * d3) / p; - - return out; -}; - -module.exports = InCenter; - - -/***/ }), -/* 314 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Phaser.Input.InteractiveObject - -var InteractiveObject = function (gameObject, hitArea, hitAreaCallback) -{ - return { - - gameObject: gameObject, - - enabled: true, - draggable: false, - dropZone: false, - - target: null, - - camera: null, - - hitArea: hitArea, - hitAreaCallback: hitAreaCallback, - - localX: 0, - localY: 0, - - // 0 = Not being dragged - // 1 = Being checked for dragging - // 2 = Being dragged - dragState: 0, - - dragStartX: 0, - dragStartY: 0, - - dragX: 0, - dragY: 0 - - }; -}; - -module.exports = InteractiveObject; - - -/***/ }), -/* 315 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MergeXHRSettings = __webpack_require__(151); - -/** - * Creates a new XMLHttpRequest (xhr) object based on the given File and XHRSettings - * and starts the download of it. It uses the Files own XHRSettings and merges them - * with the global XHRSettings object to set the xhr values before download. - * - * @function Phaser.Loader.XHRLoader - * @since 3.0.0 - * - * @param {Phaser.Loader.File} file - The File to download. - * @param {Phaser.Loader.XHRSettings} globalXHRSettings - The global XHRSettings object. - * - * @return {XMLHttpRequest} The XHR object. - */ -var XHRLoader = function (file, globalXHRSettings) -{ - var config = MergeXHRSettings(globalXHRSettings, file.xhrSettings); - - var xhr = new XMLHttpRequest(); - - xhr.open('GET', file.src, config.async, config.user, config.password); - - xhr.responseType = file.xhrSettings.responseType; - xhr.timeout = config.timeout; - - if (config.header && config.headerValue) - { - xhr.setRequestHeader(config.header, config.headerValue); - } - - if (config.overrideMimeType) - { - xhr.overrideMimeType(config.overrideMimeType); - } - - // After a successful request, the xhr.response property will contain the requested data as a DOMString, ArrayBuffer, Blob, or Document (depending on what was set for responseType.) - - xhr.onload = file.onLoad.bind(file); - xhr.onerror = file.onError.bind(file); - xhr.onprogress = file.onProgress.bind(file); - - // This is the only standard method, the ones above are browser additions (maybe not universal?) - // xhr.onreadystatechange - - xhr.send(); - - return xhr; -}; - -module.exports = XHRLoader; - - -/***/ }), -/* 316 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(19); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(2); -var HTML5AudioFile = __webpack_require__(317); - -/** - * @classdesc - * [description] - * - * @class AudioFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {object} xhrSettings - [description] - * @param {[type]} audioContext - [description] - */ -var AudioFile = new Class({ - - Extends: File, - - initialize: - - function AudioFile (key, url, path, xhrSettings, audioContext) - { - /** - * [description] - * - * @property {[type]} context - * @since 3.0.0 - */ - this.context = audioContext; - - var fileConfig = { - type: 'audio', - extension: GetFastValue(url, 'type', ''), - responseType: 'arraybuffer', - key: key, - url: GetFastValue(url, 'uri', url), - path: path, - xhrSettings: xhrSettings - }; - - File.call(this, fileConfig); - }, - - /** - * [description] - * - * @method Phaser.Loader.FileTypes.AudioFile#onProcess - * @since 3.0.0 - * - * @param {[type]} callback - [description] - */ - onProcess: function (callback) - { - this.state = CONST.FILE_PROCESSING; - - var _this = this; - - // interesting read https://github.com/WebAudio/web-audio-api/issues/1305 - this.context.decodeAudioData(this.xhrLoader.response, - function (audioBuffer) - { - _this.data = audioBuffer; - - _this.onComplete(); - - callback(_this); - }, - function (e) - { - // eslint-disable-next-line no-console - console.error('Error with decoding audio data for \'' + this.key + '\':', e.message); - - _this.state = CONST.FILE_ERRORED; - - callback(_this); - } - ); - - this.context = null; - } - -}); - -AudioFile.create = function (loader, key, urls, config, xhrSettings) -{ - var game = loader.systems.game; - var audioConfig = game.config.audio; - var deviceAudio = game.device.audio; - - if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) - { - // console.info('Skipping loading audio \'' + key + '\' since sounds are disabled.'); - return null; - } - - var url = AudioFile.findAudioURL(game, urls); - - if (!url) - { - // console.warn('No supported url provided for audio \'' + key + '\'!'); - return null; - } - - if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio)) - { - return new AudioFile(key, url, loader.path, xhrSettings, game.sound.context); - } - else - { - return new HTML5AudioFile(key, url, loader.path, config, game.sound.locked); - } -}; - -/** - * Adds an Audio file to the current load queue. - * - * Note: This method will only be available if the Audio File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#audio - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string|string[]} urls - [description] - * @param {object} config - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('audio', function (key, urls, config, xhrSettings) -{ - var audioFile = AudioFile.create(this, key, urls, config, xhrSettings); - - if (audioFile) - { - this.addFile(audioFile); - } - - return this; -}); - -// this.load.audio('sound', 'assets/audio/booom.ogg', config, xhrSettings); -// -// this.load.audio('sound', -// [ -// 'assets/audio/booom.ogg', -// 'assets/audio/booom.m4a', -// 'assets/audio/booom.mp3' -// ], -// config, xhrSettings); -// -// this.load.audio('sound', -// { -// uri: 'assets/audio/boooooom', -// type: 'ogg' -// }, -// config, xhrSettings); -// -// this.load.audio('sound', -// [ -// { -// uri: 'assets/audio/booooooo', -// type: 'ogg' -// }, -// { -// uri: 'assets/audio/boooooom', -// type: 'mp3' -// } -// ], -// config, xhrSettings); -// -// this.load.audio('sound', -// [ -// { -// uri: 'assets/audio/booooooo', -// type: 'ogg' -// }, -// 'assets/audio/booom.m4a', -// { -// uri: 'assets/audio/boooooom', -// type: 'mp3' -// } -// ], -// config, xhrSettings); - -AudioFile.findAudioURL = function (game, urls) -{ - if (urls.constructor !== Array) - { - urls = [ urls ]; - } - - for (var i = 0; i < urls.length; i++) - { - var url = GetFastValue(urls[i], 'uri', urls[i]); - - if (url.indexOf('blob:') === 0 || url.indexOf('data:') === 0) - { - return url; - } - - var type = url.match(/\.([a-zA-Z0-9]+)($|\?)/); - type = GetFastValue(urls[i], 'type', type ? type[1] : '').toLowerCase(); - - if (game.device.audio[type]) - { - return { - uri: url, - type: type - }; - } - } - - return null; -}; - -module.exports = AudioFile; - - -/***/ }), -/* 317 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var File = __webpack_require__(18); -var GetFastValue = __webpack_require__(2); -var GetURL = __webpack_require__(150); - -/** - * @classdesc - * [description] - * - * @class HTML5AudioFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {object} config - [description] - * @param {boolean} locked - [description] - */ -var HTML5AudioFile = new Class({ - - Extends: File, - - initialize: - - function HTML5AudioFile (key, url, path, config, locked) - { - this.locked = locked; - - this.loaded = false; - - var fileConfig = { - type: 'audio', - extension: GetFastValue(url, 'type', ''), - key: key, - url: GetFastValue(url, 'uri', url), - path: path, - config: config - }; - - File.call(this, fileConfig); - }, - - onLoad: function () - { - if(this.loaded) - { - return; - } - - this.loaded = true; - - this.loader.nextFile(this, true); - }, - - onError: function () - { - for (var i = 0; i < this.data.length; i++) - { - var audio = this.data[i]; - audio.oncanplaythrough = null; - audio.onerror = null; - } - - this.loader.nextFile(this, false); - }, - - onProgress: function (event) - { - var audio = event.target; - audio.oncanplaythrough = null; - audio.onerror = null; - - this.filesLoaded++; - - this.percentComplete = Math.min((this.filesLoaded / this.filesTotal), 1); - - this.loader.emit('fileprogress', this, this.percentComplete); - - if(this.filesLoaded === this.filesTotal) - { - this.onLoad(); - } - }, - - // Called by the Loader, starts the actual file downloading - load: function (loader) - { - this.loader = loader; - - this.data = []; - - var instances = (this.config && this.config.instances) || 1; - - this.filesTotal = instances; - this.filesLoaded = 0; - this.percentComplete = 0; - - for(var i = 0; i < instances; i++) - { - var audio = new Audio(); - audio.dataset.name = this.key + ('0' + i).slice(-2); // Useful for debugging - audio.dataset.used = 'false'; - - if (!this.locked) - { - audio.preload = 'auto'; - audio.oncanplaythrough = this.onProgress.bind(this); - audio.onerror = this.onError.bind(this); - } - - this.data.push(audio); - } - - for (i = 0; i < this.data.length; i++) - { - audio = this.data[i]; - audio.src = GetURL(this, loader.baseURL); - - if (!this.locked) - { - audio.load(); - } - } - - if (this.locked) - { - setTimeout(this.onLoad.bind(this)); - } - } - -}); - -module.exports = HTML5AudioFile; - - -/***/ }), -/* 318 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(2); -var ParseXML = __webpack_require__(233); - -/** - * @classdesc - * [description] - * - * @class XMLFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {object} xhrSettings - [description] - */ -var XMLFile = new Class({ - - Extends: File, - - initialize: - - function XMLFile (key, url, path, xhrSettings) - { - var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); - - var fileConfig = { - type: 'xml', - extension: GetFastValue(key, 'extension', 'xml'), - responseType: 'text', - key: fileKey, - url: GetFastValue(key, 'file', url), - path: path, - xhrSettings: GetFastValue(key, 'xhr', xhrSettings) - }; - - File.call(this, fileConfig); - }, - - onProcess: function (callback) - { - this.state = CONST.FILE_PROCESSING; - - this.data = ParseXML(this.xhrLoader.responseText); - - if (this.data === null) - { - throw new Error('XMLFile: Invalid XML'); - } - - this.onComplete(); - - callback(this); - } - -}); - -/** - * Adds an XML file to the current load queue. - * - * Note: This method will only be available if the XML File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#xml - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('xml', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new XMLFile(key[i], url, this.path, xhrSettings)); - } - } - else - { - this.addFile(new XMLFile(key, url, this.path, xhrSettings)); - } - - // For method chaining - return this; -}); - -module.exports = XMLFile; - - -/***/ }), -/* 319 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Create an array representing the range of numbers (usually integers), between, and inclusive of, - * the given `start` and `end` arguments. For example: - * - * `var array = numberArray(2, 4); // array = [2, 3, 4]` - * `var array = numberArray(0, 9); // array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]` - * - * This is equivalent to `numberArrayStep(start, end, 1)`. - * - * You can optionally provide a prefix and / or suffix string. If given the array will contain - * strings, not integers. For example: - * - * `var array = numberArray(1, 4, 'Level '); // array = ["Level 1", "Level 2", "Level 3", "Level 4"]` - * `var array = numberArray(5, 7, 'HD-', '.png'); // array = ["HD-5.png", "HD-6.png", "HD-7.png"]` - * - * @function Phaser.Utils.Array.NumberArray - * @since 3.0.0 - * - * @param {number} start - The minimum value the array starts with. - * @param {number} end - The maximum value the array contains. - * @param {string} [prefix] - Optional prefix to place before the number. If provided the array will contain strings, not integers. - * @param {string} [suffix] - Optional suffix to place after the number. If provided the array will contain strings, not integers. - * - * @return {number[]|string[]} The array of number values, or strings if a prefix or suffix was provided. - */ -var NumberArray = function (start, end, prefix, suffix) -{ - var result = []; - - for (var i = start; i <= end; i++) - { - if (prefix || suffix) - { - var key = (prefix) ? prefix + i.toString() : i.toString(); - - if (suffix) - { - key = key.concat(suffix); - } - - result.push(key); - } - else - { - result.push(i); - } - } - - return result; -}; - -module.exports = NumberArray; - - -/***/ }), -/* 320 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); - -/** - * @classdesc - * [description] - * - * @class TextFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {object} xhrSettings - [description] - */ -var TextFile = new Class({ - - Extends: File, - - initialize: - - function TextFile (key, url, path, xhrSettings) - { - var fileConfig = { - type: 'text', - extension: 'txt', - responseType: 'text', - key: key, - url: url, - path: path, - xhrSettings: xhrSettings - }; - - File.call(this, fileConfig); - }, - - onProcess: function (callback) - { - this.state = CONST.FILE_PROCESSING; - - this.data = this.xhrLoader.responseText; - - this.onComplete(); - - callback(this); - } - -}); - -/** - * Adds a Text file to the current load queue. - * - * Note: This method will only be available if the Text File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#text - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('text', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new TextFile(key[i], url, this.path, xhrSettings)); - } - } - else - { - this.addFile(new TextFile(key, url, this.path, xhrSettings)); - } - - // For method chaining - return this; -}); - -module.exports = TextFile; - - -/***/ }), -/* 321 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Angle.Normalize - * @since 3.0.0 - * - * @param {number} angle - [description] - * - * @return {number} [description] - */ -var Normalize = function (angle) -{ - angle = angle % (2 * Math.PI); - - if (angle >= 0) - { - return angle; - } - else - { - return angle + 2 * Math.PI; - } -}; - -module.exports = Normalize; - - -/***/ }), -/* 322 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Factorial = __webpack_require__(323); - -/** - * [description] - * - * @function Phaser.Math.Bernstein - * @since 3.0.0 - * - * @param {number} n - [description] - * @param {number} i - [description] - * - * @return {number} [description] - */ -var Bernstein = function (n, i) -{ - return Factorial(n) / Factorial(i) / Factorial(n - i); -}; - -module.exports = Bernstein; - - -/***/ }), -/* 323 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Factorial - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {number} [description] - */ -var Factorial = function (value) -{ - if (value === 0) - { - return 1; - } - - var res = value; - - while (--value) - { - res *= value; - } - - return res; -}; - -module.exports = Factorial; - - -/***/ }), -/* 324 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Rotate - * @since 3.0.0 - * - * @param {Phaser.Geom.Point|object} point - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Rotate = function (point, angle) -{ - var x = point.x; - var y = point.y; - - point.x = (x * Math.cos(angle)) - (y * Math.sin(angle)); - point.y = (x * Math.sin(angle)) + (y * Math.cos(angle)); - - return point; -}; - -module.exports = Rotate; - - -/***/ }), -/* 325 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.RoundAwayFromZero - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {number} [description] - */ -var RoundAwayFromZero = function (value) -{ - // "Opposite" of truncate. - return (value > 0) ? Math.ceil(value) : Math.floor(value); -}; - -module.exports = RoundAwayFromZero; - - -/***/ }), -/* 326 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ArcadeImage = __webpack_require__(327); -var ArcadeSprite = __webpack_require__(91); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(59); -var PhysicsGroup = __webpack_require__(329); -var StaticPhysicsGroup = __webpack_require__(330); - -/** - * @classdesc - * The Arcade Physics Factory allows you to easily create Arcade Physics enabled Game Objects. - * Objects that are created by this Factory are automatically added to the physics world. - * - * @class Factory - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.World} world - The Arcade Physics World instance. - */ -var Factory = new Class({ - - initialize: - - function Factory (world) - { - /** - * A reference to the Arcade Physics World. - * - * @name Phaser.Physics.Arcade.Factory#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world = world; - - /** - * A reference to the Scene this Arcade Physics instance belongs to. - * - * @name Phaser.Physics.Arcade.Factory#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = world.scene; - - /** - * A reference to the Scene.Systems this Arcade Physics instance belongs to. - * - * @name Phaser.Physics.Arcade.Factory#sys - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.sys = world.scene.sys; - }, - - /** - * Create a new Arcade Physics Collider object. - * - * @method Phaser.Physics.Arcade.Factory#collider - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for collision. - * @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for collision. - * @param {function} collideCallback - The callback to invoke when the two objects collide. - * @param {function} processCallback - The callback to invoke when the two objects collide. Must return a boolean. - * @param {object} callbackContext - The scope in which to call the callbacks. - * - * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. - */ - collider: function (object1, object2, collideCallback, processCallback, callbackContext) - { - return this.world.addCollider(object1, object2, collideCallback, processCallback, callbackContext); - }, - - /** - * Create a new Arcade Physics Collider Overlap object. - * - * @method Phaser.Physics.Arcade.Factory#overlap - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for overlap. - * @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for overlap. - * @param {function} collideCallback - The callback to invoke when the two objects collide. - * @param {function} processCallback - The callback to invoke when the two objects collide. Must return a boolean. - * @param {object} callbackContext - The scope in which to call the callbacks. - * - * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. - */ - overlap: function (object1, object2, collideCallback, processCallback, callbackContext) - { - return this.world.addOverlap(object1, object2, collideCallback, processCallback, callbackContext); - }, - - /** - * Adds an Arcade Physics Body to the given Game Object. - * - * @method Phaser.Physics.Arcade.Factory#existing - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - * @param {boolean} [isStatic=false] - Set to true to create a Static body, otherwise it will create a Dynamic body. - * - * @return {Phaser.GameObjects.GameObject} The Game Object. - */ - existing: function (gameObject, isStatic) - { - var type = (isStatic) ? CONST.STATIC_BODY : CONST.DYNAMIC_BODY; - - this.world.enableBody(gameObject, type); - - return gameObject; - }, - - /** - * Creates a new Arcade Image object with a Static body. - * - * @method Phaser.Physics.Arcade.Factory#staticImage - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.Physics.Arcade.Image} The Image object that was created. - */ - staticImage: function (x, y, key, frame) - { - var image = new ArcadeImage(this.scene, x, y, key, frame); - - this.sys.displayList.add(image); - - this.world.enableBody(image, CONST.STATIC_BODY); - - return image; - }, - - /** - * Creates a new Arcade Image object with a Dynamic body. - * - * @method Phaser.Physics.Arcade.Factory#image - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.Physics.Arcade.Image} The Image object that was created. - */ - image: function (x, y, key, frame) - { - var image = new ArcadeImage(this.scene, x, y, key, frame); - - this.sys.displayList.add(image); - - this.world.enableBody(image, CONST.DYNAMIC_BODY); - - return image; - }, - - /** - * Creates a new Arcade Sprite object with a Static body. - * - * @method Phaser.Physics.Arcade.Factory#staticSprite - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.Physics.Arcade.Sprite} The Sprite object that was created. - */ - staticSprite: function (x, y, key, frame) - { - var sprite = new ArcadeSprite(this.scene, x, y, key, frame); - - this.sys.displayList.add(sprite); - this.sys.updateList.add(sprite); - - this.world.enableBody(sprite, CONST.STATIC_BODY); - - return sprite; - }, - - /** - * Creates a new Arcade Sprite object with a Dynamic body. - * - * @method Phaser.Physics.Arcade.Factory#sprite - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.Physics.Arcade.Sprite} The Sprite object that was created. - */ - sprite: function (x, y, key, frame) - { - var sprite = new ArcadeSprite(this.scene, x, y, key, frame); - - this.sys.displayList.add(sprite); - this.sys.updateList.add(sprite); - - this.world.enableBody(sprite, CONST.DYNAMIC_BODY); - - return sprite; - }, - - /** - * Creates a Static Physics Group object. - * All Game Objects created by this Group will automatically be static Arcade Physics objects. - * - * @method Phaser.Physics.Arcade.Factory#staticGroup - * @since 3.0.0 - * - * @param {array} [children] - [description] - * @param {object} [config] - [description] - * - * @return {Phaser.Physics.Arcade.StaticGroup} The Static Group object that was created. - */ - staticGroup: function (children, config) - { - return this.sys.updateList.add(new StaticPhysicsGroup(this.world, this.world.scene, children, config)); - }, - - /** - * Creates a Physics Group object. - * All Game Objects created by this Group will automatically be dynamic Arcade Physics objects. - * - * @method Phaser.Physics.Arcade.Factory#group - * @since 3.0.0 - * - * @param {array} [children] - [description] - * @param {object} [config] - [description] - * - * @return {Phaser.Physics.Arcade.Group} The Group object that was created. - */ - group: function (children, config) - { - return this.sys.updateList.add(new PhysicsGroup(this.world, this.world.scene, children, config)); - } - -}); - -module.exports = Factory; - - -/***/ }), -/* 327 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(328); -var Image = __webpack_require__(70); - -/** - * @classdesc - * An Arcade Physics Image Game Object. - * - * An Image is a light-weight Game Object useful for the display of static images in your game, - * such as logos, backgrounds, scenery or other non-animated elements. Images can have input - * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an - * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. - * - * @class Image - * @extends Phaser.GameObjects.Image - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @extends Phaser.Physics.Arcade.Components.Acceleration - * @extends Phaser.Physics.Arcade.Components.Angular - * @extends Phaser.Physics.Arcade.Components.Bounce - * @extends Phaser.Physics.Arcade.Components.Debug - * @extends Phaser.Physics.Arcade.Components.Drag - * @extends Phaser.Physics.Arcade.Components.Enable - * @extends Phaser.Physics.Arcade.Components.Friction - * @extends Phaser.Physics.Arcade.Components.Gravity - * @extends Phaser.Physics.Arcade.Components.Immovable - * @extends Phaser.Physics.Arcade.Components.Mass - * @extends Phaser.Physics.Arcade.Components.Size - * @extends Phaser.Physics.Arcade.Components.Velocity - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var ArcadeImage = new Class({ - - Extends: Image, - - Mixins: [ - Components.Acceleration, - Components.Angular, - Components.Bounce, - Components.Debug, - Components.Drag, - Components.Enable, - Components.Friction, - Components.Gravity, - Components.Immovable, - Components.Mass, - Components.Size, - Components.Velocity - ], - - initialize: - - function ArcadeImage (scene, x, y, texture, frame) - { - Image.call(this, scene, x, y, texture, frame); - } - -}); - -module.exports = ArcadeImage; - - -/***/ }), -/* 328 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Phaser.Physics.Arcade.Body.Components - -module.exports = { - - Acceleration: __webpack_require__(838), - Angular: __webpack_require__(839), - Bounce: __webpack_require__(840), - Debug: __webpack_require__(841), - Drag: __webpack_require__(842), - Enable: __webpack_require__(843), - Friction: __webpack_require__(844), - Gravity: __webpack_require__(845), - Immovable: __webpack_require__(846), - Mass: __webpack_require__(847), - Size: __webpack_require__(848), - Velocity: __webpack_require__(849) - -}; - - -/***/ }), -/* 329 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ArcadeSprite = __webpack_require__(91); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(59); -var GetFastValue = __webpack_require__(2); -var Group = __webpack_require__(69); - -/** - * @classdesc - * An Arcade Physics Group object. - * - * All Game Objects created by this Group will automatically be dynamic Arcade Physics objects. - * - * @class Group - * @extends Phaser.GameObjects.Group - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.World} world - [description] - * @param {Phaser.Scene} scene - [description] - * @param {array} children - [description] - * @param {object} config - [description] - */ -var PhysicsGroup = new Class({ - - Extends: Group, - - initialize: - - function PhysicsGroup (world, scene, children, config) - { - if (config === undefined && !Array.isArray(children) && typeof children === 'object') - { - config = children; - children = null; - } - else if (config === undefined) - { - config = {}; - } - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Group#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world = world; - - config.createCallback = this.createCallback; - config.removeCallback = this.removeCallback; - - config.classType = GetFastValue(config, 'classType', ArcadeSprite); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Group#physicsType - * @type {integer} - * @since 3.0.0 - */ - this.physicsType = CONST.DYNAMIC_BODY; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Group#defaults - * @type {object} - * @since 3.0.0 - */ - this.defaults = { - setCollideWorldBounds: GetFastValue(config, 'collideWorldBounds', false), - setAccelerationX: GetFastValue(config, 'accelerationX', 0), - setAccelerationY: GetFastValue(config, 'accelerationY', 0), - setBounceX: GetFastValue(config, 'bounceX', 0), - setBounceY: GetFastValue(config, 'bounceY', 0), - setDragX: GetFastValue(config, 'dragX', 0), - setDragY: GetFastValue(config, 'dragY', 0), - setGravityX: GetFastValue(config, 'gravityX', 0), - setGravityY: GetFastValue(config, 'gravityY', 0), - setFrictionX: GetFastValue(config, 'frictionX', 0), - setFrictionY: GetFastValue(config, 'frictionY', 0), - setVelocityX: GetFastValue(config, 'velocityX', 0), - setVelocityY: GetFastValue(config, 'velocityY', 0), - setAngularVelocity: GetFastValue(config, 'angularVelocity', 0), - setAngularAcceleration: GetFastValue(config, 'angularAcceleration', 0), - setAngularDrag: GetFastValue(config, 'angularDrag', 0), - setMass: GetFastValue(config, 'mass', 1), - setImmovable: GetFastValue(config, 'immovable', false) - }; - - Group.call(this, scene, children, config); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Group#createCallback - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - */ - createCallback: function (child) - { - if (!child.body) - { - this.world.enableBody(child, CONST.DYNAMIC_BODY); - } - - var body = child.body; - - for (var key in this.defaults) - { - body[key](this.defaults[key]); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Group#removeCallback - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - */ - removeCallback: function (child) - { - if (child.body) - { - this.world.disableBody(child); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Group#setVelocity - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} step - [description] - * - * @return {Phaser.Physics.Arcade.Group} This Physics Group object. - */ - setVelocity: function (x, y, step) - { - if (step === undefined) { step = 0; } - - var items = this.getChildren(); - - for (var i = 0; i < items.length; i++) - { - items[i].body.velocity.set(x + (i * step), y + (i * step)); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Group#setVelocityX - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} step - [description] - * - * @return {Phaser.Physics.Arcade.Group} This Physics Group object. - */ - setVelocityX: function (value, step) - { - if (step === undefined) { step = 0; } - - var items = this.getChildren(); - - for (var i = 0; i < items.length; i++) - { - items[i].body.velocity.x = value + (i * step); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Group#setVelocityY - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} step - [description] - * - * @return {Phaser.Physics.Arcade.Group} This Physics Group object. - */ - setVelocityY: function (value, step) - { - if (step === undefined) { step = 0; } - - var items = this.getChildren(); - - for (var i = 0; i < items.length; i++) - { - items[i].body.velocity.y = value + (i * step); - } - - return this; - } - -}); - -module.exports = PhysicsGroup; - - -/***/ }), -/* 330 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Phaser.Physics.Arcade.StaticGroup - -var ArcadeSprite = __webpack_require__(91); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(59); -var Group = __webpack_require__(69); - -/** - * @classdesc - * [description] - * - * @class StaticGroup - * @extends Phaser.GameObjects.Group - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.World} world - [description] - * @param {Phaser.Scene} scene - [description] - * @param {array} children - [description] - * @param {object} config - [description] - */ -var StaticPhysicsGroup = new Class({ - - Extends: Group, - - initialize: - - function StaticPhysicsGroup (world, scene, children, config) - { - if (config === undefined && !Array.isArray(children) && typeof children === 'object') - { - config = children; - children = null; - } - else if (config === undefined) - { - config = {}; - } - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticGroup#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world = world; - - config.createCallback = this.createCallback; - config.removeCallback = this.removeCallback; - config.createMultipleCallback = this.createMultipleCallback; - - config.classType = ArcadeSprite; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticGroup#physicsType - * @type {integer} - * @since 3.0.0 - */ - this.physicsType = CONST.STATIC_BODY; - - Group.call(this, scene, children, config); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticGroup#createCallback - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - */ - createCallback: function (child) - { - if (!child.body) - { - this.world.enableBody(child, CONST.STATIC_BODY); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticGroup#removeCallback - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - */ - removeCallback: function (child) - { - if (child.body) - { - this.world.disableBody(child); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticGroup#createMultipleCallback - * @since 3.0.0 - * - * @param {object} entries - [description] - */ - createMultipleCallback: function () - { - this.refresh(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticGroup#refresh - * @since 3.0.0 - * - * @return {Phaser.Physics.Arcade.StaticGroup} [description] - */ - refresh: function () - { - var children = this.children.entries; - - for (var i = 0; i < children.length; i++) - { - children[i].body.reset(); - } - - return this; - } - -}); - -module.exports = StaticPhysicsGroup; - - -/***/ }), -/* 331 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Body = __webpack_require__(332); -var Clamp = __webpack_require__(61); -var Class = __webpack_require__(0); -var Collider = __webpack_require__(333); -var CONST = __webpack_require__(59); -var DistanceBetween = __webpack_require__(42); -var EventEmitter = __webpack_require__(14); -var GetOverlapX = __webpack_require__(334); -var GetOverlapY = __webpack_require__(335); -var GetValue = __webpack_require__(4); -var ProcessQueue = __webpack_require__(336); -var ProcessTileCallbacks = __webpack_require__(850); -var Rectangle = __webpack_require__(8); -var RTree = __webpack_require__(337); -var SeparateTile = __webpack_require__(851); -var SeparateX = __webpack_require__(856); -var SeparateY = __webpack_require__(857); -var Set = __webpack_require__(62); -var StaticBody = __webpack_require__(340); -var TileIntersectsBody = __webpack_require__(339); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * [description] - * - * @class World - * @extends EventEmitter - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {object} config - [description] - */ -var World = new Class({ - - Extends: EventEmitter, - - initialize: - - function World (scene, config) - { - EventEmitter.call(this); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * Dynamic Bodies - * - * @name Phaser.Physics.Arcade.World#bodies - * @type {Phaser.Structs.Set} - * @since 3.0.0 - */ - this.bodies = new Set(); - - /** - * Static Bodies - * - * @name Phaser.Physics.Arcade.World#staticBodies - * @type {Phaser.Structs.Set} - * @since 3.0.0 - */ - this.staticBodies = new Set(); - - /** - * Static Bodies - * - * @name Phaser.Physics.Arcade.World#pendingDestroy - * @type {Phaser.Structs.Set} - * @since 3.1.0 - */ - this.pendingDestroy = new Set(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#colliders - * @type {Phaser.Structs.ProcessQueue} - * @since 3.0.0 - */ - this.colliders = new ProcessQueue(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#gravity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.gravity = new Vector2(GetValue(config, 'gravity.x', 0), GetValue(config, 'gravity.y', 0)); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#bounds - * @type {Phaser.Geom.Rectangle} - * @since 3.0.0 - */ - this.bounds = new Rectangle( - GetValue(config, 'x', 0), - GetValue(config, 'y', 0), - GetValue(config, 'width', scene.sys.game.config.width), - GetValue(config, 'height', scene.sys.game.config.height) - ); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#checkCollision - * @type {object} - * @since 3.0.0 - */ - this.checkCollision = { - up: GetValue(config, 'checkCollision.up', true), - down: GetValue(config, 'checkCollision.down', true), - left: GetValue(config, 'checkCollision.left', true), - right: GetValue(config, 'checkCollision.right', true) - }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#OVERLAP_BIAS - * @type {number} - * @default 4 - * @since 3.0.0 - */ - this.OVERLAP_BIAS = GetValue(config, 'overlapBias', 4); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#TILE_BIAS - * @type {number} - * @default 16 - * @since 3.0.0 - */ - this.TILE_BIAS = GetValue(config, 'tileBias', 16); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#forceX - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.forceX = GetValue(config, 'forceX', false); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#isPaused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isPaused = GetValue(config, 'isPaused', false); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#_total - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._total = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#drawDebug - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.drawDebug = GetValue(config, 'debug', false); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#debugGraphic - * @type {Phaser.GameObjects.Graphics} - * @since 3.0.0 - */ - this.debugGraphic; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#defaults - * @type {object} - * @since 3.0.0 - */ - this.defaults = { - debugShowBody: GetValue(config, 'debugShowBody', true), - debugShowStaticBody: GetValue(config, 'debugShowStaticBody', true), - debugShowVelocity: GetValue(config, 'debugShowVelocity', true), - bodyDebugColor: GetValue(config, 'debugBodyColor', 0xff00ff), - staticBodyDebugColor: GetValue(config, 'debugBodyColor', 0x0000ff), - velocityDebugColor: GetValue(config, 'debugVelocityColor', 0x00ff00) - }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#maxEntries - * @type {integer} - * @default 16 - * @since 3.0.0 - */ - this.maxEntries = GetValue(config, 'maxEntries', 16); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#tree - * @type {Phaser.Structs.RTree} - * @since 3.0.0 - */ - this.tree = new RTree(this.maxEntries, [ '.left', '.top', '.right', '.bottom' ]); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#staticTree - * @type {Phaser.Structs.RTree} - * @since 3.0.0 - */ - this.staticTree = new RTree(this.maxEntries, [ '.left', '.top', '.right', '.bottom' ]); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#treeMinMax - * @type {object} - * @since 3.0.0 - */ - this.treeMinMax = { minX: 0, minY: 0, maxX: 0, maxY: 0 }; - - if (this.drawDebug) - { - this.createDebugGraphic(); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#enable - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} object - [description] - * @param {integer} [type] - [description] - */ - enable: function (object, type) - { - if (type === undefined) { type = CONST.DYNAMIC_BODY; } - - var i = 1; - - if (Array.isArray(object)) - { - i = object.length; - - while (i--) - { - if (object[i].hasOwnProperty('children')) - { - // If it's a Group then we do it on the children regardless - this.enable(object[i].children.entries, type); - } - else - { - this.enableBody(object[i], type); - } - } - } - else if (object.hasOwnProperty('children')) - { - // If it's a Group then we do it on the children regardless - this.enable(object.children.entries, type); - } - else - { - this.enableBody(object, type); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#enableBody - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} object - [description] - * @param {integer} type - [description] - * - * @return {Phaser.GameObjects.GameObject} [description] - */ - enableBody: function (object, type) - { - if (object.body === null) - { - if (type === CONST.DYNAMIC_BODY) - { - object.body = new Body(this, object); - - this.bodies.set(object.body); - } - else if (type === CONST.STATIC_BODY) - { - object.body = new StaticBody(this, object); - - this.staticBodies.set(object.body); - - this.staticTree.insert(object.body); - } - } - - return object; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#remove - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} object - [description] - */ - remove: function (object) - { - this.disableBody(object); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#disable - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} object - [description] - */ - disable: function (object) - { - var i = 1; - - if (Array.isArray(object)) - { - i = object.length; - - while (i--) - { - if (object[i].hasOwnProperty('children')) - { - // If it's a Group then we do it on the children regardless - this.disable(object[i].children.entries); - } - else - { - this.disableGameObjectBody(object[i]); - } - } - } - else if (object.hasOwnProperty('children')) - { - // If it's a Group then we do it on the children regardless - this.disable(object.children.entries); - } - else - { - this.disableGameObjectBody(object); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#disableGameObjectBody - * @since 3.1.0 - * - * @param {Phaser.GameObjects.GameObject} object - [description] - * - * @return {Phaser.GameObjects.GameObject} [description] - */ - disableGameObjectBody: function (object) - { - if (object.body) - { - if (object.body.physicsType === CONST.DYNAMIC_BODY) - { - this.bodies.delete(object.body); - } - else if (object.body.physicsType === CONST.STATIC_BODY) - { - this.staticBodies.delete(object.body); - this.staticTree.remove(object.body); - } - - object.body.enable = false; - } - - return object; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#disableBody - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - [description] - */ - disableBody: function (body) - { - if (body.physicsType === CONST.DYNAMIC_BODY) - { - this.tree.remove(body); - this.bodies.delete(body); - } - else if (body.physicsType === CONST.STATIC_BODY) - { - this.staticBodies.delete(body); - this.staticTree.remove(body); - } - - body.enable = false; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#createDebugGraphic - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} [description] - */ - createDebugGraphic: function () - { - var graphic = this.scene.sys.add.graphics({ x: 0, y: 0 }); - - graphic.setDepth(Number.MAX_VALUE); - - this.debugGraphic = graphic; - - this.drawDebug = true; - - return graphic; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#setBounds - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {boolean} [checkLeft] - [description] - * @param {boolean} [checkRight] - [description] - * @param {boolean} [checkUp] - [description] - * @param {boolean} [checkDown] - [description] - * - * @return {Phaser.Physics.Arcade.World} This World object. - */ - setBounds: function (x, y, width, height, checkLeft, checkRight, checkUp, checkDown) - { - this.bounds.setTo(x, y, width, height); - - if (checkLeft !== undefined) - { - this.setBoundsCollision(checkLeft, checkRight, checkUp, checkDown); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#setBoundsCollision - * @since 3.0.0 - * - * @param {boolean} [left=true] - [description] - * @param {boolean} [right=true] - [description] - * @param {boolean} [up=true] - [description] - * @param {boolean} [down=true] - [description] - * - * @return {Phaser.Physics.Arcade.World} This World object. - */ - setBoundsCollision: function (left, right, up, down) - { - if (left === undefined) { left = true; } - if (right === undefined) { right = true; } - if (up === undefined) { up = true; } - if (down === undefined) { down = true; } - - this.checkCollision.left = left; - this.checkCollision.right = right; - this.checkCollision.up = up; - this.checkCollision.down = down; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#pause - * @since 3.0.0 - * - * @return {Phaser.Physics.Arcade.World} This World object. - */ - pause: function () - { - this.isPaused = true; - - this.emit('pause'); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#resume - * @since 3.0.0 - * - * @return {Phaser.Physics.Arcade.World} This World object. - */ - resume: function () - { - this.isPaused = false; - - this.emit('resume'); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#addCollider - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for collision. - * @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for collision. - * @param {function} collideCallback - The callback to invoke when the two objects collide. - * @param {function} processCallback - The callback to invoke when the two objects collide. Must return a boolean. - * @param {object} callbackContext - The scope in which to call the callbacks. - * - * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. - */ - addCollider: function (object1, object2, collideCallback, processCallback, callbackContext) - { - if (collideCallback === undefined) { collideCallback = null; } - if (processCallback === undefined) { processCallback = null; } - if (callbackContext === undefined) { callbackContext = collideCallback; } - - var collider = new Collider(this, false, object1, object2, collideCallback, processCallback, callbackContext); - - this.colliders.add(collider); - - return collider; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#addOverlap - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for overlap. - * @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for overlap. - * @param {function} collideCallback - The callback to invoke when the two objects overlap. - * @param {function} processCallback - The callback to invoke when the two objects overlap. Must return a boolean. - * @param {object} callbackContext - The scope in which to call the callbacks. - * - * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. - */ - addOverlap: function (object1, object2, collideCallback, processCallback, callbackContext) - { - if (collideCallback === undefined) { collideCallback = null; } - if (processCallback === undefined) { processCallback = null; } - if (callbackContext === undefined) { callbackContext = collideCallback; } - - var collider = new Collider(this, true, object1, object2, collideCallback, processCallback, callbackContext); - - this.colliders.add(collider); - - return collider; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#removeCollider - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Collider} collider - [description] - * - * @return {Phaser.Physics.Arcade.World} This World object. - */ - removeCollider: function (collider) - { - this.colliders.remove(collider); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#update - * @since 3.0.0 - * - * @param {number} time - [description] - * @param {number} delta - [description] - */ - update: function (time, delta) - { - if (this.isPaused || this.bodies.size === 0) - { - return; - } - - // this.delta = Math.min(delta / 1000, this.maxStep) * this.timeScale; - delta /= 1000; - - this.delta = delta; - - // Update all active bodies - - var i; - var body; - var bodies = this.bodies.entries; - var len = bodies.length; - - for (i = 0; i < len; i++) - { - body = bodies[i]; - - if (body.enable) - { - body.update(delta); - } - } - - // Populate our dynamic collision tree - this.tree.clear(); - this.tree.load(bodies); - - // Process any colliders - var colliders = this.colliders.update(); - - for (i = 0; i < colliders.length; i++) - { - var collider = colliders[i]; - - if (collider.active) - { - collider.update(); - } - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#postUpdate - * @since 3.0.0 - */ - postUpdate: function () - { - var i; - var body; - - var dynamic = this.bodies; - var staticBodies = this.staticBodies; - var pending = this.pendingDestroy; - - var bodies = dynamic.entries; - var len = bodies.length; - - for (i = 0; i < len; i++) - { - body = bodies[i]; - - if (body.enable) - { - body.postUpdate(); - } - } - - if (this.drawDebug) - { - var graphics = this.debugGraphic; - - graphics.clear(); - - for (i = 0; i < len; i++) - { - body = bodies[i]; - - if (body.willDrawDebug()) - { - body.drawDebug(graphics); - } - } - - bodies = staticBodies.entries; - len = bodies.length; - - for (i = 0; i < len; i++) - { - body = bodies[i]; - - if (body.willDrawDebug()) - { - body.drawDebug(graphics); - } - } - } - - if (pending.size > 0) - { - var dynamicTree = this.tree; - var staticTree = this.staticTree; - - bodies = pending.entries; - len = bodies.length; - - for (i = 0; i < len; i++) - { - body = bodies[i]; - - if (body.physicsType === CONST.DYNAMIC_BODY) - { - dynamicTree.remove(body); - dynamic.delete(body); - } - else if (body.physicsType === CONST.STATIC_BODY) - { - staticTree.remove(body); - staticBodies.delete(body); - } - - body.world = undefined; - body.gameObject = undefined; - } - - pending.clear(); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#updateMotion - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - [description] - */ - updateMotion: function (body) - { - if (body.allowRotation) - { - var velocityDelta = this.computeVelocity(0, body, body.angularVelocity, body.angularAcceleration, body.angularDrag, body.maxAngular) - body.angularVelocity; - - body.angularVelocity += velocityDelta; - body.rotation += (body.angularVelocity * this.delta); - } - - body.velocity.x = this.computeVelocity(1, body, body.velocity.x, body.acceleration.x, body.drag.x, body.maxVelocity.x); - body.velocity.y = this.computeVelocity(2, body, body.velocity.y, body.acceleration.y, body.drag.y, body.maxVelocity.y); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#computeVelocity - * @since 3.0.0 - * - * @param {integer} axis - [description] - * @param {Phaser.Physics.Arcade.Body} body - [description] - * @param {number} velocity - [description] - * @param {number} acceleration - [description] - * @param {number} drag - [description] - * @param {number} max - [description] - * - * @return {number} [description] - */ - computeVelocity: function (axis, body, velocity, acceleration, drag, max) - { - if (max === undefined) { max = 10000; } - - if (axis === 1 && body.allowGravity) - { - velocity += (this.gravity.x + body.gravity.x) * this.delta; - } - else if (axis === 2 && body.allowGravity) - { - velocity += (this.gravity.y + body.gravity.y) * this.delta; - } - - if (acceleration) - { - velocity += acceleration * this.delta; - } - else if (drag && body.allowDrag) - { - drag *= this.delta; - - if (velocity - drag > 0) - { - velocity -= drag; - } - else if (velocity + drag < 0) - { - velocity += drag; - } - else - { - velocity = 0; - } - } - - if (velocity > max) - { - velocity = max; - } - else if (velocity < -max) - { - velocity = -max; - } - - return velocity; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#separate - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {function} processCallback - [description] - * @param {object} callbackContext - [description] - * @param {boolean} overlapOnly - [description] - * - * @return {boolean} [description] - */ - separate: function (body1, body2, processCallback, callbackContext, overlapOnly) - { - if ( - !body1.enable || - !body2.enable || - body1.checkCollision.none || - body2.checkCollision.none || - !this.intersects(body1, body2)) - { - return false; - } - - // They overlap. Is there a custom process callback? If it returns true then we can carry on, otherwise we should abort. - if (processCallback && processCallback.call(callbackContext, body1.gameObject, body2.gameObject) === false) - { - return false; - } - - // Circle vs. Circle quick bail out - if (body1.isCircle && body2.isCircle) - { - return this.separateCircle(body1, body2, overlapOnly); - } - - // We define the behavior of bodies in a collision circle and rectangle - // If a collision occurs in the corner points of the rectangle, the body behave like circles - - // Either body1 or body2 is a circle - if (body1.isCircle !== body2.isCircle) - { - var bodyRect = (body1.isCircle) ? body2 : body1; - var bodyCircle = (body1.isCircle) ? body1 : body2; - - var rect = { - x: bodyRect.x, - y: bodyRect.y, - right: bodyRect.right, - bottom: bodyRect.bottom - }; - - var circle = bodyCircle.center; - - if (circle.y < rect.y || circle.y > rect.bottom) - { - if (circle.x < rect.x || circle.x > rect.right) - { - return this.separateCircle(body1, body2, overlapOnly); - } - } - } - - var resultX = false; - var resultY = false; - - // Do we separate on x or y first? - if (this.forceX || Math.abs(this.gravity.y + body1.gravity.y) < Math.abs(this.gravity.x + body1.gravity.x)) - { - resultX = SeparateX(body1, body2, overlapOnly, this.OVERLAP_BIAS); - - // Are they still intersecting? Let's do the other axis then - if (this.intersects(body1, body2)) - { - resultY = SeparateY(body1, body2, overlapOnly, this.OVERLAP_BIAS); - } - } - else - { - resultY = SeparateY(body1, body2, overlapOnly, this.OVERLAP_BIAS); - - // Are they still intersecting? Let's do the other axis then - if (this.intersects(body1, body2)) - { - resultX = SeparateX(body1, body2, overlapOnly, this.OVERLAP_BIAS); - } - } - - var result = (resultX || resultY); - - if (result) - { - if (overlapOnly && (body1.onOverlap || body2.onOverlap)) - { - this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2); - } - else if (body1.onCollide || body2.onCollide) - { - this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); - } - } - - return result; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#separateCircle - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {boolean} overlapOnly - [description] - * @param {number} bias - [description] - * - * @return {boolean} [description] - */ - separateCircle: function (body1, body2, overlapOnly, bias) - { - // Set the bounding box overlap values into the bodies themselves (hence we don't use the return values here) - GetOverlapX(body1, body2, false, bias); - GetOverlapY(body1, body2, false, bias); - - var dx = body2.center.x - body1.center.x; - var dy = body2.center.y - body1.center.y; - - var angleCollision = Math.atan2(dy, dx); - - var overlap = 0; - - if (body1.isCircle !== body2.isCircle) - { - var rect = { - x: (body2.isCircle) ? body1.position.x : body2.position.x, - y: (body2.isCircle) ? body1.position.y : body2.position.y, - right: (body2.isCircle) ? body1.right : body2.right, - bottom: (body2.isCircle) ? body1.bottom : body2.bottom - }; - - var circle = { - x: (body1.isCircle) ? body1.center.x : body2.center.x, - y: (body1.isCircle) ? body1.center.y : body2.center.y, - radius: (body1.isCircle) ? body1.halfWidth : body2.halfWidth - }; - - if (circle.y < rect.y) - { - if (circle.x < rect.x) - { - overlap = DistanceBetween(circle.x, circle.y, rect.x, rect.y) - circle.radius; - } - else if (circle.x > rect.right) - { - overlap = DistanceBetween(circle.x, circle.y, rect.right, rect.y) - circle.radius; - } - } - else if (circle.y > rect.bottom) - { - if (circle.x < rect.x) - { - overlap = DistanceBetween(circle.x, circle.y, rect.x, rect.bottom) - circle.radius; - } - else if (circle.x > rect.right) - { - overlap = DistanceBetween(circle.x, circle.y, rect.right, rect.bottom) - circle.radius; - } - } - - overlap *= -1; - } - else - { - overlap = (body1.halfWidth + body2.halfWidth) - DistanceBetween(body1.center.x, body1.center.y, body2.center.x, body2.center.y); - } - - // Can't separate two immovable bodies, or a body with its own custom separation logic - if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateX || body2.customSeparateX) - { - if (overlap !== 0 && (body1.onOverlap || body2.onOverlap)) - { - this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2); - } - - // return true if there was some overlap, otherwise false - return (overlap !== 0); - } - - // Transform the velocity vector to the coordinate system oriented along the direction of impact. - // This is done to eliminate the vertical component of the velocity - - var b1vx = body1.velocity.x; - var b1vy = body1.velocity.y; - var b1mass = body1.mass; - - var b2vx = body2.velocity.x; - var b2vy = body2.velocity.y; - var b2mass = body2.mass; - - var v1 = { - x: b1vx * Math.cos(angleCollision) + b1vy * Math.sin(angleCollision), - y: b1vx * Math.sin(angleCollision) - b1vy * Math.cos(angleCollision) - }; - - var v2 = { - x: b2vx * Math.cos(angleCollision) + b2vy * Math.sin(angleCollision), - y: b2vx * Math.sin(angleCollision) - b2vy * Math.cos(angleCollision) - }; - - // We expect the new velocity after impact - var tempVel1 = ((b1mass - b2mass) * v1.x + 2 * b2mass * v2.x) / (b1mass + b2mass); - var tempVel2 = (2 * b1mass * v1.x + (b2mass - b1mass) * v2.x) / (b1mass + b2mass); - - // We convert the vector to the original coordinate system and multiplied by factor of rebound - if (!body1.immovable) - { - body1.velocity.x = (tempVel1 * Math.cos(angleCollision) - v1.y * Math.sin(angleCollision)) * body1.bounce.x; - body1.velocity.y = (v1.y * Math.cos(angleCollision) + tempVel1 * Math.sin(angleCollision)) * body1.bounce.y; - - // Reset local var - b1vx = body1.velocity.x; - b1vy = body1.velocity.y; - } - - if (!body2.immovable) - { - body2.velocity.x = (tempVel2 * Math.cos(angleCollision) - v2.y * Math.sin(angleCollision)) * body2.bounce.x; - body2.velocity.y = (v2.y * Math.cos(angleCollision) + tempVel2 * Math.sin(angleCollision)) * body2.bounce.y; - - // Reset local var - b2vx = body2.velocity.x; - b2vy = body2.velocity.y; - } - - // When the collision angle is almost perpendicular to the total initial velocity vector - // (collision on a tangent) vector direction can be determined incorrectly. - // This code fixes the problem - - if (Math.abs(angleCollision) < Math.PI / 2) - { - if ((b1vx > 0) && !body1.immovable && (b2vx > b1vx)) - { - body1.velocity.x *= -1; - } - else if ((b2vx < 0) && !body2.immovable && (b1vx < b2vx)) - { - body2.velocity.x *= -1; - } - else if ((b1vy > 0) && !body1.immovable && (b2vy > b1vy)) - { - body1.velocity.y *= -1; - } - else if ((b2vy < 0) && !body2.immovable && (b1vy < b2vy)) - { - body2.velocity.y *= -1; - } - } - else if (Math.abs(angleCollision) > Math.PI / 2) - { - if ((b1vx < 0) && !body1.immovable && (b2vx < b1vx)) - { - body1.velocity.x *= -1; - } - else if ((b2vx > 0) && !body2.immovable && (b1vx > b2vx)) - { - body2.velocity.x *= -1; - } - else if ((b1vy < 0) && !body1.immovable && (b2vy < b1vy)) - { - body1.velocity.y *= -1; - } - else if ((b2vy > 0) && !body2.immovable && (b1vx > b2vy)) - { - body2.velocity.y *= -1; - } - } - - if (!body1.immovable) - { - body1.x += (body1.velocity.x * this.delta) - overlap * Math.cos(angleCollision); - body1.y += (body1.velocity.y * this.delta) - overlap * Math.sin(angleCollision); - } - - if (!body2.immovable) - { - body2.x += (body2.velocity.x * this.delta) + overlap * Math.cos(angleCollision); - body2.y += (body2.velocity.y * this.delta) + overlap * Math.sin(angleCollision); - } - - if (body1.onCollide || body2.onCollide) - { - this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); - } - - return true; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#intersects - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * - * @return {boolean} [description] - */ - intersects: function (body1, body2) - { - if (body1 === body2) - { - return false; - } - - if (body1.isCircle) - { - if (body2.isCircle) - { - // Circle vs. Circle - return DistanceBetween(body1.center.x, body1.center.y, body2.center.x, body2.center.y) <= (body1.halfWidth + body2.halfWidth); - } - else - { - // Circle vs. Rect - return this.circleBodyIntersects(body1, body2); - } - } - else if (body2.isCircle) - { - // Rect vs. Circle - return this.circleBodyIntersects(body2, body1); - } - else - { - // Rect vs. Rect - if (body1.right <= body2.position.x) - { - return false; - } - - if (body1.bottom <= body2.position.y) - { - return false; - } - - if (body1.position.x >= body2.right) - { - return false; - } - - if (body1.position.y >= body2.bottom) - { - return false; - } - - return true; - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#circleBodyIntersects - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} circle - [description] - * @param {Phaser.Physics.Arcade.Body} body - [description] - * - * @return {boolean} [description] - */ - circleBodyIntersects: function (circle, body) - { - var x = Clamp(circle.center.x, body.left, body.right); - var y = Clamp(circle.center.y, body.top, body.bottom); - - var dx = (circle.center.x - x) * (circle.center.x - x); - var dy = (circle.center.y - y) * (circle.center.y - y); - - return (dx + dy) <= (circle.halfWidth * circle.halfWidth); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#overlap - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} object1 - [description] - * @param {Phaser.GameObjects.GameObject} object2 - [description] - * @param {function} overlapCallback - [description] - * @param {function} processCallback - [description] - * @param {object} callbackContext - [description] - * - * @return {boolean} [description] - */ - overlap: function (object1, object2, overlapCallback, processCallback, callbackContext) - { - if (overlapCallback === undefined) { overlapCallback = null; } - if (processCallback === undefined) { processCallback = null; } - if (callbackContext === undefined) { callbackContext = overlapCallback; } - - return this.collideObjects(object1, object2, overlapCallback, processCallback, callbackContext, true); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#collide - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} object1 - [description] - * @param {Phaser.GameObjects.GameObject} object2 - [description] - * @param {function} collideCallback - [description] - * @param {function} processCallback - [description] - * @param {object} callbackContext - [description] - * - * @return {boolean} [description] - */ - collide: function (object1, object2, collideCallback, processCallback, callbackContext) - { - if (collideCallback === undefined) { collideCallback = null; } - if (processCallback === undefined) { processCallback = null; } - if (callbackContext === undefined) { callbackContext = collideCallback; } - - return this.collideObjects(object1, object2, collideCallback, processCallback, callbackContext, false); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#collideObjects - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} object1 - [description] - * @param {Phaser.GameObjects.GameObject} object2 - [description] - * @param {function} collideCallback - [description] - * @param {function} processCallback - [description] - * @param {object} callbackContext - [description] - * @param {boolean} overlapOnly - [description] - * - * @return {boolean} [description] - */ - collideObjects: function (object1, object2, collideCallback, processCallback, callbackContext, overlapOnly) - { - var i; - object1 = object1.isParent && typeof(object1.physicsType) === 'undefined' ? object1.children.entries : object1; - object2 = object2.isParent && typeof(object2.physicsType) === 'undefined' ? object2.children.entries : object2; - var object1isArray = Array.isArray(object1); - var object2isArray = Array.isArray(object2); - - this._total = 0; - - if (!object1isArray && !object2isArray) - { - // Neither of them are arrays - do this first as it's the most common use-case - this.collideHandler(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (!object1isArray && object2isArray) - { - // Object 2 is an Array - for (i = 0; i < object2.length; i++) - { - this.collideHandler(object1, object2[i], collideCallback, processCallback, callbackContext, overlapOnly); - } - } - else if (object1isArray && !object2isArray) - { - // Object 1 is an Array - for (i = 0; i < object1.length; i++) - { - this.collideHandler(object1[i], object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - } - else - { - // They're both arrays - for (i = 0; i < object1.length; i++) - { - for (var j = 0; j < object2.length; j++) - { - this.collideHandler(object1[i], object2[j], collideCallback, processCallback, callbackContext, overlapOnly); - } - } - } - - return (this._total > 0); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#collideHandler - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} object1 - [description] - * @param {Phaser.GameObjects.GameObject} object2 - [description] - * @param {function} collideCallback - [description] - * @param {function} processCallback - [description] - * @param {object} callbackContext - [description] - * @param {boolean} overlapOnly - [description] - * - * @return {boolean} [description] - */ - collideHandler: function (object1, object2, collideCallback, processCallback, callbackContext, overlapOnly) - { - // Collide Group with Self - // Only collide valid objects - if (object2 === undefined && object1.isParent) - { - return this.collideGroupVsGroup(object1, object1, collideCallback, processCallback, callbackContext, overlapOnly); - } - - // If neither of the objects are set then bail out - if (!object1 || !object2) - { - return false; - } - - // A Body - if (object1.body) - { - if (object2.body) - { - return this.collideSpriteVsSprite(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (object2.isParent) - { - return this.collideSpriteVsGroup(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (object2.isTilemap) - { - return this.collideSpriteVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - } - - // GROUPS - else if (object1.isParent) - { - if (object2.body) - { - return this.collideSpriteVsGroup(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (object2.isParent) - { - return this.collideGroupVsGroup(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (object2.isTilemap) - { - return this.collideGroupVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - } - - // TILEMAP LAYERS - else if (object1.isTilemap) - { - if (object2.body) - { - return this.collideSpriteVsTilemapLayer(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (object2.isParent) - { - return this.collideGroupVsTilemapLayer(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); - } - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#collideSpriteVsSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} sprite1 - [description] - * @param {Phaser.GameObjects.GameObject} sprite2 - [description] - * @param {function} collideCallback - [description] - * @param {function} processCallback - [description] - * @param {object} callbackContext - [description] - * @param {boolean} overlapOnly - [description] - * - * @return {boolean} [description] - */ - collideSpriteVsSprite: function (sprite1, sprite2, collideCallback, processCallback, callbackContext, overlapOnly) - { - if (!sprite1.body || !sprite2.body) - { - return false; - } - - if (this.separate(sprite1.body, sprite2.body, processCallback, callbackContext, overlapOnly)) - { - if (collideCallback) - { - collideCallback.call(callbackContext, sprite1, sprite2); - } - - this._total++; - } - - return true; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#collideSpriteVsGroup - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} sprite - [description] - * @param {Phaser.GameObjects.Group} group - [description] - * @param {function} collideCallback - [description] - * @param {function} processCallback - [description] - * @param {object} callbackContext - [description] - * @param {boolean} overlapOnly - [description] - * - * @return {boolean} [description] - */ - collideSpriteVsGroup: function (sprite, group, collideCallback, processCallback, callbackContext, overlapOnly) - { - var bodyA = sprite.body; - - if (group.length === 0 || !bodyA) - { - return; - } - - // Does sprite collide with anything? - - var minMax = this.treeMinMax; - - minMax.minX = bodyA.left; - minMax.minY = bodyA.top; - minMax.maxX = bodyA.right; - minMax.maxY = bodyA.bottom; - - var results = (group.physicsType === CONST.DYNAMIC_BODY) ? this.tree.search(minMax) : this.staticTree.search(minMax); - - if (results.length === 0) - { - return; - } - - var children = group.getChildren(); - - for (var i = 0; i < children.length; i++) - { - var bodyB = children[i].body; - - if (!bodyB || bodyA === bodyB || results.indexOf(bodyB) === -1) - { - continue; - } - - if (this.separate(bodyA, bodyB, processCallback, callbackContext, overlapOnly)) - { - if (collideCallback) - { - collideCallback.call(callbackContext, bodyA.gameObject, bodyB.gameObject); - } - - this._total++; - } - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#collideGroupVsTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Group} group - [description] - * @param {[type]} tilemapLayer - [description] - * @param {function} collideCallback - [description] - * @param {function} processCallback - [description] - * @param {object} callbackContext - [description] - * @param {boolean} overlapOnly - [description] - * - * @return {boolean} [description] - */ - collideGroupVsTilemapLayer: function (group, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) - { - var children = group.getChildren(); - - if (children.length === 0) - { - return false; - } - - var didCollide = false; - - for (var i = 0; i < children.length; i++) - { - if (children[i].body) - { - if (this.collideSpriteVsTilemapLayer(children[i], tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly)) - { - didCollide = true; - } - } - } - - return didCollide; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#collideSpriteVsTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} sprite - [description] - * @param {[type]} tilemapLayer - [description] - * @param {function} collideCallback - [description] - * @param {function} processCallback - [description] - * @param {object} callbackContext - [description] - * @param {boolean} overlapOnly - [description] - * - * @return {boolean} [description] - */ - collideSpriteVsTilemapLayer: function (sprite, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) - { - var body = sprite.body; - - if (!body.enable) - { - return false; - } - - var x = body.position.x; - var y = body.position.y; - var w = body.width; - var h = body.height; - - // TODO: this logic should be encapsulated within the Tilemap API at some point. - // If the maps base tile size differs from the layer's tile size, we need to adjust the - // selection area by the difference between the two. - var layerData = tilemapLayer.layer; - - if (layerData.tileWidth > layerData.baseTileWidth) - { - // The x origin of a tile is the left side, so x and width need to be adjusted. - var xDiff = (layerData.tileWidth - layerData.baseTileWidth) * tilemapLayer.scaleX; - x -= xDiff; - w += xDiff; - } - - if (layerData.tileHeight > layerData.baseTileHeight) - { - // The y origin of a tile is the bottom side, so just the height needs to be adjusted. - var yDiff = (layerData.tileHeight - layerData.baseTileHeight) * tilemapLayer.scaleY; - h += yDiff; - } - - var mapData = tilemapLayer.getTilesWithinWorldXY(x, y, w, h); - - if (mapData.length === 0) - { - return false; - } - - var tile; - var tileWorldRect = { left: 0, right: 0, top: 0, bottom: 0 }; - - for (var i = 0; i < mapData.length; i++) - { - tile = mapData[i]; - tileWorldRect.left = tilemapLayer.tileToWorldX(tile.x); - tileWorldRect.top = tilemapLayer.tileToWorldY(tile.y); - - // If the map's base tile size differs from the layer's tile size, only the top of the rect - // needs to be adjusted since it's origin is (0, 1). - if (tile.baseHeight !== tile.height) - { - tileWorldRect.top -= (tile.height - tile.baseHeight) * tilemapLayer.scaleY; - } - - tileWorldRect.right = tileWorldRect.left + tile.width * tilemapLayer.scaleX; - tileWorldRect.bottom = tileWorldRect.top + tile.height * tilemapLayer.scaleY; - - if (TileIntersectsBody(tileWorldRect, body) - && (!processCallback || processCallback.call(callbackContext, sprite, tile)) - && ProcessTileCallbacks(tile, sprite) - && (overlapOnly || SeparateTile(i, body, tile, tileWorldRect, tilemapLayer, this.TILE_BIAS))) - { - this._total++; - - if (collideCallback) - { - collideCallback.call(callbackContext, sprite, tile); - } - - if (overlapOnly && body.onOverlap) - { - sprite.emit('overlap', body.gameObject, tile, body, null); - } - else if (body.onCollide) - { - sprite.emit('collide', body.gameObject, tile, body, null); - } - } - } - }, - - /** - * TODO! - * - * @method Phaser.Physics.Arcade.World#collideGroupVsGroup - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Group} group1 - [description] - * @param {Phaser.GameObjects.Group} group2 - [description] - * @param {function} collideCallback - [description] - * @param {function} processCallback - [description] - * @param {object} callbackContext - [description] - * @param {boolean} overlapOnly - [description] - * - * @return {boolean} [description] - */ - collideGroupVsGroup: function (group1, group2, collideCallback, processCallback, callbackContext, overlapOnly) - { - if (group1.length === 0 || group2.length === 0) - { - return; - } - - var children = group1.getChildren(); - - for (var i = 0; i < children.length; i++) - { - this.collideSpriteVsGroup(children[i], group2, collideCallback, processCallback, callbackContext, overlapOnly); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this.removeAllListeners(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.tree.clear(); - this.staticTree.clear(); - this.bodies.clear(); - this.staticBodies.clear(); - this.colliders.destroy(); - - this.removeAllListeners(); - } - -}); - -module.exports = World; - - -/***/ }), -/* 332 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CircleContains = __webpack_require__(32); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(59); -var Rectangle = __webpack_require__(8); -var RectangleContains = __webpack_require__(33); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * [description] - * - * @class Body - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.World} world - [description] - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - */ -var Body = new Class({ - - initialize: - - function Body (world, gameObject) - { - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world = world; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#gameObject - * @type {Phaser.GameObjects.GameObject} - * @since 3.0.0 - */ - this.gameObject = gameObject; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#debugShowBody - * @type {boolean} - * @since 3.0.0 - */ - this.debugShowBody = world.defaults.debugShowBody; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#debugShowVelocity - * @type {boolean} - * @since 3.0.0 - */ - this.debugShowVelocity = world.defaults.debugShowVelocity; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#debugBodyColor - * @type {integer} - * @since 3.0.0 - */ - this.debugBodyColor = world.defaults.bodyDebugColor; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#enable - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.enable = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#isCircle - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isCircle = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#radius - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.radius = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#offset - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.offset = new Vector2(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#position - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.position = new Vector2(gameObject.x, gameObject.y); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#prev - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.prev = new Vector2(this.position.x, this.position.y); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#allowRotation - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.allowRotation = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#rotation - * @type {number} - * @since 3.0.0 - */ - this.rotation = gameObject.angle; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#preRotation - * @type {number} - * @since 3.0.0 - */ - this.preRotation = gameObject.angle; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#width - * @type {number} - * @since 3.0.0 - */ - this.width = gameObject.width; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#height - * @type {number} - * @since 3.0.0 - */ - this.height = gameObject.height; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#sourceWidth - * @type {number} - * @since 3.0.0 - */ - this.sourceWidth = gameObject.width; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#sourceHeight - * @type {number} - * @since 3.0.0 - */ - this.sourceHeight = gameObject.height; - - if (gameObject.frame) - { - this.sourceWidth = gameObject.frame.realWidth; - this.sourceHeight = gameObject.frame.realHeight; - } - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#halfWidth - * @type {number} - * @since 3.0.0 - */ - this.halfWidth = Math.abs(gameObject.width / 2); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#halfHeight - * @type {number} - * @since 3.0.0 - */ - this.halfHeight = Math.abs(gameObject.height / 2); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#center - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#velocity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.velocity = new Vector2(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#newVelocity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.newVelocity = new Vector2(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#deltaMax - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.deltaMax = new Vector2(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#acceleration - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.acceleration = new Vector2(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#allowDrag - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.allowDrag = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#drag - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.drag = new Vector2(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#allowGravity - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.allowGravity = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#gravity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.gravity = new Vector2(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#bounce - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.bounce = new Vector2(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#worldBounce - * @type {?[type]} - * @default null - * @since 3.0.0 - */ - this.worldBounce = null; - - // If true this Body will dispatch events - - /** - * Emit a `worldbounds` event when this body collides with the world bounds (and `collideWorldBounds` is also true). - * - * @name Phaser.Physics.Arcade.Body#onWorldBounds - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.onWorldBounds = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#onCollide - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.onCollide = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#onOverlap - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.onOverlap = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#maxVelocity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.maxVelocity = new Vector2(10000, 10000); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#friction - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.friction = new Vector2(1, 0); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#angularVelocity - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.angularVelocity = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#angularAcceleration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.angularAcceleration = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#angularDrag - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.angularDrag = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#maxAngular - * @type {number} - * @default 1000 - * @since 3.0.0 - */ - this.maxAngular = 1000; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#mass - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.mass = 1; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#angle - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.angle = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#speed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.speed = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#facing - * @type {integer} - * @since 3.0.0 - */ - this.facing = CONST.FACING_NONE; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#immovable - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.immovable = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#moves - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.moves = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#customSeparateX - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.customSeparateX = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#customSeparateY - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.customSeparateY = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#overlapX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapX = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#overlapY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapY = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#overlapR - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapR = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#embedded - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.embedded = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#collideWorldBounds - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.collideWorldBounds = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#checkCollision - * @type {object} - * @since 3.0.0 - */ - this.checkCollision = { none: false, up: true, down: true, left: true, right: true }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#touching - * @type {object} - * @since 3.0.0 - */ - this.touching = { none: true, up: false, down: false, left: false, right: false }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#wasTouching - * @type {object} - * @since 3.0.0 - */ - this.wasTouching = { none: true, up: false, down: false, left: false, right: false }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#blocked - * @type {object} - * @since 3.0.0 - */ - this.blocked = { none: true, up: false, down: false, left: false, right: false }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#dirty - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.dirty = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#syncBounds - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.syncBounds = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#isMoving - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isMoving = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#stopVelocityOnCollide - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.stopVelocityOnCollide = true; - - // read-only - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#physicsType - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.physicsType = CONST.DYNAMIC_BODY; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#_reset - * @type {boolean} - * @private - * @default true - * @since 3.0.0 - */ - this._reset = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#_sx - * @type {number} - * @private - * @since 3.0.0 - */ - this._sx = gameObject.scaleX; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#_sy - * @type {number} - * @private - * @since 3.0.0 - */ - this._sy = gameObject.scaleY; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#_dx - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._dx = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#_dy - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._dy = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#_bounds - * @type {Phaser.Geom.Rectangle} - * @private - * @since 3.0.0 - */ - this._bounds = new Rectangle(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#updateBounds - * @since 3.0.0 - */ - updateBounds: function () - { - var sprite = this.gameObject; - - if (this.syncBounds) - { - var b = sprite.getBounds(this._bounds); - - if (b.width !== this.width || b.height !== this.height) - { - this.width = b.width; - this.height = b.height; - this._reset = true; - } - } - else - { - var asx = Math.abs(sprite.scaleX); - var asy = Math.abs(sprite.scaleY); - - if (asx !== this._sx || asy !== this._sy) - { - this.width = this.sourceWidth * asx; - this.height = this.sourceHeight * asy; - this._sx = asx; - this._sy = asy; - this._reset = true; - } - } - - if (this._reset) - { - this.halfWidth = Math.floor(this.width / 2); - this.halfHeight = Math.floor(this.height / 2); - this.updateCenter(); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#updateCenter - * @since 3.0.0 - */ - updateCenter: function () - { - this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#update - * @since 3.0.0 - * - * @param {number} delta - [description] - */ - update: function (delta) - { - this.dirty = true; - - // Store and reset collision flags - this.wasTouching.none = this.touching.none; - this.wasTouching.up = this.touching.up; - this.wasTouching.down = this.touching.down; - this.wasTouching.left = this.touching.left; - this.wasTouching.right = this.touching.right; - - this.touching.none = true; - this.touching.up = false; - this.touching.down = false; - this.touching.left = false; - this.touching.right = false; - - this.blocked.none = true; - this.blocked.up = false; - this.blocked.down = false; - this.blocked.left = false; - this.blocked.right = false; - - this.overlapR = 0; - this.overlapX = 0; - this.overlapY = 0; - - this.embedded = false; - - this.updateBounds(); - - var sprite = this.gameObject; - - this.position.x = sprite.x + sprite.scaleX * (this.offset.x - sprite.displayOriginX); - this.position.y = sprite.y + sprite.scaleY * (this.offset.y - sprite.displayOriginY); - - this.updateCenter(); - - this.rotation = sprite.angle; - - this.preRotation = this.rotation; - - if (this._reset) - { - this.prev.x = this.position.x; - this.prev.y = this.position.y; - } - - if (this.moves) - { - this.world.updateMotion(this); - - this.newVelocity.set(this.velocity.x * delta, this.velocity.y * delta); - - this.position.x += this.newVelocity.x; - this.position.y += this.newVelocity.y; - - this.updateCenter(); - - if (this.position.x !== this.prev.x || this.position.y !== this.prev.y) - { - this.angle = Math.atan2(this.velocity.y, this.velocity.x); - } - - this.speed = Math.sqrt(this.velocity.x * this.velocity.x + this.velocity.y * this.velocity.y); - - // Now the State update will throw collision checks at the Body - // And finally we'll integrate the new position back to the Sprite in postUpdate - - if (this.collideWorldBounds && this.checkWorldBounds() && this.onWorldBounds) - { - this.world.emit('worldbounds', this, this.blocked.up, this.blocked.down, this.blocked.left, this.blocked.right); - } - } - - this._dx = this.deltaX(); - this._dy = this.deltaY(); - - this._reset = false; - }, - - /** - * Feeds the body results back into the parent gameobject. - * - * @method Phaser.Physics.Arcade.Body#postUpdate - * @since 3.0.0 - */ - postUpdate: function () - { - // Only allow postUpdate to be called once per frame - if (!this.enable || !this.dirty) - { - return; - } - - this.dirty = false; - - this._dx = this.deltaX(); - this._dy = this.deltaY(); - - if (this._dx < 0) - { - this.facing = CONST.FACING_LEFT; - } - else if (this._dx > 0) - { - this.facing = CONST.FACING_RIGHT; - } - - if (this._dy < 0) - { - this.facing = CONST.FACING_UP; - } - else if (this._dy > 0) - { - this.facing = CONST.FACING_DOWN; - } - - if (this.moves) - { - if (this.deltaMax.x !== 0 && this._dx !== 0) - { - if (this._dx < 0 && this._dx < -this.deltaMax.x) - { - this._dx = -this.deltaMax.x; - } - else if (this._dx > 0 && this._dx > this.deltaMax.x) - { - this._dx = this.deltaMax.x; - } - } - - if (this.deltaMax.y !== 0 && this._dy !== 0) - { - if (this._dy < 0 && this._dy < -this.deltaMax.y) - { - this._dy = -this.deltaMax.y; - } - else if (this._dy > 0 && this._dy > this.deltaMax.y) - { - this._dy = this.deltaMax.y; - } - } - - this.gameObject.x += this._dx; - this.gameObject.y += this._dy; - - this._reset = true; - } - - this.updateCenter(); - - if (this.allowRotation) - { - this.gameObject.angle += this.deltaZ(); - } - - this.prev.x = this.position.x; - this.prev.y = this.position.y; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#checkWorldBounds - * @since 3.0.0 - * - * @return {boolean} [description] - */ - checkWorldBounds: function () - { - var pos = this.position; - var bounds = this.world.bounds; - var check = this.world.checkCollision; - - var bx = (this.worldBounce) ? -this.worldBounce.x : -this.bounce.x; - var by = (this.worldBounce) ? -this.worldBounce.y : -this.bounce.y; - - if (pos.x < bounds.x && check.left) - { - pos.x = bounds.x; - this.velocity.x *= bx; - this.blocked.left = true; - this.blocked.none = false; - } - else if (this.right > bounds.right && check.right) - { - pos.x = bounds.right - this.width; - this.velocity.x *= bx; - this.blocked.right = true; - this.blocked.none = false; - } - - if (pos.y < bounds.y && check.up) - { - pos.y = bounds.y; - this.velocity.y *= by; - this.blocked.up = true; - this.blocked.none = false; - } - else if (this.bottom > bounds.bottom && check.down) - { - pos.y = bounds.bottom - this.height; - this.velocity.y *= by; - this.blocked.down = true; - this.blocked.none = false; - } - - return !this.blocked.none; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setOffset - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setOffset: function (x, y) - { - if (y === undefined) { y = x; } - - this.offset.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setSize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {boolean} [center=true] - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setSize: function (width, height, center) - { - if (center === undefined) { center = true; } - - var gameObject = this.gameObject; - - this.sourceWidth = width; - this.sourceHeight = height; - - this.width = this.sourceWidth * this._sx; - this.height = this.sourceHeight * this._sy; - - this.halfWidth = Math.floor(this.width / 2); - this.halfHeight = Math.floor(this.height / 2); - - this.updateCenter(); - - if (center && gameObject.getCenter) - { - var ox = gameObject.displayWidth / 2; - var oy = gameObject.displayHeight / 2; - - this.offset.set(ox - this.halfWidth, oy - this.halfHeight); - } - - this.isCircle = false; - this.radius = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setCircle - * @since 3.0.0 - * - * @param {number} radius - [description] - * @param {number} [offsetX] - [description] - * @param {number} [offsetY] - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setCircle: function (radius, offsetX, offsetY) - { - if (offsetX === undefined) { offsetX = this.offset.x; } - if (offsetY === undefined) { offsetY = this.offset.y; } - - if (radius > 0) - { - this.isCircle = true; - this.radius = radius; - - this.sourceWidth = radius * 2; - this.sourceHeight = radius * 2; - - this.width = this.sourceWidth * this._sx; - this.height = this.sourceHeight * this._sy; - - this.halfWidth = Math.floor(this.width / 2); - this.halfHeight = Math.floor(this.height / 2); - - this.offset.set(offsetX, offsetY); - - this.updateCenter(); - } - else - { - this.isCircle = false; - } - - return this; - }, - - /** - * Resets this Body to the given coordinates. Also positions its parent Game Object to the same coordinates. - * If the body had any velocity or acceleration it is lost as a result of calling this. - * - * @method Phaser.Physics.Arcade.Body#reset - * @since 3.0.0 - * - * @param {number} x - The horizontal position to place the Game Object and Body. - * @param {number} y - The vertical position to place the Game Object and Body. - */ - reset: function (x, y) - { - this.stop(); - - var gameObject = this.gameObject; - - gameObject.setPosition(x, y); - - gameObject.getTopLeft(this.position); - - this.prev.copy(this.position); - - this.rotation = gameObject.angle; - this.preRotation = gameObject.angle; - - this.updateBounds(); - this.updateCenter(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#stop - * @since 3.0.0 - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - stop: function () - { - this.velocity.set(0); - this.acceleration.set(0); - this.speed = 0; - this.angularVelocity = 0; - this.angularAcceleration = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#getBounds - * @since 3.0.0 - * - * @param {object} obj - [description] - * - * @return {object} [description] - */ - getBounds: function (obj) - { - obj.x = this.x; - obj.y = this.y; - obj.right = this.right; - obj.bottom = this.bottom; - - return obj; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#hitTest - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ - hitTest: function (x, y) - { - return (this.isCircle) ? CircleContains(this, x, y) : RectangleContains(this, x, y); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#onFloor - * @since 3.0.0 - * - * @return {boolean} [description] - */ - onFloor: function () - { - return this.blocked.down; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#onCeiling - * @since 3.0.0 - * - * @return {boolean} [description] - */ - onCeiling: function () - { - return this.blocked.up; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#onWall - * @since 3.0.0 - * - * @return {boolean} [description] - */ - onWall: function () - { - return (this.blocked.left || this.blocked.right); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#deltaAbsX - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaAbsX: function () - { - return (this.deltaX() > 0) ? this.deltaX() : -this.deltaX(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#deltaAbsY - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaAbsY: function () - { - return (this.deltaY() > 0) ? this.deltaY() : -this.deltaY(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#deltaX - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaX: function () - { - return this.position.x - this.prev.x; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#deltaY - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaY: function () - { - return this.position.y - this.prev.y; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#deltaZ - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaZ: function () - { - return this.rotation - this.preRotation; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.enable = false; - - this.world.pendingDestroy.set(this); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#drawDebug - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphic - [description] - */ - drawDebug: function (graphic) - { - var pos = this.position; - var x = pos.x + this.halfWidth; - var y = pos.y + this.halfHeight; - - if (this.debugShowBody) - { - graphic.lineStyle(1, this.debugBodyColor); - - if (this.isCircle) - { - graphic.strokeCircle(x, y, this.radius); - } - else - { - graphic.strokeRect(pos.x, pos.y, this.width, this.height); - } - } - - if (this.debugShowVelocity) - { - graphic.lineStyle(1, this.world.defaults.velocityDebugColor, 1); - graphic.lineBetween(x, y, x + this.velocity.x / 2, y + this.velocity.y / 2); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#willDrawDebug - * @since 3.0.0 - * - * @return {boolean} [description] - */ - willDrawDebug: function () - { - return (this.debugShowBody || this.debugShowVelocity); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setCollideWorldBounds - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setCollideWorldBounds: function (value) - { - this.collideWorldBounds = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setVelocity - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setVelocity: function (x, y) - { - this.velocity.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setVelocityX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setVelocityX: function (value) - { - this.velocity.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setVelocityY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setVelocityY: function (value) - { - this.velocity.y = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setBounce - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setBounce: function (x, y) - { - this.bounce.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setBounceX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setBounceX: function (value) - { - this.bounce.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setBounceY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setBounceY: function (value) - { - this.bounce.y = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setAcceleration - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAcceleration: function (x, y) - { - this.acceleration.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setAccelerationX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAccelerationX: function (value) - { - this.acceleration.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setAccelerationY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAccelerationY: function (value) - { - this.acceleration.y = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setDrag - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setDrag: function (x, y) - { - this.drag.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setDragX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setDragX: function (value) - { - this.drag.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setDragY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setDragY: function (value) - { - this.drag.y = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setGravity - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setGravity: function (x, y) - { - this.gravity.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setGravityX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setGravityX: function (value) - { - this.gravity.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setGravityY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setGravityY: function (value) - { - this.gravity.y = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setFriction - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setFriction: function (x, y) - { - this.friction.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setFrictionX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setFrictionX: function (value) - { - this.friction.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setFrictionY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setFrictionY: function (value) - { - this.friction.y = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setAngularVelocity - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAngularVelocity: function (value) - { - this.angularVelocity = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setAngularAcceleration - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAngularAcceleration: function (value) - { - this.angularAcceleration = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setAngularDrag - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAngularDrag: function (value) - { - this.angularDrag = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setMass - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setMass: function (value) - { - this.mass = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setImmovable - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setImmovable: function (value) - { - this.immovable = value; - - return this; - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#x - * @type {number} - * @since 3.0.0 - */ - x: { - - get: function () - { - return this.position.x; - }, - - set: function (value) - { - this.position.x = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#y - * @type {number} - * @since 3.0.0 - */ - y: { - - get: function () - { - return this.position.y; - }, - - set: function (value) - { - this.position.y = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#left - * @type {number} - * @readOnly - * @since 3.0.0 - */ - left: { - - get: function () - { - return this.position.x; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#right - * @type {number} - * @readOnly - * @since 3.0.0 - */ - right: { - - get: function () - { - return this.position.x + this.width; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#top - * @type {number} - * @readOnly - * @since 3.0.0 - */ - top: { - - get: function () - { - return this.position.y; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#bottom - * @type {number} - * @readOnly - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return this.position.y + this.height; - } - - } - -}); - -module.exports = Body; - - -/***/ }), -/* 333 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class Collider - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.World} world - [description] - * @param {boolean} overlapOnly - [description] - * @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for collision. - * @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for collision. - * @param {function} collideCallback - The callback to invoke when the two objects collide. - * @param {function} processCallback - The callback to invoke when the two objects collide. Must return a boolean. - * @param {object} callbackContext - The scope in which to call the callbacks. - */ -var Collider = new Class({ - - initialize: - - function Collider (world, overlapOnly, object1, object2, collideCallback, processCallback, callbackContext) - { - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world = world; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#name - * @type {string} - * @since 3.1.0 - */ - this.name = ''; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#active - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.active = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#overlapOnly - * @type {boolean} - * @since 3.0.0 - */ - this.overlapOnly = overlapOnly; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#object1 - * @type {Phaser.Physics.Arcade.Body} - * @since 3.0.0 - */ - this.object1 = object1; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#object2 - * @type {Phaser.Physics.Arcade.Body} - * @since 3.0.0 - */ - this.object2 = object2; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#collideCallback - * @type {function} - * @since 3.0.0 - */ - this.collideCallback = collideCallback; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#processCallback - * @type {function} - * @since 3.0.0 - */ - this.processCallback = processCallback; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#callbackContext - * @type {object} - * @since 3.0.0 - */ - this.callbackContext = callbackContext; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Collider#setName - * @since 3.1.0 - * - * @param {string} name - [description] - * - * @return {Phaser.Physics.Arcade.Collider} [description] - */ - setName: function (name) - { - this.name = name; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Collider#update - * @since 3.0.0 - */ - update: function () - { - this.world.collideObjects( - this.object1, - this.object2, - this.collideCallback, - this.processCallback, - this.callbackContext, - this.overlapOnly - ); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Collider#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.world.removeCollider(this); - - this.active = false; - - this.world = null; - - this.object1 = null; - this.object2 = null; - - this.collideCallback = null; - this.processCallback = null; - this.callbackContext = null; - } - -}); - -module.exports = Collider; - - -/***/ }), -/* 334 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Physics.Arcade.GetOverlapX - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {boolean} overlapOnly - [description] - * @param {number} bias - [description] - * - * @return {number} [description] - */ -var GetOverlapX = function (body1, body2, overlapOnly, bias) -{ - var overlap = 0; - var maxOverlap = body1.deltaAbsX() + body2.deltaAbsX() + bias; - - if (body1.deltaX() === 0 && body2.deltaX() === 0) - { - // They overlap but neither of them are moving - body1.embedded = true; - body2.embedded = true; - } - else if (body1.deltaX() > body2.deltaX()) - { - // Body1 is moving right and / or Body2 is moving left - overlap = body1.right - body2.x; - - if ((overlap > maxOverlap && !overlapOnly) || body1.checkCollision.right === false || body2.checkCollision.left === false) - { - overlap = 0; - } - else - { - body1.touching.none = false; - body1.touching.right = true; - body2.touching.none = false; - body2.touching.left = true; - } - } - else if (body1.deltaX() < body2.deltaX()) - { - // Body1 is moving left and/or Body2 is moving right - overlap = body1.x - body2.width - body2.x; - - if ((-overlap > maxOverlap && !overlapOnly) || body1.checkCollision.left === false || body2.checkCollision.right === false) - { - overlap = 0; - } - else - { - body1.touching.none = false; - body1.touching.left = true; - body2.touching.none = false; - body2.touching.right = true; - } - } - - // Resets the overlapX to zero if there is no overlap, or to the actual pixel value if there is - body1.overlapX = overlap; - body2.overlapX = overlap; - - return overlap; -}; - -module.exports = GetOverlapX; - - -/***/ }), -/* 335 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Physics.Arcade.GetOverlapY - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {boolean} overlapOnly - [description] - * @param {number} bias - [description] - * - * @return {number} [description] - */ -var GetOverlapY = function (body1, body2, overlapOnly, bias) -{ - var overlap = 0; - var maxOverlap = body1.deltaAbsY() + body2.deltaAbsY() + bias; - - if (body1.deltaY() === 0 && body2.deltaY() === 0) - { - // They overlap but neither of them are moving - body1.embedded = true; - body2.embedded = true; - } - else if (body1.deltaY() > body2.deltaY()) - { - // Body1 is moving down and/or Body2 is moving up - overlap = body1.bottom - body2.y; - - if ((overlap > maxOverlap && !overlapOnly) || body1.checkCollision.down === false || body2.checkCollision.up === false) - { - overlap = 0; - } - else - { - body1.touching.none = false; - body1.touching.down = true; - body2.touching.none = false; - body2.touching.up = true; - } - } - else if (body1.deltaY() < body2.deltaY()) - { - // Body1 is moving up and/or Body2 is moving down - overlap = body1.y - body2.bottom; - - if ((-overlap > maxOverlap && !overlapOnly) || body1.checkCollision.up === false || body2.checkCollision.down === false) - { - overlap = 0; - } - else - { - body1.touching.none = false; - body1.touching.up = true; - body2.touching.none = false; - body2.touching.down = true; - } - } - - // Resets the overlapY to zero if there is no overlap, or to the actual pixel value if there is - body1.overlapY = overlap; - body2.overlapY = overlap; - - return overlap; -}; - -module.exports = GetOverlapY; - - -/***/ }), -/* 336 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class ProcessQueue - * @memberOf Phaser.Structs - * @constructor - * @since 3.0.0 - */ -var ProcessQueue = new Class({ - - initialize: - - function ProcessQueue () - { - /** - * [description] - * - * @name Phaser.Structs.ProcessQueue#_pending - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._pending = []; - - /** - * [description] - * - * @name Phaser.Structs.ProcessQueue#_active - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._active = []; - - /** - * [description] - * - * @name Phaser.Structs.ProcessQueue#_destroy - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._destroy = []; - - /** - * [description] - * - * @name Phaser.Structs.ProcessQueue#_toProcess - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - this._toProcess = 0; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#add - * @since 3.0.0 - * - * @param {any} item - [description] - * - * @return {Phaser.Structs.ProcessQueue} This Process Queue object. - */ - add: function (item) - { - this._pending.push(item); - - this._toProcess++; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#remove - * @since 3.0.0 - * - * @param {any} item - [description] - * - * @return {Phaser.Structs.ProcessQueue} This Process Queue object. - */ - remove: function (item) - { - this._destroy.push(item); - - this._toProcess++; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#update - * @since 3.0.0 - * - * @return {array} [description] - */ - update: function () - { - if (this._toProcess === 0) - { - // Quick bail - return this._active; - } - - var list = this._destroy; - var active = this._active; - var i; - var item; - - // Clear the 'destroy' list - for (i = 0; i < list.length; i++) - { - item = list[i]; - - // Remove from the 'active' array - var idx = active.indexOf(item); - - if (idx !== -1) - { - active.splice(idx, 1); - } - } - - list.length = 0; - - // Process the pending addition list - // This stops callbacks and out of sync events from populating the active array mid-way during an update - - list = this._pending; - - for (i = 0; i < list.length; i++) - { - item = list[i]; - - this._active.push(item); - } - - list.length = 0; - - this._toProcess = 0; - - // The owner of this queue can now safely do whatever it needs to with the active list - return this._active; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#getActive - * @since 3.0.0 - * - * @return {array} [description] - */ - getActive: function () - { - return this._active; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#destroy - * @since 3.0.0 - */ - destroy: function () - { - this._pending = []; - this._active = []; - this._destroy = []; - } - -}); - -module.exports = ProcessQueue; - - -/***/ }), -/* 337 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var quickselect = __webpack_require__(338); - -/** - * @classdesc - * RBush is a high-performance JavaScript library for 2D spatial indexing of points and rectangles. - * It's based on an optimized R-tree data structure with bulk insertion support. - * - * Spatial index is a special data structure for points and rectangles that allows you to perform queries like - * "all items within this bounding box" very efficiently (e.g. hundreds of times faster than looping over all items). - * - * @class RTree - * @memberOf Phaser.Structs - * @constructor - * @since 3.0.0 - */ - -function rbush (maxEntries, format) -{ - if (!(this instanceof rbush)) return new rbush(maxEntries, format); - - // max entries in a node is 9 by default; min node fill is 40% for best performance - this._maxEntries = Math.max(4, maxEntries || 9); - this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)); - - if (format) - { - this._initFormat(format); - } - - this.clear(); -} - -rbush.prototype = { - - all: function () - { - return this._all(this.data, []); - }, - - search: function (bbox) - { - var node = this.data, - result = [], - toBBox = this.toBBox; - - if (!intersects(bbox, node)) return result; - - var nodesToSearch = [], - i, len, child, childBBox; - - while (node) { - for (i = 0, len = node.children.length; i < len; i++) { - - child = node.children[i]; - childBBox = node.leaf ? toBBox(child) : child; - - if (intersects(bbox, childBBox)) { - if (node.leaf) result.push(child); - else if (contains(bbox, childBBox)) this._all(child, result); - else nodesToSearch.push(child); - } - } - node = nodesToSearch.pop(); - } - - return result; - }, - - collides: function (bbox) - { - var node = this.data, - toBBox = this.toBBox; - - if (!intersects(bbox, node)) return false; - - var nodesToSearch = [], - i, len, child, childBBox; - - while (node) { - for (i = 0, len = node.children.length; i < len; i++) { - - child = node.children[i]; - childBBox = node.leaf ? toBBox(child) : child; - - if (intersects(bbox, childBBox)) { - if (node.leaf || contains(bbox, childBBox)) return true; - nodesToSearch.push(child); - } - } - node = nodesToSearch.pop(); - } - - return false; - }, - - load: function (data) - { - if (!(data && data.length)) return this; - - if (data.length < this._minEntries) { - for (var i = 0, len = data.length; i < len; i++) { - this.insert(data[i]); - } - return this; - } - - // recursively build the tree with the given data from scratch using OMT algorithm - var node = this._build(data.slice(), 0, data.length - 1, 0); - - if (!this.data.children.length) { - // save as is if tree is empty - this.data = node; - - } else if (this.data.height === node.height) { - // split root if trees have the same height - this._splitRoot(this.data, node); - - } else { - if (this.data.height < node.height) { - // swap trees if inserted one is bigger - var tmpNode = this.data; - this.data = node; - node = tmpNode; - } - - // insert the small tree into the large tree at appropriate level - this._insert(node, this.data.height - node.height - 1, true); - } - - return this; - }, - - insert: function (item) - { - if (item) this._insert(item, this.data.height - 1); - return this; - }, - - clear: function () - { - this.data = createNode([]); - return this; - }, - - remove: function (item, equalsFn) - { - if (!item) return this; - - var node = this.data, - bbox = this.toBBox(item), - path = [], - indexes = [], - i, parent, index, goingUp; - - // depth-first iterative tree traversal - while (node || path.length) { - - if (!node) { // go up - node = path.pop(); - parent = path[path.length - 1]; - i = indexes.pop(); - goingUp = true; - } - - if (node.leaf) { // check current node - index = findItem(item, node.children, equalsFn); - - if (index !== -1) { - // item found, remove the item and condense tree upwards - node.children.splice(index, 1); - path.push(node); - this._condense(path); - return this; - } - } - - if (!goingUp && !node.leaf && contains(node, bbox)) { // go down - path.push(node); - indexes.push(i); - i = 0; - parent = node; - node = node.children[0]; - - } else if (parent) { // go right - i++; - node = parent.children[i]; - goingUp = false; - - } else node = null; // nothing found - } - - return this; - }, - - toBBox: function (item) { return item; }, - - compareMinX: compareNodeMinX, - compareMinY: compareNodeMinY, - - toJSON: function () { return this.data; }, - - fromJSON: function (data) - { - this.data = data; - return this; - }, - - _all: function (node, result) - { - var nodesToSearch = []; - while (node) { - if (node.leaf) result.push.apply(result, node.children); - else nodesToSearch.push.apply(nodesToSearch, node.children); - - node = nodesToSearch.pop(); - } - return result; - }, - - _build: function (items, left, right, height) - { - var N = right - left + 1, - M = this._maxEntries, - node; - - if (N <= M) { - // reached leaf level; return leaf - node = createNode(items.slice(left, right + 1)); - calcBBox(node, this.toBBox); - return node; - } - - if (!height) { - // target height of the bulk-loaded tree - height = Math.ceil(Math.log(N) / Math.log(M)); - - // target number of root entries to maximize storage utilization - M = Math.ceil(N / Math.pow(M, height - 1)); - } - - node = createNode([]); - node.leaf = false; - node.height = height; - - // split the items into M mostly square tiles - - var N2 = Math.ceil(N / M), - N1 = N2 * Math.ceil(Math.sqrt(M)), - i, j, right2, right3; - - multiSelect(items, left, right, N1, this.compareMinX); - - for (i = left; i <= right; i += N1) { - - right2 = Math.min(i + N1 - 1, right); - - multiSelect(items, i, right2, N2, this.compareMinY); - - for (j = i; j <= right2; j += N2) { - - right3 = Math.min(j + N2 - 1, right2); - - // pack each entry recursively - node.children.push(this._build(items, j, right3, height - 1)); - } - } - - calcBBox(node, this.toBBox); - - return node; - }, - - _chooseSubtree: function (bbox, node, level, path) - { - var i, len, child, targetNode, area, enlargement, minArea, minEnlargement; - - while (true) { - path.push(node); - - if (node.leaf || path.length - 1 === level) break; - - minArea = minEnlargement = Infinity; - - for (i = 0, len = node.children.length; i < len; i++) { - child = node.children[i]; - area = bboxArea(child); - enlargement = enlargedArea(bbox, child) - area; - - // choose entry with the least area enlargement - if (enlargement < minEnlargement) { - minEnlargement = enlargement; - minArea = area < minArea ? area : minArea; - targetNode = child; - - } else if (enlargement === minEnlargement) { - // otherwise choose one with the smallest area - if (area < minArea) { - minArea = area; - targetNode = child; - } - } - } - - node = targetNode || node.children[0]; - } - - return node; - }, - - _insert: function (item, level, isNode) - { - var toBBox = this.toBBox, - bbox = isNode ? item : toBBox(item), - insertPath = []; - - // find the best node for accommodating the item, saving all nodes along the path too - var node = this._chooseSubtree(bbox, this.data, level, insertPath); - - // put the item into the node - node.children.push(item); - extend(node, bbox); - - // split on node overflow; propagate upwards if necessary - while (level >= 0) { - if (insertPath[level].children.length > this._maxEntries) { - this._split(insertPath, level); - level--; - } else break; - } - - // adjust bboxes along the insertion path - this._adjustParentBBoxes(bbox, insertPath, level); - }, - - // split overflowed node into two - _split: function (insertPath, level) - { - var node = insertPath[level], - M = node.children.length, - m = this._minEntries; - - this._chooseSplitAxis(node, m, M); - - var splitIndex = this._chooseSplitIndex(node, m, M); - - var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex)); - newNode.height = node.height; - newNode.leaf = node.leaf; - - calcBBox(node, this.toBBox); - calcBBox(newNode, this.toBBox); - - if (level) insertPath[level - 1].children.push(newNode); - else this._splitRoot(node, newNode); - }, - - _splitRoot: function (node, newNode) - { - // split root node - this.data = createNode([node, newNode]); - this.data.height = node.height + 1; - this.data.leaf = false; - calcBBox(this.data, this.toBBox); - }, - - _chooseSplitIndex: function (node, m, M) - { - var i, bbox1, bbox2, overlap, area, minOverlap, minArea, index; - - minOverlap = minArea = Infinity; - - for (i = m; i <= M - m; i++) { - bbox1 = distBBox(node, 0, i, this.toBBox); - bbox2 = distBBox(node, i, M, this.toBBox); - - overlap = intersectionArea(bbox1, bbox2); - area = bboxArea(bbox1) + bboxArea(bbox2); - - // choose distribution with minimum overlap - if (overlap < minOverlap) { - minOverlap = overlap; - index = i; - - minArea = area < minArea ? area : minArea; - - } else if (overlap === minOverlap) { - // otherwise choose distribution with minimum area - if (area < minArea) { - minArea = area; - index = i; - } - } - } - - return index; - }, - - // sorts node children by the best axis for split - _chooseSplitAxis: function (node, m, M) - { - var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX, - compareMinY = node.leaf ? this.compareMinY : compareNodeMinY, - xMargin = this._allDistMargin(node, m, M, compareMinX), - yMargin = this._allDistMargin(node, m, M, compareMinY); - - // if total distributions margin value is minimal for x, sort by minX, - // otherwise it's already sorted by minY - if (xMargin < yMargin) node.children.sort(compareMinX); - }, - - // total margin of all possible split distributions where each node is at least m full - _allDistMargin: function (node, m, M, compare) - { - node.children.sort(compare); - - var toBBox = this.toBBox, - leftBBox = distBBox(node, 0, m, toBBox), - rightBBox = distBBox(node, M - m, M, toBBox), - margin = bboxMargin(leftBBox) + bboxMargin(rightBBox), - i, child; - - for (i = m; i < M - m; i++) { - child = node.children[i]; - extend(leftBBox, node.leaf ? toBBox(child) : child); - margin += bboxMargin(leftBBox); - } - - for (i = M - m - 1; i >= m; i--) { - child = node.children[i]; - extend(rightBBox, node.leaf ? toBBox(child) : child); - margin += bboxMargin(rightBBox); - } - - return margin; - }, - - _adjustParentBBoxes: function (bbox, path, level) - { - // adjust bboxes along the given tree path - for (var i = level; i >= 0; i--) { - extend(path[i], bbox); - } - }, - - _condense: function (path) - { - // go through the path, removing empty nodes and updating bboxes - for (var i = path.length - 1, siblings; i >= 0; i--) { - if (path[i].children.length === 0) { - if (i > 0) { - siblings = path[i - 1].children; - siblings.splice(siblings.indexOf(path[i]), 1); - - } else this.clear(); - - } else calcBBox(path[i], this.toBBox); - } - }, - - _initFormat: function (format) - { - // data format (minX, minY, maxX, maxY accessors) - - // uses eval-type function compilation instead of just accepting a toBBox function - // because the algorithms are very sensitive to sorting functions performance, - // so they should be dead simple and without inner calls - - var compareArr = ['return a', ' - b', ';']; - - this.compareMinX = new Function('a', 'b', compareArr.join(format[0])); - this.compareMinY = new Function('a', 'b', compareArr.join(format[1])); - - this.toBBox = new Function('a', - 'return {minX: a' + format[0] + - ', minY: a' + format[1] + - ', maxX: a' + format[2] + - ', maxY: a' + format[3] + '};'); - } -}; - -function findItem (item, items, equalsFn) -{ - if (!equalsFn) return items.indexOf(item); - - for (var i = 0; i < items.length; i++) { - if (equalsFn(item, items[i])) return i; - } - return -1; -} - -// calculate node's bbox from bboxes of its children -function calcBBox (node, toBBox) -{ - distBBox(node, 0, node.children.length, toBBox, node); -} - -// min bounding rectangle of node children from k to p-1 -function distBBox (node, k, p, toBBox, destNode) -{ - if (!destNode) destNode = createNode(null); - destNode.minX = Infinity; - destNode.minY = Infinity; - destNode.maxX = -Infinity; - destNode.maxY = -Infinity; - - for (var i = k, child; i < p; i++) { - child = node.children[i]; - extend(destNode, node.leaf ? toBBox(child) : child); - } - - return destNode; -} - -function extend (a, b) -{ - a.minX = Math.min(a.minX, b.minX); - a.minY = Math.min(a.minY, b.minY); - a.maxX = Math.max(a.maxX, b.maxX); - a.maxY = Math.max(a.maxY, b.maxY); - return a; -} - -function compareNodeMinX (a, b) { return a.minX - b.minX; } -function compareNodeMinY (a, b) { return a.minY - b.minY; } - -function bboxArea (a) { return (a.maxX - a.minX) * (a.maxY - a.minY); } -function bboxMargin (a) { return (a.maxX - a.minX) + (a.maxY - a.minY); } - -function enlargedArea (a, b) -{ - return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) * - (Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY)); -} - -function intersectionArea (a, b) -{ - var minX = Math.max(a.minX, b.minX), - minY = Math.max(a.minY, b.minY), - maxX = Math.min(a.maxX, b.maxX), - maxY = Math.min(a.maxY, b.maxY); - - return Math.max(0, maxX - minX) * - Math.max(0, maxY - minY); -} - -function contains (a, b) -{ - return a.minX <= b.minX && - a.minY <= b.minY && - b.maxX <= a.maxX && - b.maxY <= a.maxY; -} - -function intersects (a, b) -{ - return b.minX <= a.maxX && - b.minY <= a.maxY && - b.maxX >= a.minX && - b.maxY >= a.minY; -} - -function createNode (children) -{ - return { - children: children, - height: 1, - leaf: true, - minX: Infinity, - minY: Infinity, - maxX: -Infinity, - maxY: -Infinity - }; -} - -// sort an array so that items come in groups of n unsorted items, with groups sorted between each other; -// combines selection algorithm with binary divide & conquer approach - -function multiSelect (arr, left, right, n, compare) -{ - var stack = [left, right], - mid; - - while (stack.length) - { - right = stack.pop(); - left = stack.pop(); - - if (right - left <= n) continue; - - mid = left + Math.ceil((right - left) / n / 2) * n; - quickselect(arr, mid, left, right, compare); - - stack.push(left, mid, mid, right); - } -} - -module.exports = rbush; - - -/***/ }), -/* 338 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// This is from the quickselect npm package: https://www.npmjs.com/package/quickselect -// Coded by https://www.npmjs.com/~mourner (Vladimir Agafonkin) - -// https://en.wikipedia.org/wiki/Floyd%E2%80%93Rivest_algorithm - -// Floyd-Rivest selection algorithm: -// Rearrange items so that all items in the [left, k] range are smaller than all items in (k, right]; -// The k-th element will have the (k - left + 1)th smallest value in [left, right] - -/** - * [description] - * - * @function Phaser.Utils.Array.QuickSelect - * @since 3.0.0 - * - * @param {[type]} arr - [description] - * @param {[type]} k - [description] - * @param {[type]} left - [description] - * @param {[type]} right - [description] - * @param {[type]} compare - [description] - */ -var QuickSelect = function (arr, k, left, right, compare) -{ - left = left || 0; - right = right || (arr.length - 1); - compare = compare || defaultCompare; - - while (right > left) - { - if (right - left > 600) - { - var n = right - left + 1; - var m = k - left + 1; - var z = Math.log(n); - var s = 0.5 * Math.exp(2 * z / 3); - var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1); - var newLeft = Math.max(left, Math.floor(k - m * s / n + sd)); - var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd)); - - QuickSelect(arr, k, newLeft, newRight, compare); - } - - var t = arr[k]; - var i = left; - var j = right; - - swap(arr, left, k); - - if (compare(arr[right], t) > 0) - { - swap(arr, left, right); - } - - while (i < j) - { - swap(arr, i, j); - - i++; - j--; - - while (compare(arr[i], t) < 0) - { - i++; - } - - while (compare(arr[j], t) > 0) - { - j--; - } - } - - if (compare(arr[left], t) === 0) - { - swap(arr, left, j); - } - else - { - j++; - swap(arr, j, right); - } - - if (j <= k) - { - left = j + 1; - } - - if (k <= j) - { - right = j - 1; - } - } -}; - -function swap (arr, i, j) -{ - var tmp = arr[i]; - arr[i] = arr[j]; - arr[j] = tmp; -} - -function defaultCompare (a, b) -{ - return a < b ? -1 : a > b ? 1 : 0; -} - -module.exports = QuickSelect; - - -/***/ }), -/* 339 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Physics.Arcade.Tilemap.TileIntersectsBody - * @since 3.0.0 - * - * @param {[type]} tileWorldRect - [description] - * @param {[type]} body - [description] - * - * @return {boolean} [description] - */ -var TileIntersectsBody = function (tileWorldRect, body) -{ - // Currently, all bodies are treated as rectangles when colliding with a Tile. Eventually, this - // should support circle bodies when those are less buggy in v3. - - return !( - body.right <= tileWorldRect.left || - body.bottom <= tileWorldRect.top || - body.position.x >= tileWorldRect.right || - body.position.y >= tileWorldRect.bottom - ); -}; - -module.exports = TileIntersectsBody; - - -/***/ }), -/* 340 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CircleContains = __webpack_require__(32); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(59); -var RectangleContains = __webpack_require__(33); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * [description] - * - * @class StaticBody - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.World} world - [description] - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - */ -var StaticBody = new Class({ - - initialize: - - function StaticBody (world, gameObject) - { - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world = world; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#gameObject - * @type {Phaser.GameObjects.GameObject} - * @since 3.0.0 - */ - this.gameObject = gameObject; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#debugShowBody - * @type {boolean} - * @since 3.0.0 - */ - this.debugShowBody = world.defaults.debugShowStaticBody; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#debugBodyColor - * @type {integer} - * @since 3.0.0 - */ - this.debugBodyColor = world.defaults.staticBodyDebugColor; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#enable - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.enable = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#isCircle - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isCircle = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#radius - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.radius = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#offset - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.offset = new Vector2(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#position - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.position = new Vector2(gameObject.x - gameObject.displayOriginX, gameObject.y - gameObject.displayOriginY); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#width - * @type {number} - * @since 3.0.0 - */ - this.width = gameObject.displayWidth; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#height - * @type {number} - * @since 3.0.0 - */ - this.height = gameObject.displayHeight; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#halfWidth - * @type {number} - * @since 3.0.0 - */ - this.halfWidth = Math.abs(this.width / 2); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#halfHeight - * @type {number} - * @since 3.0.0 - */ - this.halfHeight = Math.abs(this.height / 2); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#center - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#velocity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.velocity = Vector2.ZERO; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#allowGravity - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.allowGravity = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#gravity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.gravity = Vector2.ZERO; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#bounce - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.bounce = Vector2.ZERO; - - // If true this Body will dispatch events - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#onWorldBounds - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.onWorldBounds = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#onCollide - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.onCollide = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#onOverlap - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.onOverlap = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#mass - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.mass = 1; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#immovable - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.immovable = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#customSeparateX - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.customSeparateX = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#customSeparateY - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.customSeparateY = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#overlapX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapX = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#overlapY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapY = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#overlapR - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapR = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#embedded - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.embedded = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#collideWorldBounds - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.collideWorldBounds = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#checkCollision - * @type {object} - * @since 3.0.0 - */ - this.checkCollision = { none: false, up: true, down: true, left: true, right: true }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#touching - * @type {object} - * @since 3.0.0 - */ - this.touching = { none: true, up: false, down: false, left: false, right: false }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#wasTouching - * @type {object} - * @since 3.0.0 - */ - this.wasTouching = { none: true, up: false, down: false, left: false, right: false }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#blocked - * @type {object} - * @since 3.0.0 - */ - this.blocked = { none: true, up: false, down: false, left: false, right: false }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#physicsType - * @type {integer} - * @since 3.0.0 - */ - this.physicsType = CONST.STATIC_BODY; - }, - - /** - * Changes the Game Object this Body is bound to. - * First it removes its reference from the old Game Object, then sets the new one. - * You can optionally update the position and dimensions of this Body to reflect that of the new Game Object. - * - * @method Phaser.Physics.Arcade.StaticBody#setGameObject - * @since 3.1.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The new Game Object that will own this Body. - * @param {boolean} [update=true] - Reposition and resize this Body to match the new Game Object? - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - setGameObject: function (gameObject, update) - { - if (gameObject && gameObject !== this.gameObject) - { - // Remove this body from the old game object - this.gameObject.body = null; - - gameObject.body = this; - - // Update our reference - this.gameObject = gameObject; - } - - if (update) - { - this.updateFromGameObject(); - } - - return this; - }, - - /** - * Updates this Static Body so that its position and dimensions are updated - * based on the current Game Object it is bound to. - * - * @method Phaser.Physics.Arcade.StaticBody#updateFromGameObject - * @since 3.1.0 - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - updateFromGameObject: function () - { - this.world.staticTree.remove(this); - - var gameObject = this.gameObject; - - gameObject.getTopLeft(this.position); - - this.width = gameObject.displayWidth; - this.height = gameObject.displayHeight; - - this.halfWidth = Math.abs(this.width / 2); - this.halfHeight = Math.abs(this.height / 2); - - this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); - - this.world.staticTree.insert(this); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#setSize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} [offsetX] - [description] - * @param {number} [offsetY] - [description] - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - setSize: function (width, height, offsetX, offsetY) - { - if (offsetX === undefined) { offsetX = this.offset.x; } - if (offsetY === undefined) { offsetY = this.offset.y; } - - this.world.staticTree.remove(this); - - this.width = width; - this.height = height; - - this.halfWidth = Math.floor(width / 2); - this.halfHeight = Math.floor(height / 2); - - this.offset.set(offsetX, offsetY); - - this.updateCenter(); - - this.isCircle = false; - this.radius = 0; - - this.world.staticTree.insert(this); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#setCircle - * @since 3.0.0 - * - * @param {number} radius - [description] - * @param {number} [offsetX] - [description] - * @param {number} [offsetY] - [description] - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - setCircle: function (radius, offsetX, offsetY) - { - if (offsetX === undefined) { offsetX = this.offset.x; } - if (offsetY === undefined) { offsetY = this.offset.y; } - - if (radius > 0) - { - this.world.staticTree.remove(this); - - this.isCircle = true; - - this.radius = radius; - - this.width = radius * 2; - this.height = radius * 2; - - this.halfWidth = Math.floor(this.width / 2); - this.halfHeight = Math.floor(this.height / 2); - - this.offset.set(offsetX, offsetY); - - this.updateCenter(); - - this.world.staticTree.insert(this); - } - else - { - this.isCircle = false; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#updateCenter - * @since 3.0.0 - */ - updateCenter: function () - { - this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#reset - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - */ - reset: function (x, y) - { - var gameObject = this.gameObject; - - if (x === undefined) { x = gameObject.x; } - if (y === undefined) { y = gameObject.y; } - - this.world.staticTree.remove(this); - - gameObject.getTopLeft(this.position); - - this.updateCenter(); - - this.world.staticTree.insert(this); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#stop - * @since 3.0.0 - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - stop: function () - { - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#getBounds - * @since 3.0.0 - * - * @param {object} obj - [description] - * - * @return {object} [description] - */ - getBounds: function (obj) - { - obj.x = this.x; - obj.y = this.y; - obj.right = this.right; - obj.bottom = this.bottom; - - return obj; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#hitTest - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ - hitTest: function (x, y) - { - return (this.isCircle) ? CircleContains(this, x, y) : RectangleContains(this, x, y); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#deltaAbsX - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaAbsX: function () - { - return 0; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#deltaAbsY - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaAbsY: function () - { - return 0; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#deltaX - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaX: function () - { - return 0; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#deltaY - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaY: function () - { - return 0; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#deltaZ - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaZ: function () - { - return 0; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.enable = false; - - this.world.pendingDestroy.set(this); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#drawDebug - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphic - [description] - */ - drawDebug: function (graphic) - { - var pos = this.position; - - if (this.debugShowBody) - { - graphic.lineStyle(1, this.debugBodyColor, 1); - graphic.strokeRect(pos.x, pos.y, this.width, this.height); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#willDrawDebug - * @since 3.0.0 - * - * @return {boolean} [description] - */ - willDrawDebug: function () - { - return this.debugShowBody; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#setMass - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - setMass: function (value) - { - if (value <= 0) - { - // Causes havoc otherwise - value = 0.1; - } - - this.mass = value; - - return this; - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#x - * @type {number} - * @since 3.0.0 - */ - x: { - - get: function () - { - return this.position.x; - }, - - set: function (value) - { - this.world.staticTree.remove(this); - - this.position.x = value; - - this.world.staticTree.insert(this); - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#y - * @type {number} - * @since 3.0.0 - */ - y: { - - get: function () - { - return this.position.y; - }, - - set: function (value) - { - this.world.staticTree.remove(this); - - this.position.y = value; - - this.world.staticTree.insert(this); - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#left - * @type {number} - * @readOnly - * @since 3.0.0 - */ - left: { - - get: function () - { - return this.position.x; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#right - * @type {number} - * @readOnly - * @since 3.0.0 - */ - right: { - - get: function () - { - return this.position.x + this.width; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#top - * @type {number} - * @readOnly - * @since 3.0.0 - */ - top: { - - get: function () - { - return this.position.y; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#bottom - * @type {number} - * @readOnly - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return this.position.y + this.height; - } - - } - -}); - -module.exports = StaticBody; - - -/***/ }), -/* 341 */, -/* 342 */, -/* 343 */, -/* 344 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); - -/** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does - * not change collision information. - * - * @function Phaser.Tilemaps.Components.ReplaceByIndex - * @since 3.0.0 - * - * @param {integer} findIndex - [description] - * @param {integer} newIndex - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var ReplaceByIndex = function (findIndex, newIndex, tileX, tileY, width, height, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - for (var i = 0; i < tiles.length; i++) - { - if (tiles[i] && tiles[i].index === findIndex) - { - tiles[i].index = newIndex; - } - } -}; - -module.exports = ReplaceByIndex; - - -/***/ }), -/* 345 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var IsInLayerBounds = __webpack_require__(74); - -/** - * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @function Phaser.Tilemaps.Components.HasTileAt - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {boolean} - */ -var HasTileAt = function (tileX, tileY, layer) -{ - if (IsInLayerBounds(tileX, tileY, layer)) - { - var tile = layer.data[tileY][tileX]; - return (tile !== null && tile.index > -1); - } - else - { - return false; - } - -}; - -module.exports = HasTileAt; - - -/***/ }), -/* 346 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Tile = __webpack_require__(44); -var IsInLayerBounds = __webpack_require__(74); -var CalculateFacesAt = __webpack_require__(153); - -/** - * Removes the tile at the given tile coordinates in the specified layer and updates the layer's - * collision information. - * - * @function Phaser.Tilemaps.Components.RemoveTileAt - * @since 3.0.0 - * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The Tile object that was removed. - */ -var RemoveTileAt = function (tileX, tileY, replaceWithNull, recalculateFaces, layer) -{ - if (replaceWithNull === undefined) { replaceWithNull = false; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - if (!IsInLayerBounds(tileX, tileY, layer)) { return null; } - - var tile = layer.data[tileY][tileX]; - if (tile === null) - { - return null; - } - else - { - layer.data[tileY][tileX] = replaceWithNull - ? null - : new Tile(layer, -1, tileX, tileY, tile.width, tile.height); - } - - // Recalculate faces only if the removed tile was a colliding tile - if (recalculateFaces && tile && tile.collides) - { - CalculateFacesAt(tileX, tileY, layer); - } - - return tile; -}; - -module.exports = RemoveTileAt; - - -/***/ }), -/* 347 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Formats = __webpack_require__(22); -var Parse2DArray = __webpack_require__(156); -var ParseCSV = __webpack_require__(348); -var ParseJSONTiled = __webpack_require__(349); -var ParseWeltmeister = __webpack_require__(354); - -/** - * Parses raw data of a given Tilemap format into a new MapData object. If no recognized data format - * is found, returns `null`. When loading from CSV or a 2D array, you should specify the tileWidth & - * tileHeight. When parsing from a map from Tiled, the tileWidth & tileHeight will be pulled from - * the map data. - * - * @function Phaser.Tilemaps.Parsers.Parse - * @since 3.0.0 - * - * @param {string} name - The name of the tilemap, used to set the name on the MapData. - * @param {integer} mapFormat - See ../Formats.js. - * @param {integer[][]|string|object} data - 2D array, CSV string or Tiled JSON object. - * @param {integer} tileWidth - The width of a tile in pixels. Required for 2D array and CSV, but - * ignored for Tiled JSON. - * @param {integer} tileHeight - The height of a tile in pixels. Required for 2D array and CSV, but - * ignored for Tiled JSON. - * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {[type]} [description] - */ -var Parse = function (name, mapFormat, data, tileWidth, tileHeight, insertNull) -{ - var newMap; - - switch (mapFormat) - { - case (Formats.ARRAY_2D): - newMap = Parse2DArray(name, data, tileWidth, tileHeight, insertNull); - break; - case (Formats.CSV): - newMap = ParseCSV(name, data, tileWidth, tileHeight, insertNull); - break; - case (Formats.TILED_JSON): - newMap = ParseJSONTiled(name, data, insertNull); - break; - case (Formats.WELTMEISTER): - newMap = ParseWeltmeister(name, data, insertNull); - break; - default: - console.warn('Unrecognized tilemap data format: ' + mapFormat); - newMap = null; - } - - return newMap; -}; - -module.exports = Parse; - - -/***/ }), -/* 348 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Formats = __webpack_require__(22); -var Parse2DArray = __webpack_require__(156); - -/** - * Parses a CSV string of tile indexes into a new MapData object with a single layer. - * - * @function Phaser.Tilemaps.Parsers.ParseCSV - * @since 3.0.0 - * - * @param {string} name - The name of the tilemap, used to set the name on the MapData. - * @param {string} data - CSV string of tile indexes. - * @param {integer} tileWidth - The width of a tile in pixels. - * @param {integer} tileHeight - The height of a tile in pixels. - * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {[type]} [description] - */ -var ParseCSV = function (name, data, tileWidth, tileHeight, insertNull) -{ - var array2D = data - .trim() - .split('\n') - .map(function (row) { return row.split(','); }); - - var map = Parse2DArray(name, array2D, tileWidth, tileHeight, insertNull); - map.format = Formats.CSV; - - return map; -}; - -module.exports = ParseCSV; - - -/***/ }), -/* 349 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Formats = __webpack_require__(22); -var MapData = __webpack_require__(76); -var ParseTileLayers = __webpack_require__(904); -var ParseImageLayers = __webpack_require__(906); -var ParseTilesets = __webpack_require__(907); -var ParseObjectLayers = __webpack_require__(909); -var BuildTilesetIndex = __webpack_require__(910); -var AssignTileProperties = __webpack_require__(911); - -/** - * Parses a Tiled JSON object into a new MapData object. - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseJSONTiled - * @since 3.0.0 - * - * @param {string} name - The name of the tilemap, used to set the name on the MapData. - * @param {object} json - The Tiled JSON object. - * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {Phaser.Tilemaps.MapData|null} [description] - */ -var ParseJSONTiled = function (name, json, insertNull) -{ - if (json.orientation !== 'orthogonal') - { - console.warn('Only orthogonal map types are supported in this version of Phaser'); - return null; - } - - // Map data will consist of: layers, objects, images, tilesets, sizes - var mapData = new MapData({ - width: json.width, - height: json.height, - name: name, - tileWidth: json.tilewidth, - tileHeight: json.tileheight, - orientation: json.orientation, - format: Formats.TILED_JSON, - version: json.version, - properties: json.properties - }); - - mapData.layers = ParseTileLayers(json, insertNull); - mapData.images = ParseImageLayers(json); - - var sets = ParseTilesets(json); - mapData.tilesets = sets.tilesets; - mapData.imageCollections = sets.imageCollections; - - mapData.objects = ParseObjectLayers(json); - - mapData.tiles = BuildTilesetIndex(mapData); - - AssignTileProperties(mapData); - - return mapData; -}; - -module.exports = ParseJSONTiled; - - -/***/ }), -/* 350 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var FLIPPED_HORIZONTAL = 0x80000000; -var FLIPPED_VERTICAL = 0x40000000; -var FLIPPED_ANTI_DIAGONAL = 0x20000000; // Top-right is swapped with bottom-left corners - -/** - * See Tiled documentation on tile flipping: - * http://docs.mapeditor.org/en/latest/reference/tmx-map-format/ - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseGID - * @since 3.0.0 - * - * @param {number} gid - [description] - * - * @return {object} [description] - */ -var ParseGID = function (gid) -{ - var flippedHorizontal = Boolean(gid & FLIPPED_HORIZONTAL); - var flippedVertical = Boolean(gid & FLIPPED_VERTICAL); - var flippedAntiDiagonal = Boolean(gid & FLIPPED_ANTI_DIAGONAL); - gid = gid & ~(FLIPPED_HORIZONTAL | FLIPPED_VERTICAL | FLIPPED_ANTI_DIAGONAL); - - // Parse the flip flags into something Phaser can use - var rotation = 0; - var flipped = false; - - if (flippedHorizontal && flippedVertical && flippedAntiDiagonal) - { - rotation = Math.PI / 2; - flipped = true; - } - else if (flippedHorizontal && flippedVertical && !flippedAntiDiagonal) - { - rotation = Math.PI; - flipped = false; - } - else if (flippedHorizontal && !flippedVertical && flippedAntiDiagonal) - { - rotation = Math.PI / 2; - flipped = false; - } - else if (flippedHorizontal && !flippedVertical && !flippedAntiDiagonal) - { - rotation = 0; - flipped = true; - } - else if (!flippedHorizontal && flippedVertical && flippedAntiDiagonal) - { - rotation = 3 * Math.PI / 2; - flipped = false; - } - else if (!flippedHorizontal && flippedVertical && !flippedAntiDiagonal) - { - rotation = Math.PI; - flipped = true; - } - else if (!flippedHorizontal && !flippedVertical && flippedAntiDiagonal) - { - rotation = 3 * Math.PI / 2; - flipped = true; - } - else if (!flippedHorizontal && !flippedVertical && !flippedAntiDiagonal) - { - rotation = 0; - flipped = false; - } - - return { - gid: gid, - flippedHorizontal: flippedHorizontal, - flippedVertical: flippedVertical, - flippedAntiDiagonal: flippedAntiDiagonal, - rotation: rotation, - flipped: flipped - }; -}; - -module.exports = ParseGID; - - -/***/ }), -/* 351 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * An Image Collection is a special Tile Set containing multiple images, with no slicing into each image. - * - * Image Collections are normally created automatically when Tiled data is loaded. - * - * @class ImageCollection - * @memberOf Phaser.Tilemaps - * @constructor - * @since 3.0.0 - * - * @param {string} name - The name of the image collection in the map data. - * @param {integer} firstgid - The first image index this image collection contains. - * @param {integer} [width=32] - Width of widest image (in pixels). - * @param {integer} [height=32] - Height of tallest image (in pixels). - * @param {integer} [margin=0] - The margin around all images in the collection (in pixels). - * @param {integer} [spacing=0] - The spacing between each image in the collection (in pixels). - * @param {object} [properties={}] - Custom Image Collection properties. - */ -var ImageCollection = new Class({ - - initialize: - - function ImageCollection (name, firstgid, width, height, margin, spacing, properties) - { - if (width === undefined || width <= 0) { width = 32; } - if (height === undefined || height <= 0) { height = 32; } - if (margin === undefined) { margin = 0; } - if (spacing === undefined) { spacing = 0; } - - /** - * The name of the Image Collection. - * - * @name Phaser.Tilemaps.ImageCollection#name - * @type {string} - * @since 3.0.0 - */ - this.name = name; - - /** - * The Tiled firstgid value. - * This is the starting index of the first image index this Image Collection contains. - * - * @name Phaser.Tilemaps.ImageCollection#firstgid - * @type {integer} - * @since 3.0.0 - */ - this.firstgid = firstgid | 0; - - /** - * The width of the widest image (in pixels). - * - * @name Phaser.Tilemaps.ImageCollection#imageWidth - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.imageWidth = width | 0; - - /** - * The height of the tallest image (in pixels). - * - * @name Phaser.Tilemaps.ImageCollection#imageHeight - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.imageHeight = height | 0; - - /** - * The margin around the images in the collection (in pixels). - * Use `setSpacing` to change. - * - * @name Phaser.Tilemaps.ImageCollection#imageMarge - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.imageMargin = margin | 0; - - /** - * The spacing between each image in the collection (in pixels). - * Use `setSpacing` to change. - * - * @name Phaser.Tilemaps.ImageCollection#imageSpacing - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.imageSpacing = spacing | 0; - - /** - * Image Collection-specific properties that are typically defined in the Tiled editor. - * - * @name Phaser.Tilemaps.ImageCollection#properties - * @type {object} - * @since 3.0.0 - */ - this.properties = properties || {}; - - /** - * The cached images that are a part of this collection. - * - * @name Phaser.Tilemaps.ImageCollection#images - * @type {array} - * @readOnly - * @since 3.0.0 - */ - this.images = []; - - /** - * The total number of images in the image collection. - * - * @name Phaser.Tilemaps.ImageCollection#total - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.total = 0; - }, - - /** - * Returns true if and only if this image collection contains the given image index. - * - * @method Phaser.Tilemaps.ImageCollection#containsImageIndex - * @since 3.0.0 - * - * @param {integer} imageIndex - The image index to search for. - * - * @return {boolean} True if this Image Collection contains the given index. - */ - containsImageIndex: function (imageIndex) - { - return (imageIndex >= this.firstgid && imageIndex < (this.firstgid + this.total)); - }, - - /** - * Add an image to this Image Collection. - * - * @method Phaser.Tilemaps.ImageCollection#addImage - * @since 3.0.0 - * - * @param {integer} gid - The gid of the image in the Image Collection. - * @param {string} image - The the key of the image in the Image Collection and in the cache. - * - * @return {Phaser.Tilemaps.ImageCollection} This ImageCollection object. - */ - addImage: function (gid, image) - { - this.images.push({ gid: gid, image: image }); - this.total++; - - return this; - } - -}); - -module.exports = ImageCollection; - - /***/ }), /* 352 */ /***/ (function(module, exports, __webpack_require__) { @@ -64844,81 +71865,51 @@ module.exports = ImageCollection; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Pick = __webpack_require__(908); -var ParseGID = __webpack_require__(350); +var GetPoint = __webpack_require__(166); +var Perimeter = __webpack_require__(105); -var copyPoints = function (p) { return { x: p.x, y: p.y }; }; - -var commonObjectProps = [ 'id', 'name', 'type', 'rotation', 'properties', 'visible', 'x', 'y', 'width', 'height' ]; +// Return an array of points from the perimeter of the rectangle +// each spaced out based on the quantity or step required /** * [description] * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseObject + * @function Phaser.Geom.Rectangle.GetPoints * @since 3.0.0 * - * @param {object} tiledObject - [description] - * @param {number} [offsetX=0] - [description] - * @param {number} [offsetY=0] - [description] + * @param {Phaser.Geom.Rectangle} rectangle - [description] + * @param {number} step - [description] + * @param {integer} quantity - [description] + * @param {array} [out] - [description] * - * @return {object} [description] + * @return {Phaser.Geom.Point[]} [description] */ -var ParseObject = function (tiledObject, offsetX, offsetY) +var GetPoints = function (rectangle, quantity, stepRate, out) { - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } + if (out === undefined) { out = []; } - var parsedObject = Pick(tiledObject, commonObjectProps); - - parsedObject.x += offsetX; - parsedObject.y += offsetY; - - if (tiledObject.gid) + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) { - // Object tiles - var gidInfo = ParseGID(tiledObject.gid); - parsedObject.gid = gidInfo.gid; - parsedObject.flippedHorizontal = gidInfo.flippedHorizontal; - parsedObject.flippedVertical = gidInfo.flippedVertical; - parsedObject.flippedAntiDiagonal = gidInfo.flippedAntiDiagonal; - } - else if (tiledObject.polyline) - { - parsedObject.polyline = tiledObject.polyline.map(copyPoints); - } - else if (tiledObject.polygon) - { - parsedObject.polygon = tiledObject.polygon.map(copyPoints); - } - else if (tiledObject.ellipse) - { - parsedObject.ellipse = tiledObject.ellipse; - parsedObject.width = tiledObject.width; - parsedObject.height = tiledObject.height; - } - else if (tiledObject.text) - { - parsedObject.width = tiledObject.width; - parsedObject.height = tiledObject.height; - parsedObject.text = tiledObject.text; - } - else - { - // Otherwise, assume it is a rectangle - parsedObject.rectangle = true; - parsedObject.width = tiledObject.width; - parsedObject.height = tiledObject.height; + quantity = Perimeter(rectangle) / stepRate; } - return parsedObject; + for (var i = 0; i < quantity; i++) + { + var position = i / quantity; + + out.push(GetPoint(rectangle, position)); + } + + return out; }; -module.exports = ParseObject; +module.exports = GetPoints; /***/ }), /* 353 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -64926,100 +71917,22 @@ module.exports = ParseObject; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(2); - /** - * @classdesc - * A class for representing a Tiled object layer in a map. This mirrors the structure of a Tiled - * object layer, except: - * - "x" & "y" properties are ignored since these cannot be changed in Tiled. - * - "offsetx" & "offsety" are applied to the individual object coordinates directly, so they - * are ignored as well. - * - "draworder" is ignored. + * Returns the circumference of the given Circle. * - * @class ObjectLayer - * @memberOf Phaser.Tilemaps - * @constructor + * @function Phaser.Geom.Circle.Circumference * @since 3.0.0 * - * @param {object} [config] - [description] + * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference of. + * + * @return {number} The circumference of the Circle. */ -var ObjectLayer = new Class({ +var Circumference = function (circle) +{ + return 2 * (Math.PI * circle.radius); +}; - initialize: - - function ObjectLayer (config) - { - if (config === undefined) { config = {}; } - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#name - * @type {string} - * @since 3.0.0 - */ - this.name = GetFastValue(config, 'name', 'object layer'); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#opacity - * @type {number} - * @since 3.0.0 - */ - this.opacity = GetFastValue(config, 'opacity', 1); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#properties - * @type {object} - * @since 3.0.0 - */ - this.properties = GetFastValue(config, 'properties', {}); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#propertyTypes - * @type {object} - * @since 3.0.0 - */ - this.propertyTypes = GetFastValue(config, 'propertytypes', {}); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#type - * @type {string} - * @since 3.0.0 - */ - this.type = GetFastValue(config, 'type', 'objectgroup'); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#visible - * @type {boolean} - * @since 3.0.0 - */ - this.visible = GetFastValue(config, 'visible', true); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#objects - * @type {array} - * @since 3.0.0 - */ - this.objects = GetFastValue(config, 'objects', []); - } - -}); - -module.exports = ObjectLayer; +module.exports = Circumference; /***/ }), @@ -65032,61 +71945,46 @@ module.exports = ObjectLayer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Formats = __webpack_require__(22); -var MapData = __webpack_require__(76); -var ParseTileLayers = __webpack_require__(912); -var ParseTilesets = __webpack_require__(913); +var Circumference = __webpack_require__(353); +var CircumferencePoint = __webpack_require__(168); +var FromPercent = __webpack_require__(78); +var MATH_CONST = __webpack_require__(16); /** - * Parses a Weltmeister JSON object into a new MapData object. + * Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, + * based on the given quantity or stepRate values. * - * @function Phaser.Tilemaps.Parsers.Impact.ParseWeltmeister + * @function Phaser.Geom.Circle.GetPoints * @since 3.0.0 * - * @param {string} name - The name of the tilemap, used to set the name on the MapData. - * @param {object} json - The Weltmeister JSON object. - * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. + * @param {Phaser.Geom.Circle} circle - The Circle to get the points from. + * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. + * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. * - * @return {object|null} [description] + * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the circumference of the circle. */ -var ParseWeltmeister = function (name, json, insertNull) +var GetPoints = function (circle, quantity, stepRate, out) { - if (json.layer.length === 0) + if (out === undefined) { out = []; } + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) { - console.warn('No layers found in the Weltmeister map: ' + name); - return null; + quantity = Circumference(circle) / stepRate; } - var width = 0; - var height = 0; - - for (var i = 0; i < json.layer.length; i++) + for (var i = 0; i < quantity; i++) { - if (json.layer[i].width > width) { width = json.layer[i].width; } - if (json.layer[i].height > height) { height = json.layer[i].height; } + var angle = FromPercent(i / quantity, 0, MATH_CONST.PI2); + + out.push(CircumferencePoint(circle, angle)); } - var mapData = new MapData({ - width: width, - height: height, - name: name, - tileWidth: json.layer[0].tilesize, - tileHeight: json.layer[0].tilesize, - format: Formats.WELTMEISTER - }); - - mapData.layers = ParseTileLayers(json, insertNull); - mapData.tilesets = ParseTilesets(json); - - return mapData; + return out; }; -module.exports = ParseWeltmeister; +module.exports = GetPoints; /***/ }), @@ -65099,2253 +71997,35 @@ module.exports = ParseWeltmeister; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var DegToRad = __webpack_require__(35); -var DynamicTilemapLayer = __webpack_require__(356); -var Extend = __webpack_require__(23); -var Formats = __webpack_require__(22); -var LayerData = __webpack_require__(75); -var Rotate = __webpack_require__(324); -var StaticTilemapLayer = __webpack_require__(357); -var Tile = __webpack_require__(44); -var TilemapComponents = __webpack_require__(96); -var Tileset = __webpack_require__(100); +var CircumferencePoint = __webpack_require__(168); +var FromPercent = __webpack_require__(78); +var MATH_CONST = __webpack_require__(16); +var Point = __webpack_require__(4); /** - * @classdesc - * A Tilemap is a container for Tilemap data. This isn't a display object, rather, it holds data - * about the map and allows you to add tilesets and tilemap layers to it. A map can have one or - * more tilemap layers (StaticTilemapLayer or DynamicTilemapLayer), which are the display - * objects that actually render tiles. + * Returns a Point object containing the coordinates of a point on the circumference of the Circle + * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point + * at 180 degrees around the circle. * - * The Tilemap data be parsed from a Tiled JSON file, a CSV file or a 2D array. Tiled is a free - * software package specifically for creating tile maps, and is available from: - * http://www.mapeditor.org - * - * A Tilemap has handy methods for getting & manipulating the tiles within a layer. You can only - * use the methods that change tiles (e.g. removeTileAt) on a DynamicTilemapLayer. - * - * Note that all Tilemaps use a base tile size to calculate dimensions from, but that a - * StaticTilemapLayer or DynamicTilemapLayer may have its own unique tile size that overrides - * it. - * - * @class Tilemap - * @memberOf Phaser.Tilemaps - * @constructor + * @function Phaser.Geom.Circle.GetPoint * @since 3.0.0 * - * @param {Phaser.Scene} scene - The Scene to which this Tilemap belongs. - * @param {Phaser.Tilemaps.MapData} mapData - A MapData instance containing Tilemap data. + * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on. + * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. + * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. + * + * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the circle. */ -var Tilemap = new Class({ +var GetPoint = function (circle, position, out) +{ + if (out === undefined) { out = new Point(); } - initialize: + var angle = FromPercent(position, 0, MATH_CONST.PI2); - function Tilemap (scene, mapData) - { - /** - * @name Phaser.Tilemaps.Tilemap#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; + return CircumferencePoint(circle, angle, out); +}; - /** - * The base width of a tile in pixels. Note that individual layers may have a different tile - * width. - * - * @name Phaser.Tilemaps.Tilemap#tileWidth - * @type {integer} - * @since 3.0.0 - */ - this.tileWidth = mapData.tileWidth; - - /** - * The base height of a tile in pixels. Note that individual layers may have a different - * tile height. - * - * @name Phaser.Tilemaps.Tilemap#tileHeight - * @type {integer} - * @since 3.0.0 - */ - this.tileHeight = mapData.tileHeight; - - /** - * The width of the map (in tiles). - * - * @name Phaser.Tilemaps.Tilemap#width - * @type {number} - * @since 3.0.0 - */ - this.width = mapData.width; - - /** - * The height of the map (in tiles). - * - * @name Phaser.Tilemaps.Tilemap#height - * @type {number} - * @since 3.0.0 - */ - this.height = mapData.height; - - /** - * The orientation of the map data (as specified in Tiled), usually 'orthogonal'. - * - * @name Phaser.Tilemaps.Tilemap#orientation - * @type {string} - * @since 3.0.0 - */ - this.orientation = mapData.orientation; - - /** - * The format of the map data. - * - * @name Phaser.Tilemaps.Tilemap#format - * @type {number} - * @since 3.0.0 - */ - this.format = mapData.format; - - /** - * The version of the map data (as specified in Tiled, usually 1). - * - * @name Phaser.Tilemaps.Tilemap#version - * @type {number} - * @since 3.0.0 - */ - this.version = mapData.version; - - /** - * Map specific properties as specified in Tiled. - * - * @name Phaser.Tilemaps.Tilemap#properties - * @type {object} - * @since 3.0.0 - */ - this.properties = mapData.properties; - - /** - * The width of the map in pixels based on width * tileWidth. - * - * @name Phaser.Tilemaps.Tilemap#widthInPixels - * @type {number} - * @since 3.0.0 - */ - this.widthInPixels = mapData.widthInPixels; - - /** - * The height of the map in pixels based on height * tileHeight. - * - * @name Phaser.Tilemaps.Tilemap#heightInPixels - * @type {number} - * @since 3.0.0 - */ - this.heightInPixels = mapData.heightInPixels; - - /** - * - * @name Phaser.Tilemaps.Tilemap#imageCollections - * @type {Phaser.Tilemaps.ImageCollection[]} - * @since 3.0.0 - */ - this.imageCollections = mapData.imageCollections; - - /** - * An array of Tiled Image Layers. - * - * @name Phaser.Tilemaps.Tilemap#images - * @type {array} - * @since 3.0.0 - */ - this.images = mapData.images; - - /** - * An array of Tilemap layer data. - * - * @name Phaser.Tilemaps.Tilemap#layers - * @type {Phaser.Tilemaps.LayerData[]} - * @since 3.0.0 - */ - this.layers = mapData.layers; - - /** - * An array of Tilesets used in the map. - * - * @name Phaser.Tilemaps.Tilemap#tilesets - * @type {Phaser.Tilemaps.Tileset[]} - * @since 3.0.0 - */ - this.tilesets = mapData.tilesets; - - /** - * An array of ObjectLayer instances parsed from Tiled object layers. - * - * @name Phaser.Tilemaps.Tilemap#objects - * @type {Phaser.Tilemaps.ObjectLayer[]} - * @since 3.0.0 - */ - this.objects = mapData.objects; - - /** - * The index of the currently selected LayerData object. - * - * @name Phaser.Tilemaps.Tilemap#currentLayerIndex - * @type {integer} - * @since 3.0.0 - */ - this.currentLayerIndex = 0; - }, - - /** - * Adds an image to the map to be used as a tileset. A single map may use multiple tilesets. - * Note that the tileset name can be found in the JSON file exported from Tiled, or in the Tiled - * editor. - * - * @method Phaser.Tilemaps.Tilemap#addTilesetImage - * @since 3.0.0 - * - * @param {string} tilesetName - The name of the tileset as specified in the map data. - * @param {string} [key] - The key of the Phaser.Cache image used for this tileset. If - * `undefined` or `null` it will look for an image with a key matching the tileset parameter. - * @param {integer} [tileWidth] - The width of the tile (in pixels) in the Tileset Image. If not - * given it will default to the map's tileWidth value, or the tileWidth specified in the Tiled - * JSON file. - * @param {integer} [tileHeight] - The height of the tiles (in pixels) in the Tileset Image. If - * not given it will default to the map's tileHeight value, or the tileHeight specified in the - * Tiled JSON file. - * @param {integer} [tileMargin] - The margin around the tiles in the sheet (in pixels). If not - * specified, it will default to 0 or the value specified in the Tiled JSON file. - * @param {integer} [tileSpacing] - The spacing between each the tile in the sheet (in pixels). - * If not specified, it will default to 0 or the value specified in the Tiled JSON file. - * @param {integer} [gid=0] - If adding multiple tilesets to a blank map, specify the starting - * GID this set will use here. - * - * @return {Phaser.Tilemaps.Tileset|null} Returns the Tileset object that was created or updated, or null if it - * failed. - */ - addTilesetImage: function (tilesetName, key, tileWidth, tileHeight, tileMargin, tileSpacing, gid) - { - if (tilesetName === undefined) { return null; } - if (key === undefined || key === null) { key = tilesetName; } - - if (!this.scene.sys.textures.exists(key)) - { - console.warn('Invalid image key given for tileset: "' + key + '"'); - return null; - } - - var texture = this.scene.sys.textures.get(key); - - var index = this.getTilesetIndex(tilesetName); - - if (index === null && this.format === Formats.TILED_JSON) - { - console.warn('No data found in the JSON tilemap from Tiled matching the tileset name: "' + tilesetName + '"'); - return null; - } - - if (this.tilesets[index]) - { - this.tilesets[index].setTileSize(tileWidth, tileHeight); - this.tilesets[index].setSpacing(tileMargin, tileSpacing); - this.tilesets[index].setImage(texture); - return this.tilesets[index]; - } - - if (tileWidth === undefined) { tileWidth = this.tileWidth; } - if (tileHeight === undefined) { tileHeight = this.tileHeight; } - if (tileMargin === undefined) { tileMargin = 0; } - if (tileSpacing === undefined) { tileSpacing = 0; } - if (gid === undefined) { gid = 0; } - - var tileset = new Tileset(tilesetName, gid, tileWidth, tileHeight, tileMargin, tileSpacing); - tileset.setImage(texture); - this.tilesets.push(tileset); - - return tileset; - }, - - /** - * Turns the StaticTilemapLayer associated with the given layer into a DynamicTilemapLayer. If - * no layer specified, the map's current layer is used. This is useful if you want to manipulate - * a map at the start of a scene, but then make it non-manipulable and optimize it for speed. - * Note: the DynamicTilemapLayer passed in is destroyed, so make sure to store the value - * returned from this method if you want to manipulate the new StaticTilemapLayer. - * - * @method Phaser.Tilemaps.Tilemap#convertLayerToStatic - * @since 3.0.0 - * - * @param {string|integer|Phaser.Tilemaps.DynamicTilemapLayer} [layer] - The name of the layer from Tiled, the - * index of the layer in the map, or a DynamicTilemapLayer. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer|null} Returns the new layer that was created, or null if it - * failed. - */ - convertLayerToStatic: function (layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - var dynamicLayer = layer.tilemapLayer; - - if (!dynamicLayer || !(dynamicLayer instanceof DynamicTilemapLayer)) - { - return null; - } - - var staticLayer = new StaticTilemapLayer( - dynamicLayer.scene, - dynamicLayer.tilemap, - dynamicLayer.layerIndex, - dynamicLayer.tileset, - dynamicLayer.x, - dynamicLayer.y - ); - - this.scene.sys.displayList.add(staticLayer); - - dynamicLayer.destroy(); - - return staticLayer; - }, - - /** - * See component documentation. If no layer specified, the map's current layer is used. This - * cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#copy - * @since 3.0.0 - * - * @return {Phaser.Tilemaps.Tilemap|null} Returns this, or null if the layer given was invalid. - */ - copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'copy')) { return this; } - - if (layer !== null) - { - TilemapComponents.Copy( - srcTileX, srcTileY, - width, height, - destTileX, destTileY, - recalculateFaces, layer - ); - } - - return this; - }, - - /** - * Creates a new and empty DynamicTilemapLayer. The currently selected layer in the map is set - * to this new layer. - * - * @method Phaser.Tilemaps.Tilemap#createBlankDynamicLayer - * @since 3.0.0 - * - * @param {string} name - The name of this layer. Must be unique within the map. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset the new layer will use. - * @param {integer} width - The width of the layer in tiles. If not specified, it will default - * to the map's width. - * @param {integer} height - The height of the layer in tiles. If not specified, it will default - * to the map's height. - * @param {integer} tileWidth - The width of the tiles the layer uses for calculations. If not - * specified, it will default to the map's tileWidth. - * @param {integer} tileHeight - The height of the tiles the layer uses for calculations. If not - * specified, it will default to the map's tileHeight. - * @return {Phaser.Tilemaps.DynamicTilemapLayer|null} Returns the new layer was created, or null if it failed. - */ - createBlankDynamicLayer: function (name, tileset, x, y, width, height, tileWidth, tileHeight) - { - if (tileWidth === undefined) { tileWidth = tileset.tileWidth; } - if (tileHeight === undefined) { tileHeight = tileset.tileHeight; } - if (width === undefined) { width = this.width; } - if (height === undefined) { height = this.height; } - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - - var index = this.getLayerIndex(name); - - if (index !== null) - { - console.warn('Cannot create blank layer: layer with matching name already exists ' + name); - return null; - } - - var layerData = new LayerData({ - name: name, - tileWidth: tileWidth, - tileHeight: tileHeight, - width: width, - height: height - }); - - var row; - - for (var tileY = 0; tileY < height; tileY++) - { - row = []; - - for (var tileX = 0; tileX < width; tileX++) - { - row.push(new Tile(layerData, -1, tileX, tileY, tileWidth, tileHeight, this.tileWidth, this.tileHeight)); - } - - layerData.data.push(row); - } - - this.layers.push(layerData); - this.currentLayerIndex = this.layers.length - 1; - - var dynamicLayer = new DynamicTilemapLayer(this.scene, this, this.currentLayerIndex, tileset, x, y); - this.scene.sys.displayList.add(dynamicLayer); - - return dynamicLayer; - }, - - /** - * Creates a new DynamicTilemapLayer that renders the LayerData associated with the given - * `layerID`. The currently selected layer in the map is set to this new layer. - * - * The `layerID` is important. If you've created your map in Tiled then you can get this by - * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and - * look at the layers[].name value. Either way it must match. - * - * Unlike a static layer, a dynamic layer can be modified. See DynamicTilemapLayer for more - * information. - * - * @method Phaser.Tilemaps.Tilemap#createDynamicLayer - * @since 3.0.0 - * - * @param {integer|string} layerID - The layer array index value, or if a string is given, the - * layer name from Tiled. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset the new layer will use. - * @param {number} x - The x position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. - * @param {number} y - The y position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer|null} Returns the new layer was created, or null if it failed. - */ - createDynamicLayer: function (layerID, tileset, x, y) - { - var index = this.getLayerIndex(layerID); - - if (index === null) - { - console.warn('Cannot create tilemap layer, invalid layer ID given: ' + layerID); - return null; - } - - var layerData = this.layers[index]; - - // Check for an associated static or dynamic tilemap layer - if (layerData.tilemapLayer) - { - console.warn('Cannot create dynamic tilemap layer since a static or dynamic tilemap layer exists for layer ID:' + layerID); - return null; - } - - this.currentLayerIndex = index; - - // Make sure that all the LayerData & the tiles have the correct tile size. They usually - // are, but wouldn't match if you try to load a 2x or 4x res tileset when the map was made - // with a 1x res tileset. - if (layerData.tileWidth !== tileset.tileWidth || layerData.tileHeight !== tileset.tileHeight) - { - this.setLayerTileSize(tileset.tileWidth, tileset.tileHeight, index); - } - - // Default the x/y position to match Tiled layer offset, if it exists. - if (x === undefined && this.layers[index].x) { x = this.layers[index].x; } - if (y === undefined && this.layers[index].y) { y = this.layers[index].y; } - - var layer = new DynamicTilemapLayer(this.scene, this, index, tileset, x, y); - this.scene.sys.displayList.add(layer); - - return layer; - }, - - /** - * Creates a Sprite for every object matching the given gid in the map data. All properties from - * the map data objectgroup are copied into the `spriteConfig`, so you can use this as an easy - * way to configure Sprite properties from within the map editor. For example giving an object a - * property of alpha: 0.5 in the map editor will duplicate that when the Sprite is created. - * - * @method Phaser.Tilemaps.Tilemap#createFromObjects - * @since 3.0.0 - * - * @param {string} name - The name of the object layer (from Tiled) to create Sprites from. - * @param {integer|string} id - Either the id (object), gid (tile object) or name (object or - * tile object) from Tiled. Ids are unique in Tiled, but a gid is shared by all tile objects - * with the same graphic. The same name can be used on multiple objects. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). - * @param {Phaser.Scene} [scene=the scene the map is within] - The Scene to create the Sprites within. - * - * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. - */ - createFromObjects: function (name, id, spriteConfig, scene) - { - if (spriteConfig === undefined) { spriteConfig = {}; } - if (scene === undefined) { scene = this.scene; } - - var objectLayer = this.getObjectLayer(name); - if (!objectLayer) - { - console.warn('Cannot create from object. Invalid objectgroup name given: ' + name); - return; - } - - var objects = objectLayer.objects; - var sprites = []; - - for (var i = 0; i < objects.length; i++) - { - var found = false; - var obj = objects[i]; - - if (obj.gid !== undefined && typeof id === 'number' && obj.gid === id || - obj.id !== undefined && typeof id === 'number' && obj.id === id || - obj.name !== undefined && typeof id === 'string' && obj.name === id) - { - found = true; - } - - if (found) - { - var config = Extend({}, spriteConfig, obj.properties); - - config.x = obj.x; - config.y = obj.y; - - var sprite = this.scene.make.sprite(config); - - sprite.name = obj.name; - - if (obj.width) { sprite.displayWidth = obj.width; } - if (obj.height) { sprite.displayHeight = obj.height; } - - // Origin is (0, 1) in Tiled, so find the offset that matches the Sprite's origin. - var offset = { - x: sprite.originX * sprite.displayWidth, - y: (sprite.originY - 1) * sprite.displayHeight - }; - - // If the object is rotated, then the origin offset also needs to be rotated. - if (obj.rotation) - { - var angle = DegToRad(obj.rotation); - Rotate(offset, angle); - sprite.rotation = angle; - } - - sprite.x += offset.x; - sprite.y += offset.y; - - if (obj.flippedHorizontal !== undefined || obj.flippedVertical !== undefined) - { - sprite.setFlip(obj.flippedHorizontal, obj.flippedVertical); - } - - if (!obj.visible) { sprite.visible = false; } - - sprites.push(sprite); - } - } - - return sprites; - }, - - /** - * Creates a Sprite for every object matching the given tile indexes in the layer. You can - * optionally specify if each tile will be replaced with a new tile after the Sprite has been - * created. This is useful if you want to lay down special tiles in a level that are converted to - * Sprites, but want to replace the tile itself with a floor tile or similar once converted. - * - * @method Phaser.Tilemaps.Tilemap#createFromTiles - * @since 3.0.0 - * - * @param {integer|array} indexes - The tile index, or array of indexes, to create Sprites from. - * @param {integer|array} replacements - The tile index, or array of indexes, to change a converted - * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a - * one-to-one mapping with the indexes array. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). - * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.GameObjects.Sprite[]|null} Returns an array of Tiles, or null if the layer given was invalid. - */ - createFromTiles: function (indexes, replacements, spriteConfig, scene, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, layer); - }, - - /** - * Creates a new StaticTilemapLayer that renders the LayerData associated with the given - * `layerID`. The currently selected layer in the map is set to this new layer. - * - * The `layerID` is important. If you've created your map in Tiled then you can get this by - * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and - * look at the layers[].name value. Either way it must match. - * - * It's important to remember that a static layer cannot be modified. See StaticTilemapLayer for - * more information. - * - * @method Phaser.Tilemaps.Tilemap#createStaticLayer - * @since 3.0.0 - * - * @param {integer|string} layerID - The layer array index value, or if a string is given, the - * layer name from Tiled. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset the new layer will use. - * @param {number} x - The x position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. - * @param {number} y - The y position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer|null} Returns the new layer was created, or null if it failed. - */ - createStaticLayer: function (layerID, tileset, x, y) - { - var index = this.getLayerIndex(layerID); - - if (index === null) - { - console.warn('Cannot create tilemap layer, invalid layer ID given: ' + layerID); - return null; - } - - var layerData = this.layers[index]; - - // Check for an associated static or dynamic tilemap layer - if (layerData.tilemapLayer) - { - console.warn('Cannot create static tilemap layer since a static or dynamic tilemap layer exists for layer ID:' + layerID); - return null; - } - - this.currentLayerIndex = index; - - // Make sure that all the LayerData & the tiles have the correct tile size. They usually - // are, but wouldn't match if you try to load a 2x or 4x res tileset when the map was made - // with a 1x res tileset. - if (layerData.tileWidth !== tileset.tileWidth || layerData.tileHeight !== tileset.tileHeight) - { - this.setLayerTileSize(tileset.tileWidth, tileset.tileHeight, index); - } - - // Default the x/y position to match Tiled layer offset, if it exists. - if (x === undefined && this.layers[index].x) { x = this.layers[index].x; } - if (y === undefined && this.layers[index].y) { y = this.layers[index].y; } - - var layer = new StaticTilemapLayer(this.scene, this, index, tileset, x, y); - this.scene.sys.displayList.add(layer); - - return layer; - }, - - /** - * Removes all layer data from this Tilemap and nulls the scene reference. This will destroy any - * StaticTilemapLayers or DynamicTilemapLayers that have been linked to LayerData. - * - * @method Phaser.Tilemaps.Tilemap#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.removeAllLayers(); - this.tilesets.length = 0; - this.objects.length = 0; - this.scene = undefined; - }, - - /** - * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the - * specified index. Tiles will be set to collide if the given index is a colliding index. - * Collision information in the region will be recalculated. - * - * If no layer specified, the map's current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#fill - * @since 3.0.0 - * - * @param {integer} index - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Returns this, or null if the layer given was invalid. - */ - fill: function (index, tileX, tileY, width, height, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'fill')) { return this; } - - if (layer !== null) - { - TilemapComponents.Fill(index, tileX, tileY, width, height, recalculateFaces, layer); - } - - return this; - }, - - /** - * For each object in the given object layer, run the given filter callback function. Any - * objects that pass the filter test (i.e. where the callback returns true) will returned as a - * new array. Similar to Array.prototype.Filter in vanilla JS. - * - * @method Phaser.Tilemaps.Tilemap#filterObjects - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.ObjectLayer|string} [objectLayer] - The name of an object layer (from Tiled) or an - * ObjectLayer instance. - * @param {function} callback - The callback. Each object in the given area will be passed to - * this callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * - * @return {object[]|null} An array of object that match the search, or null if the objectLayer - * given was invalid. - */ - filterObjects: function (objectLayer, callback, context) - { - if (typeof objectLayer === 'string') - { - var name = objectLayer; - - objectLayer = this.getObjectLayer(objectLayer); - - if (!objectLayer) - { - console.warn('No object layer found with the name: ' + name); - return null; - } - } - - return objectLayer.objects.filter(callback, context); - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns - * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#filterTiles - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. The callback should return true for tiles that pass the - * filter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile[]|null} Returns an array of Tiles, or null if the layer given was invalid. - */ - filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, layer); - }, - - /** - * Searches the entire map layer for the first tile matching the given index, then returns that Tile - * object. If no match is found, it returns null. The search starts from the top-left tile and - * continues horizontally until it hits the end of the row, then it drops down to the next column. - * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to - * the top-left. - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#findByIndex - * @since 3.0.0 - * - * @param {integer} index - The tile index value to search for. - * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. - * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the - * bottom-right. Otherwise it scans from the top-left. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile|null} Returns a Tiles, or null if the layer given was invalid. - */ - findByIndex: function (findIndex, skip, reverse, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.FindByIndex(findIndex, skip, reverse, layer); - }, - - /** - * Find the first object in the given object layer that satisfies the provided testing function. - * I.e. finds the first object for which `callback` returns true. Similar to - * Array.prototype.find in vanilla JS. - * - * @method Phaser.Tilemaps.Tilemap#findObject - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.ObjectLayer|string} [objectLayer] - The name of an object layer (from Tiled) or an - * ObjectLayer instance. - * @param {function} callback - The callback. Each object in the given area will be passed to - * this callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * - * @return {object|null} An object that matches the search, or null if no object found - */ - findObject: function (objectLayer, callback, context) - { - if (typeof objectLayer === 'string') - { - var name = objectLayer; - - objectLayer = this.getObjectLayer(objectLayer); - - if (!objectLayer) - { - console.warn('No object layer found with the name: ' + name); - return null; - } - } - - return objectLayer.objects.find(callback, context) || null; - }, - - /** - * Find the first tile in the given rectangular area (in tile coordinates) of the layer that - * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns - * true. Similar to Array.prototype.find in vanilla JS. - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#findTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile|null} Returns a Tiles, or null if the layer given was invalid. - */ - findTile: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, layer); - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * callback. Similar to Array.prototype.forEach in vanilla JS. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#forEachTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Returns this, or null if the layer given was invalid. - */ - forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) - { - layer = this.getLayer(layer); - - if (layer !== null) - { - TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, layer); - } - - return this; - }, - - /** - * Gets the image layer index based on its name. - * - * @method Phaser.Tilemaps.Tilemap#getImageIndex - * @since 3.0.0 - * - * @param {string} name - The name of the image to get. - * - * @return {integer} The index of the image in this tilemap, or null if not found. - */ - getImageIndex: function (name) - { - return this.getIndex(this.images, name); - }, - - /** - * Internally used. Returns the index of the object in one of the Tilemaps arrays whose name - * property matches the given `name`. - * - * @method Phaser.Tilemaps.Tilemap#getIndex - * @since 3.0.0 - * - * @param {array} location - The Tilemap array to search. - * @param {string} name - The name of the array element to get. - * - * @return {number} The index of the element in the array, or null if not found. - */ - getIndex: function (location, name) - { - for (var i = 0; i < location.length; i++) - { - if (location[i].name === name) - { - return i; - } - } - - return null; - }, - - /** - * Gets the LayerData from this.layers that is associated with `layer`, or null if an invalid - * `layer` is given. - * - * @method Phaser.Tilemaps.Tilemap#getLayer - * @since 3.0.0 - * - * @param {string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer} [layer] - The name of the - * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a - * StaticTilemapLayer. If not given will default to the maps current layer index. - * - * @return {Phaser.Tilemaps.LayerData} The corresponding LayerData within this.layers. - */ - getLayer: function (layer) - { - var index = this.getLayerIndex(layer); - - return index !== null ? this.layers[index] : null; - }, - - /** - * Gets the ObjectLayer from this.objects that has the given `name`, or null if no ObjectLayer - * is found with that name. - * - * @method Phaser.Tilemaps.Tilemap#getObjectLayer - * @since 3.0.0 - * - * @param {string} [name] - The name of the object layer from Tiled. - * - * @return {Phaser.Tilemaps.ObjectLayer|null} The corresponding ObjectLayer within this.objects or null. - */ - getObjectLayer: function (name) - { - var index = this.getIndex(this.objects, name); - - return index !== null ? this.objects[index] : null; - }, - - /** - * Gets the LayerData index of the given `layer` within this.layers, or null if an invalid - * `layer` is given. - * - * @method Phaser.Tilemaps.Tilemap#getLayerIndex - * @since 3.0.0 - * - * @param {string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer} [layer] - The name of the - * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a - * StaticTilemapLayer. If not given will default to the map's current layer index. - * - * @return {integer} The LayerData index within this.layers. - */ - getLayerIndex: function (layer) - { - if (layer === undefined) - { - return this.currentLayerIndex; - } - else if (typeof layer === 'string') - { - return this.getLayerIndexByName(layer); - } - else if (typeof layer === 'number' && layer < this.layers.length) - { - return layer; - } - else if (layer instanceof StaticTilemapLayer || layer instanceof DynamicTilemapLayer) - { - return layer.layerIndex; - } - else - { - return null; - } - }, - - /** - * Gets the index of the LayerData within this.layers that has the given `name`, or null if an - * invalid `name` is given. - * - * @method Phaser.Tilemaps.Tilemap#getLayerIndexByName - * @since 3.0.0 - * - * @param {string} name - The name of the layer to get. - * - * @return {integer} The LayerData index within this.layers. - */ - getLayerIndexByName: function (name) - { - return this.getIndex(this.layers, name); - }, - - /** - * Gets a tile at the given tile coordinates from the given layer. - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#getTileAt - * @since 3.0.0 - * - * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). - * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). - * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile|null} Returns a Tile, or null if the layer given was invalid. - */ - getTileAt: function (tileX, tileY, nonNull, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.GetTileAt(tileX, tileY, nonNull, layer); - }, - - /** - * Gets a tile at the given world coordinates from the given layer. - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#getTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - X position to get the tile from (given in pixels) - * @param {number} worldY - Y position to get the tile from (given in pixels) - * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile|null} Returns a Tile, or null if the layer given was invalid. - */ - getTileAtWorldXY: function (worldX, worldY, nonNull, camera, layer) - { - layer = this.getLayer(layer); - - - if (layer === null) { return null; } - - return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, layer); - }, - - /** - * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#getTilesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile[]|null} Returns an array of Tiles, or null if the layer given was invalid. - */ - getTilesWithin: function (tileX, tileY, width, height, filteringOptions, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); - }, - - /** - * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, - * Line, Rectangle or Triangle. The shape should be in world coordinates. - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#getTilesWithinShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle} shape - A shape in world (pixel) coordinates - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile[]|null} Returns an array of Tiles, or null if the layer given was invalid. - */ - getTilesWithinShape: function (shape, filteringOptions, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, layer); - }, - - /** - * Gets the tiles in the given rectangular area (in world coordinates) of the layer. - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#getTilesWithinWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile[]|null} Returns an array of Tiles, or null if the layer given was invalid. - */ - getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, layer); - }, - - /** - * Gets the index of the Tileset within this.tilesets that has the given `name`, or null if an - * invalid `name` is given. - * - * @method Phaser.Tilemaps.Tilemap#getTilesetIndex - * @since 3.0.0 - * - * @param {string} name - The name of the Tileset to get. - * - * @return {integer} The Tileset index within this.tilesets. - */ - getTilesetIndex: function (name) - { - return this.getIndex(this.tilesets, name); - }, - - /** - * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#hasTileAt - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {boolean|null} Returns a boolean, or null if the layer given was invalid. - */ - hasTileAt: function (tileX, tileY, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.HasTileAt(tileX, tileY, layer); - }, - - /** - * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#hasTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {boolean|null} Returns a boolean, or null if the layer given was invalid. - */ - hasTileAtWorldXY: function (worldX, worldY, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, layer); - }, - - /** - * The LayerData object that is currently selected in the map. You can set this property using - * any type supported by setLayer. - * - * @name Phaser.Tilemaps.Tilemap#layer - * @type {Phaser.Tilemaps.LayerData} - * @since 3.0.0 - */ - layer: { - get: function () - { - return this.layers[this.currentLayerIndex]; - }, - - set: function (layer) - { - this.setLayer(layer); - } - }, - - /** - * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index - * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified - * location. If you pass in an index, only the index at the specified location will be changed. - * Collision information will be recalculated at the specified location. - * - * If no layer specified, the maps current layer is used. - * - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#putTileAt - * @since 3.0.0 - * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile|null} Returns a Tile, or null if the layer given was invalid. - */ - putTileAt: function (tile, tileX, tileY, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'putTileAt')) { return null; } - - if (layer === null) { return null; } - - return TilemapComponents.PutTileAt(tile, tileX, tileY, recalculateFaces, layer); - }, - - /** - * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either - * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the - * specified location. If you pass in an index, only the index at the specified location will be - * changed. Collision information will be recalculated at the specified location. - * - * If no layer specified, the maps current layer is used. This - * cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#putTileAtWorldXY - * @since 3.0.0 - * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {integer} worldX - [description] - * @param {integer} worldY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile|null} Returns a Tile, or null if the layer given was invalid. - */ - putTileAtWorldXY: function (tile, worldX, worldY, recalculateFaces, camera, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'putTileAtWorldXY')) { return null; } - - if (layer === null) { return null; } - - return TilemapComponents.PutTileAtWorldXY(tile, worldX, worldY, recalculateFaces, camera, layer); - }, - - /** - * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified - * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, - * all attributes will be copied over to the specified location. If you pass in an index, only the - * index at the specified location will be changed. Collision information will be recalculated - * within the region tiles were changed. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#putTilesAt - * @since 3.0.0 - * - * @param {integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][]} tile - A row (array) or grid (2D array) of Tiles - * or tile indexes to place. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Returns this, or null if the layer given was invalid. - */ - putTilesAt: function (tilesArray, tileX, tileY, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'putTilesAt')) { return this; } - - if (layer !== null) - { - TilemapComponents.PutTilesAt(tilesArray, tileX, tileY, recalculateFaces, layer); - } - - return this; - }, - - /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will recieve a new index. If an array of indexes is passed in, then - * those will be used for randomly assigning new tile indexes. If an array is not provided, the - * indexes found within the region (excluding -1) will be used for randomly assigning new tile - * indexes. This method only modifies tile indexes and does not change collision information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#randomize - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Returns this, or null if the layer given was invalid. - */ - randomize: function (tileX, tileY, width, height, indexes, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'randomize')) { return this; } - - if (layer !== null) - { - TilemapComponents.Randomize(tileX, tileY, width, height, indexes, layer); - } - - return this; - }, - - /** - * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting - * faces are used internally for optimizing collisions against tiles. This method is mostly used - * internally to optimize recalculating faces when only one tile has been changed. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#calculateFacesAt - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Returns this, or null if the layer given was invalid. - */ - calculateFacesAt: function (tileX, tileY, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.CalculateFacesAt(tileX, tileY, layer); - - return this; - }, - - /** - * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the - * layer. Interesting faces are used internally for optimizing collisions against tiles. This method - * is mostly used internally. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#calculateFacesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Returns this, or null if the layer given was invalid. - */ - calculateFacesWithin: function (tileX, tileY, width, height, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, layer); - - return this; - }, - - /** - * Removes all layers from this Tilemap and destroys any associated StaticTilemapLayers or - * DynamicTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#removeAllLayers - * @since 3.0.0 - * - * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. - */ - removeAllLayers: function () - { - // Destroy any StaticTilemapLayers or DynamicTilemapLayers that are stored in LayerData - for (var i = 0; i < this.layers.length; i++) - { - if (this.layers[i].tilemapLayer) - { - this.layers[i].tilemapLayer.destroy(); - } - } - - this.layers.length = 0; - this.currentLayerIndex = 0; - - return this; - }, - - /** - * Removes the tile at the given tile coordinates in the specified layer and updates the layer's - * collision information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#removeTileAt - * @since 3.0.0 - * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile|null} Returns a Tile, or null if the layer given was invalid. - */ - removeTileAt: function (tileX, tileY, replaceWithNull, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'removeTileAt')) { return null; } - - if (layer === null) { return null; } - - return TilemapComponents.RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, layer); - }, - - /** - * Removes the tile at the given world coordinates in the specified layer and updates the layer's - * collision information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#removeTileAtWorldXY - * @since 3.0.0 - * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile|null} Returns a Tile, or null if the layer given was invalid. - */ - removeTileAtWorldXY: function (worldX, worldY, replaceWithNull, recalculateFaces, camera, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'removeTileAtWorldXY')) { return null; } - - if (layer === null) { return null; } - - return TilemapComponents.RemoveTileAtWorldXY(worldX, worldY, replaceWithNull, recalculateFaces, camera, layer); - }, - - /** - * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to - * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles - * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation - * wherever you want on the screen. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#renderDebug - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. - * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. - * @param {Color|null} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at - * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. - * @param {Color|null} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled - * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. - * @param {Color|null} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting - * tile faces. If set to null, interesting tile faces will not be drawn. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - renderDebug: function (graphics, styleConfig, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.RenderDebug(graphics, styleConfig, layer); - - return this; - }, - - /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does - * not change collision information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#replaceByIndex - * @since 3.0.0 - * - * @param {integer} findIndex - [description] - * @param {integer} newIndex - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - replaceByIndex: function (findIndex, newIndex, tileX, tileY, width, height, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'replaceByIndex')) { return this; } - - if (layer !== null) - { - TilemapComponents.ReplaceByIndex(findIndex, newIndex, tileX, tileY, width, height, layer); - } - - return this; - }, - - /** - * Sets collision on the given tile or tiles within a layer by index. You can pass in either a - * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if - * collision will be enabled (true) or disabled (false). - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setCollision - * @since 3.0.0 - * - * @param {integer|array} indexes - Either a single tile index, or an array of tile indexes. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - setCollision: function (indexes, collides, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetCollision(indexes, collides, recalculateFaces, layer); - - return this; - }, - - /** - * Sets collision on a range of tiles in a layer whose index is between the specified `start` and - * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set - * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be - * enabled (true) or disabled (false). - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setCollisionBetween - * @since 3.0.0 - * - * @param {integer} start - The first index of the tile to be set for collision. - * @param {integer} stop - The last index of the tile to be set for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - setCollisionBetween: function (start, stop, collides, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property - * that matches the given properties object, its collision flag will be set. The `collides` - * parameter controls if collision will be enabled (true) or disabled (false). Passing in - * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that - * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can - * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a - * "types" property that matches any of those values, its collision flag will be updated. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setCollisionByProperty - * @since 3.0.0 - * - * @param {object} properties - An object with tile properties and corresponding values that should - * be checked. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - setCollisionByProperty: function (properties, collides, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, layer); - - return this; - }, - - /** - * Sets collision on all tiles in the given layer, except for tiles that have an index specified in - * the given array. The `collides` parameter controls if collision will be enabled (true) or - * disabled (false). - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setCollisionByExclusion - * @since 3.0.0 - * - * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - setCollisionByExclusion: function (indexes, collides, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking each tile's collision group data - * (typically defined in Tiled within the tileset collision editor). If any objects are found within - * a tile's collision group, the tile's colliding information will be set. The `collides` parameter - * controls if collision will be enabled (true) or disabled (false). - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setCollisionFromCollisionGroup - * @since 3.0.0 - * - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - setCollisionFromCollisionGroup: function (collides, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, layer); - - return this; - }, - - /** - * Sets a global collision callback for the given tile index within the layer. This will affect all - * tiles on this layer that have the same index. If a callback is already set for the tile index it - * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile - * at a specific location on the map then see setTileLocationCallback. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setTileIndexCallback - * @since 3.0.0 - * - * @param {integer|array} indexes - Either a single tile index, or an array of tile indexes to have a - * collision callback set for. - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - setTileIndexCallback: function (indexes, callback, callbackContext, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, layer); - - return this; - }, - - /** - * Sets a collision callback for the given rectangular area (in tile coordindates) within the layer. - * If a callback is already set for the tile index it will be replaced. Set the callback to null to - * remove it. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setTileLocationCallback - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, layer); - - return this; - }, - - /** - * Sets the current layer to the LayerData associated with `layer`. - * - * @method Phaser.Tilemaps.Tilemap#setLayer - * @since 3.0.0 - * - * @param {string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer} [layer] - The name of the - * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a - * StaticTilemapLayer. If not given will default to the map's current layer index. - * - * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. - */ - setLayer: function (layer) - { - var index = this.getLayerIndex(layer); - - if (index !== null) - { - this.currentLayerIndex = index; - } - - return this; - }, - - /** - * Sets the base tile size for the map. Note: this does not necessarily match the tileWidth and - * tileHeight for all layers. This also updates the base size on all tiles across all layers. - * - * @method Phaser.Tilemaps.Tilemap#setBaseTileSize - * @since 3.0.0 - * - * @param {integer} tileWidth - The width of the tiles the map uses for calculations. - * @param {integer} tileHeight - The height of the tiles the map uses for calculations. - * - * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. - */ - setBaseTileSize: function (tileWidth, tileHeight) - { - this.tileWidth = tileWidth; - this.tileHeight = tileHeight; - this.widthInPixels = this.width * tileWidth; - this.heightInPixels = this.height * tileHeight; - - // Update the base tile size on all layers & tiles - for (var i = 0; i < this.layers.length; i++) - { - this.layers[i].baseWidth = tileWidth; - this.layers[i].baseHeight = tileHeight; - - var mapData = this.layers[i].data; - var mapWidth = this.layers[i].width; - var mapHeight = this.layers[i].height; - - for (var row = 0; row < mapHeight; ++row) - { - for (var col = 0; col < mapWidth; ++col) - { - var tile = mapData[row][col]; - - if (tile !== null) - { - tile.setSize(undefined, undefined, tileWidth, tileHeight); - } - } - } - } - - return this; - }, - - /** - * Sets the tile size for a specific `layer`. Note: this does not necessarily match the map's - * tileWidth and tileHeight for all layers. This will set the tile size for the layer and any - * tiles the layer has. - * - * @method Phaser.Tilemaps.Tilemap#setLayerTileSize - * @since 3.0.0 - * - * @param {integer} tileWidth - The width of the tiles (in pixels) in the layer. - * @param {integer} tileHeight - The height of the tiles (in pixels) in the layer. - * @param {string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer} [layer] - The name of the - * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a - * StaticTilemapLayer. If not given will default to the map's current layer index. - * - * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. - */ - setLayerTileSize: function (tileWidth, tileHeight, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - layer.tileWidth = tileWidth; - layer.tileHeight = tileHeight; - - var mapData = layer.data; - var mapWidth = layer.width; - var mapHeight = layer.height; - - for (var row = 0; row < mapHeight; ++row) - { - for (var col = 0; col < mapWidth; ++col) - { - var tile = mapData[row][col]; - - if (tile !== null) { tile.setSize(tileWidth, tileHeight); } - } - } - - return this; - }, - - /** - * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given - * layer. It will only randomize the tiles in that area, so if they're all the same nothing will - * appear to have changed! This method only modifies tile indexes and does not change collision - * information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#shuffle - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - shuffle: function (tileX, tileY, width, height, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'shuffle')) { return this; } - - if (layer !== null) - { - TilemapComponents.Shuffle(tileX, tileY, width, height, layer); - } - - return this; - }, - - /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision - * information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#swapByIndex - * @since 3.0.0 - * - * @param {integer} tileA - First tile index. - * @param {integer} tileB - Second tile index. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - swapByIndex: function (indexA, indexB, tileX, tileY, width, height, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'swapByIndex')) { return this; } - - if (layer !== null) - { - TilemapComponents.SwapByIndex(indexA, indexB, tileX, tileY, width, height, layer); - } - - return this; - }, - - /** - * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#tileToWorldX - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {number|null} Returns a number, or null if the layer given was invalid. - */ - tileToWorldX: function (tileX, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.TileToWorldX(tileX, camera, layer); - }, - - /** - * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#tileToWorldY - * @since 3.0.0 - * - * @param {integer} tileY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {number|null} Returns a number, or null if the layer given was invalid. - */ - tileToWorldY: function (tileX, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.TileToWorldY(tileX, camera, layer); - }, - - /** - * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#tileToWorldXY - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Math.Vector2|null} Returns a point, or null if the layer given was invalid. - */ - tileToWorldXY: function (tileX, tileY, point, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, layer); - }, - - /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will receive a new index. New indexes are drawn from the given - * weightedIndexes array. An example weighted array: - * - * [ - * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 - * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 - * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 - * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 - * ] - * - * The probability of any index being choose is (the index's weight) / (sum of all weights). This - * method only modifies tile indexes and does not change collision information. - * - * If no layer specified, the map's current layer is used. This - * cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#weightedRandomize - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during - * randomization. They should be in the form: { index: 0, weight: 4 } or - * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - weightedRandomize: function (tileX, tileY, width, height, weightedIndexes, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'weightedRandomize')) { return this; } - - if (layer !== null) - { - TilemapComponents.WeightedRandomize(tileX, tileY, width, height, weightedIndexes, layer); - } - - return this; - }, - - /** - * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#worldToTileX - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {number|null} Returns a number, or null if the layer given was invalid. - */ - worldToTileX: function (worldX, snapToFloor, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, layer); - }, - - /** - * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#worldToTileY - * @since 3.0.0 - * - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {number|null} Returns a number, or null if the layer given was invalid. - */ - worldToTileY: function (worldY, snapToFloor, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, layer); - }, - - /** - * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#worldToTileXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Math.Vector2|null} Returns a point, or null if the layer given was invalid. - */ - worldToTileXY: function (worldX, worldY, snapToFloor, point, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, layer); - }, - - /** - * Used internally to check if a layer is static and prints out a warning. - * - * @method Phaser.Tilemaps.Tilemap#_isStaticCall - * @private - * @since 3.0.0 - * - * @return {boolean} - */ - _isStaticCall: function (layer, functionName) - { - if (layer.tilemapLayer instanceof StaticTilemapLayer) - { - console.warn(functionName + ': You cannot change the tiles in a static tilemap layer'); - return true; - } - else - { - return false; - } - } - -}); - -module.exports = Tilemap; +module.exports = GetPoint; /***/ }), @@ -67358,1113 +72038,36 @@ module.exports = Tilemap; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var DynamicTilemapLayerRender = __webpack_require__(914); -var GameObject = __webpack_require__(1); -var TilemapComponents = __webpack_require__(96); +var GetRight = __webpack_require__(32); +var GetTop = __webpack_require__(30); +var SetRight = __webpack_require__(31); +var SetTop = __webpack_require__(29); /** - * @classdesc - * A DynamicTilemapLayer is a game object that renders LayerData from a Tilemap. A - * DynamicTilemapLayer can only render tiles from a single tileset. + * Takes given Game Object and aligns it so that it is positioned in the top right of the other. * - * A DynamicTilemapLayer trades some speed for being able to apply powerful effects. Unlike a - * StaticTilemapLayer, you can apply per-tile effects like tint or alpha, and you can change the - * tiles in a DynamicTilemapLayer. Use this over a StaticTilemapLayer when you need those - * features. - * - * @class DynamicTilemapLayer - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.Tilemaps - * @constructor + * @function Phaser.Display.Align.In.TopRight * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * @extends Phaser.GameObjects.Components.ScrollFactor * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.Tilemaps.Tilemap} tilemap - The Tilemap this layer is a part of. - * @param {integer} layerIndex - The index of the LayerData associated with this layer. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset used to render the tiles in this layer. - * @param {number} [x=0] - The world x position where the top left of this layer will be placed. - * @param {number} [y=0] - The world y position where the top left of this layer will be placed. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. */ -var DynamicTilemapLayer = new Class({ +var TopRight = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } - Extends: GameObject, + SetRight(gameObject, GetRight(alignIn) + offsetX); + SetTop(gameObject, GetTop(alignIn) - offsetY); - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.Size, - Components.Transform, - Components.Visible, - Components.ScrollFactor, - DynamicTilemapLayerRender - ], + return gameObject; +}; - initialize: - - function DynamicTilemapLayer (scene, tilemap, layerIndex, tileset, x, y) - { - GameObject.call(this, scene, 'DynamicTilemapLayer'); - - /** - * Used internally by physics system to perform fast type checks. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#isTilemap - * @type {boolean} - * @readOnly - * @since 3.0.0 - */ - this.isTilemap = true; - - /** - * The Tilemap that this layer is a part of. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#tilemap - * @type {Phaser.Tilemaps.Tilemap} - * @since 3.0.0 - */ - this.tilemap = tilemap; - - /** - * The index of the LayerData associated with this layer. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#layerIndex - * @type {integer} - * @since 3.0.0 - */ - this.layerIndex = layerIndex; - - /** - * The LayerData associated with this layer. LayerData can only be associated with one - * tilemap layer. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#layer - * @type {Phaser.Tilemaps.LayerData} - * @since 3.0.0 - */ - this.layer = tilemap.layers[layerIndex]; - - this.layer.tilemapLayer = this; // Link the LayerData with this static tilemap layer - - /** - * The Tileset associated with this layer. A tilemap layer can only render from one Tileset. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#tileset - * @type {Phaser.Tilemaps.Tileset} - * @since 3.0.0 - */ - this.tileset = tileset; - - /** - * Used internally with the canvas render. This holds the tiles that are visible within the - * camera. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#culledTiles - * @type {array} - * @since 3.0.0 - */ - this.culledTiles = []; - - this.setAlpha(this.layer.alpha); - this.setPosition(x, y); - this.setOrigin(); - this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height); - - this.initPipeline('TextureTintPipeline'); - }, - - /** - * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting - * faces are used internally for optimizing collisions against tiles. This method is mostly used - * internally to optimize recalculating faces when only one tile has been changed. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#calculateFacesAt - * @since 3.0.0 - * - * @param {integer} tileX - The x coordinate. - * @param {integer} tileY - The y coordinate. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - calculateFacesAt: function (tileX, tileY) - { - TilemapComponents.CalculateFacesAt(tileX, tileY, this.layer); - - return this; - }, - - /** - * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the - * layer. Interesting faces are used internally for optimizing collisions against tiles. This method - * is mostly used internally. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#calculateFacesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - calculateFacesWithin: function (tileX, tileY, width, height) - { - TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, this.layer); - - return this; - }, - - /** - * Creates a Sprite for every object matching the given tile indexes in the layer. You can - * optionally specify if each tile will be replaced with a new tile after the Sprite has been - * created. This is useful if you want to lay down special tiles in a level that are converted to - * Sprites, but want to replace the tile itself with a floor tile or similar once converted. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#createFromTiles - * @since 3.0.0 - * - * @param {integer|array} indexes - The tile index, or array of indexes, to create Sprites from. - * @param {integer|array} replacements - The tile index, or array of indexes, to change a converted - * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a - * one-to-one mapping with the indexes array. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). - * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY - * - * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. - */ - createFromTiles: function (indexes, replacements, spriteConfig, scene, camera) - { - return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, this.layer); - }, - - /** - * Returns the tiles in the given layer that are within the cameras viewport. - * This is used internally. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#cull - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - cull: function (camera) - { - return TilemapComponents.CullTiles(this.layer, camera, this.culledTiles); - }, - - /** - * Copies the tiles in the source rectangular area to a new destination (all specified in tile - * coordinates) within the layer. This copies all tile properties & recalculates collision - * information in the destination region. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#copy - * @since 3.0.0 - * - * @param {integer} srcTileX - [description] - * @param {integer} srcTileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {integer} destTileX - [description] - * @param {integer} destTileY - [description] - * @param {integer} destTileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces) - { - TilemapComponents.Copy(srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, this.layer); - - return this; - }, - - /** - * Destroys this DynamicTilemapLayer and removes its link to the associated LayerData. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#destroy - * @since 3.0.0 - */ - destroy: function () - { - // Uninstall this layer only if it is still installed on the LayerData object - if (this.layer.tilemapLayer === this) - { - this.layer.tilemapLayer = undefined; - } - - this.tilemap = undefined; - this.layer = undefined; - this.tileset = undefined; - this.culledTiles.length = 0; - - GameObject.prototype.destroy.call(this); - }, - - /** - * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the - * specified index. Tiles will be set to collide if the given index is a colliding index. - * Collision information in the region will be recalculated. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#fill - * @since 3.0.0 - * - * @param {integer} index - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - fill: function (index, tileX, tileY, width, height, recalculateFaces) - { - TilemapComponents.Fill(index, tileX, tileY, width, height, recalculateFaces, this.layer); - - return this; - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns - * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#filterTiles - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. The callback should return true for tiles that pass the - * filter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * Searches the entire map layer for the first tile matching the given index, then returns that Tile - * object. If no match is found, it returns null. The search starts from the top-left tile and - * continues horizontally until it hits the end of the row, then it drops down to the next column. - * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to - * the top-left. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#findByIndex - * @since 3.0.0 - * - * @param {integer} index - The tile index value to search for. - * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. - * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the - * bottom-right. Otherwise it scans from the top-left. - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - findByIndex: function (findIndex, skip, reverse) - { - return TilemapComponents.FindByIndex(findIndex, skip, reverse, this.layer); - }, - - /** - * Find the first tile in the given rectangular area (in tile coordinates) of the layer that - * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns - * true. Similar to Array.prototype.find in vanilla JS. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#findTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.Tile|null} - */ - findTile: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * callback. Similar to Array.prototype.forEach in vanilla JS. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#forEachTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - - return this; - }, - - /** - * Gets a tile at the given tile coordinates from the given layer. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#getTileAt - * @since 3.0.0 - * - * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). - * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). - * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile - * object with an index of -1. - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates were invalid. - */ - getTileAt: function (tileX, tileY, nonNull) - { - return TilemapComponents.GetTileAt(tileX, tileY, nonNull, this.layer); - }, - - /** - * Gets a tile at the given world coordinates from the given layer. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#getTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - X position to get the tile from (given in pixels) - * @param {number} worldY - Y position to get the tile from (given in pixels) - * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates - * were invalid. - */ - getTileAtWorldXY: function (worldX, worldY, nonNull, camera) - { - return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, this.layer); - }, - - /** - * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithin: function (tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, - * Line, Rectangle or Triangle. The shape should be in world coordinates. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithinShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle} shape - A shape in world (pixel) coordinates - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithinShape: function (shape, filteringOptions, camera) - { - return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, this.layer); - }, - - /** - * Gets the tiles in the given rectangular area (in world coordinates) of the layer. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithinWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera) - { - return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, this.layer); - }, - - /** - * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#hasTileAt - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * - * @return {boolean} - */ - hasTileAt: function (tileX, tileY) - { - return TilemapComponents.HasTileAt(tileX, tileY, this.layer); - }, - - /** - * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#hasTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {boolean} - */ - hasTileAtWorldXY: function (worldX, worldY, camera) - { - return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, this.layer); - }, - - /** - * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index - * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified - * location. If you pass in an index, only the index at the specified location will be changed. - * Collision information will be recalculated at the specified location. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#putTileAt - * @since 3.0.0 - * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - putTileAt: function (tile, tileX, tileY, recalculateFaces) - { - return TilemapComponents.PutTileAt(tile, tileX, tileY, recalculateFaces, this.layer); - }, - - /** - * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either - * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the - * specified location. If you pass in an index, only the index at the specified location will be - * changed. Collision information will be recalculated at the specified location. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#putTileAtWorldXY - * @since 3.0.0 - * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {integer} worldX - [description] - * @param {integer} worldY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera] - [description] - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - putTileAtWorldXY: function (tile, worldX, worldY, recalculateFaces, camera) - { - return TilemapComponents.PutTileAtWorldXY(tile, worldX, worldY, recalculateFaces, camera, this.layer); - }, - - /** - * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified - * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, - * all attributes will be copied over to the specified location. If you pass in an index, only the - * index at the specified location will be changed. Collision information will be recalculated - * within the region tiles were changed. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#putTilesAt - * @since 3.0.0 - * - * @param {integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][]} tile - A row (array) or grid (2D array) of Tiles - * or tile indexes to place. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - putTilesAt: function (tilesArray, tileX, tileY, recalculateFaces) - { - TilemapComponents.PutTilesAt(tilesArray, tileX, tileY, recalculateFaces, this.layer); - - return this; - }, - - /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then - * those will be used for randomly assigning new tile indexes. If an array is not provided, the - * indexes found within the region (excluding -1) will be used for randomly assigning new tile - * indexes. This method only modifies tile indexes and does not change collision information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#randomize - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - randomize: function (tileX, tileY, width, height, indexes) - { - TilemapComponents.Randomize(tileX, tileY, width, height, indexes, this.layer); - - return this; - }, - - /** - * Removes the tile at the given tile coordinates in the specified layer and updates the layer's - * collision information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#removeTileAt - * @since 3.0.0 - * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - removeTileAt: function (tileX, tileY, replaceWithNull, recalculateFaces) - { - return TilemapComponents.RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, this.layer); - }, - - /** - * Removes the tile at the given world coordinates in the specified layer and updates the layer's - * collision information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#removeTileAtWorldXY - * @since 3.0.0 - * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - removeTileAtWorldXY: function (worldX, worldY, replaceWithNull, recalculateFaces, camera) - { - return TilemapComponents.RemoveTileAtWorldXY(worldX, worldY, replaceWithNull, recalculateFaces, camera, this.layer); - }, - - /** - * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to - * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles - * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation - * wherever you want on the screen. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#renderDebug - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. - * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. - * @param {Color|null} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at - * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. - * @param {Color|null} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled - * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. - * @param {Color|null} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting - * tile faces. If set to null, interesting tile faces will not be drawn. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - renderDebug: function (graphics, styleConfig) - { - TilemapComponents.RenderDebug(graphics, styleConfig, this.layer); - - return this; - }, - - /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does - * not change collision information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#replaceByIndex - * @since 3.0.0 - * - * @param {integer} findIndex - [description] - * @param {integer} newIndex - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - replaceByIndex: function (findIndex, newIndex, tileX, tileY, width, height) - { - TilemapComponents.ReplaceByIndex(findIndex, newIndex, tileX, tileY, width, height, this.layer); - - return this; - }, - - /** - * Sets collision on the given tile or tiles within a layer by index. You can pass in either a - * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if - * collision will be enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollision - * @since 3.0.0 - * - * @param {integer|array} indexes - Either a single tile index, or an array of tile indexes. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setCollision: function (indexes, collides, recalculateFaces) - { - TilemapComponents.SetCollision(indexes, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on a range of tiles in a layer whose index is between the specified `start` and - * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set - * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be - * enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionBetween - * @since 3.0.0 - * - * @param {integer} start - The first index of the tile to be set for collision. - * @param {integer} stop - The last index of the tile to be set for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setCollisionBetween: function (start, stop, collides, recalculateFaces) - { - TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property - * that matches the given properties object, its collision flag will be set. The `collides` - * parameter controls if collision will be enabled (true) or disabled (false). Passing in - * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that - * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can - * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a - * "types" property that matches any of those values, its collision flag will be updated. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionByProperty - * @since 3.0.0 - * - * @param {object} properties - An object with tile properties and corresponding values that should - * be checked. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setCollisionByProperty: function (properties, collides, recalculateFaces) - { - TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on all tiles in the given layer, except for tiles that have an index specified in - * the given array. The `collides` parameter controls if collision will be enabled (true) or - * disabled (false). - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionByExclusion - * @since 3.0.0 - * - * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setCollisionByExclusion: function (indexes, collides, recalculateFaces) - { - TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking each tiles collision group data - * (typically defined in Tiled within the tileset collision editor). If any objects are found within - * a tiles collision group, the tile's colliding information will be set. The `collides` parameter - * controls if collision will be enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionFromCollisionGroup - * @since 3.0.0 - * - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setCollisionFromCollisionGroup: function (collides, recalculateFaces) - { - TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets a global collision callback for the given tile index within the layer. This will affect all - * tiles on this layer that have the same index. If a callback is already set for the tile index it - * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile - * at a specific location on the map then see setTileLocationCallback. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setTileIndexCallback - * @since 3.0.0 - * - * @param {integer|array} indexes - Either a single tile index, or an array of tile indexes to have a - * collision callback set for. - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setTileIndexCallback: function (indexes, callback, callbackContext) - { - TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, this.layer); - - return this; - }, - - /** - * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. - * If a callback is already set for the tile index it will be replaced. Set the callback to null to - * remove it. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setTileLocationCallback - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext) - { - TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, this.layer); - - return this; - }, - - /** - * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given - * layer. It will only randomize the tiles in that area, so if they're all the same nothing will - * appear to have changed! This method only modifies tile indexes and does not change collision - * information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#shuffle - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - shuffle: function (tileX, tileY, width, height) - { - TilemapComponents.Shuffle(tileX, tileY, width, height, this.layer); - - return this; - }, - - /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision - * information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#swapByIndex - * @since 3.0.0 - * - * @param {integer} tileA - First tile index. - * @param {integer} tileB - Second tile index. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - swapByIndex: function (indexA, indexB, tileX, tileY, width, height) - { - TilemapComponents.SwapByIndex(indexA, indexB, tileX, tileY, width, height, this.layer); - - return this; - }, - - /** - * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldX - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - tileToWorldX: function (tileX, camera) - { - return TilemapComponents.TileToWorldX(tileX, camera, this.layer); - }, - - /** - * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldY - * @since 3.0.0 - * - * @param {integer} tileY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - tileToWorldY: function (tileY, camera) - { - return TilemapComponents.TileToWorldY(tileY, camera, this.layer); - }, - - /** - * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldXY - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Math.Vector2} - */ - tileToWorldXY: function (tileX, tileY, point, camera) - { - return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, this.layer); - }, - - /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will recieve a new index. New indexes are drawn from the given - * weightedIndexes array. An example weighted array: - * - * [ - * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 - * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 - * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 - * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 - * ] - * - * The probability of any index being choose is (the index's weight) / (sum of all weights). This - * method only modifies tile indexes and does not change collision information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#weightedRandomize - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during - * randomization. They should be in the form: { index: 0, weight: 4 } or - * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - weightedRandomize: function (tileX, tileY, width, height, weightedIndexes) - { - TilemapComponents.WeightedRandomize(tileX, tileY, width, height, weightedIndexes, this.layer); - - return this; - }, - - /** - * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileX - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - worldToTileX: function (worldX, snapToFloor, camera) - { - return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, this.layer); - }, - - /** - * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileXY - * @since 3.0.0 - * - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - worldToTileY: function (worldY, snapToFloor, camera) - { - return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, this.layer); - }, - - /** - * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Math.Vector2} - */ - worldToTileXY: function (worldX, worldY, snapToFloor, point, camera) - { - return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, this.layer); - } - -}); - -module.exports = DynamicTilemapLayer; +module.exports = TopRight; /***/ }), @@ -68477,1023 +72080,36 @@ module.exports = DynamicTilemapLayer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var CONST = __webpack_require__(19); -var GameObject = __webpack_require__(1); -var StaticTilemapLayerRender = __webpack_require__(917); -var TilemapComponents = __webpack_require__(96); -var Utils = __webpack_require__(41); +var GetLeft = __webpack_require__(34); +var GetTop = __webpack_require__(30); +var SetLeft = __webpack_require__(33); +var SetTop = __webpack_require__(29); /** - * @classdesc - * A StaticTilemapLayer is a game object that renders LayerData from a Tilemap. A - * StaticTilemapLayer can only render tiles from a single tileset. + * Takes given Game Object and aligns it so that it is positioned in the top left of the other. * - * A StaticTilemapLayer is optimized for speed over flexibility. You cannot apply per-tile - * effects like tint or alpha. You cannot change the tiles in a StaticTilemapLayer. Use this - * over a DynamicTilemapLayer when you don't need either of those features. - * - * @class StaticTilemapLayer - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.Tilemaps - * @constructor + * @function Phaser.Display.Align.In.TopLeft * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * @extends Phaser.GameObjects.Components.ScrollFactor * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.Tilemaps.Tilemap} tilemap - The Tilemap this layer is a part of. - * @param {integer} layerIndex - The index of the LayerData associated with this layer. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset used to render the tiles in this layer. - * @param {number} [x=0] - The world x position where the top left of this layer will be placed. - * @param {number} [y=0] - The world y position where the top left of this layer will be placed. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. */ -var StaticTilemapLayer = new Class({ +var TopLeft = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } - Extends: GameObject, + SetLeft(gameObject, GetLeft(alignIn) - offsetX); + SetTop(gameObject, GetTop(alignIn) - offsetY); - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.Size, - Components.Transform, - Components.Visible, - Components.ScrollFactor, - StaticTilemapLayerRender - ], + return gameObject; +}; - initialize: - - function StaticTilemapLayer (scene, tilemap, layerIndex, tileset, x, y) - { - GameObject.call(this, scene, 'StaticTilemapLayer'); - - /** - * Used internally by physics system to perform fast type checks. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#isTilemap - * @type {boolean} - * @readOnly - * @since 3.0.0 - */ - this.isTilemap = true; - - /** - * The Tilemap that this layer is a part of. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#tilemap - * @type {Phaser.Tilemaps.Tilemap} - * @since 3.0.0 - */ - this.tilemap = tilemap; - - /** - * The index of the LayerData associated with this layer. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#layerIndex - * @type {integer} - * @since 3.0.0 - */ - this.layerIndex = layerIndex; - - /** - * The LayerData associated with this layer. LayerData can only be associated with one - * tilemap layer. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#layer - * @type {Phaser.Tilemaps.LayerData} - * @since 3.0.0 - */ - this.layer = tilemap.layers[layerIndex]; - - this.layer.tilemapLayer = this; // Link the LayerData with this static tilemap layer - - /** - * The Tileset associated with this layer. A tilemap layer can only render from one Tileset. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#tileset - * @type {Phaser.Tilemaps.Tileset} - * @since 3.0.0 - */ - this.tileset = tileset; - - /** - * Used internally with the canvas render. This holds the tiles that are visible within the - * camera. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#culledTiles - * @type {array} - * @since 3.0.0 - */ - this.culledTiles = []; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#vertexBuffer - * @type {array} - * @private - * @since 3.0.0 - */ - this.vertexBuffer = null; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#renderer - * @type {Phaser.Renderer.CanvasRenderer|Phaser.Renderer.WebGLRenderer} - * @private - * @since 3.0.0 - */ - this.renderer = scene.sys.game.renderer; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#bufferData - * @type {ArrayBuffer} - * @private - * @since 3.0.0 - */ - this.bufferData = null; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#vertexViewF32 - * @type {Float32Array} - * @private - * @since 3.0.0 - */ - this.vertexViewF32 = null; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#vertexViewU32 - * @type {Uint32Array} - * @private - * @since 3.0.0 - */ - this.vertexViewU32 = null; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#dirty - * @type {boolean} - * @private - * @since 3.0.0 - */ - this.dirty = true; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#vertexCount - * @type {integer} - * @private - * @since 3.0.0 - */ - this.vertexCount = 0; - - this.setAlpha(this.layer.alpha); - this.setPosition(x, y); - this.setOrigin(); - this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height); - - this.initPipeline('TextureTintPipeline'); - - if (scene.sys.game.config.renderType === CONST.WEBGL) - { - scene.sys.game.renderer.onContextRestored(function () - { - this.dirty = true; - this.vertexBuffer = null; - }, this); - } - }, - - /** - * Upload the tile data to a VBO. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#upload - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to render to. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - upload: function (camera) - { - var tileset = this.tileset; - var mapWidth = this.layer.width; - var mapHeight = this.layer.height; - var width = tileset.image.get().width; - var height = tileset.image.get().height; - var mapData = this.layer.data; - var renderer = this.renderer; - var tile; - var row; - var col; - var texCoords; - - if (renderer.gl) - { - var pipeline = renderer.pipelines.TextureTintPipeline; - - if (this.dirty) - { - var gl = renderer.gl; - var vertexBuffer = this.vertexBuffer; - var bufferData = this.bufferData; - var voffset = 0; - var vertexCount = 0; - var bufferSize = (mapWidth * mapHeight) * pipeline.vertexSize * 6; - - if (bufferData === null) - { - bufferData = new ArrayBuffer(bufferSize); - this.bufferData = bufferData; - this.vertexViewF32 = new Float32Array(bufferData); - this.vertexViewU32 = new Uint32Array(bufferData); - } - - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - - for (row = 0; row < mapHeight; ++row) - { - for (col = 0; col < mapWidth; ++col) - { - tile = mapData[row][col]; - if (tile === null || tile.index === -1) { continue; } - - var tx = tile.pixelX; - var ty = tile.pixelY; - var txw = tx + tile.width; - var tyh = ty + tile.height; - - texCoords = tileset.getTileTextureCoordinates(tile.index); - if (texCoords === null) { continue; } - - var u0 = texCoords.x / width; - var v0 = texCoords.y / height; - var u1 = (texCoords.x + tile.width) / width; - var v1 = (texCoords.y + tile.height) / height; - - var tx0 = tx; - var ty0 = ty; - var tx1 = tx; - var ty1 = tyh; - var tx2 = txw; - var ty2 = tyh; - var tx3 = txw; - var ty3 = ty; - var tint = Utils.getTintAppendFloatAlpha(0xffffff, this.alpha * tile.alpha); - - vertexViewF32[voffset + 0] = tx0; - vertexViewF32[voffset + 1] = ty0; - vertexViewF32[voffset + 2] = u0; - vertexViewF32[voffset + 3] = v0; - vertexViewU32[voffset + 4] = tint; - vertexViewF32[voffset + 5] = tx1; - vertexViewF32[voffset + 6] = ty1; - vertexViewF32[voffset + 7] = u0; - vertexViewF32[voffset + 8] = v1; - vertexViewU32[voffset + 9] = tint; - vertexViewF32[voffset + 10] = tx2; - vertexViewF32[voffset + 11] = ty2; - vertexViewF32[voffset + 12] = u1; - vertexViewF32[voffset + 13] = v1; - vertexViewU32[voffset + 14] = tint; - vertexViewF32[voffset + 15] = tx0; - vertexViewF32[voffset + 16] = ty0; - vertexViewF32[voffset + 17] = u0; - vertexViewF32[voffset + 18] = v0; - vertexViewU32[voffset + 19] = tint; - vertexViewF32[voffset + 20] = tx2; - vertexViewF32[voffset + 21] = ty2; - vertexViewF32[voffset + 22] = u1; - vertexViewF32[voffset + 23] = v1; - vertexViewU32[voffset + 24] = tint; - vertexViewF32[voffset + 25] = tx3; - vertexViewF32[voffset + 26] = ty3; - vertexViewF32[voffset + 27] = u1; - vertexViewF32[voffset + 28] = v0; - vertexViewU32[voffset + 29] = tint; - - voffset += 30; - vertexCount += 6; - } - } - - this.vertexCount = vertexCount; - this.dirty = false; - if (vertexBuffer === null) - { - vertexBuffer = renderer.createVertexBuffer(bufferData, gl.STATIC_DRAW); - this.vertexBuffer = vertexBuffer; - } - else - { - renderer.setVertexBuffer(vertexBuffer); - gl.bufferSubData(gl.ARRAY_BUFFER, 0, bufferData); - } - } - - pipeline.modelIdentity(); - pipeline.modelTranslate(this.x - (camera.scrollX * this.scrollFactorX), this.y - (camera.scrollY * this.scrollFactorY), 0.0); - pipeline.modelScale(this.scaleX, this.scaleY, 1.0); - pipeline.viewLoad2D(camera.matrix.matrix); - } - - return this; - }, - - /** - * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting - * faces are used internally for optimizing collisions against tiles. This method is mostly used - * internally to optimize recalculating faces when only one tile has been changed. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#calculateFacesAt - * @since 3.0.0 - * - * @param {integer} tileX - The x coordinate. - * @param {integer} tileY - The y coordinate. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - calculateFacesAt: function (tileX, tileY) - { - TilemapComponents.CalculateFacesAt(tileX, tileY, this.layer); - - return this; - }, - - /** - * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the - * layer. Interesting faces are used internally for optimizing collisions against tiles. This method - * is mostly used internally. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#calculateFacesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - calculateFacesWithin: function (tileX, tileY, width, height) - { - TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, this.layer); - - return this; - }, - - /** - * Creates a Sprite for every object matching the given tile indexes in the layer. You can - * optionally specify if each tile will be replaced with a new tile after the Sprite has been - * created. This is useful if you want to lay down special tiles in a level that are converted to - * Sprites, but want to replace the tile itself with a floor tile or similar once converted. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#createFromTiles - * @since 3.0.0 - * - * @param {integer|array} indexes - The tile index, or array of indexes, to create Sprites from. - * @param {integer|array} replacements - The tile index, or array of indexes, to change a converted - * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a - * one-to-one mapping with the indexes array. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). - * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY - * - * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. - */ - createFromTiles: function (indexes, replacements, spriteConfig, scene, camera) - { - return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, this.layer); - }, - - /** - * Returns the tiles in the given layer that are within the cameras viewport. - * This is used internally. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#cull - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - cull: function (camera) - { - return TilemapComponents.CullTiles(this.layer, camera, this.culledTiles); - }, - - /** - * Destroys this StaticTilemapLayer and removes its link to the associated LayerData. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#destroy - * @since 3.0.0 - */ - destroy: function () - { - // Uninstall this layer only if it is still installed on the LayerData object - if (this.layer.tilemapLayer === this) - { - this.layer.tilemapLayer = undefined; - } - - this.tilemap = undefined; - this.layer = undefined; - this.tileset = undefined; - - GameObject.prototype.destroy.call(this); - }, - - /** - * Searches the entire map layer for the first tile matching the given index, then returns that Tile - * object. If no match is found, it returns null. The search starts from the top-left tile and - * continues horizontally until it hits the end of the row, then it drops down to the next column. - * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to - * the top-left. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#findByIndex - * @since 3.0.0 - * - * @param {integer} index - The tile index value to search for. - * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. - * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the - * bottom-right. Otherwise it scans from the top-left. - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - findByIndex: function (findIndex, skip, reverse) - { - return TilemapComponents.FindByIndex(findIndex, skip, reverse, this.layer); - }, - - /** - * Find the first tile in the given rectangular area (in tile coordinates) of the layer that - * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns - * true. Similar to Array.prototype.find in vanilla JS. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#findTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.Tile|null} - */ - findTile: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns - * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#filterTiles - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. The callback should return true for tiles that pass the - * filter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * callback. Similar to Array.prototype.forEach in vanilla JS. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#forEachTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - - return this; - }, - - /** - * Gets a tile at the given tile coordinates from the given layer. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#getTileAt - * @since 3.0.0 - * - * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). - * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). - * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile - * object with an index of -1. - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates were invalid. - */ - getTileAt: function (tileX, tileY, nonNull) - { - return TilemapComponents.GetTileAt(tileX, tileY, nonNull, this.layer); - }, - - /** - * Gets a tile at the given world coordinates from the given layer. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#getTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - X position to get the tile from (given in pixels) - * @param {number} worldY - Y position to get the tile from (given in pixels) - * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates - * were invalid. - */ - getTileAtWorldXY: function (worldX, worldY, nonNull, camera) - { - return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, this.layer); - }, - - /** - * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithin: function (tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * Gets the tiles in the given rectangular area (in world coordinates) of the layer. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithinWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera) - { - return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, this.layer); - }, - - /** - * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, - * Line, Rectangle or Triangle. The shape should be in world coordinates. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithinShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle} shape - A shape in world (pixel) coordinates - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithinShape: function (shape, filteringOptions, camera) - { - return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, this.layer); - }, - - /** - * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#hasTileAt - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * - * @return {boolean} - */ - hasTileAt: function (tileX, tileY) - { - return TilemapComponents.HasTileAt(tileX, tileY, this.layer); - }, - - /** - * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#hasTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {boolean} - */ - hasTileAtWorldXY: function (worldX, worldY, camera) - { - return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, this.layer); - }, - - /** - * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to - * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles - * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation - * wherever you want on the screen. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#renderDebug - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. - * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. - * @param {Color|null} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at - * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. - * @param {Color|null} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled - * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. - * @param {Color|null} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting - * tile faces. If set to null, interesting tile faces will not be drawn. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - renderDebug: function (graphics, styleConfig) - { - TilemapComponents.RenderDebug(graphics, styleConfig, this.layer); - - return this; - }, - - /** - * Sets collision on the given tile or tiles within a layer by index. You can pass in either a - * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if - * collision will be enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setCollision - * @since 3.0.0 - * - * @param {integer|array} indexes - Either a single tile index, or an array of tile indexes. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setCollision: function (indexes, collides, recalculateFaces) - { - TilemapComponents.SetCollision(indexes, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on a range of tiles in a layer whose index is between the specified `start` and - * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set - * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be - * enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionBetween - * @since 3.0.0 - * - * @param {integer} start - The first index of the tile to be set for collision. - * @param {integer} stop - The last index of the tile to be set for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setCollisionBetween: function (start, stop, collides, recalculateFaces) - { - TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property - * that matches the given properties object, its collision flag will be set. The `collides` - * parameter controls if collision will be enabled (true) or disabled (false). Passing in - * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that - * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can - * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a - * "types" property that matches any of those values, its collision flag will be updated. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionByProperty - * @since 3.0.0 - * - * @param {object} properties - An object with tile properties and corresponding values that should - * be checked. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setCollisionByProperty: function (properties, collides, recalculateFaces) - { - TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on all tiles in the given layer, except for tiles that have an index specified in - * the given array. The `collides` parameter controls if collision will be enabled (true) or - * disabled (false). - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionByExclusion - * @since 3.0.0 - * - * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setCollisionByExclusion: function (indexes, collides, recalculateFaces) - { - TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets a global collision callback for the given tile index within the layer. This will affect all - * tiles on this layer that have the same index. If a callback is already set for the tile index it - * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile - * at a specific location on the map then see setTileLocationCallback. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setTileIndexCallback - * @since 3.0.0 - * - * @param {integer|array} indexes - Either a single tile index, or an array of tile indexes to have a - * collision callback set for. - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setTileIndexCallback: function (indexes, callback, callbackContext) - { - TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, this.layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking each tiles collision group data - * (typically defined in Tiled within the tileset collision editor). If any objects are found within - * a tiles collision group, the tile's colliding information will be set. The `collides` parameter - * controls if collision will be enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionFromCollisionGroup - * @since 3.0.0 - * - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setCollisionFromCollisionGroup: function (collides, recalculateFaces) - { - TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. - * If a callback is already set for the tile index it will be replaced. Set the callback to null to - * remove it. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setTileLocationCallback - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext) - { - TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, this.layer); - - return this; - }, - - /** - * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldX - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - tileToWorldX: function (tileX, camera) - { - return TilemapComponents.TileToWorldX(tileX, camera, this.layer); - }, - - /** - * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldY - * @since 3.0.0 - * - * @param {integer} tileY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - tileToWorldY: function (tileY, camera) - { - return TilemapComponents.TileToWorldY(tileY, camera, this.layer); - }, - - /** - * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldXY - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Math.Vector2} - */ - tileToWorldXY: function (tileX, tileY, point, camera) - { - return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, this.layer); - }, - - /** - * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileX - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - worldToTileX: function (worldX, snapToFloor, camera) - { - return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, this.layer); - }, - - /** - * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileXY - * @since 3.0.0 - * - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - worldToTileY: function (worldY, snapToFloor, camera) - { - return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, this.layer); - }, - - /** - * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Math.Vector2} - */ - worldToTileXY: function (worldX, worldY, snapToFloor, point, camera) - { - return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, this.layer); - } - -}); - -module.exports = StaticTilemapLayer; +module.exports = TopLeft; /***/ }), @@ -69506,297 +72122,36 @@ module.exports = StaticTilemapLayer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(2); +var GetCenterX = __webpack_require__(61); +var GetTop = __webpack_require__(30); +var SetCenterX = __webpack_require__(60); +var SetTop = __webpack_require__(29); /** - * @classdesc - * [description] + * Takes given Game Object and aligns it so that it is positioned in the top center of the other. * - * @class TimerEvent - * @memberOf Phaser.Time - * @constructor + * @function Phaser.Display.Align.In.TopCenter * @since 3.0.0 * - * @param {object} config - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. */ -var TimerEvent = new Class({ +var TopCenter = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } - initialize: + SetCenterX(gameObject, GetCenterX(alignIn) + offsetX); + SetTop(gameObject, GetTop(alignIn) - offsetY); - function TimerEvent (config) - { - /** - * The delay in ms at which this TimerEvent fires. - * - * @name Phaser.Time.TimerEvent#delay - * @type {number} - * @default 0 - * @readOnly - * @since 3.0.0 - */ - this.delay = 0; + return gameObject; +}; - /** - * The total number of times this TimerEvent will repeat before finishing. - * - * @name Phaser.Time.TimerEvent#repeat - * @type {number} - * @default 0 - * @readOnly - * @since 3.0.0 - */ - this.repeat = 0; - - /** - * If repeating this contains the current repeat count. - * - * @name Phaser.Time.TimerEvent#repeatCount - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.repeatCount = 0; - - /** - * True if this TimerEvent loops, otherwise false. - * - * @name Phaser.Time.TimerEvent#loop - * @type {boolean} - * @default false - * @readOnly - * @since 3.0.0 - */ - this.loop = false; - - /** - * The callback that will be called when the TimerEvent occurs. - * - * @name Phaser.Time.TimerEvent#callback - * @type {function} - * @since 3.0.0 - */ - this.callback; - - /** - * The scope in which the callback will be called. - * - * @name Phaser.Time.TimerEvent#callbackScope - * @type {object} - * @since 3.0.0 - */ - this.callbackScope; - - /** - * Additional arguments to be passed to the callback. - * - * @name Phaser.Time.TimerEvent#args - * @type {array} - * @since 3.0.0 - */ - this.args; - - /** - * Scale the time causing this TimerEvent to update. - * - * @name Phaser.Time.TimerEvent#timeScale - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * Start this many MS into the elapsed (useful if you want a long duration with repeat, but for the first loop to fire quickly) - * - * @name Phaser.Time.TimerEvent#startAt - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.startAt = 0; - - /** - * [description] - * - * @name Phaser.Time.TimerEvent#elapsed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.elapsed = 0; - - /** - * [description] - * - * @name Phaser.Time.TimerEvent#paused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.paused = false; - - /** - * [description] - * - * @name Phaser.Time.TimerEvent#hasDispatched - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.hasDispatched = false; - - this.reset(config); - }, - - /** - * [description] - * - * @method Phaser.Time.TimerEvent#reset - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.Time.TimerEvent} This TimerEvent object. - */ - reset: function (config) - { - this.delay = GetFastValue(config, 'delay', 0); - - // Can also be set to -1 for an infinite loop (same as setting loop: true) - this.repeat = GetFastValue(config, 'repeat', 0); - - this.loop = GetFastValue(config, 'loop', false); - - this.callback = GetFastValue(config, 'callback', undefined); - - this.callbackScope = GetFastValue(config, 'callbackScope', this.callback); - - this.args = GetFastValue(config, 'args', []); - - this.timeScale = GetFastValue(config, 'timeScale', 1); - - this.startAt = GetFastValue(config, 'startAt', 0); - - this.paused = GetFastValue(config, 'paused', false); - - this.elapsed = this.startAt; - this.hasDispatched = false; - this.repeatCount = (this.repeat === -1 || this.loop) ? 999999999999 : this.repeat; - - return this; - }, - - /** - * Gets the progress of the current iteration, not factoring in repeats. - * - * @method Phaser.Time.TimerEvent#getProgress - * @since 3.0.0 - * - * @return {number} [description] - */ - getProgress: function () - { - return (this.elapsed / this.delay); - }, - - /** - * Gets the progress of the timer overall, factoring in repeats. - * - * @method Phaser.Time.TimerEvent#getOverallProgress - * @since 3.0.0 - * - * @return {number} [description] - */ - getOverallProgress: function () - { - if (this.repeat > 0) - { - var totalDuration = this.delay + (this.delay * this.repeat); - var totalElapsed = this.elapsed + (this.delay * (this.repeat - this.repeatCount)); - - return (totalElapsed / totalDuration); - } - else - { - return this.getProgress(); - } - }, - - /** - * [description] - * - * @method Phaser.Time.TimerEvent#getRepeatCount - * @since 3.0.0 - * - * @return {number} [description] - */ - getRepeatCount: function () - { - return this.repeatCount; - }, - - /** - * [description] - * - * @method Phaser.Time.TimerEvent#getElapsed - * @since 3.0.0 - * - * @return {number} [description] - */ - getElapsed: function () - { - return this.elapsed; - }, - - /** - * [description] - * - * @method Phaser.Time.TimerEvent#getElapsedSeconds - * @since 3.0.0 - * - * @return {number} [description] - */ - getElapsedSeconds: function () - { - return this.elapsed * 0.001; - }, - - /** - * [description] - * - * @method Phaser.Time.TimerEvent#remove - * @since 3.0.0 - * - * @param {function} dispatchCallback - [description] - */ - remove: function (dispatchCallback) - { - if (dispatchCallback === undefined) { dispatchCallback = false; } - - this.elapsed = this.delay; - - this.hasDispatched = !dispatchCallback; - - this.repeatCount = 0; - }, - - /** - * [description] - * - * @method Phaser.Time.TimerEvent#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.callback = undefined; - this.callbackScope = undefined; - this.args = []; - } - -}); - -module.exports = TimerEvent; +module.exports = TopCenter; /***/ }), @@ -69809,52 +72164,36 @@ module.exports = TimerEvent; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RESERVED = __webpack_require__(926); +var GetCenterY = __webpack_require__(58); +var GetRight = __webpack_require__(32); +var SetCenterY = __webpack_require__(59); +var SetRight = __webpack_require__(31); /** - * [description] + * Takes given Game Object and aligns it so that it is positioned in the right center of the other. * - * @function Phaser.Tweens.Builders.GetProps + * @function Phaser.Display.Align.In.RightCenter * @since 3.0.0 * - * @param {object} config - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. * - * @return {array} [description] + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. */ -var GetProps = function (config) +var RightCenter = function (gameObject, alignIn, offsetX, offsetY) { - var key; - var keys = []; + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } - // First see if we have a props object + SetRight(gameObject, GetRight(alignIn) + offsetX); + SetCenterY(gameObject, GetCenterY(alignIn) + offsetY); - if (config.hasOwnProperty('props')) - { - for (key in config.props) - { - // Skip any property that starts with an underscore - if (key.substr(0, 1) !== '_') - { - keys.push({ key: key, value: config.props[key] }); - } - } - } - else - { - for (key in config) - { - // Skip any property that is in the ReservedProps list or that starts with an underscore - if (RESERVED.indexOf(key) === -1 && key.substr(0, 1) !== '_') - { - keys.push({ key: key, value: config[key] }); - } - } - } - - return keys; + return gameObject; }; -module.exports = GetProps; +module.exports = RightCenter; /***/ }), @@ -69867,40 +72206,36 @@ module.exports = GetProps; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetValue = __webpack_require__(4); +var GetCenterY = __webpack_require__(58); +var GetLeft = __webpack_require__(34); +var SetCenterY = __webpack_require__(59); +var SetLeft = __webpack_require__(33); /** - * [description] + * Takes given Game Object and aligns it so that it is positioned in the left center of the other. * - * @function Phaser.Tweens.Builders.GetTweens + * @function Phaser.Display.Align.In.LeftCenter * @since 3.0.0 * - * @param {object} config - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. * - * @return {array} [description] + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. */ -var GetTweens = function (config) +var LeftCenter = function (gameObject, alignIn, offsetX, offsetY) { - var tweens = GetValue(config, 'tweens', null); + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } - if (tweens === null) - { - return []; - } - else if (typeof tweens === 'function') - { - tweens = tweens.call(); - } + SetLeft(gameObject, GetLeft(alignIn) - offsetX); + SetCenterY(gameObject, GetCenterY(alignIn) + offsetY); - if (!Array.isArray(tweens)) - { - tweens = [ tweens ]; - } - - return tweens; + return gameObject; }; -module.exports = GetTweens; +module.exports = LeftCenter; /***/ }), @@ -69913,122 +72248,29 @@ module.exports = GetTweens; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Defaults = __webpack_require__(160); -var GetAdvancedValue = __webpack_require__(10); -var GetBoolean = __webpack_require__(73); -var GetEaseFunction = __webpack_require__(71); -var GetNewValue = __webpack_require__(101); -var GetValue = __webpack_require__(4); -var GetValueOp = __webpack_require__(159); -var Tween = __webpack_require__(161); -var TweenData = __webpack_require__(162); +var SetCenterX = __webpack_require__(60); +var SetCenterY = __webpack_require__(59); /** - * [description] + * Positions the Game Object so that it is centered on the given coordinates. * - * @function Phaser.Tweens.Builders.NumberTweenBuilder + * @function Phaser.Display.Bounds.CenterOn * @since 3.0.0 * - * @param {Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline} parent - [description] - * @param {object} config - [description] - * @param {Phaser.Tweens.Tween~ConfigDefaults} defaults - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} x - The horizontal coordinate to position the Game Object on. + * @param {number} y - The vertical coordinate to position the Game Object on. * - * @return {Phaser.Tweens.Tween} [description] + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. */ -var NumberTweenBuilder = function (parent, config, defaults) +var CenterOn = function (gameObject, x, y) { - if (defaults === undefined) - { - defaults = Defaults; - } + SetCenterX(gameObject, x); - // var tween = this.tweens.addCounter({ - // from: 100, - // to: 200, - // ... (normal tween properties) - // }) - // - // Then use it in your game via: - // - // tween.getValue() - - var from = GetValue(config, 'from', 0); - var to = GetValue(config, 'to', 1); - - var targets = [ { value: from } ]; - - var delay = GetNewValue(config, 'delay', defaults.delay); - var duration = GetNewValue(config, 'duration', defaults.duration); - var easeParams = GetValue(config, 'easeParams', defaults.easeParams); - var ease = GetEaseFunction(GetValue(config, 'ease', defaults.ease), easeParams); - var hold = GetNewValue(config, 'hold', defaults.hold); - var repeat = GetNewValue(config, 'repeat', defaults.repeat); - var repeatDelay = GetNewValue(config, 'repeatDelay', defaults.repeatDelay); - var yoyo = GetBoolean(config, 'yoyo', defaults.yoyo); - - var data = []; - - var ops = GetValueOp('value', to); - - var tweenData = TweenData( - targets[0], - 'value', - ops.getEnd, - ops.getStart, - ease, - delay, - duration, - yoyo, - hold, - repeat, - repeatDelay, - false, - false - ); - - tweenData.start = from; - tweenData.current = from; - tweenData.to = to; - - data.push(tweenData); - - var tween = new Tween(parent, data, targets); - - tween.offset = GetAdvancedValue(config, 'offset', null); - tween.completeDelay = GetAdvancedValue(config, 'completeDelay', 0); - tween.loop = Math.round(GetAdvancedValue(config, 'loop', 0)); - tween.loopDelay = Math.round(GetAdvancedValue(config, 'loopDelay', 0)); - tween.paused = GetBoolean(config, 'paused', false); - tween.useFrames = GetBoolean(config, 'useFrames', false); - - // Set the Callbacks - var scope = GetValue(config, 'callbackScope', tween); - - // Callback parameters: 0 = a reference to the Tween itself, 1 = the target/s of the Tween, ... your own params - var tweenArray = [ tween, null ]; - - var callbacks = Tween.TYPES; - - for (var i = 0; i < callbacks.length; i++) - { - var type = callbacks[i]; - - var callback = GetValue(config, type, false); - - if (callback) - { - var callbackScope = GetValue(config, type + 'Scope', scope); - var callbackParams = GetValue(config, type + 'Params', []); - - // The null is reset to be the Tween target - tween.setCallback(type, callback, tweenArray.concat(callbackParams), callbackScope); - } - } - - return tween; + return SetCenterY(gameObject, y); }; -module.exports = NumberTweenBuilder; +module.exports = CenterOn; /***/ }), @@ -70041,146 +72283,34 @@ module.exports = NumberTweenBuilder; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Clone = __webpack_require__(53); -var Defaults = __webpack_require__(160); -var GetAdvancedValue = __webpack_require__(10); -var GetBoolean = __webpack_require__(73); -var GetEaseFunction = __webpack_require__(71); -var GetNewValue = __webpack_require__(101); -var GetTargets = __webpack_require__(158); -var GetTweens = __webpack_require__(360); -var GetValue = __webpack_require__(4); -var Timeline = __webpack_require__(363); -var TweenBuilder = __webpack_require__(102); +var CenterOn = __webpack_require__(361); +var GetCenterX = __webpack_require__(61); +var GetCenterY = __webpack_require__(58); /** - * [description] + * Takes given Game Object and aligns it so that it is positioned in the center of the other. * - * @function Phaser.Tweens.Builders.TimelineBuilder + * @function Phaser.Display.Align.In.Center * @since 3.0.0 * - * @param {Phaser.Tweens.TweenManager} manager - [description] - * @param {object} config - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. * - * @return {Phaser.Tweens.Timeline} [description] + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. */ -var TimelineBuilder = function (manager, config) +var Center = function (gameObject, alignIn, offsetX, offsetY) { - var timeline = new Timeline(manager); + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } - var tweens = GetTweens(config); + CenterOn(gameObject, GetCenterX(alignIn) + offsetX, GetCenterY(alignIn) + offsetY); - if (tweens.length === 0) - { - timeline.paused = true; - - return timeline; - } - - var defaults = Clone(Defaults); - - defaults.targets = GetTargets(config); - - // totalDuration: If specified each tween in the Timeline is given an equal portion of the totalDuration - - var totalDuration = GetAdvancedValue(config, 'totalDuration', 0); - - if (totalDuration > 0) - { - defaults.duration = Math.floor(totalDuration / tweens.length); - } - else - { - defaults.duration = GetNewValue(config, 'duration', defaults.duration); - } - - defaults.delay = GetNewValue(config, 'delay', defaults.delay); - defaults.easeParams = GetValue(config, 'easeParams', defaults.easeParams); - defaults.ease = GetEaseFunction(GetValue(config, 'ease', defaults.ease), defaults.easeParams); - defaults.hold = GetNewValue(config, 'hold', defaults.hold); - defaults.repeat = GetNewValue(config, 'repeat', defaults.repeat); - defaults.repeatDelay = GetNewValue(config, 'repeatDelay', defaults.repeatDelay); - defaults.yoyo = GetBoolean(config, 'yoyo', defaults.yoyo); - defaults.flipX = GetBoolean(config, 'flipX', defaults.flipX); - defaults.flipY = GetBoolean(config, 'flipY', defaults.flipY); - - // Create the Tweens - for (var i = 0; i < tweens.length; i++) - { - timeline.queue(TweenBuilder(timeline, tweens[i], defaults)); - } - - timeline.completeDelay = GetAdvancedValue(config, 'completeDelay', 0); - timeline.loop = Math.round(GetAdvancedValue(config, 'loop', 0)); - timeline.loopDelay = Math.round(GetAdvancedValue(config, 'loopDelay', 0)); - timeline.paused = GetBoolean(config, 'paused', false); - timeline.useFrames = GetBoolean(config, 'useFrames', false); - - // Callbacks - - var scope = GetValue(config, 'callbackScope', timeline); - - var timelineArray = [ timeline ]; - - var onStart = GetValue(config, 'onStart', false); - - // The Start of the Timeline - if (onStart) - { - var onStartScope = GetValue(config, 'onStartScope', scope); - var onStartParams = GetValue(config, 'onStartParams', []); - - timeline.setCallback('onStart', onStart, timelineArray.concat(onStartParams), onStartScope); - } - - var onUpdate = GetValue(config, 'onUpdate', false); - - // Every time the Timeline updates (regardless which Tweens are running) - if (onUpdate) - { - var onUpdateScope = GetValue(config, 'onUpdateScope', scope); - var onUpdateParams = GetValue(config, 'onUpdateParams', []); - - timeline.setCallback('onUpdate', onUpdate, timelineArray.concat(onUpdateParams), onUpdateScope); - } - - var onLoop = GetValue(config, 'onLoop', false); - - // Called when the whole Timeline loops - if (onLoop) - { - var onLoopScope = GetValue(config, 'onLoopScope', scope); - var onLoopParams = GetValue(config, 'onLoopParams', []); - - timeline.setCallback('onLoop', onLoop, timelineArray.concat(onLoopParams), onLoopScope); - } - - var onYoyo = GetValue(config, 'onYoyo', false); - - // Called when a Timeline yoyos - if (onYoyo) - { - var onYoyoScope = GetValue(config, 'onYoyoScope', scope); - var onYoyoParams = GetValue(config, 'onYoyoParams', []); - - timeline.setCallback('onYoyo', onYoyo, timelineArray.concat(null, onYoyoParams), onYoyoScope); - } - - var onComplete = GetValue(config, 'onComplete', false); - - // Called when the Timeline completes, after the completeDelay, etc. - if (onComplete) - { - var onCompleteScope = GetValue(config, 'onCompleteScope', scope); - var onCompleteParams = GetValue(config, 'onCompleteParams', []); - - timeline.setCallback('onComplete', onComplete, timelineArray.concat(onCompleteParams), onCompleteScope); - } - - return timeline; + return gameObject; }; -module.exports = TimelineBuilder; +module.exports = Center; /***/ }), @@ -70193,853 +72323,41 @@ module.exports = TimelineBuilder; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(14); -var TweenBuilder = __webpack_require__(102); -var TWEEN_CONST = __webpack_require__(87); +var GetBottom = __webpack_require__(36); +var GetRight = __webpack_require__(32); +var SetBottom = __webpack_require__(35); +var SetRight = __webpack_require__(31); /** - * @classdesc - * [description] + * Takes given Game Object and aligns it so that it is positioned in the bottom right of the other. * - * @class Timeline - * @memberOf Phaser.Tweens - * @extends EventEmitter - * @constructor + * @function Phaser.Display.Align.In.BottomRight * @since 3.0.0 * - * @param {Phaser.Tweens.TweenManager} manager - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. */ -var Timeline = new Class({ +var BottomRight = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } - Extends: EventEmitter, + SetRight(gameObject, GetRight(alignIn) + offsetX); + SetBottom(gameObject, GetBottom(alignIn) + offsetY); - initialize: + return gameObject; +}; - function Timeline (manager) - { - EventEmitter.call(this); - - /** - * [description] - * - * @name Phaser.Tweens.Timeline#manager - * @type {Phaser.Tweens.TweenManager} - * @since 3.0.0 - */ - this.manager = manager; - - /** - * [description] - * - * @name Phaser.Tweens.Timeline#isTimeline - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.isTimeline = true; - - /** - * An array of Tween objects, each containing a unique property and target being tweened. - * - * @name Phaser.Tweens.Timeline#data - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.data = []; - - /** - * data array doesn't usually change, so we can cache the length - * - * @name Phaser.Tweens.Timeline#totalData - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalData = 0; - - /** - * If true then duration, delay, etc values are all frame totals. - * - * @name Phaser.Tweens.Timeline#useFrames - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.useFrames = false; - - /** - * Scales the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. - * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. - * - * @name Phaser.Tweens.Timeline#timeScale - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * Loop this tween? Can be -1 for an infinite loop, or an integer. - * When enabled it will play through ALL TweenDatas again (use TweenData.repeat to loop a single TD) - * - * @name Phaser.Tweens.Timeline#loop - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loop = 0; - - /** - * Time in ms/frames before the tween loops. - * - * @name Phaser.Tweens.Timeline#loopDelay - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loopDelay = 0; - - /** - * How many loops are left to run? - * - * @name Phaser.Tweens.Timeline#loopCounter - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loopCounter = 0; - - /** - * Time in ms/frames before the 'onComplete' event fires. This never fires if loop = true (as it never completes) - * - * @name Phaser.Tweens.Timeline#completeDelay - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.completeDelay = 0; - - /** - * Countdown timer (used by loopDelay and completeDelay) - * - * @name Phaser.Tweens.Timeline#countdown - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.countdown = 0; - - /** - * The current state of the tween - * - * @name Phaser.Tweens.Timeline#state - * @type {integer} - * @since 3.0.0 - */ - this.state = TWEEN_CONST.PENDING_ADD; - - /** - * The state of the tween when it was paused (used by Resume) - * - * @name Phaser.Tweens.Timeline#_pausedState - * @type {integer} - * @private - * @since 3.0.0 - */ - this._pausedState = TWEEN_CONST.PENDING_ADD; - - /** - * Does the Tween start off paused? (if so it needs to be started with Tween.play) - * - * @name Phaser.Tweens.Timeline#paused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.paused = false; - - /** - * Elapsed time in ms/frames of this run through the Tween. - * - * @name Phaser.Tweens.Timeline#elapsed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.elapsed = 0; - - /** - * Total elapsed time in ms/frames of the entire Tween, including looping. - * - * @name Phaser.Tweens.Timeline#totalElapsed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalElapsed = 0; - - /** - * Time in ms/frames for the whole Tween to play through once, excluding loop amounts and loop delays. - * - * @name Phaser.Tweens.Timeline#duration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.duration = 0; - - /** - * Value between 0 and 1. The amount through the Tween, excluding loops. - * - * @name Phaser.Tweens.Timeline#progress - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.progress = 0; - - /** - * Time in ms/frames for all Tweens to complete (including looping) - * - * @name Phaser.Tweens.Timeline#totalDuration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalDuration = 0; - - /** - * Value between 0 and 1. The amount through the entire Tween, including looping. - * - * @name Phaser.Tweens.Timeline#totalProgress - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalProgress = 0; - - this.callbacks = { - onComplete: null, - onLoop: null, - onStart: null, - onUpdate: null, - onYoyo: null - }; - - this.callbackScope; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#setTimeScale - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Tweens.Timeline} This Timeline object. - */ - setTimeScale: function (value) - { - this.timeScale = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#getTimeScale - * @since 3.0.0 - * - * @return {number} [description] - */ - getTimeScale: function () - { - return this.timeScale; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#isPlaying - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isPlaying: function () - { - return (this.state === TWEEN_CONST.ACTIVE); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#add - * @since 3.0.0 - * - * @param {[type]} config - [description] - * - * @return {Phaser.Tweens.Timeline} This Timeline object. - */ - add: function (config) - { - return this.queue(TweenBuilder(this, config)); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#queue - * @since 3.0.0 - * - * @param {[type]} tween - [description] - * - * @return {Phaser.Tweens.Timeline} This Timeline object. - */ - queue: function (tween) - { - if (!this.isPlaying()) - { - tween.parent = this; - tween.parentIsTimeline = true; - - this.data.push(tween); - - this.totalData = this.data.length; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#hasOffset - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * - * @return {boolean} [description] - */ - hasOffset: function (tween) - { - return (tween.offset !== null); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#isOffsetAbsolute - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {boolean} [description] - */ - isOffsetAbsolute: function (value) - { - return (typeof(value) === 'number'); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#isOffsetRelative - * @since 3.0.0 - * - * @param {string} value - [description] - * - * @return {boolean} [description] - */ - isOffsetRelative: function (value) - { - var t = typeof(value); - - if (t === 'string') - { - var op = value[0]; - - if (op === '-' || op === '+') - { - return true; - } - } - - return false; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#getRelativeOffset - * @since 3.0.0 - * - * @param {string} value - [description] - * @param {number} base - [description] - * - * @return {number} [description] - */ - getRelativeOffset: function (value, base) - { - var op = value[0]; - var num = parseFloat(value.substr(2)); - var result = base; - - switch (op) - { - case '+': - result += num; - break; - - case '-': - result -= num; - break; - } - - // Cannot ever be < 0 - return Math.max(0, result); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#calcDuration - * @since 3.0.0 - */ - calcDuration: function () - { - var prevEnd = 0; - var totalDuration = 0; - var offsetDuration = 0; - - for (var i = 0; i < this.totalData; i++) - { - var tween = this.data[i]; - - tween.init(); - - if (this.hasOffset(tween)) - { - if (this.isOffsetAbsolute(tween.offset)) - { - // An actual number, so it defines the start point from the beginning of the timeline - tween.calculatedOffset = tween.offset; - - if (tween.offset === 0) - { - offsetDuration = 0; - } - } - else if (this.isOffsetRelative(tween.offset)) - { - // A relative offset (i.e. '-=1000', so starts at 'offset' ms relative to the PREVIOUS Tweens ending time) - tween.calculatedOffset = this.getRelativeOffset(tween.offset, prevEnd); - } - } - else - { - // Sequential - tween.calculatedOffset = offsetDuration; - } - - prevEnd = tween.totalDuration + tween.calculatedOffset; - - totalDuration += tween.totalDuration; - offsetDuration += tween.totalDuration; - } - - // Excludes loop values - this.duration = totalDuration; - - this.loopCounter = (this.loop === -1) ? 999999999999 : this.loop; - - if (this.loopCounter > 0) - { - this.totalDuration = this.duration + this.completeDelay + ((this.duration + this.loopDelay) * this.loopCounter); - } - else - { - this.totalDuration = this.duration + this.completeDelay; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#init - * @since 3.0.0 - * - * @return {boolean} [description] - */ - init: function () - { - this.calcDuration(); - - this.progress = 0; - this.totalProgress = 0; - - if (this.paused) - { - this.state = TWEEN_CONST.PAUSED; - - return false; - } - else - { - return true; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#resetTweens - * @since 3.0.0 - * - * @param {boolean} resetFromLoop - [description] - */ - resetTweens: function (resetFromLoop) - { - for (var i = 0; i < this.totalData; i++) - { - var tween = this.data[i]; - - tween.play(resetFromLoop); - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#setCallback - * @since 3.0.0 - * - * @param {string} type - [description] - * @param {function} callback - [description] - * @param {array} [params] - [description] - * @param {object} [scope] - [description] - * - * @return {Phaser.Tweens.Timeline} This Timeline object. - */ - setCallback: function (type, callback, params, scope) - { - if (Timeline.TYPES.indexOf(type) !== -1) - { - this.callbacks[type] = { func: callback, scope: scope, params: params }; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#play - * @since 3.0.0 - */ - play: function () - { - if (this.state === TWEEN_CONST.ACTIVE) - { - return; - } - - if (this.paused) - { - this.paused = false; - - this.manager.makeActive(this); - - return; - } - else - { - this.resetTweens(false); - - this.state = TWEEN_CONST.ACTIVE; - } - - var onStart = this.callbacks.onStart; - - if (onStart) - { - onStart.func.apply(onStart.scope, onStart.params); - } - - this.emit('start', this); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#nextState - * @since 3.0.0 - */ - nextState: function () - { - if (this.loopCounter > 0) - { - // Reset the elapsed time - // TODO: Probably ought to be set to the remainder from elapsed - duration - // as the tweens nearly always over-run by a few ms due to rAf - - this.elapsed = 0; - this.progress = 0; - - this.loopCounter--; - - var onLoop = this.callbacks.onLoop; - - if (onLoop) - { - onLoop.func.apply(onLoop.scope, onLoop.params); - } - - this.emit('loop', this, this.loopCounter); - - this.resetTweens(true); - - if (this.loopDelay > 0) - { - this.countdown = this.loopDelay; - this.state = TWEEN_CONST.LOOP_DELAY; - } - else - { - this.state = TWEEN_CONST.ACTIVE; - } - } - else if (this.completeDelay > 0) - { - this.countdown = this.completeDelay; - this.state = TWEEN_CONST.COMPLETE_DELAY; - } - else - { - var onComplete = this.callbacks.onComplete; - - if (onComplete) - { - onComplete.func.apply(onComplete.scope, onComplete.params); - } - - this.emit('complete', this); - - this.state = TWEEN_CONST.PENDING_REMOVE; - } - }, - - /** - * Returns 'true' if this Timeline has finished and should be removed from the Tween Manager. - * Otherwise, returns false. - * - * @method Phaser.Tweens.Timeline#update - * @since 3.0.0 - * - * @param {number} timestamp - [description] - * @param {number} delta - [description] - * - * @return {boolean} Returns `true` if this Timeline has finished and should be removed from the Tween Manager. - */ - update: function (timestamp, delta) - { - if (this.state === TWEEN_CONST.PAUSED) - { - return; - } - - var rawDelta = delta; - - if (this.useFrames) - { - delta = 1 * this.manager.timeScale; - } - - delta *= this.timeScale; - - this.elapsed += delta; - this.progress = Math.min(this.elapsed / this.duration, 1); - - this.totalElapsed += delta; - this.totalProgress = Math.min(this.totalElapsed / this.totalDuration, 1); - - switch (this.state) - { - case TWEEN_CONST.ACTIVE: - - var stillRunning = this.totalData; - - for (var i = 0; i < this.totalData; i++) - { - var tween = this.data[i]; - - if (tween.update(timestamp, rawDelta)) - { - stillRunning--; - } - } - - var onUpdate = this.callbacks.onUpdate; - - if (onUpdate) - { - onUpdate.func.apply(onUpdate.scope, onUpdate.params); - } - - this.emit('update', this); - - // Anything still running? If not, we're done - if (stillRunning === 0) - { - this.nextState(); - } - - break; - - case TWEEN_CONST.LOOP_DELAY: - - this.countdown -= delta; - - if (this.countdown <= 0) - { - this.state = TWEEN_CONST.ACTIVE; - } - - break; - - case TWEEN_CONST.COMPLETE_DELAY: - - this.countdown -= delta; - - if (this.countdown <= 0) - { - var onComplete = this.callbacks.onComplete; - - if (onComplete) - { - onComplete.func.apply(onComplete.scope, onComplete.params); - } - - this.emit('complete', this); - - this.state = TWEEN_CONST.PENDING_REMOVE; - } - - break; - } - - return (this.state === TWEEN_CONST.PENDING_REMOVE); - }, - - /** - * Stops the Tween immediately, whatever stage of progress it is at and flags it for removal by the TweenManager. - * - * @method Phaser.Tweens.Timeline#stop - * @since 3.0.0 - */ - stop: function () - { - this.state = TWEEN_CONST.PENDING_REMOVE; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#pause - * @since 3.0.0 - * - * @return {Phaser.Tweens.Timeline} This Timeline object. - */ - pause: function () - { - if (this.state === TWEEN_CONST.PAUSED) - { - return; - } - - this.paused = true; - - this._pausedState = this.state; - - this.state = TWEEN_CONST.PAUSED; - - this.emit('pause', this); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#resume - * @since 3.0.0 - * - * @return {Phaser.Tweens.Timeline} This Timeline object. - */ - resume: function () - { - if (this.state === TWEEN_CONST.PAUSED) - { - this.paused = false; - - this.state = this._pausedState; - } - - this.emit('resume', this); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#hasTarget - * @since 3.0.0 - * - * @param {object} target - [description] - * - * @return {boolean} [description] - */ - hasTarget: function (target) - { - for (var i = 0; i < this.data.length; i++) - { - if (this.data[i].hasTarget(target)) - { - return true; - } - } - - return false; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#destroy - * @since 3.0.0 - */ - destroy: function () - { - for (var i = 0; i < this.data.length; i++) - { - this.data[i].destroy(); - } - - } -}); - -Timeline.TYPES = [ 'onStart', 'onUpdate', 'onLoop', 'onComplete', 'onYoyo' ]; - -module.exports = Timeline; +module.exports = BottomRight; /***/ }), /* 364 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -71047,41 +72365,36 @@ module.exports = Timeline; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Based on code by Mike Reinstein +var GetBottom = __webpack_require__(36); +var GetLeft = __webpack_require__(34); +var SetBottom = __webpack_require__(35); +var SetLeft = __webpack_require__(33); /** - * Removes a single item from an array and returns it without creating gc (like the native splice does) + * Takes given Game Object and aligns it so that it is positioned in the bottom left of the other. * - * @function Phaser.Utils.Array.SpliceOne + * @function Phaser.Display.Align.In.BottomLeft * @since 3.0.0 * - * @param {array} array - [description] - * @param {integer} index - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. * - * @return {any} [description] + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. */ -var SpliceOne = function (array, index) +var BottomLeft = function (gameObject, alignIn, offsetX, offsetY) { - if (index >= array.length) - { - return; - } + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } - var len = array.length - 1; + SetLeft(gameObject, GetLeft(alignIn) - offsetX); + SetBottom(gameObject, GetBottom(alignIn) + offsetY); - var item = array[index]; - - for (var i = index; i < len; i++) - { - array[i] = array[i + 1]; - } - - array.length = len; - - return item; + return gameObject; }; -module.exports = SpliceOne; +module.exports = BottomLeft; /***/ }), @@ -71094,818 +72407,36 @@ module.exports = SpliceOne; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); +var GetBottom = __webpack_require__(36); +var GetCenterX = __webpack_require__(61); +var SetBottom = __webpack_require__(35); +var SetCenterX = __webpack_require__(60); /** - * @classdesc - * A Game Object Animation Controller. + * Takes given Game Object and aligns it so that it is positioned in the bottom center of the other. * - * This controller lives as an instance within a Game Object, accessible as `sprite.anims`. - * - * @class Animation - * @memberOf Phaser.GameObjects.Components - * @constructor + * @function Phaser.Display.Align.In.BottomCenter * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} parent - The Game Object to which this animation controller belongs. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. */ -var Animation = new Class({ +var BottomCenter = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } - initialize: + SetCenterX(gameObject, GetCenterX(alignIn) + offsetX); + SetBottom(gameObject, GetBottom(alignIn) + offsetY); - function Animation (parent) - { - /** - * The Game Object to which this animation controller belongs. - * - * @name Phaser.GameObjects.Components.Animation#parent - * @type {Phaser.GameObjects.GameObject} - * @since 3.0.0 - */ - this.parent = parent; + return gameObject; +}; - /** - * A reference to the global Animation Manager. - * - * @name Phaser.GameObjects.Components.Animation#animationManager - * @type {Phaser.Animations.AnimationManager} - * @since 3.0.0 - */ - this.animationManager = parent.scene.sys.anims; - - this.animationManager.once('remove', this.remove, this); - - /** - * Is an animation currently playing or not? - * - * @name Phaser.GameObjects.Components.Animation#isPlaying - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isPlaying = false; - - // Reference to the Phaser.Animation object - - /** - * The current Animation loaded into this Animation Controller. - * - * @name Phaser.GameObjects.Components.Animation#currentAnim - * @type {?Phaser.Animations.Animation} - * @default null - * @since 3.0.0 - */ - this.currentAnim = null; - - /** - * The current AnimationFrame being displayed by this Animation Controller. - * - * @name Phaser.GameObjects.Components.Animation#currentFrame - * @type {?Phaser.Animations.AnimationFrame} - * @default null - * @since 3.0.0 - */ - this.currentFrame = null; - - /** - * Time scale factor. - * - * @name Phaser.GameObjects.Components.Animation#_timeScale - * @type {number} - * @private - * @default 1 - * @since 3.0.0 - */ - this._timeScale = 1; - - /** - * The frame rate of playback in frames per second. - * The default is 24 if the `duration` property is `null`. - * - * @name Phaser.GameObjects.Components.Animation#frameRate - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.frameRate = 0; - - /** - * How long the animation should play for. - * If the `frameRate` property has been set then it overrides this value, - * otherwise frameRate is derived from `duration`. - * - * @name Phaser.GameObjects.Components.Animation#duration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.duration = 0; - - /** - * ms per frame, not including frame specific modifiers that may be present in the Animation data. - * - * @name Phaser.GameObjects.Components.Animation#msPerFrame - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.msPerFrame = 0; - - /** - * Skip frames if the time lags, or always advanced anyway? - * - * @name Phaser.GameObjects.Components.Animation#skipMissedFrames - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.skipMissedFrames = true; - - /** - * A delay before starting playback, in seconds. - * - * @name Phaser.GameObjects.Components.Animation#_delay - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._delay = 0; - - /** - * Number of times to repeat the animation (-1 for infinity) - * - * @name Phaser.GameObjects.Components.Animation#_repeat - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._repeat = 0; - - /** - * Delay before the repeat starts, in seconds. - * - * @name Phaser.GameObjects.Components.Animation#_repeatDelay - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._repeatDelay = 0; - - /** - * Should the animation yoyo? (reverse back down to the start) before repeating? - * - * @name Phaser.GameObjects.Components.Animation#_yoyo - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this._yoyo = false; - - /** - * Will the playhead move forwards (`true`) or in reverse (`false`) - * - * @name Phaser.GameObjects.Components.Animation#forward - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.forward = true; - - /** - * Internal time overflow accumulator. - * - * @name Phaser.GameObjects.Components.Animation#accumulator - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.accumulator = 0; - - /** - * The time point at which the next animation frame will change. - * - * @name Phaser.GameObjects.Components.Animation#nextTick - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.nextTick = 0; - - /** - * An internal counter keeping track of how many repeats are left to play. - * - * @name Phaser.GameObjects.Components.Animation#repeatCounter - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.repeatCounter = 0; - - /** - * An internal flag keeping track of pending repeats. - * - * @name Phaser.GameObjects.Components.Animation#pendingRepeat - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.pendingRepeat = false; - - /** - * Is the Animation paused? - * - * @name Phaser.GameObjects.Components.Animation#_paused - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this._paused = false; - - /** - * Was the animation previously playing before being paused? - * - * @name Phaser.GameObjects.Components.Animation#_wasPlaying - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this._wasPlaying = false; - - /** - * Container for the callback arguments. - * - * @name Phaser.GameObjects.Components.Animation#_callbackArgs - * @type {array} - * @private - * @since 3.0.0 - */ - this._callbackArgs = [ parent, null ]; - - /** - * Container for the update arguments. - * - * @name Phaser.GameObjects.Components.Animation#_updateParams - * @type {array} - * @private - * @since 3.0.0 - */ - this._updateParams = []; - }, - - /** - * Sets the amount of time, in seconds that the animation will be delayed before starting playback. - * - * @method Phaser.GameObjects.Components.Animation#delay - * @since 3.0.0 - * - * @param {number} value - The amount of time, in seconds, to wait before starting playback. - * - * @return {Phaser.GameObjects.GameObject} This Game Object. - */ - delay: function (value) - { - if (value === undefined) - { - return this._delay; - } - else - { - this._delay = value; - - return this; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#delayedPlay - * @since 3.0.0 - * - * @param {[type]} delay - [description] - * @param {[type]} key - [description] - * @param {[type]} startFrame - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object. - */ - delayedPlay: function (delay, key, startFrame) - { - this.play(key, true, startFrame); - - this.nextTick += (delay * 1000); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#getCurrentKey - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getCurrentKey: function () - { - if (this.currentAnim) - { - return this.currentAnim.key; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#load - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {integer} [startFrame=0] - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object. - */ - load: function (key, startFrame) - { - if (startFrame === undefined) { startFrame = 0; } - - if (this.isPlaying) - { - this.stop(); - } - - // Load the new animation in - this.animationManager.load(this, key, startFrame); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#pause - * @since 3.0.0 - * - * @param {[type]} atFrame - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object. - */ - pause: function (atFrame) - { - if (!this._paused) - { - this._paused = true; - this._wasPlaying = this.isPlaying; - this.isPlaying = false; - } - - if (atFrame !== undefined) - { - this.updateFrame(atFrame); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#paused - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - paused: function (value) - { - if (value !== undefined) - { - // Setter - if (value) - { - return this.pause(); - } - else - { - return this.resume(); - } - } - else - { - return this._paused; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#play - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {boolean} [ignoreIfPlaying=false] - [description] - * @param {integer} [startFrame=0] - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object. - */ - play: function (key, ignoreIfPlaying, startFrame) - { - if (ignoreIfPlaying === undefined) { ignoreIfPlaying = false; } - if (startFrame === undefined) { startFrame = 0; } - - if (ignoreIfPlaying && this.isPlaying && this.currentAnim.key === key) - { - return this; - } - - this.load(key, startFrame); - - var anim = this.currentAnim; - var gameObject = this.parent; - - // Should give us 9,007,199,254,740,991 safe repeats - this.repeatCounter = (this._repeat === -1) ? Number.MAX_VALUE : this._repeat; - - anim.getFirstTick(this); - - this.forward = true; - this.isPlaying = true; - this.pendingRepeat = false; - - if (anim.showOnStart) - { - gameObject.visible = true; - } - - if (anim.onStart) - { - anim.onStart.apply(anim.callbackScope, this._callbackArgs.concat(anim.onStartParams)); - } - - gameObject.setSizeToFrame(); - gameObject.updateDisplayOrigin(); - - return this; - }, - - // Value between 0 and 1. How far this animation is through, ignoring repeats and yoyos. - // If the animation has a non-zero repeat defined, progress and totalProgress will be different - // because progress doesn't include any repeats or repeatDelays whereas totalProgress does. - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#progress - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - progress: function (value) - { - if (value === undefined) - { - var p = this.currentFrame.progress; - - if (!this.forward) - { - p = 1 - p; - } - - return p; - } - else - { - // TODO: Set progress - - return this; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#remove - * @since 3.0.0 - * - * @param {[type]} event - [description] - */ - remove: function (event) - { - if (event === undefined) { event = this.currentAnim; } - - if (this.isPlaying && event.key === this.currentAnim.key) - { - this.stop(); - - var sprite = this.parent; - var frame = this.currentAnim.frames[0]; - - this.currentFrame = frame; - - sprite.texture = frame.frame.texture; - sprite.frame = frame.frame; - } - }, - - // Gets or sets the number of times that the animation should repeat - // after its first iteration. For example, if repeat is 1, the animation will - // play a total of twice (the initial play plus 1 repeat). - // To repeat indefinitely, use -1. repeat should always be an integer. - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#repeat - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - repeat: function (value) - { - if (value === undefined) - { - return this._repeat; - } - else - { - this._repeat = value; - this.repeatCounter = 0; - - return this; - } - }, - - // Gets or sets the amount of time in seconds between repeats. - // For example, if repeat is 2 and repeatDelay is 1, the animation will play initially, - // then wait for 1 second before it repeats, then play again, then wait 1 second again - // before doing its final repeat. - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#repeatDelay - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - repeatDelay: function (value) - { - if (value === undefined) - { - return this._repeatDelay; - } - else - { - this._repeatDelay = value; - - return this; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#restart - * @since 3.0.0 - * - * @param {[type]} includeDelay - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object. - */ - restart: function (includeDelay) - { - if (includeDelay === undefined) { includeDelay = false; } - - this.currentAnim.getFirstTick(this, includeDelay); - - this.forward = true; - this.isPlaying = true; - this.pendingRepeat = false; - this._paused = false; - - // Set frame - this.updateFrame(this.currentAnim.frames[0]); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#resume - * @since 3.0.0 - * - * @param {[type]} fromFrame - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object. - */ - resume: function (fromFrame) - { - if (this._paused) - { - this._paused = false; - this.isPlaying = this._wasPlaying; - } - - if (fromFrame !== undefined) - { - this.updateFrame(fromFrame); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#stop - * @since 3.0.0 - * - * @param {[type]} dispatchCallbacks - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object. - */ - stop: function (dispatchCallbacks) - { - if (dispatchCallbacks === undefined) { dispatchCallbacks = false; } - - this.isPlaying = false; - - var anim = this.currentAnim; - - if (dispatchCallbacks && anim.onComplete) - { - anim.onComplete.apply(anim.callbackScope, this._callbackArgs.concat(anim.onCompleteParams)); - } - - return this; - }, - - // Scale the time (make it go faster / slower) - // Factor that's used to scale time where 1 = normal speed (the default), 0.5 = half speed, 2 = double speed, etc. - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#timeScale - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - timeScale: function (value) - { - if (value === undefined) - { - return this._timeScale; - } - else - { - this._timeScale = value; - - return this; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#totalFrames - * @since 3.0.0 - * - * @return {[type]} [description] - */ - totalFrames: function () - { - return this.currentAnim.frames.length; - }, - - // Value between 0 and 1. How far this animation is through, including things like delays - // repeats, custom frame durations, etc. If the animation is set to repeat -1 it can never - // have a duration, therefore this will return -1. - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#totalProgres - * @since 3.0.0 - */ - totalProgres: function () - { - // TODO - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#update - * @since 3.0.0 - * - * @param {[type]} timestamp - [description] - * @param {[type]} delta - [description] - */ - update: function (timestamp, delta) - { - if (!this.isPlaying || this.currentAnim.paused) - { - return; - } - - this.accumulator += delta * this._timeScale; - - if (this.accumulator >= this.nextTick) - { - this.currentAnim.setFrame(this); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#updateFrame - * @since 3.0.0 - * - * @param {[type]} animationFrame - [description] - */ - updateFrame: function (animationFrame) - { - var sprite = this.parent; - - this.currentFrame = animationFrame; - - sprite.texture = animationFrame.frame.texture; - sprite.frame = animationFrame.frame; - - if (this.isPlaying) - { - if (animationFrame.setAlpha) - { - sprite.alpha = animationFrame.alpha; - } - - var anim = this.currentAnim; - - if (anim.onUpdate) - { - anim.onUpdate.apply(anim.callbackScope, this._updateParams); - } - - if (animationFrame.onUpdate) - { - animationFrame.onUpdate(sprite, animationFrame); - } - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#yoyo - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - yoyo: function (value) - { - if (value === undefined) - { - return this._yoyo; - } - else - { - this._yoyo = value; - - return this; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#destroy - * @since 3.0.0 - */ - destroy: function () - { - // TODO - } - -}); - -module.exports = Animation; +module.exports = BottomCenter; /***/ }), @@ -71918,529 +72449,46 @@ module.exports = Animation; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BlitImage = __webpack_require__(367); -var CanvasSnapshot = __webpack_require__(368); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(19); -var DrawImage = __webpack_require__(369); -var GetBlendModes = __webpack_require__(370); -var ScaleModes = __webpack_require__(63); -var Smoothing = __webpack_require__(121); +var ALIGN_CONST = __webpack_require__(169); + +var AlignInMap = []; + +AlignInMap[ALIGN_CONST.BOTTOM_CENTER] = __webpack_require__(365); +AlignInMap[ALIGN_CONST.BOTTOM_LEFT] = __webpack_require__(364); +AlignInMap[ALIGN_CONST.BOTTOM_RIGHT] = __webpack_require__(363); +AlignInMap[ALIGN_CONST.CENTER] = __webpack_require__(362); +AlignInMap[ALIGN_CONST.LEFT_CENTER] = __webpack_require__(360); +AlignInMap[ALIGN_CONST.RIGHT_CENTER] = __webpack_require__(359); +AlignInMap[ALIGN_CONST.TOP_CENTER] = __webpack_require__(358); +AlignInMap[ALIGN_CONST.TOP_LEFT] = __webpack_require__(357); +AlignInMap[ALIGN_CONST.TOP_RIGHT] = __webpack_require__(356); /** - * @classdesc - * [description] + * Takes given Game Object and aligns it so that it is positioned relative to the other. + * The alignment used is based on the `position` argument, which is an `ALIGN_CONST` value, such as `LEFT_CENTER` or `TOP_RIGHT`. * - * @class CanvasRenderer - * @memberOf Phaser.Renderer.Canvas - * @constructor + * @function Phaser.Display.Align.In.QuickSet * @since 3.0.0 * - * @param {Phaser.Game} game - The Phaser Game instance that owns this renderer. + * @param {Phaser.GameObjects.GameObject} child - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {integer} position - The position to align the Game Object with. This is an align constant, such as `ALIGN_CONST.LEFT_CENTER`. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. */ -var CanvasRenderer = new Class({ +var QuickSet = function (child, alignIn, position, offsetX, offsetY) +{ + return AlignInMap[position](child, alignIn, offsetX, offsetY); +}; - initialize: - - function CanvasRenderer (game) - { - /** - * The Phaser Game instance that owns this renderer. - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game = game; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#type - * @type {integer} - * @since 3.0.0 - */ - this.type = CONST.CANVAS; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#drawCount - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.drawCount = 0; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#width - * @type {number} - * @since 3.0.0 - */ - this.width = game.config.width; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#height - * @type {number} - * @since 3.0.0 - */ - this.height = game.config.height; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#config - * @type {object} - * @since 3.0.0 - */ - this.config = { - clearBeforeRender: game.config.clearBeforeRender, - pixelArt: game.config.pixelArt, - backgroundColor: game.config.backgroundColor, - resolution: game.config.resolution, - autoResize: game.config.autoResize, - roundPixels: game.config.roundPixels - }; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#scaleMode - * @type {integer} - * @since 3.0.0 - */ - this.scaleMode = (game.config.pixelArt) ? ScaleModes.NEAREST : ScaleModes.LINEAR; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#gameCanvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.gameCanvas = game.canvas; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#gameContext - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.gameContext = this.gameCanvas.getContext('2d'); - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#currentContext - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.currentContext = this.gameContext; - - /** - * Map to the required function. - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#drawImage - * @type {function} - * @since 3.0.0 - */ - this.drawImage = DrawImage(this.config.roundPixels); - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#blitImage - * @type {function} - * @since 3.0.0 - */ - this.blitImage = BlitImage(this.config.roundPixels); - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#blendModes - * @type {array} - * @since 3.0.0 - */ - this.blendModes = GetBlendModes(); - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#currentAlpha - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.currentAlpha = 1; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#currentBlendMode - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.currentBlendMode = 0; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#currentScaleMode - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.currentScaleMode = 0; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotCallback - * @type {?function} - * @default null - * @since 3.0.0 - */ - this.snapshotCallback = null; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotType - * @type {?[type]} - * @default null - * @since 3.0.0 - */ - this.snapshotType = null; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotEncoder - * @type {?[type]} - * @default null - * @since 3.0.0 - */ - this.snapshotEncoder = null; - - this.init(); - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#init - * @since 3.0.0 - */ - init: function () - { - this.resize(this.width, this.height); - }, - - /** - * Resize the main game canvas. - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#resize - * @since 3.0.0 - * - * @param {integer} width - [description] - * @param {integer} height - [description] - */ - resize: function (width, height) - { - var resolution = this.config.resolution; - - this.width = width * resolution; - this.height = height * resolution; - - this.gameCanvas.width = this.width; - this.gameCanvas.height = this.height; - - if (this.config.autoResize) - { - this.gameCanvas.style.width = (this.width / resolution) + 'px'; - this.gameCanvas.style.height = (this.height / resolution) + 'px'; - } - - // Resizing a canvas will reset imageSmoothingEnabled (and probably other properties) - if (this.scaleMode === ScaleModes.NEAREST) - { - Smoothing.disable(this.gameContext); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#onContextLost - * @since 3.0.0 - * - * @param {function} callback - [description] - */ - onContextLost: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#onContextRestored - * @since 3.0.0 - * - * @param {function} callback - [description] - */ - onContextRestored: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#resetTransform - * @since 3.0.0 - */ - resetTransform: function () - { - this.currentContext.setTransform(1, 0, 0, 1, 0, 0); - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#setBlendMode - * @since 3.0.0 - * - * @param {[type]} blendMode - [description] - * - * @return {[type]} [description] - */ - setBlendMode: function (blendMode) - { - if (this.currentBlendMode !== blendMode) - { - this.currentContext.globalCompositeOperation = blendMode; - this.currentBlendMode = blendMode; - } - - return this.currentBlendMode; - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#setAlpha - * @since 3.0.0 - * - * @param {float} alpha - [description] - * - * @return {float} [description] - */ - setAlpha: function (alpha) - { - if (this.currentAlpha !== alpha) - { - this.currentContext.globalAlpha = alpha; - this.currentAlpha = alpha; - } - - return this.currentAlpha; - }, - - /** - * Called at the start of the render loop. - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#preRender - * @since 3.0.0 - */ - preRender: function () - { - var ctx = this.gameContext; - var config = this.config; - - var width = this.width; - var height = this.height; - - if (config.clearBeforeRender) - { - ctx.clearRect(0, 0, width, height); - } - - if (!config.transparent) - { - ctx.fillStyle = config.backgroundColor.rgba; - ctx.fillRect(0, 0, width, height); - } - - this.drawCount = 0; - }, - - /** - * Renders the Scene to the given Camera. - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#render - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.GameObjects.DisplayList} children - [description] - * @param {float} interpolationPercentage - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - render: function (scene, children, interpolationPercentage, camera) - { - var ctx = scene.sys.context; - var scissor = (camera.x !== 0 || camera.y !== 0 || camera.width !== ctx.canvas.width || camera.height !== ctx.canvas.height); - var list = children.list; - var resolution = this.config.resolution; - - this.currentContext = ctx; - - // If the alpha or blend mode didn't change since the last render, then don't set them again (saves 2 ops) - - if (!camera.transparent) - { - ctx.fillStyle = camera.backgroundColor.rgba; - ctx.fillRect(camera.x, camera.y, camera.width, camera.height); - } - - if (this.currentAlpha !== 1) - { - ctx.globalAlpha = 1; - this.currentAlpha = 1; - } - - if (this.currentBlendMode !== 0) - { - ctx.globalCompositeOperation = 'source-over'; - this.currentBlendMode = 0; - } - - this.currentScaleMode = 0; - - this.drawCount += list.length; - - if (scissor) - { - ctx.save(); - ctx.beginPath(); - ctx.rect(camera.x * resolution, camera.y * resolution, camera.width * resolution, camera.height * resolution); - ctx.clip(); - } - - var matrix = camera.matrix.matrix; - - ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - - for (var c = 0; c < list.length; c++) - { - var child = list[c]; - - if (child.mask) - { - child.mask.preRenderCanvas(this, child, camera); - } - - child.renderCanvas(this, child, interpolationPercentage, camera); - - if (child.mask) - { - child.mask.postRenderCanvas(this, child, camera); - } - } - - ctx.setTransform(1, 0, 0, 1, 0, 0); - - if (camera._fadeAlpha > 0 || camera._flashAlpha > 0) - { - ctx.globalCompositeOperation = 'source-over'; - - // fade rendering - ctx.fillStyle = 'rgb(' + (camera._fadeRed * 255) + ',' + (camera._fadeGreen * 255) + ',' + (camera._fadeBlue * 255) + ')'; - ctx.globalAlpha = camera._fadeAlpha; - ctx.fillRect(camera.x, camera.y, camera.width, camera.height); - - // flash rendering - ctx.fillStyle = 'rgb(' + (camera._flashRed * 255) + ',' + (camera._flashGreen * 255) + ',' + (camera._flashBlue * 255) + ')'; - ctx.globalAlpha = camera._flashAlpha; - ctx.fillRect(camera.x, camera.y, camera.width, camera.height); - - ctx.globalAlpha = 1.0; - } - - // Reset the camera scissor - if (scissor) - { - ctx.restore(); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#postRender - * @since 3.0.0 - */ - postRender: function () - { - var ctx = this.gameContext; - - ctx.globalAlpha = 1; - ctx.globalCompositeOperation = 'source-over'; - - this.currentAlpha = 1; - this.currentBlendMode = 0; - - if (this.snapshotCallback) - { - this.snapshotCallback(CanvasSnapshot(this.gameCanvas, this.snapshotType, this.snapshotEncoder)); - this.snapshotCallback = null; - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#snapshot - * @since 3.0.0 - * - * @param {[type]} callback - [description] - * @param {[type]} type - [description] - * @param {[type]} encoderOptions - [description] - */ - snapshot: function (callback, type, encoderOptions) - { - this.snapshotCallback = callback; - this.snapshotType = type; - this.snapshotEncoder = encoderOptions; - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.gameCanvas = null; - this.gameContext = null; - - this.game = null; - } - -}); - -module.exports = CanvasRenderer; +module.exports = QuickSet; /***/ }), /* 367 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -72448,49 +72496,62 @@ module.exports = CanvasRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var roundPixels = false; - /** - * No scaling, anchor, rotation or effects, literally draws the frame directly to the canvas. - * - * @function Phaser.Renderer.Canvas.BlitImage - * @since 3.0.0 - * - * @param {number} dx - The x coordinate to render the Frame to. - * @param {number} dy - The y coordinate to render the Frame to. - * @param {Phaser.Textures.Frame} frame - The Frame to render. + * @namespace Phaser.Actions */ -var BlitImage = function (dx, dy, frame) -{ - var ctx = this.currentContext; - var cd = frame.canvasData; - if (roundPixels) - { - dx |= 0; - dy |= 0; - } +module.exports = { - ctx.drawImage( - frame.source.image, - cd.sx, - cd.sy, - cd.sWidth, - cd.sHeight, - dx, - dy, - cd.dWidth, - cd.dHeight - ); -}; + Angle: __webpack_require__(943), + Call: __webpack_require__(942), + GetFirst: __webpack_require__(941), + GetLast: __webpack_require__(940), + GridAlign: __webpack_require__(939), + IncAlpha: __webpack_require__(921), + IncX: __webpack_require__(920), + IncXY: __webpack_require__(919), + IncY: __webpack_require__(918), + PlaceOnCircle: __webpack_require__(917), + PlaceOnEllipse: __webpack_require__(916), + PlaceOnLine: __webpack_require__(915), + PlaceOnRectangle: __webpack_require__(914), + PlaceOnTriangle: __webpack_require__(913), + PlayAnimation: __webpack_require__(912), + PropertyValueInc: __webpack_require__(25), + PropertyValueSet: __webpack_require__(20), + RandomCircle: __webpack_require__(911), + RandomEllipse: __webpack_require__(910), + RandomLine: __webpack_require__(909), + RandomRectangle: __webpack_require__(908), + RandomTriangle: __webpack_require__(907), + Rotate: __webpack_require__(906), + RotateAround: __webpack_require__(905), + RotateAroundDistance: __webpack_require__(904), + ScaleX: __webpack_require__(903), + ScaleXY: __webpack_require__(902), + ScaleY: __webpack_require__(901), + SetAlpha: __webpack_require__(900), + SetBlendMode: __webpack_require__(899), + SetDepth: __webpack_require__(898), + SetHitArea: __webpack_require__(897), + SetOrigin: __webpack_require__(896), + SetRotation: __webpack_require__(895), + SetScale: __webpack_require__(894), + SetScaleX: __webpack_require__(893), + SetScaleY: __webpack_require__(892), + SetTint: __webpack_require__(891), + SetVisible: __webpack_require__(890), + SetX: __webpack_require__(889), + SetXY: __webpack_require__(888), + SetY: __webpack_require__(887), + ShiftPosition: __webpack_require__(886), + Shuffle: __webpack_require__(885), + SmootherStep: __webpack_require__(884), + SmoothStep: __webpack_require__(883), + Spread: __webpack_require__(882), + ToggleVisible: __webpack_require__(881), + WrapInRectangle: __webpack_require__(880) -// Special return so we can store the config value locally - -module.exports = function (configRoundPixels) -{ - roundPixels = configRoundPixels; - - return BlitImage; }; @@ -72505,2093 +72566,81 @@ module.exports = function (configRoundPixels) */ /** - * [description] + * This is a slightly modified version of jQuery.isPlainObject. + * A plain object is an object whose internal class property is [object Object]. * - * @function Phaser.Renderer.Snapshot.Canvas + * @function Phaser.Utils.Object.IsPlainObject * @since 3.0.0 * - * @param {HTMLCanvasElement} canvas - [description] - * @param {string} [type='image/png'] - [description] - * @param {float} [encoderOptions=0.92] - [description] + * @param {object} obj - The object to inspect. * - * @return {Image} [description] + * @return {boolean} `true` if the object is plain, otherwise `false`. */ -var CanvasSnapshot = function (canvas, type, encoderOptions) +var IsPlainObject = function (obj) { - if (type === undefined) { type = 'image/png'; } - if (encoderOptions === undefined) { encoderOptions = 0.92; } + // Not plain objects: + // - Any object or value whose internal [[Class]] property is not "[object Object]" + // - DOM nodes + // - window + if (typeof(obj) !== 'object' || obj.nodeType || obj === obj.window) + { + return false; + } - var src = canvas.toDataURL(type, encoderOptions); + // Support: Firefox <20 + // The try/catch suppresses exceptions thrown when attempting to access + // the "constructor" property of certain host objects, ie. |window.location| + // https://bugzilla.mozilla.org/show_bug.cgi?id=814622 + try + { + if (obj.constructor && !({}).hasOwnProperty.call(obj.constructor.prototype, 'isPrototypeOf')) + { + return false; + } + } + catch (e) + { + return false; + } - var image = new Image(); - - image.src = src; - - return image; + // If the function hasn't returned already, we're confident that + // |obj| is a plain object, created by {} or constructed with new Object + return true; }; -module.exports = CanvasSnapshot; +module.exports = IsPlainObject; /***/ }), /* 369 */ /***/ (function(module, exports) { -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ +var g; -var roundPixels = false; +// This works in non-strict mode +g = (function() { + return this; +})(); -/** - * [description] - * - * @function Phaser.Renderer.Canvas.DrawImage - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} src - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ -var DrawImage = function (src, camera) -{ - var ctx = this.currentContext; - var frame = src.frame; - var cd = frame.canvasData; +try { + // This works if eval is allowed (see CSP) + g = g || Function("return this")() || (1, eval)("this"); +} catch (e) { + // This works if the window reference is available + if (typeof window === "object") g = window; +} - // Blend Mode +// g can still be undefined, but nothing to do about it... +// We return undefined, instead of nothing here, so it's +// easier to handle this case. if(!global) { ...} - if (this.currentBlendMode !== src.blendMode) - { - this.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = this.blendModes[src.blendMode]; - } - - // Alpha - - if (this.currentAlpha !== src.alpha) - { - this.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - - if (this.currentScaleMode !== src.scaleMode) - { - this.currentScaleMode = src.scaleMode; - - // ctx[this.smoothProperty] = (source.scaleMode === ScaleModes.LINEAR); - } - - var dx = frame.x; - var dy = frame.y; - - var fx = 1; - var fy = 1; - - if (src.flipX) - { - fx = -1; - dx -= cd.dWidth - src.displayOriginX; - } - else - { - dx -= src.displayOriginX; - } - - if (src.flipY) - { - fy = -1; - dy -= cd.dHeight - src.displayOriginY; - } - else - { - dy -= src.displayOriginY; - } - - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - - if (roundPixels) - { - tx |= 0; - ty |= 0; - dx |= 0; - dy |= 0; - } - - // Perform Matrix ITRS - - ctx.save(); - - ctx.translate(tx, ty); - - ctx.rotate(src.rotation); - - ctx.scale(src.scaleX, src.scaleY); - ctx.scale(fx, fy); - - ctx.drawImage(frame.source.image, cd.sx, cd.sy, cd.sWidth, cd.sHeight, dx, dy, cd.dWidth, cd.dHeight); - - ctx.restore(); -}; - -// Special return so we can store the config value locally - -module.exports = function (configRoundPixels) -{ - roundPixels = configRoundPixels; - - return DrawImage; -}; - - -/***/ }), -/* 370 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var modes = __webpack_require__(45); -var CanvasFeatures = __webpack_require__(237); - -/** - * [description] - * - * @function Phaser.Renderer.Canvas.GetBlendModes - * @since 3.0.0 - * - * @return {array} [description] - */ -var GetBlendModes = function () -{ - var output = []; - var useNew = CanvasFeatures.supportNewBlendModes; - - output[modes.NORMAL] = 'source-over'; - output[modes.ADD] = 'lighter'; - output[modes.MULTIPLY] = (useNew) ? 'multiply' : 'source-over'; - output[modes.SCREEN] = (useNew) ? 'screen' : 'source-over'; - output[modes.OVERLAY] = (useNew) ? 'overlay' : 'source-over'; - output[modes.DARKEN] = (useNew) ? 'darken' : 'source-over'; - output[modes.LIGHTEN] = (useNew) ? 'lighten' : 'source-over'; - output[modes.COLOR_DODGE] = (useNew) ? 'color-dodge' : 'source-over'; - output[modes.COLOR_BURN] = (useNew) ? 'color-burn' : 'source-over'; - output[modes.HARD_LIGHT] = (useNew) ? 'hard-light' : 'source-over'; - output[modes.SOFT_LIGHT] = (useNew) ? 'soft-light' : 'source-over'; - output[modes.DIFFERENCE] = (useNew) ? 'difference' : 'source-over'; - output[modes.EXCLUSION] = (useNew) ? 'exclusion' : 'source-over'; - output[modes.HUE] = (useNew) ? 'hue' : 'source-over'; - output[modes.SATURATION] = (useNew) ? 'saturation' : 'source-over'; - output[modes.COLOR] = (useNew) ? 'color' : 'source-over'; - output[modes.LUMINOSITY] = (useNew) ? 'luminosity' : 'source-over'; - - return output; -}; - -module.exports = GetBlendModes; - - -/***/ }), -/* 371 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(19); -var IsSizePowerOfTwo = __webpack_require__(127); -var Utils = __webpack_require__(41); -var WebGLSnapshot = __webpack_require__(372); - -// Default Pipelines -var BitmapMaskPipeline = __webpack_require__(373); -var FlatTintPipeline = __webpack_require__(374); -var ForwardDiffuseLightPipeline = __webpack_require__(165); -var TextureTintPipeline = __webpack_require__(166); - -/** - * @classdesc - * [description] - * - * @class WebGLRenderer - * @memberOf Phaser.Renderer.WebGL - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - [description] - */ -var WebGLRenderer = new Class({ - - initialize: - - function WebGLRenderer (game) - { - // eslint-disable-next-line consistent-this - var renderer = this; - - var contextCreationConfig = { - alpha: game.config.transparent, - depth: false, // enable when 3D is added in the future - antialias: game.config.antialias, - premultipliedAlpha: game.config.transparent, - stencil: true, - preserveDrawingBuffer: game.config.preserveDrawingBuffer, - failIfMajorPerformanceCaveat: false, - powerPreference: game.config.powerPreference - }; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#config - * @type {object} - * @since 3.0.0 - */ - this.config = { - clearBeforeRender: game.config.clearBeforeRender, - pixelArt: game.config.pixelArt, - backgroundColor: game.config.backgroundColor, - contextCreation: contextCreationConfig, - resolution: game.config.resolution, - autoResize: game.config.autoResize, - roundPixels: game.config.roundPixels - }; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game = game; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#type - * @type {integer} - * @since 3.0.0 - */ - this.type = CONST.WEBGL; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#width - * @type {number} - * @since 3.0.0 - */ - this.width = game.config.width; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#height - * @type {number} - * @since 3.0.0 - */ - this.height = game.config.height; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#canvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.canvas = game.canvas; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#lostContextCallbacks - * @type {function[]} - * @since 3.0.0 - */ - this.lostContextCallbacks = []; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#restoredContextCallbacks - * @type {function[]} - * @since 3.0.0 - */ - this.restoredContextCallbacks = []; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#blendModes - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.blendModes = []; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#nativeTextures - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.nativeTextures = []; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#contextLost - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.contextLost = false; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#pipelines - * @type {object} - * @default null - * @since 3.0.0 - */ - this.pipelines = null; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#snapshotState - * @type {object} - * @since 3.0.0 - */ - this.snapshotState = { - callback: null, - type: null, - encoder: null - }; - - // Internal Renderer State (Textures, Framebuffers, Pipelines, Buffers, etc) - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentActiveTextureUnit - * @type {integer} - * @since 3.1.0 - */ - this.currentActiveTextureUnit = 0; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentTextures - * @type {array} - * @since 3.0.0 - */ - this.currentTextures = new Array(16); - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentFramebuffer - * @type {WebGLFramebuffer} - * @default null - * @since 3.0.0 - */ - this.currentFramebuffer = null; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentPipeline - * @type {Phaser.Renderer.WebGL.WebGLPipeline} - * @default null - * @since 3.0.0 - */ - this.currentPipeline = null; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentProgram - * @type {WebGLProgram} - * @default null - * @since 3.0.0 - */ - this.currentProgram = null; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentVertexBuffer - * @type {WebGLBuffer} - * @default null - * @since 3.0.0 - */ - this.currentVertexBuffer = null; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentIndexBuffer - * @type {WebGLBuffer} - * @default null - * @since 3.0.0 - */ - this.currentIndexBuffer = null; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentBlendMode - * @type {integer} - * @since 3.0.0 - */ - this.currentBlendMode = Infinity; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissorEnabled - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.currentScissorEnabled = false; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissor - * @type {Uint32Array} - * @since 3.0.0 - */ - this.currentScissor = new Uint32Array([ 0, 0, this.width, this.height ]); - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissorIdx - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.currentScissorIdx = 0; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#scissorStack - * @type {Uint32Array} - * @since 3.0.0 - */ - this.scissorStack = new Uint32Array(4 * 1000); - - // Setup context lost and restore event listeners - - this.canvas.addEventListener('webglcontextlost', function (event) - { - renderer.contextLost = true; - event.preventDefault(); - - for (var index = 0; index < renderer.lostContextCallbacks.length; ++index) - { - var callback = renderer.lostContextCallbacks[index]; - callback[0].call(callback[1], renderer); - } - }, false); - - this.canvas.addEventListener('webglcontextrestored', function () - { - renderer.contextLost = false; - renderer.init(renderer.config); - for (var index = 0; index < renderer.restoredContextCallbacks.length; ++index) - { - var callback = renderer.restoredContextCallbacks[index]; - callback[0].call(callback[1], renderer); - } - }, false); - - // This are initialized post context creation - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#gl - * @type {WebGLRenderingContext} - * @default null - * @since 3.0.0 - */ - this.gl = null; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#supportedExtensions - * @type {object} - * @default null - * @since 3.0.0 - */ - this.supportedExtensions = null; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#extensions - * @type {object} - * @default {} - * @since 3.0.0 - */ - this.extensions = {}; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#glFormats - * @type {array} - * @default [] - * @since 3.2.0 - */ - this.glFormats = []; - - this.init(this.config); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#init - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - init: function (config) - { - var canvas = this.canvas; - var clearColor = config.backgroundColor; - var gl = canvas.getContext('webgl', config.contextCreation) || canvas.getContext('experimental-webgl', config.contextCreation); - - if (!gl) - { - this.contextLost = true; - throw new Error('This browser does not support WebGL. Try using the Canvas pipeline.'); - } - - this.gl = gl; - - for (var i = 0; i <= 16; i++) - { - this.blendModes.push({ func: [ gl.ONE, gl.ONE_MINUS_SRC_ALPHA ], equation: gl.FUNC_ADD }); - } - - this.blendModes[1].func = [ gl.ONE, gl.DST_ALPHA ]; - this.blendModes[2].func = [ gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA ]; - this.blendModes[3].func = [ gl.ONE, gl.ONE_MINUS_SRC_COLOR ]; - - this.glFormats[0] = gl.BYTE; - this.glFormats[1] = gl.SHORT; - this.glFormats[2] = gl.UNSIGNED_BYTE; - this.glFormats[3] = gl.UNSIGNED_SHORT; - this.glFormats[4] = gl.FLOAT; - - // Load supported extensions - this.supportedExtensions = gl.getSupportedExtensions(); - - // Setup initial WebGL state - gl.disable(gl.DEPTH_TEST); - gl.disable(gl.CULL_FACE); - gl.disable(gl.SCISSOR_TEST); - gl.enable(gl.BLEND); - gl.clearColor(clearColor.redGL, clearColor.greenGL, clearColor.blueGL, 1.0); - - // Initialize all textures to null - for (var index = 0; index < this.currentTextures.length; ++index) - { - this.currentTextures[index] = null; - } - - // Clear previous pipelines and reload default ones - this.pipelines = {}; - - this.addPipeline('TextureTintPipeline', new TextureTintPipeline({ game: this.game, renderer: this })); - this.addPipeline('FlatTintPipeline', new FlatTintPipeline({ game: this.game, renderer: this })); - this.addPipeline('BitmapMaskPipeline', new BitmapMaskPipeline({ game: this.game, renderer: this })); - this.addPipeline('Light2D', new ForwardDiffuseLightPipeline({ game: this.game, renderer: this })); - - this.setBlendMode(CONST.BlendModes.NORMAL); - this.resize(this.width, this.height); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#resize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - resize: function (width, height) - { - var gl = this.gl; - var pipelines = this.pipelines; - var resolution = this.config.resolution; - - this.width = width * resolution; - this.height = height * resolution; - - this.canvas.width = this.width; - this.canvas.height = this.height; - - if (this.config.autoResize) - { - this.canvas.style.width = (this.width / resolution) + 'px'; - this.canvas.style.height = (this.height / resolution) + 'px'; - } - - gl.viewport(0, 0, this.width, this.height); - - // Update all registered pipelines - for (var pipelineName in pipelines) - { - pipelines[pipelineName].resize(width, height, resolution); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#onContextRestored - * @since 3.0.0 - * - * @param {function} callback - [description] - * @param {object} target - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - onContextRestored: function (callback, target) - { - this.restoredContextCallbacks.push([ callback, target ]); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#onContextLost - * @since 3.0.0 - * - * @param {function} callback - [description] - * @param {object} target - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - onContextLost: function (callback, target) - { - this.lostContextCallbacks.push([ callback, target ]); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#hasExtension - * @since 3.0.0 - * - * @param {string} extensionName - [description] - * - * @return {boolean} [description] - */ - hasExtension: function (extensionName) - { - return this.supportedExtensions ? this.supportedExtensions.indexOf(extensionName) : false; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#getExtension - * @since 3.0.0 - * - * @param {string} extensionName - [description] - * - * @return {object} [description] - */ - getExtension: function (extensionName) - { - if (!this.hasExtension(extensionName)) { return null; } - - if (!(extensionName in this.extensions)) - { - this.extensions[extensionName] = this.gl.getExtension(extensionName); - } - - return this.extensions[extensionName]; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#flush - * @since 3.0.0 - */ - flush: function () - { - if (this.currentPipeline) - { - this.currentPipeline.flush(); - } - }, - - /* Renderer State Manipulation Functions */ - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#hasPipeline - * @since 3.0.0 - * - * @param {string} pipelineName - [description] - * - * @return {boolean} [description] - */ - hasPipeline: function (pipelineName) - { - return (pipelineName in this.pipelines); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#getPipeline - * @since 3.0.0 - * - * @param {string} pipelineName - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - getPipeline: function (pipelineName) - { - return (this.hasPipeline(pipelineName)) ? this.pipelines[pipelineName] : null; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#removePipeline - * @since 3.0.0 - * - * @param {string} pipelineName - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - removePipeline: function (pipelineName) - { - delete this.pipelines[pipelineName]; - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#addPipeline - * @since 3.0.0 - * - * @param {string} pipelineName - [description] - * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - addPipeline: function (pipelineName, pipelineInstance) - { - if (!this.hasPipeline(pipelineName)) { this.pipelines[pipelineName] = pipelineInstance; } - else { console.warn('Pipeline', pipelineName, ' already exists.'); } - - pipelineInstance.name = pipelineName; - this.pipelines[pipelineName].resize(this.width, this.height, this.config.resolution); - - return pipelineInstance; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setScissor - * @since 3.0.0 - * - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} w - [description] - * @param {integer} h - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setScissor: function (x, y, w, h) - { - var gl = this.gl; - var currentScissor = this.currentScissor; - var enabled = (x === 0 && y === 0 && w === gl.canvas.width && h === gl.canvas.height && w >= 0 && h >= 0); - - if (currentScissor[0] !== x || - currentScissor[1] !== y || - currentScissor[2] !== w || - currentScissor[3] !== h) - { - this.flush(); - } - - currentScissor[0] = x; - currentScissor[1] = y; - currentScissor[2] = w; - currentScissor[3] = h; - - this.currentScissorEnabled = enabled; - - if (enabled) - { - gl.disable(gl.SCISSOR_TEST); - return; - } - - gl.enable(gl.SCISSOR_TEST); - gl.scissor(x, (gl.drawingBufferHeight - y - h), w, h); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#pushScissor - * @since 3.0.0 - * - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} w - [description] - * @param {integer} h - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - pushScissor: function (x, y, w, h) - { - var scissorStack = this.scissorStack; - var stackIndex = this.currentScissorIdx; - var currentScissor = this.currentScissor; - - scissorStack[stackIndex + 0] = currentScissor[0]; - scissorStack[stackIndex + 1] = currentScissor[1]; - scissorStack[stackIndex + 2] = currentScissor[2]; - scissorStack[stackIndex + 3] = currentScissor[3]; - - this.currentScissorIdx += 4; - this.setScissor(x, y, w, h); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#popScissor - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - popScissor: function () - { - var scissorStack = this.scissorStack; - var stackIndex = this.currentScissorIdx - 4; - - var x = scissorStack[stackIndex + 0]; - var y = scissorStack[stackIndex + 1]; - var w = scissorStack[stackIndex + 2]; - var h = scissorStack[stackIndex + 3]; - - this.currentScissorIdx = stackIndex; - this.setScissor(x, y, w, h); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setPipeline - * @since 3.0.0 - * - * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setPipeline: function (pipelineInstance) - { - if (this.currentPipeline !== pipelineInstance || - this.currentPipeline.vertexBuffer !== this.currentVertexBuffer || - this.currentPipeline.program !== this.currentProgram) - { - this.flush(); - this.currentPipeline = pipelineInstance; - this.currentPipeline.bind(); - } - - this.currentPipeline.onBind(); - - return this.currentPipeline; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setBlendMode - * @since 3.0.0 - * - * @param {integer} blendModeId - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setBlendMode: function (blendModeId) - { - var gl = this.gl; - var blendMode = this.blendModes[blendModeId]; - - if (blendModeId !== CONST.BlendModes.SKIP_CHECK && - this.currentBlendMode !== blendModeId) - { - this.flush(); - - gl.enable(gl.BLEND); - gl.blendEquation(blendMode.equation); - - if (blendMode.func.length > 2) - { - gl.blendFuncSeparate(blendMode.func[0], blendMode.func[1], blendMode.func[2], blendMode.func[3]); - } - else - { - gl.blendFunc(blendMode.func[0], blendMode.func[1]); - } - - this.currentBlendMode = blendModeId; - } - - return this; - }, - - addBlendMode: function (func, equation) - { - var index = this.blendModes.push({ func: func, equation: equation }); - - return index - 1; - }, - - updateBlendMode: function (index, func, equation) - { - if (this.blendModes[index]) - { - this.blendModes[index].func = func; - - if (equation) - { - this.blendModes[index].equation = equation; - } - } - - return this; - }, - - removeBlendMode: function (index) - { - if (index > 16 && this.blendModes[index]) - { - this.blendModes.splice(index, 1); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setTexture2D - * @since 3.0.0 - * - * @param {WebGLTexture} texture - [description] - * @param {integer} textureUnit - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setTexture2D: function (texture, textureUnit) - { - var gl = this.gl; - - if (texture !== this.currentTextures[textureUnit]) - { - this.flush(); - - if (this.currentActiveTextureUnit !== textureUnit) - { - gl.activeTexture(gl.TEXTURE0 + textureUnit); - this.currentActiveTextureUnit = textureUnit; - } - gl.bindTexture(gl.TEXTURE_2D, texture); - - this.currentTextures[textureUnit] = texture; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFramebuffer - * @since 3.0.0 - * - * @param {WebGLFramebuffer} framebuffer - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setFramebuffer: function (framebuffer) - { - var gl = this.gl; - - if (framebuffer !== this.currentFramebuffer) - { - this.flush(); - - gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); - this.currentFramebuffer = framebuffer; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setProgram - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setProgram: function (program) - { - var gl = this.gl; - - if (program !== this.currentProgram) - { - this.flush(); - - gl.useProgram(program); - this.currentProgram = program; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setVertexBuffer - * @since 3.0.0 - * - * @param {WebGLBuffer} vertexBuffer - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setVertexBuffer: function (vertexBuffer) - { - var gl = this.gl; - - if (vertexBuffer !== this.currentVertexBuffer) - { - this.flush(); - - gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); - this.currentVertexBuffer = vertexBuffer; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setIndexBuffer - * @since 3.0.0 - * - * @param {WebGLBuffer} indexBuffer - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setIndexBuffer: function (indexBuffer) - { - var gl = this.gl; - - if (indexBuffer !== this.currentIndexBuffer) - { - this.flush(); - - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer); - this.currentIndexBuffer = indexBuffer; - } - - return this; - }, - - /* Renderer Resource Creation Functions */ - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createTextureFromSource - * @since 3.0.0 - * - * @param {object} source - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {integer} scaleMode - [description] - * - * @return {WebGLTexture} [description] - */ - createTextureFromSource: function (source, width, height, scaleMode) - { - var gl = this.gl; - var filter = gl.NEAREST; - var wrap = gl.CLAMP_TO_EDGE; - var texture = null; - - width = source ? source.width : width; - height = source ? source.height : height; - - if (IsSizePowerOfTwo(width, height)) - { - wrap = gl.REPEAT; - } - - if (scaleMode === CONST.ScaleModes.LINEAR) - { - filter = gl.LINEAR; - } - else if (scaleMode === CONST.ScaleModes.NEAREST || this.config.pixelArt) - { - filter = gl.NEAREST; - } - - if (!source && typeof width === 'number' && typeof height === 'number') - { - texture = this.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); - } - else - { - texture = this.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, source); - } - - return texture; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createTexture2D - * @since 3.0.0 - * - * @param {integer} mipLevel - [description] - * @param {integer} minFilter - [description] - * @param {integer} magFilter - [description] - * @param {integer} wrapT - [description] - * @param {integer} wrapS - [description] - * @param {integer} format - [description] - * @param {object} pixels - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {boolean} pma - [description] - * - * @return {WebGLTexture} [description] - */ - createTexture2D: function (mipLevel, minFilter, magFilter, wrapT, wrapS, format, pixels, width, height, pma) - { - var gl = this.gl; - var texture = gl.createTexture(); - - pma = (pma === undefined || pma === null) ? true : pma; - - this.setTexture2D(texture, 0); - - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT); - gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, pma); - - if (pixels === null || pixels === undefined) - { - gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, width, height, 0, format, gl.UNSIGNED_BYTE, null); - } - else - { - gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, format, gl.UNSIGNED_BYTE, pixels); - width = pixels.width; - height = pixels.height; - } - - this.setTexture2D(null, 0); - - texture.isAlphaPremultiplied = pma; - texture.isRenderTexture = false; - texture.width = width; - texture.height = height; - - this.nativeTextures.push(texture); - - return texture; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createFramebuffer - * @since 3.0.0 - * - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {WebGLFramebuffer} renderTexture - [description] - * @param {boolean} addDepthStencilBuffer - [description] - * - * @return {WebGLFramebuffer} [description] - */ - createFramebuffer: function (width, height, renderTexture, addDepthStencilBuffer) - { - var gl = this.gl; - var framebuffer = gl.createFramebuffer(); - var complete = 0; - - this.setFramebuffer(framebuffer); - - if (addDepthStencilBuffer) - { - var depthStencilBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer); - } - - renderTexture.isRenderTexture = true; - renderTexture.isAlphaPremultiplied = false; - - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, renderTexture, 0); - - complete = gl.checkFramebufferStatus(gl.FRAMEBUFFER); - - if (complete !== gl.FRAMEBUFFER_COMPLETE) - { - var errors = { - 36054: 'Incomplete Attachment', - 36055: 'Missing Attachment', - 36057: 'Incomplete Dimensions', - 36061: 'Framebuffer Unsupported' - }; - throw new Error('Framebuffer incomplete. Framebuffer status: ' + errors[complete]); - } - - framebuffer.renderTexture = renderTexture; - - this.setFramebuffer(null); - - return framebuffer; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createProgram - * @since 3.0.0 - * - * @param {string} vertexShader - [description] - * @param {string} fragmentShader - [description] - * - * @return {WebGLProgram} [description] - */ - createProgram: function (vertexShader, fragmentShader) - { - var gl = this.gl; - var program = gl.createProgram(); - var vs = gl.createShader(gl.VERTEX_SHADER); - var fs = gl.createShader(gl.FRAGMENT_SHADER); - - gl.shaderSource(vs, vertexShader); - gl.shaderSource(fs, fragmentShader); - gl.compileShader(vs); - gl.compileShader(fs); - - if (!gl.getShaderParameter(vs, gl.COMPILE_STATUS)) - { - throw new Error('Failed to compile Vertex Shader:\n' + gl.getShaderInfoLog(vs)); - } - if (!gl.getShaderParameter(fs, gl.COMPILE_STATUS)) - { - throw new Error('Failed to compile Fragment Shader:\n' + gl.getShaderInfoLog(fs)); - } - - gl.attachShader(program, vs); - gl.attachShader(program, fs); - gl.linkProgram(program); - - if (!gl.getProgramParameter(program, gl.LINK_STATUS)) - { - throw new Error('Failed to link program:\n' + gl.getProgramInfoLog(program)); - } - - return program; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createVertexBuffer - * @since 3.0.0 - * - * @param {ArrayBuffer} initialDataOrSize - [description] - * @param {integer} bufferUsage - [description] - * - * @return {WebGLBuffer} [description] - */ - createVertexBuffer: function (initialDataOrSize, bufferUsage) - { - var gl = this.gl; - var vertexBuffer = gl.createBuffer(); - - this.setVertexBuffer(vertexBuffer); - gl.bufferData(gl.ARRAY_BUFFER, initialDataOrSize, bufferUsage); - this.setVertexBuffer(null); - - return vertexBuffer; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createIndexBuffer - * @since 3.0.0 - * - * @param {ArrayBuffer} initialDataOrSize - [description] - * @param {integer} bufferUsage - [description] - * - * @return {WebGLBuffer} [description] - */ - createIndexBuffer: function (initialDataOrSize, bufferUsage) - { - var gl = this.gl; - var indexBuffer = gl.createBuffer(); - - this.setIndexBuffer(indexBuffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, initialDataOrSize, bufferUsage); - this.setIndexBuffer(null); - - return indexBuffer; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteTexture - * @since 3.0.0 - * - * @param {WebGLTexture} texture - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - deleteTexture: function (texture) - { - this.gl.deleteTexture(texture); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteFramebuffer - * @since 3.0.0 - * - * @param {WebGLFramebuffer} framebuffer - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - deleteFramebuffer: function (framebuffer) - { - this.gl.deleteFramebuffer(framebuffer); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteProgram - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - deleteProgram: function (program) - { - this.gl.deleteProgram(program); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteBuffer - * @since 3.0.0 - * - * @param {WebGLBuffer} vertexBuffer - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - deleteBuffer: function (buffer) - { - this.gl.deleteBuffer(buffer); - return this; - }, - - /* Rendering Functions */ - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#preRenderCamera - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - preRenderCamera: function (camera) - { - var resolution = this.config.resolution; - - this.pushScissor(camera.x * resolution, camera.y * resolution, camera.width * resolution, camera.height * resolution); - - if (camera.backgroundColor.alphaGL > 0) - { - var color = camera.backgroundColor; - var FlatTintPipeline = this.pipelines.FlatTintPipeline; - - FlatTintPipeline.batchFillRect( - 0, 0, 1, 1, 0, - camera.x, camera.y, camera.width, camera.height, - Utils.getTintFromFloats(color.redGL, color.greenGL, color.blueGL, 1.0), - color.alphaGL, - 1, 0, 0, 1, 0, 0, - [ 1, 0, 0, 1, 0, 0 ] - ); - - FlatTintPipeline.flush(); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#postRenderCamera - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - postRenderCamera: function (camera) - { - if (camera._fadeAlpha > 0 || camera._flashAlpha > 0) - { - var FlatTintPipeline = this.pipelines.FlatTintPipeline; - - // Fade - FlatTintPipeline.batchFillRect( - 0, 0, 1, 1, 0, - camera.x, camera.y, camera.width, camera.height, - Utils.getTintFromFloats(camera._fadeRed, camera._fadeGreen, camera._fadeBlue, 1.0), - camera._fadeAlpha, - 1, 0, 0, 1, 0, 0, - [ 1, 0, 0, 1, 0, 0 ] - ); - - // Flash - FlatTintPipeline.batchFillRect( - 0, 0, 1, 1, 0, - camera.x, camera.y, camera.width, camera.height, - Utils.getTintFromFloats(camera._flashRed, camera._flashGreen, camera._flashBlue, 1.0), - camera._flashAlpha, - 1, 0, 0, 1, 0, 0, - [ 1, 0, 0, 1, 0, 0 ] - ); - - FlatTintPipeline.flush(); - } - - this.popScissor(); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#preRender - * @since 3.0.0 - */ - preRender: function () - { - if (this.contextLost) { return; } - - var gl = this.gl; - var color = this.config.backgroundColor; - var pipelines = this.pipelines; - - // Bind custom framebuffer here - gl.clearColor(color.redGL, color.greenGL, color.blueGL, color.alphaGL); - - if (this.config.clearBeforeRender) - { gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT); } - - for (var key in pipelines) - { - pipelines[key].onPreRender(); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#render - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.GameObjects.GameObject} children - [description] - * @param {number} interpolationPercentage - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - render: function (scene, children, interpolationPercentage, camera) - { - if (this.contextLost) { return; } - - var list = children.list; - var childCount = list.length; - var pipelines = this.pipelines; - - for (var key in pipelines) - { - pipelines[key].onRender(scene, camera); - } - - this.preRenderCamera(camera); - - for (var index = 0; index < childCount; ++index) - { - var child = list[index]; - - if (!child.willRender()) - { - continue; - } - - if (child.blendMode !== this.currentBlendMode) - { - this.setBlendMode(child.blendMode); - } - - if (child.mask) - { - child.mask.preRenderWebGL(this, child, camera); - } - - child.renderWebGL(this, child, interpolationPercentage, camera); - - if (child.mask) - { - child.mask.postRenderWebGL(this, child); - } - } - - this.flush(); - this.setBlendMode(CONST.BlendModes.NORMAL); - this.postRenderCamera(camera); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#postRender - * @since 3.0.0 - */ - postRender: function () - { - if (this.contextLost) { return; } - - // Unbind custom framebuffer here - - if (this.snapshotState.callback) - { - this.snapshotState.callback(WebGLSnapshot(this.canvas, this.snapshotState.type, this.snapshotState.encoder)); - this.snapshotState.callback = null; - } - - var pipelines = this.pipelines; - - for (var key in pipelines) - { - pipelines[key].onPostRender(); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#snapshot - * @since 3.0.0 - * - * @param {function} callback - [description] - * @param {string} type - [description] - * @param {float} encoderOptions - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - snapshot: function (callback, type, encoderOptions) - { - this.snapshotState.callback = callback; - this.snapshotState.type = type; - this.snapshotState.encoder = encoderOptions; - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#canvasToTexture - * @since 3.0.0 - * - * @param {HTMLCanvasElement} srcCanvas - [description] - * @param {WebGLTexture} dstTexture - [description] - * @param {boolean} shouldReallocate - [description] - * @param {integer} scaleMode - [description] - * - * @return {WebGLTexture} [description] - */ - canvasToTexture: function (srcCanvas, dstTexture) - { - var gl = this.gl; - - if (!dstTexture) - { - var wrapping = gl.CLAMP_TO_EDGE; - - if (IsSizePowerOfTwo(srcCanvas.width, srcCanvas.height)) - { - wrapping = gl.REPEAT; - } - - dstTexture = this.createTexture2D(0, gl.NEAREST, gl.NEAREST, wrapping, wrapping, gl.RGBA, srcCanvas, srcCanvas.width, srcCanvas.height, true); - } - else - { - this.setTexture2D(dstTexture, 0); - - // if (!shouldReallocate && dstTexture.width >= srcCanvas.width || dstTexture.height >= srcCanvas.height) - // { - // gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, srcCanvas.width, srcCanvas.height, gl.RGBA, gl.UNSIGNED_BYTE, srcCanvas); - // } - // else - { - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, srcCanvas); - dstTexture.width = srcCanvas.width; - dstTexture.height = srcCanvas.height; - } - - this.setTexture2D(null, 0); - } - - return dstTexture; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setTextureFilter - * @since 3.0.0 - * - * @param {integer} texture - [description] - * @param {integer} filter - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setTextureFilter: function (texture, filter) - { - var gl = this.gl; - var glFilter = [ gl.LINEAR, gl.NEAREST ][filter]; - - this.setTexture2D(texture, 0); - - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, glFilter); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, glFilter); - - this.setTexture2D(null, 0); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat1 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {float} x - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setFloat1: function (program, name, x) - { - this.setProgram(program); - this.gl.uniform1f(this.gl.getUniformLocation(program, name), x); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat2 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setFloat2: function (program, name, x, y) - { - this.setProgram(program); - this.gl.uniform2f(this.gl.getUniformLocation(program, name), x, y); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat3 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] - * @param {float} z - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setFloat3: function (program, name, x, y, z) - { - this.setProgram(program); - this.gl.uniform3f(this.gl.getUniformLocation(program, name), x, y, z); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat4 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] - * @param {float} z - [description] - * @param {float} w - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setFloat4: function (program, name, x, y, z, w) - { - this.setProgram(program); - this.gl.uniform4f(this.gl.getUniformLocation(program, name), x, y, z, w); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt1 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {integer} x - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setInt1: function (program, name, x) - { - this.setProgram(program); - this.gl.uniform1i(this.gl.getUniformLocation(program, name), x); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt2 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {integer} x - [description] - * @param {integer} y - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setInt2: function (program, name, x, y) - { - this.setProgram(program); - this.gl.uniform2i(this.gl.getUniformLocation(program, name), x, y); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt3 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} z - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setInt3: function (program, name, x, y, z) - { - this.setProgram(program); - this.gl.uniform3i(this.gl.getUniformLocation(program, name), x, y, z); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt4 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} z - [description] - * @param {integer} w - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setInt4: function (program, name, x, y, z, w) - { - this.setProgram(program); - this.gl.uniform4i(this.gl.getUniformLocation(program, name), x, y, z, w); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix2 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {boolean} transpose - [description] - * @param {Float32Array} matrix - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setMatrix2: function (program, name, transpose, matrix) - { - this.setProgram(program); - this.gl.uniformMatrix2fv(this.gl.getUniformLocation(program, name), transpose, matrix); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix3 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {boolean} transpose - [description] - * @param {Float32Array} matrix - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setMatrix3: function (program, name, transpose, matrix) - { - this.setProgram(program); - this.gl.uniformMatrix3fv(this.gl.getUniformLocation(program, name), transpose, matrix); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix4 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {boolean} transpose - [description] - * @param {Float32Array} matrix - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setMatrix4: function (program, name, transpose, matrix) - { - this.setProgram(program); - this.gl.uniformMatrix4fv(this.gl.getUniformLocation(program, name), transpose, matrix); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#destroy - * @since 3.0.0 - */ - destroy: function () - { - // Clear-up anything that should be cleared :) - for (var key in this.pipelines) - { - this.pipelines[key].destroy(); - delete this.pipelines[key]; - } - - for (var index = 0; index < this.nativeTextures.length; ++index) - { - this.deleteTexture(this.nativeTextures[index]); - delete this.nativeTextures[index]; - } - - if (this.hasExtension('WEBGL_lose_context')) - { - this.getExtension('WEBGL_lose_context').loseContext(); - } - - delete this.gl; - delete this.game; - - this.contextLost = true; - this.extensions = {}; - this.nativeTextures.length = 0; - } - -}); - -module.exports = WebGLRenderer; +module.exports = g; /***/ }), +/* 370 */, +/* 371 */, /* 372 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Renderer.Snapshot.WebGL - * @since 3.0.0 - * - * @param {HTMLCanvasElement} sourceCanvas - [description] - * @param {string} [type='image/png'] - [description] - * @param {float} [encoderOptions=0.92] - [description] - * - * @return {Image} [description] - */ -var WebGLSnapshot = function (sourceCanvas, type, encoderOptions) -{ - if (!type) { type = 'image/png'; } - if (!encoderOptions) { encoderOptions = 0.92; } - - var gl = sourceCanvas.getContext('experimental-webgl'); - var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); - gl.readPixels(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, gl.RGBA, gl.UNSIGNED_BYTE, pixels); - - // CanvasPool? - var canvas = document.createElement('canvas'); - var ctx = canvas.getContext('2d'); - var imageData; - - canvas.width = gl.drawingBufferWidth; - canvas.height = gl.drawingBufferHeight; - - imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); - - var data = imageData.data; - - for (var y = 0; y < canvas.height; y += 1) - { - for (var x = 0; x < canvas.width; x += 1) - { - var si = ((canvas.height - y) * canvas.width + x) * 4; - var di = (y * canvas.width + x) * 4; - data[di + 0] = pixels[si + 0]; - data[di + 1] = pixels[si + 1]; - data[di + 2] = pixels[si + 2]; - data[di + 3] = pixels[si + 3]; - } - } - - ctx.putImageData(imageData, 0, 0); - - var src = canvas.toDataURL(type, encoderOptions); - var image = new Image(); - - image.src = src; - - return image; -}; - -module.exports = WebGLSnapshot; - - -/***/ }), -/* 373 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -74601,223 +72650,13 @@ module.exports = WebGLSnapshot; */ var Class = __webpack_require__(0); -var ShaderSourceFS = __webpack_require__(511); -var ShaderSourceVS = __webpack_require__(512); -var WebGLPipeline = __webpack_require__(103); - -/** - * @classdesc - * [description] - * - * @class BitmapMaskPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline - * @memberOf Phaser.Renderer.WebGL - * @constructor - * @since 3.0.0 - * - * @param {object} config - [description] - */ -var BitmapMaskPipeline = new Class({ - - Extends: WebGLPipeline, - - initialize: - - function BitmapMaskPipeline (config) - { - WebGLPipeline.call(this, { - game: config.game, - renderer: config.renderer, - gl: config.renderer.gl, - topology: (config.topology ? config.topology : config.renderer.gl.TRIANGLES), - vertShader: (config.vertShader ? config.vertShader : ShaderSourceVS), - fragShader: (config.fragShader ? config.fragShader : ShaderSourceFS), - vertexCapacity: (config.vertexCapacity ? config.vertexCapacity : 3), - - vertexSize: (config.vertexSize ? config.vertexSize : - Float32Array.BYTES_PER_ELEMENT * 2), - - vertices: new Float32Array([ - -1, +1, -1, -7, +7, +1 - ]).buffer, - - attributes: [ - { - name: 'inPosition', - size: 2, - type: config.renderer.gl.FLOAT, - normalized: false, - offset: 0 - } - ] - }); - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.BitmapMaskPipeline#vertexViewF32 - * @type {Float32Array} - * @since 3.0.0 - */ - this.vertexViewF32 = new Float32Array(this.vertexData); - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.BitmapMaskPipeline#maxQuads - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.maxQuads = 1; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.BitmapMaskPipeline#resolutionDirty - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.resolutionDirty = true; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.BitmapMaskPipeline#onBind - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.BitmapMaskPipeline} [description] - */ - onBind: function () - { - WebGLPipeline.prototype.onBind.call(this); - - var renderer = this.renderer; - var program = this.program; - - if (this.resolutionDirty) - { - renderer.setFloat2(program, 'uResolution', this.width, this.height); - renderer.setInt1(program, 'uMainSampler', 0); - renderer.setInt1(program, 'uMaskSampler', 1); - this.resolutionDirty = false; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.BitmapMaskPipeline#resize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} resolution - [description] - * - * @return {Phaser.Renderer.WebGL.BitmapMaskPipeline} [description] - */ - resize: function (width, height, resolution) - { - WebGLPipeline.prototype.resize.call(this, width, height, resolution); - this.resolutionDirty = true; - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.BitmapMaskPipeline#beginMask - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} mask - [description] - * @param {Phaser.GameObjects.GameObject} maskedObject - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - beginMask: function (mask, maskedObject, camera) - { - var bitmapMask = mask.bitmapMask; - var renderer = this.renderer; - var gl = this.gl; - var visible = bitmapMask.visible; - - if (bitmapMask && gl) - { - // First we clear the mask framebuffer - renderer.setFramebuffer(mask.maskFramebuffer); - gl.clearColor(0, 0, 0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); - - // We render out mask source - bitmapMask.visible = true; - bitmapMask.renderWebGL(renderer, bitmapMask, 0.0, camera); - bitmapMask.visible = visible; - renderer.flush(); - - // Bind and clear our main source (masked object) - renderer.setFramebuffer(mask.mainFramebuffer); - gl.clearColor(0, 0, 0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.BitmapMaskPipeline#endMask - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} mask - [description] - */ - endMask: function (mask) - { - var bitmapMask = mask.bitmapMask; - var renderer = this.renderer; - var gl = this.gl; - - if (bitmapMask) - { - // Return to default framebuffer - renderer.setFramebuffer(null); - - // Bind bitmap mask pipeline and draw - renderer.setPipeline(this); - - renderer.setTexture2D(mask.maskTexture, 1); - renderer.setTexture2D(mask.mainTexture, 0); - renderer.setInt1(this.program, 'uInvertMaskAlpha', mask.invertAlpha); - - // Finally draw a triangle filling the whole screen - gl.drawArrays(this.topology, 0, 3); - } - } - -}); - -module.exports = BitmapMaskPipeline; - - -/***/ }), -/* 374 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Commands = __webpack_require__(128); -var Earcut = __webpack_require__(238); -var ModelViewProjection = __webpack_require__(239); -var ShaderSourceFS = __webpack_require__(513); -var ShaderSourceVS = __webpack_require__(514); -var Utils = __webpack_require__(41); -var WebGLPipeline = __webpack_require__(103); +var Commands = __webpack_require__(144); +var Earcut = __webpack_require__(301); +var ModelViewProjection = __webpack_require__(300); +var ShaderSourceFS = __webpack_require__(814); +var ShaderSourceVS = __webpack_require__(813); +var Utils = __webpack_require__(44); +var WebGLPipeline = __webpack_require__(108); var Point = function (x, y, width, rgb, alpha) { @@ -75519,6 +73358,7 @@ var FlatTintPipeline = new Class({ var srcScaleY = graphics.scaleY; var srcRotation = -graphics.rotation; var commands = graphics.commandBuffer; + var alpha = graphics.alpha; var lineAlpha = 1.0; var fillAlpha = 1.0; var lineColor = 0; @@ -75584,12 +73424,13 @@ var FlatTintPipeline = new Class({ if (lastPath === null) { - lastPath = new Path(x + cos(startAngle) * radius, y + sin(startAngle) * radius, lineWidth, lineColor, lineAlpha); + lastPath = new Path(x + cos(startAngle) * radius, y + sin(startAngle) * radius, lineWidth, lineColor, lineAlpha * alpha); pathArray.push(lastPath); iteration += iterStep; } endAngle -= startAngle; + if (anticlockwise) { if (endAngle < -PI2) @@ -75616,7 +73457,7 @@ var FlatTintPipeline = new Class({ tx = x + cos(ta) * radius; ty = y + sin(ta) * radius; - lastPath.points.push(new Point(tx, ty, lineWidth, lineColor, lineAlpha)); + lastPath.points.push(new Point(tx, ty, lineWidth, lineColor, lineAlpha * alpha)); iteration += iterStep; } @@ -75625,7 +73466,7 @@ var FlatTintPipeline = new Class({ tx = x + cos(ta) * radius; ty = y + sin(ta) * radius; - lastPath.points.push(new Point(tx, ty, lineWidth, lineColor, lineAlpha)); + lastPath.points.push(new Point(tx, ty, lineWidth, lineColor, lineAlpha * alpha)); cmdIndex += 6; break; @@ -75668,7 +73509,7 @@ var FlatTintPipeline = new Class({ /* Rectangle properties */ pathArray[pathArrayIndex].points, fillColor, - fillAlpha, + fillAlpha * alpha, /* Transform */ mva, mvb, mvc, mvd, mve, mvf, @@ -75692,7 +73533,7 @@ var FlatTintPipeline = new Class({ path.points, lineWidth, lineColor, - lineAlpha, + lineAlpha * alpha, /* Transform */ mva, mvb, mvc, mvd, mve, mvf, @@ -75714,7 +73555,7 @@ var FlatTintPipeline = new Class({ commands[cmdIndex + 3], commands[cmdIndex + 4], fillColor, - fillAlpha, + fillAlpha * alpha, /* Transform */ mva, mvb, mvc, mvd, mve, mvf, @@ -75738,7 +73579,7 @@ var FlatTintPipeline = new Class({ commands[cmdIndex + 5], commands[cmdIndex + 6], fillColor, - fillAlpha, + fillAlpha * alpha, /* Transform */ mva, mvb, mvc, mvd, mve, mvf, @@ -75763,7 +73604,7 @@ var FlatTintPipeline = new Class({ commands[cmdIndex + 6], lineWidth, lineColor, - lineAlpha, + lineAlpha * alpha, /* Transform */ mva, mvb, mvc, mvd, mve, mvf, @@ -75776,18 +73617,18 @@ var FlatTintPipeline = new Class({ case Commands.LINE_TO: if (lastPath !== null) { - lastPath.points.push(new Point(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha)); + lastPath.points.push(new Point(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha * alpha)); } else { - lastPath = new Path(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha); + lastPath = new Path(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha * alpha); pathArray.push(lastPath); } cmdIndex += 2; break; case Commands.MOVE_TO: - lastPath = new Path(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha); + lastPath = new Path(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha * alpha); pathArray.push(lastPath); cmdIndex += 2; break; @@ -75800,7 +73641,7 @@ var FlatTintPipeline = new Class({ commands[cmdIndex + 2], commands[cmdIndex + 3], commands[cmdIndex + 4], - commands[cmdIndex + 5] + commands[cmdIndex + 5] * alpha )); } else @@ -75810,7 +73651,7 @@ var FlatTintPipeline = new Class({ commands[cmdIndex + 2], commands[cmdIndex + 3], commands[cmdIndex + 4], - commands[cmdIndex + 5] + commands[cmdIndex + 5] * alpha ); pathArray.push(lastPath); } @@ -75823,7 +73664,7 @@ var FlatTintPipeline = new Class({ commands[cmdIndex + 2], commands[cmdIndex + 3], commands[cmdIndex + 4], - commands[cmdIndex + 5] + commands[cmdIndex + 5] * alpha ); pathArray.push(lastPath); cmdIndex += 5; @@ -76028,19 +73869,2262 @@ module.exports = FlatTintPipeline; /***/ }), -/* 375 */, +/* 373 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var ShaderSourceFS = __webpack_require__(816); +var ShaderSourceVS = __webpack_require__(815); +var WebGLPipeline = __webpack_require__(108); + +/** + * @classdesc + * [description] + * + * @class BitmapMaskPipeline + * @extends Phaser.Renderer.WebGL.WebGLPipeline + * @memberOf Phaser.Renderer.WebGL + * @constructor + * @since 3.0.0 + * + * @param {object} config - [description] + */ +var BitmapMaskPipeline = new Class({ + + Extends: WebGLPipeline, + + initialize: + + function BitmapMaskPipeline (config) + { + WebGLPipeline.call(this, { + game: config.game, + renderer: config.renderer, + gl: config.renderer.gl, + topology: (config.topology ? config.topology : config.renderer.gl.TRIANGLES), + vertShader: (config.vertShader ? config.vertShader : ShaderSourceVS), + fragShader: (config.fragShader ? config.fragShader : ShaderSourceFS), + vertexCapacity: (config.vertexCapacity ? config.vertexCapacity : 3), + + vertexSize: (config.vertexSize ? config.vertexSize : + Float32Array.BYTES_PER_ELEMENT * 2), + + vertices: new Float32Array([ + -1, +1, -1, -7, +7, +1 + ]).buffer, + + attributes: [ + { + name: 'inPosition', + size: 2, + type: config.renderer.gl.FLOAT, + normalized: false, + offset: 0 + } + ] + }); + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.BitmapMaskPipeline#vertexViewF32 + * @type {Float32Array} + * @since 3.0.0 + */ + this.vertexViewF32 = new Float32Array(this.vertexData); + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.BitmapMaskPipeline#maxQuads + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.maxQuads = 1; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.BitmapMaskPipeline#resolutionDirty + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.resolutionDirty = true; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.BitmapMaskPipeline#onBind + * @since 3.0.0 + * + * @return {Phaser.Renderer.WebGL.BitmapMaskPipeline} [description] + */ + onBind: function () + { + WebGLPipeline.prototype.onBind.call(this); + + var renderer = this.renderer; + var program = this.program; + + if (this.resolutionDirty) + { + renderer.setFloat2(program, 'uResolution', this.width, this.height); + renderer.setInt1(program, 'uMainSampler', 0); + renderer.setInt1(program, 'uMaskSampler', 1); + this.resolutionDirty = false; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.BitmapMaskPipeline#resize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * @param {number} resolution - [description] + * + * @return {Phaser.Renderer.WebGL.BitmapMaskPipeline} [description] + */ + resize: function (width, height, resolution) + { + WebGLPipeline.prototype.resize.call(this, width, height, resolution); + this.resolutionDirty = true; + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.BitmapMaskPipeline#beginMask + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} mask - [description] + * @param {Phaser.GameObjects.GameObject} maskedObject - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + beginMask: function (mask, maskedObject, camera) + { + var bitmapMask = mask.bitmapMask; + var renderer = this.renderer; + var gl = this.gl; + var visible = bitmapMask.visible; + + if (bitmapMask && gl) + { + // First we clear the mask framebuffer + renderer.setFramebuffer(mask.maskFramebuffer); + gl.clearColor(0, 0, 0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); + + // We render out mask source + bitmapMask.visible = true; + bitmapMask.renderWebGL(renderer, bitmapMask, 0.0, camera); + bitmapMask.visible = visible; + renderer.flush(); + + // Bind and clear our main source (masked object) + renderer.setFramebuffer(mask.mainFramebuffer); + gl.clearColor(0, 0, 0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.BitmapMaskPipeline#endMask + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} mask - [description] + */ + endMask: function (mask) + { + var bitmapMask = mask.bitmapMask; + var renderer = this.renderer; + var gl = this.gl; + + if (bitmapMask) + { + // Return to default framebuffer + renderer.setFramebuffer(null); + + // Bind bitmap mask pipeline and draw + renderer.setPipeline(this); + + renderer.setTexture2D(mask.maskTexture, 1); + renderer.setTexture2D(mask.mainTexture, 0); + renderer.setInt1(this.program, 'uInvertMaskAlpha', mask.invertAlpha); + + // Finally draw a triangle filling the whole screen + gl.drawArrays(this.topology, 0, 3); + } + } + +}); + +module.exports = BitmapMaskPipeline; + + +/***/ }), +/* 374 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Renderer.Snapshot.WebGL + * @since 3.0.0 + * + * @param {HTMLCanvasElement} sourceCanvas - [description] + * @param {string} [type='image/png'] - [description] + * @param {float} [encoderOptions=0.92] - [description] + * + * @return {HTMLImageElement} [description] + */ +var WebGLSnapshot = function (sourceCanvas, type, encoderOptions) +{ + if (!type) { type = 'image/png'; } + if (!encoderOptions) { encoderOptions = 0.92; } + + var gl = sourceCanvas.getContext('experimental-webgl'); + var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); + gl.readPixels(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, gl.RGBA, gl.UNSIGNED_BYTE, pixels); + + // CanvasPool? + var canvas = document.createElement('canvas'); + var ctx = canvas.getContext('2d'); + var imageData; + + canvas.width = gl.drawingBufferWidth; + canvas.height = gl.drawingBufferHeight; + + imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); + + var data = imageData.data; + + for (var y = 0; y < canvas.height; y += 1) + { + for (var x = 0; x < canvas.width; x += 1) + { + var si = ((canvas.height - y) * canvas.width + x) * 4; + var di = (y * canvas.width + x) * 4; + data[di + 0] = pixels[si + 0]; + data[di + 1] = pixels[si + 1]; + data[di + 2] = pixels[si + 2]; + data[di + 3] = pixels[si + 3]; + } + } + + ctx.putImageData(imageData, 0, 0); + + var src = canvas.toDataURL(type, encoderOptions); + var image = new Image(); + + image.src = src; + + return image; +}; + +module.exports = WebGLSnapshot; + + +/***/ }), +/* 375 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(21); +var IsSizePowerOfTwo = __webpack_require__(145); +var Utils = __webpack_require__(44); +var WebGLSnapshot = __webpack_require__(374); + +// Default Pipelines +var BitmapMaskPipeline = __webpack_require__(373); +var FlatTintPipeline = __webpack_require__(372); +var ForwardDiffuseLightPipeline = __webpack_require__(173); +var TextureTintPipeline = __webpack_require__(172); + +/** + * @callback WebGLContextCallback + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - [description] + */ + +/** + * @typedef {object} SnapshotState + * + * @property {SnapshotCallback} callback - [description] + * @property {string} type - [description] + * @property {float} encoder - [description] + */ + +/** + * @classdesc + * [description] + * + * @class WebGLRenderer + * @memberOf Phaser.Renderer.WebGL + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - [description] + */ +var WebGLRenderer = new Class({ + + initialize: + + function WebGLRenderer (game) + { + // eslint-disable-next-line consistent-this + var renderer = this; + + var gameConfig = game.config; + + var contextCreationConfig = { + alpha: gameConfig.transparent, + depth: false, // enable when 3D is added in the future + antialias: gameConfig.antialias, + premultipliedAlpha: gameConfig.premultipliedAlpha, + stencil: true, + preserveDrawingBuffer: gameConfig.preserveDrawingBuffer, + failIfMajorPerformanceCaveat: gameConfig.failIfMajorPerformanceCaveat, + powerPreference: gameConfig.powerPreference + }; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#config + * @type {RendererConfig} + * @since 3.0.0 + */ + this.config = { + clearBeforeRender: gameConfig.clearBeforeRender, + pixelArt: gameConfig.pixelArt, + backgroundColor: gameConfig.backgroundColor, + contextCreation: contextCreationConfig, + resolution: gameConfig.resolution, + autoResize: gameConfig.autoResize, + roundPixels: gameConfig.roundPixels + }; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game = game; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#type + * @type {integer} + * @since 3.0.0 + */ + this.type = CONST.WEBGL; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#width + * @type {number} + * @since 3.0.0 + */ + this.width = game.config.width; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#height + * @type {number} + * @since 3.0.0 + */ + this.height = game.config.height; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#canvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvas = game.canvas; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#lostContextCallbacks + * @type {WebGLContextCallback[]} + * @since 3.0.0 + */ + this.lostContextCallbacks = []; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#restoredContextCallbacks + * @type {WebGLContextCallback[]} + * @since 3.0.0 + */ + this.restoredContextCallbacks = []; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#blendModes + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.blendModes = []; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#nativeTextures + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.nativeTextures = []; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#contextLost + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.contextLost = false; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#pipelines + * @type {object} + * @default null + * @since 3.0.0 + */ + this.pipelines = null; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#snapshotState + * @type {SnapshotState} + * @since 3.0.0 + */ + this.snapshotState = { + callback: null, + type: null, + encoder: null + }; + + // Internal Renderer State (Textures, Framebuffers, Pipelines, Buffers, etc) + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentActiveTextureUnit + * @type {integer} + * @since 3.1.0 + */ + this.currentActiveTextureUnit = 0; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentTextures + * @type {array} + * @since 3.0.0 + */ + this.currentTextures = new Array(16); + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentFramebuffer + * @type {WebGLFramebuffer} + * @default null + * @since 3.0.0 + */ + this.currentFramebuffer = null; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentPipeline + * @type {Phaser.Renderer.WebGL.WebGLPipeline} + * @default null + * @since 3.0.0 + */ + this.currentPipeline = null; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentProgram + * @type {WebGLProgram} + * @default null + * @since 3.0.0 + */ + this.currentProgram = null; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentVertexBuffer + * @type {WebGLBuffer} + * @default null + * @since 3.0.0 + */ + this.currentVertexBuffer = null; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentIndexBuffer + * @type {WebGLBuffer} + * @default null + * @since 3.0.0 + */ + this.currentIndexBuffer = null; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentBlendMode + * @type {integer} + * @since 3.0.0 + */ + this.currentBlendMode = Infinity; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissorEnabled + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.currentScissorEnabled = false; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissor + * @type {Uint32Array} + * @since 3.0.0 + */ + this.currentScissor = new Uint32Array([ 0, 0, this.width, this.height ]); + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissorIdx + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.currentScissorIdx = 0; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#scissorStack + * @type {Uint32Array} + * @since 3.0.0 + */ + this.scissorStack = new Uint32Array(4 * 1000); + + // Setup context lost and restore event listeners + + this.canvas.addEventListener('webglcontextlost', function (event) + { + renderer.contextLost = true; + event.preventDefault(); + + for (var index = 0; index < renderer.lostContextCallbacks.length; ++index) + { + var callback = renderer.lostContextCallbacks[index]; + callback[0].call(callback[1], renderer); + } + }, false); + + this.canvas.addEventListener('webglcontextrestored', function () + { + renderer.contextLost = false; + renderer.init(renderer.config); + for (var index = 0; index < renderer.restoredContextCallbacks.length; ++index) + { + var callback = renderer.restoredContextCallbacks[index]; + callback[0].call(callback[1], renderer); + } + }, false); + + // This are initialized post context creation + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#gl + * @type {WebGLRenderingContext} + * @default null + * @since 3.0.0 + */ + this.gl = null; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#supportedExtensions + * @type {object} + * @default null + * @since 3.0.0 + */ + this.supportedExtensions = null; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#extensions + * @type {object} + * @default {} + * @since 3.0.0 + */ + this.extensions = {}; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#glFormats + * @type {array} + * @default [] + * @since 3.2.0 + */ + this.glFormats = []; + + this.init(this.config); + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#init + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + init: function (config) + { + var canvas = this.canvas; + var clearColor = config.backgroundColor; + var gl = canvas.getContext('webgl', config.contextCreation) || canvas.getContext('experimental-webgl', config.contextCreation); + + if (!gl) + { + this.contextLost = true; + throw new Error('This browser does not support WebGL. Try using the Canvas pipeline.'); + } + + this.gl = gl; + + for (var i = 0; i <= 16; i++) + { + this.blendModes.push({ func: [ gl.ONE, gl.ONE_MINUS_SRC_ALPHA ], equation: gl.FUNC_ADD }); + } + + this.blendModes[1].func = [ gl.ONE, gl.DST_ALPHA ]; + this.blendModes[2].func = [ gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA ]; + this.blendModes[3].func = [ gl.ONE, gl.ONE_MINUS_SRC_COLOR ]; + + this.glFormats[0] = gl.BYTE; + this.glFormats[1] = gl.SHORT; + this.glFormats[2] = gl.UNSIGNED_BYTE; + this.glFormats[3] = gl.UNSIGNED_SHORT; + this.glFormats[4] = gl.FLOAT; + + // Load supported extensions + this.supportedExtensions = gl.getSupportedExtensions(); + + // Setup initial WebGL state + gl.disable(gl.DEPTH_TEST); + gl.disable(gl.CULL_FACE); + gl.disable(gl.SCISSOR_TEST); + gl.enable(gl.BLEND); + gl.clearColor(clearColor.redGL, clearColor.greenGL, clearColor.blueGL, 1.0); + + // Initialize all textures to null + for (var index = 0; index < this.currentTextures.length; ++index) + { + this.currentTextures[index] = null; + } + + // Clear previous pipelines and reload default ones + this.pipelines = {}; + + this.addPipeline('TextureTintPipeline', new TextureTintPipeline({ game: this.game, renderer: this })); + this.addPipeline('FlatTintPipeline', new FlatTintPipeline({ game: this.game, renderer: this })); + this.addPipeline('BitmapMaskPipeline', new BitmapMaskPipeline({ game: this.game, renderer: this })); + this.addPipeline('Light2D', new ForwardDiffuseLightPipeline({ game: this.game, renderer: this })); + + this.setBlendMode(CONST.BlendModes.NORMAL); + this.resize(this.width, this.height); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#resize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + resize: function (width, height) + { + var gl = this.gl; + var pipelines = this.pipelines; + var resolution = this.config.resolution; + + this.width = Math.floor(width * resolution); + this.height = Math.floor(height * resolution); + + this.canvas.width = this.width; + this.canvas.height = this.height; + + if (this.config.autoResize) + { + this.canvas.style.width = (this.width / resolution) + 'px'; + this.canvas.style.height = (this.height / resolution) + 'px'; + } + + gl.viewport(0, 0, this.width, this.height); + + // Update all registered pipelines + for (var pipelineName in pipelines) + { + pipelines[pipelineName].resize(width, height, resolution); + } + + this.currentScissor.set([ 0, 0, this.width, this.height ]); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#onContextRestored + * @since 3.0.0 + * + * @param {WebGLContextCallback} callback - [description] + * @param {object} target - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + onContextRestored: function (callback, target) + { + this.restoredContextCallbacks.push([ callback, target ]); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#onContextLost + * @since 3.0.0 + * + * @param {WebGLContextCallback} callback - [description] + * @param {object} target - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + onContextLost: function (callback, target) + { + this.lostContextCallbacks.push([ callback, target ]); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#hasExtension + * @since 3.0.0 + * + * @param {string} extensionName - [description] + * + * @return {boolean} [description] + */ + hasExtension: function (extensionName) + { + return this.supportedExtensions ? this.supportedExtensions.indexOf(extensionName) : false; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#getExtension + * @since 3.0.0 + * + * @param {string} extensionName - [description] + * + * @return {object} [description] + */ + getExtension: function (extensionName) + { + if (!this.hasExtension(extensionName)) { return null; } + + if (!(extensionName in this.extensions)) + { + this.extensions[extensionName] = this.gl.getExtension(extensionName); + } + + return this.extensions[extensionName]; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#flush + * @since 3.0.0 + */ + flush: function () + { + if (this.currentPipeline) + { + this.currentPipeline.flush(); + } + }, + + /* Renderer State Manipulation Functions */ + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#hasPipeline + * @since 3.0.0 + * + * @param {string} pipelineName - [description] + * + * @return {boolean} [description] + */ + hasPipeline: function (pipelineName) + { + return (pipelineName in this.pipelines); + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#getPipeline + * @since 3.0.0 + * + * @param {string} pipelineName - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + */ + getPipeline: function (pipelineName) + { + return (this.hasPipeline(pipelineName)) ? this.pipelines[pipelineName] : null; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#removePipeline + * @since 3.0.0 + * + * @param {string} pipelineName - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + removePipeline: function (pipelineName) + { + delete this.pipelines[pipelineName]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#addPipeline + * @since 3.0.0 + * + * @param {string} pipelineName - [description] + * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + */ + addPipeline: function (pipelineName, pipelineInstance) + { + if (!this.hasPipeline(pipelineName)) + { + this.pipelines[pipelineName] = pipelineInstance; + } + else + { + console.warn('Pipeline', pipelineName, ' already exists.'); + } + + pipelineInstance.name = pipelineName; + + this.pipelines[pipelineName].resize(this.width, this.height, this.config.resolution); + + return pipelineInstance; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setScissor + * @since 3.0.0 + * + * @param {integer} x - [description] + * @param {integer} y - [description] + * @param {integer} w - [description] + * @param {integer} h - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setScissor: function (x, y, w, h) + { + var gl = this.gl; + var currentScissor = this.currentScissor; + var enabled = (x === 0 && y === 0 && w === gl.canvas.width && h === gl.canvas.height && w >= 0 && h >= 0); + + if (currentScissor[0] !== x || + currentScissor[1] !== y || + currentScissor[2] !== w || + currentScissor[3] !== h) + { + this.flush(); + } + + currentScissor[0] = x; + currentScissor[1] = y; + currentScissor[2] = w; + currentScissor[3] = h; + + this.currentScissorEnabled = enabled; + + if (enabled) + { + gl.disable(gl.SCISSOR_TEST); + + return this; + } + + gl.enable(gl.SCISSOR_TEST); + gl.scissor(x, (gl.drawingBufferHeight - y - h), w, h); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#pushScissor + * @since 3.0.0 + * + * @param {integer} x - [description] + * @param {integer} y - [description] + * @param {integer} w - [description] + * @param {integer} h - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + pushScissor: function (x, y, w, h) + { + var scissorStack = this.scissorStack; + var stackIndex = this.currentScissorIdx; + var currentScissor = this.currentScissor; + + scissorStack[stackIndex + 0] = currentScissor[0]; + scissorStack[stackIndex + 1] = currentScissor[1]; + scissorStack[stackIndex + 2] = currentScissor[2]; + scissorStack[stackIndex + 3] = currentScissor[3]; + + this.currentScissorIdx += 4; + this.setScissor(x, y, w, h); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#popScissor + * @since 3.0.0 + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + popScissor: function () + { + var scissorStack = this.scissorStack; + var stackIndex = this.currentScissorIdx - 4; + + var x = scissorStack[stackIndex + 0]; + var y = scissorStack[stackIndex + 1]; + var w = scissorStack[stackIndex + 2]; + var h = scissorStack[stackIndex + 3]; + + this.currentScissorIdx = stackIndex; + this.setScissor(x, y, w, h); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setPipeline + * @since 3.0.0 + * + * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + */ + setPipeline: function (pipelineInstance) + { + if (this.currentPipeline !== pipelineInstance || + this.currentPipeline.vertexBuffer !== this.currentVertexBuffer || + this.currentPipeline.program !== this.currentProgram) + { + this.flush(); + this.currentPipeline = pipelineInstance; + this.currentPipeline.bind(); + } + + this.currentPipeline.onBind(); + + return this.currentPipeline; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setBlendMode + * @since 3.0.0 + * + * @param {integer} blendModeId - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setBlendMode: function (blendModeId) + { + var gl = this.gl; + var blendMode = this.blendModes[blendModeId]; + + if (blendModeId !== CONST.BlendModes.SKIP_CHECK && + this.currentBlendMode !== blendModeId) + { + this.flush(); + + gl.enable(gl.BLEND); + gl.blendEquation(blendMode.equation); + + if (blendMode.func.length > 2) + { + gl.blendFuncSeparate(blendMode.func[0], blendMode.func[1], blendMode.func[2], blendMode.func[3]); + } + else + { + gl.blendFunc(blendMode.func[0], blendMode.func[1]); + } + + this.currentBlendMode = blendModeId; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#addBlendMode + * @since 3.0.0 + * + * @param {function} func - [description] + * @param {function} equation - [description] + * + * @return {integer} [description] + */ + addBlendMode: function (func, equation) + { + var index = this.blendModes.push({ func: func, equation: equation }); + + return index - 1; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#updateBlendMode + * @since 3.0.0 + * + * @param {integer} index - [description] + * @param {function} func - [description] + * @param {function} equation - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + */ + updateBlendMode: function (index, func, equation) + { + if (this.blendModes[index]) + { + this.blendModes[index].func = func; + + if (equation) + { + this.blendModes[index].equation = equation; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#removeBlendMode + * @since 3.0.0 + * + * @param {integer} index - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + */ + removeBlendMode: function (index) + { + if (index > 16 && this.blendModes[index]) + { + this.blendModes.splice(index, 1); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setTexture2D + * @since 3.0.0 + * + * @param {WebGLTexture} texture - [description] + * @param {integer} textureUnit - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + */ + setTexture2D: function (texture, textureUnit) + { + var gl = this.gl; + + if (texture !== this.currentTextures[textureUnit]) + { + this.flush(); + + if (this.currentActiveTextureUnit !== textureUnit) + { + gl.activeTexture(gl.TEXTURE0 + textureUnit); + + this.currentActiveTextureUnit = textureUnit; + } + + gl.bindTexture(gl.TEXTURE_2D, texture); + + this.currentTextures[textureUnit] = texture; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFramebuffer + * @since 3.0.0 + * + * @param {WebGLFramebuffer} framebuffer - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + */ + setFramebuffer: function (framebuffer) + { + var gl = this.gl; + + if (framebuffer !== this.currentFramebuffer) + { + this.flush(); + + gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); + + this.currentFramebuffer = framebuffer; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setProgram + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + */ + setProgram: function (program) + { + var gl = this.gl; + + if (program !== this.currentProgram) + { + this.flush(); + + gl.useProgram(program); + + this.currentProgram = program; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setVertexBuffer + * @since 3.0.0 + * + * @param {WebGLBuffer} vertexBuffer - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + */ + setVertexBuffer: function (vertexBuffer) + { + var gl = this.gl; + + if (vertexBuffer !== this.currentVertexBuffer) + { + this.flush(); + + gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); + + this.currentVertexBuffer = vertexBuffer; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setIndexBuffer + * @since 3.0.0 + * + * @param {WebGLBuffer} indexBuffer - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + */ + setIndexBuffer: function (indexBuffer) + { + var gl = this.gl; + + if (indexBuffer !== this.currentIndexBuffer) + { + this.flush(); + + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer); + + this.currentIndexBuffer = indexBuffer; + } + + return this; + }, + + /* Renderer Resource Creation Functions */ + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createTextureFromSource + * @since 3.0.0 + * + * @param {object} source - [description] + * @param {integer} width - [description] + * @param {integer} height - [description] + * @param {integer} scaleMode - [description] + * + * @return {WebGLTexture} [description] + */ + createTextureFromSource: function (source, width, height, scaleMode) + { + var gl = this.gl; + var filter = gl.NEAREST; + var wrap = gl.CLAMP_TO_EDGE; + var texture = null; + + width = source ? source.width : width; + height = source ? source.height : height; + + if (IsSizePowerOfTwo(width, height)) + { + wrap = gl.REPEAT; + } + + if (scaleMode === CONST.ScaleModes.LINEAR) + { + filter = gl.LINEAR; + } + else if (scaleMode === CONST.ScaleModes.NEAREST || this.config.pixelArt) + { + filter = gl.NEAREST; + } + + if (!source && typeof width === 'number' && typeof height === 'number') + { + texture = this.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); + } + else + { + texture = this.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, source); + } + + return texture; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createTexture2D + * @since 3.0.0 + * + * @param {integer} mipLevel - [description] + * @param {integer} minFilter - [description] + * @param {integer} magFilter - [description] + * @param {integer} wrapT - [description] + * @param {integer} wrapS - [description] + * @param {integer} format - [description] + * @param {object} pixels - [description] + * @param {integer} width - [description] + * @param {integer} height - [description] + * @param {boolean} pma - [description] + * + * @return {WebGLTexture} [description] + */ + createTexture2D: function (mipLevel, minFilter, magFilter, wrapT, wrapS, format, pixels, width, height, pma) + { + var gl = this.gl; + var texture = gl.createTexture(); + + pma = (pma === undefined || pma === null) ? true : pma; + + this.setTexture2D(texture, 0); + + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT); + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, pma); + + if (pixels === null || pixels === undefined) + { + gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, width, height, 0, format, gl.UNSIGNED_BYTE, null); + } + else + { + gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, format, gl.UNSIGNED_BYTE, pixels); + width = pixels.width; + height = pixels.height; + } + + this.setTexture2D(null, 0); + + texture.isAlphaPremultiplied = pma; + texture.isRenderTexture = false; + texture.width = width; + texture.height = height; + + this.nativeTextures.push(texture); + + return texture; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createFramebuffer + * @since 3.0.0 + * + * @param {integer} width - [description] + * @param {integer} height - [description] + * @param {WebGLFramebuffer} renderTexture - [description] + * @param {boolean} addDepthStencilBuffer - [description] + * + * @return {WebGLFramebuffer} [description] + */ + createFramebuffer: function (width, height, renderTexture, addDepthStencilBuffer) + { + var gl = this.gl; + var framebuffer = gl.createFramebuffer(); + var complete = 0; + + this.setFramebuffer(framebuffer); + + if (addDepthStencilBuffer) + { + var depthStencilBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer); + } + + renderTexture.isRenderTexture = true; + renderTexture.isAlphaPremultiplied = false; + + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, renderTexture, 0); + + complete = gl.checkFramebufferStatus(gl.FRAMEBUFFER); + + if (complete !== gl.FRAMEBUFFER_COMPLETE) + { + var errors = { + 36054: 'Incomplete Attachment', + 36055: 'Missing Attachment', + 36057: 'Incomplete Dimensions', + 36061: 'Framebuffer Unsupported' + }; + + throw new Error('Framebuffer incomplete. Framebuffer status: ' + errors[complete]); + } + + framebuffer.renderTexture = renderTexture; + + this.setFramebuffer(null); + + return framebuffer; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createProgram + * @since 3.0.0 + * + * @param {string} vertexShader - [description] + * @param {string} fragmentShader - [description] + * + * @return {WebGLProgram} [description] + */ + createProgram: function (vertexShader, fragmentShader) + { + var gl = this.gl; + var program = gl.createProgram(); + var vs = gl.createShader(gl.VERTEX_SHADER); + var fs = gl.createShader(gl.FRAGMENT_SHADER); + + gl.shaderSource(vs, vertexShader); + gl.shaderSource(fs, fragmentShader); + gl.compileShader(vs); + gl.compileShader(fs); + + if (!gl.getShaderParameter(vs, gl.COMPILE_STATUS)) + { + throw new Error('Failed to compile Vertex Shader:\n' + gl.getShaderInfoLog(vs)); + } + if (!gl.getShaderParameter(fs, gl.COMPILE_STATUS)) + { + throw new Error('Failed to compile Fragment Shader:\n' + gl.getShaderInfoLog(fs)); + } + + gl.attachShader(program, vs); + gl.attachShader(program, fs); + gl.linkProgram(program); + + if (!gl.getProgramParameter(program, gl.LINK_STATUS)) + { + throw new Error('Failed to link program:\n' + gl.getProgramInfoLog(program)); + } + + return program; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createVertexBuffer + * @since 3.0.0 + * + * @param {ArrayBuffer} initialDataOrSize - [description] + * @param {integer} bufferUsage - [description] + * + * @return {WebGLBuffer} [description] + */ + createVertexBuffer: function (initialDataOrSize, bufferUsage) + { + var gl = this.gl; + var vertexBuffer = gl.createBuffer(); + + this.setVertexBuffer(vertexBuffer); + + gl.bufferData(gl.ARRAY_BUFFER, initialDataOrSize, bufferUsage); + + this.setVertexBuffer(null); + + return vertexBuffer; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createIndexBuffer + * @since 3.0.0 + * + * @param {ArrayBuffer} initialDataOrSize - [description] + * @param {integer} bufferUsage - [description] + * + * @return {WebGLBuffer} [description] + */ + createIndexBuffer: function (initialDataOrSize, bufferUsage) + { + var gl = this.gl; + var indexBuffer = gl.createBuffer(); + + this.setIndexBuffer(indexBuffer); + + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, initialDataOrSize, bufferUsage); + + this.setIndexBuffer(null); + + return indexBuffer; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteTexture + * @since 3.0.0 + * + * @param {WebGLTexture} texture - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + */ + deleteTexture: function (texture) + { + this.gl.deleteTexture(texture); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteFramebuffer + * @since 3.0.0 + * + * @param {WebGLFramebuffer} framebuffer - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + */ + deleteFramebuffer: function (framebuffer) + { + this.gl.deleteFramebuffer(framebuffer); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteProgram + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + */ + deleteProgram: function (program) + { + this.gl.deleteProgram(program); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteBuffer + * @since 3.0.0 + * + * @param {WebGLBuffer} vertexBuffer - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + */ + deleteBuffer: function (buffer) + { + this.gl.deleteBuffer(buffer); + + return this; + }, + + /* Rendering Functions */ + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#preRenderCamera + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + preRenderCamera: function (camera) + { + var resolution = this.config.resolution; + + var cx = Math.floor(camera.x * resolution); + var cy = Math.floor(camera.y * resolution); + var cw = Math.floor(camera.width * resolution); + var ch = Math.floor(camera.height * resolution); + + this.pushScissor(cx, cy, cw, ch); + + if (camera.backgroundColor.alphaGL > 0) + { + var color = camera.backgroundColor; + var FlatTintPipeline = this.pipelines.FlatTintPipeline; + + FlatTintPipeline.batchFillRect( + 0, 0, 1, 1, 0, + camera.x, camera.y, camera.width, camera.height, + Utils.getTintFromFloats(color.redGL, color.greenGL, color.blueGL, 1.0), + color.alphaGL, + 1, 0, 0, 1, 0, 0, + [ 1, 0, 0, 1, 0, 0 ] + ); + + FlatTintPipeline.flush(); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#postRenderCamera + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + postRenderCamera: function (camera) + { + if (camera._fadeAlpha > 0 || camera._flashAlpha > 0) + { + var FlatTintPipeline = this.pipelines.FlatTintPipeline; + + // Fade + FlatTintPipeline.batchFillRect( + 0, 0, 1, 1, 0, + camera.x, camera.y, camera.width, camera.height, + Utils.getTintFromFloats(camera._fadeRed, camera._fadeGreen, camera._fadeBlue, 1.0), + camera._fadeAlpha, + 1, 0, 0, 1, 0, 0, + [ 1, 0, 0, 1, 0, 0 ] + ); + + // Flash + FlatTintPipeline.batchFillRect( + 0, 0, 1, 1, 0, + camera.x, camera.y, camera.width, camera.height, + Utils.getTintFromFloats(camera._flashRed, camera._flashGreen, camera._flashBlue, 1.0), + camera._flashAlpha, + 1, 0, 0, 1, 0, 0, + [ 1, 0, 0, 1, 0, 0 ] + ); + + FlatTintPipeline.flush(); + } + + this.popScissor(); + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#preRender + * @since 3.0.0 + */ + preRender: function () + { + if (this.contextLost) { return; } + + var gl = this.gl; + var color = this.config.backgroundColor; + var pipelines = this.pipelines; + + // Bind custom framebuffer here + gl.clearColor(color.redGL, color.greenGL, color.blueGL, color.alphaGL); + + if (this.config.clearBeforeRender) + { + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT); + } + + for (var key in pipelines) + { + pipelines[key].onPreRender(); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#render + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.GameObjects.GameObject} children - [description] + * @param {number} interpolationPercentage - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + render: function (scene, children, interpolationPercentage, camera) + { + if (this.contextLost) { return; } + + var list = children.list; + var childCount = list.length; + var pipelines = this.pipelines; + + for (var key in pipelines) + { + pipelines[key].onRender(scene, camera); + } + + this.preRenderCamera(camera); + + for (var index = 0; index < childCount; ++index) + { + var child = list[index]; + + if (!child.willRender()) + { + continue; + } + + if (child.blendMode !== this.currentBlendMode) + { + this.setBlendMode(child.blendMode); + } + + if (child.mask) + { + child.mask.preRenderWebGL(this, child, camera); + } + + child.renderWebGL(this, child, interpolationPercentage, camera); + + if (child.mask) + { + child.mask.postRenderWebGL(this, child); + } + } + + this.flush(); + this.setBlendMode(CONST.BlendModes.NORMAL); + this.postRenderCamera(camera); + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#postRender + * @since 3.0.0 + */ + postRender: function () + { + if (this.contextLost) { return; } + + // Unbind custom framebuffer here + + if (this.snapshotState.callback) + { + this.snapshotState.callback(WebGLSnapshot(this.canvas, this.snapshotState.type, this.snapshotState.encoder)); + this.snapshotState.callback = null; + } + + var pipelines = this.pipelines; + + for (var key in pipelines) + { + pipelines[key].onPostRender(); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#snapshot + * @since 3.0.0 + * + * @param {SnapshotCallback} callback - [description] + * @param {string} type - [description] + * @param {float} encoderOptions - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + snapshot: function (callback, type, encoderOptions) + { + this.snapshotState.callback = callback; + this.snapshotState.type = type; + this.snapshotState.encoder = encoderOptions; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#canvasToTexture + * @since 3.0.0 + * + * @param {HTMLCanvasElement} srcCanvas - [description] + * @param {WebGLTexture} dstTexture - [description] + * @param {boolean} shouldReallocate - [description] + * @param {integer} scaleMode - [description] + * + * @return {WebGLTexture} [description] + */ + canvasToTexture: function (srcCanvas, dstTexture) + { + var gl = this.gl; + + if (!dstTexture) + { + var wrapping = gl.CLAMP_TO_EDGE; + + if (IsSizePowerOfTwo(srcCanvas.width, srcCanvas.height)) + { + wrapping = gl.REPEAT; + } + + dstTexture = this.createTexture2D(0, gl.NEAREST, gl.NEAREST, wrapping, wrapping, gl.RGBA, srcCanvas, srcCanvas.width, srcCanvas.height, true); + } + else + { + this.setTexture2D(dstTexture, 0); + + // if (!shouldReallocate && dstTexture.width >= srcCanvas.width || dstTexture.height >= srcCanvas.height) + // { + // gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, srcCanvas.width, srcCanvas.height, gl.RGBA, gl.UNSIGNED_BYTE, srcCanvas); + // } + // else + { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, srcCanvas); + dstTexture.width = srcCanvas.width; + dstTexture.height = srcCanvas.height; + } + + this.setTexture2D(null, 0); + } + + return dstTexture; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setTextureFilter + * @since 3.0.0 + * + * @param {integer} texture - [description] + * @param {integer} filter - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setTextureFilter: function (texture, filter) + { + var gl = this.gl; + var glFilter = [ gl.LINEAR, gl.NEAREST ][filter]; + + this.setTexture2D(texture, 0); + + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, glFilter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, glFilter); + + this.setTexture2D(null, 0); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat1 + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * @param {string} name - [description] + * @param {float} x - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setFloat1: function (program, name, x) + { + this.setProgram(program); + + this.gl.uniform1f(this.gl.getUniformLocation(program, name), x); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat2 + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * @param {string} name - [description] + * @param {float} x - [description] + * @param {float} y - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setFloat2: function (program, name, x, y) + { + this.setProgram(program); + + this.gl.uniform2f(this.gl.getUniformLocation(program, name), x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat3 + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * @param {string} name - [description] + * @param {float} x - [description] + * @param {float} y - [description] + * @param {float} z - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setFloat3: function (program, name, x, y, z) + { + this.setProgram(program); + + this.gl.uniform3f(this.gl.getUniformLocation(program, name), x, y, z); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat4 + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * @param {string} name - [description] + * @param {float} x - [description] + * @param {float} y - [description] + * @param {float} z - [description] + * @param {float} w - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setFloat4: function (program, name, x, y, z, w) + { + this.setProgram(program); + + this.gl.uniform4f(this.gl.getUniformLocation(program, name), x, y, z, w); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt1 + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * @param {string} name - [description] + * @param {integer} x - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setInt1: function (program, name, x) + { + this.setProgram(program); + + this.gl.uniform1i(this.gl.getUniformLocation(program, name), x); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt2 + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * @param {string} name - [description] + * @param {integer} x - [description] + * @param {integer} y - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setInt2: function (program, name, x, y) + { + this.setProgram(program); + + this.gl.uniform2i(this.gl.getUniformLocation(program, name), x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt3 + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * @param {string} name - [description] + * @param {integer} x - [description] + * @param {integer} y - [description] + * @param {integer} z - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setInt3: function (program, name, x, y, z) + { + this.setProgram(program); + + this.gl.uniform3i(this.gl.getUniformLocation(program, name), x, y, z); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt4 + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * @param {string} name - [description] + * @param {integer} x - [description] + * @param {integer} y - [description] + * @param {integer} z - [description] + * @param {integer} w - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setInt4: function (program, name, x, y, z, w) + { + this.setProgram(program); + + this.gl.uniform4i(this.gl.getUniformLocation(program, name), x, y, z, w); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix2 + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * @param {string} name - [description] + * @param {boolean} transpose - [description] + * @param {Float32Array} matrix - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setMatrix2: function (program, name, transpose, matrix) + { + this.setProgram(program); + + this.gl.uniformMatrix2fv(this.gl.getUniformLocation(program, name), transpose, matrix); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix3 + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * @param {string} name - [description] + * @param {boolean} transpose - [description] + * @param {Float32Array} matrix - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setMatrix3: function (program, name, transpose, matrix) + { + this.setProgram(program); + + this.gl.uniformMatrix3fv(this.gl.getUniformLocation(program, name), transpose, matrix); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix4 + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * @param {string} name - [description] + * @param {boolean} transpose - [description] + * @param {Float32Array} matrix - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setMatrix4: function (program, name, transpose, matrix) + { + this.setProgram(program); + + this.gl.uniformMatrix4fv(this.gl.getUniformLocation(program, name), transpose, matrix); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#destroy + * @since 3.0.0 + */ + destroy: function () + { + // Clear-up anything that should be cleared :) + for (var key in this.pipelines) + { + this.pipelines[key].destroy(); + delete this.pipelines[key]; + } + + for (var index = 0; index < this.nativeTextures.length; ++index) + { + this.deleteTexture(this.nativeTextures[index]); + delete this.nativeTextures[index]; + } + + if (this.hasExtension('WEBGL_lose_context')) + { + this.getExtension('WEBGL_lose_context').loseContext(); + } + + delete this.gl; + delete this.game; + + this.contextLost = true; + this.extensions = {}; + this.nativeTextures.length = 0; + } + +}); + +module.exports = WebGLRenderer; + + +/***/ }), /* 376 */ /***/ (function(module, exports, __webpack_require__) { -__webpack_require__(377); -__webpack_require__(378); -__webpack_require__(379); -__webpack_require__(380); -__webpack_require__(381); -__webpack_require__(382); -__webpack_require__(383); -__webpack_require__(384); -__webpack_require__(385); +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var modes = __webpack_require__(62); +var CanvasFeatures = __webpack_require__(302); + +/** + * [description] + * + * @function Phaser.Renderer.Canvas.GetBlendModes + * @since 3.0.0 + * + * @return {array} [description] + */ +var GetBlendModes = function () +{ + var output = []; + var useNew = CanvasFeatures.supportNewBlendModes; + + output[modes.NORMAL] = 'source-over'; + output[modes.ADD] = 'lighter'; + output[modes.MULTIPLY] = (useNew) ? 'multiply' : 'source-over'; + output[modes.SCREEN] = (useNew) ? 'screen' : 'source-over'; + output[modes.OVERLAY] = (useNew) ? 'overlay' : 'source-over'; + output[modes.DARKEN] = (useNew) ? 'darken' : 'source-over'; + output[modes.LIGHTEN] = (useNew) ? 'lighten' : 'source-over'; + output[modes.COLOR_DODGE] = (useNew) ? 'color-dodge' : 'source-over'; + output[modes.COLOR_BURN] = (useNew) ? 'color-burn' : 'source-over'; + output[modes.HARD_LIGHT] = (useNew) ? 'hard-light' : 'source-over'; + output[modes.SOFT_LIGHT] = (useNew) ? 'soft-light' : 'source-over'; + output[modes.DIFFERENCE] = (useNew) ? 'difference' : 'source-over'; + output[modes.EXCLUSION] = (useNew) ? 'exclusion' : 'source-over'; + output[modes.HUE] = (useNew) ? 'hue' : 'source-over'; + output[modes.SATURATION] = (useNew) ? 'saturation' : 'source-over'; + output[modes.COLOR] = (useNew) ? 'color' : 'source-over'; + output[modes.LUMINOSITY] = (useNew) ? 'luminosity' : 'source-over'; + + return output; +}; + +module.exports = GetBlendModes; /***/ }), @@ -76048,39 +76132,114 @@ __webpack_require__(385); /***/ (function(module, exports) { /** -* A polyfill for Array.forEach -* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach -*/ -if (!Array.prototype.forEach) + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var roundPixels = false; + +/** + * [description] + * + * @function Phaser.Renderer.Canvas.DrawImage + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} src - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ +var DrawImage = function (src, camera) { - Array.prototype.forEach = function (fun /*, thisArg */) + var ctx = this.currentContext; + var frame = src.frame; + var cd = frame.canvasData; + + // Blend Mode + + if (this.currentBlendMode !== src.blendMode) { - 'use strict'; + this.currentBlendMode = src.blendMode; + ctx.globalCompositeOperation = this.blendModes[src.blendMode]; + } - if (this === void 0 || this === null) - { - throw new TypeError(); - } + // Alpha - var t = Object(this); - var len = t.length >>> 0; + if (this.currentAlpha !== src.alpha) + { + this.currentAlpha = src.alpha; + ctx.globalAlpha = src.alpha; + } - if (typeof fun !== 'function') - { - throw new TypeError(); - } + // Smoothing - var thisArg = arguments.length >= 2 ? arguments[1] : void 0; + if (this.currentScaleMode !== src.scaleMode) + { + this.currentScaleMode = src.scaleMode; - for (var i = 0; i < len; i++) - { - if (i in t) - { - fun.call(thisArg, t[i], i, t); - } - } - }; -} + // ctx[this.smoothProperty] = (source.scaleMode === ScaleModes.LINEAR); + } + + var dx = frame.x; + var dy = frame.y; + + var fx = 1; + var fy = 1; + + if (src.flipX) + { + fx = -1; + dx -= cd.dWidth - src.displayOriginX; + } + else + { + dx -= src.displayOriginX; + } + + if (src.flipY) + { + fy = -1; + dy -= cd.dHeight - src.displayOriginY; + } + else + { + dy -= src.displayOriginY; + } + + var tx = src.x - camera.scrollX * src.scrollFactorX; + var ty = src.y - camera.scrollY * src.scrollFactorY; + + if (roundPixels) + { + tx |= 0; + ty |= 0; + dx |= 0; + dy |= 0; + } + + // Perform Matrix ITRS + + ctx.save(); + + ctx.translate(tx, ty); + + ctx.rotate(src.rotation); + + ctx.scale(src.scaleX, src.scaleY); + ctx.scale(fx, fy); + + ctx.drawImage(frame.source.image, cd.sx, cd.sy, cd.sWidth, cd.sHeight, dx, dy, cd.dWidth, cd.dHeight); + + ctx.restore(); +}; + +// Special return so we can store the config value locally + +module.exports = function (configRoundPixels) +{ + roundPixels = configRoundPixels; + + return DrawImage; +}; /***/ }), @@ -76088,278 +76247,1470 @@ if (!Array.prototype.forEach) /***/ (function(module, exports) { /** -* A polyfill for Array.isArray -*/ -if (!Array.isArray) + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Renderer.Snapshot.Canvas + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - [description] + * @param {string} [type='image/png'] - [description] + * @param {float} [encoderOptions=0.92] - [description] + * + * @return {HTMLImageElement} [description] + */ +var CanvasSnapshot = function (canvas, type, encoderOptions) { - Array.isArray = function (arg) - { - return Object.prototype.toString.call(arg) === '[object Array]'; - }; -} + if (type === undefined) { type = 'image/png'; } + if (encoderOptions === undefined) { encoderOptions = 0.92; } + + var src = canvas.toDataURL(type, encoderOptions); + + var image = new Image(); + + image.src = src; + + return image; +}; + +module.exports = CanvasSnapshot; /***/ }), /* 379 */ /***/ (function(module, exports) { -/* Copyright 2013 Chris Wilson +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at +var roundPixels = false; - http://www.apache.org/licenses/LICENSE-2.0 +/** + * No scaling, anchor, rotation or effects, literally draws the frame directly to the canvas. + * + * @function Phaser.Renderer.Canvas.BlitImage + * @since 3.0.0 + * + * @param {number} dx - The x coordinate to render the Frame to. + * @param {number} dy - The y coordinate to render the Frame to. + * @param {Phaser.Textures.Frame} frame - The Frame to render. + */ +var BlitImage = function (dx, dy, frame) +{ + var ctx = this.currentContext; + var cd = frame.canvasData; - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/* - -This monkeypatch library is intended to be included in projects that are -written to the proper AudioContext spec (instead of webkitAudioContext), -and that use the new naming and proper bits of the Web Audio API (e.g. -using BufferSourceNode.start() instead of BufferSourceNode.noteOn()), but may -have to run on systems that only support the deprecated bits. - -This library should be harmless to include if the browser supports -unprefixed "AudioContext", and/or if it supports the new names. - -The patches this library handles: -if window.AudioContext is unsupported, it will be aliased to webkitAudioContext(). -if AudioBufferSourceNode.start() is unimplemented, it will be routed to noteOn() or -noteGrainOn(), depending on parameters. - -The following aliases only take effect if the new names are not already in place: - -AudioBufferSourceNode.stop() is aliased to noteOff() -AudioContext.createGain() is aliased to createGainNode() -AudioContext.createDelay() is aliased to createDelayNode() -AudioContext.createScriptProcessor() is aliased to createJavaScriptNode() -AudioContext.createPeriodicWave() is aliased to createWaveTable() -OscillatorNode.start() is aliased to noteOn() -OscillatorNode.stop() is aliased to noteOff() -OscillatorNode.setPeriodicWave() is aliased to setWaveTable() -AudioParam.setTargetAtTime() is aliased to setTargetValueAtTime() - -This library does NOT patch the enumerated type changes, as it is -recommended in the specification that implementations support both integer -and string types for AudioPannerNode.panningModel, AudioPannerNode.distanceModel -BiquadFilterNode.type and OscillatorNode.type. - -*/ -(function (global, exports, perf) { - 'use strict'; - - function fixSetTarget(param) { - if (!param) // if NYI, just return - return; - if (!param.setTargetAtTime) - param.setTargetAtTime = param.setTargetValueAtTime; - } - - if (window.hasOwnProperty('webkitAudioContext') && - !window.hasOwnProperty('AudioContext')) { - window.AudioContext = webkitAudioContext; - - if (!AudioContext.prototype.hasOwnProperty('createGain')) - AudioContext.prototype.createGain = AudioContext.prototype.createGainNode; - if (!AudioContext.prototype.hasOwnProperty('createDelay')) - AudioContext.prototype.createDelay = AudioContext.prototype.createDelayNode; - if (!AudioContext.prototype.hasOwnProperty('createScriptProcessor')) - AudioContext.prototype.createScriptProcessor = AudioContext.prototype.createJavaScriptNode; - if (!AudioContext.prototype.hasOwnProperty('createPeriodicWave')) - AudioContext.prototype.createPeriodicWave = AudioContext.prototype.createWaveTable; - - - AudioContext.prototype.internal_createGain = AudioContext.prototype.createGain; - AudioContext.prototype.createGain = function() { - var node = this.internal_createGain(); - fixSetTarget(node.gain); - return node; - }; - - AudioContext.prototype.internal_createDelay = AudioContext.prototype.createDelay; - AudioContext.prototype.createDelay = function(maxDelayTime) { - var node = maxDelayTime ? this.internal_createDelay(maxDelayTime) : this.internal_createDelay(); - fixSetTarget(node.delayTime); - return node; - }; - - AudioContext.prototype.internal_createBufferSource = AudioContext.prototype.createBufferSource; - AudioContext.prototype.createBufferSource = function() { - var node = this.internal_createBufferSource(); - if (!node.start) { - node.start = function ( when, offset, duration ) { - if ( offset || duration ) - this.noteGrainOn( when || 0, offset, duration ); - else - this.noteOn( when || 0 ); - }; - } else { - node.internal_start = node.start; - node.start = function( when, offset, duration ) { - if( typeof duration !== 'undefined' ) - node.internal_start( when || 0, offset, duration ); - else - node.internal_start( when || 0, offset || 0 ); - }; - } - if (!node.stop) { - node.stop = function ( when ) { - this.noteOff( when || 0 ); - }; - } else { - node.internal_stop = node.stop; - node.stop = function( when ) { - node.internal_stop( when || 0 ); - }; - } - fixSetTarget(node.playbackRate); - return node; - }; - - AudioContext.prototype.internal_createDynamicsCompressor = AudioContext.prototype.createDynamicsCompressor; - AudioContext.prototype.createDynamicsCompressor = function() { - var node = this.internal_createDynamicsCompressor(); - fixSetTarget(node.threshold); - fixSetTarget(node.knee); - fixSetTarget(node.ratio); - fixSetTarget(node.reduction); - fixSetTarget(node.attack); - fixSetTarget(node.release); - return node; - }; - - AudioContext.prototype.internal_createBiquadFilter = AudioContext.prototype.createBiquadFilter; - AudioContext.prototype.createBiquadFilter = function() { - var node = this.internal_createBiquadFilter(); - fixSetTarget(node.frequency); - fixSetTarget(node.detune); - fixSetTarget(node.Q); - fixSetTarget(node.gain); - return node; - }; - - if (AudioContext.prototype.hasOwnProperty( 'createOscillator' )) { - AudioContext.prototype.internal_createOscillator = AudioContext.prototype.createOscillator; - AudioContext.prototype.createOscillator = function() { - var node = this.internal_createOscillator(); - if (!node.start) { - node.start = function ( when ) { - this.noteOn( when || 0 ); - }; - } else { - node.internal_start = node.start; - node.start = function ( when ) { - node.internal_start( when || 0); - }; - } - if (!node.stop) { - node.stop = function ( when ) { - this.noteOff( when || 0 ); - }; - } else { - node.internal_stop = node.stop; - node.stop = function( when ) { - node.internal_stop( when || 0 ); - }; - } - if (!node.setPeriodicWave) - node.setPeriodicWave = node.setWaveTable; - fixSetTarget(node.frequency); - fixSetTarget(node.detune); - return node; - }; + if (roundPixels) + { + dx |= 0; + dy |= 0; } - } - if (window.hasOwnProperty('webkitOfflineAudioContext') && - !window.hasOwnProperty('OfflineAudioContext')) { - window.OfflineAudioContext = webkitOfflineAudioContext; - } + ctx.drawImage( + frame.source.image, + cd.sx, + cd.sy, + cd.sWidth, + cd.sHeight, + dx, + dy, + cd.dWidth, + cd.dHeight + ); +}; -}(window)); +// Special return so we can store the config value locally +module.exports = function (configRoundPixels) +{ + roundPixels = configRoundPixels; + + return BlitImage; +}; /***/ }), /* 380 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** - * Also fix for the absent console in IE9 + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -if (!window.console) -{ - window.console = {}; - window.console.log = window.console.assert = function(){}; - window.console.warn = window.console.assert = function(){}; -} + +var BlitImage = __webpack_require__(379); +var CanvasSnapshot = __webpack_require__(378); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(21); +var DrawImage = __webpack_require__(377); +var GetBlendModes = __webpack_require__(376); +var ScaleModes = __webpack_require__(80); +var Smoothing = __webpack_require__(151); + +/** + * @classdesc + * [description] + * + * @class CanvasRenderer + * @memberOf Phaser.Renderer.Canvas + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Phaser Game instance that owns this renderer. + */ +var CanvasRenderer = new Class({ + + initialize: + + function CanvasRenderer (game) + { + /** + * The Phaser Game instance that owns this renderer. + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game = game; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#type + * @type {integer} + * @since 3.0.0 + */ + this.type = CONST.CANVAS; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#drawCount + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.drawCount = 0; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#width + * @type {number} + * @since 3.0.0 + */ + this.width = game.config.width; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#height + * @type {number} + * @since 3.0.0 + */ + this.height = game.config.height; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#config + * @type {RendererConfig} + * @since 3.0.0 + */ + this.config = { + clearBeforeRender: game.config.clearBeforeRender, + pixelArt: game.config.pixelArt, + backgroundColor: game.config.backgroundColor, + resolution: game.config.resolution, + autoResize: game.config.autoResize, + roundPixels: game.config.roundPixels + }; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#scaleMode + * @type {integer} + * @since 3.0.0 + */ + this.scaleMode = (game.config.pixelArt) ? ScaleModes.NEAREST : ScaleModes.LINEAR; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#gameCanvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.gameCanvas = game.canvas; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#gameContext + * @type {CanvasRenderingContext2D} + * @since 3.0.0 + */ + this.gameContext = this.gameCanvas.getContext('2d'); + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#currentContext + * @type {CanvasRenderingContext2D} + * @since 3.0.0 + */ + this.currentContext = this.gameContext; + + /** + * Map to the required function. + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#drawImage + * @type {Phaser.Renderer.Canvas.DrawImage} + * @since 3.0.0 + */ + this.drawImage = DrawImage(this.config.roundPixels); + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#blitImage + * @type {Phaser.Renderer.Canvas.BlitImage} + * @since 3.0.0 + */ + this.blitImage = BlitImage(this.config.roundPixels); + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#blendModes + * @type {array} + * @since 3.0.0 + */ + this.blendModes = GetBlendModes(); + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#currentAlpha + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.currentAlpha = 1; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#currentBlendMode + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.currentBlendMode = 0; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#currentScaleMode + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.currentScaleMode = 0; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotCallback + * @type {?SnapshotCallback} + * @default null + * @since 3.0.0 + */ + this.snapshotCallback = null; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotType + * @type {?string} + * @default null + * @since 3.0.0 + */ + this.snapshotType = null; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotEncoder + * @type {?number} + * @default null + * @since 3.0.0 + */ + this.snapshotEncoder = null; + + this.init(); + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#init + * @since 3.0.0 + */ + init: function () + { + this.resize(this.width, this.height); + }, + + /** + * Resize the main game canvas. + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#resize + * @since 3.0.0 + * + * @param {integer} width - [description] + * @param {integer} height - [description] + */ + resize: function (width, height) + { + var resolution = this.config.resolution; + + this.width = width * resolution; + this.height = height * resolution; + + this.gameCanvas.width = this.width; + this.gameCanvas.height = this.height; + + if (this.config.autoResize) + { + this.gameCanvas.style.width = (this.width / resolution) + 'px'; + this.gameCanvas.style.height = (this.height / resolution) + 'px'; + } + + // Resizing a canvas will reset imageSmoothingEnabled (and probably other properties) + if (this.scaleMode === ScaleModes.NEAREST) + { + Smoothing.disable(this.gameContext); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#onContextLost + * @since 3.0.0 + * + * @param {function} callback - [description] + */ + onContextLost: function () + { + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#onContextRestored + * @since 3.0.0 + * + * @param {function} callback - [description] + */ + onContextRestored: function () + { + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#resetTransform + * @since 3.0.0 + */ + resetTransform: function () + { + this.currentContext.setTransform(1, 0, 0, 1, 0, 0); + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#setBlendMode + * @since 3.0.0 + * + * @param {number} blendMode - [description] + * + * @return {number} [description] + */ + setBlendMode: function (blendMode) + { + if (this.currentBlendMode !== blendMode) + { + this.currentContext.globalCompositeOperation = blendMode; + this.currentBlendMode = blendMode; + } + + return this.currentBlendMode; + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#setAlpha + * @since 3.0.0 + * + * @param {float} alpha - [description] + * + * @return {float} [description] + */ + setAlpha: function (alpha) + { + if (this.currentAlpha !== alpha) + { + this.currentContext.globalAlpha = alpha; + this.currentAlpha = alpha; + } + + return this.currentAlpha; + }, + + /** + * Called at the start of the render loop. + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#preRender + * @since 3.0.0 + */ + preRender: function () + { + var ctx = this.gameContext; + var config = this.config; + + var width = this.width; + var height = this.height; + + if (config.clearBeforeRender) + { + ctx.clearRect(0, 0, width, height); + } + + if (!config.transparent) + { + ctx.fillStyle = config.backgroundColor.rgba; + ctx.fillRect(0, 0, width, height); + } + + this.drawCount = 0; + }, + + /** + * Renders the Scene to the given Camera. + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#render + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.GameObjects.DisplayList} children - [description] + * @param {float} interpolationPercentage - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + render: function (scene, children, interpolationPercentage, camera) + { + var ctx = scene.sys.context; + var scissor = (camera.x !== 0 || camera.y !== 0 || camera.width !== ctx.canvas.width || camera.height !== ctx.canvas.height); + var list = children.list; + var resolution = this.config.resolution; + + this.currentContext = ctx; + + // If the alpha or blend mode didn't change since the last render, then don't set them again (saves 2 ops) + + if (!camera.transparent) + { + ctx.fillStyle = camera.backgroundColor.rgba; + ctx.fillRect(camera.x, camera.y, camera.width, camera.height); + } + + if (this.currentAlpha !== 1) + { + ctx.globalAlpha = 1; + this.currentAlpha = 1; + } + + if (this.currentBlendMode !== 0) + { + ctx.globalCompositeOperation = 'source-over'; + this.currentBlendMode = 0; + } + + this.currentScaleMode = 0; + + this.drawCount += list.length; + + if (scissor) + { + ctx.save(); + ctx.beginPath(); + ctx.rect(camera.x * resolution, camera.y * resolution, camera.width * resolution, camera.height * resolution); + ctx.clip(); + } + + var matrix = camera.matrix.matrix; + + ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + + for (var c = 0; c < list.length; c++) + { + var child = list[c]; + + if (child.mask) + { + child.mask.preRenderCanvas(this, child, camera); + } + + child.renderCanvas(this, child, interpolationPercentage, camera); + + if (child.mask) + { + child.mask.postRenderCanvas(this, child, camera); + } + } + + ctx.setTransform(1, 0, 0, 1, 0, 0); + + if (camera._fadeAlpha > 0 || camera._flashAlpha > 0) + { + ctx.globalCompositeOperation = 'source-over'; + + // fade rendering + ctx.fillStyle = 'rgb(' + (camera._fadeRed * 255) + ',' + (camera._fadeGreen * 255) + ',' + (camera._fadeBlue * 255) + ')'; + ctx.globalAlpha = camera._fadeAlpha; + ctx.fillRect(camera.x, camera.y, camera.width, camera.height); + + // flash rendering + ctx.fillStyle = 'rgb(' + (camera._flashRed * 255) + ',' + (camera._flashGreen * 255) + ',' + (camera._flashBlue * 255) + ')'; + ctx.globalAlpha = camera._flashAlpha; + ctx.fillRect(camera.x, camera.y, camera.width, camera.height); + + ctx.globalAlpha = 1.0; + } + + // Reset the camera scissor + if (scissor) + { + ctx.restore(); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#postRender + * @since 3.0.0 + */ + postRender: function () + { + var ctx = this.gameContext; + + ctx.globalAlpha = 1; + ctx.globalCompositeOperation = 'source-over'; + + this.currentAlpha = 1; + this.currentBlendMode = 0; + + if (this.snapshotCallback) + { + this.snapshotCallback(CanvasSnapshot(this.gameCanvas, this.snapshotType, this.snapshotEncoder)); + this.snapshotCallback = null; + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#snapshot + * @since 3.0.0 + * + * @param {SnapshotCallback} callback - [description] + * @param {string} type - [description] + * @param {number} encoderOptions - [description] + */ + snapshot: function (callback, type, encoderOptions) + { + this.snapshotCallback = callback; + this.snapshotType = type; + this.snapshotEncoder = encoderOptions; + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.gameCanvas = null; + this.gameContext = null; + + this.game = null; + } + +}); + +module.exports = CanvasRenderer; /***/ }), /* 381 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** -* A polyfill for Function.prototype.bind -*/ -if (!Function.prototype.bind) { + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ - /* jshint freeze: false */ - Function.prototype.bind = (function () { +var Class = __webpack_require__(0); - var slice = Array.prototype.slice; +/** + * @classdesc + * A Game Object Animation Controller. + * + * This controller lives as an instance within a Game Object, accessible as `sprite.anims`. + * + * @class Animation + * @memberOf Phaser.GameObjects.Components + * @constructor + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} parent - The Game Object to which this animation controller belongs. + */ +var Animation = new Class({ - return function (thisArg) { + initialize: - var target = this, boundArgs = slice.call(arguments, 1); + function Animation (parent) + { + /** + * The Game Object to which this animation controller belongs. + * + * @name Phaser.GameObjects.Components.Animation#parent + * @type {Phaser.GameObjects.GameObject} + * @since 3.0.0 + */ + this.parent = parent; - if (typeof target !== 'function') + /** + * A reference to the global Animation Manager. + * + * @name Phaser.GameObjects.Components.Animation#animationManager + * @type {Phaser.Animations.AnimationManager} + * @since 3.0.0 + */ + this.animationManager = parent.scene.sys.anims; + + this.animationManager.once('remove', this.remove, this); + + /** + * Is an animation currently playing or not? + * + * @name Phaser.GameObjects.Components.Animation#isPlaying + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isPlaying = false; + + // Reference to the Phaser.Animation object + + /** + * The current Animation loaded into this Animation Controller. + * + * @name Phaser.GameObjects.Components.Animation#currentAnim + * @type {?Phaser.Animations.Animation} + * @default null + * @since 3.0.0 + */ + this.currentAnim = null; + + /** + * The current AnimationFrame being displayed by this Animation Controller. + * + * @name Phaser.GameObjects.Components.Animation#currentFrame + * @type {?Phaser.Animations.AnimationFrame} + * @default null + * @since 3.0.0 + */ + this.currentFrame = null; + + /** + * Time scale factor. + * + * @name Phaser.GameObjects.Components.Animation#_timeScale + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + this._timeScale = 1; + + /** + * The frame rate of playback in frames per second. + * The default is 24 if the `duration` property is `null`. + * + * @name Phaser.GameObjects.Components.Animation#frameRate + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.frameRate = 0; + + /** + * How long the animation should play for. + * If the `frameRate` property has been set then it overrides this value, + * otherwise frameRate is derived from `duration`. + * + * @name Phaser.GameObjects.Components.Animation#duration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.duration = 0; + + /** + * ms per frame, not including frame specific modifiers that may be present in the Animation data. + * + * @name Phaser.GameObjects.Components.Animation#msPerFrame + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.msPerFrame = 0; + + /** + * Skip frames if the time lags, or always advanced anyway? + * + * @name Phaser.GameObjects.Components.Animation#skipMissedFrames + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.skipMissedFrames = true; + + /** + * A delay before starting playback, in seconds. + * + * @name Phaser.GameObjects.Components.Animation#_delay + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._delay = 0; + + /** + * Number of times to repeat the animation (-1 for infinity) + * + * @name Phaser.GameObjects.Components.Animation#_repeat + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._repeat = 0; + + /** + * Delay before the repeat starts, in seconds. + * + * @name Phaser.GameObjects.Components.Animation#_repeatDelay + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._repeatDelay = 0; + + /** + * Should the animation yoyo? (reverse back down to the start) before repeating? + * + * @name Phaser.GameObjects.Components.Animation#_yoyo + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._yoyo = false; + + /** + * Will the playhead move forwards (`true`) or in reverse (`false`) + * + * @name Phaser.GameObjects.Components.Animation#forward + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.forward = true; + + /** + * Internal time overflow accumulator. + * + * @name Phaser.GameObjects.Components.Animation#accumulator + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accumulator = 0; + + /** + * The time point at which the next animation frame will change. + * + * @name Phaser.GameObjects.Components.Animation#nextTick + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.nextTick = 0; + + /** + * An internal counter keeping track of how many repeats are left to play. + * + * @name Phaser.GameObjects.Components.Animation#repeatCounter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.repeatCounter = 0; + + /** + * An internal flag keeping track of pending repeats. + * + * @name Phaser.GameObjects.Components.Animation#pendingRepeat + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.pendingRepeat = false; + + /** + * Is the Animation paused? + * + * @name Phaser.GameObjects.Components.Animation#_paused + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._paused = false; + + /** + * Was the animation previously playing before being paused? + * + * @name Phaser.GameObjects.Components.Animation#_wasPlaying + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._wasPlaying = false; + + /** + * Container for the callback arguments. + * + * @name Phaser.GameObjects.Components.Animation#_callbackArgs + * @type {array} + * @private + * @since 3.0.0 + */ + this._callbackArgs = [ parent, null ]; + + /** + * Container for the update arguments. + * + * @name Phaser.GameObjects.Components.Animation#_updateParams + * @type {array} + * @private + * @since 3.0.0 + */ + this._updateParams = []; + }, + + /** + * Sets the amount of time, in seconds that the animation will be delayed before starting playback. + * + * @method Phaser.GameObjects.Components.Animation#delay + * @since 3.0.0 + * + * @param {number} value - The amount of time, in seconds, to wait before starting playback. + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + delay: function (value) + { + if (value === undefined) + { + return this._delay; + } + else + { + this._delay = value; + + return this; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#delayedPlay + * @since 3.0.0 + * + * @param {number} delay - [description] + * @param {string} key - [description] + * @param {integer} startFrame - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + delayedPlay: function (delay, key, startFrame) + { + this.play(key, true, startFrame); + + this.nextTick += (delay * 1000); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#getCurrentKey + * @since 3.0.0 + * + * @return {string} [description] + */ + getCurrentKey: function () + { + if (this.currentAnim) + { + return this.currentAnim.key; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#load + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {integer} [startFrame=0] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + load: function (key, startFrame) + { + if (startFrame === undefined) { startFrame = 0; } + + if (this.isPlaying) + { + this.stop(); + } + + // Load the new animation in + this.animationManager.load(this, key, startFrame); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#pause + * @since 3.0.0 + * + * @param {Phaser.Animations.Animation} [atFrame] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + pause: function (atFrame) + { + if (!this._paused) + { + this._paused = true; + this._wasPlaying = this.isPlaying; + this.isPlaying = false; + } + + if (atFrame !== undefined) + { + this.updateFrame(atFrame); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#paused + * @since 3.0.0 + * + * @param {boolean} [value] - [description] + * + * @return {(boolean|Phaser.GameObjects.GameObject)} [description] + */ + paused: function (value) + { + if (value !== undefined) + { + // Setter + if (value) { - throw new TypeError(); + return this.pause(); + } + else + { + return this.resume(); + } + } + else + { + return this._paused; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#play + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {boolean} [ignoreIfPlaying=false] - [description] + * @param {integer} [startFrame=0] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + play: function (key, ignoreIfPlaying, startFrame) + { + if (ignoreIfPlaying === undefined) { ignoreIfPlaying = false; } + if (startFrame === undefined) { startFrame = 0; } + + if (ignoreIfPlaying && this.isPlaying && this.currentAnim.key === key) + { + return this; + } + + this.load(key, startFrame); + + var anim = this.currentAnim; + var gameObject = this.parent; + + // Should give us 9,007,199,254,740,991 safe repeats + this.repeatCounter = (this._repeat === -1) ? Number.MAX_VALUE : this._repeat; + + anim.getFirstTick(this); + + this.forward = true; + this.isPlaying = true; + this.pendingRepeat = false; + + if (anim.showOnStart) + { + gameObject.visible = true; + } + + if (anim.onStart) + { + anim.onStart.apply(anim.callbackScope, this._callbackArgs.concat(anim.onStartParams)); + } + + gameObject.setSizeToFrame(); + gameObject.updateDisplayOrigin(); + + return this; + }, + + /** + * Value between 0 and 1. How far this animation is through, ignoring repeats and yoyos. + * If the animation has a non-zero repeat defined, progress and totalProgress will be different + * because progress doesn't include any repeats or repeatDelays whereas totalProgress does. + * + * @method Phaser.GameObjects.Components.Animation#progress + * @since 3.0.0 + * + * @param {number} [value] - [description] + * + * @return {(number|Phaser.GameObjects.GameObject)} [description] + */ + progress: function (value) + { + if (value === undefined) + { + var p = this.currentFrame.progress; + + if (!this.forward) + { + p = 1 - p; } - function bound() { - var args = boundArgs.concat(slice.call(arguments)); - target.apply(this instanceof bound ? this : thisArg, args); + return p; + } + else + { + // TODO: Set progress + + return this; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#remove + * @since 3.0.0 + * + * @param {Phaser.Animations.Animation} [event] - [description] + */ + remove: function (event) + { + if (event === undefined) { event = this.currentAnim; } + + if (this.isPlaying && event.key === this.currentAnim.key) + { + this.stop(); + + var sprite = this.parent; + var frame = this.currentAnim.frames[0]; + + this.currentFrame = frame; + + sprite.texture = frame.frame.texture; + sprite.frame = frame.frame; + } + }, + + /** + * Gets or sets the number of times that the animation should repeat + * after its first iteration. For example, if repeat is 1, the animation will + * play a total of twice (the initial play plus 1 repeat). + * To repeat indefinitely, use -1. repeat should always be an integer. + * + * @method Phaser.GameObjects.Components.Animation#repeat + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {(number|Phaser.GameObjects.GameObject)} [description] + */ + repeat: function (value) + { + if (value === undefined) + { + return this._repeat; + } + else + { + this._repeat = value; + this.repeatCounter = 0; + + return this; + } + }, + + /** + * Gets or sets the amount of time in seconds between repeats. + * For example, if repeat is 2 and repeatDelay is 1, the animation will play initially, + * then wait for 1 second before it repeats, then play again, then wait 1 second again + * before doing its final repeat. + * + * @method Phaser.GameObjects.Components.Animation#repeatDelay + * @since 3.0.0 + * + * @param {number} [value] - [description] + * + * @return {(number|Phaser.GameObjects.GameObject)} [description] + */ + repeatDelay: function (value) + { + if (value === undefined) + { + return this._repeatDelay; + } + else + { + this._repeatDelay = value; + + return this; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#restart + * @since 3.0.0 + * + * @param {boolean} [includeDelay=false] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + restart: function (includeDelay) + { + if (includeDelay === undefined) { includeDelay = false; } + + this.currentAnim.getFirstTick(this, includeDelay); + + this.forward = true; + this.isPlaying = true; + this.pendingRepeat = false; + this._paused = false; + + // Set frame + this.updateFrame(this.currentAnim.frames[0]); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#resume + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationFrame} fromFrame - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + resume: function (fromFrame) + { + if (this._paused) + { + this._paused = false; + this.isPlaying = this._wasPlaying; + } + + if (fromFrame !== undefined) + { + this.updateFrame(fromFrame); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#stop + * @since 3.0.0 + * + * @param {boolean} [dispatchCallbacks=false] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + stop: function (dispatchCallbacks) + { + if (dispatchCallbacks === undefined) { dispatchCallbacks = false; } + + this.isPlaying = false; + + var anim = this.currentAnim; + + if (dispatchCallbacks && anim.onComplete) + { + anim.onComplete.apply(anim.callbackScope, this._callbackArgs.concat(anim.onCompleteParams)); + } + + return this; + }, + + /** + * Scale the time (make it go faster / slower) + * Factor that's used to scale time where 1 = normal speed (the default), 0.5 = half speed, 2 = double speed, etc. + * + * @method Phaser.GameObjects.Components.Animation#timeScale + * @since 3.0.0 + * + * @param {number} [value] - [description] + * + * @return {(number|Phaser.GameObjects.GameObject)} [description] + */ + timeScale: function (value) + { + if (value === undefined) + { + return this._timeScale; + } + else + { + this._timeScale = value; + + return this; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#totalFrames + * @since 3.0.0 + * + * @return {number} [description] + */ + totalFrames: function () + { + return this.currentAnim.frames.length; + }, + + // Value between 0 and 1. How far this animation is through, including things like delays + // repeats, custom frame durations, etc. If the animation is set to repeat -1 it can never + // have a duration, therefore this will return -1. + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#totalProgres + * @since 3.0.0 + */ + totalProgres: function () + { + // TODO + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#update + * @since 3.0.0 + * + * @param {number} timestamp - [description] + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + update: function (timestamp, delta) + { + if (!this.isPlaying || this.currentAnim.paused) + { + return; + } + + this.accumulator += delta * this._timeScale; + + if (this.accumulator >= this.nextTick) + { + this.currentAnim.setFrame(this); + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#updateFrame + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationFrame} animationFrame - [description] + */ + updateFrame: function (animationFrame) + { + var sprite = this.parent; + + this.currentFrame = animationFrame; + + sprite.texture = animationFrame.frame.texture; + sprite.frame = animationFrame.frame; + + if (this.isPlaying) + { + if (animationFrame.setAlpha) + { + sprite.alpha = animationFrame.alpha; } - bound.prototype = (function F(proto) { - if (proto) - { - F.prototype = proto; - } + var anim = this.currentAnim; - if (!(this instanceof F)) - { - /* jshint supernew: true */ - return new F; - } - })(target.prototype); + if (anim.onUpdate) + { + anim.onUpdate.apply(anim.callbackScope, this._updateParams); + } - return bound; - }; - })(); -} + if (animationFrame.onUpdate) + { + animationFrame.onUpdate(sprite, animationFrame); + } + } + }, + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#yoyo + * @since 3.0.0 + * + * @param {boolean} [value] - [description] + * + * @return {(boolean|Phaser.GameObjects.GameObject)} [description] + */ + yoyo: function (value) + { + if (value === undefined) + { + return this._yoyo; + } + else + { + this._yoyo = value; + + return this; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#destroy + * @since 3.0.0 + */ + destroy: function () + { + // TODO + } + +}); + +module.exports = Animation; /***/ }), /* 382 */ /***/ (function(module, exports) { -// ES6 Math.trunc - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc -if (!Math.trunc) { - Math.trunc = function trunc(x) { - return x < 0 ? Math.ceil(x) : Math.floor(x); - }; -} +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes the given string and reverses it, returning the reversed string. + * For example if given the string `Atari 520ST` it would return `TS025 iratA`. + * + * @function Phaser.Utils.String.ReverseString + * @since 3.0.0 + * + * @param {string} string - The string to be reversed. + * + * @return {string} The reversed string. + */ +var ReverseString = function (string) +{ + return string.split('').reverse().join(''); +}; + +module.exports = ReverseString; /***/ }), @@ -76367,161 +77718,101 @@ if (!Math.trunc) { /***/ (function(module, exports) { /** - * performance.now + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -(function () { - if ('performance' in window === false) +/** + * Takes a string and replaces instances of markers with values in the given array. + * The markers take the form of `%1`, `%2`, etc. I.e.: + * + * `Format("The %1 is worth %2 gold", [ 'Sword', 500 ])` + * + * @function Phaser.Utils.String.Format + * @since 3.0.0 + * + * @param {string} string - The string containing the replacement markers. + * @param {array} values - An array containing values that will replace the markers. If no value exists an empty string is inserted instead. + * + * @return {string} The string containing replaced values. + */ +var Format = function (string, values) +{ + return string.replace(/%([0-9]+)/g, function (s, n) { - window.performance = {}; - } - - // Thanks IE8 - Date.now = (Date.now || function () { - return new Date().getTime(); + return values[Number(n) - 1]; }); +}; - if ('now' in window.performance === false) - { - var nowOffset = Date.now(); - - if (performance.timing && performance.timing.navigationStart) - { - nowOffset = performance.timing.navigationStart; - } - - window.performance.now = function now () - { - return Date.now() - nowOffset; - } - } - -})(); +module.exports = Format; /***/ }), /* 384 */ /***/ (function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(global) {// References: -// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ -// https://gist.github.com/1579671 -// http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision -// https://gist.github.com/timhall/4078614 -// https://github.com/Financial-Times/polyfill-service/tree/master/polyfills/requestAnimationFrame +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ -// Expected to be used with Browserfiy -// Browserify automatically detects the use of `global` and passes the -// correct reference of `global`, `self`, and finally `window` +/** + * @namespace Phaser.Utils.String + */ -// Date.now -if (!(Date.now && Date.prototype.getTime)) { - Date.now = function now() { - return new Date().getTime(); - }; -} +module.exports = { -// performance.now -if (!(global.performance && global.performance.now)) { - var startTime = Date.now(); - if (!global.performance) { - global.performance = {}; - } - global.performance.now = function () { - return Date.now() - startTime; - }; -} + Format: __webpack_require__(383), + Pad: __webpack_require__(158), + Reverse: __webpack_require__(382), + UppercaseFirst: __webpack_require__(285) -// requestAnimationFrame -var lastTime = Date.now(); -var vendors = ['ms', 'moz', 'webkit', 'o']; +}; -for(var x = 0; x < vendors.length && !global.requestAnimationFrame; ++x) { - global.requestAnimationFrame = global[vendors[x] + 'RequestAnimationFrame']; - global.cancelAnimationFrame = global[vendors[x] + 'CancelAnimationFrame'] || - global[vendors[x] + 'CancelRequestAnimationFrame']; -} - -if (!global.requestAnimationFrame) { - global.requestAnimationFrame = function (callback) { - if (typeof callback !== 'function') { - throw new TypeError(callback + 'is not a function'); - } - - var currentTime = Date.now(), - delay = 16 + lastTime - currentTime; - - if (delay < 0) { - delay = 0; - } - - lastTime = currentTime; - - return setTimeout(function () { - lastTime = Date.now(); - callback(performance.now()); - }, delay); - }; -} - -if (!global.cancelAnimationFrame) { - global.cancelAnimationFrame = function(id) { - clearTimeout(id); - }; -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(169))) /***/ }), /* 385 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** -* Low-budget Float32Array knock-off, suitable for use with P2.js in IE9 -* Source: http://www.html5gamedevs.com/topic/5988-phaser-12-ie9/ -* Cameron Foale (http://www.kibibu.com) -*/ -if (typeof window.Uint32Array !== "function" && typeof window.Uint32Array !== "object") + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clone = __webpack_require__(55); + +/** + * Creates a new Object using all values from obj1. + * + * Then scans obj2. If a property is found in obj2 that *also* exists in obj1, the value from obj2 is used, otherwise the property is skipped. + * + * @function Phaser.Utils.Object.MergeRight + * @since 3.0.0 + * + * @param {object} obj1 - [description] + * @param {object} obj2 - [description] + * + * @return {object} [description] + */ +var MergeRight = function (obj1, obj2) { - var CheapArray = function(type) + var clone = Clone(obj1); + + for (var key in obj2) { - var proto = new Array(); // jshint ignore:line + if (clone.hasOwnProperty(key)) + { + clone[key] = obj2[key]; + } + } - window[type] = function(arg) { + return clone; +}; - if (typeof(arg) === "number") - { - Array.call(this, arg); - this.length = arg; - - for (var i = 0; i < this.length; i++) - { - this[i] = 0; - } - } - else - { - Array.call(this, arg.length); - - this.length = arg.length; - - for (var i = 0; i < this.length; i++) - { - this[i] = arg[i]; - } - } - }; - - window[type].prototype = proto; - window[type].constructor = window[type]; - }; - - CheapArray('Float32Array'); // jshint ignore:line - CheapArray('Uint32Array'); // jshint ignore:line - CheapArray('Uint16Array'); // jshint ignore:line - CheapArray('Int16Array'); // jshint ignore:line - CheapArray('ArrayBuffer'); // jshint ignore:line -} +module.exports = MergeRight; /***/ }), @@ -76537,30 +77828,33 @@ if (typeof window.Uint32Array !== "function" && typeof window.Uint32Array !== "o /** * [description] * - * @function Phaser.Actions.Angle + * @function Phaser.Utils.Object.HasAll * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] * - * @return {array} The array of Game Objects that was passed to this Action. + * @param {object} source - [description] + * @param {string[]} keys - [description] + * + * @return {boolean} [description] */ -var Angle = function (items, value) +var HasAll = function (source, keys) { - for (var i = 0; i < items.length; i++) + for (var i = 0; i < keys.length; i++) { - items[i].angle += value; + if (!source.hasOwnProperty(keys[i])) + { + return false; + } } - return items; + return true; }; -module.exports = Angle; +module.exports = HasAll; /***/ }), /* 387 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -76568,36 +77862,38 @@ module.exports = Angle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var GetValue = __webpack_require__(5); +var Clamp = __webpack_require__(64); + /** * [description] * - * @function Phaser.Actions.Call + * @function Phaser.Utils.Object.GetMinMaxValue * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {function} callback - [description] - * @param {object} thisArg - [description] * - * @return {array} The array of Game Objects that was passed to this Action. + * @param {object} source - [description] + * @param {string} key - [description] + * @param {number} min - [description] + * @param {number} max - [description] + * @param {number} defaultValue - [description] + * + * @return {number} [description] */ -var Call = function (items, callback, thisArg) +var GetMinMaxValue = function (source, key, min, max, defaultValue) { - for (var i = 0; i < items.length; i++) - { - var item = items[i]; + if (defaultValue === undefined) { defaultValue = min; } - callback.call(thisArg, item); - } + var value = GetValue(source, key, defaultValue); - return items; + return Clamp(value, min, max); }; -module.exports = Call; +module.exports = GetMinMaxValue; /***/ }), /* 388 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -76605,51 +77901,27 @@ module.exports = Call; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// compare = Object: -// { -// scaleX: 0.5, -// scaleY: 1 -// } - /** - * [description] - * - * @function Phaser.Actions.GetFirst - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {object} compare - [description] - * @param {integer} index - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. + * @namespace Phaser.Utils.Object */ -var GetFirst = function (items, compare, index) -{ - for (var i = index; i < items.length; i++) - { - var item = items[i]; - var match = true; +module.exports = { - for (var property in compare) - { - if (item[property] !== compare[property]) - { - match = false; - } - } + Clone: __webpack_require__(55), + Extend: __webpack_require__(18), + GetAdvancedValue: __webpack_require__(8), + GetFastValue: __webpack_require__(2), + GetMinMaxValue: __webpack_require__(387), + GetValue: __webpack_require__(5), + HasAll: __webpack_require__(386), + HasAny: __webpack_require__(250), + HasValue: __webpack_require__(70), + IsPlainObject: __webpack_require__(368), + Merge: __webpack_require__(107), + MergeRight: __webpack_require__(385) - if (match) - { - return item; - } - } - - return null; }; -module.exports = GetFirst; - /***/ }), /* 389 */ @@ -76661,108 +77933,32 @@ module.exports = GetFirst; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var AlignIn = __webpack_require__(172); -var CONST = __webpack_require__(173); -var GetValue = __webpack_require__(4); -var NOOP = __webpack_require__(3); -var Zone = __webpack_require__(77); - -var tempZone = new Zone({ sys: { queueDepthSort: NOOP }}, 0, 0, 1, 1); +var SpliceOne = __webpack_require__(176); /** - * [description] + * Removes a random object from the given array and returns it. + * Will return null if there are no array items that fall within the specified range or if there is no item for the randomly chosen index. * - * @function Phaser.Actions.GridAlign + * @function Phaser.Utils.Array.RemoveRandomElement * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {object} options - [description] * - * @return {array} The array of Game Objects that was passed to this Action. + * @param {array} array - The array to removed a random element from. + * @param {integer} [start=0] - The array index to start the search from. + * @param {integer} [length=array.length] - Optional restriction on the number of elements to randomly select from. + * + * @return {object} The random element that was removed, or `null` if there were no array elements that fell within the given range. */ -var GridAlign = function (items, options) +var RemoveRandomElement = function (array, start, length) { - var width = GetValue(options, 'width', -1); - var height = GetValue(options, 'height', -1); - var cellWidth = GetValue(options, 'cellWidth', 1); - var cellHeight = GetValue(options, 'cellHeight', cellWidth); - var position = GetValue(options, 'position', CONST.TOP_LEFT); - var x = GetValue(options, 'x', 0); - var y = GetValue(options, 'y', 0); + if (start === undefined) { start = 0; } + if (length === undefined) { length = array.length; } - // var centerX = GetValue(options, 'centerX', null); - // var centerY = GetValue(options, 'centerY', null); + var randomIndex = start + Math.floor(Math.random() * length); - var cx = 0; - var cy = 0; - var w = (width * cellWidth); - var h = (height * cellHeight); - - // If the Grid is centered on a position then we need to calculate it now - // if (centerX !== null && centerY !== null) - // { - // - // } - - tempZone.setPosition(x, y); - tempZone.setSize(cellWidth, cellHeight); - - for (var i = 0; i < items.length; i++) - { - AlignIn(items[i], tempZone, position); - - if (width === -1) - { - // We keep laying them out horizontally until we've done them all - cy += cellHeight; - tempZone.y += cellHeight; - - if (cy === h) - { - cy = 0; - tempZone.x += cellWidth; - tempZone.y = y; - } - } - else if (height === -1) - { - // We keep laying them out vertically until we've done them all - cx += cellWidth; - tempZone.x += cellWidth; - - if (cx === w) - { - cx = 0; - tempZone.x = x; - tempZone.y += cellHeight; - } - } - else - { - // We keep laying them out until we hit the column limit - cx += cellWidth; - tempZone.x += cellWidth; - - if (cx === w) - { - cx = 0; - cy += cellHeight; - tempZone.x = x; - tempZone.y += cellHeight; - - if (cy === h) - { - // We've hit the column limit, so return, even if there are items left - break; - } - } - } - } - - return items; + return SpliceOne(array, randomIndex); }; -module.exports = GridAlign; +module.exports = RemoveRandomElement; /***/ }), @@ -76775,456 +77971,71 @@ module.exports = GridAlign; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); +var RoundAwayFromZero = __webpack_require__(216); /** - * @classdesc - * [description] + * Create an array of numbers (positive and/or negative) progressing from `start` + * up to but not including `end` by advancing by `step`. * - * @class RandomDataGenerator - * @memberOf Phaser.Math - * @constructor + * If `start` is less than `end` a zero-length range is created unless a negative `step` is specified. + * + * Certain values for `start` and `end` (eg. NaN/undefined/null) are currently coerced to 0; + * for forward compatibility make sure to pass in actual numbers. + * + * @example + * NumberArrayStep(4); + * // => [0, 1, 2, 3] + * + * NumberArrayStep(1, 5); + * // => [1, 2, 3, 4] + * + * NumberArrayStep(0, 20, 5); + * // => [0, 5, 10, 15] + * + * NumberArrayStep(0, -4, -1); + * // => [0, -1, -2, -3] + * + * NumberArrayStep(1, 4, 0); + * // => [1, 1, 1] + * + * NumberArrayStep(0); + * // => [] + * + * @function Phaser.Utils.Array.NumberArrayStep * @since 3.0.0 * - * @param {array} [seeds] - [description] + * @param {number} [start=0] - The start of the range. + * @param {number} [end=null] - The end of the range. + * @param {number} [step=1] - The value to increment or decrement by. + * + * @return {number[]} [description] */ -var RandomDataGenerator = new Class({ +var NumberArrayStep = function (start, end, step) +{ + if (start === undefined) { start = 0; } + if (end === undefined) { end = null; } + if (step === undefined) { step = 1; } - initialize: - - function RandomDataGenerator (seeds) + if (end === null) { - /** - * Internal var. - * - * @name Phaser.Math.RandomDataGenerator#c - * @type {number} - * @default 1 - * @private - * @since 3.0.0 - */ - this.c = 1; - - /** - * Internal var. - * - * @name Phaser.Math.RandomDataGenerator#s0 - * @type {number} - * @default 0 - * @private - * @since 3.0.0 - */ - this.s0 = 0; - - /** - * Internal var. - * - * @name Phaser.Math.RandomDataGenerator#s1 - * @type {number} - * @default 0 - * @private - * @since 3.0.0 - */ - this.s1 = 0; - - /** - * Internal var. - * - * @name Phaser.Math.RandomDataGenerator#s2 - * @type {number} - * @default 0 - * @private - * @since 3.0.0 - */ - this.s2 = 0; - - /** - * Internal var. - * - * @name Phaser.Math.RandomDataGenerator#n - * @type {number} - * @default 0 - * @private - * @since 3.2.0 - */ - this.n = 0; - - /** - * [description] - * - * @name Phaser.Math.RandomDataGenerator#sign - * @type {array} - * @since 3.0.0 - */ - this.signs = [ -1, 1 ]; - - if (seeds) - { - this.init(seeds); - } - }, - - /** - * Private random helper. - * - * @method Phaser.Math.RandomDataGenerator#rnd - * @since 3.0.0 - * @private - * - * @return {number} [description] - */ - rnd: function () - { - var t = 2091639 * this.s0 + this.c * 2.3283064365386963e-10; // 2^-32 - - this.c = t | 0; - this.s0 = this.s1; - this.s1 = this.s2; - this.s2 = t - this.c; - - return this.s2; - }, - - /** - * Internal method that creates a seed hash. - * - * @method Phaser.Math.RandomDataGenerator#hash - * @since 3.0.0 - * @private - * - * @param {[type]} data - [description] - * - * @return {number} The hashed value. - */ - hash: function (data) - { - var h; - var n = this.n; - - data = data.toString(); - - for (var i = 0; i < data.length; i++) - { - n += data.charCodeAt(i); - h = 0.02519603282416938 * n; - n = h >>> 0; - h -= n; - h *= n; - n = h >>> 0; - h -= n; - n += h * 0x100000000;// 2^32 - } - - this.n = n; - - return (n >>> 0) * 2.3283064365386963e-10;// 2^-32 - }, - - /** - * [description] - * - * @method Phaser.Math.RandomDataGenerator#init - * @since 3.0.0 - * - * @param {string|array} seeds - [description] - */ - init: function (seeds) - { - if (typeof seeds === 'string') - { - this.state(seeds); - } - else - { - this.sow(seeds); - } - }, - - /** - * Reset the seed of the random data generator. - * - * _Note_: the seed array is only processed up to the first `undefined` (or `null`) value, should such be present. - * - * @method Phaser.Math.RandomDataGenerator#sow - * @since 3.0.0 - * - * @param {any[]} seeds - The array of seeds: the `toString()` of each value is used. - */ - sow: function (seeds) - { - // Always reset to default seed - this.n = 0xefc8249d; - this.s0 = this.hash(' '); - this.s1 = this.hash(' '); - this.s2 = this.hash(' '); - this.c = 1; - - if (!seeds) - { - return; - } - - // Apply any seeds - for (var i = 0; i < seeds.length && (seeds[i] != null); i++) - { - var seed = seeds[i]; - - this.s0 -= this.hash(seed); - this.s0 += ~~(this.s0 < 0); - this.s1 -= this.hash(seed); - this.s1 += ~~(this.s1 < 0); - this.s2 -= this.hash(seed); - this.s2 += ~~(this.s2 < 0); - } - }, - - /** - * Returns a random integer between 0 and 2^32. - * - * @method Phaser.Math.RandomDataGenerator#integer - * @since 3.0.0 - * - * @return {number} A random integer between 0 and 2^32. - */ - integer: function () - { - // 2^32 - return this.rnd() * 0x100000000; - }, - - /** - * Returns a random real number between 0 and 1. - * - * @method Phaser.Math.RandomDataGenerator#frac - * @since 3.0.0 - * - * @return {number} A random real number between 0 and 1. - */ - frac: function () - { - // 2^-53 - return this.rnd() + (this.rnd() * 0x200000 | 0) * 1.1102230246251565e-16; - }, - - /** - * Returns a random real number between 0 and 2^32. - * - * @method Phaser.Math.RandomDataGenerator#real - * @since 3.0.0 - * - * @return {number} A random real number between 0 and 2^32. - */ - real: function () - { - return this.integer() + this.frac(); - }, - - /** - * Returns a random integer between and including min and max. - * - * @method Phaser.Math.RandomDataGenerator#integerInRange - * @since 3.0.0 - * - * @param {number} min - The minimum value in the range. - * @param {number} max - The maximum value in the range. - * - * @return {number} A random number between min and max. - */ - integerInRange: function (min, max) - { - return Math.floor(this.realInRange(0, max - min + 1) + min); - }, - - /** - * Returns a random integer between and including min and max. - * This method is an alias for RandomDataGenerator.integerInRange. - * - * @method Phaser.Math.RandomDataGenerator#between - * @since 3.0.0 - * - * @param {number} min - The minimum value in the range. - * @param {number} max - The maximum value in the range. - * - * @return {number} A random number between min and max. - */ - between: function (min, max) - { - return Math.floor(this.realInRange(0, max - min + 1) + min); - }, - - /** - * Returns a random real number between min and max. - * - * @method Phaser.Math.RandomDataGenerator#realInRange - * @since 3.0.0 - * - * @param {number} min - The minimum value in the range. - * @param {number} max - The maximum value in the range. - * - * @return {number} A random number between min and max. - */ - realInRange: function (min, max) - { - return this.frac() * (max - min) + min; - }, - - /** - * Returns a random real number between -1 and 1. - * - * @method Phaser.Math.RandomDataGenerator#normal - * @since 3.0.0 - * - * @return {number} A random real number between -1 and 1. - */ - normal: function () - { - return 1 - (2 * this.frac()); - }, - - /** - * Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368 - * - * @method Phaser.Math.RandomDataGenerator#uuid - * @since 3.0.0 - * - * @return {string} A valid RFC4122 version4 ID hex string - */ - uuid: function () - { - var a = ''; - var b = ''; - - for (b = a = ''; a++ < 36; b += ~a % 5 | a * 3 & 4 ? (a ^ 15 ? 8 ^ this.frac() * (a ^ 20 ? 16 : 4) : 4).toString(16) : '-') - { - // eslint-disable-next-line no-empty - } - - return b; - }, - - /** - * Returns a random element from within the given array. - * - * @method Phaser.Math.RandomDataGenerator#pick - * @since 3.0.0 - * - * @param {array} array - The array to pick a random element from. - * - * @return {any} A random member of the array. - */ - pick: function (array) - { - return array[this.integerInRange(0, array.length - 1)]; - }, - - /** - * Returns a sign to be used with multiplication operator. - * - * @method Phaser.Math.RandomDataGenerator#sign - * @since 3.0.0 - * - * @return {number} -1 or +1. - */ - sign: function () - { - return this.pick(this.signs); - }, - - /** - * Returns a random element from within the given array, favoring the earlier entries. - * - * @method Phaser.Math.RandomDataGenerator#weightedPick - * @since 3.0.0 - * - * @param {array} array - The array to pick a random element from. - * - * @return {any} A random member of the array. - */ - weightedPick: function (array) - { - return array[~~(Math.pow(this.frac(), 2) * (array.length - 1) + 0.5)]; - }, - - /** - * Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified. - * - * @method Phaser.Math.RandomDataGenerator#timestamp - * @since 3.0.0 - * - * @param {number} min - The minimum value in the range. - * @param {number} max - The maximum value in the range. - * - * @return {number} A random timestamp between min and max. - */ - timestamp: function (min, max) - { - return this.realInRange(min || 946684800000, max || 1577862000000); - }, - - /** - * Returns a random angle between -180 and 180. - * - * @method Phaser.Math.RandomDataGenerator#angle - * @since 3.0.0 - * - * @return {number} A random number between -180 and 180. - */ - angle: function () - { - return this.integerInRange(-180, 180); - }, - - /** - * Returns a random rotation in radians, between -3.141 and 3.141 - * - * @method Phaser.Math.RandomDataGenerator#rotation - * @since 3.0.0 - * - * @return {number} A random number between -3.141 and 3.141 - */ - rotation: function () - { - return this.realInRange(-3.1415926, 3.1415926); - }, - - /** - * Gets or Sets the state of the generator. This allows you to retain the values - * that the generator is using between games, i.e. in a game save file. - * - * To seed this generator with a previously saved state you can pass it as the - * `seed` value in your game config, or call this method directly after Phaser has booted. - * - * Call this method with no parameters to return the current state. - * - * If providing a state it should match the same format that this method - * returns, which is a string with a header `!rnd` followed by the `c`, - * `s0`, `s1` and `s2` values respectively, each comma-delimited. - * - * @method Phaser.Math.RandomDataGenerator#state - * @since 3.0.0 - * - * @param {string} [state] - Generator state to be set. - * - * @return {string} The current state of the generator. - */ - state: function (state) - { - if (typeof state === 'string' && state.match(/^!rnd/)) - { - state = state.split(','); - - this.c = parseFloat(state[1]); - this.s0 = parseFloat(state[2]); - this.s1 = parseFloat(state[3]); - this.s2 = parseFloat(state[4]); - } - - return [ '!rnd', this.c, this.s0, this.s1, this.s2 ].join(','); + end = start; + start = 0; } -}); + var result = []; -module.exports = RandomDataGenerator; + var total = Math.max(RoundAwayFromZero((end - start) / (step || 1)), 0); + + for (var i = 0; i < total; i++) + { + result.push(start); + start += step; + } + + return result; +}; + +module.exports = NumberArrayStep; /***/ }), @@ -77237,240 +78048,24 @@ module.exports = RandomDataGenerator; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Clamp = __webpack_require__(61); - -// bitmask flag for GameObject.renderMask -var _FLAG = 2; // 0010 +var RotateMatrix = __webpack_require__(81); /** - * Provides methods used for setting the alpha properties of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Alpha + * [description] + * + * @function Phaser.Utils.Array.Matrix.RotateRight * @since 3.0.0 + * + * @param {array} matrix - [description] + * + * @return {array} [description] */ - -var Alpha = { - - _alpha: 1, - - _alphaTL: 1, - _alphaTR: 1, - _alphaBL: 1, - _alphaBR: 1, - - /** - * Clears all alpha values associated with this Game Object. - * Immediately sets the alpha levels back to 1 (fully opaque) - * - * @method Phaser.GameObjects.Components.Alpha#clearAlpha - * @since 3.0.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - clearAlpha: function () - { - return this.setAlpha(1); - }, - - /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * - * If your game is running under WebGL you can optionally specify four different alpha values, each of which - * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. - * - * @method Phaser.GameObjects.Components.Alpha#setAlpha - * @since 3.0.0 - * - * @param {float} [topLeft=1] - The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. - * @param {float} [topRight] - The alpha value used for the top-right of the Game Object. WebGL only. - * @param {float} [bottomLeft] - The alpha value used for the bottom-left of the Game Object. WebGL only. - * @param {float} [bottomRight] - The alpha value used for the bottom-right of the Game Object. WebGL only. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setAlpha: function (topLeft, topRight, bottomLeft, bottomRight) - { - if (topLeft === undefined) { topLeft = 1; } - - // Treat as if there is only one alpha value for the whole Game Object - if (topRight === undefined) - { - this.alpha = topLeft; - } - else - { - this._alphaTL = Clamp(topLeft, 0, 1); - this._alphaTR = Clamp(topRight, 0, 1); - this._alphaBL = Clamp(bottomLeft, 0, 1); - this._alphaBR = Clamp(bottomRight, 0, 1); - } - - return this; - }, - - /** - * The alpha value of the Game Object. - * - * This is a global value, impacting the entire Game Object, not just a region of it. - * - * @name Phaser.GameObjects.Components.Alpha#alpha - * @type {float} - * @since 3.0.0 - */ - alpha: { - - get: function () - { - return this._alpha; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alpha = v; - this._alphaTL = v; - this._alphaTR = v; - this._alphaBL = v; - this._alphaBR = v; - - if (v === 0) - { - this.renderFlags &= ~_FLAG; - } - else - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The alpha value starting from the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Alpha#alphaTopLeft - * @type {float} - * @webglOnly - * @since 3.0.0 - */ - alphaTopLeft: { - - get: function () - { - return this._alphaTL; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alphaTL = v; - - if (v !== 0) - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The alpha value starting from the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Alpha#alphaTopRight - * @type {float} - * @webglOnly - * @since 3.0.0 - */ - alphaTopRight: { - - get: function () - { - return this._alphaTR; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alphaTR = v; - - if (v !== 0) - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The alpha value starting from the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Alpha#alphaBottomLeft - * @type {float} - * @webglOnly - * @since 3.0.0 - */ - alphaBottomLeft: { - - get: function () - { - return this._alphaBL; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alphaBL = v; - - if (v !== 0) - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The alpha value starting from the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Alpha#alphaBottomRight - * @type {float} - * @webglOnly - * @since 3.0.0 - */ - alphaBottomRight: { - - get: function () - { - return this._alphaBR; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alphaBR = v; - - if (v !== 0) - { - this.renderFlags |= _FLAG; - } - } - - } - +var RotateRight = function (matrix) +{ + return RotateMatrix(matrix, -90); }; -module.exports = Alpha; +module.exports = RotateRight; /***/ }), @@ -77483,110 +78078,29 @@ module.exports = Alpha; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BlendModes = __webpack_require__(45); +var RotateMatrix = __webpack_require__(81); /** - * Provides methods used for setting the blend mode of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.BlendMode + * [description] + * + * @function Phaser.Utils.Array.Matrix.RotateLeft * @since 3.0.0 + * + * @param {array} matrix - [description] + * + * @return {array} [description] */ - -var BlendMode = { - - _blendMode: BlendModes.NORMAL, - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - * - * @name Phaser.GameObjects.Components.BlendMode#blendMode - * @type {integer|string} - * @since 3.0.0 - */ - blendMode: { - - get: function () - { - return this._blendMode; - }, - - set: function (value) - { - if (typeof value === 'string') - { - value = BlendModes[value]; - } - - value | 0; - - if (value >= 0) - { - this._blendMode = value; - } - } - - }, - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - * - * @method Phaser.GameObjects.Components.BlendMode#setBlendMode - * @since 3.0.0 - * - * @param {string|integer} value - The BlendMode value. Either a string or a CONST. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setBlendMode: function (value) - { - this.blendMode = value; - - return this; - } - +var RotateLeft = function (matrix) +{ + return RotateMatrix(matrix, 90); }; -module.exports = BlendMode; +module.exports = RotateLeft; /***/ }), /* 393 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -77594,81 +78108,24 @@ module.exports = BlendMode; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var RotateMatrix = __webpack_require__(81); + /** - * Provides methods used for setting the blend mode of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.ComputedSize + * [description] + * + * @function Phaser.Utils.Array.Matrix.Rotate180 * @since 3.0.0 + * + * @param {array} matrix - [description] + * + * @return {array} [description] */ - -var ComputedSize = { - - /** - * The native (un-scaled) width of this Game Object. - * - * @name Phaser.GameObjects.Components.ComputedSize#width - * @type {number} - * @since 3.0.0 - */ - width: 0, - - /** - * The native (un-scaled) height of this Game Object. - * - * @name Phaser.GameObjects.Components.ComputedSize#height - * @type {number} - * @since 3.0.0 - */ - height: 0, - - /** - * The displayed width of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Components.ComputedSize#displayWidth - * @type {number} - * @since 3.0.0 - */ - displayWidth: { - - get: function () - { - return this.scaleX * this.width; - }, - - set: function (value) - { - this.scaleX = value / this.width; - } - - }, - - /** - * The displayed height of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Components.ComputedSize#displayHeight - * @type {number} - * @since 3.0.0 - */ - displayHeight: { - - get: function () - { - return this.scaleY * this.height; - }, - - set: function (value) - { - this.scaleY = value / this.height; - } - - } - +var Rotate180 = function (matrix) +{ + return RotateMatrix(matrix, 180); }; -module.exports = ComputedSize; +module.exports = Rotate180; /***/ }), @@ -77682,77 +78139,21 @@ module.exports = ComputedSize; */ /** - * Provides methods used for setting the depth of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Depth + * [description] + * + * @function Phaser.Utils.Array.Matrix.ReverseRows * @since 3.0.0 + * + * @param {array} matrix - [description] + * + * @return {array} [description] */ - -var Depth = { - - _depth: 0, - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * - * @name Phaser.GameObjects.Components.Depth#depth - * @type {number} - * @since 3.0.0 - */ - depth: { - - get: function () - { - return this._depth; - }, - - set: function (value) - { - this.scene.sys.queueDepthSort(); - this._depth = value; - } - - }, - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * - * @method Phaser.GameObjects.Components.Depth#setDepth - * @since 3.0.0 - * - * @param {integer} value - The depth of this Game Object. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setDepth: function (value) - { - if (value === undefined) { value = 0; } - - this.depth = value; - - return this; - } - +var ReverseRows = function (matrix) +{ + return matrix.reverse(); }; -module.exports = Depth; +module.exports = ReverseRows; /***/ }), @@ -77766,141 +78167,26 @@ module.exports = Depth; */ /** - * Provides methods used for visually flipping a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Flip + * [description] + * + * @function Phaser.Utils.Array.Matrix.ReverseColumns * @since 3.0.0 + * + * @param {array} matrix - [description] + * + * @return {array} [description] */ - -var Flip = { - - /** - * The horizontally flipped state of the Game Object. - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * - * @name Phaser.GameObjects.Components.Flip#flipX - * @type {boolean} - * @default false - * @since 3.0.0 - */ - flipX: false, - - /** - * The vertically flipped state of the Game Object. - * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * - * @name Phaser.GameObjects.Components.Flip#flipY - * @type {boolean} - * @default false - * @since 3.0.0 - */ - flipY: false, - - /** - * Toggles the horizontal flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#toggleFlipX - * @since 3.0.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - toggleFlipX: function () +var ReverseColumns = function (matrix) +{ + for (var i = 0; i < matrix.length; i++) { - this.flipX = !this.flipX; - - return this; - }, - - /** - * Toggles the vertical flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#toggleFlipY - * @since 3.0.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - toggleFlipY: function () - { - this.flipY = !this.flipY; - - return this; - }, - - /** - * Sets the horizontal flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#setFlipX - * @since 3.0.0 - * - * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setFlipX: function (value) - { - this.flipX = value; - - return this; - }, - - /** - * Sets the vertical flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#setFlipY - * @since 3.0.0 - * - * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setFlipY: function (value) - { - this.flipY = value; - - return this; - }, - - /** - * Sets the horizontal and vertical flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#setFlip - * @since 3.0.0 - * - * @param {boolean} x - The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * @param {boolean} y - The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setFlip: function (x, y) - { - this.flipX = x; - this.flipY = y; - - return this; - }, - - /** - * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. - * - * @method Phaser.GameObjects.Components.Flip#resetFlip - * @since 3.0.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - resetFlip: function () - { - this.flipX = false; - this.flipY = false; - - return this; + matrix[i].reverse(); } + return matrix; }; -module.exports = Flip; +module.exports = ReverseColumns; /***/ }), @@ -77913,193 +78199,80 @@ module.exports = Flip; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Rectangle = __webpack_require__(8); -var RotateAround = __webpack_require__(188); -var Vector2 = __webpack_require__(6); +var Pad = __webpack_require__(158); +var CheckMatrix = __webpack_require__(109); + +// Generates a string (which you can pass to console.log) from the given +// Array Matrix. /** - * Provides methods used for obtaining the bounds of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.GetBounds + * [description] + * + * @function Phaser.Utils.Array.Matrix.MatrixToString * @since 3.0.0 + * + * @param {array} matrix - [description] + * + * @return {string} [description] */ +var MatrixToString = function (matrix) +{ + var str = ''; -var GetBounds = { - - /** - * Gets the center coordinate of this Game Object, regardless of origin. - * - * @method Phaser.GameObjects.Components.GetBounds#getCenter - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2|object} [output] - An object to store the values in. If not provided a new Vector2 will be created. - * - * @return {Phaser.Math.Vector2|object} The values stored in the output object. - */ - getCenter: function (output) + if (!CheckMatrix(matrix)) { - if (output === undefined) { output = new Vector2(); } - - output.x = this.x - (this.displayWidth * this.originX) + (this.displayWidth / 2); - output.y = this.y - (this.displayHeight * this.originY) + (this.displayHeight / 2); - - return output; - }, - - /** - * Gets the top-left corner coordinate of this Game Object, regardless of origin. - * - * @method Phaser.GameObjects.Components.GetBounds#getTopLeft - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2|object} [output] - An object to store the values in. If not provided a new Vector2 will be created. - * - * @return {Phaser.Math.Vector2|object} The values stored in the output object. - */ - getTopLeft: function (output) - { - if (output === undefined) { output = new Vector2(); } - - output.x = this.x - (this.displayWidth * this.originX); - output.y = this.y - (this.displayHeight * this.originY); - - if (this.rotation !== 0) - { - RotateAround(output, this.x, this.y, this.rotation); - } - - return output; - }, - - /** - * Gets the top-right corner coordinate of this Game Object, regardless of origin. - * - * @method Phaser.GameObjects.Components.GetBounds#getTopRight - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2|object} [output] - An object to store the values in. If not provided a new Vector2 will be created. - * - * @return {Phaser.Math.Vector2|object} The values stored in the output object. - */ - getTopRight: function (output) - { - if (output === undefined) { output = new Vector2(); } - - output.x = (this.x - (this.displayWidth * this.originX)) + this.displayWidth; - output.y = this.y - (this.displayHeight * this.originY); - - if (this.rotation !== 0) - { - RotateAround(output, this.x, this.y, this.rotation); - } - - return output; - }, - - /** - * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. - * - * @method Phaser.GameObjects.Components.GetBounds#getBottomLeft - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2|object} [output] - An object to store the values in. If not provided a new Vector2 will be created. - * - * @return {Phaser.Math.Vector2|object} The values stored in the output object. - */ - getBottomLeft: function (output) - { - if (output === undefined) { output = new Vector2(); } - - output.x = this.x - (this.displayWidth * this.originX); - output.y = (this.y - (this.displayHeight * this.originY)) + this.displayHeight; - - if (this.rotation !== 0) - { - RotateAround(output, this.x, this.y, this.rotation); - } - - return output; - }, - - /** - * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. - * - * @method Phaser.GameObjects.Components.GetBounds#getBottomRight - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2|object} [output] - An object to store the values in. If not provided a new Vector2 will be created. - * - * @return {Phaser.Math.Vector2|object} The values stored in the output object. - */ - getBottomRight: function (output) - { - if (output === undefined) { output = new Vector2(); } - - output.x = (this.x - (this.displayWidth * this.originX)) + this.displayWidth; - output.y = (this.y - (this.displayHeight * this.originY)) + this.displayHeight; - - if (this.rotation !== 0) - { - RotateAround(output, this.x, this.y, this.rotation); - } - - return output; - }, - - /** - * Gets the bounds of this Game Object, regardless of origin. - * The values are stored and returned in a Rectangle, or Rectangle-like, object. - * - * @method Phaser.GameObjects.Components.GetBounds#getBounds - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle|object} [output] - An object to store the values in. If not provided a new Rectangle will be created. - * - * @return {Phaser.Geom.Rectangle|object} The values stored in the output object. - */ - getBounds: function (output) - { - if (output === undefined) { output = new Rectangle(); } - - // We can use the output object to temporarily store the x/y coords in: - - this.getTopLeft(output); - - var TLx = output.x; - var TLy = output.y; - - this.getTopRight(output); - - var TRx = output.x; - var TRy = output.y; - - this.getBottomLeft(output); - - var BLx = output.x; - var BLy = output.y; - - this.getBottomRight(output); - - var BRx = output.x; - var BRy = output.y; - - output.x = Math.min(TLx, TRx, BLx, BRx); - output.y = Math.min(TLy, TRy, BLy, BRy); - output.width = Math.max(TLx, TRx, BLx, BRx) - output.x; - output.height = Math.max(TLy, TRy, BLy, BRy) - output.y; - - return output; + return str; } + for (var r = 0; r < matrix.length; r++) + { + for (var c = 0; c < matrix[r].length; c++) + { + var cell = matrix[r][c].toString(); + + if (cell !== 'undefined') + { + str += Pad(cell, 2); + } + else + { + str += '?'; + } + + if (c < matrix[r].length - 1) + { + str += ' |'; + } + } + + if (r < matrix.length - 1) + { + str += '\n'; + + for (var i = 0; i < matrix[r].length; i++) + { + str += '---'; + + if (i < matrix[r].length - 1) + { + str += '+'; + } + } + + str += '\n'; + } + + } + + return str; }; -module.exports = GetBounds; +module.exports = MatrixToString; /***/ }), /* 397 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -78108,282 +78281,23 @@ module.exports = GetBounds; */ /** - * Provides methods used for getting and setting the transform values of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.MatrixStack - * @since 3.2.0 + * @namespace Phaser.Utils.Array.Matrix */ -var MatrixStack = { +module.exports = { - /** - * [description] - * - * @name Phaser.GameObjects.Components.MatrixStack#matrixStack - * @type {Float32Array} - * @private - * @since 3.2.0 - */ - matrixStack: null, - - /** - * [description] - * - * @name Phaser.GameObjects.Components.MatrixStack#currentMatrix - * @type {Float32Array} - * @private - * @since 3.2.0 - */ - currentMatrix: null, - - /** - * [description] - * - * @name Phaser.GameObjects.Components.MatrixStack#currentMatrixIndex - * @type {integer} - * @private - * @since 3.2.0 - */ - currentMatrixIndex: 0, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.MatrixStack#initMatrixStack - * @since 3.2.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - initMatrixStack: function () - { - this.matrixStack = new Float32Array(6000); // up to 1000 matrices - this.currentMatrix = new Float32Array([ 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 ]); - this.currentMatrixIndex = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.MatrixStack#save - * @since 3.2.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - save: function () - { - if (this.currentMatrixIndex >= this.matrixStack.length) { return this; } - - var matrixStack = this.matrixStack; - var currentMatrix = this.currentMatrix; - var currentMatrixIndex = this.currentMatrixIndex; - this.currentMatrixIndex += 6; - - matrixStack[currentMatrixIndex + 0] = currentMatrix[0]; - matrixStack[currentMatrixIndex + 1] = currentMatrix[1]; - matrixStack[currentMatrixIndex + 2] = currentMatrix[2]; - matrixStack[currentMatrixIndex + 3] = currentMatrix[3]; - matrixStack[currentMatrixIndex + 4] = currentMatrix[4]; - matrixStack[currentMatrixIndex + 5] = currentMatrix[5]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.MatrixStack#restore - * @since 3.2.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - restore: function () - { - if (this.currentMatrixIndex <= 0) { return this; } - - this.currentMatrixIndex -= 6; - - var matrixStack = this.matrixStack; - var currentMatrix = this.currentMatrix; - var currentMatrixIndex = this.currentMatrixIndex; - - currentMatrix[0] = matrixStack[currentMatrixIndex + 0]; - currentMatrix[1] = matrixStack[currentMatrixIndex + 1]; - currentMatrix[2] = matrixStack[currentMatrixIndex + 2]; - currentMatrix[3] = matrixStack[currentMatrixIndex + 3]; - currentMatrix[4] = matrixStack[currentMatrixIndex + 4]; - currentMatrix[5] = matrixStack[currentMatrixIndex + 5]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.MatrixStack#loadIdentity - * @since 3.2.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - loadIdentity: function () - { - this.setTransform(1.0, 0.0, 0.0, 1.0, 0.0, 0.0); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.MatrixStack#transform - * @since 3.2.0 - * - * @param {number} a - [description] - * @param {number} b - [description] - * @param {number} c - [description] - * @param {number} d - [description] - * @param {number} tx - [description] - * @param {number} ty - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - transform: function (a, b, c, d, tx, ty) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - var m4 = currentMatrix[4]; - var m5 = currentMatrix[5]; - - currentMatrix[0] = m0 * a + m2 * b; - currentMatrix[1] = m1 * a + m3 * b; - currentMatrix[2] = m0 * c + m2 * d; - currentMatrix[3] = m1 * c + m3 * d; - currentMatrix[4] = m0 * tx + m2 * ty + m4; - currentMatrix[5] = m1 * tx + m3 * ty + m5; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.MatrixStack#setTransform - * @since 3.2.0 - * - * @param {number} a - [description] - * @param {number} b - [description] - * @param {number} c - [description] - * @param {number} d - [description] - * @param {number} tx - [description] - * @param {number} ty - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setTransform: function (a, b, c, d, tx, ty) - { - var currentMatrix = this.currentMatrix; - - currentMatrix[0] = a; - currentMatrix[1] = b; - currentMatrix[2] = c; - currentMatrix[3] = d; - currentMatrix[4] = tx; - currentMatrix[5] = ty; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.MatrixStack#translate - * @since 3.2.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - translate: function (x, y) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - var m4 = currentMatrix[4]; - var m5 = currentMatrix[5]; - - currentMatrix[4] = m0 * x + m2 * y + m4; - currentMatrix[5] = m1 * x + m3 * y + m5; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.MatrixStack#scale - * @since 3.2.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - scale: function (x, y) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - - currentMatrix[0] = m0 * x; - currentMatrix[1] = m1 * x; - currentMatrix[2] = m2 * y; - currentMatrix[3] = m3 * y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.MatrixStack#rotate - * @since 3.2.0 - * - * @param {number} t - The angle of rotation, in radians. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - rotate: function (t) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - var st = Math.sin(t); - var ct = Math.cos(t); - - currentMatrix[0] = m0 * ct + m2 * st; - currentMatrix[1] = m1 * ct + m3 * st; - currentMatrix[2] = m0 * -st + m2 * ct; - currentMatrix[3] = m1 * -st + m3 * ct; - - return this; - } + CheckMatrix: __webpack_require__(109), + MatrixToString: __webpack_require__(396), + ReverseColumns: __webpack_require__(395), + ReverseRows: __webpack_require__(394), + Rotate180: __webpack_require__(393), + RotateLeft: __webpack_require__(392), + RotateMatrix: __webpack_require__(81), + RotateRight: __webpack_require__(391), + TransposeMatrix: __webpack_require__(177) }; -module.exports = MatrixStack; - /***/ }), /* 398 */ @@ -78396,196 +78310,41 @@ module.exports = MatrixStack; */ /** - * Provides methods used for getting and setting the origin of a Game Object. - * Values are normalized, given in the range 0 to 1. - * Display values contain the calculated pixel values. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Origin + * [description] + * + * @function Phaser.Utils.Array.FindClosestInSorted * @since 3.0.0 + * + * @param {number} value - The value to search for in the array. + * @param {array} array - The array to search, which must be sorted. + * + * @return {number} The nearest value found in the array. */ - -var Origin = { - - /** - * A property indicating that a Game Object has this component. - * - * @name Phaser.GameObjects.Components.Origin#_originComponent - * @type {boolean} - * @private - * @default true - * @since 3.2.0 - */ - _originComponent: true, - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - * - * @name Phaser.GameObjects.Components.Origin#originX - * @type {float} - * @default 0.5 - * @since 3.0.0 - */ - originX: 0.5, - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - * - * @name Phaser.GameObjects.Components.Origin#originY - * @type {float} - * @default 0.5 - * @since 3.0.0 - */ - originY: 0.5, - - // private + read only - _displayOriginX: 0, - _displayOriginY: 0, - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - * - * @name Phaser.GameObjects.Components.Origin#displayOriginX - * @type {float} - * @since 3.0.0 - */ - displayOriginX: { - - get: function () - { - return this._displayOriginX; - }, - - set: function (value) - { - this._displayOriginX = value; - this.originX = value / this.width; - } - - }, - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - * - * @name Phaser.GameObjects.Components.Origin#displayOriginY - * @type {float} - * @since 3.0.0 - */ - displayOriginY: { - - get: function () - { - return this._displayOriginY; - }, - - set: function (value) - { - this._displayOriginY = value; - this.originY = value / this.height; - } - - }, - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * - * @method Phaser.GameObjects.Components.Origin#setOrigin - * @since 3.0.0 - * - * @param {number} [x=0.5] - The horizontal origin value. - * @param {number} [y=0.5] - The vertical origin value. If not defined it will be set to the value of `x`. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setOrigin: function (x, y) +var FindClosestInSorted = function (value, array) +{ + if (!array.length) { - if (x === undefined) { x = 0.5; } - if (y === undefined) { y = x; } - - this.originX = x; - this.originY = y; - - return this.updateDisplayOrigin(); - }, - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - * - * @method Phaser.GameObjects.Components.Origin#setOriginFromFrame - * @since 3.0.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setOriginFromFrame: function () + return NaN; + } + else if (array.length === 1 || value < array[0]) { - if (!this.frame || !this.frame.customPivot) - { - return this.setOrigin(); - } - else - { - this.originX = this.frame.pivotX; - this.originY = this.frame.pivotY; - } - - return this.updateDisplayOrigin(); - }, - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * - * @method Phaser.GameObjects.Components.Origin#setDisplayOrigin - * @since 3.0.0 - * - * @param {number} [x=0] - The horizontal display origin value. - * @param {number} [y=0] - The vertical display origin value. If not defined it will be set to the value of `x`. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setDisplayOrigin: function (x, y) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = x; } - - this.displayOriginX = x; - this.displayOriginY = y; - - return this; - }, - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - * - * @method Phaser.GameObjects.Components.Origin#updateDisplayOrigin - * @since 3.0.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - updateDisplayOrigin: function () - { - this._displayOriginX = Math.round(this.originX * this.width); - this._displayOriginY = Math.round(this.originY * this.height); - - return this; + return array[0]; } + var i = 1; + + while (array[i] < value) + { + i++; + } + + var low = array[i - 1]; + var high = (i < array.length) ? array[i] : Number.POSITIVE_INFINITY; + + return ((high - value) <= (value - low)) ? high : low; }; -module.exports = Origin; +module.exports = FindClosestInSorted; /***/ }), @@ -78598,70 +78357,31 @@ module.exports = Origin; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var ScaleModes = __webpack_require__(63); - /** - * Provides methods used for getting and setting the scale of a Game Object. - * - * @name Phaser.GameObjects.Components.ScaleMode - * @since 3.0.0 + * @namespace Phaser.Utils.Array */ -var ScaleMode = { +module.exports = { - _scaleMode: ScaleModes.DEFAULT, - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * - * @name Phaser.GameObjects.Components.ScaleMode#scaleMode - * @type {integer} - * @since 3.0.0 - */ - scaleMode: { - - get: function () - { - return this._scaleMode; - }, - - set: function (value) - { - if (value === ScaleModes.LINEAR || value === ScaleModes.NEAREST) - { - this._scaleMode = value; - } - } - - }, - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * - * @method Phaser.GameObjects.Components.ScaleMode#setScaleMode - * @since 3.0.0 - * - * @param {integer} value - The Scale Mode to be used by this Game Object. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setScaleMode: function (value) - { - this.scaleMode = value; - - return this; - } + FindClosestInSorted: __webpack_require__(398), + GetRandomElement: __webpack_require__(132), + Matrix: __webpack_require__(397), + NumberArray: __webpack_require__(222), + NumberArrayStep: __webpack_require__(390), + QuickSelect: __webpack_require__(203), + Range: __webpack_require__(264), + RemoveRandomElement: __webpack_require__(389), + RotateLeft: __webpack_require__(346), + RotateRight: __webpack_require__(345), + Shuffle: __webpack_require__(102), + SpliceOne: __webpack_require__(176) }; -module.exports = ScaleMode; - /***/ }), /* 400 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -78670,90 +78390,21 @@ module.exports = ScaleMode; */ /** - * Provides methods used for getting and setting the Scroll Factor of a Game Object. - * - * @name Phaser.GameObjects.Components.ScrollFactor - * @since 3.0.0 + * @namespace Phaser.Utils */ -var ScrollFactor = { +module.exports = { - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorX - * @type {number} - * @default 1 - * @since 3.0.0 - */ - scrollFactorX: 1, - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorY - * @type {number} - * @default 1 - * @since 3.0.0 - */ - scrollFactorY: 1, - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * @method Phaser.GameObjects.Components.ScrollFactor#setScrollFactor - * @since 3.0.0 - * - * @param {number} x - The horizontal scroll factor of this Game Object. - * @param {number} [y] - The vertical scroll factor of this Game Object. If not set it will use the `x` value. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setScrollFactor: function (x, y) - { - if (y === undefined) { y = x; } - - this.scrollFactorX = x; - this.scrollFactorY = y; - - return this; - } + Array: __webpack_require__(399), + Objects: __webpack_require__(388), + String: __webpack_require__(384) }; -module.exports = ScrollFactor; - /***/ }), /* 401 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -78761,150 +78412,651 @@ module.exports = ScrollFactor; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var NumberTweenBuilder = __webpack_require__(180); +var PluginManager = __webpack_require__(12); +var TimelineBuilder = __webpack_require__(179); +var TWEEN_CONST = __webpack_require__(68); +var TweenBuilder = __webpack_require__(82); + +// Phaser.Tweens.TweenManager + /** - * Provides methods used for getting and setting the size of a Game Object. - * - * @name Phaser.GameObjects.Components.Size + * @classdesc + * [description] + * + * @class TweenManager + * @memberOf Phaser.Tweens + * @constructor * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] */ +var TweenManager = new Class({ -var Size = { + initialize: - /** - * A property indicating that a Game Object has this component. - * - * @name Phaser.GameObjects.Components.Size#_sizeComponent - * @type {boolean} - * @private - * @default true - * @since 3.2.0 - */ - _sizeComponent: true, + function TweenManager (scene) + { + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; - /** - * The native (un-scaled) width of this Game Object. - * - * @name Phaser.GameObjects.Components.Size#width - * @type {number} - * @since 3.0.0 - */ - width: 0, + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; - /** - * The native (un-scaled) height of this Game Object. - * - * @name Phaser.GameObjects.Components.Size#height - * @type {number} - * @since 3.0.0 - */ - height: 0, - - /** - * The displayed width of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Components.Size#displayWidth - * @type {number} - * @since 3.0.0 - */ - displayWidth: { - - get: function () + if (!scene.sys.settings.isBooted) { - return this.scaleX * this.frame.realWidth; - }, - - set: function (value) - { - this.scaleX = value / this.frame.realWidth; + scene.sys.events.once('boot', this.boot, this); } + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#_add + * @type {array} + * @private + * @since 3.0.0 + */ + this._add = []; + + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#_pending + * @type {array} + * @private + * @since 3.0.0 + */ + this._pending = []; + + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#_active + * @type {array} + * @private + * @since 3.0.0 + */ + this._active = []; + + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#_destroy + * @type {array} + * @private + * @since 3.0.0 + */ + this._destroy = []; + + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#_toProcess + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + this._toProcess = 0; }, /** - * The displayed height of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Components.Size#displayHeight - * @type {number} + * [description] + * + * @method Phaser.Tweens.TweenManager#boot * @since 3.0.0 */ - displayHeight: { + boot: function () + { + var eventEmitter = this.systems.events; - get: function () - { - return this.scaleY * this.frame.realHeight; - }, + eventEmitter.on('preupdate', this.preUpdate, this); + eventEmitter.on('update', this.update, this); + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); - set: function (value) + this.timeScale = 1; + }, + + /** + * Create a Tween Timeline and return it, but do NOT add it to the active or pending Tween lists. + * + * @method Phaser.Tweens.TweenManager#createTimeline + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.Tweens.Timeline} [description] + */ + createTimeline: function (config) + { + return TimelineBuilder(this, config); + }, + + /** + * Create a Tween Timeline and add it to the active Tween list/ + * + * @method Phaser.Tweens.TweenManager#timeline + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.Tweens.Timeline} [description] + */ + timeline: function (config) + { + var timeline = TimelineBuilder(this, config); + + if (!timeline.paused) { - this.scaleY = value / this.frame.realHeight; + this._add.push(timeline); + + this._toProcess++; } + return timeline; }, /** - * Sets the size of this Game Object to be that of the given Frame. - * - * @method Phaser.GameObjects.Components.Size#setSizeToFrame + * Create a Tween and return it, but do NOT add it to the active or pending Tween lists. + * + * @method Phaser.Tweens.TweenManager#create * @since 3.0.0 * - * @param {Phaser.Textures.Frame} frame - The frame to base the size of this Game Object on. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. + * @param {object} config - [description] + * + * @return {Phaser.Tweens.Tween} [description] */ - setSizeToFrame: function (frame) + create: function (config) { - if (frame === undefined) { frame = this.frame; } + return TweenBuilder(this, config); + }, - this.width = frame.realWidth; - this.height = frame.realHeight; + /** + * Create a Tween and add it to the active Tween list. + * + * @method Phaser.Tweens.TweenManager#add + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.Tweens.Tween} [description] + */ + add: function (config) + { + var tween = TweenBuilder(this, config); + + this._add.push(tween); + + this._toProcess++; + + return tween; + }, + + /** + * Add an existing tween into the active Tween list. + * + * @method Phaser.Tweens.TweenManager#existing + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * + * @return {Phaser.Tweens.TweenManager} This Tween Manager object. + */ + existing: function (tween) + { + this._add.push(tween); + + this._toProcess++; return this; }, /** - * Sets the size of this Game Object. - * - * @method Phaser.GameObjects.Components.Size#setSize + * Create a Tween and add it to the active Tween list. + * + * @method Phaser.Tweens.TweenManager#addCounter * @since 3.0.0 * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. + * @param {object} config - [description] + * + * @return {Phaser.Tweens.Tween} [description] */ - setSize: function (width, height) + addCounter: function (config) { - this.width = width; - this.height = height; + var tween = NumberTweenBuilder(this, config); + + this._add.push(tween); + + this._toProcess++; + + return tween; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#preUpdate + * @since 3.0.0 + */ + preUpdate: function () + { + if (this._toProcess === 0) + { + // Quick bail + return; + } + + var list = this._destroy; + var active = this._active; + var i; + var tween; + + // Clear the 'destroy' list + for (i = 0; i < list.length; i++) + { + tween = list[i]; + + // Remove from the 'active' array + var idx = active.indexOf(tween); + + if (idx !== -1) + { + tween.state = TWEEN_CONST.REMOVED; + active.splice(idx, 1); + } + } + + list.length = 0; + + // Process the addition list + // This stops callbacks and out of sync events from populating the active array mid-way during the update + + list = this._add; + + for (i = 0; i < list.length; i++) + { + tween = list[i]; + + if (tween.state === TWEEN_CONST.PENDING_ADD) + { + // Return true if the Tween should be started right away, otherwise false + if (tween.init()) + { + tween.play(); + + this._active.push(tween); + } + else + { + this._pending.push(tween); + } + } + } + + list.length = 0; + + this._toProcess = 0; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#update + * @since 3.0.0 + * + * @param {number} timestamp - [description] + * @param {number} delta - [description] + */ + update: function (timestamp, delta) + { + // Process active tweens + var list = this._active; + var tween; + + // Scale the delta + delta *= this.timeScale; + + for (var i = 0; i < list.length; i++) + { + tween = list[i]; + + // If Tween.update returns 'true' then it means it has completed, + // so move it to the destroy list + if (tween.update(timestamp, delta)) + { + this._destroy.push(tween); + this._toProcess++; + } + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#makeActive + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * + * @return {Phaser.Tweens.TweenManager} This Tween Manager object. + */ + makeActive: function (tween) + { + if (this._add.indexOf(tween) !== -1 || this._active.indexOf(tween) !== -1) + { + return; + } + + var idx = this._pending.indexOf(tween); + + if (idx !== -1) + { + this._pending.splice(idx, 1); + } + + this._add.push(tween); + + tween.state = TWEEN_CONST.PENDING_ADD; + + this._toProcess++; return this; }, /** - * Sets the display size of this Game Object. - * Calling this will adjust the scale. - * - * @method Phaser.GameObjects.Components.Size#setDisplaySize + * Passes all Tweens to the given callback. + * + * @method Phaser.Tweens.TweenManager#each * @since 3.0.0 * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. + * @param {function} callback - [description] + * @param {object} [scope] - [description] + * @param {...*} [arguments] - [description] */ - setDisplaySize: function (width, height) + each: function (callback, scope) { - this.displayWidth = width; - this.displayHeight = height; + var args = [ null ]; + + for (var i = 1; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (var texture in this.list) + { + args[0] = this.list[texture]; + + callback.apply(scope, args); + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#getAllTweens + * @since 3.0.0 + * + * @return {Phaser.Tweens.Tween[]} [description] + */ + getAllTweens: function () + { + var list = this._active; + var output = []; + + for (var i = 0; i < list.length; i++) + { + output.push(list[i]); + } + + return output; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#getGlobalTimeScale + * @since 3.0.0 + * + * @return {number} [description] + */ + getGlobalTimeScale: function () + { + return this.timeScale; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#getTweensOf + * @since 3.0.0 + * + * @param {(object|array)} target - [description] + * + * @return {Phaser.Tweens.Tween[]} [description] + */ + getTweensOf: function (target) + { + var list = this._active; + var tween; + var output = []; + var i; + + if (Array.isArray(target)) + { + for (i = 0; i < list.length; i++) + { + tween = list[i]; + + for (var t = 0; t < target.length; i++) + { + if (tween.hasTarget(target[t])) + { + output.push(tween); + } + } + } + } + else + { + for (i = 0; i < list.length; i++) + { + tween = list[i]; + + if (tween.hasTarget(target)) + { + output.push(tween); + } + } + } + + return output; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#isTweening + * @since 3.0.0 + * + * @param {object} target - [description] + * + * @return {boolean} [description] + */ + isTweening: function (target) + { + var list = this._active; + var tween; + + for (var i = 0; i < list.length; i++) + { + tween = list[i]; + + if (tween.hasTarget(target) && tween.isPlaying()) + { + return true; + } + } + + return false; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#killAll + * @since 3.0.0 + * + * @return {Phaser.Tweens.TweenManager} [description] + */ + killAll: function () + { + var tweens = this.getAllTweens(); + + for (var i = 0; i < tweens.length; i++) + { + tweens[i].stop(); + } return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#killTweensOf + * @since 3.0.0 + * + * @param {(object|array)} target - [description] + * + * @return {Phaser.Tweens.TweenManager} [description] + */ + killTweensOf: function (target) + { + var tweens = this.getTweensOf(target); + + for (var i = 0; i < tweens.length; i++) + { + tweens[i].stop(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#pauseAll + * @since 3.0.0 + * + * @return {Phaser.Tweens.TweenManager} [description] + */ + pauseAll: function () + { + var list = this._active; + + for (var i = 0; i < list.length; i++) + { + list[i].pause(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#resumeAll + * @since 3.0.0 + * + * @return {Phaser.Tweens.TweenManager} [description] + */ + resumeAll: function () + { + var list = this._active; + + for (var i = 0; i < list.length; i++) + { + list[i].resume(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#setGlobalTimeScale + * @since 3.0.0 + * + * @param {float} value - [description] + * + * @return {Phaser.Tweens.TweenManager} [description] + */ + setGlobalTimeScale: function (value) + { + this.timeScale = value; + + return this; + }, + + /** + * Scene that owns this manager is shutting down. + * + * @method Phaser.Tweens.TweenManager#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.killAll(); + + this._add = []; + this._pending = []; + this._active = []; + this._destroy = []; + + this._toProcess = 0; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); } -}; +}); -module.exports = Size; +PluginManager.register('TweenManager', TweenManager, 'tweens'); + +module.exports = TweenManager; /***/ }), @@ -78917,119 +79069,71 @@ module.exports = Size; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// bitmask flag for GameObject.renderMask -var _FLAG = 8; // 1000 +// RESERVED properties that a Tween config object uses -/** - * Provides methods used for getting and setting the texture of a Game Object. - * - * @name Phaser.GameObjects.Components.Texture - * @since 3.0.0 - */ +// completeDelay: The time the tween will wait before the onComplete event is dispatched once it has completed +// delay: The time the tween will wait before it first starts +// duration: The duration of the tween +// ease: The ease function used by the tween +// easeParams: The parameters to go with the ease function (if any) +// flipX: flip X the GameObject on tween end +// flipY: flip Y the GameObject on tween end// hold: The time the tween will pause before running a yoyo +// hold: The time the tween will pause before running a yoyo +// loop: The time the tween will pause before starting either a yoyo or returning to the start for a repeat +// loopDelay: +// offset: Used when the Tween is part of a Timeline +// paused: Does the tween start in a paused state, or playing? +// props: The properties being tweened by the tween +// repeat: The number of times the tween will repeat itself (a value of 1 means the tween will play twice, as it repeated once) +// repeatDelay: The time the tween will pause for before starting a repeat. The tween holds in the start state. +// targets: The targets the tween is updating. +// useFrames: Use frames or milliseconds? +// yoyo: boolean - Does the tween reverse itself (yoyo) when it reaches the end? -var Texture = { - - /** - * The Texture this Game Object is using to render with. - * - * @name Phaser.GameObjects.Components.Texture#texture - * @type {Phaser.Textures.Texture} - * @since 3.0.0 - */ - texture: null, - - /** - * The Texture Frame this Game Object is using to render with. - * - * @name Phaser.GameObjects.Components.Texture#frame - * @type {Phaser.Textures.Frame} - * @since 3.0.0 - */ - frame: null, - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * - * @method Phaser.GameObjects.Components.Texture#setTexture - * @since 3.0.0 - * - * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. - * @param {string|integer} [frame] - The name or index of the frame within the Texture. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setTexture: function (key, frame) - { - this.texture = this.scene.sys.textures.get(key); - - return this.setFrame(frame); - }, - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * It can be either a string or an index. - * - * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * - * @method Phaser.GameObjects.Components.Texture#setFrame - * @since 3.0.0 - * - * @param {string|integer} frame - The name or index of the frame within the Texture. - * @param {boolean} [updateSize=true] - Should this call adjust the size of the Game Object? - * @param {boolean} [updateOrigin=true] - Should this call adjust the origin of the Game Object? - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setFrame: function (frame, updateSize, updateOrigin) - { - if (updateSize === undefined) { updateSize = true; } - if (updateOrigin === undefined) { updateOrigin = true; } - - this.frame = this.texture.get(frame); - - if (!this.frame.cutWidth || !this.frame.cutHeight) - { - this.renderFlags &= ~_FLAG; - } - else - { - this.renderFlags |= _FLAG; - } - - if (this._sizeComponent && updateSize) - { - this.setSizeToFrame(); - } - - if (this._originComponent && updateOrigin) - { - if (this.frame.customPivot) - { - this.setOrigin(this.frame.pivotX, this.frame.pivotY); - } - else - { - this.updateDisplayOrigin(); - } - } - - return this; - } - -}; - -module.exports = Texture; +module.exports = [ + 'callbackScope', + 'completeDelay', + 'delay', + 'duration', + 'ease', + 'easeParams', + 'flipX', + 'flipY', + 'hold', + 'loop', + 'loopDelay', + 'offset', + 'onComplete', + 'onCompleteParams', + 'onCompleteScope', + 'onLoop', + 'onLoopParams', + 'onLoopScope', + 'onRepeat', + 'onRepeatParams', + 'onRepeatScope', + 'onStart', + 'onStartParams', + 'onStartScope', + 'onUpdate', + 'onUpdateParams', + 'onUpdateScope', + 'onYoyo', + 'onYoyoParams', + 'onYoyoScope', + 'paused', + 'props', + 'repeat', + 'repeatDelay', + 'targets', + 'useFrames', + 'yoyo' +]; /***/ }), /* 403 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -79037,194 +79141,29 @@ module.exports = Texture; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetColor = function (value) -{ - return (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16); -}; - /** - * Provides methods used for setting the tint of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Tint - * @webglOnly - * @since 3.0.0 + * @namespace Phaser.Tweens.Builders */ -var Tint = { +module.exports = { - // 0: topLeft, 1: topRight, 2: bottomLeft, 3: bottomRight - _tintTL: 16777215, - _tintTR: 16777215, - _tintBL: 16777215, - _tintBR: 16777215, - - /** - * Clears all tint values associated with this Game Object. - * Immediately sets the alpha levels back to 0xffffff (no tint) - * - * @method Phaser.GameObjects.Components.Tint#clearTint - * @webglOnly - * @since 3.0.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - clearTint: function () - { - this.setTint(0xffffff); - - return this; - }, - - /** - * Sets the tint values for this Game Object. - * - * @method Phaser.GameObjects.Components.Tint#setTint - * @webglOnly - * @since 3.0.0 - * - * @param {integer} [topLeft=0xffffff] - The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. - * @param {integer} [topRight] - The tint being applied to the top-right of the Game Object. - * @param {integer} [bottomLeft] - The tint being applied to the bottom-left of the Game Object. - * @param {integer} [bottomRight] - The tint being applied to the bottom-right of the Game Object. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setTint: function (topLeft, topRight, bottomLeft, bottomRight) - { - if (topLeft === undefined) { topLeft = 0xffffff; } - - if (topRight === undefined) - { - topRight = topLeft; - bottomLeft = topLeft; - bottomRight = topLeft; - } - - this._tintTL = GetColor(topLeft); - this._tintTR = GetColor(topRight); - this._tintBL = GetColor(bottomLeft); - this._tintBR = GetColor(bottomRight); - - return this; - }, - - /** - * The tint value being applied to the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tintTopLeft - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tintTopLeft: { - - get: function () - { - return this._tintTL; - }, - - set: function (value) - { - this._tintTL = GetColor(value); - } - - }, - - /** - * The tint value being applied to the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tintTopRight - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tintTopRight: { - - get: function () - { - return this._tintTR; - }, - - set: function (value) - { - this._tintTR = GetColor(value); - } - - }, - - /** - * The tint value being applied to the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tintBottomLeft - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tintBottomLeft: { - - get: function () - { - return this._tintBL; - }, - - set: function (value) - { - this._tintBL = GetColor(value); - } - - }, - - /** - * The tint value being applied to the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tintBottomRight - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tintBottomRight: { - - get: function () - { - return this._tintBR; - }, - - set: function (value) - { - this._tintBR = GetColor(value); - } - - }, - - /** - * The tint value being applied to the whole of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tint - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tint: { - - set: function (value) - { - this.setTint(value, value, value, value); - } - } + GetBoolean: __webpack_require__(69), + GetEaseFunction: __webpack_require__(71), + GetNewValue: __webpack_require__(83), + GetProps: __webpack_require__(182), + GetTargets: __webpack_require__(114), + GetTweens: __webpack_require__(181), + GetValueOp: __webpack_require__(113), + NumberTweenBuilder: __webpack_require__(180), + TimelineBuilder: __webpack_require__(179), + TweenBuilder: __webpack_require__(82) }; -module.exports = Tint; - /***/ }), /* 404 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -79232,2280 +79171,34 @@ module.exports = Tint; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Default Game Object JSON export -// Is extended further by Game Object specific implementations +var CONST = __webpack_require__(68); +var Extend = __webpack_require__(18); -var ToJSON = function (gameObject) -{ - var out = { - name: gameObject.name, - type: gameObject.type, - x: gameObject.x, - y: gameObject.y, - depth: gameObject.depth, - scale: { - x: gameObject.scaleX, - y: gameObject.scaleY - }, - origin: { - x: gameObject.originX, - y: gameObject.originY - }, - flipX: gameObject.flipX, - flipY: gameObject.flipY, - rotation: gameObject.rotation, - alpha: gameObject.alpha, - visible: gameObject.visible, - scaleMode: gameObject.scaleMode, - blendMode: gameObject.blendMode, - textureKey: '', - frameKey: '', - data: {} - }; +/** + * @namespace Phaser.Tweens + */ - if (gameObject.texture) - { - out.textureKey = gameObject.texture.key; - out.frameKey = gameObject.frame.name; - } +var Tweens = { + + Builders: __webpack_require__(403), + + TweenManager: __webpack_require__(401), + Tween: __webpack_require__(111), + TweenData: __webpack_require__(110), + Timeline: __webpack_require__(178) - return out; }; -module.exports = ToJSON; +// Merge in the consts +Tweens = Extend(false, Tweens, CONST); + +module.exports = Tweens; /***/ }), /* 405 */ /***/ (function(module, exports, __webpack_require__) { -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH_CONST = __webpack_require__(16); -var WrapAngle = __webpack_require__(163); -var WrapAngleDegrees = __webpack_require__(164); - -// global bitmask flag for GameObject.renderMask (used by Scale) -var _FLAG = 4; // 0100 - -/** - * Provides methods used for getting and setting the position, scale and rotation of a Game Object. - * - * @name Phaser.GameObjects.Components.Transform - * @since 3.0.0 - */ - -var Transform = { - - // "private" properties - _scaleX: 1, - _scaleY: 1, - _rotation: 0, - - /** - * The x position of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - x: 0, - - /** - * The y position of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - y: 0, - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - * - * @name Phaser.GameObjects.Components.Transform#z - * @type {number} - * @default 0 - * @since 3.0.0 - */ - z: 0, - - /** - * The w position of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#w - * @type {number} - * @default 0 - * @since 3.0.0 - */ - w: 0, - - /** - * The horizontal scale of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#scaleX - * @type {number} - * @default 1 - * @since 3.0.0 - */ - scaleX: { - - get: function () - { - return this._scaleX; - }, - - set: function (value) - { - this._scaleX = value; - - if (this._scaleX === 0) - { - this.renderFlags &= ~_FLAG; - } - else - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The vertical scale of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#scaleY - * @type {number} - * @default 1 - * @since 3.0.0 - */ - scaleY: { - - get: function () - { - return this._scaleY; - }, - - set: function (value) - { - this._scaleY = value; - - if (this._scaleY === 0) - { - this.renderFlags &= ~_FLAG; - } - else - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The angle of this Game Object as expressed in degrees. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - * - * @name Phaser.GameObjects.Components.Transform#angle - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - angle: { - - get: function () - { - return WrapAngleDegrees(this._rotation * MATH_CONST.RAD_TO_DEG); - }, - - set: function (value) - { - // value is in degrees - this.rotation = WrapAngleDegrees(value) * MATH_CONST.DEG_TO_RAD; - } - }, - - /** - * The angle of this Game Object in radians. - * - * If you prefer to work in degrees, see the `angle` property instead. - * - * @name Phaser.GameObjects.Components.Transform#rotation - * @type {number} - * @default 1 - * @since 3.0.0 - */ - rotation: { - - get: function () - { - return this._rotation; - }, - - set: function (value) - { - // value is in radians - this._rotation = WrapAngle(value); - } - }, - - /** - * Sets the position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setPosition - * @since 3.0.0 - * - * @param {number} [x=0] - The x position of this Game Object. - * @param {number} [y] - The y position of this Game Object. If not set it will use the `x` value. - * @param {number} [z=0] - The z position of this Game Object. - * @param {number} [w=0] - The w position of this Game Object. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setPosition: function (x, y, z, w) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = x; } - if (z === undefined) { z = 0; } - if (w === undefined) { w = 0; } - - this.x = x; - this.y = y; - this.z = z; - this.w = w; - - return this; - }, - - /** - * Sets the rotation of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setRotation - * @since 3.0.0 - * - * @param {number} [radians=0] - The rotation of this Game Object, in radians. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setRotation: function (radians) - { - if (radians === undefined) { radians = 0; } - - this.rotation = radians; - - return this; - }, - - /** - * Sets the angle of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setAngle - * @since 3.0.0 - * - * @param {number} [degrees=0] - The rotation of this Game Object, in degrees. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setAngle: function (degrees) - { - if (degrees === undefined) { degrees = 0; } - - this.angle = degrees; - - return this; - }, - - /** - * Sets the scale of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setScale - * @since 3.0.0 - * - * @param {number} x - The horizontal scale of this Game Object. - * @param {number} [y] - The vertical scale of this Game Object. If not set it will use the `x` value. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setScale: function (x, y) - { - if (x === undefined) { x = 1; } - if (y === undefined) { y = x; } - - this.scaleX = x; - this.scaleY = y; - - return this; - }, - - /** - * Sets the x position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setX - * @since 3.0.0 - * - * @param {number} [value=0] - The x position of this Game Object. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setX: function (value) - { - if (value === undefined) { value = 0; } - - this.x = value; - - return this; - }, - - /** - * Sets the y position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setY - * @since 3.0.0 - * - * @param {number} [value=0] - The y position of this Game Object. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setY: function (value) - { - if (value === undefined) { value = 0; } - - this.y = value; - - return this; - }, - - /** - * Sets the z position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setZ - * @since 3.0.0 - * - * @param {number} [value=0] - The z position of this Game Object. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setZ: function (value) - { - if (value === undefined) { value = 0; } - - this.z = value; - - return this; - }, - - /** - * Sets the w position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setW - * @since 3.0.0 - * - * @param {number} [value=0] - The w position of this Game Object. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setW: function (value) - { - if (value === undefined) { value = 0; } - - this.w = value; - - return this; - } - -}; - -module.exports = Transform; - - -/***/ }), -/* 406 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// bitmask flag for GameObject.renderMask -var _FLAG = 1; // 0001 - -/** - * Provides methods used for setting the visibility of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Visible - * @since 3.0.0 - */ - -var Visible = { - - _visible: true, - - /** - * The visible state of the Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - * - * @name Phaser.GameObjects.Components.Visible#visible - * @type {boolean} - * @since 3.0.0 - */ - visible: { - - get: function () - { - return this._visible; - }, - - set: function (value) - { - if (value) - { - this._visible = true; - this.renderFlags |= _FLAG; - } - else - { - this._visible = false; - this.renderFlags &= ~_FLAG; - } - } - - }, - - /** - * Sets the visibility of this Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - * - * @method Phaser.GameObjects.Components.Visible#setVisible - * @since 3.0.0 - * - * @param {boolean} value - The visible state of the Game Object. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setVisible: function (value) - { - this.visible = value; - - return this; - } -}; - -module.exports = Visible; - - -/***/ }), -/* 407 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.IncAlpha - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var IncAlpha = function (items, value) -{ - for (var i = 0; i < items.length; i++) - { - items[i].alpha += value; - } - - return items; -}; - -module.exports = IncAlpha; - - -/***/ }), -/* 408 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.IncX - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var IncX = function (items, value) -{ - for (var i = 0; i < items.length; i++) - { - items[i].x += value; - } - - return items; -}; - -module.exports = IncX; - - -/***/ }), -/* 409 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.IncXY - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var IncXY = function (items, x, y) -{ - for (var i = 0; i < items.length; i++) - { - items[i].x += x; - items[i].y += y; - } - - return items; -}; - -module.exports = IncXY; - - -/***/ }), -/* 410 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.IncY - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var IncY = function (items, value) -{ - for (var i = 0; i < items.length; i++) - { - items[i].y += value; - } - - return items; -}; - -module.exports = IncY; - - -/***/ }), -/* 411 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.PlaceOnCircle - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Circle} circle - [description] - * @param {number} [startAngle=0] - [description] - * @param {number} [endAngle=6.28] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var PlaceOnCircle = function (items, circle, startAngle, endAngle) -{ - if (startAngle === undefined) { startAngle = 0; } - if (endAngle === undefined) { endAngle = 6.28; } - - var angle = startAngle; - var angleStep = (endAngle - startAngle) / items.length; - - for (var i = 0; i < items.length; i++) - { - items[i].x = circle.x + (circle.radius * Math.cos(angle)); - items[i].y = circle.y + (circle.radius * Math.sin(angle)); - - angle += angleStep; - } - - return items; -}; - -module.exports = PlaceOnCircle; - - -/***/ }), -/* 412 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.PlaceOnEllipse - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Ellipse} ellipse - [description] - * @param {number} [startAngle=0] - [description] - * @param {number} [endAngle=6.28] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var PlaceOnEllipse = function (items, ellipse, startAngle, endAngle) -{ - if (startAngle === undefined) { startAngle = 0; } - if (endAngle === undefined) { endAngle = 6.28; } - - var angle = startAngle; - var angleStep = (endAngle - startAngle) / items.length; - - var a = ellipse.width / 2; - var b = ellipse.height / 2; - - for (var i = 0; i < items.length; i++) - { - items[i].x = ellipse.x + a * Math.cos(angle); - items[i].y = ellipse.y + b * Math.sin(angle); - - angle += angleStep; - } - - return items; -}; - -module.exports = PlaceOnEllipse; - - -/***/ }), -/* 413 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetPoints = __webpack_require__(109); - -/** - * [description] - * - * @function Phaser.Actions.PlaceOnLine - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Line} line - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var PlaceOnLine = function (items, line) -{ - var points = GetPoints(line, items.length); - - for (var i = 0; i < items.length; i++) - { - var item = items[i]; - var point = points[i]; - - item.x = point.x; - item.y = point.y; - } - - return items; -}; - -module.exports = PlaceOnLine; - - -/***/ }), -/* 414 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MarchingAnts = __webpack_require__(191); -var RotateLeft = __webpack_require__(192); -var RotateRight = __webpack_require__(193); - -// Place the items in the array around the perimeter of the given rectangle. - -// Placement starts from the top-left of the rectangle, and proceeds in a -// clockwise direction. If the shift parameter is given you can offset where -// placement begins. - -/** - * [description] - * - * @function Phaser.Actions.PlaceOnRectangle - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {integer} [shift=1] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var PlaceOnRectangle = function (items, rect, shift) -{ - if (shift === undefined) { shift = 0; } - - var points = MarchingAnts(rect, false, items.length); - - if (shift > 0) - { - RotateLeft(points, shift); - } - else if (shift < 0) - { - RotateRight(points, Math.abs(shift)); - } - - for (var i = 0; i < items.length; i++) - { - items[i].x = points[i].x; - items[i].y = points[i].y; - } - - return items; -}; - -module.exports = PlaceOnRectangle; - - -/***/ }), -/* 415 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// var GetPointsOnLine = require('../geom/line/GetPointsOnLine'); -var BresenhamPoints = __webpack_require__(194); - -/** - * [description] - * - * @function Phaser.Actions.PlaceOnTriangle - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} [stepRate=1] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var PlaceOnTriangle = function (items, triangle, stepRate) -{ - var p1 = BresenhamPoints({ x1: triangle.x1, y1: triangle.y1, x2: triangle.x2, y2: triangle.y2 }, stepRate); - var p2 = BresenhamPoints({ x1: triangle.x2, y1: triangle.y2, x2: triangle.x3, y2: triangle.y3 }, stepRate); - var p3 = BresenhamPoints({ x1: triangle.x3, y1: triangle.y3, x2: triangle.x1, y2: triangle.y1 }, stepRate); - - // Remove overlaps - p1.pop(); - p2.pop(); - p3.pop(); - - p1 = p1.concat(p2, p3); - - var step = p1.length / items.length; - var p = 0; - - for (var i = 0; i < items.length; i++) - { - var item = items[i]; - var point = p1[Math.floor(p)]; - - item.x = point.x; - item.y = point.y; - - p += step; - } - - return items; -}; - -module.exports = PlaceOnTriangle; - - -/***/ }), -/* 416 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.PlayAnimation - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {string} key - [description] - * @param {string|integer} [startFrame] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var PlayAnimation = function (items, key, startFrame) -{ - for (var i = 0; i < items.length; i++) - { - items[i].anims.play(key, startFrame); - } - - return items; -}; - -module.exports = PlayAnimation; - - -/***/ }), -/* 417 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Random = __webpack_require__(106); - -/** - * [description] - * - * @function Phaser.Actions.RandomCircle - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Circle} circle - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var RandomCircle = function (items, circle) -{ - for (var i = 0; i < items.length; i++) - { - Random(circle, items[i]); - } - - return items; -}; - -module.exports = RandomCircle; - - -/***/ }), -/* 418 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Random = __webpack_require__(110); - -/** - * [description] - * - * @function Phaser.Actions.RandomEllipse - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Ellipse} ellipse - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var RandomEllipse = function (items, ellipse) -{ - for (var i = 0; i < items.length; i++) - { - Random(ellipse, items[i]); - } - - return items; -}; - -module.exports = RandomEllipse; - - -/***/ }), -/* 419 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Random = __webpack_require__(111); - -/** - * [description] - * - * @function Phaser.Actions.RandomLine - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Line} line - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var RandomLine = function (items, line) -{ - for (var i = 0; i < items.length; i++) - { - Random(line, items[i]); - } - - return items; -}; - -module.exports = RandomLine; - - -/***/ }), -/* 420 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Random = __webpack_require__(108); - -/** - * [description] - * - * @function Phaser.Actions.RandomRectangle - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var RandomRectangle = function (items, rect) -{ - for (var i = 0; i < items.length; i++) - { - Random(rect, items[i]); - } - - return items; -}; - -module.exports = RandomRectangle; - - -/***/ }), -/* 421 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Random = __webpack_require__(112); - -/** - * [description] - * - * @function Phaser.Actions.RandomTriangle - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Triangle} triangle - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var RandomTriangle = function (items, triangle) -{ - for (var i = 0; i < items.length; i++) - { - Random(triangle, items[i]); - } - - return items; -}; - -module.exports = RandomTriangle; - - -/***/ }), -/* 422 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.Rotate - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * @param {number} [step=0] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var Rotate = function (items, value, step) -{ - if (step === undefined) { step = 0; } - - for (var i = 0; i < items.length; i++) - { - items[i].rotation += value + (i * step); - } - - return items; -}; - -module.exports = Rotate; - - -/***/ }), -/* 423 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RotateAroundDistance = __webpack_require__(113); -var DistanceBetween = __webpack_require__(42); - -/** - * [description] - * - * @function Phaser.Actions.RotateAround - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {object} point - Any object with public `x` and `y` properties. - * @param {number} angle - The angle to rotate by, in radians. - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var RotateAround = function (items, point, angle) -{ - var x = point.x; - var y = point.y; - - for (var i = 0; i < items.length; i++) - { - var item = items[i]; - - RotateAroundDistance(item, x, y, angle, Math.max(1, DistanceBetween(item.x, item.y, x, y))); - } - - return items; -}; - -module.exports = RotateAround; - - -/***/ }), -/* 424 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MathRotateAroundDistance = __webpack_require__(113); - -/** - * [description] - * - * @function Phaser.Actions.RotateAroundDistance - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {object} point - Any object with public `x` and `y` properties. - * @param {number} angle - The angle to rotate by, in radians. - * @param {number} distance - The distance from the point of rotation in pixels. - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var RotateAroundDistance = function (items, point, angle, distance) -{ - var x = point.x; - var y = point.y; - - // There's nothing to do - if (distance === 0) - { - return items; - } - - for (var i = 0; i < items.length; i++) - { - MathRotateAroundDistance(items[i], x, y, angle, distance); - } - - return items; -}; - -module.exports = RotateAroundDistance; - - -/***/ }), -/* 425 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.ScaleX - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var ScaleX = function (items, value) -{ - for (var i = 0; i < items.length; i++) - { - items[i].scaleX += value; - } - - return items; -}; - -module.exports = ScaleX; - - -/***/ }), -/* 426 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.ScaleXY - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var ScaleXY = function (items, x, y) -{ - for (var i = 0; i < items.length; i++) - { - items[i].scaleX += x; - items[i].scaleY += y; - } - - return items; -}; - -module.exports = ScaleXY; - - -/***/ }), -/* 427 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.ScaleY - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var ScaleY = function (items, value) -{ - for (var i = 0; i < items.length; i++) - { - items[i].scaleY += value; - } - - return items; -}; - -module.exports = ScaleY; - - -/***/ }), -/* 428 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetAlpha - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * @param {number} [step=0] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetAlpha = function (items, value, step) -{ - if (step === undefined) { step = 0; } - - for (var i = 0; i < items.length; i++) - { - items[i].alpha = value + (i * step); - } - - return items; -}; - -module.exports = SetAlpha; - - -/***/ }), -/* 429 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetBlendMode - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetBlendMode = function (items, value) -{ - for (var i = 0; i < items.length; i++) - { - items[i].setBlendMode(value); - } - - return items; -}; - -module.exports = SetBlendMode; - - -/***/ }), -/* 430 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetDepth - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * @param {number} [step=0] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetDepth = function (items, value, step) -{ - if (step === undefined) { step = 0; } - - for (var i = 0; i < items.length; i++) - { - items[i].depth = value + (i * step); - } - - return items; -}; - -module.exports = SetDepth; - - -/***/ }), -/* 431 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetHitArea - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {any} hitArea - [description] - * @param {function} hitAreaCallback - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetHitArea = function (items, hitArea, hitAreaCallback) -{ - for (var i = 0; i < items.length; i++) - { - items[i].setInteractive(hitArea, hitAreaCallback); - } - - return items; -}; - -module.exports = SetHitArea; - - -/***/ }), -/* 432 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetOrigin - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetOrigin = function (items, x, y) -{ - for (var i = 0; i < items.length; i++) - { - items[i].setOrigin(x, y); - } - - return items; -}; - -module.exports = SetOrigin; - - -/***/ }), -/* 433 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetRotation - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * @param {number} [step=0] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetRotation = function (items, value, step) -{ - if (step === undefined) { step = 0; } - - for (var i = 0; i < items.length; i++) - { - items[i].rotation = value + (i * step); - } - - return items; -}; - -module.exports = SetRotation; - - -/***/ }), -/* 434 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetScale - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} [stepX=0] - [description] - * @param {number} [stepY=0] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetScale = function (items, x, y, stepX, stepY) -{ - if (stepX === undefined) { stepX = 0; } - if (stepY === undefined) { stepY = 0; } - - for (var i = 0; i < items.length; i++) - { - items[i].setScale( - x + (i * stepX), - y + (i * stepY) - ); - } - - return items; -}; - -module.exports = SetScale; - - -/***/ }), -/* 435 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetScaleX - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * @param {number} [step=0] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetScaleX = function (items, value, step) -{ - if (step === undefined) { step = 0; } - - for (var i = 0; i < items.length; i++) - { - items[i].scaleX = value + (i * step); - } - - return items; -}; - -module.exports = SetScaleX; - - -/***/ }), -/* 436 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetScaleY - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * @param {number} [step=0] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetScaleY = function (items, value, step) -{ - if (step === undefined) { step = 0; } - - for (var i = 0; i < items.length; i++) - { - items[i].scaleY = value + (i * step); - } - - return items; -}; - -module.exports = SetScaleY; - - -/***/ }), -/* 437 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetTint - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} topLeft - [description] - * @param {number} [topRight] - [description] - * @param {number} [bottomLeft] - [description] - * @param {number} [bottomRight] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetTint = function (items, topLeft, topRight, bottomLeft, bottomRight) -{ - for (var i = 0; i < items.length; i++) - { - items[i].setTint(topLeft, topRight, bottomLeft, bottomRight); - } - - return items; -}; - -module.exports = SetTint; - - -/***/ }), -/* 438 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetVisible - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {boolean} value - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetVisible = function (items, value) -{ - for (var i = 0; i < items.length; i++) - { - items[i].visible = value; - } - - return items; -}; - -module.exports = SetVisible; - - -/***/ }), -/* 439 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetX - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * @param {number} [step=0] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetX = function (items, value, step) -{ - if (step === undefined) { step = 0; } - - for (var i = 0; i < items.length; i++) - { - items[i].x = value + (i * step); - } - - return items; -}; - -module.exports = SetX; - - -/***/ }), -/* 440 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetXY - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} [stepX=0] - [description] - * @param {number} [stepY=0] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetXY = function (items, x, y, stepX, stepY) -{ - if (stepX === undefined) { stepX = 0; } - if (stepY === undefined) { stepY = 0; } - - for (var i = 0; i < items.length; i++) - { - items[i].x = x + (i * stepX); - items[i].y = y + (i * stepY); - } - - return items; -}; - -module.exports = SetXY; - - -/***/ }), -/* 441 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetY - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * @param {number} [step=0] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetY = function (items, value, step) -{ - if (step === undefined) { step = 0; } - - for (var i = 0; i < items.length; i++) - { - items[i].y = value + (i * step); - } - - return items; -}; - -module.exports = SetY; - - -/***/ }), -/* 442 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Vector2 = __webpack_require__(6); - -// Iterate through items changing the position of each element to -// be that of the element that came before it in the array (or after it if direction = 1) -// The first items position is set to x/y. -// The final x/y coords are returned - -/** - * [description] - * - * @function Phaser.Actions.ShiftPosition - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} x - [description] - * @param {number} y - [description] - * @param {integer} [direction=0] - [description] - * @param {Phaser.Math.Vector2|object} [output] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var ShiftPosition = function (items, x, y, direction, output) -{ - if (direction === undefined) { direction = 0; } - if (output === undefined) { output = new Vector2(); } - - var px; - var py; - - if (items.length > 1) - { - var i; - var cx; - var cy; - var cur; - - if (direction === 0) - { - // Bottom to Top - - var len = items.length - 1; - - px = items[len].x; - py = items[len].y; - - for (i = len - 1; i >= 0; i--) - { - // Current item - cur = items[i]; - - // Get current item x/y, to be passed to the next item in the list - cx = cur.x; - cy = cur.y; - - // Set current item to the previous items x/y - cur.x = px; - cur.y = py; - - // Set current as previous - px = cx; - py = cy; - } - - // Update the head item to the new x/y coordinates - items[len].x = x; - items[len].y = y; - } - else - { - // Top to Bottom - - px = items[0].x; - py = items[0].y; - - for (i = 1; i < items.length; i++) - { - // Current item - cur = items[i]; - - // Get current item x/y, to be passed to the next item in the list - cx = cur.x; - cy = cur.y; - - // Set current item to the previous items x/y - cur.x = px; - cur.y = py; - - // Set current as previous - px = cx; - py = cy; - } - - // Update the head item to the new x/y coordinates - items[0].x = x; - items[0].y = y; - } - } - else - { - px = items[0].x; - py = items[0].y; - - items[0].x = x; - items[0].y = y; - } - - // Return the final set of coordinates as they're effectively lost from the shift and may be needed - - output.x = px; - output.y = py; - - return output; -}; - -module.exports = ShiftPosition; - - -/***/ }), -/* 443 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ArrayShuffle = __webpack_require__(80); - -/** - * [description] - * - * @function Phaser.Actions.Shuffle - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var Shuffle = function (items) -{ - return ArrayShuffle(items); -}; - -module.exports = Shuffle; - - -/***/ }), -/* 444 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MathSmootherStep = __webpack_require__(195); - -/** - * [description] - * - * @function Phaser.Actions.SmootherStep - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {string} property - [description] - * @param {number} min - [description] - * @param {number} max - [description] - * @param {number} inc - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SmootherStep = function (items, property, min, max, inc) -{ - if (inc === undefined) { inc = false; } - - var step = Math.abs(max - min) / items.length; - var i; - - if (inc) - { - for (i = 0; i < items.length; i++) - { - items[i][property] += MathSmootherStep(i * step, min, max); - } - } - else - { - for (i = 0; i < items.length; i++) - { - items[i][property] = MathSmootherStep(i * step, min, max); - } - } - - return items; -}; - -module.exports = SmootherStep; - - -/***/ }), -/* 445 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MathSmoothStep = __webpack_require__(196); - -/** - * [description] - * - * @function Phaser.Actions.SmoothStep - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {string} property - [description] - * @param {number} min - [description] - * @param {number} max - [description] - * @param {number} inc - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SmoothStep = function (items, property, min, max, inc) -{ - if (inc === undefined) { inc = false; } - - var step = Math.abs(max - min) / items.length; - var i; - - if (inc) - { - for (i = 0; i < items.length; i++) - { - items[i][property] += MathSmoothStep(i * step, min, max); - } - } - else - { - for (i = 0; i < items.length; i++) - { - items[i][property] = MathSmoothStep(i * step, min, max); - } - } - - return items; -}; - -module.exports = SmoothStep; - - -/***/ }), -/* 446 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.Spread - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {string} property - [description] - * @param {number} min - [description] - * @param {number} max - [description] - * @param {number} inc - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var Spread = function (items, property, min, max, inc) -{ - if (inc === undefined) { inc = false; } - - var step = Math.abs(max - min) / items.length; - var i; - - if (inc) - { - for (i = 0; i < items.length; i++) - { - items[i][property] += i * step; - } - } - else - { - for (i = 0; i < items.length; i++) - { - items[i][property] = i * step; - } - } - - return items; -}; - -module.exports = Spread; - - -/***/ }), -/* 447 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.ToggleVisible - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var ToggleVisible = function (items) -{ - for (var i = 0; i < items.length; i++) - { - items[i].visible = !items[i].visible; - } - - return items; -}; - -module.exports = ToggleVisible; - - -/***/ }), -/* 448 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Animations - */ - -module.exports = { - - Animation: __webpack_require__(197), - AnimationFrame: __webpack_require__(198), - AnimationManager: __webpack_require__(199) - -}; - - -/***/ }), -/* 449 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Cache - */ - -module.exports = { - - BaseCache: __webpack_require__(201), - CacheManager: __webpack_require__(202) - -}; - - -/***/ }), -/* 450 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Cameras - */ - -module.exports = { - - Controls: __webpack_require__(451), - Scene2D: __webpack_require__(454), - Sprite3D: __webpack_require__(456) - -}; - - -/***/ }), -/* 451 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Cameras.Controls - */ - -module.exports = { - - Fixed: __webpack_require__(452), - Smoothed: __webpack_require__(453) - -}; - - -/***/ }), -/* 452 */ -/***/ (function(module, exports, __webpack_require__) { - /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. @@ -81513,821 +79206,39 @@ module.exports = { */ var Class = __webpack_require__(0); -var GetValue = __webpack_require__(4); - -// var camControl = new CameraControl({ -// camera: this.cameras.main, -// left: cursors.left, -// right: cursors.right, -// speed: float OR { x: 0, y: 0 } -// }) - -/** - * @classdesc - * [description] - * - * @class FixedKeyControl - * @memberOf Phaser.Cameras.Controls - * @constructor - * @since 3.0.0 - * - * @param {object} config - [description] - */ -var FixedKeyControl = new Class({ - - initialize: - - function FixedKeyControl (config) - { - /** - * The Camera that this Control will update. - * - * @name Phaser.Cameras.Controls.FixedKeyControl#camera - * @type {Phaser.Cameras.Scene2D.Camera} - * @default null - * @since 3.0.0 - */ - this.camera = GetValue(config, 'camera', null); - - /** - * The Key to be pressed that will move the Camera left. - * - * @name Phaser.Cameras.Controls.FixedKeyControl#left - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.left = GetValue(config, 'left', null); - - /** - * The Key to be pressed that will move the Camera right. - * - * @name Phaser.Cameras.Controls.FixedKeyControl#right - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.right = GetValue(config, 'right', null); - - /** - * The Key to be pressed that will move the Camera up. - * - * @name Phaser.Cameras.Controls.FixedKeyControl#up - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.up = GetValue(config, 'up', null); - - /** - * The Key to be pressed that will move the Camera down. - * - * @name Phaser.Cameras.Controls.FixedKeyControl#down - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.down = GetValue(config, 'down', null); - - /** - * The Key to be pressed that will zoom the Camera in. - * - * @name Phaser.Cameras.Controls.FixedKeyControl#zoomIn - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.zoomIn = GetValue(config, 'zoomIn', null); - - /** - * The Key to be pressed that will zoom the Camera out. - * - * @name Phaser.Cameras.Controls.FixedKeyControl#zoomOut - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.zoomOut = GetValue(config, 'zoomOut', null); - - /** - * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. - * - * @name Phaser.Cameras.Controls.FixedKeyControl#zoomSpeed - * @type {float} - * @default 0.01 - * @since 3.0.0 - */ - this.zoomSpeed = GetValue(config, 'zoomSpeed', 0.01); - - /** - * The horizontal speed the camera will move. - * - * @name Phaser.Cameras.Controls.FixedKeyControl#speedX - * @type {float} - * @default 0 - * @since 3.0.0 - */ - - /** - * The vertical speed the camera will move. - * - * @name Phaser.Cameras.Controls.FixedKeyControl#speedY - * @type {float} - * @default 0 - * @since 3.0.0 - */ - var speed = GetValue(config, 'speed', null); - - if (typeof speed === 'number') - { - this.speedX = speed; - this.speedY = speed; - } - else - { - this.speedX = GetValue(config, 'speed.x', 0); - this.speedY = GetValue(config, 'speed.y', 0); - } - - /** - * [description] - * - * @name Phaser.Cameras.Controls.FixedKeyControl#_zoom - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._zoom = 0; - - /** - * A flag controlling if the Controls will update the Camera or not. - * - * @name Phaser.Cameras.Controls.FixedKeyControl#active - * @type {boolean} - * @since 3.0.0 - */ - this.active = (this.camera !== null); - }, - - /** - * Starts the Key Control running, providing it has been linked to a camera. - * - * @method Phaser.Cameras.Controls.FixedKeyControl#start - * @since 3.0.0 - * - * @return {Phaser.Cameras.Controls.FixedKeyControl} This Key Control instance. - */ - start: function () - { - this.active = (this.camera !== null); - - return this; - }, - - /** - * Stops this Key Control from running. Call `start` to start it again. - * - * @method Phaser.Cameras.Controls.FixedKeyControl#stop - * @since 3.0.0 - * - * @return {Phaser.Cameras.Controls.FixedKeyControl} This Key Control instance. - */ - stop: function () - { - this.active = false; - - return this; - }, - - /** - * Binds this Key Control to a camera. - * - * @method Phaser.Cameras.Controls.FixedKeyControl#setCamera - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to bind this Key Control to. - * - * @return {Phaser.Cameras.Controls.FixedKeyControl} This Key Control instance. - */ - setCamera: function (camera) - { - this.camera = camera; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Controls.FixedKeyControl#update - * @since 3.0.0 - * - * @param {number} delta - [description] - */ - update: function (delta) - { - if (!this.active) - { - return; - } - - if (delta === undefined) { delta = 1; } - - var cam = this.camera; - - if (this.up && this.up.isDown) - { - cam.scrollY -= ((this.speedY * delta) | 0); - } - else if (this.down && this.down.isDown) - { - cam.scrollY += ((this.speedY * delta) | 0); - } - - if (this.left && this.left.isDown) - { - cam.scrollX -= ((this.speedX * delta) | 0); - } - else if (this.right && this.right.isDown) - { - cam.scrollX += ((this.speedX * delta) | 0); - } - - // Camera zoom - - if (this.zoomIn && this.zoomIn.isDown) - { - cam.zoom -= this.zoomSpeed; - - if (cam.zoom < 0.1) - { - cam.zoom = 0.1; - } - } - else if (this.zoomOut && this.zoomOut.isDown) - { - cam.zoom += this.zoomSpeed; - } - }, - - /** - * Destroys this Key Control. - * - * @method Phaser.Cameras.Controls.FixedKeyControl#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.camera = null; - - this.left = null; - this.right = null; - this.up = null; - this.down = null; - - this.zoomIn = null; - this.zoomOut = null; - } - -}); - -module.exports = FixedKeyControl; - - -/***/ }), -/* 453 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GetValue = __webpack_require__(4); - -// var controlConfig = { -// camera: this.cameras.main, -// left: cursors.left, -// right: cursors.right, -// up: cursors.up, -// down: cursors.down, -// zoomIn: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q), -// zoomOut: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E), -// zoomSpeed: 0.02, -// acceleration: 0.06, -// drag: 0.0005, -// maxSpeed: 1.0 -// }; - -/** - * @classdesc - * [description] - * - * @class SmoothedKeyControl - * @memberOf Phaser.Cameras.Controls - * @constructor - * @since 3.0.0 - * - * @param {object} config - [description] - */ -var SmoothedKeyControl = new Class({ - - initialize: - - function SmoothedKeyControl (config) - { - /** - * The Camera that this Control will update. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#camera - * @type {Phaser.Cameras.Scene2D.Camera} - * @default null - * @since 3.0.0 - */ - this.camera = GetValue(config, 'camera', null); - - /** - * The Key to be pressed that will move the Camera left. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#left - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.left = GetValue(config, 'left', null); - - /** - * The Key to be pressed that will move the Camera right. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#right - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.right = GetValue(config, 'right', null); - - /** - * The Key to be pressed that will move the Camera up. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#up - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.up = GetValue(config, 'up', null); - - /** - * The Key to be pressed that will move the Camera down. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#down - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.down = GetValue(config, 'down', null); - - /** - * The Key to be pressed that will zoom the Camera in. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomIn - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.zoomIn = GetValue(config, 'zoomIn', null); - - /** - * The Key to be pressed that will zoom the Camera out. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomOut - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.zoomOut = GetValue(config, 'zoomOut', null); - - /** - * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomSpeed - * @type {float} - * @default 0.01 - * @since 3.0.0 - */ - this.zoomSpeed = GetValue(config, 'zoomSpeed', 0.01); - - /** - * The horizontal acceleration the camera will move. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#accelX - * @type {float} - * @default 0 - * @since 3.0.0 - */ - - /** - * The vertical acceleration the camera will move. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#accelY - * @type {float} - * @default 0 - * @since 3.0.0 - */ - var accel = GetValue(config, 'acceleration', null); - - if (typeof accel === 'number') - { - this.accelX = accel; - this.accelY = accel; - } - else - { - this.accelX = GetValue(config, 'acceleration.x', 0); - this.accelY = GetValue(config, 'acceleration.y', 0); - } - - /** - * The horizontal drag applied to the camera when it is moving. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#dragX - * @type {float} - * @default 0 - * @since 3.0.0 - */ - - /** - * The vertical drag applied to the camera when it is moving. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#dragY - * @type {float} - * @default 0 - * @since 3.0.0 - */ - var drag = GetValue(config, 'drag', null); - - if (typeof drag === 'number') - { - this.dragX = drag; - this.dragY = drag; - } - else - { - this.dragX = GetValue(config, 'drag.x', 0); - this.dragY = GetValue(config, 'drag.y', 0); - } - - /** - * The maximum horizontal speed the camera will move. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#maxSpeedX - * @type {float} - * @default 0 - * @since 3.0.0 - */ - - /** - * The maximum vertical speed the camera will move. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#maxSpeedY - * @type {float} - * @default 0 - * @since 3.0.0 - */ - var maxSpeed = GetValue(config, 'maxSpeed', null); - - if (typeof maxSpeed === 'number') - { - this.maxSpeedX = maxSpeed; - this.maxSpeedY = maxSpeed; - } - else - { - this.maxSpeedX = GetValue(config, 'maxSpeed.x', 0); - this.maxSpeedY = GetValue(config, 'maxSpeed.y', 0); - } - - /** - * [description] - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#_speedX - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._speedX = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#_speedY - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._speedY = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#_zoom - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._zoom = 0; - - /** - * A flag controlling if the Controls will update the Camera or not. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#active - * @type {boolean} - * @since 3.0.0 - */ - this.active = (this.camera !== null); - }, - - /** - * Starts the Key Control running, providing it has been linked to a camera. - * - * @method Phaser.Cameras.Controls.SmoothedKeyControl#start - * @since 3.0.0 - * - * @return {Phaser.Cameras.Controls.SmoothedKeyControl} This Key Control instance. - */ - start: function () - { - this.active = (this.camera !== null); - - return this; - }, - - /** - * Stops this Key Control from running. Call `start` to start it again. - * - * @method Phaser.Cameras.Controls.SmoothedKeyControl#stop - * @since 3.0.0 - * - * @return {Phaser.Cameras.Controls.SmoothedKeyControl} This Key Control instance. - */ - stop: function () - { - this.active = false; - - return this; - }, - - /** - * Binds this Key Control to a camera. - * - * @method Phaser.Cameras.Controls.SmoothedKeyControl#setCamera - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to bind this Key Control to. - * - * @return {Phaser.Cameras.Controls.SmoothedKeyControl} This Key Control instance. - */ - setCamera: function (camera) - { - this.camera = camera; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Controls.SmoothedKeyControl#update - * @since 3.0.0 - * - * @param {[type]} delta - [description] - */ - update: function (delta) - { - if (!this.active) - { - return; - } - - if (delta === undefined) { delta = 1; } - - var cam = this.camera; - - // Apply Deceleration - - if (this._speedX > 0) - { - this._speedX -= this.dragX * delta; - - if (this._speedX < 0) - { - this._speedX = 0; - } - } - else if (this._speedX < 0) - { - this._speedX += this.dragX * delta; - - if (this._speedX > 0) - { - this._speedX = 0; - } - } - - if (this._speedY > 0) - { - this._speedY -= this.dragY * delta; - - if (this._speedY < 0) - { - this._speedY = 0; - } - } - else if (this._speedY < 0) - { - this._speedY += this.dragY * delta; - - if (this._speedY > 0) - { - this._speedY = 0; - } - } - - // Check for keys - - if (this.up && this.up.isDown) - { - this._speedY += this.accelY; - - if (this._speedY > this.maxSpeedY) - { - this._speedY = this.maxSpeedY; - } - } - else if (this.down && this.down.isDown) - { - this._speedY -= this.accelY; - - if (this._speedY < -this.maxSpeedY) - { - this._speedY = -this.maxSpeedY; - } - } - - if (this.left && this.left.isDown) - { - this._speedX += this.accelX; - - if (this._speedX > this.maxSpeedX) - { - this._speedX = this.maxSpeedX; - } - } - else if (this.right && this.right.isDown) - { - this._speedX -= this.accelX; - - if (this._speedX < -this.maxSpeedX) - { - this._speedX = -this.maxSpeedX; - } - } - - // Camera zoom - - if (this.zoomIn && this.zoomIn.isDown) - { - this._zoom = -this.zoomSpeed; - } - else if (this.zoomOut && this.zoomOut.isDown) - { - this._zoom = this.zoomSpeed; - } - else - { - this._zoom = 0; - } - - // Apply to Camera - - if (this._speedX !== 0) - { - cam.scrollX -= ((this._speedX * delta) | 0); - } - - if (this._speedY !== 0) - { - cam.scrollY -= ((this._speedY * delta) | 0); - } - - if (this._zoom !== 0) - { - cam.zoom += this._zoom; - - if (cam.zoom < 0.1) - { - cam.zoom = 0.1; - } - } - }, - - /** - * Destroys this Key Control. - * - * @method Phaser.Cameras.Controls.SmoothedKeyControl#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.camera = null; - - this.left = null; - this.right = null; - this.up = null; - this.down = null; - - this.zoomIn = null; - this.zoomOut = null; - } - -}); - -module.exports = SmoothedKeyControl; - - -/***/ }), -/* 454 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Cameras.Scene2D - */ - -module.exports = { - - Camera: __webpack_require__(115), - CameraManager: __webpack_require__(455) - -}; - - -/***/ }), -/* 455 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Camera = __webpack_require__(115); -var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(2); var PluginManager = __webpack_require__(12); -var RectangleContains = __webpack_require__(33); +var TimerEvent = __webpack_require__(183); /** * @classdesc * [description] * - * @class CameraManager - * @memberOf Phaser.Cameras.Scene2D + * @class Clock + * @memberOf Phaser.Time * @constructor * @since 3.0.0 * - * @param {Phaser.Scene} scene - The Scene that owns the Camera Manager plugin. + * @param {Phaser.Scene} scene - [description] */ -var CameraManager = new Class({ +var Clock = new Class({ initialize: - function CameraManager (scene) + function Clock (scene) { /** - * The Scene that owns the Camera Manager plugin. + * [description] * - * @name Phaser.Cameras.Scene2D.CameraManager#scene + * @name Phaser.Time.Clock#scene * @type {Phaser.Scene} * @since 3.0.0 */ this.scene = scene; /** - * A reference to the Scene.Systems handler for the Scene that owns the Camera Manager. + * [description] * - * @name Phaser.Cameras.Scene2D.CameraManager#systems + * @name Phaser.Time.Clock#systems * @type {Phaser.Scenes.Systems} * @since 3.0.0 */ @@ -82339,8150 +79250,53 @@ var CameraManager = new Class({ } /** - * The current Camera ID. + * [description] * - * @name Phaser.Cameras.Scene2D.CameraManager#currentCameraId + * @name Phaser.Time.Clock#now * @type {number} + * @since 3.0.0 + */ + this.now = Date.now(); + + // Scale the delta time coming into the Clock by this factor + // which then influences anything using this Clock for calculations, like TimerEvents + + /** + * [description] + * + * @name Phaser.Time.Clock#timeScale + * @type {float} * @default 1 - * @readOnly * @since 3.0.0 */ - this.currentCameraId = 1; - - /** - * An Array of the Camera objects being managed by this Camera Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#cameras - * @type {Phaser.Cameras.Scene2D.Camera[]} - * @since 3.0.0 - */ - this.cameras = []; - - /** - * A pool of Camera objects available to be used by the Camera Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#cameraPool - * @type {Phaser.Cameras.Scene2D.Camera[]} - * @since 3.0.0 - */ - this.cameraPool = []; - - if (scene.sys.settings.cameras) - { - // We have cameras to create - this.fromJSON(scene.sys.settings.cameras); - } - else - { - // Make one - this.add(); - } - - /** - * The default Camera in the Camera Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#main - * @type {Phaser.Cameras.Scene2D.Camera} - * @since 3.0.0 - */ - this.main = this.cameras[0]; - - /** - * This scale affects all cameras. It's used by Scale Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#baseScale - * @type {number} - * @since 3.0.0 - */ - this.baseScale = 1.0; - }, - - /** - * Called when the Camera Manager boots. - * Starts the event listeners running. - * - * @method Phaser.Cameras.Scene2D.CameraManager#boot - * @since 3.0.0 - */ - boot: function () - { - var eventEmitter = this.systems.events; - - eventEmitter.on('update', this.update, this); - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#add - * @since 3.0.0 - * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] - * @param {number} [width] - [description] - * @param {number} [height] - [description] - * @param {boolean} [makeMain=false] - [description] - * @param {string} [name=''] - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} [description] - */ - add: function (x, y, width, height, makeMain, name) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (width === undefined) { width = this.scene.sys.game.config.width; } - if (height === undefined) { height = this.scene.sys.game.config.height; } - if (makeMain === undefined) { makeMain = false; } - if (name === undefined) { name = ''; } - - var camera = null; - - if (this.cameraPool.length > 0) - { - camera = this.cameraPool.pop(); - - camera.setViewport(x, y, width, height); - } - else - { - camera = new Camera(x, y, width, height); - } - - camera.setName(name); - camera.setScene(this.scene); - - this.cameras.push(camera); - - if (makeMain) - { - this.main = camera; - } - - camera._id = this.currentCameraId; - - this.currentCameraId = this.currentCameraId << 1; - - return camera; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#addExisting - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} [description] - */ - addExisting: function (camera) - { - var index = this.cameras.indexOf(camera); - var poolIndex = this.cameraPool.indexOf(camera); - - if (index < 0 && poolIndex >= 0) - { - this.cameras.push(camera); - this.cameraPool.slice(poolIndex, 1); - return camera; - } - - return null; - }, - - /* - { - cameras: [ - { - name: string - x: int - y: int - width: int - height: int - zoom: float - rotation: float - roundPixels: bool - scrollX: float - scrollY: float - backgroundColor: string - bounds: { - x: int - y: int - width: int - height: int - } - } - ] - } - */ - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#fromJSON - * @since 3.0.0 - * - * @param {[type]} config - [description] - * - * @return {[type]} [description] - */ - fromJSON: function (config) - { - if (!Array.isArray(config)) - { - config = [ config ]; - } - - var gameWidth = this.scene.sys.game.config.width; - var gameHeight = this.scene.sys.game.config.height; - - for (var i = 0; i < config.length; i++) - { - var cameraConfig = config[i]; - - var x = GetFastValue(cameraConfig, 'x', 0); - var y = GetFastValue(cameraConfig, 'y', 0); - var width = GetFastValue(cameraConfig, 'width', gameWidth); - var height = GetFastValue(cameraConfig, 'height', gameHeight); - - var camera = this.add(x, y, width, height); - - // Direct properties - camera.name = GetFastValue(cameraConfig, 'name', ''); - camera.zoom = GetFastValue(cameraConfig, 'zoom', 1); - camera.rotation = GetFastValue(cameraConfig, 'rotation', 0); - camera.scrollX = GetFastValue(cameraConfig, 'scrollX', 0); - camera.scrollY = GetFastValue(cameraConfig, 'scrollY', 0); - camera.roundPixels = GetFastValue(cameraConfig, 'roundPixels', false); - - // Background Color - - var backgroundColor = GetFastValue(cameraConfig, 'backgroundColor', false); - - if (backgroundColor) - { - camera.setBackgroundColor(backgroundColor); - } - - // Bounds - - var boundsConfig = GetFastValue(cameraConfig, 'bounds', null); - - if (boundsConfig) - { - var bx = GetFastValue(boundsConfig, 'x', 0); - var by = GetFastValue(boundsConfig, 'y', 0); - var bwidth = GetFastValue(boundsConfig, 'width', gameWidth); - var bheight = GetFastValue(boundsConfig, 'height', gameHeight); - - camera.setBounds(bx, by, bwidth, bheight); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#getCamera - * @since 3.0.0 - * - * @param {string} name - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} [description] - */ - getCamera: function (name) - { - this.cameras.forEach(function (camera) - { - if (camera.name === name) - { - return camera; - } - }); - - return null; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#getCameraBelowPointer - * @since 3.0.0 - * - * @param {[type]} pointer - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} [description] - */ - getCameraBelowPointer: function (pointer) - { - var cameras = this.cameras; - - // Start from the most recently added camera (the 'top' camera) - for (var i = cameras.length - 1; i >= 0; i--) - { - var camera = cameras[i]; - - if (camera.inputEnabled && RectangleContains(camera, pointer.x, pointer.y)) - { - return camera; - } - } - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#remove - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - remove: function (camera) - { - var cameraIndex = this.cameras.indexOf(camera); - - if (cameraIndex >= 0 && this.cameras.length > 1) - { - this.cameraPool.push(this.cameras[cameraIndex]); - this.cameras.splice(cameraIndex, 1); - - if (this.main === camera) - { - this.main = this.cameras[0]; - } - } - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#render - * @since 3.0.0 - * - * @param {[type]} renderer - [description] - * @param {[type]} children - [description] - * @param {[type]} interpolation - [description] - */ - render: function (renderer, children, interpolation) - { - var cameras = this.cameras; - var baseScale = this.baseScale; - - for (var i = 0, l = cameras.length; i < l; ++i) - { - var camera = cameras[i]; - - camera.preRender(baseScale, renderer.config.resolution); - - renderer.render(this.scene, children, interpolation, camera); - } - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#resetAll - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} [description] - */ - resetAll: function () - { - while (this.cameras.length > 0) - { - this.cameraPool.push(this.cameras.pop()); - } - - this.main = this.add(); - - return this.main; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#update - * @since 3.0.0 - * - * @param {number} timestep - [description] - * @param {number} delta - [description] - */ - update: function (timestep, delta) - { - for (var i = 0, l = this.cameras.length; i < l; ++i) - { - this.cameras[i].update(timestep, delta); - } - }, - - /** - * Resizes all cameras to the given dimensions. - * - * @method Phaser.Cameras.Scene2D.CameraManager#resize - * @since 3.2.0 - * - * @param {number} width - The new width of the camera. - * @param {number} height - The new height of the camera. - */ - resize: function (width, height) - { - for (var i = 0, l = this.cameras.length; i < l; ++i) - { - this.cameras[i].setSize(width, height); - } - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - // TODO - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.main = undefined; - - for (var i = 0; i < this.cameras.length; i++) - { - this.cameras[i].destroy(); - } - - for (i = 0; i < this.cameraPool.length; i++) - { - this.cameraPool[i].destroy(); - } - - this.cameras = []; - this.cameraPool = []; - this.scene = undefined; - } - -}); - -PluginManager.register('CameraManager', CameraManager, 'cameras'); - -module.exports = CameraManager; - - -/***/ }), -/* 456 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Cameras.Sprite3D - */ - -module.exports = { - - Camera: __webpack_require__(118), - CameraManager: __webpack_require__(460), - OrthographicCamera: __webpack_require__(214), - PerspectiveCamera: __webpack_require__(215) - -}; - - -/***/ }), -/* 457 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(458); -} - -if (true) -{ - renderCanvas = __webpack_require__(459); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 458 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Sprite#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var SpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.batchSprite(src, camera); -}; - -module.exports = SpriteWebGLRenderer; - - -/***/ }), -/* 459 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Sprite#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var SpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - renderer.drawImage(src, camera); -}; - -module.exports = SpriteCanvasRenderer; - - -/***/ }), -/* 460 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var OrthographicCamera = __webpack_require__(214); -var PerspectiveCamera = __webpack_require__(215); -var PluginManager = __webpack_require__(12); - -/** - * @classdesc - * [description] - * - * @class CameraManager - * @memberOf Phaser.Cameras.Sprite3D - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var CameraManager = new Class({ - - initialize: - - function CameraManager (scene) - { - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.CameraManager#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; + this.timeScale = 1; /** * [description] * - * @name Phaser.Cameras.Sprite3D.CameraManager#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - /** - * An Array of the Camera objects being managed by this Camera Manager. - * - * @name Phaser.Cameras.Sprite3D.CameraManager#cameras - * @type {array} - * @since 3.0.0 - */ - this.cameras = []; - - if (!scene.sys.settings.isBooted) - { - scene.sys.events.once('boot', this.boot, this); - } - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.CameraManager#boot - * @since 3.0.0 - */ - boot: function () - { - var eventEmitter = this.systems.events; - - eventEmitter.on('update', this.update, this); - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.CameraManager#add - * @since 3.0.0 - * - * @param {[type]} fieldOfView - [description] - * @param {[type]} width - [description] - * @param {[type]} height - [description] - * - * @return {[type]} [description] - */ - add: function (fieldOfView, width, height) - { - return this.addPerspectiveCamera(fieldOfView, width, height); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.CameraManager#addOrthographicCamera - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {[type]} [description] - */ - addOrthographicCamera: function (width, height) - { - var config = this.scene.sys.game.config; - - if (width === undefined) { width = config.width; } - if (height === undefined) { height = config.height; } - - var camera = new OrthographicCamera(this.scene, width, height); - - this.cameras.push(camera); - - return camera; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.CameraManager#addPerspectiveCamera - * @since 3.0.0 - * - * @param {number} [fieldOfView=80] - [description] - * @param {number} [width] - [description] - * @param {number} [height] - [description] - * - * @return {[type]} [description] - */ - addPerspectiveCamera: function (fieldOfView, width, height) - { - var config = this.scene.sys.game.config; - - if (fieldOfView === undefined) { fieldOfView = 80; } - if (width === undefined) { width = config.width; } - if (height === undefined) { height = config.height; } - - var camera = new PerspectiveCamera(this.scene, fieldOfView, width, height); - - this.cameras.push(camera); - - return camera; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.CameraManager#getCamera - * @since 3.0.0 - * - * @param {string} name - [description] - * - * @return {[type]} [description] - */ - getCamera: function (name) - { - this.cameras.forEach(function (camera) - { - if (camera.name === name) - { - return camera; - } - }); - - return null; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.CameraManager#removeCamera - * @since 3.0.0 - * - * @param {[type]} camera - [description] - */ - removeCamera: function (camera) - { - var cameraIndex = this.cameras.indexOf(camera); - - if (cameraIndex !== -1) - { - this.cameras.splice(cameraIndex, 1); - } - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.CameraManager#removeAll - * @since 3.0.0 - * - * @return {[type]} [description] - */ - removeAll: function () - { - while (this.cameras.length > 0) - { - var camera = this.cameras.pop(); - - camera.destroy(); - } - - return this.main; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.CameraManager#update - * @since 3.0.0 - * - * @param {number} timestep - [description] - * @param {number} delta - [description] - */ - update: function (timestep, delta) - { - for (var i = 0, l = this.cameras.length; i < l; ++i) - { - this.cameras[i].update(timestep, delta); - } - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.CameraManager#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.CameraManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.scene = undefined; - } - -}); - -PluginManager.register('CameraManager3D', CameraManager, 'cameras3d'); - -module.exports = CameraManager; - - -/***/ }), -/* 461 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Create - */ - -module.exports = { - - GenerateTexture: __webpack_require__(216), - Palettes: __webpack_require__(462) - -}; - - -/***/ }), -/* 462 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Create.Palettes - */ - -module.exports = { - - ARNE16: __webpack_require__(217), - C64: __webpack_require__(463), - CGA: __webpack_require__(464), - JMP: __webpack_require__(465), - MSX: __webpack_require__(466) - -}; - - -/***/ }), -/* 463 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * A 16 color palette inspired by the Commodore 64. - * - * @name Phaser.Create.Palettes.C64 - * @since 3.0.0 - * - * @type {object} - * @property {string} 0 - Color value 1. - * @property {string} 1 - Color value 2. - * @property {string} 2 - Color value 3. - * @property {string} 3 - Color value 4. - * @property {string} 4 - Color value 5. - * @property {string} 5 - Color value 6. - * @property {string} 6 - Color value 7. - * @property {string} 7 - Color value 8. - * @property {string} 8 - Color value 9. - * @property {string} 9 - Color value 10. - * @property {string} A - Color value 11. - * @property {string} B - Color value 12. - * @property {string} C - Color value 13. - * @property {string} D - Color value 14. - * @property {string} E - Color value 15. - * @property {string} F - Color value 16. - */ -module.exports = { - 0: '#000', - 1: '#fff', - 2: '#8b4131', - 3: '#7bbdc5', - 4: '#8b41ac', - 5: '#6aac41', - 6: '#3931a4', - 7: '#d5de73', - 8: '#945a20', - 9: '#5a4100', - A: '#bd736a', - B: '#525252', - C: '#838383', - D: '#acee8b', - E: '#7b73de', - F: '#acacac' -}; - - -/***/ }), -/* 464 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * A 16 color CGA inspired palette by [Arne](http://androidarts.com/palette/16pal.htm) - * - * @name Phaser.Create.Palettes.CGA - * @since 3.0.0 - * - * @type {object} - * @property {string} 0 - Color value 1. - * @property {string} 1 - Color value 2. - * @property {string} 2 - Color value 3. - * @property {string} 3 - Color value 4. - * @property {string} 4 - Color value 5. - * @property {string} 5 - Color value 6. - * @property {string} 6 - Color value 7. - * @property {string} 7 - Color value 8. - * @property {string} 8 - Color value 9. - * @property {string} 9 - Color value 10. - * @property {string} A - Color value 11. - * @property {string} B - Color value 12. - * @property {string} C - Color value 13. - * @property {string} D - Color value 14. - * @property {string} E - Color value 15. - * @property {string} F - Color value 16. - */ -module.exports = { - 0: '#000', - 1: '#2234d1', - 2: '#0c7e45', - 3: '#44aacc', - 4: '#8a3622', - 5: '#5c2e78', - 6: '#aa5c3d', - 7: '#b5b5b5', - 8: '#5e606e', - 9: '#4c81fb', - A: '#6cd947', - B: '#7be2f9', - C: '#eb8a60', - D: '#e23d69', - E: '#ffd93f', - F: '#fff' -}; - - -/***/ }), -/* 465 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * A 16 color JMP palette by [Arne](http://androidarts.com/palette/16pal.htm) - * - * @name Phaser.Create.Palettes.JMP - * @type {object} - * @since 3.0.0 - * - * @property {string} 0 - Color value 1. - * @property {string} 1 - Color value 2. - * @property {string} 2 - Color value 3. - * @property {string} 3 - Color value 4. - * @property {string} 4 - Color value 5. - * @property {string} 5 - Color value 6. - * @property {string} 6 - Color value 7. - * @property {string} 7 - Color value 8. - * @property {string} 8 - Color value 9. - * @property {string} 9 - Color value 10. - * @property {string} A - Color value 11. - * @property {string} B - Color value 12. - * @property {string} C - Color value 13. - * @property {string} D - Color value 14. - * @property {string} E - Color value 15. - * @property {string} F - Color value 16. - */ -module.exports = { - 0: '#000', - 1: '#191028', - 2: '#46af45', - 3: '#a1d685', - 4: '#453e78', - 5: '#7664fe', - 6: '#833129', - 7: '#9ec2e8', - 8: '#dc534b', - 9: '#e18d79', - A: '#d6b97b', - B: '#e9d8a1', - C: '#216c4b', - D: '#d365c8', - E: '#afaab9', - F: '#f5f4eb' -}; - - -/***/ }), -/* 466 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * A 16 color palette inspired by Japanese computers like the MSX. - * - * @name Phaser.Create.Palettes.MSX - * @since 3.0.0 - * - * @type {object} - * @property {string} 0 - Color value 1. - * @property {string} 1 - Color value 2. - * @property {string} 2 - Color value 3. - * @property {string} 3 - Color value 4. - * @property {string} 4 - Color value 5. - * @property {string} 5 - Color value 6. - * @property {string} 6 - Color value 7. - * @property {string} 7 - Color value 8. - * @property {string} 8 - Color value 9. - * @property {string} 9 - Color value 10. - * @property {string} A - Color value 11. - * @property {string} B - Color value 12. - * @property {string} C - Color value 13. - * @property {string} D - Color value 14. - * @property {string} E - Color value 15. - * @property {string} F - Color value 16. - */ -module.exports = { - 0: '#000', - 1: '#191028', - 2: '#46af45', - 3: '#a1d685', - 4: '#453e78', - 5: '#7664fe', - 6: '#833129', - 7: '#9ec2e8', - 8: '#dc534b', - 9: '#e18d79', - A: '#d6b97b', - B: '#e9d8a1', - C: '#216c4b', - D: '#d365c8', - E: '#afaab9', - F: '#fff' -}; - - -/***/ }), -/* 467 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Curves - */ - -module.exports = { - Path: __webpack_require__(468), - - CubicBezier: __webpack_require__(218), - Curve: __webpack_require__(52), - Ellipse: __webpack_require__(220), - Line: __webpack_require__(222), - QuadraticBezier: __webpack_require__(223), - Spline: __webpack_require__(225) -}; - - -/***/ }), -/* 468 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) - -var Class = __webpack_require__(0); -var CubicBezierCurve = __webpack_require__(218); -var EllipseCurve = __webpack_require__(220); -var GameObjectFactory = __webpack_require__(9); -var LineCurve = __webpack_require__(222); -var MovePathTo = __webpack_require__(469); -var QuadraticBezierCurve = __webpack_require__(223); -var Rectangle = __webpack_require__(8); -var SplineCurve = __webpack_require__(225); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * [description] - * - * @class Path - * @memberOf Phaser.Curves - * @constructor - * @since 3.0.0 - * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] - */ -var Path = new Class({ - - initialize: - - function Path (x, y) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - - /** - * [description] - * - * @name Phaser.Curves.Path#name - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.name = ''; - - /** - * [description] - * - * @name Phaser.Curves.Path#curves - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.curves = []; - - /** - * [description] - * - * @name Phaser.Curves.Path#cacheLengths - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.cacheLengths = []; - - /** - * Automatically closes the path. - * - * @name Phaser.Curves.Path#autoClose + * @name Phaser.Time.Clock#paused * @type {boolean} * @default false * @since 3.0.0 */ - this.autoClose = false; + this.paused = false; /** * [description] * - * @name {Phaser.MathPhaser.Curves.Path#startPoint - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.startPoint = new Vector2(); - - /** - * [description] - * - * @name {Phaser.MathPhaser.Curves.Path#_tmpVec2A - * @type {Phaser.Math.Vector2} - * @private - * @since 3.0.0 - */ - this._tmpVec2A = new Vector2(); - - /** - * [description] - * - * @name {Phaser.MathPhaser.Curves.Path#_tmpVec2B - * @type {Phaser.Math.Vector2} - * @private - * @since 3.0.0 - */ - this._tmpVec2B = new Vector2(); - - if (typeof x === 'object') - { - this.fromJSON(x); - } - else - { - this.startPoint.set(x, y); - } - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#add - * @since 3.0.0 - * - * @param {Phaser.Curves.Curve} curve - [description] - * - * @return {Phaser.Curves.Path} [description] - */ - add: function (curve) - { - this.curves.push(curve); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#circleTo - * @since 3.0.0 - * - * @param {number} radius - [description] - * @param {boolean} [clockwise=false] - [description] - * @param {number} [rotation=0] - [description] - * - * @return {Phaser.Curves.Path} [description] - */ - circleTo: function (radius, clockwise, rotation) - { - if (clockwise === undefined) { clockwise = false; } - - return this.ellipseTo(radius, radius, 0, 360, clockwise, rotation); - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#closePath - * @since 3.0.0 - * - * @return {Phaser.Curves.Path} [description] - */ - closePath: function () - { - // Add a line curve if start and end of lines are not connected - var startPoint = this.curves[0].getPoint(0); - var endPoint = this.curves[this.curves.length - 1].getPoint(1); - - if (!startPoint.equals(endPoint)) - { - // This will copy a reference to the vectors, which probably isn't sensible - this.curves.push(new LineCurve(endPoint, startPoint)); - } - - return this; - }, - - // Creates a cubic bezier curve starting at the previous end point and ending at p3, using p1 and p2 as control points - - /** - * [description] - * - * @method Phaser.Curves.Path#cubicBezierTo - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {Phaser.Math.Vector2} control1X - [description] - * @param {Phaser.Math.Vector2} control1Y - [description] - * @param {Phaser.Math.Vector2} control2X - [description] - * @param {Phaser.Math.Vector2} control2Y - [description] - * - * @return {Phaser.Curves.Path} [description] - */ - cubicBezierTo: function (x, y, control1X, control1Y, control2X, control2Y) - { - var p0 = this.getEndPoint(); - var p1; - var p2; - var p3; - - // Assume they're all vec2s - if (x instanceof Vector2) - { - p1 = x; - p2 = y; - p3 = control1X; - } - else - { - p1 = new Vector2(control1X, control1Y); - p2 = new Vector2(control2X, control2Y); - p3 = new Vector2(x, y); - } - - return this.add(new CubicBezierCurve(p0, p1, p2, p3)); - }, - - // Creates a quadratic bezier curve starting at the previous end point and ending at p2, using p1 as a control point - - /** - * [description] - * - * @method Phaser.Curves.Path#quadraticBezierTo - * @since 3.2.0 - * - * @param {number|Phaser.Math.Vector2[]} x - [description] - * @param {number} [y] - [description] - * @param {number} [controlX] - [description] - * @param {number} [controlY] - [description] - * - * @return {Phaser.Curves.Path} [description] - */ - quadraticBezierTo: function (x, y, controlX, controlY) - { - var p0 = this.getEndPoint(); - var p1; - var p2; - - // Assume they're all vec2s - if (x instanceof Vector2) - { - p1 = x; - p2 = y; - } - else - { - p1 = new Vector2(controlX, controlY); - p2 = new Vector2(x, y); - } - - return this.add(new QuadraticBezierCurve(p0, p1, p2)); - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#draw - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - [description] - * @param {integer} [pointsTotal=32] - [description] - * - * @return {Phaser.GameObjects.Graphics} [description] - */ - draw: function (graphics, pointsTotal) - { - for (var i = 0; i < this.curves.length; i++) - { - var curve = this.curves[i]; - - if (!curve.active) - { - continue; - } - - curve.draw(graphics, pointsTotal); - } - - return graphics; - }, - - /** - * Creates an ellipse curve positioned at the previous end point, using the given parameters. - * - * @method Phaser.Curves.Path#ellipseTo - * @since 3.0.0 - * - * @param {number} xRadius - [description] - * @param {number} yRadius - [description] - * @param {number} startAngle - [description] - * @param {number} endAngle - [description] - * @param {boolean} clockwise - [description] - * @param {number} rotation - [description] - * - * @return {Phaser.Curves.Path} [description] - */ - ellipseTo: function (xRadius, yRadius, startAngle, endAngle, clockwise, rotation) - { - var ellipse = new EllipseCurve(0, 0, xRadius, yRadius, startAngle, endAngle, clockwise, rotation); - - var end = this.getEndPoint(this._tmpVec2A); - - // Calculate where to center the ellipse - var start = ellipse.getStartPoint(this._tmpVec2B); - - end.subtract(start); - - ellipse.x = end.x; - ellipse.y = end.y; - - return this.add(ellipse); - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#fromJSON - * @since 3.0.0 - * - * @param {object} data - [description] - * - * @return {Phaser.Curves.Path} [description] - */ - fromJSON: function (data) - { - // data should be an object matching the Path.toJSON object structure. - - this.curves = []; - this.cacheLengths = []; - - this.startPoint.set(data.x, data.y); - - this.autoClose = data.autoClose; - - for (var i = 0; i < data.curves.length; i++) - { - var curve = data.curves[i]; - - switch (curve.type) - { - case 'LineCurve': - this.add(LineCurve.fromJSON(curve)); - break; - - case 'EllipseCurve': - this.add(EllipseCurve.fromJSON(curve)); - break; - - case 'SplineCurve': - this.add(SplineCurve.fromJSON(curve)); - break; - - case 'CubicBezierCurve': - this.add(CubicBezierCurve.fromJSON(curve)); - break; - - case 'QuadraticBezierCurve': - this.add(QuadraticBezierCurve.fromJSON(curve)); - break; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#getBounds - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} [out] - [description] - * @param {integer} [accuracy=16] - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ - getBounds: function (out, accuracy) - { - if (out === undefined) { out = new Rectangle(); } - if (accuracy === undefined) { accuracy = 16; } - - out.x = Number.MAX_VALUE; - out.y = Number.MAX_VALUE; - - var bounds = new Rectangle(); - var maxRight = Number.MIN_SAFE_INTEGER; - var maxBottom = Number.MIN_SAFE_INTEGER; - - for (var i = 0; i < this.curves.length; i++) - { - var curve = this.curves[i]; - - if (!curve.active) - { - continue; - } - - curve.getBounds(bounds, accuracy); - - out.x = Math.min(out.x, bounds.x); - out.y = Math.min(out.y, bounds.y); - - maxRight = Math.max(maxRight, bounds.right); - maxBottom = Math.max(maxBottom, bounds.bottom); - } - - out.right = maxRight; - out.bottom = maxBottom; - - return out; - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#getCurveLengths - * @since 3.0.0 - * - * @return {array} [description] - */ - getCurveLengths: function () - { - // We use cache values if curves and cache array are same length - - if (this.cacheLengths.length === this.curves.length) - { - return this.cacheLengths; - } - - // Get length of sub-curve - // Push sums into cached array - - var lengths = []; - var sums = 0; - - for (var i = 0; i < this.curves.length; i++) - { - sums += this.curves[i].getLength(); - - lengths.push(sums); - } - - this.cacheLengths = lengths; - - return lengths; - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#getEndPoint - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} [out] - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - getEndPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - if (this.curves.length > 0) - { - this.curves[this.curves.length - 1].getPoint(1, out); - } - else - { - out.copy(this.startPoint); - } - - return out; - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#getLength - * @since 3.0.0 - * - * @return {number} [description] - */ - getLength: function () - { - var lens = this.getCurveLengths(); - - return lens[lens.length - 1]; - }, - - // To get accurate point with reference to - // entire path distance at time t, - // following has to be done: - - // 1. Length of each sub path have to be known - // 2. Locate and identify type of curve - // 3. Get t for the curve - // 4. Return curve.getPointAt(t') - - /** - * [description] - * - * @method Phaser.Curves.Path#getPoint - * @since 3.0.0 - * - * @param {number} t - [description] - * @param {Phaser.Math.Vector2} [out] - [description] - * - * @return {Phaser.Math.Vector2|null} [description] - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - var d = t * this.getLength(); - var curveLengths = this.getCurveLengths(); - var i = 0; - - while (i < curveLengths.length) - { - if (curveLengths[i] >= d) - { - var diff = curveLengths[i] - d; - var curve = this.curves[i]; - - var segmentLength = curve.getLength(); - var u = (segmentLength === 0) ? 0 : 1 - diff / segmentLength; - - return curve.getPointAt(u, out); - } - - i++; - } - - // loop where sum != 0, sum > d , sum+1 1 && !points[points.length - 1].equals(points[0])) - { - points.push(points[0]); - } - - return points; - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#getRandomPoint - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} [out] - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - getRandomPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return this.getPoint(Math.random(), out); - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#getSpacedPoints - * @since 3.0.0 - * - * @param {integer} [divisions=40] - [description] - * - * @return {Phaser.Math.Vector2[]} [description] - */ - getSpacedPoints: function (divisions) - { - if (divisions === undefined) { divisions = 40; } - - var points = []; - - for (var i = 0; i <= divisions; i++) - { - points.push(this.getPoint(i / divisions)); - } - - if (this.autoClose) - { - points.push(points[0]); - } - - return points; - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#getStartPoint - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} [out] - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - getStartPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return out.copy(this.startPoint); - }, - - // Creates a line curve from the previous end point to x/y - - /** - * [description] - * - * @method Phaser.Curves.Path#lineTo - * @since 3.0.0 - * - * @param {number|Phaser.Math.Vector2} x - [description] - * @param {number} [y] - [description] - * - * @return {Phaser.Curves.Path} [description] - */ - lineTo: function (x, y) - { - if (x instanceof Vector2) - { - this._tmpVec2B.copy(x); - } - else - { - this._tmpVec2B.set(x, y); - } - - var end = this.getEndPoint(this._tmpVec2A); - - return this.add(new LineCurve([ end.x, end.y, this._tmpVec2B.x, this._tmpVec2B.y ])); - }, - - // Creates a spline curve starting at the previous end point, using the given parameters - - /** - * [description] - * - * @method Phaser.Curves.Path#splineTo - * @since 3.0.0 - * - * @param {[type]} points - [description] - * - * @return {Phaser.Curves.Path} [description] - */ - splineTo: function (points) - { - points.unshift(this.getEndPoint()); - - return this.add(new SplineCurve(points)); - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#moveTo - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Curves.Path} [description] - */ - moveTo: function (x, y) - { - return this.add(new MovePathTo(x, y)); - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - var out = []; - - for (var i = 0; i < this.curves.length; i++) - { - out.push(this.curves[i].toJSON()); - } - - return { - type: 'Path', - x: this.startPoint.x, - y: this.startPoint.y, - autoClose: this.autoClose, - curves: out - }; - }, - - // cacheLengths must be recalculated. - - /** - * [description] - * - * @method Phaser.Curves.Path#updateArcLengths - * @since 3.0.0 - */ - updateArcLengths: function () - { - this.cacheLengths = []; - - this.getCurveLengths(); - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.curves.length = 0; - this.cacheLengths.length = 0; - this.startPoint = undefined; - } - -}); - -/** - * Creates a new Path Object. - * - * @method Phaser.GameObjects.GameObjectFactory#path - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Path. - * @param {number} y - The vertical position of this Path. - * - * @return {Phaser.Curves.Path} The Path Object that was created. - */ -GameObjectFactory.register('path', function (x, y) -{ - return new Path(x, y); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - -module.exports = Path; - - -/***/ }), -/* 469 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * [description] - * - * @class MoveTo - * @memberOf Phaser.Curves - * @constructor - * @since 3.0.0 - * - * @param {number} [x] - [description] - * @param {number} [y] - [description] - */ -var MoveTo = new Class({ - - initialize: - - function MoveTo (x, y) - { - // Skip length calcs in paths - - /** - * [description] - * - * @name Phaser.Curves.MoveTo#active - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.active = false; - - /** - * [description] - * - * @name Phaser.Curves.MoveTo#p0 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p0 = new Vector2(x, y); - }, - - /** - * [description] - * - * @method Phaser.Curves.MoveTo#getPoint - * @since 3.0.0 - * - * @param {[type]} t - [description] - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - return out.copy(this.p0); - }, - - /** - * [description] - * - * @method Phaser.Curves.MoveTo#getPointAt - * @since 3.0.0 - * - * @param {[type]} u - [description] - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - getPointAt: function (u, out) - { - return this.getPoint(u, out); - }, - - /** - * [description] - * - * @method Phaser.Curves.MoveTo#getResolution - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getResolution: function () - { - return 1; - }, - - /** - * [description] - * - * @method Phaser.Curves.MoveTo#getLength - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getLength: function () - { - return 0; - }, - - /** - * [description] - * - * @method Phaser.Curves.MoveTo#toJSON - * @since 3.0.0 - * - * @return {[type]} [description] - */ - toJSON: function () - { - return { - type: 'MoveTo', - points: [ - this.p0.x, this.p0.y - ] - }; - } - -}); - -module.exports = MoveTo; - - -/***/ }), -/* 470 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Data - */ - -module.exports = { - - DataManager: __webpack_require__(79), - DataManagerPlugin: __webpack_require__(471) - -}; - - -/***/ }), -/* 471 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var DataManager = __webpack_require__(79); -var PluginManager = __webpack_require__(12); - -/** - * @classdesc - * The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin. - * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter, - * or have a property called `events` that is an instance of it. - * - * @class DataManagerPlugin - * @extends Phaser.Data.DataManager - * @memberOf Phaser.Data - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var DataManagerPlugin = new Class({ - - Extends: DataManager, - - initialize: - - function DataManagerPlugin (scene) - { - /** - * [description] - * - * @name Phaser.Data.DataManagerPlugin#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.Data.DataManagerPlugin#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - if (!scene.sys.settings.isBooted) - { - scene.sys.events.once('boot', this.boot, this); - } - - DataManager.call(this, this.scene, scene.sys.events); - }, - - /** - * [description] - * - * @method Phaser.Data.DataManagerPlugin#boot - * @since 3.0.0 - */ - boot: function () - { - var eventEmitter = this.systems.events; - - eventEmitter.on('shutdown', this.shutdownPlugin, this); - eventEmitter.on('destroy', this.destroyPlugin, this); - }, - - /** - * [description] - * - * @method Phaser.Data.DataManagerPlugin#shutdownPlugin - * @since 3.0.0 - */ - shutdownPlugin: function () - { - // Should we reset the events? - }, - - /** - * [description] - * - * @method Phaser.Data.DataManagerPlugin#destroyPlugin - * @since 3.0.0 - */ - destroyPlugin: function () - { - this.destroy(); - - this.scene = undefined; - this.systems = undefined; - } - -}); - -PluginManager.register('DataManagerPlugin', DataManagerPlugin, 'data'); - -module.exports = DataManagerPlugin; - - -/***/ }), -/* 472 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display - */ - -module.exports = { - - Align: __webpack_require__(473), - Bounds: __webpack_require__(488), - Canvas: __webpack_require__(491), - Color: __webpack_require__(227), - Masks: __webpack_require__(502) - -}; - - -/***/ }), -/* 473 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Align - */ - -module.exports = { - - In: __webpack_require__(474), - To: __webpack_require__(475) - -}; - - -/***/ }), -/* 474 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Align.In - */ - -module.exports = { - - BottomCenter: __webpack_require__(174), - BottomLeft: __webpack_require__(175), - BottomRight: __webpack_require__(176), - Center: __webpack_require__(177), - LeftCenter: __webpack_require__(179), - QuickSet: __webpack_require__(172), - RightCenter: __webpack_require__(180), - TopCenter: __webpack_require__(181), - TopLeft: __webpack_require__(182), - TopRight: __webpack_require__(183) - -}; - - -/***/ }), -/* 475 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Align.To - */ - -module.exports = { - - BottomCenter: __webpack_require__(476), - BottomLeft: __webpack_require__(477), - BottomRight: __webpack_require__(478), - LeftBottom: __webpack_require__(479), - LeftCenter: __webpack_require__(480), - LeftTop: __webpack_require__(481), - RightBottom: __webpack_require__(482), - RightCenter: __webpack_require__(483), - RightTop: __webpack_require__(484), - TopCenter: __webpack_require__(485), - TopLeft: __webpack_require__(486), - TopRight: __webpack_require__(487) - -}; - - -/***/ }), -/* 476 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(24); -var GetCenterX = __webpack_require__(46); -var SetCenterX = __webpack_require__(47); -var SetTop = __webpack_require__(31); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the bottom center position of the other. - * - * @function Phaser.Display.Align.To.BottomCenter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var BottomCenter = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetCenterX(gameObject, GetCenterX(alignTo) + offsetX); - SetTop(gameObject, GetBottom(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = BottomCenter; - - -/***/ }), -/* 477 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(24); -var GetLeft = __webpack_require__(26); -var SetLeft = __webpack_require__(27); -var SetTop = __webpack_require__(31); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the bottom left position of the other. - * - * @function Phaser.Display.Align.To.BottomLeft - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var BottomLeft = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetLeft(alignTo) - offsetX); - SetTop(gameObject, GetBottom(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = BottomLeft; - - -/***/ }), -/* 478 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(24); -var GetRight = __webpack_require__(28); -var SetRight = __webpack_require__(29); -var SetTop = __webpack_require__(31); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the bottom right position of the other. - * - * @function Phaser.Display.Align.To.BottomRight - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var BottomRight = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetRight(alignTo) + offsetX); - SetTop(gameObject, GetBottom(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = BottomRight; - - -/***/ }), -/* 479 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(24); -var GetLeft = __webpack_require__(26); -var SetBottom = __webpack_require__(25); -var SetRight = __webpack_require__(29); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the left bottom position of the other. - * - * @function Phaser.Display.Align.To.LeftBottom - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var LeftBottom = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetLeft(alignTo) - offsetX); - SetBottom(gameObject, GetBottom(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = LeftBottom; - - -/***/ }), -/* 480 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetCenterY = __webpack_require__(49); -var GetLeft = __webpack_require__(26); -var SetCenterY = __webpack_require__(48); -var SetRight = __webpack_require__(29); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the left center position of the other. - * - * @function Phaser.Display.Align.To.LeftCenter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var LeftCenter = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetLeft(alignTo) - offsetX); - SetCenterY(gameObject, GetCenterY(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = LeftCenter; - - -/***/ }), -/* 481 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetLeft = __webpack_require__(26); -var GetTop = __webpack_require__(30); -var SetRight = __webpack_require__(29); -var SetTop = __webpack_require__(31); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the left top position of the other. - * - * @function Phaser.Display.Align.To.LeftTop - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var LeftTop = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetLeft(alignTo) - offsetX); - SetTop(gameObject, GetTop(alignTo) - offsetY); - - return gameObject; -}; - -module.exports = LeftTop; - - -/***/ }), -/* 482 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(24); -var GetRight = __webpack_require__(28); -var SetBottom = __webpack_require__(25); -var SetLeft = __webpack_require__(27); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the right bottom position of the other. - * - * @function Phaser.Display.Align.To.RightBottom - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var RightBottom = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetRight(alignTo) + offsetX); - SetBottom(gameObject, GetBottom(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = RightBottom; - - -/***/ }), -/* 483 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetCenterY = __webpack_require__(49); -var GetRight = __webpack_require__(28); -var SetCenterY = __webpack_require__(48); -var SetLeft = __webpack_require__(27); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the right center position of the other. - * - * @function Phaser.Display.Align.To.RightCenter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var RightCenter = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetRight(alignTo) + offsetX); - SetCenterY(gameObject, GetCenterY(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = RightCenter; - - -/***/ }), -/* 484 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetRight = __webpack_require__(28); -var GetTop = __webpack_require__(30); -var SetLeft = __webpack_require__(27); -var SetTop = __webpack_require__(31); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the right top position of the other. - * - * @function Phaser.Display.Align.To.RightTop - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var RightTop = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetRight(alignTo) + offsetX); - SetTop(gameObject, GetTop(alignTo) - offsetY); - - return gameObject; -}; - -module.exports = RightTop; - - -/***/ }), -/* 485 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetCenterX = __webpack_require__(46); -var GetTop = __webpack_require__(30); -var SetBottom = __webpack_require__(25); -var SetCenterX = __webpack_require__(47); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the top center position of the other. - * - * @function Phaser.Display.Align.To.TopCenter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var TopCenter = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetCenterX(gameObject, GetCenterX(alignTo) + offsetX); - SetBottom(gameObject, GetTop(alignTo) - offsetY); - - return gameObject; -}; - -module.exports = TopCenter; - - -/***/ }), -/* 486 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetLeft = __webpack_require__(26); -var GetTop = __webpack_require__(30); -var SetBottom = __webpack_require__(25); -var SetLeft = __webpack_require__(27); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the top left position of the other. - * - * @function Phaser.Display.Align.To.TopLeft - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var TopLeft = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetLeft(alignTo) - offsetX); - SetBottom(gameObject, GetTop(alignTo) - offsetY); - - return gameObject; -}; - -module.exports = TopLeft; - - -/***/ }), -/* 487 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetRight = __webpack_require__(28); -var GetTop = __webpack_require__(30); -var SetBottom = __webpack_require__(25); -var SetRight = __webpack_require__(29); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the top right position of the other. - * - * @function Phaser.Display.Align.To.TopRight - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var TopRight = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetRight(alignTo) + offsetX); - SetBottom(gameObject, GetTop(alignTo) - offsetY); - - return gameObject; -}; - -module.exports = TopRight; - - -/***/ }), -/* 488 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Bounds - */ - -module.exports = { - - CenterOn: __webpack_require__(178), - GetBottom: __webpack_require__(24), - GetCenterX: __webpack_require__(46), - GetCenterY: __webpack_require__(49), - GetLeft: __webpack_require__(26), - GetOffsetX: __webpack_require__(489), - GetOffsetY: __webpack_require__(490), - GetRight: __webpack_require__(28), - GetTop: __webpack_require__(30), - SetBottom: __webpack_require__(25), - SetCenterX: __webpack_require__(47), - SetCenterY: __webpack_require__(48), - SetLeft: __webpack_require__(27), - SetRight: __webpack_require__(29), - SetTop: __webpack_require__(31) - -}; - - -/***/ }), -/* 489 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the amount the Game Object is visually offset from its x coordinate. - * This is the same as `width * origin.x`. - * This value will only be > 0 if `origin.x` is not equal to zero. - * - * @function Phaser.Display.Bounds.GetOffsetX - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The horizontal offset of the Game Object. - */ -var GetOffsetX = function (gameObject) -{ - return gameObject.width * gameObject.originX; -}; - -module.exports = GetOffsetX; - - -/***/ }), -/* 490 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the amount the Game Object is visually offset from its y coordinate. - * This is the same as `width * origin.y`. - * This value will only be > 0 if `origin.y` is not equal to zero. - * - * @function Phaser.Display.Bounds.GetOffsetY - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The vertical offset of the Game Object. - */ -var GetOffsetY = function (gameObject) -{ - return gameObject.height * gameObject.originY; -}; - -module.exports = GetOffsetY; - - -/***/ }), -/* 491 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Canvas - */ - -module.exports = { - - Interpolation: __webpack_require__(226), - Pool: __webpack_require__(21), - Smoothing: __webpack_require__(121), - TouchAction: __webpack_require__(492), - UserSelect: __webpack_require__(493) - -}; - - -/***/ }), -/* 492 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions. - * - * @function Phaser.Display.Canvas.TouchAction - * @since 3.0.0 - * - * @param {HTMLCanvasElement} canvas - The canvas element to have the style applied to. - * @param {string} [value='none'] - The touch action value to set on the canvas. Set to `none` to disable touch actions. - * - * @return {HTMLCanvasElement} The canvas element. - */ -var TouchAction = function (canvas, value) -{ - if (value === undefined) { value = 'none'; } - - canvas.style['msTouchAction'] = value; - canvas.style['ms-touch-action'] = value; - canvas.style['touch-action'] = value; - - return canvas; -}; - -module.exports = TouchAction; - - -/***/ }), -/* 493 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Sets the user-select property on the canvas style. Can be used to disable default browser selection actions. - * - * @function Phaser.Display.Canvas.UserSelect - * @since 3.0.0 - * - * @param {HTMLCanvasElement} canvas - The canvas element to have the style applied to. - * @param {string} [value='none'] - The touch callout value to set on the canvas. Set to `none` to disable touch callouts. - * - * @return {HTMLCanvasElement} The canvas element. - */ -var UserSelect = function (canvas, value) -{ - if (value === undefined) { value = 'none'; } - - var vendors = [ - '-webkit-', - '-khtml-', - '-moz-', - '-ms-', - '' - ]; - - vendors.forEach(function (vendor) - { - canvas.style[vendor + 'user-select'] = value; - }); - - canvas.style['-webkit-touch-callout'] = value; - canvas.style['-webkit-tap-highlight-color'] = 'rgba(0, 0, 0, 0)'; - - return canvas; -}; - -module.exports = UserSelect; - - -/***/ }), -/* 494 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @typedef {Object} ColorObject - * @property {number} r - The red color value in the range 0 to 255. - * @property {number} g - The green color value in the range 0 to 255. - * @property {number} b - The blue color value in the range 0 to 255. - * @property {number} a - The alpha color value in the range 0 to 255. - */ - -/** - * Converts the given color value into an Object containing r,g,b and a properties. - * - * @function Phaser.Display.Color.ColorToRGBA - * @since 3.0.0 - * - * @param {number} color - A color value, optionally including the alpha value. - * - * @return {ColorObject} An object containing the parsed color values. - */ -var ColorToRGBA = function (color) -{ - var output = { - r: color >> 16 & 0xFF, - g: color >> 8 & 0xFF, - b: color & 0xFF, - a: 255 - }; - - if (color > 16777215) - { - output.a = color >>> 24; - } - - return output; -}; - -module.exports = ColorToRGBA; - - -/***/ }), -/* 495 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Color = __webpack_require__(36); -var HueToComponent = __webpack_require__(229); - -/** - * Converts HSL (hue, saturation and lightness) values to a Phaser Color object. - * - * @function Phaser.Display.Color.HSLToColor - * @since 3.0.0 - * - * @param {number} h - The hue value in the range 0 to 1. - * @param {number} s - The saturation value in the range 0 to 1. - * @param {number} l - The lightness value in the range 0 to 1. - * - * @return {Phaser.Display.Color} A Color object created from the results of the h, s and l values. - */ -var HSLToColor = function (h, s, l) -{ - // achromatic by default - var r = l; - var g = l; - var b = l; - - if (s !== 0) - { - var q = (l < 0.5) ? l * (1 + s) : l + s - l * s; - var p = 2 * l - q; - - r = HueToComponent(p, q, h + 1 / 3); - g = HueToComponent(p, q, h); - b = HueToComponent(p, q, h - 1 / 3); - } - - var color = new Color(); - - return color.setGLTo(r, g, b, 1); -}; - -module.exports = HSLToColor; - - -/***/ }), -/* 496 */ -/***/ (function(module, exports) { - -module.exports = function(module) { - if(!module.webpackPolyfill) { - module.deprecate = function() {}; - module.paths = []; - // module.parent = undefined by default - if(!module.children) module.children = []; - Object.defineProperty(module, "loaded", { - enumerable: true, - get: function() { - return module.l; - } - }); - Object.defineProperty(module, "id", { - enumerable: true, - get: function() { - return module.i; - } - }); - module.webpackPolyfill = 1; - } - return module; -}; - - -/***/ }), -/* 497 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var HSVToRGB = __webpack_require__(230); - -/** - * Get HSV color wheel values in an array which will be 360 elements in size. - * - * @function Phaser.Display.Color.HSVColorWheel - * @since 3.0.0 - * - * @param {number} [s=1] - The saturation, in the range 0 - 1. - * @param {number} [v=1] - The value, in the range 0 - 1. - * - * @return {array} An array containing 360 elements, where each contains a single numeric value corresponding to the color at that point in the HSV color wheel. - */ -var HSVColorWheel = function (s, v) -{ - if (s === undefined) { s = 1; } - if (v === undefined) { v = 1; } - - var colors = []; - - for (var c = 0; c <= 359; c++) - { - colors.push(HSVToRGB(c / 359, s, v)); - } - - return colors; -}; - -module.exports = HSVColorWheel; - - -/***/ }), -/* 498 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Linear = __webpack_require__(124); - -/** - * Interpolates color values - * - * @namespace Phaser.Display.Color.Interpolate - * @since 3.0.0 - */ - -/** - * Interpolates between the two given color ranges over the length supplied. - * - * @function Phaser.Display.Color.Interpolate.RGBWithRGB - * @since 3.0.0 - * - * @param {number} r1 - Red value. - * @param {number} g1 - Blue value. - * @param {number} b1 - Green value. - * @param {number} r2 - Red value. - * @param {number} g2 - Blue value. - * @param {number} b2 - Green value. - * @param {number} [length=100] - Distance to interpolate over. - * @param {number} [index=0] - Index to start from. - * - * @return {ColorObject} An object containing the interpolated color values. - */ -var RGBWithRGB = function (r1, g1, b1, r2, g2, b2, length, index) -{ - if (length === undefined) { length = 100; } - if (index === undefined) { index = 0; } - - var t = index / length; - - return { - r: Linear(r1, r2, t), - g: Linear(g1, g2, t), - b: Linear(b1, b2, t) - }; -}; - -/** - * Interpolates between the two given color objects over the length supplied. - * - * @function Phaser.Display.Color.Interpolate.ColorWithColor - * @since 3.0.0 - * - * @param {Phaser.Display.Color} color1 - The first Color object. - * @param {Phaser.Display.Color} color2 - The second Color object. - * @param {number} [length=100] - Distance to interpolate over. - * @param {number} [index=0] - Index to start from. - * - * @return {ColorObject} An object containing the interpolated color values. - */ -var ColorWithColor = function (color1, color2, length, index) -{ - if (length === undefined) { length = 100; } - if (index === undefined) { index = 0; } - - return RGBWithRGB(color1.r, color1.g, color1.b, color2.r, color2.g, color2.b, length, index); -}; - -/** - * Interpolates between the Color object and color values over the length supplied. - * - * @function Phaser.Display.Color.Interpolate.ColorWithRGB - * @since 3.0.0 - * - * @param {Phaser.Display.Color} color1 - The first Color object. - * @param {number} r - Red value. - * @param {number} g - Blue value. - * @param {number} b - Green value. - * @param {number} [length=100] - Distance to interpolate over. - * @param {number} [index=0] - Index to start from. - * - * @return {ColorObject} An object containing the interpolated color values. - */ -var ColorWithRGB = function (color, r, g, b, length, index) -{ - if (length === undefined) { length = 100; } - if (index === undefined) { index = 0; } - - return RGBWithRGB(color.r, color.g, color.b, r, g, b, length, index); -}; - -module.exports = { - - RGBWithRGB: RGBWithRGB, - ColorWithRGB: ColorWithRGB, - ColorWithColor: ColorWithColor - -}; - - -/***/ }), -/* 499 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Between = __webpack_require__(231); -var Color = __webpack_require__(36); - -/** - * Creates a new Color object where the r, g, and b values have been set to random values - * based on the given min max values. - * - * @function Phaser.Display.Color.RandomRGB - * @since 3.0.0 - * - * @param {integer} [min=0] - The minimum value to set the random range from (between 0 and 255) - * @param {integer} [max=255] - The maximum value to set the random range from (between 0 and 255) - * - * @return {Phaser.Display.Color} A Color object. - */ -var RandomRGB = function (min, max) -{ - if (min === undefined) { min = 0; } - if (max === undefined) { max = 255; } - - return new Color(Between(min, max), Between(min, max), Between(min, max)); -}; - -module.exports = RandomRGB; - - -/***/ }), -/* 500 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Converts an RGB color value to HSV (hue, saturation and value). - * Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space. - * Assumes RGB values are contained in the set [0, 255] and returns h, s and v in the set [0, 1]. - * Based on code by Michael Jackson (https://github.com/mjijackson) - * - * @function Phaser.Display.Color.RGBToHSV - * @since 3.0.0 - * - * @param {integer} r - The red color value. A number between 0 and 255. - * @param {integer} g - The green color value. A number between 0 and 255. - * @param {integer} b - The blue color value. A number between 0 and 255. - * - * @return {object} An object with the properties `h`, `s` and `v`. - */ -var RGBToHSV = function (r, g, b) -{ - r /= 255; - g /= 255; - b /= 255; - - var min = Math.min(r, g, b); - var max = Math.max(r, g, b); - var d = max - min; - - // achromatic by default - var h = 0; - var s = (max === 0) ? 0 : d / max; - var v = max; - - if (max !== min) - { - if (max === r) - { - h = (g - b) / d + ((g < b) ? 6 : 0); - } - else if (max === g) - { - h = (b - r) / d + 2; - } - else if (max === b) - { - h = (r - g) / d + 4; - } - - h /= 6; - } - - return { h: h, s: s, v: v }; -}; - -module.exports = RGBToHSV; - - -/***/ }), -/* 501 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ComponentToHex = __webpack_require__(228); - -/** - * Converts the color values into an HTML compatible color string, prefixed with either `#` or `0x`. - * - * @function Phaser.Display.Color.RGBToString - * @since 3.0.0 - * - * @param {integer} r - The red color value. A number between 0 and 255. - * @param {integer} g - The green color value. A number between 0 and 255. - * @param {integer} b - The blue color value. A number between 0 and 255. - * @param {integer} [a=255] - The alpha value. A number between 0 and 255. - * @param {string} [prefix=#] - The prefix of the string. Either `#` or `0x`. - * - * @return {string} A string-based representation of the color values. - */ -var RGBToString = function (r, g, b, a, prefix) -{ - if (a === undefined) { a = 255; } - if (prefix === undefined) { prefix = '#'; } - - if (prefix === '#') - { - return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); - } - else - { - return '0x' + ComponentToHex(a) + ComponentToHex(r) + ComponentToHex(g) + ComponentToHex(b); - } -}; - -module.exports = RGBToString; - - -/***/ }), -/* 502 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Masks - */ - -module.exports = { - - BitmapMask: __webpack_require__(503), - GeometryMask: __webpack_require__(504) - -}; - - -/***/ }), -/* 503 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class BitmapMask - * @memberOf Phaser.Display.Masks - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {[type]} renderable - [description] - */ -var BitmapMask = new Class({ - - initialize: - - function BitmapMask (scene, renderable) - { - var renderer = scene.sys.game.renderer; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#bitmapMask - * @type {[type]} - * @since 3.0.0 - */ - this.bitmapMask = renderable; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#maskRenderTarget - * @type {[type]} - * @default null - * @since 3.0.0 - */ - this.maskRenderTarget = null; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#mainRenderTarget - * @type {[type]} - * @default null - * @since 3.0.0 - */ - this.mainRenderTarget = null; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#maskTexture - * @type {[type]} - * @default null - * @since 3.0.0 - */ - this.maskTexture = null; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#mainTexture - * @type {[type]} - * @default null - * @since 3.0.0 - */ - this.mainTexture = null; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#dirty - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.dirty = true; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#mainFramebuffer - * @type {WebGLFramebuffer} - * @since 3.0.0 - */ - this.mainFramebuffer = null; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#maskFramebuffer - * @type {WebGLFramebuffer} - * @since 3.0.0 - */ - this.maskFramebuffer = null; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#invertAlpha - * @type {boolean} - * @since 3.1.2 - */ - this.invertAlpha = false; - - if (renderer && renderer.gl) - { - var width = renderer.width; - var height = renderer.height; - var pot = ((width & (width - 1)) === 0 && (height & (height - 1)) === 0); - var gl = renderer.gl; - var wrap = pot ? gl.REPEAT : gl.CLAMP_TO_EDGE; - var filter = gl.LINEAR; - - this.mainTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); - this.maskTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); - this.mainFramebuffer = renderer.createFramebuffer(width, height, this.mainTexture, false); - this.maskFramebuffer = renderer.createFramebuffer(width, height, this.maskTexture, false); - - renderer.onContextRestored(function (renderer) - { - var width = renderer.width; - var height = renderer.height; - var pot = ((width & (width - 1)) === 0 && (height & (height - 1)) === 0); - var gl = renderer.gl; - var wrap = pot ? gl.REPEAT : gl.CLAMP_TO_EDGE; - var filter = gl.LINEAR; - - this.mainTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); - this.maskTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); - this.mainFramebuffer = renderer.createFramebuffer(width, height, this.mainTexture, false); - this.maskFramebuffer = renderer.createFramebuffer(width, height, this.maskTexture, false); - - }, this); - } - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.BitmapMask#setBitmap - * @since 3.0.0 - * - * @param {[type]} renderable - [description] - */ - setBitmap: function (renderable) - { - this.bitmapMask = renderable; - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.BitmapMask#preRenderWebGL - * @since 3.0.0 - * - * @param {[type]} renderer - [description] - * @param {[type]} maskedObject - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to render to. - */ - preRenderWebGL: function (renderer, maskedObject, camera) - { - renderer.pipelines.BitmapMaskPipeline.beginMask(this, maskedObject, camera); - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.BitmapMask#postRenderWebGL - * @since 3.0.0 - * - * @param {[type]} renderer - [description] - */ - postRenderWebGL: function (renderer) - { - renderer.pipelines.BitmapMaskPipeline.endMask(this); - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.BitmapMask#preRenderCanvas - * @since 3.0.0 - * - * @param {[type]} renderer - [description] - * @param {[type]} mask - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to render to. - */ - preRenderCanvas: function () - { - // NOOP - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.BitmapMask#postRenderCanvas - * @since 3.0.0 - * - * @param {[type]} renderer - [description] - */ - postRenderCanvas: function () - { - // NOOP - } - -}); - -module.exports = BitmapMask; - - -/***/ }), -/* 504 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class GeometryMask - * @memberOf Phaser.Display.Masks - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {[type]} graphicsGeometry - [description] - */ -var GeometryMask = new Class({ - - initialize: - - function GeometryMask (scene, graphicsGeometry) - { - /** - * [description] - * - * @name Phaser.Display.Masks.GeometryMask#geometryMask - * @type {Phaser.GameObjects.Graphics} - * @since 3.0.0 - */ - this.geometryMask = graphicsGeometry; - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.GeometryMask#setShape - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphicsGeometry - [description] - */ - setShape: function (graphicsGeometry) - { - this.geometryMask = graphicsGeometry; - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.GeometryMask#preRenderWebGL - * @since 3.0.0 - * - * @param {[type]} renderer - [description] - * @param {[type]} mask - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - preRenderWebGL: function (renderer, mask, camera) - { - var gl = renderer.gl; - var geometryMask = this.geometryMask; - - // Force flushing before drawing to stencil buffer - renderer.flush(); - - // Enable and setup GL state to write to stencil buffer - gl.enable(gl.STENCIL_TEST); - gl.clear(gl.STENCIL_BUFFER_BIT); - gl.colorMask(false, false, false, false); - gl.stencilFunc(gl.NOTEQUAL, 1, 1); - gl.stencilOp(gl.REPLACE, gl.REPLACE, gl.REPLACE); - - // Write stencil buffer - geometryMask.renderWebGL(renderer, geometryMask, 0.0, camera); - renderer.flush(); - - // Use stencil buffer to affect next rendering object - gl.colorMask(true, true, true, true); - gl.stencilFunc(gl.EQUAL, 1, 1); - gl.stencilOp(gl.INVERT, gl.INVERT, gl.INVERT); - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.GeometryMask#postRenderWebGL - * @since 3.0.0 - * - * @param {[type]} renderer - [description] - */ - postRenderWebGL: function (renderer) - { - var gl = renderer.gl; - - // Force flush before disabling stencil test - renderer.flush(); - gl.disable(gl.STENCIL_TEST); - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.GeometryMask#preRenderCanvas - * @since 3.0.0 - * - * @param {[type]} renderer - [description] - * @param {[type]} mask - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - preRenderCanvas: function (renderer, mask, camera) - { - var geometryMask = this.geometryMask; - - renderer.currentContext.save(); - - geometryMask.renderCanvas(renderer, geometryMask, 0.0, camera, null, true); - - renderer.currentContext.clip(); - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.GeometryMask#postRenderCanvas - * @since 3.0.0 - * - * @param {[type]} renderer - [description] - */ - postRenderCanvas: function (renderer) - { - renderer.currentContext.restore(); - } - -}); - -module.exports = GeometryMask; - - -/***/ }), -/* 505 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.DOM - */ - -module.exports = { - - AddToDOM: __webpack_require__(125), - DOMContentLoaded: __webpack_require__(232), - ParseXML: __webpack_require__(233), - RemoveFromDOM: __webpack_require__(234), - RequestAnimationFrame: __webpack_require__(235) - -}; - - -/***/ }), -/* 506 */ -/***/ (function(module, exports) { - -// shim for using process in browser -var process = module.exports = {}; - -// cached from whatever global is present so that test runners that stub it -// don't break things. But we need to wrap it in a try catch in case it is -// wrapped in strict mode code which doesn't define any globals. It's inside a -// function because try/catches deoptimize in certain engines. - -var cachedSetTimeout; -var cachedClearTimeout; - -function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); -} -function defaultClearTimeout () { - throw new Error('clearTimeout has not been defined'); -} -(function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } -} ()) -function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); - } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); - } - } - - -} -function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); - } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); - } - } - - - -} -var queue = []; -var draining = false; -var currentQueue; -var queueIndex = -1; - -function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - if (queue.length) { - drainQueue(); - } -} - -function drainQueue() { - if (draining) { - return; - } - var timeout = runTimeout(cleanUpNextTick); - draining = true; - - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - runClearTimeout(timeout); -} - -process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; -process.prependListener = noop; -process.prependOnceListener = noop; - -process.listeners = function (name) { return [] } - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - - -/***/ }), -/* 507 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var EE = __webpack_require__(14); -var PluginManager = __webpack_require__(12); - -/** - * @namespace Phaser.Events - */ - -/** - * @classdesc - * EventEmitter is a Scene Systems plugin compatible version of eventemitter3. - * - * @class EventEmitter - * @extends EventEmitter - * @memberOf Phaser.Events - * @constructor - * @since 3.0.0 - */ -var EventEmitter = new Class({ - - Extends: EE, - - initialize: - - function EventEmitter () - { - EE.call(this); - }, - - /** - * Removes all listeners. - * - * @method Phaser.Events.EventEmitter#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this.removeAllListeners(); - }, - - /** - * Removes all listeners. - * - * @method Phaser.Events.EventEmitter#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.removeAllListeners(); - } - -}); - -/** - * @namespace EventEmitter - */ - -/** - * Return an array listing the events for which the emitter has registered listeners. - * - * @method EventEmitter#eventNames - * - * @return {array} - */ - -/** - * Return the listeners registered for a given event. - * - * @method EventEmitter#listeners - * - * @param {string|symbol} event - The event name. - * - * @return {array} The registered listeners. - */ - -/** - * Return the number of listeners listening to a given event. - * - * @method EventEmitter#listenerCount - * - * @param {string|symbol} event - The event name. - * - * @return {number} The number of listeners. - */ - -/** - * Calls each of the listeners registered for a given event. - * - * @method EventEmitter#emit - * - * @param {string|symbol} event - The event name. - * - * @return {Boolean} `true` if the event had listeners, else `false`. - */ - -/** - * Add a listener for a given event. - * - * @method EventEmitter#on - * - * @param {string|symbol} event - The event name. - * @param {function} fn - The listener function. - * @param {*} [context=this] - The context to invoke the listener with. - * - * @return {EventEmitter} `this`. - */ - -/** - * Add a listener for a given event. - * - * @method EventEmitter#addListener - * - * @param {string|symbol} event - The event name. - * @param {function} fn - The listener function. - * @param {*} [context=this] - The context to invoke the listener with. - * - * @return {EventEmitter} `this`. - */ - -/** - * Add a one-time listener for a given event. - * - * @method EventEmitter#once - * - * @param {string|symbol} event - The event name. - * @param {function} fn - The listener function. - * @param {*} [context=this] - The context to invoke the listener with. - * - * @return {EventEmitter} `this`. - */ - -/** - * Remove the listeners of a given event. - * - * @method EventEmitter#removeListener - * - * @param {string|symbol} event - The event name. - * @param {function} fn - Only remove the listeners that match this function. - * @param {*} context - Only remove the listeners that have this context. - * @param {boolean} once - Only remove one-time listeners. - * - * @return {EventEmitter} `this`. - */ - -/** - * Remove the listeners of a given event. - * - * @method EventEmitter#off - * - * @param {string|symbol} event - The event name. - * @param {function} fn - Only remove the listeners that match this function. - * @param {*} context - Only remove the listeners that have this context. - * @param {boolean} once - Only remove one-time listeners. - * - * @return {EventEmitter} `this`. - */ - -/** - * Remove all listeners, or those of the specified event. - * - * @method EventEmitter#removeAllListeners - * - * @param {string|symbol} [event] - The event name. - * - * @return {EventEmitter} `this`. - */ - -PluginManager.register('EventEmitter', EventEmitter, 'events'); - -module.exports = EventEmitter; - - -/***/ }), -/* 508 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var AddToDOM = __webpack_require__(125); -var AnimationManager = __webpack_require__(199); -var CacheManager = __webpack_require__(202); -var CanvasPool = __webpack_require__(21); -var Class = __webpack_require__(0); -var Config = __webpack_require__(509); -var CreateRenderer = __webpack_require__(510); -var DataManager = __webpack_require__(79); -var DebugHeader = __webpack_require__(518); -var Device = __webpack_require__(519); -var DOMContentLoaded = __webpack_require__(232); -var EventEmitter = __webpack_require__(14); -var InputManager = __webpack_require__(240); -var NOOP = __webpack_require__(3); -var PluginManager = __webpack_require__(12); -var SceneManager = __webpack_require__(252); -var SoundManagerCreator = __webpack_require__(256); -var TextureManager = __webpack_require__(263); -var TimeStep = __webpack_require__(542); -var VisibilityHandler = __webpack_require__(543); - -/** - * @classdesc - * The Phaser.Game instance is the main controller for the entire Phaser game. It is responsible - * for handling the boot process, parsing the configuration values, creating the renderer, - * and setting-up all of the global Phaser systems, such as sound and input. - * Once that is complete it will start the Scene Manager and then begin the main game loop. - * - * You should generally avoid accessing any of the systems created by Game, and instead use those - * made available to you via the Phaser.Scene Systems class instead. - * - * @class Game - * @memberOf Phaser - * @constructor - * @since 3.0.0 - * - * @param {object} [GameConfig] - The configuration object for your Phaser Game instance. - */ -var Game = new Class({ - - initialize: - - function Game (config) - { - /** - * The parsed Game Configuration object. - * - * The values stored within this object are read-only and should not be changed at run-time. - * - * @name Phaser.Game#config - * @type {Phaser.Boot.Config} - * @readOnly - * @since 3.0.0 - */ - this.config = new Config(config); - - /** - * A reference to either the Canvas or WebGL Renderer that this Game is using. - * - * @name Phaser.Game#renderer - * @type {Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer} - * @since 3.0.0 - */ - this.renderer = null; - - /** - * A reference to the HTML Canvas Element on which the renderer is drawing. - * - * @name Phaser.Game#canvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.canvas = null; - - /** - * A reference to the Canvas Rendering Context belonging to the Canvas Element this game is rendering to. - * - * @name Phaser.Game#context - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.context = null; - - /** - * A flag indicating when this Game instance has finished its boot process. - * - * @name Phaser.Game#isBooted - * @type {boolean} - * @readOnly - * @since 3.0.0 - */ - this.isBooted = false; - - /** - * A flag indicating if this Game is currently running its game step or not. - * - * @name Phaser.Game#isRunning - * @type {boolean} - * @readOnly - * @since 3.0.0 - */ - this.isRunning = false; - - /** - * An Event Emitter which is used to broadcast game-level events from the global systems. - * - * @name Phaser.Game#events - * @type {EventEmitter} - * @since 3.0.0 - */ - this.events = new EventEmitter(); - - /** - * An instance of the Animation Manager. - * - * The Animation Manager is a global system responsible for managing all animations used within your game. - * - * @name Phaser.Game#anims - * @type {Phaser.Animations.AnimationManager} - * @since 3.0.0 - */ - this.anims = new AnimationManager(this); - - /** - * An instance of the Texture Manager. - * - * The Texture Manager is a global system responsible for managing all textures being used by your game. - * - * @name Phaser.Game#textures - * @type {Phaser.Textures.TextureManager} - * @since 3.0.0 - */ - this.textures = new TextureManager(this); - - /** - * An instance of the Cache Manager. - * - * The Cache Manager is a global system responsible for caching, accessing and releasing external game assets. - * - * @name Phaser.Game#cache - * @type {Phaser.Cache.CacheManager} - * @since 3.0.0 - */ - this.cache = new CacheManager(this); - - /** - * [description] - * - * @name Phaser.Game#registry - * @type {Phaser.Data.DataManager} - * @since 3.0.0 - */ - this.registry = new DataManager(this); - - /** - * An instance of the Input Manager. - * - * The Input Manager is a global system responsible for the capture of browser-level input events. - * - * @name Phaser.Game#input - * @type {Phaser.Input.InputManager} - * @since 3.0.0 - */ - this.input = new InputManager(this, this.config); - - /** - * An instance of the Scene Manager. - * - * The Scene Manager is a global system responsible for creating, modifying and updating the Scenes in your game. - * - * @name Phaser.Game#scene - * @type {Phaser.Scenes.SceneManager} - * @since 3.0.0 - */ - this.scene = new SceneManager(this, this.config.sceneConfig); - - /** - * A reference to the Device inspector. - * - * Contains information about the device running this game, such as OS, browser vendor and feature support. - * Used by various systems to determine capabilities and code paths. - * - * @name Phaser.Game#device - * @type {Phaser.Device} - * @since 3.0.0 - */ - this.device = Device; - - /** - * An instance of the base Sound Manager. - * - * The Sound Manager is a global system responsible for the playback and updating of all audio in your game. - * - * @name Phaser.Game#sound - * @type {Phaser.BaseSoundManager} - * @since 3.0.0 - */ - this.sound = SoundManagerCreator.create(this); - - /** - * An instance of the Time Step. - * - * The Time Step is a global system responsible for setting-up and responding to the browser frame events, processing - * them and calculating delta values. It then automatically calls the game step. - * - * @name Phaser.Game#loop - * @type {Phaser.Boot.TimeStep} - * @since 3.0.0 - */ - this.loop = new TimeStep(this, this.config.fps); - - /** - * An instance of the Plugin Manager. - * - * The Plugin Manager is a global system that allows plugins to register themselves with it, and can then install - * those plugins into Scenes as required. - * - * @name Phaser.Game#plugins - * @type {Phaser.Boot.PluginManager} - * @since 3.0.0 - */ - this.plugins = new PluginManager(this, this.config); - - /** - * The `onStepCallback` is a callback that is fired each time the Time Step ticks. - * It is set automatically when the Game boot process has completed. - * - * @name Phaser.Game#onStepCallback - * @type {function} - * @private - * @since 3.0.0 - */ - this.onStepCallback = NOOP; - - // Wait for the DOM Ready event, then call boot. - DOMContentLoaded(this.boot.bind(this)); - }, - - /** - * Game boot event. - * - * This is an internal event dispatched when the game has finished booting, but before it is ready to start running. - * The global systems use this event to know when to set themselves up, dispatching their own `ready` events as required. - * - * @event Phaser.Game#boot - */ - - /** - * This method is called automatically when the DOM is ready. It is responsible for creating the renderer, - * displaying the Debug Header, adding the game canvas to the DOM and emitting the 'boot' event. - * It listens for a 'ready' event from the base systems and once received it will call `Game.start`. - * - * @method Phaser.Game#boot - * @protected - * @fires Phaser.Game#boot - * @since 3.0.0 - */ - boot: function () - { - this.isBooted = true; - - this.config.preBoot(this); - - CreateRenderer(this); - - DebugHeader(this); - - AddToDOM(this.canvas, this.config.parent); - - this.events.emit('boot'); - - // The Texture Manager has to wait on a couple of non-blocking events before it's fully ready, so it will emit this event - this.events.once('ready', this.start, this); - }, - - /** - * Called automatically by Game.boot once all of the global systems have finished setting themselves up. - * By this point the Game is now ready to start the main loop running. - * It will also enable the Visibility Handler. - * - * @method Phaser.Game#start - * @protected - * @since 3.0.0 - */ - start: function () - { - this.isRunning = true; - - this.config.postBoot(this); - - if (this.renderer) - { - this.loop.start(this.step.bind(this)); - } - else - { - this.loop.start(this.headlessStep.bind(this)); - } - - VisibilityHandler(this.events); - - this.events.on('hidden', this.onHidden, this); - this.events.on('visible', this.onVisible, this); - this.events.on('blur', this.onBlur, this); - this.events.on('focus', this.onFocus, this); - }, - - /** - * Game Pre-Render event. - * - * This event is dispatched immediately before any of the Scenes have started to render. - * The renderer will already have been initialized this frame, clearing itself and preparing to receive - * the Scenes for rendering, but it won't have actually drawn anything yet. - * - * @event Phaser.Game#prerenderEvent - * @param {Phaser.Renderer.CanvasRenderer|Phaser.Renderer.WebGLRenderer} renderer - A reference to the current renderer. - */ - - /** - * Game Post-Render event. - * - * This event is dispatched right at the end of the render process. - * Every Scene will have rendered and drawn to the canvas. - * - * @event Phaser.Game#postrenderEvent - * @param {Phaser.Renderer.CanvasRenderer|Phaser.Renderer.WebGLRenderer} renderer - A reference to the current renderer. - */ - - /** - * The main Game Step. Called automatically by the Time Step, once per browser frame (typically as a result of - * Request Animation Frame, or Set Timeout on very old browsers.) - * - * The step will update the global managers first, then proceed to update each Scene in turn, via the Scene Manager. - * - * It will then render each Scene in turn, via the Renderer. This process emits `prerender` and `postrender` events. - * - * @method Phaser.Game#step - * @fires Phaser.Game#prerenderEvent - * @fires Phaser.Game#postrenderEvent - * @since 3.0.0 - * - * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {number} delta - The delta time elapsed since the last frame. - */ - step: function (time, delta) - { - // Global Managers - - this.input.update(time, delta); - - this.sound.update(time, delta); - - // Scenes - - this.onStepCallback(); - - this.scene.update(time, delta); - - // Render - - var renderer = this.renderer; - - renderer.preRender(); - - this.events.emit('prerender', renderer); - - this.scene.render(renderer); - - renderer.postRender(); - - this.events.emit('postrender', renderer); - }, - - /** - * A special version of the Game Step for the HEADLESS renderer only. - * - * The main Game Step. Called automatically by the Time Step, once per browser frame (typically as a result of - * Request Animation Frame, or Set Timeout on very old browsers.) - * - * The step will update the global managers first, then proceed to update each Scene in turn, via the Scene Manager. - * - * This process emits `prerender` and `postrender` events, even though nothing actually displays. - * - * @method Phaser.Game#headlessStep - * @fires Phaser.Game#prerenderEvent - * @fires Phaser.Game#postrenderEvent - * @since 3.2.0 - * - * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {number} delta - The delta time elapsed since the last frame. - */ - headlessStep: function (time, delta) - { - // Global Managers - - this.input.update(time, delta); - - this.sound.update(time, delta); - - // Scenes - - this.onStepCallback(); - - this.scene.update(time, delta); - - // Render - - this.events.emit('prerender'); - - this.events.emit('postrender'); - }, - - /** - * Game Pause event. - * - * This event is dispatched when the game loop enters a paused state, usually as a result of the Visibility Handler. - * - * @event Phaser.Game#pauseEvent - */ - - /** - * Called automatically by the Visibility Handler. - * This will pause the main loop and then emit a pause event. - * - * @method Phaser.Game#onHidden - * @protected - * @fires Phaser.Game#pauseEvent - * @since 3.0.0 - */ - onHidden: function () - { - this.loop.pause(); - - this.events.emit('pause'); - }, - - /** - * Game Resume event. - * - * This event is dispatched when the game loop leaves a paused state and resumes running. - * - * @event Phaser.Game#resumeEvent - */ - - /** - * Called automatically by the Visibility Handler. - * This will resume the main loop and then emit a resume event. - * - * @method Phaser.Game#onVisible - * @protected - * @fires Phaser.Game#resumeEvent - * @since 3.0.0 - */ - onVisible: function () - { - this.loop.resume(); - - this.events.emit('resume'); - }, - - /** - * Called automatically by the Visibility Handler. - * This will set the main loop into a 'blurred' state, which pauses it. - * - * @method Phaser.Game#onBlur - * @protected - * @since 3.0.0 - */ - onBlur: function () - { - this.loop.blur(); - }, - - /** - * Called automatically by the Visibility Handler. - * This will set the main loop into a 'focused' state, which resumes it. - * - * @method Phaser.Game#onFocus - * @protected - * @since 3.0.0 - */ - onFocus: function () - { - this.loop.focus(); - }, - - /** - * Game Resize event. - * - * @event Phaser.Game#resizeEvent - * @param {number} width - The new width of the Game. - * @param {number} height - The new height of the Game. - */ - - /** - * Updates the Game Config with the new width and height values given. - * Then resizes the Renderer and Input Manager scale. - * - * @method Phaser.Game#resize - * @since 3.2.0 - * - * @param {number} width - The new width of the game. - * @param {number} height - The new height of the game. - */ - resize: function (width, height) - { - this.config.width = width; - this.config.height = height; - - this.renderer.resize(width, height); - - this.input.resize(); - - this.scene.resize(width, height); - - this.events.emit('resize', width, height); - }, - - /** - * Destroys this Phaser.Game instance, all global systems, all sub-systems and all Scenes. - * - * @method Phaser.Game#destroy - * @since 3.0.0 - */ - destroy: function (removeCanvas) - { - this.loop.destroy(); - - this.scene.destroy(); - - this.renderer.destroy(); - - this.events.emit('destroy'); - - this.events.removeAllListeners(); - - this.onStepCallback = null; - - if (removeCanvas) - { - CanvasPool.remove(this.canvas); - } - } - -}); - -module.exports = Game; - - -/***/ }), -/* 509 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(19); -var GetValue = __webpack_require__(4); -var MATH = __webpack_require__(16); -var NOOP = __webpack_require__(3); -var Plugins = __webpack_require__(236); -var ValueToColor = __webpack_require__(116); - -/** - * This callback type is completely empty, a no-operation. - * - * @callback NOOP - */ - -/** - * @typedef {object} FPSConfig - * - * @property {integer} [min=10] - [description] - * @property {integer} [target=60] - [description] - * @property {boolean} [forceSetTimeOut=false] - [description] - * @property {integer} [deltaHistory=10] - [description] - * @property {integer} [panicMax=120] - [description] - */ - -/** - * @typedef {object} LoaderConfig - * - * @property {string} [baseURL] - [description] - * @property {string} [path] - [description] - * @property {boolean} [enableParallel=true] - [description] - * @property {integer} [maxParallelDownloads=4] - [description] - * @property {string|undefined} [crossOrigin=undefined] - [description] - * @property {string} [responseType] - [description] - * @property {boolean} [async=true] - [description] - * @property {string} [user] - [description] - * @property {string} [password] - [description] - * @property {integer} [timeout=0] - [description] - */ - -/** - * @typedef {object} GameConfig - * - * @property {integer|string} [width=1024] - [description] - * @property {integer|string} [height=768] - [description] - * @property {number} [zoom=1] - [description] - * @property {number} [resolution=1] - [description] - * @property {number} [type=CONST.AUTO] - [description] - * @property {object} [?parent=null] - [description] - * @property {HTMLCanvasElement} [?canvas=null] - [description] - * @property {string} [?canvasStyle=null] - [description] - * @property {object} [?scene=null] - [description] - * @property {array} [seed] - [description] - * @property {string} [title=''] - [description] - * @property {string} [url='http://phaser.io'] - [description] - * @property {string} [version=''] - [description] - * @property {object} [input] - [description] - * @property {boolean} [input.keyboard=true] - [description] - * @property {object} [input.keyboard.target=window] - [description] - * @property {boolean} [input.mouse=true] - [description] - * @property {object} [?input.mouse.target=null] - [description] - * @property {boolean} [input.touch=true] - [description] - * @property {object} [?input.touch.target=null] - [description] - * @property {object} [?input.touch.capture=true] - [description] - * @property {boolean} [input.gamepad=false] - [description] - * @property {boolean} [disableContextMenu=false] - [description] - * @property {boolean} [banner=false] - [description] - * @property {boolean} [banner.hidePhaser=false] - [description] - * @property {string} [banner.text='#ffffff'] - [description] - * @property {array} [banner.background] - [description] - * @property {FPSConfig} [?fps] - [description] - * @property {boolean} [pixelArt=false] - [description] - * @property {boolean} [autoResize=false] - [description] - * @property {boolean} [roundPixels=false] - [description] - * @property {boolean} [transparent=false] - [description] - * @property {boolean} [clearBeforeRender=true] - [description] - * @property {string|number} [backgroundColor=0x000000] - [description] - * @property {object} [?callbacks] - [description] - * @property {function} [callbacks.preBoot=NOOP] - [description] - * @property {function} [callbacks.postBoot=NOOP] - [description] - * @property {LoaderConfig} [?loader] - [description] - * @property {object} [?images] - [description] - * @property {string} [images.default] - [description] - * @property {string} [images.missing] - [description] - */ - -/** - * @classdesc - * [description] - * - * @class Config - * @memberOf Phaser.Boot - * @constructor - * @since 3.0.0 - * - * @param {object} [GameConfig] - The configuration object for your Phaser Game instance. - * - */ -var Config = new Class({ - - initialize: - - function Config (config) - { - if (config === undefined) { config = {}; } - - var defaultBannerColor = [ - '#ff0000', - '#ffff00', - '#00ff00', - '#00ffff', - '#000000' - ]; - - var defaultBannerTextColor = '#ffffff'; - - this.width = GetValue(config, 'width', 1024); - this.height = GetValue(config, 'height', 768); - this.zoom = GetValue(config, 'zoom', 1); - - this.resolution = GetValue(config, 'resolution', 1); - - this.renderType = GetValue(config, 'type', CONST.AUTO); - - this.parent = GetValue(config, 'parent', null); - this.canvas = GetValue(config, 'canvas', null); - this.canvasStyle = GetValue(config, 'canvasStyle', null); - - this.sceneConfig = GetValue(config, 'scene', null); - - this.seed = GetValue(config, 'seed', [ (Date.now() * Math.random()).toString() ]); - - MATH.RND.init(this.seed); - - this.gameTitle = GetValue(config, 'title', ''); - this.gameURL = GetValue(config, 'url', 'https://phaser.io'); - this.gameVersion = GetValue(config, 'version', ''); - - // Input - this.inputKeyboard = GetValue(config, 'input.keyboard', true); - this.inputKeyboardEventTarget = GetValue(config, 'input.keyboard.target', window); - - this.inputMouse = GetValue(config, 'input.mouse', true); - this.inputMouseEventTarget = GetValue(config, 'input.mouse.target', null); - this.inputMouseCapture = GetValue(config, 'input.mouse.capture', true); - - this.inputTouch = GetValue(config, 'input.touch', true); - this.inputTouchEventTarget = GetValue(config, 'input.touch.target', null); - this.inputTouchCapture = GetValue(config, 'input.touch.capture', true); - - this.inputGamepad = GetValue(config, 'input.gamepad', false); - - this.disableContextMenu = GetValue(config, 'disableContextMenu', false); - - this.audio = GetValue(config, 'audio'); - - // If you do: { banner: false } it won't display any banner at all - this.hideBanner = (GetValue(config, 'banner', null) === false); - - this.hidePhaser = GetValue(config, 'banner.hidePhaser', false); - this.bannerTextColor = GetValue(config, 'banner.text', defaultBannerTextColor); - this.bannerBackgroundColor = GetValue(config, 'banner.background', defaultBannerColor); - - if (this.gameTitle === '' && this.hidePhaser) - { - this.hideBanner = true; - } - - // Frame Rate config - // fps: { - // min: 10, - // target: 60, - // forceSetTimeOut: false, - // deltaHistory: 10 - // } - - this.fps = GetValue(config, 'fps', null); - - this.pixelArt = GetValue(config, 'pixelArt', false); - this.autoResize = GetValue(config, 'autoResize', false); - this.roundPixels = GetValue(config, 'roundPixels', false); - this.transparent = GetValue(config, 'transparent', false); - this.clearBeforeRender = GetValue(config, 'clearBeforeRender', true); - - var bgc = GetValue(config, 'backgroundColor', 0); - - this.backgroundColor = ValueToColor(bgc); - - if (bgc === 0 && this.transparent) - { - this.backgroundColor.alpha = 0; - } - - // Callbacks - this.preBoot = GetValue(config, 'callbacks.preBoot', NOOP); - this.postBoot = GetValue(config, 'callbacks.postBoot', NOOP); - - // Physics - // physics: { - // system: 'impact', - // setBounds: true, - // gravity: 0, - // cellSize: 64 - // } - this.physics = GetValue(config, 'physics', {}); - this.defaultPhysicsSystem = GetValue(this.physics, 'default', false); - - // Loader Defaults - this.loaderBaseURL = GetValue(config, 'loader.baseURL', ''); - this.loaderPath = GetValue(config, 'loader.path', ''); - this.loaderEnableParallel = GetValue(config, 'loader.enableParallel', true); - this.loaderMaxParallelDownloads = GetValue(config, 'loader.maxParallelDownloads', 4); - this.loaderCrossOrigin = GetValue(config, 'loader.crossOrigin', undefined); - this.loaderResponseType = GetValue(config, 'loader.responseType', ''); - this.loaderAsync = GetValue(config, 'loader.async', true); - this.loaderUser = GetValue(config, 'loader.user', ''); - this.loaderPassword = GetValue(config, 'loader.password', ''); - this.loaderTimeout = GetValue(config, 'loader.timeout', 0); - - // Scene Plugins - this.defaultPlugins = GetValue(config, 'plugins', Plugins.DefaultScene); - - // Default / Missing Images - var pngPrefix = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAg'; - - this.defaultImage = GetValue(config, 'images.default', pngPrefix + 'AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=='); - this.missingImage = GetValue(config, 'images.missing', pngPrefix + 'CAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg=='); - } - -}); - -module.exports = Config; - - -/***/ }), -/* 510 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CanvasInterpolation = __webpack_require__(226); -var CanvasPool = __webpack_require__(21); -var CONST = __webpack_require__(19); -var Features = __webpack_require__(126); - -/** - * Called automatically by Phaser.Game and responsible for creating the renderer it will use. - * - * Relies upon two webpack global flags to be defined: `WEBGL_RENDERER` and `CANVAS_RENDERER` during build time, but not at run-time. - * - * @function Phaser.Boot.CreateRenderer - * @since 3.0.0 - * - * @param {Phaser.Game} game - The Phaser.Game instance on which the renderer will be set. - */ -var CreateRenderer = function (game) -{ - var config = game.config; - - // Game either requested Canvas, - // or requested AUTO or WEBGL but the browser doesn't support it, so fall back to Canvas - - if (config.renderType !== CONST.HEADLESS) - { - if (config.renderType === CONST.CANVAS || (config.renderType !== CONST.CANVAS && !Features.webGL)) - { - if (Features.canvas) - { - // They requested Canvas and their browser supports it - config.renderType = CONST.CANVAS; - } - else - { - throw new Error('Cannot create Canvas or WebGL context, aborting.'); - } - } - else - { - // Game requested WebGL and browser says it supports it - config.renderType = CONST.WEBGL; - } - } - - // Pixel Art mode? - if (config.pixelArt) - { - CanvasPool.disableSmoothing(); - } - - // Does the game config provide its own canvas element to use? - if (config.canvas) - { - game.canvas = config.canvas; - } - else - { - game.canvas = CanvasPool.create(game, config.width, config.height, config.renderType); - } - - // Does the game config provide some canvas css styles to use? - if (config.canvasStyle) - { - game.canvas.style = config.canvasStyle; - } - - // Pixel Art mode? - if (config.pixelArt) - { - CanvasInterpolation.setCrisp(game.canvas); - } - - // Zoomed? - if (config.zoom !== 1) - { - game.canvas.style.width = (config.width * config.zoom).toString() + 'px'; - game.canvas.style.height = (config.height * config.zoom).toString() + 'px'; - } - - if (config.renderType === CONST.HEADLESS) - { - // Nothing more to do here - return; - } - - var CanvasRenderer; - var WebGLRenderer; - - if (true) - { - CanvasRenderer = __webpack_require__(366); - WebGLRenderer = __webpack_require__(371); - - // Let the config pick the renderer type, both are included - if (config.renderType === CONST.WEBGL) - { - game.renderer = new WebGLRenderer(game); - game.context = null; - } - else - { - game.renderer = new CanvasRenderer(game); - game.context = game.renderer.gameContext; - } - } - - if (false) - { - WebGLRenderer = require('../renderer/webgl/WebGLRenderer'); - - // Force the type to WebGL, regardless what was requested - config.renderType = CONST.WEBGL; - game.renderer = new WebGLRenderer(game); - game.context = null; - } - - if (false) - { - CanvasRenderer = require('../renderer/canvas/CanvasRenderer'); - - // Force the type to Canvas, regardless what was requested - config.renderType = CONST.CANVAS; - game.renderer = new CanvasRenderer(game); - game.context = game.renderer.gameContext; - } -}; - -module.exports = CreateRenderer; - - -/***/ }), -/* 511 */ -/***/ (function(module, exports) { - -module.exports = "#define SHADER_NAME PHASER_BITMAP_MASK_FS\r\n\r\nprecision mediump float;\r\n\r\nuniform vec2 uResolution;\r\nuniform sampler2D uMainSampler;\r\nuniform sampler2D uMaskSampler;\r\nuniform bool uInvertMaskAlpha;\r\n\r\nvoid main()\r\n{\r\n vec2 uv = gl_FragCoord.xy / uResolution;\r\n vec4 mainColor = texture2D(uMainSampler, uv);\r\n vec4 maskColor = texture2D(uMaskSampler, uv);\r\n float alpha = mainColor.a;\r\n\r\n if (!uInvertMaskAlpha)\r\n {\r\n alpha *= (maskColor.a);\r\n }\r\n else\r\n {\r\n alpha *= (1.0 - maskColor.a);\r\n }\r\n \r\n gl_FragColor = vec4(mainColor.rgb * alpha, alpha);\r\n}\r\n" - -/***/ }), -/* 512 */ -/***/ (function(module, exports) { - -module.exports = "#define SHADER_NAME PHASER_BITMAP_MASK_VS\r\n\r\nprecision mediump float;\r\n\r\nattribute vec2 inPosition;\r\n\r\nvoid main()\r\n{\r\n gl_Position = vec4(inPosition, 0.0, 1.0);\r\n}\r\n" - -/***/ }), -/* 513 */ -/***/ (function(module, exports) { - -module.exports = "#define SHADER_NAME PHASER_FLAT_TINT_FS\r\n\r\nprecision mediump float;\r\n\r\nvarying vec4 outTint;\r\n\r\nvoid main() {\r\n gl_FragColor = vec4(outTint.rgb * outTint.a, outTint.a);\r\n}\r\n" - -/***/ }), -/* 514 */ -/***/ (function(module, exports) { - -module.exports = "#define SHADER_NAME PHASER_FLAT_TINT_VS\r\n\r\nprecision mediump float;\r\n\r\nuniform mat4 uProjectionMatrix;\r\nuniform mat4 uViewMatrix;\r\nuniform mat4 uModelMatrix;\r\n\r\nattribute vec2 inPosition;\r\nattribute vec4 inTint;\r\n\r\nvarying vec4 outTint;\r\n\r\nvoid main () {\r\n gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);\r\n outTint = inTint;\r\n}\r\n" - -/***/ }), -/* 515 */ -/***/ (function(module, exports) { - -module.exports = "#define SHADER_NAME PHASER_FORWARD_DIFFUSE_FS\r\n\r\nprecision mediump float;\r\n\r\nstruct Light\r\n{\r\n vec2 position;\r\n vec3 color;\r\n float intensity;\r\n float radius;\r\n};\r\n\r\nconst int kMaxLights = %LIGHT_COUNT%;\r\n\r\nuniform vec4 uCamera; /* x, y, rotation, zoom */\r\nuniform vec2 uResolution;\r\nuniform sampler2D uMainSampler;\r\nuniform sampler2D uNormSampler;\r\nuniform vec3 uAmbientLightColor;\r\nuniform Light uLights[kMaxLights];\r\n\r\nvarying vec2 outTexCoord;\r\nvarying vec4 outTint;\r\n\r\nvoid main()\r\n{\r\n vec3 finalColor = vec3(0.0, 0.0, 0.0);\r\n vec4 color = texture2D(uMainSampler, outTexCoord) * vec4(outTint.rgb * outTint.a, outTint.a);\r\n vec3 normalMap = texture2D(uNormSampler, outTexCoord).rgb;\r\n vec3 normal = normalize(vec3(normalMap * 2.0 - 1.0));\r\n vec2 res = vec2(min(uResolution.x, uResolution.y)) * uCamera.w;\r\n\r\n for (int index = 0; index < kMaxLights; ++index)\r\n {\r\n Light light = uLights[index];\r\n vec3 lightDir = vec3((light.position.xy / res) - (gl_FragCoord.xy / res), 0.1);\r\n vec3 lightNormal = normalize(lightDir);\r\n float distToSurf = length(lightDir) * uCamera.w;\r\n float diffuseFactor = max(dot(normal, lightNormal), 0.0);\r\n float radius = (light.radius / res.x * uCamera.w) * uCamera.w;\r\n float attenuation = clamp(1.0 - distToSurf * distToSurf / (radius * radius), 0.0, 1.0);\r\n vec3 diffuse = light.color * diffuseFactor;\r\n finalColor += (attenuation * diffuse) * light.intensity;\r\n }\r\n\r\n vec4 colorOutput = vec4(uAmbientLightColor + finalColor, 1.0);\r\n gl_FragColor = color * vec4(colorOutput.rgb * colorOutput.a, colorOutput.a);\r\n\r\n}\r\n" - -/***/ }), -/* 516 */ -/***/ (function(module, exports) { - -module.exports = "#define SHADER_NAME PHASER_TEXTURE_TINT_FS\r\n\r\nprecision mediump float;\r\n\r\nuniform sampler2D uMainSampler;\r\n\r\nvarying vec2 outTexCoord;\r\nvarying vec4 outTint;\r\n\r\nvoid main() \r\n{\r\n vec4 texel = texture2D(uMainSampler, outTexCoord);\r\n texel *= vec4(outTint.rgb * outTint.a, outTint.a);\r\n gl_FragColor = texel;\r\n}\r\n" - -/***/ }), -/* 517 */ -/***/ (function(module, exports) { - -module.exports = "#define SHADER_NAME PHASER_TEXTURE_TINT_VS\r\n\r\nprecision mediump float;\r\n\r\nuniform mat4 uProjectionMatrix;\r\nuniform mat4 uViewMatrix;\r\nuniform mat4 uModelMatrix;\r\n\r\nattribute vec2 inPosition;\r\nattribute vec2 inTexCoord;\r\nattribute vec4 inTint;\r\n\r\nvarying vec2 outTexCoord;\r\nvarying vec4 outTint;\r\n\r\nvoid main () \r\n{\r\n gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);\r\n outTexCoord = inTexCoord;\r\n outTint = inTint;\r\n}\r\n\r\n" - -/***/ }), -/* 518 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(19); - -/** - * Called automatically by Phaser.Game and responsible for creating the console.log debug header. - * - * You can customize or disable the header via the Game Config object. - * - * @function Phaser.Boot.DebugHeader - * @since 3.0.0 - * - * @param {Phaser.Game} game - The Phaser.Game instance which will output this debug header. - */ -var DebugHeader = function (game) -{ - var config = game.config; - - if (config.hideBanner) - { - return; - } - - var renderType = 'WebGL'; - - if (config.renderType === CONST.CANVAS) - { - renderType = 'Canvas'; - } - else if (config.renderType === CONST.HEADLESS) - { - renderType = 'Headless'; - } - - var audioConfig = config.audio; - var deviceAudio = game.device.audio; - - var audioType; - - if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio)) - { - audioType = 'Web Audio'; - } - else if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) - { - audioType = 'No Audio'; - } - else - { - audioType = 'HTML5 Audio'; - } - - if (!game.device.browser.ie) - { - var c = ''; - var args = [ c ]; - - if (Array.isArray(config.bannerBackgroundColor)) - { - var lastColor; - - config.bannerBackgroundColor.forEach(function (color) - { - c = c.concat('%c '); - - args.push('background: ' + color); - - lastColor = color; - - }); - - // inject the text color - args[args.length - 1] = 'color: ' + config.bannerTextColor + '; background: ' + lastColor; - } - else - { - c = c.concat('%c '); - - args.push('color: ' + config.bannerTextColor + '; background: ' + config.bannerBackgroundColor); - } - - // URL link background color (always white) - args.push('background: #fff'); - - if (config.gameTitle) - { - c = c.concat(config.gameTitle); - - if (config.gameVersion) - { - c = c.concat(' v' + config.gameVersion); - } - - if (!config.hidePhaser) - { - c = c.concat(' / '); - } - } - - if (!config.hidePhaser) - { - c = c.concat('Phaser v' + CONST.VERSION + ' (' + renderType + ' | ' + audioType + ')'); - } - - c = c.concat(' %c ' + config.gameURL); - - // Inject the new string back into the args array - args[0] = c; - - console.log.apply(console, args); - } - else if (window['console']) - { - console.log('Phaser v' + CONST.VERSION + ' / https://phaser.io'); - } -}; - -module.exports = DebugHeader; - - -/***/ }), -/* 519 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// This singleton is instantiated as soon as Phaser loads, -// before a Phaser.Game instance has even been created. -// Which means all instances of Phaser Games can share it, -// without having to re-poll the device all over again - -/** - * @namespace Phaser.Device - */ - -module.exports = { - - os: __webpack_require__(67), - browser: __webpack_require__(82), - features: __webpack_require__(126), - input: __webpack_require__(520), - audio: __webpack_require__(521), - video: __webpack_require__(522), - fullscreen: __webpack_require__(523), - canvasFeatures: __webpack_require__(237) - -}; - - -/***/ }), -/* 520 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var OS = __webpack_require__(67); -var Browser = __webpack_require__(82); - -/** - * Determines the input support of the browser running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.input` from within any Scene. - * - * @name Phaser.Device.Input - * @since 3.0.0 - * - * @type {object} - * @property {?string} wheelType - The newest type of Wheel/Scroll event supported: 'wheel', 'mousewheel', 'DOMMouseScroll' - * @property {boolean} gamepads - Is navigator.getGamepads available? - * @property {boolean} mspointer - Is mspointer available? - * @property {boolean} touch - Is touch available? - */ -var Input = { - - gamepads: false, - mspointer: false, - touch: false, - wheelEvent: null - -}; - -function init () -{ - if ('ontouchstart' in document.documentElement || (navigator.maxTouchPoints && navigator.maxTouchPoints >= 1)) - { - Input.touch = true; - } - - if (navigator.msPointerEnabled || navigator.pointerEnabled) - { - Input.mspointer = true; - } - - if (navigator.getGamepads) - { - Input.gamepads = true; - } - - if (!OS.cocoonJS) - { - // See https://developer.mozilla.org/en-US/docs/Web/Events/wheel - if ('onwheel' in window || (Browser.ie && 'WheelEvent' in window)) - { - // DOM3 Wheel Event: FF 17+, IE 9+, Chrome 31+, Safari 7+ - Input.wheelEvent = 'wheel'; - } - else if ('onmousewheel' in window) - { - // Non-FF legacy: IE 6-9, Chrome 1-31, Safari 5-7. - Input.wheelEvent = 'mousewheel'; - } - else if (Browser.firefox && 'MouseScrollEvent' in window) - { - // FF prior to 17. This should probably be scrubbed. - Input.wheelEvent = 'DOMMouseScroll'; - } - } - - return Input; -} - -module.exports = init(); - - -/***/ }), -/* 521 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Browser = __webpack_require__(82); - -/** - * Determines the audio playback capabilities of the device running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.audio` from within any Scene. - * - * @name Phaser.Device.Audio - * @since 3.0.0 - * - * @type {object} - * @property {boolean} audioData - Can this device play HTML Audio tags? - * @property {boolean} dolby - Can this device play EC-3 Dolby Digital Plus files? - * @property {boolean} m4a - Can this device can play m4a files. - * @property {boolean} mp3 - Can this device play mp3 files? - * @property {boolean} ogg - Can this device play ogg files? - * @property {boolean} opus - Can this device play opus files? - * @property {boolean} wav - Can this device play wav files? - * @property {boolean} webAudio - Does this device have the Web Audio API? - * @property {boolean} webm - Can this device play webm files? - */ -var Audio = { - - audioData: false, - dolby: false, - m4a: false, - mp3: false, - ogg: false, - opus: false, - wav: false, - webAudio: false, - webm: false - -}; - -function init () -{ - Audio.audioData = !!(window['Audio']); - - Audio.webAudio = !!(window['AudioContext'] || window['webkitAudioContext']); - - var audioElement = document.createElement('audio'); - - var result = !!audioElement.canPlayType; - - try - { - if (result) - { - if (audioElement.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) - { - Audio.ogg = true; - } - - if (audioElement.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, '') || audioElement.canPlayType('audio/opus;').replace(/^no$/, '')) - { - Audio.opus = true; - } - - if (audioElement.canPlayType('audio/mpeg;').replace(/^no$/, '')) - { - Audio.mp3 = true; - } - - // Mimetypes accepted: - // developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements - // bit.ly/iphoneoscodecs - if (audioElement.canPlayType('audio/wav; codecs="1"').replace(/^no$/, '')) - { - Audio.wav = true; - } - - if (audioElement.canPlayType('audio/x-m4a;') || audioElement.canPlayType('audio/aac;').replace(/^no$/, '')) - { - Audio.m4a = true; - } - - if (audioElement.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, '')) - { - Audio.webm = true; - } - - if (audioElement.canPlayType('audio/mp4;codecs="ec-3"') !== '') - { - if (Browser.edge) - { - Audio.dolby = true; - } - else if (Browser.safari && Browser.safariVersion >= 9) - { - if ((/Mac OS X (\d+)_(\d+)/).test(navigator.userAgent)) - { - var major = parseInt(RegExp.$1, 10); - var minor = parseInt(RegExp.$2, 10); - - if ((major === 10 && minor >= 11) || major > 10) - { - Audio.dolby = true; - } - } - } - } - } - } - catch (e) - { - // Nothing to do here - } - - return Audio; -} - -module.exports = init(); - - -/***/ }), -/* 522 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Determines the video support of the browser running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.video` from within any Scene. - * - * @name Phaser.Device.Video - * @since 3.0.0 - * - * @type {object} - * @property {boolean} h264Video - Can this device play h264 mp4 video files? - * @property {boolean} hlsVideo - Can this device play hls video files? - * @property {boolean} mp4Video - Can this device play h264 mp4 video files? - * @property {boolean} oggVideo - Can this device play ogg video files? - * @property {boolean} vp9Video - Can this device play vp9 video files? - * @property {boolean} webmVideo - Can this device play webm video files? - */ -var Video = { - - h264Video: false, - hlsVideo: false, - mp4Video: false, - oggVideo: false, - vp9Video: false, - webmVideo: false - -}; - -function init () -{ - var videoElement = document.createElement('video'); - var result = !!videoElement.canPlayType; - - try - { - if (result) - { - if (videoElement.canPlayType('video/ogg; codecs="theora"').replace(/^no$/, '')) - { - Video.oggVideo = true; - } - - if (videoElement.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/, '')) - { - // Without QuickTime, this value will be `undefined`. github.com/Modernizr/Modernizr/issues/546 - Video.h264Video = true; - Video.mp4Video = true; - } - - if (videoElement.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/, '')) - { - Video.webmVideo = true; - } - - if (videoElement.canPlayType('video/webm; codecs="vp9"').replace(/^no$/, '')) - { - Video.vp9Video = true; - } - - if (videoElement.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(/^no$/, '')) - { - Video.hlsVideo = true; - } - } - } - catch (e) - { - // Nothing to do - } - - return Video; -} - -module.exports = init(); - - -/***/ }), -/* 523 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Determines the full screen support of the browser running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.fullscreen` from within any Scene. - * - * @name Phaser.Device.Fullscreen - * @since 3.0.0 - * - * @type {object} - * @property {boolean} available - Does the browser support the Full Screen API? - * @property {boolean} keyboard - Does the browser support access to the Keyboard during Full Screen mode? - * @property {string} cancel - If the browser supports the Full Screen API this holds the call you need to use to cancel it. - * @property {string} request - If the browser supports the Full Screen API this holds the call you need to use to activate it. - */ -var Fullscreen = { - - available: false, - cancel: '', - keyboard: false, - request: '' - -}; - -/** -* Checks for support of the Full Screen API. -*/ -function init () -{ - var i; - - var fs = [ - 'requestFullscreen', - 'requestFullScreen', - 'webkitRequestFullscreen', - 'webkitRequestFullScreen', - 'msRequestFullscreen', - 'msRequestFullScreen', - 'mozRequestFullScreen', - 'mozRequestFullscreen' - ]; - - var element = document.createElement('div'); - - for (i = 0; i < fs.length; i++) - { - if (element[fs[i]]) - { - Fullscreen.available = true; - Fullscreen.request = fs[i]; - break; - } - } - - var cfs = [ - 'cancelFullScreen', - 'exitFullscreen', - 'webkitCancelFullScreen', - 'webkitExitFullscreen', - 'msCancelFullScreen', - 'msExitFullscreen', - 'mozCancelFullScreen', - 'mozExitFullscreen' - ]; - - if (Fullscreen.available) - { - for (i = 0; i < cfs.length; i++) - { - if (document[cfs[i]]) - { - Fullscreen.cancel = cfs[i]; - break; - } - } - } - - // Keyboard Input? - if (window['Element'] && Element['ALLOW_KEYBOARD_INPUT']) - { - Fullscreen.keyboard = true; - } - - return Fullscreen; -} - -module.exports = init(); - - -/***/ }), -/* 524 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var AdvanceKeyCombo = __webpack_require__(525); - -/** - * Used internally by the KeyCombo class. - * - * @function Phaser.Input.Keyboard.KeyCombo.ProcessKeyCombo - * @since 3.0.0 - * - * @param {[type]} event - [description] - * @param {[type]} combo - [description] - * - * @return {[type]} [description] - */ -var ProcessKeyCombo = function (event, combo) -{ - if (combo.matched) - { - return true; - } - - var comboMatched = false; - var keyMatched = false; - - if (event.keyCode === combo.current) - { - // Key was correct - - if (combo.index > 0 && combo.maxKeyDelay > 0) - { - // We have to check to see if the delay between - // the new key and the old one was too long (if enabled) - - var timeLimit = combo.timeLastMatched + combo.maxKeyDelay; - - // Check if they pressed it in time or not - if (event.timeStamp <= timeLimit) - { - keyMatched = true; - comboMatched = AdvanceKeyCombo(event, combo); - } - } - else - { - keyMatched = true; - - // We don't check the time for the first key pressed, so just advance it - comboMatched = AdvanceKeyCombo(event, combo); - } - } - - if (!keyMatched && combo.resetOnWrongKey) - { - // Wrong key was pressed - combo.index = 0; - combo.current = combo.keyCodes[0]; - } - - if (comboMatched) - { - combo.timeLastMatched = event.timeStamp; - combo.matched = true; - combo.timeMatched = event.timeStamp; - } - - return comboMatched; -}; - -module.exports = ProcessKeyCombo; - - -/***/ }), -/* 525 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Used internally by the KeyCombo class. - * Return `true` if it reached the end of the combo, `false` if not. - * - * @function Phaser.Input.Keyboard.KeyCombo.AdvanceKeyCombo - * @since 3.0.0 - * - * @param {[type]} event - [description] - * @param {[type]} combo - [description] - * - * @return {boolean} `true` if it reached the end of the combo, `false` if not. - */ -var AdvanceKeyCombo = function (event, combo) -{ - combo.timeLastMatched = event.timeStamp; - combo.index++; - - if (combo.index === combo.size) - { - return true; - } - else - { - combo.current = combo.keyCodes[combo.index]; - return false; - } -}; - -module.exports = AdvanceKeyCombo; - - -/***/ }), -/* 526 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Used internally by the KeyCombo class. - * - * @function Phaser.Input.Keyboard.KeyCombo.ResetKeyCombo - * @since 3.0.0 - * - * @param {Phaser.Input.Keyboard.KeyCombo} combo - The KeyCombo to reset. - * - * @return {Phaser.Input.Keyboard.KeyCombo} The KeyCombo. - */ -var ResetKeyCombo = function (combo) -{ - combo.current = combo.keyCodes[0]; - combo.index = 0; - combo.timeLastMatched = 0; - combo.matched = false; - combo.timeMatched = 0; - - return combo; -}; - -module.exports = ResetKeyCombo; - - -/***/ }), -/* 527 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var KeyCodes = __webpack_require__(129); - -var KeyMap = {}; - -for (var key in KeyCodes) -{ - KeyMap[KeyCodes[key]] = key; -} - -module.exports = KeyMap; - - -/***/ }), -/* 528 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Used internally by the KeyboardManager. - * - * @function Phaser.Input.Keyboard.Keys.ProcessKeyDown - * @since 3.0.0 - * - * @param {Phaser.Input.Keyboard.Key} key - [description] - * @param {[type]} event - [description] - * - * @return {Phaser.Input.Keyboard.Key} [description] - */ -var ProcessKeyDown = function (key, event) -{ - key.originalEvent = event; - - if (key.preventDefault) - { - event.preventDefault(); - } - - if (!key.enabled) - { - return; - } - - key.altKey = event.altKey; - key.ctrlKey = event.ctrlKey; - key.shiftKey = event.shiftKey; - key.location = event.location; - - if (key.isDown === false) - { - key.isDown = true; - key.isUp = false; - key.timeDown = event.timeStamp; - key.duration = 0; - } - - key.repeats++; - - key._justDown = true; - key._justUp = false; - - return key; -}; - -module.exports = ProcessKeyDown; - - -/***/ }), -/* 529 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Used internally by the KeyboardManager. - * - * @function Phaser.Input.Keyboard.Keys.ProcessKeyUp - * @since 3.0.0 - * - * @param {Phaser.Input.Keyboard.Key} key - [description] - * @param {[type]} event - [description] - * - * @return {Phaser.Input.Keyboard.Key} [description] - */ -var ProcessKeyUp = function (key, event) -{ - key.originalEvent = event; - - if (key.preventDefault) - { - event.preventDefault(); - } - - if (!key.enabled) - { - return; - } - - key.isDown = false; - key.isUp = true; - key.timeUp = event.timeStamp; - key.duration = key.timeUp - key.timeDown; - key.repeats = 0; - - key._justDown = false; - key._justUp = true; - - return key; -}; - -module.exports = ProcessKeyUp; - - -/***/ }), -/* 530 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetFastValue = __webpack_require__(2); -var UppercaseFirst = __webpack_require__(254); - -/** - * Builds an array of which physics plugins should be activated for the given Scene. - * - * @function Phaser.Scenes.GetPhysicsPlugins - * @since 3.0.0 - * - * @param {Phaser.Scenes.Systems} sys - [description] - * - * @return {array} [description] - */ -var GetPhysicsPlugins = function (sys) -{ - var defaultSystem = sys.game.config.defaultPhysicsSystem; - var sceneSystems = GetFastValue(sys.settings, 'physics', false); - - if (!defaultSystem && !sceneSystems) - { - // No default physics system or systems in this scene - return; - } - - // Let's build the systems array - var output = []; - - if (defaultSystem) - { - output.push(UppercaseFirst(defaultSystem + 'Physics')); - } - - if (sceneSystems) - { - for (var key in sceneSystems) - { - key = UppercaseFirst(key.concat('Physics')); - - if (output.indexOf(key) === -1) - { - output.push(key); - } - } - } - - // An array of Physics systems to start for this Scene - return output; -}; - -module.exports = GetPhysicsPlugins; - - -/***/ }), -/* 531 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetFastValue = __webpack_require__(2); - -/** - * Builds an array of which plugins (not including physics plugins) should be activated for the given Scene. - * - * @function Phaser.Scenes.GetScenePlugins - * @since 3.0.0 - * - * @param {Phaser.Scenes.Systems} sys - [description] - * - * @return {array} [description] - */ -var GetScenePlugins = function (sys) -{ - var defaultPlugins = sys.game.config.defaultPlugins; - var scenePlugins = GetFastValue(sys.settings, 'plugins', false); - - // Scene Plugins always override Default Plugins - if (Array.isArray(scenePlugins)) - { - return scenePlugins; - } - else if (defaultPlugins) - { - return defaultPlugins; - } - else - { - // No default plugins or plugins in this scene - return []; - } -}; - -module.exports = GetScenePlugins; - - -/***/ }), -/* 532 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// These properties get injected into the Scene and map to local systems -// The map key is the property that is added to the Scene, the value is the Scene.Systems reference -// These defaults can be modified via the Scene config object - -var InjectionMap = { - - game: 'game', - - anims: 'anims', - cache: 'cache', - registry: 'registry', - sound: 'sound', - textures: 'textures', - - events: 'events', - cameras: 'cameras', - cameras3d: 'cameras3d', - add: 'add', - make: 'make', - scenePlugin: 'scene', - displayList: 'children', - lights: 'lights', - - data: 'data', - input: 'input', - load: 'load', - time: 'time', - tweens: 'tweens', - - arcadePhysics: 'physics', - impactPhysics: 'impact', - matterPhysics: 'matter' - -}; - -module.exports = InjectionMap; - - -/***/ }), -/* 533 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Adds a Canvas Element to a Texture. - * - * @function Phaser.Textures.Parsers.Canvas - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {integer} sourceIndex - The index of the TextureSource. - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var Canvas = function (texture, sourceIndex) -{ - var source = texture.source[sourceIndex]; - - texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); - - return texture; -}; - -module.exports = Canvas; - - -/***/ }), -/* 534 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Adds an Image Element to a Texture. - * - * @function Phaser.Textures.Parsers.Image - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {integer} sourceIndex - The index of the TextureSource. - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var Image = function (texture, sourceIndex) -{ - var source = texture.source[sourceIndex]; - - texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); - - return texture; -}; - -module.exports = Image; - - -/***/ }), -/* 535 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clone = __webpack_require__(53); - -/** - * Parses a Texture Atlas JSON Array and adds the Frames to the Texture. - * JSON format expected to match that defined by Texture Packer, with the frames property containing an array of Frames. - * - * @function Phaser.Textures.Parsers.JSONArray - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {integer} sourceIndex - The index of the TextureSource. - * @param {object} json - The JSON data. - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var JSONArray = function (texture, sourceIndex, json) -{ - // Malformed? - if (!json['frames'] && !json['textures']) - { - console.warn('Invalid Texture Atlas JSON Array given, missing \'frames\' and \'textures\' array'); - return; - } - - // Add in a __BASE entry (for the entire atlas) - var source = texture.source[sourceIndex]; - - texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); - - // By this stage frames is a fully parsed array - var frames = (Array.isArray(json.textures)) ? json.textures[sourceIndex].frames : json.frames; - - var newFrame; - - for (var i = 0; i < frames.length; i++) - { - var src = frames[i]; - - // The frame values are the exact coordinates to cut the frame out of the atlas from - newFrame = texture.add(src.filename, sourceIndex, src.frame.x, src.frame.y, src.frame.w, src.frame.h); - - // These are the original (non-trimmed) sprite values - if (src.trimmed) - { - newFrame.setTrim( - src.sourceSize.w, - src.sourceSize.h, - src.spriteSourceSize.x, - src.spriteSourceSize.y, - src.spriteSourceSize.w, - src.spriteSourceSize.h - ); - } - - if (src.rotated) - { - newFrame.rotated = true; - newFrame.updateUVsInverted(); - } - - if (src.anchor) - { - newFrame.customPivot = true; - newFrame.pivotX = src.anchor.x; - newFrame.pivotY = src.anchor.y; - } - - // Copy over any extra data - newFrame.customData = Clone(src); - } - - // Copy over any additional data that was in the JSON to Texture.customData - for (var dataKey in json) - { - if (dataKey === 'frames') - { - continue; - } - - if (Array.isArray(json[dataKey])) - { - texture.customData[dataKey] = json[dataKey].slice(0); - } - else - { - texture.customData[dataKey] = json[dataKey]; - } - } - - return texture; -}; - -module.exports = JSONArray; - - -/***/ }), -/* 536 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clone = __webpack_require__(53); - -/** - * Parses a Texture Atlas JSON Hash and adds the Frames to the Texture. - * JSON format expected to match that defined by Texture Packer, with the frames property containing an object of Frames. - * - * @function Phaser.Textures.Parsers.JSONHash - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {integer} sourceIndex - The index of the TextureSource. - * @param {object} json - The JSON data. - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var JSONHash = function (texture, sourceIndex, json) -{ - // Malformed? - if (!json['frames']) - { - console.warn('Invalid Texture Atlas JSON Hash given, missing \'frames\' Object'); - return; - } - - // Add in a __BASE entry (for the entire atlas) - var source = texture.source[sourceIndex]; - - texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); - - // By this stage frames is a fully parsed Object - var frames = json['frames']; - var newFrame; - - for (var key in frames) - { - var src = frames[key]; - - // The frame values are the exact coordinates to cut the frame out of the atlas from - newFrame = texture.add(key, sourceIndex, src.frame.x, src.frame.y, src.frame.w, src.frame.h); - - // These are the original (non-trimmed) sprite values - if (src.trimmed) - { - newFrame.setTrim( - src.sourceSize.w, - src.sourceSize.h, - src.spriteSourceSize.x, - src.spriteSourceSize.y, - src.spriteSourceSize.w, - src.spriteSourceSize.h - ); - } - - if (src.rotated) - { - newFrame.rotated = true; - newFrame.updateUVsInverted(); - } - - // Copy over any extra data - newFrame.customData = Clone(src); - } - - // Copy over any additional data that was in the JSON to Texture.customData - for (var dataKey in json) - { - if (dataKey === 'frames') - { - continue; - } - - if (Array.isArray(json[dataKey])) - { - texture.customData[dataKey] = json[dataKey].slice(0); - } - else - { - texture.customData[dataKey] = json[dataKey]; - } - } - - return texture; -}; - -module.exports = JSONHash; - - -/***/ }), -/* 537 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Parses a Pyxel JSON object and adds the Frames to a Texture. - * - * @function Phaser.Textures.Parsers.Pyxel - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {object} json - The JSON data. - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var Pyxel = function (texture, json) -{ - // Malformed? There are a few keys to check here. - var signature = [ 'layers', 'tilewidth', 'tileheight', 'tileswide', 'tileshigh' ]; - - signature.forEach(function (key) - { - if (!json[key]) - { - // console.warn('Phaser.AnimationParser.JSONDataPyxel: Invalid Pyxel Tilemap JSON given, missing "' + key + '" key.'); - // console.log(json); - return; - } - }); - - // For this purpose, I only care about parsing tilemaps with a single layer. - if (json['layers'].length !== 1) - { - // console.warn('Phaser.AnimationParser.JSONDataPyxel: Too many layers, this parser only supports flat Tilemaps.'); - // console.log(json); - return; - } - - var data = new Phaser.FrameData(); - - var tileheight = json['tileheight']; - var tilewidth = json['tilewidth']; - - var frames = json['layers'][0]['tiles']; - var newFrame; - - for (var i = 0; i < frames.length; i++) - { - newFrame = data.addFrame(new Phaser.Frame( - i, - frames[i].x, - frames[i].y, - tilewidth, - tileheight, - 'frame_' + i // No names are included in pyxel tilemap data. - )); - - // No trim data is included. - newFrame.setTrim(false); - } - - return data; -}; - -module.exports = Pyxel; - - -/***/ }), -/* 538 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetFastValue = __webpack_require__(2); - -/** - * Parses a Sprite Sheet and adds the Frames to the Texture. - * - * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact - * same size and cannot be trimmed or rotated. - * - * @function Phaser.Textures.Parsers.SpriteSheet - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {integer} sourceIndex - The index of the TextureSource. - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {object} config - [description] - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var SpriteSheet = function (texture, sourceIndex, x, y, width, height, config) -{ - var frameWidth = GetFastValue(config, 'frameWidth', null); - var frameHeight = GetFastValue(config, 'frameHeight', frameWidth); - - // If missing we can't proceed - if (frameWidth === null) - { - throw new Error('TextureManager.SpriteSheet: Invalid frameWidth given.'); - } - - // Add in a __BASE entry (for the entire atlas) - var source = texture.source[sourceIndex]; - - texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); - - var startFrame = GetFastValue(config, 'startFrame', 0); - var endFrame = GetFastValue(config, 'endFrame', -1); - var margin = GetFastValue(config, 'margin', 0); - var spacing = GetFastValue(config, 'spacing', 0); - - var row = Math.floor((width - margin + spacing) / (frameWidth + spacing)); - var column = Math.floor((height - margin + spacing) / (frameHeight + spacing)); - var total = row * column; - - if (startFrame > total || startFrame < -total) - { - startFrame = 0; - } - - if (startFrame < 0) - { - // Allow negative skipframes. - startFrame = total + startFrame; - } - - if (endFrame !== -1) - { - total = startFrame + (endFrame + 1); - } - - var fx = margin; - var fy = margin; - var ax = 0; - var ay = 0; - - for (var i = 0; i < total; i++) - { - ax = 0; - ay = 0; - - var w = fx + frameWidth; - var h = fy + frameHeight; - - if (w > width) - { - ax = w - width; - } - - if (h > height) - { - ay = h - height; - } - - texture.add(i, sourceIndex, x + fx, y + fy, frameWidth - ax, frameHeight - ay); - - fx += frameWidth + spacing; - - if (fx + frameWidth > width) - { - fx = margin; - fy += frameHeight + spacing; - } - } - - return texture; -}; - -module.exports = SpriteSheet; - - -/***/ }), -/* 539 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetFastValue = __webpack_require__(2); - -/** - * Parses a Sprite Sheet and adds the Frames to the Texture, where the Sprite Sheet is stored as a frame within an Atlas. - * - * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact - * same size and cannot be trimmed or rotated. - * - * @function Phaser.Textures.Parsers.SpriteSheetFromAtlas - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {Phaser.Textures.Frame} frame - The Frame that contains the Sprite Sheet. - * @param {object} config - [description] - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var SpriteSheetFromAtlas = function (texture, frame, config) -{ - var frameWidth = GetFastValue(config, 'frameWidth', null); - var frameHeight = GetFastValue(config, 'frameHeight', frameWidth); - - // If missing we can't proceed - if (!frameWidth) - { - throw new Error('TextureManager.SpriteSheetFromAtlas: Invalid frameWidth given.'); - } - - // Add in a __BASE entry (for the entire atlas) - // var source = texture.source[sourceIndex]; - // texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); - - var startFrame = GetFastValue(config, 'startFrame', 0); - var endFrame = GetFastValue(config, 'endFrame', -1); - var margin = GetFastValue(config, 'margin', 0); - var spacing = GetFastValue(config, 'spacing', 0); - - var x = frame.cutX; - var y = frame.cutY; - - var cutWidth = frame.cutWidth; - var cutHeight = frame.cutHeight; - var sheetWidth = frame.realWidth; - var sheetHeight = frame.realHeight; - - var row = Math.floor((sheetWidth - margin + spacing) / (frameWidth + spacing)); - var column = Math.floor((sheetHeight - margin + spacing) / (frameHeight + spacing)); - var total = row * column; - - // trim offsets - - var leftPad = frame.x; - var leftWidth = frameWidth - leftPad; - - var rightWidth = frameWidth - ((sheetWidth - cutWidth) - leftPad); - - var topPad = frame.y; - var topHeight = frameHeight - topPad; - - var bottomHeight = frameHeight - ((sheetHeight - cutHeight) - topPad); - - // console.log('x / y', x, y); - // console.log('cutW / H', cutWidth, cutHeight); - // console.log('sheetW / H', sheetWidth, sheetHeight); - // console.log('row', row, 'column', column, 'total', total); - // console.log('LW', leftWidth, 'RW', rightWidth, 'TH', topHeight, 'BH', bottomHeight); - - if (startFrame > total || startFrame < -total) - { - startFrame = 0; - } - - if (startFrame < 0) - { - // Allow negative skipframes. - startFrame = total + startFrame; - } - - if (endFrame !== -1) - { - total = startFrame + (endFrame + 1); - } - - var sheetFrame; - var frameX = margin; - var frameY = margin; - var frameIndex = 0; - var sourceIndex = frame.sourceIndex; - - for (var sheetY = 0; sheetY < column; sheetY++) - { - var topRow = (sheetY === 0); - var bottomRow = (sheetY === column - 1); - - for (var sheetX = 0; sheetX < row; sheetX++) - { - var leftRow = (sheetX === 0); - var rightRow = (sheetX === row - 1); - - sheetFrame = texture.add(frameIndex, sourceIndex, x + frameX, y + frameY, frameWidth, frameHeight); - - if (leftRow || topRow || rightRow || bottomRow) - { - var destX = (leftRow) ? leftPad : 0; - var destY = (topRow) ? topPad : 0; - var destWidth = frameWidth; - var destHeight = frameHeight; - - if (leftRow) - { - destWidth = leftWidth; - } - else if (rightRow) - { - destWidth = rightWidth; - } - - if (topRow) - { - destHeight = topHeight; - } - else if (bottomRow) - { - destHeight = bottomHeight; - } - - sheetFrame.cutWidth = destWidth; - sheetFrame.cutHeight = destHeight; - - sheetFrame.setTrim(frameWidth, frameHeight, destX, destY, destWidth, destHeight); - } - - frameX += spacing; - - if (leftRow) - { - frameX += leftWidth; - } - else if (rightRow) - { - frameX += rightRow; - } - else - { - frameX += frameWidth; - } - - frameIndex++; - } - - frameX = margin; - frameY += spacing; - - if (topRow) - { - frameY += topHeight; - } - else if (bottomRow) - { - frameY += bottomHeight; - } - else - { - frameY += frameHeight; - } - } - - return texture; -}; - -module.exports = SpriteSheetFromAtlas; - - -/***/ }), -/* 540 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Parses a Starling XML object and adds all the Frames into a Texture. - * - * @function Phaser.Textures.Parsers.StarlingXML - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {any} xml - The XML data. - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var StarlingXML = function (texture, xml) -{ - // Malformed? - if (!xml.getElementsByTagName('TextureAtlas')) - { - // console.warn("Phaser.AnimationParser.XMLData: Invalid Texture Atlas XML given, missing tag"); - return; - } - - // Let's create some frames then - var data = new Phaser.FrameData(); - var frames = xml.getElementsByTagName('SubTexture'); - var newFrame; - - var name; - var frame; - var x; - var y; - var width; - var height; - var frameX; - var frameY; - var frameWidth; - var frameHeight; - - for (var i = 0; i < frames.length; i++) - { - frame = frames[i].attributes; - - name = frame.name.value; - x = parseInt(frame.x.value, 10); - y = parseInt(frame.y.value, 10); - width = parseInt(frame.width.value, 10); - height = parseInt(frame.height.value, 10); - - frameX = null; - frameY = null; - - if (frame.frameX) - { - frameX = Math.abs(parseInt(frame.frameX.value, 10)); - frameY = Math.abs(parseInt(frame.frameY.value, 10)); - frameWidth = parseInt(frame.frameWidth.value, 10); - frameHeight = parseInt(frame.frameHeight.value, 10); - } - - newFrame = data.addFrame(new Phaser.Frame(i, x, y, width, height, name)); - - // Trimmed? - if (frameX !== null || frameY !== null) - { - newFrame.setTrim(true, width, height, frameX, frameY, frameWidth, frameHeight); - } - } - - return data; - -}; - -module.exports = StarlingXML; - - -/***/ }), -/* 541 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var imageHeight = 0; - -var addFrame = function (texture, sourceIndex, name, frame) -{ - // The frame values are the exact coordinates to cut the frame out of the atlas from - - var y = imageHeight - frame.y - frame.height; - - // var newFrame = texture.add(name, sourceIndex, frame.x, y, frame.width, frame.height); - - texture.add(name, sourceIndex, frame.x, y, frame.width, frame.height); - - // console.log('name', name, 'rect', frame.x, y, frame.width, frame.height); - - // These are the original (non-trimmed) sprite values - /* - if (src.trimmed) - { - newFrame.setTrim( - src.sourceSize.w, - src.sourceSize.h, - src.spriteSourceSize.x, - src.spriteSourceSize.y, - src.spriteSourceSize.w, - src.spriteSourceSize.h - ); - } - */ -}; - -/** - * Parses a Unity YAML File and creates Frames in the Texture. - * For more details about Sprite Meta Data see https://docs.unity3d.com/ScriptReference/SpriteMetaData.html - * - * @function Phaser.Textures.Parsers.UnityYAML - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {integer} sourceIndex - The index of the TextureSource. - * @param {object} yaml - The YAML data. - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var UnityYAML = function (texture, sourceIndex, yaml) -{ - // Add in a __BASE entry (for the entire atlas) - var source = texture.source[sourceIndex]; - - texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); - - imageHeight = source.height; - - var data = yaml.split('\n'); - - var lineRegExp = /^[ ]*(- )*(\w+)+[: ]+(.*)/; - - var prevSprite = ''; - var currentSprite = ''; - var rect = { x: 0, y: 0, width: 0, height: 0 }; - - // var pivot = { x: 0, y: 0 }; - // var border = { x: 0, y: 0, z: 0, w: 0 }; - - for (var i = 0; i < data.length; i++) - { - var results = data[i].match(lineRegExp); - - if (!results) - { - continue; - } - - var isList = (results[1] === '- '); - var key = results[2]; - var value = results[3]; - - if (isList) - { - if (currentSprite !== prevSprite) - { - addFrame(texture, sourceIndex, currentSprite, rect); - - prevSprite = currentSprite; - } - - rect = { x: 0, y: 0, width: 0, height: 0 }; - } - - if (key === 'name') - { - // Start new list - currentSprite = value; - continue; - } - - switch (key) - { - case 'x': - case 'y': - case 'width': - case 'height': - rect[key] = parseInt(value, 10); - break; - - // case 'pivot': - // pivot = eval('var obj = ' + value); - // break; - - // case 'border': - // border = eval('var obj = ' + value); - // break; - } - } - - if (currentSprite !== prevSprite) - { - addFrame(texture, sourceIndex, currentSprite, rect); - } - - return texture; -}; - -module.exports = UnityYAML; - -/* -Example data: - -TextureImporter: - spritePivot: {x: .5, y: .5} - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spritePixelsToUnits: 100 - spriteSheet: - sprites: - - name: asteroids_0 - rect: - serializedVersion: 2 - x: 5 - y: 328 - width: 65 - height: 82 - alignment: 0 - pivot: {x: 0, y: 0} - border: {x: 0, y: 0, z: 0, w: 0} - - name: asteroids_1 - rect: - serializedVersion: 2 - x: 80 - y: 322 - width: 53 - height: 88 - alignment: 0 - pivot: {x: 0, y: 0} - border: {x: 0, y: 0, z: 0, w: 0} - spritePackingTag: Asteroids -*/ - - -/***/ }), -/* 542 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GetValue = __webpack_require__(4); -var NOOP = __webpack_require__(3); -var RequestAnimationFrame = __webpack_require__(235); - -// Frame Rate config -// fps: { -// min: 10, -// target: 60, -// forceSetTimeOut: false, -// deltaHistory: 10, -// panicMax: 120 -// } - -// http://www.testufo.com/#test=animation-time-graph - -/** - * @classdesc - * [description] - * - * @class TimeStep - * @memberOf Phaser.Boot - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - A reference to the Phaser.Game instance that owns this Time Step. - * @param {FPSConfig} config - */ -var TimeStep = new Class({ - - initialize: - - function TimeStep (game, config) - { - /** - * A reference to the Phaser.Game instance. - * - * @property {Phaser.Game} game - * @readOnly - * @since 3.0.0 - */ - this.game = game; - - /** - * [description] - * - * @property {Phaser.DOM.RequestAnimationFrame} raf - * @readOnly - * @since 3.0.0 - */ - this.raf = new RequestAnimationFrame(); - - /** - * A flag that is set once the TimeStep has started running and toggled when it stops. - * - * @property {boolean} started - * @readOnly - * @default false - * @since 3.0.0 - */ - this.started = false; - - /** - * A flag that is set once the TimeStep has started running and toggled when it stops. - * The difference between this value and `started` is that `running` is toggled when - * the TimeStep is sent to sleep, where-as `started` remains `true`, only changing if - * the TimeStep is actually stopped, not just paused. - * - * @property {boolean} running - * @readOnly - * @default false - * @since 3.0.0 - */ - this.running = false; - - /** - * The minimum fps rate you want the Time Step to run at. - * - * @property {integer} minFps - * @default 5 - * @since 3.0.0 - */ - this.minFps = GetValue(config, 'min', 5); - - /** - * The target fps rate for the Time Step to run at. - * - * Setting this value will not actually change the speed at which the browser runs, that is beyond - * the control of Phaser. Instead, it allows you to determine performance issues and if the Time Step - * is spiraling out of control. - * - * @property {integer} targetFps - * @default 60 - * @since 3.0.0 - */ - this.targetFps = GetValue(config, 'target', 60); - - /** - * The minFps value in ms. - * Defaults to 200ms between frames (i.e. super slow!) - * - * @property {number} _min - * @private - * @since 3.0.0 - */ - this._min = 1000 / this.minFps; - - /** - * The targetFps value in ms. - * Defaults to 16.66ms between frames (i.e. normal) - * - * @property {number} _target - * @private - * @since 3.0.0 - */ - this._target = 1000 / this.targetFps; - - /** - * An exponential moving average of the frames per second. - * - * @property {integer} actualFps - * @readOnly - * @default 60 - * @since 3.0.0 - */ - this.actualFps = this.targetFps; - - /** - * [description] - * - * @property {integer} nextFpsUpdate - * @readOnly - * @default 0 - * @since 3.0.0 - */ - this.nextFpsUpdate = 0; - - /** - * The number of frames processed this second. - * - * @property {integer} framesThisSecond - * @readOnly - * @default 0 - * @since 3.0.0 - */ - this.framesThisSecond = 0; - - /** - * A callback to be invoked each time the Time Step steps. - * - * @property {function} callback - * @default NOOP - * @since 3.0.0 - */ - this.callback = NOOP; - - /** - * You can force the Time Step to use Set Timeout instead of Request Animation Frame by setting - * the `forceSetTimeOut` property to `true` in the Game Configuration object. It cannot be changed at run-time. - * - * @property {boolean} forceSetTimeOut - * @readOnly - * @default false - * @since 3.0.0 - */ - this.forceSetTimeOut = GetValue(config, 'forceSetTimeOut', false); - - /** - * [description] - * - * @property {integer} time - * @default 0 - * @since 3.0.0 - */ - this.time = 0; - - /** - * [description] - * - * @property {integer} startTime - * @default 0 - * @since 3.0.0 - */ - this.startTime = 0; - - /** - * [description] - * - * @property {integer} lastTime - * @default 0 - * @since 3.0.0 - */ - this.lastTime = 0; - - /** - * [description] - * - * @property {integer} frame - * @readOnly - * @default 0 - * @since 3.0.0 - */ - this.frame = 0; - - /** - * [description] - * - * @property {boolean} inFocus - * @readOnly - * @default true - * @since 3.0.0 - */ - this.inFocus = true; - - /** - * [description] - * - * @property {integer} _pauseTime - * @private - * @default 0 - * @since 3.0.0 - */ - this._pauseTime = 0; - - /** - * [description] - * - * @property {integer} _coolDown - * @private - * @default 0 - * @since 3.0.0 - */ - this._coolDown = 0; - - /** - * [description] - * - * @property {integer} delta - * @default 0 - * @since 3.0.0 - */ - this.delta = 0; - - /** - * [description] - * - * @property {integer} deltaIndex - * @default 0 - * @since 3.0.0 - */ - this.deltaIndex = 0; - - /** - * [description] - * - * @property {array} deltaHistory - * @default 0 - * @since 3.0.0 - */ - this.deltaHistory = []; - - /** - * [description] - * - * @property {integer} deltaSmoothingMax - * @default 10 - * @since 3.0.0 - */ - this.deltaSmoothingMax = GetValue(config, 'deltaHistory', 10); - - /** - * [description] - * - * @property {integer} panicMax - * @default 120 - * @since 3.0.0 - */ - this.panicMax = GetValue(config, 'panicMax', 120); - - /** - * The actual elapsed time in ms between one update and the next. - * Unlike with `delta` no smoothing, capping, or averaging is applied to this value. - * So please be careful when using this value in calculations. - * - * @property {number} rawDelta - * @default 0 - * @since 3.0.0 - */ - this.rawDelta = 0; - }, - - /** - * Called when the DOM window.onBlur event triggers. - * - * @method Phaser.Boot.TimeStep#blur - * @since 3.0.0 - */ - blur: function () - { - this.inFocus = false; - }, - - /** - * Called when the DOM window.onFocus event triggers. - * - * @method Phaser.Boot.TimeStep#focus - * @since 3.0.0 - */ - focus: function () - { - this.inFocus = true; - - this.resetDelta(); - }, - - /** - * Called when the visibility API says the game is 'hidden' (tab switch out of view, etc) - * - * @method Phaser.Boot.TimeStep#pause - * @since 3.0.0 - */ - pause: function () - { - this._pauseTime = window.performance.now(); - }, - - /** - * Called when the visibility API says the game is 'visible' again (tab switch back into view, etc) - * - * @method Phaser.Boot.TimeStep#resume - * @since 3.0.0 - */ - resume: function () - { - this.resetDelta(); - - this.startTime += this.time - this._pauseTime; - }, - - /** - * [description] - * - * @method Phaser.Boot.TimeStep#resetDelta - * @since 3.0.0 - */ - resetDelta: function () - { - var now = window.performance.now(); - - this.time = now; - this.lastTime = now; - this.nextFpsUpdate = now + 1000; - this.framesThisSecond = 0; - this.frame = 0; - - // Pre-populate smoothing array - - for (var i = 0; i < this.deltaSmoothingMax; i++) - { - this.deltaHistory[i] = Math.min(this._target, this.deltaHistory[i]); - } - - this.delta = 0; - this.deltaIndex = 0; - - this._coolDown = this.panicMax; - }, - - /** - * Starts the Time Step running, if it is not already doing so. - * Called automatically by the Game Boot process. - * - * @method Phaser.Boot.TimeStep#start - * @since 3.0.0 - * - * @param {function} callback - The callback to be invoked each time the Time Step steps. - */ - start: function (callback) - { - if (this.started) - { - return this; - } - - this.started = true; - this.running = true; - - for (var i = 0; i < this.deltaSmoothingMax; i++) - { - this.deltaHistory[i] = this._target; - } - - this.resetDelta(); - - this.startTime = window.performance.now(); - - this.callback = callback; - - this.raf.start(this.step.bind(this), this.forceSetTimeOut); - }, - - /** - * The main step method. This is called each time the browser updates, either by Request Animation Frame, - * or by Set Timeout. It is responsible for calculating the delta values, frame totals, cool down history and more. - * You generally should never call this method directly. - * - * @method Phaser.Boot.TimeStep#step - * @since 3.0.0 - * - * @param {integer} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. - */ - step: function (time) - { - this.frame++; - - this.rawDelta = time - this.lastTime; - - var idx = this.deltaIndex; - var history = this.deltaHistory; - var max = this.deltaSmoothingMax; - - // delta time (time is in ms) - var dt = (time - this.lastTime); - - // When a browser switches tab, then comes back again, it takes around 10 frames before - // the delta time settles down so we employ a 'cooling down' period before we start - // trusting the delta values again, to avoid spikes flooding through our delta average - - if (this._coolDown > 0 || !this.inFocus) - { - this._coolDown--; - - dt = Math.min(dt, this._target); - } - - if (dt > this._min) - { - // Probably super bad start time or browser tab context loss, - // so use the last 'sane' dt value - - dt = history[idx]; - - // Clamp delta to min (in case history has become corrupted somehow) - dt = Math.min(dt, this._min); - } - - // Smooth out the delta over the previous X frames - - // add the delta to the smoothing array - history[idx] = dt; - - // adjusts the delta history array index based on the smoothing count - // this stops the array growing beyond the size of deltaSmoothingMax - this.deltaIndex++; - - if (this.deltaIndex > max) - { - this.deltaIndex = 0; - } - - // Delta Average - var avg = 0; - - // Loop the history array, adding the delta values together - - for (var i = 0; i < max; i++) - { - avg += history[i]; - } - - // Then divide by the array length to get the average delta - avg /= max; - - // Set as the world delta value - this.delta = avg; - - // Real-world timer advance - this.time += this.rawDelta; - - // Update the estimate of the frame rate, `fps`. Every second, the number - // of frames that occurred in that second are included in an exponential - // moving average of all frames per second, with an alpha of 0.25. This - // means that more recent seconds affect the estimated frame rate more than - // older seconds. - // - // When a browser window is NOT minimized, but is covered up (i.e. you're using - // another app which has spawned a window over the top of the browser), then it - // will start to throttle the raf callback time. It waits for a while, and then - // starts to drop the frame rate at 1 frame per second until it's down to just over 1fps. - // So if the game was running at 60fps, and the player opens a new window, then - // after 60 seconds (+ the 'buffer time') it'll be down to 1fps, so rafin'g at 1Hz. - // - // When they make the game visible again, the frame rate is increased at a rate of - // approx. 8fps, back up to 60fps (or the max it can obtain) - // - // There is no easy way to determine if this drop in frame rate is because the - // browser is throttling raf, or because the game is struggling with performance - // because you're asking it to do too much on the device. - - if (time > this.nextFpsUpdate) - { - // Compute the new exponential moving average with an alpha of 0.25. - this.actualFps = 0.25 * this.framesThisSecond + 0.75 * this.actualFps; - this.nextFpsUpdate = time + 1000; - this.framesThisSecond = 0; - } - - this.framesThisSecond++; - - // Interpolation - how far between what is expected and where we are? - var interpolation = avg / this._target; - - this.callback(time, avg, interpolation); - - // Shift time value over - this.lastTime = time; - }, - - /** - * Manually calls TimeStep.step, passing in the performance.now value to it. - * - * @method Phaser.Boot.TimeStep#tick - * @since 3.0.0 - */ - tick: function () - { - this.step(window.performance.now()); - }, - - /** - * Sends the TimeStep to sleep, stopping Request Animation Frame (or SetTimeout) and toggling the `running` flag to false. - * - * @method Phaser.Boot.TimeStep#sleep - * @since 3.0.0 - */ - sleep: function () - { - if (this.running) - { - this.raf.stop(); - - this.running = false; - } - }, - - /** - * Wakes-up the TimeStep, restarting Request Animation Frame (or SetTimeout) and toggling the `running` flag to true. - * The `seamless` argument controls if the wake-up should adjust the start time or not. - * - * @method Phaser.Boot.TimeStep#wake - * @since 3.0.0 - * - * @param {boolean} [seamless=false] - Adjust the startTime based on the lastTime values. - */ - wake: function (seamless) - { - if (this.running) - { - this.sleep(); - } - else if (seamless) - { - this.startTime += -this.lastTime + (this.lastTime = window.performance.now()); - } - - this.raf.start(this.step.bind(this), this.useRAF); - - this.running = true; - - this.step(window.performance.now()); - }, - - /** - * Stops the TimeStep running. - * - * @method Phaser.Boot.TimeStep#stop - * @since 3.0.0 - * - * @return {Phaser.Boot.TimeStep} The TimeStep object. - */ - stop: function () - { - this.running = false; - this.started = false; - - this.raf.stop(); - - return this; - }, - - /** - * Destroys the TimeStep. This will stop Request Animation Frame, stop the step, clear the callbacks and null - * any objects. - * - * @method Phaser.Boot.TimeStep#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.stop(); - - this.callback = NOOP; - - this.raf = null; - this.game = null; - } - -}); - -module.exports = TimeStep; - - -/***/ }), -/* 543 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Visibility Handler hidden event. - * - * The document in which the Game is embedded has entered a hidden state. - * - * @event Phaser.Boot.VisibilityHandler#hidden - */ - -/** - * Visibility Handler visible event. - * - * The document in which the Game is embedded has entered a visible state. - * - * @event Phaser.Boot.VisibilityHandler#visible - */ - -/** - * Visibility Handler blur event. - * - * The window in which the Game is embedded has entered a blurred state. - * - * @event Phaser.Boot.VisibilityHandler#blur - */ - -/** - * Visibility Handler focus event. - * - * The window in which the Game is embedded has entered a focused state. - * - * @event Phaser.Boot.VisibilityHandler#focus - */ - -/** - * The Visibility Handler is responsible for listening out for document level visibility change events. - * This includes `visibilitychange` if the browser supports it, and blur and focus events. It then uses - * the provided Event Emitter and fires the related events. - * - * @function Phaser.Boot.VisibilityHandler - * @fires Phaser.Boot.VisibilityHandler#hidden - * @fires Phaser.Boot.VisibilityHandler#visible - * @fires Phaser.Boot.VisibilityHandler#blur - * @fires Phaser.Boot.VisibilityHandler#focus - * @since 3.0.0 - * - * @param {Phaser.EventEmitter} eventEmitter - The EventEmitter that will emit the visibility events. - */ -var VisibilityHandler = function (eventEmitter) -{ - var hiddenVar; - - if (document.hidden !== undefined) - { - hiddenVar = 'visibilitychange'; - } - else - { - var vendors = [ 'webkit', 'moz', 'ms' ]; - - vendors.forEach(function (prefix) - { - if (document[prefix + 'Hidden'] !== undefined) - { - document.hidden = function () - { - return document[prefix + 'Hidden']; - }; - - hiddenVar = prefix + 'visibilitychange'; - } - - }); - } - - var onChange = function (event) - { - if (document.hidden || event.type === 'pause') - { - eventEmitter.emit('hidden'); - } - else - { - eventEmitter.emit('visible'); - } - }; - - if (hiddenVar) - { - document.addEventListener(hiddenVar, onChange, false); - } - - window.onblur = function () - { - eventEmitter.emit('blur'); - }; - - window.onfocus = function () - { - eventEmitter.emit('focus'); - }; -}; - -module.exports = VisibilityHandler; - - -/***/ }), -/* 544 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.GameObjects - */ - -var GameObjects = { - - DisplayList: __webpack_require__(545), - GameObjectCreator: __webpack_require__(13), - GameObjectFactory: __webpack_require__(9), - UpdateList: __webpack_require__(546), - - Components: __webpack_require__(11), - - BuildGameObject: __webpack_require__(20), - BuildGameObjectAnimation: __webpack_require__(132), - GameObject: __webpack_require__(1), - BitmapText: __webpack_require__(133), - Blitter: __webpack_require__(134), - DynamicBitmapText: __webpack_require__(135), - Graphics: __webpack_require__(136), - Group: __webpack_require__(69), - Image: __webpack_require__(70), - Particles: __webpack_require__(139), - PathFollower: __webpack_require__(290), - RenderTexture: __webpack_require__(141), - Sprite3D: __webpack_require__(81), - Sprite: __webpack_require__(37), - Text: __webpack_require__(142), - TileSprite: __webpack_require__(143), - Zone: __webpack_require__(77), - - // Game Object Factories - - Factories: { - Blitter: __webpack_require__(630), - DynamicBitmapText: __webpack_require__(631), - Graphics: __webpack_require__(632), - Group: __webpack_require__(633), - Image: __webpack_require__(634), - Particles: __webpack_require__(635), - PathFollower: __webpack_require__(636), - RenderTexture: __webpack_require__(637), - Sprite3D: __webpack_require__(638), - Sprite: __webpack_require__(639), - StaticBitmapText: __webpack_require__(640), - Text: __webpack_require__(641), - TileSprite: __webpack_require__(642), - Zone: __webpack_require__(643) - }, - - Creators: { - Blitter: __webpack_require__(644), - DynamicBitmapText: __webpack_require__(645), - Graphics: __webpack_require__(646), - Group: __webpack_require__(647), - Image: __webpack_require__(648), - Particles: __webpack_require__(649), - RenderTexture: __webpack_require__(650), - Sprite3D: __webpack_require__(651), - Sprite: __webpack_require__(652), - StaticBitmapText: __webpack_require__(653), - Text: __webpack_require__(654), - TileSprite: __webpack_require__(655), - Zone: __webpack_require__(656) - } - -}; - -if (true) -{ - // WebGL only Game Objects - GameObjects.Mesh = __webpack_require__(88); - GameObjects.Quad = __webpack_require__(144); - - GameObjects.Factories.Mesh = __webpack_require__(660); - GameObjects.Factories.Quad = __webpack_require__(661); - - GameObjects.Creators.Mesh = __webpack_require__(662); - GameObjects.Creators.Quad = __webpack_require__(663); - - GameObjects.Light = __webpack_require__(292); - - __webpack_require__(293); - __webpack_require__(664); -} - -module.exports = GameObjects; - - -/***/ }), -/* 545 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var List = __webpack_require__(86); -var PluginManager = __webpack_require__(12); -var StableSort = __webpack_require__(267); - -/** - * @classdesc - * [description] - * - * @class DisplayList - * @extends Phaser.Structs.List - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var DisplayList = new Class({ - - Extends: List, - - initialize: - - function DisplayList (scene) - { - List.call(this, scene); - - /** - * [description] - * - * @name Phaser.GameObjects.DisplayList#sortChildrenFlag - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.sortChildrenFlag = false; - - /** - * [description] - * - * @name Phaser.GameObjects.DisplayList#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.GameObjects.DisplayList#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - if (!scene.sys.settings.isBooted) - { - scene.sys.events.once('boot', this.boot, this); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.DisplayList#boot - * @since 3.0.0 - */ - boot: function () - { - var eventEmitter = this.systems.events; - - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); - }, - - /** - * Force a sort of the display list on the next call to depthSort. - * - * @method Phaser.GameObjects.DisplayList#queueDepthSort - * @since 3.0.0 - */ - queueDepthSort: function () - { - this.sortChildrenFlag = true; - }, - - /** - * Immediately sorts the display list if the flag is set. - * - * @method Phaser.GameObjects.DisplayList#depthSort - * @since 3.0.0 - */ - depthSort: function () - { - if (this.sortChildrenFlag) - { - StableSort.inplace(this.list, this.sortByDepth); - - this.sortChildrenFlag = false; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.DisplayList#sortByDepth - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} childA - [description] - * @param {Phaser.GameObjects.GameObject} childB - [description] - * - * @return {integer} [description] - */ - sortByDepth: function (childA, childB) - { - return childA._depth - childB._depth; - }, - - /** - * Given an array of Game Objects, sort the array and return it, - * so that the objects are in index order with the lowest at the bottom. - * - * @method Phaser.GameObjects.DisplayList#sortGameObjects - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject[]} gameObjects - [description] - * - * @return {array} [description] - */ - sortGameObjects: function (gameObjects) - { - if (gameObjects === undefined) { gameObjects = this.list; } - - this.scene.sys.depthSort(); - - return gameObjects.sort(this.sortIndexHandler.bind(this)); - }, - - /** - * Note that the given array is sorted in place, even though it isn't returned directly it will still be updated. - * - * @method Phaser.GameObjects.DisplayList#getTopGameObject - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject[]} gameObjects - [description] - * - * @return {Phaser.GameObjects.GameObject} The top-most Game Object on the Display List. - */ - getTopGameObject: function (gameObjects) - { - this.sortGameObjects(gameObjects); - - return gameObjects[gameObjects.length - 1]; - } - -}); - -PluginManager.register('DisplayList', DisplayList, 'displayList'); - -module.exports = DisplayList; - - -/***/ }), -/* 546 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var PluginManager = __webpack_require__(12); - -/** - * @classdesc - * [description] - * - * @class UpdateList - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var UpdateList = new Class({ - - initialize: - - function UpdateList (scene) - { - /** - * [description] - * - * @name Phaser.GameObjects.UpdateList#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.GameObjects.UpdateList#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - if (!scene.sys.settings.isBooted) - { - scene.sys.events.once('boot', this.boot, this); - } - - /** - * [description] - * - * @name Phaser.GameObjects.UpdateList#_list - * @type {array} + * @name Phaser.Time.Clock#_active + * @type {Phaser.Time.TimerEvent[]} * @private * @default [] * @since 3.0.0 */ - this._list = []; + this._active = []; /** * [description] * - * @name Phaser.GameObjects.UpdateList#_pendingInsertion - * @type {array} + * @name Phaser.Time.Clock#_pendingInsertion + * @type {Phaser.Time.TimerEvent[]} * @private * @default [] * @since 3.0.0 @@ -90492,8 +79306,8 @@ var UpdateList = new Class({ /** * [description] * - * @name Phaser.GameObjects.UpdateList#_pendingRemoval - * @type {array} + * @name Phaser.Time.Clock#_pendingRemoval + * @type {Phaser.Time.TimerEvent[]} * @private * @default [] * @since 3.0.0 @@ -90504,7 +79318,7 @@ var UpdateList = new Class({ /** * [description] * - * @method Phaser.GameObjects.UpdateList#boot + * @method Phaser.Time.Clock#boot * @since 3.0.0 */ boot: function () @@ -90520,29 +79334,74 @@ var UpdateList = new Class({ /** * [description] * - * @method Phaser.GameObjects.UpdateList#add + * @method Phaser.Time.Clock#addEvent * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} child - [description] + * @param {TimerEventConfig} config - [description] * - * @return {Phaser.GameObjects.GameObject} [description] + * @return {Phaser.Time.TimerEvent} [description] */ - add: function (child) + addEvent: function (config) { - // Is child already in this list? + var event = new TimerEvent(config); - if (this._list.indexOf(child) === -1 && this._pendingInsertion.indexOf(child) === -1) - { - this._pendingInsertion.push(child); - } + this._pendingInsertion.push(event); - return child; + return event; }, /** * [description] * - * @method Phaser.GameObjects.UpdateList#preUpdate + * @method Phaser.Time.Clock#delayedCall + * @since 3.0.0 + * + * @param {number} delay - [description] + * @param {function} callback - [description] + * @param {Array.<*>} args - [description] + * @param {*} callbackScope - [description] + * + * @return {Phaser.Time.TimerEvent} [description] + */ + delayedCall: function (delay, callback, args, callbackScope) + { + return this.addEvent({ delay: delay, callback: callback, args: args, callbackScope: callbackScope }); + }, + + /** + * [description] + * + * @method Phaser.Time.Clock#clearPendingEvents + * @since 3.0.0 + * + * @return {Phaser.Time.Clock} [description] + */ + clearPendingEvents: function () + { + this._pendingInsertion = []; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Time.Clock#removeAllEvents + * @since 3.0.0 + * + * @return {Phaser.Time.Clock} [description] + */ + removeAllEvents: function () + { + this._pendingRemoval = this._pendingRemoval.concat(this._active); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Time.Clock#preUpdate * @since 3.0.0 * * @param {number} time - [description] @@ -90560,23 +79419,30 @@ var UpdateList = new Class({ } var i; - var gameObject; + var event; - // Delete old gameObjects + // Delete old events for (i = 0; i < toRemove; i++) { - gameObject = this._pendingRemoval[i]; + event = this._pendingRemoval[i]; - var index = this._list.indexOf(gameObject); + var index = this._active.indexOf(event); if (index > -1) { - this._list.splice(index, 1); + this._active.splice(index, 1); } + + // Pool them? + event.destroy(); } - // Move pending to active - this._list = this._list.concat(this._pendingInsertion.splice(0)); + for (i = 0; i < toInsert; i++) + { + event = this._pendingInsertion[i]; + + this._active.push(event); + } // Clear the lists this._pendingRemoval.length = 0; @@ -90586,7 +79452,7 @@ var UpdateList = new Class({ /** * [description] * - * @method Phaser.GameObjects.UpdateList#update + * @method Phaser.Time.Clock#update * @since 3.0.0 * * @param {number} time - [description] @@ -90594,13 +79460,55 @@ var UpdateList = new Class({ */ update: function (time, delta) { - for (var i = 0; i < this._list.length; i++) - { - var gameObject = this._list[i]; + this.now = time; - if (gameObject.active) + if (this.paused) + { + return; + } + + delta *= this.timeScale; + + for (var i = 0; i < this._active.length; i++) + { + var event = this._active[i]; + + if (event.paused) { - gameObject.preUpdate.call(gameObject, time, delta); + continue; + } + + // Use delta time to increase elapsed. + // Avoids needing to adjust for pause / resume. + // Automatically smoothed by TimeStep class. + // In testing accurate to +- 1ms! + event.elapsed += delta * event.timeScale; + + if (event.elapsed >= event.delay) + { + var remainder = event.elapsed - event.delay; + + // Limit it, in case it's checked in the callback + event.elapsed = event.delay; + + // Process the event + if (!event.hasDispatched && event.callback) + { + event.hasDispatched = true; + event.callback.apply(event.callbackScope, event.args); + } + + if (event.repeatCount > 0) + { + event.repeatCount--; + + event.elapsed = remainder; + event.hasDispatched = false; + } + else + { + this._pendingRemoval.push(event); + } } } }, @@ -90608,56 +79516,29 @@ var UpdateList = new Class({ /** * [description] * - * @method Phaser.GameObjects.UpdateList#remove - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - * - * @return {Phaser.GameObjects.GameObject} [description] - */ - remove: function (child) - { - var index = this._list.indexOf(child); - - if (index !== -1) - { - this._list.splice(index, 1); - } - - return child; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.UpdateList#removeAll - * @since 3.0.0 - * - * @return {Phaser.GameObjects.UpdateList} The UpdateList object. - */ - removeAll: function () - { - var i = this._list.length; - - while (i--) - { - this.remove(this._list[i]); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.UpdateList#shutdown + * @method Phaser.Time.Clock#shutdown * @since 3.0.0 */ shutdown: function () { - this.removeAll(); + var i; - this._list.length = 0; + for (i = 0; i < this._pendingInsertion.length; i++) + { + this._pendingInsertion[i].destroy(); + } + + for (i = 0; i < this._active.length; i++) + { + this._active[i].destroy(); + } + + for (i = 0; i < this._pendingRemoval.length; i++) + { + this._pendingRemoval[i].destroy(); + } + + this._active.length = 0; this._pendingRemoval.length = 0; this._pendingInsertion.length = 0; }, @@ -90665,7 +79546,7 @@ var UpdateList = new Class({ /** * [description] * - * @method Phaser.GameObjects.UpdateList#destroy + * @method Phaser.Time.Clock#destroy * @since 3.0.0 */ destroy: function () @@ -90673,15 +79554,9529 @@ var UpdateList = new Class({ this.shutdown(); this.scene = undefined; - this.systems = undefined; - } }); -PluginManager.register('UpdateList', UpdateList, 'updateList'); +PluginManager.register('Clock', Clock, 'time'); -module.exports = UpdateList; +module.exports = Clock; + + +/***/ }), +/* 406 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Time + */ + +module.exports = { + + Clock: __webpack_require__(405), + TimerEvent: __webpack_require__(183) + +}; + + +/***/ }), +/* 407 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(9); +var ParseToTilemap = __webpack_require__(115); + +/** + * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. + * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing + * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map + * data. For an empty map, you should specify tileWidth, tileHeight, width & height. + * + * @method Phaser.GameObjects.GameObjectFactory#tilemap + * @since 3.0.0 + * + * @param {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data. + * @param {integer} [tileWidth=32] - The width of a tile in pixels. Pass in `null` to leave as the + * default. + * @param {integer} [tileHeight=32] - The height of a tile in pixels. Pass in `null` to leave as the + * default. + * @param {integer} [width=10] - The width of the map in tiles. Pass in `null` to leave as the + * default. + * @param {integer} [height=10] - The height of the map in tiles. Pass in `null` to leave as the + * default. + * @param {integer[][]} [data] - Instead of loading from the cache, you can also load directly from + * a 2D array of tile indexes. Pass in `null` for no data. + * @param {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, in the + * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + * + * @return {Phaser.Tilemaps.Tilemap} + */ +GameObjectFactory.register('tilemap', function (key, tileWidth, tileHeight, width, height, data, insertNull) +{ + // Allow users to specify null to indicate that they want the default value, since null is + // shorter & more legible than undefined. Convert null to undefined to allow ParseToTilemap + // defaults to take effect. + + if (key === null) { key = undefined; } + if (tileWidth === null) { tileWidth = undefined; } + if (tileHeight === null) { tileHeight = undefined; } + if (width === null) { width = undefined; } + if (height === null) { height = undefined; } + + return ParseToTilemap(this.scene, key, tileWidth, tileHeight, width, height, data, insertNull); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 408 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectCreator = __webpack_require__(11); +var ParseToTilemap = __webpack_require__(115); + +/** + * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. + * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing + * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map + * data. For an empty map, you should specify tileWidth, tileHeight, width & height. + * + * @method Phaser.GameObjects.GameObjectCreator#tilemap + * @since 3.0.0 + * + * @param {object} [config] - The config options for the Tilemap. + * @param {string} [config.key] - The key in the Phaser cache that corresponds to the loaded tilemap + * data. + * @param {integer[][]} [config.data] - Instead of loading from the cache, you can also load + * directly from a 2D array of tile indexes. + * @param {integer} [config.tileWidth=32] - The width of a tile in pixels. + * @param {integer} [config.tileHeight=32] - The height of a tile in pixels. + * @param {integer} [config.width=10] - The width of the map in tiles. + * @param {integer} [config.height=10] - The height of the map in tiles. + * @param {boolean} [config.insertNull=false] - Controls how empty tiles, tiles with an index of -1, + * in the map data are handled. If `true`, empty locations will get a value of `null`. If `false`, + * empty location will get a Tile object with an index of -1. If you've a large sparsely populated + * map and the tile data doesn't need to change then setting this value to `true` will help with + * memory consumption. However if your map is small or you need to update the tiles dynamically, + * then leave the default value set. + * + * @return {Phaser.Tilemaps.Tilemap} + */ +GameObjectCreator.register('tilemap', function (config) +{ + // Defaults are applied in ParseToTilemap + var c = (config !== undefined) ? config : {}; + + return ParseToTilemap( + this.scene, + c.key, + c.tileWidth, + c.tileHeight, + c.width, + c.height, + c.data, + c.insertNull + ); +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 409 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.Tilemaps.StaticTilemapLayer} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + src.cull(camera); + + var renderTiles = src.culledTiles; + var tileset = this.tileset; + var ctx = renderer.gameContext; + var tileCount = renderTiles.length; + var image = tileset.image.getSourceImage(); + var tx = src.x - camera.scrollX * src.scrollFactorX; + var ty = src.y - camera.scrollY * src.scrollFactorY; + + ctx.save(); + ctx.translate(tx, ty); + ctx.rotate(src.rotation); + ctx.scale(src.scaleX, src.scaleY); + ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); + ctx.globalAlpha = src.alpha; + + for (var index = 0; index < tileCount; ++index) + { + var tile = renderTiles[index]; + + var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); + + if (tileTexCoords === null) { continue; } + + ctx.drawImage( + image, + tileTexCoords.x, tileTexCoords.y, + tile.width, tile.height, + tile.pixelX, tile.pixelY, + tile.width, tile.height + ); + } + + ctx.restore(); +}; + +module.exports = StaticTilemapLayerCanvasRenderer; + + +/***/ }), +/* 410 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.Tilemaps.StaticTilemapLayer} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + src.upload(camera); + + this.pipeline.drawStaticTilemapLayer(src, camera); +}; + +module.exports = StaticTilemapLayerWebGLRenderer; + + +/***/ }), +/* 411 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); + +if (true) +{ + renderWebGL = __webpack_require__(410); +} + +if (true) +{ + renderCanvas = __webpack_require__(409); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 412 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.Tilemaps.DynamicTilemapLayer} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + src.cull(camera); + + var renderTiles = src.culledTiles; + var length = renderTiles.length; + var image = src.tileset.image.getSourceImage(); + var tileset = this.tileset; + + var tx = src.x - camera.scrollX * src.scrollFactorX; + var ty = src.y - camera.scrollY * src.scrollFactorY; + var ctx = renderer.gameContext; + + ctx.save(); + ctx.translate(tx, ty); + ctx.rotate(src.rotation); + ctx.scale(src.scaleX, src.scaleY); + ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); + + for (var index = 0; index < length; ++index) + { + var tile = renderTiles[index]; + + var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); + if (tileTexCoords === null) { continue; } + + var halfWidth = tile.width / 2; + var halfHeight = tile.height / 2; + + ctx.save(); + ctx.translate(tile.pixelX + halfWidth, tile.pixelY + halfHeight); + + if (tile.rotation !== 0) + { + ctx.rotate(tile.rotation); + } + + if (tile.flipX || tile.flipY) + { + ctx.scale(tile.flipX ? -1 : 1, tile.flipY ? -1 : 1); + } + + ctx.globalAlpha = src.alpha * tile.alpha; + + ctx.drawImage( + image, + tileTexCoords.x, tileTexCoords.y, + tile.width, tile.height, + -halfWidth, -halfHeight, + tile.width, tile.height + ); + + ctx.restore(); + } + + ctx.restore(); +}; + +module.exports = DynamicTilemapLayerCanvasRenderer; + + +/***/ }), +/* 413 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.Tilemaps.DynamicTilemapLayer} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var DynamicTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + src.cull(camera); + + this.pipeline.batchDynamicTilemapLayer(src, camera); +}; + +module.exports = DynamicTilemapLayerWebGLRenderer; + + +/***/ }), +/* 414 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); + +if (true) +{ + renderWebGL = __webpack_require__(413); +} + +if (true) +{ + renderCanvas = __webpack_require__(412); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 415 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Tileset = __webpack_require__(84); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Impact.ParseTilesets + * @since 3.0.0 + * + * @param {object} json - [description] + * + * @return {array} [description] + */ +var ParseTilesets = function (json) +{ + var tilesets = []; + var tilesetsNames = []; + + for (var i = 0; i < json.layer.length; i++) + { + var layer = json.layer[i]; + + // A relative filepath to the source image (within Weltmeister) is used for the name + var tilesetName = layer.tilesetName; + + // Only add unique tilesets that have a valid name. Collision layers will have a blank name. + if (tilesetName !== '' && tilesetsNames.indexOf(tilesetName) === -1) + { + tilesetsNames.push(tilesetName); + + // Tiles are stored with an ID relative to the tileset, rather than a globally unique ID + // across all tilesets. Also, tilesets in Weltmeister have no margin or padding. + tilesets.push(new Tileset(tilesetName, 0, layer.tilesize, layer.tilesize, 0, 0)); + } + } + + return tilesets; +}; + +module.exports = ParseTilesets; + + +/***/ }), +/* 416 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var LayerData = __webpack_require__(66); +var Tile = __webpack_require__(45); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Impact.ParseTileLayers + * @since 3.0.0 + * + * @param {object} json - [description] + * @param {boolean} insertNull - [description] + * + * @return {array} [description] + */ +var ParseTileLayers = function (json, insertNull) +{ + var tileLayers = []; + + for (var i = 0; i < json.layer.length; i++) + { + var layer = json.layer[i]; + + var layerData = new LayerData({ + name: layer.name, + width: layer.width, + height: layer.height, + tileWidth: layer.tilesize, + tileHeight: layer.tilesize, + visible: layer.visible === 1 + }); + + var row = []; + var tileGrid = []; + + // Loop through the data field in the JSON. This is a 2D array containing the tile indexes, + // one after the other. The indexes are relative to the tileset that contains the tile. + for (var y = 0; y < layer.data.length; y++) + { + for (var x = 0; x < layer.data[y].length; x++) + { + // In Weltmeister, 0 = no tile, but the Tilemap API expects -1 = no tile. + var index = layer.data[y][x] - 1; + + var tile; + + if (index > -1) + { + tile = new Tile(layerData, index, x, y, layer.tilesize, layer.tilesize); + } + else + { + tile = insertNull + ? null + : new Tile(layerData, -1, x, y, layer.tilesize, layer.tilesize); + } + + row.push(tile); + } + + tileGrid.push(row); + row = []; + } + + layerData.data = tileGrid; + + tileLayers.push(layerData); + } + + return tileLayers; +}; + +module.exports = ParseTileLayers; + + +/***/ }), +/* 417 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Extend = __webpack_require__(18); + +/** + * Copy properties from tileset to tiles. + * + * @function Phaser.Tilemaps.Parsers.Tiled.AssignTileProperties + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.MapData} mapData - [description] + */ +var AssignTileProperties = function (mapData) +{ + var layerData; + var tile; + var sid; + var set; + var row; + + // go through each of the map data layers + for (var i = 0; i < mapData.layers.length; i++) + { + layerData = mapData.layers[i]; + + set = null; + + // rows of tiles + for (var j = 0; j < layerData.data.length; j++) + { + row = layerData.data[j]; + + // individual tiles + for (var k = 0; k < row.length; k++) + { + tile = row[k]; + + if (tile === null || tile.index < 0) + { + continue; + } + + // find the relevant tileset + sid = mapData.tiles[tile.index][2]; + set = mapData.tilesets[sid]; + + // Ensure that a tile's size matches its tileset + tile.width = set.tileWidth; + tile.height = set.tileHeight; + + // if that tile type has any properties, add them to the tile object + if (set.tileProperties && set.tileProperties[tile.index - set.firstgid]) + { + tile.properties = Extend( + tile.properties, set.tileProperties[tile.index - set.firstgid] + ); + } + } + } + } +}; + +module.exports = AssignTileProperties; + + +/***/ }), +/* 418 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Master list of tiles -> x, y, index in tileset. + * + * @function Phaser.Tilemaps.Parsers.Tiled.BuildTilesetIndex + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.MapData} mapData - [description] + * + * @return {array} [description] + */ +var BuildTilesetIndex = function (mapData) +{ + var tiles = []; + + for (var i = 0; i < mapData.tilesets.length; i++) + { + var set = mapData.tilesets[i]; + + var x = set.tileMargin; + var y = set.tileMargin; + + var count = 0; + var countX = 0; + var countY = 0; + + for (var t = set.firstgid; t < set.firstgid + set.total; t++) + { + // Can add extra properties here as needed + tiles[t] = [ x, y, i ]; + + x += set.tileWidth + set.tileSpacing; + + count++; + + if (count === set.total) + { + break; + } + + countX++; + + if (countX === set.columns) + { + x = set.tileMargin; + y += set.tileHeight + set.tileSpacing; + + countX = 0; + countY++; + + if (countY === set.rows) + { + break; + } + } + } + } + + return tiles; +}; + +module.exports = BuildTilesetIndex; + + +/***/ }), +/* 419 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(2); +var ParseObject = __webpack_require__(189); +var ObjectLayer = __webpack_require__(188); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseObjectLayers + * @since 3.0.0 + * + * @param {object} json - [description] + * + * @return {array} [description] + */ +var ParseObjectLayers = function (json) +{ + var objectLayers = []; + + for (var i = 0; i < json.layers.length; i++) + { + if (json.layers[i].type !== 'objectgroup') + { + continue; + } + + var curo = json.layers[i]; + var offsetX = GetFastValue(curo, 'offsetx', 0); + var offsetY = GetFastValue(curo, 'offsety', 0); + var objects = []; + + for (var j = 0; j < curo.objects.length; j++) + { + var parsedObject = ParseObject(curo.objects[j], offsetX, offsetY); + + objects.push(parsedObject); + } + + var objectLayer = new ObjectLayer(curo); + objectLayer.objects = objects; + + objectLayers.push(objectLayer); + } + + return objectLayers; +}; + +module.exports = ParseObjectLayers; + + +/***/ }), +/* 420 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var HasValue = __webpack_require__(70); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.Pick + * @since 3.0.0 + * + * @param {object} object - [description] + * @param {array} keys - [description] + * + * @return {object} [description] + */ +var Pick = function (object, keys) +{ + var obj = {}; + + for (var i = 0; i < keys.length; i++) + { + var key = keys[i]; + + if (HasValue(object, key)) + { + obj[key] = object[key]; + } + } + + return obj; +}; + +module.exports = Pick; + + +/***/ }), +/* 421 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Tileset = __webpack_require__(84); +var ImageCollection = __webpack_require__(190); +var ParseObject = __webpack_require__(189); + +/** + * Tilesets & Image Collections + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseTilesets + * @since 3.0.0 + * + * @param {object} json - [description] + * + * @return {object} [description] + */ +var ParseTilesets = function (json) +{ + var tilesets = []; + var imageCollections = []; + var lastSet = null; + var stringID; + + for (var i = 0; i < json.tilesets.length; i++) + { + // name, firstgid, width, height, margin, spacing, properties + var set = json.tilesets[i]; + + if (set.source) + { + console.warn('Phaser can\'t load external tilesets. Use the Embed Tileset button and then export the map again.'); + } + else if (set.image) + { + var newSet = new Tileset(set.name, set.firstgid, set.tilewidth, set.tileheight, set.margin, set.spacing); + + // Properties stored per-tile in object with string indexes starting at "0" + if (set.tileproperties) + { + newSet.tileProperties = set.tileproperties; + } + + // Object & terrain shapes stored per-tile in object with string indexes starting at "0" + if (set.tiles) + { + newSet.tileData = set.tiles; + + // Parse the objects into Phaser format to match handling of other Tiled objects + for (stringID in newSet.tileData) + { + var objectGroup = newSet.tileData[stringID].objectgroup; + if (objectGroup && objectGroup.objects) + { + var parsedObjects = objectGroup.objects.map( + function (obj) { return ParseObject(obj); } + ); + newSet.tileData[stringID].objectgroup.objects = parsedObjects; + } + } + } + + // For a normal sliced tileset the row/count/size information is computed when updated. + // This is done (again) after the image is set. + newSet.updateTileData(set.imagewidth, set.imageheight); + + tilesets.push(newSet); + } + else + { + var newCollection = new ImageCollection(set.name, set.firstgid, set.tilewidth, + set.tileheight, set.margin, set.spacing, set.properties); + + for (stringID in set.tiles) + { + var image = set.tiles[stringID].image; + var gid = set.firstgid + parseInt(stringID, 10); + newCollection.addImage(gid, image); + } + + imageCollections.push(newCollection); + } + + // We've got a new Tileset, so set the lastgid into the previous one + if (lastSet) + { + lastSet.lastgid = set.firstgid - 1; + } + + lastSet = set; + } + + return { tilesets: tilesets, imageCollections: imageCollections }; +}; + +module.exports = ParseTilesets; + + +/***/ }), +/* 422 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(2); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseImageLayers + * @since 3.0.0 + * + * @param {object} json - [description] + * + * @return {array} [description] + */ +var ParseImageLayers = function (json) +{ + var images = []; + + for (var i = 0; i < json.layers.length; i++) + { + if (json.layers[i].type !== 'imagelayer') + { + continue; + } + + var curi = json.layers[i]; + + images.push({ + name: curi.name, + image: curi.image, + x: GetFastValue(curi, 'offsetx', 0) + curi.x, + y: GetFastValue(curi, 'offsety', 0) + curi.y, + alpha: curi.opacity, + visible: curi.visible, + properties: GetFastValue(curi, 'properties', {}) + }); + } + + return images; +}; + +module.exports = ParseImageLayers; + + +/***/ }), +/* 423 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.Base64Decode + * @since 3.0.0 + * + * @param {object} data - [description] + * + * @return {array} [description] + */ +var Base64Decode = function (data) +{ + var binaryString = window.atob(data); + var len = binaryString.length; + var bytes = new Array(len); + + // Interpret binaryString as an array of bytes representing little-endian encoded uint32 values. + for (var i = 0; i < len; i += 4) + { + bytes[i / 4] = ( + binaryString.charCodeAt(i) | + binaryString.charCodeAt(i + 1) << 8 | + binaryString.charCodeAt(i + 2) << 16 | + binaryString.charCodeAt(i + 3) << 24 + ) >>> 0; + } + + return bytes; +}; + +module.exports = Base64Decode; + + +/***/ }), +/* 424 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Base64Decode = __webpack_require__(423); +var GetFastValue = __webpack_require__(2); +var LayerData = __webpack_require__(66); +var ParseGID = __webpack_require__(191); +var Tile = __webpack_require__(45); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseTileLayers + * @since 3.0.0 + * + * @param {object} json - [description] + * @param {boolean} insertNull - [description] + * + * @return {array} [description] + */ +var ParseTileLayers = function (json, insertNull) +{ + var tileLayers = []; + + for (var i = 0; i < json.layers.length; i++) + { + if (json.layers[i].type !== 'tilelayer') + { + continue; + } + + var curl = json.layers[i]; + + // Base64 decode data if necessary. NOTE: uncompressed base64 only. + if (curl.compression) + { + console.warn( + 'TilemapParser.parseTiledJSON - Layer compression is unsupported, skipping layer \'' + + curl.name + '\'' + ); + continue; + } + else if (curl.encoding && curl.encoding === 'base64') + { + curl.data = Base64Decode(curl.data); + delete curl.encoding; // Allow the same map to be parsed multiple times + } + + var layerData = new LayerData({ + name: curl.name, + x: GetFastValue(curl, 'offsetx', 0) + curl.x, + y: GetFastValue(curl, 'offsety', 0) + curl.y, + width: curl.width, + height: curl.height, + tileWidth: json.tilewidth, + tileHeight: json.tileheight, + alpha: curl.opacity, + visible: curl.visible, + properties: GetFastValue(curl, 'properties', {}) + }); + + var x = 0; + var row = []; + var output = []; + + // Loop through the data field in the JSON. + + // This is an array containing the tile indexes, one after the other. -1 = no tile, + // everything else = the tile index (starting at 1 for Tiled, 0 for CSV) If the map + // contains multiple tilesets then the indexes are relative to that which the set starts + // from. Need to set which tileset in the cache = which tileset in the JSON, if you do this + // manually it means you can use the same map data but a new tileset. + + for (var t = 0, len = curl.data.length; t < len; t++) + { + var gidInfo = ParseGID(curl.data[t]); + + // index, x, y, width, height + if (gidInfo.gid > 0) + { + var tile = new Tile(layerData, gidInfo.gid, x, output.length, json.tilewidth, + json.tileheight); + + // Turning Tiled's FlippedHorizontal, FlippedVertical and FlippedAntiDiagonal + // propeties into flipX, flipY and rotation + tile.rotation = gidInfo.rotation; + tile.flipX = gidInfo.flipped; + + row.push(tile); + } + else + { + var blankTile = insertNull + ? null + : new Tile(layerData, -1, x, output.length, json.tilewidth, json.tileheight); + row.push(blankTile); + } + + x++; + + if (x === curl.width) + { + output.push(row); + x = 0; + row = []; + } + } + + layerData.data = output; + + tileLayers.push(layerData); + } + + return tileLayers; +}; + +module.exports = ParseTileLayers; + + +/***/ }), +/* 425 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Tilemaps.Parsers + */ + +module.exports = { + + Parse: __webpack_require__(194), + Parse2DArray: __webpack_require__(116), + ParseCSV: __webpack_require__(193), + + Impact: __webpack_require__(187), + Tiled: __webpack_require__(192) + +}; + + +/***/ }), +/* 426 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var WorldToTileX = __webpack_require__(38); +var WorldToTileY = __webpack_require__(37); +var Vector2 = __webpack_require__(6); + +/** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @function Phaser.Tilemaps.Components.WorldToTileXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Math.Vector2} [point] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Math.Vector2} The XY location in tile units. + */ +var WorldToTileXY = function (worldX, worldY, snapToFloor, point, camera, layer) +{ + if (point === undefined) { point = new Vector2(0, 0); } + + point.x = WorldToTileX(worldX, snapToFloor, camera, layer); + point.y = WorldToTileY(worldY, snapToFloor, camera, layer); + + return point; +}; + +module.exports = WorldToTileXY; + + +/***/ }), +/* 427 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); + +/** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will recieve a new index. New indexes are drawn from the given + * weightedIndexes array. An example weighted array: + * + * [ + * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 + * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 + * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 + * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 + * ] + * + * The probability of any index being choose is (the index's weight) / (sum of all weights). This + * method only modifies tile indexes and does not change collision information. + * + * @function Phaser.Tilemaps.Components.WeightedRandomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during + * randomization. They should be in the form: { index: 0, weight: 4 } or + * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var WeightedRandomize = function (tileX, tileY, width, height, weightedIndexes, layer) +{ + if (weightedIndexes === undefined) { return; } + + var i; + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + var weightTotal = 0; + for (i = 0; i < weightedIndexes.length; i++) + { + weightTotal += weightedIndexes[i].weight; + } + + if (weightTotal <= 0) { return; } + + for (i = 0; i < tiles.length; i++) + { + var rand = Math.random() * weightTotal; + var sum = 0; + var randomIndex = -1; + for (var j = 0; j < weightedIndexes.length; j++) + { + sum += weightedIndexes[j].weight; + if (rand <= sum) + { + var chosen = weightedIndexes[j].index; + randomIndex = Array.isArray(chosen) + ? chosen[Math.floor(Math.random() * chosen.length)] + : chosen; + break; + } + } + + tiles[i].index = randomIndex; + } +}; + +module.exports = WeightedRandomize; + + +/***/ }), +/* 428 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TileToWorldX = __webpack_require__(86); +var TileToWorldY = __webpack_require__(85); +var Vector2 = __webpack_require__(6); + +/** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @function Phaser.Tilemaps.Components.TileToWorldXY + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {Phaser.Math.Vector2} [point] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Math.Vector2} The XY location in world coordinates. + */ +var TileToWorldXY = function (tileX, tileY, point, camera, layer) +{ + if (point === undefined) { point = new Vector2(0, 0); } + + point.x = TileToWorldX(tileX, camera, layer); + point.y = TileToWorldY(tileY, camera, layer); + + return point; +}; + +module.exports = TileToWorldXY; + + +/***/ }), +/* 429 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); + +/** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision + * information. + * + * @function Phaser.Tilemaps.Components.SwapByIndex + * @since 3.0.0 + * + * @param {integer} tileA - First tile index. + * @param {integer} tileB - Second tile index. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SwapByIndex = function (indexA, indexB, tileX, tileY, width, height, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + for (var i = 0; i < tiles.length; i++) + { + if (tiles[i]) + { + if (tiles[i].index === indexA) + { + tiles[i].index = indexB; + } + else if (tiles[i].index === indexB) + { + tiles[i].index = indexA; + } + } + } +}; + +module.exports = SwapByIndex; + + +/***/ }), +/* 430 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); +var ShuffleArray = __webpack_require__(102); + +/** + * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given + * layer. It will only randomize the tiles in that area, so if they're all the same nothing will + * appear to have changed! This method only modifies tile indexes and does not change collision + * information. + * + * @function Phaser.Tilemaps.Components.Shuffle + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var Shuffle = function (tileX, tileY, width, height, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + var indexes = tiles.map(function (tile) { return tile.index; }); + ShuffleArray(indexes); + + for (var i = 0; i < tiles.length; i++) + { + tiles[i].index = indexes[i]; + } +}; + +module.exports = Shuffle; + + +/***/ }), +/* 431 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); + +/** + * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * + * @function Phaser.Tilemaps.Components.SetTileLocationCallback + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetTileLocationCallback = function (tileX, tileY, width, height, callback, callbackContext, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + for (var i = 0; i < tiles.length; i++) + { + tiles[i].setCollisionCallback(callback, callbackContext); + } + +}; + +module.exports = SetTileLocationCallback; + + +/***/ }), +/* 432 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see setTileLocationCallback. + * + * @function Phaser.Tilemaps.Components.SetTileIndexCallback + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a + * collision callback set for. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetTileIndexCallback = function (indexes, callback, callbackContext, layer) +{ + if (typeof indexes === 'number') + { + layer.callbacks[indexes] = (callback !== null) + ? { callback: callback, callbackContext: callbackContext } + : undefined; + } + else + { + for (var i = 0, len = indexes.length; i < len; i++) + { + layer.callbacks[indexes[i]] = (callback !== null) + ? { callback: callback, callbackContext: callbackContext } + : undefined; + } + } +}; + +module.exports = SetTileIndexCallback; + + +/***/ }), +/* 433 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(46); +var CalculateFacesWithin = __webpack_require__(26); + +/** + * Sets collision on the tiles within a layer by checking each tile's collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tile's collision group, the tile's colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * + * @function Phaser.Tilemaps.Components.SetCollisionFromCollisionGroup + * @since 3.0.0 + * + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollisionFromCollisionGroup = function (collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + + if (!tile) { continue; } + + var collisionGroup = tile.getCollisionGroup(); + + // It's possible in Tiled to have a collision group without any shapes, e.g. create a + // shape and then delete the shape. + if (collisionGroup && collisionGroup.objects && collisionGroup.objects.length > 0) + { + SetTileCollision(tile, collides); + } + } + } + + if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } +}; + +module.exports = SetCollisionFromCollisionGroup; + + +/***/ }), +/* 434 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(46); +var CalculateFacesWithin = __webpack_require__(26); +var HasValue = __webpack_require__(70); + +/** + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. + * + * @function Phaser.Tilemaps.Components.SetCollisionByProperty + * @since 3.0.0 + * + * @param {object} properties - An object with tile properties and corresponding values that should + * be checked. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollisionByProperty = function (properties, collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + + if (!tile) { continue; } + + for (var property in properties) + { + if (!HasValue(tile.properties, property)) { continue; } + + var values = properties[property]; + if (!Array.isArray(values)) + { + values = [ values ]; + } + + for (var i = 0; i < values.length; i++) + { + if (tile.properties[property] === values[i]) + { + SetTileCollision(tile, collides); + } + } + } + } + } + + if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } +}; + +module.exports = SetCollisionByProperty; + + +/***/ }), +/* 435 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(46); +var CalculateFacesWithin = __webpack_require__(26); +var SetLayerCollisionIndex = __webpack_require__(117); + +/** + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). + * + * @function Phaser.Tilemaps.Components.SetCollisionByExclusion + * @since 3.0.0 + * + * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollisionByExclusion = function (indexes, collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + if (!Array.isArray(indexes)) { indexes = [ indexes ]; } + + // Note: this only updates layer.collideIndexes for tile indexes found currently in the layer + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + if (tile && indexes.indexOf(tile.index) === -1) + { + SetTileCollision(tile, collides); + SetLayerCollisionIndex(tile.index, collides, layer); + } + } + } + + if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } +}; + +module.exports = SetCollisionByExclusion; + + +/***/ }), +/* 436 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(46); +var CalculateFacesWithin = __webpack_require__(26); +var SetLayerCollisionIndex = __webpack_require__(117); + +/** + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * + * @function Phaser.Tilemaps.Components.SetCollisionBetween + * @since 3.0.0 + * + * @param {integer} start - The first index of the tile to be set for collision. + * @param {integer} stop - The last index of the tile to be set for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollisionBetween = function (start, stop, collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + if (start > stop) { return; } + + // Update the array of colliding indexes + for (var index = start; index <= stop; index++) + { + SetLayerCollisionIndex(index, collides, layer); + } + + // Update the tiles + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + if (tile) + { + if (tile.index >= start && tile.index <= stop) + { + SetTileCollision(tile, collides); + } + } + } + } + + if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } +}; + +module.exports = SetCollisionBetween; + + +/***/ }), +/* 437 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(46); +var CalculateFacesWithin = __webpack_require__(26); +var SetLayerCollisionIndex = __webpack_require__(117); + +/** + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * + * @function Phaser.Tilemaps.Components.SetCollision + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollision = function (indexes, collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + if (!Array.isArray(indexes)) { indexes = [ indexes ]; } + + // Update the array of colliding indexes + for (var i = 0; i < indexes.length; i++) + { + SetLayerCollisionIndex(indexes[i], collides, layer); + } + + // Update the tiles + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + + if (tile && indexes.indexOf(tile.index) !== -1) + { + SetTileCollision(tile, collides); + } + } + } + + if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } +}; + +module.exports = SetCollision; + + +/***/ }), +/* 438 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); +var Color = __webpack_require__(312); + +/** + * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * + * @function Phaser.Tilemaps.Components.RenderDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. + * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. + * @param {?Phaser.Display.Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at + * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. + * @param {?Phaser.Display.Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled + * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. + * @param {?Phaser.Display.Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting + * tile faces. If set to null, interesting tile faces will not be drawn. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var RenderDebug = function (graphics, styleConfig, layer) +{ + if (styleConfig === undefined) { styleConfig = {}; } + + // Default colors without needlessly creating Color objects + var tileColor = styleConfig.tileColor !== undefined + ? styleConfig.tileColor + : new Color(105, 210, 231, 150); + var collidingTileColor = styleConfig.collidingTileColor !== undefined + ? styleConfig.collidingTileColor + : new Color(243, 134, 48, 200); + var faceColor = styleConfig.faceColor !== undefined + ? styleConfig.faceColor + : new Color(40, 39, 37, 150); + + var tiles = GetTilesWithin(0, 0, layer.width, layer.height, null, layer); + + for (var i = 0; i < tiles.length; i++) + { + var tile = tiles[i]; + + var tw = tile.width; + var th = tile.height; + var x = tile.pixelX; + var y = tile.pixelY; + + var color = tile.collides ? collidingTileColor : tileColor; + if (color !== null) + { + graphics.fillStyle(color.color, color.alpha / 255); + graphics.fillRect(x, y, tw, th); + } + + // Inset the face line to prevent neighboring tile's lines from overlapping + x += 1; + y += 1; + tw -= 2; + th -= 2; + + if (faceColor !== null) + { + graphics.lineStyle(1, faceColor.color, faceColor.alpha / 255); + if (tile.faceTop) { graphics.lineBetween(x, y, x + tw, y); } + if (tile.faceRight) { graphics.lineBetween(x + tw, y, x + tw, y + th); } + if (tile.faceBottom) { graphics.lineBetween(x, y + th, x + tw, y + th); } + if (tile.faceLeft) { graphics.lineBetween(x, y, x, y + th); } + } + } +}; + +module.exports = RenderDebug; + + +/***/ }), +/* 439 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RemoveTileAt = __webpack_require__(195); +var WorldToTileX = __webpack_require__(38); +var WorldToTileY = __webpack_require__(37); + +/** + * Removes the tile at the given world coordinates in the specified layer and updates the layer's + * collision information. + * + * @function Phaser.Tilemaps.Components.RemoveTileAtWorldXY + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified + * location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The Tile object that was removed. + */ +var RemoveTileAtWorldXY = function (worldX, worldY, replaceWithNull, recalculateFaces, camera, layer) +{ + var tileX = WorldToTileX(worldX, true, camera, layer); + var tileY = WorldToTileY(worldY, true, camera, layer); + return RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, layer); +}; + +module.exports = RemoveTileAtWorldXY; + + +/***/ }), +/* 440 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); +var GetRandomElement = __webpack_require__(132); + +/** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then + * those will be used for randomly assigning new tile indexes. If an array is not provided, the + * indexes found within the region (excluding -1) will be used for randomly assigning new tile + * indexes. This method only modifies tile indexes and does not change collision information. + * + * @function Phaser.Tilemaps.Components.Randomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var Randomize = function (tileX, tileY, width, height, indexes, layer) +{ + var i; + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + // If no indicies are given, then find all the unique indexes within the specified region + if (indexes === undefined) + { + indexes = []; + for (i = 0; i < tiles.length; i++) + { + if (indexes.indexOf(tiles[i].index) === -1) + { + indexes.push(tiles[i].index); + } + } + } + + for (i = 0; i < tiles.length; i++) + { + tiles[i].index = GetRandomElement(indexes); + } +}; + +module.exports = Randomize; + + +/***/ }), +/* 441 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CalculateFacesWithin = __webpack_require__(26); +var PutTileAt = __webpack_require__(118); + +/** + * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified + * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, + * all attributes will be copied over to the specified location. If you pass in an index, only the + * index at the specified location will be changed. Collision information will be recalculated + * within the region tiles were changed. + * + * @function Phaser.Tilemaps.Components.PutTilesAt + * @since 3.0.0 + * + * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles + * or tile indexes to place. + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var PutTilesAt = function (tilesArray, tileX, tileY, recalculateFaces, layer) +{ + if (!Array.isArray(tilesArray)) { return null; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + // Force the input array to be a 2D array + if (!Array.isArray(tilesArray[0])) + { + tilesArray = [ tilesArray ]; + } + + var height = tilesArray.length; + var width = tilesArray[0].length; + + for (var ty = 0; ty < height; ty++) + { + for (var tx = 0; tx < width; tx++) + { + var tile = tilesArray[ty][tx]; + PutTileAt(tile, tileX + tx, tileY + ty, false, layer); + } + } + + if (recalculateFaces) + { + // Recalculate the faces within the destination area and neighboring tiles + CalculateFacesWithin(tileX - 1, tileY - 1, width + 2, height + 2, layer); + } +}; + +module.exports = PutTilesAt; + + + +/***/ }), +/* 442 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PutTileAt = __webpack_require__(118); +var WorldToTileX = __webpack_require__(38); +var WorldToTileY = __webpack_require__(37); + +/** + * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either + * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the + * specified location. If you pass in an index, only the index at the specified location will be + * changed. Collision information will be recalculated at the specified location. + * + * @function Phaser.Tilemaps.Components.PutTileAtWorldXY + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} worldX - [description] + * @param {integer} worldY - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map. + */ +var PutTileAtWorldXY = function (tile, worldX, worldY, recalculateFaces, camera, layer) +{ + var tileX = WorldToTileX(worldX, true, camera, layer); + var tileY = WorldToTileY(worldY, true, camera, layer); + return PutTileAt(tile, tileX, tileY, recalculateFaces, layer); +}; + +module.exports = PutTileAtWorldXY; + + +/***/ }), +/* 443 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var HasTileAt = __webpack_require__(196); +var WorldToTileX = __webpack_require__(38); +var WorldToTileY = __webpack_require__(37); + +/** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @function Phaser.Tilemaps.Components.HasTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {boolean} + */ +var HasTileAtWorldXY = function (worldX, worldY, camera, layer) +{ + var tileX = WorldToTileX(worldX, true, camera, layer); + var tileY = WorldToTileY(worldY, true, camera, layer); + + return HasTileAt(tileX, tileY, layer); +}; + +module.exports = HasTileAtWorldXY; + + +/***/ }), +/* 444 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); +var WorldToTileX = __webpack_require__(38); +var WorldToTileY = __webpack_require__(37); + +/** + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * + * @function Phaser.Tilemaps.Components.GetTilesWithinWorldXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. + */ +var GetTilesWithinWorldXY = function (worldX, worldY, width, height, filteringOptions, camera, layer) +{ + // Top left corner of the rect, rounded down to include partial tiles + var xStart = WorldToTileX(worldX, true, camera, layer); + var yStart = WorldToTileY(worldY, true, camera, layer); + + // Bottom right corner of the rect, rounded up to include partial tiles + var xEnd = Math.ceil(WorldToTileX(worldX + width, false, camera, layer)); + var yEnd = Math.ceil(WorldToTileY(worldY + height, false, camera, layer)); + + return GetTilesWithin(xStart, yStart, xEnd - xStart, yEnd - yStart, filteringOptions, layer); +}; + +module.exports = GetTilesWithinWorldXY; + + +/***/ }), +/* 445 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Geom = __webpack_require__(245); +var GetTilesWithin = __webpack_require__(14); +var Intersects = __webpack_require__(244); +var NOOP = __webpack_require__(3); +var TileToWorldX = __webpack_require__(86); +var TileToWorldY = __webpack_require__(85); +var WorldToTileX = __webpack_require__(38); +var WorldToTileY = __webpack_require__(37); + +var TriangleToRectangle = function (triangle, rect) +{ + return Intersects.RectangleToTriangle(rect, triangle); +}; + +// Note: Could possibly be optimized by copying the shape and shifting it into tilemapLayer +// coordinates instead of shifting the tiles. + +/** + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * + * @function Phaser.Tilemaps.Components.GetTilesWithinShape + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. + */ +var GetTilesWithinShape = function (shape, filteringOptions, camera, layer) +{ + if (shape === undefined) { return []; } + + // intersectTest is a function with parameters: shape, rect + var intersectTest = NOOP; + if (shape instanceof Geom.Circle) { intersectTest = Intersects.CircleToRectangle; } + else if (shape instanceof Geom.Rectangle) { intersectTest = Intersects.RectangleToRectangle; } + else if (shape instanceof Geom.Triangle) { intersectTest = TriangleToRectangle; } + else if (shape instanceof Geom.Line) { intersectTest = Intersects.LineToRectangle; } + + // Top left corner of the shapes's bounding box, rounded down to include partial tiles + var xStart = WorldToTileX(shape.left, true, camera, layer); + var yStart = WorldToTileY(shape.top, true, camera, layer); + + // Bottom right corner of the shapes's bounding box, rounded up to include partial tiles + var xEnd = Math.ceil(WorldToTileX(shape.right, false, camera, layer)); + var yEnd = Math.ceil(WorldToTileY(shape.bottom, false, camera, layer)); + + // Tiles within bounding rectangle of shape. Bounds are forced to be at least 1 x 1 tile in size + // to grab tiles for shapes that don't have a height or width (e.g. a horizontal line). + var width = Math.max(xEnd - xStart, 1); + var height = Math.max(yEnd - yStart, 1); + var tiles = GetTilesWithin(xStart, yStart, width, height, filteringOptions, layer); + + var tileWidth = layer.tileWidth; + var tileHeight = layer.tileHeight; + if (layer.tilemapLayer) + { + tileWidth *= layer.tilemapLayer.scaleX; + tileHeight *= layer.tilemapLayer.scaleY; + } + + var results = []; + var tileRect = new Geom.Rectangle(0, 0, tileWidth, tileHeight); + for (var i = 0; i < tiles.length; i++) + { + var tile = tiles[i]; + tileRect.x = TileToWorldX(tile.x, camera, layer); + tileRect.y = TileToWorldY(tile.y, camera, layer); + if (intersectTest(shape, tileRect)) + { + results.push(tile); + } + } + + return results; +}; + +module.exports = GetTilesWithinShape; + + +/***/ }), +/* 446 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTileAt = __webpack_require__(87); +var WorldToTileX = __webpack_require__(38); +var WorldToTileY = __webpack_require__(37); + +/** + * Gets a tile at the given world coordinates from the given layer. + * + * @function Phaser.Tilemaps.Components.GetTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - X position to get the tile from (given in pixels) + * @param {number} worldY - Y position to get the tile from (given in pixels) + * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile + * object with an index of -1. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates + * were invalid. + */ +var GetTileAtWorldXY = function (worldX, worldY, nonNull, camera, layer) +{ + var tileX = WorldToTileX(worldX, true, camera, layer); + var tileY = WorldToTileY(worldY, true, camera, layer); + + return GetTileAt(tileX, tileY, nonNull, layer); +}; + +module.exports = GetTileAtWorldXY; + + +/***/ }), +/* 447 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); + +/** + * @callback EachTileCallback + * + * @param {Phaser.Tilemaps.Tile} value - [description] + * @param {number} index - [description] + * @param {Phaser.Tilemaps.Tile[]} array - [description] + */ + +/** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * + * @function Phaser.Tilemaps.Components.ForEachTile + * @since 3.0.0 + * + * @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var ForEachTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); + tiles.forEach(callback, context); +}; + +module.exports = ForEachTile; + + +/***/ }), +/* 448 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); + +/** + * @callback FindTileCallback + * + * @param {Phaser.Tilemaps.Tile} value - [description] + * @param {number} index - [description] + * @param {Phaser.Tilemaps.Tile[]} array - [description] + * + * @return {boolean} [description] + */ + +/** + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * + * @function Phaser.Tilemaps.Components.FindTile + * @since 3.0.0 + * + * @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {?Phaser.Tilemaps.Tile} A Tile that matches the search, or null if no Tile found + */ +var FindTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); + return tiles.find(callback, context) || null; +}; + +module.exports = FindTile; + + +/***/ }), +/* 449 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * + * @function Phaser.Tilemaps.Components.FindByIndex + * @since 3.0.0 + * + * @param {integer} index - The tile index value to search for. + * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. + * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the + * bottom-right. Otherwise it scans from the top-left. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {?Phaser.Tilemaps.Tile} The first (or n skipped) tile with the matching index. + */ +var FindByIndex = function (findIndex, skip, reverse, layer) +{ + if (skip === undefined) { skip = 0; } + if (reverse === undefined) { reverse = false; } + + var count = 0; + var tx; + var ty; + var tile; + + if (reverse) + { + for (ty = layer.height - 1; ty >= 0; ty--) + { + for (tx = layer.width - 1; tx >= 0; tx--) + { + tile = layer.data[ty][tx]; + if (tile && tile.index === findIndex) + { + if (count === skip) + { + return tile; + } + else + { + count += 1; + } + } + } + } + } + else + { + for (ty = 0; ty < layer.height; ty++) + { + for (tx = 0; tx < layer.width; tx++) + { + tile = layer.data[ty][tx]; + if (tile && tile.index === findIndex) + { + if (count === skip) + { + return tile; + } + else + { + count += 1; + } + } + } + } + } + + return null; +}; + +module.exports = FindByIndex; + + +/***/ }), +/* 450 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); + +/** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * + * @function Phaser.Tilemaps.Components.FilterTiles + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile[]} The filtered array of Tiles. + */ +var FilterTiles = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); + return tiles.filter(callback, context); +}; + +module.exports = FilterTiles; + + + +/***/ }), +/* 451 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); +var CalculateFacesWithin = __webpack_require__(26); +var SetTileCollision = __webpack_require__(46); + +/** + * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the + * specified index. Tiles will be set to collide if the given index is a colliding index. + * Collision information in the region will be recalculated. + * + * @function Phaser.Tilemaps.Components.Fill + * @since 3.0.0 + * + * @param {integer} index - [description] + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var Fill = function (index, tileX, tileY, width, height, recalculateFaces, layer) +{ + if (recalculateFaces === undefined) { recalculateFaces = true; } + + var doesIndexCollide = (layer.collideIndexes.indexOf(index) !== -1); + + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + for (var i = 0; i < tiles.length; i++) + { + tiles[i].index = index; + + SetTileCollision(tiles[i], doesIndexCollide); + } + + if (recalculateFaces) + { + // Recalculate the faces within the area and neighboring tiles + CalculateFacesWithin(tileX - 1, tileY - 1, width + 2, height + 2, layer); + } +}; + +module.exports = Fill; + + +/***/ }), +/* 452 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the tiles in the given layer that are within the camera's viewport. This is used + * internally. + * + * @function Phaser.Tilemaps.Components.CullTiles + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. + * @param {array} [outputArray] - [description] + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ +var CullTiles = function (layer, camera, outputArray) +{ + if (outputArray === undefined) { outputArray = []; } + + outputArray.length = 0; + + var tilemapLayer = layer.tilemapLayer; + var mapData = layer.data; + var mapWidth = layer.width; + var mapHeight = layer.height; + var left = (camera.scrollX * camera.zoom * tilemapLayer.scrollFactorX) - tilemapLayer.x; + var top = (camera.scrollY * camera.zoom * tilemapLayer.scrollFactorY) - tilemapLayer.y; + var sx = tilemapLayer.scaleX; + var sy = tilemapLayer.scaleY; + var tileWidth = layer.tileWidth * sx; + var tileHeight = layer.tileHeight * sy; + + for (var row = 0; row < mapHeight; ++row) + { + for (var col = 0; col < mapWidth; ++col) + { + var tile = mapData[row][col]; + + if (tile === null || tile.index === -1) { continue; } + + var tileX = tile.pixelX * sx - left; + var tileY = tile.pixelY * sy - top; + var cullW = camera.width + tileWidth; + var cullH = camera.height + tileHeight; + + if (tile.visible && + tileX > -tileWidth && tileY > -tileHeight && + tileX < cullW && tileY < cullH) + { + outputArray.push(tile); + } + } + } + + return outputArray; +}; + +module.exports = CullTiles; + + +/***/ }), +/* 453 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TileToWorldX = __webpack_require__(86); +var TileToWorldY = __webpack_require__(85); +var GetTilesWithin = __webpack_require__(14); +var ReplaceByIndex = __webpack_require__(197); + +/** + * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. + * + * @function Phaser.Tilemaps.Components.CreateFromTiles + * @since 3.0.0 + * + * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. + * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted + * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a + * one-to-one mapping with the indexes array. + * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. + * scene.make.sprite). + * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. + */ +var CreateFromTiles = function (indexes, replacements, spriteConfig, scene, camera, layer) +{ + if (spriteConfig === undefined) { spriteConfig = {}; } + + if (!Array.isArray(indexes)) { indexes = [ indexes ]; } + + var tilemapLayer = layer.tilemapLayer; + if (scene === undefined) { scene = tilemapLayer.scene; } + if (camera === undefined) { camera = scene.cameras.main; } + + var tiles = GetTilesWithin(0, 0, layer.width, layer.height, null, layer); + var sprites = []; + var i; + + for (i = 0; i < tiles.length; i++) + { + var tile = tiles[i]; + + if (indexes.indexOf(tile.index) !== -1) + { + spriteConfig.x = TileToWorldX(tile.x, camera, layer); + spriteConfig.y = TileToWorldY(tile.y, camera, layer); + + var sprite = scene.make.sprite(spriteConfig); + sprites.push(sprite); + } + } + + if (typeof replacements === 'number') + { + // Assume 1 replacement for all types of tile given + for (i = 0; i < indexes.length; i++) + { + ReplaceByIndex(indexes[i], replacements, 0, 0, layer.width, layer.height, layer); + } + } + else if (Array.isArray(replacements)) + { + // Assume 1 to 1 mapping with indexes array + for (i = 0; i < indexes.length; i++) + { + ReplaceByIndex(indexes[i], replacements[i], 0, 0, layer.width, layer.height, layer); + } + } + + return sprites; +}; + +module.exports = CreateFromTiles; + + +/***/ }), +/* 454 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); +var CalculateFacesWithin = __webpack_require__(26); + +/** + * Copies the tiles in the source rectangular area to a new destination (all specified in tile + * coordinates) within the layer. This copies all tile properties & recalculates collision + * information in the destination region. + * + * @function Phaser.Tilemaps.Components.Copy + * @since 3.0.0 + * + * @param {integer} srcTileX - [description] + * @param {integer} srcTileY - [description] + * @param {integer} width - [description] + * @param {integer} height - [description] + * @param {integer} destTileX - [description] + * @param {integer} destTileY - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var Copy = function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer) +{ + if (srcTileX < 0) { srcTileX = 0; } + if (srcTileY < 0) { srcTileY = 0; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + var srcTiles = GetTilesWithin(srcTileX, srcTileY, width, height, null, layer); + + var offsetX = destTileX - srcTileX; + var offsetY = destTileY - srcTileY; + + for (var i = 0; i < srcTiles.length; i++) + { + var tileX = srcTiles[i].x + offsetX; + var tileY = srcTiles[i].y + offsetY; + if (tileX >= 0 && tileX < layer.width && tileY >= 0 && tileY < layer.height) + { + if (layer.data[tileY][tileX]) + { + layer.data[tileY][tileX].copy(srcTiles[i]); + } + } + } + + if (recalculateFaces) + { + // Recalculate the faces within the destination area and neighboring tiles + CalculateFacesWithin(destTileX - 1, destTileY - 1, width + 2, height + 2, layer); + } +}; + +module.exports = Copy; + + +/***/ }), +/* 455 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Tilemaps + */ + +module.exports = { + + Components: __webpack_require__(88), + Parsers: __webpack_require__(425), + + Formats: __webpack_require__(24), + ImageCollection: __webpack_require__(190), + ParseToTilemap: __webpack_require__(115), + Tile: __webpack_require__(45), + Tilemap: __webpack_require__(186), + TilemapCreator: __webpack_require__(408), + TilemapFactory: __webpack_require__(407), + Tileset: __webpack_require__(84), + + LayerData: __webpack_require__(66), + MapData: __webpack_require__(65), + ObjectLayer: __webpack_require__(188), + + DynamicTilemapLayer: __webpack_require__(185), + StaticTilemapLayer: __webpack_require__(184) + +}; + + +/***/ }), +/* 456 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = { + + /** + * Linear filter type. + * + * @name Phaser.Textures.LINEAR + * @type {integer} + * @since 3.0.0 + */ + LINEAR: 0, + + /** + * Nearest neighbor filter type. + * + * @name Phaser.Textures.NEAREST + * @type {integer} + * @since 3.0.0 + */ + NEAREST: 1 + +}; + +module.exports = CONST; + + +/***/ }), +/* 457 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(456); +var Extend = __webpack_require__(18); + +/** + * @namespace Phaser.Textures + */ + +var Textures = { + + Parsers: __webpack_require__(275), + + Frame: __webpack_require__(141), + Texture: __webpack_require__(274), + TextureManager: __webpack_require__(276), + TextureSource: __webpack_require__(273) + +}; + +// Merge in the consts +Textures = Extend(false, Textures, CONST); + +module.exports = Textures; + + +/***/ }), +/* 458 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Structs + */ + +module.exports = { + + List: __webpack_require__(97), + Map: __webpack_require__(159), + ProcessQueue: __webpack_require__(205), + RTree: __webpack_require__(204), + Set: __webpack_require__(63) + +}; + + +/***/ }), +/* 459 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Sound + * + * @author Pavle Goloskokovic (http://prunegames.com) + */ + +/** + * Config object containing various sound settings. + * + * @typedef {object} SoundConfig + * + * @property {boolean} [mute=false] - Boolean indicating whether the sound should be muted or not. + * @property {number} [volume=1] - A value between 0 (silence) and 1 (full volume). + * @property {number} [rate=1] - Defines the speed at which the sound should be played. + * @property {number} [detune=0] - Represents detuning of sound in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * @property {number} [seek=0] - Position of playback for this sound, in seconds. + * @property {boolean} [loop=false] - Whether or not the sound or current sound marker should loop. + * @property {number} [delay=0] - Time, in seconds, that should elapse before the sound actually starts its playback. + */ + +/** + * Marked section of a sound represented by name, and optionally start time, duration, and config object. + * + * @typedef {object} SoundMarker + * + * @property {string} name - Unique identifier of a sound marker. + * @property {number} [start=0] - Sound position offset at witch playback should start. + * @property {number} [duration] - Playback duration of this marker. + * @property {SoundConfig} [config] - An optional config object containing default marker settings. + */ + +module.exports = { + + SoundManagerCreator: __webpack_require__(283), + + BaseSound: __webpack_require__(98), + BaseSoundManager: __webpack_require__(99), + + WebAudioSound: __webpack_require__(277), + WebAudioSoundManager: __webpack_require__(278), + + HTML5AudioSound: __webpack_require__(281), + HTML5AudioSoundManager: __webpack_require__(282), + + NoAudioSound: __webpack_require__(279), + NoAudioSoundManager: __webpack_require__(280) + +}; + + +/***/ }), +/* 460 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(75); +var PluginManager = __webpack_require__(12); + +/** + * @classdesc + * A proxy class to the Global Scene Manager. + * + * @class ScenePlugin + * @memberOf Phaser.Scenes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ +var ScenePlugin = new Class({ + + initialize: + + function ScenePlugin (scene) + { + /** + * [description] + * + * @name Phaser.Scenes.ScenePlugin#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Scenes.ScenePlugin#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + if (!scene.sys.settings.isBooted) + { + scene.sys.events.once('boot', this.boot, this); + } + + /** + * [description] + * + * @name Phaser.Scenes.ScenePlugin#settings + * @type {SettingsObject} + * @since 3.0.0 + */ + this.settings = scene.sys.settings; + + /** + * [description] + * + * @name Phaser.Scenes.ScenePlugin#key + * @type {string} + * @since 3.0.0 + */ + this.key = scene.sys.settings.key; + + /** + * [description] + * + * @name Phaser.Scenes.ScenePlugin#manager + * @type {Phaser.Scenes.SceneManager} + * @since 3.0.0 + */ + this.manager = scene.sys.game.scene; + }, + + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#boot + * @since 3.0.0 + */ + boot: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); + }, + + /** + * Shutdown this Scene and run the given one. + * + * @method Phaser.Scenes.ScenePlugin#start + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {object} [data] - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + start: function (key, data) + { + if (key === undefined) { key = this.key; } + + if (this.settings.status !== CONST.RUNNING) + { + this.manager.queueOp('stop', this.key); + this.manager.queueOp('start', key, data); + } + else + { + this.manager.stop(this.key); + this.manager.start(key, data); + } + + return this; + }, + + /** + * Add the Scene into the Scene Manager and start it if 'autoStart' is true or the Scene config 'active' property is set. + * + * @method Phaser.Scenes.ScenePlugin#add + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {object} sceneConfig - [description] + * @param {boolean} autoStart - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + add: function (key, sceneConfig, autoStart) + { + this.manager.add(key, sceneConfig, autoStart); + + return this; + }, + + /** + * Launch the given Scene and run it in parallel with this one. + * + * @method Phaser.Scenes.ScenePlugin#launch + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {object} [data] - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + launch: function (key, data) + { + if (key && key !== this.key) + { + if (this.settings.status !== CONST.RUNNING) + { + this.manager.queueOp('start', key, data); + } + else + { + this.manager.start(key, data); + } + } + + return this; + }, + + /** + * Pause the Scene - this stops the update step from happening but it still renders. + * + * @method Phaser.Scenes.ScenePlugin#pause + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + pause: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.pause(key); + + return this; + }, + + /** + * Resume the Scene - starts the update loop again. + * + * @method Phaser.Scenes.ScenePlugin#resume + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + resume: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.resume(key); + + return this; + }, + + /** + * Makes the Scene sleep (no update, no render) but doesn't shutdown. + * + * @method Phaser.Scenes.ScenePlugin#sleep + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + sleep: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.sleep(key); + + return this; + }, + + /** + * Makes the Scene wake-up (starts update and render) + * + * @method Phaser.Scenes.ScenePlugin#wake + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + wake: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.wake(key); + + return this; + }, + + /** + * Makes this Scene sleep then starts the Scene given. + * + * @method Phaser.Scenes.ScenePlugin#switch + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + switch: function (key) + { + if (key !== this.key) + { + if (this.settings.status !== CONST.RUNNING) + { + this.manager.queueOp('switch', this.key, key); + } + else + { + this.manager.switch(this.key, key); + } + } + + return this; + }, + + /** + * Shutdown the Scene, clearing display list, timers, etc. + * + * @method Phaser.Scenes.ScenePlugin#stop + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + stop: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.stop(key); + + return this; + }, + + /** + * Sets the active state of the given Scene. + * + * @method Phaser.Scenes.ScenePlugin#setActive + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + setActive: function (value) + { + this.settings.active = value; + + return this; + }, + + /** + * Sets the visible state of the given Scene. + * + * @method Phaser.Scenes.ScenePlugin#setVisible + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + setVisible: function (value) + { + this.settings.visible = value; + + return this; + }, + + /** + * Checks if the given Scene is sleeping or not? + * + * @method Phaser.Scenes.ScenePlugin#isSleeping + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {boolean} [description] + */ + isSleeping: function (key) + { + if (key === undefined) { key = this.key; } + + return this.manager.isSleeping(key); + }, + + /** + * Checks if the given Scene is active or not? + * + * @method Phaser.Scenes.ScenePlugin#isActive + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {boolean} [description] + */ + isActive: function (key) + { + if (key === undefined) { key = this.key; } + + return this.manager.isActive(key); + }, + + /** + * Checks if the given Scene is visible or not? + * + * @method Phaser.Scenes.ScenePlugin#isVisible + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {boolean} [description] + */ + isVisible: function (key) + { + if (key === undefined) { key = this.key; } + + return this.manager.isVisible(key); + }, + + /** + * Swaps the position of two scenes in the Scenes list. + * This controls the order in which they are rendered and updated. + * + * @method Phaser.Scenes.ScenePlugin#swapPosition + * @since 3.2.0 + * + * @param {string} keyA - The first Scene to swap. + * @param {string} [keyB] - The second Scene to swap. If none is given it defaults to this Scene. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + swapPosition: function (keyA, keyB) + { + if (keyB === undefined) { keyB = this.key; } + + if (keyA !== keyB) + { + this.manager.swapPosition(keyA, keyB); + } + + return this; + }, + + /** + * Swaps the position of two scenes in the Scenes list, so that Scene B is directly above Scene A. + * This controls the order in which they are rendered and updated. + * + * @method Phaser.Scenes.ScenePlugin#moveAbove + * @since 3.2.0 + * + * @param {string} keyA - The Scene that Scene B will be moved to be above. + * @param {string} [keyB] - The Scene to be moved. If none is given it defaults to this Scene. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + moveAbove: function (keyA, keyB) + { + if (keyB === undefined) { keyB = this.key; } + + if (keyA !== keyB) + { + this.manager.moveAbove(keyA, keyB); + } + + return this; + }, + + /** + * Swaps the position of two scenes in the Scenes list, so that Scene B is directly below Scene A. + * This controls the order in which they are rendered and updated. + * + * @method Phaser.Scenes.ScenePlugin#moveBelow + * @since 3.2.0 + * + * @param {string} keyA - The Scene that Scene B will be moved to be below. + * @param {string} [keyB] - The Scene to be moved. If none is given it defaults to this Scene. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + moveBelow: function (keyA, keyB) + { + if (keyB === undefined) { keyB = this.key; } + + if (keyA !== keyB) + { + this.manager.moveBelow(keyA, keyB); + } + + return this; + }, + + /** + * Removes a Scene from the SceneManager. + * + * The Scene is removed from the local scenes array, it's key is cleared from the keys + * cache and Scene.Systems.destroy is then called on it. + * + * If the SceneManager is processing the Scenes when this method is called it wil + * queue the operation for the next update sequence. + * + * @method Phaser.Scenes.ScenePlugin#remove + * @since 3.2.0 + * + * @param {(string|Phaser.Scene)} scene - The Scene to be removed. + * + * @return {Phaser.Scenes.SceneManager} This SceneManager. + */ + remove: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.remove(key); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#moveUp + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + moveUp: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.moveUp(key); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#moveDown + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + moveDown: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.moveDown(key); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#bringToTop + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + bringToTop: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.bringToTop(key); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#sendToBack + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + sendToBack: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.sendToBack(key); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#get + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scene} [description] + */ + get: function (key) + { + return this.manager.getScene(key); + }, + + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + // TODO + }, + + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#destroy + * @since 3.0.0 + */ + destroy: function () + { + // TODO + } + +}); + +PluginManager.register('ScenePlugin', ScenePlugin, 'scenePlugin'); + +module.exports = ScenePlugin; + + +/***/ }), +/* 461 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(75); +var Extend = __webpack_require__(18); + +/** + * @namespace Phaser.Scenes + */ + +var Scene = { + + SceneManager: __webpack_require__(287), + ScenePlugin: __webpack_require__(460), + Settings: __webpack_require__(284), + Systems: __webpack_require__(142) + +}; + +// Merge in the consts +Scene = Extend(false, Scene, CONST); + +module.exports = Scene; + + +/***/ }), +/* 462 */, +/* 463 */, +/* 464 */, +/* 465 */, +/* 466 */, +/* 467 */, +/* 468 */, +/* 469 */, +/* 470 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetOverlapY = __webpack_require__(206); + +/** + * [description] + * + * @function Phaser.Physics.Arcade.SeparateY + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {boolean} overlapOnly - [description] + * @param {number} bias - [description] + * + * @return {boolean} [description] + */ +var SeparateY = function (body1, body2, overlapOnly, bias) +{ + var overlap = GetOverlapY(body1, body2, overlapOnly, bias); + + // Can't separate two immovable bodies, or a body with its own custom separation logic + if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateY || body2.customSeparateY) + { + // return true if there was some overlap, otherwise false + return (overlap !== 0) || (body1.embedded && body2.embedded); + } + + // Adjust their positions and velocities accordingly (if there was any overlap) + var v1 = body1.velocity.y; + var v2 = body2.velocity.y; + + if (!body1.immovable && !body2.immovable) + { + overlap *= 0.5; + + body1.y -= overlap; + body2.y += overlap; + + var nv1 = Math.sqrt((v2 * v2 * body2.mass) / body1.mass) * ((v2 > 0) ? 1 : -1); + var nv2 = Math.sqrt((v1 * v1 * body1.mass) / body2.mass) * ((v1 > 0) ? 1 : -1); + var avg = (nv1 + nv2) * 0.5; + + nv1 -= avg; + nv2 -= avg; + + body1.velocity.y = avg + nv1 * body1.bounce.y; + body2.velocity.y = avg + nv2 * body2.bounce.y; + } + else if (!body1.immovable) + { + body1.y -= overlap; + body1.velocity.y = v2 - v1 * body1.bounce.y; + + // This is special case code that handles things like horizontal moving platforms you can ride + if (body2.moves) + { + body1.x += (body2.x - body2.prev.x) * body2.friction.x; + } + } + else + { + body2.y += overlap; + body2.velocity.y = v1 - v2 * body2.bounce.y; + + // This is special case code that handles things like horizontal moving platforms you can ride + if (body1.moves) + { + body2.x += (body1.x - body1.prev.x) * body1.friction.x; + } + } + + // If we got this far then there WAS overlap, and separation is complete, so return true + return true; +}; + +module.exports = SeparateY; + + +/***/ }), +/* 471 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetOverlapX = __webpack_require__(207); + +/** + * [description] + * + * @function Phaser.Physics.Arcade.SeparateX + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {boolean} overlapOnly - [description] + * @param {number} bias - [description] + * + * @return {boolean} [description] + */ +var SeparateX = function (body1, body2, overlapOnly, bias) +{ + var overlap = GetOverlapX(body1, body2, overlapOnly, bias); + + // Can't separate two immovable bodies, or a body with its own custom separation logic + if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateX || body2.customSeparateX) + { + // return true if there was some overlap, otherwise false + return (overlap !== 0) || (body1.embedded && body2.embedded); + } + + // Adjust their positions and velocities accordingly (if there was any overlap) + var v1 = body1.velocity.x; + var v2 = body2.velocity.x; + + if (!body1.immovable && !body2.immovable) + { + overlap *= 0.5; + + body1.x -= overlap; + body2.x += overlap; + + var nv1 = Math.sqrt((v2 * v2 * body2.mass) / body1.mass) * ((v2 > 0) ? 1 : -1); + var nv2 = Math.sqrt((v1 * v1 * body1.mass) / body2.mass) * ((v1 > 0) ? 1 : -1); + var avg = (nv1 + nv2) * 0.5; + + nv1 -= avg; + nv2 -= avg; + + body1.velocity.x = avg + nv1 * body1.bounce.x; + body2.velocity.x = avg + nv2 * body2.bounce.x; + } + else if (!body1.immovable) + { + body1.x -= overlap; + body1.velocity.x = v2 - v1 * body1.bounce.x; + + // This is special case code that handles things like vertically moving platforms you can ride + if (body2.moves) + { + body1.y += (body2.y - body2.prev.y) * body2.friction.y; + } + } + else + { + body2.x += overlap; + body2.velocity.x = v1 - v2 * body2.bounce.x; + + // This is special case code that handles things like vertically moving platforms you can ride + if (body1.moves) + { + body2.y += (body1.y - body1.prev.y) * body1.friction.y; + } + } + + // If we got this far then there WAS overlap, and separation is complete, so return true + return true; +}; + +module.exports = SeparateX; + + +/***/ }), +/* 472 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Internal function to process the separation of a physics body from a tile. + * + * @function Phaser.Physics.Arcade.Tilemap.ProcessTileSeparationY + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {number} y - The y separation amount. + */ +var ProcessTileSeparationY = function (body, y) +{ + if (y < 0) + { + body.blocked.up = true; + } + else if (y > 0) + { + body.blocked.down = true; + } + + body.position.y -= y; + + if (body.bounce.y === 0) + { + body.velocity.y = 0; + } + else + { + body.velocity.y = -body.velocity.y * body.bounce.y; + } +}; + +module.exports = ProcessTileSeparationY; + + +/***/ }), +/* 473 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ProcessTileSeparationY = __webpack_require__(472); + +/** + * Check the body against the given tile on the Y axis. + * + * @function Phaser.Physics.Arcade.Tilemap.TileCheckY + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {Phaser.Tilemaps.Tile} tile - The tile to check. + * @param {number} tileTop - [description] + * @param {number} tileBottom - [description] + * @param {number} tileBias - [description] + * + * @return {number} The amount of separation that occurred. + */ +var TileCheckY = function (body, tile, tileTop, tileBottom, tileBias) +{ + var oy = 0; + + if (body.deltaY() < 0 && !body.blocked.up && tile.collideDown && body.checkCollision.up) + { + // Body is moving UP + if (tile.faceBottom && body.y < tileBottom) + { + oy = body.y - tileBottom; + + if (oy < -tileBias) + { + oy = 0; + } + } + } + else if (body.deltaY() > 0 && !body.blocked.down && tile.collideUp && body.checkCollision.down) + { + // Body is moving DOWN + if (tile.faceTop && body.bottom > tileTop) + { + oy = body.bottom - tileTop; + + if (oy > tileBias) + { + oy = 0; + } + } + } + + if (oy !== 0) + { + if (body.customSeparateY) + { + body.overlapY = oy; + } + else + { + ProcessTileSeparationY(body, oy); + } + } + + return oy; +}; + +module.exports = TileCheckY; + + +/***/ }), +/* 474 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Internal function to process the separation of a physics body from a tile. + * + * @function Phaser.Physics.Arcade.Tilemap.ProcessTileSeparationX + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {number} x - The x separation amount. + */ +var ProcessTileSeparationX = function (body, x) +{ + if (x < 0) + { + body.blocked.left = true; + } + else if (x > 0) + { + body.blocked.right = true; + } + + body.position.x -= x; + + if (body.bounce.x === 0) + { + body.velocity.x = 0; + } + else + { + body.velocity.x = -body.velocity.x * body.bounce.x; + } +}; + +module.exports = ProcessTileSeparationX; + + +/***/ }), +/* 475 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ProcessTileSeparationX = __webpack_require__(474); + +/** + * Check the body against the given tile on the X axis. + * + * @function Phaser.Physics.Arcade.Tilemap.TileCheckX + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {Phaser.Tilemaps.Tile} tile - The tile to check. + * @param {number} tileLeft - [description] + * @param {number} tileRight - [description] + * @param {number} tileBias - [description] + * + * @return {number} The amount of separation that occurred. + */ +var TileCheckX = function (body, tile, tileLeft, tileRight, tileBias) +{ + var ox = 0; + + if (body.deltaX() < 0 && !body.blocked.left && tile.collideRight && body.checkCollision.left) + { + // Body is moving LEFT + if (tile.faceRight && body.x < tileRight) + { + ox = body.x - tileRight; + + if (ox < -tileBias) + { + ox = 0; + } + } + } + else if (body.deltaX() > 0 && !body.blocked.right && tile.collideLeft && body.checkCollision.right) + { + // Body is moving RIGHT + if (tile.faceLeft && body.right > tileLeft) + { + ox = body.right - tileLeft; + + if (ox > tileBias) + { + ox = 0; + } + } + } + + if (ox !== 0) + { + if (body.customSeparateX) + { + body.overlapX = ox; + } + else + { + ProcessTileSeparationX(body, ox); + } + } + + return ox; +}; + +module.exports = TileCheckX; + + +/***/ }), +/* 476 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TileCheckX = __webpack_require__(475); +var TileCheckY = __webpack_require__(473); +var TileIntersectsBody = __webpack_require__(202); + +/** + * The core separation function to separate a physics body and a tile. + * + * @function Phaser.Physics.Arcade.Tilemap.SeparateTile + * @since 3.0.0 + * + * @param {number} i - [description] + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {Phaser.Tilemaps.Tile} tile - The tile to collide against. + * @param {Phaser.Geom.Rectangle} tileWorldRect - [description] + * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - The tilemapLayer to collide against. + * @param {number} tileBias - [description] + * + * @return {boolean} Returns true if the body was separated, otherwise false. + */ +var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer, tileBias) +{ + var tileLeft = tileWorldRect.left; + var tileTop = tileWorldRect.top; + var tileRight = tileWorldRect.right; + var tileBottom = tileWorldRect.bottom; + var faceHorizontal = tile.faceLeft || tile.faceRight; + var faceVertical = tile.faceTop || tile.faceBottom; + + // We don't need to go any further if this tile doesn't actually have any colliding faces. This + // could happen if the tile was meant to be collided with re: a callback, but otherwise isn't + // needed for separation. + if (!faceHorizontal && !faceVertical) + { + return false; + } + + var ox = 0; + var oy = 0; + var minX = 0; + var minY = 1; + + if (body.deltaAbsX() > body.deltaAbsY()) + { + // Moving faster horizontally, check X axis first + minX = -1; + } + else if (body.deltaAbsX() < body.deltaAbsY()) + { + // Moving faster vertically, check Y axis first + minY = -1; + } + + if (body.deltaX() !== 0 && body.deltaY() !== 0 && faceHorizontal && faceVertical) + { + // We only need do this if both axes have colliding faces AND we're moving in both + // directions + minX = Math.min(Math.abs(body.position.x - tileRight), Math.abs(body.right - tileLeft)); + minY = Math.min(Math.abs(body.position.y - tileBottom), Math.abs(body.bottom - tileTop)); + } + + if (minX < minY) + { + if (faceHorizontal) + { + ox = TileCheckX(body, tile, tileLeft, tileRight, tileBias); + + // That's horizontal done, check if we still intersects? If not then we can return now + if (ox !== 0 && !TileIntersectsBody(tileWorldRect, body)) + { + return true; + } + } + + if (faceVertical) + { + oy = TileCheckY(body, tile, tileTop, tileBottom, tileBias); + } + } + else + { + if (faceVertical) + { + oy = TileCheckY(body, tile, tileTop, tileBottom, tileBias); + + // That's vertical done, check if we still intersects? If not then we can return now + if (oy !== 0 && !TileIntersectsBody(tileWorldRect, body)) + { + return true; + } + } + + if (faceHorizontal) + { + ox = TileCheckX(body, tile, tileLeft, tileRight, tileBias); + } + } + + return (ox !== 0 || oy !== 0); +}; + +module.exports = SeparateTile; + + +/***/ }), +/* 477 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Physics.Arcade.Tilemap.ProcessTileCallbacks + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.Tilemap} tile - [description] + * @param {Phaser.GameObjects.Sprite} sprite - [description] + * + * @return {boolean} [description] + */ +var ProcessTileCallbacks = function (tile, sprite) +{ + // Tile callbacks take priority over layer level callbacks + if (tile.collisionCallback) + { + return !tile.collisionCallback.call(tile.collisionCallbackContext, sprite, tile); + } + else if (tile.layer.callbacks[tile.index]) + { + return !tile.layer.callbacks[tile.index].callback.call( + tile.layer.callbacks[tile.index].callbackContext, sprite, tile + ); + } + + return true; +}; + +module.exports = ProcessTileCallbacks; + + +/***/ }), +/* 478 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Velocity + * @since 3.0.0 + */ +var Velocity = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Velocity#setVelocity + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setVelocity: function (x, y) + { + this.body.velocity.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Velocity#setVelocityX + * @since 3.0.0 + * + * @param {number} x - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setVelocityX: function (x) + { + this.body.velocity.x = x; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Velocity#setVelocityY + * @since 3.0.0 + * + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setVelocityY: function (y) + { + this.body.velocity.y = y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Velocity#setMaxVelocity + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setMaxVelocity: function (x, y) + { + this.body.maxVelocity.set(x, y); + + return this; + } + +}; + +module.exports = Velocity; + + +/***/ }), +/* 479 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Size + * @since 3.0.0 + */ +var Size = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Size#setOffset + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setOffset: function (x, y) + { + this.body.setOffset(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Size#setSize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * @param {boolean} [center=true] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setSize: function (width, height, center) + { + this.body.setSize(width, height, center); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Size#setCircle + * @since 3.0.0 + * + * @param {number} radius - [description] + * @param {number} [offsetX] - [description] + * @param {number} [offsetY] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setCircle: function (radius, offsetX, offsetY) + { + this.body.setCircle(radius, offsetX, offsetY); + + return this; + } + +}; + +module.exports = Size; + + +/***/ }), +/* 480 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Mass + * @since 3.0.0 + */ +var Mass = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Mass#setMass + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setMass: function (value) + { + this.body.mass = value; + + return this; + } + +}; + +module.exports = Mass; + + +/***/ }), +/* 481 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Immovable + * @since 3.0.0 + */ +var Immovable = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Immovable#setImmovable + * @since 3.0.0 + * + * @param {boolean} [value=true] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setImmovable: function (value) + { + if (value === undefined) { value = true; } + + this.body.immovable = value; + + return this; + } + +}; + +module.exports = Immovable; + + +/***/ }), +/* 482 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Gravity + * @since 3.0.0 + */ +var Gravity = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Gravity#setGravity + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setGravity: function (x, y) + { + this.body.gravity.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Gravity#setGravityX + * @since 3.0.0 + * + * @param {number} x - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setGravityX: function (x) + { + this.body.gravity.x = x; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Gravity#setGravityY + * @since 3.0.0 + * + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setGravityY: function (y) + { + this.body.gravity.y = y; + + return this; + } + +}; + +module.exports = Gravity; + + +/***/ }), +/* 483 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Friction + * @since 3.0.0 + */ +var Friction = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Friction#setFriction + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setFriction: function (x, y) + { + this.body.friction.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Friction#setFrictionX + * @since 3.0.0 + * + * @param {number} x - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setFrictionX: function (x) + { + this.body.friction.x = x; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Friction#setFrictionY + * @since 3.0.0 + * + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setFrictionY: function (y) + { + this.body.friction.y = y; + + return this; + } + +}; + +module.exports = Friction; + + +/***/ }), +/* 484 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Enable + * @since 3.0.0 + */ +var Enable = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Enable#enableBody + * @since 3.0.0 + * + * @param {boolean} reset - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {boolean} enableGameObject - [description] + * @param {boolean} showGameObject - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + enableBody: function (reset, x, y, enableGameObject, showGameObject) + { + if (reset) + { + this.body.reset(x, y); + } + + if (enableGameObject) + { + this.body.gameObject.active = true; + } + + if (showGameObject) + { + this.body.gameObject.visible = true; + } + + this.body.enable = true; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Enable#disableBody + * @since 3.0.0 + * + * @param {boolean} [disableGameObject=false] - [description] + * @param {boolean} [hideGameObject=false] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + disableBody: function (disableGameObject, hideGameObject) + { + if (disableGameObject === undefined) { disableGameObject = false; } + if (hideGameObject === undefined) { hideGameObject = false; } + + this.body.stop(); + + this.body.enable = false; + + if (disableGameObject) + { + this.body.gameObject.active = false; + } + + if (hideGameObject) + { + this.body.gameObject.visible = false; + } + + return this; + }, + + /** + * Syncs the Bodies position and size with its parent Game Object. + * You don't need to call this for Dynamic Bodies, as it happens automatically. + * But for Static bodies it's a useful way of modifying the position of a Static Body + * in the Physics World, based on its Game Object. + * + * @method Phaser.Physics.Arcade.Components.Enable#refreshBody + * @since 3.1.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + refreshBody: function () + { + this.body.updateFromGameObject(); + + return this; + } + +}; + +module.exports = Enable; + + +/***/ }), +/* 485 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Drag + * @since 3.0.0 + */ +var Drag = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Drag#setDrag + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setDrag: function (x, y) + { + this.body.drag.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Drag#setDragX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setDragX: function (value) + { + this.body.drag.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Drag#setDragY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setDragY: function (value) + { + this.body.drag.y = value; + + return this; + } + +}; + +module.exports = Drag; + + +/***/ }), +/* 486 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Debug + * @since 3.0.0 + */ +var Debug = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Debug#setDebug + * @since 3.0.0 + * + * @param {boolean} showBody - [description] + * @param {boolean} showVelocity - [description] + * @param {number} bodyColor - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setDebug: function (showBody, showVelocity, bodyColor) + { + this.debugShowBody = showBody; + this.debugShowVelocity = showVelocity; + this.debugBodyColor = bodyColor; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Debug#setDebugBodyColor + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setDebugBodyColor: function (value) + { + this.body.debugBodyColor = value; + + return this; + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Debug#debugShowBody + * @type {boolean} + * @since 3.0.0 + */ + debugShowBody: { + + get: function () + { + return this.body.debugShowBody; + }, + + set: function (value) + { + this.body.debugShowBody = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Debug#debugShowVelocity + * @type {boolean} + * @since 3.0.0 + */ + debugShowVelocity: { + + get: function () + { + return this.body.debugShowVelocity; + }, + + set: function (value) + { + this.body.debugShowVelocity = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Debug#debugBodyColor + * @type {number} + * @since 3.0.0 + */ + debugBodyColor: { + + get: function () + { + return this.body.debugBodyColor; + }, + + set: function (value) + { + this.body.debugBodyColor = value; + } + + } + +}; + +module.exports = Debug; + + +/***/ }), +/* 487 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Bounce + * @since 3.0.0 + */ +var Bounce = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Bounce#setBounce + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setBounce: function (x, y) + { + this.body.bounce.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Bounce#setBounceX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setBounceX: function (value) + { + this.body.bounce.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Bounce#setBounceY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setBounceY: function (value) + { + this.body.bounce.y = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Bounce#setCollideWorldBounds + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setCollideWorldBounds: function (value) + { + this.body.collideWorldBounds = value; + + return this; + } + +}; + +module.exports = Bounce; + + +/***/ }), +/* 488 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Angular + * @since 3.0.0 + */ +var Angular = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Angular#setAngularVelocity + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setAngularVelocity: function (value) + { + this.body.angularVelocity = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Angular#setAngularAcceleration + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setAngularAcceleration: function (value) + { + this.body.angularAcceleration = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Angular#setAngularDrag + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setAngularDrag: function (value) + { + this.body.angularDrag = value; + + return this; + } + +}; + +module.exports = Angular; + + +/***/ }), +/* 489 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Acceleration + * @since 3.0.0 + */ +var Acceleration = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Acceleration#setAcceleration + * @since 3.0.0 + * + * @param {number} x - The horizontal acceleration + * @param {number} [y=x] - The vertical acceleration + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setAcceleration: function (x, y) + { + this.body.acceleration.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Acceleration#setAccelerationX + * @since 3.0.0 + * + * @param {number} value - The horizontal acceleration + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setAccelerationX: function (value) + { + this.body.acceleration.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Acceleration#setAccelerationY + * @since 3.0.0 + * + * @param {number} value - The vertical acceleration + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setAccelerationY: function (value) + { + this.body.acceleration.y = value; + + return this; + } + +}; + +module.exports = Acceleration; + + +/***/ }), +/* 490 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Factory = __webpack_require__(215); +var GetFastValue = __webpack_require__(2); +var Merge = __webpack_require__(107); +var PluginManager = __webpack_require__(12); +var World = __webpack_require__(210); +var DistanceBetween = __webpack_require__(48); +var DegToRad = __webpack_require__(42); + +// All methods in this class are available under `this.physics` in a Scene. + +/** + * @classdesc + * [description] + * + * @class ArcadePhysics + * @memberOf Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ +var ArcadePhysics = new Class({ + + initialize: + + function ArcadePhysics (scene) + { + /** + * [description] + * + * @name Phaser.Physics.Arcade.ArcadePhysics#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.ArcadePhysics#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + if (!scene.sys.settings.isBooted) + { + scene.sys.events.once('boot', this.boot, this); + } + + /** + * [description] + * + * @name Phaser.Physics.Arcade.ArcadePhysics#config + * @type {object} + * @since 3.0.0 + */ + this.config = this.getConfig(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.ArcadePhysics#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.ArcadePhysics#add + * @type {Phaser.Physics.Arcade.Factory} + * @since 3.0.0 + */ + this.add; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.ArcadePhysics#getConfig + * @since 3.0.0 + * + * @return {object} [description] + */ + getConfig: function () + { + var gameConfig = this.systems.game.config.physics; + var sceneConfig = this.systems.settings.physics; + + var config = Merge( + GetFastValue(sceneConfig, 'arcade', {}), + GetFastValue(gameConfig, 'arcade', {}) + ); + + return config; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.ArcadePhysics#boot + * @since 3.0.0 + */ + boot: function () + { + this.world = new World(this.scene, this.config); + this.add = new Factory(this.world); + + var eventEmitter = this.systems.events; + + eventEmitter.on('update', this.world.update, this.world); + eventEmitter.on('postupdate', this.world.postUpdate, this.world); + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); + }, + + /** + * Checks for overlaps between two Game Objects. The objects can be any Game Object that have an Arcade Physics Body. + * + * Unlike {@link #collide} the objects are NOT automatically separated or have any physics applied, they merely test for overlap results. + * + * Both the first and second parameter can be arrays of objects, of differing types. + * If two arrays are passed, the contents of the first parameter will be tested against all contents of the 2nd parameter. + * + * ##### Tilemaps + * + * Any overlapping tiles, including blank/null tiles, will give a positive result. Tiles marked via {@link Phaser.Tilemap#setCollision} (and similar methods) have no special status, and callbacks added via {@link Phaser.Tilemap#setTileIndexCallback} or {@link Phaser.Tilemap#setTileLocationCallback} are not invoked. So calling this method without any callbacks isn't very useful. + * + * If you're interested only in whether an object overlaps a certain tile or class of tiles, filter the tiles with `processCallback` and then use the result returned by this method. Blank/null tiles can be excluded by their {@link Phaser.Tile#index index} (-1). + * + * If you want to take action on certain overlaps, examine the tiles in `collideCallback` and then handle as you like. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#overlap + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|array)} object1 - The first object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. + * @param {(Phaser.GameObjects.GameObject|array)} object2 - The second object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. + * @param {ArcadePhysicsCallback} [overlapCallback=null] - An optional callback function that is called if the objects overlap. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter. + * @param {ArcadePhysicsCallback} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `overlapCallback` will only be called if this callback returns `true`. + * @param {*} [callbackContext] - The context in which to run the callbacks. + * + * @return {boolean} True if an overlap occurred otherwise false. + */ + overlap: function (object1, object2, overlapCallback, processCallback, callbackContext) + { + if (overlapCallback === undefined) { overlapCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = overlapCallback; } + + return this.world.collideObjects(object1, object2, overlapCallback, processCallback, callbackContext, true); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.ArcadePhysics#collide + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|array)} object1 - The first object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. + * @param {(Phaser.GameObjects.GameObject|array)} object2 - The second object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. + * @param {ArcadePhysicsCallback} [collideCallback=null] - An optional callback function that is called if the objects collide. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter. + * @param {ArcadePhysicsCallback} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param {*} [callbackContext] - The context in which to run the callbacks. + * + * @return {boolean} True if a collision occurred otherwise false. + */ + collide: function (object1, object2, collideCallback, processCallback, callbackContext) + { + if (collideCallback === undefined) { collideCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = collideCallback; } + + return this.world.collideObjects(object1, object2, collideCallback, processCallback, callbackContext, false); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.ArcadePhysics#pause + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.World} [description] + */ + pause: function () + { + return this.world.pause(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.ArcadePhysics#resume + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.World} [description] + */ + resume: function () + { + return this.world.resume(); + }, + + /** + * Sets the acceleration.x/y property on the game object so it will move towards the x/y coordinates at the given speed (in pixels per second sq.) + * + * You must give a maximum speed value, beyond which the game object won't go any faster. + * + * Note: The game object does not continuously track the target. If the target changes location during transit the game object will not modify its course. + * Note: The game object doesn't stop moving once it reaches the destination coordinates. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#accelerateTo + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. + * @param {number} x - The x coordinate to accelerate towards. + * @param {number} y - The y coordinate to accelerate towards. + * @param {number} [speed=60] - The speed it will accelerate in pixels per second. + * @param {number} [xSpeedMax=500] - The maximum x velocity the game object can reach. + * @param {number} [ySpeedMax=500] - The maximum y velocity the game object can reach. + * + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. + */ + accelerateTo: function (gameObject, x, y, speed, xSpeedMax, ySpeedMax) + { + if (speed === undefined) { speed = 60; } + + var angle = Math.atan2(y - gameObject.y, x - gameObject.x); + + gameObject.body.acceleration.setToPolar(angle, speed); + + if (xSpeedMax !== undefined && ySpeedMax !== undefined) + { + gameObject.body.maxVelocity.set(xSpeedMax, ySpeedMax); + } + + return angle; + }, + + /** + * Sets the acceleration.x/y property on the game object so it will move towards the x/y coordinates at the given speed (in pixels per second sq.) + * + * You must give a maximum speed value, beyond which the game object won't go any faster. + * + * Note: The game object does not continuously track the target. If the target changes location during transit the game object will not modify its course. + * Note: The game object doesn't stop moving once it reaches the destination coordinates. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#accelerateToObject + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. + * @param {Phaser.GameObjects.GameObject} destination - The Game Object to move towards. Can be any object but must have visible x/y properties. + * @param {number} [speed=60] - The speed it will accelerate in pixels per second. + * @param {number} [xSpeedMax=500] - The maximum x velocity the game object can reach. + * @param {number} [ySpeedMax=500] - The maximum y velocity the game object can reach. + * + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. + */ + accelerateToObject: function (gameObject, destination, speed, xSpeedMax, ySpeedMax) + { + return this.accelerateTo(gameObject, destination.x, destination.y, speed, xSpeedMax, ySpeedMax); + }, + + /** + * From a set of points or display objects, find the one closest to a source point or object. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#closest + * @since 3.0.0 + * + * @param {object} source - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. + * + * @return {Phaser.Physics.Arcade.Body} The closest Body to the given source point. + */ + closest: function (source) + { + var bodies = this.tree.all(); + + var min = Number.MAX_VALUE; + var closest = null; + var x = source.x; + var y = source.y; + + for (var i = bodies.length - 1; i >= 0; i--) + { + var target = bodies[i]; + var distance = DistanceBetween(x, y, target.x, target.y); + + if (distance < min) + { + closest = target; + min = distance; + } + } + + return closest; + }, + + /** + * From a set of points or display objects, find the one farthest from a source point or object. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#furthest + * @since 3.0.0 + * + * @param {object} source - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. + * + * @return {Phaser.Physics.Arcade.Body} The Body furthest from the given source point. + */ + furthest: function (source) + { + var bodies = this.tree.all(); + + var max = -1; + var farthest = null; + var x = source.x; + var y = source.y; + + for (var i = bodies.length - 1; i >= 0; i--) + { + var target = bodies[i]; + var distance = DistanceBetween(x, y, target.x, target.y); + + if (distance > max) + { + farthest = target; + max = distance; + } + } + + return farthest; + }, + + /** + * Move the given display object towards the x/y coordinates at a steady velocity. + * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. + * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) + * + * @method Phaser.Physics.Arcade.ArcadePhysics#moveTo + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. + * @param {number} x - The x coordinate to move towards. + * @param {number} y - The y coordinate to move towards. + * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) + * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. + * + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. + */ + moveTo: function (gameObject, x, y, speed, maxTime) + { + if (speed === undefined) { speed = 60; } + if (maxTime === undefined) { maxTime = 0; } + + var angle = Math.atan2(y - gameObject.y, x - gameObject.x); + + if (maxTime > 0) + { + // We know how many pixels we need to move, but how fast? + speed = DistanceBetween(gameObject.x, gameObject.y, x, y) / (maxTime / 1000); + } + + gameObject.body.velocity.setToPolar(angle, speed); + + return angle; + }, + + /** + * Move the given display object towards the destination object at a steady velocity. + * If you specify a maxTime then it will adjust the speed (overwriting what you set) so it arrives at the destination in that number of seconds. + * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) + * + * @method Phaser.Physics.Arcade.ArcadePhysics#moveToObject + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. + * @param {object} destination - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. + * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) + * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. + * + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. + */ + moveToObject: function (gameObject, destination, speed, maxTime) + { + return this.moveTo(gameObject, destination.x, destination.y, speed, maxTime); + }, + + /** + * Given the angle (in degrees) and speed calculate the velocity and return it as a Point object, or set it to the given point object. + * One way to use this is: velocityFromAngle(angle, 200, sprite.velocity) which will set the values directly to the sprites velocity and not create a new Point object. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#velocityFromAngle + * @since 3.0.0 + * + * @param {number} angle - The angle in degrees calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) + * @param {number} [speed=60] - The speed it will move, in pixels per second sq. + * @param {Phaser.Math.Vector2} vec2 - The Vector2 in which the x and y properties will be set to the calculated velocity. + * + * @return {Phaser.Math.Vector2} The Vector2 that stores the velocity. + */ + velocityFromAngle: function (angle, speed, vec2) + { + if (speed === undefined) { speed = 60; } + + return vec2.setToPolar(DegToRad(angle), speed); + }, + + /** + * Given the rotation (in radians) and speed calculate the velocity and return it as a Point object, or set it to the given point object. + * One way to use this is: velocityFromRotation(rotation, 200, sprite.velocity) which will set the values directly to the sprites velocity and not create a new Point object. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#velocityFromRotation + * @since 3.0.0 + * + * @param {number} rotation - The angle in radians. + * @param {number} [speed=60] - The speed it will move, in pixels per second sq. + * @param {Phaser.Math.Vector2} vec2 - The Vector2 in which the x and y properties will be set to the calculated velocity. + * + * @return {Phaser.Math.Vector2} The Vector2 that stores the velocity. + */ + velocityFromRotation: function (rotation, speed, vec2) + { + if (speed === undefined) { speed = 60; } + + return vec2.setToPolar(rotation, speed); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.ArcadePhysics#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.world.shutdown(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.ArcadePhysics#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.world.destroy(); + } + +}); + +PluginManager.register('ArcadePhysics', ArcadePhysics, 'arcadePhysics'); + +module.exports = ArcadePhysics; + + +/***/ }), +/* 491 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(47); +var Extend = __webpack_require__(18); + +/** + * @callback ArcadePhysicsCallback + * + * @param {Phaser.GameObjects.GameObject} object1 - [description] + * @param {Phaser.GameObjects.GameObject} object2 - [description] + */ + +/** + * @namespace Phaser.Physics.Arcade + */ + +var Arcade = { + + ArcadePhysics: __webpack_require__(490), + Body: __webpack_require__(209), + Collider: __webpack_require__(208), + Factory: __webpack_require__(215), + Group: __webpack_require__(212), + Image: __webpack_require__(214), + Sprite: __webpack_require__(93), + StaticBody: __webpack_require__(201), + StaticGroup: __webpack_require__(211), + World: __webpack_require__(210) + +}; + +// Merge in the consts +Arcade = Extend(false, Arcade, CONST); + +module.exports = Arcade; + + +/***/ }), +/* 492 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Checks if the two values are within the given `tolerance` of each other. + * + * @function Phaser.Math.Within + * @since 3.0.0 + * + * @param {number} a - [description] + * @param {number} b - [description] + * @param {number} tolerance - The tolerance. Anything equal to or less than this value is considered as being within range. + * + * @return {boolean} Returns `true` if `a` is less than or equal to the tolerance of `b`. + */ +var Within = function (a, b, tolerance) +{ + return (Math.abs(a - b) <= tolerance); +}; + +module.exports = Within; + + +/***/ }), +/* 493 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} SinCosTable + * + * @property {number} sin - [description] + * @property {number} cos - [description] + * @property {number} length - [description] + */ + +/** + * [description] + * + * @function Phaser.Math.SinCosTableGenerator + * @since 3.0.0 + * + * @param {number} length - [description] + * @param {number} sinAmp - [description] + * @param {number} cosAmp - [description] + * @param {number} frequency - [description] + * + * @return {SinCosTable} [description] + */ +var SinCosTableGenerator = function (length, sinAmp, cosAmp, frequency) +{ + if (sinAmp === undefined) { sinAmp = 1; } + if (cosAmp === undefined) { cosAmp = 1; } + if (frequency === undefined) { frequency = 1; } + + frequency *= Math.PI / length; + + var cos = []; + var sin = []; + + for (var c = 0; c < length; c++) + { + cosAmp -= sinAmp * frequency; + sinAmp += cosAmp * frequency; + + cos[c] = cosAmp; + sin[c] = sinAmp; + } + + return { + sin: sin, + cos: cos, + length: length + }; +}; + +module.exports = SinCosTableGenerator; + + +/***/ }), +/* 494 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.RoundTo + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {integer} [place=0] - [description] + * @param {integer} [base=10] - [description] + * + * @return {number} [description] + */ +var RoundTo = function (value, place, base) +{ + if (place === undefined) { place = 0; } + if (base === undefined) { base = 10; } + + var p = Math.pow(base, -place); + + return Math.round(value * p) / p; +}; + +module.exports = RoundTo; + + +/***/ }), +/* 495 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.RandomXY + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} vector - [description] + * @param {float} scale - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ +var RandomXY = function (vector, scale) +{ + if (scale === undefined) { scale = 1; } + + var r = Math.random() * 2 * Math.PI; + + vector.x = Math.cos(r) * scale; + vector.y = Math.sin(r) * scale; + + return vector; +}; + +module.exports = RandomXY; + + +/***/ }), +/* 496 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Work out what percentage `value` is of the range between `min` and `max`. + * If `max` isn't given then it will return the percentage of `value` to `min`. + * + * You can optionally specify an `upperMax` value, which is a mid-way point in the range that represents 100%, after which the % starts to go down to zero again. + * + * @function Phaser.Math.Percent + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} min - [description] + * @param {number} [max] - [description] + * @param {number} [upperMax] - [description] + * + * @return {float} A value between 0 and 1 representing the percentage. + */ +var Percent = function (value, min, max, upperMax) +{ + if (max === undefined) { max = min + 1; } + + var percentage = (value - min) / (max - min); + + if (percentage > 1) + { + if (upperMax !== undefined) + { + percentage = ((upperMax - value)) / (upperMax - max); + + if (percentage < 0) + { + percentage = 0; + } + } + else + { + percentage = 1; + } + } + else if (percentage < 0) + { + percentage = 0; + } + + return percentage; +}; + +module.exports = Percent; + + +/***/ }), +/* 497 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.MinSub + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} amount - [description] + * @param {number} min - [description] + * + * @return {number} [description] + */ +var MinSub = function (value, amount, min) +{ + return Math.max(value - amount, min); +}; + +module.exports = MinSub; + + +/***/ }), +/* 498 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.MaxAdd + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} amount - [description] + * @param {number} max - [description] + * + * @return {number} [description] + */ +var MaxAdd = function (value, amount, max) +{ + return Math.min(value + amount, max); +}; + +module.exports = MaxAdd; + + +/***/ }), +/* 499 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.IsEvenStrict + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {boolean} [description] + */ +var IsEvenStrict = function (value) +{ + // Use strict equality === for "is number" test + return (value === parseFloat(value)) ? !(value % 2) : void 0; +}; + +module.exports = IsEvenStrict; + + +/***/ }), +/* 500 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.IsEven + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {boolean} [description] + */ +var IsEven = function (value) +{ + // Use abstract equality == for "is number" test + + // eslint-disable-next-line eqeqeq + return (value == parseFloat(value)) ? !(value % 2) : void 0; +}; + +module.exports = IsEven; + + +/***/ }), +/* 501 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.GetSpeed + * @since 3.0.0 + * + * @param {number} distance - The distance to travel in pixels. + * @param {integer} time - The time, in ms, to cover the distance in. + * + * @return {number} The amount you will need to increment the position by each step in order to cover the distance in the time given. + */ +var GetSpeed = function (distance, time) +{ + return (distance / time) / 1000; +}; + +module.exports = GetSpeed; + + +/***/ }), +/* 502 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.FloorTo + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {integer} [place=0 - [description] + * @param {integer} [base=10] - [description] + * + * @return {number} [description] + */ +var FloorTo = function (value, place, base) +{ + if (place === undefined) { place = 0; } + if (base === undefined) { base = 10; } + + var p = Math.pow(base, -place); + + return Math.floor(value * p) / p; +}; + +module.exports = FloorTo; + + +/***/ }), +/* 503 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Difference + * @since 3.0.0 + * + * @param {number} a - [description] + * @param {number} b - [description] + * + * @return {number} [description] + */ +var Difference = function (a, b) +{ + return Math.abs(a - b); +}; + +module.exports = Difference; + + +/***/ }), +/* 504 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.CeilTo + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} [place=0] - [description] + * @param {integer} [base=10] - [description] + * + * @return {number} [description] + */ +var CeilTo = function (value, place, base) +{ + if (place === undefined) { place = 0; } + if (base === undefined) { base = 10; } + + var p = Math.pow(base, -place); + + return Math.ceil(value * p) / p; +}; + +module.exports = CeilTo; + + +/***/ }), +/* 505 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Average + * @since 3.0.0 + * + * @param {number[]} values - [description] + * + * @return {number} [description] + */ +var Average = function (values) +{ + var sum = 0; + + for (var i = 0; i < values.length; i++) + { + sum += (+values[i]); + } + + return sum / values.length; +}; + +module.exports = Average; + + +/***/ }), +/* 506 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Snap.To + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} gap - [description] + * @param {number} [start=0] - [description] + * + * @return {number} [description] + */ +var SnapTo = function (value, gap, start) +{ + if (start === undefined) { start = 0; } + + if (gap === 0) + { + return value; + } + + value -= start; + value = gap * Math.round(value / gap); + + return start + value; +}; + +module.exports = SnapTo; + + +/***/ }), +/* 507 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Snap.Floor + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} gap - [description] + * @param {number} [start=0] - [description] + * + * @return {number} [description] + */ +var SnapFloor = function (value, gap, start) +{ + if (start === undefined) { start = 0; } + + if (gap === 0) + { + return value; + } + + value -= start; + value = gap * Math.floor(value / gap); + + return start + value; +}; + +module.exports = SnapFloor; + + +/***/ }), +/* 508 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Snap.Ceil + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} gap - [description] + * @param {number} [start=0] - [description] + * + * @return {number} [description] + */ +var SnapCeil = function (value, gap, start) +{ + if (start === undefined) { start = 0; } + + if (gap === 0) + { + return value; + } + + value -= start; + value = gap * Math.ceil(value / gap); + + return start + value; +}; + +module.exports = SnapCeil; + + +/***/ }), +/* 509 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Snap + */ + +module.exports = { + + Ceil: __webpack_require__(508), + Floor: __webpack_require__(507), + To: __webpack_require__(506) + +}; + + +/***/ }), +/* 510 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Tests the value and returns `true` if it is a power of two. + * + * @function Phaser.Math.Pow2.IsValuePowerOfTwo + * @since 3.0.0 + * + * @param {number} value - The value to check if it's a power of two. + * + * @return {boolean} Returns `true` if `value` is a power of two, otherwise `false`. + */ +var IsValuePowerOfTwo = function (value) +{ + return (value > 0 && (value & (value - 1)) === 0); +}; + +module.exports = IsValuePowerOfTwo; + + +/***/ }), +/* 511 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Pow2 + */ + +module.exports = { + + GetNext: __webpack_require__(248), + IsSize: __webpack_require__(145), + IsValue: __webpack_require__(510) + +}; + + +/***/ }), +/* 512 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Linear = __webpack_require__(148); + +/** + * [description] + * + * @function Phaser.Math.Interpolation.Linear + * @since 3.0.0 + * + * @param {float} v - [description] + * @param {number} k - [description] + * + * @return {number} [description] + */ +var LinearInterpolation = function (v, k) +{ + var m = v.length - 1; + var f = m * k; + var i = Math.floor(f); + + if (k < 0) + { + return Linear(v[0], v[1], f); + } + + if (k > 1) + { + return Linear(v[m], v[m - 1], m - f); + } + + return Linear(v[i], v[(i + 1 > m) ? m : i + 1], f - i); +}; + +module.exports = LinearInterpolation; + + +/***/ }), +/* 513 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CatmullRom = __webpack_require__(149); + +/** + * [description] + * + * @function Phaser.Math.Interpolation.CatmullRom + * @since 3.0.0 + * + * @param {number} v - [description] + * @param {number} k - [description] + * + * @return {number} [description] + */ +var CatmullRomInterpolation = function (v, k) +{ + var m = v.length - 1; + var f = m * k; + var i = Math.floor(f); + + if (v[0] === v[m]) + { + if (k < 0) + { + i = Math.floor(f = m * (1 + k)); + } + + return CatmullRom(f - i, v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m]); + } + else + { + if (k < 0) + { + return v[0] - (CatmullRom(-f, v[0], v[0], v[1], v[1]) - v[0]); + } + + if (k > 1) + { + return v[m] - (CatmullRom(f - m, v[m], v[m], v[m - 1], v[m - 1]) - v[m]); + } + + return CatmullRom(f - i, v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2]); + } +}; + +module.exports = CatmullRomInterpolation; + + +/***/ }), +/* 514 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Bernstein = __webpack_require__(219); + +/** + * [description] + * + * @function Phaser.Math.Interpolation.Bezier + * @since 3.0.0 + * + * @param {number} v - [description] + * @param {number} k - [description] + * + * @return {number} [description] + */ +var BezierInterpolation = function (v, k) +{ + var b = 0; + var n = v.length - 1; + + for (var i = 0; i <= n; i++) + { + b += Math.pow(1 - k, n - i) * Math.pow(k, i) * v[i] * Bernstein(n, i); + } + + return b; +}; + +module.exports = BezierInterpolation; + + +/***/ }), +/* 515 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Interpolation + */ + +module.exports = { + Bezier: __webpack_require__(514), + CatmullRom: __webpack_require__(513), + CubicBezier: __webpack_require__(320), + Linear: __webpack_require__(512), + QuadraticBezier: __webpack_require__(315) +}; + + +/***/ }), +/* 516 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Fuzzy.LessThan + * @since 3.0.0 + * + * @param {number} a - [description] + * @param {number} b - [description] + * @param {float} [epsilon=0.0001] - [description] + * + * @return {boolean} [description] + */ +var LessThan = function (a, b, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return a < b + epsilon; +}; + +module.exports = LessThan; + + +/***/ }), +/* 517 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Fuzzy.GreaterThan + * @since 3.0.0 + * + * @param {number} a - [description] + * @param {number} b - [description] + * @param {float} [epsilon=0.0001] - [description] + * + * @return {boolean} [description] + */ +var GreaterThan = function (a, b, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return a > b - epsilon; +}; + +module.exports = GreaterThan; + + +/***/ }), +/* 518 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Fuzzy.Floor + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {float} [epsilon=0.0001] - [description] + * + * @return {number} [description] + */ +var Floor = function (value, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return Math.floor(value + epsilon); +}; + +module.exports = Floor; + + +/***/ }), +/* 519 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Fuzzy.Equal + * @since 3.0.0 + * + * @param {number} a - [description] + * @param {number} b - [description] + * @param {float} [epsilon=0.0001] - [description] + * + * @return {boolean} [description] + */ +var Equal = function (a, b, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return Math.abs(a - b) < epsilon; +}; + +module.exports = Equal; + + +/***/ }), +/* 520 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Fuzzy.Ceil + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {float} [epsilon=0.0001] - [description] + * + * @return {number} [description] + */ +var Ceil = function (value, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return Math.ceil(value - epsilon); +}; + +module.exports = Ceil; + + +/***/ }), +/* 521 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Fuzzy + */ + +module.exports = { + + Ceil: __webpack_require__(520), + Equal: __webpack_require__(519), + Floor: __webpack_require__(518), + GreaterThan: __webpack_require__(517), + LessThan: __webpack_require__(516) + +}; + + +/***/ }), +/* 522 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing + */ + +module.exports = { + + Back: __webpack_require__(262), + Bounce: __webpack_require__(261), + Circular: __webpack_require__(260), + Cubic: __webpack_require__(259), + Elastic: __webpack_require__(258), + Expo: __webpack_require__(257), + Linear: __webpack_require__(256), + Quadratic: __webpack_require__(255), + Quartic: __webpack_require__(254), + Quintic: __webpack_require__(253), + Sine: __webpack_require__(252), + Stepped: __webpack_require__(251) + +}; + + +/***/ }), +/* 523 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Distance.Squared + * @since 3.0.0 + * + * @param {number} x1 - [description] + * @param {number} y1 - [description] + * @param {number} x2 - [description] + * @param {number} y2 - [description] + * + * @return {number} [description] + */ +var DistanceSquared = function (x1, y1, x2, y2) +{ + var dx = x1 - x2; + var dy = y1 - y2; + + return dx * dx + dy * dy; +}; + +module.exports = DistanceSquared; + + +/***/ }), +/* 524 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Distance.Power + * @since 3.0.0 + * + * @param {number} x1 - [description] + * @param {number} y1 - [description] + * @param {number} x2 - [description] + * @param {number} y2 - [description] + * @param {number} pow - [description] + * + * @return {number} [description] + */ +var DistancePower = function (x1, y1, x2, y2, pow) +{ + if (pow === undefined) { pow = 2; } + + return Math.sqrt(Math.pow(x2 - x1, pow) + Math.pow(y2 - y1, pow)); +}; + +module.exports = DistancePower; + + +/***/ }), +/* 525 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Distance + */ + +module.exports = { + + Between: __webpack_require__(48), + Power: __webpack_require__(524), + Squared: __webpack_require__(523) + +}; + + +/***/ }), +/* 526 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Gets the shortest angle between `angle1` and `angle2`. + * Both angles must be in the range -180 to 180, which is the same clamped + * range that `sprite.angle` uses, so you can pass in two sprite angles to + * this method and get the shortest angle back between the two of them. + * + * The angle returned will be in the same range. If the returned angle is + * greater than 0 then it's a counter-clockwise rotation, if < 0 then it's + * a clockwise rotation. + * + * @function Phaser.Math.Angle.ShortestBetween + * @since 3.0.0 + * + * @param {number} angle1 - The first angle in the range -180 to 180. + * @param {number} angle2 - The second angle in the range -180 to 180. + * + * @return {number} The shortest angle, in degrees. If greater than zero it's a counter-clockwise rotation. + */ +var ShortestBetween = function (angle1, angle2) +{ + var difference = angle2 - angle1; + + if (difference === 0) + { + return 0; + } + + var times = Math.floor((difference - (-180)) / 360); + + return difference - (times * 360); + +}; + +module.exports = ShortestBetween; + + +/***/ }), +/* 527 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(16); + +/** + * Rotates `currentAngle` towards `targetAngle`, taking the shortest rotation distance. The `lerp` argument is the amount to rotate by in this call. + * + * @function Phaser.Math.Angle.RotateTo + * @since 3.0.0 + * + * @param {number} currentAngle - The current angle, in radians. + * @param {number} targetAngle - The target angle to rotate to, in radians. + * @param {number} [lerp=0.05] - The lerp value to add to the current angle. + * + * @return {number} The adjusted angle. + */ +var RotateTo = function (currentAngle, targetAngle, lerp) +{ + if (lerp === undefined) { lerp = 0.05; } + + if (currentAngle === targetAngle) + { + return currentAngle; + } + + if (Math.abs(targetAngle - currentAngle) <= lerp || Math.abs(targetAngle - currentAngle) >= (MATH_CONST.PI2 - lerp)) + { + currentAngle = targetAngle; + } + else + { + if (Math.abs(targetAngle - currentAngle) > Math.PI) + { + if (targetAngle < currentAngle) + { + targetAngle += MATH_CONST.PI2; + } + else + { + targetAngle -= MATH_CONST.PI2; + } + } + + if (targetAngle > currentAngle) + { + currentAngle += lerp; + } + else if (targetAngle < currentAngle) + { + currentAngle -= lerp; + } + } + + return currentAngle; +}; + +module.exports = RotateTo; + + +/***/ }), +/* 528 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Normalize = __webpack_require__(220); + +/** + * [description] + * + * @function Phaser.Math.Angle.Reverse + * @since 3.0.0 + * + * @param {number} angle - [description] + * + * @return {number} [description] + */ +var Reverse = function (angle) +{ + return Normalize(angle + Math.PI); +}; + +module.exports = Reverse; + + +/***/ }), +/* 529 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Angle.BetweenPointsY + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point1 - [description] + * @param {(Phaser.Geom.Point|object)} point2 - [description] + * + * @return {number} [description] + */ +var BetweenPointsY = function (point1, point2) +{ + return Math.atan2(point2.x - point1.x, point2.y - point1.y); +}; + +module.exports = BetweenPointsY; + + +/***/ }), +/* 530 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Angle.BetweenPoints + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point1 - [description] + * @param {(Phaser.Geom.Point|object)} point2 - [description] + * + * @return {number} [description] + */ +var BetweenPoints = function (point1, point2) +{ + return Math.atan2(point2.y - point1.y, point2.x - point1.x); +}; + +module.exports = BetweenPoints; + + +/***/ }), +/* 531 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Angle.BetweenY + * @since 3.0.0 + * + * @param {number} x1 - [description] + * @param {number} y1 - [description] + * @param {number} x2 - [description] + * @param {number} y2 - [description] + * + * @return {number} [description] + */ +var BetweenY = function (x1, y1, x2, y2) +{ + return Math.atan2(x2 - x1, y2 - y1); +}; + +module.exports = BetweenY; + + +/***/ }), +/* 532 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Angle.Between + * @since 3.0.0 + * + * @param {number} x1 - [description] + * @param {number} y1 - [description] + * @param {number} x2 - [description] + * @param {number} y2 - [description] + * + * @return {number} [description] + */ +var Between = function (x1, y1, x2, y2) +{ + return Math.atan2(y2 - y1, x2 - x1); +}; + +module.exports = Between; + + +/***/ }), +/* 533 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Angle + */ + +module.exports = { + + Between: __webpack_require__(532), + BetweenY: __webpack_require__(531), + BetweenPoints: __webpack_require__(530), + BetweenPointsY: __webpack_require__(529), + Reverse: __webpack_require__(528), + RotateTo: __webpack_require__(527), + ShortestBetween: __webpack_require__(526), + Normalize: __webpack_require__(220), + Wrap: __webpack_require__(175), + WrapDegrees: __webpack_require__(174) + +}; + + +/***/ }), +/* 534 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(16); +var Extend = __webpack_require__(18); + +/** + * @namespace Phaser.Math + */ + +var PhaserMath = { + + // Collections of functions + Angle: __webpack_require__(533), + Distance: __webpack_require__(525), + Easing: __webpack_require__(522), + Fuzzy: __webpack_require__(521), + Interpolation: __webpack_require__(515), + Pow2: __webpack_require__(511), + Snap: __webpack_require__(509), + + // Single functions + Average: __webpack_require__(505), + Bernstein: __webpack_require__(219), + Between: __webpack_require__(308), + CatmullRom: __webpack_require__(149), + CeilTo: __webpack_require__(504), + Clamp: __webpack_require__(64), + DegToRad: __webpack_require__(42), + Difference: __webpack_require__(503), + Factorial: __webpack_require__(218), + FloatBetween: __webpack_require__(263), + FloorTo: __webpack_require__(502), + FromPercent: __webpack_require__(78), + GetSpeed: __webpack_require__(501), + IsEven: __webpack_require__(500), + IsEvenStrict: __webpack_require__(499), + Linear: __webpack_require__(148), + MaxAdd: __webpack_require__(498), + MinSub: __webpack_require__(497), + Percent: __webpack_require__(496), + RadToDeg: __webpack_require__(318), + RandomXY: __webpack_require__(495), + RandomXYZ: __webpack_require__(330), + RandomXYZW: __webpack_require__(329), + Rotate: __webpack_require__(217), + RotateAround: __webpack_require__(350), + RotateAroundDistance: __webpack_require__(160), + RoundAwayFromZero: __webpack_require__(216), + RoundTo: __webpack_require__(494), + SinCosTableGenerator: __webpack_require__(493), + SmootherStep: __webpack_require__(343), + SmoothStep: __webpack_require__(342), + TransformXY: __webpack_require__(288), + Within: __webpack_require__(492), + Wrap: __webpack_require__(43), + + // Vector classes + Vector2: __webpack_require__(6), + Vector3: __webpack_require__(57), + Vector4: __webpack_require__(152), + Matrix3: __webpack_require__(326), + Matrix4: __webpack_require__(153), + Quaternion: __webpack_require__(327), + RotateVec3: __webpack_require__(328) + +}; + +// Merge in the consts + +PhaserMath = Extend(false, PhaserMath, CONST); + +// Export it + +module.exports = PhaserMath; + + +/***/ }), +/* 535 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var CustomSet = __webpack_require__(63); +var EventEmitter = __webpack_require__(15); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var ParseXMLBitmapFont = __webpack_require__(270); +var PluginManager = __webpack_require__(12); +var XHRSettings = __webpack_require__(94); + +/** + * @typedef {object} LoaderFileObject + * + * @property {string} key - [description] + * @property {string} type - [description] + * @property {string} [url] - [description] + * @property {string[]} [urls] - [description] + * @property {string} [textureURL] - [description] + * @property {string} [atlasURL] - [description] + * @property {string} [xmlURL] - [description] + * @property {string[]} [textureURLs] - [description] + * @property {string[]} [atlasURLs] - [description] + * @property {object} [config] - [description] + * @property {object} [json] - [description] + * @property {XHRSettingsObject} [xhrSettings] - [description] + * @property {XHRSettingsObject} [textureXhrSettings] - [description] + * @property {XHRSettingsObject} [atlasXhrSettings] - [description] + * @property {XHRSettingsObject} [xmlXhrSettings] - [description] + * @property {XHRSettingsObject} [audioXhrSettings] - [description] + * @property {XHRSettingsObject} [jsonXhrSettings] - [description] + */ + +/** + * @classdesc + * [description] + * + * @class LoaderPlugin + * @extends EventEmitter + * @memberOf Phaser.Loader + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ +var LoaderPlugin = new Class({ + + Extends: EventEmitter, + + initialize: + + function LoaderPlugin (scene) + { + EventEmitter.call(this); + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + if (!scene.sys.settings.isBooted) + { + scene.sys.events.once('boot', this.boot, this); + } + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#_multilist + * @type {object} + * @private + * @default {} + * @since 3.0.0 + */ + this._multilist = {}; + + // Inject the available filetypes into the Loader + FileTypesManager.install(this); + + var gameConfig = this.systems.game.config; + var sceneConfig = this.systems.settings.loader; + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#path + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.path = ''; + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#baseURL + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.baseURL = ''; + + this.setBaseURL(GetFastValue(sceneConfig, 'baseURL', gameConfig.loaderBaseURL)); + + this.setPath(GetFastValue(sceneConfig, 'path', gameConfig.loaderPath)); + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#enableParallel + * @type {boolean} + * @since 3.0.0 + */ + this.enableParallel = GetFastValue(sceneConfig, 'enableParallel', gameConfig.loaderEnableParallel); + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#maxParallelDownloads + * @type {integer} + * @since 3.0.0 + */ + this.maxParallelDownloads = GetFastValue(sceneConfig, 'maxParallelDownloads', gameConfig.loaderMaxParallelDownloads); + + /** + * xhr specific global settings (can be overridden on a per-file basis) + * + * @name Phaser.Loader.LoaderPlugin#xhr + * @type {XHRSettingsObject} + * @since 3.0.0 + */ + this.xhr = XHRSettings( + GetFastValue(sceneConfig, 'responseType', gameConfig.loaderResponseType), + GetFastValue(sceneConfig, 'async', gameConfig.loaderAsync), + GetFastValue(sceneConfig, 'user', gameConfig.loaderUser), + GetFastValue(sceneConfig, 'password', gameConfig.loaderPassword), + GetFastValue(sceneConfig, 'timeout', gameConfig.loaderTimeout) + ); + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#crossOrigin + * @type {string} + * @since 3.0.0 + */ + this.crossOrigin = GetFastValue(sceneConfig, 'crossOrigin', gameConfig.loaderCrossOrigin); + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#totalToLoad + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalToLoad = 0; + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#progress + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.progress = 0; + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#list + * @type {Phaser.Structs.Set} + * @since 3.0.0 + */ + this.list = new CustomSet(); + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#inflight + * @type {Phaser.Structs.Set} + * @since 3.0.0 + */ + this.inflight = new CustomSet(); + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#failed + * @type {Phaser.Structs.Set} + * @since 3.0.0 + */ + this.failed = new CustomSet(); + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#queue + * @type {Phaser.Structs.Set} + * @since 3.0.0 + */ + this.queue = new CustomSet(); + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#storage + * @type {Phaser.Structs.Set} + * @since 3.0.0 + */ + this.storage = new CustomSet(); + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#state + * @type {integer} + * @since 3.0.0 + */ + this.state = CONST.LOADER_IDLE; + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#boot + * @since 3.0.0 + */ + boot: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#setBaseURL + * @since 3.0.0 + * + * @param {string} url - [description] + * + * @return {Phaser.Loader.LoaderPlugin} This Loader object. + */ + setBaseURL: function (url) + { + if (url !== '' && url.substr(-1) !== '/') + { + url = url.concat('/'); + } + + this.baseURL = url; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#setPath + * @since 3.0.0 + * + * @param {string} path - [description] + * + * @return {Phaser.Loader.LoaderPlugin} This Loader object. + */ + setPath: function (path) + { + if (path !== '' && path.substr(-1) !== '/') + { + path = path.concat('/'); + } + + this.path = path; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#setCORS + * @since 3.0.0 + * + * @param {string} crossOrigin - [description] + * + * @return {Phaser.Loader.LoaderPlugin} This Loader object. + */ + setCORS: function (crossOrigin) + { + this.crossOrigin = crossOrigin; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#addFile + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - [description] + * + * @return {Phaser.Loader.File} [description] + */ + addFile: function (file) + { + if (!this.isReady()) + { + return -1; + } + + file.path = this.path; + + this.list.set(file); + + return file; + }, + + /** + * Is the Loader actively loading (or processing loaded files) + * + * @method Phaser.Loader.LoaderPlugin#isLoading + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isLoading: function () + { + return (this.state === CONST.LOADER_LOADING || this.state === CONST.LOADER_PROCESSING); + }, + + /** + * Is the Loader ready to start a new load? + * + * @method Phaser.Loader.LoaderPlugin#isReady + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isReady: function () + { + return (this.state === CONST.LOADER_IDLE || this.state === CONST.LOADER_COMPLETE || this.state === CONST.LOADER_FAILED); + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#start + * @since 3.0.0 + */ + start: function () + { + if (!this.isReady()) + { + return; + } + + this.progress = 0; + this.totalToLoad = this.list.size; + + this.emit('start', this); + + if (this.list.size === 0) + { + this.finishedLoading(); + } + else + { + this.state = CONST.LOADER_LOADING; + + this.failed.clear(); + this.inflight.clear(); + this.queue.clear(); + + this.queue.debug = true; + + this.updateProgress(); + + this.processLoadQueue(); + } + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#updateProgress + * @since 3.0.0 + */ + updateProgress: function () + { + this.progress = 1 - ((this.list.size + this.inflight.size) / this.totalToLoad); + + this.emit('progress', this.progress); + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#processLoadQueue + * @since 3.0.0 + */ + processLoadQueue: function () + { + this.list.each(function (file) + { + if (file.state === CONST.FILE_POPULATED || (file.state === CONST.FILE_PENDING && this.inflight.size < this.maxParallelDownloads)) + { + this.inflight.set(file); + + this.list.delete(file); + + this.loadFile(file); + } + + if (this.inflight.size === this.maxParallelDownloads) + { + // Tells the Set iterator to abort + return false; + } + + }, this); + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#loadFile + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - [description] + */ + loadFile: function (file) + { + // If the file doesn't have its own crossOrigin set, + // we'll use the Loaders (which is undefined by default) + if (!file.crossOrigin) + { + file.crossOrigin = this.crossOrigin; + } + + file.load(this); + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#nextFile + * @since 3.0.0 + * + * @param {Phaser.Loader.File} previousFile - [description] + * @param {boolean} success - [description] + */ + nextFile: function (previousFile, success) + { + // Move the file that just loaded from the inflight list to the queue or failed Set + + if (success) + { + this.emit('load', previousFile); + this.queue.set(previousFile); + } + else + { + this.emit('loaderror', previousFile); + this.failed.set(previousFile); + } + + this.inflight.delete(previousFile); + + this.updateProgress(); + + if (this.list.size > 0) + { + this.processLoadQueue(); + } + else if (this.inflight.size === 0) + { + this.finishedLoading(); + } + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#finishedLoading + * @since 3.0.0 + */ + finishedLoading: function () + { + if (this.state === CONST.LOADER_PROCESSING) + { + return; + } + + this.progress = 1; + + this.state = CONST.LOADER_PROCESSING; + + this.storage.clear(); + + if (this.queue.size === 0) + { + // Everything failed, so nothing to process + this.processComplete(); + } + else + { + this.queue.each(function (file) + { + file.onProcess(this.processUpdate.bind(this)); + }, this); + } + }, + + /** + * Called automatically by the File when it has finished processing. + * + * @method Phaser.Loader.LoaderPlugin#processUpdate + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - [description] + */ + processUpdate: function (file) + { + // This file has failed to load, so move it to the failed Set + if (file.state === CONST.FILE_ERRORED) + { + this.failed.set(file); + + if (file.linkFile) + { + this.queue.delete(file.linkFile); + } + + return this.removeFromQueue(file); + } + + // If we got here, then the file loaded + + // Special handling for multi-part files + + if (file.linkFile) + { + if (file.state === CONST.FILE_COMPLETE && file.linkFile.state === CONST.FILE_COMPLETE) + { + // Partner has loaded, so add them both to Storage + + this.storage.set({ type: file.linkType, fileA: file, fileB: file.linkFile }); + + this.queue.delete(file.linkFile); + + this.removeFromQueue(file); + } + } + else + { + this.storage.set(file); + + this.removeFromQueue(file); + } + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#removeFromQueue + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - [description] + */ + removeFromQueue: function (file) + { + this.queue.delete(file); + + if (this.queue.size === 0 && this.state === CONST.LOADER_PROCESSING) + { + // We've processed all the files we loaded + this.processComplete(); + } + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#processComplete + * @since 3.0.0 + */ + processComplete: function () + { + this.list.clear(); + this.inflight.clear(); + this.queue.clear(); + + this.processCallback(); + + this.state = CONST.LOADER_COMPLETE; + + this.emit('complete', this, this.storage.size, this.failed.size); + + // Move to a User setting: + // this.removeAllListeners(); + }, + + /** + * The Loader has finished. + * + * @method Phaser.Loader.LoaderPlugin#processCallback + * @since 3.0.0 + */ + processCallback: function () + { + if (this.storage.size === 0) + { + return; + } + + // The global Texture Manager + var cache = this.scene.sys.cache; + var textures = this.scene.sys.textures; + var anims = this.scene.sys.anims; + + // Process multiatlas groups first + + var file; + var fileA; + var fileB; + + for (var key in this._multilist) + { + var data = []; + var images = []; + var keys = this._multilist[key]; + + for (var i = 0; i < keys.length; i++) + { + file = this.storage.get('key', keys[i]); + + if (file) + { + if (file.type === 'image') + { + images.push(file.data); + } + else if (file.type === 'json') + { + data.push(file.data); + } + + this.storage.delete(file); + } + } + + // Do we have everything needed? + if (images.length + data.length === keys.length) + { + // Yup, add them to the Texture Manager + + // Is the data JSON Hash or JSON Array? + if (Array.isArray(data[0].textures) || Array.isArray(data[0].frames)) + { + textures.addAtlasJSONArray(key, images, data); + } + else + { + textures.addAtlasJSONHash(key, images, data); + } + } + } + + // Process all of the files + + // Because AnimationJSON may require images to be loaded first, we process them last + var animJSON = []; + + this.storage.each(function (file) + { + switch (file.type) + { + case 'animationJSON': + animJSON.push(file); + break; + + case 'image': + case 'svg': + case 'html': + textures.addImage(file.key, file.data); + break; + + case 'atlasjson': + + fileA = file.fileA; + fileB = file.fileB; + + if (fileA.type === 'image') + { + textures.addAtlas(fileA.key, fileA.data, fileB.data); + } + else + { + textures.addAtlas(fileB.key, fileB.data, fileA.data); + } + break; + + case 'dataimage': + + fileA = file.fileA; + fileB = file.fileB; + + if (fileA.linkParent) + { + textures.addImage(fileA.key, fileA.data, fileB.data); + } + else + { + textures.addImage(fileB.key, fileB.data, fileA.data); + } + break; + + case 'unityatlas': + + fileA = file.fileA; + fileB = file.fileB; + + if (fileA.type === 'image') + { + textures.addUnityAtlas(fileA.key, fileA.data, fileB.data); + } + else + { + textures.addUnityAtlas(fileB.key, fileB.data, fileA.data); + } + break; + + case 'bitmapfont': + + fileA = file.fileA; + fileB = file.fileB; + + if (fileA.type === 'image') + { + cache.bitmapFont.add(fileB.key, { data: ParseXMLBitmapFont(fileB.data), texture: fileA.key, frame: null }); + textures.addImage(fileA.key, fileA.data); + } + else + { + cache.bitmapFont.add(fileA.key, { data: ParseXMLBitmapFont(fileA.data), texture: fileB.key, frame: null }); + textures.addImage(fileB.key, fileB.data); + } + break; + + case 'spritesheet': + textures.addSpriteSheet(file.key, file.data, file.config); + break; + + case 'json': + cache.json.add(file.key, file.data); + break; + + case 'xml': + cache.xml.add(file.key, file.data); + break; + + case 'text': + cache.text.add(file.key, file.data); + break; + + case 'obj': + cache.obj.add(file.key, file.data); + break; + + case 'binary': + cache.binary.add(file.key, file.data); + break; + + case 'audio': + cache.audio.add(file.key, file.data); + break; + + case 'audioSprite': + + var files = [ file.fileA, file.fileB ]; + + files.forEach(function (file) + { + cache[file.type].add(file.key, file.data); + }); + + break; + + case 'glsl': + cache.shader.add(file.key, file.data); + break; + + case 'tilemapCSV': + case 'tilemapJSON': + cache.tilemap.add(file.key, { format: file.tilemapFormat, data: file.data }); + break; + } + }); + + animJSON.forEach(function (file) + { + anims.fromJSON(file.data); + }); + + this.storage.clear(); + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#saveJSON + * @since 3.0.0 + * + * @param {*} data - [description] + * @param {string} [filename=file.json] - [description] + * + * @return {Phaser.Loader.LoaderPlugin} This Loader plugin. + */ + saveJSON: function (data, filename) + { + return this.save(JSON.stringify(data), filename); + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#save + * @since 3.0.0 + * + * @param {*} data - [description] + * @param {string} [filename=file.json] - [description] + * @param {string} [filetype=application/json] - [description] + * + * @return {Phaser.Loader.LoaderPlugin} This Loader plugin. + */ + save: function (data, filename, filetype) + { + if (filename === undefined) { filename = 'file.json'; } + if (filetype === undefined) { filetype = 'application/json'; } + + var blob = new Blob([ data ], { type: filetype }); + + var url = URL.createObjectURL(blob); + + var a = document.createElement('a'); + + a.download = filename; + a.textContent = 'Download ' + filename; + a.href = url; + a.click(); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#reset + * @since 3.0.0 + */ + reset: function () + { + this.list.clear(); + this.inflight.clear(); + this.failed.clear(); + this.queue.clear(); + this.storage.clear(); + + var gameConfig = this.systems.game.config; + var sceneConfig = this.systems.settings.loader; + + this.setBaseURL(GetFastValue(sceneConfig, 'baseURL', gameConfig.loaderBaseURL)); + this.setPath(GetFastValue(sceneConfig, 'path', gameConfig.loaderPath)); + + this.state = CONST.LOADER_IDLE; + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#loadArray + * @since 3.0.0 + * + * @param {LoaderFileObject[]} files - [description] + * + * @return {boolean} [description] + */ + loadArray: function (files) + { + if (Array.isArray(files)) + { + for (var i = 0; i < files.length; i++) + { + this.file(files[i]); + } + } + + return (this.list.size > 0); + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#file + * @since 3.0.0 + * + * @param {LoaderFileObject} file - [description] + * + * @return {Phaser.Loader.File} [description] + */ + file: function (file) + { + var entry; + var key = file.key; + + switch (file.type) + { + case 'spritesheet': + entry = this.spritesheet(key, file.url, file.config, file.xhrSettings); + break; + + case 'atlas': + entry = this.atlas(key, file.textureURL, file.atlasURL, file.textureXhrSettings, file.atlasXhrSettings); + break; + + case 'bitmapFont': + entry = this.bitmapFont(key, file.textureURL, file.xmlURL, file.textureXhrSettings, file.xmlXhrSettings); + break; + + case 'multiatlas': + entry = this.multiatlas(key, file.textureURLs, file.atlasURLs, file.textureXhrSettings, file.atlasXhrSettings); + break; + + case 'audioSprite': + entry = this.audioSprite(key, file.urls, file.json, file.config, file.audioXhrSettings, file.jsonXhrSettings); + break; + + // image, json, xml, binary, text, glsl, svg, obj + default: + entry = this[file.type](key, file.url, file.xhrSettings); + break; + } + + return entry; + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.reset(); + this.state = CONST.LOADER_SHUTDOWN; + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.reset(); + this.state = CONST.LOADER_DESTROYED; + } + +}); + +PluginManager.register('Loader', LoaderPlugin, 'load'); + +module.exports = LoaderPlugin; + + +/***/ }), +/* 536 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FileTypesManager = __webpack_require__(7); +var ImageFile = __webpack_require__(50); +var TextFile = __webpack_require__(221); + +/** + * An Atlas JSON File. + * + * @function Phaser.Loader.FileTypes.UnityAtlasFile + * @since 3.0.0 + * + * @param {string} key - The key of the file within the loader. + * @param {string} textureURL - The url to load the texture file from. + * @param {string} atlasURL - The url to load the atlas file from. + * @param {string} path - The path of the file. + * @param {XHRSettingsObject} textureXhrSettings - Optional texture file specific XHR settings. + * @param {XHRSettingsObject} atlasXhrSettings - Optional atlas file specific XHR settings. + * + * @return {object} An object containing two File objects to be added to the loader. + */ +var UnityAtlasFile = function (key, textureURL, atlasURL, path, textureXhrSettings, atlasXhrSettings) +{ + var image = new ImageFile(key, textureURL, path, textureXhrSettings); + var data = new TextFile(key, atlasURL, path, atlasXhrSettings); + + // Link them together + image.linkFile = data; + data.linkFile = image; + + // Set the type + image.linkType = 'unityatlas'; + data.linkType = 'unityatlas'; + + return { texture: image, data: data }; +}; + +/** + * Adds a Unity Texture Atlas file to the current load queue. + * + * Note: This method will only be available if the Unity Atlas File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#unityAtlas + * @since 3.0.0 + * + * @param {string} key - The key of the file within the loader. + * @param {string} textureURL - The url to load the texture file from. + * @param {string} atlasURL - The url to load the atlas file from. + * @param {XHRSettingsObject} textureXhrSettings - Optional texture file specific XHR settings. + * @param {XHRSettingsObject} atlasXhrSettings - Optional atlas file specific XHR settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('unityAtlas', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) +{ + // Returns an object with two properties: 'texture' and 'data' + var files = new UnityAtlasFile(key, textureURL, atlasURL, this.path, textureXhrSettings, atlasXhrSettings); + + this.addFile(files.texture); + this.addFile(files.data); + + return this; + +}); + +module.exports = UnityAtlasFile; + + +/***/ }), +/* 537 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FileTypesManager = __webpack_require__(7); +var JSONFile = __webpack_require__(51); +var TILEMAP_FORMATS = __webpack_require__(24); + +/** + * A Tilemap File. + * + * @function Phaser.Loader.FileTypes.TilemapJSONFile + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {string} format - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {object} An object containing two File objects to be added to the loader. + */ +var TilemapJSONFile = function (key, url, path, format, xhrSettings) +{ + var json = new JSONFile(key, url, path, xhrSettings); + + // Override the File type + json.type = 'tilemapJSON'; + + json.tilemapFormat = format; + + return json; +}; + +/** + * Adds a Tilemap (Tiled JSON Format) file to the current load queue. + * + * Note: This method will only be available if the Tilemap File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#tilemapTiledJSON + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('tilemapTiledJSON', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(TilemapJSONFile(key[i], url, this.path, TILEMAP_FORMATS.TILED_JSON, xhrSettings)); + } + } + else + { + this.addFile(TilemapJSONFile(key, url, this.path, TILEMAP_FORMATS.TILED_JSON, xhrSettings)); + } + + // For method chaining + return this; +}); + +/** + * Adds a Tilemap (Weltmeister Format) file to the current load queue. + * + * Note: This method will only be available if the Tilemap File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#tilemapWeltmeister + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('tilemapWeltmeister', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(TilemapJSONFile(key[i], url, this.path, TILEMAP_FORMATS.WELTMEISTER, xhrSettings)); + } + } + else + { + this.addFile(TilemapJSONFile(key, url, this.path, TILEMAP_FORMATS.WELTMEISTER, xhrSettings)); + } + + // For method chaining + return this; +}); + +module.exports = TilemapJSONFile; + + +/***/ }), +/* 538 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); +var TILEMAP_FORMATS = __webpack_require__(24); + +/** + * @classdesc + * [description] + * + * @class TilemapCSVFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {string} format - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + */ +var TilemapCSVFile = new Class({ + + Extends: File, + + initialize: + + function TilemapCSVFile (key, url, path, format, xhrSettings) + { + var fileConfig = { + type: 'tilemapCSV', + extension: '.csv', + responseType: 'text', + key: key, + url: url, + path: path, + xhrSettings: xhrSettings + }; + + File.call(this, fileConfig); + + this.tilemapFormat = format; + }, + + onProcess: function (callback) + { + this.state = CONST.FILE_PROCESSING; + + this.data = this.xhrLoader.responseText; + + this.onComplete(); + + callback(this); + } + +}); + +/** + * Adds a Tilemap CSV file to the current load queue. + * + * Note: This method will only be available if the Tilemap CSV File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#tilemapCSV + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('tilemapCSV', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new TilemapCSVFile(key[i], url, this.path, TILEMAP_FORMATS.CSV, xhrSettings)); + } + } + else + { + this.addFile(new TilemapCSVFile(key, url, this.path, TILEMAP_FORMATS.CSV, xhrSettings)); + } + + // For method chaining + return this; +}); + +module.exports = TilemapCSVFile; + + +/***/ }), +/* 539 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); + +/** + * @classdesc + * [description] + * + * @class SVGFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + */ +var SVGFile = new Class({ + + Extends: File, + + initialize: + + function SVGFile (key, url, path, xhrSettings) + { + var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); + + var fileConfig = { + type: 'svg', + extension: GetFastValue(key, 'extension', 'svg'), + responseType: 'text', + key: fileKey, + url: GetFastValue(key, 'file', url), + path: path, + xhrSettings: GetFastValue(key, 'xhr', xhrSettings) + }; + + File.call(this, fileConfig); + }, + + onProcess: function (callback) + { + this.state = CONST.FILE_PROCESSING; + + var svg = [ this.xhrLoader.responseText ]; + var _this = this; + + try + { + var blob = new window.Blob(svg, { type: 'image/svg+xml;charset=utf-8' }); + } + catch (e) + { + _this.state = CONST.FILE_ERRORED; + + callback(_this); + + return; + } + + this.data = new Image(); + + this.data.crossOrigin = this.crossOrigin; + + var retry = false; + + this.data.onload = function () + { + if(!retry) + { + File.revokeObjectURL(_this.data); + } + + _this.onComplete(); + + callback(_this); + }; + + this.data.onerror = function () + { + // Safari 8 re-try + if (!retry) + { + retry = true; + + File.revokeObjectURL(_this.data); + + _this.data.src = 'data:image/svg+xml,' + encodeURIComponent(svg.join('')); + } + else + { + _this.state = CONST.FILE_ERRORED; + + callback(_this); + } + }; + + File.createObjectURL(this.data, blob, 'image/svg+xml'); + } + +}); + +/** + * Adds an SVG file to the current load queue. + * + * Note: This method will only be available if the SVG File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#svg + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('svg', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new SVGFile(key[i], url, this.path, xhrSettings)); + } + } + else + { + this.addFile(new SVGFile(key, url, this.path, xhrSettings)); + } + + // For method chaining + return this; +}); + +module.exports = SVGFile; + + +/***/ }), +/* 540 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FileTypesManager = __webpack_require__(7); +var ImageFile = __webpack_require__(50); + +/** + * A Sprite Sheet File. + * + * @function Phaser.Loader.FileTypes.SpriteSheetFile + * @since 3.0.0 + * + * @param {string} key - The key of the file within the loader. + * @param {string} url - The url to load the texture file from. + * @param {object} config - Optional texture file specific XHR settings. + * @param {string} path - Optional texture file specific XHR settings. + * @param {XHRSettingsObject} xhrSettings - Optional atlas file specific XHR settings. + * + * @return {object} An object containing two File objects to be added to the loader. + */ +var SpriteSheetFile = function (key, url, config, path, xhrSettings) +{ + var image = new ImageFile(key, url, path, xhrSettings, config); + + // Override the File type + image.type = 'spritesheet'; + + return image; +}; + +/** + * Adds a Sprite Sheet file to the current load queue. + * + * Note: This method will only be available if the Sprite Sheet File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#spritesheet + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {object} config - config can include: frameWidth, frameHeight, startFrame, endFrame, margin, spacing. + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('spritesheet', function (key, url, config, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new SpriteSheetFile(key[i], url, null, this.path, xhrSettings)); + } + } + else + { + this.addFile(new SpriteSheetFile(key, url, config, this.path, xhrSettings)); + } + + // For method chaining + return this; +}); + +module.exports = SpriteSheetFile; + + +/***/ }), +/* 541 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); + +/** + * @classdesc + * [description] + * + * @class ScriptFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + */ +var ScriptFile = new Class({ + + Extends: File, + + initialize: + + function ScriptFile (key, url, path, xhrSettings) + { + var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); + + var fileConfig = { + type: 'script', + extension: GetFastValue(key, 'extension', 'js'), + responseType: 'text', + key: fileKey, + url: GetFastValue(key, 'file', url), + path: path, + xhrSettings: GetFastValue(key, 'xhr', xhrSettings) + }; + + File.call(this, fileConfig); + }, + + onProcess: function (callback) + { + this.state = CONST.FILE_PROCESSING; + + this.data = document.createElement('script'); + this.data.language = 'javascript'; + this.data.type = 'text/javascript'; + this.data.defer = false; + this.data.text = this.xhrLoader.responseText; + + document.head.appendChild(this.data); + + this.onComplete(); + + callback(this); + } + +}); + +/** + * Adds a JavaScript file to the current load queue. + * + * Note: This method will only be available if the Script File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#script + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('script', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new ScriptFile(key[i], url, this.path, xhrSettings)); + } + } + else + { + this.addFile(new ScriptFile(key, url, this.path, xhrSettings)); + } + + // For method chaining + return this; +}); + +module.exports = ScriptFile; + + +/***/ }), +/* 542 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var PluginManager = __webpack_require__(12); + +/** + * @classdesc + * [description] + * + * @class PluginFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + */ +var PluginFile = new Class({ + + Extends: File, + + initialize: + + function PluginFile (key, url, path, xhrSettings) + { + // If the url variable refers to a class, add the plugin directly + if (typeof url === 'function') + { + this.key = key; + window[key] = url; + window[key].register(PluginManager); + } + + var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); + + var fileConfig = { + type: 'script', + extension: GetFastValue(key, 'extension', 'js'), + responseType: 'text', + key: fileKey, + url: GetFastValue(key, 'file', url), + path: path, + xhrSettings: GetFastValue(key, 'xhr', xhrSettings) + }; + + File.call(this, fileConfig); + }, + + onProcess: function (callback) + { + this.state = CONST.FILE_PROCESSING; + + this.data = document.createElement('script'); + this.data.language = 'javascript'; + this.data.type = 'text/javascript'; + this.data.defer = false; + this.data.text = this.xhrLoader.responseText; + + document.head.appendChild(this.data); + + // Need to wait for onload? + window[this.key].register(PluginManager); + + this.onComplete(); + + callback(this); + } + +}); + +/** + * Adds a Plugin file to the current load queue. + * + * Note: This method will only be available if the Plugin File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#plugin + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('plugin', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new PluginFile(key[i], url, this.path, xhrSettings)); + } + } + else + { + this.addFile(new PluginFile(key, url, this.path, xhrSettings)); + } + + // For method chaining + return this; +}); + +module.exports = PluginFile; + + +/***/ }), +/* 543 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FileTypesManager = __webpack_require__(7); +var ImageFile = __webpack_require__(50); +var JSONFile = __webpack_require__(51); +var NumberArray = __webpack_require__(222); + +/** + * Adds a Multi File Texture Atlas to the current load queue. + * + * Note: This method will only be available if the Multi Atlas File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#multiatlas + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string[]} textureURLs - [description] + * @param {string[]} atlasURLs - [description] + * @param {XHRSettingsObject} textureXhrSettings - [description] + * @param {XHRSettingsObject} atlasXhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('multiatlas', function (key, textureURLs, atlasURLs, textureXhrSettings, atlasXhrSettings) +{ + if (typeof textureURLs === 'number') + { + var total = textureURLs; + var suffix = (atlasURLs === undefined) ? '' : atlasURLs; + + textureURLs = NumberArray(0, total, key + suffix, '.png'); + atlasURLs = NumberArray(0, total, key + suffix, '.json'); + } + else + { + if (!Array.isArray(textureURLs)) + { + textureURLs = [ textureURLs ]; + } + + if (!Array.isArray(atlasURLs)) + { + atlasURLs = [ atlasURLs ]; + } + } + + var file; + var i = 0; + var multiKey; + + this._multilist[key] = []; + + for (i = 0; i < textureURLs.length; i++) + { + multiKey = '_MA_IMG_' + key + '_' + i.toString(); + + file = new ImageFile(multiKey, textureURLs[i], this.path, textureXhrSettings); + + this.addFile(file); + + this._multilist[key].push(multiKey); + } + + for (i = 0; i < atlasURLs.length; i++) + { + multiKey = '_MA_JSON_' + key + '_' + i.toString(); + + file = new JSONFile(multiKey, atlasURLs[i], this.path, atlasXhrSettings); + + this.addFile(file); + + this._multilist[key].push(multiKey); + } + + return this; +}); + + +/***/ }), +/* 544 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); + +/** + * @classdesc + * [description] + * + * @class HTMLFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {string} path - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + */ +var HTMLFile = new Class({ + + Extends: File, + + initialize: + + function HTMLFile (key, url, width, height, path, xhrSettings) + { + if (width === undefined) { width = 512; } + if (height === undefined) { height = 512; } + + var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); + + var fileConfig = { + type: 'html', + extension: GetFastValue(key, 'extension', 'html'), + responseType: 'text', + key: fileKey, + url: GetFastValue(key, 'file', url), + path: path, + xhrSettings: GetFastValue(key, 'xhr', xhrSettings), + config: { + width: width, + height: height + } + }; + + File.call(this, fileConfig); + }, + + onProcess: function (callback) + { + this.state = CONST.FILE_PROCESSING; + + var w = this.config.width; + var h = this.config.height; + + var data = []; + + data.push(''); + data.push(''); + data.push(''); + data.push(this.xhrLoader.responseText); + data.push(''); + data.push(''); + data.push(''); + + var svg = [ data.join('\n') ]; + var _this = this; + + try + { + var blob = new window.Blob(svg, { type: 'image/svg+xml;charset=utf-8' }); + } + catch (e) + { + _this.state = CONST.FILE_ERRORED; + + callback(_this); + + return; + } + + this.data = new Image(); + + this.data.crossOrigin = this.crossOrigin; + + this.data.onload = function () + { + File.revokeObjectURL(_this.data); + + _this.onComplete(); + + callback(_this); + }; + + this.data.onerror = function () + { + File.revokeObjectURL(_this.data); + + _this.state = CONST.FILE_ERRORED; + + callback(_this); + }; + + File.createObjectURL(this.data, blob, 'image/svg+xml'); + } + +}); + +/** + * Adds an HTML file to the current load queue. + * + * Note: This method will only be available if the HTML File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#html + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('html', function (key, url, width, height, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new HTMLFile(key[i], url, width, height, this.path, xhrSettings)); + } + } + else + { + this.addFile(new HTMLFile(key, url, width, height, this.path, xhrSettings)); + } + + // For method chaining + return this; +}); + +module.exports = HTMLFile; + + +/***/ }), +/* 545 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); + +/** + * @classdesc + * [description] + * + * @class GLSLFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + */ +var GLSLFile = new Class({ + + Extends: File, + + initialize: + + function GLSLFile (key, url, path, xhrSettings) + { + var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); + + var fileConfig = { + type: 'glsl', + extension: GetFastValue(key, 'extension', 'glsl'), + responseType: 'text', + key: fileKey, + url: GetFastValue(key, 'file', url), + path: path, + xhrSettings: GetFastValue(key, 'xhr', xhrSettings) + }; + + File.call(this, fileConfig); + }, + + onProcess: function (callback) + { + this.state = CONST.FILE_PROCESSING; + + this.data = this.xhrLoader.responseText; + + this.onComplete(); + + callback(this); + } + +}); + +/** + * Adds a GLSL file to the current load queue. + * + * Note: This method will only be available if the GLSL File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#glsl + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('glsl', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new GLSLFile(key[i], url, this.path, xhrSettings)); + } + } + else + { + this.addFile(new GLSLFile(key, url, this.path, xhrSettings)); + } + + // For method chaining + return this; +}); + +module.exports = GLSLFile; + + +/***/ }), +/* 546 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FileTypesManager = __webpack_require__(7); +var ImageFile = __webpack_require__(50); +var XMLFile = __webpack_require__(223); + +/** + * An Bitmap Font File. + * + * @function Phaser.Loader.FileTypes.BitmapFontFile + * @since 3.0.0 + * + * @param {string} key - The key of the file within the loader. + * @param {string} textureURL - The url to load the texture file from. + * @param {string} xmlURL - The url to load the atlas file from. + * @param {string} path - The path of the file. + * @param {XHRSettingsObject} textureXhrSettings - Optional texture file specific XHR settings. + * @param {XHRSettingsObject} xmlXhrSettings - Optional atlas file specific XHR settings. + * + * @return {object} An object containing two File objects to be added to the loader. + */ +var BitmapFontFile = function (key, textureURL, xmlURL, path, textureXhrSettings, xmlXhrSettings) +{ + var image = new ImageFile(key, textureURL, path, textureXhrSettings); + var data = new XMLFile(key, xmlURL, path, xmlXhrSettings); + + // Link them together + image.linkFile = data; + data.linkFile = image; + + // Set the type + image.linkType = 'bitmapfont'; + data.linkType = 'bitmapfont'; + + return { texture: image, data: data }; +}; + +/** + * Adds a Bitmap Font file to the current load queue. + * + * Note: This method will only be available if the Bitmap Font File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#bitmapFont + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} textureURL - [description] + * @param {string} xmlURL - [description] + * @param {XHRSettingsObject} textureXhrSettings - [description] + * @param {XHRSettingsObject} xmlXhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('bitmapFont', function (key, textureURL, xmlURL, textureXhrSettings, xmlXhrSettings) +{ + // Returns an object with two properties: 'texture' and 'data' + var files = new BitmapFontFile(key, textureURL, xmlURL, this.path, textureXhrSettings, xmlXhrSettings); + + this.addFile(files.texture); + this.addFile(files.data); + + return this; +}); + +module.exports = BitmapFontFile; /***/ }), @@ -90694,28 +89089,100 @@ module.exports = UpdateList; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var ParseXMLBitmapFont = __webpack_require__(269); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); -var ParseFromAtlas = function (scene, fontName, textureKey, frameKey, xmlKey, xSpacing, ySpacing) -{ - var frame = scene.sys.textures.getFrame(textureKey, frameKey); - var xml = scene.sys.cache.xml.get(xmlKey); +/** + * @classdesc + * [description] + * + * @class BinaryFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + */ +var BinaryFile = new Class({ - if (frame && xml) + Extends: File, + + initialize: + + function BinaryFile (key, url, path, xhrSettings) { - var data = ParseXMLBitmapFont(xml, xSpacing, ySpacing, frame); + var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); - scene.sys.cache.bitmapFont.add(fontName, { data: data, texture: textureKey, frame: frameKey }); + var fileConfig = { + type: 'binary', + extension: GetFastValue(key, 'extension', 'bin'), + responseType: 'arraybuffer', + key: fileKey, + url: GetFastValue(key, 'file', url), + path: path, + xhrSettings: GetFastValue(key, 'xhr', xhrSettings) + }; - return true; + File.call(this, fileConfig); + }, + + onProcess: function (callback) + { + this.state = CONST.FILE_PROCESSING; + + this.data = this.xhrLoader.response; + + this.onComplete(); + + callback(this); + } + +}); + +/** + * Adds Binary file to the current load queue. + * + * Note: This method will only be available if the Binary File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#binary + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('binary', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new BinaryFile(key[i], url, this.path, xhrSettings)); + } } else { - return false; + this.addFile(new BinaryFile(key, url, this.path, xhrSettings)); } -}; -module.exports = ParseFromAtlas; + // For method chaining + return this; +}); + +module.exports = BinaryFile; /***/ }), @@ -90728,189 +89195,68 @@ module.exports = ParseFromAtlas; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetValue = __webpack_require__(4); +var AudioFile = __webpack_require__(225); +var CONST = __webpack_require__(17); +var FileTypesManager = __webpack_require__(7); +var JSONFile = __webpack_require__(51); -// * @param {number} characterWidth - The width of each character in the font set. -// * @param {number} characterHeight - The height of each character in the font set. -// * @param {string} chars - The characters used in the font set, in display order. You can use the TEXT_SET consts for common font set arrangements. -// * @param {number} [charsPerRow] - The number of characters per row in the font set. If not given charsPerRow will be the image width / characterWidth. -// * @param {number} [xSpacing=0] - If the characters in the font set have horizontal spacing between them set the required amount here. -// * @param {number} [ySpacing=0] - If the characters in the font set have vertical spacing between them set the required amount here. -// * @param {number} [xOffset=0] - If the font set doesn't start at the top left of the given image, specify the X coordinate offset here. -// * @param {number} [yOffset=0] - If the font set doesn't start at the top left of the given image, specify the Y coordinate offset here. -// Phaser.GameObject.RetroFont = function (game, key, characterWidth, characterHeight, chars, charsPerRow, xSpacing, ySpacing, xOffset, yOffset) - -// { -// image: key, -// width: 32, -// height: 32, -// chars: 'string', -// charsPerRow: null, -// spacing: { x: 0, y: 0 }, -// offset: { x: 0, y: 0 } -// } - -var ParseRetroFont = function (scene, config) +/** + * Adds an Audio Sprite file to the current load queue. + * + * Note: This method will only be available if the Audio Sprite File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#audioSprite + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {(string|string[])} urls - [description] + * @param {object} json - [description] + * @param {object} config - [description] + * @param {XHRSettingsObject} audioXhrSettings - Optional file specific XHR settings. + * @param {XHRSettingsObject} jsonXhrSettings - Optional file specific XHR settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('audioSprite', function (key, urls, json, config, audioXhrSettings, jsonXhrSettings) { - var w = config.width; - var h = config.height; - var cx = Math.floor(w / 2); - var cy = Math.floor(h / 2); - var letters = config.chars; + var audioFile = AudioFile.create(this, key, urls, config, audioXhrSettings); - var key = GetValue(config, 'image', ''); - var offsetX = GetValue(config, 'offset.x', 0); - var offsetY = GetValue(config, 'offset.y', 0); - var spacingX = GetValue(config, 'spacing.x', 0); - var spacingY = GetValue(config, 'spacing.y', 0); - - var charsPerRow = GetValue(config, 'charsPerRow', null); - - if (charsPerRow === null) + if (audioFile) { - charsPerRow = scene.sys.textures.getFrame(key).width / w; + var jsonFile; - if (charsPerRow > letters.length) + if (typeof json === 'string') { - charsPerRow = letters.length; - } - } + jsonFile = new JSONFile(key, json, this.path, jsonXhrSettings); - var x = offsetX; - var y = offsetY; - - var data = { - retroFont: true, - font: key, - size: w, - lineHeight: h, - chars: {} - }; - - var r = 0; - - for (var i = 0; i < letters.length; i++) - { - // var node = letters[i]; - - var charCode = letters.charCodeAt(i); - - data.chars[charCode] = - { - x: x, - y: y, - width: w, - height: h, - centerX: cx, - centerY: cy, - xOffset: 0, - yOffset: 0, - xAdvance: w, - data: {}, - kerning: {} - }; - - r++; - - if (r === charsPerRow) - { - r = 0; - x = offsetX; - y += h + spacingY; + this.addFile(jsonFile); } else { - x += w + spacingX; + jsonFile = { + type: 'json', + key: key, + data: json, + state: CONST.FILE_WAITING_LINKFILE + }; } + + // Link them together + audioFile.linkFile = jsonFile; + jsonFile.linkFile = audioFile; + + // Set the type + audioFile.linkType = 'audioSprite'; + jsonFile.linkType = 'audioSprite'; + + this.addFile(audioFile); } - var entry = { - data: data, - frame: null, - texture: key - }; - - return entry; -}; - -/** -* Text Set 1 = !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ -* @constant -* @type {string} -*/ -ParseRetroFont.TEXT_SET1 = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; - -/** -* Text Set 2 = !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ -* @constant -* @type {string} -*/ -ParseRetroFont.TEXT_SET2 = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ'; - -/** -* Text Set 3 = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 -* @constant -* @type {string} -*/ -ParseRetroFont.TEXT_SET3 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 '; - -/** -* Text Set 4 = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 -* @constant -* @type {string} -*/ -ParseRetroFont.TEXT_SET4 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789'; - -/** -* Text Set 5 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789 -* @constant -* @type {string} -*/ -ParseRetroFont.TEXT_SET5 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() \'!?-*:0123456789'; - -/** -* Text Set 6 = ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.' -* @constant -* @type {string} -*/ -ParseRetroFont.TEXT_SET6 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.\' '; - -/** -* Text Set 7 = AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-'39 -* @constant -* @type {string} -*/ -ParseRetroFont.TEXT_SET7 = 'AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-\'39'; - -/** -* Text Set 8 = 0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ -* @constant -* @type {string} -*/ -ParseRetroFont.TEXT_SET8 = '0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ'; - -/** -* Text Set 9 = ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'"?! -* @constant -* @type {string} -*/ -ParseRetroFont.TEXT_SET9 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,\'"?!'; - -/** -* Text Set 10 = ABCDEFGHIJKLMNOPQRSTUVWXYZ -* @constant -* @type {string} -*/ -ParseRetroFont.TEXT_SET10 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; - -/** -* Text Set 11 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()':;0123456789 -* @constant -* @type {string} -*/ -ParseRetroFont.TEXT_SET11 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()\':;0123456789'; - -module.exports = ParseRetroFont; + return this; +}); /***/ }), @@ -90923,26 +89269,86 @@ module.exports = ParseRetroFont; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); +var FileTypesManager = __webpack_require__(7); +var ImageFile = __webpack_require__(50); +var JSONFile = __webpack_require__(51); -if (true) +/** + * An Atlas JSON File. + * + * @function Phaser.Loader.FileTypes.AtlasJSONFile + * @since 3.0.0 + * + * @param {string} key - The key of the file within the loader. + * @param {string} textureURL - The url to load the texture file from. + * @param {string} atlasURL - The url to load the atlas file from. + * @param {string} path - The path of the file. + * @param {XHRSettingsObject} textureXhrSettings - Optional texture file specific XHR settings. + * @param {XHRSettingsObject} atlasXhrSettings - Optional atlas file specific XHR settings. + * + * @return {object} An object containing two File objects to be added to the loader. + */ +var AtlasJSONFile = function (key, textureURL, atlasURL, path, textureXhrSettings, atlasXhrSettings) { - renderWebGL = __webpack_require__(550); -} + var image = new ImageFile(key, textureURL, path, textureXhrSettings); + var data = new JSONFile(key, atlasURL, path, atlasXhrSettings); -if (true) -{ - renderCanvas = __webpack_require__(551); -} + // Link them together + image.linkFile = data; + data.linkFile = image; -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas + // Set the type + image.linkType = 'atlasjson'; + data.linkType = 'atlasjson'; + return { texture: image, data: data }; }; +/** + * Adds a Texture Atlas file to the current load queue. + * + * Note: This method will only be available if the Atlas JSON File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#atlas + * @since 3.0.0 + * + * @param {string} key - The key of the file within the loader. + * @param {string} textureURL - The url to load the texture file from. + * @param {string} atlasURL - The url to load the atlas file from. + * @param {XHRSettingsObject} textureXhrSettings - Optional texture file specific XHR settings. + * @param {XHRSettingsObject} atlasXhrSettings - Optional atlas file specific XHR settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('atlas', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) +{ + + var files; + + // If param key is an object, use object based loading method + if ((typeof key === 'object') && (key !== null)) + { + files = new AtlasJSONFile(key.key, key.texture, key.data, this.path, textureXhrSettings, atlasXhrSettings); + } + + // Else just use the parameters like normal + else + { + // Returns an object with two properties: 'texture' and 'data' + files = new AtlasJSONFile(key, textureURL, atlasURL, this.path, textureXhrSettings, atlasXhrSettings); + } + + this.addFile(files.texture); + this.addFile(files.data); + + return this; +}); + +module.exports = AtlasJSONFile; + /***/ }), /* 550 */ @@ -90954,36 +89360,76 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(1); +var FileTypesManager = __webpack_require__(7); +var JSONFile = __webpack_require__(51); /** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. + * An Animation JSON File. * - * @method Phaser.GameObjects.BitmapText#renderWebGL + * @function Phaser.Loader.FileTypes.AnimationJSONFile * @since 3.0.0 - * @private * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.BitmapText} gameObject - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {string} key - The key of the file within the loader. + * @param {string} url - The url to load the file from. + * @param {string} path - The path of the file. + * @param {XHRSettingsObject} xhrSettings - Optional file specific XHR settings. + * + * @return {Phaser.Loader.FileTypes.AnimationJSONFile} A File instance to be added to the Loader. */ -var BitmapTextWebGLRenderer = function (renderer, gameObject, interpolationPercentage, camera) +var AnimationJSONFile = function (key, url, path, xhrSettings) { - var text = gameObject.text; - var textLength = text.length; + var json = new JSONFile(key, url, path, xhrSettings); - if (GameObject.RENDER_MASK !== gameObject.renderFlags || textLength === 0 || (gameObject.cameraFilter > 0 && (gameObject.cameraFilter & camera._id))) - { - return; - } + // Override the File type + json.type = 'animationJSON'; - this.pipeline.batchBitmapText(this, camera); + return json; }; -module.exports = BitmapTextWebGLRenderer; +/** + * Adds an Animation JSON file to the current load queue. + * + * Note: This method will only be available if the Animation JSON File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#animation + * @since 3.0.0 + * + * @param {(string|array|object)} key - A unique string to be used as the key to reference this file from the Cache. Must be unique within this file type. + * @param {string} [url] - URL of the file. If `undefined` or `null` the url will be set to `.json`, + * i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {XHRSettingsObject} [xhrSettings] - File specific XHR settings to be used during the load. These settings are merged with the global Loader XHR settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('animation', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new AnimationJSONFile(key[i], url, this.path, xhrSettings)); + } + } + else + { + this.addFile(new AnimationJSONFile(key, url, this.path, xhrSettings)); + } + + // For method chaining + return this; +}); + +// When registering a factory function 'this' refers to the Loader context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory + +module.exports = AnimationJSONFile; /***/ }), @@ -90996,175 +89442,59 @@ module.exports = BitmapTextWebGLRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(1); +/** + * @namespace Phaser.Loader.FileTypes + */ /** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. + * @typedef {object} XHRConfig * - * @method Phaser.GameObjects.BitmapText#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.BitmapText} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @property {string} key - [description] + * @property {string} texture - [description] + * @property {string} [data] - [description] + * @property {XHRConfig} [xhr] - [description] */ -var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera) -{ - var text = src.text; - var textLength = text.length; - if (GameObject.RENDER_MASK !== src.renderFlags || textLength === 0 || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - var textureFrame = src.frame; +/** + * @typedef {object} FileTypeConfig + * + * @property {string} key - [description] + * @property {string} texture - [description] + * @property {string} [data] - [description] + * @property {string} [url] - [description] + * @property {string} [path] - [description] + * @property {string} [extension] - [description] + * @property {string} [responseType] - [description] + * @property {object} [config] - [description] + * @property {XHRConfig} [xhr] - [description] + */ - var chars = src.fontData.chars; - var lineHeight = src.fontData.lineHeight; +module.exports = { - var xAdvance = 0; - var yAdvance = 0; + AnimationJSONFile: __webpack_require__(550), + AtlasJSONFile: __webpack_require__(549), + AudioFile: __webpack_require__(225), + AudioSprite: __webpack_require__(548), + BinaryFile: __webpack_require__(547), + BitmapFontFile: __webpack_require__(546), + GLSLFile: __webpack_require__(545), + HTML5AudioFile: __webpack_require__(224), + HTMLFile: __webpack_require__(544), + ImageFile: __webpack_require__(50), + JSONFile: __webpack_require__(51), + MultiAtlas: __webpack_require__(543), + PluginFile: __webpack_require__(542), + ScriptFile: __webpack_require__(541), + SpriteSheetFile: __webpack_require__(540), + SVGFile: __webpack_require__(539), + TextFile: __webpack_require__(221), + TilemapCSVFile: __webpack_require__(538), + TilemapJSONFile: __webpack_require__(537), + UnityAtlasFile: __webpack_require__(536), + XMLFile: __webpack_require__(223) - var indexCount = 0; - var charCode = 0; - - var glyph = null; - var glyphX = 0; - var glyphY = 0; - var glyphW = 0; - var glyphH = 0; - - var x = 0; - var y = 0; - - var lastGlyph = null; - var lastCharCode = 0; - - var ctx = renderer.currentContext; - var image = src.frame.source.image; - - var textureX = textureFrame.cutX; - var textureY = textureFrame.cutY; - - var scale = (src.fontSize / src.fontData.size); - - // Blend Mode - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - var roundPixels = renderer.config.roundPixels; - - var tx = (src.x - camera.scrollX * src.scrollFactorX) + src.frame.x; - var ty = (src.y - camera.scrollY * src.scrollFactorY) + src.frame.y; - - if (roundPixels) - { - tx |= 0; - ty |= 0; - } - - ctx.save(); - - ctx.translate(tx, ty); - - ctx.rotate(src.rotation); - - ctx.translate(-src.displayOriginX, -src.displayOriginY); - - ctx.scale(src.scaleX, src.scaleY); - - for (var index = 0; index < textLength; ++index) - { - charCode = text.charCodeAt(index); - - if (charCode === 10) - { - xAdvance = 0; - indexCount = 0; - yAdvance += lineHeight; - lastGlyph = null; - continue; - } - - glyph = chars[charCode]; - - if (!glyph) - { - continue; - } - - glyphX = textureX + glyph.x; - glyphY = textureY + glyph.y; - - glyphW = glyph.width; - glyphH = glyph.height; - - x = indexCount + glyph.xOffset + xAdvance; - y = glyph.yOffset + yAdvance; - - if (lastGlyph !== null) - { - var kerningOffset = glyph.kerning[lastCharCode]; - x += (kerningOffset !== undefined) ? kerningOffset : 0; - } - - x *= scale; - y *= scale; - - xAdvance += glyph.xAdvance; - indexCount += 1; - lastGlyph = glyph; - lastCharCode = charCode; - - // Nothing to render or a space? Then skip to the next glyph - if (glyphW === 0 || glyphH === 0 || charCode === 32) - { - continue; - } - - if (roundPixels) - { - x |= 0; - y |= 0; - } - - ctx.save(); - - ctx.translate(x, y); - - ctx.scale(scale, scale); - - ctx.drawImage(image, glyphX, glyphY, glyphW, glyphH, 0, 0, glyphW, glyphH); - - ctx.restore(); - } - - ctx.restore(); }; -module.exports = BitmapTextCanvasRenderer; - /***/ }), /* 552 */ @@ -91176,26 +89506,32 @@ module.exports = BitmapTextCanvasRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); +var CONST = __webpack_require__(17); +var Extend = __webpack_require__(18); -if (true) -{ - renderWebGL = __webpack_require__(553); -} +/** + * @namespace Phaser.Loader + */ -if (true) -{ - renderCanvas = __webpack_require__(554); -} +var Loader = { -module.exports = { + FileTypes: __webpack_require__(551), - renderWebGL: renderWebGL, - renderCanvas: renderCanvas + File: __webpack_require__(19), + FileTypesManager: __webpack_require__(7), + GetURL: __webpack_require__(122), + LoaderPlugin: __webpack_require__(535), + MergeXHRSettings: __webpack_require__(121), + XHRLoader: __webpack_require__(226), + XHRSettings: __webpack_require__(94) }; +// Merge in the consts +Loader = Extend(false, Loader, CONST); + +module.exports = Loader; + /***/ }), /* 553 */ @@ -91207,33 +89543,17 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(1); - /** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Blitter#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Blitter} gameObject - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @namespace Phaser.Input.Touch */ -var BlitterWebGLRenderer = function (renderer, gameObject, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== gameObject.renderFlags || (gameObject.cameraFilter > 0 && (gameObject.cameraFilter & camera._id))) - { - return; - } - this.pipeline.drawBlitter(gameObject, camera); +/* eslint-disable */ +module.exports = { + + TouchManager: __webpack_require__(289) + }; - -module.exports = BlitterWebGLRenderer; +/* eslint-enable */ /***/ }), @@ -91246,704 +89566,21 @@ module.exports = BlitterWebGLRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(1); - /** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Blitter#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Blitter} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @namespace Phaser.Input.Mouse */ -var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - var list = src.getRenderList(); +/* eslint-disable */ +module.exports = { - renderer.setBlendMode(src.blendMode); - - var ctx = renderer.gameContext; - var cameraScrollX = src.x - camera.scrollX * src.scrollFactorX; - var cameraScrollY = src.y - camera.scrollY * src.scrollFactorY; - - // Render bobs - for (var i = 0; i < list.length; i++) - { - var bob = list[i]; - var flip = (bob.flipX || bob.flipY); - var frame = bob.frame; - var cd = frame.canvasData; - var dx = frame.x; - var dy = frame.y; - var fx = 1; - var fy = 1; - - if (!flip) - { - renderer.blitImage(dx + bob.x + cameraScrollX, dy + bob.y + cameraScrollY, bob.frame); - } - else - { - if (bob.flipX) - { - fx = -1; - dx -= cd.dWidth; - } - - if (bob.flipY) - { - fy = -1; - dy -= cd.dHeight; - } - - ctx.save(); - ctx.translate(bob.x + cameraScrollX, bob.y + cameraScrollY); - ctx.scale(fx, fy); - ctx.drawImage(frame.source.image, cd.sx, cd.sy, cd.sWidth, cd.sHeight, dx, dy, cd.dWidth, cd.dHeight); - ctx.restore(); - } - } + MouseManager: __webpack_require__(291) + }; - -module.exports = BlitterCanvasRenderer; +/* eslint-enable */ /***/ }), /* 555 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * A Bob Game Object. - * - * A Bob belongs to a Blitter Game Object. The Blitter is responsible for managing and rendering this object. - * - * A Bob has a position, alpha value and a frame from a texture that it uses to render with. You can also toggle - * the flipped and visible state of the Bob. The Frame the Bob uses to render can be changed dynamically, but it - * must be a Frame within the Texture used by the parent Blitter. - * - * Bob positions are relative to the Blitter parent. So if you move the Blitter parent, all Bob children will - * have their positions impacted by this change as well. - * - * You can manipulate Bob objects directly from your game code, but the creation and destruction of them should be - * handled via the Blitter parent. - * - * @class Bob - * @memberOf Phaser.GameObjects.Blitter - * @constructor - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter} blitter - The parent Blitter object is responsible for updating this Bob. - * @param {number} x - The horizontal position of this Game Object in the world, relative to the parent Blitter position. - * @param {number} y - The vertical position of this Game Object in the world, relative to the parent Blitter position. - * @param {string|integer} frame - The Frame this Bob will render with, as defined in the Texture the parent Blitter is using. - * @param {boolean} visible - Should the Bob render visible or not to start with? - */ -var Bob = new Class({ - - initialize: - - function Bob (blitter, x, y, frame, visible) - { - /** - * [description] - * - * @name Phaser.GameObjects.Blitter.Bob#parent - * @type {Phaser.GameObjects.Blitter} - * @since 3.0.0 - */ - this.parent = blitter; - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter.Bob#x - * @type {number} - * @since 3.0.0 - */ - this.x = x; - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter.Bob#y - * @type {number} - * @since 3.0.0 - */ - this.y = y; - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter.Bob#frame - * @type {string|integer} - * @since 3.0.0 - */ - this.frame = frame; - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter.Bob#data - * @type {object} - * @default {} - * @since 3.0.0 - */ - this.data = {}; - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter.Bob#_visible - * @type {boolean} - * @private - * @since 3.0.0 - */ - this._visible = visible; - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter.Bob#_alpha - * @type {number} - * @private - * @default 1 - * @since 3.0.0 - */ - this._alpha = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter.Bob#flipX - * @type {boolean} - * @since 3.0.0 - */ - this.flipX = false; - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter.Bob#flipY - * @type {boolean} - * @since 3.0.0 - */ - this.flipY = false; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter.Bob#setFrame - * @since 3.0.0 - * - * @param {[type]} frame - [description] - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setFrame: function (frame) - { - if (frame === undefined) - { - frame = this.parent.frame; - } - else - { - frame = this.parent.texture.get(frame); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter.Bob#resetFlip - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - resetFlip: function () - { - this.flipX = false; - this.flipY = false; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter.Bob#reset - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} frame - [description] - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - reset: function (x, y, frame) - { - this.x = x; - this.y = y; - this.frame = frame; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter.Bob#setFlipX - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setFlipX: function (value) - { - this.flipX = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter.Bob#setFlipY - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setFlipY: function (value) - { - this.flipY = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter.Bob#setFlip - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setFlip: function (x, y) - { - this.flipX = x; - this.flipY = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter.Bob#setVisible - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setVisible: function (value) - { - this.visible = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter.Bob#setAlpha - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setAlpha: function (value) - { - this.alpha = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter.Bob#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.parent.dirty = true; - - this.parent.children.remove(this); - - this.parent = undefined; - this.frame = undefined; - this.data = undefined; - }, - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter.Bob#visible - * @type {boolean} - * @since 3.0.0 - */ - visible: { - - get: function () - { - return this._visible; - }, - - set: function (value) - { - this._visible = value; - this.parent.dirty = true; - } - - }, - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter.Bob#alpha - * @type {number} - * @since 3.0.0 - */ - alpha: { - - get: function () - { - return this._alpha; - }, - - set: function (value) - { - this._alpha = value; - this.parent.dirty = true; - } - - } - -}); - -module.exports = Bob; - - -/***/ }), -/* 556 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(557); -} - -if (true) -{ - renderCanvas = __webpack_require__(558); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 557 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.DynamicBitmapText#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.DynamicBitmapText} gameObject - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var DynamicBitmapTextWebGLRenderer = function (renderer, bitmapText, interpolationPercentage, camera) -{ - var text = bitmapText.text; - var textLength = text.length; - - if (GameObject.RENDER_MASK !== bitmapText.renderFlags || textLength === 0 || (bitmapText.cameraFilter > 0 && (bitmapText.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.batchDynamicBitmapText(bitmapText, camera); -}; - -module.exports = DynamicBitmapTextWebGLRenderer; - - -/***/ }), -/* 558 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.DynamicBitmapText#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.DynamicBitmapText} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera) -{ - var text = src.text; - var textLength = text.length; - - if (GameObject.RENDER_MASK !== src.renderFlags || textLength === 0 || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - var textureFrame = src.frame; - - var displayCallback = src.displayCallback; - - var cameraScrollX = camera.scrollX * src.scrollFactorX; - var cameraScrollY = camera.scrollY * src.scrollFactorY; - - var chars = src.fontData.chars; - var lineHeight = src.fontData.lineHeight; - - var xAdvance = 0; - var yAdvance = 0; - - var indexCount = 0; - var charCode = 0; - - var glyph = null; - var glyphX = 0; - var glyphY = 0; - var glyphW = 0; - var glyphH = 0; - - var x = 0; - var y = 0; - - var lastGlyph = null; - var lastCharCode = 0; - - var ctx = renderer.currentContext; - var image = src.frame.source.image; - - var textureX = textureFrame.cutX; - var textureY = textureFrame.cutY; - - var rotation = 0; - var scale = (src.fontSize / src.fontData.size); - - // Blend Mode - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - ctx.save(); - - ctx.translate(src.x, src.y); - - ctx.rotate(src.rotation); - - ctx.translate(-src.displayOriginX, -src.displayOriginY); - - ctx.scale(src.scaleX, src.scaleY); - - if (src.cropWidth > 0 && src.cropHeight > 0) - { - ctx.save(); - ctx.beginPath(); - ctx.rect(0, 0, src.cropWidth, src.cropHeight); - ctx.clip(); - } - - var roundPixels = renderer.config.roundPixels; - - for (var index = 0; index < textLength; ++index) - { - // Reset the scale (in case the callback changed it) - scale = (src.fontSize / src.fontData.size); - rotation = 0; - - charCode = text.charCodeAt(index); - - if (charCode === 10) - { - xAdvance = 0; - indexCount = 0; - yAdvance += lineHeight; - lastGlyph = null; - continue; - } - - glyph = chars[charCode]; - - if (!glyph) - { - continue; - } - - glyphX = textureX + glyph.x; - glyphY = textureY + glyph.y; - - glyphW = glyph.width; - glyphH = glyph.height; - - x = (indexCount + glyph.xOffset + xAdvance) - src.scrollX; - y = (glyph.yOffset + yAdvance) - src.scrollY; - - // This could be optimized so that it doesn't even bother drawing it if the x/y is out of range - - if (lastGlyph !== null) - { - var kerningOffset = glyph.kerning[lastCharCode]; - x += (kerningOffset !== undefined) ? kerningOffset : 0; - } - - if (displayCallback) - { - var output = displayCallback({ tint: { topLeft: 0, topRight: 0, bottomLeft: 0, bottomRight: 0 }, index: index, charCode: charCode, x: x, y: y, scale: scale, rotation: 0, data: glyph.data }); - - x = output.x; - y = output.y; - scale = output.scale; - rotation = output.rotation; - } - - x *= scale; - y *= scale; - - x -= cameraScrollX; - y -= cameraScrollY; - - if (roundPixels) - { - x |= 0; - y |= 0; - } - - ctx.save(); - - ctx.translate(x, y); - - ctx.rotate(rotation); - - ctx.scale(scale, scale); - - ctx.drawImage(image, glyphX, glyphY, glyphW, glyphH, 0, 0, glyphW, glyphH); - - ctx.restore(); - - xAdvance += glyph.xAdvance; - indexCount += 1; - lastGlyph = glyph; - lastCharCode = charCode; - } - - if (src.cropWidth > 0 && src.cropHeight > 0) - { - ctx.restore(); - } - - ctx.restore(); -}; - -module.exports = DynamicBitmapTextCanvasRenderer; - - -/***/ }), -/* 559 */ /***/ (function(module, exports) { /** @@ -91953,27 +89590,166 @@ module.exports = DynamicBitmapTextCanvasRenderer; */ /** - * Calculates the area of the Ellipse. + * Returns `true` if the Key was released within the `duration` value given, or `false` if it either isn't up, + * or was released longer ago than then given duration. * - * @function Phaser.Geom.Ellipse.Area + * @function Phaser.Input.Keyboard.UpDuration * @since 3.0.0 * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the area of. + * @param {Phaser.Input.Keyboard.Key} key - [description] + * @param {integer} [duration=50] - [description] * - * @return {number} The area of the Ellipse. + * @return {boolean} [description] */ -var Area = function (ellipse) +var UpDuration = function (key, duration) { - if (ellipse.isEmpty()) - { - return 0; - } + if (duration === undefined) { duration = 50; } - // units squared - return (ellipse.getMajorRadius() * ellipse.getMinorRadius() * Math.PI); + return (key.isUp && key.duration < duration); }; -module.exports = Area; +module.exports = UpDuration; + + +/***/ }), +/* 556 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns `true` if the Key was pressed down within the `duration` value given, or `false` if it either isn't down, + * or was pressed down longer ago than then given duration. + * + * @function Phaser.Input.Keyboard.DownDuration + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.Key} key - [description] + * @param {integer} [duration=50] - [description] + * + * @return {boolean} [description] + */ +var DownDuration = function (key, duration) +{ + if (duration === undefined) { duration = 50; } + + return (key.isDown && key.duration < duration); +}; + +module.exports = DownDuration; + + +/***/ }), +/* 557 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * The justUp value allows you to test if this Key has just been released or not. + * When you check this value it will return `true` if the Key is up, otherwise `false`. + * You can only call justUp once per key release. It will only return `true` once, until the Key is pressed down and released again. + * This allows you to use it in situations where you want to check if this key is up without using a Signal, such as in a core game loop. + * + * @function Phaser.Input.Keyboard.JustUp + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.Key} key - [description] + * + * @return {boolean} [description] + */ +var JustUp = function (key) +{ + var current = false; + + if (key.isDown) + { + current = key._justUp; + key._justUp = false; + } + + return current; +}; + +module.exports = JustUp; + + +/***/ }), +/* 558 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * The justDown value allows you to test if this Key has just been pressed down or not. + * When you check this value it will return `true` if the Key is down, otherwise `false`. + * You can only call justDown once per key press. It will only return `true` once, until the Key is released and pressed down again. + * This allows you to use it in situations where you want to check if this key is down without using a Signal, such as in a core game loop. + * + * @function Phaser.Input.Keyboard.JustDown + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.Key} key - [description] + * + * @return {boolean} [description] + */ +var JustDown = function (key) +{ + var current = false; + + if (key.isDown) + { + current = key._justDown; + key._justDown = false; + } + + return current; +}; + +module.exports = JustDown; + + +/***/ }), +/* 559 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Input.Keyboard + */ + +module.exports = { + + KeyboardManager: __webpack_require__(294), + + Key: __webpack_require__(293), + KeyCodes: __webpack_require__(143), + + KeyCombo: __webpack_require__(292), + + JustDown: __webpack_require__(558), + JustUp: __webpack_require__(557), + DownDuration: __webpack_require__(556), + UpDuration: __webpack_require__(555) + +}; /***/ }), @@ -91986,29 +89762,1642 @@ module.exports = Area; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Ellipse = __webpack_require__(137); +var Circle = __webpack_require__(79); +var CircleContains = __webpack_require__(28); +var Class = __webpack_require__(0); +var DistanceBetween = __webpack_require__(48); +var Ellipse = __webpack_require__(135); +var EllipseContains = __webpack_require__(74); +var EventEmitter = __webpack_require__(15); +var InteractiveObject = __webpack_require__(227); +var PluginManager = __webpack_require__(12); +var Rectangle = __webpack_require__(10); +var RectangleContains = __webpack_require__(27); +var Triangle = __webpack_require__(52); +var TriangleContains = __webpack_require__(54); /** - * Creates a new Ellipse instance based on the values contained in the given source. + * @classdesc + * [description] * - * @function Phaser.Geom.Ellipse.Clone + * @class InputPlugin + * @extends EventEmitter + * @memberOf Phaser.Input + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Ellipse} source - The Ellipse to be cloned. Can be an instance of an Ellipse or a ellipse-like object, with x, y, width and height properties. - * - * @return {Phaser.Geom.Ellipse} A clone of the source Ellipse. + * @param {Phaser.Scene} scene - The Scene that owns this plugin. */ -var Clone = function (source) -{ - return new Ellipse(source.x, source.y, source.width, source.height); -}; +var InputPlugin = new Class({ -module.exports = Clone; + Extends: EventEmitter, + + initialize: + + function InputPlugin (scene) + { + EventEmitter.call(this); + + /** + * The Scene that owns this plugin. + * + * @name Phaser.Input.InputPlugin#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Input.InputPlugin#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + if (!scene.sys.settings.isBooted) + { + scene.sys.events.once('boot', this.boot, this); + } + + /** + * [description] + * + * @name Phaser.Input.InputPlugin#manager + * @type {Phaser.Input.InputManager} + * @since 3.0.0 + */ + this.manager = scene.sys.game.input; + + /** + * A reference to this.scene.sys.displayList (set in boot) + * + * @name Phaser.Input.InputPlugin#displayList + * @type {Phaser.GameObjects.DisplayList} + * @since 3.0.0 + */ + this.displayList; + + /** + * A reference to the this.scene.sys.cameras (set in boot) + * + * @name Phaser.Input.InputPlugin#cameras + * @type {null} + * @since 3.0.0 + */ + this.cameras; + + /** + * [description] + * + * @name Phaser.Input.InputPlugin#keyboard + * @type {Phaser.Input.Keyboard.KeyboardManager} + * @since 3.0.0 + */ + this.keyboard = this.manager.keyboard; + + /** + * [description] + * + * @name Phaser.Input.InputPlugin#mouse + * @type {Phaser.Input.Mouse.MouseManager} + * @since 3.0.0 + */ + this.mouse = this.manager.mouse; + + /** + * [description] + * + * @name Phaser.Input.InputPlugin#gamepad + * @type {Phaser.Input.Gamepad.GamepadManager} + * @since 3.0.0 + */ + this.gamepad = this.manager.gamepad; + + /** + * Only fire callbacks and events on the top-most Game Object in the display list (emulating DOM behavior) + * and ignore any GOs below it, or call them all? + * + * @name Phaser.Input.InputPlugin#topOnly + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.topOnly = true; + + /** + * How often should the pointer input be checked? + * Time given in ms + * Pointer will *always* be checked if it has been moved by the user. + * This controls how often it will be polled if it hasn't been moved. + * Set to 0 to poll constantly. Set to -1 to only poll on user movement. + * + * @name Phaser.Input.InputPlugin#pollRate + * @type {integer} + * @default -1 + * @since 3.0.0 + */ + this.pollRate = -1; + + /** + * [description] + * + * @name Phaser.Input.InputPlugin#_pollTimer + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._pollTimer = 0; + + /** + * The distance, in pixels, the pointer has to move while being held down, before it thinks it is being dragged. + * + * @name Phaser.Input.InputPlugin#dragDistanceThreshold + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.dragDistanceThreshold = 0; + + /** + * The amount of time, in ms, the pointer has to be held down before it thinks it is dragging. + * + * @name Phaser.Input.InputPlugin#dragTimeThreshold + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.dragTimeThreshold = 0; + + /** + * Used to temporarily store the results of the Hit Test + * + * @name Phaser.Input.InputPlugin#_temp + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this._temp = []; + + /** + * Used to temporarily store the results of the Hit Test dropZones + * + * @name Phaser.Input.InputPlugin#_tempZones + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this._tempZones = []; + + /** + * A list of all Game Objects that have been set to be interactive. + * + * @name Phaser.Input.InputPlugin#_list + * @type {Phaser.GameObjects.GameObject[]} + * @private + * @default [] + * @since 3.0.0 + */ + this._list = []; + + /** + * Objects waiting to be inserted to the list on the next call to 'begin'. + * + * @name Phaser.Input.InputPlugin#_pendingInsertion + * @type {Phaser.GameObjects.GameObject[]} + * @private + * @default [] + * @since 3.0.0 + */ + this._pendingInsertion = []; + + /** + * Objects waiting to be removed from the list on the next call to 'begin'. + * + * @name Phaser.Input.InputPlugin#_pendingRemoval + * @type {Phaser.GameObjects.GameObject[]} + * @private + * @default [] + * @since 3.0.0 + */ + this._pendingRemoval = []; + + /** + * A list of all Game Objects that have been enabled for dragging. + * + * @name Phaser.Input.InputPlugin#_draggable + * @type {Phaser.GameObjects.GameObject[]} + * @private + * @default [] + * @since 3.0.0 + */ + this._draggable = []; + + /** + * A list of all Interactive Objects currently considered as being 'draggable' by any pointer, indexed by pointer ID. + * + * @name Phaser.Input.InputPlugin#_drag + * @type {{0:Array,2:Array,3:Array,4:Array,5:Array,6:Array,7:Array,8:Array,9:Array}} + * @private + * @since 3.0.0 + */ + this._drag = { 0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [] }; + + /** + * A list of all Interactive Objects currently considered as being 'over' by any pointer, indexed by pointer ID. + * + * @name Phaser.Input.InputPlugin#_over + * @type {{0:Array,2:Array,3:Array,4:Array,5:Array,6:Array,7:Array,8:Array,9:Array}} + * @private + * @since 3.0.0 + */ + this._over = { 0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [] }; + + /** + * [description] + * + * @name Phaser.Input.InputPlugin#_validTypes + * @type {string[]} + * @private + * @since 3.0.0 + */ + this._validTypes = [ 'onDown', 'onUp', 'onOver', 'onOut', 'onMove', 'onDragStart', 'onDrag', 'onDragEnd', 'onDragEnter', 'onDragLeave', 'onDragOver', 'onDrop' ]; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#boot + * @since 3.0.0 + */ + boot: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on('preupdate', this.preUpdate, this); + eventEmitter.on('update', this.update, this); + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); + + this.cameras = this.systems.cameras; + + this.displayList = this.systems.displayList; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#preUpdate + * @since 3.0.0 + */ + preUpdate: function () + { + var removeList = this._pendingRemoval; + var insertList = this._pendingInsertion; + + var toRemove = removeList.length; + var toInsert = insertList.length; + + if (toRemove === 0 && toInsert === 0) + { + // Quick bail + return; + } + + var current = this._list; + + // Delete old gameObjects + for (var i = 0; i < toRemove; i++) + { + var gameObject = removeList[i]; + + var index = current.indexOf(gameObject); + + if (index > -1) + { + current.splice(index, 1); + + this.clear(gameObject); + } + } + + // Clear the removal list + removeList.length = 0; + + // Move pendingInsertion to list (also clears pendingInsertion at the same time) + this._list = current.concat(insertList.splice(0)); + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#clear + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * + * @return {Phaser.GameObjects.GameObject} [description] + */ + clear: function (gameObject) + { + var input = gameObject.input; + + input.gameObject = undefined; + input.target = undefined; + input.hitArea = undefined; + input.hitAreaCallback = undefined; + input.callbackContext = undefined; + + gameObject.input = null; + + // Clear from _draggable, _drag and _over + var index = this._draggable.indexOf(gameObject); + + if (index > -1) + { + this._draggable.splice(index, 1); + } + + index = this._drag[0].indexOf(gameObject); + + if (index > -1) + { + this._drag[0].splice(index, 1); + } + + index = this._over[0].indexOf(gameObject); + + if (index > -1) + { + this._over[0].splice(index, 1); + } + + return gameObject; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#disable + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + */ + disable: function (gameObject) + { + gameObject.input.enabled = false; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#enable + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * @param {object} shape - [description] + * @param {HitAreaCallback} callback - [description] + * @param {boolean} [dropZone=false] - [description] + * + * @return {Phaser.Input.InputPlugin} This Input Plugin. + */ + enable: function (gameObject, shape, callback, dropZone) + { + if (dropZone === undefined) { dropZone = false; } + + if (gameObject.input) + { + // If it is already has an InteractiveObject then just enable it and return + gameObject.input.enabled = true; + } + else + { + // Create an InteractiveObject and enable it + this.setHitArea(gameObject, shape, callback); + } + + gameObject.input.dropZone = dropZone; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#hitTestPointer + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - [description] + * + * @return {array} [description] + */ + hitTestPointer: function (pointer) + { + var camera = this.cameras.getCameraBelowPointer(pointer); + + if (camera) + { + pointer.camera = camera; + + // Get a list of all objects that can be seen by the camera below the pointer in the scene and store in 'output' array. + // All objects in this array are input enabled, as checked by the hitTest method, so we don't need to check later on as well. + var over = this.manager.hitTest(pointer.x, pointer.y, this._list, camera); + + // Filter out the drop zones + for (var i = 0; i < over.length; i++) + { + var obj = over[i]; + + if (obj.input.dropZone) + { + this._tempZones.push(obj); + } + } + + return over; + } + else + { + return []; + } + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#processDownEvents + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer to check for events against. + * + * @return {integer} The total number of objects interacted with. + */ + processDownEvents: function (pointer) + { + var currentlyOver = this._temp; + + // Contains ALL Game Objects currently over in the array + this.emit('pointerdown', pointer, currentlyOver); + + var total = 0; + + // Go through all objects the pointer was over and fire their events / callbacks + for (var i = 0; i < currentlyOver.length; i++) + { + var gameObject = currentlyOver[i]; + + if (!gameObject.input) + { + continue; + } + + total++; + + gameObject.emit('pointerdown', pointer, gameObject.input.localX, gameObject.input.localY, pointer.camera); + + this.emit('gameobjectdown', pointer, gameObject); + } + + return total; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#processDragEvents + * @since 3.0.0 + * + * @param {number} pointer - [description] + * @param {number} time - [description] + * + * @return {integer} [description] + */ + processDragEvents: function (pointer, time) + { + if (this._draggable.length === 0) + { + // There are no draggable items, so let's not even bother going further + return 0; + } + + var i; + var gameObject; + var list; + var input; + var currentlyOver = this._temp; + + // 0 = Not dragging anything + // 1 = Primary button down and objects below, so collect a draglist + // 2 = Pointer being checked if meets drag criteria + // 3 = Pointer meets criteria, notify the draglist + // 4 = Pointer actively dragging the draglist and has moved + // 5 = Pointer actively dragging but has been released, notify draglist + + if (pointer.dragState === 0 && pointer.primaryDown && pointer.justDown && currentlyOver.length > 0) + { + pointer.dragState = 1; + } + else if (pointer.dragState > 0 && !pointer.primaryDown && pointer.justUp) + { + pointer.dragState = 5; + } + + // Process the various drag states + + // 1 = Primary button down and objects below, so collect a draglist + if (pointer.dragState === 1) + { + // Get draggable objects, sort them, pick the top (or all) and store them somewhere + var draglist = []; + + for (i = 0; i < currentlyOver.length; i++) + { + gameObject = currentlyOver[i]; + + if (gameObject.input.draggable) + { + draglist.push(gameObject); + } + } + + if (draglist.length === 0) + { + pointer.dragState = 0; + + return 0; + } + else if (draglist.length > 1) + { + this.sortGameObjects(draglist); + + if (this.topOnly) + { + draglist.splice(1); + } + } + + // draglist now contains all potential candidates for dragging + this._drag[pointer.id] = draglist; + + if (this.dragDistanceThreshold === 0 && this.dragTimeThreshold === 0) + { + // No drag criteria, so snap immediately to mode 3 + pointer.dragState = 3; + } + else + { + // Check the distance / time + pointer.dragState = 2; + } + } + + // 2 = Pointer being checked if meets drag criteria + if (pointer.dragState === 2) + { + // Has it moved far enough to be considered a drag? + if (this.dragDistanceThreshold > 0 && DistanceBetween(pointer.x, pointer.y, pointer.downX, pointer.downY) >= this.dragDistanceThreshold) + { + // Alrighty, we've got a drag going on ... + pointer.dragState = 3; + } + + // Held down long enough to be considered a drag? + if (this.dragTimeThreshold > 0 && (time >= pointer.downTime + this.dragTimeThreshold)) + { + // Alrighty, we've got a drag going on ... + pointer.dragState = 3; + } + } + + // 3 = Pointer meets criteria and is freshly down, notify the draglist + if (pointer.dragState === 3) + { + list = this._drag[pointer.id]; + + for (i = 0; i < list.length; i++) + { + gameObject = list[i]; + + input = gameObject.input; + + input.dragState = 2; + + input.dragX = pointer.x - gameObject.x; + input.dragY = pointer.y - gameObject.y; + + input.dragStartX = gameObject.x; + input.dragStartY = gameObject.y; + + gameObject.emit('dragstart', pointer, input.dragX, input.dragY); + + this.emit('dragstart', pointer, gameObject); + } + + pointer.dragState = 4; + + return list.length; + } + + // 4 = Pointer actively dragging the draglist and has moved + if (pointer.dragState === 4 && pointer.justMoved) + { + var dropZones = this._tempZones; + + list = this._drag[pointer.id]; + + for (i = 0; i < list.length; i++) + { + gameObject = list[i]; + + input = gameObject.input; + + // If this GO has a target then let's check it + if (input.target) + { + var index = dropZones.indexOf(input.target); + + // Got a target, are we still over it? + if (index === 0) + { + // We're still over it, and it's still the top of the display list, phew ... + gameObject.emit('dragover', pointer, input.target); + + this.emit('dragover', pointer, gameObject, input.target); + } + else if (index > 0) + { + // Still over it but it's no longer top of the display list (targets must always be at the top) + gameObject.emit('dragleave', pointer, input.target); + + this.emit('dragleave', pointer, gameObject, input.target); + + input.target = dropZones[0]; + + gameObject.emit('dragenter', pointer, input.target); + + this.emit('dragenter', pointer, gameObject, input.target); + } + else + { + // Nope, we've moved on (or the target has!), leave the old target + gameObject.emit('dragleave', pointer, input.target); + + this.emit('dragleave', pointer, gameObject, input.target); + + // Anything new to replace it? + // Yup! + if (dropZones[0]) + { + input.target = dropZones[0]; + + gameObject.emit('dragenter', pointer, input.target); + + this.emit('dragenter', pointer, gameObject, input.target); + } + else + { + // Nope + input.target = null; + } + } + } + else if (!input.target && dropZones[0]) + { + input.target = dropZones[0]; + + gameObject.emit('dragenter', pointer, input.target); + + this.emit('dragenter', pointer, gameObject, input.target); + } + + var dragX = pointer.x - gameObject.input.dragX; + var dragY = pointer.y - gameObject.input.dragY; + + gameObject.emit('drag', pointer, dragX, dragY); + + this.emit('drag', pointer, gameObject, dragX, dragY); + } + + return list.length; + } + + // 5 = Pointer was actively dragging but has been released, notify draglist + if (pointer.dragState === 5) + { + list = this._drag[pointer.id]; + + for (i = 0; i < list.length; i++) + { + gameObject = list[i]; + + input = gameObject.input; + + input.dragState = 0; + + input.dragX = input.localX - gameObject.displayOriginX; + input.dragY = input.localY - gameObject.displayOriginY; + + var dropped = false; + + if (input.target) + { + gameObject.emit('drop', pointer, input.target); + + this.emit('drop', pointer, gameObject, input.target); + + input.target = null; + + dropped = true; + } + + // And finally the dragend event + + gameObject.emit('dragend', pointer, input.dragX, input.dragY, dropped); + + this.emit('dragend', pointer, gameObject, dropped); + } + + pointer.dragState = 0; + } + + return 0; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#processMoveEvents + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The pointer to check for events against. + * + * @return {integer} The total number of objects interacted with. + */ + processMoveEvents: function (pointer) + { + var currentlyOver = this._temp; + + this.emit('pointermove', pointer, currentlyOver); + + var total = 0; + + // Go through all objects the pointer was over and fire their events / callbacks + for (var i = 0; i < currentlyOver.length; i++) + { + var gameObject = currentlyOver[i]; + + if (!gameObject.input) + { + continue; + } + + total++; + + gameObject.emit('pointermove', pointer, gameObject.input.localX, gameObject.input.localY); + + this.emit('gameobjectmove', pointer, gameObject); + + if (this.topOnly) + { + break; + } + } + + return total; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#processOverOutEvents + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - [description] + * + * @return {integer} The number of objects interacted with. + */ + processOverOutEvents: function (pointer) + { + var currentlyOver = this._temp; + + var i; + var gameObject; + var justOut = []; + var justOver = []; + var stillOver = []; + var previouslyOver = this._over[pointer.id]; + var currentlyDragging = this._drag[pointer.id]; + + // Go through all objects the pointer was previously over, and see if it still is. + // Splits the previouslyOver array into two parts: justOut and stillOver + + for (i = 0; i < previouslyOver.length; i++) + { + gameObject = previouslyOver[i]; + + if (currentlyOver.indexOf(gameObject) === -1 && currentlyDragging.indexOf(gameObject) === -1) + { + // Not in the currentlyOver array, so must be outside of this object now + justOut.push(gameObject); + } + else + { + // In the currentlyOver array + stillOver.push(gameObject); + } + } + + // Go through all objects the pointer is currently over (the hit test results) + // and if not in the previouslyOver array we know it's a new entry, so add to justOver + for (i = 0; i < currentlyOver.length; i++) + { + gameObject = currentlyOver[i]; + + // Is this newly over? + + if (previouslyOver.indexOf(gameObject) === -1) + { + justOver.push(gameObject); + } + } + + // By this point the arrays are filled, so now we can process what happened... + + // Process the Just Out objects + var total = justOut.length; + + var totalInteracted = 0; + + if (total > 0) + { + this.sortGameObjects(justOut); + + this.emit('pointerout', pointer, justOut); + + // Call onOut for everything in the justOut array + for (i = 0; i < total; i++) + { + gameObject = justOut[i]; + + if (!gameObject.input) + { + continue; + } + + this.emit('gameobjectout', pointer, gameObject); + + gameObject.emit('pointerout', pointer); + + totalInteracted++; + } + } + + // Process the Just Over objects + total = justOver.length; + + if (total > 0) + { + this.sortGameObjects(justOver); + + this.emit('pointerover', pointer, justOver); + + // Call onOver for everything in the justOver array + for (i = 0; i < total; i++) + { + gameObject = justOver[i]; + + if (!gameObject.input) + { + continue; + } + + this.emit('gameobjectover', pointer, gameObject); + + gameObject.emit('pointerover', pointer, gameObject.input.localX, gameObject.input.localY); + + totalInteracted++; + } + } + + // Add the contents of justOver to the previously over array + previouslyOver = stillOver.concat(justOver); + + // Then sort it into display list order + this._over[pointer.id] = this.sortGameObjects(previouslyOver); + + return totalInteracted; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#processUpEvents + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - [description] + */ + processUpEvents: function (pointer) + { + var currentlyOver = this._temp; + + // Contains ALL Game Objects currently up in the array + this.emit('pointerup', pointer, currentlyOver); + + // Go through all objects the pointer was over and fire their events / callbacks + for (var i = 0; i < currentlyOver.length; i++) + { + var gameObject = currentlyOver[i]; + + if (!gameObject.input) + { + continue; + } + + // pointerupoutside + + gameObject.emit('pointerup', pointer, gameObject.input.localX, gameObject.input.localY); + + this.emit('gameobjectup', pointer, gameObject); + } + + return currentlyOver.length; + }, + + /** + * Queues a Game Object for insertion into this Input Manager on the next update. + * + * @method Phaser.Input.InputPlugin#queueForInsertion + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to add. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + queueForInsertion: function (child) + { + if (this._pendingInsertion.indexOf(child) === -1 && this._list.indexOf(child) === -1) + { + this._pendingInsertion.push(child); + } + + return this; + }, + + /** + * Queues a Game Object for removal from this Input Manager on the next update. + * + * @method Phaser.Input.InputPlugin#queueForRemoval + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to remove. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + queueForRemoval: function (child) + { + this._pendingRemoval.push(child); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setDraggable + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to change the draggable state on. + * @param {boolean} [value=true] - Set to `true` if the Game Objects should be made draggable, `false` if they should be unset. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setDraggable: function (gameObjects, value) + { + if (value === undefined) { value = true; } + + if (!Array.isArray(gameObjects)) + { + gameObjects = [ gameObjects ]; + } + + for (var i = 0; i < gameObjects.length; i++) + { + var gameObject = gameObjects[i]; + + gameObject.input.draggable = value; + + var index = this._draggable.indexOf(gameObject); + + if (value && index === -1) + { + this._draggable.push(gameObject); + } + else if (!value && index > -1) + { + this._draggable.splice(index, 1); + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setHitArea + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set the hit area on. + * @param {object} [shape] - The shape or object to check if the pointer is within for hit area checks. + * @param {HitAreaCallback} [callback] - The 'contains' function to invoke to check if the pointer is within the hit area. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setHitArea: function (gameObjects, shape, callback) + { + if (shape === undefined) + { + return this.setHitAreaFromTexture(gameObjects); + } + + if (!Array.isArray(gameObjects)) + { + gameObjects = [ gameObjects ]; + } + + for (var i = 0; i < gameObjects.length; i++) + { + var gameObject = gameObjects[i]; + + gameObject.input = InteractiveObject(gameObject, shape, callback); + + this.queueForInsertion(gameObject); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setHitAreaCircle + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having a circle hit area. + * @param {number} x - The center of the circle. + * @param {number} y - The center of the circle. + * @param {number} radius - The radius of the circle. + * @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Circle.Contains. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setHitAreaCircle: function (gameObjects, x, y, radius, callback) + { + if (callback === undefined) { callback = CircleContains; } + + var shape = new Circle(x, y, radius); + + return this.setHitArea(gameObjects, shape, callback); + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setHitAreaEllipse + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having an ellipse hit area. + * @param {number} x - The center of the ellipse. + * @param {number} y - The center of the ellipse. + * @param {number} width - The width of the ellipse. + * @param {number} height - The height of the ellipse. + * @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Ellipse.Contains. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setHitAreaEllipse: function (gameObjects, x, y, width, height, callback) + { + if (callback === undefined) { callback = EllipseContains; } + + var shape = new Ellipse(x, y, width, height); + + return this.setHitArea(gameObjects, shape, callback); + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setHitAreaFromTexture + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having an ellipse hit area. + * @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Rectangle.Contains. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setHitAreaFromTexture: function (gameObjects, callback) + { + if (callback === undefined) { callback = RectangleContains; } + + if (!Array.isArray(gameObjects)) + { + gameObjects = [ gameObjects ]; + } + + for (var i = 0; i < gameObjects.length; i++) + { + var gameObject = gameObjects[i]; + var frame = gameObject.frame; + + var width = 0; + var height = 0; + + if (frame) + { + width = frame.realWidth; + height = frame.realHeight; + } + else if (gameObject.width) + { + width = gameObject.width; + height = gameObject.height; + } + + if (width !== 0 && height !== 0) + { + gameObject.input = InteractiveObject(gameObject, new Rectangle(0, 0, width, height), callback); + + this.queueForInsertion(gameObject); + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setHitAreaRectangle + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having a rectangular hit area. + * @param {number} x - The top-left of the rectangle. + * @param {number} y - The top-left of the rectangle. + * @param {number} width - The width of the rectangle. + * @param {number} height - The height of the rectangle. + * @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Rectangle.Contains. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setHitAreaRectangle: function (gameObjects, x, y, width, height, callback) + { + if (callback === undefined) { callback = RectangleContains; } + + var shape = new Rectangle(x, y, width, height); + + return this.setHitArea(gameObjects, shape, callback); + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setHitAreaTriangle + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having a triangular hit area. + * @param {number} x1 - The x coordinate of the first point of the triangle. + * @param {number} y1 - The y coordinate of the first point of the triangle. + * @param {number} x2 - The x coordinate of the second point of the triangle. + * @param {number} y2 - The y coordinate of the second point of the triangle. + * @param {number} x3 - The x coordinate of the third point of the triangle. + * @param {number} y3 - The y coordinate of the third point of the triangle. + * @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Triangle.Contains. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setHitAreaTriangle: function (gameObjects, x1, y1, x2, y2, x3, y3, callback) + { + if (callback === undefined) { callback = TriangleContains; } + + var shape = new Triangle(x1, y1, x2, y2, x3, y3); + + return this.setHitArea(gameObjects, shape, callback); + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setPollAlways + * @since 3.0.0 + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setPollAlways: function () + { + this.pollRate = 0; + this._pollTimer = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setPollOnMove + * @since 3.0.0 + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setPollOnMove: function () + { + this.pollRate = -1; + this._pollTimer = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setPollRate + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setPollRate: function (value) + { + this.pollRate = value; + this._pollTimer = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setGlobalTopOnly + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setGlobalTopOnly: function (value) + { + this.manager.globalTopOnly = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setTopOnly + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setTopOnly: function (value) + { + this.topOnly = value; + + return this; + }, + + /** + * Given an array of Game Objects, sort the array and return it, + * so that the objects are in index order with the lowest at the bottom. + * + * @method Phaser.Input.InputPlugin#sortGameObjects + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject[]} gameObjects - [description] + * + * @return {Phaser.GameObjects.GameObject[]} [description] + */ + sortGameObjects: function (gameObjects) + { + if (gameObjects.length < 2) + { + return gameObjects; + } + + this.scene.sys.depthSort(); + + return gameObjects.sort(this.sortHandlerGO.bind(this)); + }, + + /** + * Return the child lowest down the display list (with the smallest index) + * + * @method Phaser.Input.InputPlugin#sortHandlerGO + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} childA - [description] + * @param {Phaser.GameObjects.GameObject} childB - [description] + * + * @return {integer} [description] + */ + sortHandlerGO: function (childA, childB) + { + // The higher the index, the lower down the display list they are. + // So entry 0 will be the top-most item (visually) + var indexA = this.displayList.getIndex(childA); + var indexB = this.displayList.getIndex(childB); + + if (indexA < indexB) + { + return 1; + } + else if (indexA > indexB) + { + return -1; + } + + // Technically this shouldn't happen, but if the GO wasn't part of this display list then it'll + // have an index of -1, so in some cases it can + return 0; + }, + + /** + * Return the child lowest down the display list (with the smallest index) + * + * @method Phaser.Input.InputPlugin#sortHandlerIO + * @since 3.0.0 + * + * @param {Phaser.Input.InteractiveObject} childA - [description] + * @param {Phaser.Input.InteractiveObject} childB - [description] + * + * @return {integer} [description] + */ + sortHandlerIO: function (childA, childB) + { + // The higher the index, the lower down the display list they are. + // So entry 0 will be the top-most item (visually) + var indexA = this.displayList.getIndex(childA.gameObject); + var indexB = this.displayList.getIndex(childB.gameObject); + + if (indexA < indexB) + { + return 1; + } + else if (indexA > indexB) + { + return -1; + } + + // Technically this shouldn't happen, but if the GO wasn't part of this display list then it'll + // have an index of -1, so in some cases it can + return 0; + }, + + /** + * Given an array of Interactive Objects, sort the array and return it, + * so that the objects are in index order with the lowest at the bottom. + * + * @method Phaser.Input.InputPlugin#sortInteractiveObjects + * @since 3.0.0 + * + * @param {Phaser.Input.InteractiveObject[]} interactiveObjects - [description] + * + * @return {Phaser.Input.InteractiveObject[]} [description] + */ + sortInteractiveObjects: function (interactiveObjects) + { + if (interactiveObjects.length < 2) + { + return interactiveObjects; + } + + this.scene.sys.depthSort(); + + return interactiveObjects.sort(this.sortHandlerIO.bind(this)); + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#stopPropagation + * @since 3.0.0 + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + stopPropagation: function () + { + if (this.manager.globalTopOnly) + { + this.manager.ignoreEvents = true; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#update + * @since 3.0.0 + * + * @param {number} time - [description] + * @param {number} delta - [description] + */ + update: function (time, delta) + { + var manager = this.manager; + + // Another Scene above this one has already consumed the input events + if (manager.globalTopOnly && manager.ignoreEvents) + { + return; + } + + var pointer = manager.activePointer; + + var runUpdate = (pointer.dirty || this.pollRate === 0); + + if (this.pollRate > -1) + { + this._pollTimer -= delta; + + if (this._pollTimer < 0) + { + runUpdate = true; + + // Discard timer diff + this._pollTimer = this.pollRate; + } + } + + if (!runUpdate) + { + return; + } + + // Always reset this array + this._tempZones = []; + + // _temp contains a hit tested and camera culled list of IO objects + this._temp = this.hitTestPointer(pointer); + + this.sortGameObjects(this._temp); + this.sortGameObjects(this._tempZones); + + if (this.topOnly) + { + // Only the top-most one counts now, so safely ignore the rest + if (this._temp.length) + { + this._temp.splice(1); + } + + if (this._tempZones.length) + { + this._tempZones.splice(1); + } + } + + var total = this.processDragEvents(pointer, time); + + if (!pointer.wasTouch) + { + total += this.processOverOutEvents(pointer); + } + + if (pointer.justDown) + { + total += this.processDownEvents(pointer); + } + + if (pointer.justUp) + { + total += this.processUpEvents(pointer); + } + + if (pointer.justMoved) + { + total += this.processMoveEvents(pointer); + } + + if (total > 0 && manager.globalTopOnly) + { + // We interacted with an event in this Scene, so block any Scenes below us from doing the same this frame + manager.ignoreEvents = true; + } + }, + + /** + * The Scene that owns this plugin is shutting down. + * + * @method Phaser.Input.InputPlugin#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this._temp.length = 0; + this._list.length = 0; + this._draggable.length = 0; + this._pendingRemoval.length = 0; + this._pendingInsertion.length = 0; + + for (var i = 0; i < 10; i++) + { + this._drag[i] = []; + this._over[i] = []; + } + + this.removeAllListeners(); + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + + this.scene = undefined; + this.cameras = undefined; + this.manager = undefined; + this.events = undefined; + this.keyboard = undefined; + this.mouse = undefined; + this.gamepad = undefined; + }, + + /** + * The current active input Pointer. + * + * @name Phaser.Input.InputPlugin#activePointer + * @type {Phaser.Input.Pointer} + * @readOnly + * @since 3.0.0 + */ + activePointer: { + + get: function () + { + return this.manager.activePointer; + } + + }, + + /** + * The x coordinates of the ActivePointer based on the first camera in the camera list. + * This is only safe to use if your game has just 1 non-transformed camera and doesn't use multi-touch. + * + * @name Phaser.Input.InputPlugin#x + * @type {number} + * @readOnly + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.manager.activePointer.x; + } + + }, + + /** + * The y coordinates of the ActivePointer based on the first camera in the camera list. + * This is only safe to use if your game has just 1 non-transformed camera and doesn't use multi-touch. + * + * @name Phaser.Input.InputPlugin#y + * @type {number} + * @readOnly + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.manager.activePointer.y; + } + + } + +}); + +PluginManager.register('InputPlugin', InputPlugin, 'input'); + +module.exports = InputPlugin; /***/ }), /* 561 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -92016,30 +91405,50 @@ module.exports = Clone; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Contains = __webpack_require__(68); - /** - * Check to see if the Ellipse contains the given Point object. + * XBox 360 Gamepad Configuration. * - * @function Phaser.Geom.Ellipse.ContainsPoint + * @name Phaser.Input.Gamepad.Configs.XBOX_360 + * @type {object} * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. - * @param {Phaser.Geom.Point|object} point - The Point object to check if it's within the Circle or not. - * - * @return {boolean} True if the Point coordinates are within the circle, otherwise false. */ -var ContainsPoint = function (ellipse, point) -{ - return Contains(ellipse, point.x, point.y); -}; +module.exports = { -module.exports = ContainsPoint; + UP: 12, + DOWN: 13, + LEFT: 14, + RIGHT: 15, + + MENU: 16, + + A: 0, + B: 1, + X: 2, + Y: 3, + + LB: 4, + RB: 5, + + LT: 6, + RT: 7, + + BACK: 8, + START: 9, + + LS: 10, + RS: 11, + + LEFT_STICK_H: 0, + LEFT_STICK_V: 1, + RIGHT_STICK_H: 2, + RIGHT_STICK_V: 3 + +}; /***/ }), /* 562 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -92047,30 +91456,33 @@ module.exports = ContainsPoint; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Contains = __webpack_require__(68); - /** - * Check to see if the Ellipse contains all four points of the given Rectangle object. + * Tatar SNES USB Controller Gamepad Configuration. + * USB Gamepad (STANDARD GAMEPAD Vendor: 0079 Product: 0011) * - * @function Phaser.Geom.Ellipse.ContainsRect + * @name Phaser.Input.Gamepad.Configs.SNES_USB + * @type {object} * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - [description] - * @param {Phaser.Geom.Rectangle|object} rect - The Rectangle object to check if it's within the Ellipse or not. - * - * @return {boolean} True if all of the Rectangle coordinates are within the ellipse, otherwise false. */ -var ContainsRect = function (ellipse, rect) -{ - return ( - Contains(ellipse, rect.x, rect.y) && - Contains(ellipse, rect.right, rect.y) && - Contains(ellipse, rect.x, rect.bottom) && - Contains(ellipse, rect.right, rect.bottom) - ); -}; +module.exports = { -module.exports = ContainsRect; + UP: 12, + DOWN: 13, + LEFT: 14, + RIGHT: 15, + + SELECT: 8, + START: 9, + + B: 0, + A: 1, + Y: 2, + X: 3, + + LEFT_SHOULDER: 4, + RIGHT_SHOULDER: 5 + +}; /***/ }), @@ -92084,28 +91496,48 @@ module.exports = ContainsRect; */ /** - * Copies the `x`, `y`, `width` and `height` properties from the `source` Ellipse - * into the given `dest` Ellipse, then returns the `dest` Ellipse. + * PlayStation DualShock 4 Gamepad Configuration. + * Sony PlayStation DualShock 4 (v2) wireless controller * - * @function Phaser.Geom.Ellipse.CopyFrom + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4 + * @type {object} * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} source - The source Ellipse to copy the values from. - * @param {Phaser.Geom.Ellipse} dest - The destination Ellipse to copy the values to. - * - * @return {Phaser.Geom.Ellipse} The dest Ellipse. */ -var CopyFrom = function (source, dest) -{ - return dest.setTo(source.x, source.y, source.width, source.height); -}; +module.exports = { -module.exports = CopyFrom; + UP: 12, + DOWN: 13, + LEFT: 14, + RIGHT: 15, + + SHARE: 8, + OPTIONS: 9, + PS: 16, + TOUCHBAR: 17, + + X: 0, + CIRCLE: 1, + SQUARE: 2, + TRIANGLE: 3, + + L1: 4, + R1: 5, + L2: 6, + R2: 7, + L3: 10, + R3: 11, + + LEFT_STICK_H: 0, + LEFT_STICK_V: 1, + RIGHT_STICK_H: 2, + RIGHT_STICK_V: 3 + +}; /***/ }), /* 564 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -92114,28 +91546,16 @@ module.exports = CopyFrom; */ /** - * Compares the `x`, `y`, `width` and `height` properties of the two given Ellipses. - * Returns `true` if they all match, otherwise returns `false`. - * - * @function Phaser.Geom.Ellipse.Equals - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The first Ellipse to compare. - * @param {Phaser.Geom.Ellipse} toCompare - The second Ellipse to compare. - * - * @return {boolean} `true` if the two Ellipse equal each other, otherwise `false`. + * @namespace Phaser.Input.Gamepad.Configs */ -var Equals = function (ellipse, toCompare) -{ - return ( - ellipse.x === toCompare.x && - ellipse.y === toCompare.y && - ellipse.width === toCompare.width && - ellipse.height === toCompare.height - ); -}; -module.exports = Equals; +module.exports = { + + DUALSHOCK_4: __webpack_require__(563), + SNES_USB: __webpack_require__(562), + XBOX_360: __webpack_require__(561) + +}; /***/ }), @@ -92148,37 +91568,24 @@ module.exports = Equals; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Rectangle = __webpack_require__(8); - /** - * Returns the bounds of the Ellipse object. - * - * @function Phaser.Geom.Ellipse.GetBounds - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the bounds from. - * @param {Phaser.Geom.Rectangle|object} [out] - A Rectangle, or rectangle-like object, to store the ellipse bounds in. If not given a new Rectangle will be created. - * - * @return {Phaser.Geom.Rectangle|object} The Rectangle object containing the Ellipse bounds. + * @namespace Phaser.Input.Gamepad */ -var GetBounds = function (ellipse, out) -{ - if (out === undefined) { out = new Rectangle(); } - out.x = ellipse.left; - out.y = ellipse.top; - out.width = ellipse.width; - out.height = ellipse.height; +module.exports = { - return out; + Axis: __webpack_require__(296), + Button: __webpack_require__(295), + Gamepad: __webpack_require__(297), + GamepadManager: __webpack_require__(298), + + Configs: __webpack_require__(564) }; -module.exports = GetBounds; - /***/ }), /* 566 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -92187,31 +91594,26 @@ module.exports = GetBounds; */ /** - * Offsets the Ellipse by the values given. - * - * @function Phaser.Geom.Ellipse.Offset - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to be offset (translated.) - * @param {number} x - The amount to horizontally offset the Ellipse by. - * @param {number} y - The amount to vertically offset the Ellipse by. - * - * @return {Phaser.Geom.Ellipse} The Ellipse that was offset. + * @namespace Phaser.Input */ -var Offset = function (ellipse, x, y) -{ - ellipse.x += x; - ellipse.y += y; - return ellipse; +module.exports = { + + Gamepad: __webpack_require__(565), + InputManager: __webpack_require__(299), + InputPlugin: __webpack_require__(560), + InteractiveObject: __webpack_require__(227), + Keyboard: __webpack_require__(559), + Mouse: __webpack_require__(554), + Pointer: __webpack_require__(290), + Touch: __webpack_require__(553) + }; -module.exports = Offset; - /***/ }), /* 567 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -92219,26 +91621,26 @@ module.exports = Offset; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var RotateAroundXY = __webpack_require__(123); + /** - * Offsets the Ellipse by the values given in the `x` and `y` properties of the Point object. + * [description] * - * @function Phaser.Geom.Ellipse.OffsetPoint + * @function Phaser.Geom.Triangle.RotateAroundPoint * @since 3.0.0 * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to be offset (translated.) - * @param {Phaser.Geom.Point|object} point - The Point object containing the values to offset the Ellipse by. + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Point} point - [description] + * @param {number} angle - [description] * - * @return {Phaser.Geom.Ellipse} The Ellipse that was offset. + * @return {Phaser.Geom.Triangle} [description] */ -var OffsetPoint = function (ellipse, point) +var RotateAroundPoint = function (triangle, point, angle) { - ellipse.x += point.x; - ellipse.y += point.y; - - return ellipse; + return RotateAroundXY(triangle, point.x, point.y, angle); }; -module.exports = OffsetPoint; +module.exports = RotateAroundPoint; /***/ }), @@ -92251,29 +91653,29 @@ module.exports = OffsetPoint; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); +var RotateAroundXY = __webpack_require__(123); +var InCenter = __webpack_require__(228); -if (true) +/** + * [description] + * + * @function Phaser.Geom.Triangle.Rotate + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} angle - [description] + * + * @return {Phaser.Geom.Triangle} [description] + */ +var Rotate = function (triangle, angle) { - renderWebGL = __webpack_require__(569); - - // Needed for Graphics.generateTexture - renderCanvas = __webpack_require__(274); -} - -if (true) -{ - renderCanvas = __webpack_require__(274); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas + var point = InCenter(triangle); + return RotateAroundXY(triangle, point.x, point.y, angle); }; +module.exports = Rotate; + /***/ }), /* 569 */ @@ -92285,38 +91687,35 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(1); +var Length = __webpack_require__(77); + +// The 2D area of a triangle. The area value is always non-negative. /** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. + * [description] * - * @method Phaser.GameObjects.Graphics#renderWebGL + * @function Phaser.Geom.Triangle.Perimeter * @since 3.0.0 - * @private * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Graphics} graphics - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.Geom.Triangle} triangle - [description] + * + * @return {number} [description] */ -var GraphicsWebGLRenderer = function (renderer, graphics, interpolationPercentage, camera) +var Perimeter = function (triangle) { - if (GameObject.RENDER_MASK !== graphics.renderFlags || (graphics.cameraFilter > 0 && (graphics.cameraFilter & camera._id))) - { - return; - } + var line1 = triangle.getLineA(); + var line2 = triangle.getLineB(); + var line3 = triangle.getLineC(); - this.pipeline.batchGraphics(this, camera); + return (Length(line1) + Length(line2) + Length(line3)); }; -module.exports = GraphicsWebGLRenderer; +module.exports = Perimeter; /***/ }), /* 570 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -92324,30 +91723,35 @@ module.exports = GraphicsWebGLRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) +/** + * [description] + * + * @function Phaser.Geom.Triangle.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Triangle} toCompare - [description] + * + * @return {boolean} [description] + */ +var Equals = function (triangle, toCompare) { - renderWebGL = __webpack_require__(571); -} - -if (true) -{ - renderCanvas = __webpack_require__(572); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - + return ( + triangle.x1 === toCompare.x1 && + triangle.y1 === toCompare.y1 && + triangle.x2 === toCompare.x2 && + triangle.y2 === toCompare.y2 && + triangle.x3 === toCompare.x3 && + triangle.y3 === toCompare.y3 + ); }; +module.exports = Equals; + /***/ }), /* 571 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -92355,33 +91759,23 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(1); - /** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. + * [description] * - * @method Phaser.GameObjects.Image#renderWebGL + * @function Phaser.Geom.Triangle.CopyFrom * @since 3.0.0 - * @private * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Image} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.Geom.Triangle} source - [description] + * @param {Phaser.Geom.Triangle} dest - [description] + * + * @return {Phaser.Geom.Triangle} [description] */ -var ImageWebGLRenderer = function (renderer, src, interpolationPercentage, camera) +var CopyFrom = function (source, dest) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.batchSprite(src, camera); + return dest.setTo(source.x1, source.y1, source.x2, source.y2, source.x3, source.y3); }; -module.exports = ImageWebGLRenderer; +module.exports = CopyFrom; /***/ }), @@ -92394,33 +91788,25 @@ module.exports = ImageWebGLRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(1); +var Contains = __webpack_require__(54); /** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. + * [description] * - * @method Phaser.GameObjects.Image#renderCanvas + * @function Phaser.Geom.Triangle.ContainsPoint * @since 3.0.0 - * @private * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Image} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Point} point - [description] + * + * @return {boolean} [description] */ -var ImageCanvasRenderer = function (renderer, src, interpolationPercentage, camera) +var ContainsPoint = function (triangle, point) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - renderer.drawImage(src, camera); + return Contains(triangle, point.x, point.y); }; -module.exports = ImageCanvasRenderer; +module.exports = ContainsPoint; /***/ }), @@ -92433,209 +91819,24 @@ module.exports = ImageCanvasRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(2); +var Triangle = __webpack_require__(52); /** - * @classdesc * [description] * - * @class GravityWell - * @memberOf Phaser.GameObjects.Particles - * @constructor + * @function Phaser.Geom.Triangle.Clone * @since 3.0.0 * - * @param {number|object} [x=0] - The x coordinate of the Gravity Well, in world space. - * @param {number} [y=0] - The y coordinate of the Gravity Well, in world space. - * @param {number} [power=0] - The power of the Gravity Well. - * @param {number} [epsilon=100] - [description] - * @param {number} [gravity=50] - The gravitational force of this Gravity Well. + * @param {Phaser.Geom.Triangle} source - [description] + * + * @return {Phaser.Geom.Triangle} [description] */ -var GravityWell = new Class({ +var Clone = function (source) +{ + return new Triangle(source.x1, source.y1, source.x2, source.y2, source.x3, source.y3); +}; - initialize: - - function GravityWell (x, y, power, epsilon, gravity) - { - if (typeof x === 'object') - { - var config = x; - - x = GetFastValue(config, 'x', 0); - y = GetFastValue(config, 'y', 0); - power = GetFastValue(config, 'power', 0); - epsilon = GetFastValue(config, 'epsilon', 100); - gravity = GetFastValue(config, 'gravity', 50); - } - else - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (power === undefined) { power = 0; } - if (epsilon === undefined) { epsilon = 100; } - if (gravity === undefined) { gravity = 50; } - } - - /** - * The x coordinate of the Gravity Well, in world space. - * - * @name Phaser.GameObjects.Particles.GravityWell#x - * @type {number} - * @since 3.0.0 - */ - this.x = x; - - /** - * The y coordinate of the Gravity Well, in world space. - * - * @name Phaser.GameObjects.Particles.GravityWell#y - * @type {number} - * @since 3.0.0 - */ - this.y = y; - - /** - * The active state of the Gravity Well. An inactive Gravity Well will not influence any particles. - * - * @name Phaser.GameObjects.Particles.GravityWell#active - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.active = true; - - /** - * Internal gravity value. - * - * @name Phaser.GameObjects.Particles.GravityWell#_gravity - * @type {number} - * @private - * @since 3.0.0 - */ - this._gravity = gravity; - - /** - * Internal power value. - * - * @name Phaser.GameObjects.Particles.GravityWell#_power - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._power = 0; - - /** - * Internal epsilon value. - * - * @name Phaser.GameObjects.Particles.GravityWell#_epsilon - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._epsilon = 0; - - /** - * The power of the Gravity Well. - * - * @name Phaser.GameObjects.Particles.GravityWell#power - * @type {number} - * @since 3.0.0 - */ - this.power = power; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.GravityWell#epsilon - * @type {number} - * @since 3.0.0 - */ - this.epsilon = epsilon; - }, - - /** - * Takes a Particle and updates it based on the properties of this Gravity Well. - * - * @method Phaser.GameObjects.Particles.GravityWell#update - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle to update. - * @param {number} delta - The delta time in ms. - * @param {float} step - The delta value divided by 1000. - */ - update: function (particle, delta) - { - var x = this.x - particle.x; - var y = this.y - particle.y; - var dSq = x * x + y * y; - - if (dSq === 0) - { - return; - } - - var d = Math.sqrt(dSq); - - if (dSq < this._epsilon) - { - dSq = this._epsilon; - } - - var factor = ((this._power * delta) / (dSq * d)) * 100; - - particle.velocityX += x * factor; - particle.velocityY += y * factor; - }, - - epsilon: { - - get: function () - { - return Math.sqrt(this._epsilon); - }, - - set: function (value) - { - this._epsilon = value * value; - } - - }, - - power: { - - get: function () - { - return this._power / this._gravity; - }, - - set: function (value) - { - this._power = value * this._gravity; - } - - }, - - gravity: { - - get: function () - { - return this._gravity; - }, - - set: function (value) - { - var pwr = this.power; - this._gravity = value; - this.power = pwr; - } - - } - -}); - -module.exports = GravityWell; +module.exports = Clone; /***/ }), @@ -92648,1975 +91849,75 @@ module.exports = GravityWell; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BlendModes = __webpack_require__(45); -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var DeathZone = __webpack_require__(575); -var EdgeZone = __webpack_require__(576); -var EmitterOp = __webpack_require__(577); -var GetFastValue = __webpack_require__(2); -var GetRandomElement = __webpack_require__(140); -var HasAny = __webpack_require__(289); -var HasValue = __webpack_require__(72); -var Particle = __webpack_require__(611); -var RandomZone = __webpack_require__(612); -var Rectangle = __webpack_require__(8); -var StableSort = __webpack_require__(267); -var Vector2 = __webpack_require__(6); -var Wrap = __webpack_require__(50); +var Circle = __webpack_require__(79); + +// Adapted from https://gist.github.com/mutoo/5617691 /** - * @classdesc * [description] * - * @class ParticleEmitter - * @memberOf Phaser.GameObjects.Particles - * @constructor + * @function Phaser.Geom.Triangle.CircumCircle * @since 3.0.0 * - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Visible + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Circle} [out] - [description] * - * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} manager - The Emitter Manager this Emitter belongs to. - * @param {object} config - [description] + * @return {Phaser.Geom.Circle} [description] */ -var ParticleEmitter = new Class({ +var CircumCircle = function (triangle, out) +{ + if (out === undefined) { out = new Circle(); } - Mixins: [ - Components.BlendMode, - Components.ScrollFactor, - Components.Visible - ], + // A + var x1 = triangle.x1; + var y1 = triangle.y1; - initialize: + // B + var x2 = triangle.x2; + var y2 = triangle.y2; - function ParticleEmitter (manager, config) + // C + var x3 = triangle.x3; + var y3 = triangle.y3; + + var A = x2 - x1; + var B = y2 - y1; + var C = x3 - x1; + var D = y3 - y1; + var E = A * (x1 + x2) + B * (y1 + y2); + var F = C * (x1 + x3) + D * (y1 + y3); + var G = 2 * (A * (y3 - y2) - B * (x3 - x2)); + + var dx; + var dy; + + // If the points of the triangle are collinear, then just find the + // extremes and use the midpoint as the center of the circumcircle. + + if (Math.abs(G) < 0.000001) { - /** - * The Emitter Manager this Emitter belongs to. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#manager - * @type {Phaser.GameObjects.Particles.ParticleEmitterManager} - * @since 3.0.0 - */ - this.manager = manager; + var minX = Math.min(x1, x2, x3); + var minY = Math.min(y1, y2, y3); + dx = (Math.max(x1, x2, x3) - minX) * 0.5; + dy = (Math.max(y1, y2, y3) - minY) * 0.5; - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#texture - * @type {Phaser.Textures.Texture} - * @since 3.0.0 - */ - this.texture = manager.texture; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#frames - * @type {Phaser.Textures.Frame[]} - * @since 3.0.0 - */ - this.frames = [ manager.defaultFrame ]; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#defaultFrame - * @type {Phaser.Textures.Frame} - * @since 3.0.0 - */ - this.defaultFrame = manager.defaultFrame; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#configFastMap - * @type {object} - * @since 3.0.0 - */ - this.configFastMap = [ - 'active', - 'blendMode', - 'collideBottom', - 'collideLeft', - 'collideRight', - 'collideTop', - 'deathCallback', - 'deathCallbackScope', - 'emitCallback', - 'emitCallbackScope', - 'follow', - 'frequency', - 'gravityX', - 'gravityY', - 'maxParticles', - 'name', - 'on', - 'particleBringToTop', - 'particleClass', - 'radial', - 'timeScale', - 'trackVisible', - 'visible' - ]; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#configOpMap - * @type {object} - * @since 3.0.0 - */ - this.configOpMap = [ - 'accelerationX', - 'accelerationY', - 'alpha', - 'bounce', - 'delay', - 'lifespan', - 'maxVelocityX', - 'maxVelocityY', - 'moveToX', - 'moveToY', - 'quantity', - 'rotate', - 'scaleX', - 'scaleY', - 'speedX', - 'speedY', - 'tint', - 'x', - 'y' - ]; - - /** - * The name of this Game Object. - * - * Empty by default and never populated by Phaser, this is left for developers to use. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#name - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.name = ''; - - /** - * The Particle Class which will be emitted by this Emitter. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#particleClass - * @type {Phaser.GameObjects.Particles.Particle} - * @since 3.0.0 - */ - this.particleClass = Particle; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#x - * @type {number} - * @since 3.0.0 - */ - this.x = new EmitterOp(config, 'x', 0); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#y - * @type {number} - * @since 3.0.0 - */ - this.y = new EmitterOp(config, 'y', 0); - - /** - * A radial emitter will emit particles in all directions between angle min and max, - * using speed as the value. If set to false then this acts as a point Emitter. - * A point emitter will emit particles only in the direction derived from the speedX and speedY values. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#radial - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.radial = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#gravityX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.gravityX = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#gravityY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.gravityY = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#acceleration - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.acceleration = false; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#accelerationX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.accelerationX = new EmitterOp(config, 'accelerationX', 0, true); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#accelerationY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.accelerationY = new EmitterOp(config, 'accelerationY', 0, true); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityX - * @type {number} - * @default 10000 - * @since 3.0.0 - */ - this.maxVelocityX = new EmitterOp(config, 'maxVelocityX', 10000, true); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityY - * @type {number} - * @default 10000 - * @since 3.0.0 - */ - this.maxVelocityY = new EmitterOp(config, 'maxVelocityY', 10000, true); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#speedX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.speedX = new EmitterOp(config, 'speedX', 0, true); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#speedY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.speedY = new EmitterOp(config, 'speedY', 0, true); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#moveTo - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.moveTo = false; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#moveToX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.moveToX = new EmitterOp(config, 'moveToX', 0, true); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#moveToY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.moveToY = new EmitterOp(config, 'moveToY', 0, true); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#bounce - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.bounce = new EmitterOp(config, 'bounce', 0, true); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#scaleX - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.scaleX = new EmitterOp(config, 'scaleX', 1); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#scaleY - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.scaleY = new EmitterOp(config, 'scaleY', 1); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#tint - * @type {integer} - * @since 3.0.0 - */ - this.tint = new EmitterOp(config, 'tint', 0xffffffff); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#alpha - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.alpha = new EmitterOp(config, 'alpha', 1); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#lifespan - * @type {number} - * @default 1000 - * @since 3.0.0 - */ - this.lifespan = new EmitterOp(config, 'lifespan', 1000); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#angle - * @type {number} - * @since 3.0.0 - */ - this.angle = new EmitterOp(config, 'angle', { min: 0, max: 360 }); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#rotate - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.rotate = new EmitterOp(config, 'rotate', 0); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#emitCallback - * @type {?function} - * @default null - * @since 3.0.0 - */ - this.emitCallback = null; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope - * @type {?object} - * @default null - * @since 3.0.0 - */ - this.emitCallbackScope = null; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#deathCallback - * @type {?function} - * @default null - * @since 3.0.0 - */ - this.deathCallback = null; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope - * @type {?object} - * @default null - * @since 3.0.0 - */ - this.deathCallbackScope = null; - - /** - * Set to hard limit the amount of particle objects this emitter is allowed to create. - * 0 means unlimited. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#maxParticles - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.maxParticles = 0; - - /** - * How many particles are emitted each time the emitter updates. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#quantity - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.quantity = new EmitterOp(config, 'quantity', 1, true); - - /** - * How many ms to wait after emission before the particles start updating. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#delay - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.delay = new EmitterOp(config, 'delay', 0, true); - - /** - * How often a particle is emitted in ms (if emitter is a constant / flow emitter) - * If emitter is an explosion emitter this value will be -1. - * Anything > -1 sets this to be a flow emitter. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#frequency - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.frequency = 0; - - /** - * Controls if the emitter is currently emitting particles. - * Already alive particles will continue to update until they expire. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#on - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.on = true; - - /** - * Newly emitted particles are added to the top of the particle list, i.e. rendered above those already alive. - * Set to false to send them to the back. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#particleBringToTop - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.particleBringToTop = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#timeScale - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#emitZone - * @type {?object} - * @default null - * @since 3.0.0 - */ - this.emitZone = null; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#deathZone - * @type {?object} - * @default null - * @since 3.0.0 - */ - this.deathZone = null; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#bounds - * @type {?Phaser.Geom.Rectangle} - * @default null - * @since 3.0.0 - */ - this.bounds = null; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#collideLeft - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.collideLeft = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#collideRight - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.collideRight = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#collideTop - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.collideTop = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#collideBottom - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.collideBottom = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#active - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.active = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#visible - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.visible = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#blendMode - * @type {integer} - * @since 3.0.0 - */ - this.blendMode = BlendModes.NORMAL; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#follow - * @type {?[type]} - * @default null - * @since 3.0.0 - */ - this.follow = null; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#followOffset - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.followOffset = new Vector2(); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#trackVisible - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.trackVisible = false; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#currentFrame - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.currentFrame = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#randomFrame - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.randomFrame = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#frameQuantity - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.frameQuantity = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#dead - * @type {array} - * @private - * @since 3.0.0 - */ - this.dead = []; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#alive - * @type {array} - * @private - * @since 3.0.0 - */ - this.alive = []; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#_counter - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._counter = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#_frameCounter - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._frameCounter = 0; - - if (config) - { - this.fromJSON(config); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#fromJSON - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - fromJSON: function (config) + out.x = minX + dx; + out.y = minY + dy; + out.radius = Math.sqrt(dx * dx + dy * dy); + } + else { - if (!config) - { - return this; - } - - // Only update properties from their current state if they exist in the given config - - var i = 0; - var key = ''; - - for (i = 0; i < this.configFastMap.length; i++) - { - key = this.configFastMap[i]; - - if (HasValue(config, key)) - { - this[key] = GetFastValue(config, key); - } - } - - for (i = 0; i < this.configOpMap.length; i++) - { - key = this.configOpMap[i]; - - if (HasValue(config, key)) - { - this[key].loadConfig(config); - } - } - - this.acceleration = (this.accelerationX.propertyValue !== 0 || this.accelerationY.propertyValue !== 0); - - this.moveTo = (this.moveToX.propertyValue !== 0 || this.moveToY.propertyValue !== 0); - - // Special 'speed' override - - if (HasValue(config, 'speed')) - { - this.speedX.loadConfig(config, 'speed'); - this.speedY = null; - } - - // If you specify speedX, speedY ot moveTo then it changes the emitter from radial to a point emitter - if (HasAny(config, [ 'speedX', 'speedY' ]) || this.moveTo) - { - this.radial = false; - } - - // Special 'scale' override - - if (HasValue(config, 'scale')) - { - this.scaleX.loadConfig(config, 'scale'); - this.scaleY = null; - } - - if (HasValue(config, 'callbackScope')) - { - var callbackScope = GetFastValue(config, 'callbackScope', null); - - this.emitCallbackScope = callbackScope; - this.deathCallbackScope = callbackScope; - } - - if (HasValue(config, 'emitZone')) - { - this.setEmitZone(config.emitZone); - } - - if (HasValue(config, 'deathZone')) - { - this.setDeathZone(config.deathZone); - } - - if (HasValue(config, 'bounds')) - { - this.setBounds(config.bounds); - } - - if (HasValue(config, 'followOffset')) - { - this.followOffset.setFromObject(GetFastValue(config, 'followOffset', 0)); - } - - if (HasValue(config, 'frame')) - { - this.setFrame(config.frame); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#toJSON - * @since 3.0.0 - * - * @param {object} output - [description] - * - * @return {object} [description] - */ - toJSON: function (output) - { - if (output === undefined) { output = {}; } - - var i = 0; - var key = ''; - - for (i = 0; i < this.configFastMap.length; i++) - { - key = this.configFastMap[i]; - - output[key] = this[key]; - } - - for (i = 0; i < this.configOpMap.length; i++) - { - key = this.configOpMap[i]; - - if (this[key]) - { - output[key] = this[key].toJSON(); - } - } - - // special handlers - if (!this.speedY) - { - delete output.speedX; - output.speed = this.speedX.toJSON(); - } - - if (!this.scaleY) - { - delete output.scaleX; - output.scale = this.scaleX.toJSON(); - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#startFollow - * @since 3.0.0 - * - * @param {[type]} target - [description] - * @param {number} offsetX - [description] - * @param {number} offsetY - [description] - * @param {boolean} trackVisible - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - startFollow: function (target, offsetX, offsetY, trackVisible) - { - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - if (trackVisible === undefined) { trackVisible = false; } - - this.follow = target; - this.followOffset.set(offsetX, offsetY); - this.trackVisible = trackVisible; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#stopFollow - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - stopFollow: function () - { - this.follow = null; - this.followOffset.set(0, 0); - this.trackVisible = false; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#getFrame - * @since 3.0.0 - * - * @return {Phaser.Textures.Frame} [description] - */ - getFrame: function () - { - if (this.frames.length === 1) - { - return this.defaultFrame; - } - else if (this.randomFrame) - { - return GetRandomElement(this.frames); - } - else - { - var frame = this.frames[this.currentFrame]; - - this._frameCounter++; - - if (this._frameCounter === this.frameQuantity) - { - this._frameCounter = 0; - this.currentFrame = Wrap(this.currentFrame + 1, 0, this._frameLength); - } - - return frame; - } - }, - - // frame: 0 - // frame: 'red' - // frame: [ 0, 1, 2, 3 ] - // frame: [ 'red', 'green', 'blue', 'pink', 'white' ] - // frame: { frames: [ 'red', 'green', 'blue', 'pink', 'white' ], [cycle: bool], [quantity: int] } - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setFrame - * @since 3.0.0 - * - * @param {array|string|integer|object} frames - [description] - * @param {boolean} [pickRandom=true] - [description] - * @param {integer} [quantity=1] - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setFrame: function (frames, pickRandom, quantity) - { - if (pickRandom === undefined) { pickRandom = true; } - if (quantity === undefined) { quantity = 1; } - - this.randomFrame = pickRandom; - this.frameQuantity = quantity; - this.currentFrame = 0; - this._frameCounter = 0; - - var t = typeof (frames); - - if (Array.isArray(frames) || t === 'string' || t === 'number') - { - this.manager.setEmitterFrames(frames, this); - } - else if (t === 'object') - { - var frameConfig = frames; - - frames = GetFastValue(frameConfig, 'frames', null); - - if (frames) - { - this.manager.setEmitterFrames(frames, this); - } - - var isCycle = GetFastValue(frameConfig, 'cycle', false); - - this.randomFrame = (isCycle) ? false : true; - - this.frameQuantity = GetFastValue(frameConfig, 'quantity', quantity); - } - - this._frameLength = this.frames.length; - - if (this._frameLength === 1) - { - this.frameQuantity = 1; - this.randomFrame = false; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setRadial - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setRadial: function (value) - { - if (value === undefined) { value = true; } - - this.radial = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setPosition - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setPosition: function (x, y) - { - this.x.onChange(x); - this.y.onChange(y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setBounds - * @since 3.0.0 - * - * @param {number|object} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setBounds: function (x, y, width, height) - { - if (typeof x === 'object') - { - var obj = x; - - x = obj.x; - y = obj.y; - width = (HasValue(obj, 'w')) ? obj.w : obj.width; - height = (HasValue(obj, 'h')) ? obj.h : obj.height; - } - - if (this.bounds) - { - this.bounds.setTo(x, y, width, height); - } - else - { - this.bounds = new Rectangle(x, y, width, height); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeedX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setSpeedX: function (value) - { - this.speedX.onChange(value); - - // If you specify speedX and Y then it changes the emitter from radial to a point emitter - this.radial = false; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeedY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setSpeedY: function (value) - { - if (this.speedY) - { - this.speedY.onChange(value); - - // If you specify speedX and Y then it changes the emitter from radial to a point emitter - this.radial = false; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeed - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setSpeed: function (value) - { - this.speedX.onChange(value); - this.speedY = null; - - // If you specify speedX and Y then it changes the emitter from radial to a point emitter - this.radial = true; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setScaleX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setScaleX: function (value) - { - this.scaleX.onChange(value); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setScaleY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setScaleY: function (value) - { - this.scaleY.onChange(value); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setScale - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setScale: function (value) - { - this.scaleX.onChange(value); - this.scaleY = null; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravityX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setGravityX: function (value) - { - this.gravityX = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravityY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setGravityY: function (value) - { - this.gravityY = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravity - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setGravity: function (x, y) - { - this.gravityX = x; - this.gravityY = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setAlpha - * @since 3.0.0 - * - * @param {float} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setAlpha: function (value) - { - this.alpha.onChange(value); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setEmitterAngle - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setEmitterAngle: function (value) - { - this.angle.onChange(value); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setAngle - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setAngle: function (value) - { - this.angle.onChange(value); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setLifespan - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setLifespan: function (value) - { - this.lifespan.onChange(value); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setQuantity - * @since 3.0.0 - * - * @param {integer} quantity - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setQuantity: function (quantity) - { - this.quantity.onChange(quantity); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setFrequency - * @since 3.0.0 - * - * @param {number} frequency - [description] - * @param {integer} [quantity] - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setFrequency: function (frequency, quantity) - { - this.frequency = frequency; - - this._counter = 0; - - if (quantity) - { - this.quantity.onChange(quantity); - } - - return this; - }, - - /** - * The zone must have a function called `getPoint` that takes a particle object and sets - * its x and y properties accordingly then returns that object. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone - * @since 3.0.0 - * - * @param {[type]} zoneConfig - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setEmitZone: function (zoneConfig) - { - if (zoneConfig === undefined) - { - this.emitZone = null; - } - else - { - // Where source = Geom like Circle, or a Path or Curve - // emitZone: { type: 'random', source: X } - // emitZone: { type: 'edge', source: X, quantity: 32, [stepRate=0], [yoyo=false], [seamless=true] } - - var type = GetFastValue(zoneConfig, 'type', 'random'); - var source = GetFastValue(zoneConfig, 'source', null); - - if (source && typeof source.getPoint === 'function') - { - switch (type) - { - case 'random': - - this.emitZone = new RandomZone(source); - - break; - - case 'edge': - - var quantity = GetFastValue(zoneConfig, 'quantity', 1); - var stepRate = GetFastValue(zoneConfig, 'stepRate', 0); - var yoyo = GetFastValue(zoneConfig, 'yoyo', false); - var seamless = GetFastValue(zoneConfig, 'seamless', true); - - this.emitZone = new EdgeZone(source, quantity, stepRate, yoyo, seamless); - - break; - } - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setDeathZone - * @since 3.0.0 - * - * @param {[type]} zoneConfig - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setDeathZone: function (zoneConfig) - { - if (zoneConfig === undefined) - { - this.deathZone = null; - } - else - { - // Where source = Geom like Circle or Rect that supports a 'contains' function - // deathZone: { type: 'onEnter', source: X } - // deathZone: { type: 'onLeave', source: X } - - var type = GetFastValue(zoneConfig, 'type', 'onEnter'); - var source = GetFastValue(zoneConfig, 'source', null); - - if (source && typeof source.contains === 'function') - { - var killOnEnter = (type === 'onEnter') ? true : false; - - this.deathZone = new DeathZone(source, killOnEnter); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#reserve - * @since 3.0.0 - * - * @param {integer} particleCount - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - reserve: function (particleCount) - { - var dead = this.dead; - - for (var i = 0; i < particleCount; i++) - { - dead.push(new this.particleClass(this)); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#getAliveParticleCount - * @since 3.0.0 - * - * @return {integer} The number of currently alive Particles in this Emitter. - */ - getAliveParticleCount: function () - { - return this.alive.length; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#getDeadParticleCount - * @since 3.0.0 - * - * @return {integer} The number of currently dead Particles in this Emitter. - */ - getDeadParticleCount: function () - { - return this.dead.length; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#getParticleCount - * @since 3.0.0 - * - * @return {integer} The number of Particles in this Emitter, including both alive and dead. - */ - getParticleCount: function () - { - return this.getAliveParticleCount() + this.getDeadParticleCount(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#atLimit - * @since 3.0.0 - * - * @return {boolean} Returns `true` if this Emitter is at its limit, or `false` if no limit, or below the `maxParticles` level. - */ - atLimit: function () - { - return (this.maxParticles > 0 && this.getParticleCount() === this.maxParticles); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#onParticleEmit - * @since 3.0.0 - * - * @param {[type]} callback - [description] - * @param {[type]} context - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - onParticleEmit: function (callback, context) - { - if (callback === undefined) - { - // Clear any previously set callback - this.emitCallback = null; - this.emitCallbackScope = null; - } - else if (typeof callback === 'function') - { - this.emitCallback = callback; - - if (context) - { - this.emitCallbackScope = context; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#onParticleDeath - * @since 3.0.0 - * - * @param {[type]} callback - [description] - * @param {[type]} context - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - onParticleDeath: function (callback, context) - { - if (callback === undefined) - { - // Clear any previously set callback - this.deathCallback = null; - this.deathCallbackScope = null; - } - else if (typeof callback === 'function') - { - this.deathCallback = callback; - - if (context) - { - this.deathCallbackScope = context; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#killAll - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - killAll: function () - { - var dead = this.dead; - var alive = this.alive; - - while (alive.length > 0) - { - dead.push(alive.pop()); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#forEachAlive - * @since 3.0.0 - * - * @param {[type]} callback - [description] - * @param {[type]} thisArg - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - forEachAlive: function (callback, thisArg) - { - var alive = this.alive; - var length = alive.length; - - for (var index = 0; index < length; ++index) - { - // Sends the Particle and the Emitter - callback.call(thisArg, alive[index], this); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#forEachDead - * @since 3.0.0 - * - * @param {[type]} callback - [description] - * @param {[type]} thisArg - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - forEachDead: function (callback, thisArg) - { - var dead = this.dead; - var length = dead.length; - - for (var index = 0; index < length; ++index) - { - // Sends the Particle and the Emitter - callback.call(thisArg, dead[index], this); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#start - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - start: function () - { - this.on = true; - - this._counter = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#pause - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - pause: function () - { - this.active = false; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#resume - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - resume: function () - { - this.active = true; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#depthSort - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - depthSort: function () - { - StableSort.inplace(this.alive, this.depthSortCallback); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#flow - * @since 3.0.0 - * - * @param {number} frequency - [description] - * @param {integer} [count=1] - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - flow: function (frequency, count) - { - if (count === undefined) { count = 1; } - - this.frequency = frequency; - - this.quantity.onChange(count); - - return this.start(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#explode - * @since 3.0.0 - * - * @param {integer} count - The amount of Particles to emit. - * @param {number} x - The x coordinate to emit the Particles from. - * @param {number} y - The y coordinate to emit the Particles from. - * - * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. - */ - explode: function (count, x, y) - { - this.frequency = -1; - - return this.emitParticle(count, x, y); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#emitParticleAt - * @since 3.0.0 - * - * @param {number} x - The x coordinate to emit the Particles from. - * @param {number} y - The y coordinate to emit the Particles from. - * @param {integer} count - The amount of Particles to emit. - * - * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. - */ - emitParticleAt: function (x, y, count) - { - return this.emitParticle(count, x, y); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#emitParticle - * @since 3.0.0 - * - * @param {integer} count - The amount of Particles to emit. - * @param {number} x - The x coordinate to emit the Particles from. - * @param {number} y - The y coordinate to emit the Particles from. - * - * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. - */ - emitParticle: function (count, x, y) - { - if (this.atLimit()) - { - return; - } - - if (count === undefined) - { - count = this.quantity.onEmit(); - } - - var dead = this.dead; - - for (var i = 0; i < count; i++) - { - var particle; - - if (dead.length > 0) - { - particle = dead.pop(); - } - else - { - particle = new this.particleClass(this); - } - - particle.fire(x, y); - - if (this.particleBringToTop) - { - this.alive.push(particle); - } - else - { - this.alive.unshift(particle); - } - - if (this.emitCallback) - { - this.emitCallback.call(this.emitCallbackScope, particle, this); - } - - if (this.atLimit()) - { - break; - } - } - - return particle; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#preUpdate - * @since 3.0.0 - * - * @param {[type]} time - [description] - * @param {[type]} delta - [description] - */ - preUpdate: function (time, delta) - { - // Scale the delta - delta *= this.timeScale; - - var step = (delta / 1000); - - if (this.trackVisible) - { - this.visible = this.follow.visible; - } - - // Any particle processors? - var processors = this.manager.getProcessors(); - - var particles = this.alive; - var length = particles.length; - - for (var index = 0; index < length; index++) - { - var particle = particles[index]; - - // update returns `true` if the particle is now dead (lifeStep < 0) - if (particle.update(delta, step, processors)) - { - // Moves the dead particle to the end of the particles array (ready for splicing out later) - var last = particles[length - 1]; - - particles[length - 1] = particle; - particles[index] = last; - - index -= 1; - length -= 1; - } - } - - // Move dead particles to the dead array - var deadLength = particles.length - length; - - if (deadLength > 0) - { - var rip = particles.splice(particles.length - deadLength, deadLength); - - var deathCallback = this.deathCallback; - var deathCallbackScope = this.deathCallbackScope; - - if (deathCallback) - { - for (var i = 0; i < rip.length; i++) - { - deathCallback.call(deathCallbackScope, rip[i]); - } - } - - this.dead.concat(rip); - - StableSort.inplace(particles, this.indexSortCallback); - } - - if (!this.on) - { - return; - } - - if (this.frequency === 0) - { - this.emitParticle(); - } - else if (this.frequency > 0) - { - this._counter -= delta; - - if (this._counter <= 0) - { - this.emitParticle(); - - // counter = frequency - remained from previous delta - this._counter = (this.frequency - Math.abs(this._counter)); - } - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#depthSortCallback - * @since 3.0.0 - * - * @param {object} a - [description] - * @param {object} b - [description] - * - * @return {integer} [description] - */ - depthSortCallback: function (a, b) - { - return a.y - b.y; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#indexSortCallback - * @since 3.0.0 - * - * @param {object} a - [description] - * @param {object} b - [description] - * - * @return {integer} [description] - */ - indexSortCallback: function (a, b) - { - return a.index - b.index; + out.x = (D * E - B * F) / G; + out.y = (A * F - C * E) / G; + dx = out.x - x1; + dy = out.y - y1; + out.radius = Math.sqrt(dx * dx + dy * dy); } -}); + return out; +}; -module.exports = ParticleEmitter; +module.exports = CircumCircle; /***/ }), @@ -94629,72 +91930,68 @@ module.exports = ParticleEmitter; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); +var Vector2 = __webpack_require__(6); + +// Adapted from http://bjornharrtell.github.io/jsts/doc/api/jsts_geom_Triangle.js.html /** - * @classdesc - * A Death Zone. - * - * A Death Zone is a special type of zone that will kill a Particle as soon as it either enters, or leaves, the zone. - * - * The zone consists of a `source` which could be a Geometric shape, such as a Rectangle or Ellipse, or your own - * object as long as it includes a `contains` method for which the Particles can be tested against. - * - * @class DeathZone - * @memberOf Phaser.GameObjects.Particles.Zones - * @constructor + * Computes the determinant of a 2x2 matrix. Uses standard double-precision arithmetic, so is susceptible to round-off error. + * + * @function det + * @private * @since 3.0.0 * - * @param {object} source - An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. - * @param {boolean} killOnEnter - Should the Particle be killed when it enters the zone? `true` or leaves it? `false` + * @param {number} m00 - The [0,0] entry of the matrix. + * @param {number} m01 - The [0,1] entry of the matrix. + * @param {number} m10 - The [1,0] entry of the matrix. + * @param {number} m11 - The [1,1] entry of the matrix. + * + * @return {number} the determinant. */ -var DeathZone = new Class({ +function det (m00, m01, m10, m11) +{ + return (m00 * m11) - (m01 * m10); +} - initialize: +/** + * Computes the circumcentre of a triangle. The circumcentre is the centre of + * the circumcircle, the smallest circle which encloses the triangle. It is also + * the common intersection point of the perpendicular bisectors of the sides of + * the triangle, and is the only point which has equal distance to all three + * vertices of the triangle. + * + * @function Phaser.Geom.Triangle.CircumCenter + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ +var CircumCenter = function (triangle, out) +{ + if (out === undefined) { out = new Vector2(); } - function DeathZone (source, killOnEnter) - { - /** - * An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. - * This could be a Geometry shape, such as `Phaser.Geom.Circle`, or your own custom object. - * - * @name Phaser.GameObjects.Particles.Zones.DeathZone#source - * @type {object} - * @since 3.0.0 - */ - this.source = source; + var cx = triangle.x3; + var cy = triangle.y3; - /** - * Set to `true` if the Particle should be killed if it enters this zone. - * Set to `false` to kill the Particle if it leaves this zone. - * - * @name Phaser.GameObjects.Particles.Zones.DeathZone#killOnEnter - * @type {boolean} - * @since 3.0.0 - */ - this.killOnEnter = killOnEnter; - }, + var ax = triangle.x1 - cx; + var ay = triangle.y1 - cy; - /** - * Checks if the given Particle will be killed or not by this zone. - * - * @method Phaser.GameObjects.Particles.Zones.DeathZone#willKill - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle to be checked against this zone. - * - * @return {boolean} Return `true` if the Particle is to be killed, otherwise return `false`. - */ - willKill: function (particle) - { - var withinZone = this.source.contains(particle.x, particle.y); + var bx = triangle.x2 - cx; + var by = triangle.y2 - cy; - return (withinZone && this.killOnEnter || !withinZone && !this.killOnEnter); - } + var denom = 2 * det(ax, ay, bx, by); + var numx = det(ay, ax * ax + ay * ay, by, bx * bx + by * by); + var numy = det(ax, ax * ax + ay * ay, bx, bx * bx + by * by); -}); + out.x = cx - numx / denom; + out.y = cy + numy / denom; -module.exports = DeathZone; + return out; +}; + +module.exports = CircumCenter; /***/ }), @@ -94707,233 +92004,45 @@ module.exports = DeathZone; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); +var Centroid = __webpack_require__(230); +var Offset = __webpack_require__(229); + +/** + * @callback CenterFunction + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ /** - * @classdesc * [description] * - * @class EdgeZone - * @memberOf Phaser.GameObjects.Particles.Zones - * @constructor + * @function Phaser.Geom.Triangle.CenterOn * @since 3.0.0 * - * @param {object} source - [description] - * @param {number} quantity - [description] - * @param {number} stepRate - [description] - * @param {boolean} yoyo - [description] - * @param {boolean} seamless - [description] + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {CenterFunction} [centerFunc] - [description] + * + * @return {Phaser.Geom.Triangle} [description] */ -var EdgeZone = new Class({ +var CenterOn = function (triangle, x, y, centerFunc) +{ + if (centerFunc === undefined) { centerFunc = Centroid; } - initialize: + // Get the center of the triangle + var center = centerFunc(triangle); - function EdgeZone (source, quantity, stepRate, yoyo, seamless) - { - if (yoyo === undefined) { yoyo = false; } - if (seamless === undefined) { seamless = true; } + // Difference + var diffX = x - center.x; + var diffY = y - center.y; - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#source - * @type {object} - * @since 3.0.0 - */ - this.source = source; + return Offset(triangle, diffX, diffY); +}; - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#points - * @type {Phaser.Geom.Point[]} - * @default [] - * @since 3.0.0 - */ - this.points = []; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#quantity - * @type {number} - * @since 3.0.0 - */ - this.quantity = quantity; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#stepRate - * @type {number} - * @since 3.0.0 - */ - this.stepRate = stepRate; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#yoyo - * @type {boolean} - * @since 3.0.0 - */ - this.yoyo = yoyo; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#counter - * @type {number} - * @default -1 - * @since 3.0.0 - */ - this.counter = -1; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#seamless - * @type {boolean} - * @since 3.0.0 - */ - this.seamless = seamless; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#_length - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._length = 0; - - /** - * 0 = forwards, 1 = backwards - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#_direction - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._direction = 0; - - this.updateSource(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.Zones.EdgeZone#updateSource - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.Zones.EdgeZone} This Edge Zone. - */ - updateSource: function () - { - this.points = this.source.getPoints(this.quantity, this.stepRate); - - // Remove ends? - if (this.seamless) - { - var a = this.points[0]; - var b = this.points[this.points.length - 1]; - - if (a.x === b.x && a.y === b.y) - { - this.points.pop(); - } - } - - var oldLength = this._length; - - this._length = this.points.length; - - // Adjust counter if we now have less points than before - if (this._length < oldLength && this.counter > this._length) - { - this.counter = this._length - 1; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.Zones.EdgeZone#changeSource - * @since 3.0.0 - * - * @param {object} source - [description] - * - * @return {Phaser.GameObjects.Particles.Zones.EdgeZone} This Edge Zone. - */ - changeSource: function (source) - { - this.source = source; - - return this.updateSource(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.Zones.EdgeZone#getPoint - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - */ - getPoint: function (particle) - { - if (this._direction === 0) - { - this.counter++; - - if (this.counter >= this._length) - { - if (this.yoyo) - { - this._direction = 1; - this.counter = this._length - 1; - } - else - { - this.counter = 0; - } - } - } - else - { - this.counter--; - - if (this.counter === -1) - { - if (this.yoyo) - { - this._direction = 0; - this.counter = 0; - } - else - { - this.counter = this._length - 1; - } - } - } - - var point = this.points[this.counter]; - - if (point) - { - particle.x = point.x; - particle.y = point.y; - } - } - -}); - -module.exports = EdgeZone; +module.exports = CenterOn; /***/ }), @@ -94946,553 +92055,43 @@ module.exports = EdgeZone; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var FloatBetween = __webpack_require__(276); -var GetEaseFunction = __webpack_require__(71); -var GetFastValue = __webpack_require__(2); -var Wrap = __webpack_require__(50); +var Triangle = __webpack_require__(52); + +// Builds a right triangle, with one 90 degree angle and two acute angles +// The x/y is the coordinate of the 90 degree angle (and will map to x1/y1 in the resulting Triangle) +// w/h can be positive or negative and represent the length of each side /** - * @classdesc * [description] * - * @class EmitterOp - * @memberOf Phaser.GameObjects.Particles - * @constructor + * @function Phaser.Geom.Triangle.BuildRight * @since 3.0.0 * - * @param {object} config - [description] - * @param {string} key - [description] - * @param {number} defaultValue - [description] - * @param {boolean} [emitOnly=false] - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.Geom.Triangle} [description] */ -var EmitterOp = new Class({ +var BuildRight = function (x, y, width, height) +{ + if (height === undefined) { height = width; } - initialize: + // 90 degree angle + var x1 = x; + var y1 = y; - function EmitterOp (config, key, defaultValue, emitOnly) - { - if (emitOnly === undefined) { emitOnly = false; } + var x2 = x; + var y2 = y - height; - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#propertyKey - * @type {string} - * @since 3.0.0 - */ - this.propertyKey = key; + var x3 = x + width; + var y3 = y; - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#propertyValue - * @type {number} - * @since 3.0.0 - */ - this.propertyValue = defaultValue; + return new Triangle(x1, y1, x2, y2, x3, y3); +}; - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#defaultValue - * @type {number} - * @since 3.0.0 - */ - this.defaultValue = defaultValue; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#steps - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.steps = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#counter - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.counter = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#start - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.start = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#end - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.end = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#ease - * @type {?function} - * @since 3.0.0 - */ - this.ease; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#emitOnly - * @type {boolean} - * @since 3.0.0 - */ - this.emitOnly = emitOnly; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#onEmit - * @type {[type]} - * @since 3.0.0 - */ - this.onEmit = this.defaultEmit; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#onUpdate - * @type {[type]} - * @since 3.0.0 - */ - this.onUpdate = this.defaultUpdate; - - this.loadConfig(config); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#loadConfig - * @since 3.0.0 - * - * @param {object} config - [description] - * @param {string} newKey - [description] - */ - loadConfig: function (config, newKey) - { - if (config === undefined) { config = {}; } - - if (newKey) - { - this.propertyKey = newKey; - } - - this.propertyValue = GetFastValue(config, this.propertyKey, this.defaultValue); - - this.setMethods(); - - if (this.emitOnly) - { - // Reset it back again - this.onUpdate = this.defaultUpdate; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - return JSON.stringify(this.propertyValue); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#onChange - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {Phaser.GameObjects.Particles.EmitterOp} This Emitter Op object. - */ - onChange: function (value) - { - this.propertyValue = value; - - return this.setMethods(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#setMethods - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.EmitterOp} This Emitter Op object. - */ - setMethods: function () - { - var value = this.propertyValue; - - var t = typeof(value); - - if (t === 'number') - { - // Explicit static value: - // x: 400 - - this.onEmit = this.staticValueEmit; - this.onUpdate = this.staticValueUpdate; - } - else if (Array.isArray(value)) - { - // Picks a random element from the array: - // x: [ 100, 200, 300, 400 ] - - this.onEmit = this.randomStaticValueEmit; - } - else if (t === 'function') - { - // The same as setting just the onUpdate function and no onEmit (unless this op is an emitOnly one) - // Custom callback, must return a value: - - /* - x: function (particle, key, t, value) - { - return value + 50; - } - */ - - if (this.emitOnly) - { - this.onEmit = value; - } - else - { - this.onUpdate = value; - } - } - else if (t === 'object' && (this.has(value, 'random') || this.hasBoth(value, 'start', 'end') || this.hasBoth(value, 'min', 'max'))) - { - this.start = (this.has(value, 'start')) ? value.start : value.min; - this.end = (this.has(value, 'end')) ? value.end : value.max; - - var isRandom = (this.hasBoth(value, 'min', 'max') || this.has(value, 'random')); - - // A random starting value (using 'min | max' instead of 'start | end' automatically implies a random value) - - // x: { start: 100, end: 400, random: true } OR { min: 100, max: 400 } OR { random: [ 100, 400 ] } - - if (isRandom) - { - var rnd = value.random; - - // x: { random: [ 100, 400 ] } = the same as doing: x: { start: 100, end: 400, random: true } - if (Array.isArray(rnd)) - { - this.start = rnd[0]; - this.end = rnd[1]; - } - - this.onEmit = this.randomRangedValueEmit; - } - - if (this.has(value, 'steps')) - { - // A stepped (per emit) range - - // x: { start: 100, end: 400, steps: 64 } - - // Increments a value stored in the emitter - - this.steps = value.steps; - this.counter = this.start; - - this.onEmit = this.steppedEmit; - } - else - { - // An eased range (defaults to Linear if not specified) - - // x: { start: 100, end: 400, [ ease: 'Linear' ] } - - var easeType = (this.has(value, 'ease')) ? value.ease : 'Linear'; - - this.ease = GetEaseFunction(easeType); - - if (!isRandom) - { - this.onEmit = this.easedValueEmit; - } - - this.onUpdate = this.easeValueUpdate; - } - } - else if (t === 'object' && this.hasEither(value, 'onEmit', 'onUpdate')) - { - // Custom onEmit and onUpdate callbacks - - /* - x: { - // Called at the start of the particles life, when it is being created - onEmit: function (particle, key, t, value) - { - return value; - }, - - // Called during the particles life on each update - onUpdate: function (particle, key, t, value) - { - return value; - } - } - */ - - if (this.has(value, 'onEmit')) - { - this.onEmit = value.onEmit; - } - - if (this.has(value, 'onUpdate')) - { - this.onUpdate = value.onUpdate; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#has - * @since 3.0.0 - * - * @param {object} object - [description] - * @param {string} key - [description] - * - * @return {boolean} [description] - */ - has: function (object, key) - { - return (object.hasOwnProperty(key)); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#hasBoth - * @since 3.0.0 - * - * @param {object} object - [description] - * @param {string} key1 - [description] - * @param {string} key2 - [description] - * - * @return {boolean} [description] - */ - hasBoth: function (object, key1, key2) - { - return (object.hasOwnProperty(key1) && object.hasOwnProperty(key2)); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#hasEither - * @since 3.0.0 - * - * @param {object} object - [description] - * @param {string} key1 - [description] - * @param {string} key2 - [description] - * - * @return {boolean} [description] - */ - hasEither: function (object, key1, key2) - { - return (object.hasOwnProperty(key1) || object.hasOwnProperty(key2)); - }, - - /** - * The returned value sets what the property will be at the START of the particles life, on emit. - * - * @method Phaser.GameObjects.Particles.EmitterOp#defaultEmit - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - * @param {string} key - [description] - * @param {number} value - [description] - * - * @return {number} [description] - */ - defaultEmit: function (particle, key, value) - { - return value; - }, - - /** - * The returned value updates the property for the duration of the particles life. - * - * @method Phaser.GameObjects.Particles.EmitterOp#defaultUpdate - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - * @param {string} key - [description] - * @param {float} t - The T value (between 0 and 1) - * @param {number} value - [description] - * - * @return {number} [description] - */ - defaultUpdate: function (particle, key, t, value) - { - return value; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#staticValueEmit - * @since 3.0.0 - * - * @return {number} [description] - */ - staticValueEmit: function () - { - return this.propertyValue; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#staticValueUpdate - * @since 3.0.0 - * - * @return {number} [description] - */ - staticValueUpdate: function () - { - return this.propertyValue; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#randomStaticValueEmit - * @since 3.0.0 - * - * @return {number} [description] - */ - randomStaticValueEmit: function () - { - var randomIndex = Math.floor(Math.random() * this.propertyValue.length); - - return this.propertyValue[randomIndex]; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#randomRangedValueEmit - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - * @param {string} key - [description] - * - * @return {number} [description] - */ - randomRangedValueEmit: function (particle, key) - { - var value = FloatBetween(this.start, this.end); - - if (particle && particle.data[key]) - { - particle.data[key].min = value; - } - - return value; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#steppedEmit - * @since 3.0.0 - * - * @return {number} [description] - */ - steppedEmit: function () - { - var current = this.counter; - - var next = this.counter + ((this.end - this.start) / this.steps); - - this.counter = Wrap(next, this.start, this.end); - - return current; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#easedValueEmit - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - * @param {string} key - [description] - * - * @return {number} [description] - */ - easedValueEmit: function (particle, key) - { - if (particle && particle.data[key]) - { - var data = particle.data[key]; - - data.min = this.start; - data.max = this.end; - } - - return this.start; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#easeValueUpdate - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - * @param {string} key - [description] - * @param {float} t - The T value (between 0 and 1) - * - * @return {number} [description] - */ - easeValueUpdate: function (particle, key, t) - { - var data = particle.data[key]; - - return (data.max - data.min) * this.ease(t) + data.min; - } - -}); - -module.exports = EmitterOp; +module.exports = BuildRight; /***/ }), @@ -95505,80 +92104,72 @@ module.exports = EmitterOp; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Back = __webpack_require__(277); -var Bounce = __webpack_require__(278); -var Circular = __webpack_require__(279); -var Cubic = __webpack_require__(280); -var Elastic = __webpack_require__(281); -var Expo = __webpack_require__(282); -var Linear = __webpack_require__(283); -var Quadratic = __webpack_require__(284); -var Quartic = __webpack_require__(285); -var Quintic = __webpack_require__(286); -var Sine = __webpack_require__(287); -var Stepped = __webpack_require__(288); +var EarCut = __webpack_require__(301); +var Triangle = __webpack_require__(52); -// EaseMap -module.exports = { +/** + * [description] + * + * @function Phaser.Geom.Triangle.BuildFromPolygon + * @since 3.0.0 + * + * @param {array} data - A flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...] + * @param {array} [?holes] - An array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). + * @param {float} [scaleX=1] - [description] + * @param {float} [scaleY=1] - [description] + * @param {array} [out] - [description] + * + * @return {Phaser.Geom.Triangle[]} [description] + */ +var BuildFromPolygon = function (data, holes, scaleX, scaleY, out) +{ + if (holes === undefined) { holes = null; } + if (scaleX === undefined) { scaleX = 1; } + if (scaleY === undefined) { scaleY = 1; } + if (out === undefined) { out = []; } - Power0: Linear, - Power1: Quadratic.Out, - Power2: Cubic.Out, - Power3: Quartic.Out, - Power4: Quintic.Out, + var tris = EarCut(data, holes); - Linear: Linear, - Quad: Quadratic.Out, - Cubic: Cubic.Out, - Quart: Quartic.Out, - Quint: Quintic.Out, - Sine: Sine.Out, - Expo: Expo.Out, - Circ: Circular.Out, - Elastic: Elastic.Out, - Back: Back.Out, - Bounce: Bounce.Out, - Stepped: Stepped, + var a; + var b; + var c; - 'Quad.easeIn': Quadratic.In, - 'Cubic.easeIn': Cubic.In, - 'Quart.easeIn': Quartic.In, - 'Quint.easeIn': Quintic.In, - 'Sine.easeIn': Sine.In, - 'Expo.easeIn': Expo.In, - 'Circ.easeIn': Circular.In, - 'Elastic.easeIn': Elastic.In, - 'Back.easeIn': Back.In, - 'Bounce.easeIn': Bounce.In, + var x1; + var y1; - 'Quad.easeOut': Quadratic.Out, - 'Cubic.easeOut': Cubic.Out, - 'Quart.easeOut': Quartic.Out, - 'Quint.easeOut': Quintic.Out, - 'Sine.easeOut': Sine.Out, - 'Expo.easeOut': Expo.Out, - 'Circ.easeOut': Circular.Out, - 'Elastic.easeOut': Elastic.Out, - 'Back.easeOut': Back.Out, - 'Bounce.easeOut': Bounce.Out, + var x2; + var y2; - 'Quad.easeInOut': Quadratic.InOut, - 'Cubic.easeInOut': Cubic.InOut, - 'Quart.easeInOut': Quartic.InOut, - 'Quint.easeInOut': Quintic.InOut, - 'Sine.easeInOut': Sine.InOut, - 'Expo.easeInOut': Expo.InOut, - 'Circ.easeInOut': Circular.InOut, - 'Elastic.easeInOut': Elastic.InOut, - 'Back.easeInOut': Back.InOut, - 'Bounce.easeInOut': Bounce.InOut + var x3; + var y3; + for (var i = 0; i < tris.length; i += 3) + { + a = tris[i]; + b = tris[i + 1]; + c = tris[i + 2]; + + x1 = data[a * 2] * scaleX; + y1 = data[(a * 2) + 1] * scaleY; + + x2 = data[b * 2] * scaleX; + y2 = data[(b * 2) + 1] * scaleY; + + x3 = data[c * 2] * scaleX; + y3 = data[(c * 2) + 1] * scaleY; + + out.push(new Triangle(x1, y1, x2, y2, x3, y3)); + } + + return out; }; +module.exports = BuildFromPolygon; + /***/ }), /* 579 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -95586,25 +92177,44 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Triangle = __webpack_require__(52); + +// Builds an equilateral triangle. +// In the equilateral triangle, all the sides are the same length (congruent) +// and all the angles are the same size (congruent). + +// The x/y specifies the top-middle of the triangle (x1/y1) and length +// is the length of each side + /** * [description] * - * @function Phaser.Math.Easing.Back.In + * @function Phaser.Geom.Triangle.BuildEquilateral * @since 3.0.0 * - * @param {number} v - [description] - * @param {number} [overshoot=1.70158] - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} length - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Triangle} [description] */ -var In = function (v, overshoot) +var BuildEquilateral = function (x, y, length) { - if (overshoot === undefined) { overshoot = 1.70158; } + var height = length * (Math.sqrt(3) / 2); - return v * v * ((overshoot + 1) * v - overshoot); + var x1 = x; + var y1 = y; + + var x2 = x + (length / 2); + var y2 = y + height; + + var x3 = x - (length / 2); + var y3 = y + height; + + return new Triangle(x1, y1, x2, y2, x3, y3); }; -module.exports = In; +module.exports = BuildEquilateral; /***/ }), @@ -95617,30 +92227,38 @@ module.exports = In; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +// The 2D area of a triangle. The area value is always non-negative. + /** * [description] * - * @function Phaser.Math.Easing.Back.Out + * @function Phaser.Geom.Triangle.Area * @since 3.0.0 * - * @param {number} v - [description] - * @param {number} [overshoot=1.70158] - [description] + * @param {Phaser.Geom.Triangle} triangle - [description] * * @return {number} [description] */ -var Out = function (v, overshoot) +var Area = function (triangle) { - if (overshoot === undefined) { overshoot = 1.70158; } + var x1 = triangle.x1; + var y1 = triangle.y1; - return --v * v * ((overshoot + 1) * v + overshoot) + 1; + var x2 = triangle.x2; + var y2 = triangle.y2; + + var x3 = triangle.x3; + var y3 = triangle.y3; + + return Math.abs(((x3 - x1) * (y2 - y1) - (x2 - x1) * (y3 - y1)) / 2); }; -module.exports = Out; +module.exports = Area; /***/ }), /* 581 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -95648,39 +92266,39 @@ module.exports = Out; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * [description] - * - * @function Phaser.Math.Easing.Back.InOut - * @since 3.0.0 - * - * @param {number} v - [description] - * @param {number} [overshoot=1.70158] - [description] - * - * @return {number} [description] - */ -var InOut = function (v, overshoot) -{ - if (overshoot === undefined) { overshoot = 1.70158; } +var Triangle = __webpack_require__(52); - var s = overshoot * 1.525; +Triangle.Area = __webpack_require__(580); +Triangle.BuildEquilateral = __webpack_require__(579); +Triangle.BuildFromPolygon = __webpack_require__(578); +Triangle.BuildRight = __webpack_require__(577); +Triangle.CenterOn = __webpack_require__(576); +Triangle.Centroid = __webpack_require__(230); +Triangle.CircumCenter = __webpack_require__(575); +Triangle.CircumCircle = __webpack_require__(574); +Triangle.Clone = __webpack_require__(573); +Triangle.Contains = __webpack_require__(54); +Triangle.ContainsArray = __webpack_require__(127); +Triangle.ContainsPoint = __webpack_require__(572); +Triangle.CopyFrom = __webpack_require__(571); +Triangle.Decompose = __webpack_require__(239); +Triangle.Equals = __webpack_require__(570); +Triangle.GetPoint = __webpack_require__(232); +Triangle.GetPoints = __webpack_require__(231); +Triangle.InCenter = __webpack_require__(228); +Triangle.Perimeter = __webpack_require__(569); +Triangle.Offset = __webpack_require__(229); +Triangle.Random = __webpack_require__(161); +Triangle.Rotate = __webpack_require__(568); +Triangle.RotateAroundPoint = __webpack_require__(567); +Triangle.RotateAroundXY = __webpack_require__(123); - if ((v *= 2) < 1) - { - return 0.5 * (v * v * ((s + 1) * v - s)); - } - else - { - return 0.5 * ((v -= 2) * v * ((s + 1) * v + s) + 2); - } -}; - -module.exports = InOut; +module.exports = Triangle; /***/ }), /* 582 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -95688,39 +92306,36 @@ module.exports = InOut; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Rectangle = __webpack_require__(10); + /** * [description] * - * @function Phaser.Math.Easing.Bounce.In + * @function Phaser.Geom.Rectangle.Union * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rectA - [description] + * @param {Phaser.Geom.Rectangle} rectB - [description] + * @param {Phaser.Geom.Rectangle} [out] - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var In = function (v) +var Union = function (rectA, rectB, out) { - v = 1 - v; + if (out === undefined) { out = new Rectangle(); } - if (v < 1 / 2.75) - { - return 1 - (7.5625 * v * v); - } - else if (v < 2 / 2.75) - { - return 1 - (7.5625 * (v -= 1.5 / 2.75) * v + 0.75); - } - else if (v < 2.5 / 2.75) - { - return 1 - (7.5625 * (v -= 2.25 / 2.75) * v + 0.9375); - } - else - { - return 1 - (7.5625 * (v -= 2.625 / 2.75) * v + 0.984375); - } + var x = Math.min(rectA.x, rectB.x); + var y = Math.min(rectA.y, rectB.y); + + return out.setTo( + x, + y, + Math.max(rectA.right, rectB.right) - x, + Math.max(rectA.bottom, rectB.bottom) - y + ); }; -module.exports = In; +module.exports = Union; /***/ }), @@ -95733,42 +92348,36 @@ module.exports = In; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +// Scales the width and height of this Rectangle by the given amounts. + /** * [description] * - * @function Phaser.Math.Easing.Bounce.Out + * @function Phaser.Geom.Rectangle.Scale * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} x - [description] + * @param {number} y - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var Out = function (v) +var Scale = function (rect, x, y) { - if (v < 1 / 2.75) - { - return 7.5625 * v * v; - } - else if (v < 2 / 2.75) - { - return 7.5625 * (v -= 1.5 / 2.75) * v + 0.75; - } - else if (v < 2.5 / 2.75) - { - return 7.5625 * (v -= 2.25 / 2.75) * v + 0.9375; - } - else - { - return 7.5625 * (v -= 2.625 / 2.75) * v + 0.984375; - } + if (y === undefined) { y = x; } + + rect.width *= x; + rect.height *= y; + + return rect; }; -module.exports = Out; +module.exports = Scale; /***/ }), /* 584 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -95776,58 +92385,49 @@ module.exports = Out; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Point = __webpack_require__(4); +var DegToRad = __webpack_require__(42); + /** * [description] * - * @function Phaser.Math.Easing.Bounce.InOut + * @function Phaser.Geom.Rectangle.PerimeterPoint * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rectangle - [description] + * @param {integer} angle - [description] + * @param {Phaser.Geom.Point} [out] - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Point} [description] */ -var InOut = function (v) +var PerimeterPoint = function (rectangle, angle, out) { - var reverse = false; + if (out === undefined) { out = new Point(); } - if (v < 0.5) + angle = DegToRad(angle); + + var s = Math.sin(angle); + var c = Math.cos(angle); + + var dx = (c > 0) ? rectangle.width / 2 : rectangle.width / -2; + var dy = (s > 0) ? rectangle.height / 2 : rectangle.height / -2; + + if (Math.abs(dx * s) < Math.abs(dy * c)) { - v = 1 - (v * 2); - reverse = true; + dy = (dx * s) / c; } else { - v = (v * 2) - 1; + dx = (dy * c) / s; } - if (v < 1 / 2.75) - { - v = 7.5625 * v * v; - } - else if (v < 2 / 2.75) - { - v = 7.5625 * (v -= 1.5 / 2.75) * v + 0.75; - } - else if (v < 2.5 / 2.75) - { - v = 7.5625 * (v -= 2.25 / 2.75) * v + 0.9375; - } - else - { - v = 7.5625 * (v -= 2.625 / 2.75) * v + 0.984375; - } + out.x = dx + rectangle.centerX; + out.y = dy + rectangle.centerY; - if (reverse) - { - return (1 - v) * 0.5; - } - else - { - return v * 0.5 + 0.5; - } + return out; }; -module.exports = InOut; +module.exports = PerimeterPoint; /***/ }), @@ -95843,19 +92443,25 @@ module.exports = InOut; /** * [description] * - * @function Phaser.Math.Easing.Circular.In + * @function Phaser.Geom.Rectangle.Overlaps * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rectA - [description] + * @param {Phaser.Geom.Rectangle} rectB - [description] * - * @return {number} [description] + * @return {boolean} [description] */ -var In = function (v) +var Overlaps = function (rectA, rectB) { - return 1 - Math.sqrt(1 - v * v); + return ( + rectA.x < rectB.right && + rectA.right > rectB.x && + rectA.y < rectB.bottom && + rectA.bottom > rectB.y + ); }; -module.exports = In; +module.exports = Overlaps; /***/ }), @@ -95871,19 +92477,23 @@ module.exports = In; /** * [description] * - * @function Phaser.Math.Easing.Circular.Out + * @function Phaser.Geom.Rectangle.OffsetPoint * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Point} point - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var Out = function (v) +var OffsetPoint = function (rect, point) { - return Math.sqrt(1 - (--v * v)); + rect.x += point.x; + rect.y += point.y; + + return rect; }; -module.exports = Out; +module.exports = OffsetPoint; /***/ }), @@ -95899,26 +92509,24 @@ module.exports = Out; /** * [description] * - * @function Phaser.Math.Easing.Circular.InOut + * @function Phaser.Geom.Rectangle.Offset * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} x - [description] + * @param {number} y - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var InOut = function (v) +var Offset = function (rect, x, y) { - if ((v *= 2) < 1) - { - return -0.5 * (Math.sqrt(1 - v * v) - 1); - } - else - { - return 0.5 * (Math.sqrt(1 - (v -= 2) * v) + 1); - } + rect.x += x; + rect.y += y; + + return rect; }; -module.exports = InOut; +module.exports = Offset; /***/ }), @@ -95934,19 +92542,33 @@ module.exports = InOut; /** * [description] * - * @function Phaser.Math.Easing.Cubic.In + * @function Phaser.Geom.Rectangle.MergeXY * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} target - [description] + * @param {number} x - [description] + * @param {number} y - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var In = function (v) +var MergeXY = function (target, x, y) { - return v * v * v; + var minX = Math.min(target.x, x); + var maxX = Math.max(target.right, x); + + target.x = minX; + target.width = maxX - minX; + + var minY = Math.min(target.y, y); + var maxY = Math.max(target.bottom, y); + + target.y = minY; + target.height = maxY - minY; + + return target; }; -module.exports = In; +module.exports = MergeXY; /***/ }), @@ -95959,22 +92581,38 @@ module.exports = In; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +// Merges source rectangle into target rectangle and returns target +// Neither rect should have negative widths or heights + /** * [description] * - * @function Phaser.Math.Easing.Cubic.Out + * @function Phaser.Geom.Rectangle.MergeRect * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} target - [description] + * @param {Phaser.Geom.Rectangle} source - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var Out = function (v) +var MergeRect = function (target, source) { - return --v * v * v + 1; + var minX = Math.min(target.x, source.x); + var maxX = Math.max(target.right, source.right); + + target.x = minX; + target.width = maxX - minX; + + var minY = Math.min(target.y, source.y); + var maxY = Math.max(target.bottom, source.bottom); + + target.y = minY; + target.height = maxY - minY; + + return target; }; -module.exports = Out; +module.exports = MergeRect; /***/ }), @@ -95987,34 +92625,49 @@ module.exports = Out; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +// Merges the target Rectangle with a list of points. +// The points is an array of objects with public x/y properties. + /** * [description] * - * @function Phaser.Math.Easing.Cubic.InOut + * @function Phaser.Geom.Rectangle.MergePoints * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} target - [description] + * @param {Phaser.Geom.Point[]} points - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var InOut = function (v) +var MergePoints = function (target, points) { - if ((v *= 2) < 1) + var minX = target.x; + var maxX = target.right; + var minY = target.y; + var maxY = target.bottom; + + for (var i = 0; i < points.length; i++) { - return 0.5 * v * v * v; - } - else - { - return 0.5 * ((v -= 2) * v * v + 2); + minX = Math.min(minX, points[i].x); + maxX = Math.max(maxX, points[i].x); + minY = Math.min(minY, points[i].y); + maxY = Math.max(maxY, points[i].y); } + + target.x = minX; + target.y = minY; + target.width = maxX - minX; + target.height = maxY - minY; + + return target; }; -module.exports = InOut; +module.exports = MergePoints; /***/ }), /* 591 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -96022,54 +92675,40 @@ module.exports = InOut; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var CenterOn = __webpack_require__(233); + +// Increases the size of the Rectangle object by the specified amounts. +// The center point of the Rectangle object stays the same, and its size increases +// to the left and right by the x value, and to the top and the bottom by the y value. + /** * [description] * - * @function Phaser.Math.Easing.Elastic.In + * @function Phaser.Geom.Rectangle.Inflate * @since 3.0.0 * - * @param {number} v - [description] - * @param {float} [amplitude=0.1] - [description] - * @param {float} [period=0.1] - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} x - [description] + * @param {number} y - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var In = function (v, amplitude, period) +var Inflate = function (rect, x, y) { - if (amplitude === undefined) { amplitude = 0.1; } - if (period === undefined) { period = 0.1; } + var cx = rect.centerX; + var cy = rect.centerY; - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - var s = period / 4; + rect.setSize(rect.width + (x * 2), rect.height + (y * 2)); - if (amplitude < 1) - { - amplitude = 1; - } - else - { - s = period * Math.asin(1 / amplitude) / (2 * Math.PI); - } - - return -(amplitude * Math.pow(2, 10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period)); - } + return CenterOn(rect, cx, cy); }; -module.exports = In; +module.exports = Inflate; /***/ }), /* 592 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -96077,54 +92716,38 @@ module.exports = In; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Point = __webpack_require__(4); + +// The size of the Rectangle object, expressed as a Point object +// with the values of the width and height properties. + /** * [description] * - * @function Phaser.Math.Easing.Elastic.Out + * @function Phaser.Geom.Rectangle.GetSize * @since 3.0.0 * - * @param {number} v - [description] - * @param {float} [amplitude=0.1] - [description] - * @param {float} [period=0.1] - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] * - * @return {number} [description] + * @return {(Phaser.Geom.Point|object)} [description] */ -var Out = function (v, amplitude, period) +var GetSize = function (rect, out) { - if (amplitude === undefined) { amplitude = 0.1; } - if (period === undefined) { period = 0.1; } + if (out === undefined) { out = new Point(); } - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - var s = period / 4; + out.x = rect.width; + out.y = rect.height; - if (amplitude < 1) - { - amplitude = 1; - } - else - { - s = period * Math.asin(1 / amplitude) / (2 * Math.PI); - } - - return (amplitude * Math.pow(2, -10 * v) * Math.sin((v - s) * (2 * Math.PI) / period) + 1); - } + return out; }; -module.exports = Out; +module.exports = GetSize; /***/ }), /* 593 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -96132,56 +92755,32 @@ module.exports = Out; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Point = __webpack_require__(4); + +// The center of the Rectangle object, expressed as a Point object + /** * [description] * - * @function Phaser.Math.Easing.Elastic.InOut + * @function Phaser.Geom.Rectangle.GetCenter * @since 3.0.0 * - * @param {number} v - [description] - * @param {float} [amplitude=0.1] - [description] - * @param {float} [period=0.1] - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] * - * @return {number} [description] + * @return {(Phaser.Geom.Point|object)} [description] */ -var InOut = function (v, amplitude, period) +var GetCenter = function (rect, out) { - if (amplitude === undefined) { amplitude = 0.1; } - if (period === undefined) { period = 0.1; } + if (out === undefined) { out = new Point(); } - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - var s = period / 4; + out.x = rect.centerX; + out.y = rect.centerY; - if (amplitude < 1) - { - amplitude = 1; - } - else - { - s = period * Math.asin(1 / amplitude) / (2 * Math.PI); - } - - if ((v *= 2) < 1) - { - return -0.5 * (amplitude * Math.pow(2, 10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period)); - } - else - { - return amplitude * Math.pow(2, -10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period) * 0.5 + 1; - } - } + return out; }; -module.exports = InOut; +module.exports = GetCenter; /***/ }), @@ -96197,19 +92796,24 @@ module.exports = InOut; /** * [description] * - * @function Phaser.Math.Easing.Expo.In + * @function Phaser.Geom.Rectangle.FloorAll * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var In = function (v) +var FloorAll = function (rect) { - return Math.pow(2, 10 * (v - 1)) - 0.001; + rect.x = Math.floor(rect.x); + rect.y = Math.floor(rect.y); + rect.width = Math.floor(rect.width); + rect.height = Math.floor(rect.height); + + return rect; }; -module.exports = In; +module.exports = FloorAll; /***/ }), @@ -96225,24 +92829,27 @@ module.exports = In; /** * [description] * - * @function Phaser.Math.Easing.Expo.Out + * @function Phaser.Geom.Rectangle.Floor * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var Out = function (v) +var Floor = function (rect) { - return 1 - Math.pow(2, -10 * v); + rect.x = Math.floor(rect.x); + rect.y = Math.floor(rect.y); + + return rect; }; -module.exports = Out; +module.exports = Floor; /***/ }), /* 596 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -96250,34 +92857,50 @@ module.exports = Out; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var GetAspectRatio = __webpack_require__(124); + +// Fits the target rectangle around the source rectangle. +// Preserves aspect ration. +// Scales and centers the target rectangle to the source rectangle + /** * [description] * - * @function Phaser.Math.Easing.Expo.InOut + * @function Phaser.Geom.Rectangle.FitOutside * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} target - [description] + * @param {Phaser.Geom.Rectangle} source - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var InOut = function (v) +var FitOutside = function (target, source) { - if ((v *= 2) < 1) + var ratio = GetAspectRatio(target); + + if (ratio > GetAspectRatio(source)) { - return 0.5 * Math.pow(2, 10 * (v - 1)); + // Wider than Tall + target.setSize(source.height * ratio, source.height); } else { - return 0.5 * (2 - Math.pow(2, -10 * (v - 1))); + // Taller than Wide + target.setSize(source.width, source.width / ratio); } + + return target.setPosition( + source.centerX - target.width / 2, + source.centerY - target.height / 2 + ); }; -module.exports = InOut; +module.exports = FitOutside; /***/ }), /* 597 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -96285,22 +92908,45 @@ module.exports = InOut; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var GetAspectRatio = __webpack_require__(124); + +// Fits the target rectangle into the source rectangle. +// Preserves aspect ratio. +// Scales and centers the target rectangle to the source rectangle + /** * [description] * - * @function Phaser.Math.Easing.Linear + * @function Phaser.Geom.Rectangle.FitInside * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} target - [description] + * @param {Phaser.Geom.Rectangle} source - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var Linear = function (v) +var FitInside = function (target, source) { - return v; + var ratio = GetAspectRatio(target); + + if (ratio < GetAspectRatio(source)) + { + // Taller than Wide + target.setSize(source.height * ratio, source.height); + } + else + { + // Wider than Tall + target.setSize(source.width, source.width / ratio); + } + + return target.setPosition( + source.centerX - (target.width / 2), + source.centerY - (target.height / 2) + ); }; -module.exports = Linear; +module.exports = FitInside; /***/ }), @@ -96316,19 +92962,25 @@ module.exports = Linear; /** * [description] * - * @function Phaser.Math.Easing.Quadratic.In + * @function Phaser.Geom.Rectangle.Equals * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Rectangle} toCompare - [description] * - * @return {number} [description] + * @return {boolean} [description] */ -var In = function (v) +var Equals = function (rect, toCompare) { - return v * v; + return ( + rect.x === toCompare.x && + rect.y === toCompare.y && + rect.width === toCompare.width && + rect.height === toCompare.height + ); }; -module.exports = In; +module.exports = Equals; /***/ }), @@ -96344,19 +92996,20 @@ module.exports = In; /** * [description] * - * @function Phaser.Math.Easing.Quadratic.Out + * @function Phaser.Geom.Rectangle.CopyFrom * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} source - [description] + * @param {Phaser.Geom.Rectangle} dest - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var Out = function (v) +var CopyFrom = function (source, dest) { - return v * (2 - v); + return dest.setTo(source.x, source.y, source.width, source.height); }; -module.exports = Out; +module.exports = CopyFrom; /***/ }), @@ -96369,34 +93022,41 @@ module.exports = Out; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +// Checks if rectB is fully contained within rectA + /** * [description] * - * @function Phaser.Math.Easing.Quadratic.InOut + * @function Phaser.Geom.Rectangle.ContainsRect * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rectA - [description] + * @param {Phaser.Geom.Rectangle} rectB - [description] * - * @return {number} [description] + * @return {boolean} [description] */ -var InOut = function (v) +var ContainsRect = function (rectA, rectB) { - if ((v *= 2) < 1) + // Volume check (if rectB volume > rectA then rectA cannot contain it) + if ((rectB.width * rectB.height) > (rectA.width * rectA.height)) { - return 0.5 * v * v; - } - else - { - return -0.5 * (--v * (v - 2) - 1); + return false; } + + return ( + (rectB.x > rectA.x && rectB.x < rectA.right) && + (rectB.right > rectA.x && rectB.right < rectA.right) && + (rectB.y > rectA.y && rectB.y < rectA.bottom) && + (rectB.bottom > rectA.y && rectB.bottom < rectA.bottom) + ); }; -module.exports = InOut; +module.exports = ContainsRect; /***/ }), /* 601 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -96404,27 +93064,30 @@ module.exports = InOut; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Contains = __webpack_require__(27); + /** * [description] * - * @function Phaser.Math.Easing.Quartic.In + * @function Phaser.Geom.Rectangle.ContainsPoint * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Point} point - [description] * - * @return {number} [description] + * @return {boolean} [description] */ -var In = function (v) +var ContainsPoint = function (rect, point) { - return v * v * v * v; + return Contains(rect, point.x, point.y); }; -module.exports = In; +module.exports = ContainsPoint; /***/ }), /* 602 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -96432,22 +93095,24 @@ module.exports = In; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Rectangle = __webpack_require__(10); + /** * [description] * - * @function Phaser.Math.Easing.Quartic.Out + * @function Phaser.Geom.Rectangle.Clone * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} source - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var Out = function (v) +var Clone = function (source) { - return 1 - (--v * v * v * v); + return new Rectangle(source.x, source.y, source.width, source.height); }; -module.exports = Out; +module.exports = Clone; /***/ }), @@ -96463,26 +93128,24 @@ module.exports = Out; /** * [description] * - * @function Phaser.Math.Easing.Quartic.InOut + * @function Phaser.Geom.Rectangle.CeilAll * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var InOut = function (v) +var CeilAll = function (rect) { - if ((v *= 2) < 1) - { - return 0.5 * v * v * v * v; - } - else - { - return -0.5 * ((v -= 2) * v * v * v - 2); - } + rect.x = Math.ceil(rect.x); + rect.y = Math.ceil(rect.y); + rect.width = Math.ceil(rect.width); + rect.height = Math.ceil(rect.height); + + return rect; }; -module.exports = InOut; +module.exports = CeilAll; /***/ }), @@ -96498,19 +93161,22 @@ module.exports = InOut; /** * [description] * - * @function Phaser.Math.Easing.Quintic.In + * @function Phaser.Geom.Rectangle.Ceil * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var In = function (v) +var Ceil = function (rect) { - return v * v * v * v * v; + rect.x = Math.ceil(rect.x); + rect.y = Math.ceil(rect.y); + + return rect; }; -module.exports = In; +module.exports = Ceil; /***/ }), @@ -96526,19 +93192,19 @@ module.exports = In; /** * [description] * - * @function Phaser.Math.Easing.Quintic.Out + * @function Phaser.Geom.Rectangle.Area * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] * * @return {number} [description] */ -var Out = function (v) +var Area = function (rect) { - return --v * v * v * v * v + 1; + return rect.width * rect.height; }; -module.exports = Out; +module.exports = Area; /***/ }), @@ -96551,34 +93217,38 @@ module.exports = Out; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +// Export the points as an array of flat numbers, following the sequence [ x,y, x,y, x,y ] + /** * [description] * - * @function Phaser.Math.Easing.Quintic.InOut + * @function Phaser.Geom.Polygon.GetNumberArray * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Polygon} polygon - [description] + * @param {array} [output] - [description] * - * @return {number} [description] + * @return {number[]} [description] */ -var InOut = function (v) +var GetNumberArray = function (polygon, output) { - if ((v *= 2) < 1) + if (output === undefined) { output = []; } + + for (var i = 0; i < polygon.points.length; i++) { - return 0.5 * v * v * v * v * v; - } - else - { - return 0.5 * ((v -= 2) * v * v * v * v + 2); + output.push(polygon.points[i].x); + output.push(polygon.points[i].y); } + + return output; }; -module.exports = InOut; +module.exports = GetNumberArray; /***/ }), /* 607 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -96586,38 +93256,53 @@ module.exports = InOut; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Rectangle = __webpack_require__(10); + /** * [description] * - * @function Phaser.Math.Easing.Sine.In + * @function Phaser.Geom.Polygon.GetAABB * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Polygon} polygon - [description] + * @param {(Phaser.Geom.Rectangle|object)} [out] - [description] * - * @return {number} [description] + * @return {(Phaser.Geom.Rectangle|object)} [description] */ -var In = function (v) +var GetAABB = function (polygon, out) { - if (v === 0) + if (out === undefined) { out = new Rectangle(); } + + var minX = Infinity; + var minY = Infinity; + var maxX = -minX; + var maxY = -minY; + var p; + + for (var i = 0; i < polygon.points.length; i++) { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - return 1 - Math.cos(v * Math.PI / 2); + p = polygon.points[i]; + + minX = Math.min(minX, p.x); + minY = Math.min(minY, p.y); + maxX = Math.max(maxX, p.x); + maxY = Math.max(maxY, p.y); } + + out.x = minX; + out.y = minY; + out.width = maxX - minX; + out.height = maxY - minY; + + return out; }; -module.exports = In; +module.exports = GetAABB; /***/ }), /* 608 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -96625,38 +93310,30 @@ module.exports = In; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Contains = __webpack_require__(125); + /** * [description] * - * @function Phaser.Math.Easing.Sine.Out + * @function Phaser.Geom.Polygon.ContainsPoint * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Polygon} polygon - [description] + * @param {Phaser.Geom.Point} point - [description] * - * @return {number} [description] + * @return {boolean} [description] */ -var Out = function (v) +var ContainsPoint = function (polygon, point) { - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - return Math.sin(v * Math.PI / 2); - } + return Contains(polygon, point.x, point.y); }; -module.exports = Out; +module.exports = ContainsPoint; /***/ }), /* 609 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -96664,38 +93341,29 @@ module.exports = Out; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Polygon = __webpack_require__(235); + /** * [description] * - * @function Phaser.Math.Easing.Sine.InOut + * @function Phaser.Geom.Polygon.Clone * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Polygon} polygon - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Polygon} [description] */ -var InOut = function (v) +var Clone = function (polygon) { - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - return 0.5 * (1 - Math.cos(Math.PI * v)); - } + return new Polygon(polygon.points); }; -module.exports = InOut; +module.exports = Clone; /***/ }), /* 610 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -96703,42 +93371,2084 @@ module.exports = InOut; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * [description] - * - * @function Phaser.Math.Easing.Stepped - * @since 3.0.0 - * - * @param {number} v - [description] - * @param {float} [steps=1] - [description] - * - * @return {number} [description] - */ -var Stepped = function (v, steps) -{ - if (steps === undefined) { steps = 1; } +var Polygon = __webpack_require__(235); - if (v <= 0) - { - return 0; - } - else if (v >= 1) - { - return 1; - } - else - { - return (((steps * v) | 0) + 1) * (1 / steps); - } -}; +Polygon.Clone = __webpack_require__(609); +Polygon.Contains = __webpack_require__(125); +Polygon.ContainsPoint = __webpack_require__(608); +Polygon.GetAABB = __webpack_require__(607); +Polygon.GetNumberArray = __webpack_require__(606); -module.exports = Stepped; +module.exports = Polygon; /***/ }), /* 611 */ /***/ (function(module, exports, __webpack_require__) { +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetMagnitude = __webpack_require__(237); + +/** + * [description] + * + * @function Phaser.Geom.Point.SetMagnitude + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * @param {number} magnitude - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var SetMagnitude = function (point, magnitude) +{ + if (point.x !== 0 || point.y !== 0) + { + var m = GetMagnitude(point); + + point.x /= m; + point.y /= m; + } + + point.x *= magnitude; + point.y *= magnitude; + + return point; +}; + +module.exports = SetMagnitude; + + +/***/ }), +/* 612 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +/** + * [description] + * + * @function Phaser.Geom.Point.ProjectUnit + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} pointA - [description] + * @param {Phaser.Geom.Point} pointB - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var ProjectUnit = function (pointA, pointB, out) +{ + if (out === undefined) { out = new Point(); } + + var amt = ((pointA.x * pointB.x) + (pointA.y * pointB.y)); + + if (amt !== 0) + { + out.x = amt * pointB.x; + out.y = amt * pointB.y; + } + + return out; +}; + +module.exports = ProjectUnit; + + +/***/ }), +/* 613 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); +var GetMagnitudeSq = __webpack_require__(236); + +/** + * [description] + * + * @function Phaser.Geom.Point.Project + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} pointA - [description] + * @param {Phaser.Geom.Point} pointB - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Project = function (pointA, pointB, out) +{ + if (out === undefined) { out = new Point(); } + + var dot = ((pointA.x * pointB.x) + (pointA.y * pointB.y)); + var amt = dot / GetMagnitudeSq(pointB); + + if (amt !== 0) + { + out.x = amt * pointB.x; + out.y = amt * pointB.y; + } + + return out; +}; + +module.exports = Project; + + +/***/ }), +/* 614 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +/** + * [description] + * + * @function Phaser.Geom.Point.Negative + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Negative = function (point, out) +{ + if (out === undefined) { out = new Point(); } + + return out.setTo(-point.x, -point.y); +}; + +module.exports = Negative; + + +/***/ }), +/* 615 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Point.Invert + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Invert = function (point) +{ + return point.setTo(point.y, point.x); +}; + +module.exports = Invert; + + +/***/ }), +/* 616 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +/** + * [description] + * + * @function Phaser.Geom.Point.Interpolate + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} pointA - [description] + * @param {Phaser.Geom.Point} pointB - [description] + * @param {float} [t=0] - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ +var Interpolate = function (pointA, pointB, t, out) +{ + if (t === undefined) { t = 0; } + if (out === undefined) { out = new Point(); } + + out.x = pointA.x + ((pointB.x - pointA.x) * t); + out.y = pointA.y + ((pointB.y - pointA.y) * t); + + return out; +}; + +module.exports = Interpolate; + + +/***/ }), +/* 617 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(10); + +/** + * Calculates the Axis Aligned Bounding Box (or aabb) from an array of points. + * + * @function Phaser.Geom.Point.GetRectangleFromPoints + * @since 3.0.0 + * + * @param {Phaser.Geom.Point[]} points - [description] + * @param {Phaser.Geom.Rectangle} [out] - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var GetRectangleFromPoints = function (points, out) +{ + if (out === undefined) { out = new Rectangle(); } + + var xMax = Number.NEGATIVE_INFINITY; + var xMin = Number.POSITIVE_INFINITY; + var yMax = Number.NEGATIVE_INFINITY; + var yMin = Number.POSITIVE_INFINITY; + + for (var i = 0; i < points.length; i++) + { + var point = points[i]; + + if (point.x > xMax) + { + xMax = point.x; + } + + if (point.x < xMin) + { + xMin = point.x; + } + + if (point.y > yMax) + { + yMax = point.y; + } + + if (point.y < yMin) + { + yMin = point.y; + } + } + + out.x = xMin; + out.y = yMin; + out.width = xMax - xMin; + out.height = yMax - yMin; + + return out; +}; + +module.exports = GetRectangleFromPoints; + + +/***/ }), +/* 618 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +/** + * [description] + * + * @function Phaser.Geom.Point.GetCentroid + * @since 3.0.0 + * + * @param {Phaser.Geom.Point[]} points - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var GetCentroid = function (points, out) +{ + if (out === undefined) { out = new Point(); } + + if (!Array.isArray(points)) + { + throw new Error('GetCentroid points argument must be an array'); + } + + var len = points.length; + + if (len < 1) + { + throw new Error('GetCentroid points array must not be empty'); + } + else if (len === 1) + { + out.x = points[0].x; + out.y = points[0].y; + } + else + { + for (var i = 0; i < len; i++) + { + out.x += points[i].x; + out.y += points[i].y; + } + + out.x /= len; + out.y /= len; + } + + return out; +}; + +module.exports = GetCentroid; + + +/***/ }), +/* 619 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Point.Floor + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Floor = function (point) +{ + return point.setTo(Math.floor(point.x), Math.floor(point.y)); +}; + +module.exports = Floor; + + +/***/ }), +/* 620 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Point.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * @param {Phaser.Geom.Point} toCompare - [description] + * + * @return {boolean} [description] + */ +var Equals = function (point, toCompare) +{ + return (point.x === toCompare.x && point.y === toCompare.y); +}; + +module.exports = Equals; + + +/***/ }), +/* 621 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Point.CopyFrom + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} source - [description] + * @param {Phaser.Geom.Point} dest - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x, source.y); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 622 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +/** + * [description] + * + * @function Phaser.Geom.Point.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} source - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Clone = function (source) +{ + return new Point(source.x, source.y); +}; + +module.exports = Clone; + + +/***/ }), +/* 623 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Point.Ceil + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Ceil = function (point) +{ + return point.setTo(Math.ceil(point.x), Math.ceil(point.y)); +}; + +module.exports = Ceil; + + +/***/ }), +/* 624 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +Point.Ceil = __webpack_require__(623); +Point.Clone = __webpack_require__(622); +Point.CopyFrom = __webpack_require__(621); +Point.Equals = __webpack_require__(620); +Point.Floor = __webpack_require__(619); +Point.GetCentroid = __webpack_require__(618); +Point.GetMagnitude = __webpack_require__(237); +Point.GetMagnitudeSq = __webpack_require__(236); +Point.GetRectangleFromPoints = __webpack_require__(617); +Point.Interpolate = __webpack_require__(616); +Point.Invert = __webpack_require__(615); +Point.Negative = __webpack_require__(614); +Point.Project = __webpack_require__(613); +Point.ProjectUnit = __webpack_require__(612); +Point.SetMagnitude = __webpack_require__(611); + +module.exports = Point; + + +/***/ }), +/* 625 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Line.Width + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * + * @return {number} [description] + */ +var Width = function (line) +{ + return Math.abs(line.x1 - line.x2); +}; + +module.exports = Width; + + +/***/ }), +/* 626 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Line.Slope + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * + * @return {number} [description] + */ +var Slope = function (line) +{ + return (line.y2 - line.y1) / (line.x2 - line.x1); +}; + +module.exports = Slope; + + +/***/ }), +/* 627 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Line.SetToAngle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} angle - [description] + * @param {number} length - [description] + * + * @return {Phaser.Geom.Line} [description] + */ +var SetToAngle = function (line, x, y, angle, length) +{ + line.x1 = x; + line.y1 = y; + + line.x2 = x + (Math.cos(angle) * length); + line.y2 = y + (Math.sin(angle) * length); + + return line; +}; + +module.exports = SetToAngle; + + +/***/ }), +/* 628 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RotateAroundXY = __webpack_require__(126); + +/** + * [description] + * + * @function Phaser.Geom.Line.RotateAroundPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {(Phaser.Geom.Point|object)} point - [description] + * @param {number} angle - [description] + * + * @return {Phaser.Geom.Line} [description] + */ +var RotateAroundPoint = function (line, point, angle) +{ + return RotateAroundXY(line, point.x, point.y, angle); +}; + +module.exports = RotateAroundPoint; + + +/***/ }), +/* 629 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RotateAroundXY = __webpack_require__(126); + +/** + * [description] + * + * @function Phaser.Geom.Line.Rotate + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {number} angle - [description] + * + * @return {Phaser.Geom.Line} [description] + */ +var Rotate = function (line, angle) +{ + var x = (line.x1 + line.x2) / 2; + var y = (line.y1 + line.y2) / 2; + + return RotateAroundXY(line, x, y, angle); +}; + +module.exports = Rotate; + + +/***/ }), +/* 630 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Angle = __webpack_require__(53); +var NormalAngle = __webpack_require__(238); + +/** +* Returns the reflected angle between two lines. +* This is the outgoing angle based on the angle of Line 1 and the normalAngle of Line 2. +*/ +/** + * [description] + * + * @function Phaser.Geom.Line.ReflectAngle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} lineA - [description] + * @param {Phaser.Geom.Line} lineB - [description] + * + * @return {number} [description] + */ +var ReflectAngle = function (lineA, lineB) +{ + return (2 * NormalAngle(lineB) - Math.PI - Angle(lineA)); +}; + +module.exports = ReflectAngle; + + +/***/ }), +/* 631 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Line.PerpSlope + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * + * @return {number} [description] + */ +var PerpSlope = function (line) +{ + return -((line.x2 - line.x1) / (line.y2 - line.y1)); +}; + +module.exports = PerpSlope; + + +/***/ }), +/* 632 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Line.Offset + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Geom.Line} [description] + */ +var Offset = function (line, x, y) +{ + line.x1 += x; + line.y1 += y; + + line.x2 += x; + line.y2 += y; + + return line; +}; + +module.exports = Offset; + + +/***/ }), +/* 633 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(16); +var Angle = __webpack_require__(53); + +/** + * [description] + * + * @function Phaser.Geom.Line.NormalY + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * + * @return {number} [description] + */ +var NormalY = function (line) +{ + return Math.sin(Angle(line) - MATH_CONST.TAU); +}; + +module.exports = NormalY; + + +/***/ }), +/* 634 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(16); +var Angle = __webpack_require__(53); + +/** + * [description] + * + * @function Phaser.Geom.Line.NormalX + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * + * @return {number} [description] + */ +var NormalX = function (line) +{ + return Math.cos(Angle(line) - MATH_CONST.TAU); +}; + +module.exports = NormalX; + + +/***/ }), +/* 635 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Line.Height + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * + * @return {number} [description] + */ +var Height = function (line) +{ + return Math.abs(line.y1 - line.y2); +}; + +module.exports = Height; + + +/***/ }), +/* 636 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(16); +var Angle = __webpack_require__(53); +var Point = __webpack_require__(4); + +/** + * [description] + * + * @function Phaser.Geom.Line.GetNormal + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ +var GetNormal = function (line, out) +{ + if (out === undefined) { out = new Point(); } + + var a = Angle(line) - MATH_CONST.TAU; + + out.x = Math.cos(a); + out.y = Math.sin(a); + + return out; +}; + +module.exports = GetNormal; + + +/***/ }), +/* 637 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +/** + * [description] + * + * @function Phaser.Geom.Line.GetMidPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ +var GetMidPoint = function (line, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = (line.x1 + line.x2) / 2; + out.y = (line.y1 + line.y2) / 2; + + return out; +}; + +module.exports = GetMidPoint; + + +/***/ }), +/* 638 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Line.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {Phaser.Geom.Line} toCompare - [description] + * + * @return {boolean} [description] + */ +var Equals = function (line, toCompare) +{ + return ( + line.x1 === toCompare.x1 && + line.y1 === toCompare.y1 && + line.x2 === toCompare.x2 && + line.y2 === toCompare.y2 + ); +}; + +module.exports = Equals; + + +/***/ }), +/* 639 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Line.CopyFrom + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} source - [description] + * @param {Phaser.Geom.Line} dest - [description] + * + * @return {Phaser.Geom.Line} [description] + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x1, source.y1, source.x2, source.y2); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 640 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Line = __webpack_require__(104); + +/** + * [description] + * + * @function Phaser.Geom.Line.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} source - [description] + * + * @return {Phaser.Geom.Line} [description] + */ +var Clone = function (source) +{ + return new Line(source.x1, source.y1, source.x2, source.y2); +}; + +module.exports = Clone; + + +/***/ }), +/* 641 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + + +/** + * [description] + * + * @function Phaser.Geom.Line.CenterOn + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Geom.Line} [description] + */ +var CenterOn = function (line, x, y) +{ + var tx = x - ((line.x1 + line.x2) / 2); + var ty = y - ((line.y1 + line.y2) / 2); + + line.x1 += tx; + line.y1 += ty; + + line.x2 += tx; + line.y2 += ty; + + return line; +}; + +module.exports = CenterOn; + + +/***/ }), +/* 642 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Line = __webpack_require__(104); + +Line.Angle = __webpack_require__(53); +Line.BresenhamPoints = __webpack_require__(344); +Line.CenterOn = __webpack_require__(641); +Line.Clone = __webpack_require__(640); +Line.CopyFrom = __webpack_require__(639); +Line.Equals = __webpack_require__(638); +Line.GetMidPoint = __webpack_require__(637); +Line.GetNormal = __webpack_require__(636); +Line.GetPoint = __webpack_require__(351); +Line.GetPoints = __webpack_require__(165); +Line.Height = __webpack_require__(635); +Line.Length = __webpack_require__(77); +Line.NormalAngle = __webpack_require__(238); +Line.NormalX = __webpack_require__(634); +Line.NormalY = __webpack_require__(633); +Line.Offset = __webpack_require__(632); +Line.PerpSlope = __webpack_require__(631); +Line.Random = __webpack_require__(164); +Line.ReflectAngle = __webpack_require__(630); +Line.Rotate = __webpack_require__(629); +Line.RotateAroundPoint = __webpack_require__(628); +Line.RotateAroundXY = __webpack_require__(126); +Line.SetToAngle = __webpack_require__(627); +Line.Slope = __webpack_require__(626); +Line.Width = __webpack_require__(625); + +module.exports = Line; + + +/***/ }), +/* 643 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ContainsArray = __webpack_require__(127); +var Decompose = __webpack_require__(239); +var LineToLine = __webpack_require__(95); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.TriangleToTriangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangleA - [description] + * @param {Phaser.Geom.Triangle} triangleB - [description] + * + * @return {boolean} [description] + */ +var TriangleToTriangle = function (triangleA, triangleB) +{ + // First the cheapest ones: + + if ( + triangleA.left > triangleB.right || + triangleA.right < triangleB.left || + triangleA.top > triangleB.bottom || + triangleA.bottom < triangleB.top) + { + return false; + } + + var lineAA = triangleA.getLineA(); + var lineAB = triangleA.getLineB(); + var lineAC = triangleA.getLineC(); + + var lineBA = triangleB.getLineA(); + var lineBB = triangleB.getLineB(); + var lineBC = triangleB.getLineC(); + + // Now check the lines against each line of TriangleB + if (LineToLine(lineAA, lineBA) || LineToLine(lineAA, lineBB) || LineToLine(lineAA, lineBC)) + { + return true; + } + + if (LineToLine(lineAB, lineBA) || LineToLine(lineAB, lineBB) || LineToLine(lineAB, lineBC)) + { + return true; + } + + if (LineToLine(lineAC, lineBA) || LineToLine(lineAC, lineBB) || LineToLine(lineAC, lineBC)) + { + return true; + } + + // Nope, so check to see if any of the points of triangleA are within triangleB + + var points = Decompose(triangleA); + var within = ContainsArray(triangleB, points, true); + + if (within.length > 0) + { + return true; + } + + // Finally check to see if any of the points of triangleB are within triangleA + + points = Decompose(triangleB); + within = ContainsArray(triangleA, points, true); + + if (within.length > 0) + { + return true; + } + + return false; +}; + +module.exports = TriangleToTriangle; + + +/***/ }), +/* 644 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(54); +var LineToLine = __webpack_require__(95); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.TriangleToLine + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Line} line - [description] + * + * @return {boolean} [description] + */ +var TriangleToLine = function (triangle, line) +{ + // If the Triangle contains either the start or end point of the line, it intersects + if (Contains(triangle, line.getPointA()) || Contains(triangle, line.getPointB())) + { + return true; + } + + // Now check the line against each line of the Triangle + if (LineToLine(triangle.getLineA(), line)) + { + return true; + } + + if (LineToLine(triangle.getLineB(), line)) + { + return true; + } + + if (LineToLine(triangle.getLineC(), line)) + { + return true; + } + + return false; +}; + +module.exports = TriangleToLine; + + +/***/ }), +/* 645 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var LineToCircle = __webpack_require__(242); +var Contains = __webpack_require__(54); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.TriangleToCircle + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Circle} circle - [description] + * + * @return {boolean} [description] + */ +var TriangleToCircle = function (triangle, circle) +{ + // First the cheapest ones: + + if ( + triangle.left > circle.right || + triangle.right < circle.left || + triangle.top > circle.bottom || + triangle.bottom < circle.top) + { + return false; + } + + if (Contains(triangle, circle.x, circle.y)) + { + return true; + } + + if (LineToCircle(triangle.getLineA(), circle)) + { + return true; + } + + if (LineToCircle(triangle.getLineB(), circle)) + { + return true; + } + + if (LineToCircle(triangle.getLineC(), circle)) + { + return true; + } + + return false; +}; + +module.exports = TriangleToCircle; + + +/***/ }), +/* 646 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Intersects.RectangleToValues + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} left - [description] + * @param {number} right - [description] + * @param {number} top - [description] + * @param {number} bottom - [description] + * @param {float} [tolerance=0] - [description] + * + * @return {boolean} [description] + */ +var RectangleToValues = function (rect, left, right, top, bottom, tolerance) +{ + if (tolerance === undefined) { tolerance = 0; } + + return !( + left > rect.right + tolerance || + right < rect.left - tolerance || + top > rect.bottom + tolerance || + bottom < rect.top - tolerance + ); +}; + +module.exports = RectangleToValues; + + +/***/ }), +/* 647 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var LineToLine = __webpack_require__(95); +var Contains = __webpack_require__(27); +var ContainsArray = __webpack_require__(127); +var Decompose = __webpack_require__(240); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.RectangleToTriangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Triangle} triangle - [description] + * + * @return {boolean} [description] + */ +var RectangleToTriangle = function (rect, triangle) +{ + // First the cheapest ones: + + if ( + triangle.left > rect.right || + triangle.right < rect.left || + triangle.top > rect.bottom || + triangle.bottom < rect.top) + { + return false; + } + + var triA = triangle.getLineA(); + var triB = triangle.getLineB(); + var triC = triangle.getLineC(); + + // Are any of the triangle points within the rectangle? + + if (Contains(rect, triA.x1, triA.y1) || Contains(rect, triA.x2, triA.y2)) + { + return true; + } + + if (Contains(rect, triB.x1, triB.y1) || Contains(rect, triB.x2, triB.y2)) + { + return true; + } + + if (Contains(rect, triC.x1, triC.y1) || Contains(rect, triC.x2, triC.y2)) + { + return true; + } + + // Cheap tests over, now to see if any of the lines intersect ... + + var rectA = rect.getLineA(); + var rectB = rect.getLineB(); + var rectC = rect.getLineC(); + var rectD = rect.getLineD(); + + if (LineToLine(triA, rectA) || LineToLine(triA, rectB) || LineToLine(triA, rectC) || LineToLine(triA, rectD)) + { + return true; + } + + if (LineToLine(triB, rectA) || LineToLine(triB, rectB) || LineToLine(triB, rectC) || LineToLine(triB, rectD)) + { + return true; + } + + if (LineToLine(triC, rectA) || LineToLine(triC, rectB) || LineToLine(triC, rectC) || LineToLine(triC, rectD)) + { + return true; + } + + // None of the lines intersect, so are any rectangle points within the triangle? + + var points = Decompose(rect); + var within = ContainsArray(triangle, points, true); + + return (within.length > 0); +}; + +module.exports = RectangleToTriangle; + + +/***/ }), +/* 648 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PointToLine = __webpack_require__(241); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.PointToLineSegment + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * @param {Phaser.Geom.Line} line - [description] + * + * @return {boolean} [description] + */ +var PointToLineSegment = function (point, line) +{ + if (!PointToLine(point, line)) + { + return false; + } + + var xMin = Math.min(line.x1, line.x2); + var xMax = Math.max(line.x1, line.x2); + var yMin = Math.min(line.y1, line.y2); + var yMax = Math.max(line.y1, line.y2); + + return ((point.x >= xMin && point.x <= xMax) && (point.y >= yMin && point.y <= yMax)); +}; + +module.exports = PointToLineSegment; + + +/***/ }), +/* 649 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Checks for intersection between the Line and a Rectangle shape, or a rectangle-like + * object, with public `x`, `y`, `right` and `bottom` properties, such as a Sprite or Body. + * + * An intersection is considered valid if: + * + * The line starts within, or ends within, the Rectangle. + * The line segment intersects one of the 4 rectangle edges. + * + * The for the purposes of this function rectangles are considered 'solid'. + * + * @function Phaser.Geom.Intersects.LineToRectangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {(Phaser.Geom.Rectangle|object)} rect - [description] + * + * @return {boolean} [description] + */ +var LineToRectangle = function (line, rect) +{ + var x1 = line.x1; + var y1 = line.y1; + + var x2 = line.x2; + var y2 = line.y2; + + var bx1 = rect.x; + var by1 = rect.y; + var bx2 = rect.right; + var by2 = rect.bottom; + + var t = 0; + + // If the start or end of the line is inside the rect then we assume + // collision, as rects are solid for our use-case. + + if ((x1 >= bx1 && x1 <= bx2 && y1 >= by1 && y1 <= by2) || + (x2 >= bx1 && x2 <= bx2 && y2 >= by1 && y2 <= by2)) + { + return true; + } + + if (x1 < bx1 && x2 >= bx1) + { + // Left edge + t = y1 + (y2 - y1) * (bx1 - x1) / (x2 - x1); + + if (t > by1 && t <= by2) + { + return true; + } + } + else if (x1 > bx2 && x2 <= bx2) + { + // Right edge + t = y1 + (y2 - y1) * (bx2 - x1) / (x2 - x1); + + if (t >= by1 && t <= by2) + { + return true; + } + } + + if (y1 < by1 && y2 >= by1) + { + // Top edge + t = x1 + (x2 - x1) * (by1 - y1) / (y2 - y1); + + if (t >= bx1 && t <= bx2) + { + return true; + } + } + else if (y1 > by2 && y2 <= by2) + { + // Bottom edge + t = x1 + (x2 - x1) * (by2 - y1) / (y2 - y1); + + if (t >= bx1 && t <= bx2) + { + return true; + } + } + + return false; +}; + +module.exports = LineToRectangle; + + +/***/ }), +/* 650 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(10); +var RectangleToRectangle = __webpack_require__(243); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.GetRectangleIntersection + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rectA - [description] + * @param {Phaser.Geom.Rectangle} rectB - [description] + * @param {Phaser.Geom.Rectangle} [output] - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var GetRectangleIntersection = function (rectA, rectB, output) +{ + if (output === undefined) { output = new Rectangle(); } + + if (RectangleToRectangle(rectA, rectB)) + { + output.x = Math.max(rectA.x, rectB.x); + output.y = Math.max(rectA.y, rectB.y); + output.width = Math.min(rectA.right, rectB.right) - output.x; + output.height = Math.min(rectA.bottom, rectB.bottom) - output.y; + } + + return output; +}; + +module.exports = GetRectangleIntersection; + + +/***/ }), +/* 651 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Intersects.CircleToRectangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {boolean} [description] + */ +var CircleToRectangle = function (circle, rect) +{ + var halfWidth = rect.width / 2; + var halfHeight = rect.height / 2; + + var cx = Math.abs(circle.x - rect.x - halfWidth); + var cy = Math.abs(circle.y - rect.y - halfHeight); + var xDist = halfWidth + circle.radius; + var yDist = halfHeight + circle.radius; + + if (cx > xDist || cy > yDist) + { + return false; + } + else if (cx <= halfWidth || cy <= halfHeight) + { + return true; + } + else + { + var xCornerDist = cx - halfWidth; + var yCornerDist = cy - halfHeight; + var xCornerDistSq = xCornerDist * xCornerDist; + var yCornerDistSq = yCornerDist * yCornerDist; + var maxCornerDistSq = circle.radius * circle.radius; + + return (xCornerDistSq + yCornerDistSq <= maxCornerDistSq); + } +}; + +module.exports = CircleToRectangle; + + +/***/ }), +/* 652 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var DistanceBetween = __webpack_require__(48); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.CircleToCircle + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circleA - [description] + * @param {Phaser.Geom.Circle} circleB - [description] + * + * @return {boolean} [description] + */ +var CircleToCircle = function (circleA, circleB) +{ + return (DistanceBetween(circleA.x, circleA.y, circleB.x, circleB.y) <= (circleA.radius + circleB.radius)); +}; + +module.exports = CircleToCircle; + + +/***/ }), +/* 653 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Offsets the Circle by the values given in the `x` and `y` properties of the Point object. + * + * @function Phaser.Geom.Circle.OffsetPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to be offset (translated.) + * @param {(Phaser.Geom.Point|object)} point - The Point object containing the values to offset the Circle by. + * + * @return {Phaser.Geom.Circle} The Circle that was offset. + */ +var OffsetPoint = function (circle, point) +{ + circle.x += point.x; + circle.y += point.y; + + return circle; +}; + +module.exports = OffsetPoint; + + +/***/ }), +/* 654 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Offsets the Circle by the values given. + * + * @function Phaser.Geom.Circle.Offset + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to be offset (translated.) + * @param {number} x - The amount to horizontally offset the Circle by. + * @param {number} y - The amount to vertically offset the Circle by. + * + * @return {Phaser.Geom.Circle} The Circle that was offset. + */ +var Offset = function (circle, x, y) +{ + circle.x += x; + circle.y += y; + + return circle; +}; + +module.exports = Offset; + + +/***/ }), +/* 655 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(10); + +/** + * Returns the bounds of the Circle object. + * + * @function Phaser.Geom.Circle.GetBounds + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the bounds from. + * @param {(Phaser.Geom.Rectangle|object)} [out] - A Rectangle, or rectangle-like object, to store the circle bounds in. If not given a new Rectangle will be created. + * + * @return {(Phaser.Geom.Rectangle|object)} The Rectangle object containing the Circles bounds. + */ +var GetBounds = function (circle, out) +{ + if (out === undefined) { out = new Rectangle(); } + + out.x = circle.left; + out.y = circle.top; + out.width = circle.diameter; + out.height = circle.diameter; + + return out; +}; + +module.exports = GetBounds; + + +/***/ }), +/* 656 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Compares the `x`, `y` and `radius` properties of the two given Circles. + * Returns `true` if they all match, otherwise returns `false`. + * + * @function Phaser.Geom.Circle.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The first Circle to compare. + * @param {Phaser.Geom.Circle} toCompare - The second Circle to compare. + * + * @return {boolean} `true` if the two Circles equal each other, otherwise `false`. + */ +var Equals = function (circle, toCompare) +{ + return ( + circle.x === toCompare.x && + circle.y === toCompare.y && + circle.radius === toCompare.radius + ); +}; + +module.exports = Equals; + + +/***/ }), +/* 657 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Copies the `x`, `y` and `radius` properties from the `source` Circle + * into the given `dest` Circle, then returns the `dest` Circle. + * + * @function Phaser.Geom.Circle.CopyFrom + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} source - The source Circle to copy the values from. + * @param {Phaser.Geom.Circle} dest - The destination Circle to copy the values to. + * + * @return {Phaser.Geom.Circle} The dest Circle. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x, source.y, source.radius); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 658 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(28); + +/** + * Check to see if the Circle contains all four points of the given Rectangle object. + * + * @function Phaser.Geom.Circle.ContainsRect + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to check. + * @param {(Phaser.Geom.Rectangle|object)} rect - The Rectangle object to check if it's within the Circle or not. + * + * @return {boolean} True if all of the Rectangle coordinates are within the circle, otherwise false. + */ +var ContainsRect = function (circle, rect) +{ + return ( + Contains(circle, rect.x, rect.y) && + Contains(circle, rect.right, rect.y) && + Contains(circle, rect.x, rect.bottom) && + Contains(circle, rect.right, rect.bottom) + ); +}; + +module.exports = ContainsRect; + + +/***/ }), +/* 659 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(28); + +/** + * Check to see if the Circle contains the given Point object. + * + * @function Phaser.Geom.Circle.ContainsPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to check. + * @param {(Phaser.Geom.Point|object)} point - The Point object to check if it's within the Circle or not. + * + * @return {boolean} True if the Point coordinates are within the circle, otherwise false. + */ +var ContainsPoint = function (circle, point) +{ + return Contains(circle, point.x, point.y); +}; + +module.exports = ContainsPoint; + + +/***/ }), +/* 660 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Circle = __webpack_require__(79); + +/** + * Creates a new Circle instance based on the values contained in the given source. + * + * @function Phaser.Geom.Circle.Clone + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|object)} source - The Circle to be cloned. Can be an instance of a Circle or a circle-like object, with x, y and radius properties. + * + * @return {Phaser.Geom.Circle} A clone of the source Circle. + */ +var Clone = function (source) +{ + return new Circle(source.x, source.y, source.radius); +}; + +module.exports = Clone; + + +/***/ }), +/* 661 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculates the area of the circle. + * + * @function Phaser.Geom.Circle.Area + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the area of. + * + * @return {number} The area of the Circle. + */ +var Area = function (circle) +{ + return (circle.radius > 0) ? Math.PI * circle.radius * circle.radius : 0; +}; + +module.exports = Area; + + +/***/ }), +/* 662 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Circle = __webpack_require__(79); + +Circle.Area = __webpack_require__(661); +Circle.Circumference = __webpack_require__(353); +Circle.CircumferencePoint = __webpack_require__(168); +Circle.Clone = __webpack_require__(660); +Circle.Contains = __webpack_require__(28); +Circle.ContainsPoint = __webpack_require__(659); +Circle.ContainsRect = __webpack_require__(658); +Circle.CopyFrom = __webpack_require__(657); +Circle.Equals = __webpack_require__(656); +Circle.GetBounds = __webpack_require__(655); +Circle.GetPoint = __webpack_require__(355); +Circle.GetPoints = __webpack_require__(354); +Circle.Offset = __webpack_require__(654); +Circle.OffsetPoint = __webpack_require__(653); +Circle.Random = __webpack_require__(167); + +module.exports = Circle; + + +/***/ }), +/* 663 */ +/***/ (function(module, exports, __webpack_require__) { + /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. @@ -96746,8 +95456,3672 @@ module.exports = Stepped; */ var Class = __webpack_require__(0); -var DegToRad = __webpack_require__(35); -var DistanceBetween = __webpack_require__(42); +var LightsManager = __webpack_require__(246); +var PluginManager = __webpack_require__(12); + +/** + * @classdesc + * [description] + * + * @class LightsPlugin + * @extends Phaser.GameObjects.LightsManager + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ +var LightsPlugin = new Class({ + + Extends: LightsManager, + + initialize: + + function LightsPlugin (scene) + { + /** + * [description] + * + * @name Phaser.GameObjects.LightsPlugin#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.GameObjects.LightsPlugin#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + if (!scene.sys.settings.isBooted) + { + scene.sys.events.once('boot', this.boot, this); + } + + LightsManager.call(this); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsPlugin#boot + * @since 3.0.0 + */ + boot: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsPlugin#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + + this.scene = undefined; + this.systems = undefined; + } + +}); + +PluginManager.register('LightsPlugin', LightsPlugin, 'lights'); + +module.exports = LightsPlugin; + + +/***/ }), +/* 664 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(22); +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); +var Quad = __webpack_require__(128); + +/** + * Creates a new Quad Game Object and returns it. + * + * Note: This method will only be available if the Quad Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#quad + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Quad} The Game Object that was created. + */ +GameObjectCreator.register('quad', function (config) +{ + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + + var quad = new Quad(this.scene, x, y, key, frame); + + BuildGameObject(this.scene, quad, config); + + return quad; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 665 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(22); +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); +var GetValue = __webpack_require__(5); +var Mesh = __webpack_require__(96); + +/** + * Creates a new Mesh Game Object and returns it. + * + * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#mesh + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Mesh} The Game Object that was created. + */ +GameObjectCreator.register('mesh', function (config) +{ + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + var vertices = GetValue(config, 'vertices', []); + var colors = GetValue(config, 'colors', []); + var alphas = GetValue(config, 'alphas', []); + var uv = GetValue(config, 'uv', []); + + var mesh = new Mesh(this.scene, 0, 0, vertices, uv, colors, alphas, key, frame); + + BuildGameObject(this.scene, mesh, config); + + return mesh; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 666 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Quad = __webpack_require__(128); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new Quad Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Quad Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#quad + * @webglOnly + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Quad} The Game Object that was created. + */ +if (true) +{ + GameObjectFactory.register('quad', function (x, y, key, frame) + { + return this.displayList.add(new Quad(this.scene, x, y, key, frame)); + }); +} + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 667 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Mesh = __webpack_require__(96); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new Mesh Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#mesh + * @webglOnly + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {array} vertices - An array containing the vertices data for this Mesh. + * @param {array} uv - An array containing the uv data for this Mesh. + * @param {array} colors - An array containing the color data for this Mesh. + * @param {array} alphas - An array containing the alpha data for this Mesh. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Mesh} The Game Object that was created. + */ +if (true) +{ + GameObjectFactory.register('mesh', function (x, y, vertices, uv, colors, alphas, texture, frame) + { + return this.displayList.add(new Mesh(this.scene, x, y, vertices, uv, colors, alphas, texture, frame)); + }); +} + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 668 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * This is a stub function for Mesh.Render. There is no Canvas renderer for Mesh objects. + * + * @method Phaser.GameObjects.Mesh#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Mesh} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var MeshCanvasRenderer = function () +{ +}; + +module.exports = MeshCanvasRenderer; + + +/***/ }), +/* 669 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Mesh#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Mesh} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var MeshWebGLRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + this.pipeline.batchMesh(src, camera); +}; + +module.exports = MeshWebGLRenderer; + + +/***/ }), +/* 670 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); + +if (true) +{ + renderWebGL = __webpack_require__(669); +} + +if (true) +{ + renderCanvas = __webpack_require__(668); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 671 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); +var Zone = __webpack_require__(106); + +/** + * Creates a new Zone Game Object and returns it. + * + * Note: This method will only be available if the Zone Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#zone + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Zone} The Game Object that was created. + */ +GameObjectCreator.register('zone', function (config) +{ + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 1); + var height = GetAdvancedValue(config, 'height', width); + + return new Zone(this.scene, x, y, width, height); +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 672 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(22); +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); +var TileSprite = __webpack_require__(129); + +/** + * @typedef {object} TileSprite + * @extends GameObjectConfig + * + * @property {number} [x=0] - [description] + * @property {number} [y=0] - [description] + * @property {number} [width=512] - [description] + * @property {number} [height=512] - [description] + * @property {string} [key=''] - [description] + * @property {string} [frame=''] - [description] + */ + +/** + * Creates a new TileSprite Game Object and returns it. + * + * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#tileSprite + * @since 3.0.0 + * + * @param {TileSprite} config - [description] + * + * @return {Phaser.GameObjects.TileSprite} The Game Object that was created. + */ +GameObjectCreator.register('tileSprite', function (config) +{ + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 512); + var height = GetAdvancedValue(config, 'height', 512); + var key = GetAdvancedValue(config, 'key', ''); + var frame = GetAdvancedValue(config, 'frame', ''); + + var tile = new TileSprite(this.scene, x, y, width, height, key, frame); + + BuildGameObject(this.scene, tile, config); + + return tile; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 673 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(22); +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); +var Text = __webpack_require__(130); + +/** + * Creates a new Text Game Object and returns it. + * + * Note: This method will only be available if the Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#text + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Text} The Game Object that was created. + */ +GameObjectCreator.register('text', function (config) +{ + // style Object = { + // font: [ 'font', '16px Courier' ], + // backgroundColor: [ 'backgroundColor', null ], + // fill: [ 'fill', '#fff' ], + // stroke: [ 'stroke', '#fff' ], + // strokeThickness: [ 'strokeThickness', 0 ], + // shadowOffsetX: [ 'shadow.offsetX', 0 ], + // shadowOffsetY: [ 'shadow.offsetY', 0 ], + // shadowColor: [ 'shadow.color', '#000' ], + // shadowBlur: [ 'shadow.blur', 0 ], + // shadowStroke: [ 'shadow.stroke', false ], + // shadowFill: [ 'shadow.fill', false ], + // align: [ 'align', 'left' ], + // maxLines: [ 'maxLines', 0 ], + // fixedWidth: [ 'fixedWidth', false ], + // fixedHeight: [ 'fixedHeight', false ], + // rtl: [ 'rtl', false ] + // } + + var content = GetAdvancedValue(config, 'text', ''); + var style = GetAdvancedValue(config, 'style', null); + + // Padding + // { padding: 2 } + // { padding: { x: , y: }} + // { padding: { left: , top: }} + // { padding: { left: , right: , top: , bottom: }} + + var padding = GetAdvancedValue(config, 'padding', null); + + if (padding !== null) + { + style.padding = padding; + } + + var text = new Text(this.scene, 0, 0, content, style); + + BuildGameObject(this.scene, text, config); + + // Text specific config options: + + text.autoRound = GetAdvancedValue(config, 'autoRound', true); + text.resolution = GetAdvancedValue(config, 'resolution', 1); + + return text; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 674 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BitmapText = __webpack_require__(139); +var BuildGameObject = __webpack_require__(22); +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); +var GetValue = __webpack_require__(5); + +/** + * Creates a new Bitmap Text Game Object and returns it. + * + * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#bitmapText + * @since 3.0.0 + * + * @param {BitmapTextConfig} config - [description] + * + * @return {Phaser.GameObjects.BitmapText} The Game Object that was created. + */ +GameObjectCreator.register('bitmapText', function (config) +{ + var font = GetValue(config, 'font', ''); + var text = GetAdvancedValue(config, 'text', ''); + var size = GetAdvancedValue(config, 'size', false); + + // var align = GetValue(config, 'align', 'left'); + + var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size); + + BuildGameObject(this.scene, bitmapText, config); + + return bitmapText; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 675 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(22); +var BuildGameObjectAnimation = __webpack_require__(140); +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); +var Sprite = __webpack_require__(40); + +/** + * Creates a new Sprite Game Object and returns it. + * + * Note: This method will only be available if the Sprite Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#sprite + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Sprite} The Game Object that was created. + */ +GameObjectCreator.register('sprite', function (config) +{ + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + + var sprite = new Sprite(this.scene, 0, 0, key, frame); + + BuildGameObject(this.scene, sprite, config); + + // Sprite specific config options: + + BuildGameObjectAnimation(sprite, config); + + // Physics, Input, etc to follow ... + + return sprite; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 676 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(22); +var BuildGameObjectAnimation = __webpack_require__(140); +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); +var Sprite3D = __webpack_require__(101); + +/** + * Creates a new Sprite3D Game Object and returns it. + * + * Note: This method will only be available if the Sprite3D Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#sprite3D + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Sprite3D} The Game Object that was created. + */ +GameObjectCreator.register('sprite3D', function (config) +{ + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + + var sprite = new Sprite3D(this.scene, 0, 0, key, frame); + + BuildGameObject(this.scene, sprite, config); + + // Sprite specific config options: + + BuildGameObjectAnimation(sprite, config); + + // Physics, Input, etc to follow ... + + return sprite; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 677 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(22); +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); +var RenderTexture = __webpack_require__(131); + +/** + * @typedef {object} RenderTextureConfig + * + * @property {number} [x=0] - [description] + * @property {number} [y=0] - [description] + * @property {number} [width=32] - [description] + * @property {number} [height=32] - [description] + */ + +/** + * Creates a new Render Texture Game Object and returns it. + * + * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#renderTexture + * @since 3.2.0 + * + * @param {RenderTextureConfig} config - [description] + * + * @return {Phaser.GameObjects.RenderTexture} The Game Object that was created. + */ +GameObjectCreator.register('renderTexture', function (config) +{ + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 32); + var height = GetAdvancedValue(config, 'height', 32); + var renderTexture = new RenderTexture(this.scene, x, y, width, height); + + BuildGameObject(this.scene, renderTexture, config); + + return renderTexture; +}); + + +/***/ }), +/* 678 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); +var GetFastValue = __webpack_require__(2); +var ParticleEmitterManager = __webpack_require__(133); + +/** + * Creates a new Particle Emitter Manager Game Object and returns it. + * + * Note: This method will only be available if the Particles Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#particles + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} The Game Object that was created. + */ +GameObjectCreator.register('particles', function (config) +{ + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + var emitters = GetFastValue(config, 'emitters', null); + + // frame is optional and can contain the emitters array or object if skipped + var manager = new ParticleEmitterManager(this.scene, key, frame, emitters); + + var add = GetFastValue(config, 'add', false); + + if (add) + { + this.displayList.add(manager); + } + + this.updateList.add(manager); + + return manager; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 679 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(22); +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); +var Image = __webpack_require__(72); + +/** + * Creates a new Image Game Object and returns it. + * + * Note: This method will only be available if the Image Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#image + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Image} The Game Object that was created. + */ +GameObjectCreator.register('image', function (config) +{ + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + + var image = new Image(this.scene, 0, 0, key, frame); + + BuildGameObject(this.scene, image, config); + + return image; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 680 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectCreator = __webpack_require__(11); +var Group = __webpack_require__(73); + +/** + * Creates a new Group Game Object and returns it. + * + * Note: This method will only be available if the Group Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#group + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Group} The Game Object that was created. + */ +GameObjectCreator.register('group', function (config) +{ + return new Group(this.scene, null, config); +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 681 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectCreator = __webpack_require__(11); +var Graphics = __webpack_require__(136); + +/** + * Creates a new Graphics Game Object and returns it. + * + * Note: This method will only be available if the Graphics Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#graphics + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Graphics} The Game Object that was created. + */ +GameObjectCreator.register('graphics', function (config) +{ + return new Graphics(this.scene, config); +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 682 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BitmapText = __webpack_require__(137); +var BuildGameObject = __webpack_require__(22); +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); + +/** + * @typedef {object} BitmapTextConfig + * @extends GameObjectConfig + * + * @property {string} [font=''] - [description] + * @property {string} [text=''] - [description] + * @property {(number|false)} [size=false] - [description] + * @property {string} [align=''] - [description] + */ + +/** + * Creates a new Dynamic Bitmap Text Game Object and returns it. + * + * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#dynamicBitmapText + * @since 3.0.0 + *² + * @param {BitmapTextConfig} config - [description] + * + * @return {Phaser.GameObjects.DynamicBitmapText} The Game Object that was created. + */ +GameObjectCreator.register('dynamicBitmapText', function (config) +{ + var font = GetAdvancedValue(config, 'font', ''); + var text = GetAdvancedValue(config, 'text', ''); + var size = GetAdvancedValue(config, 'size', false); + var align = GetAdvancedValue(config, 'align', 'left'); + + var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size, align); + + BuildGameObject(this.scene, bitmapText, config); + + return bitmapText; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 683 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Blitter = __webpack_require__(138); +var BuildGameObject = __webpack_require__(22); +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); + +/** + * Creates a new Blitter Game Object and returns it. + * + * Note: This method will only be available if the Blitter Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#blitter + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Blitter} The Game Object that was created. + */ +GameObjectCreator.register('blitter', function (config) +{ + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + + var blitter = new Blitter(this.scene, 0, 0, key, frame); + + BuildGameObject(this.scene, blitter, config); + + return blitter; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 684 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Zone = __webpack_require__(106); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new Zone Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Zone Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#zone + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number} width - The width of the Game Object. + * @param {number} height - The height of the Game Object. + * + * @return {Phaser.GameObjects.Zone} The Game Object that was created. + */ +GameObjectFactory.register('zone', function (x, y, width, height) +{ + return this.displayList.add(new Zone(this.scene, x, y, width, height)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 685 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TileSprite = __webpack_require__(129); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new TileSprite Game Object and adds it to the Scene. + * + * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#tileSprite + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number} width - The width of the Game Object. + * @param {number} height - The height of the Game Object. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.TileSprite} The Game Object that was created. + */ +GameObjectFactory.register('tileSprite', function (x, y, width, height, key, frame) +{ + return this.displayList.add(new TileSprite(this.scene, x, y, width, height, key, frame)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 686 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Text = __webpack_require__(130); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new Text Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#text + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {(string|string[])} text - The text this Text object will display. + * @param {object} [style] - The Text style configuration object. + * + * @return {Phaser.GameObjects.Text} The Game Object that was created. + */ +GameObjectFactory.register('text', function (x, y, text, style) +{ + return this.displayList.add(new Text(this.scene, x, y, text, style)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 687 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BitmapText = __webpack_require__(139); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new Bitmap Text Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#bitmapText + * @since 3.0.0 + * + * @param {number} x - The x position of the Game Object. + * @param {number} y - The y position of the Game Object. + * @param {string} font - [description] + * @param {(string|string[])} [text] - [description] + * @param {number} [size] - [description] + * + * @return {Phaser.GameObjects.BitmapText} The Game Object that was created. + */ +GameObjectFactory.register('bitmapText', function (x, y, font, text, size) +{ + return this.displayList.add(new BitmapText(this.scene, x, y, font, text, size)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 688 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(9); +var Sprite = __webpack_require__(40); + +/** + * Creates a new Sprite Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Sprite Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#sprite + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Sprite} The Game Object that was created. + */ +GameObjectFactory.register('sprite', function (x, y, key, frame) +{ + var sprite = new Sprite(this.scene, x, y, key, frame); + + this.displayList.add(sprite); + this.updateList.add(sprite); + + return sprite; +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 689 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Sprite3D = __webpack_require__(101); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new Sprite3D Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Sprite3D Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#sprite3D + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object. + * @param {number} y - The vertical position of this Game Object. + * @param {number} z - The z position of this Game Object. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Sprite3D} The Game Object that was created. + */ +GameObjectFactory.register('sprite3D', function (x, y, z, key, frame) +{ + var sprite = new Sprite3D(this.scene, x, y, z, key, frame); + + this.displayList.add(sprite.gameObject); + this.updateList.add(sprite.gameObject); + + return sprite; +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 690 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(9); +var RenderTexture = __webpack_require__(131); + +/** + * Creates a new Render Texture Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#renderTexture + * @since 3.2.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {integer} [width=32] - The width of the Render Texture. + * @param {integer} [height=32] - The height of the Render Texture. + * + * @return {Phaser.GameObjects.RenderTexture} The Game Object that was created. + */ +GameObjectFactory.register('renderTexture', function (x, y, width, height) +{ + return this.displayList.add(new RenderTexture(this.scene, x, y, width, height)); +}); + + +/***/ }), +/* 691 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(9); +var PathFollower = __webpack_require__(249); + +/** + * Creates a new PathFollower Game Object and adds it to the Scene. + * + * Note: This method will only be available if the PathFollower Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#follower + * @since 3.0.0 + * + * @param {Phaser.Curves.Path} path - The Path this PathFollower is connected to. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.PathFollower} The Game Object that was created. + */ +GameObjectFactory.register('follower', function (path, x, y, key, frame) +{ + var sprite = new PathFollower(this.scene, path, x, y, key, frame); + + this.displayList.add(sprite); + this.updateList.add(sprite); + + return sprite; +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 692 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(9); +var ParticleEmitterManager = __webpack_require__(133); + +/** + * Creates a new Particle Emitter Manager Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Particles Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#particles + * @since 3.0.0 + * + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer|object)} [frame] - [description] + * @param {object} [emitters] - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} The Game Object that was created. + */ +GameObjectFactory.register('particles', function (key, frame, emitters) +{ + var manager = new ParticleEmitterManager(this.scene, key, frame, emitters); + + this.displayList.add(manager); + this.updateList.add(manager); + + return manager; +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 693 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Image = __webpack_require__(72); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new Image Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Image Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#image + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Image} The Game Object that was created. + */ +GameObjectFactory.register('image', function (x, y, key, frame) +{ + return this.displayList.add(new Image(this.scene, x, y, key, frame)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 694 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Group = __webpack_require__(73); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new Group Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Group Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#group + * @since 3.0.0 + * + * @param {(array|object)} children - [description] + * @param {object} [config] - [description] + * + * @return {Phaser.GameObjects.Group} The Game Object that was created. + */ +GameObjectFactory.register('group', function (children, config) +{ + if (typeof children === 'object' && config === undefined) + { + config = children; + children = []; + } + + return this.updateList.add(new Group(this.scene, children, config)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 695 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Graphics = __webpack_require__(136); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new Graphics Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Graphics Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#graphics + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Graphics} The Game Object that was created. + */ +GameObjectFactory.register('graphics', function (config) +{ + return this.displayList.add(new Graphics(this.scene, config)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 696 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var DynamicBitmapText = __webpack_require__(137); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new Dynamic Bitmap Text Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#dynamicBitmapText + * @since 3.0.0 + * + * @param {number} x - The x position of the Game Object. + * @param {number} y - The y position of the Game Object. + * @param {string} font - [description] + * @param {(string|string[])} [text] - [description] + * @param {number} [size] - [description] + * + * @return {Phaser.GameObjects.DynamicBitmapText} The Game Object that was created. + */ +GameObjectFactory.register('dynamicBitmapText', function (x, y, font, text, size) +{ + return this.displayList.add(new DynamicBitmapText(this.scene, x, y, font, text, size)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 697 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Blitter = __webpack_require__(138); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new Blitter Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Blitter Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#blitter + * @since 3.0.0 + * + * @param {number} x - The x position of the Game Object. + * @param {number} y - The y position of the Game Object. + * @param {string} key - The key of the Texture the Blitter object will use. + * @param {(string|integer)} [frame] - The default Frame children of the Blitter will use. + * + * @return {Phaser.GameObjects.Blitter} The Game Object that was created. + */ +GameObjectFactory.register('blitter', function (x, y, key, frame) +{ + return this.displayList.add(new Blitter(this.scene, x, y, key, frame)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 698 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.TileSprite#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.TileSprite} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + var ctx = renderer.currentContext; + var frame = src.frame; + + src.updateTileTexture(); + + // Blend Mode + + if (renderer.currentBlendMode !== src.blendMode) + { + renderer.currentBlendMode = src.blendMode; + ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; + } + + // Alpha + + if (renderer.currentAlpha !== src.alpha) + { + renderer.currentAlpha = src.alpha; + ctx.globalAlpha = src.alpha; + } + + // Smoothing + + if (renderer.currentScaleMode !== src.scaleMode) + { + renderer.currentScaleMode = src.scaleMode; + } + + var dx = frame.x - (src.originX * src.width); + var dy = frame.y - (src.originY * src.height); + + var tx = src.x - camera.scrollX * src.scrollFactorX; + var ty = src.y - camera.scrollY * src.scrollFactorY; + + var fx = 1; + var fy = 1; + + // Flipping + + if (src.flipX) + { + fx = -1; + dx += src.width; + } + + if (src.flipY) + { + fy = -1; + dy += src.height; + } + + if (renderer.config.roundPixels) + { + dx |= 0; + dy |= 0; + tx |= 0; + ty |= 0; + } + + ctx.save(); + + ctx.translate(dx, dy); + + ctx.translate(tx, ty); + + // Flip + ctx.scale(fx, fy); + + // Rotate and scale around center + ctx.translate((src.originX * src.width), (src.originY * src.height)); + ctx.rotate(fx * fy * src.rotation); + ctx.scale(this.scaleX, this.scaleY); + ctx.translate(-(src.originX * src.width), -(src.originY * src.height)); + + // Draw + ctx.translate(-this.tilePositionX, -this.tilePositionY); + ctx.fillStyle = src.canvasPattern; + ctx.fillRect(this.tilePositionX, this.tilePositionY, src.width, src.height); + + ctx.restore(); +}; + +module.exports = TileSpriteCanvasRenderer; + + +/***/ }), +/* 699 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.TileSprite#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.TileSprite} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var TileSpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + src.updateTileTexture(); + + this.pipeline.batchTileSprite(this, camera); +}; + +module.exports = TileSpriteWebGLRenderer; + + +/***/ }), +/* 700 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); + +if (true) +{ + renderWebGL = __webpack_require__(699); +} + +if (true) +{ + renderCanvas = __webpack_require__(698); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 701 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasPool = __webpack_require__(23); + +/** + * Calculates the ascent, descent and fontSize of a given font style. + * + * @function Phaser.GameObjects.Text.MeasureText + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Text.TextStyle} textStyle - The TextStyle object to measure. + * + * @return {object} An object containing the ascent, descent and fontSize of the TextStyle. + */ +var MeasureText = function (textStyle) +{ + // @property {HTMLCanvasElement} canvas - The canvas element that the text is rendered. + var canvas = CanvasPool.create(this); + + // @property {HTMLCanvasElement} context - The context of the canvas element that the text is rendered to. + var context = canvas.getContext('2d'); + + textStyle.syncFont(canvas, context); + + var width = Math.ceil(context.measureText(textStyle.testString).width * textStyle.baselineX); + var baseline = width; + var height = 2 * baseline; + + baseline = baseline * textStyle.baselineY | 0; + + canvas.width = width; + canvas.height = height; + + context.fillStyle = '#f00'; + context.fillRect(0, 0, width, height); + + context.font = textStyle._font; + + context.textBaseline = 'alphabetic'; + context.fillStyle = '#000'; + context.fillText(textStyle.testString, 0, baseline); + + var output = { + ascent: 0, + descent: 0, + fontSize: 0 + }; + + if (!context.getImageData(0, 0, width, height)) + { + output.ascent = baseline; + output.descent = baseline + 6; + output.fontSize = output.ascent + output.descent; + + CanvasPool.remove(canvas); + + return output; + } + + var imagedata = context.getImageData(0, 0, width, height).data; + var pixels = imagedata.length; + var line = width * 4; + var i; + var j; + var idx = 0; + var stop = false; + + // ascent. scan from top to bottom until we find a non red pixel + for (i = 0; i < baseline; i++) + { + for (j = 0; j < line; j += 4) + { + if (imagedata[idx + j] !== 255) + { + stop = true; + break; + } + } + + if (!stop) + { + idx += line; + } + else + { + break; + } + } + + output.ascent = baseline - i; + + idx = pixels - line; + stop = false; + + // descent. scan from bottom to top until we find a non red pixel + for (i = height; i > baseline; i--) + { + for (j = 0; j < line; j += 4) + { + if (imagedata[idx + j] !== 255) + { + stop = true; + break; + } + } + + if (!stop) + { + idx -= line; + } + else + { + break; + } + } + + output.descent = (i - baseline); + output.fontSize = output.ascent + output.descent; + + CanvasPool.remove(canvas); + + return output; +}; + +module.exports = MeasureText; + + +/***/ }), +/* 702 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetAdvancedValue = __webpack_require__(8); +var GetValue = __webpack_require__(5); +var MeasureText = __webpack_require__(701); + +// Key: [ Object Key, Default Value ] + +/** + * A custom function that will be responsible for wrapping the text. + * @callback TextStyleWordWrapCallback + * + * @param {string} text - The string to wrap. + * @param {Phaser.GameObjects.Text} textObject - The Text instance. + * + * @return {(string|string[])} Should return the wrapped lines either as an array of lines or as a string with + * newline characters in place to indicate where breaks should happen. + */ + +var propertyMap = { + fontFamily: [ 'fontFamily', 'Courier' ], + fontSize: [ 'fontSize', '16px' ], + fontStyle: [ 'fontStyle', '' ], + backgroundColor: [ 'backgroundColor', null ], + color: [ 'color', '#fff' ], + stroke: [ 'stroke', '#fff' ], + strokeThickness: [ 'strokeThickness', 0 ], + shadowOffsetX: [ 'shadow.offsetX', 0 ], + shadowOffsetY: [ 'shadow.offsetY', 0 ], + shadowColor: [ 'shadow.color', '#000' ], + shadowBlur: [ 'shadow.blur', 0 ], + shadowStroke: [ 'shadow.stroke', false ], + shadowFill: [ 'shadow.fill', false ], + align: [ 'align', 'left' ], + maxLines: [ 'maxLines', 0 ], + fixedWidth: [ 'fixedWidth', 0 ], + fixedHeight: [ 'fixedHeight', 0 ], + rtl: [ 'rtl', false ], + testString: [ 'testString', '|MÉqgy' ], + baselineX: [ 'baselineX', 1.2 ], + baselineY: [ 'baselineY', 1.4 ], + wordWrapWidth: [ 'wordWrap.width', null ], + wordWrapCallback: [ 'wordWrap.callback', null ], + wordWrapCallbackScope: [ 'wordWrap.callbackScope', null ], + wordWrapUseAdvanced: [ 'wordWrap.useAdvancedWrap', false ] +}; + +/** + * @classdesc + * [description] + * + * @class TextStyle + * @memberOf Phaser.GameObjects.Text + * @constructor + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Text} text - The Text object that this TextStyle is styling. + * @param {object} style - [description] + */ +var TextStyle = new Class({ + + initialize: + + function TextStyle (text, style) + { + /** + * The Text object that this TextStyle is styling. + * + * @name Phaser.GameObjects.Components.TextStyle#parent + * @type {Phaser.GameObjects.Text} + * @since 3.0.0 + */ + this.parent = text; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#fontFamily + * @type {string} + * @default 'Courier' + * @since 3.0.0 + */ + this.fontFamily; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#fontSize + * @type {string} + * @default '16px' + * @since 3.0.0 + */ + this.fontSize; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#fontStyle + * @type {string} + * @since 3.0.0 + */ + this.fontStyle; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#backgroundColor + * @type {string} + * @since 3.0.0 + */ + this.backgroundColor; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#color + * @type {string} + * @default '#fff' + * @since 3.0.0 + */ + this.color; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#stroke + * @type {string} + * @default '#fff' + * @since 3.0.0 + */ + this.stroke; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#strokeThickness + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.strokeThickness; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#shadowOffsetX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.shadowOffsetX; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#shadowOffsetY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.shadowOffsetY; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#shadowColor + * @type {string} + * @default '#000' + * @since 3.0.0 + */ + this.shadowColor; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#shadowBlur + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.shadowBlur; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#shadowStroke + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.shadowStroke; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#shadowFill + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.shadowFill; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#align + * @type {string} + * @default 'left' + * @since 3.0.0 + */ + this.align; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#maxLines + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.maxLines; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#fixedWidth + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.fixedWidth; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#fixedHeight + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.fixedHeight; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#rtl + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.rtl; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#testString + * @type {string} + * @default '|MÉqgy' + * @since 3.0.0 + */ + this.testString; + + /** + * The amount of horizontal padding adding to the width of the text when calculating the font metrics. + * + * @name Phaser.GameObjects.Components.TextStyle#baselineX + * @type {number} + * @default 1.2 + * @since 3.3.0 + */ + this.baselineX; + + /** + * The amount of vertical padding adding to the width of the text when calculating the font metrics. + * + * @name Phaser.GameObjects.Components.TextStyle#baselineY + * @type {number} + * @default 1.4 + * @since 3.3.0 + */ + this.baselineY; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#_font + * @type {string} + * @private + * @since 3.0.0 + */ + this._font; + + // Set to defaults + user style + this.setStyle(style, false); + + var metrics = GetValue(style, 'metrics', false); + + // Provide optional TextMetrics in the style object to avoid the canvas look-up / scanning + // Doing this is reset if you then change the font of this TextStyle after creation + if (metrics) + { + this.metrics = { + ascent: GetValue(metrics, 'ascent', 0), + descent: GetValue(metrics, 'descent', 0), + fontSize: GetValue(metrics, 'fontSize', 0) + }; + } + else + { + this.metrics = MeasureText(this); + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setStyle + * @since 3.0.0 + * + * @param {CSSStyleRule} style - [description] + * @param {boolean} [updateText=true] - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setStyle: function (style, updateText) + { + if (updateText === undefined) { updateText = true; } + + // Avoid type mutation + if (style && style.hasOwnProperty('fontSize') && typeof style.fontSize === 'number') + { + style.fontSize = style.fontSize.toString() + 'px'; + } + + for (var key in propertyMap) + { + if (key === 'wordWrapCallback' || key === 'wordWrapCallbackScope') + { + // Callback & scope should be set without processing the values + this[key] = GetValue(style, propertyMap[key][0], propertyMap[key][1]); + } + else + { + this[key] = GetAdvancedValue(style, propertyMap[key][0], propertyMap[key][1]); + } + } + + // Allow for 'font' override + var font = GetValue(style, 'font', null); + + if (font === null) + { + this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' '); + } + else + { + this._font = font; + } + + // Allow for 'fill' to be used in place of 'color' + var fill = GetValue(style, 'fill', null); + + if (fill !== null) + { + this.color = fill; + } + + if (updateText) + { + return this.update(true); + } + else + { + return this.parent; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#syncFont + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - [description] + * @param {CanvasRenderingContext2D} context - [description] + */ + syncFont: function (canvas, context) + { + context.font = this._font; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#syncStyle + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - [description] + * @param {CanvasRenderingContext2D} context - [description] + */ + syncStyle: function (canvas, context) + { + context.textBaseline = 'alphabetic'; + + context.fillStyle = this.color; + context.strokeStyle = this.stroke; + + context.lineWidth = this.strokeThickness; + context.lineCap = 'round'; + context.lineJoin = 'round'; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#syncShadow + * @since 3.0.0 + * + * @param {CanvasRenderingContext2D} context - [description] + * @param {boolean} enabled - [description] + */ + syncShadow: function (context, enabled) + { + if (enabled) + { + context.shadowOffsetX = this.shadowOffsetX; + context.shadowOffsetY = this.shadowOffsetY; + context.shadowColor = this.shadowColor; + context.shadowBlur = this.shadowBlur; + } + else + { + context.shadowOffsetX = 0; + context.shadowOffsetY = 0; + context.shadowColor = 0; + context.shadowBlur = 0; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#update + * @since 3.0.0 + * + * @param {boolean} recalculateMetrics - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + update: function (recalculateMetrics) + { + if (recalculateMetrics) + { + this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' '); + + this.metrics = MeasureText(this); + } + + return this.parent.updateText(); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setFont + * @since 3.0.0 + * + * @param {(string|object)} font - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFont: function (font) + { + if (typeof font === 'string') + { + this.fontFamily = font; + this.fontSize = ''; + this.fontStyle = ''; + } + else + { + this.fontFamily = GetValue(font, 'fontFamily', 'Courier'); + this.fontSize = GetValue(font, 'fontSize', '16px'); + this.fontStyle = GetValue(font, 'fontStyle', ''); + } + + return this.update(true); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setFontFamily + * @since 3.0.0 + * + * @param {string} family - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFontFamily: function (family) + { + this.fontFamily = family; + + return this.update(true); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setFontStyle + * @since 3.0.0 + * + * @param {string} style - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFontStyle: function (style) + { + this.fontStyle = style; + + return this.update(true); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setFontSize + * @since 3.0.0 + * + * @param {(number|string)} size - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFontSize: function (size) + { + if (typeof size === 'number') + { + size = size.toString() + 'px'; + } + + this.fontSize = size; + + return this.update(true); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setTestString + * @since 3.0.0 + * + * @param {string} string - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setTestString: function (string) + { + this.testString = string; + + return this.update(true); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setFixedSize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFixedSize: function (width, height) + { + this.fixedWidth = width; + this.fixedHeight = height; + + if (width) + { + this.parent.width = width; + } + + if (height) + { + this.parent.height = height; + } + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setBackgroundColor + * @since 3.0.0 + * + * @param {string} color - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setBackgroundColor: function (color) + { + this.backgroundColor = color; + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setFill + * @since 3.0.0 + * + * @param {string} color - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFill: function (color) + { + this.color = color; + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setColor + * @since 3.0.0 + * + * @param {string} color - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setColor: function (color) + { + this.color = color; + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setStroke + * @since 3.0.0 + * + * @param {string} color - [description] + * @param {number} thickness - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setStroke: function (color, thickness) + { + if (color === undefined) + { + // Reset the stroke to zero (disabling it) + this.strokeThickness = 0; + } + else + { + if (thickness === undefined) { thickness = this.strokeThickness; } + + this.stroke = color; + this.strokeThickness = thickness; + } + + return this.update(true); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setShadow + * @since 3.0.0 + * + * @param {number} [x=0] - [description] + * @param {number} [y=0] - [description] + * @param {string} [color='#000'] - [description] + * @param {number} [blur=0] - [description] + * @param {boolean} [shadowStroke=false] - [description] + * @param {boolean} [shadowFill=true] - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadow: function (x, y, color, blur, shadowStroke, shadowFill) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (color === undefined) { color = '#000'; } + if (blur === undefined) { blur = 0; } + if (shadowStroke === undefined) { shadowStroke = false; } + if (shadowFill === undefined) { shadowFill = true; } + + this.shadowOffsetX = x; + this.shadowOffsetY = y; + this.shadowColor = color; + this.shadowBlur = blur; + this.shadowStroke = shadowStroke; + this.shadowFill = shadowFill; + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setShadowOffset + * @since 3.0.0 + * + * @param {number} [x=0] - [description] + * @param {number} [y=0] - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadowOffset: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + + this.shadowOffsetX = x; + this.shadowOffsetY = y; + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setShadowColor + * @since 3.0.0 + * + * @param {string} [color='#000'] - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadowColor: function (color) + { + if (color === undefined) { color = '#000'; } + + this.shadowColor = color; + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setShadowBlur + * @since 3.0.0 + * + * @param {number} [blur=0] - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadowBlur: function (blur) + { + if (blur === undefined) { blur = 0; } + + this.shadowBlur = blur; + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setShadowStroke + * @since 3.0.0 + * + * @param {boolean} enabled - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadowStroke: function (enabled) + { + this.shadowStroke = enabled; + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setShadowFill + * @since 3.0.0 + * + * @param {boolean} enabled - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadowFill: function (enabled) + { + this.shadowFill = enabled; + + return this.update(false); + }, + + /** + * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width. + * + * @method Phaser.GameObjects.Components.TextStyle#setWordWrapWidth + * @since 3.0.0 + * + * @param {number} width - The maximum width of a line in pixels. Set to null to remove wrapping. + * @param {boolean} [useAdvancedWrap=false] - Whether or not to use the advanced wrapping + * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, + * spaces and whitespace are left as is. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setWordWrapWidth: function (width, useAdvancedWrap) + { + if (useAdvancedWrap === undefined) { useAdvancedWrap = false; } + + this.wordWrapWidth = width; + this.wordWrapUseAdvanced = useAdvancedWrap; + + return this.update(false); + }, + + /** + * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback. + * + * @method Phaser.GameObjects.Components.TextStyle#setWordWrapCallback + * @since 3.0.0 + * + * @param {TextStyleWordWrapCallback} callback - A custom function that will be responsible for wrapping the + * text. It will receive two arguments: text (the string to wrap), textObject (this Text + * instance). It should return the wrapped lines either as an array of lines or as a string with + * newline characters in place to indicate where breaks should happen. + * @param {object} [scope=null] - The scope that will be applied when the callback is invoked. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setWordWrapCallback: function (callback, scope) + { + if (scope === undefined) { scope = null; } + + this.wordWrapCallback = callback; + this.wordWrapCallbackScope = scope; + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setAlign + * @since 3.0.0 + * + * @param {string} align - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setAlign: function (align) + { + if (align === undefined) { align = 'left'; } + + this.align = align; + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setMaxLines + * @since 3.0.0 + * + * @param {integer} [max=0] - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setMaxLines: function (max) + { + if (max === undefined) { max = 0; } + + this.maxLines = max; + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#getTextMetrics + * @since 3.0.0 + * + * @return {object} [description] + */ + getTextMetrics: function () + { + var metrics = this.metrics; + + return { + ascent: metrics.ascent, + descent: metrics.descent, + fontSize: metrics.fontSize + }; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#toJSON + * @since 3.0.0 + * + * @return {object} [description] + */ + toJSON: function () + { + var output = {}; + + for (var key in propertyMap) + { + output[key] = this[key]; + } + + output.metrics = this.getTextMetrics(); + + return output; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.parent = undefined; + } + +}); + +module.exports = TextStyle; + + +/***/ }), +/* 703 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Text#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Text} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var TextCanvasRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)) || src.text === '') + { + return; + } + + var ctx = renderer.currentContext; + + // var resolution = src.resolution; + + // Blend Mode + if (renderer.currentBlendMode !== src.blendMode) + { + renderer.currentBlendMode = src.blendMode; + ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; + } + + // Alpha + if (renderer.currentAlpha !== src.alpha) + { + renderer.currentAlpha = src.alpha; + ctx.globalAlpha = src.alpha; + } + + // Smoothing + if (renderer.currentScaleMode !== src.scaleMode) + { + renderer.currentScaleMode = src.scaleMode; + } + + var canvas = src.canvas; + + ctx.save(); + + var tx = src.x - camera.scrollX * src.scrollFactorX; + var ty = src.y - camera.scrollY * src.scrollFactorY; + + if (renderer.config.roundPixels) + { + tx |= 0; + ty |= 0; + } + + ctx.translate(tx, ty); + + ctx.rotate(src.rotation); + + ctx.scale(src.scaleX, src.scaleY); + + ctx.translate(canvas.width * (src.flipX ? 1 : 0), canvas.height * (src.flipY ? 1 : 0)); + + ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); + + ctx.drawImage(canvas, 0, 0, canvas.width, canvas.height, -src.displayOriginX, -src.displayOriginY, canvas.width, canvas.height); + + ctx.restore(); +}; + +module.exports = TextCanvasRenderer; + + +/***/ }), +/* 704 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Text#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Text} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var TextWebGLRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)) || src.text === '') + { + return; + } + + if (src.dirty) + { + src.canvasTexture = renderer.canvasToTexture(src.canvas, src.canvasTexture, true, src.scaleMode); + src.dirty = false; + } + + this.pipeline.batchText(this, camera); +}; + +module.exports = TextWebGLRenderer; + + +/***/ }), +/* 705 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); + +if (true) +{ + renderWebGL = __webpack_require__(704); +} + +if (true) +{ + renderCanvas = __webpack_require__(703); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 706 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns an object containing dimensions of the Text object. + * + * @function Phaser.GameObjects.Text.GetTextSize + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Text} text - The Text object to get the size from. + * @param {number} size - [description] + * @param {array} lines - [description] + * + * @return {object} An object containing dimensions of the Text object. + */ +var GetTextSize = function (text, size, lines) +{ + var canvas = text.canvas; + var context = text.context; + var style = text.style; + + var lineWidths = []; + var maxLineWidth = 0; + var drawnLines = lines.length; + + if (style.maxLines > 0 && style.maxLines < lines.length) + { + drawnLines = style.maxLines; + } + + style.syncFont(canvas, context); + + // Text Width + + for (var i = 0; i < drawnLines; i++) + { + var lineWidth = style.strokeThickness; + + lineWidth += context.measureText(lines[i]).width; + + // Adjust for wrapped text + if (style.wordWrap) + { + lineWidth -= context.measureText(' ').width; + } + + lineWidths[i] = Math.ceil(lineWidth); + maxLineWidth = Math.max(maxLineWidth, lineWidths[i]); + } + + // Text Height + + var lineHeight = size.fontSize + style.strokeThickness; + var height = lineHeight * drawnLines; + var lineSpacing = text._lineSpacing || 0; + + if (lineSpacing < 0 && Math.abs(lineSpacing) > lineHeight) + { + lineSpacing = -lineHeight; + } + + // Adjust for line spacing + if (lineSpacing !== 0) + { + height += (lineSpacing > 0) ? lineSpacing * lines.length : lineSpacing * (lines.length - 1); + } + + return { + width: maxLineWidth, + height: height, + lines: drawnLines, + lineWidths: lineWidths, + lineSpacing: lineSpacing, + lineHeight: lineHeight + }; +}; + +module.exports = GetTextSize; + + +/***/ }), +/* 707 */ +/***/ (function(module, exports) { + +var RenderTextureWebGL = { + + fill: function (rgb) + { + var ur = ((rgb >> 16)|0) & 0xff; + var ug = ((rgb >> 8)|0) & 0xff; + var ub = (rgb|0) & 0xff; + + this.renderer.setFramebuffer(this.framebuffer); + var gl = this.gl; + gl.clearColor(ur / 255.0, ug / 255.0, ub / 255.0, 1); + gl.clear(gl.COLOR_BUFFER_BIT); + this.renderer.setFramebuffer(null); + return this; + }, + + clear: function () + { + this.renderer.setFramebuffer(this.framebuffer); + var gl = this.gl; + gl.clearColor(0, 0, 0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); + this.renderer.setFramebuffer(null); + return this; + }, + + draw: function (texture, frame, x, y) + { + var glTexture = texture.source[frame.sourceIndex].glTexture; + var tint = (this.globalTint >> 16) + (this.globalTint & 0xff00) + ((this.globalTint & 0xff) << 16); + this.renderer.setFramebuffer(this.framebuffer); + this.renderer.pipelines.TextureTintPipeline.drawTexture(glTexture, x, y, tint, this.globalAlpha, frame.cutX, frame.cutY, frame.cutWidth, frame.cutHeight, this.currentMatrix); + this.renderer.setFramebuffer(null); + return this; + } + +}; + +module.exports = RenderTextureWebGL; + + +/***/ }), +/* 708 */ +/***/ (function(module, exports) { + +var RenderTextureCanvas = { + + fill: function (rgb) + { + var ur = ((rgb >> 16)|0) & 0xff; + var ug = ((rgb >> 8)|0) & 0xff; + var ub = (rgb|0) & 0xff; + + this.context.fillStyle = 'rgb(' + ur + ',' + ug + ',' + ub + ')'; + this.context.fillRect(0, 0, this.canvas.width, this.canvas.height); + return this; + }, + + clear: function () + { + this.context.save(); + this.context.setTransform(1, 0, 0, 1, 0, 0); + this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); + this.context.restore(); + return this; + }, + + draw: function (texture, frame, x, y) + { + var matrix = this.currentMatrix; + + this.context.globalAlpha = this.globalAlpha; + this.context.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + this.context.drawImage(texture.source[frame.sourceIndex].image, frame.cutX, frame.cutY, frame.cutWidth, frame.cutHeight, x, y, frame.cutWidth, frame.cutWidth); + + return this; + } + +}; + +module.exports = RenderTextureCanvas; + + +/***/ }), +/* 709 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.RenderTexture#renderCanvas + * @since 3.2.0 + * @private + * + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.RenderTexture} renderTexture - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var RenderTextureCanvasRenderer = function (renderer, renderTexture, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== renderTexture.renderFlags || (renderTexture.cameraFilter > 0 && (renderTexture.cameraFilter & camera._id))) + { + return; + } + + var ctx = renderer.currentContext; + + if (renderer.currentBlendMode !== renderTexture.blendMode) + { + renderer.currentBlendMode = renderTexture.blendMode; + ctx.globalCompositeOperation = renderer.blendModes[renderTexture.blendMode]; + } + + if (renderer.currentAlpha !== renderTexture.alpha) + { + renderer.currentAlpha = renderTexture.alpha; + ctx.globalAlpha = renderTexture.alpha; + } + + if (renderer.currentScaleMode !== renderTexture.scaleMode) + { + renderer.currentScaleMode = renderTexture.scaleMode; + } + + var dx = 0; + var dy = 0; + + var fx = 1; + var fy = 1; + + if (renderTexture.flipX) + { + fx = -1; + dx -= renderTexture.canvas.width - renderTexture.displayOriginX; + } + else + { + dx -= renderTexture.displayOriginX; + } + + if (renderTexture.flipY) + { + fy = -1; + dy -= renderTexture.canvas.height - renderTexture.displayOriginY; + } + else + { + dy -= renderTexture.displayOriginY; + } + + ctx.save(); + ctx.translate(renderTexture.x - camera.scrollX * renderTexture.scrollFactorX, renderTexture.y - camera.scrollY * renderTexture.scrollFactorY); + ctx.rotate(renderTexture.rotation); + ctx.scale(renderTexture.scaleX, renderTexture.scaleY); + ctx.scale(fx, fy); + ctx.drawImage(renderTexture.canvas, dx, dy); + ctx.restore(); +}; + +module.exports = RenderTextureCanvasRenderer; + + +/***/ }), +/* 710 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.RenderTexture#renderWebgl + * @since 3.2.0 + * @private + * + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.RenderTexture} renderTexture - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var RenderTextureWebGLRenderer = function (renderer, renderTexture, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== renderTexture.renderFlags || (renderTexture.cameraFilter > 0 && (renderTexture.cameraFilter & camera._id))) + { + return; + } + + this.pipeline.batchTexture( + renderTexture, + renderTexture.texture, + renderTexture.texture.width, renderTexture.texture.height, + renderTexture.x, renderTexture.y, + renderTexture.width, renderTexture.height, + renderTexture.scaleX, renderTexture.scaleY, + renderTexture.rotation, + renderTexture.flipX, renderTexture.flipY, + renderTexture.scrollFactorX, renderTexture.scrollFactorY, + renderTexture.displayOriginX, renderTexture.displayOriginY, + 0, 0, renderTexture.texture.width, renderTexture.texture.height, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0, 0, + camera + ); +}; + +module.exports = RenderTextureWebGLRenderer; + + +/***/ }), +/* 711 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); + +if (true) +{ + renderWebGL = __webpack_require__(710); +} + +if (true) +{ + renderCanvas = __webpack_require__(709); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 712 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Particles.EmitterManager#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Particles} emitterManager - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpolationPercentage, camera) +{ + var emitters = emitterManager.emitters.list; + + if (emitters.length === 0 || GameObject.RENDER_MASK !== emitterManager.renderFlags || (emitterManager.cameraFilter > 0 && (emitterManager.cameraFilter & camera._id))) + { + return; + } + + for (var i = 0; i < emitters.length; i++) + { + var emitter = emitters[i]; + + var particles = emitter.alive; + var length = particles.length; + + if (!emitter.visible || length === 0) + { + continue; + } + + var ctx = renderer.currentContext; + + var lastAlpha = ctx.globalAlpha; + var cameraScrollX = camera.scrollX * emitter.scrollFactorX; + var cameraScrollY = camera.scrollY * emitter.scrollFactorY; + + if (renderer.currentBlendMode !== emitter.blendMode) + { + renderer.currentBlendMode = emitter.blendMode; + ctx.globalCompositeOperation = renderer.blendModes[emitter.blendMode]; + } + + var roundPixels = renderer.config.roundPixels; + + for (var index = 0; index < length; ++index) + { + var particle = particles[index]; + + var alpha = ((particle.color >> 24) & 0xFF) / 255.0; + + if (alpha <= 0) + { + continue; + } + + var frame = particle.frame; + var width = frame.width; + var height = frame.height; + var ox = width * 0.5; + var oy = height * 0.5; + var cd = frame.canvasData; + + var x = -ox; + var y = -oy; + + var tx = particle.x - cameraScrollX * particle.scrollFactorX; + var ty = particle.y - cameraScrollY * particle.scrollFactorY; + + if (roundPixels) + { + tx |= 0; + ty |= 0; + } + + ctx.globalAlpha = alpha; + + ctx.save(); + + ctx.translate(tx, ty); + + ctx.rotate(particle.rotation); + + ctx.scale(particle.scaleX, particle.scaleY); + + ctx.drawImage(frame.source.image, cd.sx, cd.sy, cd.sWidth, cd.sHeight, x, y, cd.dWidth, cd.dHeight); + + ctx.restore(); + } + + ctx.globalAlpha = lastAlpha; + } +}; + +module.exports = ParticleManagerCanvasRenderer; + + +/***/ }), +/* 713 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Particles.EmitterManager#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Particles} emitterManager - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var ParticleManagerWebGLRenderer = function (renderer, emitterManager, interpolationPercentage, camera) +{ + var emitters = emitterManager.emitters; + + if (emitters.length === 0 || GameObject.RENDER_MASK !== emitterManager.renderFlags || (emitterManager.cameraFilter > 0 && (emitterManager.cameraFilter & camera._id))) + { + return; + } + + this.pipeline.drawEmitterManager(emitterManager, camera); +}; + +module.exports = ParticleManagerWebGLRenderer; + + +/***/ }), +/* 714 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); + +if (true) +{ + renderWebGL = __webpack_require__(713); +} + +if (true) +{ + renderCanvas = __webpack_require__(712); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 715 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Vector2 = __webpack_require__(6); + +/** + * @classdesc + * [description] + * + * @class RandomZone + * @memberOf Phaser.GameObjects.Particles.Zones + * @constructor + * @since 3.0.0 + * + * @param {object} source - [description] + */ +var RandomZone = new Class({ + + initialize: + + function RandomZone (source) + { + /** + * [description] + * + * @name Phaser.GameObjects.Particles.Zones.RandomZone#source + * @type {object} + * @since 3.0.0 + */ + this.source = source; + + /** + * Internal calculation vector. + * + * @name Phaser.GameObjects.Particles.Zones.RandomZone#_tempVec + * @type {Phaser.Math.Vector2} + * @private + * @since 3.0.0 + */ + this._tempVec = new Vector2(); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.Zones.RandomZone#getPoint + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - [description] + */ + getPoint: function (particle) + { + var vec = this._tempVec; + + this.source.getRandomPoint(vec); + + particle.x = vec.x; + particle.y = vec.y; + } + +}); + +module.exports = RandomZone; + + +/***/ }), +/* 716 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var DegToRad = __webpack_require__(42); +var DistanceBetween = __webpack_require__(48); /** * @classdesc @@ -97336,5658 +99710,9 @@ var Particle = new Class({ module.exports = Particle; -/***/ }), -/* 612 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * [description] - * - * @class RandomZone - * @memberOf Phaser.GameObjects.Particles.Zones - * @constructor - * @since 3.0.0 - * - * @param {object} source - [description] - */ -var RandomZone = new Class({ - - initialize: - - function RandomZone (source) - { - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.RandomZone#source - * @type {object} - * @since 3.0.0 - */ - this.source = source; - - /** - * Internal calculation vector. - * - * @name Phaser.GameObjects.Particles.Zones.RandomZone#_tempVec - * @type {Phaser.Math.Vector2} - * @private - * @since 3.0.0 - */ - this._tempVec = new Vector2(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.Zones.RandomZone#getPoint - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - */ - getPoint: function (particle) - { - var vec = this._tempVec; - - this.source.getRandomPoint(vec); - - particle.x = vec.x; - particle.y = vec.y; - } - -}); - -module.exports = RandomZone; - - -/***/ }), -/* 613 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(614); -} - -if (true) -{ - renderCanvas = __webpack_require__(615); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 614 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Particles.EmitterManager#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Particles} emitterManager - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var ParticleManagerWebGLRenderer = function (renderer, emitterManager, interpolationPercentage, camera) -{ - var emitters = emitterManager.emitters; - - if (emitters.length === 0 || GameObject.RENDER_MASK !== emitterManager.renderFlags || (emitterManager.cameraFilter > 0 && (emitterManager.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.drawEmitterManager(emitterManager, camera); -}; - -module.exports = ParticleManagerWebGLRenderer; - - -/***/ }), -/* 615 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Particles.EmitterManager#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Particles} emitterManager - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpolationPercentage, camera) -{ - var emitters = emitterManager.emitters.list; - - if (emitters.length === 0 || GameObject.RENDER_MASK !== emitterManager.renderFlags || (emitterManager.cameraFilter > 0 && (emitterManager.cameraFilter & camera._id))) - { - return; - } - - for (var i = 0; i < emitters.length; i++) - { - var emitter = emitters[i]; - - var particles = emitter.alive; - var length = particles.length; - - if (!emitter.visible || length === 0) - { - continue; - } - - var ctx = renderer.currentContext; - - var lastAlpha = ctx.globalAlpha; - var cameraScrollX = camera.scrollX * emitter.scrollFactorX; - var cameraScrollY = camera.scrollY * emitter.scrollFactorY; - - if (renderer.currentBlendMode !== emitter.blendMode) - { - renderer.currentBlendMode = emitter.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[emitter.blendMode]; - } - - var roundPixels = renderer.config.roundPixels; - - for (var index = 0; index < length; ++index) - { - var particle = particles[index]; - - var alpha = ((particle.color >> 24) & 0xFF) / 255.0; - - if (alpha <= 0) - { - continue; - } - - var frame = particle.frame; - var width = frame.width; - var height = frame.height; - var ox = width * 0.5; - var oy = height * 0.5; - var cd = frame.canvasData; - - var x = -ox; - var y = -oy; - - var tx = particle.x - cameraScrollX * particle.scrollFactorX; - var ty = particle.y - cameraScrollY * particle.scrollFactorY; - - if (roundPixels) - { - tx |= 0; - ty |= 0; - } - - ctx.globalAlpha = alpha; - - ctx.save(); - - ctx.translate(tx, ty); - - ctx.rotate(particle.rotation); - - ctx.scale(particle.scaleX, particle.scaleY); - - ctx.drawImage(frame.source.image, cd.sx, cd.sy, cd.sWidth, cd.sHeight, x, y, cd.dWidth, cd.dHeight); - - ctx.restore(); - } - - ctx.globalAlpha = lastAlpha; - } -}; - -module.exports = ParticleManagerCanvasRenderer; - - -/***/ }), -/* 616 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(617); -} - -if (true) -{ - renderCanvas = __webpack_require__(618); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 617 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.RenderTexture#renderWebgl - * @since 3.2.0 - * @private - * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.RenderTexture} renderTexture - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var RenderTextureWebGLRenderer = function (renderer, renderTexture, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== renderTexture.renderFlags || (renderTexture.cameraFilter > 0 && (renderTexture.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.batchTexture( - renderTexture, - renderTexture.texture, - renderTexture.texture.width, renderTexture.texture.height, - renderTexture.x, renderTexture.y, - renderTexture.width, renderTexture.height, - renderTexture.scaleX, renderTexture.scaleY, - renderTexture.rotation, - renderTexture.flipX, renderTexture.flipY, - renderTexture.scrollFactorX, renderTexture.scrollFactorY, - renderTexture.displayOriginX, renderTexture.displayOriginY, - 0, 0, renderTexture.texture.width, renderTexture.texture.height, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0, 0, - camera - ); -}; - -module.exports = RenderTextureWebGLRenderer; - - -/***/ }), -/* 618 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.RenderTexture#renderCanvas - * @since 3.2.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.RenderTexture} renderTexture - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var RenderTextureCanvasRenderer = function (renderer, renderTexture, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== renderTexture.renderFlags || (renderTexture.cameraFilter > 0 && (renderTexture.cameraFilter & camera._id))) - { - return; - } - - var ctx = renderer.currentContext; - - if (renderer.currentBlendMode !== renderTexture.blendMode) - { - renderer.currentBlendMode = renderTexture.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[renderTexture.blendMode]; - } - - if (renderer.currentAlpha !== renderTexture.alpha) - { - renderer.currentAlpha = renderTexture.alpha; - ctx.globalAlpha = renderTexture.alpha; - } - - if (renderer.currentScaleMode !== renderTexture.scaleMode) - { - renderer.currentScaleMode = renderTexture.scaleMode; - } - - var dx = 0; - var dy = 0; - - var fx = 1; - var fy = 1; - - if (renderTexture.flipX) - { - fx = -1; - dx -= renderTexture.canvas.width - renderTexture.displayOriginX; - } - else - { - dx -= renderTexture.displayOriginX; - } - - if (renderTexture.flipY) - { - fy = -1; - dy -= renderTexture.canvas.height - renderTexture.displayOriginY; - } - else - { - dy -= renderTexture.displayOriginY; - } - - ctx.save(); - ctx.translate(renderTexture.x - camera.scrollX * renderTexture.scrollFactorX, renderTexture.y - camera.scrollY * renderTexture.scrollFactorY); - ctx.rotate(renderTexture.rotation); - ctx.scale(renderTexture.scaleX, renderTexture.scaleY); - ctx.scale(fx, fy); - ctx.drawImage(renderTexture.canvas, dx, dy); - ctx.restore(); -}; - -module.exports = RenderTextureCanvasRenderer; - - -/***/ }), -/* 619 */ -/***/ (function(module, exports) { - -var RenderTextureCanvas = { - - fill: function (rgb) - { - var ur = ((rgb >> 16)|0) & 0xff; - var ug = ((rgb >> 8)|0) & 0xff; - var ub = (rgb|0) & 0xff; - - this.context.fillStyle = 'rgb(' + ur + ',' + ug + ',' + ub + ')'; - this.context.fillRect(0, 0, this.canvas.width, this.canvas.height); - return this; - }, - - clear: function () - { - this.context.save(); - this.context.setTransform(1, 0, 0, 1, 0, 0); - this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); - this.context.restore(); - return this; - }, - - draw: function (texture, frame, x, y) - { - var matrix = this.currentMatrix; - - this.context.globalAlpha = this.globalAlpha; - this.context.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - this.context.drawImage(texture.source[frame.sourceIndex].image, frame.cutX, frame.cutY, frame.cutWidth, frame.cutHeight, x, y, frame.cutWidth, frame.cutWidth); - - return this; - } - -}; - -module.exports = RenderTextureCanvas; - - -/***/ }), -/* 620 */ -/***/ (function(module, exports) { - -var RenderTextureWebGL = { - - fill: function (rgb) - { - var ur = ((rgb >> 16)|0) & 0xff; - var ug = ((rgb >> 8)|0) & 0xff; - var ub = (rgb|0) & 0xff; - - this.renderer.setFramebuffer(this.framebuffer); - var gl = this.gl; - gl.clearColor(ur / 255.0, ug / 255.0, ub / 255.0, 1); - gl.clear(gl.COLOR_BUFFER_BIT); - this.renderer.setFramebuffer(null); - return this; - }, - - clear: function () - { - this.renderer.setFramebuffer(this.framebuffer); - var gl = this.gl; - gl.clearColor(0, 0, 0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); - this.renderer.setFramebuffer(null); - return this; - }, - - draw: function (texture, frame, x, y) - { - var glTexture = texture.source[frame.sourceIndex].glTexture; - var tint = (this.globalTint >> 16) + (this.globalTint & 0xff00) + ((this.globalTint & 0xff) << 16); - this.renderer.setFramebuffer(this.framebuffer); - this.renderer.pipelines.TextureTintPipeline.drawTexture(glTexture, x, y, tint, this.globalAlpha, frame.cutX, frame.cutY, frame.cutWidth, frame.cutHeight, this.currentMatrix); - this.renderer.setFramebuffer(null); - return this; - } - -}; - -module.exports = RenderTextureWebGL; - - -/***/ }), -/* 621 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns an object containing dimensions of the Text object. - */ - -var GetTextSize = function (text, size, lines) -{ - var canvas = text.canvas; - var context = text.context; - var style = text.style; - - var lineWidths = []; - var maxLineWidth = 0; - var drawnLines = lines.length; - - if (style.maxLines > 0 && style.maxLines < lines.length) - { - drawnLines = style.maxLines; - } - - style.syncFont(canvas, context); - - // Text Width - - for (var i = 0; i < drawnLines; i++) - { - var lineWidth = style.strokeThickness; - - lineWidth += context.measureText(lines[i]).width; - - // Adjust for wrapped text - if (style.wordWrap) - { - lineWidth -= context.measureText(' ').width; - } - - lineWidths[i] = Math.ceil(lineWidth); - maxLineWidth = Math.max(maxLineWidth, lineWidths[i]); - } - - // Text Height - - var lineHeight = size.fontSize + style.strokeThickness; - var height = lineHeight * drawnLines; - var lineSpacing = text._lineSpacing || 0; - - if (lineSpacing < 0 && Math.abs(lineSpacing) > lineHeight) - { - lineSpacing = -lineHeight; - } - - // Adjust for line spacing - if (lineSpacing !== 0) - { - height += (lineSpacing > 0) ? lineSpacing * lines.length : lineSpacing * (lines.length - 1); - } - - return { - width: maxLineWidth, - height: height, - lines: drawnLines, - lineWidths: lineWidths, - lineSpacing: lineSpacing, - lineHeight: lineHeight - }; -}; - -module.exports = GetTextSize; - - -/***/ }), -/* 622 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(623); -} - -if (true) -{ - renderCanvas = __webpack_require__(624); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 623 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Text#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Text} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var TextWebGLRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)) || src.text === '') - { - return; - } - - if (src.dirty) - { - src.canvasTexture = renderer.canvasToTexture(src.canvas, src.canvasTexture, true, src.scaleMode); - src.dirty = false; - } - - this.pipeline.batchText(this, camera); -}; - -module.exports = TextWebGLRenderer; - - -/***/ }), -/* 624 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Text#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Text} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var TextCanvasRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)) || src.text === '') - { - return; - } - - var ctx = renderer.currentContext; - - // var resolution = src.resolution; - - // Blend Mode - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - var canvas = src.canvas; - - ctx.save(); - - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - - if (renderer.config.roundPixels) - { - tx |= 0; - ty |= 0; - } - - ctx.translate(tx, ty); - - ctx.rotate(src.rotation); - - ctx.scale(src.scaleX, src.scaleY); - - ctx.translate(canvas.width * (src.flipX ? 1 : 0), canvas.height * (src.flipY ? 1 : 0)); - - ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); - - ctx.drawImage(canvas, 0, 0, canvas.width, canvas.height, -src.displayOriginX, -src.displayOriginY, canvas.width, canvas.height); - - ctx.restore(); -}; - -module.exports = TextCanvasRenderer; - - -/***/ }), -/* 625 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GetAdvancedValue = __webpack_require__(10); -var GetValue = __webpack_require__(4); -var MeasureText = __webpack_require__(626); - -// Key: [ Object Key, Default Value ] - -var propertyMap = { - fontFamily: [ 'fontFamily', 'Courier' ], - fontSize: [ 'fontSize', '16px' ], - fontStyle: [ 'fontStyle', '' ], - backgroundColor: [ 'backgroundColor', null ], - color: [ 'color', '#fff' ], - stroke: [ 'stroke', '#fff' ], - strokeThickness: [ 'strokeThickness', 0 ], - shadowOffsetX: [ 'shadow.offsetX', 0 ], - shadowOffsetY: [ 'shadow.offsetY', 0 ], - shadowColor: [ 'shadow.color', '#000' ], - shadowBlur: [ 'shadow.blur', 0 ], - shadowStroke: [ 'shadow.stroke', false ], - shadowFill: [ 'shadow.fill', false ], - align: [ 'align', 'left' ], - maxLines: [ 'maxLines', 0 ], - fixedWidth: [ 'fixedWidth', 0 ], - fixedHeight: [ 'fixedHeight', 0 ], - rtl: [ 'rtl', false ], - testString: [ 'testString', '|MÉqgy' ], - wordWrapWidth: [ 'wordWrap.width', null ], - wordWrapCallback: [ 'wordWrap.callback', null ], - wordWrapCallbackScope: [ 'wordWrap.callbackScope', null ], - wordWrapUseAdvanced: [ 'wordWrap.useAdvancedWrap', false ] -}; - -/** - * @classdesc - * [description] - * - * @class TextStyle - * @memberOf Phaser.GameObjects.Components - * @constructor - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Text} text - The Text object that this TextStyle is styling. - * @param {object} style - [description] - */ -var TextStyle = new Class({ - - initialize: - - function TextStyle (text, style) - { - /** - * The Text object that this TextStyle is styling. - * - * @name Phaser.GameObjects.Components.TextStyle#parent - * @type {Phaser.GameObjects.Text} - * @since 3.0.0 - */ - this.parent = text; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#fontFamily - * @type {string} - * @default 'Courier' - * @since 3.0.0 - */ - this.fontFamily; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#fontSize - * @type {string} - * @default '16px' - * @since 3.0.0 - */ - this.fontSize; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#fontStyle - * @type {string} - * @since 3.0.0 - */ - this.fontStyle; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#backgroundColor - * @type {string} - * @since 3.0.0 - */ - this.backgroundColor; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#color - * @type {string} - * @default '#fff' - * @since 3.0.0 - */ - this.color; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#stroke - * @type {string} - * @default '#fff' - * @since 3.0.0 - */ - this.stroke; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#strokeThickness - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.strokeThickness; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#shadowOffsetX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.shadowOffsetX; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#shadowOffsetY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.shadowOffsetY; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#shadowColor - * @type {string} - * @default '#000' - * @since 3.0.0 - */ - this.shadowColor; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#shadowBlur - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.shadowBlur; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#shadowStroke - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.shadowStroke; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#shadowFill - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.shadowFill; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#align - * @type {string} - * @default 'left' - * @since 3.0.0 - */ - this.align; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#maxLines - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.maxLines; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#fixedWidth - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.fixedWidth; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#fixedHeight - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.fixedHeight; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#rtl - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.rtl; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#testString - * @type {string} - * @default '|MÉqgy' - * @since 3.0.0 - */ - this.testString; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#_font - * @type {string} - * @private - * @since 3.0.0 - */ - this._font; - - // Set to defaults + user style - this.setStyle(style, false); - - var metrics = GetValue(style, 'metrics', false); - - // Provide optional TextMetrics in the style object to avoid the canvas look-up / scanning - // Doing this is reset if you then change the font of this TextStyle after creation - if (metrics) - { - this.metrics = { - ascent: GetValue(metrics, 'ascent', 0), - descent: GetValue(metrics, 'descent', 0), - fontSize: GetValue(metrics, 'fontSize', 0) - }; - } - else - { - this.metrics = MeasureText(this); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setStyle - * @since 3.0.0 - * - * @param {[type]} style - [description] - * @param {boolean} [updateText=true] - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setStyle: function (style, updateText) - { - if (updateText === undefined) { updateText = true; } - - // Avoid type mutation - if (style && style.hasOwnProperty('fontSize') && typeof style.fontSize === 'number') - { - style.fontSize = style.fontSize.toString() + 'px'; - } - - for (var key in propertyMap) - { - if (key === 'wordWrapCallback' || key === 'wordWrapCallbackScope') - { - // Callback & scope should be set without processing the values - this[key] = GetValue(style, propertyMap[key][0], propertyMap[key][1]); - } - else - { - this[key] = GetAdvancedValue(style, propertyMap[key][0], propertyMap[key][1]); - } - } - - // Allow for 'font' override - var font = GetValue(style, 'font', null); - - if (font === null) - { - this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' '); - } - else - { - this._font = font; - } - - // Allow for 'fill' to be used in place of 'color' - var fill = GetValue(style, 'fill', null); - - if (fill !== null) - { - this.color = fill; - } - - if (updateText) - { - return this.update(true); - } - else - { - return this.parent; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#syncFont - * @since 3.0.0 - * - * @param {[type]} canvas - [description] - * @param {[type]} context - [description] - */ - syncFont: function (canvas, context) - { - context.font = this._font; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#syncStyle - * @since 3.0.0 - * - * @param {[type]} canvas - [description] - * @param {[type]} context - [description] - */ - syncStyle: function (canvas, context) - { - context.textBaseline = 'alphabetic'; - - context.fillStyle = this.color; - context.strokeStyle = this.stroke; - - context.lineWidth = this.strokeThickness; - context.lineCap = 'round'; - context.lineJoin = 'round'; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#syncShadow - * @since 3.0.0 - * - * @param {[type]} context - [description] - * @param {[type]} enabled - [description] - */ - syncShadow: function (context, enabled) - { - if (enabled) - { - context.shadowOffsetX = this.shadowOffsetX; - context.shadowOffsetY = this.shadowOffsetY; - context.shadowColor = this.shadowColor; - context.shadowBlur = this.shadowBlur; - } - else - { - context.shadowOffsetX = 0; - context.shadowOffsetY = 0; - context.shadowColor = 0; - context.shadowBlur = 0; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#update - * @since 3.0.0 - * - * @param {boolean} recalculateMetrics - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - update: function (recalculateMetrics) - { - if (recalculateMetrics) - { - this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' '); - - this.metrics = MeasureText(this); - } - - return this.parent.updateText(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setFont - * @since 3.0.0 - * - * @param {string|object} font - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setFont: function (font) - { - if (typeof font === 'string') - { - this.fontFamily = font; - this.fontSize = ''; - this.fontStyle = ''; - } - else - { - this.fontFamily = GetValue(font, 'fontFamily', 'Courier'); - this.fontSize = GetValue(font, 'fontSize', '16px'); - this.fontStyle = GetValue(font, 'fontStyle', ''); - } - - return this.update(true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setFontFamily - * @since 3.0.0 - * - * @param {[type]} family - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setFontFamily: function (family) - { - this.fontFamily = family; - - return this.update(true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setFontStyle - * @since 3.0.0 - * - * @param {[type]} style - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setFontStyle: function (style) - { - this.fontStyle = style; - - return this.update(true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setFontSize - * @since 3.0.0 - * - * @param {[type]} size - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setFontSize: function (size) - { - if (typeof size === 'number') - { - size = size.toString() + 'px'; - } - - this.fontSize = size; - - return this.update(true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setTestString - * @since 3.0.0 - * - * @param {[type]} string - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setTestString: function (string) - { - this.testString = string; - - return this.update(true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setFixedSize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setFixedSize: function (width, height) - { - this.fixedWidth = width; - this.fixedHeight = height; - - if (width) - { - this.parent.width = width; - } - - if (height) - { - this.parent.height = height; - } - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setBackgroundColor - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setBackgroundColor: function (color) - { - this.backgroundColor = color; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setFill - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setFill: function (color) - { - this.color = color; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setColor - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setColor: function (color) - { - this.color = color; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setStroke - * @since 3.0.0 - * - * @param {string} color - [description] - * @param {number} thickness - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setStroke: function (color, thickness) - { - if (color === undefined) - { - // Reset the stroke to zero (disabling it) - this.strokeThickness = 0; - } - else - { - if (thickness === undefined) { thickness = this.strokeThickness; } - - this.stroke = color; - this.strokeThickness = thickness; - } - - return this.update(true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setShadow - * @since 3.0.0 - * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] - * @param {string} [color='#000'] - [description] - * @param {number} [blur=0] - [description] - * @param {boolean} [shadowStroke=false] - [description] - * @param {boolean} [shadowFill=true] - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setShadow: function (x, y, color, blur, shadowStroke, shadowFill) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (color === undefined) { color = '#000'; } - if (blur === undefined) { blur = 0; } - if (shadowStroke === undefined) { shadowStroke = false; } - if (shadowFill === undefined) { shadowFill = true; } - - this.shadowOffsetX = x; - this.shadowOffsetY = y; - this.shadowColor = color; - this.shadowBlur = blur; - this.shadowStroke = shadowStroke; - this.shadowFill = shadowFill; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setShadowOffset - * @since 3.0.0 - * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setShadowOffset: function (x, y) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = x; } - - this.shadowOffsetX = x; - this.shadowOffsetY = y; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setShadowColor - * @since 3.0.0 - * - * @param {string} [color='#000'] - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setShadowColor: function (color) - { - if (color === undefined) { color = '#000'; } - - this.shadowColor = color; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setShadowBlur - * @since 3.0.0 - * - * @param {number} [blur=0] - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setShadowBlur: function (blur) - { - if (blur === undefined) { blur = 0; } - - this.shadowBlur = blur; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setShadowStroke - * @since 3.0.0 - * - * @param {boolean} enabled - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setShadowStroke: function (enabled) - { - this.shadowStroke = enabled; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setShadowFill - * @since 3.0.0 - * - * @param {boolean} enabled - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setShadowFill: function (enabled) - { - this.shadowFill = enabled; - - return this.update(false); - }, - - /** - * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width. - * - * @method Phaser.GameObjects.Components.TextStyle#setWordWrapWidth - * @since 3.0.0 - * - * @param {number} width - The maximum width of a line in pixels. Set to null to remove wrapping. - * @param {boolean} [useAdvancedWrap=false] - Whether or not to use the advanced wrapping - * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, - * spaces and whitespace are left as is. - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setWordWrapWidth: function (width, useAdvancedWrap) - { - if (useAdvancedWrap === undefined) { useAdvancedWrap = false; } - - this.wordWrapWidth = width; - this.wordWrapUseAdvanced = useAdvancedWrap; - - return this.update(false); - }, - - /** - * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback. - * - * @method Phaser.GameObjects.Components.TextStyle#setWordWrapCallback - * @since 3.0.0 - * - * @param {function} callback - A custom function that will be responsible for wrapping the - * text. It will receive two arguments: text (the string to wrap), textObject (this Text - * instance). It should return the wrapped lines either as an array of lines or as a string with - * newline characters in place to indicate where breaks should happen. - * @param {object} [scope=null] - The scope that will be applied when the callback is invoked. - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setWordWrapCallback: function (callback, scope) - { - if (scope === undefined) { scope = null; } - - this.wordWrapCallback = callback; - this.wordWrapCallbackScope = scope; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setAlign - * @since 3.0.0 - * - * @param {string} align - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setAlign: function (align) - { - if (align === undefined) { align = 'left'; } - - this.align = align; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setMaxLines - * @since 3.0.0 - * - * @param {integer} [max=0] - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setMaxLines: function (max) - { - if (max === undefined) { max = 0; } - - this.maxLines = max; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#getTextMetrics - * @since 3.0.0 - * - * @return {object} [description] - */ - getTextMetrics: function () - { - var metrics = this.metrics; - - return { - ascent: metrics.ascent, - descent: metrics.descent, - fontSize: metrics.fontSize - }; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - var output = {}; - - for (var key in propertyMap) - { - output[key] = this[key]; - } - - output.metrics = this.getTextMetrics(); - - return output; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.parent = undefined; - } - -}); - -module.exports = TextStyle; - - -/***/ }), -/* 626 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CanvasPool = __webpack_require__(21); - -/** - * Calculates the ascent, descent and fontSize of a given font style. - */ - -var MeasureText = function (textStyle) -{ - // @property {HTMLCanvasElement} canvas - The canvas element that the text is rendered. - var canvas = CanvasPool.create(this); - - // @property {HTMLCanvasElement} context - The context of the canvas element that the text is rendered to. - var context = canvas.getContext('2d'); - - textStyle.syncFont(canvas, context); - - var width = Math.ceil(context.measureText(textStyle.testString).width * 1.2); - var baseline = width; - var height = 2 * baseline; - - baseline = baseline * 1.4 | 0; - - canvas.width = width; - canvas.height = height; - - context.fillStyle = '#f00'; - context.fillRect(0, 0, width, height); - - context.font = textStyle._font; - - context.textBaseline = 'alphabetic'; - context.fillStyle = '#000'; - context.fillText(textStyle.testString, 0, baseline); - - var output = { - ascent: 0, - descent: 0, - fontSize: 0 - }; - - if (!context.getImageData(0, 0, width, height)) - { - output.ascent = baseline; - output.descent = baseline + 6; - output.fontSize = output.ascent + output.descent; - - CanvasPool.remove(canvas); - - return output; - } - - var imagedata = context.getImageData(0, 0, width, height).data; - var pixels = imagedata.length; - var line = width * 4; - var i; - var j; - var idx = 0; - var stop = false; - - // ascent. scan from top to bottom until we find a non red pixel - for (i = 0; i < baseline; i++) - { - for (j = 0; j < line; j += 4) - { - if (imagedata[idx + j] !== 255) - { - stop = true; - break; - } - } - - if (!stop) - { - idx += line; - } - else - { - break; - } - } - - output.ascent = baseline - i; - - idx = pixels - line; - stop = false; - - // descent. scan from bottom to top until we find a non red pixel - for (i = height; i > baseline; i--) - { - for (j = 0; j < line; j += 4) - { - if (imagedata[idx + j] !== 255) - { - stop = true; - break; - } - } - - if (!stop) - { - idx -= line; - } - else - { - break; - } - } - - output.descent = (i - baseline); - output.fontSize = output.ascent + output.descent; - - CanvasPool.remove(canvas); - - return output; -}; - -module.exports = MeasureText; - - -/***/ }), -/* 627 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(628); -} - -if (true) -{ - renderCanvas = __webpack_require__(629); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 628 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.TileSprite#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.TileSprite} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var TileSpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - src.updateTileTexture(); - - this.pipeline.batchTileSprite(this, camera); -}; - -module.exports = TileSpriteWebGLRenderer; - - -/***/ }), -/* 629 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.TileSprite#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.TileSprite} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - var ctx = renderer.currentContext; - var frame = src.frame; - - src.updateTileTexture(); - - // Blend Mode - - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Alpha - - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - var dx = frame.x - (src.originX * src.width); - var dy = frame.y - (src.originY * src.height); - - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - - var fx = 1; - var fy = 1; - - // Flipping - - if (src.flipX) - { - fx = -1; - dx += src.width; - } - - if (src.flipY) - { - fy = -1; - dy += src.height; - } - - if (renderer.config.roundPixels) - { - dx |= 0; - dy |= 0; - tx |= 0; - ty |= 0; - } - - ctx.save(); - - ctx.translate(dx, dy); - - ctx.translate(tx, ty); - - // Flip - ctx.scale(fx, fy); - - // Rotate and scale around center - ctx.translate((src.originX * src.width), (src.originY * src.height)); - ctx.rotate(fx * fy * src.rotation); - ctx.scale(this.scaleX, this.scaleY); - ctx.translate(-(src.originX * src.width), -(src.originY * src.height)); - - // Draw - ctx.translate(-this.tilePositionX, -this.tilePositionY); - ctx.fillStyle = src.canvasPattern; - ctx.fillRect(this.tilePositionX, this.tilePositionY, src.width, src.height); - - ctx.restore(); -}; - -module.exports = TileSpriteCanvasRenderer; - - -/***/ }), -/* 630 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Blitter = __webpack_require__(134); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new Blitter Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Blitter Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#blitter - * @since 3.0.0 - * - * @param {number} x - The x position of the Game Object. - * @param {number} y - The y position of the Game Object. - * @param {string} key - The key of the Texture the Blitter object will use. - * @param {string|integer} [frame] - The default Frame children of the Blitter will use. - * - * @return {Phaser.GameObjects.Blitter} The Game Object that was created. - */ -GameObjectFactory.register('blitter', function (x, y, key, frame) -{ - return this.displayList.add(new Blitter(this.scene, x, y, key, frame)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 631 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var DynamicBitmapText = __webpack_require__(135); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new Dynamic Bitmap Text Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#dynamicBitmapText - * @since 3.0.0 - * - * @param {number} x - The x position of the Game Object. - * @param {number} y - The y position of the Game Object. - * @param {string} font - [description] - * @param {string|string[]} [text] - [description] - * @param {number} [size] - [description] - * - * @return {Phaser.GameObjects.DynamicBitmapText} The Game Object that was created. - */ -GameObjectFactory.register('dynamicBitmapText', function (x, y, font, text, size) -{ - return this.displayList.add(new DynamicBitmapText(this.scene, x, y, font, text, size)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 632 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Graphics = __webpack_require__(136); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new Graphics Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Graphics Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#graphics - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Graphics} The Game Object that was created. - */ -GameObjectFactory.register('graphics', function (config) -{ - return this.displayList.add(new Graphics(this.scene, config)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 633 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Group = __webpack_require__(69); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new Group Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Group Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#group - * @since 3.0.0 - * - * @param {array|object} children - [description] - * @param {object} [config] - [description] - * - * @return {Phaser.GameObjects.Group} The Game Object that was created. - */ -GameObjectFactory.register('group', function (children, config) -{ - if (typeof children === 'object' && config === undefined) - { - config = children; - children = []; - } - - return this.updateList.add(new Group(this.scene, children, config)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 634 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Image = __webpack_require__(70); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new Image Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Image Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#image - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.Image} The Game Object that was created. - */ -GameObjectFactory.register('image', function (x, y, key, frame) -{ - return this.displayList.add(new Image(this.scene, x, y, key, frame)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 635 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectFactory = __webpack_require__(9); -var ParticleEmitterManager = __webpack_require__(139); - -/** - * Creates a new Particle Emitter Manager Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Particles Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#particles - * @since 3.0.0 - * - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer|object} [frame] - [description] - * @param {object} [emitters] - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} The Game Object that was created. - */ -GameObjectFactory.register('particles', function (key, frame, emitters) -{ - var manager = new ParticleEmitterManager(this.scene, key, frame, emitters); - - this.displayList.add(manager); - this.updateList.add(manager); - - return manager; -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 636 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectFactory = __webpack_require__(9); -var PathFollower = __webpack_require__(290); - -/** - * Creates a new PathFollower Game Object and adds it to the Scene. - * - * Note: This method will only be available if the PathFollower Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#follower - * @since 3.0.0 - * - * @param {Phaser.Curves.Path} path - The Path this PathFollower is connected to. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.PathFollower} The Game Object that was created. - */ -GameObjectFactory.register('follower', function (path, x, y, key, frame) -{ - var sprite = new PathFollower(this.scene, path, x, y, key, frame); - - this.displayList.add(sprite); - this.updateList.add(sprite); - - return sprite; -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 637 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectFactory = __webpack_require__(9); -var RenderTexture = __webpack_require__(141); - -/** - * Creates a new Render Texture Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#renderTexture - * @since 3.2.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {integer} [width=32] - The width of the Render Texture. - * @param {integer} [height=32] - The height of the Render Texture. - * - * @return {Phaser.GameObjects.RenderTexture} The Game Object that was created. - */ -GameObjectFactory.register('renderTexture', function (x, y, width, height) -{ - return this.displayList.add(new RenderTexture(this.scene, x, y, width, height)); -}); - - -/***/ }), -/* 638 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Sprite3D = __webpack_require__(81); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new Sprite3D Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Sprite3D Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#sprite3D - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object. - * @param {number} y - The vertical position of this Game Object. - * @param {number} z - The z position of this Game Object. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.Sprite3D} The Game Object that was created. - */ -GameObjectFactory.register('sprite3D', function (x, y, z, key, frame) -{ - var sprite = new Sprite3D(this.scene, x, y, z, key, frame); - - this.displayList.add(sprite.gameObject); - this.updateList.add(sprite.gameObject); - - return sprite; -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 639 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectFactory = __webpack_require__(9); -var Sprite = __webpack_require__(37); - -/** - * Creates a new Sprite Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Sprite Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#sprite - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.Sprite} The Game Object that was created. - */ -GameObjectFactory.register('sprite', function (x, y, key, frame) -{ - var sprite = new Sprite(this.scene, x, y, key, frame); - - this.displayList.add(sprite); - this.updateList.add(sprite); - - return sprite; -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 640 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BitmapText = __webpack_require__(133); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new Bitmap Text Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#bitmapText - * @since 3.0.0 - * - * @param {number} x - The x position of the Game Object. - * @param {number} y - The y position of the Game Object. - * @param {string} font - [description] - * @param {string|string[]} [text] - [description] - * @param {number} [size] - [description] - * - * @return {Phaser.GameObjects.BitmapText} The Game Object that was created. - */ -GameObjectFactory.register('bitmapText', function (x, y, font, text, size) -{ - return this.displayList.add(new BitmapText(this.scene, x, y, font, text, size)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 641 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Text = __webpack_require__(142); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new Text Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Text Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#text - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string|string[]} text - The text this Text object will display. - * @param {object} [style] - The Text style configuration object. - * - * @return {Phaser.GameObjects.Text} The Game Object that was created. - */ -GameObjectFactory.register('text', function (x, y, text, style) -{ - return this.displayList.add(new Text(this.scene, x, y, text, style)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 642 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var TileSprite = __webpack_require__(143); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new TileSprite Game Object and adds it to the Scene. - * - * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#tileSprite - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {number} width - The width of the Game Object. - * @param {number} height - The height of the Game Object. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.TileSprite} The Game Object that was created. - */ -GameObjectFactory.register('tileSprite', function (x, y, width, height, key, frame) -{ - return this.displayList.add(new TileSprite(this.scene, x, y, width, height, key, frame)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 643 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Zone = __webpack_require__(77); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new Zone Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Zone Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#zone - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {number} width - The width of the Game Object. - * @param {number} height - The height of the Game Object. - * - * @return {Phaser.GameObjects.Zone} The Game Object that was created. - */ -GameObjectFactory.register('zone', function (x, y, width, height) -{ - return this.displayList.add(new Zone(this.scene, x, y, width, height)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 644 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Blitter = __webpack_require__(134); -var BuildGameObject = __webpack_require__(20); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); - -/** - * Creates a new Blitter Game Object and returns it. - * - * Note: This method will only be available if the Blitter Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#blitter - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Blitter} The Game Object that was created. - */ -GameObjectCreator.register('blitter', function (config) -{ - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - - var blitter = new Blitter(this.scene, 0, 0, key, frame); - - BuildGameObject(this.scene, blitter, config); - - return blitter; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 645 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BitmapText = __webpack_require__(135); -var BuildGameObject = __webpack_require__(20); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); - -/** - * Creates a new Dynamic Bitmap Text Game Object and returns it. - * - * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#dynamicBitmapText - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.DynamicBitmapText} The Game Object that was created. - */ -GameObjectCreator.register('dynamicBitmapText', function (config) -{ - var font = GetAdvancedValue(config, 'font', ''); - var text = GetAdvancedValue(config, 'text', ''); - var size = GetAdvancedValue(config, 'size', false); - var align = GetAdvancedValue(config, 'align', 'left'); - - var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size, align); - - BuildGameObject(this.scene, bitmapText, config); - - return bitmapText; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 646 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectCreator = __webpack_require__(13); -var Graphics = __webpack_require__(136); - -/** - * Creates a new Graphics Game Object and returns it. - * - * Note: This method will only be available if the Graphics Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#graphics - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Graphics} The Game Object that was created. - */ -GameObjectCreator.register('graphics', function (config) -{ - return new Graphics(this.scene, config); -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 647 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectCreator = __webpack_require__(13); -var Group = __webpack_require__(69); - -/** - * Creates a new Group Game Object and returns it. - * - * Note: This method will only be available if the Group Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#group - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Group} The Game Object that was created. - */ -GameObjectCreator.register('group', function (config) -{ - return new Group(this.scene, null, config); -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 648 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(20); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Image = __webpack_require__(70); - -/** - * Creates a new Image Game Object and returns it. - * - * Note: This method will only be available if the Image Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#image - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Image} The Game Object that was created. - */ -GameObjectCreator.register('image', function (config) -{ - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - - var image = new Image(this.scene, 0, 0, key, frame); - - BuildGameObject(this.scene, image, config); - - return image; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 649 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var GetFastValue = __webpack_require__(2); -var ParticleEmitterManager = __webpack_require__(139); - -/** - * Creates a new Particle Emitter Manager Game Object and returns it. - * - * Note: This method will only be available if the Particles Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#particles - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} The Game Object that was created. - */ -GameObjectCreator.register('particles', function (config) -{ - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - var emitters = GetFastValue(config, 'emitters', null); - - // frame is optional and can contain the emitters array or object if skipped - var manager = new ParticleEmitterManager(this.scene, key, frame, emitters); - - var add = GetFastValue(config, 'add', false); - - if (add) - { - this.displayList.add(manager); - } - - this.updateList.add(manager); - - return manager; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 650 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(20); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var RenderTexture = __webpack_require__(141); - -/** - * Creates a new Render Texture Game Object and returns it. - * - * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#renderTexture - * @since 3.2.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.RenderTexture} The Game Object that was created. - */ -GameObjectCreator.register('renderTexture', function (config) -{ - var x = GetAdvancedValue(config, 'x', 0); - var y = GetAdvancedValue(config, 'y', 0); - var width = GetAdvancedValue(config, 'width', 32); - var height = GetAdvancedValue(config, 'height', 32); - var renderTexture = new RenderTexture(this.scene, x, y, width, height); - - BuildGameObject(this.scene, renderTexture, config); - - return renderTexture; -}); - - -/***/ }), -/* 651 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(20); -var BuildGameObjectAnimation = __webpack_require__(132); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Sprite3D = __webpack_require__(81); - -/** - * Creates a new Sprite3D Game Object and returns it. - * - * Note: This method will only be available if the Sprite3D Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#sprite3D - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Sprite3D} The Game Object that was created. - */ -GameObjectCreator.register('sprite3D', function (config) -{ - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - - var sprite = new Sprite3D(this.scene, 0, 0, key, frame); - - BuildGameObject(this.scene, sprite, config); - - // Sprite specific config options: - - BuildGameObjectAnimation(sprite, config); - - // Physics, Input, etc to follow ... - - return sprite; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 652 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(20); -var BuildGameObjectAnimation = __webpack_require__(132); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Sprite = __webpack_require__(37); - -/** - * Creates a new Sprite Game Object and returns it. - * - * Note: This method will only be available if the Sprite Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#sprite - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Sprite} The Game Object that was created. - */ -GameObjectCreator.register('sprite', function (config) -{ - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - - var sprite = new Sprite(this.scene, 0, 0, key, frame); - - BuildGameObject(this.scene, sprite, config); - - // Sprite specific config options: - - BuildGameObjectAnimation(sprite, config); - - // Physics, Input, etc to follow ... - - return sprite; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 653 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BitmapText = __webpack_require__(133); -var BuildGameObject = __webpack_require__(20); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var GetValue = __webpack_require__(4); - -/** - * Creates a new Bitmap Text Game Object and returns it. - * - * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#bitmapText - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.BitmapText} The Game Object that was created. - */ -GameObjectCreator.register('bitmapText', function (config) -{ - var font = GetValue(config, 'font', ''); - var text = GetAdvancedValue(config, 'text', ''); - var size = GetAdvancedValue(config, 'size', false); - - // var align = GetValue(config, 'align', 'left'); - - var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size); - - BuildGameObject(this.scene, bitmapText, config); - - return bitmapText; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 654 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(20); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Text = __webpack_require__(142); - -/** - * Creates a new Text Game Object and returns it. - * - * Note: This method will only be available if the Text Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#text - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Text} The Game Object that was created. - */ -GameObjectCreator.register('text', function (config) -{ - // style Object = { - // font: [ 'font', '16px Courier' ], - // backgroundColor: [ 'backgroundColor', null ], - // fill: [ 'fill', '#fff' ], - // stroke: [ 'stroke', '#fff' ], - // strokeThickness: [ 'strokeThickness', 0 ], - // shadowOffsetX: [ 'shadow.offsetX', 0 ], - // shadowOffsetY: [ 'shadow.offsetY', 0 ], - // shadowColor: [ 'shadow.color', '#000' ], - // shadowBlur: [ 'shadow.blur', 0 ], - // shadowStroke: [ 'shadow.stroke', false ], - // shadowFill: [ 'shadow.fill', false ], - // align: [ 'align', 'left' ], - // maxLines: [ 'maxLines', 0 ], - // fixedWidth: [ 'fixedWidth', false ], - // fixedHeight: [ 'fixedHeight', false ], - // rtl: [ 'rtl', false ] - // } - - var content = GetAdvancedValue(config, 'text', ''); - var style = GetAdvancedValue(config, 'style', null); - - // Padding - // { padding: 2 } - // { padding: { x: , y: }} - // { padding: { left: , top: }} - // { padding: { left: , right: , top: , bottom: }} - - var padding = GetAdvancedValue(config, 'padding', null); - - if (padding !== null) - { - style.padding = padding; - } - - var text = new Text(this.scene, 0, 0, content, style); - - BuildGameObject(this.scene, text, config); - - // Text specific config options: - - text.autoRound = GetAdvancedValue(config, 'autoRound', true); - text.resolution = GetAdvancedValue(config, 'resolution', 1); - - return text; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 655 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(20); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var TileSprite = __webpack_require__(143); - -/** - * Creates a new TileSprite Game Object and returns it. - * - * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#tileSprite - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.TileSprite} The Game Object that was created. - */ -GameObjectCreator.register('tileSprite', function (config) -{ - var x = GetAdvancedValue(config, 'x', 0); - var y = GetAdvancedValue(config, 'y', 0); - var width = GetAdvancedValue(config, 'width', 512); - var height = GetAdvancedValue(config, 'height', 512); - var key = GetAdvancedValue(config, 'key', ''); - var frame = GetAdvancedValue(config, 'frame', ''); - - var tile = new TileSprite(this.scene, x, y, width, height, key, frame); - - BuildGameObject(this.scene, tile, config); - - return tile; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 656 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Zone = __webpack_require__(77); - -/** - * Creates a new Zone Game Object and returns it. - * - * Note: This method will only be available if the Zone Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#zone - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Zone} The Game Object that was created. - */ -GameObjectCreator.register('zone', function (config) -{ - var x = GetAdvancedValue(config, 'x', 0); - var y = GetAdvancedValue(config, 'y', 0); - var width = GetAdvancedValue(config, 'width', 1); - var height = GetAdvancedValue(config, 'height', width); - - return new Zone(this.scene, x, y, width, height); -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 657 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(658); -} - -if (true) -{ - renderCanvas = __webpack_require__(659); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 658 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Mesh#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Mesh} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var MeshWebGLRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.batchMesh(src, camera); -}; - -module.exports = MeshWebGLRenderer; - - -/***/ }), -/* 659 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * This is a stub function for Mesh.Render. There is no Canvas renderer for Mesh objects. - * - * @method Phaser.GameObjects.Mesh#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Mesh} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var MeshCanvasRenderer = function () -{ -}; - -module.exports = MeshCanvasRenderer; - - -/***/ }), -/* 660 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Mesh = __webpack_require__(88); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new Mesh Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#mesh - * @webglOnly - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {array} vertices - An array containing the vertices data for this Mesh. - * @param {array} uv - An array containing the uv data for this Mesh. - * @param {array} colors - An array containing the color data for this Mesh. - * @param {array} alphas - An array containing the alpha data for this Mesh. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.Mesh} The Game Object that was created. - */ -if (true) -{ - GameObjectFactory.register('mesh', function (x, y, vertices, uv, colors, alphas, texture, frame) - { - return this.displayList.add(new Mesh(this.scene, x, y, vertices, uv, colors, alphas, texture, frame)); - }); -} - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 661 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Quad = __webpack_require__(144); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new Quad Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Quad Game Object and WebGL support have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#quad - * @webglOnly - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.Quad} The Game Object that was created. - */ -if (true) -{ - GameObjectFactory.register('quad', function (x, y, key, frame) - { - return this.displayList.add(new Quad(this.scene, x, y, key, frame)); - }); -} - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 662 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(20); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var GetValue = __webpack_require__(4); -var Mesh = __webpack_require__(88); - -/** - * Creates a new Mesh Game Object and returns it. - * - * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#mesh - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Mesh} The Game Object that was created. - */ -GameObjectCreator.register('mesh', function (config) -{ - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - var vertices = GetValue(config, 'vertices', []); - var colors = GetValue(config, 'colors', []); - var alphas = GetValue(config, 'alphas', []); - var uv = GetValue(config, 'uv', []); - - var mesh = new Mesh(this.scene, 0, 0, vertices, uv, colors, alphas, key, frame); - - BuildGameObject(this.scene, mesh, config); - - return mesh; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 663 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(20); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Quad = __webpack_require__(144); - -/** - * Creates a new Quad Game Object and returns it. - * - * Note: This method will only be available if the Quad Game Object and WebGL support have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#quad - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Quad} The Game Object that was created. - */ -GameObjectCreator.register('quad', function (config) -{ - var x = GetAdvancedValue(config, 'x', 0); - var y = GetAdvancedValue(config, 'y', 0); - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - - var quad = new Quad(this.scene, x, y, key, frame); - - BuildGameObject(this.scene, quad, config); - - return quad; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 664 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var LightsManager = __webpack_require__(293); -var PluginManager = __webpack_require__(12); - -/** - * @classdesc - * [description] - * - * @class LightsPlugin - * @extends Phaser.GameObjects.LightsManager - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var LightsPlugin = new Class({ - - Extends: LightsManager, - - initialize: - - function LightsPlugin (scene) - { - /** - * [description] - * - * @name Phaser.GameObjects.LightsPlugin#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.GameObjects.LightsPlugin#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - if (!scene.sys.settings.isBooted) - { - scene.sys.events.once('boot', this.boot, this); - } - - LightsManager.call(this); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsPlugin#boot - * @since 3.0.0 - */ - boot: function () - { - var eventEmitter = this.systems.events; - - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsPlugin#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.shutdown(); - - this.scene = undefined; - this.systems = undefined; - } - -}); - -PluginManager.register('LightsPlugin', LightsPlugin, 'lights'); - -module.exports = LightsPlugin; - - -/***/ }), -/* 665 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Circle = __webpack_require__(64); - -Circle.Area = __webpack_require__(666); -Circle.Circumference = __webpack_require__(186); -Circle.CircumferencePoint = __webpack_require__(105); -Circle.Clone = __webpack_require__(667); -Circle.Contains = __webpack_require__(32); -Circle.ContainsPoint = __webpack_require__(668); -Circle.ContainsRect = __webpack_require__(669); -Circle.CopyFrom = __webpack_require__(670); -Circle.Equals = __webpack_require__(671); -Circle.GetBounds = __webpack_require__(672); -Circle.GetPoint = __webpack_require__(184); -Circle.GetPoints = __webpack_require__(185); -Circle.Offset = __webpack_require__(673); -Circle.OffsetPoint = __webpack_require__(674); -Circle.Random = __webpack_require__(106); - -module.exports = Circle; - - -/***/ }), -/* 666 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculates the area of the circle. - * - * @function Phaser.Geom.Circle.Area - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to get the area of. - * - * @return {number} The area of the Circle. - */ -var Area = function (circle) -{ - return (circle.radius > 0) ? Math.PI * circle.radius * circle.radius : 0; -}; - -module.exports = Area; - - -/***/ }), -/* 667 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Circle = __webpack_require__(64); - -/** - * Creates a new Circle instance based on the values contained in the given source. - * - * @function Phaser.Geom.Circle.Clone - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle|object} source - The Circle to be cloned. Can be an instance of a Circle or a circle-like object, with x, y and radius properties. - * - * @return {Phaser.Geom.Circle} A clone of the source Circle. - */ -var Clone = function (source) -{ - return new Circle(source.x, source.y, source.radius); -}; - -module.exports = Clone; - - -/***/ }), -/* 668 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(32); - -/** - * Check to see if the Circle contains the given Point object. - * - * @function Phaser.Geom.Circle.ContainsPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to check. - * @param {Phaser.Geom.Point|object} point - The Point object to check if it's within the Circle or not. - * - * @return {boolean} True if the Point coordinates are within the circle, otherwise false. - */ -var ContainsPoint = function (circle, point) -{ - return Contains(circle, point.x, point.y); -}; - -module.exports = ContainsPoint; - - -/***/ }), -/* 669 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(32); - -/** - * Check to see if the Circle contains all four points of the given Rectangle object. - * - * @function Phaser.Geom.Circle.ContainsRect - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to check. - * @param {Phaser.Geom.Rectangle|object} rect - The Rectangle object to check if it's within the Circle or not. - * - * @return {boolean} True if all of the Rectangle coordinates are within the circle, otherwise false. - */ -var ContainsRect = function (circle, rect) -{ - return ( - Contains(circle, rect.x, rect.y) && - Contains(circle, rect.right, rect.y) && - Contains(circle, rect.x, rect.bottom) && - Contains(circle, rect.right, rect.bottom) - ); -}; - -module.exports = ContainsRect; - - -/***/ }), -/* 670 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Copies the `x`, `y` and `radius` properties from the `source` Circle - * into the given `dest` Circle, then returns the `dest` Circle. - * - * @function Phaser.Geom.Circle.CopyFrom - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} source - The source Circle to copy the values from. - * @param {Phaser.Geom.Circle} dest - The destination Circle to copy the values to. - * - * @return {Phaser.Geom.Circle} The dest Circle. - */ -var CopyFrom = function (source, dest) -{ - return dest.setTo(source.x, source.y, source.radius); -}; - -module.exports = CopyFrom; - - -/***/ }), -/* 671 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Compares the `x`, `y` and `radius` properties of the two given Circles. - * Returns `true` if they all match, otherwise returns `false`. - * - * @function Phaser.Geom.Circle.Equals - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The first Circle to compare. - * @param {Phaser.Geom.Circle} toCompare - The second Circle to compare. - * - * @return {boolean} `true` if the two Circles equal each other, otherwise `false`. - */ -var Equals = function (circle, toCompare) -{ - return ( - circle.x === toCompare.x && - circle.y === toCompare.y && - circle.radius === toCompare.radius - ); -}; - -module.exports = Equals; - - -/***/ }), -/* 672 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(8); - -/** - * Returns the bounds of the Circle object. - * - * @function Phaser.Geom.Circle.GetBounds - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to get the bounds from. - * @param {Phaser.Geom.Rectangle|object} [out] - A Rectangle, or rectangle-like object, to store the circle bounds in. If not given a new Rectangle will be created. - * - * @return {Phaser.Geom.Rectangle|object} The Rectangle object containing the Circles bounds. - */ -var GetBounds = function (circle, out) -{ - if (out === undefined) { out = new Rectangle(); } - - out.x = circle.left; - out.y = circle.top; - out.width = circle.diameter; - out.height = circle.diameter; - - return out; -}; - -module.exports = GetBounds; - - -/***/ }), -/* 673 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Offsets the Circle by the values given. - * - * @function Phaser.Geom.Circle.Offset - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to be offset (translated.) - * @param {number} x - The amount to horizontally offset the Circle by. - * @param {number} y - The amount to vertically offset the Circle by. - * - * @return {Phaser.Geom.Circle} The Circle that was offset. - */ -var Offset = function (circle, x, y) -{ - circle.x += x; - circle.y += y; - - return circle; -}; - -module.exports = Offset; - - -/***/ }), -/* 674 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Offsets the Circle by the values given in the `x` and `y` properties of the Point object. - * - * @function Phaser.Geom.Circle.OffsetPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to be offset (translated.) - * @param {Phaser.Geom.Point|object} point - The Point object containing the values to offset the Circle by. - * - * @return {Phaser.Geom.Circle} The Circle that was offset. - */ -var OffsetPoint = function (circle, point) -{ - circle.x += point.x; - circle.y += point.y; - - return circle; -}; - -module.exports = OffsetPoint; - - -/***/ }), -/* 675 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var DistanceBetween = __webpack_require__(42); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.CircleToCircle - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circleA - [description] - * @param {Phaser.Geom.Circle} circleB - [description] - * - * @return {boolean} [description] - */ -var CircleToCircle = function (circleA, circleB) -{ - return (DistanceBetween(circleA.x, circleA.y, circleB.x, circleB.y) <= (circleA.radius + circleB.radius)); -}; - -module.exports = CircleToCircle; - - -/***/ }), -/* 676 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Intersects.CircleToRectangle - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - [description] - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {boolean} [description] - */ -var CircleToRectangle = function (circle, rect) -{ - var halfWidth = rect.width / 2; - var halfHeight = rect.height / 2; - - var cx = Math.abs(circle.x - rect.x - halfWidth); - var cy = Math.abs(circle.y - rect.y - halfHeight); - var xDist = halfWidth + circle.radius; - var yDist = halfHeight + circle.radius; - - if (cx > xDist || cy > yDist) - { - return false; - } - else if (cx <= halfWidth || cy <= halfHeight) - { - return true; - } - else - { - var xCornerDist = cx - halfWidth; - var yCornerDist = cy - halfHeight; - var xCornerDistSq = xCornerDist * xCornerDist; - var yCornerDistSq = yCornerDist * yCornerDist; - var maxCornerDistSq = circle.radius * circle.radius; - - return (xCornerDistSq + yCornerDistSq <= maxCornerDistSq); - } -}; - -module.exports = CircleToRectangle; - - -/***/ }), -/* 677 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(8); -var RectangleToRectangle = __webpack_require__(296); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.GetRectangleIntersection - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] - * @param {Phaser.Geom.Rectangle} [output] - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var GetRectangleIntersection = function (rectA, rectB, output) -{ - if (output === undefined) { output = new Rectangle(); } - - if (RectangleToRectangle(rectA, rectB)) - { - output.x = Math.max(rectA.x, rectB.x); - output.y = Math.max(rectA.y, rectB.y); - output.width = Math.min(rectA.right, rectB.right) - output.x; - output.height = Math.min(rectA.bottom, rectB.bottom) - output.y; - } - - return output; -}; - -module.exports = GetRectangleIntersection; - - -/***/ }), -/* 678 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Checks for intersection between the Line and a Rectangle shape, or a rectangle-like - * object, with public `x`, `y`, `right` and `bottom` properties, such as a Sprite or Body. - * - * An intersection is considered valid if: - * - * The line starts within, or ends within, the Rectangle. - * The line segment intersects one of the 4 rectangle edges. - * - * The for the purposes of this function rectangles are considered 'solid'. - * - * @function Phaser.Geom.Intersects.LineToRectangle - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {Phaser.Geom.Rectangle|object} rect - [description] - * - * @return {boolean} [description] - */ -var LineToRectangle = function (line, rect) -{ - var x1 = line.x1; - var y1 = line.y1; - - var x2 = line.x2; - var y2 = line.y2; - - var bx1 = rect.x; - var by1 = rect.y; - var bx2 = rect.right; - var by2 = rect.bottom; - - var t = 0; - - // If the start or end of the line is inside the rect then we assume - // collision, as rects are solid for our use-case. - - if ((x1 >= bx1 && x1 <= bx2 && y1 >= by1 && y1 <= by2) || - (x2 >= bx1 && x2 <= bx2 && y2 >= by1 && y2 <= by2)) - { - return true; - } - - if (x1 < bx1 && x2 >= bx1) - { - // Left edge - t = y1 + (y2 - y1) * (bx1 - x1) / (x2 - x1); - - if (t > by1 && t <= by2) - { - return true; - } - } - else if (x1 > bx2 && x2 <= bx2) - { - // Right edge - t = y1 + (y2 - y1) * (bx2 - x1) / (x2 - x1); - - if (t >= by1 && t <= by2) - { - return true; - } - } - - if (y1 < by1 && y2 >= by1) - { - // Top edge - t = x1 + (x2 - x1) * (by1 - y1) / (y2 - y1); - - if (t >= bx1 && t <= bx2) - { - return true; - } - } - else if (y1 > by2 && y2 <= by2) - { - // Bottom edge - t = x1 + (x2 - x1) * (by2 - y1) / (y2 - y1); - - if (t >= bx1 && t <= bx2) - { - return true; - } - } - - return false; -}; - -module.exports = LineToRectangle; - - -/***/ }), -/* 679 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var PointToLine = __webpack_require__(298); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.PointToLineSegment - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} point - [description] - * @param {Phaser.Geom.Line} line - [description] - * - * @return {boolean} [description] - */ -var PointToLineSegment = function (point, line) -{ - if (!PointToLine(point, line)) - { - return false; - } - - var xMin = Math.min(line.x1, line.x2); - var xMax = Math.max(line.x1, line.x2); - var yMin = Math.min(line.y1, line.y2); - var yMax = Math.max(line.y1, line.y2); - - return ((point.x >= xMin && point.x <= xMax) && (point.y >= yMin && point.y <= yMax)); -}; - -module.exports = PointToLineSegment; - - -/***/ }), -/* 680 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var LineToLine = __webpack_require__(89); -var Contains = __webpack_require__(33); -var ContainsArray = __webpack_require__(145); -var Decompose = __webpack_require__(299); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.RectangleToTriangle - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Triangle} triangle - [description] - * - * @return {boolean} [description] - */ -var RectangleToTriangle = function (rect, triangle) -{ - // First the cheapest ones: - - if ( - triangle.left > rect.right || - triangle.right < rect.left || - triangle.top > rect.bottom || - triangle.bottom < rect.top) - { - return false; - } - - var triA = triangle.getLineA(); - var triB = triangle.getLineB(); - var triC = triangle.getLineC(); - - // Are any of the triangle points within the rectangle? - - if (Contains(rect, triA.x1, triA.y1) || Contains(rect, triA.x2, triA.y2)) - { - return true; - } - - if (Contains(rect, triB.x1, triB.y1) || Contains(rect, triB.x2, triB.y2)) - { - return true; - } - - if (Contains(rect, triC.x1, triC.y1) || Contains(rect, triC.x2, triC.y2)) - { - return true; - } - - // Cheap tests over, now to see if any of the lines intersect ... - - var rectA = rect.getLineA(); - var rectB = rect.getLineB(); - var rectC = rect.getLineC(); - var rectD = rect.getLineD(); - - if (LineToLine(triA, rectA) || LineToLine(triA, rectB) || LineToLine(triA, rectC) || LineToLine(triA, rectD)) - { - return true; - } - - if (LineToLine(triB, rectA) || LineToLine(triB, rectB) || LineToLine(triB, rectC) || LineToLine(triB, rectD)) - { - return true; - } - - if (LineToLine(triC, rectA) || LineToLine(triC, rectB) || LineToLine(triC, rectC) || LineToLine(triC, rectD)) - { - return true; - } - - // None of the lines intersect, so are any rectangle points within the triangle? - - var points = Decompose(rect); - var within = ContainsArray(triangle, points, true); - - return (within.length > 0); -}; - -module.exports = RectangleToTriangle; - - -/***/ }), -/* 681 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Intersects.RectangleToValues - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} left - [description] - * @param {number} right - [description] - * @param {number} top - [description] - * @param {number} bottom - [description] - * @param {float} [tolerance=0] - [description] - * - * @return {boolean} [description] - */ -var RectangleToValues = function (rect, left, right, top, bottom, tolerance) -{ - if (tolerance === undefined) { tolerance = 0; } - - return !( - left > rect.right + tolerance || - right < rect.left - tolerance || - top > rect.bottom + tolerance || - bottom < rect.top - tolerance - ); -}; - -module.exports = RectangleToValues; - - -/***/ }), -/* 682 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var LineToCircle = __webpack_require__(297); -var Contains = __webpack_require__(54); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.TriangleToCircle - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Circle} circle - [description] - * - * @return {boolean} [description] - */ -var TriangleToCircle = function (triangle, circle) -{ - // First the cheapest ones: - - if ( - triangle.left > circle.right || - triangle.right < circle.left || - triangle.top > circle.bottom || - triangle.bottom < circle.top) - { - return false; - } - - if (Contains(triangle, circle.x, circle.y)) - { - return true; - } - - if (LineToCircle(triangle.getLineA(), circle)) - { - return true; - } - - if (LineToCircle(triangle.getLineB(), circle)) - { - return true; - } - - if (LineToCircle(triangle.getLineC(), circle)) - { - return true; - } - - return false; -}; - -module.exports = TriangleToCircle; - - -/***/ }), -/* 683 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(54); -var LineToLine = __webpack_require__(89); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.TriangleToLine - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Line} line - [description] - * - * @return {boolean} [description] - */ -var TriangleToLine = function (triangle, line) -{ - // If the Triangle contains either the start or end point of the line, it intersects - if (Contains(triangle, line.getPointA()) || Contains(triangle, line.getPointB())) - { - return true; - } - - // Now check the line against each line of the Triangle - if (LineToLine(triangle.getLineA(), line)) - { - return true; - } - - if (LineToLine(triangle.getLineB(), line)) - { - return true; - } - - if (LineToLine(triangle.getLineC(), line)) - { - return true; - } - - return false; -}; - -module.exports = TriangleToLine; - - -/***/ }), -/* 684 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ContainsArray = __webpack_require__(145); -var Decompose = __webpack_require__(300); -var LineToLine = __webpack_require__(89); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.TriangleToTriangle - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangleA - [description] - * @param {Phaser.Geom.Triangle} triangleB - [description] - * - * @return {boolean} [description] - */ -var TriangleToTriangle = function (triangleA, triangleB) -{ - // First the cheapest ones: - - if ( - triangleA.left > triangleB.right || - triangleA.right < triangleB.left || - triangleA.top > triangleB.bottom || - triangleA.bottom < triangleB.top) - { - return false; - } - - var lineAA = triangleA.getLineA(); - var lineAB = triangleA.getLineB(); - var lineAC = triangleA.getLineC(); - - var lineBA = triangleB.getLineA(); - var lineBB = triangleB.getLineB(); - var lineBC = triangleB.getLineC(); - - // Now check the lines against each line of TriangleB - if (LineToLine(lineAA, lineBA) || LineToLine(lineAA, lineBB) || LineToLine(lineAA, lineBC)) - { - return true; - } - - if (LineToLine(lineAB, lineBA) || LineToLine(lineAB, lineBB) || LineToLine(lineAB, lineBC)) - { - return true; - } - - if (LineToLine(lineAC, lineBA) || LineToLine(lineAC, lineBB) || LineToLine(lineAC, lineBC)) - { - return true; - } - - // Nope, so check to see if any of the points of triangleA are within triangleB - - var points = Decompose(triangleA); - var within = ContainsArray(triangleB, points, true); - - if (within.length > 0) - { - return true; - } - - // Finally check to see if any of the points of triangleB are within triangleA - - points = Decompose(triangleB); - within = ContainsArray(triangleA, points, true); - - if (within.length > 0) - { - return true; - } - - return false; -}; - -module.exports = TriangleToTriangle; - - -/***/ }), -/* 685 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Line = __webpack_require__(301); - -Line.Angle = __webpack_require__(55); -Line.BresenhamPoints = __webpack_require__(194); -Line.CenterOn = __webpack_require__(686); -Line.Clone = __webpack_require__(687); -Line.CopyFrom = __webpack_require__(688); -Line.Equals = __webpack_require__(689); -Line.GetMidPoint = __webpack_require__(690); -Line.GetNormal = __webpack_require__(691); -Line.GetPoint = __webpack_require__(302); -Line.GetPoints = __webpack_require__(109); -Line.Height = __webpack_require__(692); -Line.Length = __webpack_require__(66); -Line.NormalAngle = __webpack_require__(303); -Line.NormalX = __webpack_require__(693); -Line.NormalY = __webpack_require__(694); -Line.Offset = __webpack_require__(695); -Line.PerpSlope = __webpack_require__(696); -Line.Random = __webpack_require__(111); -Line.ReflectAngle = __webpack_require__(697); -Line.Rotate = __webpack_require__(698); -Line.RotateAroundPoint = __webpack_require__(699); -Line.RotateAroundXY = __webpack_require__(146); -Line.SetToAngle = __webpack_require__(700); -Line.Slope = __webpack_require__(701); -Line.Width = __webpack_require__(702); - -module.exports = Line; - - -/***/ }), -/* 686 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - - -/** - * [description] - * - * @function Phaser.Geom.Line.CenterOn - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var CenterOn = function (line, x, y) -{ - var tx = x - ((line.x1 + line.x2) / 2); - var ty = y - ((line.y1 + line.y2) / 2); - - line.x1 += tx; - line.y1 += ty; - - line.x2 += tx; - line.y2 += ty; - - return line; -}; - -module.exports = CenterOn; - - -/***/ }), -/* 687 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Line = __webpack_require__(301); - -/** - * [description] - * - * @function Phaser.Geom.Line.Clone - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} source - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var Clone = function (source) -{ - return new Line(source.x1, source.y1, source.x2, source.y2); -}; - -module.exports = Clone; - - -/***/ }), -/* 688 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.CopyFrom - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} source - [description] - * @param {Phaser.Geom.Line} dest - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var CopyFrom = function (source, dest) -{ - return dest.setTo(source.x1, source.y1, source.x2, source.y2); -}; - -module.exports = CopyFrom; - - -/***/ }), -/* 689 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Equals - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {Phaser.Geom.Line} toCompare - [description] - * - * @return {boolean} [description] - */ -var Equals = function (line, toCompare) -{ - return ( - line.x1 === toCompare.x1 && - line.y1 === toCompare.y1 && - line.x2 === toCompare.x2 && - line.y2 === toCompare.y2 - ); -}; - -module.exports = Equals; - - -/***/ }), -/* 690 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Line.GetMidPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {Phaser.Geom.Point|object} [out] - [description] - * - * @return {Phaser.Geom.Point|object} [description] - */ -var GetMidPoint = function (line, out) -{ - if (out === undefined) { out = new Point(); } - - out.x = (line.x1 + line.x2) / 2; - out.y = (line.y1 + line.y2) / 2; - - return out; -}; - -module.exports = GetMidPoint; - - -/***/ }), -/* 691 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH_CONST = __webpack_require__(16); -var Angle = __webpack_require__(55); -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Line.GetNormal - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {Phaser.Geom.Point|object} [out] - [description] - * - * @return {Phaser.Geom.Point|object} [description] - */ -var GetNormal = function (line, out) -{ - if (out === undefined) { out = new Point(); } - - var a = Angle(line) - MATH_CONST.TAU; - - out.x = Math.cos(a); - out.y = Math.sin(a); - - return out; -}; - -module.exports = GetNormal; - - -/***/ }), -/* 692 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Height - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var Height = function (line) -{ - return Math.abs(line.y1 - line.y2); -}; - -module.exports = Height; - - -/***/ }), -/* 693 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH_CONST = __webpack_require__(16); -var Angle = __webpack_require__(55); - -/** - * [description] - * - * @function Phaser.Geom.Line.NormalX - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var NormalX = function (line) -{ - return Math.cos(Angle(line) - MATH_CONST.TAU); -}; - -module.exports = NormalX; - - -/***/ }), -/* 694 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH_CONST = __webpack_require__(16); -var Angle = __webpack_require__(55); - -/** - * [description] - * - * @function Phaser.Geom.Line.NormalY - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var NormalY = function (line) -{ - return Math.sin(Angle(line) - MATH_CONST.TAU); -}; - -module.exports = NormalY; - - -/***/ }), -/* 695 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Offset - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var Offset = function (line, x, y) -{ - line.x1 += x; - line.y1 += y; - - line.x2 += x; - line.y2 += y; - - return line; -}; - -module.exports = Offset; - - -/***/ }), -/* 696 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.PerpSlope - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var PerpSlope = function (line) -{ - return -((line.x2 - line.x1) / (line.y2 - line.y1)); -}; - -module.exports = PerpSlope; - - -/***/ }), -/* 697 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Angle = __webpack_require__(55); -var NormalAngle = __webpack_require__(303); - -/** -* Returns the reflected angle between two lines. -* This is the outgoing angle based on the angle of Line 1 and the normalAngle of Line 2. -*/ -/** - * [description] - * - * @function Phaser.Geom.Line.ReflectAngle - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} lineA - [description] - * @param {Phaser.Geom.Line} lineB - [description] - * - * @return {number} [description] - */ -var ReflectAngle = function (lineA, lineB) -{ - return (2 * NormalAngle(lineB) - Math.PI - Angle(lineA)); -}; - -module.exports = ReflectAngle; - - -/***/ }), -/* 698 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RotateAroundXY = __webpack_require__(146); - -/** - * [description] - * - * @function Phaser.Geom.Line.Rotate - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var Rotate = function (line, angle) -{ - var x = (line.x1 + line.x2) / 2; - var y = (line.y1 + line.y2) / 2; - - return RotateAroundXY(line, x, y, angle); -}; - -module.exports = Rotate; - - -/***/ }), -/* 699 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RotateAroundXY = __webpack_require__(146); - -/** - * [description] - * - * @function Phaser.Geom.Line.RotateAroundPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {Phaser.Geom.Point|object} point - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var RotateAroundPoint = function (line, point, angle) -{ - return RotateAroundXY(line, point.x, point.y, angle); -}; - -module.exports = RotateAroundPoint; - - -/***/ }), -/* 700 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.SetToAngle - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} angle - [description] - * @param {number} length - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var SetToAngle = function (line, x, y, angle, length) -{ - line.x1 = x; - line.y1 = y; - - line.x2 = x + (Math.cos(angle) * length); - line.y2 = y + (Math.sin(angle) * length); - - return line; -}; - -module.exports = SetToAngle; - - -/***/ }), -/* 701 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Slope - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var Slope = function (line) -{ - return (line.y2 - line.y1) / (line.x2 - line.x1); -}; - -module.exports = Slope; - - -/***/ }), -/* 702 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Width - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var Width = function (line) -{ - return Math.abs(line.x1 - line.x2); -}; - -module.exports = Width; - - -/***/ }), -/* 703 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -Point.Ceil = __webpack_require__(704); -Point.Clone = __webpack_require__(705); -Point.CopyFrom = __webpack_require__(706); -Point.Equals = __webpack_require__(707); -Point.Floor = __webpack_require__(708); -Point.GetCentroid = __webpack_require__(709); -Point.GetMagnitude = __webpack_require__(304); -Point.GetMagnitudeSq = __webpack_require__(305); -Point.GetRectangleFromPoints = __webpack_require__(710); -Point.Interpolate = __webpack_require__(711); -Point.Invert = __webpack_require__(712); -Point.Negative = __webpack_require__(713); -Point.Project = __webpack_require__(714); -Point.ProjectUnit = __webpack_require__(715); -Point.SetMagnitude = __webpack_require__(716); - -module.exports = Point; - - -/***/ }), -/* 704 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.Ceil - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} point - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Ceil = function (point) -{ - return point.setTo(Math.ceil(point.x), Math.ceil(point.y)); -}; - -module.exports = Ceil; - - -/***/ }), -/* 705 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Point.Clone - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} source - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Clone = function (source) -{ - return new Point(source.x, source.y); -}; - -module.exports = Clone; - - -/***/ }), -/* 706 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.CopyFrom - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} source - [description] - * @param {Phaser.Geom.Point} dest - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var CopyFrom = function (source, dest) -{ - return dest.setTo(source.x, source.y); -}; - -module.exports = CopyFrom; - - -/***/ }), -/* 707 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.Equals - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} point - [description] - * @param {Phaser.Geom.Point} toCompare - [description] - * - * @return {boolean} [description] - */ -var Equals = function (point, toCompare) -{ - return (point.x === toCompare.x && point.y === toCompare.y); -}; - -module.exports = Equals; - - -/***/ }), -/* 708 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.Floor - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} point - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Floor = function (point) -{ - return point.setTo(Math.floor(point.x), Math.floor(point.y)); -}; - -module.exports = Floor; - - -/***/ }), -/* 709 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Point.GetCentroid - * @since 3.0.0 - * - * @param {Phaser.Geom.Point[]} points - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var GetCentroid = function (points, out) -{ - if (out === undefined) { out = new Point(); } - - if (!Array.isArray(points)) - { - throw new Error('GetCentroid points argument must be an array'); - } - - var len = points.length; - - if (len < 1) - { - throw new Error('GetCentroid points array must not be empty'); - } - else if (len === 1) - { - out.x = points[0].x; - out.y = points[0].y; - } - else - { - for (var i = 0; i < len; i++) - { - out.x += points[i].x; - out.y += points[i].y; - } - - out.x /= len; - out.y /= len; - } - - return out; -}; - -module.exports = GetCentroid; - - -/***/ }), -/* 710 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(8); - -/** - * Calculates the Axis Aligned Bounding Box (or aabb) from an array of points. - * - * @function Phaser.Geom.Point.GetRectangleFromPoints - * @since 3.0.0 - * - * @param {Phaser.Geom.Point[]} points - [description] - * @param {Phaser.Geom.Rectangle} [out] - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var GetRectangleFromPoints = function (points, out) -{ - if (out === undefined) { out = new Rectangle(); } - - var xMax = Number.NEGATIVE_INFINITY; - var xMin = Number.POSITIVE_INFINITY; - var yMax = Number.NEGATIVE_INFINITY; - var yMin = Number.POSITIVE_INFINITY; - - for (var i = 0; i < points.length; i++) - { - var point = points[i]; - - if (point.x > xMax) - { - xMax = point.x; - } - - if (point.x < xMin) - { - xMin = point.x; - } - - if (point.y > yMax) - { - yMax = point.y; - } - - if (point.y < yMin) - { - yMin = point.y; - } - } - - out.x = xMin; - out.y = yMin; - out.width = xMax - xMin; - out.height = yMax - yMin; - - return out; -}; - -module.exports = GetRectangleFromPoints; - - -/***/ }), -/* 711 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Point.Interpolate - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} pointA - [description] - * @param {Phaser.Geom.Point} pointB - [description] - * @param {float} [t=0] - [description] - * @param {Phaser.Geom.Point|object} [out] - [description] - * - * @return {Phaser.Geom.Point|object} [description] - */ -var Interpolate = function (pointA, pointB, t, out) -{ - if (t === undefined) { t = 0; } - if (out === undefined) { out = new Point(); } - - out.x = pointA.x + ((pointB.x - pointA.x) * t); - out.y = pointA.y + ((pointB.y - pointA.y) * t); - - return out; -}; - -module.exports = Interpolate; - - -/***/ }), -/* 712 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.Invert - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} point - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Invert = function (point) -{ - return point.setTo(point.y, point.x); -}; - -module.exports = Invert; - - -/***/ }), -/* 713 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Point.Negative - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} point - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Negative = function (point, out) -{ - if (out === undefined) { out = new Point(); } - - return out.setTo(-point.x, -point.y); -}; - -module.exports = Negative; - - -/***/ }), -/* 714 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); -var GetMagnitudeSq = __webpack_require__(305); - -/** - * [description] - * - * @function Phaser.Geom.Point.Project - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} pointA - [description] - * @param {Phaser.Geom.Point} pointB - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Project = function (pointA, pointB, out) -{ - if (out === undefined) { out = new Point(); } - - var dot = ((pointA.x * pointB.x) + (pointA.y * pointB.y)); - var amt = dot / GetMagnitudeSq(pointB); - - if (amt !== 0) - { - out.x = amt * pointB.x; - out.y = amt * pointB.y; - } - - return out; -}; - -module.exports = Project; - - -/***/ }), -/* 715 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Point.ProjectUnit - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} pointA - [description] - * @param {Phaser.Geom.Point} pointB - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var ProjectUnit = function (pointA, pointB, out) -{ - if (out === undefined) { out = new Point(); } - - var amt = ((pointA.x * pointB.x) + (pointA.y * pointB.y)); - - if (amt !== 0) - { - out.x = amt * pointB.x; - out.y = amt * pointB.y; - } - - return out; -}; - -module.exports = ProjectUnit; - - -/***/ }), -/* 716 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetMagnitude = __webpack_require__(304); - -/** - * [description] - * - * @function Phaser.Geom.Point.SetMagnitude - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} point - [description] - * @param {number} magnitude - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var SetMagnitude = function (point, magnitude) -{ - if (point.x !== 0 || point.y !== 0) - { - var m = GetMagnitude(point); - - point.x /= m; - point.y /= m; - } - - point.x *= magnitude; - point.y *= magnitude; - - return point; -}; - -module.exports = SetMagnitude; - - /***/ }), /* 717 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -102995,20 +99720,41 @@ module.exports = SetMagnitude; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Polygon = __webpack_require__(306); +/** + * [description] + * + * @function Phaser.Math.Easing.Stepped + * @since 3.0.0 + * + * @param {number} v - [description] + * @param {float} [steps=1] - [description] + * + * @return {number} [description] + */ +var Stepped = function (v, steps) +{ + if (steps === undefined) { steps = 1; } -Polygon.Clone = __webpack_require__(718); -Polygon.Contains = __webpack_require__(147); -Polygon.ContainsPoint = __webpack_require__(719); -Polygon.GetAABB = __webpack_require__(720); -Polygon.GetNumberArray = __webpack_require__(721); + if (v <= 0) + { + return 0; + } + else if (v >= 1) + { + return 1; + } + else + { + return (((steps * v) | 0) + 1) * (1 / steps); + } +}; -module.exports = Polygon; +module.exports = Stepped; /***/ }), /* 718 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -103016,29 +99762,38 @@ module.exports = Polygon; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Polygon = __webpack_require__(306); - /** * [description] * - * @function Phaser.Geom.Polygon.Clone + * @function Phaser.Math.Easing.Sine.InOut * @since 3.0.0 * - * @param {Phaser.Geom.Polygon} polygon - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Polygon} [description] + * @return {number} [description] */ -var Clone = function (polygon) +var InOut = function (v) { - return new Polygon(polygon.points); + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + return 0.5 * (1 - Math.cos(Math.PI * v)); + } }; -module.exports = Clone; +module.exports = InOut; /***/ }), /* 719 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -103046,30 +99801,38 @@ module.exports = Clone; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Contains = __webpack_require__(147); - /** * [description] * - * @function Phaser.Geom.Polygon.ContainsPoint + * @function Phaser.Math.Easing.Sine.Out * @since 3.0.0 * - * @param {Phaser.Geom.Polygon} polygon - [description] - * @param {Phaser.Geom.Point} point - [description] + * @param {number} v - [description] * - * @return {boolean} [description] + * @return {number} [description] */ -var ContainsPoint = function (polygon, point) +var Out = function (v) { - return Contains(polygon, point.x, point.y); + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + return Math.sin(v * Math.PI / 2); + } }; -module.exports = ContainsPoint; +module.exports = Out; /***/ }), /* 720 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -103077,48 +99840,33 @@ module.exports = ContainsPoint; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Rectangle = __webpack_require__(8); - /** * [description] * - * @function Phaser.Geom.Polygon.GetAABB + * @function Phaser.Math.Easing.Sine.In * @since 3.0.0 * - * @param {Phaser.Geom.Polygon} polygon - [description] - * @param {Phaser.Geom.Rectangle|object} [out] - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle|object} [description] + * @return {number} [description] */ -var GetAABB = function (polygon, out) +var In = function (v) { - if (out === undefined) { out = new Rectangle(); } - - var minX = Infinity; - var minY = Infinity; - var maxX = -minX; - var maxY = -minY; - var p; - - for (var i = 0; i < polygon.points.length; i++) + if (v === 0) { - p = polygon.points[i]; - - minX = Math.min(minX, p.x); - minY = Math.min(minY, p.y); - maxX = Math.max(maxX, p.x); - maxY = Math.max(maxY, p.y); + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + return 1 - Math.cos(v * Math.PI / 2); } - - out.x = minX; - out.y = minY; - out.width = maxX - minX; - out.height = maxY - minY; - - return out; }; -module.exports = GetAABB; +module.exports = In; /***/ }), @@ -103131,33 +99879,29 @@ module.exports = GetAABB; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Export the points as an array of flat numbers, following the sequence [ x,y, x,y, x,y ] - /** * [description] * - * @function Phaser.Geom.Polygon.GetNumberArray + * @function Phaser.Math.Easing.Quintic.InOut * @since 3.0.0 * - * @param {Phaser.Geom.Polygon} polygon - [description] - * @param {array} [output] - [description] + * @param {number} v - [description] * - * @return {number[]} [description] + * @return {number} [description] */ -var GetNumberArray = function (polygon, output) +var InOut = function (v) { - if (output === undefined) { output = []; } - - for (var i = 0; i < polygon.points.length; i++) + if ((v *= 2) < 1) { - output.push(polygon.points[i].x); - output.push(polygon.points[i].y); + return 0.5 * v * v * v * v * v; + } + else + { + return 0.5 * ((v -= 2) * v * v * v * v + 2); } - - return output; }; -module.exports = GetNumberArray; +module.exports = InOut; /***/ }), @@ -103173,19 +99917,19 @@ module.exports = GetNumberArray; /** * [description] * - * @function Phaser.Geom.Rectangle.Area + * @function Phaser.Math.Easing.Quintic.Out * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} v - [description] * * @return {number} [description] */ -var Area = function (rect) +var Out = function (v) { - return rect.width * rect.height; + return --v * v * v * v * v + 1; }; -module.exports = Area; +module.exports = Out; /***/ }), @@ -103201,22 +99945,19 @@ module.exports = Area; /** * [description] * - * @function Phaser.Geom.Rectangle.Ceil + * @function Phaser.Math.Easing.Quintic.In * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var Ceil = function (rect) +var In = function (v) { - rect.x = Math.ceil(rect.x); - rect.y = Math.ceil(rect.y); - - return rect; + return v * v * v * v * v; }; -module.exports = Ceil; +module.exports = In; /***/ }), @@ -103232,29 +99973,31 @@ module.exports = Ceil; /** * [description] * - * @function Phaser.Geom.Rectangle.CeilAll + * @function Phaser.Math.Easing.Quartic.InOut * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var CeilAll = function (rect) +var InOut = function (v) { - rect.x = Math.ceil(rect.x); - rect.y = Math.ceil(rect.y); - rect.width = Math.ceil(rect.width); - rect.height = Math.ceil(rect.height); - - return rect; + if ((v *= 2) < 1) + { + return 0.5 * v * v * v * v; + } + else + { + return -0.5 * ((v -= 2) * v * v * v - 2); + } }; -module.exports = CeilAll; +module.exports = InOut; /***/ }), /* 725 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -103262,29 +100005,27 @@ module.exports = CeilAll; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Rectangle = __webpack_require__(8); - /** * [description] * - * @function Phaser.Geom.Rectangle.Clone + * @function Phaser.Math.Easing.Quartic.Out * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} source - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var Clone = function (source) +var Out = function (v) { - return new Rectangle(source.x, source.y, source.width, source.height); + return 1 - (--v * v * v * v); }; -module.exports = Clone; +module.exports = Out; /***/ }), /* 726 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -103292,25 +100033,22 @@ module.exports = Clone; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Contains = __webpack_require__(33); - /** * [description] * - * @function Phaser.Geom.Rectangle.ContainsPoint + * @function Phaser.Math.Easing.Quartic.In * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Point} point - [description] + * @param {number} v - [description] * - * @return {boolean} [description] + * @return {number} [description] */ -var ContainsPoint = function (rect, point) +var In = function (v) { - return Contains(rect, point.x, point.y); + return v * v * v * v; }; -module.exports = ContainsPoint; +module.exports = In; /***/ }), @@ -103323,36 +100061,29 @@ module.exports = ContainsPoint; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Checks if rectB is fully contained within rectA - /** * [description] * - * @function Phaser.Geom.Rectangle.ContainsRect + * @function Phaser.Math.Easing.Quadratic.InOut * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] + * @param {number} v - [description] * - * @return {boolean} [description] + * @return {number} [description] */ -var ContainsRect = function (rectA, rectB) +var InOut = function (v) { - // Volume check (if rectB volume > rectA then rectA cannot contain it) - if ((rectB.width * rectB.height) > (rectA.width * rectA.height)) + if ((v *= 2) < 1) { - return false; + return 0.5 * v * v; + } + else + { + return -0.5 * (--v * (v - 2) - 1); } - - return ( - (rectB.x > rectA.x && rectB.x < rectA.right) && - (rectB.right > rectA.x && rectB.right < rectA.right) && - (rectB.y > rectA.y && rectB.y < rectA.bottom) && - (rectB.bottom > rectA.y && rectB.bottom < rectA.bottom) - ); }; -module.exports = ContainsRect; +module.exports = InOut; /***/ }), @@ -103368,20 +100099,19 @@ module.exports = ContainsRect; /** * [description] * - * @function Phaser.Geom.Rectangle.CopyFrom + * @function Phaser.Math.Easing.Quadratic.Out * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} source - [description] - * @param {Phaser.Geom.Rectangle} dest - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var CopyFrom = function (source, dest) +var Out = function (v) { - return dest.setTo(source.x, source.y, source.width, source.height); + return v * (2 - v); }; -module.exports = CopyFrom; +module.exports = Out; /***/ }), @@ -103397,30 +100127,24 @@ module.exports = CopyFrom; /** * [description] * - * @function Phaser.Geom.Rectangle.Equals + * @function Phaser.Math.Easing.Quadratic.In * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Rectangle} toCompare - [description] + * @param {number} v - [description] * - * @return {boolean} [description] + * @return {number} [description] */ -var Equals = function (rect, toCompare) +var In = function (v) { - return ( - rect.x === toCompare.x && - rect.y === toCompare.y && - rect.width === toCompare.width && - rect.height === toCompare.height - ); + return v * v; }; -module.exports = Equals; +module.exports = In; /***/ }), /* 730 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -103428,50 +100152,27 @@ module.exports = Equals; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetAspectRatio = __webpack_require__(148); - -// Fits the target rectangle into the source rectangle. -// Preserves aspect ratio. -// Scales and centers the target rectangle to the source rectangle - /** * [description] * - * @function Phaser.Geom.Rectangle.FitInside + * @function Phaser.Math.Easing.Linear * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} target - [description] - * @param {Phaser.Geom.Rectangle} source - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var FitInside = function (target, source) +var Linear = function (v) { - var ratio = GetAspectRatio(target); - - if (ratio < GetAspectRatio(source)) - { - // Taller than Wide - target.setSize(source.height * ratio, source.height); - } - else - { - // Wider than Tall - target.setSize(source.width, source.width / ratio); - } - - return target.setPosition( - source.centerX - (target.width / 2), - source.centerY - (target.height / 2) - ); + return v; }; -module.exports = FitInside; +module.exports = Linear; /***/ }), /* 731 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -103479,45 +100180,29 @@ module.exports = FitInside; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetAspectRatio = __webpack_require__(148); - -// Fits the target rectangle around the source rectangle. -// Preserves aspect ration. -// Scales and centers the target rectangle to the source rectangle - /** * [description] * - * @function Phaser.Geom.Rectangle.FitOutside + * @function Phaser.Math.Easing.Expo.InOut * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} target - [description] - * @param {Phaser.Geom.Rectangle} source - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var FitOutside = function (target, source) +var InOut = function (v) { - var ratio = GetAspectRatio(target); - - if (ratio > GetAspectRatio(source)) + if ((v *= 2) < 1) { - // Wider than Tall - target.setSize(source.height * ratio, source.height); + return 0.5 * Math.pow(2, 10 * (v - 1)); } else { - // Taller than Wide - target.setSize(source.width, source.width / ratio); + return 0.5 * (2 - Math.pow(2, -10 * (v - 1))); } - - return target.setPosition( - source.centerX - target.width / 2, - source.centerY - target.height / 2 - ); }; -module.exports = FitOutside; +module.exports = InOut; /***/ }), @@ -103533,22 +100218,19 @@ module.exports = FitOutside; /** * [description] * - * @function Phaser.Geom.Rectangle.Floor + * @function Phaser.Math.Easing.Expo.Out * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var Floor = function (rect) +var Out = function (v) { - rect.x = Math.floor(rect.x); - rect.y = Math.floor(rect.y); - - return rect; + return 1 - Math.pow(2, -10 * v); }; -module.exports = Floor; +module.exports = Out; /***/ }), @@ -103564,29 +100246,24 @@ module.exports = Floor; /** * [description] * - * @function Phaser.Geom.Rectangle.FloorAll + * @function Phaser.Math.Easing.Expo.In * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var FloorAll = function (rect) +var In = function (v) { - rect.x = Math.floor(rect.x); - rect.y = Math.floor(rect.y); - rect.width = Math.floor(rect.width); - rect.height = Math.floor(rect.height); - - return rect; + return Math.pow(2, 10 * (v - 1)) - 0.001; }; -module.exports = FloorAll; +module.exports = In; /***/ }), /* 734 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -103594,37 +100271,61 @@ module.exports = FloorAll; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); - -// The center of the Rectangle object, expressed as a Point object - /** * [description] * - * @function Phaser.Geom.Rectangle.GetCenter + * @function Phaser.Math.Easing.Elastic.InOut * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Point|object} [out] - [description] + * @param {number} v - [description] + * @param {float} [amplitude=0.1] - [description] + * @param {float} [period=0.1] - [description] * - * @return {Phaser.Geom.Point|object} [description] + * @return {number} [description] */ -var GetCenter = function (rect, out) +var InOut = function (v, amplitude, period) { - if (out === undefined) { out = new Point(); } + if (amplitude === undefined) { amplitude = 0.1; } + if (period === undefined) { period = 0.1; } - out.x = rect.centerX; - out.y = rect.centerY; + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + var s = period / 4; - return out; + if (amplitude < 1) + { + amplitude = 1; + } + else + { + s = period * Math.asin(1 / amplitude) / (2 * Math.PI); + } + + if ((v *= 2) < 1) + { + return -0.5 * (amplitude * Math.pow(2, 10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period)); + } + else + { + return amplitude * Math.pow(2, -10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period) * 0.5 + 1; + } + } }; -module.exports = GetCenter; +module.exports = InOut; /***/ }), /* 735 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -103632,38 +100333,54 @@ module.exports = GetCenter; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); - -// The size of the Rectangle object, expressed as a Point object -// with the values of the width and height properties. - /** * [description] * - * @function Phaser.Geom.Rectangle.GetSize + * @function Phaser.Math.Easing.Elastic.Out * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Point|object} [out] - [description] + * @param {number} v - [description] + * @param {float} [amplitude=0.1] - [description] + * @param {float} [period=0.1] - [description] * - * @return {Phaser.Geom.Point|object} [description] + * @return {number} [description] */ -var GetSize = function (rect, out) +var Out = function (v, amplitude, period) { - if (out === undefined) { out = new Point(); } + if (amplitude === undefined) { amplitude = 0.1; } + if (period === undefined) { period = 0.1; } - out.x = rect.width; - out.y = rect.height; + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + var s = period / 4; - return out; + if (amplitude < 1) + { + amplitude = 1; + } + else + { + s = period * Math.asin(1 / amplitude) / (2 * Math.PI); + } + + return (amplitude * Math.pow(2, -10 * v) * Math.sin((v - s) * (2 * Math.PI) / period) + 1); + } }; -module.exports = GetSize; +module.exports = Out; /***/ }), /* 736 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -103671,35 +100388,49 @@ module.exports = GetSize; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CenterOn = __webpack_require__(308); - -// Increases the size of the Rectangle object by the specified amounts. -// The center point of the Rectangle object stays the same, and its size increases -// to the left and right by the x value, and to the top and the bottom by the y value. - /** * [description] * - * @function Phaser.Geom.Rectangle.Inflate + * @function Phaser.Math.Easing.Elastic.In * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] + * @param {number} v - [description] + * @param {float} [amplitude=0.1] - [description] + * @param {float} [period=0.1] - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var Inflate = function (rect, x, y) +var In = function (v, amplitude, period) { - var cx = rect.centerX; - var cy = rect.centerY; + if (amplitude === undefined) { amplitude = 0.1; } + if (period === undefined) { period = 0.1; } - rect.setSize(rect.width + (x * 2), rect.height + (y * 2)); + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + var s = period / 4; - return CenterOn(rect, cx, cy); + if (amplitude < 1) + { + amplitude = 1; + } + else + { + s = period * Math.asin(1 / amplitude) / (2 * Math.PI); + } + + return -(amplitude * Math.pow(2, 10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period)); + } }; -module.exports = Inflate; +module.exports = In; /***/ }), @@ -103712,44 +100443,29 @@ module.exports = Inflate; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Merges the target Rectangle with a list of points. -// The points is an array of objects with public x/y properties. - /** * [description] * - * @function Phaser.Geom.Rectangle.MergePoints + * @function Phaser.Math.Easing.Cubic.InOut * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} target - [description] - * @param {Phaser.Geom.Point[]} points - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var MergePoints = function (target, points) +var InOut = function (v) { - var minX = target.x; - var maxX = target.right; - var minY = target.y; - var maxY = target.bottom; - - for (var i = 0; i < points.length; i++) + if ((v *= 2) < 1) { - minX = Math.min(minX, points[i].x); - maxX = Math.max(maxX, points[i].x); - minY = Math.min(minY, points[i].y); - maxY = Math.max(maxY, points[i].y); + return 0.5 * v * v * v; + } + else + { + return 0.5 * ((v -= 2) * v * v + 2); } - - target.x = minX; - target.y = minY; - target.width = maxX - minX; - target.height = maxY - minY; - - return target; }; -module.exports = MergePoints; +module.exports = InOut; /***/ }), @@ -103762,38 +100478,22 @@ module.exports = MergePoints; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Merges source rectangle into target rectangle and returns target -// Neither rect should have negative widths or heights - /** * [description] * - * @function Phaser.Geom.Rectangle.MergeRect + * @function Phaser.Math.Easing.Cubic.Out * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} target - [description] - * @param {Phaser.Geom.Rectangle} source - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var MergeRect = function (target, source) +var Out = function (v) { - var minX = Math.min(target.x, source.x); - var maxX = Math.max(target.right, source.right); - - target.x = minX; - target.width = maxX - minX; - - var minY = Math.min(target.y, source.y); - var maxY = Math.max(target.bottom, source.bottom); - - target.y = minY; - target.height = maxY - minY; - - return target; + return --v * v * v + 1; }; -module.exports = MergeRect; +module.exports = Out; /***/ }), @@ -103809,33 +100509,19 @@ module.exports = MergeRect; /** * [description] * - * @function Phaser.Geom.Rectangle.MergeXY + * @function Phaser.Math.Easing.Cubic.In * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} target - [description] - * @param {number} x - [description] - * @param {number} y - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var MergeXY = function (target, x, y) +var In = function (v) { - var minX = Math.min(target.x, x); - var maxX = Math.max(target.right, x); - - target.x = minX; - target.width = maxX - minX; - - var minY = Math.min(target.y, y); - var maxY = Math.max(target.bottom, y); - - target.y = minY; - target.height = maxY - minY; - - return target; + return v * v * v; }; -module.exports = MergeXY; +module.exports = In; /***/ }), @@ -103851,24 +100537,26 @@ module.exports = MergeXY; /** * [description] * - * @function Phaser.Geom.Rectangle.Offset + * @function Phaser.Math.Easing.Circular.InOut * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var Offset = function (rect, x, y) +var InOut = function (v) { - rect.x += x; - rect.y += y; - - return rect; + if ((v *= 2) < 1) + { + return -0.5 * (Math.sqrt(1 - v * v) - 1); + } + else + { + return 0.5 * (Math.sqrt(1 - (v -= 2) * v) + 1); + } }; -module.exports = Offset; +module.exports = InOut; /***/ }), @@ -103884,23 +100572,19 @@ module.exports = Offset; /** * [description] * - * @function Phaser.Geom.Rectangle.OffsetPoint + * @function Phaser.Math.Easing.Circular.Out * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Point} point - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var OffsetPoint = function (rect, point) +var Out = function (v) { - rect.x += point.x; - rect.y += point.y; - - return rect; + return Math.sqrt(1 - (--v * v)); }; -module.exports = OffsetPoint; +module.exports = Out; /***/ }), @@ -103916,30 +100600,24 @@ module.exports = OffsetPoint; /** * [description] * - * @function Phaser.Geom.Rectangle.Overlaps + * @function Phaser.Math.Easing.Circular.In * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] + * @param {number} v - [description] * - * @return {boolean} [description] + * @return {number} [description] */ -var Overlaps = function (rectA, rectB) +var In = function (v) { - return ( - rectA.x < rectB.right && - rectA.right > rectB.x && - rectA.y < rectB.bottom && - rectA.bottom > rectB.y - ); + return 1 - Math.sqrt(1 - v * v); }; -module.exports = Overlaps; +module.exports = In; /***/ }), /* 743 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -103947,49 +100625,58 @@ module.exports = Overlaps; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); -var DegToRad = __webpack_require__(35); - /** * [description] * - * @function Phaser.Geom.Rectangle.PerimeterPoint + * @function Phaser.Math.Easing.Bounce.InOut * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rectangle - [description] - * @param {integer} angle - [description] - * @param {Phaser.Geom.Point} [out] - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Point} [description] + * @return {number} [description] */ -var PerimeterPoint = function (rectangle, angle, out) +var InOut = function (v) { - if (out === undefined) { out = new Point(); } + var reverse = false; - angle = DegToRad(angle); - - var s = Math.sin(angle); - var c = Math.cos(angle); - - var dx = (c > 0) ? rectangle.width / 2 : rectangle.width / -2; - var dy = (s > 0) ? rectangle.height / 2 : rectangle.height / -2; - - if (Math.abs(dx * s) < Math.abs(dy * c)) + if (v < 0.5) { - dy = (dx * s) / c; + v = 1 - (v * 2); + reverse = true; } else { - dx = (dy * c) / s; + v = (v * 2) - 1; } - out.x = dx + rectangle.centerX; - out.y = dy + rectangle.centerY; + if (v < 1 / 2.75) + { + v = 7.5625 * v * v; + } + else if (v < 2 / 2.75) + { + v = 7.5625 * (v -= 1.5 / 2.75) * v + 0.75; + } + else if (v < 2.5 / 2.75) + { + v = 7.5625 * (v -= 2.25 / 2.75) * v + 0.9375; + } + else + { + v = 7.5625 * (v -= 2.625 / 2.75) * v + 0.984375; + } - return out; + if (reverse) + { + return (1 - v) * 0.5; + } + else + { + return v * 0.5 + 0.5; + } }; -module.exports = PerimeterPoint; +module.exports = InOut; /***/ }), @@ -104002,36 +100689,42 @@ module.exports = PerimeterPoint; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Scales the width and height of this Rectangle by the given amounts. - /** * [description] * - * @function Phaser.Geom.Rectangle.Scale + * @function Phaser.Math.Easing.Bounce.Out * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var Scale = function (rect, x, y) +var Out = function (v) { - if (y === undefined) { y = x; } - - rect.width *= x; - rect.height *= y; - - return rect; + if (v < 1 / 2.75) + { + return 7.5625 * v * v; + } + else if (v < 2 / 2.75) + { + return 7.5625 * (v -= 1.5 / 2.75) * v + 0.75; + } + else if (v < 2.5 / 2.75) + { + return 7.5625 * (v -= 2.25 / 2.75) * v + 0.9375; + } + else + { + return 7.5625 * (v -= 2.625 / 2.75) * v + 0.984375; + } }; -module.exports = Scale; +module.exports = Out; /***/ }), /* 745 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -104039,41 +100732,44 @@ module.exports = Scale; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Rectangle = __webpack_require__(8); - /** * [description] * - * @function Phaser.Geom.Rectangle.Union + * @function Phaser.Math.Easing.Bounce.In * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] - * @param {Phaser.Geom.Rectangle} [out] - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var Union = function (rectA, rectB, out) +var In = function (v) { - if (out === undefined) { out = new Rectangle(); } + v = 1 - v; - var x = Math.min(rectA.x, rectB.x); - var y = Math.min(rectA.y, rectB.y); - - return out.setTo( - x, - y, - Math.max(rectA.right, rectB.right) - x, - Math.max(rectA.bottom, rectB.bottom) - y - ); + if (v < 1 / 2.75) + { + return 1 - (7.5625 * v * v); + } + else if (v < 2 / 2.75) + { + return 1 - (7.5625 * (v -= 1.5 / 2.75) * v + 0.75); + } + else if (v < 2.5 / 2.75) + { + return 1 - (7.5625 * (v -= 2.25 / 2.75) * v + 0.9375); + } + else + { + return 1 - (7.5625 * (v -= 2.625 / 2.75) * v + 0.984375); + } }; -module.exports = Union; +module.exports = In; /***/ }), /* 746 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -104081,34 +100777,34 @@ module.exports = Union; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Triangle = __webpack_require__(56); +/** + * [description] + * + * @function Phaser.Math.Easing.Back.InOut + * @since 3.0.0 + * + * @param {number} v - [description] + * @param {number} [overshoot=1.70158] - [description] + * + * @return {number} [description] + */ +var InOut = function (v, overshoot) +{ + if (overshoot === undefined) { overshoot = 1.70158; } -Triangle.Area = __webpack_require__(747); -Triangle.BuildEquilateral = __webpack_require__(748); -Triangle.BuildFromPolygon = __webpack_require__(749); -Triangle.BuildRight = __webpack_require__(750); -Triangle.CenterOn = __webpack_require__(751); -Triangle.Centroid = __webpack_require__(311); -Triangle.CircumCenter = __webpack_require__(752); -Triangle.CircumCircle = __webpack_require__(753); -Triangle.Clone = __webpack_require__(754); -Triangle.Contains = __webpack_require__(54); -Triangle.ContainsArray = __webpack_require__(145); -Triangle.ContainsPoint = __webpack_require__(755); -Triangle.CopyFrom = __webpack_require__(756); -Triangle.Decompose = __webpack_require__(300); -Triangle.Equals = __webpack_require__(757); -Triangle.GetPoint = __webpack_require__(309); -Triangle.GetPoints = __webpack_require__(310); -Triangle.InCenter = __webpack_require__(313); -Triangle.Perimeter = __webpack_require__(758); -Triangle.Offset = __webpack_require__(312); -Triangle.Random = __webpack_require__(112); -Triangle.Rotate = __webpack_require__(759); -Triangle.RotateAroundPoint = __webpack_require__(760); -Triangle.RotateAroundXY = __webpack_require__(149); + var s = overshoot * 1.525; -module.exports = Triangle; + if ((v *= 2) < 1) + { + return 0.5 * (v * v * ((s + 1) * v - s)); + } + else + { + return 0.5 * ((v -= 2) * v * ((s + 1) * v + s) + 2); + } +}; + +module.exports = InOut; /***/ }), @@ -104121,38 +100817,30 @@ module.exports = Triangle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// The 2D area of a triangle. The area value is always non-negative. - /** * [description] * - * @function Phaser.Geom.Triangle.Area + * @function Phaser.Math.Easing.Back.Out * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} v - [description] + * @param {number} [overshoot=1.70158] - [description] * * @return {number} [description] */ -var Area = function (triangle) +var Out = function (v, overshoot) { - var x1 = triangle.x1; - var y1 = triangle.y1; + if (overshoot === undefined) { overshoot = 1.70158; } - var x2 = triangle.x2; - var y2 = triangle.y2; - - var x3 = triangle.x3; - var y3 = triangle.y3; - - return Math.abs(((x3 - x1) * (y2 - y1) - (x2 - x1) * (y3 - y1)) / 2); + return --v * v * ((overshoot + 1) * v + overshoot) + 1; }; -module.exports = Area; +module.exports = Out; /***/ }), /* 748 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -104160,44 +100848,25 @@ module.exports = Area; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Triangle = __webpack_require__(56); - -// Builds an equilateral triangle. -// In the equilateral triangle, all the sides are the same length (congruent) -// and all the angles are the same size (congruent). - -// The x/y specifies the top-middle of the triangle (x1/y1) and length -// is the length of each side - /** * [description] * - * @function Phaser.Geom.Triangle.BuildEquilateral + * @function Phaser.Math.Easing.Back.In * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} length - [description] + * @param {number} v - [description] + * @param {number} [overshoot=1.70158] - [description] * - * @return {Phaser.Geom.Triangle} [description] + * @return {number} [description] */ -var BuildEquilateral = function (x, y, length) +var In = function (v, overshoot) { - var height = length * (Math.sqrt(3) / 2); + if (overshoot === undefined) { overshoot = 1.70158; } - var x1 = x; - var y1 = y; - - var x2 = x + (length / 2); - var y2 = y + height; - - var x3 = x - (length / 2); - var y3 = y + height; - - return new Triangle(x1, y1, x2, y2, x3, y3); + return v * v * ((overshoot + 1) * v - overshoot); }; -module.exports = BuildEquilateral; +module.exports = In; /***/ }), @@ -104210,68 +100879,76 @@ module.exports = BuildEquilateral; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var EarCut = __webpack_require__(238); -var Triangle = __webpack_require__(56); +var Back = __webpack_require__(262); +var Bounce = __webpack_require__(261); +var Circular = __webpack_require__(260); +var Cubic = __webpack_require__(259); +var Elastic = __webpack_require__(258); +var Expo = __webpack_require__(257); +var Linear = __webpack_require__(256); +var Quadratic = __webpack_require__(255); +var Quartic = __webpack_require__(254); +var Quintic = __webpack_require__(253); +var Sine = __webpack_require__(252); +var Stepped = __webpack_require__(251); -/** - * [description] - * - * @function Phaser.Geom.Triangle.BuildFromPolygon - * @since 3.0.0 - * - * @param {array} data - A flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...] - * @param {array} [?holes] - An array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). - * @param {float} [scaleX=1] - [description] - * @param {float} [scaleY=1] - [description] - * @param {array} [out] - [description] - * - * @return {Phaser.Geom.Triangle[]} [description] - */ -var BuildFromPolygon = function (data, holes, scaleX, scaleY, out) -{ - if (holes === undefined) { holes = null; } - if (scaleX === undefined) { scaleX = 1; } - if (scaleY === undefined) { scaleY = 1; } - if (out === undefined) { out = []; } +// EaseMap +module.exports = { - var tris = EarCut(data, holes); + Power0: Linear, + Power1: Quadratic.Out, + Power2: Cubic.Out, + Power3: Quartic.Out, + Power4: Quintic.Out, - var a; - var b; - var c; + Linear: Linear, + Quad: Quadratic.Out, + Cubic: Cubic.Out, + Quart: Quartic.Out, + Quint: Quintic.Out, + Sine: Sine.Out, + Expo: Expo.Out, + Circ: Circular.Out, + Elastic: Elastic.Out, + Back: Back.Out, + Bounce: Bounce.Out, + Stepped: Stepped, - var x1; - var y1; + 'Quad.easeIn': Quadratic.In, + 'Cubic.easeIn': Cubic.In, + 'Quart.easeIn': Quartic.In, + 'Quint.easeIn': Quintic.In, + 'Sine.easeIn': Sine.In, + 'Expo.easeIn': Expo.In, + 'Circ.easeIn': Circular.In, + 'Elastic.easeIn': Elastic.In, + 'Back.easeIn': Back.In, + 'Bounce.easeIn': Bounce.In, - var x2; - var y2; + 'Quad.easeOut': Quadratic.Out, + 'Cubic.easeOut': Cubic.Out, + 'Quart.easeOut': Quartic.Out, + 'Quint.easeOut': Quintic.Out, + 'Sine.easeOut': Sine.Out, + 'Expo.easeOut': Expo.Out, + 'Circ.easeOut': Circular.Out, + 'Elastic.easeOut': Elastic.Out, + 'Back.easeOut': Back.Out, + 'Bounce.easeOut': Bounce.Out, - var x3; - var y3; + 'Quad.easeInOut': Quadratic.InOut, + 'Cubic.easeInOut': Cubic.InOut, + 'Quart.easeInOut': Quartic.InOut, + 'Quint.easeInOut': Quintic.InOut, + 'Sine.easeInOut': Sine.InOut, + 'Expo.easeInOut': Expo.InOut, + 'Circ.easeInOut': Circular.InOut, + 'Elastic.easeInOut': Elastic.InOut, + 'Back.easeInOut': Back.InOut, + 'Bounce.easeInOut': Bounce.InOut - for (var i = 0; i < tris.length; i += 3) - { - a = tris[i]; - b = tris[i + 1]; - c = tris[i + 2]; - - x1 = data[a * 2] * scaleX; - y1 = data[(a * 2) + 1] * scaleY; - - x2 = data[b * 2] * scaleX; - y2 = data[(b * 2) + 1] * scaleY; - - x3 = data[c * 2] * scaleX; - y3 = data[(c * 2) + 1] * scaleY; - - out.push(new Triangle(x1, y1, x2, y2, x3, y3)); - } - - return out; }; -module.exports = BuildFromPolygon; - /***/ }), /* 750 */ @@ -104283,43 +100960,576 @@ module.exports = BuildFromPolygon; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Triangle = __webpack_require__(56); - -// Builds a right triangle, with one 90 degree angle and two acute angles -// The x/y is the coordinate of the 90 degree angle (and will map to x1/y1 in the resulting Triangle) -// w/h can be positive or negative and represent the length of each side +var Class = __webpack_require__(0); +var FloatBetween = __webpack_require__(263); +var GetEaseFunction = __webpack_require__(71); +var GetFastValue = __webpack_require__(2); +var Wrap = __webpack_require__(43); /** + * The returned value sets what the property will be at the START of the particles life, on emit. + * @callback EmitterOpOnEmitCallback + * + * @param {Phaser.GameObjects.Particles.Particle} particle - [description] + * @param {string} key - [description] + * @param {number} value - [description] + * + * @return {number} [description] + */ + +/** + * The returned value updates the property for the duration of the particles life. + * @callback EmitterOpOnUpdateCallback + * + * @param {Phaser.GameObjects.Particles.Particle} particle - [description] + * @param {string} key - [description] + * @param {float} t - The T value (between 0 and 1) + * @param {number} value - [description] + * + * @return {number} [description] + */ + +/** + * @classdesc * [description] * - * @function Phaser.Geom.Triangle.BuildRight + * @class EmitterOp + * @memberOf Phaser.GameObjects.Particles + * @constructor * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Geom.Triangle} [description] + * @param {object} config - [description] + * @param {string} key - [description] + * @param {number} defaultValue - [description] + * @param {boolean} [emitOnly=false] - [description] */ -var BuildRight = function (x, y, width, height) -{ - if (height === undefined) { height = width; } +var EmitterOp = new Class({ - // 90 degree angle - var x1 = x; - var y1 = y; + initialize: - var x2 = x; - var y2 = y - height; + function EmitterOp (config, key, defaultValue, emitOnly) + { + if (emitOnly === undefined) { emitOnly = false; } - var x3 = x + width; - var y3 = y; + /** + * [description] + * + * @name Phaser.GameObjects.Particles.EmitterOp#propertyKey + * @type {string} + * @since 3.0.0 + */ + this.propertyKey = key; - return new Triangle(x1, y1, x2, y2, x3, y3); -}; + /** + * [description] + * + * @name Phaser.GameObjects.Particles.EmitterOp#propertyValue + * @type {number} + * @since 3.0.0 + */ + this.propertyValue = defaultValue; -module.exports = BuildRight; + /** + * [description] + * + * @name Phaser.GameObjects.Particles.EmitterOp#defaultValue + * @type {number} + * @since 3.0.0 + */ + this.defaultValue = defaultValue; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.EmitterOp#steps + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.steps = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.EmitterOp#counter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.counter = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.EmitterOp#start + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.start = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.EmitterOp#end + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.end = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.EmitterOp#ease + * @type {?function} + * @since 3.0.0 + */ + this.ease; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.EmitterOp#emitOnly + * @type {boolean} + * @since 3.0.0 + */ + this.emitOnly = emitOnly; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.EmitterOp#onEmit + * @type {EmitterOpOnEmitCallback} + * @since 3.0.0 + */ + this.onEmit = this.defaultEmit; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.EmitterOp#onUpdate + * @type {EmitterOpOnUpdateCallback} + * @since 3.0.0 + */ + this.onUpdate = this.defaultUpdate; + + this.loadConfig(config); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#loadConfig + * @since 3.0.0 + * + * @param {object} config - [description] + * @param {string} newKey - [description] + */ + loadConfig: function (config, newKey) + { + if (config === undefined) { config = {}; } + + if (newKey) + { + this.propertyKey = newKey; + } + + this.propertyValue = GetFastValue(config, this.propertyKey, this.defaultValue); + + this.setMethods(); + + if (this.emitOnly) + { + // Reset it back again + this.onUpdate = this.defaultUpdate; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#toJSON + * @since 3.0.0 + * + * @return {object} [description] + */ + toJSON: function () + { + return JSON.stringify(this.propertyValue); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#onChange + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.EmitterOp} This Emitter Op object. + */ + onChange: function (value) + { + this.propertyValue = value; + + return this.setMethods(); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#setMethods + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.EmitterOp} This Emitter Op object. + */ + setMethods: function () + { + var value = this.propertyValue; + + var t = typeof(value); + + if (t === 'number') + { + // Explicit static value: + // x: 400 + + this.onEmit = this.staticValueEmit; + this.onUpdate = this.staticValueUpdate; + } + else if (Array.isArray(value)) + { + // Picks a random element from the array: + // x: [ 100, 200, 300, 400 ] + + this.onEmit = this.randomStaticValueEmit; + } + else if (t === 'function') + { + // The same as setting just the onUpdate function and no onEmit (unless this op is an emitOnly one) + // Custom callback, must return a value: + + /* + x: function (particle, key, t, value) + { + return value + 50; + } + */ + + if (this.emitOnly) + { + this.onEmit = value; + } + else + { + this.onUpdate = value; + } + } + else if (t === 'object' && (this.has(value, 'random') || this.hasBoth(value, 'start', 'end') || this.hasBoth(value, 'min', 'max'))) + { + this.start = (this.has(value, 'start')) ? value.start : value.min; + this.end = (this.has(value, 'end')) ? value.end : value.max; + + var isRandom = (this.hasBoth(value, 'min', 'max') || this.has(value, 'random')); + + // A random starting value (using 'min | max' instead of 'start | end' automatically implies a random value) + + // x: { start: 100, end: 400, random: true } OR { min: 100, max: 400 } OR { random: [ 100, 400 ] } + + if (isRandom) + { + var rnd = value.random; + + // x: { random: [ 100, 400 ] } = the same as doing: x: { start: 100, end: 400, random: true } + if (Array.isArray(rnd)) + { + this.start = rnd[0]; + this.end = rnd[1]; + } + + this.onEmit = this.randomRangedValueEmit; + } + + if (this.has(value, 'steps')) + { + // A stepped (per emit) range + + // x: { start: 100, end: 400, steps: 64 } + + // Increments a value stored in the emitter + + this.steps = value.steps; + this.counter = this.start; + + this.onEmit = this.steppedEmit; + } + else + { + // An eased range (defaults to Linear if not specified) + + // x: { start: 100, end: 400, [ ease: 'Linear' ] } + + var easeType = (this.has(value, 'ease')) ? value.ease : 'Linear'; + + this.ease = GetEaseFunction(easeType); + + if (!isRandom) + { + this.onEmit = this.easedValueEmit; + } + + this.onUpdate = this.easeValueUpdate; + } + } + else if (t === 'object' && this.hasEither(value, 'onEmit', 'onUpdate')) + { + // Custom onEmit and onUpdate callbacks + + /* + x: { + // Called at the start of the particles life, when it is being created + onEmit: function (particle, key, t, value) + { + return value; + }, + + // Called during the particles life on each update + onUpdate: function (particle, key, t, value) + { + return value; + } + } + */ + + if (this.has(value, 'onEmit')) + { + this.onEmit = value.onEmit; + } + + if (this.has(value, 'onUpdate')) + { + this.onUpdate = value.onUpdate; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#has + * @since 3.0.0 + * + * @param {object} object - [description] + * @param {string} key - [description] + * + * @return {boolean} [description] + */ + has: function (object, key) + { + return (object.hasOwnProperty(key)); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#hasBoth + * @since 3.0.0 + * + * @param {object} object - [description] + * @param {string} key1 - [description] + * @param {string} key2 - [description] + * + * @return {boolean} [description] + */ + hasBoth: function (object, key1, key2) + { + return (object.hasOwnProperty(key1) && object.hasOwnProperty(key2)); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#hasEither + * @since 3.0.0 + * + * @param {object} object - [description] + * @param {string} key1 - [description] + * @param {string} key2 - [description] + * + * @return {boolean} [description] + */ + hasEither: function (object, key1, key2) + { + return (object.hasOwnProperty(key1) || object.hasOwnProperty(key2)); + }, + + /** + * The returned value sets what the property will be at the START of the particles life, on emit. + * + * @method Phaser.GameObjects.Particles.EmitterOp#defaultEmit + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - [description] + * @param {string} key - [description] + * @param {number} value - [description] + * + * @return {number} [description] + */ + defaultEmit: function (particle, key, value) + { + return value; + }, + + /** + * The returned value updates the property for the duration of the particles life. + * + * @method Phaser.GameObjects.Particles.EmitterOp#defaultUpdate + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - [description] + * @param {string} key - [description] + * @param {float} t - The T value (between 0 and 1) + * @param {number} value - [description] + * + * @return {number} [description] + */ + defaultUpdate: function (particle, key, t, value) + { + return value; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#staticValueEmit + * @since 3.0.0 + * + * @return {number} [description] + */ + staticValueEmit: function () + { + return this.propertyValue; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#staticValueUpdate + * @since 3.0.0 + * + * @return {number} [description] + */ + staticValueUpdate: function () + { + return this.propertyValue; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#randomStaticValueEmit + * @since 3.0.0 + * + * @return {number} [description] + */ + randomStaticValueEmit: function () + { + var randomIndex = Math.floor(Math.random() * this.propertyValue.length); + + return this.propertyValue[randomIndex]; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#randomRangedValueEmit + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - [description] + * @param {string} key - [description] + * + * @return {number} [description] + */ + randomRangedValueEmit: function (particle, key) + { + var value = FloatBetween(this.start, this.end); + + if (particle && particle.data[key]) + { + particle.data[key].min = value; + } + + return value; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#steppedEmit + * @since 3.0.0 + * + * @return {number} [description] + */ + steppedEmit: function () + { + var current = this.counter; + + var next = this.counter + ((this.end - this.start) / this.steps); + + this.counter = Wrap(next, this.start, this.end); + + return current; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#easedValueEmit + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - [description] + * @param {string} key - [description] + * + * @return {number} [description] + */ + easedValueEmit: function (particle, key) + { + if (particle && particle.data[key]) + { + var data = particle.data[key]; + + data.min = this.start; + data.max = this.end; + } + + return this.start; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#easeValueUpdate + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - [description] + * @param {string} key - [description] + * @param {float} t - The T value (between 0 and 1) + * + * @return {number} [description] + */ + easeValueUpdate: function (particle, key, t) + { + var data = particle.data[key]; + + return (data.max - data.min) * this.ease(t) + data.min; + } + +}); + +module.exports = EmitterOp; /***/ }), @@ -104332,42 +101542,238 @@ module.exports = BuildRight; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Centroid = __webpack_require__(311); -var Offset = __webpack_require__(312); +var Class = __webpack_require__(0); /** + * @classdesc * [description] * - * @function Phaser.Geom.Triangle.CenterOn + * @class EdgeZone + * @memberOf Phaser.GameObjects.Particles.Zones + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {function} [centerFunc] - [description] - * - * @return {Phaser.Geom.Triangle} [description] + * @param {object} source - [description] + * @param {number} quantity - [description] + * @param {number} stepRate - [description] + * @param {boolean} yoyo - [description] + * @param {boolean} seamless - [description] */ -var CenterOn = function (triangle, x, y, centerFunc) -{ - if (centerFunc === undefined) { centerFunc = Centroid; } +var EdgeZone = new Class({ - // Get the center of the triangle - var center = centerFunc(triangle); + initialize: - // Difference - var diffX = x - center.x; - var diffY = y - center.y; + function EdgeZone (source, quantity, stepRate, yoyo, seamless) + { + if (yoyo === undefined) { yoyo = false; } + if (seamless === undefined) { seamless = true; } - return Offset(triangle, diffX, diffY); -}; + /** + * [description] + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#source + * @type {object} + * @since 3.0.0 + */ + this.source = source; -module.exports = CenterOn; + /** + * [description] + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#points + * @type {Phaser.Geom.Point[]} + * @default [] + * @since 3.0.0 + */ + this.points = []; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#quantity + * @type {number} + * @since 3.0.0 + */ + this.quantity = quantity; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#stepRate + * @type {number} + * @since 3.0.0 + */ + this.stepRate = stepRate; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#yoyo + * @type {boolean} + * @since 3.0.0 + */ + this.yoyo = yoyo; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#counter + * @type {number} + * @default -1 + * @since 3.0.0 + */ + this.counter = -1; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#seamless + * @type {boolean} + * @since 3.0.0 + */ + this.seamless = seamless; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#_length + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._length = 0; + + /** + * 0 = forwards, 1 = backwards + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#_direction + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._direction = 0; + + this.updateSource(); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.Zones.EdgeZone#updateSource + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.Zones.EdgeZone} This Edge Zone. + */ + updateSource: function () + { + this.points = this.source.getPoints(this.quantity, this.stepRate); + + // Remove ends? + if (this.seamless) + { + var a = this.points[0]; + var b = this.points[this.points.length - 1]; + + if (a.x === b.x && a.y === b.y) + { + this.points.pop(); + } + } + + var oldLength = this._length; + + this._length = this.points.length; + + // Adjust counter if we now have less points than before + if (this._length < oldLength && this.counter > this._length) + { + this.counter = this._length - 1; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.Zones.EdgeZone#changeSource + * @since 3.0.0 + * + * @param {object} source - [description] + * + * @return {Phaser.GameObjects.Particles.Zones.EdgeZone} This Edge Zone. + */ + changeSource: function (source) + { + this.source = source; + + return this.updateSource(); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.Zones.EdgeZone#getPoint + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - [description] + */ + getPoint: function (particle) + { + if (this._direction === 0) + { + this.counter++; + + if (this.counter >= this._length) + { + if (this.yoyo) + { + this._direction = 1; + this.counter = this._length - 1; + } + else + { + this.counter = 0; + } + } + } + else + { + this.counter--; + + if (this.counter === -1) + { + if (this.yoyo) + { + this._direction = 0; + this.counter = 0; + } + else + { + this.counter = this._length - 1; + } + } + } + + var point = this.points[this.counter]; + + if (point) + { + particle.x = point.x; + particle.y = point.y; + } + } + +}); + +module.exports = EdgeZone; /***/ }), /* 752 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -104375,62 +101781,72 @@ module.exports = CenterOn; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Adapted from http://bjornharrtell.github.io/jsts/doc/api/jsts_geom_Triangle.js.html +var Class = __webpack_require__(0); /** - * Computes the determinant of a 2x2 matrix. Uses standard double-precision - * arithmetic, so is susceptible to round-off error. + * @classdesc + * A Death Zone. * - * @param {Number} - * m00 the [0,0] entry of the matrix. - * @param {Number} - * m01 the [0,1] entry of the matrix. - * @param {Number} - * m10 the [1,0] entry of the matrix. - * @param {Number} - * m11 the [1,1] entry of the matrix. - * @return {Number} the determinant. + * A Death Zone is a special type of zone that will kill a Particle as soon as it either enters, or leaves, the zone. + * + * The zone consists of a `source` which could be a Geometric shape, such as a Rectangle or Ellipse, or your own + * object as long as it includes a `contains` method for which the Particles can be tested against. + * + * @class DeathZone + * @memberOf Phaser.GameObjects.Particles.Zones + * @constructor + * @since 3.0.0 + * + * @param {object} source - An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. + * @param {boolean} killOnEnter - Should the Particle be killed when it enters the zone? `true` or leaves it? `false` */ -function det (m00, m01, m10, m11) -{ - return (m00 * m11) - (m01 * m10); -} +var DeathZone = new Class({ -/** - * Computes the circumcentre of a triangle. The circumcentre is the centre of - * the circumcircle, the smallest circle which encloses the triangle. It is also - * the common intersection point of the perpendicular bisectors of the sides of - * the triangle, and is the only point which has equal distance to all three - * vertices of the triangle. - *

- * This method uses an algorithm due to J.R.Shewchuk which uses normalization to - * the origin to improve the accuracy of computation. (See Lecture Notes on - * Geometric Robustness, Jonathan Richard Shewchuk, 1999). - */ -var CircumCenter = function (triangle, out) -{ - if (out === undefined) { out = { x: 0, y: 0 }; } + initialize: - var cx = triangle.x3; - var cy = triangle.y3; + function DeathZone (source, killOnEnter) + { + /** + * An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. + * This could be a Geometry shape, such as `Phaser.Geom.Circle`, or your own custom object. + * + * @name Phaser.GameObjects.Particles.Zones.DeathZone#source + * @type {object} + * @since 3.0.0 + */ + this.source = source; - var ax = triangle.x1 - cx; - var ay = triangle.y1 - cy; + /** + * Set to `true` if the Particle should be killed if it enters this zone. + * Set to `false` to kill the Particle if it leaves this zone. + * + * @name Phaser.GameObjects.Particles.Zones.DeathZone#killOnEnter + * @type {boolean} + * @since 3.0.0 + */ + this.killOnEnter = killOnEnter; + }, - var bx = triangle.x2 - cx; - var by = triangle.y2 - cy; + /** + * Checks if the given Particle will be killed or not by this zone. + * + * @method Phaser.GameObjects.Particles.Zones.DeathZone#willKill + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle to be checked against this zone. + * + * @return {boolean} Return `true` if the Particle is to be killed, otherwise return `false`. + */ + willKill: function (particle) + { + var withinZone = this.source.contains(particle.x, particle.y); - var denom = 2 * det(ax, ay, bx, by); - var numx = det(ay, ax * ax + ay * ay, by, bx * bx + by * by); - var numy = det(ax, ax * ax + ay * ay, bx, bx * bx + by * by); + return (withinZone && this.killOnEnter || !withinZone && !this.killOnEnter); + } - out.x = cx - numx / denom; - out.y = cy + numy / denom; +}); - return out; -}; - -module.exports = CircumCenter; +module.exports = DeathZone; /***/ }), @@ -104443,75 +101859,1988 @@ module.exports = CircumCenter; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Circle = __webpack_require__(64); - -// Adapted from https://gist.github.com/mutoo/5617691 +var BlendModes = __webpack_require__(62); +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var DeathZone = __webpack_require__(752); +var EdgeZone = __webpack_require__(751); +var EmitterOp = __webpack_require__(750); +var GetFastValue = __webpack_require__(2); +var GetRandomElement = __webpack_require__(132); +var HasAny = __webpack_require__(250); +var HasValue = __webpack_require__(70); +var Particle = __webpack_require__(716); +var RandomZone = __webpack_require__(715); +var Rectangle = __webpack_require__(10); +var StableSort = __webpack_require__(272); +var Vector2 = __webpack_require__(6); +var Wrap = __webpack_require__(43); /** + * @callback ParticleEmitterCallback + * + * @param {Phaser.GameObjects.Particles.Particle} particle - [description] + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - [description] + */ + +/** + * @callback ParticleDeathCallback + * + * @param {Phaser.GameObjects.Particles.Particle} particle - [description] + */ + +/** + * @classdesc * [description] * - * @function Phaser.Geom.Triangle.CircumCircle + * @class ParticleEmitter + * @memberOf Phaser.GameObjects.Particles + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Circle} [out] - [description] + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Visible * - * @return {Phaser.Geom.Circle} [description] + * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} manager - The Emitter Manager this Emitter belongs to. + * @param {object} config - [description] */ -var CircumCircle = function (triangle, out) -{ - if (out === undefined) { out = new Circle(); } +var ParticleEmitter = new Class({ - // A - var x1 = triangle.x1; - var y1 = triangle.y1; + Mixins: [ + Components.BlendMode, + Components.ScrollFactor, + Components.Visible + ], - // B - var x2 = triangle.x2; - var y2 = triangle.y2; + initialize: - // C - var x3 = triangle.x3; - var y3 = triangle.y3; - - var A = x2 - x1; - var B = y2 - y1; - var C = x3 - x1; - var D = y3 - y1; - var E = A * (x1 + x2) + B * (y1 + y2); - var F = C * (x1 + x3) + D * (y1 + y3); - var G = 2 * (A * (y3 - y2) - B * (x3 - x2)); - - var dx; - var dy; - - // If the points of the triangle are collinear, then just find the - // extremes and use the midpoint as the center of the circumcircle. - - if (Math.abs(G) < 0.000001) + function ParticleEmitter (manager, config) { - var minX = Math.min(x1, x2, x3); - var minY = Math.min(y1, y2, y3); - dx = (Math.max(x1, x2, x3) - minX) * 0.5; - dy = (Math.max(y1, y2, y3) - minY) * 0.5; + /** + * The Emitter Manager this Emitter belongs to. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#manager + * @type {Phaser.GameObjects.Particles.ParticleEmitterManager} + * @since 3.0.0 + */ + this.manager = manager; - out.x = minX + dx; - out.y = minY + dy; - out.radius = Math.sqrt(dx * dx + dy * dy); - } - else + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#texture + * @type {Phaser.Textures.Texture} + * @since 3.0.0 + */ + this.texture = manager.texture; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#frames + * @type {Phaser.Textures.Frame[]} + * @since 3.0.0 + */ + this.frames = [ manager.defaultFrame ]; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#defaultFrame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + this.defaultFrame = manager.defaultFrame; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#configFastMap + * @type {object} + * @since 3.0.0 + */ + this.configFastMap = [ + 'active', + 'blendMode', + 'collideBottom', + 'collideLeft', + 'collideRight', + 'collideTop', + 'deathCallback', + 'deathCallbackScope', + 'emitCallback', + 'emitCallbackScope', + 'follow', + 'frequency', + 'gravityX', + 'gravityY', + 'maxParticles', + 'name', + 'on', + 'particleBringToTop', + 'particleClass', + 'radial', + 'timeScale', + 'trackVisible', + 'visible' + ]; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#configOpMap + * @type {object} + * @since 3.0.0 + */ + this.configOpMap = [ + 'accelerationX', + 'accelerationY', + 'alpha', + 'bounce', + 'delay', + 'lifespan', + 'maxVelocityX', + 'maxVelocityY', + 'moveToX', + 'moveToY', + 'quantity', + 'rotate', + 'scaleX', + 'scaleY', + 'speedX', + 'speedY', + 'tint', + 'x', + 'y' + ]; + + /** + * The name of this Game Object. + * + * Empty by default and never populated by Phaser, this is left for developers to use. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * The Particle Class which will be emitted by this Emitter. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#particleClass + * @type {Phaser.GameObjects.Particles.Particle} + * @since 3.0.0 + */ + this.particleClass = Particle; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#x + * @type {number} + * @since 3.0.0 + */ + this.x = new EmitterOp(config, 'x', 0); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#y + * @type {number} + * @since 3.0.0 + */ + this.y = new EmitterOp(config, 'y', 0); + + /** + * A radial emitter will emit particles in all directions between angle min and max, + * using speed as the value. If set to false then this acts as a point Emitter. + * A point emitter will emit particles only in the direction derived from the speedX and speedY values. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#radial + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.radial = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#gravityX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.gravityX = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#gravityY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.gravityY = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#acceleration + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.acceleration = false; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#accelerationX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accelerationX = new EmitterOp(config, 'accelerationX', 0, true); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#accelerationY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accelerationY = new EmitterOp(config, 'accelerationY', 0, true); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityX + * @type {number} + * @default 10000 + * @since 3.0.0 + */ + this.maxVelocityX = new EmitterOp(config, 'maxVelocityX', 10000, true); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityY + * @type {number} + * @default 10000 + * @since 3.0.0 + */ + this.maxVelocityY = new EmitterOp(config, 'maxVelocityY', 10000, true); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#speedX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.speedX = new EmitterOp(config, 'speedX', 0, true); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#speedY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.speedY = new EmitterOp(config, 'speedY', 0, true); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#moveTo + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.moveTo = false; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#moveToX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.moveToX = new EmitterOp(config, 'moveToX', 0, true); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#moveToY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.moveToY = new EmitterOp(config, 'moveToY', 0, true); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#bounce + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.bounce = new EmitterOp(config, 'bounce', 0, true); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#scaleX + * @type {float} + * @default 1 + * @since 3.0.0 + */ + this.scaleX = new EmitterOp(config, 'scaleX', 1); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#scaleY + * @type {float} + * @default 1 + * @since 3.0.0 + */ + this.scaleY = new EmitterOp(config, 'scaleY', 1); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#tint + * @type {integer} + * @since 3.0.0 + */ + this.tint = new EmitterOp(config, 'tint', 0xffffffff); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#alpha + * @type {float} + * @default 1 + * @since 3.0.0 + */ + this.alpha = new EmitterOp(config, 'alpha', 1); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#lifespan + * @type {number} + * @default 1000 + * @since 3.0.0 + */ + this.lifespan = new EmitterOp(config, 'lifespan', 1000); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#angle + * @type {number} + * @since 3.0.0 + */ + this.angle = new EmitterOp(config, 'angle', { min: 0, max: 360 }); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#rotate + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.rotate = new EmitterOp(config, 'rotate', 0); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#emitCallback + * @type {?ParticleEmitterCallback} + * @default null + * @since 3.0.0 + */ + this.emitCallback = null; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope + * @type {?*} + * @default null + * @since 3.0.0 + */ + this.emitCallbackScope = null; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#deathCallback + * @type {?ParticleDeathCallback} + * @default null + * @since 3.0.0 + */ + this.deathCallback = null; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope + * @type {?*} + * @default null + * @since 3.0.0 + */ + this.deathCallbackScope = null; + + /** + * Set to hard limit the amount of particle objects this emitter is allowed to create. + * 0 means unlimited. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#maxParticles + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.maxParticles = 0; + + /** + * How many particles are emitted each time the emitter updates. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#quantity + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.quantity = new EmitterOp(config, 'quantity', 1, true); + + /** + * How many ms to wait after emission before the particles start updating. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#delay + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.delay = new EmitterOp(config, 'delay', 0, true); + + /** + * How often a particle is emitted in ms (if emitter is a constant / flow emitter) + * If emitter is an explosion emitter this value will be -1. + * Anything > -1 sets this to be a flow emitter. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#frequency + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.frequency = 0; + + /** + * Controls if the emitter is currently emitting particles. + * Already alive particles will continue to update until they expire. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#on + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.on = true; + + /** + * Newly emitted particles are added to the top of the particle list, i.e. rendered above those already alive. + * Set to false to send them to the back. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#particleBringToTop + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.particleBringToTop = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#emitZone + * @type {?object} + * @default null + * @since 3.0.0 + */ + this.emitZone = null; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#deathZone + * @type {?object} + * @default null + * @since 3.0.0 + */ + this.deathZone = null; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#bounds + * @type {?Phaser.Geom.Rectangle} + * @default null + * @since 3.0.0 + */ + this.bounds = null; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#collideLeft + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.collideLeft = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#collideRight + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.collideRight = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#collideTop + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.collideTop = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#collideBottom + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.collideBottom = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#visible + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.visible = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#blendMode + * @type {integer} + * @since 3.0.0 + */ + this.blendMode = BlendModes.NORMAL; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#follow + * @type {?Phaser.GameObjects.Particles.Particle} + * @default null + * @since 3.0.0 + */ + this.follow = null; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#followOffset + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.followOffset = new Vector2(); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#trackVisible + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.trackVisible = false; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#currentFrame + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.currentFrame = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#randomFrame + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.randomFrame = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#frameQuantity + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.frameQuantity = 1; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#dead + * @type {Phaser.GameObjects.Particles.Particle[]} + * @private + * @since 3.0.0 + */ + this.dead = []; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#alive + * @type {Phaser.GameObjects.Particles.Particle[]} + * @private + * @since 3.0.0 + */ + this.alive = []; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#_counter + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._counter = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#_frameCounter + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._frameCounter = 0; + + if (config) + { + this.fromJSON(config); + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#fromJSON + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + fromJSON: function (config) { - out.x = (D * E - B * F) / G; - out.y = (A * F - C * E) / G; - dx = out.x - x1; - dy = out.y - y1; - out.radius = Math.sqrt(dx * dx + dy * dy); + if (!config) + { + return this; + } + + // Only update properties from their current state if they exist in the given config + + var i = 0; + var key = ''; + + for (i = 0; i < this.configFastMap.length; i++) + { + key = this.configFastMap[i]; + + if (HasValue(config, key)) + { + this[key] = GetFastValue(config, key); + } + } + + for (i = 0; i < this.configOpMap.length; i++) + { + key = this.configOpMap[i]; + + if (HasValue(config, key)) + { + this[key].loadConfig(config); + } + } + + this.acceleration = (this.accelerationX.propertyValue !== 0 || this.accelerationY.propertyValue !== 0); + + this.moveTo = (this.moveToX.propertyValue !== 0 || this.moveToY.propertyValue !== 0); + + // Special 'speed' override + + if (HasValue(config, 'speed')) + { + this.speedX.loadConfig(config, 'speed'); + this.speedY = null; + } + + // If you specify speedX, speedY ot moveTo then it changes the emitter from radial to a point emitter + if (HasAny(config, [ 'speedX', 'speedY' ]) || this.moveTo) + { + this.radial = false; + } + + // Special 'scale' override + + if (HasValue(config, 'scale')) + { + this.scaleX.loadConfig(config, 'scale'); + this.scaleY = null; + } + + if (HasValue(config, 'callbackScope')) + { + var callbackScope = GetFastValue(config, 'callbackScope', null); + + this.emitCallbackScope = callbackScope; + this.deathCallbackScope = callbackScope; + } + + if (HasValue(config, 'emitZone')) + { + this.setEmitZone(config.emitZone); + } + + if (HasValue(config, 'deathZone')) + { + this.setDeathZone(config.deathZone); + } + + if (HasValue(config, 'bounds')) + { + this.setBounds(config.bounds); + } + + if (HasValue(config, 'followOffset')) + { + this.followOffset.setFromObject(GetFastValue(config, 'followOffset', 0)); + } + + if (HasValue(config, 'frame')) + { + this.setFrame(config.frame); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#toJSON + * @since 3.0.0 + * + * @param {object} output - [description] + * + * @return {object} [description] + */ + toJSON: function (output) + { + if (output === undefined) { output = {}; } + + var i = 0; + var key = ''; + + for (i = 0; i < this.configFastMap.length; i++) + { + key = this.configFastMap[i]; + + output[key] = this[key]; + } + + for (i = 0; i < this.configOpMap.length; i++) + { + key = this.configOpMap[i]; + + if (this[key]) + { + output[key] = this[key].toJSON(); + } + } + + // special handlers + if (!this.speedY) + { + delete output.speedX; + output.speed = this.speedX.toJSON(); + } + + if (!this.scaleY) + { + delete output.scaleX; + output.scale = this.scaleX.toJSON(); + } + + return output; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#startFollow + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} target - [description] + * @param {number} [offsetX=0] - [description] + * @param {number} [offsetY=0] - [description] + * @param {boolean} [trackVisible=false] - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + startFollow: function (target, offsetX, offsetY, trackVisible) + { + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + if (trackVisible === undefined) { trackVisible = false; } + + this.follow = target; + this.followOffset.set(offsetX, offsetY); + this.trackVisible = trackVisible; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#stopFollow + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + stopFollow: function () + { + this.follow = null; + this.followOffset.set(0, 0); + this.trackVisible = false; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getFrame + * @since 3.0.0 + * + * @return {Phaser.Textures.Frame} [description] + */ + getFrame: function () + { + if (this.frames.length === 1) + { + return this.defaultFrame; + } + else if (this.randomFrame) + { + return GetRandomElement(this.frames); + } + else + { + var frame = this.frames[this.currentFrame]; + + this._frameCounter++; + + if (this._frameCounter === this.frameQuantity) + { + this._frameCounter = 0; + this.currentFrame = Wrap(this.currentFrame + 1, 0, this._frameLength); + } + + return frame; + } + }, + + // frame: 0 + // frame: 'red' + // frame: [ 0, 1, 2, 3 ] + // frame: [ 'red', 'green', 'blue', 'pink', 'white' ] + // frame: { frames: [ 'red', 'green', 'blue', 'pink', 'white' ], [cycle: bool], [quantity: int] } + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setFrame + * @since 3.0.0 + * + * @param {(array|string|integer|object)} frames - [description] + * @param {boolean} [pickRandom=true] - [description] + * @param {integer} [quantity=1] - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setFrame: function (frames, pickRandom, quantity) + { + if (pickRandom === undefined) { pickRandom = true; } + if (quantity === undefined) { quantity = 1; } + + this.randomFrame = pickRandom; + this.frameQuantity = quantity; + this.currentFrame = 0; + this._frameCounter = 0; + + var t = typeof (frames); + + if (Array.isArray(frames) || t === 'string' || t === 'number') + { + this.manager.setEmitterFrames(frames, this); + } + else if (t === 'object') + { + var frameConfig = frames; + + frames = GetFastValue(frameConfig, 'frames', null); + + if (frames) + { + this.manager.setEmitterFrames(frames, this); + } + + var isCycle = GetFastValue(frameConfig, 'cycle', false); + + this.randomFrame = (isCycle) ? false : true; + + this.frameQuantity = GetFastValue(frameConfig, 'quantity', quantity); + } + + this._frameLength = this.frames.length; + + if (this._frameLength === 1) + { + this.frameQuantity = 1; + this.randomFrame = false; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setRadial + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setRadial: function (value) + { + if (value === undefined) { value = true; } + + this.radial = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setPosition + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setPosition: function (x, y) + { + this.x.onChange(x); + this.y.onChange(y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setBounds + * @since 3.0.0 + * + * @param {(number|object)} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setBounds: function (x, y, width, height) + { + if (typeof x === 'object') + { + var obj = x; + + x = obj.x; + y = obj.y; + width = (HasValue(obj, 'w')) ? obj.w : obj.width; + height = (HasValue(obj, 'h')) ? obj.h : obj.height; + } + + if (this.bounds) + { + this.bounds.setTo(x, y, width, height); + } + else + { + this.bounds = new Rectangle(x, y, width, height); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeedX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setSpeedX: function (value) + { + this.speedX.onChange(value); + + // If you specify speedX and Y then it changes the emitter from radial to a point emitter + this.radial = false; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeedY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setSpeedY: function (value) + { + if (this.speedY) + { + this.speedY.onChange(value); + + // If you specify speedX and Y then it changes the emitter from radial to a point emitter + this.radial = false; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeed + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setSpeed: function (value) + { + this.speedX.onChange(value); + this.speedY = null; + + // If you specify speedX and Y then it changes the emitter from radial to a point emitter + this.radial = true; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setScaleX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setScaleX: function (value) + { + this.scaleX.onChange(value); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setScaleY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setScaleY: function (value) + { + this.scaleY.onChange(value); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setScale + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setScale: function (value) + { + this.scaleX.onChange(value); + this.scaleY = null; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravityX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setGravityX: function (value) + { + this.gravityX = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravityY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setGravityY: function (value) + { + this.gravityY = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravity + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setGravity: function (x, y) + { + this.gravityX = x; + this.gravityY = y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setAlpha + * @since 3.0.0 + * + * @param {float} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setAlpha: function (value) + { + this.alpha.onChange(value); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setEmitterAngle + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setEmitterAngle: function (value) + { + this.angle.onChange(value); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setAngle + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setAngle: function (value) + { + this.angle.onChange(value); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setLifespan + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setLifespan: function (value) + { + this.lifespan.onChange(value); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setQuantity + * @since 3.0.0 + * + * @param {integer} quantity - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setQuantity: function (quantity) + { + this.quantity.onChange(quantity); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setFrequency + * @since 3.0.0 + * + * @param {number} frequency - [description] + * @param {integer} [quantity] - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setFrequency: function (frequency, quantity) + { + this.frequency = frequency; + + this._counter = 0; + + if (quantity) + { + this.quantity.onChange(quantity); + } + + return this; + }, + + /** + * The zone must have a function called `getPoint` that takes a particle object and sets + * its x and y properties accordingly then returns that object. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone + * @since 3.0.0 + * + * @param {object} [zoneConfig] - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setEmitZone: function (zoneConfig) + { + if (zoneConfig === undefined) + { + this.emitZone = null; + } + else + { + // Where source = Geom like Circle, or a Path or Curve + // emitZone: { type: 'random', source: X } + // emitZone: { type: 'edge', source: X, quantity: 32, [stepRate=0], [yoyo=false], [seamless=true] } + + var type = GetFastValue(zoneConfig, 'type', 'random'); + var source = GetFastValue(zoneConfig, 'source', null); + + if (source && typeof source.getPoint === 'function') + { + switch (type) + { + case 'random': + + this.emitZone = new RandomZone(source); + + break; + + case 'edge': + + var quantity = GetFastValue(zoneConfig, 'quantity', 1); + var stepRate = GetFastValue(zoneConfig, 'stepRate', 0); + var yoyo = GetFastValue(zoneConfig, 'yoyo', false); + var seamless = GetFastValue(zoneConfig, 'seamless', true); + + this.emitZone = new EdgeZone(source, quantity, stepRate, yoyo, seamless); + + break; + } + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setDeathZone + * @since 3.0.0 + * + * @param {object} [zoneConfig] - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setDeathZone: function (zoneConfig) + { + if (zoneConfig === undefined) + { + this.deathZone = null; + } + else + { + // Where source = Geom like Circle or Rect that supports a 'contains' function + // deathZone: { type: 'onEnter', source: X } + // deathZone: { type: 'onLeave', source: X } + + var type = GetFastValue(zoneConfig, 'type', 'onEnter'); + var source = GetFastValue(zoneConfig, 'source', null); + + if (source && typeof source.contains === 'function') + { + var killOnEnter = (type === 'onEnter') ? true : false; + + this.deathZone = new DeathZone(source, killOnEnter); + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#reserve + * @since 3.0.0 + * + * @param {integer} particleCount - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + reserve: function (particleCount) + { + var dead = this.dead; + + for (var i = 0; i < particleCount; i++) + { + dead.push(new this.particleClass(this)); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getAliveParticleCount + * @since 3.0.0 + * + * @return {integer} The number of currently alive Particles in this Emitter. + */ + getAliveParticleCount: function () + { + return this.alive.length; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getDeadParticleCount + * @since 3.0.0 + * + * @return {integer} The number of currently dead Particles in this Emitter. + */ + getDeadParticleCount: function () + { + return this.dead.length; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getParticleCount + * @since 3.0.0 + * + * @return {integer} The number of Particles in this Emitter, including both alive and dead. + */ + getParticleCount: function () + { + return this.getAliveParticleCount() + this.getDeadParticleCount(); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#atLimit + * @since 3.0.0 + * + * @return {boolean} Returns `true` if this Emitter is at its limit, or `false` if no limit, or below the `maxParticles` level. + */ + atLimit: function () + { + return (this.maxParticles > 0 && this.getParticleCount() === this.maxParticles); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#onParticleEmit + * @since 3.0.0 + * + * @param {ParticleEmitterCallback} callback - [description] + * @param {*} [context] - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + onParticleEmit: function (callback, context) + { + if (callback === undefined) + { + // Clear any previously set callback + this.emitCallback = null; + this.emitCallbackScope = null; + } + else if (typeof callback === 'function') + { + this.emitCallback = callback; + + if (context) + { + this.emitCallbackScope = context; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#onParticleDeath + * @since 3.0.0 + * + * @param {ParticleDeathCallback} callback - [description] + * @param {*} [context] - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + onParticleDeath: function (callback, context) + { + if (callback === undefined) + { + // Clear any previously set callback + this.deathCallback = null; + this.deathCallbackScope = null; + } + else if (typeof callback === 'function') + { + this.deathCallback = callback; + + if (context) + { + this.deathCallbackScope = context; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#killAll + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + killAll: function () + { + var dead = this.dead; + var alive = this.alive; + + while (alive.length > 0) + { + dead.push(alive.pop()); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#forEachAlive + * @since 3.0.0 + * + * @param {ParticleEmitterCallback} callback - [description] + * @param {*} thisArg - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + forEachAlive: function (callback, thisArg) + { + var alive = this.alive; + var length = alive.length; + + for (var index = 0; index < length; ++index) + { + // Sends the Particle and the Emitter + callback.call(thisArg, alive[index], this); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#forEachDead + * @since 3.0.0 + * + * @param {ParticleEmitterCallback} callback - [description] + * @param {*} thisArg - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + forEachDead: function (callback, thisArg) + { + var dead = this.dead; + var length = dead.length; + + for (var index = 0; index < length; ++index) + { + // Sends the Particle and the Emitter + callback.call(thisArg, dead[index], this); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#start + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + start: function () + { + this.on = true; + + this._counter = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#pause + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + pause: function () + { + this.active = false; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#resume + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + resume: function () + { + this.active = true; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#depthSort + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + depthSort: function () + { + StableSort.inplace(this.alive, this.depthSortCallback); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#flow + * @since 3.0.0 + * + * @param {number} frequency - [description] + * @param {integer} [count=1] - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + flow: function (frequency, count) + { + if (count === undefined) { count = 1; } + + this.frequency = frequency; + + this.quantity.onChange(count); + + return this.start(); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#explode + * @since 3.0.0 + * + * @param {integer} count - The amount of Particles to emit. + * @param {number} x - The x coordinate to emit the Particles from. + * @param {number} y - The y coordinate to emit the Particles from. + * + * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. + */ + explode: function (count, x, y) + { + this.frequency = -1; + + return this.emitParticle(count, x, y); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#emitParticleAt + * @since 3.0.0 + * + * @param {number} x - The x coordinate to emit the Particles from. + * @param {number} y - The y coordinate to emit the Particles from. + * @param {integer} count - The amount of Particles to emit. + * + * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. + */ + emitParticleAt: function (x, y, count) + { + return this.emitParticle(count, x, y); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#emitParticle + * @since 3.0.0 + * + * @param {integer} count - The amount of Particles to emit. + * @param {number} x - The x coordinate to emit the Particles from. + * @param {number} y - The y coordinate to emit the Particles from. + * + * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. + */ + emitParticle: function (count, x, y) + { + if (this.atLimit()) + { + return; + } + + if (count === undefined) + { + count = this.quantity.onEmit(); + } + + var dead = this.dead; + + for (var i = 0; i < count; i++) + { + var particle; + + if (dead.length > 0) + { + particle = dead.pop(); + } + else + { + particle = new this.particleClass(this); + } + + particle.fire(x, y); + + if (this.particleBringToTop) + { + this.alive.push(particle); + } + else + { + this.alive.unshift(particle); + } + + if (this.emitCallback) + { + this.emitCallback.call(this.emitCallbackScope, particle, this); + } + + if (this.atLimit()) + { + break; + } + } + + return particle; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#preUpdate + * @since 3.0.0 + * + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + preUpdate: function (time, delta) + { + // Scale the delta + delta *= this.timeScale; + + var step = (delta / 1000); + + if (this.trackVisible) + { + this.visible = this.follow.visible; + } + + // Any particle processors? + var processors = this.manager.getProcessors(); + + var particles = this.alive; + var length = particles.length; + + for (var index = 0; index < length; index++) + { + var particle = particles[index]; + + // update returns `true` if the particle is now dead (lifeStep < 0) + if (particle.update(delta, step, processors)) + { + // Moves the dead particle to the end of the particles array (ready for splicing out later) + var last = particles[length - 1]; + + particles[length - 1] = particle; + particles[index] = last; + + index -= 1; + length -= 1; + } + } + + // Move dead particles to the dead array + var deadLength = particles.length - length; + + if (deadLength > 0) + { + var rip = particles.splice(particles.length - deadLength, deadLength); + + var deathCallback = this.deathCallback; + var deathCallbackScope = this.deathCallbackScope; + + if (deathCallback) + { + for (var i = 0; i < rip.length; i++) + { + deathCallback.call(deathCallbackScope, rip[i]); + } + } + + this.dead.concat(rip); + + StableSort.inplace(particles, this.indexSortCallback); + } + + if (!this.on) + { + return; + } + + if (this.frequency === 0) + { + this.emitParticle(); + } + else if (this.frequency > 0) + { + this._counter -= delta; + + if (this._counter <= 0) + { + this.emitParticle(); + + // counter = frequency - remained from previous delta + this._counter = (this.frequency - Math.abs(this._counter)); + } + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#depthSortCallback + * @since 3.0.0 + * + * @param {object} a - [description] + * @param {object} b - [description] + * + * @return {integer} [description] + */ + depthSortCallback: function (a, b) + { + return a.y - b.y; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#indexSortCallback + * @since 3.0.0 + * + * @param {object} a - [description] + * @param {object} b - [description] + * + * @return {integer} [description] + */ + indexSortCallback: function (a, b) + { + return a.index - b.index; } - return out; -}; +}); -module.exports = CircumCircle; +module.exports = ParticleEmitter; /***/ }), @@ -104524,24 +103853,209 @@ module.exports = CircumCircle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Triangle = __webpack_require__(56); +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(2); /** + * @classdesc * [description] * - * @function Phaser.Geom.Triangle.Clone + * @class GravityWell + * @memberOf Phaser.GameObjects.Particles + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} source - [description] - * - * @return {Phaser.Geom.Triangle} [description] + * @param {(number|object)} [x=0] - The x coordinate of the Gravity Well, in world space. + * @param {number} [y=0] - The y coordinate of the Gravity Well, in world space. + * @param {number} [power=0] - The power of the Gravity Well. + * @param {number} [epsilon=100] - [description] + * @param {number} [gravity=50] - The gravitational force of this Gravity Well. */ -var Clone = function (source) -{ - return new Triangle(source.x1, source.y1, source.x2, source.y2, source.x3, source.y3); -}; +var GravityWell = new Class({ -module.exports = Clone; + initialize: + + function GravityWell (x, y, power, epsilon, gravity) + { + if (typeof x === 'object') + { + var config = x; + + x = GetFastValue(config, 'x', 0); + y = GetFastValue(config, 'y', 0); + power = GetFastValue(config, 'power', 0); + epsilon = GetFastValue(config, 'epsilon', 100); + gravity = GetFastValue(config, 'gravity', 50); + } + else + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (power === undefined) { power = 0; } + if (epsilon === undefined) { epsilon = 100; } + if (gravity === undefined) { gravity = 50; } + } + + /** + * The x coordinate of the Gravity Well, in world space. + * + * @name Phaser.GameObjects.Particles.GravityWell#x + * @type {number} + * @since 3.0.0 + */ + this.x = x; + + /** + * The y coordinate of the Gravity Well, in world space. + * + * @name Phaser.GameObjects.Particles.GravityWell#y + * @type {number} + * @since 3.0.0 + */ + this.y = y; + + /** + * The active state of the Gravity Well. An inactive Gravity Well will not influence any particles. + * + * @name Phaser.GameObjects.Particles.GravityWell#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * Internal gravity value. + * + * @name Phaser.GameObjects.Particles.GravityWell#_gravity + * @type {number} + * @private + * @since 3.0.0 + */ + this._gravity = gravity; + + /** + * Internal power value. + * + * @name Phaser.GameObjects.Particles.GravityWell#_power + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._power = 0; + + /** + * Internal epsilon value. + * + * @name Phaser.GameObjects.Particles.GravityWell#_epsilon + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._epsilon = 0; + + /** + * The power of the Gravity Well. + * + * @name Phaser.GameObjects.Particles.GravityWell#power + * @type {number} + * @since 3.0.0 + */ + this.power = power; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.GravityWell#epsilon + * @type {number} + * @since 3.0.0 + */ + this.epsilon = epsilon; + }, + + /** + * Takes a Particle and updates it based on the properties of this Gravity Well. + * + * @method Phaser.GameObjects.Particles.GravityWell#update + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle to update. + * @param {number} delta - The delta time in ms. + * @param {float} step - The delta value divided by 1000. + */ + update: function (particle, delta) + { + var x = this.x - particle.x; + var y = this.y - particle.y; + var dSq = x * x + y * y; + + if (dSq === 0) + { + return; + } + + var d = Math.sqrt(dSq); + + if (dSq < this._epsilon) + { + dSq = this._epsilon; + } + + var factor = ((this._power * delta) / (dSq * d)) * 100; + + particle.velocityX += x * factor; + particle.velocityY += y * factor; + }, + + epsilon: { + + get: function () + { + return Math.sqrt(this._epsilon); + }, + + set: function (value) + { + this._epsilon = value * value; + } + + }, + + power: { + + get: function () + { + return this._power / this._gravity; + }, + + set: function (value) + { + this._power = value * this._gravity; + } + + }, + + gravity: { + + get: function () + { + return this._gravity; + }, + + set: function (value) + { + var pwr = this.power; + this._gravity = value; + this.power = pwr; + } + + } + +}); + +module.exports = GravityWell; /***/ }), @@ -104554,30 +104068,38 @@ module.exports = Clone; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Contains = __webpack_require__(54); +var GameObject = __webpack_require__(1); /** - * [description] + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. * - * @function Phaser.Geom.Triangle.ContainsPoint + * @method Phaser.GameObjects.Image#renderCanvas * @since 3.0.0 + * @private * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point} point - [description] - * - * @return {boolean} [description] + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Image} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. */ -var ContainsPoint = function (triangle, point) +var ImageCanvasRenderer = function (renderer, src, interpolationPercentage, camera) { - return Contains(triangle, point.x, point.y); + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + renderer.drawImage(src, camera); }; -module.exports = ContainsPoint; +module.exports = ImageCanvasRenderer; /***/ }), /* 756 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -104585,28 +104107,38 @@ module.exports = ContainsPoint; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var GameObject = __webpack_require__(1); + /** - * [description] + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. * - * @function Phaser.Geom.Triangle.CopyFrom + * @method Phaser.GameObjects.Image#renderWebGL * @since 3.0.0 + * @private * - * @param {Phaser.Geom.Triangle} source - [description] - * @param {Phaser.Geom.Triangle} dest - [description] - * - * @return {Phaser.Geom.Triangle} [description] + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Image} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. */ -var CopyFrom = function (source, dest) +var ImageWebGLRenderer = function (renderer, src, interpolationPercentage, camera) { - return dest.setTo(source.x1, source.y1, source.x2, source.y2, source.x3, source.y3); + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + this.pipeline.batchSprite(src, camera); }; -module.exports = CopyFrom; +module.exports = ImageWebGLRenderer; /***/ }), /* 757 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -104614,30 +104146,25 @@ module.exports = CopyFrom; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * [description] - * - * @function Phaser.Geom.Triangle.Equals - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Triangle} toCompare - [description] - * - * @return {boolean} [description] - */ -var Equals = function (triangle, toCompare) -{ - return ( - triangle.x1 === toCompare.x1 && - triangle.y1 === toCompare.y1 && - triangle.x2 === toCompare.x2 && - triangle.y2 === toCompare.y2 && - triangle.x3 === toCompare.x3 && - triangle.y3 === toCompare.y3 - ); -}; +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); -module.exports = Equals; +if (true) +{ + renderWebGL = __webpack_require__(756); +} + +if (true) +{ + renderCanvas = __webpack_require__(755); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; /***/ }), @@ -104650,30 +104177,33 @@ module.exports = Equals; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Length = __webpack_require__(66); - -// The 2D area of a triangle. The area value is always non-negative. +var GameObject = __webpack_require__(1); /** - * [description] + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. * - * @function Phaser.Geom.Triangle.Perimeter + * @method Phaser.GameObjects.Graphics#renderWebGL * @since 3.0.0 + * @private * - * @param {Phaser.Geom.Triangle} triangle - [description] - * - * @return {number} [description] + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Graphics} graphics - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. */ -var Perimeter = function (triangle) +var GraphicsWebGLRenderer = function (renderer, graphics, interpolationPercentage, camera) { - var line1 = triangle.getLineA(); - var line2 = triangle.getLineB(); - var line3 = triangle.getLineC(); + if (GameObject.RENDER_MASK !== graphics.renderFlags || (graphics.cameraFilter > 0 && (graphics.cameraFilter & camera._id))) + { + return; + } - return (Length(line1) + Length(line2) + Length(line3)); + this.pipeline.batchGraphics(this, camera); }; -module.exports = Perimeter; +module.exports = GraphicsWebGLRenderer; /***/ }), @@ -104686,33 +104216,33 @@ module.exports = Perimeter; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RotateAroundXY = __webpack_require__(149); -var InCenter = __webpack_require__(313); +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); -/** - * [description] - * - * @function Phaser.Geom.Triangle.Rotate - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Triangle} [description] - */ -var Rotate = function (triangle, angle) +if (true) { - var point = InCenter(triangle); + renderWebGL = __webpack_require__(758); + + // Needed for Graphics.generateTexture + renderCanvas = __webpack_require__(265); +} + +if (true) +{ + renderCanvas = __webpack_require__(265); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas - return RotateAroundXY(triangle, point.x, point.y, angle); }; -module.exports = Rotate; - /***/ }), /* 760 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -104720,31 +104250,31 @@ module.exports = Rotate; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RotateAroundXY = __webpack_require__(149); - /** - * [description] + * Offsets the Ellipse by the values given in the `x` and `y` properties of the Point object. * - * @function Phaser.Geom.Triangle.RotateAroundPoint + * @function Phaser.Geom.Ellipse.OffsetPoint * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point} point - [description] - * @param {number} angle - [description] + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to be offset (translated.) + * @param {(Phaser.Geom.Point|object)} point - The Point object containing the values to offset the Ellipse by. * - * @return {Phaser.Geom.Triangle} [description] + * @return {Phaser.Geom.Ellipse} The Ellipse that was offset. */ -var RotateAroundPoint = function (triangle, point, angle) +var OffsetPoint = function (ellipse, point) { - return RotateAroundXY(triangle, point.x, point.y, angle); + ellipse.x += point.x; + ellipse.y += point.y; + + return ellipse; }; -module.exports = RotateAroundPoint; +module.exports = OffsetPoint; /***/ }), /* 761 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -104753,22 +104283,27 @@ module.exports = RotateAroundPoint; */ /** - * @namespace Phaser.Input + * Offsets the Ellipse by the values given. + * + * @function Phaser.Geom.Ellipse.Offset + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to be offset (translated.) + * @param {number} x - The amount to horizontally offset the Ellipse by. + * @param {number} y - The amount to vertically offset the Ellipse by. + * + * @return {Phaser.Geom.Ellipse} The Ellipse that was offset. */ +var Offset = function (ellipse, x, y) +{ + ellipse.x += x; + ellipse.y += y; -module.exports = { - - Gamepad: __webpack_require__(762), - InputManager: __webpack_require__(240), - InputPlugin: __webpack_require__(767), - InteractiveObject: __webpack_require__(314), - Keyboard: __webpack_require__(768), - Mouse: __webpack_require__(773), - Pointer: __webpack_require__(249), - Touch: __webpack_require__(774) - + return ellipse; }; +module.exports = Offset; + /***/ }), /* 762 */ @@ -104780,24 +104315,37 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Rectangle = __webpack_require__(10); + /** - * @namespace Phaser.Input.Gamepad + * Returns the bounds of the Ellipse object. + * + * @function Phaser.Geom.Ellipse.GetBounds + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the bounds from. + * @param {(Phaser.Geom.Rectangle|object)} [out] - A Rectangle, or rectangle-like object, to store the ellipse bounds in. If not given a new Rectangle will be created. + * + * @return {(Phaser.Geom.Rectangle|object)} The Rectangle object containing the Ellipse bounds. */ +var GetBounds = function (ellipse, out) +{ + if (out === undefined) { out = new Rectangle(); } -module.exports = { + out.x = ellipse.left; + out.y = ellipse.top; + out.width = ellipse.width; + out.height = ellipse.height; - Axis: __webpack_require__(243), - Button: __webpack_require__(244), - Gamepad: __webpack_require__(242), - GamepadManager: __webpack_require__(241), - - Configs: __webpack_require__(763) + return out; }; +module.exports = GetBounds; + /***/ }), /* 763 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -104806,17 +104354,29 @@ module.exports = { */ /** - * @namespace Phaser.Input.Gamepad.Configs + * Compares the `x`, `y`, `width` and `height` properties of the two given Ellipses. + * Returns `true` if they all match, otherwise returns `false`. + * + * @function Phaser.Geom.Ellipse.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The first Ellipse to compare. + * @param {Phaser.Geom.Ellipse} toCompare - The second Ellipse to compare. + * + * @return {boolean} `true` if the two Ellipse equal each other, otherwise `false`. */ - -module.exports = { - - DUALSHOCK_4: __webpack_require__(764), - SNES_USB: __webpack_require__(765), - XBOX_360: __webpack_require__(766) - +var Equals = function (ellipse, toCompare) +{ + return ( + ellipse.x === toCompare.x && + ellipse.y === toCompare.y && + ellipse.width === toCompare.width && + ellipse.height === toCompare.height + ); }; +module.exports = Equals; + /***/ }), /* 764 */ @@ -104829,49 +104389,28 @@ module.exports = { */ /** - * PlayStation DualShock 4 Gamepad Configuration. - * Sony PlayStation DualShock 4 (v2) wireless controller - * - * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4 - * @type {object} + * Copies the `x`, `y`, `width` and `height` properties from the `source` Ellipse + * into the given `dest` Ellipse, then returns the `dest` Ellipse. + * + * @function Phaser.Geom.Ellipse.CopyFrom * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} source - The source Ellipse to copy the values from. + * @param {Phaser.Geom.Ellipse} dest - The destination Ellipse to copy the values to. + * + * @return {Phaser.Geom.Ellipse} The dest Ellipse. */ - -module.exports = { - - UP: 12, - DOWN: 13, - LEFT: 14, - RIGHT: 15, - - SHARE: 8, - OPTIONS: 9, - PS: 16, - TOUCHBAR: 17, - - X: 0, - CIRCLE: 1, - SQUARE: 2, - TRIANGLE: 3, - - L1: 4, - R1: 5, - L2: 6, - R2: 7, - L3: 10, - R3: 11, - - LEFT_STICK_H: 0, - LEFT_STICK_V: 1, - RIGHT_STICK_H: 2, - RIGHT_STICK_V: 3 - +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x, source.y, source.width, source.height); }; +module.exports = CopyFrom; + /***/ }), /* 765 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -104879,39 +104418,35 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Contains = __webpack_require__(74); + /** - * Tatar SNES USB Controller Gamepad Configuration. - * USB Gamepad (STANDARD GAMEPAD Vendor: 0079 Product: 0011) - * - * @name Phaser.Input.Gamepad.Configs.SNES_USB - * @type {object} + * Check to see if the Ellipse contains all four points of the given Rectangle object. + * + * @function Phaser.Geom.Ellipse.ContainsRect * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - [description] + * @param {(Phaser.Geom.Rectangle|object)} rect - The Rectangle object to check if it's within the Ellipse or not. + * + * @return {boolean} True if all of the Rectangle coordinates are within the ellipse, otherwise false. */ - -module.exports = { - - UP: 12, - DOWN: 13, - LEFT: 14, - RIGHT: 15, - - SELECT: 8, - START: 9, - - B: 0, - A: 1, - Y: 2, - X: 3, - - LEFT_SHOULDER: 4, - RIGHT_SHOULDER: 5 - +var ContainsRect = function (ellipse, rect) +{ + return ( + Contains(ellipse, rect.x, rect.y) && + Contains(ellipse, rect.right, rect.y) && + Contains(ellipse, rect.x, rect.bottom) && + Contains(ellipse, rect.right, rect.bottom) + ); }; +module.exports = ContainsRect; + /***/ }), /* 766 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -104919,47 +104454,26 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Contains = __webpack_require__(74); + /** - * XBox 360 Gamepad Configuration. - * - * @name Phaser.Input.Gamepad.Configs.XBOX_360 - * @type {object} + * Check to see if the Ellipse contains the given Point object. + * + * @function Phaser.Geom.Ellipse.ContainsPoint * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. + * @param {(Phaser.Geom.Point|object)} point - The Point object to check if it's within the Circle or not. + * + * @return {boolean} True if the Point coordinates are within the circle, otherwise false. */ - -module.exports = { - - UP: 12, - DOWN: 13, - LEFT: 14, - RIGHT: 15, - - MENU: 16, - - A: 0, - B: 1, - X: 2, - Y: 3, - - LB: 4, - RB: 5, - - LT: 6, - RT: 7, - - BACK: 8, - START: 9, - - LS: 10, - RS: 11, - - LEFT_STICK_H: 0, - LEFT_STICK_V: 1, - RIGHT_STICK_H: 2, - RIGHT_STICK_V: 3 - +var ContainsPoint = function (ellipse, point) +{ + return Contains(ellipse, point.x, point.y); }; +module.exports = ContainsPoint; + /***/ }), /* 767 */ @@ -104971,1633 +104485,62 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Circle = __webpack_require__(64); -var CircleContains = __webpack_require__(32); -var Class = __webpack_require__(0); -var DistanceBetween = __webpack_require__(42); -var Ellipse = __webpack_require__(137); -var EllipseContains = __webpack_require__(68); -var EventEmitter = __webpack_require__(14); -var InteractiveObject = __webpack_require__(314); -var PluginManager = __webpack_require__(12); -var Rectangle = __webpack_require__(8); -var RectangleContains = __webpack_require__(33); -var Triangle = __webpack_require__(56); -var TriangleContains = __webpack_require__(54); +var Ellipse = __webpack_require__(135); /** - * @classdesc - * [description] + * Creates a new Ellipse instance based on the values contained in the given source. * - * @class InputPlugin - * @extends EventEmitter - * @memberOf Phaser.Input - * @constructor + * @function Phaser.Geom.Ellipse.Clone * @since 3.0.0 * - * @param {Phaser.Scene} scene - The Scene that owns this plugin. + * @param {Phaser.Geom.Ellipse} source - The Ellipse to be cloned. Can be an instance of an Ellipse or a ellipse-like object, with x, y, width and height properties. + * + * @return {Phaser.Geom.Ellipse} A clone of the source Ellipse. */ -var InputPlugin = new Class({ +var Clone = function (source) +{ + return new Ellipse(source.x, source.y, source.width, source.height); +}; - Extends: EventEmitter, - - initialize: - - function InputPlugin (scene) - { - EventEmitter.call(this); - - /** - * The Scene that owns this plugin. - * - * @name Phaser.Input.InputPlugin#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.Input.InputPlugin#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - if (!scene.sys.settings.isBooted) - { - scene.sys.events.once('boot', this.boot, this); - } - - /** - * [description] - * - * @name Phaser.Input.InputPlugin#manager - * @type {Phaser.Input.InputManager} - * @since 3.0.0 - */ - this.manager = scene.sys.game.input; - - /** - * A reference to this.scene.sys.displayList (set in boot) - * - * @name Phaser.Input.InputPlugin#displayList - * @type {Phaser.GameObjects.DisplayList} - * @since 3.0.0 - */ - this.displayList; - - /** - * A reference to the this.scene.sys.cameras (set in boot) - * - * @name Phaser.Input.InputPlugin#cameras - * @type {null} - * @since 3.0.0 - */ - this.cameras; - - /** - * [description] - * - * @name Phaser.Input.InputPlugin#keyboard - * @type {Phaser.Input.Keyboard.KeyboardManager} - * @since 3.0.0 - */ - this.keyboard = this.manager.keyboard; - - /** - * [description] - * - * @name Phaser.Input.InputPlugin#mouse - * @type {Phaser.Input.Mouse.MouseManager} - * @since 3.0.0 - */ - this.mouse = this.manager.mouse; - - /** - * [description] - * - * @name Phaser.Input.InputPlugin#gamepad - * @type {Phaser.Input.Gamepad.GamepadManager} - * @since 3.0.0 - */ - this.gamepad = this.manager.gamepad; - - /** - * Only fire callbacks and events on the top-most Game Object in the display list (emulating DOM behavior) - * and ignore any GOs below it, or call them all? - * - * @name Phaser.Input.InputPlugin#topOnly - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.topOnly = true; - - /** - * How often should the pointer input be checked? - * Time given in ms - * Pointer will *always* be checked if it has been moved by the user. - * This controls how often it will be polled if it hasn't been moved. - * Set to 0 to poll constantly. Set to -1 to only poll on user movement. - * - * @name Phaser.Input.InputPlugin#pollRate - * @type {integer} - * @default -1 - * @since 3.0.0 - */ - this.pollRate = -1; - - /** - * [description] - * - * @name Phaser.Input.InputPlugin#_pollTimer - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._pollTimer = 0; - - /** - * The distance, in pixels, the pointer has to move while being held down, before it thinks it is being dragged. - * - * @name Phaser.Input.InputPlugin#dragDistanceThreshold - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.dragDistanceThreshold = 0; - - /** - * The amount of time, in ms, the pointer has to be held down before it thinks it is dragging. - * - * @name Phaser.Input.InputPlugin#dragTimeThreshold - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.dragTimeThreshold = 0; - - /** - * Used to temporarily store the results of the Hit Test - * - * @name Phaser.Input.InputPlugin#_temp - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._temp = []; - - /** - * Used to temporarily store the results of the Hit Test dropZones - * - * @name Phaser.Input.InputPlugin#_tempZones - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._tempZones = []; - - /** - * A list of all Game Objects that have been set to be interactive. - * - * @name Phaser.Input.InputPlugin#_list - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._list = []; - - /** - * Objects waiting to be inserted to the list on the next call to 'begin'. - * - * @name Phaser.Input.InputPlugin#_pendingInsertion - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._pendingInsertion = []; - - /** - * Objects waiting to be removed from the list on the next call to 'begin'. - * - * @name Phaser.Input.InputPlugin#_pendingRemoval - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._pendingRemoval = []; - - /** - * A list of all Game Objects that have been enabled for dragging. - * - * @name Phaser.Input.InputPlugin#_draggable - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._draggable = []; - - /** - * A list of all Interactive Objects currently considered as being 'draggable' by any pointer, indexed by pointer ID. - * - * @name Phaser.Input.InputPlugin#_drag - * @type {[type]} - * @private - * @since 3.0.0 - */ - this._drag = { 0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [] }; - - /** - * A list of all Interactive Objects currently considered as being 'over' by any pointer, indexed by pointer ID. - * - * @name Phaser.Input.InputPlugin#_over - * @type {[type]} - * @private - * @since 3.0.0 - */ - this._over = { 0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [] }; - - /** - * [description] - * - * @name Phaser.Input.InputPlugin#_validTypes - * @type {[type]} - * @private - * @since 3.0.0 - */ - this._validTypes = [ 'onDown', 'onUp', 'onOver', 'onOut', 'onMove', 'onDragStart', 'onDrag', 'onDragEnd', 'onDragEnter', 'onDragLeave', 'onDragOver', 'onDrop' ]; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#boot - * @since 3.0.0 - */ - boot: function () - { - var eventEmitter = this.systems.events; - - eventEmitter.on('preupdate', this.preUpdate, this); - eventEmitter.on('update', this.update, this); - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); - - this.cameras = this.systems.cameras; - - this.displayList = this.systems.displayList; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#preUpdate - * @since 3.0.0 - * - * @return {[type]} [description] - */ - preUpdate: function () - { - var removeList = this._pendingRemoval; - var insertList = this._pendingInsertion; - - var toRemove = removeList.length; - var toInsert = insertList.length; - - if (toRemove === 0 && toInsert === 0) - { - // Quick bail - return; - } - - var current = this._list; - - // Delete old gameObjects - for (var i = 0; i < toRemove; i++) - { - var gameObject = removeList[i]; - - var index = current.indexOf(gameObject); - - if (index > -1) - { - current.splice(index, 1); - - this.clear(gameObject); - } - } - - // Clear the removal list - removeList.length = 0; - - // Move pendingInsertion to list (also clears pendingInsertion at the same time) - this._list = current.concat(insertList.splice(0)); - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#clear - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - * - * @return {Phaser.GameObjects.GameObject} [description] - */ - clear: function (gameObject) - { - var input = gameObject.input; - - input.gameObject = undefined; - input.target = undefined; - input.hitArea = undefined; - input.hitAreaCallback = undefined; - input.callbackContext = undefined; - - gameObject.input = null; - - // Clear from _draggable, _drag and _over - var index = this._draggable.indexOf(gameObject); - - if (index > -1) - { - this._draggable.splice(index, 1); - } - - index = this._drag[0].indexOf(gameObject); - - if (index > -1) - { - this._drag[0].splice(index, 1); - } - - index = this._over[0].indexOf(gameObject); - - if (index > -1) - { - this._over[0].splice(index, 1); - } - - return gameObject; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#disable - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - */ - disable: function (gameObject) - { - gameObject.input.enabled = false; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#enable - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - * @param {object} shape - [description] - * @param {function} callback - [description] - * @param {boolean} [dropZone=false] - [description] - * - * @return {Phaser.Input.InputPlugin} This Input Plugin. - */ - enable: function (gameObject, shape, callback, dropZone) - { - if (dropZone === undefined) { dropZone = false; } - - if (gameObject.input) - { - // If it is already has an InteractiveObject then just enable it and return - gameObject.input.enabled = true; - } - else - { - // Create an InteractiveObject and enable it - this.setHitArea(gameObject, shape, callback); - } - - gameObject.input.dropZone = dropZone; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#hitTestPointer - * @since 3.0.0 - * - * @param {Phaser.Input.Pointer} pointer - [description] - * - * @return {array} [description] - */ - hitTestPointer: function (pointer) - { - var camera = this.cameras.getCameraBelowPointer(pointer); - - if (camera) - { - pointer.camera = camera; - - // Get a list of all objects that can be seen by the camera below the pointer in the scene and store in 'output' array. - // All objects in this array are input enabled, as checked by the hitTest method, so we don't need to check later on as well. - var over = this.manager.hitTest(pointer.x, pointer.y, this._list, camera); - - // Filter out the drop zones - for (var i = 0; i < over.length; i++) - { - var obj = over[i]; - - if (obj.input.dropZone) - { - this._tempZones.push(obj); - } - } - - return over; - } - else - { - return []; - } - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#processDownEvents - * @since 3.0.0 - * - * @param {Phaser.Input.Pointer} pointer - [description] - * - * @return {[type]} [description] - */ - processDownEvents: function (pointer) - { - var currentlyOver = this._temp; - - // Contains ALL Game Objects currently over in the array - this.emit('pointerdown', pointer, currentlyOver); - - var total = 0; - - // Go through all objects the pointer was over and fire their events / callbacks - for (var i = 0; i < currentlyOver.length; i++) - { - var gameObject = currentlyOver[i]; - - if (!gameObject.input) - { - continue; - } - - total++; - - gameObject.emit('pointerdown', pointer, gameObject.input.localX, gameObject.input.localY, pointer.camera); - - this.emit('gameobjectdown', pointer, gameObject); - } - - return total; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#processDragEvents - * @since 3.0.0 - * - * @param {number} pointer - [description] - * @param {number} time - [description] - * - * @return {integer} [description] - */ - processDragEvents: function (pointer, time) - { - if (this._draggable.length === 0) - { - // There are no draggable items, so let's not even bother going further - return 0; - } - - var i; - var gameObject; - var list; - var input; - var currentlyOver = this._temp; - - // 0 = Not dragging anything - // 1 = Primary button down and objects below, so collect a draglist - // 2 = Pointer being checked if meets drag criteria - // 3 = Pointer meets criteria, notify the draglist - // 4 = Pointer actively dragging the draglist and has moved - // 5 = Pointer actively dragging but has been released, notify draglist - - if (pointer.dragState === 0 && pointer.primaryDown && pointer.justDown && currentlyOver.length > 0) - { - pointer.dragState = 1; - } - else if (pointer.dragState > 0 && !pointer.primaryDown && pointer.justUp) - { - pointer.dragState = 5; - } - - // Process the various drag states - - // 1 = Primary button down and objects below, so collect a draglist - if (pointer.dragState === 1) - { - // Get draggable objects, sort them, pick the top (or all) and store them somewhere - var draglist = []; - - for (i = 0; i < currentlyOver.length; i++) - { - gameObject = currentlyOver[i]; - - if (gameObject.input.draggable) - { - draglist.push(gameObject); - } - } - - if (draglist.length === 0) - { - pointer.dragState = 0; - - return 0; - } - else if (draglist.length > 1) - { - this.sortGameObjects(draglist); - - if (this.topOnly) - { - draglist.splice(1); - } - } - - // draglist now contains all potential candidates for dragging - this._drag[pointer.id] = draglist; - - if (this.dragDistanceThreshold === 0 && this.dragTimeThreshold === 0) - { - // No drag criteria, so snap immediately to mode 3 - pointer.dragState = 3; - } - else - { - // Check the distance / time - pointer.dragState = 2; - } - } - - // 2 = Pointer being checked if meets drag criteria - if (pointer.dragState === 2) - { - // Has it moved far enough to be considered a drag? - if (this.dragDistanceThreshold > 0 && DistanceBetween(pointer.x, pointer.y, pointer.downX, pointer.downY) >= this.dragDistanceThreshold) - { - // Alrighty, we've got a drag going on ... - pointer.dragState = 3; - } - - // Held down long enough to be considered a drag? - if (this.dragTimeThreshold > 0 && (time >= pointer.downTime + this.dragTimeThreshold)) - { - // Alrighty, we've got a drag going on ... - pointer.dragState = 3; - } - } - - // 3 = Pointer meets criteria and is freshly down, notify the draglist - if (pointer.dragState === 3) - { - list = this._drag[pointer.id]; - - for (i = 0; i < list.length; i++) - { - gameObject = list[i]; - - input = gameObject.input; - - input.dragState = 2; - - input.dragX = pointer.x - gameObject.x; - input.dragY = pointer.y - gameObject.y; - - input.dragStartX = gameObject.x; - input.dragStartY = gameObject.y; - - gameObject.emit('dragstart', pointer, input.dragX, input.dragY); - - this.emit('dragstart', pointer, gameObject); - } - - pointer.dragState = 4; - - return 1; - } - - // 4 = Pointer actively dragging the draglist and has moved - if (pointer.dragState === 4 && pointer.justMoved) - { - var dropZones = this._tempZones; - - list = this._drag[pointer.id]; - - for (i = 0; i < list.length; i++) - { - gameObject = list[i]; - - input = gameObject.input; - - // If this GO has a target then let's check it - if (input.target) - { - var index = dropZones.indexOf(input.target); - - // Got a target, are we still over it? - if (index === 0) - { - // We're still over it, and it's still the top of the display list, phew ... - gameObject.emit('dragover', pointer, input.target); - - this.emit('dragover', pointer, gameObject, input.target); - } - else if (index > 0) - { - // Still over it but it's no longer top of the display list (targets must always be at the top) - gameObject.emit('dragleave', pointer, input.target); - - this.emit('dragleave', pointer, gameObject, input.target); - - input.target = dropZones[0]; - - gameObject.emit('dragenter', pointer, input.target); - - this.emit('dragenter', pointer, gameObject, input.target); - } - else - { - // Nope, we've moved on (or the target has!), leave the old target - gameObject.emit('dragleave', pointer, input.target); - - this.emit('dragleave', pointer, gameObject, input.target); - - // Anything new to replace it? - // Yup! - if (dropZones[0]) - { - input.target = dropZones[0]; - - gameObject.emit('dragenter', pointer, input.target); - - this.emit('dragenter', pointer, gameObject, input.target); - } - else - { - // Nope - input.target = null; - } - } - } - else if (!input.target && dropZones[0]) - { - input.target = dropZones[0]; - - gameObject.emit('dragenter', pointer, input.target); - - this.emit('dragenter', pointer, gameObject, input.target); - } - - var dragX = pointer.x - gameObject.input.dragX; - var dragY = pointer.y - gameObject.input.dragY; - - gameObject.emit('drag', pointer, dragX, dragY); - - this.emit('drag', pointer, gameObject, dragX, dragY); - } - } - - // 5 = Pointer actively dragging but has been released, notify draglist - if (pointer.dragState === 5) - { - list = this._drag[pointer.id]; - - for (i = 0; i < list.length; i++) - { - gameObject = list[i]; - - input = gameObject.input; - - input.dragState = 0; - - input.dragX = input.localX - gameObject.displayOriginX; - input.dragY = input.localY - gameObject.displayOriginY; - - var dropped = false; - - if (input.target) - { - gameObject.emit('drop', pointer, input.target); - - this.emit('drop', pointer, gameObject, input.target); - - input.target = null; - - dropped = true; - } - - // And finally the dragend event - - gameObject.emit('dragend', pointer, input.dragX, input.dragY, dropped); - - this.emit('dragend', pointer, gameObject, dropped); - } - - pointer.dragState = 0; - } - - return (pointer.dragState > 0); - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#processMoveEvents - * @since 3.0.0 - * - * @param {Phaser.Input.Pointer} pointer - [description] - * - * @return {[type]} [description] - */ - processMoveEvents: function (pointer) - { - var currentlyOver = this._temp; - - this.emit('pointermove', pointer, currentlyOver); - - var total = 0; - - // Go through all objects the pointer was over and fire their events / callbacks - for (var i = 0; i < currentlyOver.length; i++) - { - var gameObject = currentlyOver[i]; - - if (!gameObject.input) - { - continue; - } - - total++; - - gameObject.emit('pointermove', pointer, gameObject.input.localX, gameObject.input.localY); - - this.emit('gameobjectmove', pointer, gameObject); - - if (this.topOnly) - { - break; - } - } - - return total; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#processOverOutEvents - * @since 3.0.0 - * - * @param {Phaser.Input.Pointer} pointer - [description] - * - * @return {[type]} [description] - */ - processOverOutEvents: function (pointer) - { - var currentlyOver = this._temp; - - var i; - var gameObject; - var justOut = []; - var justOver = []; - var stillOver = []; - var previouslyOver = this._over[pointer.id]; - var currentlyDragging = this._drag[pointer.id]; - - // Go through all objects the pointer was previously over, and see if it still is. - // Splits the previouslyOver array into two parts: justOut and stillOver - - for (i = 0; i < previouslyOver.length; i++) - { - gameObject = previouslyOver[i]; - - if (currentlyOver.indexOf(gameObject) === -1 && currentlyDragging.indexOf(gameObject) === -1) - { - // Not in the currentlyOver array, so must be outside of this object now - justOut.push(gameObject); - } - else - { - // In the currentlyOver array - stillOver.push(gameObject); - } - } - - // Go through all objects the pointer is currently over (the hit test results) - // and if not in the previouslyOver array we know it's a new entry, so add to justOver - for (i = 0; i < currentlyOver.length; i++) - { - gameObject = currentlyOver[i]; - - // Is this newly over? - - if (previouslyOver.indexOf(gameObject) === -1) - { - justOver.push(gameObject); - } - } - - // By this point the arrays are filled, so now we can process what happened... - - // Process the Just Out objects - var total = justOut.length; - - if (total > 0) - { - this.sortGameObjects(justOut); - - this.emit('pointerout', pointer, justOut); - - // Call onOut for everything in the justOut array - for (i = 0; i < total; i++) - { - gameObject = justOut[i]; - - if (!gameObject.input) - { - continue; - } - - this.emit('gameobjectout', pointer, gameObject); - - gameObject.emit('pointerout', pointer); - } - } - - // Process the Just Over objects - total = justOver.length; - - if (total > 0) - { - this.sortGameObjects(justOver); - - this.emit('pointerover', pointer, justOver); - - // Call onOver for everything in the justOver array - for (i = 0; i < total; i++) - { - gameObject = justOver[i]; - - if (!gameObject.input) - { - continue; - } - - this.emit('gameobjectover', pointer, gameObject); - - gameObject.emit('pointerover', pointer, gameObject.input.localX, gameObject.input.localY); - } - } - - // Add the contents of justOver to the previously over array - previouslyOver = stillOver.concat(justOver); - - // Then sort it into display list order - this._over[pointer.id] = this.sortGameObjects(previouslyOver); - - return previouslyOver.length; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#processUpEvents - * @since 3.0.0 - * - * @param {Phaser.Input.Pointer} pointer - [description] - */ - processUpEvents: function (pointer) - { - var currentlyOver = this._temp; - - // Contains ALL Game Objects currently up in the array - this.emit('pointerup', pointer, currentlyOver); - - // Go through all objects the pointer was over and fire their events / callbacks - for (var i = 0; i < currentlyOver.length; i++) - { - var gameObject = currentlyOver[i]; - - if (!gameObject.input) - { - continue; - } - - gameObject.emit('pointerup', pointer, gameObject.input.localX, gameObject.input.localY); - - this.emit('gameobjectup', pointer, gameObject); - } - - return currentlyOver.length; - }, - - /** - * Queues a Game Object for insertion into this Input Manager on the next update. - * - * @method Phaser.Input.InputPlugin#queueForInsertion - * @since 3.0.0 - * - * @param {[type]} child - [description] - * - * @return {[type]} [description] - */ - queueForInsertion: function (child) - { - if (this._pendingInsertion.indexOf(child) === -1 && this._list.indexOf(child) === -1) - { - this._pendingInsertion.push(child); - } - - return this; - }, - - /** - * Queues a Game Object for removal from this Input Manager on the next update. - * - * @method Phaser.Input.InputPlugin#queueForRemoval - * @since 3.0.0 - * - * @param {[type]} child - [description] - * - * @return {[type]} [description] - */ - queueForRemoval: function (child) - { - this._pendingRemoval.push(child); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setDraggable - * @since 3.0.0 - * - * @param {[type]} gameObjects - [description] - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setDraggable: function (gameObjects, value) - { - if (value === undefined) { value = true; } - - if (!Array.isArray(gameObjects)) - { - gameObjects = [ gameObjects ]; - } - - for (var i = 0; i < gameObjects.length; i++) - { - var gameObject = gameObjects[i]; - - gameObject.input.draggable = value; - - var index = this._draggable.indexOf(gameObject); - - if (value && index === -1) - { - this._draggable.push(gameObject); - } - else if (!value && index > -1) - { - this._draggable.splice(index, 1); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setHitArea - * @since 3.0.0 - * - * @param {[type]} gameObjects - [description] - * @param {[type]} shape - [description] - * @param {[type]} callback - [description] - * - * @return {[type]} [description] - */ - setHitArea: function (gameObjects, shape, callback) - { - if (shape === undefined) - { - return this.setHitAreaFromTexture(gameObjects); - } - - if (!Array.isArray(gameObjects)) - { - gameObjects = [ gameObjects ]; - } - - for (var i = 0; i < gameObjects.length; i++) - { - var gameObject = gameObjects[i]; - - gameObject.input = InteractiveObject(gameObject, shape, callback); - - this.queueForInsertion(gameObject); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setHitAreaCircle - * @since 3.0.0 - * - * @param {[type]} gameObjects - [description] - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} radius - [description] - * @param {[type]} callback - [description] - * - * @return {[type]} [description] - */ - setHitAreaCircle: function (gameObjects, x, y, radius, callback) - { - if (callback === undefined) { callback = CircleContains; } - - var shape = new Circle(x, y, radius); - - return this.setHitArea(gameObjects, shape, callback); - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setHitAreaEllipse - * @since 3.0.0 - * - * @param {[type]} gameObjects - [description] - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} width - [description] - * @param {[type]} height - [description] - * @param {[type]} callback - [description] - * - * @return {[type]} [description] - */ - setHitAreaEllipse: function (gameObjects, x, y, width, height, callback) - { - if (callback === undefined) { callback = EllipseContains; } - - var shape = new Ellipse(x, y, width, height); - - return this.setHitArea(gameObjects, shape, callback); - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setHitAreaFromTexture - * @since 3.0.0 - * - * @param {[type]} gameObjects - [description] - * @param {[type]} callback - [description] - * - * @return {[type]} [description] - */ - setHitAreaFromTexture: function (gameObjects, callback) - { - if (callback === undefined) { callback = RectangleContains; } - - if (!Array.isArray(gameObjects)) - { - gameObjects = [ gameObjects ]; - } - - for (var i = 0; i < gameObjects.length; i++) - { - var gameObject = gameObjects[i]; - var frame = gameObject.frame; - - var width = 0; - var height = 0; - - if (frame) - { - width = frame.realWidth; - height = frame.realHeight; - } - else if (gameObject.width) - { - width = gameObject.width; - height = gameObject.height; - } - - if (width !== 0 && height !== 0) - { - gameObject.input = InteractiveObject(gameObject, new Rectangle(0, 0, width, height), callback); - - this.queueForInsertion(gameObject); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setHitAreaRectangle - * @since 3.0.0 - * - * @param {[type]} gameObjects - [description] - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} width - [description] - * @param {[type]} height - [description] - * @param {[type]} callback - [description] - * - * @return {[type]} [description] - */ - setHitAreaRectangle: function (gameObjects, x, y, width, height, callback) - { - if (callback === undefined) { callback = RectangleContains; } - - var shape = new Rectangle(x, y, width, height); - - return this.setHitArea(gameObjects, shape, callback); - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setHitAreaTriangle - * @since 3.0.0 - * - * @param {[type]} gameObjects - [description] - * @param {[type]} x1 - [description] - * @param {[type]} y1 - [description] - * @param {[type]} x2 - [description] - * @param {[type]} y2 - [description] - * @param {[type]} x3 - [description] - * @param {[type]} y3 - [description] - * @param {[type]} callback - [description] - * - * @return {[type]} [description] - */ - setHitAreaTriangle: function (gameObjects, x1, y1, x2, y2, x3, y3, callback) - { - if (callback === undefined) { callback = TriangleContains; } - - var shape = new Triangle(x1, y1, x2, y2, x3, y3); - - return this.setHitArea(gameObjects, shape, callback); - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setPollAlways - * @since 3.0.0 - * - * @return {[type]} [description] - */ - setPollAlways: function () - { - this.pollRate = 0; - this._pollTimer = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setPollOnMove - * @since 3.0.0 - * - * @return {[type]} [description] - */ - setPollOnMove: function () - { - this.pollRate = -1; - this._pollTimer = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setPollRate - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setPollRate: function (value) - { - this.pollRate = value; - this._pollTimer = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setGlobalTopOnly - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setGlobalTopOnly: function (value) - { - this.manager.globalTopOnly = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setTopOnly - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setTopOnly: function (value) - { - this.topOnly = value; - - return this; - }, - - /** - * Given an array of Game Objects, sort the array and return it, - * so that the objects are in index order with the lowest at the bottom. - * - * @method Phaser.Input.InputPlugin#sortGameObjects - * @since 3.0.0 - * - * @param {[type]} gameObjects - [description] - * - * @return {[type]} [description] - */ - sortGameObjects: function (gameObjects) - { - if (gameObjects.length < 2) - { - return gameObjects; - } - - this.scene.sys.depthSort(); - - return gameObjects.sort(this.sortHandlerGO.bind(this)); - }, - - /** - * Return the child lowest down the display list (with the smallest index) - * - * @method Phaser.Input.InputPlugin#sortHandlerGO - * @since 3.0.0 - * - * @param {[type]} childA - [description] - * @param {[type]} childB - [description] - * - * @return {[type]} [description] - */ - sortHandlerGO: function (childA, childB) - { - // The higher the index, the lower down the display list they are. - // So entry 0 will be the top-most item (visually) - var indexA = this.displayList.getIndex(childA); - var indexB = this.displayList.getIndex(childB); - - if (indexA < indexB) - { - return 1; - } - else if (indexA > indexB) - { - return -1; - } - - // Technically this shouldn't happen, but if the GO wasn't part of this display list then it'll - // have an index of -1, so in some cases it can - return 0; - }, - - /** - * Return the child lowest down the display list (with the smallest index) - * - * @method Phaser.Input.InputPlugin#sortHandlerIO - * @since 3.0.0 - * - * @param {[type]} childA - [description] - * @param {[type]} childB - [description] - * - * @return {[type]} [description] - */ - sortHandlerIO: function (childA, childB) - { - // The higher the index, the lower down the display list they are. - // So entry 0 will be the top-most item (visually) - var indexA = this.displayList.getIndex(childA.gameObject); - var indexB = this.displayList.getIndex(childB.gameObject); - - if (indexA < indexB) - { - return 1; - } - else if (indexA > indexB) - { - return -1; - } - - // Technically this shouldn't happen, but if the GO wasn't part of this display list then it'll - // have an index of -1, so in some cases it can - return 0; - }, - - /** - * Given an array of Interactive Objects, sort the array and return it, - * so that the objects are in index order with the lowest at the bottom. - * - * @method Phaser.Input.InputPlugin#sortInteractiveObjects - * @since 3.0.0 - * - * @param {[type]} interactiveObjects - [description] - * - * @return {[type]} [description] - */ - sortInteractiveObjects: function (interactiveObjects) - { - if (interactiveObjects.length < 2) - { - return interactiveObjects; - } - - this.scene.sys.depthSort(); - - return interactiveObjects.sort(this.sortHandlerIO.bind(this)); - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#stopPropagation - * @since 3.0.0 - * - * @return {[type]} [description] - */ - stopPropagation: function () - { - if (this.manager.globalTopOnly) - { - this.manager.ignoreEvents = true; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#update - * @since 3.0.0 - * - * @param {number} time - [description] - * @param {number} delta - [description] - */ - update: function (time, delta) - { - var manager = this.manager; - - // Another Scene above this one has already consumed the input events - if (manager.globalTopOnly && manager.ignoreEvents) - { - return; - } - - var pointer = manager.activePointer; - - var runUpdate = (pointer.dirty || this.pollRate === 0); - - if (this.pollRate > -1) - { - this._pollTimer -= delta; - - if (this._pollTimer < 0) - { - runUpdate = true; - - // Discard timer diff - this._pollTimer = this.pollRate; - } - } - - if (!runUpdate) - { - return; - } - - // Always reset this array - this._tempZones = []; - - // _temp contains a hit tested and camera culled list of IO objects - this._temp = this.hitTestPointer(pointer); - - this.sortGameObjects(this._temp); - this.sortGameObjects(this._tempZones); - - if (this.topOnly) - { - // Only the top-most one counts now, so safely ignore the rest - if (this._temp.length) - { - this._temp.splice(1); - } - - if (this._tempZones.length) - { - this._tempZones.splice(1); - } - } - - var total = this.processDragEvents(pointer, time); - - if (!pointer.wasTouch) - { - total += this.processOverOutEvents(pointer); - } - - if (pointer.justDown) - { - total += this.processDownEvents(pointer); - } - - if (pointer.justUp) - { - total += this.processUpEvents(pointer); - } - - if (pointer.justMoved) - { - total += this.processMoveEvents(pointer); - } - - if (total > 0 && manager.globalTopOnly) - { - // We interacted with an event in this Scene, so block any Scenes below us from doing the same this frame - manager.ignoreEvents = true; - } - }, - - /** - * The Scene that owns this plugin is shutting down. - * - * @method Phaser.Input.InputPlugin#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this._temp.length = 0; - this._list.length = 0; - this._draggable.length = 0; - this._pendingRemoval.length = 0; - this._pendingInsertion.length = 0; - - for (var i = 0; i < 10; i++) - { - this._drag[i] = []; - this._over[i] = []; - } - - this.removeAllListeners(); - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.shutdown(); - - this.scene = undefined; - this.cameras = undefined; - this.manager = undefined; - this.events = undefined; - this.keyboard = undefined; - this.mouse = undefined; - this.gamepad = undefined; - }, - - /** - * The current active input Pointer. - * - * @name Phaser.Input.InputPlugin#activePointer - * @type {Phaser.Input.Pointer} - * @readOnly - * @since 3.0.0 - */ - activePointer: { - - get: function () - { - return this.manager.activePointer; - } - - }, - - /** - * The x coordinates of the ActivePointer based on the first camera in the camera list. - * This is only safe to use if your game has just 1 non-transformed camera and doesn't use multi-touch. - * - * @name Phaser.Input.InputPlugin#x - * @type {number} - * @readOnly - * @since 3.0.0 - */ - x: { - - get: function () - { - return this.manager.activePointer.x; - } - - }, - - /** - * The y coordinates of the ActivePointer based on the first camera in the camera list. - * This is only safe to use if your game has just 1 non-transformed camera and doesn't use multi-touch. - * - * @name Phaser.Input.InputPlugin#y - * @type {number} - * @readOnly - * @since 3.0.0 - */ - y: { - - get: function () - { - return this.manager.activePointer.y; - } - - } - -}); - -PluginManager.register('InputPlugin', InputPlugin, 'input'); - -module.exports = InputPlugin; +module.exports = Clone; /***/ }), /* 768 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculates the area of the Ellipse. + * + * @function Phaser.Geom.Ellipse.Area + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the area of. + * + * @return {number} The area of the Ellipse. + */ +var Area = function (ellipse) +{ + if (ellipse.isEmpty()) + { + return 0; + } + + // units squared + return (ellipse.getMajorRadius() * ellipse.getMinorRadius() * Math.PI); +}; + +module.exports = Area; + + +/***/ }), +/* 769 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -106606,69 +104549,204 @@ module.exports = InputPlugin; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * @namespace Phaser.Input.Keyboard - */ - -module.exports = { - - KeyboardManager: __webpack_require__(245), - - Key: __webpack_require__(246), - KeyCodes: __webpack_require__(129), - - KeyCombo: __webpack_require__(247), - - JustDown: __webpack_require__(769), - JustUp: __webpack_require__(770), - DownDuration: __webpack_require__(771), - UpDuration: __webpack_require__(772) - -}; - - -/***/ }), -/* 769 */ -/***/ (function(module, exports) { +var GameObject = __webpack_require__(1); /** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * The justDown value allows you to test if this Key has just been pressed down or not. - * When you check this value it will return `true` if the Key is down, otherwise `false`. - * You can only call justDown once per key press. It will only return `true` once, until the Key is released and pressed down again. - * This allows you to use it in situations where you want to check if this key is down without using a Signal, such as in a core game loop. + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. * - * @function Phaser.Input.Keyboard.JustDown + * @method Phaser.GameObjects.DynamicBitmapText#renderCanvas * @since 3.0.0 + * @private * - * @param {Phaser.Input.Keyboard.Key} key - [description] - * - * @return {boolean} [description] + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.DynamicBitmapText} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. */ -var JustDown = function (key) +var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera) { - var current = false; + var text = src.text; + var textLength = text.length; - if (key.isDown) + if (GameObject.RENDER_MASK !== src.renderFlags || textLength === 0 || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) { - current = key._justDown; - key._justDown = false; + return; + } + + var textureFrame = src.frame; + + var displayCallback = src.displayCallback; + + var cameraScrollX = camera.scrollX * src.scrollFactorX; + var cameraScrollY = camera.scrollY * src.scrollFactorY; + + var chars = src.fontData.chars; + var lineHeight = src.fontData.lineHeight; + + var xAdvance = 0; + var yAdvance = 0; + + var indexCount = 0; + var charCode = 0; + + var glyph = null; + var glyphX = 0; + var glyphY = 0; + var glyphW = 0; + var glyphH = 0; + + var x = 0; + var y = 0; + + var lastGlyph = null; + var lastCharCode = 0; + + var ctx = renderer.currentContext; + var image = src.frame.source.image; + + var textureX = textureFrame.cutX; + var textureY = textureFrame.cutY; + + var rotation = 0; + var scale = (src.fontSize / src.fontData.size); + + // Blend Mode + if (renderer.currentBlendMode !== src.blendMode) + { + renderer.currentBlendMode = src.blendMode; + ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; } - return current; + // Alpha + if (renderer.currentAlpha !== src.alpha) + { + renderer.currentAlpha = src.alpha; + ctx.globalAlpha = src.alpha; + } + + // Smoothing + if (renderer.currentScaleMode !== src.scaleMode) + { + renderer.currentScaleMode = src.scaleMode; + } + + ctx.save(); + + ctx.translate(src.x, src.y); + + ctx.rotate(src.rotation); + + ctx.translate(-src.displayOriginX, -src.displayOriginY); + + ctx.scale(src.scaleX, src.scaleY); + + if (src.cropWidth > 0 && src.cropHeight > 0) + { + ctx.save(); + ctx.beginPath(); + ctx.rect(0, 0, src.cropWidth, src.cropHeight); + ctx.clip(); + } + + var roundPixels = renderer.config.roundPixels; + + for (var index = 0; index < textLength; ++index) + { + // Reset the scale (in case the callback changed it) + scale = (src.fontSize / src.fontData.size); + rotation = 0; + + charCode = text.charCodeAt(index); + + if (charCode === 10) + { + xAdvance = 0; + indexCount = 0; + yAdvance += lineHeight; + lastGlyph = null; + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + glyphX = textureX + glyph.x; + glyphY = textureY + glyph.y; + + glyphW = glyph.width; + glyphH = glyph.height; + + x = (indexCount + glyph.xOffset + xAdvance) - src.scrollX; + y = (glyph.yOffset + yAdvance) - src.scrollY; + + // This could be optimized so that it doesn't even bother drawing it if the x/y is out of range + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + if (displayCallback) + { + var output = displayCallback({ tint: { topLeft: 0, topRight: 0, bottomLeft: 0, bottomRight: 0 }, index: index, charCode: charCode, x: x, y: y, scale: scale, rotation: 0, data: glyph.data }); + + x = output.x; + y = output.y; + scale = output.scale; + rotation = output.rotation; + } + + x *= scale; + y *= scale; + + x -= cameraScrollX; + y -= cameraScrollY; + + if (roundPixels) + { + x |= 0; + y |= 0; + } + + ctx.save(); + + ctx.translate(x, y); + + ctx.rotate(rotation); + + ctx.scale(scale, scale); + + ctx.drawImage(image, glyphX, glyphY, glyphW, glyphH, 0, 0, glyphW, glyphH); + + ctx.restore(); + + xAdvance += glyph.xAdvance; + indexCount += 1; + lastGlyph = glyph; + lastCharCode = charCode; + } + + if (src.cropWidth > 0 && src.cropHeight > 0) + { + ctx.restore(); + } + + ctx.restore(); }; -module.exports = JustDown; +module.exports = DynamicBitmapTextCanvasRenderer; /***/ }), /* 770 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -106676,38 +104754,41 @@ module.exports = JustDown; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * The justUp value allows you to test if this Key has just been released or not. - * When you check this value it will return `true` if the Key is up, otherwise `false`. - * You can only call justUp once per key release. It will only return `true` once, until the Key is pressed down and released again. - * This allows you to use it in situations where you want to check if this key is up without using a Signal, such as in a core game loop. - * - * @function Phaser.Input.Keyboard.JustUp - * @since 3.0.0 - * - * @param {Phaser.Input.Keyboard.Key} key - [description] - * - * @return {boolean} [description] - */ -var JustUp = function (key) -{ - var current = false; +var GameObject = __webpack_require__(1); - if (key.isDown) +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.DynamicBitmapText#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.DynamicBitmapText} gameObject - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var DynamicBitmapTextWebGLRenderer = function (renderer, bitmapText, interpolationPercentage, camera) +{ + var text = bitmapText.text; + var textLength = text.length; + + if (GameObject.RENDER_MASK !== bitmapText.renderFlags || textLength === 0 || (bitmapText.cameraFilter > 0 && (bitmapText.cameraFilter & camera._id))) { - current = key._justUp; - key._justUp = false; + return; } - return current; + this.pipeline.batchDynamicBitmapText(bitmapText, camera); }; -module.exports = JustUp; +module.exports = DynamicBitmapTextWebGLRenderer; /***/ }), /* 771 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -106715,31 +104796,30 @@ module.exports = JustUp; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * Returns `true` if the Key was pressed down within the `duration` value given, or `false` if it either isn't down, - * or was pressed down longer ago than then given duration. - * - * @function Phaser.Input.Keyboard.DownDuration - * @since 3.0.0 - * - * @param {Phaser.Input.Keyboard.Key} key - [description] - * @param {integer} duration - [description] - * - * @return {boolean} [description] - */ -var DownDuration = function (key, duration) +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); + +if (true) { - if (duration === undefined) { duration = 50; } + renderWebGL = __webpack_require__(770); +} + +if (true) +{ + renderCanvas = __webpack_require__(769); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas - return (key.isDown && key.duration < duration); }; -module.exports = DownDuration; - /***/ }), /* 772 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -106747,26 +104827,339 @@ module.exports = DownDuration; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); + /** - * Returns `true` if the Key was released within the `duration` value given, or `false` if it either isn't up, - * or was released longer ago than then given duration. + * @classdesc + * A Bob Game Object. * - * @function Phaser.Input.Keyboard.UpDuration + * A Bob belongs to a Blitter Game Object. The Blitter is responsible for managing and rendering this object. + * + * A Bob has a position, alpha value and a frame from a texture that it uses to render with. You can also toggle + * the flipped and visible state of the Bob. The Frame the Bob uses to render can be changed dynamically, but it + * must be a Frame within the Texture used by the parent Blitter. + * + * Bob positions are relative to the Blitter parent. So if you move the Blitter parent, all Bob children will + * have their positions impacted by this change as well. + * + * You can manipulate Bob objects directly from your game code, but the creation and destruction of them should be + * handled via the Blitter parent. + * + * @class Bob + * @memberOf Phaser.GameObjects.Blitter + * @constructor * @since 3.0.0 * - * @param {Phaser.Input.Keyboard.Key} key - [description] - * @param {integer} [duration] - [description] - * - * @return {boolean} [description] + * @param {Phaser.GameObjects.Blitter} blitter - The parent Blitter object is responsible for updating this Bob. + * @param {number} x - The horizontal position of this Game Object in the world, relative to the parent Blitter position. + * @param {number} y - The vertical position of this Game Object in the world, relative to the parent Blitter position. + * @param {(string|integer)} frame - The Frame this Bob will render with, as defined in the Texture the parent Blitter is using. + * @param {boolean} visible - Should the Bob render visible or not to start with? */ -var UpDuration = function (key, duration) -{ - if (duration === undefined) { duration = 50; } +var Bob = new Class({ - return (key.isUp && key.duration < duration); -}; + initialize: -module.exports = UpDuration; + function Bob (blitter, x, y, frame, visible) + { + /** + * [description] + * + * @name Phaser.GameObjects.Blitter.Bob#parent + * @type {Phaser.GameObjects.Blitter} + * @since 3.0.0 + */ + this.parent = blitter; + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter.Bob#x + * @type {number} + * @since 3.0.0 + */ + this.x = x; + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter.Bob#y + * @type {number} + * @since 3.0.0 + */ + this.y = y; + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter.Bob#frame + * @type {(string|integer)} + * @since 3.0.0 + */ + this.frame = frame; + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter.Bob#data + * @type {object} + * @default {} + * @since 3.0.0 + */ + this.data = {}; + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter.Bob#_visible + * @type {boolean} + * @private + * @since 3.0.0 + */ + this._visible = visible; + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter.Bob#_alpha + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + this._alpha = 1; + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter.Bob#flipX + * @type {boolean} + * @since 3.0.0 + */ + this.flipX = false; + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter.Bob#flipY + * @type {boolean} + * @since 3.0.0 + */ + this.flipY = false; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter.Bob#setFrame + * @since 3.0.0 + * + * @param {Phaser.Textures.Frame} [frame] - [description] + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setFrame: function (frame) + { + if (frame === undefined) + { + frame = this.parent.frame; + } + else + { + frame = this.parent.texture.get(frame); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter.Bob#resetFlip + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + resetFlip: function () + { + this.flipX = false; + this.flipY = false; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter.Bob#reset + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {Phaser.Textures.Frame} frame - [description] + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + reset: function (x, y, frame) + { + this.x = x; + this.y = y; + this.frame = frame; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter.Bob#setFlipX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setFlipX: function (value) + { + this.flipX = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter.Bob#setFlipY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setFlipY: function (value) + { + this.flipY = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter.Bob#setFlip + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setFlip: function (x, y) + { + this.flipX = x; + this.flipY = y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter.Bob#setVisible + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setVisible: function (value) + { + this.visible = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter.Bob#setAlpha + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setAlpha: function (value) + { + this.alpha = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter.Bob#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.parent.dirty = true; + + this.parent.children.remove(this); + + this.parent = undefined; + this.frame = undefined; + this.data = undefined; + }, + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter.Bob#visible + * @type {boolean} + * @since 3.0.0 + */ + visible: { + + get: function () + { + return this._visible; + }, + + set: function (value) + { + this._visible = value; + this.parent.dirty = true; + } + + }, + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter.Bob#alpha + * @type {number} + * @since 3.0.0 + */ + alpha: { + + get: function () + { + return this._alpha; + }, + + set: function (value) + { + this._alpha = value; + this.parent.dirty = true; + } + + } + +}); + +module.exports = Bob; /***/ }), @@ -106779,17 +105172,77 @@ module.exports = UpDuration; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var GameObject = __webpack_require__(1); + /** - * @namespace Phaser.Input.Mouse + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Blitter#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Blitter} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. */ +var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } -/* eslint-disable */ -module.exports = { + var list = src.getRenderList(); - MouseManager: __webpack_require__(248) - + renderer.setBlendMode(src.blendMode); + + var ctx = renderer.gameContext; + var cameraScrollX = src.x - camera.scrollX * src.scrollFactorX; + var cameraScrollY = src.y - camera.scrollY * src.scrollFactorY; + + // Render bobs + for (var i = 0; i < list.length; i++) + { + var bob = list[i]; + var flip = (bob.flipX || bob.flipY); + var frame = bob.frame; + var cd = frame.canvasData; + var dx = frame.x; + var dy = frame.y; + var fx = 1; + var fy = 1; + + if (!flip) + { + renderer.blitImage(dx + bob.x + cameraScrollX, dy + bob.y + cameraScrollY, bob.frame); + } + else + { + if (bob.flipX) + { + fx = -1; + dx -= cd.dWidth; + } + + if (bob.flipY) + { + fy = -1; + dy -= cd.dHeight; + } + + ctx.save(); + ctx.translate(bob.x + cameraScrollX, bob.y + cameraScrollY); + ctx.scale(fx, fy); + ctx.drawImage(frame.source.image, cd.sx, cd.sy, cd.sWidth, cd.sHeight, dx, dy, cd.dWidth, cd.dHeight); + ctx.restore(); + } + } }; -/* eslint-enable */ + +module.exports = BlitterCanvasRenderer; /***/ }), @@ -106802,17 +105255,33 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var GameObject = __webpack_require__(1); + /** - * @namespace Phaser.Input.Touch + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Blitter#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Blitter} gameObject - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. */ +var BlitterWebGLRenderer = function (renderer, gameObject, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== gameObject.renderFlags || (gameObject.cameraFilter > 0 && (gameObject.cameraFilter & camera._id))) + { + return; + } -/* eslint-disable */ -module.exports = { - - TouchManager: __webpack_require__(250) - + this.pipeline.drawBlitter(gameObject, camera); }; -/* eslint-enable */ + +module.exports = BlitterWebGLRenderer; /***/ }), @@ -106825,21 +105294,23 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * @namespace Phaser.Loader - */ +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); + +if (true) +{ + renderWebGL = __webpack_require__(774); +} + +if (true) +{ + renderCanvas = __webpack_require__(773); +} module.exports = { - FileTypes: __webpack_require__(776), - - File: __webpack_require__(18), - FileTypesManager: __webpack_require__(7), - GetURL: __webpack_require__(150), - LoaderPlugin: __webpack_require__(792), - MergeXHRSettings: __webpack_require__(151), - XHRLoader: __webpack_require__(315), - XHRSettings: __webpack_require__(90) + renderWebGL: renderWebGL, + renderCanvas: renderCanvas }; @@ -106854,59 +105325,175 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * @namespace Phaser.Loader.FileTypes - */ +var GameObject = __webpack_require__(1); /** - * @typedef {object} XHRConfig + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. * - * @property {string} key - [description] - * @property {string} texture - [description] - * @property {string} [data] - [description] - * @property {XHRConfig} [xhr] - [description] - */ - -/** - * @typedef {object} FileTypeConfig + * @method Phaser.GameObjects.BitmapText#renderCanvas + * @since 3.0.0 + * @private * - * @property {string} key - [description] - * @property {string} texture - [description] - * @property {string} [data] - [description] - * @property {string} [url] - [description] - * @property {string} [path] - [description] - * @property {string} [extension] - [description] - * @property {string} [responseType] - [description] - * @property {object} [config] - [description] - * @property {XHRConfig} [xhr] - [description] + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.BitmapText} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. */ +var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera) +{ + var text = src.text; + var textLength = text.length; -module.exports = { + if (GameObject.RENDER_MASK !== src.renderFlags || textLength === 0 || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + var textureFrame = src.frame; - AnimationJSONFile: __webpack_require__(777), - AtlasJSONFile: __webpack_require__(778), - AudioFile: __webpack_require__(316), - AudioSprite: __webpack_require__(779), - BinaryFile: __webpack_require__(780), - BitmapFontFile: __webpack_require__(781), - GLSLFile: __webpack_require__(782), - HTML5AudioFile: __webpack_require__(317), - HTMLFile: __webpack_require__(783), - ImageFile: __webpack_require__(58), - JSONFile: __webpack_require__(57), - MultiAtlas: __webpack_require__(784), - PluginFile: __webpack_require__(785), - ScriptFile: __webpack_require__(786), - SpriteSheetFile: __webpack_require__(787), - SVGFile: __webpack_require__(788), - TextFile: __webpack_require__(320), - TilemapCSVFile: __webpack_require__(789), - TilemapJSONFile: __webpack_require__(790), - UnityAtlasFile: __webpack_require__(791), - XMLFile: __webpack_require__(318) + var chars = src.fontData.chars; + var lineHeight = src.fontData.lineHeight; + var xAdvance = 0; + var yAdvance = 0; + + var indexCount = 0; + var charCode = 0; + + var glyph = null; + var glyphX = 0; + var glyphY = 0; + var glyphW = 0; + var glyphH = 0; + + var x = 0; + var y = 0; + + var lastGlyph = null; + var lastCharCode = 0; + + var ctx = renderer.currentContext; + var image = src.frame.source.image; + + var textureX = textureFrame.cutX; + var textureY = textureFrame.cutY; + + var scale = (src.fontSize / src.fontData.size); + + // Blend Mode + if (renderer.currentBlendMode !== src.blendMode) + { + renderer.currentBlendMode = src.blendMode; + ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; + } + + // Alpha + if (renderer.currentAlpha !== src.alpha) + { + renderer.currentAlpha = src.alpha; + ctx.globalAlpha = src.alpha; + } + + // Smoothing + if (renderer.currentScaleMode !== src.scaleMode) + { + renderer.currentScaleMode = src.scaleMode; + } + + var roundPixels = renderer.config.roundPixels; + + var tx = (src.x - camera.scrollX * src.scrollFactorX) + src.frame.x; + var ty = (src.y - camera.scrollY * src.scrollFactorY) + src.frame.y; + + if (roundPixels) + { + tx |= 0; + ty |= 0; + } + + ctx.save(); + + ctx.translate(tx, ty); + + ctx.rotate(src.rotation); + + ctx.translate(-src.displayOriginX, -src.displayOriginY); + + ctx.scale(src.scaleX, src.scaleY); + + for (var index = 0; index < textLength; ++index) + { + charCode = text.charCodeAt(index); + + if (charCode === 10) + { + xAdvance = 0; + indexCount = 0; + yAdvance += lineHeight; + lastGlyph = null; + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + glyphX = textureX + glyph.x; + glyphY = textureY + glyph.y; + + glyphW = glyph.width; + glyphH = glyph.height; + + x = indexCount + glyph.xOffset + xAdvance; + y = glyph.yOffset + yAdvance; + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + x *= scale; + y *= scale; + + xAdvance += glyph.xAdvance; + indexCount += 1; + lastGlyph = glyph; + lastCharCode = charCode; + + // Nothing to render or a space? Then skip to the next glyph + if (glyphW === 0 || glyphH === 0 || charCode === 32) + { + continue; + } + + if (roundPixels) + { + x |= 0; + y |= 0; + } + + ctx.save(); + + ctx.translate(x, y); + + ctx.scale(scale, scale); + + ctx.drawImage(image, glyphX, glyphY, glyphW, glyphH, 0, 0, glyphW, glyphH); + + ctx.restore(); + } + + ctx.restore(); }; +module.exports = BitmapTextCanvasRenderer; + /***/ }), /* 777 */ @@ -106918,76 +105505,36 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var FileTypesManager = __webpack_require__(7); -var JSONFile = __webpack_require__(57); +var GameObject = __webpack_require__(1); /** - * An Animation JSON File. + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. * - * @function Phaser.Loader.Filetypes.AnimationJSONFile + * @method Phaser.GameObjects.BitmapText#renderWebGL * @since 3.0.0 + * @private * - * @param {string} key - The key of the file within the loader. - * @param {string} url - The url to load the file from. - * @param {string} path - The path of the file. - * @param {object} xhrSettings - Optional file specific XHR settings. - * - * @return {Phaser.Loader.Filetypes.AnimationJSONFile} A File instance to be added to the Loader. + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.BitmapText} gameObject - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. */ -var AnimationJSONFile = function (key, url, path, xhrSettings) +var BitmapTextWebGLRenderer = function (renderer, gameObject, interpolationPercentage, camera) { - var json = new JSONFile(key, url, path, xhrSettings); + var text = gameObject.text; + var textLength = text.length; - // Override the File type - json.type = 'animationJSON'; + if (GameObject.RENDER_MASK !== gameObject.renderFlags || textLength === 0 || (gameObject.cameraFilter > 0 && (gameObject.cameraFilter & camera._id))) + { + return; + } - return json; + this.pipeline.batchBitmapText(this, camera); }; -/** - * Adds an Animation JSON file to the current load queue. - * - * Note: This method will only be available if the Animation JSON File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#animation - * @since 3.0.0 - * - * @param {string|array|object} key - A unique string to be used as the key to reference this file from the Cache. Must be unique within this file type. - * @param {string} [url] - URL of the file. If `undefined` or `null` the url will be set to `.json`, - * i.e. if `key` was "alien" then the URL will be "alien.json". - * @param {object} [xhrSettings] - File specific XHR settings to be used during the load. These settings are merged with the global Loader XHR settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('animation', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new AnimationJSONFile(key[i], url, this.path, xhrSettings)); - } - } - else - { - this.addFile(new AnimationJSONFile(key, url, this.path, xhrSettings)); - } - - // For method chaining - return this; -}); - -// When registering a factory function 'this' refers to the Loader context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory - -module.exports = AnimationJSONFile; +module.exports = BitmapTextWebGLRenderer; /***/ }), @@ -107000,86 +105547,26 @@ module.exports = AnimationJSONFile; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var FileTypesManager = __webpack_require__(7); -var ImageFile = __webpack_require__(58); -var JSONFile = __webpack_require__(57); +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); -/** - * An Atlas JSON File. - * - * @function Phaser.Loader.Filetypes.AtlasJSONFile - * @since 3.0.0 - * - * @param {string} key - The key of the file within the loader. - * @param {string} textureURL - The url to load the texture file from. - * @param {string} atlasURL - The url to load the atlas file from. - * @param {string} path - The path of the file. - * @param {object} textureXhrSettings - Optional texture file specific XHR settings. - * @param {object} atlasXhrSettings - Optional atlas file specific XHR settings. - * - * @return {object} An object containing two File objects to be added to the loader. - */ -var AtlasJSONFile = function (key, textureURL, atlasURL, path, textureXhrSettings, atlasXhrSettings) +if (true) { - var image = new ImageFile(key, textureURL, path, textureXhrSettings); - var data = new JSONFile(key, atlasURL, path, atlasXhrSettings); + renderWebGL = __webpack_require__(777); +} - // Link them together - image.linkFile = data; - data.linkFile = image; +if (true) +{ + renderCanvas = __webpack_require__(776); +} - // Set the type - image.linkType = 'atlasjson'; - data.linkType = 'atlasjson'; +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas - return { texture: image, data: data }; }; -/** - * Adds a Texture Atlas file to the current load queue. - * - * Note: This method will only be available if the Atlas JSON File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#atlas - * @since 3.0.0 - * - * @param {string} key - The key of the file within the loader. - * @param {string} textureURL - The url to load the texture file from. - * @param {string} atlasURL - The url to load the atlas file from. - * @param {object} textureXhrSettings - Optional texture file specific XHR settings. - * @param {object} atlasXhrSettings - Optional atlas file specific XHR settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('atlas', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) -{ - - var files; - - // If param key is an object, use object based loading method - if ((typeof key === 'object') && (key !== null)) - { - files = new AtlasJSONFile(key.key, key.texture, key.data, this.path, textureXhrSettings, atlasXhrSettings); - } - - // Else just use the parameters like normal - else - { - // Returns an object with two properties: 'texture' and 'data' - files = new AtlasJSONFile(key, textureURL, atlasURL, this.path, textureXhrSettings, atlasXhrSettings); - } - - this.addFile(files.texture); - this.addFile(files.data); - - return this; -}); - -module.exports = AtlasJSONFile; - /***/ }), /* 779 */ @@ -107091,68 +105578,196 @@ module.exports = AtlasJSONFile; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var AudioFile = __webpack_require__(316); -var CONST = __webpack_require__(17); -var FileTypesManager = __webpack_require__(7); -var JSONFile = __webpack_require__(57); +var GetValue = __webpack_require__(5); + +// * @param {number} characterWidth - The width of each character in the font set. +// * @param {number} characterHeight - The height of each character in the font set. +// * @param {string} chars - The characters used in the font set, in display order. You can use the TEXT_SET consts for common font set arrangements. +// * @param {number} [charsPerRow] - The number of characters per row in the font set. If not given charsPerRow will be the image width / characterWidth. +// * @param {number} [xSpacing=0] - If the characters in the font set have horizontal spacing between them set the required amount here. +// * @param {number} [ySpacing=0] - If the characters in the font set have vertical spacing between them set the required amount here. +// * @param {number} [xOffset=0] - If the font set doesn't start at the top left of the given image, specify the X coordinate offset here. +// * @param {number} [yOffset=0] - If the font set doesn't start at the top left of the given image, specify the Y coordinate offset here. +// Phaser.GameObject.RetroFont = function (game, key, characterWidth, characterHeight, chars, charsPerRow, xSpacing, ySpacing, xOffset, yOffset) + +// { +// image: key, +// width: 32, +// height: 32, +// chars: 'string', +// charsPerRow: null, +// spacing: { x: 0, y: 0 }, +// offset: { x: 0, y: 0 } +// } /** - * Adds an Audio Sprite file to the current load queue. - * - * Note: This method will only be available if the Audio Sprite File type has been built into Phaser. + * [description] * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#audioSprite + * @function ParseRetroFont * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string|string[]} urls - [description] - * @param {object} json - [description] - * @param {object} config - [description] - * @param {object} audioXhrSettings - Optional file specific XHR settings. - * @param {object} jsonXhrSettings - Optional file specific XHR settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. + * @private */ -FileTypesManager.register('audioSprite', function (key, urls, json, config, audioXhrSettings, jsonXhrSettings) +var ParseRetroFont = function (scene, config) { - var audioFile = AudioFile.create(this, key, urls, config, audioXhrSettings); + var w = config.width; + var h = config.height; + var cx = Math.floor(w / 2); + var cy = Math.floor(h / 2); + var letters = config.chars; - if (audioFile) + var key = GetValue(config, 'image', ''); + var offsetX = GetValue(config, 'offset.x', 0); + var offsetY = GetValue(config, 'offset.y', 0); + var spacingX = GetValue(config, 'spacing.x', 0); + var spacingY = GetValue(config, 'spacing.y', 0); + + var charsPerRow = GetValue(config, 'charsPerRow', null); + + if (charsPerRow === null) { - var jsonFile; + charsPerRow = scene.sys.textures.getFrame(key).width / w; - if (typeof json === 'string') + if (charsPerRow > letters.length) { - jsonFile = new JSONFile(key, json, this.path, jsonXhrSettings); + charsPerRow = letters.length; + } + } - this.addFile(jsonFile); + var x = offsetX; + var y = offsetY; + + var data = { + retroFont: true, + font: key, + size: w, + lineHeight: h, + chars: {} + }; + + var r = 0; + + for (var i = 0; i < letters.length; i++) + { + // var node = letters[i]; + + var charCode = letters.charCodeAt(i); + + data.chars[charCode] = + { + x: x, + y: y, + width: w, + height: h, + centerX: cx, + centerY: cy, + xOffset: 0, + yOffset: 0, + xAdvance: w, + data: {}, + kerning: {} + }; + + r++; + + if (r === charsPerRow) + { + r = 0; + x = offsetX; + y += h + spacingY; } else { - jsonFile = { - type: 'json', - key: key, - data: json, - state: CONST.FILE_WAITING_LINKFILE - }; + x += w + spacingX; } - - // Link them together - audioFile.linkFile = jsonFile; - jsonFile.linkFile = audioFile; - - // Set the type - audioFile.linkType = 'audioSprite'; - jsonFile.linkType = 'audioSprite'; - - this.addFile(audioFile); } - return this; -}); + var entry = { + data: data, + frame: null, + texture: key + }; + + return entry; +}; + +/** +* Text Set 1 = !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ +* @constant +* @type {string} +*/ +ParseRetroFont.TEXT_SET1 = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + +/** +* Text Set 2 = !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ +* @constant +* @type {string} +*/ +ParseRetroFont.TEXT_SET2 = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + +/** +* Text Set 3 = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 +* @constant +* @type {string} +*/ +ParseRetroFont.TEXT_SET3 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 '; + +/** +* Text Set 4 = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 +* @constant +* @type {string} +*/ +ParseRetroFont.TEXT_SET4 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789'; + +/** +* Text Set 5 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789 +* @constant +* @type {string} +*/ +ParseRetroFont.TEXT_SET5 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() \'!?-*:0123456789'; + +/** +* Text Set 6 = ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.' +* @constant +* @type {string} +*/ +ParseRetroFont.TEXT_SET6 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.\' '; + +/** +* Text Set 7 = AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-'39 +* @constant +* @type {string} +*/ +ParseRetroFont.TEXT_SET7 = 'AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-\'39'; + +/** +* Text Set 8 = 0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ +* @constant +* @type {string} +*/ +ParseRetroFont.TEXT_SET8 = '0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + +/** +* Text Set 9 = ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'"?! +* @constant +* @type {string} +*/ +ParseRetroFont.TEXT_SET9 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,\'"?!'; + +/** +* Text Set 10 = ABCDEFGHIJKLMNOPQRSTUVWXYZ +* @constant +* @type {string} +*/ +ParseRetroFont.TEXT_SET10 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + +/** +* Text Set 11 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()':;0123456789 +* @constant +* @type {string} +*/ +ParseRetroFont.TEXT_SET11 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()\':;0123456789'; + +module.exports = ParseRetroFont; /***/ }), @@ -107165,184 +105780,41 @@ FileTypesManager.register('audioSprite', function (key, urls, json, config, audi * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(2); +var ParseXMLBitmapFont = __webpack_require__(270); /** - * @classdesc * [description] * - * @class BinaryFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor + * @function ParseFromAtlas * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {object} xhrSettings - [description] + * @private */ -var BinaryFile = new Class({ - - Extends: File, - - initialize: - - function BinaryFile (key, url, path, xhrSettings) - { - var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); - - var fileConfig = { - type: 'binary', - extension: GetFastValue(key, 'extension', 'bin'), - responseType: 'arraybuffer', - key: fileKey, - url: GetFastValue(key, 'file', url), - path: path, - xhrSettings: GetFastValue(key, 'xhr', xhrSettings) - }; - - File.call(this, fileConfig); - }, - - onProcess: function (callback) - { - this.state = CONST.FILE_PROCESSING; - - this.data = this.xhrLoader.response; - - this.onComplete(); - - callback(this); - } - -}); - -/** - * Adds Binary file to the current load queue. - * - * Note: This method will only be available if the Binary File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#binary - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('binary', function (key, url, xhrSettings) +var ParseFromAtlas = function (scene, fontName, textureKey, frameKey, xmlKey, xSpacing, ySpacing) { - if (Array.isArray(key)) + var frame = scene.sys.textures.getFrame(textureKey, frameKey); + var xml = scene.sys.cache.xml.get(xmlKey); + + if (frame && xml) { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new BinaryFile(key[i], url, this.path, xhrSettings)); - } + var data = ParseXMLBitmapFont(xml, xSpacing, ySpacing, frame); + + scene.sys.cache.bitmapFont.add(fontName, { data: data, texture: textureKey, frame: frameKey }); + + return true; } else { - this.addFile(new BinaryFile(key, url, this.path, xhrSettings)); + return false; } +}; - // For method chaining - return this; -}); - -module.exports = BinaryFile; +module.exports = ParseFromAtlas; /***/ }), /* 781 */ /***/ (function(module, exports, __webpack_require__) { -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var FileTypesManager = __webpack_require__(7); -var ImageFile = __webpack_require__(58); -var XMLFile = __webpack_require__(318); - -/** - * An Bitmap Font File. - * - * @function Phaser.Loader.Filetypes.BitmapFontFile - * @since 3.0.0 - * - * @param {string} key - The key of the file within the loader. - * @param {string} textureURL - The url to load the texture file from. - * @param {string} xmlURL - The url to load the atlas file from. - * @param {string} path - The path of the file. - * @param {object} textureXhrSettings - Optional texture file specific XHR settings. - * @param {object} xmlXhrSettings - Optional atlas file specific XHR settings. - * - * @return {object} An object containing two File objects to be added to the loader. - */ -var BitmapFontFile = function (key, textureURL, xmlURL, path, textureXhrSettings, xmlXhrSettings) -{ - var image = new ImageFile(key, textureURL, path, textureXhrSettings); - var data = new XMLFile(key, xmlURL, path, xmlXhrSettings); - - // Link them together - image.linkFile = data; - data.linkFile = image; - - // Set the type - image.linkType = 'bitmapfont'; - data.linkType = 'bitmapfont'; - - return { texture: image, data: data }; -}; - -/** - * Adds a Bitmap Font file to the current load queue. - * - * Note: This method will only be available if the Bitmap Font File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#bitmapFont - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} textureURL - [description] - * @param {string} xmlURL - [description] - * @param {object} textureXhrSettings - [description] - * @param {object} xmlXhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('bitmapFont', function (key, textureURL, xmlURL, textureXhrSettings, xmlXhrSettings) -{ - // Returns an object with two properties: 'texture' and 'data' - var files = new BitmapFontFile(key, textureURL, xmlURL, this.path, textureXhrSettings, xmlXhrSettings); - - this.addFile(files.texture); - this.addFile(files.data); - - return this; -}); - -module.exports = BitmapFontFile; - - -/***/ }), -/* 782 */ -/***/ (function(module, exports, __webpack_require__) { - /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. @@ -107350,1169 +105822,29 @@ module.exports = BitmapFontFile; */ var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(2); - -/** - * @classdesc - * [description] - * - * @class GLSLFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {object} xhrSettings - [description] - */ -var GLSLFile = new Class({ - - Extends: File, - - initialize: - - function GLSLFile (key, url, path, xhrSettings) - { - var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); - - var fileConfig = { - type: 'glsl', - extension: GetFastValue(key, 'extension', 'glsl'), - responseType: 'text', - key: fileKey, - url: GetFastValue(key, 'file', url), - path: path, - xhrSettings: GetFastValue(key, 'xhr', xhrSettings) - }; - - File.call(this, fileConfig); - }, - - onProcess: function (callback) - { - this.state = CONST.FILE_PROCESSING; - - this.data = this.xhrLoader.responseText; - - this.onComplete(); - - callback(this); - } - -}); - -/** - * Adds a GLSL file to the current load queue. - * - * Note: This method will only be available if the GLSL File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#glsl - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('glsl', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new GLSLFile(key[i], url, this.path, xhrSettings)); - } - } - else - { - this.addFile(new GLSLFile(key, url, this.path, xhrSettings)); - } - - // For method chaining - return this; -}); - -module.exports = GLSLFile; - - -/***/ }), -/* 783 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(2); - -/** - * @classdesc - * [description] - * - * @class HTMLFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {string} path - [description] - * @param {object} xhrSettings - [description] - */ -var HTMLFile = new Class({ - - Extends: File, - - initialize: - - function HTMLFile (key, url, width, height, path, xhrSettings) - { - if (width === undefined) { width = 512; } - if (height === undefined) { height = 512; } - - var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); - - var fileConfig = { - type: 'html', - extension: GetFastValue(key, 'extension', 'html'), - responseType: 'text', - key: fileKey, - url: GetFastValue(key, 'file', url), - path: path, - xhrSettings: GetFastValue(key, 'xhr', xhrSettings), - config: { - width: width, - height: height - } - }; - - File.call(this, fileConfig); - }, - - onProcess: function (callback) - { - this.state = CONST.FILE_PROCESSING; - - var w = this.config.width; - var h = this.config.height; - - var data = []; - - data.push(''); - data.push(''); - data.push(''); - data.push(this.xhrLoader.responseText); - data.push(''); - data.push(''); - data.push(''); - - var svg = [ data.join('\n') ]; - var _this = this; - - try - { - var blob = new window.Blob(svg, { type: 'image/svg+xml;charset=utf-8' }); - } - catch (e) - { - _this.state = CONST.FILE_ERRORED; - - callback(_this); - - return; - } - - this.data = new Image(); - - this.data.crossOrigin = this.crossOrigin; - - this.data.onload = function () - { - File.revokeObjectURL(_this.data); - - _this.onComplete(); - - callback(_this); - }; - - this.data.onerror = function () - { - File.revokeObjectURL(_this.data); - - _this.state = CONST.FILE_ERRORED; - - callback(_this); - }; - - File.createObjectURL(this.data, blob, 'image/svg+xml'); - } - -}); - -/** - * Adds an HTML file to the current load queue. - * - * Note: This method will only be available if the HTML File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#html - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('html', function (key, url, width, height, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new HTMLFile(key[i], url, width, height, this.path, xhrSettings)); - } - } - else - { - this.addFile(new HTMLFile(key, url, width, height, this.path, xhrSettings)); - } - - // For method chaining - return this; -}); - -module.exports = HTMLFile; - - -/***/ }), -/* 784 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var FileTypesManager = __webpack_require__(7); -var ImageFile = __webpack_require__(58); -var JSONFile = __webpack_require__(57); -var NumberArray = __webpack_require__(319); - -/** - * Adds a Multi File Texture Atlas to the current load queue. - * - * Note: This method will only be available if the Multi Atlas File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#multiatlas - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string[]} textureURLs - [description] - * @param {string[]} atlasURLs - [description] - * @param {object} textureXhrSettings - [description] - * @param {object} atlasXhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('multiatlas', function (key, textureURLs, atlasURLs, textureXhrSettings, atlasXhrSettings) -{ - if (typeof textureURLs === 'number') - { - var total = textureURLs; - var suffix = (atlasURLs === undefined) ? '' : atlasURLs; - - textureURLs = NumberArray(0, total, key + suffix, '.png'); - atlasURLs = NumberArray(0, total, key + suffix, '.json'); - } - else - { - if (!Array.isArray(textureURLs)) - { - textureURLs = [ textureURLs ]; - } - - if (!Array.isArray(atlasURLs)) - { - atlasURLs = [ atlasURLs ]; - } - } - - var file; - var i = 0; - var multiKey; - - this._multilist[key] = []; - - for (i = 0; i < textureURLs.length; i++) - { - multiKey = '_MA_IMG_' + key + '_' + i.toString(); - - file = new ImageFile(multiKey, textureURLs[i], this.path, textureXhrSettings); - - this.addFile(file); - - this._multilist[key].push(multiKey); - } - - for (i = 0; i < atlasURLs.length; i++) - { - multiKey = '_MA_JSON_' + key + '_' + i.toString(); - - file = new JSONFile(multiKey, atlasURLs[i], this.path, atlasXhrSettings); - - this.addFile(file); - - this._multilist[key].push(multiKey); - } - - return this; -}); - - -/***/ }), -/* 785 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(2); var PluginManager = __webpack_require__(12); /** * @classdesc * [description] * - * @class PluginFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {object} xhrSettings - [description] - */ -var PluginFile = new Class({ - - Extends: File, - - initialize: - - function PluginFile (key, url, path, xhrSettings) - { - // If the url variable refers to a class, add the plugin directly - if (typeof url === 'function') - { - this.key = key; - window[key] = url; - window[key].register(PluginManager); - } - - var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); - - var fileConfig = { - type: 'script', - extension: GetFastValue(key, 'extension', 'js'), - responseType: 'text', - key: fileKey, - url: GetFastValue(key, 'file', url), - path: path, - xhrSettings: GetFastValue(key, 'xhr', xhrSettings) - }; - - File.call(this, fileConfig); - }, - - onProcess: function (callback) - { - this.state = CONST.FILE_PROCESSING; - - this.data = document.createElement('script'); - this.data.language = 'javascript'; - this.data.type = 'text/javascript'; - this.data.defer = false; - this.data.text = this.xhrLoader.responseText; - - document.head.appendChild(this.data); - - // Need to wait for onload? - window[this.key].register(PluginManager); - - this.onComplete(); - - callback(this); - } - -}); - -/** - * Adds a Plugin file to the current load queue. - * - * Note: This method will only be available if the Plugin File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#plugin - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('plugin', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new PluginFile(key[i], url, this.path, xhrSettings)); - } - } - else - { - this.addFile(new PluginFile(key, url, this.path, xhrSettings)); - } - - // For method chaining - return this; -}); - -module.exports = PluginFile; - - -/***/ }), -/* 786 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(2); - -/** - * @classdesc - * [description] - * - * @class ScriptFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {object} xhrSettings - [description] - */ -var ScriptFile = new Class({ - - Extends: File, - - initialize: - - function ScriptFile (key, url, path, xhrSettings) - { - var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); - - var fileConfig = { - type: 'script', - extension: GetFastValue(key, 'extension', 'js'), - responseType: 'text', - key: fileKey, - url: GetFastValue(key, 'file', url), - path: path, - xhrSettings: GetFastValue(key, 'xhr', xhrSettings) - }; - - File.call(this, fileConfig); - }, - - onProcess: function (callback) - { - this.state = CONST.FILE_PROCESSING; - - this.data = document.createElement('script'); - this.data.language = 'javascript'; - this.data.type = 'text/javascript'; - this.data.defer = false; - this.data.text = this.xhrLoader.responseText; - - document.head.appendChild(this.data); - - this.onComplete(); - - callback(this); - } - -}); - -/** - * Adds a JavaScript file to the current load queue. - * - * Note: This method will only be available if the Script File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#script - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('script', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new ScriptFile(key[i], url, this.path, xhrSettings)); - } - } - else - { - this.addFile(new ScriptFile(key, url, this.path, xhrSettings)); - } - - // For method chaining - return this; -}); - -module.exports = ScriptFile; - - -/***/ }), -/* 787 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var FileTypesManager = __webpack_require__(7); -var ImageFile = __webpack_require__(58); - -/** - * A Sprite Sheet File. - * - * @function Phaser.Loader.Filetypes.SpriteSheetFile - * @since 3.0.0 - * - * @param {string} key - The key of the file within the loader. - * @param {string} url - The url to load the texture file from. - * @param {object} config - Optional texture file specific XHR settings. - * @param {string} path - Optional texture file specific XHR settings. - * @param {object} xhrSettings - Optional atlas file specific XHR settings. - * - * @return {object} An object containing two File objects to be added to the loader. - */ -var SpriteSheetFile = function (key, url, config, path, xhrSettings) -{ - var image = new ImageFile(key, url, path, xhrSettings, config); - - // Override the File type - image.type = 'spritesheet'; - - return image; -}; - -/** - * Adds a Sprite Sheet file to the current load queue. - * - * Note: This method will only be available if the Sprite Sheet File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#spritesheet - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} config - config can include: frameWidth, frameHeight, startFrame, endFrame, margin, spacing. - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('spritesheet', function (key, url, config, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new SpriteSheetFile(key[i], url, null, this.path, xhrSettings)); - } - } - else - { - this.addFile(new SpriteSheetFile(key, url, config, this.path, xhrSettings)); - } - - // For method chaining - return this; -}); - -module.exports = SpriteSheetFile; - - -/***/ }), -/* 788 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(2); - -/** - * @classdesc - * [description] - * - * @class SVGFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {object} xhrSettings - [description] - */ -var SVGFile = new Class({ - - Extends: File, - - initialize: - - function SVGFile (key, url, path, xhrSettings) - { - var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); - - var fileConfig = { - type: 'svg', - extension: GetFastValue(key, 'extension', 'svg'), - responseType: 'text', - key: fileKey, - url: GetFastValue(key, 'file', url), - path: path, - xhrSettings: GetFastValue(key, 'xhr', xhrSettings) - }; - - File.call(this, fileConfig); - }, - - onProcess: function (callback) - { - this.state = CONST.FILE_PROCESSING; - - var svg = [ this.xhrLoader.responseText ]; - var _this = this; - - try - { - var blob = new window.Blob(svg, { type: 'image/svg+xml;charset=utf-8' }); - } - catch (e) - { - _this.state = CONST.FILE_ERRORED; - - callback(_this); - - return; - } - - this.data = new Image(); - - this.data.crossOrigin = this.crossOrigin; - - var retry = false; - - this.data.onload = function () - { - if(!retry) - { - File.revokeObjectURL(_this.data); - } - - _this.onComplete(); - - callback(_this); - }; - - this.data.onerror = function () - { - // Safari 8 re-try - if (!retry) - { - retry = true; - - File.revokeObjectURL(_this.data); - - _this.data.src = 'data:image/svg+xml,' + encodeURIComponent(svg.join('')); - } - else - { - _this.state = CONST.FILE_ERRORED; - - callback(_this); - } - }; - - File.createObjectURL(this.data, blob, 'image/svg+xml'); - } - -}); - -/** - * Adds an SVG file to the current load queue. - * - * Note: This method will only be available if the SVG File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#svg - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('svg', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new SVGFile(key[i], url, this.path, xhrSettings)); - } - } - else - { - this.addFile(new SVGFile(key, url, this.path, xhrSettings)); - } - - // For method chaining - return this; -}); - -module.exports = SVGFile; - - -/***/ }), -/* 789 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var TILEMAP_FORMATS = __webpack_require__(22); - -/** - * @classdesc - * [description] - * - * @class TilemapCSVFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {string} format - [description] - * @param {object} xhrSettings - [description] - */ -var TilemapCSVFile = new Class({ - - Extends: File, - - initialize: - - function TilemapCSVFile (key, url, path, format, xhrSettings) - { - var fileConfig = { - type: 'tilemapCSV', - extension: '.csv', - responseType: 'text', - key: key, - url: url, - path: path, - xhrSettings: xhrSettings - }; - - File.call(this, fileConfig); - - this.tilemapFormat = format; - }, - - onProcess: function (callback) - { - this.state = CONST.FILE_PROCESSING; - - this.data = this.xhrLoader.responseText; - - this.onComplete(); - - callback(this); - } - -}); - -/** - * Adds a Tilemap CSV file to the current load queue. - * - * Note: This method will only be available if the Tilemap CSV File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#tilemapCSV - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('tilemapCSV', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new TilemapCSVFile(key[i], url, this.path, TILEMAP_FORMATS.CSV, xhrSettings)); - } - } - else - { - this.addFile(new TilemapCSVFile(key, url, this.path, TILEMAP_FORMATS.CSV, xhrSettings)); - } - - // For method chaining - return this; -}); - -module.exports = TilemapCSVFile; - - -/***/ }), -/* 790 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var FileTypesManager = __webpack_require__(7); -var JSONFile = __webpack_require__(57); -var TILEMAP_FORMATS = __webpack_require__(22); - -/** - * A Tilemap File. - * - * @function Phaser.Loader.Filetypes.TilemapJSONFile - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {string} format - [description] - * @param {object} xhrSettings - [description] - * - * @return {object} An object containing two File objects to be added to the loader. - */ -var TilemapJSONFile = function (key, url, path, format, xhrSettings) -{ - var json = new JSONFile(key, url, path, xhrSettings); - - // Override the File type - json.type = 'tilemapJSON'; - - json.tilemapFormat = format; - - return json; -}; - -/** - * Adds a Tilemap (Tiled JSON Format) file to the current load queue. - * - * Note: This method will only be available if the Tilemap File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#tilemapTiledJSON - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('tilemapTiledJSON', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(TilemapJSONFile(key[i], url, this.path, TILEMAP_FORMATS.TILED_JSON, xhrSettings)); - } - } - else - { - this.addFile(TilemapJSONFile(key, url, this.path, TILEMAP_FORMATS.TILED_JSON, xhrSettings)); - } - - // For method chaining - return this; -}); - -/** - * Adds a Tilemap (Weltmeister Format) file to the current load queue. - * - * Note: This method will only be available if the Tilemap File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#tilemapWeltmeister - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('tilemapWeltmeister', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(TilemapJSONFile(key[i], url, this.path, TILEMAP_FORMATS.WELTMEISTER, xhrSettings)); - } - } - else - { - this.addFile(TilemapJSONFile(key, url, this.path, TILEMAP_FORMATS.WELTMEISTER, xhrSettings)); - } - - // For method chaining - return this; -}); - -module.exports = TilemapJSONFile; - - -/***/ }), -/* 791 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var FileTypesManager = __webpack_require__(7); -var ImageFile = __webpack_require__(58); -var TextFile = __webpack_require__(320); - -/** - * An Atlas JSON File. - * - * @function Phaser.Loader.Filetypes.UnityAtlasFile - * @since 3.0.0 - * - * @param {string} key - The key of the file within the loader. - * @param {string} textureURL - The url to load the texture file from. - * @param {string} atlasURL - The url to load the atlas file from. - * @param {string} path - The path of the file. - * @param {object} textureXhrSettings - Optional texture file specific XHR settings. - * @param {object} atlasXhrSettings - Optional atlas file specific XHR settings. - * - * @return {object} An object containing two File objects to be added to the loader. - */ -var UnityAtlasFile = function (key, textureURL, atlasURL, path, textureXhrSettings, atlasXhrSettings) -{ - var image = new ImageFile(key, textureURL, path, textureXhrSettings); - var data = new TextFile(key, atlasURL, path, atlasXhrSettings); - - // Link them together - image.linkFile = data; - data.linkFile = image; - - // Set the type - image.linkType = 'unityatlas'; - data.linkType = 'unityatlas'; - - return { texture: image, data: data }; -}; - -/** - * Adds a Unity Texture Atlas file to the current load queue. - * - * Note: This method will only be available if the Unity Atlas File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#unityAtlas - * @since 3.0.0 - * - * @param {string} key - The key of the file within the loader. - * @param {string} textureURL - The url to load the texture file from. - * @param {string} atlasURL - The url to load the atlas file from. - * @param {object} textureXhrSettings - Optional texture file specific XHR settings. - * @param {object} atlasXhrSettings - Optional atlas file specific XHR settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('unityAtlas', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) -{ - // Returns an object with two properties: 'texture' and 'data' - var files = new UnityAtlasFile(key, textureURL, atlasURL, this.path, textureXhrSettings, atlasXhrSettings); - - this.addFile(files.texture); - this.addFile(files.data); - - return this; - -}); - -module.exports = UnityAtlasFile; - - -/***/ }), -/* 792 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var CustomSet = __webpack_require__(62); -var EventEmitter = __webpack_require__(14); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(2); -var ParseXMLBitmapFont = __webpack_require__(269); -var PluginManager = __webpack_require__(12); -var XHRSettings = __webpack_require__(90); - -/** - * @classdesc - * [description] - * - * @class LoaderPlugin - * @extends EventEmitter - * @memberOf Phaser.Loader + * @class UpdateList + * @memberOf Phaser.GameObjects * @constructor * @since 3.0.0 * * @param {Phaser.Scene} scene - [description] */ -var LoaderPlugin = new Class({ - - Extends: EventEmitter, +var UpdateList = new Class({ initialize: - function LoaderPlugin (scene) + function UpdateList (scene) { - EventEmitter.call(this); - /** * [description] * - * @name Phaser.Loader.LoaderPlugin#scene + * @name Phaser.GameObjects.UpdateList#scene * @type {Phaser.Scene} * @since 3.0.0 */ @@ -108521,7 +105853,7 @@ var LoaderPlugin = new Class({ /** * [description] * - * @name Phaser.Loader.LoaderPlugin#systems + * @name Phaser.GameObjects.UpdateList#systems * @type {Phaser.Scenes.Systems} * @since 3.0.0 */ @@ -108535,8281 +105867,19 @@ var LoaderPlugin = new Class({ /** * [description] * - * @name Phaser.Loader.LoaderPlugin#_multilist - * @type {object} - * @private - * @default {} - * @since 3.0.0 - */ - this._multilist = {}; - - // Inject the available filetypes into the Loader - FileTypesManager.install(this); - - var gameConfig = this.systems.game.config; - var sceneConfig = this.systems.settings.loader; - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#path - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.path = ''; - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#baseURL - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.baseURL = ''; - - this.setBaseURL(GetFastValue(sceneConfig, 'baseURL', gameConfig.loaderBaseURL)); - - this.setPath(GetFastValue(sceneConfig, 'path', gameConfig.loaderPath)); - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#enableParallel - * @type {boolean} - * @since 3.0.0 - */ - this.enableParallel = GetFastValue(sceneConfig, 'enableParallel', gameConfig.loaderEnableParallel); - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#maxParallelDownloads - * @type {integer} - * @since 3.0.0 - */ - this.maxParallelDownloads = GetFastValue(sceneConfig, 'maxParallelDownloads', gameConfig.loaderMaxParallelDownloads); - - /** - * xhr specific global settings (can be overridden on a per-file basis) - * - * @name Phaser.Loader.LoaderPlugin#xhr - * @type {Phaser.Loader.XHRSettings} - * @since 3.0.0 - */ - this.xhr = XHRSettings( - GetFastValue(sceneConfig, 'responseType', gameConfig.loaderResponseType), - GetFastValue(sceneConfig, 'async', gameConfig.loaderAsync), - GetFastValue(sceneConfig, 'user', gameConfig.loaderUser), - GetFastValue(sceneConfig, 'password', gameConfig.loaderPassword), - GetFastValue(sceneConfig, 'timeout', gameConfig.loaderTimeout) - ); - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#crossOrigin - * @type {string} - * @since 3.0.0 - */ - this.crossOrigin = GetFastValue(sceneConfig, 'crossOrigin', gameConfig.loaderCrossOrigin); - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#totalToLoad - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalToLoad = 0; - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#progress - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.progress = 0; - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#list - * @type {Phaser.Structs.Set} - * @since 3.0.0 - */ - this.list = new CustomSet(); - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#inflight - * @type {Phaser.Structs.Set} - * @since 3.0.0 - */ - this.inflight = new CustomSet(); - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#failed - * @type {Phaser.Structs.Set} - * @since 3.0.0 - */ - this.failed = new CustomSet(); - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#queue - * @type {Phaser.Structs.Set} - * @since 3.0.0 - */ - this.queue = new CustomSet(); - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#storage - * @type {Phaser.Structs.Set} - * @since 3.0.0 - */ - this.storage = new CustomSet(); - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#state - * @type {integer} - * @since 3.0.0 - */ - this.state = CONST.LOADER_IDLE; - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#boot - * @since 3.0.0 - */ - boot: function () - { - var eventEmitter = this.systems.events; - - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#setBaseURL - * @since 3.0.0 - * - * @param {string} url - [description] - * - * @return {Phaser.Loader.LoaderPlugin} This Loader object. - */ - setBaseURL: function (url) - { - if (url !== '' && url.substr(-1) !== '/') - { - url = url.concat('/'); - } - - this.baseURL = url; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#setPath - * @since 3.0.0 - * - * @param {string} path - [description] - * - * @return {Phaser.Loader.LoaderPlugin} This Loader object. - */ - setPath: function (path) - { - if (path !== '' && path.substr(-1) !== '/') - { - path = path.concat('/'); - } - - this.path = path; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#setCORS - * @since 3.0.0 - * - * @param {string} crossOrigin - [description] - * - * @return {Phaser.Loader.LoaderPlugin} This Loader object. - */ - setCORS: function (crossOrigin) - { - this.crossOrigin = crossOrigin; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#addFile - * @since 3.0.0 - * - * @param {Phaser.Loader.File} file - [description] - * - * @return {Phaser.Loader.File} [description] - */ - addFile: function (file) - { - if (!this.isReady()) - { - return -1; - } - - file.path = this.path; - - this.list.set(file); - - return file; - }, - - /** - * Is the Loader actively loading (or processing loaded files) - * - * @method Phaser.Loader.LoaderPlugin#isLoading - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isLoading: function () - { - return (this.state === CONST.LOADER_LOADING || this.state === CONST.LOADER_PROCESSING); - }, - - /** - * Is the Loader ready to start a new load? - * - * @method Phaser.Loader.LoaderPlugin#isReady - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isReady: function () - { - return (this.state === CONST.LOADER_IDLE || this.state === CONST.LOADER_COMPLETE || this.state === CONST.LOADER_FAILED); - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#start - * @since 3.0.0 - */ - start: function () - { - if (!this.isReady()) - { - return; - } - - this.progress = 0; - this.totalToLoad = this.list.size; - - this.emit('start', this); - - if (this.list.size === 0) - { - this.finishedLoading(); - } - else - { - this.state = CONST.LOADER_LOADING; - - this.failed.clear(); - this.inflight.clear(); - this.queue.clear(); - - this.queue.debug = true; - - this.updateProgress(); - - this.processLoadQueue(); - } - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#updateProgress - * @since 3.0.0 - */ - updateProgress: function () - { - this.progress = 1 - (this.list.size / this.totalToLoad); - - this.emit('progress', this.progress); - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#processLoadQueue - * @since 3.0.0 - */ - processLoadQueue: function () - { - this.list.each(function (file) - { - if (file.state === CONST.FILE_POPULATED || (file.state === CONST.FILE_PENDING && this.inflight.size < this.maxParallelDownloads)) - { - this.inflight.set(file); - - this.list.delete(file); - - this.loadFile(file); - } - - if (this.inflight.size === this.maxParallelDownloads) - { - // Tells the Set iterator to abort - return false; - } - - }, this); - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#loadFile - * @since 3.0.0 - * - * @param {Phaser.Loader.File} file - [description] - */ - loadFile: function (file) - { - // If the file doesn't have its own crossOrigin set, - // we'll use the Loaders (which is undefined by default) - if (!file.crossOrigin) - { - file.crossOrigin = this.crossOrigin; - } - - file.load(this); - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#nextFile - * @since 3.0.0 - * - * @param {Phaser.Loader.File} previousFile - [description] - * @param {boolean} success - [description] - */ - nextFile: function (previousFile, success) - { - // Move the file that just loaded from the inflight list to the queue or failed Set - - if (success) - { - this.emit('load', previousFile); - this.queue.set(previousFile); - } - else - { - this.emit('loaderror', previousFile); - this.failed.set(previousFile); - } - - this.inflight.delete(previousFile); - - this.updateProgress(); - - if (this.list.size > 0) - { - this.processLoadQueue(); - } - else if (this.inflight.size === 0) - { - this.finishedLoading(); - } - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#finishedLoading - * @since 3.0.0 - */ - finishedLoading: function () - { - if (this.state === CONST.LOADER_PROCESSING) - { - return; - } - - this.progress = 1; - - this.state = CONST.LOADER_PROCESSING; - - this.storage.clear(); - - if (this.queue.size === 0) - { - // Everything failed, so nothing to process - this.processComplete(); - } - else - { - this.queue.each(function (file) - { - file.onProcess(this.processUpdate.bind(this)); - }, this); - } - }, - - /** - * Called automatically by the File when it has finished processing. - * - * @method Phaser.Loader.LoaderPlugin#processUpdate - * @since 3.0.0 - * - * @param {Phaser.Loader.File} file - [description] - */ - processUpdate: function (file) - { - // This file has failed to load, so move it to the failed Set - if (file.state === CONST.FILE_ERRORED) - { - this.failed.set(file); - - if (file.linkFile) - { - this.queue.delete(file.linkFile); - } - - return this.removeFromQueue(file); - } - - // If we got here, then the file loaded - - // Special handling for multi-part files - - if (file.linkFile) - { - if (file.state === CONST.FILE_COMPLETE && file.linkFile.state === CONST.FILE_COMPLETE) - { - // Partner has loaded, so add them both to Storage - - this.storage.set({ type: file.linkType, fileA: file, fileB: file.linkFile }); - - this.queue.delete(file.linkFile); - - this.removeFromQueue(file); - } - } - else - { - this.storage.set(file); - - this.removeFromQueue(file); - } - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#removeFromQueue - * @since 3.0.0 - * - * @param {Phaser.Loader.File} file - [description] - */ - removeFromQueue: function (file) - { - this.queue.delete(file); - - if (this.queue.size === 0 && this.state === CONST.LOADER_PROCESSING) - { - // We've processed all the files we loaded - this.processComplete(); - } - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#processComplete - * @since 3.0.0 - */ - processComplete: function () - { - this.list.clear(); - this.inflight.clear(); - this.queue.clear(); - - this.processCallback(); - - this.state = CONST.LOADER_COMPLETE; - - this.emit('complete', this, this.storage.size, this.failed.size); - - // Move to a User setting: - // this.removeAllListeners(); - }, - - /** - * The Loader has finished. - * - * @method Phaser.Loader.LoaderPlugin#processCallback - * @since 3.0.0 - */ - processCallback: function () - { - if (this.storage.size === 0) - { - return; - } - - // The global Texture Manager - var cache = this.scene.sys.cache; - var textures = this.scene.sys.textures; - var anims = this.scene.sys.anims; - - // Process multiatlas groups first - - var file; - var fileA; - var fileB; - - for (var key in this._multilist) - { - var data = []; - var images = []; - var keys = this._multilist[key]; - - for (var i = 0; i < keys.length; i++) - { - file = this.storage.get('key', keys[i]); - - if (file) - { - if (file.type === 'image') - { - images.push(file.data); - } - else if (file.type === 'json') - { - data.push(file.data); - } - - this.storage.delete(file); - } - } - - // Do we have everything needed? - if (images.length + data.length === keys.length) - { - // Yup, add them to the Texture Manager - - // Is the data JSON Hash or JSON Array? - if (Array.isArray(data[0].textures) || Array.isArray(data[0].frames)) - { - textures.addAtlasJSONArray(key, images, data); - } - else - { - textures.addAtlasJSONHash(key, images, data); - } - } - } - - // Process all of the files - - // Because AnimationJSON may require images to be loaded first, we process them last - var animJSON = []; - - this.storage.each(function (file) - { - switch (file.type) - { - case 'animationJSON': - animJSON.push(file); - break; - - case 'image': - case 'svg': - case 'html': - textures.addImage(file.key, file.data); - break; - - case 'atlasjson': - - fileA = file.fileA; - fileB = file.fileB; - - if (fileA.type === 'image') - { - textures.addAtlas(fileA.key, fileA.data, fileB.data); - } - else - { - textures.addAtlas(fileB.key, fileB.data, fileA.data); - } - break; - - case 'dataimage': - - fileA = file.fileA; - fileB = file.fileB; - - if (fileA.linkParent) - { - textures.addImage(fileA.key, fileA.data, fileB.data); - } - else - { - textures.addImage(fileB.key, fileB.data, fileA.data); - } - break; - - case 'unityatlas': - - fileA = file.fileA; - fileB = file.fileB; - - if (fileA.type === 'image') - { - textures.addUnityAtlas(fileA.key, fileA.data, fileB.data); - } - else - { - textures.addUnityAtlas(fileB.key, fileB.data, fileA.data); - } - break; - - case 'bitmapfont': - - fileA = file.fileA; - fileB = file.fileB; - - if (fileA.type === 'image') - { - cache.bitmapFont.add(fileB.key, { data: ParseXMLBitmapFont(fileB.data), texture: fileA.key, frame: null }); - textures.addImage(fileA.key, fileA.data); - } - else - { - cache.bitmapFont.add(fileA.key, { data: ParseXMLBitmapFont(fileA.data), texture: fileB.key, frame: null }); - textures.addImage(fileB.key, fileB.data); - } - break; - - case 'spritesheet': - textures.addSpriteSheet(file.key, file.data, file.config); - break; - - case 'json': - cache.json.add(file.key, file.data); - break; - - case 'xml': - cache.xml.add(file.key, file.data); - break; - - case 'text': - cache.text.add(file.key, file.data); - break; - - case 'obj': - cache.obj.add(file.key, file.data); - break; - - case 'binary': - cache.binary.add(file.key, file.data); - break; - - case 'audio': - cache.audio.add(file.key, file.data); - break; - - case 'audioSprite': - - var files = [ file.fileA, file.fileB ]; - - files.forEach(function (file) - { - cache[file.type].add(file.key, file.data); - }); - - break; - - case 'glsl': - cache.shader.add(file.key, file.data); - break; - - case 'tilemapCSV': - case 'tilemapJSON': - cache.tilemap.add(file.key, { format: file.tilemapFormat, data: file.data }); - break; - } - }); - - animJSON.forEach(function (file) - { - anims.fromJSON(file.data); - }); - - this.storage.clear(); - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#saveJSON - * @since 3.0.0 - * - * @param {[type]} data - [description] - * @param {[type]} filename - [description] - * - * @return {[type]} [description] - */ - saveJSON: function (data, filename) - { - return this.save(JSON.stringify(data), filename); - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#save - * @since 3.0.0 - * - * @param {[type]} data - [description] - * @param {[type]} filename - [description] - * @param {[type]} filetype - [description] - * - * @return {Phaser.Loader.LoaderPlugin} This Loader plugin. - */ - save: function (data, filename, filetype) - { - if (filename === undefined) { filename = 'file.json'; } - if (filetype === undefined) { filetype = 'application/json'; } - - var blob = new Blob([ data ], { type: filetype }); - - var url = URL.createObjectURL(blob); - - var a = document.createElement('a'); - - a.download = filename; - a.textContent = 'Download ' + filename; - a.href = url; - a.click(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#reset - * @since 3.0.0 - */ - reset: function () - { - this.list.clear(); - this.inflight.clear(); - this.failed.clear(); - this.queue.clear(); - this.storage.clear(); - - var gameConfig = this.systems.game.config; - var sceneConfig = this.systems.settings.loader; - - this.setBaseURL(GetFastValue(sceneConfig, 'baseURL', gameConfig.loaderBaseURL)); - this.setPath(GetFastValue(sceneConfig, 'path', gameConfig.loaderPath)); - - this.state = CONST.LOADER_IDLE; - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#loadArray - * @since 3.0.0 - * - * @param {array} files - [description] - * - * @return {boolean} [description] - */ - loadArray: function (files) - { - if (Array.isArray(files)) - { - for (var i = 0; i < files.length; i++) - { - this.file(files[i]); - } - } - - return (this.list.size > 0); - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#file - * @since 3.0.0 - * - * @param {object} file - [description] - * - * @return {Phaser.Loader.File} [description] - */ - file: function (file) - { - var entry; - var key = file.key; - - switch (file.type) - { - case 'spritesheet': - entry = this.spritesheet(key, file.url, file.config, file.xhrSettings); - break; - - case 'atlas': - entry = this.atlas(key, file.textureURL, file.atlasURL, file.textureXhrSettings, file.atlasXhrSettings); - break; - - case 'bitmapFont': - entry = this.bitmapFont(key, file.textureURL, file.xmlURL, file.textureXhrSettings, file.xmlXhrSettings); - break; - - case 'multiatlas': - entry = this.multiatlas(key, file.textureURLs, file.atlasURLs, file.textureXhrSettings, file.atlasXhrSettings); - break; - - case 'audioSprite': - entry = this.audioSprite(key, file.urls, file.json, file.config, file.audioXhrSettings, file.jsonXhrSettings); - break; - - // image, json, xml, binary, text, glsl, svg, obj - default: - entry = this[file.type](key, file.url, file.xhrSettings); - break; - } - - return entry; - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this.reset(); - this.state = CONST.LOADER_SHUTDOWN; - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.reset(); - this.state = CONST.LOADER_DESTROYED; - } - -}); - -PluginManager.register('Loader', LoaderPlugin, 'load'); - -module.exports = LoaderPlugin; - - -/***/ }), -/* 793 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(16); -var Extend = __webpack_require__(23); - -/** - * @namespace Phaser.Math - */ - -var PhaserMath = { - - // Collections of functions - Angle: __webpack_require__(794), - Distance: __webpack_require__(802), - Easing: __webpack_require__(805), - Fuzzy: __webpack_require__(806), - Interpolation: __webpack_require__(812), - Pow2: __webpack_require__(816), - Snap: __webpack_require__(818), - - // Single functions - Average: __webpack_require__(822), - Bernstein: __webpack_require__(322), - Between: __webpack_require__(231), - CatmullRom: __webpack_require__(123), - CeilTo: __webpack_require__(823), - Clamp: __webpack_require__(61), - DegToRad: __webpack_require__(35), - Difference: __webpack_require__(824), - Factorial: __webpack_require__(323), - FloatBetween: __webpack_require__(276), - FloorTo: __webpack_require__(825), - FromPercent: __webpack_require__(65), - GetSpeed: __webpack_require__(826), - IsEven: __webpack_require__(827), - IsEvenStrict: __webpack_require__(828), - Linear: __webpack_require__(124), - MaxAdd: __webpack_require__(829), - MinSub: __webpack_require__(830), - Percent: __webpack_require__(831), - RadToDeg: __webpack_require__(221), - RandomXY: __webpack_require__(832), - RandomXYZ: __webpack_require__(209), - RandomXYZW: __webpack_require__(210), - Rotate: __webpack_require__(324), - RotateAround: __webpack_require__(188), - RotateAroundDistance: __webpack_require__(113), - RoundAwayFromZero: __webpack_require__(325), - RoundTo: __webpack_require__(833), - SinCosTableGenerator: __webpack_require__(834), - SmootherStep: __webpack_require__(195), - SmoothStep: __webpack_require__(196), - TransformXY: __webpack_require__(251), - Within: __webpack_require__(835), - Wrap: __webpack_require__(50), - - // Vector classes - Vector2: __webpack_require__(6), - Vector3: __webpack_require__(51), - Vector4: __webpack_require__(120), - Matrix3: __webpack_require__(213), - Matrix4: __webpack_require__(119), - Quaternion: __webpack_require__(212), - RotateVec3: __webpack_require__(211) - -}; - -// Merge in the consts - -PhaserMath = Extend(false, PhaserMath, CONST); - -// Export it - -module.exports = PhaserMath; - - -/***/ }), -/* 794 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Angle - */ - -module.exports = { - - Between: __webpack_require__(795), - BetweenY: __webpack_require__(796), - BetweenPoints: __webpack_require__(797), - BetweenPointsY: __webpack_require__(798), - Reverse: __webpack_require__(799), - RotateTo: __webpack_require__(800), - ShortestBetween: __webpack_require__(801), - Normalize: __webpack_require__(321), - Wrap: __webpack_require__(163), - WrapDegrees: __webpack_require__(164) - -}; - - -/***/ }), -/* 795 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Angle.Between - * @since 3.0.0 - * - * @param {number} x1 - [description] - * @param {number} y1 - [description] - * @param {number} x2 - [description] - * @param {number} y2 - [description] - * - * @return {number} [description] - */ -var Between = function (x1, y1, x2, y2) -{ - return Math.atan2(y2 - y1, x2 - x1); -}; - -module.exports = Between; - - -/***/ }), -/* 796 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Angle.BetweenY - * @since 3.0.0 - * - * @param {number} x1 - [description] - * @param {number} y1 - [description] - * @param {number} x2 - [description] - * @param {number} y2 - [description] - * - * @return {number} [description] - */ -var BetweenY = function (x1, y1, x2, y2) -{ - return Math.atan2(x2 - x1, y2 - y1); -}; - -module.exports = BetweenY; - - -/***/ }), -/* 797 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Angle.BetweenPoints - * @since 3.0.0 - * - * @param {Phaser.Geom.Point|object} point1 - [description] - * @param {Phaser.Geom.Point|object} point2 - [description] - * - * @return {number} [description] - */ -var BetweenPoints = function (point1, point2) -{ - return Math.atan2(point2.y - point1.y, point2.x - point1.x); -}; - -module.exports = BetweenPoints; - - -/***/ }), -/* 798 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Angle.BetweenPointsY - * @since 3.0.0 - * - * @param {Phaser.Geom.Point|object} point1 - [description] - * @param {Phaser.Geom.Point|object} point2 - [description] - * - * @return {number} [description] - */ -var BetweenPointsY = function (point1, point2) -{ - return Math.atan2(point2.x - point1.x, point2.y - point1.y); -}; - -module.exports = BetweenPointsY; - - -/***/ }), -/* 799 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Normalize = __webpack_require__(321); - -/** - * [description] - * - * @function Phaser.Math.Angle.Reverse - * @since 3.0.0 - * - * @param {number} angle - [description] - * - * @return {number} [description] - */ -var Reverse = function (angle) -{ - return Normalize(angle + Math.PI); -}; - -module.exports = Reverse; - - -/***/ }), -/* 800 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH_CONST = __webpack_require__(16); - -/** - * Rotates `currentAngle` towards `targetAngle`, taking the shortest rotation distance. The `lerp` argument is the amount to rotate by in this call. - * - * @function Phaser.Math.Angle.RotateTo - * @since 3.0.0 - * - * @param {number} currentAngle - The current angle, in radians. - * @param {number} targetAngle - The target angle to rotate to, in radians. - * @param {number} [lerp=0.05] - The lerp value to add to the current angle. - * - * @return {number} The adjusted angle. - */ -var RotateTo = function (currentAngle, targetAngle, lerp) -{ - if (lerp === undefined) { lerp = 0.05; } - - if (currentAngle === targetAngle) - { - return currentAngle; - } - - if (Math.abs(targetAngle - currentAngle) <= lerp || Math.abs(targetAngle - currentAngle) >= (MATH_CONST.PI2 - lerp)) - { - currentAngle = targetAngle; - } - else - { - if (Math.abs(targetAngle - currentAngle) > Math.PI) - { - if (targetAngle < currentAngle) - { - targetAngle += MATH_CONST.PI2; - } - else - { - targetAngle -= MATH_CONST.PI2; - } - } - - if (targetAngle > currentAngle) - { - currentAngle += lerp; - } - else if (targetAngle < currentAngle) - { - currentAngle -= lerp; - } - } - - return currentAngle; -}; - -module.exports = RotateTo; - - -/***/ }), -/* 801 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Gets the shortest angle between `angle1` and `angle2`. - * Both angles must be in the range -180 to 180, which is the same clamped - * range that `sprite.angle` uses, so you can pass in two sprite angles to - * this method and get the shortest angle back between the two of them. - * - * The angle returned will be in the same range. If the returned angle is - * greater than 0 then it's a counter-clockwise rotation, if < 0 then it's - * a clockwise rotation. - * - * @function Phaser.Math.Angle.ShortestBetween - * @since 3.0.0 - * - * @param {number} angle1 - The first angle in the range -180 to 180. - * @param {number} angle2 - The second angle in the range -180 to 180. - * - * @return {number} The shortest angle, in degrees. If greater than zero it's a counter-clockwise rotation. - */ -var ShortestBetween = function (angle1, angle2) -{ - var difference = angle2 - angle1; - - if (difference === 0) - { - return 0; - } - - var times = Math.floor((difference - (-180)) / 360); - - return difference - (times * 360); - -}; - -module.exports = ShortestBetween; - - -/***/ }), -/* 802 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Distance - */ - -module.exports = { - - Between: __webpack_require__(42), - Power: __webpack_require__(803), - Squared: __webpack_require__(804) - -}; - - -/***/ }), -/* 803 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Distance.Power - * @since 3.0.0 - * - * @param {number} x1 - [description] - * @param {number} y1 - [description] - * @param {number} x2 - [description] - * @param {number} y2 - [description] - * @param {number} pow - [description] - * - * @return {number} [description] - */ -var DistancePower = function (x1, y1, x2, y2, pow) -{ - if (pow === undefined) { pow = 2; } - - return Math.sqrt(Math.pow(x2 - x1, pow) + Math.pow(y2 - y1, pow)); -}; - -module.exports = DistancePower; - - -/***/ }), -/* 804 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Distance.Squared - * @since 3.0.0 - * - * @param {number} x1 - [description] - * @param {number} y1 - [description] - * @param {number} x2 - [description] - * @param {number} y2 - [description] - * - * @return {number} [description] - */ -var DistanceSquared = function (x1, y1, x2, y2) -{ - var dx = x1 - x2; - var dy = y1 - y2; - - return dx * dx + dy * dy; -}; - -module.exports = DistanceSquared; - - -/***/ }), -/* 805 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing - */ - -module.exports = { - - Back: __webpack_require__(277), - Bounce: __webpack_require__(278), - Circular: __webpack_require__(279), - Cubic: __webpack_require__(280), - Elastic: __webpack_require__(281), - Expo: __webpack_require__(282), - Linear: __webpack_require__(283), - Quadratic: __webpack_require__(284), - Quartic: __webpack_require__(285), - Quintic: __webpack_require__(286), - Sine: __webpack_require__(287), - Stepped: __webpack_require__(288) - -}; - - -/***/ }), -/* 806 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Fuzzy - */ - -module.exports = { - - Ceil: __webpack_require__(807), - Equal: __webpack_require__(808), - Floor: __webpack_require__(809), - GreaterThan: __webpack_require__(810), - LessThan: __webpack_require__(811) - -}; - - -/***/ }), -/* 807 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Fuzzy.Ceil - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {float} [epsilon=0.0001] - [description] - * - * @return {number} [description] - */ -var Ceil = function (value, epsilon) -{ - if (epsilon === undefined) { epsilon = 0.0001; } - - return Math.ceil(value - epsilon); -}; - -module.exports = Ceil; - - -/***/ }), -/* 808 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Fuzzy.Equal - * @since 3.0.0 - * - * @param {number} a - [description] - * @param {number} b - [description] - * @param {float} [epsilon=0.0001] - [description] - * - * @return {boolean} [description] - */ -var Equal = function (a, b, epsilon) -{ - if (epsilon === undefined) { epsilon = 0.0001; } - - return Math.abs(a - b) < epsilon; -}; - -module.exports = Equal; - - -/***/ }), -/* 809 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Fuzzy.Floor - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {float} [epsilon=0.0001] - [description] - * - * @return {number} [description] - */ -var Floor = function (value, epsilon) -{ - if (epsilon === undefined) { epsilon = 0.0001; } - - return Math.floor(value + epsilon); -}; - -module.exports = Floor; - - -/***/ }), -/* 810 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Fuzzy.GreaterThan - * @since 3.0.0 - * - * @param {number} a - [description] - * @param {number} b - [description] - * @param {float} [epsilon=0.0001] - [description] - * - * @return {boolean} [description] - */ -var GreaterThan = function (a, b, epsilon) -{ - if (epsilon === undefined) { epsilon = 0.0001; } - - return a > b - epsilon; -}; - -module.exports = GreaterThan; - - -/***/ }), -/* 811 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Fuzzy.LessThan - * @since 3.0.0 - * - * @param {number} a - [description] - * @param {number} b - [description] - * @param {float} [epsilon=0.0001] - [description] - * - * @return {boolean} [description] - */ -var LessThan = function (a, b, epsilon) -{ - if (epsilon === undefined) { epsilon = 0.0001; } - - return a < b + epsilon; -}; - -module.exports = LessThan; - - -/***/ }), -/* 812 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Interpolation - */ - -module.exports = { - Bezier: __webpack_require__(813), - CatmullRom: __webpack_require__(814), - CubicBezier: __webpack_require__(219), - Linear: __webpack_require__(815), - QuadraticBezier: __webpack_require__(224) -}; - - -/***/ }), -/* 813 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Bernstein = __webpack_require__(322); - -/** - * [description] - * - * @function Phaser.Math.Interpolation.Bezier - * @since 3.0.0 - * - * @param {number} v - [description] - * @param {number} k - [description] - * - * @return {number} [description] - */ -var BezierInterpolation = function (v, k) -{ - var b = 0; - var n = v.length - 1; - - for (var i = 0; i <= n; i++) - { - b += Math.pow(1 - k, n - i) * Math.pow(k, i) * v[i] * Bernstein(n, i); - } - - return b; -}; - -module.exports = BezierInterpolation; - - -/***/ }), -/* 814 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CatmullRom = __webpack_require__(123); - -/** - * [description] - * - * @function Phaser.Math.Interpolation.CatmullRom - * @since 3.0.0 - * - * @param {number} v - [description] - * @param {number} k - [description] - * - * @return {number} [description] - */ -var CatmullRomInterpolation = function (v, k) -{ - var m = v.length - 1; - var f = m * k; - var i = Math.floor(f); - - if (v[0] === v[m]) - { - if (k < 0) - { - i = Math.floor(f = m * (1 + k)); - } - - return CatmullRom(f - i, v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m]); - } - else - { - if (k < 0) - { - return v[0] - (CatmullRom(-f, v[0], v[0], v[1], v[1]) - v[0]); - } - - if (k > 1) - { - return v[m] - (CatmullRom(f - m, v[m], v[m], v[m - 1], v[m - 1]) - v[m]); - } - - return CatmullRom(f - i, v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2]); - } -}; - -module.exports = CatmullRomInterpolation; - - -/***/ }), -/* 815 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Linear = __webpack_require__(124); - -/** - * [description] - * - * @function Phaser.Math.Interpolation.Linear - * @since 3.0.0 - * - * @param {float} v - [description] - * @param {number} k - [description] - * - * @return {number} [description] - */ -var LinearInterpolation = function (v, k) -{ - var m = v.length - 1; - var f = m * k; - var i = Math.floor(f); - - if (k < 0) - { - return Linear(v[0], v[1], f); - } - - if (k > 1) - { - return Linear(v[m], v[m - 1], m - f); - } - - return Linear(v[i], v[(i + 1 > m) ? m : i + 1], f - i); -}; - -module.exports = LinearInterpolation; - - -/***/ }), -/* 816 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Pow2 - */ - -module.exports = { - - GetNext: __webpack_require__(291), - IsSize: __webpack_require__(127), - IsValue: __webpack_require__(817) - -}; - - -/***/ }), -/* 817 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Tests the value and returns `true` if it is a power of two. - * - * @function Phaser.Math.Pow2.IsValuePowerOfTwo - * @since 3.0.0 - * - * @param {number} value - The value to check if it's a power of two. - * - * @return {boolean} Returns `true` if `value` is a power of two, otherwise `false`. - */ -var IsValuePowerOfTwo = function (value) -{ - return (value > 0 && (value & (value - 1)) === 0); -}; - -module.exports = IsValuePowerOfTwo; - - -/***/ }), -/* 818 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Snap - */ - -module.exports = { - - Ceil: __webpack_require__(819), - Floor: __webpack_require__(820), - To: __webpack_require__(821) - -}; - - -/***/ }), -/* 819 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Snap.Ceil - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} gap - [description] - * @param {number} [start=0] - [description] - * - * @return {number} [description] - */ -var SnapCeil = function (value, gap, start) -{ - if (start === undefined) { start = 0; } - - if (gap === 0) - { - return value; - } - - value -= start; - value = gap * Math.ceil(value / gap); - - return start + value; -}; - -module.exports = SnapCeil; - - -/***/ }), -/* 820 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Snap.Floor - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} gap - [description] - * @param {number} [start=0] - [description] - * - * @return {number} [description] - */ -var SnapFloor = function (value, gap, start) -{ - if (start === undefined) { start = 0; } - - if (gap === 0) - { - return value; - } - - value -= start; - value = gap * Math.floor(value / gap); - - return start + value; -}; - -module.exports = SnapFloor; - - -/***/ }), -/* 821 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Snap.To - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} gap - [description] - * @param {number} [start=0] - [description] - * - * @return {number} [description] - */ -var SnapTo = function (value, gap, start) -{ - if (start === undefined) { start = 0; } - - if (gap === 0) - { - return value; - } - - value -= start; - value = gap * Math.round(value / gap); - - return start + value; -}; - -module.exports = SnapTo; - - -/***/ }), -/* 822 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Average - * @since 3.0.0 - * - * @param {number[]} values - [description] - * - * @return {number} [description] - */ -var Average = function (values) -{ - var sum = 0; - - for (var i = 0; i < values.length; i++) - { - sum += (+values[i]); - } - - return sum / values.length; -}; - -module.exports = Average; - - -/***/ }), -/* 823 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.CeilTo - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} [place=0] - [description] - * @param {integer} [base=10] - [description] - * - * @return {number} [description] - */ -var CeilTo = function (value, place, base) -{ - if (place === undefined) { place = 0; } - if (base === undefined) { base = 10; } - - var p = Math.pow(base, -place); - - return Math.ceil(value * p) / p; -}; - -module.exports = CeilTo; - - -/***/ }), -/* 824 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Difference - * @since 3.0.0 - * - * @param {number} a - [description] - * @param {number} b - [description] - * - * @return {number} [description] - */ -var Difference = function (a, b) -{ - return Math.abs(a - b); -}; - -module.exports = Difference; - - -/***/ }), -/* 825 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.FloorTo - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {integer} [place=0 - [description] - * @param {integer} [base=10] - [description] - * - * @return {number} [description] - */ -var FloorTo = function (value, place, base) -{ - if (place === undefined) { place = 0; } - if (base === undefined) { base = 10; } - - var p = Math.pow(base, -place); - - return Math.floor(value * p) / p; -}; - -module.exports = FloorTo; - - -/***/ }), -/* 826 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.GetSpeed - * @since 3.0.0 - * - * @param {number} distance - The distance to travel in pixels. - * @param {integer} time - The time, in ms, to cover the distance in. - * - * @return {number} The amount you will need to increment the position by each step in order to cover the distance in the time given. - */ -var GetSpeed = function (distance, time) -{ - return (distance / time) / 1000; -}; - -module.exports = GetSpeed; - - -/***/ }), -/* 827 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.IsEven - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {boolean} [description] - */ -var IsEven = function (value) -{ - // Use abstract equality == for "is number" test - - // eslint-disable-next-line eqeqeq - return (value == parseFloat(value)) ? !(value % 2) : void 0; -}; - -module.exports = IsEven; - - -/***/ }), -/* 828 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.IsEvenStrict - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {boolean} [description] - */ -var IsEvenStrict = function (value) -{ - // Use strict equality === for "is number" test - return (value === parseFloat(value)) ? !(value % 2) : void 0; -}; - -module.exports = IsEvenStrict; - - -/***/ }), -/* 829 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.MaxAdd - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} amount - [description] - * @param {number} max - [description] - * - * @return {number} [description] - */ -var MaxAdd = function (value, amount, max) -{ - return Math.min(value + amount, max); -}; - -module.exports = MaxAdd; - - -/***/ }), -/* 830 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.MinSub - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} amount - [description] - * @param {number} min - [description] - * - * @return {number} [description] - */ -var MinSub = function (value, amount, min) -{ - return Math.max(value - amount, min); -}; - -module.exports = MinSub; - - -/***/ }), -/* 831 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Work out what percentage `value` is of the range between `min` and `max`. - * If `max` isn't given then it will return the percentage of `value` to `min`. - * - * You can optionally specify an `upperMax` value, which is a mid-way point in the range that represents 100%, after which the % starts to go down to zero again. - * - * @function Phaser.Math.Percent - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} min - [description] - * @param {number} [max] - [description] - * @param {number} [upperMax] - [description] - * - * @return {float} A value between 0 and 1 representing the percentage. - */ -var Percent = function (value, min, max, upperMax) -{ - if (max === undefined) { max = min + 1; } - - var percentage = (value - min) / (max - min); - - if (percentage > 1) - { - if (upperMax !== undefined) - { - percentage = ((upperMax - value)) / (upperMax - max); - - if (percentage < 0) - { - percentage = 0; - } - } - else - { - percentage = 1; - } - } - else if (percentage < 0) - { - percentage = 0; - } - - return percentage; -}; - -module.exports = Percent; - - -/***/ }), -/* 832 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.RandomXY - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} vector - [description] - * @param {float} scale - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ -var RandomXY = function (vector, scale) -{ - if (scale === undefined) { scale = 1; } - - var r = Math.random() * 2 * Math.PI; - - vector.x = Math.cos(r) * scale; - vector.y = Math.sin(r) * scale; - - return vector; -}; - -module.exports = RandomXY; - - -/***/ }), -/* 833 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.RoundTo - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {integer} [place=0] - [description] - * @param {integer} [base=10] - [description] - * - * @return {number} [description] - */ -var RoundTo = function (value, place, base) -{ - if (place === undefined) { place = 0; } - if (base === undefined) { base = 10; } - - var p = Math.pow(base, -place); - - return Math.round(value * p) / p; -}; - -module.exports = RoundTo; - - -/***/ }), -/* 834 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - - -/** - * [description] - * - * @function Phaser.Math.SinCosTableGenerator - * @since 3.0.0 - * - * @param {number} length - [description] - * @param {number} sinAmp - [description] - * @param {number} cosAmp - [description] - * @param {number} frequency - [description] - * - * @return {object} [description] - */ -var SinCosTableGenerator = function (length, sinAmp, cosAmp, frequency) -{ - if (sinAmp === undefined) { sinAmp = 1; } - if (cosAmp === undefined) { cosAmp = 1; } - if (frequency === undefined) { frequency = 1; } - - frequency *= Math.PI / length; - - var cos = []; - var sin = []; - - for (var c = 0; c < length; c++) - { - cosAmp -= sinAmp * frequency; - sinAmp += cosAmp * frequency; - - cos[c] = cosAmp; - sin[c] = sinAmp; - } - - return { - sin: sin, - cos: cos, - length: length - }; -}; - -module.exports = SinCosTableGenerator; - - -/***/ }), -/* 835 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Checks if the two values are within the given `tolerance` of each other. - * - * @function Phaser.Math.Within - * @since 3.0.0 - * - * @param {number} a - [description] - * @param {number} b - [description] - * @param {number} tolerance - The tolerance. Anything equal to or less than this value is considered as being within range. - * - * @return {boolean} Returns `true` if `a` is less than or equal to the tolerance of `b`. - */ -var Within = function (a, b, tolerance) -{ - return (Math.abs(a - b) <= tolerance); -}; - -module.exports = Within; - - -/***/ }), -/* 836 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Physics.Arcade - */ - -module.exports = { - - ArcadePhysics: __webpack_require__(837), - Body: __webpack_require__(332), - Collider: __webpack_require__(333), - Factory: __webpack_require__(326), - Group: __webpack_require__(329), - Image: __webpack_require__(327), - Sprite: __webpack_require__(91), - StaticBody: __webpack_require__(340), - StaticGroup: __webpack_require__(330), - World: __webpack_require__(331) - -}; - - -/***/ }), -/* 837 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Factory = __webpack_require__(326); -var GetFastValue = __webpack_require__(2); -var Merge = __webpack_require__(104); -var PluginManager = __webpack_require__(12); -var World = __webpack_require__(331); -var DistanceBetween = __webpack_require__(42); -var DegToRad = __webpack_require__(35); - -// All methods in this class are available under `this.physics` in a Scene. - -/** - * @classdesc - * [description] - * - * @class ArcadePhysics - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var ArcadePhysics = new Class({ - - initialize: - - function ArcadePhysics (scene) - { - /** - * [description] - * - * @name Phaser.Physics.Arcade.ArcadePhysics#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.ArcadePhysics#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - if (!scene.sys.settings.isBooted) - { - scene.sys.events.once('boot', this.boot, this); - } - - /** - * [description] - * - * @name Phaser.Physics.Arcade.ArcadePhysics#config - * @type {object} - * @since 3.0.0 - */ - this.config = this.getConfig(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.ArcadePhysics#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.ArcadePhysics#add - * @type {Phaser.Physics.Arcade.Factory} - * @since 3.0.0 - */ - this.add; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.ArcadePhysics#getConfig - * @since 3.0.0 - * - * @return {object} [description] - */ - getConfig: function () - { - var gameConfig = this.systems.game.config.physics; - var sceneConfig = this.systems.settings.physics; - - var config = Merge( - GetFastValue(sceneConfig, 'arcade', {}), - GetFastValue(gameConfig, 'arcade', {}) - ); - - return config; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.ArcadePhysics#boot - * @since 3.0.0 - */ - boot: function () - { - this.world = new World(this.scene, this.config); - this.add = new Factory(this.world); - - var eventEmitter = this.systems.events; - - eventEmitter.on('update', this.world.update, this.world); - eventEmitter.on('postupdate', this.world.postUpdate, this.world); - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); - }, - - /** - * Checks for overlaps between two Game Objects. The objects can be any Game Object that have an Arcade Physics Body. - * - * Unlike {@link #collide} the objects are NOT automatically separated or have any physics applied, they merely test for overlap results. - * - * Both the first and second parameter can be arrays of objects, of differing types. - * If two arrays are passed, the contents of the first parameter will be tested against all contents of the 2nd parameter. - * - * ##### Tilemaps - * - * Any overlapping tiles, including blank/null tiles, will give a positive result. Tiles marked via {@link Phaser.Tilemap#setCollision} (and similar methods) have no special status, and callbacks added via {@link Phaser.Tilemap#setTileIndexCallback} or {@link Phaser.Tilemap#setTileLocationCallback} are not invoked. So calling this method without any callbacks isn't very useful. - * - * If you're interested only in whether an object overlaps a certain tile or class of tiles, filter the tiles with `processCallback` and then use the result returned by this method. Blank/null tiles can be excluded by their {@link Phaser.Tile#index index} (-1). - * - * If you want to take action on certain overlaps, examine the tiles in `collideCallback` and then handle as you like. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#overlap - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject|array} object1 - The first object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param {Phaser.GameObjects.GameObject|array} object2 - The second object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param {function} [overlapCallback=null] - An optional callback function that is called if the objects overlap. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter. - * @param {function} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `overlapCallback` will only be called if this callback returns `true`. - * @param {object} [callbackContext] - The context in which to run the callbacks. - * - * @return {boolean} True if an overlap occurred otherwise false. - */ - overlap: function (object1, object2, overlapCallback, processCallback, callbackContext) - { - if (overlapCallback === undefined) { overlapCallback = null; } - if (processCallback === undefined) { processCallback = null; } - if (callbackContext === undefined) { callbackContext = overlapCallback; } - - return this.world.collideObjects(object1, object2, overlapCallback, processCallback, callbackContext, true); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.ArcadePhysics#collide - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject|array} object1 - The first object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param {Phaser.GameObjects.GameObject|array} object2 - The second object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param {function} [collideCallback=null] - An optional callback function that is called if the objects collide. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter. - * @param {function} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. - * @param {object} [callbackContext] - The context in which to run the callbacks. - * - * @return {boolean} True if a collision occurred otherwise false. - */ - collide: function (object1, object2, collideCallback, processCallback, callbackContext) - { - if (collideCallback === undefined) { collideCallback = null; } - if (processCallback === undefined) { processCallback = null; } - if (callbackContext === undefined) { callbackContext = collideCallback; } - - return this.world.collideObjects(object1, object2, collideCallback, processCallback, callbackContext, false); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.ArcadePhysics#pause - * @since 3.0.0 - * - * @return {[type]} [description] - */ - pause: function () - { - return this.world.pause(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.ArcadePhysics#resume - * @since 3.0.0 - * - * @return {[type]} [description] - */ - resume: function () - { - return this.world.resume(); - }, - - /** - * Sets the acceleration.x/y property on the game object so it will move towards the x/y coordinates at the given speed (in pixels per second sq.) - * - * You must give a maximum speed value, beyond which the game object won't go any faster. - * - * Note: The game object does not continuously track the target. If the target changes location during transit the game object will not modify its course. - * Note: The game object doesn't stop moving once it reaches the destination coordinates. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#accelerateTo - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. - * @param {number} x - The x coordinate to accelerate towards. - * @param {number} y - The y coordinate to accelerate towards. - * @param {number} [speed=60] - The speed it will accelerate in pixels per second. - * @param {number} [xSpeedMax=500] - The maximum x velocity the game object can reach. - * @param {number} [ySpeedMax=500] - The maximum y velocity the game object can reach. - * - * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. - */ - accelerateTo: function (gameObject, x, y, speed, xSpeedMax, ySpeedMax) - { - if (speed === undefined) { speed = 60; } - - var angle = Math.atan2(y - gameObject.y, x - gameObject.x); - - gameObject.body.acceleration.setToPolar(angle, speed); - - if (xSpeedMax !== undefined && ySpeedMax !== undefined) - { - gameObject.body.maxVelocity.set(xSpeedMax, ySpeedMax); - } - - return angle; - }, - - /** - * Sets the acceleration.x/y property on the game object so it will move towards the x/y coordinates at the given speed (in pixels per second sq.) - * - * You must give a maximum speed value, beyond which the game object won't go any faster. - * - * Note: The game object does not continuously track the target. If the target changes location during transit the game object will not modify its course. - * Note: The game object doesn't stop moving once it reaches the destination coordinates. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#accelerateToObject - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. - * @param {Phaser.GameObjects.GameObject} destination - The Game Object to move towards. Can be any object but must have visible x/y properties. - * @param {number} [speed=60] - The speed it will accelerate in pixels per second. - * @param {number} [xSpeedMax=500] - The maximum x velocity the game object can reach. - * @param {number} [ySpeedMax=500] - The maximum y velocity the game object can reach. - * - * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. - */ - accelerateToObject: function (gameObject, destination, speed, xSpeedMax, ySpeedMax) - { - return this.accelerateTo(gameObject, destination.x, destination.y, speed, xSpeedMax, ySpeedMax); - }, - - /** - * From a set of points or display objects, find the one closest to a source point or object. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#closest - * @since 3.0.0 - * - * @param {object} source - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. - * - * @return {Phaser.Physics.Arcade.Body} The closest Body to the given source point. - */ - closest: function (source) - { - var bodies = this.tree.all(); - - var min = Number.MAX_VALUE; - var closest = null; - var x = source.x; - var y = source.y; - - for (var i = bodies.length - 1; i >= 0; i--) - { - var target = bodies[i]; - var distance = DistanceBetween(x, y, target.x, target.y); - - if (distance < min) - { - closest = target; - min = distance; - } - } - - return closest; - }, - - /** - * From a set of points or display objects, find the one farthest from a source point or object. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#furthest - * @since 3.0.0 - * - * @param {object} source - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. - * - * @return {Phaser.Physics.Arcade.Body} The Body furthest from the given source point. - */ - furthest: function (source) - { - var bodies = this.tree.all(); - - var max = -1; - var farthest = null; - var x = source.x; - var y = source.y; - - for (var i = bodies.length - 1; i >= 0; i--) - { - var target = bodies[i]; - var distance = DistanceBetween(x, y, target.x, target.y); - - if (distance > max) - { - farthest = target; - max = distance; - } - } - - return farthest; - }, - - /** - * Move the given display object towards the x/y coordinates at a steady velocity. - * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. - * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. - * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. - * Note: The display object doesn't stop moving once it reaches the destination coordinates. - * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) - * - * @method Phaser.Physics.Arcade.ArcadePhysics#moveTo - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. - * @param {number} x - The x coordinate to move towards. - * @param {number} y - The y coordinate to move towards. - * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) - * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. - * - * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. - */ - moveTo: function (gameObject, x, y, speed, maxTime) - { - if (speed === undefined) { speed = 60; } - if (maxTime === undefined) { maxTime = 0; } - - var angle = Math.atan2(y - gameObject.y, x - gameObject.x); - - if (maxTime > 0) - { - // We know how many pixels we need to move, but how fast? - speed = DistanceBetween(gameObject.x, gameObject.y, x, y) / (maxTime / 1000); - } - - gameObject.body.velocity.setToPolar(angle, speed); - - return angle; - }, - - /** - * Move the given display object towards the destination object at a steady velocity. - * If you specify a maxTime then it will adjust the speed (overwriting what you set) so it arrives at the destination in that number of seconds. - * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. - * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. - * Note: The display object doesn't stop moving once it reaches the destination coordinates. - * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) - * - * @method Phaser.Physics.Arcade.ArcadePhysics#moveToObject - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. - * @param {object} destination - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. - * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) - * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. - * - * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. - */ - moveToObject: function (gameObject, destination, speed, maxTime) - { - return this.moveTo(gameObject, destination.x, destination.y, speed, maxTime); - }, - - /** - * Given the angle (in degrees) and speed calculate the velocity and return it as a Point object, or set it to the given point object. - * One way to use this is: velocityFromAngle(angle, 200, sprite.velocity) which will set the values directly to the sprites velocity and not create a new Point object. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#velocityFromAngle - * @since 3.0.0 - * - * @param {number} angle - The angle in degrees calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) - * @param {number} [speed=60] - The speed it will move, in pixels per second sq. - * @param {Phaser.Math.Vector2} vec2 - The Vector2 in which the x and y properties will be set to the calculated velocity. - * - * @return {Phaser.Math.Vector2} The Vector2 that stores the velocity. - */ - velocityFromAngle: function (angle, speed, vec2) - { - if (speed === undefined) { speed = 60; } - - return vec2.setToPolar(DegToRad(angle), speed); - }, - - /** - * Given the rotation (in radians) and speed calculate the velocity and return it as a Point object, or set it to the given point object. - * One way to use this is: velocityFromRotation(rotation, 200, sprite.velocity) which will set the values directly to the sprites velocity and not create a new Point object. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#velocityFromRotation - * @since 3.0.0 - * - * @param {number} rotation - The angle in radians. - * @param {number} [speed=60] - The speed it will move, in pixels per second sq. - * @param {Phaser.Math.Vector2} vec2 - The Vector2 in which the x and y properties will be set to the calculated velocity. - * - * @return {Phaser.Math.Vector2} The Vector2 that stores the velocity. - */ - velocityFromRotation: function (rotation, speed, vec2) - { - if (speed === undefined) { speed = 60; } - - return vec2.setToPolar(rotation, speed); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.ArcadePhysics#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this.world.shutdown(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.ArcadePhysics#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.world.destroy(); - } - -}); - -PluginManager.register('ArcadePhysics', ArcadePhysics, 'arcadePhysics'); - -module.exports = ArcadePhysics; - - -/***/ }), -/* 838 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Acceleration - * @since 3.0.0 - */ -var Acceleration = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Acceleration#setAcceleration - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setAcceleration: function (x, y) - { - this.body.acceleration.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Acceleration#setAccelerationX - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setAccelerationX: function (value) - { - this.body.acceleration.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Acceleration#setAccelerationY - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setAccelerationY: function (value) - { - this.body.acceleration.y = value; - - return this; - } - -}; - -module.exports = Acceleration; - - -/***/ }), -/* 839 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Angular - * @since 3.0.0 - */ -var Angular = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Angular#setAngularVelocity - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setAngularVelocity: function (value) - { - this.body.angularVelocity = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Angular#setAngularAcceleration - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setAngularAcceleration: function (value) - { - this.body.angularAcceleration = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Angular#setAngularDrag - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setAngularDrag: function (value) - { - this.body.angularDrag = value; - - return this; - } - -}; - -module.exports = Angular; - - -/***/ }), -/* 840 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Bounce - * @since 3.0.0 - */ -var Bounce = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Bounce#setBounce - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setBounce: function (x, y) - { - this.body.bounce.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Bounce#setBounceX - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setBounceX: function (value) - { - this.body.bounce.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Bounce#setBounceY - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setBounceY: function (value) - { - this.body.bounce.y = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Bounce#setCollideWorldBounds - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setCollideWorldBounds: function (value) - { - this.body.collideWorldBounds = value; - - return this; - } - -}; - -module.exports = Bounce; - - -/***/ }), -/* 841 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Debug - * @since 3.0.0 - */ -var Debug = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Debug#setDebug - * @since 3.0.0 - * - * @param {[type]} showBody - [description] - * @param {[type]} showVelocity - [description] - * @param {[type]} bodyColor - [description] - * - * @return {[type]} [description] - */ - setDebug: function (showBody, showVelocity, bodyColor) - { - this.debugShowBody = showBody; - this.debugShowVelocity = showVelocity; - this.debugBodyColor = bodyColor; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Debug#setDebugBodyColor - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setDebugBodyColor: function (value) - { - this.body.debugBodyColor = value; - - return this; - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Debug#debugShowBody - * @type {[type]} - * @since 3.0.0 - */ - debugShowBody: { - - get: function () - { - return this.body.debugShowBody; - }, - - set: function (value) - { - this.body.debugShowBody = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Debug#debugShowVelocity - * @type {[type]} - * @since 3.0.0 - */ - debugShowVelocity: { - - get: function () - { - return this.body.debugShowVelocity; - }, - - set: function (value) - { - this.body.debugShowVelocity = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Debug#debugBodyColor - * @type {[type]} - * @since 3.0.0 - */ - debugBodyColor: { - - get: function () - { - return this.body.debugBodyColor; - }, - - set: function (value) - { - this.body.debugBodyColor = value; - } - - } - -}; - -module.exports = Debug; - - -/***/ }), -/* 842 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Drag - * @since 3.0.0 - */ -var Drag = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Drag#setDrag - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setDrag: function (x, y) - { - this.body.drag.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Drag#setDragX - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setDragX: function (value) - { - this.body.drag.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Drag#setDragY - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setDragY: function (value) - { - this.body.drag.y = value; - - return this; - } - -}; - -module.exports = Drag; - - -/***/ }), -/* 843 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Enable - * @since 3.0.0 - */ -var Enable = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Enable#enableBody - * @since 3.0.0 - * - * @param {boolean} reset - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {boolean} enableGameObject - [description] - * @param {boolean} showGameObject - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object. - */ - enableBody: function (reset, x, y, enableGameObject, showGameObject) - { - if (reset) - { - this.body.reset(x, y); - } - - if (enableGameObject) - { - this.body.gameObject.active = true; - } - - if (showGameObject) - { - this.body.gameObject.visible = true; - } - - this.body.enable = true; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Enable#disableBody - * @since 3.0.0 - * - * @param {boolean} [disableGameObject=false] - [description] - * @param {boolean} [hideGameObject=false] - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object. - */ - disableBody: function (disableGameObject, hideGameObject) - { - if (disableGameObject === undefined) { disableGameObject = false; } - if (hideGameObject === undefined) { hideGameObject = false; } - - this.body.stop(); - - this.body.enable = false; - - if (disableGameObject) - { - this.body.gameObject.active = false; - } - - if (hideGameObject) - { - this.body.gameObject.visible = false; - } - - return this; - }, - - /** - * Syncs the Bodies position and size with its parent Game Object. - * You don't need to call this for Dynamic Bodies, as it happens automatically. - * But for Static bodies it's a useful way of modifying the position of a Static Body - * in the Physics World, based on its Game Object. - * - * @method Phaser.Physics.Arcade.Components.Enable#refreshBody - * @since 3.1.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object. - */ - refreshBody: function () - { - this.body.updateFromGameObject(); - - return this; - } - -}; - -module.exports = Enable; - - -/***/ }), -/* 844 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Friction - * @since 3.0.0 - */ -var Friction = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Friction#setFriction - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setFriction: function (x, y) - { - this.body.friction.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Friction#setFrictionX - * @since 3.0.0 - * - * @param {[type]} x - [description] - * - * @return {[type]} [description] - */ - setFrictionX: function (x) - { - this.body.friction.x = x; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Friction#setFrictionY - * @since 3.0.0 - * - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setFrictionY: function (y) - { - this.body.friction.y = y; - - return this; - } - -}; - -module.exports = Friction; - - -/***/ }), -/* 845 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Gravity - * @since 3.0.0 - */ -var Gravity = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Gravity#setGravity - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setGravity: function (x, y) - { - this.body.gravity.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Gravity#setGravityX - * @since 3.0.0 - * - * @param {[type]} x - [description] - * - * @return {[type]} [description] - */ - setGravityX: function (x) - { - this.body.gravity.x = x; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Gravity#setGravityY - * @since 3.0.0 - * - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setGravityY: function (y) - { - this.body.gravity.y = y; - - return this; - } - -}; - -module.exports = Gravity; - - -/***/ }), -/* 846 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Immovable - * @since 3.0.0 - */ -var Immovable = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Immovable#setImmovable - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setImmovable: function (value) - { - if (value === undefined) { value = true; } - - this.body.immovable = value; - - return this; - } - -}; - -module.exports = Immovable; - - -/***/ }), -/* 847 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Mass - * @since 3.0.0 - */ -var Mass = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Mass#setMass - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setMass: function (value) - { - this.body.mass = value; - - return this; - } - -}; - -module.exports = Mass; - - -/***/ }), -/* 848 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Size - * @since 3.0.0 - */ -var Size = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Size#setOffset - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setOffset: function (x, y) - { - this.body.setOffset(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Size#setSize - * @since 3.0.0 - * - * @param {[type]} width - [description] - * @param {[type]} height - [description] - * @param {[type]} center - [description] - * - * @return {[type]} [description] - */ - setSize: function (width, height, center) - { - this.body.setSize(width, height, center); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Size#setCircle - * @since 3.0.0 - * - * @param {[type]} radius - [description] - * @param {[type]} offsetX - [description] - * @param {[type]} offsetY - [description] - * - * @return {[type]} [description] - */ - setCircle: function (radius, offsetX, offsetY) - { - this.body.setCircle(radius, offsetX, offsetY); - - return this; - } - -}; - -module.exports = Size; - - -/***/ }), -/* 849 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Velocity - * @since 3.0.0 - */ -var Velocity = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Velocity#setVelocity - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setVelocity: function (x, y) - { - this.body.velocity.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Velocity#setVelocityX - * @since 3.0.0 - * - * @param {[type]} x - [description] - * - * @return {[type]} [description] - */ - setVelocityX: function (x) - { - this.body.velocity.x = x; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Velocity#setVelocityY - * @since 3.0.0 - * - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setVelocityY: function (y) - { - this.body.velocity.y = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Velocity#setMaxVelocity - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setMaxVelocity: function (x, y) - { - if (y === undefined) { y = x; } - - this.body.maxVelocity.set(x, y); - - return this; - } - -}; - -module.exports = Velocity; - - -/***/ }), -/* 850 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Physics.Arcade.Tilemap.ProcessTileCallbacks - * @since 3.0.0 - * - * @param {[type]} tile - [description] - * @param {Phaser.GameObjects.Sprite} sprite - [description] - * - * @return {boolean} [description] - */ -var ProcessTileCallbacks = function (tile, sprite) -{ - // Tile callbacks take priority over layer level callbacks - if (tile.collisionCallback) - { - return !tile.collisionCallback.call(tile.collisionCallbackContext, sprite, tile); - } - else if (tile.layer.callbacks[tile.index]) - { - return !tile.layer.callbacks[tile.index].callback.call( - tile.layer.callbacks[tile.index].callbackContext, sprite, tile - ); - } - - return true; -}; - -module.exports = ProcessTileCallbacks; - - -/***/ }), -/* 851 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var TileCheckX = __webpack_require__(852); -var TileCheckY = __webpack_require__(854); -var TileIntersectsBody = __webpack_require__(339); - -/** - * The core separation function to separate a physics body and a tile. - * - * @function Phaser.Physics.Arcade.Tilemap.SeparateTile - * @since 3.0.0 - * - * @param {number} i - [description] - * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. - * @param {Phaser.Tilemaps.Tile} tile - The tile to collide against. - * @param {Phaser.Geom.Rectangle} tileWorldRect - [description] - * @param {Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer} tilemapLayer - The tilemapLayer to collide against. - * @param {number} tileBias - [description] - * - * @return {boolean} Returns true if the body was separated, otherwise false. - */ -var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer, tileBias) -{ - var tileLeft = tileWorldRect.left; - var tileTop = tileWorldRect.top; - var tileRight = tileWorldRect.right; - var tileBottom = tileWorldRect.bottom; - var faceHorizontal = tile.faceLeft || tile.faceRight; - var faceVertical = tile.faceTop || tile.faceBottom; - - // We don't need to go any further if this tile doesn't actually have any colliding faces. This - // could happen if the tile was meant to be collided with re: a callback, but otherwise isn't - // needed for separation. - if (!faceHorizontal && !faceVertical) - { - return false; - } - - var ox = 0; - var oy = 0; - var minX = 0; - var minY = 1; - - if (body.deltaAbsX() > body.deltaAbsY()) - { - // Moving faster horizontally, check X axis first - minX = -1; - } - else if (body.deltaAbsX() < body.deltaAbsY()) - { - // Moving faster vertically, check Y axis first - minY = -1; - } - - if (body.deltaX() !== 0 && body.deltaY() !== 0 && faceHorizontal && faceVertical) - { - // We only need do this if both axes have colliding faces AND we're moving in both - // directions - minX = Math.min(Math.abs(body.position.x - tileRight), Math.abs(body.right - tileLeft)); - minY = Math.min(Math.abs(body.position.y - tileBottom), Math.abs(body.bottom - tileTop)); - } - - if (minX < minY) - { - if (faceHorizontal) - { - ox = TileCheckX(body, tile, tileLeft, tileRight, tileBias); - - // That's horizontal done, check if we still intersects? If not then we can return now - if (ox !== 0 && !TileIntersectsBody(tileWorldRect, body)) - { - return true; - } - } - - if (faceVertical) - { - oy = TileCheckY(body, tile, tileTop, tileBottom, tileBias); - } - } - else - { - if (faceVertical) - { - oy = TileCheckY(body, tile, tileTop, tileBottom, tileBias); - - // That's vertical done, check if we still intersects? If not then we can return now - if (oy !== 0 && !TileIntersectsBody(tileWorldRect, body)) - { - return true; - } - } - - if (faceHorizontal) - { - ox = TileCheckX(body, tile, tileLeft, tileRight, tileBias); - } - } - - return (ox !== 0 || oy !== 0); -}; - -module.exports = SeparateTile; - - -/***/ }), -/* 852 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ProcessTileSeparationX = __webpack_require__(853); - -/** - * Check the body against the given tile on the X axis. - * - * @function Phaser.Physics.Arcade.Tilemap.TileCheckX - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. - * @param {Phaser.Tilemaps.Tile} tile - The tile to check. - * @param {number} tileLeft - [description] - * @param {number} tileRight - [description] - * @param {number} tileBias - [description] - * - * @return {number} The amount of separation that occurred. - */ -var TileCheckX = function (body, tile, tileLeft, tileRight, tileBias) -{ - var ox = 0; - - if (body.deltaX() < 0 && !body.blocked.left && tile.collideRight && body.checkCollision.left) - { - // Body is moving LEFT - if (tile.faceRight && body.x < tileRight) - { - ox = body.x - tileRight; - - if (ox < -tileBias) - { - ox = 0; - } - } - } - else if (body.deltaX() > 0 && !body.blocked.right && tile.collideLeft && body.checkCollision.right) - { - // Body is moving RIGHT - if (tile.faceLeft && body.right > tileLeft) - { - ox = body.right - tileLeft; - - if (ox > tileBias) - { - ox = 0; - } - } - } - - if (ox !== 0) - { - if (body.customSeparateX) - { - body.overlapX = ox; - } - else - { - ProcessTileSeparationX(body, ox); - } - } - - return ox; -}; - -module.exports = TileCheckX; - - -/***/ }), -/* 853 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Internal function to process the separation of a physics body from a tile. - * - * @function Phaser.Physics.Arcade.Tilemap.ProcessTileSeparationX - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. - * @param {number} x - The x separation amount. - */ -var ProcessTileSeparationX = function (body, x) -{ - if (x < 0) - { - body.blocked.left = true; - } - else if (x > 0) - { - body.blocked.right = true; - } - - body.position.x -= x; - - if (body.bounce.x === 0) - { - body.velocity.x = 0; - } - else - { - body.velocity.x = -body.velocity.x * body.bounce.x; - } -}; - -module.exports = ProcessTileSeparationX; - - -/***/ }), -/* 854 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ProcessTileSeparationY = __webpack_require__(855); - -/** - * Check the body against the given tile on the Y axis. - * - * @function Phaser.Physics.Arcade.Tilemap.TileCheckY - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. - * @param {Phaser.Tilemaps.Tile} tile - The tile to check. - * @param {number} tileTop - [description] - * @param {number} tileBottom - [description] - * @param {number} tileBias - [description] - * - * @return {number} The amount of separation that occurred. - */ -var TileCheckY = function (body, tile, tileTop, tileBottom, tileBias) -{ - var oy = 0; - - if (body.deltaY() < 0 && !body.blocked.up && tile.collideDown && body.checkCollision.up) - { - // Body is moving UP - if (tile.faceBottom && body.y < tileBottom) - { - oy = body.y - tileBottom; - - if (oy < -tileBias) - { - oy = 0; - } - } - } - else if (body.deltaY() > 0 && !body.blocked.down && tile.collideUp && body.checkCollision.down) - { - // Body is moving DOWN - if (tile.faceTop && body.bottom > tileTop) - { - oy = body.bottom - tileTop; - - if (oy > tileBias) - { - oy = 0; - } - } - } - - if (oy !== 0) - { - if (body.customSeparateY) - { - body.overlapY = oy; - } - else - { - ProcessTileSeparationY(body, oy); - } - } - - return oy; -}; - -module.exports = TileCheckY; - - -/***/ }), -/* 855 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Internal function to process the separation of a physics body from a tile. - * - * @function Phaser.Physics.Arcade.Tilemap.ProcessTileSeparationY - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. - * @param {number} y - The y separation amount. - */ -var ProcessTileSeparationY = function (body, y) -{ - if (y < 0) - { - body.blocked.up = true; - } - else if (y > 0) - { - body.blocked.down = true; - } - - body.position.y -= y; - - if (body.bounce.y === 0) - { - body.velocity.y = 0; - } - else - { - body.velocity.y = -body.velocity.y * body.bounce.y; - } -}; - -module.exports = ProcessTileSeparationY; - - -/***/ }), -/* 856 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetOverlapX = __webpack_require__(334); - -/** - * [description] - * - * @function Phaser.Physics.Arcade.SeparateX - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {boolean} overlapOnly - [description] - * @param {number} bias - [description] - * - * @return {boolean} [description] - */ -var SeparateX = function (body1, body2, overlapOnly, bias) -{ - var overlap = GetOverlapX(body1, body2, overlapOnly, bias); - - // Can't separate two immovable bodies, or a body with its own custom separation logic - if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateX || body2.customSeparateX) - { - // return true if there was some overlap, otherwise false - return (overlap !== 0) || (body1.embedded && body2.embedded); - } - - // Adjust their positions and velocities accordingly (if there was any overlap) - var v1 = body1.velocity.x; - var v2 = body2.velocity.x; - - if (!body1.immovable && !body2.immovable) - { - overlap *= 0.5; - - body1.x -= overlap; - body2.x += overlap; - - var nv1 = Math.sqrt((v2 * v2 * body2.mass) / body1.mass) * ((v2 > 0) ? 1 : -1); - var nv2 = Math.sqrt((v1 * v1 * body1.mass) / body2.mass) * ((v1 > 0) ? 1 : -1); - var avg = (nv1 + nv2) * 0.5; - - nv1 -= avg; - nv2 -= avg; - - body1.velocity.x = avg + nv1 * body1.bounce.x; - body2.velocity.x = avg + nv2 * body2.bounce.x; - } - else if (!body1.immovable) - { - body1.x -= overlap; - body1.velocity.x = v2 - v1 * body1.bounce.x; - - // This is special case code that handles things like vertically moving platforms you can ride - if (body2.moves) - { - body1.y += (body2.y - body2.prev.y) * body2.friction.y; - } - } - else - { - body2.x += overlap; - body2.velocity.x = v1 - v2 * body2.bounce.x; - - // This is special case code that handles things like vertically moving platforms you can ride - if (body1.moves) - { - body2.y += (body1.y - body1.prev.y) * body1.friction.y; - } - } - - // If we got this far then there WAS overlap, and separation is complete, so return true - return true; -}; - -module.exports = SeparateX; - - -/***/ }), -/* 857 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetOverlapY = __webpack_require__(335); - -/** - * [description] - * - * @function Phaser.Physics.Arcade.SeparateY - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {boolean} overlapOnly - [description] - * @param {number} bias - [description] - * - * @return {boolean} [description] - */ -var SeparateY = function (body1, body2, overlapOnly, bias) -{ - var overlap = GetOverlapY(body1, body2, overlapOnly, bias); - - // Can't separate two immovable bodies, or a body with its own custom separation logic - if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateY || body2.customSeparateY) - { - // return true if there was some overlap, otherwise false - return (overlap !== 0) || (body1.embedded && body2.embedded); - } - - // Adjust their positions and velocities accordingly (if there was any overlap) - var v1 = body1.velocity.y; - var v2 = body2.velocity.y; - - if (!body1.immovable && !body2.immovable) - { - overlap *= 0.5; - - body1.y -= overlap; - body2.y += overlap; - - var nv1 = Math.sqrt((v2 * v2 * body2.mass) / body1.mass) * ((v2 > 0) ? 1 : -1); - var nv2 = Math.sqrt((v1 * v1 * body1.mass) / body2.mass) * ((v1 > 0) ? 1 : -1); - var avg = (nv1 + nv2) * 0.5; - - nv1 -= avg; - nv2 -= avg; - - body1.velocity.y = avg + nv1 * body1.bounce.y; - body2.velocity.y = avg + nv2 * body2.bounce.y; - } - else if (!body1.immovable) - { - body1.y -= overlap; - body1.velocity.y = v2 - v1 * body1.bounce.y; - - // This is special case code that handles things like horizontal moving platforms you can ride - if (body2.moves) - { - body1.x += (body2.x - body2.prev.x) * body2.friction.x; - } - } - else - { - body2.y += overlap; - body2.velocity.y = v1 - v2 * body2.bounce.y; - - // This is special case code that handles things like horizontal moving platforms you can ride - if (body1.moves) - { - body2.x += (body1.x - body1.prev.x) * body1.friction.x; - } - } - - // If we got this far then there WAS overlap, and separation is complete, so return true - return true; -}; - -module.exports = SeparateY; - - -/***/ }), -/* 858 */, -/* 859 */, -/* 860 */, -/* 861 */, -/* 862 */, -/* 863 */, -/* 864 */, -/* 865 */, -/* 866 */, -/* 867 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Scenes - */ - -module.exports = { - - SceneManager: __webpack_require__(252), - ScenePlugin: __webpack_require__(868), - Settings: __webpack_require__(255), - Systems: __webpack_require__(130) - -}; - - -/***/ }), -/* 868 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(83); -var PluginManager = __webpack_require__(12); - -/** - * @classdesc - * A proxy class to the Global Scene Manager. - * - * @class ScenePlugin - * @memberOf Phaser.Scenes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var ScenePlugin = new Class({ - - initialize: - - function ScenePlugin (scene) - { - /** - * [description] - * - * @name Phaser.Scenes.ScenePlugin#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.Scenes.ScenePlugin#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - if (!scene.sys.settings.isBooted) - { - scene.sys.events.once('boot', this.boot, this); - } - - /** - * [description] - * - * @name Phaser.Scenes.ScenePlugin#settings - * @type {object} - * @since 3.0.0 - */ - this.settings = scene.sys.settings; - - /** - * [description] - * - * @name Phaser.Scenes.ScenePlugin#key - * @type {string} - * @since 3.0.0 - */ - this.key = scene.sys.settings.key; - - /** - * [description] - * - * @name Phaser.Scenes.ScenePlugin#manager - * @type {Phaser.Scenes.SceneManager} - * @since 3.0.0 - */ - this.manager = scene.sys.game.scene; - }, - - /** - * [description] - * - * @method Phaser.Scenes.ScenePlugin#boot - * @since 3.0.0 - */ - boot: function () - { - var eventEmitter = this.systems.events; - - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); - }, - - /** - * Shutdown this Scene and run the given one. - * - * @method Phaser.Scenes.ScenePlugin#start - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {object} [data] - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - start: function (key, data) - { - if (key === undefined) { key = this.key; } - - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('stop', this.key); - this.manager.queueOp('start', key); - } - else - { - this.manager.stop(this.key); - this.manager.start(key, data); - } - - return this; - }, - - /** - * Add the Scene into the Scene Manager and start it if 'autoStart' is true or the Scene config 'active' property is set. - * - * @method Phaser.Scenes.ScenePlugin#add - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {object} sceneConfig - [description] - * @param {boolean} autoStart - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - add: function (key, sceneConfig, autoStart) - { - this.manager.add(key, sceneConfig, autoStart); - - return this; - }, - - /** - * Launch the given Scene and run it in parallel with this one. - * - * @method Phaser.Scenes.ScenePlugin#launch - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {object} [data] - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - launch: function (key, data) - { - if (key && key !== this.key) - { - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('start', key, data); - } - else - { - this.manager.start(key, data); - } - } - - return this; - }, - - /** - * Pause the Scene - this stops the update step from happening but it still renders. - * - * @method Phaser.Scenes.ScenePlugin#pause - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - pause: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.pause(key); - - return this; - }, - - /** - * Resume the Scene - starts the update loop again. - * - * @method Phaser.Scenes.ScenePlugin#resume - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - resume: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.resume(key); - - return this; - }, - - /** - * Makes the Scene sleep (no update, no render) but doesn't shutdown. - * - * @method Phaser.Scenes.ScenePlugin#sleep - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - sleep: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.sleep(key); - - return this; - }, - - /** - * Makes the Scene wake-up (starts update and render) - * - * @method Phaser.Scenes.ScenePlugin#wake - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - wake: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.wake(key); - - return this; - }, - - /** - * Makes this Scene sleep then starts the Scene given. - * - * @method Phaser.Scenes.ScenePlugin#switch - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - switch: function (key) - { - if (key !== this.key) - { - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('switch', this.key, key); - } - else - { - this.manager.switch(this.key, key); - } - } - - return this; - }, - - /** - * Shutdown the Scene, clearing display list, timers, etc. - * - * @method Phaser.Scenes.ScenePlugin#stop - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - stop: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.stop(key); - - return this; - }, - - /** - * Sets the active state of the given Scene. - * - * @method Phaser.Scenes.ScenePlugin#setActive - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - setActive: function (value) - { - this.settings.active = value; - - return this; - }, - - /** - * Sets the visible state of the given Scene. - * - * @method Phaser.Scenes.ScenePlugin#setVisible - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - setVisible: function (value) - { - this.settings.visible = value; - - return this; - }, - - /** - * Checks if the given Scene is sleeping or not? - * - * @method Phaser.Scenes.ScenePlugin#isSleeping - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {boolean} [description] - */ - isSleeping: function (key) - { - if (key === undefined) { key = this.key; } - - return this.manager.isSleeping(key); - }, - - /** - * Checks if the given Scene is active or not? - * - * @method Phaser.Scenes.ScenePlugin#isActive - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {boolean} [description] - */ - isActive: function (key) - { - if (key === undefined) { key = this.key; } - - return this.manager.isActive(key); - }, - - /** - * Checks if the given Scene is visible or not? - * - * @method Phaser.Scenes.ScenePlugin#isVisible - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {boolean} [description] - */ - isVisible: function (key) - { - if (key === undefined) { key = this.key; } - - return this.manager.isVisible(key); - }, - - /** - * Swaps the position of two scenes in the Scenes list. - * This controls the order in which they are rendered and updated. - * - * @method Phaser.Scenes.ScenePlugin#swapPosition - * @since 3.2.0 - * - * @param {string} keyA - The first Scene to swap. - * @param {string} [keyB] - The second Scene to swap. If none is given it defaults to this Scene. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - swapPosition: function (keyA, keyB) - { - if (keyB === undefined) { keyB = this.key; } - - if (keyA !== keyB) - { - this.manager.swapPosition(keyA, keyB); - } - - return this; - }, - - /** - * Swaps the position of two scenes in the Scenes list, so that Scene B is directly above Scene A. - * This controls the order in which they are rendered and updated. - * - * @method Phaser.Scenes.ScenePlugin#moveAbove - * @since 3.2.0 - * - * @param {string} keyA - The Scene that Scene B will be moved to be above. - * @param {string} [keyB] - The Scene to be moved. If none is given it defaults to this Scene. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - moveAbove: function (keyA, keyB) - { - if (keyB === undefined) { keyB = this.key; } - - if (keyA !== keyB) - { - this.manager.moveAbove(keyA, keyB); - } - - return this; - }, - - /** - * Swaps the position of two scenes in the Scenes list, so that Scene B is directly below Scene A. - * This controls the order in which they are rendered and updated. - * - * @method Phaser.Scenes.ScenePlugin#moveBelow - * @since 3.2.0 - * - * @param {string} keyA - The Scene that Scene B will be moved to be below. - * @param {string} [keyB] - The Scene to be moved. If none is given it defaults to this Scene. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - moveBelow: function (keyA, keyB) - { - if (keyB === undefined) { keyB = this.key; } - - if (keyA !== keyB) - { - this.manager.moveBelow(keyA, keyB); - } - - return this; - }, - - /** - * Removes a Scene from the SceneManager. - * - * The Scene is removed from the local scenes array, it's key is cleared from the keys - * cache and Scene.Systems.destroy is then called on it. - * - * If the SceneManager is processing the Scenes when this method is called it wil - * queue the operation for the next update sequence. - * - * @method Phaser.Scenes.ScenePlugin#remove - * @since 3.2.0 - * - * @param {string|Phaser.Scene} scene - The Scene to be removed. - * - * @return {Phaser.Scenes.SceneManager} This SceneManager. - */ - remove: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.remove(key); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.ScenePlugin#moveUp - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - moveUp: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.moveUp(key); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.ScenePlugin#moveDown - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - moveDown: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.moveDown(key); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.ScenePlugin#bringToTop - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - bringToTop: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.bringToTop(key); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.ScenePlugin#sendToBack - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - sendToBack: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.sendToBack(key); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.ScenePlugin#get - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scene} [description] - */ - get: function (key) - { - return this.manager.getScene(key); - }, - - /** - * [description] - * - * @method Phaser.Scenes.ScenePlugin#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - // TODO - }, - - /** - * [description] - * - * @method Phaser.Scenes.ScenePlugin#destroy - * @since 3.0.0 - */ - destroy: function () - { - // TODO - } - -}); - -PluginManager.register('ScenePlugin', ScenePlugin, 'scenePlugin'); - -module.exports = ScenePlugin; - - -/***/ }), -/* 869 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Sound - * - * @author Pavle Goloskokovic (http://prunegames.com) - */ - -/** - * Config object containing various sound settings. - * - * @typedef {object} SoundConfig - * - * @property {boolean} [mute=false] - Boolean indicating whether the sound should be muted or not. - * @property {number} [volume=1] - A value between 0 (silence) and 1 (full volume). - * @property {number} [rate=1] - Defines the speed at which the sound should be played. - * @property {number} [detune=0] - Represents detuning of sound in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * @property {number} [seek=0] - Position of playback for this sound, in seconds. - * @property {boolean} [loop=false] - Whether or not the sound or current sound marker should loop. - * @property {number} [delay=0] - Time, in seconds, that should elapse before the sound actually starts its playback. - */ - -/** - * Marked section of a sound represented by name, and optionally start time, duration, and config object. - * - * @typedef {object} SoundMarker - * - * @property {string} name - Unique identifier of a sound marker. - * @property {number} [start=0] - Sound position offset at witch playback should start. - * @property {number} [duration] - Playback duration of this marker. - * @property {SoundConfig} [config] - An optional config object containing default marker settings. - */ - -module.exports = { - - SoundManagerCreator: __webpack_require__(256), - - BaseSound: __webpack_require__(85), - BaseSoundManager: __webpack_require__(84), - - WebAudioSound: __webpack_require__(262), - WebAudioSoundManager: __webpack_require__(261), - - HTML5AudioSound: __webpack_require__(258), - HTML5AudioSoundManager: __webpack_require__(257), - - NoAudioSound: __webpack_require__(260), - NoAudioSoundManager: __webpack_require__(259) - -}; - - -/***/ }), -/* 870 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Structs - */ - -module.exports = { - - List: __webpack_require__(86), - Map: __webpack_require__(114), - ProcessQueue: __webpack_require__(336), - RTree: __webpack_require__(337), - Set: __webpack_require__(62) - -}; - - -/***/ }), -/* 871 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Textures - */ - -module.exports = { - - Parsers: __webpack_require__(264), - - FilterMode: __webpack_require__(872), - Frame: __webpack_require__(131), - Texture: __webpack_require__(265), - TextureManager: __webpack_require__(263), - TextureSource: __webpack_require__(266) - -}; - - -/***/ }), -/* 872 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Textures.FilterMode - */ - -var CONST = { - - /** - * CSV Map Type - * - * @name Phaser.Textures.FilterMode.LINEAR - * @type {number} - * @since 3.0.0 - */ - LINEAR: 0, - - /** - * CSV Map Type - * - * @name Phaser.Textures.FilterMode.NEAREST - * @type {number} - * @since 3.0.0 - */ - NEAREST: 1 - -}; - -module.exports = CONST; - - -/***/ }), -/* 873 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Tilemaps - */ - -module.exports = { - - Components: __webpack_require__(96), - Parsers: __webpack_require__(903), - - Formats: __webpack_require__(22), - ImageCollection: __webpack_require__(351), - ParseToTilemap: __webpack_require__(157), - Tile: __webpack_require__(44), - Tilemap: __webpack_require__(355), - TilemapCreator: __webpack_require__(920), - TilemapFactory: __webpack_require__(921), - Tileset: __webpack_require__(100), - - LayerData: __webpack_require__(75), - MapData: __webpack_require__(76), - ObjectLayer: __webpack_require__(353), - - DynamicTilemapLayer: __webpack_require__(356), - StaticTilemapLayer: __webpack_require__(357) - -}; - - -/***/ }), -/* 874 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); -var CalculateFacesWithin = __webpack_require__(34); - -/** - * Copies the tiles in the source rectangular area to a new destination (all specified in tile - * coordinates) within the layer. This copies all tile properties & recalculates collision - * information in the destination region. - * - * @function Phaser.Tilemaps.Components.Copy - * @since 3.0.0 - * - * @param {integer} srcTileX - [description] - * @param {integer} srcTileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {integer} destTileX - [description] - * @param {integer} destTileY - [description] - * @param {integer} destTileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var Copy = function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer) -{ - if (srcTileX < 0) { srcTileX = 0; } - if (srcTileY < 0) { srcTileY = 0; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - - var srcTiles = GetTilesWithin(srcTileX, srcTileY, width, height, null, layer); - - var offsetX = destTileX - srcTileX; - var offsetY = destTileY - srcTileY; - - for (var i = 0; i < srcTiles.length; i++) - { - var tileX = srcTiles[i].x + offsetX; - var tileY = srcTiles[i].y + offsetY; - if (tileX >= 0 && tileX < layer.width && tileY >= 0 && tileY < layer.height) - { - if (layer.data[tileY][tileX]) - { - layer.data[tileY][tileX].copy(srcTiles[i]); - } - } - } - - if (recalculateFaces) - { - // Recalculate the faces within the destination area and neighboring tiles - CalculateFacesWithin(destTileX - 1, destTileY - 1, width + 2, height + 2, layer); - } -}; - -module.exports = Copy; - - -/***/ }), -/* 875 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var TileToWorldX = __webpack_require__(98); -var TileToWorldY = __webpack_require__(99); -var GetTilesWithin = __webpack_require__(15); -var ReplaceByIndex = __webpack_require__(344); - -/** - * Creates a Sprite for every object matching the given tile indexes in the layer. You can - * optionally specify if each tile will be replaced with a new tile after the Sprite has been - * created. This is useful if you want to lay down special tiles in a level that are converted to - * Sprites, but want to replace the tile itself with a floor tile or similar once converted. - * - * @function Phaser.Tilemaps.Components.CreateFromTiles - * @since 3.0.0 - * - * @param {integer|array} indexes - The tile index, or array of indexes, to create Sprites from. - * @param {integer|array} replacements - The tile index, or array of indexes, to change a converted - * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a - * one-to-one mapping with the indexes array. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). - * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. - */ -var CreateFromTiles = function (indexes, replacements, spriteConfig, scene, camera, layer) -{ - if (spriteConfig === undefined) { spriteConfig = {}; } - - if (!Array.isArray(indexes)) { indexes = [ indexes ]; } - - var tilemapLayer = layer.tilemapLayer; - if (scene === undefined) { scene = tilemapLayer.scene; } - if (camera === undefined) { camera = scene.cameras.main; } - - var tiles = GetTilesWithin(0, 0, layer.width, layer.height, null, layer); - var sprites = []; - var i; - - for (i = 0; i < tiles.length; i++) - { - var tile = tiles[i]; - - if (indexes.indexOf(tile.index) !== -1) - { - spriteConfig.x = TileToWorldX(tile.x, camera, layer); - spriteConfig.y = TileToWorldY(tile.y, camera, layer); - - var sprite = scene.make.sprite(spriteConfig); - sprites.push(sprite); - } - } - - if (typeof replacements === 'number') - { - // Assume 1 replacement for all types of tile given - for (i = 0; i < indexes.length; i++) - { - ReplaceByIndex(indexes[i], replacements, 0, 0, layer.width, layer.height, layer); - } - } - else if (Array.isArray(replacements)) - { - // Assume 1 to 1 mapping with indexes array - for (i = 0; i < indexes.length; i++) - { - ReplaceByIndex(indexes[i], replacements[i], 0, 0, layer.width, layer.height, layer); - } - } - - return sprites; -}; - -module.exports = CreateFromTiles; - - -/***/ }), -/* 876 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the tiles in the given layer that are within the camera's viewport. This is used - * internally. - * - * @function Phaser.Tilemaps.Components.CullTiles - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. - * @param {array} [outputArray] - [description] - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ -var CullTiles = function (layer, camera, outputArray) -{ - if (outputArray === undefined) { outputArray = []; } - - outputArray.length = 0; - - var tilemapLayer = layer.tilemapLayer; - var mapData = layer.data; - var mapWidth = layer.width; - var mapHeight = layer.height; - var left = (camera.scrollX * tilemapLayer.scrollFactorX) - tilemapLayer.x; - var top = (camera.scrollY * tilemapLayer.scrollFactorY) - tilemapLayer.y; - var sx = tilemapLayer.scaleX; - var sy = tilemapLayer.scaleY; - var tileWidth = layer.tileWidth * sx; - var tileHeight = layer.tileHeight * sy; - - for (var row = 0; row < mapHeight; ++row) - { - for (var col = 0; col < mapWidth; ++col) - { - var tile = mapData[row][col]; - - if (tile === null || tile.index === -1) { continue; } - - var tileX = tile.pixelX * sx - left; - var tileY = tile.pixelY * sy - top; - var cullW = camera.width + tileWidth; - var cullH = camera.height + tileHeight; - - if (tile.visible && - tileX > -tileWidth && tileY > -tileHeight && - tileX < cullW && tileY < cullH) - { - outputArray.push(tile); - } - } - } - - return outputArray; -}; - -module.exports = CullTiles; - - -/***/ }), -/* 877 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); -var CalculateFacesWithin = __webpack_require__(34); -var SetTileCollision = __webpack_require__(43); - -/** - * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the - * specified index. Tiles will be set to collide if the given index is a colliding index. - * Collision information in the region will be recalculated. - * - * @function Phaser.Tilemaps.Components.Fill - * @since 3.0.0 - * - * @param {integer} index - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var Fill = function (index, tileX, tileY, width, height, recalculateFaces, layer) -{ - if (recalculateFaces === undefined) { recalculateFaces = true; } - - var doesIndexCollide = (layer.collideIndexes.indexOf(index) !== -1); - - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - for (var i = 0; i < tiles.length; i++) - { - tiles[i].index = index; - - SetTileCollision(tiles[i], doesIndexCollide); - } - - if (recalculateFaces) - { - // Recalculate the faces within the area and neighboring tiles - CalculateFacesWithin(tileX - 1, tileY - 1, width + 2, height + 2, layer); - } -}; - -module.exports = Fill; - - -/***/ }), -/* 878 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); - -/** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns - * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. - * - * @function Phaser.Tilemaps.Components.FilterTiles - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. The callback should return true for tiles that pass the - * filter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile[]} The filtered array of Tiles. - */ -var FilterTiles = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); - return tiles.filter(callback, context); -}; - -module.exports = FilterTiles; - - - -/***/ }), -/* 879 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Searches the entire map layer for the first tile matching the given index, then returns that Tile - * object. If no match is found, it returns null. The search starts from the top-left tile and - * continues horizontally until it hits the end of the row, then it drops down to the next column. - * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to - * the top-left. - * - * @function Phaser.Tilemaps.Components.FindByIndex - * @since 3.0.0 - * - * @param {integer} index - The tile index value to search for. - * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. - * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the - * bottom-right. Otherwise it scans from the top-left. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile|null} The first (or n skipped) tile with the matching index. - */ -var FindByIndex = function (findIndex, skip, reverse, layer) -{ - if (skip === undefined) { skip = 0; } - if (reverse === undefined) { reverse = false; } - - var count = 0; - var tx; - var ty; - var tile; - - if (reverse) - { - for (ty = layer.height - 1; ty >= 0; ty--) - { - for (tx = layer.width - 1; tx >= 0; tx--) - { - tile = layer.data[ty][tx]; - if (tile && tile.index === findIndex) - { - if (count === skip) - { - return tile; - } - else - { - count += 1; - } - } - } - } - } - else - { - for (ty = 0; ty < layer.height; ty++) - { - for (tx = 0; tx < layer.width; tx++) - { - tile = layer.data[ty][tx]; - if (tile && tile.index === findIndex) - { - if (count === skip) - { - return tile; - } - else - { - count += 1; - } - } - } - } - } - - return null; -}; - -module.exports = FindByIndex; - - -/***/ }), -/* 880 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); - -/** - * Find the first tile in the given rectangular area (in tile coordinates) of the layer that - * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns - * true. Similar to Array.prototype.find in vanilla JS. - * - * @function Phaser.Tilemaps.Components.FindTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile|null} A Tile that matches the search, or null if no Tile found - */ -var FindTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); - return tiles.find(callback, context) || null; -}; - -module.exports = FindTile; - - -/***/ }), -/* 881 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); - -/** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * callback. Similar to Array.prototype.forEach in vanilla JS. - * - * @function Phaser.Tilemaps.Components.ForEachTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var ForEachTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); - tiles.forEach(callback, context); -}; - -module.exports = ForEachTile; - - -/***/ }), -/* 882 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTileAt = __webpack_require__(97); -var WorldToTileX = __webpack_require__(39); -var WorldToTileY = __webpack_require__(40); - -/** - * Gets a tile at the given world coordinates from the given layer. - * - * @function Phaser.Tilemaps.Components.GetTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - X position to get the tile from (given in pixels) - * @param {number} worldY - Y position to get the tile from (given in pixels) - * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates - * were invalid. - */ -var GetTileAtWorldXY = function (worldX, worldY, nonNull, camera, layer) -{ - var tileX = WorldToTileX(worldX, true, camera, layer); - var tileY = WorldToTileY(worldY, true, camera, layer); - - return GetTileAt(tileX, tileY, nonNull, layer); -}; - -module.exports = GetTileAtWorldXY; - - -/***/ }), -/* 883 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Geom = __webpack_require__(294); -var GetTilesWithin = __webpack_require__(15); -var Intersects = __webpack_require__(295); -var NOOP = __webpack_require__(3); -var TileToWorldX = __webpack_require__(98); -var TileToWorldY = __webpack_require__(99); -var WorldToTileX = __webpack_require__(39); -var WorldToTileY = __webpack_require__(40); - -var TriangleToRectangle = function (triangle, rect) -{ - return Intersects.RectangleToTriangle(rect, triangle); -}; - -// Note: Could possibly be optimized by copying the shape and shifting it into tilemapLayer -// coordinates instead of shifting the tiles. - -/** - * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, - * Line, Rectangle or Triangle. The shape should be in world coordinates. - * - * @function Phaser.Tilemaps.Components.GetTilesWithinShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle} shape - A shape in world (pixel) coordinates - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. - */ -var GetTilesWithinShape = function (shape, filteringOptions, camera, layer) -{ - if (shape === undefined) { return []; } - - // intersectTest is a function with parameters: shape, rect - var intersectTest = NOOP; - if (shape instanceof Geom.Circle) { intersectTest = Intersects.CircleToRectangle; } - else if (shape instanceof Geom.Rectangle) { intersectTest = Intersects.RectangleToRectangle; } - else if (shape instanceof Geom.Triangle) { intersectTest = TriangleToRectangle; } - else if (shape instanceof Geom.Line) { intersectTest = Intersects.LineToRectangle; } - - // Top left corner of the shapes's bounding box, rounded down to include partial tiles - var xStart = WorldToTileX(shape.left, true, camera, layer); - var yStart = WorldToTileY(shape.top, true, camera, layer); - - // Bottom right corner of the shapes's bounding box, rounded up to include partial tiles - var xEnd = Math.ceil(WorldToTileX(shape.right, false, camera, layer)); - var yEnd = Math.ceil(WorldToTileY(shape.bottom, false, camera, layer)); - - // Tiles within bounding rectangle of shape. Bounds are forced to be at least 1 x 1 tile in size - // to grab tiles for shapes that don't have a height or width (e.g. a horizontal line). - var width = Math.max(xEnd - xStart, 1); - var height = Math.max(yEnd - yStart, 1); - var tiles = GetTilesWithin(xStart, yStart, width, height, filteringOptions, layer); - - var tileWidth = layer.tileWidth; - var tileHeight = layer.tileHeight; - if (layer.tilemapLayer) - { - tileWidth *= layer.tilemapLayer.scaleX; - tileHeight *= layer.tilemapLayer.scaleY; - } - - var results = []; - var tileRect = new Geom.Rectangle(0, 0, tileWidth, tileHeight); - for (var i = 0; i < tiles.length; i++) - { - var tile = tiles[i]; - tileRect.x = TileToWorldX(tile.x, camera, layer); - tileRect.y = TileToWorldY(tile.y, camera, layer); - if (intersectTest(shape, tileRect)) - { - results.push(tile); - } - } - - return results; -}; - -module.exports = GetTilesWithinShape; - - -/***/ }), -/* 884 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); -var WorldToTileX = __webpack_require__(39); -var WorldToTileY = __webpack_require__(40); - -/** - * Gets the tiles in the given rectangular area (in world coordinates) of the layer. - * - * @function Phaser.Tilemaps.Components.GetTilesWithinWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. - */ -var GetTilesWithinWorldXY = function (worldX, worldY, width, height, filteringOptions, camera, layer) -{ - // Top left corner of the rect, rounded down to include partial tiles - var xStart = WorldToTileX(worldX, true, camera, layer); - var yStart = WorldToTileY(worldY, true, camera, layer); - - // Bottom right corner of the rect, rounded up to include partial tiles - var xEnd = Math.ceil(WorldToTileX(worldX + width, false, camera, layer)); - var yEnd = Math.ceil(WorldToTileY(worldY + height, false, camera, layer)); - - return GetTilesWithin(xStart, yStart, xEnd - xStart, yEnd - yStart, filteringOptions, layer); -}; - -module.exports = GetTilesWithinWorldXY; - - -/***/ }), -/* 885 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var HasTileAt = __webpack_require__(345); -var WorldToTileX = __webpack_require__(39); -var WorldToTileY = __webpack_require__(40); - -/** - * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @function Phaser.Tilemaps.Components.HasTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {boolean} - */ -var HasTileAtWorldXY = function (worldX, worldY, camera, layer) -{ - var tileX = WorldToTileX(worldX, true, camera, layer); - var tileY = WorldToTileY(worldY, true, camera, layer); - - return HasTileAt(tileX, tileY, layer); -}; - -module.exports = HasTileAtWorldXY; - - -/***/ }), -/* 886 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var PutTileAt = __webpack_require__(154); -var WorldToTileX = __webpack_require__(39); -var WorldToTileY = __webpack_require__(40); - -/** - * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either - * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the - * specified location. If you pass in an index, only the index at the specified location will be - * changed. Collision information will be recalculated at the specified location. - * - * @function Phaser.Tilemaps.Components.PutTileAtWorldXY - * @since 3.0.0 - * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {integer} worldX - [description] - * @param {integer} worldY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map. - */ -var PutTileAtWorldXY = function (tile, worldX, worldY, recalculateFaces, camera, layer) -{ - var tileX = WorldToTileX(worldX, true, camera, layer); - var tileY = WorldToTileY(worldY, true, camera, layer); - return PutTileAt(tile, tileX, tileY, recalculateFaces, layer); -}; - -module.exports = PutTileAtWorldXY; - - -/***/ }), -/* 887 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CalculateFacesWithin = __webpack_require__(34); -var PutTileAt = __webpack_require__(154); - -/** - * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified - * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, - * all attributes will be copied over to the specified location. If you pass in an index, only the - * index at the specified location will be changed. Collision information will be recalculated - * within the region tiles were changed. - * - * @function Phaser.Tilemaps.Components.PutTilesAt - * @since 3.0.0 - * - * @param {integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][]} tile - A row (array) or grid (2D array) of Tiles - * or tile indexes to place. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var PutTilesAt = function (tilesArray, tileX, tileY, recalculateFaces, layer) -{ - if (!Array.isArray(tilesArray)) { return null; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - - // Force the input array to be a 2D array - if (!Array.isArray(tilesArray[0])) - { - tilesArray = [ tilesArray ]; - } - - var height = tilesArray.length; - var width = tilesArray[0].length; - - for (var ty = 0; ty < height; ty++) - { - for (var tx = 0; tx < width; tx++) - { - var tile = tilesArray[ty][tx]; - PutTileAt(tile, tileX + tx, tileY + ty, false, layer); - } - } - - if (recalculateFaces) - { - // Recalculate the faces within the destination area and neighboring tiles - CalculateFacesWithin(tileX - 1, tileY - 1, width + 2, height + 2, layer); - } -}; - -module.exports = PutTilesAt; - - - -/***/ }), -/* 888 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); -var GetRandomElement = __webpack_require__(140); - -/** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then - * those will be used for randomly assigning new tile indexes. If an array is not provided, the - * indexes found within the region (excluding -1) will be used for randomly assigning new tile - * indexes. This method only modifies tile indexes and does not change collision information. - * - * @function Phaser.Tilemaps.Components.Randomize - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var Randomize = function (tileX, tileY, width, height, indexes, layer) -{ - var i; - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - - // If no indicies are given, then find all the unique indexes within the specified region - if (indexes === undefined) - { - indexes = []; - for (i = 0; i < tiles.length; i++) - { - if (indexes.indexOf(tiles[i].index) === -1) - { - indexes.push(tiles[i].index); - } - } - } - - for (i = 0; i < tiles.length; i++) - { - tiles[i].index = GetRandomElement(indexes); - } -}; - -module.exports = Randomize; - - -/***/ }), -/* 889 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RemoveTileAt = __webpack_require__(346); -var WorldToTileX = __webpack_require__(39); -var WorldToTileY = __webpack_require__(40); - -/** - * Removes the tile at the given world coordinates in the specified layer and updates the layer's - * collision information. - * - * @function Phaser.Tilemaps.Components.RemoveTileAtWorldXY - * @since 3.0.0 - * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The Tile object that was removed. - */ -var RemoveTileAtWorldXY = function (worldX, worldY, replaceWithNull, recalculateFaces, camera, layer) -{ - var tileX = WorldToTileX(worldX, true, camera, layer); - var tileY = WorldToTileY(worldY, true, camera, layer); - return RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, layer); -}; - -module.exports = RemoveTileAtWorldXY; - - -/***/ }), -/* 890 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); -var Color = __webpack_require__(227); - -/** - * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to - * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles - * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation - * wherever you want on the screen. - * - * @function Phaser.Tilemaps.Components.RenderDebug - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. - * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. - * @param {Color|null} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at - * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. - * @param {Color|null} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled - * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. - * @param {Color|null} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting - * tile faces. If set to null, interesting tile faces will not be drawn. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var RenderDebug = function (graphics, styleConfig, layer) -{ - if (styleConfig === undefined) { styleConfig = {}; } - - // Default colors without needlessly creating Color objects - var tileColor = styleConfig.tileColor !== undefined - ? styleConfig.tileColor - : new Color(105, 210, 231, 150); - var collidingTileColor = styleConfig.collidingTileColor !== undefined - ? styleConfig.collidingTileColor - : new Color(243, 134, 48, 200); - var faceColor = styleConfig.faceColor !== undefined - ? styleConfig.faceColor - : new Color(40, 39, 37, 150); - - var tiles = GetTilesWithin(0, 0, layer.width, layer.height, null, layer); - - for (var i = 0; i < tiles.length; i++) - { - var tile = tiles[i]; - - var tw = tile.width; - var th = tile.height; - var x = tile.pixelX; - var y = tile.pixelY; - - var color = tile.collides ? collidingTileColor : tileColor; - if (color !== null) - { - graphics.fillStyle(color.color, color.alpha / 255); - graphics.fillRect(x, y, tw, th); - } - - // Inset the face line to prevent neighboring tile's lines from overlapping - x += 1; - y += 1; - tw -= 2; - th -= 2; - - if (faceColor !== null) - { - graphics.lineStyle(1, faceColor.color, faceColor.alpha / 255); - if (tile.faceTop) { graphics.lineBetween(x, y, x + tw, y); } - if (tile.faceRight) { graphics.lineBetween(x + tw, y, x + tw, y + th); } - if (tile.faceBottom) { graphics.lineBetween(x, y + th, x + tw, y + th); } - if (tile.faceLeft) { graphics.lineBetween(x, y, x, y + th); } - } - } -}; - -module.exports = RenderDebug; - - -/***/ }), -/* 891 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SetTileCollision = __webpack_require__(43); -var CalculateFacesWithin = __webpack_require__(34); -var SetLayerCollisionIndex = __webpack_require__(155); - -/** - * Sets collision on the given tile or tiles within a layer by index. You can pass in either a - * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if - * collision will be enabled (true) or disabled (false). - * - * @function Phaser.Tilemaps.Components.SetCollision - * @since 3.0.0 - * - * @param {integer|array} indexes - Either a single tile index, or an array of tile indexes. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetCollision = function (indexes, collides, recalculateFaces, layer) -{ - if (collides === undefined) { collides = true; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - if (!Array.isArray(indexes)) { indexes = [ indexes ]; } - - // Update the array of colliding indexes - for (var i = 0; i < indexes.length; i++) - { - SetLayerCollisionIndex(indexes[i], collides, layer); - } - - // Update the tiles - for (var ty = 0; ty < layer.height; ty++) - { - for (var tx = 0; tx < layer.width; tx++) - { - var tile = layer.data[ty][tx]; - - if (tile && indexes.indexOf(tile.index) !== -1) - { - SetTileCollision(tile, collides); - } - } - } - - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } -}; - -module.exports = SetCollision; - - -/***/ }), -/* 892 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SetTileCollision = __webpack_require__(43); -var CalculateFacesWithin = __webpack_require__(34); -var SetLayerCollisionIndex = __webpack_require__(155); - -/** - * Sets collision on a range of tiles in a layer whose index is between the specified `start` and - * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set - * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be - * enabled (true) or disabled (false). - * - * @function Phaser.Tilemaps.Components.SetCollisionBetween - * @since 3.0.0 - * - * @param {integer} start - The first index of the tile to be set for collision. - * @param {integer} stop - The last index of the tile to be set for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetCollisionBetween = function (start, stop, collides, recalculateFaces, layer) -{ - if (collides === undefined) { collides = true; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - - if (start > stop) { return; } - - // Update the array of colliding indexes - for (var index = start; index <= stop; index++) - { - SetLayerCollisionIndex(index, collides, layer); - } - - // Update the tiles - for (var ty = 0; ty < layer.height; ty++) - { - for (var tx = 0; tx < layer.width; tx++) - { - var tile = layer.data[ty][tx]; - if (tile) - { - if (tile.index >= start && tile.index <= stop) - { - SetTileCollision(tile, collides); - } - } - } - } - - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } -}; - -module.exports = SetCollisionBetween; - - -/***/ }), -/* 893 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SetTileCollision = __webpack_require__(43); -var CalculateFacesWithin = __webpack_require__(34); -var SetLayerCollisionIndex = __webpack_require__(155); - -/** - * Sets collision on all tiles in the given layer, except for tiles that have an index specified in - * the given array. The `collides` parameter controls if collision will be enabled (true) or - * disabled (false). - * - * @function Phaser.Tilemaps.Components.SetCollisionByExclusion - * @since 3.0.0 - * - * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetCollisionByExclusion = function (indexes, collides, recalculateFaces, layer) -{ - if (collides === undefined) { collides = true; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - if (!Array.isArray(indexes)) { indexes = [ indexes ]; } - - // Note: this only updates layer.collideIndexes for tile indexes found currently in the layer - for (var ty = 0; ty < layer.height; ty++) - { - for (var tx = 0; tx < layer.width; tx++) - { - var tile = layer.data[ty][tx]; - if (tile && indexes.indexOf(tile.index) === -1) - { - SetTileCollision(tile, collides); - SetLayerCollisionIndex(tile.index, collides, layer); - } - } - } - - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } -}; - -module.exports = SetCollisionByExclusion; - - -/***/ }), -/* 894 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SetTileCollision = __webpack_require__(43); -var CalculateFacesWithin = __webpack_require__(34); -var HasValue = __webpack_require__(72); - -/** - * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property - * that matches the given properties object, its collision flag will be set. The `collides` - * parameter controls if collision will be enabled (true) or disabled (false). Passing in - * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that - * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can - * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a - * "types" property that matches any of those values, its collision flag will be updated. - * - * @function Phaser.Tilemaps.Components.SetCollisionByProperty - * @since 3.0.0 - * - * @param {object} properties - An object with tile properties and corresponding values that should - * be checked. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetCollisionByProperty = function (properties, collides, recalculateFaces, layer) -{ - if (collides === undefined) { collides = true; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - - for (var ty = 0; ty < layer.height; ty++) - { - for (var tx = 0; tx < layer.width; tx++) - { - var tile = layer.data[ty][tx]; - - if (!tile) { continue; } - - for (var property in properties) - { - if (!HasValue(tile.properties, property)) { continue; } - - var values = properties[property]; - if (!Array.isArray(values)) - { - values = [ values ]; - } - - for (var i = 0; i < values.length; i++) - { - if (tile.properties[property] === values[i]) - { - SetTileCollision(tile, collides); - } - } - } - } - } - - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } -}; - -module.exports = SetCollisionByProperty; - - -/***/ }), -/* 895 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SetTileCollision = __webpack_require__(43); -var CalculateFacesWithin = __webpack_require__(34); - -/** - * Sets collision on the tiles within a layer by checking each tile's collision group data - * (typically defined in Tiled within the tileset collision editor). If any objects are found within - * a tile's collision group, the tile's colliding information will be set. The `collides` parameter - * controls if collision will be enabled (true) or disabled (false). - * - * @function Phaser.Tilemaps.Components.SetCollisionFromCollisionGroup - * @since 3.0.0 - * - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetCollisionFromCollisionGroup = function (collides, recalculateFaces, layer) -{ - if (collides === undefined) { collides = true; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - - for (var ty = 0; ty < layer.height; ty++) - { - for (var tx = 0; tx < layer.width; tx++) - { - var tile = layer.data[ty][tx]; - - if (!tile) { continue; } - - var collisionGroup = tile.getCollisionGroup(); - - // It's possible in Tiled to have a collision group without any shapes, e.g. create a - // shape and then delete the shape. - if (collisionGroup && collisionGroup.objects && collisionGroup.objects.length > 0) - { - SetTileCollision(tile, collides); - } - } - } - - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } -}; - -module.exports = SetCollisionFromCollisionGroup; - - -/***/ }), -/* 896 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Sets a global collision callback for the given tile index within the layer. This will affect all - * tiles on this layer that have the same index. If a callback is already set for the tile index it - * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile - * at a specific location on the map then see setTileLocationCallback. - * - * @function Phaser.Tilemaps.Components.SetTileIndexCallback - * @since 3.0.0 - * - * @param {integer|array} indexes - Either a single tile index, or an array of tile indexes to have a - * collision callback set for. - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetTileIndexCallback = function (indexes, callback, callbackContext, layer) -{ - if (typeof indexes === 'number') - { - layer.callbacks[indexes] = (callback !== null) - ? { callback: callback, callbackContext: callbackContext } - : undefined; - } - else - { - for (var i = 0, len = indexes.length; i < len; i++) - { - layer.callbacks[indexes[i]] = (callback !== null) - ? { callback: callback, callbackContext: callbackContext } - : undefined; - } - } -}; - -module.exports = SetTileIndexCallback; - - -/***/ }), -/* 897 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); - -/** - * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. - * If a callback is already set for the tile index it will be replaced. Set the callback to null to - * remove it. - * - * @function Phaser.Tilemaps.Components.SetTileLocationCallback - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetTileLocationCallback = function (tileX, tileY, width, height, callback, callbackContext, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - - for (var i = 0; i < tiles.length; i++) - { - tiles[i].setCollisionCallback(callback, callbackContext); - } - -}; - -module.exports = SetTileLocationCallback; - - -/***/ }), -/* 898 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); -var ShuffleArray = __webpack_require__(80); - -/** - * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given - * layer. It will only randomize the tiles in that area, so if they're all the same nothing will - * appear to have changed! This method only modifies tile indexes and does not change collision - * information. - * - * @function Phaser.Tilemaps.Components.Shuffle - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var Shuffle = function (tileX, tileY, width, height, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - - var indexes = tiles.map(function (tile) { return tile.index; }); - ShuffleArray(indexes); - - for (var i = 0; i < tiles.length; i++) - { - tiles[i].index = indexes[i]; - } -}; - -module.exports = Shuffle; - - -/***/ }), -/* 899 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); - -/** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision - * information. - * - * @function Phaser.Tilemaps.Components.SwapByIndex - * @since 3.0.0 - * - * @param {integer} tileA - First tile index. - * @param {integer} tileB - Second tile index. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SwapByIndex = function (indexA, indexB, tileX, tileY, width, height, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - for (var i = 0; i < tiles.length; i++) - { - if (tiles[i]) - { - if (tiles[i].index === indexA) - { - tiles[i].index = indexB; - } - else if (tiles[i].index === indexB) - { - tiles[i].index = indexA; - } - } - } -}; - -module.exports = SwapByIndex; - - -/***/ }), -/* 900 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var TileToWorldX = __webpack_require__(98); -var TileToWorldY = __webpack_require__(99); -var Vector2 = __webpack_require__(6); - -/** - * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layer's position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @function Phaser.Tilemaps.Components.TileToWorldXY - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Math.Vector2} The XY location in world coordinates. - */ -var TileToWorldXY = function (tileX, tileY, point, camera, layer) -{ - if (point === undefined) { point = new Vector2(0, 0); } - - point.x = TileToWorldX(tileX, camera, layer); - point.y = TileToWorldY(tileY, camera, layer); - - return point; -}; - -module.exports = TileToWorldXY; - - -/***/ }), -/* 901 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); - -/** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will recieve a new index. New indexes are drawn from the given - * weightedIndexes array. An example weighted array: - * - * [ - * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 - * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 - * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 - * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 - * ] - * - * The probability of any index being choose is (the index's weight) / (sum of all weights). This - * method only modifies tile indexes and does not change collision information. - * - * @function Phaser.Tilemaps.Components.WeightedRandomize - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during - * randomization. They should be in the form: { index: 0, weight: 4 } or - * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var WeightedRandomize = function (tileX, tileY, width, height, weightedIndexes, layer) -{ - if (weightedIndexes === undefined) { return; } - - var i; - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - - var weightTotal = 0; - for (i = 0; i < weightedIndexes.length; i++) - { - weightTotal += weightedIndexes[i].weight; - } - - if (weightTotal <= 0) { return; } - - for (i = 0; i < tiles.length; i++) - { - var rand = Math.random() * weightTotal; - var sum = 0; - var randomIndex = -1; - for (var j = 0; j < weightedIndexes.length; j++) - { - sum += weightedIndexes[j].weight; - if (rand <= sum) - { - var chosen = weightedIndexes[j].index; - randomIndex = Array.isArray(chosen) - ? chosen[Math.floor(Math.random() * chosen.length)] - : chosen; - break; - } - } - - tiles[i].index = randomIndex; - } -}; - -module.exports = WeightedRandomize; - - -/***/ }), -/* 902 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var WorldToTileX = __webpack_require__(39); -var WorldToTileY = __webpack_require__(40); -var Vector2 = __webpack_require__(6); - -/** - * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the - * layer's position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @function Phaser.Tilemaps.Components.WorldToTileXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Math.Vector2} The XY location in tile units. - */ -var WorldToTileXY = function (worldX, worldY, snapToFloor, point, camera, layer) -{ - if (point === undefined) { point = new Vector2(0, 0); } - - point.x = WorldToTileX(worldX, snapToFloor, camera, layer); - point.y = WorldToTileY(worldY, snapToFloor, camera, layer); - - return point; -}; - -module.exports = WorldToTileXY; - - -/***/ }), -/* 903 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Tilemaps.Parsers - */ - -module.exports = { - - Parse: __webpack_require__(347), - Parse2DArray: __webpack_require__(156), - ParseCSV: __webpack_require__(348), - - Impact: __webpack_require__(354), - Tiled: __webpack_require__(349) - -}; - - -/***/ }), -/* 904 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Base64Decode = __webpack_require__(905); -var GetFastValue = __webpack_require__(2); -var LayerData = __webpack_require__(75); -var ParseGID = __webpack_require__(350); -var Tile = __webpack_require__(44); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseTileLayers - * @since 3.0.0 - * - * @param {object} json - [description] - * @param {boolean} insertNull - [description] - * - * @return {array} [description] - */ -var ParseTileLayers = function (json, insertNull) -{ - var tileLayers = []; - - for (var i = 0; i < json.layers.length; i++) - { - if (json.layers[i].type !== 'tilelayer') - { - continue; - } - - var curl = json.layers[i]; - - // Base64 decode data if necessary. NOTE: uncompressed base64 only. - if (curl.compression) - { - console.warn( - 'TilemapParser.parseTiledJSON - Layer compression is unsupported, skipping layer \'' - + curl.name + '\'' - ); - continue; - } - else if (curl.encoding && curl.encoding === 'base64') - { - curl.data = Base64Decode(curl.data); - delete curl.encoding; // Allow the same map to be parsed multiple times - } - - var layerData = new LayerData({ - name: curl.name, - x: GetFastValue(curl, 'offsetx', 0) + curl.x, - y: GetFastValue(curl, 'offsety', 0) + curl.y, - width: curl.width, - height: curl.height, - tileWidth: json.tilewidth, - tileHeight: json.tileheight, - alpha: curl.opacity, - visible: curl.visible, - properties: GetFastValue(curl, 'properties', {}) - }); - - var x = 0; - var row = []; - var output = []; - - // Loop through the data field in the JSON. - - // This is an array containing the tile indexes, one after the other. -1 = no tile, - // everything else = the tile index (starting at 1 for Tiled, 0 for CSV) If the map - // contains multiple tilesets then the indexes are relative to that which the set starts - // from. Need to set which tileset in the cache = which tileset in the JSON, if you do this - // manually it means you can use the same map data but a new tileset. - - for (var t = 0, len = curl.data.length; t < len; t++) - { - var gidInfo = ParseGID(curl.data[t]); - - // index, x, y, width, height - if (gidInfo.gid > 0) - { - var tile = new Tile(layerData, gidInfo.gid, x, output.length, json.tilewidth, - json.tileheight); - - // Turning Tiled's FlippedHorizontal, FlippedVertical and FlippedAntiDiagonal - // propeties into flipX, flipY and rotation - tile.rotation = gidInfo.rotation; - tile.flipX = gidInfo.flipped; - - row.push(tile); - } - else - { - var blankTile = insertNull - ? null - : new Tile(layerData, -1, x, output.length, json.tilewidth, json.tileheight); - row.push(blankTile); - } - - x++; - - if (x === curl.width) - { - output.push(row); - x = 0; - row = []; - } - } - - layerData.data = output; - - tileLayers.push(layerData); - } - - return tileLayers; -}; - -module.exports = ParseTileLayers; - - -/***/ }), -/* 905 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Tiled.Base64Decode - * @since 3.0.0 - * - * @param {object} data - [description] - * - * @return {array} [description] - */ -var Base64Decode = function (data) -{ - var binaryString = window.atob(data); - var len = binaryString.length; - var bytes = new Array(len); - - // Interpret binaryString as an array of bytes representing little-endian encoded uint32 values. - for (var i = 0; i < len; i += 4) - { - bytes[i / 4] = ( - binaryString.charCodeAt(i) | - binaryString.charCodeAt(i + 1) << 8 | - binaryString.charCodeAt(i + 2) << 16 | - binaryString.charCodeAt(i + 3) << 24 - ) >>> 0; - } - - return bytes; -}; - -module.exports = Base64Decode; - - -/***/ }), -/* 906 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetFastValue = __webpack_require__(2); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseImageLayers - * @since 3.0.0 - * - * @param {object} json - [description] - * - * @return {array} [description] - */ -var ParseImageLayers = function (json) -{ - var images = []; - - for (var i = 0; i < json.layers.length; i++) - { - if (json.layers[i].type !== 'imagelayer') - { - continue; - } - - var curi = json.layers[i]; - - images.push({ - name: curi.name, - image: curi.image, - x: GetFastValue(curi, 'offsetx', 0) + curi.x, - y: GetFastValue(curi, 'offsety', 0) + curi.y, - alpha: curi.opacity, - visible: curi.visible, - properties: GetFastValue(curi, 'properties', {}) - }); - } - - return images; -}; - -module.exports = ParseImageLayers; - - -/***/ }), -/* 907 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Tileset = __webpack_require__(100); -var ImageCollection = __webpack_require__(351); -var ParseObject = __webpack_require__(352); - -/** - * Tilesets & Image Collections - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseTilesets - * @since 3.0.0 - * - * @param {object} json - [description] - * - * @return {object} [description] - */ -var ParseTilesets = function (json) -{ - var tilesets = []; - var imageCollections = []; - var lastSet = null; - var stringID; - - for (var i = 0; i < json.tilesets.length; i++) - { - // name, firstgid, width, height, margin, spacing, properties - var set = json.tilesets[i]; - - if (set.source) - { - console.warn('Phaser can\'t load external tilesets. Use the Embed Tileset button and then export the map again.'); - } - else if (set.image) - { - var newSet = new Tileset(set.name, set.firstgid, set.tilewidth, set.tileheight, set.margin, set.spacing); - - // Properties stored per-tile in object with string indexes starting at "0" - if (set.tileproperties) - { - newSet.tileProperties = set.tileproperties; - } - - // Object & terrain shapes stored per-tile in object with string indexes starting at "0" - if (set.tiles) - { - newSet.tileData = set.tiles; - - // Parse the objects into Phaser format to match handling of other Tiled objects - for (stringID in newSet.tileData) - { - var objectGroup = newSet.tileData[stringID].objectgroup; - if (objectGroup && objectGroup.objects) - { - var parsedObjects = objectGroup.objects.map( - function (obj) { return ParseObject(obj); } - ); - newSet.tileData[stringID].objectgroup.objects = parsedObjects; - } - } - } - - // For a normal sliced tileset the row/count/size information is computed when updated. - // This is done (again) after the image is set. - newSet.updateTileData(set.imagewidth, set.imageheight); - - tilesets.push(newSet); - } - else - { - var newCollection = new ImageCollection(set.name, set.firstgid, set.tilewidth, - set.tileheight, set.margin, set.spacing, set.properties); - - for (stringID in set.tiles) - { - var image = set.tiles[stringID].image; - var gid = set.firstgid + parseInt(stringID, 10); - newCollection.addImage(gid, image); - } - - imageCollections.push(newCollection); - } - - // We've got a new Tileset, so set the lastgid into the previous one - if (lastSet) - { - lastSet.lastgid = set.firstgid - 1; - } - - lastSet = set; - } - - return { tilesets: tilesets, imageCollections: imageCollections }; -}; - -module.exports = ParseTilesets; - - -/***/ }), -/* 908 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var HasValue = __webpack_require__(72); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Tiled.Pick - * @since 3.0.0 - * - * @param {object} object - [description] - * @param {array} keys - [description] - * - * @return {object} [description] - */ -var Pick = function (object, keys) -{ - var obj = {}; - - for (var i = 0; i < keys.length; i++) - { - var key = keys[i]; - - if (HasValue(object, key)) - { - obj[key] = object[key]; - } - } - - return obj; -}; - -module.exports = Pick; - - -/***/ }), -/* 909 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetFastValue = __webpack_require__(2); -var ParseObject = __webpack_require__(352); -var ObjectLayer = __webpack_require__(353); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseObjectLayers - * @since 3.0.0 - * - * @param {object} json - [description] - * - * @return {array} [description] - */ -var ParseObjectLayers = function (json) -{ - var objectLayers = []; - - for (var i = 0; i < json.layers.length; i++) - { - if (json.layers[i].type !== 'objectgroup') - { - continue; - } - - var curo = json.layers[i]; - var offsetX = GetFastValue(curo, 'offsetx', 0); - var offsetY = GetFastValue(curo, 'offsety', 0); - var objects = []; - - for (var j = 0; j < curo.objects.length; j++) - { - var parsedObject = ParseObject(curo.objects[j], offsetX, offsetY); - - objects.push(parsedObject); - } - - var objectLayer = new ObjectLayer(curo); - objectLayer.objects = objects; - - objectLayers.push(objectLayer); - } - - return objectLayers; -}; - -module.exports = ParseObjectLayers; - - -/***/ }), -/* 910 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Master list of tiles -> x, y, index in tileset. - * - * @function Phaser.Tilemaps.Parsers.Tiled.BuildTilesetIndex - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.MapData} mapData - [description] - * - * @return {array} [description] - */ -var BuildTilesetIndex = function (mapData) -{ - var tiles = []; - - for (var i = 0; i < mapData.tilesets.length; i++) - { - var set = mapData.tilesets[i]; - - var x = set.tileMargin; - var y = set.tileMargin; - - var count = 0; - var countX = 0; - var countY = 0; - - for (var t = set.firstgid; t < set.firstgid + set.total; t++) - { - // Can add extra properties here as needed - tiles[t] = [ x, y, i ]; - - x += set.tileWidth + set.tileSpacing; - - count++; - - if (count === set.total) - { - break; - } - - countX++; - - if (countX === set.columns) - { - x = set.tileMargin; - y += set.tileHeight + set.tileSpacing; - - countX = 0; - countY++; - - if (countY === set.rows) - { - break; - } - } - } - } - - return tiles; -}; - -module.exports = BuildTilesetIndex; - - -/***/ }), -/* 911 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Extend = __webpack_require__(23); - -/** - * Copy properties from tileset to tiles. - * - * @function Phaser.Tilemaps.Parsers.Tiled.AssignTileProperties - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.MapData} mapData - [description] - */ -var AssignTileProperties = function (mapData) -{ - var layerData; - var tile; - var sid; - var set; - var row; - - // go through each of the map data layers - for (var i = 0; i < mapData.layers.length; i++) - { - layerData = mapData.layers[i]; - - set = null; - - // rows of tiles - for (var j = 0; j < layerData.data.length; j++) - { - row = layerData.data[j]; - - // individual tiles - for (var k = 0; k < row.length; k++) - { - tile = row[k]; - - if (tile === null || tile.index < 0) - { - continue; - } - - // find the relevant tileset - sid = mapData.tiles[tile.index][2]; - set = mapData.tilesets[sid]; - - // Ensure that a tile's size matches its tileset - tile.width = set.tileWidth; - tile.height = set.tileHeight; - - // if that tile type has any properties, add them to the tile object - if (set.tileProperties && set.tileProperties[tile.index - set.firstgid]) - { - tile.properties = Extend( - tile.properties, set.tileProperties[tile.index - set.firstgid] - ); - } - } - } - } -}; - -module.exports = AssignTileProperties; - - -/***/ }), -/* 912 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var LayerData = __webpack_require__(75); -var Tile = __webpack_require__(44); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Impact.ParseTileLayers - * @since 3.0.0 - * - * @param {object} json - [description] - * @param {boolean} insertNull - [description] - * - * @return {array} [description] - */ -var ParseTileLayers = function (json, insertNull) -{ - var tileLayers = []; - - for (var i = 0; i < json.layer.length; i++) - { - var layer = json.layer[i]; - - var layerData = new LayerData({ - name: layer.name, - width: layer.width, - height: layer.height, - tileWidth: layer.tilesize, - tileHeight: layer.tilesize, - visible: layer.visible === 1 - }); - - var row = []; - var tileGrid = []; - - // Loop through the data field in the JSON. This is a 2D array containing the tile indexes, - // one after the other. The indexes are relative to the tileset that contains the tile. - for (var y = 0; y < layer.data.length; y++) - { - for (var x = 0; x < layer.data[y].length; x++) - { - // In Weltmeister, 0 = no tile, but the Tilemap API expects -1 = no tile. - var index = layer.data[y][x] - 1; - - var tile; - - if (index > -1) - { - tile = new Tile(layerData, index, x, y, layer.tilesize, layer.tilesize); - } - else - { - tile = insertNull - ? null - : new Tile(layerData, -1, x, y, layer.tilesize, layer.tilesize); - } - - row.push(tile); - } - - tileGrid.push(row); - row = []; - } - - layerData.data = tileGrid; - - tileLayers.push(layerData); - } - - return tileLayers; -}; - -module.exports = ParseTileLayers; - - -/***/ }), -/* 913 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Tileset = __webpack_require__(100); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Impact.ParseTilesets - * @since 3.0.0 - * - * @param {object} json - [description] - * - * @return {array} [description] - */ -var ParseTilesets = function (json) -{ - var tilesets = []; - var tilesetsNames = []; - - for (var i = 0; i < json.layer.length; i++) - { - var layer = json.layer[i]; - - // A relative filepath to the source image (within Weltmeister) is used for the name - var tilesetName = layer.tilesetName; - - // Only add unique tilesets that have a valid name. Collision layers will have a blank name. - if (tilesetName !== '' && tilesetsNames.indexOf(tilesetName) === -1) - { - tilesetsNames.push(tilesetName); - - // Tiles are stored with an ID relative to the tileset, rather than a globally unique ID - // across all tilesets. Also, tilesets in Weltmeister have no margin or padding. - tilesets.push(new Tileset(tilesetName, 0, layer.tilesize, layer.tilesize, 0, 0)); - } - } - - return tilesets; -}; - -module.exports = ParseTilesets; - - -/***/ }), -/* 914 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(915); -} - -if (true) -{ - renderCanvas = __webpack_require__(916); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 915 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.Tilemaps.DynamicTilemapLayer} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var DynamicTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - src.cull(camera); - - this.pipeline.batchDynamicTilemapLayer(src, camera); -}; - -module.exports = DynamicTilemapLayerWebGLRenderer; - - -/***/ }), -/* 916 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.Tilemaps.DynamicTilemapLayer} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - src.cull(camera); - - var renderTiles = src.culledTiles; - var length = renderTiles.length; - var image = src.tileset.image.getSourceImage(); - var tileset = this.tileset; - - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - var ctx = renderer.gameContext; - - ctx.save(); - ctx.translate(tx, ty); - ctx.rotate(src.rotation); - ctx.scale(src.scaleX, src.scaleY); - ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); - - for (var index = 0; index < length; ++index) - { - var tile = renderTiles[index]; - - var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); - if (tileTexCoords === null) { continue; } - - var halfWidth = tile.width / 2; - var halfHeight = tile.height / 2; - - ctx.save(); - ctx.translate(tile.pixelX + halfWidth, tile.pixelY + halfHeight); - - if (tile.rotation !== 0) - { - ctx.rotate(tile.rotation); - } - - if (tile.flipX || tile.flipY) - { - ctx.scale(tile.flipX ? -1 : 1, tile.flipY ? -1 : 1); - } - - ctx.globalAlpha = src.alpha * tile.alpha; - - ctx.drawImage( - image, - tileTexCoords.x, tileTexCoords.y, - tile.width, tile.height, - -halfWidth, -halfHeight, - tile.width, tile.height - ); - - ctx.restore(); - } - - ctx.restore(); -}; - -module.exports = DynamicTilemapLayerCanvasRenderer; - - -/***/ }), -/* 917 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(918); -} - -if (true) -{ - renderCanvas = __webpack_require__(919); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 918 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.Tilemaps.StaticTilemapLayer} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - src.upload(camera); - - this.pipeline.drawStaticTilemapLayer(src, camera); -}; - -module.exports = StaticTilemapLayerWebGLRenderer; - - -/***/ }), -/* 919 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.Tilemaps.StaticTilemapLayer} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - src.cull(camera); - - var renderTiles = src.culledTiles; - var tileset = this.tileset; - var ctx = renderer.gameContext; - var tileCount = renderTiles.length; - var image = tileset.image.getSourceImage(); - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - - ctx.save(); - ctx.translate(tx, ty); - ctx.rotate(src.rotation); - ctx.scale(src.scaleX, src.scaleY); - ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); - ctx.globalAlpha = src.alpha; - - for (var index = 0; index < tileCount; ++index) - { - var tile = renderTiles[index]; - - var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); - - if (tileTexCoords === null) { continue; } - - ctx.drawImage( - image, - tileTexCoords.x, tileTexCoords.y, - tile.width, tile.height, - tile.pixelX, tile.pixelY, - tile.width, tile.height - ); - } - - ctx.restore(); -}; - -module.exports = StaticTilemapLayerCanvasRenderer; - - -/***/ }), -/* 920 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectCreator = __webpack_require__(13); -var ParseToTilemap = __webpack_require__(157); - -/** - * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. - * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing - * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map - * data. For an empty map, you should specify tileWidth, tileHeight, width & height. - * - * @method Phaser.GameObjects.GameObjectCreator#tilemap - * @since 3.0.0 - * - * @param {object} [config] - The config options for the Tilemap. - * @param {string} [config.key] - The key in the Phaser cache that corresponds to the loaded tilemap - * data. - * @param {integer[][]} [config.data] - Instead of loading from the cache, you can also load - * directly from a 2D array of tile indexes. - * @param {integer} [config.tileWidth=32] - The width of a tile in pixels. - * @param {integer} [config.tileHeight=32] - The height of a tile in pixels. - * @param {integer} [config.width=10] - The width of the map in tiles. - * @param {integer} [config.height=10] - The height of the map in tiles. - * @param {boolean} [config.insertNull=false] - Controls how empty tiles, tiles with an index of -1, - * in the map data are handled. If `true`, empty locations will get a value of `null`. If `false`, - * empty location will get a Tile object with an index of -1. If you've a large sparsely populated - * map and the tile data doesn't need to change then setting this value to `true` will help with - * memory consumption. However if your map is small or you need to update the tiles dynamically, - * then leave the default value set. - * - * @return {Phaser.Tilemaps.Tilemap} - */ -GameObjectCreator.register('tilemap', function (config) -{ - // Defaults are applied in ParseToTilemap - var c = (config !== undefined) ? config : {}; - - return ParseToTilemap( - this.scene, - c.key, - c.tileWidth, - c.tileHeight, - c.width, - c.height, - c.data, - c.insertNull - ); -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 921 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectFactory = __webpack_require__(9); -var ParseToTilemap = __webpack_require__(157); - -/** - * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. - * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing - * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map - * data. For an empty map, you should specify tileWidth, tileHeight, width & height. - * - * @method Phaser.GameObjects.GameObjectFactory#tilemap - * @since 3.0.0 - * - * @param {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data. - * @param {integer} [tileWidth=32] - The width of a tile in pixels. Pass in `null` to leave as the - * default. - * @param {integer} [tileHeight=32] - The height of a tile in pixels. Pass in `null` to leave as the - * default. - * @param {integer} [width=10] - The width of the map in tiles. Pass in `null` to leave as the - * default. - * @param {integer} [height=10] - The height of the map in tiles. Pass in `null` to leave as the - * default. - * @param {integer[][]} [data] - Instead of loading from the cache, you can also load directly from - * a 2D array of tile indexes. Pass in `null` for no data. - * @param {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, in the - * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {Phaser.Tilemaps.Tilemap} - */ -GameObjectFactory.register('tilemap', function (key, tileWidth, tileHeight, width, height, data, insertNull) -{ - // Allow users to specify null to indicate that they want the default value, since null is - // shorter & more legible than undefined. Convert null to undefined to allow ParseToTilemap - // defaults to take effect. - - if (key === null) { key = undefined; } - if (tileWidth === null) { tileWidth = undefined; } - if (tileHeight === null) { tileHeight = undefined; } - if (width === null) { width = undefined; } - if (height === null) { height = undefined; } - - return ParseToTilemap(this.scene, key, tileWidth, tileHeight, width, height, data, insertNull); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 922 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Time - */ - -module.exports = { - - Clock: __webpack_require__(923), - TimerEvent: __webpack_require__(358) - -}; - - -/***/ }), -/* 923 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var PluginManager = __webpack_require__(12); -var TimerEvent = __webpack_require__(358); - -/** - * @classdesc - * [description] - * - * @class Clock - * @memberOf Phaser.Time - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var Clock = new Class({ - - initialize: - - function Clock (scene) - { - /** - * [description] - * - * @name Phaser.Time.Clock#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.Time.Clock#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - if (!scene.sys.settings.isBooted) - { - scene.sys.events.once('boot', this.boot, this); - } - - /** - * [description] - * - * @name Phaser.Time.Clock#now - * @type {number} - * @since 3.0.0 - */ - this.now = Date.now(); - - // Scale the delta time coming into the Clock by this factor - // which then influences anything using this Clock for calculations, like TimerEvents - - /** - * [description] - * - * @name Phaser.Time.Clock#timeScale - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * [description] - * - * @name Phaser.Time.Clock#paused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.paused = false; - - /** - * [description] - * - * @name Phaser.Time.Clock#_active - * @type {Phaser.Time.TimerEvent[]} + * @name Phaser.GameObjects.UpdateList#_list + * @type {array} * @private * @default [] * @since 3.0.0 */ - this._active = []; + this._list = []; /** * [description] * - * @name Phaser.Time.Clock#_pendingInsertion - * @type {Phaser.Time.TimerEvent[]} + * @name Phaser.GameObjects.UpdateList#_pendingInsertion + * @type {array} * @private * @default [] * @since 3.0.0 @@ -116819,8 +105889,8 @@ var Clock = new Class({ /** * [description] * - * @name Phaser.Time.Clock#_pendingRemoval - * @type {Phaser.Time.TimerEvent[]} + * @name Phaser.GameObjects.UpdateList#_pendingRemoval + * @type {array} * @private * @default [] * @since 3.0.0 @@ -116831,7 +105901,7 @@ var Clock = new Class({ /** * [description] * - * @method Phaser.Time.Clock#boot + * @method Phaser.GameObjects.UpdateList#boot * @since 3.0.0 */ boot: function () @@ -116847,74 +105917,29 @@ var Clock = new Class({ /** * [description] * - * @method Phaser.Time.Clock#addEvent + * @method Phaser.GameObjects.UpdateList#add * @since 3.0.0 * - * @param {object} config - [description] + * @param {Phaser.GameObjects.GameObject} child - [description] * - * @return {Phaser.Time.TimerEvent} [description] + * @return {Phaser.GameObjects.GameObject} [description] */ - addEvent: function (config) + add: function (child) { - var event = new TimerEvent(config); + // Is child already in this list? - this._pendingInsertion.push(event); + if (this._list.indexOf(child) === -1 && this._pendingInsertion.indexOf(child) === -1) + { + this._pendingInsertion.push(child); + } - return event; + return child; }, /** * [description] * - * @method Phaser.Time.Clock#delayedCall - * @since 3.0.0 - * - * @param {number} delay - [description] - * @param {function} callback - [description] - * @param {array} args - [description] - * @param {object} callbackScope - [description] - * - * @return {[type]} [description] - */ - delayedCall: function (delay, callback, args, callbackScope) - { - return this.addEvent({ delay: delay, callback: callback, args: args, callbackScope: callbackScope }); - }, - - /** - * [description] - * - * @method Phaser.Time.Clock#clearPendingEvents - * @since 3.0.0 - * - * @return {Phaser.Time.Clock} [description] - */ - clearPendingEvents: function () - { - this._pendingInsertion = []; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Time.Clock#removeAllEvents - * @since 3.0.0 - * - * @return {Phaser.Time.Clock} [description] - */ - removeAllEvents: function () - { - this._pendingRemoval = this._pendingRemoval.concat(this._active); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Time.Clock#preUpdate + * @method Phaser.GameObjects.UpdateList#preUpdate * @since 3.0.0 * * @param {number} time - [description] @@ -116932,30 +105957,23 @@ var Clock = new Class({ } var i; - var event; + var gameObject; - // Delete old events + // Delete old gameObjects for (i = 0; i < toRemove; i++) { - event = this._pendingRemoval[i]; + gameObject = this._pendingRemoval[i]; - var index = this._active.indexOf(event); + var index = this._list.indexOf(gameObject); if (index > -1) { - this._active.splice(index, 1); + this._list.splice(index, 1); } - - // Pool them? - event.destroy(); } - for (i = 0; i < toInsert; i++) - { - event = this._pendingInsertion[i]; - - this._active.push(event); - } + // Move pending to active + this._list = this._list.concat(this._pendingInsertion.splice(0)); // Clear the lists this._pendingRemoval.length = 0; @@ -116965,7 +105983,7 @@ var Clock = new Class({ /** * [description] * - * @method Phaser.Time.Clock#update + * @method Phaser.GameObjects.UpdateList#update * @since 3.0.0 * * @param {number} time - [description] @@ -116973,55 +105991,13 @@ var Clock = new Class({ */ update: function (time, delta) { - this.now = time; - - if (this.paused) + for (var i = 0; i < this._list.length; i++) { - return; - } + var gameObject = this._list[i]; - delta *= this.timeScale; - - for (var i = 0; i < this._active.length; i++) - { - var event = this._active[i]; - - if (event.paused) + if (gameObject.active) { - continue; - } - - // Use delta time to increase elapsed. - // Avoids needing to adjust for pause / resume. - // Automatically smoothed by TimeStep class. - // In testing accurate to +- 1ms! - event.elapsed += delta * event.timeScale; - - if (event.elapsed >= event.delay) - { - var remainder = event.elapsed - event.delay; - - // Limit it, in case it's checked in the callback - event.elapsed = event.delay; - - // Process the event - if (!event.hasDispatched && event.callback) - { - event.hasDispatched = true; - event.callback.apply(event.callbackScope, event.args); - } - - if (event.repeatCount > 0) - { - event.repeatCount--; - - event.elapsed = remainder; - event.hasDispatched = false; - } - else - { - this._pendingRemoval.push(event); - } + gameObject.preUpdate.call(gameObject, time, delta); } } }, @@ -117029,29 +106005,56 @@ var Clock = new Class({ /** * [description] * - * @method Phaser.Time.Clock#shutdown + * @method Phaser.GameObjects.UpdateList#remove + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - [description] + * + * @return {Phaser.GameObjects.GameObject} [description] + */ + remove: function (child) + { + var index = this._list.indexOf(child); + + if (index !== -1) + { + this._list.splice(index, 1); + } + + return child; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.UpdateList#removeAll + * @since 3.0.0 + * + * @return {Phaser.GameObjects.UpdateList} The UpdateList object. + */ + removeAll: function () + { + var i = this._list.length; + + while (i--) + { + this.remove(this._list[i]); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.UpdateList#shutdown * @since 3.0.0 */ shutdown: function () { - var i; + this.removeAll(); - for (i = 0; i < this._pendingInsertion.length; i++) - { - this._pendingInsertion[i].destroy(); - } - - for (i = 0; i < this._active.length; i++) - { - this._active[i].destroy(); - } - - for (i = 0; i < this._pendingRemoval.length; i++) - { - this._pendingRemoval[i].destroy(); - } - - this._active.length = 0; + this._list.length = 0; this._pendingRemoval.length = 0; this._pendingInsertion.length = 0; }, @@ -117059,7 +106062,7 @@ var Clock = new Class({ /** * [description] * - * @method Phaser.Time.Clock#destroy + * @method Phaser.GameObjects.UpdateList#destroy * @since 3.0.0 */ destroy: function () @@ -117067,18 +106070,11331 @@ var Clock = new Class({ this.shutdown(); this.scene = undefined; + this.systems = undefined; + } }); -PluginManager.register('Clock', Clock, 'time'); +PluginManager.register('UpdateList', UpdateList, 'updateList'); -module.exports = Clock; +module.exports = UpdateList; + + +/***/ }), +/* 782 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var List = __webpack_require__(97); +var PluginManager = __webpack_require__(12); +var StableSort = __webpack_require__(272); + +/** + * @classdesc + * [description] + * + * @class DisplayList + * @extends Phaser.Structs.List + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ +var DisplayList = new Class({ + + Extends: List, + + initialize: + + function DisplayList (scene) + { + List.call(this, scene); + + /** + * [description] + * + * @name Phaser.GameObjects.DisplayList#sortChildrenFlag + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.sortChildrenFlag = false; + + /** + * [description] + * + * @name Phaser.GameObjects.DisplayList#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.GameObjects.DisplayList#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + if (!scene.sys.settings.isBooted) + { + scene.sys.events.once('boot', this.boot, this); + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.DisplayList#boot + * @since 3.0.0 + */ + boot: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); + }, + + /** + * Force a sort of the display list on the next call to depthSort. + * + * @method Phaser.GameObjects.DisplayList#queueDepthSort + * @since 3.0.0 + */ + queueDepthSort: function () + { + this.sortChildrenFlag = true; + }, + + /** + * Immediately sorts the display list if the flag is set. + * + * @method Phaser.GameObjects.DisplayList#depthSort + * @since 3.0.0 + */ + depthSort: function () + { + if (this.sortChildrenFlag) + { + StableSort.inplace(this.list, this.sortByDepth); + + this.sortChildrenFlag = false; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.DisplayList#sortByDepth + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} childA - [description] + * @param {Phaser.GameObjects.GameObject} childB - [description] + * + * @return {integer} [description] + */ + sortByDepth: function (childA, childB) + { + return childA._depth - childB._depth; + }, + + /** + * Given an array of Game Objects, sort the array and return it, + * so that the objects are in index order with the lowest at the bottom. + * + * @method Phaser.GameObjects.DisplayList#sortGameObjects + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject[]} gameObjects - [description] + * + * @return {array} [description] + */ + sortGameObjects: function (gameObjects) + { + if (gameObjects === undefined) { gameObjects = this.list; } + + this.scene.sys.depthSort(); + + return gameObjects.sort(this.sortIndexHandler.bind(this)); + }, + + /** + * Note that the given array is sorted in place, even though it isn't returned directly it will still be updated. + * + * @method Phaser.GameObjects.DisplayList#getTopGameObject + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject[]} gameObjects - [description] + * + * @return {Phaser.GameObjects.GameObject} The top-most Game Object on the Display List. + */ + getTopGameObject: function (gameObjects) + { + this.sortGameObjects(gameObjects); + + return gameObjects[gameObjects.length - 1]; + } + +}); + +PluginManager.register('DisplayList', DisplayList, 'displayList'); + +module.exports = DisplayList; + + +/***/ }), +/* 783 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.GameObjects + */ + +var GameObjects = { + + DisplayList: __webpack_require__(782), + GameObjectCreator: __webpack_require__(11), + GameObjectFactory: __webpack_require__(9), + UpdateList: __webpack_require__(781), + + Components: __webpack_require__(13), + + BuildGameObject: __webpack_require__(22), + BuildGameObjectAnimation: __webpack_require__(140), + GameObject: __webpack_require__(1), + BitmapText: __webpack_require__(139), + Blitter: __webpack_require__(138), + DynamicBitmapText: __webpack_require__(137), + Graphics: __webpack_require__(136), + Group: __webpack_require__(73), + Image: __webpack_require__(72), + Particles: __webpack_require__(133), + PathFollower: __webpack_require__(249), + RenderTexture: __webpack_require__(131), + Sprite3D: __webpack_require__(101), + Sprite: __webpack_require__(40), + Text: __webpack_require__(130), + TileSprite: __webpack_require__(129), + Zone: __webpack_require__(106), + + // Game Object Factories + + Factories: { + Blitter: __webpack_require__(697), + DynamicBitmapText: __webpack_require__(696), + Graphics: __webpack_require__(695), + Group: __webpack_require__(694), + Image: __webpack_require__(693), + Particles: __webpack_require__(692), + PathFollower: __webpack_require__(691), + RenderTexture: __webpack_require__(690), + Sprite3D: __webpack_require__(689), + Sprite: __webpack_require__(688), + StaticBitmapText: __webpack_require__(687), + Text: __webpack_require__(686), + TileSprite: __webpack_require__(685), + Zone: __webpack_require__(684) + }, + + Creators: { + Blitter: __webpack_require__(683), + DynamicBitmapText: __webpack_require__(682), + Graphics: __webpack_require__(681), + Group: __webpack_require__(680), + Image: __webpack_require__(679), + Particles: __webpack_require__(678), + RenderTexture: __webpack_require__(677), + Sprite3D: __webpack_require__(676), + Sprite: __webpack_require__(675), + StaticBitmapText: __webpack_require__(674), + Text: __webpack_require__(673), + TileSprite: __webpack_require__(672), + Zone: __webpack_require__(671) + } + +}; + +if (true) +{ + // WebGL only Game Objects + GameObjects.Mesh = __webpack_require__(96); + GameObjects.Quad = __webpack_require__(128); + + GameObjects.Factories.Mesh = __webpack_require__(667); + GameObjects.Factories.Quad = __webpack_require__(666); + + GameObjects.Creators.Mesh = __webpack_require__(665); + GameObjects.Creators.Quad = __webpack_require__(664); + + GameObjects.Light = __webpack_require__(247); + + __webpack_require__(246); + __webpack_require__(663); +} + +module.exports = GameObjects; + + +/***/ }), +/* 784 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Visibility Handler hidden event. + * + * The document in which the Game is embedded has entered a hidden state. + * + * @event Phaser.Boot.VisibilityHandler#hidden + */ + +/** + * Visibility Handler visible event. + * + * The document in which the Game is embedded has entered a visible state. + * + * @event Phaser.Boot.VisibilityHandler#visible + */ + +/** + * Visibility Handler blur event. + * + * The window in which the Game is embedded has entered a blurred state. + * + * @event Phaser.Boot.VisibilityHandler#blur + */ + +/** + * Visibility Handler focus event. + * + * The window in which the Game is embedded has entered a focused state. + * + * @event Phaser.Boot.VisibilityHandler#focus + */ + +/** + * The Visibility Handler is responsible for listening out for document level visibility change events. + * This includes `visibilitychange` if the browser supports it, and blur and focus events. It then uses + * the provided Event Emitter and fires the related events. + * + * @function Phaser.Boot.VisibilityHandler + * @fires Phaser.Boot.VisibilityHandler#hidden + * @fires Phaser.Boot.VisibilityHandler#visible + * @fires Phaser.Boot.VisibilityHandler#blur + * @fires Phaser.Boot.VisibilityHandler#focus + * @since 3.0.0 + * + * @param {Phaser.Events.EventEmitter} eventEmitter - The EventEmitter that will emit the visibility events. + */ +var VisibilityHandler = function (eventEmitter) +{ + var hiddenVar; + + if (document.hidden !== undefined) + { + hiddenVar = 'visibilitychange'; + } + else + { + var vendors = [ 'webkit', 'moz', 'ms' ]; + + vendors.forEach(function (prefix) + { + if (document[prefix + 'Hidden'] !== undefined) + { + document.hidden = function () + { + return document[prefix + 'Hidden']; + }; + + hiddenVar = prefix + 'visibilitychange'; + } + + }); + } + + var onChange = function (event) + { + if (document.hidden || event.type === 'pause') + { + eventEmitter.emit('hidden'); + } + else + { + eventEmitter.emit('visible'); + } + }; + + if (hiddenVar) + { + document.addEventListener(hiddenVar, onChange, false); + } + + window.onblur = function () + { + eventEmitter.emit('blur'); + }; + + window.onfocus = function () + { + eventEmitter.emit('focus'); + }; +}; + +module.exports = VisibilityHandler; + + +/***/ }), +/* 785 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetValue = __webpack_require__(5); +var NOOP = __webpack_require__(3); +var RequestAnimationFrame = __webpack_require__(304); + +// Frame Rate config +// fps: { +// min: 10, +// target: 60, +// forceSetTimeOut: false, +// deltaHistory: 10, +// panicMax: 120 +// } + +// http://www.testufo.com/#test=animation-time-graph + +/** + * @callback TimeStepCallback + * + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} average - The Delta Average. + * @param {number} interpolation - Interpolation - how far between what is expected and where we are? + */ + +/** + * @classdesc + * [description] + * + * @class TimeStep + * @memberOf Phaser.Boot + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - A reference to the Phaser.Game instance that owns this Time Step. + * @param {FPSConfig} config + */ +var TimeStep = new Class({ + + initialize: + + function TimeStep (game, config) + { + /** + * A reference to the Phaser.Game instance. + * + * @property {Phaser.Game} game + * @readOnly + * @since 3.0.0 + */ + this.game = game; + + /** + * [description] + * + * @property {Phaser.DOM.RequestAnimationFrame} raf + * @readOnly + * @since 3.0.0 + */ + this.raf = new RequestAnimationFrame(); + + /** + * A flag that is set once the TimeStep has started running and toggled when it stops. + * + * @property {boolean} started + * @readOnly + * @default false + * @since 3.0.0 + */ + this.started = false; + + /** + * A flag that is set once the TimeStep has started running and toggled when it stops. + * The difference between this value and `started` is that `running` is toggled when + * the TimeStep is sent to sleep, where-as `started` remains `true`, only changing if + * the TimeStep is actually stopped, not just paused. + * + * @property {boolean} running + * @readOnly + * @default false + * @since 3.0.0 + */ + this.running = false; + + /** + * The minimum fps rate you want the Time Step to run at. + * + * @property {integer} minFps + * @default 5 + * @since 3.0.0 + */ + this.minFps = GetValue(config, 'min', 5); + + /** + * The target fps rate for the Time Step to run at. + * + * Setting this value will not actually change the speed at which the browser runs, that is beyond + * the control of Phaser. Instead, it allows you to determine performance issues and if the Time Step + * is spiraling out of control. + * + * @property {integer} targetFps + * @default 60 + * @since 3.0.0 + */ + this.targetFps = GetValue(config, 'target', 60); + + /** + * The minFps value in ms. + * Defaults to 200ms between frames (i.e. super slow!) + * + * @property {number} _min + * @private + * @since 3.0.0 + */ + this._min = 1000 / this.minFps; + + /** + * The targetFps value in ms. + * Defaults to 16.66ms between frames (i.e. normal) + * + * @property {number} _target + * @private + * @since 3.0.0 + */ + this._target = 1000 / this.targetFps; + + /** + * An exponential moving average of the frames per second. + * + * @property {integer} actualFps + * @readOnly + * @default 60 + * @since 3.0.0 + */ + this.actualFps = this.targetFps; + + /** + * [description] + * + * @property {integer} nextFpsUpdate + * @readOnly + * @default 0 + * @since 3.0.0 + */ + this.nextFpsUpdate = 0; + + /** + * The number of frames processed this second. + * + * @property {integer} framesThisSecond + * @readOnly + * @default 0 + * @since 3.0.0 + */ + this.framesThisSecond = 0; + + /** + * A callback to be invoked each time the Time Step steps. + * + * @property {TimeStepCallback} callback + * @default NOOP + * @since 3.0.0 + */ + this.callback = NOOP; + + /** + * You can force the Time Step to use Set Timeout instead of Request Animation Frame by setting + * the `forceSetTimeOut` property to `true` in the Game Configuration object. It cannot be changed at run-time. + * + * @property {boolean} forceSetTimeOut + * @readOnly + * @default false + * @since 3.0.0 + */ + this.forceSetTimeOut = GetValue(config, 'forceSetTimeOut', false); + + /** + * [description] + * + * @property {integer} time + * @default 0 + * @since 3.0.0 + */ + this.time = 0; + + /** + * [description] + * + * @property {integer} startTime + * @default 0 + * @since 3.0.0 + */ + this.startTime = 0; + + /** + * [description] + * + * @property {integer} lastTime + * @default 0 + * @since 3.0.0 + */ + this.lastTime = 0; + + /** + * [description] + * + * @property {integer} frame + * @readOnly + * @default 0 + * @since 3.0.0 + */ + this.frame = 0; + + /** + * [description] + * + * @property {boolean} inFocus + * @readOnly + * @default true + * @since 3.0.0 + */ + this.inFocus = true; + + /** + * [description] + * + * @property {integer} _pauseTime + * @private + * @default 0 + * @since 3.0.0 + */ + this._pauseTime = 0; + + /** + * [description] + * + * @property {integer} _coolDown + * @private + * @default 0 + * @since 3.0.0 + */ + this._coolDown = 0; + + /** + * [description] + * + * @property {integer} delta + * @default 0 + * @since 3.0.0 + */ + this.delta = 0; + + /** + * [description] + * + * @property {integer} deltaIndex + * @default 0 + * @since 3.0.0 + */ + this.deltaIndex = 0; + + /** + * [description] + * + * @property {array} deltaHistory + * @default 0 + * @since 3.0.0 + */ + this.deltaHistory = []; + + /** + * [description] + * + * @property {integer} deltaSmoothingMax + * @default 10 + * @since 3.0.0 + */ + this.deltaSmoothingMax = GetValue(config, 'deltaHistory', 10); + + /** + * [description] + * + * @property {integer} panicMax + * @default 120 + * @since 3.0.0 + */ + this.panicMax = GetValue(config, 'panicMax', 120); + + /** + * The actual elapsed time in ms between one update and the next. + * Unlike with `delta` no smoothing, capping, or averaging is applied to this value. + * So please be careful when using this value in calculations. + * + * @property {number} rawDelta + * @default 0 + * @since 3.0.0 + */ + this.rawDelta = 0; + }, + + /** + * Called when the DOM window.onBlur event triggers. + * + * @method Phaser.Boot.TimeStep#blur + * @since 3.0.0 + */ + blur: function () + { + this.inFocus = false; + }, + + /** + * Called when the DOM window.onFocus event triggers. + * + * @method Phaser.Boot.TimeStep#focus + * @since 3.0.0 + */ + focus: function () + { + this.inFocus = true; + + this.resetDelta(); + }, + + /** + * Called when the visibility API says the game is 'hidden' (tab switch out of view, etc) + * + * @method Phaser.Boot.TimeStep#pause + * @since 3.0.0 + */ + pause: function () + { + this._pauseTime = window.performance.now(); + }, + + /** + * Called when the visibility API says the game is 'visible' again (tab switch back into view, etc) + * + * @method Phaser.Boot.TimeStep#resume + * @since 3.0.0 + */ + resume: function () + { + this.resetDelta(); + + this.startTime += this.time - this._pauseTime; + }, + + /** + * [description] + * + * @method Phaser.Boot.TimeStep#resetDelta + * @since 3.0.0 + */ + resetDelta: function () + { + var now = window.performance.now(); + + this.time = now; + this.lastTime = now; + this.nextFpsUpdate = now + 1000; + this.framesThisSecond = 0; + this.frame = 0; + + // Pre-populate smoothing array + + for (var i = 0; i < this.deltaSmoothingMax; i++) + { + this.deltaHistory[i] = Math.min(this._target, this.deltaHistory[i]); + } + + this.delta = 0; + this.deltaIndex = 0; + + this._coolDown = this.panicMax; + }, + + /** + * Starts the Time Step running, if it is not already doing so. + * Called automatically by the Game Boot process. + * + * @method Phaser.Boot.TimeStep#start + * @since 3.0.0 + * + * @param {TimeStepCallback} callback - The callback to be invoked each time the Time Step steps. + */ + start: function (callback) + { + if (this.started) + { + return this; + } + + this.started = true; + this.running = true; + + for (var i = 0; i < this.deltaSmoothingMax; i++) + { + this.deltaHistory[i] = this._target; + } + + this.resetDelta(); + + this.startTime = window.performance.now(); + + this.callback = callback; + + this.raf.start(this.step.bind(this), this.forceSetTimeOut); + }, + + /** + * The main step method. This is called each time the browser updates, either by Request Animation Frame, + * or by Set Timeout. It is responsible for calculating the delta values, frame totals, cool down history and more. + * You generally should never call this method directly. + * + * @method Phaser.Boot.TimeStep#step + * @since 3.0.0 + * + * @param {integer} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + */ + step: function (time) + { + this.frame++; + + this.rawDelta = time - this.lastTime; + + var idx = this.deltaIndex; + var history = this.deltaHistory; + var max = this.deltaSmoothingMax; + + // delta time (time is in ms) + var dt = (time - this.lastTime); + + // When a browser switches tab, then comes back again, it takes around 10 frames before + // the delta time settles down so we employ a 'cooling down' period before we start + // trusting the delta values again, to avoid spikes flooding through our delta average + + if (this._coolDown > 0 || !this.inFocus) + { + this._coolDown--; + + dt = Math.min(dt, this._target); + } + + if (dt > this._min) + { + // Probably super bad start time or browser tab context loss, + // so use the last 'sane' dt value + + dt = history[idx]; + + // Clamp delta to min (in case history has become corrupted somehow) + dt = Math.min(dt, this._min); + } + + // Smooth out the delta over the previous X frames + + // add the delta to the smoothing array + history[idx] = dt; + + // adjusts the delta history array index based on the smoothing count + // this stops the array growing beyond the size of deltaSmoothingMax + this.deltaIndex++; + + if (this.deltaIndex > max) + { + this.deltaIndex = 0; + } + + // Delta Average + var avg = 0; + + // Loop the history array, adding the delta values together + + for (var i = 0; i < max; i++) + { + avg += history[i]; + } + + // Then divide by the array length to get the average delta + avg /= max; + + // Set as the world delta value + this.delta = avg; + + // Real-world timer advance + this.time += this.rawDelta; + + // Update the estimate of the frame rate, `fps`. Every second, the number + // of frames that occurred in that second are included in an exponential + // moving average of all frames per second, with an alpha of 0.25. This + // means that more recent seconds affect the estimated frame rate more than + // older seconds. + // + // When a browser window is NOT minimized, but is covered up (i.e. you're using + // another app which has spawned a window over the top of the browser), then it + // will start to throttle the raf callback time. It waits for a while, and then + // starts to drop the frame rate at 1 frame per second until it's down to just over 1fps. + // So if the game was running at 60fps, and the player opens a new window, then + // after 60 seconds (+ the 'buffer time') it'll be down to 1fps, so rafin'g at 1Hz. + // + // When they make the game visible again, the frame rate is increased at a rate of + // approx. 8fps, back up to 60fps (or the max it can obtain) + // + // There is no easy way to determine if this drop in frame rate is because the + // browser is throttling raf, or because the game is struggling with performance + // because you're asking it to do too much on the device. + + if (time > this.nextFpsUpdate) + { + // Compute the new exponential moving average with an alpha of 0.25. + this.actualFps = 0.25 * this.framesThisSecond + 0.75 * this.actualFps; + this.nextFpsUpdate = time + 1000; + this.framesThisSecond = 0; + } + + this.framesThisSecond++; + + // Interpolation - how far between what is expected and where we are? + var interpolation = avg / this._target; + + this.callback(time, avg, interpolation); + + // Shift time value over + this.lastTime = time; + }, + + /** + * Manually calls TimeStep.step, passing in the performance.now value to it. + * + * @method Phaser.Boot.TimeStep#tick + * @since 3.0.0 + */ + tick: function () + { + this.step(window.performance.now()); + }, + + /** + * Sends the TimeStep to sleep, stopping Request Animation Frame (or SetTimeout) and toggling the `running` flag to false. + * + * @method Phaser.Boot.TimeStep#sleep + * @since 3.0.0 + */ + sleep: function () + { + if (this.running) + { + this.raf.stop(); + + this.running = false; + } + }, + + /** + * Wakes-up the TimeStep, restarting Request Animation Frame (or SetTimeout) and toggling the `running` flag to true. + * The `seamless` argument controls if the wake-up should adjust the start time or not. + * + * @method Phaser.Boot.TimeStep#wake + * @since 3.0.0 + * + * @param {boolean} [seamless=false] - Adjust the startTime based on the lastTime values. + */ + wake: function (seamless) + { + if (this.running) + { + this.sleep(); + } + else if (seamless) + { + this.startTime += -this.lastTime + (this.lastTime = window.performance.now()); + } + + this.raf.start(this.step.bind(this), this.useRAF); + + this.running = true; + + this.step(window.performance.now()); + }, + + /** + * Stops the TimeStep running. + * + * @method Phaser.Boot.TimeStep#stop + * @since 3.0.0 + * + * @return {Phaser.Boot.TimeStep} The TimeStep object. + */ + stop: function () + { + this.running = false; + this.started = false; + + this.raf.stop(); + + return this; + }, + + /** + * Destroys the TimeStep. This will stop Request Animation Frame, stop the step, clear the callbacks and null + * any objects. + * + * @method Phaser.Boot.TimeStep#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.stop(); + + this.callback = NOOP; + + this.raf = null; + this.game = null; + } + +}); + +module.exports = TimeStep; + + +/***/ }), +/* 786 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var imageHeight = 0; + +/** + * @function addFrame + * @private + * @since 3.0.0 + */ +var addFrame = function (texture, sourceIndex, name, frame) +{ + // The frame values are the exact coordinates to cut the frame out of the atlas from + + var y = imageHeight - frame.y - frame.height; + + texture.add(name, sourceIndex, frame.x, y, frame.width, frame.height); + + // These are the original (non-trimmed) sprite values + /* + if (src.trimmed) + { + newFrame.setTrim( + src.sourceSize.w, + src.sourceSize.h, + src.spriteSourceSize.x, + src.spriteSourceSize.y, + src.spriteSourceSize.w, + src.spriteSourceSize.h + ); + } + */ +}; + +/** + * Parses a Unity YAML File and creates Frames in the Texture. + * For more details about Sprite Meta Data see https://docs.unity3d.com/ScriptReference/SpriteMetaData.html + * + * @function Phaser.Textures.Parsers.UnityYAML + * @memberOf Phaser.Textures.Parsers + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {integer} sourceIndex - The index of the TextureSource. + * @param {object} yaml - The YAML data. + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var UnityYAML = function (texture, sourceIndex, yaml) +{ + // Add in a __BASE entry (for the entire atlas) + var source = texture.source[sourceIndex]; + + texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); + + imageHeight = source.height; + + var data = yaml.split('\n'); + + var lineRegExp = /^[ ]*(- )*(\w+)+[: ]+(.*)/; + + var prevSprite = ''; + var currentSprite = ''; + var rect = { x: 0, y: 0, width: 0, height: 0 }; + + // var pivot = { x: 0, y: 0 }; + // var border = { x: 0, y: 0, z: 0, w: 0 }; + + for (var i = 0; i < data.length; i++) + { + var results = data[i].match(lineRegExp); + + if (!results) + { + continue; + } + + var isList = (results[1] === '- '); + var key = results[2]; + var value = results[3]; + + if (isList) + { + if (currentSprite !== prevSprite) + { + addFrame(texture, sourceIndex, currentSprite, rect); + + prevSprite = currentSprite; + } + + rect = { x: 0, y: 0, width: 0, height: 0 }; + } + + if (key === 'name') + { + // Start new list + currentSprite = value; + continue; + } + + switch (key) + { + case 'x': + case 'y': + case 'width': + case 'height': + rect[key] = parseInt(value, 10); + break; + + // case 'pivot': + // pivot = eval('var obj = ' + value); + // break; + + // case 'border': + // border = eval('var obj = ' + value); + // break; + } + } + + if (currentSprite !== prevSprite) + { + addFrame(texture, sourceIndex, currentSprite, rect); + } + + return texture; +}; + +module.exports = UnityYAML; + +/* +Example data: + +TextureImporter: + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + spriteSheet: + sprites: + - name: asteroids_0 + rect: + serializedVersion: 2 + x: 5 + y: 328 + width: 65 + height: 82 + alignment: 0 + pivot: {x: 0, y: 0} + border: {x: 0, y: 0, z: 0, w: 0} + - name: asteroids_1 + rect: + serializedVersion: 2 + x: 80 + y: 322 + width: 53 + height: 88 + alignment: 0 + pivot: {x: 0, y: 0} + border: {x: 0, y: 0, z: 0, w: 0} + spritePackingTag: Asteroids +*/ + + +/***/ }), +/* 787 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Parses a Starling XML object and adds all the Frames into a Texture. + * + * @function Phaser.Textures.Parsers.StarlingXML + * @memberOf Phaser.Textures.Parsers + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {*} xml - The XML data. + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var StarlingXML = function (texture, xml) +{ + // Malformed? + if (!xml.getElementsByTagName('TextureAtlas')) + { + // console.warn("Phaser.AnimationParser.XMLData: Invalid Texture Atlas XML given, missing tag"); + return; + } + + // Let's create some frames then + var data = new Phaser.FrameData(); + var frames = xml.getElementsByTagName('SubTexture'); + var newFrame; + + var name; + var frame; + var x; + var y; + var width; + var height; + var frameX; + var frameY; + var frameWidth; + var frameHeight; + + for (var i = 0; i < frames.length; i++) + { + frame = frames[i].attributes; + + name = frame.name.value; + x = parseInt(frame.x.value, 10); + y = parseInt(frame.y.value, 10); + width = parseInt(frame.width.value, 10); + height = parseInt(frame.height.value, 10); + + frameX = null; + frameY = null; + + if (frame.frameX) + { + frameX = Math.abs(parseInt(frame.frameX.value, 10)); + frameY = Math.abs(parseInt(frame.frameY.value, 10)); + frameWidth = parseInt(frame.frameWidth.value, 10); + frameHeight = parseInt(frame.frameHeight.value, 10); + } + + newFrame = data.addFrame(new Phaser.Frame(i, x, y, width, height, name)); + + // Trimmed? + if (frameX !== null || frameY !== null) + { + newFrame.setTrim(true, width, height, frameX, frameY, frameWidth, frameHeight); + } + } + + return data; + +}; + +module.exports = StarlingXML; + + +/***/ }), +/* 788 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(2); + +/** + * Parses a Sprite Sheet and adds the Frames to the Texture, where the Sprite Sheet is stored as a frame within an Atlas. + * + * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact + * same size and cannot be trimmed or rotated. + * + * @function Phaser.Textures.Parsers.SpriteSheetFromAtlas + * @memberOf Phaser.Textures.Parsers + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {Phaser.Textures.Frame} frame - The Frame that contains the Sprite Sheet. + * @param {object} config - [description] + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var SpriteSheetFromAtlas = function (texture, frame, config) +{ + var frameWidth = GetFastValue(config, 'frameWidth', null); + var frameHeight = GetFastValue(config, 'frameHeight', frameWidth); + + // If missing we can't proceed + if (!frameWidth) + { + throw new Error('TextureManager.SpriteSheetFromAtlas: Invalid frameWidth given.'); + } + + // Add in a __BASE entry (for the entire atlas) + // var source = texture.source[sourceIndex]; + // texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); + + var startFrame = GetFastValue(config, 'startFrame', 0); + var endFrame = GetFastValue(config, 'endFrame', -1); + var margin = GetFastValue(config, 'margin', 0); + var spacing = GetFastValue(config, 'spacing', 0); + + var x = frame.cutX; + var y = frame.cutY; + + var cutWidth = frame.cutWidth; + var cutHeight = frame.cutHeight; + var sheetWidth = frame.realWidth; + var sheetHeight = frame.realHeight; + + var row = Math.floor((sheetWidth - margin + spacing) / (frameWidth + spacing)); + var column = Math.floor((sheetHeight - margin + spacing) / (frameHeight + spacing)); + var total = row * column; + + // trim offsets + + var leftPad = frame.x; + var leftWidth = frameWidth - leftPad; + + var rightWidth = frameWidth - ((sheetWidth - cutWidth) - leftPad); + + var topPad = frame.y; + var topHeight = frameHeight - topPad; + + var bottomHeight = frameHeight - ((sheetHeight - cutHeight) - topPad); + + // console.log('x / y', x, y); + // console.log('cutW / H', cutWidth, cutHeight); + // console.log('sheetW / H', sheetWidth, sheetHeight); + // console.log('row', row, 'column', column, 'total', total); + // console.log('LW', leftWidth, 'RW', rightWidth, 'TH', topHeight, 'BH', bottomHeight); + + if (startFrame > total || startFrame < -total) + { + startFrame = 0; + } + + if (startFrame < 0) + { + // Allow negative skipframes. + startFrame = total + startFrame; + } + + if (endFrame !== -1) + { + total = startFrame + (endFrame + 1); + } + + var sheetFrame; + var frameX = margin; + var frameY = margin; + var frameIndex = 0; + var sourceIndex = frame.sourceIndex; + + for (var sheetY = 0; sheetY < column; sheetY++) + { + var topRow = (sheetY === 0); + var bottomRow = (sheetY === column - 1); + + for (var sheetX = 0; sheetX < row; sheetX++) + { + var leftRow = (sheetX === 0); + var rightRow = (sheetX === row - 1); + + sheetFrame = texture.add(frameIndex, sourceIndex, x + frameX, y + frameY, frameWidth, frameHeight); + + if (leftRow || topRow || rightRow || bottomRow) + { + var destX = (leftRow) ? leftPad : 0; + var destY = (topRow) ? topPad : 0; + var destWidth = frameWidth; + var destHeight = frameHeight; + + if (leftRow) + { + destWidth = leftWidth; + } + else if (rightRow) + { + destWidth = rightWidth; + } + + if (topRow) + { + destHeight = topHeight; + } + else if (bottomRow) + { + destHeight = bottomHeight; + } + + sheetFrame.cutWidth = destWidth; + sheetFrame.cutHeight = destHeight; + + sheetFrame.setTrim(frameWidth, frameHeight, destX, destY, destWidth, destHeight); + } + + frameX += spacing; + + if (leftRow) + { + frameX += leftWidth; + } + else if (rightRow) + { + frameX += rightRow; + } + else + { + frameX += frameWidth; + } + + frameIndex++; + } + + frameX = margin; + frameY += spacing; + + if (topRow) + { + frameY += topHeight; + } + else if (bottomRow) + { + frameY += bottomHeight; + } + else + { + frameY += frameHeight; + } + } + + return texture; +}; + +module.exports = SpriteSheetFromAtlas; + + +/***/ }), +/* 789 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(2); + +/** + * Parses a Sprite Sheet and adds the Frames to the Texture. + * + * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact + * same size and cannot be trimmed or rotated. + * + * @function Phaser.Textures.Parsers.SpriteSheet + * @memberOf Phaser.Textures.Parsers + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {integer} sourceIndex - The index of the TextureSource. + * @param {integer} x - [description] + * @param {integer} y - [description] + * @param {integer} width - [description] + * @param {integer} height - [description] + * @param {object} config - [description] + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var SpriteSheet = function (texture, sourceIndex, x, y, width, height, config) +{ + var frameWidth = GetFastValue(config, 'frameWidth', null); + var frameHeight = GetFastValue(config, 'frameHeight', frameWidth); + + // If missing we can't proceed + if (frameWidth === null) + { + throw new Error('TextureManager.SpriteSheet: Invalid frameWidth given.'); + } + + // Add in a __BASE entry (for the entire atlas) + var source = texture.source[sourceIndex]; + + texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); + + var startFrame = GetFastValue(config, 'startFrame', 0); + var endFrame = GetFastValue(config, 'endFrame', -1); + var margin = GetFastValue(config, 'margin', 0); + var spacing = GetFastValue(config, 'spacing', 0); + + var row = Math.floor((width - margin + spacing) / (frameWidth + spacing)); + var column = Math.floor((height - margin + spacing) / (frameHeight + spacing)); + var total = row * column; + + if (startFrame > total || startFrame < -total) + { + startFrame = 0; + } + + if (startFrame < 0) + { + // Allow negative skipframes. + startFrame = total + startFrame; + } + + if (endFrame !== -1) + { + total = startFrame + (endFrame + 1); + } + + var fx = margin; + var fy = margin; + var ax = 0; + var ay = 0; + + for (var i = 0; i < total; i++) + { + ax = 0; + ay = 0; + + var w = fx + frameWidth; + var h = fy + frameHeight; + + if (w > width) + { + ax = w - width; + } + + if (h > height) + { + ay = h - height; + } + + texture.add(i, sourceIndex, x + fx, y + fy, frameWidth - ax, frameHeight - ay); + + fx += frameWidth + spacing; + + if (fx + frameWidth > width) + { + fx = margin; + fy += frameHeight + spacing; + } + } + + return texture; +}; + +module.exports = SpriteSheet; + + +/***/ }), +/* 790 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Parses a Pyxel JSON object and adds the Frames to a Texture. + * + * @function Phaser.Textures.Parsers.Pyxel + * @memberOf Phaser.Textures.Parsers + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {object} json - The JSON data. + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var Pyxel = function (texture, json) +{ + // Malformed? There are a few keys to check here. + var signature = [ 'layers', 'tilewidth', 'tileheight', 'tileswide', 'tileshigh' ]; + + signature.forEach(function (key) + { + if (!json[key]) + { + // console.warn('Phaser.AnimationParser.JSONDataPyxel: Invalid Pyxel Tilemap JSON given, missing "' + key + '" key.'); + // console.log(json); + return; + } + }); + + // For this purpose, I only care about parsing tilemaps with a single layer. + if (json['layers'].length !== 1) + { + // console.warn('Phaser.AnimationParser.JSONDataPyxel: Too many layers, this parser only supports flat Tilemaps.'); + // console.log(json); + return; + } + + var data = new Phaser.FrameData(); + + var tileheight = json['tileheight']; + var tilewidth = json['tilewidth']; + + var frames = json['layers'][0]['tiles']; + var newFrame; + + for (var i = 0; i < frames.length; i++) + { + newFrame = data.addFrame(new Phaser.Frame( + i, + frames[i].x, + frames[i].y, + tilewidth, + tileheight, + 'frame_' + i // No names are included in pyxel tilemap data. + )); + + // No trim data is included. + newFrame.setTrim(false); + } + + return data; +}; + +module.exports = Pyxel; + + +/***/ }), +/* 791 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clone = __webpack_require__(55); + +/** + * Parses a Texture Atlas JSON Hash and adds the Frames to the Texture. + * JSON format expected to match that defined by Texture Packer, with the frames property containing an object of Frames. + * + * @function Phaser.Textures.Parsers.JSONHash + * @memberOf Phaser.Textures.Parsers + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {integer} sourceIndex - The index of the TextureSource. + * @param {object} json - The JSON data. + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var JSONHash = function (texture, sourceIndex, json) +{ + // Malformed? + if (!json['frames']) + { + console.warn('Invalid Texture Atlas JSON Hash given, missing \'frames\' Object'); + return; + } + + // Add in a __BASE entry (for the entire atlas) + var source = texture.source[sourceIndex]; + + texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); + + // By this stage frames is a fully parsed Object + var frames = json['frames']; + var newFrame; + + for (var key in frames) + { + var src = frames[key]; + + // The frame values are the exact coordinates to cut the frame out of the atlas from + newFrame = texture.add(key, sourceIndex, src.frame.x, src.frame.y, src.frame.w, src.frame.h); + + // These are the original (non-trimmed) sprite values + if (src.trimmed) + { + newFrame.setTrim( + src.sourceSize.w, + src.sourceSize.h, + src.spriteSourceSize.x, + src.spriteSourceSize.y, + src.spriteSourceSize.w, + src.spriteSourceSize.h + ); + } + + if (src.rotated) + { + newFrame.rotated = true; + newFrame.updateUVsInverted(); + } + + // Copy over any extra data + newFrame.customData = Clone(src); + } + + // Copy over any additional data that was in the JSON to Texture.customData + for (var dataKey in json) + { + if (dataKey === 'frames') + { + continue; + } + + if (Array.isArray(json[dataKey])) + { + texture.customData[dataKey] = json[dataKey].slice(0); + } + else + { + texture.customData[dataKey] = json[dataKey]; + } + } + + return texture; +}; + +module.exports = JSONHash; + + +/***/ }), +/* 792 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clone = __webpack_require__(55); + +/** + * Parses a Texture Atlas JSON Array and adds the Frames to the Texture. + * JSON format expected to match that defined by Texture Packer, with the frames property containing an array of Frames. + * + * @function Phaser.Textures.Parsers.JSONArray + * @memberOf Phaser.Textures.Parsers + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {integer} sourceIndex - The index of the TextureSource. + * @param {object} json - The JSON data. + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var JSONArray = function (texture, sourceIndex, json) +{ + // Malformed? + if (!json['frames'] && !json['textures']) + { + console.warn('Invalid Texture Atlas JSON Array given, missing \'frames\' and \'textures\' array'); + return; + } + + // Add in a __BASE entry (for the entire atlas) + var source = texture.source[sourceIndex]; + + texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); + + // By this stage frames is a fully parsed array + var frames = (Array.isArray(json.textures)) ? json.textures[sourceIndex].frames : json.frames; + + var newFrame; + + for (var i = 0; i < frames.length; i++) + { + var src = frames[i]; + + // The frame values are the exact coordinates to cut the frame out of the atlas from + newFrame = texture.add(src.filename, sourceIndex, src.frame.x, src.frame.y, src.frame.w, src.frame.h); + + // These are the original (non-trimmed) sprite values + if (src.trimmed) + { + newFrame.setTrim( + src.sourceSize.w, + src.sourceSize.h, + src.spriteSourceSize.x, + src.spriteSourceSize.y, + src.spriteSourceSize.w, + src.spriteSourceSize.h + ); + } + + if (src.rotated) + { + newFrame.rotated = true; + newFrame.updateUVsInverted(); + } + + if (src.anchor) + { + newFrame.customPivot = true; + newFrame.pivotX = src.anchor.x; + newFrame.pivotY = src.anchor.y; + } + + // Copy over any extra data + newFrame.customData = Clone(src); + } + + // Copy over any additional data that was in the JSON to Texture.customData + for (var dataKey in json) + { + if (dataKey === 'frames') + { + continue; + } + + if (Array.isArray(json[dataKey])) + { + texture.customData[dataKey] = json[dataKey].slice(0); + } + else + { + texture.customData[dataKey] = json[dataKey]; + } + } + + return texture; +}; + +module.exports = JSONArray; + + +/***/ }), +/* 793 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Adds an Image Element to a Texture. + * + * @function Phaser.Textures.Parsers.Image + * @memberOf Phaser.Textures.Parsers + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {integer} sourceIndex - The index of the TextureSource. + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var Image = function (texture, sourceIndex) +{ + var source = texture.source[sourceIndex]; + + texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); + + return texture; +}; + +module.exports = Image; + + +/***/ }), +/* 794 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Adds a Canvas Element to a Texture. + * + * @function Phaser.Textures.Parsers.Canvas + * @memberOf Phaser.Textures.Parsers + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {integer} sourceIndex - The index of the TextureSource. + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var Canvas = function (texture, sourceIndex) +{ + var source = texture.source[sourceIndex]; + + texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); + + return texture; +}; + +module.exports = Canvas; + + +/***/ }), +/* 795 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// These properties get injected into the Scene and map to local systems +// The map key is the property that is added to the Scene, the value is the Scene.Systems reference +// These defaults can be modified via the Scene config object + +var InjectionMap = { + + game: 'game', + + anims: 'anims', + cache: 'cache', + registry: 'registry', + sound: 'sound', + textures: 'textures', + + events: 'events', + cameras: 'cameras', + cameras3d: 'cameras3d', + add: 'add', + make: 'make', + scenePlugin: 'scene', + displayList: 'children', + lights: 'lights', + + data: 'data', + input: 'input', + load: 'load', + time: 'time', + tweens: 'tweens', + + arcadePhysics: 'physics', + impactPhysics: 'impact', + matterPhysics: 'matter' + +}; + +module.exports = InjectionMap; + + +/***/ }), +/* 796 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(2); + +/** + * Builds an array of which plugins (not including physics plugins) should be activated for the given Scene. + * + * @function Phaser.Scenes.GetScenePlugins + * @since 3.0.0 + * + * @param {Phaser.Scenes.Systems} sys - [description] + * + * @return {array} [description] + */ +var GetScenePlugins = function (sys) +{ + var defaultPlugins = sys.game.config.defaultPlugins; + var scenePlugins = GetFastValue(sys.settings, 'plugins', false); + + // Scene Plugins always override Default Plugins + if (Array.isArray(scenePlugins)) + { + return scenePlugins; + } + else if (defaultPlugins) + { + return defaultPlugins; + } + else + { + // No default plugins or plugins in this scene + return []; + } +}; + +module.exports = GetScenePlugins; + + +/***/ }), +/* 797 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(2); +var UppercaseFirst = __webpack_require__(285); + +/** + * Builds an array of which physics plugins should be activated for the given Scene. + * + * @function Phaser.Scenes.GetPhysicsPlugins + * @since 3.0.0 + * + * @param {Phaser.Scenes.Systems} sys - [description] + * + * @return {array} [description] + */ +var GetPhysicsPlugins = function (sys) +{ + var defaultSystem = sys.game.config.defaultPhysicsSystem; + var sceneSystems = GetFastValue(sys.settings, 'physics', false); + + if (!defaultSystem && !sceneSystems) + { + // No default physics system or systems in this scene + return; + } + + // Let's build the systems array + var output = []; + + if (defaultSystem) + { + output.push(UppercaseFirst(defaultSystem + 'Physics')); + } + + if (sceneSystems) + { + for (var key in sceneSystems) + { + key = UppercaseFirst(key.concat('Physics')); + + if (output.indexOf(key) === -1) + { + output.push(key); + } + } + } + + // An array of Physics systems to start for this Scene + return output; +}; + +module.exports = GetPhysicsPlugins; + + +/***/ }), +/* 798 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Used internally by the KeyboardManager. + * + * @function Phaser.Input.Keyboard.Keys.ProcessKeyUp + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.Key} key - [description] + * @param {KeyboardEvent} event - [description] + * + * @return {Phaser.Input.Keyboard.Key} [description] + */ +var ProcessKeyUp = function (key, event) +{ + key.originalEvent = event; + + if (key.preventDefault) + { + event.preventDefault(); + } + + if (!key.enabled) + { + return; + } + + key.isDown = false; + key.isUp = true; + key.timeUp = event.timeStamp; + key.duration = key.timeUp - key.timeDown; + key.repeats = 0; + + key._justDown = false; + key._justUp = true; + + return key; +}; + +module.exports = ProcessKeyUp; + + +/***/ }), +/* 799 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Used internally by the KeyboardManager. + * + * @function Phaser.Input.Keyboard.Keys.ProcessKeyDown + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.Key} key - [description] + * @param {KeyboardEvent} event - [description] + * + * @return {Phaser.Input.Keyboard.Key} [description] + */ +var ProcessKeyDown = function (key, event) +{ + key.originalEvent = event; + + if (key.preventDefault) + { + event.preventDefault(); + } + + if (!key.enabled) + { + return; + } + + key.altKey = event.altKey; + key.ctrlKey = event.ctrlKey; + key.shiftKey = event.shiftKey; + key.location = event.location; + + if (key.isDown === false) + { + key.isDown = true; + key.isUp = false; + key.timeDown = event.timeStamp; + key.duration = 0; + } + + key.repeats++; + + key._justDown = true; + key._justUp = false; + + return key; +}; + +module.exports = ProcessKeyDown; + + +/***/ }), +/* 800 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var KeyCodes = __webpack_require__(143); + +var KeyMap = {}; + +for (var key in KeyCodes) +{ + KeyMap[KeyCodes[key]] = key; +} + +module.exports = KeyMap; + + +/***/ }), +/* 801 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Used internally by the KeyCombo class. + * + * @function Phaser.Input.Keyboard.KeyCombo.ResetKeyCombo + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.KeyCombo} combo - The KeyCombo to reset. + * + * @return {Phaser.Input.Keyboard.KeyCombo} The KeyCombo. + */ +var ResetKeyCombo = function (combo) +{ + combo.current = combo.keyCodes[0]; + combo.index = 0; + combo.timeLastMatched = 0; + combo.matched = false; + combo.timeMatched = 0; + + return combo; +}; + +module.exports = ResetKeyCombo; + + +/***/ }), +/* 802 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Used internally by the KeyCombo class. + * Return `true` if it reached the end of the combo, `false` if not. + * + * @function Phaser.Input.Keyboard.KeyCombo.AdvanceKeyCombo + * @since 3.0.0 + * + * @param {KeyboardEvent} event - [description] + * @param {Phaser.Input.Keyboard.KeyCombo} combo - [description] + * + * @return {boolean} `true` if it reached the end of the combo, `false` if not. + */ +var AdvanceKeyCombo = function (event, combo) +{ + combo.timeLastMatched = event.timeStamp; + combo.index++; + + if (combo.index === combo.size) + { + return true; + } + else + { + combo.current = combo.keyCodes[combo.index]; + return false; + } +}; + +module.exports = AdvanceKeyCombo; + + +/***/ }), +/* 803 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var AdvanceKeyCombo = __webpack_require__(802); + +/** + * Used internally by the KeyCombo class. + * + * @function Phaser.Input.Keyboard.KeyCombo.ProcessKeyCombo + * @since 3.0.0 + * + * @param {KeyboardEvent} event - [description] + * @param {Phaser.Input.Keyboard.KeyCombo} combo - [description] + * + * @return {boolean} [description] + */ +var ProcessKeyCombo = function (event, combo) +{ + if (combo.matched) + { + return true; + } + + var comboMatched = false; + var keyMatched = false; + + if (event.keyCode === combo.current) + { + // Key was correct + + if (combo.index > 0 && combo.maxKeyDelay > 0) + { + // We have to check to see if the delay between + // the new key and the old one was too long (if enabled) + + var timeLimit = combo.timeLastMatched + combo.maxKeyDelay; + + // Check if they pressed it in time or not + if (event.timeStamp <= timeLimit) + { + keyMatched = true; + comboMatched = AdvanceKeyCombo(event, combo); + } + } + else + { + keyMatched = true; + + // We don't check the time for the first key pressed, so just advance it + comboMatched = AdvanceKeyCombo(event, combo); + } + } + + if (!keyMatched && combo.resetOnWrongKey) + { + // Wrong key was pressed + combo.index = 0; + combo.current = combo.keyCodes[0]; + } + + if (comboMatched) + { + combo.timeLastMatched = event.timeStamp; + combo.matched = true; + combo.timeMatched = event.timeStamp; + } + + return comboMatched; +}; + +module.exports = ProcessKeyCombo; + + +/***/ }), +/* 804 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Determines the full screen support of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.fullscreen` from within any Scene. + * + * @name Phaser.Device.Fullscreen + * @since 3.0.0 + * + * @type {object} + * @property {boolean} available - Does the browser support the Full Screen API? + * @property {boolean} keyboard - Does the browser support access to the Keyboard during Full Screen mode? + * @property {string} cancel - If the browser supports the Full Screen API this holds the call you need to use to cancel it. + * @property {string} request - If the browser supports the Full Screen API this holds the call you need to use to activate it. + */ +var Fullscreen = { + + available: false, + cancel: '', + keyboard: false, + request: '' + +}; + +/** +* Checks for support of the Full Screen API. +*/ +function init () +{ + var i; + + var fs = [ + 'requestFullscreen', + 'requestFullScreen', + 'webkitRequestFullscreen', + 'webkitRequestFullScreen', + 'msRequestFullscreen', + 'msRequestFullScreen', + 'mozRequestFullScreen', + 'mozRequestFullscreen' + ]; + + var element = document.createElement('div'); + + for (i = 0; i < fs.length; i++) + { + if (element[fs[i]]) + { + Fullscreen.available = true; + Fullscreen.request = fs[i]; + break; + } + } + + var cfs = [ + 'cancelFullScreen', + 'exitFullscreen', + 'webkitCancelFullScreen', + 'webkitExitFullscreen', + 'msCancelFullScreen', + 'msExitFullscreen', + 'mozCancelFullScreen', + 'mozExitFullscreen' + ]; + + if (Fullscreen.available) + { + for (i = 0; i < cfs.length; i++) + { + if (document[cfs[i]]) + { + Fullscreen.cancel = cfs[i]; + break; + } + } + } + + // Keyboard Input? + if (window['Element'] && Element['ALLOW_KEYBOARD_INPUT']) + { + Fullscreen.keyboard = true; + } + + return Fullscreen; +} + +module.exports = init(); + + +/***/ }), +/* 805 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Determines the video support of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.video` from within any Scene. + * + * @name Phaser.Device.Video + * @since 3.0.0 + * + * @type {object} + * @property {boolean} h264Video - Can this device play h264 mp4 video files? + * @property {boolean} hlsVideo - Can this device play hls video files? + * @property {boolean} mp4Video - Can this device play h264 mp4 video files? + * @property {boolean} oggVideo - Can this device play ogg video files? + * @property {boolean} vp9Video - Can this device play vp9 video files? + * @property {boolean} webmVideo - Can this device play webm video files? + */ +var Video = { + + h264Video: false, + hlsVideo: false, + mp4Video: false, + oggVideo: false, + vp9Video: false, + webmVideo: false + +}; + +function init () +{ + var videoElement = document.createElement('video'); + var result = !!videoElement.canPlayType; + + try + { + if (result) + { + if (videoElement.canPlayType('video/ogg; codecs="theora"').replace(/^no$/, '')) + { + Video.oggVideo = true; + } + + if (videoElement.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/, '')) + { + // Without QuickTime, this value will be `undefined`. github.com/Modernizr/Modernizr/issues/546 + Video.h264Video = true; + Video.mp4Video = true; + } + + if (videoElement.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/, '')) + { + Video.webmVideo = true; + } + + if (videoElement.canPlayType('video/webm; codecs="vp9"').replace(/^no$/, '')) + { + Video.vp9Video = true; + } + + if (videoElement.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(/^no$/, '')) + { + Video.hlsVideo = true; + } + } + } + catch (e) + { + // Nothing to do + } + + return Video; +} + +module.exports = init(); + + +/***/ }), +/* 806 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Browser = __webpack_require__(100); + +/** + * Determines the audio playback capabilities of the device running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.audio` from within any Scene. + * + * @name Phaser.Device.Audio + * @since 3.0.0 + * + * @type {object} + * @property {boolean} audioData - Can this device play HTML Audio tags? + * @property {boolean} dolby - Can this device play EC-3 Dolby Digital Plus files? + * @property {boolean} m4a - Can this device can play m4a files. + * @property {boolean} mp3 - Can this device play mp3 files? + * @property {boolean} ogg - Can this device play ogg files? + * @property {boolean} opus - Can this device play opus files? + * @property {boolean} wav - Can this device play wav files? + * @property {boolean} webAudio - Does this device have the Web Audio API? + * @property {boolean} webm - Can this device play webm files? + */ +var Audio = { + + audioData: false, + dolby: false, + m4a: false, + mp3: false, + ogg: false, + opus: false, + wav: false, + webAudio: false, + webm: false + +}; + +function init () +{ + Audio.audioData = !!(window['Audio']); + + Audio.webAudio = !!(window['AudioContext'] || window['webkitAudioContext']); + + var audioElement = document.createElement('audio'); + + var result = !!audioElement.canPlayType; + + try + { + if (result) + { + if (audioElement.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) + { + Audio.ogg = true; + } + + if (audioElement.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, '') || audioElement.canPlayType('audio/opus;').replace(/^no$/, '')) + { + Audio.opus = true; + } + + if (audioElement.canPlayType('audio/mpeg;').replace(/^no$/, '')) + { + Audio.mp3 = true; + } + + // Mimetypes accepted: + // developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements + // bit.ly/iphoneoscodecs + if (audioElement.canPlayType('audio/wav; codecs="1"').replace(/^no$/, '')) + { + Audio.wav = true; + } + + if (audioElement.canPlayType('audio/x-m4a;') || audioElement.canPlayType('audio/aac;').replace(/^no$/, '')) + { + Audio.m4a = true; + } + + if (audioElement.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, '')) + { + Audio.webm = true; + } + + if (audioElement.canPlayType('audio/mp4;codecs="ec-3"') !== '') + { + if (Browser.edge) + { + Audio.dolby = true; + } + else if (Browser.safari && Browser.safariVersion >= 9) + { + if ((/Mac OS X (\d+)_(\d+)/).test(navigator.userAgent)) + { + var major = parseInt(RegExp.$1, 10); + var minor = parseInt(RegExp.$2, 10); + + if ((major === 10 && minor >= 11) || major > 10) + { + Audio.dolby = true; + } + } + } + } + } + } + catch (e) + { + // Nothing to do here + } + + return Audio; +} + +module.exports = init(); + + +/***/ }), +/* 807 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var OS = __webpack_require__(76); +var Browser = __webpack_require__(100); + +/** + * Determines the input support of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.input` from within any Scene. + * + * @name Phaser.Device.Input + * @since 3.0.0 + * + * @type {object} + * @property {?string} wheelType - The newest type of Wheel/Scroll event supported: 'wheel', 'mousewheel', 'DOMMouseScroll' + * @property {boolean} gamepads - Is navigator.getGamepads available? + * @property {boolean} mspointer - Is mspointer available? + * @property {boolean} touch - Is touch available? + */ +var Input = { + + gamepads: false, + mspointer: false, + touch: false, + wheelEvent: null + +}; + +function init () +{ + if ('ontouchstart' in document.documentElement || (navigator.maxTouchPoints && navigator.maxTouchPoints >= 1)) + { + Input.touch = true; + } + + if (navigator.msPointerEnabled || navigator.pointerEnabled) + { + Input.mspointer = true; + } + + if (navigator.getGamepads) + { + Input.gamepads = true; + } + + if (!OS.cocoonJS) + { + // See https://developer.mozilla.org/en-US/docs/Web/Events/wheel + if ('onwheel' in window || (Browser.ie && 'WheelEvent' in window)) + { + // DOM3 Wheel Event: FF 17+, IE 9+, Chrome 31+, Safari 7+ + Input.wheelEvent = 'wheel'; + } + else if ('onmousewheel' in window) + { + // Non-FF legacy: IE 6-9, Chrome 1-31, Safari 5-7. + Input.wheelEvent = 'mousewheel'; + } + else if (Browser.firefox && 'MouseScrollEvent' in window) + { + // FF prior to 17. This should probably be scrubbed. + Input.wheelEvent = 'DOMMouseScroll'; + } + } + + return Input; +} + +module.exports = init(); + + +/***/ }), +/* 808 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// This singleton is instantiated as soon as Phaser loads, +// before a Phaser.Game instance has even been created. +// Which means all instances of Phaser Games can share it, +// without having to re-poll the device all over again + +/** + * @namespace Phaser.Device + * @since 3.0.0 + */ + +/** + * @typedef {object} Phaser.DeviceConf + * + * @property {Phaser.Device.OS} os - The OS Device functions. + * @property {Phaser.Device.Browser} browser - The Browser Device functions. + * @property {Phaser.Device.Features} features - The Features Device functions. + * @property {Phaser.Device.Input} input - The Input Device functions. + * @property {Phaser.Device.Audio} audio - The Audio Device functions. + * @property {Phaser.Device.Video} video - The Video Device functions. + * @property {Phaser.Device.Fullscreen} fullscreen - The Fullscreen Device functions. + * @property {Phaser.Device.CanvasFeatures} canvasFeatures - The Canvas Device functions. + */ + +module.exports = { + + os: __webpack_require__(76), + browser: __webpack_require__(100), + features: __webpack_require__(146), + input: __webpack_require__(807), + audio: __webpack_require__(806), + video: __webpack_require__(805), + fullscreen: __webpack_require__(804), + canvasFeatures: __webpack_require__(302) + +}; + + +/***/ }), +/* 809 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(21); + +/** + * Called automatically by Phaser.Game and responsible for creating the console.log debug header. + * + * You can customize or disable the header via the Game Config object. + * + * @function Phaser.Boot.DebugHeader + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Phaser.Game instance which will output this debug header. + */ +var DebugHeader = function (game) +{ + var config = game.config; + + if (config.hideBanner) + { + return; + } + + var renderType = 'WebGL'; + + if (config.renderType === CONST.CANVAS) + { + renderType = 'Canvas'; + } + else if (config.renderType === CONST.HEADLESS) + { + renderType = 'Headless'; + } + + var audioConfig = config.audio; + var deviceAudio = game.device.audio; + + var audioType; + + if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio)) + { + audioType = 'Web Audio'; + } + else if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) + { + audioType = 'No Audio'; + } + else + { + audioType = 'HTML5 Audio'; + } + + if (!game.device.browser.ie) + { + var c = ''; + var args = [ c ]; + + if (Array.isArray(config.bannerBackgroundColor)) + { + var lastColor; + + config.bannerBackgroundColor.forEach(function (color) + { + c = c.concat('%c '); + + args.push('background: ' + color); + + lastColor = color; + + }); + + // inject the text color + args[args.length - 1] = 'color: ' + config.bannerTextColor + '; background: ' + lastColor; + } + else + { + c = c.concat('%c '); + + args.push('color: ' + config.bannerTextColor + '; background: ' + config.bannerBackgroundColor); + } + + // URL link background color (always white) + args.push('background: #fff'); + + if (config.gameTitle) + { + c = c.concat(config.gameTitle); + + if (config.gameVersion) + { + c = c.concat(' v' + config.gameVersion); + } + + if (!config.hidePhaser) + { + c = c.concat(' / '); + } + } + + if (!config.hidePhaser) + { + c = c.concat('Phaser v' + CONST.VERSION + ' (' + renderType + ' | ' + audioType + ')'); + } + + c = c.concat(' %c ' + config.gameURL); + + // Inject the new string back into the args array + args[0] = c; + + console.log.apply(console, args); + } + else if (window['console']) + { + console.log('Phaser v' + CONST.VERSION + ' / https://phaser.io'); + } +}; + +module.exports = DebugHeader; + + +/***/ }), +/* 810 */ +/***/ (function(module, exports) { + +module.exports = "#define SHADER_NAME PHASER_TEXTURE_TINT_VS\r\n\r\nprecision mediump float;\r\n\r\nuniform mat4 uProjectionMatrix;\r\nuniform mat4 uViewMatrix;\r\nuniform mat4 uModelMatrix;\r\n\r\nattribute vec2 inPosition;\r\nattribute vec2 inTexCoord;\r\nattribute vec4 inTint;\r\n\r\nvarying vec2 outTexCoord;\r\nvarying vec4 outTint;\r\n\r\nvoid main () \r\n{\r\n gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);\r\n outTexCoord = inTexCoord;\r\n outTint = inTint;\r\n}\r\n\r\n" + +/***/ }), +/* 811 */ +/***/ (function(module, exports) { + +module.exports = "#define SHADER_NAME PHASER_TEXTURE_TINT_FS\r\n\r\nprecision mediump float;\r\n\r\nuniform sampler2D uMainSampler;\r\n\r\nvarying vec2 outTexCoord;\r\nvarying vec4 outTint;\r\n\r\nvoid main() \r\n{\r\n vec4 texel = texture2D(uMainSampler, outTexCoord);\r\n texel *= vec4(outTint.rgb * outTint.a, outTint.a);\r\n gl_FragColor = texel;\r\n}\r\n" + +/***/ }), +/* 812 */ +/***/ (function(module, exports) { + +module.exports = "#define SHADER_NAME PHASER_FORWARD_DIFFUSE_FS\r\n\r\nprecision mediump float;\r\n\r\nstruct Light\r\n{\r\n vec2 position;\r\n vec3 color;\r\n float intensity;\r\n float radius;\r\n};\r\n\r\nconst int kMaxLights = %LIGHT_COUNT%;\r\n\r\nuniform vec4 uCamera; /* x, y, rotation, zoom */\r\nuniform vec2 uResolution;\r\nuniform sampler2D uMainSampler;\r\nuniform sampler2D uNormSampler;\r\nuniform vec3 uAmbientLightColor;\r\nuniform Light uLights[kMaxLights];\r\n\r\nvarying vec2 outTexCoord;\r\nvarying vec4 outTint;\r\n\r\nvoid main()\r\n{\r\n vec3 finalColor = vec3(0.0, 0.0, 0.0);\r\n vec4 color = texture2D(uMainSampler, outTexCoord) * vec4(outTint.rgb * outTint.a, outTint.a);\r\n vec3 normalMap = texture2D(uNormSampler, outTexCoord).rgb;\r\n vec3 normal = normalize(vec3(normalMap * 2.0 - 1.0));\r\n vec2 res = vec2(min(uResolution.x, uResolution.y)) * uCamera.w;\r\n\r\n for (int index = 0; index < kMaxLights; ++index)\r\n {\r\n Light light = uLights[index];\r\n vec3 lightDir = vec3((light.position.xy / res) - (gl_FragCoord.xy / res), 0.1);\r\n vec3 lightNormal = normalize(lightDir);\r\n float distToSurf = length(lightDir) * uCamera.w;\r\n float diffuseFactor = max(dot(normal, lightNormal), 0.0);\r\n float radius = (light.radius / res.x * uCamera.w) * uCamera.w;\r\n float attenuation = clamp(1.0 - distToSurf * distToSurf / (radius * radius), 0.0, 1.0);\r\n vec3 diffuse = light.color * diffuseFactor;\r\n finalColor += (attenuation * diffuse) * light.intensity;\r\n }\r\n\r\n vec4 colorOutput = vec4(uAmbientLightColor + finalColor, 1.0);\r\n gl_FragColor = color * vec4(colorOutput.rgb * colorOutput.a, colorOutput.a);\r\n\r\n}\r\n" + +/***/ }), +/* 813 */ +/***/ (function(module, exports) { + +module.exports = "#define SHADER_NAME PHASER_FLAT_TINT_VS\r\n\r\nprecision mediump float;\r\n\r\nuniform mat4 uProjectionMatrix;\r\nuniform mat4 uViewMatrix;\r\nuniform mat4 uModelMatrix;\r\n\r\nattribute vec2 inPosition;\r\nattribute vec4 inTint;\r\n\r\nvarying vec4 outTint;\r\n\r\nvoid main () {\r\n gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);\r\n outTint = inTint;\r\n}\r\n" + +/***/ }), +/* 814 */ +/***/ (function(module, exports) { + +module.exports = "#define SHADER_NAME PHASER_FLAT_TINT_FS\r\n\r\nprecision mediump float;\r\n\r\nvarying vec4 outTint;\r\n\r\nvoid main() {\r\n gl_FragColor = vec4(outTint.rgb * outTint.a, outTint.a);\r\n}\r\n" + +/***/ }), +/* 815 */ +/***/ (function(module, exports) { + +module.exports = "#define SHADER_NAME PHASER_BITMAP_MASK_VS\r\n\r\nprecision mediump float;\r\n\r\nattribute vec2 inPosition;\r\n\r\nvoid main()\r\n{\r\n gl_Position = vec4(inPosition, 0.0, 1.0);\r\n}\r\n" + +/***/ }), +/* 816 */ +/***/ (function(module, exports) { + +module.exports = "#define SHADER_NAME PHASER_BITMAP_MASK_FS\r\n\r\nprecision mediump float;\r\n\r\nuniform vec2 uResolution;\r\nuniform sampler2D uMainSampler;\r\nuniform sampler2D uMaskSampler;\r\nuniform bool uInvertMaskAlpha;\r\n\r\nvoid main()\r\n{\r\n vec2 uv = gl_FragCoord.xy / uResolution;\r\n vec4 mainColor = texture2D(uMainSampler, uv);\r\n vec4 maskColor = texture2D(uMaskSampler, uv);\r\n float alpha = mainColor.a;\r\n\r\n if (!uInvertMaskAlpha)\r\n {\r\n alpha *= (maskColor.a);\r\n }\r\n else\r\n {\r\n alpha *= (1.0 - maskColor.a);\r\n }\r\n \r\n gl_FragColor = vec4(mainColor.rgb * alpha, alpha);\r\n}\r\n" + +/***/ }), +/* 817 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasInterpolation = __webpack_require__(313); +var CanvasPool = __webpack_require__(23); +var CONST = __webpack_require__(21); +var Features = __webpack_require__(146); + +/** + * Called automatically by Phaser.Game and responsible for creating the renderer it will use. + * + * Relies upon two webpack global flags to be defined: `WEBGL_RENDERER` and `CANVAS_RENDERER` during build time, but not at run-time. + * + * @function Phaser.Boot.CreateRenderer + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Phaser.Game instance on which the renderer will be set. + */ +var CreateRenderer = function (game) +{ + var config = game.config; + + // Game either requested Canvas, + // or requested AUTO or WEBGL but the browser doesn't support it, so fall back to Canvas + + if (config.renderType !== CONST.HEADLESS) + { + if (config.renderType === CONST.CANVAS || (config.renderType !== CONST.CANVAS && !Features.webGL)) + { + if (Features.canvas) + { + // They requested Canvas and their browser supports it + config.renderType = CONST.CANVAS; + } + else + { + throw new Error('Cannot create Canvas or WebGL context, aborting.'); + } + } + else + { + // Game requested WebGL and browser says it supports it + config.renderType = CONST.WEBGL; + } + } + + // Pixel Art mode? + if (config.pixelArt) + { + CanvasPool.disableSmoothing(); + } + + // Does the game config provide its own canvas element to use? + if (config.canvas) + { + game.canvas = config.canvas; + } + else + { + game.canvas = CanvasPool.create(game, config.width, config.height, config.renderType); + } + + // Does the game config provide some canvas css styles to use? + if (config.canvasStyle) + { + game.canvas.style = config.canvasStyle; + } + + // Pixel Art mode? + if (config.pixelArt) + { + CanvasInterpolation.setCrisp(game.canvas); + } + + // Zoomed? + if (config.zoom !== 1) + { + game.canvas.style.width = (config.width * config.zoom).toString() + 'px'; + game.canvas.style.height = (config.height * config.zoom).toString() + 'px'; + } + + if (config.renderType === CONST.HEADLESS) + { + // Nothing more to do here + return; + } + + var CanvasRenderer; + var WebGLRenderer; + + if (true) + { + CanvasRenderer = __webpack_require__(380); + WebGLRenderer = __webpack_require__(375); + + // Let the config pick the renderer type, both are included + if (config.renderType === CONST.WEBGL) + { + game.renderer = new WebGLRenderer(game); + game.context = null; + } + else + { + game.renderer = new CanvasRenderer(game); + game.context = game.renderer.gameContext; + } + } + + if (false) + {} + + if (false) + {} +}; + +module.exports = CreateRenderer; + + +/***/ }), +/* 818 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(21); +var GetValue = __webpack_require__(5); +var MATH = __webpack_require__(16); +var NOOP = __webpack_require__(3); +var Plugins = __webpack_require__(303); +var ValueToColor = __webpack_require__(156); + +/** + * This callback type is completely empty, a no-operation. + * + * @callback NOOP + */ + +/** + * @callback BootCallback + * + * @param {Phaser.Game} game - [description] + */ + +/** + * @typedef {object} FPSConfig + * + * @property {integer} [min=10] - [description] + * @property {integer} [target=60] - [description] + * @property {boolean} [forceSetTimeOut=false] - [description] + * @property {integer} [deltaHistory=10] - [description] + * @property {integer} [panicMax=120] - [description] + */ + +/** + * @typedef {object} LoaderConfig + * + * @property {string} [baseURL] - [description] + * @property {string} [path] - [description] + * @property {boolean} [enableParallel=true] - [description] + * @property {integer} [maxParallelDownloads=4] - [description] + * @property {(string|undefined)} [crossOrigin=undefined] - [description] + * @property {string} [responseType] - [description] + * @property {boolean} [async=true] - [description] + * @property {string} [user] - [description] + * @property {string} [password] - [description] + * @property {integer} [timeout=0] - [description] + */ + +/** + * @typedef {object} GameConfig + * + * @property {(integer|string)} [width=1024] - [description] + * @property {(integer|string)} [height=768] - [description] + * @property {number} [zoom=1] - [description] + * @property {number} [resolution=1] - [description] + * @property {number} [type=CONST.AUTO] - [description] + * @property {object} [?parent=null] - [description] + * @property {HTMLCanvasElement} [?canvas=null] - [description] + * @property {string} [?canvasStyle=null] - [description] + * @property {object} [?scene=null] - [description] + * @property {string[]} [seed] - [description] + * @property {string} [title=''] - [description] + * @property {string} [url='http://phaser.io'] - [description] + * @property {string} [version=''] - [description] + * @property {object} [input] - [description] + * @property {boolean} [input.keyboard=true] - [description] + * @property {object} [input.keyboard.target=window] - [description] + * @property {boolean} [input.mouse=true] - [description] + * @property {object} [?input.mouse.target=null] - [description] + * @property {boolean} [input.touch=true] - [description] + * @property {object} [?input.touch.target=null] - [description] + * @property {object} [?input.touch.capture=true] - [description] + * @property {boolean} [input.gamepad=false] - [description] + * @property {boolean} [disableContextMenu=false] - [description] + * @property {boolean} [banner=false] - [description] + * @property {boolean} [banner.hidePhaser=false] - [description] + * @property {string} [banner.text='#ffffff'] - [description] + * @property {string[]} [banner.background] - [description] + * @property {FPSConfig} [?fps] - [description] + * @property {boolean} [antialias=true] - [description] + * @property {boolean} [pixelArt=false] - [description] + * @property {boolean} [autoResize=false] - [description] + * @property {boolean} [roundPixels=false] - [description] + * @property {boolean} [transparent=false] - [description] + * @property {boolean} [clearBeforeRender=true] - [description] + * @property {boolean} [premultipliedAlpha=true] - [description] + * @property {boolean} [preserveDrawingBuffer=false] - [description] + * @property {boolean} [failIfMajorPerformanceCaveat=false] - [description] + * @property {boolean} [powerPreference='default'] - "high-performance", "low-power" or "default" + * @property {(string|number)} [backgroundColor=0x000000] - [description] + * @property {object} [?callbacks] - [description] + * @property {BootCallback} [callbacks.preBoot=NOOP] - [description] + * @property {BootCallback} [callbacks.postBoot=NOOP] - [description] + * @property {LoaderConfig} [?loader] - [description] + * @property {object} [?images] - [description] + * @property {string} [images.default] - [description] + * @property {string} [images.missing] - [description] + */ + +/** + * @classdesc + * [description] + * + * @class Config + * @memberOf Phaser.Boot + * @constructor + * @since 3.0.0 + * + * @param {GameConfig} [GameConfig] - The configuration object for your Phaser Game instance. + * + */ +var Config = new Class({ + + initialize: + + function Config (config) + { + if (config === undefined) { config = {}; } + + var defaultBannerColor = [ + '#ff0000', + '#ffff00', + '#00ff00', + '#00ffff', + '#000000' + ]; + + var defaultBannerTextColor = '#ffffff'; + + this.width = GetValue(config, 'width', 1024); + this.height = GetValue(config, 'height', 768); + this.zoom = GetValue(config, 'zoom', 1); + + this.resolution = GetValue(config, 'resolution', 1); + + this.renderType = GetValue(config, 'type', CONST.AUTO); + + this.parent = GetValue(config, 'parent', null); + this.canvas = GetValue(config, 'canvas', null); + this.canvasStyle = GetValue(config, 'canvasStyle', null); + + this.sceneConfig = GetValue(config, 'scene', null); + + this.seed = GetValue(config, 'seed', [ (Date.now() * Math.random()).toString() ]); + + MATH.RND.init(this.seed); + + this.gameTitle = GetValue(config, 'title', ''); + this.gameURL = GetValue(config, 'url', 'https://phaser.io'); + this.gameVersion = GetValue(config, 'version', ''); + + // Input + this.inputKeyboard = GetValue(config, 'input.keyboard', true); + this.inputKeyboardEventTarget = GetValue(config, 'input.keyboard.target', window); + + this.inputMouse = GetValue(config, 'input.mouse', true); + this.inputMouseEventTarget = GetValue(config, 'input.mouse.target', null); + this.inputMouseCapture = GetValue(config, 'input.mouse.capture', true); + + this.inputTouch = GetValue(config, 'input.touch', true); + this.inputTouchEventTarget = GetValue(config, 'input.touch.target', null); + this.inputTouchCapture = GetValue(config, 'input.touch.capture', true); + + this.inputGamepad = GetValue(config, 'input.gamepad', false); + + this.disableContextMenu = GetValue(config, 'disableContextMenu', false); + + this.audio = GetValue(config, 'audio'); + + // If you do: { banner: false } it won't display any banner at all + this.hideBanner = (GetValue(config, 'banner', null) === false); + + this.hidePhaser = GetValue(config, 'banner.hidePhaser', false); + this.bannerTextColor = GetValue(config, 'banner.text', defaultBannerTextColor); + this.bannerBackgroundColor = GetValue(config, 'banner.background', defaultBannerColor); + + if (this.gameTitle === '' && this.hidePhaser) + { + this.hideBanner = true; + } + + // Frame Rate config + // fps: { + // min: 10, + // target: 60, + // forceSetTimeOut: false, + // deltaHistory: 10 + // } + + this.fps = GetValue(config, 'fps', null); + + // Renderer Settings + // These can either be in a `render` object within the Config, or specified on their own + + var renderConfig = GetValue(config, 'render', config); + + this.antialias = GetValue(renderConfig, 'antialias', true); + this.pixelArt = GetValue(renderConfig, 'pixelArt', false); + this.autoResize = GetValue(renderConfig, 'autoResize', false); + this.roundPixels = GetValue(renderConfig, 'roundPixels', false); + this.transparent = GetValue(renderConfig, 'transparent', false); + this.clearBeforeRender = GetValue(renderConfig, 'clearBeforeRender', true); + this.premultipliedAlpha = GetValue(renderConfig, 'premultipliedAlpha', true); + this.preserveDrawingBuffer = GetValue(renderConfig, 'preserveDrawingBuffer', false); + this.failIfMajorPerformanceCaveat = GetValue(renderConfig, 'failIfMajorPerformanceCaveat', false); + this.powerPreference = GetValue(renderConfig, 'powerPreference', 'default'); + + var bgc = GetValue(config, 'backgroundColor', 0); + + this.backgroundColor = ValueToColor(bgc); + + if (bgc === 0 && this.transparent) + { + this.backgroundColor.alpha = 0; + } + + // Callbacks + this.preBoot = GetValue(config, 'callbacks.preBoot', NOOP); + this.postBoot = GetValue(config, 'callbacks.postBoot', NOOP); + + // Physics + // physics: { + // system: 'impact', + // setBounds: true, + // gravity: 0, + // cellSize: 64 + // } + + this.physics = GetValue(config, 'physics', {}); + this.defaultPhysicsSystem = GetValue(this.physics, 'default', false); + + // Loader Defaults + this.loaderBaseURL = GetValue(config, 'loader.baseURL', ''); + this.loaderPath = GetValue(config, 'loader.path', ''); + this.loaderEnableParallel = GetValue(config, 'loader.enableParallel', true); + this.loaderMaxParallelDownloads = GetValue(config, 'loader.maxParallelDownloads', 4); + this.loaderCrossOrigin = GetValue(config, 'loader.crossOrigin', undefined); + this.loaderResponseType = GetValue(config, 'loader.responseType', ''); + this.loaderAsync = GetValue(config, 'loader.async', true); + this.loaderUser = GetValue(config, 'loader.user', ''); + this.loaderPassword = GetValue(config, 'loader.password', ''); + this.loaderTimeout = GetValue(config, 'loader.timeout', 0); + + // Scene Plugins + this.defaultPlugins = GetValue(config, 'plugins', Plugins.DefaultScene); + + // Default / Missing Images + var pngPrefix = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAg'; + + this.defaultImage = GetValue(config, 'images.default', pngPrefix + 'AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=='); + this.missingImage = GetValue(config, 'images.missing', pngPrefix + 'CAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg=='); + } + +}); + +module.exports = Config; + + +/***/ }), +/* 819 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var AddToDOM = __webpack_require__(147); +var AnimationManager = __webpack_require__(339); +var CacheManager = __webpack_require__(337); +var CanvasPool = __webpack_require__(23); +var Class = __webpack_require__(0); +var Config = __webpack_require__(818); +var CreateRenderer = __webpack_require__(817); +var DataManager = __webpack_require__(103); +var DebugHeader = __webpack_require__(809); +var Device = __webpack_require__(808); +var DOMContentLoaded = __webpack_require__(307); +var EventEmitter = __webpack_require__(15); +var InputManager = __webpack_require__(299); +var NOOP = __webpack_require__(3); +var PluginManager = __webpack_require__(12); +var SceneManager = __webpack_require__(287); +var SoundManagerCreator = __webpack_require__(283); +var TextureManager = __webpack_require__(276); +var TimeStep = __webpack_require__(785); +var VisibilityHandler = __webpack_require__(784); + +/** + * @callback GameStepCallback + */ + +/** + * @classdesc + * The Phaser.Game instance is the main controller for the entire Phaser game. It is responsible + * for handling the boot process, parsing the configuration values, creating the renderer, + * and setting-up all of the global Phaser systems, such as sound and input. + * Once that is complete it will start the Scene Manager and then begin the main game loop. + * + * You should generally avoid accessing any of the systems created by Game, and instead use those + * made available to you via the Phaser.Scene Systems class instead. + * + * @class Game + * @memberOf Phaser + * @constructor + * @since 3.0.0 + * + * @param {object} [GameConfig] - The configuration object for your Phaser Game instance. + */ +var Game = new Class({ + + initialize: + + function Game (config) + { + /** + * The parsed Game Configuration object. + * + * The values stored within this object are read-only and should not be changed at run-time. + * + * @name Phaser.Game#config + * @type {Phaser.Boot.Config} + * @readOnly + * @since 3.0.0 + */ + this.config = new Config(config); + + /** + * A reference to either the Canvas or WebGL Renderer that this Game is using. + * + * @name Phaser.Game#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.0.0 + */ + this.renderer = null; + + /** + * A reference to the HTML Canvas Element on which the renderer is drawing. + * + * @name Phaser.Game#canvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvas = null; + + /** + * A reference to the Canvas Rendering Context belonging to the Canvas Element this game is rendering to. + * + * @name Phaser.Game#context + * @type {CanvasRenderingContext2D} + * @since 3.0.0 + */ + this.context = null; + + /** + * A flag indicating when this Game instance has finished its boot process. + * + * @name Phaser.Game#isBooted + * @type {boolean} + * @readOnly + * @since 3.0.0 + */ + this.isBooted = false; + + /** + * A flag indicating if this Game is currently running its game step or not. + * + * @name Phaser.Game#isRunning + * @type {boolean} + * @readOnly + * @since 3.0.0 + */ + this.isRunning = false; + + /** + * An Event Emitter which is used to broadcast game-level events from the global systems. + * + * @name Phaser.Game#events + * @type {EventEmitter} + * @since 3.0.0 + */ + this.events = new EventEmitter(); + + /** + * An instance of the Animation Manager. + * + * The Animation Manager is a global system responsible for managing all animations used within your game. + * + * @name Phaser.Game#anims + * @type {Phaser.Animations.AnimationManager} + * @since 3.0.0 + */ + this.anims = new AnimationManager(this); + + /** + * An instance of the Texture Manager. + * + * The Texture Manager is a global system responsible for managing all textures being used by your game. + * + * @name Phaser.Game#textures + * @type {Phaser.Textures.TextureManager} + * @since 3.0.0 + */ + this.textures = new TextureManager(this); + + /** + * An instance of the Cache Manager. + * + * The Cache Manager is a global system responsible for caching, accessing and releasing external game assets. + * + * @name Phaser.Game#cache + * @type {Phaser.Cache.CacheManager} + * @since 3.0.0 + */ + this.cache = new CacheManager(this); + + /** + * [description] + * + * @name Phaser.Game#registry + * @type {Phaser.Data.DataManager} + * @since 3.0.0 + */ + this.registry = new DataManager(this); + + /** + * An instance of the Input Manager. + * + * The Input Manager is a global system responsible for the capture of browser-level input events. + * + * @name Phaser.Game#input + * @type {Phaser.Input.InputManager} + * @since 3.0.0 + */ + this.input = new InputManager(this, this.config); + + /** + * An instance of the Scene Manager. + * + * The Scene Manager is a global system responsible for creating, modifying and updating the Scenes in your game. + * + * @name Phaser.Game#scene + * @type {Phaser.Scenes.SceneManager} + * @since 3.0.0 + */ + this.scene = new SceneManager(this, this.config.sceneConfig); + + /** + * A reference to the Device inspector. + * + * Contains information about the device running this game, such as OS, browser vendor and feature support. + * Used by various systems to determine capabilities and code paths. + * + * @name Phaser.Game#device + * @type {Phaser.DeviceConf} + * @since 3.0.0 + */ + this.device = Device; + + /** + * An instance of the base Sound Manager. + * + * The Sound Manager is a global system responsible for the playback and updating of all audio in your game. + * + * @name Phaser.Game#sound + * @type {Phaser.BaseSoundManager} + * @since 3.0.0 + */ + this.sound = SoundManagerCreator.create(this); + + /** + * An instance of the Time Step. + * + * The Time Step is a global system responsible for setting-up and responding to the browser frame events, processing + * them and calculating delta values. It then automatically calls the game step. + * + * @name Phaser.Game#loop + * @type {Phaser.Boot.TimeStep} + * @since 3.0.0 + */ + this.loop = new TimeStep(this, this.config.fps); + + /** + * An instance of the Plugin Manager. + * + * The Plugin Manager is a global system that allows plugins to register themselves with it, and can then install + * those plugins into Scenes as required. + * + * @name Phaser.Game#plugins + * @type {Phaser.Boot.PluginManager} + * @since 3.0.0 + */ + this.plugins = new PluginManager(this, this.config); + + /** + * The `onStepCallback` is a callback that is fired each time the Time Step ticks. + * It is set automatically when the Game boot process has completed. + * + * @name Phaser.Game#onStepCallback + * @type {GameStepCallback} + * @private + * @since 3.0.0 + */ + this.onStepCallback = NOOP; + + // Wait for the DOM Ready event, then call boot. + DOMContentLoaded(this.boot.bind(this)); + }, + + /** + * Game boot event. + * + * This is an internal event dispatched when the game has finished booting, but before it is ready to start running. + * The global systems use this event to know when to set themselves up, dispatching their own `ready` events as required. + * + * @event Phaser.Game#boot + */ + + /** + * This method is called automatically when the DOM is ready. It is responsible for creating the renderer, + * displaying the Debug Header, adding the game canvas to the DOM and emitting the 'boot' event. + * It listens for a 'ready' event from the base systems and once received it will call `Game.start`. + * + * @method Phaser.Game#boot + * @protected + * @fires Phaser.Game#boot + * @since 3.0.0 + */ + boot: function () + { + this.isBooted = true; + + this.config.preBoot(this); + + CreateRenderer(this); + + DebugHeader(this); + + AddToDOM(this.canvas, this.config.parent); + + this.events.emit('boot'); + + // The Texture Manager has to wait on a couple of non-blocking events before it's fully ready, so it will emit this event + this.events.once('ready', this.start, this); + }, + + /** + * Called automatically by Game.boot once all of the global systems have finished setting themselves up. + * By this point the Game is now ready to start the main loop running. + * It will also enable the Visibility Handler. + * + * @method Phaser.Game#start + * @protected + * @since 3.0.0 + */ + start: function () + { + this.isRunning = true; + + this.config.postBoot(this); + + if (this.renderer) + { + this.loop.start(this.step.bind(this)); + } + else + { + this.loop.start(this.headlessStep.bind(this)); + } + + VisibilityHandler(this.events); + + this.events.on('hidden', this.onHidden, this); + this.events.on('visible', this.onVisible, this); + this.events.on('blur', this.onBlur, this); + this.events.on('focus', this.onFocus, this); + }, + + /** + * Game Pre-Render event. + * + * This event is dispatched immediately before any of the Scenes have started to render. + * The renderer will already have been initialized this frame, clearing itself and preparing to receive + * the Scenes for rendering, but it won't have actually drawn anything yet. + * + * @event Phaser.Game#prerenderEvent + * @param {(Phaser.Renderer.CanvasRenderer|Phaser.Renderer.WebGLRenderer)} renderer - A reference to the current renderer. + */ + + /** + * Game Post-Render event. + * + * This event is dispatched right at the end of the render process. + * Every Scene will have rendered and drawn to the canvas. + * + * @event Phaser.Game#postrenderEvent + * @param {(Phaser.Renderer.CanvasRenderer|Phaser.Renderer.WebGLRenderer)} renderer - A reference to the current renderer. + */ + + /** + * The main Game Step. Called automatically by the Time Step, once per browser frame (typically as a result of + * Request Animation Frame, or Set Timeout on very old browsers.) + * + * The step will update the global managers first, then proceed to update each Scene in turn, via the Scene Manager. + * + * It will then render each Scene in turn, via the Renderer. This process emits `prerender` and `postrender` events. + * + * @method Phaser.Game#step + * @fires Phaser.Game#prerenderEvent + * @fires Phaser.Game#postrenderEvent + * @since 3.0.0 + * + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + step: function (time, delta) + { + // Global Managers + + this.input.update(time, delta); + + this.sound.update(time, delta); + + // Scenes + + this.onStepCallback(); + + this.scene.update(time, delta); + + // Render + + var renderer = this.renderer; + + renderer.preRender(); + + this.events.emit('prerender', renderer); + + this.scene.render(renderer); + + renderer.postRender(); + + this.events.emit('postrender', renderer); + }, + + /** + * A special version of the Game Step for the HEADLESS renderer only. + * + * The main Game Step. Called automatically by the Time Step, once per browser frame (typically as a result of + * Request Animation Frame, or Set Timeout on very old browsers.) + * + * The step will update the global managers first, then proceed to update each Scene in turn, via the Scene Manager. + * + * This process emits `prerender` and `postrender` events, even though nothing actually displays. + * + * @method Phaser.Game#headlessStep + * @fires Phaser.Game#prerenderEvent + * @fires Phaser.Game#postrenderEvent + * @since 3.2.0 + * + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time elapsed since the last frame. + */ + headlessStep: function (time, delta) + { + // Global Managers + + this.input.update(time, delta); + + this.sound.update(time, delta); + + // Scenes + + this.onStepCallback(); + + this.scene.update(time, delta); + + // Render + + this.events.emit('prerender'); + + this.events.emit('postrender'); + }, + + /** + * Game Pause event. + * + * This event is dispatched when the game loop enters a paused state, usually as a result of the Visibility Handler. + * + * @event Phaser.Game#pauseEvent + */ + + /** + * Called automatically by the Visibility Handler. + * This will pause the main loop and then emit a pause event. + * + * @method Phaser.Game#onHidden + * @protected + * @fires Phaser.Game#pauseEvent + * @since 3.0.0 + */ + onHidden: function () + { + this.loop.pause(); + + this.events.emit('pause'); + }, + + /** + * Game Resume event. + * + * This event is dispatched when the game loop leaves a paused state and resumes running. + * + * @event Phaser.Game#resumeEvent + */ + + /** + * Called automatically by the Visibility Handler. + * This will resume the main loop and then emit a resume event. + * + * @method Phaser.Game#onVisible + * @protected + * @fires Phaser.Game#resumeEvent + * @since 3.0.0 + */ + onVisible: function () + { + this.loop.resume(); + + this.events.emit('resume'); + }, + + /** + * Called automatically by the Visibility Handler. + * This will set the main loop into a 'blurred' state, which pauses it. + * + * @method Phaser.Game#onBlur + * @protected + * @since 3.0.0 + */ + onBlur: function () + { + this.loop.blur(); + }, + + /** + * Called automatically by the Visibility Handler. + * This will set the main loop into a 'focused' state, which resumes it. + * + * @method Phaser.Game#onFocus + * @protected + * @since 3.0.0 + */ + onFocus: function () + { + this.loop.focus(); + }, + + /** + * Game Resize event. + * + * @event Phaser.Game#resizeEvent + * @param {number} width - The new width of the Game. + * @param {number} height - The new height of the Game. + */ + + /** + * Updates the Game Config with the new width and height values given. + * Then resizes the Renderer and Input Manager scale. + * + * @method Phaser.Game#resize + * @since 3.2.0 + * + * @param {number} width - The new width of the game. + * @param {number} height - The new height of the game. + */ + resize: function (width, height) + { + this.config.width = width; + this.config.height = height; + + this.renderer.resize(width, height); + + this.input.resize(); + + this.scene.resize(width, height); + + this.events.emit('resize', width, height); + }, + + /** + * Destroys this Phaser.Game instance, all global systems, all sub-systems and all Scenes. + * + * @method Phaser.Game#destroy + * @since 3.0.0 + */ + destroy: function (removeCanvas) + { + this.loop.destroy(); + + this.scene.destroy(); + + this.renderer.destroy(); + + this.events.emit('destroy'); + + this.events.removeAllListeners(); + + this.onStepCallback = null; + + if (removeCanvas) + { + CanvasPool.remove(this.canvas); + } + } + +}); + +module.exports = Game; + + +/***/ }), +/* 820 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var EE = __webpack_require__(15); +var PluginManager = __webpack_require__(12); + +/** + * @namespace Phaser.Events + */ + +/** + * @classdesc + * EventEmitter is a Scene Systems plugin compatible version of eventemitter3. + * + * @class EventEmitter + * @memberOf Phaser.Events + * @constructor + * @since 3.0.0 + */ +var EventEmitter = new Class({ + + Extends: EE, + + initialize: + + function EventEmitter () + { + EE.call(this); + }, + + /** + * Removes all listeners. + * + * @method Phaser.Events.EventEmitter#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.removeAllListeners(); + }, + + /** + * Removes all listeners. + * + * @method Phaser.Events.EventEmitter#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.removeAllListeners(); + } + +}); + +/** + * Return an array listing the events for which the emitter has registered listeners. + * + * @method Phaser.Events.EventEmitter#eventNames + * @since 3.0.0 + * + * @return {array} + */ + +/** + * Return the listeners registered for a given event. + * + * @method Phaser.Events.EventEmitter#listeners + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * + * @return {array} The registered listeners. + */ + +/** + * Return the number of listeners listening to a given event. + * + * @method Phaser.Events.EventEmitter#listenerCount + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * + * @return {number} The number of listeners. + */ + +/** + * Calls each of the listeners registered for a given event. + * + * @method Phaser.Events.EventEmitter#emit + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * + * @return {boolean} `true` if the event had listeners, else `false`. + */ + +/** + * Add a listener for a given event. + * + * @method Phaser.Events.EventEmitter#on + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} fn - The listener function. + * @param {*} [context=this] - The context to invoke the listener with. + * + * @return {Phaser.Events.EventEmitter} `this`. + */ + +/** + * Add a listener for a given event. + * + * @method Phaser.Events.EventEmitter#addListener + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} fn - The listener function. + * @param {*} [context=this] - The context to invoke the listener with. + * + * @return {Phaser.Events.EventEmitter} `this`. + */ + +/** + * Add a one-time listener for a given event. + * + * @method Phaser.Events.EventEmitter#once + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} fn - The listener function. + * @param {*} [context=this] - The context to invoke the listener with. + * + * @return {Phaser.Events.EventEmitter} `this`. + */ + +/** + * Remove the listeners of a given event. + * + * @method Phaser.Events.EventEmitter#removeListener + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} fn - Only remove the listeners that match this function. + * @param {*} context - Only remove the listeners that have this context. + * @param {boolean} once - Only remove one-time listeners. + * + * @return {Phaser.Events.EventEmitter} `this`. + */ + +/** + * Remove the listeners of a given event. + * + * @method Phaser.Events.EventEmitter#off + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} fn - Only remove the listeners that match this function. + * @param {*} context - Only remove the listeners that have this context. + * @param {boolean} once - Only remove one-time listeners. + * + * @return {Phaser.Events.EventEmitter} `this`. + */ + +/** + * Remove all listeners, or those of the specified event. + * + * @method Phaser.Events.EventEmitter#removeAllListeners + * @since 3.0.0 + * + * @param {(string|symbol)} [event] - The event name. + * + * @return {Phaser.Events.EventEmitter} `this`. + */ + +PluginManager.register('EventEmitter', EventEmitter, 'events'); + +module.exports = EventEmitter; + + +/***/ }), +/* 821 */ +/***/ (function(module, exports) { + +// shim for using process in browser +var process = module.exports = {}; + +// cached from whatever global is present so that test runners that stub it +// don't break things. But we need to wrap it in a try catch in case it is +// wrapped in strict mode code which doesn't define any globals. It's inside a +// function because try/catches deoptimize in certain engines. + +var cachedSetTimeout; +var cachedClearTimeout; + +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} + +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; +process.prependListener = noop; +process.prependOnceListener = noop; + +process.listeners = function (name) { return [] } + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + + +/***/ }), +/* 822 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.DOM + */ + +module.exports = { + + AddToDOM: __webpack_require__(147), + DOMContentLoaded: __webpack_require__(307), + ParseXML: __webpack_require__(306), + RemoveFromDOM: __webpack_require__(305), + RequestAnimationFrame: __webpack_require__(304) + +}; + + +/***/ }), +/* 823 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * [description] + * + * @class GeometryMask + * @memberOf Phaser.Display.Masks + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.GameObjects.Graphics} graphicsGeometry - [description] + */ +var GeometryMask = new Class({ + + initialize: + + function GeometryMask (scene, graphicsGeometry) + { + /** + * [description] + * + * @name Phaser.Display.Masks.GeometryMask#geometryMask + * @type {Phaser.GameObjects.Graphics} + * @since 3.0.0 + */ + this.geometryMask = graphicsGeometry; + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.GeometryMask#setShape + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphicsGeometry - [description] + */ + setShape: function (graphicsGeometry) + { + this.geometryMask = graphicsGeometry; + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.GeometryMask#preRenderWebGL + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + * @param {Phaser.GameObjects.GameObject} mask - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + preRenderWebGL: function (renderer, mask, camera) + { + var gl = renderer.gl; + var geometryMask = this.geometryMask; + + // Force flushing before drawing to stencil buffer + renderer.flush(); + + // Enable and setup GL state to write to stencil buffer + gl.enable(gl.STENCIL_TEST); + gl.clear(gl.STENCIL_BUFFER_BIT); + gl.colorMask(false, false, false, false); + gl.stencilFunc(gl.NOTEQUAL, 1, 1); + gl.stencilOp(gl.REPLACE, gl.REPLACE, gl.REPLACE); + + // Write stencil buffer + geometryMask.renderWebGL(renderer, geometryMask, 0.0, camera); + renderer.flush(); + + // Use stencil buffer to affect next rendering object + gl.colorMask(true, true, true, true); + gl.stencilFunc(gl.EQUAL, 1, 1); + gl.stencilOp(gl.INVERT, gl.INVERT, gl.INVERT); + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.GeometryMask#postRenderWebGL + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + */ + postRenderWebGL: function (renderer) + { + var gl = renderer.gl; + + // Force flush before disabling stencil test + renderer.flush(); + gl.disable(gl.STENCIL_TEST); + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.GeometryMask#preRenderCanvas + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + * @param {Phaser.GameObjects.GameObject} mask - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + preRenderCanvas: function (renderer, mask, camera) + { + var geometryMask = this.geometryMask; + + renderer.currentContext.save(); + + geometryMask.renderCanvas(renderer, geometryMask, 0.0, camera, null, true); + + renderer.currentContext.clip(); + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.GeometryMask#postRenderCanvas + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + */ + postRenderCanvas: function (renderer) + { + renderer.currentContext.restore(); + } + +}); + +module.exports = GeometryMask; + + +/***/ }), +/* 824 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * [description] + * + * @class BitmapMask + * @memberOf Phaser.Display.Masks + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.GameObjects.GameObject} renderable - A renderable Game Object that uses a texture, such as a Sprite. + */ +var BitmapMask = new Class({ + + initialize: + + function BitmapMask (scene, renderable) + { + var renderer = scene.sys.game.renderer; + + /** + * A renderable Game Object that uses a texture, such as a Sprite. + * + * @name Phaser.Display.Masks.BitmapMask#bitmapMask + * @type {Phaser.GameObjects.GameObject} + * @since 3.0.0 + */ + this.bitmapMask = renderable; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#maskTexture + * @type {WebGLTexture} + * @default null + * @since 3.0.0 + */ + this.maskTexture = null; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#mainTexture + * @type {WebGLTexture} + * @default null + * @since 3.0.0 + */ + this.mainTexture = null; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#dirty + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.dirty = true; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#mainFramebuffer + * @type {WebGLFramebuffer} + * @since 3.0.0 + */ + this.mainFramebuffer = null; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#maskFramebuffer + * @type {WebGLFramebuffer} + * @since 3.0.0 + */ + this.maskFramebuffer = null; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#invertAlpha + * @type {boolean} + * @since 3.1.2 + */ + this.invertAlpha = false; + + if (renderer && renderer.gl) + { + var width = renderer.width; + var height = renderer.height; + var pot = ((width & (width - 1)) === 0 && (height & (height - 1)) === 0); + var gl = renderer.gl; + var wrap = pot ? gl.REPEAT : gl.CLAMP_TO_EDGE; + var filter = gl.LINEAR; + + this.mainTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); + this.maskTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); + this.mainFramebuffer = renderer.createFramebuffer(width, height, this.mainTexture, false); + this.maskFramebuffer = renderer.createFramebuffer(width, height, this.maskTexture, false); + + renderer.onContextRestored(function (renderer) + { + var width = renderer.width; + var height = renderer.height; + var pot = ((width & (width - 1)) === 0 && (height & (height - 1)) === 0); + var gl = renderer.gl; + var wrap = pot ? gl.REPEAT : gl.CLAMP_TO_EDGE; + var filter = gl.LINEAR; + + this.mainTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); + this.maskTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); + this.mainFramebuffer = renderer.createFramebuffer(width, height, this.mainTexture, false); + this.maskFramebuffer = renderer.createFramebuffer(width, height, this.maskTexture, false); + + }, this); + } + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.BitmapMask#setBitmap + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} renderable - A renderable Game Object that uses a texture, such as a Sprite. + */ + setBitmap: function (renderable) + { + this.bitmapMask = renderable; + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.BitmapMask#preRenderWebGL + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + * @param {Phaser.GameObjects.GameObject} maskedObject - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to render to. + */ + preRenderWebGL: function (renderer, maskedObject, camera) + { + renderer.pipelines.BitmapMaskPipeline.beginMask(this, maskedObject, camera); + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.BitmapMask#postRenderWebGL + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + */ + postRenderWebGL: function (renderer) + { + renderer.pipelines.BitmapMaskPipeline.endMask(this); + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.BitmapMask#preRenderCanvas + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + * @param {Phaser.GameObjects.GameObject} mask - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to render to. + */ + preRenderCanvas: function () + { + // NOOP + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.BitmapMask#postRenderCanvas + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + */ + postRenderCanvas: function () + { + // NOOP + } + +}); + +module.exports = BitmapMask; + + +/***/ }), +/* 825 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Masks + */ + +module.exports = { + + BitmapMask: __webpack_require__(824), + GeometryMask: __webpack_require__(823) + +}; + + +/***/ }), +/* 826 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ComponentToHex = __webpack_require__(311); + +/** + * Converts the color values into an HTML compatible color string, prefixed with either `#` or `0x`. + * + * @function Phaser.Display.Color.RGBToString + * @since 3.0.0 + * + * @param {integer} r - The red color value. A number between 0 and 255. + * @param {integer} g - The green color value. A number between 0 and 255. + * @param {integer} b - The blue color value. A number between 0 and 255. + * @param {integer} [a=255] - The alpha value. A number between 0 and 255. + * @param {string} [prefix=#] - The prefix of the string. Either `#` or `0x`. + * + * @return {string} A string-based representation of the color values. + */ +var RGBToString = function (r, g, b, a, prefix) +{ + if (a === undefined) { a = 255; } + if (prefix === undefined) { prefix = '#'; } + + if (prefix === '#') + { + return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); + } + else + { + return '0x' + ComponentToHex(a) + ComponentToHex(r) + ComponentToHex(g) + ComponentToHex(b); + } +}; + +module.exports = RGBToString; + + +/***/ }), +/* 827 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} HSLColorObject + * + * @property {number} h - The hue color value. A number between 0 and 1 + * @property {number} s - The saturation color value. A number between 0 and 1 + * @property {number} l - The lightness color value. A number between 0 and 1 + */ + +/** + * Converts an RGB color value to HSV (hue, saturation and value). + * Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space. + * Assumes RGB values are contained in the set [0, 255] and returns h, s and v in the set [0, 1]. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * + * @function Phaser.Display.Color.RGBToHSV + * @since 3.0.0 + * + * @param {integer} r - The red color value. A number between 0 and 255. + * @param {integer} g - The green color value. A number between 0 and 255. + * @param {integer} b - The blue color value. A number between 0 and 255. + * + * @return {HSLColorObject} An object with the properties `h`, `s` and `v`. + */ +var RGBToHSV = function (r, g, b) +{ + r /= 255; + g /= 255; + b /= 255; + + var min = Math.min(r, g, b); + var max = Math.max(r, g, b); + var d = max - min; + + // achromatic by default + var h = 0; + var s = (max === 0) ? 0 : d / max; + var v = max; + + if (max !== min) + { + if (max === r) + { + h = (g - b) / d + ((g < b) ? 6 : 0); + } + else if (max === g) + { + h = (b - r) / d + 2; + } + else if (max === b) + { + h = (r - g) / d + 4; + } + + h /= 6; + } + + return { h: h, s: s, v: v }; +}; + +module.exports = RGBToHSV; + + +/***/ }), +/* 828 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Between = __webpack_require__(308); +var Color = __webpack_require__(41); + +/** + * Creates a new Color object where the r, g, and b values have been set to random values + * based on the given min max values. + * + * @function Phaser.Display.Color.RandomRGB + * @since 3.0.0 + * + * @param {integer} [min=0] - The minimum value to set the random range from (between 0 and 255) + * @param {integer} [max=255] - The maximum value to set the random range from (between 0 and 255) + * + * @return {Phaser.Display.Color} A Color object. + */ +var RandomRGB = function (min, max) +{ + if (min === undefined) { min = 0; } + if (max === undefined) { max = 255; } + + return new Color(Between(min, max), Between(min, max), Between(min, max)); +}; + +module.exports = RandomRGB; + + +/***/ }), +/* 829 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Linear = __webpack_require__(148); + +/** + * Interpolates color values + * + * @namespace Phaser.Display.Color.Interpolate + * @since 3.0.0 + */ + +/** + * Interpolates between the two given color ranges over the length supplied. + * + * @function Phaser.Display.Color.Interpolate.RGBWithRGB + * @since 3.0.0 + * + * @param {number} r1 - Red value. + * @param {number} g1 - Blue value. + * @param {number} b1 - Green value. + * @param {number} r2 - Red value. + * @param {number} g2 - Blue value. + * @param {number} b2 - Green value. + * @param {number} [length=100] - Distance to interpolate over. + * @param {number} [index=0] - Index to start from. + * + * @return {ColorObject} An object containing the interpolated color values. + */ +var RGBWithRGB = function (r1, g1, b1, r2, g2, b2, length, index) +{ + if (length === undefined) { length = 100; } + if (index === undefined) { index = 0; } + + var t = index / length; + + return { + r: Linear(r1, r2, t), + g: Linear(g1, g2, t), + b: Linear(b1, b2, t) + }; +}; + +/** + * Interpolates between the two given color objects over the length supplied. + * + * @function Phaser.Display.Color.Interpolate.ColorWithColor + * @since 3.0.0 + * + * @param {Phaser.Display.Color} color1 - The first Color object. + * @param {Phaser.Display.Color} color2 - The second Color object. + * @param {number} [length=100] - Distance to interpolate over. + * @param {number} [index=0] - Index to start from. + * + * @return {ColorObject} An object containing the interpolated color values. + */ +var ColorWithColor = function (color1, color2, length, index) +{ + if (length === undefined) { length = 100; } + if (index === undefined) { index = 0; } + + return RGBWithRGB(color1.r, color1.g, color1.b, color2.r, color2.g, color2.b, length, index); +}; + +/** + * Interpolates between the Color object and color values over the length supplied. + * + * @function Phaser.Display.Color.Interpolate.ColorWithRGB + * @since 3.0.0 + * + * @param {Phaser.Display.Color} color1 - The first Color object. + * @param {number} r - Red value. + * @param {number} g - Blue value. + * @param {number} b - Green value. + * @param {number} [length=100] - Distance to interpolate over. + * @param {number} [index=0] - Index to start from. + * + * @return {ColorObject} An object containing the interpolated color values. + */ +var ColorWithRGB = function (color, r, g, b, length, index) +{ + if (length === undefined) { length = 100; } + if (index === undefined) { index = 0; } + + return RGBWithRGB(color.r, color.g, color.b, r, g, b, length, index); +}; + +module.exports = { + + RGBWithRGB: RGBWithRGB, + ColorWithRGB: ColorWithRGB, + ColorWithColor: ColorWithColor + +}; + + +/***/ }), +/* 830 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var HSVToRGB = __webpack_require__(309); + +/** + * Get HSV color wheel values in an array which will be 360 elements in size. + * + * @function Phaser.Display.Color.HSVColorWheel + * @since 3.0.0 + * + * @param {number} [s=1] - The saturation, in the range 0 - 1. + * @param {number} [v=1] - The value, in the range 0 - 1. + * + * @return {array} An array containing 360 elements, where each contains a single numeric value corresponding to the color at that point in the HSV color wheel. + */ +var HSVColorWheel = function (s, v) +{ + if (s === undefined) { s = 1; } + if (v === undefined) { v = 1; } + + var colors = []; + + for (var c = 0; c <= 359; c++) + { + colors.push(HSVToRGB(c / 359, s, v)); + } + + return colors; +}; + +module.exports = HSVColorWheel; + + +/***/ }), +/* 831 */ +/***/ (function(module, exports) { + +module.exports = function(module) { + if (!module.webpackPolyfill) { + module.deprecate = function() {}; + module.paths = []; + // module.parent = undefined by default + if (!module.children) module.children = []; + Object.defineProperty(module, "loaded", { + enumerable: true, + get: function() { + return module.l; + } + }); + Object.defineProperty(module, "id", { + enumerable: true, + get: function() { + return module.i; + } + }); + module.webpackPolyfill = 1; + } + return module; +}; + + +/***/ }), +/* 832 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Color = __webpack_require__(41); +var HueToComponent = __webpack_require__(310); + +/** + * Converts HSL (hue, saturation and lightness) values to a Phaser Color object. + * + * @function Phaser.Display.Color.HSLToColor + * @since 3.0.0 + * + * @param {number} h - The hue value in the range 0 to 1. + * @param {number} s - The saturation value in the range 0 to 1. + * @param {number} l - The lightness value in the range 0 to 1. + * + * @return {Phaser.Display.Color} A Color object created from the results of the h, s and l values. + */ +var HSLToColor = function (h, s, l) +{ + // achromatic by default + var r = l; + var g = l; + var b = l; + + if (s !== 0) + { + var q = (l < 0.5) ? l * (1 + s) : l + s - l * s; + var p = 2 * l - q; + + r = HueToComponent(p, q, h + 1 / 3); + g = HueToComponent(p, q, h); + b = HueToComponent(p, q, h - 1 / 3); + } + + var color = new Color(); + + return color.setGLTo(r, g, b, 1); +}; + +module.exports = HSLToColor; + + +/***/ }), +/* 833 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts the given color value into an Object containing r,g,b and a properties. + * + * @function Phaser.Display.Color.ColorToRGBA + * @since 3.0.0 + * + * @param {number} color - A color value, optionally including the alpha value. + * + * @return {ColorObject} An object containing the parsed color values. + */ +var ColorToRGBA = function (color) +{ + var output = { + r: color >> 16 & 0xFF, + g: color >> 8 & 0xFF, + b: color & 0xFF, + a: 255 + }; + + if (color > 16777215) + { + output.a = color >>> 24; + } + + return output; +}; + +module.exports = ColorToRGBA; + + +/***/ }), +/* 834 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sets the user-select property on the canvas style. Can be used to disable default browser selection actions. + * + * @function Phaser.Display.Canvas.UserSelect + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The canvas element to have the style applied to. + * @param {string} [value='none'] - The touch callout value to set on the canvas. Set to `none` to disable touch callouts. + * + * @return {HTMLCanvasElement} The canvas element. + */ +var UserSelect = function (canvas, value) +{ + if (value === undefined) { value = 'none'; } + + var vendors = [ + '-webkit-', + '-khtml-', + '-moz-', + '-ms-', + '' + ]; + + vendors.forEach(function (vendor) + { + canvas.style[vendor + 'user-select'] = value; + }); + + canvas.style['-webkit-touch-callout'] = value; + canvas.style['-webkit-tap-highlight-color'] = 'rgba(0, 0, 0, 0)'; + + return canvas; +}; + +module.exports = UserSelect; + + +/***/ }), +/* 835 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions. + * + * @function Phaser.Display.Canvas.TouchAction + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The canvas element to have the style applied to. + * @param {string} [value='none'] - The touch action value to set on the canvas. Set to `none` to disable touch actions. + * + * @return {HTMLCanvasElement} The canvas element. + */ +var TouchAction = function (canvas, value) +{ + if (value === undefined) { value = 'none'; } + + canvas.style['msTouchAction'] = value; + canvas.style['ms-touch-action'] = value; + canvas.style['touch-action'] = value; + + return canvas; +}; + +module.exports = TouchAction; + + +/***/ }), +/* 836 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Canvas + */ + +module.exports = { + + Interpolation: __webpack_require__(313), + Pool: __webpack_require__(23), + Smoothing: __webpack_require__(151), + TouchAction: __webpack_require__(835), + UserSelect: __webpack_require__(834) + +}; + + +/***/ }), +/* 837 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the amount the Game Object is visually offset from its y coordinate. + * This is the same as `width * origin.y`. + * This value will only be > 0 if `origin.y` is not equal to zero. + * + * @function Phaser.Display.Bounds.GetOffsetY + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The vertical offset of the Game Object. + */ +var GetOffsetY = function (gameObject) +{ + return gameObject.height * gameObject.originY; +}; + +module.exports = GetOffsetY; + + +/***/ }), +/* 838 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the amount the Game Object is visually offset from its x coordinate. + * This is the same as `width * origin.x`. + * This value will only be > 0 if `origin.x` is not equal to zero. + * + * @function Phaser.Display.Bounds.GetOffsetX + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The horizontal offset of the Game Object. + */ +var GetOffsetX = function (gameObject) +{ + return gameObject.width * gameObject.originX; +}; + +module.exports = GetOffsetX; + + +/***/ }), +/* 839 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Bounds + */ + +module.exports = { + + CenterOn: __webpack_require__(361), + GetBottom: __webpack_require__(36), + GetCenterX: __webpack_require__(61), + GetCenterY: __webpack_require__(58), + GetLeft: __webpack_require__(34), + GetOffsetX: __webpack_require__(838), + GetOffsetY: __webpack_require__(837), + GetRight: __webpack_require__(32), + GetTop: __webpack_require__(30), + SetBottom: __webpack_require__(35), + SetCenterX: __webpack_require__(60), + SetCenterY: __webpack_require__(59), + SetLeft: __webpack_require__(33), + SetRight: __webpack_require__(31), + SetTop: __webpack_require__(29) + +}; + + +/***/ }), +/* 840 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetRight = __webpack_require__(32); +var GetTop = __webpack_require__(30); +var SetBottom = __webpack_require__(35); +var SetRight = __webpack_require__(31); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the top right position of the other. + * + * @function Phaser.Display.Align.To.TopRight + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopRight = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignTo) + offsetX); + SetBottom(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = TopRight; + + +/***/ }), +/* 841 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetLeft = __webpack_require__(34); +var GetTop = __webpack_require__(30); +var SetBottom = __webpack_require__(35); +var SetLeft = __webpack_require__(33); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the top left position of the other. + * + * @function Phaser.Display.Align.To.TopLeft + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopLeft = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignTo) - offsetX); + SetBottom(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = TopLeft; + + +/***/ }), +/* 842 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterX = __webpack_require__(61); +var GetTop = __webpack_require__(30); +var SetBottom = __webpack_require__(35); +var SetCenterX = __webpack_require__(60); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the top center position of the other. + * + * @function Phaser.Display.Align.To.TopCenter + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetCenterX(gameObject, GetCenterX(alignTo) + offsetX); + SetBottom(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = TopCenter; + + +/***/ }), +/* 843 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetRight = __webpack_require__(32); +var GetTop = __webpack_require__(30); +var SetLeft = __webpack_require__(33); +var SetTop = __webpack_require__(29); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the right top position of the other. + * + * @function Phaser.Display.Align.To.RightTop + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var RightTop = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetRight(alignTo) + offsetX); + SetTop(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = RightTop; + + +/***/ }), +/* 844 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterY = __webpack_require__(58); +var GetRight = __webpack_require__(32); +var SetCenterY = __webpack_require__(59); +var SetLeft = __webpack_require__(33); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the right center position of the other. + * + * @function Phaser.Display.Align.To.RightCenter + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var RightCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetRight(alignTo) + offsetX); + SetCenterY(gameObject, GetCenterY(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = RightCenter; + + +/***/ }), +/* 845 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(36); +var GetRight = __webpack_require__(32); +var SetBottom = __webpack_require__(35); +var SetLeft = __webpack_require__(33); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the right bottom position of the other. + * + * @function Phaser.Display.Align.To.RightBottom + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var RightBottom = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetRight(alignTo) + offsetX); + SetBottom(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = RightBottom; + + +/***/ }), +/* 846 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetLeft = __webpack_require__(34); +var GetTop = __webpack_require__(30); +var SetRight = __webpack_require__(31); +var SetTop = __webpack_require__(29); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the left top position of the other. + * + * @function Phaser.Display.Align.To.LeftTop + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var LeftTop = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetLeft(alignTo) - offsetX); + SetTop(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = LeftTop; + + +/***/ }), +/* 847 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterY = __webpack_require__(58); +var GetLeft = __webpack_require__(34); +var SetCenterY = __webpack_require__(59); +var SetRight = __webpack_require__(31); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the left center position of the other. + * + * @function Phaser.Display.Align.To.LeftCenter + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var LeftCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetLeft(alignTo) - offsetX); + SetCenterY(gameObject, GetCenterY(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = LeftCenter; + + +/***/ }), +/* 848 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(36); +var GetLeft = __webpack_require__(34); +var SetBottom = __webpack_require__(35); +var SetRight = __webpack_require__(31); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the left bottom position of the other. + * + * @function Phaser.Display.Align.To.LeftBottom + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var LeftBottom = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetLeft(alignTo) - offsetX); + SetBottom(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = LeftBottom; + + +/***/ }), +/* 849 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(36); +var GetRight = __webpack_require__(32); +var SetRight = __webpack_require__(31); +var SetTop = __webpack_require__(29); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the bottom right position of the other. + * + * @function Phaser.Display.Align.To.BottomRight + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomRight = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignTo) + offsetX); + SetTop(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = BottomRight; + + +/***/ }), +/* 850 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(36); +var GetLeft = __webpack_require__(34); +var SetLeft = __webpack_require__(33); +var SetTop = __webpack_require__(29); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the bottom left position of the other. + * + * @function Phaser.Display.Align.To.BottomLeft + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomLeft = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignTo) - offsetX); + SetTop(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = BottomLeft; + + +/***/ }), +/* 851 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(36); +var GetCenterX = __webpack_require__(61); +var SetCenterX = __webpack_require__(60); +var SetTop = __webpack_require__(29); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the bottom center position of the other. + * + * @function Phaser.Display.Align.To.BottomCenter + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetCenterX(gameObject, GetCenterX(alignTo) + offsetX); + SetTop(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = BottomCenter; + + +/***/ }), +/* 852 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Align.To + */ + +module.exports = { + + BottomCenter: __webpack_require__(851), + BottomLeft: __webpack_require__(850), + BottomRight: __webpack_require__(849), + LeftBottom: __webpack_require__(848), + LeftCenter: __webpack_require__(847), + LeftTop: __webpack_require__(846), + RightBottom: __webpack_require__(845), + RightCenter: __webpack_require__(844), + RightTop: __webpack_require__(843), + TopCenter: __webpack_require__(842), + TopLeft: __webpack_require__(841), + TopRight: __webpack_require__(840) + +}; + + +/***/ }), +/* 853 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Align.In + */ + +module.exports = { + + BottomCenter: __webpack_require__(365), + BottomLeft: __webpack_require__(364), + BottomRight: __webpack_require__(363), + Center: __webpack_require__(362), + LeftCenter: __webpack_require__(360), + QuickSet: __webpack_require__(366), + RightCenter: __webpack_require__(359), + TopCenter: __webpack_require__(358), + TopLeft: __webpack_require__(357), + TopRight: __webpack_require__(356) + +}; + + +/***/ }), +/* 854 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(169); +var Extend = __webpack_require__(18); + +/** + * @namespace Phaser.Display.Align + */ + +var Align = { + + In: __webpack_require__(853), + To: __webpack_require__(852) + +}; + +// Merge in the consts +Align = Extend(false, Align, CONST); + +module.exports = Align; + + +/***/ }), +/* 855 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display + */ + +module.exports = { + + Align: __webpack_require__(854), + Bounds: __webpack_require__(839), + Canvas: __webpack_require__(836), + Color: __webpack_require__(312), + Masks: __webpack_require__(825) + +}; + + +/***/ }), +/* 856 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var DataManager = __webpack_require__(103); +var PluginManager = __webpack_require__(12); + +/** + * @classdesc + * The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin. + * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter, + * or have a property called `events` that is an instance of it. + * + * @class DataManagerPlugin + * @extends Phaser.Data.DataManager + * @memberOf Phaser.Data + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ +var DataManagerPlugin = new Class({ + + Extends: DataManager, + + initialize: + + function DataManagerPlugin (scene) + { + /** + * [description] + * + * @name Phaser.Data.DataManagerPlugin#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Data.DataManagerPlugin#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + if (!scene.sys.settings.isBooted) + { + scene.sys.events.once('boot', this.boot, this); + } + + DataManager.call(this, this.scene, scene.sys.events); + }, + + /** + * [description] + * + * @method Phaser.Data.DataManagerPlugin#boot + * @since 3.0.0 + */ + boot: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on('shutdown', this.shutdownPlugin, this); + eventEmitter.on('destroy', this.destroyPlugin, this); + }, + + /** + * [description] + * + * @method Phaser.Data.DataManagerPlugin#shutdownPlugin + * @since 3.0.0 + */ + shutdownPlugin: function () + { + // Should we reset the events? + }, + + /** + * [description] + * + * @method Phaser.Data.DataManagerPlugin#destroyPlugin + * @since 3.0.0 + */ + destroyPlugin: function () + { + this.destroy(); + + this.scene = undefined; + this.systems = undefined; + } + +}); + +PluginManager.register('DataManagerPlugin', DataManagerPlugin, 'data'); + +module.exports = DataManagerPlugin; + + +/***/ }), +/* 857 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Data + */ + +module.exports = { + + DataManager: __webpack_require__(103), + DataManagerPlugin: __webpack_require__(856) + +}; + + +/***/ }), +/* 858 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Vector2 = __webpack_require__(6); + +/** + * @classdesc + * [description] + * + * @class MoveTo + * @memberOf Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {number} [x] - [description] + * @param {number} [y] - [description] + */ +var MoveTo = new Class({ + + initialize: + + function MoveTo (x, y) + { + // Skip length calcs in paths + + /** + * [description] + * + * @name Phaser.Curves.MoveTo#active + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.active = false; + + /** + * [description] + * + * @name Phaser.Curves.MoveTo#p0 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p0 = new Vector2(x, y); + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.MoveTo#getPoint + * @since 3.0.0 + * + * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.p0); + }, + + /** + * [description] + * + * @method Phaser.Curves.MoveTo#getPointAt + * @since 3.0.0 + * + * @param {float} u - [description] + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + getPointAt: function (u, out) + { + return this.getPoint(u, out); + }, + + /** + * Gets the resolution of this curve. + * + * @method Phaser.Curves.MoveTo#getResolution + * @since 3.0.0 + * + * @return {number} The resolution of this curve. For a MoveTo the value is always 1. + */ + getResolution: function () + { + return 1; + }, + + /** + * Gets the length of this curve. + * + * @method Phaser.Curves.MoveTo#getLength + * @since 3.0.0 + * + * @return {number} The length of this curve. For a MoveTo the value is always 0. + */ + getLength: function () + { + return 0; + }, + + /** + * [description] + * + * @method Phaser.Curves.MoveTo#toJSON + * @since 3.0.0 + * + * @return {JSONCurve} [description] + */ + toJSON: function () + { + return { + type: 'MoveTo', + points: [ + this.p0.x, this.p0.y + ] + }; + } + +}); + +module.exports = MoveTo; + + +/***/ }), +/* 859 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var Class = __webpack_require__(0); +var CubicBezierCurve = __webpack_require__(321); +var EllipseCurve = __webpack_require__(319); +var GameObjectFactory = __webpack_require__(9); +var LineCurve = __webpack_require__(317); +var MovePathTo = __webpack_require__(858); +var QuadraticBezierCurve = __webpack_require__(316); +var Rectangle = __webpack_require__(10); +var SplineCurve = __webpack_require__(314); +var Vector2 = __webpack_require__(6); + +/** + * @typedef {object} JSONPath + * + * @property {string} type - The of the curve. + * @property {number} x - [description] + * @property {number} y - [description] + * @property {boolean} autoClose - The path is auto closed. + * @property {JSONCurve[]} curves - The list of the curves + */ + +/** + * @classdesc + * [description] + * + * @class Path + * @memberOf Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - [description] + * @param {number} [y=0] - [description] + */ +var Path = new Class({ + + initialize: + + function Path (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + /** + * [description] + * + * @name Phaser.Curves.Path#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * [description] + * + * @name Phaser.Curves.Path#curves + * @type {Phaser.Curves.Curve[]} + * @default [] + * @since 3.0.0 + */ + this.curves = []; + + /** + * [description] + * + * @name Phaser.Curves.Path#cacheLengths + * @type {number[]} + * @default [] + * @since 3.0.0 + */ + this.cacheLengths = []; + + /** + * Automatically closes the path. + * + * @name Phaser.Curves.Path#autoClose + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.autoClose = false; + + /** + * [description] + * + * @name {Phaser.Curves.Path#startPoint + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.startPoint = new Vector2(); + + /** + * [description] + * + * @name {Phaser.Curves.Path#_tmpVec2A + * @type {Phaser.Math.Vector2} + * @private + * @since 3.0.0 + */ + this._tmpVec2A = new Vector2(); + + /** + * [description] + * + * @name {Phaser.Curves.Path#_tmpVec2B + * @type {Phaser.Math.Vector2} + * @private + * @since 3.0.0 + */ + this._tmpVec2B = new Vector2(); + + if (typeof x === 'object') + { + this.fromJSON(x); + } + else + { + this.startPoint.set(x, y); + } + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#add + * @since 3.0.0 + * + * @param {Phaser.Curves.Curve} curve - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + add: function (curve) + { + this.curves.push(curve); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#circleTo + * @since 3.0.0 + * + * @param {number} radius - [description] + * @param {boolean} [clockwise=false] - [description] + * @param {number} [rotation=0] - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + circleTo: function (radius, clockwise, rotation) + { + if (clockwise === undefined) { clockwise = false; } + + return this.ellipseTo(radius, radius, 0, 360, clockwise, rotation); + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#closePath + * @since 3.0.0 + * + * @return {Phaser.Curves.Path} [description] + */ + closePath: function () + { + // Add a line curve if start and end of lines are not connected + var startPoint = this.curves[0].getPoint(0); + var endPoint = this.curves[this.curves.length - 1].getPoint(1); + + if (!startPoint.equals(endPoint)) + { + // This will copy a reference to the vectors, which probably isn't sensible + this.curves.push(new LineCurve(endPoint, startPoint)); + } + + return this; + }, + + // Creates a cubic bezier curve starting at the previous end point and ending at p3, using p1 and p2 as control points + + /** + * [description] + * + * @method Phaser.Curves.Path#cubicBezierTo + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {Phaser.Math.Vector2} control1X - [description] + * @param {Phaser.Math.Vector2} control1Y - [description] + * @param {Phaser.Math.Vector2} control2X - [description] + * @param {Phaser.Math.Vector2} control2Y - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + cubicBezierTo: function (x, y, control1X, control1Y, control2X, control2Y) + { + var p0 = this.getEndPoint(); + var p1; + var p2; + var p3; + + // Assume they're all vec2s + if (x instanceof Vector2) + { + p1 = x; + p2 = y; + p3 = control1X; + } + else + { + p1 = new Vector2(control1X, control1Y); + p2 = new Vector2(control2X, control2Y); + p3 = new Vector2(x, y); + } + + return this.add(new CubicBezierCurve(p0, p1, p2, p3)); + }, + + // Creates a quadratic bezier curve starting at the previous end point and ending at p2, using p1 as a control point + + /** + * [description] + * + * @method Phaser.Curves.Path#quadraticBezierTo + * @since 3.2.0 + * + * @param {(number|Phaser.Math.Vector2[])} x - [description] + * @param {number} [y] - [description] + * @param {number} [controlX] - [description] + * @param {number} [controlY] - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + quadraticBezierTo: function (x, y, controlX, controlY) + { + var p0 = this.getEndPoint(); + var p1; + var p2; + + // Assume they're all vec2s + if (x instanceof Vector2) + { + p1 = x; + p2 = y; + } + else + { + p1 = new Vector2(controlX, controlY); + p2 = new Vector2(x, y); + } + + return this.add(new QuadraticBezierCurve(p0, p1, p2)); + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#draw + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - [description] + * @param {integer} [pointsTotal=32] - [description] + * + * @return {Phaser.GameObjects.Graphics} [description] + */ + draw: function (graphics, pointsTotal) + { + for (var i = 0; i < this.curves.length; i++) + { + var curve = this.curves[i]; + + if (!curve.active) + { + continue; + } + + curve.draw(graphics, pointsTotal); + } + + return graphics; + }, + + /** + * Creates an ellipse curve positioned at the previous end point, using the given parameters. + * + * @method Phaser.Curves.Path#ellipseTo + * @since 3.0.0 + * + * @param {number} xRadius - [description] + * @param {number} yRadius - [description] + * @param {number} startAngle - [description] + * @param {number} endAngle - [description] + * @param {boolean} clockwise - [description] + * @param {number} rotation - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + ellipseTo: function (xRadius, yRadius, startAngle, endAngle, clockwise, rotation) + { + var ellipse = new EllipseCurve(0, 0, xRadius, yRadius, startAngle, endAngle, clockwise, rotation); + + var end = this.getEndPoint(this._tmpVec2A); + + // Calculate where to center the ellipse + var start = ellipse.getStartPoint(this._tmpVec2B); + + end.subtract(start); + + ellipse.x = end.x; + ellipse.y = end.y; + + return this.add(ellipse); + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#fromJSON + * @since 3.0.0 + * + * @param {object} data - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + fromJSON: function (data) + { + // data should be an object matching the Path.toJSON object structure. + + this.curves = []; + this.cacheLengths = []; + + this.startPoint.set(data.x, data.y); + + this.autoClose = data.autoClose; + + for (var i = 0; i < data.curves.length; i++) + { + var curve = data.curves[i]; + + switch (curve.type) + { + case 'LineCurve': + this.add(LineCurve.fromJSON(curve)); + break; + + case 'EllipseCurve': + this.add(EllipseCurve.fromJSON(curve)); + break; + + case 'SplineCurve': + this.add(SplineCurve.fromJSON(curve)); + break; + + case 'CubicBezierCurve': + this.add(CubicBezierCurve.fromJSON(curve)); + break; + + case 'QuadraticBezierCurve': + this.add(QuadraticBezierCurve.fromJSON(curve)); + break; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#getBounds + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} [out] - [description] + * @param {integer} [accuracy=16] - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ + getBounds: function (out, accuracy) + { + if (out === undefined) { out = new Rectangle(); } + if (accuracy === undefined) { accuracy = 16; } + + out.x = Number.MAX_VALUE; + out.y = Number.MAX_VALUE; + + var bounds = new Rectangle(); + var maxRight = Number.MIN_SAFE_INTEGER; + var maxBottom = Number.MIN_SAFE_INTEGER; + + for (var i = 0; i < this.curves.length; i++) + { + var curve = this.curves[i]; + + if (!curve.active) + { + continue; + } + + curve.getBounds(bounds, accuracy); + + out.x = Math.min(out.x, bounds.x); + out.y = Math.min(out.y, bounds.y); + + maxRight = Math.max(maxRight, bounds.right); + maxBottom = Math.max(maxBottom, bounds.bottom); + } + + out.right = maxRight; + out.bottom = maxBottom; + + return out; + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#getCurveLengths + * @since 3.0.0 + * + * @return {array} [description] + */ + getCurveLengths: function () + { + // We use cache values if curves and cache array are same length + + if (this.cacheLengths.length === this.curves.length) + { + return this.cacheLengths; + } + + // Get length of sub-curve + // Push sums into cached array + + var lengths = []; + var sums = 0; + + for (var i = 0; i < this.curves.length; i++) + { + sums += this.curves[i].getLength(); + + lengths.push(sums); + } + + this.cacheLengths = lengths; + + return lengths; + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#getEndPoint + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + getEndPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + if (this.curves.length > 0) + { + this.curves[this.curves.length - 1].getPoint(1, out); + } + else + { + out.copy(this.startPoint); + } + + return out; + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#getLength + * @since 3.0.0 + * + * @return {number} [description] + */ + getLength: function () + { + var lens = this.getCurveLengths(); + + return lens[lens.length - 1]; + }, + + // To get accurate point with reference to + // entire path distance at time t, + // following has to be done: + + // 1. Length of each sub path have to be known + // 2. Locate and identify type of curve + // 3. Get t for the curve + // 4. Return curve.getPointAt(t') + + /** + * [description] + * + * @method Phaser.Curves.Path#getPoint + * @since 3.0.0 + * + * @param {number} t - [description] + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {?Phaser.Math.Vector2} [description] + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var d = t * this.getLength(); + var curveLengths = this.getCurveLengths(); + var i = 0; + + while (i < curveLengths.length) + { + if (curveLengths[i] >= d) + { + var diff = curveLengths[i] - d; + var curve = this.curves[i]; + + var segmentLength = curve.getLength(); + var u = (segmentLength === 0) ? 0 : 1 - diff / segmentLength; + + return curve.getPointAt(u, out); + } + + i++; + } + + // loop where sum != 0, sum > d , sum+1 1 && !points[points.length - 1].equals(points[0])) + { + points.push(points[0]); + } + + return points; + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#getRandomPoint + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + getRandomPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return this.getPoint(Math.random(), out); + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#getSpacedPoints + * @since 3.0.0 + * + * @param {integer} [divisions=40] - [description] + * + * @return {Phaser.Math.Vector2[]} [description] + */ + getSpacedPoints: function (divisions) + { + if (divisions === undefined) { divisions = 40; } + + var points = []; + + for (var i = 0; i <= divisions; i++) + { + points.push(this.getPoint(i / divisions)); + } + + if (this.autoClose) + { + points.push(points[0]); + } + + return points; + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#getStartPoint + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.startPoint); + }, + + // Creates a line curve from the previous end point to x/y + + /** + * [description] + * + * @method Phaser.Curves.Path#lineTo + * @since 3.0.0 + * + * @param {(number|Phaser.Math.Vector2)} x - [description] + * @param {number} [y] - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + lineTo: function (x, y) + { + if (x instanceof Vector2) + { + this._tmpVec2B.copy(x); + } + else + { + this._tmpVec2B.set(x, y); + } + + var end = this.getEndPoint(this._tmpVec2A); + + return this.add(new LineCurve([ end.x, end.y, this._tmpVec2B.x, this._tmpVec2B.y ])); + }, + + // Creates a spline curve starting at the previous end point, using the given parameters + + /** + * [description] + * + * @method Phaser.Curves.Path#splineTo + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2[]} points - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + splineTo: function (points) + { + points.unshift(this.getEndPoint()); + + return this.add(new SplineCurve(points)); + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#moveTo + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + moveTo: function (x, y) + { + return this.add(new MovePathTo(x, y)); + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#toJSON + * @since 3.0.0 + * + * @return {JSONPath} [description] + */ + toJSON: function () + { + var out = []; + + for (var i = 0; i < this.curves.length; i++) + { + out.push(this.curves[i].toJSON()); + } + + return { + type: 'Path', + x: this.startPoint.x, + y: this.startPoint.y, + autoClose: this.autoClose, + curves: out + }; + }, + + // cacheLengths must be recalculated. + + /** + * [description] + * + * @method Phaser.Curves.Path#updateArcLengths + * @since 3.0.0 + */ + updateArcLengths: function () + { + this.cacheLengths = []; + + this.getCurveLengths(); + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.curves.length = 0; + this.cacheLengths.length = 0; + this.startPoint = undefined; + } + +}); + +/** + * Creates a new Path Object. + * + * @method Phaser.GameObjects.GameObjectFactory#path + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Path. + * @param {number} y - The vertical position of this Path. + * + * @return {Phaser.Curves.Path} The Path Object that was created. + */ +GameObjectFactory.register('path', function (x, y) +{ + return new Path(x, y); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +module.exports = Path; + + +/***/ }), +/* 860 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Curves + */ + +/** + * @typedef {object} JSONCurve + * + * @property {string} type - The of the curve + * @property {number[]} points - The arrays of points like `[x1, y1, x2, y2]` + */ + +module.exports = { + Path: __webpack_require__(859), + + CubicBezier: __webpack_require__(321), + Curve: __webpack_require__(56), + Ellipse: __webpack_require__(319), + Line: __webpack_require__(317), + QuadraticBezier: __webpack_require__(316), + Spline: __webpack_require__(314) +}; + + +/***/ }), +/* 861 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A 16 color palette inspired by Japanese computers like the MSX. + * + * @name Phaser.Create.Palettes.MSX + * @since 3.0.0 + * + * @type {Palette} + */ +module.exports = { + 0: '#000', + 1: '#191028', + 2: '#46af45', + 3: '#a1d685', + 4: '#453e78', + 5: '#7664fe', + 6: '#833129', + 7: '#9ec2e8', + 8: '#dc534b', + 9: '#e18d79', + A: '#d6b97b', + B: '#e9d8a1', + C: '#216c4b', + D: '#d365c8', + E: '#afaab9', + F: '#fff' +}; + + +/***/ }), +/* 862 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A 16 color JMP palette by [Arne](http://androidarts.com/palette/16pal.htm) + * + * @name Phaser.Create.Palettes.JMP + * @since 3.0.0 + * + * @type {Palette} + */ +module.exports = { + 0: '#000', + 1: '#191028', + 2: '#46af45', + 3: '#a1d685', + 4: '#453e78', + 5: '#7664fe', + 6: '#833129', + 7: '#9ec2e8', + 8: '#dc534b', + 9: '#e18d79', + A: '#d6b97b', + B: '#e9d8a1', + C: '#216c4b', + D: '#d365c8', + E: '#afaab9', + F: '#f5f4eb' +}; + + +/***/ }), +/* 863 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A 16 color CGA inspired palette by [Arne](http://androidarts.com/palette/16pal.htm) + * + * @name Phaser.Create.Palettes.CGA + * @since 3.0.0 + * + * @type {Palette} + */ +module.exports = { + 0: '#000', + 1: '#2234d1', + 2: '#0c7e45', + 3: '#44aacc', + 4: '#8a3622', + 5: '#5c2e78', + 6: '#aa5c3d', + 7: '#b5b5b5', + 8: '#5e606e', + 9: '#4c81fb', + A: '#6cd947', + B: '#7be2f9', + C: '#eb8a60', + D: '#e23d69', + E: '#ffd93f', + F: '#fff' +}; + + +/***/ }), +/* 864 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A 16 color palette inspired by the Commodore 64. + * + * @name Phaser.Create.Palettes.C64 + * @since 3.0.0 + * + * @type {Palette} + */ +module.exports = { + 0: '#000', + 1: '#fff', + 2: '#8b4131', + 3: '#7bbdc5', + 4: '#8b41ac', + 5: '#6aac41', + 6: '#3931a4', + 7: '#d5de73', + 8: '#945a20', + 9: '#5a4100', + A: '#bd736a', + B: '#525252', + C: '#838383', + D: '#acee8b', + E: '#7b73de', + F: '#acacac' +}; + + +/***/ }), +/* 865 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} Palette + * + * @property {string} 0 - Color value 1. + * @property {string} 1 - Color value 2. + * @property {string} 2 - Color value 3. + * @property {string} 3 - Color value 4. + * @property {string} 4 - Color value 5. + * @property {string} 5 - Color value 6. + * @property {string} 6 - Color value 7. + * @property {string} 7 - Color value 8. + * @property {string} 8 - Color value 9. + * @property {string} 9 - Color value 10. + * @property {string} A - Color value 11. + * @property {string} B - Color value 12. + * @property {string} C - Color value 13. + * @property {string} D - Color value 14. + * @property {string} E - Color value 15. + * @property {string} F - Color value 16. + */ + +/** + * @namespace Phaser.Create.Palettes + */ + +module.exports = { + + ARNE16: __webpack_require__(322), + C64: __webpack_require__(864), + CGA: __webpack_require__(863), + JMP: __webpack_require__(862), + MSX: __webpack_require__(861) + +}; + + +/***/ }), +/* 866 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Create + */ + +module.exports = { + + GenerateTexture: __webpack_require__(323), + Palettes: __webpack_require__(865) + +}; + + +/***/ }), +/* 867 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var OrthographicCamera = __webpack_require__(325); +var PerspectiveCamera = __webpack_require__(324); +var PluginManager = __webpack_require__(12); + +/** + * @classdesc + * [description] + * + * @class CameraManager + * @memberOf Phaser.Cameras.Sprite3D + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ +var CameraManager = new Class({ + + initialize: + + function CameraManager (scene) + { + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.CameraManager#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.CameraManager#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + /** + * An Array of the Camera objects being managed by this Camera Manager. + * + * @name Phaser.Cameras.Sprite3D.CameraManager#cameras + * @type {array} + * @since 3.0.0 + */ + this.cameras = []; + + if (!scene.sys.settings.isBooted) + { + scene.sys.events.once('boot', this.boot, this); + } + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.CameraManager#boot + * @since 3.0.0 + */ + boot: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on('update', this.update, this); + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.CameraManager#add + * @since 3.0.0 + * + * @param {number} [fieldOfView=80] - [description] + * @param {number} [width] - [description] + * @param {number} [height] - [description] + * + * @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description] + */ + add: function (fieldOfView, width, height) + { + return this.addPerspectiveCamera(fieldOfView, width, height); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.CameraManager#addOrthographicCamera + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.Cameras.Sprite3D.OrthographicCamera} [description] + */ + addOrthographicCamera: function (width, height) + { + var config = this.scene.sys.game.config; + + if (width === undefined) { width = config.width; } + if (height === undefined) { height = config.height; } + + var camera = new OrthographicCamera(this.scene, width, height); + + this.cameras.push(camera); + + return camera; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.CameraManager#addPerspectiveCamera + * @since 3.0.0 + * + * @param {number} [fieldOfView=80] - [description] + * @param {number} [width] - [description] + * @param {number} [height] - [description] + * + * @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description] + */ + addPerspectiveCamera: function (fieldOfView, width, height) + { + var config = this.scene.sys.game.config; + + if (fieldOfView === undefined) { fieldOfView = 80; } + if (width === undefined) { width = config.width; } + if (height === undefined) { height = config.height; } + + var camera = new PerspectiveCamera(this.scene, fieldOfView, width, height); + + this.cameras.push(camera); + + return camera; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.CameraManager#getCamera + * @since 3.0.0 + * + * @param {string} name - [description] + * + * @return {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} [description] + */ + getCamera: function (name) + { + for (var i = 0; i < this.cameras.length; i++) + { + if (this.cameras[i].name === name) + { + return this.cameras[i]; + } + } + + return null; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.CameraManager#removeCamera + * @since 3.0.0 + * + * @param {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} camera - [description] + */ + removeCamera: function (camera) + { + var cameraIndex = this.cameras.indexOf(camera); + + if (cameraIndex !== -1) + { + this.cameras.splice(cameraIndex, 1); + } + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.CameraManager#removeAll + * @since 3.0.0 + * + * @return {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} [description] + */ + removeAll: function () + { + while (this.cameras.length > 0) + { + var camera = this.cameras.pop(); + + camera.destroy(); + } + + return this.main; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.CameraManager#update + * @since 3.0.0 + * + * @param {number} timestep - [description] + * @param {number} delta - [description] + */ + update: function (timestep, delta) + { + for (var i = 0, l = this.cameras.length; i < l; ++i) + { + this.cameras[i].update(timestep, delta); + } + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.CameraManager#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.CameraManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.scene = undefined; + } + +}); + +PluginManager.register('CameraManager3D', CameraManager, 'cameras3d'); + +module.exports = CameraManager; + + +/***/ }), +/* 868 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Sprite#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var SpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + renderer.drawImage(src, camera); +}; + +module.exports = SpriteCanvasRenderer; + + +/***/ }), +/* 869 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Sprite#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var SpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + this.pipeline.batchSprite(src, camera); +}; + +module.exports = SpriteWebGLRenderer; + + +/***/ }), +/* 870 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); + +if (true) +{ + renderWebGL = __webpack_require__(869); +} + +if (true) +{ + renderCanvas = __webpack_require__(868); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 871 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Cameras.Sprite3D + */ + +module.exports = { + + Camera: __webpack_require__(154), + CameraManager: __webpack_require__(867), + OrthographicCamera: __webpack_require__(325), + PerspectiveCamera: __webpack_require__(324) + +}; + + +/***/ }), +/* 872 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Camera = __webpack_require__(157); +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(2); +var PluginManager = __webpack_require__(12); +var RectangleContains = __webpack_require__(27); + +/** + * @typedef {object} InputJSONCameraObject + * + * @property {string} [name=''] - [description] + * @property {integer} [x=0] - [description] + * @property {integer} [y=0] - [description] + * @property {integer} [width] - [description] + * @property {integer} [height] - [description] + * @property {float} [zoom=1] - [description] + * @property {float} [rotation=0] - [description] + * @property {boolean} [roundPixels=false] - [description] + * @property {float} [scrollX=0] - [description] + * @property {float} [scrollY=0] - [description] + * @property {(false|string)} [backgroundColor=false] - [description] + * @property {?object} [bounds] - [description] + * @property {number} [bounds.x=0] - [description] + * @property {number} [bounds.y=0] - [description] + * @property {number} [bounds.width] - [description] + * @property {number} [bounds.height] - [description] + */ + +/** + * @classdesc + * [description] + * + * @class CameraManager + * @memberOf Phaser.Cameras.Scene2D + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene that owns the Camera Manager plugin. + */ +var CameraManager = new Class({ + + initialize: + + function CameraManager (scene) + { + /** + * The Scene that owns the Camera Manager plugin. + * + * @name Phaser.Cameras.Scene2D.CameraManager#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A reference to the Scene.Systems handler for the Scene that owns the Camera Manager. + * + * @name Phaser.Cameras.Scene2D.CameraManager#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + if (!scene.sys.settings.isBooted) + { + scene.sys.events.once('boot', this.boot, this); + } + + /** + * The current Camera ID. + * + * @name Phaser.Cameras.Scene2D.CameraManager#currentCameraId + * @type {number} + * @default 1 + * @readOnly + * @since 3.0.0 + */ + this.currentCameraId = 1; + + /** + * An Array of the Camera objects being managed by this Camera Manager. + * + * @name Phaser.Cameras.Scene2D.CameraManager#cameras + * @type {Phaser.Cameras.Scene2D.Camera[]} + * @since 3.0.0 + */ + this.cameras = []; + + /** + * A pool of Camera objects available to be used by the Camera Manager. + * + * @name Phaser.Cameras.Scene2D.CameraManager#cameraPool + * @type {Phaser.Cameras.Scene2D.Camera[]} + * @since 3.0.0 + */ + this.cameraPool = []; + + if (scene.sys.settings.cameras) + { + // We have cameras to create + this.fromJSON(scene.sys.settings.cameras); + } + else + { + // Make one + this.add(); + } + + /** + * The default Camera in the Camera Manager. + * + * @name Phaser.Cameras.Scene2D.CameraManager#main + * @type {Phaser.Cameras.Scene2D.Camera} + * @since 3.0.0 + */ + this.main = this.cameras[0]; + + /** + * This scale affects all cameras. It's used by Scale Manager. + * + * @name Phaser.Cameras.Scene2D.CameraManager#baseScale + * @type {number} + * @since 3.0.0 + */ + this.baseScale = 1.0; + }, + + /** + * Called when the Camera Manager boots. + * Starts the event listeners running. + * + * @method Phaser.Cameras.Scene2D.CameraManager#boot + * @since 3.0.0 + */ + boot: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on('update', this.update, this); + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.CameraManager#add + * @since 3.0.0 + * + * @param {number} [x=0] - [description] + * @param {number} [y=0] - [description] + * @param {number} [width] - [description] + * @param {number} [height] - [description] + * @param {boolean} [makeMain=false] - [description] + * @param {string} [name=''] - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} [description] + */ + add: function (x, y, width, height, makeMain, name) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = this.scene.sys.game.config.width; } + if (height === undefined) { height = this.scene.sys.game.config.height; } + if (makeMain === undefined) { makeMain = false; } + if (name === undefined) { name = ''; } + + var camera = null; + + if (this.cameraPool.length > 0) + { + camera = this.cameraPool.pop(); + + camera.setViewport(x, y, width, height); + } + else + { + camera = new Camera(x, y, width, height); + } + + camera.setName(name); + camera.setScene(this.scene); + + this.cameras.push(camera); + + if (makeMain) + { + this.main = camera; + } + + camera._id = this.currentCameraId; + + this.currentCameraId = this.currentCameraId << 1; + + return camera; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.CameraManager#addExisting + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} [description] + */ + addExisting: function (camera) + { + var index = this.cameras.indexOf(camera); + var poolIndex = this.cameraPool.indexOf(camera); + + if (index < 0 && poolIndex >= 0) + { + this.cameras.push(camera); + this.cameraPool.slice(poolIndex, 1); + return camera; + } + + return null; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.CameraManager#fromJSON + * @since 3.0.0 + * + * @param {(InputJSONCameraObject|InputJSONCameraObject[])} config - [description] + * + * @return {Phaser.Cameras.Scene2D.CameraManager} [description] + */ + fromJSON: function (config) + { + if (!Array.isArray(config)) + { + config = [ config ]; + } + + var gameWidth = this.scene.sys.game.config.width; + var gameHeight = this.scene.sys.game.config.height; + + for (var i = 0; i < config.length; i++) + { + var cameraConfig = config[i]; + + var x = GetFastValue(cameraConfig, 'x', 0); + var y = GetFastValue(cameraConfig, 'y', 0); + var width = GetFastValue(cameraConfig, 'width', gameWidth); + var height = GetFastValue(cameraConfig, 'height', gameHeight); + + var camera = this.add(x, y, width, height); + + // Direct properties + camera.name = GetFastValue(cameraConfig, 'name', ''); + camera.zoom = GetFastValue(cameraConfig, 'zoom', 1); + camera.rotation = GetFastValue(cameraConfig, 'rotation', 0); + camera.scrollX = GetFastValue(cameraConfig, 'scrollX', 0); + camera.scrollY = GetFastValue(cameraConfig, 'scrollY', 0); + camera.roundPixels = GetFastValue(cameraConfig, 'roundPixels', false); + + // Background Color + + var backgroundColor = GetFastValue(cameraConfig, 'backgroundColor', false); + + if (backgroundColor) + { + camera.setBackgroundColor(backgroundColor); + } + + // Bounds + + var boundsConfig = GetFastValue(cameraConfig, 'bounds', null); + + if (boundsConfig) + { + var bx = GetFastValue(boundsConfig, 'x', 0); + var by = GetFastValue(boundsConfig, 'y', 0); + var bwidth = GetFastValue(boundsConfig, 'width', gameWidth); + var bheight = GetFastValue(boundsConfig, 'height', gameHeight); + + camera.setBounds(bx, by, bwidth, bheight); + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.CameraManager#getCamera + * @since 3.0.0 + * + * @param {string} name - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} [description] + */ + getCamera: function (name) + { + for (var i = 0; i < this.cameras.length; i++) + { + if (this.cameras[i].name === name) + { + return this.cameras[i]; + } + } + + return null; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.CameraManager#getCameraBelowPointer + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} [description] + */ + getCameraBelowPointer: function (pointer) + { + var cameras = this.cameras; + + // Start from the most recently added camera (the 'top' camera) + for (var i = cameras.length - 1; i >= 0; i--) + { + var camera = cameras[i]; + + if (camera.inputEnabled && RectangleContains(camera, pointer.x, pointer.y)) + { + return camera; + } + } + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.CameraManager#remove + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + remove: function (camera) + { + var cameraIndex = this.cameras.indexOf(camera); + + if (cameraIndex >= 0 && this.cameras.length > 1) + { + this.cameraPool.push(this.cameras[cameraIndex]); + this.cameras.splice(cameraIndex, 1); + + if (this.main === camera) + { + this.main = this.cameras[0]; + } + } + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.CameraManager#render + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - The Renderer that will render the children to this camera. + * @param {Phaser.GameObjects.GameObject[]} children - An array of renderable Game Objects. + * @param {number} interpolation - Interpolation value. Reserved for future use. + */ + render: function (renderer, children, interpolation) + { + var cameras = this.cameras; + var baseScale = this.baseScale; + + for (var i = 0, l = cameras.length; i < l; ++i) + { + var camera = cameras[i]; + + camera.preRender(baseScale, renderer.config.resolution); + + renderer.render(this.scene, children, interpolation, camera); + } + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.CameraManager#resetAll + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} [description] + */ + resetAll: function () + { + while (this.cameras.length > 0) + { + this.cameraPool.push(this.cameras.pop()); + } + + this.main = this.add(); + + return this.main; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.CameraManager#update + * @since 3.0.0 + * + * @param {number} timestep - [description] + * @param {number} delta - [description] + */ + update: function (timestep, delta) + { + for (var i = 0, l = this.cameras.length; i < l; ++i) + { + this.cameras[i].update(timestep, delta); + } + }, + + /** + * Resizes all cameras to the given dimensions. + * + * @method Phaser.Cameras.Scene2D.CameraManager#resize + * @since 3.2.0 + * + * @param {number} width - The new width of the camera. + * @param {number} height - The new height of the camera. + */ + resize: function (width, height) + { + for (var i = 0, l = this.cameras.length; i < l; ++i) + { + this.cameras[i].setSize(width, height); + } + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.CameraManager#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + // TODO + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.CameraManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.main = undefined; + + for (var i = 0; i < this.cameras.length; i++) + { + this.cameras[i].destroy(); + } + + for (i = 0; i < this.cameraPool.length; i++) + { + this.cameraPool[i].destroy(); + } + + this.cameras = []; + this.cameraPool = []; + this.scene = undefined; + } + +}); + +PluginManager.register('CameraManager', CameraManager, 'cameras'); + +module.exports = CameraManager; + + +/***/ }), +/* 873 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Cameras.Scene2D + */ + +module.exports = { + + Camera: __webpack_require__(157), + CameraManager: __webpack_require__(872) + +}; + + +/***/ }), +/* 874 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetValue = __webpack_require__(5); + +// var controlConfig = { +// camera: this.cameras.main, +// left: cursors.left, +// right: cursors.right, +// up: cursors.up, +// down: cursors.down, +// zoomIn: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q), +// zoomOut: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E), +// zoomSpeed: 0.02, +// acceleration: 0.06, +// drag: 0.0005, +// maxSpeed: 1.0 +// }; + +/** + * @typedef {object} SmoothedKeyControlConfig + * + * @property {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera that this Control will update. + * @property {Phaser.Input.Keyboard.Key} [left] - The Key to be pressed that will move the Camera left. + * @property {Phaser.Input.Keyboard.Key} [right] - The Key to be pressed that will move the Camera right. + * @property {Phaser.Input.Keyboard.Key} [up] - The Key to be pressed that will move the Camera up. + * @property {Phaser.Input.Keyboard.Key} [zoomIn] - The Key to be pressed that will zoom the Camera in. + * @property {Phaser.Input.Keyboard.Key} [zoomOut] - The Key to be pressed that will zoom the Camera out. + * @property {float} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + * @property {(float|{x:float,y:float})} [acceleration=0] - The horizontal and vertical acceleration the camera will move. + * @property {(float|{x:float,y:float})} [drag=0] - The horizontal and vertical drag applied to the camera when it is moving. + * @property {(float|{x:float,y:float})} [maxSpeed=0] - The maximum horizontal and vertical speed the camera will move. + */ + +/** + * @classdesc + * [description] + * + * @class SmoothedKeyControl + * @memberOf Phaser.Cameras.Controls + * @constructor + * @since 3.0.0 + * + * @param {SmoothedKeyControlConfig} config - [description] + */ +var SmoothedKeyControl = new Class({ + + initialize: + + function SmoothedKeyControl (config) + { + /** + * The Camera that this Control will update. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @default null + * @since 3.0.0 + */ + this.camera = GetValue(config, 'camera', null); + + /** + * The Key to be pressed that will move the Camera left. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#left + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.left = GetValue(config, 'left', null); + + /** + * The Key to be pressed that will move the Camera right. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#right + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.right = GetValue(config, 'right', null); + + /** + * The Key to be pressed that will move the Camera up. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#up + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.up = GetValue(config, 'up', null); + + /** + * The Key to be pressed that will move the Camera down. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#down + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.down = GetValue(config, 'down', null); + + /** + * The Key to be pressed that will zoom the Camera in. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomIn + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.zoomIn = GetValue(config, 'zoomIn', null); + + /** + * The Key to be pressed that will zoom the Camera out. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomOut + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.zoomOut = GetValue(config, 'zoomOut', null); + + /** + * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomSpeed + * @type {float} + * @default 0.01 + * @since 3.0.0 + */ + this.zoomSpeed = GetValue(config, 'zoomSpeed', 0.01); + + /** + * The horizontal acceleration the camera will move. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#accelX + * @type {float} + * @default 0 + * @since 3.0.0 + */ + this.accelX = 0; + + /** + * The vertical acceleration the camera will move. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#accelY + * @type {float} + * @default 0 + * @since 3.0.0 + */ + this.accelY = 0; + + var accel = GetValue(config, 'acceleration', null); + + if (typeof accel === 'number') + { + this.accelX = accel; + this.accelY = accel; + } + else + { + this.accelX = GetValue(config, 'acceleration.x', 0); + this.accelY = GetValue(config, 'acceleration.y', 0); + } + + /** + * The horizontal drag applied to the camera when it is moving. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#dragX + * @type {float} + * @default 0 + * @since 3.0.0 + */ + this.dragX = 0; + + /** + * The vertical drag applied to the camera when it is moving. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#dragY + * @type {float} + * @default 0 + * @since 3.0.0 + */ + this.dragY = 0; + + var drag = GetValue(config, 'drag', null); + + if (typeof drag === 'number') + { + this.dragX = drag; + this.dragY = drag; + } + else + { + this.dragX = GetValue(config, 'drag.x', 0); + this.dragY = GetValue(config, 'drag.y', 0); + } + + /** + * The maximum horizontal speed the camera will move. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#maxSpeedX + * @type {float} + * @default 0 + * @since 3.0.0 + */ + this.maxSpeedX = 0; + + /** + * The maximum vertical speed the camera will move. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#maxSpeedY + * @type {float} + * @default 0 + * @since 3.0.0 + */ + this.maxSpeedY = 0; + + var maxSpeed = GetValue(config, 'maxSpeed', null); + + if (typeof maxSpeed === 'number') + { + this.maxSpeedX = maxSpeed; + this.maxSpeedY = maxSpeed; + } + else + { + this.maxSpeedX = GetValue(config, 'maxSpeed.x', 0); + this.maxSpeedY = GetValue(config, 'maxSpeed.y', 0); + } + + /** + * [description] + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#_speedX + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._speedX = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#_speedY + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._speedY = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#_zoom + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._zoom = 0; + + /** + * A flag controlling if the Controls will update the Camera or not. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#active + * @type {boolean} + * @since 3.0.0 + */ + this.active = (this.camera !== null); + }, + + /** + * Starts the Key Control running, providing it has been linked to a camera. + * + * @method Phaser.Cameras.Controls.SmoothedKeyControl#start + * @since 3.0.0 + * + * @return {Phaser.Cameras.Controls.SmoothedKeyControl} This Key Control instance. + */ + start: function () + { + this.active = (this.camera !== null); + + return this; + }, + + /** + * Stops this Key Control from running. Call `start` to start it again. + * + * @method Phaser.Cameras.Controls.SmoothedKeyControl#stop + * @since 3.0.0 + * + * @return {Phaser.Cameras.Controls.SmoothedKeyControl} This Key Control instance. + */ + stop: function () + { + this.active = false; + + return this; + }, + + /** + * Binds this Key Control to a camera. + * + * @method Phaser.Cameras.Controls.SmoothedKeyControl#setCamera + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to bind this Key Control to. + * + * @return {Phaser.Cameras.Controls.SmoothedKeyControl} This Key Control instance. + */ + setCamera: function (camera) + { + this.camera = camera; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Controls.SmoothedKeyControl#update + * @since 3.0.0 + * + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + update: function (delta) + { + if (!this.active) + { + return; + } + + if (delta === undefined) { delta = 1; } + + var cam = this.camera; + + // Apply Deceleration + + if (this._speedX > 0) + { + this._speedX -= this.dragX * delta; + + if (this._speedX < 0) + { + this._speedX = 0; + } + } + else if (this._speedX < 0) + { + this._speedX += this.dragX * delta; + + if (this._speedX > 0) + { + this._speedX = 0; + } + } + + if (this._speedY > 0) + { + this._speedY -= this.dragY * delta; + + if (this._speedY < 0) + { + this._speedY = 0; + } + } + else if (this._speedY < 0) + { + this._speedY += this.dragY * delta; + + if (this._speedY > 0) + { + this._speedY = 0; + } + } + + // Check for keys + + if (this.up && this.up.isDown) + { + this._speedY += this.accelY; + + if (this._speedY > this.maxSpeedY) + { + this._speedY = this.maxSpeedY; + } + } + else if (this.down && this.down.isDown) + { + this._speedY -= this.accelY; + + if (this._speedY < -this.maxSpeedY) + { + this._speedY = -this.maxSpeedY; + } + } + + if (this.left && this.left.isDown) + { + this._speedX += this.accelX; + + if (this._speedX > this.maxSpeedX) + { + this._speedX = this.maxSpeedX; + } + } + else if (this.right && this.right.isDown) + { + this._speedX -= this.accelX; + + if (this._speedX < -this.maxSpeedX) + { + this._speedX = -this.maxSpeedX; + } + } + + // Camera zoom + + if (this.zoomIn && this.zoomIn.isDown) + { + this._zoom = -this.zoomSpeed; + } + else if (this.zoomOut && this.zoomOut.isDown) + { + this._zoom = this.zoomSpeed; + } + else + { + this._zoom = 0; + } + + // Apply to Camera + + if (this._speedX !== 0) + { + cam.scrollX -= ((this._speedX * delta) | 0); + } + + if (this._speedY !== 0) + { + cam.scrollY -= ((this._speedY * delta) | 0); + } + + if (this._zoom !== 0) + { + cam.zoom += this._zoom; + + if (cam.zoom < 0.1) + { + cam.zoom = 0.1; + } + } + }, + + /** + * Destroys this Key Control. + * + * @method Phaser.Cameras.Controls.SmoothedKeyControl#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.camera = null; + + this.left = null; + this.right = null; + this.up = null; + this.down = null; + + this.zoomIn = null; + this.zoomOut = null; + } + +}); + +module.exports = SmoothedKeyControl; + + +/***/ }), +/* 875 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetValue = __webpack_require__(5); + +// var camControl = new CameraControl({ +// camera: this.cameras.main, +// left: cursors.left, +// right: cursors.right, +// speed: float OR { x: 0, y: 0 } +// }) + +/** + * @typedef {object} FixedKeyControlConfig + * + * @property {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera that this Control will update. + * @property {Phaser.Input.Keyboard.Key} [left] - The Key to be pressed that will move the Camera left. + * @property {Phaser.Input.Keyboard.Key} [right] - The Key to be pressed that will move the Camera right. + * @property {Phaser.Input.Keyboard.Key} [up] - The Key to be pressed that will move the Camera up. + * @property {Phaser.Input.Keyboard.Key} [zoomIn] - The Key to be pressed that will zoom the Camera in. + * @property {Phaser.Input.Keyboard.Key} [zoomOut] - The Key to be pressed that will zoom the Camera out. + * @property {float} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + * @property {(float|{x:float,y:float})} [speed=0] - The horizontal and vertical speed the camera will move. + */ + +/** + * @classdesc + * [description] + * + * @class FixedKeyControl + * @memberOf Phaser.Cameras.Controls + * @constructor + * @since 3.0.0 + * + * @param {FixedKeyControlConfig} config - [description] + */ +var FixedKeyControl = new Class({ + + initialize: + + function FixedKeyControl (config) + { + /** + * The Camera that this Control will update. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @default null + * @since 3.0.0 + */ + this.camera = GetValue(config, 'camera', null); + + /** + * The Key to be pressed that will move the Camera left. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#left + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.left = GetValue(config, 'left', null); + + /** + * The Key to be pressed that will move the Camera right. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#right + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.right = GetValue(config, 'right', null); + + /** + * The Key to be pressed that will move the Camera up. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#up + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.up = GetValue(config, 'up', null); + + /** + * The Key to be pressed that will move the Camera down. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#down + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.down = GetValue(config, 'down', null); + + /** + * The Key to be pressed that will zoom the Camera in. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#zoomIn + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.zoomIn = GetValue(config, 'zoomIn', null); + + /** + * The Key to be pressed that will zoom the Camera out. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#zoomOut + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.zoomOut = GetValue(config, 'zoomOut', null); + + /** + * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#zoomSpeed + * @type {float} + * @default 0.01 + * @since 3.0.0 + */ + this.zoomSpeed = GetValue(config, 'zoomSpeed', 0.01); + + /** + * The horizontal speed the camera will move. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#speedX + * @type {float} + * @default 0 + * @since 3.0.0 + */ + this.speedX = 0; + + /** + * The vertical speed the camera will move. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#speedY + * @type {float} + * @default 0 + * @since 3.0.0 + */ + this.speedY = 0; + + var speed = GetValue(config, 'speed', null); + + if (typeof speed === 'number') + { + this.speedX = speed; + this.speedY = speed; + } + else + { + this.speedX = GetValue(config, 'speed.x', 0); + this.speedY = GetValue(config, 'speed.y', 0); + } + + /** + * [description] + * + * @name Phaser.Cameras.Controls.FixedKeyControl#_zoom + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._zoom = 0; + + /** + * A flag controlling if the Controls will update the Camera or not. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#active + * @type {boolean} + * @since 3.0.0 + */ + this.active = (this.camera !== null); + }, + + /** + * Starts the Key Control running, providing it has been linked to a camera. + * + * @method Phaser.Cameras.Controls.FixedKeyControl#start + * @since 3.0.0 + * + * @return {Phaser.Cameras.Controls.FixedKeyControl} This Key Control instance. + */ + start: function () + { + this.active = (this.camera !== null); + + return this; + }, + + /** + * Stops this Key Control from running. Call `start` to start it again. + * + * @method Phaser.Cameras.Controls.FixedKeyControl#stop + * @since 3.0.0 + * + * @return {Phaser.Cameras.Controls.FixedKeyControl} This Key Control instance. + */ + stop: function () + { + this.active = false; + + return this; + }, + + /** + * Binds this Key Control to a camera. + * + * @method Phaser.Cameras.Controls.FixedKeyControl#setCamera + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to bind this Key Control to. + * + * @return {Phaser.Cameras.Controls.FixedKeyControl} This Key Control instance. + */ + setCamera: function (camera) + { + this.camera = camera; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Controls.FixedKeyControl#update + * @since 3.0.0 + * + * @param {number} delta - [description] + */ + update: function (delta) + { + if (!this.active) + { + return; + } + + if (delta === undefined) { delta = 1; } + + var cam = this.camera; + + if (this.up && this.up.isDown) + { + cam.scrollY -= ((this.speedY * delta) | 0); + } + else if (this.down && this.down.isDown) + { + cam.scrollY += ((this.speedY * delta) | 0); + } + + if (this.left && this.left.isDown) + { + cam.scrollX -= ((this.speedX * delta) | 0); + } + else if (this.right && this.right.isDown) + { + cam.scrollX += ((this.speedX * delta) | 0); + } + + // Camera zoom + + if (this.zoomIn && this.zoomIn.isDown) + { + cam.zoom -= this.zoomSpeed; + + if (cam.zoom < 0.1) + { + cam.zoom = 0.1; + } + } + else if (this.zoomOut && this.zoomOut.isDown) + { + cam.zoom += this.zoomSpeed; + } + }, + + /** + * Destroys this Key Control. + * + * @method Phaser.Cameras.Controls.FixedKeyControl#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.camera = null; + + this.left = null; + this.right = null; + this.up = null; + this.down = null; + + this.zoomIn = null; + this.zoomOut = null; + } + +}); + +module.exports = FixedKeyControl; + + +/***/ }), +/* 876 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Cameras.Controls + */ + +module.exports = { + + Fixed: __webpack_require__(875), + Smoothed: __webpack_require__(874) + +}; + + +/***/ }), +/* 877 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Cameras + */ + +module.exports = { + + Controls: __webpack_require__(876), + Scene2D: __webpack_require__(873), + Sprite3D: __webpack_require__(871) + +}; + + +/***/ }), +/* 878 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Cache + */ + +module.exports = { + + BaseCache: __webpack_require__(338), + CacheManager: __webpack_require__(337) + +}; + + +/***/ }), +/* 879 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Animations + */ + +module.exports = { + + Animation: __webpack_require__(341), + AnimationFrame: __webpack_require__(340), + AnimationManager: __webpack_require__(339) + +}; + + +/***/ }), +/* 880 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author samme + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Wrap = __webpack_require__(43); + +/** + * Wrap each item's coordinates within a rectangle's area. + * + * @function Phaser.Actions.WrapInRectangle + * @since 3.0.0 + * @see Phaser.Math.Wrap + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Rectangle} rect - The rectangle. + * @param {number} [padding=0] - An amount added to each side of the rectangle during the operation. + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var WrapInRectangle = function (items, rect, padding) +{ + if (padding === undefined) + { + padding = 0; + } + + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + + item.x = Wrap(item.x, rect.left - padding, rect.right + padding); + item.y = Wrap(item.y, rect.top - padding, rect.bottom + padding); + } + + return items; +}; + +module.exports = WrapInRectangle; + + +/***/ }), +/* 881 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Actions.ToggleVisible + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var ToggleVisible = function (items) +{ + for (var i = 0; i < items.length; i++) + { + items[i].visible = !items[i].visible; + } + + return items; +}; + +module.exports = ToggleVisible; + + +/***/ }), +/* 882 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Actions.Spread + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {string} property - [description] + * @param {number} min - [description] + * @param {number} max - [description] + * @param {number} [inc=false] - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var Spread = function (items, property, min, max, inc) +{ + if (inc === undefined) { inc = false; } + + var step = Math.abs(max - min) / items.length; + var i; + + if (inc) + { + for (i = 0; i < items.length; i++) + { + items[i][property] += i * step; + } + } + else + { + for (i = 0; i < items.length; i++) + { + items[i][property] = i * step; + } + } + + return items; +}; + +module.exports = Spread; + + +/***/ }), +/* 883 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MathSmoothStep = __webpack_require__(342); + +/** + * [description] + * + * @function Phaser.Actions.SmoothStep + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {string} property - [description] + * @param {number} min - [description] + * @param {number} max - [description] + * @param {number} inc - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var SmoothStep = function (items, property, min, max, inc) +{ + if (inc === undefined) { inc = false; } + + var step = Math.abs(max - min) / items.length; + var i; + + if (inc) + { + for (i = 0; i < items.length; i++) + { + items[i][property] += MathSmoothStep(i * step, min, max); + } + } + else + { + for (i = 0; i < items.length; i++) + { + items[i][property] = MathSmoothStep(i * step, min, max); + } + } + + return items; +}; + +module.exports = SmoothStep; + + +/***/ }), +/* 884 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MathSmootherStep = __webpack_require__(343); + +/** + * [description] + * + * @function Phaser.Actions.SmootherStep + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {string} property - [description] + * @param {number} min - [description] + * @param {number} max - [description] + * @param {number} inc - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var SmootherStep = function (items, property, min, max, inc) +{ + if (inc === undefined) { inc = false; } + + var step = Math.abs(max - min) / items.length; + var i; + + if (inc) + { + for (i = 0; i < items.length; i++) + { + items[i][property] += MathSmootherStep(i * step, min, max); + } + } + else + { + for (i = 0; i < items.length; i++) + { + items[i][property] = MathSmootherStep(i * step, min, max); + } + } + + return items; +}; + +module.exports = SmootherStep; + + +/***/ }), +/* 885 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArrayShuffle = __webpack_require__(102); + +/** + * [description] + * + * @function Phaser.Actions.Shuffle + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var Shuffle = function (items) +{ + return ArrayShuffle(items); +}; + +module.exports = Shuffle; + + +/***/ }), +/* 886 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Vector2 = __webpack_require__(6); + +/** + * Iterate through items changing the position of each element to + * be that of the element that came before it in the array (or after it if direction = 1) + * The first items position is set to x/y. + * The final x/y coords are returned + * + * @function Phaser.Actions.ShiftPosition + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {number} x - [description] + * @param {number} y - [description] + * @param {integer} [direction=0] - [description] + * @param {(Phaser.Math.Vector2|object)} [output] - [description] + * + * @return {Phaser.Math.Vector2} The output vector. + */ +var ShiftPosition = function (items, x, y, direction, output) +{ + if (direction === undefined) { direction = 0; } + if (output === undefined) { output = new Vector2(); } + + var px; + var py; + + if (items.length > 1) + { + var i; + var cx; + var cy; + var cur; + + if (direction === 0) + { + // Bottom to Top + + var len = items.length - 1; + + px = items[len].x; + py = items[len].y; + + for (i = len - 1; i >= 0; i--) + { + // Current item + cur = items[i]; + + // Get current item x/y, to be passed to the next item in the list + cx = cur.x; + cy = cur.y; + + // Set current item to the previous items x/y + cur.x = px; + cur.y = py; + + // Set current as previous + px = cx; + py = cy; + } + + // Update the head item to the new x/y coordinates + items[len].x = x; + items[len].y = y; + } + else + { + // Top to Bottom + + px = items[0].x; + py = items[0].y; + + for (i = 1; i < items.length; i++) + { + // Current item + cur = items[i]; + + // Get current item x/y, to be passed to the next item in the list + cx = cur.x; + cy = cur.y; + + // Set current item to the previous items x/y + cur.x = px; + cur.y = py; + + // Set current as previous + px = cx; + py = cy; + } + + // Update the head item to the new x/y coordinates + items[0].x = x; + items[0].y = y; + } + } + else + { + px = items[0].x; + py = items[0].y; + + items[0].x = x; + items[0].y = y; + } + + // Return the final set of coordinates as they're effectively lost from the shift and may be needed + + output.x = px; + output.y = py; + + return output; +}; + +module.exports = ShiftPosition; + + +/***/ }), +/* 887 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public property `y` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetY(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetY + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetY = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'y', value, step, index, direction); +}; + +module.exports = SetY; + + +/***/ }), +/* 888 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public properties `x` and `y` + * and then sets them to the given values. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetXY(group.getChildren(), x, y, stepX, stepY)` + * + * @function Phaser.Actions.SetXY + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} x - The amount to set the `x` property to. + * @param {number} [y=x] - The amount to set the `y` property to. If `undefined` or `null` it uses the `x` value. + * @param {number} [stepX=0] - This is added to the `x` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `y` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetXY = function (items, x, y, stepX, stepY, index, direction) +{ + if (y === undefined || y === null) { y = x; } + + PropertyValueSet(items, 'x', x, stepX, index, direction); + + return PropertyValueSet(items, 'y', y, stepY, index, direction); +}; + +module.exports = SetXY; + + +/***/ }), +/* 889 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public property `x` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetX(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetX + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetX = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'x', value, step, index, direction); +}; + +module.exports = SetX; + + +/***/ }), +/* 890 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public property `visible` + * and then sets it to the given value. + * + * To use this with a Group: `SetVisible(group.getChildren(), value)` + * + * @function Phaser.Actions.SetVisible + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {boolean} value - The value to set the property to. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetVisible = function (items, value, index, direction) +{ + return PropertyValueSet(items, 'visible', value, 0, index, direction); +}; + +module.exports = SetVisible; + + +/***/ }), +/* 891 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Actions.SetTint + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {number} topLeft - [description] + * @param {number} [topRight] - [description] + * @param {number} [bottomLeft] - [description] + * @param {number} [bottomRight] - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var SetTint = function (items, topLeft, topRight, bottomLeft, bottomRight) +{ + for (var i = 0; i < items.length; i++) + { + items[i].setTint(topLeft, topRight, bottomLeft, bottomRight); + } + + return items; +}; + +module.exports = SetTint; + + +/***/ }), +/* 892 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public property `scaleY` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetScaleY(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetScaleY + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetScaleY = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'scaleY', value, step, index, direction); +}; + +module.exports = SetScaleY; + + +/***/ }), +/* 893 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public property `scaleX` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetScaleX(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetScaleX + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetScaleX = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'scaleX', value, step, index, direction); +}; + +module.exports = SetScaleX; + + +/***/ }), +/* 894 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public properties `scaleX` and `scaleY` + * and then sets them to the given values. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetScale(group.getChildren(), scaleX, scaleY, stepX, stepY)` + * + * @function Phaser.Actions.SetScale + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} scaleX - The amount to set the `scaleX` property to. + * @param {number} [scaleY] - The amount to set the `scaleY` property to. If `undefined` or `null` it uses the `scaleX` value. + * @param {number} [stepX=0] - This is added to the `scaleX` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `scaleY` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetScale = function (items, scaleX, scaleY, stepX, stepY, index, direction) +{ + if (scaleY === undefined || scaleY === null) { scaleY = scaleX; } + + PropertyValueSet(items, 'scaleX', scaleX, stepX, index, direction); + + return PropertyValueSet(items, 'scaleY', scaleY, stepY, index, direction); +}; + +module.exports = SetScale; + + +/***/ }), +/* 895 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public property `rotation` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetRotation(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetRotation + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetRotation = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'rotation', value, step, index, direction); +}; + +module.exports = SetRotation; + + +/***/ }), +/* 896 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public properties `originX` and `originY` + * and then sets them to the given values. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetOrigin(group.getChildren(), originX, originY, stepX, stepY)` + * + * @function Phaser.Actions.SetOrigin + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} originX - The amount to set the `originX` property to. + * @param {number} [originY] - The amount to set the `originY` property to. If `undefined` or `null` it uses the `originX` value. + * @param {number} [stepX=0] - This is added to the `originX` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `originY` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetOrigin = function (items, originX, originY, stepX, stepY, index, direction) +{ + if (originY === undefined || originY === null) { originY = originX; } + + PropertyValueSet(items, 'originX', originX, stepX, index, direction); + + return PropertyValueSet(items, 'originY', originY, stepY, index, direction); +}; + +module.exports = SetOrigin; + + +/***/ }), +/* 897 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Actions.SetHitArea + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {*} hitArea - [description] + * @param {HitAreaCallback} hitAreaCallback - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var SetHitArea = function (items, hitArea, hitAreaCallback) +{ + for (var i = 0; i < items.length; i++) + { + items[i].setInteractive(hitArea, hitAreaCallback); + } + + return items; +}; + +module.exports = SetHitArea; + + +/***/ }), +/* 898 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public property `depth` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetDepth(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetDepth + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetDepth = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'depth', value, step, index, direction); +}; + +module.exports = SetDepth; + + +/***/ }), +/* 899 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public property `blendMode` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetBlendMode(group.getChildren(), value)` + * + * @function Phaser.Actions.SetBlendMode + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetBlendMode = function (items, value, index, direction) +{ + return PropertyValueSet(items, 'blendMode', value, 0, index, direction); +}; + +module.exports = SetBlendMode; + + +/***/ }), +/* 900 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public property `alpha` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetAlpha(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetAlpha + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetAlpha = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'alpha', value, step, index, direction); +}; + +module.exports = SetAlpha; + + +/***/ }), +/* 901 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(25); + +/** + * Takes an array of Game Objects, or any objects that have a public `scaleY` property, + * and then adds the given value to each of their `scaleY` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `ScaleY(group.getChildren(), value, step)` + * + * @function Phaser.Actions.ScaleY + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `scaleY` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var ScaleY = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'scaleY', value, step, index, direction); +}; + +module.exports = ScaleY; + + +/***/ }), +/* 902 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(25); + +/** + * Takes an array of Game Objects, or any objects that have public `scaleX` and `scaleY` properties, + * and then adds the given value to each of them. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `ScaleXY(group.getChildren(), scaleX, scaleY, stepX, stepY)` + * + * @function Phaser.Actions.ScaleXY + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} scaleX - The amount to be added to the `scaleX` property. + * @param {number} [scaleY] - The amount to be added to the `scaleY` property. If `undefined` or `null` it uses the `scaleX` value. + * @param {number} [stepX=0] - This is added to the `scaleX` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `y` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var ScaleXY = function (items, scaleX, scaleY, stepX, stepY, index, direction) +{ + if (scaleY === undefined || scaleY === null) { scaleY = scaleX; } + + PropertyValueInc(items, 'scaleX', scaleX, stepX, index, direction); + + return PropertyValueInc(items, 'scaleY', scaleY, stepY, index, direction); +}; + +module.exports = ScaleXY; + + +/***/ }), +/* 903 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(25); + +/** + * Takes an array of Game Objects, or any objects that have a public `scaleX` property, + * and then adds the given value to each of their `scaleX` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `ScaleX(group.getChildren(), value, step)` + * + * @function Phaser.Actions.ScaleX + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `scaleX` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var ScaleX = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'scaleX', value, step, index, direction); +}; + +module.exports = ScaleX; + + +/***/ }), +/* 904 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MathRotateAroundDistance = __webpack_require__(160); + +/** + * [description] + * + * @function Phaser.Actions.RotateAroundDistance + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {object} point - Any object with public `x` and `y` properties. + * @param {number} angle - The angle to rotate by, in radians. + * @param {number} distance - The distance from the point of rotation in pixels. + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var RotateAroundDistance = function (items, point, angle, distance) +{ + var x = point.x; + var y = point.y; + + // There's nothing to do + if (distance === 0) + { + return items; + } + + for (var i = 0; i < items.length; i++) + { + MathRotateAroundDistance(items[i], x, y, angle, distance); + } + + return items; +}; + +module.exports = RotateAroundDistance; + + +/***/ }), +/* 905 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RotateAroundDistance = __webpack_require__(160); +var DistanceBetween = __webpack_require__(48); + +/** + * [description] + * + * @function Phaser.Actions.RotateAround + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {object} point - Any object with public `x` and `y` properties. + * @param {number} angle - The angle to rotate by, in radians. + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var RotateAround = function (items, point, angle) +{ + var x = point.x; + var y = point.y; + + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + + RotateAroundDistance(item, x, y, angle, Math.max(1, DistanceBetween(item.x, item.y, x, y))); + } + + return items; +}; + +module.exports = RotateAround; + + +/***/ }), +/* 906 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(25); + +/** + * Takes an array of Game Objects, or any objects that have a public `rotation` property, + * and then adds the given value to each of their `rotation` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `Rotate(group.getChildren(), value, step)` + * + * @function Phaser.Actions.Rotate + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `rotation` property (in radians). + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var Rotate = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'rotation', value, step, index, direction); +}; + +module.exports = Rotate; + + +/***/ }), +/* 907 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Random = __webpack_require__(161); + +/** + * [description] + * + * @function Phaser.Actions.RandomTriangle + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Triangle} triangle - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var RandomTriangle = function (items, triangle) +{ + for (var i = 0; i < items.length; i++) + { + Random(triangle, items[i]); + } + + return items; +}; + +module.exports = RandomTriangle; + + +/***/ }), +/* 908 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Random = __webpack_require__(163); + +/** + * [description] + * + * @function Phaser.Actions.RandomRectangle + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var RandomRectangle = function (items, rect) +{ + for (var i = 0; i < items.length; i++) + { + Random(rect, items[i]); + } + + return items; +}; + +module.exports = RandomRectangle; + + +/***/ }), +/* 909 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Random = __webpack_require__(164); + +/** + * [description] + * + * @function Phaser.Actions.RandomLine + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Line} line - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var RandomLine = function (items, line) +{ + for (var i = 0; i < items.length; i++) + { + Random(line, items[i]); + } + + return items; +}; + +module.exports = RandomLine; + + +/***/ }), +/* 910 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Random = __webpack_require__(162); + +/** + * [description] + * + * @function Phaser.Actions.RandomEllipse + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Ellipse} ellipse - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var RandomEllipse = function (items, ellipse) +{ + for (var i = 0; i < items.length; i++) + { + Random(ellipse, items[i]); + } + + return items; +}; + +module.exports = RandomEllipse; + + +/***/ }), +/* 911 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Random = __webpack_require__(167); + +/** + * [description] + * + * @function Phaser.Actions.RandomCircle + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Circle} circle - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var RandomCircle = function (items, circle) +{ + for (var i = 0; i < items.length; i++) + { + Random(circle, items[i]); + } + + return items; +}; + +module.exports = RandomCircle; + + +/***/ }), +/* 912 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Actions.PlayAnimation + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {string} key - [description] + * @param {(string|integer)} [startFrame] - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var PlayAnimation = function (items, key, startFrame) +{ + for (var i = 0; i < items.length; i++) + { + items[i].anims.play(key, startFrame); + } + + return items; +}; + +module.exports = PlayAnimation; + + +/***/ }), +/* 913 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// var GetPointsOnLine = require('../geom/line/GetPointsOnLine'); +var BresenhamPoints = __webpack_require__(344); + +/** + * [description] + * + * @function Phaser.Actions.PlaceOnTriangle + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} [stepRate=1] - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var PlaceOnTriangle = function (items, triangle, stepRate) +{ + var p1 = BresenhamPoints({ x1: triangle.x1, y1: triangle.y1, x2: triangle.x2, y2: triangle.y2 }, stepRate); + var p2 = BresenhamPoints({ x1: triangle.x2, y1: triangle.y2, x2: triangle.x3, y2: triangle.y3 }, stepRate); + var p3 = BresenhamPoints({ x1: triangle.x3, y1: triangle.y3, x2: triangle.x1, y2: triangle.y1 }, stepRate); + + // Remove overlaps + p1.pop(); + p2.pop(); + p3.pop(); + + p1 = p1.concat(p2, p3); + + var step = p1.length / items.length; + var p = 0; + + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + var point = p1[Math.floor(p)]; + + item.x = point.x; + item.y = point.y; + + p += step; + } + + return items; +}; + +module.exports = PlaceOnTriangle; + + +/***/ }), +/* 914 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MarchingAnts = __webpack_require__(347); +var RotateLeft = __webpack_require__(346); +var RotateRight = __webpack_require__(345); + +// Place the items in the array around the perimeter of the given rectangle. + +// Placement starts from the top-left of the rectangle, and proceeds in a +// clockwise direction. If the shift parameter is given you can offset where +// placement begins. + +/** + * [description] + * + * @function Phaser.Actions.PlaceOnRectangle + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {integer} [shift=1] - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var PlaceOnRectangle = function (items, rect, shift) +{ + if (shift === undefined) { shift = 0; } + + var points = MarchingAnts(rect, false, items.length); + + if (shift > 0) + { + RotateLeft(points, shift); + } + else if (shift < 0) + { + RotateRight(points, Math.abs(shift)); + } + + for (var i = 0; i < items.length; i++) + { + items[i].x = points[i].x; + items[i].y = points[i].y; + } + + return items; +}; + +module.exports = PlaceOnRectangle; + + +/***/ }), +/* 915 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetPoints = __webpack_require__(165); + +/** + * [description] + * + * @function Phaser.Actions.PlaceOnLine + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Line} line - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var PlaceOnLine = function (items, line) +{ + var points = GetPoints(line, items.length); + + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + var point = points[i]; + + item.x = point.x; + item.y = point.y; + } + + return items; +}; + +module.exports = PlaceOnLine; + + +/***/ }), +/* 916 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Actions.PlaceOnEllipse + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Ellipse} ellipse - [description] + * @param {number} [startAngle=0] - [description] + * @param {number} [endAngle=6.28] - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var PlaceOnEllipse = function (items, ellipse, startAngle, endAngle) +{ + if (startAngle === undefined) { startAngle = 0; } + if (endAngle === undefined) { endAngle = 6.28; } + + var angle = startAngle; + var angleStep = (endAngle - startAngle) / items.length; + + var a = ellipse.width / 2; + var b = ellipse.height / 2; + + for (var i = 0; i < items.length; i++) + { + items[i].x = ellipse.x + a * Math.cos(angle); + items[i].y = ellipse.y + b * Math.sin(angle); + + angle += angleStep; + } + + return items; +}; + +module.exports = PlaceOnEllipse; + + +/***/ }), +/* 917 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Actions.PlaceOnCircle + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Circle} circle - [description] + * @param {number} [startAngle=0] - [description] + * @param {number} [endAngle=6.28] - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var PlaceOnCircle = function (items, circle, startAngle, endAngle) +{ + if (startAngle === undefined) { startAngle = 0; } + if (endAngle === undefined) { endAngle = 6.28; } + + var angle = startAngle; + var angleStep = (endAngle - startAngle) / items.length; + + for (var i = 0; i < items.length; i++) + { + items[i].x = circle.x + (circle.radius * Math.cos(angle)); + items[i].y = circle.y + (circle.radius * Math.sin(angle)); + + angle += angleStep; + } + + return items; +}; + +module.exports = PlaceOnCircle; + + +/***/ }), +/* 918 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(25); + +/** + * Takes an array of Game Objects, or any objects that have a public `y` property, + * and then adds the given value to each of their `y` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `IncY(group.getChildren(), value, step)` + * + * @function Phaser.Actions.IncY + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `y` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var IncY = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'y', value, step, index, direction); +}; + +module.exports = IncY; + + +/***/ }), +/* 919 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(25); + +/** + * Takes an array of Game Objects, or any objects that have public `x` and `y` properties, + * and then adds the given value to each of them. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `IncXY(group.getChildren(), x, y, stepX, stepY)` + * + * @function Phaser.Actions.IncXY + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} x - The amount to be added to the `x` property. + * @param {number} [y=x] - The amount to be added to the `y` property. If `undefined` or `null` it uses the `x` value. + * @param {number} [stepX=0] - This is added to the `x` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `y` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var IncXY = function (items, x, y, stepX, stepY, index, direction) +{ + if (y === undefined || y === null) { y = x; } + + PropertyValueInc(items, 'x', x, stepX, index, direction); + + return PropertyValueInc(items, 'y', y, stepY, index, direction); +}; + +module.exports = IncXY; + + +/***/ }), +/* 920 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(25); + +/** + * Takes an array of Game Objects, or any objects that have a public `x` property, + * and then adds the given value to each of their `x` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `IncX(group.getChildren(), value, step)` + * + * @function Phaser.Actions.IncX + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `x` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var IncX = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'x', value, step, index, direction); +}; + +module.exports = IncX; + + +/***/ }), +/* 921 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(25); + +/** + * Takes an array of Game Objects, or any objects that have a public `alpha` property, + * and then adds the given value to each of their `alpha` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `IncAlpha(group.getChildren(), value, step)` + * + * @function Phaser.Actions.IncAlpha + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `alpha` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var IncAlpha = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'alpha', value, step, index, direction); +}; + +module.exports = IncAlpha; + + +/***/ }), +/* 922 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// bitmask flag for GameObject.renderMask +var _FLAG = 1; // 0001 + +/** + * Provides methods used for setting the visibility of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Visible + * @since 3.0.0 + */ + +var Visible = { + + _visible: true, + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * + * @name Phaser.GameObjects.Components.Visible#visible + * @type {boolean} + * @since 3.0.0 + */ + visible: { + + get: function () + { + return this._visible; + }, + + set: function (value) + { + if (value) + { + this._visible = true; + this.renderFlags |= _FLAG; + } + else + { + this._visible = false; + this.renderFlags &= ~_FLAG; + } + } + + }, + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * + * @method Phaser.GameObjects.Components.Visible#setVisible + * @since 3.0.0 + * + * @param {boolean} value - The visible state of the Game Object. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setVisible: function (value) + { + this.visible = value; + + return this; + } +}; + +module.exports = Visible; + + +/***/ }), +/* 923 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(16); +var WrapAngle = __webpack_require__(175); +var WrapAngleDegrees = __webpack_require__(174); + +// global bitmask flag for GameObject.renderMask (used by Scale) +var _FLAG = 4; // 0100 + +/** + * Provides methods used for getting and setting the position, scale and rotation of a Game Object. + * + * @name Phaser.GameObjects.Components.Transform + * @since 3.0.0 + */ + +var Transform = { + + // "private" properties + _scaleX: 1, + _scaleY: 1, + _rotation: 0, + + /** + * The x position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + x: 0, + + /** + * The y position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + y: 0, + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + * + * @name Phaser.GameObjects.Components.Transform#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + z: 0, + + /** + * The w position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#w + * @type {number} + * @default 0 + * @since 3.0.0 + */ + w: 0, + + /** + * The horizontal scale of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#scaleX + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scaleX: { + + get: function () + { + return this._scaleX; + }, + + set: function (value) + { + this._scaleX = value; + + if (this._scaleX === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The vertical scale of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#scaleY + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scaleY: { + + get: function () + { + return this._scaleY; + }, + + set: function (value) + { + this._scaleY = value; + + if (this._scaleY === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The angle of this Game Object as expressed in degrees. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + * + * @name Phaser.GameObjects.Components.Transform#angle + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + angle: { + + get: function () + { + return WrapAngleDegrees(this._rotation * MATH_CONST.RAD_TO_DEG); + }, + + set: function (value) + { + // value is in degrees + this.rotation = WrapAngleDegrees(value) * MATH_CONST.DEG_TO_RAD; + } + }, + + /** + * The angle of this Game Object in radians. + * + * If you prefer to work in degrees, see the `angle` property instead. + * + * @name Phaser.GameObjects.Components.Transform#rotation + * @type {number} + * @default 1 + * @since 3.0.0 + */ + rotation: { + + get: function () + { + return this._rotation; + }, + + set: function (value) + { + // value is in radians + this._rotation = WrapAngle(value); + } + }, + + /** + * Sets the position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setPosition + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of this Game Object. + * @param {number} [y] - The y position of this Game Object. If not set it will use the `x` value. + * @param {number} [z=0] - The z position of this Game Object. + * @param {number} [w=0] - The w position of this Game Object. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setPosition: function (x, y, z, w) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + if (z === undefined) { z = 0; } + if (w === undefined) { w = 0; } + + this.x = x; + this.y = y; + this.z = z; + this.w = w; + + return this; + }, + + /** + * Sets the rotation of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setRotation + * @since 3.0.0 + * + * @param {number} [radians=0] - The rotation of this Game Object, in radians. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setRotation: function (radians) + { + if (radians === undefined) { radians = 0; } + + this.rotation = radians; + + return this; + }, + + /** + * Sets the angle of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setAngle + * @since 3.0.0 + * + * @param {number} [degrees=0] - The rotation of this Game Object, in degrees. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setAngle: function (degrees) + { + if (degrees === undefined) { degrees = 0; } + + this.angle = degrees; + + return this; + }, + + /** + * Sets the scale of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setScale + * @since 3.0.0 + * + * @param {number} x - The horizontal scale of this Game Object. + * @param {number} [y=x] - The vertical scale of this Game Object. If not set it will use the `x` value. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setScale: function (x, y) + { + if (x === undefined) { x = 1; } + if (y === undefined) { y = x; } + + this.scaleX = x; + this.scaleY = y; + + return this; + }, + + /** + * Sets the x position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setX + * @since 3.0.0 + * + * @param {number} [value=0] - The x position of this Game Object. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setX: function (value) + { + if (value === undefined) { value = 0; } + + this.x = value; + + return this; + }, + + /** + * Sets the y position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setY + * @since 3.0.0 + * + * @param {number} [value=0] - The y position of this Game Object. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setY: function (value) + { + if (value === undefined) { value = 0; } + + this.y = value; + + return this; + }, + + /** + * Sets the z position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setZ + * @since 3.0.0 + * + * @param {number} [value=0] - The z position of this Game Object. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setZ: function (value) + { + if (value === undefined) { value = 0; } + + this.z = value; + + return this; + }, + + /** + * Sets the w position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setW + * @since 3.0.0 + * + * @param {number} [value=0] - The w position of this Game Object. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setW: function (value) + { + if (value === undefined) { value = 0; } + + this.w = value; + + return this; + } + +}; + +module.exports = Transform; /***/ }), /* 924 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -117087,24 +117403,87 @@ module.exports = Clock; */ /** - * @namespace Phaser.Tweens + * @typedef {object} JSONGameObject + * @template DATA + * + * @property {string} name - The name of this Game Object. + * @property {string} type - A textual representation of this Game Object, i.e. `sprite`. + * @property {number} x - The x position of this Game Object. + * @property {number} y - The y position of this Game Object. + * @property {object} scale - The scale of this Game Object + * @property {number} scale.x - The horizontal scale of this Game Object. + * @property {number} scale.y - The vertical scale of this Game Object. + * @property {object} origin - The origin of this Game Object. + * @property {float} origin.x - The horizontal origin of this Game Object. + * @property {float} origin.y - The vertical origin of this Game Object. + * @property {boolean} flipX - The horizontally flipped state of the Game Object. + * @property {boolean} flipY - The vertically flipped state of the Game Object. + * @property {number} rotation - The angle of this Game Object in radians. + * @property {float} alpha - The alpha value of the Game Object. + * @property {boolean} visible - The visible state of the Game Object. + * @property {integer} scaleMode - The Scale Mode being used by this Game Object. + * @property {(integer|string)} blendMode - Sets the Blend Mode being used by this Game Object. + * @property {string} textureKey - The texture key of this Game Object. + * @property {string} frameKey - The frame key of this Game Object. + * @property {DATA} data - The data of this Game Object. */ -module.exports = { +// Default Game Object JSON export +// Is extended further by Game Object specific implementations - Builders: __webpack_require__(925), +/** + * [description] + * + * @method Phaser.GameObjects.Components.ToJSON + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * + * @return {JSONGameObject} [description] + */ +var ToJSON = function (gameObject) +{ + var out = { + name: gameObject.name, + type: gameObject.type, + x: gameObject.x, + y: gameObject.y, + depth: gameObject.depth, + scale: { + x: gameObject.scaleX, + y: gameObject.scaleY + }, + origin: { + x: gameObject.originX, + y: gameObject.originY + }, + flipX: gameObject.flipX, + flipY: gameObject.flipY, + rotation: gameObject.rotation, + alpha: gameObject.alpha, + visible: gameObject.visible, + scaleMode: gameObject.scaleMode, + blendMode: gameObject.blendMode, + textureKey: '', + frameKey: '', + data: {} + }; - TweenManager: __webpack_require__(927), - Tween: __webpack_require__(161), - TweenData: __webpack_require__(162), - Timeline: __webpack_require__(363) + if (gameObject.texture) + { + out.textureKey = gameObject.texture.key; + out.frameKey = gameObject.frame.name; + } + return out; }; +module.exports = ToJSON; + /***/ }), /* 925 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -117113,24 +117492,194 @@ module.exports = { */ /** - * @namespace Phaser.Tweens.Builders + * @function GetColor + * @since 3.0.0 + * @private + */ +var GetColor = function (value) +{ + return (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16); +}; + +/** + * Provides methods used for setting the tint of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Tint + * @webglOnly + * @since 3.0.0 */ -module.exports = { +var Tint = { - GetBoolean: __webpack_require__(73), - GetEaseFunction: __webpack_require__(71), - GetNewValue: __webpack_require__(101), - GetProps: __webpack_require__(359), - GetTargets: __webpack_require__(158), - GetTweens: __webpack_require__(360), - GetValueOp: __webpack_require__(159), - NumberTweenBuilder: __webpack_require__(361), - TimelineBuilder: __webpack_require__(362), - TweenBuilder: __webpack_require__(102) + // 0: topLeft, 1: topRight, 2: bottomLeft, 3: bottomRight + _tintTL: 16777215, + _tintTR: 16777215, + _tintBL: 16777215, + _tintBR: 16777215, + + /** + * Clears all tint values associated with this Game Object. + * Immediately sets the alpha levels back to 0xffffff (no tint) + * + * @method Phaser.GameObjects.Components.Tint#clearTint + * @webglOnly + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + clearTint: function () + { + this.setTint(0xffffff); + + return this; + }, + + /** + * Sets the tint values for this Game Object. + * + * @method Phaser.GameObjects.Components.Tint#setTint + * @webglOnly + * @since 3.0.0 + * + * @param {integer} [topLeft=0xffffff] - The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. + * @param {integer} [topRight] - The tint being applied to the top-right of the Game Object. + * @param {integer} [bottomLeft] - The tint being applied to the bottom-left of the Game Object. + * @param {integer} [bottomRight] - The tint being applied to the bottom-right of the Game Object. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setTint: function (topLeft, topRight, bottomLeft, bottomRight) + { + if (topLeft === undefined) { topLeft = 0xffffff; } + + if (topRight === undefined) + { + topRight = topLeft; + bottomLeft = topLeft; + bottomRight = topLeft; + } + + this._tintTL = GetColor(topLeft); + this._tintTR = GetColor(topRight); + this._tintBL = GetColor(bottomLeft); + this._tintBR = GetColor(bottomRight); + + return this; + }, + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintTopLeft + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintTopLeft: { + + get: function () + { + return this._tintTL; + }, + + set: function (value) + { + this._tintTL = GetColor(value); + } + + }, + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintTopRight + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintTopRight: { + + get: function () + { + return this._tintTR; + }, + + set: function (value) + { + this._tintTR = GetColor(value); + } + + }, + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintBottomLeft + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintBottomLeft: { + + get: function () + { + return this._tintBL; + }, + + set: function (value) + { + this._tintBL = GetColor(value); + } + + }, + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintBottomRight + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintBottomRight: { + + get: function () + { + return this._tintBR; + }, + + set: function (value) + { + this._tintBR = GetColor(value); + } + + }, + + /** + * The tint value being applied to the whole of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tint + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tint: { + + set: function (value) + { + this.setTint(value, value, value, value); + } + } }; +module.exports = Tint; + /***/ }), /* 926 */ @@ -117142,71 +117691,119 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// RESERVED properties that a Tween config object uses +// bitmask flag for GameObject.renderMask +var _FLAG = 8; // 1000 -// completeDelay: The time the tween will wait before the onComplete event is dispatched once it has completed -// delay: The time the tween will wait before it first starts -// duration: The duration of the tween -// ease: The ease function used by the tween -// easeParams: The parameters to go with the ease function (if any) -// flipX: flip X the GameObject on tween end -// flipY: flip Y the GameObject on tween end// hold: The time the tween will pause before running a yoyo -// hold: The time the tween will pause before running a yoyo -// loop: The time the tween will pause before starting either a yoyo or returning to the start for a repeat -// loopDelay: -// offset: Used when the Tween is part of a Timeline -// paused: Does the tween start in a paused state, or playing? -// props: The properties being tweened by the tween -// repeat: The number of times the tween will repeat itself (a value of 1 means the tween will play twice, as it repeated once) -// repeatDelay: The time the tween will pause for before starting a repeat. The tween holds in the start state. -// targets: The targets the tween is updating. -// useFrames: Use frames or milliseconds? -// yoyo: boolean - Does the tween reverse itself (yoyo) when it reaches the end? +/** + * Provides methods used for getting and setting the texture of a Game Object. + * + * @name Phaser.GameObjects.Components.Texture + * @since 3.0.0 + */ -module.exports = [ - 'callbackScope', - 'completeDelay', - 'delay', - 'duration', - 'ease', - 'easeParams', - 'flipX', - 'flipY', - 'hold', - 'loop', - 'loopDelay', - 'offset', - 'onComplete', - 'onCompleteParams', - 'onCompleteScope', - 'onLoop', - 'onLoopParams', - 'onLoopScope', - 'onRepeat', - 'onRepeatParams', - 'onRepeatScope', - 'onStart', - 'onStartParams', - 'onStartScope', - 'onUpdate', - 'onUpdateParams', - 'onUpdateScope', - 'onYoyo', - 'onYoyoParams', - 'onYoyoScope', - 'paused', - 'props', - 'repeat', - 'repeatDelay', - 'targets', - 'useFrames', - 'yoyo' -]; +var Texture = { + + /** + * The Texture this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Texture#texture + * @type {Phaser.Textures.Texture} + * @since 3.0.0 + */ + texture: null, + + /** + * The Texture Frame this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Texture#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + frame: null, + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * @method Phaser.GameObjects.Components.Texture#setTexture + * @since 3.0.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setTexture: function (key, frame) + { + this.texture = this.scene.sys.textures.get(key); + + return this.setFrame(frame); + }, + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * + * @method Phaser.GameObjects.Components.Texture#setFrame + * @since 3.0.0 + * + * @param {(string|integer)} frame - The name or index of the frame within the Texture. + * @param {boolean} [updateSize=true] - Should this call adjust the size of the Game Object? + * @param {boolean} [updateOrigin=true] - Should this call adjust the origin of the Game Object? + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setFrame: function (frame, updateSize, updateOrigin) + { + if (updateSize === undefined) { updateSize = true; } + if (updateOrigin === undefined) { updateOrigin = true; } + + this.frame = this.texture.get(frame); + + if (!this.frame.cutWidth || !this.frame.cutHeight) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + + if (this._sizeComponent && updateSize) + { + this.setSizeToFrame(); + } + + if (this._originComponent && updateOrigin) + { + if (this.frame.customPivot) + { + this.setOrigin(this.frame.pivotX, this.frame.pivotY); + } + else + { + this.updateDisplayOrigin(); + } + } + + return this; + } + +}; + +module.exports = Texture; /***/ }), /* 927 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -117214,653 +117811,155 @@ module.exports = [ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var NumberTweenBuilder = __webpack_require__(361); -var PluginManager = __webpack_require__(12); -var TimelineBuilder = __webpack_require__(362); -var TWEEN_CONST = __webpack_require__(87); -var TweenBuilder = __webpack_require__(102); - -// Phaser.Tweens.TweenManager - /** - * @classdesc - * [description] - * - * @class TweenManager - * @memberOf Phaser.Tweens - * @constructor + * Provides methods used for getting and setting the size of a Game Object. + * + * @name Phaser.GameObjects.Components.Size * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] */ -var TweenManager = new Class({ - initialize: +var Size = { - function TweenManager (scene) - { - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; + /** + * A property indicating that a Game Object has this component. + * + * @name Phaser.GameObjects.Components.Size#_sizeComponent + * @type {boolean} + * @private + * @default true + * @since 3.2.0 + */ + _sizeComponent: true, - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; + /** + * The native (un-scaled) width of this Game Object. + * + * @name Phaser.GameObjects.Components.Size#width + * @type {number} + * @since 3.0.0 + */ + width: 0, - if (!scene.sys.settings.isBooted) + /** + * The native (un-scaled) height of this Game Object. + * + * @name Phaser.GameObjects.Components.Size#height + * @type {number} + * @since 3.0.0 + */ + height: 0, + + /** + * The displayed width of this Game Object. + * This value takes into account the scale factor. + * + * @name Phaser.GameObjects.Components.Size#displayWidth + * @type {number} + * @since 3.0.0 + */ + displayWidth: { + + get: function () { - scene.sys.events.once('boot', this.boot, this); + return this.scaleX * this.frame.realWidth; + }, + + set: function (value) + { + this.scaleX = value / this.frame.realWidth; } - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#timeScale - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#_add - * @type {array} - * @private - * @since 3.0.0 - */ - this._add = []; - - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#_pending - * @type {array} - * @private - * @since 3.0.0 - */ - this._pending = []; - - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#_active - * @type {array} - * @private - * @since 3.0.0 - */ - this._active = []; - - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#_destroy - * @type {array} - * @private - * @since 3.0.0 - */ - this._destroy = []; - - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#_toProcess - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - this._toProcess = 0; }, /** - * [description] - * - * @method Phaser.Tweens.TweenManager#boot + * The displayed height of this Game Object. + * This value takes into account the scale factor. + * + * @name Phaser.GameObjects.Components.Size#displayHeight + * @type {number} * @since 3.0.0 */ - boot: function () - { - var eventEmitter = this.systems.events; + displayHeight: { - eventEmitter.on('preupdate', this.preUpdate, this); - eventEmitter.on('update', this.update, this); - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); - - this.timeScale = 1; - }, - - /** - * Create a Tween Timeline and return it, but do NOT add it to the active or pending Tween lists. - * - * @method Phaser.Tweens.TweenManager#createTimeline - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.Tweens.Timeline} [description] - */ - createTimeline: function (config) - { - return TimelineBuilder(this, config); - }, - - /** - * Create a Tween Timeline and add it to the active Tween list/ - * - * @method Phaser.Tweens.TweenManager#timeline - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.Tweens.Timeline} [description] - */ - timeline: function (config) - { - var timeline = TimelineBuilder(this, config); - - if (!timeline.paused) + get: function () { - this._add.push(timeline); + return this.scaleY * this.frame.realHeight; + }, - this._toProcess++; + set: function (value) + { + this.scaleY = value / this.frame.realHeight; } - return timeline; }, /** - * Create a Tween and return it, but do NOT add it to the active or pending Tween lists. - * - * @method Phaser.Tweens.TweenManager#create + * Sets the size of this Game Object to be that of the given Frame. + * + * @method Phaser.GameObjects.Components.Size#setSizeToFrame * @since 3.0.0 * - * @param {object} config - [description] - * - * @return {Phaser.Tweens.Tween} [description] + * @param {Phaser.Textures.Frame} frame - The frame to base the size of this Game Object on. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. */ - create: function (config) + setSizeToFrame: function (frame) { - return TweenBuilder(this, config); - }, + if (frame === undefined) { frame = this.frame; } - /** - * Create a Tween and add it to the active Tween list. - * - * @method Phaser.Tweens.TweenManager#add - * @since 3.0.0 - * - * @param {[type]} config - [description] - * - * @return {Phaser.Tweens.Tween} [description] - */ - add: function (config) - { - var tween = TweenBuilder(this, config); - - this._add.push(tween); - - this._toProcess++; - - return tween; - }, - - /** - * Add an existing tween into the active Tween list. - * - * @method Phaser.Tweens.TweenManager#existing - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * - * @return {Phaser.Tweens.TweenManager} This Tween Manager object. - */ - existing: function (tween) - { - this._add.push(tween); - - this._toProcess++; + this.width = frame.realWidth; + this.height = frame.realHeight; return this; }, /** - * Create a Tween and add it to the active Tween list. - * - * @method Phaser.Tweens.TweenManager#addCounter + * Sets the size of this Game Object. + * + * @method Phaser.GameObjects.Components.Size#setSize * @since 3.0.0 * - * @param {object} config - [description] - * - * @return {Phaser.Tweens.Tween} [description] + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. */ - addCounter: function (config) + setSize: function (width, height) { - var tween = NumberTweenBuilder(this, config); - - this._add.push(tween); - - this._toProcess++; - - return tween; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#preUpdate - * @since 3.0.0 - */ - preUpdate: function () - { - if (this._toProcess === 0) - { - // Quick bail - return; - } - - var list = this._destroy; - var active = this._active; - var i; - var tween; - - // Clear the 'destroy' list - for (i = 0; i < list.length; i++) - { - tween = list[i]; - - // Remove from the 'active' array - var idx = active.indexOf(tween); - - if (idx !== -1) - { - tween.state = TWEEN_CONST.REMOVED; - active.splice(idx, 1); - } - } - - list.length = 0; - - // Process the addition list - // This stops callbacks and out of sync events from populating the active array mid-way during the update - - list = this._add; - - for (i = 0; i < list.length; i++) - { - tween = list[i]; - - // Return true if the Tween should be started right away, otherwise false - if (tween.init()) - { - tween.play(); - - this._active.push(tween); - } - else - { - this._pending.push(tween); - } - } - - list.length = 0; - - this._toProcess = 0; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#update - * @since 3.0.0 - * - * @param {number} timestamp - [description] - * @param {number} delta - [description] - */ - update: function (timestamp, delta) - { - // Process active tweens - var list = this._active; - var tween; - - // Scale the delta - delta *= this.timeScale; - - for (var i = 0; i < list.length; i++) - { - tween = list[i]; - - // If Tween.update returns 'true' then it means it has completed, - // so move it to the destroy list - if (tween.update(timestamp, delta)) - { - this._destroy.push(tween); - this._toProcess++; - } - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#makeActive - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * - * @return {Phaser.Tweens.TweenManager} This Tween Manager object. - */ - makeActive: function (tween) - { - if (this._add.indexOf(tween) !== -1 || this._active.indexOf(tween) !== -1) - { - return; - } - - var idx = this._pending.indexOf(tween); - - if (idx !== -1) - { - this._pending.splice(idx, 1); - } - - this._add.push(tween); - - tween.state = TWEEN_CONST.PENDING_ADD; - - this._toProcess++; + this.width = width; + this.height = height; return this; }, /** - * Passes all Tweens to the given callback. - * - * @method Phaser.Tweens.TweenManager#each + * Sets the display size of this Game Object. + * Calling this will adjust the scale. + * + * @method Phaser.GameObjects.Components.Size#setDisplaySize * @since 3.0.0 * - * @param {function} callback - [description] - * @param {object} [scope] - [description] - * @param {...*} [arguments] - [description] + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. */ - each: function (callback, scope) + setDisplaySize: function (width, height) { - var args = [ null ]; - - for (var i = 1; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - for (var texture in this.list) - { - args[0] = this.list[texture]; - - callback.apply(scope, args); - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#getAllTweens - * @since 3.0.0 - * - * @return {Phaser.Tweens.Tween[]} [description] - */ - getAllTweens: function () - { - var list = this._active; - var output = []; - - for (var i = 0; i < list.length; i++) - { - output.push(list[i]); - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#getGlobalTimeScale - * @since 3.0.0 - * - * @return {number} [description] - */ - getGlobalTimeScale: function () - { - return this.timeScale; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#getTweensOf - * @since 3.0.0 - * - * @param {object|array} target - [description] - * - * @return {Phaser.Tweens.Tween[]} [description] - */ - getTweensOf: function (target) - { - var list = this._active; - var tween; - var output = []; - var i; - - if (Array.isArray(target)) - { - for (i = 0; i < list.length; i++) - { - tween = list[i]; - - for (var t = 0; t < target.length; i++) - { - if (tween.hasTarget(target[t])) - { - output.push(tween); - } - } - } - } - else - { - for (i = 0; i < list.length; i++) - { - tween = list[i]; - - if (tween.hasTarget(target)) - { - output.push(tween); - } - } - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#isTweening - * @since 3.0.0 - * - * @param {object} target - [description] - * - * @return {boolean} [description] - */ - isTweening: function (target) - { - var list = this._active; - var tween; - - for (var i = 0; i < list.length; i++) - { - tween = list[i]; - - if (tween.hasTarget(target) && tween.isPlaying()) - { - return true; - } - } - - return false; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#killAll - * @since 3.0.0 - * - * @return {Phaser.Tweens.TweenManager} [description] - */ - killAll: function () - { - var tweens = this.getAllTweens(); - - for (var i = 0; i < tweens.length; i++) - { - tweens[i].stop(); - } + this.displayWidth = width; + this.displayHeight = height; return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#killTweensOf - * @since 3.0.0 - * - * @param {object|array} target - [description] - * - * @return {Phaser.Tweens.TweenManager} [description] - */ - killTweensOf: function (target) - { - var tweens = this.getTweensOf(target); - - for (var i = 0; i < tweens.length; i++) - { - tweens[i].stop(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#pauseAll - * @since 3.0.0 - * - * @return {Phaser.Tweens.TweenManager} [description] - */ - pauseAll: function () - { - var list = this._active; - - for (var i = 0; i < list.length; i++) - { - list[i].pause(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#resumeAll - * @since 3.0.0 - * - * @return {Phaser.Tweens.TweenManager} [description] - */ - resumeAll: function () - { - var list = this._active; - - for (var i = 0; i < list.length; i++) - { - list[i].resume(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#setGlobalTimeScale - * @since 3.0.0 - * - * @param {float} value - [description] - * - * @return {Phaser.Tweens.TweenManager} [description] - */ - setGlobalTimeScale: function (value) - { - this.timeScale = value; - - return this; - }, - - /** - * Scene that owns this manager is shutting down. - * - * @method Phaser.Tweens.TweenManager#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this.killAll(); - - this._add = []; - this._pending = []; - this._active = []; - this._destroy = []; - - this._toProcess = 0; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.shutdown(); } -}); +}; -PluginManager.register('TweenManager', TweenManager, 'tweens'); - -module.exports = TweenManager; +module.exports = Size; /***/ }), /* 928 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -117869,17 +117968,86 @@ module.exports = TweenManager; */ /** - * @namespace Phaser.Utils + * Provides methods used for getting and setting the Scroll Factor of a Game Object. + * + * @name Phaser.GameObjects.Components.ScrollFactor + * @since 3.0.0 */ -module.exports = { +var ScrollFactor = { - Array: __webpack_require__(929), - Objects: __webpack_require__(933), - String: __webpack_require__(937) + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorX + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scrollFactorX: 1, + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorY + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scrollFactorY: 1, + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * @method Phaser.GameObjects.Components.ScrollFactor#setScrollFactor + * @since 3.0.0 + * + * @param {number} x - The horizontal scroll factor of this Game Object. + * @param {number} [y] - The vertical scroll factor of this Game Object. If not set it will use the `x` value. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setScrollFactor: function (x, y) + { + if (y === undefined) { y = x; } + + this.scrollFactorX = x; + this.scrollFactorY = y; + + return this; + } }; +module.exports = ScrollFactor; + /***/ }), /* 929 */ @@ -117891,26 +118059,66 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var ScaleModes = __webpack_require__(80); + /** - * @namespace Phaser.Utils.Array + * Provides methods used for getting and setting the scale of a Game Object. + * + * @name Phaser.GameObjects.Components.ScaleMode + * @since 3.0.0 */ -module.exports = { +var ScaleMode = { - FindClosestInSorted: __webpack_require__(930), - GetRandomElement: __webpack_require__(140), - NumberArray: __webpack_require__(319), - NumberArrayStep: __webpack_require__(931), - QuickSelect: __webpack_require__(338), - Range: __webpack_require__(275), - RemoveRandomElement: __webpack_require__(932), - RotateLeft: __webpack_require__(192), - RotateRight: __webpack_require__(193), - Shuffle: __webpack_require__(80), - SpliceOne: __webpack_require__(364) + _scaleMode: ScaleModes.DEFAULT, + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * + * @name Phaser.GameObjects.Components.ScaleMode#scaleMode + * @type {integer} + * @since 3.0.0 + */ + scaleMode: { + + get: function () + { + return this._scaleMode; + }, + + set: function (value) + { + if (value === ScaleModes.LINEAR || value === ScaleModes.NEAREST) + { + this._scaleMode = value; + } + } + + }, + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * + * @method Phaser.GameObjects.Components.ScaleMode#setScaleMode + * @since 3.0.0 + * + * @param {integer} value - The Scale Mode to be used by this Game Object. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setScaleMode: function (value) + { + this.scaleMode = value; + + return this; + } }; +module.exports = ScaleMode; + /***/ }), /* 930 */ @@ -117923,46 +118131,201 @@ module.exports = { */ /** - * [description] - * - * @function Phaser.Utils.Array.FindClosestInSorted + * Provides methods used for getting and setting the origin of a Game Object. + * Values are normalized, given in the range 0 to 1. + * Display values contain the calculated pixel values. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Origin * @since 3.0.0 - * - * @param {number} value - The value to search for in the array. - * @param {array} array - The array to search, which must be sorted. - * - * @return {number} The nearest value found in the array. */ -var FindClosestInSorted = function (value, array) -{ - if (!array.length) + +var Origin = { + + /** + * A property indicating that a Game Object has this component. + * + * @name Phaser.GameObjects.Components.Origin#_originComponent + * @type {boolean} + * @private + * @default true + * @since 3.2.0 + */ + _originComponent: true, + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + * + * @name Phaser.GameObjects.Components.Origin#originX + * @type {float} + * @default 0.5 + * @since 3.0.0 + */ + originX: 0.5, + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + * + * @name Phaser.GameObjects.Components.Origin#originY + * @type {float} + * @default 0.5 + * @since 3.0.0 + */ + originY: 0.5, + + // private + read only + _displayOriginX: 0, + _displayOriginY: 0, + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * + * @name Phaser.GameObjects.Components.Origin#displayOriginX + * @type {float} + * @since 3.0.0 + */ + displayOriginX: { + + get: function () + { + return this._displayOriginX; + }, + + set: function (value) + { + this._displayOriginX = value; + this.originX = value / this.width; + } + + }, + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * + * @name Phaser.GameObjects.Components.Origin#displayOriginY + * @type {float} + * @since 3.0.0 + */ + displayOriginY: { + + get: function () + { + return this._displayOriginY; + }, + + set: function (value) + { + this._displayOriginY = value; + this.originY = value / this.height; + } + + }, + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * + * @method Phaser.GameObjects.Components.Origin#setOrigin + * @since 3.0.0 + * + * @param {number} [x=0.5] - The horizontal origin value. + * @param {number} [y=0.5] - The vertical origin value. If not defined it will be set to the value of `x`. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setOrigin: function (x, y) { - return NaN; - } - else if (array.length === 1 || value < array[0]) + if (x === undefined) { x = 0.5; } + if (y === undefined) { y = x; } + + this.originX = x; + this.originY = y; + + return this.updateDisplayOrigin(); + }, + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + * + * @method Phaser.GameObjects.Components.Origin#setOriginFromFrame + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setOriginFromFrame: function () { - return array[0]; + if (!this.frame || !this.frame.customPivot) + { + return this.setOrigin(); + } + else + { + this.originX = this.frame.pivotX; + this.originY = this.frame.pivotY; + } + + return this.updateDisplayOrigin(); + }, + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * + * @method Phaser.GameObjects.Components.Origin#setDisplayOrigin + * @since 3.0.0 + * + * @param {number} [x=0] - The horizontal display origin value. + * @param {number} [y=0] - The vertical display origin value. If not defined it will be set to the value of `x`. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setDisplayOrigin: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + + this.displayOriginX = x; + this.displayOriginY = y; + + return this; + }, + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + * + * @method Phaser.GameObjects.Components.Origin#updateDisplayOrigin + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + updateDisplayOrigin: function () + { + this._displayOriginX = Math.round(this.originX * this.width); + this._displayOriginY = Math.round(this.originY * this.height); + + return this; } - var i = 1; - - while (array[i] < value) - { - i++; - } - - var low = array[i - 1]; - var high = (i < array.length) ? array[i] : Number.POSITIVE_INFINITY; - - return ((high - value) <= (value - low)) ? high : low; }; -module.exports = FindClosestInSorted; +module.exports = Origin; /***/ }), /* 931 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -117970,71 +118333,282 @@ module.exports = FindClosestInSorted; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RoundAwayFromZero = __webpack_require__(325); - /** - * Create an array of numbers (positive and/or negative) progressing from `start` - * up to but not including `end` by advancing by `step`. - * - * If `start` is less than `end` a zero-length range is created unless a negative `step` is specified. - * - * Certain values for `start` and `end` (eg. NaN/undefined/null) are currently coerced to 0; - * for forward compatibility make sure to pass in actual numbers. + * Provides methods used for getting and setting the transform values of a Game Object. + * Should be applied as a mixin and not used directly. * - * @example - * NumberArrayStep(4); - * // => [0, 1, 2, 3] - * - * NumberArrayStep(1, 5); - * // => [1, 2, 3, 4] - * - * NumberArrayStep(0, 20, 5); - * // => [0, 5, 10, 15] - * - * NumberArrayStep(0, -4, -1); - * // => [0, -1, -2, -3] - * - * NumberArrayStep(1, 4, 0); - * // => [1, 1, 1] - * - * NumberArrayStep(0); - * // => [] - * - * @function Phaser.Utils.Array.NumberArrayStep - * @since 3.0.0 - * - * @param {number} [start=0] - The start of the range. - * @param {number} [end=null] - The end of the range. - * @param {number} [step=1] - The value to increment or decrement by. - * - * @return {number[]} [description] + * @name Phaser.GameObjects.Components.MatrixStack + * @since 3.2.0 */ -var NumberArrayStep = function (start, end, step) -{ - if (start === undefined) { start = 0; } - if (end === undefined) { end = null; } - if (step === undefined) { step = 1; } - if (end === null) +var MatrixStack = { + + /** + * [description] + * + * @name Phaser.GameObjects.Components.MatrixStack#matrixStack + * @type {Float32Array} + * @private + * @since 3.2.0 + */ + matrixStack: null, + + /** + * [description] + * + * @name Phaser.GameObjects.Components.MatrixStack#currentMatrix + * @type {Float32Array} + * @private + * @since 3.2.0 + */ + currentMatrix: null, + + /** + * [description] + * + * @name Phaser.GameObjects.Components.MatrixStack#currentMatrixIndex + * @type {integer} + * @private + * @since 3.2.0 + */ + currentMatrixIndex: 0, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.MatrixStack#initMatrixStack + * @since 3.2.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + initMatrixStack: function () { - end = start; - start = 0; + this.matrixStack = new Float32Array(6000); // up to 1000 matrices + this.currentMatrix = new Float32Array([ 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 ]); + this.currentMatrixIndex = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.MatrixStack#save + * @since 3.2.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + save: function () + { + if (this.currentMatrixIndex >= this.matrixStack.length) { return this; } + + var matrixStack = this.matrixStack; + var currentMatrix = this.currentMatrix; + var currentMatrixIndex = this.currentMatrixIndex; + this.currentMatrixIndex += 6; + + matrixStack[currentMatrixIndex + 0] = currentMatrix[0]; + matrixStack[currentMatrixIndex + 1] = currentMatrix[1]; + matrixStack[currentMatrixIndex + 2] = currentMatrix[2]; + matrixStack[currentMatrixIndex + 3] = currentMatrix[3]; + matrixStack[currentMatrixIndex + 4] = currentMatrix[4]; + matrixStack[currentMatrixIndex + 5] = currentMatrix[5]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.MatrixStack#restore + * @since 3.2.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + restore: function () + { + if (this.currentMatrixIndex <= 0) { return this; } + + this.currentMatrixIndex -= 6; + + var matrixStack = this.matrixStack; + var currentMatrix = this.currentMatrix; + var currentMatrixIndex = this.currentMatrixIndex; + + currentMatrix[0] = matrixStack[currentMatrixIndex + 0]; + currentMatrix[1] = matrixStack[currentMatrixIndex + 1]; + currentMatrix[2] = matrixStack[currentMatrixIndex + 2]; + currentMatrix[3] = matrixStack[currentMatrixIndex + 3]; + currentMatrix[4] = matrixStack[currentMatrixIndex + 4]; + currentMatrix[5] = matrixStack[currentMatrixIndex + 5]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.MatrixStack#loadIdentity + * @since 3.2.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + loadIdentity: function () + { + this.setTransform(1.0, 0.0, 0.0, 1.0, 0.0, 0.0); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.MatrixStack#transform + * @since 3.2.0 + * + * @param {number} a - [description] + * @param {number} b - [description] + * @param {number} c - [description] + * @param {number} d - [description] + * @param {number} tx - [description] + * @param {number} ty - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + transform: function (a, b, c, d, tx, ty) + { + var currentMatrix = this.currentMatrix; + var m0 = currentMatrix[0]; + var m1 = currentMatrix[1]; + var m2 = currentMatrix[2]; + var m3 = currentMatrix[3]; + var m4 = currentMatrix[4]; + var m5 = currentMatrix[5]; + + currentMatrix[0] = m0 * a + m2 * b; + currentMatrix[1] = m1 * a + m3 * b; + currentMatrix[2] = m0 * c + m2 * d; + currentMatrix[3] = m1 * c + m3 * d; + currentMatrix[4] = m0 * tx + m2 * ty + m4; + currentMatrix[5] = m1 * tx + m3 * ty + m5; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.MatrixStack#setTransform + * @since 3.2.0 + * + * @param {number} a - [description] + * @param {number} b - [description] + * @param {number} c - [description] + * @param {number} d - [description] + * @param {number} tx - [description] + * @param {number} ty - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setTransform: function (a, b, c, d, tx, ty) + { + var currentMatrix = this.currentMatrix; + + currentMatrix[0] = a; + currentMatrix[1] = b; + currentMatrix[2] = c; + currentMatrix[3] = d; + currentMatrix[4] = tx; + currentMatrix[5] = ty; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.MatrixStack#translate + * @since 3.2.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + translate: function (x, y) + { + var currentMatrix = this.currentMatrix; + var m0 = currentMatrix[0]; + var m1 = currentMatrix[1]; + var m2 = currentMatrix[2]; + var m3 = currentMatrix[3]; + var m4 = currentMatrix[4]; + var m5 = currentMatrix[5]; + + currentMatrix[4] = m0 * x + m2 * y + m4; + currentMatrix[5] = m1 * x + m3 * y + m5; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.MatrixStack#scale + * @since 3.2.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + scale: function (x, y) + { + var currentMatrix = this.currentMatrix; + var m0 = currentMatrix[0]; + var m1 = currentMatrix[1]; + var m2 = currentMatrix[2]; + var m3 = currentMatrix[3]; + + currentMatrix[0] = m0 * x; + currentMatrix[1] = m1 * x; + currentMatrix[2] = m2 * y; + currentMatrix[3] = m3 * y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.MatrixStack#rotate + * @since 3.2.0 + * + * @param {number} t - The angle of rotation, in radians. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + rotate: function (t) + { + var currentMatrix = this.currentMatrix; + var m0 = currentMatrix[0]; + var m1 = currentMatrix[1]; + var m2 = currentMatrix[2]; + var m3 = currentMatrix[3]; + var st = Math.sin(t); + var ct = Math.cos(t); + + currentMatrix[0] = m0 * ct + m2 * st; + currentMatrix[1] = m1 * ct + m3 * st; + currentMatrix[2] = m0 * -st + m2 * ct; + currentMatrix[3] = m1 * -st + m3 * ct; + + return this; } - var result = []; - - var total = Math.max(RoundAwayFromZero((end - start) / (step || 1)), 0); - - for (var i = 0; i < total; i++) - { - result.push(start); - start += step; - } - - return result; }; -module.exports = NumberArrayStep; +module.exports = MatrixStack; /***/ }), @@ -118047,37 +118621,193 @@ module.exports = NumberArrayStep; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var SpliceOne = __webpack_require__(364); +var Rectangle = __webpack_require__(10); +var RotateAround = __webpack_require__(350); +var Vector2 = __webpack_require__(6); /** - * Removes a random object from the given array and returns it. - * Will return null if there are no array items that fall within the specified range or if there is no item for the randomly chosen index. + * Provides methods used for obtaining the bounds of a Game Object. + * Should be applied as a mixin and not used directly. * - * @function Phaser.Utils.Array.RemoveRandomElement + * @name Phaser.GameObjects.Components.GetBounds * @since 3.0.0 - * - * @param {array} array - The array to removed a random element from. - * @param {integer} [start=0] - The array index to start the search from. - * @param {integer} [length=array.length] - Optional restriction on the number of elements to randomly select from. - * - * @return {object} The random element that was removed, or `null` if there were no array elements that fell within the given range. */ -var RemoveRandomElement = function (array, start, length) -{ - if (start === undefined) { start = 0; } - if (length === undefined) { length = array.length; } - var randomIndex = start + Math.floor(Math.random() * length); +var GetBounds = { + + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * + * @method Phaser.GameObjects.Components.GetBounds#getCenter + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|object)} [output] - An object to store the values in. If not provided a new Vector2 will be created. + * + * @return {(Phaser.Math.Vector2|object)} The values stored in the output object. + */ + getCenter: function (output) + { + if (output === undefined) { output = new Vector2(); } + + output.x = this.x - (this.displayWidth * this.originX) + (this.displayWidth / 2); + output.y = this.y - (this.displayHeight * this.originY) + (this.displayHeight / 2); + + return output; + }, + + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * + * @method Phaser.GameObjects.Components.GetBounds#getTopLeft + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|object)} [output] - An object to store the values in. If not provided a new Vector2 will be created. + * + * @return {(Phaser.Math.Vector2|object)} The values stored in the output object. + */ + getTopLeft: function (output) + { + if (output === undefined) { output = new Vector2(); } + + output.x = this.x - (this.displayWidth * this.originX); + output.y = this.y - (this.displayHeight * this.originY); + + if (this.rotation !== 0) + { + RotateAround(output, this.x, this.y, this.rotation); + } + + return output; + }, + + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * + * @method Phaser.GameObjects.Components.GetBounds#getTopRight + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|object)} [output] - An object to store the values in. If not provided a new Vector2 will be created. + * + * @return {(Phaser.Math.Vector2|object)} The values stored in the output object. + */ + getTopRight: function (output) + { + if (output === undefined) { output = new Vector2(); } + + output.x = (this.x - (this.displayWidth * this.originX)) + this.displayWidth; + output.y = this.y - (this.displayHeight * this.originY); + + if (this.rotation !== 0) + { + RotateAround(output, this.x, this.y, this.rotation); + } + + return output; + }, + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * + * @method Phaser.GameObjects.Components.GetBounds#getBottomLeft + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|object)} [output] - An object to store the values in. If not provided a new Vector2 will be created. + * + * @return {(Phaser.Math.Vector2|object)} The values stored in the output object. + */ + getBottomLeft: function (output) + { + if (output === undefined) { output = new Vector2(); } + + output.x = this.x - (this.displayWidth * this.originX); + output.y = (this.y - (this.displayHeight * this.originY)) + this.displayHeight; + + if (this.rotation !== 0) + { + RotateAround(output, this.x, this.y, this.rotation); + } + + return output; + }, + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * + * @method Phaser.GameObjects.Components.GetBounds#getBottomRight + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|object)} [output] - An object to store the values in. If not provided a new Vector2 will be created. + * + * @return {(Phaser.Math.Vector2|object)} The values stored in the output object. + */ + getBottomRight: function (output) + { + if (output === undefined) { output = new Vector2(); } + + output.x = (this.x - (this.displayWidth * this.originX)) + this.displayWidth; + output.y = (this.y - (this.displayHeight * this.originY)) + this.displayHeight; + + if (this.rotation !== 0) + { + RotateAround(output, this.x, this.y, this.rotation); + } + + return output; + }, + + /** + * Gets the bounds of this Game Object, regardless of origin. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * + * @method Phaser.GameObjects.Components.GetBounds#getBounds + * @since 3.0.0 + * + * @param {(Phaser.Geom.Rectangle|object)} [output] - An object to store the values in. If not provided a new Rectangle will be created. + * + * @return {(Phaser.Geom.Rectangle|object)} The values stored in the output object. + */ + getBounds: function (output) + { + if (output === undefined) { output = new Rectangle(); } + + // We can use the output object to temporarily store the x/y coords in: + + this.getTopLeft(output); + + var TLx = output.x; + var TLy = output.y; + + this.getTopRight(output); + + var TRx = output.x; + var TRy = output.y; + + this.getBottomLeft(output); + + var BLx = output.x; + var BLy = output.y; + + this.getBottomRight(output); + + var BRx = output.x; + var BRy = output.y; + + output.x = Math.min(TLx, TRx, BLx, BRx); + output.y = Math.min(TLy, TRy, BLy, BRy); + output.width = Math.max(TLx, TRx, BLx, BRx) - output.x; + output.height = Math.max(TLy, TRy, BLy, BRy) - output.y; + + return output; + } - return SpliceOne(array, randomIndex); }; -module.exports = RemoveRandomElement; +module.exports = GetBounds; /***/ }), /* 933 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -118086,30 +118816,146 @@ module.exports = RemoveRandomElement; */ /** - * @namespace Phaser.Utils.Object + * Provides methods used for visually flipping a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Flip + * @since 3.0.0 */ -module.exports = { +var Flip = { - Clone: __webpack_require__(53), - Extend: __webpack_require__(23), - GetAdvancedValue: __webpack_require__(10), - GetFastValue: __webpack_require__(2), - GetMinMaxValue: __webpack_require__(934), - GetValue: __webpack_require__(4), - HasAll: __webpack_require__(935), - HasAny: __webpack_require__(289), - HasValue: __webpack_require__(72), - IsPlainObject: __webpack_require__(170), - Merge: __webpack_require__(104), - MergeRight: __webpack_require__(936) + /** + * The horizontally flipped state of the Game Object. + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * + * @name Phaser.GameObjects.Components.Flip#flipX + * @type {boolean} + * @default false + * @since 3.0.0 + */ + flipX: false, + + /** + * The vertically flipped state of the Game Object. + * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * + * @name Phaser.GameObjects.Components.Flip#flipY + * @type {boolean} + * @default false + * @since 3.0.0 + */ + flipY: false, + + /** + * Toggles the horizontal flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#toggleFlipX + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + toggleFlipX: function () + { + this.flipX = !this.flipX; + + return this; + }, + + /** + * Toggles the vertical flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#toggleFlipY + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + toggleFlipY: function () + { + this.flipY = !this.flipY; + + return this; + }, + + /** + * Sets the horizontal flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#setFlipX + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setFlipX: function (value) + { + this.flipX = value; + + return this; + }, + + /** + * Sets the vertical flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#setFlipY + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setFlipY: function (value) + { + this.flipY = value; + + return this; + }, + + /** + * Sets the horizontal and vertical flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#setFlip + * @since 3.0.0 + * + * @param {boolean} x - The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param {boolean} y - The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setFlip: function (x, y) + { + this.flipX = x; + this.flipY = y; + + return this; + }, + + /** + * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. + * + * @method Phaser.GameObjects.Components.Flip#resetFlip + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + resetFlip: function () + { + this.flipX = false; + this.flipY = false; + + return this; + } }; +module.exports = Flip; + /***/ }), /* 934 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -118117,33 +118963,78 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetValue = __webpack_require__(4); -var Clamp = __webpack_require__(61); - /** - * [description] - * - * @function Phaser.Utils.Object.GetMinMaxValue + * Provides methods used for setting the depth of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Depth * @since 3.0.0 - * - * @param {[type]} source - [description] - * @param {string} key - [description] - * @param {number} min - [description] - * @param {number} max - [description] - * @param {number} defaultValue - [description] - * - * @return {number} [description] */ -var GetMinMaxValue = function (source, key, min, max, defaultValue) -{ - if (defaultValue === undefined) { defaultValue = min; } - var value = GetValue(source, key, defaultValue); +var Depth = { + + _depth: 0, + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * + * @name Phaser.GameObjects.Components.Depth#depth + * @type {number} + * @since 3.0.0 + */ + depth: { + + get: function () + { + return this._depth; + }, + + set: function (value) + { + this.scene.sys.queueDepthSort(); + this._depth = value; + } + + }, + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * + * @method Phaser.GameObjects.Components.Depth#setDepth + * @since 3.0.0 + * + * @param {integer} value - The depth of this Game Object. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setDepth: function (value) + { + if (value === undefined) { value = 0; } + + this.depth = value; + + return this; + } - return Clamp(value, min, max); }; -module.exports = GetMinMaxValue; +module.exports = Depth; /***/ }), @@ -118157,30 +119048,80 @@ module.exports = GetMinMaxValue; */ /** - * [description] - * - * @function Phaser.Utils.Object.HasAll + * Provides methods used for setting the blend mode of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.ComputedSize * @since 3.0.0 - * - * @param {object} source - [description] - * @param {string[]} keys - [description] - * - * @return {boolean} [description] */ -var HasAll = function (source, keys) -{ - for (var i = 0; i < keys.length; i++) - { - if (!source.hasOwnProperty(keys[i])) + +var ComputedSize = { + + /** + * The native (un-scaled) width of this Game Object. + * + * @name Phaser.GameObjects.Components.ComputedSize#width + * @type {number} + * @since 3.0.0 + */ + width: 0, + + /** + * The native (un-scaled) height of this Game Object. + * + * @name Phaser.GameObjects.Components.ComputedSize#height + * @type {number} + * @since 3.0.0 + */ + height: 0, + + /** + * The displayed width of this Game Object. + * This value takes into account the scale factor. + * + * @name Phaser.GameObjects.Components.ComputedSize#displayWidth + * @type {number} + * @since 3.0.0 + */ + displayWidth: { + + get: function () { - return false; + return this.scaleX * this.width; + }, + + set: function (value) + { + this.scaleX = value / this.width; } + + }, + + /** + * The displayed height of this Game Object. + * This value takes into account the scale factor. + * + * @name Phaser.GameObjects.Components.ComputedSize#displayHeight + * @type {number} + * @since 3.0.0 + */ + displayHeight: { + + get: function () + { + return this.scaleY * this.height; + }, + + set: function (value) + { + this.scaleY = value / this.height; + } + } - return true; }; -module.exports = HasAll; +module.exports = ComputedSize; /***/ }), @@ -118193,37 +119134,105 @@ module.exports = HasAll; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Clone = __webpack_require__(53); +var BlendModes = __webpack_require__(62); /** - * Creates a new Object using all values from obj1. - * - * Then scans obj2. If a property is found in obj2 that *also* exists in obj1, the value from obj2 is used, otherwise the property is skipped. + * Provides methods used for setting the blend mode of a Game Object. + * Should be applied as a mixin and not used directly. * - * @function Phaser.Utils.Object.MergeRight + * @name Phaser.GameObjects.Components.BlendMode * @since 3.0.0 - * - * @param {object} obj1 - [description] - * @param {object} obj2 - [description] - * - * @return {object} [description] */ -var MergeRight = function (obj1, obj2) -{ - var clone = Clone(obj1); - for (var key in obj2) - { - if (clone.hasOwnProperty(key)) +var BlendMode = { + + _blendMode: BlendModes.NORMAL, + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + * + * @name Phaser.GameObjects.Components.BlendMode#blendMode + * @type {(integer|string)} + * @since 3.0.0 + */ + blendMode: { + + get: function () { - clone[key] = obj2[key]; + return this._blendMode; + }, + + set: function (value) + { + if (typeof value === 'string') + { + value = BlendModes[value]; + } + + value |= 0; + + if (value >= 0) + { + this._blendMode = value; + } } + + }, + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + * + * @method Phaser.GameObjects.Components.BlendMode#setBlendMode + * @since 3.0.0 + * + * @param {(string|integer)} value - The BlendMode value. Either a string or a CONST. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setBlendMode: function (value) + { + this.blendMode = value; + + return this; } - return clone; }; -module.exports = MergeRight; +module.exports = BlendMode; /***/ }), @@ -118236,23 +119245,245 @@ module.exports = MergeRight; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Clamp = __webpack_require__(64); + +// bitmask flag for GameObject.renderMask +var _FLAG = 2; // 0010 + /** - * @namespace Phaser.Utils.String + * Provides methods used for setting the alpha properties of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Alpha + * @since 3.0.0 */ -module.exports = { +var Alpha = { - Format: __webpack_require__(938), - Pad: __webpack_require__(200), - Reverse: __webpack_require__(939), - UppercaseFirst: __webpack_require__(254) + _alpha: 1, + + _alphaTL: 1, + _alphaTR: 1, + _alphaBL: 1, + _alphaBR: 1, + + /** + * Clears all alpha values associated with this Game Object. + * Immediately sets the alpha levels back to 1 (fully opaque) + * + * @method Phaser.GameObjects.Components.Alpha#clearAlpha + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + clearAlpha: function () + { + return this.setAlpha(1); + }, + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * + * @method Phaser.GameObjects.Components.Alpha#setAlpha + * @since 3.0.0 + * + * @param {float} [topLeft=1] - The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. + * @param {float} [topRight] - The alpha value used for the top-right of the Game Object. WebGL only. + * @param {float} [bottomLeft] - The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param {float} [bottomRight] - The alpha value used for the bottom-right of the Game Object. WebGL only. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setAlpha: function (topLeft, topRight, bottomLeft, bottomRight) + { + if (topLeft === undefined) { topLeft = 1; } + + // Treat as if there is only one alpha value for the whole Game Object + if (topRight === undefined) + { + this.alpha = topLeft; + } + else + { + this._alphaTL = Clamp(topLeft, 0, 1); + this._alphaTR = Clamp(topRight, 0, 1); + this._alphaBL = Clamp(bottomLeft, 0, 1); + this._alphaBR = Clamp(bottomRight, 0, 1); + } + + return this; + }, + + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + * + * @name Phaser.GameObjects.Components.Alpha#alpha + * @type {float} + * @since 3.0.0 + */ + alpha: { + + get: function () + { + return this._alpha; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alpha = v; + this._alphaTL = v; + this._alphaTR = v; + this._alphaBL = v; + this._alphaBR = v; + + if (v === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaTopLeft + * @type {float} + * @webglOnly + * @since 3.0.0 + */ + alphaTopLeft: { + + get: function () + { + return this._alphaTL; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaTL = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaTopRight + * @type {float} + * @webglOnly + * @since 3.0.0 + */ + alphaTopRight: { + + get: function () + { + return this._alphaTR; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaTR = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaBottomLeft + * @type {float} + * @webglOnly + * @since 3.0.0 + */ + alphaBottomLeft: { + + get: function () + { + return this._alphaBL; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaBL = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaBottomRight + * @type {float} + * @webglOnly + * @since 3.0.0 + */ + alphaBottomRight: { + + get: function () + { + return this._alphaBR; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaBR = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + } }; +module.exports = Alpha; + /***/ }), /* 938 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -118260,33 +119491,582 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); + /** - * Takes a string and replaces instances of markers with values in the given array. - * The markers take the form of `%1`, `%2`, etc. I.e.: + * @classdesc + * [description] * - * `Format("The %1 is worth %2 gold", [ 'Sword', 500 ])` - * - * @function Phaser.Utils.String.Format + * @class RandomDataGenerator + * @memberOf Phaser.Math + * @constructor * @since 3.0.0 * - * @param {string} string - The string containing the replacement markers. - * @param {array} values - An array containing values that will replace the markers. If no value exists an empty string is inserted instead. - * - * @return {string} The string containing replaced values. + * @param {string[]} [seeds] - [description] */ -var Format = function (string, values) -{ - return string.replace(/%([0-9]+)/g, function (s, n) - { - return values[Number(n) - 1]; - }); -}; +var RandomDataGenerator = new Class({ -module.exports = Format; + initialize: + + function RandomDataGenerator (seeds) + { + /** + * Internal var. + * + * @name Phaser.Math.RandomDataGenerator#c + * @type {number} + * @default 1 + * @private + * @since 3.0.0 + */ + this.c = 1; + + /** + * Internal var. + * + * @name Phaser.Math.RandomDataGenerator#s0 + * @type {number} + * @default 0 + * @private + * @since 3.0.0 + */ + this.s0 = 0; + + /** + * Internal var. + * + * @name Phaser.Math.RandomDataGenerator#s1 + * @type {number} + * @default 0 + * @private + * @since 3.0.0 + */ + this.s1 = 0; + + /** + * Internal var. + * + * @name Phaser.Math.RandomDataGenerator#s2 + * @type {number} + * @default 0 + * @private + * @since 3.0.0 + */ + this.s2 = 0; + + /** + * Internal var. + * + * @name Phaser.Math.RandomDataGenerator#n + * @type {number} + * @default 0 + * @private + * @since 3.2.0 + */ + this.n = 0; + + /** + * [description] + * + * @name Phaser.Math.RandomDataGenerator#sign + * @type {number[]} + * @since 3.0.0 + */ + this.signs = [ -1, 1 ]; + + if (seeds) + { + this.init(seeds); + } + }, + + /** + * Private random helper. + * + * @method Phaser.Math.RandomDataGenerator#rnd + * @since 3.0.0 + * @private + * + * @return {number} [description] + */ + rnd: function () + { + var t = 2091639 * this.s0 + this.c * 2.3283064365386963e-10; // 2^-32 + + this.c = t | 0; + this.s0 = this.s1; + this.s1 = this.s2; + this.s2 = t - this.c; + + return this.s2; + }, + + /** + * Internal method that creates a seed hash. + * + * @method Phaser.Math.RandomDataGenerator#hash + * @since 3.0.0 + * @private + * + * @param {string} data - [description] + * + * @return {number} The hashed value. + */ + hash: function (data) + { + var h; + var n = this.n; + + data = data.toString(); + + for (var i = 0; i < data.length; i++) + { + n += data.charCodeAt(i); + h = 0.02519603282416938 * n; + n = h >>> 0; + h -= n; + h *= n; + n = h >>> 0; + h -= n; + n += h * 0x100000000;// 2^32 + } + + this.n = n; + + return (n >>> 0) * 2.3283064365386963e-10;// 2^-32 + }, + + /** + * [description] + * + * @method Phaser.Math.RandomDataGenerator#init + * @since 3.0.0 + * + * @param {(string|string[])} seeds - [description] + */ + init: function (seeds) + { + if (typeof seeds === 'string') + { + this.state(seeds); + } + else + { + this.sow(seeds); + } + }, + + /** + * Reset the seed of the random data generator. + * + * _Note_: the seed array is only processed up to the first `undefined` (or `null`) value, should such be present. + * + * @method Phaser.Math.RandomDataGenerator#sow + * @since 3.0.0 + * + * @param {string[]} seeds - The array of seeds: the `toString()` of each value is used. + */ + sow: function (seeds) + { + // Always reset to default seed + this.n = 0xefc8249d; + this.s0 = this.hash(' '); + this.s1 = this.hash(' '); + this.s2 = this.hash(' '); + this.c = 1; + + if (!seeds) + { + return; + } + + // Apply any seeds + for (var i = 0; i < seeds.length && (seeds[i] != null); i++) + { + var seed = seeds[i]; + + this.s0 -= this.hash(seed); + this.s0 += ~~(this.s0 < 0); + this.s1 -= this.hash(seed); + this.s1 += ~~(this.s1 < 0); + this.s2 -= this.hash(seed); + this.s2 += ~~(this.s2 < 0); + } + }, + + /** + * Returns a random integer between 0 and 2^32. + * + * @method Phaser.Math.RandomDataGenerator#integer + * @since 3.0.0 + * + * @return {number} A random integer between 0 and 2^32. + */ + integer: function () + { + // 2^32 + return this.rnd() * 0x100000000; + }, + + /** + * Returns a random real number between 0 and 1. + * + * @method Phaser.Math.RandomDataGenerator#frac + * @since 3.0.0 + * + * @return {number} A random real number between 0 and 1. + */ + frac: function () + { + // 2^-53 + return this.rnd() + (this.rnd() * 0x200000 | 0) * 1.1102230246251565e-16; + }, + + /** + * Returns a random real number between 0 and 2^32. + * + * @method Phaser.Math.RandomDataGenerator#real + * @since 3.0.0 + * + * @return {number} A random real number between 0 and 2^32. + */ + real: function () + { + return this.integer() + this.frac(); + }, + + /** + * Returns a random integer between and including min and max. + * + * @method Phaser.Math.RandomDataGenerator#integerInRange + * @since 3.0.0 + * + * @param {number} min - The minimum value in the range. + * @param {number} max - The maximum value in the range. + * + * @return {number} A random number between min and max. + */ + integerInRange: function (min, max) + { + return Math.floor(this.realInRange(0, max - min + 1) + min); + }, + + /** + * Returns a random integer between and including min and max. + * This method is an alias for RandomDataGenerator.integerInRange. + * + * @method Phaser.Math.RandomDataGenerator#between + * @since 3.0.0 + * + * @param {number} min - The minimum value in the range. + * @param {number} max - The maximum value in the range. + * + * @return {number} A random number between min and max. + */ + between: function (min, max) + { + return Math.floor(this.realInRange(0, max - min + 1) + min); + }, + + /** + * Returns a random real number between min and max. + * + * @method Phaser.Math.RandomDataGenerator#realInRange + * @since 3.0.0 + * + * @param {number} min - The minimum value in the range. + * @param {number} max - The maximum value in the range. + * + * @return {number} A random number between min and max. + */ + realInRange: function (min, max) + { + return this.frac() * (max - min) + min; + }, + + /** + * Returns a random real number between -1 and 1. + * + * @method Phaser.Math.RandomDataGenerator#normal + * @since 3.0.0 + * + * @return {number} A random real number between -1 and 1. + */ + normal: function () + { + return 1 - (2 * this.frac()); + }, + + /** + * Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368 + * + * @method Phaser.Math.RandomDataGenerator#uuid + * @since 3.0.0 + * + * @return {string} A valid RFC4122 version4 ID hex string + */ + uuid: function () + { + var a = ''; + var b = ''; + + for (b = a = ''; a++ < 36; b += ~a % 5 | a * 3 & 4 ? (a ^ 15 ? 8 ^ this.frac() * (a ^ 20 ? 16 : 4) : 4).toString(16) : '-') + { + // eslint-disable-next-line no-empty + } + + return b; + }, + + /** + * Returns a random element from within the given array. + * + * @method Phaser.Math.RandomDataGenerator#pick + * @since 3.0.0 + * + * @param {array} array - The array to pick a random element from. + * + * @return {*} A random member of the array. + */ + pick: function (array) + { + return array[this.integerInRange(0, array.length - 1)]; + }, + + /** + * Returns a sign to be used with multiplication operator. + * + * @method Phaser.Math.RandomDataGenerator#sign + * @since 3.0.0 + * + * @return {number} -1 or +1. + */ + sign: function () + { + return this.pick(this.signs); + }, + + /** + * Returns a random element from within the given array, favoring the earlier entries. + * + * @method Phaser.Math.RandomDataGenerator#weightedPick + * @since 3.0.0 + * + * @param {array} array - The array to pick a random element from. + * + * @return {*} A random member of the array. + */ + weightedPick: function (array) + { + return array[~~(Math.pow(this.frac(), 2) * (array.length - 1) + 0.5)]; + }, + + /** + * Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified. + * + * @method Phaser.Math.RandomDataGenerator#timestamp + * @since 3.0.0 + * + * @param {number} min - The minimum value in the range. + * @param {number} max - The maximum value in the range. + * + * @return {number} A random timestamp between min and max. + */ + timestamp: function (min, max) + { + return this.realInRange(min || 946684800000, max || 1577862000000); + }, + + /** + * Returns a random angle between -180 and 180. + * + * @method Phaser.Math.RandomDataGenerator#angle + * @since 3.0.0 + * + * @return {number} A random number between -180 and 180. + */ + angle: function () + { + return this.integerInRange(-180, 180); + }, + + /** + * Returns a random rotation in radians, between -3.141 and 3.141 + * + * @method Phaser.Math.RandomDataGenerator#rotation + * @since 3.0.0 + * + * @return {number} A random number between -3.141 and 3.141 + */ + rotation: function () + { + return this.realInRange(-3.1415926, 3.1415926); + }, + + /** + * Gets or Sets the state of the generator. This allows you to retain the values + * that the generator is using between games, i.e. in a game save file. + * + * To seed this generator with a previously saved state you can pass it as the + * `seed` value in your game config, or call this method directly after Phaser has booted. + * + * Call this method with no parameters to return the current state. + * + * If providing a state it should match the same format that this method + * returns, which is a string with a header `!rnd` followed by the `c`, + * `s0`, `s1` and `s2` values respectively, each comma-delimited. + * + * @method Phaser.Math.RandomDataGenerator#state + * @since 3.0.0 + * + * @param {string} [state] - Generator state to be set. + * + * @return {string} The current state of the generator. + */ + state: function (state) + { + if (typeof state === 'string' && state.match(/^!rnd/)) + { + state = state.split(','); + + this.c = parseFloat(state[1]); + this.s0 = parseFloat(state[2]); + this.s1 = parseFloat(state[3]); + this.s2 = parseFloat(state[4]); + } + + return [ '!rnd', this.c, this.s0, this.s1, this.s2 ].join(','); + } + +}); + +module.exports = RandomDataGenerator; /***/ }), /* 939 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var AlignIn = __webpack_require__(366); +var CONST = __webpack_require__(169); +var GetFastValue = __webpack_require__(2); +var NOOP = __webpack_require__(3); +var Zone = __webpack_require__(106); + +var tempZone = new Zone({ sys: { queueDepthSort: NOOP }}, 0, 0, 1, 1); + +/** + * @typedef {object} GridAlignConfig + * + * @property {integer} [width=-1] - The width of the grid in items (not pixels). -1 means lay all items out horizontally, regardless of quantity. + * If both this value and height are set to -1 then this value overrides it and the `height` value is ignored. + * @property {integer} [height=-1] - The height of the grid in items (not pixels). -1 means lay all items out vertically, regardless of quantity. + * If both this value and `width` are set to -1 then `width` overrides it and this value is ignored. + * @property {boolean} [cellWidth=1] - The width of the cell, in pixels, in which the item is positioned. + * @property {integer} [cellHeight=1] - The height of the cell, in pixels, in which the item is positioned. + * @property {integer} [position=0] - The alignment position. One of the Phaser.Display.Align consts such as `TOP_LEFT` or `RIGHT_CENTER`. + * @property {number} [x=0] - Optionally place the top-left of the final grid at this coordinate. + * @property {number} [y=0] - Optionally place the top-left of the final grid at this coordinate. + */ + +/** + * Takes an array of Game Objects, or any objects that have public `x` and `y` properties, + * and then aligns them based on the grid configuration given to this action. + * + * @function Phaser.Actions.GridAlign + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {GridAlignConfig} options - The GridAlign Configuration object. + * + * @return {array} The array of objects that were passed to this Action. + */ +var GridAlign = function (items, options) +{ + if (options === undefined) { options = {}; } + + var width = GetFastValue(options, 'width', -1); + var height = GetFastValue(options, 'height', -1); + var cellWidth = GetFastValue(options, 'cellWidth', 1); + var cellHeight = GetFastValue(options, 'cellHeight', cellWidth); + var position = GetFastValue(options, 'position', CONST.TOP_LEFT); + var x = GetFastValue(options, 'x', 0); + var y = GetFastValue(options, 'y', 0); + + var cx = 0; + var cy = 0; + var w = (width * cellWidth); + var h = (height * cellHeight); + + tempZone.setPosition(x, y); + tempZone.setSize(cellWidth, cellHeight); + + for (var i = 0; i < items.length; i++) + { + AlignIn(items[i], tempZone, position); + + if (width === -1) + { + // We keep laying them out horizontally until we've done them all + cy += cellHeight; + tempZone.y += cellHeight; + + if (cy === h) + { + cy = 0; + tempZone.x += cellWidth; + tempZone.y = y; + } + } + else if (height === -1) + { + // We keep laying them out vertically until we've done them all + cx += cellWidth; + tempZone.x += cellWidth; + + if (cx === w) + { + cx = 0; + tempZone.x = x; + tempZone.y += cellHeight; + } + } + else + { + // We keep laying them out until we hit the column limit + cx += cellWidth; + tempZone.x += cellWidth; + + if (cx === w) + { + cx = 0; + cy += cellHeight; + tempZone.x = x; + tempZone.y += cellHeight; + + if (cy === h) + { + // We've hit the column limit, so return, even if there are items left + break; + } + } + } + } + + return items; +}; + +module.exports = GridAlign; + + +/***/ }), +/* 940 */ /***/ (function(module, exports) { /** @@ -118296,39 +120076,687 @@ module.exports = Format; */ /** - * Takes the given string and reverses it, returning the reversed string. - * For example if given the string `Atari 520ST` it would return `TS025 iratA`. + * Takes an array of objects and returns the last element in the array that has properties which match + * all of those specified in the `compare` object. For example, if the compare object was: `{ scaleX: 0.5, alpha: 1 }` + * then it would return the last item which had the property `scaleX` set to 0.5 and `alpha` set to 1. * - * @function Phaser.Utils.String.ReverseString - * @since 3.0.0 + * To use this with a Group: `GetLast(group.getChildren(), compare, index)` * - * @param {string} string - The string to be reversed. + * @function Phaser.Actions.GetLast + * @since 3.3.0 * - * @return {string} The reversed string. + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be searched by this action. + * @param {object} compare - The comparison object. Each property in this object will be checked against the items of the array. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * + * @return {?(object|Phaser.GameObjects.GameObject)} The last object in the array that matches the comparison object, or `null` if no match was found. */ -var ReverseString = function (string) +var GetLast = function (items, compare, index) { - return string.split('').reverse().join(''); + if (index === undefined) { index = 0; } + + for (var i = index; i < items.length; i++) + { + var item = items[i]; + + var match = true; + + for (var property in compare) + { + if (item[property] !== compare[property]) + { + match = false; + } + } + + if (match) + { + return item; + } + } + + return null; }; -module.exports = ReverseString; +module.exports = GetLast; + + +/***/ }), +/* 941 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes an array of objects and returns the first element in the array that has properties which match + * all of those specified in the `compare` object. For example, if the compare object was: `{ scaleX: 0.5, alpha: 1 }` + * then it would return the first item which had the property `scaleX` set to 0.5 and `alpha` set to 1. + * + * To use this with a Group: `GetFirst(group.getChildren(), compare, index)` + * + * @function Phaser.Actions.GetFirst + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be searched by this action. + * @param {object} compare - The comparison object. Each property in this object will be checked against the items of the array. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * + * @return {?(object|Phaser.GameObjects.GameObject)} The first object in the array that matches the comparison object, or `null` if no match was found. + */ +var GetFirst = function (items, compare, index) +{ + if (index === undefined) { index = 0; } + + for (var i = index; i < items.length; i++) + { + var item = items[i]; + + var match = true; + + for (var property in compare) + { + if (item[property] !== compare[property]) + { + match = false; + } + } + + if (match) + { + return item; + } + } + + return null; +}; + +module.exports = GetFirst; + + +/***/ }), +/* 942 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @callback CallCallback + * + * @param {Phaser.GameObjects.GameObject} item - [description] + */ + +/** + * Takes an array of objects and passes each of them to the given callback. + * + * @function Phaser.Actions.Call + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {CallCallback} callback - The callback to be invoked. It will be passed just one argument: the item from the array. + * @param {*} context - The scope in which the callback will be invoked. + * + * @return {array} The array of objects that was passed to this Action. + */ +var Call = function (items, callback, context) +{ + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + + callback.call(context, item); + } + + return items; +}; + +module.exports = Call; + + +/***/ }), +/* 943 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(25); + +/** + * Takes an array of Game Objects, or any objects that have a public `angle` property, + * and then adds the given value to each of their `angle` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `Angle(group.getChildren(), value, step)` + * + * @function Phaser.Actions.Angle + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `angle` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var Angle = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'angle', value, step, index, direction); +}; + +module.exports = Angle; + + +/***/ }), +/* 944 */ +/***/ (function(module, exports) { + +/** +* Low-budget Float32Array knock-off, suitable for use with P2.js in IE9 +* Source: http://www.html5gamedevs.com/topic/5988-phaser-12-ie9/ +* Cameron Foale (http://www.kibibu.com) +*/ +if (typeof window.Uint32Array !== 'function' && typeof window.Uint32Array !== 'object') +{ + var CheapArray = function (fakeType) + { + var proto = new Array(); // jshint ignore:line + + window[fakeType] = function(arg) { + + if (typeof(arg) === 'number') + { + Array.call(this, arg); + + this.length = arg; + + for (var i = 0; i < this.length; i++) + { + this[i] = 0; + } + } + else + { + Array.call(this, arg.length); + + this.length = arg.length; + + for (var i = 0; i < this.length; i++) + { + this[i] = arg[i]; + } + } + }; + + window[fakeType].prototype = proto; + window[fakeType].constructor = window[fakeType]; + }; + + CheapArray('Float32Array'); // jshint ignore:line + CheapArray('Uint32Array'); // jshint ignore:line + CheapArray('Uint16Array'); // jshint ignore:line + CheapArray('Int16Array'); // jshint ignore:line + CheapArray('ArrayBuffer'); // jshint ignore:line +} + + +/***/ }), +/* 945 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global) {// References: +// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ +// https://gist.github.com/1579671 +// http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision +// https://gist.github.com/timhall/4078614 +// https://github.com/Financial-Times/polyfill-service/tree/master/polyfills/requestAnimationFrame + +// Expected to be used with Browserfiy +// Browserify automatically detects the use of `global` and passes the +// correct reference of `global`, `self`, and finally `window` + +// Date.now +if (!(Date.now && Date.prototype.getTime)) { + Date.now = function now() { + return new Date().getTime(); + }; +} + +// performance.now +if (!(global.performance && global.performance.now)) { + var startTime = Date.now(); + if (!global.performance) { + global.performance = {}; + } + global.performance.now = function () { + return Date.now() - startTime; + }; +} + +// requestAnimationFrame +var lastTime = Date.now(); +var vendors = ['ms', 'moz', 'webkit', 'o']; + +for(var x = 0; x < vendors.length && !global.requestAnimationFrame; ++x) { + global.requestAnimationFrame = global[vendors[x] + 'RequestAnimationFrame']; + global.cancelAnimationFrame = global[vendors[x] + 'CancelAnimationFrame'] || + global[vendors[x] + 'CancelRequestAnimationFrame']; +} + +if (!global.requestAnimationFrame) { + global.requestAnimationFrame = function (callback) { + if (typeof callback !== 'function') { + throw new TypeError(callback + 'is not a function'); + } + + var currentTime = Date.now(), + delay = 16 + lastTime - currentTime; + + if (delay < 0) { + delay = 0; + } + + lastTime = currentTime; + + return setTimeout(function () { + lastTime = Date.now(); + callback(performance.now()); + }, delay); + }; +} + +if (!global.cancelAnimationFrame) { + global.cancelAnimationFrame = function(id) { + clearTimeout(id); + }; +} + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(369))) + +/***/ }), +/* 946 */ +/***/ (function(module, exports) { + +/** + * performance.now + */ +(function () { + + if ('performance' in window === false) + { + window.performance = {}; + } + + // Thanks IE8 + Date.now = (Date.now || function () { + return new Date().getTime(); + }); + + if ('now' in window.performance === false) + { + var nowOffset = Date.now(); + + if (performance.timing && performance.timing.navigationStart) + { + nowOffset = performance.timing.navigationStart; + } + + window.performance.now = function now () + { + return Date.now() - nowOffset; + } + } + +})(); + + +/***/ }), +/* 947 */ +/***/ (function(module, exports) { + +// ES6 Math.trunc - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc +if (!Math.trunc) { + Math.trunc = function trunc(x) { + return x < 0 ? Math.ceil(x) : Math.floor(x); + }; +} + + +/***/ }), +/* 948 */ +/***/ (function(module, exports) { + +/** +* A polyfill for Function.prototype.bind +*/ +if (!Function.prototype.bind) { + + /* jshint freeze: false */ + Function.prototype.bind = (function () { + + var slice = Array.prototype.slice; + + return function (thisArg) { + + var target = this, boundArgs = slice.call(arguments, 1); + + if (typeof target !== 'function') + { + throw new TypeError(); + } + + function bound() { + var args = boundArgs.concat(slice.call(arguments)); + target.apply(this instanceof bound ? this : thisArg, args); + } + + bound.prototype = (function F(proto) { + if (proto) + { + F.prototype = proto; + } + + if (!(this instanceof F)) + { + /* jshint supernew: true */ + return new F; + } + })(target.prototype); + + return bound; + }; + })(); +} + + + +/***/ }), +/* 949 */ +/***/ (function(module, exports) { + +/** + * Also fix for the absent console in IE9 + */ +if (!window.console) +{ + window.console = {}; + window.console.log = window.console.assert = function(){}; + window.console.warn = window.console.assert = function(){}; +} + + +/***/ }), +/* 950 */ +/***/ (function(module, exports) { + +/* Copyright 2013 Chris Wilson + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/* + +This monkeypatch library is intended to be included in projects that are +written to the proper AudioContext spec (instead of webkitAudioContext), +and that use the new naming and proper bits of the Web Audio API (e.g. +using BufferSourceNode.start() instead of BufferSourceNode.noteOn()), but may +have to run on systems that only support the deprecated bits. + +This library should be harmless to include if the browser supports +unprefixed "AudioContext", and/or if it supports the new names. + +The patches this library handles: +if window.AudioContext is unsupported, it will be aliased to webkitAudioContext(). +if AudioBufferSourceNode.start() is unimplemented, it will be routed to noteOn() or +noteGrainOn(), depending on parameters. + +The following aliases only take effect if the new names are not already in place: + +AudioBufferSourceNode.stop() is aliased to noteOff() +AudioContext.createGain() is aliased to createGainNode() +AudioContext.createDelay() is aliased to createDelayNode() +AudioContext.createScriptProcessor() is aliased to createJavaScriptNode() +AudioContext.createPeriodicWave() is aliased to createWaveTable() +OscillatorNode.start() is aliased to noteOn() +OscillatorNode.stop() is aliased to noteOff() +OscillatorNode.setPeriodicWave() is aliased to setWaveTable() +AudioParam.setTargetAtTime() is aliased to setTargetValueAtTime() + +This library does NOT patch the enumerated type changes, as it is +recommended in the specification that implementations support both integer +and string types for AudioPannerNode.panningModel, AudioPannerNode.distanceModel +BiquadFilterNode.type and OscillatorNode.type. + +*/ +(function (global, exports, perf) { + 'use strict'; + + function fixSetTarget(param) { + if (!param) // if NYI, just return + return; + if (!param.setTargetAtTime) + param.setTargetAtTime = param.setTargetValueAtTime; + } + + if (window.hasOwnProperty('webkitAudioContext') && + !window.hasOwnProperty('AudioContext')) { + window.AudioContext = webkitAudioContext; + + if (!AudioContext.prototype.hasOwnProperty('createGain')) + AudioContext.prototype.createGain = AudioContext.prototype.createGainNode; + if (!AudioContext.prototype.hasOwnProperty('createDelay')) + AudioContext.prototype.createDelay = AudioContext.prototype.createDelayNode; + if (!AudioContext.prototype.hasOwnProperty('createScriptProcessor')) + AudioContext.prototype.createScriptProcessor = AudioContext.prototype.createJavaScriptNode; + if (!AudioContext.prototype.hasOwnProperty('createPeriodicWave')) + AudioContext.prototype.createPeriodicWave = AudioContext.prototype.createWaveTable; + + + AudioContext.prototype.internal_createGain = AudioContext.prototype.createGain; + AudioContext.prototype.createGain = function() { + var node = this.internal_createGain(); + fixSetTarget(node.gain); + return node; + }; + + AudioContext.prototype.internal_createDelay = AudioContext.prototype.createDelay; + AudioContext.prototype.createDelay = function(maxDelayTime) { + var node = maxDelayTime ? this.internal_createDelay(maxDelayTime) : this.internal_createDelay(); + fixSetTarget(node.delayTime); + return node; + }; + + AudioContext.prototype.internal_createBufferSource = AudioContext.prototype.createBufferSource; + AudioContext.prototype.createBufferSource = function() { + var node = this.internal_createBufferSource(); + if (!node.start) { + node.start = function ( when, offset, duration ) { + if ( offset || duration ) + this.noteGrainOn( when || 0, offset, duration ); + else + this.noteOn( when || 0 ); + }; + } else { + node.internal_start = node.start; + node.start = function( when, offset, duration ) { + if( typeof duration !== 'undefined' ) + node.internal_start( when || 0, offset, duration ); + else + node.internal_start( when || 0, offset || 0 ); + }; + } + if (!node.stop) { + node.stop = function ( when ) { + this.noteOff( when || 0 ); + }; + } else { + node.internal_stop = node.stop; + node.stop = function( when ) { + node.internal_stop( when || 0 ); + }; + } + fixSetTarget(node.playbackRate); + return node; + }; + + AudioContext.prototype.internal_createDynamicsCompressor = AudioContext.prototype.createDynamicsCompressor; + AudioContext.prototype.createDynamicsCompressor = function() { + var node = this.internal_createDynamicsCompressor(); + fixSetTarget(node.threshold); + fixSetTarget(node.knee); + fixSetTarget(node.ratio); + fixSetTarget(node.reduction); + fixSetTarget(node.attack); + fixSetTarget(node.release); + return node; + }; + + AudioContext.prototype.internal_createBiquadFilter = AudioContext.prototype.createBiquadFilter; + AudioContext.prototype.createBiquadFilter = function() { + var node = this.internal_createBiquadFilter(); + fixSetTarget(node.frequency); + fixSetTarget(node.detune); + fixSetTarget(node.Q); + fixSetTarget(node.gain); + return node; + }; + + if (AudioContext.prototype.hasOwnProperty( 'createOscillator' )) { + AudioContext.prototype.internal_createOscillator = AudioContext.prototype.createOscillator; + AudioContext.prototype.createOscillator = function() { + var node = this.internal_createOscillator(); + if (!node.start) { + node.start = function ( when ) { + this.noteOn( when || 0 ); + }; + } else { + node.internal_start = node.start; + node.start = function ( when ) { + node.internal_start( when || 0); + }; + } + if (!node.stop) { + node.stop = function ( when ) { + this.noteOff( when || 0 ); + }; + } else { + node.internal_stop = node.stop; + node.stop = function( when ) { + node.internal_stop( when || 0 ); + }; + } + if (!node.setPeriodicWave) + node.setPeriodicWave = node.setWaveTable; + fixSetTarget(node.frequency); + fixSetTarget(node.detune); + return node; + }; + } + } + + if (window.hasOwnProperty('webkitOfflineAudioContext') && + !window.hasOwnProperty('OfflineAudioContext')) { + window.OfflineAudioContext = webkitOfflineAudioContext; + } + +}(window)); + + + +/***/ }), +/* 951 */ +/***/ (function(module, exports) { + +/** +* A polyfill for Array.isArray +*/ +if (!Array.isArray) +{ + Array.isArray = function (arg) + { + return Object.prototype.toString.call(arg) === '[object Array]'; + }; +} + + +/***/ }), +/* 952 */ +/***/ (function(module, exports) { + +/** +* A polyfill for Array.forEach +* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach +*/ +if (!Array.prototype.forEach) +{ + Array.prototype.forEach = function (fun /*, thisArg */) + { + 'use strict'; + + if (this === void 0 || this === null) + { + throw new TypeError(); + } + + var t = Object(this); + var len = t.length >>> 0; + + if (typeof fun !== 'function') + { + throw new TypeError(); + } + + var thisArg = arguments.length >= 2 ? arguments[1] : void 0; + + for (var i = 0; i < len; i++) + { + if (i in t) + { + fun.call(thisArg, t[i], i, t); + } + } + }; +} + + +/***/ }), +/* 953 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(952); +__webpack_require__(951); +__webpack_require__(950); +__webpack_require__(949); +__webpack_require__(948); +__webpack_require__(947); +__webpack_require__(946); +__webpack_require__(945); +__webpack_require__(944); /***/ }), -/* 940 */, -/* 941 */, -/* 942 */, -/* 943 */, -/* 944 */, -/* 945 */, -/* 946 */, -/* 947 */, -/* 948 */, -/* 949 */, -/* 950 */, -/* 951 */, -/* 952 */, -/* 953 */, /* 954 */, /* 955 */, /* 956 */, @@ -118347,40 +120775,7 @@ module.exports = ReverseString; /* 969 */, /* 970 */, /* 971 */, -/* 972 */, -/* 973 */, -/* 974 */, -/* 975 */, -/* 976 */, -/* 977 */, -/* 978 */, -/* 979 */, -/* 980 */, -/* 981 */, -/* 982 */, -/* 983 */, -/* 984 */, -/* 985 */, -/* 986 */, -/* 987 */, -/* 988 */, -/* 989 */, -/* 990 */, -/* 991 */, -/* 992 */, -/* 993 */, -/* 994 */, -/* 995 */, -/* 996 */, -/* 997 */, -/* 998 */, -/* 999 */, -/* 1000 */, -/* 1001 */, -/* 1002 */, -/* 1003 */, -/* 1004 */, -/* 1005 */ +/* 972 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(global) {/** @@ -118389,10 +120784,10 @@ module.exports = ReverseString; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -__webpack_require__(376); +__webpack_require__(953); -var CONST = __webpack_require__(19); -var Extend = __webpack_require__(23); +var CONST = __webpack_require__(21); +var Extend = __webpack_require__(18); /** * @namespace Phaser @@ -118400,35 +120795,35 @@ var Extend = __webpack_require__(23); var Phaser = { - Actions: __webpack_require__(171), - Animation: __webpack_require__(448), - Cache: __webpack_require__(449), - Cameras: __webpack_require__(450), + Actions: __webpack_require__(367), + Animation: __webpack_require__(879), + Cache: __webpack_require__(878), + Cameras: __webpack_require__(877), Class: __webpack_require__(0), - Create: __webpack_require__(461), - Curves: __webpack_require__(467), - Data: __webpack_require__(470), - Display: __webpack_require__(472), - DOM: __webpack_require__(505), - EventEmitter: __webpack_require__(507), - Game: __webpack_require__(508), - GameObjects: __webpack_require__(544), - Geom: __webpack_require__(294), - Input: __webpack_require__(761), - Loader: __webpack_require__(775), - Math: __webpack_require__(793), + Create: __webpack_require__(866), + Curves: __webpack_require__(860), + Data: __webpack_require__(857), + Display: __webpack_require__(855), + DOM: __webpack_require__(822), + EventEmitter: __webpack_require__(820), + Game: __webpack_require__(819), + GameObjects: __webpack_require__(783), + Geom: __webpack_require__(245), + Input: __webpack_require__(566), + Loader: __webpack_require__(552), + Math: __webpack_require__(534), Physics: { - Arcade: __webpack_require__(836) + Arcade: __webpack_require__(491) }, - Scene: __webpack_require__(253), - Scenes: __webpack_require__(867), - Sound: __webpack_require__(869), - Structs: __webpack_require__(870), - Textures: __webpack_require__(871), - Tilemaps: __webpack_require__(873), - Time: __webpack_require__(922), - Tweens: __webpack_require__(924), - Utils: __webpack_require__(928) + Scene: __webpack_require__(286), + Scenes: __webpack_require__(461), + Sound: __webpack_require__(459), + Structs: __webpack_require__(458), + Textures: __webpack_require__(457), + Tilemaps: __webpack_require__(455), + Time: __webpack_require__(406), + Tweens: __webpack_require__(404), + Utils: __webpack_require__(400) }; @@ -118448,7 +120843,7 @@ global.Phaser = Phaser; * -- Dick Brandon */ -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(169))) +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(369))) /***/ }) /******/ ]); diff --git a/dist/phaser-arcade-physics.min.js b/dist/phaser-arcade-physics.min.js index 62ee1c7e8..ef8da2c9a 100644 --- a/dist/phaser-arcade-physics.min.js +++ b/dist/phaser-arcade-physics.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Phaser",[],e):"object"==typeof exports?exports.Phaser=e():t.Phaser=e()}("undefined"!=typeof self?self:this,function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=1005)}([function(t,e){function i(t,e,i){var n=i?t[e]:Object.getOwnPropertyDescriptor(t,e);return!i&&n.value&&"object"==typeof n.value&&(n=n.value),!(!n||!function(t){return!!t.get&&"function"==typeof t.get||!!t.set&&"function"==typeof t.set}(n))&&(void 0===n.enumerable&&(n.enumerable=!0),void 0===n.configurable&&(n.configurable=!0),n)}function n(t,e){var i=Object.getOwnPropertyDescriptor(t,e);return!!i&&(i.value&&"object"==typeof i.value&&(i=i.value),!1===i.configurable)}function s(t,e,s,r){for(var a in e)if(e.hasOwnProperty(a)){var h=i(e,a,s);if(!1!==h){if(n((r||t).prototype,a)){if(o.ignoreFinals)continue;throw new Error("cannot override final property '"+a+"', set Class.ignoreFinals = true to skip")}Object.defineProperty(t.prototype,a,h)}else t.prototype[a]=e[a]}}function r(t,e){if(e){Array.isArray(e)||(e=[e]);for(var i=0;i0&&(i=1/Math.sqrt(i),this.x=t*i,this.y=e*i),this},normalizeRightHand:function(){var t=this.x;return this.x=-1*this.y,this.y=t,this},dot:function(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.x},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this},transformMat3:function(t){var e=this.x,i=this.y,n=t.val;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this},transformMat4:function(t){var e=this.x,i=this.y,n=t.val;return this.x=n[0]*e+n[4]*i+n[12],this.y=n[1]*e+n[5]*i+n[13],this},reset:function(){return this.x=0,this.y=0,this}});n.ZERO=new n,t.exports=n},function(t,e){var i={},n={install:function(t){for(var e in i)t[e]=i[e]},register:function(t,e){i[t]=e},destroy:function(){i={}}};t.exports=n},function(t,e,i){var n=i(0),s=i(33),r=i(107),o=i(187),a=i(108),h=new n({initialize:function(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x=t,this.y=e,this.width=i,this.height=n},contains:function(t,e){return s(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return a(this,t)},setTo:function(t,e,i,n){return this.x=t,this.y=e,this.width=i,this.height=n,this},setEmpty:function(){return this.setTo(0,0,0,0)},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setSize:function(t,e){return void 0===e&&(e=t),this.width=t,this.height=e,this},isEmpty:function(){return this.width<=0||this.height<=0},getLineA:function(){return{x1:this.x,y1:this.y,x2:this.right,y2:this.y}},getLineB:function(){return{x1:this.right,y1:this.y,x2:this.right,y2:this.bottom}},getLineC:function(){return{x1:this.right,y1:this.bottom,x2:this.x,y2:this.bottom}},getLineD:function(){return{x1:this.x,y1:this.bottom,x2:this.x,y2:this.y}},left:{get:function(){return this.x},set:function(t){t>=this.right?this.width=0:this.width=this.right-t,this.x=t}},right:{get:function(){return this.x+this.width},set:function(t){t<=this.x?this.width=0:this.width=t-this.x}},top:{get:function(){return this.y},set:function(t){t>=this.bottom?this.height=0:this.height=this.bottom-t,this.y=t}},bottom:{get:function(){return this.y+this.height},set:function(t){t<=this.y?this.height=0:this.height=t-this.y}},centerX:{get:function(){return this.x+this.width/2},set:function(t){this.x=t-this.width/2}},centerY:{get:function(){return this.y+this.height/2},set:function(t){this.y=t-this.height/2}}});t.exports=h},function(t,e,i){var n=i(0),s=i(12),r=new n({initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),this.displayList,this.updateList},boot:function(){this.displayList=this.systems.displayList,this.updateList=this.systems.updateList;var t=this.systems.events;t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},existing:function(t){return(t.renderCanvas||t.renderWebGL)&&this.displayList.add(t),t.preUpdate&&this.updateList.add(t),t},shutdown:function(){},destroy:function(){this.scene=null,this.displayList=null,this.updateList=null}});r.register=function(t,e){r.prototype.hasOwnProperty(t)||(r.prototype[t]=e)},s.register("GameObjectFactory",r,"add"),t.exports=r},function(t,e,i){var n=i(16),s=i(4);t.exports=function(t,e,i){var r=s(t,e,null);if(null===r)return i;if(Array.isArray(r))return n.RND.pick(r);if("object"==typeof r){if(r.hasOwnProperty("randInt"))return n.RND.integerInRange(r.randInt[0],r.randInt[1]);if(r.hasOwnProperty("randFloat"))return n.RND.realInRange(r.randFloat[0],r.randFloat[1])}else if("function"==typeof r)return r(e);return r}},function(t,e,i){t.exports={Alpha:i(391),Animation:i(365),BlendMode:i(392),ComputedSize:i(393),Depth:i(394),Flip:i(395),GetBounds:i(396),MatrixStack:i(397),Origin:i(398),Pipeline:i(189),ScaleMode:i(399),ScrollFactor:i(400),Size:i(401),Texture:i(402),Tint:i(403),ToJSON:i(404),Transform:i(405),TransformMatrix:i(190),Visible:i(406)}},function(t,e,i){var n=i(0),s={},r=new n({initialize:function(t){this.game=t,t.events.once("boot",this.boot,this)},boot:function(){this.game.events.once("destroy",this.destroy,this)},installGlobal:function(t,e){for(var i=t.game,n=t.scene,s=t.settings.map,r=0;ro.width&&(i=Math.max(o.width-t,0)),e+s>o.height&&(s=Math.max(o.height-e,0));for(var l=[],c=e;c0&&e>=t.left&&e<=t.right&&i>=t.top&&i<=t.bottom&&(t.x-e)*(t.x-e)+(t.y-i)*(t.y-i)<=t.radius*t.radius}},function(t,e){t.exports=function(t,e,i){return!(t.width<=0||t.height<=0)&&t.x<=e&&t.x+t.width>=e&&t.y<=i&&t.y+t.height>=i}},function(t,e,i){var n=i(97),s=i(15);t.exports=function(t,e,i,r,o){for(var a=null,h=null,u=null,l=null,c=s(t,e,i,r,null,o),d=0;d>>0},getTintAppendFloatAlpha:function(t,e){return((255&(255*e|0))<<24|t)>>>0},getTintAppendFloatAlphaAndSwap:function(t,e){return((255&(255*e|0))<<24|(255&(0|t))<<16|(255&(t>>8|0))<<8|255&(t>>16|0))>>>0},getFloatsFromUintRGB:function(t){return[(255&(t>>16|0))/255,(255&(t>>8|0))/255,(255&(0|t))/255]},getComponentCount:function(t,e){for(var i=0,n=0;nthis.right||e>this.bottom)},copy:function(t){return this.index=t.index,this.alpha=t.alpha,this.properties=t.properties,this.visible=t.visible,this.setFlip(t.flipX,t.flipY),this.tint=t.tint,this.rotation=t.rotation,this.collideUp=t.collideUp,this.collideDown=t.collideDown,this.collideLeft=t.collideLeft,this.collideRight=t.collideRight,this.collisionCallback=t.collisionCallback,this.collisionCallbackContext=t.collisionCallbackContext,this},getCollisionGroup:function(){return this.tileset?this.tileset.getTileCollisionGroup(this.index):null},getTileData:function(){return this.tileset?this.tileset.getTileData(this.index):null},getLeft:function(t){var e=this.tilemapLayer;return e?e.tileToWorldX(this.x,t):this.x*this.baseWidth},getRight:function(t){var e=this.tilemapLayer;return e?this.getLeft(t)+this.width*e.scaleX:this.getLeft(t)+this.width},getTop:function(t){var e=this.tilemapLayer;return e?e.tileToWorldY(this.y,t)-(this.height-this.baseHeight)*e.scaleY:this.y*this.baseHeight-(this.height-this.baseHeight)},getBottom:function(t){var e=this.tilemapLayer;return e?this.getTop(t)+this.height*e.scaleY:this.getTop(t)+this.height},getBounds:function(t,e){return void 0===e&&(e=new r),e.x=this.getLeft(),e.y=this.getTop(),e.width=this.getRight()-e.x,e.height=this.getBottom()-e.y,e},getCenterX:function(t){return this.getLeft(t)+this.width/2},getCenterY:function(t){return this.getTop(t)+this.height/2},destroy:function(){this.collisionCallback=void 0,this.collisionCallbackContext=void 0,this.properties=void 0},intersects:function(t,e,i,n){return!(i<=this.pixelX||n<=this.pixelY||t>=this.right||e>=this.bottom)},isInteresting:function(t,e){return t&&e?this.canCollide||this.hasInterestingFace:t?this.collides:!!e&&this.hasInterestingFace},resetCollision:function(t){(void 0===t&&(t=!0),this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,t)&&(this.tilemapLayer&&this.tilemapLayer.calculateFacesAt(this.x,this.y));return this},resetFaces:function(){return this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,this},setCollision:function(t,e,i,n,s){(void 0===e&&(e=t),void 0===i&&(i=t),void 0===n&&(n=t),void 0===s&&(s=!0),this.collideLeft=t,this.collideRight=e,this.collideUp=i,this.collideDown=n,this.faceLeft=t,this.faceRight=e,this.faceTop=i,this.faceBottom=n,s)&&(this.tilemapLayer&&this.tilemapLayer.calculateFacesAt(this.x,this.y));return this},setCollisionCallback:function(t,e){return null===t?(this.collisionCallback=void 0,this.collisionCallbackContext=void 0):(this.collisionCallback=t,this.collisionCallbackContext=e),this},setSize:function(t,e,i,n){return void 0!==t&&(this.width=t),void 0!==e&&(this.height=e),void 0!==i&&(this.baseWidth=i),void 0!==n&&(this.baseHeight=n),this.updatePixelXY(),this},updatePixelXY:function(){return this.pixelX=this.x*this.baseWidth,this.pixelY=this.y*this.baseHeight-(this.height-this.baseHeight),this},canCollide:{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.collisionCallback}},collides:{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown}},hasInterestingFace:{get:function(){return this.faceTop||this.faceBottom||this.faceLeft||this.faceRight}},tileset:{get:function(){var t=this.tilemapLayer;return t?t.tileset:null}},tilemapLayer:{get:function(){return this.layer.tilemapLayer}},tilemap:{get:function(){var t=this.tilemapLayer;return t?t.tilemap:null}}});t.exports=o},function(t,e){t.exports={SKIP_CHECK:-1,NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16}},function(t,e){t.exports=function(t){return t.x-t.width*t.originX+.5*t.width}},function(t,e){t.exports=function(t,e){var i=t.width*t.originX;return t.x=e+i-.5*t.width,t}},function(t,e){t.exports=function(t,e){var i=t.height*t.originY;return t.y=e+i-.5*t.height,t}},function(t,e){t.exports=function(t){return t.y-t.height*t.originY+.5*t.height}},function(t,e){t.exports=function(t,e,i){var n=i-e;return e+((t-e)%n+n)%n}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i){"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0):(this.x=t||0,this.y=e||0,this.z=i||0)},up:function(){return this.x=0,this.y=1,this.z=0,this},clone:function(){return new n(this.x,this.y,this.z)},crossVectors:function(t,e){var i=t.x,n=t.y,s=t.z,r=e.x,o=e.y,a=e.z;return this.x=n*a-s*o,this.y=s*r-i*a,this.z=i*o-n*r,this},equals:function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this},set:function(t,e,i){return"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0):(this.x=t||0,this.y=e||0,this.z=i||0),this},add:function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this},subtract:function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z||0,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z||1,this},scale:function(t){return isFinite(t)?(this.x*=t,this.y*=t,this.z*=t):(this.x=0,this.y=0,this.z=0),this},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z||1,this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},distance:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0;return Math.sqrt(e*e+i*i+n*n)},distanceSq:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0;return e*e+i*i+n*n},length:function(){var t=this.x,e=this.y,i=this.z;return Math.sqrt(t*t+e*e+i*i)},lengthSq:function(){var t=this.x,e=this.y,i=this.z;return t*t+e*e+i*i},normalize:function(){var t=this.x,e=this.y,i=this.z,n=t*t+e*e+i*i;return n>0&&(n=1/Math.sqrt(n),this.x=t*n,this.y=e*n,this.z=i*n),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},cross:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z;return this.x=i*o-n*r,this.y=n*s-e*o,this.z=e*r-i*s,this},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this},transformMat3:function(t){var e=this.x,i=this.y,n=this.z,s=t.val;return this.x=e*s[0]+i*s[3]+n*s[6],this.y=e*s[1]+i*s[4]+n*s[7],this.z=e*s[2]+i*s[5]+n*s[8],this},transformMat4:function(t){var e=this.x,i=this.y,n=this.z,s=t.val;return this.x=s[0]*e+s[4]*i+s[8]*n+s[12],this.y=s[1]*e+s[5]*i+s[9]*n+s[13],this.z=s[2]*e+s[6]*i+s[10]*n+s[14],this},transformCoordinates:function(t){var e=this.x,i=this.y,n=this.z,s=t.val,r=e*s[0]+i*s[4]+n*s[8]+s[12],o=e*s[1]+i*s[5]+n*s[9]+s[13],a=e*s[2]+i*s[6]+n*s[10]+s[14],h=e*s[3]+i*s[7]+n*s[11]+s[15];return this.x=r/h,this.y=o/h,this.z=a/h,this},transformQuat:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z,a=t.w,h=a*e+r*n-o*i,u=a*i+o*e-s*n,l=a*n+s*i-r*e,c=-s*e-r*i-o*n;return this.x=h*a+c*-s+u*-o-l*-r,this.y=u*a+c*-r+l*-s-h*-o,this.z=l*a+c*-o+h*-r-u*-s,this},project:function(t){var e=this.x,i=this.y,n=this.z,s=t.val,r=s[0],o=s[1],a=s[2],h=s[3],u=s[4],l=s[5],c=s[6],d=s[7],f=s[8],p=s[9],g=s[10],v=s[11],y=s[12],m=s[13],x=s[14],w=1/(e*h+i*d+n*v+s[15]);return this.x=(e*r+i*u+n*f+y)*w,this.y=(e*o+i*l+n*p+m)*w,this.z=(e*a+i*c+n*g+x)*w,this},unproject:function(t,e){var i=t.x,n=t.y,s=t.z,r=t.w,o=this.x-i,a=r-this.y-1-n,h=this.z;return this.x=2*o/s-1,this.y=2*a/r-1,this.z=2*h-1,this.project(e)},reset:function(){return this.x=0,this.y=0,this.z=0,this}});t.exports=n},function(t,e,i){var n=i(0),s=i(122),r=i(8),o=i(6),a=new n({initialize:function(t){this.type=t,this.defaultDivisions=5,this.arcLengthDivisions=100,this.cacheArcLengths=[],this.needsUpdate=!0,this.active=!0,this._tmpVec2A=new o,this._tmpVec2B=new o},draw:function(t,e){return void 0===e&&(e=32),t.strokePoints(this.getPoints(e))},getBounds:function(t,e){t||(t=new r),void 0===e&&(e=16);var i=this.getLength();e>i&&(e=i/2);var n=Math.max(1,Math.round(i/e));return s(this.getSpacedPoints(n),t)},getDistancePoints:function(t){var e=this.getLength(),i=Math.max(1,e/t);return this.getSpacedPoints(i)},getEndPoint:function(t){return void 0===t&&(t=new o),this.getPointAt(1,t)},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,i=[],n=this.getPoint(0,this._tmpVec2A),s=0;i.push(0);for(var r=1;r<=t;r++)s+=(e=this.getPoint(r/t,this._tmpVec2B)).distance(n),i.push(s),n.copy(e);return this.cacheArcLengths=i,i},getPointAt:function(t,e){var i=this.getUtoTmapping(t);return this.getPoint(i,e)},getPoints:function(t){void 0===t&&(t=this.defaultDivisions);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return e},getRandomPoint:function(t){return void 0===t&&(t=new o),this.getPoint(Math.random(),t)},getSpacedPoints:function(t){void 0===t&&(t=this.defaultDivisions);for(var e=[],i=0;i<=t;i++){var n=this.getUtoTmapping(i/t,null,t);e.push(this.getPoint(n))}return e},getStartPoint:function(t){return void 0===t&&(t=new o),this.getPointAt(0,t)},getTangent:function(t,e){void 0===e&&(e=new o);var i=t-1e-4,n=t+1e-4;return i<0&&(i=0),n>1&&(n=1),this.getPoint(i,this._tmpVec2A),this.getPoint(n,e),e.subtract(this._tmpVec2A).normalize()},getTangentAt:function(t,e){var i=this.getUtoTmapping(t);return this.getTangent(i,e)},getTFromDistance:function(t,e){return t<=0?0:this.getUtoTmapping(0,t,e)},getUtoTmapping:function(t,e,i){var n,s=this.getLengths(i),r=0,o=s.length;n=e?Math.min(e,s[o-1]):t*s[o-1];for(var a,h=0,u=o-1;h<=u;)if((a=s[r=Math.floor(h+(u-h)/2)]-n)<0)h=r+1;else{if(!(a>0)){u=r;break}u=r-1}if(s[r=u]===n)return r/(o-1);var l=s[r];return(r+(n-l)/(s[r+1]-l))/(o-1)},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()}});t.exports=a},function(t,e){t.exports=function(t){var e={};for(var i in t)Array.isArray(t[i])?e[i]=t[i].slice(0):e[i]=t[i];return e}},function(t,e){t.exports=function(t,e,i){var n=t.x3-t.x1,s=t.y3-t.y1,r=t.x2-t.x1,o=t.y2-t.y1,a=e-t.x1,h=i-t.y1,u=n*n+s*s,l=n*r+s*o,c=n*a+s*h,d=r*r+o*o,f=r*a+o*h,p=u*d-l*l,g=0===p?0:1/p,v=(d*c-l*f)*g,y=(u*f-l*c)*g;return v>=0&&y>=0&&v+y<1}},function(t,e){t.exports=function(t){return Math.atan2(t.y2-t.y1,t.x2-t.x1)}},function(t,e,i){var n=i(0),s=i(54),r=i(309),o=i(310),a=i(112),h=new n({initialize:function(t,e,i,n,s,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===s&&(s=0),void 0===r&&(r=0),this.x1=t,this.y1=e,this.x2=i,this.y2=n,this.x3=s,this.y3=r},contains:function(t,e){return s(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return a(this,t)},setTo:function(t,e,i,n,s,r){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===s&&(s=0),void 0===r&&(r=0),this.x1=t,this.y1=e,this.x2=i,this.y2=n,this.x3=s,this.y3=r,this},getLineA:function(){return{x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2}},getLineB:function(){return{x1:this.x2,y1:this.y2,x2:this.x3,y2:this.y3}},getLineC:function(){return{x1:this.x3,y1:this.y3,x2:this.x1,y2:this.y1}},left:{get:function(){return Math.min(this.x1,this.x2,this.x3)},set:function(t){var e=0;e=this.x1<=this.x2&&this.x1<=this.x3?this.x1-t:this.x2<=this.x1&&this.x2<=this.x3?this.x2-t:this.x3-t,this.x1-=e,this.x2-=e,this.x3-=e}},right:{get:function(){return Math.max(this.x1,this.x2,this.x3)},set:function(t){var e=0;e=this.x1>=this.x2&&this.x1>=this.x3?this.x1-t:this.x2>=this.x1&&this.x2>=this.x3?this.x2-t:this.x3-t,this.x1-=e,this.x2-=e,this.x3-=e}},top:{get:function(){return Math.min(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1<=this.y2&&this.y1<=this.y3?this.y1-t:this.y2<=this.y1&&this.y2<=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}},bottom:{get:function(){return Math.max(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1>=this.y2&&this.y1>=this.y3?this.y1-t:this.y2>=this.y1&&this.y2>=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}}});t.exports=h},function(t,e,i){var n=i(0),s=i(17),r=i(18),o=i(7),a=i(2),h=new n({Extends:r,initialize:function(t,e,i,n){var o="string"==typeof t?t:a(t,"key",""),h={type:"json",extension:a(t,"extension","json"),responseType:"text",key:o,url:a(t,"file",e),path:i,xhrSettings:a(t,"xhr",n)};r.call(this,h),"object"==typeof h.url&&(this.data=h.url,this.state=s.FILE_POPULATED)},onProcess:function(t){this.state=s.FILE_PROCESSING,this.data=JSON.parse(this.xhrLoader.responseText),this.onComplete(),t(this)}});o.register("json",function(t,e,i){if(Array.isArray(t))for(var n=0;n-1&&this.entries.splice(e,1),this},dump:function(){console.group("Set");for(var t=0;t-1},union:function(t){var e=new n;return t.entries.forEach(function(t){e.set(t)}),this.entries.forEach(function(t){e.set(t)}),e},intersect:function(t){var e=new n;return this.entries.forEach(function(i){t.contains(i)&&e.set(i)}),e},difference:function(t){var e=new n;return this.entries.forEach(function(i){t.contains(i)||e.set(i)}),e},size:{get:function(){return this.entries.length},set:function(t){return this.entries.length=t}}});t.exports=n},function(t,e){t.exports={DEFAULT:0,LINEAR:0,NEAREST:1}},function(t,e,i){var n=i(0),s=i(32),r=i(184),o=i(185),a=i(106),h=new n({initialize:function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.x=t,this.y=e,this._radius=i,this._diameter=2*i},contains:function(t,e){return s(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return a(this,t)},setTo:function(t,e,i){return this.x=t,this.y=e,this._radius=i,this._diameter=2*i,this},setEmpty:function(){return this._radius=0,this._diameter=0,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},isEmpty:function(){return this._radius<=0},radius:{get:function(){return this._radius},set:function(t){this._radius=t,this._diameter=2*t}},diameter:{get:function(){return this._diameter},set:function(t){this._diameter=t,this._radius=.5*t}},left:{get:function(){return this.x-this._radius},set:function(t){this.x=t+this._radius}},right:{get:function(){return this.x+this._radius},set:function(t){this.x=t-this._radius}},top:{get:function(){return this.y-this._radius},set:function(t){this.y=t+this._radius}},bottom:{get:function(){return this.y+this._radius},set:function(t){this.y=t-this._radius}}});t.exports=h},function(t,e,i){var n=i(61);t.exports=function(t,e,i){return(i-e)*(t=n(t,0,1))}},function(t,e){t.exports=function(t){return Math.sqrt((t.x2-t.x1)*(t.x2-t.x1)+(t.y2-t.y1)*(t.y2-t.y1))}},function(t,e,i){(function(e){var i={android:!1,chromeOS:!1,cocoonJS:!1,cocoonJSApp:!1,cordova:!1,crosswalk:!1,desktop:!1,ejecta:!1,electron:!1,iOS:!1,iOSVersion:0,iPad:!1,iPhone:!1,kindle:!1,linux:!1,macOS:!1,node:!1,nodeWebkit:!1,pixelRatio:1,webApp:!1,windows:!1,windowsPhone:!1};t.exports=function(){var t=navigator.userAgent;/Windows/.test(t)?i.windows=!0:/Mac OS/.test(t)?i.macOS=!0:/Linux/.test(t)?i.linux=!0:/Android/.test(t)?i.android=!0:/iP[ao]d|iPhone/i.test(t)?(i.iOS=!0,navigator.appVersion.match(/OS (\d+)/),i.iOSVersion=parseInt(RegExp.$1,10)):/Kindle/.test(t)||/\bKF[A-Z][A-Z]+/.test(t)||/Silk.*Mobile Safari/.test(t)?i.kindle=!0:/CrOS/.test(t)&&(i.chromeOS=!0),(/Windows Phone/i.test(t)||/IEMobile/i.test(t))&&(i.android=!1,i.iOS=!1,i.macOS=!1,i.windows=!0,i.windowsPhone=!0);var n=/Silk/.test(t);if((i.windows||i.macOS||i.linux&&!n||i.chromeOS)&&(i.desktop=!0),(i.windowsPhone||/Windows NT/i.test(t)&&/Touch/i.test(t))&&(i.desktop=!1),navigator.standalone&&(i.webApp=!0),void 0!==window.cordova&&(i.cordova=!0),void 0!==e&&void 0!==e.versions.node&&(i.node=!0),i.node&&"object"==typeof e.versions&&(i.nodeWebkit=!!e.versions["node-webkit"],i.electron=!!e.versions.electron),navigator.isCocoonJS){i.cocoonJS=!0;try{i.cocoonJSApp="undefined"!=typeof CocoonJS}catch(t){i.cocoonJSApp=!1}}return void 0!==window.ejecta&&(i.ejecta=!0),/Crosswalk/.test(t)&&(i.crosswalk=!0),i.iPhone=-1!==t.toLowerCase().indexOf("iphone"),i.iPad=-1!==t.toLowerCase().indexOf("ipad"),i.pixelRatio=window.devicePixelRatio||1,i}()}).call(e,i(506))},function(t,e){t.exports=function(t,e,i){if(t.width<=0||t.height<=0)return!1;var n=(e-t.x)/t.width,s=(i-t.y)/t.height;return(n*=n)+(s*=s)<.25}},function(t,e,i){var n=i(171),s=i(0),r=i(2),o=i(4),a=i(275),h=i(62),u=i(37),l=new s({initialize:function(t,e,i){void 0!==i||Array.isArray(e)||"object"!=typeof e||(i=e,e=null),this.scene=t,this.children=new h(e),this.isParent=!0,this.classType=r(i,"classType",u),this.active=r(i,"active",!0),this.maxSize=r(i,"maxSize",-1),this.defaultKey=r(i,"defaultKey",null),this.defaultFrame=r(i,"defaultFrame",null),this.runChildUpdate=r(i,"runChildUpdate",!1),this.createCallback=r(i,"createCallback",null),this.removeCallback=r(i,"removeCallback",null),this.createMultipleCallback=r(i,"createMultipleCallback",null),i&&this.createMultiple(i)},create:function(t,e,i,n,s){if(void 0===i&&(i=this.defaultKey),void 0===n&&(n=this.defaultFrame),void 0===s&&(s=!0),this.isFull())return null;var r=new this.classType(this.scene,t,e,i,n);return this.scene.sys.displayList.add(r),r.preUpdate&&this.scene.sys.updateList.add(r),r.visible=s,this.add(r),r},createMultiple:function(t){Array.isArray(t)||(t=[t]);for(var e=[],i=0;i=0&&t=0&&e0){this.blockSet=!1;var i=this;if(this.events.emit("changedata",this.parent,t,e,function(e){i.blockSet=!0,i.list[t]=e,i.events.emit("setdata",i.parent,t,e)}),this.blockSet)return this}return this.list[t]=e,this.events.emit("setdata",this.parent,t,e),this},each:function(t,e){for(var i=[this.parent,null,void 0],n=1;n0;e--){var i=Math.floor(Math.random()*(e+1)),n=t[e];t[e]=t[i],t[i]=n}return t}},function(t,e,i){var n=i(0),s=i(1),r=i(37),o=i(6),a=i(120),h=new n({Extends:s,initialize:function(t,e,i,n,h,u){s.call(this,t,"Sprite3D"),this.gameObject=new r(t,0,0,h,u),this.position=new a(e,i,n),this.size=new o(this.gameObject.width,this.gameObject.height),this.scale=new o(1,1),this.adjustScaleX=!0,this.adjustScaleY=!0,this._visible=!0},project:function(t){var e=this.position,i=this.gameObject;t.project(e,i),t.getPointSize(e,this.size,this.scale),this.scale.x<=0||this.scale.y<=0?i.setVisible(!1):(i.visible||i.setVisible(!0),this.adjustScaleX&&(i.scaleX=this.scale.x),this.adjustScaleY&&(i.scaleY=this.scale.y),i.setDepth(-1*i.z))},setVisible:function(t){return this.visible=t,this},visible:{get:function(){return this._visible},set:function(t){this._visible=t,this.gameObject.visible=t}},x:{get:function(){return this.position.x},set:function(t){this.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t}},z:{get:function(){return this.position.z},set:function(t){this.position.z=t}}});t.exports=h},function(t,e,i){var n,s=i(67),r={chrome:!1,chromeVersion:0,edge:!1,firefox:!1,firefoxVersion:0,ie:!1,ieVersion:0,mobileSafari:!1,opera:!1,safari:!1,safariVersion:0,silk:!1,trident:!1,tridentVersion:0};t.exports=(n=navigator.userAgent,/Edge\/\d+/.test(n)?r.edge=!0:/Chrome\/(\d+)/.test(n)&&!s.windowsPhone?(r.chrome=!0,r.chromeVersion=parseInt(RegExp.$1,10)):/Firefox\D+(\d+)/.test(n)?(r.firefox=!0,r.firefoxVersion=parseInt(RegExp.$1,10)):/AppleWebKit/.test(n)&&s.iOS?r.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(n)?(r.ie=!0,r.ieVersion=parseInt(RegExp.$1,10)):/Opera/.test(n)?r.opera=!0:/Safari/.test(n)&&!s.windowsPhone?r.safari=!0:/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(n)&&(r.ie=!0,r.trident=!0,r.tridentVersion=parseInt(RegExp.$1,10),r.ieVersion=parseInt(RegExp.$3,10)),/Silk/.test(n)&&(r.silk=!0),r)},function(t,e){t.exports={PENDING:0,INIT:1,START:2,LOADING:3,CREATING:4,RUNNING:5,PAUSED:6,SLEEPING:7,SHUTDOWN:8,DESTROYED:9}},function(t,e,i){var n=i(0),s=i(14),r=i(3),o=new n({Extends:s,initialize:function(t){s.call(this),this.game=t,this.sounds=[],this.mute=!1,this.volume=1,this.pauseOnBlur=!0,t.events.on("blur",function(){this.pauseOnBlur&&this.onBlur()},this),t.events.on("focus",function(){this.pauseOnBlur&&this.onFocus()},this),t.events.once("destroy",this.destroy,this),this._rate=1,this._detune=0,this.locked=this.locked||!1,this.unlocked=!1,this.locked&&this.unlock()},add:r,addAudioSprite:function(t,e){var i=this.add(t,e);for(var n in i.spritemap=this.game.cache.json.get(t).spritemap,i.spritemap)if(i.spritemap.hasOwnProperty(n)){var s=i.spritemap[n];i.addMarker({name:n,start:s.start,duration:s.end-s.start,config:e})}return i},play:function(t,e){var i=this.add(t);return i.once("ended",i.destroy,i),e?e.name?(i.addMarker(e),i.play(e.name)):i.play(e):i.play()},playAudioSprite:function(t,e,i){var n=this.addAudioSprite(t);return n.once("ended",n.destroy,n),n.play(e,i)},remove:function(t){var e=this.sounds.indexOf(t);return-1!==e&&(t.destroy(),this.sounds.splice(e,1),!0)},removeByKey:function(t){for(var e=0,i=this.sounds.length-1;i>=0;i--){var n=this.sounds[i];n.key===t&&(n.destroy(),this.sounds.splice(i,1),e++)}return e},pauseAll:function(){this.forEachActiveSound(function(t){t.pause()}),this.emit("pauseall",this)},resumeAll:function(){this.forEachActiveSound(function(t){t.resume()}),this.emit("resumeall",this)},stopAll:function(){this.forEachActiveSound(function(t){t.stop()}),this.emit("stopall",this)},unlock:r,onBlur:r,onFocus:r,update:function(t,e){this.unlocked&&(this.unlocked=!1,this.locked=!1,this.emit("unlocked",this));for(var i=this.sounds.length-1;i>=0;i--)this.sounds[i].pendingRemove&&this.sounds.splice(i,1);this.sounds.forEach(function(i){i.update(t,e)})},destroy:function(){this.removeAllListeners(),this.forEachActiveSound(function(t){t.destroy()}),this.sounds.length=0,this.sounds=null,this.game=null},forEachActiveSound:function(t,e){var i=this;this.sounds.forEach(function(n,s){n.pendingRemove||t.call(e||i,n,s,i.sounds)})},rate:{get:function(){return this._rate},set:function(t){this._rate=t,this.forEachActiveSound(function(t){t.setRate()}),this.emit("rate",this,t)}},detune:{get:function(){return this._detune},set:function(t){this._detune=t,this.forEachActiveSound(function(t){t.setRate()}),this.emit("detune",this,t)}}});t.exports=o},function(t,e,i){var n=i(0),s=i(14),r=i(23),o=i(3),a=new n({Extends:s,initialize:function(t,e,i){s.call(this),this.manager=t,this.key=e,this.isPlaying=!1,this.isPaused=!1,this.totalRate=1,this.duration=this.duration||0,this.totalDuration=this.totalDuration||0,this.config={delay:0},this.currentConfig=this.config,this.mute=!1,this.volume=1,this.rate=1,this.detune=0,this.seek=0,this.loop=!1,this.config=r(this.config,i),this.markers={},this.currentMarker=null,this.pendingRemove=!1},addMarker:function(t){return!(!t||!t.name||"string"!=typeof t.name)&&(this.markers[t.name]?(console.error("addMarker - Marker with name '"+t.name+"' already exists for sound '"+this.key+"'!"),!1):(t=r(!0,{name:"",start:0,duration:this.totalDuration-(t.start||0),config:{mute:!1,volume:1,rate:1,detune:0,seek:0,loop:!1,delay:0}},t),this.markers[t.name]=t,!0))},updateMarker:function(t){return!(!t||!t.name||"string"!=typeof t.name)&&(this.markers[t.name]?(this.markers[t.name]=r(!0,this.markers[t.name],t),!0):(console.error("updateMarker - Marker with name '"+t.name+"' does not exist for sound '"+this.key+"'!"),!1))},removeMarker:function(t){var e=this.markers[t];return e?(this.markers[t]=null,e):null},play:function(t,e){if(void 0===t&&(t=""),"object"==typeof t&&(e=t,t=""),"string"!=typeof t)return console.error("Sound marker name has to be a string!"),!1;if(t){if(!this.markers[t])return console.error("No marker with name '"+t+"' found for sound '"+this.key+"'!"),!1;this.currentMarker=this.markers[t],this.currentConfig=this.currentMarker.config,this.duration=this.currentMarker.duration}else this.currentMarker=null,this.currentConfig=this.config,this.duration=this.totalDuration;return this.resetConfig(),this.currentConfig=r(this.currentConfig,e),this.isPlaying=!0,this.isPaused=!1,!0},pause:function(){return!(this.isPaused||!this.isPlaying)&&(this.isPlaying=!1,this.isPaused=!0,!0)},resume:function(){return!(!this.isPaused||this.isPlaying)&&(this.isPlaying=!0,this.isPaused=!1,!0)},stop:function(){return!(!this.isPaused&&!this.isPlaying)&&(this.isPlaying=!1,this.isPaused=!1,this.resetConfig(),!0)},applyConfig:function(){this.mute=this.currentConfig.mute,this.volume=this.currentConfig.volume,this.rate=this.currentConfig.rate,this.detune=this.currentConfig.detune,this.loop=this.currentConfig.loop},resetConfig:function(){this.currentConfig.seek=0,this.currentConfig.delay=0},update:o,destroy:function(){this.pendingRemove||(this.pendingRemove=!0,this.manager=null,this.key="",this.removeAllListeners(),this.isPlaying=!1,this.isPaused=!1,this.config=null,this.currentConfig=null,this.markers=null,this.currentMarker=null)},setRate:function(){var t=this.currentConfig.detune+this.manager.detune,e=Math.pow(1.0005777895065548,t);this.totalRate=this.currentConfig.rate*this.manager.rate*e}});Object.defineProperty(a.prototype,"rate",{get:function(){return this.currentConfig.rate},set:function(t){this.currentConfig.rate=t,this.setRate(),this.emit("rate",this,t)}}),Object.defineProperty(a.prototype,"detune",{get:function(){return this.currentConfig.detune},set:function(t){this.currentConfig.detune=t,this.setRate(),this.emit("detune",this,t)}}),t.exports=a},function(t,e,i){var n=new(i(0))({initialize:function(t){this.parent=t,this.list=[],this.position=0},add:function(t){return-1===this.getIndex(t)&&this.list.push(t),t},addAt:function(t,e){return void 0===e&&(e=0),0===this.list.length?this.add(t):(e>=0&&e<=this.list.length&&-1===this.getIndex(t)&&this.list.splice(e,0,t),t)},addMultiple:function(t){if(Array.isArray(t))for(var e=0;en?1:0},getByKey:function(t,e){for(var i=0;ithis.list.length)return null;var i=t+Math.floor(Math.random()*e);return this.list[i]},getFirst:function(t,e,i,n){void 0===i&&(i=0),void 0===n&&(n=this.list.length);for(var s=i;s=this.list.length)throw new Error("List.moveTo: The supplied index is out of bounds");return this.list.splice(i,1),this.list.splice(e,0,t),t},remove:function(t){var e=this.list.indexOf(t);return-1!==e&&this.list.splice(e,1),t},removeAt:function(t){var e=this.list[t];return e&&this.children.splice(t,1),e},removeBetween:function(t,e){void 0===t&&(t=0),void 0===e&&(e=this.list.length);var i=e-t;if(i>0&&i<=e)return this.list.splice(t,i);if(0===i&&0===this.list.length)return[];throw new Error("List.removeBetween: Range Error, numeric values are outside the acceptable range")},removeAll:function(){for(var t=this.list.length;t--;)this.remove(this.list[t]);return this},bringToTop:function(t){return this.getIndex(t)0&&(this.remove(t),this.addAt(t,0)),t},moveUp:function(t){var e=this.getIndex(t);if(-1!==e&&e0){var i=this.getAt(e-1);i&&this.swap(t,i)}return t},reverse:function(){return this.list.reverse(),this},shuffle:function(){for(var t=this.list.length-1;t>0;t--){var e=Math.floor(Math.random()*(t+1)),i=this.list[t];this.list[t]=this.list[e],this.list[e]=i}return this},replace:function(t,e){var i=this.getIndex(t);if(-1!==i)return this.remove(t),this.addAt(e,i),t},exists:function(t){return this.list.indexOf(t)>-1},setAll:function(t,e){for(var i=0;i0?this.list[0]:null}},last:{get:function(){return this.list.length>0?(this.position=this.list.length-1,this.list[this.position]):null}},next:{get:function(){return this.position0?(this.position--,this.list[this.position]):null}}});t.exports=n},function(t,e){t.exports={CREATED:0,INIT:1,DELAY:2,OFFSET_DELAY:3,PENDING_RENDER:4,PLAYING_FORWARD:5,PLAYING_BACKWARD:6,HOLD_DELAY:7,REPEAT_DELAY:8,COMPLETE:9,PENDING_ADD:20,PAUSED:21,LOOP_DELAY:22,ACTIVE:23,COMPLETE_DELAY:24,PENDING_REMOVE:25,REMOVED:26}},function(t,e,i){var n=i(0),s=i(11),r=i(1),o=i(657),a=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Flip,s.GetBounds,s.Origin,s.Pipeline,s.ScaleMode,s.Size,s.Texture,s.Transform,s.Visible,s.ScrollFactor,o],initialize:function(t,e,i,n,s,o,a,h,u){if(r.call(this,t,"Mesh"),this.setTexture(h,u),this.setPosition(e,i),this.setSizeToFrame(),this.setOrigin(),this.initPipeline("TextureTintPipeline"),n.length!==s.length)throw new Error("Mesh Vertex count must match UV count");var l,c=n.length/2|0;if(o.length>0&&o.length0&&a.length=0&&f<=1&&p>=0&&p<=1&&(i.x=s+f*(o-s),i.y=r+f*(a-r),!0)}},function(t,e){t.exports=function(t,e,i,n,s){return void 0===t&&(t=""),void 0===e&&(e=!0),void 0===i&&(i=""),void 0===n&&(n=""),void 0===s&&(s=0),{responseType:t,async:e,user:i,password:n,timeout:s,header:void 0,headerValue:void 0,overrideMimeType:void 0}}},function(t,e,i){var n=i(0),s=i(328),r=i(37),o=new n({Extends:r,Mixins:[s.Acceleration,s.Angular,s.Bounce,s.Debug,s.Drag,s.Enable,s.Friction,s.Gravity,s.Immovable,s.Mass,s.Size,s.Velocity],initialize:function(t,e,i,n,s){r.call(this,t,e,i,n,s)}});t.exports=o},,,,,function(t,e,i){t.exports={CalculateFacesAt:i(153),CalculateFacesWithin:i(34),Copy:i(874),CreateFromTiles:i(875),CullTiles:i(876),Fill:i(877),FilterTiles:i(878),FindByIndex:i(879),FindTile:i(880),ForEachTile:i(881),GetTileAt:i(97),GetTileAtWorldXY:i(882),GetTilesWithin:i(15),GetTilesWithinShape:i(883),GetTilesWithinWorldXY:i(884),HasTileAt:i(345),HasTileAtWorldXY:i(885),IsInLayerBounds:i(74),PutTileAt:i(154),PutTileAtWorldXY:i(886),PutTilesAt:i(887),Randomize:i(888),RemoveTileAt:i(346),RemoveTileAtWorldXY:i(889),RenderDebug:i(890),ReplaceByIndex:i(344),SetCollision:i(891),SetCollisionBetween:i(892),SetCollisionByExclusion:i(893),SetCollisionByProperty:i(894),SetCollisionFromCollisionGroup:i(895),SetTileIndexCallback:i(896),SetTileLocationCallback:i(897),Shuffle:i(898),SwapByIndex:i(899),TileToWorldX:i(98),TileToWorldXY:i(900),TileToWorldY:i(99),WeightedRandomize:i(901),WorldToTileX:i(39),WorldToTileXY:i(902),WorldToTileY:i(40)}},function(t,e,i){var n=i(74);t.exports=function(t,e,i,s){if(void 0===i&&(i=!1),n(t,e,s)){var r=s.data[e][t];return null===r?null:-1===r.index?i?r:null:r}return null}},function(t,e){t.exports=function(t,e,i){var n=i.baseTileWidth,s=i.tilemapLayer,r=0;return s&&(void 0===e&&(e=s.scene.cameras.main),r=s.x+e.scrollX*(1-s.scrollFactorX),n*=s.scaleX),r+t*n}},function(t,e){t.exports=function(t,e,i){var n=i.baseTileHeight,s=i.tilemapLayer,r=0;return s&&(void 0===e&&(e=s.scene.cameras.main),r=s.y+e.scrollY*(1-s.scrollFactorY),n*=s.scaleY),r+t*n}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r,o,a){(void 0===i||i<=0)&&(i=32),(void 0===n||n<=0)&&(n=32),void 0===s&&(s=0),void 0===r&&(r=0),void 0===o&&(o={}),void 0===a&&(a={}),this.name=t,this.firstgid=e,this.tileWidth=i,this.tileHeight=n,this.tileMargin=s,this.tileSpacing=r,this.tileProperties=o,this.tileData=a,this.image=null,this.rows=0,this.columns=0,this.total=0,this.texCoordinates=[]},getTileProperties:function(t){return this.containsTileIndex(t)?this.tileProperties[t-this.firstgid]:null},getTileData:function(t){return this.containsTileIndex(t)?this.tileData[t-this.firstgid]:null},getTileCollisionGroup:function(t){var e=this.getTileData(t);return e&&e.objectgroup?e.objectgroup:null},containsTileIndex:function(t){return t>=this.firstgid&&t=this.vertexCapacity},resize:function(t,e,i){return this.width=t*i,this.height=e*i,this},bind:function(){var t=this.gl,e=this.vertexBuffer,i=this.attributes,n=this.program,s=this.renderer,r=this.vertexSize;s.setProgram(n),s.setVertexBuffer(e);for(var o=0;o=0?(t.enableVertexAttribArray(h),t.vertexAttribPointer(h,a.size,a.type,a.normalized,r,a.offset)):t.disableVertexAttribArray(h)}return this},onBind:function(){return this},onPreRender:function(){return this},onRender:function(){return this},onPostRender:function(){return this},flush:function(){if(this.flushLocked)return this;this.flushLocked=!0;var t=this.gl,e=this.vertexCount,i=this.topology,n=this.vertexSize;if(0!==e)return t.bufferSubData(t.ARRAY_BUFFER,0,this.bytes.subarray(0,e*n)),t.drawArrays(i,0,e),this.vertexCount=0,this.flushLocked=!1,this;this.flushLocked=!1},destroy:function(){var t=this.gl;return t.deleteProgram(this.program),t.deleteBuffer(this.vertexBuffer),delete this.program,delete this.vertexBuffer,delete this.gl,this},setFloat1:function(t,e){return this.renderer.setFloat1(this.program,t,e),this},setFloat2:function(t,e,i){return this.renderer.setFloat2(this.program,t,e,i),this},setFloat3:function(t,e,i,n){return this.renderer.setFloat3(this.program,t,e,i,n),this},setFloat4:function(t,e,i,n,s){return this.renderer.setFloat4(this.program,t,e,i,n,s),this},setInt1:function(t,e){return this.renderer.setInt1(this.program,t,e),this},setInt2:function(t,e,i){return this.renderer.setInt2(this.program,t,e,i),this},setInt3:function(t,e,i,n){return this.renderer.setInt3(this.program,t,e,i,n),this},setInt4:function(t,e,i,n,s){return this.renderer.setInt4(this.program,t,e,i,n,s),this},setMatrix2:function(t,e,i){return this.renderer.setMatrix2(this.program,t,e,i),this},setMatrix3:function(t,e,i){return this.renderer.setMatrix3(this.program,t,e,i),this},setMatrix4:function(t,e,i){return this.renderer.setMatrix4(this.program,t,e,i),this}});t.exports=r},function(t,e,i){var n=i(53);t.exports=function(t,e){var i=n(t);for(var s in e)i.hasOwnProperty(s)||(i[s]=e[s]);return i}},function(t,e,i){var n=i(5);t.exports=function(t,e,i){return void 0===i&&(i=new n),i.x=t.x+t.radius*Math.cos(e),i.y=t.y+t.radius*Math.sin(e),i}},function(t,e,i){var n=i(5);t.exports=function(t,e){void 0===e&&(e=new n);var i=2*Math.PI*Math.random(),s=Math.random()+Math.random(),r=s>1?2-s:s,o=r*Math.cos(i),a=r*Math.sin(i);return e.x=t.x+o*t.radius,e.y=t.y+a*t.radius,e}},function(t,e,i){var n=i(78),s=i(5);t.exports=function(t,e,i){if(void 0===i&&(i=new s),e<=0||e>=1)return i.x=t.x,i.y=t.y,i;var r=n(t)*e;return e>.5?(r-=t.width+t.height)<=t.width?(i.x=t.right-r,i.y=t.bottom):(i.x=t.x,i.y=t.bottom-(r-t.width)):r<=t.width?(i.x=t.x+r,i.y=t.y):(i.x=t.right,i.y=t.y+(r-t.width)),i}},function(t,e,i){var n=i(5);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.x+Math.random()*t.width,e.y=t.y+Math.random()*t.height,e}},function(t,e,i){var n=i(66),s=i(5);t.exports=function(t,e,i,r){void 0===r&&(r=[]),e||(e=n(t)/i);for(var o=t.x1,a=t.y1,h=t.x2,u=t.y2,l=0;l=1&&(a=1-a,h=1-h),e.x=t.x1+(i*a+r*h),e.y=t.y1+(s*a+o*h),e}},function(t,e){t.exports=function(t,e,i,n,s){var r=n+Math.atan2(t.y-i,t.x-e);return t.x=e+s*Math.cos(r),t.y=i+s*Math.sin(r),t}},function(t,e,i){var n=new(i(0))({initialize:function(t){if(this.entries={},this.size=0,Array.isArray(t))for(var e=0;e-y||T>-m||b-y||S>-m||A-y||T>-m||b-y||S>-m||A-v&&S*n+C*r+h>-y&&(S+v)*i+(C+y)*s+a0?this:(this._fadeRed=e,this._fadeGreen=i,this._fadeBlue=n,t<=0&&(t=Number.MIN_VALUE),this._fadeDuration=t,this._fadeAlpha=Number.MIN_VALUE,this)},flash:function(t,e,i,n,s){return!s&&this._flashAlpha>0?this:(void 0===e&&(e=1),void 0===i&&(i=1),void 0===n&&(n=1),this._flashRed=e,this._flashGreen=i,this._flashBlue=n,t<=0&&(t=Number.MIN_VALUE),this._flashDuration=t,this._flashAlpha=1,this)},getWorldPoint:function(t,e,i){void 0===i&&(i=new h);var n=this.matrix.matrix,s=n[0],r=n[1],o=n[2],a=n[3],u=n[4],l=n[5],c=s*a-r*o;if(!c)return i.x=t,i.y=e,i;var d=a*(c=1/c),f=-r*c,p=-o*c,g=s*c,v=(o*l-a*u)*c,y=(r*u-s*l)*c,m=Math.cos(this.rotation),x=Math.sin(this.rotation),w=this.zoom,b=this.scrollX,T=this.scrollY,A=t+(b*m-T*x)*w,S=e+(b*x+T*m)*w;return i.x=A*d+S*p+v,i.y=A*f+S*g+y,i},ignore:function(t){if(t instanceof Array)for(var e=0;el&&(this.scrollX=l),this.scrollYc&&(this.scrollY=c)}this.roundPixels&&(this.scrollX=Math.round(this.scrollX),this.scrollY=Math.round(this.scrollY)),r.loadIdentity(),r.scale(e,e),r.translate(this.x+o,this.y+a),r.rotate(this.rotation),r.scale(s,s),r.translate(-o,-a),r.translate(this._shakeOffsetX,this._shakeOffsetY)},removeBounds:function(){return this.useBounds=!1,this._bounds.setEmpty(),this},setAngle:function(t){return void 0===t&&(t=0),this.rotation=s(t),this},setBackgroundColor:function(t){return void 0===t&&(t="rgba(0,0,0,0)"),this.backgroundColor=a(t),this.transparent=0===this.backgroundColor.alpha,this},setBounds:function(t,e,i,n){return this._bounds.setTo(t,e,i,n),this.useBounds=!0,this},setName:function(t){return void 0===t&&(t=""),this.name=t,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setRotation:function(t){return void 0===t&&(t=0),this.rotation=t,this},setRoundPixels:function(t){return this.roundPixels=t,this},setScene:function(t){return this.scene=t,this},setScroll:function(t,e){return void 0===e&&(e=t),this.scrollX=t,this.scrollY=e,this},setSize:function(t,e){return void 0===e&&(e=t),this.width=t,this.height=e,this},setViewport:function(t,e,i,n){return this.x=t,this.y=e,this.width=i,this.height=n,this},setZoom:function(t){return void 0===t&&(t=1),this.zoom=t,this},shake:function(t,e,i){return void 0===e&&(e=.05),i||0===this._shakeOffsetX&&0===this._shakeOffsetY?(this._shakeDuration=t,this._shakeIntensity=e,this._shakeOffsetX=0,this._shakeOffsetY=0,this):this},startFollow:function(t,e){return this._follow=t,void 0!==e&&(this.roundPixels=e),this},stopFollow:function(){return this._follow=null,this},toJSON:function(){var t={name:this.name,x:this.x,y:this.y,width:this.width,height:this.height,zoom:this.zoom,rotation:this.rotation,roundPixels:this.roundPixels,scrollX:this.scrollX,scrollY:this.scrollY,backgroundColor:this.backgroundColor.rgba};return this.useBounds&&(t.bounds={x:this._bounds.x,y:this._bounds.y,width:this._bounds.width,height:this._bounds.height}),t},resetFX:function(){return this._flashAlpha=0,this._fadeAlpha=0,this._shakeOffsetX=0,this._shakeOffsetY=0,this._shakeDuration=0,this},update:function(t,e){if(this._flashAlpha>0&&(this._flashAlpha-=e/this._flashDuration,this._flashAlpha<0&&(this._flashAlpha=0)),this._fadeAlpha>0&&this._fadeAlpha<1&&(this._fadeAlpha+=e/this._fadeDuration,this._fadeAlpha>=1&&(this._fadeAlpha=1)),this._shakeDuration>0){var i=this._shakeIntensity;this._shakeDuration-=e,this._shakeDuration<=0?(this._shakeOffsetX=0,this._shakeOffsetY=0):(this._shakeOffsetX=(Math.random()*i*this.width*2-i*this.width)*this.zoom,this._shakeOffsetY=(Math.random()*i*this.height*2-i*this.height)*this.zoom,this.roundPixels&&(this._shakeOffsetX|=0,this._shakeOffsetY|=0))}},destroy:function(){this._bounds=void 0,this.matrix=void 0,this.culledObjects=[],this.scene=void 0}});t.exports=u},function(t,e,i){var n=i(203),s=i(205),r=i(207),o=i(208);t.exports=function(t){switch(typeof t){case"string":return"rgb"===t.substr(0,3).toLowerCase()?o(t):n(t);case"number":return s(t);case"object":return r(t)}}},function(t,e){t.exports=function(t,e,i){return t<<16|e<<8|i}},function(t,e,i){var n=i(0),s=i(119),r=i(209),o=i(210),a=i(211),h=i(62),u=i(81),l=i(6),c=i(51),d=i(120),f=new c,p=new d,g=new c,v=new c,y=new s,m=new n({initialize:function(t){this.scene=t,this.displayList=t.sys.displayList,this.updateList=t.sys.updateList,this.name="",this.direction=new c(0,0,-1),this.up=new c(0,1,0),this.position=new c,this.pixelScale=128,this.projection=new s,this.view=new s,this.combined=new s,this.invProjectionView=new s,this.near=1,this.far=100,this.ray={origin:new c,direction:new c},this.viewportWidth=0,this.viewportHeight=0,this.billboardMatrixDirty=!0,this.children=new h},setPosition:function(t,e,i){return this.position.set(t,e,i),this.update()},setScene:function(t){return this.scene=t,this},setPixelScale:function(t){return this.pixelScale=t,this.update()},add:function(t){return this.children.set(t),this.updateChildren(),t},remove:function(t){return this.displayList.remove(t.gameObject),this.updateList.remove(t.gameObject),this.children.delete(t),this},clear:function(){for(var t=this.getChildren(),e=0;e0&&(s=1/Math.sqrt(s),this.x=t*s,this.y=e*s,this.z=i*s,this.w=n*s),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z,r=this.w;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this.w=r+e*(t.w-r),this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z||1,this.w*=t.w||1,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z||1,this.w/=t.w||1,this},distance:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0,s=t.w-this.w||0;return Math.sqrt(e*e+i*i+n*n+s*s)},distanceSq:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0,s=t.w-this.w||0;return e*e+i*i+n*n+s*s},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},transformMat4:function(t){var e=this.x,i=this.y,n=this.z,s=this.w,r=t.val;return this.x=r[0]*e+r[4]*i+r[8]*n+r[12]*s,this.y=r[1]*e+r[5]*i+r[9]*n+r[13]*s,this.z=r[2]*e+r[6]*i+r[10]*n+r[14]*s,this.w=r[3]*e+r[7]*i+r[11]*n+r[15]*s,this},transformQuat:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z,a=t.w,h=a*e+r*n-o*i,u=a*i+o*e-s*n,l=a*n+s*i-r*e,c=-s*e-r*i-o*n;return this.x=h*a+c*-s+u*-o-l*-r,this.y=u*a+c*-r+l*-s-h*-o,this.z=l*a+c*-o+h*-r-u*-s,this},reset:function(){return this.x=0,this.y=0,this.z=0,this.w=0,this}});n.prototype.sub=n.prototype.subtract,n.prototype.mul=n.prototype.multiply,n.prototype.div=n.prototype.divide,n.prototype.dist=n.prototype.distance,n.prototype.distSq=n.prototype.distanceSq,n.prototype.len=n.prototype.length,n.prototype.lenSq=n.prototype.lengthSq,t.exports=n},function(t,e){var i,n="";t.exports={disable:function(t){return""===n&&(n=i(t)),n&&(t[n]=!1),t},enable:function(t){return""===n&&(n=i(t)),n&&(t[n]=!0),t},getPrefix:i=function(t){for(var e=["i","webkitI","msI","mozI","oI"],i=0;i0&&0==(t&t-1)&&e>0&&0==(e&e-1)}},function(t,e){t.exports={ARC:0,BEGIN_PATH:1,CLOSE_PATH:2,FILL_RECT:3,LINE_TO:4,MOVE_TO:5,LINE_STYLE:6,FILL_STYLE:7,FILL_PATH:8,STROKE_PATH:9,FILL_TRIANGLE:10,STROKE_TRIANGLE:11,LINE_FX_TO:12,MOVE_FX_TO:13,SAVE:14,RESTORE:15,TRANSLATE:16,SCALE:17,ROTATE:18}},function(t,e){t.exports={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PRINT_SCREEN:42,INSERT:45,DELETE:46,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,SEMICOLON:186,PLUS:187,COMMA:188,MINUS:189,PERIOD:190,FORWARD_SLASH:191,BACK_SLASH:220,QUOTES:222,BACKTICK:192,OPEN_BRACKET:219,CLOSED_BRACKET:221}},function(t,e,i){var n=i(0),s=i(83),r=i(530),o=i(531),a=i(236),h=i(255),u=new n({initialize:function(t,e){this.scene=t,this.game,this.config=e,this.settings=h.create(e),this.canvas,this.context,this.anims,this.cache,this.plugins,this.registry,this.sound,this.textures,this.add,this.cameras,this.displayList,this.events,this.make,this.scenePlugin,this.updateList},init:function(t){this.settings.status=s.INIT,this.game=t,this.canvas=t.canvas,this.context=t.context;var e=t.plugins;this.plugins=e,e.installGlobal(this,a.Global),e.installLocal(this,a.CoreScene),e.installLocal(this,o(this)),e.installLocal(this,r(this)),this.events.emit("boot",this),this.settings.isBooted=!0},install:function(t){Array.isArray(t)||(t=[t]),this.plugins.installLocal(this,t)},step:function(t,e){this.events.emit("preupdate",t,e),this.events.emit("update",t,e),this.scene.update.call(this.scene,t,e),this.events.emit("postupdate",t,e)},render:function(t){var e=this.displayList;e.depthSort(),this.cameras.render(t,e),this.events.emit("render",t)},queueDepthSort:function(){this.displayList.queueDepthSort()},depthSort:function(){this.displayList.depthSort()},pause:function(){return this.settings.active&&(this.settings.status=s.PAUSED,this.settings.active=!1,this.events.emit("pause",this)),this},resume:function(){return this.settings.active||(this.settings.status=s.RUNNING,this.settings.active=!0,this.events.emit("resume",this)),this},sleep:function(){return this.settings.status=s.SLEEPING,this.settings.active=!1,this.settings.visible=!1,this.events.emit("sleep",this),this},wake:function(){return this.settings.status=s.RUNNING,this.settings.active=!0,this.settings.visible=!0,this.events.emit("wake",this),this},isSleeping:function(){return this.settings.status===s.SLEEPING},isActive:function(){return this.settings.status===s.RUNNING},isVisible:function(){return this.settings.visible},setVisible:function(t){return this.settings.visible=t,this},setActive:function(t){return t?this.resume():this.pause()},start:function(t){this.settings.status=s.START,this.settings.data=t,this.settings.active=!0,this.settings.visible=!0,this.events.emit("start",this)},resize:function(t,e){this.events.emit("resize",t,e)},shutdown:function(){this.settings.status=s.SHUTDOWN,this.settings.active=!1,this.settings.visible=!1,this.events.emit("shutdown",this)},destroy:function(){this.settings.status=s.DESTROYED,this.settings.active=!1,this.settings.visible=!1,this.events.emit("destroy",this)}});t.exports=u},function(t,e,i){var n=i(0),s=i(23),r=new n({initialize:function(t,e,i,n,s,r,o){this.texture=t,this.name=e,this.source=t.source[i],this.sourceIndex=i,this.cutX=n,this.cutY=s,this.cutWidth=r,this.cutHeight=o,this.x=0,this.y=0,this.width=r,this.height=o,this.halfWidth=Math.floor(.5*r),this.halfHeight=Math.floor(.5*o),this.centerX=Math.floor(r/2),this.centerY=Math.floor(o/2),this.pivotX=0,this.pivotY=0,this.customPivot=!1,this.rotated=!1,this.autoRound=-1,this.customData={},this.data={cut:{x:n,y:s,w:r,h:o,r:n+r,b:s+o},trim:!1,sourceSize:{w:r,h:o},spriteSourceSize:{x:0,y:0,w:r,h:o},uvs:{x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},radius:.5*Math.sqrt(r*r+o*o),drawImage:{sx:n,sy:s,sWidth:r,sHeight:o,dWidth:r,dHeight:o}},this.updateUVs()},setTrim:function(t,e,i,n,s,r){var o=this.data,a=o.spriteSourceSize;return o.trim=!0,o.sourceSize.w=t,o.sourceSize.h=e,a.x=i,a.y=n,a.w=s,a.h=r,this.x=i,this.y=n,this.width=s,this.height=r,this.halfWidth=.5*s,this.halfHeight=.5*r,this.centerX=Math.floor(s/2),this.centerY=Math.floor(r/2),this.updateUVs()},updateUVs:function(){var t=this.cutX,e=this.cutY,i=this.cutWidth,n=this.cutHeight,s=this.data.drawImage;s.sWidth=i,s.sHeight=n,s.dWidth=i,s.dHeight=n;var r=this.source.width,o=this.source.height,a=this.data.uvs;return a.x0=t/r,a.y0=e/o,a.x1=t/r,a.y1=(e+n)/o,a.x2=(t+i)/r,a.y2=(e+n)/o,a.x3=(t+i)/r,a.y3=e/o,this},updateUVsInverted:function(){var t=this.source.width,e=this.source.height,i=this.data.uvs;return i.x3=(this.cutX+this.cutHeight)/t,i.y3=(this.cutY+this.cutWidth)/e,i.x2=this.cutX/t,i.y2=(this.cutY+this.cutWidth)/e,i.x1=this.cutX/t,i.y1=this.cutY/e,i.x0=(this.cutX+this.cutHeight)/t,i.y0=this.cutY/e,this},clone:function(){var t=new r(this.texture,this.name,this.sourceIndex);return t.cutX=this.cutX,t.cutY=this.cutY,t.cutWidth=this.cutWidth,t.cutHeight=this.cutHeight,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t.halfWidth=this.halfWidth,t.halfHeight=this.halfHeight,t.centerX=this.centerX,t.centerY=this.centerY,t.rotated=this.rotated,t.data=s(!0,t.data,this.data),t.updateUVs(),t},destroy:function(){this.texture=null,this.source=null},realWidth:{get:function(){return this.data.sourceSize.w}},realHeight:{get:function(){return this.data.sourceSize.h}},uvs:{get:function(){return this.data.uvs}},radius:{get:function(){return this.data.radius}},trimmed:{get:function(){return this.data.trim}},canvasData:{get:function(){return this.data.drawImage}}});t.exports=r},function(t,e,i){var n=i(10);t.exports=function(t,e){var i=n(e,"anims",null);if(null===i)return t;if("string"==typeof i)t.anims.play(i);else if("object"==typeof i){var s=t.anims,r=n(i,"key",void 0),o=n(i,"startFrame",void 0),a=n(i,"delay",0),h=n(i,"repeat",0),u=n(i,"repeatDelay",0),l=n(i,"yoyo",!1),c=n(i,"play",!1),d=n(i,"delayedPlay",0);s.delay(a),s.repeat(h),s.repeatDelay(u),s.yoyo(l),c?s.play(r,o):d>0?s.delayedPlay(d,r,o):s.load(r)}return t}},function(t,e,i){var n=i(0),s=i(11),r=i(1),o=i(268),a=i(547),h=i(548),u=i(549),l=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Origin,s.Pipeline,s.ScaleMode,s.Texture,s.Tint,s.Transform,s.Visible,s.ScrollFactor,u],initialize:function(t,e,i,n,s,o){void 0===s&&(s=""),r.call(this,t,"BitmapText"),this.font=n;var a=this.scene.sys.cache.bitmapFont.get(n);this.fontData=a.data,this.text=Array.isArray(s)?s.join("\n"):s,this.fontSize=o||this.fontData.size,this.setTexture(a.texture,a.frame),this.setPosition(e,i),this.setOrigin(0,0),this.initPipeline("TextureTintPipeline"),this._bounds=this.getTextBounds()},setFontSize:function(t){return this.fontSize=t,this},setText:function(t){return t||0===t||(t=""),Array.isArray(t)&&(t=t.join("\n")),t!==this.text&&(this.text=t.toString(),this.updateDisplayOrigin()),this},getTextBounds:function(t){return this._bounds=o(this,t),this._bounds},width:{get:function(){return this.getTextBounds(!1),this._bounds.global.width}},height:{get:function(){return this.getTextBounds(!1),this._bounds.global.height}},toJSON:function(){var t=s.ToJSON(this),e={font:this.font,text:this.text,fontSize:this.fontSize};return t.data=e,t}});l.ParseRetroFont=h,l.ParseFromAtlas=a,t.exports=l},function(t,e,i){var n=i(552),s=i(555),r=i(0),o=i(11),a=i(131),h=i(1),u=i(86),l=new r({Extends:h,Mixins:[o.Alpha,o.BlendMode,o.Depth,o.Pipeline,o.ScaleMode,o.ScrollFactor,o.Size,o.Texture,o.Transform,o.Visible,n],initialize:function(t,e,i,n,s){h.call(this,t,"Blitter"),this.setTexture(n,s),this.setPosition(e,i),this.initPipeline("TextureTintPipeline"),this.children=new u,this.renderList=[],this.dirty=!1},create:function(t,e,i,n,r){void 0===n&&(n=!0),void 0===r&&(r=this.children.length),void 0===i?i=this.frame:i instanceof a||(i=this.texture.get(i));var o=new s(this,t,e,i,n);return this.children.addAt(o,r,!1),this.dirty=!0,o},createFromCallback:function(t,e,i,n){for(var s=this.createMultiple(e,i,n),r=0;r0},getRenderList:function(){return this.dirty&&(this.renderList=this.children.list.filter(this.childCanRender,this),this.dirty=!1),this.renderList},clear:function(){this.children.removeAll(),this.dirty=!0}});t.exports=l},function(t,e,i){var n=i(0),s=i(11),r=i(1),o=i(268),a=i(556),h=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Origin,s.Pipeline,s.Texture,s.Tint,s.Transform,s.Visible,s.ScrollFactor,a],initialize:function(t,e,i,n,s,o){void 0===s&&(s=""),r.call(this,t,"DynamicBitmapText"),this.font=n;var a=this.scene.sys.cache.bitmapFont.get(n);this.fontData=a.data,this.text=Array.isArray(s)?s.join("\n"):s,this.fontSize=o||this.fontData.size,this.setTexture(a.texture,a.frame),this.setPosition(e,i),this.setOrigin(0,0),this.initPipeline("TextureTintPipeline"),this._bounds=this.getTextBounds(),this.scrollX=0,this.scrollY=0,this.cropWidth=0,this.cropHeight=0,this.displayCallback},setSize:function(t,e){return this.cropWidth=t,this.cropHeight=e,this},setDisplayCallback:function(t){return this.displayCallback=t,this},setFontSize:function(t){return this.fontSize=t,this},setText:function(t){return t||0===t||(t=""),Array.isArray(t)&&(t=t.join("\n")),t!==this.text&&(this.text=t.toString(),this.updateDisplayOrigin()),this},setScrollX:function(t){return this.scrollX=t,this},setScrollY:function(t){return this.scrollY=t,this},getTextBounds:function(t){return this._bounds=o(this,t),this._bounds},width:{get:function(){return this.getTextBounds(!1),this._bounds.global.width}},height:{get:function(){return this.getTextBounds(!1),this._bounds.global.height}},toJSON:function(){var t=s.ToJSON(this),e={font:this.font,text:this.text,fontSize:this.fontSize};return t.data=e,t}});t.exports=h},function(t,e,i){var n=i(115),s=i(0),r=i(128),o=i(11),a=i(270),h=i(1),u=i(4),l=i(16),c=i(568),d=new s({Extends:h,Mixins:[o.Alpha,o.BlendMode,o.Depth,o.Pipeline,o.Transform,o.Visible,o.ScrollFactor,c],initialize:function(t,e){var i=u(e,"x",0),n=u(e,"y",0);h.call(this,t,"Graphics"),this.setPosition(i,n),this.initPipeline("FlatTintPipeline"),this.displayOriginX=0,this.displayOriginY=0,this.commandBuffer=[],this.defaultFillColor=-1,this.defaultFillAlpha=1,this.defaultStrokeWidth=1,this.defaultStrokeColor=-1,this.defaultStrokeAlpha=1,this._lineWidth=1,this.setDefaultStyles(e)},setDefaultStyles:function(t){return u(t,"lineStyle",null)&&(this.defaultStrokeWidth=u(t,"lineStyle.width",1),this.defaultStrokeColor=u(t,"lineStyle.color",16777215),this.defaultStrokeAlpha=u(t,"lineStyle.alpha",1),this.lineStyle(this.defaultStrokeWidth,this.defaultStrokeColor,this.defaultStrokeAlpha)),u(t,"fillStyle",null)&&(this.defaultFillColor=u(t,"fillStyle.color",16777215),this.defaultFillAlpha=u(t,"fillStyle.alpha",1),this.fillStyle(this.defaultFillColor,this.defaultFillAlpha)),this},lineStyle:function(t,e,i){return void 0===i&&(i=1),this.commandBuffer.push(r.LINE_STYLE,t,e,i),this._lineWidth=t,this},fillStyle:function(t,e){return void 0===e&&(e=1),this.commandBuffer.push(r.FILL_STYLE,t,e),this},beginPath:function(){return this.commandBuffer.push(r.BEGIN_PATH),this},closePath:function(){return this.commandBuffer.push(r.CLOSE_PATH),this},fillPath:function(){return this.commandBuffer.push(r.FILL_PATH),this},strokePath:function(){return this.commandBuffer.push(r.STROKE_PATH),this},fillCircleShape:function(t){return this.fillCircle(t.x,t.y,t.radius)},strokeCircleShape:function(t){return this.strokeCircle(t.x,t.y,t.radius)},fillCircle:function(t,e,i){return this.beginPath(),this.arc(t,e,i,0,l.PI2),this.fillPath(),this},strokeCircle:function(t,e,i){return this.beginPath(),this.arc(t,e,i,0,l.PI2),this.strokePath(),this},fillRectShape:function(t){return this.fillRect(t.x,t.y,t.width,t.height)},strokeRectShape:function(t){return this.strokeRect(t.x,t.y,t.width,t.height)},fillRect:function(t,e,i,n){return this.commandBuffer.push(r.FILL_RECT,t,e,i,n),this},strokeRect:function(t,e,i,n){var s=this._lineWidth/2,r=t-s,o=t+s;return this.beginPath(),this.moveTo(t,e),this.lineTo(t,e+n),this.strokePath(),this.beginPath(),this.moveTo(t+i,e),this.lineTo(t+i,e+n),this.strokePath(),this.beginPath(),this.moveTo(r,e),this.lineTo(o+i,e),this.strokePath(),this.beginPath(),this.moveTo(r,e+n),this.lineTo(o+i,e+n),this.strokePath(),this},fillPointShape:function(t,e){return this.fillPoint(t.x,t.y,e)},fillPoint:function(t,e,i){return!i||i<1?i=1:(t-=i/2,e-=i/2),this.commandBuffer.push(r.FILL_RECT,t,e,i,i),this},fillTriangleShape:function(t){return this.fillTriangle(t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)},strokeTriangleShape:function(t){return this.strokeTriangle(t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)},fillTriangle:function(t,e,i,n,s,o){return this.commandBuffer.push(r.FILL_TRIANGLE,t,e,i,n,s,o),this},strokeTriangle:function(t,e,i,n,s,o){return this.commandBuffer.push(r.STROKE_TRIANGLE,t,e,i,n,s,o),this},strokeLineShape:function(t){return this.lineBetween(t.x1,t.y1,t.x2,t.y2)},lineBetween:function(t,e,i,n){return this.beginPath(),this.moveTo(t,e),this.lineTo(i,n),this.strokePath(),this},lineTo:function(t,e){return this.commandBuffer.push(r.LINE_TO,t,e),this},moveTo:function(t,e){return this.commandBuffer.push(r.MOVE_TO,t,e),this},lineFxTo:function(t,e,i,n){return this.commandBuffer.push(r.LINE_FX_TO,t,e,i,n,1),this},moveFxTo:function(t,e,i,n){return this.commandBuffer.push(r.MOVE_FX_TO,t,e,i,n,1),this},strokePoints:function(t,e,i){void 0===e&&(e=!1),void 0===i&&(i=t.length),this.beginPath(),this.moveTo(t[0].x,t[0].y);for(var n=1;n-1&&this.fillStyle(this.defaultFillColor,this.defaultFillAlpha),this.defaultStrokeColor>-1&&this.lineStyle(this.defaultStrokeWidth,this.defaultStrokeColor,this.defaultStrokeAlpha),this},generateTexture:function(t,e,i){var n,s,r=this.scene.sys;if(void 0===e&&(e=r.game.config.width),void 0===i&&(i=r.game.config.height),d.TargetCamera.setViewport(0,0,e,i),d.TargetCamera.scrollX=this.x,d.TargetCamera.scrollY=this.y,"string"==typeof t)if(r.textures.exists(t)){var o=(n=r.textures.get(t)).getSourceImage();o instanceof HTMLCanvasElement&&(s=o.getContext("2d"))}else s=(n=r.textures.createCanvas(t,e,i)).getSourceImage().getContext("2d");else t instanceof HTMLCanvasElement&&(s=t.getContext("2d"));return s&&(this.renderCanvas(r.game.renderer,this,0,d.TargetCamera,s),r.game.renderer.gl&&n&&(n.source[0].glTexture=r.game.renderer.canvasToTexture(s.canvas,n.source[0].glTexture,!0,0))),this}});d.TargetCamera=new n(0,0,0,0),t.exports=d},function(t,e,i){var n=i(0),s=i(68),r=i(271),o=i(272),a=i(110),h=new n({initialize:function(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x=t,this.y=e,this.width=i,this.height=n},contains:function(t,e){return s(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return a(this,t)},setTo:function(t,e,i,n){return this.x=t,this.y=e,this.width=i,this.height=n,this},setEmpty:function(){return this.width=0,this.height=0,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setSize:function(t,e){return void 0===e&&(e=t),this.width=t,this.height=e,this},isEmpty:function(){return this.width<=0||this.height<=0},getMinorRadius:function(){return Math.min(this.width,this.height)/2},getMajorRadius:function(){return Math.max(this.width,this.height)/2},left:{get:function(){return this.x-this.width/2},set:function(t){this.x=t+this.width/2}},right:{get:function(){return this.x+this.width/2},set:function(t){this.x=t-this.width/2}},top:{get:function(){return this.y-this.height/2},set:function(t){this.y=t+this.height/2}},bottom:{get:function(){return this.y+this.height/2},set:function(t){this.y=t-this.height/2}}});t.exports=h},function(t,e,i){var n=i(5);t.exports=function(t,e,i){void 0===i&&(i=new n);var s=t.width/2,r=t.height/2;return i.x=t.x+s*Math.cos(e),i.y=t.y+r*Math.sin(e),i}},function(t,e,i){var n=i(0),s=i(11),r=i(1),o=i(573),a=i(86),h=i(574),u=i(613),l=new n({Extends:r,Mixins:[s.Depth,s.Visible,s.Pipeline,u],initialize:function(t,e,i,n){if(r.call(this,t,"ParticleEmitterManager"),this.blendMode=-1,this.timeScale=1,this.texture=null,this.frame=null,this.frameNames=[],null===i||"object"!=typeof i&&!Array.isArray(i)||(n=i,i=null),this.setTexture(e,i),this.initPipeline("TextureTintPipeline"),this.emitters=new a(this),this.wells=new a(this),n){Array.isArray(n)||(n=[n]);for(var s=0;s0?e.defaultFrame=i[0]:e.defaultFrame=this.defaultFrame,this},addEmitter:function(t){return this.emitters.add(t)},createEmitter:function(t){return this.addEmitter(new h(this,t))},addGravityWell:function(t){return this.wells.add(t)},createGravityWell:function(t){return this.addGravityWell(new o(t))},emitParticle:function(t,e,i){for(var n=this.emitters.list,s=0;su){if(0===c){for(var g=f;g.length&&(g=g.slice(0,-1),!((p=e.measureText(g).width)<=u)););if(!g.length)throw new Error("This text's wordWrapWidth setting is less than a single character!");var v=d.substr(g.length);l[c]=v,h+=g}var y=l[c].length?c:c+1,m=l.slice(y).join(" ").replace(/[ \n]*$/gi,"");s[o+1]=m+" "+(s[o+1]||""),r=s.length;break}h+=f,u-=p}n+=h.replace(/[ \n]*$/gi,"")+"\n"}}return n=n.replace(/[\s|\n]*$/gi,"")},basicWordWrap:function(t,e,i){for(var n="",s=t.split(this.splitRegExp),r=0;ro?(h>0&&(n+="\n"),n+=a[h]+" ",o=i-u):(o-=l,n+=a[h]+" ")}r0&&(a+=l.lineSpacing*p),i.rtl?o=d-o:"right"===i.align?o+=l.width-l.lineWidths[p]:"center"===i.align&&(o+=(l.width-l.lineWidths[p])/2),this.autoRound&&(o=Math.round(o),a=Math.round(a)),i.strokeThickness&&(this.style.syncShadow(e,i.shadowStroke),e.strokeText(h[p],o,a)),i.color&&(this.style.syncShadow(e,i.shadowFill),e.fillText(h[p],o,a));return e.restore(),this.dirty=!0,this},getTextMetrics:function(){return this.style.getTextMetrics()},toJSON:function(){var t=o.ToJSON(this),e={autoRound:this.autoRound,text:this.text,style:this.style.toJSON(),resolution:this.resolution,padding:{left:this.padding.left,right:this.padding.right,top:this.padding.top,bottom:this.padding.bottom}};return t.data=e,t},preDestroy:function(){this.style.rtl&&c(this.canvas),s.remove(this.canvas)}});t.exports=p},function(t,e,i){var n=i(21),s=i(0),r=i(11),o=i(19),a=i(1),h=i(291),u=i(627),l=new s({Extends:a,Mixins:[r.Alpha,r.BlendMode,r.Depth,r.Flip,r.GetBounds,r.Origin,r.Pipeline,r.ScaleMode,r.ScrollFactor,r.Size,r.Texture,r.Tint,r.Transform,r.Visible,u],initialize:function(t,e,i,s,r,u,l){var c=t.sys.game.renderer;a.call(this,t,"TileSprite"),this.tilePositionX=0,this.tilePositionY=0,this.dirty=!0,this.tileTexture=null,this.renderer=c,this.setTexture(u,l),this.setPosition(e,i),this.setSize(s,r),this.setOriginFromFrame(),this.initPipeline("TextureTintPipeline"),this.potWidth=h(this.frame.width),this.potHeight=h(this.frame.height),this.canvasPattern=null,this.canvasBuffer=n.create2D(null,this.potWidth,this.potHeight),this.canvasBufferCtx=this.canvasBuffer.getContext("2d"),this.oldFrame=null,this.updateTileTexture(),t.sys.game.config.renderType===o.WEBGL&&t.sys.game.renderer.onContextRestored(function(t){var e=t.gl;this.tileTexture=null,this.dirty=!0,this.tileTexture=t.createTexture2D(0,e.LINEAR,e.LINEAR,e.REPEAT,e.REPEAT,e.RGBA,this.canvasBuffer,this.potWidth,this.potHeight)},this)},updateTileTexture:function(){(this.dirty||this.oldFrame!==this.frame)&&(this.oldFrame=this.frame,this.canvasBufferCtx.clearRect(0,0,this.canvasBuffer.width,this.canvasBuffer.height),this.renderer.gl?(this.canvasBufferCtx.drawImage(this.frame.source.image,this.frame.cutX,this.frame.cutY,this.frame.cutWidth,this.frame.cutHeight,0,0,this.potWidth,this.potHeight),this.tileTexture=this.renderer.canvasToTexture(this.canvasBuffer,this.tileTexture,null===this.tileTexture,this.scaleMode)):(this.canvasBuffer.width=this.frame.cutWidth,this.canvasBuffer.height=this.frame.cutHeight,this.canvasBufferCtx.drawImage(this.frame.source.image,this.frame.cutX,this.frame.cutY,this.frame.cutWidth,this.frame.cutHeight,0,0,this.frame.cutWidth,this.frame.cutHeight),this.canvasPattern=this.canvasBufferCtx.createPattern(this.canvasBuffer,"repeat")),this.dirty=!1)},destroy:function(){this.renderer&&this.renderer.deleteTexture(this.tileTexture),n.remove(this.canvasBuffer),this.canvasPattern=null,this.canvasBufferCtx=null,this.canvasBuffer=null,this.renderer=null,this.visible=!1}});t.exports=l},function(t,e,i){var n=i(0),s=i(88),r=new n({Extends:s,initialize:function(t,e,i,n,r){s.call(this,t,e,i,[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,1,1,1,0,0,1,1,1,0],[16777215,16777215,16777215,16777215,16777215,16777215],[1,1,1,1,1,1],n,r),this.resetPosition()},topLeftX:{get:function(){return this.x+this.vertices[0]},set:function(t){this.vertices[0]=t-this.x,this.vertices[6]=t-this.x}},topLeftY:{get:function(){return this.y+this.vertices[1]},set:function(t){this.vertices[1]=t-this.y,this.vertices[7]=t-this.y}},topRightX:{get:function(){return this.x+this.vertices[10]},set:function(t){this.vertices[10]=t-this.x}},topRightY:{get:function(){return this.y+this.vertices[11]},set:function(t){this.vertices[11]=t-this.y}},bottomLeftX:{get:function(){return this.x+this.vertices[2]},set:function(t){this.vertices[2]=t-this.x}},bottomLeftY:{get:function(){return this.y+this.vertices[3]},set:function(t){this.vertices[3]=t-this.y}},bottomRightX:{get:function(){return this.x+this.vertices[4]},set:function(t){this.vertices[4]=t-this.x,this.vertices[8]=t-this.x}},bottomRightY:{get:function(){return this.y+this.vertices[5]},set:function(t){this.vertices[5]=t-this.y,this.vertices[9]=t-this.y}},topLeftAlpha:{get:function(){return this.alphas[0]},set:function(t){this.alphas[0]=t,this.alphas[3]=t}},topRightAlpha:{get:function(){return this.alphas[5]},set:function(t){this.alphas[5]=t}},bottomLeftAlpha:{get:function(){return this.alphas[1]},set:function(t){this.alphas[1]=t}},bottomRightAlpha:{get:function(){return this.alphas[2]},set:function(t){this.alphas[2]=t,this.alphas[4]=t}},topLeftColor:{get:function(){return this.colors[0]},set:function(t){this.colors[0]=t,this.colors[3]=t}},topRightColor:{get:function(){return this.colors[5]},set:function(t){this.colors[5]=t}},bottomLeftColor:{get:function(){return this.colors[1]},set:function(t){this.colors[1]=t}},bottomRightColor:{get:function(){return this.colors[2]},set:function(t){this.colors[2]=t,this.colors[4]=t}},setTopLeft:function(t,e){return this.topLeftX=t,this.topLeftY=e,this},setTopRight:function(t,e){return this.topRightX=t,this.topRightY=e,this},setBottomLeft:function(t,e){return this.bottomLeftX=t,this.bottomLeftY=e,this},setBottomRight:function(t,e){return this.bottomRightX=t,this.bottomRightY=e,this},resetPosition:function(){var t=this.x,e=this.y,i=Math.floor(this.width/2),n=Math.floor(this.height/2);return this.setTopLeft(t-i,e-n),this.setTopRight(t+i,e-n),this.setBottomLeft(t-i,e+n),this.setBottomRight(t+i,e+n),this},resetAlpha:function(){var t=this.alphas;return t[0]=1,t[1]=1,t[2]=1,t[3]=1,t[4]=1,t[5]=1,this},resetColors:function(){var t=this.colors;return t[0]=16777215,t[1]=16777215,t[2]=16777215,t[3]=16777215,t[4]=16777215,t[5]=16777215,this},reset:function(){return this.resetPosition(),this.resetAlpha(),this.resetColors()}});t.exports=r},function(t,e){t.exports=function(t,e,i,n){void 0===i&&(i=!1),void 0===n&&(n=[]);for(var s,r,o,a,h,u,l=t.x3-t.x1,c=t.y3-t.y1,d=t.x2-t.x1,f=t.y2-t.y1,p=l*l+c*c,g=l*d+c*f,v=d*d+f*f,y=p*v-g*g,m=0===y?0:1/y,x=t.x1,w=t.y1,b=0;b=0&&r>=0&&s+r<1&&(n.push({x:e[b].x,y:e[b].y}),i)));b++);return n}},function(t,e){t.exports=function(t,e,i,n){var s=Math.cos(n),r=Math.sin(n),o=t.x1-e,a=t.y1-i;return t.x1=o*s-a*r+e,t.y1=o*r+a*s+i,o=t.x2-e,a=t.y2-i,t.x2=o*s-a*r+e,t.y2=o*r+a*s+i,t}},function(t,e){t.exports=function(t,e,i){for(var n=!1,s=-1,r=t.points.length-1;++s0&&(n.totalDuration+=n.t2*n.repeat),n.totalDuration>t&&(t=n.totalDuration)}this.duration=t,this.loopCounter=-1===this.loop?999999999999:this.loop,this.loopCounter>0?this.totalDuration=this.duration+this.completeDelay+(this.duration+this.loopDelay)*this.loopCounter:this.totalDuration=this.duration+this.completeDelay},init:function(){for(var t=this.data,e=this.totalTargets,i=0;i0){this.elapsed=0,this.progress=0,this.loopCounter--;var t=this.callbacks.onLoop;t&&(t.params[1]=this.targets,t.func.apply(t.scope,t.params)),this.resetTweenData(!0),this.loopDelay>0?(this.countdown=this.loopDelay,this.state=o.LOOP_DELAY):this.state=o.ACTIVE}else if(this.completeDelay>0)this.countdown=this.completeDelay,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.PENDING_REMOVE}},pause:function(){if(this.state!==o.PAUSED)return this.paused=!0,this._pausedState=this.state,this.state=o.PAUSED,this},play:function(t){if(this.state!==o.ACTIVE){this.state!==o.PENDING_REMOVE&&this.state!==o.REMOVED||(this.init(),this.parent.makeActive(this),t=!0);var e=this.callbacks.onStart;this.parentIsTimeline?(this.resetTweenData(t),0===this.calculatedOffset?(e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.ACTIVE):(this.countdown=this.calculatedOffset,this.state=o.OFFSET_DELAY)):this.paused?(this.paused=!1,this.parent.makeActive(this)):(this.resetTweenData(t),this.state=o.ACTIVE,e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)))}},resetTweenData:function(t){for(var e=this.data,i=0;i0?(n.elapsed=n.delay,n.state=o.DELAY):n.state=o.PENDING_RENDER}},resume:function(){return this.state===o.PAUSED&&(this.paused=!1,this.state=this._pausedState),this},seek:function(t){for(var e=this.data,i=0;i=s.totalDuration?(r=1,o=s.duration):n>s.delay&&n<=s.t1?(r=(n=Math.max(0,n-s.delay))/s.t1,o=s.duration*r):n>s.t1&&ns.repeatDelay&&(r=n/s.t1,o=s.duration*r)),s.progress=r,s.elapsed=o;var a=s.ease(s.progress);s.current=s.start+(s.end-s.start)*a,s.target[s.key]=s.current}},setCallback:function(t,e,i,n){return this.callbacks[t]={func:e,scope:n,params:i},this},complete:function(t){if(void 0===t&&(t=0),t)this.countdown=t,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.PENDING_REMOVE}},stop:function(t){void 0!==t&&this.seek(t),this.state=o.PENDING_REMOVE},update:function(t,e){if(this.state===o.PAUSED)return!1;switch(this.useFrames&&(e=1*this.parent.timeScale),e*=this.timeScale,this.elapsed+=e,this.progress=Math.min(this.elapsed/this.duration,1),this.totalElapsed+=e,this.totalProgress=Math.min(this.totalElapsed/this.totalDuration,1),this.state){case o.ACTIVE:for(var i=!1,n=0;n0){e.repeatCounter--,e.elapsed=i,e.progress=i/e.duration,e.flipX&&e.target.toggleFlipX(),e.flipY&&e.target.toggleFlipY();var s=t.callbacks.onRepeat;return s&&(s.params[1]=e.target,s.func.apply(s.scope,s.params)),e.start=e.getStartValue(e.target,e.key,e.start),e.end=e.getEndValue(e.target,e.key,e.start),e.repeatDelay>0?(e.elapsed=e.repeatDelay-i,e.current=e.start,e.target[e.key]=e.current,o.REPEAT_DELAY):o.PLAYING_FORWARD}return o.COMPLETE},setStateFromStart:function(t,e,i){if(e.repeatCounter>0){e.repeatCounter--,e.elapsed=i,e.progress=i/e.duration,e.flipX&&e.target.toggleFlipX(),e.flipY&&e.target.toggleFlipY();var n=t.callbacks.onRepeat;return n&&(n.params[1]=e.target,n.func.apply(n.scope,n.params)),e.end=e.getEndValue(e.target,e.key,e.start),e.repeatDelay>0?(e.elapsed=e.repeatDelay-i,e.current=e.start,e.target[e.key]=e.current,o.REPEAT_DELAY):o.PLAYING_FORWARD}return o.COMPLETE},updateTweenData:function(t,e,i){switch(e.state){case o.PLAYING_FORWARD:case o.PLAYING_BACKWARD:if(!e.target){e.state=o.COMPLETE;break}var n=e.elapsed,s=e.duration,r=0;(n+=i)>s&&(r=n-s,n=s);var a,h=e.state===o.PLAYING_FORWARD,u=n/s;a=h?e.ease(u):e.ease(1-u),e.current=e.start+(e.end-e.start)*a,e.target[e.key]=e.current,e.elapsed=n,e.progress=u;var l=t.callbacks.onUpdate;l&&(l.params[1]=e.target,l.func.apply(l.scope,l.params)),1===u&&(h?e.hold>0?(e.elapsed=e.hold-r,e.state=o.HOLD_DELAY):e.state=this.setStateFromEnd(t,e,r):e.state=this.setStateFromStart(t,e,r));break;case o.DELAY:e.elapsed-=i,e.elapsed<=0&&(e.elapsed=Math.abs(e.elapsed),e.state=o.PENDING_RENDER);break;case o.REPEAT_DELAY:e.elapsed-=i,e.elapsed<=0&&(e.elapsed=Math.abs(e.elapsed),e.state=o.PLAYING_FORWARD);break;case o.HOLD_DELAY:e.elapsed-=i,e.elapsed<=0&&(e.state=this.setStateFromEnd(t,e,Math.abs(e.elapsed)));break;case o.PENDING_RENDER:e.target?(e.start=e.getStartValue(e.target,e.key,e.target[e.key]),e.end=e.getEndValue(e.target,e.key,e.start),e.current=e.start,e.target[e.key]=e.start,e.state=o.PLAYING_FORWARD):e.state=o.COMPLETE}return e.state!==o.COMPLETE}});a.TYPES=["onComplete","onLoop","onRepeat","onStart","onUpdate","onYoyo"],r.register("tween",function(t){return this.scene.sys.tweens.add(t)}),s.register("tween",function(t){return this.scene.sys.tweens.create(t)}),t.exports=a},function(t,e){t.exports=function(t,e,i,n,s,r,o,a,h,u,l,c,d){return{target:t,key:e,getEndValue:i,getStartValue:n,ease:s,duration:0,totalDuration:0,delay:0,yoyo:a,hold:0,repeat:0,repeatDelay:0,flipX:c,flipY:d,progress:0,elapsed:0,repeatCounter:0,start:0,current:0,end:0,t1:0,t2:0,gen:{delay:r,duration:o,hold:h,repeat:u,repeatDelay:l},state:0}}},function(t,e,i){var n=i(50);t.exports=function(t){return n(t,-Math.PI,Math.PI)}},function(t,e,i){var n=i(50);t.exports=function(t){return n(t,-180,180)}},function(t,e,i){var n=i(0),s=i(515),r=i(166),o=new n({Extends:r,initialize:function(t){t.fragShader=s.replace("%LIGHT_COUNT%",10..toString()),r.call(this,t)},onBind:function(){r.prototype.onBind.call(this);var t=this.renderer,e=this.program;return this.mvpUpdate(),t.setInt1(e,"uNormSampler",1),t.setFloat2(e,"uResolution",this.width,this.height),this},onRender:function(t,e){var i=t.sys.lights;if(!i)return this;if(i.culledLights.length=0,i.lights.length<=0||!i.active)return this;var n,s=this.renderer,r=this.program,o=i.cull(e),a=Math.min(o.length,10),h=e.matrix,u={x:0,y:0},l=s.height;for(n=0;n<10;++n)s.setFloat1(r,"uLights["+n+"].radius",0);if(a<=0)return this;for(s.setFloat4(r,"uCamera",e.x,e.y,e.rotation,e.zoom),s.setFloat3(r,"uAmbientLightColor",i.ambientColor.r,i.ambientColor.g,i.ambientColor.b),n=0;n0?(n.textures[e-1]&&n.textures[e-1]!==t&&this.pushBatch(),i[i.length-1].textures[e-1]=t):(null!==n.texture&&n.texture!==t&&this.pushBatch(),i[i.length-1].texture=t),this},pushBatch:function(){var t={first:this.vertexCount,texture:null,textures:[]};this.batches.push(t)},flush:function(){if(this.flushLocked)return this;this.flushLocked=!0;var t,e,i,n=this.gl,s=this.renderer,r=this.vertexCount,o=this.topology,a=this.vertexSize,h=this.batches,u=0,l=null;if(0===h.length||0===r)return this.flushLocked=!1,this;n.bufferSubData(n.ARRAY_BUFFER,0,this.bytes.subarray(0,r*a));for(var c=0;c0){for(e=0;e0){for(e=0;e0&&(s.setTexture2D(l.texture,0),n.drawArrays(o,l.first,u)),this.vertexCount=0,h.length=0,this.pushBatch(),this.flushLocked=!1,this},onBind:function(){return h.prototype.onBind.call(this),this.mvpUpdate(),0===this.batches.length&&this.pushBatch(),this},resize:function(t,e,i){return h.prototype.resize.call(this,t,e,i),this.projOrtho(0,this.width,this.height,0,-1e3,1e3),this},drawStaticTilemapLayer:function(t){if(t.vertexCount>0){var e=this.vertexBuffer,i=this.gl,n=this.renderer,s=t.tileset.image.get();n.currentPipeline&&n.currentPipeline.vertexCount>0&&n.flush(),this.vertexBuffer=t.vertexBuffer,n.setPipeline(this),n.setTexture2D(s.source.glTexture,0),i.drawArrays(this.topology,0,t.vertexCount),this.vertexBuffer=e}this.viewIdentity(),this.modelIdentity()},drawEmitterManager:function(t,e){this.renderer.setPipeline(this);var i=this.renderer.config.roundPixels,n=t.emitters.list,s=n.length,r=this.vertexViewF32,o=this.vertexViewU32,a=this.renderer,h=this.maxQuads,u=e.scrollX,l=e.scrollY,c=e.matrix.matrix,d=c[0],f=c[1],p=c[2],g=c[3],v=c[4],y=c[5],m=Math.sin,x=Math.cos,w=this.vertexComponentCount,b=this.vertexCapacity,T=t.defaultFrame.source.glTexture;this.setTexture2D(T,0);for(var A=0;A=b&&(this.flush(),this.setTexture2D(T,0));for(var F=0;F=b&&(this.flush(),this.setTexture2D(T,0))}}}this.setTexture2D(T,0)},drawBlitter:function(t,e){this.renderer.setPipeline(this);for(var i=this.renderer.config.roundPixels,n=a.getTintAppendFloatAlpha,s=this.vertexViewF32,r=this.vertexViewU32,o=t.getRenderList(),h=o.length,u=e.matrix.matrix,l=u[0],c=u[1],d=u[2],f=u[3],p=u[4],g=u[5],v=e.scrollX*t.scrollFactorX,y=e.scrollY*t.scrollFactorY,m=Math.ceil(h/this.maxQuads),x=0,w=t.x-v,b=t.y-y,T=0;T=this.vertexCapacity&&this.flush()}x+=A,h-=A,this.vertexCount>=this.vertexCapacity&&this.flush()}},batchSprite:function(t,e){this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var i,n=this.renderer.config.roundPixels,s=a.getTintAppendFloatAlpha,r=this.vertexViewF32,o=this.vertexViewU32,h=e.matrix.matrix,u=t.frame,l=u.texture.source[u.sourceIndex].glTexture,c=!!l.isRenderTexture,d=t.flipX,f=t.flipY^c,p=u.uvs,g=u.width*(d?-1:1),v=u.height*(f?-1:1),y=-t.displayOriginX+u.x+u.width*(d?1:0),m=-t.displayOriginY+u.y+u.height*(f?1:0),x=(n?0|y:y)+g,w=(n?0|m:m)+v,b=t.x-e.scrollX*t.scrollFactorX,T=t.y-e.scrollY*t.scrollFactorY,A=t.scaleX,S=t.scaleY,C=-t.rotation,M=t._alphaTL,E=t._alphaTR,_=t._alphaBL,L=t._alphaBR,P=t._tintTL,F=t._tintTR,k=t._tintBL,O=t._tintBR,R=Math.sin(C),D=Math.cos(C),I=D*A,B=-R*A,Y=R*S,X=D*S,z=b,N=T,G=h[0],W=h[1],U=h[2],V=h[3],H=I*G+B*U,j=I*W+B*V,q=Y*G+X*U,K=Y*W+X*V,J=z*G+N*U+h[4],Z=z*W+N*V+h[5],Q=y*H+m*q+J,$=y*j+m*K+Z,tt=y*H+w*q+J,et=y*j+w*K+Z,it=x*H+w*q+J,nt=x*j+w*K+Z,st=x*H+m*q+J,rt=x*j+m*K+Z,ot=s(P,M),at=s(F,E),ht=s(k,_),ut=s(O,L);n&&(Q|=0,$|=0,tt|=0,et|=0,it|=0,nt|=0,st|=0,rt|=0),this.setTexture2D(l,0),r[(i=this.vertexCount*this.vertexComponentCount)+0]=Q,r[i+1]=$,r[i+2]=p.x0,r[i+3]=p.y0,o[i+4]=ot,r[i+5]=tt,r[i+6]=et,r[i+7]=p.x1,r[i+8]=p.y1,o[i+9]=ht,r[i+10]=it,r[i+11]=nt,r[i+12]=p.x2,r[i+13]=p.y2,o[i+14]=ut,r[i+15]=Q,r[i+16]=$,r[i+17]=p.x0,r[i+18]=p.y0,o[i+19]=ot,r[i+20]=it,r[i+21]=nt,r[i+22]=p.x2,r[i+23]=p.y2,o[i+24]=ut,r[i+25]=st,r[i+26]=rt,r[i+27]=p.x3,r[i+28]=p.y3,o[i+29]=at,this.vertexCount+=6},batchMesh:function(t,e){var i=t.vertices,n=i.length,s=n/2|0;this.renderer.setPipeline(this),this.vertexCount+s>this.vertexCapacity&&this.flush();var r=this.renderer.config.roundPixels,o=a.getTintAppendFloatAlpha,h=t.uv,u=t.colors,l=t.alphas,c=this.vertexViewF32,d=this.vertexViewU32,f=e.matrix.matrix,p=t.frame,g=t.texture.source[p.sourceIndex].glTexture,v=t.x-e.scrollX*t.scrollFactorX,y=t.y-e.scrollY*t.scrollFactorY,m=t.scaleX,x=t.scaleY,w=-t.rotation,b=Math.sin(w),T=Math.cos(w),A=T*m,S=-b*m,C=b*x,M=T*x,E=v,_=y,L=f[0],P=f[1],F=f[2],k=f[3],O=A*L+S*F,R=A*P+S*k,D=C*L+M*F,I=C*P+M*k,B=E*L+_*F+f[4],Y=E*P+_*k+f[5],X=0;this.setTexture2D(g,0),X=this.vertexCount*this.vertexComponentCount;for(var z=0,N=0;zthis.vertexCapacity&&this.flush();var i,n,s,r,o,h,u,l,c=this.renderer.config.roundPixels,d=t.text,f=d.length,p=a.getTintAppendFloatAlpha,g=this.vertexViewF32,v=this.vertexViewU32,y=e.matrix.matrix,m=e.width+50,x=e.height+50,w=t.frame,b=t.texture.source[w.sourceIndex],T=e.scrollX*t.scrollFactorX,A=e.scrollY*t.scrollFactorY,S=t.fontData,C=S.lineHeight,M=t.fontSize/S.size,E=S.chars,_=t.alpha,L=p(t._tintTL,_),P=p(t._tintTR,_),F=p(t._tintBL,_),k=p(t._tintBR,_),O=t.x,R=t.y,D=w.cutX,I=w.cutY,B=b.width,Y=b.height,X=b.glTexture,z=0,N=0,G=0,W=0,U=null,V=0,H=0,j=0,q=0,K=0,J=0,Z=0,Q=0,$=0,tt=0,et=0,it=0,nt=null,st=0,rt=O-T+w.x,ot=R-A+w.y,at=-t.rotation,ht=t.scaleX,ut=t.scaleY,lt=Math.sin(at),ct=Math.cos(at),dt=ct*ht,ft=-lt*ht,pt=lt*ut,gt=ct*ut,vt=rt,yt=ot,mt=y[0],xt=y[1],wt=y[2],bt=y[3],Tt=dt*mt+ft*wt,At=dt*xt+ft*bt,St=pt*mt+gt*wt,Ct=pt*xt+gt*bt,Mt=vt*mt+yt*wt+y[4],Et=vt*xt+yt*bt+y[5],_t=0;this.setTexture2D(X,0);for(var Lt=0;Ltm||n<-50||n>x)&&(s<-50||s>m||r<-50||r>x)&&(o<-50||o>m||h<-50||h>x)&&(u<-50||u>m||l<-50||l>x)||(this.vertexCount+6>this.vertexCapacity&&this.flush(),c&&(i|=0,n|=0,s|=0,r|=0,o|=0,h|=0,u|=0,l|=0),g[(_t=this.vertexCount*this.vertexComponentCount)+0]=i,g[_t+1]=n,g[_t+2]=$,g[_t+3]=et,v[_t+4]=L,g[_t+5]=s,g[_t+6]=r,g[_t+7]=$,g[_t+8]=it,v[_t+9]=F,g[_t+10]=o,g[_t+11]=h,g[_t+12]=tt,g[_t+13]=it,v[_t+14]=k,g[_t+15]=i,g[_t+16]=n,g[_t+17]=$,g[_t+18]=et,v[_t+19]=L,g[_t+20]=o,g[_t+21]=h,g[_t+22]=tt,g[_t+23]=it,v[_t+24]=k,g[_t+25]=u,g[_t+26]=l,g[_t+27]=tt,g[_t+28]=et,v[_t+29]=P,this.vertexCount+=6))}}else z=0,G=0,N+=C,nt=null},batchDynamicBitmapText:function(t,e){this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var i,n,s,r,o,h,u,l,c,d,f,p,g,v,y=this.renderer.config.roundPixels,m=t.displayCallback,x=t.text,w=x.length,b=a.getTintAppendFloatAlpha,T=this.vertexViewF32,A=this.vertexViewU32,S=this.renderer,C=e.matrix.matrix,M=t.frame,E=t.texture.source[M.sourceIndex],_=e.scrollX*t.scrollFactorX,L=e.scrollY*t.scrollFactorY,P=t.scrollX,F=t.scrollY,k=t.fontData,O=k.lineHeight,R=t.fontSize/k.size,D=k.chars,I=t.alpha,B=b(t._tintTL,I),Y=b(t._tintTR,I),X=b(t._tintBL,I),z=b(t._tintBR,I),N=t.x,G=t.y,W=M.cutX,U=M.cutY,V=E.width,H=E.height,j=E.glTexture,q=0,K=0,J=0,Z=0,Q=null,$=0,tt=0,et=0,it=0,nt=0,st=0,rt=0,ot=0,at=0,ht=0,ut=0,lt=0,ct=null,dt=0,ft=N+M.x,pt=G+M.y,gt=-t.rotation,vt=t.scaleX,yt=t.scaleY,mt=Math.sin(gt),xt=Math.cos(gt),wt=xt*vt,bt=-mt*vt,Tt=mt*yt,At=xt*yt,St=ft,Ct=pt,Mt=C[0],Et=C[1],_t=C[2],Lt=C[3],Pt=wt*Mt+bt*_t,Ft=wt*Et+bt*Lt,kt=Tt*Mt+At*_t,Ot=Tt*Et+At*Lt,Rt=St*Mt+Ct*_t+C[4],Dt=St*Et+Ct*Lt+C[5],It=t.cropWidth>0||t.cropHeight>0,Bt=0;this.setTexture2D(j,0),It&&S.pushScissor(t.x,t.y,t.cropWidth*t.scaleX,t.cropHeight*t.scaleY);for(var Yt=0;Ytthis.vertexCapacity&&this.flush(),y&&(i|=0,n|=0,s|=0,r|=0,o|=0,h|=0,u|=0,l|=0),T[(Bt=this.vertexCount*this.vertexComponentCount)+0]=i,T[Bt+1]=n,T[Bt+2]=at,T[Bt+3]=ut,A[Bt+4]=B,T[Bt+5]=s,T[Bt+6]=r,T[Bt+7]=at,T[Bt+8]=lt,A[Bt+9]=X,T[Bt+10]=o,T[Bt+11]=h,T[Bt+12]=ht,T[Bt+13]=lt,A[Bt+14]=z,T[Bt+15]=i,T[Bt+16]=n,T[Bt+17]=at,T[Bt+18]=ut,A[Bt+19]=B,T[Bt+20]=o,T[Bt+21]=h,T[Bt+22]=ht,T[Bt+23]=lt,A[Bt+24]=z,T[Bt+25]=u,T[Bt+26]=l,T[Bt+27]=ht,T[Bt+28]=ut,A[Bt+29]=Y,this.vertexCount+=6}}}else q=0,J=0,K+=O,ct=null;It&&S.popScissor()},batchText:function(t,e){var i=a.getTintAppendFloatAlpha;this.batchTexture(t,t.canvasTexture,t.canvasTexture.width,t.canvasTexture.height,t.x,t.y,t.canvasTexture.width,t.canvasTexture.height,t.scaleX,t.scaleY,t.rotation,t.flipX,t.flipY,t.scrollFactorX,t.scrollFactorY,t.displayOriginX,t.displayOriginY,0,0,t.canvasTexture.width,t.canvasTexture.height,i(t._tintTL,t._alphaTL),i(t._tintTR,t._alphaTR),i(t._tintBL,t._alphaBL),i(t._tintBR,t._alphaBR),0,0,e)},batchDynamicTilemapLayer:function(t,e){for(var i=t.culledTiles,n=i.length,s=t.tileset.image.get().source.glTexture,r=t.tileset,o=t.scrollFactorX,h=t.scrollFactorY,u=t.alpha,l=t.x,c=t.y,d=t.scaleX,f=t.scaleY,p=a.getTintAppendFloatAlpha,g=0;gthis.vertexCapacity&&this.flush(),d^=e.isRenderTexture?1:0,l=-l;var _,L=this.renderer.config.roundPixels,P=this.vertexViewF32,F=this.vertexViewU32,k=E.matrix.matrix,O=o*(c?1:0)-g,R=a*(d?1:0)-v,D=O+o*(c?-1:1),I=R+a*(d?-1:1),B=s-E.scrollX*f,Y=r-E.scrollY*p,X=Math.sin(l),z=Math.cos(l),N=z*h,G=-X*h,W=X*u,U=z*u,V=B,H=Y,j=k[0],q=k[1],K=k[2],J=k[3],Z=N*j+G*K,Q=N*q+G*J,$=W*j+U*K,tt=W*q+U*J,et=V*j+H*K+k[4],it=V*q+H*J+k[5],nt=O*Z+R*$+et,st=O*Q+R*tt+it,rt=O*Z+I*$+et,ot=O*Q+I*tt+it,at=D*Z+I*$+et,ht=D*Q+I*tt+it,ut=D*Z+R*$+et,lt=D*Q+R*tt+it,ct=y/i+C,dt=m/n+M,ft=(y+x)/i+C,pt=(m+w)/n+M;this.setTexture2D(e,0),L&&(nt|=0,st|=0,rt|=0,ot|=0,at|=0,ht|=0,ut|=0,lt|=0),P[(_=this.vertexCount*this.vertexComponentCount)+0]=nt,P[_+1]=st,P[_+2]=ct,P[_+3]=dt,F[_+4]=b,P[_+5]=rt,P[_+6]=ot,P[_+7]=ct,P[_+8]=pt,F[_+9]=T,P[_+10]=at,P[_+11]=ht,P[_+12]=ft,P[_+13]=pt,F[_+14]=A,P[_+15]=nt,P[_+16]=st,P[_+17]=ct,P[_+18]=dt,F[_+19]=b,P[_+20]=at,P[_+21]=ht,P[_+22]=ft,P[_+23]=pt,F[_+24]=A,P[_+25]=ut,P[_+26]=lt,P[_+27]=ft,P[_+28]=dt,F[_+29]=S,this.vertexCount+=6},drawTexture:function(t,e,i,n,s,r,o,h,u,l){this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var c,d=this.renderer.config.roundPixels,f=this.vertexViewF32,p=this.vertexViewU32,g=e,v=i,y=g+h,m=v+u,x=l[0],w=l[1],b=l[2],T=l[3],A=l[4],S=l[5],C=g*x+v*b+A,M=g*w+v*T+S,E=g*x+m*b+A,_=g*w+m*T+S,L=y*x+m*b+A,P=y*w+m*T+S,F=y*x+v*b+A,k=y*w+v*T+S,O=t.width,R=t.height,D=r/O,I=o/R,B=(r+h)/O,Y=(o+u)/R;n=a.getTintAppendFloatAlpha(n,s),this.setTexture2D(t,0),d&&(C|=0,M|=0,E|=0,_|=0,L|=0,P|=0,F|=0,k|=0),f[(c=this.vertexCount*this.vertexComponentCount)+0]=C,f[c+1]=M,f[c+2]=D,f[c+3]=I,p[c+4]=n,f[c+5]=E,f[c+6]=_,f[c+7]=D,f[c+8]=Y,p[c+9]=n,f[c+10]=L,f[c+11]=P,f[c+12]=B,f[c+13]=Y,p[c+14]=n,f[c+15]=C,f[c+16]=M,f[c+17]=D,f[c+18]=I,p[c+19]=n,f[c+20]=L,f[c+21]=P,f[c+22]=B,f[c+23]=Y,p[c+24]=n,f[c+25]=F,f[c+26]=k,f[c+27]=B,f[c+28]=I,p[c+29]=n,this.vertexCount+=6,this.flush()},batchGraphics:function(){}});t.exports=u},,,function(t,e){var i;i=function(){return this}();try{i=i||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e){t.exports=function(t){if("object"!=typeof t||t.nodeType||t===t.window)return!1;try{if(t.constructor&&!{}.hasOwnProperty.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}return!0}},function(t,e,i){t.exports={Angle:i(386),Call:i(387),GetFirst:i(388),GridAlign:i(389),IncAlpha:i(407),IncX:i(408),IncXY:i(409),IncY:i(410),PlaceOnCircle:i(411),PlaceOnEllipse:i(412),PlaceOnLine:i(413),PlaceOnRectangle:i(414),PlaceOnTriangle:i(415),PlayAnimation:i(416),RandomCircle:i(417),RandomEllipse:i(418),RandomLine:i(419),RandomRectangle:i(420),RandomTriangle:i(421),Rotate:i(422),RotateAround:i(423),RotateAroundDistance:i(424),ScaleX:i(425),ScaleXY:i(426),ScaleY:i(427),SetAlpha:i(428),SetBlendMode:i(429),SetDepth:i(430),SetHitArea:i(431),SetOrigin:i(432),SetRotation:i(433),SetScale:i(434),SetScaleX:i(435),SetScaleY:i(436),SetTint:i(437),SetVisible:i(438),SetX:i(439),SetXY:i(440),SetY:i(441),ShiftPosition:i(442),Shuffle:i(443),SmootherStep:i(444),SmoothStep:i(445),Spread:i(446),ToggleVisible:i(447)}},function(t,e,i){var n=i(173),s=[];s[n.BOTTOM_CENTER]=i(174),s[n.BOTTOM_LEFT]=i(175),s[n.BOTTOM_RIGHT]=i(176),s[n.CENTER]=i(177),s[n.LEFT_CENTER]=i(179),s[n.RIGHT_CENTER]=i(180),s[n.TOP_CENTER]=i(181),s[n.TOP_LEFT]=i(182),s[n.TOP_RIGHT]=i(183);t.exports=function(t,e,i,n,r){return s[i](t,e,n,r)}},function(t,e){t.exports={TOP_LEFT:0,TOP_CENTER:1,TOP_RIGHT:2,LEFT_TOP:3,LEFT_CENTER:4,LEFT_BOTTOM:5,CENTER:6,RIGHT_TOP:7,RIGHT_CENTER:8,RIGHT_BOTTOM:9,BOTTOM_LEFT:10,BOTTOM_CENTER:11,BOTTOM_RIGHT:12}},function(t,e,i){var n=i(24),s=i(46),r=i(25),o=i(47);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(24),s=i(26),r=i(25),o=i(27);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(24),s=i(28),r=i(25),o=i(29);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(178),s=i(46),r=i(49);t.exports=function(t,e,i,o){return void 0===i&&(i=0),void 0===o&&(o=0),n(t,s(e)+i,r(e)+o),t}},function(t,e,i){var n=i(47),s=i(48);t.exports=function(t,e,i){return n(t,e),s(t,i)}},function(t,e,i){var n=i(49),s=i(26),r=i(48),o=i(27);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(49),s=i(28),r=i(48),o=i(29);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(46),s=i(30),r=i(47),o=i(31);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)-a),t}},function(t,e,i){var n=i(26),s=i(30),r=i(27),o=i(31);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)-i),o(t,s(e)-a),t}},function(t,e,i){var n=i(28),s=i(30),r=i(29),o=i(31);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)-a),t}},function(t,e,i){var n=i(105),s=i(65),r=i(16),o=i(5);t.exports=function(t,e,i){void 0===i&&(i=new o);var a=s(e,0,r.PI2);return n(t,a,i)}},function(t,e,i){var n=i(186),s=i(105),r=i(65),o=i(16);t.exports=function(t,e,i,a){void 0===a&&(a=[]),e||(e=n(t)/i);for(var h=0;h=t.right&&(h=1,a+=o-t.right,o=t.right);break;case 1:(a+=e)>=t.bottom&&(h=2,o-=a-t.bottom,a=t.bottom);break;case 2:(o-=e)<=t.left&&(h=3,a-=t.left-o,o=t.left);break;case 3:(a-=e)<=t.top&&(h=0,a=t.top)}return r}},function(t,e){t.exports=function(t,e){void 0===e&&(e=1);for(var i=null,n=0;n-h&&(c-=h,n+=u),f0){if(0===t)this.frames=i.concat(this.frames);else if(t===this.frames.length)this.frames=this.frames.concat(i);else{var n=this.frames.slice(0,t),s=this.frames.slice(t);this.frames=n.concat(i,s)}this.updateFrameSequence()}return this},checkFrame:function(t){return t0){o.isLast=!0,o.nextFrame=u[0],u[0].prevFrame=o;var v=1/(u.length-1);for(a=0;a=this.frames.length&&(e=0),t.currentAnim!==this&&(t.currentAnim=this,t._timeScale=1,t.frameRate=this.frameRate,t.duration=this.duration,t.msPerFrame=this.msPerFrame,t.skipMissedFrames=this.skipMissedFrames,t._delay=this.delay,t._repeat=this.repeat,t._repeatDelay=this.repeatDelay,t._yoyo=this.yoyo,t._callbackArgs[1]=this,t._updateParams=t._callbackArgs.concat(this.onUpdateParams)),t.updateFrame(this.frames[e])},nextFrame:function(t){var e=t.currentFrame;e.isLast?this.yoyo?(t.forward=!1,t.updateFrame(e.prevFrame),this.getNextTick(t)):t.repeatCounter>0?this.repeatAnimation(t):this.completeAnimation(t):(t.updateFrame(e.nextFrame),this.getNextTick(t))},previousFrame:function(t){var e=t.currentFrame;e.isFirst?t.repeatCounter>0?this.repeatAnimation(t):this.completeAnimation(t):(t.updateFrame(e.prevFrame),this.getNextTick(t))},removeFrame:function(t){var e=this.frames.indexOf(t);return-1!==e&&this.removeFrameAt(e),this},removeFrameAt:function(t){return this.frames.splice(t,1),this.updateFrameSequence(),this},repeatAnimation:function(t){t._repeatDelay>0&&!1===t.pendingRepeat?(t.pendingRepeat=!0,t.accumulator-=t.nextTick,t.nextTick+=1e3*t._repeatDelay):(t.repeatCounter--,t.forward=!0,t.updateFrame(t.currentFrame.nextFrame),this.getNextTick(t),t.pendingRepeat=!1,this.onRepeat&&this.onRepeat.apply(this.callbackScope,t._callbackArgs.concat(this.onRepeatParams)))},setFrame:function(t){t.forward?this.nextFrame(t):this.previousFrame(t)},toJSON:function(){var t={key:this.key,type:this.type,frames:[],frameRate:this.frameRate,duration:this.duration,skipMissedFrames:this.skipMissedFrames,delay:this.delay,repeat:this.repeat,repeatDelay:this.repeatDelay,yoyo:this.yoyo,showOnStart:this.showOnStart,hideOnComplete:this.hideOnComplete};return this.frames.forEach(function(e){t.frames.push(e.toJSON())}),t},updateFrameSequence:function(){for(var t=this.frames.length,e=1/(t-1),i=0;i1&&(n.prevFrame=this.frames[i-1],n.nextFrame=this.frames[i+1])}return this},pause:function(){return this.paused=!0,this},resume:function(){return this.paused=!1,this},destroy:function(){}});t.exports=o},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n){this.textureKey=t,this.textureFrame=e,this.index=i,this.frame=n,this.isFirst=!1,this.isLast=!1,this.prevFrame=null,this.nextFrame=null,this.duration=0,this.progress=0,this.onUpdate=null},toJSON:function(){return{key:this.textureKey,frame:this.textureFrame,duration:this.duration}},destroy:function(){this.frame=void 0,this.onUpdate=void 0}});t.exports=n},function(t,e,i){var n=i(197),s=i(0),r=i(114),o=i(14),a=i(4),h=i(200),u=new s({Extends:o,initialize:function(t){o.call(this),this.game=t,this.textureManager=null,this.globalTimeScale=1,this.anims=new r,this.paused=!1,this.name="AnimationManager",t.events.once("boot",this.boot,this)},boot:function(){this.textureManager=this.game.textures,this.game.events.once("destroy",this.destroy,this)},add:function(t,e){if(!this.anims.has(t))return e.key=t,this.anims.set(t,e),this.emit("add",t,e),this;console.warn("Animation with key",t,"already exists")},create:function(t){var e=t.key;if(e&&!this.anims.has(e)){var i=new n(this,e,t);return this.anims.set(e,i),this.emit("add",e,i),i}console.warn("Invalid Animation Key, or Key already in use: "+e)},fromJSON:function(t,e){void 0===e&&(e=!1),e&&this.anims.clear(),"string"==typeof t&&(t=JSON.parse(t));var i=[];if(t.hasOwnProperty("anims")&&Array.isArray(t.anims)){for(var n=0;n=(t=t.toString()).length)switch(n){case 1:t=new Array(e+1-t.length).join(i)+t;break;case 3:var r=Math.ceil((s=e-t.length)/2);t=new Array(s-r+1).join(i)+t+new Array(r+1).join(i);break;default:t+=new Array(e+1-t.length).join(i)}return t}},function(t,e,i){var n=i(0),s=i(114),r=i(14),o=new n({initialize:function(){this.entries=new s,this.events=new r},add:function(t,e){return this.entries.set(t,e),this.events.emit("add",this,t,e),this},has:function(t){return this.entries.has(t)},get:function(t){return this.entries.get(t)},remove:function(t){var e=this.get(t);return e&&(this.entries.delete(t),this.events.emit("remove",this,t,e.data)),this},destroy:function(){this.entries.clear(),this.events.removeAllListeners(),this.entries=null,this.events=null}});t.exports=o},function(t,e,i){var n=i(201),s=new(i(0))({initialize:function(t){this.game=t,this.binary=new n,this.bitmapFont=new n,this.json=new n,this.physics=new n,this.shader=new n,this.audio=new n,this.text=new n,this.obj=new n,this.tilemap=new n,this.xml=new n,this.custom={},this.game.events.once("destroy",this.destroy,this)},addCustom:function(t){return this.custom.hasOwnProperty(t)||(this.custom[t]=new n),this.custom[t]},destroy:function(){for(var t=["binary","bitmapFont","json","physics","shader","audio","text","obj","tilemap","xml"],e=0;e16777215?{a:t>>>24,r:t>>16&255,g:t>>8&255,b:255&t}:{a:255,r:t>>16&255,g:t>>8&255,b:255&t}}},function(t,e,i){var n=i(36);t.exports=function(t){return new n(t.r,t.g,t.b,t.a)}},function(t,e,i){var n=i(36);t.exports=function(t){var e=new n,i=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(t.toLowerCase());if(i){var s=parseInt(i[1],10),r=parseInt(i[2],10),o=parseInt(i[3],10),a=void 0!==i[4]?parseFloat(i[4]):1;e.setTo(s,r,o,255*a)}return e}},function(t,e){t.exports=function(t,e){void 0===e&&(e=1);var i=2*Math.random()*Math.PI,n=2*Math.random()-1,s=Math.sqrt(1-n*n)*e;return t.x=Math.cos(i)*s,t.y=Math.sin(i)*s,t.z=n*e,t}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1),t.x=(2*Math.random()-1)*e,t.y=(2*Math.random()-1)*e,t.z=(2*Math.random()-1)*e,t.w=(2*Math.random()-1)*e,t}},function(t,e,i){var n=i(51),s=i(119),r=i(212),o=new s,a=new r,h=new n;t.exports=function(t,e,i){return a.setAxisAngle(e,i),o.fromRotationTranslation(a,h.set(0,0,0)),t.transformMat4(o)}},function(t,e,i){var n=i(0),s=i(51),r=i(213),o=new Int8Array([1,2,0]),a=new Float32Array([0,0,0]),h=new s(1,0,0),u=new s(0,1,0),l=new s,c=new r,d=new n({initialize:function(t,e,i,n){"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this.w=t.w||0):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=n||0)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},set:function(t,e,i,n){return"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this.w=t.w||0):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=n||0),this},add:function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this},subtract:function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this},scale:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},length:function(){var t=this.x,e=this.y,i=this.z,n=this.w;return Math.sqrt(t*t+e*e+i*i+n*n)},lengthSq:function(){var t=this.x,e=this.y,i=this.z,n=this.w;return t*t+e*e+i*i+n*n},normalize:function(){var t=this.x,e=this.y,i=this.z,n=this.w,s=t*t+e*e+i*i+n*n;return s>0&&(s=1/Math.sqrt(s),this.x=t*s,this.y=e*s,this.z=i*s,this.w=n*s),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z,r=this.w;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this.w=r+e*(t.w-r),this},rotationTo:function(t,e){var i=t.x*e.x+t.y*e.y+t.z*e.z;return i<-.999999?(l.copy(h).cross(t).length()<1e-6&&l.copy(u).cross(t),l.normalize(),this.setAxisAngle(l,Math.PI)):i>.999999?(this.x=0,this.y=0,this.z=0,this.w=1,this):(l.copy(t).cross(e),this.x=l.x,this.y=l.y,this.z=l.z,this.w=1+i,this.normalize())},setAxes:function(t,e,i){var n=c.val;return n[0]=e.x,n[3]=e.y,n[6]=e.z,n[1]=i.x,n[4]=i.y,n[7]=i.z,n[2]=-t.x,n[5]=-t.y,n[8]=-t.z,this.fromMat3(c).normalize()},identity:function(){return this.x=0,this.y=0,this.z=0,this.w=1,this},setAxisAngle:function(t,e){e*=.5;var i=Math.sin(e);return this.x=i*t.x,this.y=i*t.y,this.z=i*t.z,this.w=Math.cos(e),this},multiply:function(t){var e=this.x,i=this.y,n=this.z,s=this.w,r=t.x,o=t.y,a=t.z,h=t.w;return this.x=e*h+s*r+i*a-n*o,this.y=i*h+s*o+n*r-e*a,this.z=n*h+s*a+e*o-i*r,this.w=s*h-e*r-i*o-n*a,this},slerp:function(t,e){var i=this.x,n=this.y,s=this.z,r=this.w,o=t.x,a=t.y,h=t.z,u=t.w,l=i*o+n*a+s*h+r*u;l<0&&(l=-l,o=-o,a=-a,h=-h,u=-u);var c=1-e,d=e;if(1-l>1e-6){var f=Math.acos(l),p=Math.sin(f);c=Math.sin((1-e)*f)/p,d=Math.sin(e*f)/p}return this.x=c*i+d*o,this.y=c*n+d*a,this.z=c*s+d*h,this.w=c*r+d*u,this},invert:function(){var t=this.x,e=this.y,i=this.z,n=this.w,s=t*t+e*e+i*i+n*n,r=s?1/s:0;return this.x=-t*r,this.y=-e*r,this.z=-i*r,this.w=n*r,this},conjugate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},rotateX:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o+s*r,this.y=i*o+n*r,this.z=n*o-i*r,this.w=s*o-e*r,this},rotateY:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o-n*r,this.y=i*o+s*r,this.z=n*o+e*r,this.w=s*o-i*r,this},rotateZ:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o+i*r,this.y=i*o-e*r,this.z=n*o+s*r,this.w=s*o-n*r,this},calculateW:function(){var t=this.x,e=this.y,i=this.z;return this.w=-Math.sqrt(Math.abs(1-t*t-e*e-i*i)),this},fromMat3:function(t){var e,i=t.val,n=i[0]+i[4]+i[8];if(n>0)e=Math.sqrt(n+1),this.w=.5*e,e=.5/e,this.x=(i[7]-i[5])*e,this.y=(i[2]-i[6])*e,this.z=(i[3]-i[1])*e;else{var s=0;i[4]>i[0]&&(s=1),i[8]>i[3*s+s]&&(s=2);var r=o[s],h=o[r];e=Math.sqrt(i[3*s+s]-i[3*r+r]-i[3*h+h]+1),a[s]=.5*e,e=.5/e,a[r]=(i[3*r+s]+i[3*s+r])*e,a[h]=(i[3*h+s]+i[3*s+h])*e,this.x=a[0],this.y=a[1],this.z=a[2],this.w=(i[3*h+r]-i[3*r+h])*e}return this}});t.exports=d},function(t,e,i){var n=new(i(0))({initialize:function(t){this.val=new Float32Array(9),t?this.copy(t):this.identity()},clone:function(){return new n(this)},set:function(t){return this.copy(t)},copy:function(t){var e=this.val,i=t.val;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this},fromMat4:function(t){var e=t.val,i=this.val;return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[4],i[4]=e[5],i[5]=e[6],i[6]=e[8],i[7]=e[9],i[8]=e[10],this},fromArray:function(t){var e=this.val;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],this},identity:function(){var t=this.val;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,this},transpose:function(){var t=this.val,e=t[1],i=t[2],n=t[5];return t[1]=t[3],t[2]=t[6],t[3]=e,t[5]=t[7],t[6]=i,t[7]=n,this},invert:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],u=t[8],l=u*r-o*h,c=-u*s+o*a,d=h*s-r*a,f=e*l+i*c+n*d;return f?(f=1/f,t[0]=l*f,t[1]=(-u*i+n*h)*f,t[2]=(o*i-n*r)*f,t[3]=c*f,t[4]=(u*e-n*a)*f,t[5]=(-o*e+n*s)*f,t[6]=d*f,t[7]=(-h*e+i*a)*f,t[8]=(r*e-i*s)*f,this):null},adjoint:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],u=t[8];return t[0]=r*u-o*h,t[1]=n*h-i*u,t[2]=i*o-n*r,t[3]=o*a-s*u,t[4]=e*u-n*a,t[5]=n*s-e*o,t[6]=s*h-r*a,t[7]=i*a-e*h,t[8]=e*r-i*s,this},determinant:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],u=t[8];return e*(u*r-o*h)+i*(-u*s+o*a)+n*(h*s-r*a)},multiply:function(t){var e=this.val,i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],h=e[6],u=e[7],l=e[8],c=t.val,d=c[0],f=c[1],p=c[2],g=c[3],v=c[4],y=c[5],m=c[6],x=c[7],w=c[8];return e[0]=d*i+f*r+p*h,e[1]=d*n+f*o+p*u,e[2]=d*s+f*a+p*l,e[3]=g*i+v*r+y*h,e[4]=g*n+v*o+y*u,e[5]=g*s+v*a+y*l,e[6]=m*i+x*r+w*h,e[7]=m*n+x*o+w*u,e[8]=m*s+x*a+w*l,this},translate:function(t){var e=this.val,i=t.x,n=t.y;return e[6]=i*e[0]+n*e[3]+e[6],e[7]=i*e[1]+n*e[4]+e[7],e[8]=i*e[2]+n*e[5]+e[8],this},rotate:function(t){var e=this.val,i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],h=Math.sin(t),u=Math.cos(t);return e[0]=u*i+h*r,e[1]=u*n+h*o,e[2]=u*s+h*a,e[3]=u*r-h*i,e[4]=u*o-h*n,e[5]=u*a-h*s,this},scale:function(t){var e=this.val,i=t.x,n=t.y;return e[0]=i*e[0],e[1]=i*e[1],e[2]=i*e[2],e[3]=n*e[3],e[4]=n*e[4],e[5]=n*e[5],this},fromQuat:function(t){var e=t.x,i=t.y,n=t.z,s=t.w,r=e+e,o=i+i,a=n+n,h=e*r,u=e*o,l=e*a,c=i*o,d=i*a,f=n*a,p=s*r,g=s*o,v=s*a,y=this.val;return y[0]=1-(c+f),y[3]=u+v,y[6]=l-g,y[1]=u-v,y[4]=1-(h+f),y[7]=d+p,y[2]=l+g,y[5]=d-p,y[8]=1-(h+c),this},normalFromMat4:function(t){var e=t.val,i=this.val,n=e[0],s=e[1],r=e[2],o=e[3],a=e[4],h=e[5],u=e[6],l=e[7],c=e[8],d=e[9],f=e[10],p=e[11],g=e[12],v=e[13],y=e[14],m=e[15],x=n*h-s*a,w=n*u-r*a,b=n*l-o*a,T=s*u-r*h,A=s*l-o*h,S=r*l-o*u,C=c*v-d*g,M=c*y-f*g,E=c*m-p*g,_=d*y-f*v,L=d*m-p*v,P=f*m-p*y,F=x*P-w*L+b*_+T*E-A*M+S*C;return F?(F=1/F,i[0]=(h*P-u*L+l*_)*F,i[1]=(u*E-a*P-l*M)*F,i[2]=(a*L-h*E+l*C)*F,i[3]=(r*L-s*P-o*_)*F,i[4]=(n*P-r*E+o*M)*F,i[5]=(s*E-n*L-o*C)*F,i[6]=(v*S-y*A+m*T)*F,i[7]=(y*b-g*S-m*w)*F,i[8]=(g*A-v*b+m*x)*F,this):null}});t.exports=n},function(t,e,i){var n=i(118),s=i(0),r=new(i(51)),o=new s({Extends:n,initialize:function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=0),n.call(this,t),this.viewportWidth=e,this.viewportHeight=i,this._zoom=1,this.near=0,this.update()},setToOrtho:function(t,e,i){void 0===e&&(e=this.viewportWidth),void 0===i&&(i=this.viewportHeight);var n=this.zoom;return this.up.set(0,t?-1:1,0),this.direction.set(0,0,t?1:-1),this.position.set(n*e/2,n*i/2,0),this.viewportWidth=e,this.viewportHeight=i,this.update()},update:function(){var t=this.viewportWidth,e=this.viewportHeight,i=Math.abs(this.near),n=Math.abs(this.far),s=this.zoom;return 0===t||0===e?this:(this.projection.ortho(s*-t/2,s*t/2,s*-e/2,s*e/2,i,n),r.copy(this.position).add(this.direction),this.view.lookAt(this.position,r,this.up),this.combined.copy(this.projection).multiply(this.view),this.invProjectionView.copy(this.combined).invert(),this.billboardMatrixDirty=!0,this.updateChildren(),this)},zoom:{get:function(){return this._zoom},set:function(t){this._zoom=t,this.update()}}});t.exports=o},function(t,e,i){var n=i(118),s=i(0),r=new(i(51)),o=new s({Extends:n,initialize:function(t,e,i,s){void 0===e&&(e=80),void 0===i&&(i=0),void 0===s&&(s=0),n.call(this,t),this.viewportWidth=i,this.viewportHeight=s,this.fieldOfView=e*Math.PI/180,this.update()},setFOV:function(t){return this.fieldOfView=t*Math.PI/180,this},update:function(){var t=this.viewportWidth/this.viewportHeight;return this.projection.perspective(this.fieldOfView,t,Math.abs(this.near),Math.abs(this.far)),r.copy(this.position).add(this.direction),this.view.lookAt(this.position,r,this.up),this.combined.copy(this.projection).multiply(this.view),this.invProjectionView.copy(this.combined).invert(),this.billboardMatrixDirty=!0,this.updateChildren(),this}});t.exports=o},function(t,e,i){var n=i(217),s=i(21),r=i(4);t.exports=function(t){var e=r(t,"data",[]),i=r(t,"canvas",null),o=r(t,"palette",n),a=r(t,"pixelWidth",1),h=r(t,"pixelHeight",a),u=r(t,"resizeCanvas",!0),l=r(t,"clearCanvas",!0),c=r(t,"preRender",null),d=r(t,"postRender",null),f=Math.floor(Math.abs(e[0].length*a)),p=Math.floor(Math.abs(e.length*h));i||(i=s.create2D(this,f,p),u=!1,l=!1),u&&(i.width=f,i.height=p);var g=i.getContext("2d");l&&g.clearRect(0,0,f,p),c&&c(i,g);for(var v=0;vi;)n-=i;ni.length-2?i.length-1:r+1],c=i[r>i.length-3?i.length-1:r+2];return e.set(n(a,h.x,u.x,l.x,c.x),n(a,h.y,u.y,l.y,c.y))},toJSON:function(){for(var t=[],e=0;e1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}}).call(e,i(496)(t))},function(t,e,i){var n=i(117);t.exports=function(t,e,i){void 0===e&&(e=1),void 0===i&&(i=1);var s=Math.floor(6*t),r=6*t-s,o=Math.floor(i*(1-e)*255),a=Math.floor(i*(1-r*e)*255),h=Math.floor(i*(1-(1-r)*e)*255),u={r:i=Math.floor(i*=255),g:i,b:i,color:0},l=s%6;return 0===l?(u.g=h,u.b=o):1===l?(u.r=a,u.b=o):2===l?(u.r=o,u.b=h):3===l?(u.r=o,u.g=a):4===l?(u.r=h,u.g=o):5===l&&(u.g=o,u.b=a),u.color=n(u.r,u.g,u.b),u}},function(t,e){t.exports=function(t,e){return Math.floor(Math.random()*(e-t+1)+t)}},function(t,e,i){var n=i(67);t.exports=function(t){if("complete"!==document.readyState&&"interactive"!==document.readyState){var e=function(){document.removeEventListener("deviceready",e,!0),document.removeEventListener("DOMContentLoaded",e,!0),window.removeEventListener("load",e,!0),t()};document.body?n.cordova&&!n.cocoonJS?document.addEventListener("deviceready",e,!1):(document.addEventListener("DOMContentLoaded",e,!0),window.addEventListener("load",e,!0)):window.setTimeout(e,20)}else t()}},function(t,e){t.exports=function(t){var e="";try{window.DOMParser?e=(new DOMParser).parseFromString(t,"text/xml"):(e=new ActiveXObject("Microsoft.XMLDOM")).loadXML(t)}catch(t){e=null}return e&&e.documentElement&&!e.getElementsByTagName("parsererror").length?e:null}},function(t,e){t.exports=function(t){t.parentNode&&t.parentNode.removeChild(t)}},function(t,e,i){var n=i(0),s=i(3),r=new n({initialize:function(){this.isRunning=!1,this.callback=s,this.tick=0,this.isSetTimeOut=!1,this.timeOutID=null,this.lastTime=0;var t=this;this.step=function e(i){t.lastTime=t.tick,t.tick=i,t.callback(i),t.timeOutID=window.requestAnimationFrame(e)},this.stepTimeout=function e(){var i=Date.now(),n=Math.max(16+t.lastTime-i,0);t.lastTime=t.tick,t.tick=i,t.callback(i),t.timeOutID=window.setTimeout(e,n)}},start:function(t,e){this.isRunning||(this.callback=t,this.isSetTimeOut=e,this.isRunning=!0,this.timeOutID=e?window.setTimeout(this.stepTimeout,0):window.requestAnimationFrame(this.step))},stop:function(){this.isRunning=!1,this.isSetTimeOut?clearTimeout(this.timeOutID):window.cancelAnimationFrame(this.timeOutID)},destroy:function(){this.stop(),this.callback=s}});t.exports=r},function(t,e){t.exports={Global:["anims","cache","registry","sound","textures"],CoreScene:["EventEmitter","CameraManager","GameObjectCreator","GameObjectFactory","ScenePlugin","DisplayList","UpdateList"],DefaultScene:["CameraManager3D","Clock","DataManagerPlugin","InputPlugin","Loader","TweenManager","LightsPlugin"]}},function(t,e,i){var n,s,r,o=i(21),a={supportInverseAlpha:!1,supportNewBlendModes:!1};t.exports=(void 0!==document&&(a.supportNewBlendModes=(n="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/",s="AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==",(r=new Image).onload=function(){var t=new Image;t.onload=function(){var e=o.create(t,6,1).getContext("2d");if(e.globalCompositeOperation="multiply",e.drawImage(r,0,0),e.drawImage(t,2,0),!e.getImageData(2,0,1,1))return!1;var i=e.getImageData(2,0,1,1).data;o.remove(t),a.supportNewBlendModes=255===i[0]&&0===i[1]&&0===i[2]},t.src=n+"/wCKxvRF"+s},r.src=n+"AP804Oa6"+s,!1),a.supportInverseAlpha=function(){var t=o.create(this,2,1).getContext("2d");t.fillStyle="rgba(10, 20, 30, 0.5)",t.fillRect(0,0,1,1);var e=t.getImageData(0,0,1,1);if(null===e)return!1;t.putImageData(e,1,0);var i=t.getImageData(1,0,1,1);return i.data[0]===e.data[0]&&i.data[1]===e.data[1]&&i.data[2]===e.data[2]&&i.data[3]===e.data[3]}()),a)},function(t,e,i){"use strict";function n(t,e,i){i=i||2;var n,a,h,u,l,f,g,v=e&&e.length,y=v?e[0]*i:t.length,m=s(t,0,y,i,!0),x=[];if(!m)return x;if(v&&(m=function(t,e,i,n){var o,a,h,u,l,f=[];for(o=0,a=e.length;o80*i){n=h=t[0],a=u=t[1];for(var w=i;wh&&(h=l),f>u&&(u=f);g=Math.max(h-n,u-a)}return o(m,x,i,n,a,g),x}function s(t,e,i,n,s){var r,o;if(s===C(t,e,i,n)>0)for(r=e;r=e;r-=n)o=T(r,t[r],t[r+1],o);return o&&m(o,o.next)&&(A(o),o=o.next),o}function r(t,e){if(!t)return t;e||(e=t);var i,n=t;do{if(i=!1,n.steiner||!m(n,n.next)&&0!==y(n.prev,n,n.next))n=n.next;else{if(A(n),(n=e=n.prev)===n.next)return null;i=!0}}while(i||n!==e);return e}function o(t,e,i,n,s,c,d){if(t){!d&&c&&function(t,e,i,n){var s=t;do{null===s.z&&(s.z=f(s.x,s.y,e,i,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){var e,i,n,s,r,o,a,h,u=1;do{for(i=t,t=null,r=null,o=0;i;){for(o++,n=i,a=0,e=0;e0||h>0&&n;)0!==a&&(0===h||!n||i.z<=n.z)?(s=i,i=i.nextZ,a--):(s=n,n=n.nextZ,h--),r?r.nextZ=s:t=s,s.prevZ=r,r=s;i=n}r.nextZ=null,u*=2}while(o>1)}(s)}(t,n,s,c);for(var p,g,v=t;t.prev!==t.next;)if(p=t.prev,g=t.next,c?h(t,n,s,c):a(t))e.push(p.i/i),e.push(t.i/i),e.push(g.i/i),A(t),t=g.next,v=g.next;else if((t=g)===v){d?1===d?o(t=u(t,e,i),e,i,n,s,c,2):2===d&&l(t,e,i,n,s,c):o(r(t),e,i,n,s,c,1);break}}}function a(t){var e=t.prev,i=t,n=t.next;if(y(e,i,n)>=0)return!1;for(var s=t.next.next;s!==t.prev;){if(g(e.x,e.y,i.x,i.y,n.x,n.y,s.x,s.y)&&y(s.prev,s,s.next)>=0)return!1;s=s.next}return!0}function h(t,e,i,n){var s=t.prev,r=t,o=t.next;if(y(s,r,o)>=0)return!1;for(var a=s.xr.x?s.x>o.x?s.x:o.x:r.x>o.x?r.x:o.x,l=s.y>r.y?s.y>o.y?s.y:o.y:r.y>o.y?r.y:o.y,c=f(a,h,e,i,n),d=f(u,l,e,i,n),p=t.nextZ;p&&p.z<=d;){if(p!==t.prev&&p!==t.next&&g(s.x,s.y,r.x,r.y,o.x,o.y,p.x,p.y)&&y(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=t.prevZ;p&&p.z>=c;){if(p!==t.prev&&p!==t.next&&g(s.x,s.y,r.x,r.y,o.x,o.y,p.x,p.y)&&y(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}function u(t,e,i){var n=t;do{var s=n.prev,r=n.next.next;!m(s,r)&&x(s,n,n.next,r)&&w(s,r)&&w(r,s)&&(e.push(s.i/i),e.push(n.i/i),e.push(r.i/i),A(n),A(n.next),n=t=r),n=n.next}while(n!==t);return n}function l(t,e,i,n,s,a){var h=t;do{for(var u=h.next.next;u!==h.prev;){if(h.i!==u.i&&v(h,u)){var l=b(h,u);return h=r(h,h.next),l=r(l,l.next),o(h,e,i,n,s,a),void o(l,e,i,n,s,a)}u=u.next}h=h.next}while(h!==t)}function c(t,e){return t.x-e.x}function d(t,e){if(e=function(t,e){var i,n=e,s=t.x,r=t.y,o=-1/0;do{if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){var a=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(a<=s&&a>o){if(o=a,a===s){if(r===n.y)return n;if(r===n.next.y)return n.next}i=n.x=n.x&&n.x>=l&&s!==n.x&&g(ri.x)&&w(n,t)&&(i=n,d=h),n=n.next;return i}(t,e)){var i=b(e,t);r(i,i.next)}}function f(t,e,i,n,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)/s)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)/s)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function p(t){var e=t,i=t;do{e.x=0&&(t-o)*(n-a)-(i-o)*(e-a)>=0&&(i-o)*(r-a)-(s-o)*(n-a)>=0}function v(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&x(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&w(t,e)&&w(e,t)&&function(t,e){var i=t,n=!1,s=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&i.next.y!==i.y&&s<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)}function y(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function m(t,e){return t.x===e.x&&t.y===e.y}function x(t,e,i,n){return!!(m(t,e)&&m(i,n)||m(t,n)&&m(i,e))||y(t,e,i)>0!=y(t,e,n)>0&&y(i,n,t)>0!=y(i,n,e)>0}function w(t,e){return y(t.prev,t,t.next)<0?y(t,e,t.next)>=0&&y(t,t.prev,e)>=0:y(t,e,t.prev)<0||y(t,t.next,e)<0}function b(t,e){var i=new S(t.i,t.x,t.y),n=new S(e.i,e.x,e.y),s=t.next,r=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,n.next=i,i.prev=n,r.next=n,n.prev=r,n}function T(t,e,i,n){var s=new S(t,e,i);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function A(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function S(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function C(t,e,i,n){for(var s=0,r=e,o=i-n;r0&&(n+=t[s-1].length,i.holes.push(n))}return i}},function(t,e){var i={modelMatrixDirty:!1,viewMatrixDirty:!1,projectionMatrixDirty:!1,modelMatrix:null,viewMatrix:null,projectionMatrix:null,mvpInit:function(){return this.modelMatrixDirty=!0,this.viewMatrixDirty=!0,this.projectionMatrixDirty=!0,this.modelMatrix=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),this.viewMatrix=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),this.projectionMatrix=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),this},mvpUpdate:function(){var t=this.program;return this.modelMatrixDirty&&(this.renderer.setMatrix4(t,"uModelMatrix",!1,this.modelMatrix),this.modelMatrixDirty=!1),this.viewMatrixDirty&&(this.renderer.setMatrix4(t,"uViewMatrix",!1,this.viewMatrix),this.viewMatrixDirty=!1),this.projectionMatrixDirty&&(this.renderer.setMatrix4(t,"uProjectionMatrix",!1,this.projectionMatrix),this.projectionMatrixDirty=!1),this},modelIdentity:function(){var t=this.modelMatrix;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this.modelMatrixDirty=!0,this},modelScale:function(t,e,i){var n=this.modelMatrix;return n[0]=n[0]*t,n[1]=n[1]*t,n[2]=n[2]*t,n[3]=n[3]*t,n[4]=n[4]*e,n[5]=n[5]*e,n[6]=n[6]*e,n[7]=n[7]*e,n[8]=n[8]*i,n[9]=n[9]*i,n[10]=n[10]*i,n[11]=n[11]*i,this.modelMatrixDirty=!0,this},modelTranslate:function(t,e,i){var n=this.modelMatrix;return n[12]=n[0]*t+n[4]*e+n[8]*i+n[12],n[13]=n[1]*t+n[5]*e+n[9]*i+n[13],n[14]=n[2]*t+n[6]*e+n[10]*i+n[14],n[15]=n[3]*t+n[7]*e+n[11]*i+n[15],this.modelMatrixDirty=!0,this},modelRotateX:function(t){var e=this.modelMatrix,i=Math.sin(t),n=Math.cos(t),s=e[4],r=e[5],o=e[6],a=e[7],h=e[8],u=e[9],l=e[10],c=e[11];return e[4]=s*n+h*i,e[5]=r*n+u*i,e[6]=o*n+l*i,e[7]=a*n+c*i,e[8]=h*n-s*i,e[9]=u*n-r*i,e[10]=l*n-o*i,e[11]=c*n-a*i,this.modelMatrixDirty=!0,this},modelRotateY:function(t){var e=this.modelMatrix,i=Math.sin(t),n=Math.cos(t),s=e[0],r=e[1],o=e[2],a=e[3],h=e[8],u=e[9],l=e[10],c=e[11];return e[0]=s*n-h*i,e[1]=r*n-u*i,e[2]=o*n-l*i,e[3]=a*n-c*i,e[8]=s*i+h*n,e[9]=r*i+u*n,e[10]=o*i+l*n,e[11]=a*i+c*n,this.modelMatrixDirty=!0,this},modelRotateZ:function(t){var e=this.modelMatrix,i=Math.sin(t),n=Math.cos(t),s=e[0],r=e[1],o=e[2],a=e[3],h=e[4],u=e[5],l=e[6],c=e[7];return e[0]=s*n+h*i,e[1]=r*n+u*i,e[2]=o*n+l*i,e[3]=a*n+c*i,e[4]=h*n-s*i,e[5]=u*n-r*i,e[6]=l*n-o*i,e[7]=c*n-a*i,this.modelMatrixDirty=!0,this},viewIdentity:function(){var t=this.viewMatrix;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this.viewMatrixDirty=!0,this},viewScale:function(t,e,i){var n=this.viewMatrix;return n[0]=n[0]*t,n[1]=n[1]*t,n[2]=n[2]*t,n[3]=n[3]*t,n[4]=n[4]*e,n[5]=n[5]*e,n[6]=n[6]*e,n[7]=n[7]*e,n[8]=n[8]*i,n[9]=n[9]*i,n[10]=n[10]*i,n[11]=n[11]*i,this.viewMatrixDirty=!0,this},viewTranslate:function(t,e,i){var n=this.viewMatrix;return n[12]=n[0]*t+n[4]*e+n[8]*i+n[12],n[13]=n[1]*t+n[5]*e+n[9]*i+n[13],n[14]=n[2]*t+n[6]*e+n[10]*i+n[14],n[15]=n[3]*t+n[7]*e+n[11]*i+n[15],this.viewMatrixDirty=!0,this},viewRotateX:function(t){var e=this.viewMatrix,i=Math.sin(t),n=Math.cos(t),s=e[4],r=e[5],o=e[6],a=e[7],h=e[8],u=e[9],l=e[10],c=e[11];return e[4]=s*n+h*i,e[5]=r*n+u*i,e[6]=o*n+l*i,e[7]=a*n+c*i,e[8]=h*n-s*i,e[9]=u*n-r*i,e[10]=l*n-o*i,e[11]=c*n-a*i,this.viewMatrixDirty=!0,this},viewRotateY:function(t){var e=this.viewMatrix,i=Math.sin(t),n=Math.cos(t),s=e[0],r=e[1],o=e[2],a=e[3],h=e[8],u=e[9],l=e[10],c=e[11];return e[0]=s*n-h*i,e[1]=r*n-u*i,e[2]=o*n-l*i,e[3]=a*n-c*i,e[8]=s*i+h*n,e[9]=r*i+u*n,e[10]=o*i+l*n,e[11]=a*i+c*n,this.viewMatrixDirty=!0,this},viewRotateZ:function(t){var e=this.viewMatrix,i=Math.sin(t),n=Math.cos(t),s=e[0],r=e[1],o=e[2],a=e[3],h=e[4],u=e[5],l=e[6],c=e[7];return e[0]=s*n+h*i,e[1]=r*n+u*i,e[2]=o*n+l*i,e[3]=a*n+c*i,e[4]=h*n-s*i,e[5]=u*n-r*i,e[6]=l*n-o*i,e[7]=c*n-a*i,this.viewMatrixDirty=!0,this},viewLoad2D:function(t){var e=this.viewMatrix;return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=0,e[4]=t[2],e[5]=t[3],e[6]=0,e[7]=0,e[8]=t[4],e[9]=t[5],e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this.viewMatrixDirty=!0,this},viewLoad:function(t){var e=this.viewMatrix;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],this.viewMatrixDirty=!0,this},projIdentity:function(){var t=this.projectionMatrix;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this.projectionMatrixDirty=!0,this},projOrtho:function(t,e,i,n,s,r){var o=this.projectionMatrix,a=1/(t-e),h=1/(i-n),u=1/(s-r);return o[0]=-2*a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=-2*h,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=2*u,o[11]=0,o[12]=(t+e)*a,o[13]=(n+i)*h,o[14]=(r+s)*u,o[15]=1,this.projectionMatrixDirty=!0,this},projPersp:function(t,e,i,n){var s=this.projectionMatrix,r=1/Math.tan(t/2),o=1/(i-n);return s[0]=r/e,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=r,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=(n+i)*o,s[11]=-1,s[12]=0,s[13]=0,s[14]=2*n*i*o,s[15]=0,this.projectionMatrixDirty=!0,this}};t.exports=i},function(t,e,i){var n=i(0),s=i(14),r=i(241),o=i(245),a=i(248),h=i(249),u=i(8),l=i(250),c=i(251),d=new n({initialize:function(t,e){this.game=t,this.canvas,this.config=e,this.enabled=!0,this.events=new s,this.queue=[],this.keyboard=new o(this),this.mouse=new a(this),this.touch=new l(this),this.gamepad=new r(this),this.activePointer=new h(this,0),this.scale={x:1,y:1},this.globalTopOnly=!0,this.ignoreEvents=!1,this.bounds=new u,this._tempPoint={x:0,y:0},this._tempHitTest=[],t.events.once("boot",this.boot,this)},boot:function(){this.canvas=this.game.canvas,this.updateBounds(),this.keyboard.boot(),this.mouse.boot(),this.touch.boot(),this.gamepad.boot(),this.game.events.once("destroy",this.destroy,this)},updateBounds:function(){var t=this.bounds,e=this.canvas.getBoundingClientRect();t.x=e.left+window.pageXOffset-document.documentElement.clientLeft,t.y=e.top+window.pageYOffset-document.documentElement.clientTop,t.width=e.width,t.height=e.height},resize:function(){this.updateBounds();var t=this.game.config.width,e=this.game.config.height,i=this.bounds.width,n=this.bounds.height;this.scale.x=t/i,this.scale.y=e/n},update:function(t){this.keyboard.update(),this.gamepad.update(),this.ignoreEvents=!1;var e=this.queue.length,i=this.activePointer;if(i.reset(),this.enabled&&0!==e){this.updateBounds(),this.scale.x=this.game.config.width/this.bounds.width,this.scale.y=this.game.config.height/this.bounds.height;for(var n=this.queue.splice(0,e),s=0;s=n.x&&e>=n.y&&t<=n.x+o&&e<=n.y+a))return s;n.getWorldPoint(t,e,r);for(var h=n.cull(i),u={x:0,y:0},l=0;l0?1:-1)}});t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.pad=t,this.events=t.events,this.index=e,this.value=0,this.threshold=0,this.pressed=!1},update:function(t){this.value=t.value,this.value>=this.threshold?this.pressed||(this.pressed=!0,this.events.emit("down",this.pad,this,this.value,t)):this.pressed&&(this.pressed=!1,this.events.emit("up",this.pad,this,this.value,t))}});t.exports=n},function(t,e,i){var n=i(0),s=i(14),r=i(246),o=i(129),a=i(247),h=i(527),u=i(528),l=i(529),c=new n({Extends:s,initialize:function(t){s.call(this),this.manager=t,this.enabled=!1,this.target,this.keys=[],this.combos=[],this.captures=[],this.queue=[],this.handler},boot:function(){var t=this.manager.config;this.enabled=t.inputKeyboard,this.target=t.inputKeyboardEventTarget,this.enabled&&this.startListeners()},startListeners:function(){var t=this.queue,e=this.captures,i=function(i){i.defaultPrevented||(t.push(i),e[i.keyCode]&&i.preventDefault())};this.handler=i,this.target.addEventListener("keydown",i,!1),this.target.addEventListener("keyup",i,!1)},stopListeners:function(){this.target.removeEventListener("keydown",this.handler),this.target.removeEventListener("keyup",this.handler)},createCursorKeys:function(){return this.addKeys({up:o.UP,down:o.DOWN,left:o.LEFT,right:o.RIGHT,space:o.SPACE,shift:o.SHIFT})},addKeys:function(t){var e={};for(var i in t)e[i]=this.addKey(t[i]);return e},addKey:function(t){var e=this.keys;return e[t]||(e[t]=new r(t),this.captures[t]=!0),e[t]},removeKey:function(t){this.keys[t]&&(this.keys[t]=void 0,this.captures[t]=!1)},addKeyCapture:function(t){Array.isArray(t)||(t=[t]);for(var e=0;e-1&&(this.keys[n]=void 0,this.scenes.splice(i,1),this._start.indexOf(n)>-1&&(i=this._start.indexOf(n),this._start.splice(i,1)),e.sys.destroy())}return this},bootScene:function(t){var e;t.init&&t.init.call(t,t.sys.settings.data),t.sys.load&&(e=t.sys.load).reset(),e&&t.preload?(t.preload.call(t),0===e.list.size?this.create(t):(t.sys.settings.status=s.LOADING,e.once("complete",this.loadComplete,this),e.start())):this.create(t)},loadComplete:function(t){var e=t.scene;this.create(e)},payloadComplete:function(t){this.bootScene(t.scene)},update:function(t,e){this.processQueue(),this._processing=1;for(var i=this.scenes.length-1;i>=0;i--){var n=this.scenes[i].sys;n.settings.status===s.RUNNING&&n.step(t,e)}},resize:function(t,e){for(var i=0;i=s.LOADING&&i.settings.status0){var i=this.getScene(t);this.scenes.splice(e,1),this.scenes.unshift(i)}}return this},moveDown:function(t){if(this._processing)this._queue.push({op:"moveDown",keyA:t,keyB:null});else{var e=this.getIndex(t);if(e>0){var i=e-1,n=this.getScene(t),s=this.getAt(i);this.scenes[e]=s,this.scenes[i]=n}}return this},moveUp:function(t){if(this._processing)this._queue.push({op:"moveUp",keyA:t,keyB:null});else{var e=this.getIndex(t);if(en&&-1!==i&&-1!==n){var s=this.getAt(n);this.scenes.splice(n,1),this.scenes.splice(i,0,s)}}return this},moveBelow:function(t,e){if(t===e)return this;if(this._processing)this._queue.push({op:"moveBelow",keyA:t,keyB:e});else{var i=this.getIndex(t),n=this.getIndex(e);if(i=0;t--){this.scenes[t].sys.destroy()}this.scenes=[],this._pending=[],this._start=[],this._queue=[],this.game=null}});t.exports=u},function(t,e,i){var n=i(0),s=i(130),r=new n({initialize:function(t){this.sys=new s(this,t)},update:function(){}});t.exports=r},function(t,e){t.exports=function(t){return t&&t[0].toUpperCase()+t.slice(1)}},function(t,e,i){var n=i(83),s=i(4),r=i(532),o={create:function(t){return"string"==typeof t?t={key:t}:void 0===t&&(t={}),{status:n.PENDING,key:s(t,"key",""),active:s(t,"active",!1),visible:s(t,"visible",!0),isBooted:!1,data:{},files:s(t,"files",!1),cameras:s(t,"cameras",null),map:s(t,"map",r),physics:s(t,"physics",{}),loader:s(t,"loader",{}),plugins:s(t,"plugins",!1)}}};t.exports=o},function(t,e,i){var n=i(257),s=i(259),r=i(261),o={create:function(t){var e=t.config.audio,i=t.device.audio;return e&&e.noAudio||!i.webAudio&&!i.audioData?new s(t):!i.webAudio||e&&e.disableWebAudio?new n(t):new r(t)}};t.exports=o},function(t,e,i){var n=i(84),s=i(0),r=i(258),o=new s({Extends:n,initialize:function(t){this.override=!0,this.audioPlayDelay=.1,this.loopEndOffset=.05,this.onBlurPausedSounds=[],this.locked="ontouchstart"in window,this.lockedActionsQueue=this.locked?[]:null,this._mute=!1,this._volume=1,n.call(this,t)},add:function(t,e){var i=new r(this,t,e);return this.sounds.push(i),i},unlock:function(){var t=this,e=!1,i=function(){e=!0},n=function(){if(t.game.cache.audio.entries.size)if(e)e=!1;else{document.body.removeEventListener("touchmove",i),document.body.removeEventListener("touchend",n);var s=[];t.game.cache.audio.entries.each(function(t,e){for(var i=0;i0)&&(!!s.prototype.pause.call(this)&&(this.currentConfig.seek=this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0),this.stopAndReleaseAudioTag(),this.emit("pause",this),!0)))},resume:function(){return!this.manager.isLocked(this,"resume")&&(!(this.startTime>0)&&(!!s.prototype.resume.call(this)&&(!!this.pickAndPlayAudioTag()&&(this.emit("resume",this),!0))))},stop:function(){return!this.manager.isLocked(this,"stop")&&(!!s.prototype.stop.call(this)&&(this.stopAndReleaseAudioTag(),this.emit("stop",this),!0))},pickAndPlayAudioTag:function(){if(!this.pickAudioTag())return this.reset(),!1;var t=this.currentConfig.seek,e=this.currentConfig.delay,i=(this.currentMarker?this.currentMarker.start:0)+t;return this.previousTime=i,this.audio.currentTime=i,this.applyConfig(),0===e?(this.startTime=0,this.audio.paused&&this.playCatchPromise()):(this.startTime=window.performance.now()+1e3*e,this.audio.paused||this.audio.pause()),this.resetConfig(),!0},pickAudioTag:function(){if(this.audio)return!0;for(var t=0;t0)this.startTime=n-this.manager.loopEndOffset?(this.audio.currentTime=i+Math.max(0,s-n),s=this.audio.currentTime):s=n)return this.reset(),this.stopAndReleaseAudioTag(),void this.emit("ended",this);this.previousTime=s}},destroy:function(){s.prototype.destroy.call(this),this.tags=null,this.audio&&this.stopAndReleaseAudioTag()},setMute:function(){this.audio&&(this.audio.muted=this.currentConfig.mute||this.manager.mute)},setVolume:function(){this.audio&&(this.audio.volume=this.currentConfig.volume*this.manager.volume)},setRate:function(){s.prototype.setRate.call(this),this.audio&&(this.audio.playbackRate=this.totalRate)}});Object.defineProperty(r.prototype,"mute",{get:function(){return this.currentConfig.mute},set:function(t){this.currentConfig.mute=t,this.manager.isLocked(this,"mute",t)||(this.setMute(),this.emit("mute",this,t))}}),Object.defineProperty(r.prototype,"volume",{get:function(){return this.currentConfig.volume},set:function(t){this.currentConfig.volume=t,this.manager.isLocked(this,"volume",t)||(this.setVolume(),this.emit("volume",this,t))}}),Object.defineProperty(r.prototype,"rate",{get:function(){return Object.getOwnPropertyDescriptor(s.prototype,"rate").get.call(this)},set:function(t){this.currentConfig.rate=t,this.manager.isLocked(this,"rate",t)||Object.getOwnPropertyDescriptor(s.prototype,"rate").set.call(this,t)}}),Object.defineProperty(r.prototype,"detune",{get:function(){return Object.getOwnPropertyDescriptor(s.prototype,"detune").get.call(this)},set:function(t){this.currentConfig.detune=t,this.manager.isLocked(this,"detune",t)||Object.getOwnPropertyDescriptor(s.prototype,"detune").set.call(this,t)}}),Object.defineProperty(r.prototype,"seek",{get:function(){return this.isPlaying?this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0):this.isPaused?this.currentConfig.seek:0},set:function(t){this.manager.isLocked(this,"seek",t)||this.startTime>0||(this.isPlaying||this.isPaused)&&(t=Math.min(Math.max(0,t),this.duration),this.isPlaying?(this.previousTime=t,this.audio.currentTime=t):this.isPaused&&(this.currentConfig.seek=t),this.emit("seek",this,t))}}),Object.defineProperty(r.prototype,"loop",{get:function(){return this.currentConfig.loop},set:function(t){this.currentConfig.loop=t,this.manager.isLocked(this,"loop",t)||(this.audio&&(this.audio.loop=t),this.emit("loop",this,t))}}),t.exports=r},function(t,e,i){var n=i(84),s=i(0),r=i(14),o=i(260),a=i(3),h=new s({Extends:r,initialize:function(t){r.call(this),this.game=t,this.sounds=[],this.mute=!1,this.volume=1,this.rate=1,this.detune=0,this.pauseOnBlur=!0,this.locked=!1},add:function(t,e){var i=new o(this,t,e);return this.sounds.push(i),i},addAudioSprite:function(t,e){var i=this.add(t,e);return i.spritemap={},i},play:function(t,e){return!1},playAudioSprite:function(t,e,i){return!1},remove:function(t){return n.prototype.remove.call(this,t)},removeByKey:function(t){return n.prototype.removeByKey.call(this,t)},pauseAll:a,resumeAll:a,stopAll:a,update:a,destroy:function(){n.prototype.destroy.call(this)},forEachActiveSound:function(t,e){n.prototype.forEachActiveSound.call(this,t,e)}});t.exports=h},function(t,e,i){var n=i(85),s=i(0),r=i(14),o=i(23),a=new s({Extends:r,initialize:function(t,e,i){void 0===i&&(i={}),r.call(this),this.manager=t,this.key=e,this.isPlaying=!1,this.isPaused=!1,this.totalRate=1,this.duration=0,this.totalDuration=0,this.config=o({mute:!1,volume:1,rate:1,detune:0,seek:0,loop:!1,delay:0},i),this.currentConfig=this.config,this.mute=!1,this.volume=1,this.rate=1,this.detune=0,this.seek=0,this.loop=!1,this.markers={},this.currentMarker=null,this.pendingRemove=!1},addMarker:function(t){return!1},updateMarker:function(t){return!1},removeMarker:function(t){return null},play:function(t,e){return!1},pause:function(){return!1},resume:function(){return!1},stop:function(){return!1},destroy:function(){this.manager.remove(this),n.prototype.destroy.call(this)}});t.exports=a},function(t,e,i){var n=i(84),s=i(0),r=i(262),o=new s({Extends:n,initialize:function(t){this.context=this.createAudioContext(t),this.masterMuteNode=this.context.createGain(),this.masterVolumeNode=this.context.createGain(),this.masterMuteNode.connect(this.masterVolumeNode),this.masterVolumeNode.connect(this.context.destination),this.destination=this.masterMuteNode,this.locked="suspended"===this.context.state&&"ontouchstart"in window,n.call(this,t)},createAudioContext:function(t){var e=t.config.audio;return e&&e.context?(e.context.resume(),e.context):new AudioContext},add:function(t,e){var i=new r(this,t,e);return this.sounds.push(i),i},unlock:function(){var t=this,e=function(){t.context.resume().then(function(){document.body.removeEventListener("touchstart",e),document.body.removeEventListener("touchend",e),t.unlocked=!0})};document.body.addEventListener("touchstart",e,!1),document.body.addEventListener("touchend",e,!1)},onBlur:function(){this.context.suspend()},onFocus:function(){this.context.resume()},destroy:function(){this.destination=null,this.masterVolumeNode.disconnect(),this.masterVolumeNode=null,this.masterMuteNode.disconnect(),this.masterMuteNode=null,this.game.config.audio&&this.game.config.audio.context?this.context.suspend():this.context.close(),this.context=null,n.prototype.destroy.call(this)},mute:{get:function(){return 0===this.masterMuteNode.gain.value},set:function(t){this.masterMuteNode.gain.setValueAtTime(t?0:1,0),this.emit("mute",this,t)}},volume:{get:function(){return this.masterVolumeNode.gain.value},set:function(t){this.masterVolumeNode.gain.setValueAtTime(t,0),this.emit("volume",this,t)}}});t.exports=o},function(t,e,i){var n=i(0),s=i(85),r=new n({Extends:s,initialize:function(t,e,i){void 0===i&&(i={}),this.audioBuffer=t.game.cache.audio.get(e),this.audioBuffer?(this.source=null,this.loopSource=null,this.muteNode=t.context.createGain(),this.volumeNode=t.context.createGain(),this.playTime=0,this.startTime=0,this.loopTime=0,this.rateUpdates=[],this.hasEnded=!1,this.hasLooped=!1,this.muteNode.connect(this.volumeNode),this.volumeNode.connect(t.destination),this.duration=this.audioBuffer.duration,this.totalDuration=this.audioBuffer.duration,s.call(this,t,e,i)):console.error("No audio loaded in cache with key: '"+e+"'!")},play:function(t,e){return!!s.prototype.play.call(this,t,e)&&(this.stopAndRemoveBufferSource(),this.createAndStartBufferSource(),this.emit("play",this),!0)},pause:function(){return!(this.manager.context.currentTime=0&&t<=o.width&&e>=0&&e<=o.height){t+=s.cutX,e+=s.cutY;var a=this._tempContext;a.clearRect(0,0,1,1),a.drawImage(o,t,e,1,1,0,0,1,1);var h=a.getImageData(0,0,1,1);return new r(h.data[0],h.data[1],h.data[2],h.data[3])}}return null},setTexture:function(t,e,i){return this.list[e]&&(t.texture=this.list[e],t.frame=t.texture.get(i)),t},each:function(t,e){for(var i=[null],n=1;nu&&(r=u),o>u&&(o=u),a=s,h=r;;)if(ay&&(s=y),r>m&&(r=m);var A=y+g-s,S=m+v-r;o0&&e.cameraFilter&r._id)){var h=r.scrollX*e.scrollFactorX,u=r.scrollY*e.scrollFactorY,l=e.x,c=e.y,d=e.scaleX,f=e.scaleY,p=e.rotation,g=e.commandBuffer,v=o||t.currentContext,y=1,m=1,x=0,w=0,b=1,T=0,A=0,S=0;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,v.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,v.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode),v.save(),v.translate(l-h,c-u),v.rotate(p),v.scale(d,f),v.fillStyle="#fff",v.globalAlpha=e.alpha;for(var C=0,M=g.length;C>>16,A=(65280&x)>>>8,S=255&x,v.strokeStyle="rgba("+T+","+A+","+S+","+y+")",v.lineWidth=b,C+=3;break;case n.FILL_STYLE:w=g[C+1],m=g[C+2],T=(16711680&w)>>>16,A=(65280&w)>>>8,S=255&w,v.fillStyle="rgba("+T+","+A+","+S+","+m+")",C+=2;break;case n.BEGIN_PATH:v.beginPath();break;case n.CLOSE_PATH:v.closePath();break;case n.FILL_PATH:a||v.fill();break;case n.STROKE_PATH:a||v.stroke();break;case n.FILL_RECT:a?v.rect(g[C+1],g[C+2],g[C+3],g[C+4]):v.fillRect(g[C+1],g[C+2],g[C+3],g[C+4]),C+=4;break;case n.FILL_TRIANGLE:v.beginPath(),v.moveTo(g[C+1],g[C+2]),v.lineTo(g[C+3],g[C+4]),v.lineTo(g[C+5],g[C+6]),v.closePath(),a||v.fill(),C+=6;break;case n.STROKE_TRIANGLE:v.beginPath(),v.moveTo(g[C+1],g[C+2]),v.lineTo(g[C+3],g[C+4]),v.lineTo(g[C+5],g[C+6]),v.closePath(),a||v.stroke(),C+=6;break;case n.LINE_TO:v.lineTo(g[C+1],g[C+2]),C+=2;break;case n.MOVE_TO:v.moveTo(g[C+1],g[C+2]),C+=2;break;case n.LINE_FX_TO:v.lineTo(g[C+1],g[C+2]),C+=5;break;case n.MOVE_FX_TO:v.moveTo(g[C+1],g[C+2]),C+=5;break;case n.SAVE:v.save();break;case n.RESTORE:v.restore();break;case n.TRANSLATE:v.translate(g[C+1],g[C+2]),C+=2;break;case n.SCALE:v.scale(g[C+1],g[C+2]),C+=2;break;case n.ROTATE:v.rotate(g[C+1]),C+=1}v.restore()}}},function(t,e,i){var n=i(4),s=i(80),r=function(t,e,i){for(var n=[],s=0;s0?(h=this.lightPool.pop()).set(t,e,i,a[0],a[1],a[2],r):h=new s(t,e,i,a[0],a[1],a[2],r),this.lights.push(h),h},removeLight:function(t){var e=this.lights.indexOf(t);return e>=0&&(this.lightPool.push(t),this.lights.splice(e,1)),this},shutdown:function(){for(;this.lights.length>0;)this.lightPool.push(this.lights.pop());this.ambientColor={r:.1,g:.1,b:.1},this.culledLights.length=0,this.lights.length=0},destroy:function(){this.shutdown()}});t.exports=a},function(t,e,i){t.exports={Circle:i(665),Ellipse:i(270),Intersects:i(295),Line:i(685),Point:i(703),Polygon:i(717),Rectangle:i(307),Triangle:i(746)}},function(t,e,i){t.exports={CircleToCircle:i(675),CircleToRectangle:i(676),GetRectangleIntersection:i(677),LineToCircle:i(297),LineToLine:i(89),LineToRectangle:i(678),PointToLine:i(298),PointToLineSegment:i(679),RectangleToRectangle:i(296),RectangleToTriangle:i(680),RectangleToValues:i(681),TriangleToCircle:i(682),TriangleToLine:i(683),TriangleToTriangle:i(684)}},function(t,e){t.exports=function(t,e){return!(t.width<=0||t.height<=0||e.width<=0||e.height<=0||t.righte.right||t.y>e.bottom)}},function(t,e,i){var n=i(32),s=new(i(5));t.exports=function(t,e,i){if(void 0===i&&(i=s),n(e,t.x1,t.y1))return i.x=t.x1,i.y=t.y1,!0;if(n(e,t.x2,t.y2))return i.x=t.x2,i.y=t.y2,!0;var r=t.x2-t.x1,o=t.y2-t.y1,a=e.x-t.x1,h=e.y-t.y1,u=r*r+o*o,l=r,c=o;if(u>0){var d=(a*r+h*o)/u;l*=d,c*=d}return i.x=t.x1+l,i.y=t.y1+c,l*l+c*c<=u&&l*r+c*o>=0&&n(e,i.x,i.y)}},function(t,e){t.exports=function(t,e){return(t.x-e.x1)*(e.y2-e.y1)==(e.x2-e.x1)*(t.y-e.y1)}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=[]),e.push({x:t.x,y:t.y}),e.push({x:t.right,y:t.y}),e.push({x:t.right,y:t.bottom}),e.push({x:t.x,y:t.bottom}),e}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=[]),e.push({x:t.x1,y:t.y1}),e.push({x:t.x2,y:t.y2}),e.push({x:t.x3,y:t.y3}),e}},function(t,e,i){var n=i(0),s=i(302),r=i(109),o=i(111),a=new n({initialize:function(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x1=t,this.y1=e,this.x2=i,this.y2=n},getPoint:function(t,e){return s(this,t,e)},getPoints:function(t,e,i){return r(this,t,e,i)},getRandomPoint:function(t){return o(this,t)},setTo:function(t,e,i,n){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x1=t,this.y1=e,this.x2=i,this.y2=n,this},getPointA:function(){return{x:this.x1,y:this.y1}},getPointB:function(){return{x:this.x2,y:this.y2}},left:{get:function(){return Math.min(this.x1,this.x2)},set:function(t){this.x1<=this.x2?this.x1=t:this.x2=t}},right:{get:function(){return Math.max(this.x1,this.x2)},set:function(t){this.x1>this.x2?this.x1=t:this.x2=t}},top:{get:function(){return Math.min(this.y1,this.y2)},set:function(t){this.y1<=this.y2?this.y1=t:this.y2=t}},bottom:{get:function(){return Math.max(this.y1,this.y2)},set:function(t){this.y1>this.y2?this.y1=t:this.y2=t}}});t.exports=a},function(t,e,i){var n=i(5);t.exports=function(t,e,i){return void 0===i&&(i=new n),i.x=t.x1+(t.x2-t.x1)*e,i.y=t.y1+(t.y2-t.y1)*e,i}},function(t,e,i){var n=i(16),s=i(50),r=i(55);t.exports=function(t){var e=r(t)-n.TAU;return s(e,-Math.PI,Math.PI)}},function(t,e){t.exports=function(t){return Math.sqrt(t.x*t.x+t.y*t.y)}},function(t,e){t.exports=function(t){return t.x*t.x+t.y*t.y}},function(t,e,i){var n=i(0),s=i(147),r=new n({initialize:function(t){this.area=0,this.points=[],t&&this.setTo(t)},contains:function(t,e){return s(this,t,e)},setTo:function(t){if(this.area=0,this.points=[],!Array.isArray(t))return this;for(var e,i=Number.MAX_VALUE,n=0;n=1)return i.x=r.x1,i.y=r.y1,i;var h=s(r),u=s(o),l=s(a),c=(h+u+l)*e,d=0;return ch+u?(d=(c-=h+u)/l,i.x=a.x1+(a.x2-a.x1)*d,i.y=a.y1+(a.y2-a.y1)*d):(d=(c-=h)/u,i.x=o.x1+(o.x2-o.x1)*d,i.y=o.y1+(o.y2-o.y1)*d),i}},function(t,e,i){var n=i(66),s=i(5);t.exports=function(t,e,i,r){void 0===r&&(r=[]);var o=t.getLineA(),a=t.getLineB(),h=t.getLineC(),u=n(o),l=n(a),c=n(h),d=u+l+c;e||(e=d/i);for(var f=0;fu+l?(g=(p-=u+l)/c,v.x=h.x1+(h.x2-h.x1)*g,v.y=h.y1+(h.y2-h.y1)*g):(g=(p-=u)/l,v.x=a.x1+(a.x2-a.x1)*g,v.y=a.y1+(a.y2-a.y1)*g),r.push(v)}return r}},function(t,e,i){var n=i(5);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=(t.x1+t.x2+t.x3)/3,e.y=(t.y1+t.y2+t.y3)/3,e}},function(t,e){t.exports=function(t,e,i){return t.x1+=e,t.y1+=i,t.x2+=e,t.y2+=i,t.x3+=e,t.y3+=i,t}},function(t,e,i){var n=i(5);function s(t,e,i,n){var s=t-i,r=e-n,o=s*s+r*r;return Math.sqrt(o)}t.exports=function(t,e){void 0===e&&(e=new n);var i=t.x1,r=t.y1,o=t.x2,a=t.y2,h=t.x3,u=t.y3,l=s(h,u,o,a),c=s(i,r,h,u),d=s(o,a,i,r),f=l+c+d;return e.x=(i*l+o*c+h*d)/f,e.y=(r*l+a*c+u*d)/f,e}},function(t,e){t.exports=function(t,e,i){return{gameObject:t,enabled:!0,draggable:!1,dropZone:!1,target:null,camera:null,hitArea:e,hitAreaCallback:i,localX:0,localY:0,dragState:0,dragStartX:0,dragStartY:0,dragX:0,dragY:0}}},function(t,e,i){var n=i(151);t.exports=function(t,e){var i=n(e,t.xhrSettings),s=new XMLHttpRequest;return s.open("GET",t.src,i.async,i.user,i.password),s.responseType=t.xhrSettings.responseType,s.timeout=i.timeout,i.header&&i.headerValue&&s.setRequestHeader(i.header,i.headerValue),i.overrideMimeType&&s.overrideMimeType(i.overrideMimeType),s.onload=t.onLoad.bind(t),s.onerror=t.onError.bind(t),s.onprogress=t.onProgress.bind(t),s.send(),s}},function(t,e,i){var n=i(0),s=i(19),r=i(18),o=i(7),a=i(2),h=i(317),u=new n({Extends:r,initialize:function(t,e,i,n,s){this.context=s;var o={type:"audio",extension:a(e,"type",""),responseType:"arraybuffer",key:t,url:a(e,"uri",e),path:i,xhrSettings:n};r.call(this,o)},onProcess:function(t){this.state=s.FILE_PROCESSING;var e=this;this.context.decodeAudioData(this.xhrLoader.response,function(i){e.data=i,e.onComplete(),t(e)},function(i){console.error("Error with decoding audio data for '"+this.key+"':",i.message),e.state=s.FILE_ERRORED,t(e)}),this.context=null}});u.create=function(t,e,i,n,s){var r=t.systems.game,o=r.config.audio,a=r.device.audio;if(o&&o.noAudio||!a.webAudio&&!a.audioData)return null;var l=u.findAudioURL(r,i);return l?!a.webAudio||o&&o.disableWebAudio?new h(e,l,t.path,n,r.sound.locked):new u(e,l,t.path,s,r.sound.context):null},o.register("audio",function(t,e,i,n){var s=u.create(this,t,e,i,n);return s&&this.addFile(s),this}),u.findAudioURL=function(t,e){e.constructor!==Array&&(e=[e]);for(var i=0;i=0?t:t+2*Math.PI}},function(t,e,i){var n=i(323);t.exports=function(t,e){return n(t)/n(e)/n(t-e)}},function(t,e){t.exports=function(t){if(0===t)return 1;for(var e=t;--t;)e*=t;return e}},function(t,e){t.exports=function(t,e){var i=t.x,n=t.y;return t.x=i*Math.cos(e)-n*Math.sin(e),t.y=i*Math.sin(e)+n*Math.cos(e),t}},function(t,e){t.exports=function(t){return t>0?Math.ceil(t):Math.floor(t)}},function(t,e,i){var n=i(327),s=i(91),r=i(0),o=i(59),a=i(329),h=i(330),u=new r({initialize:function(t){this.world=t,this.scene=t.scene,this.sys=t.scene.sys},collider:function(t,e,i,n,s){return this.world.addCollider(t,e,i,n,s)},overlap:function(t,e,i,n,s){return this.world.addOverlap(t,e,i,n,s)},existing:function(t,e){var i=e?o.STATIC_BODY:o.DYNAMIC_BODY;return this.world.enableBody(t,i),t},staticImage:function(t,e,i,s){var r=new n(this.scene,t,e,i,s);return this.sys.displayList.add(r),this.world.enableBody(r,o.STATIC_BODY),r},image:function(t,e,i,s){var r=new n(this.scene,t,e,i,s);return this.sys.displayList.add(r),this.world.enableBody(r,o.DYNAMIC_BODY),r},staticSprite:function(t,e,i,n){var r=new s(this.scene,t,e,i,n);return this.sys.displayList.add(r),this.sys.updateList.add(r),this.world.enableBody(r,o.STATIC_BODY),r},sprite:function(t,e,i,n){var r=new s(this.scene,t,e,i,n);return this.sys.displayList.add(r),this.sys.updateList.add(r),this.world.enableBody(r,o.DYNAMIC_BODY),r},staticGroup:function(t,e){return this.sys.updateList.add(new h(this.world,this.world.scene,t,e))},group:function(t,e){return this.sys.updateList.add(new a(this.world,this.world.scene,t,e))}});t.exports=u},function(t,e,i){var n=i(0),s=i(328),r=i(70),o=new n({Extends:r,Mixins:[s.Acceleration,s.Angular,s.Bounce,s.Debug,s.Drag,s.Enable,s.Friction,s.Gravity,s.Immovable,s.Mass,s.Size,s.Velocity],initialize:function(t,e,i,n,s){r.call(this,t,e,i,n,s)}});t.exports=o},function(t,e,i){t.exports={Acceleration:i(838),Angular:i(839),Bounce:i(840),Debug:i(841),Drag:i(842),Enable:i(843),Friction:i(844),Gravity:i(845),Immovable:i(846),Mass:i(847),Size:i(848),Velocity:i(849)}},function(t,e,i){var n=i(91),s=i(0),r=i(59),o=i(2),a=i(69),h=new s({Extends:a,initialize:function(t,e,i,s){void 0!==s||Array.isArray(i)||"object"!=typeof i?void 0===s&&(s={}):(s=i,i=null),this.world=t,s.createCallback=this.createCallback,s.removeCallback=this.removeCallback,s.classType=o(s,"classType",n),this.physicsType=r.DYNAMIC_BODY,this.defaults={setCollideWorldBounds:o(s,"collideWorldBounds",!1),setAccelerationX:o(s,"accelerationX",0),setAccelerationY:o(s,"accelerationY",0),setBounceX:o(s,"bounceX",0),setBounceY:o(s,"bounceY",0),setDragX:o(s,"dragX",0),setDragY:o(s,"dragY",0),setGravityX:o(s,"gravityX",0),setGravityY:o(s,"gravityY",0),setFrictionX:o(s,"frictionX",0),setFrictionY:o(s,"frictionY",0),setVelocityX:o(s,"velocityX",0),setVelocityY:o(s,"velocityY",0),setAngularVelocity:o(s,"angularVelocity",0),setAngularAcceleration:o(s,"angularAcceleration",0),setAngularDrag:o(s,"angularDrag",0),setMass:o(s,"mass",1),setImmovable:o(s,"immovable",!1)},a.call(this,e,i,s)},createCallback:function(t){t.body||this.world.enableBody(t,r.DYNAMIC_BODY);var e=t.body;for(var i in this.defaults)e[i](this.defaults[i])},removeCallback:function(t){t.body&&this.world.disableBody(t)},setVelocity:function(t,e,i){void 0===i&&(i=0);for(var n=this.getChildren(),s=0;s0){var u=this.tree,l=this.staticTree;for(o=(r=s.entries).length,t=0;t0?i-=s:i+s<0?i+=s:i=0),i>r?i=r:i<-r&&(i=-r),i},separate:function(t,e,i,n,s){if(!t.enable||!e.enable||t.checkCollision.none||e.checkCollision.none||!this.intersects(t,e))return!1;if(i&&!1===i.call(n,t.gameObject,e.gameObject))return!1;if(t.isCircle&&e.isCircle)return this.separateCircle(t,e,s);if(t.isCircle!==e.isCircle){var r=t.isCircle?e:t,o=t.isCircle?t:e,a={x:r.x,y:r.y,right:r.right,bottom:r.bottom},h=o.center;if((h.ya.bottom)&&(h.xa.right))return this.separateCircle(t,e,s)}var u=!1,l=!1;this.forceX||Math.abs(this.gravity.y+t.gravity.y)u.right&&(a=h(d.x,d.y,u.right,u.y)-d.radius):d.y>u.bottom&&(d.xu.right&&(a=h(d.x,d.y,u.right,u.bottom)-d.radius)),a*=-1}else a=t.halfWidth+e.halfWidth-h(t.center.x,t.center.y,e.center.x,e.center.y);if(i||0===a||t.immovable&&e.immovable||t.customSeparateX||e.customSeparateX)return 0!==a&&(t.onOverlap||e.onOverlap)&&this.emit("overlap",t.gameObject,e.gameObject,t,e),0!==a;var f=t.velocity.x,p=t.velocity.y,g=t.mass,v=e.velocity.x,y=e.velocity.y,m=e.mass,x=f*Math.cos(o)+p*Math.sin(o),w=f*Math.sin(o)-p*Math.cos(o),b=v*Math.cos(o)+y*Math.sin(o),T=v*Math.sin(o)-y*Math.cos(o),A=((g-m)*x+2*m*b)/(g+m),S=(2*g*x+(m-g)*b)/(g+m);return t.immovable||(t.velocity.x=(A*Math.cos(o)-w*Math.sin(o))*t.bounce.x,t.velocity.y=(w*Math.cos(o)+A*Math.sin(o))*t.bounce.y,f=t.velocity.x,p=t.velocity.y),e.immovable||(e.velocity.x=(S*Math.cos(o)-T*Math.sin(o))*e.bounce.x,e.velocity.y=(T*Math.cos(o)+S*Math.sin(o))*e.bounce.y,v=e.velocity.x,y=e.velocity.y),Math.abs(o)0&&!t.immovable&&v>f?t.velocity.x*=-1:v<0&&!e.immovable&&f0&&!t.immovable&&y>p?t.velocity.y*=-1:y<0&&!e.immovable&&pMath.PI/2&&(f<0&&!t.immovable&&v0&&!e.immovable&&f>v?e.velocity.x*=-1:p<0&&!t.immovable&&y0&&!e.immovable&&f>y&&(e.velocity.y*=-1)),t.immovable||(t.x+=t.velocity.x*this.delta-a*Math.cos(o),t.y+=t.velocity.y*this.delta-a*Math.sin(o)),e.immovable||(e.x+=e.velocity.x*this.delta+a*Math.cos(o),e.y+=e.velocity.y*this.delta+a*Math.sin(o)),(t.onCollide||e.onCollide)&&this.emit("collide",t.gameObject,e.gameObject,t,e),!0},intersects:function(t,e){return t!==e&&(t.isCircle?e.isCircle?h(t.center.x,t.center.y,e.center.x,e.center.y)<=t.halfWidth+e.halfWidth:this.circleBodyIntersects(t,e):e.isCircle?this.circleBodyIntersects(e,t):!(t.right<=e.position.x)&&(!(t.bottom<=e.position.y)&&(!(t.position.x>=e.right)&&!(t.position.y>=e.bottom))))},circleBodyIntersects:function(t,e){var i=s(t.center.x,e.left,e.right),n=s(t.center.y,e.top,e.bottom);return(t.center.x-i)*(t.center.x-i)+(t.center.y-n)*(t.center.y-n)<=t.halfWidth*t.halfWidth},overlap:function(t,e,i,n,s){return void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=i),this.collideObjects(t,e,i,n,s,!0)},collide:function(t,e,i,n,s){return void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=i),this.collideObjects(t,e,i,n,s,!1)},collideObjects:function(t,e,i,n,s,r){var o;t=t.isParent&&void 0===t.physicsType?t.children.entries:t,e=e.isParent&&void 0===e.physicsType?e.children.entries:e;var a=Array.isArray(t),h=Array.isArray(e);if(this._total=0,a||h)if(!a&&h)for(o=0;o0},collideHandler:function(t,e,i,n,s,r){if(void 0===e&&t.isParent)return this.collideGroupVsGroup(t,t,i,n,s,r);if(!t||!e)return!1;if(t.body){if(e.body)return this.collideSpriteVsSprite(t,e,i,n,s,r);if(e.isParent)return this.collideSpriteVsGroup(t,e,i,n,s,r);if(e.isTilemap)return this.collideSpriteVsTilemapLayer(t,e,i,n,s,r)}else if(t.isParent){if(e.body)return this.collideSpriteVsGroup(e,t,i,n,s,r);if(e.isParent)return this.collideGroupVsGroup(t,e,i,n,s,r);if(e.isTilemap)return this.collideGroupVsTilemapLayer(t,e,i,n,s,r)}else if(t.isTilemap){if(e.body)return this.collideSpriteVsTilemapLayer(e,t,i,n,s,r);if(e.isParent)return this.collideGroupVsTilemapLayer(e,t,i,n,s,r)}},collideSpriteVsSprite:function(t,e,i,n,s,r){return!(!t.body||!e.body)&&(this.separate(t.body,e.body,n,s,r)&&(i&&i.call(s,t,e),this._total++),!0)},collideSpriteVsGroup:function(t,e,i,n,s,r){var o=t.body;if(0!==e.length&&o){var h=this.treeMinMax;h.minX=o.left,h.minY=o.top,h.maxX=o.right,h.maxY=o.bottom;var u=e.physicsType===a.DYNAMIC_BODY?this.tree.search(h):this.staticTree.search(h);if(0!==u.length)for(var l=e.getChildren(),c=0;cc.baseTileWidth){var d=(c.tileWidth-c.baseTileWidth)*e.scaleX;a-=d,u+=d}c.tileHeight>c.baseTileHeight&&(l+=(c.tileHeight-c.baseTileHeight)*e.scaleY);var f,g=e.getTilesWithinWorldXY(a,h,u,l);if(0===g.length)return!1;for(var v={left:0,right:0,top:0,bottom:0},m=0;m0&&(this.facing=r.FACING_RIGHT),this._dy<0?this.facing=r.FACING_UP:this._dy>0&&(this.facing=r.FACING_DOWN),this.moves&&(0!==this.deltaMax.x&&0!==this._dx&&(this._dx<0&&this._dx<-this.deltaMax.x?this._dx=-this.deltaMax.x:this._dx>0&&this._dx>this.deltaMax.x&&(this._dx=this.deltaMax.x)),0!==this.deltaMax.y&&0!==this._dy&&(this._dy<0&&this._dy<-this.deltaMax.y?this._dy=-this.deltaMax.y:this._dy>0&&this._dy>this.deltaMax.y&&(this._dy=this.deltaMax.y)),this.gameObject.x+=this._dx,this.gameObject.y+=this._dy,this._reset=!0),this.updateCenter(),this.allowRotation&&(this.gameObject.angle+=this.deltaZ()),this.prev.x=this.position.x,this.prev.y=this.position.y)},checkWorldBounds:function(){var t=this.position,e=this.world.bounds,i=this.world.checkCollision,n=this.worldBounce?-this.worldBounce.x:-this.bounce.x,s=this.worldBounce?-this.worldBounce.y:-this.bounce.y;return t.xe.right&&i.right&&(t.x=e.right-this.width,this.velocity.x*=n,this.blocked.right=!0,this.blocked.none=!1),t.ye.bottom&&i.down&&(t.y=e.bottom-this.height,this.velocity.y*=s,this.blocked.down=!0,this.blocked.none=!1),!this.blocked.none},setOffset:function(t,e){return void 0===e&&(e=t),this.offset.set(t,e),this},setSize:function(t,e,i){void 0===i&&(i=!0);var n=this.gameObject;if(this.sourceWidth=t,this.sourceHeight=e,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter(),i&&n.getCenter){var s=n.displayWidth/2,r=n.displayHeight/2;this.offset.set(s-this.halfWidth,r-this.halfHeight)}return this.isCircle=!1,this.radius=0,this},setCircle:function(t,e,i){return void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.isCircle=!0,this.radius=t,this.sourceWidth=2*t,this.sourceHeight=2*t,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.set(e,i),this.updateCenter()):this.isCircle=!1,this},reset:function(t,e){this.stop();var i=this.gameObject;i.setPosition(t,e),i.getTopLeft(this.position),this.prev.copy(this.position),this.rotation=i.angle,this.preRotation=i.angle,this.updateBounds(),this.updateCenter()},stop:function(){return this.velocity.set(0),this.acceleration.set(0),this.speed=0,this.angularVelocity=0,this.angularAcceleration=0,this},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,e){return this.isCircle?n(this,t,e):a(this,t,e)},onFloor:function(){return this.blocked.down},onCeiling:function(){return this.blocked.up},onWall:function(){return this.blocked.left||this.blocked.right},deltaAbsX:function(){return this.deltaX()>0?this.deltaX():-this.deltaX()},deltaAbsY:function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},deltaX:function(){return this.position.x-this.prev.x},deltaY:function(){return this.position.y-this.prev.y},deltaZ:function(){return this.rotation-this.preRotation},destroy:function(){this.enable=!1,this.world.pendingDestroy.set(this)},drawDebug:function(t){var e=this.position,i=e.x+this.halfWidth,n=e.y+this.halfHeight;this.debugShowBody&&(t.lineStyle(1,this.debugBodyColor),this.isCircle?t.strokeCircle(i,n,this.radius):t.strokeRect(e.x,e.y,this.width,this.height)),this.debugShowVelocity&&(t.lineStyle(1,this.world.defaults.velocityDebugColor,1),t.lineBetween(i,n,i+this.velocity.x/2,n+this.velocity.y/2))},willDrawDebug:function(){return this.debugShowBody||this.debugShowVelocity},setCollideWorldBounds:function(t){return this.collideWorldBounds=t,this},setVelocity:function(t,e){return this.velocity.set(t,e),this},setVelocityX:function(t){return this.velocity.x=t,this},setVelocityY:function(t){return this.velocity.y=t,this},setBounce:function(t,e){return this.bounce.set(t,e),this},setBounceX:function(t){return this.bounce.x=t,this},setBounceY:function(t){return this.bounce.y=t,this},setAcceleration:function(t,e){return this.acceleration.set(t,e),this},setAccelerationX:function(t){return this.acceleration.x=t,this},setAccelerationY:function(t){return this.acceleration.y=t,this},setDrag:function(t,e){return this.drag.set(t,e),this},setDragX:function(t){return this.drag.x=t,this},setDragY:function(t){return this.drag.y=t,this},setGravity:function(t,e){return this.gravity.set(t,e),this},setGravityX:function(t){return this.gravity.x=t,this},setGravityY:function(t){return this.gravity.y=t,this},setFriction:function(t,e){return this.friction.set(t,e),this},setFrictionX:function(t){return this.friction.x=t,this},setFrictionY:function(t){return this.friction.y=t,this},setAngularVelocity:function(t){return this.angularVelocity=t,this},setAngularAcceleration:function(t){return this.angularAcceleration=t,this},setAngularDrag:function(t){return this.angularDrag=t,this},setMass:function(t){return this.mass=t,this},setImmovable:function(t){return this.immovable=t,this},x:{get:function(){return this.position.x},set:function(t){this.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t}},left:{get:function(){return this.position.x}},right:{get:function(){return this.position.x+this.width}},top:{get:function(){return this.position.y}},bottom:{get:function(){return this.position.y+this.height}}});t.exports=u},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r,o){this.world=t,this.name="",this.active=!0,this.overlapOnly=e,this.object1=i,this.object2=n,this.collideCallback=s,this.processCallback=r,this.callbackContext=o},setName:function(t){return this.name=t,this},update:function(){this.world.collideObjects(this.object1,this.object2,this.collideCallback,this.processCallback,this.callbackContext,this.overlapOnly)},destroy:function(){this.world.removeCollider(this),this.active=!1,this.world=null,this.object1=null,this.object2=null,this.collideCallback=null,this.processCallback=null,this.callbackContext=null}});t.exports=n},function(t,e){t.exports=function(t,e,i,n){var s=0,r=t.deltaAbsX()+e.deltaAbsX()+n;return 0===t.deltaX()&&0===e.deltaX()?(t.embedded=!0,e.embedded=!0):t.deltaX()>e.deltaX()?(s=t.right-e.x)>r&&!i||!1===t.checkCollision.right||!1===e.checkCollision.left?s=0:(t.touching.none=!1,t.touching.right=!0,e.touching.none=!1,e.touching.left=!0):t.deltaX()r&&!i||!1===t.checkCollision.left||!1===e.checkCollision.right?s=0:(t.touching.none=!1,t.touching.left=!0,e.touching.none=!1,e.touching.right=!0)),t.overlapX=s,e.overlapX=s,s}},function(t,e){t.exports=function(t,e,i,n){var s=0,r=t.deltaAbsY()+e.deltaAbsY()+n;return 0===t.deltaY()&&0===e.deltaY()?(t.embedded=!0,e.embedded=!0):t.deltaY()>e.deltaY()?(s=t.bottom-e.y)>r&&!i||!1===t.checkCollision.down||!1===e.checkCollision.up?s=0:(t.touching.none=!1,t.touching.down=!0,e.touching.none=!1,e.touching.up=!0):t.deltaY()r&&!i||!1===t.checkCollision.up||!1===e.checkCollision.down?s=0:(t.touching.none=!1,t.touching.up=!0,e.touching.none=!1,e.touching.down=!0)),t.overlapY=s,e.overlapY=s,s}},function(t,e,i){var n=new(i(0))({initialize:function(){this._pending=[],this._active=[],this._destroy=[],this._toProcess=0},add:function(t){return this._pending.push(t),this._toProcess++,this},remove:function(t){return this._destroy.push(t),this._toProcess++,this},update:function(){if(0===this._toProcess)return this._active;var t,e,i=this._destroy,n=this._active;for(t=0;t=t.minX&&e.maxY>=t.minY}function g(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function v(t,e,i,s,r){for(var o,a=[e,i];a.length;)(i=a.pop())-(e=a.pop())<=s||(o=e+Math.ceil((i-e)/s/2)*s,n(t,o,e,i,r),a.push(e,o,o,i))}s.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,i=[],n=this.toBBox;if(!p(t,e))return i;for(var s,r,o,a,h=[];e;){for(s=0,r=e.children.length;s=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(s,r,e)},_split:function(t,e){var i=t[e],n=i.children.length,s=this._minEntries;this._chooseSplitAxis(i,s,n);var r=this._chooseSplitIndex(i,s,n),a=g(i.children.splice(r,i.children.length-r));a.height=i.height,a.leaf=i.leaf,o(i,this.toBBox),o(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)},_splitRoot:function(t,e){this.data=g([t,e]),this.data.height=t.height+1,this.data.leaf=!1,o(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,i){var n,s,r,o,h,u,l,d,f,p,g,v,y,m;for(u=l=1/0,n=e;n<=i-e;n++)s=a(t,0,n,this.toBBox),r=a(t,n,i,this.toBBox),f=s,p=r,void 0,void 0,void 0,void 0,g=Math.max(f.minX,p.minX),v=Math.max(f.minY,p.minY),y=Math.min(f.maxX,p.maxX),m=Math.min(f.maxY,p.maxY),o=Math.max(0,y-g)*Math.max(0,m-v),h=c(s)+c(r),o=e;s--)r=t.children[s],h(l,t.leaf?o(r):r),c+=d(l);return c},_adjustParentBBoxes:function(t,e,i){for(var n=i;n>=0;n--)h(e[n],t)},_condense:function(t){for(var e,i=t.length-1;i>=0;i--)0===t[i].children.length?i>0?(e=t[i-1].children).splice(e.indexOf(t[i]),1):this.clear():o(t[i],this.toBBox)},_initFormat:function(t){var e=["return a"," - b",";"];this.compareMinX=new Function("a","b",e.join(t[0])),this.compareMinY=new Function("a","b",e.join(t[1])),this.toBBox=new Function("a","return {minX: a"+t[0]+", minY: a"+t[1]+", maxX: a"+t[2]+", maxY: a"+t[3]+"};")}},t.exports=s},function(t,e){var i=function(t,e,r,o,a){for(r=r||0,o=o||t.length-1,a=a||s;o>r;){if(o-r>600){var h=o-r+1,u=e-r+1,l=Math.log(h),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(h-c)/h)*(u-h/2<0?-1:1),f=Math.max(r,Math.floor(e-u*c/h+d)),p=Math.min(o,Math.floor(e+(h-u)*c/h+d));i(t,e,f,p,a)}var g=t[e],v=r,y=o;for(n(t,r,e),a(t[o],g)>0&&n(t,r,o);v0;)y--}0===a(t[r],g)?n(t,r,y):n(t,++y,o),y<=e&&(r=y+1),e<=y&&(o=y-1)}};function n(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function s(t,e){return te?1:0}t.exports=i},function(t,e){t.exports=function(t,e){return!(e.right<=t.left||e.bottom<=t.top||e.position.x>=t.right||e.position.y>=t.bottom)}},function(t,e,i){var n=i(32),s=i(0),r=i(59),o=i(33),a=i(6),h=new s({initialize:function(t,e){this.world=t,this.gameObject=e,this.debugShowBody=t.defaults.debugShowStaticBody,this.debugBodyColor=t.defaults.staticBodyDebugColor,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new a,this.position=new a(e.x-e.displayOriginX,e.y-e.displayOriginY),this.width=e.displayWidth,this.height=e.displayHeight,this.halfWidth=Math.abs(this.width/2),this.halfHeight=Math.abs(this.height/2),this.center=new a(e.x+this.halfWidth,e.y+this.halfHeight),this.velocity=a.ZERO,this.allowGravity=!1,this.gravity=a.ZERO,this.bounce=a.ZERO,this.onWorldBounds=!1,this.onCollide=!1,this.onOverlap=!1,this.mass=1,this.immovable=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.overlapR=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision={none:!1,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.blocked={none:!0,up:!1,down:!1,left:!1,right:!1},this.physicsType=r.STATIC_BODY},setGameObject:function(t,e){return t&&t!==this.gameObject&&(this.gameObject.body=null,t.body=this,this.gameObject=t),e&&this.updateFromGameObject(),this},updateFromGameObject:function(){this.world.staticTree.remove(this);var t=this.gameObject;return t.getTopLeft(this.position),this.width=t.displayWidth,this.height=t.displayHeight,this.halfWidth=Math.abs(this.width/2),this.halfHeight=Math.abs(this.height/2),this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight),this.world.staticTree.insert(this),this},setSize:function(t,e,i,n){return void 0===i&&(i=this.offset.x),void 0===n&&(n=this.offset.y),this.world.staticTree.remove(this),this.width=t,this.height=e,this.halfWidth=Math.floor(t/2),this.halfHeight=Math.floor(e/2),this.offset.set(i,n),this.updateCenter(),this.isCircle=!1,this.radius=0,this.world.staticTree.insert(this),this},setCircle:function(t,e,i){return void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.world.staticTree.remove(this),this.isCircle=!0,this.radius=t,this.width=2*t,this.height=2*t,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.set(e,i),this.updateCenter(),this.world.staticTree.insert(this)):this.isCircle=!1,this},updateCenter:function(){this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},reset:function(t,e){var i=this.gameObject;void 0===t&&(t=i.x),void 0===e&&(e=i.y),this.world.staticTree.remove(this),i.getTopLeft(this.position),this.updateCenter(),this.world.staticTree.insert(this)},stop:function(){return this},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,e){return this.isCircle?n(this,t,e):o(this,t,e)},deltaAbsX:function(){return 0},deltaAbsY:function(){return 0},deltaX:function(){return 0},deltaY:function(){return 0},deltaZ:function(){return 0},destroy:function(){this.enable=!1,this.world.pendingDestroy.set(this)},drawDebug:function(t){var e=this.position;this.debugShowBody&&(t.lineStyle(1,this.debugBodyColor,1),t.strokeRect(e.x,e.y,this.width,this.height))},willDrawDebug:function(){return this.debugShowBody},setMass:function(t){return t<=0&&(t=.1),this.mass=t,this},x:{get:function(){return this.position.x},set:function(t){this.world.staticTree.remove(this),this.position.x=t,this.world.staticTree.insert(this)}},y:{get:function(){return this.position.y},set:function(t){this.world.staticTree.remove(this),this.position.y=t,this.world.staticTree.insert(this)}},left:{get:function(){return this.position.x}},right:{get:function(){return this.position.x+this.width}},top:{get:function(){return this.position.y}},bottom:{get:function(){return this.position.y+this.height}}});t.exports=h},,,,function(t,e,i){var n=i(15);t.exports=function(t,e,i,s,r,o,a){for(var h=n(i,s,r,o,null,a),u=0;u-1}return!1}},function(t,e,i){var n=i(44),s=i(74),r=i(153);t.exports=function(t,e,i,o,a){if(void 0===i&&(i=!1),void 0===o&&(o=!0),!s(t,e,a))return null;var h=a.data[e][t];return null===h?null:(a.data[e][t]=i?null:new n(a,-1,t,e,h.width,h.height),o&&h&&h.collides&&r(t,e,a),h)}},function(t,e,i){var n=i(22),s=i(156),r=i(348),o=i(349),a=i(354);t.exports=function(t,e,i,h,u,l){var c;switch(e){case n.ARRAY_2D:c=s(t,i,h,u,l);break;case n.CSV:c=r(t,i,h,u,l);break;case n.TILED_JSON:c=o(t,i,l);break;case n.WELTMEISTER:c=a(t,i,l);break;default:console.warn("Unrecognized tilemap data format: "+e),c=null}return c}},function(t,e,i){var n=i(22),s=i(156);t.exports=function(t,e,i,r,o){var a=e.trim().split("\n").map(function(t){return t.split(",")}),h=s(t,a,i,r,o);return h.format=n.CSV,h}},function(t,e,i){var n=i(22),s=i(76),r=i(904),o=i(906),a=i(907),h=i(909),u=i(910),l=i(911);t.exports=function(t,e,i){if("orthogonal"!==e.orientation)return console.warn("Only orthogonal map types are supported in this version of Phaser"),null;var c=new s({width:e.width,height:e.height,name:t,tileWidth:e.tilewidth,tileHeight:e.tileheight,orientation:e.orientation,format:n.TILED_JSON,version:e.version,properties:e.properties});c.layers=r(e,i),c.images=o(e);var d=a(e);return c.tilesets=d.tilesets,c.imageCollections=d.imageCollections,c.objects=h(e),c.tiles=u(c),l(c),c}},function(t,e){t.exports=function(t){var e=Boolean(2147483648&t),i=Boolean(1073741824&t),n=Boolean(536870912&t);t&=536870911;var s=0,r=!1;return e&&i&&n?(s=Math.PI/2,r=!0):e&&i&&!n?(s=Math.PI,r=!1):e&&!i&&n?(s=Math.PI/2,r=!1):!e||i||n?!e&&i&&n?(s=3*Math.PI/2,r=!1):e||!i||n?e||i||!n?e||i||n||(s=0,r=!1):(s=3*Math.PI/2,r=!0):(s=Math.PI,r=!0):(s=0,r=!0),{gid:t,flippedHorizontal:e,flippedVertical:i,flippedAntiDiagonal:n,rotation:s,flipped:r}}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r,o){(void 0===i||i<=0)&&(i=32),(void 0===n||n<=0)&&(n=32),void 0===s&&(s=0),void 0===r&&(r=0),this.name=t,this.firstgid=0|e,this.imageWidth=0|i,this.imageHeight=0|n,this.imageMargin=0|s,this.imageSpacing=0|r,this.properties=o||{},this.images=[],this.total=0},containsImageIndex:function(t){return t>=this.firstgid&&ta&&(a=e.layer[u].width),e.layer[u].height>h&&(h=e.layer[u].height);var l=new s({width:a,height:h,name:t,tileWidth:e.layer[0].tilesize,tileHeight:e.layer[0].tilesize,format:n.WELTMEISTER});return l.layers=r(e,i),l.tilesets=o(e),l}},function(t,e,i){var n=i(0),s=i(35),r=i(356),o=i(23),a=i(22),h=i(75),u=i(324),l=i(357),c=i(44),d=i(96),f=i(100),p=new n({initialize:function(t,e){this.scene=t,this.tileWidth=e.tileWidth,this.tileHeight=e.tileHeight,this.width=e.width,this.height=e.height,this.orientation=e.orientation,this.format=e.format,this.version=e.version,this.properties=e.properties,this.widthInPixels=e.widthInPixels,this.heightInPixels=e.heightInPixels,this.imageCollections=e.imageCollections,this.images=e.images,this.layers=e.layers,this.tilesets=e.tilesets,this.objects=e.objects,this.currentLayerIndex=0},addTilesetImage:function(t,e,i,n,s,r,o){if(void 0===t)return null;if(null==e&&(e=t),!this.scene.sys.textures.exists(e))return console.warn('Invalid image key given for tileset: "'+e+'"'),null;var h=this.scene.sys.textures.get(e),u=this.getTilesetIndex(t);if(null===u&&this.format===a.TILED_JSON)return console.warn('No data found in the JSON tilemap from Tiled matching the tileset name: "'+t+'"'),null;if(this.tilesets[u])return this.tilesets[u].setTileSize(i,n),this.tilesets[u].setSpacing(s,r),this.tilesets[u].setImage(h),this.tilesets[u];void 0===i&&(i=this.tileWidth),void 0===n&&(n=this.tileHeight),void 0===s&&(s=0),void 0===r&&(r=0),void 0===o&&(o=0);var l=new f(t,o,i,n,s,r);return l.setImage(h),this.tilesets.push(l),l},convertLayerToStatic:function(t){if(null===(t=this.getLayer(t)))return null;var e=t.tilemapLayer;if(!(e&&e instanceof r))return null;var i=new l(e.scene,e.tilemap,e.layerIndex,e.tileset,e.x,e.y);return this.scene.sys.displayList.add(i),e.destroy(),i},copy:function(t,e,i,n,s,r,o,a){return a=this.getLayer(a),this._isStaticCall(a,"copy")?this:(null!==a&&d.Copy(t,e,i,n,s,r,o,a),this)},createBlankDynamicLayer:function(t,e,i,n,s,o,a,u){if(void 0===a&&(a=e.tileWidth),void 0===u&&(u=e.tileHeight),void 0===s&&(s=this.width),void 0===o&&(o=this.height),void 0===i&&(i=0),void 0===n&&(n=0),null!==this.getLayerIndex(t))return console.warn("Cannot create blank layer: layer with matching name already exists "+t),null;for(var l,d=new h({name:t,tileWidth:a,tileHeight:u,width:s,height:o}),f=0;f0){var t=this.delay+this.delay*this.repeat;return(this.elapsed+this.delay*(this.repeat-this.repeatCount))/t}return this.getProgress()},getRepeatCount:function(){return this.repeatCount},getElapsed:function(){return this.elapsed},getElapsedSeconds:function(){return.001*this.elapsed},remove:function(t){void 0===t&&(t=!1),this.elapsed=this.delay,this.hasDispatched=!t,this.repeatCount=0},destroy:function(){this.callback=void 0,this.callbackScope=void 0,this.args=[]}});t.exports=r},function(t,e,i){var n=i(926);t.exports=function(t){var e,i=[];if(t.hasOwnProperty("props"))for(e in t.props)"_"!==e.substr(0,1)&&i.push({key:e,value:t.props[e]});else for(e in t)-1===n.indexOf(e)&&"_"!==e.substr(0,1)&&i.push({key:e,value:t[e]});return i}},function(t,e,i){var n=i(4);t.exports=function(t){var e=n(t,"tweens",null);return null===e?[]:("function"==typeof e&&(e=e.call()),Array.isArray(e)||(e=[e]),e)}},function(t,e,i){var n=i(160),s=i(10),r=i(73),o=i(71),a=i(101),h=i(4),u=i(159),l=i(161),c=i(162);t.exports=function(t,e,i){void 0===i&&(i=n);var d=h(e,"from",0),f=h(e,"to",1),p=[{value:d}],g=a(e,"delay",i.delay),v=a(e,"duration",i.duration),y=h(e,"easeParams",i.easeParams),m=o(h(e,"ease",i.ease),y),x=a(e,"hold",i.hold),w=a(e,"repeat",i.repeat),b=a(e,"repeatDelay",i.repeatDelay),T=r(e,"yoyo",i.yoyo),A=[],S=u("value",f),C=c(p[0],"value",S.getEnd,S.getStart,m,g,v,T,x,w,b,!1,!1);C.start=d,C.current=d,C.to=f,A.push(C);var M=new l(t,A,p);M.offset=s(e,"offset",null),M.completeDelay=s(e,"completeDelay",0),M.loop=Math.round(s(e,"loop",0)),M.loopDelay=Math.round(s(e,"loopDelay",0)),M.paused=r(e,"paused",!1),M.useFrames=r(e,"useFrames",!1);for(var E=h(e,"callbackScope",M),_=[M,null],L=l.TYPES,P=0;P0?Math.floor(v/p.length):h(e,"duration",g.duration),g.delay=h(e,"delay",g.delay),g.easeParams=c(e,"easeParams",g.easeParams),g.ease=a(c(e,"ease",g.ease),g.easeParams),g.hold=h(e,"hold",g.hold),g.repeat=h(e,"repeat",g.repeat),g.repeatDelay=h(e,"repeatDelay",g.repeatDelay),g.yoyo=o(e,"yoyo",g.yoyo),g.flipX=o(e,"flipX",g.flipX),g.flipY=o(e,"flipY",g.flipY);for(var y=0;y0?this.totalDuration=this.duration+this.completeDelay+(this.duration+this.loopDelay)*this.loopCounter:this.totalDuration=this.duration+this.completeDelay},init:function(){return this.calcDuration(),this.progress=0,this.totalProgress=0,!this.paused||(this.state=o.PAUSED,!1)},resetTweens:function(t){for(var e=0;e0){this.elapsed=0,this.progress=0,this.loopCounter--;var t=this.callbacks.onLoop;t&&t.func.apply(t.scope,t.params),this.emit("loop",this,this.loopCounter),this.resetTweens(!0),this.loopDelay>0?(this.countdown=this.loopDelay,this.state=o.LOOP_DELAY):this.state=o.ACTIVE}else if(this.completeDelay>0)this.countdown=this.completeDelay,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&e.func.apply(e.scope,e.params),this.emit("complete",this),this.state=o.PENDING_REMOVE}},update:function(t,e){if(this.state!==o.PAUSED){var i=e;switch(this.useFrames&&(e=1*this.manager.timeScale),e*=this.timeScale,this.elapsed+=e,this.progress=Math.min(this.elapsed/this.duration,1),this.totalElapsed+=e,this.totalProgress=Math.min(this.totalElapsed/this.totalDuration,1),this.state){case o.ACTIVE:for(var n=this.totalData,s=0;s=t.length)){for(var i=t.length-1,n=t[e],s=e;s=this.nextTick&&this.currentAnim.setFrame(this))},updateFrame:function(t){var e=this.parent;if(this.currentFrame=t,e.texture=t.frame.texture,e.frame=t.frame,this.isPlaying){t.setAlpha&&(e.alpha=t.alpha);var i=this.currentAnim;i.onUpdate&&i.onUpdate.apply(i.callbackScope,this._updateParams),t.onUpdate&&t.onUpdate(e,t)}},yoyo:function(t){return void 0===t?this._yoyo:(this._yoyo=t,this)},destroy:function(){}});t.exports=n},function(t,e,i){var n=i(367),s=i(368),r=i(0),o=i(19),a=i(369),h=i(370),u=i(63),l=i(121),c=new r({initialize:function(t){this.game=t,this.type=o.CANVAS,this.drawCount=0,this.width=t.config.width,this.height=t.config.height,this.config={clearBeforeRender:t.config.clearBeforeRender,pixelArt:t.config.pixelArt,backgroundColor:t.config.backgroundColor,resolution:t.config.resolution,autoResize:t.config.autoResize,roundPixels:t.config.roundPixels},this.scaleMode=t.config.pixelArt?u.NEAREST:u.LINEAR,this.gameCanvas=t.canvas,this.gameContext=this.gameCanvas.getContext("2d"),this.currentContext=this.gameContext,this.drawImage=a(this.config.roundPixels),this.blitImage=n(this.config.roundPixels),this.blendModes=h(),this.currentAlpha=1,this.currentBlendMode=0,this.currentScaleMode=0,this.snapshotCallback=null,this.snapshotType=null,this.snapshotEncoder=null,this.init()},init:function(){this.resize(this.width,this.height)},resize:function(t,e){var i=this.config.resolution;this.width=t*i,this.height=e*i,this.gameCanvas.width=this.width,this.gameCanvas.height=this.height,this.config.autoResize&&(this.gameCanvas.style.width=this.width/i+"px",this.gameCanvas.style.height=this.height/i+"px"),this.scaleMode===u.NEAREST&&l.disable(this.gameContext)},onContextLost:function(){},onContextRestored:function(){},resetTransform:function(){this.currentContext.setTransform(1,0,0,1,0,0)},setBlendMode:function(t){return this.currentBlendMode!==t&&(this.currentContext.globalCompositeOperation=t,this.currentBlendMode=t),this.currentBlendMode},setAlpha:function(t){return this.currentAlpha!==t&&(this.currentContext.globalAlpha=t,this.currentAlpha=t),this.currentAlpha},preRender:function(){var t=this.gameContext,e=this.config,i=this.width,n=this.height;e.clearBeforeRender&&t.clearRect(0,0,i,n),e.transparent||(t.fillStyle=e.backgroundColor.rgba,t.fillRect(0,0,i,n)),this.drawCount=0},render:function(t,e,i,n){var s=t.sys.context,r=0!==n.x||0!==n.y||n.width!==s.canvas.width||n.height!==s.canvas.height,o=e.list,a=this.config.resolution;this.currentContext=s,n.transparent||(s.fillStyle=n.backgroundColor.rgba,s.fillRect(n.x,n.y,n.width,n.height)),1!==this.currentAlpha&&(s.globalAlpha=1,this.currentAlpha=1),0!==this.currentBlendMode&&(s.globalCompositeOperation="source-over",this.currentBlendMode=0),this.currentScaleMode=0,this.drawCount+=o.length,r&&(s.save(),s.beginPath(),s.rect(n.x*a,n.y*a,n.width*a,n.height*a),s.clip());var h=n.matrix.matrix;s.setTransform(h[0],h[1],h[2],h[3],h[4],h[5]);for(var u=0;u0||n._flashAlpha>0)&&(s.globalCompositeOperation="source-over",s.fillStyle="rgb("+255*n._fadeRed+","+255*n._fadeGreen+","+255*n._fadeBlue+")",s.globalAlpha=n._fadeAlpha,s.fillRect(n.x,n.y,n.width,n.height),s.fillStyle="rgb("+255*n._flashRed+","+255*n._flashGreen+","+255*n._flashBlue+")",s.globalAlpha=n._flashAlpha,s.fillRect(n.x,n.y,n.width,n.height),s.globalAlpha=1),r&&s.restore()},postRender:function(){var t=this.gameContext;t.globalAlpha=1,t.globalCompositeOperation="source-over",this.currentAlpha=1,this.currentBlendMode=0,this.snapshotCallback&&(this.snapshotCallback(s(this.gameCanvas,this.snapshotType,this.snapshotEncoder)),this.snapshotCallback=null)},snapshot:function(t,e,i){this.snapshotCallback=t,this.snapshotType=e,this.snapshotEncoder=i},destroy:function(){this.gameCanvas=null,this.gameContext=null,this.game=null}});t.exports=c},function(t,e){var i=!1,n=function(t,e,n){var s=this.currentContext,r=n.canvasData;i&&(t|=0,e|=0),s.drawImage(n.source.image,r.sx,r.sy,r.sWidth,r.sHeight,t,e,r.dWidth,r.dHeight)};t.exports=function(t){return i=t,n}},function(t,e){t.exports=function(t,e,i){void 0===e&&(e="image/png"),void 0===i&&(i=.92);var n=t.toDataURL(e,i),s=new Image;return s.src=n,s}},function(t,e){var i=!1,n=function(t,e){var n=this.currentContext,s=t.frame,r=s.canvasData;this.currentBlendMode!==t.blendMode&&(this.currentBlendMode=t.blendMode,n.globalCompositeOperation=this.blendModes[t.blendMode]),this.currentAlpha!==t.alpha&&(this.currentAlpha=t.alpha,n.globalAlpha=t.alpha),this.currentScaleMode!==t.scaleMode&&(this.currentScaleMode=t.scaleMode);var o=s.x,a=s.y,h=1,u=1;t.flipX?(h=-1,o-=r.dWidth-t.displayOriginX):o-=t.displayOriginX,t.flipY?(u=-1,a-=r.dHeight-t.displayOriginY):a-=t.displayOriginY;var l=t.x-e.scrollX*t.scrollFactorX,c=t.y-e.scrollY*t.scrollFactorY;i&&(l|=0,c|=0,o|=0,a|=0),n.save(),n.translate(l,c),n.rotate(t.rotation),n.scale(t.scaleX,t.scaleY),n.scale(h,u),n.drawImage(s.source.image,r.sx,r.sy,r.sWidth,r.sHeight,o,a,r.dWidth,r.dHeight),n.restore()};t.exports=function(t){return i=t,n}},function(t,e,i){var n=i(45),s=i(237);t.exports=function(){var t=[],e=s.supportNewBlendModes;return t[n.NORMAL]="source-over",t[n.ADD]="lighter",t[n.MULTIPLY]=e?"multiply":"source-over",t[n.SCREEN]=e?"screen":"source-over",t[n.OVERLAY]=e?"overlay":"source-over",t[n.DARKEN]=e?"darken":"source-over",t[n.LIGHTEN]=e?"lighten":"source-over",t[n.COLOR_DODGE]=e?"color-dodge":"source-over",t[n.COLOR_BURN]=e?"color-burn":"source-over",t[n.HARD_LIGHT]=e?"hard-light":"source-over",t[n.SOFT_LIGHT]=e?"soft-light":"source-over",t[n.DIFFERENCE]=e?"difference":"source-over",t[n.EXCLUSION]=e?"exclusion":"source-over",t[n.HUE]=e?"hue":"source-over",t[n.SATURATION]=e?"saturation":"source-over",t[n.COLOR]=e?"color":"source-over",t[n.LUMINOSITY]=e?"luminosity":"source-over",t}},function(t,e,i){var n=i(0),s=i(19),r=i(127),o=i(41),a=i(372),h=i(373),u=i(374),l=i(165),c=i(166),d=new n({initialize:function(t){var e=this,i={alpha:t.config.transparent,depth:!1,antialias:t.config.antialias,premultipliedAlpha:t.config.transparent,stencil:!0,preserveDrawingBuffer:t.config.preserveDrawingBuffer,failIfMajorPerformanceCaveat:!1,powerPreference:t.config.powerPreference};this.config={clearBeforeRender:t.config.clearBeforeRender,pixelArt:t.config.pixelArt,backgroundColor:t.config.backgroundColor,contextCreation:i,resolution:t.config.resolution,autoResize:t.config.autoResize,roundPixels:t.config.roundPixels},this.game=t,this.type=s.WEBGL,this.width=t.config.width,this.height=t.config.height,this.canvas=t.canvas,this.lostContextCallbacks=[],this.restoredContextCallbacks=[],this.blendModes=[],this.nativeTextures=[],this.contextLost=!1,this.pipelines=null,this.snapshotState={callback:null,type:null,encoder:null},this.currentActiveTextureUnit=0,this.currentTextures=new Array(16),this.currentFramebuffer=null,this.currentPipeline=null,this.currentProgram=null,this.currentVertexBuffer=null,this.currentIndexBuffer=null,this.currentBlendMode=1/0,this.currentScissorEnabled=!1,this.currentScissor=new Uint32Array([0,0,this.width,this.height]),this.currentScissorIdx=0,this.scissorStack=new Uint32Array(4e3),this.canvas.addEventListener("webglcontextlost",function(t){e.contextLost=!0,t.preventDefault();for(var i=0;i=0&&n>=0;if(r[0]===t&&r[1]===e&&r[2]===i&&r[3]===n||this.flush(),r[0]=t,r[1]=e,r[2]=i,r[3]=n,this.currentScissorEnabled=o,!o)return s.enable(s.SCISSOR_TEST),s.scissor(t,s.drawingBufferHeight-e-n,i,n),this;s.disable(s.SCISSOR_TEST)},pushScissor:function(t,e,i,n){var s=this.scissorStack,r=this.currentScissorIdx,o=this.currentScissor;return s[r+0]=o[0],s[r+1]=o[1],s[r+2]=o[2],s[r+3]=o[3],this.currentScissorIdx+=4,this.setScissor(t,e,i,n),this},popScissor:function(){var t=this.scissorStack,e=this.currentScissorIdx-4,i=t[e+0],n=t[e+1],s=t[e+2],r=t[e+3];return this.currentScissorIdx=e,this.setScissor(i,n,s,r),this},setPipeline:function(t){return this.currentPipeline===t&&this.currentPipeline.vertexBuffer===this.currentVertexBuffer&&this.currentPipeline.program===this.currentProgram||(this.flush(),this.currentPipeline=t,this.currentPipeline.bind()),this.currentPipeline.onBind(),this.currentPipeline},setBlendMode:function(t){var e=this.gl,i=this.blendModes[t];return t!==s.BlendModes.SKIP_CHECK&&this.currentBlendMode!==t&&(this.flush(),e.enable(e.BLEND),e.blendEquation(i.equation),i.func.length>2?e.blendFuncSeparate(i.func[0],i.func[1],i.func[2],i.func[3]):e.blendFunc(i.func[0],i.func[1]),this.currentBlendMode=t),this},addBlendMode:function(t,e){return this.blendModes.push({func:t,equation:e})-1},updateBlendMode:function(t,e,i){return this.blendModes[t]&&(this.blendModes[t].func=e,i&&(this.blendModes[t].equation=i)),this},removeBlendMode:function(t){return t>16&&this.blendModes[t]&&this.blendModes.splice(t,1),this},setTexture2D:function(t,e){var i=this.gl;return t!==this.currentTextures[e]&&(this.flush(),this.currentActiveTextureUnit!==e&&(i.activeTexture(i.TEXTURE0+e),this.currentActiveTextureUnit=e),i.bindTexture(i.TEXTURE_2D,t),this.currentTextures[e]=t),this},setFramebuffer:function(t){var e=this.gl;return t!==this.currentFramebuffer&&(this.flush(),e.bindFramebuffer(e.FRAMEBUFFER,t),this.currentFramebuffer=t),this},setProgram:function(t){var e=this.gl;return t!==this.currentProgram&&(this.flush(),e.useProgram(t),this.currentProgram=t),this},setVertexBuffer:function(t){var e=this.gl;return t!==this.currentVertexBuffer&&(this.flush(),e.bindBuffer(e.ARRAY_BUFFER,t),this.currentVertexBuffer=t),this},setIndexBuffer:function(t){var e=this.gl;return t!==this.currentIndexBuffer&&(this.flush(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.currentIndexBuffer=t),this},createTextureFromSource:function(t,e,i,n){var o=this.gl,a=o.NEAREST,h=o.CLAMP_TO_EDGE;return e=t?t.width:e,i=t?t.height:i,r(e,i)&&(h=o.REPEAT),n===s.ScaleModes.LINEAR?a=o.LINEAR:(n===s.ScaleModes.NEAREST||this.config.pixelArt)&&(a=o.NEAREST),t||"number"!=typeof e||"number"!=typeof i?this.createTexture2D(0,a,a,h,h,o.RGBA,t):this.createTexture2D(0,a,a,h,h,o.RGBA,null,e,i)},createTexture2D:function(t,e,i,n,s,r,o,a,h,u){var l=this.gl,c=l.createTexture();return u=null==u||u,this.setTexture2D(c,0),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,e),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,i),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,s),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,n),l.pixelStorei(l.UNPACK_PREMULTIPLY_ALPHA_WEBGL,u),null==o?l.texImage2D(l.TEXTURE_2D,t,r,a,h,0,r,l.UNSIGNED_BYTE,null):(l.texImage2D(l.TEXTURE_2D,t,r,r,l.UNSIGNED_BYTE,o),a=o.width,h=o.height),this.setTexture2D(null,0),c.isAlphaPremultiplied=u,c.isRenderTexture=!1,c.width=a,c.height=h,this.nativeTextures.push(c),c},createFramebuffer:function(t,e,i,n){var s,r=this.gl,o=r.createFramebuffer();if(this.setFramebuffer(o),n){var a=r.createRenderbuffer();r.bindRenderbuffer(r.RENDERBUFFER,a),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t,e),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,a)}if(i.isRenderTexture=!0,i.isAlphaPremultiplied=!1,r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,i,0),(s=r.checkFramebufferStatus(r.FRAMEBUFFER))!==r.FRAMEBUFFER_COMPLETE){throw new Error("Framebuffer incomplete. Framebuffer status: "+{36054:"Incomplete Attachment",36055:"Missing Attachment",36057:"Incomplete Dimensions",36061:"Framebuffer Unsupported"}[s])}return o.renderTexture=i,this.setFramebuffer(null),o},createProgram:function(t,e){var i=this.gl,n=i.createProgram(),s=i.createShader(i.VERTEX_SHADER),r=i.createShader(i.FRAGMENT_SHADER);if(i.shaderSource(s,t),i.shaderSource(r,e),i.compileShader(s),i.compileShader(r),!i.getShaderParameter(s,i.COMPILE_STATUS))throw new Error("Failed to compile Vertex Shader:\n"+i.getShaderInfoLog(s));if(!i.getShaderParameter(r,i.COMPILE_STATUS))throw new Error("Failed to compile Fragment Shader:\n"+i.getShaderInfoLog(r));if(i.attachShader(n,s),i.attachShader(n,r),i.linkProgram(n),!i.getProgramParameter(n,i.LINK_STATUS))throw new Error("Failed to link program:\n"+i.getProgramInfoLog(n));return n},createVertexBuffer:function(t,e){var i=this.gl,n=i.createBuffer();return this.setVertexBuffer(n),i.bufferData(i.ARRAY_BUFFER,t,e),this.setVertexBuffer(null),n},createIndexBuffer:function(t,e){var i=this.gl,n=i.createBuffer();return this.setIndexBuffer(n),i.bufferData(i.ELEMENT_ARRAY_BUFFER,t,e),this.setIndexBuffer(null),n},deleteTexture:function(t){return this.gl.deleteTexture(t),this},deleteFramebuffer:function(t){return this.gl.deleteFramebuffer(t),this},deleteProgram:function(t){return this.gl.deleteProgram(t),this},deleteBuffer:function(t){return this.gl.deleteBuffer(t),this},preRenderCamera:function(t){var e=this.config.resolution;if(this.pushScissor(t.x*e,t.y*e,t.width*e,t.height*e),t.backgroundColor.alphaGL>0){var i=t.backgroundColor,n=this.pipelines.FlatTintPipeline;n.batchFillRect(0,0,1,1,0,t.x,t.y,t.width,t.height,o.getTintFromFloats(i.redGL,i.greenGL,i.blueGL,1),i.alphaGL,1,0,0,1,0,0,[1,0,0,1,0,0]),n.flush()}},postRenderCamera:function(t){if(t._fadeAlpha>0||t._flashAlpha>0){var e=this.pipelines.FlatTintPipeline;e.batchFillRect(0,0,1,1,0,t.x,t.y,t.width,t.height,o.getTintFromFloats(t._fadeRed,t._fadeGreen,t._fadeBlue,1),t._fadeAlpha,1,0,0,1,0,0,[1,0,0,1,0,0]),e.batchFillRect(0,0,1,1,0,t.x,t.y,t.width,t.height,o.getTintFromFloats(t._flashRed,t._flashGreen,t._flashBlue,1),t._flashAlpha,1,0,0,1,0,0,[1,0,0,1,0,0]),e.flush()}this.popScissor()},preRender:function(){if(!this.contextLost){var t=this.gl,e=this.config.backgroundColor,i=this.pipelines;for(var n in t.clearColor(e.redGL,e.greenGL,e.blueGL,e.alphaGL),this.config.clearBeforeRender&&t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT|t.STENCIL_BUFFER_BIT),i)i[n].onPreRender()}},render:function(t,e,i,n){if(!this.contextLost){var r=e.list,o=r.length,a=this.pipelines;for(var h in a)a[h].onRender(t,n);this.preRenderCamera(n);for(var u=0;uthis.vertexCapacity&&this.flush();var x=this.vertexViewF32,w=this.vertexViewU32,b=this.vertexCount*this.vertexComponentCount,T=r+a,A=o+h,S=m[0],C=m[1],M=m[2],E=m[3],_=d*S+f*M,L=d*C+f*E,P=p*S+g*M,F=p*C+g*E,k=v*S+y*M+m[4],O=v*C+y*E+m[5],R=r*_+o*P+k,D=r*L+o*F+O,I=r*_+A*P+k,B=r*L+A*F+O,Y=T*_+A*P+k,X=T*L+A*F+O,z=T*_+o*P+k,N=T*L+o*F+O,G=u.getTintAppendFloatAlphaAndSwap(l,c);x[b+0]=R,x[b+1]=D,w[b+2]=G,x[b+3]=I,x[b+4]=B,w[b+5]=G,x[b+6]=Y,x[b+7]=X,w[b+8]=G,x[b+9]=R,x[b+10]=D,w[b+11]=G,x[b+12]=Y,x[b+13]=X,w[b+14]=G,x[b+15]=z,x[b+16]=N,w[b+17]=G,this.vertexCount+=6},batchFillTriangle:function(t,e,i,n,s,r,o,a,h,l,c,d,f,p,g,v,y,m,x,w){this.renderer.setPipeline(this),this.vertexCount+3>this.vertexCapacity&&this.flush();var b=this.vertexViewF32,T=this.vertexViewU32,A=this.vertexCount*this.vertexComponentCount,S=w[0],C=w[1],M=w[2],E=w[3],_=p*S+g*M,L=p*C+g*E,P=v*S+y*M,F=v*C+y*E,k=m*S+x*M+w[4],O=m*C+x*E+w[5],R=r*_+o*P+k,D=r*L+o*F+O,I=a*_+h*P+k,B=a*L+h*F+O,Y=l*_+c*P+k,X=l*L+c*F+O,z=u.getTintAppendFloatAlphaAndSwap(d,f);b[A+0]=R,b[A+1]=D,T[A+2]=z,b[A+3]=I,b[A+4]=B,T[A+5]=z,b[A+6]=Y,b[A+7]=X,T[A+8]=z,this.vertexCount+=3},batchStrokeTriangle:function(t,e,i,n,s,r,o,a,h,u,l,c,d,f,p,g,v,y,m,x,w){var b=this.tempTriangle;b[0].x=r,b[0].y=o,b[0].width=c,b[0].rgb=d,b[0].alpha=f,b[1].x=a,b[1].y=h,b[1].width=c,b[1].rgb=d,b[1].alpha=f,b[2].x=u,b[2].y=l,b[2].width=c,b[2].rgb=d,b[2].alpha=f,b[3].x=r,b[3].y=o,b[3].width=c,b[3].rgb=d,b[3].alpha=f,this.batchStrokePath(t,e,i,n,s,b,c,d,f,p,g,v,y,m,x,!1,w)},batchFillPath:function(t,e,i,n,s,o,a,h,l,c,d,f,p,g,v){this.renderer.setPipeline(this);for(var y,m,x,w,b,T,A,S,C,M,E,_,L,P,F,k,O,R=o.length,D=this.polygonCache,I=this.vertexViewF32,B=this.vertexViewU32,Y=0,X=v[0],z=v[1],N=v[2],G=v[3],W=l*X+c*N,U=l*z+c*G,V=d*X+f*N,H=d*z+f*G,j=p*X+g*N+v[4],q=p*z+g*G+v[5],K=u.getTintAppendFloatAlphaAndSwap(a,h),J=0;Jthis.vertexCapacity&&this.flush(),Y=this.vertexCount*this.vertexComponentCount,_=(T=D[x+0])*W+(A=D[x+1])*V+j,L=T*U+A*H+q,P=(S=D[w+0])*W+(C=D[w+1])*V+j,F=S*U+C*H+q,k=(M=D[b+0])*W+(E=D[b+1])*V+j,O=M*U+E*H+q,I[Y+0]=_,I[Y+1]=L,B[Y+2]=K,I[Y+3]=P,I[Y+4]=F,B[Y+5]=K,I[Y+6]=k,I[Y+7]=O,B[Y+8]=K,this.vertexCount+=3;D.length=0},batchStrokePath:function(t,e,i,n,s,r,o,a,h,l,c,d,f,p,g,v,y){var m,x;this.renderer.setPipeline(this);for(var w,b,T,A,S=r.length,C=this.polygonCache,M=this.vertexViewF32,E=this.vertexViewU32,_=u.getTintAppendFloatAlphaAndSwap,L=0;L+1this.vertexCapacity&&this.flush(),w=C[P-1]||C[F-1],b=C[P],M[(T=this.vertexCount*this.vertexComponentCount)+0]=w[6],M[T+1]=w[7],E[T+2]=_(w[8],h),M[T+3]=w[0],M[T+4]=w[1],E[T+5]=_(w[2],h),M[T+6]=b[9],M[T+7]=b[10],E[T+8]=_(b[11],h),M[T+9]=w[0],M[T+10]=w[1],E[T+11]=_(w[2],h),M[T+12]=w[6],M[T+13]=w[7],E[T+14]=_(w[8],h),M[T+15]=b[3],M[T+16]=b[4],E[T+17]=_(b[5],h),this.vertexCount+=6;C.length=0},batchLine:function(t,e,i,n,s,r,o,a,h,l,c,d,f,p,g,v,y,m,x,w,b){this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var T=b[0],A=b[1],S=b[2],C=b[3],M=g*T+v*S,E=g*A+v*C,_=y*T+m*S,L=y*A+m*C,P=x*T+w*S+b[4],F=x*A+w*C+b[5],k=this.vertexViewF32,O=this.vertexViewU32,R=a-r,D=h-o,I=Math.sqrt(R*R+D*D),B=l*(h-o)/I,Y=l*(r-a)/I,X=c*(h-o)/I,z=c*(r-a)/I,N=a-X,G=h-z,W=r-B,U=o-Y,V=a+X,H=h+z,j=r+B,q=o+Y,K=N*M+G*_+P,J=N*E+G*L+F,Z=W*M+U*_+P,Q=W*E+U*L+F,$=V*M+H*_+P,tt=V*E+H*L+F,et=j*M+q*_+P,it=j*E+q*L+F,nt=u.getTintAppendFloatAlphaAndSwap,st=nt(d,p),rt=nt(f,p),ot=this.vertexCount*this.vertexComponentCount;return k[ot+0]=K,k[ot+1]=J,O[ot+2]=rt,k[ot+3]=Z,k[ot+4]=Q,O[ot+5]=st,k[ot+6]=$,k[ot+7]=tt,O[ot+8]=rt,k[ot+9]=Z,k[ot+10]=Q,O[ot+11]=st,k[ot+12]=et,k[ot+13]=it,O[ot+14]=st,k[ot+15]=$,k[ot+16]=tt,O[ot+17]=rt,this.vertexCount+=6,[K,J,f,Z,Q,d,$,tt,f,et,it,d]},batchGraphics:function(t,e){if(!(t.commandBuffer.length<=0)){this.renderer.setPipeline(this);var i,n,r=e.scrollX*t.scrollFactorX,o=e.scrollY*t.scrollFactorY,a=t.x-r,h=t.y-o,u=t.scaleX,l=t.scaleY,y=-t.rotation,m=t.commandBuffer,x=1,w=1,b=0,T=0,A=1,S=e.matrix.matrix,C=null,M=0,E=0,_=0,L=0,P=0,F=0,k=0,O=0,R=0,D=0,I=null,B=Math.sin,Y=Math.cos,X=2*Math.PI,z=B(y),N=Y(y),G=N*u,W=-z*u,U=z*l,V=N*l,H=a,j=h,q=S[0],K=S[1],J=S[2],Z=S[3],Q=G*q+W*J,$=G*K+W*Z,tt=U*q+V*J,et=U*K+V*Z,it=H*q+j*J+S[4],nt=H*K+j*Z+S[5];v.length=0;for(var st=0,rt=m.length;st0&&(R=R%X-X):R>X?R=X:R<0&&(R=X+R%X);M<1;)E=P+Y(L=R*M+O)*k,_=F+B(L)*k,C.points.push(new c(E,_,A,b,x)),M+=.01;E=P+Y(L=R+O)*k,_=F+B(L)*k,C.points.push(new c(E,_,A,b,x)),st+=6;break;case s.LINE_STYLE:A=m[st+1],b=m[st+2],x=m[st+3],st+=3;break;case s.FILL_STYLE:T=m[st+1],w=m[st+2],st+=2;break;case s.BEGIN_PATH:v.length=0,C=null;break;case s.CLOSE_PATH:C&&C.points.length&&C.points.push(C.points[0]);break;case s.FILL_PATH:for(i=0,n=v.length;i>>0;if("function"!=typeof t)throw new TypeError;for(var n=arguments.length>=2?arguments[1]:void 0,s=0;s>>0,i=(e*=i)>>>0,i+=4294967296*(e-=i);return this.n=i,2.3283064365386963e-10*(i>>>0)},init:function(t){"string"==typeof t?this.state(t):this.sow(t)},sow:function(t){if(this.n=4022871197,this.s0=this.hash(" "),this.s1=this.hash(" "),this.s2=this.hash(" "),this.c=1,t)for(var e=0;e=0&&(this._blendMode=t)}},setBlendMode:function(t){return this.blendMode=t,this}};t.exports=s},function(t,e){t.exports={width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.width},set:function(t){this.scaleX=t/this.width}},displayHeight:{get:function(){return this.scaleY*this.height},set:function(t){this.scaleY=t/this.height}}}},function(t,e){var i={_depth:0,depth:{get:function(){return this._depth},set:function(t){this.scene.sys.queueDepthSort(),this._depth=t}},setDepth:function(t){return void 0===t&&(t=0),this.depth=t,this}};t.exports=i},function(t,e){t.exports={flipX:!1,flipY:!1,toggleFlipX:function(){return this.flipX=!this.flipX,this},toggleFlipY:function(){return this.flipY=!this.flipY,this},setFlipX:function(t){return this.flipX=t,this},setFlipY:function(t){return this.flipY=t,this},setFlip:function(t,e){return this.flipX=t,this.flipY=e,this},resetFlip:function(){return this.flipX=!1,this.flipY=!1,this}}},function(t,e,i){var n=i(8),s=i(188),r=i(6),o={getCenter:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth/2,t.y=this.y-this.displayHeight*this.originY+this.displayHeight/2,t},getTopLeft:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY,0!==this.rotation&&s(t,this.x,this.y,this.rotation),t},getTopRight:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY,0!==this.rotation&&s(t,this.x,this.y,this.rotation),t},getBottomLeft:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,0!==this.rotation&&s(t,this.x,this.y,this.rotation),t},getBottomRight:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,0!==this.rotation&&s(t,this.x,this.y,this.rotation),t},getBounds:function(t){void 0===t&&(t=new n),this.getTopLeft(t);var e=t.x,i=t.y;this.getTopRight(t);var s=t.x,r=t.y;this.getBottomLeft(t);var o=t.x,a=t.y;this.getBottomRight(t);var h=t.x,u=t.y;return t.x=Math.min(e,s,o,h),t.y=Math.min(i,r,a,u),t.width=Math.max(e,s,o,h)-t.x,t.height=Math.max(i,r,a,u)-t.y,t}};t.exports=o},function(t,e){var i={matrixStack:null,currentMatrix:null,currentMatrixIndex:0,initMatrixStack:function(){return this.matrixStack=new Float32Array(6e3),this.currentMatrix=new Float32Array([1,0,0,1,0,0]),this.currentMatrixIndex=0,this},save:function(){if(this.currentMatrixIndex>=this.matrixStack.length)return this;var t=this.matrixStack,e=this.currentMatrix,i=this.currentMatrixIndex;return this.currentMatrixIndex+=6,t[i+0]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=e[3],t[i+4]=e[4],t[i+5]=e[5],this},restore:function(){if(this.currentMatrixIndex<=0)return this;this.currentMatrixIndex-=6;var t=this.matrixStack,e=this.currentMatrix,i=this.currentMatrixIndex;return e[0]=t[i+0],e[1]=t[i+1],e[2]=t[i+2],e[3]=t[i+3],e[4]=t[i+4],e[5]=t[i+5],this},loadIdentity:function(){return this.setTransform(1,0,0,1,0,0),this},transform:function(t,e,i,n,s,r){var o=this.currentMatrix,a=o[0],h=o[1],u=o[2],l=o[3],c=o[4],d=o[5];return o[0]=a*t+u*e,o[1]=h*t+l*e,o[2]=a*i+u*n,o[3]=h*i+l*n,o[4]=a*s+u*r+c,o[5]=h*s+l*r+d,this},setTransform:function(t,e,i,n,s,r){var o=this.currentMatrix;return o[0]=t,o[1]=e,o[2]=i,o[3]=n,o[4]=s,o[5]=r,this},translate:function(t,e){var i=this.currentMatrix,n=i[0],s=i[1],r=i[2],o=i[3],a=i[4],h=i[5];return i[4]=n*t+r*e+a,i[5]=s*t+o*e+h,this},scale:function(t,e){var i=this.currentMatrix,n=i[0],s=i[1],r=i[2],o=i[3];return i[0]=n*t,i[1]=s*t,i[2]=r*e,i[3]=o*e,this},rotate:function(t){var e=this.currentMatrix,i=e[0],n=e[1],s=e[2],r=e[3],o=Math.sin(t),a=Math.cos(t);return e[0]=i*a+s*o,e[1]=n*a+r*o,e[2]=i*-o+s*a,e[3]=n*-o+r*a,this}};t.exports=i},function(t,e){var i={_originComponent:!0,originX:.5,originY:.5,_displayOriginX:0,_displayOriginY:0,displayOriginX:{get:function(){return this._displayOriginX},set:function(t){this._displayOriginX=t,this.originX=t/this.width}},displayOriginY:{get:function(){return this._displayOriginY},set:function(t){this._displayOriginY=t,this.originY=t/this.height}},setOrigin:function(t,e){return void 0===t&&(t=.5),void 0===e&&(e=t),this.originX=t,this.originY=e,this.updateDisplayOrigin()},setOriginFromFrame:function(){return this.frame&&this.frame.customPivot?(this.originX=this.frame.pivotX,this.originY=this.frame.pivotY,this.updateDisplayOrigin()):this.setOrigin()},setDisplayOrigin:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.displayOriginX=t,this.displayOriginY=e,this},updateDisplayOrigin:function(){return this._displayOriginX=Math.round(this.originX*this.width),this._displayOriginY=Math.round(this.originY*this.height),this}};t.exports=i},function(t,e,i){var n=i(63),s={_scaleMode:n.DEFAULT,scaleMode:{get:function(){return this._scaleMode},set:function(t){t!==n.LINEAR&&t!==n.NEAREST||(this._scaleMode=t)}},setScaleMode:function(t){return this.scaleMode=t,this}};t.exports=s},function(t,e){var i={scrollFactorX:1,scrollFactorY:1,setScrollFactor:function(t,e){return void 0===e&&(e=t),this.scrollFactorX=t,this.scrollFactorY=e,this}};t.exports=i},function(t,e){var i={_sizeComponent:!0,width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.frame.realWidth},set:function(t){this.scaleX=t/this.frame.realWidth}},displayHeight:{get:function(){return this.scaleY*this.frame.realHeight},set:function(t){this.scaleY=t/this.frame.realHeight}},setSizeToFrame:function(t){return void 0===t&&(t=this.frame),this.width=t.realWidth,this.height=t.realHeight,this},setSize:function(t,e){return this.width=t,this.height=e,this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}};t.exports=i},function(t,e){var i={texture:null,frame:null,setTexture:function(t,e){return this.texture=this.scene.sys.textures.get(t),this.setFrame(e)},setFrame:function(t,e,i){return void 0===e&&(e=!0),void 0===i&&(i=!0),this.frame=this.texture.get(t),this.frame.cutWidth&&this.frame.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,this._sizeComponent&&e&&this.setSizeToFrame(),this._originComponent&&i&&(this.frame.customPivot?this.setOrigin(this.frame.pivotX,this.frame.pivotY):this.updateDisplayOrigin()),this}};t.exports=i},function(t,e){var i=function(t){return(t>>16)+(65280&t)+((255&t)<<16)},n={_tintTL:16777215,_tintTR:16777215,_tintBL:16777215,_tintBR:16777215,clearTint:function(){return this.setTint(16777215),this},setTint:function(t,e,n,s){return void 0===t&&(t=16777215),void 0===e&&(e=t,n=t,s=t),this._tintTL=i(t),this._tintTR=i(e),this._tintBL=i(n),this._tintBR=i(s),this},tintTopLeft:{get:function(){return this._tintTL},set:function(t){this._tintTL=i(t)}},tintTopRight:{get:function(){return this._tintTR},set:function(t){this._tintTR=i(t)}},tintBottomLeft:{get:function(){return this._tintBL},set:function(t){this._tintBL=i(t)}},tintBottomRight:{get:function(){return this._tintBR},set:function(t){this._tintBR=i(t)}},tint:{set:function(t){this.setTint(t,t,t,t)}}};t.exports=n},function(t,e){t.exports=function(t){var e={name:t.name,type:t.type,x:t.x,y:t.y,depth:t.depth,scale:{x:t.scaleX,y:t.scaleY},origin:{x:t.originX,y:t.originY},flipX:t.flipX,flipY:t.flipY,rotation:t.rotation,alpha:t.alpha,visible:t.visible,scaleMode:t.scaleMode,blendMode:t.blendMode,textureKey:"",frameKey:"",data:{}};return t.texture&&(e.textureKey=t.texture.key,e.frameKey=t.frame.name),e}},function(t,e,i){var n=i(16),s=i(163),r=i(164),o={_scaleX:1,_scaleY:1,_rotation:0,x:0,y:0,z:0,w:0,scaleX:{get:function(){return this._scaleX},set:function(t){this._scaleX=t,0===this._scaleX?this.renderFlags&=-5:this.renderFlags|=4}},scaleY:{get:function(){return this._scaleY},set:function(t){this._scaleY=t,0===this._scaleY?this.renderFlags&=-5:this.renderFlags|=4}},angle:{get:function(){return r(this._rotation*n.RAD_TO_DEG)},set:function(t){this.rotation=r(t)*n.DEG_TO_RAD}},rotation:{get:function(){return this._rotation},set:function(t){this._rotation=s(t)}},setPosition:function(t,e,i,n){return void 0===t&&(t=0),void 0===e&&(e=t),void 0===i&&(i=0),void 0===n&&(n=0),this.x=t,this.y=e,this.z=i,this.w=n,this},setRotation:function(t){return void 0===t&&(t=0),this.rotation=t,this},setAngle:function(t){return void 0===t&&(t=0),this.angle=t,this},setScale:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.scaleX=t,this.scaleY=e,this},setX:function(t){return void 0===t&&(t=0),this.x=t,this},setY:function(t){return void 0===t&&(t=0),this.y=t,this},setZ:function(t){return void 0===t&&(t=0),this.z=t,this},setW:function(t){return void 0===t&&(t=0),this.w=t,this}};t.exports=o},function(t,e){var i={_visible:!0,visible:{get:function(){return this._visible},set:function(t){t?(this._visible=!0,this.renderFlags|=1):(this._visible=!1,this.renderFlags&=-2)}},setVisible:function(t){return this.visible=t,this}};t.exports=i},function(t,e){t.exports=function(t,e){for(var i=0;i0?s(o,i):i<0&&r(o,Math.abs(i));for(var a=0;a1)if(0===s){var d=t.length-1;for(o=t[d].x,a=t[d].y,h=d-1;h>=0;h--)u=(c=t[h]).x,l=c.y,c.x=o,c.y=a,o=u,a=l;t[d].x=e,t[d].y=i}else{for(o=t[0].x,a=t[0].y,h=1;h0?(this._speedX-=this.dragX*t,this._speedX<0&&(this._speedX=0)):this._speedX<0&&(this._speedX+=this.dragX*t,this._speedX>0&&(this._speedX=0)),this._speedY>0?(this._speedY-=this.dragY*t,this._speedY<0&&(this._speedY=0)):this._speedY<0&&(this._speedY+=this.dragY*t,this._speedY>0&&(this._speedY=0)),this.up&&this.up.isDown?(this._speedY+=this.accelY,this._speedY>this.maxSpeedY&&(this._speedY=this.maxSpeedY)):this.down&&this.down.isDown&&(this._speedY-=this.accelY,this._speedY<-this.maxSpeedY&&(this._speedY=-this.maxSpeedY)),this.left&&this.left.isDown?(this._speedX+=this.accelX,this._speedX>this.maxSpeedX&&(this._speedX=this.maxSpeedX)):this.right&&this.right.isDown&&(this._speedX-=this.accelX,this._speedX<-this.maxSpeedX&&(this._speedX=-this.maxSpeedX)),this.zoomIn&&this.zoomIn.isDown?this._zoom=-this.zoomSpeed:this.zoomOut&&this.zoomOut.isDown?this._zoom=this.zoomSpeed:this._zoom=0,0!==this._speedX&&(e.scrollX-=this._speedX*t|0),0!==this._speedY&&(e.scrollY-=this._speedY*t|0),0!==this._zoom&&(e.zoom+=this._zoom,e.zoom<.1&&(e.zoom=.1))}},destroy:function(){this.camera=null,this.left=null,this.right=null,this.up=null,this.down=null,this.zoomIn=null,this.zoomOut=null}});t.exports=r},function(t,e,i){t.exports={Camera:i(115),CameraManager:i(455)}},function(t,e,i){var n=i(115),s=i(0),r=i(2),o=i(12),a=i(33),h=new s({initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),this.currentCameraId=1,this.cameras=[],this.cameraPool=[],t.sys.settings.cameras?this.fromJSON(t.sys.settings.cameras):this.add(),this.main=this.cameras[0],this.baseScale=1},boot:function(){var t=this.systems.events;t.on("update",this.update,this),t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},add:function(t,e,i,s,r,o){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.scene.sys.game.config.width),void 0===s&&(s=this.scene.sys.game.config.height),void 0===r&&(r=!1),void 0===o&&(o="");var a=null;return this.cameraPool.length>0?(a=this.cameraPool.pop()).setViewport(t,e,i,s):a=new n(t,e,i,s),a.setName(o),a.setScene(this.scene),this.cameras.push(a),r&&(this.main=a),a._id=this.currentCameraId,this.currentCameraId=this.currentCameraId<<1,a},addExisting:function(t){var e=this.cameras.indexOf(t),i=this.cameraPool.indexOf(t);return e<0&&i>=0?(this.cameras.push(t),this.cameraPool.slice(i,1),t):null},fromJSON:function(t){Array.isArray(t)||(t=[t]);for(var e=this.scene.sys.game.config.width,i=this.scene.sys.game.config.height,n=0;n=0;i--){var n=e[i];if(n.inputEnabled&&a(n,t.x,t.y))return n}},remove:function(t){var e=this.cameras.indexOf(t);e>=0&&this.cameras.length>1&&(this.cameraPool.push(this.cameras[e]),this.cameras.splice(e,1),this.main===t&&(this.main=this.cameras[0]))},render:function(t,e,i){for(var n=this.cameras,s=this.baseScale,r=0,o=n.length;r0;)this.cameraPool.push(this.cameras.pop());return this.main=this.add(),this.main},update:function(t,e){for(var i=0,n=this.cameras.length;i0&&e.cameraFilter&s._id||this.pipeline.batchSprite(e,s)}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||t.drawImage(e,s)}},function(t,e,i){var n=i(0),s=i(214),r=i(215),o=i(12),a=new n({initialize:function(t){this.scene=t,this.systems=t.sys,this.cameras=[],t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this)},boot:function(){var t=this.systems.events;t.on("update",this.update,this),t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},add:function(t,e,i){return this.addPerspectiveCamera(t,e,i)},addOrthographicCamera:function(t,e){var i=this.scene.sys.game.config;void 0===t&&(t=i.width),void 0===e&&(e=i.height);var n=new s(this.scene,t,e);return this.cameras.push(n),n},addPerspectiveCamera:function(t,e,i){var n=this.scene.sys.game.config;void 0===t&&(t=80),void 0===e&&(e=n.width),void 0===i&&(i=n.height);var s=new r(this.scene,t,e,i);return this.cameras.push(s),s},getCamera:function(t){return this.cameras.forEach(function(e){if(e.name===t)return e}),null},removeCamera:function(t){var e=this.cameras.indexOf(t);-1!==e&&this.cameras.splice(e,1)},removeAll:function(){for(;this.cameras.length>0;){this.cameras.pop().destroy()}return this.main},update:function(t,e){for(var i=0,n=this.cameras.length;i0?this.curves[this.curves.length-1].getPoint(1,t):t.copy(this.startPoint),t},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},getPoint:function(t,e){void 0===e&&(e=new d);for(var i=t*this.getLength(),n=this.getCurveLengths(),s=0;s=i){var r=n[s]-i,o=this.curves[s],a=o.getLength(),h=0===a?0:1-r/a;return o.getPointAt(h,e)}s++}return null},getPoints:function(t){void 0===t&&(t=12);for(var e,i=[],n=0;n1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i},getRandomPoint:function(t){return void 0===t&&(t=new d),this.getPoint(Math.random(),t)},getSpacedPoints:function(t){void 0===t&&(t=40);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return this.autoClose&&e.push(e[0]),e},getStartPoint:function(t){return void 0===t&&(t=new d),t.copy(this.startPoint)},lineTo:function(t,e){t instanceof d?this._tmpVec2B.copy(t):this._tmpVec2B.set(t,e);var i=this.getEndPoint(this._tmpVec2A);return this.add(new a([i.x,i.y,this._tmpVec2B.x,this._tmpVec2B.y]))},splineTo:function(t){return t.unshift(this.getEndPoint()),this.add(new c(t))},moveTo:function(t,e){return this.add(new h(t,e))},toJSON:function(){for(var t=[],e=0;e>16&255,g:t>>8&255,b:255&t,a:255};return t>16777215&&(e.a=t>>>24),e}},function(t,e,i){var n=i(36),s=i(229);t.exports=function(t,e,i){var r=i,o=i,a=i;if(0!==e){var h=i<.5?i*(1+e):i+e-i*e,u=2*i-h;r=s(u,h,t+1/3),o=s(u,h,t),a=s(u,h,t-1/3)}return(new n).setGLTo(r,o,a,1)}},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,i){var n=i(230);t.exports=function(t,e){void 0===t&&(t=1),void 0===e&&(e=1);for(var i=[],s=0;s<=359;s++)i.push(n(s/359,t,e));return i}},function(t,e,i){var n=i(124),s=function(t,e,i,s,r,o,a,h){void 0===a&&(a=100),void 0===h&&(h=0);var u=h/a;return{r:n(t,s,u),g:n(e,r,u),b:n(i,o,u)}};t.exports={RGBWithRGB:s,ColorWithRGB:function(t,e,i,n,r,o){return void 0===r&&(r=100),void 0===o&&(o=0),s(t.r,t.g,t.b,e,i,n,r,o)},ColorWithColor:function(t,e,i,n){return void 0===i&&(i=100),void 0===n&&(n=0),s(t.r,t.g,t.b,e.r,e.g,e.b,i,n)}}},function(t,e,i){var n=i(231),s=i(36);t.exports=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=255),new s(n(t,e),n(t,e),n(t,e))}},function(t,e){t.exports=function(t,e,i){t/=255,e/=255,i/=255;var n=Math.min(t,e,i),s=Math.max(t,e,i),r=s-n,o=0;return s!==n&&(s===t?o=(e-i)/r+(e1)for(var i=1;i=1)&&(r.touch=!0),(navigator.msPointerEnabled||navigator.pointerEnabled)&&(r.mspointer=!0),navigator.getGamepads&&(r.gamepads=!0),n.cocoonJS||("onwheel"in window||s.ie&&"WheelEvent"in window?r.wheelEvent="wheel":"onmousewheel"in window?r.wheelEvent="mousewheel":s.firefox&&"MouseScrollEvent"in window&&(r.wheelEvent="DOMMouseScroll")),r)},function(t,e,i){var n=i(82),s={audioData:!1,dolby:!1,m4a:!1,mp3:!1,ogg:!1,opus:!1,wav:!1,webAudio:!1,webm:!1};t.exports=function(){s.audioData=!!window.Audio,s.webAudio=!(!window.AudioContext&&!window.webkitAudioContext);var t=document.createElement("audio"),e=!!t.canPlayType;try{if(e&&(t.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(s.ogg=!0),(t.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,"")||t.canPlayType("audio/opus;").replace(/^no$/,""))&&(s.opus=!0),t.canPlayType("audio/mpeg;").replace(/^no$/,"")&&(s.mp3=!0),t.canPlayType('audio/wav; codecs="1"').replace(/^no$/,"")&&(s.wav=!0),(t.canPlayType("audio/x-m4a;")||t.canPlayType("audio/aac;").replace(/^no$/,""))&&(s.m4a=!0),t.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")&&(s.webm=!0),""!==t.canPlayType('audio/mp4;codecs="ec-3"')))if(n.edge)s.dolby=!0;else if(n.safari&&n.safariVersion>=9&&/Mac OS X (\d+)_(\d+)/.test(navigator.userAgent)){var i=parseInt(RegExp.$1,10),r=parseInt(RegExp.$2,10);(10===i&&r>=11||i>10)&&(s.dolby=!0)}}catch(t){}return s}()},function(t,e){var i={h264Video:!1,hlsVideo:!1,mp4Video:!1,oggVideo:!1,vp9Video:!1,webmVideo:!1};t.exports=function(){var t=document.createElement("video"),e=!!t.canPlayType;try{e&&(t.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,"")&&(i.oggVideo=!0),t.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,"")&&(i.h264Video=!0,i.mp4Video=!0),t.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")&&(i.webmVideo=!0),t.canPlayType('video/webm; codecs="vp9"').replace(/^no$/,"")&&(i.vp9Video=!0),t.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(/^no$/,"")&&(i.hlsVideo=!0))}catch(t){}return i}()},function(t,e){var i={available:!1,cancel:"",keyboard:!1,request:""};t.exports=function(){var t,e=["requestFullscreen","requestFullScreen","webkitRequestFullscreen","webkitRequestFullScreen","msRequestFullscreen","msRequestFullScreen","mozRequestFullScreen","mozRequestFullscreen"],n=document.createElement("div");for(t=0;t0&&e.maxKeyDelay>0){var r=e.timeLastMatched+e.maxKeyDelay;t.timeStamp<=r&&(s=!0,i=n(t,e))}else s=!0,i=n(t,e);return!s&&e.resetOnWrongKey&&(e.index=0,e.current=e.keyCodes[0]),i&&(e.timeLastMatched=t.timeStamp,e.matched=!0,e.timeMatched=t.timeStamp),i}},function(t,e){t.exports=function(t,e){return e.timeLastMatched=t.timeStamp,e.index++,e.index===e.size||(e.current=e.keyCodes[e.index],!1)}},function(t,e){t.exports=function(t){return t.current=t.keyCodes[0],t.index=0,t.timeLastMatched=0,t.matched=!1,t.timeMatched=0,t}},function(t,e,i){var n=i(129),s={};for(var r in n)s[n[r]]=r;t.exports=s},function(t,e){t.exports=function(t,e){if(t.originalEvent=e,t.preventDefault&&e.preventDefault(),t.enabled)return t.altKey=e.altKey,t.ctrlKey=e.ctrlKey,t.shiftKey=e.shiftKey,t.location=e.location,!1===t.isDown&&(t.isDown=!0,t.isUp=!1,t.timeDown=e.timeStamp,t.duration=0),t.repeats++,t._justDown=!0,t._justUp=!1,t}},function(t,e){t.exports=function(t,e){if(t.originalEvent=e,t.preventDefault&&e.preventDefault(),t.enabled)return t.isDown=!1,t.isUp=!0,t.timeUp=e.timeStamp,t.duration=t.timeUp-t.timeDown,t.repeats=0,t._justDown=!1,t._justUp=!0,t}},function(t,e,i){var n=i(2),s=i(254);t.exports=function(t){var e=t.game.config.defaultPhysicsSystem,i=n(t.settings,"physics",!1);if(e||i){var r=[];if(e&&r.push(s(e+"Physics")),i)for(var o in i)o=s(o.concat("Physics")),-1===r.indexOf(o)&&r.push(o);return r}}},function(t,e,i){var n=i(2);t.exports=function(t){var e=t.game.config.defaultPlugins,i=n(t.settings,"plugins",!1);return Array.isArray(i)?i:e||[]}},function(t,e){t.exports={game:"game",anims:"anims",cache:"cache",registry:"registry",sound:"sound",textures:"textures",events:"events",cameras:"cameras",cameras3d:"cameras3d",add:"add",make:"make",scenePlugin:"scene",displayList:"children",lights:"lights",data:"data",input:"input",load:"load",time:"time",tweens:"tweens",arcadePhysics:"physics",impactPhysics:"impact",matterPhysics:"matter"}},function(t,e){t.exports=function(t,e){var i=t.source[e];return t.add("__BASE",e,0,0,i.width,i.height),t}},function(t,e){t.exports=function(t,e){var i=t.source[e];return t.add("__BASE",e,0,0,i.width,i.height),t}},function(t,e,i){var n=i(53);t.exports=function(t,e,i){if(i.frames||i.textures){var s=t.source[e];t.add("__BASE",e,0,0,s.width,s.height);for(var r,o=Array.isArray(i.textures)?i.textures[e].frames:i.frames,a=0;ag||c<-g)&&(c=0),c<0&&(c=g+c),-1!==d&&(g=c+(d+1));for(var v=f,y=f,m=0,x=0,w=0;wr&&(m=b-r),T>o&&(x=T-o),t.add(w,e,i+v,s+y,h-m,u-x),(v+=h+p)+h>r&&(v=f,y+=u+p)}return t}},function(t,e,i){var n=i(2);t.exports=function(t,e,i){var s=n(i,"frameWidth",null),r=n(i,"frameHeight",s);if(!s)throw new Error("TextureManager.SpriteSheetFromAtlas: Invalid frameWidth given.");var o,a=n(i,"startFrame",0),h=n(i,"endFrame",-1),u=n(i,"margin",0),l=n(i,"spacing",0),c=e.cutX,d=e.cutY,f=e.cutWidth,p=e.cutHeight,g=e.realWidth,v=e.realHeight,y=Math.floor((g-u+l)/(s+l)),m=Math.floor((v-u+l)/(r+l)),x=y*m,w=e.x,b=s-w,T=s-(g-f-w),A=e.y,S=r-A,C=r-(v-p-A);(a>x||a<-x)&&(a=0),a<0&&(a=x+a),-1!==h&&(x=a+(h+1));for(var M=u,E=u,_=0,L=e.sourceIndex,P=0;P0||!this.inFocus)&&(this._coolDown--,s=Math.min(s,this._target)),s>this._min&&(s=i[e],s=Math.min(s,this._min)),i[e]=s,this.deltaIndex++,this.deltaIndex>n&&(this.deltaIndex=0);for(var r=0,o=0;othis.nextFpsUpdate&&(this.actualFps=.25*this.framesThisSecond+.75*this.actualFps,this.nextFpsUpdate=t+1e3,this.framesThisSecond=0),this.framesThisSecond++;var a=r/this._target;this.callback(t,r,a),this.lastTime=t},tick:function(){this.step(window.performance.now())},sleep:function(){this.running&&(this.raf.stop(),this.running=!1)},wake:function(t){this.running?this.sleep():t&&(this.startTime+=-this.lastTime+(this.lastTime=window.performance.now())),this.raf.start(this.step.bind(this),this.useRAF),this.running=!0,this.step(window.performance.now())},stop:function(){return this.running=!1,this.started=!1,this.raf.stop(),this},destroy:function(){this.stop(),this.callback=r,this.raf=null,this.game=null}});t.exports=a},function(t,e){t.exports=function(t){var e;void 0!==document.hidden?e="visibilitychange":["webkit","moz","ms"].forEach(function(t){void 0!==document[t+"Hidden"]&&(document.hidden=function(){return document[t+"Hidden"]},e=t+"visibilitychange")});e&&document.addEventListener(e,function(e){document.hidden||"pause"===e.type?t.emit("hidden"):t.emit("visible")},!1),window.onblur=function(){t.emit("blur")},window.onfocus=function(){t.emit("focus")}}},function(t,e,i){var n={DisplayList:i(545),GameObjectCreator:i(13),GameObjectFactory:i(9),UpdateList:i(546),Components:i(11),BuildGameObject:i(20),BuildGameObjectAnimation:i(132),GameObject:i(1),BitmapText:i(133),Blitter:i(134),DynamicBitmapText:i(135),Graphics:i(136),Group:i(69),Image:i(70),Particles:i(139),PathFollower:i(290),RenderTexture:i(141),Sprite3D:i(81),Sprite:i(37),Text:i(142),TileSprite:i(143),Zone:i(77),Factories:{Blitter:i(630),DynamicBitmapText:i(631),Graphics:i(632),Group:i(633),Image:i(634),Particles:i(635),PathFollower:i(636),RenderTexture:i(637),Sprite3D:i(638),Sprite:i(639),StaticBitmapText:i(640),Text:i(641),TileSprite:i(642),Zone:i(643)},Creators:{Blitter:i(644),DynamicBitmapText:i(645),Graphics:i(646),Group:i(647),Image:i(648),Particles:i(649),RenderTexture:i(650),Sprite3D:i(651),Sprite:i(652),StaticBitmapText:i(653),Text:i(654),TileSprite:i(655),Zone:i(656)}};n.Mesh=i(88),n.Quad=i(144),n.Factories.Mesh=i(660),n.Factories.Quad=i(661),n.Creators.Mesh=i(662),n.Creators.Quad=i(663),n.Light=i(292),i(293),i(664),t.exports=n},function(t,e,i){var n=i(0),s=i(86),r=i(12),o=i(267),a=new n({Extends:s,initialize:function(t){s.call(this,t),this.sortChildrenFlag=!1,this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this)},boot:function(){var t=this.systems.events;t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},queueDepthSort:function(){this.sortChildrenFlag=!0},depthSort:function(){this.sortChildrenFlag&&(o.inplace(this.list,this.sortByDepth),this.sortChildrenFlag=!1)},sortByDepth:function(t,e){return t._depth-e._depth},sortGameObjects:function(t){return void 0===t&&(t=this.list),this.scene.sys.depthSort(),t.sort(this.sortIndexHandler.bind(this))},getTopGameObject:function(t){return this.sortGameObjects(t),t[t.length-1]}});r.register("DisplayList",a,"displayList"),t.exports=a},function(t,e,i){var n=i(0),s=i(12),r=new n({initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),this._list=[],this._pendingInsertion=[],this._pendingRemoval=[]},boot:function(){var t=this.systems.events;t.on("preupdate",this.preUpdate,this),t.on("update",this.update,this),t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},add:function(t){return-1===this._list.indexOf(t)&&-1===this._pendingInsertion.indexOf(t)&&this._pendingInsertion.push(t),t},preUpdate:function(){var t=this._pendingRemoval.length,e=this._pendingInsertion.length;if(0!==t||0!==e){var i,n;for(i=0;i-1&&this._list.splice(s,1)}this._list=this._list.concat(this._pendingInsertion.splice(0)),this._pendingRemoval.length=0,this._pendingInsertion.length=0}},update:function(t,e){for(var i=0;ia.length&&(f=a.length);for(var p=u,g=l,v={retroFont:!0,font:h,size:i,lineHeight:s,chars:{}},y=0,m=0;m?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",s.TEXT_SET2=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ",s.TEXT_SET3="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",s.TEXT_SET4="ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",s.TEXT_SET5="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789",s.TEXT_SET6="ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ",s.TEXT_SET7="AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39",s.TEXT_SET8="0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ",s.TEXT_SET9="ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!",s.TEXT_SET10="ABCDEFGHIJKLMNOPQRSTUVWXYZ",s.TEXT_SET11="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789",t.exports=s},function(t,e,i){var n=i(3),s=i(3);n=i(550),s=i(551),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){var r=e.text.length;n.RENDER_MASK!==e.renderFlags||0===r||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchBitmapText(this,s)}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){var r=e.text,o=r.length;if(!(n.RENDER_MASK!==e.renderFlags||0===o||e.cameraFilter>0&&e.cameraFilter&s._id)){var a=e.frame,h=e.fontData.chars,u=e.fontData.lineHeight,l=0,c=0,d=0,f=0,p=null,g=0,v=0,y=0,m=0,x=0,w=0,b=null,T=0,A=t.currentContext,S=e.frame.source.image,C=a.cutX,M=a.cutY,E=e.fontSize/e.fontData.size;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,A.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,A.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var _=t.config.roundPixels,L=e.x-s.scrollX*e.scrollFactorX+e.frame.x,P=e.y-s.scrollY*e.scrollFactorY+e.frame.y;_&&(L|=0,P|=0),A.save(),A.translate(L,P),A.rotate(e.rotation),A.translate(-e.displayOriginX,-e.displayOriginY),A.scale(e.scaleX,e.scaleY);for(var F=0;F0&&e.cameraFilter&s._id||this.pipeline.drawBlitter(e,s)}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){var r=e.getRenderList();t.setBlendMode(e.blendMode);for(var o=t.gameContext,a=e.x-s.scrollX*e.scrollFactorX,h=e.y-s.scrollY*e.scrollFactorY,u=0;u0&&e.cameraFilter&s._id||this.pipeline.batchDynamicBitmapText(e,s)}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){var r=e.text,o=r.length;if(!(n.RENDER_MASK!==e.renderFlags||0===o||e.cameraFilter>0&&e.cameraFilter&s._id)){var a=e.frame,h=e.displayCallback,u=s.scrollX*e.scrollFactorX,l=s.scrollY*e.scrollFactorY,c=e.fontData.chars,d=e.fontData.lineHeight,f=0,p=0,g=0,v=0,y=null,m=0,x=0,w=0,b=0,T=0,A=0,S=null,C=0,M=t.currentContext,E=e.frame.source.image,_=a.cutX,L=a.cutY,P=0,F=e.fontSize/e.fontData.size;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,M.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,M.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode),M.save(),M.translate(e.x,e.y),M.rotate(e.rotation),M.translate(-e.displayOriginX,-e.displayOriginY),M.scale(e.scaleX,e.scaleY),e.cropWidth>0&&e.cropHeight>0&&(M.save(),M.beginPath(),M.rect(0,0,e.cropWidth,e.cropHeight),M.clip());for(var k=t.config.roundPixels,O=0;O0&&e.cropHeight>0&&M.restore(),M.restore()}}},function(t,e){t.exports=function(t){return t.isEmpty()?0:t.getMajorRadius()*t.getMinorRadius()*Math.PI}},function(t,e,i){var n=i(137);t.exports=function(t){return new n(t.x,t.y,t.width,t.height)}},function(t,e,i){var n=i(68);t.exports=function(t,e){return n(t,e.x,e.y)}},function(t,e,i){var n=i(68);t.exports=function(t,e){return n(t,e.x,e.y)&&n(t,e.right,e.y)&&n(t,e.x,e.bottom)&&n(t,e.right,e.bottom)}},function(t,e){t.exports=function(t,e){return e.setTo(t.x,t.y,t.width,t.height)}},function(t,e){t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}},function(t,e,i){var n=i(8);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.left,e.y=t.top,e.width=t.width,e.height=t.height,e}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e,i){var n=i(3),s=i(3);n=i(569),s=i(274),s=i(274),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchGraphics(this,s)}},function(t,e,i){var n=i(3),s=i(3);n=i(571),s=i(572),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchSprite(e,s)}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||t.drawImage(e,s)}},function(t,e,i){var n=i(0),s=i(2),r=new n({initialize:function(t,e,i,n,r){if("object"==typeof t){var o=t;t=s(o,"x",0),e=s(o,"y",0),i=s(o,"power",0),n=s(o,"epsilon",100),r=s(o,"gravity",50)}else void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=100),void 0===r&&(r=50);this.x=t,this.y=e,this.active=!0,this._gravity=r,this._power=0,this._epsilon=0,this.power=i,this.epsilon=n},update:function(t,e){var i=this.x-t.x,n=this.y-t.y,s=i*i+n*n;if(0!==s){var r=Math.sqrt(s);s0&&this.getParticleCount()===this.maxParticles},onParticleEmit:function(t,e){return void 0===t?(this.emitCallback=null,this.emitCallbackScope=null):"function"==typeof t&&(this.emitCallback=t,e&&(this.emitCallbackScope=e)),this},onParticleDeath:function(t,e){return void 0===t?(this.deathCallback=null,this.deathCallbackScope=null):"function"==typeof t&&(this.deathCallback=t,e&&(this.deathCallbackScope=e)),this},killAll:function(){for(var t=this.dead,e=this.alive;e.length>0;)t.push(e.pop());return this},forEachAlive:function(t,e){for(var i=this.alive,n=i.length,s=0;s0?n.pop():new this.particleClass(this)).fire(e,i),this.particleBringToTop?this.alive.push(r):this.alive.unshift(r),this.emitCallback&&this.emitCallback.call(this.emitCallbackScope,r,this),this.atLimit())break}return r}},preUpdate:function(t,e){var i=(e*=this.timeScale)/1e3;this.trackVisible&&(this.visible=this.follow.visible);for(var n=this.manager.getProcessors(),s=this.alive,r=s.length,o=0;o0){var l=s.splice(s.length-u,u),c=this.deathCallback,d=this.deathCallbackScope;if(c)for(var f=0;f0&&(this._counter-=e,this._counter<=0&&(this.emitParticle(),this._counter=this.frequency-Math.abs(this._counter))))},depthSortCallback:function(t,e){return t.y-e.y},indexSortCallback:function(t,e){return t.index-e.index}});t.exports=x},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.source=t,this.killOnEnter=e},willKill:function(t){var e=this.source.contains(t.x,t.y);return e&&this.killOnEnter||!e&&!this.killOnEnter}});t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s){void 0===n&&(n=!1),void 0===s&&(s=!0),this.source=t,this.points=[],this.quantity=e,this.stepRate=i,this.yoyo=n,this.counter=-1,this.seamless=s,this._length=0,this._direction=0,this.updateSource()},updateSource:function(){if(this.points=this.source.getPoints(this.quantity,this.stepRate),this.seamless){var t=this.points[0],e=this.points[this.points.length-1];t.x===e.x&&t.y===e.y&&this.points.pop()}var i=this._length;return this._length=this.points.length,this._lengththis._length&&(this.counter=this._length-1),this},changeSource:function(t){return this.source=t,this.updateSource()},getPoint:function(t){0===this._direction?(this.counter++,this.counter>=this._length&&(this.yoyo?(this._direction=1,this.counter=this._length-1):this.counter=0)):(this.counter--,-1===this.counter&&(this.yoyo?(this._direction=0,this.counter=0):this.counter=this._length-1));var e=this.points[this.counter];e&&(t.x=e.x,t.y=e.y)}});t.exports=n},function(t,e,i){var n=i(0),s=i(276),r=i(71),o=i(2),a=i(50),h=new n({initialize:function(t,e,i,n){void 0===n&&(n=!1),this.propertyKey=e,this.propertyValue=i,this.defaultValue=i,this.steps=0,this.counter=0,this.start=0,this.end=0,this.ease,this.emitOnly=n,this.onEmit=this.defaultEmit,this.onUpdate=this.defaultUpdate,this.loadConfig(t)},loadConfig:function(t,e){void 0===t&&(t={}),e&&(this.propertyKey=e),this.propertyValue=o(t,this.propertyKey,this.defaultValue),this.setMethods(),this.emitOnly&&(this.onUpdate=this.defaultUpdate)},toJSON:function(){return JSON.stringify(this.propertyValue)},onChange:function(t){return this.propertyValue=t,this.setMethods()},setMethods:function(){var t=this.propertyValue,e=typeof t;if("number"===e)this.onEmit=this.staticValueEmit,this.onUpdate=this.staticValueUpdate;else if(Array.isArray(t))this.onEmit=this.randomStaticValueEmit;else if("function"===e)this.emitOnly?this.onEmit=t:this.onUpdate=t;else if("object"===e&&(this.has(t,"random")||this.hasBoth(t,"start","end")||this.hasBoth(t,"min","max"))){this.start=this.has(t,"start")?t.start:t.min,this.end=this.has(t,"end")?t.end:t.max;var i=this.hasBoth(t,"min","max")||this.has(t,"random");if(i){var n=t.random;Array.isArray(n)&&(this.start=n[0],this.end=n[1]),this.onEmit=this.randomRangedValueEmit}if(this.has(t,"steps"))this.steps=t.steps,this.counter=this.start,this.onEmit=this.steppedEmit;else{var s=this.has(t,"ease")?t.ease:"Linear";this.ease=r(s),i||(this.onEmit=this.easedValueEmit),this.onUpdate=this.easeValueUpdate}}else"object"===e&&this.hasEither(t,"onEmit","onUpdate")&&(this.has(t,"onEmit")&&(this.onEmit=t.onEmit),this.has(t,"onUpdate")&&(this.onUpdate=t.onUpdate));return this},has:function(t,e){return t.hasOwnProperty(e)},hasBoth:function(t,e,i){return t.hasOwnProperty(e)&&t.hasOwnProperty(i)},hasEither:function(t,e,i){return t.hasOwnProperty(e)||t.hasOwnProperty(i)},defaultEmit:function(t,e,i){return i},defaultUpdate:function(t,e,i,n){return n},staticValueEmit:function(){return this.propertyValue},staticValueUpdate:function(){return this.propertyValue},randomStaticValueEmit:function(){var t=Math.floor(Math.random()*this.propertyValue.length);return this.propertyValue[t]},randomRangedValueEmit:function(t,e){var i=s(this.start,this.end);return t&&t.data[e]&&(t.data[e].min=i),i},steppedEmit:function(){var t=this.counter,e=this.counter+(this.end-this.start)/this.steps;return this.counter=a(e,this.start,this.end),t},easedValueEmit:function(t,e){if(t&&t.data[e]){var i=t.data[e];i.min=this.start,i.max=this.end}return this.start},easeValueUpdate:function(t,e,i){var n=t.data[e];return(n.max-n.min)*this.ease(i)+n.min}});t.exports=h},function(t,e,i){var n=i(277),s=i(278),r=i(279),o=i(280),a=i(281),h=i(282),u=i(283),l=i(284),c=i(285),d=i(286),f=i(287),p=i(288);t.exports={Power0:u,Power1:l.Out,Power2:o.Out,Power3:c.Out,Power4:d.Out,Linear:u,Quad:l.Out,Cubic:o.Out,Quart:c.Out,Quint:d.Out,Sine:f.Out,Expo:h.Out,Circ:r.Out,Elastic:a.Out,Back:n.Out,Bounce:s.Out,Stepped:p,"Quad.easeIn":l.In,"Cubic.easeIn":o.In,"Quart.easeIn":c.In,"Quint.easeIn":d.In,"Sine.easeIn":f.In,"Expo.easeIn":h.In,"Circ.easeIn":r.In,"Elastic.easeIn":a.In,"Back.easeIn":n.In,"Bounce.easeIn":s.In,"Quad.easeOut":l.Out,"Cubic.easeOut":o.Out,"Quart.easeOut":c.Out,"Quint.easeOut":d.Out,"Sine.easeOut":f.Out,"Expo.easeOut":h.Out,"Circ.easeOut":r.Out,"Elastic.easeOut":a.Out,"Back.easeOut":n.Out,"Bounce.easeOut":s.Out,"Quad.easeInOut":l.InOut,"Cubic.easeInOut":o.InOut,"Quart.easeInOut":c.InOut,"Quint.easeInOut":d.InOut,"Sine.easeInOut":f.InOut,"Expo.easeInOut":h.InOut,"Circ.easeInOut":r.InOut,"Elastic.easeInOut":a.InOut,"Back.easeInOut":n.InOut,"Bounce.easeInOut":s.InOut}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1.70158),t*t*((e+1)*t-e)}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1.70158),--t*t*((e+1)*t+e)+1}},function(t,e){t.exports=function(t,e){void 0===e&&(e=1.70158);var i=1.525*e;return(t*=2)<1?t*t*((i+1)*t-i)*.5:.5*((t-=2)*t*((i+1)*t+i)+2)}},function(t,e){t.exports=function(t){return(t=1-t)<1/2.75?1-7.5625*t*t:t<2/2.75?1-(7.5625*(t-=1.5/2.75)*t+.75):t<2.5/2.75?1-(7.5625*(t-=2.25/2.75)*t+.9375):1-(7.5625*(t-=2.625/2.75)*t+.984375)}},function(t,e){t.exports=function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},function(t,e){t.exports=function(t){var e=!1;return t<.5?(t=1-2*t,e=!0):t=2*t-1,t<1/2.75?t*=7.5625*t:t=t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375,e?.5*(1-t):.5*t+.5}},function(t,e){t.exports=function(t){return 1-Math.sqrt(1-t*t)}},function(t,e){t.exports=function(t){return Math.sqrt(1- --t*t)}},function(t,e){t.exports=function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},function(t,e){t.exports=function(t){return t*t*t}},function(t,e){t.exports=function(t){return--t*t*t+1}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),-e*Math.pow(2,10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),e*Math.pow(2,-10*t)*Math.sin((t-n)*(2*Math.PI)/i)+1}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),(t*=2)<1?e*Math.pow(2,10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)*-.5:e*Math.pow(2,-10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)*.5+1}},function(t,e){t.exports=function(t){return Math.pow(2,10*(t-1))-.001}},function(t,e){t.exports=function(t){return 1-Math.pow(2,-10*t)}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*(t-1)))}},function(t,e){t.exports=function(t){return t}},function(t,e){t.exports=function(t){return t*t}},function(t,e){t.exports=function(t){return t*(2-t)}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},function(t,e){t.exports=function(t){return t*t*t*t}},function(t,e){t.exports=function(t){return 1- --t*t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},function(t,e){t.exports=function(t){return t*t*t*t*t}},function(t,e){t.exports=function(t){return--t*t*t*t*t+1}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:1-Math.cos(t*Math.PI/2)}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:Math.sin(t*Math.PI/2)}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:.5*(1-Math.cos(Math.PI*t))}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1),t<=0?0:t>=1?1:1/e*(1+(e*t|0))}},function(t,e,i){var n=i(0),s=i(35),r=i(42),o=new n({initialize:function(t){this.emitter=t,this.frame=null,this.index=0,this.x=0,this.y=0,this.velocityX=0,this.velocityY=0,this.accelerationX=0,this.accelerationY=0,this.maxVelocityX=1e4,this.maxVelocityY=1e4,this.bounce=0,this.scaleX=1,this.scaleY=1,this.alpha=1,this.angle=0,this.rotation=0,this.scrollFactorX=1,this.scrollFactorY=1,this.tint=4294967295,this.color=4294967295,this.life=1e3,this.lifeCurrent=1e3,this.delayCurrent=0,this.lifeT=0,this.data={tint:{min:16777215,max:16777215,current:16777215},alpha:{min:1,max:1},rotate:{min:0,max:0},scaleX:{min:1,max:1},scaleY:{min:1,max:1}}},isAlive:function(){return this.lifeCurrent>0},fire:function(t,e){var i=this.emitter;this.frame=i.getFrame(),i.emitZone&&i.emitZone.getPoint(this),void 0===t?(i.follow&&(this.x+=i.follow.x+i.followOffset.x),this.x+=i.x.onEmit(this,"x")):this.x+=t,void 0===e?(i.follow&&(this.y+=i.follow.y+i.followOffset.y),this.y+=i.y.onEmit(this,"y")):this.y+=e,this.life=i.lifespan.onEmit(this,"lifespan"),this.lifeCurrent=this.life,this.lifeT=0;var n=i.speedX.onEmit(this,"speedX"),o=i.speedY?i.speedY.onEmit(this,"speedY"):n;if(i.radial){var a=s(i.angle.onEmit(this,"angle"));this.velocityX=Math.cos(a)*Math.abs(n),this.velocityY=Math.sin(a)*Math.abs(o)}else if(i.moveTo){var h=i.moveToX.onEmit(this,"moveToX"),u=i.moveToY?i.moveToY.onEmit(this,"moveToY"):h,l=Math.atan2(u-this.y,h-this.x),c=r(this.x,this.y,h,u)/(this.life/1e3);this.velocityX=Math.cos(l)*c,this.velocityY=Math.sin(l)*c}else this.velocityX=n,this.velocityY=o;i.acceleration&&(this.accelerationX=i.accelerationX.onEmit(this,"accelerationX"),this.accelerationY=i.accelerationY.onEmit(this,"accelerationY")),this.maxVelocityX=i.maxVelocityX.onEmit(this,"maxVelocityX"),this.maxVelocityY=i.maxVelocityY.onEmit(this,"maxVelocityY"),this.delayCurrent=i.delay.onEmit(this,"delay"),this.scaleX=i.scaleX.onEmit(this,"scaleX"),this.scaleY=i.scaleY?i.scaleY.onEmit(this,"scaleY"):this.scaleX,this.angle=i.rotate.onEmit(this,"rotate"),this.rotation=s(this.angle),this.bounce=i.bounce.onEmit(this,"bounce"),this.alpha=i.alpha.onEmit(this,"alpha"),this.tint=i.tint.onEmit(this,"tint"),this.color=16777215&this.tint|(255*this.alpha|0)<<24,this.index=i.alive.length},computeVelocity:function(t,e,i,n){var s=this.velocityX,r=this.velocityY,o=this.accelerationX,a=this.accelerationY,h=this.maxVelocityX,u=this.maxVelocityY;s+=t.gravityX*i,r+=t.gravityY*i,o&&(s+=o*i),a&&(r+=a*i),s>h?s=h:s<-h&&(s=-h),r>u?r=u:r<-u&&(r=-u),this.velocityX=s,this.velocityY=r;for(var l=0;le.right&&t.collideRight&&(this.x=e.right,this.velocityX*=i),this.ye.bottom&&t.collideBottom&&(this.y=e.bottom,this.velocityY*=i)},update:function(t,e,i){if(this.delayCurrent>0)return this.delayCurrent-=t,!1;var n=this.emitter,r=1-this.lifeCurrent/this.life;return this.lifeT=r,this.computeVelocity(n,t,e,i),this.x+=this.velocityX*e,this.y+=this.velocityY*e,n.bounds&&this.checkBounds(n),n.deathZone&&n.deathZone.willKill(this)?(this.lifeCurrent=0,!0):(this.scaleX=n.scaleX.onUpdate(this,"scaleX",r,this.scaleX),n.scaleY?this.scaleY=n.scaleY.onUpdate(this,"scaleY",r,this.scaleY):this.scaleY=this.scaleX,this.angle=n.rotate.onUpdate(this,"rotate",r,this.angle),this.rotation=s(this.angle),this.alpha=n.alpha.onUpdate(this,"alpha",r,this.alpha),this.tint=n.tint.onUpdate(this,"tint",r,this.tint),this.color=16777215&this.tint|(255*this.alpha|0)<<24,this.lifeCurrent-=t,this.lifeCurrent<=0)}});t.exports=o},function(t,e,i){var n=i(0),s=i(6),r=new n({initialize:function(t){this.source=t,this._tempVec=new s},getPoint:function(t){var e=this._tempVec;this.source.getRandomPoint(e),t.x=e.x,t.y=e.y}});t.exports=r},function(t,e,i){var n=i(3),s=i(3);n=i(614),s=i(615),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){0===e.emitters.length||n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.drawEmitterManager(e,s)}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){var r=e.emitters.list;if(!(0===r.length||n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id))for(var o=0;o>24&255)/255;if(!(y<=0)){var m=v.frame,x=.5*m.width,w=.5*m.height,b=m.canvasData,T=-x,A=-w,S=v.x-d*v.scrollFactorX,C=v.y-f*v.scrollFactorY;p&&(S|=0,C|=0),l.globalAlpha=y,l.save(),l.translate(S,C),l.rotate(v.rotation),l.scale(v.scaleX,v.scaleY),l.drawImage(m.source.image,b.sx,b.sy,b.sWidth,b.sHeight,T,A,b.dWidth,b.dHeight),l.restore()}}l.globalAlpha=c}}}},function(t,e,i){var n=i(3),s=i(3);n=i(617),s=i(618),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchTexture(e,e.texture,e.texture.width,e.texture.height,e.x,e.y,e.width,e.height,e.scaleX,e.scaleY,e.rotation,e.flipX,e.flipY,e.scrollFactorX,e.scrollFactorY,e.displayOriginX,e.displayOriginY,0,0,e.texture.width,e.texture.height,4294967295,4294967295,4294967295,4294967295,0,0,s)}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){var r=t.currentContext;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,r.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,r.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var o=0,a=0,h=1,u=1;e.flipX?(h=-1,o-=e.canvas.width-e.displayOriginX):o-=e.displayOriginX,e.flipY?(u=-1,a-=e.canvas.height-e.displayOriginY):a-=e.displayOriginY,r.save(),r.translate(e.x-s.scrollX*e.scrollFactorX,e.y-s.scrollY*e.scrollFactorY),r.rotate(e.rotation),r.scale(e.scaleX,e.scaleY),r.scale(h,u),r.drawImage(e.canvas,o,a),r.restore()}}},function(t,e){t.exports={fill:function(t){var e=255&(t>>16|0),i=255&(t>>8|0),n=255&(0|t);return this.context.fillStyle="rgb("+e+","+i+","+n+")",this.context.fillRect(0,0,this.canvas.width,this.canvas.height),this},clear:function(){return this.context.save(),this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.restore(),this},draw:function(t,e,i,n){var s=this.currentMatrix;return this.context.globalAlpha=this.globalAlpha,this.context.setTransform(s[0],s[1],s[2],s[3],s[4],s[5]),this.context.drawImage(t.source[e.sourceIndex].image,e.cutX,e.cutY,e.cutWidth,e.cutHeight,i,n,e.cutWidth,e.cutWidth),this}}},function(t,e){t.exports={fill:function(t){var e=255&(t>>16|0),i=255&(t>>8|0),n=255&(0|t);this.renderer.setFramebuffer(this.framebuffer);var s=this.gl;return s.clearColor(e/255,i/255,n/255,1),s.clear(s.COLOR_BUFFER_BIT),this.renderer.setFramebuffer(null),this},clear:function(){this.renderer.setFramebuffer(this.framebuffer);var t=this.gl;return t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),this.renderer.setFramebuffer(null),this},draw:function(t,e,i,n){var s=t.source[e.sourceIndex].glTexture,r=(this.globalTint>>16)+(65280&this.globalTint)+((255&this.globalTint)<<16);return this.renderer.setFramebuffer(this.framebuffer),this.renderer.pipelines.TextureTintPipeline.drawTexture(s,i,n,r,this.globalAlpha,e.cutX,e.cutY,e.cutWidth,e.cutHeight,this.currentMatrix),this.renderer.setFramebuffer(null),this}}},function(t,e){t.exports=function(t,e,i){var n=t.canvas,s=t.context,r=t.style,o=[],a=0,h=i.length;r.maxLines>0&&r.maxLinesc&&(f=-c),0!==f&&(d+=f>0?f*i.length:f*(i.length-1)),{width:a,height:d,lines:h,lineWidths:o,lineSpacing:f,lineHeight:c}}},function(t,e,i){var n=i(3),s=i(3);n=i(623),s=i(624),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||""===e.text||(e.dirty&&(e.canvasTexture=t.canvasToTexture(e.canvas,e.canvasTexture,!0,e.scaleMode),e.dirty=!1),this.pipeline.batchText(this,s))}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||""===e.text)){var r=t.currentContext;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,r.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,r.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var o=e.canvas;r.save();var a=e.x-s.scrollX*e.scrollFactorX,h=e.y-s.scrollY*e.scrollFactorY;t.config.roundPixels&&(a|=0,h|=0),r.translate(a,h),r.rotate(e.rotation),r.scale(e.scaleX,e.scaleY),r.translate(o.width*(e.flipX?1:0),o.height*(e.flipY?1:0)),r.scale(e.flipX?-1:1,e.flipY?-1:1),r.drawImage(o,0,0,o.width,o.height,-e.displayOriginX,-e.displayOriginY,o.width,o.height),r.restore()}}},function(t,e,i){var n=i(0),s=i(10),r=i(4),o=i(626),a={fontFamily:["fontFamily","Courier"],fontSize:["fontSize","16px"],fontStyle:["fontStyle",""],backgroundColor:["backgroundColor",null],color:["color","#fff"],stroke:["stroke","#fff"],strokeThickness:["strokeThickness",0],shadowOffsetX:["shadow.offsetX",0],shadowOffsetY:["shadow.offsetY",0],shadowColor:["shadow.color","#000"],shadowBlur:["shadow.blur",0],shadowStroke:["shadow.stroke",!1],shadowFill:["shadow.fill",!1],align:["align","left"],maxLines:["maxLines",0],fixedWidth:["fixedWidth",0],fixedHeight:["fixedHeight",0],rtl:["rtl",!1],testString:["testString","|MÉqgy"],wordWrapWidth:["wordWrap.width",null],wordWrapCallback:["wordWrap.callback",null],wordWrapCallbackScope:["wordWrap.callbackScope",null],wordWrapUseAdvanced:["wordWrap.useAdvancedWrap",!1]},h=new n({initialize:function(t,e){this.parent=t,this.fontFamily,this.fontSize,this.fontStyle,this.backgroundColor,this.color,this.stroke,this.strokeThickness,this.shadowOffsetX,this.shadowOffsetY,this.shadowColor,this.shadowBlur,this.shadowStroke,this.shadowFill,this.align,this.maxLines,this.fixedWidth,this.fixedHeight,this.rtl,this.testString,this._font,this.setStyle(e,!1);var i=r(e,"metrics",!1);this.metrics=i?{ascent:r(i,"ascent",0),descent:r(i,"descent",0),fontSize:r(i,"fontSize",0)}:o(this)},setStyle:function(t,e){for(var i in void 0===e&&(e=!0),t&&t.hasOwnProperty("fontSize")&&"number"==typeof t.fontSize&&(t.fontSize=t.fontSize.toString()+"px"),a)this[i]="wordWrapCallback"===i||"wordWrapCallbackScope"===i?r(t,a[i][0],a[i][1]):s(t,a[i][0],a[i][1]);var n=r(t,"font",null);this._font=null===n?[this.fontStyle,this.fontSize,this.fontFamily].join(" "):n;var o=r(t,"fill",null);return null!==o&&(this.color=o),e?this.update(!0):this.parent},syncFont:function(t,e){e.font=this._font},syncStyle:function(t,e){e.textBaseline="alphabetic",e.fillStyle=this.color,e.strokeStyle=this.stroke,e.lineWidth=this.strokeThickness,e.lineCap="round",e.lineJoin="round"},syncShadow:function(t,e){e?(t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY,t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur):(t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowColor=0,t.shadowBlur=0)},update:function(t){return t&&(this._font=[this.fontStyle,this.fontSize,this.fontFamily].join(" "),this.metrics=o(this)),this.parent.updateText()},setFont:function(t){return"string"==typeof t?(this.fontFamily=t,this.fontSize="",this.fontStyle=""):(this.fontFamily=r(t,"fontFamily","Courier"),this.fontSize=r(t,"fontSize","16px"),this.fontStyle=r(t,"fontStyle","")),this.update(!0)},setFontFamily:function(t){return this.fontFamily=t,this.update(!0)},setFontStyle:function(t){return this.fontStyle=t,this.update(!0)},setFontSize:function(t){return"number"==typeof t&&(t=t.toString()+"px"),this.fontSize=t,this.update(!0)},setTestString:function(t){return this.testString=t,this.update(!0)},setFixedSize:function(t,e){return this.fixedWidth=t,this.fixedHeight=e,t&&(this.parent.width=t),e&&(this.parent.height=e),this.update(!1)},setBackgroundColor:function(t){return this.backgroundColor=t,this.update(!1)},setFill:function(t){return this.color=t,this.update(!1)},setColor:function(t){return this.color=t,this.update(!1)},setStroke:function(t,e){return void 0===t?this.strokeThickness=0:(void 0===e&&(e=this.strokeThickness),this.stroke=t,this.strokeThickness=e),this.update(!0)},setShadow:function(t,e,i,n,s,r){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i="#000"),void 0===n&&(n=0),void 0===s&&(s=!1),void 0===r&&(r=!0),this.shadowOffsetX=t,this.shadowOffsetY=e,this.shadowColor=i,this.shadowBlur=n,this.shadowStroke=s,this.shadowFill=r,this.update(!1)},setShadowOffset:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.shadowOffsetX=t,this.shadowOffsetY=e,this.update(!1)},setShadowColor:function(t){return void 0===t&&(t="#000"),this.shadowColor=t,this.update(!1)},setShadowBlur:function(t){return void 0===t&&(t=0),this.shadowBlur=t,this.update(!1)},setShadowStroke:function(t){return this.shadowStroke=t,this.update(!1)},setShadowFill:function(t){return this.shadowFill=t,this.update(!1)},setWordWrapWidth:function(t,e){return void 0===e&&(e=!1),this.wordWrapWidth=t,this.wordWrapUseAdvanced=e,this.update(!1)},setWordWrapCallback:function(t,e){return void 0===e&&(e=null),this.wordWrapCallback=t,this.wordWrapCallbackScope=e,this.update(!1)},setAlign:function(t){return void 0===t&&(t="left"),this.align=t,this.update(!1)},setMaxLines:function(t){return void 0===t&&(t=0),this.maxLines=t,this.update(!1)},getTextMetrics:function(){var t=this.metrics;return{ascent:t.ascent,descent:t.descent,fontSize:t.fontSize}},toJSON:function(){var t={};for(var e in a)t[e]=this[e];return t.metrics=this.getTextMetrics(),t},destroy:function(){this.parent=void 0}});t.exports=h},function(t,e,i){var n=i(21);t.exports=function(t){var e=n.create(this),i=e.getContext("2d");t.syncFont(e,i);var s=Math.ceil(1.2*i.measureText(t.testString).width),r=s,o=2*r;r=1.4*r|0,e.width=s,e.height=o,i.fillStyle="#f00",i.fillRect(0,0,s,o),i.font=t._font,i.textBaseline="alphabetic",i.fillStyle="#000",i.fillText(t.testString,0,r);var a={ascent:0,descent:0,fontSize:0};if(!i.getImageData(0,0,s,o))return a.ascent=r,a.descent=r+6,a.fontSize=a.ascent+a.descent,n.remove(e),a;var h,u,l=i.getImageData(0,0,s,o).data,c=l.length,d=4*s,f=0,p=!1;for(h=0;hr;h--){for(u=0;u0&&e.cameraFilter&s._id||(e.updateTileTexture(),this.pipeline.batchTileSprite(this,s))}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){var r=t.currentContext,o=e.frame;e.updateTileTexture(),t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,r.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,r.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var a=o.x-e.originX*e.width,h=o.y-e.originY*e.height,u=e.x-s.scrollX*e.scrollFactorX,l=e.y-s.scrollY*e.scrollFactorY,c=1,d=1;e.flipX&&(c=-1,a+=e.width),e.flipY&&(d=-1,h+=e.height),t.config.roundPixels&&(a|=0,h|=0,u|=0,l|=0),r.save(),r.translate(a,h),r.translate(u,l),r.scale(c,d),r.translate(e.originX*e.width,e.originY*e.height),r.rotate(c*d*e.rotation),r.scale(this.scaleX,this.scaleY),r.translate(-e.originX*e.width,-e.originY*e.height),r.translate(-this.tilePositionX,-this.tilePositionY),r.fillStyle=e.canvasPattern,r.fillRect(this.tilePositionX,this.tilePositionY,e.width,e.height),r.restore()}}},function(t,e,i){var n=i(134);i(9).register("blitter",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(135);i(9).register("dynamicBitmapText",function(t,e,i,s,r){return this.displayList.add(new n(this.scene,t,e,i,s,r))})},function(t,e,i){var n=i(136);i(9).register("graphics",function(t){return this.displayList.add(new n(this.scene,t))})},function(t,e,i){var n=i(69);i(9).register("group",function(t,e){return"object"==typeof t&&void 0===e&&(e=t,t=[]),this.updateList.add(new n(this.scene,t,e))})},function(t,e,i){var n=i(70);i(9).register("image",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(9),s=i(139);n.register("particles",function(t,e,i){var n=new s(this.scene,t,e,i);return this.displayList.add(n),this.updateList.add(n),n})},function(t,e,i){var n=i(9),s=i(290);n.register("follower",function(t,e,i,n,r){var o=new s(this.scene,t,e,i,n,r);return this.displayList.add(o),this.updateList.add(o),o})},function(t,e,i){var n=i(9),s=i(141);n.register("renderTexture",function(t,e,i,n){return this.displayList.add(new s(this.scene,t,e,i,n))})},function(t,e,i){var n=i(81);i(9).register("sprite3D",function(t,e,i,s,r){var o=new n(this.scene,t,e,i,s,r);return this.displayList.add(o.gameObject),this.updateList.add(o.gameObject),o})},function(t,e,i){var n=i(9),s=i(37);n.register("sprite",function(t,e,i,n){var r=new s(this.scene,t,e,i,n);return this.displayList.add(r),this.updateList.add(r),r})},function(t,e,i){var n=i(133);i(9).register("bitmapText",function(t,e,i,s,r){return this.displayList.add(new n(this.scene,t,e,i,s,r))})},function(t,e,i){var n=i(142);i(9).register("text",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(143);i(9).register("tileSprite",function(t,e,i,s,r,o){return this.displayList.add(new n(this.scene,t,e,i,s,r,o))})},function(t,e,i){var n=i(77);i(9).register("zone",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(134),s=i(20),r=i(13),o=i(10);r.register("blitter",function(t){var e=o(t,"key",null),i=o(t,"frame",null),r=new n(this.scene,0,0,e,i);return s(this.scene,r,t),r})},function(t,e,i){var n=i(135),s=i(20),r=i(13),o=i(10);r.register("dynamicBitmapText",function(t){var e=o(t,"font",""),i=o(t,"text",""),r=o(t,"size",!1),a=o(t,"align","left"),h=new n(this.scene,0,0,e,i,r,a);return s(this.scene,h,t),h})},function(t,e,i){var n=i(13),s=i(136);n.register("graphics",function(t){return new s(this.scene,t)})},function(t,e,i){var n=i(13),s=i(69);n.register("group",function(t){return new s(this.scene,null,t)})},function(t,e,i){var n=i(20),s=i(13),r=i(10),o=i(70);s.register("image",function(t){var e=r(t,"key",null),i=r(t,"frame",null),s=new o(this.scene,0,0,e,i);return n(this.scene,s,t),s})},function(t,e,i){var n=i(13),s=i(10),r=i(2),o=i(139);n.register("particles",function(t){var e=s(t,"key",null),i=s(t,"frame",null),n=r(t,"emitters",null),a=new o(this.scene,e,i,n);return r(t,"add",!1)&&this.displayList.add(a),this.updateList.add(a),a})},function(t,e,i){var n=i(20),s=i(13),r=i(10),o=i(141);s.register("renderTexture",function(t){var e=r(t,"x",0),i=r(t,"y",0),s=r(t,"width",32),a=r(t,"height",32),h=new o(this.scene,e,i,s,a);return n(this.scene,h,t),h})},function(t,e,i){var n=i(20),s=i(132),r=i(13),o=i(10),a=i(81);r.register("sprite3D",function(t){var e=o(t,"key",null),i=o(t,"frame",null),r=new a(this.scene,0,0,e,i);return n(this.scene,r,t),s(r,t),r})},function(t,e,i){var n=i(20),s=i(132),r=i(13),o=i(10),a=i(37);r.register("sprite",function(t){var e=o(t,"key",null),i=o(t,"frame",null),r=new a(this.scene,0,0,e,i);return n(this.scene,r,t),s(r,t),r})},function(t,e,i){var n=i(133),s=i(20),r=i(13),o=i(10),a=i(4);r.register("bitmapText",function(t){var e=a(t,"font",""),i=o(t,"text",""),r=o(t,"size",!1),h=new n(this.scene,0,0,e,i,r);return s(this.scene,h,t),h})},function(t,e,i){var n=i(20),s=i(13),r=i(10),o=i(142);s.register("text",function(t){var e=r(t,"text",""),i=r(t,"style",null),s=r(t,"padding",null);null!==s&&(i.padding=s);var a=new o(this.scene,0,0,e,i);return n(this.scene,a,t),a.autoRound=r(t,"autoRound",!0),a.resolution=r(t,"resolution",1),a})},function(t,e,i){var n=i(20),s=i(13),r=i(10),o=i(143);s.register("tileSprite",function(t){var e=r(t,"x",0),i=r(t,"y",0),s=r(t,"width",512),a=r(t,"height",512),h=r(t,"key",""),u=r(t,"frame",""),l=new o(this.scene,e,i,s,a,h,u);return n(this.scene,l,t),l})},function(t,e,i){var n=i(13),s=i(10),r=i(77);n.register("zone",function(t){var e=s(t,"x",0),i=s(t,"y",0),n=s(t,"width",1),o=s(t,"height",n);return new r(this.scene,e,i,n,o)})},function(t,e,i){var n=i(3),s=i(3);n=i(658),s=i(659),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchMesh(e,s)}},function(t,e){t.exports=function(){}},function(t,e,i){var n=i(88);i(9).register("mesh",function(t,e,i,s,r,o,a,h){return this.displayList.add(new n(this.scene,t,e,i,s,r,o,a,h))})},function(t,e,i){var n=i(144);i(9).register("quad",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(20),s=i(13),r=i(10),o=i(4),a=i(88);s.register("mesh",function(t){var e=r(t,"key",null),i=r(t,"frame",null),s=o(t,"vertices",[]),h=o(t,"colors",[]),u=o(t,"alphas",[]),l=o(t,"uv",[]),c=new a(this.scene,0,0,s,l,h,u,e,i);return n(this.scene,c,t),c})},function(t,e,i){var n=i(20),s=i(13),r=i(10),o=i(144);s.register("quad",function(t){var e=r(t,"x",0),i=r(t,"y",0),s=r(t,"key",null),a=r(t,"frame",null),h=new o(this.scene,e,i,s,a);return n(this.scene,h,t),h})},function(t,e,i){var n=i(0),s=i(293),r=i(12),o=new n({Extends:s,initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),s.call(this)},boot:function(){var t=this.systems.events;t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},destroy:function(){this.shutdown(),this.scene=void 0,this.systems=void 0}});r.register("LightsPlugin",o,"lights"),t.exports=o},function(t,e,i){var n=i(64);n.Area=i(666),n.Circumference=i(186),n.CircumferencePoint=i(105),n.Clone=i(667),n.Contains=i(32),n.ContainsPoint=i(668),n.ContainsRect=i(669),n.CopyFrom=i(670),n.Equals=i(671),n.GetBounds=i(672),n.GetPoint=i(184),n.GetPoints=i(185),n.Offset=i(673),n.OffsetPoint=i(674),n.Random=i(106),t.exports=n},function(t,e){t.exports=function(t){return t.radius>0?Math.PI*t.radius*t.radius:0}},function(t,e,i){var n=i(64);t.exports=function(t){return new n(t.x,t.y,t.radius)}},function(t,e,i){var n=i(32);t.exports=function(t,e){return n(t,e.x,e.y)}},function(t,e,i){var n=i(32);t.exports=function(t,e){return n(t,e.x,e.y)&&n(t,e.right,e.y)&&n(t,e.x,e.bottom)&&n(t,e.right,e.bottom)}},function(t,e){t.exports=function(t,e){return e.setTo(t.x,t.y,t.radius)}},function(t,e){t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.radius===e.radius}},function(t,e,i){var n=i(8);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.left,e.y=t.top,e.width=t.diameter,e.height=t.diameter,e}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e,i){var n=i(42);t.exports=function(t,e){return n(t.x,t.y,e.x,e.y)<=t.radius+e.radius}},function(t,e){t.exports=function(t,e){var i=e.width/2,n=e.height/2,s=Math.abs(t.x-e.x-i),r=Math.abs(t.y-e.y-n),o=i+t.radius,a=n+t.radius;if(s>o||r>a)return!1;if(s<=i||r<=n)return!0;var h=s-i,u=r-n;return h*h+u*u<=t.radius*t.radius}},function(t,e,i){var n=i(8),s=i(296);t.exports=function(t,e,i){return void 0===i&&(i=new n),s(t,e)&&(i.x=Math.max(t.x,e.x),i.y=Math.max(t.y,e.y),i.width=Math.min(t.right,e.right)-i.x,i.height=Math.min(t.bottom,e.bottom)-i.y),i}},function(t,e){t.exports=function(t,e){var i=t.x1,n=t.y1,s=t.x2,r=t.y2,o=e.x,a=e.y,h=e.right,u=e.bottom,l=0;if(i>=o&&i<=h&&n>=a&&n<=u||s>=o&&s<=h&&r>=a&&r<=u)return!0;if(i=o){if((l=n+(r-n)*(o-i)/(s-i))>a&&l<=u)return!0}else if(i>h&&s<=h&&(l=n+(r-n)*(h-i)/(s-i))>=a&&l<=u)return!0;if(n=a){if((l=i+(s-i)*(a-n)/(r-n))>=o&&l<=h)return!0}else if(n>u&&r<=u&&(l=i+(s-i)*(u-n)/(r-n))>=o&&l<=h)return!0;return!1}},function(t,e,i){var n=i(298);t.exports=function(t,e){if(!n(t,e))return!1;var i=Math.min(e.x1,e.x2),s=Math.max(e.x1,e.x2),r=Math.min(e.y1,e.y2),o=Math.max(e.y1,e.y2);return t.x>=i&&t.x<=s&&t.y>=r&&t.y<=o}},function(t,e,i){var n=i(89),s=i(33),r=i(145),o=i(299);t.exports=function(t,e){if(e.left>t.right||e.rightt.bottom||e.bottom0}},function(t,e){t.exports=function(t,e,i,n,s,r){return void 0===r&&(r=0),!(e>t.right+r||it.bottom+r||se.right||t.righte.bottom||t.bottome.right||t.righte.bottom||t.bottom0||(c=s(e),(d=n(t,c,!0)).length>0)}},function(t,e,i){var n=i(301);n.Angle=i(55),n.BresenhamPoints=i(194),n.CenterOn=i(686),n.Clone=i(687),n.CopyFrom=i(688),n.Equals=i(689),n.GetMidPoint=i(690),n.GetNormal=i(691),n.GetPoint=i(302),n.GetPoints=i(109),n.Height=i(692),n.Length=i(66),n.NormalAngle=i(303),n.NormalX=i(693),n.NormalY=i(694),n.Offset=i(695),n.PerpSlope=i(696),n.Random=i(111),n.ReflectAngle=i(697),n.Rotate=i(698),n.RotateAroundPoint=i(699),n.RotateAroundXY=i(146),n.SetToAngle=i(700),n.Slope=i(701),n.Width=i(702),t.exports=n},function(t,e){t.exports=function(t,e,i){var n=e-(t.x1+t.x2)/2,s=i-(t.y1+t.y2)/2;return t.x1+=n,t.y1+=s,t.x2+=n,t.y2+=s,t}},function(t,e,i){var n=i(301);t.exports=function(t){return new n(t.x1,t.y1,t.x2,t.y2)}},function(t,e){t.exports=function(t,e){return e.setTo(t.x1,t.y1,t.x2,t.y2)}},function(t,e){t.exports=function(t,e){return t.x1===e.x1&&t.y1===e.y1&&t.x2===e.x2&&t.y2===e.y2}},function(t,e,i){var n=i(5);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=(t.x1+t.x2)/2,e.y=(t.y1+t.y2)/2,e}},function(t,e,i){var n=i(16),s=i(55),r=i(5);t.exports=function(t,e){void 0===e&&(e=new r);var i=s(t)-n.TAU;return e.x=Math.cos(i),e.y=Math.sin(i),e}},function(t,e){t.exports=function(t){return Math.abs(t.y1-t.y2)}},function(t,e,i){var n=i(16),s=i(55);t.exports=function(t){return Math.cos(s(t)-n.TAU)}},function(t,e,i){var n=i(16),s=i(55);t.exports=function(t){return Math.sin(s(t)-n.TAU)}},function(t,e){t.exports=function(t,e,i){return t.x1+=e,t.y1+=i,t.x2+=e,t.y2+=i,t}},function(t,e){t.exports=function(t){return-(t.x2-t.x1)/(t.y2-t.y1)}},function(t,e,i){var n=i(55),s=i(303);t.exports=function(t,e){return 2*s(e)-Math.PI-n(t)}},function(t,e,i){var n=i(146);t.exports=function(t,e){var i=(t.x1+t.x2)/2,s=(t.y1+t.y2)/2;return n(t,i,s,e)}},function(t,e,i){var n=i(146);t.exports=function(t,e,i){return n(t,e.x,e.y,i)}},function(t,e){t.exports=function(t,e,i,n,s){return t.x1=e,t.y1=i,t.x2=e+Math.cos(n)*s,t.y2=i+Math.sin(n)*s,t}},function(t,e){t.exports=function(t){return(t.y2-t.y1)/(t.x2-t.x1)}},function(t,e){t.exports=function(t){return Math.abs(t.x1-t.x2)}},function(t,e,i){var n=i(5);n.Ceil=i(704),n.Clone=i(705),n.CopyFrom=i(706),n.Equals=i(707),n.Floor=i(708),n.GetCentroid=i(709),n.GetMagnitude=i(304),n.GetMagnitudeSq=i(305),n.GetRectangleFromPoints=i(710),n.Interpolate=i(711),n.Invert=i(712),n.Negative=i(713),n.Project=i(714),n.ProjectUnit=i(715),n.SetMagnitude=i(716),t.exports=n},function(t,e){t.exports=function(t){return t.setTo(Math.ceil(t.x),Math.ceil(t.y))}},function(t,e,i){var n=i(5);t.exports=function(t){return new n(t.x,t.y)}},function(t,e){t.exports=function(t,e){return e.setTo(t.x,t.y)}},function(t,e){t.exports=function(t,e){return t.x===e.x&&t.y===e.y}},function(t,e){t.exports=function(t){return t.setTo(Math.floor(t.x),Math.floor(t.y))}},function(t,e,i){var n=i(5);t.exports=function(t,e){if(void 0===e&&(e=new n),!Array.isArray(t))throw new Error("GetCentroid points argument must be an array");var i=t.length;if(i<1)throw new Error("GetCentroid points array must not be empty");if(1===i)e.x=t[0].x,e.y=t[0].y;else{for(var s=0;si&&(i=h.x),h.xr&&(r=h.y),h.yt.width*t.height)&&e.x>t.x&&e.xt.x&&e.rightt.y&&e.yt.y&&e.bottomn(e)?t.setSize(e.height*i,e.height):t.setSize(e.width,e.width/i),t.setPosition(e.centerX-t.width/2,e.centerY-t.height/2)}},function(t,e){t.exports=function(t){return t.x=Math.floor(t.x),t.y=Math.floor(t.y),t}},function(t,e){t.exports=function(t){return t.x=Math.floor(t.x),t.y=Math.floor(t.y),t.width=Math.floor(t.width),t.height=Math.floor(t.height),t}},function(t,e,i){var n=i(5);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.centerX,e.y=t.centerY,e}},function(t,e,i){var n=i(5);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.width,e.y=t.height,e}},function(t,e,i){var n=i(308);t.exports=function(t,e,i){var s=t.centerX,r=t.centerY;return t.setSize(t.width+2*e,t.height+2*i),n(t,s,r)}},function(t,e){t.exports=function(t,e){for(var i=t.x,n=t.right,s=t.y,r=t.bottom,o=0;oe.x&&t.ye.y}},function(t,e,i){var n=i(5),s=i(35);t.exports=function(t,e,i){void 0===i&&(i=new n),e=s(e);var r=Math.sin(e),o=Math.cos(e),a=o>0?t.width/2:t.width/-2,h=r>0?t.height/2:t.height/-2;return Math.abs(a*r)-1&&(s.splice(a,1),this.clear(o))}t.length=0,this._list=s.concat(e.splice(0))}},clear:function(t){var e=t.input;e.gameObject=void 0,e.target=void 0,e.hitArea=void 0,e.hitAreaCallback=void 0,e.callbackContext=void 0,t.input=null;var i=this._draggable.indexOf(t);return i>-1&&this._draggable.splice(i,1),(i=this._drag[0].indexOf(t))>-1&&this._drag[0].splice(i,1),(i=this._over[0].indexOf(t))>-1&&this._over[0].splice(i,1),t},disable:function(t){t.input.enabled=!1},enable:function(t,e,i,n){return void 0===n&&(n=!1),t.input?t.input.enabled=!0:this.setHitArea(t,e,i),t.input.dropZone=n,this},hitTestPointer:function(t){var e=this.cameras.getCameraBelowPointer(t);if(e){t.camera=e;for(var i=this.manager.hitTest(t.x,t.y,this._list,e),n=0;n0?t.dragState=1:t.dragState>0&&!t.primaryDown&&t.justUp&&(t.dragState=5),1===t.dragState){var h=[];for(i=0;i1&&(this.sortGameObjects(h),this.topOnly&&h.splice(1)),this._drag[t.id]=h,0===this.dragDistanceThreshold&&0===this.dragTimeThreshold?t.dragState=3:t.dragState=2}if(2===t.dragState&&(this.dragDistanceThreshold>0&&o(t.x,t.y,t.downX,t.downY)>=this.dragDistanceThreshold&&(t.dragState=3),this.dragTimeThreshold>0&&e>=t.downTime+this.dragTimeThreshold&&(t.dragState=3)),3===t.dragState){for(s=this._drag[t.id],i=0;i0?(n.emit("dragleave",t,r.target),this.emit("dragleave",t,n,r.target),r.target=u[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target)):(n.emit("dragleave",t,r.target),this.emit("dragleave",t,n,r.target),u[0]?(r.target=u[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target)):r.target=null)}else!r.target&&u[0]&&(r.target=u[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target));var c=t.x-n.input.dragX,d=t.y-n.input.dragY;n.emit("drag",t,c,d),this.emit("drag",t,n,c,d)}}if(5===t.dragState){for(s=this._drag[t.id],i=0;i0},processMoveEvents:function(t){var e=this._temp;this.emit("pointermove",t,e);for(var i=0,n=0;n0)for(this.sortGameObjects(s),this.emit("pointerout",t,s),e=0;e0)for(this.sortGameObjects(r),this.emit("pointerover",t,r),e=0;e-1&&this._draggable.splice(s,1)}return this},setHitArea:function(t,e,i){if(void 0===e)return this.setHitAreaFromTexture(t);Array.isArray(t)||(t=[t]);for(var n=0;nn?-1:0},sortHandlerIO:function(t,e){var i=this.displayList.getIndex(t.gameObject),n=this.displayList.getIndex(e.gameObject);return in?-1:0},sortInteractiveObjects:function(t){return t.length<2?t:(this.scene.sys.depthSort(),t.sort(this.sortHandlerIO.bind(this)))},stopPropagation:function(){return this.manager.globalTopOnly&&(this.manager.ignoreEvents=!0),this},update:function(t,e){var i=this.manager;if(!i.globalTopOnly||!i.ignoreEvents){var n=i.activePointer,s=n.dirty||0===this.pollRate;if(this.pollRate>-1&&(this._pollTimer-=e,this._pollTimer<0&&(s=!0,this._pollTimer=this.pollRate)),s){this._tempZones=[],this._temp=this.hitTestPointer(n),this.sortGameObjects(this._temp),this.sortGameObjects(this._tempZones),this.topOnly&&(this._temp.length&&this._temp.splice(1),this._tempZones.length&&this._tempZones.splice(1));var r=this.processDragEvents(n,t);n.wasTouch||(r+=this.processOverOutEvents(n)),n.justDown&&(r+=this.processDownEvents(n)),n.justUp&&(r+=this.processUpEvents(n)),n.justMoved&&(r+=this.processMoveEvents(n)),r>0&&i.globalTopOnly&&(i.ignoreEvents=!0)}}},shutdown:function(){this._temp.length=0,this._list.length=0,this._draggable.length=0,this._pendingRemoval.length=0,this._pendingInsertion.length=0;for(var t=0;t<10;t++)this._drag[t]=[],this._over[t]=[];this.removeAllListeners()},destroy:function(){this.shutdown(),this.scene=void 0,this.cameras=void 0,this.manager=void 0,this.events=void 0,this.keyboard=void 0,this.mouse=void 0,this.gamepad=void 0},activePointer:{get:function(){return this.manager.activePointer}},x:{get:function(){return this.manager.activePointer.x}},y:{get:function(){return this.manager.activePointer.y}}});c.register("InputPlugin",v,"input"),t.exports=v},function(t,e,i){t.exports={KeyboardManager:i(245),Key:i(246),KeyCodes:i(129),KeyCombo:i(247),JustDown:i(769),JustUp:i(770),DownDuration:i(771),UpDuration:i(772)}},function(t,e){t.exports=function(t){var e=!1;return t.isDown&&(e=t._justDown,t._justDown=!1),e}},function(t,e){t.exports=function(t){var e=!1;return t.isDown&&(e=t._justUp,t._justUp=!1),e}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=50),t.isDown&&t.duration'),n.push(''),n.push(''),n.push(this.xhrLoader.responseText),n.push(""),n.push(""),n.push("");var o=[n.join("\n")],a=this;try{var h=new window.Blob(o,{type:"image/svg+xml;charset=utf-8"})}catch(e){return a.state=s.FILE_ERRORED,void t(a)}this.data=new Image,this.data.crossOrigin=this.crossOrigin,this.data.onload=function(){r.revokeObjectURL(a.data),a.onComplete(),t(a)},this.data.onerror=function(){r.revokeObjectURL(a.data),a.state=s.FILE_ERRORED,t(a)},r.createObjectURL(this.data,h,"image/svg+xml")}});o.register("html",function(t,e,i,n,s){if(Array.isArray(t))for(var r=0;r0?this.processLoadQueue():0===this.inflight.size&&this.finishedLoading()},finishedLoading:function(){this.state!==s.LOADER_PROCESSING&&(this.progress=1,this.state=s.LOADER_PROCESSING,this.storage.clear(),0===this.queue.size?this.processComplete():this.queue.each(function(t){t.onProcess(this.processUpdate.bind(this))},this))},processUpdate:function(t){if(t.state===s.FILE_ERRORED)return this.failed.set(t),t.linkFile&&this.queue.delete(t.linkFile),this.removeFromQueue(t);t.linkFile?t.state===s.FILE_COMPLETE&&t.linkFile.state===s.FILE_COMPLETE&&(this.storage.set({type:t.linkType,fileA:t,fileB:t.linkFile}),this.queue.delete(t.linkFile),this.removeFromQueue(t)):(this.storage.set(t),this.removeFromQueue(t))},removeFromQueue:function(t){this.queue.delete(t),0===this.queue.size&&this.state===s.LOADER_PROCESSING&&this.processComplete()},processComplete:function(){this.list.clear(),this.inflight.clear(),this.queue.clear(),this.processCallback(),this.state=s.LOADER_COMPLETE,this.emit("complete",this,this.storage.size,this.failed.size)},processCallback:function(){if(0!==this.storage.size){var t,e,i,n=this.scene.sys.cache,s=this.scene.sys.textures,r=this.scene.sys.anims;for(var o in this._multilist){for(var a=[],h=[],l=this._multilist[o],c=0;c0},file:function(t){var e,i=t.key;switch(t.type){case"spritesheet":e=this.spritesheet(i,t.url,t.config,t.xhrSettings);break;case"atlas":e=this.atlas(i,t.textureURL,t.atlasURL,t.textureXhrSettings,t.atlasXhrSettings);break;case"bitmapFont":e=this.bitmapFont(i,t.textureURL,t.xmlURL,t.textureXhrSettings,t.xmlXhrSettings);break;case"multiatlas":e=this.multiatlas(i,t.textureURLs,t.atlasURLs,t.textureXhrSettings,t.atlasXhrSettings);break;case"audioSprite":e=this.audioSprite(i,t.urls,t.json,t.config,t.audioXhrSettings,t.jsonXhrSettings);break;default:e=this[t.type](i,t.url,t.xhrSettings)}return e},shutdown:function(){this.reset(),this.state=s.LOADER_SHUTDOWN},destroy:function(){this.reset(),this.state=s.LOADER_DESTROYED}});l.register("Loader",d,"load"),t.exports=d},function(t,e,i){var n=i(16),s=i(23),r={Angle:i(794),Distance:i(802),Easing:i(805),Fuzzy:i(806),Interpolation:i(812),Pow2:i(816),Snap:i(818),Average:i(822),Bernstein:i(322),Between:i(231),CatmullRom:i(123),CeilTo:i(823),Clamp:i(61),DegToRad:i(35),Difference:i(824),Factorial:i(323),FloatBetween:i(276),FloorTo:i(825),FromPercent:i(65),GetSpeed:i(826),IsEven:i(827),IsEvenStrict:i(828),Linear:i(124),MaxAdd:i(829),MinSub:i(830),Percent:i(831),RadToDeg:i(221),RandomXY:i(832),RandomXYZ:i(209),RandomXYZW:i(210),Rotate:i(324),RotateAround:i(188),RotateAroundDistance:i(113),RoundAwayFromZero:i(325),RoundTo:i(833),SinCosTableGenerator:i(834),SmootherStep:i(195),SmoothStep:i(196),TransformXY:i(251),Within:i(835),Wrap:i(50),Vector2:i(6),Vector3:i(51),Vector4:i(120),Matrix3:i(213),Matrix4:i(119),Quaternion:i(212),RotateVec3:i(211)};r=s(!1,r,n),t.exports=r},function(t,e,i){t.exports={Between:i(795),BetweenY:i(796),BetweenPoints:i(797),BetweenPointsY:i(798),Reverse:i(799),RotateTo:i(800),ShortestBetween:i(801),Normalize:i(321),Wrap:i(163),WrapDegrees:i(164)}},function(t,e){t.exports=function(t,e,i,n){return Math.atan2(n-e,i-t)}},function(t,e){t.exports=function(t,e,i,n){return Math.atan2(i-t,n-e)}},function(t,e){t.exports=function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)}},function(t,e){t.exports=function(t,e){return Math.atan2(e.x-t.x,e.y-t.y)}},function(t,e,i){var n=i(321);t.exports=function(t){return n(t+Math.PI)}},function(t,e,i){var n=i(16);t.exports=function(t,e,i){return void 0===i&&(i=.05),t===e?t:(Math.abs(e-t)<=i||Math.abs(e-t)>=n.PI2-i?t=e:(Math.abs(e-t)>Math.PI&&(et?t+=i:ee-i}},function(t,e){t.exports=function(t,e,i){return void 0===i&&(i=1e-4),t1?t[i]-(n(s-i,t[i],t[i],t[i-1],t[i-1])-t[i]):n(s-r,t[r?r-1:0],t[r],t[i1?n(t[i],t[i-1],i-s):n(t[r],t[r+1>i?i:r+1],s-r)}},function(t,e,i){t.exports={GetNext:i(291),IsSize:i(127),IsValue:i(817)}},function(t,e){t.exports=function(t){return t>0&&0==(t&t-1)}},function(t,e,i){t.exports={Ceil:i(819),Floor:i(820),To:i(821)}},function(t,e){t.exports=function(t,e,i){return void 0===i&&(i=0),0===e?t:(t-=i,i+(t=e*Math.ceil(t/e)))}},function(t,e){t.exports=function(t,e,i){return void 0===i&&(i=0),0===e?t:(t-=i,i+(t=e*Math.floor(t/e)))}},function(t,e){t.exports=function(t,e,i){return void 0===i&&(i=0),0===e?t:(t-=i,i+(t=e*Math.round(t/e)))}},function(t,e){t.exports=function(t){for(var e=0,i=0;i1?void 0!==n?(s=(n-t)/(n-i))<0&&(s=0):s=1:s<0&&(s=0),s}},function(t,e){t.exports=function(t,e){void 0===e&&(e=1);var i=2*Math.random()*Math.PI;return t.x=Math.cos(i)*e,t.y=Math.sin(i)*e,t}},function(t,e){t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var n=Math.pow(i,-e);return Math.round(t*n)/n}},function(t,e){t.exports=function(t,e,i,n){void 0===e&&(e=1),void 0===i&&(i=1),void 0===n&&(n=1),n*=Math.PI/t;for(var s=[],r=[],o=0;o=0;o--){var a=e[o],h=u(s,r,a.x,a.y);h=0;o--){var a=e[o],h=u(s,r,a.x,a.y);h>i&&(n=a,i=h)}return n},moveTo:function(t,e,i,n,s){void 0===n&&(n=60),void 0===s&&(s=0);var r=Math.atan2(i-t.y,e-t.x);return s>0&&(n=u(t.x,t.y,e,i)/(s/1e3)),t.body.velocity.setToPolar(r,n),r},moveToObject:function(t,e,i,n){return this.moveTo(t,e.x,e.y,i,n)},velocityFromAngle:function(t,e,i){return void 0===e&&(e=60),i.setToPolar(l(t),e)},velocityFromRotation:function(t,e,i){return void 0===e&&(e=60),i.setToPolar(t,e)},shutdown:function(){this.world.shutdown()},destroy:function(){this.world.destroy()}});a.register("ArcadePhysics",c,"arcadePhysics"),t.exports=c},function(t,e){t.exports={setAcceleration:function(t,e){return this.body.acceleration.set(t,e),this},setAccelerationX:function(t){return this.body.acceleration.x=t,this},setAccelerationY:function(t){return this.body.acceleration.y=t,this}}},function(t,e){t.exports={setAngularVelocity:function(t){return this.body.angularVelocity=t,this},setAngularAcceleration:function(t){return this.body.angularAcceleration=t,this},setAngularDrag:function(t){return this.body.angularDrag=t,this}}},function(t,e){t.exports={setBounce:function(t,e){return this.body.bounce.set(t,e),this},setBounceX:function(t){return this.body.bounce.x=t,this},setBounceY:function(t){return this.body.bounce.y=t,this},setCollideWorldBounds:function(t){return this.body.collideWorldBounds=t,this}}},function(t,e){t.exports={setDebug:function(t,e,i){return this.debugShowBody=t,this.debugShowVelocity=e,this.debugBodyColor=i,this},setDebugBodyColor:function(t){return this.body.debugBodyColor=t,this},debugShowBody:{get:function(){return this.body.debugShowBody},set:function(t){this.body.debugShowBody=t}},debugShowVelocity:{get:function(){return this.body.debugShowVelocity},set:function(t){this.body.debugShowVelocity=t}},debugBodyColor:{get:function(){return this.body.debugBodyColor},set:function(t){this.body.debugBodyColor=t}}}},function(t,e){t.exports={setDrag:function(t,e){return this.body.drag.set(t,e),this},setDragX:function(t){return this.body.drag.x=t,this},setDragY:function(t){return this.body.drag.y=t,this}}},function(t,e){var i={enableBody:function(t,e,i,n,s){return t&&this.body.reset(e,i),n&&(this.body.gameObject.active=!0),s&&(this.body.gameObject.visible=!0),this.body.enable=!0,this},disableBody:function(t,e){return void 0===t&&(t=!1),void 0===e&&(e=!1),this.body.stop(),this.body.enable=!1,t&&(this.body.gameObject.active=!1),e&&(this.body.gameObject.visible=!1),this},refreshBody:function(){return this.body.updateFromGameObject(),this}};t.exports=i},function(t,e){t.exports={setFriction:function(t,e){return this.body.friction.set(t,e),this},setFrictionX:function(t){return this.body.friction.x=t,this},setFrictionY:function(t){return this.body.friction.y=t,this}}},function(t,e){t.exports={setGravity:function(t,e){return this.body.gravity.set(t,e),this},setGravityX:function(t){return this.body.gravity.x=t,this},setGravityY:function(t){return this.body.gravity.y=t,this}}},function(t,e){var i={setImmovable:function(t){return void 0===t&&(t=!0),this.body.immovable=t,this}};t.exports=i},function(t,e){t.exports={setMass:function(t){return this.body.mass=t,this}}},function(t,e){t.exports={setOffset:function(t,e){return this.body.setOffset(t,e),this},setSize:function(t,e,i){return this.body.setSize(t,e,i),this},setCircle:function(t,e,i){return this.body.setCircle(t,e,i),this}}},function(t,e){var i={setVelocity:function(t,e){return this.body.velocity.set(t,e),this},setVelocityX:function(t){return this.body.velocity.x=t,this},setVelocityY:function(t){return this.body.velocity.y=t,this},setMaxVelocity:function(t,e){return void 0===e&&(e=t),this.body.maxVelocity.set(t,e),this}};t.exports=i},function(t,e){t.exports=function(t,e){return t.collisionCallback?!t.collisionCallback.call(t.collisionCallbackContext,e,t):!t.layer.callbacks[t.index]||!t.layer.callbacks[t.index].callback.call(t.layer.callbacks[t.index].callbackContext,e,t)}},function(t,e,i){var n=i(852),s=i(854),r=i(339);t.exports=function(t,e,i,o,a,h){var u=o.left,l=o.top,c=o.right,d=o.bottom,f=i.faceLeft||i.faceRight,p=i.faceTop||i.faceBottom;if(!f&&!p)return!1;var g=0,v=0,y=0,m=1;if(e.deltaAbsX()>e.deltaAbsY()?y=-1:e.deltaAbsX()0&&!t.blocked.right&&e.collideLeft&&t.checkCollision.right&&e.faceLeft&&t.right>i&&(o=t.right-i)>r&&(o=0),0!==o&&(t.customSeparateX?t.overlapX=o:n(t,o)),o}},function(t,e){t.exports=function(t,e){e<0?t.blocked.left=!0:e>0&&(t.blocked.right=!0),t.position.x-=e,0===t.bounce.x?t.velocity.x=0:t.velocity.x=-t.velocity.x*t.bounce.x}},function(t,e,i){var n=i(855);t.exports=function(t,e,i,s,r){var o=0;return t.deltaY()<0&&!t.blocked.up&&e.collideDown&&t.checkCollision.up?e.faceBottom&&t.y0&&!t.blocked.down&&e.collideUp&&t.checkCollision.down&&e.faceTop&&t.bottom>i&&(o=t.bottom-i)>r&&(o=0),0!==o&&(t.customSeparateY?t.overlapY=o:n(t,o)),o}},function(t,e){t.exports=function(t,e){e<0?t.blocked.up=!0:e>0&&(t.blocked.down=!0),t.position.y-=e,0===t.bounce.y?t.velocity.y=0:t.velocity.y=-t.velocity.y*t.bounce.y}},function(t,e,i){var n=i(334);t.exports=function(t,e,i,s){var r=n(t,e,i,s);if(i||0===r||t.immovable&&e.immovable||t.customSeparateX||e.customSeparateX)return 0!==r||t.embedded&&e.embedded;var o=t.velocity.x,a=e.velocity.x;if(t.immovable||e.immovable)t.immovable?(e.x+=r,e.velocity.x=o-a*e.bounce.x,t.moves&&(e.y+=(t.y-t.prev.y)*t.friction.y)):(t.x-=r,t.velocity.x=a-o*t.bounce.x,e.moves&&(t.y+=(e.y-e.prev.y)*e.friction.y));else{r*=.5,t.x-=r,e.x+=r;var h=Math.sqrt(a*a*e.mass/t.mass)*(a>0?1:-1),u=Math.sqrt(o*o*t.mass/e.mass)*(o>0?1:-1),l=.5*(h+u);h-=l,u-=l,t.velocity.x=l+h*t.bounce.x,e.velocity.x=l+u*e.bounce.x}return!0}},function(t,e,i){var n=i(335);t.exports=function(t,e,i,s){var r=n(t,e,i,s);if(i||0===r||t.immovable&&e.immovable||t.customSeparateY||e.customSeparateY)return 0!==r||t.embedded&&e.embedded;var o=t.velocity.y,a=e.velocity.y;if(t.immovable||e.immovable)t.immovable?(e.y+=r,e.velocity.y=o-a*e.bounce.y,t.moves&&(e.x+=(t.x-t.prev.x)*t.friction.x)):(t.y-=r,t.velocity.y=a-o*t.bounce.y,e.moves&&(t.x+=(e.x-e.prev.x)*e.friction.x));else{r*=.5,t.y-=r,e.y+=r;var h=Math.sqrt(a*a*e.mass/t.mass)*(a>0?1:-1),u=Math.sqrt(o*o*t.mass/e.mass)*(o>0?1:-1),l=.5*(h+u);h-=l,u-=l,t.velocity.y=l+h*t.bounce.y,e.velocity.y=l+u*e.bounce.y}return!0}},,,,,,,,,,function(t,e,i){t.exports={SceneManager:i(252),ScenePlugin:i(868),Settings:i(255),Systems:i(130)}},function(t,e,i){var n=i(0),s=i(83),r=i(12),o=new n({initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),this.settings=t.sys.settings,this.key=t.sys.settings.key,this.manager=t.sys.game.scene},boot:function(){var t=this.systems.events;t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},start:function(t,e){return void 0===t&&(t=this.key),this.settings.status!==s.RUNNING?(this.manager.queueOp("stop",this.key),this.manager.queueOp("start",t)):(this.manager.stop(this.key),this.manager.start(t,e)),this},add:function(t,e,i){return this.manager.add(t,e,i),this},launch:function(t,e){return t&&t!==this.key&&(this.settings.status!==s.RUNNING?this.manager.queueOp("start",t,e):this.manager.start(t,e)),this},pause:function(t){return void 0===t&&(t=this.key),this.manager.pause(t),this},resume:function(t){return void 0===t&&(t=this.key),this.manager.resume(t),this},sleep:function(t){return void 0===t&&(t=this.key),this.manager.sleep(t),this},wake:function(t){return void 0===t&&(t=this.key),this.manager.wake(t),this},switch:function(t){return t!==this.key&&(this.settings.status!==s.RUNNING?this.manager.queueOp("switch",this.key,t):this.manager.switch(this.key,t)),this},stop:function(t){return void 0===t&&(t=this.key),this.manager.stop(t),this},setActive:function(t){return this.settings.active=t,this},setVisible:function(t){return this.settings.visible=t,this},isSleeping:function(t){return void 0===t&&(t=this.key),this.manager.isSleeping(t)},isActive:function(t){return void 0===t&&(t=this.key),this.manager.isActive(t)},isVisible:function(t){return void 0===t&&(t=this.key),this.manager.isVisible(t)},swapPosition:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.swapPosition(t,e),this},moveAbove:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.moveAbove(t,e),this},moveBelow:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.moveBelow(t,e),this},remove:function(t){return void 0===t&&(t=this.key),this.manager.remove(t),this},moveUp:function(t){return void 0===t&&(t=this.key),this.manager.moveUp(t),this},moveDown:function(t){return void 0===t&&(t=this.key),this.manager.moveDown(t),this},bringToTop:function(t){return void 0===t&&(t=this.key),this.manager.bringToTop(t),this},sendToBack:function(t){return void 0===t&&(t=this.key),this.manager.sendToBack(t),this},get:function(t){return this.manager.getScene(t)},shutdown:function(){},destroy:function(){}});r.register("ScenePlugin",o,"scenePlugin"),t.exports=o},function(t,e,i){t.exports={SoundManagerCreator:i(256),BaseSound:i(85),BaseSoundManager:i(84),WebAudioSound:i(262),WebAudioSoundManager:i(261),HTML5AudioSound:i(258),HTML5AudioSoundManager:i(257),NoAudioSound:i(260),NoAudioSoundManager:i(259)}},function(t,e,i){t.exports={List:i(86),Map:i(114),ProcessQueue:i(336),RTree:i(337),Set:i(62)}},function(t,e,i){t.exports={Parsers:i(264),FilterMode:i(872),Frame:i(131),Texture:i(265),TextureManager:i(263),TextureSource:i(266)}},function(t,e){t.exports={LINEAR:0,NEAREST:1}},function(t,e,i){t.exports={Components:i(96),Parsers:i(903),Formats:i(22),ImageCollection:i(351),ParseToTilemap:i(157),Tile:i(44),Tilemap:i(355),TilemapCreator:i(920),TilemapFactory:i(921),Tileset:i(100),LayerData:i(75),MapData:i(76),ObjectLayer:i(353),DynamicTilemapLayer:i(356),StaticTilemapLayer:i(357)}},function(t,e,i){var n=i(15),s=i(34);t.exports=function(t,e,i,r,o,a,h,u){t<0&&(t=0),e<0&&(e=0),void 0===h&&(h=!0);for(var l=n(t,e,i,r,null,u),c=o-t,d=a-e,f=0;f=0&&p=0&&g-c&&y>-d&&v=0;r--)for(s=n.width-1;s>=0;s--)if((o=n.data[r][s])&&o.index===t){if(a===e)return o;a+=1}}else for(r=0;re)){for(var h=t;h<=e;h++)r(h,i,a);for(var u=0;u=t&&c.index<=e&&n(c,i)}o&&s(0,0,a.width,a.height,a)}}},function(t,e,i){var n=i(43),s=i(34),r=i(155);t.exports=function(t,e,i,o){void 0===e&&(e=!0),void 0===i&&(i=!0),Array.isArray(t)||(t=[t]);for(var a=0;a0&&n(a,t)}}e&&s(0,0,i.width,i.height,i)}},function(t,e){t.exports=function(t,e,i,n){if("number"==typeof t)n.callbacks[t]=null!==e?{callback:e,callbackContext:i}:void 0;else for(var s=0,r=t.length;s0){var y=new a(l,v.gid,c,f.length,t.tilewidth,t.tileheight);y.rotation=v.rotation,y.flipX=v.flipped,d.push(y)}else{var m=e?null:new a(l,-1,c,f.length,t.tilewidth,t.tileheight);d.push(m)}++c===u.width&&(f.push(d),c=0,d=[])}l.data=f,i.push(l)}}return i}},function(t,e){t.exports=function(t){for(var e=window.atob(t),i=e.length,n=new Array(i),s=0;s>>0;return n}},function(t,e,i){var n=i(2);t.exports=function(t){for(var e=[],i=0;i-1?new s(a,f,c,l,o.tilesize,o.tilesize):e?null:new s(a,-1,c,l,o.tilesize,o.tilesize),h.push(d)}u.push(h),h=[]}a.data=u,i.push(a)}return i}},function(t,e,i){var n=i(100);t.exports=function(t){for(var e=[],i=[],s=0;s0&&e.cameraFilter&s._id||(e.cull(s),this.pipeline.batchDynamicTilemapLayer(e,s))}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){e.cull(s);var r=e.culledTiles,o=r.length,a=e.tileset.image.getSourceImage(),h=this.tileset,u=e.x-s.scrollX*e.scrollFactorX,l=e.y-s.scrollY*e.scrollFactorY,c=t.gameContext;c.save(),c.translate(u,l),c.rotate(e.rotation),c.scale(e.scaleX,e.scaleY),c.scale(e.flipX?-1:1,e.flipY?-1:1);for(var d=0;d0&&e.cameraFilter&s._id||(e.upload(s),this.pipeline.drawStaticTilemapLayer(e,s))}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){e.cull(s);var r=e.culledTiles,o=this.tileset,a=t.gameContext,h=r.length,u=o.image.getSourceImage(),l=e.x-s.scrollX*e.scrollFactorX,c=e.y-s.scrollY*e.scrollFactorY;a.save(),a.translate(l,c),a.rotate(e.rotation),a.scale(e.scaleX,e.scaleY),a.scale(e.flipX?-1:1,e.flipY?-1:1),a.globalAlpha=e.alpha;for(var d=0;d-1&&this._active.splice(s,1),n.destroy()}for(i=0;i=n.delay)){var s=n.elapsed-n.delay;n.elapsed=n.delay,!n.hasDispatched&&n.callback&&(n.hasDispatched=!0,n.callback.apply(n.callbackScope,n.args)),n.repeatCount>0?(n.repeatCount--,n.elapsed=s,n.hasDispatched=!1):this._pendingRemoval.push(n)}}}},shutdown:function(){var t;for(t=0;t0&&(i=1/Math.sqrt(i),this.x=t*i,this.y=e*i),this},normalizeRightHand:function(){var t=this.x;return this.x=-1*this.y,this.y=t,this},dot:function(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.x},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this},transformMat3:function(t){var e=this.x,i=this.y,n=t.val;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this},transformMat4:function(t){var e=this.x,i=this.y,n=t.val;return this.x=n[0]*e+n[4]*i+n[12],this.y=n[1]*e+n[5]*i+n[13],this},reset:function(){return this.x=0,this.y=0,this}});n.ZERO=new n,t.exports=n},function(t,e){var i={},n={install:function(t){for(var e in i)t[e]=i[e]},register:function(t,e){i[t]=e},destroy:function(){i={}}};t.exports=n},function(t,e,i){var n=i(16),s=i(5);t.exports=function(t,e,i){var r=s(t,e,null);if(null===r)return i;if(Array.isArray(r))return n.RND.pick(r);if("object"==typeof r){if(r.hasOwnProperty("randInt"))return n.RND.integerInRange(r.randInt[0],r.randInt[1]);if(r.hasOwnProperty("randFloat"))return n.RND.realInRange(r.randFloat[0],r.randFloat[1])}else if("function"==typeof r)return r(e);return r}},function(t,e,i){var n=i(0),s=i(12),r=new n({initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),this.displayList,this.updateList},boot:function(){this.displayList=this.systems.displayList,this.updateList=this.systems.updateList;var t=this.systems.events;t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},existing:function(t){return(t.renderCanvas||t.renderWebGL)&&this.displayList.add(t),t.preUpdate&&this.updateList.add(t),t},shutdown:function(){},destroy:function(){this.scene=null,this.displayList=null,this.updateList=null}});r.register=function(t,e){r.prototype.hasOwnProperty(t)||(r.prototype[t]=e)},s.register("GameObjectFactory",r,"add"),t.exports=r},function(t,e,i){var n=i(0),s=i(27),r=i(166),o=i(352),a=i(104),h=i(163),u=new n({initialize:function(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x=t,this.y=e,this.width=i,this.height=n},contains:function(t,e){return s(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return h(this,t)},setTo:function(t,e,i,n){return this.x=t,this.y=e,this.width=i,this.height=n,this},setEmpty:function(){return this.setTo(0,0,0,0)},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setSize:function(t,e){return void 0===e&&(e=t),this.width=t,this.height=e,this},isEmpty:function(){return this.width<=0||this.height<=0},getLineA:function(t){return void 0===t&&(t=new a),t.setTo(this.x,this.y,this.right,this.y),t},getLineB:function(t){return void 0===t&&(t=new a),t.setTo(this.right,this.y,this.right,this.bottom),t},getLineC:function(t){return void 0===t&&(t=new a),t.setTo(this.right,this.bottom,this.x,this.bottom),t},getLineD:function(t){return void 0===t&&(t=new a),t.setTo(this.x,this.bottom,this.x,this.y),t},left:{get:function(){return this.x},set:function(t){t>=this.right?this.width=0:this.width=this.right-t,this.x=t}},right:{get:function(){return this.x+this.width},set:function(t){t<=this.x?this.width=0:this.width=t-this.x}},top:{get:function(){return this.y},set:function(t){t>=this.bottom?this.height=0:this.height=this.bottom-t,this.y=t}},bottom:{get:function(){return this.y+this.height},set:function(t){t<=this.y?this.height=0:this.height=t-this.y}},centerX:{get:function(){return this.x+this.width/2},set:function(t){this.x=t-this.width/2}},centerY:{get:function(){return this.y+this.height/2},set:function(t){this.y=t-this.height/2}}});t.exports=u},function(t,e,i){var n=i(0),s=i(12),r=new n({initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),this.displayList,this.updateList},boot:function(){this.displayList=this.systems.displayList,this.updateList=this.systems.updateList;var t=this.systems.events;t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},shutdown:function(){},destroy:function(){this.scene=null,this.displayList=null,this.updateList=null}});r.register=function(t,e){r.prototype.hasOwnProperty(t)||(r.prototype[t]=e)},s.register("GameObjectCreator",r,"make"),t.exports=r},function(t,e,i){var n={},s=new(i(0))({initialize:function(t){this.game=t,t.events.once("boot",this.boot,this)},boot:function(){this.game.events.once("destroy",this.destroy,this)},installGlobal:function(t,e){for(var i=t.game,n=t.scene,s=t.settings.map,r=0;ro.width&&(i=Math.max(o.width-t,0)),e+s>o.height&&(s=Math.max(o.height-e,0));for(var l=[],c=e;c=0;o--)t[o][e]=i+a*n,a++;return t}},function(t,e,i){var n={VERSION:"3.3.0",BlendModes:i(62),ScaleModes:i(80),AUTO:0,CANVAS:1,WEBGL:2,HEADLESS:3,FOREVER:-1,NONE:4,UP:5,DOWN:6,LEFT:7,RIGHT:8};t.exports=n},function(t,e,i){var n=i(62),s=i(8),r=i(80);t.exports=function(t,e,i){e.x=s(i,"x",0),e.y=s(i,"y",0),e.depth=s(i,"depth",0),e.flipX=s(i,"flipX",!1),e.flipY=s(i,"flipY",!1);var o=s(i,"scale",null);"number"==typeof o?e.setScale(o):null!==o&&(e.scaleX=s(o,"x",1),e.scaleY=s(o,"y",1));var a=s(i,"scrollFactor",null);"number"==typeof a?e.setScrollFactor(a):null!==a&&(e.scrollFactorX=s(a,"x",1),e.scrollFactorY=s(a,"y",1)),e.rotation=s(i,"rotation",0);var h=s(i,"angle",null);null!==h&&(e.angle=h),e.alpha=s(i,"alpha",1);var u=s(i,"origin",null);if("number"==typeof u)e.setOrigin(u);else if(null!==u){var l=s(u,"x",.5),c=s(u,"y",.5);e.setOrigin(l,c)}return e.scaleMode=s(i,"scaleMode",r.DEFAULT),e.blendMode=s(i,"blendMode",n.NORMAL),e.visible=s(i,"visible",!0),s(i,"add",!0)&&t.sys.displayList.add(e),e.preUpdate&&t.sys.updateList.add(e),e}},function(t,e,i){var n,s,r,o=i(21),a=i(151),h=[],u=!1;t.exports={create2D:function(t,e,i){return n(t,e,i,o.CANVAS)},create:n=function(t,e,i,n){var r;void 0===e&&(e=1),void 0===i&&(i=1),void 0===n&&(n=o.CANVAS);var l=s(n);return null===l?(l={parent:t,canvas:document.createElement("canvas"),type:n},h.push(l),r=l.canvas):(l.parent=t,r=l.canvas),r.width=e,r.height=i,u&&n===o.CANVAS&&a.disable(r.getContext("2d")),r},createWebGL:function(t,e,i){return n(t,e,i,o.WEBGL)},disableSmoothing:function(){u=!0},enableSmoothing:function(){u=!1},first:s=function(t){return void 0===t&&(t=o.CANVAS),h.forEach(function(e){if(!e.parent&&e.type===t)return e}),null},free:function(){return h.length-r()},pool:h,remove:function(t){var e=t instanceof HTMLCanvasElement;h.forEach(function(i){(e&&i.canvas===t||!e&&i.parent===t)&&(i.parent=null,i.canvas.width=1,i.canvas.height=1)})},total:r=function(){var t=0;return h.forEach(function(e){e.parent&&t++}),t}}},function(t,e){t.exports={CSV:0,TILED_JSON:1,ARRAY_2D:2,WELTMEISTER:3}},function(t,e){t.exports=function(t,e,i,n,s,r){var o;void 0===n&&(n=0),void 0===s&&(s=0),void 0===r&&(r=1);var a=0,h=t.length;if(1===r)for(o=s;o=0;o--)t[o][e]+=i+a*n,a++;return t}},function(t,e,i){var n=i(87),s=i(14);t.exports=function(t,e,i,r,o){for(var a=null,h=null,u=null,l=null,c=s(t,e,i,r,null,o),d=0;d=e&&t.y<=i&&t.y+t.height>=i}},function(t,e){t.exports=function(t,e,i){return t.radius>0&&e>=t.left&&e<=t.right&&i>=t.top&&i<=t.bottom&&(t.x-e)*(t.x-e)+(t.y-i)*(t.y-i)<=t.radius*t.radius}},function(t,e){t.exports=function(t,e){return t.y=e+t.height*t.originY,t}},function(t,e){t.exports=function(t){return t.y-t.height*t.originY}},function(t,e){t.exports=function(t,e){return t.x=e-t.width+t.width*t.originX,t}},function(t,e){t.exports=function(t){return t.x+t.width-t.width*t.originX}},function(t,e){t.exports=function(t,e){return t.x=e+t.width*t.originX,t}},function(t,e){t.exports=function(t){return t.x-t.width*t.originX}},function(t,e){t.exports=function(t,e){return t.y=e-t.height+t.height*t.originY,t}},function(t,e){t.exports=function(t){return t.y+t.height-t.height*t.originY}},function(t,e){t.exports=function(t,e,i,n){void 0===e&&(e=!0);var s=n.baseTileHeight,r=n.tilemapLayer;return r&&(void 0===i&&(i=r.scene.cameras.main),t-=r.y+i.scrollY*(1-r.scrollFactorY),s*=r.scaleY),e?Math.floor(t/s):t/s}},function(t,e){t.exports=function(t,e,i,n){void 0===e&&(e=!0);var s=n.baseTileWidth,r=n.tilemapLayer;return r&&(void 0===i&&(i=r.scene.cameras.main),t-=r.x+i.scrollX*(1-r.scrollFactorX),s*=r.scaleX),e?Math.floor(t/s):t/s}},,function(t,e,i){var n=i(0),s=i(13),r=i(1),o=i(870),a=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Flip,s.GetBounds,s.Origin,s.Pipeline,s.ScaleMode,s.ScrollFactor,s.Size,s.Texture,s.Tint,s.Transform,s.Visible,o],initialize:function(t,e,i,n,o){r.call(this,t,"Sprite"),this.anims=new s.Animation(this),this.setTexture(n,o),this.setPosition(e,i),this.setSizeToFrame(),this.setOriginFromFrame(),this.initPipeline("TextureTintPipeline")},preUpdate:function(t,e){this.anims.update(t,e)},play:function(t,e,i){return this.anims.play(t,e,i),this},toJSON:function(){return s.ToJSON(this)}});t.exports=a},function(t,e,i){var n=i(0),s=i(155),r=i(335),o=new n({initialize:function(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=255),this.r=0,this.g=0,this.b=0,this.a=255,this.gl=[0,0,0,1],this._color=0,this._color32=0,this._rgba="",this.setTo(t,e,i,n)},transparent:function(){return this.red=0,this.green=0,this.blue=0,this.alpha=0,this.update()},setTo:function(t,e,i,n){return void 0===n&&(n=255),this.red=t,this.green=e,this.blue=i,this.alpha=n,this.update()},setGLTo:function(t,e,i,n){return void 0===n&&(n=1),this.redGL=t,this.greenGL=e,this.blueGL=i,this.alphaGL=n,this.update()},setFromRGB:function(t){return this.red=t.r,this.green=t.g,this.blue=t.b,t.hasOwnProperty("a")&&(this.alpha=t.a),this.update()},update:function(){return this._color=s(this.r,this.g,this.b),this._color32=r(this.r,this.g,this.b,this.a),this._rgba="rgba("+this.r+","+this.g+","+this.b+","+this.a/255+")",this},clone:function(){return new o(this.r,this.g,this.b,this.a)},color:{get:function(){return this._color}},color32:{get:function(){return this._color32}},rgba:{get:function(){return this._rgba}},redGL:{get:function(){return this.gl[0]},set:function(t){this.gl[0]=Math.min(Math.abs(t),1),this.r=Math.floor(255*this.gl[0]),this.update()}},greenGL:{get:function(){return this.gl[1]},set:function(t){this.gl[1]=Math.min(Math.abs(t),1),this.g=Math.floor(255*this.gl[1]),this.update()}},blueGL:{get:function(){return this.gl[2]},set:function(t){this.gl[2]=Math.min(Math.abs(t),1),this.b=Math.floor(255*this.gl[2]),this.update()}},alphaGL:{get:function(){return this.gl[3]},set:function(t){this.gl[3]=Math.min(Math.abs(t),1),this.a=Math.floor(255*this.gl[3]),this.update()}},red:{get:function(){return this.r},set:function(t){t=Math.floor(Math.abs(t)),this.r=Math.min(t,255),this.gl[0]=t/255,this.update()}},green:{get:function(){return this.g},set:function(t){t=Math.floor(Math.abs(t)),this.g=Math.min(t,255),this.gl[1]=t/255,this.update()}},blue:{get:function(){return this.b},set:function(t){t=Math.floor(Math.abs(t)),this.b=Math.min(t,255),this.gl[2]=t/255,this.update()}},alpha:{get:function(){return this.a},set:function(t){t=Math.floor(Math.abs(t)),this.a=Math.min(t,255),this.gl[3]=t/255,this.update()}}});t.exports=o},function(t,e,i){var n=i(16);t.exports=function(t){return t*n.DEG_TO_RAD}},function(t,e){t.exports=function(t,e,i){var n=i-e;return e+((t-e)%n+n)%n}},function(t,e){t.exports={getTintFromFloats:function(t,e,i,n){return((255&(255*n|0))<<24|(255&(255*t|0))<<16|(255&(255*e|0))<<8|255&(255*i|0))>>>0},getTintAppendFloatAlpha:function(t,e){return((255&(255*e|0))<<24|t)>>>0},getTintAppendFloatAlphaAndSwap:function(t,e){return((255&(255*e|0))<<24|(255&(0|t))<<16|(255&(t>>8|0))<<8|255&(t>>16|0))>>>0},getFloatsFromUintRGB:function(t){return[(255&(t>>16|0))/255,(255&(t>>8|0))/255,(255&(0|t))/255]},getComponentCount:function(t,e){for(var i=0,n=0;nthis.right||e>this.bottom)},copy:function(t){return this.index=t.index,this.alpha=t.alpha,this.properties=t.properties,this.visible=t.visible,this.setFlip(t.flipX,t.flipY),this.tint=t.tint,this.rotation=t.rotation,this.collideUp=t.collideUp,this.collideDown=t.collideDown,this.collideLeft=t.collideLeft,this.collideRight=t.collideRight,this.collisionCallback=t.collisionCallback,this.collisionCallbackContext=t.collisionCallbackContext,this},getCollisionGroup:function(){return this.tileset?this.tileset.getTileCollisionGroup(this.index):null},getTileData:function(){return this.tileset?this.tileset.getTileData(this.index):null},getLeft:function(t){var e=this.tilemapLayer;return e?e.tileToWorldX(this.x,t):this.x*this.baseWidth},getRight:function(t){var e=this.tilemapLayer;return e?this.getLeft(t)+this.width*e.scaleX:this.getLeft(t)+this.width},getTop:function(t){var e=this.tilemapLayer;return e?e.tileToWorldY(this.y,t)-(this.height-this.baseHeight)*e.scaleY:this.y*this.baseHeight-(this.height-this.baseHeight)},getBottom:function(t){var e=this.tilemapLayer;return e?this.getTop(t)+this.height*e.scaleY:this.getTop(t)+this.height},getBounds:function(t,e){return void 0===e&&(e=new r),e.x=this.getLeft(),e.y=this.getTop(),e.width=this.getRight()-e.x,e.height=this.getBottom()-e.y,e},getCenterX:function(t){return this.getLeft(t)+this.width/2},getCenterY:function(t){return this.getTop(t)+this.height/2},destroy:function(){this.collisionCallback=void 0,this.collisionCallbackContext=void 0,this.properties=void 0},intersects:function(t,e,i,n){return!(i<=this.pixelX||n<=this.pixelY||t>=this.right||e>=this.bottom)},isInteresting:function(t,e){return t&&e?this.canCollide||this.hasInterestingFace:t?this.collides:!!e&&this.hasInterestingFace},resetCollision:function(t){(void 0===t&&(t=!0),this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,t)&&(this.tilemapLayer&&this.tilemapLayer.calculateFacesAt(this.x,this.y));return this},resetFaces:function(){return this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,this},setCollision:function(t,e,i,n,s){(void 0===e&&(e=t),void 0===i&&(i=t),void 0===n&&(n=t),void 0===s&&(s=!0),this.collideLeft=t,this.collideRight=e,this.collideUp=i,this.collideDown=n,this.faceLeft=t,this.faceRight=e,this.faceTop=i,this.faceBottom=n,s)&&(this.tilemapLayer&&this.tilemapLayer.calculateFacesAt(this.x,this.y));return this},setCollisionCallback:function(t,e){return null===t?(this.collisionCallback=void 0,this.collisionCallbackContext=void 0):(this.collisionCallback=t,this.collisionCallbackContext=e),this},setSize:function(t,e,i,n){return void 0!==t&&(this.width=t),void 0!==e&&(this.height=e),void 0!==i&&(this.baseWidth=i),void 0!==n&&(this.baseHeight=n),this.updatePixelXY(),this},updatePixelXY:function(){return this.pixelX=this.x*this.baseWidth,this.pixelY=this.y*this.baseHeight-(this.height-this.baseHeight),this},canCollide:{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.collisionCallback}},collides:{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown}},hasInterestingFace:{get:function(){return this.faceTop||this.faceBottom||this.faceLeft||this.faceRight}},tileset:{get:function(){var t=this.tilemapLayer;return t?t.tileset:null}},tilemapLayer:{get:function(){return this.layer.tilemapLayer}},tilemap:{get:function(){var t=this.tilemapLayer;return t?t.tilemap:null}}});t.exports=o},function(t,e){t.exports=function(t,e){e?t.setCollision(!0,!0,!0,!0,!1):t.resetCollision(!1)}},function(t,e){t.exports={DYNAMIC_BODY:0,STATIC_BODY:1,GROUP:2,TILEMAPLAYER:3,FACING_NONE:10,FACING_UP:11,FACING_DOWN:12,FACING_LEFT:13,FACING_RIGHT:14}},function(t,e){t.exports=function(t,e,i,n){var s=t-i,r=e-n;return Math.sqrt(s*s+r*r)}},,function(t,e,i){var n=i(0),s=i(17),r=i(19),o=i(7),a=i(2),h=new n({Extends:r,initialize:function(t,e,i,n,s){var o="string"==typeof t?t:a(t,"key",""),h={type:"image",extension:a(t,"extension","png"),responseType:"blob",key:o,url:a(t,"file",e),path:i,xhrSettings:a(t,"xhr",n),config:a(t,"config",s)};r.call(this,h)},onProcess:function(t){this.state=s.FILE_PROCESSING,this.data=new Image,this.data.crossOrigin=this.crossOrigin;var e=this;this.data.onload=function(){r.revokeObjectURL(e.data),e.onComplete(),t(e)},this.data.onerror=function(){r.revokeObjectURL(e.data),e.state=s.FILE_ERRORED,t(e)},r.createObjectURL(this.data,this.xhrLoader.response,"image/png")}});o.register("image",function(t,e,i){var n,s,r;if(Array.isArray(t))for(var o=0;o=this.x2&&this.x1>=this.x3?this.x1-t:this.x2>=this.x1&&this.x2>=this.x3?this.x2-t:this.x3-t,this.x1-=e,this.x2-=e,this.x3-=e}},top:{get:function(){return Math.min(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1<=this.y2&&this.y1<=this.y3?this.y1-t:this.y2<=this.y1&&this.y2<=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}},bottom:{get:function(){return Math.max(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1>=this.y2&&this.y1>=this.y3?this.y1-t:this.y2>=this.y1&&this.y2>=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}}});t.exports=u},function(t,e){t.exports=function(t){return Math.atan2(t.y2-t.y1,t.x2-t.x1)}},function(t,e){t.exports=function(t,e,i){var n=t.x3-t.x1,s=t.y3-t.y1,r=t.x2-t.x1,o=t.y2-t.y1,a=e-t.x1,h=i-t.y1,u=n*n+s*s,l=n*r+s*o,c=n*a+s*h,d=r*r+o*o,f=r*a+o*h,p=u*d-l*l,g=0===p?0:1/p,v=(d*c-l*f)*g,y=(u*f-l*c)*g;return v>=0&&y>=0&&v+y<1}},function(t,e){t.exports=function(t){var e={};for(var i in t)Array.isArray(t[i])?e[i]=t[i].slice(0):e[i]=t[i];return e}},function(t,e,i){var n=i(0),s=i(150),r=i(10),o=i(6),a=new n({initialize:function(t){this.type=t,this.defaultDivisions=5,this.arcLengthDivisions=100,this.cacheArcLengths=[],this.needsUpdate=!0,this.active=!0,this._tmpVec2A=new o,this._tmpVec2B=new o},draw:function(t,e){return void 0===e&&(e=32),t.strokePoints(this.getPoints(e))},getBounds:function(t,e){t||(t=new r),void 0===e&&(e=16);var i=this.getLength();e>i&&(e=i/2);var n=Math.max(1,Math.round(i/e));return s(this.getSpacedPoints(n),t)},getDistancePoints:function(t){var e=this.getLength(),i=Math.max(1,e/t);return this.getSpacedPoints(i)},getEndPoint:function(t){return void 0===t&&(t=new o),this.getPointAt(1,t)},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,i=[],n=this.getPoint(0,this._tmpVec2A),s=0;i.push(0);for(var r=1;r<=t;r++)s+=(e=this.getPoint(r/t,this._tmpVec2B)).distance(n),i.push(s),n.copy(e);return this.cacheArcLengths=i,i},getPointAt:function(t,e){var i=this.getUtoTmapping(t);return this.getPoint(i,e)},getPoints:function(t){void 0===t&&(t=this.defaultDivisions);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return e},getRandomPoint:function(t){return void 0===t&&(t=new o),this.getPoint(Math.random(),t)},getSpacedPoints:function(t){void 0===t&&(t=this.defaultDivisions);for(var e=[],i=0;i<=t;i++){var n=this.getUtoTmapping(i/t,null,t);e.push(this.getPoint(n))}return e},getStartPoint:function(t){return void 0===t&&(t=new o),this.getPointAt(0,t)},getTangent:function(t,e){void 0===e&&(e=new o);var i=t-1e-4,n=t+1e-4;return i<0&&(i=0),n>1&&(n=1),this.getPoint(i,this._tmpVec2A),this.getPoint(n,e),e.subtract(this._tmpVec2A).normalize()},getTangentAt:function(t,e){var i=this.getUtoTmapping(t);return this.getTangent(i,e)},getTFromDistance:function(t,e){return t<=0?0:this.getUtoTmapping(0,t,e)},getUtoTmapping:function(t,e,i){var n,s=this.getLengths(i),r=0,o=s.length;n=e?Math.min(e,s[o-1]):t*s[o-1];for(var a,h=0,u=o-1;h<=u;)if((a=s[r=Math.floor(h+(u-h)/2)]-n)<0)h=r+1;else{if(!(a>0)){u=r;break}u=r-1}if(s[r=u]===n)return r/(o-1);var l=s[r];return(r+(n-l)/(s[r+1]-l))/(o-1)},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()}});t.exports=a},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i){"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0):(this.x=t||0,this.y=e||0,this.z=i||0)},up:function(){return this.x=0,this.y=1,this.z=0,this},clone:function(){return new n(this.x,this.y,this.z)},crossVectors:function(t,e){var i=t.x,n=t.y,s=t.z,r=e.x,o=e.y,a=e.z;return this.x=n*a-s*o,this.y=s*r-i*a,this.z=i*o-n*r,this},equals:function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this},set:function(t,e,i){return"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0):(this.x=t||0,this.y=e||0,this.z=i||0),this},add:function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this},subtract:function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z||0,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z||1,this},scale:function(t){return isFinite(t)?(this.x*=t,this.y*=t,this.z*=t):(this.x=0,this.y=0,this.z=0),this},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z||1,this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},distance:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0;return Math.sqrt(e*e+i*i+n*n)},distanceSq:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0;return e*e+i*i+n*n},length:function(){var t=this.x,e=this.y,i=this.z;return Math.sqrt(t*t+e*e+i*i)},lengthSq:function(){var t=this.x,e=this.y,i=this.z;return t*t+e*e+i*i},normalize:function(){var t=this.x,e=this.y,i=this.z,n=t*t+e*e+i*i;return n>0&&(n=1/Math.sqrt(n),this.x=t*n,this.y=e*n,this.z=i*n),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},cross:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z;return this.x=i*o-n*r,this.y=n*s-e*o,this.z=e*r-i*s,this},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this},transformMat3:function(t){var e=this.x,i=this.y,n=this.z,s=t.val;return this.x=e*s[0]+i*s[3]+n*s[6],this.y=e*s[1]+i*s[4]+n*s[7],this.z=e*s[2]+i*s[5]+n*s[8],this},transformMat4:function(t){var e=this.x,i=this.y,n=this.z,s=t.val;return this.x=s[0]*e+s[4]*i+s[8]*n+s[12],this.y=s[1]*e+s[5]*i+s[9]*n+s[13],this.z=s[2]*e+s[6]*i+s[10]*n+s[14],this},transformCoordinates:function(t){var e=this.x,i=this.y,n=this.z,s=t.val,r=e*s[0]+i*s[4]+n*s[8]+s[12],o=e*s[1]+i*s[5]+n*s[9]+s[13],a=e*s[2]+i*s[6]+n*s[10]+s[14],h=e*s[3]+i*s[7]+n*s[11]+s[15];return this.x=r/h,this.y=o/h,this.z=a/h,this},transformQuat:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z,a=t.w,h=a*e+r*n-o*i,u=a*i+o*e-s*n,l=a*n+s*i-r*e,c=-s*e-r*i-o*n;return this.x=h*a+c*-s+u*-o-l*-r,this.y=u*a+c*-r+l*-s-h*-o,this.z=l*a+c*-o+h*-r-u*-s,this},project:function(t){var e=this.x,i=this.y,n=this.z,s=t.val,r=s[0],o=s[1],a=s[2],h=s[3],u=s[4],l=s[5],c=s[6],d=s[7],f=s[8],p=s[9],g=s[10],v=s[11],y=s[12],m=s[13],x=s[14],w=1/(e*h+i*d+n*v+s[15]);return this.x=(e*r+i*u+n*f+y)*w,this.y=(e*o+i*l+n*p+m)*w,this.z=(e*a+i*c+n*g+x)*w,this},unproject:function(t,e){var i=t.x,n=t.y,s=t.z,r=t.w,o=this.x-i,a=r-this.y-1-n,h=this.z;return this.x=2*o/s-1,this.y=2*a/r-1,this.z=2*h-1,this.project(e)},reset:function(){return this.x=0,this.y=0,this.z=0,this}});t.exports=n},function(t,e){t.exports=function(t){return t.y-t.height*t.originY+.5*t.height}},function(t,e){t.exports=function(t,e){var i=t.height*t.originY;return t.y=e+i-.5*t.height,t}},function(t,e){t.exports=function(t,e){var i=t.width*t.originX;return t.x=e+i-.5*t.width,t}},function(t,e){t.exports=function(t){return t.x-t.width*t.originX+.5*t.width}},function(t,e){t.exports={SKIP_CHECK:-1,NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16}},function(t,e,i){var n=new(i(0))({initialize:function(t){if(this.entries=[],Array.isArray(t))for(var e=0;e-1&&this.entries.splice(e,1),this},dump:function(){console.group("Set");for(var t=0;t-1},union:function(t){var e=new n;return t.entries.forEach(function(t){e.set(t)}),this.entries.forEach(function(t){e.set(t)}),e},intersect:function(t){var e=new n;return this.entries.forEach(function(i){t.contains(i)&&e.set(i)}),e},difference:function(t){var e=new n;return this.entries.forEach(function(i){t.contains(i)||e.set(i)}),e},size:{get:function(){return this.entries.length},set:function(t){return this.entries.length=t}}});t.exports=n},function(t,e){t.exports=function(t,e,i){return Math.max(e,Math.min(i,t))}},function(t,e,i){var n=i(0),s=i(2),r=new n({initialize:function(t){void 0===t&&(t={}),this.name=s(t,"name","map"),this.width=s(t,"width",0),this.height=s(t,"height",0),this.tileWidth=s(t,"tileWidth",0),this.tileHeight=s(t,"tileHeight",0),this.widthInPixels=s(t,"widthInPixels",this.width*this.tileWidth),this.heightInPixels=s(t,"heightInPixels",this.height*this.tileHeight),this.format=s(t,"format",null),this.orientation=s(t,"orientation","orthogonal"),this.version=s(t,"version","1"),this.properties=s(t,"properties",{}),this.layers=s(t,"layers",[]),this.images=s(t,"images",[]),this.objects=s(t,"objects",{}),this.collision=s(t,"collision",{}),this.tilesets=s(t,"tilesets",[]),this.imageCollections=s(t,"imageCollections",[]),this.tiles=s(t,"tiles",[])}});t.exports=r},function(t,e,i){var n=i(0),s=i(2),r=new n({initialize:function(t){void 0===t&&(t={}),this.name=s(t,"name","layer"),this.x=s(t,"x",0),this.y=s(t,"y",0),this.width=s(t,"width",0),this.height=s(t,"height",0),this.tileWidth=s(t,"tileWidth",0),this.tileHeight=s(t,"tileHeight",0),this.baseTileWidth=s(t,"baseTileWidth",this.tileWidth),this.baseTileHeight=s(t,"baseTileHeight",this.tileHeight),this.widthInPixels=s(t,"widthInPixels",this.width*this.baseTileWidth),this.heightInPixels=s(t,"heightInPixels",this.height*this.baseTileHeight),this.alpha=s(t,"alpha",1),this.visible=s(t,"visible",!0),this.properties=s(t,"properties",{}),this.indexes=s(t,"indexes",[]),this.collideIndexes=s(t,"collideIndexes",[]),this.callbacks=s(t,"callbacks",[]),this.bodies=s(t,"bodies",[]),this.data=s(t,"data",[]),this.tilemapLayer=s(t,"tilemapLayer",null)}});t.exports=r},function(t,e){t.exports=function(t,e,i){return t>=0&&t=0&&e=this.firstgid&&t=0&&g<=1&&v>=0&&v<=1&&(i.x=s+g*(o-s),i.y=r+g*(a-r),!0)}},function(t,e,i){var n=i(0),s=i(13),r=i(1),o=i(670),a=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Flip,s.GetBounds,s.Origin,s.Pipeline,s.ScaleMode,s.Size,s.Texture,s.Transform,s.Visible,s.ScrollFactor,o],initialize:function(t,e,i,n,s,o,a,h,u){if(r.call(this,t,"Mesh"),this.setTexture(h,u),this.setPosition(e,i),this.setSizeToFrame(),this.setOrigin(),this.initPipeline("TextureTintPipeline"),n.length!==s.length)throw new Error("Mesh Vertex count must match UV count");var l,c=n.length/2|0;if(o.length>0&&o.length0&&a.length=0&&e<=this.list.length&&-1===this.getIndex(t)&&this.list.splice(e,0,t),t)},addMultiple:function(t){if(Array.isArray(t))for(var e=0;en?1:0},getByKey:function(t,e){for(var i=0;ithis.list.length)return null;var i=t+Math.floor(Math.random()*e);return this.list[i]},getFirst:function(t,e,i,n){void 0===i&&(i=0),void 0===n&&(n=this.list.length);for(var s=i;s=this.list.length)throw new Error("List.moveTo: The supplied index is out of bounds");return this.list.splice(i,1),this.list.splice(e,0,t),t},remove:function(t){var e=this.list.indexOf(t);return-1!==e&&this.list.splice(e,1),t},removeAt:function(t){var e=this.list[t];return e&&this.children.splice(t,1),e},removeBetween:function(t,e){void 0===t&&(t=0),void 0===e&&(e=this.list.length);var i=e-t;if(i>0&&i<=e)return this.list.splice(t,i);if(0===i&&0===this.list.length)return[];throw new Error("List.removeBetween: Range Error, numeric values are outside the acceptable range")},removeAll:function(){for(var t=this.list.length;t--;)this.remove(this.list[t]);return this},bringToTop:function(t){return this.getIndex(t)0&&(this.remove(t),this.addAt(t,0)),t},moveUp:function(t){var e=this.getIndex(t);if(-1!==e&&e0){var i=this.getAt(e-1);i&&this.swap(t,i)}return t},reverse:function(){return this.list.reverse(),this},shuffle:function(){for(var t=this.list.length-1;t>0;t--){var e=Math.floor(Math.random()*(t+1)),i=this.list[t];this.list[t]=this.list[e],this.list[e]=i}return this},replace:function(t,e){var i=this.getIndex(t);if(-1!==i)return this.remove(t),this.addAt(e,i),t},exists:function(t){return this.list.indexOf(t)>-1},setAll:function(t,e){for(var i=0;i0?this.list[0]:null}},last:{get:function(){return this.list.length>0?(this.position=this.list.length-1,this.list[this.position]):null}},next:{get:function(){return this.position0?(this.position--,this.list[this.position]):null}}});t.exports=n},function(t,e,i){var n=i(0),s=i(15),r=i(18),o=i(3),a=new n({Extends:s,initialize:function(t,e,i){s.call(this),this.manager=t,this.key=e,this.isPlaying=!1,this.isPaused=!1,this.totalRate=1,this.duration=this.duration||0,this.totalDuration=this.totalDuration||0,this.config={delay:0},this.currentConfig=this.config,this.mute=!1,this.volume=1,this.rate=1,this.detune=0,this.seek=0,this.loop=!1,this.config=r(this.config,i),this.markers={},this.currentMarker=null,this.pendingRemove=!1},addMarker:function(t){return!(!t||!t.name||"string"!=typeof t.name)&&(this.markers[t.name]?(console.error("addMarker - Marker with name '"+t.name+"' already exists for sound '"+this.key+"'!"),!1):(t=r(!0,{name:"",start:0,duration:this.totalDuration-(t.start||0),config:{mute:!1,volume:1,rate:1,detune:0,seek:0,loop:!1,delay:0}},t),this.markers[t.name]=t,!0))},updateMarker:function(t){return!(!t||!t.name||"string"!=typeof t.name)&&(this.markers[t.name]?(this.markers[t.name]=r(!0,this.markers[t.name],t),!0):(console.error("updateMarker - Marker with name '"+t.name+"' does not exist for sound '"+this.key+"'!"),!1))},removeMarker:function(t){var e=this.markers[t];return e?(this.markers[t]=null,e):null},play:function(t,e){if(void 0===t&&(t=""),"object"==typeof t&&(e=t,t=""),"string"!=typeof t)return console.error("Sound marker name has to be a string!"),!1;if(t){if(!this.markers[t])return console.error("No marker with name '"+t+"' found for sound '"+this.key+"'!"),!1;this.currentMarker=this.markers[t],this.currentConfig=this.currentMarker.config,this.duration=this.currentMarker.duration}else this.currentMarker=null,this.currentConfig=this.config,this.duration=this.totalDuration;return this.resetConfig(),this.currentConfig=r(this.currentConfig,e),this.isPlaying=!0,this.isPaused=!1,!0},pause:function(){return!(this.isPaused||!this.isPlaying)&&(this.isPlaying=!1,this.isPaused=!0,!0)},resume:function(){return!(!this.isPaused||this.isPlaying)&&(this.isPlaying=!0,this.isPaused=!1,!0)},stop:function(){return!(!this.isPaused&&!this.isPlaying)&&(this.isPlaying=!1,this.isPaused=!1,this.resetConfig(),!0)},applyConfig:function(){this.mute=this.currentConfig.mute,this.volume=this.currentConfig.volume,this.rate=this.currentConfig.rate,this.detune=this.currentConfig.detune,this.loop=this.currentConfig.loop},resetConfig:function(){this.currentConfig.seek=0,this.currentConfig.delay=0},update:o,calculateRate:function(){var t=this.currentConfig.detune+this.manager.detune,e=Math.pow(1.0005777895065548,t);this.totalRate=this.currentConfig.rate*this.manager.rate*e},setRate:function(t){return this.rate=t,this},rate:{get:function(){return this.currentConfig.rate},set:function(t){this.currentConfig.rate=t,this.calculateRate(),this.emit("rate",this,t)}},setDetune:function(t){return this.detune=t,this},detune:{get:function(){return this.currentConfig.detune},set:function(t){this.currentConfig.detune=t,this.calculateRate(),this.emit("detune",this,t)}},destroy:function(){this.pendingRemove||(this.pendingRemove=!0,this.manager=null,this.key="",this.removeAllListeners(),this.isPlaying=!1,this.isPaused=!1,this.config=null,this.currentConfig=null,this.markers=null,this.currentMarker=null)}});t.exports=a},function(t,e,i){var n=i(0),s=i(15),r=i(3),o=new n({Extends:s,initialize:function(t){s.call(this),this.game=t,this.sounds=[],this.mute=!1,this.volume=1,this.pauseOnBlur=!0,t.events.on("blur",function(){this.pauseOnBlur&&this.onBlur()},this),t.events.on("focus",function(){this.pauseOnBlur&&this.onFocus()},this),t.events.once("destroy",this.destroy,this),this._rate=1,this._detune=0,this.locked=this.locked||!1,this.unlocked=!1,this.locked&&this.unlock()},add:r,addAudioSprite:function(t,e){var i=this.add(t,e);for(var n in i.spritemap=this.game.cache.json.get(t).spritemap,i.spritemap)if(i.spritemap.hasOwnProperty(n)){var s=i.spritemap[n];i.addMarker({name:n,start:s.start,duration:s.end-s.start,config:e})}return i},play:function(t,e){var i=this.add(t);return i.once("ended",i.destroy,i),e?e.name?(i.addMarker(e),i.play(e.name)):i.play(e):i.play()},playAudioSprite:function(t,e,i){var n=this.addAudioSprite(t);return n.once("ended",n.destroy,n),n.play(e,i)},remove:function(t){var e=this.sounds.indexOf(t);return-1!==e&&(t.destroy(),this.sounds.splice(e,1),!0)},removeByKey:function(t){for(var e=0,i=this.sounds.length-1;i>=0;i--){var n=this.sounds[i];n.key===t&&(n.destroy(),this.sounds.splice(i,1),e++)}return e},pauseAll:function(){this.forEachActiveSound(function(t){t.pause()}),this.emit("pauseall",this)},resumeAll:function(){this.forEachActiveSound(function(t){t.resume()}),this.emit("resumeall",this)},stopAll:function(){this.forEachActiveSound(function(t){t.stop()}),this.emit("stopall",this)},unlock:r,onBlur:r,onFocus:r,update:function(t,e){this.unlocked&&(this.unlocked=!1,this.locked=!1,this.emit("unlocked",this));for(var i=this.sounds.length-1;i>=0;i--)this.sounds[i].pendingRemove&&this.sounds.splice(i,1);this.sounds.forEach(function(i){i.update(t,e)})},destroy:function(){this.removeAllListeners(),this.forEachActiveSound(function(t){t.destroy()}),this.sounds.length=0,this.sounds=null,this.game=null},forEachActiveSound:function(t,e){var i=this;this.sounds.forEach(function(n,s){n.pendingRemove||t.call(e||i,n,s,i.sounds)})},setRate:function(t){return this.rate=t,this},rate:{get:function(){return this._rate},set:function(t){this._rate=t,this.forEachActiveSound(function(t){t.setRate()}),this.emit("rate",this,t)}},setDetune:function(t){return this.detune=t,this},detune:{get:function(){return this._detune},set:function(t){this._detune=t,this.forEachActiveSound(function(t){t.setRate()}),this.emit("detune",this,t)}}});t.exports=o},function(t,e,i){var n,s=i(76),r={chrome:!1,chromeVersion:0,edge:!1,firefox:!1,firefoxVersion:0,ie:!1,ieVersion:0,mobileSafari:!1,opera:!1,safari:!1,safariVersion:0,silk:!1,trident:!1,tridentVersion:0};t.exports=(n=navigator.userAgent,/Edge\/\d+/.test(n)?r.edge=!0:/Chrome\/(\d+)/.test(n)&&!s.windowsPhone?(r.chrome=!0,r.chromeVersion=parseInt(RegExp.$1,10)):/Firefox\D+(\d+)/.test(n)?(r.firefox=!0,r.firefoxVersion=parseInt(RegExp.$1,10)):/AppleWebKit/.test(n)&&s.iOS?r.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(n)?(r.ie=!0,r.ieVersion=parseInt(RegExp.$1,10)):/Opera/.test(n)?r.opera=!0:/Safari/.test(n)&&!s.windowsPhone?r.safari=!0:/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(n)&&(r.ie=!0,r.trident=!0,r.tridentVersion=parseInt(RegExp.$1,10),r.ieVersion=parseInt(RegExp.$3,10)),/Silk/.test(n)&&(r.silk=!0),r)},function(t,e,i){var n=i(0),s=i(1),r=i(40),o=i(6),a=i(152),h=new n({Extends:s,initialize:function(t,e,i,n,h,u){s.call(this,t,"Sprite3D"),this.gameObject=new r(t,0,0,h,u),this.position=new a(e,i,n),this.size=new o(this.gameObject.width,this.gameObject.height),this.scale=new o(1,1),this.adjustScaleX=!0,this.adjustScaleY=!0,this._visible=!0},project:function(t){var e=this.position,i=this.gameObject;t.project(e,i),t.getPointSize(e,this.size,this.scale),this.scale.x<=0||this.scale.y<=0?i.setVisible(!1):(i.visible||i.setVisible(!0),this.adjustScaleX&&(i.scaleX=this.scale.x),this.adjustScaleY&&(i.scaleY=this.scale.y),i.setDepth(-1*i.z))},setVisible:function(t){return this.visible=t,this},visible:{get:function(){return this._visible},set:function(t){this._visible=t,this.gameObject.visible=t}},x:{get:function(){return this.position.x},set:function(t){this.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t}},z:{get:function(){return this.position.z},set:function(t){this.position.z=t}}});t.exports=h},function(t,e){t.exports=function(t){for(var e=t.length-1;e>0;e--){var i=Math.floor(Math.random()*(e+1)),n=t[e];t[e]=t[i],t[i]=n}return t}},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.parent=t,this.events=e,e||(this.events=t.events?t.events:t),this.list={},this.blockSet=!1,this._frozen=!1,this.events.once("destroy",this.destroy,this)},get:function(t){return this.list[t]},getAll:function(){var t={};for(var e in this.list)this.list.hasOwnProperty(e)&&(t[e]=this.list[e]);return t},query:function(t){var e={};for(var i in this.list)this.list.hasOwnProperty(i)&&i.match(t)&&(e[i]=this.list[i]);return e},set:function(t,e){if(this._frozen)return this;if(this.events.listenerCount("changedata")>0){this.blockSet=!1;var i=this;if(this.events.emit("changedata",this.parent,t,e,function(e){i.blockSet=!0,i.list[t]=e,i.events.emit("setdata",i.parent,t,e)}),this.blockSet)return this}return this.list[t]=e,this.events.emit("setdata",this.parent,t,e),this},each:function(t,e){for(var i=[this.parent,null,void 0],n=1;nthis.x2?this.x1=t:this.x2=t}},top:{get:function(){return Math.min(this.y1,this.y2)},set:function(t){this.y1<=this.y2?this.y1=t:this.y2=t}},bottom:{get:function(){return Math.max(this.y1,this.y2)},set:function(t){this.y1>this.y2?this.y1=t:this.y2=t}}});t.exports=h},function(t,e){t.exports=function(t){return 2*(t.width+t.height)}},function(t,e,i){var n=i(62),s=i(79),r=i(28),o=i(0),a=i(13),h=i(1),u=i(10),l=i(27),c=new o({Extends:h,Mixins:[a.Depth,a.GetBounds,a.Origin,a.ScaleMode,a.Transform,a.ScrollFactor,a.Visible],initialize:function(t,e,i,s,r){void 0===s&&(s=1),void 0===r&&(r=s),h.call(this,t,"Zone"),this.setPosition(e,i),this.width=s,this.height=r,this.blendMode=n.NORMAL},displayWidth:{get:function(){return this.scaleX*this.width},set:function(t){this.scaleX=t/this.width}},displayHeight:{get:function(){return this.scaleY*this.height},set:function(t){this.scaleY=t/this.height}},setSize:function(t,e,i){return void 0===i&&(i=!0),this.width=t,this.height=e,i&&this.input&&this.input.hitArea instanceof u&&(this.input.hitArea.width=t,this.input.hitArea.height=e),this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this},setCircleDropZone:function(t){return this.setDropZone(new s(0,0,t),r)},setRectangleDropZone:function(t,e){var i=-t/2,n=-e/2;return this.setDropZone(new u(i,n,t,e),l)},setDropZone:function(t,e){return void 0===t?this.setRectangleDropZone(this.width,this.height):this.input||this.setInteractive(t,e,!0),this},renderCanvas:function(){},renderWebGL:function(){}});t.exports=c},function(t,e,i){var n=i(55);t.exports=function(t,e){var i=n(t);for(var s in e)i.hasOwnProperty(s)||(i[s]=e[s]);return i}},function(t,e,i){var n=i(0),s=i(44),r=new n({initialize:function(t){this.name="WebGLPipeline",this.game=t.game,this.view=t.game.canvas,this.resolution=t.game.config.resolution,this.width=t.game.config.width*this.resolution,this.height=t.game.config.height*this.resolution,this.gl=t.gl,this.vertexCount=0,this.vertexCapacity=t.vertexCapacity,this.renderer=t.renderer,this.vertexData=t.vertices?t.vertices:new ArrayBuffer(t.vertexCapacity*t.vertexSize),this.vertexBuffer=this.renderer.createVertexBuffer(t.vertices?t.vertices:this.vertexData.byteLength,this.gl.STREAM_DRAW),this.program=this.renderer.createProgram(t.vertShader,t.fragShader),this.attributes=t.attributes,this.vertexSize=t.vertexSize,this.topology=t.topology,this.bytes=new Uint8Array(this.vertexData),this.vertexComponentCount=s.getComponentCount(t.attributes,this.gl),this.flushLocked=!1},addAttribute:function(t,e,i,n,s){return this.attributes.push({name:t,size:e,type:this.renderer.glFormats[i],normalized:n,offset:s}),this},shouldFlush:function(){return this.vertexCount>=this.vertexCapacity},resize:function(t,e,i){return this.width=t*i,this.height=e*i,this},bind:function(){var t=this.gl,e=this.vertexBuffer,i=this.attributes,n=this.program,s=this.renderer,r=this.vertexSize;s.setProgram(n),s.setVertexBuffer(e);for(var o=0;o=0?(t.enableVertexAttribArray(h),t.vertexAttribPointer(h,a.size,a.type,a.normalized,r,a.offset)):t.disableVertexAttribArray(h)}return this},onBind:function(){return this},onPreRender:function(){return this},onRender:function(){return this},onPostRender:function(){return this},flush:function(){if(this.flushLocked)return this;this.flushLocked=!0;var t=this.gl,e=this.vertexCount,i=this.topology,n=this.vertexSize;if(0!==e)return t.bufferSubData(t.ARRAY_BUFFER,0,this.bytes.subarray(0,e*n)),t.drawArrays(i,0,e),this.vertexCount=0,this.flushLocked=!1,this;this.flushLocked=!1},destroy:function(){var t=this.gl;return t.deleteProgram(this.program),t.deleteBuffer(this.vertexBuffer),delete this.program,delete this.vertexBuffer,delete this.gl,this},setFloat1:function(t,e){return this.renderer.setFloat1(this.program,t,e),this},setFloat2:function(t,e,i){return this.renderer.setFloat2(this.program,t,e,i),this},setFloat3:function(t,e,i,n){return this.renderer.setFloat3(this.program,t,e,i,n),this},setFloat4:function(t,e,i,n,s){return this.renderer.setFloat4(this.program,t,e,i,n,s),this},setInt1:function(t,e){return this.renderer.setInt1(this.program,t,e),this},setInt2:function(t,e,i){return this.renderer.setInt2(this.program,t,e,i),this},setInt3:function(t,e,i,n){return this.renderer.setInt3(this.program,t,e,i,n),this},setInt4:function(t,e,i,n,s){return this.renderer.setInt4(this.program,t,e,i,n,s),this},setMatrix2:function(t,e,i){return this.renderer.setMatrix2(this.program,t,e,i),this},setMatrix3:function(t,e,i){return this.renderer.setMatrix3(this.program,t,e,i),this},setMatrix4:function(t,e,i){return this.renderer.setMatrix4(this.program,t,e,i),this}});t.exports=r},function(t,e){t.exports=function(t){if(!Array.isArray(t)||t.length<2||!Array.isArray(t[0]))return!1;for(var e=t[0].length,i=1;i0&&(n.totalDuration+=n.t2*n.repeat),n.totalDuration>t&&(t=n.totalDuration)}this.duration=t,this.loopCounter=-1===this.loop?999999999999:this.loop,this.loopCounter>0?this.totalDuration=this.duration+this.completeDelay+(this.duration+this.loopDelay)*this.loopCounter:this.totalDuration=this.duration+this.completeDelay},init:function(){for(var t=this.data,e=this.totalTargets,i=0;i0){this.elapsed=0,this.progress=0,this.loopCounter--;var t=this.callbacks.onLoop;t&&(t.params[1]=this.targets,t.func.apply(t.scope,t.params)),this.resetTweenData(!0),this.loopDelay>0?(this.countdown=this.loopDelay,this.state=o.LOOP_DELAY):this.state=o.ACTIVE}else if(this.completeDelay>0)this.countdown=this.completeDelay,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.PENDING_REMOVE}},pause:function(){if(this.state!==o.PAUSED)return this.paused=!0,this._pausedState=this.state,this.state=o.PAUSED,this},play:function(t){if(this.state!==o.ACTIVE){this.state!==o.PENDING_REMOVE&&this.state!==o.REMOVED||(this.init(),this.parent.makeActive(this),t=!0);var e=this.callbacks.onStart;this.parentIsTimeline?(this.resetTweenData(t),0===this.calculatedOffset?(e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.ACTIVE):(this.countdown=this.calculatedOffset,this.state=o.OFFSET_DELAY)):this.paused?(this.paused=!1,this.parent.makeActive(this)):(this.resetTweenData(t),this.state=o.ACTIVE,e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)))}},resetTweenData:function(t){for(var e=this.data,i=0;i0?(n.elapsed=n.delay,n.state=o.DELAY):n.state=o.PENDING_RENDER}},resume:function(){return this.state===o.PAUSED&&(this.paused=!1,this.state=this._pausedState),this},seek:function(t){for(var e=this.data,i=0;i=s.totalDuration?(r=1,o=s.duration):n>s.delay&&n<=s.t1?(r=(n=Math.max(0,n-s.delay))/s.t1,o=s.duration*r):n>s.t1&&ns.repeatDelay&&(r=n/s.t1,o=s.duration*r)),s.progress=r,s.elapsed=o;var a=s.ease(s.progress);s.current=s.start+(s.end-s.start)*a,s.target[s.key]=s.current}},setCallback:function(t,e,i,n){return this.callbacks[t]={func:e,scope:n,params:i},this},complete:function(t){if(void 0===t&&(t=0),t)this.countdown=t,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.PENDING_REMOVE}},stop:function(t){this.state===o.ACTIVE&&void 0!==t&&this.seek(t),this.state!==o.REMOVED&&(this.state=o.PENDING_REMOVE)},update:function(t,e){if(this.state===o.PAUSED)return!1;switch(this.useFrames&&(e=1*this.parent.timeScale),e*=this.timeScale,this.elapsed+=e,this.progress=Math.min(this.elapsed/this.duration,1),this.totalElapsed+=e,this.totalProgress=Math.min(this.totalElapsed/this.totalDuration,1),this.state){case o.ACTIVE:for(var i=!1,n=0;n0){e.repeatCounter--,e.elapsed=i,e.progress=i/e.duration,e.flipX&&e.target.toggleFlipX(),e.flipY&&e.target.toggleFlipY();var s=t.callbacks.onRepeat;return s&&(s.params[1]=e.target,s.func.apply(s.scope,s.params)),e.start=e.getStartValue(e.target,e.key,e.start),e.end=e.getEndValue(e.target,e.key,e.start),e.repeatDelay>0?(e.elapsed=e.repeatDelay-i,e.current=e.start,e.target[e.key]=e.current,o.REPEAT_DELAY):o.PLAYING_FORWARD}return o.COMPLETE},setStateFromStart:function(t,e,i){if(e.repeatCounter>0){e.repeatCounter--,e.elapsed=i,e.progress=i/e.duration,e.flipX&&e.target.toggleFlipX(),e.flipY&&e.target.toggleFlipY();var n=t.callbacks.onRepeat;return n&&(n.params[1]=e.target,n.func.apply(n.scope,n.params)),e.end=e.getEndValue(e.target,e.key,e.start),e.repeatDelay>0?(e.elapsed=e.repeatDelay-i,e.current=e.start,e.target[e.key]=e.current,o.REPEAT_DELAY):o.PLAYING_FORWARD}return o.COMPLETE},updateTweenData:function(t,e,i){switch(e.state){case o.PLAYING_FORWARD:case o.PLAYING_BACKWARD:if(!e.target){e.state=o.COMPLETE;break}var n=e.elapsed,s=e.duration,r=0;(n+=i)>s&&(r=n-s,n=s);var a,h=e.state===o.PLAYING_FORWARD,u=n/s;a=h?e.ease(u):e.ease(1-u),e.current=e.start+(e.end-e.start)*a,e.target[e.key]=e.current,e.elapsed=n,e.progress=u;var l=t.callbacks.onUpdate;l&&(l.params[1]=e.target,l.func.apply(l.scope,l.params)),1===u&&(h?e.hold>0?(e.elapsed=e.hold-r,e.state=o.HOLD_DELAY):e.state=this.setStateFromEnd(t,e,r):e.state=this.setStateFromStart(t,e,r));break;case o.DELAY:e.elapsed-=i,e.elapsed<=0&&(e.elapsed=Math.abs(e.elapsed),e.state=o.PENDING_RENDER);break;case o.REPEAT_DELAY:e.elapsed-=i,e.elapsed<=0&&(e.elapsed=Math.abs(e.elapsed),e.state=o.PLAYING_FORWARD);break;case o.HOLD_DELAY:e.elapsed-=i,e.elapsed<=0&&(e.state=this.setStateFromEnd(t,e,Math.abs(e.elapsed)));break;case o.PENDING_RENDER:e.target?(e.start=e.getStartValue(e.target,e.key,e.target[e.key]),e.end=e.getEndValue(e.target,e.key,e.start),e.current=e.start,e.target[e.key]=e.start,e.state=o.PLAYING_FORWARD):e.state=o.COMPLETE}return e.state!==o.COMPLETE}});a.TYPES=["onComplete","onLoop","onRepeat","onStart","onUpdate","onYoyo"],r.register("tween",function(t){return this.scene.sys.tweens.add(t)}),s.register("tween",function(t){return this.scene.sys.tweens.create(t)}),t.exports=a},function(t,e){t.exports={targets:null,delay:0,duration:1e3,ease:"Power0",easeParams:null,hold:0,repeat:0,repeatDelay:0,yoyo:!1,flipX:!1,flipY:!1}},function(t,e){function i(t){return!!t.getStart&&"function"==typeof t.getStart}function n(t){return!!t.getEnd&&"function"==typeof t.getEnd}var s=function(t,e){var r,o,a=function(t,e,i){return i},h=function(t,e,i){return i},u=typeof e;if("number"===u)a=function(){return e};else if("string"===u){var l=e[0],c=parseFloat(e.substr(2));switch(l){case"+":a=function(t,e,i){return i+c};break;case"-":a=function(t,e,i){return i-c};break;case"*":a=function(t,e,i){return i*c};break;case"/":a=function(t,e,i){return i/c};break;default:a=function(){return parseFloat(e)}}}else"function"===u?a=e:"object"===u&&(i(o=e)||n(o))?(n(e)&&(a=e.getEnd),i(e)&&(h=e.getStart)):e.hasOwnProperty("value")&&(r=s(t,e.value));return r||(r={getEnd:a,getStart:h}),r};t.exports=s},function(t,e,i){var n=i(5);t.exports=function(t){var e=n(t,"targets",null);return null===e?e:("function"==typeof e&&(e=e.call()),Array.isArray(e)||(e=[e]),e)}},function(t,e,i){var n=i(24),s=i(65),r=i(194),o=i(186);t.exports=function(t,e,i,a,h,u,l,c){void 0===i&&(i=32),void 0===a&&(a=32),void 0===h&&(h=10),void 0===u&&(u=10),void 0===c&&(c=!1);var d=null;if(Array.isArray(l))d=r(void 0!==e?e:"map",n.ARRAY_2D,l,i,a,c);else if(void 0!==e){var f=t.cache.tilemap.get(e);f?d=r(e,f.format,f.data,i,a,c):console.warn("No map data found for key "+e)}return null===d&&(d=new s({tileWidth:i,tileHeight:a,width:h,height:u})),new o(t,d)}},function(t,e,i){var n=i(24),s=i(66),r=i(65),o=i(45);t.exports=function(t,e,i,a,h){for(var u=new s({tileWidth:i,tileHeight:a}),l=new r({name:t,tileWidth:i,tileHeight:a,format:n.ARRAY_2D,layers:[u]}),c=[],d=e.length,f=0,p=0;p=0&&r>=0&&s+r<1&&(n.push({x:e[b].x,y:e[b].y}),i)));b++);return n}},function(t,e,i){var n=i(0),s=i(96),r=new n({Extends:s,initialize:function(t,e,i,n,r){s.call(this,t,e,i,[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,1,1,1,0,0,1,1,1,0],[16777215,16777215,16777215,16777215,16777215,16777215],[1,1,1,1,1,1],n,r),this.resetPosition()},topLeftX:{get:function(){return this.x+this.vertices[0]},set:function(t){this.vertices[0]=t-this.x,this.vertices[6]=t-this.x}},topLeftY:{get:function(){return this.y+this.vertices[1]},set:function(t){this.vertices[1]=t-this.y,this.vertices[7]=t-this.y}},topRightX:{get:function(){return this.x+this.vertices[10]},set:function(t){this.vertices[10]=t-this.x}},topRightY:{get:function(){return this.y+this.vertices[11]},set:function(t){this.vertices[11]=t-this.y}},bottomLeftX:{get:function(){return this.x+this.vertices[2]},set:function(t){this.vertices[2]=t-this.x}},bottomLeftY:{get:function(){return this.y+this.vertices[3]},set:function(t){this.vertices[3]=t-this.y}},bottomRightX:{get:function(){return this.x+this.vertices[4]},set:function(t){this.vertices[4]=t-this.x,this.vertices[8]=t-this.x}},bottomRightY:{get:function(){return this.y+this.vertices[5]},set:function(t){this.vertices[5]=t-this.y,this.vertices[9]=t-this.y}},topLeftAlpha:{get:function(){return this.alphas[0]},set:function(t){this.alphas[0]=t,this.alphas[3]=t}},topRightAlpha:{get:function(){return this.alphas[5]},set:function(t){this.alphas[5]=t}},bottomLeftAlpha:{get:function(){return this.alphas[1]},set:function(t){this.alphas[1]=t}},bottomRightAlpha:{get:function(){return this.alphas[2]},set:function(t){this.alphas[2]=t,this.alphas[4]=t}},topLeftColor:{get:function(){return this.colors[0]},set:function(t){this.colors[0]=t,this.colors[3]=t}},topRightColor:{get:function(){return this.colors[5]},set:function(t){this.colors[5]=t}},bottomLeftColor:{get:function(){return this.colors[1]},set:function(t){this.colors[1]=t}},bottomRightColor:{get:function(){return this.colors[2]},set:function(t){this.colors[2]=t,this.colors[4]=t}},setTopLeft:function(t,e){return this.topLeftX=t,this.topLeftY=e,this},setTopRight:function(t,e){return this.topRightX=t,this.topRightY=e,this},setBottomLeft:function(t,e){return this.bottomLeftX=t,this.bottomLeftY=e,this},setBottomRight:function(t,e){return this.bottomRightX=t,this.bottomRightY=e,this},resetPosition:function(){var t=this.x,e=this.y,i=Math.floor(this.width/2),n=Math.floor(this.height/2);return this.setTopLeft(t-i,e-n),this.setTopRight(t+i,e-n),this.setBottomLeft(t-i,e+n),this.setBottomRight(t+i,e+n),this},resetAlpha:function(){var t=this.alphas;return t[0]=1,t[1]=1,t[2]=1,t[3]=1,t[4]=1,t[5]=1,this},resetColors:function(){var t=this.colors;return t[0]=16777215,t[1]=16777215,t[2]=16777215,t[3]=16777215,t[4]=16777215,t[5]=16777215,this},reset:function(){return this.resetPosition(),this.resetAlpha(),this.resetColors()}});t.exports=r},function(t,e,i){var n=i(23),s=i(0),r=i(13),o=i(21),a=i(1),h=i(248),u=i(700),l=new s({Extends:a,Mixins:[r.Alpha,r.BlendMode,r.Depth,r.Flip,r.GetBounds,r.Origin,r.Pipeline,r.ScaleMode,r.ScrollFactor,r.Size,r.Texture,r.Tint,r.Transform,r.Visible,u],initialize:function(t,e,i,s,r,u,l){var c=t.sys.game.renderer;a.call(this,t,"TileSprite"),this.tilePositionX=0,this.tilePositionY=0,this.dirty=!0,this.tileTexture=null,this.renderer=c,this.setTexture(u,l),this.setPosition(e,i),this.setSize(s,r),this.setOriginFromFrame(),this.initPipeline("TextureTintPipeline"),this.potWidth=h(this.frame.width),this.potHeight=h(this.frame.height),this.canvasPattern=null,this.canvasBuffer=n.create2D(null,this.potWidth,this.potHeight),this.canvasBufferCtx=this.canvasBuffer.getContext("2d"),this.oldFrame=null,this.updateTileTexture(),t.sys.game.config.renderType===o.WEBGL&&t.sys.game.renderer.onContextRestored(function(t){var e=t.gl;this.tileTexture=null,this.dirty=!0,this.tileTexture=t.createTexture2D(0,e.LINEAR,e.LINEAR,e.REPEAT,e.REPEAT,e.RGBA,this.canvasBuffer,this.potWidth,this.potHeight)},this)},setTilePosition:function(t,e){return void 0!==t&&(this.tilePositionX=t),void 0!==e&&(this.tilePositionY=e),this},updateTileTexture:function(){(this.dirty||this.oldFrame!==this.frame)&&(this.oldFrame=this.frame,this.canvasBufferCtx.clearRect(0,0,this.canvasBuffer.width,this.canvasBuffer.height),this.renderer.gl?(this.canvasBufferCtx.drawImage(this.frame.source.image,this.frame.cutX,this.frame.cutY,this.frame.cutWidth,this.frame.cutHeight,0,0,this.potWidth,this.potHeight),this.tileTexture=this.renderer.canvasToTexture(this.canvasBuffer,this.tileTexture,null===this.tileTexture,this.scaleMode)):(this.canvasBuffer.width=this.frame.cutWidth,this.canvasBuffer.height=this.frame.cutHeight,this.canvasBufferCtx.drawImage(this.frame.source.image,this.frame.cutX,this.frame.cutY,this.frame.cutWidth,this.frame.cutHeight,0,0,this.frame.cutWidth,this.frame.cutHeight),this.canvasPattern=this.canvasBufferCtx.createPattern(this.canvasBuffer,"repeat")),this.dirty=!1)},destroy:function(){this.renderer&&this.renderer.deleteTexture(this.tileTexture),n.remove(this.canvasBuffer),this.canvasPattern=null,this.canvasBufferCtx=null,this.canvasBuffer=null,this.renderer=null,this.visible=!1}});t.exports=l},function(t,e,i){var n=i(147),s=i(23),r=i(0),o=i(13),a=i(21),h=i(1),u=i(706),l=i(5),c=i(305),d=i(705),f=i(702),p=new r({Extends:h,Mixins:[o.Alpha,o.BlendMode,o.ComputedSize,o.Depth,o.Flip,o.GetBounds,o.Origin,o.Pipeline,o.ScaleMode,o.ScrollFactor,o.Tint,o.Transform,o.Visible,d],initialize:function(t,e,i,n,r){void 0===e&&(e=0),void 0===i&&(i=0),h.call(this,t,"Text"),this.setPosition(e,i),this.setOrigin(0,0),this.initPipeline("TextureTintPipeline"),this.canvas=s.create(this),this.context=this.canvas.getContext("2d"),this.style=new f(this,r),this.autoRound=!0,this.splitRegExp=/(?:\r\n|\r|\n)/,this.text="",this.resolution=1,this.padding={left:0,right:0,top:0,bottom:0},this.width=1,this.height=1,this.canvasTexture=null,this.dirty=!1,this.initRTL(),r&&r.padding&&this.setPadding(r.padding),r&&r.lineSpacing&&(this._lineSpacing=r.lineSpacing),this.setText(n),t.sys.game.config.renderType===a.WEBGL&&t.sys.game.renderer.onContextRestored(function(){this.canvasTexture=null,this.dirty=!0},this)},initRTL:function(){this.style.rtl&&(this.canvas.dir="rtl",this.context.direction="rtl",this.canvas.style.display="none",n(this.canvas,this.scene.sys.canvas),this.originX=1)},runWordWrap:function(t){var e=this.style;if(e.wordWrapCallback){var i=e.wordWrapCallback.call(e.wordWrapCallbackScope,t,this);return Array.isArray(i)&&(i=i.join("\n")),i}return e.wordWrapWidth?e.wordWrapUseAdvanced?this.advancedWordWrap(t,this.context,this.style.wordWrapWidth):this.basicWordWrap(t,this.context,this.style.wordWrapWidth):t},advancedWordWrap:function(t,e,i){for(var n="",s=t.replace(/ +/gi," ").split(this.splitRegExp),r=s.length,o=0;ou){if(0===c){for(var g=f;g.length&&(g=g.slice(0,-1),!((p=e.measureText(g).width)<=u)););if(!g.length)throw new Error("This text's wordWrapWidth setting is less than a single character!");var v=d.substr(g.length);l[c]=v,h+=g}var y=l[c].length?c:c+1,m=l.slice(y).join(" ").replace(/[ \n]*$/gi,"");s[o+1]=m+" "+(s[o+1]||""),r=s.length;break}h+=f,u-=p}n+=h.replace(/[ \n]*$/gi,"")+"\n"}}return n=n.replace(/[\s|\n]*$/gi,"")},basicWordWrap:function(t,e,i){for(var n="",s=t.split(this.splitRegExp),r=0;ro?(h>0&&(n+="\n"),n+=a[h]+" ",o=i-u):(o-=l,n+=a[h]+" ")}r0&&(a+=l.lineSpacing*p),i.rtl?o=d-o:"right"===i.align?o+=l.width-l.lineWidths[p]:"center"===i.align&&(o+=(l.width-l.lineWidths[p])/2),this.autoRound&&(o=Math.round(o),a=Math.round(a)),i.strokeThickness&&(this.style.syncShadow(e,i.shadowStroke),e.strokeText(h[p],o,a)),i.color&&(this.style.syncShadow(e,i.shadowFill),e.fillText(h[p],o,a));return e.restore(),this.dirty=!0,this},getTextMetrics:function(){return this.style.getTextMetrics()},toJSON:function(){var t=o.ToJSON(this),e={autoRound:this.autoRound,text:this.text,style:this.style.toJSON(),resolution:this.resolution,padding:{left:this.padding.left,right:this.padding.right,top:this.padding.top,bottom:this.padding.bottom}};return t.data=e,t},preDestroy:function(){this.style.rtl&&c(this.canvas),s.remove(this.canvas)}});t.exports=p},function(t,e,i){var n=i(23),s=i(0),r=i(13),o=i(21),a=i(1),h=i(711),u=i(708),l=i(707),c=new s({Extends:a,Mixins:[r.Alpha,r.BlendMode,r.Depth,r.Flip,r.GetBounds,r.MatrixStack,r.Origin,r.Pipeline,r.ScaleMode,r.ScrollFactor,r.Size,r.Tint,r.Transform,r.Visible,h],initialize:function(t,e,i,s,r){if(void 0===s&&(s=32),void 0===r&&(r=32),a.call(this,t,"RenderTexture"),this.initMatrixStack(),this.renderer=t.sys.game.renderer,this.globalTint=16777215,this.globalAlpha=1,this.renderer.type===o.WEBGL){var h=this.renderer.gl;this.gl=h,this.fill=l.fill,this.clear=l.clear,this.draw=l.draw,this.drawFrame=l.drawFrame,this.texture=this.renderer.createTexture2D(0,h.NEAREST,h.NEAREST,h.CLAMP_TO_EDGE,h.CLAMP_TO_EDGE,h.RGBA,null,s,r,!1),this.framebuffer=this.renderer.createFramebuffer(s,r,this.texture,!1)}else this.renderer.type===o.CANVAS&&(this.fill=u.fill,this.clear=u.clear,this.draw=u.draw,this.drawFrame=u.drawFrame,this.canvas=n.create2D(null,s,r),this.context=this.canvas.getContext("2d"));this.setPosition(e,i),this.setSize(s,r),this.initPipeline("TextureTintPipeline")},destroy:function(){a.destroy.call(this),this.renderer.type===o.WEBGL&&(this.renderer.deleteTexture(this.texture),this.renderer.deleteFramebuffer(this.framebuffer))},setGlobalTint:function(t){return this.globalTint=t,this},setGlobalAlpha:function(t){return this.globalAlpha=t,this}});t.exports=c},function(t,e){t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=t.length);var n=e+Math.floor(Math.random()*i);return void 0===t[n]?null:t[n]}},function(t,e,i){var n=i(0),s=i(13),r=i(1),o=i(754),a=i(97),h=i(753),u=i(714),l=new n({Extends:r,Mixins:[s.Depth,s.Visible,s.Pipeline,u],initialize:function(t,e,i,n){if(r.call(this,t,"ParticleEmitterManager"),this.blendMode=-1,this.timeScale=1,this.texture=null,this.frame=null,this.frameNames=[],null===i||"object"!=typeof i&&!Array.isArray(i)||(n=i,i=null),this.setTexture(e,i),this.initPipeline("TextureTintPipeline"),this.emitters=new a(this),this.wells=new a(this),n){Array.isArray(n)||(n=[n]);for(var s=0;s0?e.defaultFrame=i[0]:e.defaultFrame=this.defaultFrame,this},addEmitter:function(t){return this.emitters.add(t)},createEmitter:function(t){return this.addEmitter(new h(this,t))},addGravityWell:function(t){return this.wells.add(t)},createGravityWell:function(t){return this.addGravityWell(new o(t))},emitParticle:function(t,e,i){for(var n=this.emitters.list,s=0;s-1&&this.fillStyle(this.defaultFillColor,this.defaultFillAlpha),this.defaultStrokeColor>-1&&this.lineStyle(this.defaultStrokeWidth,this.defaultStrokeColor,this.defaultStrokeAlpha),this},generateTexture:function(t,e,i){var n,s,r=this.scene.sys;if(void 0===e&&(e=r.game.config.width),void 0===i&&(i=r.game.config.height),d.TargetCamera.setViewport(0,0,e,i),d.TargetCamera.scrollX=this.x,d.TargetCamera.scrollY=this.y,"string"==typeof t)if(r.textures.exists(t)){var o=(n=r.textures.get(t)).getSourceImage();o instanceof HTMLCanvasElement&&(s=o.getContext("2d"))}else s=(n=r.textures.createCanvas(t,e,i)).getSourceImage().getContext("2d");else t instanceof HTMLCanvasElement&&(s=t.getContext("2d"));return s&&(this.renderCanvas(r.game.renderer,this,0,d.TargetCamera,s),r.game.renderer.gl&&n&&(n.source[0].glTexture=r.game.renderer.canvasToTexture(s.canvas,n.source[0].glTexture,!0,0))),this}});d.TargetCamera=new n(0,0,0,0),t.exports=d},function(t,e,i){var n=i(0),s=i(13),r=i(1),o=i(271),a=i(771),h=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Origin,s.Pipeline,s.ScrollFactor,s.Texture,s.Tint,s.Transform,s.Visible,a],initialize:function(t,e,i,n,s,o){void 0===s&&(s=""),r.call(this,t,"DynamicBitmapText"),this.font=n;var a=this.scene.sys.cache.bitmapFont.get(n);this.fontData=a.data,this.text=Array.isArray(s)?s.join("\n"):s,this.fontSize=o||this.fontData.size,this.setTexture(a.texture,a.frame),this.setPosition(e,i),this.setOrigin(0,0),this.initPipeline("TextureTintPipeline"),this._bounds=this.getTextBounds(),this.scrollX=0,this.scrollY=0,this.cropWidth=0,this.cropHeight=0,this.displayCallback},setSize:function(t,e){return this.cropWidth=t,this.cropHeight=e,this},setDisplayCallback:function(t){return this.displayCallback=t,this},setFontSize:function(t){return this.fontSize=t,this},setText:function(t){return t||0===t||(t=""),Array.isArray(t)&&(t=t.join("\n")),t!==this.text&&(this.text=t.toString(),this.updateDisplayOrigin()),this},setScrollX:function(t){return this.scrollX=t,this},setScrollY:function(t){return this.scrollY=t,this},getTextBounds:function(t){return this._bounds=o(this,t),this._bounds},width:{get:function(){return this.getTextBounds(!1),this._bounds.global.width}},height:{get:function(){return this.getTextBounds(!1),this._bounds.global.height}},toJSON:function(){var t=s.ToJSON(this),e={font:this.font,text:this.text,fontSize:this.fontSize};return t.data=e,t}});t.exports=h},function(t,e,i){var n=i(775),s=i(772),r=i(0),o=i(13),a=i(141),h=i(1),u=i(97),l=new r({Extends:h,Mixins:[o.Alpha,o.BlendMode,o.Depth,o.Pipeline,o.ScaleMode,o.ScrollFactor,o.Size,o.Texture,o.Transform,o.Visible,n],initialize:function(t,e,i,n,s){h.call(this,t,"Blitter"),this.setTexture(n,s),this.setPosition(e,i),this.initPipeline("TextureTintPipeline"),this.children=new u,this.renderList=[],this.dirty=!1},create:function(t,e,i,n,r){void 0===n&&(n=!0),void 0===r&&(r=this.children.length),void 0===i?i=this.frame:i instanceof a||(i=this.texture.get(i));var o=new s(this,t,e,i,n);return this.children.addAt(o,r,!1),this.dirty=!0,o},createFromCallback:function(t,e,i,n){for(var s=this.createMultiple(e,i,n),r=0;r0},getRenderList:function(){return this.dirty&&(this.renderList=this.children.list.filter(this.childCanRender,this),this.dirty=!1),this.renderList},clear:function(){this.children.removeAll(),this.dirty=!0}});t.exports=l},function(t,e,i){var n=i(0),s=i(13),r=i(1),o=i(271),a=i(780),h=i(779),u=i(778),l=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Origin,s.Pipeline,s.ScaleMode,s.ScrollFactor,s.Texture,s.Tint,s.Transform,s.Visible,u],initialize:function(t,e,i,n,s,o){void 0===s&&(s=""),r.call(this,t,"BitmapText"),this.font=n;var a=this.scene.sys.cache.bitmapFont.get(n);this.fontData=a.data,this.text=Array.isArray(s)?s.join("\n"):s,this.fontSize=o||this.fontData.size,this.setTexture(a.texture,a.frame),this.setPosition(e,i),this.setOrigin(0,0),this.initPipeline("TextureTintPipeline"),this._bounds=this.getTextBounds()},setFontSize:function(t){return this.fontSize=t,this},setText:function(t){return t||0===t||(t=""),Array.isArray(t)&&(t=t.join("\n")),t!==this.text&&(this.text=t.toString(),this.updateDisplayOrigin()),this},getTextBounds:function(t){return this._bounds=o(this,t),this._bounds},width:{get:function(){return this.getTextBounds(!1),this._bounds.global.width}},height:{get:function(){return this.getTextBounds(!1),this._bounds.global.height}},toJSON:function(){var t=s.ToJSON(this),e={font:this.font,text:this.text,fontSize:this.fontSize};return t.data=e,t}});l.ParseRetroFont=h,l.ParseFromAtlas=a,t.exports=l},function(t,e,i){var n=i(8);t.exports=function(t,e){var i=n(e,"anims",null);if(null===i)return t;if("string"==typeof i)t.anims.play(i);else if("object"==typeof i){var s=t.anims,r=n(i,"key",void 0),o=n(i,"startFrame",void 0),a=n(i,"delay",0),h=n(i,"repeat",0),u=n(i,"repeatDelay",0),l=n(i,"yoyo",!1),c=n(i,"play",!1),d=n(i,"delayedPlay",0);s.delay(a),s.repeat(h),s.repeatDelay(u),s.yoyo(l),c?s.play(r,o):d>0?s.delayedPlay(d,r,o):s.load(r)}return t}},function(t,e,i){var n=i(0),s=i(18),r=new n({initialize:function(t,e,i,n,s,r,o){this.texture=t,this.name=e,this.source=t.source[i],this.sourceIndex=i,this.cutX=n,this.cutY=s,this.cutWidth=r,this.cutHeight=o,this.x=0,this.y=0,this.width=r,this.height=o,this.halfWidth=Math.floor(.5*r),this.halfHeight=Math.floor(.5*o),this.centerX=Math.floor(r/2),this.centerY=Math.floor(o/2),this.pivotX=0,this.pivotY=0,this.customPivot=!1,this.rotated=!1,this.autoRound=-1,this.customData={},this.data={cut:{x:n,y:s,w:r,h:o,r:n+r,b:s+o},trim:!1,sourceSize:{w:r,h:o},spriteSourceSize:{x:0,y:0,w:r,h:o},uvs:{x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},radius:.5*Math.sqrt(r*r+o*o),drawImage:{sx:n,sy:s,sWidth:r,sHeight:o,dWidth:r,dHeight:o}},this.updateUVs()},setTrim:function(t,e,i,n,s,r){var o=this.data,a=o.spriteSourceSize;return o.trim=!0,o.sourceSize.w=t,o.sourceSize.h=e,a.x=i,a.y=n,a.w=s,a.h=r,this.x=i,this.y=n,this.width=s,this.height=r,this.halfWidth=.5*s,this.halfHeight=.5*r,this.centerX=Math.floor(s/2),this.centerY=Math.floor(r/2),this.updateUVs()},updateUVs:function(){var t=this.cutX,e=this.cutY,i=this.cutWidth,n=this.cutHeight,s=this.data.drawImage;s.sWidth=i,s.sHeight=n,s.dWidth=i,s.dHeight=n;var r=this.source.width,o=this.source.height,a=this.data.uvs;return a.x0=t/r,a.y0=e/o,a.x1=t/r,a.y1=(e+n)/o,a.x2=(t+i)/r,a.y2=(e+n)/o,a.x3=(t+i)/r,a.y3=e/o,this},updateUVsInverted:function(){var t=this.source.width,e=this.source.height,i=this.data.uvs;return i.x3=(this.cutX+this.cutHeight)/t,i.y3=(this.cutY+this.cutWidth)/e,i.x2=this.cutX/t,i.y2=(this.cutY+this.cutWidth)/e,i.x1=this.cutX/t,i.y1=this.cutY/e,i.x0=(this.cutX+this.cutHeight)/t,i.y0=this.cutY/e,this},clone:function(){var t=new r(this.texture,this.name,this.sourceIndex);return t.cutX=this.cutX,t.cutY=this.cutY,t.cutWidth=this.cutWidth,t.cutHeight=this.cutHeight,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t.halfWidth=this.halfWidth,t.halfHeight=this.halfHeight,t.centerX=this.centerX,t.centerY=this.centerY,t.rotated=this.rotated,t.data=s(!0,t.data,this.data),t.updateUVs(),t},destroy:function(){this.texture=null,this.source=null},realWidth:{get:function(){return this.data.sourceSize.w}},realHeight:{get:function(){return this.data.sourceSize.h}},uvs:{get:function(){return this.data.uvs}},radius:{get:function(){return this.data.radius}},trimmed:{get:function(){return this.data.trim}},canvasData:{get:function(){return this.data.drawImage}}});t.exports=r},function(t,e,i){var n=i(0),s=i(75),r=i(797),o=i(796),a=i(303),h=i(284),u=new n({initialize:function(t,e){this.scene=t,this.game,this.config=e,this.settings=h.create(e),this.canvas,this.context,this.anims,this.cache,this.plugins,this.registry,this.sound,this.textures,this.add,this.cameras,this.displayList,this.events,this.make,this.scenePlugin,this.updateList},init:function(t){this.settings.status=s.INIT,this.game=t,this.canvas=t.canvas,this.context=t.context;var e=t.plugins;this.plugins=e,e.installGlobal(this,a.Global),e.installLocal(this,a.CoreScene),e.installLocal(this,o(this)),e.installLocal(this,r(this)),this.events.emit("boot",this),this.settings.isBooted=!0},install:function(t){Array.isArray(t)||(t=[t]),this.plugins.installLocal(this,t)},step:function(t,e){this.events.emit("preupdate",t,e),this.events.emit("update",t,e),this.scene.update.call(this.scene,t,e),this.events.emit("postupdate",t,e)},render:function(t){var e=this.displayList;e.depthSort(),this.cameras.render(t,e),this.events.emit("render",t)},queueDepthSort:function(){this.displayList.queueDepthSort()},depthSort:function(){this.displayList.depthSort()},pause:function(){return this.settings.active&&(this.settings.status=s.PAUSED,this.settings.active=!1,this.events.emit("pause",this)),this},resume:function(){return this.settings.active||(this.settings.status=s.RUNNING,this.settings.active=!0,this.events.emit("resume",this)),this},sleep:function(){return this.settings.status=s.SLEEPING,this.settings.active=!1,this.settings.visible=!1,this.events.emit("sleep",this),this},wake:function(){return this.settings.status=s.RUNNING,this.settings.active=!0,this.settings.visible=!0,this.events.emit("wake",this),this},isSleeping:function(){return this.settings.status===s.SLEEPING},isActive:function(){return this.settings.status===s.RUNNING},isVisible:function(){return this.settings.visible},setVisible:function(t){return this.settings.visible=t,this},setActive:function(t){return t?this.resume():this.pause()},start:function(t){this.settings.status=s.START,this.settings.data=t,this.settings.active=!0,this.settings.visible=!0,this.events.emit("start",this)},resize:function(t,e){this.events.emit("resize",t,e)},shutdown:function(){this.settings.status=s.SHUTDOWN,this.settings.active=!1,this.settings.visible=!1,this.events.emit("shutdown",this)},destroy:function(){this.settings.status=s.DESTROYED,this.settings.active=!1,this.settings.visible=!1,this.events.emit("destroy",this)}});t.exports=u},function(t,e){t.exports={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PRINT_SCREEN:42,INSERT:45,DELETE:46,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,SEMICOLON:186,PLUS:187,COMMA:188,MINUS:189,PERIOD:190,FORWARD_SLASH:191,BACK_SLASH:220,QUOTES:222,BACKTICK:192,OPEN_BRACKET:219,CLOSED_BRACKET:221}},function(t,e){t.exports={ARC:0,BEGIN_PATH:1,CLOSE_PATH:2,FILL_RECT:3,LINE_TO:4,MOVE_TO:5,LINE_STYLE:6,FILL_STYLE:7,FILL_PATH:8,STROKE_PATH:9,FILL_TRIANGLE:10,STROKE_TRIANGLE:11,LINE_FX_TO:12,MOVE_FX_TO:13,SAVE:14,RESTORE:15,TRANSLATE:16,SCALE:17,ROTATE:18}},function(t,e){t.exports=function(t,e){return t>0&&0==(t&t-1)&&e>0&&0==(e&e-1)}},function(t,e,i){var n=i(76),s=i(100),r=i(23),o={canvas:!1,canvasBitBltShift:null,file:!1,fileSystem:!1,getUserMedia:!0,littleEndian:!1,localStorage:!1,pointerLock:!1,support32bit:!1,vibration:!1,webGL:!1,worker:!1};t.exports=function(){o.canvas=!!window.CanvasRenderingContext2D||n.cocoonJS;try{o.localStorage=!!localStorage.getItem}catch(t){o.localStorage=!1}o.file=!!(window.File&&window.FileReader&&window.FileList&&window.Blob),o.fileSystem=!!window.requestFileSystem;var t,e,i,a=!1;return o.webGL=function(){if(window.WebGLRenderingContext)try{var t=r.createWebGL(this);n.cocoonJS&&(t.screencanvas=!1);var e=t.getContext("webgl")||t.getContext("experimental-webgl"),i=r.create2D(this),s=i.getContext("2d").createImageData(1,1);return a=s.data instanceof Uint8ClampedArray,r.remove(t),r.remove(i),!!e}catch(t){return!1}return!1}(),o.worker=!!window.Worker,o.pointerLock="pointerLockElement"in document||"mozPointerLockElement"in document||"webkitPointerLockElement"in document,navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia||navigator.oGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,o.getUserMedia=o.getUserMedia&&!!navigator.getUserMedia&&!!window.URL,s.firefox&&s.firefoxVersion<21&&(o.getUserMedia=!1),!n.iOS&&(s.ie||s.firefox||s.chrome)&&(o.canvasBitBltShift=!0),(s.safari||s.mobileSafari)&&(o.canvasBitBltShift=!1),navigator.vibrate=navigator.vibrate||navigator.webkitVibrate||navigator.mozVibrate||navigator.msVibrate,navigator.vibrate&&(o.vibration=!0),"undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint32Array&&(o.littleEndian=(t=new ArrayBuffer(4),e=new Uint8Array(t),i=new Uint32Array(t),e[0]=161,e[1]=178,e[2]=195,e[3]=212,3569595041===i[0]||2712847316!==i[0]&&null)),o.support32bit="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof Int32Array&&null!==o.littleEndian&&a,o}()},function(t,e){t.exports=function(t,e,i){var n;return void 0===i&&(i=!0),e&&("string"==typeof e?n=document.getElementById(e):"object"==typeof e&&1===e.nodeType&&(n=e)),n||(n=document.body),i&&n.style&&(n.style.overflow="hidden"),n.appendChild(t),t}},function(t,e){t.exports=function(t,e,i){return(e-t)*i+t}},function(t,e){t.exports=function(t,e,i,n,s){var r=.5*(n-e),o=.5*(s-i),a=t*t;return(2*i-2*n+r+o)*(t*a)+(-3*i+3*n-2*r-o)*a+r*t+i}},function(t,e,i){var n=i(10);t.exports=function(t,e){if(void 0===e&&(e=new n),0===t.length)return e;for(var i,s,r,o=Number.MAX_VALUE,a=Number.MAX_VALUE,h=Number.MIN_SAFE_INTEGER,u=Number.MIN_SAFE_INTEGER,l=0;l0&&(s=1/Math.sqrt(s),this.x=t*s,this.y=e*s,this.z=i*s,this.w=n*s),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z,r=this.w;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this.w=r+e*(t.w-r),this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z||1,this.w*=t.w||1,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z||1,this.w/=t.w||1,this},distance:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0,s=t.w-this.w||0;return Math.sqrt(e*e+i*i+n*n+s*s)},distanceSq:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0,s=t.w-this.w||0;return e*e+i*i+n*n+s*s},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},transformMat4:function(t){var e=this.x,i=this.y,n=this.z,s=this.w,r=t.val;return this.x=r[0]*e+r[4]*i+r[8]*n+r[12]*s,this.y=r[1]*e+r[5]*i+r[9]*n+r[13]*s,this.z=r[2]*e+r[6]*i+r[10]*n+r[14]*s,this.w=r[3]*e+r[7]*i+r[11]*n+r[15]*s,this},transformQuat:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z,a=t.w,h=a*e+r*n-o*i,u=a*i+o*e-s*n,l=a*n+s*i-r*e,c=-s*e-r*i-o*n;return this.x=h*a+c*-s+u*-o-l*-r,this.y=u*a+c*-r+l*-s-h*-o,this.z=l*a+c*-o+h*-r-u*-s,this},reset:function(){return this.x=0,this.y=0,this.z=0,this.w=0,this}});n.prototype.sub=n.prototype.subtract,n.prototype.mul=n.prototype.multiply,n.prototype.div=n.prototype.divide,n.prototype.dist=n.prototype.distance,n.prototype.distSq=n.prototype.distanceSq,n.prototype.len=n.prototype.length,n.prototype.lenSq=n.prototype.lengthSq,t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t){this.val=new Float32Array(16),t?this.copy(t):this.identity()},clone:function(){return new n(this)},set:function(t){return this.copy(t)},copy:function(t){var e=this.val,i=t.val;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this},fromArray:function(t){var e=this.val;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],this},zero:function(){var t=this.val;return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=0,this},xyz:function(t,e,i){this.identity();var n=this.val;return n[12]=t,n[13]=e,n[14]=i,this},scaling:function(t,e,i){this.zero();var n=this.val;return n[0]=t,n[5]=e,n[10]=i,n[15]=1,this},identity:function(){var t=this.val;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},transpose:function(){var t=this.val,e=t[1],i=t[2],n=t[3],s=t[6],r=t[7],o=t[11];return t[1]=t[4],t[2]=t[8],t[3]=t[12],t[4]=e,t[6]=t[9],t[7]=t[13],t[8]=i,t[9]=s,t[11]=t[14],t[12]=n,t[13]=r,t[14]=o,this},invert:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],u=t[8],l=t[9],c=t[10],d=t[11],f=t[12],p=t[13],g=t[14],v=t[15],y=e*o-i*r,m=e*a-n*r,x=e*h-s*r,w=i*a-n*o,b=i*h-s*o,T=n*h-s*a,A=u*p-l*f,S=u*g-c*f,C=u*v-d*f,M=l*g-c*p,E=l*v-d*p,_=c*v-d*g,L=y*_-m*E+x*M+w*C-b*S+T*A;return L?(L=1/L,t[0]=(o*_-a*E+h*M)*L,t[1]=(n*E-i*_-s*M)*L,t[2]=(p*T-g*b+v*w)*L,t[3]=(c*b-l*T-d*w)*L,t[4]=(a*C-r*_-h*S)*L,t[5]=(e*_-n*C+s*S)*L,t[6]=(g*x-f*T-v*m)*L,t[7]=(u*T-c*x+d*m)*L,t[8]=(r*E-o*C+h*A)*L,t[9]=(i*C-e*E-s*A)*L,t[10]=(f*b-p*x+v*y)*L,t[11]=(l*x-u*b-d*y)*L,t[12]=(o*S-r*M-a*A)*L,t[13]=(e*M-i*S+n*A)*L,t[14]=(p*m-f*w-g*y)*L,t[15]=(u*w-l*m+c*y)*L,this):null},adjoint:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],u=t[8],l=t[9],c=t[10],d=t[11],f=t[12],p=t[13],g=t[14],v=t[15];return t[0]=o*(c*v-d*g)-l*(a*v-h*g)+p*(a*d-h*c),t[1]=-(i*(c*v-d*g)-l*(n*v-s*g)+p*(n*d-s*c)),t[2]=i*(a*v-h*g)-o*(n*v-s*g)+p*(n*h-s*a),t[3]=-(i*(a*d-h*c)-o*(n*d-s*c)+l*(n*h-s*a)),t[4]=-(r*(c*v-d*g)-u*(a*v-h*g)+f*(a*d-h*c)),t[5]=e*(c*v-d*g)-u*(n*v-s*g)+f*(n*d-s*c),t[6]=-(e*(a*v-h*g)-r*(n*v-s*g)+f*(n*h-s*a)),t[7]=e*(a*d-h*c)-r*(n*d-s*c)+u*(n*h-s*a),t[8]=r*(l*v-d*p)-u*(o*v-h*p)+f*(o*d-h*l),t[9]=-(e*(l*v-d*p)-u*(i*v-s*p)+f*(i*d-s*l)),t[10]=e*(o*v-h*p)-r*(i*v-s*p)+f*(i*h-s*o),t[11]=-(e*(o*d-h*l)-r*(i*d-s*l)+u*(i*h-s*o)),t[12]=-(r*(l*g-c*p)-u*(o*g-a*p)+f*(o*c-a*l)),t[13]=e*(l*g-c*p)-u*(i*g-n*p)+f*(i*c-n*l),t[14]=-(e*(o*g-a*p)-r*(i*g-n*p)+f*(i*a-n*o)),t[15]=e*(o*c-a*l)-r*(i*c-n*l)+u*(i*a-n*o),this},determinant:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],u=t[8],l=t[9],c=t[10],d=t[11],f=t[12],p=t[13],g=t[14],v=t[15];return(e*o-i*r)*(c*v-d*g)-(e*a-n*r)*(l*v-d*p)+(e*h-s*r)*(l*g-c*p)+(i*a-n*o)*(u*v-d*f)-(i*h-s*o)*(u*g-c*f)+(n*h-s*a)*(u*p-l*f)},multiply:function(t){var e=this.val,i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],h=e[6],u=e[7],l=e[8],c=e[9],d=e[10],f=e[11],p=e[12],g=e[13],v=e[14],y=e[15],m=t.val,x=m[0],w=m[1],b=m[2],T=m[3];return e[0]=x*i+w*o+b*l+T*p,e[1]=x*n+w*a+b*c+T*g,e[2]=x*s+w*h+b*d+T*v,e[3]=x*r+w*u+b*f+T*y,x=m[4],w=m[5],b=m[6],T=m[7],e[4]=x*i+w*o+b*l+T*p,e[5]=x*n+w*a+b*c+T*g,e[6]=x*s+w*h+b*d+T*v,e[7]=x*r+w*u+b*f+T*y,x=m[8],w=m[9],b=m[10],T=m[11],e[8]=x*i+w*o+b*l+T*p,e[9]=x*n+w*a+b*c+T*g,e[10]=x*s+w*h+b*d+T*v,e[11]=x*r+w*u+b*f+T*y,x=m[12],w=m[13],b=m[14],T=m[15],e[12]=x*i+w*o+b*l+T*p,e[13]=x*n+w*a+b*c+T*g,e[14]=x*s+w*h+b*d+T*v,e[15]=x*r+w*u+b*f+T*y,this},multiplyLocal:function(t){var e=[],i=this.val,n=t.val;return e[0]=i[0]*n[0]+i[1]*n[4]+i[2]*n[8]+i[3]*n[12],e[1]=i[0]*n[1]+i[1]*n[5]+i[2]*n[9]+i[3]*n[13],e[2]=i[0]*n[2]+i[1]*n[6]+i[2]*n[10]+i[3]*n[14],e[3]=i[0]*n[3]+i[1]*n[7]+i[2]*n[11]+i[3]*n[15],e[4]=i[4]*n[0]+i[5]*n[4]+i[6]*n[8]+i[7]*n[12],e[5]=i[4]*n[1]+i[5]*n[5]+i[6]*n[9]+i[7]*n[13],e[6]=i[4]*n[2]+i[5]*n[6]+i[6]*n[10]+i[7]*n[14],e[7]=i[4]*n[3]+i[5]*n[7]+i[6]*n[11]+i[7]*n[15],e[8]=i[8]*n[0]+i[9]*n[4]+i[10]*n[8]+i[11]*n[12],e[9]=i[8]*n[1]+i[9]*n[5]+i[10]*n[9]+i[11]*n[13],e[10]=i[8]*n[2]+i[9]*n[6]+i[10]*n[10]+i[11]*n[14],e[11]=i[8]*n[3]+i[9]*n[7]+i[10]*n[11]+i[11]*n[15],e[12]=i[12]*n[0]+i[13]*n[4]+i[14]*n[8]+i[15]*n[12],e[13]=i[12]*n[1]+i[13]*n[5]+i[14]*n[9]+i[15]*n[13],e[14]=i[12]*n[2]+i[13]*n[6]+i[14]*n[10]+i[15]*n[14],e[15]=i[12]*n[3]+i[13]*n[7]+i[14]*n[11]+i[15]*n[15],this.fromArray(e)},translate:function(t){var e=t.x,i=t.y,n=t.z,s=this.val;return s[12]=s[0]*e+s[4]*i+s[8]*n+s[12],s[13]=s[1]*e+s[5]*i+s[9]*n+s[13],s[14]=s[2]*e+s[6]*i+s[10]*n+s[14],s[15]=s[3]*e+s[7]*i+s[11]*n+s[15],this},scale:function(t){var e=t.x,i=t.y,n=t.z,s=this.val;return s[0]=s[0]*e,s[1]=s[1]*e,s[2]=s[2]*e,s[3]=s[3]*e,s[4]=s[4]*i,s[5]=s[5]*i,s[6]=s[6]*i,s[7]=s[7]*i,s[8]=s[8]*n,s[9]=s[9]*n,s[10]=s[10]*n,s[11]=s[11]*n,this},makeRotationAxis:function(t,e){var i=Math.cos(e),n=Math.sin(e),s=1-i,r=t.x,o=t.y,a=t.z,h=s*r,u=s*o;return this.set(h*r+i,h*o-n*a,h*a+n*o,0,h*o+n*a,u*o+i,u*a-n*r,0,h*a-n*o,u*a+n*r,s*a*a+i,0,0,0,0,1),this},rotate:function(t,e){var i=this.val,n=e.x,s=e.y,r=e.z,o=Math.sqrt(n*n+s*s+r*r);if(Math.abs(o)<1e-6)return null;n*=o=1/o,s*=o,r*=o;var a=Math.sin(t),h=Math.cos(t),u=1-h,l=i[0],c=i[1],d=i[2],f=i[3],p=i[4],g=i[5],v=i[6],y=i[7],m=i[8],x=i[9],w=i[10],b=i[11],T=n*n*u+h,A=s*n*u+r*a,S=r*n*u-s*a,C=n*s*u-r*a,M=s*s*u+h,E=r*s*u+n*a,_=n*r*u+s*a,L=s*r*u-n*a,P=r*r*u+h;return i[0]=l*T+p*A+m*S,i[1]=c*T+g*A+x*S,i[2]=d*T+v*A+w*S,i[3]=f*T+y*A+b*S,i[4]=l*C+p*M+m*E,i[5]=c*C+g*M+x*E,i[6]=d*C+v*M+w*E,i[7]=f*C+y*M+b*E,i[8]=l*_+p*L+m*P,i[9]=c*_+g*L+x*P,i[10]=d*_+v*L+w*P,i[11]=f*_+y*L+b*P,this},rotateX:function(t){var e=this.val,i=Math.sin(t),n=Math.cos(t),s=e[4],r=e[5],o=e[6],a=e[7],h=e[8],u=e[9],l=e[10],c=e[11];return e[4]=s*n+h*i,e[5]=r*n+u*i,e[6]=o*n+l*i,e[7]=a*n+c*i,e[8]=h*n-s*i,e[9]=u*n-r*i,e[10]=l*n-o*i,e[11]=c*n-a*i,this},rotateY:function(t){var e=this.val,i=Math.sin(t),n=Math.cos(t),s=e[0],r=e[1],o=e[2],a=e[3],h=e[8],u=e[9],l=e[10],c=e[11];return e[0]=s*n-h*i,e[1]=r*n-u*i,e[2]=o*n-l*i,e[3]=a*n-c*i,e[8]=s*i+h*n,e[9]=r*i+u*n,e[10]=o*i+l*n,e[11]=a*i+c*n,this},rotateZ:function(t){var e=this.val,i=Math.sin(t),n=Math.cos(t),s=e[0],r=e[1],o=e[2],a=e[3],h=e[4],u=e[5],l=e[6],c=e[7];return e[0]=s*n+h*i,e[1]=r*n+u*i,e[2]=o*n+l*i,e[3]=a*n+c*i,e[4]=h*n-s*i,e[5]=u*n-r*i,e[6]=l*n-o*i,e[7]=c*n-a*i,this},fromRotationTranslation:function(t,e){var i=this.val,n=t.x,s=t.y,r=t.z,o=t.w,a=n+n,h=s+s,u=r+r,l=n*a,c=n*h,d=n*u,f=s*h,p=s*u,g=r*u,v=o*a,y=o*h,m=o*u;return i[0]=1-(f+g),i[1]=c+m,i[2]=d-y,i[3]=0,i[4]=c-m,i[5]=1-(l+g),i[6]=p+v,i[7]=0,i[8]=d+y,i[9]=p-v,i[10]=1-(l+f),i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this},fromQuat:function(t){var e=this.val,i=t.x,n=t.y,s=t.z,r=t.w,o=i+i,a=n+n,h=s+s,u=i*o,l=i*a,c=i*h,d=n*a,f=n*h,p=s*h,g=r*o,v=r*a,y=r*h;return e[0]=1-(d+p),e[1]=l+y,e[2]=c-v,e[3]=0,e[4]=l-y,e[5]=1-(u+p),e[6]=f+g,e[7]=0,e[8]=c+v,e[9]=f-g,e[10]=1-(u+d),e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},frustum:function(t,e,i,n,s,r){var o=this.val,a=1/(e-t),h=1/(n-i),u=1/(s-r);return o[0]=2*s*a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=2*s*h,o[6]=0,o[7]=0,o[8]=(e+t)*a,o[9]=(n+i)*h,o[10]=(r+s)*u,o[11]=-1,o[12]=0,o[13]=0,o[14]=r*s*2*u,o[15]=0,this},perspective:function(t,e,i,n){var s=this.val,r=1/Math.tan(t/2),o=1/(i-n);return s[0]=r/e,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=r,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=(n+i)*o,s[11]=-1,s[12]=0,s[13]=0,s[14]=2*n*i*o,s[15]=0,this},perspectiveLH:function(t,e,i,n){var s=this.val;return s[0]=2*i/t,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=2*i/e,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=-n/(i-n),s[11]=1,s[12]=0,s[13]=0,s[14]=i*n/(i-n),s[15]=0,this},ortho:function(t,e,i,n,s,r){var o=this.val,a=t-e,h=i-n,u=s-r;return a=0===a?a:1/a,h=0===h?h:1/h,u=0===u?u:1/u,o[0]=-2*a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=-2*h,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=2*u,o[11]=0,o[12]=(t+e)*a,o[13]=(n+i)*h,o[14]=(r+s)*u,o[15]=1,this},lookAt:function(t,e,i){var n=this.val,s=t.x,r=t.y,o=t.z,a=i.x,h=i.y,u=i.z,l=e.x,c=e.y,d=e.z;if(Math.abs(s-l)<1e-6&&Math.abs(r-c)<1e-6&&Math.abs(o-d)<1e-6)return this.identity();var f=s-l,p=r-c,g=o-d,v=1/Math.sqrt(f*f+p*p+g*g),y=h*(g*=v)-u*(p*=v),m=u*(f*=v)-a*g,x=a*p-h*f;(v=Math.sqrt(y*y+m*m+x*x))?(y*=v=1/v,m*=v,x*=v):(y=0,m=0,x=0);var w=p*x-g*m,b=g*y-f*x,T=f*m-p*y;return(v=Math.sqrt(w*w+b*b+T*T))?(w*=v=1/v,b*=v,T*=v):(w=0,b=0,T=0),n[0]=y,n[1]=w,n[2]=f,n[3]=0,n[4]=m,n[5]=b,n[6]=p,n[7]=0,n[8]=x,n[9]=T,n[10]=g,n[11]=0,n[12]=-(y*s+m*r+x*o),n[13]=-(w*s+b*r+T*o),n[14]=-(f*s+p*r+g*o),n[15]=1,this},yawPitchRoll:function(t,e,i){this.zero(),s.zero(),r.zero();var n=this.val,o=s.val,a=r.val,h=Math.sin(i),u=Math.cos(i);return n[10]=1,n[15]=1,n[0]=u,n[1]=h,n[4]=-h,n[5]=u,h=Math.sin(e),u=Math.cos(e),o[0]=1,o[15]=1,o[5]=u,o[10]=u,o[9]=-h,o[6]=h,h=Math.sin(t),u=Math.cos(t),a[5]=1,a[15]=1,a[0]=u,a[2]=-h,a[8]=h,a[10]=u,this.multiplyLocal(s),this.multiplyLocal(r),this},setWorldMatrix:function(t,e,i,n,o){return this.yawPitchRoll(t.y,t.x,t.z),s.scaling(i.x,i.y,i.z),r.xyz(e.x,e.y,e.z),this.multiplyLocal(s),this.multiplyLocal(r),void 0!==n&&this.multiplyLocal(n),void 0!==o&&this.multiplyLocal(o),this}}),s=new n,r=new n;t.exports=n},function(t,e,i){var n=i(0),s=i(153),r=i(330),o=i(329),a=i(328),h=i(63),u=i(101),l=i(6),c=i(57),d=i(152),f=new c,p=new d,g=new c,v=new c,y=new s,m=new n({initialize:function(t){this.scene=t,this.displayList=t.sys.displayList,this.updateList=t.sys.updateList,this.name="",this.direction=new c(0,0,-1),this.up=new c(0,1,0),this.position=new c,this.pixelScale=128,this.projection=new s,this.view=new s,this.combined=new s,this.invProjectionView=new s,this.near=1,this.far=100,this.ray={origin:new c,direction:new c},this.viewportWidth=0,this.viewportHeight=0,this.billboardMatrixDirty=!0,this.children=new h},setPosition:function(t,e,i){return this.position.set(t,e,i),this.update()},setScene:function(t){return this.scene=t,this},setPixelScale:function(t){return this.pixelScale=t,this.update()},add:function(t){return this.children.set(t),this.updateChildren(),t},remove:function(t){return this.displayList.remove(t.gameObject),this.updateList.remove(t.gameObject),this.children.delete(t),this},clear:function(){for(var t=this.getChildren(),e=0;e-y||T>-m||b-y||S>-m||A-y||T>-m||b-y||S>-m||A-v&&S*n+C*r+h>-y&&(S+v)*i+(C+y)*s+a0?this:(this._fadeRed=e,this._fadeGreen=i,this._fadeBlue=n,this._fadeCallback=r,this._fadeDuration=t,this._fadeAlpha=Number.MIN_VALUE,this)},flash:function(t,e,i,n,s,r){return t||(t=Number.MIN_VALUE),void 0===e&&(e=1),void 0===i&&(i=1),void 0===n&&(n=1),void 0===s&&(s=!1),void 0===r&&(r=null),!s&&this._flashAlpha>0?this:(this._flashRed=e,this._flashGreen=i,this._flashBlue=n,this._flashCallback=r,this._flashDuration=t,this._flashAlpha=1,this)},shake:function(t,e,i,n){return t||(t=Number.MIN_VALUE),void 0===e&&(e=.05),void 0===i&&(i=!1),void 0===n&&(n=null),i||0===this._shakeOffsetX&&0===this._shakeOffsetY?(this._shakeDuration=t,this._shakeIntensity=e,this._shakeOffsetX=0,this._shakeOffsetY=0,this._shakeCallback=n,this):this},getWorldPoint:function(t,e,i){void 0===i&&(i=new h);var n=this.matrix.matrix,s=n[0],r=n[1],o=n[2],a=n[3],u=n[4],l=n[5],c=s*a-r*o;if(!c)return i.x=t,i.y=e,i;var d=a*(c=1/c),f=-r*c,p=-o*c,g=s*c,v=(o*l-a*u)*c,y=(r*u-s*l)*c,m=Math.cos(this.rotation),x=Math.sin(this.rotation),w=this.zoom,b=this.scrollX,T=this.scrollY,A=t+(b*m-T*x)*w,S=e+(b*x+T*m)*w;return i.x=A*d+S*p+v,i.y=A*f+S*g+y,i},ignore:function(t){if(t instanceof Array)for(var e=0;el&&(this.scrollX=l),this.scrollYc&&(this.scrollY=c)}this.roundPixels&&(this.scrollX=Math.round(this.scrollX),this.scrollY=Math.round(this.scrollY)),r.loadIdentity(),r.scale(e,e),r.translate(this.x+o,this.y+a),r.rotate(this.rotation),r.scale(s,s),r.translate(-o,-a),r.translate(this._shakeOffsetX,this._shakeOffsetY)},removeBounds:function(){return this.useBounds=!1,this._bounds.setEmpty(),this},setAngle:function(t){return void 0===t&&(t=0),this.rotation=s(t),this},setBackgroundColor:function(t){return void 0===t&&(t="rgba(0,0,0,0)"),this.backgroundColor=a(t),this.transparent=0===this.backgroundColor.alpha,this},setBounds:function(t,e,i,n){return this._bounds.setTo(t,e,i,n),this.useBounds=!0,this},setName:function(t){return void 0===t&&(t=""),this.name=t,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setRotation:function(t){return void 0===t&&(t=0),this.rotation=t,this},setRoundPixels:function(t){return this.roundPixels=t,this},setScene:function(t){return this.scene=t,this},setScroll:function(t,e){return void 0===e&&(e=t),this.scrollX=t,this.scrollY=e,this},setSize:function(t,e){return void 0===e&&(e=t),this.width=t,this.height=e,this},setViewport:function(t,e,i,n){return this.x=t,this.y=e,this.width=i,this.height=n,this},setZoom:function(t){return void 0===t&&(t=1),this.zoom=t,this},startFollow:function(t,e){return void 0===e&&(e=!1),this._follow=t,this.roundPixels=e,this},stopFollow:function(){return this._follow=null,this},toJSON:function(){var t={name:this.name,x:this.x,y:this.y,width:this.width,height:this.height,zoom:this.zoom,rotation:this.rotation,roundPixels:this.roundPixels,scrollX:this.scrollX,scrollY:this.scrollY,backgroundColor:this.backgroundColor.rgba};return this.useBounds&&(t.bounds={x:this._bounds.x,y:this._bounds.y,width:this._bounds.width,height:this._bounds.height}),t},resetFX:function(){return this._flashAlpha=0,this._fadeAlpha=0,this._shakeOffsetX=0,this._shakeOffsetY=0,this._shakeDuration=0,this},update:function(t,e){if(this._flashAlpha>0&&(this._flashAlpha-=e/this._flashDuration,this._flashAlpha<=0&&(this._flashAlpha=0,this._flashCallback))){var i=this._flashCallback;this._flashCallback=null,i(this)}if(this._fadeAlpha>0&&this._fadeAlpha<1&&(this._fadeAlpha+=e/this._fadeDuration,this._fadeAlpha>=1&&(this._fadeAlpha=1,this._fadeCallback))){var n=this._fadeCallback;this._fadeCallback=null,n(this)}if(this._shakeDuration>0){var s=this._shakeIntensity;if(this._shakeDuration-=e,this._shakeDuration<=0){if(this._shakeOffsetX=0,this._shakeOffsetY=0,this._shakeCallback){var r=this._shakeCallback;this._shakeCallback=null,r(this)}}else this._shakeOffsetX=(Math.random()*s*this.width*2-s*this.width)*this.zoom,this._shakeOffsetY=(Math.random()*s*this.height*2-s*this.height)*this.zoom,this.roundPixels&&(this._shakeOffsetX|=0,this._shakeOffsetY|=0)}},destroy:function(){this._bounds=void 0,this.matrix=void 0,this.culledObjects=[],this.scene=void 0}});t.exports=u},function(t,e){t.exports=function(t,e,i,n){void 0===e&&(e=0),void 0===i&&(i=" "),void 0===n&&(n=3);var s=0;if(e+1>=(t=t.toString()).length)switch(n){case 1:t=new Array(e+1-t.length).join(i)+t;break;case 3:var r=Math.ceil((s=e-t.length)/2);t=new Array(s-r+1).join(i)+t+new Array(r+1).join(i);break;default:t+=new Array(e+1-t.length).join(i)}return t}},function(t,e,i){var n=new(i(0))({initialize:function(t){if(this.entries={},this.size=0,Array.isArray(t))for(var e=0;e=1&&(a=1-a,h=1-h),e.x=t.x1+(i*a+r*h),e.y=t.y1+(s*a+o*h),e}},function(t,e,i){var n=i(4);t.exports=function(t,e){void 0===e&&(e=new n);var i=Math.random()*Math.PI*2,s=Math.sqrt(Math.random());return e.x=t.x+s*Math.cos(i)*t.width/2,e.y=t.y+s*Math.sin(i)*t.height/2,e}},function(t,e,i){var n=i(4);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.x+Math.random()*t.width,e.y=t.y+Math.random()*t.height,e}},function(t,e,i){var n=i(4);t.exports=function(t,e){void 0===e&&(e=new n);var i=Math.random();return e.x=t.x1+i*(t.x2-t.x1),e.y=t.y1+i*(t.y2-t.y1),e}},function(t,e,i){var n=i(77),s=i(4);t.exports=function(t,e,i,r){void 0===r&&(r=[]),e||(e=n(t)/i);for(var o=t.x1,a=t.y1,h=t.x2,u=t.y2,l=0;l=1)return i.x=t.x,i.y=t.y,i;var r=n(t)*e;return e>.5?(r-=t.width+t.height)<=t.width?(i.x=t.right-r,i.y=t.bottom):(i.x=t.x,i.y=t.bottom-(r-t.width)):r<=t.width?(i.x=t.x+r,i.y=t.y):(i.x=t.right,i.y=t.y+(r-t.width)),i}},function(t,e,i){var n=i(4);t.exports=function(t,e){void 0===e&&(e=new n);var i=2*Math.PI*Math.random(),s=Math.random()+Math.random(),r=s>1?2-s:s,o=r*Math.cos(i),a=r*Math.sin(i);return e.x=t.x+o*t.radius,e.y=t.y+a*t.radius,e}},function(t,e,i){var n=i(4);t.exports=function(t,e,i){return void 0===i&&(i=new n),i.x=t.x+t.radius*Math.cos(e),i.y=t.y+t.radius*Math.sin(e),i}},function(t,e){t.exports={TOP_LEFT:0,TOP_CENTER:1,TOP_RIGHT:2,LEFT_TOP:3,LEFT_CENTER:4,LEFT_BOTTOM:5,CENTER:6,RIGHT_TOP:7,RIGHT_CENTER:8,RIGHT_BOTTOM:9,BOTTOM_LEFT:10,BOTTOM_CENTER:11,BOTTOM_RIGHT:12}},,,function(t,e,i){var n=i(0),s=i(300),r=i(811),o=i(810),a=i(44),h=i(108),u=new n({Extends:h,Mixins:[s],initialize:function(t){h.call(this,{game:t.game,renderer:t.renderer,gl:t.renderer.gl,topology:t.topology?t.topology:t.renderer.gl.TRIANGLES,vertShader:t.vertShader?t.vertShader:o,fragShader:t.fragShader?t.fragShader:r,vertexCapacity:t.vertexCapacity?t.vertexCapacity:12e3,vertexSize:t.vertexSize?t.vertexSize:2*Float32Array.BYTES_PER_ELEMENT+2*Float32Array.BYTES_PER_ELEMENT+4*Uint8Array.BYTES_PER_ELEMENT,attributes:[{name:"inPosition",size:2,type:t.renderer.gl.FLOAT,normalized:!1,offset:0},{name:"inTexCoord",size:2,type:t.renderer.gl.FLOAT,normalized:!1,offset:2*Float32Array.BYTES_PER_ELEMENT},{name:"inTint",size:4,type:t.renderer.gl.UNSIGNED_BYTE,normalized:!0,offset:4*Float32Array.BYTES_PER_ELEMENT}]}),this.vertexViewF32=new Float32Array(this.vertexData),this.vertexViewU32=new Uint32Array(this.vertexData),this.maxQuads=2e3,this.batches=[],this.mvpInit()},setTexture2D:function(t,e){if(!t)return this;var i=this.batches;0===i.length&&this.pushBatch();var n=i[i.length-1];return e>0?(n.textures[e-1]&&n.textures[e-1]!==t&&this.pushBatch(),i[i.length-1].textures[e-1]=t):(null!==n.texture&&n.texture!==t&&this.pushBatch(),i[i.length-1].texture=t),this},pushBatch:function(){var t={first:this.vertexCount,texture:null,textures:[]};this.batches.push(t)},flush:function(){if(this.flushLocked)return this;this.flushLocked=!0;var t,e,i,n=this.gl,s=this.renderer,r=this.vertexCount,o=this.topology,a=this.vertexSize,h=this.batches,u=0,l=null;if(0===h.length||0===r)return this.flushLocked=!1,this;n.bufferSubData(n.ARRAY_BUFFER,0,this.bytes.subarray(0,r*a));for(var c=0;c0){for(e=0;e0){for(e=0;e0&&(s.setTexture2D(l.texture,0),n.drawArrays(o,l.first,u)),this.vertexCount=0,h.length=0,this.pushBatch(),this.flushLocked=!1,this},onBind:function(){return h.prototype.onBind.call(this),this.mvpUpdate(),0===this.batches.length&&this.pushBatch(),this},resize:function(t,e,i){return h.prototype.resize.call(this,t,e,i),this.projOrtho(0,this.width,this.height,0,-1e3,1e3),this},drawStaticTilemapLayer:function(t){if(t.vertexCount>0){var e=this.vertexBuffer,i=this.gl,n=this.renderer,s=t.tileset.image.get();n.currentPipeline&&n.currentPipeline.vertexCount>0&&n.flush(),this.vertexBuffer=t.vertexBuffer,n.setPipeline(this),n.setTexture2D(s.source.glTexture,0),i.drawArrays(this.topology,0,t.vertexCount),this.vertexBuffer=e}this.viewIdentity(),this.modelIdentity()},drawEmitterManager:function(t,e){this.renderer.setPipeline(this);var i=this.renderer.config.roundPixels,n=t.emitters.list,s=n.length,r=this.vertexViewF32,o=this.vertexViewU32,a=this.renderer,h=this.maxQuads,u=e.scrollX,l=e.scrollY,c=e.matrix.matrix,d=c[0],f=c[1],p=c[2],g=c[3],v=c[4],y=c[5],m=Math.sin,x=Math.cos,w=this.vertexComponentCount,b=this.vertexCapacity,T=t.defaultFrame.source.glTexture;this.setTexture2D(T,0);for(var A=0;A=b&&(this.flush(),this.setTexture2D(T,0));for(var F=0;F=b&&(this.flush(),this.setTexture2D(T,0))}}}this.setTexture2D(T,0)},drawBlitter:function(t,e){this.renderer.setPipeline(this);for(var i=this.renderer.config.roundPixels,n=a.getTintAppendFloatAlpha,s=this.vertexViewF32,r=this.vertexViewU32,o=t.getRenderList(),h=o.length,u=e.matrix.matrix,l=u[0],c=u[1],d=u[2],f=u[3],p=u[4],g=u[5],v=e.scrollX*t.scrollFactorX,y=e.scrollY*t.scrollFactorY,m=Math.ceil(h/this.maxQuads),x=0,w=t.x-v,b=t.y-y,T=0;T=this.vertexCapacity&&this.flush()}x+=A,h-=A,this.vertexCount>=this.vertexCapacity&&this.flush()}},batchSprite:function(t,e){this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var i,n=this.renderer.config.roundPixels,s=a.getTintAppendFloatAlpha,r=this.vertexViewF32,o=this.vertexViewU32,h=e.matrix.matrix,u=t.frame,l=u.texture.source[u.sourceIndex].glTexture,c=!!l.isRenderTexture,d=t.flipX,f=t.flipY^c,p=u.uvs,g=u.width*(d?-1:1),v=u.height*(f?-1:1),y=-t.displayOriginX+u.x+u.width*(d?1:0),m=-t.displayOriginY+u.y+u.height*(f?1:0),x=(n?0|y:y)+g,w=(n?0|m:m)+v,b=t.x-e.scrollX*t.scrollFactorX,T=t.y-e.scrollY*t.scrollFactorY,A=t.scaleX,S=t.scaleY,C=-t.rotation,M=t._alphaTL,E=t._alphaTR,_=t._alphaBL,L=t._alphaBR,P=t._tintTL,F=t._tintTR,k=t._tintBL,R=t._tintBR,O=Math.sin(C),D=Math.cos(C),I=D*A,B=-O*A,Y=O*S,X=D*S,z=b,N=T,G=h[0],W=h[1],U=h[2],V=h[3],H=I*G+B*U,j=I*W+B*V,q=Y*G+X*U,K=Y*W+X*V,J=z*G+N*U+h[4],Z=z*W+N*V+h[5],Q=y*H+m*q+J,$=y*j+m*K+Z,tt=y*H+w*q+J,et=y*j+w*K+Z,it=x*H+w*q+J,nt=x*j+w*K+Z,st=x*H+m*q+J,rt=x*j+m*K+Z,ot=s(P,M),at=s(F,E),ht=s(k,_),ut=s(R,L);n&&(Q|=0,$|=0,tt|=0,et|=0,it|=0,nt|=0,st|=0,rt|=0),this.setTexture2D(l,0),r[(i=this.vertexCount*this.vertexComponentCount)+0]=Q,r[i+1]=$,r[i+2]=p.x0,r[i+3]=p.y0,o[i+4]=ot,r[i+5]=tt,r[i+6]=et,r[i+7]=p.x1,r[i+8]=p.y1,o[i+9]=ht,r[i+10]=it,r[i+11]=nt,r[i+12]=p.x2,r[i+13]=p.y2,o[i+14]=ut,r[i+15]=Q,r[i+16]=$,r[i+17]=p.x0,r[i+18]=p.y0,o[i+19]=ot,r[i+20]=it,r[i+21]=nt,r[i+22]=p.x2,r[i+23]=p.y2,o[i+24]=ut,r[i+25]=st,r[i+26]=rt,r[i+27]=p.x3,r[i+28]=p.y3,o[i+29]=at,this.vertexCount+=6},batchMesh:function(t,e){var i=t.vertices,n=i.length,s=n/2|0;this.renderer.setPipeline(this),this.vertexCount+s>this.vertexCapacity&&this.flush();var r=this.renderer.config.roundPixels,o=a.getTintAppendFloatAlpha,h=t.uv,u=t.colors,l=t.alphas,c=this.vertexViewF32,d=this.vertexViewU32,f=e.matrix.matrix,p=t.frame,g=t.texture.source[p.sourceIndex].glTexture,v=t.x-e.scrollX*t.scrollFactorX,y=t.y-e.scrollY*t.scrollFactorY,m=t.scaleX,x=t.scaleY,w=-t.rotation,b=Math.sin(w),T=Math.cos(w),A=T*m,S=-b*m,C=b*x,M=T*x,E=v,_=y,L=f[0],P=f[1],F=f[2],k=f[3],R=A*L+S*F,O=A*P+S*k,D=C*L+M*F,I=C*P+M*k,B=E*L+_*F+f[4],Y=E*P+_*k+f[5],X=0;this.setTexture2D(g,0),X=this.vertexCount*this.vertexComponentCount;for(var z=0,N=0;zthis.vertexCapacity&&this.flush();var i,n,s,r,o,h,u,l,c=this.renderer.config.roundPixels,d=t.text,f=d.length,p=a.getTintAppendFloatAlpha,g=this.vertexViewF32,v=this.vertexViewU32,y=e.matrix.matrix,m=e.width+50,x=e.height+50,w=t.frame,b=t.texture.source[w.sourceIndex],T=e.scrollX*t.scrollFactorX,A=e.scrollY*t.scrollFactorY,S=t.fontData,C=S.lineHeight,M=t.fontSize/S.size,E=S.chars,_=t.alpha,L=p(t._tintTL,_),P=p(t._tintTR,_),F=p(t._tintBL,_),k=p(t._tintBR,_),R=t.x,O=t.y,D=w.cutX,I=w.cutY,B=b.width,Y=b.height,X=b.glTexture,z=0,N=0,G=0,W=0,U=null,V=0,H=0,j=0,q=0,K=0,J=0,Z=0,Q=0,$=0,tt=0,et=0,it=0,nt=null,st=0,rt=R-T+w.x,ot=O-A+w.y,at=-t.rotation,ht=t.scaleX,ut=t.scaleY,lt=Math.sin(at),ct=Math.cos(at),dt=ct*ht,ft=-lt*ht,pt=lt*ut,gt=ct*ut,vt=rt,yt=ot,mt=y[0],xt=y[1],wt=y[2],bt=y[3],Tt=dt*mt+ft*wt,At=dt*xt+ft*bt,St=pt*mt+gt*wt,Ct=pt*xt+gt*bt,Mt=vt*mt+yt*wt+y[4],Et=vt*xt+yt*bt+y[5],_t=0;this.setTexture2D(X,0);for(var Lt=0;Ltm||n<-50||n>x)&&(s<-50||s>m||r<-50||r>x)&&(o<-50||o>m||h<-50||h>x)&&(u<-50||u>m||l<-50||l>x)||(this.vertexCount+6>this.vertexCapacity&&this.flush(),_t=this.vertexCount*this.vertexComponentCount,c&&(i|=0,n|=0,s|=0,r|=0,o|=0,h|=0,u|=0,l|=0),g[_t+0]=i,g[_t+1]=n,g[_t+2]=$,g[_t+3]=et,v[_t+4]=L,g[_t+5]=s,g[_t+6]=r,g[_t+7]=$,g[_t+8]=it,v[_t+9]=F,g[_t+10]=o,g[_t+11]=h,g[_t+12]=tt,g[_t+13]=it,v[_t+14]=k,g[_t+15]=i,g[_t+16]=n,g[_t+17]=$,g[_t+18]=et,v[_t+19]=L,g[_t+20]=o,g[_t+21]=h,g[_t+22]=tt,g[_t+23]=it,v[_t+24]=k,g[_t+25]=u,g[_t+26]=l,g[_t+27]=tt,g[_t+28]=et,v[_t+29]=P,this.vertexCount+=6))}}else z=0,G=0,N+=C,nt=null},batchDynamicBitmapText:function(t,e){this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var i,n,s,r,o,h,u,l,c,d,f,p,g,v,y=this.renderer.config.roundPixels,m=t.displayCallback,x=t.text,w=x.length,b=a.getTintAppendFloatAlpha,T=this.vertexViewF32,A=this.vertexViewU32,S=this.renderer,C=e.matrix.matrix,M=t.frame,E=t.texture.source[M.sourceIndex],_=e.scrollX*t.scrollFactorX,L=e.scrollY*t.scrollFactorY,P=t.scrollX,F=t.scrollY,k=t.fontData,R=k.lineHeight,O=t.fontSize/k.size,D=k.chars,I=t.alpha,B=b(t._tintTL,I),Y=b(t._tintTR,I),X=b(t._tintBL,I),z=b(t._tintBR,I),N=t.x,G=t.y,W=M.cutX,U=M.cutY,V=E.width,H=E.height,j=E.glTexture,q=0,K=0,J=0,Z=0,Q=null,$=0,tt=0,et=0,it=0,nt=0,st=0,rt=0,ot=0,at=0,ht=0,ut=0,lt=0,ct=null,dt=0,ft=N+M.x,pt=G+M.y,gt=-t.rotation,vt=t.scaleX,yt=t.scaleY,mt=Math.sin(gt),xt=Math.cos(gt),wt=xt*vt,bt=-mt*vt,Tt=mt*yt,At=xt*yt,St=ft,Ct=pt,Mt=C[0],Et=C[1],_t=C[2],Lt=C[3],Pt=wt*Mt+bt*_t,Ft=wt*Et+bt*Lt,kt=Tt*Mt+At*_t,Rt=Tt*Et+At*Lt,Ot=St*Mt+Ct*_t+C[4],Dt=St*Et+Ct*Lt+C[5],It=t.cropWidth>0||t.cropHeight>0,Bt=0;this.setTexture2D(j,0),It&&S.pushScissor(t.x,t.y,t.cropWidth*t.scaleX,t.cropHeight*t.scaleY);for(var Yt=0;Ytthis.vertexCapacity&&this.flush(),Bt=this.vertexCount*this.vertexComponentCount,y&&(i|=0,n|=0,s|=0,r|=0,o|=0,h|=0,u|=0,l|=0),T[Bt+0]=i,T[Bt+1]=n,T[Bt+2]=at,T[Bt+3]=ut,A[Bt+4]=B,T[Bt+5]=s,T[Bt+6]=r,T[Bt+7]=at,T[Bt+8]=lt,A[Bt+9]=X,T[Bt+10]=o,T[Bt+11]=h,T[Bt+12]=ht,T[Bt+13]=lt,A[Bt+14]=z,T[Bt+15]=i,T[Bt+16]=n,T[Bt+17]=at,T[Bt+18]=ut,A[Bt+19]=B,T[Bt+20]=o,T[Bt+21]=h,T[Bt+22]=ht,T[Bt+23]=lt,A[Bt+24]=z,T[Bt+25]=u,T[Bt+26]=l,T[Bt+27]=ht,T[Bt+28]=ut,A[Bt+29]=Y,this.vertexCount+=6}}}else q=0,J=0,K+=R,ct=null;It&&S.popScissor()},batchText:function(t,e){var i=a.getTintAppendFloatAlpha;this.batchTexture(t,t.canvasTexture,t.canvasTexture.width,t.canvasTexture.height,t.x,t.y,t.canvasTexture.width,t.canvasTexture.height,t.scaleX,t.scaleY,t.rotation,t.flipX,t.flipY,t.scrollFactorX,t.scrollFactorY,t.displayOriginX,t.displayOriginY,0,0,t.canvasTexture.width,t.canvasTexture.height,i(t._tintTL,t._alphaTL),i(t._tintTR,t._alphaTR),i(t._tintBL,t._alphaBL),i(t._tintBR,t._alphaBR),0,0,e)},batchDynamicTilemapLayer:function(t,e){for(var i=t.culledTiles,n=i.length,s=t.tileset.image.get().source.glTexture,r=t.tileset,o=t.scrollFactorX,h=t.scrollFactorY,u=t.alpha,l=t.x,c=t.y,d=t.scaleX,f=t.scaleY,p=a.getTintAppendFloatAlpha,g=0;gthis.vertexCapacity&&this.flush(),d^=e.isRenderTexture?1:0,l=-l;var _,L=this.renderer.config.roundPixels,P=this.vertexViewF32,F=this.vertexViewU32,k=E.matrix.matrix,R=o*(c?1:0)-g,O=a*(d?1:0)-v,D=R+o*(c?-1:1),I=O+a*(d?-1:1),B=s-E.scrollX*f,Y=r-E.scrollY*p,X=Math.sin(l),z=Math.cos(l),N=z*h,G=-X*h,W=X*u,U=z*u,V=B,H=Y,j=k[0],q=k[1],K=k[2],J=k[3],Z=N*j+G*K,Q=N*q+G*J,$=W*j+U*K,tt=W*q+U*J,et=V*j+H*K+k[4],it=V*q+H*J+k[5],nt=R*Z+O*$+et,st=R*Q+O*tt+it,rt=R*Z+I*$+et,ot=R*Q+I*tt+it,at=D*Z+I*$+et,ht=D*Q+I*tt+it,ut=D*Z+O*$+et,lt=D*Q+O*tt+it,ct=y/i+C,dt=m/n+M,ft=(y+x)/i+C,pt=(m+w)/n+M;this.setTexture2D(e,0),_=this.vertexCount*this.vertexComponentCount,L&&(nt|=0,st|=0,rt|=0,ot|=0,at|=0,ht|=0,ut|=0,lt|=0),P[_+0]=nt,P[_+1]=st,P[_+2]=ct,P[_+3]=dt,F[_+4]=b,P[_+5]=rt,P[_+6]=ot,P[_+7]=ct,P[_+8]=pt,F[_+9]=T,P[_+10]=at,P[_+11]=ht,P[_+12]=ft,P[_+13]=pt,F[_+14]=A,P[_+15]=nt,P[_+16]=st,P[_+17]=ct,P[_+18]=dt,F[_+19]=b,P[_+20]=at,P[_+21]=ht,P[_+22]=ft,P[_+23]=pt,F[_+24]=A,P[_+25]=ut,P[_+26]=lt,P[_+27]=ft,P[_+28]=dt,F[_+29]=S,this.vertexCount+=6},drawTexture:function(t,e,i,n,s,r,o,h,u,l){this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var c,d=this.renderer.config.roundPixels,f=this.vertexViewF32,p=this.vertexViewU32,g=e,v=i,y=g+h,m=v+u,x=l[0],w=l[1],b=l[2],T=l[3],A=l[4],S=l[5],C=g*x+v*b+A,M=g*w+v*T+S,E=g*x+m*b+A,_=g*w+m*T+S,L=y*x+m*b+A,P=y*w+m*T+S,F=y*x+v*b+A,k=y*w+v*T+S,R=t.width,O=t.height,D=r/R,I=o/O,B=(r+h)/R,Y=(o+u)/O;n=a.getTintAppendFloatAlpha(n,s),this.setTexture2D(t,0),c=this.vertexCount*this.vertexComponentCount,d&&(C|=0,M|=0,E|=0,_|=0,L|=0,P|=0,F|=0,k|=0),f[c+0]=C,f[c+1]=M,f[c+2]=D,f[c+3]=I,p[c+4]=n,f[c+5]=E,f[c+6]=_,f[c+7]=D,f[c+8]=Y,p[c+9]=n,f[c+10]=L,f[c+11]=P,f[c+12]=B,f[c+13]=Y,p[c+14]=n,f[c+15]=C,f[c+16]=M,f[c+17]=D,f[c+18]=I,p[c+19]=n,f[c+20]=L,f[c+21]=P,f[c+22]=B,f[c+23]=Y,p[c+24]=n,f[c+25]=F,f[c+26]=k,f[c+27]=B,f[c+28]=I,p[c+29]=n,this.vertexCount+=6,this.flush()},batchGraphics:function(){}});t.exports=u},function(t,e,i){var n=i(0),s=i(812),r=i(172),o=new n({Extends:r,initialize:function(t){t.fragShader=s.replace("%LIGHT_COUNT%",10..toString()),r.call(this,t)},onBind:function(){r.prototype.onBind.call(this);var t=this.renderer,e=this.program;return this.mvpUpdate(),t.setInt1(e,"uNormSampler",1),t.setFloat2(e,"uResolution",this.width,this.height),this},onRender:function(t,e){var i=t.sys.lights;if(!i)return this;if(i.culledLights.length=0,i.lights.length<=0||!i.active)return this;var n,s=this.renderer,r=this.program,o=i.cull(e),a=Math.min(o.length,10),h=e.matrix,u={x:0,y:0},l=s.height;for(n=0;n<10;++n)s.setFloat1(r,"uLights["+n+"].radius",0);if(a<=0)return this;for(s.setFloat4(r,"uCamera",e.x,e.y,e.rotation,e.zoom),s.setFloat3(r,"uAmbientLightColor",i.ambientColor.r,i.ambientColor.g,i.ambientColor.b),n=0;n=t.length)){for(var i=t.length-1,n=t[e],s=e;s-1;r--)n[s][r]=t[r][s]}return n}},function(t,e,i){var n=i(0),s=i(15),r=i(82),o=i(68),a=new n({Extends:s,initialize:function(t){s.call(this),this.manager=t,this.isTimeline=!0,this.data=[],this.totalData=0,this.useFrames=!1,this.timeScale=1,this.loop=0,this.loopDelay=0,this.loopCounter=0,this.completeDelay=0,this.countdown=0,this.state=o.PENDING_ADD,this._pausedState=o.PENDING_ADD,this.paused=!1,this.elapsed=0,this.totalElapsed=0,this.duration=0,this.progress=0,this.totalDuration=0,this.totalProgress=0,this.callbacks={onComplete:null,onLoop:null,onStart:null,onUpdate:null,onYoyo:null},this.callbackScope},setTimeScale:function(t){return this.timeScale=t,this},getTimeScale:function(){return this.timeScale},isPlaying:function(){return this.state===o.ACTIVE},add:function(t){return this.queue(r(this,t))},queue:function(t){return this.isPlaying()||(t.parent=this,t.parentIsTimeline=!0,this.data.push(t),this.totalData=this.data.length),this},hasOffset:function(t){return null!==t.offset},isOffsetAbsolute:function(t){return"number"==typeof t},isOffsetRelative:function(t){if("string"===typeof t){var e=t[0];if("-"===e||"+"===e)return!0}return!1},getRelativeOffset:function(t,e){var i=t[0],n=parseFloat(t.substr(2)),s=e;switch(i){case"+":s+=n;break;case"-":s-=n}return Math.max(0,s)},calcDuration:function(){for(var t=0,e=0,i=0,n=0;n0?this.totalDuration=this.duration+this.completeDelay+(this.duration+this.loopDelay)*this.loopCounter:this.totalDuration=this.duration+this.completeDelay},init:function(){return this.calcDuration(),this.progress=0,this.totalProgress=0,!this.paused||(this.state=o.PAUSED,!1)},resetTweens:function(t){for(var e=0;e0){this.elapsed=0,this.progress=0,this.loopCounter--;var t=this.callbacks.onLoop;t&&t.func.apply(t.scope,t.params),this.emit("loop",this,this.loopCounter),this.resetTweens(!0),this.loopDelay>0?(this.countdown=this.loopDelay,this.state=o.LOOP_DELAY):this.state=o.ACTIVE}else if(this.completeDelay>0)this.countdown=this.completeDelay,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&e.func.apply(e.scope,e.params),this.emit("complete",this),this.state=o.PENDING_REMOVE}},update:function(t,e){if(this.state!==o.PAUSED){var i=e;switch(this.useFrames&&(e=1*this.manager.timeScale),e*=this.timeScale,this.elapsed+=e,this.progress=Math.min(this.elapsed/this.duration,1),this.totalElapsed+=e,this.totalProgress=Math.min(this.totalElapsed/this.totalDuration,1),this.state){case o.ACTIVE:for(var n=this.totalData,s=0;s0?Math.floor(v/p.length):h(e,"duration",g.duration),g.delay=h(e,"delay",g.delay),g.easeParams=c(e,"easeParams",g.easeParams),g.ease=a(c(e,"ease",g.ease),g.easeParams),g.hold=h(e,"hold",g.hold),g.repeat=h(e,"repeat",g.repeat),g.repeatDelay=h(e,"repeatDelay",g.repeatDelay),g.yoyo=o(e,"yoyo",g.yoyo),g.flipX=o(e,"flipX",g.flipX),g.flipY=o(e,"flipY",g.flipY);for(var y=0;y0){var t=this.delay+this.delay*this.repeat;return(this.elapsed+this.delay*(this.repeat-this.repeatCount))/t}return this.getProgress()},getRepeatCount:function(){return this.repeatCount},getElapsed:function(){return this.elapsed},getElapsedSeconds:function(){return.001*this.elapsed},remove:function(t){void 0===t&&(t=!1),this.elapsed=this.delay,this.hasDispatched=!t,this.repeatCount=0},destroy:function(){this.callback=void 0,this.callbackScope=void 0,this.args=[]}});t.exports=r},function(t,e,i){var n=i(0),s=i(13),r=i(21),o=i(1),a=i(411),h=i(88),u=i(44),l=new n({Extends:o,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Flip,s.GetBounds,s.Origin,s.Pipeline,s.ScaleMode,s.Size,s.Transform,s.Visible,s.ScrollFactor,a],initialize:function(t,e,i,n,s,a){o.call(this,t,"StaticTilemapLayer"),this.isTilemap=!0,this.tilemap=e,this.layerIndex=i,this.layer=e.layers[i],this.layer.tilemapLayer=this,this.tileset=n,this.culledTiles=[],this.vertexBuffer=null,this.renderer=t.sys.game.renderer,this.bufferData=null,this.vertexViewF32=null,this.vertexViewU32=null,this.dirty=!0,this.vertexCount=0,this.setAlpha(this.layer.alpha),this.setPosition(s,a),this.setOrigin(),this.setSize(this.layer.tileWidth*this.layer.width,this.layer.tileHeight*this.layer.height),this.initPipeline("TextureTintPipeline"),t.sys.game.config.renderType===r.WEBGL&&t.sys.game.renderer.onContextRestored(function(){this.dirty=!0,this.vertexBuffer=null},this)},upload:function(t){var e,i,n,s,r=this.tileset,o=this.layer.width,a=this.layer.height,h=r.image.get().width,l=r.image.get().height,c=this.layer.data,d=this.renderer;if(d.gl){var f=d.pipelines.TextureTintPipeline;if(this.dirty){var p=d.gl,g=this.vertexBuffer,v=this.bufferData,y=0,m=0,x=o*a*f.vertexSize*6;null===v&&(v=new ArrayBuffer(x),this.bufferData=v,this.vertexViewF32=new Float32Array(v),this.vertexViewU32=new Uint32Array(v));var w=this.vertexViewF32,b=this.vertexViewU32;for(i=0;ia&&(a=e.layer[u].width),e.layer[u].height>h&&(h=e.layer[u].height);var l=new s({width:a,height:h,name:t,tileWidth:e.layer[0].tilesize,tileHeight:e.layer[0].tilesize,format:n.WELTMEISTER});return l.layers=r(e,i),l.tilesets=o(e),l}},function(t,e,i){var n=i(0),s=i(2),r=new n({initialize:function(t){void 0===t&&(t={}),this.name=s(t,"name","object layer"),this.opacity=s(t,"opacity",1),this.properties=s(t,"properties",{}),this.propertyTypes=s(t,"propertytypes",{}),this.type=s(t,"type","objectgroup"),this.visible=s(t,"visible",!0),this.objects=s(t,"objects",[])}});t.exports=r},function(t,e,i){var n=i(420),s=i(191),r=function(t){return{x:t.x,y:t.y}},o=["id","name","type","rotation","properties","visible","x","y","width","height"];t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=0);var a=n(t,o);if(a.x+=e,a.y+=i,t.gid){var h=s(t.gid);a.gid=h.gid,a.flippedHorizontal=h.flippedHorizontal,a.flippedVertical=h.flippedVertical,a.flippedAntiDiagonal=h.flippedAntiDiagonal}else t.polyline?a.polyline=t.polyline.map(r):t.polygon?a.polygon=t.polygon.map(r):t.ellipse?(a.ellipse=t.ellipse,a.width=t.width,a.height=t.height):t.text?(a.width=t.width,a.height=t.height,a.text=t.text):(a.rectangle=!0,a.width=t.width,a.height=t.height);return a}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r,o){(void 0===i||i<=0)&&(i=32),(void 0===n||n<=0)&&(n=32),void 0===s&&(s=0),void 0===r&&(r=0),this.name=t,this.firstgid=0|e,this.imageWidth=0|i,this.imageHeight=0|n,this.imageMargin=0|s,this.imageSpacing=0|r,this.properties=o||{},this.images=[],this.total=0},containsImageIndex:function(t){return t>=this.firstgid&&t-1}return!1}},function(t,e,i){var n=i(14);t.exports=function(t,e,i,s,r,o,a){for(var h=n(i,s,r,o,null,a),u=0;u0?(this.world.staticTree.remove(this),this.isCircle=!0,this.radius=t,this.width=2*t,this.height=2*t,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.set(e,i),this.updateCenter(),this.world.staticTree.insert(this)):this.isCircle=!1,this},updateCenter:function(){this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},reset:function(t,e){var i=this.gameObject;void 0===t&&(t=i.x),void 0===e&&(e=i.y),this.world.staticTree.remove(this),i.getTopLeft(this.position),this.updateCenter(),this.world.staticTree.insert(this)},stop:function(){return this},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,e){return this.isCircle?n(this,t,e):o(this,t,e)},deltaAbsX:function(){return 0},deltaAbsY:function(){return 0},deltaX:function(){return 0},deltaY:function(){return 0},deltaZ:function(){return 0},destroy:function(){this.enable=!1,this.world.pendingDestroy.set(this)},drawDebug:function(t){var e=this.position;this.debugShowBody&&(t.lineStyle(1,this.debugBodyColor,1),t.strokeRect(e.x,e.y,this.width,this.height))},willDrawDebug:function(){return this.debugShowBody},setMass:function(t){return t<=0&&(t=.1),this.mass=t,this},x:{get:function(){return this.position.x},set:function(t){this.world.staticTree.remove(this),this.position.x=t,this.world.staticTree.insert(this)}},y:{get:function(){return this.position.y},set:function(t){this.world.staticTree.remove(this),this.position.y=t,this.world.staticTree.insert(this)}},left:{get:function(){return this.position.x}},right:{get:function(){return this.position.x+this.width}},top:{get:function(){return this.position.y}},bottom:{get:function(){return this.position.y+this.height}}});t.exports=h},function(t,e){t.exports=function(t,e){return!(e.right<=t.left||e.bottom<=t.top||e.position.x>=t.right||e.position.y>=t.bottom)}},function(t,e){var i=function(t,e,r,o,a){for(r=r||0,o=o||t.length-1,a=a||s;o>r;){if(o-r>600){var h=o-r+1,u=e-r+1,l=Math.log(h),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(h-c)/h)*(u-h/2<0?-1:1),f=Math.max(r,Math.floor(e-u*c/h+d)),p=Math.min(o,Math.floor(e+(h-u)*c/h+d));i(t,e,f,p,a)}var g=t[e],v=r,y=o;for(n(t,r,e),a(t[o],g)>0&&n(t,r,o);v0;)y--}0===a(t[r],g)?n(t,r,y):n(t,++y,o),y<=e&&(r=y+1),e<=y&&(o=y-1)}};function n(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function s(t,e){return te?1:0}t.exports=i},function(t,e,i){var n=i(203);function s(t,e){if(!(this instanceof s))return new s(t,e);this._maxEntries=Math.max(4,t||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),e&&this._initFormat(e),this.clear()}function r(t,e,i){if(!i)return e.indexOf(t);for(var n=0;n=t.minX&&e.maxY>=t.minY}function g(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function v(t,e,i,s,r){for(var o,a=[e,i];a.length;)(i=a.pop())-(e=a.pop())<=s||(o=e+Math.ceil((i-e)/s/2)*s,n(t,o,e,i,r),a.push(e,o,o,i))}s.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,i=[],n=this.toBBox;if(!p(t,e))return i;for(var s,r,o,a,h=[];e;){for(s=0,r=e.children.length;s=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(s,r,e)},_split:function(t,e){var i=t[e],n=i.children.length,s=this._minEntries;this._chooseSplitAxis(i,s,n);var r=this._chooseSplitIndex(i,s,n),a=g(i.children.splice(r,i.children.length-r));a.height=i.height,a.leaf=i.leaf,o(i,this.toBBox),o(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)},_splitRoot:function(t,e){this.data=g([t,e]),this.data.height=t.height+1,this.data.leaf=!1,o(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,i){var n,s,r,o,h,u,l,d,f,p,g,v,y,m;for(u=l=1/0,n=e;n<=i-e;n++)s=a(t,0,n,this.toBBox),r=a(t,n,i,this.toBBox),f=s,p=r,void 0,void 0,void 0,void 0,g=Math.max(f.minX,p.minX),v=Math.max(f.minY,p.minY),y=Math.min(f.maxX,p.maxX),m=Math.min(f.maxY,p.maxY),o=Math.max(0,y-g)*Math.max(0,m-v),h=c(s)+c(r),o=e;s--)r=t.children[s],h(l,t.leaf?o(r):r),c+=d(l);return c},_adjustParentBBoxes:function(t,e,i){for(var n=i;n>=0;n--)h(e[n],t)},_condense:function(t){for(var e,i=t.length-1;i>=0;i--)0===t[i].children.length?i>0?(e=t[i-1].children).splice(e.indexOf(t[i]),1):this.clear():o(t[i],this.toBBox)},_initFormat:function(t){var e=["return a"," - b",";"];this.compareMinX=new Function("a","b",e.join(t[0])),this.compareMinY=new Function("a","b",e.join(t[1])),this.toBBox=new Function("a","return {minX: a"+t[0]+", minY: a"+t[1]+", maxX: a"+t[2]+", maxY: a"+t[3]+"};")}},t.exports=s},function(t,e,i){var n=new(i(0))({initialize:function(){this._pending=[],this._active=[],this._destroy=[],this._toProcess=0},add:function(t){return this._pending.push(t),this._toProcess++,this},remove:function(t){return this._destroy.push(t),this._toProcess++,this},update:function(){if(0===this._toProcess)return this._active;var t,e,i=this._destroy,n=this._active;for(t=0;te.deltaY()?(s=t.bottom-e.y)>r&&!i||!1===t.checkCollision.down||!1===e.checkCollision.up?s=0:(t.touching.none=!1,t.touching.down=!0,e.touching.none=!1,e.touching.up=!0):t.deltaY()r&&!i||!1===t.checkCollision.up||!1===e.checkCollision.down?s=0:(t.touching.none=!1,t.touching.up=!0,e.touching.none=!1,e.touching.down=!0)),t.overlapY=s,e.overlapY=s,s}},function(t,e){t.exports=function(t,e,i,n){var s=0,r=t.deltaAbsX()+e.deltaAbsX()+n;return 0===t.deltaX()&&0===e.deltaX()?(t.embedded=!0,e.embedded=!0):t.deltaX()>e.deltaX()?(s=t.right-e.x)>r&&!i||!1===t.checkCollision.right||!1===e.checkCollision.left?s=0:(t.touching.none=!1,t.touching.right=!0,e.touching.none=!1,e.touching.left=!0):t.deltaX()r&&!i||!1===t.checkCollision.left||!1===e.checkCollision.right?s=0:(t.touching.none=!1,t.touching.left=!0,e.touching.none=!1,e.touching.right=!0)),t.overlapX=s,e.overlapX=s,s}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r,o){this.world=t,this.name="",this.active=!0,this.overlapOnly=e,this.object1=i,this.object2=n,this.collideCallback=s,this.processCallback=r,this.callbackContext=o},setName:function(t){return this.name=t,this},update:function(){this.world.collideObjects(this.object1,this.object2,this.collideCallback,this.processCallback,this.callbackContext,this.overlapOnly)},destroy:function(){this.world.removeCollider(this),this.active=!1,this.world=null,this.object1=null,this.object2=null,this.collideCallback=null,this.processCallback=null,this.callbackContext=null}});t.exports=n},function(t,e,i){var n=i(28),s=i(0),r=i(47),o=i(10),a=i(27),h=i(6),u=new s({initialize:function(t,e){this.world=t,this.gameObject=e,this.debugShowBody=t.defaults.debugShowBody,this.debugShowVelocity=t.defaults.debugShowVelocity,this.debugBodyColor=t.defaults.bodyDebugColor,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new h,this.position=new h(e.x,e.y),this.prev=new h(this.position.x,this.position.y),this.allowRotation=!0,this.rotation=e.angle,this.preRotation=e.angle,this.width=e.width,this.height=e.height,this.sourceWidth=e.width,this.sourceHeight=e.height,e.frame&&(this.sourceWidth=e.frame.realWidth,this.sourceHeight=e.frame.realHeight),this.halfWidth=Math.abs(e.width/2),this.halfHeight=Math.abs(e.height/2),this.center=new h(e.x+this.halfWidth,e.y+this.halfHeight),this.velocity=new h,this.newVelocity=new h,this.deltaMax=new h,this.acceleration=new h,this.allowDrag=!0,this.drag=new h,this.allowGravity=!0,this.gravity=new h,this.bounce=new h,this.worldBounce=null,this.onWorldBounds=!1,this.onCollide=!1,this.onOverlap=!1,this.maxVelocity=new h(1e4,1e4),this.friction=new h(1,0),this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e3,this.mass=1,this.angle=0,this.speed=0,this.facing=r.FACING_NONE,this.immovable=!1,this.moves=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.overlapR=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision={none:!1,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.blocked={none:!0,up:!1,down:!1,left:!1,right:!1},this.dirty=!1,this.syncBounds=!1,this.isMoving=!1,this.stopVelocityOnCollide=!0,this.physicsType=r.DYNAMIC_BODY,this._reset=!0,this._sx=e.scaleX,this._sy=e.scaleY,this._dx=0,this._dy=0,this._bounds=new o},updateBounds:function(){var t=this.gameObject;if(this.syncBounds){var e=t.getBounds(this._bounds);e.width===this.width&&e.height===this.height||(this.width=e.width,this.height=e.height,this._reset=!0)}else{var i=Math.abs(t.scaleX),n=Math.abs(t.scaleY);i===this._sx&&n===this._sy||(this.width=this.sourceWidth*i,this.height=this.sourceHeight*n,this._sx=i,this._sy=n,this._reset=!0)}this._reset&&(this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter())},updateCenter:function(){this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},update:function(t){this.dirty=!0,this.wasTouching.none=this.touching.none,this.wasTouching.up=this.touching.up,this.wasTouching.down=this.touching.down,this.wasTouching.left=this.touching.left,this.wasTouching.right=this.touching.right,this.touching.none=!0,this.touching.up=!1,this.touching.down=!1,this.touching.left=!1,this.touching.right=!1,this.blocked.none=!0,this.blocked.up=!1,this.blocked.down=!1,this.blocked.left=!1,this.blocked.right=!1,this.overlapR=0,this.overlapX=0,this.overlapY=0,this.embedded=!1,this.updateBounds();var e=this.gameObject;this.position.x=e.x+e.scaleX*(this.offset.x-e.displayOriginX),this.position.y=e.y+e.scaleY*(this.offset.y-e.displayOriginY),this.updateCenter(),this.rotation=e.angle,this.preRotation=this.rotation,this._reset&&(this.prev.x=this.position.x,this.prev.y=this.position.y),this.moves&&(this.world.updateMotion(this),this.newVelocity.set(this.velocity.x*t,this.velocity.y*t),this.position.x+=this.newVelocity.x,this.position.y+=this.newVelocity.y,this.updateCenter(),this.position.x===this.prev.x&&this.position.y===this.prev.y||(this.angle=Math.atan2(this.velocity.y,this.velocity.x)),this.speed=Math.sqrt(this.velocity.x*this.velocity.x+this.velocity.y*this.velocity.y),this.collideWorldBounds&&this.checkWorldBounds()&&this.onWorldBounds&&this.world.emit("worldbounds",this,this.blocked.up,this.blocked.down,this.blocked.left,this.blocked.right)),this._dx=this.deltaX(),this._dy=this.deltaY(),this._reset=!1},postUpdate:function(){this.enable&&this.dirty&&(this.dirty=!1,this._dx=this.deltaX(),this._dy=this.deltaY(),this._dx<0?this.facing=r.FACING_LEFT:this._dx>0&&(this.facing=r.FACING_RIGHT),this._dy<0?this.facing=r.FACING_UP:this._dy>0&&(this.facing=r.FACING_DOWN),this.moves&&(0!==this.deltaMax.x&&0!==this._dx&&(this._dx<0&&this._dx<-this.deltaMax.x?this._dx=-this.deltaMax.x:this._dx>0&&this._dx>this.deltaMax.x&&(this._dx=this.deltaMax.x)),0!==this.deltaMax.y&&0!==this._dy&&(this._dy<0&&this._dy<-this.deltaMax.y?this._dy=-this.deltaMax.y:this._dy>0&&this._dy>this.deltaMax.y&&(this._dy=this.deltaMax.y)),this.gameObject.x+=this._dx,this.gameObject.y+=this._dy,this._reset=!0),this.updateCenter(),this.allowRotation&&(this.gameObject.angle+=this.deltaZ()),this.prev.x=this.position.x,this.prev.y=this.position.y)},checkWorldBounds:function(){var t=this.position,e=this.world.bounds,i=this.world.checkCollision,n=this.worldBounce?-this.worldBounce.x:-this.bounce.x,s=this.worldBounce?-this.worldBounce.y:-this.bounce.y;return t.xe.right&&i.right&&(t.x=e.right-this.width,this.velocity.x*=n,this.blocked.right=!0,this.blocked.none=!1),t.ye.bottom&&i.down&&(t.y=e.bottom-this.height,this.velocity.y*=s,this.blocked.down=!0,this.blocked.none=!1),!this.blocked.none},setOffset:function(t,e){return void 0===e&&(e=t),this.offset.set(t,e),this},setSize:function(t,e,i){void 0===i&&(i=!0);var n=this.gameObject;if(this.sourceWidth=t,this.sourceHeight=e,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter(),i&&n.getCenter){var s=n.displayWidth/2,r=n.displayHeight/2;this.offset.set(s-this.halfWidth,r-this.halfHeight)}return this.isCircle=!1,this.radius=0,this},setCircle:function(t,e,i){return void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.isCircle=!0,this.radius=t,this.sourceWidth=2*t,this.sourceHeight=2*t,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.set(e,i),this.updateCenter()):this.isCircle=!1,this},reset:function(t,e){this.stop();var i=this.gameObject;i.setPosition(t,e),i.getTopLeft(this.position),this.prev.copy(this.position),this.rotation=i.angle,this.preRotation=i.angle,this.updateBounds(),this.updateCenter()},stop:function(){return this.velocity.set(0),this.acceleration.set(0),this.speed=0,this.angularVelocity=0,this.angularAcceleration=0,this},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,e){return this.isCircle?n(this,t,e):a(this,t,e)},onFloor:function(){return this.blocked.down},onCeiling:function(){return this.blocked.up},onWall:function(){return this.blocked.left||this.blocked.right},deltaAbsX:function(){return this.deltaX()>0?this.deltaX():-this.deltaX()},deltaAbsY:function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},deltaX:function(){return this.position.x-this.prev.x},deltaY:function(){return this.position.y-this.prev.y},deltaZ:function(){return this.rotation-this.preRotation},destroy:function(){this.enable=!1,this.world.pendingDestroy.set(this)},drawDebug:function(t){var e=this.position,i=e.x+this.halfWidth,n=e.y+this.halfHeight;this.debugShowBody&&(t.lineStyle(1,this.debugBodyColor),this.isCircle?t.strokeCircle(i,n,this.width/2):t.strokeRect(e.x,e.y,this.width,this.height)),this.debugShowVelocity&&(t.lineStyle(1,this.world.defaults.velocityDebugColor,1),t.lineBetween(i,n,i+this.velocity.x/2,n+this.velocity.y/2))},willDrawDebug:function(){return this.debugShowBody||this.debugShowVelocity},setCollideWorldBounds:function(t){return this.collideWorldBounds=t,this},setVelocity:function(t,e){return this.velocity.set(t,e),this},setVelocityX:function(t){return this.velocity.x=t,this},setVelocityY:function(t){return this.velocity.y=t,this},setBounce:function(t,e){return this.bounce.set(t,e),this},setBounceX:function(t){return this.bounce.x=t,this},setBounceY:function(t){return this.bounce.y=t,this},setAcceleration:function(t,e){return this.acceleration.set(t,e),this},setAccelerationX:function(t){return this.acceleration.x=t,this},setAccelerationY:function(t){return this.acceleration.y=t,this},setDrag:function(t,e){return this.drag.set(t,e),this},setDragX:function(t){return this.drag.x=t,this},setDragY:function(t){return this.drag.y=t,this},setGravity:function(t,e){return this.gravity.set(t,e),this},setGravityX:function(t){return this.gravity.x=t,this},setGravityY:function(t){return this.gravity.y=t,this},setFriction:function(t,e){return this.friction.set(t,e),this},setFrictionX:function(t){return this.friction.x=t,this},setFrictionY:function(t){return this.friction.y=t,this},setAngularVelocity:function(t){return this.angularVelocity=t,this},setAngularAcceleration:function(t){return this.angularAcceleration=t,this},setAngularDrag:function(t){return this.angularDrag=t,this},setMass:function(t){return this.mass=t,this},setImmovable:function(t){return this.immovable=t,this},x:{get:function(){return this.position.x},set:function(t){this.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t}},left:{get:function(){return this.position.x}},right:{get:function(){return this.position.x+this.width}},top:{get:function(){return this.position.y}},bottom:{get:function(){return this.position.y+this.height}}});t.exports=u},function(t,e,i){var n=i(209),s=i(64),r=i(0),o=i(208),a=i(47),h=i(48),u=i(15),l=i(207),c=i(206),d=i(5),f=i(205),p=i(477),g=i(10),v=i(204),y=i(476),m=i(471),x=i(470),w=i(63),b=i(201),T=i(202),A=i(6),S=i(43),C=new r({Extends:u,initialize:function(t,e){u.call(this),this.scene=t,this.bodies=new w,this.staticBodies=new w,this.pendingDestroy=new w,this.colliders=new f,this.gravity=new A(d(e,"gravity.x",0),d(e,"gravity.y",0)),this.bounds=new g(d(e,"x",0),d(e,"y",0),d(e,"width",t.sys.game.config.width),d(e,"height",t.sys.game.config.height)),this.checkCollision={up:d(e,"checkCollision.up",!0),down:d(e,"checkCollision.down",!0),left:d(e,"checkCollision.left",!0),right:d(e,"checkCollision.right",!0)},this.OVERLAP_BIAS=d(e,"overlapBias",4),this.TILE_BIAS=d(e,"tileBias",16),this.forceX=d(e,"forceX",!1),this.isPaused=d(e,"isPaused",!1),this._total=0,this.drawDebug=d(e,"debug",!1),this.debugGraphic,this.defaults={debugShowBody:d(e,"debugShowBody",!0),debugShowStaticBody:d(e,"debugShowStaticBody",!0),debugShowVelocity:d(e,"debugShowVelocity",!0),bodyDebugColor:d(e,"debugBodyColor",16711935),staticBodyDebugColor:d(e,"debugStaticBodyColor",255),velocityDebugColor:d(e,"debugVelocityColor",65280)},this.maxEntries=d(e,"maxEntries",16),this.tree=new v(this.maxEntries,[".left",".top",".right",".bottom"]),this.staticTree=new v(this.maxEntries,[".left",".top",".right",".bottom"]),this.treeMinMax={minX:0,minY:0,maxX:0,maxY:0},this.drawDebug&&this.createDebugGraphic()},enable:function(t,e){void 0===e&&(e=a.DYNAMIC_BODY);var i=1;if(Array.isArray(t))for(i=t.length;i--;)t[i].hasOwnProperty("children")?this.enable(t[i].children.entries,e):this.enableBody(t[i],e);else t.hasOwnProperty("children")?this.enable(t.children.entries,e):this.enableBody(t,e)},enableBody:function(t,e){return null===t.body&&(e===a.DYNAMIC_BODY?(t.body=new n(this,t),this.bodies.set(t.body)):e===a.STATIC_BODY&&(t.body=new b(this,t),this.staticBodies.set(t.body),this.staticTree.insert(t.body))),t},remove:function(t){this.disableBody(t)},disable:function(t){var e=1;if(Array.isArray(t))for(e=t.length;e--;)t[e].hasOwnProperty("children")?this.disable(t[e].children.entries):this.disableGameObjectBody(t[e]);else t.hasOwnProperty("children")?this.disable(t.children.entries):this.disableGameObjectBody(t)},disableGameObjectBody:function(t){return t.body&&(t.body.physicsType===a.DYNAMIC_BODY?this.bodies.delete(t.body):t.body.physicsType===a.STATIC_BODY&&(this.staticBodies.delete(t.body),this.staticTree.remove(t.body)),t.body.enable=!1),t},disableBody:function(t){t.physicsType===a.DYNAMIC_BODY?(this.tree.remove(t),this.bodies.delete(t)):t.physicsType===a.STATIC_BODY&&(this.staticBodies.delete(t),this.staticTree.remove(t)),t.enable=!1},createDebugGraphic:function(){var t=this.scene.sys.add.graphics({x:0,y:0});return t.setDepth(Number.MAX_VALUE),this.debugGraphic=t,this.drawDebug=!0,t},setBounds:function(t,e,i,n,s,r,o,a){return this.bounds.setTo(t,e,i,n),void 0!==s&&this.setBoundsCollision(s,r,o,a),this},setBoundsCollision:function(t,e,i,n){return void 0===t&&(t=!0),void 0===e&&(e=!0),void 0===i&&(i=!0),void 0===n&&(n=!0),this.checkCollision.left=t,this.checkCollision.right=e,this.checkCollision.up=i,this.checkCollision.down=n,this},pause:function(){return this.isPaused=!0,this.emit("pause"),this},resume:function(){return this.isPaused=!1,this.emit("resume"),this},addCollider:function(t,e,i,n,s){void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=i);var r=new o(this,!1,t,e,i,n,s);return this.colliders.add(r),r},addOverlap:function(t,e,i,n,s){void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=i);var r=new o(this,!0,t,e,i,n,s);return this.colliders.add(r),r},removeCollider:function(t){return this.colliders.remove(t),this},update:function(t,e){if(!this.isPaused&&0!==this.bodies.size){var i,n;e/=1e3,this.delta=e;var s=this.bodies.entries,r=s.length;for(i=0;i0){var u=this.tree,l=this.staticTree;for(o=(r=s.entries).length,t=0;t0?i-=s:i+s<0?i+=s:i=0),i>r?i=r:i<-r&&(i=-r),i},separate:function(t,e,i,n,s){if(!t.enable||!e.enable||t.checkCollision.none||e.checkCollision.none||!this.intersects(t,e))return!1;if(i&&!1===i.call(n,t.gameObject,e.gameObject))return!1;if(t.isCircle&&e.isCircle)return this.separateCircle(t,e,s);if(t.isCircle!==e.isCircle){var r=t.isCircle?e:t,o=t.isCircle?t:e,a={x:r.x,y:r.y,right:r.right,bottom:r.bottom},h=o.center;if((h.ya.bottom)&&(h.xa.right))return this.separateCircle(t,e,s)}var u=!1,l=!1;this.forceX||Math.abs(this.gravity.y+t.gravity.y)u.right&&(a=h(d.x,d.y,u.right,u.y)-d.radius):d.y>u.bottom&&(d.xu.right&&(a=h(d.x,d.y,u.right,u.bottom)-d.radius)),a*=-1}else a=t.halfWidth+e.halfWidth-h(t.center.x,t.center.y,e.center.x,e.center.y);if(i||0===a||t.immovable&&e.immovable||t.customSeparateX||e.customSeparateX)return 0!==a&&(t.onOverlap||e.onOverlap)&&this.emit("overlap",t.gameObject,e.gameObject,t,e),0!==a;var f=t.velocity.x,p=t.velocity.y,g=t.mass,v=e.velocity.x,y=e.velocity.y,m=e.mass,x=f*Math.cos(o)+p*Math.sin(o),w=f*Math.sin(o)-p*Math.cos(o),b=v*Math.cos(o)+y*Math.sin(o),T=v*Math.sin(o)-y*Math.cos(o),A=((g-m)*x+2*m*b)/(g+m),S=(2*g*x+(m-g)*b)/(g+m);return t.immovable||(t.velocity.x=(A*Math.cos(o)-w*Math.sin(o))*t.bounce.x,t.velocity.y=(w*Math.cos(o)+A*Math.sin(o))*t.bounce.y,f=t.velocity.x,p=t.velocity.y),e.immovable||(e.velocity.x=(S*Math.cos(o)-T*Math.sin(o))*e.bounce.x,e.velocity.y=(T*Math.cos(o)+S*Math.sin(o))*e.bounce.y,v=e.velocity.x,y=e.velocity.y),Math.abs(o)0&&!t.immovable&&v>f?t.velocity.x*=-1:v<0&&!e.immovable&&f0&&!t.immovable&&y>p?t.velocity.y*=-1:y<0&&!e.immovable&&pMath.PI/2&&(f<0&&!t.immovable&&v0&&!e.immovable&&f>v?e.velocity.x*=-1:p<0&&!t.immovable&&y0&&!e.immovable&&f>y&&(e.velocity.y*=-1)),t.immovable||(t.x+=t.velocity.x*this.delta-a*Math.cos(o),t.y+=t.velocity.y*this.delta-a*Math.sin(o)),e.immovable||(e.x+=e.velocity.x*this.delta+a*Math.cos(o),e.y+=e.velocity.y*this.delta+a*Math.sin(o)),(t.onCollide||e.onCollide)&&this.emit("collide",t.gameObject,e.gameObject,t,e),!0},intersects:function(t,e){return t!==e&&(t.isCircle?e.isCircle?h(t.center.x,t.center.y,e.center.x,e.center.y)<=t.halfWidth+e.halfWidth:this.circleBodyIntersects(t,e):e.isCircle?this.circleBodyIntersects(e,t):!(t.right<=e.position.x)&&(!(t.bottom<=e.position.y)&&(!(t.position.x>=e.right)&&!(t.position.y>=e.bottom))))},circleBodyIntersects:function(t,e){var i=s(t.center.x,e.left,e.right),n=s(t.center.y,e.top,e.bottom);return(t.center.x-i)*(t.center.x-i)+(t.center.y-n)*(t.center.y-n)<=t.halfWidth*t.halfWidth},overlap:function(t,e,i,n,s){return void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=i),this.collideObjects(t,e,i,n,s,!0)},collide:function(t,e,i,n,s){return void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=i),this.collideObjects(t,e,i,n,s,!1)},collideObjects:function(t,e,i,n,s,r){var o;t=t.isParent&&void 0===t.physicsType?t.children.entries:t,e=e.isParent&&void 0===e.physicsType?e.children.entries:e;var a=Array.isArray(t),h=Array.isArray(e);if(this._total=0,a||h)if(!a&&h)for(o=0;o0},collideHandler:function(t,e,i,n,s,r){if(void 0===e&&t.isParent)return this.collideGroupVsGroup(t,t,i,n,s,r);if(!t||!e)return!1;if(t.body){if(e.body)return this.collideSpriteVsSprite(t,e,i,n,s,r);if(e.isParent)return this.collideSpriteVsGroup(t,e,i,n,s,r);if(e.isTilemap)return this.collideSpriteVsTilemapLayer(t,e,i,n,s,r)}else if(t.isParent){if(e.body)return this.collideSpriteVsGroup(e,t,i,n,s,r);if(e.isParent)return this.collideGroupVsGroup(t,e,i,n,s,r);if(e.isTilemap)return this.collideGroupVsTilemapLayer(t,e,i,n,s,r)}else if(t.isTilemap){if(e.body)return this.collideSpriteVsTilemapLayer(e,t,i,n,s,r);if(e.isParent)return this.collideGroupVsTilemapLayer(e,t,i,n,s,r)}},collideSpriteVsSprite:function(t,e,i,n,s,r){return!(!t.body||!e.body)&&(this.separate(t.body,e.body,n,s,r)&&(i&&i.call(s,t,e),this._total++),!0)},collideSpriteVsGroup:function(t,e,i,n,s,r){var o=t.body;if(0!==e.length&&o){var h=this.treeMinMax;h.minX=o.left,h.minY=o.top,h.maxX=o.right,h.maxY=o.bottom;var u=e.physicsType===a.DYNAMIC_BODY?this.tree.search(h):this.staticTree.search(h);if(0!==u.length)for(var l=e.getChildren(),c=0;cc.baseTileWidth){var d=(c.tileWidth-c.baseTileWidth)*e.scaleX;a-=d,u+=d}c.tileHeight>c.baseTileHeight&&(l+=(c.tileHeight-c.baseTileHeight)*e.scaleY);var f,g=e.getTilesWithinWorldXY(a,h,u,l);if(0===g.length)return!1;for(var v={left:0,right:0,top:0,bottom:0},m=0;m0?Math.ceil(t):Math.floor(t)}},function(t,e){t.exports=function(t,e){var i=t.x,n=t.y;return t.x=i*Math.cos(e)-n*Math.sin(e),t.y=i*Math.sin(e)+n*Math.cos(e),t}},function(t,e){t.exports=function(t){if(0===t)return 1;for(var e=t;--t;)e*=t;return e}},function(t,e,i){var n=i(218);t.exports=function(t,e){return n(t)/n(e)/n(t-e)}},function(t,e){t.exports=function(t){return(t%=2*Math.PI)>=0?t:t+2*Math.PI}},function(t,e,i){var n=i(0),s=i(17),r=i(19),o=i(7),a=new n({Extends:r,initialize:function(t,e,i,n){var s={type:"text",extension:"txt",responseType:"text",key:t,url:e,path:i,xhrSettings:n};r.call(this,s)},onProcess:function(t){this.state=s.FILE_PROCESSING,this.data=this.xhrLoader.responseText,this.onComplete(),t(this)}});o.register("text",function(t,e,i){if(Array.isArray(t))for(var n=0;nu+l?(g=(p-=u+l)/c,v.x=h.x1+(h.x2-h.x1)*g,v.y=h.y1+(h.y2-h.y1)*g):(g=(p-=u)/l,v.x=a.x1+(a.x2-a.x1)*g,v.y=a.y1+(a.y2-a.y1)*g),r.push(v)}return r}},function(t,e,i){var n=i(4),s=i(77);t.exports=function(t,e,i){void 0===i&&(i=new n);var r=t.getLineA(),o=t.getLineB(),a=t.getLineC();if(e<=0||e>=1)return i.x=r.x1,i.y=r.y1,i;var h=s(r),u=s(o),l=s(a),c=(h+u+l)*e,d=0;return ch+u?(d=(c-=h+u)/l,i.x=a.x1+(a.x2-a.x1)*d,i.y=a.y1+(a.y2-a.y1)*d):(d=(c-=h)/u,i.x=o.x1+(o.x2-o.x1)*d,i.y=o.y1+(o.y2-o.y1)*d),i}},function(t,e){t.exports=function(t,e,i){return t.x=e-t.width/2,t.y=i-t.height/2,t}},function(t,e,i){var n=i(10);n.Area=i(605),n.Ceil=i(604),n.CeilAll=i(603),n.CenterOn=i(233),n.Clone=i(602),n.Contains=i(27),n.ContainsPoint=i(601),n.ContainsRect=i(600),n.CopyFrom=i(599),n.Decompose=i(240),n.Equals=i(598),n.FitInside=i(597),n.FitOutside=i(596),n.Floor=i(595),n.FloorAll=i(594),n.FromPoints=i(150),n.GetAspectRatio=i(124),n.GetCenter=i(593),n.GetPoint=i(166),n.GetPoints=i(352),n.GetSize=i(592),n.Inflate=i(591),n.MarchingAnts=i(347),n.MergePoints=i(590),n.MergeRect=i(589),n.MergeXY=i(588),n.Offset=i(587),n.OffsetPoint=i(586),n.Overlaps=i(585),n.Perimeter=i(105),n.PerimeterPoint=i(584),n.Random=i(163),n.Scale=i(583),n.Union=i(582),t.exports=n},function(t,e,i){var n=i(0),s=i(125),r=new n({initialize:function(t){this.area=0,this.points=[],t&&this.setTo(t)},contains:function(t,e){return s(this,t,e)},setTo:function(t){if(this.area=0,this.points=[],!Array.isArray(t))return this;for(var e,i=Number.MAX_VALUE,n=0;n0){var d=(a*r+h*o)/u;l*=d,c*=d}return i.x=t.x1+l,i.y=t.y1+c,l*l+c*c<=u&&l*r+c*o>=0&&n(e,i.x,i.y)}},function(t,e){t.exports=function(t,e){return!(t.width<=0||t.height<=0||e.width<=0||e.height<=0||t.righte.right||t.y>e.bottom)}},function(t,e,i){t.exports={CircleToCircle:i(652),CircleToRectangle:i(651),GetRectangleIntersection:i(650),LineToCircle:i(242),LineToLine:i(95),LineToRectangle:i(649),PointToLine:i(241),PointToLineSegment:i(648),RectangleToRectangle:i(243),RectangleToTriangle:i(647),RectangleToValues:i(646),TriangleToCircle:i(645),TriangleToLine:i(644),TriangleToTriangle:i(643)}},function(t,e,i){t.exports={Circle:i(662),Ellipse:i(269),Intersects:i(244),Line:i(642),Point:i(624),Polygon:i(610),Rectangle:i(234),Triangle:i(581)}},function(t,e,i){var n=i(0),s=i(247),r=i(173),o=i(44),a=new n({initialize:function(){this.lightPool=[],this.lights=[],this.culledLights=[],this.ambientColor={r:.1,g:.1,b:.1},this.active=!1},enable:function(){return this.active=!0,this},disable:function(){return this.active=!1,this},cull:function(t){var e=this.lights,i=this.culledLights,n=e.length,s=t.x+t.width/2,o=t.y+t.height/2,a=(t.width+t.height)/2,h={x:0,y:0},u=t.matrix,l=this.systems.game.config.height;i.length=0;for(var c=0;c0?(h=this.lightPool.pop()).set(t,e,i,a[0],a[1],a[2],r):h=new s(t,e,i,a[0],a[1],a[2],r),this.lights.push(h),h},removeLight:function(t){var e=this.lights.indexOf(t);return e>=0&&(this.lightPool.push(t),this.lights.splice(e,1)),this},shutdown:function(){for(;this.lights.length>0;)this.lightPool.push(this.lights.pop());this.ambientColor={r:.1,g:.1,b:.1},this.culledLights.length=0,this.lights.length=0},destroy:function(){this.shutdown()}});t.exports=a},function(t,e,i){var n=i(0),s=i(44),r=new n({initialize:function(t,e,i,n,s,r,o){this.x=t,this.y=e,this.radius=i,this.r=n,this.g=s,this.b=r,this.intensity=o,this.scrollFactorX=1,this.scrollFactorY=1},set:function(t,e,i,n,s,r,o){return this.x=t,this.y=e,this.radius=i,this.r=n,this.g=s,this.b=r,this.intensity=o,this.scrollFactorX=1,this.scrollFactorY=1,this},setScrollFactor:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.scrollFactorX=t,this.scrollFactorY=e,this},setColor:function(t){var e=s.getFloatsFromUintRGB(t);return this.r=e[0],this.g=e[1],this.b=e[2],this},setIntensity:function(t){return this.intensity=t,this},setPosition:function(t,e){return this.x=t,this.y=e,this},setRadius:function(t){return this.radius=t,this}});t.exports=r},function(t,e){t.exports=function(t){var e=Math.log(t)/.6931471805599453;return 1<0&&e.cameraFilter&r._id)){var h=r.scrollX*e.scrollFactorX,u=r.scrollY*e.scrollFactorY,l=e.x,c=e.y,d=e.scaleX,f=e.scaleY,p=e.rotation,g=e.commandBuffer,v=o||t.currentContext,y=1,m=1,x=0,w=0,b=1,T=0,A=0,S=0;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,v.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,v.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode),v.save(),v.translate(l-h,c-u),v.rotate(p),v.scale(d,f),v.fillStyle="#fff",v.globalAlpha=e.alpha;for(var C=0,M=g.length;C>>16,A=(65280&x)>>>8,S=255&x,v.strokeStyle="rgba("+T+","+A+","+S+","+y+")",v.lineWidth=b,C+=3;break;case n.FILL_STYLE:w=g[C+1],m=g[C+2],T=(16711680&w)>>>16,A=(65280&w)>>>8,S=255&w,v.fillStyle="rgba("+T+","+A+","+S+","+m+")",C+=2;break;case n.BEGIN_PATH:v.beginPath();break;case n.CLOSE_PATH:v.closePath();break;case n.FILL_PATH:a||v.fill();break;case n.STROKE_PATH:a||v.stroke();break;case n.FILL_RECT:a?v.rect(g[C+1],g[C+2],g[C+3],g[C+4]):v.fillRect(g[C+1],g[C+2],g[C+3],g[C+4]),C+=4;break;case n.FILL_TRIANGLE:v.beginPath(),v.moveTo(g[C+1],g[C+2]),v.lineTo(g[C+3],g[C+4]),v.lineTo(g[C+5],g[C+6]),v.closePath(),a||v.fill(),C+=6;break;case n.STROKE_TRIANGLE:v.beginPath(),v.moveTo(g[C+1],g[C+2]),v.lineTo(g[C+3],g[C+4]),v.lineTo(g[C+5],g[C+6]),v.closePath(),a||v.stroke(),C+=6;break;case n.LINE_TO:v.lineTo(g[C+1],g[C+2]),C+=2;break;case n.MOVE_TO:v.moveTo(g[C+1],g[C+2]),C+=2;break;case n.LINE_FX_TO:v.lineTo(g[C+1],g[C+2]),C+=5;break;case n.MOVE_FX_TO:v.moveTo(g[C+1],g[C+2]),C+=5;break;case n.SAVE:v.save();break;case n.RESTORE:v.restore();break;case n.TRANSLATE:v.translate(g[C+1],g[C+2]),C+=2;break;case n.SCALE:v.scale(g[C+1],g[C+2]),C+=2;break;case n.ROTATE:v.rotate(g[C+1]),C+=1}v.restore()}}},function(t,e){t.exports=function(t){var e=t.width/2,i=t.height/2,n=Math.pow(e-i,2)/Math.pow(e+i,2);return Math.PI*(e+i)*(1+3*n/(10+Math.sqrt(4-3*n)))}},function(t,e,i){var n=i(266),s=i(134),r=i(78),o=i(16);t.exports=function(t,e,i,a){void 0===a&&(a=[]),e||(e=n(t)/i);for(var h=0;hy&&(s=y),r>m&&(r=m);var A=y+g-s,S=m+v-r;ou&&(r=u),o>u&&(o=u),a=s,h=r;;)if(a=0&&t<=o.width&&e>=0&&e<=o.height){t+=s.cutX,e+=s.cutY;var a=this._tempContext;a.clearRect(0,0,1,1),a.drawImage(o,t,e,1,1,0,0,1,1);var h=a.getImageData(0,0,1,1);return new r(h.data[0],h.data[1],h.data[2],h.data[3])}}return null},setTexture:function(t,e,i){return this.list[e]&&(t.texture=this.list[e],t.frame=t.texture.get(i)),t},each:function(t,e){for(var i=[null],n=1;n0)&&(!!s.prototype.pause.call(this)&&(this.currentConfig.seek=this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0),this.stopAndReleaseAudioTag(),this.emit("pause",this),!0)))},resume:function(){return!this.manager.isLocked(this,"resume")&&(!(this.startTime>0)&&(!!s.prototype.resume.call(this)&&(!!this.pickAndPlayAudioTag()&&(this.emit("resume",this),!0))))},stop:function(){return!this.manager.isLocked(this,"stop")&&(!!s.prototype.stop.call(this)&&(this.stopAndReleaseAudioTag(),this.emit("stop",this),!0))},pickAndPlayAudioTag:function(){if(!this.pickAudioTag())return this.reset(),!1;var t=this.currentConfig.seek,e=this.currentConfig.delay,i=(this.currentMarker?this.currentMarker.start:0)+t;return this.previousTime=i,this.audio.currentTime=i,this.applyConfig(),0===e?(this.startTime=0,this.audio.paused&&this.playCatchPromise()):(this.startTime=window.performance.now()+1e3*e,this.audio.paused||this.audio.pause()),this.resetConfig(),!0},pickAudioTag:function(){if(this.audio)return!0;for(var t=0;t0)this.startTime=n-this.manager.loopEndOffset?(this.audio.currentTime=i+Math.max(0,s-n),s=this.audio.currentTime):s=n)return this.reset(),this.stopAndReleaseAudioTag(),void this.emit("ended",this);this.previousTime=s}},destroy:function(){s.prototype.destroy.call(this),this.tags=null,this.audio&&this.stopAndReleaseAudioTag()},setMute:function(){this.audio&&(this.audio.muted=this.currentConfig.mute||this.manager.mute)},setVolume:function(){this.audio&&(this.audio.volume=this.currentConfig.volume*this.manager.volume)},setRate:function(){s.prototype.setRate.call(this),this.audio&&(this.audio.playbackRate=this.totalRate)}});Object.defineProperty(r.prototype,"mute",{get:function(){return this.currentConfig.mute},set:function(t){this.currentConfig.mute=t,this.manager.isLocked(this,"mute",t)||(this.setMute(),this.emit("mute",this,t))}}),Object.defineProperty(r.prototype,"volume",{get:function(){return this.currentConfig.volume},set:function(t){this.currentConfig.volume=t,this.manager.isLocked(this,"volume",t)||(this.setVolume(),this.emit("volume",this,t))}}),Object.defineProperty(r.prototype,"rate",{get:function(){return Object.getOwnPropertyDescriptor(s.prototype,"rate").get.call(this)},set:function(t){this.currentConfig.rate=t,this.manager.isLocked(this,"rate",t)||Object.getOwnPropertyDescriptor(s.prototype,"rate").set.call(this,t)}}),Object.defineProperty(r.prototype,"detune",{get:function(){return Object.getOwnPropertyDescriptor(s.prototype,"detune").get.call(this)},set:function(t){this.currentConfig.detune=t,this.manager.isLocked(this,"detune",t)||Object.getOwnPropertyDescriptor(s.prototype,"detune").set.call(this,t)}}),Object.defineProperty(r.prototype,"seek",{get:function(){return this.isPlaying?this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0):this.isPaused?this.currentConfig.seek:0},set:function(t){this.manager.isLocked(this,"seek",t)||this.startTime>0||(this.isPlaying||this.isPaused)&&(t=Math.min(Math.max(0,t),this.duration),this.isPlaying?(this.previousTime=t,this.audio.currentTime=t):this.isPaused&&(this.currentConfig.seek=t),this.emit("seek",this,t))}}),Object.defineProperty(r.prototype,"loop",{get:function(){return this.currentConfig.loop},set:function(t){this.currentConfig.loop=t,this.manager.isLocked(this,"loop",t)||(this.audio&&(this.audio.loop=t),this.emit("loop",this,t))}}),t.exports=r},function(t,e,i){var n=i(99),s=i(0),r=i(281),o=new s({Extends:n,initialize:function(t){this.override=!0,this.audioPlayDelay=.1,this.loopEndOffset=.05,this.onBlurPausedSounds=[],this.locked="ontouchstart"in window,this.lockedActionsQueue=this.locked?[]:null,this._mute=!1,this._volume=1,n.call(this,t)},add:function(t,e){var i=new r(this,t,e);return this.sounds.push(i),i},unlock:function(){var t=this,e=!1,i=function(){e=!0},n=function(){if(t.game.cache.audio.entries.size)if(e)e=!1;else{document.body.removeEventListener("touchmove",i),document.body.removeEventListener("touchend",n);var s=[];t.game.cache.audio.entries.each(function(t,e){for(var i=0;i-1&&(delete this.keys[n],this.scenes.splice(i,1),this._start.indexOf(n)>-1&&(i=this._start.indexOf(n),this._start.splice(i,1)),e.sys.destroy())}return this},bootScene:function(t){var e;t.init&&t.init.call(t,t.sys.settings.data),t.sys.load&&(e=t.sys.load).reset(),e&&t.preload?(t.preload.call(t),0===e.list.size?this.create(t):(t.sys.settings.status=s.LOADING,e.once("complete",this.loadComplete,this),e.start())):this.create(t)},loadComplete:function(t){var e=t.scene;this.create(e)},payloadComplete:function(t){this.bootScene(t.scene)},update:function(t,e){this.processQueue(),this._processing=1;for(var i=this.scenes.length-1;i>=0;i--){var n=this.scenes[i].sys;n.settings.status===s.RUNNING&&n.step(t,e)}},resize:function(t,e){for(var i=0;i=s.LOADING&&i.settings.status0){var i=this.getScene(t);this.scenes.splice(e,1),this.scenes.unshift(i)}}return this},moveDown:function(t){if(this._processing)this._queue.push({op:"moveDown",keyA:t,keyB:null});else{var e=this.getIndex(t);if(e>0){var i=e-1,n=this.getScene(t),s=this.getAt(i);this.scenes[e]=s,this.scenes[i]=n}}return this},moveUp:function(t){if(this._processing)this._queue.push({op:"moveUp",keyA:t,keyB:null});else{var e=this.getIndex(t);if(en&&-1!==i&&-1!==n){var s=this.getAt(n);this.scenes.splice(n,1),this.scenes.splice(i,0,s)}}return this},moveBelow:function(t,e){if(t===e)return this;if(this._processing)this._queue.push({op:"moveBelow",keyA:t,keyB:e});else{var i=this.getIndex(t),n=this.getIndex(e);if(i=0;t--){this.scenes[t].sys.destroy()}this.scenes=[],this._pending=[],this._start=[],this._queue=[],this.game=null}});t.exports=u},function(t,e,i){var n=i(6);t.exports=function(t,e,i,s,r,o,a,h){void 0===h&&(h=new n);var u=Math.sin(-r),l=Math.cos(-r),c=l*o,d=-u*o,f=u*a,p=l*a,g=c*p-d*f,v=p/g,y=-d/g,m=-f/g,x=c/g,w=(f*s-p*i)/g,b=-(c*s-d*i)/g;return h.x=t*v+e*m+w,h.y=t*y+e*x+b,h}},function(t,e,i){var n=new(i(0))({initialize:function(t){this.manager=t,this.capture=!0,this.enabled=!1,this.target,this.handler},boot:function(){var t=this.manager.config;this.enabled=t.inputTouch,this.target=t.inputTouchEventTarget,this.capture=t.inputTouchCapture,this.target||(this.target=this.manager.game.canvas),this.enabled&&this.startListeners()},startListeners:function(){var t,e=this.manager.queue,i=this.target,n={passive:!0},s={passive:!1};this.capture?(t=function(t){t.defaultPrevented||(e.push(t),t.preventDefault())},i.addEventListener("touchstart",t,s),i.addEventListener("touchmove",t,s),i.addEventListener("touchend",t,s)):(t=function(t){t.defaultPrevented||e.push(t)},i.addEventListener("touchstart",t,n),i.addEventListener("touchmove",t,n),i.addEventListener("touchend",t,n)),this.handler=t},stopListeners:function(){var t=this.target;t.removeEventListener("touchstart",this.handler),t.removeEventListener("touchmove",this.handler),t.removeEventListener("touchend",this.handler)},destroy:function(){this.stopListeners(),this.manager=null}});t.exports=n},function(t,e,i){var n=i(0),s=i(6),r=new n({initialize:function(t,e){this.manager=t,this.id=e,this.event,this.camera=null,this.buttons=0,this.position=new s,this.downX=0,this.downY=0,this.downTime=0,this.upX=0,this.upY=0,this.upTime=0,this.primaryDown=!1,this.dragState=0,this.isDown=!1,this.dirty=!1,this.justDown=!1,this.justUp=!1,this.justMoved=!1,this.wasTouch=!1,this.movementX=0,this.movementY=0},positionToCamera:function(t,e){return t.getWorldPoint(this.x,this.y,e)},x:{get:function(){return this.position.x},set:function(t){this.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t}},reset:function(){this.dirty=!1,this.justDown=!1,this.justUp=!1,this.justMoved=!1,this.movementX=0,this.movementY=0},touchmove:function(t){this.event=t,this.x=this.manager.transformX(t.changedTouches[0].pageX),this.y=this.manager.transformY(t.changedTouches[0].pageY),this.justMoved=!0,this.dirty=!0,this.wasTouch=!0},move:function(t){t.buttons&&(this.buttons=t.buttons),this.event=t,this.x=this.manager.transformX(t.pageX),this.y=this.manager.transformY(t.pageY),this.manager.mouse.locked&&(this.movementX+=t.movementX||t.mozMovementX||t.webkitMovementX||0,this.movementY+=t.movementY||t.mozMovementY||t.webkitMovementY||0),this.justMoved=!0,this.dirty=!0,this.wasTouch=!1},down:function(t,e){t.buttons&&(this.buttons=t.buttons),this.event=t,this.x=this.manager.transformX(t.pageX),this.y=this.manager.transformY(t.pageY),0===t.button&&(this.primaryDown=!0,this.downX=this.x,this.downY=this.y,this.downTime=e),this.justDown=!0,this.isDown=!0,this.dirty=!0,this.wasTouch=!1},touchstart:function(t,e){this.buttons=1,this.event=t,this.x=this.manager.transformX(t.changedTouches[0].pageX),this.y=this.manager.transformY(t.changedTouches[0].pageY),this.primaryDown=!0,this.downX=this.x,this.downY=this.y,this.downTime=e,this.justDown=!0,this.isDown=!0,this.dirty=!0,this.wasTouch=!0},up:function(t,e){t.buttons&&(this.buttons=t.buttons),this.event=t,this.x=this.manager.transformX(t.pageX),this.y=this.manager.transformY(t.pageY),0===t.button&&(this.primaryDown=!1,this.upX=this.x,this.upY=this.y,this.upTime=e),this.justUp=!0,this.isDown=!1,this.dirty=!0,this.wasTouch=!1},touchend:function(t,e){this.buttons=0,this.event=t,this.x=this.manager.transformX(t.changedTouches[0].pageX),this.y=this.manager.transformY(t.changedTouches[0].pageY),this.primaryDown=!1,this.upX=this.x,this.upY=this.y,this.upTime=e,this.justUp=!0,this.isDown=!1,this.dirty=!0,this.wasTouch=!0},noButtonDown:function(){return 0===this.buttons},leftButtonDown:function(){return 1&this.buttons},rightButtonDown:function(){return 2&this.buttons},middleButtonDown:function(){return 4&this.buttons},backButtonDown:function(){return 8&this.buttons},forwardButtonDown:function(){return 16&this.buttons},destroy:function(){this.camera=null,this.manager=null,this.position=null}});t.exports=r},function(t,e,i){var n=i(0),s=i(146),r=new n({initialize:function(t){this.manager=t,this.capture=!0,this.enabled=!1,this.target,this.handler,this.locked=!1},boot:function(){var t=this.manager.config;this.enabled=t.inputMouse,this.target=t.inputMouseEventTarget,this.capture=t.inputMouseCapture,this.target||(this.target=this.manager.game.canvas),t.disableContextMenu&&this.disableContextMenu(),this.enabled&&this.startListeners()},disableContextMenu:function(){return document.body.addEventListener("contextmenu",function(t){return t.preventDefault(),!1}),this},requestPointerLock:function(){if(s.pointerLock){var t=this.target;t.requestPointerLock=t.requestPointerLock||t.mozRequestPointerLock||t.webkitRequestPointerLock,t.requestPointerLock()}},pointerLockChange:function(t){var e=this.target;this.locked=document.pointerLockElement===e||document.mozPointerLockElement===e||document.webkitPointerLockElement===e,this.manager.queue.push(t)},releasePointerLock:function(){s.pointerLock&&(document.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock,document.exitPointerLock())},startListeners:function(){var t,e=this.manager.queue,i=this.target,n={passive:!0},r={passive:!1};this.capture?(t=function(t){t.defaultPrevented||(e.push(t),t.preventDefault())},i.addEventListener("mousemove",t,r),i.addEventListener("mousedown",t,r),i.addEventListener("mouseup",t,r)):(t=function(t){t.defaultPrevented||e.push(t)},i.addEventListener("mousemove",t,n),i.addEventListener("mousedown",t,n),i.addEventListener("mouseup",t,n)),this.handler=t,s.pointerLock&&(this.pointerLockChange=this.pointerLockChange.bind(this),document.addEventListener("pointerlockchange",this.pointerLockChange,!0),document.addEventListener("mozpointerlockchange",this.pointerLockChange,!0),document.addEventListener("webkitpointerlockchange",this.pointerLockChange,!0))},stopListeners:function(){var t=this.target;t.removeEventListener("mousemove",this.handler),t.removeEventListener("mousedown",this.handler),t.removeEventListener("mouseup",this.handler),s.pointerLock&&(document.removeEventListener("pointerlockchange",this.pointerLockChange,!0),document.removeEventListener("mozpointerlockchange",this.pointerLockChange,!0),document.removeEventListener("webkitpointerlockchange",this.pointerLockChange,!0))},destroy:function(){this.stopListeners(),this.manager=null}});t.exports=r},function(t,e,i){var n=i(0),s=i(2),r=i(803),o=i(801),a=new n({initialize:function(t,e,i){if(void 0===i&&(i={}),e.length<2)return!1;this.manager=t,this.enabled=!0,this.keyCodes=[];for(var n=0;n=this.threshold?this.pressed||(this.pressed=!0,this.events.emit("down",this.pad,this,this.value,t)):this.pressed&&(this.pressed=!1,this.events.emit("up",this.pad,this,this.value,t))}});t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.pad=t,this.events=t.events,this.index=e,this.value=0,this.threshold=.05},update:function(t){this.value=t},getValue:function(){var t=(Math.abs(this.value)-this.threshold)/(1-this.threshold);return t<0&&(t=0),t*(this.value>0?1:-1)}});t.exports=n},function(t,e,i){var n=i(296),s=i(295),r=new(i(0))({initialize:function(t,e,i){this.manager=t,this.events=t.events,this.id=e,this.index=i,this.connected=!0,this.timestamp=0,this.buttons=[],this.axes=[]},update:function(t){var e;this.timestamp=t.timestamp,this.connected=t.connected;var i=this.axes,r=this.buttons;for(e=0;e=n.x&&e>=n.y&&t<=n.x+o&&e<=n.y+a))return s;n.getWorldPoint(t,e,r);for(var h=n.cull(i),u={x:0,y:0},l=this.game.config.resolution,d=0;d80*i){n=h=t[0],a=u=t[1];for(var w=i;wh&&(h=l),f>u&&(u=f);g=Math.max(h-n,u-a)}return o(m,x,i,n,a,g),x}function s(t,e,i,n,s){var r,o;if(s===C(t,e,i,n)>0)for(r=e;r=e;r-=n)o=T(r,t[r],t[r+1],o);return o&&m(o,o.next)&&(A(o),o=o.next),o}function r(t,e){if(!t)return t;e||(e=t);var i,n=t;do{if(i=!1,n.steiner||!m(n,n.next)&&0!==y(n.prev,n,n.next))n=n.next;else{if(A(n),(n=e=n.prev)===n.next)return null;i=!0}}while(i||n!==e);return e}function o(t,e,i,n,s,c,d){if(t){!d&&c&&function(t,e,i,n){var s=t;do{null===s.z&&(s.z=f(s.x,s.y,e,i,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){var e,i,n,s,r,o,a,h,u=1;do{for(i=t,t=null,r=null,o=0;i;){for(o++,n=i,a=0,e=0;e0||h>0&&n;)0!==a&&(0===h||!n||i.z<=n.z)?(s=i,i=i.nextZ,a--):(s=n,n=n.nextZ,h--),r?r.nextZ=s:t=s,s.prevZ=r,r=s;i=n}r.nextZ=null,u*=2}while(o>1)}(s)}(t,n,s,c);for(var p,g,v=t;t.prev!==t.next;)if(p=t.prev,g=t.next,c?h(t,n,s,c):a(t))e.push(p.i/i),e.push(t.i/i),e.push(g.i/i),A(t),t=g.next,v=g.next;else if((t=g)===v){d?1===d?o(t=u(t,e,i),e,i,n,s,c,2):2===d&&l(t,e,i,n,s,c):o(r(t),e,i,n,s,c,1);break}}}function a(t){var e=t.prev,i=t,n=t.next;if(y(e,i,n)>=0)return!1;for(var s=t.next.next;s!==t.prev;){if(g(e.x,e.y,i.x,i.y,n.x,n.y,s.x,s.y)&&y(s.prev,s,s.next)>=0)return!1;s=s.next}return!0}function h(t,e,i,n){var s=t.prev,r=t,o=t.next;if(y(s,r,o)>=0)return!1;for(var a=s.xr.x?s.x>o.x?s.x:o.x:r.x>o.x?r.x:o.x,l=s.y>r.y?s.y>o.y?s.y:o.y:r.y>o.y?r.y:o.y,c=f(a,h,e,i,n),d=f(u,l,e,i,n),p=t.nextZ;p&&p.z<=d;){if(p!==t.prev&&p!==t.next&&g(s.x,s.y,r.x,r.y,o.x,o.y,p.x,p.y)&&y(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=t.prevZ;p&&p.z>=c;){if(p!==t.prev&&p!==t.next&&g(s.x,s.y,r.x,r.y,o.x,o.y,p.x,p.y)&&y(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}function u(t,e,i){var n=t;do{var s=n.prev,r=n.next.next;!m(s,r)&&x(s,n,n.next,r)&&w(s,r)&&w(r,s)&&(e.push(s.i/i),e.push(n.i/i),e.push(r.i/i),A(n),A(n.next),n=t=r),n=n.next}while(n!==t);return n}function l(t,e,i,n,s,a){var h=t;do{for(var u=h.next.next;u!==h.prev;){if(h.i!==u.i&&v(h,u)){var l=b(h,u);return h=r(h,h.next),l=r(l,l.next),o(h,e,i,n,s,a),void o(l,e,i,n,s,a)}u=u.next}h=h.next}while(h!==t)}function c(t,e){return t.x-e.x}function d(t,e){if(e=function(t,e){var i,n=e,s=t.x,r=t.y,o=-1/0;do{if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){var a=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(a<=s&&a>o){if(o=a,a===s){if(r===n.y)return n;if(r===n.next.y)return n.next}i=n.x=n.x&&n.x>=l&&s!==n.x&&g(ri.x)&&w(n,t)&&(i=n,d=h),n=n.next;return i}(t,e)){var i=b(e,t);r(i,i.next)}}function f(t,e,i,n,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)/s)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)/s)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function p(t){var e=t,i=t;do{e.x=0&&(t-o)*(n-a)-(i-o)*(e-a)>=0&&(i-o)*(r-a)-(s-o)*(n-a)>=0}function v(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&x(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&w(t,e)&&w(e,t)&&function(t,e){var i=t,n=!1,s=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&i.next.y!==i.y&&s<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)}function y(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function m(t,e){return t.x===e.x&&t.y===e.y}function x(t,e,i,n){return!!(m(t,e)&&m(i,n)||m(t,n)&&m(i,e))||y(t,e,i)>0!=y(t,e,n)>0&&y(i,n,t)>0!=y(i,n,e)>0}function w(t,e){return y(t.prev,t,t.next)<0?y(t,e,t.next)>=0&&y(t,t.prev,e)>=0:y(t,e,t.prev)<0||y(t,t.next,e)<0}function b(t,e){var i=new S(t.i,t.x,t.y),n=new S(e.i,e.x,e.y),s=t.next,r=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,n.next=i,i.prev=n,r.next=n,n.prev=r,n}function T(t,e,i,n){var s=new S(t,e,i);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function A(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function S(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function C(t,e,i,n){for(var s=0,r=e,o=i-n;r0&&(n+=t[s-1].length,i.holes.push(n))}return i}},function(t,e,i){var n,s,r,o=i(23),a={supportInverseAlpha:!1,supportNewBlendModes:!1};t.exports=(void 0!==document&&(a.supportNewBlendModes=(n="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/",s="AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==",(r=new Image).onload=function(){var t=new Image;t.onload=function(){var e=o.create(t,6,1).getContext("2d");if(e.globalCompositeOperation="multiply",e.drawImage(r,0,0),e.drawImage(t,2,0),!e.getImageData(2,0,1,1))return!1;var i=e.getImageData(2,0,1,1).data;o.remove(t),a.supportNewBlendModes=255===i[0]&&0===i[1]&&0===i[2]},t.src=n+"/wCKxvRF"+s},r.src=n+"AP804Oa6"+s,!1),a.supportInverseAlpha=function(){var t=o.create(this,2,1).getContext("2d");t.fillStyle="rgba(10, 20, 30, 0.5)",t.fillRect(0,0,1,1);var e=t.getImageData(0,0,1,1);if(null===e)return!1;t.putImageData(e,1,0);var i=t.getImageData(1,0,1,1);return i.data[0]===e.data[0]&&i.data[1]===e.data[1]&&i.data[2]===e.data[2]&&i.data[3]===e.data[3]}()),a)},function(t,e){t.exports={Global:["anims","cache","registry","sound","textures"],CoreScene:["EventEmitter","CameraManager","GameObjectCreator","GameObjectFactory","ScenePlugin","DisplayList","UpdateList"],DefaultScene:["CameraManager3D","Clock","DataManagerPlugin","InputPlugin","Loader","TweenManager","LightsPlugin"]}},function(t,e,i){var n=i(0),s=i(3),r=new n({initialize:function(){this.isRunning=!1,this.callback=s,this.tick=0,this.isSetTimeOut=!1,this.timeOutID=null,this.lastTime=0;var t=this;this.step=function e(i){t.lastTime=t.tick,t.tick=i,t.callback(i),t.timeOutID=window.requestAnimationFrame(e)},this.stepTimeout=function e(){var i=Date.now(),n=Math.max(16+t.lastTime-i,0);t.lastTime=t.tick,t.tick=i,t.callback(i),t.timeOutID=window.setTimeout(e,n)}},start:function(t,e){this.isRunning||(this.callback=t,this.isSetTimeOut=e,this.isRunning=!0,this.timeOutID=e?window.setTimeout(this.stepTimeout,0):window.requestAnimationFrame(this.step))},stop:function(){this.isRunning=!1,this.isSetTimeOut?clearTimeout(this.timeOutID):window.cancelAnimationFrame(this.timeOutID)},destroy:function(){this.stop(),this.callback=s}});t.exports=r},function(t,e){t.exports=function(t){t.parentNode&&t.parentNode.removeChild(t)}},function(t,e){t.exports=function(t){var e="";try{window.DOMParser?e=(new DOMParser).parseFromString(t,"text/xml"):(e=new ActiveXObject("Microsoft.XMLDOM")).loadXML(t)}catch(t){e=null}return e&&e.documentElement&&!e.getElementsByTagName("parsererror").length?e:null}},function(t,e,i){var n=i(76);t.exports=function(t){if("complete"!==document.readyState&&"interactive"!==document.readyState){var e=function(){document.removeEventListener("deviceready",e,!0),document.removeEventListener("DOMContentLoaded",e,!0),window.removeEventListener("load",e,!0),t()};document.body?n.cordova&&!n.cocoonJS?document.addEventListener("deviceready",e,!1):(document.addEventListener("DOMContentLoaded",e,!0),window.addEventListener("load",e,!0)):window.setTimeout(e,20)}else t()}},function(t,e){t.exports=function(t,e){return Math.floor(Math.random()*(e-t+1)+t)}},function(t,e,i){var n=i(155);t.exports=function(t,e,i){void 0===e&&(e=1),void 0===i&&(i=1);var s=Math.floor(6*t),r=6*t-s,o=Math.floor(i*(1-e)*255),a=Math.floor(i*(1-r*e)*255),h=Math.floor(i*(1-(1-r)*e)*255),u={r:i=Math.floor(i*=255),g:i,b:i,color:0},l=s%6;return 0===l?(u.g=h,u.b=o):1===l?(u.r=a,u.b=o):2===l?(u.r=o,u.b=h):3===l?(u.r=o,u.g=a):4===l?(u.r=h,u.g=o):5===l&&(u.g=o,u.b=a),u.color=n(u.r,u.g,u.b),u}},function(t,e,i){(function(t){t.export=function(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}}).call(this,i(831)(t))},function(t,e){t.exports=function(t){var e=t.toString(16);return 1===e.length?"0"+e:e}},function(t,e,i){var n=i(41);n.ColorToRGBA=i(833),n.ComponentToHex=i(311),n.GetColor=i(155),n.GetColor32=i(335),n.HexStringToColor=i(336),n.HSLToColor=i(832),n.HSVColorWheel=i(830),n.HSVToRGB=i(309),n.HueToComponent=i(310),n.IntegerToColor=i(334),n.IntegerToRGB=i(333),n.Interpolate=i(829),n.ObjectToColor=i(332),n.RandomRGB=i(828),n.RGBStringToColor=i(331),n.RGBToHSV=i(827),n.RGBToString=i(826),n.ValueToColor=i(156),t.exports=n},function(t,e){t.exports={setCrisp:function(t){return["optimizeSpeed","crisp-edges","-moz-crisp-edges","-webkit-optimize-contrast","optimize-contrast","pixelated"].forEach(function(e){t.style["image-rendering"]=e}),t.style.msInterpolationMode="nearest-neighbor",t},setBicubic:function(t){return t.style["image-rendering"]="auto",t.style.msInterpolationMode="bicubic",t}}},function(t,e,i){var n=i(149),s=i(0),r=i(56),o=i(6),a=new s({Extends:r,initialize:function(t){void 0===t&&(t=[]),r.call(this,"SplineCurve"),this.points=[],this.addPoints(t)},addPoints:function(t){for(var e=0;ei.length-2?i.length-1:r+1],c=i[r>i.length-3?i.length-1:r+2];return e.set(n(a,h.x,u.x,l.x,c.x),n(a,h.y,u.y,l.y,c.y))},toJSON:function(){for(var t=[],e=0;ei;)n-=i;n0&&(s=1/Math.sqrt(s),this.x=t*s,this.y=e*s,this.z=i*s,this.w=n*s),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z,r=this.w;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this.w=r+e*(t.w-r),this},rotationTo:function(t,e){var i=t.x*e.x+t.y*e.y+t.z*e.z;return i<-.999999?(l.copy(h).cross(t).length()<1e-6&&l.copy(u).cross(t),l.normalize(),this.setAxisAngle(l,Math.PI)):i>.999999?(this.x=0,this.y=0,this.z=0,this.w=1,this):(l.copy(t).cross(e),this.x=l.x,this.y=l.y,this.z=l.z,this.w=1+i,this.normalize())},setAxes:function(t,e,i){var n=c.val;return n[0]=e.x,n[3]=e.y,n[6]=e.z,n[1]=i.x,n[4]=i.y,n[7]=i.z,n[2]=-t.x,n[5]=-t.y,n[8]=-t.z,this.fromMat3(c).normalize()},identity:function(){return this.x=0,this.y=0,this.z=0,this.w=1,this},setAxisAngle:function(t,e){e*=.5;var i=Math.sin(e);return this.x=i*t.x,this.y=i*t.y,this.z=i*t.z,this.w=Math.cos(e),this},multiply:function(t){var e=this.x,i=this.y,n=this.z,s=this.w,r=t.x,o=t.y,a=t.z,h=t.w;return this.x=e*h+s*r+i*a-n*o,this.y=i*h+s*o+n*r-e*a,this.z=n*h+s*a+e*o-i*r,this.w=s*h-e*r-i*o-n*a,this},slerp:function(t,e){var i=this.x,n=this.y,s=this.z,r=this.w,o=t.x,a=t.y,h=t.z,u=t.w,l=i*o+n*a+s*h+r*u;l<0&&(l=-l,o=-o,a=-a,h=-h,u=-u);var c=1-e,d=e;if(1-l>1e-6){var f=Math.acos(l),p=Math.sin(f);c=Math.sin((1-e)*f)/p,d=Math.sin(e*f)/p}return this.x=c*i+d*o,this.y=c*n+d*a,this.z=c*s+d*h,this.w=c*r+d*u,this},invert:function(){var t=this.x,e=this.y,i=this.z,n=this.w,s=t*t+e*e+i*i+n*n,r=s?1/s:0;return this.x=-t*r,this.y=-e*r,this.z=-i*r,this.w=n*r,this},conjugate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},rotateX:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o+s*r,this.y=i*o+n*r,this.z=n*o-i*r,this.w=s*o-e*r,this},rotateY:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o-n*r,this.y=i*o+s*r,this.z=n*o+e*r,this.w=s*o-i*r,this},rotateZ:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o+i*r,this.y=i*o-e*r,this.z=n*o+s*r,this.w=s*o-n*r,this},calculateW:function(){var t=this.x,e=this.y,i=this.z;return this.w=-Math.sqrt(Math.abs(1-t*t-e*e-i*i)),this},fromMat3:function(t){var e,i=t.val,n=i[0]+i[4]+i[8];if(n>0)e=Math.sqrt(n+1),this.w=.5*e,e=.5/e,this.x=(i[7]-i[5])*e,this.y=(i[2]-i[6])*e,this.z=(i[3]-i[1])*e;else{var s=0;i[4]>i[0]&&(s=1),i[8]>i[3*s+s]&&(s=2);var r=o[s],h=o[r];e=Math.sqrt(i[3*s+s]-i[3*r+r]-i[3*h+h]+1),a[s]=.5*e,e=.5/e,a[r]=(i[3*r+s]+i[3*s+r])*e,a[h]=(i[3*h+s]+i[3*s+h])*e,this.x=a[0],this.y=a[1],this.z=a[2],this.w=(i[3*h+r]-i[3*r+h])*e}return this}});t.exports=d},function(t,e,i){var n=i(57),s=i(153),r=i(327),o=new s,a=new r,h=new n;t.exports=function(t,e,i){return a.setAxisAngle(e,i),o.fromRotationTranslation(a,h.set(0,0,0)),t.transformMat4(o)}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1),t.x=(2*Math.random()-1)*e,t.y=(2*Math.random()-1)*e,t.z=(2*Math.random()-1)*e,t.w=(2*Math.random()-1)*e,t}},function(t,e){t.exports=function(t,e){void 0===e&&(e=1);var i=2*Math.random()*Math.PI,n=2*Math.random()-1,s=Math.sqrt(1-n*n)*e;return t.x=Math.cos(i)*s,t.y=Math.sin(i)*s,t.z=n*e,t}},function(t,e,i){var n=i(41);t.exports=function(t){var e=new n,i=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(t.toLowerCase());if(i){var s=parseInt(i[1],10),r=parseInt(i[2],10),o=parseInt(i[3],10),a=void 0!==i[4]?parseFloat(i[4]):1;e.setTo(s,r,o,255*a)}return e}},function(t,e,i){var n=i(41);t.exports=function(t){return new n(t.r,t.g,t.b,t.a)}},function(t,e){t.exports=function(t){return t>16777215?{a:t>>>24,r:t>>16&255,g:t>>8&255,b:255&t}:{a:255,r:t>>16&255,g:t>>8&255,b:255&t}}},function(t,e,i){var n=i(41),s=i(333);t.exports=function(t){var e=s(t);return new n(e.r,e.g,e.b,e.a)}},function(t,e){t.exports=function(t,e,i,n){return n<<24|t<<16|e<<8|i}},function(t,e,i){var n=i(41);t.exports=function(t){var e=new n;t=t.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i,function(t,e,i,n){return e+e+i+i+n+n});var i=/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);if(i){var s=parseInt(i[1],16),r=parseInt(i[2],16),o=parseInt(i[3],16);e.setTo(s,r,o)}return e}},function(t,e,i){var n=i(338),s=new(i(0))({initialize:function(t){this.game=t,this.binary=new n,this.bitmapFont=new n,this.json=new n,this.physics=new n,this.shader=new n,this.audio=new n,this.text=new n,this.obj=new n,this.tilemap=new n,this.xml=new n,this.custom={},this.game.events.once("destroy",this.destroy,this)},addCustom:function(t){return this.custom.hasOwnProperty(t)||(this.custom[t]=new n),this.custom[t]},destroy:function(){for(var t=["binary","bitmapFont","json","physics","shader","audio","text","obj","tilemap","xml"],e=0;e0){if(0===t)this.frames=i.concat(this.frames);else if(t===this.frames.length)this.frames=this.frames.concat(i);else{var n=this.frames.slice(0,t),s=this.frames.slice(t);this.frames=n.concat(i,s)}this.updateFrameSequence()}return this},checkFrame:function(t){return t0){o.isLast=!0,o.nextFrame=u[0],u[0].prevFrame=o;var v=1/(u.length-1);for(a=0;a=this.frames.length&&(e=0),t.currentAnim!==this&&(t.currentAnim=this,t._timeScale=1,t.frameRate=this.frameRate,t.duration=this.duration,t.msPerFrame=this.msPerFrame,t.skipMissedFrames=this.skipMissedFrames,t._delay=this.delay,t._repeat=this.repeat,t._repeatDelay=this.repeatDelay,t._yoyo=this.yoyo,t._callbackArgs[1]=this,t._updateParams=t._callbackArgs.concat(this.onUpdateParams)),t.updateFrame(this.frames[e])},nextFrame:function(t){var e=t.currentFrame;e.isLast?this.yoyo?(t.forward=!1,t.updateFrame(e.prevFrame),this.getNextTick(t)):t.repeatCounter>0?this.repeatAnimation(t):this.completeAnimation(t):(t.updateFrame(e.nextFrame),this.getNextTick(t))},previousFrame:function(t){var e=t.currentFrame;e.isFirst?t.repeatCounter>0?this.repeatAnimation(t):this.completeAnimation(t):(t.updateFrame(e.prevFrame),this.getNextTick(t))},removeFrame:function(t){var e=this.frames.indexOf(t);return-1!==e&&this.removeFrameAt(e),this},removeFrameAt:function(t){return this.frames.splice(t,1),this.updateFrameSequence(),this},repeatAnimation:function(t){t._repeatDelay>0&&!1===t.pendingRepeat?(t.pendingRepeat=!0,t.accumulator-=t.nextTick,t.nextTick+=1e3*t._repeatDelay):(t.repeatCounter--,t.forward=!0,t.updateFrame(t.currentFrame.nextFrame),this.getNextTick(t),t.pendingRepeat=!1,this.onRepeat&&this.onRepeat.apply(this.callbackScope,t._callbackArgs.concat(this.onRepeatParams)))},setFrame:function(t){t.forward?this.nextFrame(t):this.previousFrame(t)},toJSON:function(){var t={key:this.key,type:this.type,frames:[],frameRate:this.frameRate,duration:this.duration,skipMissedFrames:this.skipMissedFrames,delay:this.delay,repeat:this.repeat,repeatDelay:this.repeatDelay,yoyo:this.yoyo,showOnStart:this.showOnStart,hideOnComplete:this.hideOnComplete};return this.frames.forEach(function(e){t.frames.push(e.toJSON())}),t},updateFrameSequence:function(){for(var t=this.frames.length,e=1/(t-1),i=0;i1&&(n.prevFrame=this.frames[i-1],n.nextFrame=this.frames[i+1])}return this},pause:function(){return this.paused=!0,this},resume:function(){return this.paused=!1,this},destroy:function(){}});t.exports=o},function(t,e){t.exports=function(t,e,i){return(t=Math.max(0,Math.min(1,(t-e)/(i-e))))*t*(3-2*t)}},function(t,e){t.exports=function(t,e,i){return(t=Math.max(0,Math.min(1,(t-e)/(i-e))))*t*t*(t*(6*t-15)+10)}},function(t,e){t.exports=function(t,e,i){void 0===e&&(e=1),void 0===i&&(i=[]);var n=Math.round(t.x1),s=Math.round(t.y1),r=Math.round(t.x2),o=Math.round(t.y2),a=Math.abs(r-n),h=Math.abs(o-s),u=n-h&&(c-=h,n+=u),f=t.right&&(h=1,a+=o-t.right,o=t.right);break;case 1:(a+=e)>=t.bottom&&(h=2,o-=a-t.bottom,a=t.bottom);break;case 2:(o-=e)<=t.left&&(h=3,a-=t.left-o,o=t.left);break;case 3:(a-=e)<=t.top&&(h=0,a=t.top)}return r}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===s&&(s=0),void 0===r&&(r=0),this.matrix=new Float32Array([t,e,i,n,s,r,0,0,1]),this.decomposedMatrix={translateX:0,translateY:0,scaleX:1,scaleY:1,rotation:0}},loadIdentity:function(){var t=this.matrix;return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,this},translate:function(t,e){var i=this.matrix;return i[4]=i[0]*t+i[2]*e+i[4],i[5]=i[1]*t+i[3]*e+i[5],this},scale:function(t,e){var i=this.matrix;return i[0]*=t,i[1]*=t,i[2]*=e,i[3]*=e,this},rotate:function(t){var e=Math.sin(t),i=Math.cos(t);return this.transform(i,e,-e,i,0,0)},multiply:function(t){var e=this.matrix,i=t.matrix,n=e[0],s=e[1],r=e[2],o=e[3],a=e[4],h=e[5],u=i[0],l=i[1],c=i[2],d=i[3],f=i[4],p=i[5];return e[0]=u*n+l*r,e[1]=u*s+l*o,e[2]=c*n+d*r,e[3]=c*s+d*o,e[4]=f*n+p*r+a,e[5]=f*s+p*o+h,this},transform:function(t,e,i,n,s,r){var o=this.matrix,a=o[0],h=o[1],u=o[2],l=o[3],c=o[4],d=o[5];return o[0]=t*a+e*u,o[1]=t*h+e*l,o[2]=i*a+n*u,o[3]=i*h+n*l,o[4]=s*a+r*u+c,o[5]=s*h+r*l+d,this},transformPoint:function(t,e,i){void 0===i&&(i={x:0,y:0});var n=this.matrix,s=n[0],r=n[1],o=n[2],a=n[3],h=n[4],u=n[5];return i.x=t*s+e*o+h,i.y=t*r+e*a+u,i},invert:function(){var t=this.matrix,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=e*s-i*n;return t[0]=s/a,t[1]=-i/a,t[2]=-n/a,t[3]=e/a,t[4]=(n*o-s*r)/a,t[5]=-(e*o-i*r)/a,this},setTransform:function(t,e,i,n,s,r){var o=this.matrix;return o[0]=t,o[1]=e,o[2]=i,o[3]=n,o[4]=s,o[5]=r,this},decomposeMatrix:function(){var t=this.decomposedMatrix,e=this.matrix,i=e[0],n=e[1],s=e[2],r=e[3],o=i*i,a=n*n,h=s*s,u=r*r,l=Math.sqrt(o+h),c=Math.sqrt(a+u);return t.translateX=e[4],t.translateY=e[5],t.scaleX=l,t.scaleY=c,t.rotation=Math.acos(i/l)*(Math.atan(-s/i)<0?-1:1),t},applyITRS:function(t,e,i,n,s){var r=this.matrix,o=Math.sin(i),a=Math.cos(i);return r[4]=t,r[5]=e,r[0]=a*n,r[1]=-o*n,r[2]=o*s,r[3]=a*s,this}});t.exports=n},function(t,e){t.exports={defaultPipeline:null,pipeline:null,initPipeline:function(t){var e=this.scene.sys.game.renderer;return!!(e&&e.gl&&e.hasPipeline(t))&&(this.defaultPipeline=e.getPipeline(t),this.pipeline=this.defaultPipeline,!0)},setPipeline:function(t){var e=this.scene.sys.game.renderer;return!!(e&&e.gl&&e.hasPipeline(t))&&(this.pipeline=e.getPipeline(t),!0)},resetPipeline:function(){return this.pipeline=this.defaultPipeline,null!==this.pipeline},getPipelineName:function(){return this.pipeline.name}}},function(t,e){t.exports=function(t,e,i,n){var s=Math.cos(n),r=Math.sin(n),o=t.x-e,a=t.y-i;return t.x=o*s-a*r+e,t.y=o*r+a*s+i,t}},function(t,e,i){var n=i(4);t.exports=function(t,e,i){return void 0===i&&(i=new n),i.x=t.x1+(t.x2-t.x1)*e,i.y=t.y1+(t.y2-t.y1)*e,i}},function(t,e,i){var n=i(166),s=i(105);t.exports=function(t,e,i,r){void 0===r&&(r=[]),e||(e=s(t)/i);for(var o=0;othis.vertexCapacity&&this.flush();var x=this.vertexViewF32,w=this.vertexViewU32,b=this.vertexCount*this.vertexComponentCount,T=r+a,A=o+h,S=m[0],C=m[1],M=m[2],E=m[3],_=d*S+f*M,L=d*C+f*E,P=p*S+g*M,F=p*C+g*E,k=v*S+y*M+m[4],R=v*C+y*E+m[5],O=r*_+o*P+k,D=r*L+o*F+R,I=r*_+A*P+k,B=r*L+A*F+R,Y=T*_+A*P+k,X=T*L+A*F+R,z=T*_+o*P+k,N=T*L+o*F+R,G=u.getTintAppendFloatAlphaAndSwap(l,c);x[b+0]=O,x[b+1]=D,w[b+2]=G,x[b+3]=I,x[b+4]=B,w[b+5]=G,x[b+6]=Y,x[b+7]=X,w[b+8]=G,x[b+9]=O,x[b+10]=D,w[b+11]=G,x[b+12]=Y,x[b+13]=X,w[b+14]=G,x[b+15]=z,x[b+16]=N,w[b+17]=G,this.vertexCount+=6},batchFillTriangle:function(t,e,i,n,s,r,o,a,h,l,c,d,f,p,g,v,y,m,x,w){this.renderer.setPipeline(this),this.vertexCount+3>this.vertexCapacity&&this.flush();var b=this.vertexViewF32,T=this.vertexViewU32,A=this.vertexCount*this.vertexComponentCount,S=w[0],C=w[1],M=w[2],E=w[3],_=p*S+g*M,L=p*C+g*E,P=v*S+y*M,F=v*C+y*E,k=m*S+x*M+w[4],R=m*C+x*E+w[5],O=r*_+o*P+k,D=r*L+o*F+R,I=a*_+h*P+k,B=a*L+h*F+R,Y=l*_+c*P+k,X=l*L+c*F+R,z=u.getTintAppendFloatAlphaAndSwap(d,f);b[A+0]=O,b[A+1]=D,T[A+2]=z,b[A+3]=I,b[A+4]=B,T[A+5]=z,b[A+6]=Y,b[A+7]=X,T[A+8]=z,this.vertexCount+=3},batchStrokeTriangle:function(t,e,i,n,s,r,o,a,h,u,l,c,d,f,p,g,v,y,m,x,w){var b=this.tempTriangle;b[0].x=r,b[0].y=o,b[0].width=c,b[0].rgb=d,b[0].alpha=f,b[1].x=a,b[1].y=h,b[1].width=c,b[1].rgb=d,b[1].alpha=f,b[2].x=u,b[2].y=l,b[2].width=c,b[2].rgb=d,b[2].alpha=f,b[3].x=r,b[3].y=o,b[3].width=c,b[3].rgb=d,b[3].alpha=f,this.batchStrokePath(t,e,i,n,s,b,c,d,f,p,g,v,y,m,x,!1,w)},batchFillPath:function(t,e,i,n,s,o,a,h,l,c,d,f,p,g,v){this.renderer.setPipeline(this);for(var y,m,x,w,b,T,A,S,C,M,E,_,L,P,F,k,R,O=o.length,D=this.polygonCache,I=this.vertexViewF32,B=this.vertexViewU32,Y=0,X=v[0],z=v[1],N=v[2],G=v[3],W=l*X+c*N,U=l*z+c*G,V=d*X+f*N,H=d*z+f*G,j=p*X+g*N+v[4],q=p*z+g*G+v[5],K=u.getTintAppendFloatAlphaAndSwap(a,h),J=0;Jthis.vertexCapacity&&this.flush(),Y=this.vertexCount*this.vertexComponentCount,_=(T=D[x+0])*W+(A=D[x+1])*V+j,L=T*U+A*H+q,P=(S=D[w+0])*W+(C=D[w+1])*V+j,F=S*U+C*H+q,k=(M=D[b+0])*W+(E=D[b+1])*V+j,R=M*U+E*H+q,I[Y+0]=_,I[Y+1]=L,B[Y+2]=K,I[Y+3]=P,I[Y+4]=F,B[Y+5]=K,I[Y+6]=k,I[Y+7]=R,B[Y+8]=K,this.vertexCount+=3;D.length=0},batchStrokePath:function(t,e,i,n,s,r,o,a,h,l,c,d,f,p,g,v,y){var m,x;this.renderer.setPipeline(this);for(var w,b,T,A,S=r.length,C=this.polygonCache,M=this.vertexViewF32,E=this.vertexViewU32,_=u.getTintAppendFloatAlphaAndSwap,L=0;L+1this.vertexCapacity&&this.flush(),w=C[P-1]||C[F-1],b=C[P],M[(T=this.vertexCount*this.vertexComponentCount)+0]=w[6],M[T+1]=w[7],E[T+2]=_(w[8],h),M[T+3]=w[0],M[T+4]=w[1],E[T+5]=_(w[2],h),M[T+6]=b[9],M[T+7]=b[10],E[T+8]=_(b[11],h),M[T+9]=w[0],M[T+10]=w[1],E[T+11]=_(w[2],h),M[T+12]=w[6],M[T+13]=w[7],E[T+14]=_(w[8],h),M[T+15]=b[3],M[T+16]=b[4],E[T+17]=_(b[5],h),this.vertexCount+=6;C.length=0},batchLine:function(t,e,i,n,s,r,o,a,h,l,c,d,f,p,g,v,y,m,x,w,b){this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var T=b[0],A=b[1],S=b[2],C=b[3],M=g*T+v*S,E=g*A+v*C,_=y*T+m*S,L=y*A+m*C,P=x*T+w*S+b[4],F=x*A+w*C+b[5],k=this.vertexViewF32,R=this.vertexViewU32,O=a-r,D=h-o,I=Math.sqrt(O*O+D*D),B=l*(h-o)/I,Y=l*(r-a)/I,X=c*(h-o)/I,z=c*(r-a)/I,N=a-X,G=h-z,W=r-B,U=o-Y,V=a+X,H=h+z,j=r+B,q=o+Y,K=N*M+G*_+P,J=N*E+G*L+F,Z=W*M+U*_+P,Q=W*E+U*L+F,$=V*M+H*_+P,tt=V*E+H*L+F,et=j*M+q*_+P,it=j*E+q*L+F,nt=u.getTintAppendFloatAlphaAndSwap,st=nt(d,p),rt=nt(f,p),ot=this.vertexCount*this.vertexComponentCount;return k[ot+0]=K,k[ot+1]=J,R[ot+2]=rt,k[ot+3]=Z,k[ot+4]=Q,R[ot+5]=st,k[ot+6]=$,k[ot+7]=tt,R[ot+8]=rt,k[ot+9]=Z,k[ot+10]=Q,R[ot+11]=st,k[ot+12]=et,k[ot+13]=it,R[ot+14]=st,k[ot+15]=$,k[ot+16]=tt,R[ot+17]=rt,this.vertexCount+=6,[K,J,f,Z,Q,d,$,tt,f,et,it,d]},batchGraphics:function(t,e){if(!(t.commandBuffer.length<=0)){this.renderer.setPipeline(this);var i,n,r=e.scrollX*t.scrollFactorX,o=e.scrollY*t.scrollFactorY,a=t.x-r,h=t.y-o,u=t.scaleX,l=t.scaleY,y=-t.rotation,m=t.commandBuffer,x=t.alpha,w=1,b=1,T=0,A=0,S=1,C=e.matrix.matrix,M=null,E=0,_=0,L=0,P=0,F=0,k=0,R=0,O=0,D=0,I=0,B=null,Y=Math.sin,X=Math.cos,z=2*Math.PI,N=Y(y),G=X(y),W=G*u,U=-N*u,V=N*l,H=G*l,j=a,q=h,K=C[0],J=C[1],Z=C[2],Q=C[3],$=W*K+U*Z,tt=W*J+U*Q,et=V*K+H*Z,it=V*J+H*Q,nt=j*K+q*Z+C[4],st=j*J+q*Q+C[5];v.length=0;for(var rt=0,ot=m.length;rt0&&(D=D%z-z):D>z?D=z:D<0&&(D=z+D%z);E<1;)_=F+X(P=D*E+O)*R,L=k+Y(P)*R,M.points.push(new c(_,L,S,T,w*x)),E+=.01;_=F+X(P=D+O)*R,L=k+Y(P)*R,M.points.push(new c(_,L,S,T,w*x)),rt+=6;break;case s.LINE_STYLE:S=m[rt+1],T=m[rt+2],w=m[rt+3],rt+=3;break;case s.FILL_STYLE:A=m[rt+1],b=m[rt+2],rt+=2;break;case s.BEGIN_PATH:v.length=0,M=null;break;case s.CLOSE_PATH:M&&M.points.length&&M.points.push(M.points[0]);break;case s.FILL_PATH:for(i=0,n=v.length;i=0&&n>=0;return r[0]===t&&r[1]===e&&r[2]===i&&r[3]===n||this.flush(),r[0]=t,r[1]=e,r[2]=i,r[3]=n,this.currentScissorEnabled=o,o?(s.disable(s.SCISSOR_TEST),this):(s.enable(s.SCISSOR_TEST),s.scissor(t,s.drawingBufferHeight-e-n,i,n),this)},pushScissor:function(t,e,i,n){var s=this.scissorStack,r=this.currentScissorIdx,o=this.currentScissor;return s[r+0]=o[0],s[r+1]=o[1],s[r+2]=o[2],s[r+3]=o[3],this.currentScissorIdx+=4,this.setScissor(t,e,i,n),this},popScissor:function(){var t=this.scissorStack,e=this.currentScissorIdx-4,i=t[e+0],n=t[e+1],s=t[e+2],r=t[e+3];return this.currentScissorIdx=e,this.setScissor(i,n,s,r),this},setPipeline:function(t){return this.currentPipeline===t&&this.currentPipeline.vertexBuffer===this.currentVertexBuffer&&this.currentPipeline.program===this.currentProgram||(this.flush(),this.currentPipeline=t,this.currentPipeline.bind()),this.currentPipeline.onBind(),this.currentPipeline},setBlendMode:function(t){var e=this.gl,i=this.blendModes[t];return t!==s.BlendModes.SKIP_CHECK&&this.currentBlendMode!==t&&(this.flush(),e.enable(e.BLEND),e.blendEquation(i.equation),i.func.length>2?e.blendFuncSeparate(i.func[0],i.func[1],i.func[2],i.func[3]):e.blendFunc(i.func[0],i.func[1]),this.currentBlendMode=t),this},addBlendMode:function(t,e){return this.blendModes.push({func:t,equation:e})-1},updateBlendMode:function(t,e,i){return this.blendModes[t]&&(this.blendModes[t].func=e,i&&(this.blendModes[t].equation=i)),this},removeBlendMode:function(t){return t>16&&this.blendModes[t]&&this.blendModes.splice(t,1),this},setTexture2D:function(t,e){var i=this.gl;return t!==this.currentTextures[e]&&(this.flush(),this.currentActiveTextureUnit!==e&&(i.activeTexture(i.TEXTURE0+e),this.currentActiveTextureUnit=e),i.bindTexture(i.TEXTURE_2D,t),this.currentTextures[e]=t),this},setFramebuffer:function(t){var e=this.gl;return t!==this.currentFramebuffer&&(this.flush(),e.bindFramebuffer(e.FRAMEBUFFER,t),this.currentFramebuffer=t),this},setProgram:function(t){var e=this.gl;return t!==this.currentProgram&&(this.flush(),e.useProgram(t),this.currentProgram=t),this},setVertexBuffer:function(t){var e=this.gl;return t!==this.currentVertexBuffer&&(this.flush(),e.bindBuffer(e.ARRAY_BUFFER,t),this.currentVertexBuffer=t),this},setIndexBuffer:function(t){var e=this.gl;return t!==this.currentIndexBuffer&&(this.flush(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.currentIndexBuffer=t),this},createTextureFromSource:function(t,e,i,n){var o=this.gl,a=o.NEAREST,h=o.CLAMP_TO_EDGE;return e=t?t.width:e,i=t?t.height:i,r(e,i)&&(h=o.REPEAT),n===s.ScaleModes.LINEAR?a=o.LINEAR:(n===s.ScaleModes.NEAREST||this.config.pixelArt)&&(a=o.NEAREST),t||"number"!=typeof e||"number"!=typeof i?this.createTexture2D(0,a,a,h,h,o.RGBA,t):this.createTexture2D(0,a,a,h,h,o.RGBA,null,e,i)},createTexture2D:function(t,e,i,n,s,r,o,a,h,u){var l=this.gl,c=l.createTexture();return u=void 0===u||null===u||u,this.setTexture2D(c,0),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,e),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,i),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,s),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,n),l.pixelStorei(l.UNPACK_PREMULTIPLY_ALPHA_WEBGL,u),null===o||void 0===o?l.texImage2D(l.TEXTURE_2D,t,r,a,h,0,r,l.UNSIGNED_BYTE,null):(l.texImage2D(l.TEXTURE_2D,t,r,r,l.UNSIGNED_BYTE,o),a=o.width,h=o.height),this.setTexture2D(null,0),c.isAlphaPremultiplied=u,c.isRenderTexture=!1,c.width=a,c.height=h,this.nativeTextures.push(c),c},createFramebuffer:function(t,e,i,n){var s,r=this.gl,o=r.createFramebuffer();if(this.setFramebuffer(o),n){var a=r.createRenderbuffer();r.bindRenderbuffer(r.RENDERBUFFER,a),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t,e),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,a)}if(i.isRenderTexture=!0,i.isAlphaPremultiplied=!1,r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,i,0),(s=r.checkFramebufferStatus(r.FRAMEBUFFER))!==r.FRAMEBUFFER_COMPLETE){throw new Error("Framebuffer incomplete. Framebuffer status: "+{36054:"Incomplete Attachment",36055:"Missing Attachment",36057:"Incomplete Dimensions",36061:"Framebuffer Unsupported"}[s])}return o.renderTexture=i,this.setFramebuffer(null),o},createProgram:function(t,e){var i=this.gl,n=i.createProgram(),s=i.createShader(i.VERTEX_SHADER),r=i.createShader(i.FRAGMENT_SHADER);if(i.shaderSource(s,t),i.shaderSource(r,e),i.compileShader(s),i.compileShader(r),!i.getShaderParameter(s,i.COMPILE_STATUS))throw new Error("Failed to compile Vertex Shader:\n"+i.getShaderInfoLog(s));if(!i.getShaderParameter(r,i.COMPILE_STATUS))throw new Error("Failed to compile Fragment Shader:\n"+i.getShaderInfoLog(r));if(i.attachShader(n,s),i.attachShader(n,r),i.linkProgram(n),!i.getProgramParameter(n,i.LINK_STATUS))throw new Error("Failed to link program:\n"+i.getProgramInfoLog(n));return n},createVertexBuffer:function(t,e){var i=this.gl,n=i.createBuffer();return this.setVertexBuffer(n),i.bufferData(i.ARRAY_BUFFER,t,e),this.setVertexBuffer(null),n},createIndexBuffer:function(t,e){var i=this.gl,n=i.createBuffer();return this.setIndexBuffer(n),i.bufferData(i.ELEMENT_ARRAY_BUFFER,t,e),this.setIndexBuffer(null),n},deleteTexture:function(t){return this.gl.deleteTexture(t),this},deleteFramebuffer:function(t){return this.gl.deleteFramebuffer(t),this},deleteProgram:function(t){return this.gl.deleteProgram(t),this},deleteBuffer:function(t){return this.gl.deleteBuffer(t),this},preRenderCamera:function(t){var e=this.config.resolution,i=Math.floor(t.x*e),n=Math.floor(t.y*e),s=Math.floor(t.width*e),r=Math.floor(t.height*e);if(this.pushScissor(i,n,s,r),t.backgroundColor.alphaGL>0){var a=t.backgroundColor,h=this.pipelines.FlatTintPipeline;h.batchFillRect(0,0,1,1,0,t.x,t.y,t.width,t.height,o.getTintFromFloats(a.redGL,a.greenGL,a.blueGL,1),a.alphaGL,1,0,0,1,0,0,[1,0,0,1,0,0]),h.flush()}},postRenderCamera:function(t){if(t._fadeAlpha>0||t._flashAlpha>0){var e=this.pipelines.FlatTintPipeline;e.batchFillRect(0,0,1,1,0,t.x,t.y,t.width,t.height,o.getTintFromFloats(t._fadeRed,t._fadeGreen,t._fadeBlue,1),t._fadeAlpha,1,0,0,1,0,0,[1,0,0,1,0,0]),e.batchFillRect(0,0,1,1,0,t.x,t.y,t.width,t.height,o.getTintFromFloats(t._flashRed,t._flashGreen,t._flashBlue,1),t._flashAlpha,1,0,0,1,0,0,[1,0,0,1,0,0]),e.flush()}this.popScissor()},preRender:function(){if(!this.contextLost){var t=this.gl,e=this.config.backgroundColor,i=this.pipelines;for(var n in t.clearColor(e.redGL,e.greenGL,e.blueGL,e.alphaGL),this.config.clearBeforeRender&&t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT|t.STENCIL_BUFFER_BIT),i)i[n].onPreRender()}},render:function(t,e,i,n){if(!this.contextLost){var r=e.list,o=r.length,a=this.pipelines;for(var h in a)a[h].onRender(t,n);this.preRenderCamera(n);for(var u=0;u0||n._flashAlpha>0)&&(s.globalCompositeOperation="source-over",s.fillStyle="rgb("+255*n._fadeRed+","+255*n._fadeGreen+","+255*n._fadeBlue+")",s.globalAlpha=n._fadeAlpha,s.fillRect(n.x,n.y,n.width,n.height),s.fillStyle="rgb("+255*n._flashRed+","+255*n._flashGreen+","+255*n._flashBlue+")",s.globalAlpha=n._flashAlpha,s.fillRect(n.x,n.y,n.width,n.height),s.globalAlpha=1),r&&s.restore()},postRender:function(){var t=this.gameContext;t.globalAlpha=1,t.globalCompositeOperation="source-over",this.currentAlpha=1,this.currentBlendMode=0,this.snapshotCallback&&(this.snapshotCallback(s(this.gameCanvas,this.snapshotType,this.snapshotEncoder)),this.snapshotCallback=null)},snapshot:function(t,e,i){this.snapshotCallback=t,this.snapshotType=e,this.snapshotEncoder=i},destroy:function(){this.gameCanvas=null,this.gameContext=null,this.game=null}});t.exports=c},function(t,e,i){var n=new(i(0))({initialize:function(t){this.parent=t,this.animationManager=t.scene.sys.anims,this.animationManager.once("remove",this.remove,this),this.isPlaying=!1,this.currentAnim=null,this.currentFrame=null,this._timeScale=1,this.frameRate=0,this.duration=0,this.msPerFrame=0,this.skipMissedFrames=!0,this._delay=0,this._repeat=0,this._repeatDelay=0,this._yoyo=!1,this.forward=!0,this.accumulator=0,this.nextTick=0,this.repeatCounter=0,this.pendingRepeat=!1,this._paused=!1,this._wasPlaying=!1,this._callbackArgs=[t,null],this._updateParams=[]},delay:function(t){return void 0===t?this._delay:(this._delay=t,this)},delayedPlay:function(t,e,i){return this.play(e,!0,i),this.nextTick+=1e3*t,this},getCurrentKey:function(){if(this.currentAnim)return this.currentAnim.key},load:function(t,e){return void 0===e&&(e=0),this.isPlaying&&this.stop(),this.animationManager.load(this,t,e),this},pause:function(t){return this._paused||(this._paused=!0,this._wasPlaying=this.isPlaying,this.isPlaying=!1),void 0!==t&&this.updateFrame(t),this},paused:function(t){return void 0!==t?t?this.pause():this.resume():this._paused},play:function(t,e,i){if(void 0===e&&(e=!1),void 0===i&&(i=0),e&&this.isPlaying&&this.currentAnim.key===t)return this;this.load(t,i);var n=this.currentAnim,s=this.parent;return this.repeatCounter=-1===this._repeat?Number.MAX_VALUE:this._repeat,n.getFirstTick(this),this.forward=!0,this.isPlaying=!0,this.pendingRepeat=!1,n.showOnStart&&(s.visible=!0),n.onStart&&n.onStart.apply(n.callbackScope,this._callbackArgs.concat(n.onStartParams)),s.setSizeToFrame(),s.updateDisplayOrigin(),this},progress:function(t){if(void 0===t){var e=this.currentFrame.progress;return this.forward||(e=1-e),e}return this},remove:function(t){if(void 0===t&&(t=this.currentAnim),this.isPlaying&&t.key===this.currentAnim.key){this.stop();var e=this.parent,i=this.currentAnim.frames[0];this.currentFrame=i,e.texture=i.frame.texture,e.frame=i.frame}},repeat:function(t){return void 0===t?this._repeat:(this._repeat=t,this.repeatCounter=0,this)},repeatDelay:function(t){return void 0===t?this._repeatDelay:(this._repeatDelay=t,this)},restart:function(t){return void 0===t&&(t=!1),this.currentAnim.getFirstTick(this,t),this.forward=!0,this.isPlaying=!0,this.pendingRepeat=!1,this._paused=!1,this.updateFrame(this.currentAnim.frames[0]),this},resume:function(t){return this._paused&&(this._paused=!1,this.isPlaying=this._wasPlaying),void 0!==t&&this.updateFrame(t),this},stop:function(t){void 0===t&&(t=!1),this.isPlaying=!1;var e=this.currentAnim;return t&&e.onComplete&&e.onComplete.apply(e.callbackScope,this._callbackArgs.concat(e.onCompleteParams)),this},timeScale:function(t){return void 0===t?this._timeScale:(this._timeScale=t,this)},totalFrames:function(){return this.currentAnim.frames.length},totalProgres:function(){},update:function(t,e){this.isPlaying&&!this.currentAnim.paused&&(this.accumulator+=e*this._timeScale,this.accumulator>=this.nextTick&&this.currentAnim.setFrame(this))},updateFrame:function(t){var e=this.parent;if(this.currentFrame=t,e.texture=t.frame.texture,e.frame=t.frame,this.isPlaying){t.setAlpha&&(e.alpha=t.alpha);var i=this.currentAnim;i.onUpdate&&i.onUpdate.apply(i.callbackScope,this._updateParams),t.onUpdate&&t.onUpdate(e,t)}},yoyo:function(t){return void 0===t?this._yoyo:(this._yoyo=t,this)},destroy:function(){}});t.exports=n},function(t,e){t.exports=function(t){return t.split("").reverse().join("")}},function(t,e){t.exports=function(t,e){return t.replace(/%([0-9]+)/g,function(t,i){return e[Number(i)-1]})}},function(t,e,i){t.exports={Format:i(383),Pad:i(158),Reverse:i(382),UppercaseFirst:i(285)}},function(t,e,i){var n=i(55);t.exports=function(t,e){var i=n(t);for(var s in e)i.hasOwnProperty(s)&&(i[s]=e[s]);return i}},function(t,e){t.exports=function(t,e){for(var i=0;i-1&&this._active.splice(s,1),n.destroy()}for(i=0;i=n.delay)){var s=n.elapsed-n.delay;n.elapsed=n.delay,!n.hasDispatched&&n.callback&&(n.hasDispatched=!0,n.callback.apply(n.callbackScope,n.args)),n.repeatCount>0?(n.repeatCount--,n.elapsed=s,n.hasDispatched=!1):this._pendingRemoval.push(n)}}}},shutdown:function(){var t;for(t=0;t0&&e.cameraFilter&s._id)){e.cull(s);var r=e.culledTiles,o=this.tileset,a=t.gameContext,h=r.length,u=o.image.getSourceImage(),l=e.x-s.scrollX*e.scrollFactorX,c=e.y-s.scrollY*e.scrollFactorY;a.save(),a.translate(l,c),a.rotate(e.rotation),a.scale(e.scaleX,e.scaleY),a.scale(e.flipX?-1:1,e.flipY?-1:1),a.globalAlpha=e.alpha;for(var d=0;d0&&e.cameraFilter&s._id||(e.upload(s),this.pipeline.drawStaticTilemapLayer(e,s))}},function(t,e,i){var n=i(3),s=i(3);n=i(410),s=i(409),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){e.cull(s);var r=e.culledTiles,o=r.length,a=e.tileset.image.getSourceImage(),h=this.tileset,u=e.x-s.scrollX*e.scrollFactorX,l=e.y-s.scrollY*e.scrollFactorY,c=t.gameContext;c.save(),c.translate(u,l),c.rotate(e.rotation),c.scale(e.scaleX,e.scaleY),c.scale(e.flipX?-1:1,e.flipY?-1:1);for(var d=0;d0&&e.cameraFilter&s._id||(e.cull(s),this.pipeline.batchDynamicTilemapLayer(e,s))}},function(t,e,i){var n=i(3),s=i(3);n=i(413),s=i(412),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(84);t.exports=function(t){for(var e=[],i=[],s=0;s-1?new s(a,f,c,l,o.tilesize,o.tilesize):e?null:new s(a,-1,c,l,o.tilesize,o.tilesize),h.push(d)}u.push(h),h=[]}a.data=u,i.push(a)}return i}},function(t,e,i){var n=i(18);t.exports=function(t){for(var e,i,s,r,o,a=0;a>>0;return n}},function(t,e,i){var n=i(423),s=i(2),r=i(66),o=i(191),a=i(45);t.exports=function(t,e){for(var i=[],h=0;h0){var y=new a(l,v.gid,c,f.length,t.tilewidth,t.tileheight);y.rotation=v.rotation,y.flipX=v.flipped,d.push(y)}else{var m=e?null:new a(l,-1,c,f.length,t.tilewidth,t.tileheight);d.push(m)}++c===u.width&&(f.push(d),c=0,d=[])}l.data=f,i.push(l)}}return i}},function(t,e,i){t.exports={Parse:i(194),Parse2DArray:i(116),ParseCSV:i(193),Impact:i(187),Tiled:i(192)}},function(t,e,i){var n=i(38),s=i(37),r=i(6);t.exports=function(t,e,i,o,a,h){return void 0===o&&(o=new r(0,0)),o.x=n(t,i,a,h),o.y=s(e,i,a,h),o}},function(t,e,i){var n=i(14);t.exports=function(t,e,i,s,r,o){if(void 0!==r){var a,h=n(t,e,i,s,null,o),u=0;for(a=0;a0&&n(a,t)}}e&&s(0,0,i.width,i.height,i)}},function(t,e,i){var n=i(46),s=i(26),r=i(70);t.exports=function(t,e,i,o){void 0===e&&(e=!0),void 0===i&&(i=!0);for(var a=0;ae)){for(var h=t;h<=e;h++)r(h,i,a);for(var u=0;u=t&&c.index<=e&&n(c,i)}o&&s(0,0,a.width,a.height,a)}}},function(t,e,i){var n=i(46),s=i(26),r=i(117);t.exports=function(t,e,i,o){void 0===e&&(e=!0),void 0===i&&(i=!0),Array.isArray(t)||(t=[t]);for(var a=0;a=0;r--)for(s=n.width-1;s>=0;s--)if((o=n.data[r][s])&&o.index===t){if(a===e)return o;a+=1}}else for(r=0;r-c&&y>-d&&v=0&&p=0&&g0?1:-1),u=Math.sqrt(o*o*t.mass/e.mass)*(o>0?1:-1),l=.5*(h+u);h-=l,u-=l,t.velocity.y=l+h*t.bounce.y,e.velocity.y=l+u*e.bounce.y}return!0}},function(t,e,i){var n=i(207);t.exports=function(t,e,i,s){var r=n(t,e,i,s);if(i||0===r||t.immovable&&e.immovable||t.customSeparateX||e.customSeparateX)return 0!==r||t.embedded&&e.embedded;var o=t.velocity.x,a=e.velocity.x;if(t.immovable||e.immovable)t.immovable?(e.x+=r,e.velocity.x=o-a*e.bounce.x,t.moves&&(e.y+=(t.y-t.prev.y)*t.friction.y)):(t.x-=r,t.velocity.x=a-o*t.bounce.x,e.moves&&(t.y+=(e.y-e.prev.y)*e.friction.y));else{r*=.5,t.x-=r,e.x+=r;var h=Math.sqrt(a*a*e.mass/t.mass)*(a>0?1:-1),u=Math.sqrt(o*o*t.mass/e.mass)*(o>0?1:-1),l=.5*(h+u);h-=l,u-=l,t.velocity.x=l+h*t.bounce.x,e.velocity.x=l+u*e.bounce.x}return!0}},function(t,e){t.exports=function(t,e){e<0?t.blocked.up=!0:e>0&&(t.blocked.down=!0),t.position.y-=e,0===t.bounce.y?t.velocity.y=0:t.velocity.y=-t.velocity.y*t.bounce.y}},function(t,e,i){var n=i(472);t.exports=function(t,e,i,s,r){var o=0;return t.deltaY()<0&&!t.blocked.up&&e.collideDown&&t.checkCollision.up?e.faceBottom&&t.y0&&!t.blocked.down&&e.collideUp&&t.checkCollision.down&&e.faceTop&&t.bottom>i&&(o=t.bottom-i)>r&&(o=0),0!==o&&(t.customSeparateY?t.overlapY=o:n(t,o)),o}},function(t,e){t.exports=function(t,e){e<0?t.blocked.left=!0:e>0&&(t.blocked.right=!0),t.position.x-=e,0===t.bounce.x?t.velocity.x=0:t.velocity.x=-t.velocity.x*t.bounce.x}},function(t,e,i){var n=i(474);t.exports=function(t,e,i,s,r){var o=0;return t.deltaX()<0&&!t.blocked.left&&e.collideRight&&t.checkCollision.left?e.faceRight&&t.x0&&!t.blocked.right&&e.collideLeft&&t.checkCollision.right&&e.faceLeft&&t.right>i&&(o=t.right-i)>r&&(o=0),0!==o&&(t.customSeparateX?t.overlapX=o:n(t,o)),o}},function(t,e,i){var n=i(475),s=i(473),r=i(202);t.exports=function(t,e,i,o,a,h){var u=o.left,l=o.top,c=o.right,d=o.bottom,f=i.faceLeft||i.faceRight,p=i.faceTop||i.faceBottom;if(!f&&!p)return!1;var g=0,v=0,y=0,m=1;if(e.deltaAbsX()>e.deltaAbsY()?y=-1:e.deltaAbsX()=0;o--){var a=e[o],h=u(s,r,a.x,a.y);h=0;o--){var a=e[o],h=u(s,r,a.x,a.y);h>i&&(n=a,i=h)}return n},moveTo:function(t,e,i,n,s){void 0===n&&(n=60),void 0===s&&(s=0);var r=Math.atan2(i-t.y,e-t.x);return s>0&&(n=u(t.x,t.y,e,i)/(s/1e3)),t.body.velocity.setToPolar(r,n),r},moveToObject:function(t,e,i,n){return this.moveTo(t,e.x,e.y,i,n)},velocityFromAngle:function(t,e,i){return void 0===e&&(e=60),i.setToPolar(l(t),e)},velocityFromRotation:function(t,e,i){return void 0===e&&(e=60),i.setToPolar(t,e)},shutdown:function(){this.world.shutdown()},destroy:function(){this.world.destroy()}});a.register("ArcadePhysics",c,"arcadePhysics"),t.exports=c},function(t,e,i){var n=i(47),s=i(18),r={ArcadePhysics:i(490),Body:i(209),Collider:i(208),Factory:i(215),Group:i(212),Image:i(214),Sprite:i(93),StaticBody:i(201),StaticGroup:i(211),World:i(210)};r=s(!1,r,n),t.exports=r},function(t,e){t.exports=function(t,e,i){return Math.abs(t-e)<=i}},function(t,e){t.exports=function(t,e,i,n){void 0===e&&(e=1),void 0===i&&(i=1),void 0===n&&(n=1),n*=Math.PI/t;for(var s=[],r=[],o=0;o1?void 0!==n?(s=(n-t)/(n-i))<0&&(s=0):s=1:s<0&&(s=0),s}},function(t,e){t.exports=function(t,e,i){return Math.max(t-e,i)}},function(t,e){t.exports=function(t,e,i){return Math.min(t+e,i)}},function(t,e){t.exports=function(t){return t===parseFloat(t)?!(t%2):void 0}},function(t,e){t.exports=function(t){return t==parseFloat(t)?!(t%2):void 0}},function(t,e){t.exports=function(t,e){return t/e/1e3}},function(t,e){t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var n=Math.pow(i,-e);return Math.floor(t*n)/n}},function(t,e){t.exports=function(t,e){return Math.abs(t-e)}},function(t,e){t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var n=Math.pow(i,-e);return Math.ceil(t*n)/n}},function(t,e){t.exports=function(t){for(var e=0,i=0;i0&&0==(t&t-1)}},function(t,e,i){t.exports={GetNext:i(248),IsSize:i(145),IsValue:i(510)}},function(t,e,i){var n=i(148);t.exports=function(t,e){var i=t.length-1,s=i*e,r=Math.floor(s);return e<0?n(t[0],t[1],s):e>1?n(t[i],t[i-1],i-s):n(t[r],t[r+1>i?i:r+1],s-r)}},function(t,e,i){var n=i(149);t.exports=function(t,e){var i=t.length-1,s=i*e,r=Math.floor(s);return t[0]===t[i]?(e<0&&(r=Math.floor(s=i*(1+e))),n(s-r,t[(r-1+i)%i],t[r],t[(r+1)%i],t[(r+2)%i])):e<0?t[0]-(n(-s,t[0],t[0],t[1],t[1])-t[0]):e>1?t[i]-(n(s-i,t[i],t[i],t[i-1],t[i-1])-t[i]):n(s-r,t[r?r-1:0],t[r],t[ie-i}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1e-4),Math.floor(t+e)}},function(t,e){t.exports=function(t,e,i){return void 0===i&&(i=1e-4),Math.abs(t-e)=n.PI2-i?t=e:(Math.abs(e-t)>Math.PI&&(et?t+=i:e0?this.processLoadQueue():0===this.inflight.size&&this.finishedLoading()},finishedLoading:function(){this.state!==s.LOADER_PROCESSING&&(this.progress=1,this.state=s.LOADER_PROCESSING,this.storage.clear(),0===this.queue.size?this.processComplete():this.queue.each(function(t){t.onProcess(this.processUpdate.bind(this))},this))},processUpdate:function(t){if(t.state===s.FILE_ERRORED)return this.failed.set(t),t.linkFile&&this.queue.delete(t.linkFile),this.removeFromQueue(t);t.linkFile?t.state===s.FILE_COMPLETE&&t.linkFile.state===s.FILE_COMPLETE&&(this.storage.set({type:t.linkType,fileA:t,fileB:t.linkFile}),this.queue.delete(t.linkFile),this.removeFromQueue(t)):(this.storage.set(t),this.removeFromQueue(t))},removeFromQueue:function(t){this.queue.delete(t),0===this.queue.size&&this.state===s.LOADER_PROCESSING&&this.processComplete()},processComplete:function(){this.list.clear(),this.inflight.clear(),this.queue.clear(),this.processCallback(),this.state=s.LOADER_COMPLETE,this.emit("complete",this,this.storage.size,this.failed.size)},processCallback:function(){if(0!==this.storage.size){var t,e,i,n=this.scene.sys.cache,s=this.scene.sys.textures,r=this.scene.sys.anims;for(var o in this._multilist){for(var a=[],h=[],l=this._multilist[o],c=0;c0},file:function(t){var e,i=t.key;switch(t.type){case"spritesheet":e=this.spritesheet(i,t.url,t.config,t.xhrSettings);break;case"atlas":e=this.atlas(i,t.textureURL,t.atlasURL,t.textureXhrSettings,t.atlasXhrSettings);break;case"bitmapFont":e=this.bitmapFont(i,t.textureURL,t.xmlURL,t.textureXhrSettings,t.xmlXhrSettings);break;case"multiatlas":e=this.multiatlas(i,t.textureURLs,t.atlasURLs,t.textureXhrSettings,t.atlasXhrSettings);break;case"audioSprite":e=this.audioSprite(i,t.urls,t.json,t.config,t.audioXhrSettings,t.jsonXhrSettings);break;default:e=this[t.type](i,t.url,t.xhrSettings)}return e},shutdown:function(){this.reset(),this.state=s.LOADER_SHUTDOWN},destroy:function(){this.reset(),this.state=s.LOADER_DESTROYED}});l.register("Loader",d,"load"),t.exports=d},function(t,e,i){var n=i(7),s=i(50),r=i(221),o=function(t,e,i,n,o,a){var h=new s(t,e,n,o),u=new r(t,i,n,a);return h.linkFile=u,u.linkFile=h,h.linkType="unityatlas",u.linkType="unityatlas",{texture:h,data:u}};n.register("unityAtlas",function(t,e,i,n,s){var r=new o(t,e,i,this.path,n,s);return this.addFile(r.texture),this.addFile(r.data),this}),t.exports=o},function(t,e,i){var n=i(7),s=i(51),r=i(24),o=function(t,e,i,n,r){var o=new s(t,e,i,r);return o.type="tilemapJSON",o.tilemapFormat=n,o};n.register("tilemapTiledJSON",function(t,e,i){if(Array.isArray(t))for(var n=0;n'),n.push(''),n.push(''),n.push(this.xhrLoader.responseText),n.push(""),n.push(""),n.push("");var o=[n.join("\n")],a=this;try{var h=new window.Blob(o,{type:"image/svg+xml;charset=utf-8"})}catch(e){return a.state=s.FILE_ERRORED,void t(a)}this.data=new Image,this.data.crossOrigin=this.crossOrigin,this.data.onload=function(){r.revokeObjectURL(a.data),a.onComplete(),t(a)},this.data.onerror=function(){r.revokeObjectURL(a.data),a.state=s.FILE_ERRORED,t(a)},r.createObjectURL(this.data,h,"image/svg+xml")}});o.register("html",function(t,e,i,n,s){if(Array.isArray(t))for(var r=0;r-1&&(s.splice(a,1),this.clear(o))}t.length=0,this._list=s.concat(e.splice(0))}},clear:function(t){var e=t.input;e.gameObject=void 0,e.target=void 0,e.hitArea=void 0,e.hitAreaCallback=void 0,e.callbackContext=void 0,t.input=null;var i=this._draggable.indexOf(t);return i>-1&&this._draggable.splice(i,1),(i=this._drag[0].indexOf(t))>-1&&this._drag[0].splice(i,1),(i=this._over[0].indexOf(t))>-1&&this._over[0].splice(i,1),t},disable:function(t){t.input.enabled=!1},enable:function(t,e,i,n){return void 0===n&&(n=!1),t.input?t.input.enabled=!0:this.setHitArea(t,e,i),t.input.dropZone=n,this},hitTestPointer:function(t){var e=this.cameras.getCameraBelowPointer(t);if(e){t.camera=e;for(var i=this.manager.hitTest(t.x,t.y,this._list,e),n=0;n0?t.dragState=1:t.dragState>0&&!t.primaryDown&&t.justUp&&(t.dragState=5),1===t.dragState){var h=[];for(i=0;i1&&(this.sortGameObjects(h),this.topOnly&&h.splice(1)),this._drag[t.id]=h,0===this.dragDistanceThreshold&&0===this.dragTimeThreshold?t.dragState=3:t.dragState=2}if(2===t.dragState&&(this.dragDistanceThreshold>0&&o(t.x,t.y,t.downX,t.downY)>=this.dragDistanceThreshold&&(t.dragState=3),this.dragTimeThreshold>0&&e>=t.downTime+this.dragTimeThreshold&&(t.dragState=3)),3===t.dragState){for(s=this._drag[t.id],i=0;i0?(n.emit("dragleave",t,r.target),this.emit("dragleave",t,n,r.target),r.target=u[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target)):(n.emit("dragleave",t,r.target),this.emit("dragleave",t,n,r.target),u[0]?(r.target=u[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target)):r.target=null)}else!r.target&&u[0]&&(r.target=u[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target));var c=t.x-n.input.dragX,d=t.y-n.input.dragY;n.emit("drag",t,c,d),this.emit("drag",t,n,c,d)}return s.length}if(5===t.dragState){for(s=this._drag[t.id],i=0;i0)for(this.sortGameObjects(s),this.emit("pointerout",t,s),e=0;e0)for(this.sortGameObjects(r),this.emit("pointerover",t,r),e=0;e-1&&this._draggable.splice(s,1)}return this},setHitArea:function(t,e,i){if(void 0===e)return this.setHitAreaFromTexture(t);Array.isArray(t)||(t=[t]);for(var n=0;nn?-1:0},sortHandlerIO:function(t,e){var i=this.displayList.getIndex(t.gameObject),n=this.displayList.getIndex(e.gameObject);return in?-1:0},sortInteractiveObjects:function(t){return t.length<2?t:(this.scene.sys.depthSort(),t.sort(this.sortHandlerIO.bind(this)))},stopPropagation:function(){return this.manager.globalTopOnly&&(this.manager.ignoreEvents=!0),this},update:function(t,e){var i=this.manager;if(!i.globalTopOnly||!i.ignoreEvents){var n=i.activePointer,s=n.dirty||0===this.pollRate;if(this.pollRate>-1&&(this._pollTimer-=e,this._pollTimer<0&&(s=!0,this._pollTimer=this.pollRate)),s){this._tempZones=[],this._temp=this.hitTestPointer(n),this.sortGameObjects(this._temp),this.sortGameObjects(this._tempZones),this.topOnly&&(this._temp.length&&this._temp.splice(1),this._tempZones.length&&this._tempZones.splice(1));var r=this.processDragEvents(n,t);n.wasTouch||(r+=this.processOverOutEvents(n)),n.justDown&&(r+=this.processDownEvents(n)),n.justUp&&(r+=this.processUpEvents(n)),n.justMoved&&(r+=this.processMoveEvents(n)),r>0&&i.globalTopOnly&&(i.ignoreEvents=!0)}}},shutdown:function(){this._temp.length=0,this._list.length=0,this._draggable.length=0,this._pendingRemoval.length=0,this._pendingInsertion.length=0;for(var t=0;t<10;t++)this._drag[t]=[],this._over[t]=[];this.removeAllListeners()},destroy:function(){this.shutdown(),this.scene=void 0,this.cameras=void 0,this.manager=void 0,this.events=void 0,this.keyboard=void 0,this.mouse=void 0,this.gamepad=void 0},activePointer:{get:function(){return this.manager.activePointer}},x:{get:function(){return this.manager.activePointer.x}},y:{get:function(){return this.manager.activePointer.y}}});c.register("InputPlugin",v,"input"),t.exports=v},function(t,e){t.exports={UP:12,DOWN:13,LEFT:14,RIGHT:15,MENU:16,A:0,B:1,X:2,Y:3,LB:4,RB:5,LT:6,RT:7,BACK:8,START:9,LS:10,RS:11,LEFT_STICK_H:0,LEFT_STICK_V:1,RIGHT_STICK_H:2,RIGHT_STICK_V:3}},function(t,e){t.exports={UP:12,DOWN:13,LEFT:14,RIGHT:15,SELECT:8,START:9,B:0,A:1,Y:2,X:3,LEFT_SHOULDER:4,RIGHT_SHOULDER:5}},function(t,e){t.exports={UP:12,DOWN:13,LEFT:14,RIGHT:15,SHARE:8,OPTIONS:9,PS:16,TOUCHBAR:17,X:0,CIRCLE:1,SQUARE:2,TRIANGLE:3,L1:4,R1:5,L2:6,R2:7,L3:10,R3:11,LEFT_STICK_H:0,LEFT_STICK_V:1,RIGHT_STICK_H:2,RIGHT_STICK_V:3}},function(t,e,i){t.exports={DUALSHOCK_4:i(563),SNES_USB:i(562),XBOX_360:i(561)}},function(t,e,i){t.exports={Axis:i(296),Button:i(295),Gamepad:i(297),GamepadManager:i(298),Configs:i(564)}},function(t,e,i){t.exports={Gamepad:i(565),InputManager:i(299),InputPlugin:i(560),InteractiveObject:i(227),Keyboard:i(559),Mouse:i(554),Pointer:i(290),Touch:i(553)}},function(t,e,i){var n=i(123);t.exports=function(t,e,i){return n(t,e.x,e.y,i)}},function(t,e,i){var n=i(123),s=i(228);t.exports=function(t,e){var i=s(t);return n(t,i.x,i.y,e)}},function(t,e,i){var n=i(77);t.exports=function(t){var e=t.getLineA(),i=t.getLineB(),s=t.getLineC();return n(e)+n(i)+n(s)}},function(t,e){t.exports=function(t,e){return t.x1===e.x1&&t.y1===e.y1&&t.x2===e.x2&&t.y2===e.y2&&t.x3===e.x3&&t.y3===e.y3}},function(t,e){t.exports=function(t,e){return e.setTo(t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)}},function(t,e,i){var n=i(54);t.exports=function(t,e){return n(t,e.x,e.y)}},function(t,e,i){var n=i(52);t.exports=function(t){return new n(t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)}},function(t,e,i){var n=i(79);t.exports=function(t,e){void 0===e&&(e=new n);var i,s,r=t.x1,o=t.y1,a=t.x2,h=t.y2,u=t.x3,l=t.y3,c=a-r,d=h-o,f=u-r,p=l-o,g=c*(r+a)+d*(o+h),v=f*(r+u)+p*(o+l),y=2*(c*(l-h)-d*(u-a));if(Math.abs(y)<1e-6){var m=Math.min(r,a,u),x=Math.min(o,h,l);i=.5*(Math.max(r,a,u)-m),s=.5*(Math.max(o,h,l)-x),e.x=m+i,e.y=x+s,e.radius=Math.sqrt(i*i+s*s)}else e.x=(p*g-d*v)/y,e.y=(c*v-f*g)/y,i=e.x-r,s=e.y-o,e.radius=Math.sqrt(i*i+s*s);return e}},function(t,e,i){var n=i(6);function s(t,e,i,n){return t*n-e*i}t.exports=function(t,e){void 0===e&&(e=new n);var i=t.x3,r=t.y3,o=t.x1-i,a=t.y1-r,h=t.x2-i,u=t.y2-r,l=2*s(o,a,h,u),c=s(a,o*o+a*a,u,h*h+u*u),d=s(o,o*o+a*a,h,h*h+u*u);return e.x=i-c/l,e.y=r+d/l,e}},function(t,e,i){var n=i(230),s=i(229);t.exports=function(t,e,i,r){void 0===r&&(r=n);var o=r(t),a=e-o.x,h=i-o.y;return s(t,a,h)}},function(t,e,i){var n=i(52);t.exports=function(t,e,i,s){return void 0===s&&(s=i),new n(t,e,t,e-s,t+i,e)}},function(t,e,i){var n=i(301),s=i(52);t.exports=function(t,e,i,r,o){void 0===e&&(e=null),void 0===i&&(i=1),void 0===r&&(r=1),void 0===o&&(o=[]);for(var a,h,u,l,c,d,f,p,g,v=n(t,e),y=0;y0?t.width/2:t.width/-2,h=r>0?t.height/2:t.height/-2;return Math.abs(a*r)e.x&&t.ye.y}},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e){t.exports=function(t,e,i){var n=Math.min(t.x,e),s=Math.max(t.right,e);t.x=n,t.width=s-n;var r=Math.min(t.y,i),o=Math.max(t.bottom,i);return t.y=r,t.height=o-r,t}},function(t,e){t.exports=function(t,e){var i=Math.min(t.x,e.x),n=Math.max(t.right,e.right);t.x=i,t.width=n-i;var s=Math.min(t.y,e.y),r=Math.max(t.bottom,e.bottom);return t.y=s,t.height=r-s,t}},function(t,e){t.exports=function(t,e){for(var i=t.x,n=t.right,s=t.y,r=t.bottom,o=0;on(e)?t.setSize(e.height*i,e.height):t.setSize(e.width,e.width/i),t.setPosition(e.centerX-t.width/2,e.centerY-t.height/2)}},function(t,e,i){var n=i(124);t.exports=function(t,e){var i=n(t);return it.width*t.height)&&e.x>t.x&&e.xt.x&&e.rightt.y&&e.yt.y&&e.bottomi&&(i=h.x),h.xr&&(r=h.y),h.ye.right||t.righte.bottom||t.bottom0||(c=s(e),(d=n(t,c,!0)).length>0)}},function(t,e,i){var n=i(54),s=i(95);t.exports=function(t,e){return!!(n(t,e.getPointA())||n(t,e.getPointB())||s(t.getLineA(),e)||s(t.getLineB(),e)||s(t.getLineC(),e))}},function(t,e,i){var n=i(242),s=i(54);t.exports=function(t,e){return!(t.left>e.right||t.righte.bottom||t.bottomt.right+r||it.bottom+r||st.right||e.rightt.bottom||e.bottom0}},function(t,e,i){var n=i(241);t.exports=function(t,e){if(!n(t,e))return!1;var i=Math.min(e.x1,e.x2),s=Math.max(e.x1,e.x2),r=Math.min(e.y1,e.y2),o=Math.max(e.y1,e.y2);return t.x>=i&&t.x<=s&&t.y>=r&&t.y<=o}},function(t,e){t.exports=function(t,e){var i=t.x1,n=t.y1,s=t.x2,r=t.y2,o=e.x,a=e.y,h=e.right,u=e.bottom,l=0;if(i>=o&&i<=h&&n>=a&&n<=u||s>=o&&s<=h&&r>=a&&r<=u)return!0;if(i=o){if((l=n+(r-n)*(o-i)/(s-i))>a&&l<=u)return!0}else if(i>h&&s<=h&&(l=n+(r-n)*(h-i)/(s-i))>=a&&l<=u)return!0;if(n=a){if((l=i+(s-i)*(a-n)/(r-n))>=o&&l<=h)return!0}else if(n>u&&r<=u&&(l=i+(s-i)*(u-n)/(r-n))>=o&&l<=h)return!0;return!1}},function(t,e,i){var n=i(10),s=i(243);t.exports=function(t,e,i){return void 0===i&&(i=new n),s(t,e)&&(i.x=Math.max(t.x,e.x),i.y=Math.max(t.y,e.y),i.width=Math.min(t.right,e.right)-i.x,i.height=Math.min(t.bottom,e.bottom)-i.y),i}},function(t,e){t.exports=function(t,e){var i=e.width/2,n=e.height/2,s=Math.abs(t.x-e.x-i),r=Math.abs(t.y-e.y-n),o=i+t.radius,a=n+t.radius;if(s>o||r>a)return!1;if(s<=i||r<=n)return!0;var h=s-i,u=r-n;return h*h+u*u<=t.radius*t.radius}},function(t,e,i){var n=i(48);t.exports=function(t,e){return n(t.x,t.y,e.x,e.y)<=t.radius+e.radius}},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e,i){var n=i(10);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.left,e.y=t.top,e.width=t.diameter,e.height=t.diameter,e}},function(t,e){t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.radius===e.radius}},function(t,e){t.exports=function(t,e){return e.setTo(t.x,t.y,t.radius)}},function(t,e,i){var n=i(28);t.exports=function(t,e){return n(t,e.x,e.y)&&n(t,e.right,e.y)&&n(t,e.x,e.bottom)&&n(t,e.right,e.bottom)}},function(t,e,i){var n=i(28);t.exports=function(t,e){return n(t,e.x,e.y)}},function(t,e,i){var n=i(79);t.exports=function(t){return new n(t.x,t.y,t.radius)}},function(t,e){t.exports=function(t){return t.radius>0?Math.PI*t.radius*t.radius:0}},function(t,e,i){var n=i(79);n.Area=i(661),n.Circumference=i(353),n.CircumferencePoint=i(168),n.Clone=i(660),n.Contains=i(28),n.ContainsPoint=i(659),n.ContainsRect=i(658),n.CopyFrom=i(657),n.Equals=i(656),n.GetBounds=i(655),n.GetPoint=i(355),n.GetPoints=i(354),n.Offset=i(654),n.OffsetPoint=i(653),n.Random=i(167),t.exports=n},function(t,e,i){var n=i(0),s=i(246),r=i(12),o=new n({Extends:s,initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),s.call(this)},boot:function(){var t=this.systems.events;t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},destroy:function(){this.shutdown(),this.scene=void 0,this.systems=void 0}});r.register("LightsPlugin",o,"lights"),t.exports=o},function(t,e,i){var n=i(22),s=i(11),r=i(8),o=i(128);s.register("quad",function(t){var e=r(t,"x",0),i=r(t,"y",0),s=r(t,"key",null),a=r(t,"frame",null),h=new o(this.scene,e,i,s,a);return n(this.scene,h,t),h})},function(t,e,i){var n=i(22),s=i(11),r=i(8),o=i(5),a=i(96);s.register("mesh",function(t){var e=r(t,"key",null),i=r(t,"frame",null),s=o(t,"vertices",[]),h=o(t,"colors",[]),u=o(t,"alphas",[]),l=o(t,"uv",[]),c=new a(this.scene,0,0,s,l,h,u,e,i);return n(this.scene,c,t),c})},function(t,e,i){var n=i(128);i(9).register("quad",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(96);i(9).register("mesh",function(t,e,i,s,r,o,a,h){return this.displayList.add(new n(this.scene,t,e,i,s,r,o,a,h))})},function(t,e){t.exports=function(){}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchMesh(e,s)}},function(t,e,i){var n=i(3),s=i(3);n=i(669),s=i(668),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(11),s=i(8),r=i(106);n.register("zone",function(t){var e=s(t,"x",0),i=s(t,"y",0),n=s(t,"width",1),o=s(t,"height",n);return new r(this.scene,e,i,n,o)})},function(t,e,i){var n=i(22),s=i(11),r=i(8),o=i(129);s.register("tileSprite",function(t){var e=r(t,"x",0),i=r(t,"y",0),s=r(t,"width",512),a=r(t,"height",512),h=r(t,"key",""),u=r(t,"frame",""),l=new o(this.scene,e,i,s,a,h,u);return n(this.scene,l,t),l})},function(t,e,i){var n=i(22),s=i(11),r=i(8),o=i(130);s.register("text",function(t){var e=r(t,"text",""),i=r(t,"style",null),s=r(t,"padding",null);null!==s&&(i.padding=s);var a=new o(this.scene,0,0,e,i);return n(this.scene,a,t),a.autoRound=r(t,"autoRound",!0),a.resolution=r(t,"resolution",1),a})},function(t,e,i){var n=i(139),s=i(22),r=i(11),o=i(8),a=i(5);r.register("bitmapText",function(t){var e=a(t,"font",""),i=o(t,"text",""),r=o(t,"size",!1),h=new n(this.scene,0,0,e,i,r);return s(this.scene,h,t),h})},function(t,e,i){var n=i(22),s=i(140),r=i(11),o=i(8),a=i(40);r.register("sprite",function(t){var e=o(t,"key",null),i=o(t,"frame",null),r=new a(this.scene,0,0,e,i);return n(this.scene,r,t),s(r,t),r})},function(t,e,i){var n=i(22),s=i(140),r=i(11),o=i(8),a=i(101);r.register("sprite3D",function(t){var e=o(t,"key",null),i=o(t,"frame",null),r=new a(this.scene,0,0,e,i);return n(this.scene,r,t),s(r,t),r})},function(t,e,i){var n=i(22),s=i(11),r=i(8),o=i(131);s.register("renderTexture",function(t){var e=r(t,"x",0),i=r(t,"y",0),s=r(t,"width",32),a=r(t,"height",32),h=new o(this.scene,e,i,s,a);return n(this.scene,h,t),h})},function(t,e,i){var n=i(11),s=i(8),r=i(2),o=i(133);n.register("particles",function(t){var e=s(t,"key",null),i=s(t,"frame",null),n=r(t,"emitters",null),a=new o(this.scene,e,i,n);return r(t,"add",!1)&&this.displayList.add(a),this.updateList.add(a),a})},function(t,e,i){var n=i(22),s=i(11),r=i(8),o=i(72);s.register("image",function(t){var e=r(t,"key",null),i=r(t,"frame",null),s=new o(this.scene,0,0,e,i);return n(this.scene,s,t),s})},function(t,e,i){var n=i(11),s=i(73);n.register("group",function(t){return new s(this.scene,null,t)})},function(t,e,i){var n=i(11),s=i(136);n.register("graphics",function(t){return new s(this.scene,t)})},function(t,e,i){var n=i(137),s=i(22),r=i(11),o=i(8);r.register("dynamicBitmapText",function(t){var e=o(t,"font",""),i=o(t,"text",""),r=o(t,"size",!1),a=o(t,"align","left"),h=new n(this.scene,0,0,e,i,r,a);return s(this.scene,h,t),h})},function(t,e,i){var n=i(138),s=i(22),r=i(11),o=i(8);r.register("blitter",function(t){var e=o(t,"key",null),i=o(t,"frame",null),r=new n(this.scene,0,0,e,i);return s(this.scene,r,t),r})},function(t,e,i){var n=i(106);i(9).register("zone",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(129);i(9).register("tileSprite",function(t,e,i,s,r,o){return this.displayList.add(new n(this.scene,t,e,i,s,r,o))})},function(t,e,i){var n=i(130);i(9).register("text",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(139);i(9).register("bitmapText",function(t,e,i,s,r){return this.displayList.add(new n(this.scene,t,e,i,s,r))})},function(t,e,i){var n=i(9),s=i(40);n.register("sprite",function(t,e,i,n){var r=new s(this.scene,t,e,i,n);return this.displayList.add(r),this.updateList.add(r),r})},function(t,e,i){var n=i(101);i(9).register("sprite3D",function(t,e,i,s,r){var o=new n(this.scene,t,e,i,s,r);return this.displayList.add(o.gameObject),this.updateList.add(o.gameObject),o})},function(t,e,i){var n=i(9),s=i(131);n.register("renderTexture",function(t,e,i,n){return this.displayList.add(new s(this.scene,t,e,i,n))})},function(t,e,i){var n=i(9),s=i(249);n.register("follower",function(t,e,i,n,r){var o=new s(this.scene,t,e,i,n,r);return this.displayList.add(o),this.updateList.add(o),o})},function(t,e,i){var n=i(9),s=i(133);n.register("particles",function(t,e,i){var n=new s(this.scene,t,e,i);return this.displayList.add(n),this.updateList.add(n),n})},function(t,e,i){var n=i(72);i(9).register("image",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(73);i(9).register("group",function(t,e){return"object"==typeof t&&void 0===e&&(e=t,t=[]),this.updateList.add(new n(this.scene,t,e))})},function(t,e,i){var n=i(136);i(9).register("graphics",function(t){return this.displayList.add(new n(this.scene,t))})},function(t,e,i){var n=i(137);i(9).register("dynamicBitmapText",function(t,e,i,s,r){return this.displayList.add(new n(this.scene,t,e,i,s,r))})},function(t,e,i){var n=i(138);i(9).register("blitter",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){var r=t.currentContext,o=e.frame;e.updateTileTexture(),t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,r.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,r.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var a=o.x-e.originX*e.width,h=o.y-e.originY*e.height,u=e.x-s.scrollX*e.scrollFactorX,l=e.y-s.scrollY*e.scrollFactorY,c=1,d=1;e.flipX&&(c=-1,a+=e.width),e.flipY&&(d=-1,h+=e.height),t.config.roundPixels&&(a|=0,h|=0,u|=0,l|=0),r.save(),r.translate(a,h),r.translate(u,l),r.scale(c,d),r.translate(e.originX*e.width,e.originY*e.height),r.rotate(c*d*e.rotation),r.scale(this.scaleX,this.scaleY),r.translate(-e.originX*e.width,-e.originY*e.height),r.translate(-this.tilePositionX,-this.tilePositionY),r.fillStyle=e.canvasPattern,r.fillRect(this.tilePositionX,this.tilePositionY,e.width,e.height),r.restore()}}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||(e.updateTileTexture(),this.pipeline.batchTileSprite(this,s))}},function(t,e,i){var n=i(3),s=i(3);n=i(699),s=i(698),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(23);t.exports=function(t){var e=n.create(this),i=e.getContext("2d");t.syncFont(e,i);var s=Math.ceil(i.measureText(t.testString).width*t.baselineX),r=s,o=2*r;r=r*t.baselineY|0,e.width=s,e.height=o,i.fillStyle="#f00",i.fillRect(0,0,s,o),i.font=t._font,i.textBaseline="alphabetic",i.fillStyle="#000",i.fillText(t.testString,0,r);var a={ascent:0,descent:0,fontSize:0};if(!i.getImageData(0,0,s,o))return a.ascent=r,a.descent=r+6,a.fontSize=a.ascent+a.descent,n.remove(e),a;var h,u,l=i.getImageData(0,0,s,o).data,c=l.length,d=4*s,f=0,p=!1;for(h=0;hr;h--){for(u=0;u0&&e.cameraFilter&s._id||""===e.text)){var r=t.currentContext;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,r.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,r.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var o=e.canvas;r.save();var a=e.x-s.scrollX*e.scrollFactorX,h=e.y-s.scrollY*e.scrollFactorY;t.config.roundPixels&&(a|=0,h|=0),r.translate(a,h),r.rotate(e.rotation),r.scale(e.scaleX,e.scaleY),r.translate(o.width*(e.flipX?1:0),o.height*(e.flipY?1:0)),r.scale(e.flipX?-1:1,e.flipY?-1:1),r.drawImage(o,0,0,o.width,o.height,-e.displayOriginX,-e.displayOriginY,o.width,o.height),r.restore()}}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||""===e.text||(e.dirty&&(e.canvasTexture=t.canvasToTexture(e.canvas,e.canvasTexture,!0,e.scaleMode),e.dirty=!1),this.pipeline.batchText(this,s))}},function(t,e,i){var n=i(3),s=i(3);n=i(704),s=i(703),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e){t.exports=function(t,e,i){var n=t.canvas,s=t.context,r=t.style,o=[],a=0,h=i.length;r.maxLines>0&&r.maxLinesc&&(f=-c),0!==f&&(d+=f>0?f*i.length:f*(i.length-1)),{width:a,height:d,lines:h,lineWidths:o,lineSpacing:f,lineHeight:c}}},function(t,e){t.exports={fill:function(t){var e=255&(t>>16|0),i=255&(t>>8|0),n=255&(0|t);this.renderer.setFramebuffer(this.framebuffer);var s=this.gl;return s.clearColor(e/255,i/255,n/255,1),s.clear(s.COLOR_BUFFER_BIT),this.renderer.setFramebuffer(null),this},clear:function(){this.renderer.setFramebuffer(this.framebuffer);var t=this.gl;return t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),this.renderer.setFramebuffer(null),this},draw:function(t,e,i,n){var s=t.source[e.sourceIndex].glTexture,r=(this.globalTint>>16)+(65280&this.globalTint)+((255&this.globalTint)<<16);return this.renderer.setFramebuffer(this.framebuffer),this.renderer.pipelines.TextureTintPipeline.drawTexture(s,i,n,r,this.globalAlpha,e.cutX,e.cutY,e.cutWidth,e.cutHeight,this.currentMatrix),this.renderer.setFramebuffer(null),this}}},function(t,e){t.exports={fill:function(t){var e=255&(t>>16|0),i=255&(t>>8|0),n=255&(0|t);return this.context.fillStyle="rgb("+e+","+i+","+n+")",this.context.fillRect(0,0,this.canvas.width,this.canvas.height),this},clear:function(){return this.context.save(),this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.restore(),this},draw:function(t,e,i,n){var s=this.currentMatrix;return this.context.globalAlpha=this.globalAlpha,this.context.setTransform(s[0],s[1],s[2],s[3],s[4],s[5]),this.context.drawImage(t.source[e.sourceIndex].image,e.cutX,e.cutY,e.cutWidth,e.cutHeight,i,n,e.cutWidth,e.cutWidth),this}}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){var r=t.currentContext;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,r.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,r.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var o=0,a=0,h=1,u=1;e.flipX?(h=-1,o-=e.canvas.width-e.displayOriginX):o-=e.displayOriginX,e.flipY?(u=-1,a-=e.canvas.height-e.displayOriginY):a-=e.displayOriginY,r.save(),r.translate(e.x-s.scrollX*e.scrollFactorX,e.y-s.scrollY*e.scrollFactorY),r.rotate(e.rotation),r.scale(e.scaleX,e.scaleY),r.scale(h,u),r.drawImage(e.canvas,o,a),r.restore()}}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchTexture(e,e.texture,e.texture.width,e.texture.height,e.x,e.y,e.width,e.height,e.scaleX,e.scaleY,e.rotation,e.flipX,e.flipY,e.scrollFactorX,e.scrollFactorY,e.displayOriginX,e.displayOriginY,0,0,e.texture.width,e.texture.height,4294967295,4294967295,4294967295,4294967295,0,0,s)}},function(t,e,i){var n=i(3),s=i(3);n=i(710),s=i(709),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){var r=e.emitters.list;if(!(0===r.length||n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id))for(var o=0;o>24&255)/255;if(!(y<=0)){var m=v.frame,x=.5*m.width,w=.5*m.height,b=m.canvasData,T=-x,A=-w,S=v.x-d*v.scrollFactorX,C=v.y-f*v.scrollFactorY;p&&(S|=0,C|=0),l.globalAlpha=y,l.save(),l.translate(S,C),l.rotate(v.rotation),l.scale(v.scaleX,v.scaleY),l.drawImage(m.source.image,b.sx,b.sy,b.sWidth,b.sHeight,T,A,b.dWidth,b.dHeight),l.restore()}}l.globalAlpha=c}}}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){0===e.emitters.length||n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.drawEmitterManager(e,s)}},function(t,e,i){var n=i(3),s=i(3);n=i(713),s=i(712),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(0),s=i(6),r=new n({initialize:function(t){this.source=t,this._tempVec=new s},getPoint:function(t){var e=this._tempVec;this.source.getRandomPoint(e),t.x=e.x,t.y=e.y}});t.exports=r},function(t,e,i){var n=i(0),s=i(42),r=i(48),o=new n({initialize:function(t){this.emitter=t,this.frame=null,this.index=0,this.x=0,this.y=0,this.velocityX=0,this.velocityY=0,this.accelerationX=0,this.accelerationY=0,this.maxVelocityX=1e4,this.maxVelocityY=1e4,this.bounce=0,this.scaleX=1,this.scaleY=1,this.alpha=1,this.angle=0,this.rotation=0,this.scrollFactorX=1,this.scrollFactorY=1,this.tint=4294967295,this.color=4294967295,this.life=1e3,this.lifeCurrent=1e3,this.delayCurrent=0,this.lifeT=0,this.data={tint:{min:16777215,max:16777215,current:16777215},alpha:{min:1,max:1},rotate:{min:0,max:0},scaleX:{min:1,max:1},scaleY:{min:1,max:1}}},isAlive:function(){return this.lifeCurrent>0},fire:function(t,e){var i=this.emitter;this.frame=i.getFrame(),i.emitZone&&i.emitZone.getPoint(this),void 0===t?(i.follow&&(this.x+=i.follow.x+i.followOffset.x),this.x+=i.x.onEmit(this,"x")):this.x+=t,void 0===e?(i.follow&&(this.y+=i.follow.y+i.followOffset.y),this.y+=i.y.onEmit(this,"y")):this.y+=e,this.life=i.lifespan.onEmit(this,"lifespan"),this.lifeCurrent=this.life,this.lifeT=0;var n=i.speedX.onEmit(this,"speedX"),o=i.speedY?i.speedY.onEmit(this,"speedY"):n;if(i.radial){var a=s(i.angle.onEmit(this,"angle"));this.velocityX=Math.cos(a)*Math.abs(n),this.velocityY=Math.sin(a)*Math.abs(o)}else if(i.moveTo){var h=i.moveToX.onEmit(this,"moveToX"),u=i.moveToY?i.moveToY.onEmit(this,"moveToY"):h,l=Math.atan2(u-this.y,h-this.x),c=r(this.x,this.y,h,u)/(this.life/1e3);this.velocityX=Math.cos(l)*c,this.velocityY=Math.sin(l)*c}else this.velocityX=n,this.velocityY=o;i.acceleration&&(this.accelerationX=i.accelerationX.onEmit(this,"accelerationX"),this.accelerationY=i.accelerationY.onEmit(this,"accelerationY")),this.maxVelocityX=i.maxVelocityX.onEmit(this,"maxVelocityX"),this.maxVelocityY=i.maxVelocityY.onEmit(this,"maxVelocityY"),this.delayCurrent=i.delay.onEmit(this,"delay"),this.scaleX=i.scaleX.onEmit(this,"scaleX"),this.scaleY=i.scaleY?i.scaleY.onEmit(this,"scaleY"):this.scaleX,this.angle=i.rotate.onEmit(this,"rotate"),this.rotation=s(this.angle),this.bounce=i.bounce.onEmit(this,"bounce"),this.alpha=i.alpha.onEmit(this,"alpha"),this.tint=i.tint.onEmit(this,"tint"),this.color=16777215&this.tint|(255*this.alpha|0)<<24,this.index=i.alive.length},computeVelocity:function(t,e,i,n){var s=this.velocityX,r=this.velocityY,o=this.accelerationX,a=this.accelerationY,h=this.maxVelocityX,u=this.maxVelocityY;s+=t.gravityX*i,r+=t.gravityY*i,o&&(s+=o*i),a&&(r+=a*i),s>h?s=h:s<-h&&(s=-h),r>u?r=u:r<-u&&(r=-u),this.velocityX=s,this.velocityY=r;for(var l=0;le.right&&t.collideRight&&(this.x=e.right,this.velocityX*=i),this.ye.bottom&&t.collideBottom&&(this.y=e.bottom,this.velocityY*=i)},update:function(t,e,i){if(this.delayCurrent>0)return this.delayCurrent-=t,!1;var n=this.emitter,r=1-this.lifeCurrent/this.life;return this.lifeT=r,this.computeVelocity(n,t,e,i),this.x+=this.velocityX*e,this.y+=this.velocityY*e,n.bounds&&this.checkBounds(n),n.deathZone&&n.deathZone.willKill(this)?(this.lifeCurrent=0,!0):(this.scaleX=n.scaleX.onUpdate(this,"scaleX",r,this.scaleX),n.scaleY?this.scaleY=n.scaleY.onUpdate(this,"scaleY",r,this.scaleY):this.scaleY=this.scaleX,this.angle=n.rotate.onUpdate(this,"rotate",r,this.angle),this.rotation=s(this.angle),this.alpha=n.alpha.onUpdate(this,"alpha",r,this.alpha),this.tint=n.tint.onUpdate(this,"tint",r,this.tint),this.color=16777215&this.tint|(255*this.alpha|0)<<24,this.lifeCurrent-=t,this.lifeCurrent<=0)}});t.exports=o},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1),t<=0?0:t>=1?1:1/e*(1+(e*t|0))}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:.5*(1-Math.cos(Math.PI*t))}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:Math.sin(t*Math.PI/2)}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:1-Math.cos(t*Math.PI/2)}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},function(t,e){t.exports=function(t){return--t*t*t*t*t+1}},function(t,e){t.exports=function(t){return t*t*t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},function(t,e){t.exports=function(t){return 1- --t*t*t*t}},function(t,e){t.exports=function(t){return t*t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},function(t,e){t.exports=function(t){return t*(2-t)}},function(t,e){t.exports=function(t){return t*t}},function(t,e){t.exports=function(t){return t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*(t-1)))}},function(t,e){t.exports=function(t){return 1-Math.pow(2,-10*t)}},function(t,e){t.exports=function(t){return Math.pow(2,10*(t-1))-.001}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),(t*=2)<1?e*Math.pow(2,10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)*-.5:e*Math.pow(2,-10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)*.5+1}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),e*Math.pow(2,-10*t)*Math.sin((t-n)*(2*Math.PI)/i)+1}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),-e*Math.pow(2,10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},function(t,e){t.exports=function(t){return--t*t*t+1}},function(t,e){t.exports=function(t){return t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},function(t,e){t.exports=function(t){return Math.sqrt(1- --t*t)}},function(t,e){t.exports=function(t){return 1-Math.sqrt(1-t*t)}},function(t,e){t.exports=function(t){var e=!1;return t<.5?(t=1-2*t,e=!0):t=2*t-1,t<1/2.75?t*=7.5625*t:t=t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375,e?.5*(1-t):.5*t+.5}},function(t,e){t.exports=function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},function(t,e){t.exports=function(t){return(t=1-t)<1/2.75?1-7.5625*t*t:t<2/2.75?1-(7.5625*(t-=1.5/2.75)*t+.75):t<2.5/2.75?1-(7.5625*(t-=2.25/2.75)*t+.9375):1-(7.5625*(t-=2.625/2.75)*t+.984375)}},function(t,e){t.exports=function(t,e){void 0===e&&(e=1.70158);var i=1.525*e;return(t*=2)<1?t*t*((i+1)*t-i)*.5:.5*((t-=2)*t*((i+1)*t+i)+2)}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1.70158),--t*t*((e+1)*t+e)+1}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1.70158),t*t*((e+1)*t-e)}},function(t,e,i){var n=i(262),s=i(261),r=i(260),o=i(259),a=i(258),h=i(257),u=i(256),l=i(255),c=i(254),d=i(253),f=i(252),p=i(251);t.exports={Power0:u,Power1:l.Out,Power2:o.Out,Power3:c.Out,Power4:d.Out,Linear:u,Quad:l.Out,Cubic:o.Out,Quart:c.Out,Quint:d.Out,Sine:f.Out,Expo:h.Out,Circ:r.Out,Elastic:a.Out,Back:n.Out,Bounce:s.Out,Stepped:p,"Quad.easeIn":l.In,"Cubic.easeIn":o.In,"Quart.easeIn":c.In,"Quint.easeIn":d.In,"Sine.easeIn":f.In,"Expo.easeIn":h.In,"Circ.easeIn":r.In,"Elastic.easeIn":a.In,"Back.easeIn":n.In,"Bounce.easeIn":s.In,"Quad.easeOut":l.Out,"Cubic.easeOut":o.Out,"Quart.easeOut":c.Out,"Quint.easeOut":d.Out,"Sine.easeOut":f.Out,"Expo.easeOut":h.Out,"Circ.easeOut":r.Out,"Elastic.easeOut":a.Out,"Back.easeOut":n.Out,"Bounce.easeOut":s.Out,"Quad.easeInOut":l.InOut,"Cubic.easeInOut":o.InOut,"Quart.easeInOut":c.InOut,"Quint.easeInOut":d.InOut,"Sine.easeInOut":f.InOut,"Expo.easeInOut":h.InOut,"Circ.easeInOut":r.InOut,"Elastic.easeInOut":a.InOut,"Back.easeInOut":n.InOut,"Bounce.easeInOut":s.InOut}},function(t,e,i){var n=i(0),s=i(263),r=i(71),o=i(2),a=i(43),h=new n({initialize:function(t,e,i,n){void 0===n&&(n=!1),this.propertyKey=e,this.propertyValue=i,this.defaultValue=i,this.steps=0,this.counter=0,this.start=0,this.end=0,this.ease,this.emitOnly=n,this.onEmit=this.defaultEmit,this.onUpdate=this.defaultUpdate,this.loadConfig(t)},loadConfig:function(t,e){void 0===t&&(t={}),e&&(this.propertyKey=e),this.propertyValue=o(t,this.propertyKey,this.defaultValue),this.setMethods(),this.emitOnly&&(this.onUpdate=this.defaultUpdate)},toJSON:function(){return JSON.stringify(this.propertyValue)},onChange:function(t){return this.propertyValue=t,this.setMethods()},setMethods:function(){var t=this.propertyValue,e=typeof t;if("number"===e)this.onEmit=this.staticValueEmit,this.onUpdate=this.staticValueUpdate;else if(Array.isArray(t))this.onEmit=this.randomStaticValueEmit;else if("function"===e)this.emitOnly?this.onEmit=t:this.onUpdate=t;else if("object"===e&&(this.has(t,"random")||this.hasBoth(t,"start","end")||this.hasBoth(t,"min","max"))){this.start=this.has(t,"start")?t.start:t.min,this.end=this.has(t,"end")?t.end:t.max;var i=this.hasBoth(t,"min","max")||this.has(t,"random");if(i){var n=t.random;Array.isArray(n)&&(this.start=n[0],this.end=n[1]),this.onEmit=this.randomRangedValueEmit}if(this.has(t,"steps"))this.steps=t.steps,this.counter=this.start,this.onEmit=this.steppedEmit;else{var s=this.has(t,"ease")?t.ease:"Linear";this.ease=r(s),i||(this.onEmit=this.easedValueEmit),this.onUpdate=this.easeValueUpdate}}else"object"===e&&this.hasEither(t,"onEmit","onUpdate")&&(this.has(t,"onEmit")&&(this.onEmit=t.onEmit),this.has(t,"onUpdate")&&(this.onUpdate=t.onUpdate));return this},has:function(t,e){return t.hasOwnProperty(e)},hasBoth:function(t,e,i){return t.hasOwnProperty(e)&&t.hasOwnProperty(i)},hasEither:function(t,e,i){return t.hasOwnProperty(e)||t.hasOwnProperty(i)},defaultEmit:function(t,e,i){return i},defaultUpdate:function(t,e,i,n){return n},staticValueEmit:function(){return this.propertyValue},staticValueUpdate:function(){return this.propertyValue},randomStaticValueEmit:function(){var t=Math.floor(Math.random()*this.propertyValue.length);return this.propertyValue[t]},randomRangedValueEmit:function(t,e){var i=s(this.start,this.end);return t&&t.data[e]&&(t.data[e].min=i),i},steppedEmit:function(){var t=this.counter,e=this.counter+(this.end-this.start)/this.steps;return this.counter=a(e,this.start,this.end),t},easedValueEmit:function(t,e){if(t&&t.data[e]){var i=t.data[e];i.min=this.start,i.max=this.end}return this.start},easeValueUpdate:function(t,e,i){var n=t.data[e];return(n.max-n.min)*this.ease(i)+n.min}});t.exports=h},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s){void 0===n&&(n=!1),void 0===s&&(s=!0),this.source=t,this.points=[],this.quantity=e,this.stepRate=i,this.yoyo=n,this.counter=-1,this.seamless=s,this._length=0,this._direction=0,this.updateSource()},updateSource:function(){if(this.points=this.source.getPoints(this.quantity,this.stepRate),this.seamless){var t=this.points[0],e=this.points[this.points.length-1];t.x===e.x&&t.y===e.y&&this.points.pop()}var i=this._length;return this._length=this.points.length,this._lengththis._length&&(this.counter=this._length-1),this},changeSource:function(t){return this.source=t,this.updateSource()},getPoint:function(t){0===this._direction?(this.counter++,this.counter>=this._length&&(this.yoyo?(this._direction=1,this.counter=this._length-1):this.counter=0)):(this.counter--,-1===this.counter&&(this.yoyo?(this._direction=0,this.counter=0):this.counter=this._length-1));var e=this.points[this.counter];e&&(t.x=e.x,t.y=e.y)}});t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.source=t,this.killOnEnter=e},willKill:function(t){var e=this.source.contains(t.x,t.y);return e&&this.killOnEnter||!e&&!this.killOnEnter}});t.exports=n},function(t,e,i){var n=i(62),s=i(0),r=i(13),o=i(752),a=i(751),h=i(750),u=i(2),l=i(132),c=i(250),d=i(70),f=i(716),p=i(715),g=i(10),v=i(272),y=i(6),m=i(43),x=new s({Mixins:[r.BlendMode,r.ScrollFactor,r.Visible],initialize:function(t,e){this.manager=t,this.texture=t.texture,this.frames=[t.defaultFrame],this.defaultFrame=t.defaultFrame,this.configFastMap=["active","blendMode","collideBottom","collideLeft","collideRight","collideTop","deathCallback","deathCallbackScope","emitCallback","emitCallbackScope","follow","frequency","gravityX","gravityY","maxParticles","name","on","particleBringToTop","particleClass","radial","timeScale","trackVisible","visible"],this.configOpMap=["accelerationX","accelerationY","alpha","bounce","delay","lifespan","maxVelocityX","maxVelocityY","moveToX","moveToY","quantity","rotate","scaleX","scaleY","speedX","speedY","tint","x","y"],this.name="",this.particleClass=f,this.x=new h(e,"x",0),this.y=new h(e,"y",0),this.radial=!0,this.gravityX=0,this.gravityY=0,this.acceleration=!1,this.accelerationX=new h(e,"accelerationX",0,!0),this.accelerationY=new h(e,"accelerationY",0,!0),this.maxVelocityX=new h(e,"maxVelocityX",1e4,!0),this.maxVelocityY=new h(e,"maxVelocityY",1e4,!0),this.speedX=new h(e,"speedX",0,!0),this.speedY=new h(e,"speedY",0,!0),this.moveTo=!1,this.moveToX=new h(e,"moveToX",0,!0),this.moveToY=new h(e,"moveToY",0,!0),this.bounce=new h(e,"bounce",0,!0),this.scaleX=new h(e,"scaleX",1),this.scaleY=new h(e,"scaleY",1),this.tint=new h(e,"tint",4294967295),this.alpha=new h(e,"alpha",1),this.lifespan=new h(e,"lifespan",1e3),this.angle=new h(e,"angle",{min:0,max:360}),this.rotate=new h(e,"rotate",0),this.emitCallback=null,this.emitCallbackScope=null,this.deathCallback=null,this.deathCallbackScope=null,this.maxParticles=0,this.quantity=new h(e,"quantity",1,!0),this.delay=new h(e,"delay",0,!0),this.frequency=0,this.on=!0,this.particleBringToTop=!0,this.timeScale=1,this.emitZone=null,this.deathZone=null,this.bounds=null,this.collideLeft=!0,this.collideRight=!0,this.collideTop=!0,this.collideBottom=!0,this.active=!0,this.visible=!0,this.blendMode=n.NORMAL,this.follow=null,this.followOffset=new y,this.trackVisible=!1,this.currentFrame=0,this.randomFrame=!0,this.frameQuantity=1,this.dead=[],this.alive=[],this._counter=0,this._frameCounter=0,e&&this.fromJSON(e)},fromJSON:function(t){if(!t)return this;var e=0,i="";for(e=0;e0&&this.getParticleCount()===this.maxParticles},onParticleEmit:function(t,e){return void 0===t?(this.emitCallback=null,this.emitCallbackScope=null):"function"==typeof t&&(this.emitCallback=t,e&&(this.emitCallbackScope=e)),this},onParticleDeath:function(t,e){return void 0===t?(this.deathCallback=null,this.deathCallbackScope=null):"function"==typeof t&&(this.deathCallback=t,e&&(this.deathCallbackScope=e)),this},killAll:function(){for(var t=this.dead,e=this.alive;e.length>0;)t.push(e.pop());return this},forEachAlive:function(t,e){for(var i=this.alive,n=i.length,s=0;s0?n.pop():new this.particleClass(this)).fire(e,i),this.particleBringToTop?this.alive.push(r):this.alive.unshift(r),this.emitCallback&&this.emitCallback.call(this.emitCallbackScope,r,this),this.atLimit())break}return r}},preUpdate:function(t,e){var i=(e*=this.timeScale)/1e3;this.trackVisible&&(this.visible=this.follow.visible);for(var n=this.manager.getProcessors(),s=this.alive,r=s.length,o=0;o0){var l=s.splice(s.length-u,u),c=this.deathCallback,d=this.deathCallbackScope;if(c)for(var f=0;f0&&(this._counter-=e,this._counter<=0&&(this.emitParticle(),this._counter=this.frequency-Math.abs(this._counter))))},depthSortCallback:function(t,e){return t.y-e.y},indexSortCallback:function(t,e){return t.index-e.index}});t.exports=x},function(t,e,i){var n=i(0),s=i(2),r=new n({initialize:function(t,e,i,n,r){if("object"==typeof t){var o=t;t=s(o,"x",0),e=s(o,"y",0),i=s(o,"power",0),n=s(o,"epsilon",100),r=s(o,"gravity",50)}else void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=100),void 0===r&&(r=50);this.x=t,this.y=e,this.active=!0,this._gravity=r,this._power=0,this._epsilon=0,this.power=i,this.epsilon=n},update:function(t,e){var i=this.x-t.x,n=this.y-t.y,s=i*i+n*n;if(0!==s){var r=Math.sqrt(s);s0&&e.cameraFilter&s._id||t.drawImage(e,s)}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchSprite(e,s)}},function(t,e,i){var n=i(3),s=i(3);n=i(756),s=i(755),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchGraphics(this,s)}},function(t,e,i){var n=i(3),s=i(3);n=i(758),s=i(265),s=i(265),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e,i){var n=i(10);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.left,e.y=t.top,e.width=t.width,e.height=t.height,e}},function(t,e){t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}},function(t,e){t.exports=function(t,e){return e.setTo(t.x,t.y,t.width,t.height)}},function(t,e,i){var n=i(74);t.exports=function(t,e){return n(t,e.x,e.y)&&n(t,e.right,e.y)&&n(t,e.x,e.bottom)&&n(t,e.right,e.bottom)}},function(t,e,i){var n=i(74);t.exports=function(t,e){return n(t,e.x,e.y)}},function(t,e,i){var n=i(135);t.exports=function(t){return new n(t.x,t.y,t.width,t.height)}},function(t,e){t.exports=function(t){return t.isEmpty()?0:t.getMajorRadius()*t.getMinorRadius()*Math.PI}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){var r=e.text,o=r.length;if(!(n.RENDER_MASK!==e.renderFlags||0===o||e.cameraFilter>0&&e.cameraFilter&s._id)){var a=e.frame,h=e.displayCallback,u=s.scrollX*e.scrollFactorX,l=s.scrollY*e.scrollFactorY,c=e.fontData.chars,d=e.fontData.lineHeight,f=0,p=0,g=0,v=0,y=null,m=0,x=0,w=0,b=0,T=0,A=0,S=null,C=0,M=t.currentContext,E=e.frame.source.image,_=a.cutX,L=a.cutY,P=0,F=e.fontSize/e.fontData.size;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,M.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,M.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode),M.save(),M.translate(e.x,e.y),M.rotate(e.rotation),M.translate(-e.displayOriginX,-e.displayOriginY),M.scale(e.scaleX,e.scaleY),e.cropWidth>0&&e.cropHeight>0&&(M.save(),M.beginPath(),M.rect(0,0,e.cropWidth,e.cropHeight),M.clip());for(var k=t.config.roundPixels,R=0;R0&&e.cropHeight>0&&M.restore(),M.restore()}}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){var r=e.text.length;n.RENDER_MASK!==e.renderFlags||0===r||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchDynamicBitmapText(e,s)}},function(t,e,i){var n=i(3),s=i(3);n=i(770),s=i(769),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s){this.parent=t,this.x=e,this.y=i,this.frame=n,this.data={},this._visible=s,this._alpha=1,this.flipX=!1,this.flipY=!1},setFrame:function(t){return t=void 0===t?this.parent.frame:this.parent.texture.get(t),this},resetFlip:function(){return this.flipX=!1,this.flipY=!1,this},reset:function(t,e,i){return this.x=t,this.y=e,this.frame=i,this},setFlipX:function(t){return this.flipX=t,this},setFlipY:function(t){return this.flipY=t,this},setFlip:function(t,e){return this.flipX=t,this.flipY=e,this},setVisible:function(t){return this.visible=t,this},setAlpha:function(t){return this.alpha=t,this},destroy:function(){this.parent.dirty=!0,this.parent.children.remove(this),this.parent=void 0,this.frame=void 0,this.data=void 0},visible:{get:function(){return this._visible},set:function(t){this._visible=t,this.parent.dirty=!0}},alpha:{get:function(){return this._alpha},set:function(t){this._alpha=t,this.parent.dirty=!0}}});t.exports=n},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){var r=e.getRenderList();t.setBlendMode(e.blendMode);for(var o=t.gameContext,a=e.x-s.scrollX*e.scrollFactorX,h=e.y-s.scrollY*e.scrollFactorY,u=0;u0&&e.cameraFilter&s._id||this.pipeline.drawBlitter(e,s)}},function(t,e,i){var n=i(3),s=i(3);n=i(774),s=i(773),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){var r=e.text,o=r.length;if(!(n.RENDER_MASK!==e.renderFlags||0===o||e.cameraFilter>0&&e.cameraFilter&s._id)){var a=e.frame,h=e.fontData.chars,u=e.fontData.lineHeight,l=0,c=0,d=0,f=0,p=null,g=0,v=0,y=0,m=0,x=0,w=0,b=null,T=0,A=t.currentContext,S=e.frame.source.image,C=a.cutX,M=a.cutY,E=e.fontSize/e.fontData.size;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,A.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,A.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var _=t.config.roundPixels,L=e.x-s.scrollX*e.scrollFactorX+e.frame.x,P=e.y-s.scrollY*e.scrollFactorY+e.frame.y;_&&(L|=0,P|=0),A.save(),A.translate(L,P),A.rotate(e.rotation),A.translate(-e.displayOriginX,-e.displayOriginY),A.scale(e.scaleX,e.scaleY);for(var F=0;F0&&e.cameraFilter&s._id||this.pipeline.batchBitmapText(this,s)}},function(t,e,i){var n=i(3),s=i(3);n=i(777),s=i(776),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(5),s=function(t,e){var i=e.width,s=e.height,r=Math.floor(i/2),o=Math.floor(s/2),a=e.chars,h=n(e,"image",""),u=n(e,"offset.x",0),l=n(e,"offset.y",0),c=n(e,"spacing.x",0),d=n(e,"spacing.y",0),f=n(e,"charsPerRow",null);null===f&&(f=t.sys.textures.getFrame(h).width/i)>a.length&&(f=a.length);for(var p=u,g=l,v={retroFont:!0,font:h,size:i,lineHeight:s,chars:{}},y=0,m=0;m?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",s.TEXT_SET2=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ",s.TEXT_SET3="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",s.TEXT_SET4="ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",s.TEXT_SET5="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789",s.TEXT_SET6="ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ",s.TEXT_SET7="AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39",s.TEXT_SET8="0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ",s.TEXT_SET9="ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!",s.TEXT_SET10="ABCDEFGHIJKLMNOPQRSTUVWXYZ",s.TEXT_SET11="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789",t.exports=s},function(t,e,i){var n=i(270);t.exports=function(t,e,i,s,r,o,a){var h=t.sys.textures.getFrame(i,s),u=t.sys.cache.xml.get(r);if(h&&u){var l=n(u,o,a,h);return t.sys.cache.bitmapFont.add(e,{data:l,texture:i,frame:s}),!0}return!1}},function(t,e,i){var n=i(0),s=i(12),r=new n({initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),this._list=[],this._pendingInsertion=[],this._pendingRemoval=[]},boot:function(){var t=this.systems.events;t.on("preupdate",this.preUpdate,this),t.on("update",this.update,this),t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},add:function(t){return-1===this._list.indexOf(t)&&-1===this._pendingInsertion.indexOf(t)&&this._pendingInsertion.push(t),t},preUpdate:function(){var t=this._pendingRemoval.length,e=this._pendingInsertion.length;if(0!==t||0!==e){var i,n;for(i=0;i-1&&this._list.splice(s,1)}this._list=this._list.concat(this._pendingInsertion.splice(0)),this._pendingRemoval.length=0,this._pendingInsertion.length=0}},update:function(t,e){for(var i=0;i0||!this.inFocus)&&(this._coolDown--,s=Math.min(s,this._target)),s>this._min&&(s=i[e],s=Math.min(s,this._min)),i[e]=s,this.deltaIndex++,this.deltaIndex>n&&(this.deltaIndex=0);for(var r=0,o=0;othis.nextFpsUpdate&&(this.actualFps=.25*this.framesThisSecond+.75*this.actualFps,this.nextFpsUpdate=t+1e3,this.framesThisSecond=0),this.framesThisSecond++;var a=r/this._target;this.callback(t,r,a),this.lastTime=t},tick:function(){this.step(window.performance.now())},sleep:function(){this.running&&(this.raf.stop(),this.running=!1)},wake:function(t){this.running?this.sleep():t&&(this.startTime+=-this.lastTime+(this.lastTime=window.performance.now())),this.raf.start(this.step.bind(this),this.useRAF),this.running=!0,this.step(window.performance.now())},stop:function(){return this.running=!1,this.started=!1,this.raf.stop(),this},destroy:function(){this.stop(),this.callback=r,this.raf=null,this.game=null}});t.exports=a},function(t,e){var i=0,n=function(t,e,n,s){var r=i-s.y-s.height;t.add(n,e,s.x,r,s.width,s.height)};t.exports=function(t,e,s){var r=t.source[e];t.add("__BASE",e,0,0,r.width,r.height),i=r.height;for(var o=s.split("\n"),a=/^[ ]*(- )*(\w+)+[: ]+(.*)/,h="",u="",l={x:0,y:0,width:0,height:0},c=0;cx||a<-x)&&(a=0),a<0&&(a=x+a),-1!==h&&(x=a+(h+1));for(var M=u,E=u,_=0,L=e.sourceIndex,P=0;Pg||c<-g)&&(c=0),c<0&&(c=g+c),-1!==d&&(g=c+(d+1));for(var v=f,y=f,m=0,x=0,w=0;wr&&(m=b-r),T>o&&(x=T-o),t.add(w,e,i+v,s+y,h-m,u-x),(v+=h+p)+h>r&&(v=f,y+=u+p)}return t}},function(t,e){t.exports=function(t,e){if(["layers","tilewidth","tileheight","tileswide","tileshigh"].forEach(function(t){e[t]}),1===e.layers.length){for(var i=new Phaser.FrameData,n=e.tileheight,s=e.tilewidth,r=e.layers[0].tiles,o=0;o0&&e.maxKeyDelay>0){var r=e.timeLastMatched+e.maxKeyDelay;t.timeStamp<=r&&(s=!0,i=n(t,e))}else s=!0,i=n(t,e);return!s&&e.resetOnWrongKey&&(e.index=0,e.current=e.keyCodes[0]),i&&(e.timeLastMatched=t.timeStamp,e.matched=!0,e.timeMatched=t.timeStamp),i}},function(t,e){var i={available:!1,cancel:"",keyboard:!1,request:""};t.exports=function(){var t,e=["requestFullscreen","requestFullScreen","webkitRequestFullscreen","webkitRequestFullScreen","msRequestFullscreen","msRequestFullScreen","mozRequestFullScreen","mozRequestFullscreen"],n=document.createElement("div");for(t=0;t=9&&/Mac OS X (\d+)_(\d+)/.test(navigator.userAgent)){var i=parseInt(RegExp.$1,10),r=parseInt(RegExp.$2,10);(10===i&&r>=11||i>10)&&(s.dolby=!0)}}catch(t){}return s}()},function(t,e,i){var n=i(76),s=i(100),r={gamepads:!1,mspointer:!1,touch:!1,wheelEvent:null};t.exports=(("ontouchstart"in document.documentElement||navigator.maxTouchPoints&&navigator.maxTouchPoints>=1)&&(r.touch=!0),(navigator.msPointerEnabled||navigator.pointerEnabled)&&(r.mspointer=!0),navigator.getGamepads&&(r.gamepads=!0),n.cocoonJS||("onwheel"in window||s.ie&&"WheelEvent"in window?r.wheelEvent="wheel":"onmousewheel"in window?r.wheelEvent="mousewheel":s.firefox&&"MouseScrollEvent"in window&&(r.wheelEvent="DOMMouseScroll")),r)},function(t,e,i){t.exports={os:i(76),browser:i(100),features:i(146),input:i(807),audio:i(806),video:i(805),fullscreen:i(804),canvasFeatures:i(302)}},function(t,e,i){var n=i(21);t.exports=function(t){var e=t.config;if(!e.hideBanner){var i="WebGL";e.renderType===n.CANVAS?i="Canvas":e.renderType===n.HEADLESS&&(i="Headless");var s,r=e.audio,o=t.device.audio;if(s=!o.webAudio||r&&r.disableWebAudio?r&&r.noAudio||!o.webAudio&&!o.audioData?"No Audio":"HTML5 Audio":"Web Audio",t.device.browser.ie)window.console&&console.log("Phaser v"+n.VERSION+" / https://phaser.io");else{var a,h="",u=[h];Array.isArray(e.bannerBackgroundColor)?(e.bannerBackgroundColor.forEach(function(t){h=h.concat("%c "),u.push("background: "+t),a=t}),u[u.length-1]="color: "+e.bannerTextColor+"; background: "+a):(h=h.concat("%c "),u.push("color: "+e.bannerTextColor+"; background: "+e.bannerBackgroundColor)),u.push("background: #fff"),e.gameTitle&&(h=h.concat(e.gameTitle),e.gameVersion&&(h=h.concat(" v"+e.gameVersion)),e.hidePhaser||(h=h.concat(" / "))),e.hidePhaser||(h=h.concat("Phaser v"+n.VERSION+" ("+i+" | "+s+")")),h=h.concat(" %c "+e.gameURL),u[0]=h,console.log.apply(console,u)}}}},function(t,e){t.exports="#define SHADER_NAME PHASER_TEXTURE_TINT_VS\r\n\r\nprecision mediump float;\r\n\r\nuniform mat4 uProjectionMatrix;\r\nuniform mat4 uViewMatrix;\r\nuniform mat4 uModelMatrix;\r\n\r\nattribute vec2 inPosition;\r\nattribute vec2 inTexCoord;\r\nattribute vec4 inTint;\r\n\r\nvarying vec2 outTexCoord;\r\nvarying vec4 outTint;\r\n\r\nvoid main () \r\n{\r\n gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);\r\n outTexCoord = inTexCoord;\r\n outTint = inTint;\r\n}\r\n\r\n"},function(t,e){t.exports="#define SHADER_NAME PHASER_TEXTURE_TINT_FS\r\n\r\nprecision mediump float;\r\n\r\nuniform sampler2D uMainSampler;\r\n\r\nvarying vec2 outTexCoord;\r\nvarying vec4 outTint;\r\n\r\nvoid main() \r\n{\r\n vec4 texel = texture2D(uMainSampler, outTexCoord);\r\n texel *= vec4(outTint.rgb * outTint.a, outTint.a);\r\n gl_FragColor = texel;\r\n}\r\n"},function(t,e){t.exports="#define SHADER_NAME PHASER_FORWARD_DIFFUSE_FS\r\n\r\nprecision mediump float;\r\n\r\nstruct Light\r\n{\r\n vec2 position;\r\n vec3 color;\r\n float intensity;\r\n float radius;\r\n};\r\n\r\nconst int kMaxLights = %LIGHT_COUNT%;\r\n\r\nuniform vec4 uCamera; /* x, y, rotation, zoom */\r\nuniform vec2 uResolution;\r\nuniform sampler2D uMainSampler;\r\nuniform sampler2D uNormSampler;\r\nuniform vec3 uAmbientLightColor;\r\nuniform Light uLights[kMaxLights];\r\n\r\nvarying vec2 outTexCoord;\r\nvarying vec4 outTint;\r\n\r\nvoid main()\r\n{\r\n vec3 finalColor = vec3(0.0, 0.0, 0.0);\r\n vec4 color = texture2D(uMainSampler, outTexCoord) * vec4(outTint.rgb * outTint.a, outTint.a);\r\n vec3 normalMap = texture2D(uNormSampler, outTexCoord).rgb;\r\n vec3 normal = normalize(vec3(normalMap * 2.0 - 1.0));\r\n vec2 res = vec2(min(uResolution.x, uResolution.y)) * uCamera.w;\r\n\r\n for (int index = 0; index < kMaxLights; ++index)\r\n {\r\n Light light = uLights[index];\r\n vec3 lightDir = vec3((light.position.xy / res) - (gl_FragCoord.xy / res), 0.1);\r\n vec3 lightNormal = normalize(lightDir);\r\n float distToSurf = length(lightDir) * uCamera.w;\r\n float diffuseFactor = max(dot(normal, lightNormal), 0.0);\r\n float radius = (light.radius / res.x * uCamera.w) * uCamera.w;\r\n float attenuation = clamp(1.0 - distToSurf * distToSurf / (radius * radius), 0.0, 1.0);\r\n vec3 diffuse = light.color * diffuseFactor;\r\n finalColor += (attenuation * diffuse) * light.intensity;\r\n }\r\n\r\n vec4 colorOutput = vec4(uAmbientLightColor + finalColor, 1.0);\r\n gl_FragColor = color * vec4(colorOutput.rgb * colorOutput.a, colorOutput.a);\r\n\r\n}\r\n"},function(t,e){t.exports="#define SHADER_NAME PHASER_FLAT_TINT_VS\r\n\r\nprecision mediump float;\r\n\r\nuniform mat4 uProjectionMatrix;\r\nuniform mat4 uViewMatrix;\r\nuniform mat4 uModelMatrix;\r\n\r\nattribute vec2 inPosition;\r\nattribute vec4 inTint;\r\n\r\nvarying vec4 outTint;\r\n\r\nvoid main () {\r\n gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);\r\n outTint = inTint;\r\n}\r\n"},function(t,e){t.exports="#define SHADER_NAME PHASER_FLAT_TINT_FS\r\n\r\nprecision mediump float;\r\n\r\nvarying vec4 outTint;\r\n\r\nvoid main() {\r\n gl_FragColor = vec4(outTint.rgb * outTint.a, outTint.a);\r\n}\r\n"},function(t,e){t.exports="#define SHADER_NAME PHASER_BITMAP_MASK_VS\r\n\r\nprecision mediump float;\r\n\r\nattribute vec2 inPosition;\r\n\r\nvoid main()\r\n{\r\n gl_Position = vec4(inPosition, 0.0, 1.0);\r\n}\r\n"},function(t,e){t.exports="#define SHADER_NAME PHASER_BITMAP_MASK_FS\r\n\r\nprecision mediump float;\r\n\r\nuniform vec2 uResolution;\r\nuniform sampler2D uMainSampler;\r\nuniform sampler2D uMaskSampler;\r\nuniform bool uInvertMaskAlpha;\r\n\r\nvoid main()\r\n{\r\n vec2 uv = gl_FragCoord.xy / uResolution;\r\n vec4 mainColor = texture2D(uMainSampler, uv);\r\n vec4 maskColor = texture2D(uMaskSampler, uv);\r\n float alpha = mainColor.a;\r\n\r\n if (!uInvertMaskAlpha)\r\n {\r\n alpha *= (maskColor.a);\r\n }\r\n else\r\n {\r\n alpha *= (1.0 - maskColor.a);\r\n }\r\n \r\n gl_FragColor = vec4(mainColor.rgb * alpha, alpha);\r\n}\r\n"},function(t,e,i){var n=i(313),s=i(23),r=i(21),o=i(146);t.exports=function(t){var e,a,h=t.config;if(h.renderType!==r.HEADLESS)if(h.renderType===r.CANVAS||h.renderType!==r.CANVAS&&!o.webGL){if(!o.canvas)throw new Error("Cannot create Canvas or WebGL context, aborting.");h.renderType=r.CANVAS}else h.renderType=r.WEBGL;h.pixelArt&&s.disableSmoothing(),h.canvas?t.canvas=h.canvas:t.canvas=s.create(t,h.width,h.height,h.renderType),h.canvasStyle&&(t.canvas.style=h.canvasStyle),h.pixelArt&&n.setCrisp(t.canvas),1!==h.zoom&&(t.canvas.style.width=(h.width*h.zoom).toString()+"px",t.canvas.style.height=(h.height*h.zoom).toString()+"px"),h.renderType!==r.HEADLESS&&(e=i(380),a=i(375),h.renderType===r.WEBGL?(t.renderer=new a(t),t.context=null):(t.renderer=new e(t),t.context=t.renderer.gameContext))}},function(t,e,i){var n=i(0),s=i(21),r=i(5),o=i(16),a=i(3),h=i(303),u=i(156),l=new n({initialize:function(t){void 0===t&&(t={});this.width=r(t,"width",1024),this.height=r(t,"height",768),this.zoom=r(t,"zoom",1),this.resolution=r(t,"resolution",1),this.renderType=r(t,"type",s.AUTO),this.parent=r(t,"parent",null),this.canvas=r(t,"canvas",null),this.canvasStyle=r(t,"canvasStyle",null),this.sceneConfig=r(t,"scene",null),this.seed=r(t,"seed",[(Date.now()*Math.random()).toString()]),o.RND.init(this.seed),this.gameTitle=r(t,"title",""),this.gameURL=r(t,"url","https://phaser.io"),this.gameVersion=r(t,"version",""),this.inputKeyboard=r(t,"input.keyboard",!0),this.inputKeyboardEventTarget=r(t,"input.keyboard.target",window),this.inputMouse=r(t,"input.mouse",!0),this.inputMouseEventTarget=r(t,"input.mouse.target",null),this.inputMouseCapture=r(t,"input.mouse.capture",!0),this.inputTouch=r(t,"input.touch",!0),this.inputTouchEventTarget=r(t,"input.touch.target",null),this.inputTouchCapture=r(t,"input.touch.capture",!0),this.inputGamepad=r(t,"input.gamepad",!1),this.disableContextMenu=r(t,"disableContextMenu",!1),this.audio=r(t,"audio"),this.hideBanner=!1===r(t,"banner",null),this.hidePhaser=r(t,"banner.hidePhaser",!1),this.bannerTextColor=r(t,"banner.text","#ffffff"),this.bannerBackgroundColor=r(t,"banner.background",["#ff0000","#ffff00","#00ff00","#00ffff","#000000"]),""===this.gameTitle&&this.hidePhaser&&(this.hideBanner=!0),this.fps=r(t,"fps",null);var e=r(t,"render",t);this.antialias=r(e,"antialias",!0),this.pixelArt=r(e,"pixelArt",!1),this.autoResize=r(e,"autoResize",!1),this.roundPixels=r(e,"roundPixels",!1),this.transparent=r(e,"transparent",!1),this.clearBeforeRender=r(e,"clearBeforeRender",!0),this.premultipliedAlpha=r(e,"premultipliedAlpha",!0),this.preserveDrawingBuffer=r(e,"preserveDrawingBuffer",!1),this.failIfMajorPerformanceCaveat=r(e,"failIfMajorPerformanceCaveat",!1),this.powerPreference=r(e,"powerPreference","default");var i=r(t,"backgroundColor",0);this.backgroundColor=u(i),0===i&&this.transparent&&(this.backgroundColor.alpha=0),this.preBoot=r(t,"callbacks.preBoot",a),this.postBoot=r(t,"callbacks.postBoot",a),this.physics=r(t,"physics",{}),this.defaultPhysicsSystem=r(this.physics,"default",!1),this.loaderBaseURL=r(t,"loader.baseURL",""),this.loaderPath=r(t,"loader.path",""),this.loaderEnableParallel=r(t,"loader.enableParallel",!0),this.loaderMaxParallelDownloads=r(t,"loader.maxParallelDownloads",4),this.loaderCrossOrigin=r(t,"loader.crossOrigin",void 0),this.loaderResponseType=r(t,"loader.responseType",""),this.loaderAsync=r(t,"loader.async",!0),this.loaderUser=r(t,"loader.user",""),this.loaderPassword=r(t,"loader.password",""),this.loaderTimeout=r(t,"loader.timeout",0),this.defaultPlugins=r(t,"plugins",h.DefaultScene);var n="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAg";this.defaultImage=r(t,"images.default",n+"AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=="),this.missingImage=r(t,"images.missing",n+"CAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==")}});t.exports=l},function(t,e,i){var n=i(147),s=i(339),r=i(337),o=i(23),a=i(0),h=i(818),u=i(817),l=i(103),c=i(809),d=i(808),f=i(307),p=i(15),g=i(299),v=i(3),y=i(12),m=i(287),x=i(283),w=i(276),b=i(785),T=i(784),A=new a({initialize:function(t){this.config=new h(t),this.renderer=null,this.canvas=null,this.context=null,this.isBooted=!1,this.isRunning=!1,this.events=new p,this.anims=new s(this),this.textures=new w(this),this.cache=new r(this),this.registry=new l(this),this.input=new g(this,this.config),this.scene=new m(this,this.config.sceneConfig),this.device=d,this.sound=x.create(this),this.loop=new b(this,this.config.fps),this.plugins=new y(this,this.config),this.onStepCallback=v,f(this.boot.bind(this))},boot:function(){this.isBooted=!0,this.config.preBoot(this),u(this),c(this),n(this.canvas,this.config.parent),this.events.emit("boot"),this.events.once("ready",this.start,this)},start:function(){this.isRunning=!0,this.config.postBoot(this),this.renderer?this.loop.start(this.step.bind(this)):this.loop.start(this.headlessStep.bind(this)),T(this.events),this.events.on("hidden",this.onHidden,this),this.events.on("visible",this.onVisible,this),this.events.on("blur",this.onBlur,this),this.events.on("focus",this.onFocus,this)},step:function(t,e){this.input.update(t,e),this.sound.update(t,e),this.onStepCallback(),this.scene.update(t,e);var i=this.renderer;i.preRender(),this.events.emit("prerender",i),this.scene.render(i),i.postRender(),this.events.emit("postrender",i)},headlessStep:function(t,e){this.input.update(t,e),this.sound.update(t,e),this.onStepCallback(),this.scene.update(t,e),this.events.emit("prerender"),this.events.emit("postrender")},onHidden:function(){this.loop.pause(),this.events.emit("pause")},onVisible:function(){this.loop.resume(),this.events.emit("resume")},onBlur:function(){this.loop.blur()},onFocus:function(){this.loop.focus()},resize:function(t,e){this.config.width=t,this.config.height=e,this.renderer.resize(t,e),this.input.resize(),this.scene.resize(t,e),this.events.emit("resize",t,e)},destroy:function(t){this.loop.destroy(),this.scene.destroy(),this.renderer.destroy(),this.events.emit("destroy"),this.events.removeAllListeners(),this.onStepCallback=null,t&&o.remove(this.canvas)}});t.exports=A},function(t,e,i){var n=i(0),s=i(15),r=i(12),o=new n({Extends:s,initialize:function(){s.call(this)},shutdown:function(){this.removeAllListeners()},destroy:function(){this.removeAllListeners()}});r.register("EventEmitter",o,"events"),t.exports=o},function(t,e){var i,n,s=t.exports={};function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(i===setTimeout)return setTimeout(t,0);if((i===r||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:r}catch(t){i=r}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(t){n=o}}();var h,u=[],l=!1,c=-1;function d(){l&&h&&(l=!1,h.length?u=h.concat(u):c=-1,u.length&&f())}function f(){if(!l){var t=a(d);l=!0;for(var e=u.length;e;){for(h=u,u=[];++c1)for(var i=1;i>16&255,g:t>>8&255,b:255&t,a:255};return t>16777215&&(e.a=t>>>24),e}},function(t,e){t.exports=function(t,e){void 0===e&&(e="none");return["-webkit-","-khtml-","-moz-","-ms-",""].forEach(function(i){t.style[i+"user-select"]=e}),t.style["-webkit-touch-callout"]=e,t.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",t}},function(t,e){t.exports=function(t,e){return void 0===e&&(e="none"),t.style.msTouchAction=e,t.style["ms-touch-action"]=e,t.style["touch-action"]=e,t}},function(t,e,i){t.exports={Interpolation:i(313),Pool:i(23),Smoothing:i(151),TouchAction:i(835),UserSelect:i(834)}},function(t,e){t.exports=function(t){return t.height*t.originY}},function(t,e){t.exports=function(t){return t.width*t.originX}},function(t,e,i){t.exports={CenterOn:i(361),GetBottom:i(36),GetCenterX:i(61),GetCenterY:i(58),GetLeft:i(34),GetOffsetX:i(838),GetOffsetY:i(837),GetRight:i(32),GetTop:i(30),SetBottom:i(35),SetCenterX:i(60),SetCenterY:i(59),SetLeft:i(33),SetRight:i(31),SetTop:i(29)}},function(t,e,i){var n=i(32),s=i(30),r=i(35),o=i(31);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)-a),t}},function(t,e,i){var n=i(34),s=i(30),r=i(35),o=i(33);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)-i),r(t,s(e)-a),t}},function(t,e,i){var n=i(61),s=i(30),r=i(35),o=i(60);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)-a),t}},function(t,e,i){var n=i(32),s=i(30),r=i(33),o=i(29);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)-a),t}},function(t,e,i){var n=i(58),s=i(32),r=i(59),o=i(33);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(36),s=i(32),r=i(35),o=i(33);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(34),s=i(30),r=i(31),o=i(29);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)-i),o(t,s(e)-a),t}},function(t,e,i){var n=i(58),s=i(34),r=i(59),o=i(31);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(36),s=i(34),r=i(35),o=i(31);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(36),s=i(32),r=i(31),o=i(29);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)+i),o(t,n(e)+a),t}},function(t,e,i){var n=i(36),s=i(34),r=i(33),o=i(29);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)-i),o(t,n(e)+a),t}},function(t,e,i){var n=i(36),s=i(61),r=i(60),o=i(29);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)+i),o(t,n(e)+a),t}},function(t,e,i){t.exports={BottomCenter:i(851),BottomLeft:i(850),BottomRight:i(849),LeftBottom:i(848),LeftCenter:i(847),LeftTop:i(846),RightBottom:i(845),RightCenter:i(844),RightTop:i(843),TopCenter:i(842),TopLeft:i(841),TopRight:i(840)}},function(t,e,i){t.exports={BottomCenter:i(365),BottomLeft:i(364),BottomRight:i(363),Center:i(362),LeftCenter:i(360),QuickSet:i(366),RightCenter:i(359),TopCenter:i(358),TopLeft:i(357),TopRight:i(356)}},function(t,e,i){var n=i(169),s=i(18),r={In:i(853),To:i(852)};r=s(!1,r,n),t.exports=r},function(t,e,i){t.exports={Align:i(854),Bounds:i(839),Canvas:i(836),Color:i(312),Masks:i(825)}},function(t,e,i){var n=i(0),s=i(103),r=i(12),o=new n({Extends:s,initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),s.call(this,this.scene,t.sys.events)},boot:function(){var t=this.systems.events;t.on("shutdown",this.shutdownPlugin,this),t.on("destroy",this.destroyPlugin,this)},shutdownPlugin:function(){},destroyPlugin:function(){this.destroy(),this.scene=void 0,this.systems=void 0}});r.register("DataManagerPlugin",o,"data"),t.exports=o},function(t,e,i){t.exports={DataManager:i(103),DataManagerPlugin:i(856)}},function(t,e,i){var n=i(0),s=i(6),r=new n({initialize:function(t,e){this.active=!1,this.p0=new s(t,e)},getPoint:function(t,e){return void 0===e&&(e=new s),e.copy(this.p0)},getPointAt:function(t,e){return this.getPoint(t,e)},getResolution:function(){return 1},getLength:function(){return 0},toJSON:function(){return{type:"MoveTo",points:[this.p0.x,this.p0.y]}}});t.exports=r},function(t,e,i){var n=i(0),s=i(321),r=i(319),o=i(9),a=i(317),h=i(858),u=i(316),l=i(10),c=i(314),d=i(6),f=new n({initialize:function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.name="",this.curves=[],this.cacheLengths=[],this.autoClose=!1,this.startPoint=new d,this._tmpVec2A=new d,this._tmpVec2B=new d,"object"==typeof t?this.fromJSON(t):this.startPoint.set(t,e)},add:function(t){return this.curves.push(t),this},circleTo:function(t,e,i){return void 0===e&&(e=!1),this.ellipseTo(t,t,0,360,e,i)},closePath:function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);return t.equals(e)||this.curves.push(new a(e,t)),this},cubicBezierTo:function(t,e,i,n,r,o){var a,h,u,l=this.getEndPoint();return t instanceof d?(a=t,h=e,u=i):(a=new d(i,n),h=new d(r,o),u=new d(t,e)),this.add(new s(l,a,h,u))},quadraticBezierTo:function(t,e,i,n){var s,r,o=this.getEndPoint();return t instanceof d?(s=t,r=e):(s=new d(i,n),r=new d(t,e)),this.add(new u(o,s,r))},draw:function(t,e){for(var i=0;i0?this.curves[this.curves.length-1].getPoint(1,t):t.copy(this.startPoint),t},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},getPoint:function(t,e){void 0===e&&(e=new d);for(var i=t*this.getLength(),n=this.getCurveLengths(),s=0;s=i){var r=n[s]-i,o=this.curves[s],a=o.getLength(),h=0===a?0:1-r/a;return o.getPointAt(h,e)}s++}return null},getPoints:function(t){void 0===t&&(t=12);for(var e,i=[],n=0;n1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i},getRandomPoint:function(t){return void 0===t&&(t=new d),this.getPoint(Math.random(),t)},getSpacedPoints:function(t){void 0===t&&(t=40);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return this.autoClose&&e.push(e[0]),e},getStartPoint:function(t){return void 0===t&&(t=new d),t.copy(this.startPoint)},lineTo:function(t,e){t instanceof d?this._tmpVec2B.copy(t):this._tmpVec2B.set(t,e);var i=this.getEndPoint(this._tmpVec2A);return this.add(new a([i.x,i.y,this._tmpVec2B.x,this._tmpVec2B.y]))},splineTo:function(t){return t.unshift(this.getEndPoint()),this.add(new c(t))},moveTo:function(t,e){return this.add(new h(t,e))},toJSON:function(){for(var t=[],e=0;e0;){this.cameras.pop().destroy()}return this.main},update:function(t,e){for(var i=0,n=this.cameras.length;i0&&e.cameraFilter&s._id||t.drawImage(e,s)}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchSprite(e,s)}},function(t,e,i){var n=i(3),s=i(3);n=i(869),s=i(868),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){t.exports={Camera:i(154),CameraManager:i(867),OrthographicCamera:i(325),PerspectiveCamera:i(324)}},function(t,e,i){var n=i(157),s=i(0),r=i(2),o=i(12),a=i(27),h=new s({initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),this.currentCameraId=1,this.cameras=[],this.cameraPool=[],t.sys.settings.cameras?this.fromJSON(t.sys.settings.cameras):this.add(),this.main=this.cameras[0],this.baseScale=1},boot:function(){var t=this.systems.events;t.on("update",this.update,this),t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},add:function(t,e,i,s,r,o){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.scene.sys.game.config.width),void 0===s&&(s=this.scene.sys.game.config.height),void 0===r&&(r=!1),void 0===o&&(o="");var a=null;return this.cameraPool.length>0?(a=this.cameraPool.pop()).setViewport(t,e,i,s):a=new n(t,e,i,s),a.setName(o),a.setScene(this.scene),this.cameras.push(a),r&&(this.main=a),a._id=this.currentCameraId,this.currentCameraId=this.currentCameraId<<1,a},addExisting:function(t){var e=this.cameras.indexOf(t),i=this.cameraPool.indexOf(t);return e<0&&i>=0?(this.cameras.push(t),this.cameraPool.slice(i,1),t):null},fromJSON:function(t){Array.isArray(t)||(t=[t]);for(var e=this.scene.sys.game.config.width,i=this.scene.sys.game.config.height,n=0;n=0;i--){var n=e[i];if(n.inputEnabled&&a(n,t.x,t.y))return n}},remove:function(t){var e=this.cameras.indexOf(t);e>=0&&this.cameras.length>1&&(this.cameraPool.push(this.cameras[e]),this.cameras.splice(e,1),this.main===t&&(this.main=this.cameras[0]))},render:function(t,e,i){for(var n=this.cameras,s=this.baseScale,r=0,o=n.length;r0;)this.cameraPool.push(this.cameras.pop());return this.main=this.add(),this.main},update:function(t,e){for(var i=0,n=this.cameras.length;i0?(this._speedX-=this.dragX*t,this._speedX<0&&(this._speedX=0)):this._speedX<0&&(this._speedX+=this.dragX*t,this._speedX>0&&(this._speedX=0)),this._speedY>0?(this._speedY-=this.dragY*t,this._speedY<0&&(this._speedY=0)):this._speedY<0&&(this._speedY+=this.dragY*t,this._speedY>0&&(this._speedY=0)),this.up&&this.up.isDown?(this._speedY+=this.accelY,this._speedY>this.maxSpeedY&&(this._speedY=this.maxSpeedY)):this.down&&this.down.isDown&&(this._speedY-=this.accelY,this._speedY<-this.maxSpeedY&&(this._speedY=-this.maxSpeedY)),this.left&&this.left.isDown?(this._speedX+=this.accelX,this._speedX>this.maxSpeedX&&(this._speedX=this.maxSpeedX)):this.right&&this.right.isDown&&(this._speedX-=this.accelX,this._speedX<-this.maxSpeedX&&(this._speedX=-this.maxSpeedX)),this.zoomIn&&this.zoomIn.isDown?this._zoom=-this.zoomSpeed:this.zoomOut&&this.zoomOut.isDown?this._zoom=this.zoomSpeed:this._zoom=0,0!==this._speedX&&(e.scrollX-=this._speedX*t|0),0!==this._speedY&&(e.scrollY-=this._speedY*t|0),0!==this._zoom&&(e.zoom+=this._zoom,e.zoom<.1&&(e.zoom=.1))}},destroy:function(){this.camera=null,this.left=null,this.right=null,this.up=null,this.down=null,this.zoomIn=null,this.zoomOut=null}});t.exports=r},function(t,e,i){var n=i(0),s=i(5),r=new n({initialize:function(t){this.camera=s(t,"camera",null),this.left=s(t,"left",null),this.right=s(t,"right",null),this.up=s(t,"up",null),this.down=s(t,"down",null),this.zoomIn=s(t,"zoomIn",null),this.zoomOut=s(t,"zoomOut",null),this.zoomSpeed=s(t,"zoomSpeed",.01),this.speedX=0,this.speedY=0;var e=s(t,"speed",null);"number"==typeof e?(this.speedX=e,this.speedY=e):(this.speedX=s(t,"speed.x",0),this.speedY=s(t,"speed.y",0)),this._zoom=0,this.active=null!==this.camera},start:function(){return this.active=null!==this.camera,this},stop:function(){return this.active=!1,this},setCamera:function(t){return this.camera=t,this},update:function(t){if(this.active){void 0===t&&(t=1);var e=this.camera;this.up&&this.up.isDown?e.scrollY-=this.speedY*t|0:this.down&&this.down.isDown&&(e.scrollY+=this.speedY*t|0),this.left&&this.left.isDown?e.scrollX-=this.speedX*t|0:this.right&&this.right.isDown&&(e.scrollX+=this.speedX*t|0),this.zoomIn&&this.zoomIn.isDown?(e.zoom-=this.zoomSpeed,e.zoom<.1&&(e.zoom=.1)):this.zoomOut&&this.zoomOut.isDown&&(e.zoom+=this.zoomSpeed)}},destroy:function(){this.camera=null,this.left=null,this.right=null,this.up=null,this.down=null,this.zoomIn=null,this.zoomOut=null}});t.exports=r},function(t,e,i){t.exports={Fixed:i(875),Smoothed:i(874)}},function(t,e,i){t.exports={Controls:i(876),Scene2D:i(873),Sprite3D:i(871)}},function(t,e,i){t.exports={BaseCache:i(338),CacheManager:i(337)}},function(t,e,i){t.exports={Animation:i(341),AnimationFrame:i(340),AnimationManager:i(339)}},function(t,e,i){var n=i(43);t.exports=function(t,e,i){void 0===i&&(i=0);for(var s=0;s1)if(0===s){var d=t.length-1;for(o=t[d].x,a=t[d].y,h=d-1;h>=0;h--)u=(c=t[h]).x,l=c.y,c.x=o,c.y=a,o=u,a=l;t[d].x=e,t[d].y=i}else{for(o=t[0].x,a=t[0].y,h=1;h0?s(o,i):i<0&&r(o,Math.abs(i));for(var a=0;a>16)+(65280&t)+((255&t)<<16)},n={_tintTL:16777215,_tintTR:16777215,_tintBL:16777215,_tintBR:16777215,clearTint:function(){return this.setTint(16777215),this},setTint:function(t,e,n,s){return void 0===t&&(t=16777215),void 0===e&&(e=t,n=t,s=t),this._tintTL=i(t),this._tintTR=i(e),this._tintBL=i(n),this._tintBR=i(s),this},tintTopLeft:{get:function(){return this._tintTL},set:function(t){this._tintTL=i(t)}},tintTopRight:{get:function(){return this._tintTR},set:function(t){this._tintTR=i(t)}},tintBottomLeft:{get:function(){return this._tintBL},set:function(t){this._tintBL=i(t)}},tintBottomRight:{get:function(){return this._tintBR},set:function(t){this._tintBR=i(t)}},tint:{set:function(t){this.setTint(t,t,t,t)}}};t.exports=n},function(t,e){var i={texture:null,frame:null,setTexture:function(t,e){return this.texture=this.scene.sys.textures.get(t),this.setFrame(e)},setFrame:function(t,e,i){return void 0===e&&(e=!0),void 0===i&&(i=!0),this.frame=this.texture.get(t),this.frame.cutWidth&&this.frame.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,this._sizeComponent&&e&&this.setSizeToFrame(),this._originComponent&&i&&(this.frame.customPivot?this.setOrigin(this.frame.pivotX,this.frame.pivotY):this.updateDisplayOrigin()),this}};t.exports=i},function(t,e){var i={_sizeComponent:!0,width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.frame.realWidth},set:function(t){this.scaleX=t/this.frame.realWidth}},displayHeight:{get:function(){return this.scaleY*this.frame.realHeight},set:function(t){this.scaleY=t/this.frame.realHeight}},setSizeToFrame:function(t){return void 0===t&&(t=this.frame),this.width=t.realWidth,this.height=t.realHeight,this},setSize:function(t,e){return this.width=t,this.height=e,this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}};t.exports=i},function(t,e){var i={scrollFactorX:1,scrollFactorY:1,setScrollFactor:function(t,e){return void 0===e&&(e=t),this.scrollFactorX=t,this.scrollFactorY=e,this}};t.exports=i},function(t,e,i){var n=i(80),s={_scaleMode:n.DEFAULT,scaleMode:{get:function(){return this._scaleMode},set:function(t){t!==n.LINEAR&&t!==n.NEAREST||(this._scaleMode=t)}},setScaleMode:function(t){return this.scaleMode=t,this}};t.exports=s},function(t,e){var i={_originComponent:!0,originX:.5,originY:.5,_displayOriginX:0,_displayOriginY:0,displayOriginX:{get:function(){return this._displayOriginX},set:function(t){this._displayOriginX=t,this.originX=t/this.width}},displayOriginY:{get:function(){return this._displayOriginY},set:function(t){this._displayOriginY=t,this.originY=t/this.height}},setOrigin:function(t,e){return void 0===t&&(t=.5),void 0===e&&(e=t),this.originX=t,this.originY=e,this.updateDisplayOrigin()},setOriginFromFrame:function(){return this.frame&&this.frame.customPivot?(this.originX=this.frame.pivotX,this.originY=this.frame.pivotY,this.updateDisplayOrigin()):this.setOrigin()},setDisplayOrigin:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.displayOriginX=t,this.displayOriginY=e,this},updateDisplayOrigin:function(){return this._displayOriginX=Math.round(this.originX*this.width),this._displayOriginY=Math.round(this.originY*this.height),this}};t.exports=i},function(t,e){var i={matrixStack:null,currentMatrix:null,currentMatrixIndex:0,initMatrixStack:function(){return this.matrixStack=new Float32Array(6e3),this.currentMatrix=new Float32Array([1,0,0,1,0,0]),this.currentMatrixIndex=0,this},save:function(){if(this.currentMatrixIndex>=this.matrixStack.length)return this;var t=this.matrixStack,e=this.currentMatrix,i=this.currentMatrixIndex;return this.currentMatrixIndex+=6,t[i+0]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=e[3],t[i+4]=e[4],t[i+5]=e[5],this},restore:function(){if(this.currentMatrixIndex<=0)return this;this.currentMatrixIndex-=6;var t=this.matrixStack,e=this.currentMatrix,i=this.currentMatrixIndex;return e[0]=t[i+0],e[1]=t[i+1],e[2]=t[i+2],e[3]=t[i+3],e[4]=t[i+4],e[5]=t[i+5],this},loadIdentity:function(){return this.setTransform(1,0,0,1,0,0),this},transform:function(t,e,i,n,s,r){var o=this.currentMatrix,a=o[0],h=o[1],u=o[2],l=o[3],c=o[4],d=o[5];return o[0]=a*t+u*e,o[1]=h*t+l*e,o[2]=a*i+u*n,o[3]=h*i+l*n,o[4]=a*s+u*r+c,o[5]=h*s+l*r+d,this},setTransform:function(t,e,i,n,s,r){var o=this.currentMatrix;return o[0]=t,o[1]=e,o[2]=i,o[3]=n,o[4]=s,o[5]=r,this},translate:function(t,e){var i=this.currentMatrix,n=i[0],s=i[1],r=i[2],o=i[3],a=i[4],h=i[5];return i[4]=n*t+r*e+a,i[5]=s*t+o*e+h,this},scale:function(t,e){var i=this.currentMatrix,n=i[0],s=i[1],r=i[2],o=i[3];return i[0]=n*t,i[1]=s*t,i[2]=r*e,i[3]=o*e,this},rotate:function(t){var e=this.currentMatrix,i=e[0],n=e[1],s=e[2],r=e[3],o=Math.sin(t),a=Math.cos(t);return e[0]=i*a+s*o,e[1]=n*a+r*o,e[2]=i*-o+s*a,e[3]=n*-o+r*a,this}};t.exports=i},function(t,e,i){var n=i(10),s=i(350),r=i(6),o={getCenter:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth/2,t.y=this.y-this.displayHeight*this.originY+this.displayHeight/2,t},getTopLeft:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY,0!==this.rotation&&s(t,this.x,this.y,this.rotation),t},getTopRight:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY,0!==this.rotation&&s(t,this.x,this.y,this.rotation),t},getBottomLeft:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,0!==this.rotation&&s(t,this.x,this.y,this.rotation),t},getBottomRight:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,0!==this.rotation&&s(t,this.x,this.y,this.rotation),t},getBounds:function(t){void 0===t&&(t=new n),this.getTopLeft(t);var e=t.x,i=t.y;this.getTopRight(t);var s=t.x,r=t.y;this.getBottomLeft(t);var o=t.x,a=t.y;this.getBottomRight(t);var h=t.x,u=t.y;return t.x=Math.min(e,s,o,h),t.y=Math.min(i,r,a,u),t.width=Math.max(e,s,o,h)-t.x,t.height=Math.max(i,r,a,u)-t.y,t}};t.exports=o},function(t,e){t.exports={flipX:!1,flipY:!1,toggleFlipX:function(){return this.flipX=!this.flipX,this},toggleFlipY:function(){return this.flipY=!this.flipY,this},setFlipX:function(t){return this.flipX=t,this},setFlipY:function(t){return this.flipY=t,this},setFlip:function(t,e){return this.flipX=t,this.flipY=e,this},resetFlip:function(){return this.flipX=!1,this.flipY=!1,this}}},function(t,e){var i={_depth:0,depth:{get:function(){return this._depth},set:function(t){this.scene.sys.queueDepthSort(),this._depth=t}},setDepth:function(t){return void 0===t&&(t=0),this.depth=t,this}};t.exports=i},function(t,e){t.exports={width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.width},set:function(t){this.scaleX=t/this.width}},displayHeight:{get:function(){return this.scaleY*this.height},set:function(t){this.scaleY=t/this.height}}}},function(t,e,i){var n=i(62),s={_blendMode:n.NORMAL,blendMode:{get:function(){return this._blendMode},set:function(t){"string"==typeof t&&(t=n[t]),(t|=0)>=0&&(this._blendMode=t)}},setBlendMode:function(t){return this.blendMode=t,this}};t.exports=s},function(t,e,i){var n=i(64),s={_alpha:1,_alphaTL:1,_alphaTR:1,_alphaBL:1,_alphaBR:1,clearAlpha:function(){return this.setAlpha(1)},setAlpha:function(t,e,i,s){return void 0===t&&(t=1),void 0===e?this.alpha=t:(this._alphaTL=n(t,0,1),this._alphaTR=n(e,0,1),this._alphaBL=n(i,0,1),this._alphaBR=n(s,0,1)),this},alpha:{get:function(){return this._alpha},set:function(t){var e=n(t,0,1);this._alpha=e,this._alphaTL=e,this._alphaTR=e,this._alphaBL=e,this._alphaBR=e,0===e?this.renderFlags&=-3:this.renderFlags|=2}},alphaTopLeft:{get:function(){return this._alphaTL},set:function(t){var e=n(t,0,1);this._alphaTL=e,0!==e&&(this.renderFlags|=2)}},alphaTopRight:{get:function(){return this._alphaTR},set:function(t){var e=n(t,0,1);this._alphaTR=e,0!==e&&(this.renderFlags|=2)}},alphaBottomLeft:{get:function(){return this._alphaBL},set:function(t){var e=n(t,0,1);this._alphaBL=e,0!==e&&(this.renderFlags|=2)}},alphaBottomRight:{get:function(){return this._alphaBR},set:function(t){var e=n(t,0,1);this._alphaBR=e,0!==e&&(this.renderFlags|=2)}}};t.exports=s},function(t,e,i){var n=new(i(0))({initialize:function(t){this.c=1,this.s0=0,this.s1=0,this.s2=0,this.n=0,this.signs=[-1,1],t&&this.init(t)},rnd:function(){var t=2091639*this.s0+2.3283064365386963e-10*this.c;return this.c=0|t,this.s0=this.s1,this.s1=this.s2,this.s2=t-this.c,this.s2},hash:function(t){var e,i=this.n;t=t.toString();for(var n=0;n>>0,i=(e*=i)>>>0,i+=4294967296*(e-=i);return this.n=i,2.3283064365386963e-10*(i>>>0)},init:function(t){"string"==typeof t?this.state(t):this.sow(t)},sow:function(t){if(this.n=4022871197,this.s0=this.hash(" "),this.s1=this.hash(" "),this.s2=this.hash(" "),this.c=1,t)for(var e=0;e>>0;if("function"!=typeof t)throw new TypeError;for(var n=arguments.length>=2?arguments[1]:void 0,s=0;s - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Source object -// The key as a string, or an array of keys, i.e. 'banner', or 'banner.hideBanner' -// The default value to use if the key doesn't exist - -/** - * [description] - * - * @function Phaser.Utils.Object.GetValue - * @since 3.0.0 - * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {any} defaultValue - [description] - * - * @return {any} [description] - */ -var GetValue = function (source, key, defaultValue) -{ - if (!source || typeof source === 'number') - { - return defaultValue; - } - else if (source.hasOwnProperty(key)) - { - return source[key]; - } - else if (key.indexOf('.')) - { - var keys = key.split('.'); - var parent = source; - var value = defaultValue; - - // Use for loop here so we can break early - for (var i = 0; i < keys.length; i++) - { - if (parent.hasOwnProperty(keys[i])) - { - // Yes it has a key property, let's carry on down - value = parent[keys[i]]; - - parent = parent[keys[i]]; - } - else - { - // Can't go any further, so reset to default - value = defaultValue; - break; - } - } - - return value; - } - else - { - return defaultValue; - } -}; - -module.exports = GetValue; - - -/***/ }), -/* 5 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -925,6 +860,77 @@ var Point = new Class({ module.exports = Point; +/***/ }), +/* 5 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Source object +// The key as a string, or an array of keys, i.e. 'banner', or 'banner.hideBanner' +// The default value to use if the key doesn't exist + +/** + * [description] + * + * @function Phaser.Utils.Object.GetValue + * @since 3.0.0 + * + * @param {object} source - [description] + * @param {string} key - [description] + * @param {*} defaultValue - [description] + * + * @return {*} [description] + */ +var GetValue = function (source, key, defaultValue) +{ + if (!source || typeof source === 'number') + { + return defaultValue; + } + else if (source.hasOwnProperty(key)) + { + return source[key]; + } + else if (key.indexOf('.')) + { + var keys = key.split('.'); + var parent = source; + var value = defaultValue; + + // Use for loop here so we can break early + for (var i = 0; i < keys.length; i++) + { + if (parent.hasOwnProperty(keys[i])) + { + // Yes it has a key property, let's carry on down + value = parent[keys[i]]; + + parent = parent[keys[i]]; + } + else + { + // Can't go any further, so reset to default + value = defaultValue; + break; + } + } + + return value; + } + else + { + return defaultValue; + } +}; + +module.exports = GetValue; + + /***/ }), /* 6 */ /***/ (function(module, exports, __webpack_require__) { @@ -935,11 +941,18 @@ module.exports = Point; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji // and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl var Class = __webpack_require__(0); +/** + * @typedef {object} Vector2Like + * + * @property {number} x - [description] + * @property {number} y - [description] + */ + /** * @classdesc * [description] @@ -966,6 +979,7 @@ var Vector2 = new Class({ * @default 0 * @since 3.0.0 */ + this.x = 0; /** * The y component of this Vector. @@ -975,6 +989,7 @@ var Vector2 = new Class({ * @default 0 * @since 3.0.0 */ + this.y = 0; if (typeof x === 'object') { @@ -1009,7 +1024,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#copy * @since 3.0.0 * - * @param {Phaser.Math.Vector2|object} src - [description] + * @param {Phaser.Math.Vector2} src - [description] * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1027,7 +1042,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#setFromObject * @since 3.0.0 * - * @param {[type]} obj - [description] + * @param {Vector2Like} obj - [description] * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1045,8 +1060,8 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#set * @since 3.0.0 * - * @param {[type]} x - [description] - * @param {[type]} y - [description] + * @param {number} x - [description] + * @param {number} [y=x] - [description] * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1060,17 +1075,14 @@ var Vector2 = new Class({ return this; }, - // Sets the `x` and `y` values of this object from a given polar coordinate. - // @param {number} azimuth - The angular coordinate, in radians. - // @param {number} [radius=1] - The radial coordinate (length). /** - * [description] + * Sets the `x` and `y` values of this object from a given polar coordinate. * * @method Phaser.Math.Vector2#setToPolar * @since 3.0.0 * - * @param {[type]} azimuth - [description] - * @param {[type]} radius - [description] + * @param {float} azimuth - The angular coordinate, in radians. + * @param {float} [radius=1] - The radial coordinate (length). * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1090,7 +1102,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#equals * @since 3.0.0 * - * @param {[type]} v - [description] + * @param {Phaser.Math.Vector2} v - [description] * * @return {boolean} [description] */ @@ -1127,7 +1139,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#add * @since 3.0.0 * - * @param {[type]} src - [description] + * @param {Phaser.Math.Vector2} src - [description] * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1145,7 +1157,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#subtract * @since 3.0.0 * - * @param {[type]} src - [description] + * @param {Phaser.Math.Vector2} src - [description] * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1163,7 +1175,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#multiply * @since 3.0.0 * - * @param {[type]} src - [description] + * @param {Phaser.Math.Vector2} src - [description] * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1181,7 +1193,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#scale * @since 3.0.0 * - * @param {[type]} value - [description] + * @param {number} value - [description] * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1207,7 +1219,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#divide * @since 3.0.0 * - * @param {[type]} src - [description] + * @param {Phaser.Math.Vector2} src - [description] * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1241,7 +1253,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#distance * @since 3.0.0 * - * @param {[type]} src - [description] + * @param {Phaser.Math.Vector2} src - [description] * * @return {number} [description] */ @@ -1259,7 +1271,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#distanceSq * @since 3.0.0 * - * @param {[type]} src - [description] + * @param {Phaser.Math.Vector2} src - [description] * * @return {number} [description] */ @@ -1323,7 +1335,7 @@ var Vector2 = new Class({ this.x = x * len; this.y = y * len; } - + return this; }, @@ -1354,7 +1366,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#dot * @since 3.0.0 * - * @param {[type]} src - [description] + * @param {Phaser.Math.Vector2} src - [description] * * @return {number} [description] */ @@ -1369,7 +1381,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#cross * @since 3.0.0 * - * @param {[type]} src - [description] + * @param {Phaser.Math.Vector2} src - [description] * * @return {number} [description] */ @@ -1384,8 +1396,8 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#lerp * @since 3.0.0 * - * @param {[type]} src - [description] - * @param {[type]} t - [description] + * @param {Phaser.Math.Vector2} src - [description] + * @param {number} [t=0] - [description] * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1408,7 +1420,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#transformMat3 * @since 3.0.0 * - * @param {[type]} mat - [description] + * @param {Phaser.Math.Matrix3} mat - [description] * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1430,7 +1442,7 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#transformMat4 * @since 3.0.0 * - * @param {[type]} mat - [description] + * @param {Phaser.Math.Matrix4} mat - [description] * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1524,450 +1536,80 @@ module.exports = FileTypesManager; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Contains = __webpack_require__(33); -var GetPoint = __webpack_require__(107); -var GetPoints = __webpack_require__(187); -var Random = __webpack_require__(108); +var MATH = __webpack_require__(16); +var GetValue = __webpack_require__(5); + +// Allowed types: + +// Implicit +// { +// x: 4 +// } +// +// From function +// { +// x: function () +// } +// +// Randomly pick one element from the array +// { +// x: [a, b, c, d, e, f] +// } +// +// Random integer between min and max: +// { +// x: { randInt: [min, max] } +// } +// +// Random float between min and max: +// { +// x: { randFloat: [min, max] } +// } /** - * @classdesc - * Encapsulates a 2D rectangle defined by its corner point in the top-left and its extends in x (width) and y (height) + * [description] * - * @class Rectangle - * @memberOf Phaser.Geom - * @constructor + * @function Phaser.Utils.Object.GetAdvancedValue * @since 3.0.0 * - * @param {number} [x] - [description] - * @param {number} [y] - [description] - * @param {number} [width] - [description] - * @param {number} [height] - [description] + * @param {object} source - [description] + * @param {string} key - [description] + * @param {*} defaultValue - [description] + * + * @return {*} [description] */ -var Rectangle = new Class({ +var GetAdvancedValue = function (source, key, defaultValue) +{ + var value = GetValue(source, key, null); - initialize: - - function Rectangle (x, y, width, height) + if (value === null) { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (width === undefined) { width = 0; } - if (height === undefined) { height = 0; } - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x = x; - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y = y; - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#width - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.width = width; - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#height - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.height = height; - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#contains - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - contains: function (x, y) + return defaultValue; + } + else if (Array.isArray(value)) { - return Contains(this, x, y); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#getPoint - * @since 3.0.0 - * - * @param {[type]} position - [description] - * @param {[type]} output - [description] - * - * @return {[type]} [description] - */ - getPoint: function (position, output) + return MATH.RND.pick(value); + } + else if (typeof value === 'object') { - return GetPoint(this, position, output); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#getPoints - * @since 3.0.0 - * - * @param {[type]} quantity - [description] - * @param {[type]} stepRate - [description] - * @param {[type]} output - [description] - * - * @return {[type]} [description] - */ - getPoints: function (quantity, stepRate, output) - { - return GetPoints(this, quantity, stepRate, output); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#getRandomPoint - * @since 3.0.0 - * - * @param {[type]} point - [description] - * - * @return {[type]} [description] - */ - getRandomPoint: function (point) - { - return Random(this, point); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#setTo - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} width - [description] - * @param {[type]} height - [description] - * - * @return {Phaser.Geom.Rectangle} This Rectangle object. - */ - setTo: function (x, y, width, height) - { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#setEmpty - * @since 3.0.0 - * - * @return {Phaser.Geom.Rectangle} This Rectangle object. - */ - setEmpty: function () - { - return this.setTo(0, 0, 0, 0); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#setPosition - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {Phaser.Geom.Rectangle} This Rectangle object. - */ - setPosition: function (x, y) - { - if (y === undefined) { y = x; } - - this.x = x; - this.y = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#setSize - * @since 3.0.0 - * - * @param {[type]} width - [description] - * @param {[type]} height - [description] - * - * @return {Phaser.Geom.Rectangle} This Rectangle object. - */ - setSize: function (width, height) - { - if (height === undefined) { height = width; } - - this.width = width; - this.height = height; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#isEmpty - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isEmpty: function () - { - return (this.width <= 0 || this.height <= 0); - }, - - // TOP - /** - * [description] - * - * @method Phaser.Geom.Rectangle#getLineA - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getLineA: function () - { - return { x1: this.x, y1: this.y, x2: this.right, y2: this.y }; - }, - - // RIGHT - /** - * [description] - * - * @method Phaser.Geom.Rectangle#getLineB - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getLineB: function () - { - return { x1: this.right, y1: this.y, x2: this.right, y2: this.bottom }; - }, - - // BOTTOM - /** - * [description] - * - * @method Phaser.Geom.Rectangle#getLineC - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getLineC: function () - { - return { x1: this.right, y1: this.bottom, x2: this.x, y2: this.bottom }; - }, - - // LEFT - /** - * [description] - * - * @method Phaser.Geom.Rectangle#getLineD - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getLineD: function () - { - return { x1: this.x, y1: this.bottom, x2: this.x, y2: this.y }; - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#left - * @type {number} - * @since 3.0.0 - */ - left: { - - get: function () + if (value.hasOwnProperty('randInt')) { - return this.x; - }, - - set: function (value) - { - if (value >= this.right) - { - this.width = 0; - } - else - { - this.width = this.right - value; - } - - this.x = value; + return MATH.RND.integerInRange(value.randInt[0], value.randInt[1]); } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#right - * @type {number} - * @since 3.0.0 - */ - right: { - - get: function () + else if (value.hasOwnProperty('randFloat')) { - return this.x + this.width; - }, - - set: function (value) - { - if (value <= this.x) - { - this.width = 0; - } - else - { - this.width = value - this.x; - } + return MATH.RND.realInRange(value.randFloat[0], value.randFloat[1]); } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#top - * @type {number} - * @since 3.0.0 - */ - top: { - - get: function () - { - return this.y; - }, - - set: function (value) - { - if (value >= this.bottom) - { - this.height = 0; - } - else - { - this.height = (this.bottom - value); - } - - this.y = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#bottom - * @type {number} - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return this.y + this.height; - }, - - set: function (value) - { - if (value <= this.y) - { - this.height = 0; - } - else - { - this.height = value - this.y; - } - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#centerX - * @type {number} - * @since 3.0.0 - */ - centerX: { - - get: function () - { - return this.x + (this.width / 2); - }, - - set: function (value) - { - this.x = value - (this.width / 2); - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#centerY - * @type {number} - * @since 3.0.0 - */ - centerY: { - - get: function () - { - return this.y + (this.height / 2); - }, - - set: function (value) - { - this.y = value - (this.height / 2); - } - + } + else if (typeof value === 'function') + { + return value(key); } -}); + return value; +}; -module.exports = Rectangle; +module.exports = GetAdvancedValue; /***/ }), @@ -2123,11 +1765,11 @@ var GameObjectFactory = new Class({ // Static method called directly by the Game Object factory functions -GameObjectFactory.register = function (type, factoryFunction) +GameObjectFactory.register = function (factoryType, factoryFunction) { - if (!GameObjectFactory.prototype.hasOwnProperty(type)) + if (!GameObjectFactory.prototype.hasOwnProperty(factoryType)) { - GameObjectFactory.prototype[type] = factoryFunction; + GameObjectFactory.prototype[factoryType] = factoryFunction; } }; @@ -2146,80 +1788,471 @@ module.exports = GameObjectFactory; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var MATH = __webpack_require__(16); -var GetValue = __webpack_require__(4); - -// Allowed types: - -// Implicit -// { -// x: 4 -// } -// -// From function -// { -// x: function () -// } -// -// Randomly pick one element from the array -// { -// x: [a, b, c, d, e, f] -// } -// -// Random integer between min and max: -// { -// x: { randInt: [min, max] } -// } -// -// Random float between min and max: -// { -// x: { randFloat: [min, max] } -// } +var Class = __webpack_require__(0); +var Contains = __webpack_require__(27); +var GetPoint = __webpack_require__(166); +var GetPoints = __webpack_require__(352); +var Line = __webpack_require__(104); +var Random = __webpack_require__(163); /** - * [description] + * @classdesc + * Encapsulates a 2D rectangle defined by its corner point in the top-left and its extends in x (width) and y (height) * - * @function Phaser.Utils.Object.GetAdvancedValue + * @class Rectangle + * @memberOf Phaser.Geom + * @constructor * @since 3.0.0 * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {any} defaultValue - [description] - * - * @return {any} [description] + * @param {number} [x] - [description] + * @param {number} [y] - [description] + * @param {number} [width] - [description] + * @param {number} [height] - [description] */ -var GetAdvancedValue = function (source, key, defaultValue) -{ - var value = GetValue(source, key, null); +var Rectangle = new Class({ - if (value === null) + initialize: + + function Rectangle (x, y, width, height) { - return defaultValue; - } - else if (Array.isArray(value)) + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 0; } + if (height === undefined) { height = 0; } + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = x; + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = y; + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#width + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.width = width; + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#height + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.height = height; + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#contains + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ + contains: function (x, y) { - return MATH.RND.pick(value); - } - else if (typeof value === 'object') + return Contains(this, x, y); + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#getPoint + * @since 3.0.0 + * + * @param {float} position - [description] + * @param {(Phaser.Geom.Point|object)} output - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ + getPoint: function (position, output) { - if (value.hasOwnProperty('randInt')) + return GetPoint(this, position, output); + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#getPoints + * @since 3.0.0 + * + * @param {integer} quantity - [description] + * @param {number} [stepRate] - [description] + * @param {(array|Phaser.Geom.Point[])} [output] - [description] + * + * @return {(array|Phaser.Geom.Point[])} [description] + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#getRandomPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * + * @return {Phaser.Geom.Point} [description] + */ + getRandomPoint: function (point) + { + return Random(this, point); + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#setTo + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setTo: function (x, y, width, height) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#setEmpty + * @since 3.0.0 + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setEmpty: function () + { + return this.setTo(0, 0, 0, 0); + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#setPosition + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setPosition: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#setSize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} [height=width] - [description] + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setSize: function (width, height) + { + if (height === undefined) { height = width; } + + this.width = width; + this.height = height; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#isEmpty + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isEmpty: function () + { + return (this.width <= 0 || this.height <= 0); + }, + + /** + * Returns a Line object that corresponds to the top of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineA + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the top of this Rectangle. + */ + getLineA: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x, this.y, this.right, this.y); + + return line; + }, + + /** + * Returns a Line object that corresponds to the right of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineB + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the right of this Rectangle. + */ + getLineB: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.right, this.y, this.right, this.bottom); + + return line; + }, + + /** + * Returns a Line object that corresponds to the bottom of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineC + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the bottom of this Rectangle. + */ + getLineC: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.right, this.bottom, this.x, this.bottom); + + return line; + }, + + /** + * Returns a Line object that corresponds to the left of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineD + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the left of this Rectangle. + */ + getLineD: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x, this.bottom, this.x, this.y); + + return line; + }, + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () { - return MATH.RND.integerInRange(value.randInt[0], value.randInt[1]); - } - else if (value.hasOwnProperty('randFloat')) + return this.x; + }, + + set: function (value) { - return MATH.RND.realInRange(value.randFloat[0], value.randFloat[1]); + if (value >= this.right) + { + this.width = 0; + } + else + { + this.width = this.right - value; + } + + this.x = value; } - } - else if (typeof value === 'function') - { - return value(key); + + }, + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return this.x + this.width; + }, + + set: function (value) + { + if (value <= this.x) + { + this.width = 0; + } + else + { + this.width = value - this.x; + } + } + + }, + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return this.y; + }, + + set: function (value) + { + if (value >= this.bottom) + { + this.height = 0; + } + else + { + this.height = (this.bottom - value); + } + + this.y = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return this.y + this.height; + }, + + set: function (value) + { + if (value <= this.y) + { + this.height = 0; + } + else + { + this.height = value - this.y; + } + } + + }, + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#centerX + * @type {number} + * @since 3.0.0 + */ + centerX: { + + get: function () + { + return this.x + (this.width / 2); + }, + + set: function (value) + { + this.x = value - (this.width / 2); + } + + }, + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#centerY + * @type {number} + * @since 3.0.0 + */ + centerY: { + + get: function () + { + return this.y + (this.height / 2); + }, + + set: function (value) + { + this.y = value - (this.height / 2); + } + } - return value; -}; +}); -module.exports = GetAdvancedValue; +module.exports = Rectangle; /***/ }), @@ -2232,34 +2265,134 @@ module.exports = GetAdvancedValue; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var PluginManager = __webpack_require__(12); + /** - * @namespace Phaser.GameObjects.Components + * @classdesc + * The Game Object Creator is a Scene plugin that allows you to quickly create many common + * types of Game Objects and return them. Unlike the Game Object Factory, they are not automatically + * added to the Scene. + * + * Game Objects directly register themselves with the Creator and inject their own creation + * methods into the class. + * + * @class GameObjectCreator + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object Factory belongs. */ +var GameObjectCreator = new Class({ -module.exports = { + initialize: - Alpha: __webpack_require__(391), - Animation: __webpack_require__(365), - BlendMode: __webpack_require__(392), - ComputedSize: __webpack_require__(393), - Depth: __webpack_require__(394), - Flip: __webpack_require__(395), - GetBounds: __webpack_require__(396), - MatrixStack: __webpack_require__(397), - Origin: __webpack_require__(398), - Pipeline: __webpack_require__(189), - ScaleMode: __webpack_require__(399), - ScrollFactor: __webpack_require__(400), - Size: __webpack_require__(401), - Texture: __webpack_require__(402), - Tint: __webpack_require__(403), - ToJSON: __webpack_require__(404), - Transform: __webpack_require__(405), - TransformMatrix: __webpack_require__(190), - Visible: __webpack_require__(406) + function GameObjectCreator (scene) + { + /** + * The Scene to which this Game Object Creator belongs. + * + * @name Phaser.GameObjects.GameObjectCreator#scene + * @type {Phaser.Scene} + * @protected + * @since 3.0.0 + */ + this.scene = scene; + /** + * A reference to the Scene.Systems. + * + * @name Phaser.GameObjects.GameObjectCreator#systems + * @type {Phaser.Scenes.Systems} + * @protected + * @since 3.0.0 + */ + this.systems = scene.sys; + + if (!scene.sys.settings.isBooted) + { + scene.sys.events.once('boot', this.boot, this); + } + + /** + * A reference to the Scene Display List. + * + * @name Phaser.GameObjects.GameObjectCreator#displayList + * @type {Phaser.GameObjects.DisplayList} + * @protected + * @since 3.0.0 + */ + this.displayList; + + /** + * A reference to the Scene Update List. + * + * @name Phaser.GameObjects.GameObjectCreator#updateList; + * @type {Phaser.GameObjects.UpdateList} + * @protected + * @since 3.0.0 + */ + this.updateList; + }, + + /** + * Boots the plugin. + * + * @method Phaser.GameObjects.GameObjectCreator#boot + * @private + * @since 3.0.0 + */ + boot: function () + { + this.displayList = this.systems.displayList; + this.updateList = this.systems.updateList; + + var eventEmitter = this.systems.events; + + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); + }, + + /** + * Shuts this plugin down. + * + * @method Phaser.GameObjects.GameObjectCreator#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + }, + + /** + * Destroys this plugin. + * + * @method Phaser.GameObjects.GameObjectCreator#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.scene = null; + this.displayList = null; + this.updateList = null; + } + +}); + +// Static method called directly by the Game Object creator functions + +GameObjectCreator.register = function (factoryType, factoryFunction) +{ + if (!GameObjectCreator.prototype.hasOwnProperty(factoryType)) + { + GameObjectCreator.prototype[factoryType] = factoryFunction; + } }; +PluginManager.register('GameObjectCreator', GameObjectCreator, 'make'); + +module.exports = GameObjectCreator; + /***/ }), /* 12 */ @@ -2453,139 +2586,128 @@ module.exports = PluginManager; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var PluginManager = __webpack_require__(12); - /** - * @classdesc - * The Game Object Creator is a Scene plugin that allows you to quickly create many common - * types of Game Objects and return them. Unlike the Game Object Factory, they are not automatically - * added to the Scene. - * - * Game Objects directly register themselves with the Creator and inject their own creation - * methods into the class. - * - * @class GameObjectCreator - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object Factory belongs. + * @namespace Phaser.GameObjects.Components */ -var GameObjectCreator = new Class({ - initialize: +module.exports = { - function GameObjectCreator (scene) - { - /** - * The Scene to which this Game Object Creator belongs. - * - * @name Phaser.GameObjects.GameObjectCreator#scene - * @type {Phaser.Scene} - * @protected - * @since 3.0.0 - */ - this.scene = scene; + Alpha: __webpack_require__(937), + Animation: __webpack_require__(381), + BlendMode: __webpack_require__(936), + ComputedSize: __webpack_require__(935), + Depth: __webpack_require__(934), + Flip: __webpack_require__(933), + GetBounds: __webpack_require__(932), + MatrixStack: __webpack_require__(931), + Origin: __webpack_require__(930), + Pipeline: __webpack_require__(349), + ScaleMode: __webpack_require__(929), + ScrollFactor: __webpack_require__(928), + Size: __webpack_require__(927), + Texture: __webpack_require__(926), + Tint: __webpack_require__(925), + ToJSON: __webpack_require__(924), + Transform: __webpack_require__(923), + TransformMatrix: __webpack_require__(348), + Visible: __webpack_require__(922) - /** - * A reference to the Scene.Systems. - * - * @name Phaser.GameObjects.GameObjectCreator#systems - * @type {Phaser.Scenes.Systems} - * @protected - * @since 3.0.0 - */ - this.systems = scene.sys; - - if (!scene.sys.settings.isBooted) - { - scene.sys.events.once('boot', this.boot, this); - } - - /** - * A reference to the Scene Display List. - * - * @name Phaser.GameObjects.GameObjectCreator#displayList - * @type {Phaser.GameObjects.DisplayList} - * @protected - * @since 3.0.0 - */ - this.displayList; - - /** - * A reference to the Scene Update List. - * - * @name Phaser.GameObjects.GameObjectCreator#updateList; - * @type {Phaser.GameObjects.UpdateList} - * @protected - * @since 3.0.0 - */ - this.updateList; - }, - - /** - * Boots the plugin. - * - * @method Phaser.GameObjects.GameObjectCreator#boot - * @private - * @since 3.0.0 - */ - boot: function () - { - this.displayList = this.systems.displayList; - this.updateList = this.systems.updateList; - - var eventEmitter = this.systems.events; - - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); - }, - - /** - * Shuts this plugin down. - * - * @method Phaser.GameObjects.GameObjectCreator#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - }, - - /** - * Destroys this plugin. - * - * @method Phaser.GameObjects.GameObjectCreator#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.scene = null; - this.displayList = null; - this.updateList = null; - } - -}); - -// Static method called directly by the Game Object creator functions - -GameObjectCreator.register = function (type, factoryFunction) -{ - if (!GameObjectCreator.prototype.hasOwnProperty(type)) - { - GameObjectCreator.prototype[type] = factoryFunction; - } }; -PluginManager.register('GameObjectCreator', GameObjectCreator, 'make'); - -module.exports = GameObjectCreator; - /***/ }), /* 14 */ /***/ (function(module, exports, __webpack_require__) { +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(2); + +/** + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * + * @function Phaser.Tilemaps.Components.GetTilesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. + */ +var GetTilesWithin = function (tileX, tileY, width, height, filteringOptions, layer) +{ + if (tileX === undefined) { tileX = 0; } + if (tileY === undefined) { tileY = 0; } + if (width === undefined) { width = layer.width; } + if (height === undefined) { height = layer.height; } + + var isNotEmpty = GetFastValue(filteringOptions, 'isNotEmpty', false); + var isColliding = GetFastValue(filteringOptions, 'isColliding', false); + var hasInterestingFace = GetFastValue(filteringOptions, 'hasInterestingFace', false); + + // Clip x, y to top left of map, while shrinking width/height to match. + if (tileX < 0) + { + width += tileX; + tileX = 0; + } + if (tileY < 0) + { + height += tileY; + tileY = 0; + } + + // Clip width and height to bottom right of map. + if (tileX + width > layer.width) + { + width = Math.max(layer.width - tileX, 0); + } + if (tileY + height > layer.height) + { + height = Math.max(layer.height - tileY, 0); + } + + var results = []; + + for (var ty = tileY; ty < tileY + height; ty++) + { + for (var tx = tileX; tx < tileX + width; tx++) + { + var tile = layer.data[ty][tx]; + if (tile !== null) + { + if (isNotEmpty && tile.index === -1) { continue; } + if (isColliding && !tile.collides) { continue; } + if (hasInterestingFace && !tile.hasInterestingFace) { continue; } + results.push(tile); + } + } + } + + return results; +}; + +module.exports = GetTilesWithin; + + +/***/ }), +/* 15 */ +/***/ (function(module, exports, __webpack_require__) { + "use strict"; @@ -2925,95 +3047,6 @@ if (true) { } -/***/ }), -/* 15 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetFastValue = __webpack_require__(2); - -/** - * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. - * - * @function Phaser.Tilemaps.Components.GetTilesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. - */ -var GetTilesWithin = function (tileX, tileY, width, height, filteringOptions, layer) -{ - if (tileX === undefined) { tileX = 0; } - if (tileY === undefined) { tileY = 0; } - if (width === undefined) { width = layer.width; } - if (height === undefined) { height = layer.height; } - - var isNotEmpty = GetFastValue(filteringOptions, 'isNotEmpty', false); - var isColliding = GetFastValue(filteringOptions, 'isColliding', false); - var hasInterestingFace = GetFastValue(filteringOptions, 'hasInterestingFace', false); - - // Clip x, y to top left of map, while shrinking width/height to match. - if (tileX < 0) - { - width += tileX; - tileX = 0; - } - if (tileY < 0) - { - height += tileY; - tileY = 0; - } - - // Clip width and height to bottom right of map. - if (tileX + width > layer.width) - { - width = Math.max(layer.width - tileX, 0); - } - if (tileY + height > layer.height) - { - height = Math.max(layer.height - tileY, 0); - } - - var results = []; - - for (var ty = tileY; ty < tileY + height; ty++) - { - for (var tx = tileX; tx < tileX + width; tx++) - { - var tile = layer.data[ty][tx]; - if (tile !== null) - { - if (isNotEmpty && tile.index === -1) { continue; } - if (isColliding && !tile.collides) { continue; } - if (hasInterestingFace && !tile.hasInterestingFace) { continue; } - results.push(tile); - } - } - } - - return results; -}; - -module.exports = GetTilesWithin; - - /***/ }), /* 16 */ /***/ (function(module, exports, __webpack_require__) { @@ -3024,7 +3057,7 @@ module.exports = GetTilesWithin; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RND = __webpack_require__(390); +var RND = __webpack_require__(938); var MATH_CONST = { @@ -3270,6 +3303,105 @@ module.exports = FILE_CONST; /* 18 */ /***/ (function(module, exports, __webpack_require__) { +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var IsPlainObject = __webpack_require__(368); + +// @param {boolean} deep - Perform a deep copy? +// @param {object} target - The target object to copy to. +// @return {object} The extended object. + +/** + * This is a slightly modified version of http://api.jquery.com/jQuery.extend/ + * + * @function Phaser.Utils.Object.Extend + * @since 3.0.0 + * + * @return {object} [description] + */ +var Extend = function () +{ + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if (typeof target === 'boolean') + { + deep = target; + target = arguments[1] || {}; + + // skip the boolean and the target + i = 2; + } + + // extend Phaser if only one argument is passed + if (length === i) + { + target = this; + --i; + } + + for (; i < length; i++) + { + // Only deal with non-null/undefined values + if ((options = arguments[i]) != null) + { + // Extend the base object + for (name in options) + { + src = target[name]; + copy = options[name]; + + // Prevent never-ending loop + if (target === copy) + { + continue; + } + + // Recurse if we're merging plain objects or arrays + if (deep && copy && (IsPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) + { + if (copyIsArray) + { + copyIsArray = false; + clone = src && Array.isArray(src) ? src : []; + } + else + { + clone = src && IsPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[name] = Extend(deep, clone, copy); + + // Don't bring in undefined values + } + else if (copy !== undefined) + { + target[name] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +module.exports = Extend; + + +/***/ }), +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { + /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. @@ -3279,10 +3411,29 @@ module.exports = FILE_CONST; var Class = __webpack_require__(0); var CONST = __webpack_require__(17); var GetFastValue = __webpack_require__(2); -var GetURL = __webpack_require__(150); -var MergeXHRSettings = __webpack_require__(151); -var XHRLoader = __webpack_require__(315); -var XHRSettings = __webpack_require__(90); +var GetURL = __webpack_require__(122); +var MergeXHRSettings = __webpack_require__(121); +var XHRLoader = __webpack_require__(226); +var XHRSettings = __webpack_require__(94); + +/** + * @callback FileProcessCallback + * + * @param {Phaser.Loader.File} file - [description] + */ + +/** + * @typedef {object} FileConfig + * + * @property {(string|false)} [type=false] - The file type string (image, json, etc) for sorting within the Loader. + * @property {(string|false)} [key=false] - Unique cache key (unique within its file type) + * @property {string} [url] - The URL of the file, not including baseURL. + * @property {string} [path=''] - [description] + * @property {string} [extension=''] - [description] + * @property {XMLHttpRequestResponseType} [responseType] - [description] + * @property {(XHRSettingsObject|false)} [xhrSettings=false] - [description] + * @property {object} [config] - A config object that can be used by file types to store transitional data. + */ /** * @classdesc @@ -3293,7 +3444,7 @@ var XHRSettings = __webpack_require__(90); * @constructor * @since 3.0.0 * - * @param {object} fileConfig - [description] + * @param {FileConfig} fileConfig - [description] */ var File = new Class({ @@ -3303,7 +3454,7 @@ var File = new Class({ { /** * The file type string (image, json, etc) for sorting within the Loader. - * + * * @name Phaser.Loader.File#type * @type {string} * @since 3.0.0 @@ -3355,7 +3506,7 @@ var File = new Class({ * The merged XHRSettings for this file. * * @name Phaser.Loader.File#xhrSettings - * @type {Phaser.Loader.XHRSettings} + * @type {XHRSettingsObject} * @since 3.0.0 */ this.xhrSettings = XHRSettings(GetFastValue(fileConfig, 'responseType', undefined)); @@ -3430,7 +3581,7 @@ var File = new Class({ * If this is undefined then the File will check BaseLoader.crossOrigin and use that (if set) * * @name Phaser.Loader.File#crossOrigin - * @type {string|undefined} + * @type {(string|undefined)} * @since 3.0.0 */ this.crossOrigin = undefined; @@ -3439,7 +3590,7 @@ var File = new Class({ * The processed file data, stored in here after the file has loaded. * * @name Phaser.Loader.File#data - * @type {any} + * @type {*} * @since 3.0.0 */ this.data = undefined; @@ -3491,7 +3642,7 @@ var File = new Class({ * * @method Phaser.Loader.File#setLinkFile * @since 3.0.0 - * + * * @param {Phaser.Loader.File} fileB - The linked file. * @param {string} linkType - The type of association. */ @@ -3514,9 +3665,12 @@ var File = new Class({ */ resetXHR: function () { - this.xhrLoader.onload = undefined; - this.xhrLoader.onerror = undefined; - this.xhrLoader.onprogress = undefined; + if (this.xhrLoader) + { + this.xhrLoader.onload = undefined; + this.xhrLoader.onerror = undefined; + this.xhrLoader.onprogress = undefined; + } }, /** @@ -3619,7 +3773,7 @@ var File = new Class({ * @method Phaser.Loader.File#onProcess * @since 3.0.0 * - * @param {function} callback - The callback to invoke to process this File. + * @param {FileProcessCallback} callback - The callback to invoke to process this File. */ onProcess: function (callback) { @@ -3713,7 +3867,72 @@ module.exports = File; /***/ }), -/* 19 */ +/* 20 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes an array of Game Objects, or any objects that have a public property as defined in `key`, + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `PropertyValueSet(group.getChildren(), key, value, step)` + * + * @function Phaser.Actions.PropertyValueSet + * @since 3.3.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {string} key - The property to be updated. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var PropertyValueSet = function (items, key, value, step, index, direction) +{ + if (step === undefined) { step = 0; } + if (index === undefined) { index = 0; } + if (direction === undefined) { direction = 1; } + + var i; + var t = 0; + var end = items.length; + + if (direction === 1) + { + // Start to End + for (i = index; i < end; i++) + { + items[i][key] = value + (t * step); + t++; + } + } + else + { + // End to Start + for (i = index; i >= 0; i--) + { + items[i][key] = value + (t * step); + t++; + } + } + + return items; +}; + +module.exports = PropertyValueSet; + + +/***/ }), +/* 21 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -3731,11 +3950,11 @@ var CONST = { * @type {string} * @since 3.0.0 */ - VERSION: '3.2.1', + VERSION: '3.3.0', - BlendModes: __webpack_require__(45), + BlendModes: __webpack_require__(62), - ScaleModes: __webpack_require__(63), + ScaleModes: __webpack_require__(80), /** * AUTO Detect Renderer. @@ -3834,7 +4053,7 @@ module.exports = CONST; /***/ }), -/* 20 */ +/* 22 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -3843,19 +4062,39 @@ module.exports = CONST; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BlendModes = __webpack_require__(45); -var GetAdvancedValue = __webpack_require__(10); -var ScaleModes = __webpack_require__(63); +var BlendModes = __webpack_require__(62); +var GetAdvancedValue = __webpack_require__(8); +var ScaleModes = __webpack_require__(80); + +/** + * @typedef {object} GameObjectConfig + * + * @property {number} [x=0] - [description] + * @property {number} [y=0] - [description] + * @property {number} [depth=0] - [description] + * @property {boolean} [flipX=false] - [description] + * @property {boolean} [flipY=false] - [description] + * @property {?(number|object)} [scale=null] - [description] + * @property {?(number|object)} [scrollFactor=null] - [description] + * @property {number} [rotation=0] - [description] + * @property {?number} [angle=null] - [description] + * @property {number} [alpha=1] - [description] + * @property {?(number|object)} [origin=null] - [description] + * @property {number} [scaleMode=ScaleModes.DEFAULT] - [description] + * @property {number} [blendMode=BlendModes.DEFAULT] - [description] + * @property {boolean} [visible=true] - [description] + * @property {boolean} [add=true] - [description] + */ /** * Builds a Game Object using the provided configuration object. * - * @function Phaser.Gameobjects.BuildGameObject + * @function Phaser.GameObjects.BuildGameObject * @since 3.0.0 * * @param {Phaser.Scene} scene - [description] * @param {Phaser.GameObjects.GameObject} gameObject - [description] - * @param {object} config - [description] + * @param {GameObjectConfig} config - [description] * * @return {Phaser.GameObjects.GameObject} The built Game Object. */ @@ -3967,7 +4206,7 @@ module.exports = BuildGameObject; /***/ }), -/* 21 */ +/* 23 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -3976,8 +4215,8 @@ module.exports = BuildGameObject; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CONST = __webpack_require__(19); -var Smoothing = __webpack_require__(121); +var CONST = __webpack_require__(21); +var Smoothing = __webpack_require__(151); // The pool into which the canvas elements are placed. var pool = []; @@ -3992,7 +4231,7 @@ var _disableContextSmoothing = false; * before a Phaser.Game instance has even been created. * Which means all instances of Phaser Games on the same page * can share the one single pool - * + * * @namespace Phaser.Display.Canvas.CanvasPool * @since 3.0.0 */ @@ -4003,29 +4242,29 @@ var CanvasPool = function () * * @function Phaser.Display.Canvas.CanvasPool.create * @since 3.0.0 - * - * @param {any} parent - [description] - * @param {integer} [width=1] - [description] - * @param {integer} [height=1] - [description] - * @param {integer} [type] - [description] - * + * + * @param {*} parent - The parent of the Canvas object. + * @param {integer} [width=1] - The width of the Canvas. + * @param {integer} [height=1] - The height of the Canvas. + * @param {integer} [canvasType=Phaser.CANVAS] - The type of the Canvas. Either `Phaser.CANVAS` or `Phaser.WEBGL`. + * * @return {HTMLCanvasElement} [description] */ - var create = function (parent, width, height, type) + var create = function (parent, width, height, canvasType) { if (width === undefined) { width = 1; } if (height === undefined) { height = 1; } - if (type === undefined) { type = CONST.CANVAS; } + if (canvasType === undefined) { canvasType = CONST.CANVAS; } var canvas; - var container = first(type); + var container = first(canvasType); if (container === null) { container = { parent: parent, canvas: document.createElement('canvas'), - type: type + type: canvasType }; pool.push(container); @@ -4042,11 +4281,11 @@ var CanvasPool = function () canvas.width = width; canvas.height = height; - if (_disableContextSmoothing && type === CONST.CANVAS) + if (_disableContextSmoothing && canvasType === CONST.CANVAS) { Smoothing.disable(canvas.getContext('2d')); } - + return canvas; }; @@ -4055,11 +4294,11 @@ var CanvasPool = function () * * @function Phaser.Display.Canvas.CanvasPool.create2D * @since 3.0.0 - * - * @param {any} parent - [description] - * @param {integer} [width=1] - [description] - * @param {integer} [height=1] - [description] - * + * + * @param {*} parent - The parent of the Canvas object. + * @param {integer} [width=1] - The width of the Canvas. + * @param {integer} [height=1] - The height of the Canvas. + * * @return {HTMLCanvasElement} [description] */ var create2D = function (parent, width, height) @@ -4072,11 +4311,11 @@ var CanvasPool = function () * * @function Phaser.Display.Canvas.CanvasPool.createWebGL * @since 3.0.0 - * - * @param {any} parent - [description] - * @param {integer} [width=1] - [description] - * @param {integer} [height=1] - [description] - * + * + * @param {*} parent - The parent of the Canvas object. + * @param {integer} [width=1] - The width of the Canvas. + * @param {integer} [height=1] - The height of the Canvas. + * * @return {HTMLCanvasElement} [description] */ var createWebGL = function (parent, width, height) @@ -4089,18 +4328,18 @@ var CanvasPool = function () * * @function Phaser.Display.Canvas.CanvasPool.first * @since 3.0.0 - * - * @param {integer} [type] - [description] - * + * + * @param {integer} [canvasType=Phaser.CANVAS] - The type of the Canvas. Either `Phaser.CANVAS` or `Phaser.WEBGL`. + * * @return {HTMLCanvasElement} [description] */ - var first = function (type) + var first = function (canvasType) { - if (type === undefined) { type = CONST.CANVAS; } + if (canvasType === undefined) { canvasType = CONST.CANVAS; } pool.forEach(function (container) { - if (!container.parent && container.type === type) + if (!container.parent && container.type === canvasType) { return container; } @@ -4115,8 +4354,8 @@ var CanvasPool = function () * * @function Phaser.Display.Canvas.CanvasPool.remove * @since 3.0.0 - * - * @param {any} parent - [description] + * + * @param {*} parent - [description] */ var remove = function (parent) { @@ -4140,7 +4379,7 @@ var CanvasPool = function () * * @function Phaser.Display.Canvas.CanvasPool.total * @since 3.0.0 - * + * * @return {integer} [description] */ var total = function () @@ -4163,7 +4402,7 @@ var CanvasPool = function () * * @function Phaser.Display.Canvas.CanvasPool.free * @since 3.0.0 - * + * * @return {integer} [description] */ var free = function () @@ -4212,7 +4451,7 @@ module.exports = CanvasPool(); /***/ }), -/* 22 */ +/* 24 */ /***/ (function(module, exports) { /** @@ -4266,133 +4505,6 @@ module.exports = { }; -/***/ }), -/* 23 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var IsPlainObject = __webpack_require__(170); - -// @param {boolean} deep - Perform a deep copy? -// @param {object} target - The target object to copy to. -// @return {object} The extended object. - -/** - * This is a slightly modified version of http://api.jquery.com/jQuery.extend/ - * - * @function Phaser.Utils.Object.Extend - * @since 3.0.0 - * - * @return {object} [description] - */ -var Extend = function () -{ - var options, name, src, copy, copyIsArray, clone, - target = arguments[0] || {}, - i = 1, - length = arguments.length, - deep = false; - - // Handle a deep copy situation - if (typeof target === 'boolean') - { - deep = target; - target = arguments[1] || {}; - - // skip the boolean and the target - i = 2; - } - - // extend Phaser if only one argument is passed - if (length === i) - { - target = this; - --i; - } - - for (; i < length; i++) - { - // Only deal with non-null/undefined values - if ((options = arguments[i]) != null) - { - // Extend the base object - for (name in options) - { - src = target[name]; - copy = options[name]; - - // Prevent never-ending loop - if (target === copy) - { - continue; - } - - // Recurse if we're merging plain objects or arrays - if (deep && copy && (IsPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) - { - if (copyIsArray) - { - copyIsArray = false; - clone = src && Array.isArray(src) ? src : []; - } - else - { - clone = src && IsPlainObject(src) ? src : {}; - } - - // Never move original objects, clone them - target[name] = Extend(deep, clone, copy); - - // Don't bring in undefined values - } - else if (copy !== undefined) - { - target[name] = copy; - } - } - } - } - - // Return the modified object - return target; -}; - -module.exports = Extend; - - -/***/ }), -/* 24 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the bottom coordinate from the bounds of the Game Object. - * - * @function Phaser.Display.Bounds.GetBottom - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The bottom coordinate of the bounds of the Game Object. - */ -var GetBottom = function (gameObject) -{ - return (gameObject.y + gameObject.height) - (gameObject.height * gameObject.originY); -}; - -module.exports = GetBottom; - - /***/ }), /* 25 */ /***/ (function(module, exports) { @@ -4404,281 +4516,62 @@ module.exports = GetBottom; */ /** - * Positions the Game Object so that the bottom of its bounds aligns with the given coordinate. + * Takes an array of Game Objects, or any objects that have a public property as defined in `key`, + * and then adds the given value to it. * - * @function Phaser.Display.Bounds.SetBottom - * @since 3.0.0 + * The optional `step` property is applied incrementally, multiplied by each item in the array. * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} value - The coordinate to position the Game Object bounds on. + * To use this with a Group: `PropertyValueInc(group.getChildren(), key, value, step)` * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + * @function Phaser.Actions.PropertyValueInc + * @since 3.3.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {string} key - The property to be updated. + * @param {number} value - The amount to be added to the property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. */ -var SetBottom = function (gameObject, value) +var PropertyValueInc = function (items, key, value, step, index, direction) { - gameObject.y = (value - gameObject.height) + (gameObject.height * gameObject.originY); + if (step === undefined) { step = 0; } + if (index === undefined) { index = 0; } + if (direction === undefined) { direction = 1; } - return gameObject; + var i; + var t = 0; + var end = items.length; + + if (direction === 1) + { + // Start to End + for (i = index; i < end; i++) + { + items[i][key] += value + (t * step); + t++; + } + } + else + { + // End to Start + for (i = index; i >= 0; i--) + { + items[i][key] += value + (t * step); + t++; + } + } + + return items; }; -module.exports = SetBottom; +module.exports = PropertyValueInc; /***/ }), /* 26 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the left coordinate from the bounds of the Game Object. - * - * @function Phaser.Display.Bounds.GetLeft - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The left coordinate of the bounds of the Game Object. - */ -var GetLeft = function (gameObject) -{ - return gameObject.x - (gameObject.width * gameObject.originX); -}; - -module.exports = GetLeft; - - -/***/ }), -/* 27 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Positions the Game Object so that the left of its bounds aligns with the given coordinate. - * - * @function Phaser.Display.Bounds.SetLeft - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} value - The coordinate to position the Game Object bounds on. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. - */ -var SetLeft = function (gameObject, value) -{ - gameObject.x = value + (gameObject.width * gameObject.originX); - - return gameObject; -}; - -module.exports = SetLeft; - - -/***/ }), -/* 28 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the right coordinate from the bounds of the Game Object. - * - * @function Phaser.Display.Bounds.GetRight - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The right coordinate of the bounds of the Game Object. - */ -var GetRight = function (gameObject) -{ - return (gameObject.x + gameObject.width) - (gameObject.width * gameObject.originX); -}; - -module.exports = GetRight; - - -/***/ }), -/* 29 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Positions the Game Object so that the left of its bounds aligns with the given coordinate. - * - * @function Phaser.Display.Bounds.SetRight - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} value - The coordinate to position the Game Object bounds on. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. - */ -var SetRight = function (gameObject, value) -{ - gameObject.x = (value - gameObject.width) + (gameObject.width * gameObject.originX); - - return gameObject; -}; - -module.exports = SetRight; - - -/***/ }), -/* 30 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the top coordinate from the bounds of the Game Object. - * - * @function Phaser.Display.Bounds.GetTop - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The top coordinate of the bounds of the Game Object. - */ -var GetTop = function (gameObject) -{ - return gameObject.y - (gameObject.height * gameObject.originY); -}; - -module.exports = GetTop; - - -/***/ }), -/* 31 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Positions the Game Object so that the top of its bounds aligns with the given coordinate. - * - * @function Phaser.Display.Bounds.SetTop - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} value - The coordinate to position the Game Object bounds on. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. - */ -var SetTop = function (gameObject, value) -{ - gameObject.y = value + (gameObject.height * gameObject.originY); - - return gameObject; -}; - -module.exports = SetTop; - - -/***/ }), -/* 32 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Check to see if the Circle contains the given x / y coordinates. - * - * @function Phaser.Geom.Circle.Contains - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to check. - * @param {number} x - The x coordinate to check within the circle. - * @param {number} y - The y coordinate to check within the circle. - * - * @return {boolean} True if the coordinates are within the circle, otherwise false. - */ -var Contains = function (circle, x, y) -{ - // Check if x/y are within the bounds first - if (circle.radius > 0 && x >= circle.left && x <= circle.right && y >= circle.top && y <= circle.bottom) - { - var dx = (circle.x - x) * (circle.x - x); - var dy = (circle.y - y) * (circle.y - y); - - return (dx + dy) <= (circle.radius * circle.radius); - } - else - { - return false; - } -}; - -module.exports = Contains; - - -/***/ }), -/* 33 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Contains - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ -var Contains = function (rect, x, y) -{ - if (rect.width <= 0 || rect.height <= 0) - { - return false; - } - - return (rect.x <= x && rect.x + rect.width >= x && rect.y <= y && rect.y + rect.height >= y); -}; - -module.exports = Contains; - - -/***/ }), -/* 34 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -4687,8 +4580,8 @@ module.exports = Contains; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetTileAt = __webpack_require__(97); -var GetTilesWithin = __webpack_require__(15); +var GetTileAt = __webpack_require__(87); +var GetTilesWithin = __webpack_require__(14); /** * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the @@ -4743,8 +4636,8 @@ module.exports = CalculateFacesWithin; /***/ }), -/* 35 */ -/***/ (function(module, exports, __webpack_require__) { +/* 27 */ +/***/ (function(module, exports) { /** * @author Richard Davey @@ -4752,29 +4645,283 @@ module.exports = CalculateFacesWithin; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CONST = __webpack_require__(16); - /** * [description] * - * @function Phaser.Math.DegToRad + * @function Phaser.Geom.Rectangle.Contains * @since 3.0.0 * - * @param {integer} degrees - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} x - [description] + * @param {number} y - [description] * - * @return {float} [description] + * @return {boolean} [description] */ -var DegToRad = function (degrees) +var Contains = function (rect, x, y) { - return degrees * CONST.DEG_TO_RAD; + if (rect.width <= 0 || rect.height <= 0) + { + return false; + } + + return (rect.x <= x && rect.x + rect.width >= x && rect.y <= y && rect.y + rect.height >= y); }; -module.exports = DegToRad; +module.exports = Contains; + + +/***/ }), +/* 28 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Check to see if the Circle contains the given x / y coordinates. + * + * @function Phaser.Geom.Circle.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to check. + * @param {number} x - The x coordinate to check within the circle. + * @param {number} y - The y coordinate to check within the circle. + * + * @return {boolean} True if the coordinates are within the circle, otherwise false. + */ +var Contains = function (circle, x, y) +{ + // Check if x/y are within the bounds first + if (circle.radius > 0 && x >= circle.left && x <= circle.right && y >= circle.top && y <= circle.bottom) + { + var dx = (circle.x - x) * (circle.x - x); + var dy = (circle.y - y) * (circle.y - y); + + return (dx + dy) <= (circle.radius * circle.radius); + } + else + { + return false; + } +}; + +module.exports = Contains; + + +/***/ }), +/* 29 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the top of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetTop + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetTop = function (gameObject, value) +{ + gameObject.y = value + (gameObject.height * gameObject.originY); + + return gameObject; +}; + +module.exports = SetTop; + + +/***/ }), +/* 30 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the top coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetTop + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The top coordinate of the bounds of the Game Object. + */ +var GetTop = function (gameObject) +{ + return gameObject.y - (gameObject.height * gameObject.originY); +}; + +module.exports = GetTop; + + +/***/ }), +/* 31 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the left of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetRight + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetRight = function (gameObject, value) +{ + gameObject.x = (value - gameObject.width) + (gameObject.width * gameObject.originX); + + return gameObject; +}; + +module.exports = SetRight; + + +/***/ }), +/* 32 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the right coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetRight + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The right coordinate of the bounds of the Game Object. + */ +var GetRight = function (gameObject) +{ + return (gameObject.x + gameObject.width) - (gameObject.width * gameObject.originX); +}; + +module.exports = GetRight; + + +/***/ }), +/* 33 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the left of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetLeft + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetLeft = function (gameObject, value) +{ + gameObject.x = value + (gameObject.width * gameObject.originX); + + return gameObject; +}; + +module.exports = SetLeft; + + +/***/ }), +/* 34 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the left coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetLeft + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The left coordinate of the bounds of the Game Object. + */ +var GetLeft = function (gameObject) +{ + return gameObject.x - (gameObject.width * gameObject.originX); +}; + +module.exports = GetLeft; + + +/***/ }), +/* 35 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the bottom of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetBottom + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetBottom = function (gameObject, value) +{ + gameObject.y = (value - gameObject.height) + (gameObject.height * gameObject.originY); + + return gameObject; +}; + +module.exports = SetBottom; /***/ }), /* 36 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -4782,513 +4929,27 @@ module.exports = DegToRad; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var GetColor = __webpack_require__(117); -var GetColor32 = __webpack_require__(204); - /** - * @classdesc - * The Color class holds a single color value and allows for easy modification and reading of it. + * Returns the bottom coordinate from the bounds of the Game Object. * - * @class Color - * @memberOf Phaser.Display - * @constructor + * @function Phaser.Display.Bounds.GetBottom * @since 3.0.0 * - * @param {integer} [red=0] - The red color value. A number between 0 and 255. - * @param {integer} [green=0] - The green color value. A number between 0 and 255. - * @param {integer} [blue=0] - The blue color value. A number between 0 and 255. - * @param {integer} [alpha=255] - The alpha value. A number between 0 and 255. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The bottom coordinate of the bounds of the Game Object. */ -var Color = new Class({ +var GetBottom = function (gameObject) +{ + return (gameObject.y + gameObject.height) - (gameObject.height * gameObject.originY); +}; - initialize: - - function Color (red, green, blue, alpha) - { - if (red === undefined) { red = 0; } - if (green === undefined) { green = 0; } - if (blue === undefined) { blue = 0; } - if (alpha === undefined) { alpha = 255; } - - /** - * The internal red color value. - * - * @name Phaser.Display.Color#r - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this.r = 0; - - /** - * The internal green color value. - * - * @name Phaser.Display.Color#g - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this.g = 0; - - /** - * The internal blue color value. - * - * @name Phaser.Display.Color#b - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this.b = 0; - - /** - * The internal alpha color value. - * - * @name Phaser.Display.Color#a - * @type {number} - * @private - * @default 255 - * @since 3.0.0 - */ - this.a = 255; - - /** - * An array containing the calculated color values for WebGL use. - * - * @name Phaser.Display.Color#gl - * @type {array} - * @since 3.0.0 - */ - this.gl = [ 0, 0, 0, 1 ]; - - /** - * Pre-calculated internal color value. - * - * @name Phaser.Display.Color#_color - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._color = 0; - - /** - * Pre-calculated internal color32 value. - * - * @name Phaser.Display.Color#_color32 - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._color32 = 0; - - /** - * Pre-calculated internal color rgb string value. - * - * @name Phaser.Display.Color#_rgba - * @type {string} - * @private - * @default '' - * @since 3.0.0 - */ - this._rgba = ''; - - this.setTo(red, green, blue, alpha); - }, - - /** - * Sets this color to be transparent. Sets all values to zero. - * - * @method Phaser.Curves.Color#transparent - * @since 3.0.0 - * - * @return {Phaser.Display.Color} This Color object. - */ - transparent: function () - { - this.red = 0; - this.green = 0; - this.blue = 0; - this.alpha = 0; - - return this.update(); - }, - - /** - * Sets the color of this Color component. - * - * @method Phaser.Curves.Color#setTo - * @since 3.0.0 - * - * @param {integer} red - The red color value. A number between 0 and 255. - * @param {integer} green - The green color value. A number between 0 and 255. - * @param {integer} blue - The blue color value. A number between 0 and 255. - * @param {integer} [alpha=255] - The alpha value. A number between 0 and 255. - * - * @return {Phaser.Display.Color} This Color object. - */ - setTo: function (red, green, blue, alpha) - { - if (alpha === undefined) { alpha = 255; } - - this.red = red; - this.green = green; - this.blue = blue; - this.alpha = alpha; - - return this.update(); - }, - - /** - * Sets the red, green, blue and alpha GL values of this Color component. - * - * @method Phaser.Curves.Color#setGLTo - * @since 3.0.0 - * - * @param {float} red - The red color value. A number between 0 and 1. - * @param {float} green - The green color value. A number between 0 and 1. - * @param {float} blue - The blue color value. A number between 0 and 1. - * @param {float} [alpha=1] - The alpha value. A number between 0 and 1. - * - * @return {Phaser.Display.Color} This Color object. - */ - setGLTo: function (red, green, blue, alpha) - { - if (alpha === undefined) { alpha = 1; } - - this.redGL = red; - this.greenGL = green; - this.blueGL = blue; - this.alphaGL = alpha; - - return this.update(); - }, - - /** - * Sets the color based on the color object given. - * - * @method Phaser.Curves.Color#setFromRGB - * @since 3.0.0 - * - * @param {object} color - An object containing `r`, `g`, `b` and optionally `a` values in the range 0 to 255. - * - * @return {Phaser.Display.Color} This Color object. - */ - setFromRGB: function (color) - { - this.red = color.r; - this.green = color.g; - this.blue = color.b; - - if (color.hasOwnProperty('a')) - { - this.alpha = color.a; - } - - return this.update(); - }, - - /** - * Updates the internal cache values. - * - * @method Phaser.Curves.Color#update - * @since 3.0.0 - * - * @return {Phaser.Display.Color} This Color object. - */ - update: function () - { - this._color = GetColor(this.r, this.g, this.b); - this._color32 = GetColor32(this.r, this.g, this.b, this.a); - this._rgba = 'rgba(' + this.r + ',' + this.g + ',' + this.b + ',' + (this.a / 255) + ')'; - - return this; - }, - - /** - * Returns a new Color component using the values from this one. - * - * @method Phaser.Curves.Color#clone - * @since 3.0.0 - * - * @return {Phaser.Display.Color} A new Color object. - */ - clone: function () - { - return new Color(this.r, this.g, this.b, this.a); - }, - - /** - * The color of this Color component, not including the alpha channel. - * - * @name Phaser.Display.Color#color - * @type {number} - * @readOnly - * @since 3.0.0 - */ - color: { - - get: function () - { - return this._color; - } - - }, - - /** - * The color of this Color component, including the alpha channel. - * - * @name Phaser.Display.Color#color32 - * @type {number} - * @readOnly - * @since 3.0.0 - */ - color32: { - - get: function () - { - return this._color32; - } - - }, - - /** - * The color of this Color component as a string which can be used in CSS color values. - * - * @name Phaser.Display.Color#rgba - * @type {string} - * @readOnly - * @since 3.0.0 - */ - rgba: { - - get: function () - { - return this._rgba; - } - - }, - - /** - * The red color value, normalized to the range 0 to 1. - * - * @name Phaser.Display.Color#redGL - * @type {float} - * @since 3.0.0 - */ - redGL: { - - get: function () - { - return this.gl[0]; - }, - - set: function (value) - { - this.gl[0] = Math.min(Math.abs(value), 1); - - this.r = Math.floor(this.gl[0] * 255); - - this.update(); - } - - }, - - /** - * The green color value, normalized to the range 0 to 1. - * - * @name Phaser.Display.Color#greenGL - * @type {float} - * @since 3.0.0 - */ - greenGL: { - - get: function () - { - return this.gl[1]; - }, - - set: function (value) - { - this.gl[1] = Math.min(Math.abs(value), 1); - - this.g = Math.floor(this.gl[1] * 255); - - this.update(); - } - - }, - - /** - * The blue color value, normalized to the range 0 to 1. - * - * @name Phaser.Display.Color#blueGL - * @type {float} - * @since 3.0.0 - */ - blueGL: { - - get: function () - { - return this.gl[2]; - }, - - set: function (value) - { - this.gl[2] = Math.min(Math.abs(value), 1); - - this.b = Math.floor(this.gl[2] * 255); - - this.update(); - } - - }, - - /** - * The alpha color value, normalized to the range 0 to 1. - * - * @name Phaser.Display.Color#alphaGL - * @type {float} - * @since 3.0.0 - */ - alphaGL: { - - get: function () - { - return this.gl[3]; - }, - - set: function (value) - { - this.gl[3] = Math.min(Math.abs(value), 1); - - this.a = Math.floor(this.gl[3] * 255); - - this.update(); - } - - }, - - /** - * The red color value, normalized to the range 0 to 255. - * - * @name Phaser.Display.Color#red - * @type {float} - * @since 3.0.0 - */ - red: { - - get: function () - { - return this.r; - }, - - set: function (value) - { - value = Math.floor(Math.abs(value)); - - this.r = Math.min(value, 255); - - this.gl[0] = value / 255; - - this.update(); - } - - }, - - /** - * The green color value, normalized to the range 0 to 255. - * - * @name Phaser.Display.Color#green - * @type {float} - * @since 3.0.0 - */ - green: { - - get: function () - { - return this.g; - }, - - set: function (value) - { - value = Math.floor(Math.abs(value)); - - this.g = Math.min(value, 255); - - this.gl[1] = value / 255; - - this.update(); - } - - }, - - /** - * The blue color value, normalized to the range 0 to 255. - * - * @name Phaser.Display.Color#blue - * @type {float} - * @since 3.0.0 - */ - blue: { - - get: function () - { - return this.b; - }, - - set: function (value) - { - value = Math.floor(Math.abs(value)); - - this.b = Math.min(value, 255); - - this.gl[2] = value / 255; - - this.update(); - } - - }, - - /** - * The alpha color value, normalized to the range 0 to 255. - * - * @name Phaser.Display.Color#alpha - * @type {float} - * @since 3.0.0 - */ - alpha: { - - get: function () - { - return this.a; - }, - - set: function (value) - { - value = Math.floor(Math.abs(value)); - - this.a = Math.min(value, 255); - - this.gl[3] = value / 255; - - this.update(); - } - - } - -}); - -module.exports = Color; +module.exports = GetBottom; /***/ }), /* 37 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -5296,154 +4957,102 @@ module.exports = Color; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var GameObject = __webpack_require__(1); -var SpriteRender = __webpack_require__(457); - /** - * @classdesc - * A Sprite Game Object. + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layer's position, scale and scroll. * - * A Sprite Game Object is used for the display of both static and animated images in your game. - * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled - * and animated. - * - * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. - * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation - * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. - * - * @class Sprite - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor + * @function Phaser.Tilemaps.Components.WorldToTileY * @since 3.0.0 * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.Animation - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {number} worldY - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {number} The Y location in tile units. */ -var Sprite = new Class({ +var WorldToTileY = function (worldY, snapToFloor, camera, layer) +{ + if (snapToFloor === undefined) { snapToFloor = true; } - Extends: GameObject, + var tileHeight = layer.baseTileHeight; + var tilemapLayer = layer.tilemapLayer; - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Size, - Components.Texture, - Components.Tint, - Components.Transform, - Components.Visible, - SpriteRender - ], - - initialize: - - function Sprite (scene, x, y, texture, frame) + if (tilemapLayer) { - GameObject.call(this, scene, 'Sprite'); + if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } - /** - * [description] - * - * @name Phaser.GameObjects.Sprite#anims - * @type {[type]} - * @since 3.0.0 - */ - this.anims = new Components.Animation(this); + // Find the world position relative to the static or dynamic layer's top left origin, + // factoring in the camera's vertical scroll + worldY = worldY - (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY)); - this.setTexture(texture, frame); - this.setPosition(x, y); - this.setSizeToFrame(); - this.setOriginFromFrame(); - this.initPipeline('TextureTintPipeline'); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Sprite#preUpdate - * @since 3.0.0 - * - * @param {number} time - [description] - * @param {number} delta - [description] - */ - preUpdate: function (time, delta) - { - this.anims.update(time, delta); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Sprite#play - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {boolean} ignoreIfPlaying - [description] - * @param {integer|string} startFrame - [description] - * - * @return {Phaser.GameObjects.Sprite} This Game Object. - */ - play: function (key, ignoreIfPlaying, startFrame) - { - this.anims.play(key, ignoreIfPlaying, startFrame); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Sprite#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - var data = Components.ToJSON(this); - - // Extra Sprite data is added here - - return data; + tileHeight *= tilemapLayer.scaleY; } -}); + return snapToFloor + ? Math.floor(worldY / tileHeight) + : worldY / tileHeight; +}; -module.exports = Sprite; +module.exports = WorldToTileY; /***/ }), /* 38 */ /***/ (function(module, exports) { +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layer's position, scale and scroll. + * + * @function Phaser.Tilemaps.Components.WorldToTileX + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {number} The X location in tile units. + */ +var WorldToTileX = function (worldX, snapToFloor, camera, layer) +{ + if (snapToFloor === undefined) { snapToFloor = true; } + + var tileWidth = layer.baseTileWidth; + var tilemapLayer = layer.tilemapLayer; + + if (tilemapLayer) + { + if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } + + // Find the world position relative to the static or dynamic layer's top left origin, + // factoring in the camera's horizontal scroll + worldX = worldX - (tilemapLayer.x + camera.scrollX * (1 - tilemapLayer.scrollFactorX)); + + tileWidth *= tilemapLayer.scaleX; + } + + return snapToFloor + ? Math.floor(worldX / tileWidth) + : worldX / tileWidth; +}; + +module.exports = WorldToTileX; + + +/***/ }), +/* 39 */ +/***/ (function(module, exports) { + /** * The `Matter.Common` module contains utility functions that are common to all modules. * @@ -5981,60 +5590,9 @@ module.exports = Common; })(); -/***/ }), -/* 39 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the - * layer's position, scale and scroll. - * - * @function Phaser.Tilemaps.Components.WorldToTileX - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {number} The X location in tile units. - */ -var WorldToTileX = function (worldX, snapToFloor, camera, layer) -{ - if (snapToFloor === undefined) { snapToFloor = true; } - - var tileWidth = layer.baseTileWidth; - var tilemapLayer = layer.tilemapLayer; - - if (tilemapLayer) - { - if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } - - // Find the world position relative to the static or dynamic layer's top left origin, - // factoring in the camera's horizontal scroll - worldX = worldX - (tilemapLayer.x + camera.scrollX * (1 - tilemapLayer.scrollFactorX)); - - tileWidth *= tilemapLayer.scaleX; - } - - return snapToFloor - ? Math.floor(worldX / tileWidth) - : worldX / tileWidth; -}; - -module.exports = WorldToTileX; - - /***/ }), /* 40 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -6042,49 +5600,728 @@ module.exports = WorldToTileX; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var GameObject = __webpack_require__(1); +var SpriteRender = __webpack_require__(870); + /** - * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the - * layer's position, scale and scroll. + * @classdesc + * A Sprite Game Object. * - * @function Phaser.Tilemaps.Components.WorldToTileY + * A Sprite Game Object is used for the display of both static and animated images in your game. + * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled + * and animated. + * + * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. + * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation + * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. + * + * @class Sprite + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor * @since 3.0.0 * - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {number} The Y location in tile units. + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.Animation + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. */ -var WorldToTileY = function (worldY, snapToFloor, camera, layer) -{ - if (snapToFloor === undefined) { snapToFloor = true; } +var Sprite = new Class({ - var tileHeight = layer.baseTileHeight; - var tilemapLayer = layer.tilemapLayer; + Extends: GameObject, - if (tilemapLayer) + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Size, + Components.Texture, + Components.Tint, + Components.Transform, + Components.Visible, + SpriteRender + ], + + initialize: + + function Sprite (scene, x, y, texture, frame) { - if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } + GameObject.call(this, scene, 'Sprite'); - // Find the world position relative to the static or dynamic layer's top left origin, - // factoring in the camera's vertical scroll - worldY = worldY - (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY)); + /** + * [description] + * + * @name Phaser.GameObjects.Sprite#anims + * @type {Phaser.GameObjects.Components.Animation} + * @since 3.0.0 + */ + this.anims = new Components.Animation(this); - tileHeight *= tilemapLayer.scaleY; + this.setTexture(texture, frame); + this.setPosition(x, y); + this.setSizeToFrame(); + this.setOriginFromFrame(); + this.initPipeline('TextureTintPipeline'); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Sprite#preUpdate + * @since 3.0.0 + * + * @param {number} time - [description] + * @param {number} delta - [description] + */ + preUpdate: function (time, delta) + { + this.anims.update(time, delta); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Sprite#play + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {boolean} ignoreIfPlaying - [description] + * @param {(integer|string)} startFrame - [description] + * + * @return {Phaser.GameObjects.Sprite} This Game Object. + */ + play: function (key, ignoreIfPlaying, startFrame) + { + this.anims.play(key, ignoreIfPlaying, startFrame); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Sprite#toJSON + * @since 3.0.0 + * + * @return {object} [description] + */ + toJSON: function () + { + var data = Components.ToJSON(this); + + // Extra Sprite data is added here + + return data; } - return snapToFloor - ? Math.floor(worldY / tileHeight) - : worldY / tileHeight; -}; +}); -module.exports = WorldToTileY; +module.exports = Sprite; /***/ }), /* 41 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetColor = __webpack_require__(155); +var GetColor32 = __webpack_require__(335); + +/** + * @classdesc + * The Color class holds a single color value and allows for easy modification and reading of it. + * + * @class Color + * @memberOf Phaser.Display + * @constructor + * @since 3.0.0 + * + * @param {integer} [red=0] - The red color value. A number between 0 and 255. + * @param {integer} [green=0] - The green color value. A number between 0 and 255. + * @param {integer} [blue=0] - The blue color value. A number between 0 and 255. + * @param {integer} [alpha=255] - The alpha value. A number between 0 and 255. + */ +var Color = new Class({ + + initialize: + + function Color (red, green, blue, alpha) + { + if (red === undefined) { red = 0; } + if (green === undefined) { green = 0; } + if (blue === undefined) { blue = 0; } + if (alpha === undefined) { alpha = 255; } + + /** + * The internal red color value. + * + * @name Phaser.Display.Color#r + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.r = 0; + + /** + * The internal green color value. + * + * @name Phaser.Display.Color#g + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.g = 0; + + /** + * The internal blue color value. + * + * @name Phaser.Display.Color#b + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.b = 0; + + /** + * The internal alpha color value. + * + * @name Phaser.Display.Color#a + * @type {number} + * @private + * @default 255 + * @since 3.0.0 + */ + this.a = 255; + + /** + * An array containing the calculated color values for WebGL use. + * + * @name Phaser.Display.Color#gl + * @type {number[]} + * @since 3.0.0 + */ + this.gl = [ 0, 0, 0, 1 ]; + + /** + * Pre-calculated internal color value. + * + * @name Phaser.Display.Color#_color + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._color = 0; + + /** + * Pre-calculated internal color32 value. + * + * @name Phaser.Display.Color#_color32 + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._color32 = 0; + + /** + * Pre-calculated internal color rgb string value. + * + * @name Phaser.Display.Color#_rgba + * @type {string} + * @private + * @default '' + * @since 3.0.0 + */ + this._rgba = ''; + + this.setTo(red, green, blue, alpha); + }, + + /** + * Sets this color to be transparent. Sets all values to zero. + * + * @method Phaser.Display.Color#transparent + * @since 3.0.0 + * + * @return {Phaser.Display.Color} This Color object. + */ + transparent: function () + { + this.red = 0; + this.green = 0; + this.blue = 0; + this.alpha = 0; + + return this.update(); + }, + + /** + * Sets the color of this Color component. + * + * @method Phaser.Display.Color#setTo + * @since 3.0.0 + * + * @param {integer} red - The red color value. A number between 0 and 255. + * @param {integer} green - The green color value. A number between 0 and 255. + * @param {integer} blue - The blue color value. A number between 0 and 255. + * @param {integer} [alpha=255] - The alpha value. A number between 0 and 255. + * + * @return {Phaser.Display.Color} This Color object. + */ + setTo: function (red, green, blue, alpha) + { + if (alpha === undefined) { alpha = 255; } + + this.red = red; + this.green = green; + this.blue = blue; + this.alpha = alpha; + + return this.update(); + }, + + /** + * Sets the red, green, blue and alpha GL values of this Color component. + * + * @method Phaser.Display.Color#setGLTo + * @since 3.0.0 + * + * @param {float} red - The red color value. A number between 0 and 1. + * @param {float} green - The green color value. A number between 0 and 1. + * @param {float} blue - The blue color value. A number between 0 and 1. + * @param {float} [alpha=1] - The alpha value. A number between 0 and 1. + * + * @return {Phaser.Display.Color} This Color object. + */ + setGLTo: function (red, green, blue, alpha) + { + if (alpha === undefined) { alpha = 1; } + + this.redGL = red; + this.greenGL = green; + this.blueGL = blue; + this.alphaGL = alpha; + + return this.update(); + }, + + /** + * Sets the color based on the color object given. + * + * @method Phaser.Display.Color#setFromRGB + * @since 3.0.0 + * + * @param {InputColorObject} color - An object containing `r`, `g`, `b` and optionally `a` values in the range 0 to 255. + * + * @return {Phaser.Display.Color} This Color object. + */ + setFromRGB: function (color) + { + this.red = color.r; + this.green = color.g; + this.blue = color.b; + + if (color.hasOwnProperty('a')) + { + this.alpha = color.a; + } + + return this.update(); + }, + + /** + * Updates the internal cache values. + * + * @method Phaser.Display.Color#update + * @since 3.0.0 + * + * @return {Phaser.Display.Color} This Color object. + */ + update: function () + { + this._color = GetColor(this.r, this.g, this.b); + this._color32 = GetColor32(this.r, this.g, this.b, this.a); + this._rgba = 'rgba(' + this.r + ',' + this.g + ',' + this.b + ',' + (this.a / 255) + ')'; + + return this; + }, + + /** + * Returns a new Color component using the values from this one. + * + * @method Phaser.Display.Color#clone + * @since 3.0.0 + * + * @return {Phaser.Display.Color} A new Color object. + */ + clone: function () + { + return new Color(this.r, this.g, this.b, this.a); + }, + + /** + * The color of this Color component, not including the alpha channel. + * + * @name Phaser.Display.Color#color + * @type {number} + * @readOnly + * @since 3.0.0 + */ + color: { + + get: function () + { + return this._color; + } + + }, + + /** + * The color of this Color component, including the alpha channel. + * + * @name Phaser.Display.Color#color32 + * @type {number} + * @readOnly + * @since 3.0.0 + */ + color32: { + + get: function () + { + return this._color32; + } + + }, + + /** + * The color of this Color component as a string which can be used in CSS color values. + * + * @name Phaser.Display.Color#rgba + * @type {string} + * @readOnly + * @since 3.0.0 + */ + rgba: { + + get: function () + { + return this._rgba; + } + + }, + + /** + * The red color value, normalized to the range 0 to 1. + * + * @name Phaser.Display.Color#redGL + * @type {float} + * @since 3.0.0 + */ + redGL: { + + get: function () + { + return this.gl[0]; + }, + + set: function (value) + { + this.gl[0] = Math.min(Math.abs(value), 1); + + this.r = Math.floor(this.gl[0] * 255); + + this.update(); + } + + }, + + /** + * The green color value, normalized to the range 0 to 1. + * + * @name Phaser.Display.Color#greenGL + * @type {float} + * @since 3.0.0 + */ + greenGL: { + + get: function () + { + return this.gl[1]; + }, + + set: function (value) + { + this.gl[1] = Math.min(Math.abs(value), 1); + + this.g = Math.floor(this.gl[1] * 255); + + this.update(); + } + + }, + + /** + * The blue color value, normalized to the range 0 to 1. + * + * @name Phaser.Display.Color#blueGL + * @type {float} + * @since 3.0.0 + */ + blueGL: { + + get: function () + { + return this.gl[2]; + }, + + set: function (value) + { + this.gl[2] = Math.min(Math.abs(value), 1); + + this.b = Math.floor(this.gl[2] * 255); + + this.update(); + } + + }, + + /** + * The alpha color value, normalized to the range 0 to 1. + * + * @name Phaser.Display.Color#alphaGL + * @type {float} + * @since 3.0.0 + */ + alphaGL: { + + get: function () + { + return this.gl[3]; + }, + + set: function (value) + { + this.gl[3] = Math.min(Math.abs(value), 1); + + this.a = Math.floor(this.gl[3] * 255); + + this.update(); + } + + }, + + /** + * The red color value, normalized to the range 0 to 255. + * + * @name Phaser.Display.Color#red + * @type {number} + * @since 3.0.0 + */ + red: { + + get: function () + { + return this.r; + }, + + set: function (value) + { + value = Math.floor(Math.abs(value)); + + this.r = Math.min(value, 255); + + this.gl[0] = value / 255; + + this.update(); + } + + }, + + /** + * The green color value, normalized to the range 0 to 255. + * + * @name Phaser.Display.Color#green + * @type {number} + * @since 3.0.0 + */ + green: { + + get: function () + { + return this.g; + }, + + set: function (value) + { + value = Math.floor(Math.abs(value)); + + this.g = Math.min(value, 255); + + this.gl[1] = value / 255; + + this.update(); + } + + }, + + /** + * The blue color value, normalized to the range 0 to 255. + * + * @name Phaser.Display.Color#blue + * @type {number} + * @since 3.0.0 + */ + blue: { + + get: function () + { + return this.b; + }, + + set: function (value) + { + value = Math.floor(Math.abs(value)); + + this.b = Math.min(value, 255); + + this.gl[2] = value / 255; + + this.update(); + } + + }, + + /** + * The alpha color value, normalized to the range 0 to 255. + * + * @name Phaser.Display.Color#alpha + * @type {number} + * @since 3.0.0 + */ + alpha: { + + get: function () + { + return this.a; + }, + + set: function (value) + { + value = Math.floor(Math.abs(value)); + + this.a = Math.min(value, 255); + + this.gl[3] = value / 255; + + this.update(); + } + + } + +}); + +module.exports = Color; + + +/***/ }), +/* 42 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(16); + +/** + * [description] + * + * @function Phaser.Math.DegToRad + * @since 3.0.0 + * + * @param {integer} degrees - [description] + * + * @return {float} [description] + */ +var DegToRad = function (degrees) +{ + return degrees * CONST.DEG_TO_RAD; +}; + +module.exports = DegToRad; + + +/***/ }), +/* 43 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Wrap + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} min - [description] + * @param {number} max - [description] + * + * @return {number} [description] + */ +var Wrap = function (value, min, max) +{ + var range = max - min; + + return (min + ((((value - min) % range) + range) % range)); +}; + +module.exports = Wrap; + + +/***/ }), +/* 44 */ /***/ (function(module, exports) { /** @@ -6215,76 +6452,7 @@ module.exports = { /***/ }), -/* 42 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Distance.Between - * @since 3.0.0 - * - * @param {number} x1 - [description] - * @param {number} y1 - [description] - * @param {number} x2 - [description] - * @param {number} y2 - [description] - * - * @return {number} [description] - */ -var DistanceBetween = function (x1, y1, x2, y2) -{ - var dx = x1 - x2; - var dy = y1 - y2; - - return Math.sqrt(dx * dx + dy * dy); -}; - -module.exports = DistanceBetween; - - -/***/ }), -/* 43 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Internally used method to set the colliding state of a tile. This does not recalculate - * interesting faces. - * - * @function Phaser.Tilemaps.Components.SetTileCollision - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.Tile} tile - [description] - * @param {boolean} [collides=true] - [description] - */ -var SetTileCollision = function (tile, collides) -{ - if (collides) - { - tile.setCollision(true, true, true, true, false); - } - else - { - tile.resetCollision(false); - } -}; - -module.exports = SetTileCollision; - - -/***/ }), -/* 44 */ +/* 45 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -6294,8 +6462,8 @@ module.exports = SetTileCollision; */ var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var Rectangle = __webpack_require__(307); +var Components = __webpack_require__(13); +var Rectangle = __webpack_require__(234); /** * @classdesc @@ -6307,7 +6475,7 @@ var Rectangle = __webpack_require__(307); * @memberOf Phaser.Tilemaps * @constructor * @since 3.0.0 - * + * * @extends Phaser.GameObjects.Components.Alpha * @extends Phaser.GameObjects.Components.Flip * @extends Phaser.GameObjects.Components.Visible @@ -6339,7 +6507,7 @@ var Tile = new Class({ { /** * The LayerData in the Tilemap data that this tile belongs to. - * + * * @name Phaser.Tilemaps.Tile#layer * @type {Phaser.Tilemaps.LayerData} * @since 3.0.0 @@ -6349,7 +6517,7 @@ var Tile = new Class({ /** * The index of this tile within the map data corresponding to the tileset, or -1 if this * represents a blank tile. - * + * * @name Phaser.Tilemaps.Tile#index * @type {integer} * @since 3.0.0 @@ -6358,7 +6526,7 @@ var Tile = new Class({ /** * The x map coordinate of this tile in tile units. - * + * * @name Phaser.Tilemaps.Tile#x * @type {integer} * @since 3.0.0 @@ -6367,7 +6535,7 @@ var Tile = new Class({ /** * The y map coordinate of this tile in tile units. - * + * * @name Phaser.Tilemaps.Tile#y * @type {integer} * @since 3.0.0 @@ -6376,7 +6544,7 @@ var Tile = new Class({ /** * The width of the tile in pixels. - * + * * @name Phaser.Tilemaps.Tile#width * @type {integer} * @since 3.0.0 @@ -6385,7 +6553,7 @@ var Tile = new Class({ /** * The height of the tile in pixels. - * + * * @name Phaser.Tilemaps.Tile#height * @type {integer} * @since 3.0.0 @@ -6395,7 +6563,7 @@ var Tile = new Class({ /** * The map's base width of a tile in pixels. Tiled maps support multiple tileset sizes * within one map, but they are still placed at intervals of the base tile size. - * + * * @name Phaser.Tilemaps.Tile#baseWidth * @type {integer} * @since 3.0.0 @@ -6405,7 +6573,7 @@ var Tile = new Class({ /** * The map's base height of a tile in pixels. Tiled maps support multiple tileset sizes * within one map, but they are still placed at intervals of the base tile size. - * + * * @name Phaser.Tilemaps.Tile#baseHeight * @type {integer} * @since 3.0.0 @@ -6416,7 +6584,7 @@ var Tile = new Class({ * The x coordinate of the top left of this tile in pixels. This is relative to the top left * of the layer this tile is being rendered within. This property does NOT factor in camera * scroll, layer scale or layer position. - * + * * @name Phaser.Tilemaps.Tile#pixelX * @type {number} * @since 3.0.0 @@ -6427,7 +6595,7 @@ var Tile = new Class({ * The y coordinate of the top left of this tile in pixels. This is relative to the top left * of the layer this tile is being rendered within. This property does NOT factor in camera * scroll, layer scale or layer position. - * + * * @name Phaser.Tilemaps.Tile#pixelY * @type {number} * @since 3.0.0 @@ -6438,7 +6606,7 @@ var Tile = new Class({ /** * Tile specific properties. These usually come from Tiled. - * + * * @name Phaser.Tilemaps.Tile#properties * @type {object} * @since 3.0.0 @@ -6447,7 +6615,7 @@ var Tile = new Class({ /** * The rotation angle of this tile. - * + * * @name Phaser.Tilemaps.Tile#rotation * @type {number} * @since 3.0.0 @@ -6456,7 +6624,7 @@ var Tile = new Class({ /** * Whether the tile should collide with any object on the left side. - * + * * @name Phaser.Tilemaps.Tile#collideLeft * @type {boolean} * @since 3.0.0 @@ -6465,7 +6633,7 @@ var Tile = new Class({ /** * Whether the tile should collide with any object on the right side. - * + * * @name Phaser.Tilemaps.Tile#collideRight * @type {boolean} * @since 3.0.0 @@ -6474,7 +6642,7 @@ var Tile = new Class({ /** * Whether the tile should collide with any object on the top side. - * + * * @name Phaser.Tilemaps.Tile#collideUp * @type {boolean} * @since 3.0.0 @@ -6483,7 +6651,7 @@ var Tile = new Class({ /** * Whether the tile should collide with any object on the bottom side. - * + * * @name Phaser.Tilemaps.Tile#collideDown * @type {boolean} * @since 3.0.0 @@ -6492,7 +6660,7 @@ var Tile = new Class({ /** * Whether the tile's left edge is interesting for collisions. - * + * * @name Phaser.Tilemaps.Tile#faceLeft * @type {boolean} * @since 3.0.0 @@ -6501,7 +6669,7 @@ var Tile = new Class({ /** * Whether the tile's right edge is interesting for collisions. - * + * * @name Phaser.Tilemaps.Tile#faceRight * @type {boolean} * @since 3.0.0 @@ -6510,7 +6678,7 @@ var Tile = new Class({ /** * Whether the tile's top edge is interesting for collisions. - * + * * @name Phaser.Tilemaps.Tile#faceTop * @type {boolean} * @since 3.0.0 @@ -6519,7 +6687,7 @@ var Tile = new Class({ /** * Whether the tile's bottom edge is interesting for collisions. - * + * * @name Phaser.Tilemaps.Tile#faceBottom * @type {boolean} * @since 3.0.0 @@ -6528,7 +6696,7 @@ var Tile = new Class({ /** * Tile collision callback. - * + * * @name Phaser.Tilemaps.Tile#collisionCallback * @type {function} * @since 3.0.0 @@ -6537,7 +6705,7 @@ var Tile = new Class({ /** * The context in which the collision callback will be called. - * + * * @name Phaser.Tilemaps.Tile#collisionCallbackContext * @type {object} * @since 3.0.0 @@ -6547,7 +6715,7 @@ var Tile = new Class({ /** * The tint to apply to this tile. Note: tint is currently a single color value instead of * the 4 corner tint component on other GameObjects. - * + * * @name Phaser.Tilemaps.Tile#tint * @type {number} * @default @@ -6557,7 +6725,7 @@ var Tile = new Class({ /** * An empty object where physics-engine specific information (e.g. bodies) may be stored. - * + * * @name Phaser.Tilemaps.Tile#physics * @type {object} * @since 3.0.0 @@ -6571,10 +6739,10 @@ var Tile = new Class({ * * @method Phaser.Tilemaps.Tile#containsPoint * @since 3.0.0 - * + * * @param {number} x - The x coordinate to test. * @param {number} y - The y coordinate to test. - * + * * @return {boolean} True if the coordinates are within this Tile, otherwise false. */ containsPoint: function (x, y) @@ -6588,9 +6756,9 @@ var Tile = new Class({ * * @method Phaser.Tilemaps.Tile#containsPoint * @since 3.0.0 - * + * * @param {Phaser.Tilemaps.Tile} tile - The tile to copy from. - * + * * @return {Phaser.Tilemaps.Tile} This Tile object. */ copy: function (tile) @@ -6616,11 +6784,11 @@ var Tile = new Class({ * The collision group for this Tile, defined within the Tileset. This returns a reference to * the collision group stored within the Tileset, so any modification of the returned object * will impact all tiles that have the same index as this tile. - * + * * @method Phaser.Tilemaps.Tile#getCollisionGroup * @since 3.0.0 - * - * @return {object|null} tileset + * + * @return {?object} tileset */ getCollisionGroup: function () { @@ -6632,11 +6800,11 @@ var Tile = new Class({ * collision data, tile animations and terrain information. This returns a reference to the tile * data stored within the Tileset, so any modification of the returned object will impact all * tiles that have the same index as this tile. - * + * * @method Phaser.Tilemaps.Tile#getTileData * @since 3.0.0 - * - * @return {object|null} tileset + * + * @return {?object} tileset */ getTileData: function () { @@ -6646,12 +6814,12 @@ var Tile = new Class({ /** * Gets the world X position of the left side of the tile, factoring in the layers position, * scale and scroll. - * + * * @method Phaser.Tilemaps.Tile#getLeft * @since 3.0.0 - * + * * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to use to perform the check. - * + * * @return {number} */ getLeft: function (camera) @@ -6664,12 +6832,12 @@ var Tile = new Class({ /** * Gets the world X position of the right side of the tile, factoring in the layer's position, * scale and scroll. - * + * * @method Phaser.Tilemaps.Tile#getRight * @since 3.0.0 - * + * * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to use to perform the check. - * + * * @return {number} */ getRight: function (camera) @@ -6682,12 +6850,12 @@ var Tile = new Class({ /** * Gets the world Y position of the top side of the tile, factoring in the layer's position, * scale and scroll. - * + * * @method Phaser.Tilemaps.Tile#getTop * @since 3.0.0 - * + * * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to use to perform the check. - * + * * @return {number} */ getTop: function (camera) @@ -6708,9 +6876,9 @@ var Tile = new Class({ * @method Phaser.Tilemaps.Tile#getBottom * @since 3.0.0 - * + * * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to use to perform the check. - * + * * @return {number} */ getBottom: function (camera) @@ -6725,14 +6893,14 @@ var Tile = new Class({ /** * Gets the world rectangle bounding box for the tile, factoring in the layers position, * scale and scroll. - * + * * @method Phaser.Tilemaps.Tile#getBounds * @since 3.0.0 - * + * * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to use to perform the check. * @param {object} [output] - [description] - * - * @return {Phaser.Geom.Rectangle|object} + * + * @return {(Phaser.Geom.Rectangle|object)} */ getBounds: function (camera, output) { @@ -6749,12 +6917,12 @@ var Tile = new Class({ /** * Gets the world X position of the center of the tile, factoring in the layer's position, * scale and scroll. - * + * * @method Phaser.Tilemaps.Tile#getCenterX * @since 3.0.0 - * + * * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to use to perform the check. - * + * * @return {number} */ getCenterX: function (camera) @@ -6765,12 +6933,12 @@ var Tile = new Class({ /** * Gets the world Y position of the center of the tile, factoring in the layer's position, * scale and scroll. - * + * * @method Phaser.Tilemaps.Tile#getCenterY * @since 3.0.0 - * + * * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to use to perform the check. - * + * * @return {number} */ getCenterY: function (camera) @@ -6780,7 +6948,7 @@ var Tile = new Class({ /** * Clean up memory. - * + * * @method Phaser.Tilemaps.Tile#destroy * @since 3.0.0 */ @@ -6797,12 +6965,12 @@ var Tile = new Class({ * * @method Phaser.Tilemaps.Tile#intersects * @since 3.0.0 - * + * * @param {number} x - The x axis in pixels. * @param {number} y - The y axis in pixels. * @param {number} right - The right point. * @param {number} bottom - The bottom point. - * + * * @return {boolean} */ intersects: function (x, y, right, bottom) @@ -6815,13 +6983,13 @@ var Tile = new Class({ /** * Checks if the tile is interesting. - * + * * @method Phaser.Tilemaps.Tile#isInteresting * @since 3.0.0 * * @param {boolean} collides - If true, will consider the tile interesting if it collides on any side. * @param {boolean} faces - If true, will consider the tile interesting if it has an interesting face. - * + * * @return {boolean} True if the Tile is interesting, otherwise false. */ isInteresting: function (collides, faces) @@ -6837,9 +7005,9 @@ var Tile = new Class({ * * @method Phaser.Tilemaps.Tile#resetCollision * @since 3.0.0 - * + * * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate interesting faces for this tile and its neighbors. - * + * * @return {Phaser.Tilemaps.Tile} This Tile object. */ resetCollision: function (recalculateFaces) @@ -6871,7 +7039,7 @@ var Tile = new Class({ /** * Reset faces. - * + * * @method Phaser.Tilemaps.Tile#resetFaces * @since 3.0.0 * @@ -6889,7 +7057,7 @@ var Tile = new Class({ /** * Sets the collision flags for each side of this tile and updates the interesting faces list. - * + * * @method Phaser.Tilemaps.Tile#setCollision * @since 3.0.0 * @@ -6899,7 +7067,7 @@ var Tile = new Class({ * @param {boolean} [down] - Indicating collide with any object on the bottom. * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate interesting faces * for this tile and its neighbors. - * + * * @return {Phaser.Tilemaps.Tile} This Tile object. */ setCollision: function (left, right, up, down, recalculateFaces) @@ -6935,13 +7103,13 @@ var Tile = new Class({ /** * Set a callback to be called when this tile is hit by an object. The callback must true for * collision processing to take place. - * + * * @method Phaser.Tilemaps.Tile#setCollisionCallback * @since 3.0.0 * * @param {function} callback - Callback function. * @param {object} context - Callback will be called within this context. - * + * * @return {Phaser.Tilemaps.Tile} This Tile object. */ setCollisionCallback: function (callback, context) @@ -6962,7 +7130,7 @@ var Tile = new Class({ /** * Sets the size of the tile and updates its pixelX and pixelY. - * + * * @method Phaser.Tilemaps.Tile#setSize * @since 3.0.0 * @@ -6970,7 +7138,7 @@ var Tile = new Class({ * @param {integer} tileHeight - The height of the tile in pixels. * @param {integer} baseWidth - The base width a tile in the map (in pixels). * @param {integer} baseHeight - The base height of the tile in pixels (in pixels). - * + * * @return {Phaser.Tilemaps.Tile} This Tile object. */ setSize: function (tileWidth, tileHeight, baseWidth, baseHeight) @@ -6987,7 +7155,7 @@ var Tile = new Class({ /** * Used internally. Updates the tile's world XY position based on the current tile size. - * + * * @method Phaser.Tilemaps.Tile#updatePixelXY * @since 3.0.0 * @@ -7006,7 +7174,7 @@ var Tile = new Class({ /** * True if this tile can collide on any of its faces or has a collision callback set. - * + * * @name Phaser.Tilemaps.Tile#canCollide * @type {boolean} * @readOnly @@ -7021,7 +7189,7 @@ var Tile = new Class({ /** * True if this tile can collide on any of its faces. - * + * * @name Phaser.Tilemaps.Tile#collides * @type {boolean} * @readOnly @@ -7036,7 +7204,7 @@ var Tile = new Class({ /** * True if this tile has any interesting faces. - * + * * @name Phaser.Tilemaps.Tile#hasInterestingFace * @type {boolean} * @readOnly @@ -7052,7 +7220,7 @@ var Tile = new Class({ /** * The tileset that contains this Tile. This will only return null if accessed from a LayerData * instance before the tile is placed within a StaticTilemapLayer or DynamicTilemapLayer. - * + * * @name Phaser.Tilemaps.Tile#tileset * @type {?Phaser.Tilemaps.Tileset} * @readOnly @@ -7070,9 +7238,9 @@ var Tile = new Class({ * The tilemap layer that contains this Tile. This will only return null if accessed from a * LayerData instance before the tile is placed within a StaticTilemapLayer or * DynamicTilemapLayer. - * + * * @name Phaser.Tilemaps.Tile#tilemapLayer - * @type {Phaser.Tilemaps.StaticTilemapLayer|Phaser.Tilemaps.DynamicTilemapLayer|null} + * @type {?Phaser.Tilemaps.StaticTilemapLayer|Phaser.Tilemaps.DynamicTilemapLayer} * @readOnly * @since 3.0.0 */ @@ -7086,7 +7254,7 @@ var Tile = new Class({ /** * The tilemap that contains this Tile. This will only return null if accessed from a LayerData * instance before the tile is placed within a StaticTilemapLayer or DynamicTilemapLayer. - * + * * @name Phaser.Tilemaps.Tile#tilemap * @type {?Phaser.Tilemaps.Tilemap} * @readOnly @@ -7105,187 +7273,6 @@ var Tile = new Class({ module.exports = Tile; -/***/ }), -/* 45 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.BlendModes - */ - -module.exports = { - - /** - * Skips the Blend Mode check in the renderer. - * - * @name Phaser.BlendModes.SKIP_CHECK - * @type {integer} - * @since 3.0.0 - */ - SKIP_CHECK: -1, - - /** - * Normal blend mode. - * - * @name Phaser.BlendModes.NORMAL - * @type {integer} - * @since 3.0.0 - */ - NORMAL: 0, - - /** - * Add blend mode. - * - * @name Phaser.BlendModes.ADD - * @type {integer} - * @since 3.0.0 - */ - ADD: 1, - - /** - * Multiply blend mode. - * - * @name Phaser.BlendModes.MULTIPLY - * @type {integer} - * @since 3.0.0 - */ - MULTIPLY: 2, - - /** - * Screen blend mode. - * - * @name Phaser.BlendModes.SCREEN - * @type {integer} - * @since 3.0.0 - */ - SCREEN: 3, - - /** - * Overlay blend mode. - * - * @name Phaser.BlendModes.OVERLAY - * @type {integer} - * @since 3.0.0 - */ - OVERLAY: 4, - - /** - * Darken blend mode. - * - * @name Phaser.BlendModes.DARKEN - * @type {integer} - * @since 3.0.0 - */ - DARKEN: 5, - - /** - * Lighten blend mode. - * - * @name Phaser.BlendModes.LIGHTEN - * @type {integer} - * @since 3.0.0 - */ - LIGHTEN: 6, - - /** - * Color Dodge blend mode. - * - * @name Phaser.BlendModes.COLOR_DODGE - * @type {integer} - * @since 3.0.0 - */ - COLOR_DODGE: 7, - - /** - * Color Burn blend mode. - * - * @name Phaser.BlendModes.COLOR_BURN - * @type {integer} - * @since 3.0.0 - */ - COLOR_BURN: 8, - - /** - * Hard Light blend mode. - * - * @name Phaser.BlendModes.HARD_LIGHT - * @type {integer} - * @since 3.0.0 - */ - HARD_LIGHT: 9, - - /** - * Soft Light blend mode. - * - * @name Phaser.BlendModes.SOFT_LIGHT - * @type {integer} - * @since 3.0.0 - */ - SOFT_LIGHT: 10, - - /** - * Difference blend mode. - * - * @name Phaser.BlendModes.DIFFERENCE - * @type {integer} - * @since 3.0.0 - */ - DIFFERENCE: 11, - - /** - * Exclusion blend mode. - * - * @name Phaser.BlendModes.EXCLUSION - * @type {integer} - * @since 3.0.0 - */ - EXCLUSION: 12, - - /** - * Hue blend mode. - * - * @name Phaser.BlendModes.HUE - * @type {integer} - * @since 3.0.0 - */ - HUE: 13, - - /** - * Saturation blend mode. - * - * @name Phaser.BlendModes.SATURATION - * @type {integer} - * @since 3.0.0 - */ - SATURATION: 14, - - /** - * Color blend mode. - * - * @name Phaser.BlendModes.COLOR - * @type {integer} - * @since 3.0.0 - */ - COLOR: 15, - - /** - * Luminosity blend mode. - * - * @name Phaser.BlendModes.LUMINOSITY - * @type {integer} - * @since 3.0.0 - */ - LUMINOSITY: 16 - -}; - - /***/ }), /* 46 */ /***/ (function(module, exports) { @@ -7297,2315 +7284,34 @@ module.exports = { */ /** - * Returns the center x coordinate from the bounds of the Game Object. + * Internally used method to set the colliding state of a tile. This does not recalculate + * interesting faces. * - * @function Phaser.Display.Bounds.GetCenterX + * @function Phaser.Tilemaps.Components.SetTileCollision * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The center x coordinate of the bounds of the Game Object. + * @param {Phaser.Tilemaps.Tile} tile - [description] + * @param {boolean} [collides=true] - [description] */ -var GetCenterX = function (gameObject) +var SetTileCollision = function (tile, collides) { - return gameObject.x - (gameObject.width * gameObject.originX) + (gameObject.width * 0.5); + if (collides) + { + tile.setCollision(true, true, true, true, false); + } + else + { + tile.resetCollision(false); + } }; -module.exports = GetCenterX; +module.exports = SetTileCollision; /***/ }), /* 47 */ /***/ (function(module, exports) { -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Positions the Game Object so that the center top of its bounds aligns with the given coordinate. - * - * @function Phaser.Display.Bounds.SetCenterX - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} x - The coordinate to position the Game Object bounds on. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. - */ -var SetCenterX = function (gameObject, x) -{ - var offsetX = gameObject.width * gameObject.originX; - - gameObject.x = (x + offsetX) - (gameObject.width * 0.5); - - return gameObject; -}; - -module.exports = SetCenterX; - - -/***/ }), -/* 48 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Positions the Game Object so that the center top of its bounds aligns with the given coordinate. - * - * @function Phaser.Display.Bounds.SetCenterY - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} y - The coordinate to position the Game Object bounds on. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. - */ -var SetCenterY = function (gameObject, y) -{ - var offsetY = gameObject.height * gameObject.originY; - - gameObject.y = (y + offsetY) - (gameObject.height * 0.5); - - return gameObject; -}; - -module.exports = SetCenterY; - - -/***/ }), -/* 49 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the center y coordinate from the bounds of the Game Object. - * - * @function Phaser.Display.Bounds.GetCenterY - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The center y coordinate of the bounds of the Game Object. - */ -var GetCenterY = function (gameObject) -{ - return gameObject.y - (gameObject.height * gameObject.originY) + (gameObject.height * 0.5); -}; - -module.exports = GetCenterY; - - -/***/ }), -/* 50 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Wrap - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} min - [description] - * @param {number} max - [description] - * - * @return {number} [description] - */ -var Wrap = function (value, min, max) -{ - var range = max - min; - - return (min + ((((value - min) % range) + range) % range)); -}; - -module.exports = Wrap; - - -/***/ }), -/* 51 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji -// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class Vector3 - * @memberOf Phaser.Math - * @constructor - * @since 3.0.0 - * - * @param {number} [x] - [description] - * @param {number} [y] - [description] - * @param {number} [z] - [description] - */ -var Vector3 = new Class({ - - initialize: - - function Vector3 (x, y, z) - { - /** - * The x component of this Vector. - * - * @name Phaser.Math.Vector3#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - /** - * The y component of this Vector. - * - * @name Phaser.Math.Vector3#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - /** - * The z component of this Vector. - * - * @name Phaser.Math.Vector3#z - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - if (typeof x === 'object') - { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - } - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#up - * @since 3.0.0 - * - * @return {[type]} [description] - */ - up: function () - { - this.x = 0; - this.y = 1; - this.z = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#clone - * @since 3.0.0 - * - * @return {[type]} [description] - */ - clone: function () - { - return new Vector3(this.x, this.y, this.z); - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#crossVectors - * @since 3.0.0 - * - * @param {[type]} a - [description] - * @param {[type]} b - [description] - * - * @return {[type]} [description] - */ - crossVectors: function (a, b) - { - var ax = a.x; - var ay = a.y; - var az = a.z; - var bx = b.x; - var by = b.y; - var bz = b.z; - - this.x = ay * bz - az * by; - this.y = az * bx - ax * bz; - this.z = ax * by - ay * bx; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#equals - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - equals: function (v) - { - return ((this.x === v.x) && (this.y === v.y) && (this.z === v.z)); - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#copy - * @since 3.0.0 - * - * @param {[type]} src - [description] - * - * @return {[type]} [description] - */ - copy: function (src) - { - this.x = src.x; - this.y = src.y; - this.z = src.z || 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#set - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} z - [description] - * - * @return {[type]} [description] - */ - set: function (x, y, z) - { - if (typeof x === 'object') - { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#add - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - add: function (v) - { - this.x += v.x; - this.y += v.y; - this.z += v.z || 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#subtract - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - subtract: function (v) - { - this.x -= v.x; - this.y -= v.y; - this.z -= v.z || 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#multiply - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - multiply: function (v) - { - this.x *= v.x; - this.y *= v.y; - this.z *= v.z || 1; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#scale - * @since 3.0.0 - * - * @param {[type]} scale - [description] - * - * @return {[type]} [description] - */ - scale: function (scale) - { - if (isFinite(scale)) - { - this.x *= scale; - this.y *= scale; - this.z *= scale; - } - else - { - this.x = 0; - this.y = 0; - this.z = 0; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#divide - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - divide: function (v) - { - this.x /= v.x; - this.y /= v.y; - this.z /= v.z || 1; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#negate - * @since 3.0.0 - * - * @return {[type]} [description] - */ - negate: function () - { - this.x = -this.x; - this.y = -this.y; - this.z = -this.z; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#distance - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - distance: function (v) - { - var dx = v.x - this.x; - var dy = v.y - this.y; - var dz = v.z - this.z || 0; - - return Math.sqrt(dx * dx + dy * dy + dz * dz); - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#distanceSq - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - distanceSq: function (v) - { - var dx = v.x - this.x; - var dy = v.y - this.y; - var dz = v.z - this.z || 0; - - return dx * dx + dy * dy + dz * dz; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#length - * @since 3.0.0 - * - * @return {[type]} [description] - */ - length: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - - return Math.sqrt(x * x + y * y + z * z); - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#lengthSq - * @since 3.0.0 - * - * @return {[type]} [description] - */ - lengthSq: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - - return x * x + y * y + z * z; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#normalize - * @since 3.0.0 - * - * @return {[type]} [description] - */ - normalize: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var len = x * x + y * y + z * z; - - if (len > 0) - { - len = 1 / Math.sqrt(len); - - this.x = x * len; - this.y = y * len; - this.z = z * len; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#dot - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - dot: function (v) - { - return this.x * v.x + this.y * v.y + this.z * v.z; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#cross - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - cross: function (v) - { - var ax = this.x; - var ay = this.y; - var az = this.z; - var bx = v.x; - var by = v.y; - var bz = v.z; - - this.x = ay * bz - az * by; - this.y = az * bx - ax * bz; - this.z = ax * by - ay * bx; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#lerp - * @since 3.0.0 - * - * @param {[type]} v - [description] - * @param {[type]} t - [description] - * - * @return {[type]} [description] - */ - lerp: function (v, t) - { - if (t === undefined) { t = 0; } - - var ax = this.x; - var ay = this.y; - var az = this.z; - - this.x = ax + t * (v.x - ax); - this.y = ay + t * (v.y - ay); - this.z = az + t * (v.z - az); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#transformMat3 - * @since 3.0.0 - * - * @param {[type]} mat - [description] - * - * @return {[type]} [description] - */ - transformMat3: function (mat) - { - var x = this.x; - var y = this.y; - var z = this.z; - var m = mat.val; - - this.x = x * m[0] + y * m[3] + z * m[6]; - this.y = x * m[1] + y * m[4] + z * m[7]; - this.z = x * m[2] + y * m[5] + z * m[8]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#transformMat4 - * @since 3.0.0 - * - * @param {[type]} mat - [description] - * - * @return {[type]} [description] - */ - transformMat4: function (mat) - { - var x = this.x; - var y = this.y; - var z = this.z; - var m = mat.val; - - this.x = m[0] * x + m[4] * y + m[8] * z + m[12]; - this.y = m[1] * x + m[5] * y + m[9] * z + m[13]; - this.z = m[2] * x + m[6] * y + m[10] * z + m[14]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#transformCoordinates - * @since 3.0.0 - * - * @param {[type]} mat - [description] - * - * @return {[type]} [description] - */ - transformCoordinates: function (mat) - { - var x = this.x; - var y = this.y; - var z = this.z; - var m = mat.val; - - var tx = (x * m[0]) + (y * m[4]) + (z * m[8]) + m[12]; - var ty = (x * m[1]) + (y * m[5]) + (z * m[9]) + m[13]; - var tz = (x * m[2]) + (y * m[6]) + (z * m[10]) + m[14]; - var tw = (x * m[3]) + (y * m[7]) + (z * m[11]) + m[15]; - - this.x = tx / tw; - this.y = ty / tw; - this.z = tz / tw; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#transformQuat - * @since 3.0.0 - * - * @param {[type]} q - [description] - * - * @return {[type]} [description] - */ - transformQuat: function (q) - { - // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations - var x = this.x; - var y = this.y; - var z = this.z; - var qx = q.x; - var qy = q.y; - var qz = q.z; - var qw = q.w; - - // calculate quat * vec - var ix = qw * x + qy * z - qz * y; - var iy = qw * y + qz * x - qx * z; - var iz = qw * z + qx * y - qy * x; - var iw = -qx * x - qy * y - qz * z; - - // calculate result * inverse quat - this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; - this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; - this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; - - return this; - }, - - /** - * Multiplies this Vector3 by the specified matrix, - * applying a W divide. This is useful for projection, - * e.g. unprojecting a 2D point into 3D space. - * - * @method project - * @param {Matrix4} the 4x4 matrix to multiply with - * @return {Vector3} this object for chaining - */ - /** - * [description] - * - * @method Phaser.Math.Vector3#project - * @since 3.0.0 - * - * @param {[type]} mat - [description] - * - * @return {[type]} [description] - */ - project: function (mat) - { - var x = this.x; - var y = this.y; - var z = this.z; - var m = mat.val; - - var a00 = m[0]; - var a01 = m[1]; - var a02 = m[2]; - var a03 = m[3]; - var a10 = m[4]; - var a11 = m[5]; - var a12 = m[6]; - var a13 = m[7]; - var a20 = m[8]; - var a21 = m[9]; - var a22 = m[10]; - var a23 = m[11]; - var a30 = m[12]; - var a31 = m[13]; - var a32 = m[14]; - var a33 = m[15]; - - var lw = 1 / (x * a03 + y * a13 + z * a23 + a33); - - this.x = (x * a00 + y * a10 + z * a20 + a30) * lw; - this.y = (x * a01 + y * a11 + z * a21 + a31) * lw; - this.z = (x * a02 + y * a12 + z * a22 + a32) * lw; - - return this; - }, - - /** - * Unproject this point from 2D space to 3D space. - * The point should have its x and y properties set to - * 2D screen space, and the z either at 0 (near plane) - * or 1 (far plane). The provided matrix is assumed to already - * be combined, i.e. projection * view * model. - * - * After this operation, this vector's (x, y, z) components will - * represent the unprojected 3D coordinate. - * - * @param {Vector4} viewport screen x, y, width and height in pixels - * @param {Matrix4} invProjectionView combined projection and view matrix - * @return {Vector3} this object, for chaining - */ - /** - * [description] - * - * @method Phaser.Math.Vector3#unproject - * @since 3.0.0 - * - * @param {[type]} viewport - [description] - * @param {[type]} invProjectionView - [description] - * - * @return {[type]} [description] - */ - unproject: function (viewport, invProjectionView) - { - var viewX = viewport.x; - var viewY = viewport.y; - var viewWidth = viewport.z; - var viewHeight = viewport.w; - - var x = this.x - viewX; - var y = (viewHeight - this.y - 1) - viewY; - var z = this.z; - - this.x = (2 * x) / viewWidth - 1; - this.y = (2 * y) / viewHeight - 1; - this.z = 2 * z - 1; - - return this.project(invProjectionView); - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#reset - * @since 3.0.0 - * - * @return {[type]} [description] - */ - reset: function () - { - this.x = 0; - this.y = 0; - this.z = 0; - - return this; - } - -}); - -/* -Vector3.Zero = function () -{ - return new Vector3(0, 0, 0); -}; - -Vector3.Up = function () -{ - return new Vector3(0, 1.0, 0); -}; - -Vector3.Copy = function (source) -{ - return new Vector3(source.x, source.y, source.z); -}; - -Vector3.TransformCoordinates = function (vector, transformation) -{ - var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + (vector.z * transformation.m[8]) + transformation.m[12]; - var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + (vector.z * transformation.m[9]) + transformation.m[13]; - var z = (vector.x * transformation.m[2]) + (vector.y * transformation.m[6]) + (vector.z * transformation.m[10]) + transformation.m[14]; - var w = (vector.x * transformation.m[3]) + (vector.y * transformation.m[7]) + (vector.z * transformation.m[11]) + transformation.m[15]; - - return new Vector3(x / w, y / w, z / w); -}; - -Vector3.TransformNormal = function (vector, transformation) -{ - var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + (vector.z * transformation.m[8]); - var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + (vector.z * transformation.m[9]); - var z = (vector.x * transformation.m[2]) + (vector.y * transformation.m[6]) + (vector.z * transformation.m[10]); - - return new Vector3(x, y, z); -}; - -Vector3.Dot = function (left, right) -{ - return (left.x * right.x + left.y * right.y + left.z * right.z); -}; - -Vector3.Cross = function (left, right) -{ - var x = left.y * right.z - left.z * right.y; - var y = left.z * right.x - left.x * right.z; - var z = left.x * right.y - left.y * right.x; - - return new Vector3(x, y, z); -}; - -Vector3.Normalize = function (vector) -{ - var newVector = Vector3.Copy(vector); - newVector.normalize(); - - return newVector; -}; - -Vector3.Distance = function (value1, value2) -{ - return Math.sqrt(Vector3.DistanceSquared(value1, value2)); -}; - -Vector3.DistanceSquared = function (value1, value2) -{ - var x = value1.x - value2.x; - var y = value1.y - value2.y; - var z = value1.z - value2.z; - - return (x * x) + (y * y) + (z * z); -}; -*/ - -module.exports = Vector3; - - -/***/ }), -/* 52 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var FromPoints = __webpack_require__(122); -var Rectangle = __webpack_require__(8); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * A Base Curve class, which all other curve types extend. - * - * Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) - * - * @class Curve - * @memberOf Phaser.Curves - * @constructor - * @since 3.0.0 - * - * @param {string} type - [description] - */ -var Curve = new Class({ - - initialize: - - function Curve (type) - { - /** - * String based identifier for the type of curve. - * - * @name Phaser.Curves.Curve#type - * @type {string} - * @since 3.0.0 - */ - this.type = type; - - /** - * The default number of divisions within the curve. - * - * @name Phaser.Curves.Curve#defaultDivisions - * @type {integer} - * @default 5 - * @since 3.0.0 - */ - this.defaultDivisions = 5; - - /** - * The quantity of arc length divisions within the curve. - * - * @name Phaser.Curves.Curve#arcLengthDivisions - * @type {integer} - * @default 100 - * @since 3.0.0 - */ - this.arcLengthDivisions = 100; - - /** - * An array of cached arc length values. - * - * @name Phaser.Curves.Curve#cacheArcLengths - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.cacheArcLengths = []; - - /** - * Does the data of this curve need updating? - * - * @name Phaser.Curves.Curve#needsUpdate - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.needsUpdate = true; - - /** - * [description] - * - * @name Phaser.Curves.Curve#active - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.active = true; - - /** - * A temporary calculation Vector. - * - * @name Phaser.Curves.Curve#_tmpVec2A - * @type {Phaser.Math.Vector2} - * @private - * @since 3.0.0 - */ - this._tmpVec2A = new Vector2(); - - /** - * A temporary calculation Vector. - * - * @name Phaser.Curves.Curve#_tmpVec2B - * @type {Phaser.Math.Vector2} - * @private - * @since 3.0.0 - */ - this._tmpVec2B = new Vector2(); - }, - - /** - * Draws this curve on the given Graphics object. - * - * The curve is drawn using `Graphics.strokePoints` so will be drawn at whatever the present Graphics stroke color is. - * The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it. - * - * @method Phaser.Curves.Curve#draw - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - The Graphics instance onto which this curve will be drawn. - * @param {integer} [pointsTotal=32] - The resolution of the curve. The higher the value the smoother it will render, at the cost of rendering performance. - * - * @return {Phaser.GameObjects.Graphics} The Graphics object to which the curve was drawn. - */ - draw: function (graphics, pointsTotal) - { - if (pointsTotal === undefined) { pointsTotal = 32; } - - // So you can chain graphics calls - return graphics.strokePoints(this.getPoints(pointsTotal)); - }, - - /** - * Returns a Rectangle where the position and dimensions match the bounds of this Curve. - * - * You can control the accuracy of the bounds. The value given is used to work out how many points - * to plot across the curve. Higher values are more accurate at the cost of calculation speed. - * - * @method Phaser.Curves.Curve#getBounds - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} out - The Rectangle to store the bounds in. If falsey a new object will be created. - * @param {integer} [accuracy=16] - The accuracy of the bounds calculations. - * - * @return {Phaser.Geom.Rectangle} A Rectangle containing the bounds values of this Curve. - */ - getBounds: function (out, accuracy) - { - if (!out) { out = new Rectangle(); } - if (accuracy === undefined) { accuracy = 16; } - - var len = this.getLength(); - - if (accuracy > len) - { - accuracy = len / 2; - } - - // The length of the curve in pixels - // So we'll have 1 spaced point per 'accuracy' pixels - - var spaced = Math.max(1, Math.round(len / accuracy)); - - return FromPoints(this.getSpacedPoints(spaced), out); - }, - - /** - * Returns an array of points, spaced out X distance pixels apart. - * The smaller the distance, the larger the array will be. - * - * @method Phaser.Curves.Curve#getDistancePoints - * @since 3.0.0 - * - * @param {integer} distance - The distance, in pixels, between each point along the curve. - * - * @return {Phaser.Geom.Point[]} An Array of Point objects. - */ - getDistancePoints: function (distance) - { - var len = this.getLength(); - - var spaced = Math.max(1, len / distance); - - return this.getSpacedPoints(spaced); - }, - - /** - * [description] - * - * @method Phaser.Curves.Curve#getEndPoint - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} out - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - getEndPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return this.getPointAt(1, out); - }, - - // Get total curve arc length - - /** - * [description] - * - * @method Phaser.Curves.Curve#getLength - * @since 3.0.0 - * - * @return {number} [description] - */ - getLength: function () - { - var lengths = this.getLengths(); - - return lengths[lengths.length - 1]; - }, - - // Get list of cumulative segment lengths - - /** - * [description] - * - * @method Phaser.Curves.Curve#getLengths - * @since 3.0.0 - * - * @param {integer} [divisions] - [description] - * - * @return {number[]} [description] - */ - getLengths: function (divisions) - { - if (divisions === undefined) { divisions = this.arcLengthDivisions; } - - if ((this.cacheArcLengths.length === divisions + 1) && !this.needsUpdate) - { - return this.cacheArcLengths; - } - - this.needsUpdate = false; - - var cache = []; - var current; - var last = this.getPoint(0, this._tmpVec2A); - var sum = 0; - - cache.push(0); - - for (var p = 1; p <= divisions; p++) - { - current = this.getPoint(p / divisions, this._tmpVec2B); - - sum += current.distance(last); - - cache.push(sum); - - last.copy(current); - } - - this.cacheArcLengths = cache; - - return cache; // { sums: cache, sum:sum }; Sum is in the last element. - }, - - // Get point at relative position in curve according to arc length - - // - u [0 .. 1] - - /** - * [description] - * - * @method Phaser.Curves.Curve#getPointAt - * @since 3.0.0 - * - * @param {float} u - [description] - * @param {Phaser.Math.Vector2} [out] - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - getPointAt: function (u, out) - { - var t = this.getUtoTmapping(u); - - return this.getPoint(t, out); - }, - - // Get sequence of points using getPoint( t ) - - /** - * [description] - * - * @method Phaser.Curves.Curve#getPoints - * @since 3.0.0 - * - * @param {integer} [divisions] - [description] - * - * @return {Phaser.Math.Vector2[]} [description] - */ - getPoints: function (divisions) - { - if (divisions === undefined) { divisions = this.defaultDivisions; } - - var points = []; - - for (var d = 0; d <= divisions; d++) - { - points.push(this.getPoint(d / divisions)); - } - - return points; - }, - - /** - * [description] - * - * @method Phaser.Curves.Curve#getRandomPoint - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} [out] - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - getRandomPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return this.getPoint(Math.random(), out); - }, - - // Get sequence of points using getPointAt( u ) - - /** - * [description] - * - * @method Phaser.Curves.Curve#getSpacedPoints - * @since 3.0.0 - * - * @param {integer} [divisions] - [description] - * - * @return {Phaser.Math.Vector2[]} [description] - */ - getSpacedPoints: function (divisions) - { - if (divisions === undefined) { divisions = this.defaultDivisions; } - - var points = []; - - for (var d = 0; d <= divisions; d++) - { - var t = this.getUtoTmapping(d / divisions, null, divisions); - - points.push(this.getPoint(t)); - } - - return points; - }, - - /** - * [description] - * - * @method Phaser.Curves.Curve#getStartPoint - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} [out] - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - getStartPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return this.getPointAt(0, out); - }, - - // Returns a unit vector tangent at t - // In case any sub curve does not implement its tangent derivation, - // 2 points a small delta apart will be used to find its gradient - // which seems to give a reasonable approximation - - /** - * [description] - * - * @method Phaser.Curves.Curve#getTangent - * @since 3.0.0 - * - * @param {number} t - [description] - * @param {Phaser.Math.Vector2} [out] - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - getTangent: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - var delta = 0.0001; - var t1 = t - delta; - var t2 = t + delta; - - // Capping in case of danger - - if (t1 < 0) - { - t1 = 0; - } - - if (t2 > 1) - { - t2 = 1; - } - - this.getPoint(t1, this._tmpVec2A); - this.getPoint(t2, out); - - return out.subtract(this._tmpVec2A).normalize(); - }, - - /** - * [description] - * - * @method Phaser.Curves.Curve#getTangentAt - * @since 3.0.0 - * - * @param {float} u - [description] - * @param {Phaser.Math.Vector2} [out] - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - getTangentAt: function (u, out) - { - var t = this.getUtoTmapping(u); - - return this.getTangent(t, out); - }, - - // Given a distance in pixels, get a t to find p. - /** - * [description] - * - * @method Phaser.Curves.Curve#getTFromDistance - * @since 3.0.0 - * - * @param {integer} distance - [description] - * @param {integer} [divisions] - [description] - * - * @return {float} [description] - */ - getTFromDistance: function (distance, divisions) - { - if (distance <= 0) - { - return 0; - } - - return this.getUtoTmapping(0, distance, divisions); - }, - - // Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant - - /** - * [description] - * - * @method Phaser.Curves.Curve#getUtoTmapping - * @since 3.0.0 - * - * @param {float} u - [description] - * @param {integer} distance - [description] - * @param {integer} [divisions] - [description] - * - * @return {number} [description] - */ - getUtoTmapping: function (u, distance, divisions) - { - var arcLengths = this.getLengths(divisions); - - var i = 0; - var il = arcLengths.length; - - var targetArcLength; // The targeted u distance value to get - - if (distance) - { - // Cannot overshoot the curve - targetArcLength = Math.min(distance, arcLengths[il - 1]); - } - else - { - targetArcLength = u * arcLengths[il - 1]; - } - - // binary search for the index with largest value smaller than target u distance - - var low = 0; - var high = il - 1; - var comparison; - - while (low <= high) - { - i = Math.floor(low + (high - low) / 2); // less likely to overflow, though probably not issue here, JS doesn't really have integers, all numbers are floats - - comparison = arcLengths[i] - targetArcLength; - - if (comparison < 0) - { - low = i + 1; - } - else if (comparison > 0) - { - high = i - 1; - } - else - { - high = i; - break; - } - } - - i = high; - - if (arcLengths[i] === targetArcLength) - { - return i / (il - 1); - } - - // we could get finer grain at lengths, or use simple interpolation between two points - - var lengthBefore = arcLengths[i]; - var lengthAfter = arcLengths[i + 1]; - - var segmentLength = lengthAfter - lengthBefore; - - // determine where we are between the 'before' and 'after' points - - var segmentFraction = (targetArcLength - lengthBefore) / segmentLength; - - // add that fractional amount to t - - return (i + segmentFraction) / (il - 1); - }, - - /** - * [description] - * - * @method Phaser.Curves.Curve#updateArcLengths - * @since 3.0.0 - */ - updateArcLengths: function () - { - this.needsUpdate = true; - - this.getLengths(); - } - -}); - -module.exports = Curve; - - -/***/ }), -/* 53 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Shallow Object Clone. Will not clone nested objects. - * - * @function Phaser.Utils.Object.Clone - * @since 3.0.0 - * - * @param {object} obj - [description] - * - * @return {object} [description] - */ -var Clone = function (obj) -{ - var clone = {}; - - for (var key in obj) - { - if (Array.isArray(obj[key])) - { - clone[key] = obj[key].slice(0); - } - else - { - clone[key] = obj[key]; - } - } - - return clone; -}; - -module.exports = Clone; - - -/***/ }), -/* 54 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// http://www.blackpawn.com/texts/pointinpoly/ - -/** - * [description] - * - * @function Phaser.Geom.Triangle.Contains - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ -var Contains = function (triangle, x, y) -{ - var v0x = triangle.x3 - triangle.x1; - var v0y = triangle.y3 - triangle.y1; - - var v1x = triangle.x2 - triangle.x1; - var v1y = triangle.y2 - triangle.y1; - - var v2x = x - triangle.x1; - var v2y = y - triangle.y1; - - var dot00 = (v0x * v0x) + (v0y * v0y); - var dot01 = (v0x * v1x) + (v0y * v1y); - var dot02 = (v0x * v2x) + (v0y * v2y); - var dot11 = (v1x * v1x) + (v1y * v1y); - var dot12 = (v1x * v2x) + (v1y * v2y); - - // Compute barycentric coordinates - var b = ((dot00 * dot11) - (dot01 * dot01)); - var inv = (b === 0) ? 0 : (1 / b); - var u = ((dot11 * dot02) - (dot01 * dot12)) * inv; - var v = ((dot00 * dot12) - (dot01 * dot02)) * inv; - - return (u >= 0 && v >= 0 && (u + v < 1)); -}; - -module.exports = Contains; - - -/***/ }), -/* 55 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Angle - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var Angle = function (line) -{ - return Math.atan2(line.y2 - line.y1, line.x2 - line.x1); -}; - -module.exports = Angle; - - -/***/ }), -/* 56 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Contains = __webpack_require__(54); -var GetPoint = __webpack_require__(309); -var GetPoints = __webpack_require__(310); -var Random = __webpack_require__(112); - -/** - * @classdesc - * A triangle is a plane created by connecting three points. - * The first two arguments specify the first point, the middle two arguments - * specify the second point, and the last two arguments specify the third point. - * - * @class Triangle - * @memberOf Phaser.Geom - * @constructor - * @since 3.0.0 - * - * @param {number} [x1=0] - [description] - * @param {number} [y1=0] - [description] - * @param {number} [x2=0] - [description] - * @param {number} [y2=0] - [description] - * @param {number} [x3=0] - [description] - * @param {number} [y3=0] - [description] - */ -var Triangle = new Class({ - - initialize: - - function Triangle (x1, y1, x2, y2, x3, y3) - { - if (x1 === undefined) { x1 = 0; } - if (y1 === undefined) { y1 = 0; } - if (x2 === undefined) { x2 = 0; } - if (y2 === undefined) { y2 = 0; } - if (x3 === undefined) { x3 = 0; } - if (y3 === undefined) { y3 = 0; } - - /** - * [description] - * - * @name Phaser.Geom.Triangle#x1 - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x1 = x1; - - /** - * [description] - * - * @name Phaser.Geom.Triangle#y1 - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y1 = y1; - - /** - * [description] - * - * @name Phaser.Geom.Triangle#x2 - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x2 = x2; - - /** - * [description] - * - * @name Phaser.Geom.Triangle#y2 - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y2 = y2; - - /** - * [description] - * - * @name Phaser.Geom.Triangle#x3 - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x3 = x3; - - /** - * [description] - * - * @name Phaser.Geom.Triangle#y3 - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y3 = y3; - }, - - /** - * [description] - * - * @method Phaser.Geom.Triangle#contains - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - contains: function (x, y) - { - return Contains(this, x, y); - }, - - /** - * [description] - * - * @method Phaser.Geom.Triangle#getPoint - * @since 3.0.0 - * - * @param {[type]} position - [description] - * @param {[type]} output - [description] - * - * @return {[type]} [description] - */ - getPoint: function (position, output) - { - return GetPoint(this, position, output); - }, - - /** - * [description] - * - * @method Phaser.Geom.Triangle#getPoints - * @since 3.0.0 - * - * @param {[type]} quantity - [description] - * @param {[type]} stepRate - [description] - * @param {[type]} output - [description] - * - * @return {[type]} [description] - */ - getPoints: function (quantity, stepRate, output) - { - return GetPoints(this, quantity, stepRate, output); - }, - - /** - * [description] - * - * @method Phaser.Geom.Triangle#getRandomPoint - * @since 3.0.0 - * - * @param {[type]} point - [description] - * - * @return {[type]} [description] - */ - getRandomPoint: function (point) - { - return Random(this, point); - }, - - /** - * [description] - * - * @method Phaser.Geom.Triangle#setTo - * @since 3.0.0 - * - * @param {[type]} x1 - [description] - * @param {[type]} y1 - [description] - * @param {[type]} x2 - [description] - * @param {[type]} y2 - [description] - * @param {[type]} x3 - [description] - * @param {[type]} y3 - [description] - * - * @return {Phaser.Geom.Triangle} This Triangle object. - */ - setTo: function (x1, y1, x2, y2, x3, y3) - { - if (x1 === undefined) { x1 = 0; } - if (y1 === undefined) { y1 = 0; } - if (x2 === undefined) { x2 = 0; } - if (y2 === undefined) { y2 = 0; } - if (x3 === undefined) { x3 = 0; } - if (y3 === undefined) { y3 = 0; } - - this.x1 = x1; - this.y1 = y1; - - this.x2 = x2; - this.y2 = y2; - - this.x3 = x3; - this.y3 = y3; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Geom.Triangle#getLineA - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getLineA: function () - { - return { x1: this.x1, y1: this.y1, x2: this.x2, y2: this.y2 }; - }, - - /** - * [description] - * - * @method Phaser.Geom.Triangle#getLineB - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getLineB: function () - { - return { x1: this.x2, y1: this.y2, x2: this.x3, y2: this.y3 }; - }, - - /** - * [description] - * - * @method Phaser.Geom.Triangle#getLineC - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getLineC: function () - { - return { x1: this.x3, y1: this.y3, x2: this.x1, y2: this.y1 }; - }, - - /** - * [description] - * - * @name Phaser.Geom.Triangle#left - * @type {number} - * @since 3.0.0 - */ - left: { - - get: function () - { - return Math.min(this.x1, this.x2, this.x3); - }, - - set: function (value) - { - var diff = 0; - - if (this.x1 <= this.x2 && this.x1 <= this.x3) - { - diff = this.x1 - value; - } - else if (this.x2 <= this.x1 && this.x2 <= this.x3) - { - diff = this.x2 - value; - } - else - { - diff = this.x3 - value; - } - - this.x1 -= diff; - this.x2 -= diff; - this.x3 -= diff; - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Triangle#right - * @type {number} - * @since 3.0.0 - */ - right: { - - get: function () - { - return Math.max(this.x1, this.x2, this.x3); - }, - - set: function (value) - { - var diff = 0; - - if (this.x1 >= this.x2 && this.x1 >= this.x3) - { - diff = this.x1 - value; - } - else if (this.x2 >= this.x1 && this.x2 >= this.x3) - { - diff = this.x2 - value; - } - else - { - diff = this.x3 - value; - } - - this.x1 -= diff; - this.x2 -= diff; - this.x3 -= diff; - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Triangle#top - * @type {number} - * @since 3.0.0 - */ - top: { - - get: function () - { - return Math.min(this.y1, this.y2, this.y3); - }, - - set: function (value) - { - var diff = 0; - - if (this.y1 <= this.y2 && this.y1 <= this.y3) - { - diff = this.y1 - value; - } - else if (this.y2 <= this.y1 && this.y2 <= this.y3) - { - diff = this.y2 - value; - } - else - { - diff = this.y3 - value; - } - - this.y1 -= diff; - this.y2 -= diff; - this.y3 -= diff; - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Triangle#bottom - * @type {number} - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return Math.max(this.y1, this.y2, this.y3); - }, - - set: function (value) - { - var diff = 0; - - if (this.y1 >= this.y2 && this.y1 >= this.y3) - { - diff = this.y1 - value; - } - else if (this.y2 >= this.y1 && this.y2 >= this.y3) - { - diff = this.y2 - value; - } - else - { - diff = this.y3 - value; - } - - this.y1 -= diff; - this.y2 -= diff; - this.y3 -= diff; - } - - } - -}); - -module.exports = Triangle; - - -/***/ }), -/* 57 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(2); - -/** - * @classdesc - * [description] - * - * @class JSONFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {object} xhrSettings - [description] - */ -var JSONFile = new Class({ - - Extends: File, - - initialize: - - // url can either be a string, in which case it is treated like a proper url, or an object, in which case it is treated as a ready-made JS Object - - function JSONFile (key, url, path, xhrSettings) - { - var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); - - var fileConfig = { - type: 'json', - extension: GetFastValue(key, 'extension', 'json'), - responseType: 'text', - key: fileKey, - url: GetFastValue(key, 'file', url), - path: path, - xhrSettings: GetFastValue(key, 'xhr', xhrSettings) - }; - - File.call(this, fileConfig); - - if (typeof fileConfig.url === 'object') - { - // Object provided instead of a URL, so no need to actually load it (populate data with value) - this.data = fileConfig.url; - - this.state = CONST.FILE_POPULATED; - } - }, - - onProcess: function (callback) - { - this.state = CONST.FILE_PROCESSING; - - this.data = JSON.parse(this.xhrLoader.responseText); - - this.onComplete(); - - callback(this); - } - -}); - -/** - * Adds a JSON file to the current load queue. - * - * Note: This method will only be available if the JSON File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#json - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('json', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new JSONFile(key[i], url, this.path, xhrSettings)); - } - } - else - { - this.addFile(new JSONFile(key, url, this.path, xhrSettings)); - } - - // For method chaining - return this; -}); - -module.exports = JSONFile; - - -/***/ }), -/* 58 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(2); - -/** - * @classdesc - * [description] - * - * @class ImageFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {object} xhrSettings - [description] - * @param {object} config - [description] - */ -var ImageFile = new Class({ - - Extends: File, - - initialize: - - // this.load.image('pic', 'assets/pics/taikodrummaster.jpg'); - // this.load.image({ key: 'pic', file: 'assets/pics/taikodrummaster.jpg' }); - // this.load.image({ - // key: 'bunny', - // file: 'assets/sprites/bunny.png', - // xhr: { - // user: 'root', - // password: 'th3G1bs0n', - // timeout: 30, - // header: 'Content-Type', - // headerValue: 'text/xml' - // } - // }); - // this.load.image({ key: 'bunny' }); - // this.load.image({ key: 'bunny', extension: 'jpg' }); - - function ImageFile (key, url, path, xhrSettings, config) - { - var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); - - var fileConfig = { - type: 'image', - extension: GetFastValue(key, 'extension', 'png'), - responseType: 'blob', - key: fileKey, - url: GetFastValue(key, 'file', url), - path: path, - xhrSettings: GetFastValue(key, 'xhr', xhrSettings), - config: GetFastValue(key, 'config', config) - }; - - File.call(this, fileConfig); - }, - - onProcess: function (callback) - { - this.state = CONST.FILE_PROCESSING; - - this.data = new Image(); - - this.data.crossOrigin = this.crossOrigin; - - var _this = this; - - this.data.onload = function () - { - File.revokeObjectURL(_this.data); - - _this.onComplete(); - - callback(_this); - }; - - this.data.onerror = function () - { - File.revokeObjectURL(_this.data); - - _this.state = CONST.FILE_ERRORED; - - callback(_this); - }; - - File.createObjectURL(this.data, this.xhrLoader.response, 'image/png'); - } - -}); - -/** - * Adds an Image file to the current load queue. - * - * Note: This method will only be available if the Image File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#image - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('image', function (key, url, xhrSettings) -{ - var urls; - var fileA; - var fileB; - - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - urls = GetFastValue(key[i], 'file', url); - - if (Array.isArray(urls) && urls.length === 2) - { - fileA = this.addFile(new ImageFile(key[i], urls[0], this.path, xhrSettings)); - fileB = this.addFile(new ImageFile(key[i], urls[1], this.path, xhrSettings)); - - fileA.setLinkFile(fileB, 'dataimage'); - } - else - { - this.addFile(new ImageFile(key[i], url, this.path, xhrSettings)); - } - } - } - else - { - urls = GetFastValue(key, 'file', url); - - if (Array.isArray(urls) && urls.length === 2) - { - fileA = this.addFile(new ImageFile(key, urls[0], this.path, xhrSettings)); - fileB = this.addFile(new ImageFile(key, urls[1], this.path, xhrSettings)); - - fileA.setLinkFile(fileB, 'dataimage'); - } - else - { - this.addFile(new ImageFile(key, url, this.path, xhrSettings)); - } - } - - // For method chaining - return this; -}); - -module.exports = ImageFile; - - -/***/ }), -/* 59 */ -/***/ (function(module, exports) { - /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. @@ -9699,7 +7405,41 @@ module.exports = { /***/ }), -/* 60 */ +/* 48 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Distance.Between + * @since 3.0.0 + * + * @param {number} x1 - [description] + * @param {number} y1 - [description] + * @param {number} x2 - [description] + * @param {number} y2 - [description] + * + * @return {number} [description] + */ +var DistanceBetween = function (x1, y1, x2, y2) +{ + var dx = x1 - x2; + var dy = y1 - y2; + + return Math.sqrt(dx * dx + dy * dy); +}; + +module.exports = DistanceBetween; + + +/***/ }), +/* 49 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -9716,12 +7456,12 @@ var Body = {}; module.exports = Body; -var Vertices = __webpack_require__(93); -var Vector = __webpack_require__(94); -var Sleeping = __webpack_require__(343); -var Common = __webpack_require__(38); -var Bounds = __webpack_require__(95); -var Axes = __webpack_require__(859); +var Vertices = __webpack_require__(91); +var Vector = __webpack_require__(90); +var Sleeping = __webpack_require__(198); +var Common = __webpack_require__(39); +var Bounds = __webpack_require__(89); +var Axes = __webpack_require__(468); (function() { @@ -10906,6 +8646,2268 @@ var Axes = __webpack_require__(859); })(); +/***/ }), +/* 50 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); + +/** + * @classdesc + * [description] + * + * @class ImageFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * @param {object} config - [description] + */ +var ImageFile = new Class({ + + Extends: File, + + initialize: + + // this.load.image('pic', 'assets/pics/taikodrummaster.jpg'); + // this.load.image({ key: 'pic', file: 'assets/pics/taikodrummaster.jpg' }); + // this.load.image({ + // key: 'bunny', + // file: 'assets/sprites/bunny.png', + // xhr: { + // user: 'root', + // password: 'th3G1bs0n', + // timeout: 30, + // header: 'Content-Type', + // headerValue: 'text/xml' + // } + // }); + // this.load.image({ key: 'bunny' }); + // this.load.image({ key: 'bunny', extension: 'jpg' }); + + function ImageFile (key, url, path, xhrSettings, config) + { + var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); + + var fileConfig = { + type: 'image', + extension: GetFastValue(key, 'extension', 'png'), + responseType: 'blob', + key: fileKey, + url: GetFastValue(key, 'file', url), + path: path, + xhrSettings: GetFastValue(key, 'xhr', xhrSettings), + config: GetFastValue(key, 'config', config) + }; + + File.call(this, fileConfig); + }, + + onProcess: function (callback) + { + this.state = CONST.FILE_PROCESSING; + + this.data = new Image(); + + this.data.crossOrigin = this.crossOrigin; + + var _this = this; + + this.data.onload = function () + { + File.revokeObjectURL(_this.data); + + _this.onComplete(); + + callback(_this); + }; + + this.data.onerror = function () + { + File.revokeObjectURL(_this.data); + + _this.state = CONST.FILE_ERRORED; + + callback(_this); + }; + + File.createObjectURL(this.data, this.xhrLoader.response, 'image/png'); + } + +}); + +/** + * Adds an Image file to the current load queue. + * + * Note: This method will only be available if the Image File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#image + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('image', function (key, url, xhrSettings) +{ + var urls; + var fileA; + var fileB; + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + urls = GetFastValue(key[i], 'file', url); + + if (Array.isArray(urls) && urls.length === 2) + { + fileA = this.addFile(new ImageFile(key[i], urls[0], this.path, xhrSettings)); + fileB = this.addFile(new ImageFile(key[i], urls[1], this.path, xhrSettings)); + + fileA.setLinkFile(fileB, 'dataimage'); + } + else + { + this.addFile(new ImageFile(key[i], url, this.path, xhrSettings)); + } + } + } + else + { + urls = GetFastValue(key, 'file', url); + + if (Array.isArray(urls) && urls.length === 2) + { + fileA = this.addFile(new ImageFile(key, urls[0], this.path, xhrSettings)); + fileB = this.addFile(new ImageFile(key, urls[1], this.path, xhrSettings)); + + fileA.setLinkFile(fileB, 'dataimage'); + } + else + { + this.addFile(new ImageFile(key, url, this.path, xhrSettings)); + } + } + + // For method chaining + return this; +}); + +module.exports = ImageFile; + + +/***/ }), +/* 51 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); + +/** + * @classdesc + * [description] + * + * @class JSONFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + */ +var JSONFile = new Class({ + + Extends: File, + + initialize: + + // url can either be a string, in which case it is treated like a proper url, or an object, in which case it is treated as a ready-made JS Object + + function JSONFile (key, url, path, xhrSettings) + { + var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); + + var fileConfig = { + type: 'json', + extension: GetFastValue(key, 'extension', 'json'), + responseType: 'text', + key: fileKey, + url: GetFastValue(key, 'file', url), + path: path, + xhrSettings: GetFastValue(key, 'xhr', xhrSettings) + }; + + File.call(this, fileConfig); + + if (typeof fileConfig.url === 'object') + { + // Object provided instead of a URL, so no need to actually load it (populate data with value) + this.data = fileConfig.url; + + this.state = CONST.FILE_POPULATED; + } + }, + + onProcess: function (callback) + { + this.state = CONST.FILE_PROCESSING; + + this.data = JSON.parse(this.xhrLoader.responseText); + + this.onComplete(); + + callback(this); + } + +}); + +/** + * Adds a JSON file to the current load queue. + * + * Note: This method will only be available if the JSON File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#json + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('json', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new JSONFile(key[i], url, this.path, xhrSettings)); + } + } + else + { + this.addFile(new JSONFile(key, url, this.path, xhrSettings)); + } + + // For method chaining + return this; +}); + +module.exports = JSONFile; + + +/***/ }), +/* 52 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Contains = __webpack_require__(54); +var GetPoint = __webpack_require__(232); +var GetPoints = __webpack_require__(231); +var Line = __webpack_require__(104); +var Random = __webpack_require__(161); + +/** + * @classdesc + * A triangle is a plane created by connecting three points. + * The first two arguments specify the first point, the middle two arguments + * specify the second point, and the last two arguments specify the third point. + * + * @class Triangle + * @memberOf Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x1=0] - [description] + * @param {number} [y1=0] - [description] + * @param {number} [x2=0] - [description] + * @param {number} [y2=0] - [description] + * @param {number} [x3=0] - [description] + * @param {number} [y3=0] - [description] + */ +var Triangle = new Class({ + + initialize: + + function Triangle (x1, y1, x2, y2, x3, y3) + { + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 0; } + if (y2 === undefined) { y2 = 0; } + if (x3 === undefined) { x3 = 0; } + if (y3 === undefined) { y3 = 0; } + + /** + * [description] + * + * @name Phaser.Geom.Triangle#x1 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x1 = x1; + + /** + * [description] + * + * @name Phaser.Geom.Triangle#y1 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y1 = y1; + + /** + * [description] + * + * @name Phaser.Geom.Triangle#x2 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x2 = x2; + + /** + * [description] + * + * @name Phaser.Geom.Triangle#y2 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y2 = y2; + + /** + * [description] + * + * @name Phaser.Geom.Triangle#x3 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x3 = x3; + + /** + * [description] + * + * @name Phaser.Geom.Triangle#y3 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y3 = y3; + }, + + /** + * [description] + * + * @method Phaser.Geom.Triangle#contains + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ + contains: function (x, y) + { + return Contains(this, x, y); + }, + + /** + * [description] + * + * @method Phaser.Geom.Triangle#getPoint + * @since 3.0.0 + * + * @param {float} position - [description] + * @param {(Phaser.Geom.Point|object)} output - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ + getPoint: function (position, output) + { + return GetPoint(this, position, output); + }, + + /** + * [description] + * + * @method Phaser.Geom.Triangle#getPoints + * @since 3.0.0 + * + * @param {integer} quantity - [description] + * @param {number} [stepRate] - [description] + * @param {(array|Phaser.Geom.Point[])} [output] - [description] + * + * @return {(array|Phaser.Geom.Point[])} [description] + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * [description] + * + * @method Phaser.Geom.Triangle#getRandomPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * + * @return {Phaser.Geom.Point} [description] + */ + getRandomPoint: function (point) + { + return Random(this, point); + }, + + /** + * [description] + * + * @method Phaser.Geom.Triangle#setTo + * @since 3.0.0 + * + * @param {number} [x1=0] - [description] + * @param {number} [y1=0] - [description] + * @param {number} [x2=0] - [description] + * @param {number} [y2=0] - [description] + * @param {number} [x3=0] - [description] + * @param {number} [y3=0] - [description] + * + * @return {Phaser.Geom.Triangle} This Triangle object. + */ + setTo: function (x1, y1, x2, y2, x3, y3) + { + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 0; } + if (y2 === undefined) { y2 = 0; } + if (x3 === undefined) { x3 = 0; } + if (y3 === undefined) { y3 = 0; } + + this.x1 = x1; + this.y1 = y1; + + this.x2 = x2; + this.y2 = y2; + + this.x3 = x3; + this.y3 = y3; + + return this; + }, + + /** + * Returns a Line object that corresponds to Line A of this Triangle. + * + * @method Phaser.Geom.Triangle#getLineA + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to line A of this Triangle. + */ + getLineA: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x1, this.y1, this.x2, this.y2); + + return line; + }, + + /** + * Returns a Line object that corresponds to Line B of this Triangle. + * + * @method Phaser.Geom.Triangle#getLineB + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to line B of this Triangle. + */ + getLineB: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x2, this.y2, this.x3, this.y3); + + return line; + }, + + /** + * Returns a Line object that corresponds to Line C of this Triangle. + * + * @method Phaser.Geom.Triangle#getLineC + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to line C of this Triangle. + */ + getLineC: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x3, this.y3, this.x1, this.y1); + + return line; + }, + + /** + * [description] + * + * @name Phaser.Geom.Triangle#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () + { + return Math.min(this.x1, this.x2, this.x3); + }, + + set: function (value) + { + var diff = 0; + + if (this.x1 <= this.x2 && this.x1 <= this.x3) + { + diff = this.x1 - value; + } + else if (this.x2 <= this.x1 && this.x2 <= this.x3) + { + diff = this.x2 - value; + } + else + { + diff = this.x3 - value; + } + + this.x1 -= diff; + this.x2 -= diff; + this.x3 -= diff; + } + + }, + + /** + * [description] + * + * @name Phaser.Geom.Triangle#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return Math.max(this.x1, this.x2, this.x3); + }, + + set: function (value) + { + var diff = 0; + + if (this.x1 >= this.x2 && this.x1 >= this.x3) + { + diff = this.x1 - value; + } + else if (this.x2 >= this.x1 && this.x2 >= this.x3) + { + diff = this.x2 - value; + } + else + { + diff = this.x3 - value; + } + + this.x1 -= diff; + this.x2 -= diff; + this.x3 -= diff; + } + + }, + + /** + * [description] + * + * @name Phaser.Geom.Triangle#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return Math.min(this.y1, this.y2, this.y3); + }, + + set: function (value) + { + var diff = 0; + + if (this.y1 <= this.y2 && this.y1 <= this.y3) + { + diff = this.y1 - value; + } + else if (this.y2 <= this.y1 && this.y2 <= this.y3) + { + diff = this.y2 - value; + } + else + { + diff = this.y3 - value; + } + + this.y1 -= diff; + this.y2 -= diff; + this.y3 -= diff; + } + + }, + + /** + * [description] + * + * @name Phaser.Geom.Triangle#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return Math.max(this.y1, this.y2, this.y3); + }, + + set: function (value) + { + var diff = 0; + + if (this.y1 >= this.y2 && this.y1 >= this.y3) + { + diff = this.y1 - value; + } + else if (this.y2 >= this.y1 && this.y2 >= this.y3) + { + diff = this.y2 - value; + } + else + { + diff = this.y3 - value; + } + + this.y1 -= diff; + this.y2 -= diff; + this.y3 -= diff; + } + + } + +}); + +module.exports = Triangle; + + +/***/ }), +/* 53 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Line.Angle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * + * @return {number} [description] + */ +var Angle = function (line) +{ + return Math.atan2(line.y2 - line.y1, line.x2 - line.x1); +}; + +module.exports = Angle; + + +/***/ }), +/* 54 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// http://www.blackpawn.com/texts/pointinpoly/ + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ +var Contains = function (triangle, x, y) +{ + var v0x = triangle.x3 - triangle.x1; + var v0y = triangle.y3 - triangle.y1; + + var v1x = triangle.x2 - triangle.x1; + var v1y = triangle.y2 - triangle.y1; + + var v2x = x - triangle.x1; + var v2y = y - triangle.y1; + + var dot00 = (v0x * v0x) + (v0y * v0y); + var dot01 = (v0x * v1x) + (v0y * v1y); + var dot02 = (v0x * v2x) + (v0y * v2y); + var dot11 = (v1x * v1x) + (v1y * v1y); + var dot12 = (v1x * v2x) + (v1y * v2y); + + // Compute barycentric coordinates + var b = ((dot00 * dot11) - (dot01 * dot01)); + var inv = (b === 0) ? 0 : (1 / b); + var u = ((dot11 * dot02) - (dot01 * dot12)) * inv; + var v = ((dot00 * dot12) - (dot01 * dot02)) * inv; + + return (u >= 0 && v >= 0 && (u + v < 1)); +}; + +module.exports = Contains; + + +/***/ }), +/* 55 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Shallow Object Clone. Will not clone nested objects. + * + * @function Phaser.Utils.Object.Clone + * @since 3.0.0 + * + * @param {object} obj - [description] + * + * @return {object} [description] + */ +var Clone = function (obj) +{ + var clone = {}; + + for (var key in obj) + { + if (Array.isArray(obj[key])) + { + clone[key] = obj[key].slice(0); + } + else + { + clone[key] = obj[key]; + } + } + + return clone; +}; + +module.exports = Clone; + + +/***/ }), +/* 56 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var FromPoints = __webpack_require__(150); +var Rectangle = __webpack_require__(10); +var Vector2 = __webpack_require__(6); + +/** + * @classdesc + * A Base Curve class, which all other curve types extend. + * + * Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + * + * @class Curve + * @memberOf Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {string} type - [description] + */ +var Curve = new Class({ + + initialize: + + function Curve (type) + { + /** + * String based identifier for the type of curve. + * + * @name Phaser.Curves.Curve#type + * @type {string} + * @since 3.0.0 + */ + this.type = type; + + /** + * The default number of divisions within the curve. + * + * @name Phaser.Curves.Curve#defaultDivisions + * @type {integer} + * @default 5 + * @since 3.0.0 + */ + this.defaultDivisions = 5; + + /** + * The quantity of arc length divisions within the curve. + * + * @name Phaser.Curves.Curve#arcLengthDivisions + * @type {integer} + * @default 100 + * @since 3.0.0 + */ + this.arcLengthDivisions = 100; + + /** + * An array of cached arc length values. + * + * @name Phaser.Curves.Curve#cacheArcLengths + * @type {number[]} + * @default [] + * @since 3.0.0 + */ + this.cacheArcLengths = []; + + /** + * Does the data of this curve need updating? + * + * @name Phaser.Curves.Curve#needsUpdate + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.needsUpdate = true; + + /** + * [description] + * + * @name Phaser.Curves.Curve#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * A temporary calculation Vector. + * + * @name Phaser.Curves.Curve#_tmpVec2A + * @type {Phaser.Math.Vector2} + * @private + * @since 3.0.0 + */ + this._tmpVec2A = new Vector2(); + + /** + * A temporary calculation Vector. + * + * @name Phaser.Curves.Curve#_tmpVec2B + * @type {Phaser.Math.Vector2} + * @private + * @since 3.0.0 + */ + this._tmpVec2B = new Vector2(); + }, + + /** + * Draws this curve on the given Graphics object. + * + * The curve is drawn using `Graphics.strokePoints` so will be drawn at whatever the present Graphics stroke color is. + * The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it. + * + * @method Phaser.Curves.Curve#draw + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - The Graphics instance onto which this curve will be drawn. + * @param {integer} [pointsTotal=32] - The resolution of the curve. The higher the value the smoother it will render, at the cost of rendering performance. + * + * @return {Phaser.GameObjects.Graphics} The Graphics object to which the curve was drawn. + */ + draw: function (graphics, pointsTotal) + { + if (pointsTotal === undefined) { pointsTotal = 32; } + + // So you can chain graphics calls + return graphics.strokePoints(this.getPoints(pointsTotal)); + }, + + /** + * Returns a Rectangle where the position and dimensions match the bounds of this Curve. + * + * You can control the accuracy of the bounds. The value given is used to work out how many points + * to plot across the curve. Higher values are more accurate at the cost of calculation speed. + * + * @method Phaser.Curves.Curve#getBounds + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} [out] - The Rectangle to store the bounds in. If falsey a new object will be created. + * @param {integer} [accuracy=16] - The accuracy of the bounds calculations. + * + * @return {Phaser.Geom.Rectangle} A Rectangle object holding the bounds of this curve. If `out` was given it will be this object. + */ + getBounds: function (out, accuracy) + { + if (!out) { out = new Rectangle(); } + if (accuracy === undefined) { accuracy = 16; } + + var len = this.getLength(); + + if (accuracy > len) + { + accuracy = len / 2; + } + + // The length of the curve in pixels + // So we'll have 1 spaced point per 'accuracy' pixels + + var spaced = Math.max(1, Math.round(len / accuracy)); + + return FromPoints(this.getSpacedPoints(spaced), out); + }, + + /** + * Returns an array of points, spaced out X distance pixels apart. + * The smaller the distance, the larger the array will be. + * + * @method Phaser.Curves.Curve#getDistancePoints + * @since 3.0.0 + * + * @param {integer} distance - The distance, in pixels, between each point along the curve. + * + * @return {Phaser.Geom.Point[]} An Array of Point objects. + */ + getDistancePoints: function (distance) + { + var len = this.getLength(); + + var spaced = Math.max(1, len / distance); + + return this.getSpacedPoints(spaced); + }, + + /** + * [description] + * + * @method Phaser.Curves.Curve#getEndPoint + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} out - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + getEndPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return this.getPointAt(1, out); + }, + + // Get total curve arc length + + /** + * [description] + * + * @method Phaser.Curves.Curve#getLength + * @since 3.0.0 + * + * @return {number} [description] + */ + getLength: function () + { + var lengths = this.getLengths(); + + return lengths[lengths.length - 1]; + }, + + // Get list of cumulative segment lengths + + /** + * [description] + * + * @method Phaser.Curves.Curve#getLengths + * @since 3.0.0 + * + * @param {integer} [divisions] - [description] + * + * @return {number[]} [description] + */ + getLengths: function (divisions) + { + if (divisions === undefined) { divisions = this.arcLengthDivisions; } + + if ((this.cacheArcLengths.length === divisions + 1) && !this.needsUpdate) + { + return this.cacheArcLengths; + } + + this.needsUpdate = false; + + var cache = []; + var current; + var last = this.getPoint(0, this._tmpVec2A); + var sum = 0; + + cache.push(0); + + for (var p = 1; p <= divisions; p++) + { + current = this.getPoint(p / divisions, this._tmpVec2B); + + sum += current.distance(last); + + cache.push(sum); + + last.copy(current); + } + + this.cacheArcLengths = cache; + + return cache; // { sums: cache, sum:sum }; Sum is in the last element. + }, + + // Get point at relative position in curve according to arc length + + // - u [0 .. 1] + + /** + * [description] + * + * @method Phaser.Curves.Curve#getPointAt + * @since 3.0.0 + * + * @param {float} u - [description] + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + getPointAt: function (u, out) + { + var t = this.getUtoTmapping(u); + + return this.getPoint(t, out); + }, + + // Get sequence of points using getPoint( t ) + + /** + * [description] + * + * @method Phaser.Curves.Curve#getPoints + * @since 3.0.0 + * + * @param {integer} [divisions] - [description] + * + * @return {Phaser.Math.Vector2[]} [description] + */ + getPoints: function (divisions) + { + if (divisions === undefined) { divisions = this.defaultDivisions; } + + var points = []; + + for (var d = 0; d <= divisions; d++) + { + points.push(this.getPoint(d / divisions)); + } + + return points; + }, + + /** + * [description] + * + * @method Phaser.Curves.Curve#getRandomPoint + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + getRandomPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return this.getPoint(Math.random(), out); + }, + + // Get sequence of points using getPointAt( u ) + + /** + * [description] + * + * @method Phaser.Curves.Curve#getSpacedPoints + * @since 3.0.0 + * + * @param {integer} [divisions] - [description] + * + * @return {Phaser.Math.Vector2[]} [description] + */ + getSpacedPoints: function (divisions) + { + if (divisions === undefined) { divisions = this.defaultDivisions; } + + var points = []; + + for (var d = 0; d <= divisions; d++) + { + var t = this.getUtoTmapping(d / divisions, null, divisions); + + points.push(this.getPoint(t)); + } + + return points; + }, + + /** + * [description] + * + * @method Phaser.Curves.Curve#getStartPoint + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return this.getPointAt(0, out); + }, + + // Returns a unit vector tangent at t + // In case any sub curve does not implement its tangent derivation, + // 2 points a small delta apart will be used to find its gradient + // which seems to give a reasonable approximation + + /** + * [description] + * + * @method Phaser.Curves.Curve#getTangent + * @since 3.0.0 + * + * @param {number} t - [description] + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + getTangent: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var delta = 0.0001; + var t1 = t - delta; + var t2 = t + delta; + + // Capping in case of danger + + if (t1 < 0) + { + t1 = 0; + } + + if (t2 > 1) + { + t2 = 1; + } + + this.getPoint(t1, this._tmpVec2A); + this.getPoint(t2, out); + + return out.subtract(this._tmpVec2A).normalize(); + }, + + /** + * [description] + * + * @method Phaser.Curves.Curve#getTangentAt + * @since 3.0.0 + * + * @param {float} u - [description] + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + getTangentAt: function (u, out) + { + var t = this.getUtoTmapping(u); + + return this.getTangent(t, out); + }, + + // Given a distance in pixels, get a t to find p. + /** + * [description] + * + * @method Phaser.Curves.Curve#getTFromDistance + * @since 3.0.0 + * + * @param {integer} distance - [description] + * @param {integer} [divisions] - [description] + * + * @return {float} [description] + */ + getTFromDistance: function (distance, divisions) + { + if (distance <= 0) + { + return 0; + } + + return this.getUtoTmapping(0, distance, divisions); + }, + + // Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant + + /** + * [description] + * + * @method Phaser.Curves.Curve#getUtoTmapping + * @since 3.0.0 + * + * @param {float} u - [description] + * @param {integer} distance - [description] + * @param {integer} [divisions] - [description] + * + * @return {number} [description] + */ + getUtoTmapping: function (u, distance, divisions) + { + var arcLengths = this.getLengths(divisions); + + var i = 0; + var il = arcLengths.length; + + var targetArcLength; // The targeted u distance value to get + + if (distance) + { + // Cannot overshoot the curve + targetArcLength = Math.min(distance, arcLengths[il - 1]); + } + else + { + targetArcLength = u * arcLengths[il - 1]; + } + + // binary search for the index with largest value smaller than target u distance + + var low = 0; + var high = il - 1; + var comparison; + + while (low <= high) + { + i = Math.floor(low + (high - low) / 2); // less likely to overflow, though probably not issue here, JS doesn't really have integers, all numbers are floats + + comparison = arcLengths[i] - targetArcLength; + + if (comparison < 0) + { + low = i + 1; + } + else if (comparison > 0) + { + high = i - 1; + } + else + { + high = i; + break; + } + } + + i = high; + + if (arcLengths[i] === targetArcLength) + { + return i / (il - 1); + } + + // we could get finer grain at lengths, or use simple interpolation between two points + + var lengthBefore = arcLengths[i]; + var lengthAfter = arcLengths[i + 1]; + + var segmentLength = lengthAfter - lengthBefore; + + // determine where we are between the 'before' and 'after' points + + var segmentFraction = (targetArcLength - lengthBefore) / segmentLength; + + // add that fractional amount to t + + return (i + segmentFraction) / (il - 1); + }, + + /** + * [description] + * + * @method Phaser.Curves.Curve#updateArcLengths + * @since 3.0.0 + */ + updateArcLengths: function () + { + this.needsUpdate = true; + + this.getLengths(); + } + +}); + +module.exports = Curve; + + +/***/ }), +/* 57 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); + +/** + * @classdesc + * [description] + * + * @class Vector3 + * @memberOf Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {number} [x] - [description] + * @param {number} [y] - [description] + * @param {number} [z] - [description] + */ +var Vector3 = new Class({ + + initialize: + + function Vector3 (x, y, z) + { + /** + * The x component of this Vector. + * + * @name Phaser.Math.Vector3#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The y component of this Vector. + * + * @name Phaser.Math.Vector3#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The z component of this Vector. + * + * @name Phaser.Math.Vector3#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + } + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#up + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + up: function () + { + this.x = 0; + this.y = 1; + this.z = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} A new Vector3 object containing this Vectors values. + */ + clone: function () + { + return new Vector3(this.x, this.y, this.z); + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#crossVectors + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} a - [description] + * @param {Phaser.Math.Vector3} b - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + crossVectors: function (a, b) + { + var ax = a.x; + var ay = a.y; + var az = a.z; + var bx = b.x; + var by = b.y; + var bz = b.z; + + this.x = ay * bz - az * by; + this.y = az * bx - ax * bz; + this.z = ax * by - ay * bx; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#equals + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - The Vector3 to compare against. + * + * @return {boolean} True if the two vectors strictly match, otherwise false. + */ + equals: function (v) + { + return ((this.x === v.x) && (this.y === v.y) && (this.z === v.z)); + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#copy + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} src - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + copy: function (src) + { + this.x = src.x; + this.y = src.y; + this.z = src.z || 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#set + * @since 3.0.0 + * + * @param {(number|object)} x - [description] + * @param {number} [y] - [description] + * @param {number} [z] - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + set: function (x, y, z) + { + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#add + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + add: function (v) + { + this.x += v.x; + this.y += v.y; + this.z += v.z || 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#subtract + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + subtract: function (v) + { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z || 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#multiply + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + multiply: function (v) + { + this.x *= v.x; + this.y *= v.y; + this.z *= v.z || 1; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#scale + * @since 3.0.0 + * + * @param {float} scale - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + scale: function (scale) + { + if (isFinite(scale)) + { + this.x *= scale; + this.y *= scale; + this.z *= scale; + } + else + { + this.x = 0; + this.y = 0; + this.z = 0; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#divide + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + divide: function (v) + { + this.x /= v.x; + this.y /= v.y; + this.z /= v.z || 1; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#negate + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + negate: function () + { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#distance + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - [description] + * + * @return {number} [description] + */ + distance: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + + return Math.sqrt(dx * dx + dy * dy + dz * dz); + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#distanceSq + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - [description] + * + * @return {number} [description] + */ + distanceSq: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + + return dx * dx + dy * dy + dz * dz; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#length + * @since 3.0.0 + * + * @return {number} [description] + */ + length: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + + return Math.sqrt(x * x + y * y + z * z); + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#lengthSq + * @since 3.0.0 + * + * @return {number} [description] + */ + lengthSq: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + + return x * x + y * y + z * z; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#normalize + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + normalize: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var len = x * x + y * y + z * z; + + if (len > 0) + { + len = 1 / Math.sqrt(len); + + this.x = x * len; + this.y = y * len; + this.z = z * len; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#dot + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - [description] + * + * @return {number} [description] + */ + dot: function (v) + { + return this.x * v.x + this.y * v.y + this.z * v.z; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#cross + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + cross: function (v) + { + var ax = this.x; + var ay = this.y; + var az = this.z; + var bx = v.x; + var by = v.y; + var bz = v.z; + + this.x = ay * bz - az * by; + this.y = az * bx - ax * bz; + this.z = ax * by - ay * bx; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#lerp + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - [description] + * @param {number} [t=0] - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + lerp: function (v, t) + { + if (t === undefined) { t = 0; } + + var ax = this.x; + var ay = this.y; + var az = this.z; + + this.x = ax + t * (v.x - ax); + this.y = ay + t * (v.y - ay); + this.z = az + t * (v.z - az); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#transformMat3 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} mat - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + transformMat3: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + this.x = x * m[0] + y * m[3] + z * m[6]; + this.y = x * m[1] + y * m[4] + z * m[7]; + this.z = x * m[2] + y * m[5] + z * m[8]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#transformMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + transformMat4: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + this.x = m[0] * x + m[4] * y + m[8] * z + m[12]; + this.y = m[1] * x + m[5] * y + m[9] * z + m[13]; + this.z = m[2] * x + m[6] * y + m[10] * z + m[14]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#transformCoordinates + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + transformCoordinates: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + var tx = (x * m[0]) + (y * m[4]) + (z * m[8]) + m[12]; + var ty = (x * m[1]) + (y * m[5]) + (z * m[9]) + m[13]; + var tz = (x * m[2]) + (y * m[6]) + (z * m[10]) + m[14]; + var tw = (x * m[3]) + (y * m[7]) + (z * m[11]) + m[15]; + + this.x = tx / tw; + this.y = ty / tw; + this.z = tz / tw; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#transformQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + transformQuat: function (q) + { + // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations + var x = this.x; + var y = this.y; + var z = this.z; + var qx = q.x; + var qy = q.y; + var qz = q.z; + var qw = q.w; + + // calculate quat * vec + var ix = qw * x + qy * z - qz * y; + var iy = qw * y + qz * x - qx * z; + var iz = qw * z + qx * y - qy * x; + var iw = -qx * x - qy * y - qz * z; + + // calculate result * inverse quat + this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; + this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; + this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; + + return this; + }, + + /** + * Multiplies this Vector3 by the specified matrix, applying a W divide. This is useful for projection, + * e.g. unprojecting a 2D point into 3D space. + * + * @method Phaser.Math.Vector3#project + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - [description] + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + project: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + var a00 = m[0]; + var a01 = m[1]; + var a02 = m[2]; + var a03 = m[3]; + var a10 = m[4]; + var a11 = m[5]; + var a12 = m[6]; + var a13 = m[7]; + var a20 = m[8]; + var a21 = m[9]; + var a22 = m[10]; + var a23 = m[11]; + var a30 = m[12]; + var a31 = m[13]; + var a32 = m[14]; + var a33 = m[15]; + + var lw = 1 / (x * a03 + y * a13 + z * a23 + a33); + + this.x = (x * a00 + y * a10 + z * a20 + a30) * lw; + this.y = (x * a01 + y * a11 + z * a21 + a31) * lw; + this.z = (x * a02 + y * a12 + z * a22 + a32) * lw; + + return this; + }, + + /** + * Unproject this point from 2D space to 3D space. + * The point should have its x and y properties set to + * 2D screen space, and the z either at 0 (near plane) + * or 1 (far plane). The provided matrix is assumed to already + * be combined, i.e. projection * view * model. + * + * After this operation, this vector's (x, y, z) components will + * represent the unprojected 3D coordinate. + * + * @method Phaser.Math.Vector3#unproject + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} viewport - Screen x, y, width and height in pixels. + * @param {Phaser.Math.Matrix4} invProjectionView - Combined projection and view matrix. + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + unproject: function (viewport, invProjectionView) + { + var viewX = viewport.x; + var viewY = viewport.y; + var viewWidth = viewport.z; + var viewHeight = viewport.w; + + var x = this.x - viewX; + var y = (viewHeight - this.y - 1) - viewY; + var z = this.z; + + this.x = (2 * x) / viewWidth - 1; + this.y = (2 * y) / viewHeight - 1; + this.z = 2 * z - 1; + + return this.project(invProjectionView); + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#reset + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} This Vector3 object. + */ + reset: function () + { + this.x = 0; + this.y = 0; + this.z = 0; + + return this; + } + +}); + +/* +Vector3.Zero = function () +{ + return new Vector3(0, 0, 0); +}; + +Vector3.Up = function () +{ + return new Vector3(0, 1.0, 0); +}; + +Vector3.Copy = function (source) +{ + return new Vector3(source.x, source.y, source.z); +}; + +Vector3.TransformCoordinates = function (vector, transformation) +{ + var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + (vector.z * transformation.m[8]) + transformation.m[12]; + var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + (vector.z * transformation.m[9]) + transformation.m[13]; + var z = (vector.x * transformation.m[2]) + (vector.y * transformation.m[6]) + (vector.z * transformation.m[10]) + transformation.m[14]; + var w = (vector.x * transformation.m[3]) + (vector.y * transformation.m[7]) + (vector.z * transformation.m[11]) + transformation.m[15]; + + return new Vector3(x / w, y / w, z / w); +}; + +Vector3.TransformNormal = function (vector, transformation) +{ + var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + (vector.z * transformation.m[8]); + var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + (vector.z * transformation.m[9]); + var z = (vector.x * transformation.m[2]) + (vector.y * transformation.m[6]) + (vector.z * transformation.m[10]); + + return new Vector3(x, y, z); +}; + +Vector3.Dot = function (left, right) +{ + return (left.x * right.x + left.y * right.y + left.z * right.z); +}; + +Vector3.Cross = function (left, right) +{ + var x = left.y * right.z - left.z * right.y; + var y = left.z * right.x - left.x * right.z; + var z = left.x * right.y - left.y * right.x; + + return new Vector3(x, y, z); +}; + +Vector3.Normalize = function (vector) +{ + var newVector = Vector3.Copy(vector); + newVector.normalize(); + + return newVector; +}; + +Vector3.Distance = function (value1, value2) +{ + return Math.sqrt(Vector3.DistanceSquared(value1, value2)); +}; + +Vector3.DistanceSquared = function (value1, value2) +{ + var x = value1.x - value2.x; + var y = value1.y - value2.y; + var z = value1.z - value2.z; + + return (x * x) + (y * y) + (z * z); +}; +*/ + +module.exports = Vector3; + + +/***/ }), +/* 58 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the center y coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetCenterY + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The center y coordinate of the bounds of the Game Object. + */ +var GetCenterY = function (gameObject) +{ + return gameObject.y - (gameObject.height * gameObject.originY) + (gameObject.height * 0.5); +}; + +module.exports = GetCenterY; + + +/***/ }), +/* 59 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the center top of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetCenterY + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} y - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetCenterY = function (gameObject, y) +{ + var offsetY = gameObject.height * gameObject.originY; + + gameObject.y = (y + offsetY) - (gameObject.height * 0.5); + + return gameObject; +}; + +module.exports = SetCenterY; + + +/***/ }), +/* 60 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the center top of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetCenterX + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} x - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetCenterX = function (gameObject, x) +{ + var offsetX = gameObject.width * gameObject.originX; + + gameObject.x = (x + offsetX) - (gameObject.width * 0.5); + + return gameObject; +}; + +module.exports = SetCenterX; + + /***/ }), /* 61 */ /***/ (function(module, exports) { @@ -10917,27 +10919,206 @@ var Axes = __webpack_require__(859); */ /** - * Force a value within the boundaries by clamping it to the range `min`, `max`. + * Returns the center x coordinate from the bounds of the Game Object. * - * @function Phaser.Math.Clamp + * @function Phaser.Display.Bounds.GetCenterX * @since 3.0.0 * - * @param {number} value - The value to be clamped. - * @param {number} min - The minimum bounds. - * @param {number} max - The maximum bounds. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. * - * @return {number} The clamped value. + * @return {number} The center x coordinate of the bounds of the Game Object. */ -var Clamp = function (value, min, max) +var GetCenterX = function (gameObject) { - return Math.max(min, Math.min(max, value)); + return gameObject.x - (gameObject.width * gameObject.originX) + (gameObject.width * 0.5); }; -module.exports = Clamp; +module.exports = GetCenterX; /***/ }), /* 62 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.BlendModes + */ + +module.exports = { + + /** + * Skips the Blend Mode check in the renderer. + * + * @name Phaser.BlendModes.SKIP_CHECK + * @type {integer} + * @since 3.0.0 + */ + SKIP_CHECK: -1, + + /** + * Normal blend mode. + * + * @name Phaser.BlendModes.NORMAL + * @type {integer} + * @since 3.0.0 + */ + NORMAL: 0, + + /** + * Add blend mode. + * + * @name Phaser.BlendModes.ADD + * @type {integer} + * @since 3.0.0 + */ + ADD: 1, + + /** + * Multiply blend mode. + * + * @name Phaser.BlendModes.MULTIPLY + * @type {integer} + * @since 3.0.0 + */ + MULTIPLY: 2, + + /** + * Screen blend mode. + * + * @name Phaser.BlendModes.SCREEN + * @type {integer} + * @since 3.0.0 + */ + SCREEN: 3, + + /** + * Overlay blend mode. + * + * @name Phaser.BlendModes.OVERLAY + * @type {integer} + * @since 3.0.0 + */ + OVERLAY: 4, + + /** + * Darken blend mode. + * + * @name Phaser.BlendModes.DARKEN + * @type {integer} + * @since 3.0.0 + */ + DARKEN: 5, + + /** + * Lighten blend mode. + * + * @name Phaser.BlendModes.LIGHTEN + * @type {integer} + * @since 3.0.0 + */ + LIGHTEN: 6, + + /** + * Color Dodge blend mode. + * + * @name Phaser.BlendModes.COLOR_DODGE + * @type {integer} + * @since 3.0.0 + */ + COLOR_DODGE: 7, + + /** + * Color Burn blend mode. + * + * @name Phaser.BlendModes.COLOR_BURN + * @type {integer} + * @since 3.0.0 + */ + COLOR_BURN: 8, + + /** + * Hard Light blend mode. + * + * @name Phaser.BlendModes.HARD_LIGHT + * @type {integer} + * @since 3.0.0 + */ + HARD_LIGHT: 9, + + /** + * Soft Light blend mode. + * + * @name Phaser.BlendModes.SOFT_LIGHT + * @type {integer} + * @since 3.0.0 + */ + SOFT_LIGHT: 10, + + /** + * Difference blend mode. + * + * @name Phaser.BlendModes.DIFFERENCE + * @type {integer} + * @since 3.0.0 + */ + DIFFERENCE: 11, + + /** + * Exclusion blend mode. + * + * @name Phaser.BlendModes.EXCLUSION + * @type {integer} + * @since 3.0.0 + */ + EXCLUSION: 12, + + /** + * Hue blend mode. + * + * @name Phaser.BlendModes.HUE + * @type {integer} + * @since 3.0.0 + */ + HUE: 13, + + /** + * Saturation blend mode. + * + * @name Phaser.BlendModes.SATURATION + * @type {integer} + * @since 3.0.0 + */ + SATURATION: 14, + + /** + * Color blend mode. + * + * @name Phaser.BlendModes.COLOR + * @type {integer} + * @since 3.0.0 + */ + COLOR: 15, + + /** + * Luminosity blend mode. + * + * @name Phaser.BlendModes.LUMINOSITY + * @type {integer} + * @since 3.0.0 + */ + LUMINOSITY: 16 + +}; + + +/***/ }), +/* 63 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -10948,6 +11129,15 @@ module.exports = Clamp; var Class = __webpack_require__(0); +/** + * @callback EachSetCallback + * + * @param {*} entry - [description] + * @param {number} index - [description] + * + * @return {?boolean} [description] + */ + /** * @classdesc * A Set is a collection of unique elements. @@ -10990,7 +11180,7 @@ var Set = new Class({ * @method Phaser.Structs.Set#set * @since 3.0.0 * - * @param {any} value - [description] + * @param {*} value - [description] * * @return {Phaser.Structs.Set} This Set object. */ @@ -11011,9 +11201,9 @@ var Set = new Class({ * @since 3.0.0 * * @param {string} property - [description] - * @param {any} value - [description] + * @param {*} value - [description] * - * @return {any} [description] + * @return {*} [description] */ get: function (property, value) { @@ -11047,7 +11237,7 @@ var Set = new Class({ * @method Phaser.Structs.Set#delete * @since 3.0.0 * - * @param {any} value - [description] + * @param {*} value - [description] * * @return {Phaser.Structs.Set} This Set object. */ @@ -11090,7 +11280,7 @@ var Set = new Class({ * @method Phaser.Structs.Set#each * @since 3.0.0 * - * @param {function} callback - [description] + * @param {EachSetCallback} callback - [description] * @param {object} callbackScope - [description] * * @return {Phaser.Structs.Set} This Set object. @@ -11131,7 +11321,7 @@ var Set = new Class({ * @method Phaser.Structs.Set#iterate * @since 3.0.0 * - * @param {function} callback - [description] + * @param {EachSetCallback} callback - [description] * @param {object} callbackScope - [description] * * @return {Phaser.Structs.Set} This Set object. @@ -11219,7 +11409,7 @@ var Set = new Class({ * @method Phaser.Structs.Set#contains * @since 3.0.0 * - * @param {any} value - [description] + * @param {*} value - [description] * * @return {boolean} [description] */ @@ -11332,7 +11522,7 @@ module.exports = Set; /***/ }), -/* 63 */ +/* 64 */ /***/ (function(module, exports) { /** @@ -11342,2005 +11532,29 @@ module.exports = Set; */ /** - * @namespace Phaser.ScaleModes - */ - -module.exports = { - - /** - * Default Scale Mode (Linear). - * - * @name Phaser.ScaleModes.DEFAULT - * @type {integer} - * @since 3.0.0 - */ - DEFAULT: 0, - - /** - * Linear Scale Mode. - * - * @name Phaser.ScaleModes.LINEAR - * @type {integer} - * @since 3.0.0 - */ - LINEAR: 0, - - /** - * Nearest Scale Mode. - * - * @name Phaser.ScaleModes.NEAREST - * @type {integer} - * @since 3.0.0 - */ - NEAREST: 1 - -}; - - -/***/ }), -/* 64 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Contains = __webpack_require__(32); -var GetPoint = __webpack_require__(184); -var GetPoints = __webpack_require__(185); -var Random = __webpack_require__(106); - -/** - * @classdesc - * A Circle object. + * Force a value within the boundaries by clamping it to the range `min`, `max`. * - * This is a geometry object, containing numerical values and related methods to inspect and modify them. - * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. - * To render a Circle you should look at the capabilities of the Graphics class. - * - * @class Circle - * @memberOf Phaser.Geom - * @constructor + * @function Phaser.Math.Clamp * @since 3.0.0 * - * @param {number} [x=0] - The x position of the center of the circle. - * @param {number} [y=0] - The y position of the center of the circle. - * @param {number} [radius=0] - The radius of the circle. + * @param {number} value - The value to be clamped. + * @param {number} min - The minimum bounds. + * @param {number} max - The maximum bounds. + * + * @return {number} The clamped value. */ -var Circle = new Class({ +var Clamp = function (value, min, max) +{ + return Math.max(min, Math.min(max, value)); +}; - initialize: - - function Circle (x, y, radius) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (radius === undefined) { radius = 0; } - - /** - * The x position of the center of the circle. - * - * @name Phaser.Geom.Circle#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x = x; - - /** - * The y position of the center of the circle. - * - * @name Phaser.Geom.Circle#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y = y; - - /** - * The internal radius of the circle. - * - * @name Phaser.Geom.Circle#_radius - * @type {number} - * @private - * @since 3.0.0 - */ - this._radius = radius; - - /** - * The internal diameter of the circle. - * - * @name Phaser.Geom.Circle#_diameter - * @type {number} - * @private - * @since 3.0.0 - */ - this._diameter = radius * 2; - }, - - /** - * Check to see if the Circle contains the given x / y coordinates. - * - * @method Phaser.Geom.Circle#contains - * @since 3.0.0 - * - * @param {number} x - The x coordinate to check within the circle. - * @param {number} y - The y coordinate to check within the circle. - * - * @return {boolean} True if the coordinates are within the circle, otherwise false. - */ - contains: function (x, y) - { - return Contains(this, x, y); - }, - - /** - * Returns a Point object containing the coordinates of a point on the circumference of the Circle - * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point - * at 180 degrees around the circle. - * - * @method Phaser.Geom.Circle#getPoint - * @since 3.0.0 - * - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. - * @param {Phaser.Geom.Point|object} [out] - An object to store the return values in. If not given a Point object will be created. - * - * @return {Phaser.Geom.Point|object} A Point, or point-like object, containing the coordinates of the point around the circle. - */ - getPoint: function (position, point) - { - return GetPoint(this, position, point); - }, - - /** - * Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, - * based on the given quantity or stepRate values. - * - * @method Phaser.Geom.Circle#getPoints - * @since 3.0.0 - * - * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param {number} [stepRate] - Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. - * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. - * - * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the circumference of the circle. - */ - getPoints: function (quantity, stepRate, output) - { - return GetPoints(this, quantity, stepRate, output); - }, - - /** - * Returns a uniformly distributed random point from anywhere within the Circle. - * - * @method Phaser.Geom.Circle#getRandomPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Point|object} [point] - A Point or point-like object to set the random `x` and `y` values in. - * - * @return {Phaser.Geom.Point|object} A Point object with the random values set in the `x` and `y` properties. - */ - getRandomPoint: function (point) - { - return Random(this, point); - }, - - /** - * Sets the x, y and radius of this circle. - * - * @method Phaser.Geom.Circle#setTo - * @since 3.0.0 - * - * @param {number} [x=0] - The x position of the center of the circle. - * @param {number} [y=0] - The y position of the center of the circle. - * @param {number} [radius=0] - The radius of the circle. - * - * @return {Phaser.Geom.Circle} This Circle object. - */ - setTo: function (x, y, radius) - { - this.x = x; - this.y = y; - this._radius = radius; - this._diameter = radius * 2; - - return this; - }, - - /** - * Sets this Circle to be empty with a radius of zero. - * Does not change its position. - * - * @method Phaser.Geom.Circle#setEmpty - * @since 3.0.0 - * - * @return {Phaser.Geom.Circle} This Circle object. - */ - setEmpty: function () - { - this._radius = 0; - this._diameter = 0; - - return this; - }, - - /** - * Sets the position of this Circle. - * - * @method Phaser.Geom.Circle#setPosition - * @since 3.0.0 - * - * @param {number} [x=0] - The x position of the center of the circle. - * @param {number} [y=0] - The y position of the center of the circle. - * - * @return {Phaser.Geom.Circle} This Circle object. - */ - setPosition: function (x, y) - { - if (y === undefined) { y = x; } - - this.x = x; - this.y = y; - - return this; - }, - - /** - * Checks to see if the Circle is empty: has a radius of zero. - * - * @method Phaser.Geom.Circle#isEmpty - * @since 3.0.0 - * - * @return {boolean} True if the Circle is empty, otherwise false. - */ - isEmpty: function () - { - return (this._radius <= 0); - }, - - /** - * The radius of the Circle. - * - * @name Phaser.Geom.Circle#radius - * @type {number} - * @since 3.0.0 - */ - radius: { - - get: function () - { - return this._radius; - }, - - set: function (value) - { - this._radius = value; - this._diameter = value * 2; - } - - }, - - /** - * The diameter of the Circle. - * - * @name Phaser.Geom.Circle#diameter - * @type {number} - * @since 3.0.0 - */ - diameter: { - - get: function () - { - return this._diameter; - }, - - set: function (value) - { - this._diameter = value; - this._radius = value * 0.5; - } - - }, - - /** - * The left position of the Circle. - * - * @name Phaser.Geom.Circle#left - * @type {number} - * @since 3.0.0 - */ - left: { - - get: function () - { - return this.x - this._radius; - }, - - set: function (value) - { - this.x = value + this._radius; - } - - }, - - /** - * The right position of the Circle. - * - * @name Phaser.Geom.Circle#right - * @type {number} - * @since 3.0.0 - */ - right: { - - get: function () - { - return this.x + this._radius; - }, - - set: function (value) - { - this.x = value - this._radius; - } - - }, - - /** - * The top position of the Circle. - * - * @name Phaser.Geom.Circle#top - * @type {number} - * @since 3.0.0 - */ - top: { - - get: function () - { - return this.y - this._radius; - }, - - set: function (value) - { - this.y = value + this._radius; - } - - }, - - /** - * The bottom position of the Circle. - * - * @name Phaser.Geom.Circle#bottom - * @type {number} - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return this.y + this._radius; - }, - - set: function (value) - { - this.y = value - this._radius; - } - - } - -}); - -module.exports = Circle; +module.exports = Clamp; /***/ }), /* 65 */ /***/ (function(module, exports, __webpack_require__) { -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clamp = __webpack_require__(61); - -/** - * Return a value based on the range between `min` and `max` and the percentage given. - * - * @function Phaser.Math.FromPercent - * @since 3.0.0 - * - * @param {float} percent - A value between 0 and 1 representing the percentage. - * @param {number} min - [description] - * @param {number} [max] - [description] - * - * @return {number} [description] - */ -var FromPercent = function (percent, min, max) -{ - percent = Clamp(percent, 0, 1); - - return (max - min) * percent; -}; - -module.exports = FromPercent; - - -/***/ }), -/* 66 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Length - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var Length = function (line) -{ - return Math.sqrt((line.x2 - line.x1) * (line.x2 - line.x1) + (line.y2 - line.y1) * (line.y2 - line.y1)); -}; - -module.exports = Length; - - -/***/ }), -/* 67 */ -/***/ (function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(process) {/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Determines the operating system of the device running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.os` from within any Scene. - * - * @name Phaser.Device.OS - * @since 3.0.0 - * - * @type {object} - * @property {boolean} android - Is running on android? - * @property {boolean} chromeOS - Is running on chromeOS? - * @property {boolean} cocoonJS - Is the game running under CocoonJS? - * @property {boolean} cocoonJSApp - Is this game running with CocoonJS.App? - * @property {boolean} cordova - Is the game running under Apache Cordova? - * @property {boolean} crosswalk - Is the game running under the Intel Crosswalk XDK? - * @property {boolean} desktop - Is running on a desktop? - * @property {boolean} ejecta - Is the game running under Ejecta? - * @property {boolean} electron - Is the game running under GitHub Electron? - * @property {boolean} iOS - Is running on iOS? - * @property {boolean} iPad - Is running on iPad? - * @property {boolean} iPhone - Is running on iPhone? - * @property {boolean} kindle - Is running on an Amazon Kindle? - * @property {boolean} linux - Is running on linux? - * @property {boolean} macOS - Is running on macOS? - * @property {boolean} node - Is the game running under Node.js? - * @property {boolean} nodeWebkit - Is the game running under Node-Webkit? - * @property {boolean} webApp - Set to true if running as a WebApp, i.e. within a WebView - * @property {boolean} windows - Is running on windows? - * @property {boolean} windowsPhone - Is running on a Windows Phone? - * @property {number} iOSVersion - If running in iOS this will contain the major version number. - * @property {number} pixelRatio - PixelRatio of the host device? - */ -var OS = { - - android: false, - chromeOS: false, - cocoonJS: false, - cocoonJSApp: false, - cordova: false, - crosswalk: false, - desktop: false, - ejecta: false, - electron: false, - iOS: false, - iOSVersion: 0, - iPad: false, - iPhone: false, - kindle: false, - linux: false, - macOS: false, - node: false, - nodeWebkit: false, - pixelRatio: 1, - webApp: false, - windows: false, - windowsPhone: false - -}; - -function init () -{ - var ua = navigator.userAgent; - - if (/Windows/.test(ua)) - { - OS.windows = true; - } - else if (/Mac OS/.test(ua)) - { - OS.macOS = true; - } - else if (/Linux/.test(ua)) - { - OS.linux = true; - } - else if (/Android/.test(ua)) - { - OS.android = true; - } - else if (/iP[ao]d|iPhone/i.test(ua)) - { - OS.iOS = true; - (navigator.appVersion).match(/OS (\d+)/); - OS.iOSVersion = parseInt(RegExp.$1, 10); - } - else if (/Kindle/.test(ua) || (/\bKF[A-Z][A-Z]+/).test(ua) || (/Silk.*Mobile Safari/).test(ua)) - { - OS.kindle = true; - - // This will NOT detect early generations of Kindle Fire, I think there is no reliable way... - // E.g. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-80) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true" - } - else if (/CrOS/.test(ua)) - { - OS.chromeOS = true; - } - - if (/Windows Phone/i.test(ua) || (/IEMobile/i).test(ua)) - { - OS.android = false; - OS.iOS = false; - OS.macOS = false; - OS.windows = true; - OS.windowsPhone = true; - } - - var silk = (/Silk/).test(ua); - - if (OS.windows || OS.macOS || (OS.linux && !silk) || OS.chromeOS) - { - OS.desktop = true; - } - - // Windows Phone / Table reset - if (OS.windowsPhone || ((/Windows NT/i.test(ua)) && (/Touch/i.test(ua)))) - { - OS.desktop = false; - } - - // WebApp mode in iOS - if (navigator.standalone) - { - OS.webApp = true; - } - - if (window.cordova !== undefined) - { - OS.cordova = true; - } - - if ((typeof process !== 'undefined') && (typeof process.versions.node !== 'undefined')) - { - OS.node = true; - } - - if (OS.node && typeof process.versions === 'object') - { - OS.nodeWebkit = !!process.versions['node-webkit']; - - OS.electron = !!process.versions.electron; - } - - if (navigator.isCocoonJS) - { - OS.cocoonJS = true; - - try - { - OS.cocoonJSApp = (typeof CocoonJS !== 'undefined'); - } - catch (error) - { - OS.cocoonJSApp = false; - } - } - - if (window.ejecta !== undefined) - { - OS.ejecta = true; - } - - if ((/Crosswalk/).test(ua)) - { - OS.crosswalk = true; - } - - OS.iPhone = ua.toLowerCase().indexOf('iphone') !== -1; - OS.iPad = ua.toLowerCase().indexOf('ipad') !== -1; - - OS.pixelRatio = window['devicePixelRatio'] || 1; - - return OS; -} - -module.exports = init(); - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(506))) - -/***/ }), -/* 68 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Check to see if the Ellipse contains the given x / y coordinates. - * - * @function Phaser.Geom.Ellipse.Contains - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. - * @param {number} x - The x coordinate to check within the ellipse. - * @param {number} y - The y coordinate to check within the ellipse. - * - * @return {boolean} True if the coordinates are within the ellipse, otherwise false. - */ -var Contains = function (ellipse, x, y) -{ - if (ellipse.width <= 0 || ellipse.height <= 0) - { - return false; - } - - // Normalize the coords to an ellipse with center 0,0 and a radius of 0.5 - var normx = ((x - ellipse.x) / ellipse.width); - var normy = ((y - ellipse.y) / ellipse.height); - - normx *= normx; - normy *= normy; - - return (normx + normy < 0.25); -}; - -module.exports = Contains; - - -/***/ }), -/* 69 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Actions = __webpack_require__(171); -var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(2); -var GetValue = __webpack_require__(4); -var Range = __webpack_require__(275); -var Set = __webpack_require__(62); -var Sprite = __webpack_require__(37); - -/** - * @classdesc - * [description] - * - * children can be either an array of children, or a config object - * config can be either a config object, or undefined if passed as the children argument instead - * - * @class Group - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {array} children - [description] - * @param {object} config - [description] - */ -var Group = new Class({ - - initialize: - - function Group (scene, children, config) - { - if (config === undefined && !Array.isArray(children) && typeof children === 'object') - { - config = children; - children = null; - } - - /** - * [description] - * - * @name Phaser.GameObjects.Group#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.GameObjects.Group#children - * @type {Phaser.Structs.Set} - * @since 3.0.0 - */ - this.children = new Set(children); - - /** - * [description] - * - * @name Phaser.GameObjects.Group#isParent - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.isParent = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Group#classType - * @type {object} - * @since 3.0.0 - */ - this.classType = GetFastValue(config, 'classType', Sprite); - - /** - * [description] - * - * @name Phaser.GameObjects.Group#active - * @type {boolean} - * @since 3.0.0 - */ - this.active = GetFastValue(config, 'active', true); - - /** - * [description] - * - * @name Phaser.GameObjects.Group#maxSize - * @type {integer} - * @since 3.0.0 - */ - this.maxSize = GetFastValue(config, 'maxSize', -1); - - /** - * [description] - * - * @name Phaser.GameObjects.Group#defaultKey - * @type {string} - * @since 3.0.0 - */ - this.defaultKey = GetFastValue(config, 'defaultKey', null); - - /** - * [description] - * - * @name Phaser.GameObjects.Group#defaultFrame - * @type {string|integer} - * @since 3.0.0 - */ - this.defaultFrame = GetFastValue(config, 'defaultFrame', null); - - /** - * [description] - * - * @name Phaser.GameObjects.Group#runChildUpdate - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.runChildUpdate = GetFastValue(config, 'runChildUpdate', false); - - /** - * [description] - * - * @name Phaser.GameObjects.Group#createCallback - * @type {?function} - * @since 3.0.0 - */ - this.createCallback = GetFastValue(config, 'createCallback', null); - - /** - * [description] - * - * @name Phaser.GameObjects.Group#removeCallback - * @type {?function} - * @since 3.0.0 - */ - this.removeCallback = GetFastValue(config, 'removeCallback', null); - - /** - * [description] - * - * @name Phaser.GameObjects.Group#createMultipleCallback - * @type {?function} - * @since 3.0.0 - */ - this.createMultipleCallback = GetFastValue(config, 'createMultipleCallback', null); - - if (config) - { - this.createMultiple(config); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#create - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * @param {boolean} [visible=true] - [description] - * - * @return {Phaser.GameObjects.GameObject} [description] - */ - create: function (x, y, key, frame, visible) - { - if (key === undefined) { key = this.defaultKey; } - if (frame === undefined) { frame = this.defaultFrame; } - if (visible === undefined) { visible = true; } - - // Pool? - if (this.isFull()) - { - return null; - } - - var child = new this.classType(this.scene, x, y, key, frame); - - this.scene.sys.displayList.add(child); - - if (child.preUpdate) - { - this.scene.sys.updateList.add(child); - } - - child.visible = visible; - - this.add(child); - - return child; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#createMultiple - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.GameObject[]} [description] - */ - createMultiple: function (config) - { - if (!Array.isArray(config)) - { - config = [ config ]; - } - - var output = []; - - for (var i = 0; i < config.length; i++) - { - var entries = this.createFromConfig(config[i]); - - output = output.concat(entries); - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#createFromConfig - * @since 3.0.0 - * - * @param {object} options - [description] - * - * @return {Phaser.GameObjects.GameObject[]} [description] - */ - createFromConfig: function (options) - { - this.classType = GetFastValue(options, 'classType', this.classType); - - var key = GetFastValue(options, 'key', undefined); - var frame = GetFastValue(options, 'frame', null); - var visible = GetFastValue(options, 'visible', true); - - var entries = []; - - // Can't do anything without at least a key - if (key === undefined) - { - return entries; - } - else - { - if (!Array.isArray(key)) - { - key = [ key ]; - } - - if (!Array.isArray(frame)) - { - frame = [ frame ]; - } - } - - // Build an array of key frame pairs to loop through - - var repeat = GetFastValue(options, 'repeat', 0); - var randomKey = GetFastValue(options, 'randomKey', false); - var randomFrame = GetFastValue(options, 'randomFrame', false); - var yoyo = GetFastValue(options, 'yoyo', false); - var quantity = GetFastValue(options, 'frameQuantity', 1); - var max = GetFastValue(options, 'max', 0); - - // If a grid is set we use that to override the quantity? - - var range = Range(key, frame, { - max: max, - qty: quantity, - random: randomKey, - randomB: randomFrame, - repeat: repeat, - yoyo: yoyo - }); - - for (var c = 0; c < range.length; c++) - { - entries.push(this.create(0, 0, range[c].a, range[c].b, visible)); - } - - // Post-creation options (applied only to those items created in this call): - - var x = GetValue(options, 'setXY.x', 0); - var y = GetValue(options, 'setXY.y', 0); - var stepX = GetValue(options, 'setXY.stepX', 0); - var stepY = GetValue(options, 'setXY.stepY', 0); - - Actions.SetXY(entries, x, y, stepX, stepY); - - var rotation = GetValue(options, 'setRotation.value', 0); - var stepRotation = GetValue(options, 'setRotation.step', 0); - - Actions.SetRotation(entries, rotation, stepRotation); - - var scaleX = GetValue(options, 'setScale.x', 1); - var scaleY = GetValue(options, 'setScale.y', scaleX); - var stepScaleX = GetValue(options, 'setScale.stepX', 0); - var stepScaleY = GetValue(options, 'setScale.stepY', 0); - - Actions.SetScale(entries, scaleX, scaleY, stepScaleX, stepScaleY); - - var alpha = GetValue(options, 'setAlpha.value', 1); - var stepAlpha = GetValue(options, 'setAlpha.step', 0); - - Actions.SetAlpha(entries, alpha, stepAlpha); - - var hitArea = GetFastValue(options, 'hitArea', null); - var hitAreaCallback = GetFastValue(options, 'hitAreaCallback', null); - - if (hitArea) - { - Actions.SetHitArea(entries, hitArea, hitAreaCallback); - } - - var grid = GetFastValue(options, 'gridAlign', false); - - if (grid) - { - Actions.GridAlign(entries, grid); - } - - if (this.createMultipleCallback) - { - this.createMultipleCallback.call(this, entries); - } - - return entries; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#preUpdate - * @since 3.0.0 - * - * @param {number} time - [description] - * @param {number} delta - [description] - */ - preUpdate: function (time, delta) - { - if (!this.runChildUpdate || this.children.size === 0) - { - return; - } - - // Because a Group child may mess with the length of the Group during its update - var temp = this.children.entries.slice(); - - for (var i = 0; i < temp.length; i++) - { - var item = temp[i]; - - if (item.active) - { - item.update(time, delta); - } - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#add - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - * @param {boolean} [addToScene=false] - [description] - * - * @return {Phaser.GameObjects.Group} This Group object. - */ - add: function (child, addToScene) - { - if (addToScene === undefined) { addToScene = false; } - - this.children.set(child); - - if (this.createCallback) - { - this.createCallback.call(this, child); - } - - if (addToScene) - { - this.scene.sys.displayList.add(child); - - if (child.preUpdate) - { - this.scene.sys.updateList.add(child); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#addMultiple - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject[]} children - [description] - * @param {boolean} [addToScene=false] - [description] - * - * @return {Phaser.GameObjects.Group} This Group object. - */ - addMultiple: function (children, addToScene) - { - if (addToScene === undefined) { addToScene = false; } - - if (Array.isArray(children)) - { - for (var i = 0; i < children.length; i++) - { - this.add(children[i], addToScene); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#remove - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - * @param {boolean} [removeFromScene=false] - [description] - * - * @return {Phaser.GameObjects.Group} This Group object. - */ - remove: function (child, removeFromScene) - { - if (removeFromScene === undefined) { removeFromScene = false; } - - this.children.delete(child); - - if (removeFromScene) - { - this.scene.sys.displayList.remove(child); - - if (child.preUpdate) - { - this.scene.sys.updateList.remove(child); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#clear - * @since 3.0.0 - * - * @param {boolean} [removeFromScene=false] - [description] - * - * @return {Phaser.GameObjects.Group} This Group object. - */ - clear: function (removeFromScene) - { - if (removeFromScene === undefined) { removeFromScene = false; } - - if (removeFromScene) - { - var children = this.children; - - for (var i = 0; i < children.size; i++) - { - var gameObject = children.entries[i]; - - this.scene.sys.displayList.remove(gameObject); - - if (gameObject.preUpdate) - { - this.scene.sys.updateList.remove(gameObject); - } - } - } - - this.children.clear(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#contains - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - * - * @return {boolean} [description] - */ - contains: function (child) - { - return this.children.contains(child); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#getChildren - * @since 3.0.0 - * - * @return {Phaser.GameObjects.GameObject[]} [description] - */ - getChildren: function () - { - return this.children.entries; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#getLength - * @since 3.0.0 - * - * @return {integer} [description] - */ - getLength: function () - { - return this.children.size; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#getFirst - * @since 3.0.0 - * - * @param {boolean} [state=false] - [description] - * @param {boolean} [createIfNull=false] - [description] - * @param {number} [x] - The horizontal position of this Game Object in the world. - * @param {number} [y] - The vertical position of this Game Object in the world. - * @param {string} [texture] - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * @param {boolean} [visible] - [description] - * - * @return {Phaser.GameObjects.GameObject|null} [description] - */ - getFirst: function (state, createIfNull, x, y, key, frame, visible) - { - if (state === undefined) { state = false; } - if (createIfNull === undefined) { createIfNull = false; } - - var gameObject; - - var children = this.children.entries; - - for (var i = 0; i < children.length; i++) - { - gameObject = children[i]; - - if (gameObject.active === state) - { - if (typeof(x) === 'number') - { - gameObject.x = x; - } - - if (typeof(y) === 'number') - { - gameObject.y = y; - } - - return gameObject; - } - } - - // Got this far? We need to create or bail - if (createIfNull) - { - return this.create(x, y, key, frame, visible); - } - else - { - return null; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#get - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * @param {boolean} visible - [description] - * - * @return {Phaser.GameObjects.GameObject} [description] - */ - get: function (x, y, key, frame, visible) - { - return this.getFirst(false, true, x, y, key, frame, visible); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#getFirstAlive - * @since 3.0.0 - * - * @param {boolean} createIfNull - [description] - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * @param {boolean} visible - [description] - * - * @return {Phaser.GameObjects.GameObject} [description] - */ - getFirstAlive: function (createIfNull, x, y, key, frame, visible) - { - return this.getFirst(true, createIfNull, x, y, key, frame, visible); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#getFirstDead - * @since 3.0.0 - * - * @param {boolean} createIfNull - [description] - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * @param {boolean} visible - [description] - * - * @return {Phaser.GameObjects.GameObject} [description] - */ - getFirstDead: function (createIfNull, x, y, key, frame, visible) - { - return this.getFirst(false, createIfNull, x, y, key, frame, visible); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#playAnimation - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} startFrame - [description] - * - * @return {Phaser.GameObjects.Group} This Group object. - */ - playAnimation: function (key, startFrame) - { - Actions.PlayAnimation(this.children.entries, key, startFrame); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#isFull - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isFull: function () - { - if (this.maxSize === -1) - { - return false; - } - else - { - return (this.children.size === this.maxSize); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#countActive - * @since 3.0.0 - * - * @param {boolean} [value=true] - [description] - * - * @return {integer} [description] - */ - countActive: function (value) - { - if (value === undefined) { value = true; } - - var total = 0; - - for (var i = 0; i < this.children.size; i++) - { - if (this.children.entries[i].active === value) - { - total++; - } - } - - return total; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#getTotalUsed - * @since 3.0.0 - * - * @return {integer} [description] - */ - getTotalUsed: function () - { - return this.countActive(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#getTotalFree - * @since 3.0.0 - * - * @return {integer} [description] - */ - getTotalFree: function () - { - var used = this.getTotalUsed(); - var capacity = (this.maxSize === -1) ? 999999999999 : this.maxSize; - - return (capacity - used); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#setDepth - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} step - [description] - * - * @return {Phaser.GameObjects.Group} This Group object. - */ - setDepth: function (value, step) - { - Actions.SetDepth(this.children.entries, value, step); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#kill - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - */ - kill: function (gameObject) - { - if (this.children.contains(gameObject)) - { - gameObject.setActive(false); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#killAndHide - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - */ - killAndHide: function (gameObject) - { - if (this.children.contains(gameObject)) - { - gameObject.setActive(false); - gameObject.setVisible(false); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#toggleVisible - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Group} This Group object. - */ - toggleVisible: function () - { - Actions.ToggleVisible(this.children.entries); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Group#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.children.clear(); - - this.scene = undefined; - this.children = undefined; - } - -}); - -module.exports = Group; - - -/***/ }), -/* 70 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var GameObject = __webpack_require__(1); -var ImageRender = __webpack_require__(570); - -/** - * @classdesc - * An Image Game Object. - * - * An Image is a light-weight Game Object useful for the display of static images in your game, - * such as logos, backgrounds, scenery or other non-animated elements. Images can have input - * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an - * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. - * - * @class Image - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var Image = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Size, - Components.Texture, - Components.Tint, - Components.Transform, - Components.Visible, - ImageRender - ], - - initialize: - - function Image (scene, x, y, texture, frame) - { - GameObject.call(this, scene, 'Image'); - - this.setTexture(texture, frame); - this.setPosition(x, y); - this.setSizeToFrame(); - this.setOriginFromFrame(); - this.initPipeline('TextureTintPipeline'); - } - -}); - -module.exports = Image; - - -/***/ }), -/* 71 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var EaseMap = __webpack_require__(578); - -/** - * [description] - * - * @function Phaser.Tweens.Builders.GetEaseFunction - * @since 3.0.0 - * - * @param {string|function} ease - [description] - * @param {array} easeParams - [description] - * - * @return {function} [description] - */ -var GetEaseFunction = function (ease, easeParams) -{ - if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease)) - { - if (easeParams) - { - var cloneParams = easeParams.slice(0); - - cloneParams.unshift(0); - - return function (v) - { - cloneParams[0] = v; - - return EaseMap[ease].apply(this, cloneParams); - }; - } - else - { - // String based look-up - return EaseMap[ease]; - } - } - else if (typeof ease === 'function') - { - // Custom function - return ease; - } - else if (Array.isArray(ease) && ease.length === 4) - { - // Bezier function (TODO) - } - - return EaseMap.Power0; -}; - -module.exports = GetEaseFunction; - - -/***/ }), -/* 72 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Utils.Object.HasValue - * @since 3.0.0 - * - * @param {object} source - [description] - * @param {string} key - [description] - * - * @return {boolean} [description] - */ -var HasValue = function (source, key) -{ - return (source.hasOwnProperty(key)); -}; - -module.exports = HasValue; - - -/***/ }), -/* 73 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Tweens.Builders.GetBoolean - * @since 3.0.0 - * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {any} defaultValue - [description] - * - * @return {any} [description] - */ -var GetBoolean = function (source, key, defaultValue) -{ - if (!source) - { - return defaultValue; - } - else if (source.hasOwnProperty(key)) - { - return source[key]; - } - else - { - return defaultValue; - } -}; - -module.exports = GetBoolean; - - -/***/ }), -/* 74 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Checks if the given tile coordinates are within the bounds of the layer. - * - * @function Phaser.Tilemaps.Components.IsInLayerBounds - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {boolean} - */ -var IsInLayerBounds = function (tileX, tileY, layer) -{ - return (tileX >= 0 && tileX < layer.width && tileY >= 0 && tileY < layer.height); -}; - -module.exports = IsInLayerBounds; - - -/***/ }), -/* 75 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(2); - -/** - * @classdesc - * A class for representing data about about a layer in a map. Maps are parsed from CSV, Tiled, - * etc. into this format. Tilemap, StaticTilemapLayer and DynamicTilemapLayer have a reference - * to this data and use it to look up and perform operations on tiles. - * - * @class LayerData - * @memberOf Phaser.Tilemaps - * @constructor - * @since 3.0.0 - * - * @param {object} [config] - [description] - */ -var LayerData = new Class({ - - initialize: - - function LayerData (config) - { - if (config === undefined) { config = {}; } - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#name - * @type {string} - * @since 3.0.0 - */ - this.name = GetFastValue(config, 'name', 'layer'); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#x - * @type {number} - * @since 3.0.0 - */ - this.x = GetFastValue(config, 'x', 0); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#y - * @type {number} - * @since 3.0.0 - */ - this.y = GetFastValue(config, 'y', 0); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#width - * @type {number} - * @since 3.0.0 - */ - this.width = GetFastValue(config, 'width', 0); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#height - * @type {number} - * @since 3.0.0 - */ - this.height = GetFastValue(config, 'height', 0); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#tileWidth - * @type {number} - * @since 3.0.0 - */ - this.tileWidth = GetFastValue(config, 'tileWidth', 0); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#tileHeight - * @type {number} - * @since 3.0.0 - */ - this.tileHeight = GetFastValue(config, 'tileHeight', 0); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#baseTileWidth - * @type {number} - * @since 3.0.0 - */ - this.baseTileWidth = GetFastValue(config, 'baseTileWidth', this.tileWidth); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#baseTileHeight - * @type {number} - * @since 3.0.0 - */ - this.baseTileHeight = GetFastValue(config, 'baseTileHeight', this.tileHeight); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#widthInPixels - * @type {number} - * @since 3.0.0 - */ - this.widthInPixels = GetFastValue(config, 'widthInPixels', this.width * this.baseTileWidth); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#heightInPixels - * @type {number} - * @since 3.0.0 - */ - this.heightInPixels = GetFastValue(config, 'heightInPixels', this.height * this.baseTileHeight); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#alpha - * @type {float} - * @since 3.0.0 - */ - this.alpha = GetFastValue(config, 'alpha', 1); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#visible - * @type {boolean} - * @since 3.0.0 - */ - this.visible = GetFastValue(config, 'visible', true); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#properties - * @type {object} - * @since 3.0.0 - */ - this.properties = GetFastValue(config, 'properties', {}); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#indexes - * @type {array} - * @since 3.0.0 - */ - this.indexes = GetFastValue(config, 'indexes', []); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#collideIndexes - * @type {array} - * @since 3.0.0 - */ - this.collideIndexes = GetFastValue(config, 'collideIndexes', []); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#callbacks - * @type {array} - * @since 3.0.0 - */ - this.callbacks = GetFastValue(config, 'callbacks', []); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#bodies - * @type {array} - * @since 3.0.0 - */ - this.bodies = GetFastValue(config, 'bodies', []); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#data - * @type {array} - * @since 3.0.0 - */ - this.data = GetFastValue(config, 'data', []); - - /** - * [description] - * - * @name Phaser.Tilemaps.LayerData#tilemapLayer - * @type {Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer} - * @since 3.0.0 - */ - this.tilemapLayer = GetFastValue(config, 'tilemapLayer', null); - } - -}); - -module.exports = LayerData; - - -/***/ }), -/* 76 */ -/***/ (function(module, exports, __webpack_require__) { - /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. @@ -13540,7 +11754,7 @@ module.exports = MapData; /***/ }), -/* 77 */ +/* 66 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -13549,2387 +11763,219 @@ module.exports = MapData; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BlendModes = __webpack_require__(45); -var Circle = __webpack_require__(64); -var CircleContains = __webpack_require__(32); var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var GameObject = __webpack_require__(1); -var Rectangle = __webpack_require__(8); -var RectangleContains = __webpack_require__(33); +var GetFastValue = __webpack_require__(2); /** * @classdesc - * A Zone Game Object. + * A class for representing data about about a layer in a map. Maps are parsed from CSV, Tiled, + * etc. into this format. Tilemap, StaticTilemapLayer and DynamicTilemapLayer have a reference + * to this data and use it to look up and perform operations on tiles. * - * A Zone is a non-rendering rectangular Game Object that has a position and size. - * It has no texture and never displays, but does live on the display list and - * can be moved, scaled and rotated like any other Game Object. - * - * Its primary use is for creating Drop Zones and Input Hit Areas and it has a couple of helper methods - * specifically for this. It is also useful for object overlap checks, or as a base for your own - * non-displaying Game Objects. - - * The default origin is 0.5, the center of the Zone, the same as with Game Objects. - * - * @class Zone - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects + * @class LayerData + * @memberOf Phaser.Tilemaps * @constructor * @since 3.0.0 * - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - [description] - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {number} [width=1] - The width of the Game Object. - * @param {number} [height=1] - The height of the Game Object. + * @param {object} [config] - [description] */ -var Zone = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Depth, - Components.GetBounds, - Components.Origin, - Components.ScaleMode, - Components.Transform, - Components.ScrollFactor, - Components.Visible - ], +var LayerData = new Class({ initialize: - function Zone (scene, x, y, width, height) + function LayerData (config) { - if (width === undefined) { width = 1; } - if (height === undefined) { height = width; } - - GameObject.call(this, scene, 'Zone'); - - this.setPosition(x, y); - - /** - * The native (un-scaled) width of this Game Object. - * - * @name Phaser.GameObjects.Zone#width - * @type {number} - * @since 3.0.0 - */ - this.width = width; - - /** - * The native (un-scaled) height of this Game Object. - * - * @name Phaser.GameObjects.Zone#height - * @type {number} - * @since 3.0.0 - */ - this.height = height; - - /** - * The Blend Mode of the Game Object. - * Although a Zone never renders, it still has a blend mode to allow it to fit seamlessly into - * display lists without causing a batch flush. - * - * @name Phaser.GameObjects.Zone#blendMode - * @type {integer} - * @since 3.0.0 - */ - this.blendMode = BlendModes.NORMAL; - }, - - /** - * The displayed width of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Zone#displayWidth - * @type {number} - * @since 3.0.0 - */ - displayWidth: { - - get: function () - { - return this.scaleX * this.width; - }, - - set: function (value) - { - this.scaleX = value / this.width; - } - - }, - - /** - * The displayed height of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Zone#displayHeight - * @type {number} - * @since 3.0.0 - */ - displayHeight: { - - get: function () - { - return this.scaleY * this.height; - }, - - set: function (value) - { - this.scaleY = value / this.height; - } - - }, - - /** - * Sets the size of this Game Object. - * - * @method Phaser.GameObjects.Zone#setSize - * @since 3.0.0 - * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. - * @param {boolean} [resizeInput=true] - If this Zone has a Rectangle for a hit area this argument will resize the hit area as well. - * - * @return {Phaser.GameObjects.Zone} This Game Object. - */ - setSize: function (width, height, resizeInput) - { - if (resizeInput === undefined) { resizeInput = true; } - - this.width = width; - this.height = height; - - if (resizeInput && this.input && this.input.hitArea instanceof Rectangle) - { - this.input.hitArea.width = width; - this.input.hitArea.height = height; - } - - return this; - }, - - /** - * Sets the display size of this Game Object. - * Calling this will adjust the scale. - * - * @method Phaser.GameObjects.Zone#setDisplaySize - * @since 3.0.0 - * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. - * - * @return {Phaser.GameObjects.Zone} This Game Object. - */ - setDisplaySize: function (width, height) - { - this.displayWidth = width; - this.displayHeight = height; - - return this; - }, - - /** - * Sets this Zone to be a Circular Drop Zone. - * The circle is centered on this Zones `x` and `y` coordinates. - * - * @method Phaser.GameObjects.Zone#setCircleDropZone - * @since 3.0.0 - * - * @param {number} radius - The radius of the Circle that will form the Drop Zone. - * - * @return {Phaser.GameObjects.Zone} This Game Object. - */ - setCircleDropZone: function (radius) - { - return this.setDropZone(new Circle(0, 0, radius), CircleContains); - }, - - /** - * Sets this Zone to be a Rectangle Drop Zone. - * The rectangle is centered on this Zones `x` and `y` coordinates. - * - * @method Phaser.GameObjects.Zone#setRectangleDropZone - * @since 3.0.0 - * - * @param {number} width - The width of the rectangle drop zone. - * @param {number} height - The height of the rectangle drop zone. - * - * @return {Phaser.GameObjects.Zone} This Game Object. - */ - setRectangleDropZone: function (width, height) - { - var x = -(width / 2); - var y = -(height / 2); - - return this.setDropZone(new Rectangle(x, y, width, height), RectangleContains); - }, - - /** - * Allows you to define your own Geometry shape to be used as a Drop Zone. - * - * @method Phaser.GameObjects.Zone#setDropZone - * @since 3.0.0 - * - * @param {object} shape - A Geometry shape instance, such as Phaser.Geom.Ellipse, or your own custom shape. - * @param {function} callback - A function that will return `true` if the given x/y coords it is sent are within the shape. - * - * @return {Phaser.GameObjects.Zone} This Game Object. - */ - setDropZone: function (shape, callback) - { - if (shape === undefined) - { - this.setRectangleDropZone(this.width, this.height); - } - else - if (!this.input) - { - this.setInteractive(shape, callback, true); - } - - return this; - }, - - /** - * A Zone does not render. - * - * @method Phaser.GameObjects.Zone#renderCanvas - * @private - * @since 3.0.0 - */ - renderCanvas: function () - { - }, - - /** - * A Zone does not render. - * - * @method Phaser.GameObjects.Zone#renderWebGL - * @private - * @since 3.0.0 - */ - renderWebGL: function () - { - } - -}); - -module.exports = Zone; - - -/***/ }), -/* 78 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Perimeter - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {number} [description] - */ -var Perimeter = function (rect) -{ - return 2 * (rect.width + rect.height); -}; - -module.exports = Perimeter; - - -/***/ }), -/* 79 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin. - * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter, - * or have a property called `events` that is an instance of it. - * - * @class DataManager - * @memberOf Phaser.Data - * @constructor - * @since 3.0.0 - * - * @param {any} parent - [description] - * @param {any} eventEmitter - [description] - */ -var DataManager = new Class({ - - initialize: - - function DataManager (parent, eventEmitter) - { - /** - * [description] - * - * @name Phaser.Data.DataManager#parent - * @type {any} - * @since 3.0.0 - */ - this.parent = parent; + if (config === undefined) { config = {}; } /** * [description] * - * @name Phaser.Data.DataManager#events - * @type {EventEmitter} - * @since 3.0.0 - */ - this.events = eventEmitter; - - if (!eventEmitter) - { - this.events = (parent.events) ? parent.events : parent; - } - - /** - * [description] - * - * @name Phaser.Data.DataManager#list - * @type {object} - * @default {} - * @since 3.0.0 - */ - this.list = {}; - - /** - * [description] - * - * @name Phaser.Data.DataManager#blockSet - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.blockSet = false; - - /** - * [description] - * - * @name Phaser.Data.DataManager#_frozen - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this._frozen = false; - - this.events.once('destroy', this.destroy, this); - }, - - /** - * Retrieves the value for the given key, or undefined if it doesn't exist. - * - * @method Phaser.Data.DataManager#get - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {any} [description] - */ - get: function (key) - { - return this.list[key]; - }, - - /** - * [description] - * - * @method Phaser.Data.DataManager#getAll - * @since 3.0.0 - * - * @return {object} [description] - */ - getAll: function () - { - var results = {}; - - for (var key in this.list) - { - results[key] = this.list[key]; - } - - return results; - }, - - /** - * [description] - * - * @method Phaser.Data.DataManager#query - * @since 3.0.0 - * - * @param {string} search - [description] - * - * @return {object} [description] - */ - query: function (search) - { - var results = {}; - - for (var key in this.list) - { - if (key.match(search)) - { - results[key] = this.list[key]; - } - } - - return results; - }, - - /** - * [description] - * - * @method Phaser.Data.DataManager#set - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {any} data - [description] - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - set: function (key, data) - { - if (this._frozen) - { - return this; - } - - if (this.events.listenerCount('changedata') > 0) - { - this.blockSet = false; - - var _this = this; - - var resetFunction = function (value) - { - _this.blockSet = true; - _this.list[key] = value; - _this.events.emit('setdata', _this.parent, key, value); - }; - - this.events.emit('changedata', this.parent, key, data, resetFunction); - - // One of the listeners blocked this update from being set, so abort - if (this.blockSet) - { - return this; - } - } - - this.list[key] = data; - - this.events.emit('setdata', this.parent, key, data); - - return this; - }, - - /** - * Passes all data entries to the given callback. Stores the result of the callback. - * - * @method Phaser.Data.DataManager#each - * @since 3.0.0 - * - * @param {function} callback - The function to call. - * @param {object} [scope] - Value to use as `this` when executing callback. - * @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the game object, key, and data. - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - each: function (callback, scope) - { - var args = [ this.parent, null, undefined ]; - - for (var i = 1; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - for (var key in this.list) - { - args[1] = key; - args[2] = this.list[key]; - - callback.apply(scope, args); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Data.DataManager#merge - * @since 3.0.0 - * - * @param {object} data - [description] - * @param {boolean} overwrite - [description] - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - merge: function (data, overwrite) - { - if (overwrite === undefined) { overwrite = true; } - - // Merge data from another component into this one - for (var key in data) - { - if (overwrite || (!overwrite && !this.has(key))) - { - this.list[key] = data; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Data.DataManager#remove - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - remove: function (key) - { - if (!this._frozen && this.has(key)) - { - var data = this.list[key]; - - delete this.list[key]; - - this.events.emit('removedata', this, key, data); - } - - return this; - }, - - /** - * Gets the data associated with the given 'key', deletes it from this Data store, then returns it. - * - * @method Phaser.Data.DataManager#pop - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {any} [description] - */ - pop: function (key) - { - var data = undefined; - - if (!this._frozen && this.has(key)) - { - data = this.list[key]; - - delete this.list[key]; - - this.events.emit('removedata', this, key, data); - } - - return data; - }, - - /** - * [description] - * - * @method Phaser.Data.DataManager#has - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {boolean} [description] - */ - has: function (key) - { - return this.list.hasOwnProperty(key); - }, - - /** - * [description] - * - * @method Phaser.Data.DataManager#setFreeze - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - setFreeze: function (value) - { - this._frozen = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Data.DataManager#reset - * @since 3.0.0 - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - reset: function () - { - for (var key in this.list) - { - delete this.list[key]; - } - - this.blockSet = false; - this._frozen = false; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Data.DataManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.reset(); - - this.events.off('changedata'); - this.events.off('setdata'); - this.events.off('removedata'); - - this.parent = null; - }, - - /** - * Freeze this Data component, so no changes can be written to it. - * - * @name Phaser.Data.DataManager#freeze - * @type {boolean} - * @since 3.0.0 - */ - freeze: { - - get: function () - { - return this._frozen; - }, - - set: function (value) - { - this._frozen = (value) ? true : false; - } - - }, - - /** - * Return the total number of entries in this Data component. - * - * @name Phaser.Data.DataManager#count - * @type {integer} - * @since 3.0.0 - */ - count: { - - get: function () - { - var i = 0; - - for (var key in this.list) - { - if (this.list[key] !== undefined) - { - i++; - } - } - - return i; - } - - } - -}); - -module.exports = DataManager; - - -/***/ }), -/* 80 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Shuffles the contents of the given array using the Fisher-Yates implementation. - * - * The original array is modified directly and returned. - * - * @function Phaser.Utils.Array.Shuffle - * @since 3.0.0 - * - * @param {array} array - The array to shuffle. This array is modified in place. - * - * @return {array} The shuffled array. - */ -var Shuffle = function (array) -{ - for (var i = array.length - 1; i > 0; i--) - { - var j = Math.floor(Math.random() * (i + 1)); - var temp = array[i]; - array[i] = array[j]; - array[j] = temp; - } - - return array; -}; - -module.exports = Shuffle; - - -/***/ }), -/* 81 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GameObject = __webpack_require__(1); -var Sprite = __webpack_require__(37); -var Vector2 = __webpack_require__(6); -var Vector4 = __webpack_require__(120); - -/** - * @classdesc - * A Sprite 3D Game Object. - * - * The Sprite 3D object is an encapsulation of a standard Sprite object, with additional methods to allow - * it to be rendered by a 3D Camera. The Sprite can be positioned anywhere within 3D space. - * - * @class Sprite3D - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The x position of this Game Object. - * @param {number} y - The y position of this Game Object. - * @param {number} z - The z position of this Game Object. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var Sprite3D = new Class({ - - Extends: GameObject, - - initialize: - - function Sprite3D (scene, x, y, z, texture, frame) - { - GameObject.call(this, scene, 'Sprite3D'); - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#gameObject - * @type {Phaser.GameObjects.GameObject} - * @since 3.0.0 - */ - this.gameObject = new Sprite(scene, 0, 0, texture, frame); - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#position - * @type {Phaser.Math.Vector4} - * @since 3.0.0 - */ - this.position = new Vector4(x, y, z); - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#size - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.size = new Vector2(this.gameObject.width, this.gameObject.height); - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#scale - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.scale = new Vector2(1, 1); - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#adjustScaleX - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.adjustScaleX = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#adjustScaleY - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.adjustScaleY = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#_visible - * @type {boolean} - * @default true - * @private - * @since 3.0.0 - */ - this._visible = true; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Sprite3D#project - * @since 3.0.0 - * - * @param {Phaser.Cameras.Sprite3D.Camera} camera - The 3D Camera onto which to project this Sprite. - */ - project: function (camera) - { - var pos = this.position; - - var gameObject = this.gameObject; - - camera.project(pos, gameObject); - - camera.getPointSize(pos, this.size, this.scale); - - if (this.scale.x <= 0 || this.scale.y <= 0) - { - gameObject.setVisible(false); - } - else - { - if (!gameObject.visible) - { - gameObject.setVisible(true); - } - - if (this.adjustScaleX) - { - gameObject.scaleX = this.scale.x; - } - - if (this.adjustScaleY) - { - gameObject.scaleY = this.scale.y; - } - - gameObject.setDepth(gameObject.z * -1); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Sprite3D#setVisible - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {Phaser.GameObjects.Sprite3D} This Sprite3D Object. - */ - setVisible: function (value) - { - this.visible = value; - - return this; - }, - - /** - * The visible state of the Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - * - * @name Phaser.GameObjects.Sprite3D#visible - * @type {boolean} - * @since 3.0.0 - */ - visible: { - - get: function () - { - return this._visible; - }, - - set: function (value) - { - this._visible = value; - this.gameObject.visible = value; - } - - }, - - /** - * The x position of this Game Object. - * - * @name Phaser.GameObjects.Sprite3D#x - * @type {number} - * @since 3.0.0 - */ - x: { - - get: function () - { - return this.position.x; - }, - - set: function (value) - { - this.position.x = value; - } - - }, - - /** - * The y position of this Game Object. - * - * @name Phaser.GameObjects.Sprite3D#y - * @type {number} - * @since 3.0.0 - */ - y: { - - get: function () - { - return this.position.y; - }, - - set: function (value) - { - this.position.y = value; - } - - }, - - /** - * The z position of this Game Object. - * - * @name Phaser.GameObjects.Sprite3D#z - * @type {number} - * @since 3.0.0 - */ - z: { - - get: function () - { - return this.position.z; - }, - - set: function (value) - { - this.position.z = value; - } - - } - -}); - -module.exports = Sprite3D; - - -/***/ }), -/* 82 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var OS = __webpack_require__(67); - -/** - * Determines the browser type and version running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.browser` from within any Scene. - * - * @name Phaser.Device.Browser - * @since 3.0.0 - * - * @type {object} - * @property {boolean} chrome - Set to true if running in Chrome. - * @property {boolean} edge - Set to true if running in Microsoft Edge browser. - * @property {boolean} firefox - Set to true if running in Firefox. - * @property {boolean} ie - Set to true if running in Internet Explorer 11 or less (not Edge). - * @property {boolean} mobileSafari - Set to true if running in Mobile Safari. - * @property {boolean} opera - Set to true if running in Opera. - * @property {boolean} safari - Set to true if running in Safari. - * @property {boolean} silk - Set to true if running in the Silk browser (as used on the Amazon Kindle) - * @property {boolean} trident - Set to true if running a Trident version of Internet Explorer (IE11+) - * @property {number} chromeVersion - If running in Chrome this will contain the major version number. - * @property {number} firefoxVersion - If running in Firefox this will contain the major version number. - * @property {number} ieVersion - If running in Internet Explorer this will contain the major version number. Beyond IE10 you should use Browser.trident and Browser.tridentVersion. - * @property {number} safariVersion - If running in Safari this will contain the major version number. - * @property {number} tridentVersion - If running in Internet Explorer 11 this will contain the major version number. See {@link http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx} - */ -var Browser = { - - chrome: false, - chromeVersion: 0, - edge: false, - firefox: false, - firefoxVersion: 0, - ie: false, - ieVersion: 0, - mobileSafari: false, - opera: false, - safari: false, - safariVersion: 0, - silk: false, - trident: false, - tridentVersion: 0 - -}; - -function init () -{ - var ua = navigator.userAgent; - - if (/Edge\/\d+/.test(ua)) - { - Browser.edge = true; - } - else if ((/Chrome\/(\d+)/).test(ua) && !OS.windowsPhone) - { - Browser.chrome = true; - Browser.chromeVersion = parseInt(RegExp.$1, 10); - } - else if ((/Firefox\D+(\d+)/).test(ua)) - { - Browser.firefox = true; - Browser.firefoxVersion = parseInt(RegExp.$1, 10); - } - else if ((/AppleWebKit/).test(ua) && OS.iOS) - { - Browser.mobileSafari = true; - } - else if ((/MSIE (\d+\.\d+);/).test(ua)) - { - Browser.ie = true; - Browser.ieVersion = parseInt(RegExp.$1, 10); - } - else if ((/Opera/).test(ua)) - { - Browser.opera = true; - } - else if ((/Safari/).test(ua) && !OS.windowsPhone) - { - Browser.safari = true; - } - else if ((/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/).test(ua)) - { - Browser.ie = true; - Browser.trident = true; - Browser.tridentVersion = parseInt(RegExp.$1, 10); - Browser.ieVersion = parseInt(RegExp.$3, 10); - } - - // Silk gets its own if clause because its ua also contains 'Safari' - if ((/Silk/).test(ua)) - { - Browser.silk = true; - } - - return Browser; -} - -module.exports = init(); - - -/***/ }), -/* 83 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - - -module.exports = { - - /** - * Scene state. - * - * @name Phaser.Scenes.PENDING - * @type {integer} - * @since 3.0.0 - */ - PENDING: 0, - - /** - * Scene state. - * - * @name Phaser.Scenes.INIT - * @type {integer} - * @since 3.0.0 - */ - INIT: 1, - - /** - * Scene state. - * - * @name Phaser.Scenes.START - * @type {integer} - * @since 3.0.0 - */ - START: 2, - - /** - * Scene state. - * - * @name Phaser.Scenes.LOADING - * @type {integer} - * @since 3.0.0 - */ - LOADING: 3, - - /** - * Scene state. - * - * @name Phaser.Scenes.CREATING - * @type {integer} - * @since 3.0.0 - */ - CREATING: 4, - - /** - * Scene state. - * - * @name Phaser.Scenes.RUNNING - * @type {integer} - * @since 3.0.0 - */ - RUNNING: 5, - - /** - * Scene state. - * - * @name Phaser.Scenes.PAUSED - * @type {integer} - * @since 3.0.0 - */ - PAUSED: 6, - - /** - * Scene state. - * - * @name Phaser.Scenes.SLEEPING - * @type {integer} - * @since 3.0.0 - */ - SLEEPING: 7, - - /** - * Scene state. - * - * @name Phaser.Scenes.SHUTDOWN - * @type {integer} - * @since 3.0.0 - */ - SHUTDOWN: 8, - - /** - * Scene state. - * - * @name Phaser.Scenes.DESTROYED - * @type {integer} - * @since 3.0.0 - */ - DESTROYED: 9 - -}; - - -/***/ }), -/* 84 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ -var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(14); -var NOOP = __webpack_require__(3); - -/** - * @classdesc - * The sound manager is responsible for playing back audio via Web Audio API or HTML Audio tag as fallback. - * The audio file type and the encoding of those files are extremely important. - * Not all browsers can play all audio formats. - * There is a good guide to what's supported [here](https://developer.mozilla.org/en-US/Apps/Fundamentals/Audio_and_video_delivery/Cross-browser_audio_basics#Audio_Codec_Support). - * - * @class BaseSoundManager - * @extends EventEmitter - * @memberOf Phaser.Sound - * @constructor - * @author Pavle Goloskokovic (http://prunegames.com) - * @since 3.0.0 - * - * @param {Phaser.Game} game - Reference to the current game instance. - */ -var BaseSoundManager = new Class({ - Extends: EventEmitter, - initialize: function BaseSoundManager (game) - { - EventEmitter.call(this); - - /** - * Local reference to game. - * - * @name Phaser.Sound.BaseSoundManager#game - * @type {Phaser.Game} - * @readOnly - * @since 3.0.0 - */ - this.game = game; - - /** - * An array containing all added sounds. - * - * @name Phaser.Sound.BaseSoundManager#sounds - * @type {Phaser.Sound.BaseSound[]} - * @default [] - * @private - * @since 3.0.0 - */ - this.sounds = []; - - /** - * Global mute setting. - * - * @name Phaser.Sound.BaseSoundManager#mute - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.mute = false; - - /** - * Global volume setting. - * - * @name Phaser.Sound.BaseSoundManager#volume - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.volume = 1; - - /** - * Flag indicating if sounds should be paused when game looses focus, - * for instance when user switches to another tab/program/app. - * - * @name Phaser.Sound.BaseSoundManager#pauseOnBlur - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.pauseOnBlur = true; - - game.events.on('blur', function () - { - if (this.pauseOnBlur) - { - this.onBlur(); - } - }, this); - - game.events.on('focus', function () - { - if (this.pauseOnBlur) - { - this.onFocus(); - } - }, this); - - game.events.once('destroy', this.destroy, this); - - /** - * Property that actually holds the value of global playback rate. - * - * @name Phaser.Sound.BaseSoundManager#_rate - * @type {number} - * @private - * @default 1 - * @since 3.0.0 - */ - this._rate = 1; - - /** - * Property that actually holds the value of global detune. - * - * @name Phaser.Sound.BaseSoundManager#_detune - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._detune = 0; - - /** - * Mobile devices require sounds to be triggered from an explicit user action, - * such as a tap, before any sound can be loaded/played on a web page. - * Set to true if the audio system is currently locked awaiting user interaction. - * - * @name Phaser.Sound.BaseSoundManager#locked - * @type {boolean} - * @readOnly - * @since 3.0.0 - */ - this.locked = this.locked || false; - - /** - * Flag used internally for handling when the audio system - * has been unlocked, if there ever was a need for it. - * - * @name Phaser.Sound.BaseSoundManager#unlocked - * @type {boolean} - * @default false - * @private - * @since 3.0.0 - */ - this.unlocked = false; - - if (this.locked) - { - this.unlock(); - } - }, - - /** - * Adds a new sound into the sound manager. - * - * @method Phaser.Sound.BaseSoundManager#add - * @override - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - * - * @return {Phaser.Sound.BaseSound} The new sound instance. - */ - add: NOOP, - - /** - * Audio sprite sound type. - * - * @typedef {Phaser.Sound.BaseSound} AudioSpriteSound - * - * @property {object} spritemap - Local reference to 'spritemap' object form json file generated by audiosprite tool. - */ - /** - * Adds a new audio sprite sound into the sound manager. - * - * @method Phaser.Sound.BaseSoundManager#addAudioSprite - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - * - * @return {AudioSpriteSound} The new audio sprite sound instance. - */ - addAudioSprite: function (key, config) - { - var sound = this.add(key, config); - sound.spritemap = this.game.cache.json.get(key).spritemap; - for (var markerName in sound.spritemap) - { - if (!sound.spritemap.hasOwnProperty(markerName)) - { - continue; - } - var marker = sound.spritemap[markerName]; - sound.addMarker({ - name: markerName, - start: marker.start, - duration: marker.end - marker.start, - config: config - }); - } - return sound; - }, - - /** - * Enables playing sound on the fly without the need to keep a reference to it. - * Sound will auto destroy once its playback ends. - * - * @method Phaser.Sound.BaseSoundManager#play - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {SoundConfig|SoundMarker} [extra] - An optional additional object containing settings to be applied to the sound. It could be either config or marker object. - * - * @return {boolean} Whether the sound started playing successfully. - */ - play: function (key, extra) - { - var sound = this.add(key); - sound.once('ended', sound.destroy, sound); - if (extra) - { - if (extra.name) - { - sound.addMarker(extra); - return sound.play(extra.name); - } - else - { - return sound.play(extra); - } - } - else - { - return sound.play(); - } - }, - - /** - * Enables playing audio sprite sound on the fly without the need to keep a reference to it. - * Sound will auto destroy once its playback ends. - * - * @method Phaser.Sound.BaseSoundManager#playAudioSprite - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {string} spriteName - The name of the sound sprite to play. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - * - * @return {boolean} Whether the audio sprite sound started playing successfully. - */ - playAudioSprite: function (key, spriteName, config) - { - var sound = this.addAudioSprite(key); - sound.once('ended', sound.destroy, sound); - return sound.play(spriteName, config); - }, - - /** - * Removes a sound from the sound manager. - * The removed sound is destroyed before removal. - * - * @method Phaser.Sound.BaseSoundManager#remove - * @since 3.0.0 - * - * @param {Phaser.Sound.BaseSound} sound - The sound object to remove. - * - * @return {boolean} True if the sound was removed successfully, otherwise false. - */ - remove: function (sound) - { - var index = this.sounds.indexOf(sound); - if (index !== -1) - { - sound.destroy(); - this.sounds.splice(index, 1); - return true; - } - return false; - }, - - /** - * Removes all sounds from the sound manager that have an asset key matching the given value. - * The removed sounds are destroyed before removal. - * - * @method Phaser.Sound.BaseSoundManager#removeByKey - * @since 3.0.0 - * - * @param {string} key - The key to match when removing sound objects. - * - * @return {number} The number of matching sound objects that were removed. - */ - removeByKey: function (key) - { - var removed = 0; - for (var i = this.sounds.length - 1; i >= 0; i--) - { - var sound = this.sounds[i]; - if (sound.key === key) - { - sound.destroy(); - this.sounds.splice(i, 1); - removed++; - } - } - return removed; - }, - - /** - * Pauses all the sounds in the game. - * - * @method Phaser.Sound.BaseSoundManager#pauseAll - * @since 3.0.0 - */ - pauseAll: function () - { - this.forEachActiveSound(function (sound) - { - sound.pause(); - }); - - /** - * @event Phaser.Sound.BaseSoundManager#pauseall - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - */ - this.emit('pauseall', this); - }, - - /** - * Resumes all the sounds in the game. - * - * @method Phaser.Sound.BaseSoundManager#resumeAll - * @since 3.0.0 - */ - resumeAll: function () - { - this.forEachActiveSound(function (sound) - { - sound.resume(); - }); - - /** - * @event Phaser.Sound.BaseSoundManager#resumeall - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - */ - this.emit('resumeall', this); - }, - - /** - * Stops all the sounds in the game. - * - * @method Phaser.Sound.BaseSoundManager#stopAll - * @since 3.0.0 - */ - stopAll: function () - { - this.forEachActiveSound(function (sound) - { - sound.stop(); - }); - - /** - * @event Phaser.Sound.BaseSoundManager#stopall - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - */ - this.emit('stopall', this); - }, - - /** - * Method used internally for unlocking audio playback on devices that - * require user interaction before any sound can be played on a web page. - * - * Read more about how this issue is handled here in [this article](https://medium.com/@pgoloskokovic/unlocking-web-audio-the-smarter-way-8858218c0e09). - * - * @method Phaser.Sound.BaseSoundManager#unlock - * @override - * @protected - * @since 3.0.0 - */ - unlock: NOOP, - - /** - * Method used internally for pausing sound manager if - * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.BaseSoundManager#onBlur - * @override - * @protected - * @since 3.0.0 - */ - onBlur: NOOP, - - /** - * Method used internally for resuming sound manager if - * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.BaseSoundManager#onFocus - * @override - * @protected - * @since 3.0.0 - */ - onFocus: NOOP, - - /** - * Update method called on every game step. - * Removes destroyed sounds and updates every active sound in the game. - * - * @method Phaser.Sound.BaseSoundManager#update - * @protected - * @since 3.0.0 - * - * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {number} delta - The delta time elapsed since the last frame. - */ - update: function (time, delta) - { - if (this.unlocked) - { - this.unlocked = false; - this.locked = false; - - /** - * @event Phaser.Sound.BaseSoundManager#unlocked - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - */ - this.emit('unlocked', this); - } - for (var i = this.sounds.length - 1; i >= 0; i--) - { - if (this.sounds[i].pendingRemove) - { - this.sounds.splice(i, 1); - } - } - this.sounds.forEach(function (sound) - { - sound.update(time, delta); - }); - }, - - /** - * Destroys all the sounds in the game and all associated events. - * - * @method Phaser.Sound.BaseSoundManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.removeAllListeners(); - this.forEachActiveSound(function (sound) - { - sound.destroy(); - }); - this.sounds.length = 0; - this.sounds = null; - this.game = null; - }, - - /** - * Method used internally for iterating only over active sounds and skipping sounds that are marked for removal. - * - * @method Phaser.Sound.BaseSoundManager#forEachActiveSound - * @private - * @since 3.0.0 - * - * @param {function} callbackfn - Callback function. (sound: ISound, index: number, array: ISound[]) => void - * @param {object} [scope] - Callback context. - */ - forEachActiveSound: function (callbackfn, scope) - { - var _this = this; - this.sounds.forEach(function (sound, index) - { - if (!sound.pendingRemove) - { - callbackfn.call(scope || _this, sound, index, _this.sounds); - } - }); - }, - - /** - * Global playback rate at which all the sounds will be played. - * Value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed - * and 2.0 doubles the audio's playback speed. - * - * @name Phaser.Sound.BaseSoundManager#rate - * @type {number} - * @default 1 - * @since 3.0.0 - */ - rate: { - - get: function () - { - return this._rate; - }, - - set: function (value) - { - this._rate = value; - - this.forEachActiveSound(function (sound) - { - sound.setRate(); - }); - - /** - * @event Phaser.Sound.BaseSoundManager#rate - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - * @param {number} value - An updated value of Phaser.Sound.BaseSoundManager#rate property. - */ - this.emit('rate', this, value); - } - - }, - - /** - * Global detuning of all sounds in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - * - * @name Phaser.Sound.BaseSoundManager#detune - * @type {number} - * @default 0 - * @since 3.0.0 - */ - detune: { - - get: function () - { - return this._detune; - }, - - set: function (value) - { - this._detune = value; - - this.forEachActiveSound(function (sound) - { - sound.setRate(); - }); - - /** - * @event Phaser.Sound.BaseSoundManager#detune - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - * @param {number} value - An updated value of Phaser.Sound.BaseSoundManager#detune property. - */ - this.emit('detune', this, value); - } - - } - -}); - -module.exports = BaseSoundManager; - - -/***/ }), -/* 85 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ -var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(14); -var Extend = __webpack_require__(23); -var NOOP = __webpack_require__(3); - -/** - * @classdesc - * Class containing all the shared state and behaviour of a sound object, independent of the implementation. - * - * @class BaseSound - * @extends EventEmitter - * @memberOf Phaser.Sound - * @constructor - * @author Pavle Goloskokovic (http://prunegames.com) - * @since 3.0.0 - * - * @param {Phaser.Sound.BaseSoundManager} manager - Reference to the current sound manager instance. - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - */ -var BaseSound = new Class({ - Extends: EventEmitter, - initialize: function BaseSound (manager, key, config) - { - EventEmitter.call(this); - - /** - * Local reference to the sound manager. - * - * @name Phaser.Sound.BaseSound#manager - * @type {Phaser.Sound.BaseSoundManager} - * @private - * @since 3.0.0 - */ - this.manager = manager; - - /** - * Asset key for the sound. - * - * @name Phaser.Sound.BaseSound#key + * @name Phaser.Tilemaps.LayerData#name * @type {string} - * @readOnly * @since 3.0.0 */ - this.key = key; + this.name = GetFastValue(config, 'name', 'layer'); /** - * Flag indicating if sound is currently playing. + * [description] * - * @name Phaser.Sound.BaseSound#isPlaying + * @name Phaser.Tilemaps.LayerData#x + * @type {number} + * @since 3.0.0 + */ + this.x = GetFastValue(config, 'x', 0); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#y + * @type {number} + * @since 3.0.0 + */ + this.y = GetFastValue(config, 'y', 0); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#width + * @type {number} + * @since 3.0.0 + */ + this.width = GetFastValue(config, 'width', 0); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#height + * @type {number} + * @since 3.0.0 + */ + this.height = GetFastValue(config, 'height', 0); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#tileWidth + * @type {number} + * @since 3.0.0 + */ + this.tileWidth = GetFastValue(config, 'tileWidth', 0); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#tileHeight + * @type {number} + * @since 3.0.0 + */ + this.tileHeight = GetFastValue(config, 'tileHeight', 0); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#baseTileWidth + * @type {number} + * @since 3.0.0 + */ + this.baseTileWidth = GetFastValue(config, 'baseTileWidth', this.tileWidth); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#baseTileHeight + * @type {number} + * @since 3.0.0 + */ + this.baseTileHeight = GetFastValue(config, 'baseTileHeight', this.tileHeight); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#widthInPixels + * @type {number} + * @since 3.0.0 + */ + this.widthInPixels = GetFastValue(config, 'widthInPixels', this.width * this.baseTileWidth); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#heightInPixels + * @type {number} + * @since 3.0.0 + */ + this.heightInPixels = GetFastValue(config, 'heightInPixels', this.height * this.baseTileHeight); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#alpha + * @type {float} + * @since 3.0.0 + */ + this.alpha = GetFastValue(config, 'alpha', 1); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#visible * @type {boolean} - * @default false - * @readOnly * @since 3.0.0 */ - this.isPlaying = false; + this.visible = GetFastValue(config, 'visible', true); /** - * Flag indicating if sound is currently paused. + * [description] * - * @name Phaser.Sound.BaseSound#isPaused - * @type {boolean} - * @default false - * @readOnly - * @since 3.0.0 - */ - this.isPaused = false; - - /** - * A property that holds the value of sound's actual playback rate, - * after its rate and detune values has been combined with global - * rate and detune values. - * - * @name Phaser.Sound.BaseSound#totalRate - * @type {number} - * @default 1 - * @readOnly - * @since 3.0.0 - */ - this.totalRate = 1; - - /** - * A value representing the duration, in seconds. - * It could be total sound duration or a marker duration. - * - * @name Phaser.Sound.BaseSound#duration - * @type {number} - * @readOnly - * @since 3.0.0 - */ - this.duration = this.duration || 0; - - /** - * The total duration of the sound in seconds. - * - * @name Phaser.Sound.BaseSound#totalDuration - * @type {number} - * @readOnly - * @since 3.0.0 - */ - this.totalDuration = this.totalDuration || 0; - - /** - * A config object used to store default sound settings' values. - * Default values will be set by properties' setters. - * - * @name Phaser.Sound.BaseSound#config - * @type {SoundConfig} - * @private - * @since 3.0.0 - */ - this.config = { - /** - * Initializing delay config setting - */ - delay: 0 - }; - - /** - * Reference to the currently used config. - * It could be default config or marker config. - * - * @name Phaser.Sound.BaseSound#currentConfig - * @type {SoundConfig} - * @private - * @since 3.0.0 - */ - this.currentConfig = this.config; - - /** - * Boolean indicating whether the sound is muted or not. - * Gets or sets the muted state of this sound. - * - * @name Phaser.Sound.BaseSound#mute - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.mute = false; - - /** - * Gets or sets the volume of this sound, - * a value between 0 (silence) and 1 (full volume). - * - * @name Phaser.Sound.BaseSound#volume - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.volume = 1; - - /** - * Defines the speed at which the audio asset will be played. - * Value of 1.0 plays the audio at full speed, 0.5 plays the audio - * at half speed and 2.0 doubles the audio's playback speed. - * This value gets multiplied by global rate to have the final playback speed. - * - * @name Phaser.Sound.BaseSound#rate - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.rate = 1; - - /** - * Represents detuning of sound in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - * - * @name Phaser.Sound.BaseSound#detune - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.detune = 0; - - /** - * Property representing the position of playback for this sound, in seconds. - * Setting it to a specific value moves current playback to that position. - * The value given is clamped to the range 0 to current marker duration. - * Setting seek of a stopped sound has no effect. - * - * @name Phaser.Sound.BaseSound#seek - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.seek = 0; - - /** - * Flag indicating whether or not the sound or current sound marker will loop. - * - * @name Phaser.Sound.BaseSound#loop - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.loop = false; - this.config = Extend(this.config, config); - - /** - * Object containing markers definitions (Object.). - * - * @name Phaser.Sound.BaseSound#markers + * @name Phaser.Tilemaps.LayerData#properties * @type {object} - * @default {} - * @readOnly * @since 3.0.0 */ - this.markers = {}; + this.properties = GetFastValue(config, 'properties', {}); /** - * Currently playing marker. - * 'null' if whole sound is playing. + * [description] * - * @name Phaser.Sound.BaseSound#currentMarker - * @type {SoundMarker} - * @default null - * @readOnly + * @name Phaser.Tilemaps.LayerData#indexes + * @type {array} * @since 3.0.0 */ - this.currentMarker = null; + this.indexes = GetFastValue(config, 'indexes', []); /** - * Flag indicating if destroy method was called on this sound. + * [description] * - * @name Phaser.Sound.BaseSound#pendingRemove - * @type {boolean} - * @private - * @default false + * @name Phaser.Tilemaps.LayerData#collideIndexes + * @type {array} * @since 3.0.0 */ - this.pendingRemove = false; - }, - - /** - * Adds a marker into the current sound. A marker is represented by name, start time, duration, and optionally config object. - * This allows you to bundle multiple sounds together into a single audio file and use markers to jump between them for playback. - * - * @method Phaser.Sound.BaseSound#addMarker - * @since 3.0.0 - * - * @param {SoundMarker} marker - Marker object. - * - * @return {boolean} Whether the marker was added successfully. - */ - addMarker: function (marker) - { - if (!marker || !marker.name || typeof marker.name !== 'string') - { - return false; - } - if (this.markers[marker.name]) - { - // eslint-disable-next-line no-console - console.error('addMarker - Marker with name \'' + marker.name + '\' already exists for sound \'' + this.key + '\'!'); - return false; - } - marker = Extend(true, { - name: '', - start: 0, - duration: this.totalDuration - (marker.start || 0), - config: { - mute: false, - volume: 1, - rate: 1, - detune: 0, - seek: 0, - loop: false, - delay: 0 - } - }, marker); - this.markers[marker.name] = marker; - return true; - }, - - /** - * Updates previously added marker. - * - * @method Phaser.Sound.BaseSound#updateMarker - * @since 3.0.0 - * - * @param {SoundMarker} marker - Marker object with updated values. - * - * @return {boolean} Whether the marker was updated successfully. - */ - updateMarker: function (marker) - { - if (!marker || !marker.name || typeof marker.name !== 'string') - { - return false; - } - if (!this.markers[marker.name]) - { - // eslint-disable-next-line no-console - console.error('updateMarker - Marker with name \'' + marker.name + '\' does not exist for sound \'' + this.key + '\'!'); - return false; - } - this.markers[marker.name] = Extend(true, this.markers[marker.name], marker); - return true; - }, - - /** - * Removes a marker from the sound. - * - * @method Phaser.Sound.BaseSound#removeMarker - * @since 3.0.0 - * - * @param {string} markerName - The name of the marker to remove. - * - * @return {SoundMarker|null} Removed marker object or 'null' if there was no marker with provided name. - */ - removeMarker: function (markerName) - { - var marker = this.markers[markerName]; - if (!marker) - { - return null; - } - this.markers[markerName] = null; - return marker; - }, - - /** - * Play this sound, or a marked section of it. - * It always plays the sound from the start. If you want to start playback from a specific time - * you can set 'seek' setting of the config object, provided to this call, to that value. - * - * @method Phaser.Sound.BaseSound#play - * @since 3.0.0 - * - * @param {string} [markerName=''] - If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. - * @param {SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. - * - * @return {boolean} Whether the sound started playing successfully. - */ - play: function (markerName, config) - { - if (markerName === void 0) { markerName = ''; } - if (typeof markerName === 'object') - { - config = markerName; - markerName = ''; - } - if (typeof markerName !== 'string') - { - // eslint-disable-next-line no-console - console.error('Sound marker name has to be a string!'); - return false; - } - if (!markerName) - { - this.currentMarker = null; - this.currentConfig = this.config; - this.duration = this.totalDuration; - } - else - { - if (!this.markers[markerName]) - { - // eslint-disable-next-line no-console - console.error('No marker with name \'' + markerName + '\' found for sound \'' + this.key + '\'!'); - return false; - } - this.currentMarker = this.markers[markerName]; - this.currentConfig = this.currentMarker.config; - this.duration = this.currentMarker.duration; - } - this.resetConfig(); - this.currentConfig = Extend(this.currentConfig, config); - this.isPlaying = true; - this.isPaused = false; - return true; - }, - - /** - * Pauses the sound. - * - * @method Phaser.Sound.BaseSound#pause - * @since 3.0.0 - * - * @return {boolean} Whether the sound was paused successfully. - */ - pause: function () - { - if (this.isPaused || !this.isPlaying) - { - return false; - } - this.isPlaying = false; - this.isPaused = true; - return true; - }, - - /** - * Resumes the sound. - * - * @method Phaser.Sound.BaseSound#resume - * @since 3.0.0 - * - * @return {boolean} Whether the sound was resumed successfully. - */ - resume: function () - { - if (!this.isPaused || this.isPlaying) - { - return false; - } - this.isPlaying = true; - this.isPaused = false; - return true; - }, - - /** - * Stop playing this sound. - * - * @method Phaser.Sound.BaseSound#stop - * @since 3.0.0 - * - * @return {boolean} Whether the sound was stopped successfully. - */ - stop: function () - { - if (!this.isPaused && !this.isPlaying) - { - return false; - } - this.isPlaying = false; - this.isPaused = false; - this.resetConfig(); - return true; - }, - - /** - * Method used internally for applying config values to some of the sound properties. - * - * @method Phaser.Sound.BaseSound#applyConfig - * @protected - * @since 3.0.0 - */ - applyConfig: function () - { - this.mute = this.currentConfig.mute; - this.volume = this.currentConfig.volume; - this.rate = this.currentConfig.rate; - this.detune = this.currentConfig.detune; - this.loop = this.currentConfig.loop; - }, - - /** - * Method used internally for resetting values of some of the config properties. - * - * @method Phaser.Sound.BaseSound#resetConfig - * @protected - * @since 3.0.0 - */ - resetConfig: function () - { - this.currentConfig.seek = 0; - this.currentConfig.delay = 0; - }, - - /** - * Update method called automatically by sound manager on every game step. - * - * @method Phaser.Sound.BaseSound#update - * @override - * @protected - * @since 3.0.0 - * - * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {number} delta - The delta time elapsed since the last frame. - */ - update: NOOP, - - /** - * Destroys this sound and all associated events and marks it for removal from the sound manager. - * - * @method Phaser.Sound.BaseSound#destroy - * @since 3.0.0 - */ - destroy: function () - { - if (this.pendingRemove) - { - return; - } - this.pendingRemove = true; - this.manager = null; - this.key = ''; - this.removeAllListeners(); - this.isPlaying = false; - this.isPaused = false; - this.config = null; - this.currentConfig = null; - this.markers = null; - this.currentMarker = null; - }, - - /** - * Method used internally to calculate total playback rate of the sound. - * - * @method Phaser.Sound.BaseSound#setRate - * @protected - * @since 3.0.0 - */ - setRate: function () - { - var cent = 1.0005777895065548; // Math.pow(2, 1/1200); - var totalDetune = this.currentConfig.detune + this.manager.detune; - var detuneRate = Math.pow(cent, totalDetune); - this.totalRate = this.currentConfig.rate * this.manager.rate * detuneRate; - } -}); -Object.defineProperty(BaseSound.prototype, 'rate', { - get: function () - { - return this.currentConfig.rate; - }, - set: function (value) - { - this.currentConfig.rate = value; - this.setRate(); + this.collideIndexes = GetFastValue(config, 'collideIndexes', []); /** - * @event Phaser.Sound.BaseSound#rate - * @param {Phaser.Sound.BaseSound} sound - Reference to the sound that emitted event. - * @param {number} value - An updated value of Phaser.Sound.BaseSound#rate property. + * [description] + * + * @name Phaser.Tilemaps.LayerData#callbacks + * @type {array} + * @since 3.0.0 */ - this.emit('rate', this, value); - } -}); -Object.defineProperty(BaseSound.prototype, 'detune', { - get: function () - { - return this.currentConfig.detune; - }, - set: function (value) - { - this.currentConfig.detune = value; - this.setRate(); + this.callbacks = GetFastValue(config, 'callbacks', []); /** - * @event Phaser.Sound.BaseSound#detune - * @param {Phaser.Sound.BaseSound} sound - Reference to the sound that emitted event. - * @param {number} value - An updated value of Phaser.Sound.BaseSound#detune property. + * [description] + * + * @name Phaser.Tilemaps.LayerData#bodies + * @type {array} + * @since 3.0.0 */ - this.emit('detune', this, value); + this.bodies = GetFastValue(config, 'bodies', []); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#data + * @type {array} + * @since 3.0.0 + */ + this.data = GetFastValue(config, 'data', []); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#tilemapLayer + * @type {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} + * @since 3.0.0 + */ + this.tilemapLayer = GetFastValue(config, 'tilemapLayer', null); } + }); -module.exports = BaseSound; + +module.exports = LayerData; /***/ }), -/* 86 */ -/***/ (function(module, exports, __webpack_require__) { +/* 67 */ +/***/ (function(module, exports) { /** * @author Richard Davey @@ -15937,913 +11983,28 @@ module.exports = BaseSound; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); - /** - * @classdesc - * [description] + * Checks if the given tile coordinates are within the bounds of the layer. * - * @class List - * @memberOf Phaser.Structs - * @constructor + * @function Phaser.Tilemaps.Components.IsInLayerBounds * @since 3.0.0 * - * @param {any} parent - [description] + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {boolean} */ -var List = new Class({ +var IsInLayerBounds = function (tileX, tileY, layer) +{ + return (tileX >= 0 && tileX < layer.width && tileY >= 0 && tileY < layer.height); +}; - initialize: - - function List (parent) - { - /** - * The parent of this list. - * - * @name Phaser.Structs.List#parent - * @type {any} - * @since 3.0.0 - */ - this.parent = parent; - - /** - * The objects that belong to this collection. - * - * @name Phaser.Structs.List#list - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.list = []; - - /** - * [description] - * - * @name Phaser.Structs.List#position - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.position = 0; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#add - * @since 3.0.0 - * - * @param {object} child - [description] - * - * @return {object} [description] - */ - add: function (child) - { - // Is child already in this display list? - - if (this.getIndex(child) === -1) - { - this.list.push(child); - } - - return child; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#addAt - * @since 3.0.0 - * - * @param {object} child - [description] - * @param {integer} index - [description] - * - * @return {object} [description] - */ - addAt: function (child, index) - { - if (index === undefined) { index = 0; } - - if (this.list.length === 0) - { - return this.add(child); - } - - if (index >= 0 && index <= this.list.length) - { - if (this.getIndex(child) === -1) - { - this.list.splice(index, 0, child); - } - } - - return child; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#addMultiple - * @since 3.0.0 - * - * @param {array} children - [description] - * - * @return {array} [description] - */ - addMultiple: function (children) - { - if (Array.isArray(children)) - { - for (var i = 0; i < children.length; i++) - { - this.add(children[i]); - } - } - - return children; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#getAt - * @since 3.0.0 - * - * @param {integer} index - [description] - * - * @return {object} [description] - */ - getAt: function (index) - { - return this.list[index]; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#getIndex - * @since 3.0.0 - * - * @param {object} child - [description] - * - * @return {integer} [description] - */ - getIndex: function (child) - { - // Return -1 if given child isn't a child of this display list - return this.list.indexOf(child); - }, - - /** - * Given an array of objects, sort the array and return it, - * so that the objects are in index order with the lowest at the bottom. - * - * @method Phaser.Structs.List#sort - * @since 3.0.0 - * - * @param {array} children - [description] - * - * @return {array} [description] - */ - sort: function (children) - { - if (children === undefined) { children = this.list; } - - return children.sort(this.sortIndexHandler.bind(this)); - }, - - /** - * [description] - * - * @method Phaser.Structs.List#sortIndexHandler - * @since 3.0.0 - * - * @param {object} childA - [description] - * @param {object} childB - [description] - * - * @return {integer} [description] - */ - sortIndexHandler: function (childA, childB) - { - // The lower the index, the lower down the display list they are - var indexA = this.getIndex(childA); - var indexB = this.getIndex(childB); - - if (indexA < indexB) - { - return -1; - } - else if (indexA > indexB) - { - return 1; - } - - // Technically this shouldn't happen, but if the GO wasn't part of this display list then it'll - // have an index of -1, so in some cases it can - return 0; - }, - - /** - * Gets the first item from the set based on the property strictly equaling the value given. - * Returns null if not found. - * - * @method Phaser.Structs.List#getByKey - * @since 3.0.0 - * - * @param {string} property - The property to check against the value. - * @param {any} value - The value to check if the property strictly equals. - * - * @return {any} The item that was found, or null if nothing matched. - */ - getByKey: function (property, value) - { - for (var i = 0; i < this.list.length; i++) - { - if (this.list[i][property] === value) - { - return this.list[i]; - } - } - - return null; - }, - - /** - * Searches the Group for the first instance of a child with the `name` - * property matching the given argument. Should more than one child have - * the same name only the first instance is returned. - * - * @method Phaser.Structs.List#getByName - * @since 3.0.0 - * - * @param {string} name - The name to search for. - * - * @return {any} The first child with a matching name, or null if none were found. - */ - getByName: function (name) - { - return this.getByKey('name', name); - }, - - /** - * Returns a random child from the group. - * - * @method Phaser.Structs.List#getRandom - * @since 3.0.0 - * - * @param {integer} [startIndex=0] - Offset from the front of the group (lowest child). - * @param {integer} [length=(to top)] - Restriction on the number of values you want to randomly select from. - * - * @return {any} A random child of this Group. - */ - getRandom: function (startIndex, length) - { - if (startIndex === undefined) { startIndex = 0; } - if (length === undefined) { length = this.list.length; } - - if (length === 0 || length > this.list.length) - { - return null; - } - - var randomIndex = startIndex + Math.floor(Math.random() * length); - - return this.list[randomIndex]; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#getFirst - * @since 3.0.0 - * - * @param {[type]} property - [description] - * @param {[type]} value - [description] - * @param {[type]} startIndex - [description] - * @param {[type]} endIndex - [description] - * - * @return {[type]} [description] - */ - getFirst: function (property, value, startIndex, endIndex) - { - if (startIndex === undefined) { startIndex = 0; } - if (endIndex === undefined) { endIndex = this.list.length; } - - for (var i = startIndex; i < endIndex; i++) - { - var child = this.list[i]; - - if (child[property] === value) - { - return child; - } - } - - return null; - }, - - /** - * Returns all children in this List. - * - * You can optionally specify a matching criteria using the `property` and `value` arguments. - * - * For example: `getAll('visible', true)` would return only children that have their visible property set. - * - * Optionally you can specify a start and end index. For example if this List had 100 children, - * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only - * the first 50 children in the List. - * - * @method Phaser.Structs.List#getAll - * @since 3.0.0 - * - * @param {string} [property] - An optional property to test against the value argument. - * @param {any} [value] - If property is set then Child.property must strictly equal this value to be included in the results. - * @param {integer} [startIndex=0] - The first child index to start the search from. - * @param {integer} [endIndex] - The last child index to search up until. - * - * @return {array} [description] - */ - getAll: function (property, value, startIndex, endIndex) - { - if (startIndex === undefined) { startIndex = 0; } - if (endIndex === undefined) { endIndex = this.list.length; } - - var output = []; - - for (var i = startIndex; i < endIndex; i++) - { - var child = this.list[i]; - - if (property) - { - if (child[property] === value) - { - output.push(child); - } - } - else - { - output.push(child); - } - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#count - * @since 3.0.0 - * - * @param {string} property - [description] - * @param {any} value - [description] - * - * @return {integer} [description] - */ - count: function (property, value) - { - var total = 0; - - for (var i = 0; i < this.list.length; i++) - { - var child = this.list[i]; - - if (child[property] === value) - { - total++; - } - } - - return total; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#swap - * @since 3.0.0 - * - * @param {object} child1 - [description] - * @param {object} child2 - [description] - */ - swap: function (child1, child2) - { - if (child1 === child2) - { - return; - } - - var index1 = this.getIndex(child1); - var index2 = this.getIndex(child2); - - if (index1 < 0 || index2 < 0) - { - throw new Error('List.swap: Supplied objects must be children of the same list'); - } - - this.list[index1] = child2; - this.list[index2] = child1; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#moveTo - * @since 3.0.0 - * - * @param {object} child - [description] - * @param {integer} index - [description] - * - * @return {object} [description] - */ - moveTo: function (child, index) - { - var currentIndex = this.getIndex(child); - - if (currentIndex === -1 || index < 0 || index >= this.list.length) - { - throw new Error('List.moveTo: The supplied index is out of bounds'); - } - - // Remove - this.list.splice(currentIndex, 1); - - // Add in new location - this.list.splice(index, 0, child); - - return child; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#remove - * @since 3.0.0 - * - * @param {object} child - [description] - * - * @return {object} [description] - */ - remove: function (child) - { - var index = this.list.indexOf(child); - - if (index !== -1) - { - this.list.splice(index, 1); - } - - return child; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#removeAt - * @since 3.0.0 - * - * @param {integer} index - [description] - * - * @return {object} [description] - */ - removeAt: function (index) - { - var child = this.list[index]; - - if (child) - { - this.children.splice(index, 1); - } - - return child; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#removeBetween - * @since 3.0.0 - * - * @param {integer} beginIndex - [description] - * @param {integer} endIndex - [description] - * - * @return {array} [description] - */ - removeBetween: function (beginIndex, endIndex) - { - if (beginIndex === undefined) { beginIndex = 0; } - if (endIndex === undefined) { endIndex = this.list.length; } - - var range = endIndex - beginIndex; - - if (range > 0 && range <= endIndex) - { - var removed = this.list.splice(beginIndex, range); - - return removed; - } - else if (range === 0 && this.list.length === 0) - { - return []; - } - else - { - throw new Error('List.removeBetween: Range Error, numeric values are outside the acceptable range'); - } - }, - - /** - * Removes all the items. - * - * @method Phaser.Structs.List#removeAll - * @since 3.0.0 - * - * @return {Phaser.Structs.List} This List object. - */ - removeAll: function () - { - var i = this.list.length; - - while (i--) - { - this.remove(this.list[i]); - } - - return this; - }, - - /** - * Brings the given child to the top of this List. - * - * @method Phaser.Structs.List#bringToTop - * @since 3.0.0 - * - * @param {object} child - [description] - * - * @return {object} [description] - */ - bringToTop: function (child) - { - if (this.getIndex(child) < this.list.length) - { - this.remove(child); - this.add(child); - } - - return child; - }, - - /** - * Sends the given child to the bottom of this List. - * - * @method Phaser.Structs.List#sendToBack - * @since 3.0.0 - * - * @param {object} child - [description] - * - * @return {object} [description] - */ - sendToBack: function (child) - { - if (this.getIndex(child) > 0) - { - this.remove(child); - this.addAt(child, 0); - } - - return child; - }, - - /** - * Moves the given child up one place in this group unless it's already at the top. - * - * @method Phaser.Structs.List#moveUp - * @since 3.0.0 - * - * @param {object} child - [description] - * - * @return {object} [description] - */ - moveUp: function (child) - { - var a = this.getIndex(child); - - if (a !== -1 && a < this.list.length - 1) - { - var b = this.getAt(a + 1); - - if (b) - { - this.swap(child, b); - } - } - - return child; - }, - - /** - * Moves the given child down one place in this group unless it's already at the bottom. - * - * @method Phaser.Structs.List#moveDown - * @since 3.0.0 - * - * @param {object} child - [description] - * - * @return {object} [description] - */ - moveDown: function (child) - { - var a = this.getIndex(child); - - if (a > 0) - { - var b = this.getAt(a - 1); - - if (b) - { - this.swap(child, b); - } - } - - return child; - }, - - /** - * Reverses the order of all children in this List. - * - * @method Phaser.Structs.List#reverse - * @since 3.0.0 - * - * @return {Phaser.Structs.List} This List object. - */ - reverse: function () - { - this.list.reverse(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#shuffle - * @since 3.0.0 - * - * @return {Phaser.Structs.List} This List object. - */ - shuffle: function () - { - for (var i = this.list.length - 1; i > 0; i--) - { - var j = Math.floor(Math.random() * (i + 1)); - var temp = this.list[i]; - this.list[i] = this.list[j]; - this.list[j] = temp; - } - - return this; - }, - - /** - * Replaces a child of this List with the given newChild. The newChild cannot be a member of this List. - * - * @method Phaser.Structs.List#replace - * @since 3.0.0 - * - * @param {object} oldChild - The child in this List that will be replaced. - * @param {object} newChild - The child to be inserted into this List. - * - * @return {object} Returns the oldChild that was replaced within this group. - */ - replace: function (oldChild, newChild) - { - var index = this.getIndex(oldChild); - - if (index !== -1) - { - this.remove(oldChild); - - this.addAt(newChild, index); - - return oldChild; - } - }, - - /** - * [description] - * - * @method Phaser.Structs.List#exists - * @since 3.0.0 - * - * @param {object} child - [description] - * - * @return {boolean} True if the item is found in the list, otherwise false. - */ - exists: function (child) - { - return (this.list.indexOf(child) > -1); - }, - - /** - * Sets the property `key` to the given value on all members of this List. - * - * @method Phaser.Structs.List#setAll - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {any} value - [description] - */ - setAll: function (key, value) - { - for (var i = 0; i < this.list.length; i++) - { - if (this.list[i]) - { - this.list[i][key] = value; - } - } - }, - - /** - * Passes all children to the given callback. - * - * @method Phaser.Structs.List#each - * @since 3.0.0 - * - * @param {function} callback - The function to call. - * @param {object} [thisArg] - Value to use as `this` when executing callback. - * @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the child. - */ - each: function (callback, thisArg) - { - var args = [ null ]; - - for (var i = 1; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - for (i = 0; i < this.list.length; i++) - { - args[0] = this.list[i]; - callback.apply(thisArg, args); - } - }, - - /** - * [description] - * - * @method Phaser.Structs.List#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this.removeAll(); - }, - - /** - * [description] - * - * @method Phaser.Structs.List#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.removeAll(); - - this.list = []; - - this.parent = null; - }, - - /** - * [description] - * - * @name Phaser.Structs.List#length - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - length: { - - get: function () - { - return this.list.length; - } - - }, - - /** - * [description] - * - * @name Phaser.Structs.List#first - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - first: { - - get: function () - { - this.position = 0; - - if (this.list.length > 0) - { - return this.list[0]; - } - else - { - return null; - } - } - - }, - - /** - * [description] - * - * @name Phaser.Structs.List#last - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - last: { - - get: function () - { - if (this.list.length > 0) - { - this.position = this.list.length - 1; - - return this.list[this.position]; - } - else - { - return null; - } - } - - }, - - /** - * [description] - * - * @name Phaser.Structs.List#next - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - next: { - - get: function () - { - if (this.position < this.list.length) - { - this.position++; - - return this.list[this.position]; - } - else - { - return null; - } - } - - }, - - /** - * [description] - * - * @name Phaser.Structs.List#previous - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - previous: { - - get: function () - { - if (this.position > 0) - { - this.position--; - - return this.list[this.position]; - } - else - { - return null; - } - } - - } - -}); - -module.exports = List; +module.exports = IsInLayerBounds; /***/ }), -/* 87 */ +/* 68 */ /***/ (function(module, exports) { /** @@ -17015,243 +12176,7 @@ module.exports = TWEEN_CONST; /***/ }), -/* 88 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var GameObject = __webpack_require__(1); -var MeshRender = __webpack_require__(657); - -/** - * @classdesc - * A Mesh Game Object. - * - * @class Mesh - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @webglOnly - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * @extends Phaser.GameObjects.Components.ScrollFactor - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {array} vertices - An array containing the vertices data for this Mesh. - * @param {array} uv - An array containing the uv data for this Mesh. - * @param {array} colors - An array containing the color data for this Mesh. - * @param {array} alphas - An array containing the alpha data for this Mesh. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var Mesh = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.Size, - Components.Texture, - Components.Transform, - Components.Visible, - Components.ScrollFactor, - MeshRender - ], - - initialize: - - function Mesh (scene, x, y, vertices, uv, colors, alphas, texture, frame) - { - GameObject.call(this, scene, 'Mesh'); - - this.setTexture(texture, frame); - this.setPosition(x, y); - this.setSizeToFrame(); - this.setOrigin(); - this.initPipeline('TextureTintPipeline'); - - if (vertices.length !== uv.length) - { - throw new Error('Mesh Vertex count must match UV count'); - } - - var verticesUB = (vertices.length / 2) | 0; - - if (colors.length > 0 && colors.length < verticesUB) - { - throw new Error('Mesh Color count must match Vertex count'); - } - - if (alphas.length > 0 && alphas.length < verticesUB) - { - throw new Error('Mesh Alpha count must match Vertex count'); - } - - var i; - - if (colors.length === 0) - { - for (i = 0; i < verticesUB; ++i) - { - colors[i] = 0xFFFFFF; - } - } - - if (alphas.length === 0) - { - for (i = 0; i < verticesUB; ++i) - { - alphas[i] = 1.0; - } - } - - /** - * [description] - * - * @name Phaser.GameObjects.Mesh#vertices - * @type {Float32Array} - * @since 3.0.0 - */ - this.vertices = new Float32Array(vertices); - - /** - * [description] - * - * @name Phaser.GameObjects.Mesh#uv - * @type {Float32Array} - * @since 3.0.0 - */ - this.uv = new Float32Array(uv); - - /** - * [description] - * - * @name Phaser.GameObjects.Mesh#colors - * @type {Uint32Array} - * @since 3.0.0 - */ - this.colors = new Uint32Array(colors); - - /** - * [description] - * - * @name Phaser.GameObjects.Mesh#alphas - * @type {Float32Array} - * @since 3.0.0 - */ - this.alphas = new Float32Array(alphas); - } - -}); - -module.exports = Mesh; - - -/***/ }), -/* 89 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -// This is based off an explanation and expanded math presented by Paul Bourke: -// See http:'local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/ - -/** - * [description] - * - * @function Phaser.Geom.Intersects.LineToLine - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line1 - [description] - * @param {Phaser.Geom.Line} line2 - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {boolean} [description] - */ -var LineToLine = function (line1, line2, out) -{ - if (out === undefined) { out = new Point(); } - - var x1 = line1.x1; - var y1 = line1.y1; - var x2 = line1.x2; - var y2 = line1.y2; - - var x3 = line2.x1; - var y3 = line2.y1; - var x4 = line2.x2; - var y4 = line2.y2; - - var numA = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3); - var numB = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3); - var deNom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); - - // Make sure there is not a division by zero - this also indicates that the lines are parallel. - // If numA and numB were both equal to zero the lines would be on top of each other (coincidental). - // This check is not done because it is not necessary for this implementation (the parallel check accounts for this). - - if (deNom === 0) - { - return false; - } - - // Calculate the intermediate fractional point that the lines potentially intersect. - - var uA = numA / deNom; - var uB = numB / deNom; - - // The fractional point will be between 0 and 1 inclusive if the lines intersect. - // If the fractional calculation is larger than 1 or smaller than 0 the lines would need to be longer to intersect. - - if (uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1) - { - out.x = x1 + (uA * (x2 - x1)); - out.y = y1 + (uA * (y2 - y1)); - - return true; - } - - return false; -}; - -module.exports = LineToLine; - - -/***/ }), -/* 90 */ +/* 69 */ /***/ (function(module, exports) { /** @@ -17261,60 +12186,129 @@ module.exports = LineToLine; */ /** - * Creates an XHRSettings Object with default values. + * [description] * - * @function Phaser.Loader.XHRSettings + * @function Phaser.Tweens.Builders.GetBoolean * @since 3.0.0 * - * @param {string} [responseType] - The responseType, such as 'text'. - * @param {boolean} [async=true] - Should the XHR request use async or not? - * @param {string} [user] - Optional username for the XHR request. - * @param {string} [password] - Optional password for the XHR request. - * @param {integer} [timeout=0] - Optional XHR timeout value. + * @param {object} source - [description] + * @param {string} key - [description] + * @param {*} defaultValue - [description] * - * @return {Phaser.Loader.XHRSettings} The XHRSettings object as used by the Loader. + * @return {*} [description] */ -var XHRSettings = function (responseType, async, user, password, timeout) +var GetBoolean = function (source, key, defaultValue) { - if (responseType === undefined) { responseType = ''; } - if (async === undefined) { async = true; } - if (user === undefined) { user = ''; } - if (password === undefined) { password = ''; } - if (timeout === undefined) { timeout = 0; } - - // Before sending a request, set the xhr.responseType to "text", - // "arraybuffer", "blob", or "document", depending on your data needs. - // Note, setting xhr.responseType = '' (or omitting) will default the response to "text". - - return { - - // Ignored by the Loader, only used by File. - responseType: responseType, - - async: async, - - // credentials - user: user, - password: password, - - // timeout in ms (0 = no timeout) - timeout: timeout, - - // setRequestHeader - header: undefined, - headerValue: undefined, - - // overrideMimeType - overrideMimeType: undefined - - }; + if (!source) + { + return defaultValue; + } + else if (source.hasOwnProperty(key)) + { + return source[key]; + } + else + { + return defaultValue; + } }; -module.exports = XHRSettings; +module.exports = GetBoolean; /***/ }), -/* 91 */ +/* 70 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Utils.Object.HasValue + * @since 3.0.0 + * + * @param {object} source - [description] + * @param {string} key - [description] + * + * @return {boolean} [description] + */ +var HasValue = function (source, key) +{ + return (source.hasOwnProperty(key)); +}; + +module.exports = HasValue; + + +/***/ }), +/* 71 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var EaseMap = __webpack_require__(749); + +/** + * [description] + * + * @function Phaser.Tweens.Builders.GetEaseFunction + * @since 3.0.0 + * + * @param {(string|function)} ease - [description] + * @param {array} easeParams - [description] + * + * @return {function} [description] + */ +var GetEaseFunction = function (ease, easeParams) +{ + if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease)) + { + if (easeParams) + { + var cloneParams = easeParams.slice(0); + + cloneParams.unshift(0); + + return function (v) + { + cloneParams[0] = v; + + return EaseMap[ease].apply(this, cloneParams); + }; + } + else + { + // String based look-up + return EaseMap[ease]; + } + } + else if (typeof ease === 'function') + { + // Custom function + return ease; + } + else if (Array.isArray(ease) && ease.length === 4) + { + // Bezier function (TODO) + } + + return EaseMap.Power0; +}; + +module.exports = GetEaseFunction; + + +/***/ }), +/* 72 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -17324,41 +12318,26 @@ module.exports = XHRSettings; */ var Class = __webpack_require__(0); -var Components = __webpack_require__(328); -var Sprite = __webpack_require__(37); +var Components = __webpack_require__(13); +var GameObject = __webpack_require__(1); +var ImageRender = __webpack_require__(757); /** * @classdesc - * An Arcade Physics Sprite Game Object. + * An Image Game Object. * - * A Sprite Game Object is used for the display of both static and animated images in your game. - * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled - * and animated. + * An Image is a light-weight Game Object useful for the display of static images in your game, + * such as logos, backgrounds, scenery or other non-animated elements. Images can have input + * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an + * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. * - * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. - * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation - * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. - * - * @class Sprite - * @extends Phaser.GameObjects.Sprite - * @memberOf Phaser.Physics.Arcade + * @class Image + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects * @constructor * @since 3.0.0 * - * @extends Phaser.Physics.Arcade.Components.Acceleration - * @extends Phaser.Physics.Arcade.Components.Angular - * @extends Phaser.Physics.Arcade.Components.Bounce - * @extends Phaser.Physics.Arcade.Components.Debug - * @extends Phaser.Physics.Arcade.Components.Drag - * @extends Phaser.Physics.Arcade.Components.Enable - * @extends Phaser.Physics.Arcade.Components.Friction - * @extends Phaser.Physics.Arcade.Components.Gravity - * @extends Phaser.Physics.Arcade.Components.Immovable - * @extends Phaser.Physics.Arcade.Components.Mass - * @extends Phaser.Physics.Arcade.Components.Size - * @extends Phaser.Physics.Arcade.Components.Velocity * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.Animation * @extends Phaser.GameObjects.Components.BlendMode * @extends Phaser.GameObjects.Components.Depth * @extends Phaser.GameObjects.Components.Flip @@ -17377,378 +12356,2994 @@ var Sprite = __webpack_require__(37); * @param {number} x - The horizontal position of this Game Object in the world. * @param {number} y - The vertical position of this Game Object in the world. * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. */ -var ArcadeSprite = new Class({ +var Image = new Class({ - Extends: Sprite, + Extends: GameObject, Mixins: [ - Components.Acceleration, - Components.Angular, - Components.Bounce, - Components.Debug, - Components.Drag, - Components.Enable, - Components.Friction, - Components.Gravity, - Components.Immovable, - Components.Mass, + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, Components.Size, - Components.Velocity + Components.Texture, + Components.Tint, + Components.Transform, + Components.Visible, + ImageRender ], initialize: - function ArcadeSprite (scene, x, y, texture, frame) + function Image (scene, x, y, texture, frame) { - Sprite.call(this, scene, x, y, texture, frame); + GameObject.call(this, scene, 'Image'); + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.setSizeToFrame(); + this.setOriginFromFrame(); + this.initPipeline('TextureTintPipeline'); } }); -module.exports = ArcadeSprite; +module.exports = Image; /***/ }), -/* 92 */ +/* 73 */ /***/ (function(module, exports, __webpack_require__) { /** -* The `Matter.Bodies` module contains factory methods for creating rigid body models -* with commonly used body configurations (such as rectangles, circles and other polygons). + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Actions = __webpack_require__(367); +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(2); +var GetValue = __webpack_require__(5); +var Range = __webpack_require__(264); +var Set = __webpack_require__(63); +var Sprite = __webpack_require__(40); + +/** + * @callback GroupCallback + * + * @param {Phaser.GameObjects.GameObject} item - [description] + */ + +/** + * @callback GroupMultipleCreateCallback + * + * @param {Phaser.GameObjects.GameObject[]} items - [description] + */ + +/** + * @typedef {object} GroupConfig + * + * @property {object} [classType=Sprite] - [description] + * @property {boolean} [active=true] - [description] + * @property {number} [maxSize=-1] - [description] + * @property {?string} [defaultKey=null] - [description] + * @property {?(string|integer)} [defaultFrame=null] - [description] + * @property {boolean} [runChildUpdate=false] - [description] + * @property {?GroupCallback} [createCallback=null] - [description] + * @property {?GroupCallback} [removeCallback=null] - [description] + * @property {?GroupMultipleCreateCallback} [createMultipleCallback=null] - [description] + */ + +/** + * @typedef {object} GroupCreateConfig + * + * @property {object} [classType] - [description] + * @property {string} [key] - [description] + * @property {?(string|integer)} [frame=null] - [description] + * @property {boolean} [visible=true] - [description] + * @property {boolean} [active=true] - [description] + * @property {number} [repeat=0] - [description] + * @property {boolean} [randomKey=false] - [description] + * @property {boolean} [randomFrame=false] - [description] + * @property {boolean} [yoyo=false] - [description] + * @property {number} [frameQuantity=1] - [description] + * @property {number} [max=1] - [description] + * @property {object} [setXY] - [description] + * @property {number} [setXY.x=0] - [description] + * @property {number} [setXY.y=0] - [description] + * @property {number} [setXY.stepX=0] - [description] + * @property {number} [setXY.stepY=0] - [description] + * @property {object} [setRotation] - [description] + * @property {number} [setRotation.value=0] - [description] + * @property {number} [setRotation.step=0] - [description] + * @property {object} [setScale] - [description] + * @property {number} [setScale.x=0] - [description] + * @property {number} [setScale.y=0] - [description] + * @property {number} [setScale.stepX=0] - [description] + * @property {number} [setScale.stepY=0] - [description] + * @property {object} [setAlpha] - [description] + * @property {number} [setAlpha.value=0] - [description] + * @property {number} [setAlpha.step=0] - [description] + * @property {*} [hitArea] - [description] + * @property {HitAreaCallback} [hitAreaCallback] - [description] + * @property {(false|GridAlignConfig)} [gridAlign=false] - [description] + */ + +/** + * @classdesc + * [description] + * + * children can be either an array of children, or a config object + * config can be either a config object, or undefined if passed as the children argument instead + * + * @class Group + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {array} children - [description] + * @param {GroupConfig} config - [description] + */ +var Group = new Class({ + + initialize: + + function Group (scene, children, config) + { + if (config === undefined && !Array.isArray(children) && typeof children === 'object') + { + config = children; + children = null; + } + + /** + * [description] + * + * @name Phaser.GameObjects.Group#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.GameObjects.Group#children + * @type {Phaser.Structs.Set} + * @since 3.0.0 + */ + this.children = new Set(children); + + /** + * [description] + * + * @name Phaser.GameObjects.Group#isParent + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.isParent = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Group#classType + * @type {object} + * @since 3.0.0 + */ + this.classType = GetFastValue(config, 'classType', Sprite); + + /** + * [description] + * + * @name Phaser.GameObjects.Group#active + * @type {boolean} + * @since 3.0.0 + */ + this.active = GetFastValue(config, 'active', true); + + /** + * [description] + * + * @name Phaser.GameObjects.Group#maxSize + * @type {integer} + * @since 3.0.0 + */ + this.maxSize = GetFastValue(config, 'maxSize', -1); + + /** + * [description] + * + * @name Phaser.GameObjects.Group#defaultKey + * @type {string} + * @since 3.0.0 + */ + this.defaultKey = GetFastValue(config, 'defaultKey', null); + + /** + * [description] + * + * @name Phaser.GameObjects.Group#defaultFrame + * @type {(string|integer)} + * @since 3.0.0 + */ + this.defaultFrame = GetFastValue(config, 'defaultFrame', null); + + /** + * [description] + * + * @name Phaser.GameObjects.Group#runChildUpdate + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.runChildUpdate = GetFastValue(config, 'runChildUpdate', false); + + /** + * [description] + * + * @name Phaser.GameObjects.Group#createCallback + * @type {?GroupCallback} + * @since 3.0.0 + */ + this.createCallback = GetFastValue(config, 'createCallback', null); + + /** + * [description] + * + * @name Phaser.GameObjects.Group#removeCallback + * @type {?GroupCallback} + * @since 3.0.0 + */ + this.removeCallback = GetFastValue(config, 'removeCallback', null); + + /** + * [description] + * + * @name Phaser.GameObjects.Group#createMultipleCallback + * @type {?GroupMultipleCreateCallback} + * @since 3.0.0 + */ + this.createMultipleCallback = GetFastValue(config, 'createMultipleCallback', null); + + if (config) + { + this.createMultiple(config); + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#create + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {boolean} [visible=true] - The {@link Phaser.GameObjects.Components.Visible#visible} state of this Game Object. + * @param {boolean} [active=true] - The {@link Phaser.GameObjects.GameObject#active} state of this Game Object. + * + * @return {Phaser.GameObjects.GameObject} [description] + */ + create: function (x, y, key, frame, visible, active) + { + if (key === undefined) { key = this.defaultKey; } + if (frame === undefined) { frame = this.defaultFrame; } + if (visible === undefined) { visible = true; } + if (active === undefined) { active = true; } + + // Pool? + if (this.isFull()) + { + return null; + } + + var child = new this.classType(this.scene, x, y, key, frame); + + this.scene.sys.displayList.add(child); + + if (child.preUpdate) + { + this.scene.sys.updateList.add(child); + } + + child.visible = visible; + child.setActive(active); + + this.add(child); + + return child; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#createMultiple + * @since 3.0.0 + * + * @param {GroupCreateConfig} config - [description] + * + * @return {Phaser.GameObjects.GameObject[]} [description] + */ + createMultiple: function (config) + { + if (!Array.isArray(config)) + { + config = [ config ]; + } + + var output = []; + + for (var i = 0; i < config.length; i++) + { + var entries = this.createFromConfig(config[i]); + + output = output.concat(entries); + } + + return output; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#createFromConfig + * @since 3.0.0 + * + * @param {GroupCreateConfig} options - [description] + * + * @return {Phaser.GameObjects.GameObject[]} [description] + */ + createFromConfig: function (options) + { + this.classType = GetFastValue(options, 'classType', this.classType); + + var key = GetFastValue(options, 'key', undefined); + var frame = GetFastValue(options, 'frame', null); + var visible = GetFastValue(options, 'visible', true); + var active = GetFastValue(options, 'active', true); + + var entries = []; + + // Can't do anything without at least a key + if (key === undefined) + { + return entries; + } + else + { + if (!Array.isArray(key)) + { + key = [ key ]; + } + + if (!Array.isArray(frame)) + { + frame = [ frame ]; + } + } + + // Build an array of key frame pairs to loop through + + var repeat = GetFastValue(options, 'repeat', 0); + var randomKey = GetFastValue(options, 'randomKey', false); + var randomFrame = GetFastValue(options, 'randomFrame', false); + var yoyo = GetFastValue(options, 'yoyo', false); + var quantity = GetFastValue(options, 'frameQuantity', 1); + var max = GetFastValue(options, 'max', 0); + + // If a grid is set we use that to override the quantity? + + var range = Range(key, frame, { + max: max, + qty: quantity, + random: randomKey, + randomB: randomFrame, + repeat: repeat, + yoyo: yoyo + }); + + for (var c = 0; c < range.length; c++) + { + entries.push(this.create(0, 0, range[c].a, range[c].b, visible, active)); + } + + // Post-creation options (applied only to those items created in this call): + + var x = GetValue(options, 'setXY.x', 0); + var y = GetValue(options, 'setXY.y', 0); + var stepX = GetValue(options, 'setXY.stepX', 0); + var stepY = GetValue(options, 'setXY.stepY', 0); + + Actions.SetXY(entries, x, y, stepX, stepY); + + var rotation = GetValue(options, 'setRotation.value', 0); + var stepRotation = GetValue(options, 'setRotation.step', 0); + + Actions.SetRotation(entries, rotation, stepRotation); + + var scaleX = GetValue(options, 'setScale.x', 1); + var scaleY = GetValue(options, 'setScale.y', scaleX); + var stepScaleX = GetValue(options, 'setScale.stepX', 0); + var stepScaleY = GetValue(options, 'setScale.stepY', 0); + + Actions.SetScale(entries, scaleX, scaleY, stepScaleX, stepScaleY); + + var alpha = GetValue(options, 'setAlpha.value', 1); + var stepAlpha = GetValue(options, 'setAlpha.step', 0); + + Actions.SetAlpha(entries, alpha, stepAlpha); + + var hitArea = GetFastValue(options, 'hitArea', null); + var hitAreaCallback = GetFastValue(options, 'hitAreaCallback', null); + + if (hitArea) + { + Actions.SetHitArea(entries, hitArea, hitAreaCallback); + } + + var grid = GetFastValue(options, 'gridAlign', false); + + if (grid) + { + Actions.GridAlign(entries, grid); + } + + if (this.createMultipleCallback) + { + this.createMultipleCallback.call(this, entries); + } + + return entries; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#preUpdate + * @since 3.0.0 + * + * @param {number} time - [description] + * @param {number} delta - [description] + */ + preUpdate: function (time, delta) + { + if (!this.runChildUpdate || this.children.size === 0) + { + return; + } + + // Because a Group child may mess with the length of the Group during its update + var temp = this.children.entries.slice(); + + for (var i = 0; i < temp.length; i++) + { + var item = temp[i]; + + if (item.active) + { + item.update(time, delta); + } + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#add + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - [description] + * @param {boolean} [addToScene=false] - [description] + * + * @return {Phaser.GameObjects.Group} This Group object. + */ + add: function (child, addToScene) + { + if (addToScene === undefined) { addToScene = false; } + + this.children.set(child); + + if (this.createCallback) + { + this.createCallback.call(this, child); + } + + if (addToScene) + { + this.scene.sys.displayList.add(child); + + if (child.preUpdate) + { + this.scene.sys.updateList.add(child); + } + } + + child.on('destroy', this.remove, this); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#addMultiple + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject[]} children - [description] + * @param {boolean} [addToScene=false] - [description] + * + * @return {Phaser.GameObjects.Group} This Group object. + */ + addMultiple: function (children, addToScene) + { + if (addToScene === undefined) { addToScene = false; } + + if (Array.isArray(children)) + { + for (var i = 0; i < children.length; i++) + { + this.add(children[i], addToScene); + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#remove + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - [description] + * @param {boolean} [removeFromScene=false] - [description] + * + * @return {Phaser.GameObjects.Group} This Group object. + */ + remove: function (child, removeFromScene) + { + if (removeFromScene === undefined) { removeFromScene = false; } + + this.children.delete(child); + + if (this.removeCallback) + { + this.removeCallback.call(this, child); + } + + if (removeFromScene) + { + this.scene.sys.displayList.remove(child); + + if (child.preUpdate) + { + this.scene.sys.updateList.remove(child); + } + } + + child.off('destroy', this.remove, this); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#clear + * @since 3.0.0 + * + * @param {boolean} [removeFromScene=false] - [description] + * + * @return {Phaser.GameObjects.Group} This Group object. + */ + clear: function (removeFromScene) + { + if (removeFromScene === undefined) { removeFromScene = false; } + + var children = this.children; + + for (var i = 0; i < children.size; i++) + { + var gameObject = children.entries[i]; + + gameObject.off('destroy', this.remove, this); + + if (removeFromScene) + { + this.scene.sys.displayList.remove(gameObject); + + if (gameObject.preUpdate) + { + this.scene.sys.updateList.remove(gameObject); + } + } + } + + this.children.clear(); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#contains + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - [description] + * + * @return {boolean} [description] + */ + contains: function (child) + { + return this.children.contains(child); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#getChildren + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject[]} [description] + */ + getChildren: function () + { + return this.children.entries; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#getLength + * @since 3.0.0 + * + * @return {integer} [description] + */ + getLength: function () + { + return this.children.size; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#getFirst + * @since 3.0.0 + * + * @param {boolean} [state=false] - [description] + * @param {boolean} [createIfNull=false] - [description] + * @param {number} [x] - The horizontal position of this Game Object in the world. + * @param {number} [y] - The vertical position of this Game Object in the world. + * @param {string} [texture] - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {boolean} [visible] - [description] + * + * @return {?Phaser.GameObjects.GameObject} [description] + */ + getFirst: function (state, createIfNull, x, y, key, frame, visible) + { + if (state === undefined) { state = false; } + if (createIfNull === undefined) { createIfNull = false; } + + var gameObject; + + var children = this.children.entries; + + for (var i = 0; i < children.length; i++) + { + gameObject = children[i]; + + if (gameObject.active === state) + { + if (typeof(x) === 'number') + { + gameObject.x = x; + } + + if (typeof(y) === 'number') + { + gameObject.y = y; + } + + return gameObject; + } + } + + // Got this far? We need to create or bail + if (createIfNull) + { + return this.create(x, y, key, frame, visible); + } + else + { + return null; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#get + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {boolean} visible - [description] + * + * @return {Phaser.GameObjects.GameObject} [description] + */ + get: function (x, y, key, frame, visible) + { + return this.getFirst(false, true, x, y, key, frame, visible); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#getFirstAlive + * @since 3.0.0 + * + * @param {boolean} createIfNull - [description] + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {boolean} visible - [description] + * + * @return {Phaser.GameObjects.GameObject} [description] + */ + getFirstAlive: function (createIfNull, x, y, key, frame, visible) + { + return this.getFirst(true, createIfNull, x, y, key, frame, visible); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#getFirstDead + * @since 3.0.0 + * + * @param {boolean} createIfNull - [description] + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {boolean} visible - [description] + * + * @return {Phaser.GameObjects.GameObject} [description] + */ + getFirstDead: function (createIfNull, x, y, key, frame, visible) + { + return this.getFirst(false, createIfNull, x, y, key, frame, visible); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#playAnimation + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} startFrame - [description] + * + * @return {Phaser.GameObjects.Group} This Group object. + */ + playAnimation: function (key, startFrame) + { + Actions.PlayAnimation(this.children.entries, key, startFrame); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#isFull + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isFull: function () + { + if (this.maxSize === -1) + { + return false; + } + else + { + return (this.children.size === this.maxSize); + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#countActive + * @since 3.0.0 + * + * @param {boolean} [value=true] - [description] + * + * @return {integer} [description] + */ + countActive: function (value) + { + if (value === undefined) { value = true; } + + var total = 0; + + for (var i = 0; i < this.children.size; i++) + { + if (this.children.entries[i].active === value) + { + total++; + } + } + + return total; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#getTotalUsed + * @since 3.0.0 + * + * @return {integer} [description] + */ + getTotalUsed: function () + { + return this.countActive(); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#getTotalFree + * @since 3.0.0 + * + * @return {integer} [description] + */ + getTotalFree: function () + { + var used = this.getTotalUsed(); + var capacity = (this.maxSize === -1) ? 999999999999 : this.maxSize; + + return (capacity - used); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#setDepth + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} step - [description] + * + * @return {Phaser.GameObjects.Group} This Group object. + */ + setDepth: function (value, step) + { + Actions.SetDepth(this.children.entries, value, step); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#kill + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + */ + kill: function (gameObject) + { + if (this.children.contains(gameObject)) + { + gameObject.setActive(false); + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#killAndHide + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + */ + killAndHide: function (gameObject) + { + if (this.children.contains(gameObject)) + { + gameObject.setActive(false); + gameObject.setVisible(false); + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#toggleVisible + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Group} This Group object. + */ + toggleVisible: function () + { + Actions.ToggleVisible(this.children.entries); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Group#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.children.clear(); + + this.scene = undefined; + this.children = undefined; + } + +}); + +module.exports = Group; + + +/***/ }), +/* 74 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Check to see if the Ellipse contains the given x / y coordinates. + * + * @function Phaser.Geom.Ellipse.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. + * @param {number} x - The x coordinate to check within the ellipse. + * @param {number} y - The y coordinate to check within the ellipse. + * + * @return {boolean} True if the coordinates are within the ellipse, otherwise false. + */ +var Contains = function (ellipse, x, y) +{ + if (ellipse.width <= 0 || ellipse.height <= 0) + { + return false; + } + + // Normalize the coords to an ellipse with center 0,0 and a radius of 0.5 + var normx = ((x - ellipse.x) / ellipse.width); + var normy = ((y - ellipse.y) / ellipse.height); + + normx *= normx; + normy *= normy; + + return (normx + normy < 0.25); +}; + +module.exports = Contains; + + +/***/ }), +/* 75 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + + +module.exports = { + + /** + * Scene state. + * + * @name Phaser.Scenes.PENDING + * @type {integer} + * @since 3.0.0 + */ + PENDING: 0, + + /** + * Scene state. + * + * @name Phaser.Scenes.INIT + * @type {integer} + * @since 3.0.0 + */ + INIT: 1, + + /** + * Scene state. + * + * @name Phaser.Scenes.START + * @type {integer} + * @since 3.0.0 + */ + START: 2, + + /** + * Scene state. + * + * @name Phaser.Scenes.LOADING + * @type {integer} + * @since 3.0.0 + */ + LOADING: 3, + + /** + * Scene state. + * + * @name Phaser.Scenes.CREATING + * @type {integer} + * @since 3.0.0 + */ + CREATING: 4, + + /** + * Scene state. + * + * @name Phaser.Scenes.RUNNING + * @type {integer} + * @since 3.0.0 + */ + RUNNING: 5, + + /** + * Scene state. + * + * @name Phaser.Scenes.PAUSED + * @type {integer} + * @since 3.0.0 + */ + PAUSED: 6, + + /** + * Scene state. + * + * @name Phaser.Scenes.SLEEPING + * @type {integer} + * @since 3.0.0 + */ + SLEEPING: 7, + + /** + * Scene state. + * + * @name Phaser.Scenes.SHUTDOWN + * @type {integer} + * @since 3.0.0 + */ + SHUTDOWN: 8, + + /** + * Scene state. + * + * @name Phaser.Scenes.DESTROYED + * @type {integer} + * @since 3.0.0 + */ + DESTROYED: 9 + +}; + + +/***/ }), +/* 76 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(process) {/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Determines the operating system of the device running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.os` from within any Scene. + * + * @name Phaser.Device.OS + * @since 3.0.0 + * + * @type {object} + * @property {boolean} android - Is running on android? + * @property {boolean} chromeOS - Is running on chromeOS? + * @property {boolean} cocoonJS - Is the game running under CocoonJS? + * @property {boolean} cocoonJSApp - Is this game running with CocoonJS.App? + * @property {boolean} cordova - Is the game running under Apache Cordova? + * @property {boolean} crosswalk - Is the game running under the Intel Crosswalk XDK? + * @property {boolean} desktop - Is running on a desktop? + * @property {boolean} ejecta - Is the game running under Ejecta? + * @property {boolean} electron - Is the game running under GitHub Electron? + * @property {boolean} iOS - Is running on iOS? + * @property {boolean} iPad - Is running on iPad? + * @property {boolean} iPhone - Is running on iPhone? + * @property {boolean} kindle - Is running on an Amazon Kindle? + * @property {boolean} linux - Is running on linux? + * @property {boolean} macOS - Is running on macOS? + * @property {boolean} node - Is the game running under Node.js? + * @property {boolean} nodeWebkit - Is the game running under Node-Webkit? + * @property {boolean} webApp - Set to true if running as a WebApp, i.e. within a WebView + * @property {boolean} windows - Is running on windows? + * @property {boolean} windowsPhone - Is running on a Windows Phone? + * @property {number} iOSVersion - If running in iOS this will contain the major version number. + * @property {number} pixelRatio - PixelRatio of the host device? + */ +var OS = { + + android: false, + chromeOS: false, + cocoonJS: false, + cocoonJSApp: false, + cordova: false, + crosswalk: false, + desktop: false, + ejecta: false, + electron: false, + iOS: false, + iOSVersion: 0, + iPad: false, + iPhone: false, + kindle: false, + linux: false, + macOS: false, + node: false, + nodeWebkit: false, + pixelRatio: 1, + webApp: false, + windows: false, + windowsPhone: false + +}; + +function init () +{ + var ua = navigator.userAgent; + + if (/Windows/.test(ua)) + { + OS.windows = true; + } + else if (/Mac OS/.test(ua)) + { + OS.macOS = true; + } + else if (/Linux/.test(ua)) + { + OS.linux = true; + } + else if (/Android/.test(ua)) + { + OS.android = true; + } + else if (/iP[ao]d|iPhone/i.test(ua)) + { + OS.iOS = true; + (navigator.appVersion).match(/OS (\d+)/); + OS.iOSVersion = parseInt(RegExp.$1, 10); + } + else if (/Kindle/.test(ua) || (/\bKF[A-Z][A-Z]+/).test(ua) || (/Silk.*Mobile Safari/).test(ua)) + { + OS.kindle = true; + + // This will NOT detect early generations of Kindle Fire, I think there is no reliable way... + // E.g. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-80) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true" + } + else if (/CrOS/.test(ua)) + { + OS.chromeOS = true; + } + + if (/Windows Phone/i.test(ua) || (/IEMobile/i).test(ua)) + { + OS.android = false; + OS.iOS = false; + OS.macOS = false; + OS.windows = true; + OS.windowsPhone = true; + } + + var silk = (/Silk/).test(ua); + + if (OS.windows || OS.macOS || (OS.linux && !silk) || OS.chromeOS) + { + OS.desktop = true; + } + + // Windows Phone / Table reset + if (OS.windowsPhone || ((/Windows NT/i.test(ua)) && (/Touch/i.test(ua)))) + { + OS.desktop = false; + } + + // WebApp mode in iOS + if (navigator.standalone) + { + OS.webApp = true; + } + + if (window.cordova !== undefined) + { + OS.cordova = true; + } + + if ((typeof process !== 'undefined') && (typeof process.versions.node !== 'undefined')) + { + OS.node = true; + } + + if (OS.node && typeof process.versions === 'object') + { + OS.nodeWebkit = !!process.versions['node-webkit']; + + OS.electron = !!process.versions.electron; + } + + if (navigator.isCocoonJS) + { + OS.cocoonJS = true; + + try + { + OS.cocoonJSApp = (typeof CocoonJS !== 'undefined'); + } + catch (error) + { + OS.cocoonJSApp = false; + } + } + + if (window.ejecta !== undefined) + { + OS.ejecta = true; + } + + if ((/Crosswalk/).test(ua)) + { + OS.crosswalk = true; + } + + OS.iPhone = ua.toLowerCase().indexOf('iphone') !== -1; + OS.iPad = ua.toLowerCase().indexOf('ipad') !== -1; + + OS.pixelRatio = window['devicePixelRatio'] || 1; + + return OS; +} + +module.exports = init(); + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(821))) + +/***/ }), +/* 77 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Line.Length + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * + * @return {number} [description] + */ +var Length = function (line) +{ + return Math.sqrt((line.x2 - line.x1) * (line.x2 - line.x1) + (line.y2 - line.y1) * (line.y2 - line.y1)); +}; + +module.exports = Length; + + +/***/ }), +/* 78 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(64); + +/** + * Return a value based on the range between `min` and `max` and the percentage given. + * + * @function Phaser.Math.FromPercent + * @since 3.0.0 + * + * @param {float} percent - A value between 0 and 1 representing the percentage. + * @param {number} min - [description] + * @param {number} [max] - [description] + * + * @return {number} [description] + */ +var FromPercent = function (percent, min, max) +{ + percent = Clamp(percent, 0, 1); + + return (max - min) * percent; +}; + +module.exports = FromPercent; + + +/***/ }), +/* 79 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Contains = __webpack_require__(28); +var GetPoint = __webpack_require__(355); +var GetPoints = __webpack_require__(354); +var Random = __webpack_require__(167); + +/** + * @classdesc + * A Circle object. + * + * This is a geometry object, containing numerical values and related methods to inspect and modify them. + * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. + * To render a Circle you should look at the capabilities of the Graphics class. + * + * @class Circle + * @memberOf Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of the center of the circle. + * @param {number} [y=0] - The y position of the center of the circle. + * @param {number} [radius=0] - The radius of the circle. + */ +var Circle = new Class({ + + initialize: + + function Circle (x, y, radius) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (radius === undefined) { radius = 0; } + + /** + * The x position of the center of the circle. + * + * @name Phaser.Geom.Circle#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = x; + + /** + * The y position of the center of the circle. + * + * @name Phaser.Geom.Circle#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = y; + + /** + * The internal radius of the circle. + * + * @name Phaser.Geom.Circle#_radius + * @type {number} + * @private + * @since 3.0.0 + */ + this._radius = radius; + + /** + * The internal diameter of the circle. + * + * @name Phaser.Geom.Circle#_diameter + * @type {number} + * @private + * @since 3.0.0 + */ + this._diameter = radius * 2; + }, + + /** + * Check to see if the Circle contains the given x / y coordinates. + * + * @method Phaser.Geom.Circle#contains + * @since 3.0.0 + * + * @param {number} x - The x coordinate to check within the circle. + * @param {number} y - The y coordinate to check within the circle. + * + * @return {boolean} True if the coordinates are within the circle, otherwise false. + */ + contains: function (x, y) + { + return Contains(this, x, y); + }, + + /** + * Returns a Point object containing the coordinates of a point on the circumference of the Circle + * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point + * at 180 degrees around the circle. + * + * @method Phaser.Geom.Circle#getPoint + * @since 3.0.0 + * + * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. + * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. + * + * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the circle. + */ + getPoint: function (position, point) + { + return GetPoint(this, position, point); + }, + + /** + * Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, + * based on the given quantity or stepRate values. + * + * @method Phaser.Geom.Circle#getPoints + * @since 3.0.0 + * + * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. + * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. + * + * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the circumference of the circle. + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * Returns a uniformly distributed random point from anywhere within the Circle. + * + * @method Phaser.Geom.Circle#getRandomPoint + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} [point] - A Point or point-like object to set the random `x` and `y` values in. + * + * @return {(Phaser.Geom.Point|object)} A Point object with the random values set in the `x` and `y` properties. + */ + getRandomPoint: function (point) + { + return Random(this, point); + }, + + /** + * Sets the x, y and radius of this circle. + * + * @method Phaser.Geom.Circle#setTo + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of the center of the circle. + * @param {number} [y=0] - The y position of the center of the circle. + * @param {number} [radius=0] - The radius of the circle. + * + * @return {Phaser.Geom.Circle} This Circle object. + */ + setTo: function (x, y, radius) + { + this.x = x; + this.y = y; + this._radius = radius; + this._diameter = radius * 2; + + return this; + }, + + /** + * Sets this Circle to be empty with a radius of zero. + * Does not change its position. + * + * @method Phaser.Geom.Circle#setEmpty + * @since 3.0.0 + * + * @return {Phaser.Geom.Circle} This Circle object. + */ + setEmpty: function () + { + this._radius = 0; + this._diameter = 0; + + return this; + }, + + /** + * Sets the position of this Circle. + * + * @method Phaser.Geom.Circle#setPosition + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of the center of the circle. + * @param {number} [y=0] - The y position of the center of the circle. + * + * @return {Phaser.Geom.Circle} This Circle object. + */ + setPosition: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * Checks to see if the Circle is empty: has a radius of zero. + * + * @method Phaser.Geom.Circle#isEmpty + * @since 3.0.0 + * + * @return {boolean} True if the Circle is empty, otherwise false. + */ + isEmpty: function () + { + return (this._radius <= 0); + }, + + /** + * The radius of the Circle. + * + * @name Phaser.Geom.Circle#radius + * @type {number} + * @since 3.0.0 + */ + radius: { + + get: function () + { + return this._radius; + }, + + set: function (value) + { + this._radius = value; + this._diameter = value * 2; + } + + }, + + /** + * The diameter of the Circle. + * + * @name Phaser.Geom.Circle#diameter + * @type {number} + * @since 3.0.0 + */ + diameter: { + + get: function () + { + return this._diameter; + }, + + set: function (value) + { + this._diameter = value; + this._radius = value * 0.5; + } + + }, + + /** + * The left position of the Circle. + * + * @name Phaser.Geom.Circle#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () + { + return this.x - this._radius; + }, + + set: function (value) + { + this.x = value + this._radius; + } + + }, + + /** + * The right position of the Circle. + * + * @name Phaser.Geom.Circle#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return this.x + this._radius; + }, + + set: function (value) + { + this.x = value - this._radius; + } + + }, + + /** + * The top position of the Circle. + * + * @name Phaser.Geom.Circle#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return this.y - this._radius; + }, + + set: function (value) + { + this.y = value + this._radius; + } + + }, + + /** + * The bottom position of the Circle. + * + * @name Phaser.Geom.Circle#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return this.y + this._radius; + }, + + set: function (value) + { + this.y = value - this._radius; + } + + } + +}); + +module.exports = Circle; + + +/***/ }), +/* 80 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.ScaleModes + */ + +module.exports = { + + /** + * Default Scale Mode (Linear). + * + * @name Phaser.ScaleModes.DEFAULT + * @type {integer} + * @since 3.0.0 + */ + DEFAULT: 0, + + /** + * Linear Scale Mode. + * + * @name Phaser.ScaleModes.LINEAR + * @type {integer} + * @since 3.0.0 + */ + LINEAR: 0, + + /** + * Nearest Scale Mode. + * + * @name Phaser.ScaleModes.NEAREST + * @type {integer} + * @since 3.0.0 + */ + NEAREST: 1 + +}; + + +/***/ }), +/* 81 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the routine from {@link http://jsfiddle.net/MrPolywhirl/NH42z/}. + +var CheckMatrix = __webpack_require__(109); +var TransposeMatrix = __webpack_require__(177); + +/** + * [description] + * + * @function Phaser.Utils.Array.Matrix.RotateMatrix + * @since 3.0.0 + * + * @param {array} matrix - The array to rotate. + * @param {(number|string)} [direction=90] - The amount to rotate the matrix by. The value can be given in degrees: 90, -90, 270, -270 or 180, or a string command: `rotateLeft`, `rotateRight` or `rotate180`. + * + * @return {array} The rotated matrix array. The source matrix should be discard for the returned matrix. + */ +var RotateMatrix = function (matrix, direction) +{ + if (direction === undefined) { direction = 90; } + + if (!CheckMatrix(matrix)) + { + return null; + } + + if (typeof direction !== 'string') + { + direction = ((direction % 360) + 360) % 360; + } + + if (direction === 90 || direction === -270 || direction === 'rotateLeft') + { + matrix = TransposeMatrix(matrix); + matrix.reverse(); + } + else if (direction === -90 || direction === 270 || direction === 'rotateRight') + { + matrix.reverse(); + matrix = TransposeMatrix(matrix); + } + else if (Math.abs(direction) === 180 || direction === 'rotate180') + { + for (var i = 0; i < matrix.length; i++) + { + matrix[i].reverse(); + } + + matrix.reverse(); + } + + return matrix; +}; + +module.exports = RotateMatrix; + + +/***/ }), +/* 82 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Defaults = __webpack_require__(112); +var GetAdvancedValue = __webpack_require__(8); +var GetBoolean = __webpack_require__(69); +var GetEaseFunction = __webpack_require__(71); +var GetNewValue = __webpack_require__(83); +var GetProps = __webpack_require__(182); +var GetTargets = __webpack_require__(114); +var GetValue = __webpack_require__(5); +var GetValueOp = __webpack_require__(113); +var Tween = __webpack_require__(111); +var TweenData = __webpack_require__(110); + +/** + * [description] + * + * @function Phaser.Tweens.Builders.TweenBuilder + * @since 3.0.0 + * + * @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - [description] + * @param {object} config - [description] + * @param {Phaser.Tweens.TweenConfigDefaults} defaults - [description] + * + * @return {Phaser.Tweens.Tween} [description] + */ +var TweenBuilder = function (parent, config, defaults) +{ + if (defaults === undefined) + { + defaults = Defaults; + } + + // Create arrays of the Targets and the Properties + var targets = (defaults.targets) ? defaults.targets : GetTargets(config); + + // var props = (defaults.props) ? defaults.props : GetProps(config); + var props = GetProps(config); + + // Default Tween values + var delay = GetNewValue(config, 'delay', defaults.delay); + var duration = GetNewValue(config, 'duration', defaults.duration); + var easeParams = GetValue(config, 'easeParams', defaults.easeParams); + var ease = GetEaseFunction(GetValue(config, 'ease', defaults.ease), easeParams); + var hold = GetNewValue(config, 'hold', defaults.hold); + var repeat = GetNewValue(config, 'repeat', defaults.repeat); + var repeatDelay = GetNewValue(config, 'repeatDelay', defaults.repeatDelay); + var yoyo = GetBoolean(config, 'yoyo', defaults.yoyo); + var flipX = GetBoolean(config, 'flipX', defaults.flipX); + var flipY = GetBoolean(config, 'flipY', defaults.flipY); + + var data = []; + + // Loop through every property defined in the Tween, i.e.: props { x, y, alpha } + for (var p = 0; p < props.length; p++) + { + var key = props[p].key; + var value = props[p].value; + + // Create 1 TweenData per target, per property + for (var t = 0; t < targets.length; t++) + { + var ops = GetValueOp(key, value); + + var tweenData = TweenData( + targets[t], + key, + ops.getEnd, + ops.getStart, + GetEaseFunction(GetValue(value, 'ease', ease), easeParams), + GetNewValue(value, 'delay', delay), + GetNewValue(value, 'duration', duration), + GetBoolean(value, 'yoyo', yoyo), + GetNewValue(value, 'hold', hold), + GetNewValue(value, 'repeat', repeat), + GetNewValue(value, 'repeatDelay', repeatDelay), + GetBoolean(value, 'flipX', flipX), + GetBoolean(value, 'flipY', flipY) + ); + + data.push(tweenData); + } + } + + var tween = new Tween(parent, data, targets); + + tween.offset = GetAdvancedValue(config, 'offset', null); + tween.completeDelay = GetAdvancedValue(config, 'completeDelay', 0); + tween.loop = Math.round(GetAdvancedValue(config, 'loop', 0)); + tween.loopDelay = Math.round(GetAdvancedValue(config, 'loopDelay', 0)); + tween.paused = GetBoolean(config, 'paused', false); + tween.useFrames = GetBoolean(config, 'useFrames', false); + + // Set the Callbacks + var scope = GetValue(config, 'callbackScope', tween); + + // Callback parameters: 0 = a reference to the Tween itself, 1 = the target/s of the Tween, ... your own params + var tweenArray = [ tween, null ]; + + var callbacks = Tween.TYPES; + + for (var i = 0; i < callbacks.length; i++) + { + var type = callbacks[i]; + + var callback = GetValue(config, type, false); + + if (callback) + { + var callbackScope = GetValue(config, type + 'Scope', scope); + var callbackParams = GetValue(config, type + 'Params', []); + + // The null is reset to be the Tween target + tween.setCallback(type, callback, tweenArray.concat(callbackParams), callbackScope); + } + } + + return tween; +}; + +module.exports = TweenBuilder; + + +/***/ }), +/* 83 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Tweens.Builders.GetNewValue + * @since 3.0.0 + * + * @param {object} source - [description] + * @param {string} key - [description] + * @param {*} defaultValue - [description] + * + * @return {function} [description] + */ +var GetNewValue = function (source, key, defaultValue) +{ + var valueCallback; + + if (source.hasOwnProperty(key)) + { + var t = typeof(source[key]); + + if (t === 'function') + { + valueCallback = function (index, totalTargets, target) + { + return source[key](index, totalTargets, target); + }; + } + else + { + valueCallback = function () + { + return source[key]; + }; + } + } + else if (typeof defaultValue === 'function') + { + valueCallback = defaultValue; + } + else + { + valueCallback = function () + { + return defaultValue; + }; + } + + return valueCallback; +}; + +module.exports = GetNewValue; + + +/***/ }), +/* 84 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A Tileset is a combination of an image containing the tiles and a container for data about + * each tile. + * + * @class Tileset + * @memberOf Phaser.Tilemaps + * @constructor + * @since 3.0.0 + * + * @param {string} name - The name of the tileset in the map data. + * @param {integer} firstgid - The first tile index this tileset contains. + * @param {integer} [tileWidth=32] - Width of each tile (in pixels). + * @param {integer} [tileHeight=32] - Height of each tile (in pixels). + * @param {integer} [tileMargin=0] - The margin around all tiles in the sheet (in pixels). + * @param {integer} [tileSpacing=0] - The spacing between each tile in the sheet (in pixels). + * @param {object} [tileProperties={}] - Custom properties defined per tile in the Tileset. + * These typically are custom properties created in Tiled when editing a tileset. + * @param {object} [tileData={}] - Data stored per tile. These typically are created in Tiled + * when editing a tileset, e.g. from Tiled's tile collision editor or terrain editor. + */ +var Tileset = new Class({ + + initialize: + + function Tileset (name, firstgid, tileWidth, tileHeight, tileMargin, tileSpacing, tileProperties, tileData) + { + if (tileWidth === undefined || tileWidth <= 0) { tileWidth = 32; } + if (tileHeight === undefined || tileHeight <= 0) { tileHeight = 32; } + if (tileMargin === undefined) { tileMargin = 0; } + if (tileSpacing === undefined) { tileSpacing = 0; } + if (tileProperties === undefined) { tileProperties = {}; } + if (tileData === undefined) { tileData = {}; } + + /** + * The name of the Tileset. + * + * @name Phaser.Tilemaps.Tileset#name + * @type {string} + * @since 3.0.0 + */ + this.name = name; + + /** + * The starting index of the first tile index this Tileset contains. + * + * @name Phaser.Tilemaps.Tileset#firstgid + * @type {integer} + * @since 3.0.0 + */ + this.firstgid = firstgid; + + /** + * The width of each tile (in pixels). Use setTileSize to change. + * + * @name Phaser.Tilemaps.Tileset#tileWidth + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + this.tileWidth = tileWidth; + + /** + * The height of each tile (in pixels). Use setTileSize to change. + * + * @name Phaser.Tilemaps.Tileset#tileHeight + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + this.tileHeight = tileHeight; + + /** + * The margin around the tiles in the sheet (in pixels). Use `setSpacing` to change. + * + * @name Phaser.Tilemaps.Tileset#tileMargin + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + this.tileMargin = tileMargin; + + /** + * The spacing between each the tile in the sheet (in pixels). Use `setSpacing` to change. + * + * @name Phaser.Tilemaps.Tileset#tileSpacing + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + this.tileSpacing = tileSpacing; + + /** + * Tileset-specific properties per tile that are typically defined in the Tiled editor in the + * Tileset editor. + * + * @name Phaser.Tilemaps.Tileset#tileProperties + * @type {object} + * @since 3.0.0 + */ + this.tileProperties = tileProperties; + + /** + * Tileset-specific data per tile that are typically defined in the Tiled editor, e.g. within + * the Tileset collision editor. This is where collision objects and terrain are stored. + * + * @name Phaser.Tilemaps.Tileset#tileData + * @type {object} + * @since 3.0.0 + */ + this.tileData = tileData; + + /** + * The cached image that contains the individual tiles. Use setImage to set. + * + * @name Phaser.Tilemaps.Tileset#image + * @type {?Phaser.Textures.Texture} + * @readOnly + * @since 3.0.0 + */ + this.image = null; + + /** + * The number of tile rows in the the tileset. + * + * @name Phaser.Tilemaps.Tileset#rows + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + this.rows = 0; + + /** + * The number of tile columns in the tileset. + * + * @name Phaser.Tilemaps.Tileset#columns + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + this.columns = 0; + + /** + * The total number of tiles in the tileset. + * + * @name Phaser.Tilemaps.Tileset#total + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + this.total = 0; + + /** + * The look-up table to specific tile image texture coordinates (UV in pixels). Each element + * contains the coordinates for a tile in an object of the form {x, y}. + * + * @name Phaser.Tilemaps.Tileset#texCoordinates + * @type {object[]} + * @readOnly + * @since 3.0.0 + */ + this.texCoordinates = []; + }, + + /** + * Get a tiles properties that are stored in the Tileset. Returns null if tile index is not + * contained in this Tileset. This is typically defined in Tiled under the Tileset editor. + * + * @method Phaser.Tilemaps.Tileset#getTileProperties + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {?(object|undefined)} + */ + getTileProperties: function (tileIndex) + { + if (!this.containsTileIndex(tileIndex)) { return null; } + + return this.tileProperties[tileIndex - this.firstgid]; + }, + + /** + * Get a tile's data that is stored in the Tileset. Returns null if tile index is not contained + * in this Tileset. This is typically defined in Tiled and will contain both Tileset collision + * info and terrain mapping. + * + * @method Phaser.Tilemaps.Tileset#getTileData + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {?object|undefined} + */ + getTileData: function (tileIndex) + { + if (!this.containsTileIndex(tileIndex)) { return null; } + + return this.tileData[tileIndex - this.firstgid]; + }, + + /** + * Get a tile's collision group that is stored in the Tileset. Returns null if tile index is not + * contained in this Tileset. This is typically defined within Tiled's tileset collision editor. + * + * @method Phaser.Tilemaps.Tileset#getTileCollisionGroup + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {?object} + */ + getTileCollisionGroup: function (tileIndex) + { + var data = this.getTileData(tileIndex); + + return (data && data.objectgroup) ? data.objectgroup : null; + }, + + /** + * Returns true if and only if this Tileset contains the given tile index. + * + * @method Phaser.Tilemaps.Tileset#containsTileIndex + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {boolean} + */ + containsTileIndex: function (tileIndex) + { + return ( + tileIndex >= this.firstgid && + tileIndex < (this.firstgid + this.total) + ); + }, + + /** + * Returns the texture coordinates (UV in pixels) in the Tileset image for the given tile index. + * Returns null if tile index is not contained in this Tileset. + * + * @method Phaser.Tilemaps.Tileset#getTileTextureCoordinates + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {?object} Object in the form { x, y } representing the top-left UV coordinate + * within the Tileset image. + */ + getTileTextureCoordinates: function (tileIndex) + { + if (!this.containsTileIndex(tileIndex)) { return null; } + + return this.texCoordinates[tileIndex - this.firstgid]; + }, + + /** + * Sets the image associated with this Tileset and updates the tile data (rows, columns, etc.). + * + * @method Phaser.Tilemaps.Tileset#setImage + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The image that contains the tiles. + * + * @return {Phaser.Tilemaps.Tileset} This Tileset object. + */ + setImage: function (texture) + { + this.image = texture; + + this.updateTileData(this.image.source[0].width, this.image.source[0].height); + + return this; + }, + + /** + * Sets the tile width & height and updates the tile data (rows, columns, etc.). + * + * @method Phaser.Tilemaps.Tileset#setTileSize + * @since 3.0.0 + * + * @param {integer} [tileWidth] - The width of a tile in pixels. + * @param {integer} [tileHeight] - The height of a tile in pixels. + * + * @return {Phaser.Tilemaps.Tileset} This Tileset object. + */ + setTileSize: function (tileWidth, tileHeight) + { + if (tileWidth !== undefined) { this.tileWidth = tileWidth; } + if (tileHeight !== undefined) { this.tileHeight = tileHeight; } + + if (this.image) + { + this.updateTileData(this.image.source[0].width, this.image.source[0].height); + } + + return this; + }, + + /** + * Sets the tile margin & spacing and updates the tile data (rows, columns, etc.). + * + * @method Phaser.Tilemaps.Tileset#setSpacing + * @since 3.0.0 + * + * @param {integer} [margin] - The margin around the tiles in the sheet (in pixels). + * @param {integer} [spacing] - The spacing between the tiles in the sheet (in pixels). + * + * @return {Phaser.Tilemaps.Tileset} This Tileset object. + */ + setSpacing: function (margin, spacing) + { + if (margin !== undefined) { this.tileMargin = margin; } + if (spacing !== undefined) { this.tileSpacing = spacing; } + + if (this.image) + { + this.updateTileData(this.image.source[0].width, this.image.source[0].height); + } + + return this; + }, + + /** + * Updates tile texture coordinates and tileset data. + * + * @method Phaser.Tilemaps.Tileset#updateTileData + * @since 3.0.0 + * + * @param {integer} imageWidth - The (expected) width of the image to slice. + * @param {integer} imageHeight - The (expected) height of the image to slice. + * + * @return {Phaser.Tilemaps.Tileset} This Tileset object. + */ + updateTileData: function (imageWidth, imageHeight) + { + var rowCount = (imageHeight - this.tileMargin * 2 + this.tileSpacing) / (this.tileHeight + this.tileSpacing); + var colCount = (imageWidth - this.tileMargin * 2 + this.tileSpacing) / (this.tileWidth + this.tileSpacing); + + if (rowCount % 1 !== 0 || colCount % 1 !== 0) + { + console.warn('Tileset ' + this.name + ' image tile area is not an even multiple of tile size'); + } + + // In Tiled a tileset image that is not an even multiple of the tile dimensions is truncated + // - hence the floor when calculating the rows/columns. + rowCount = Math.floor(rowCount); + colCount = Math.floor(colCount); + + this.rows = rowCount; + this.columns = colCount; + + // In Tiled, "empty" spaces in a tileset count as tiles and hence count towards the gid + this.total = rowCount * colCount; + + this.texCoordinates.length = 0; + + var tx = this.tileMargin; + var ty = this.tileMargin; + + for (var y = 0; y < this.rows; y++) + { + for (var x = 0; x < this.columns; x++) + { + this.texCoordinates.push({ x: tx, y: ty }); + tx += this.tileWidth + this.tileSpacing; + } + + tx = this.tileMargin; + ty += this.tileHeight + this.tileSpacing; + } + + return this; + } + +}); + +module.exports = Tileset; + + +/***/ }), +/* 85 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layer's position, scale and scroll. + * + * @function Phaser.Tilemaps.Components.TileToWorldY + * @since 3.0.0 + * + * @param {integer} tileY - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {number} + */ +var TileToWorldY = function (tileY, camera, layer) +{ + var tileHeight = layer.baseTileHeight; + var tilemapLayer = layer.tilemapLayer; + var layerWorldY = 0; + + if (tilemapLayer) + { + if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } + + layerWorldY = (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY)); + + tileHeight *= tilemapLayer.scaleY; + } + + return layerWorldY + tileY * tileHeight; +}; + +module.exports = TileToWorldY; + + +/***/ }), +/* 86 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layer's position, scale and scroll. + * + * @function Phaser.Tilemaps.Components.TileToWorldX + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {number} + */ +var TileToWorldX = function (tileX, camera, layer) +{ + var tileWidth = layer.baseTileWidth; + var tilemapLayer = layer.tilemapLayer; + var layerWorldX = 0; + + if (tilemapLayer) + { + if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } + + layerWorldX = tilemapLayer.x + camera.scrollX * (1 - tilemapLayer.scrollFactorX); + + tileWidth *= tilemapLayer.scaleX; + } + + return layerWorldX + tileX * tileWidth; +}; + +module.exports = TileToWorldX; + + +/***/ }), +/* 87 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var IsInLayerBounds = __webpack_require__(67); + +/** + * Gets a tile at the given tile coordinates from the given layer. + * + * @function Phaser.Tilemaps.Components.GetTileAt + * @since 3.0.0 + * + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). + * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile + * object with an index of -1. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates + * were invalid. + */ +var GetTileAt = function (tileX, tileY, nonNull, layer) +{ + if (nonNull === undefined) { nonNull = false; } + + if (IsInLayerBounds(tileX, tileY, layer)) + { + var tile = layer.data[tileY][tileX]; + if (tile === null) + { + return null; + } + else if (tile.index === -1) + { + return nonNull ? tile : null; + } + else + { + return tile; + } + } + else + { + return null; + } +}; + +module.exports = GetTileAt; + + +/***/ }), +/* 88 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Tilemaps.Components + */ + +module.exports = { + + CalculateFacesAt: __webpack_require__(119), + CalculateFacesWithin: __webpack_require__(26), + Copy: __webpack_require__(454), + CreateFromTiles: __webpack_require__(453), + CullTiles: __webpack_require__(452), + Fill: __webpack_require__(451), + FilterTiles: __webpack_require__(450), + FindByIndex: __webpack_require__(449), + FindTile: __webpack_require__(448), + ForEachTile: __webpack_require__(447), + GetTileAt: __webpack_require__(87), + GetTileAtWorldXY: __webpack_require__(446), + GetTilesWithin: __webpack_require__(14), + GetTilesWithinShape: __webpack_require__(445), + GetTilesWithinWorldXY: __webpack_require__(444), + HasTileAt: __webpack_require__(196), + HasTileAtWorldXY: __webpack_require__(443), + IsInLayerBounds: __webpack_require__(67), + PutTileAt: __webpack_require__(118), + PutTileAtWorldXY: __webpack_require__(442), + PutTilesAt: __webpack_require__(441), + Randomize: __webpack_require__(440), + RemoveTileAt: __webpack_require__(195), + RemoveTileAtWorldXY: __webpack_require__(439), + RenderDebug: __webpack_require__(438), + ReplaceByIndex: __webpack_require__(197), + SetCollision: __webpack_require__(437), + SetCollisionBetween: __webpack_require__(436), + SetCollisionByExclusion: __webpack_require__(435), + SetCollisionByProperty: __webpack_require__(434), + SetCollisionFromCollisionGroup: __webpack_require__(433), + SetTileIndexCallback: __webpack_require__(432), + SetTileLocationCallback: __webpack_require__(431), + Shuffle: __webpack_require__(430), + SwapByIndex: __webpack_require__(429), + TileToWorldX: __webpack_require__(86), + TileToWorldXY: __webpack_require__(428), + TileToWorldY: __webpack_require__(85), + WeightedRandomize: __webpack_require__(427), + WorldToTileX: __webpack_require__(38), + WorldToTileXY: __webpack_require__(426), + WorldToTileY: __webpack_require__(37) + +}; + + +/***/ }), +/* 89 */ +/***/ (function(module, exports) { + +/** +* The `Matter.Bounds` module contains methods for creating and manipulating axis-aligned bounding boxes (AABB). * -* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). -* -* @class Bodies +* @class Bounds */ -// TODO: true circle bodies +var Bounds = {}; -var Bodies = {}; - -module.exports = Bodies; - -var Vertices = __webpack_require__(93); -var Common = __webpack_require__(38); -var Body = __webpack_require__(60); -var Bounds = __webpack_require__(95); -var Vector = __webpack_require__(94); -var decomp = __webpack_require__(948); +module.exports = Bounds; (function() { /** - * Creates a new rigid body model with a rectangle hull. - * The options parameter is an object that specifies any properties you wish to override the defaults. - * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. - * @method rectangle - * @param {number} x - * @param {number} y - * @param {number} width - * @param {number} height - * @param {object} [options] - * @return {body} A new rectangle body + * Creates a new axis-aligned bounding box (AABB) for the given vertices. + * @method create + * @param {vertices} vertices + * @return {bounds} A new bounds object */ - Bodies.rectangle = function(x, y, width, height, options) { - options = options || {}; - - var rectangle = { - label: 'Rectangle Body', - position: { x: x, y: y }, - vertices: Vertices.fromPath('L 0 0 L ' + width + ' 0 L ' + width + ' ' + height + ' L 0 ' + height) + Bounds.create = function(vertices) { + var bounds = { + min: { x: 0, y: 0 }, + max: { x: 0, y: 0 } }; - if (options.chamfer) { - var chamfer = options.chamfer; - rectangle.vertices = Vertices.chamfer(rectangle.vertices, chamfer.radius, - chamfer.quality, chamfer.qualityMin, chamfer.qualityMax); - delete options.chamfer; - } + if (vertices) + Bounds.update(bounds, vertices); + + return bounds; + }; - return Body.create(Common.extend({}, rectangle, options)); + /** + * Updates bounds using the given vertices and extends the bounds given a velocity. + * @method update + * @param {bounds} bounds + * @param {vertices} vertices + * @param {vector} velocity + */ + Bounds.update = function(bounds, vertices, velocity) { + bounds.min.x = Infinity; + bounds.max.x = -Infinity; + bounds.min.y = Infinity; + bounds.max.y = -Infinity; + + for (var i = 0; i < vertices.length; i++) { + var vertex = vertices[i]; + if (vertex.x > bounds.max.x) bounds.max.x = vertex.x; + if (vertex.x < bounds.min.x) bounds.min.x = vertex.x; + if (vertex.y > bounds.max.y) bounds.max.y = vertex.y; + if (vertex.y < bounds.min.y) bounds.min.y = vertex.y; + } + + if (velocity) { + if (velocity.x > 0) { + bounds.max.x += velocity.x; + } else { + bounds.min.x += velocity.x; + } + + if (velocity.y > 0) { + bounds.max.y += velocity.y; + } else { + bounds.min.y += velocity.y; + } + } + }; + + /** + * Returns true if the bounds contains the given point. + * @method contains + * @param {bounds} bounds + * @param {vector} point + * @return {boolean} True if the bounds contain the point, otherwise false + */ + Bounds.contains = function(bounds, point) { + return point.x >= bounds.min.x && point.x <= bounds.max.x + && point.y >= bounds.min.y && point.y <= bounds.max.y; + }; + + /** + * Returns true if the two bounds intersect. + * @method overlaps + * @param {bounds} boundsA + * @param {bounds} boundsB + * @return {boolean} True if the bounds overlap, otherwise false + */ + Bounds.overlaps = function(boundsA, boundsB) { + return (boundsA.min.x <= boundsB.max.x && boundsA.max.x >= boundsB.min.x + && boundsA.max.y >= boundsB.min.y && boundsA.min.y <= boundsB.max.y); + }; + + /** + * Translates the bounds by the given vector. + * @method translate + * @param {bounds} bounds + * @param {vector} vector + */ + Bounds.translate = function(bounds, vector) { + bounds.min.x += vector.x; + bounds.max.x += vector.x; + bounds.min.y += vector.y; + bounds.max.y += vector.y; + }; + + /** + * Shifts the bounds to the given position. + * @method shift + * @param {bounds} bounds + * @param {vector} position + */ + Bounds.shift = function(bounds, position) { + var deltaX = bounds.max.x - bounds.min.x, + deltaY = bounds.max.y - bounds.min.y; + + bounds.min.x = position.x; + bounds.max.x = position.x + deltaX; + bounds.min.y = position.y; + bounds.max.y = position.y + deltaY; }; - /** - * Creates a new rigid body model with a trapezoid hull. - * The options parameter is an object that specifies any properties you wish to override the defaults. - * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. - * @method trapezoid - * @param {number} x - * @param {number} y - * @param {number} width - * @param {number} height - * @param {number} slope - * @param {object} [options] - * @return {body} A new trapezoid body - */ - Bodies.trapezoid = function(x, y, width, height, slope, options) { - options = options || {}; - - slope *= 0.5; - var roof = (1 - (slope * 2)) * width; - - var x1 = width * slope, - x2 = x1 + roof, - x3 = x2 + x1, - verticesPath; - - if (slope < 0.5) { - verticesPath = 'L 0 0 L ' + x1 + ' ' + (-height) + ' L ' + x2 + ' ' + (-height) + ' L ' + x3 + ' 0'; - } else { - verticesPath = 'L 0 0 L ' + x2 + ' ' + (-height) + ' L ' + x3 + ' 0'; - } - - var trapezoid = { - label: 'Trapezoid Body', - position: { x: x, y: y }, - vertices: Vertices.fromPath(verticesPath) - }; - - if (options.chamfer) { - var chamfer = options.chamfer; - trapezoid.vertices = Vertices.chamfer(trapezoid.vertices, chamfer.radius, - chamfer.quality, chamfer.qualityMin, chamfer.qualityMax); - delete options.chamfer; - } - - return Body.create(Common.extend({}, trapezoid, options)); - }; - - /** - * Creates a new rigid body model with a circle hull. - * The options parameter is an object that specifies any properties you wish to override the defaults. - * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. - * @method circle - * @param {number} x - * @param {number} y - * @param {number} radius - * @param {object} [options] - * @param {number} [maxSides] - * @return {body} A new circle body - */ - Bodies.circle = function(x, y, radius, options, maxSides) { - options = options || {}; - - var circle = { - label: 'Circle Body', - circleRadius: radius - }; - - // approximate circles with polygons until true circles implemented in SAT - maxSides = maxSides || 25; - var sides = Math.ceil(Math.max(10, Math.min(maxSides, radius))); - - // optimisation: always use even number of sides (half the number of unique axes) - if (sides % 2 === 1) - sides += 1; - - return Bodies.polygon(x, y, sides, radius, Common.extend({}, circle, options)); - }; - - /** - * Creates a new rigid body model with a regular polygon hull with the given number of sides. - * The options parameter is an object that specifies any properties you wish to override the defaults. - * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. - * @method polygon - * @param {number} x - * @param {number} y - * @param {number} sides - * @param {number} radius - * @param {object} [options] - * @return {body} A new regular polygon body - */ - Bodies.polygon = function(x, y, sides, radius, options) { - options = options || {}; - - if (sides < 3) - return Bodies.circle(x, y, radius, options); - - var theta = 2 * Math.PI / sides, - path = '', - offset = theta * 0.5; - - for (var i = 0; i < sides; i += 1) { - var angle = offset + (i * theta), - xx = Math.cos(angle) * radius, - yy = Math.sin(angle) * radius; - - path += 'L ' + xx.toFixed(3) + ' ' + yy.toFixed(3) + ' '; - } - - var polygon = { - label: 'Polygon Body', - position: { x: x, y: y }, - vertices: Vertices.fromPath(path) - }; - - if (options.chamfer) { - var chamfer = options.chamfer; - polygon.vertices = Vertices.chamfer(polygon.vertices, chamfer.radius, - chamfer.quality, chamfer.qualityMin, chamfer.qualityMax); - delete options.chamfer; - } - - return Body.create(Common.extend({}, polygon, options)); - }; - - /** - * Creates a body using the supplied vertices (or an array containing multiple sets of vertices). - * If the vertices are convex, they will pass through as supplied. - * Otherwise if the vertices are concave, they will be decomposed if [poly-decomp.js](https://github.com/schteppe/poly-decomp.js) is available. - * Note that this process is not guaranteed to support complex sets of vertices (e.g. those with holes may fail). - * By default the decomposition will discard collinear edges (to improve performance). - * It can also optionally discard any parts that have an area less than `minimumArea`. - * If the vertices can not be decomposed, the result will fall back to using the convex hull. - * The options parameter is an object that specifies any `Matter.Body` properties you wish to override the defaults. - * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. - * @method fromVertices - * @param {number} x - * @param {number} y - * @param [[vector]] vertexSets - * @param {object} [options] - * @param {bool} [flagInternal=false] - * @param {number} [removeCollinear=0.01] - * @param {number} [minimumArea=10] - * @return {body} - */ - Bodies.fromVertices = function(x, y, vertexSets, options, flagInternal, removeCollinear, minimumArea) { - var body, - parts, - isConvex, - vertices, - i, - j, - k, - v, - z; - - options = options || {}; - parts = []; - - flagInternal = typeof flagInternal !== 'undefined' ? flagInternal : false; - removeCollinear = typeof removeCollinear !== 'undefined' ? removeCollinear : 0.01; - minimumArea = typeof minimumArea !== 'undefined' ? minimumArea : 10; - - if (!decomp) { - Common.warn('Bodies.fromVertices: poly-decomp.js required. Could not decompose vertices. Fallback to convex hull.'); - } - - // ensure vertexSets is an array of arrays - if (!Common.isArray(vertexSets[0])) { - vertexSets = [vertexSets]; - } - - for (v = 0; v < vertexSets.length; v += 1) { - vertices = vertexSets[v]; - isConvex = Vertices.isConvex(vertices); - - if (isConvex || !decomp) { - if (isConvex) { - vertices = Vertices.clockwiseSort(vertices); - } else { - // fallback to convex hull when decomposition is not possible - vertices = Vertices.hull(vertices); - } - - parts.push({ - position: { x: x, y: y }, - vertices: vertices - }); - } else { - // initialise a decomposition - var concave = vertices.map(function(vertex) { - return [vertex.x, vertex.y]; - }); - - // vertices are concave and simple, we can decompose into parts - decomp.makeCCW(concave); - if (removeCollinear !== false) - decomp.removeCollinearPoints(concave, removeCollinear); - - // use the quick decomposition algorithm (Bayazit) - var decomposed = decomp.quickDecomp(concave); - - // for each decomposed chunk - for (i = 0; i < decomposed.length; i++) { - var chunk = decomposed[i]; - - // convert vertices into the correct structure - var chunkVertices = chunk.map(function(vertices) { - return { - x: vertices[0], - y: vertices[1] - }; - }); - - // skip small chunks - if (minimumArea > 0 && Vertices.area(chunkVertices) < minimumArea) - continue; - - // create a compound part - parts.push({ - position: Vertices.centre(chunkVertices), - vertices: chunkVertices - }); - } - } - } - - // create body parts - for (i = 0; i < parts.length; i++) { - parts[i] = Body.create(Common.extend(parts[i], options)); - } - - // flag internal edges (coincident part edges) - if (flagInternal) { - var coincident_max_dist = 5; - - for (i = 0; i < parts.length; i++) { - var partA = parts[i]; - - for (j = i + 1; j < parts.length; j++) { - var partB = parts[j]; - - if (Bounds.overlaps(partA.bounds, partB.bounds)) { - var pav = partA.vertices, - pbv = partB.vertices; - - // iterate vertices of both parts - for (k = 0; k < partA.vertices.length; k++) { - for (z = 0; z < partB.vertices.length; z++) { - // find distances between the vertices - var da = Vector.magnitudeSquared(Vector.sub(pav[(k + 1) % pav.length], pbv[z])), - db = Vector.magnitudeSquared(Vector.sub(pav[k], pbv[(z + 1) % pbv.length])); - - // if both vertices are very close, consider the edge concident (internal) - if (da < coincident_max_dist && db < coincident_max_dist) { - pav[k].isInternal = true; - pbv[z].isInternal = true; - } - } - } - - } - } - } - } - - if (parts.length > 1) { - // create the parent body to be returned, that contains generated compound parts - body = Body.create(Common.extend({ parts: parts.slice(0) }, options)); - Body.setPosition(body, { x: x, y: y }); - - return body; - } else { - return parts[0]; - } - }; - })(); /***/ }), -/* 93 */ +/* 90 */ +/***/ (function(module, exports) { + +/** +* The `Matter.Vector` module contains methods for creating and manipulating vectors. +* Vectors are the basis of all the geometry related operations in the engine. +* A `Matter.Vector` object is of the form `{ x: 0, y: 0 }`. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Vector +*/ + +// TODO: consider params for reusing vector objects + +var Vector = {}; + +module.exports = Vector; + +(function() { + + /** + * Creates a new vector. + * @method create + * @param {number} x + * @param {number} y + * @return {vector} A new vector + */ + Vector.create = function(x, y) { + return { x: x || 0, y: y || 0 }; + }; + + /** + * Returns a new vector with `x` and `y` copied from the given `vector`. + * @method clone + * @param {vector} vector + * @return {vector} A new cloned vector + */ + Vector.clone = function(vector) { + return { x: vector.x, y: vector.y }; + }; + + /** + * Returns the magnitude (length) of a vector. + * @method magnitude + * @param {vector} vector + * @return {number} The magnitude of the vector + */ + Vector.magnitude = function(vector) { + return Math.sqrt((vector.x * vector.x) + (vector.y * vector.y)); + }; + + /** + * Returns the magnitude (length) of a vector (therefore saving a `sqrt` operation). + * @method magnitudeSquared + * @param {vector} vector + * @return {number} The squared magnitude of the vector + */ + Vector.magnitudeSquared = function(vector) { + return (vector.x * vector.x) + (vector.y * vector.y); + }; + + /** + * Rotates the vector about (0, 0) by specified angle. + * @method rotate + * @param {vector} vector + * @param {number} angle + * @param {vector} [output] + * @return {vector} The vector rotated about (0, 0) + */ + Vector.rotate = function(vector, angle, output) { + var cos = Math.cos(angle), sin = Math.sin(angle); + if (!output) output = {}; + var x = vector.x * cos - vector.y * sin; + output.y = vector.x * sin + vector.y * cos; + output.x = x; + return output; + }; + + /** + * Rotates the vector about a specified point by specified angle. + * @method rotateAbout + * @param {vector} vector + * @param {number} angle + * @param {vector} point + * @param {vector} [output] + * @return {vector} A new vector rotated about the point + */ + Vector.rotateAbout = function(vector, angle, point, output) { + var cos = Math.cos(angle), sin = Math.sin(angle); + if (!output) output = {}; + var x = point.x + ((vector.x - point.x) * cos - (vector.y - point.y) * sin); + output.y = point.y + ((vector.x - point.x) * sin + (vector.y - point.y) * cos); + output.x = x; + return output; + }; + + /** + * Normalises a vector (such that its magnitude is `1`). + * @method normalise + * @param {vector} vector + * @return {vector} A new vector normalised + */ + Vector.normalise = function(vector) { + var magnitude = Vector.magnitude(vector); + if (magnitude === 0) + return { x: 0, y: 0 }; + return { x: vector.x / magnitude, y: vector.y / magnitude }; + }; + + /** + * Returns the dot-product of two vectors. + * @method dot + * @param {vector} vectorA + * @param {vector} vectorB + * @return {number} The dot product of the two vectors + */ + Vector.dot = function(vectorA, vectorB) { + return (vectorA.x * vectorB.x) + (vectorA.y * vectorB.y); + }; + + /** + * Returns the cross-product of two vectors. + * @method cross + * @param {vector} vectorA + * @param {vector} vectorB + * @return {number} The cross product of the two vectors + */ + Vector.cross = function(vectorA, vectorB) { + return (vectorA.x * vectorB.y) - (vectorA.y * vectorB.x); + }; + + /** + * Returns the cross-product of three vectors. + * @method cross3 + * @param {vector} vectorA + * @param {vector} vectorB + * @param {vector} vectorC + * @return {number} The cross product of the three vectors + */ + Vector.cross3 = function(vectorA, vectorB, vectorC) { + return (vectorB.x - vectorA.x) * (vectorC.y - vectorA.y) - (vectorB.y - vectorA.y) * (vectorC.x - vectorA.x); + }; + + /** + * Adds the two vectors. + * @method add + * @param {vector} vectorA + * @param {vector} vectorB + * @param {vector} [output] + * @return {vector} A new vector of vectorA and vectorB added + */ + Vector.add = function(vectorA, vectorB, output) { + if (!output) output = {}; + output.x = vectorA.x + vectorB.x; + output.y = vectorA.y + vectorB.y; + return output; + }; + + /** + * Subtracts the two vectors. + * @method sub + * @param {vector} vectorA + * @param {vector} vectorB + * @param {vector} [output] + * @return {vector} A new vector of vectorA and vectorB subtracted + */ + Vector.sub = function(vectorA, vectorB, output) { + if (!output) output = {}; + output.x = vectorA.x - vectorB.x; + output.y = vectorA.y - vectorB.y; + return output; + }; + + /** + * Multiplies a vector and a scalar. + * @method mult + * @param {vector} vector + * @param {number} scalar + * @return {vector} A new vector multiplied by scalar + */ + Vector.mult = function(vector, scalar) { + return { x: vector.x * scalar, y: vector.y * scalar }; + }; + + /** + * Divides a vector and a scalar. + * @method div + * @param {vector} vector + * @param {number} scalar + * @return {vector} A new vector divided by scalar + */ + Vector.div = function(vector, scalar) { + return { x: vector.x / scalar, y: vector.y / scalar }; + }; + + /** + * Returns the perpendicular vector. Set `negate` to true for the perpendicular in the opposite direction. + * @method perp + * @param {vector} vector + * @param {bool} [negate=false] + * @return {vector} The perpendicular vector + */ + Vector.perp = function(vector, negate) { + negate = negate === true ? -1 : 1; + return { x: negate * -vector.y, y: negate * vector.x }; + }; + + /** + * Negates both components of a vector such that it points in the opposite direction. + * @method neg + * @param {vector} vector + * @return {vector} The negated vector + */ + Vector.neg = function(vector) { + return { x: -vector.x, y: -vector.y }; + }; + + /** + * Returns the angle in radians between the two vectors relative to the x-axis. + * @method angle + * @param {vector} vectorA + * @param {vector} vectorB + * @return {number} The angle in radians + */ + Vector.angle = function(vectorA, vectorB) { + return Math.atan2(vectorB.y - vectorA.y, vectorB.x - vectorA.x); + }; + + /** + * Temporary vector pool (not thread-safe). + * @property _temp + * @type {vector[]} + * @private + */ + Vector._temp = [ + Vector.create(), Vector.create(), + Vector.create(), Vector.create(), + Vector.create(), Vector.create() + ]; + +})(); + +/***/ }), +/* 91 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -17765,8 +15360,8 @@ var Vertices = {}; module.exports = Vertices; -var Vector = __webpack_require__(94); -var Common = __webpack_require__(38); +var Vector = __webpack_require__(90); +var Common = __webpack_require__(39); (function() { @@ -18211,374 +15806,590 @@ var Common = __webpack_require__(38); })(); +/***/ }), +/* 92 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Bodies` module contains factory methods for creating rigid body models +* with commonly used body configurations (such as rectangles, circles and other polygons). +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Bodies +*/ + +// TODO: true circle bodies + +var Bodies = {}; + +module.exports = Bodies; + +var Vertices = __webpack_require__(91); +var Common = __webpack_require__(39); +var Body = __webpack_require__(49); +var Bounds = __webpack_require__(89); +var Vector = __webpack_require__(90); +var decomp = __webpack_require__(963); + +(function() { + + /** + * Creates a new rigid body model with a rectangle hull. + * The options parameter is an object that specifies any properties you wish to override the defaults. + * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. + * @method rectangle + * @param {number} x + * @param {number} y + * @param {number} width + * @param {number} height + * @param {object} [options] + * @return {body} A new rectangle body + */ + Bodies.rectangle = function(x, y, width, height, options) { + options = options || {}; + + var rectangle = { + label: 'Rectangle Body', + position: { x: x, y: y }, + vertices: Vertices.fromPath('L 0 0 L ' + width + ' 0 L ' + width + ' ' + height + ' L 0 ' + height) + }; + + if (options.chamfer) { + var chamfer = options.chamfer; + rectangle.vertices = Vertices.chamfer(rectangle.vertices, chamfer.radius, + chamfer.quality, chamfer.qualityMin, chamfer.qualityMax); + delete options.chamfer; + } + + return Body.create(Common.extend({}, rectangle, options)); + }; + + /** + * Creates a new rigid body model with a trapezoid hull. + * The options parameter is an object that specifies any properties you wish to override the defaults. + * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. + * @method trapezoid + * @param {number} x + * @param {number} y + * @param {number} width + * @param {number} height + * @param {number} slope + * @param {object} [options] + * @return {body} A new trapezoid body + */ + Bodies.trapezoid = function(x, y, width, height, slope, options) { + options = options || {}; + + slope *= 0.5; + var roof = (1 - (slope * 2)) * width; + + var x1 = width * slope, + x2 = x1 + roof, + x3 = x2 + x1, + verticesPath; + + if (slope < 0.5) { + verticesPath = 'L 0 0 L ' + x1 + ' ' + (-height) + ' L ' + x2 + ' ' + (-height) + ' L ' + x3 + ' 0'; + } else { + verticesPath = 'L 0 0 L ' + x2 + ' ' + (-height) + ' L ' + x3 + ' 0'; + } + + var trapezoid = { + label: 'Trapezoid Body', + position: { x: x, y: y }, + vertices: Vertices.fromPath(verticesPath) + }; + + if (options.chamfer) { + var chamfer = options.chamfer; + trapezoid.vertices = Vertices.chamfer(trapezoid.vertices, chamfer.radius, + chamfer.quality, chamfer.qualityMin, chamfer.qualityMax); + delete options.chamfer; + } + + return Body.create(Common.extend({}, trapezoid, options)); + }; + + /** + * Creates a new rigid body model with a circle hull. + * The options parameter is an object that specifies any properties you wish to override the defaults. + * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. + * @method circle + * @param {number} x + * @param {number} y + * @param {number} radius + * @param {object} [options] + * @param {number} [maxSides] + * @return {body} A new circle body + */ + Bodies.circle = function(x, y, radius, options, maxSides) { + options = options || {}; + + var circle = { + label: 'Circle Body', + circleRadius: radius + }; + + // approximate circles with polygons until true circles implemented in SAT + maxSides = maxSides || 25; + var sides = Math.ceil(Math.max(10, Math.min(maxSides, radius))); + + // optimisation: always use even number of sides (half the number of unique axes) + if (sides % 2 === 1) + sides += 1; + + return Bodies.polygon(x, y, sides, radius, Common.extend({}, circle, options)); + }; + + /** + * Creates a new rigid body model with a regular polygon hull with the given number of sides. + * The options parameter is an object that specifies any properties you wish to override the defaults. + * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. + * @method polygon + * @param {number} x + * @param {number} y + * @param {number} sides + * @param {number} radius + * @param {object} [options] + * @return {body} A new regular polygon body + */ + Bodies.polygon = function(x, y, sides, radius, options) { + options = options || {}; + + if (sides < 3) + return Bodies.circle(x, y, radius, options); + + var theta = 2 * Math.PI / sides, + path = '', + offset = theta * 0.5; + + for (var i = 0; i < sides; i += 1) { + var angle = offset + (i * theta), + xx = Math.cos(angle) * radius, + yy = Math.sin(angle) * radius; + + path += 'L ' + xx.toFixed(3) + ' ' + yy.toFixed(3) + ' '; + } + + var polygon = { + label: 'Polygon Body', + position: { x: x, y: y }, + vertices: Vertices.fromPath(path) + }; + + if (options.chamfer) { + var chamfer = options.chamfer; + polygon.vertices = Vertices.chamfer(polygon.vertices, chamfer.radius, + chamfer.quality, chamfer.qualityMin, chamfer.qualityMax); + delete options.chamfer; + } + + return Body.create(Common.extend({}, polygon, options)); + }; + + /** + * Creates a body using the supplied vertices (or an array containing multiple sets of vertices). + * If the vertices are convex, they will pass through as supplied. + * Otherwise if the vertices are concave, they will be decomposed if [poly-decomp.js](https://github.com/schteppe/poly-decomp.js) is available. + * Note that this process is not guaranteed to support complex sets of vertices (e.g. those with holes may fail). + * By default the decomposition will discard collinear edges (to improve performance). + * It can also optionally discard any parts that have an area less than `minimumArea`. + * If the vertices can not be decomposed, the result will fall back to using the convex hull. + * The options parameter is an object that specifies any `Matter.Body` properties you wish to override the defaults. + * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. + * @method fromVertices + * @param {number} x + * @param {number} y + * @param [[vector]] vertexSets + * @param {object} [options] + * @param {bool} [flagInternal=false] + * @param {number} [removeCollinear=0.01] + * @param {number} [minimumArea=10] + * @return {body} + */ + Bodies.fromVertices = function(x, y, vertexSets, options, flagInternal, removeCollinear, minimumArea) { + var body, + parts, + isConvex, + vertices, + i, + j, + k, + v, + z; + + options = options || {}; + parts = []; + + flagInternal = typeof flagInternal !== 'undefined' ? flagInternal : false; + removeCollinear = typeof removeCollinear !== 'undefined' ? removeCollinear : 0.01; + minimumArea = typeof minimumArea !== 'undefined' ? minimumArea : 10; + + if (!decomp) { + Common.warn('Bodies.fromVertices: poly-decomp.js required. Could not decompose vertices. Fallback to convex hull.'); + } + + // ensure vertexSets is an array of arrays + if (!Common.isArray(vertexSets[0])) { + vertexSets = [vertexSets]; + } + + for (v = 0; v < vertexSets.length; v += 1) { + vertices = vertexSets[v]; + isConvex = Vertices.isConvex(vertices); + + if (isConvex || !decomp) { + if (isConvex) { + vertices = Vertices.clockwiseSort(vertices); + } else { + // fallback to convex hull when decomposition is not possible + vertices = Vertices.hull(vertices); + } + + parts.push({ + position: { x: x, y: y }, + vertices: vertices + }); + } else { + // initialise a decomposition + var concave = vertices.map(function(vertex) { + return [vertex.x, vertex.y]; + }); + + // vertices are concave and simple, we can decompose into parts + decomp.makeCCW(concave); + if (removeCollinear !== false) + decomp.removeCollinearPoints(concave, removeCollinear); + + // use the quick decomposition algorithm (Bayazit) + var decomposed = decomp.quickDecomp(concave); + + // for each decomposed chunk + for (i = 0; i < decomposed.length; i++) { + var chunk = decomposed[i]; + + // convert vertices into the correct structure + var chunkVertices = chunk.map(function(vertices) { + return { + x: vertices[0], + y: vertices[1] + }; + }); + + // skip small chunks + if (minimumArea > 0 && Vertices.area(chunkVertices) < minimumArea) + continue; + + // create a compound part + parts.push({ + position: Vertices.centre(chunkVertices), + vertices: chunkVertices + }); + } + } + } + + // create body parts + for (i = 0; i < parts.length; i++) { + parts[i] = Body.create(Common.extend(parts[i], options)); + } + + // flag internal edges (coincident part edges) + if (flagInternal) { + var coincident_max_dist = 5; + + for (i = 0; i < parts.length; i++) { + var partA = parts[i]; + + for (j = i + 1; j < parts.length; j++) { + var partB = parts[j]; + + if (Bounds.overlaps(partA.bounds, partB.bounds)) { + var pav = partA.vertices, + pbv = partB.vertices; + + // iterate vertices of both parts + for (k = 0; k < partA.vertices.length; k++) { + for (z = 0; z < partB.vertices.length; z++) { + // find distances between the vertices + var da = Vector.magnitudeSquared(Vector.sub(pav[(k + 1) % pav.length], pbv[z])), + db = Vector.magnitudeSquared(Vector.sub(pav[k], pbv[(z + 1) % pbv.length])); + + // if both vertices are very close, consider the edge concident (internal) + if (da < coincident_max_dist && db < coincident_max_dist) { + pav[k].isInternal = true; + pbv[z].isInternal = true; + } + } + } + + } + } + } + } + + if (parts.length > 1) { + // create the parent body to be returned, that contains generated compound parts + body = Body.create(Common.extend({ parts: parts.slice(0) }, options)); + Body.setPosition(body, { x: x, y: y }); + + return body; + } else { + return parts[0]; + } + }; + +})(); + + +/***/ }), +/* 93 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(213); +var Sprite = __webpack_require__(40); + +/** + * @classdesc + * An Arcade Physics Sprite Game Object. + * + * A Sprite Game Object is used for the display of both static and animated images in your game. + * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled + * and animated. + * + * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. + * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation + * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. + * + * @class Sprite + * @extends Phaser.GameObjects.Sprite + * @memberOf Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @extends Phaser.Physics.Arcade.Components.Acceleration + * @extends Phaser.Physics.Arcade.Components.Angular + * @extends Phaser.Physics.Arcade.Components.Bounce + * @extends Phaser.Physics.Arcade.Components.Debug + * @extends Phaser.Physics.Arcade.Components.Drag + * @extends Phaser.Physics.Arcade.Components.Enable + * @extends Phaser.Physics.Arcade.Components.Friction + * @extends Phaser.Physics.Arcade.Components.Gravity + * @extends Phaser.Physics.Arcade.Components.Immovable + * @extends Phaser.Physics.Arcade.Components.Mass + * @extends Phaser.Physics.Arcade.Components.Size + * @extends Phaser.Physics.Arcade.Components.Velocity + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.Animation + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var ArcadeSprite = new Class({ + + Extends: Sprite, + + Mixins: [ + Components.Acceleration, + Components.Angular, + Components.Bounce, + Components.Debug, + Components.Drag, + Components.Enable, + Components.Friction, + Components.Gravity, + Components.Immovable, + Components.Mass, + Components.Size, + Components.Velocity + ], + + initialize: + + function ArcadeSprite (scene, x, y, texture, frame) + { + Sprite.call(this, scene, x, y, texture, frame); + } + +}); + +module.exports = ArcadeSprite; + + /***/ }), /* 94 */ /***/ (function(module, exports) { /** -* The `Matter.Vector` module contains methods for creating and manipulating vectors. -* Vectors are the basis of all the geometry related operations in the engine. -* A `Matter.Vector` object is of the form `{ x: 0, y: 0 }`. -* -* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). -* -* @class Vector -*/ + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ -// TODO: consider params for reusing vector objects +/** + * @typedef {object} XHRSettingsObject + * + * @property {XMLHttpRequestResponseType} responseType - [description] + * @property {boolean} async - [description] + * @property {string} user - [description] + * @property {string} password - [description] + * @property {number} timeout - [description] + * @property {?string} header - [description] + * @property {?string} headerValue - [description] + * @property {(string|undefined)} overrideMimeType - [description] + */ -var Vector = {}; +/** + * Creates an XHRSettings Object with default values. + * + * @function Phaser.Loader.XHRSettings + * @since 3.0.0 + * + * @param {XMLHttpRequestResponseType} [responseType=''] - The responseType, such as 'text'. + * @param {boolean} [async=true] - Should the XHR request use async or not? + * @param {string} [user=''] - Optional username for the XHR request. + * @param {string} [password=''] - Optional password for the XHR request. + * @param {integer} [timeout=0] - Optional XHR timeout value. + * + * @return {XHRSettingsObject} The XHRSettings object as used by the Loader. + */ +var XHRSettings = function (responseType, async, user, password, timeout) +{ + if (responseType === undefined) { responseType = ''; } + if (async === undefined) { async = true; } + if (user === undefined) { user = ''; } + if (password === undefined) { password = ''; } + if (timeout === undefined) { timeout = 0; } -module.exports = Vector; + // Before sending a request, set the xhr.responseType to "text", + // "arraybuffer", "blob", or "document", depending on your data needs. + // Note, setting xhr.responseType = '' (or omitting) will default the response to "text". -(function() { + return { + + // Ignored by the Loader, only used by File. + responseType: responseType, + + async: async, + + // credentials + user: user, + password: password, + + // timeout in ms (0 = no timeout) + timeout: timeout, + + // setRequestHeader + header: undefined, + headerValue: undefined, + + // overrideMimeType + overrideMimeType: undefined - /** - * Creates a new vector. - * @method create - * @param {number} x - * @param {number} y - * @return {vector} A new vector - */ - Vector.create = function(x, y) { - return { x: x || 0, y: y || 0 }; }; +}; - /** - * Returns a new vector with `x` and `y` copied from the given `vector`. - * @method clone - * @param {vector} vector - * @return {vector} A new cloned vector - */ - Vector.clone = function(vector) { - return { x: vector.x, y: vector.y }; - }; +module.exports = XHRSettings; - /** - * Returns the magnitude (length) of a vector. - * @method magnitude - * @param {vector} vector - * @return {number} The magnitude of the vector - */ - Vector.magnitude = function(vector) { - return Math.sqrt((vector.x * vector.x) + (vector.y * vector.y)); - }; - - /** - * Returns the magnitude (length) of a vector (therefore saving a `sqrt` operation). - * @method magnitudeSquared - * @param {vector} vector - * @return {number} The squared magnitude of the vector - */ - Vector.magnitudeSquared = function(vector) { - return (vector.x * vector.x) + (vector.y * vector.y); - }; - - /** - * Rotates the vector about (0, 0) by specified angle. - * @method rotate - * @param {vector} vector - * @param {number} angle - * @param {vector} [output] - * @return {vector} The vector rotated about (0, 0) - */ - Vector.rotate = function(vector, angle, output) { - var cos = Math.cos(angle), sin = Math.sin(angle); - if (!output) output = {}; - var x = vector.x * cos - vector.y * sin; - output.y = vector.x * sin + vector.y * cos; - output.x = x; - return output; - }; - - /** - * Rotates the vector about a specified point by specified angle. - * @method rotateAbout - * @param {vector} vector - * @param {number} angle - * @param {vector} point - * @param {vector} [output] - * @return {vector} A new vector rotated about the point - */ - Vector.rotateAbout = function(vector, angle, point, output) { - var cos = Math.cos(angle), sin = Math.sin(angle); - if (!output) output = {}; - var x = point.x + ((vector.x - point.x) * cos - (vector.y - point.y) * sin); - output.y = point.y + ((vector.x - point.x) * sin + (vector.y - point.y) * cos); - output.x = x; - return output; - }; - - /** - * Normalises a vector (such that its magnitude is `1`). - * @method normalise - * @param {vector} vector - * @return {vector} A new vector normalised - */ - Vector.normalise = function(vector) { - var magnitude = Vector.magnitude(vector); - if (magnitude === 0) - return { x: 0, y: 0 }; - return { x: vector.x / magnitude, y: vector.y / magnitude }; - }; - - /** - * Returns the dot-product of two vectors. - * @method dot - * @param {vector} vectorA - * @param {vector} vectorB - * @return {number} The dot product of the two vectors - */ - Vector.dot = function(vectorA, vectorB) { - return (vectorA.x * vectorB.x) + (vectorA.y * vectorB.y); - }; - - /** - * Returns the cross-product of two vectors. - * @method cross - * @param {vector} vectorA - * @param {vector} vectorB - * @return {number} The cross product of the two vectors - */ - Vector.cross = function(vectorA, vectorB) { - return (vectorA.x * vectorB.y) - (vectorA.y * vectorB.x); - }; - - /** - * Returns the cross-product of three vectors. - * @method cross3 - * @param {vector} vectorA - * @param {vector} vectorB - * @param {vector} vectorC - * @return {number} The cross product of the three vectors - */ - Vector.cross3 = function(vectorA, vectorB, vectorC) { - return (vectorB.x - vectorA.x) * (vectorC.y - vectorA.y) - (vectorB.y - vectorA.y) * (vectorC.x - vectorA.x); - }; - - /** - * Adds the two vectors. - * @method add - * @param {vector} vectorA - * @param {vector} vectorB - * @param {vector} [output] - * @return {vector} A new vector of vectorA and vectorB added - */ - Vector.add = function(vectorA, vectorB, output) { - if (!output) output = {}; - output.x = vectorA.x + vectorB.x; - output.y = vectorA.y + vectorB.y; - return output; - }; - - /** - * Subtracts the two vectors. - * @method sub - * @param {vector} vectorA - * @param {vector} vectorB - * @param {vector} [output] - * @return {vector} A new vector of vectorA and vectorB subtracted - */ - Vector.sub = function(vectorA, vectorB, output) { - if (!output) output = {}; - output.x = vectorA.x - vectorB.x; - output.y = vectorA.y - vectorB.y; - return output; - }; - - /** - * Multiplies a vector and a scalar. - * @method mult - * @param {vector} vector - * @param {number} scalar - * @return {vector} A new vector multiplied by scalar - */ - Vector.mult = function(vector, scalar) { - return { x: vector.x * scalar, y: vector.y * scalar }; - }; - - /** - * Divides a vector and a scalar. - * @method div - * @param {vector} vector - * @param {number} scalar - * @return {vector} A new vector divided by scalar - */ - Vector.div = function(vector, scalar) { - return { x: vector.x / scalar, y: vector.y / scalar }; - }; - - /** - * Returns the perpendicular vector. Set `negate` to true for the perpendicular in the opposite direction. - * @method perp - * @param {vector} vector - * @param {bool} [negate=false] - * @return {vector} The perpendicular vector - */ - Vector.perp = function(vector, negate) { - negate = negate === true ? -1 : 1; - return { x: negate * -vector.y, y: negate * vector.x }; - }; - - /** - * Negates both components of a vector such that it points in the opposite direction. - * @method neg - * @param {vector} vector - * @return {vector} The negated vector - */ - Vector.neg = function(vector) { - return { x: -vector.x, y: -vector.y }; - }; - - /** - * Returns the angle in radians between the two vectors relative to the x-axis. - * @method angle - * @param {vector} vectorA - * @param {vector} vectorB - * @return {number} The angle in radians - */ - Vector.angle = function(vectorA, vectorB) { - return Math.atan2(vectorB.y - vectorA.y, vectorB.x - vectorA.x); - }; - - /** - * Temporary vector pool (not thread-safe). - * @property _temp - * @type {vector[]} - * @private - */ - Vector._temp = [ - Vector.create(), Vector.create(), - Vector.create(), Vector.create(), - Vector.create(), Vector.create() - ]; - -})(); /***/ }), /* 95 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** -* The `Matter.Bounds` module contains methods for creating and manipulating axis-aligned bounding boxes (AABB). -* -* @class Bounds -*/ + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ -var Bounds = {}; +var Point = __webpack_require__(4); -module.exports = Bounds; +// This is based off an explanation and expanded math presented by Paul Bourke: +// See http:'local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/ -(function() { +/** + * [description] + * + * @function Phaser.Geom.Intersects.LineToLine + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line1 - [description] + * @param {Phaser.Geom.Line} line2 - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {boolean} [description] + */ +var LineToLine = function (line1, line2, out) +{ + if (out === undefined) { out = new Point(); } - /** - * Creates a new axis-aligned bounding box (AABB) for the given vertices. - * @method create - * @param {vertices} vertices - * @return {bounds} A new bounds object - */ - Bounds.create = function(vertices) { - var bounds = { - min: { x: 0, y: 0 }, - max: { x: 0, y: 0 } - }; + var x1 = line1.x1; + var y1 = line1.y1; + var x2 = line1.x2; + var y2 = line1.y2; - if (vertices) - Bounds.update(bounds, vertices); - - return bounds; - }; + var x3 = line2.x1; + var y3 = line2.y1; + var x4 = line2.x2; + var y4 = line2.y2; - /** - * Updates bounds using the given vertices and extends the bounds given a velocity. - * @method update - * @param {bounds} bounds - * @param {vertices} vertices - * @param {vector} velocity - */ - Bounds.update = function(bounds, vertices, velocity) { - bounds.min.x = Infinity; - bounds.max.x = -Infinity; - bounds.min.y = Infinity; - bounds.max.y = -Infinity; + var numA = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3); + var numB = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3); + var deNom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); - for (var i = 0; i < vertices.length; i++) { - var vertex = vertices[i]; - if (vertex.x > bounds.max.x) bounds.max.x = vertex.x; - if (vertex.x < bounds.min.x) bounds.min.x = vertex.x; - if (vertex.y > bounds.max.y) bounds.max.y = vertex.y; - if (vertex.y < bounds.min.y) bounds.min.y = vertex.y; - } - - if (velocity) { - if (velocity.x > 0) { - bounds.max.x += velocity.x; - } else { - bounds.min.x += velocity.x; - } - - if (velocity.y > 0) { - bounds.max.y += velocity.y; - } else { - bounds.min.y += velocity.y; - } - } - }; + // Make sure there is not a division by zero - this also indicates that the lines are parallel. + // If numA and numB were both equal to zero the lines would be on top of each other (coincidental). + // This check is not done because it is not necessary for this implementation (the parallel check accounts for this). - /** - * Returns true if the bounds contains the given point. - * @method contains - * @param {bounds} bounds - * @param {vector} point - * @return {boolean} True if the bounds contain the point, otherwise false - */ - Bounds.contains = function(bounds, point) { - return point.x >= bounds.min.x && point.x <= bounds.max.x - && point.y >= bounds.min.y && point.y <= bounds.max.y; - }; + if (deNom === 0) + { + return false; + } - /** - * Returns true if the two bounds intersect. - * @method overlaps - * @param {bounds} boundsA - * @param {bounds} boundsB - * @return {boolean} True if the bounds overlap, otherwise false - */ - Bounds.overlaps = function(boundsA, boundsB) { - return (boundsA.min.x <= boundsB.max.x && boundsA.max.x >= boundsB.min.x - && boundsA.max.y >= boundsB.min.y && boundsA.min.y <= boundsB.max.y); - }; + // Calculate the intermediate fractional point that the lines potentially intersect. - /** - * Translates the bounds by the given vector. - * @method translate - * @param {bounds} bounds - * @param {vector} vector - */ - Bounds.translate = function(bounds, vector) { - bounds.min.x += vector.x; - bounds.max.x += vector.x; - bounds.min.y += vector.y; - bounds.max.y += vector.y; - }; + var uA = numA / deNom; + var uB = numB / deNom; - /** - * Shifts the bounds to the given position. - * @method shift - * @param {bounds} bounds - * @param {vector} position - */ - Bounds.shift = function(bounds, position) { - var deltaX = bounds.max.x - bounds.min.x, - deltaY = bounds.max.y - bounds.min.y; - - bounds.min.x = position.x; - bounds.max.x = position.x + deltaX; - bounds.min.y = position.y; - bounds.max.y = position.y + deltaY; - }; - -})(); + // The fractional point will be between 0 and 1 inclusive if the lines intersect. + // If the fractional calculation is larger than 1 or smaller than 0 the lines would need to be longer to intersect. + + if (uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1) + { + out.x = x1 + (uA * (x2 - x1)); + out.y = y1 + (uA * (y2 - y1)); + + return true; + } + + return false; +}; + +module.exports = LineToLine; /***/ }), @@ -18591,56 +16402,154 @@ module.exports = Bounds; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var GameObject = __webpack_require__(1); +var MeshRender = __webpack_require__(670); + /** - * @namespace Phaser.Tilemaps.Components + * @classdesc + * A Mesh Game Object. + * + * @class Mesh + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor + * @webglOnly + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * @extends Phaser.GameObjects.Components.ScrollFactor + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {array} vertices - An array containing the vertices data for this Mesh. + * @param {array} uv - An array containing the uv data for this Mesh. + * @param {array} colors - An array containing the color data for this Mesh. + * @param {array} alphas - An array containing the alpha data for this Mesh. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. */ +var Mesh = new Class({ -module.exports = { + Extends: GameObject, - CalculateFacesAt: __webpack_require__(153), - CalculateFacesWithin: __webpack_require__(34), - Copy: __webpack_require__(874), - CreateFromTiles: __webpack_require__(875), - CullTiles: __webpack_require__(876), - Fill: __webpack_require__(877), - FilterTiles: __webpack_require__(878), - FindByIndex: __webpack_require__(879), - FindTile: __webpack_require__(880), - ForEachTile: __webpack_require__(881), - GetTileAt: __webpack_require__(97), - GetTileAtWorldXY: __webpack_require__(882), - GetTilesWithin: __webpack_require__(15), - GetTilesWithinShape: __webpack_require__(883), - GetTilesWithinWorldXY: __webpack_require__(884), - HasTileAt: __webpack_require__(345), - HasTileAtWorldXY: __webpack_require__(885), - IsInLayerBounds: __webpack_require__(74), - PutTileAt: __webpack_require__(154), - PutTileAtWorldXY: __webpack_require__(886), - PutTilesAt: __webpack_require__(887), - Randomize: __webpack_require__(888), - RemoveTileAt: __webpack_require__(346), - RemoveTileAtWorldXY: __webpack_require__(889), - RenderDebug: __webpack_require__(890), - ReplaceByIndex: __webpack_require__(344), - SetCollision: __webpack_require__(891), - SetCollisionBetween: __webpack_require__(892), - SetCollisionByExclusion: __webpack_require__(893), - SetCollisionByProperty: __webpack_require__(894), - SetCollisionFromCollisionGroup: __webpack_require__(895), - SetTileIndexCallback: __webpack_require__(896), - SetTileLocationCallback: __webpack_require__(897), - Shuffle: __webpack_require__(898), - SwapByIndex: __webpack_require__(899), - TileToWorldX: __webpack_require__(98), - TileToWorldXY: __webpack_require__(900), - TileToWorldY: __webpack_require__(99), - WeightedRandomize: __webpack_require__(901), - WorldToTileX: __webpack_require__(39), - WorldToTileXY: __webpack_require__(902), - WorldToTileY: __webpack_require__(40) + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.Size, + Components.Texture, + Components.Transform, + Components.Visible, + Components.ScrollFactor, + MeshRender + ], -}; + initialize: + + function Mesh (scene, x, y, vertices, uv, colors, alphas, texture, frame) + { + GameObject.call(this, scene, 'Mesh'); + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.setSizeToFrame(); + this.setOrigin(); + this.initPipeline('TextureTintPipeline'); + + if (vertices.length !== uv.length) + { + throw new Error('Mesh Vertex count must match UV count'); + } + + var verticesUB = (vertices.length / 2) | 0; + + if (colors.length > 0 && colors.length < verticesUB) + { + throw new Error('Mesh Color count must match Vertex count'); + } + + if (alphas.length > 0 && alphas.length < verticesUB) + { + throw new Error('Mesh Alpha count must match Vertex count'); + } + + var i; + + if (colors.length === 0) + { + for (i = 0; i < verticesUB; ++i) + { + colors[i] = 0xFFFFFF; + } + } + + if (alphas.length === 0) + { + for (i = 0; i < verticesUB; ++i) + { + alphas[i] = 1.0; + } + } + + /** + * [description] + * + * @name Phaser.GameObjects.Mesh#vertices + * @type {Float32Array} + * @since 3.0.0 + */ + this.vertices = new Float32Array(vertices); + + /** + * [description] + * + * @name Phaser.GameObjects.Mesh#uv + * @type {Float32Array} + * @since 3.0.0 + */ + this.uv = new Float32Array(uv); + + /** + * [description] + * + * @name Phaser.GameObjects.Mesh#colors + * @type {Uint32Array} + * @since 3.0.0 + */ + this.colors = new Uint32Array(colors); + + /** + * [description] + * + * @name Phaser.GameObjects.Mesh#alphas + * @type {Float32Array} + * @since 3.0.0 + */ + this.alphas = new Float32Array(alphas); + } + +}); + +module.exports = Mesh; /***/ }), @@ -18653,138 +16562,2239 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var IsInLayerBounds = __webpack_require__(74); +var Class = __webpack_require__(0); /** - * Gets a tile at the given tile coordinates from the given layer. + * @callback EachListCallback * - * @function Phaser.Tilemaps.Components.GetTileAt + * @param {*} item - [description] + * @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the child. + */ + +/** + * @classdesc + * [description] + * + * @class List + * @memberOf Phaser.Structs + * @constructor * @since 3.0.0 * - * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). - * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). - * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates - * were invalid. + * @param {*} parent - [description] */ -var GetTileAt = function (tileX, tileY, nonNull, layer) -{ - if (nonNull === undefined) { nonNull = false; } +var List = new Class({ - if (IsInLayerBounds(tileX, tileY, layer)) + initialize: + + function List (parent) { - var tile = layer.data[tileY][tileX]; - if (tile === null) + /** + * The parent of this list. + * + * @name Phaser.Structs.List#parent + * @type {*} + * @since 3.0.0 + */ + this.parent = parent; + + /** + * The objects that belong to this collection. + * + * @name Phaser.Structs.List#list + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.list = []; + + /** + * [description] + * + * @name Phaser.Structs.List#position + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.position = 0; + }, + + /** + * [description] + * + * @method Phaser.Structs.List#add + * @since 3.0.0 + * + * @param {object} child - [description] + * + * @return {object} [description] + */ + add: function (child) + { + // Is child already in this display list? + + if (this.getIndex(child) === -1) + { + this.list.push(child); + } + + return child; + }, + + /** + * [description] + * + * @method Phaser.Structs.List#addAt + * @since 3.0.0 + * + * @param {object} child - [description] + * @param {integer} index - [description] + * + * @return {object} [description] + */ + addAt: function (child, index) + { + if (index === undefined) { index = 0; } + + if (this.list.length === 0) + { + return this.add(child); + } + + if (index >= 0 && index <= this.list.length) + { + if (this.getIndex(child) === -1) + { + this.list.splice(index, 0, child); + } + } + + return child; + }, + + /** + * [description] + * + * @method Phaser.Structs.List#addMultiple + * @since 3.0.0 + * + * @param {array} children - [description] + * + * @return {array} [description] + */ + addMultiple: function (children) + { + if (Array.isArray(children)) + { + for (var i = 0; i < children.length; i++) + { + this.add(children[i]); + } + } + + return children; + }, + + /** + * [description] + * + * @method Phaser.Structs.List#getAt + * @since 3.0.0 + * + * @param {integer} index - [description] + * + * @return {object} [description] + */ + getAt: function (index) + { + return this.list[index]; + }, + + /** + * [description] + * + * @method Phaser.Structs.List#getIndex + * @since 3.0.0 + * + * @param {object} child - [description] + * + * @return {integer} [description] + */ + getIndex: function (child) + { + // Return -1 if given child isn't a child of this display list + return this.list.indexOf(child); + }, + + /** + * Given an array of objects, sort the array and return it, + * so that the objects are in index order with the lowest at the bottom. + * + * @method Phaser.Structs.List#sort + * @since 3.0.0 + * + * @param {array} children - [description] + * + * @return {array} [description] + */ + sort: function (children) + { + if (children === undefined) { children = this.list; } + + return children.sort(this.sortIndexHandler.bind(this)); + }, + + /** + * [description] + * + * @method Phaser.Structs.List#sortIndexHandler + * @since 3.0.0 + * + * @param {object} childA - [description] + * @param {object} childB - [description] + * + * @return {integer} [description] + */ + sortIndexHandler: function (childA, childB) + { + // The lower the index, the lower down the display list they are + var indexA = this.getIndex(childA); + var indexB = this.getIndex(childB); + + if (indexA < indexB) + { + return -1; + } + else if (indexA > indexB) + { + return 1; + } + + // Technically this shouldn't happen, but if the GO wasn't part of this display list then it'll + // have an index of -1, so in some cases it can + return 0; + }, + + /** + * Gets the first item from the set based on the property strictly equaling the value given. + * Returns null if not found. + * + * @method Phaser.Structs.List#getByKey + * @since 3.0.0 + * + * @param {string} property - The property to check against the value. + * @param {*} value - The value to check if the property strictly equals. + * + * @return {*} The item that was found, or null if nothing matched. + */ + getByKey: function (property, value) + { + for (var i = 0; i < this.list.length; i++) + { + if (this.list[i][property] === value) + { + return this.list[i]; + } + } + + return null; + }, + + /** + * Searches the Group for the first instance of a child with the `name` + * property matching the given argument. Should more than one child have + * the same name only the first instance is returned. + * + * @method Phaser.Structs.List#getByName + * @since 3.0.0 + * + * @param {string} name - The name to search for. + * + * @return {*} The first child with a matching name, or null if none were found. + */ + getByName: function (name) + { + return this.getByKey('name', name); + }, + + /** + * Returns a random child from the group. + * + * @method Phaser.Structs.List#getRandom + * @since 3.0.0 + * + * @param {integer} [startIndex=0] - Offset from the front of the group (lowest child). + * @param {integer} [length=(to top)] - Restriction on the number of values you want to randomly select from. + * + * @return {*} A random child of this Group. + */ + getRandom: function (startIndex, length) + { + if (startIndex === undefined) { startIndex = 0; } + if (length === undefined) { length = this.list.length; } + + if (length === 0 || length > this.list.length) { return null; } - else if (tile.index === -1) + + var randomIndex = startIndex + Math.floor(Math.random() * length); + + return this.list[randomIndex]; + }, + + /** + * [description] + * + * @method Phaser.Structs.List#getFirst + * @since 3.0.0 + * + * @param {string} property - [description] + * @param {*} value - [description] + * @param {number} [startIndex=0] - [description] + * @param {number} [endIndex] - [description] + * + * @return {*} [description] + */ + getFirst: function (property, value, startIndex, endIndex) + { + if (startIndex === undefined) { startIndex = 0; } + if (endIndex === undefined) { endIndex = this.list.length; } + + for (var i = startIndex; i < endIndex; i++) { - return nonNull ? tile : null; + var child = this.list[i]; + + if (child[property] === value) + { + return child; + } + } + + return null; + }, + + /** + * Returns all children in this List. + * + * You can optionally specify a matching criteria using the `property` and `value` arguments. + * + * For example: `getAll('visible', true)` would return only children that have their visible property set. + * + * Optionally you can specify a start and end index. For example if this List had 100 children, + * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only + * the first 50 children in the List. + * + * @method Phaser.Structs.List#getAll + * @since 3.0.0 + * + * @param {string} [property] - An optional property to test against the value argument. + * @param {*} [value] - If property is set then Child.property must strictly equal this value to be included in the results. + * @param {integer} [startIndex=0] - The first child index to start the search from. + * @param {integer} [endIndex] - The last child index to search up until. + * + * @return {array} [description] + */ + getAll: function (property, value, startIndex, endIndex) + { + if (startIndex === undefined) { startIndex = 0; } + if (endIndex === undefined) { endIndex = this.list.length; } + + var output = []; + + for (var i = startIndex; i < endIndex; i++) + { + var child = this.list[i]; + + if (property) + { + if (child[property] === value) + { + output.push(child); + } + } + else + { + output.push(child); + } + } + + return output; + }, + + /** + * [description] + * + * @method Phaser.Structs.List#count + * @since 3.0.0 + * + * @param {string} property - [description] + * @param {*} value - [description] + * + * @return {integer} [description] + */ + count: function (property, value) + { + var total = 0; + + for (var i = 0; i < this.list.length; i++) + { + var child = this.list[i]; + + if (child[property] === value) + { + total++; + } + } + + return total; + }, + + /** + * [description] + * + * @method Phaser.Structs.List#swap + * @since 3.0.0 + * + * @param {object} child1 - [description] + * @param {object} child2 - [description] + */ + swap: function (child1, child2) + { + if (child1 === child2) + { + return; + } + + var index1 = this.getIndex(child1); + var index2 = this.getIndex(child2); + + if (index1 < 0 || index2 < 0) + { + throw new Error('List.swap: Supplied objects must be children of the same list'); + } + + this.list[index1] = child2; + this.list[index2] = child1; + }, + + /** + * [description] + * + * @method Phaser.Structs.List#moveTo + * @since 3.0.0 + * + * @param {object} child - [description] + * @param {integer} index - [description] + * + * @return {object} [description] + */ + moveTo: function (child, index) + { + var currentIndex = this.getIndex(child); + + if (currentIndex === -1 || index < 0 || index >= this.list.length) + { + throw new Error('List.moveTo: The supplied index is out of bounds'); + } + + // Remove + this.list.splice(currentIndex, 1); + + // Add in new location + this.list.splice(index, 0, child); + + return child; + }, + + /** + * [description] + * + * @method Phaser.Structs.List#remove + * @since 3.0.0 + * + * @param {object} child - [description] + * + * @return {object} [description] + */ + remove: function (child) + { + var index = this.list.indexOf(child); + + if (index !== -1) + { + this.list.splice(index, 1); + } + + return child; + }, + + /** + * [description] + * + * @method Phaser.Structs.List#removeAt + * @since 3.0.0 + * + * @param {integer} index - [description] + * + * @return {object} [description] + */ + removeAt: function (index) + { + var child = this.list[index]; + + if (child) + { + this.children.splice(index, 1); + } + + return child; + }, + + /** + * [description] + * + * @method Phaser.Structs.List#removeBetween + * @since 3.0.0 + * + * @param {integer} beginIndex - [description] + * @param {integer} endIndex - [description] + * + * @return {array} [description] + */ + removeBetween: function (beginIndex, endIndex) + { + if (beginIndex === undefined) { beginIndex = 0; } + if (endIndex === undefined) { endIndex = this.list.length; } + + var range = endIndex - beginIndex; + + if (range > 0 && range <= endIndex) + { + var removed = this.list.splice(beginIndex, range); + + return removed; + } + else if (range === 0 && this.list.length === 0) + { + return []; } else { - return tile; + throw new Error('List.removeBetween: Range Error, numeric values are outside the acceptable range'); } - } - else - { - return null; - } -}; + }, -module.exports = GetTileAt; + /** + * Removes all the items. + * + * @method Phaser.Structs.List#removeAll + * @since 3.0.0 + * + * @return {Phaser.Structs.List} This List object. + */ + removeAll: function () + { + var i = this.list.length; + + while (i--) + { + this.remove(this.list[i]); + } + + return this; + }, + + /** + * Brings the given child to the top of this List. + * + * @method Phaser.Structs.List#bringToTop + * @since 3.0.0 + * + * @param {object} child - [description] + * + * @return {object} [description] + */ + bringToTop: function (child) + { + if (this.getIndex(child) < this.list.length) + { + this.remove(child); + this.add(child); + } + + return child; + }, + + /** + * Sends the given child to the bottom of this List. + * + * @method Phaser.Structs.List#sendToBack + * @since 3.0.0 + * + * @param {object} child - [description] + * + * @return {object} [description] + */ + sendToBack: function (child) + { + if (this.getIndex(child) > 0) + { + this.remove(child); + this.addAt(child, 0); + } + + return child; + }, + + /** + * Moves the given child up one place in this group unless it's already at the top. + * + * @method Phaser.Structs.List#moveUp + * @since 3.0.0 + * + * @param {object} child - [description] + * + * @return {object} [description] + */ + moveUp: function (child) + { + var a = this.getIndex(child); + + if (a !== -1 && a < this.list.length - 1) + { + var b = this.getAt(a + 1); + + if (b) + { + this.swap(child, b); + } + } + + return child; + }, + + /** + * Moves the given child down one place in this group unless it's already at the bottom. + * + * @method Phaser.Structs.List#moveDown + * @since 3.0.0 + * + * @param {object} child - [description] + * + * @return {object} [description] + */ + moveDown: function (child) + { + var a = this.getIndex(child); + + if (a > 0) + { + var b = this.getAt(a - 1); + + if (b) + { + this.swap(child, b); + } + } + + return child; + }, + + /** + * Reverses the order of all children in this List. + * + * @method Phaser.Structs.List#reverse + * @since 3.0.0 + * + * @return {Phaser.Structs.List} This List object. + */ + reverse: function () + { + this.list.reverse(); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.List#shuffle + * @since 3.0.0 + * + * @return {Phaser.Structs.List} This List object. + */ + shuffle: function () + { + for (var i = this.list.length - 1; i > 0; i--) + { + var j = Math.floor(Math.random() * (i + 1)); + var temp = this.list[i]; + this.list[i] = this.list[j]; + this.list[j] = temp; + } + + return this; + }, + + /** + * Replaces a child of this List with the given newChild. The newChild cannot be a member of this List. + * + * @method Phaser.Structs.List#replace + * @since 3.0.0 + * + * @param {object} oldChild - The child in this List that will be replaced. + * @param {object} newChild - The child to be inserted into this List. + * + * @return {object} Returns the oldChild that was replaced within this group. + */ + replace: function (oldChild, newChild) + { + var index = this.getIndex(oldChild); + + if (index !== -1) + { + this.remove(oldChild); + + this.addAt(newChild, index); + + return oldChild; + } + }, + + /** + * [description] + * + * @method Phaser.Structs.List#exists + * @since 3.0.0 + * + * @param {object} child - [description] + * + * @return {boolean} True if the item is found in the list, otherwise false. + */ + exists: function (child) + { + return (this.list.indexOf(child) > -1); + }, + + /** + * Sets the property `key` to the given value on all members of this List. + * + * @method Phaser.Structs.List#setAll + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {*} value - [description] + */ + setAll: function (key, value) + { + for (var i = 0; i < this.list.length; i++) + { + if (this.list[i]) + { + this.list[i][key] = value; + } + } + }, + + /** + * Passes all children to the given callback. + * + * @method Phaser.Structs.List#each + * @since 3.0.0 + * + * @param {EachListCallback} callback - The function to call. + * @param {object} [thisArg] - Value to use as `this` when executing callback. + * @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the child. + */ + each: function (callback, thisArg) + { + var args = [ null ]; + + for (var i = 1; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (i = 0; i < this.list.length; i++) + { + args[0] = this.list[i]; + callback.apply(thisArg, args); + } + }, + + /** + * [description] + * + * @method Phaser.Structs.List#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.removeAll(); + }, + + /** + * [description] + * + * @method Phaser.Structs.List#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.removeAll(); + + this.list = []; + + this.parent = null; + }, + + /** + * [description] + * + * @name Phaser.Structs.List#length + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + length: { + + get: function () + { + return this.list.length; + } + + }, + + /** + * [description] + * + * @name Phaser.Structs.List#first + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + first: { + + get: function () + { + this.position = 0; + + if (this.list.length > 0) + { + return this.list[0]; + } + else + { + return null; + } + } + + }, + + /** + * [description] + * + * @name Phaser.Structs.List#last + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + last: { + + get: function () + { + if (this.list.length > 0) + { + this.position = this.list.length - 1; + + return this.list[this.position]; + } + else + { + return null; + } + } + + }, + + /** + * [description] + * + * @name Phaser.Structs.List#next + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + next: { + + get: function () + { + if (this.position < this.list.length) + { + this.position++; + + return this.list[this.position]; + } + else + { + return null; + } + } + + }, + + /** + * [description] + * + * @name Phaser.Structs.List#previous + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + previous: { + + get: function () + { + if (this.position > 0) + { + this.position--; + + return this.list[this.position]; + } + else + { + return null; + } + } + + } + +}); + +module.exports = List; /***/ }), /* 98 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey + * @author Pavle Goloskokovic (http://prunegames.com) * @copyright 2018 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(15); +var Extend = __webpack_require__(18); +var NOOP = __webpack_require__(3); + /** - * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the - * layer's position, scale and scroll. + * @classdesc + * Class containing all the shared state and behaviour of a sound object, independent of the implementation. * - * @function Phaser.Tilemaps.Components.TileToWorldX + * @class BaseSound + * @extends EventEmitter + * @memberOf Phaser.Sound + * @constructor * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {number} + * @param {Phaser.Sound.BaseSoundManager} manager - Reference to the current sound manager instance. + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. */ -var TileToWorldX = function (tileX, camera, layer) -{ - var tileWidth = layer.baseTileWidth; - var tilemapLayer = layer.tilemapLayer; - var layerWorldX = 0; +var BaseSound = new Class({ - if (tilemapLayer) + Extends: EventEmitter, + + initialize: + + function BaseSound (manager, key, config) { - if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } + EventEmitter.call(this); - layerWorldX = tilemapLayer.x + camera.scrollX * (1 - tilemapLayer.scrollFactorX); + /** + * Local reference to the sound manager. + * + * @name Phaser.Sound.BaseSound#manager + * @type {Phaser.Sound.BaseSoundManager} + * @private + * @since 3.0.0 + */ + this.manager = manager; - tileWidth *= tilemapLayer.scaleX; + /** + * Asset key for the sound. + * + * @name Phaser.Sound.BaseSound#key + * @type {string} + * @readOnly + * @since 3.0.0 + */ + this.key = key; + + /** + * Flag indicating if sound is currently playing. + * + * @name Phaser.Sound.BaseSound#isPlaying + * @type {boolean} + * @default false + * @readOnly + * @since 3.0.0 + */ + this.isPlaying = false; + + /** + * Flag indicating if sound is currently paused. + * + * @name Phaser.Sound.BaseSound#isPaused + * @type {boolean} + * @default false + * @readOnly + * @since 3.0.0 + */ + this.isPaused = false; + + /** + * A property that holds the value of sound's actual playback rate, + * after its rate and detune values has been combined with global + * rate and detune values. + * + * @name Phaser.Sound.BaseSound#totalRate + * @type {number} + * @default 1 + * @readOnly + * @since 3.0.0 + */ + this.totalRate = 1; + + /** + * A value representing the duration, in seconds. + * It could be total sound duration or a marker duration. + * + * @name Phaser.Sound.BaseSound#duration + * @type {number} + * @readOnly + * @since 3.0.0 + */ + this.duration = this.duration || 0; + + /** + * The total duration of the sound in seconds. + * + * @name Phaser.Sound.BaseSound#totalDuration + * @type {number} + * @readOnly + * @since 3.0.0 + */ + this.totalDuration = this.totalDuration || 0; + + /** + * A config object used to store default sound settings' values. + * Default values will be set by properties' setters. + * + * @name Phaser.Sound.BaseSound#config + * @type {SoundConfig} + * @private + * @since 3.0.0 + */ + this.config = { + /** + * Initializing delay config setting + */ + delay: 0 + }; + + /** + * Reference to the currently used config. + * It could be default config or marker config. + * + * @name Phaser.Sound.BaseSound#currentConfig + * @type {SoundConfig} + * @private + * @since 3.0.0 + */ + this.currentConfig = this.config; + + /** + * Boolean indicating whether the sound is muted or not. + * Gets or sets the muted state of this sound. + * + * @name Phaser.Sound.BaseSound#mute + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.mute = false; + + /** + * Gets or sets the volume of this sound, + * a value between 0 (silence) and 1 (full volume). + * + * @name Phaser.Sound.BaseSound#volume + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.volume = 1; + + /** + * Defines the speed at which the audio asset will be played. + * Value of 1.0 plays the audio at full speed, 0.5 plays the audio + * at half speed and 2.0 doubles the audio's playback speed. + * This value gets multiplied by global rate to have the final playback speed. + * + * @name Phaser.Sound.BaseSound#rate + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.rate = 1; + + /** + * Represents detuning of sound in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @name Phaser.Sound.BaseSound#detune + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.detune = 0; + + /** + * Property representing the position of playback for this sound, in seconds. + * Setting it to a specific value moves current playback to that position. + * The value given is clamped to the range 0 to current marker duration. + * Setting seek of a stopped sound has no effect. + * + * @name Phaser.Sound.BaseSound#seek + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.seek = 0; + + /** + * Flag indicating whether or not the sound or current sound marker will loop. + * + * @name Phaser.Sound.BaseSound#loop + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.loop = false; + this.config = Extend(this.config, config); + + /** + * Object containing markers definitions. + * + * @name Phaser.Sound.BaseSound#markers + * @type {Object.} + * @default {} + * @readOnly + * @since 3.0.0 + */ + this.markers = {}; + + /** + * Currently playing marker. + * 'null' if whole sound is playing. + * + * @name Phaser.Sound.BaseSound#currentMarker + * @type {SoundMarker} + * @default null + * @readOnly + * @since 3.0.0 + */ + this.currentMarker = null; + + /** + * Flag indicating if destroy method was called on this sound. + * + * @name Phaser.Sound.BaseSound#pendingRemove + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this.pendingRemove = false; + }, + + /** + * Adds a marker into the current sound. A marker is represented by name, start time, duration, and optionally config object. + * This allows you to bundle multiple sounds together into a single audio file and use markers to jump between them for playback. + * + * @method Phaser.Sound.BaseSound#addMarker + * @since 3.0.0 + * + * @param {SoundMarker} marker - Marker object. + * + * @return {boolean} Whether the marker was added successfully. + */ + addMarker: function (marker) + { + if (!marker || !marker.name || typeof marker.name !== 'string') + { + return false; + } + + if (this.markers[marker.name]) + { + // eslint-disable-next-line no-console + console.error('addMarker - Marker with name \'' + marker.name + '\' already exists for sound \'' + this.key + '\'!'); + + return false; + } + + marker = Extend(true, { + name: '', + start: 0, + duration: this.totalDuration - (marker.start || 0), + config: { + mute: false, + volume: 1, + rate: 1, + detune: 0, + seek: 0, + loop: false, + delay: 0 + } + }, marker); + + this.markers[marker.name] = marker; + + return true; + }, + + /** + * Updates previously added marker. + * + * @method Phaser.Sound.BaseSound#updateMarker + * @since 3.0.0 + * + * @param {SoundMarker} marker - Marker object with updated values. + * + * @return {boolean} Whether the marker was updated successfully. + */ + updateMarker: function (marker) + { + if (!marker || !marker.name || typeof marker.name !== 'string') + { + return false; + } + + if (!this.markers[marker.name]) + { + // eslint-disable-next-line no-console + console.error('updateMarker - Marker with name \'' + marker.name + '\' does not exist for sound \'' + this.key + '\'!'); + + return false; + } + + this.markers[marker.name] = Extend(true, this.markers[marker.name], marker); + + return true; + }, + + /** + * Removes a marker from the sound. + * + * @method Phaser.Sound.BaseSound#removeMarker + * @since 3.0.0 + * + * @param {string} markerName - The name of the marker to remove. + * + * @return {?SoundMarker} Removed marker object or 'null' if there was no marker with provided name. + */ + removeMarker: function (markerName) + { + var marker = this.markers[markerName]; + + if (!marker) + { + return null; + } + + this.markers[markerName] = null; + + return marker; + }, + + /** + * Play this sound, or a marked section of it. + * It always plays the sound from the start. If you want to start playback from a specific time + * you can set 'seek' setting of the config object, provided to this call, to that value. + * + * @method Phaser.Sound.BaseSound#play + * @since 3.0.0 + * + * @param {string} [markerName=''] - If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. + * @param {SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. + * + * @return {boolean} Whether the sound started playing successfully. + */ + play: function (markerName, config) + { + if (markerName === undefined) { markerName = ''; } + + if (typeof markerName === 'object') + { + config = markerName; + markerName = ''; + } + + if (typeof markerName !== 'string') + { + // eslint-disable-next-line no-console + console.error('Sound marker name has to be a string!'); + + return false; + } + + if (!markerName) + { + this.currentMarker = null; + this.currentConfig = this.config; + this.duration = this.totalDuration; + } + else + { + if (!this.markers[markerName]) + { + // eslint-disable-next-line no-console + console.error('No marker with name \'' + markerName + '\' found for sound \'' + this.key + '\'!'); + + return false; + } + + this.currentMarker = this.markers[markerName]; + this.currentConfig = this.currentMarker.config; + this.duration = this.currentMarker.duration; + } + + this.resetConfig(); + + this.currentConfig = Extend(this.currentConfig, config); + + this.isPlaying = true; + this.isPaused = false; + + return true; + }, + + /** + * Pauses the sound. + * + * @method Phaser.Sound.BaseSound#pause + * @since 3.0.0 + * + * @return {boolean} Whether the sound was paused successfully. + */ + pause: function () + { + if (this.isPaused || !this.isPlaying) + { + return false; + } + + this.isPlaying = false; + this.isPaused = true; + + return true; + }, + + /** + * Resumes the sound. + * + * @method Phaser.Sound.BaseSound#resume + * @since 3.0.0 + * + * @return {boolean} Whether the sound was resumed successfully. + */ + resume: function () + { + if (!this.isPaused || this.isPlaying) + { + return false; + } + + this.isPlaying = true; + this.isPaused = false; + + return true; + }, + + /** + * Stop playing this sound. + * + * @method Phaser.Sound.BaseSound#stop + * @since 3.0.0 + * + * @return {boolean} Whether the sound was stopped successfully. + */ + stop: function () + { + if (!this.isPaused && !this.isPlaying) + { + return false; + } + + this.isPlaying = false; + this.isPaused = false; + + this.resetConfig(); + + return true; + }, + + /** + * Method used internally for applying config values to some of the sound properties. + * + * @method Phaser.Sound.BaseSound#applyConfig + * @protected + * @since 3.0.0 + */ + applyConfig: function () + { + this.mute = this.currentConfig.mute; + this.volume = this.currentConfig.volume; + this.rate = this.currentConfig.rate; + this.detune = this.currentConfig.detune; + this.loop = this.currentConfig.loop; + }, + + /** + * Method used internally for resetting values of some of the config properties. + * + * @method Phaser.Sound.BaseSound#resetConfig + * @protected + * @since 3.0.0 + */ + resetConfig: function () + { + this.currentConfig.seek = 0; + this.currentConfig.delay = 0; + }, + + /** + * Update method called automatically by sound manager on every game step. + * + * @method Phaser.Sound.BaseSound#update + * @override + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time elapsed since the last frame. + */ + update: NOOP, + + /** + * Method used internally to calculate total playback rate of the sound. + * + * @method Phaser.Sound.BaseSound#calculateRate + * @protected + * @since 3.0.0 + */ + calculateRate: function () + { + var cent = 1.0005777895065548; // Math.pow(2, 1/1200); + var totalDetune = this.currentConfig.detune + this.manager.detune; + var detuneRate = Math.pow(cent, totalDetune); + + this.totalRate = this.currentConfig.rate * this.manager.rate * detuneRate; + }, + + /** + * @event Phaser.Sound.BaseSound#rate + * @param {Phaser.Sound.BaseSound} sound - Reference to the sound that emitted the event. + * @param {number} value - An updated value of Phaser.Sound.BaseSound#rate property. + */ + + /** + * Sets the playback rate of this Sound. + * + * For example, a value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed + * and 2.0 doubles the audios playback speed. + * + * @method Phaser.Sound.BaseSound#setRate + * @fires Phaser.Sound.BaseSound#rate + * @since 3.3.0 + * + * @param {number} value - The playback rate at of this Sound. + * + * @return {Phaser.Sound.BaseSound} This Sound. + */ + setRate: function (value) + { + this.rate = value; + + return this; + }, + + /** + * Rate at which this Sound will be played. + * Value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed + * and 2.0 doubles the audios playback speed. + * + * @name Phaser.Sound.BaseSound#rate + * @type {number} + * @default 1 + * @since 3.0.0 + */ + rate: { + + get: function () + { + return this.currentConfig.rate; + }, + + set: function (value) + { + this.currentConfig.rate = value; + + this.calculateRate(); + + this.emit('rate', this, value); + } + + }, + + /** + * Sets the detune value of this Sound, given in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @method Phaser.Sound.BaseSound#setDetune + * @fires Phaser.Sound.BaseSound#detune + * @since 3.3.0 + * + * @param {number} value - The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @return {Phaser.Sound.BaseSound} This Sound. + */ + setDetune: function (value) + { + this.detune = value; + + return this; + }, + + /** + * @event Phaser.Sound.BaseSound#detune + * @param {Phaser.Sound.BaseSound} sound - Reference to the Sound that emitted event. + * @param {number} value - An updated value of Phaser.Sound.BaseSound#detune property. + */ + + /** + * The detune value of this Sound, given in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @name Phaser.Sound.BaseSound#detune + * @type {number} + * @default 0 + * @since 3.0.0 + */ + detune: { + + get: function () + { + return this.currentConfig.detune; + }, + + set: function (value) + { + this.currentConfig.detune = value; + + this.calculateRate(); + + this.emit('detune', this, value); + } + + }, + + /** + * Destroys this sound and all associated events and marks it for removal from the sound manager. + * + * @method Phaser.Sound.BaseSound#destroy + * @since 3.0.0 + */ + destroy: function () + { + if (this.pendingRemove) + { + return; + } + + this.pendingRemove = true; + this.manager = null; + this.key = ''; + this.removeAllListeners(); + this.isPlaying = false; + this.isPaused = false; + this.config = null; + this.currentConfig = null; + this.markers = null; + this.currentMarker = null; } - return layerWorldX + tileX * tileWidth; -}; +}); -module.exports = TileToWorldX; +module.exports = BaseSound; /***/ }), /* 99 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey + * @author Pavle Goloskokovic (http://prunegames.com) * @copyright 2018 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(15); +var NOOP = __webpack_require__(3); + /** - * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layer's position, scale and scroll. + * @callback EachActiveSoundCallback * - * @function Phaser.Tilemaps.Components.TileToWorldY + * @param {Phaser.Sound.BaseSoundManager} manager - [description] + * @param {Phaser.Sound.BaseSound} sound - [description] + * @param {number} index - [description] + * @param {Phaser.Sound.BaseSound[]} sounds - [description] + */ + +/** + * Audio sprite sound type. + * + * @typedef {Phaser.Sound.BaseSound} AudioSpriteSound + * + * @property {object} spritemap - Local reference to 'spritemap' object form json file generated by audiosprite tool. + */ + + +/** + * @classdesc + * The sound manager is responsible for playing back audio via Web Audio API or HTML Audio tag as fallback. + * The audio file type and the encoding of those files are extremely important. + * + * Not all browsers can play all audio formats. + * + * There is a good guide to what's supported [here](https://developer.mozilla.org/en-US/Apps/Fundamentals/Audio_and_video_delivery/Cross-browser_audio_basics#Audio_Codec_Support). + * + * @class BaseSoundManager + * @extends EventEmitter + * @memberOf Phaser.Sound + * @constructor * @since 3.0.0 * - * @param {integer} tileY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {number} + * @param {Phaser.Game} game - Reference to the current game instance. */ -var TileToWorldY = function (tileY, camera, layer) -{ - var tileHeight = layer.baseTileHeight; - var tilemapLayer = layer.tilemapLayer; - var layerWorldY = 0; +var BaseSoundManager = new Class({ - if (tilemapLayer) + Extends: EventEmitter, + + initialize: + + function BaseSoundManager (game) { - if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } + EventEmitter.call(this); - layerWorldY = (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY)); + /** + * Local reference to game. + * + * @name Phaser.Sound.BaseSoundManager#game + * @type {Phaser.Game} + * @readOnly + * @since 3.0.0 + */ + this.game = game; + + /** + * An array containing all added sounds. + * + * @name Phaser.Sound.BaseSoundManager#sounds + * @type {Phaser.Sound.BaseSound[]} + * @default [] + * @private + * @since 3.0.0 + */ + this.sounds = []; + + /** + * Global mute setting. + * + * @name Phaser.Sound.BaseSoundManager#mute + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.mute = false; + + /** + * Global volume setting. + * + * @name Phaser.Sound.BaseSoundManager#volume + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.volume = 1; + + /** + * Flag indicating if sounds should be paused when game looses focus, + * for instance when user switches to another tab/program/app. + * + * @name Phaser.Sound.BaseSoundManager#pauseOnBlur + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.pauseOnBlur = true; + + game.events.on('blur', function () + { + if (this.pauseOnBlur) + { + this.onBlur(); + } + }, this); + + game.events.on('focus', function () + { + if (this.pauseOnBlur) + { + this.onFocus(); + } + }, this); + + game.events.once('destroy', this.destroy, this); + + /** + * Property that actually holds the value of global playback rate. + * + * @name Phaser.Sound.BaseSoundManager#_rate + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + this._rate = 1; + + /** + * Property that actually holds the value of global detune. + * + * @name Phaser.Sound.BaseSoundManager#_detune + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._detune = 0; + + /** + * Mobile devices require sounds to be triggered from an explicit user action, + * such as a tap, before any sound can be loaded/played on a web page. + * Set to true if the audio system is currently locked awaiting user interaction. + * + * @name Phaser.Sound.BaseSoundManager#locked + * @type {boolean} + * @readOnly + * @since 3.0.0 + */ + this.locked = this.locked || false; + + /** + * Flag used internally for handling when the audio system + * has been unlocked, if there ever was a need for it. + * + * @name Phaser.Sound.BaseSoundManager#unlocked + * @type {boolean} + * @default false + * @private + * @since 3.0.0 + */ + this.unlocked = false; + + if (this.locked) + { + this.unlock(); + } + }, + + /** + * Adds a new sound into the sound manager. + * + * @method Phaser.Sound.BaseSoundManager#add + * @override + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * + * @return {Phaser.Sound.BaseSound} The new sound instance. + */ + add: NOOP, + + /** + * Adds a new audio sprite sound into the sound manager. + * + * @method Phaser.Sound.BaseSoundManager#addAudioSprite + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * + * @return {AudioSpriteSound} The new audio sprite sound instance. + */ + addAudioSprite: function (key, config) + { + var sound = this.add(key, config); + + sound.spritemap = this.game.cache.json.get(key).spritemap; + + for (var markerName in sound.spritemap) + { + if (!sound.spritemap.hasOwnProperty(markerName)) + { + continue; + } + + var marker = sound.spritemap[markerName]; + + sound.addMarker({ + name: markerName, + start: marker.start, + duration: marker.end - marker.start, + config: config + }); + } + + return sound; + }, + + /** + * Enables playing sound on the fly without the need to keep a reference to it. + * Sound will auto destroy once its playback ends. + * + * @method Phaser.Sound.BaseSoundManager#play + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {(SoundConfig|SoundMarker)} [extra] - An optional additional object containing settings to be applied to the sound. It could be either config or marker object. + * + * @return {boolean} Whether the sound started playing successfully. + */ + play: function (key, extra) + { + var sound = this.add(key); + + sound.once('ended', sound.destroy, sound); + + if (extra) + { + if (extra.name) + { + sound.addMarker(extra); + + return sound.play(extra.name); + } + else + { + return sound.play(extra); + } + } + else + { + return sound.play(); + } + }, + + /** + * Enables playing audio sprite sound on the fly without the need to keep a reference to it. + * Sound will auto destroy once its playback ends. + * + * @method Phaser.Sound.BaseSoundManager#playAudioSprite + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {string} spriteName - The name of the sound sprite to play. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * + * @return {boolean} Whether the audio sprite sound started playing successfully. + */ + playAudioSprite: function (key, spriteName, config) + { + var sound = this.addAudioSprite(key); + + sound.once('ended', sound.destroy, sound); + + return sound.play(spriteName, config); + }, + + /** + * Removes a sound from the sound manager. + * The removed sound is destroyed before removal. + * + * @method Phaser.Sound.BaseSoundManager#remove + * @since 3.0.0 + * + * @param {Phaser.Sound.BaseSound} sound - The sound object to remove. + * + * @return {boolean} True if the sound was removed successfully, otherwise false. + */ + remove: function (sound) + { + var index = this.sounds.indexOf(sound); + + if (index !== -1) + { + sound.destroy(); + + this.sounds.splice(index, 1); + + return true; + } + + return false; + }, + + /** + * Removes all sounds from the sound manager that have an asset key matching the given value. + * The removed sounds are destroyed before removal. + * + * @method Phaser.Sound.BaseSoundManager#removeByKey + * @since 3.0.0 + * + * @param {string} key - The key to match when removing sound objects. + * + * @return {number} The number of matching sound objects that were removed. + */ + removeByKey: function (key) + { + var removed = 0; + + for (var i = this.sounds.length - 1; i >= 0; i--) + { + var sound = this.sounds[i]; + + if (sound.key === key) + { + sound.destroy(); + + this.sounds.splice(i, 1); + + removed++; + } + } + + return removed; + }, + + /** + * @event Phaser.Sound.BaseSoundManager#pauseall + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + */ + + /** + * Pauses all the sounds in the game. + * + * @method Phaser.Sound.BaseSoundManager#pauseAll + * @fires Phaser.Sound.BaseSoundManager#pauseall + * @since 3.0.0 + */ + pauseAll: function () + { + this.forEachActiveSound(function (sound) + { + sound.pause(); + }); + + this.emit('pauseall', this); + }, + + /** + * @event Phaser.Sound.BaseSoundManager#resumeall + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + */ + + /** + * Resumes all the sounds in the game. + * + * @method Phaser.Sound.BaseSoundManager#resumeAll + * @fires Phaser.Sound.BaseSoundManager#resumeall + * @since 3.0.0 + */ + resumeAll: function () + { + this.forEachActiveSound(function (sound) + { + sound.resume(); + }); + + this.emit('resumeall', this); + }, + + /** + * @event Phaser.Sound.BaseSoundManager#stopall + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + */ + + /** + * Stops all the sounds in the game. + * + * @method Phaser.Sound.BaseSoundManager#stopAll + * @fires Phaser.Sound.BaseSoundManager#stopall + * @since 3.0.0 + */ + stopAll: function () + { + this.forEachActiveSound(function (sound) + { + sound.stop(); + }); + + this.emit('stopall', this); + }, + + /** + * Method used internally for unlocking audio playback on devices that + * require user interaction before any sound can be played on a web page. + * + * Read more about how this issue is handled here in [this article](https://medium.com/@pgoloskokovic/unlocking-web-audio-the-smarter-way-8858218c0e09). + * + * @method Phaser.Sound.BaseSoundManager#unlock + * @override + * @protected + * @since 3.0.0 + */ + unlock: NOOP, + + /** + * Method used internally for pausing sound manager if + * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.BaseSoundManager#onBlur + * @override + * @protected + * @since 3.0.0 + */ + onBlur: NOOP, + + /** + * Method used internally for resuming sound manager if + * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.BaseSoundManager#onFocus + * @override + * @protected + * @since 3.0.0 + */ + onFocus: NOOP, + + /** + * Update method called on every game step. + * Removes destroyed sounds and updates every active sound in the game. + * + * @method Phaser.Sound.BaseSoundManager#update + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time elapsed since the last frame. + */ + update: function (time, delta) + { + if (this.unlocked) + { + this.unlocked = false; + this.locked = false; + + /** + * @event Phaser.Sound.BaseSoundManager#unlocked + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + */ + this.emit('unlocked', this); + } + + for (var i = this.sounds.length - 1; i >= 0; i--) + { + if (this.sounds[i].pendingRemove) + { + this.sounds.splice(i, 1); + } + } + + this.sounds.forEach(function (sound) + { + sound.update(time, delta); + }); + }, + + /** + * Destroys all the sounds in the game and all associated events. + * + * @method Phaser.Sound.BaseSoundManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.removeAllListeners(); + + this.forEachActiveSound(function (sound) + { + sound.destroy(); + }); + + this.sounds.length = 0; + this.sounds = null; + + this.game = null; + }, + + /** + * Method used internally for iterating only over active sounds and skipping sounds that are marked for removal. + * + * @method Phaser.Sound.BaseSoundManager#forEachActiveSound + * @private + * @since 3.0.0 + * + * @param {EachActiveSoundCallback} callback - Callback function. (sound: ISound, index: number, array: ISound[]) => void + * @param {*} [scope] - Callback context. + */ + forEachActiveSound: function (callback, scope) + { + var _this = this; + + this.sounds.forEach(function (sound, index) + { + if (!sound.pendingRemove) + { + callback.call(scope || _this, sound, index, _this.sounds); + } + }); + }, + + /** + * @event Phaser.Sound.BaseSoundManager#rate + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + * @param {number} value - An updated value of Phaser.Sound.BaseSoundManager#rate property. + */ + + /** + * Sets the global playback rate at which all the sounds will be played. + * + * For example, a value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed + * and 2.0 doubles the audios playback speed. + * + * @method Phaser.Sound.BaseSoundManager#setRate + * @fires Phaser.Sound.BaseSoundManager#rate + * @since 3.3.0 + * + * @param {number} value - Global playback rate at which all the sounds will be played. + * + * @return {Phaser.Sound.BaseSoundManager} This Sound Manager. + */ + setRate: function (value) + { + this.rate = value; + + return this; + }, + + /** + * Global playback rate at which all the sounds will be played. + * Value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed + * and 2.0 doubles the audio's playback speed. + * + * @name Phaser.Sound.BaseSoundManager#rate + * @type {number} + * @default 1 + * @since 3.0.0 + */ + rate: { + + get: function () + { + return this._rate; + }, + + set: function (value) + { + this._rate = value; + + this.forEachActiveSound(function (sound) + { + sound.setRate(); + }); + + this.emit('rate', this, value); + } + + }, + + /** + * Sets the global detuning of all sounds in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @method Phaser.Sound.BaseSoundManager#setDetune + * @fires Phaser.Sound.BaseSoundManager#detune + * @since 3.3.0 + * + * @param {number} value - The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @return {Phaser.Sound.BaseSoundManager} This Sound Manager. + */ + setDetune: function (value) + { + this.detune = value; + + return this; + }, + + /** + * @event Phaser.Sound.BaseSoundManager#detune + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + * @param {number} value - An updated value of Phaser.Sound.BaseSoundManager#detune property. + */ + + /** + * Global detuning of all sounds in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @name Phaser.Sound.BaseSoundManager#detune + * @type {number} + * @default 0 + * @since 3.0.0 + */ + detune: { + + get: function () + { + return this._detune; + }, + + set: function (value) + { + this._detune = value; + + this.forEachActiveSound(function (sound) + { + sound.setRate(); + }); + + this.emit('detune', this, value); + } - tileHeight *= tilemapLayer.scaleY; } - return layerWorldY + tileY * tileHeight; -}; +}); -module.exports = TileToWorldY; +module.exports = BaseSoundManager; /***/ }), @@ -18797,390 +18807,375 @@ module.exports = TileToWorldY; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); +var OS = __webpack_require__(76); /** - * @classdesc - * A Tileset is a combination of an image containing the tiles and a container for data about - * each tile. - * - * @class Tileset - * @memberOf Phaser.Tilemaps - * @constructor + * Determines the browser type and version running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.browser` from within any Scene. + * + * @name Phaser.Device.Browser * @since 3.0.0 * - * @param {string} name - The name of the tileset in the map data. - * @param {integer} firstgid - The first tile index this tileset contains. - * @param {integer} [tileWidth=32] - Width of each tile (in pixels). - * @param {integer} [tileHeight=32] - Height of each tile (in pixels). - * @param {integer} [tileMargin=0] - The margin around all tiles in the sheet (in pixels). - * @param {integer} [tileSpacing=0] - The spacing between each tile in the sheet (in pixels). - * @param {object} [tileProperties={}] - Custom properties defined per tile in the Tileset. - * These typically are custom properties created in Tiled when editing a tileset. - * @param {object} [tileData={}] - Data stored per tile. These typically are created in Tiled - * when editing a tileset, e.g. from Tiled's tile collision editor or terrain editor. + * @type {object} + * @property {boolean} chrome - Set to true if running in Chrome. + * @property {boolean} edge - Set to true if running in Microsoft Edge browser. + * @property {boolean} firefox - Set to true if running in Firefox. + * @property {boolean} ie - Set to true if running in Internet Explorer 11 or less (not Edge). + * @property {boolean} mobileSafari - Set to true if running in Mobile Safari. + * @property {boolean} opera - Set to true if running in Opera. + * @property {boolean} safari - Set to true if running in Safari. + * @property {boolean} silk - Set to true if running in the Silk browser (as used on the Amazon Kindle) + * @property {boolean} trident - Set to true if running a Trident version of Internet Explorer (IE11+) + * @property {number} chromeVersion - If running in Chrome this will contain the major version number. + * @property {number} firefoxVersion - If running in Firefox this will contain the major version number. + * @property {number} ieVersion - If running in Internet Explorer this will contain the major version number. Beyond IE10 you should use Browser.trident and Browser.tridentVersion. + * @property {number} safariVersion - If running in Safari this will contain the major version number. + * @property {number} tridentVersion - If running in Internet Explorer 11 this will contain the major version number. See {@link http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx} */ -var Tileset = new Class({ +var Browser = { - initialize: + chrome: false, + chromeVersion: 0, + edge: false, + firefox: false, + firefoxVersion: 0, + ie: false, + ieVersion: 0, + mobileSafari: false, + opera: false, + safari: false, + safariVersion: 0, + silk: false, + trident: false, + tridentVersion: 0 - function Tileset (name, firstgid, tileWidth, tileHeight, tileMargin, tileSpacing, tileProperties, tileData) +}; + +function init () +{ + var ua = navigator.userAgent; + + if (/Edge\/\d+/.test(ua)) { - if (tileWidth === undefined || tileWidth <= 0) { tileWidth = 32; } - if (tileHeight === undefined || tileHeight <= 0) { tileHeight = 32; } - if (tileMargin === undefined) { tileMargin = 0; } - if (tileSpacing === undefined) { tileSpacing = 0; } - if (tileProperties === undefined) { tileProperties = {}; } - if (tileData === undefined) { tileData = {}; } - - /** - * The name of the Tileset. - * - * @name Phaser.Tilemaps.Tileset#name - * @type {string} - * @since 3.0.0 - */ - this.name = name; - - /** - * The starting index of the first tile index this Tileset contains. - * - * @name Phaser.Tilemaps.Tileset#firstgid - * @type {integer} - * @since 3.0.0 - */ - this.firstgid = firstgid; - - /** - * The width of each tile (in pixels). Use setTileSize to change. - * - * @name Phaser.Tilemaps.Tileset#tileWidth - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.tileWidth = tileWidth; - - /** - * The height of each tile (in pixels). Use setTileSize to change. - * - * @name Phaser.Tilemaps.Tileset#tileHeight - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.tileHeight = tileHeight; - - /** - * The margin around the tiles in the sheet (in pixels). Use `setSpacing` to change. - * - * @name Phaser.Tilemaps.Tileset#tileMargin - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.tileMargin = tileMargin; - - /** - * The spacing between each the tile in the sheet (in pixels). Use `setSpacing` to change. - * - * @name Phaser.Tilemaps.Tileset#tileSpacing - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.tileSpacing = tileSpacing; - - /** - * Tileset-specific properties per tile that are typically defined in the Tiled editor in the - * Tileset editor. - * - * @name Phaser.Tilemaps.Tileset#tileProperties - * @type {object} - * @since 3.0.0 - */ - this.tileProperties = tileProperties; - - /** - * Tileset-specific data per tile that are typically defined in the Tiled editor, e.g. within - * the Tileset collision editor. This is where collision objects and terrain are stored. - * - * @name Phaser.Tilemaps.Tileset#tileData - * @type {object} - * @since 3.0.0 - */ - this.tileData = tileData; - - /** - * The cached image that contains the individual tiles. Use setImage to set. - * - * @name Phaser.Tilemaps.Tileset#image - * @type {Phaser.Textures.Texture|null} - * @readOnly - * @since 3.0.0 - */ - this.image = null; - - /** - * The number of tile rows in the the tileset. - * - * @name Phaser.Tilemaps.Tileset#rows - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.rows = 0; - - /** - * The number of tile columns in the tileset. - * - * @name Phaser.Tilemaps.Tileset#columns - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.columns = 0; - - /** - * The total number of tiles in the tileset. - * - * @name Phaser.Tilemaps.Tileset#total - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.total = 0; - - /** - * The look-up table to specific tile image texture coordinates (UV in pixels). Each element - * contains the coordinates for a tile in an object of the form {x, y}. - * - * @name Phaser.Tilemaps.Tileset#texCoordinates - * @type {object[]} - * @readOnly - * @since 3.0.0 - */ - this.texCoordinates = []; - }, - - /** - * Get a tiles properties that are stored in the Tileset. Returns null if tile index is not - * contained in this Tileset. This is typically defined in Tiled under the Tileset editor. - * - * @method Phaser.Tilemaps.Tileset#getTileProperties - * @since 3.0.0 - * - * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. - * - * @return {object|undefined|null} - */ - getTileProperties: function (tileIndex) + Browser.edge = true; + } + else if ((/Chrome\/(\d+)/).test(ua) && !OS.windowsPhone) { - if (!this.containsTileIndex(tileIndex)) { return null; } - - return this.tileProperties[tileIndex - this.firstgid]; - }, - - /** - * Get a tile's data that is stored in the Tileset. Returns null if tile index is not contained - * in this Tileset. This is typically defined in Tiled and will contain both Tileset collision - * info and terrain mapping. - * - * @method Phaser.Tilemaps.Tileset#getTileData - * @since 3.0.0 - * - * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. - * - * @return {object|undefined|null} - */ - getTileData: function (tileIndex) + Browser.chrome = true; + Browser.chromeVersion = parseInt(RegExp.$1, 10); + } + else if ((/Firefox\D+(\d+)/).test(ua)) { - if (!this.containsTileIndex(tileIndex)) { return null; } - - return this.tileData[tileIndex - this.firstgid]; - }, - - /** - * Get a tile's collision group that is stored in the Tileset. Returns null if tile index is not - * contained in this Tileset. This is typically defined within Tiled's tileset collision editor. - * - * @method Phaser.Tilemaps.Tileset#getTileCollisionGroup - * @since 3.0.0 - * - * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. - * - * @return {object|null} - */ - getTileCollisionGroup: function (tileIndex) + Browser.firefox = true; + Browser.firefoxVersion = parseInt(RegExp.$1, 10); + } + else if ((/AppleWebKit/).test(ua) && OS.iOS) { - var data = this.getTileData(tileIndex); - - return (data && data.objectgroup) ? data.objectgroup : null; - }, - - /** - * Returns true if and only if this Tileset contains the given tile index. - * - * @method Phaser.Tilemaps.Tileset#containsTileIndex - * @since 3.0.0 - * - * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. - * - * @return {boolean} - */ - containsTileIndex: function (tileIndex) + Browser.mobileSafari = true; + } + else if ((/MSIE (\d+\.\d+);/).test(ua)) { - return ( - tileIndex >= this.firstgid && - tileIndex < (this.firstgid + this.total) - ); - }, - - /** - * Returns the texture coordinates (UV in pixels) in the Tileset image for the given tile index. - * Returns null if tile index is not contained in this Tileset. - * - * @method Phaser.Tilemaps.Tileset#getTileTextureCoordinates - * @since 3.0.0 - * - * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. - * - * @return {object|null} Object in the form { x, y } representing the top-left UV coordinate - * within the Tileset image. - */ - getTileTextureCoordinates: function (tileIndex) + Browser.ie = true; + Browser.ieVersion = parseInt(RegExp.$1, 10); + } + else if ((/Opera/).test(ua)) { - if (!this.containsTileIndex(tileIndex)) { return null; } - - return this.texCoordinates[tileIndex - this.firstgid]; - }, - - /** - * Sets the image associated with this Tileset and updates the tile data (rows, columns, etc.). - * - * @method Phaser.Tilemaps.Tileset#setImage - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The image that contains the tiles. - * - * @return {Phaser.Tilemaps.Tileset} This Tileset object. - */ - setImage: function (texture) + Browser.opera = true; + } + else if ((/Safari/).test(ua) && !OS.windowsPhone) { - this.image = texture; - - this.updateTileData(this.image.source[0].width, this.image.source[0].height); - - return this; - }, - - /** - * Sets the tile width & height and updates the tile data (rows, columns, etc.). - * - * @method Phaser.Tilemaps.Tileset#setTileSize - * @since 3.0.0 - * - * @param {integer} [tileWidth] - The width of a tile in pixels. - * @param {integer} [tileHeight] - The height of a tile in pixels. - * - * @return {Phaser.Tilemaps.Tileset} This Tileset object. - */ - setTileSize: function (tileWidth, tileHeight) + Browser.safari = true; + } + else if ((/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/).test(ua)) { - if (tileWidth !== undefined) { this.tileWidth = tileWidth; } - if (tileHeight !== undefined) { this.tileHeight = tileHeight; } - - if (this.image) - { - this.updateTileData(this.image.source[0].width, this.image.source[0].height); - } - - return this; - }, - - /** - * Sets the tile margin & spacing and updates the tile data (rows, columns, etc.). - * - * @method Phaser.Tilemaps.Tileset#setSpacing - * @since 3.0.0 - * - * @param {integer} [margin] - The margin around the tiles in the sheet (in pixels). - * @param {integer} [spacing] - The spacing between the tiles in the sheet (in pixels). - * - * @return {Phaser.Tilemaps.Tileset} This Tileset object. - */ - setSpacing: function (margin, spacing) - { - if (margin !== undefined) { this.tileMargin = margin; } - if (spacing !== undefined) { this.tileSpacing = spacing; } - - if (this.image) - { - this.updateTileData(this.image.source[0].width, this.image.source[0].height); - } - - return this; - }, - - /** - * Updates tile texture coordinates and tileset data. - * - * @method Phaser.Tilemaps.Tileset#updateTileData - * @since 3.0.0 - * - * @param {integer} imageWidth - The (expected) width of the image to slice. - * @param {integer} imageHeight - The (expected) height of the image to slice. - * - * @return {Phaser.Tilemaps.Tileset} This Tileset object. - */ - updateTileData: function (imageWidth, imageHeight) - { - var rowCount = (imageHeight - this.tileMargin * 2 + this.tileSpacing) / (this.tileHeight + this.tileSpacing); - var colCount = (imageWidth - this.tileMargin * 2 + this.tileSpacing) / (this.tileWidth + this.tileSpacing); - - if (rowCount % 1 !== 0 || colCount % 1 !== 0) - { - console.warn('Tileset ' + this.name + ' image tile area is not an even multiple of tile size'); - } - - // In Tiled a tileset image that is not an even multiple of the tile dimensions is truncated - // - hence the floor when calculating the rows/columns. - rowCount = Math.floor(rowCount); - colCount = Math.floor(colCount); - - this.rows = rowCount; - this.columns = colCount; - - // In Tiled, "empty" spaces in a tileset count as tiles and hence count towards the gid - this.total = rowCount * colCount; - - this.texCoordinates.length = 0; - - var tx = this.tileMargin; - var ty = this.tileMargin; - - for (var y = 0; y < this.rows; y++) - { - for (var x = 0; x < this.columns; x++) - { - this.texCoordinates.push({ x: tx, y: ty }); - tx += this.tileWidth + this.tileSpacing; - } - - tx = this.tileMargin; - ty += this.tileHeight + this.tileSpacing; - } - - return this; + Browser.ie = true; + Browser.trident = true; + Browser.tridentVersion = parseInt(RegExp.$1, 10); + Browser.ieVersion = parseInt(RegExp.$3, 10); } -}); + // Silk gets its own if clause because its ua also contains 'Safari' + if ((/Silk/).test(ua)) + { + Browser.silk = true; + } -module.exports = Tileset; + return Browser; +} + +module.exports = init(); /***/ }), /* 101 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GameObject = __webpack_require__(1); +var Sprite = __webpack_require__(40); +var Vector2 = __webpack_require__(6); +var Vector4 = __webpack_require__(152); + +/** + * @classdesc + * A Sprite 3D Game Object. + * + * The Sprite 3D object is an encapsulation of a standard Sprite object, with additional methods to allow + * it to be rendered by a 3D Camera. The Sprite can be positioned anywhere within 3D space. + * + * @class Sprite3D + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The x position of this Game Object. + * @param {number} y - The y position of this Game Object. + * @param {number} z - The z position of this Game Object. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var Sprite3D = new Class({ + + Extends: GameObject, + + initialize: + + function Sprite3D (scene, x, y, z, texture, frame) + { + GameObject.call(this, scene, 'Sprite3D'); + + /** + * [description] + * + * @name Phaser.GameObjects.Sprite3D#gameObject + * @type {Phaser.GameObjects.GameObject} + * @since 3.0.0 + */ + this.gameObject = new Sprite(scene, 0, 0, texture, frame); + + /** + * [description] + * + * @name Phaser.GameObjects.Sprite3D#position + * @type {Phaser.Math.Vector4} + * @since 3.0.0 + */ + this.position = new Vector4(x, y, z); + + /** + * [description] + * + * @name Phaser.GameObjects.Sprite3D#size + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.size = new Vector2(this.gameObject.width, this.gameObject.height); + + /** + * [description] + * + * @name Phaser.GameObjects.Sprite3D#scale + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.scale = new Vector2(1, 1); + + /** + * [description] + * + * @name Phaser.GameObjects.Sprite3D#adjustScaleX + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.adjustScaleX = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Sprite3D#adjustScaleY + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.adjustScaleY = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Sprite3D#_visible + * @type {boolean} + * @default true + * @private + * @since 3.0.0 + */ + this._visible = true; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Sprite3D#project + * @since 3.0.0 + * + * @param {Phaser.Cameras.Sprite3D.Camera} camera - The 3D Camera onto which to project this Sprite. + */ + project: function (camera) + { + var pos = this.position; + + var gameObject = this.gameObject; + + camera.project(pos, gameObject); + + camera.getPointSize(pos, this.size, this.scale); + + if (this.scale.x <= 0 || this.scale.y <= 0) + { + gameObject.setVisible(false); + } + else + { + if (!gameObject.visible) + { + gameObject.setVisible(true); + } + + if (this.adjustScaleX) + { + gameObject.scaleX = this.scale.x; + } + + if (this.adjustScaleY) + { + gameObject.scaleY = this.scale.y; + } + + gameObject.setDepth(gameObject.z * -1); + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Sprite3D#setVisible + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.GameObjects.Sprite3D} This Sprite3D Object. + */ + setVisible: function (value) + { + this.visible = value; + + return this; + }, + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * + * @name Phaser.GameObjects.Sprite3D#visible + * @type {boolean} + * @since 3.0.0 + */ + visible: { + + get: function () + { + return this._visible; + }, + + set: function (value) + { + this._visible = value; + this.gameObject.visible = value; + } + + }, + + /** + * The x position of this Game Object. + * + * @name Phaser.GameObjects.Sprite3D#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.position.x; + }, + + set: function (value) + { + this.position.x = value; + } + + }, + + /** + * The y position of this Game Object. + * + * @name Phaser.GameObjects.Sprite3D#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.position.y; + }, + + set: function (value) + { + this.position.y = value; + } + + }, + + /** + * The z position of this Game Object. + * + * @name Phaser.GameObjects.Sprite3D#z + * @type {number} + * @since 3.0.0 + */ + z: { + + get: function () + { + return this.position.z; + }, + + set: function (value) + { + this.position.z = value; + } + + } + +}); + +module.exports = Sprite3D; + + +/***/ }), +/* 102 */ /***/ (function(module, exports) { /** @@ -19190,187 +19185,31 @@ module.exports = Tileset; */ /** - * [description] + * Shuffles the contents of the given array using the Fisher-Yates implementation. * - * @function Phaser.Tweens.Builders.GetNewValue + * The original array is modified directly and returned. + * + * @function Phaser.Utils.Array.Shuffle * @since 3.0.0 * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {any} defaultValue - [description] + * @param {array} array - The array to shuffle. This array is modified in place. * - * @return {function} [description] + * @return {array} The shuffled array. */ -var GetNewValue = function (source, key, defaultValue) +var Shuffle = function (array) { - var valueCallback; - - if (source.hasOwnProperty(key)) + for (var i = array.length - 1; i > 0; i--) { - var t = typeof(source[key]); - - if (t === 'function') - { - valueCallback = function (index, totalTargets, target) - { - return source[key](index, totalTargets, target); - }; - } - else - { - valueCallback = function () - { - return source[key]; - }; - } - } - else if (typeof defaultValue === 'function') - { - valueCallback = defaultValue; - } - else - { - valueCallback = function () - { - return defaultValue; - }; + var j = Math.floor(Math.random() * (i + 1)); + var temp = array[i]; + array[i] = array[j]; + array[j] = temp; } - return valueCallback; + return array; }; -module.exports = GetNewValue; - - -/***/ }), -/* 102 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Defaults = __webpack_require__(160); -var GetAdvancedValue = __webpack_require__(10); -var GetBoolean = __webpack_require__(73); -var GetEaseFunction = __webpack_require__(71); -var GetNewValue = __webpack_require__(101); -var GetProps = __webpack_require__(359); -var GetTargets = __webpack_require__(158); -var GetValue = __webpack_require__(4); -var GetValueOp = __webpack_require__(159); -var Tween = __webpack_require__(161); -var TweenData = __webpack_require__(162); - -/** - * [description] - * - * @function Phaser.Tweens.Builders.TweenBuilder - * @since 3.0.0 - * - * @param {Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline} parent - [description] - * @param {object} config - [description] - * @param {Phaser.Tweens.Tween~ConfigDefaults} defaults - [description] - * - * @return {Phaser.Tweens.Tween} [description] - */ -var TweenBuilder = function (parent, config, defaults) -{ - if (defaults === undefined) - { - defaults = Defaults; - } - - // Create arrays of the Targets and the Properties - var targets = (defaults.targets) ? defaults.targets : GetTargets(config); - - // var props = (defaults.props) ? defaults.props : GetProps(config); - var props = GetProps(config); - - // Default Tween values - var delay = GetNewValue(config, 'delay', defaults.delay); - var duration = GetNewValue(config, 'duration', defaults.duration); - var easeParams = GetValue(config, 'easeParams', defaults.easeParams); - var ease = GetEaseFunction(GetValue(config, 'ease', defaults.ease), easeParams); - var hold = GetNewValue(config, 'hold', defaults.hold); - var repeat = GetNewValue(config, 'repeat', defaults.repeat); - var repeatDelay = GetNewValue(config, 'repeatDelay', defaults.repeatDelay); - var yoyo = GetBoolean(config, 'yoyo', defaults.yoyo); - var flipX = GetBoolean(config, 'flipX', defaults.flipX); - var flipY = GetBoolean(config, 'flipY', defaults.flipY); - - var data = []; - - // Loop through every property defined in the Tween, i.e.: props { x, y, alpha } - for (var p = 0; p < props.length; p++) - { - var key = props[p].key; - var value = props[p].value; - - // Create 1 TweenData per target, per property - for (var t = 0; t < targets.length; t++) - { - var ops = GetValueOp(key, value); - - var tweenData = TweenData( - targets[t], - key, - ops.getEnd, - ops.getStart, - GetEaseFunction(GetValue(value, 'ease', ease), easeParams), - GetNewValue(value, 'delay', delay), - GetNewValue(value, 'duration', duration), - GetBoolean(value, 'yoyo', yoyo), - GetNewValue(value, 'hold', hold), - GetNewValue(value, 'repeat', repeat), - GetNewValue(value, 'repeatDelay', repeatDelay), - GetBoolean(value, 'flipX', flipX), - GetBoolean(value, 'flipY', flipY) - ); - - data.push(tweenData); - } - } - - var tween = new Tween(parent, data, targets); - - tween.offset = GetAdvancedValue(config, 'offset', null); - tween.completeDelay = GetAdvancedValue(config, 'completeDelay', 0); - tween.loop = Math.round(GetAdvancedValue(config, 'loop', 0)); - tween.loopDelay = Math.round(GetAdvancedValue(config, 'loopDelay', 0)); - tween.paused = GetBoolean(config, 'paused', false); - tween.useFrames = GetBoolean(config, 'useFrames', false); - - // Set the Callbacks - var scope = GetValue(config, 'callbackScope', tween); - - // Callback parameters: 0 = a reference to the Tween itself, 1 = the target/s of the Tween, ... your own params - var tweenArray = [ tween, null ]; - - var callbacks = Tween.TYPES; - - for (var i = 0; i < callbacks.length; i++) - { - var type = callbacks[i]; - - var callback = GetValue(config, type, false); - - if (callback) - { - var callbackScope = GetValue(config, type + 'Scope', scope); - var callbackParams = GetValue(config, type + 'Params', []); - - // The null is reset to be the Tween target - tween.setCallback(type, callback, tweenArray.concat(callbackParams), callbackScope); - } - } - - return tween; -}; - -module.exports = TweenBuilder; +module.exports = Shuffle; /***/ }), @@ -19384,7 +19223,1115 @@ module.exports = TweenBuilder; */ var Class = __webpack_require__(0); -var Utils = __webpack_require__(41); + +/** + * @callback DataEachCallback + * + * @param {*} parent - [description] + * @param {string} key - [description] + * @param {*} value - [description] + * @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the game object, key, and data. + */ + +/** + * @classdesc + * The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin. + * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter, + * or have a property called `events` that is an instance of it. + * + * @class DataManager + * @memberOf Phaser.Data + * @constructor + * @since 3.0.0 + * + * @param {*} parent - [description] + * @param {EventEmitter} eventEmitter - [description] + */ +var DataManager = new Class({ + + initialize: + + function DataManager (parent, eventEmitter) + { + /** + * [description] + * + * @name Phaser.Data.DataManager#parent + * @type {*} + * @since 3.0.0 + */ + this.parent = parent; + + /** + * [description] + * + * @name Phaser.Data.DataManager#events + * @type {EventEmitter} + * @since 3.0.0 + */ + this.events = eventEmitter; + + if (!eventEmitter) + { + this.events = (parent.events) ? parent.events : parent; + } + + /** + * [description] + * + * @name Phaser.Data.DataManager#list + * @type {Object.} + * @default {} + * @since 3.0.0 + */ + this.list = {}; + + /** + * [description] + * + * @name Phaser.Data.DataManager#blockSet + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.blockSet = false; + + /** + * [description] + * + * @name Phaser.Data.DataManager#_frozen + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._frozen = false; + + this.events.once('destroy', this.destroy, this); + }, + + /** + * Retrieves the value for the given key, or undefined if it doesn't exist. + * + * @method Phaser.Data.DataManager#get + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {*} [description] + */ + get: function (key) + { + return this.list[key]; + }, + + /** + * [description] + * + * @method Phaser.Data.DataManager#getAll + * @since 3.0.0 + * + * @return {Object.} [description] + */ + getAll: function () + { + var results = {}; + + for (var key in this.list) + { + if(this.list.hasOwnProperty(key)) + { + results[key] = this.list[key]; + } + } + + return results; + }, + + /** + * [description] + * + * @method Phaser.Data.DataManager#query + * @since 3.0.0 + * + * @param {string} search - [description] + * + * @return {Object.} [description] + */ + query: function (search) + { + var results = {}; + + for (var key in this.list) + { + if (this.list.hasOwnProperty(key) && key.match(search)) + { + results[key] = this.list[key]; + } + } + + return results; + }, + + /** + * [description] + * + * @method Phaser.Data.DataManager#set + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {*} data - [description] + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + set: function (key, data) + { + if (this._frozen) + { + return this; + } + + if (this.events.listenerCount('changedata') > 0) + { + this.blockSet = false; + + var _this = this; + + var resetFunction = function (value) + { + _this.blockSet = true; + _this.list[key] = value; + _this.events.emit('setdata', _this.parent, key, value); + }; + + this.events.emit('changedata', this.parent, key, data, resetFunction); + + // One of the listeners blocked this update from being set, so abort + if (this.blockSet) + { + return this; + } + } + + this.list[key] = data; + + this.events.emit('setdata', this.parent, key, data); + + return this; + }, + + /** + * Passes all data entries to the given callback. Stores the result of the callback. + * + * @method Phaser.Data.DataManager#each + * @since 3.0.0 + * + * @param {DataEachCallback} callback - The function to call. + * @param {object} [scope] - Value to use as `this` when executing callback. + * @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the game object, key, and data. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + each: function (callback, scope) + { + var args = [ this.parent, null, undefined ]; + + for (var i = 1; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (var key in this.list) + { + args[1] = key; + args[2] = this.list[key]; + + callback.apply(scope, args); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Data.DataManager#merge + * @since 3.0.0 + * + * @param {Object.} data - [description] + * @param {boolean} overwrite - [description] + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + merge: function (data, overwrite) + { + if (overwrite === undefined) { overwrite = true; } + + // Merge data from another component into this one + for (var key in data) + { + if (data.hasOwnProperty(key) && (overwrite || (!overwrite && !this.has(key)))) + { + this.list[key] = data[key]; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Data.DataManager#remove + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + remove: function (key) + { + if (!this._frozen && this.has(key)) + { + var data = this.list[key]; + + delete this.list[key]; + + this.events.emit('removedata', this, key, data); + } + + return this; + }, + + /** + * Gets the data associated with the given 'key', deletes it from this Data store, then returns it. + * + * @method Phaser.Data.DataManager#pop + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {*} [description] + */ + pop: function (key) + { + var data = undefined; + + if (!this._frozen && this.has(key)) + { + data = this.list[key]; + + delete this.list[key]; + + this.events.emit('removedata', this, key, data); + } + + return data; + }, + + /** + * [description] + * + * @method Phaser.Data.DataManager#has + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {boolean} [description] + */ + has: function (key) + { + return this.list.hasOwnProperty(key); + }, + + /** + * [description] + * + * @method Phaser.Data.DataManager#setFreeze + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + setFreeze: function (value) + { + this._frozen = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Data.DataManager#reset + * @since 3.0.0 + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + reset: function () + { + for (var key in this.list) + { + delete this.list[key]; + } + + this.blockSet = false; + this._frozen = false; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Data.DataManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.reset(); + + this.events.off('changedata'); + this.events.off('setdata'); + this.events.off('removedata'); + + this.parent = null; + }, + + /** + * Freeze this Data component, so no changes can be written to it. + * + * @name Phaser.Data.DataManager#freeze + * @type {boolean} + * @since 3.0.0 + */ + freeze: { + + get: function () + { + return this._frozen; + }, + + set: function (value) + { + this._frozen = (value) ? true : false; + } + + }, + + /** + * Return the total number of entries in this Data component. + * + * @name Phaser.Data.DataManager#count + * @type {integer} + * @since 3.0.0 + */ + count: { + + get: function () + { + var i = 0; + + for (var key in this.list) + { + if (this.list[key] !== undefined) + { + i++; + } + } + + return i; + } + + } + +}); + +module.exports = DataManager; + + +/***/ }), +/* 104 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetPoint = __webpack_require__(351); +var GetPoints = __webpack_require__(165); +var Random = __webpack_require__(164); +var Vector2 = __webpack_require__(6); + +/** + * @classdesc + * Defines a Line segment, a part of a line between two endpoints. + * + * @class Line + * @memberOf Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x1] - [description] + * @param {number} [y1] - [description] + * @param {number} [x2] - [description] + * @param {number} [y2] - [description] + */ +var Line = new Class({ + + initialize: + + function Line (x1, y1, x2, y2) + { + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 0; } + if (y2 === undefined) { y2 = 0; } + + /** + * [description] + * + * @name Phaser.Geom.Line#x1 + * @type {number} + * @since 3.0.0 + */ + this.x1 = x1; + + /** + * [description] + * + * @name Phaser.Geom.Line#y1 + * @type {number} + * @since 3.0.0 + */ + this.y1 = y1; + + /** + * [description] + * + * @name Phaser.Geom.Line#x2 + * @type {number} + * @since 3.0.0 + */ + this.x2 = x2; + + /** + * [description] + * + * @name Phaser.Geom.Line#y2 + * @type {number} + * @since 3.0.0 + */ + this.y2 = y2; + }, + + /** + * [description] + * + * @method Phaser.Geom.Line#getPoint + * @since 3.0.0 + * + * @param {float} position - [description] + * @param {(Phaser.Geom.Point|object)} [output] - [description] + * + * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the ellipse. + */ + getPoint: function (position, output) + { + return GetPoint(this, position, output); + }, + + /** + * [description] + * + * @method Phaser.Geom.Line#getPoints + * @since 3.0.0 + * + * @param {integer} quantity - [description] + * @param {integer} [stepRate] - [description] + * @param {(array|Phaser.Geom.Point[])} [output] - [description] + * + * @return {(array|Phaser.Geom.Point[])} [description] + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * [description] + * + * @method Phaser.Geom.Line#getRandomPoint + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point - [description] + * + * @return {Phaser.Geom.Point} [description] + */ + getRandomPoint: function (point) + { + return Random(this, point); + }, + + /** + * [description] + * + * @method Phaser.Geom.Line#setTo + * @since 3.0.0 + * + * @param {number} [x1=0] - [description] + * @param {number} [y1=0] - [description] + * @param {number} [x2=0] - [description] + * @param {number} [y2=0] - [description] + * + * @return {Phaser.Geom.Line} This Line object. + */ + setTo: function (x1, y1, x2, y2) + { + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 0; } + if (y2 === undefined) { y2 = 0; } + + this.x1 = x1; + this.y1 = y1; + + this.x2 = x2; + this.y2 = y2; + + return this; + }, + + /** + * Returns a Vector2 object that corresponds to the start of this Line. + * + * @method Phaser.Geom.Line#getPointA + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. + * + * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the start of this Line. + */ + getPointA: function (vec2) + { + if (vec2 === undefined) { vec2 = new Vector2(); } + + vec2.setTo(this.x1, this.y1); + + return vec2; + }, + + /** + * Returns a Vector2 object that corresponds to the start of this Line. + * + * @method Phaser.Geom.Line#getPointB + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. + * + * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the start of this Line. + */ + getPointB: function (vec2) + { + if (vec2 === undefined) { vec2 = new Vector2(); } + + vec2.setTo(this.x2, this.y2); + + return vec2; + }, + + /** + * The left position of the Line. + * + * @name Phaser.Geom.Line#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () + { + return Math.min(this.x1, this.x2); + }, + + set: function (value) + { + if (this.x1 <= this.x2) + { + this.x1 = value; + } + else + { + this.x2 = value; + } + } + + }, + + /** + * The right position of the Line. + * + * @name Phaser.Geom.Line#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return Math.max(this.x1, this.x2); + }, + + set: function (value) + { + if (this.x1 > this.x2) + { + this.x1 = value; + } + else + { + this.x2 = value; + } + } + + }, + + /** + * The top position of the Line. + * + * @name Phaser.Geom.Line#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return Math.min(this.y1, this.y2); + }, + + set: function (value) + { + if (this.y1 <= this.y2) + { + this.y1 = value; + } + else + { + this.y2 = value; + } + } + + }, + + /** + * The bottom position of the Line. + * + * @name Phaser.Geom.Line#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return Math.max(this.y1, this.y2); + }, + + set: function (value) + { + if (this.y1 > this.y2) + { + this.y1 = value; + } + else + { + this.y2 = value; + } + } + + } + +}); + +module.exports = Line; + + +/***/ }), +/* 105 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Perimeter + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {number} [description] + */ +var Perimeter = function (rect) +{ + return 2 * (rect.width + rect.height); +}; + +module.exports = Perimeter; + + +/***/ }), +/* 106 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BlendModes = __webpack_require__(62); +var Circle = __webpack_require__(79); +var CircleContains = __webpack_require__(28); +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var GameObject = __webpack_require__(1); +var Rectangle = __webpack_require__(10); +var RectangleContains = __webpack_require__(27); + +/** + * @classdesc + * A Zone Game Object. + * + * A Zone is a non-rendering rectangular Game Object that has a position and size. + * It has no texture and never displays, but does live on the display list and + * can be moved, scaled and rotated like any other Game Object. + * + * Its primary use is for creating Drop Zones and Input Hit Areas and it has a couple of helper methods + * specifically for this. It is also useful for object overlap checks, or as a base for your own + * non-displaying Game Objects. + + * The default origin is 0.5, the center of the Zone, the same as with Game Objects. + * + * @class Zone + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - [description] + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number} [width=1] - The width of the Game Object. + * @param {number} [height=1] - The height of the Game Object. + */ +var Zone = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Depth, + Components.GetBounds, + Components.Origin, + Components.ScaleMode, + Components.Transform, + Components.ScrollFactor, + Components.Visible + ], + + initialize: + + function Zone (scene, x, y, width, height) + { + if (width === undefined) { width = 1; } + if (height === undefined) { height = width; } + + GameObject.call(this, scene, 'Zone'); + + this.setPosition(x, y); + + /** + * The native (un-scaled) width of this Game Object. + * + * @name Phaser.GameObjects.Zone#width + * @type {number} + * @since 3.0.0 + */ + this.width = width; + + /** + * The native (un-scaled) height of this Game Object. + * + * @name Phaser.GameObjects.Zone#height + * @type {number} + * @since 3.0.0 + */ + this.height = height; + + /** + * The Blend Mode of the Game Object. + * Although a Zone never renders, it still has a blend mode to allow it to fit seamlessly into + * display lists without causing a batch flush. + * + * @name Phaser.GameObjects.Zone#blendMode + * @type {integer} + * @since 3.0.0 + */ + this.blendMode = BlendModes.NORMAL; + }, + + /** + * The displayed width of this Game Object. + * This value takes into account the scale factor. + * + * @name Phaser.GameObjects.Zone#displayWidth + * @type {number} + * @since 3.0.0 + */ + displayWidth: { + + get: function () + { + return this.scaleX * this.width; + }, + + set: function (value) + { + this.scaleX = value / this.width; + } + + }, + + /** + * The displayed height of this Game Object. + * This value takes into account the scale factor. + * + * @name Phaser.GameObjects.Zone#displayHeight + * @type {number} + * @since 3.0.0 + */ + displayHeight: { + + get: function () + { + return this.scaleY * this.height; + }, + + set: function (value) + { + this.scaleY = value / this.height; + } + + }, + + /** + * Sets the size of this Game Object. + * + * @method Phaser.GameObjects.Zone#setSize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * @param {boolean} [resizeInput=true] - If this Zone has a Rectangle for a hit area this argument will resize the hit area as well. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setSize: function (width, height, resizeInput) + { + if (resizeInput === undefined) { resizeInput = true; } + + this.width = width; + this.height = height; + + if (resizeInput && this.input && this.input.hitArea instanceof Rectangle) + { + this.input.hitArea.width = width; + this.input.hitArea.height = height; + } + + return this; + }, + + /** + * Sets the display size of this Game Object. + * Calling this will adjust the scale. + * + * @method Phaser.GameObjects.Zone#setDisplaySize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setDisplaySize: function (width, height) + { + this.displayWidth = width; + this.displayHeight = height; + + return this; + }, + + /** + * Sets this Zone to be a Circular Drop Zone. + * The circle is centered on this Zones `x` and `y` coordinates. + * + * @method Phaser.GameObjects.Zone#setCircleDropZone + * @since 3.0.0 + * + * @param {number} radius - The radius of the Circle that will form the Drop Zone. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setCircleDropZone: function (radius) + { + return this.setDropZone(new Circle(0, 0, radius), CircleContains); + }, + + /** + * Sets this Zone to be a Rectangle Drop Zone. + * The rectangle is centered on this Zones `x` and `y` coordinates. + * + * @method Phaser.GameObjects.Zone#setRectangleDropZone + * @since 3.0.0 + * + * @param {number} width - The width of the rectangle drop zone. + * @param {number} height - The height of the rectangle drop zone. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setRectangleDropZone: function (width, height) + { + var x = -(width / 2); + var y = -(height / 2); + + return this.setDropZone(new Rectangle(x, y, width, height), RectangleContains); + }, + + /** + * Allows you to define your own Geometry shape to be used as a Drop Zone. + * + * @method Phaser.GameObjects.Zone#setDropZone + * @since 3.0.0 + * + * @param {object} shape - A Geometry shape instance, such as Phaser.Geom.Ellipse, or your own custom shape. + * @param {HitAreaCallback} callback - A function that will return `true` if the given x/y coords it is sent are within the shape. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setDropZone: function (shape, callback) + { + if (shape === undefined) + { + this.setRectangleDropZone(this.width, this.height); + } + else + if (!this.input) + { + this.setInteractive(shape, callback, true); + } + + return this; + }, + + /** + * A Zone does not render. + * + * @method Phaser.GameObjects.Zone#renderCanvas + * @private + * @since 3.0.0 + */ + renderCanvas: function () + { + }, + + /** + * A Zone does not render. + * + * @method Phaser.GameObjects.Zone#renderWebGL + * @private + * @since 3.0.0 + */ + renderWebGL: function () + { + } + +}); + +module.exports = Zone; + + +/***/ }), +/* 107 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clone = __webpack_require__(55); + +/** + * Creates a new Object using all values from obj1 and obj2. + * If a value exists in both obj1 and obj2, the value in obj1 is used. + * + * @function Phaser.Utils.Object.Merge + * @since 3.0.0 + * + * @param {object} obj1 - [description] + * @param {object} obj2 - [description] + * + * @return {object} [description] + */ +var Merge = function (obj1, obj2) +{ + var clone = Clone(obj1); + + for (var key in obj2) + { + if (!clone.hasOwnProperty(key)) + { + clone[key] = obj2[key]; + } + } + + return clone; +}; + +module.exports = Merge; + + +/***/ }), +/* 108 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Utils = __webpack_require__(44); /** * @classdesc @@ -19584,10 +20531,10 @@ var WebGLPipeline = new Class({ * @since 3.2.0 * * @param {string} name - [description] - * @param {int} size - [description] - * @param {int} type - [description] + * @param {integer} size - [description] + * @param {integer} type - [description] * @param {boolean} normalized - [description] - * @param {int} offset - [description] + * @param {integer} offset - [description] * * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] */ @@ -19874,7 +20821,7 @@ var WebGLPipeline = new Class({ * @since 3.2.0 * * @param {string} name - [description] - * @param {int} x - [description] + * @param {integer} x - [description] * * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] */ @@ -19891,8 +20838,8 @@ var WebGLPipeline = new Class({ * @since 3.2.0 * * @param {string} name - [description] - * @param {int} x - [description] - * @param {int} y - [description] + * @param {integer} x - [description] + * @param {integer} y - [description] * * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] */ @@ -19909,9 +20856,9 @@ var WebGLPipeline = new Class({ * @since 3.2.0 * * @param {string} name - [description] - * @param {int} x - [description] - * @param {int} y - [description] - * @param {int} z - [description] + * @param {integer} x - [description] + * @param {integer} y - [description] + * @param {integer} z - [description] * * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] */ @@ -19928,10 +20875,10 @@ var WebGLPipeline = new Class({ * @since 3.2.0 * * @param {string} name - [description] - * @param {int} x - [description] - * @param {int} y - [description] - * @param {int} z - [description] - * @param {int} w - [description] + * @param {integer} x - [description] + * @param {integer} y - [description] + * @param {integer} z - [description] + * @param {integer} w - [description] * * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] */ @@ -20000,241 +20947,9 @@ var WebGLPipeline = new Class({ module.exports = WebGLPipeline; -/***/ }), -/* 104 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clone = __webpack_require__(53); - -/** - * Creates a new Object using all values from obj1 and obj2. - * If a value exists in both obj1 and obj2, the value in obj1 is used. - * - * @function Phaser.Utils.Object.Merge - * @since 3.0.0 - * - * @param {object} obj1 - [description] - * @param {object} obj2 - [description] - * - * @return {object} [description] - */ -var Merge = function (obj1, obj2) -{ - var clone = Clone(obj1); - - for (var key in obj2) - { - if (!clone.hasOwnProperty(key)) - { - clone[key] = obj2[key]; - } - } - - return clone; -}; - -module.exports = Merge; - - -/***/ }), -/* 105 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle. - * - * @function Phaser.Geom.Circle.CircumferencePoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on. - * @param {number} angle - The angle from the center of the Circle to the circumference to return the point from. Given in radians. - * @param {Phaser.Geom.Point|object} [out] - A Point, or point-like object, to store the results in. If not given a Point will be created. - * - * @return {Phaser.Geom.Point|object} A Point object where the `x` and `y` properties are the point on the circumference. - */ -var CircumferencePoint = function (circle, angle, out) -{ - if (out === undefined) { out = new Point(); } - - out.x = circle.x + (circle.radius * Math.cos(angle)); - out.y = circle.y + (circle.radius * Math.sin(angle)); - - return out; -}; - -module.exports = CircumferencePoint; - - -/***/ }), -/* 106 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * Returns a uniformly distributed random point from anywhere within the given Circle. - * - * @function Phaser.Geom.Circle.Random - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to get a random point from. - * @param {Phaser.Geom.Point|object} [point] - A Point or point-like object to set the random `x` and `y` values in. - * - * @return {Phaser.Geom.Point|object} A Point object with the random values set in the `x` and `y` properties. - */ -var Random = function (circle, out) -{ - if (out === undefined) { out = new Point(); } - - var t = 2 * Math.PI * Math.random(); - var u = Math.random() + Math.random(); - var r = (u > 1) ? 2 - u : u; - var x = r * Math.cos(t); - var y = r * Math.sin(t); - - out.x = circle.x + (x * circle.radius); - out.y = circle.y + (y * circle.radius); - - return out; -}; - -module.exports = Random; - - -/***/ }), -/* 107 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Perimeter = __webpack_require__(78); -var Point = __webpack_require__(5); - -/** - * Position is a value between 0 and 1 where 0 = the top-left of the rectangle and 0.5 = the bottom right. - * - * @function Phaser.Geom.Rectangle.GetPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rectangle - [description] - * @param {float} position - [description] - * @param {Phaser.Geom.Point|object} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var GetPoint = function (rectangle, position, out) -{ - if (out === undefined) { out = new Point(); } - - if (position <= 0 || position >= 1) - { - out.x = rectangle.x; - out.y = rectangle.y; - - return out; - } - - var p = Perimeter(rectangle) * position; - - if (position > 0.5) - { - p -= (rectangle.width + rectangle.height); - - if (p <= rectangle.width) - { - // Face 3 - out.x = rectangle.right - p; - out.y = rectangle.bottom; - } - else - { - // Face 4 - out.x = rectangle.x; - out.y = rectangle.bottom - (p - rectangle.width); - } - } - else if (p <= rectangle.width) - { - // Face 1 - out.x = rectangle.x + p; - out.y = rectangle.y; - } - else - { - // Face 2 - out.x = rectangle.right; - out.y = rectangle.y + (p - rectangle.width); - } - - return out; -}; - -module.exports = GetPoint; - - -/***/ }), -/* 108 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Random - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Point} out - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Random = function (rect, out) -{ - if (out === undefined) { out = new Point(); } - - out.x = rect.x + (Math.random() * rect.width); - out.y = rect.y + (Math.random() * rect.height); - - return out; -}; - -module.exports = Random; - - /***/ }), /* 109 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -20242,57 +20957,57 @@ module.exports = Random; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Length = __webpack_require__(66); -var Point = __webpack_require__(5); +/** +* A Matrix is simply an array of arrays, where each sub-array (the rows) have the same length: +* +* let matrix2 = [ +* [ 1, 1, 1, 1, 1, 1 ], +* [ 2, 0, 0, 0, 0, 4 ], +* [ 2, 0, 1, 2, 0, 4 ], +* [ 2, 0, 3, 4, 0, 4 ], +* [ 2, 0, 0, 0, 0, 4 ], +* [ 3, 3, 3, 3, 3, 3 ] +*]; +*/ /** * [description] * - * @function Phaser.Geom.Line.GetPoints + * @function Phaser.Utils.Array.Matrix.CheckMatrix * @since 3.0.0 * - * @param {Phaser.Geom.Line} line - [description] - * @param {integer} quantity - [description] - * @param {integer} [stepRate] - [description] - * @param {array} out - [description] + * @param {array} matrix - [description] * - * @return {array} [description] + * @return {boolean} [description] */ -var GetPoints = function (line, quantity, stepRate, out) +var CheckMatrix = function (matrix) { - if (out === undefined) { out = []; } - - // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. - if (!quantity) + if (!Array.isArray(matrix) || matrix.length < 2 || !Array.isArray(matrix[0])) { - quantity = Length(line) / stepRate; + return false; } - var x1 = line.x1; - var y1 = line.y1; + // How long is the first row? + var size = matrix[0].length; - var x2 = line.x2; - var y2 = line.y2; - - for (var i = 0; i < quantity; i++) + // Validate the rest of the rows are the same length + for (var i = 1; i < matrix.length; i++) { - var position = i / quantity; - - var x = x1 + (x2 - x1) * position; - var y = y1 + (y2 - y1) * position; - - out.push(new Point(x, y)); + if (matrix[i].length !== size) + { + return false; + } } - return out; + return true; }; -module.exports = GetPoints; +module.exports = CheckMatrix; /***/ }), /* 110 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -20300,33 +21015,147 @@ module.exports = GetPoints; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); +/** + * @typedef {object} TweenDataGenConfig + * + * @property {function} delay - [description] + * @property {function} duration - [description] + * @property {function} hold - [description] + * @property {function} repeat - [description] + * @property {function} repeatDelay - [description] + */ /** - * Returns a uniformly distributed random point from anywhere within the given Ellipse. + * @typedef {object} Phaser.Tweens.TweenDataConfig * - * @function Phaser.Geom.Ellipse.Random + * @property {object} target - The target to tween. + * @property {string} key - The property of the target being tweened. + * @property {function} getEndValue - The returned value sets what the property will be at the END of the Tween. + * @property {function} getStartValue - The returned value sets what the property will be at the START of the Tween. + * @property {function} ease - The ease function this tween uses. + * @property {number} [duration=0] - Duration of the tween in ms/frames, excludes time for yoyo or repeats. + * @property {number} [totalDuration=0] - The total calculated duration of this TweenData (based on duration, repeat, delay and yoyo) + * @property {number} [delay=0] - Time in ms/frames before tween will start. + * @property {boolean} [yoyo=false] - Cause the tween to return back to its start value after hold has expired. + * @property {number} [hold=0] - Time in ms/frames the tween will pause before running the yoyo or starting a repeat. + * @property {integer} [repeat=0] - Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. + * @property {number} [repeatDelay=0] - Time in ms/frames before the repeat will start. + * @property {boolean} [flipX=false] - Automatically call toggleFlipX when the TweenData yoyos or repeats + * @property {boolean} [flipY=false] - Automatically call toggleFlipY when the TweenData yoyos or repeats + * @property {float} [progress=0] - Between 0 and 1 showing completion of this TweenData. + * @property {float} [elapsed=0] - Delta counter + * @property {integer} [repeatCounter=0] - How many repeats are left to run? + * @property {number} [start=0] - Ease value data. + * @property {number} [current=0] - Ease value data. + * @property {number} [end=0] - Ease value data. + * @property {number} [t1=0] - Time duration 1. + * @property {number} [t2=0] - Time duration 2. + * @property {TweenDataGenConfig} [gen] - LoadValue generation functions. + * @property {integer} [state=0] - TWEEN_CONST.CREATED + */ + +/** + * [description] + * + * @function Phaser.Tweens.TweenData * @since 3.0.0 * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get a random point from. - * @param {Phaser.Geom.Point|object} [point] - A Point or point-like object to set the random `x` and `y` values in. + * @param {object} target - [description] + * @param {string} key - [description] + * @param {function} getEnd - [description] + * @param {function} getStart - [description] + * @param {function} ease - [description] + * @param {number} delay - [description] + * @param {number} duration - [description] + * @param {boolean} yoyo - [description] + * @param {number} hold - [description] + * @param {number} repeat - [description] + * @param {number} repeatDelay - [description] + * @param {boolean} flipX - [description] + * @param {boolean} flipY - [description] * - * @return {Phaser.Geom.Point|object} A Point object with the random values set in the `x` and `y` properties. + * @return {TweenDataConfig} [description] */ -var Random = function (ellipse, out) +var TweenData = function (target, key, getEnd, getStart, ease, delay, duration, yoyo, hold, repeat, repeatDelay, flipX, flipY) { - if (out === undefined) { out = new Point(); } + return { - var p = Math.random() * Math.PI * 2; - var s = Math.sqrt(Math.random()); + // The target to tween + target: target, - out.x = ellipse.x + ((s * Math.cos(p)) * ellipse.width / 2); - out.y = ellipse.y + ((s * Math.sin(p)) * ellipse.height / 2); + // The property of the target to tween + key: key, - return out; + // The returned value sets what the property will be at the END of the Tween. + getEndValue: getEnd, + + // The returned value sets what the property will be at the START of the Tween. + getStartValue: getStart, + + // The ease function this tween uses. + ease: ease, + + // Duration of the tween in ms/frames, excludes time for yoyo or repeats. + duration: 0, + + // The total calculated duration of this TweenData (based on duration, repeat, delay and yoyo) + totalDuration: 0, + + // Time in ms/frames before tween will start. + delay: 0, + + // Cause the tween to return back to its start value after hold has expired. + yoyo: yoyo, + + // Time in ms/frames the tween will pause before running the yoyo or starting a repeat. + hold: 0, + + // Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. + repeat: 0, + + // Time in ms/frames before the repeat will start. + repeatDelay: 0, + + // Automatically call toggleFlipX when the TweenData yoyos or repeats + flipX: flipX, + + // Automatically call toggleFlipY when the TweenData yoyos or repeats + flipY: flipY, + + // Between 0 and 1 showing completion of this TweenData. + progress: 0, + + // Delta counter. + elapsed: 0, + + // How many repeats are left to run? + repeatCounter: 0, + + // Ease Value Data: + + start: 0, + current: 0, + end: 0, + + // Time Durations + t1: 0, + t2: 0, + + // LoadValue generation functions + gen: { + delay: delay, + duration: duration, + hold: hold, + repeat: repeat, + repeatDelay: repeatDelay + }, + + // TWEEN_CONST.CREATED + state: 0 + }; }; -module.exports = Random; +module.exports = TweenData; /***/ }), @@ -20339,37 +21168,1378 @@ module.exports = Random; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); +var Class = __webpack_require__(0); +var GameObjectCreator = __webpack_require__(11); +var GameObjectFactory = __webpack_require__(9); +var TWEEN_CONST = __webpack_require__(68); /** + * @classdesc * [description] * - * @function Phaser.Geom.Line.Random + * @class Tween + * @memberOf Phaser.Tweens + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Line} line - [description] - * @param {Phaser.Geom.Point|object} [out] - [description] - * - * @return {Phaser.Geom.Point|object} [description] + * @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - [description] + * @param {Phaser.Tweens.TweenDataConfig[]} data - [description] + * @param {array} targets - [description] */ -var Random = function (line, out) +var Tween = new Class({ + + initialize: + + function Tween (parent, data, targets) + { + /** + * [description] + * + * @name Phaser.Tweens.Tween#parent + * @type {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} + * @since 3.0.0 + */ + this.parent = parent; + + /** + * Is the parent of this Tween a Timeline? + * + * @name Phaser.Tweens.Tween#parentIsTimeline + * @type {boolean} + * @since 3.0.0 + */ + this.parentIsTimeline = parent.hasOwnProperty('isTimeline'); + + /** + * An array of TweenData objects, each containing a unique property and target being tweened. + * + * @name Phaser.Tweens.Tween#data + * @type {Phaser.Tweens.TweenDataConfig[]} + * @since 3.0.0 + */ + this.data = data; + + /** + * data array doesn't change, so we can cache the length + * + * @name Phaser.Tweens.Tween#totalData + * @type {integer} + * @since 3.0.0 + */ + this.totalData = data.length; + + /** + * An array of references to the target/s this Tween is operating on + * + * @name Phaser.Tweens.Tween#targets + * @type {object[]} + * @since 3.0.0 + */ + this.targets = targets; + + /** + * Cached target total (not necessarily the same as the data total) + * + * @name Phaser.Tweens.Tween#totalTargets + * @type {integer} + * @since 3.0.0 + */ + this.totalTargets = targets.length; + + /** + * If true then duration, delay, etc values are all frame totals. + * + * @name Phaser.Tweens.Tween#useFrames + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.useFrames = false; + + /** + * Scales the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. + * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. + * + * @name Phaser.Tweens.Tween#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * Loop this tween? Can be -1 for an infinite loop, or an integer. + * When enabled it will play through ALL TweenDatas again (use TweenData.repeat to loop a single TD) + * + * @name Phaser.Tweens.Tween#loop + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loop = 0; + + /** + * Time in ms/frames before the tween loops. + * + * @name Phaser.Tweens.Tween#loopDelay + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loopDelay = 0; + + /** + * How many loops are left to run? + * + * @name Phaser.Tweens.Tween#loopCounter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loopCounter = 0; + + /** + * Time in ms/frames before the 'onComplete' event fires. This never fires if loop = -1 (as it never completes) + * + * @name Phaser.Tweens.Tween#completeDelay + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.completeDelay = 0; + + /** + * Countdown timer (used by timeline offset, loopDelay and completeDelay) + * + * @name Phaser.Tweens.Tween#countdown + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.countdown = 0; + + /** + * Set only if this Tween is part of a Timeline. + * + * @name Phaser.Tweens.Tween#offset + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.offset = 0; + + /** + * Set only if this Tween is part of a Timeline. The calculated offset amount. + * + * @name Phaser.Tweens.Tween#calculatedOffset + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.calculatedOffset = 0; + + /** + * The current state of the tween + * + * @name Phaser.Tweens.Tween#state + * @type {integer} + * @since 3.0.0 + */ + this.state = TWEEN_CONST.PENDING_ADD; + + /** + * The state of the tween when it was paused (used by Resume) + * + * @name Phaser.Tweens.Tween#_pausedState + * @type {integer} + * @private + * @since 3.0.0 + */ + this._pausedState = TWEEN_CONST.PENDING_ADD; + + /** + * Does the Tween start off paused? (if so it needs to be started with Tween.play) + * + * @name Phaser.Tweens.Tween#paused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.paused = false; + + /** + * Elapsed time in ms/frames of this run through the Tween. + * + * @name Phaser.Tweens.Tween#elapsed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.elapsed = 0; + + /** + * Total elapsed time in ms/frames of the entire Tween, including looping. + * + * @name Phaser.Tweens.Tween#totalElapsed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalElapsed = 0; + + /** + * Time in ms/frames for the whole Tween to play through once, excluding loop amounts and loop delays. + * + * @name Phaser.Tweens.Tween#duration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.duration = 0; + + /** + * Value between 0 and 1. The amount through the Tween, excluding loops. + * + * @name Phaser.Tweens.Tween#progress + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.progress = 0; + + /** + * Time in ms/frames for the Tween to complete (including looping) + * + * @name Phaser.Tweens.Tween#totalDuration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalDuration = 0; + + /** + * Value between 0 and 1. The amount through the entire Tween, including looping. + * + * @name Phaser.Tweens.Tween#totalProgress + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalProgress = 0; + + /** + * An object containing the various Tween callback references. + * + * @name Phaser.Tweens.Tween#callbacks + * @type {object} + * @default 0 + * @since 3.0.0 + */ + this.callbacks = { + onComplete: null, + onLoop: null, + onRepeat: null, + onStart: null, + onUpdate: null, + onYoyo: null + }; + + this.callbackScope; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#getValue + * @since 3.0.0 + * + * @return {number} [description] + */ + getValue: function () + { + return this.data[0].current; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#setTimeScale + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + setTimeScale: function (value) + { + this.timeScale = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#getTimeScale + * @since 3.0.0 + * + * @return {number} [description] + */ + getTimeScale: function () + { + return this.timeScale; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#isPlaying + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isPlaying: function () + { + return (this.state === TWEEN_CONST.ACTIVE); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#isPaused + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isPaused: function () + { + return (this.state === TWEEN_CONST.PAUSED); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#hasTarget + * @since 3.0.0 + * + * @param {object} target - [description] + * + * @return {boolean} [description] + */ + hasTarget: function (target) + { + return (this.targets.indexOf(target) !== -1); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#updateTo + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {*} value - [description] + * @param {boolean} startToCurrent - [description] + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + updateTo: function (key, value, startToCurrent) + { + for (var i = 0; i < this.totalData; i++) + { + var tweenData = this.data[i]; + + if (tweenData.key === key) + { + tweenData.end = value; + + if (startToCurrent) + { + tweenData.start = tweenData.current; + } + + break; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#restart + * @since 3.0.0 + */ + restart: function () + { + this.stop(); + this.play(); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#calcDuration + * @since 3.0.0 + */ + calcDuration: function () + { + var max = 0; + + var data = this.data; + + for (var i = 0; i < this.totalData; i++) + { + var tweenData = data[i]; + + // Set t1 (duration + hold + yoyo) + tweenData.t1 = tweenData.duration + tweenData.hold; + + if (tweenData.yoyo) + { + tweenData.t1 += tweenData.duration; + } + + // Set t2 (repeatDelay + duration + hold + yoyo) + tweenData.t2 = tweenData.t1 + tweenData.repeatDelay; + + // Total Duration + tweenData.totalDuration = tweenData.delay + tweenData.t1; + + if (tweenData.repeat === -1) + { + tweenData.totalDuration += (tweenData.t2 * 999999999999); + } + else if (tweenData.repeat > 0) + { + tweenData.totalDuration += (tweenData.t2 * tweenData.repeat); + } + + if (tweenData.totalDuration > max) + { + // Get the longest TweenData from the Tween, used to calculate the Tween TD + max = tweenData.totalDuration; + } + } + + // Excludes loop values + this.duration = max; + + this.loopCounter = (this.loop === -1) ? 999999999999 : this.loop; + + if (this.loopCounter > 0) + { + this.totalDuration = this.duration + this.completeDelay + ((this.duration + this.loopDelay) * this.loopCounter); + } + else + { + this.totalDuration = this.duration + this.completeDelay; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#init + * @since 3.0.0 + * + * @return {boolean} Returns `true` if this Tween should be moved from the pending list to the active list by the Tween Manager. + */ + init: function () + { + var data = this.data; + var totalTargets = this.totalTargets; + + for (var i = 0; i < this.totalData; i++) + { + var tweenData = data[i]; + var target = tweenData.target; + var gen = tweenData.gen; + + tweenData.delay = gen.delay(i, totalTargets, target); + tweenData.duration = gen.duration(i, totalTargets, target); + tweenData.hold = gen.hold(i, totalTargets, target); + tweenData.repeat = gen.repeat(i, totalTargets, target); + tweenData.repeatDelay = gen.repeatDelay(i, totalTargets, target); + } + + this.calcDuration(); + + this.progress = 0; + this.totalProgress = 0; + this.elapsed = 0; + this.totalElapsed = 0; + + // You can't have a paused Tween if it's part of a Timeline + if (this.paused && !this.parentIsTimeline) + { + this.state = TWEEN_CONST.PENDING_ADD; + + return false; + } + else + { + this.state = TWEEN_CONST.INIT; + + return true; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#nextState + * @since 3.0.0 + */ + nextState: function () + { + if (this.loopCounter > 0) + { + this.elapsed = 0; + this.progress = 0; + this.loopCounter--; + + var onLoop = this.callbacks.onLoop; + + if (onLoop) + { + onLoop.params[1] = this.targets; + + onLoop.func.apply(onLoop.scope, onLoop.params); + } + + this.resetTweenData(true); + + if (this.loopDelay > 0) + { + this.countdown = this.loopDelay; + this.state = TWEEN_CONST.LOOP_DELAY; + } + else + { + this.state = TWEEN_CONST.ACTIVE; + } + } + else if (this.completeDelay > 0) + { + this.countdown = this.completeDelay; + this.state = TWEEN_CONST.COMPLETE_DELAY; + } + else + { + var onComplete = this.callbacks.onComplete; + + if (onComplete) + { + onComplete.params[1] = this.targets; + + onComplete.func.apply(onComplete.scope, onComplete.params); + } + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#pause + * @since 3.0.0 + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + pause: function () + { + if (this.state === TWEEN_CONST.PAUSED) + { + return; + } + + this.paused = true; + + this._pausedState = this.state; + + this.state = TWEEN_CONST.PAUSED; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#play + * @since 3.0.0 + * + * @param {boolean} resetFromTimeline - [description] + */ + play: function (resetFromTimeline) + { + if (this.state === TWEEN_CONST.ACTIVE) + { + return; + } + else if (this.state === TWEEN_CONST.PENDING_REMOVE || this.state === TWEEN_CONST.REMOVED) + { + this.init(); + this.parent.makeActive(this); + resetFromTimeline = true; + } + + var onStart = this.callbacks.onStart; + + if (this.parentIsTimeline) + { + this.resetTweenData(resetFromTimeline); + + if (this.calculatedOffset === 0) + { + if (onStart) + { + onStart.params[1] = this.targets; + + onStart.func.apply(onStart.scope, onStart.params); + } + + this.state = TWEEN_CONST.ACTIVE; + } + else + { + this.countdown = this.calculatedOffset; + + this.state = TWEEN_CONST.OFFSET_DELAY; + } + } + else if (this.paused) + { + this.paused = false; + + this.parent.makeActive(this); + } + else + { + this.resetTweenData(resetFromTimeline); + + this.state = TWEEN_CONST.ACTIVE; + + if (onStart) + { + onStart.params[1] = this.targets; + + onStart.func.apply(onStart.scope, onStart.params); + } + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#resetTweenData + * @since 3.0.0 + * + * @param {boolean} resetFromLoop - [description] + */ + resetTweenData: function (resetFromLoop) + { + var data = this.data; + + for (var i = 0; i < this.totalData; i++) + { + var tweenData = data[i]; + + tweenData.progress = 0; + tweenData.elapsed = 0; + + tweenData.repeatCounter = (tweenData.repeat === -1) ? 999999999999 : tweenData.repeat; + + if (resetFromLoop) + { + tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); + + tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.end); + + tweenData.current = tweenData.start; + + tweenData.state = TWEEN_CONST.PLAYING_FORWARD; + } + else if (tweenData.delay > 0) + { + tweenData.elapsed = tweenData.delay; + tweenData.state = TWEEN_CONST.DELAY; + } + else + { + tweenData.state = TWEEN_CONST.PENDING_RENDER; + } + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#resume + * @since 3.0.0 + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + resume: function () + { + if (this.state === TWEEN_CONST.PAUSED) + { + this.paused = false; + + this.state = this._pausedState; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#seek + * @since 3.0.0 + * + * @param {float} toPosition - A value between 0 and 1. + */ + seek: function (toPosition) + { + var data = this.data; + + for (var i = 0; i < this.totalData; i++) + { + // This won't work with loop > 0 yet + var ms = this.totalDuration * toPosition; + + var tweenData = data[i]; + var progress = 0; + var elapsed = 0; + + if (ms <= tweenData.delay) + { + progress = 0; + elapsed = 0; + } + else if (ms >= tweenData.totalDuration) + { + progress = 1; + elapsed = tweenData.duration; + } + else if (ms > tweenData.delay && ms <= tweenData.t1) + { + // Keep it zero bound + ms = Math.max(0, ms - tweenData.delay); + + // Somewhere in the first playthru range + progress = ms / tweenData.t1; + elapsed = tweenData.duration * progress; + } + else if (ms > tweenData.t1 && ms < tweenData.totalDuration) + { + // Somewhere in repeat land + ms -= tweenData.delay; + ms -= tweenData.t1; + + // var repeats = Math.floor(ms / tweenData.t2); + + // remainder + ms = ((ms / tweenData.t2) % 1) * tweenData.t2; + + if (ms > tweenData.repeatDelay) + { + progress = ms / tweenData.t1; + elapsed = tweenData.duration * progress; + } + } + + tweenData.progress = progress; + tweenData.elapsed = elapsed; + + var v = tweenData.ease(tweenData.progress); + + tweenData.current = tweenData.start + ((tweenData.end - tweenData.start) * v); + + // console.log(tweenData.key, 'Seek', tweenData.target[tweenData.key], 'to', tweenData.current, 'pro', tweenData.progress, 'marker', toPosition, progress); + + // if (tweenData.current === 0) + // { + // console.log('zero', tweenData.start, tweenData.end, v, 'progress', progress); + // } + + tweenData.target[tweenData.key] = tweenData.current; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#setCallback + * @since 3.0.0 + * + * @param {string} type - [description] + * @param {function} callback - [description] + * @param {array} [params] - [description] + * @param {object} [scope] - [description] + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + setCallback: function (type, callback, params, scope) + { + this.callbacks[type] = { func: callback, scope: scope, params: params }; + + return this; + }, + + /** + * Flags the Tween as being complete, whatever stage of progress it is at. + * + * If an onComplete callback has been defined it will automatically invoke it, unless a `delay` + * argument is provided, in which case the Tween will delay for that period of time before calling the callback. + * + * If you don't need a delay, or have an onComplete callback, then call `Tween.stop` instead. + * + * @method Phaser.Tweens.Tween#complete + * @since 3.2.0 + * + * @param {number} [delay=0] - The time to wait before invoking the complete callback. If zero it will fire immediately. + */ + complete: function (delay) + { + if (delay === undefined) { delay = 0; } + + if (delay) + { + this.countdown = delay; + this.state = TWEEN_CONST.COMPLETE_DELAY; + } + else + { + var onComplete = this.callbacks.onComplete; + + if (onComplete) + { + onComplete.params[1] = this.targets; + + onComplete.func.apply(onComplete.scope, onComplete.params); + } + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + }, + + /** + * Stops the Tween immediately, whatever stage of progress it is at and flags it for removal by the TweenManager. + * + * @method Phaser.Tweens.Tween#stop + * @since 3.0.0 + * + * @param {float} [resetTo] - A value between 0 and 1. + */ + stop: function (resetTo) + { + if (this.state === TWEEN_CONST.ACTIVE) + { + if (resetTo !== undefined) + { + this.seek(resetTo); + } + } + + if (this.state !== TWEEN_CONST.REMOVED) + { + this.state = TWEEN_CONST.PENDING_REMOVE; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#update + * @since 3.0.0 + * + * @param {number} timestamp - [description] + * @param {number} delta - [description] + * + * @return {boolean} Returns `true` if this Tween has finished and should be removed from the Tween Manager, otherwise returns `false`. + */ + update: function (timestamp, delta) + { + if (this.state === TWEEN_CONST.PAUSED) + { + return false; + } + + if (this.useFrames) + { + delta = 1 * this.parent.timeScale; + } + + delta *= this.timeScale; + + this.elapsed += delta; + this.progress = Math.min(this.elapsed / this.duration, 1); + + this.totalElapsed += delta; + this.totalProgress = Math.min(this.totalElapsed / this.totalDuration, 1); + + switch (this.state) + { + case TWEEN_CONST.ACTIVE: + + var stillRunning = false; + + for (var i = 0; i < this.totalData; i++) + { + if (this.updateTweenData(this, this.data[i], delta)) + { + stillRunning = true; + } + } + + // Anything still running? If not, we're done + if (!stillRunning) + { + this.nextState(); + } + + break; + + case TWEEN_CONST.LOOP_DELAY: + + this.countdown -= delta; + + if (this.countdown <= 0) + { + this.state = TWEEN_CONST.ACTIVE; + } + + break; + + case TWEEN_CONST.OFFSET_DELAY: + + this.countdown -= delta; + + if (this.countdown <= 0) + { + var onStart = this.callbacks.onStart; + + if (onStart) + { + onStart.params[1] = this.targets; + + onStart.func.apply(onStart.scope, onStart.params); + } + + this.state = TWEEN_CONST.ACTIVE; + } + + break; + + case TWEEN_CONST.COMPLETE_DELAY: + + this.countdown -= delta; + + if (this.countdown <= 0) + { + var onComplete = this.callbacks.onComplete; + + if (onComplete) + { + onComplete.func.apply(onComplete.scope, onComplete.params); + } + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + + break; + } + + return (this.state === TWEEN_CONST.PENDING_REMOVE); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#setStateFromEnd + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] + * @param {number} diff - [description] + * + * @return {integer} The state of this Tween. + */ + setStateFromEnd: function (tween, tweenData, diff) + { + if (tweenData.yoyo) + { + // We've hit the end of a Playing Forward TweenData and we have a yoyo + + // Account for any extra time we got from the previous frame + tweenData.elapsed = diff; + tweenData.progress = diff / tweenData.duration; + + if (tweenData.flipX) + { + tweenData.target.toggleFlipX(); + } + + // Problem: The flip and callback and so on gets called for every TweenData that triggers it at the same time. + // If you're tweening several properties it can fire for all of them, at once. + + if (tweenData.flipY) + { + tweenData.target.toggleFlipY(); + } + + var onYoyo = tween.callbacks.onYoyo; + + if (onYoyo) + { + // Element 1 is reserved for the target of the yoyo (and needs setting here) + onYoyo.params[1] = tweenData.target; + + onYoyo.func.apply(onYoyo.scope, onYoyo.params); + } + + tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); + + return TWEEN_CONST.PLAYING_BACKWARD; + } + else if (tweenData.repeatCounter > 0) + { + // We've hit the end of a Playing Forward TweenData and we have a Repeat. + // So we're going to go right back to the start to repeat it again. + + tweenData.repeatCounter--; + + // Account for any extra time we got from the previous frame + tweenData.elapsed = diff; + tweenData.progress = diff / tweenData.duration; + + if (tweenData.flipX) + { + tweenData.target.toggleFlipX(); + } + + if (tweenData.flipY) + { + tweenData.target.toggleFlipY(); + } + + var onRepeat = tween.callbacks.onRepeat; + + if (onRepeat) + { + // Element 1 is reserved for the target of the repeat (and needs setting here) + onRepeat.params[1] = tweenData.target; + + onRepeat.func.apply(onRepeat.scope, onRepeat.params); + } + + tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); + + tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); + + // Delay? + if (tweenData.repeatDelay > 0) + { + tweenData.elapsed = tweenData.repeatDelay - diff; + + tweenData.current = tweenData.start; + + tweenData.target[tweenData.key] = tweenData.current; + + return TWEEN_CONST.REPEAT_DELAY; + } + else + { + return TWEEN_CONST.PLAYING_FORWARD; + } + } + + return TWEEN_CONST.COMPLETE; + }, + + /** + * Was PLAYING_BACKWARD and has hit the start. + * + * @method Phaser.Tweens.Tween#setStateFromStart + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] + * @param {number} diff - [description] + * + * @return {integer} The state of this Tween. + */ + setStateFromStart: function (tween, tweenData, diff) + { + if (tweenData.repeatCounter > 0) + { + tweenData.repeatCounter--; + + // Account for any extra time we got from the previous frame + tweenData.elapsed = diff; + tweenData.progress = diff / tweenData.duration; + + if (tweenData.flipX) + { + tweenData.target.toggleFlipX(); + } + + if (tweenData.flipY) + { + tweenData.target.toggleFlipY(); + } + + var onRepeat = tween.callbacks.onRepeat; + + if (onRepeat) + { + // Element 1 is reserved for the target of the repeat (and needs setting here) + onRepeat.params[1] = tweenData.target; + + onRepeat.func.apply(onRepeat.scope, onRepeat.params); + } + + tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); + + // Delay? + if (tweenData.repeatDelay > 0) + { + tweenData.elapsed = tweenData.repeatDelay - diff; + + tweenData.current = tweenData.start; + + tweenData.target[tweenData.key] = tweenData.current; + + return TWEEN_CONST.REPEAT_DELAY; + } + else + { + return TWEEN_CONST.PLAYING_FORWARD; + } + } + + return TWEEN_CONST.COMPLETE; + }, + + // + /** + * [description] + * + * @method Phaser.Tweens.Tween#updateTweenData + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] + * @param {number} delta - Either a value in ms, or 1 if Tween.useFrames is true + * + * @return {boolean} [description] + */ + updateTweenData: function (tween, tweenData, delta) + { + switch (tweenData.state) + { + case TWEEN_CONST.PLAYING_FORWARD: + case TWEEN_CONST.PLAYING_BACKWARD: + + if (!tweenData.target) + { + tweenData.state = TWEEN_CONST.COMPLETE; + break; + } + + var elapsed = tweenData.elapsed; + var duration = tweenData.duration; + var diff = 0; + + elapsed += delta; + + if (elapsed > duration) + { + diff = elapsed - duration; + elapsed = duration; + } + + var forward = (tweenData.state === TWEEN_CONST.PLAYING_FORWARD); + var progress = elapsed / duration; + + var v; + + if (forward) + { + v = tweenData.ease(progress); + } + else + { + v = tweenData.ease(1 - progress); + } + + tweenData.current = tweenData.start + ((tweenData.end - tweenData.start) * v); + + tweenData.target[tweenData.key] = tweenData.current; + + tweenData.elapsed = elapsed; + tweenData.progress = progress; + + var onUpdate = tween.callbacks.onUpdate; + + if (onUpdate) + { + onUpdate.params[1] = tweenData.target; + + onUpdate.func.apply(onUpdate.scope, onUpdate.params); + } + + if (progress === 1) + { + if (forward) + { + if (tweenData.hold > 0) + { + tweenData.elapsed = tweenData.hold - diff; + + tweenData.state = TWEEN_CONST.HOLD_DELAY; + } + else + { + tweenData.state = this.setStateFromEnd(tween, tweenData, diff); + } + } + else + { + tweenData.state = this.setStateFromStart(tween, tweenData, diff); + } + } + + break; + + case TWEEN_CONST.DELAY: + + tweenData.elapsed -= delta; + + if (tweenData.elapsed <= 0) + { + tweenData.elapsed = Math.abs(tweenData.elapsed); + + tweenData.state = TWEEN_CONST.PENDING_RENDER; + } + + break; + + case TWEEN_CONST.REPEAT_DELAY: + + tweenData.elapsed -= delta; + + if (tweenData.elapsed <= 0) + { + tweenData.elapsed = Math.abs(tweenData.elapsed); + + tweenData.state = TWEEN_CONST.PLAYING_FORWARD; + } + + break; + + case TWEEN_CONST.HOLD_DELAY: + + tweenData.elapsed -= delta; + + if (tweenData.elapsed <= 0) + { + tweenData.state = this.setStateFromEnd(tween, tweenData, Math.abs(tweenData.elapsed)); + } + + break; + + case TWEEN_CONST.PENDING_RENDER: + + if (tweenData.target) + { + tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.target[tweenData.key]); + + tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); + + tweenData.current = tweenData.start; + + tweenData.target[tweenData.key] = tweenData.start; + + tweenData.state = TWEEN_CONST.PLAYING_FORWARD; + } + else + { + tweenData.state = TWEEN_CONST.COMPLETE; + } + + break; + } + + // Return TRUE if this TweenData still playing, otherwise return FALSE + return (tweenData.state !== TWEEN_CONST.COMPLETE); + } + +}); + +Tween.TYPES = [ + 'onComplete', + 'onLoop', + 'onRepeat', + 'onStart', + 'onUpdate', + 'onYoyo' +]; + +/** + * Creates a new Tween object. + * + * Note: This method will only be available Tweens have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#tween + * @since 3.0.0 + * + * @param {object} config - The Tween configuration. + * + * @return {Phaser.Tweens.Tween} The Tween that was created. + */ +GameObjectFactory.register('tween', function (config) { - if (out === undefined) { out = new Point(); } + return this.scene.sys.tweens.add(config); +}); - var t = Math.random(); +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns - out.x = line.x1 + t * (line.x2 - line.x1); - out.y = line.y1 + t * (line.y2 - line.y1); +/** + * Creates a new Tween object and returns it. + * + * Note: This method will only be available if Tweens have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#tween + * @since 3.0.0 + * + * @param {object} config - The Tween configuration. + * + * @return {Phaser.Tweens.Tween} The Tween that was created. + */ +GameObjectCreator.register('tween', function (config) +{ + return this.scene.sys.tweens.create(config); +}); - return out; -}; +// When registering a factory function 'this' refers to the GameObjectCreator context. -module.exports = Random; +module.exports = Tween; /***/ }), /* 112 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -20377,48 +22547,37 @@ module.exports = Random; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); - /** - * [description] - * - * @function Phaser.Geom.Triangle.Random - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] + * @typedef {object} Phaser.Tweens.TweenConfigDefaults + * + * @property {(object|object[])} targets - [description] + * @property {number} [delay=0] - [description] + * @property {number} [duration=1000] - [description] + * @property {string} [ease='Power0'] - [description] + * @property {array} [easeParams] - [description] + * @property {number} [hold=0] - [description] + * @property {number} [repeat=0] - [description] + * @property {number} [repeatDelay=0] - [description] + * @property {boolean} [yoyo=false] - [description] + * @property {boolean} [flipX=false] - [description] + * @property {boolean} [flipY=false] - [description] */ -var Random = function (triangle, out) -{ - if (out === undefined) { out = new Point(); } - // Basis vectors - var ux = triangle.x2 - triangle.x1; - var uy = triangle.y2 - triangle.y1; - - var vx = triangle.x3 - triangle.x1; - var vy = triangle.y3 - triangle.y1; - - // Random point within the unit square - var r = Math.random(); - var s = Math.random(); - - // Point outside the triangle? Remap it. - if (r + s >= 1) - { - r = 1 - r; - s = 1 - s; - } - - out.x = triangle.x1 + ((ux * r) + (vx * s)); - out.y = triangle.y1 + ((uy * r) + (vy * s)); - - return out; +var TWEEN_DEFAULTS = { + targets: null, + delay: 0, + duration: 1000, + ease: 'Power0', + easeParams: null, + hold: 0, + repeat: 0, + repeatDelay: 0, + yoyo: false, + flipX: false, + flipY: false }; -module.exports = Random; +module.exports = TWEEN_DEFAULTS; /***/ }), @@ -20431,31 +22590,167 @@ module.exports = Random; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +function hasGetStart (def) +{ + return (!!def.getStart && typeof def.getStart === 'function'); +} + +function hasGetEnd (def) +{ + return (!!def.getEnd && typeof def.getEnd === 'function'); +} + +function hasGetters (def) +{ + return hasGetStart(def) || hasGetEnd(def); +} + /** * [description] * - * @function Phaser.Math.RotateAroundDistance + * @function Phaser.Tweens.Builders.GetValueOp * @since 3.0.0 * - * @param {Phaser.Geom.Point|object} point - The Point to be rotated. - * @param {number} x - The horizontal coordinate to rotate around. - * @param {number} y - The vertical coordinate to rotate around. - * @param {number} angle - The angle of rotation in radians. - * @param {number} distance - [description] + * @param {string} key - [description] + * @param {*} propertyValue - [description] * - * @return {Phaser.Geom.Point} [description] + * @return {function} [description] */ -var RotateAroundDistance = function (point, x, y, angle, distance) +var GetValueOp = function (key, propertyValue) { - var t = angle + Math.atan2(point.y - y, point.x - x); + var callbacks; - point.x = x + (distance * Math.cos(t)); - point.y = y + (distance * Math.sin(t)); + // The returned value sets what the property will be at the END of the Tween (usually called at the start of the Tween) + var getEnd = function (target, key, value) { return value; }; - return point; + // The returned value sets what the property will be at the START of the Tween (usually called at the end of the Tween) + var getStart = function (target, key, value) { return value; }; + + var t = typeof(propertyValue); + + if (t === 'number') + { + // props: { + // x: 400, + // y: 300 + // } + + getEnd = function () + { + return propertyValue; + }; + } + else if (t === 'string') + { + // props: { + // x: '+=400', + // y: '-=300', + // z: '*=2', + // w: '/=2' + // } + + var op = propertyValue[0]; + var num = parseFloat(propertyValue.substr(2)); + + switch (op) + { + case '+': + getEnd = function (target, key, value) + { + return value + num; + }; + break; + + case '-': + getEnd = function (target, key, value) + { + return value - num; + }; + break; + + case '*': + getEnd = function (target, key, value) + { + return value * num; + }; + break; + + case '/': + getEnd = function (target, key, value) + { + return value / num; + }; + break; + + default: + getEnd = function () + { + return parseFloat(propertyValue); + }; + } + } + else if (t === 'function') + { + // The same as setting just the getEnd function and no getStart + + // props: { + // x: function (target, key, value) { return value + 50); }, + // } + + getEnd = propertyValue; + } + else if (t === 'object' && hasGetters(propertyValue)) + { + /* + x: { + // Called at the start of the Tween. The returned value sets what the property will be at the END of the Tween. + getEnd: function (target, key, value) + { + return value; + }, + + // Called at the end of the Tween. The returned value sets what the property will be at the START of the Tween. + getStart: function (target, key, value) + { + return value; + } + } + */ + + if (hasGetEnd(propertyValue)) + { + getEnd = propertyValue.getEnd; + } + + if (hasGetStart(propertyValue)) + { + getStart = propertyValue.getStart; + } + } + else if (propertyValue.hasOwnProperty('value')) + { + // Value may still be a string, function or a number + // props: { + // x: { value: 400, ... }, + // y: { value: 300, ... } + // } + + callbacks = GetValueOp(key, propertyValue.value); + } + + // If callback not set by the else if block above then set it here and return it + if (!callbacks) + { + callbacks = { + getEnd: getEnd, + getStart: getStart + }; + } + + return callbacks; }; -module.exports = RotateAroundDistance; +module.exports = GetValueOp; /***/ }), @@ -20468,321 +22763,41 @@ module.exports = RotateAroundDistance; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); +var GetValue = __webpack_require__(5); /** - * @classdesc - * The keys of a Map can be arbitrary values. - * var map = new Map([ - * [ 1, 'one' ], - * [ 2, 'two' ], - * [ 3, 'three' ] - * ]); + * [description] * - * @class Map - * @memberOf Phaser.Structs - * @constructor + * @function Phaser.Tweens.Builders.GetTargets * @since 3.0.0 * - * @param {array} elements - [description] + * @param {object} config - [description] + * + * @return {array} [description] */ -var Map = new Class({ +var GetTargets = function (config) +{ + var targets = GetValue(config, 'targets', null); - initialize: - - function Map (elements) + if (targets === null) { - /** - * [description] - * - * @name Phaser.Structs.Map#entries - * @type {object} - * @default {} - * @since 3.0.0 - */ - this.entries = {}; - - /** - * [description] - * - * @name Phaser.Structs.Map#size - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.size = 0; - - if (Array.isArray(elements)) - { - for (var i = 0; i < elements.length; i++) - { - this.set(elements[i][0], elements[i][1]); - } - } - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#set - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {any} value - [description] - * - * @return {Phaser.Structs.Map} This Map object. - */ - set: function (key, value) - { - if (!this.has(key)) - { - this.entries[key] = value; - this.size++; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#get - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {any} [description] - */ - get: function (key) - { - if (this.has(key)) - { - return this.entries[key]; - } - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#getArray - * @since 3.0.0 - * - * @return {array} [description] - */ - getArray: function () - { - var output = []; - var entries = this.entries; - - for (var key in entries) - { - output.push(entries[key]); - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#has - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {boolean} [description] - */ - has: function (key) - { - return (this.entries.hasOwnProperty(key)); - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#delete - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Structs.Map} This Map object. - */ - delete: function (key) - { - if (this.has(key)) - { - delete this.entries[key]; - this.size--; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#clear - * @since 3.0.0 - * - * @return {Phaser.Structs.Map} This Map object. - */ - clear: function () - { - Object.keys(this.entries).forEach(function (prop) - { - delete this.entries[prop]; - - }, this); - - this.size = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#keys - * @since 3.0.0 - * - * @return {[type]} [description] - */ - keys: function () - { - return Object.keys(this.entries); - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#values - * @since 3.0.0 - * - * @return {array} [description] - */ - values: function () - { - var output = []; - var entries = this.entries; - - for (var key in entries) - { - output.push(entries[key]); - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#dump - * @since 3.0.0 - */ - dump: function () - { - var entries = this.entries; - - // eslint-disable-next-line no-console - console.group('Map'); - - for (var key in entries) - { - console.log(key, entries[key]); - } - - // eslint-disable-next-line no-console - console.groupEnd(); - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#each - * @since 3.0.0 - * - * @param {function} callback - [description] - * - * @return {Phaser.Structs.Map} This Map object. - */ - each: function (callback) - { - var entries = this.entries; - - for (var key in entries) - { - if (callback(key, entries[key]) === false) - { - break; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#contains - * @since 3.0.0 - * - * @param {any} value - [description] - * - * @return {boolean} [description] - */ - contains: function (value) - { - var entries = this.entries; - - for (var key in entries) - { - if (entries[key] === value) - { - return true; - } - } - - return false; - }, - - /** - * Merges all new keys from the given Map into this one - * If it encounters a key that already exists it will be skipped - * unless override = true. - * - * @method Phaser.Structs.Map#merge - * @since 3.0.0 - * - * @param {Phaser.Structs.Map} map - [description] - * @param {boolean} [override=false] - [description] - * - * @return {Phaser.Structs.Map} This Map object. - */ - merge: function (map, override) - { - if (override === undefined) { override = false; } - - var local = this.entries; - var source = map.entries; - - for (var key in source) - { - if (local.hasOwnProperty(key) && override) - { - local[key] = source[key]; - } - else - { - this.set(key, source[key]); - } - } - - return this; + return targets; } -}); + if (typeof targets === 'function') + { + targets = targets.call(); + } -module.exports = Map; + if (!Array.isArray(targets)) + { + targets = [ targets ]; + } + + return targets; +}; + +module.exports = GetTargets; /***/ }), @@ -20795,1352 +22810,80 @@ module.exports = Map; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var DegToRad = __webpack_require__(35); -var Rectangle = __webpack_require__(8); -var TransformMatrix = __webpack_require__(190); -var ValueToColor = __webpack_require__(116); -var Vector2 = __webpack_require__(6); +var Formats = __webpack_require__(24); +var MapData = __webpack_require__(65); +var Parse = __webpack_require__(194); +var Tilemap = __webpack_require__(186); /** - * @classdesc - * [description] + * Create a Tilemap from the given key or data. If neither is given, make a blank Tilemap. When + * loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing from + * a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map data. For + * an empty map, you should specify tileWidth, tileHeight, width & height. * - * @class Camera - * @memberOf Phaser.Cameras.Scene2D - * @constructor + * @function Phaser.Tilemaps.ParseToTilemap * @since 3.0.0 - * - * @param {number} x - The x position of the Camera, relative to the top-left of the game canvas. - * @param {number} y - The y position of the Camera, relative to the top-left of the game canvas. - * @param {number} width - The width of the Camera, in pixels. - * @param {number} height - The height of the Camera, in pixels. + * + * @param {Phaser.Scene} scene - The Scene to which this Tilemap belongs. + * @param {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data. + * @param {integer} [tileWidth=32] - The width of a tile in pixels. + * @param {integer} [tileHeight=32] - The height of a tile in pixels. + * @param {integer} [width=10] - The width of the map in tiles. + * @param {integer} [height=10] - The height of the map in tiles. + * @param {integer[][]} [data] - Instead of loading from the cache, you can also load directly from + * a 2D array of tile indexes. + * @param {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, in the + * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + * + * @return {Phaser.Tilemaps.Tilemap} */ -var Camera = new Class({ +var ParseToTilemap = function (scene, key, tileWidth, tileHeight, width, height, data, insertNull) +{ + if (tileWidth === undefined) { tileWidth = 32; } + if (tileHeight === undefined) { tileHeight = 32; } + if (width === undefined) { width = 10; } + if (height === undefined) { height = 10; } + if (insertNull === undefined) { insertNull = false; } - initialize: + var mapData = null; - function Camera (x, y, width, height) + if (Array.isArray(data)) { - /** - * A reference to the Scene this camera belongs to. - * - * @name Phaser.Cameras.Scene2D.Camera#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene; - - /** - * The name of the Camera. This is left empty for your own use. - * - * @name Phaser.Cameras.Scene2D.Camera#name - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.name = ''; - - /** - * The x position of the Camera, relative to the top-left of the game canvas. - * - * @name Phaser.Cameras.Scene2D.Camera#x - * @type {number} - * @since 3.0.0 - */ - this.x = x; - - /** - * The y position of the Camera, relative to the top-left of the game canvas. - * - * @name Phaser.Cameras.Scene2D.Camera#y - * @type {number} - * @since 3.0.0 - */ - this.y = y; - - /** - * The width of the Camera, in pixels. - * - * @name Phaser.Cameras.Scene2D.Camera#width - * @type {number} - * @since 3.0.0 - */ - this.width = width; - - /** - * The height of the Camera, in pixels. - * - * @name Phaser.Cameras.Scene2D.Camera#height - * @type {number} - * @since 3.0.0 - */ - this.height = height; - - /** - * Should this camera round its pixel values to integers? - * - * @name Phaser.Cameras.Scene2D.Camera#roundPixels - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.roundPixels = false; - - /** - * Is this Camera using a bounds to restrict scrolling movement? - * Set this property along with the bounds via `Camera.setBounds`. - * - * @name Phaser.Cameras.Scene2D.Camera#useBounds - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.useBounds = false; - - /** - * The bounds the camera is restrained to during scrolling. - * - * @name Phaser.Cameras.Scene2D.Camera#_bounds - * @type {Phaser.Geom.Rectangle} - * @private - * @since 3.0.0 - */ - this._bounds = new Rectangle(); - - /** - * Does this Camera allow the Game Objects it renders to receive input events? - * - * @name Phaser.Cameras.Scene2D.Camera#inputEnabled - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.inputEnabled = true; - - /** - * The horizontal scroll position of this camera. - * Optionally restricted via the Camera bounds. - * - * @name Phaser.Cameras.Scene2D.Camera#scrollX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.scrollX = 0; - - /** - * The vertical scroll position of this camera. - * Optionally restricted via the Camera bounds. - * - * @name Phaser.Cameras.Scene2D.Camera#scrollY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.scrollY = 0; - - /** - * The Camera zoom value. Change this value to zoom in, or out of, a Scene. - * Set to 1 to return to the default zoom level. - * - * @name Phaser.Cameras.Scene2D.Camera#zoom - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.zoom = 1; - - /** - * The rotation of the Camera. This influences the rendering of all Game Objects visible by this camera. - * - * @name Phaser.Cameras.Scene2D.Camera#rotation - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.rotation = 0; - - /** - * A local transform matrix used for internal calculations. - * - * @name Phaser.Cameras.Scene2D.Camera#matrix - * @type {TransformMatrix} - * @since 3.0.0 - */ - this.matrix = new TransformMatrix(1, 0, 0, 1, 0, 0); - - /** - * Does this Camera have a transparent background? - * - * @name Phaser.Cameras.Scene2D.Camera#transparent - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.transparent = true; - - /** - * TODO - * - * @name Phaser.Cameras.Scene2D.Camera#clearBeforeRender - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.clearBeforeRender = true; - - /** - * The background color of this Camera. Only used if `transparent` is `false`. - * - * @name Phaser.Cameras.Scene2D.Camera#backgroundColor - * @type {Phaser.Display.Color} - * @since 3.0.0 - */ - this.backgroundColor = ValueToColor('rgba(0,0,0,0)'); - - /** - * Should the camera cull Game Objects before rendering? - * In some special cases it may be beneficial to disable this. - * - * @name Phaser.Cameras.Scene2D.Camera#disableCull - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.disableCull = false; - - /** - * A temporary array of culled objects. - * - * @name Phaser.Cameras.Scene2D.Camera#culledObjects - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.culledObjects = []; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_shakeDuration - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._shakeDuration = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_shakeIntensity - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._shakeIntensity = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_shakeOffsetX - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._shakeOffsetX = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_shakeOffsetY - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._shakeOffsetY = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_fadeDuration - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._fadeDuration = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_fadeRed - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._fadeRed = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_fadeGreen - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._fadeGreen = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_fadeBlue - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._fadeBlue = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_fadeAlpha - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._fadeAlpha = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_flashDuration - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._flashDuration = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_flashRed - * @type {number} - * @private - * @default 1 - * @since 3.0.0 - */ - this._flashRed = 1; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_flashGreen - * @type {number} - * @private - * @default 1 - * @since 3.0.0 - */ - this._flashGreen = 1; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_flashBlue - * @type {number} - * @private - * @default 1 - * @since 3.0.0 - */ - this._flashBlue = 1; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_flashAlpha - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._flashAlpha = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_follow - * @type {?any} - * @private - * @default null - * @since 3.0.0 - */ - this._follow = null; - - /** - * [description] - * - * @name Phaser.Cameras.Scene2D.Camera#_id - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - this._id = 0; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#centerToBounds - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - centerToBounds: function () + var name = key !== undefined ? key : 'map'; + mapData = Parse(name, Formats.ARRAY_2D, data, tileWidth, tileHeight, insertNull); + } + else if (key !== undefined) { - this.scrollX = (this._bounds.width * 0.5) - (this.width * 0.5); - this.scrollY = (this._bounds.height * 0.5) - (this.height * 0.5); + var tilemapData = scene.cache.tilemap.get(key); - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#centerToSize - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - centerToSize: function () - { - this.scrollX = this.width * 0.5; - this.scrollY = this.height * 0.5; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#cull - * @since 3.0.0 - * - * @param {array} renderableObjects - [description] - * - * @return {array} [description] - */ - cull: function (renderableObjects) - { - if (this.disableCull) + if (!tilemapData) { - return renderableObjects; - } - - var cameraMatrix = this.matrix.matrix; - - var mva = cameraMatrix[0]; - var mvb = cameraMatrix[1]; - var mvc = cameraMatrix[2]; - var mvd = cameraMatrix[3]; - - /* First Invert Matrix */ - var determinant = (mva * mvd) - (mvb * mvc); - - if (!determinant) - { - return renderableObjects; - } - - var mve = cameraMatrix[4]; - var mvf = cameraMatrix[5]; - - var scrollX = this.scrollX; - var scrollY = this.scrollY; - var cameraW = this.width; - var cameraH = this.height; - var culledObjects = this.culledObjects; - var length = renderableObjects.length; - - determinant = 1 / determinant; - - culledObjects.length = 0; - - for (var index = 0; index < length; ++index) - { - var object = renderableObjects[index]; - - if (!object.hasOwnProperty('width')) - { - culledObjects.push(object); - continue; - } - - var objectW = object.width; - var objectH = object.height; - var objectX = (object.x - (scrollX * object.scrollFactorX)) - (objectW * object.originX); - var objectY = (object.y - (scrollY * object.scrollFactorY)) - (objectH * object.originY); - var tx = (objectX * mva + objectY * mvc + mve); - var ty = (objectX * mvb + objectY * mvd + mvf); - var tw = ((objectX + objectW) * mva + (objectY + objectH) * mvc + mve); - var th = ((objectX + objectW) * mvb + (objectY + objectH) * mvd + mvf); - var cullW = cameraW + objectW; - var cullH = cameraH + objectH; - - if (tx > -objectW || ty > -objectH || tx < cullW || ty < cullH || - tw > -objectW || th > -objectH || tw < cullW || th < cullH) - { - culledObjects.push(object); - } - } - - return culledObjects; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#cullHitTest - * @since 3.0.0 - * - * @param {array} interactiveObjects - [description] - * - * @return {array} [description] - */ - cullHitTest: function (interactiveObjects) - { - if (this.disableCull) - { - return interactiveObjects; - } - - var cameraMatrix = this.matrix.matrix; - - var mva = cameraMatrix[0]; - var mvb = cameraMatrix[1]; - var mvc = cameraMatrix[2]; - var mvd = cameraMatrix[3]; - - /* First Invert Matrix */ - var determinant = (mva * mvd) - (mvb * mvc); - - if (!determinant) - { - return interactiveObjects; - } - - var mve = cameraMatrix[4]; - var mvf = cameraMatrix[5]; - - var scrollX = this.scrollX; - var scrollY = this.scrollY; - var cameraW = this.width; - var cameraH = this.height; - var length = interactiveObjects.length; - - determinant = 1 / determinant; - - var culledObjects = []; - - for (var index = 0; index < length; ++index) - { - var object = interactiveObjects[index].gameObject; - - if (!object.hasOwnProperty('width')) - { - culledObjects.push(interactiveObjects[index]); - continue; - } - - var objectW = object.width; - var objectH = object.height; - var objectX = (object.x - (scrollX * object.scrollFactorX)) - (objectW * object.originX); - var objectY = (object.y - (scrollY * object.scrollFactorY)) - (objectH * object.originY); - var tx = (objectX * mva + objectY * mvc + mve); - var ty = (objectX * mvb + objectY * mvd + mvf); - var tw = ((objectX + objectW) * mva + (objectY + objectH) * mvc + mve); - var th = ((objectX + objectW) * mvb + (objectY + objectH) * mvd + mvf); - var cullW = cameraW + objectW; - var cullH = cameraH + objectH; - - if (tx > -objectW || ty > -objectH || tx < cullW || ty < cullH || - tw > -objectW || th > -objectH || tw < cullW || th < cullH) - { - culledObjects.push(interactiveObjects[index]); - } - } - - return culledObjects; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#cullTilemap - * @since 3.0.0 - * - * @param {array} tilemap - [description] - * - * @return {array} [description] - */ - cullTilemap: function (tilemap) - { - var cameraMatrix = this.matrix.matrix; - - var mva = cameraMatrix[0]; - var mvb = cameraMatrix[1]; - var mvc = cameraMatrix[2]; - var mvd = cameraMatrix[3]; - - /* First Invert Matrix */ - var determinant = (mva * mvd) - (mvb * mvc); - - if (!determinant) - { - return tiles; - } - - var mve = cameraMatrix[4]; - var mvf = cameraMatrix[5]; - var tiles = tilemap.tiles; - var scrollX = this.scrollX; - var scrollY = this.scrollY; - var cameraW = this.width; - var cameraH = this.height; - var culledObjects = this.culledObjects; - var length = tiles.length; - var tileW = tilemap.tileWidth; - var tileH = tilemap.tileHeight; - var cullW = cameraW + tileW; - var cullH = cameraH + tileH; - var scrollFactorX = tilemap.scrollFactorX; - var scrollFactorY = tilemap.scrollFactorY; - - determinant = 1 / determinant; - - culledObjects.length = 0; - - for (var index = 0; index < length; ++index) - { - var tile = tiles[index]; - var tileX = (tile.x - (scrollX * scrollFactorX)); - var tileY = (tile.y - (scrollY * scrollFactorY)); - var tx = (tileX * mva + tileY * mvc + mve); - var ty = (tileX * mvb + tileY * mvd + mvf); - var tw = ((tileX + tileW) * mva + (tileY + tileH) * mvc + mve); - var th = ((tileX + tileW) * mvb + (tileY + tileH) * mvd + mvf); - - if (tx > -tileW && ty > -tileH && tw < cullW && th < cullH) - { - culledObjects.push(tile); - } - } - - return culledObjects; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#fade - * @since 3.0.0 - * - * @param {number} duration - [description] - * @param {number} red - [description] - * @param {number} green - [description] - * @param {number} blue - [description] - * @param {number} force - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - fade: function (duration, red, green, blue, force) - { - if (red === undefined) { red = 0; } - if (green === undefined) { green = 0; } - if (blue === undefined) { blue = 0; } - - if (!force && this._fadeAlpha > 0) - { - return this; - } - - this._fadeRed = red; - this._fadeGreen = green; - this._fadeBlue = blue; - - if (duration <= 0) - { - duration = Number.MIN_VALUE; - } - - this._fadeDuration = duration; - this._fadeAlpha = Number.MIN_VALUE; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#flash - * @since 3.0.0 - * - * @param {number} duration - [description] - * @param {number} red - [description] - * @param {number} green - [description] - * @param {number} blue - [description] - * @param {number} force - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - flash: function (duration, red, green, blue, force) - { - if (!force && this._flashAlpha > 0.0) - { - return this; - } - - if (red === undefined) { red = 1.0; } - if (green === undefined) { green = 1.0; } - if (blue === undefined) { blue = 1.0; } - - this._flashRed = red; - this._flashGreen = green; - this._flashBlue = blue; - - if (duration <= 0) - { - duration = Number.MIN_VALUE; - } - - this._flashDuration = duration; - this._flashAlpha = 1.0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#getWorldPoint - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {object|Phaser.Math.Vector2} output - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - getWorldPoint: function (x, y, output) - { - if (output === undefined) { output = new Vector2(); } - - var cameraMatrix = this.matrix.matrix; - - var mva = cameraMatrix[0]; - var mvb = cameraMatrix[1]; - var mvc = cameraMatrix[2]; - var mvd = cameraMatrix[3]; - var mve = cameraMatrix[4]; - var mvf = cameraMatrix[5]; - - /* First Invert Matrix */ - var determinant = (mva * mvd) - (mvb * mvc); - - if (!determinant) - { - output.x = x; - output.y = y; - - return output; - } - - determinant = 1 / determinant; - - var ima = mvd * determinant; - var imb = -mvb * determinant; - var imc = -mvc * determinant; - var imd = mva * determinant; - var ime = (mvc * mvf - mvd * mve) * determinant; - var imf = (mvb * mve - mva * mvf) * determinant; - - var c = Math.cos(this.rotation); - var s = Math.sin(this.rotation); - - var zoom = this.zoom; - - var scrollX = this.scrollX; - var scrollY = this.scrollY; - - var sx = x + ((scrollX * c - scrollY * s) * zoom); - var sy = y + ((scrollX * s + scrollY * c) * zoom); - - /* Apply transform to point */ - output.x = (sx * ima + sy * imc + ime); - output.y = (sx * imb + sy * imd + imf); - - return output; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#ignore - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} gameObjectOrArray - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - ignore: function (gameObjectOrArray) - { - if (gameObjectOrArray instanceof Array) - { - for (var index = 0; index < gameObjectOrArray.length; ++index) - { - gameObjectOrArray[index].cameraFilter |= this._id; - } + console.warn('No map data found for key ' + key); } else { - gameObjectOrArray.cameraFilter |= this._id; + mapData = Parse(key, tilemapData.format, tilemapData.data, tileWidth, tileHeight, insertNull); } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#preRender - * @since 3.0.0 - * - * @param {number} baseScale - [description] - * @param {number} resolution - [description] - * - */ - preRender: function (baseScale, resolution) - { - var width = this.width; - var height = this.height; - var zoom = this.zoom * baseScale; - var matrix = this.matrix; - var originX = width / 2; - var originY = height / 2; - var follow = this._follow; - - if (follow !== null) - { - originX = follow.x; - originY = follow.y; - - this.scrollX = (originX - width * 0.5) / zoom; - this.scrollY = (originY - height * 0.5) / zoom; - } - - if (this.useBounds) - { - var bounds = this._bounds; - - var bw = Math.max(0, bounds.right - width); - var bh = Math.max(0, bounds.bottom - height); - - if (this.scrollX < bounds.x) - { - this.scrollX = bounds.x; - } - else if (this.scrollX > bw) - { - this.scrollX = bw; - } - - if (this.scrollY < bounds.y) - { - this.scrollY = bounds.y; - } - else if (this.scrollY > bh) - { - this.scrollY = bh; - } - } - - if (this.roundPixels) - { - this.scrollX = Math.round(this.scrollX); - this.scrollY = Math.round(this.scrollY); - } - - matrix.loadIdentity(); - matrix.scale(resolution, resolution); - matrix.translate(this.x + originX, this.y + originY); - matrix.rotate(this.rotation); - matrix.scale(zoom, zoom); - matrix.translate(-originX, -originY); - matrix.translate(this._shakeOffsetX, this._shakeOffsetY); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#removeBounds - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - removeBounds: function () - { - this.useBounds = false; - - this._bounds.setEmpty(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setAngle - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setAngle: function (value) - { - if (value === undefined) { value = 0; } - - this.rotation = DegToRad(value); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setBackgroundColor - * @since 3.0.0 - * - * @param {integer} color - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setBackgroundColor: function (color) - { - if (color === undefined) { color = 'rgba(0,0,0,0)'; } - - this.backgroundColor = ValueToColor(color); - - this.transparent = (this.backgroundColor.alpha === 0); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setBounds - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setBounds: function (x, y, width, height) - { - this._bounds.setTo(x, y, width, height); - - this.useBounds = true; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setName - * @since 3.0.0 - * - * @param {string} value - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setName: function (value) - { - if (value === undefined) { value = ''; } - - this.name = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setPosition - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setPosition: function (x, y) - { - if (y === undefined) { y = x; } - - this.x = x; - this.y = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setRotation - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setRotation: function (value) - { - if (value === undefined) { value = 0; } - - this.rotation = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setRoundPixels - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setRoundPixels: function (value) - { - this.roundPixels = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setScene - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setScene: function (scene) - { - this.scene = scene; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setScroll - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setScroll: function (x, y) - { - if (y === undefined) { y = x; } - - this.scrollX = x; - this.scrollY = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setSize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setSize: function (width, height) - { - if (height === undefined) { height = width; } - - this.width = width; - this.height = height; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setViewport - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setViewport: function (x, y, width, height) - { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#setZoom - * @since 3.0.0 - * - * @param {float} value - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setZoom: function (value) - { - if (value === undefined) { value = 1; } - - this.zoom = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#shake - * @since 3.0.0 - * - * @param {number} duration - [description] - * @param {number} intensity - [description] - * @param {number} force - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - shake: function (duration, intensity, force) - { - if (intensity === undefined) { intensity = 0.05; } - - if (!force && (this._shakeOffsetX !== 0 || this._shakeOffsetY !== 0)) - { - return this; - } - - this._shakeDuration = duration; - this._shakeIntensity = intensity; - this._shakeOffsetX = 0; - this._shakeOffsetY = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#startFollow - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject|object} gameObjectOrPoint - [description] - * @param {boolean} roundPx - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - startFollow: function (gameObjectOrPoint, roundPx) - { - this._follow = gameObjectOrPoint; - - if (roundPx !== undefined) - { - this.roundPixels = roundPx; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#stopFollow - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - stopFollow: function () - { - this._follow = null; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - var output = { - name: this.name, - x: this.x, - y: this.y, - width: this.width, - height: this.height, - zoom: this.zoom, - rotation: this.rotation, - roundPixels: this.roundPixels, - scrollX: this.scrollX, - scrollY: this.scrollY, - backgroundColor: this.backgroundColor.rgba - }; - - if (this.useBounds) - { - output['bounds'] = { - x: this._bounds.x, - y: this._bounds.y, - width: this._bounds.width, - height: this._bounds.height - }; - } - - return output; - }, - - /** - * Resets any active FX, such as a fade, flash or shake. Useful to call after a fade in order to - * remove the fade. - * - * @method Phaser.Cameras.Scene2D.Camera#resetFX - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - resetFX: function () - { - this._flashAlpha = 0; - this._fadeAlpha = 0; - this._shakeOffsetX = 0.0; - this._shakeOffsetY = 0.0; - this._shakeDuration = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#update - * @since 3.0.0 - * - * @param {[type]} timestep - [description] - * @param {[type]} delta - [description] - */ - update: function (timestep, delta) - { - if (this._flashAlpha > 0.0) - { - this._flashAlpha -= delta / this._flashDuration; - - if (this._flashAlpha < 0.0) - { - this._flashAlpha = 0.0; - } - } - - if (this._fadeAlpha > 0.0 && this._fadeAlpha < 1.0) - { - this._fadeAlpha += delta / this._fadeDuration; - - if (this._fadeAlpha >= 1.0) - { - this._fadeAlpha = 1.0; - } - } - - if (this._shakeDuration > 0.0) - { - var intensity = this._shakeIntensity; - - this._shakeDuration -= delta; - - if (this._shakeDuration <= 0.0) - { - this._shakeOffsetX = 0.0; - this._shakeOffsetY = 0.0; - } - else - { - this._shakeOffsetX = (Math.random() * intensity * this.width * 2 - intensity * this.width) * this.zoom; - this._shakeOffsetY = (Math.random() * intensity * this.height * 2 - intensity * this.height) * this.zoom; - - if (this.roundPixels) - { - this._shakeOffsetX |= 0; - this._shakeOffsetY |= 0; - } - } - } - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.Camera#destroy - * @since 3.0.0 - */ - destroy: function () - { - this._bounds = undefined; - this.matrix = undefined; - this.culledObjects = []; - this.scene = undefined; } -}); + if (mapData === null) + { + mapData = new MapData({ + tileWidth: tileWidth, + tileHeight: tileHeight, + width: width, + height: height + }); + } -module.exports = Camera; + return new Tilemap(scene, mapData); +}; + +module.exports = ParseToTilemap; /***/ }), @@ -22153,50 +22896,86 @@ module.exports = Camera; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var HexStringToColor = __webpack_require__(203); -var IntegerToColor = __webpack_require__(205); -var ObjectToColor = __webpack_require__(207); -var RGBStringToColor = __webpack_require__(208); +var Formats = __webpack_require__(24); +var LayerData = __webpack_require__(66); +var MapData = __webpack_require__(65); +var Tile = __webpack_require__(45); /** - * Converts the given source color value into an instance of a Color class. - * The value can be either a string, prefixed with `rgb` or a hex string, a number or an Object. + * Parses a 2D array of tile indexes into a new MapData object with a single layer. * - * @function Phaser.Display.Color.ValueToColor + * @function Phaser.Tilemaps.Parsers.Parse2DArray * @since 3.0.0 * - * @param {string|number|object} input - The source color value to convert. + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {integer[][]} data - 2D array, CSV string or Tiled JSON object. + * @param {integer} tileWidth - The width of a tile in pixels. + * @param {integer} tileHeight - The height of a tile in pixels. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. * - * @return {Phaser.Display.Color} A Color object. + * @return {Phaser.Tilemaps.MapData} [description] */ -var ValueToColor = function (input) +var Parse2DArray = function (name, data, tileWidth, tileHeight, insertNull) { - var t = typeof input; + var layerData = new LayerData({ + tileWidth: tileWidth, + tileHeight: tileHeight + }); - switch (t) + var mapData = new MapData({ + name: name, + tileWidth: tileWidth, + tileHeight: tileHeight, + format: Formats.ARRAY_2D, + layers: [ layerData ] + }); + + var tiles = []; + var height = data.length; + var width = 0; + + for (var y = 0; y < data.length; y++) { - case 'string': + tiles[y] = []; + var row = data[y]; - if (input.substr(0, 3).toLowerCase() === 'rgb') + for (var x = 0; x < row.length; x++) + { + var tileIndex = parseInt(row[x], 10); + + if (Number.isNaN(tileIndex) || tileIndex === -1) { - return RGBStringToColor(input); + tiles[y][x] = insertNull + ? null + : new Tile(layerData, -1, x, y, tileWidth, tileHeight); } else { - return HexStringToColor(input); + tiles[y][x] = new Tile(layerData, tileIndex, x, y, tileWidth, tileHeight); } + } - case 'number': - - return IntegerToColor(input); - - case 'object': - - return ObjectToColor(input); + if (width === 0) + { + width = row.length; + } } + + mapData.width = layerData.width = width; + mapData.height = layerData.height = height; + mapData.widthInPixels = layerData.widthInPixels = width * tileWidth; + mapData.heightInPixels = layerData.heightInPixels = height * tileHeight; + layerData.data = tiles; + + return mapData; }; -module.exports = ValueToColor; +module.exports = Parse2DArray; /***/ }), @@ -22210,23 +22989,31 @@ module.exports = ValueToColor; */ /** - * Given 3 separate color values this will return an integer representation of it. + * Internally used method to keep track of the tile indexes that collide within a layer. This + * updates LayerData.collideIndexes to either contain or not contain the given `tileIndex`. * - * @function Phaser.Display.Color.GetColor + * @function Phaser.Tilemaps.Components.SetLayerCollisionIndex * @since 3.0.0 * - * @param {integer} red - The red color value. A number between 0 and 255. - * @param {integer} green - The green color value. A number between 0 and 255. - * @param {integer} blue - The blue color value. A number between 0 and 255. - * - * @return {number} The combined color value. + * @param {integer} tileIndex - [description] + * @param {boolean} [collides=true] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. */ -var GetColor = function (red, green, blue) +var SetLayerCollisionIndex = function (tileIndex, collides, layer) { - return red << 16 | green << 8 | blue; + var loc = layer.collideIndexes.indexOf(tileIndex); + + if (collides && loc === -1) + { + layer.collideIndexes.push(tileIndex); + } + else if (!collides && loc !== -1) + { + layer.collideIndexes.splice(loc, 1); + } }; -module.exports = GetColor; +module.exports = SetLayerCollisionIndex; /***/ }), @@ -22239,1062 +23026,73 @@ module.exports = GetColor; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Matrix4 = __webpack_require__(119); -var RandomXYZ = __webpack_require__(209); -var RandomXYZW = __webpack_require__(210); -var RotateVec3 = __webpack_require__(211); -var Set = __webpack_require__(62); -var Sprite3D = __webpack_require__(81); -var Vector2 = __webpack_require__(6); -var Vector3 = __webpack_require__(51); -var Vector4 = __webpack_require__(120); - -// Local cache vars -var tmpVec3 = new Vector3(); -var tmpVec4 = new Vector4(); -var dirvec = new Vector3(); -var rightvec = new Vector3(); -var billboardMatrix = new Matrix4(); - -// @author attribute https://github.com/mattdesl/cam3d/wiki +var Tile = __webpack_require__(45); +var IsInLayerBounds = __webpack_require__(67); +var CalculateFacesAt = __webpack_require__(119); +var SetTileCollision = __webpack_require__(46); /** - * @classdesc - * [description] + * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index + * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified + * location. If you pass in an index, only the index at the specified location will be changed. + * Collision information will be recalculated at the specified location. * - * @class Camera - * @memberOf Phaser.Cameras.Sprite3D - * @constructor + * @function Phaser.Tilemaps.Components.PutTileAt * @since 3.0.0 * - * @param {Phaser.Scene} scene - [description] + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map. */ -var Camera = new Class({ +var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer) +{ + if (!IsInLayerBounds(tileX, tileY, layer)) { return null; } + if (recalculateFaces === undefined) { recalculateFaces = true; } - initialize: + var oldTile = layer.data[tileY][tileX]; + var oldTileCollides = oldTile && oldTile.collides; - function Camera (scene) + if (tile instanceof Tile) { - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#displayList - * @type {Phaser.GameObjects.DisplayList} - * @since 3.0.0 - */ - this.displayList = scene.sys.displayList; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#updateList - * @type {Phaser.GameObjects.UpdateList} - * @since 3.0.0 - */ - this.updateList = scene.sys.updateList; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#name - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.name = ''; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#direction - * @type {Phaser.Math.Vector3} - * @since 3.0.0 - */ - this.direction = new Vector3(0, 0, -1); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#up - * @type {Phaser.Math.Vector3} - * @since 3.0.0 - */ - this.up = new Vector3(0, 1, 0); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#position - * @type {Phaser.Math.Vector3} - * @since 3.0.0 - */ - this.position = new Vector3(); - - // The mapping from 3D size units to pixels. - // In the default case 1 3D unit = 128 pixels. So a sprite that is - // 256 x 128 px in size will be 2 x 1 units. - // Change to whatever best fits your game assets. - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#pixelScale - * @type {number} - * @since 3.0.0 - */ - this.pixelScale = 128; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#projection - * @type {Phaser.Math.Matrix4} - * @since 3.0.0 - */ - this.projection = new Matrix4(); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#view - * @type {Phaser.Math.Matrix4} - * @since 3.0.0 - */ - this.view = new Matrix4(); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#combined - * @type {Phaser.Math.Matrix4} - * @since 3.0.0 - */ - this.combined = new Matrix4(); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#invProjectionView - * @type {Phaser.Math.Matrix4} - * @since 3.0.0 - */ - this.invProjectionView = new Matrix4(); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#near - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.near = 1; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#far - * @type {number} - * @since 3.0.0 - */ - this.far = 100; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#ray - * @type {[type]} - * @since 3.0.0 - */ - this.ray = { - origin: new Vector3(), - direction: new Vector3() - }; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#viewportWidth - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.viewportWidth = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#viewportHeight - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.viewportHeight = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#billboardMatrixDirty - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.billboardMatrixDirty = true; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#children - * @type {Phaser.Structs.Set} - * @since 3.0.0 - */ - this.children = new Set(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setPosition - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} z - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setPosition: function (x, y, z) - { - this.position.set(x, y, z); - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setScene - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setScene: function (scene) - { - this.scene = scene; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setPixelScale - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setPixelScale: function (value) - { - this.pixelScale = value; - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#add - * @since 3.0.0 - * - * @param {[type]} sprite3D - [description] - * - * @return {[type]} [description] - */ - add: function (sprite3D) - { - this.children.set(sprite3D); - - this.updateChildren(); - - return sprite3D; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#remove - * @since 3.0.0 - * - * @param {[type]} child - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - remove: function (child) - { - this.displayList.remove(child.gameObject); - this.updateList.remove(child.gameObject); - - this.children.delete(child); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#clear - * @since 3.0.0 - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - clear: function () - { - var children = this.getChildren(); - - for (var i = 0; i < children.length; i++) + if (layer.data[tileY][tileX] === null) { - this.remove(children[i]); + layer.data[tileY][tileX] = new Tile(layer, tile.index, tileX, tileY, tile.width, tile.height); } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#getChildren - * @since 3.0.0 - * - * @return {array} [description] - */ - getChildren: function () + layer.data[tileY][tileX].copy(tile); + } + else { - return this.children.entries; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#create - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} z - [description] - * @param {[type]} key - [description] - * @param {[type]} frame - [description] - * @param {[type]} visible - [description] - * - * @return {[type]} [description] - */ - create: function (x, y, z, key, frame, visible) - { - if (visible === undefined) { visible = true; } - - var child = new Sprite3D(this.scene, x, y, z, key, frame); - - this.displayList.add(child.gameObject); - this.updateList.add(child.gameObject); - - child.visible = visible; - - this.children.set(child); - - this.updateChildren(); - - return child; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#createMultiple - * @since 3.0.0 - * - * @param {[type]} quantity - [description] - * @param {[type]} key - [description] - * @param {[type]} frame - [description] - * @param {[type]} visible - [description] - * - * @return {[type]} [description] - */ - createMultiple: function (quantity, key, frame, visible) - { - if (visible === undefined) { visible = true; } - - var output = []; - - for (var i = 0; i < quantity; i++) + var index = tile; + if (layer.data[tileY][tileX] === null) { - var child = new Sprite3D(this.scene, 0, 0, 0, key, frame); - - this.displayList.add(child.gameObject); - this.updateList.add(child.gameObject); - - child.visible = visible; - - this.children.set(child); - - output.push(child); - } - - return output; - }, - - // Create a bunch of Sprite3D objects in a rectangle - // size and spacing are Vec3s (or if integers are converted to vec3s) - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#createRect - * @since 3.0.0 - * - * @param {[type]} size - [description] - * @param {[type]} spacing - [description] - * @param {[type]} key - [description] - * @param {[type]} frame - [description] - * - * @return {[type]} [description] - */ - createRect: function (size, spacing, key, frame) - { - if (typeof size === 'number') { size = { x: size, y: size, z: size }; } - if (typeof spacing === 'number') { spacing = { x: spacing, y: spacing, z: spacing }; } - - var quantity = size.x * size.y * size.z; - - var sprites = this.createMultiple(quantity, key, frame); - - var i = 0; - - for (var z = 0.5 - (size.z / 2); z < (size.z / 2); z++) - { - for (var y = 0.5 - (size.y / 2); y < (size.y / 2); y++) - { - for (var x = 0.5 - (size.x / 2); x < (size.x / 2); x++) - { - var bx = (x * spacing.x); - var by = (y * spacing.y); - var bz = (z * spacing.z); - - sprites[i].position.set(bx, by, bz); - - i++; - } - } - } - - this.update(); - - return sprites; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#randomSphere - * @since 3.0.0 - * - * @param {[type]} radius - [description] - * @param {[type]} sprites - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - randomSphere: function (radius, sprites) - { - if (sprites === undefined) { sprites = this.getChildren(); } - - for (var i = 0; i < sprites.length; i++) - { - RandomXYZ(sprites[i].position, radius); - } - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#randomCube - * @since 3.0.0 - * - * @param {[type]} scale - [description] - * @param {[type]} sprites - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - randomCube: function (scale, sprites) - { - if (sprites === undefined) { sprites = this.getChildren(); } - - for (var i = 0; i < sprites.length; i++) - { - RandomXYZW(sprites[i].position, scale); - } - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#translateChildren - * @since 3.0.0 - * - * @param {[type]} vec3 - [description] - * @param {[type]} sprites - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - translateChildren: function (vec3, sprites) - { - if (sprites === undefined) { sprites = this.getChildren(); } - - for (var i = 0; i < sprites.length; i++) - { - sprites[i].position.add(vec3); - } - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#transformChildren - * @since 3.0.0 - * - * @param {[type]} mat4 - [description] - * @param {[type]} sprites - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - transformChildren: function (mat4, sprites) - { - if (sprites === undefined) { sprites = this.getChildren(); } - - for (var i = 0; i < sprites.length; i++) - { - sprites[i].position.transformMat4(mat4); - } - - return this.update(); - }, - - /** - * Sets the width and height of the viewport. Does not update any matrices. - * - * @method Phaser.Cameras.Sprite3D.Camera#setViewport - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setViewport: function (width, height) - { - this.viewportWidth = width; - this.viewportHeight = height; - - return this.update(); - }, - - /** - * Translates this camera by a specified Vector3 object - * or x, y, z parameters. Any undefined x y z values will - * default to zero, leaving that component unaffected. - * If you wish to set the camera position directly call setPosition instead. - * - * @method Phaser.Cameras.Sprite3D.Camera#translate - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} z - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - translate: function (x, y, z) - { - if (typeof x === 'object') - { - this.position.x += x.x || 0; - this.position.y += x.y || 0; - this.position.z += x.z || 0; + layer.data[tileY][tileX] = new Tile(layer, index, tileX, tileY, layer.tileWidth, layer.tileHeight); } else { - this.position.x += x || 0; - this.position.y += y || 0; - this.position.z += z || 0; - } - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#lookAt - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} z - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - lookAt: function (x, y, z) - { - var dir = this.direction; - var up = this.up; - - if (typeof x === 'object') - { - dir.copy(x); - } - else - { - dir.set(x, y, z); - } - - dir.subtract(this.position).normalize(); - - // Calculate right vector - tmpVec3.copy(dir).cross(up).normalize(); - - // Calculate up vector - up.copy(tmpVec3).cross(dir).normalize(); - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#rotate - * @since 3.0.0 - * - * @param {[type]} radians - [description] - * @param {[type]} axis - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - rotate: function (radians, axis) - { - RotateVec3(this.direction, axis, radians); - RotateVec3(this.up, axis, radians); - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#rotateAround - * @since 3.0.0 - * - * @param {[type]} point - [description] - * @param {[type]} radians - [description] - * @param {[type]} axis - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - rotateAround: function (point, radians, axis) - { - tmpVec3.copy(point).subtract(this.position); - - this.translate(tmpVec3); - this.rotate(radians, axis); - this.translate(tmpVec3.negate()); - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#project - * @since 3.0.0 - * - * @param {[type]} vec - [description] - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - project: function (vec, out) - { - if (out === undefined) { out = new Vector4(); } - - // TODO: support viewport XY - var viewportWidth = this.viewportWidth; - var viewportHeight = this.viewportHeight; - var n = Camera.NEAR_RANGE; - var f = Camera.FAR_RANGE; - - // For useful Z and W values we should do the usual steps: clip space -> NDC -> window coords - - // Implicit 1.0 for w component - tmpVec4.set(vec.x, vec.y, vec.z, 1.0); - - // Transform into clip space - tmpVec4.transformMat4(this.combined); - - // Avoid divide by zero when 0x0x0 camera projects to a 0x0x0 vec3 - if (tmpVec4.w === 0) - { - tmpVec4.w = 1; - } - - // Now into NDC - tmpVec4.x = tmpVec4.x / tmpVec4.w; - tmpVec4.y = tmpVec4.y / tmpVec4.w; - tmpVec4.z = tmpVec4.z / tmpVec4.w; - - // And finally into window coordinates - out.x = viewportWidth / 2 * tmpVec4.x + (0 + viewportWidth / 2); - out.y = viewportHeight / 2 * tmpVec4.y + (0 + viewportHeight / 2); - out.z = (f - n) / 2 * tmpVec4.z + (f + n) / 2; - - // If the out vector has a fourth component, we also store (1/clip.w), same idea as gl_FragCoord.w - if (out.w === 0 || out.w) - { - out.w = 1 / tmpVec4.w; - } - - return out; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#unproject - * @since 3.0.0 - * - * @param {[type]} vec - [description] - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - unproject: function (vec, out) - { - if (out === undefined) { out = new Vector3(); } - - var viewport = tmpVec4.set(0, 0, this.viewportWidth, this.viewportHeight); - - return out.copy(vec).unproject(viewport, this.invProjectionView); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#getPickRay - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - getPickRay: function (x, y) - { - var origin = this.ray.origin.set(x, y, 0); - var direction = this.ray.direction.set(x, y, 1); - var viewport = tmpVec4.set(0, 0, this.viewportWidth, this.viewportHeight); - var mtx = this.invProjectionView; - - origin.unproject(viewport, mtx); - - direction.unproject(viewport, mtx); - - direction.subtract(origin).normalize(); - - return this.ray; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#updateChildren - * @since 3.0.0 - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - updateChildren: function () - { - var children = this.children.entries; - - for (var i = 0; i < children.length; i++) - { - children[i].project(this); - } - - return this; - }, - - // Overriden by subclasses - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#update - * @since 3.0.0 - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - update: function () - { - return this.updateChildren(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#updateBillboardMatrix - * @since 3.0.0 - */ - updateBillboardMatrix: function () - { - var dir = dirvec.set(this.direction).negate(); - - // Better view-aligned billboards might use this: - // var dir = tmp.set(camera.position).subtract(p).normalize(); - - var right = rightvec.set(this.up).cross(dir).normalize(); - var up = tmpVec3.set(dir).cross(right).normalize(); - - var out = billboardMatrix.val; - - out[0] = right.x; - out[1] = right.y; - out[2] = right.z; - out[3] = 0; - - out[4] = up.x; - out[5] = up.y; - out[6] = up.z; - out[7] = 0; - - out[8] = dir.x; - out[9] = dir.y; - out[10] = dir.z; - out[11] = 0; - - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - - this.billboardMatrixDirty = false; - }, - - /** - * This is a utility function for canvas 3D rendering, - * which determines the "point size" of a camera-facing - * sprite billboard given its 3D world position - * (origin at center of sprite) and its world width - * and height in x/y. - * - * We place into the output Vector2 the scaled width - * and height. If no `out` is specified, a new Vector2 - * will be created for convenience (this should be avoided - * in tight loops). - * - * @method Phaser.Cameras.Sprite3D.Camera#getPointSize - * @since 3.0.0 - * - * @param {[type]} vec - The position of the 3D Sprite. - * @param {[type]} size - The x and y dimensions. - * @param {[type]} out - The result, scaled x and y dimensions. - * - * @return {[type]} [description] - */ - getPointSize: function (vec, size, out) - { - if (out === undefined) { out = new Vector2(); } - - // TODO: optimize this with a simple distance calculation: - // https://developer.valvesoftware.com/wiki/Field_of_View - - if (this.billboardMatrixDirty) - { - this.updateBillboardMatrix(); - } - - var tmp = tmpVec3; - - var dx = (size.x / this.pixelScale) / 2; - var dy = (size.y / this.pixelScale) / 2; - - tmp.set(-dx, -dy, 0).transformMat4(billboardMatrix).add(vec); - - this.project(tmp, tmp); - - var tlx = tmp.x; - var tly = tmp.y; - - tmp.set(dx, dy, 0).transformMat4(billboardMatrix).add(vec); - - this.project(tmp, tmp); - - var brx = tmp.x; - var bry = tmp.y; - - // var w = Math.abs(brx - tlx); - // var h = Math.abs(bry - tly); - - // Allow the projection to get negative ... - var w = brx - tlx; - var h = bry - tly; - - return out.set(w, h); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.children.clear(); - - this.scene = undefined; - this.children = undefined; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setX - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setX: function (value) - { - this.position.x = value; - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setY - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setY: function (value) - { - this.position.y = value; - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setZ - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setZ: function (value) - { - this.position.z = value; - - return this.update(); - }, - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.Camera#x - * @type {number} - * @since 3.0.0 - */ - x: { - get: function () - { - return this.position.x; - }, - - set: function (value) - { - this.position.x = value; - this.update(); - } - }, - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.Camera#y - * @type {number} - * @since 3.0.0 - */ - y: { - get: function () - { - return this.position.y; - }, - - set: function (value) - { - this.position.y = value; - this.update(); - } - }, - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.Camera#z - * @type {number} - * @since 3.0.0 - */ - z: { - get: function () - { - return this.position.z; - }, - - set: function (value) - { - this.position.z = value; - this.update(); + layer.data[tileY][tileX].index = index; } } -}); + // Updating colliding flag on the new tile + var newTile = layer.data[tileY][tileX]; + var collides = layer.collideIndexes.indexOf(newTile.index) !== -1; + SetTileCollision(newTile, collides); -Camera.FAR_RANGE = 1.0; -Camera.NEAR_RANGE = 0.0; + // Recalculate faces only if the colliding flag at (tileX, tileY) has changed + if (recalculateFaces && (oldTileCollides !== newTile.collides)) + { + CalculateFacesAt(tileX, tileY, layer); + } + + return newTile; +}; + +module.exports = PutTileAt; -module.exports = Camera; /***/ }), @@ -23307,9849 +23105,75 @@ module.exports = Camera; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji -// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl - -var Class = __webpack_require__(0); - -var EPSILON = 0.000001; +var GetTileAt = __webpack_require__(87); /** - * @classdesc - * [description] + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. * - * @class Matrix4 - * @memberOf Phaser.Math - * @constructor + * @function Phaser.Tilemaps.Components.CalculateFacesAt * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} [m] - [description] + * + * @param {integer} tileX - The x coordinate. + * @param {integer} tileY - The y coordinate. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. */ -var Matrix4 = new Class({ +var CalculateFacesAt = function (tileX, tileY, layer) +{ + var tile = GetTileAt(tileX, tileY, true, layer); + var above = GetTileAt(tileX, tileY - 1, true, layer); + var below = GetTileAt(tileX, tileY + 1, true, layer); + var left = GetTileAt(tileX - 1, tileY, true, layer); + var right = GetTileAt(tileX + 1, tileY, true, layer); + var tileCollides = tile && tile.collides; - initialize: - - function Matrix4 (m) + // Assume the changed tile has all interesting edges + if (tileCollides) { - /** - * [description] - * - * @name Phaser.Math.Matrix4#val - * @type {Float32Array} - * @since 3.0.0 - */ - this.val = new Float32Array(16); - - if (m) - { - // Assume Matrix4 with val: - this.copy(m); - } - else - { - // Default to identity - this.identity(); - } - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#clone - * @since 3.0.0 - * - * @return {[type]} [description] - */ - clone: function () - { - return new Matrix4(this); - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#set - * @since 3.0.0 - * - * @param {[type]} src - [description] - * - * @return {[type]} [description] - */ - set: function (src) - { - return this.copy(src); - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#copy - * @since 3.0.0 - * - * @param {[type]} src - [description] - * - * @return {[type]} [description] - */ - copy: function (src) - { - var out = this.val; - var a = src.val; - - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - out[9] = a[9]; - out[10] = a[10]; - out[11] = a[11]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#fromArray - * @since 3.0.0 - * - * @param {[type]} a - [description] - * - * @return {[type]} [description] - */ - fromArray: function (a) - { - var out = this.val; - - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - out[9] = a[9]; - out[10] = a[10]; - out[11] = a[11]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#zero - * @since 3.0.0 - * - * @return {[type]} [description] - */ - zero: function () - { - var out = this.val; - - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = 0; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = 0; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#xyz - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} z - [description] - * - * @return {[type]} [description] - */ - xyz: function (x, y, z) - { - this.identity(); - - var out = this.val; - - out[12] = x; - out[13] = y; - out[14] = z; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#scaling - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} z - [description] - * - * @return {[type]} [description] - */ - scaling: function (x, y, z) - { - this.zero(); - - var out = this.val; - - out[0] = x; - out[5] = y; - out[10] = z; - out[15] = 1; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#identity - * @since 3.0.0 - * - * @return {[type]} [description] - */ - identity: function () - { - var out = this.val; - - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = 1; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = 1; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#transpose - * @since 3.0.0 - * - * @return {[type]} [description] - */ - transpose: function () - { - var a = this.val; - - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - var a12 = a[6]; - var a13 = a[7]; - var a23 = a[11]; - - a[1] = a[4]; - a[2] = a[8]; - a[3] = a[12]; - a[4] = a01; - a[6] = a[9]; - a[7] = a[13]; - a[8] = a02; - a[9] = a12; - a[11] = a[14]; - a[12] = a03; - a[13] = a13; - a[14] = a23; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#invert - * @since 3.0.0 - * - * @return {[type]} [description] - */ - invert: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - var a30 = a[12]; - var a31 = a[13]; - var a32 = a[14]; - var a33 = a[15]; - - var b00 = a00 * a11 - a01 * a10; - var b01 = a00 * a12 - a02 * a10; - var b02 = a00 * a13 - a03 * a10; - var b03 = a01 * a12 - a02 * a11; - - var b04 = a01 * a13 - a03 * a11; - var b05 = a02 * a13 - a03 * a12; - var b06 = a20 * a31 - a21 * a30; - var b07 = a20 * a32 - a22 * a30; - - var b08 = a20 * a33 - a23 * a30; - var b09 = a21 * a32 - a22 * a31; - var b10 = a21 * a33 - a23 * a31; - var b11 = a22 * a33 - a23 * a32; - - - // Calculate the determinant - var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; - - if (!det) - { - return null; - } - - det = 1 / det; - - a[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; - a[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; - a[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; - a[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; - a[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; - a[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; - a[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; - a[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; - a[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; - a[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; - a[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; - a[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; - a[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; - a[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; - a[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; - a[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#adjoint - * @since 3.0.0 - * - * @return {[type]} [description] - */ - adjoint: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - var a30 = a[12]; - var a31 = a[13]; - var a32 = a[14]; - var a33 = a[15]; - - a[0] = (a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22)); - a[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22)); - a[2] = (a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12)); - a[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12)); - a[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22)); - a[5] = (a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22)); - a[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12)); - a[7] = (a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12)); - a[8] = (a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21)); - a[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21)); - a[10] = (a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11)); - a[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11)); - a[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21)); - a[13] = (a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21)); - a[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11)); - a[15] = (a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11)); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#determinant - * @since 3.0.0 - * - * @return {[type]} [description] - */ - determinant: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - var a30 = a[12]; - var a31 = a[13]; - var a32 = a[14]; - var a33 = a[15]; - - var b00 = a00 * a11 - a01 * a10; - var b01 = a00 * a12 - a02 * a10; - var b02 = a00 * a13 - a03 * a10; - var b03 = a01 * a12 - a02 * a11; - var b04 = a01 * a13 - a03 * a11; - var b05 = a02 * a13 - a03 * a12; - var b06 = a20 * a31 - a21 * a30; - var b07 = a20 * a32 - a22 * a30; - var b08 = a20 * a33 - a23 * a30; - var b09 = a21 * a32 - a22 * a31; - var b10 = a21 * a33 - a23 * a31; - var b11 = a22 * a33 - a23 * a32; - - // Calculate the determinant - return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#multiply - * @since 3.0.0 - * - * @param {[type]} src - [description] - * - * @return {[type]} [description] - */ - multiply: function (src) - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - var a30 = a[12]; - var a31 = a[13]; - var a32 = a[14]; - var a33 = a[15]; - - var b = src.val; - - // Cache only the current line of the second matrix - var b0 = b[0]; - var b1 = b[1]; - var b2 = b[2]; - var b3 = b[3]; - - a[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - a[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - a[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - a[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - - b0 = b[4]; - b1 = b[5]; - b2 = b[6]; - b3 = b[7]; - - a[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - a[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - a[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - a[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - - b0 = b[8]; - b1 = b[9]; - b2 = b[10]; - b3 = b[11]; - - a[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - a[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - a[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - a[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - - b0 = b[12]; - b1 = b[13]; - b2 = b[14]; - b3 = b[15]; - - a[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - a[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - a[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - a[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#multiplyLocal - * @since 3.0.0 - * - * @param {[type]} src - [description] - * - * @return {[type]} [description] - */ - multiplyLocal: function (src) - { - var a = []; - var m1 = this.val; - var m2 = src.val; - - a[0] = m1[0] * m2[0] + m1[1] * m2[4] + m1[2] * m2[8] + m1[3] * m2[12]; - a[1] = m1[0] * m2[1] + m1[1] * m2[5] + m1[2] * m2[9] + m1[3] * m2[13]; - a[2] = m1[0] * m2[2] + m1[1] * m2[6] + m1[2] * m2[10] + m1[3] * m2[14]; - a[3] = m1[0] * m2[3] + m1[1] * m2[7] + m1[2] * m2[11] + m1[3] * m2[15]; - - a[4] = m1[4] * m2[0] + m1[5] * m2[4] + m1[6] * m2[8] + m1[7] * m2[12]; - a[5] = m1[4] * m2[1] + m1[5] * m2[5] + m1[6] * m2[9] + m1[7] * m2[13]; - a[6] = m1[4] * m2[2] + m1[5] * m2[6] + m1[6] * m2[10] + m1[7] * m2[14]; - a[7] = m1[4] * m2[3] + m1[5] * m2[7] + m1[6] * m2[11] + m1[7] * m2[15]; - - a[8] = m1[8] * m2[0] + m1[9] * m2[4] + m1[10] * m2[8] + m1[11] * m2[12]; - a[9] = m1[8] * m2[1] + m1[9] * m2[5] + m1[10] * m2[9] + m1[11] * m2[13]; - a[10] = m1[8] * m2[2] + m1[9] * m2[6] + m1[10] * m2[10] + m1[11] * m2[14]; - a[11] = m1[8] * m2[3] + m1[9] * m2[7] + m1[10] * m2[11] + m1[11] * m2[15]; - - a[12] = m1[12] * m2[0] + m1[13] * m2[4] + m1[14] * m2[8] + m1[15] * m2[12]; - a[13] = m1[12] * m2[1] + m1[13] * m2[5] + m1[14] * m2[9] + m1[15] * m2[13]; - a[14] = m1[12] * m2[2] + m1[13] * m2[6] + m1[14] * m2[10] + m1[15] * m2[14]; - a[15] = m1[12] * m2[3] + m1[13] * m2[7] + m1[14] * m2[11] + m1[15] * m2[15]; - - return this.fromArray(a); - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#translate - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - translate: function (v) - { - var x = v.x; - var y = v.y; - var z = v.z; - var a = this.val; - - a[12] = a[0] * x + a[4] * y + a[8] * z + a[12]; - a[13] = a[1] * x + a[5] * y + a[9] * z + a[13]; - a[14] = a[2] * x + a[6] * y + a[10] * z + a[14]; - a[15] = a[3] * x + a[7] * y + a[11] * z + a[15]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#scale - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - scale: function (v) - { - var x = v.x; - var y = v.y; - var z = v.z; - var a = this.val; - - a[0] = a[0] * x; - a[1] = a[1] * x; - a[2] = a[2] * x; - a[3] = a[3] * x; - - a[4] = a[4] * y; - a[5] = a[5] * y; - a[6] = a[6] * y; - a[7] = a[7] * y; - - a[8] = a[8] * z; - a[9] = a[9] * z; - a[10] = a[10] * z; - a[11] = a[11] * z; - - return this; - }, - - // Axis = vec3, angle = radians - /** - * [description] - * - * @method Phaser.Math.Matrix4#makeRotationAxis - * @since 3.0.0 - * - * @param {[type]} axis - [description] - * @param {[type]} angle - [description] - * - * @return {[type]} [description] - */ - makeRotationAxis: function (axis, angle) - { - // Based on http://www.gamedev.net/reference/articles/article1199.asp - - var c = Math.cos(angle); - var s = Math.sin(angle); - var t = 1 - c; - var x = axis.x; - var y = axis.y; - var z = axis.z; - var tx = t * x; - var ty = t * y; - - this.set( - tx * x + c, tx * y - s * z, tx * z + s * y, 0, - tx * y + s * z, ty * y + c, ty * z - s * x, 0, - tx * z - s * y, ty * z + s * x, t * z * z + c, 0, - 0, 0, 0, 1 - ); - - return this; - }, - - // aka rotationAxis - /** - * [description] - * - * @method Phaser.Math.Matrix4#rotate - * @since 3.0.0 - * - * @param {[type]} rad - [description] - * @param {[type]} axis - [description] - * - * @return {[type]} [description] - */ - rotate: function (rad, axis) - { - var a = this.val; - var x = axis.x; - var y = axis.y; - var z = axis.z; - var len = Math.sqrt(x * x + y * y + z * z); - - if (Math.abs(len) < EPSILON) - { - return null; - } - - len = 1 / len; - x *= len; - y *= len; - z *= len; - - var s = Math.sin(rad); - var c = Math.cos(rad); - var t = 1 - c; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - // Construct the elements of the rotation matrix - var b00 = x * x * t + c; - var b01 = y * x * t + z * s; - var b02 = z * x * t - y * s; - - var b10 = x * y * t - z * s; - var b11 = y * y * t + c; - var b12 = z * y * t + x * s; - - var b20 = x * z * t + y * s; - var b21 = y * z * t - x * s; - var b22 = z * z * t + c; - - // Perform rotation-specific matrix multiplication - a[0] = a00 * b00 + a10 * b01 + a20 * b02; - a[1] = a01 * b00 + a11 * b01 + a21 * b02; - a[2] = a02 * b00 + a12 * b01 + a22 * b02; - a[3] = a03 * b00 + a13 * b01 + a23 * b02; - a[4] = a00 * b10 + a10 * b11 + a20 * b12; - a[5] = a01 * b10 + a11 * b11 + a21 * b12; - a[6] = a02 * b10 + a12 * b11 + a22 * b12; - a[7] = a03 * b10 + a13 * b11 + a23 * b12; - a[8] = a00 * b20 + a10 * b21 + a20 * b22; - a[9] = a01 * b20 + a11 * b21 + a21 * b22; - a[10] = a02 * b20 + a12 * b21 + a22 * b22; - a[11] = a03 * b20 + a13 * b21 + a23 * b22; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#rotateX - * @since 3.0.0 - * - * @param {[type]} rad - [description] - * - * @return {[type]} [description] - */ - rotateX: function (rad) - { - var a = this.val; - var s = Math.sin(rad); - var c = Math.cos(rad); - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - // Perform axis-specific matrix multiplication - a[4] = a10 * c + a20 * s; - a[5] = a11 * c + a21 * s; - a[6] = a12 * c + a22 * s; - a[7] = a13 * c + a23 * s; - a[8] = a20 * c - a10 * s; - a[9] = a21 * c - a11 * s; - a[10] = a22 * c - a12 * s; - a[11] = a23 * c - a13 * s; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#rotateY - * @since 3.0.0 - * - * @param {[type]} rad - [description] - * - * @return {[type]} [description] - */ - rotateY: function (rad) - { - var a = this.val; - var s = Math.sin(rad); - var c = Math.cos(rad); - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - // Perform axis-specific matrix multiplication - a[0] = a00 * c - a20 * s; - a[1] = a01 * c - a21 * s; - a[2] = a02 * c - a22 * s; - a[3] = a03 * c - a23 * s; - a[8] = a00 * s + a20 * c; - a[9] = a01 * s + a21 * c; - a[10] = a02 * s + a22 * c; - a[11] = a03 * s + a23 * c; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#rotateZ - * @since 3.0.0 - * - * @param {[type]} rad - [description] - * - * @return {[type]} [description] - */ - rotateZ: function (rad) - { - var a = this.val; - var s = Math.sin(rad); - var c = Math.cos(rad); - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - // Perform axis-specific matrix multiplication - a[0] = a00 * c + a10 * s; - a[1] = a01 * c + a11 * s; - a[2] = a02 * c + a12 * s; - a[3] = a03 * c + a13 * s; - a[4] = a10 * c - a00 * s; - a[5] = a11 * c - a01 * s; - a[6] = a12 * c - a02 * s; - a[7] = a13 * c - a03 * s; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#fromRotationTranslation - * @since 3.0.0 - * - * @param {[type]} q - [description] - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - fromRotationTranslation: function (q, v) - { - // Quaternion math - var out = this.val; - - var x = q.x; - var y = q.y; - var z = q.z; - var w = q.w; - - var x2 = x + x; - var y2 = y + y; - var z2 = z + z; - - var xx = x * x2; - var xy = x * y2; - var xz = x * z2; - - var yy = y * y2; - var yz = y * z2; - var zz = z * z2; - - var wx = w * x2; - var wy = w * y2; - var wz = w * z2; - - out[0] = 1 - (yy + zz); - out[1] = xy + wz; - out[2] = xz - wy; - out[3] = 0; - - out[4] = xy - wz; - out[5] = 1 - (xx + zz); - out[6] = yz + wx; - out[7] = 0; - - out[8] = xz + wy; - out[9] = yz - wx; - out[10] = 1 - (xx + yy); - out[11] = 0; - - out[12] = v.x; - out[13] = v.y; - out[14] = v.z; - out[15] = 1; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#fromQuat - * @since 3.0.0 - * - * @param {[type]} q - [description] - * - * @return {[type]} [description] - */ - fromQuat: function (q) - { - var out = this.val; - - var x = q.x; - var y = q.y; - var z = q.z; - var w = q.w; - - var x2 = x + x; - var y2 = y + y; - var z2 = z + z; - - var xx = x * x2; - var xy = x * y2; - var xz = x * z2; - - var yy = y * y2; - var yz = y * z2; - var zz = z * z2; - - var wx = w * x2; - var wy = w * y2; - var wz = w * z2; - - out[0] = 1 - (yy + zz); - out[1] = xy + wz; - out[2] = xz - wy; - out[3] = 0; - - out[4] = xy - wz; - out[5] = 1 - (xx + zz); - out[6] = yz + wx; - out[7] = 0; - - out[8] = xz + wy; - out[9] = yz - wx; - out[10] = 1 - (xx + yy); - out[11] = 0; - - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - - return this; - }, - - /** - * Generates a frustum matrix with the given bounds - * - * @param {Number} left Left bound of the frustum - * @param {Number} right Right bound of the frustum - * @param {Number} bottom Bottom bound of the frustum - * @param {Number} top Top bound of the frustum - * @param {Number} near Near bound of the frustum - * @param {Number} far Far bound of the frustum - * @returns {Matrix4} this for chaining - */ - /** - * [description] - * - * @method Phaser.Math.Matrix4#frustum - * @since 3.0.0 - * - * @param {[type]} left - [description] - * @param {[type]} right - [description] - * @param {[type]} bottom - [description] - * @param {[type]} top - [description] - * @param {[type]} near - [description] - * @param {[type]} far - [description] - * - * @return {[type]} [description] - */ - frustum: function (left, right, bottom, top, near, far) - { - var out = this.val; - - var rl = 1 / (right - left); - var tb = 1 / (top - bottom); - var nf = 1 / (near - far); - - out[0] = (near * 2) * rl; - out[1] = 0; - out[2] = 0; - out[3] = 0; - - out[4] = 0; - out[5] = (near * 2) * tb; - out[6] = 0; - out[7] = 0; - - out[8] = (right + left) * rl; - out[9] = (top + bottom) * tb; - out[10] = (far + near) * nf; - out[11] = -1; - - out[12] = 0; - out[13] = 0; - out[14] = (far * near * 2) * nf; - out[15] = 0; - - return this; - }, - - /** - * Generates a perspective projection matrix with the given bounds. - * perspective fov lh - * - * @param {number} fovy Vertical field of view in radians - * @param {number} aspect Aspect ratio. typically viewport width/height - * @param {number} near Near bound of the frustum - * @param {number} far Far bound of the frustum - * @returns {Matrix4} this for chaining - */ - /** - * [description] - * - * @method Phaser.Math.Matrix4#perspective - * @since 3.0.0 - * - * @param {[type]} fovy - [description] - * @param {[type]} aspect - [description] - * @param {[type]} near - [description] - * @param {[type]} far - [description] - * - * @return {[type]} [description] - */ - perspective: function (fovy, aspect, near, far) - { - var out = this.val; - var f = 1.0 / Math.tan(fovy / 2); - var nf = 1 / (near - far); - - out[0] = f / aspect; - out[1] = 0; - out[2] = 0; - out[3] = 0; - - out[4] = 0; - out[5] = f; - out[6] = 0; - out[7] = 0; - - out[8] = 0; - out[9] = 0; - out[10] = (far + near) * nf; - out[11] = -1; - - out[12] = 0; - out[13] = 0; - out[14] = (2 * far * near) * nf; - out[15] = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#perspectiveLH - * @since 3.0.0 - * - * @param {[type]} width - [description] - * @param {[type]} height - [description] - * @param {[type]} near - [description] - * @param {[type]} far - [description] - * - * @return {[type]} [description] - */ - perspectiveLH: function (width, height, near, far) - { - var out = this.val; - - out[0] = (2 * near) / width; - out[1] = 0; - out[2] = 0; - out[3] = 0; - - out[4] = 0; - out[5] = (2 * near) / height; - out[6] = 0; - out[7] = 0; - - out[8] = 0; - out[9] = 0; - out[10] = -far / (near - far); - out[11] = 1; - - out[12] = 0; - out[13] = 0; - out[14] = (near * far) / (near - far); - out[15] = 0; - - return this; - }, - - /** - * Generates a orthogonal projection matrix with the given bounds - * - * @param {number} left Left bound of the frustum - * @param {number} right Right bound of the frustum - * @param {number} bottom Bottom bound of the frustum - * @param {number} top Top bound of the frustum - * @param {number} near Near bound of the frustum - * @param {number} far Far bound of the frustum - * @returns {Matrix4} this for chaining - */ - /** - * [description] - * - * @method Phaser.Math.Matrix4#ortho - * @since 3.0.0 - * - * @param {[type]} left - [description] - * @param {[type]} right - [description] - * @param {[type]} bottom - [description] - * @param {[type]} top - [description] - * @param {[type]} near - [description] - * @param {[type]} far - [description] - * - * @return {[type]} [description] - */ - ortho: function (left, right, bottom, top, near, far) - { - var out = this.val; - var lr = left - right; - var bt = bottom - top; - var nf = near - far; - - // Avoid division by zero - lr = (lr === 0) ? lr : 1 / lr; - bt = (bt === 0) ? bt : 1 / bt; - nf = (nf === 0) ? nf : 1 / nf; - - out[0] = -2 * lr; - out[1] = 0; - out[2] = 0; - out[3] = 0; - - out[4] = 0; - out[5] = -2 * bt; - out[6] = 0; - out[7] = 0; - - out[8] = 0; - out[9] = 0; - out[10] = 2 * nf; - out[11] = 0; - - out[12] = (left + right) * lr; - out[13] = (top + bottom) * bt; - out[14] = (far + near) * nf; - out[15] = 1; - - return this; - }, - - /** - * Generates a look-at matrix with the given eye position, focal point, and up axis - * - * @param {Vector3} eye Position of the viewer - * @param {Vector3} center Point the viewer is looking at - * @param {Vector3} up vec3 pointing up - * @returns {Matrix4} this for chaining - */ - /** - * [description] - * - * @method Phaser.Math.Matrix4#lookAt - * @since 3.0.0 - * - * @param {[type]} eye - [description] - * @param {[type]} center - [description] - * @param {[type]} up - [description] - * - * @return {[type]} [description] - */ - lookAt: function (eye, center, up) - { - var out = this.val; - - var eyex = eye.x; - var eyey = eye.y; - var eyez = eye.z; - - var upx = up.x; - var upy = up.y; - var upz = up.z; - - var centerx = center.x; - var centery = center.y; - var centerz = center.z; - - if (Math.abs(eyex - centerx) < EPSILON && - Math.abs(eyey - centery) < EPSILON && - Math.abs(eyez - centerz) < EPSILON) - { - return this.identity(); - } - - var z0 = eyex - centerx; - var z1 = eyey - centery; - var z2 = eyez - centerz; - - var len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2); - - z0 *= len; - z1 *= len; - z2 *= len; - - var x0 = upy * z2 - upz * z1; - var x1 = upz * z0 - upx * z2; - var x2 = upx * z1 - upy * z0; - - len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2); - - if (!len) - { - x0 = 0; - x1 = 0; - x2 = 0; - } - else - { - len = 1 / len; - x0 *= len; - x1 *= len; - x2 *= len; - } - - var y0 = z1 * x2 - z2 * x1; - var y1 = z2 * x0 - z0 * x2; - var y2 = z0 * x1 - z1 * x0; - - len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2); - - if (!len) - { - y0 = 0; - y1 = 0; - y2 = 0; - } - else - { - len = 1 / len; - y0 *= len; - y1 *= len; - y2 *= len; - } - - out[0] = x0; - out[1] = y0; - out[2] = z0; - out[3] = 0; - - out[4] = x1; - out[5] = y1; - out[6] = z1; - out[7] = 0; - - out[8] = x2; - out[9] = y2; - out[10] = z2; - out[11] = 0; - - out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez); - out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez); - out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez); - out[15] = 1; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#yawPitchRoll - * @since 3.0.0 - * - * @param {[type]} yaw - [description] - * @param {[type]} pitch - [description] - * @param {[type]} roll - [description] - * - * @return {[type]} [description] - */ - yawPitchRoll: function (yaw, pitch, roll) - { - this.zero(); - _tempMat1.zero(); - _tempMat2.zero(); - - var m0 = this.val; - var m1 = _tempMat1.val; - var m2 = _tempMat2.val; - - // Rotate Z - var s = Math.sin(roll); - var c = Math.cos(roll); - - m0[10] = 1; - m0[15] = 1; - m0[0] = c; - m0[1] = s; - m0[4] = -s; - m0[5] = c; - - // Rotate X - s = Math.sin(pitch); - c = Math.cos(pitch); - - m1[0] = 1; - m1[15] = 1; - m1[5] = c; - m1[10] = c; - m1[9] = -s; - m1[6] = s; - - // Rotate Y - s = Math.sin(yaw); - c = Math.cos(yaw); - - m2[5] = 1; - m2[15] = 1; - m2[0] = c; - m2[2] = -s; - m2[8] = s; - m2[10] = c; - - this.multiplyLocal(_tempMat1); - this.multiplyLocal(_tempMat2); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#setWorldMatrix - * @since 3.0.0 - * - * @param {[type]} rotation - [description] - * @param {[type]} position - [description] - * @param {[type]} scale - [description] - * @param {[type]} viewMatrix - [description] - * @param {[type]} projectionMatrix - [description] - * - * @return {[type]} [description] - */ - setWorldMatrix: function (rotation, position, scale, viewMatrix, projectionMatrix) - { - this.yawPitchRoll(rotation.y, rotation.x, rotation.z); - - _tempMat1.scaling(scale.x, scale.y, scale.z); - _tempMat2.xyz(position.x, position.y, position.z); - - this.multiplyLocal(_tempMat1); - this.multiplyLocal(_tempMat2); - - if (viewMatrix !== undefined) - { - this.multiplyLocal(viewMatrix); - } - - if (projectionMatrix !== undefined) - { - this.multiplyLocal(projectionMatrix); - } - - return this; + tile.faceTop = true; + tile.faceBottom = true; + tile.faceLeft = true; + tile.faceRight = true; } -}); + // Reset edges that are shared between tile and its neighbors + if (above && above.collides) + { + if (tileCollides) { tile.faceTop = false; } + above.faceBottom = !tileCollides; + } -var _tempMat1 = new Matrix4(); -var _tempMat2 = new Matrix4(); + if (below && below.collides) + { + if (tileCollides) { tile.faceBottom = false; } + below.faceTop = !tileCollides; + } -module.exports = Matrix4; + if (left && left.collides) + { + if (tileCollides) { tile.faceLeft = false; } + left.faceRight = !tileCollides; + } + + if (right && right.collides) + { + if (tileCollides) { tile.faceRight = false; } + right.faceLeft = !tileCollides; + } + + if (tile && !tile.collides) { tile.resetFaces(); } + + return tile; +}; + +module.exports = CalculateFacesAt; /***/ }), /* 120 */ /***/ (function(module, exports, __webpack_require__) { -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji -// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class Vector4 - * @memberOf Phaser.Math - * @constructor - * @since 3.0.0 - * - * @param {number} [x] - [description] - * @param {number} [y] - [description] - * @param {number} [z] - [description] - * @param {number} [w] - [description] - */ -var Vector4 = new Class({ - - initialize: - - function Vector4 (x, y, z, w) - { - /** - * The x component of this Vector. - * - * @name Phaser.Math.Vector4#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - /** - * The y component of this Vector. - * - * @name Phaser.Math.Vector4#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - /** - * The z component of this Vector. - * - * @name Phaser.Math.Vector4#z - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - /** - * The w component of this Vector. - * - * @name Phaser.Math.Vector4#w - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - if (typeof x === 'object') - { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - this.w = x.w || 0; - } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - this.w = w || 0; - } - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#clone - * @since 3.0.0 - * - * @return {Phaser.Math.Vector4} [description] - */ - clone: function () - { - return new Vector4(this.x, this.y, this.z, this.w); - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#copy - * @since 3.0.0 - * - * @param {Phaser.Math.Vector4} src - [description] - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - copy: function (src) - { - this.x = src.x; - this.y = src.y; - this.z = src.z || 0; - this.w = src.w || 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#equals - * @since 3.0.0 - * - * @param {Phaser.Math.Vector4} v - [description] - * - * @return {boolean} [description] - */ - equals: function (v) - { - return ((this.x === v.x) && (this.y === v.y) && (this.z === v.z) && (this.w === v.w)); - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#set - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} z - [description] - * @param {number} w - [description] - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - set: function (x, y, z, w) - { - if (typeof x === 'object') - { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - this.w = x.w || 0; - } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - this.w = w || 0; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#add - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4} v - [description] - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - add: function (v) - { - this.x += v.x; - this.y += v.y; - this.z += v.z || 0; - this.w += v.w || 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#subtract - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4} v - [description] - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - subtract: function (v) - { - this.x -= v.x; - this.y -= v.y; - this.z -= v.z || 0; - this.w -= v.w || 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#scale - * @since 3.0.0 - * - * @param {number} scale - [description] - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - scale: function (scale) - { - this.x *= scale; - this.y *= scale; - this.z *= scale; - this.w *= scale; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#length - * @since 3.0.0 - * - * @return {number} [description] - */ - length: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - - return Math.sqrt(x * x + y * y + z * z + w * w); - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#lengthSq - * @since 3.0.0 - * - * @return {number} [description] - */ - lengthSq: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - - return x * x + y * y + z * z + w * w; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#normalize - * @since 3.0.0 - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - normalize: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - var len = x * x + y * y + z * z + w * w; - - if (len > 0) - { - len = 1 / Math.sqrt(len); - - this.x = x * len; - this.y = y * len; - this.z = z * len; - this.w = w * len; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#dot - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {number} [description] - */ - dot: function (v) - { - return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#lerp - * @since 3.0.0 - * - * @param {[type]} v - [description] - * @param {[type]} t - [description] - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - lerp: function (v, t) - { - if (t === undefined) { t = 0; } - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - this.x = ax + t * (v.x - ax); - this.y = ay + t * (v.y - ay); - this.z = az + t * (v.z - az); - this.w = aw + t * (v.w - aw); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#multiply - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - multiply: function (v) - { - this.x *= v.x; - this.y *= v.y; - this.z *= v.z || 1; - this.w *= v.w || 1; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#divide - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - divide: function (v) - { - this.x /= v.x; - this.y /= v.y; - this.z /= v.z || 1; - this.w /= v.w || 1; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#distance - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {number} [description] - */ - distance: function (v) - { - var dx = v.x - this.x; - var dy = v.y - this.y; - var dz = v.z - this.z || 0; - var dw = v.w - this.w || 0; - - return Math.sqrt(dx * dx + dy * dy + dz * dz + dw * dw); - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#distanceSq - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {number} [description] - */ - distanceSq: function (v) - { - var dx = v.x - this.x; - var dy = v.y - this.y; - var dz = v.z - this.z || 0; - var dw = v.w - this.w || 0; - - return dx * dx + dy * dy + dz * dz + dw * dw; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#negate - * @since 3.0.0 - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - negate: function () - { - this.x = -this.x; - this.y = -this.y; - this.z = -this.z; - this.w = -this.w; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#transformMat4 - * @since 3.0.0 - * - * @param {[type]} mat - [description] - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - transformMat4: function (mat) - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - var m = mat.val; - - this.x = m[0] * x + m[4] * y + m[8] * z + m[12] * w; - this.y = m[1] * x + m[5] * y + m[9] * z + m[13] * w; - this.z = m[2] * x + m[6] * y + m[10] * z + m[14] * w; - this.w = m[3] * x + m[7] * y + m[11] * z + m[15] * w; - - return this; - }, - - // TODO: is this really the same as Vector3? - // Also, what about this: http://molecularmusings.wordpress.com/2013/05/24/a-faster-quaternion-vector-multiplication/ - /** - * [description] - * - * @method Phaser.Math.Vector4#transformQuat - * @since 3.0.0 - * - * @param {[type]} q - [description] - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - transformQuat: function (q) - { - // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations - var x = this.x; - var y = this.y; - var z = this.z; - var qx = q.x; - var qy = q.y; - var qz = q.z; - var qw = q.w; - - // calculate quat * vec - var ix = qw * x + qy * z - qz * y; - var iy = qw * y + qz * x - qx * z; - var iz = qw * z + qx * y - qy * x; - var iw = -qx * x - qy * y - qz * z; - - // calculate result * inverse quat - this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; - this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; - this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector4#reset - * @since 3.0.0 - * - * @return {Phaser.Math.Vector4} This Vector4 object. - */ - reset: function () - { - this.x = 0; - this.y = 0; - this.z = 0; - this.w = 0; - - return this; - } - -}); - -// TODO: Check if these are required internally, if not, remove. -Vector4.prototype.sub = Vector4.prototype.subtract; -Vector4.prototype.mul = Vector4.prototype.multiply; -Vector4.prototype.div = Vector4.prototype.divide; -Vector4.prototype.dist = Vector4.prototype.distance; -Vector4.prototype.distSq = Vector4.prototype.distanceSq; -Vector4.prototype.len = Vector4.prototype.length; -Vector4.prototype.lenSq = Vector4.prototype.lengthSq; - -module.exports = Vector4; - - -/***/ }), -/* 121 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Browser specific prefix, so not going to change between contexts, only between browsers -var prefix = ''; - -/** - * @namespace Phaser.Display.Canvas.Smoothing - * @since 3.0.0 - */ -var Smoothing = function () -{ - /** - * Gets the Smoothing Enabled vendor prefix being used on the given context, or null if not set. - * - * @function Phaser.Display.Canvas.Smoothing.getPrefix - * @since 3.0.0 - * - * @param {[type]} context - [description] - * - * @return {string} [description] - */ - var getPrefix = function (context) - { - var vendors = [ 'i', 'webkitI', 'msI', 'mozI', 'oI' ]; - - for (var i = 0; i < vendors.length; i++) - { - var s = vendors[i] + 'mageSmoothingEnabled'; - - if (s in context) - { - return s; - } - } - - return null; - }; - - /** - * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. - * By default browsers have image smoothing enabled, which isn't always what you visually want, especially - * when using pixel art in a game. Note that this sets the property on the context itself, so that any image - * drawn to the context will be affected. This sets the property across all current browsers but support is - * patchy on earlier browsers, especially on mobile. - * - * @function Phaser.Display.Canvas.Smoothing.enable - * @since 3.0.0 - * - * @param {[type]} context - [description] - * - * @return {[type]} [description] - */ - var enable = function (context) - { - if (prefix === '') - { - prefix = getPrefix(context); - } - - if (prefix) - { - context[prefix] = true; - } - - return context; - }; - - /** - * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. - * By default browsers have image smoothing enabled, which isn't always what you visually want, especially - * when using pixel art in a game. Note that this sets the property on the context itself, so that any image - * drawn to the context will be affected. This sets the property across all current browsers but support is - * patchy on earlier browsers, especially on mobile. - * - * @function Phaser.Display.Canvas.Smoothing.disable - * @since 3.0.0 - * - * @param {[type]} context - [description] - * - * @return {[type]} [description] - */ - var disable = function (context) - { - if (prefix === '') - { - prefix = getPrefix(context); - } - - if (prefix) - { - context[prefix] = false; - } - - return context; - }; - - /** - * Returns `true` if the given context has image smoothing enabled, otherwise returns `false`. - * Returns null if no smoothing prefix is available. - * - * @function Phaser.Display.Canvas.Smoothing.isEnabled - * @since 3.0.0 - * - * @param {[type]} context - [description] - * - * @return {boolean} [description] - */ - var isEnabled = function (context) - { - return (prefix !== null) ? context[prefix] : null; - }; - - return { - disable: disable, - enable: enable, - getPrefix: getPrefix, - isEnabled: isEnabled - }; - -}; - -module.exports = Smoothing(); - - -/***/ }), -/* 122 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(8); - -// points is an array of Point-like objects, -// either 2 dimensional arrays, or objects with public x/y properties: -// var points = [ -// [100, 200], -// [200, 400], -// { x: 30, y: 60 } -// ] - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.FromPoints - * @since 3.0.0 - * - * @param {[type]} points - [description] - * @param {Phaser.Geom.Rectangle} out - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var FromPoints = function (points, out) -{ - if (out === undefined) { out = new Rectangle(); } - - if (points.length === 0) - { - return out; - } - - var minX = Number.MAX_VALUE; - var minY = Number.MAX_VALUE; - - var maxX = Number.MIN_SAFE_INTEGER; - var maxY = Number.MIN_SAFE_INTEGER; - - var p; - var px; - var py; - - for (var i = 0; i < points.length; i++) - { - p = points[i]; - - if (Array.isArray(p)) - { - px = p[0]; - py = p[1]; - } - else - { - px = p.x; - py = p.y; - } - - minX = Math.min(minX, px); - minY = Math.min(minY, py); - - maxX = Math.max(maxX, px); - maxY = Math.max(maxY, py); - } - - out.x = minX; - out.y = minY; - out.width = maxX - minX; - out.height = maxY - minY; - - return out; -}; - -module.exports = FromPoints; - - -/***/ }), -/* 123 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.CatmullRom - * @since 3.0.0 - * - * @param {number} t - [description] - * @param {number} p0 - [description] - * @param {number} p1 - [description] - * @param {number} p2 - [description] - * @param {number} p3 - [description] - * - * @return {number} [description] - */ -var CatmullRom = function (t, p0, p1, p2, p3) -{ - var v0 = (p2 - p0) * 0.5; - var v1 = (p3 - p1) * 0.5; - var t2 = t * t; - var t3 = t * t2; - - return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; -}; - -module.exports = CatmullRom; - - -/***/ }), -/* 124 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Linear - * @since 3.0.0 - * - * @param {number} p0 - [description] - * @param {number} p1 - [description] - * @param {float} t - [description] - * - * @return {number} [description] - */ -var Linear = function (p0, p1, t) -{ - return (p1 - p0) * t + p0; -}; - -module.exports = Linear; - - -/***/ }), -/* 125 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Adds the given element to the DOM. If a parent is provided the element is added as a child of the parent, providing it was able to access it. - * If no parent was given or falls back to using `document.body`. - * - * @function Phaser.DOM.AddToDOM - * @since 3.0.0 - * - * @param {object} element - The element to be added to the DOM. Usually a Canvas object. - * @param {string|object} [parent] - The parent in which to add the element. Can be a string which is passed to `getElementById` or an actual DOM object. - * @param {boolean} [overflowHidden=true] - [description] - * - * @return {object} The element that was added to the DOM. - */ -var AddToDOM = function (element, parent, overflowHidden) -{ - if (overflowHidden === undefined) { overflowHidden = true; } - - var target; - - if (parent) - { - if (typeof parent === 'string') - { - // Hopefully an element ID - target = document.getElementById(parent); - } - else if (typeof parent === 'object' && parent.nodeType === 1) - { - // Quick test for a HTMLelement - target = parent; - } - } - - // Fallback, covers an invalid ID and a non HTMLelement object - if (!target) - { - target = document.body; - } - - if (overflowHidden && target.style) - { - target.style.overflow = 'hidden'; - } - - target.appendChild(element); - - return element; -}; - -module.exports = AddToDOM; - - -/***/ }), -/* 126 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var OS = __webpack_require__(67); -var Browser = __webpack_require__(82); -var CanvasPool = __webpack_require__(21); - -/** - * Determines the features of the browser running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.features` from within any Scene. - * - * @name Phaser.Device.Features - * @since 3.0.0 - * - * @type {object} - * @property {?boolean} canvasBitBltShift - True if canvas supports a 'copy' bitblt onto itself when the source and destination regions overlap. - * @property {boolean} canvas - Is canvas available? - * @property {boolean} file - Is file available? - * @property {boolean} fileSystem - Is fileSystem available? - * @property {boolean} getUserMedia - Does the device support the getUserMedia API? - * @property {boolean} littleEndian - Is the device big or little endian? (only detected if the browser supports TypedArrays) - * @property {boolean} localStorage - Is localStorage available? - * @property {boolean} pointerLock - Is Pointer Lock available? - * @property {boolean} support32bit - Does the device context support 32bit pixel manipulation using array buffer views? - * @property {boolean} vibration - Does the device support the Vibration API? - * @property {boolean} webGL - Is webGL available? - * @property {boolean} worker - Is worker available? - */ -var Features = { - - canvas: false, - canvasBitBltShift: null, - file: false, - fileSystem: false, - getUserMedia: true, - littleEndian: false, - localStorage: false, - pointerLock: false, - support32bit: false, - vibration: false, - webGL: false, - worker: false - -}; - -// Check Little or Big Endian system. -// @author Matt DesLauriers (@mattdesl) -function checkIsLittleEndian () -{ - var a = new ArrayBuffer(4); - var b = new Uint8Array(a); - var c = new Uint32Array(a); - - b[0] = 0xa1; - b[1] = 0xb2; - b[2] = 0xc3; - b[3] = 0xd4; - - if (c[0] === 0xd4c3b2a1) - { - return true; - } - - if (c[0] === 0xa1b2c3d4) - { - return false; - } - else - { - // Could not determine endianness - return null; - } -} - -function init () -{ - Features.canvas = !!window['CanvasRenderingContext2D'] || OS.cocoonJS; - - try - { - Features.localStorage = !!localStorage.getItem; - } - catch (error) - { - Features.localStorage = false; - } - - Features.file = !!window['File'] && !!window['FileReader'] && !!window['FileList'] && !!window['Blob']; - Features.fileSystem = !!window['requestFileSystem']; - - var isUint8 = false; - - var testWebGL = function () - { - if (window['WebGLRenderingContext']) - { - try - { - var canvas = CanvasPool.createWebGL(this); - - if (OS.cocoonJS) - { - canvas.screencanvas = false; - } - - var ctx = canvas.getContext('webgl') || canvas.getContext('experimental-webgl'); - - var canvas2D = CanvasPool.create2D(this); - - var ctx2D = canvas2D.getContext('2d'); - - // Can't be done on a webgl context - var image = ctx2D.createImageData(1, 1); - - // Test to see if ImageData uses CanvasPixelArray or Uint8ClampedArray. - // @author Matt DesLauriers (@mattdesl) - isUint8 = image.data instanceof Uint8ClampedArray; - - CanvasPool.remove(canvas); - CanvasPool.remove(canvas2D); - - return !!ctx; - } - catch (e) - { - return false; - } - } - - return false; - }; - - Features.webGL = testWebGL(); - - Features.worker = !!window['Worker']; - - Features.pointerLock = 'pointerLockElement' in document || 'mozPointerLockElement' in document || 'webkitPointerLockElement' in document; - - navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia; - - window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL; - - Features.getUserMedia = Features.getUserMedia && !!navigator.getUserMedia && !!window.URL; - - // Older versions of firefox (< 21) apparently claim support but user media does not actually work - if (Browser.firefox && Browser.firefoxVersion < 21) - { - Features.getUserMedia = false; - } - - // Excludes iOS versions as they generally wrap UIWebView (eg. Safari WebKit) and it - // is safer to not try and use the fast copy-over method. - if (!OS.iOS && (Browser.ie || Browser.firefox || Browser.chrome)) - { - Features.canvasBitBltShift = true; - } - - // Known not to work - if (Browser.safari || Browser.mobileSafari) - { - Features.canvasBitBltShift = false; - } - - navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate; - - if (navigator.vibrate) - { - Features.vibration = true; - } - - if (typeof ArrayBuffer !== 'undefined' && typeof Uint8Array !== 'undefined' && typeof Uint32Array !== 'undefined') - { - Features.littleEndian = checkIsLittleEndian(); - } - - Features.support32bit = ( - typeof ArrayBuffer !== 'undefined' && - typeof Uint8ClampedArray !== 'undefined' && - typeof Int32Array !== 'undefined' && - Features.littleEndian !== null && - isUint8 - ); - - return Features; -} - -module.exports = init(); - - -/***/ }), -/* 127 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Checks if the given `width` and `height` are a power of two. - * Useful for checking texture dimensions. - * - * @function Phaser.Math.Pow2.IsSizePowerOfTwo - * @since 3.0.0 - * - * @param {number} width - The width. - * @param {number} height - The height. - * - * @return {boolean} `true` if `width` and `height` are a power of two, otherwise `false`. - */ -var IsSizePowerOfTwo = function (width, height) -{ - return (width > 0 && (width & (width - 1)) === 0 && height > 0 && (height & (height - 1)) === 0); -}; - -module.exports = IsSizePowerOfTwo; - - -/***/ }), -/* 128 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.GameObjects.Graphics.Commands - */ - -module.exports = { - - ARC: 0, - BEGIN_PATH: 1, - CLOSE_PATH: 2, - FILL_RECT: 3, - LINE_TO: 4, - MOVE_TO: 5, - LINE_STYLE: 6, - FILL_STYLE: 7, - FILL_PATH: 8, - STROKE_PATH: 9, - FILL_TRIANGLE: 10, - STROKE_TRIANGLE: 11, - LINE_FX_TO: 12, - MOVE_FX_TO: 13, - SAVE: 14, - RESTORE: 15, - TRANSLATE: 16, - SCALE: 17, - ROTATE: 18 - -}; - - -/***/ }), -/* 129 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -module.exports = { - - /** - * @name Phaser.Input.Keyboard.KeyCodes.BACKSPACE - * @type {integer} - * @since 3.0.0 - */ - BACKSPACE: 8, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.TAB - * @type {integer} - * @since 3.0.0 - */ - TAB: 9, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.ENTER - * @type {integer} - * @since 3.0.0 - */ - ENTER: 13, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.SHIFT - * @type {integer} - * @since 3.0.0 - */ - SHIFT: 16, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.CTRL - * @type {integer} - * @since 3.0.0 - */ - CTRL: 17, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.ALT - * @type {integer} - * @since 3.0.0 - */ - ALT: 18, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PAUSE - * @type {integer} - * @since 3.0.0 - */ - PAUSE: 19, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.CAPS_LOCK - * @type {integer} - * @since 3.0.0 - */ - CAPS_LOCK: 20, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.ESC - * @type {integer} - * @since 3.0.0 - */ - ESC: 27, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.SPACE - * @type {integer} - * @since 3.0.0 - */ - SPACE: 32, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PAGE_UP - * @type {integer} - * @since 3.0.0 - */ - PAGE_UP: 33, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PAGE_DOWN - * @type {integer} - * @since 3.0.0 - */ - PAGE_DOWN: 34, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.END - * @type {integer} - * @since 3.0.0 - */ - END: 35, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.HOME - * @type {integer} - * @since 3.0.0 - */ - HOME: 36, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.LEFT - * @type {integer} - * @since 3.0.0 - */ - LEFT: 37, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.UP - * @type {integer} - * @since 3.0.0 - */ - UP: 38, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.RIGHT - * @type {integer} - * @since 3.0.0 - */ - RIGHT: 39, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.DOWN - * @type {integer} - * @since 3.0.0 - */ - DOWN: 40, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PRINT_SCREEN - * @type {integer} - * @since 3.0.0 - */ - PRINT_SCREEN: 42, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.INSERT - * @type {integer} - * @since 3.0.0 - */ - INSERT: 45, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.DELETE - * @type {integer} - * @since 3.0.0 - */ - DELETE: 46, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.ZERO - * @type {integer} - * @since 3.0.0 - */ - ZERO: 48, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.ONE - * @type {integer} - * @since 3.0.0 - */ - ONE: 49, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.TWO - * @type {integer} - * @since 3.0.0 - */ - TWO: 50, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.THREE - * @type {integer} - * @since 3.0.0 - */ - THREE: 51, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.FOUR - * @type {integer} - * @since 3.0.0 - */ - FOUR: 52, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.FIVE - * @type {integer} - * @since 3.0.0 - */ - FIVE: 53, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.SIX - * @type {integer} - * @since 3.0.0 - */ - SIX: 54, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.SEVEN - * @type {integer} - * @since 3.0.0 - */ - SEVEN: 55, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.EIGHT - * @type {integer} - * @since 3.0.0 - */ - EIGHT: 56, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NINE - * @type {integer} - * @since 3.0.0 - */ - NINE: 57, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.A - * @type {integer} - * @since 3.0.0 - */ - A: 65, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.B - * @type {integer} - * @since 3.0.0 - */ - B: 66, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.C - * @type {integer} - * @since 3.0.0 - */ - C: 67, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.D - * @type {integer} - * @since 3.0.0 - */ - D: 68, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.E - * @type {integer} - * @since 3.0.0 - */ - E: 69, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F - * @type {integer} - * @since 3.0.0 - */ - F: 70, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.G - * @type {integer} - * @since 3.0.0 - */ - G: 71, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.H - * @type {integer} - * @since 3.0.0 - */ - H: 72, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.I - * @type {integer} - * @since 3.0.0 - */ - I: 73, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.J - * @type {integer} - * @since 3.0.0 - */ - J: 74, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.K - * @type {integer} - * @since 3.0.0 - */ - K: 75, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.L - * @type {integer} - * @since 3.0.0 - */ - L: 76, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.M - * @type {integer} - * @since 3.0.0 - */ - M: 77, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.N - * @type {integer} - * @since 3.0.0 - */ - N: 78, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.O - * @type {integer} - * @since 3.0.0 - */ - O: 79, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.P - * @type {integer} - * @since 3.0.0 - */ - P: 80, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.Q - * @type {integer} - * @since 3.0.0 - */ - Q: 81, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.R - * @type {integer} - * @since 3.0.0 - */ - R: 82, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.S - * @type {integer} - * @since 3.0.0 - */ - S: 83, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.T - * @type {integer} - * @since 3.0.0 - */ - T: 84, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.U - * @type {integer} - * @since 3.0.0 - */ - U: 85, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.V - * @type {integer} - * @since 3.0.0 - */ - V: 86, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.W - * @type {integer} - * @since 3.0.0 - */ - W: 87, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.X - * @type {integer} - * @since 3.0.0 - */ - X: 88, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.Y - * @type {integer} - * @since 3.0.0 - */ - Y: 89, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.Z - * @type {integer} - * @since 3.0.0 - */ - Z: 90, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F1 - * @type {integer} - * @since 3.0.0 - */ - F1: 112, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F2 - * @type {integer} - * @since 3.0.0 - */ - F2: 113, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F3 - * @type {integer} - * @since 3.0.0 - */ - F3: 114, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F4 - * @type {integer} - * @since 3.0.0 - */ - F4: 115, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F5 - * @type {integer} - * @since 3.0.0 - */ - F5: 116, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F6 - * @type {integer} - * @since 3.0.0 - */ - F6: 117, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F7 - * @type {integer} - * @since 3.0.0 - */ - F7: 118, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F8 - * @type {integer} - * @since 3.0.0 - */ - F8: 119, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F9 - * @type {integer} - * @since 3.0.0 - */ - F9: 120, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F10 - * @type {integer} - * @since 3.0.0 - */ - F10: 121, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F11 - * @type {integer} - * @since 3.0.0 - */ - F11: 122, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F12 - * @type {integer} - * @since 3.0.0 - */ - F12: 123, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.SEMICOLON - * @type {integer} - * @since 3.0.0 - */ - SEMICOLON: 186, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PLUS - * @type {integer} - * @since 3.0.0 - */ - PLUS: 187, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.COMMA - * @type {integer} - * @since 3.0.0 - */ - COMMA: 188, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.MINUS - * @type {integer} - * @since 3.0.0 - */ - MINUS: 189, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PERIOD - * @type {integer} - * @since 3.0.0 - */ - PERIOD: 190, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.FORWARD_SLASH - * @type {integer} - * @since 3.0.0 - */ - FORWARD_SLASH: 191, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.BACK_SLASH - * @type {integer} - * @since 3.0.0 - */ - BACK_SLASH: 220, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.QUOTES - * @type {integer} - * @since 3.0.0 - */ - QUOTES: 222, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.BACKTICK - * @type {integer} - * @since 3.0.0 - */ - BACKTICK: 192, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.OPEN_BRACKET - * @type {integer} - * @since 3.0.0 - */ - OPEN_BRACKET: 219, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.CLOSED_BRACKET - * @type {integer} - * @since 3.0.0 - */ - CLOSED_BRACKET: 221 - -}; - - -/***/ }), -/* 130 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(83); -var GetPhysicsPlugins = __webpack_require__(530); -var GetScenePlugins = __webpack_require__(531); -var Plugins = __webpack_require__(236); -var Settings = __webpack_require__(255); - -/** - * @classdesc - * The Scene Systems class. - * - * This class is available from within a Scene under the property `sys`. - * It is responsible for managing all of the plugins a Scene has running, including the display list, and - * handling the update step and renderer. It also contains references to global systems belonging to Game. - * - * @class Systems - * @memberOf Phaser.Scenes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene that owns this Systems instance. - * @param {object} config - Scene specific configuration settings. - */ -var Systems = new Class({ - - initialize: - - function Systems (scene, config) - { - /** - * [description] - * - * @name Phaser.Scenes.Systems#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#config - * @type {object} - * @since 3.0.0 - */ - this.config = config; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#settings - * @type {[type]} - * @since 3.0.0 - */ - this.settings = Settings.create(config); - - /** - * A handy reference to the Scene canvas / context. - * - * @name Phaser.Scenes.Systems#canvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.canvas; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#context - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.context; - - // Global Systems - these are single-instance global managers that belong to Game - - /** - * [description] - * - * @name Phaser.Scenes.Systems#anims - * @type {Phaser.Animations.AnimationManager} - * @since 3.0.0 - */ - this.anims; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#cache - * @type {Phaser.Cache.CacheManager} - * @since 3.0.0 - */ - this.cache; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#plugins - * @type {Phaser.Plugins.PluginManager} - * @since 3.0.0 - */ - this.plugins; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#registry - * @type {[type]} - * @since 3.0.0 - */ - this.registry; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#sound - * @type {Phaser.Sound.BaseSoundManager} - * @since 3.0.0 - */ - this.sound; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#textures - * @type {Phaser.Textures.TextureManager} - * @since 3.0.0 - */ - this.textures; - - // Core Plugins - these are non-optional Scene plugins, needed by lots of the other systems - - /** - * [description] - * - * @name Phaser.Scenes.Systems#add - * @type {Phaser.GameObjects.GameObjectFactory} - * @since 3.0.0 - */ - this.add; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#cameras - * @type {Phaser.Cameras.Scene2D.CameraManager} - * @since 3.0.0 - */ - this.cameras; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#displayList - * @type {null} - * @since 3.0.0 - */ - this.displayList; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#events - * @type {EventEmitter} - * @since 3.0.0 - */ - this.events; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#make - * @type {Phaser.GameObjects.GameObjectCreator} - * @since 3.0.0 - */ - this.make; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#scenePlugin - * @type {Phaser.Scenes.ScenePlugin} - * @since 3.0.0 - */ - this.scenePlugin; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#updateList - * @type {[type]} - * @since 3.0.0 - */ - this.updateList; - }, - - /** - * [description] - * - * @method Phaser.Scenes.Systems#init - * @since 3.0.0 - * - * @param {Phaser.Game} game - A reference to the Phaser Game - */ - init: function (game) - { - this.settings.status = CONST.INIT; - - this.game = game; - - this.canvas = game.canvas; - this.context = game.context; - - var pluginManager = game.plugins; - - this.plugins = pluginManager; - - pluginManager.installGlobal(this, Plugins.Global); - - pluginManager.installLocal(this, Plugins.CoreScene); - - pluginManager.installLocal(this, GetScenePlugins(this)); - - pluginManager.installLocal(this, GetPhysicsPlugins(this)); - - this.events.emit('boot', this); - - this.settings.isBooted = true; - }, - - /** - * [description] - * - * @method Phaser.Scenes.Systems#install - * @private - * @since 3.0.0 - * - * @param {array} plugin - An array of plugins to install into this Scene. - */ - install: function (plugin) - { - if (!Array.isArray(plugin)) - { - plugin = [ plugin ]; - } - - this.plugins.installLocal(this, plugin); - }, - - /** - * [description] - * - * @method Phaser.Scenes.Systems#step - * @since 3.0.0 - * - * @param {number} time - [description] - * @param {number} delta - [description] - */ - step: function (time, delta) - { - this.events.emit('preupdate', time, delta); - - this.events.emit('update', time, delta); - - this.scene.update.call(this.scene, time, delta); - - this.events.emit('postupdate', time, delta); - }, - - /** - * [description] - * - * @method Phaser.Scenes.Systems#render - * @since 3.0.0 - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer} renderer - [description] - */ - render: function (renderer) - { - var displayList = this.displayList; - - displayList.depthSort(); - - this.cameras.render(renderer, displayList); - - this.events.emit('render', renderer); - }, - - /** - * Force a sort of the display list on the next render. - * - * @method Phaser.Scenes.Systems#queueDepthSort - * @since 3.0.0 - */ - queueDepthSort: function () - { - this.displayList.queueDepthSort(); - }, - - /** - * Immediately sorts the display list if the flag is set. - * - * @method Phaser.Scenes.Systems#depthSort - * @since 3.0.0 - */ - depthSort: function () - { - this.displayList.depthSort(); - }, - - /** - * Pause this Scene. - * A paused Scene still renders, it just doesn't run ANY of its update handlers or systems. - * - * @method Phaser.Scenes.Systems#pause - * @since 3.0.0 - * - * @return {Phaser.Scenes.Systems} This Systems object. - */ - pause: function () - { - if (this.settings.active) - { - this.settings.status = CONST.PAUSED; - - this.settings.active = false; - - this.events.emit('pause', this); - } - - return this; - }, - - /** - * Resume this Scene. - * - * @method Phaser.Scenes.Systems#resume - * @since 3.0.0 - * - * @return {Phaser.Scenes.Systems} This Systems object. - */ - resume: function () - { - if (!this.settings.active) - { - this.settings.status = CONST.RUNNING; - - this.settings.active = true; - - this.events.emit('resume', this); - } - - return this; - }, - - /** - * Send this Scene to sleep. - * - * A sleeping Scene doesn't run it's update step or render anything, but it also isn't destroyed, - * or have any of its systems or children removed, meaning it can be re-activated at any point. - * - * @method Phaser.Scenes.Systems#sleep - * @since 3.0.0 - * - * @return {Phaser.Scenes.Systems} This Systems object. - */ - sleep: function () - { - this.settings.status = CONST.SLEEPING; - - this.settings.active = false; - this.settings.visible = false; - - this.events.emit('sleep', this); - - return this; - }, - - /** - * Wake-up this Scene if it was previously asleep. - * - * @method Phaser.Scenes.Systems#wake - * @since 3.0.0 - * - * @return {Phaser.Scenes.Systems} This Systems object. - */ - wake: function () - { - this.settings.status = CONST.RUNNING; - - this.settings.active = true; - this.settings.visible = true; - - this.events.emit('wake', this); - - return this; - }, - - /** - * Is this Scene sleeping? - * - * @method Phaser.Scenes.Systems#isSleeping - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isSleeping: function () - { - return (this.settings.status === CONST.SLEEPING); - }, - - /** - * Is this Scene active? - * - * @method Phaser.Scenes.Systems#isActive - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isActive: function () - { - return (this.settings.status === CONST.RUNNING); - }, - - /** - * Is this Scene visible and rendering? - * - * @method Phaser.Scenes.Systems#isVisible - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isVisible: function () - { - return this.settings.visible; - }, - - /** - * [description] - * - * @method Phaser.Scenes.Systems#setVisible - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {Phaser.Scenes.Systems} This Systems object. - */ - setVisible: function (value) - { - this.settings.visible = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.Systems#setActive - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {Phaser.Scenes.Systems} This Systems object. - */ - setActive: function (value) - { - if (value) - { - return this.resume(); - } - else - { - return this.pause(); - } - }, - - /** - * Start this Scene running and rendering. - * - * @method Phaser.Scenes.Systems#start - * @since 3.0.0 - * - * @param {object} data - [description] - */ - start: function (data) - { - this.settings.status = CONST.START; - - this.settings.data = data; - - this.settings.active = true; - this.settings.visible = true; - - this.events.emit('start', this); - }, - - /** - * Called automatically by the SceneManager if the Game resizes. - * Dispatches an event you can respond to in your game code. - * - * @method Phaser.Scenes.Systems#resize - * @since 3.2.0 - * - * @param {number} width - The new width of the game. - * @param {number} height - The new height of the game. - */ - resize: function (width, height) - { - this.events.emit('resize', width, height); - }, - - /** - * Shutdown this Scene and send a shutdown event to all of its systems. - * - * @method Phaser.Scenes.Systems#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this.settings.status = CONST.SHUTDOWN; - - this.settings.active = false; - this.settings.visible = false; - - this.events.emit('shutdown', this); - }, - - /** - * Destroy this Scene and send a destroy event all of its systems. - * - * @method Phaser.Scenes.Systems#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.settings.status = CONST.DESTROYED; - - this.settings.active = false; - this.settings.visible = false; - - this.events.emit('destroy', this); - } - -}); - -module.exports = Systems; - - -/***/ }), -/* 131 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Extend = __webpack_require__(23); - -/** - * @classdesc - * A Frame is a section of a Texture. - * - * @class Frame - * @memberOf Phaser.Textures - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture this Frame is a part of. - * @param {integer|string} name - The name of this Frame. The name is unique within the Texture. - * @param {integer} sourceIndex - The index of the TextureSource that this Frame is a part of. - * @param {number} x - The x coordinate of the top-left of this Frame. - * @param {number} y - The y coordinate of the top-left of this Frame. - * @param {number} width - The width of this Frame. - * @param {number} height - The height of this Frame. - */ -var Frame = new Class({ - - initialize: - - function Frame (texture, name, sourceIndex, x, y, width, height) - { - /** - * The Texture this Frame is a part of. - * - * @name Phaser.Textures.Frame#texture - * @type {Phaser.Textures.Texture} - * @since 3.0.0 - */ - this.texture = texture; - - /** - * The name of this Frame. - * The name is unique within the Texture. - * - * @name Phaser.Textures.Frame#name - * @type {string} - * @since 3.0.0 - */ - this.name = name; - - /** - * The TextureSource this Frame is part of. - * - * @name Phaser.Textures.Frame#source - * @type {Phaser.Textures.TextureSource} - * @since 3.0.0 - */ - this.source = texture.source[sourceIndex]; - - /** - * The index of the TextureSource in the Texture sources array. - * - * @name Phaser.Textures.Frame#sourceIndex - * @type {integer} - * @since 3.0.0 - */ - this.sourceIndex = sourceIndex; - - /** - * X position within the source image to cut from. - * - * @name Phaser.Textures.Frame#cutX - * @type {integer} - * @since 3.0.0 - */ - this.cutX = x; - - /** - * Y position within the source image to cut from. - * - * @name Phaser.Textures.Frame#cutY - * @type {integer} - * @since 3.0.0 - */ - this.cutY = y; - - /** - * The width of the area in the source image to cut. - * - * @name Phaser.Textures.Frame#cutWidth - * @type {integer} - * @since 3.0.0 - */ - this.cutWidth = width; - - /** - * The height of the area in the source image to cut. - * - * @name Phaser.Textures.Frame#cutHeight - * @type {integer} - * @since 3.0.0 - */ - this.cutHeight = height; - - /** - * The X rendering offset of this Frame, taking trim into account. - * - * @name Phaser.Textures.Frame#x - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.x = 0; - - /** - * The Y rendering offset of this Frame, taking trim into account. - * - * @name Phaser.Textures.Frame#y - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.y = 0; - - /** - * The rendering width of this Frame, taking trim into account. - * - * @name Phaser.Textures.Frame#width - * @type {integer} - * @since 3.0.0 - */ - this.width = width; - - /** - * The rendering height of this Frame, taking trim into account. - * - * @name Phaser.Textures.Frame#height - * @type {integer} - * @since 3.0.0 - */ - this.height = height; - - /** - * Half the width, floored. - * Precalculated for the renderer. - * - * @name Phaser.Textures.Frame#halfWidth - * @type {integer} - * @since 3.0.0 - */ - this.halfWidth = Math.floor(width * 0.5); - - /** - * Half the height, floored. - * Precalculated for the renderer. - * - * @name Phaser.Textures.Frame#halfHeight - * @type {integer} - * @since 3.0.0 - */ - this.halfHeight = Math.floor(height * 0.5); - - /** - * The x center of this frame, floored. - * - * @name Phaser.Textures.Frame#centerX - * @type {integer} - * @since 3.0.0 - */ - this.centerX = Math.floor(width / 2); - - /** - * The y center of this frame, floored. - * - * @name Phaser.Textures.Frame#centerY - * @type {integer} - * @since 3.0.0 - */ - this.centerY = Math.floor(height / 2); - - /** - * The horizontal pivot point of this Frame. - * - * @name Phaser.Textures.Frame#pivotX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.pivotX = 0; - - /** - * The vertical pivot point of this Frame. - * - * @name Phaser.Textures.Frame#pivotY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.pivotY = 0; - - /** - * Does this Frame have a custom pivot point? - * - * @name Phaser.Textures.Frame#customPivot - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.customPivot = false; - - /** - * **CURRENTLY UNSUPPORTED** - * - * Is this frame is rotated or not in the Texture? - * Rotation allows you to use rotated frames in texture atlas packing. - * It has nothing to do with Sprite rotation. - * - * @name Phaser.Textures.Frame#rotated - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.rotated = false; - - /** - * Over-rides the Renderer setting. - * -1 = use Renderer Setting - * 0 = No rounding - * 1 = Round - * - * @name Phaser.Textures.Frame#autoRound - * @type {integer} - * @default -1 - * @since 3.0.0 - */ - this.autoRound = -1; - - /** - * Any Frame specific custom data can be stored here. - * - * @name Phaser.Textures.Frame#customData - * @type {object} - * @since 3.0.0 - */ - this.customData = {}; - - /** - * The un-modified source frame, trim and UV data. - * - * @name Phaser.Textures.Frame#data - * @type {object} - * @private - * @since 3.0.0 - */ - this.data = { - cut: { - x: x, - y: y, - w: width, - h: height, - r: x + width, - b: y + height - }, - trim: false, - sourceSize: { - w: width, - h: height - }, - spriteSourceSize: { - x: 0, - y: 0, - w: width, - h: height - }, - uvs: { - x0: 0, - y0: 0, - x1: 0, - y1: 0, - x2: 0, - y2: 0, - x3: 0, - y3: 0 - }, - radius: 0.5 * Math.sqrt(width * width + height * height), - drawImage: { - sx: x, - sy: y, - sWidth: width, - sHeight: height, - dWidth: width, - dHeight: height - } - }; - - this.updateUVs(); - }, - - /** - * If the frame was trimmed when added to the Texture Atlas, this records the trim and source data. - * - * @method Phaser.Textures.Frame#setTrim - * @since 3.0.0 - * - * @param {number} actualWidth - The width of the frame before being trimmed. - * @param {number} actualHeight - The height of the frame before being trimmed. - * @param {number} destX - The destination X position of the trimmed frame for display. - * @param {number} destY - The destination Y position of the trimmed frame for display. - * @param {number} destWidth - The destination width of the trimmed frame for display. - * @param {number} destHeight - The destination height of the trimmed frame for display. - * - * @return {Phaser.Textures.Frame} This Frame object. - */ - setTrim: function (actualWidth, actualHeight, destX, destY, destWidth, destHeight) - { - var data = this.data; - var ss = data.spriteSourceSize; - - // Store actual values - - data.trim = true; - - data.sourceSize.w = actualWidth; - data.sourceSize.h = actualHeight; - - ss.x = destX; - ss.y = destY; - ss.w = destWidth; - ss.h = destHeight; - - // Adjust properties - this.x = destX; - this.y = destY; - - this.width = destWidth; - this.height = destHeight; - - this.halfWidth = destWidth * 0.5; - this.halfHeight = destHeight * 0.5; - - this.centerX = Math.floor(destWidth / 2); - this.centerY = Math.floor(destHeight / 2); - - return this.updateUVs(); - }, - - /** - * Updates the internal WebGL UV cache and the drawImage cache. - * - * @method Phaser.Textures.Frame#updateUVs - * @since 3.0.0 - * - * @return {Phaser.Textures.Frame} This Frame object. - */ - updateUVs: function () - { - var cx = this.cutX; - var cy = this.cutY; - var cw = this.cutWidth; - var ch = this.cutHeight; - - // Canvas data - - var cd = this.data.drawImage; - - cd.sWidth = cw; - cd.sHeight = ch; - cd.dWidth = cw; - cd.dHeight = ch; - - // WebGL data - - var tw = this.source.width; - var th = this.source.height; - var uvs = this.data.uvs; - - uvs.x0 = cx / tw; - uvs.y0 = cy / th; - - uvs.x1 = cx / tw; - uvs.y1 = (cy + ch) / th; - - uvs.x2 = (cx + cw) / tw; - uvs.y2 = (cy + ch) / th; - - uvs.x3 = (cx + cw) / tw; - uvs.y3 = cy / th; - - return this; - }, - - /** - * Updates the internal WebGL UV cache. - * - * @method Phaser.Textures.Frame#updateUVsInverted - * @since 3.0.0 - * - * @return {Phaser.Textures.Frame} This Frame object. - */ - updateUVsInverted: function () - { - var tw = this.source.width; - var th = this.source.height; - var uvs = this.data.uvs; - - uvs.x3 = (this.cutX + this.cutHeight) / tw; - uvs.y3 = (this.cutY + this.cutWidth) / th; - - uvs.x2 = this.cutX / tw; - uvs.y2 = (this.cutY + this.cutWidth) / th; - - uvs.x1 = this.cutX / tw; - uvs.y1 = this.cutY / th; - - uvs.x0 = (this.cutX + this.cutHeight) / tw; - uvs.y0 = this.cutY / th; - - return this; - }, - - /** - * Clones this Frame into a new Frame object. - * - * @method Phaser.Textures.Frame#clone - * @since 3.0.0 - * - * @return {Phaser.Textures.Frame} A clone of this Frame. - */ - clone: function () - { - var clone = new Frame(this.texture, this.name, this.sourceIndex); - - clone.cutX = this.cutX; - clone.cutY = this.cutY; - clone.cutWidth = this.cutWidth; - clone.cutHeight = this.cutHeight; - - clone.x = this.x; - clone.y = this.y; - - clone.width = this.width; - clone.height = this.height; - - clone.halfWidth = this.halfWidth; - clone.halfHeight = this.halfHeight; - - clone.centerX = this.centerX; - clone.centerY = this.centerY; - - clone.rotated = this.rotated; - - clone.data = Extend(true, clone.data, this.data); - - clone.updateUVs(); - - return clone; - }, - - /** - * Destroys this Frames references. - * - * @method Phaser.Textures.Frame#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.texture = null; - - this.source = null; - }, - - /** - * The width of the Frame in its un-trimmed, un-padded state, as prepared in the art package, - * before being packed. - * - * @name Phaser.Textures.Frame#realWidth - * @type {number} - * @readOnly - * @since 3.0.0 - */ - realWidth: { - - get: function () - { - return this.data.sourceSize.w; - } - - }, - - /** - * The height of the Frame in its un-trimmed, un-padded state, as prepared in the art package, - * before being packed. - * - * @name Phaser.Textures.Frame#realHeight - * @type {number} - * @readOnly - * @since 3.0.0 - */ - realHeight: { - - get: function () - { - return this.data.sourceSize.h; - } - - }, - - /** - * The UV data for this Frame. - * - * @name Phaser.Textures.Frame#uvs - * @type {object} - * @readOnly - * @since 3.0.0 - */ - uvs: { - - get: function () - { - return this.data.uvs; - } - - }, - - /** - * The radius of the Frame (derived from sqrt(w * w + h * h) / 2) - * - * @name Phaser.Textures.Frame#radius - * @type {number} - * @readOnly - * @since 3.0.0 - */ - radius: { - - get: function () - { - return this.data.radius; - } - - }, - - /** - * Is the Frame trimmed or not? - * - * @name Phaser.Textures.Frame#trimmed - * @type {boolean} - * @readOnly - * @since 3.0.0 - */ - trimmed: { - - get: function () - { - return this.data.trim; - } - - }, - - /** - * The Canvas drawImage data object. - * - * @name Phaser.Textures.Frame#canvasData - * @type {object} - * @readOnly - * @since 3.0.0 - */ - canvasData: { - - get: function () - { - return this.data.drawImage; - } - - } - -}); - -module.exports = Frame; - - -/***/ }), -/* 132 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetAdvancedValue = __webpack_require__(10); - -/** - * Adds an Animation component to a Sprite and populates it based on the given config. - * - * @function Phaser.Gameobjects.BuildGameObjectAnimation - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Sprite} sprite - [description] - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Sprite} The updated Sprite. - */ -var BuildGameObjectAnimation = function (sprite, config) -{ - var animConfig = GetAdvancedValue(config, 'anims', null); - - if (animConfig === null) - { - return sprite; - } - - if (typeof animConfig === 'string') - { - // { anims: 'key' } - sprite.anims.play(animConfig); - } - else if (typeof animConfig === 'object') - { - // { anims: { - // key: string - // startFrame: [string|integer] - // delay: [float] - // repeat: [integer] - // repeatDelay: [float] - // yoyo: [boolean] - // play: [boolean] - // delayedPlay: [boolean] - // } - // } - - var anims = sprite.anims; - - var key = GetAdvancedValue(animConfig, 'key', undefined); - var startFrame = GetAdvancedValue(animConfig, 'startFrame', undefined); - - var delay = GetAdvancedValue(animConfig, 'delay', 0); - var repeat = GetAdvancedValue(animConfig, 'repeat', 0); - var repeatDelay = GetAdvancedValue(animConfig, 'repeatDelay', 0); - var yoyo = GetAdvancedValue(animConfig, 'yoyo', false); - - var play = GetAdvancedValue(animConfig, 'play', false); - var delayedPlay = GetAdvancedValue(animConfig, 'delayedPlay', 0); - - anims.delay(delay); - anims.repeat(repeat); - anims.repeatDelay(repeatDelay); - anims.yoyo(yoyo); - - if (play) - { - anims.play(key, startFrame); - } - else if (delayedPlay > 0) - { - anims.delayedPlay(delayedPlay, key, startFrame); - } - else - { - anims.load(key); - } - } - - return sprite; -}; - -module.exports = BuildGameObjectAnimation; - - -/***/ }), -/* 133 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var GameObject = __webpack_require__(1); -var GetBitmapTextSize = __webpack_require__(268); -var ParseFromAtlas = __webpack_require__(547); -var ParseRetroFont = __webpack_require__(548); -var Render = __webpack_require__(549); - -/** - * @classdesc - * [description] - * - * @class BitmapText - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * @extends Phaser.GameObjects.Components.ScrollFactor - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. - * @param {number} [x=0] - The x coordinate of this Game Object in world space. - * @param {number} [y=0] - The y coordinate of this Game Object in world space. - * @param {string} font - [description] - * @param {string|string[]} [text] - [description] - * @param {number} [size] - [description] - */ -var BitmapText = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.Texture, - Components.Tint, - Components.Transform, - Components.Visible, - Components.ScrollFactor, - Render - ], - - initialize: - - function BitmapText (scene, x, y, font, text, size) - { - if (text === undefined) { text = ''; } - - GameObject.call(this, scene, 'BitmapText'); - - /** - * [description] - * - * @name Phaser.GameObjects.BitmapText#font - * @type {string} - * @since 3.0.0 - */ - this.font = font; - - var entry = this.scene.sys.cache.bitmapFont.get(font); - - /** - * [description] - * - * @name Phaser.GameObjects.BitmapText#fontData - * @type {object} - * @since 3.0.0 - */ - this.fontData = entry.data; - - /** - * [description] - * - * @name Phaser.GameObjects.BitmapText#text - * @type {string} - * @since 3.0.0 - */ - this.text = (Array.isArray(text)) ? text.join('\n') : text; - - /** - * [description] - * - * @name Phaser.GameObjects.BitmapText#fontSize - * @type {number} - * @since 3.0.0 - */ - this.fontSize = size || this.fontData.size; - - this.setTexture(entry.texture, entry.frame); - this.setPosition(x, y); - this.setOrigin(0, 0); - this.initPipeline('TextureTintPipeline'); - - /** - * [description] - * - * @name Phaser.GameObjects.BitmapText#_bounds - * @type {object} - * @private - * @since 3.0.0 - */ - this._bounds = this.getTextBounds(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.BitmapText#setFontSize - * @since 3.0.0 - * - * @param {number} size - [description] - * - * @return {Phaser.GameObjects.BitmapText} This Game Object. - */ - setFontSize: function (size) - { - this.fontSize = size; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.BitmapText#setText - * @since 3.0.0 - * - * @param {string|string[]} value - The string, or array of strings, to be set as the content of this BitmapText. - * - * @return {Phaser.GameObjects.BitmapText} This Game Object. - */ - setText: function (value) - { - if (!value && value !== 0) - { - value = ''; - } - - if (Array.isArray(value)) - { - value = value.join('\n'); - } - - if (value !== this.text) - { - this.text = value.toString(); - - this.updateDisplayOrigin(); - } - - return this; - }, - - // { - // local: { - // x, - // y, - // width, - // height - // }, - // global: { - // x, - // y, - // width, - // height - // } - // } - - /** - * [description] - * - * @method Phaser.GameObjects.BitmapText#getTextBounds - * @since 3.0.0 - * - * @param {boolean} round - [description] - * - * @return {object} [description] - */ - getTextBounds: function (round) - { - // local = the BitmapText based on fontSize and 0x0 coords - // global = the BitmapText, taking into account scale and world position - - this._bounds = GetBitmapTextSize(this, round); - - return this._bounds; - }, - - /** - * [description] - * - * @name Phaser.GameObjects.BitmapText#width - * @type {number} - * @since 3.0.0 - */ - width: { - - get: function () - { - this.getTextBounds(false); - - return this._bounds.global.width; - } - - }, - - /** - * [description] - * - * @name Phaser.GameObjects.BitmapText#height - * @type {number} - * @since 3.0.0 - */ - height: { - - get: function () - { - this.getTextBounds(false); - - return this._bounds.global.height; - } - - }, - - /** - * [description] - * - * @method Phaser.GameObjects.BitmapText#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - var out = Components.ToJSON(this); - - // Extra data is added here - - var data = { - font: this.font, - text: this.text, - fontSize: this.fontSize - }; - - out.data = data; - - return out; - } - -}); - -BitmapText.ParseRetroFont = ParseRetroFont; -BitmapText.ParseFromAtlas = ParseFromAtlas; - -module.exports = BitmapText; - - -/***/ }), -/* 134 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BlitterRender = __webpack_require__(552); -var Bob = __webpack_require__(555); -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var Frame = __webpack_require__(131); -var GameObject = __webpack_require__(1); -var List = __webpack_require__(86); - -/** - * @classdesc - * A Blitter Game Object. - * - * The Blitter Game Object is a special kind of container that creates, updates and manages Bob objects. - * Bobs are designed for rendering speed rather than flexibility. They consist of a texture, or frame from a texture, - * a position and an alpha value. You cannot scale or rotate them. They use a batched drawing method for speed - * during rendering. - * - * A Blitter Game Object has one texture bound to it. Bobs created by the Blitter can use any Frame from this - * Texture to render with, but they cannot use any other Texture. It is this single texture-bind that allows - * them their speed. - * - * If you have a need to blast a large volume of frames around the screen then Blitter objects are well worth - * investigating. They are especially useful for using as a base for your own special effects systems. - * - * @class Blitter - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. - * @param {number} [x=0] - The x coordinate of this Game Object in world space. - * @param {number} [y=0] - The y coordinate of this Game Object in world space. - * @param {string} [texture='__DEFAULT'] - The key of the texture this Game Object will use for rendering. The Texture must already exist in the Texture Manager. - * @param {string|integer} [frame=0] - The Frame of the Texture that this Game Object will use. Only set if the Texture has multiple frames, such as a Texture Atlas or Sprite Sheet. - */ -var Blitter = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Size, - Components.Texture, - Components.Transform, - Components.Visible, - BlitterRender - ], - - initialize: - - function Blitter (scene, x, y, texture, frame) - { - GameObject.call(this, scene, 'Blitter'); - - this.setTexture(texture, frame); - this.setPosition(x, y); - this.initPipeline('TextureTintPipeline'); - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter#children - * @type {Phaser.Structs.List} - * @since 3.0.0 - */ - this.children = new List(); - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter#renderList - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.renderList = []; - - this.dirty = false; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter#create - * @since 3.0.0 - * - * @param {number} x - The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. - * @param {number} y - The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. - * @param {string|integer|Phaser.Textures.Frame} [frame] - The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. - * @param {boolean} [visible=true] - Should the created Bob render or not? - * @param {integer} [index] - The position in the Blitters Display List to add the new Bob at. Defaults to the top of the list. - * - * @return {Phaser.GameObjects.Blitter.Bob} The newly created Bob object. - */ - create: function (x, y, frame, visible, index) - { - if (visible === undefined) { visible = true; } - if (index === undefined) { index = this.children.length; } - - if (frame === undefined) - { - frame = this.frame; - } - else if (!(frame instanceof Frame)) - { - frame = this.texture.get(frame); - } - - var bob = new Bob(this, x, y, frame, visible); - - this.children.addAt(bob, index, false); - - this.dirty = true; - - return bob; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter#createFromCallback - * @since 3.0.0 - * - * @param {function} callback - The callback to invoke after creating a bob. It will be sent two arguments: The Bob and the index of the Bob. - * @param {integer} quantity - The quantity of Bob objects to create. - * @param {string} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture. - * @param {boolean} [visible=true] - [description] - * - * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that were created. - */ - createFromCallback: function (callback, quantity, frame, visible) - { - var bobs = this.createMultiple(quantity, frame, visible); - - for (var i = 0; i < bobs.length; i++) - { - var bob = bobs[i]; - - callback.call(this, bob, i); - } - - return bobs; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter#createMultiple - * @since 3.0.0 - * - * @param {integer} quantity - The quantity of Bob objects to create. - * @param {string} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture. - * @param {boolean} [visible=true] - [description] - * - * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that were created. - */ - createMultiple: function (quantity, frame, visible) - { - if (frame === undefined) { frame = this.frame.name; } - if (visible === undefined) { visible = true; } - - if (!Array.isArray(frame)) - { - frame = [ frame ]; - } - - var bobs = []; - var _this = this; - - frame.forEach(function (singleFrame) - { - for (var i = 0; i < quantity; i++) - { - bobs.push(_this.create(0, 0, singleFrame, visible)); - } - }); - - return bobs; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter#childCanRender - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter.Bob} child - [description] - * - * @return {boolean} [description] - */ - childCanRender: function (child) - { - return (child.visible && child.alpha > 0); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter#getRenderList - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that will be rendered this frame. - */ - getRenderList: function () - { - if (this.dirty) - { - this.renderList = this.children.list.filter(this.childCanRender, this); - this.dirty = false; - } - - return this.renderList; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter#clear - * @since 3.0.0 - */ - clear: function () - { - this.children.removeAll(); - this.dirty = true; - } - -}); - -module.exports = Blitter; - - -/***/ }), -/* 135 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var GameObject = __webpack_require__(1); -var GetBitmapTextSize = __webpack_require__(268); -var Render = __webpack_require__(556); - -/** - * @classdesc - * [description] - * - * @class DynamicBitmapText - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * @extends Phaser.GameObjects.Components.ScrollFactor - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. - * @param {number} [x=0] - The x coordinate of this Game Object in world space. - * @param {number} [y=0] - The y coordinate of this Game Object in world space. - * @param {string} font - [description] - * @param {string|string[]} [text] - [description] - * @param {number} [size] - [description] - */ -var DynamicBitmapText = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Origin, - Components.Pipeline, - Components.Texture, - Components.Tint, - Components.Transform, - Components.Visible, - Components.ScrollFactor, - Render - ], - - initialize: - - function DynamicBitmapText (scene, x, y, font, text, size) - { - if (text === undefined) { text = ''; } - - GameObject.call(this, scene, 'DynamicBitmapText'); - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#font - * @type {string} - * @since 3.0.0 - */ - this.font = font; - - var entry = this.scene.sys.cache.bitmapFont.get(font); - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#fontData - * @type {object} - * @since 3.0.0 - */ - this.fontData = entry.data; - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#text - * @type {string} - * @since 3.0.0 - */ - this.text = (Array.isArray(text)) ? text.join('\n') : text; - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#fontSize - * @type {number} - * @since 3.0.0 - */ - this.fontSize = size || this.fontData.size; - - this.setTexture(entry.texture, entry.frame); - this.setPosition(x, y); - this.setOrigin(0, 0); - this.initPipeline('TextureTintPipeline'); - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#_bounds - * @type {object} - * @private - * @since 3.0.0 - */ - this._bounds = this.getTextBounds(); - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#scrollX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.scrollX = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#scrollY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.scrollY = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#cropWidth - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.cropWidth = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#cropHeight - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.cropHeight = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#displayCallback; - * @type {function} - * @since 3.0.0 - */ - this.displayCallback; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.DynamicBitmapText#setSize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setSize: function (width, height) - { - this.cropWidth = width; - this.cropHeight = height; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.DynamicBitmapText#setDisplayCallback - * @since 3.0.0 - * - * @param {function} callback - [description] - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setDisplayCallback: function (callback) - { - this.displayCallback = callback; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.DynamicBitmapText#setFontSize - * @since 3.0.0 - * - * @param {number} size - [description] - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setFontSize: function (size) - { - this.fontSize = size; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.DynamicBitmapText#setText - * @since 3.0.0 - * - * @param {string|string[]} value - The string, or array of strings, to be set as the content of this BitmapText. - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setText: function (value) - { - if (!value && value !== 0) - { - value = ''; - } - - if (Array.isArray(value)) - { - value = value.join('\n'); - } - - if (value !== this.text) - { - this.text = value.toString(); - - this.updateDisplayOrigin(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.DynamicBitmapText#setScrollX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setScrollX: function (value) - { - this.scrollX = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.DynamicBitmapText#setScrollY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setScrollY: function (value) - { - this.scrollY = value; - - return this; - }, - - // { - // local: { - // x, - // y, - // width, - // height - // }, - // global: { - // x, - // y, - // width, - // height - // } - // } - - /** - * [description] - * - * @method Phaser.GameObjects.DynamicBitmapText#getTextBounds - * @since 3.0.0 - * - * @param {boolean} round - [description] - * - * @return {object} [description] - */ - getTextBounds: function (round) - { - // local = the BitmapText based on fontSize and 0x0 coords - // global = the BitmapText, taking into account scale and world position - - this._bounds = GetBitmapTextSize(this, round); - - return this._bounds; - }, - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#width - * @type {number} - * @since 3.0.0 - */ - width: { - - get: function () - { - this.getTextBounds(false); - return this._bounds.global.width; - } - - }, - - /** - * [description] - * - * @name Phaser.GameObjects.DynamicBitmapText#height - * @type {number} - * @since 3.0.0 - */ - height: { - - get: function () - { - this.getTextBounds(false); - return this._bounds.global.height; - } - - }, - - /** - * [description] - * - * @method Phaser.GameObjects.DynamicBitmapText#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - var out = Components.ToJSON(this); - - // Extra data is added here - - var data = { - font: this.font, - text: this.text, - fontSize: this.fontSize - }; - - out.data = data; - - return out; - } - -}); - -module.exports = DynamicBitmapText; - - -/***/ }), -/* 136 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Camera = __webpack_require__(115); -var Class = __webpack_require__(0); -var Commands = __webpack_require__(128); -var Components = __webpack_require__(11); -var Ellipse = __webpack_require__(270); -var GameObject = __webpack_require__(1); -var GetValue = __webpack_require__(4); -var MATH_CONST = __webpack_require__(16); -var Render = __webpack_require__(568); - -/** - * @classdesc - * [description] - * - * @class Graphics - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * @extends Phaser.GameObjects.Components.ScrollFactor - * - * @param {Phaser.Scene} scene - [description] - * @param {object} options - [description] - */ -var Graphics = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Pipeline, - Components.Transform, - Components.Visible, - Components.ScrollFactor, - Render - ], - - initialize: - - function Graphics (scene, options) - { - var x = GetValue(options, 'x', 0); - var y = GetValue(options, 'y', 0); - - GameObject.call(this, scene, 'Graphics'); - - this.setPosition(x, y); - this.initPipeline('FlatTintPipeline'); - - /** - * [description] - * - * @name Phaser.GameObjects.Graphics#displayOriginX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.displayOriginX = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Graphics#displayOriginY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.displayOriginY = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Graphics#commandBuffer - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.commandBuffer = []; - - /** - * [description] - * - * @name Phaser.GameObjects.Graphics#defaultFillColor - * @type {number} - * @default -1 - * @since 3.0.0 - */ - this.defaultFillColor = -1; - - /** - * [description] - * - * @name Phaser.GameObjects.Graphics#defaultFillAlpha - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.defaultFillAlpha = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Graphics#defaultStrokeWidth - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.defaultStrokeWidth = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Graphics#defaultStrokeColor - * @type {number} - * @default -1 - * @since 3.0.0 - */ - this.defaultStrokeColor = -1; - - /** - * [description] - * - * @name Phaser.GameObjects.Graphics#defaultStrokeAlpha - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.defaultStrokeAlpha = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Graphics#_lineWidth - * @type {number} - * @private - * @since 3.0.0 - */ - this._lineWidth = 1.0; - - this.setDefaultStyles(options); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#setDefaultStyles - * @since 3.0.0 - * - * @param {object} options - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - setDefaultStyles: function (options) - { - if (GetValue(options, 'lineStyle', null)) - { - this.defaultStrokeWidth = GetValue(options, 'lineStyle.width', 1); - this.defaultStrokeColor = GetValue(options, 'lineStyle.color', 0xffffff); - this.defaultStrokeAlpha = GetValue(options, 'lineStyle.alpha', 1); - - this.lineStyle(this.defaultStrokeWidth, this.defaultStrokeColor, this.defaultStrokeAlpha); - } - - if (GetValue(options, 'fillStyle', null)) - { - this.defaultFillColor = GetValue(options, 'fillStyle.color', 0xffffff); - this.defaultFillAlpha = GetValue(options, 'fillStyle.alpha', 1); - - this.fillStyle(this.defaultFillColor, this.defaultFillAlpha); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#lineStyle - * @since 3.0.0 - * - * @param {number} lineWidth - [description] - * @param {number} color - [description] - * @param {float} [alpha=1] - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - lineStyle: function (lineWidth, color, alpha) - { - if (alpha === undefined) { alpha = 1; } - - this.commandBuffer.push( - Commands.LINE_STYLE, - lineWidth, color, alpha - ); - - this._lineWidth = lineWidth; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillStyle - * @since 3.0.0 - * - * @param {number} color - [description] - * @param {float} [alpha=1] - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillStyle: function (color, alpha) - { - if (alpha === undefined) { alpha = 1; } - - this.commandBuffer.push( - Commands.FILL_STYLE, - color, alpha - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#beginPath - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - beginPath: function () - { - this.commandBuffer.push( - Commands.BEGIN_PATH - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#closePath - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - closePath: function () - { - this.commandBuffer.push( - Commands.CLOSE_PATH - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillPath - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillPath: function () - { - this.commandBuffer.push( - Commands.FILL_PATH - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#strokePath - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokePath: function () - { - this.commandBuffer.push( - Commands.STROKE_PATH - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillCircleShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillCircleShape: function (circle) - { - return this.fillCircle(circle.x, circle.y, circle.radius); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#strokeCircleShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeCircleShape: function (circle) - { - return this.strokeCircle(circle.x, circle.y, circle.radius); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillCircle - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} radius - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillCircle: function (x, y, radius) - { - this.beginPath(); - this.arc(x, y, radius, 0, MATH_CONST.PI2); - this.fillPath(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#strokeCircle - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} radius - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeCircle: function (x, y, radius) - { - this.beginPath(); - this.arc(x, y, radius, 0, MATH_CONST.PI2); - this.strokePath(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillRectShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillRectShape: function (rect) - { - return this.fillRect(rect.x, rect.y, rect.width, rect.height); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#strokeRectShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeRectShape: function (rect) - { - return this.strokeRect(rect.x, rect.y, rect.width, rect.height); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillRect - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillRect: function (x, y, width, height) - { - this.commandBuffer.push( - Commands.FILL_RECT, - x, y, width, height - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#strokeRect - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeRect: function (x, y, width, height) - { - var lineWidthHalf = this._lineWidth / 2; - var minx = x - lineWidthHalf; - var maxx = x + lineWidthHalf; - - this.beginPath(); - this.moveTo(x, y); - this.lineTo(x, y + height); - this.strokePath(); - - this.beginPath(); - this.moveTo(x + width, y); - this.lineTo(x + width, y + height); - this.strokePath(); - - this.beginPath(); - this.moveTo(minx, y); - this.lineTo(maxx + width, y); - this.strokePath(); - - this.beginPath(); - this.moveTo(minx, y + height); - this.lineTo(maxx + width, y + height); - this.strokePath(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillPointShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Point|Phaser.Math.Vector2|object} point - [description] - * @param {number} [size=1] - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillPointShape: function (point, size) - { - return this.fillPoint(point.x, point.y, size); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillPoint - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} [size=1] - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillPoint: function (x, y, size) - { - if (!size || size < 1) - { - size = 1; - } - else - { - x -= (size / 2); - y -= (size / 2); - } - - this.commandBuffer.push( - Commands.FILL_RECT, - x, y, size, size - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillTriangleShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillTriangleShape: function (triangle) - { - return this.fillTriangle(triangle.x1, triangle.y1, triangle.x2, triangle.y2, triangle.x3, triangle.y3); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#strokeTriangleShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeTriangleShape: function (triangle) - { - return this.strokeTriangle(triangle.x1, triangle.y1, triangle.x2, triangle.y2, triangle.x3, triangle.y3); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillTriangle - * @since 3.0.0 - * - * @param {number} x0 - [description] - * @param {number} y0 - [description] - * @param {number} x1 - [description] - * @param {number} y1 - [description] - * @param {number} x2 - [description] - * @param {number} y2 - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillTriangle: function (x0, y0, x1, y1, x2, y2) - { - this.commandBuffer.push( - Commands.FILL_TRIANGLE, - x0, y0, x1, y1, x2, y2 - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#strokeTriangle - * @since 3.0.0 - * - * @param {number} x0 - [description] - * @param {number} y0 - [description] - * @param {number} x1 - [description] - * @param {number} y1 - [description] - * @param {number} x2 - [description] - * @param {number} y2 - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeTriangle: function (x0, y0, x1, y1, x2, y2) - { - this.commandBuffer.push( - Commands.STROKE_TRIANGLE, - x0, y0, x1, y1, x2, y2 - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#strokeLineShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeLineShape: function (line) - { - return this.lineBetween(line.x1, line.y1, line.x2, line.y2); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#lineBetween - * @since 3.0.0 - * - * @param {number} x1 - [description] - * @param {number} y1 - [description] - * @param {number} x2 - [description] - * @param {number} y2 - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - lineBetween: function (x1, y1, x2, y2) - { - this.beginPath(); - this.moveTo(x1, y1); - this.lineTo(x2, y2); - this.strokePath(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#lineTo - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - lineTo: function (x, y) - { - this.commandBuffer.push( - Commands.LINE_TO, - x, y - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#moveTo - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - moveTo: function (x, y) - { - this.commandBuffer.push( - Commands.MOVE_TO, - x, y - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#lineFxTo - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} rgb - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - lineFxTo: function (x, y, width, rgb) - { - this.commandBuffer.push( - Commands.LINE_FX_TO, - x, y, width, rgb, 1 - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#moveFxTo - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} rgb - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - moveFxTo: function (x, y, width, rgb) - { - this.commandBuffer.push( - Commands.MOVE_FX_TO, - x, y, width, rgb, 1 - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#strokePoints - * @since 3.0.0 - * - * @param {array|Phaser.Geom.Point[]} points - [description] - * @param {boolean} [autoClose=false] - [description] - * @param {integer} [endIndex] - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokePoints: function (points, autoClose, endIndex) - { - if (autoClose === undefined) { autoClose = false; } - if (endIndex === undefined) { endIndex = points.length; } - - this.beginPath(); - - this.moveTo(points[0].x, points[0].y); - - for (var i = 1; i < endIndex; i++) - { - this.lineTo(points[i].x, points[i].y); - } - - if (autoClose) - { - this.lineTo(points[0].x, points[0].y); - } - - this.strokePath(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillPoints - * @since 3.0.0 - * - * @param {array|Phaser.Geom.Point[]} points - [description] - * @param {boolean} [autoClose=false] - [description] - * @param {integer} [endIndex] - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillPoints: function (points, autoClose, endIndex) - { - if (autoClose === undefined) { autoClose = false; } - if (endIndex === undefined) { endIndex = points.length; } - - this.beginPath(); - - this.moveTo(points[0].x, points[0].y); - - for (var i = 1; i < endIndex; i++) - { - this.lineTo(points[i].x, points[i].y); - } - - if (autoClose) - { - this.lineTo(points[0].x, points[0].y); - } - - this.fillPath(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#strokeEllipseShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - [description] - * @param {integer} [smoothness=32] - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeEllipseShape: function (ellipse, smoothness) - { - if (smoothness === undefined) { smoothness = 32; } - - var points = ellipse.getPoints(smoothness); - - return this.strokePoints(points, true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#strokeEllipse - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {integer} [smoothness=32] - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeEllipse: function (x, y, width, height, smoothness) - { - if (smoothness === undefined) { smoothness = 32; } - - var ellipse = new Ellipse(x, y, width, height); - - var points = ellipse.getPoints(smoothness); - - return this.strokePoints(points, true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillEllipseShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - [description] - * @param {integer} [smoothness=32] - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillEllipseShape: function (ellipse, smoothness) - { - if (smoothness === undefined) { smoothness = 32; } - - var points = ellipse.getPoints(smoothness); - - return this.fillPoints(points, true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#fillEllipse - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {integer} [smoothness=32] - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillEllipse: function (x, y, width, height, smoothness) - { - if (smoothness === undefined) { smoothness = 32; } - - var ellipse = new Ellipse(x, y, width, height); - - var points = ellipse.getPoints(smoothness); - - return this.fillPoints(points, true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#arc - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} radius - [description] - * @param {number} startAngle - [description] - * @param {number} endAngle - [description] - * @param {boolean} anticlockwise - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - arc: function (x, y, radius, startAngle, endAngle, anticlockwise) - { - this.commandBuffer.push( - Commands.ARC, - x, y, radius, startAngle, endAngle, anticlockwise - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#save - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - save: function () - { - this.commandBuffer.push( - Commands.SAVE - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#restore - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - restore: function () - { - this.commandBuffer.push( - Commands.RESTORE - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#translate - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - translate: function (x, y) - { - this.commandBuffer.push( - Commands.TRANSLATE, - x, y - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#scale - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - scale: function (x, y) - { - this.commandBuffer.push( - Commands.SCALE, - x, y - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#rotate - * @since 3.0.0 - * - * @param {number} radians - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - rotate: function (radians) - { - this.commandBuffer.push( - Commands.ROTATE, - radians - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#clear - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - clear: function () - { - this.commandBuffer.length = 0; - - if (this.defaultFillColor > -1) - { - this.fillStyle(this.defaultFillColor, this.defaultFillAlpha); - } - - if (this.defaultStrokeColor > -1) - { - this.lineStyle(this.defaultStrokeWidth, this.defaultStrokeColor, this.defaultStrokeAlpha); - } - - return this; - }, - - /** - * If key is a string it'll generate a new texture using it and add it into the - * Texture Manager (assuming no key conflict happens). - * - * If key is a Canvas it will draw the texture to that canvas context. Note that it will NOT - * automatically upload it to the GPU in WebGL mode. - * - * @method Phaser.GameObjects.Graphics#generateTexture - * @since 3.0.0 - * - * @param {string|HTMLCanvasElement} key - [description] - * @param {integer} [width] - [description] - * @param {integer} [height] - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - generateTexture: function (key, width, height) - { - var sys = this.scene.sys; - - if (width === undefined) { width = sys.game.config.width; } - if (height === undefined) { height = sys.game.config.height; } - - Graphics.TargetCamera.setViewport(0, 0, width, height); - Graphics.TargetCamera.scrollX = this.x; - Graphics.TargetCamera.scrollY = this.y; - - var texture; - var ctx; - - if (typeof key === 'string') - { - if (sys.textures.exists(key)) - { - // Key is a string, it DOES exist in the Texture Manager AND is a canvas, so draw to it - - texture = sys.textures.get(key); - - var src = texture.getSourceImage(); - - if (src instanceof HTMLCanvasElement) - { - ctx = src.getContext('2d'); - } - } - else - { - // Key is a string and doesn't exist in the Texture Manager, so generate and save it - - texture = sys.textures.createCanvas(key, width, height); - - ctx = texture.getSourceImage().getContext('2d'); - } - } - else if (key instanceof HTMLCanvasElement) - { - // Key is a Canvas, so draw to it - - ctx = key.getContext('2d'); - } - - if (ctx) - { - this.renderCanvas(sys.game.renderer, this, 0, Graphics.TargetCamera, ctx); - - if (sys.game.renderer.gl && texture) - { - texture.source[0].glTexture = sys.game.renderer.canvasToTexture(ctx.canvas, texture.source[0].glTexture, true, 0); - } - } - - return this; - } - -}); - -/** - * A Camera used specifically by the Graphics system for rendering to textures. - * - * @name Phaser.GameObjects.Graphics.TargetCamera - * @type {Phaser.Cameras.Scene2D.Camera} - * @since 3.1.0 - */ -Graphics.TargetCamera = new Camera(0, 0, 0, 0); - -module.exports = Graphics; - - -/***/ }), -/* 137 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Contains = __webpack_require__(68); -var GetPoint = __webpack_require__(271); -var GetPoints = __webpack_require__(272); -var Random = __webpack_require__(110); - -/** - * @classdesc - * An Ellipse object. - * - * This is a geometry object, containing numerical values and related methods to inspect and modify them. - * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. - * To render an Ellipse you should look at the capabilities of the Graphics class. - * - * @class Ellipse - * @memberOf Phaser.Geom - * @constructor - * @since 3.0.0 - * - * @param {number} [x=0] - The x position of the center of the ellipse. - * @param {number} [y=0] - The y position of the center of the ellipse. - * @param {number} [width=0] - The width of the ellipse. - * @param {number} [height=0] - The height of the ellipse. - */ -var Ellipse = new Class({ - - initialize: - - function Ellipse (x, y, width, height) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (width === undefined) { width = 0; } - if (height === undefined) { height = 0; } - - /** - * The x position of the center of the ellipse. - * - * @name Phaser.Geom.Ellipse#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x = x; - - /** - * The y position of the center of the ellipse. - * - * @name Phaser.Geom.Ellipse#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y = y; - - /** - * The width of the ellipse. - * - * @name Phaser.Geom.Ellipse#width - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.width = width; - - /** - * The height of the ellipse. - * - * @name Phaser.Geom.Ellipse#height - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.height = height; - }, - - /** - * Check to see if the Ellipse contains the given x / y coordinates. - * - * @method Phaser.Geom.Ellipse#contains - * @since 3.0.0 - * - * @param {number} x - The x coordinate to check within the ellipse. - * @param {number} y - The y coordinate to check within the ellipse. - * - * @return {boolean} True if the coordinates are within the ellipse, otherwise false. - */ - contains: function (x, y) - { - return Contains(this, x, y); - }, - - /** - * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse - * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point - * at 180 degrees around the circle. - * - * @method Phaser.Geom.Ellipse#getPoint - * @since 3.0.0 - * - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. - * @param {Phaser.Geom.Point|object} [out] - An object to store the return values in. If not given a Point object will be created. - * - * @return {Phaser.Geom.Point|object} A Point, or point-like object, containing the coordinates of the point around the ellipse. - */ - getPoint: function (position, point) - { - return GetPoint(this, position, point); - }, - - /** - * Returns an array of Point objects containing the coordinates of the points around the circumference of the Ellipse, - * based on the given quantity or stepRate values. - * - * @method Phaser.Geom.Ellipse#getPoints - * @since 3.0.0 - * - * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param {number} [stepRate] - Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate. - * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. - * - * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the circumference of the ellipse. - */ - getPoints: function (quantity, stepRate, output) - { - return GetPoints(this, quantity, stepRate, output); - }, - - /** - * Returns a uniformly distributed random point from anywhere within the given Ellipse. - * - * @method Phaser.Geom.Ellipse#getRandomPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Point|object} [point] - A Point or point-like object to set the random `x` and `y` values in. - * - * @return {Phaser.Geom.Point|object} A Point object with the random values set in the `x` and `y` properties. - */ - getRandomPoint: function (point) - { - return Random(this, point); - }, - - /** - * Sets the x, y, width and height of this ellipse. - * - * @method Phaser.Geom.Ellipse#setTo - * @since 3.0.0 - * - * @param {number} x - The x position of the center of the ellipse. - * @param {number} y - The y position of the center of the ellipse. - * @param {number} width - The width of the ellipse. - * @param {number} height - The height of the ellipse. - * - * @return {Phaser.Geom.Ellipse} This Ellipse object. - */ - setTo: function (x, y, width, height) - { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - - return this; - }, - - /** - * Sets this Ellipse to be empty with a width and height of zero. - * Does not change its position. - * - * @method Phaser.Geom.Ellipse#setEmpty - * @since 3.0.0 - * - * @return {Phaser.Geom.Ellipse} This Ellipse object. - */ - setEmpty: function () - { - this.width = 0; - this.height = 0; - - return this; - }, - - /** - * Sets the position of this Ellipse. - * - * @method Phaser.Geom.Ellipse#setPosition - * @since 3.0.0 - * - * @param {number} x - The x position of the center of the ellipse. - * @param {number} y - The y position of the center of the ellipse. - * - * @return {Phaser.Geom.Ellipse} This Ellipse object. - */ - setPosition: function (x, y) - { - if (y === undefined) { y = x; } - - this.x = x; - this.y = y; - - return this; - }, - - /** - * Sets the size of this Ellipse. - * Does not change its position. - * - * @method Phaser.Geom.Ellipse#setSize - * @since 3.0.0 - * - * @param {number} width - The width of the ellipse. - * @param {number} [height=width] - The height of the ellipse. - * - * @return {Phaser.Geom.Ellipse} This Ellipse object. - */ - setSize: function (width, height) - { - if (height === undefined) { height = width; } - - this.width = width; - this.height = height; - - return this; - }, - - /** - * Checks to see if the Ellipse is empty: has a width or height equal to zero. - * - * @method Phaser.Geom.Ellipse#isEmpty - * @since 3.0.0 - * - * @return {boolean} True if the Ellipse is empty, otherwise false. - */ - isEmpty: function () - { - return (this.width <= 0 || this.height <= 0); - }, - - /** - * Returns the minor radius of the ellipse. Also known as the Semi Minor Axis. - * - * @method Phaser.Geom.Ellipse#getMinorRadius - * @since 3.0.0 - * - * @return {number} The minor radius. - */ - getMinorRadius: function () - { - return Math.min(this.width, this.height) / 2; - }, - - /** - * Returns the major radius of the ellipse. Also known as the Semi Major Axis. - * - * @method Phaser.Geom.Ellipse#getMajorRadius - * @since 3.0.0 - * - * @return {number} The major radius. - */ - getMajorRadius: function () - { - return Math.max(this.width, this.height) / 2; - }, - - /** - * The left position of the Ellipse. - * - * @name Phaser.Geom.Ellipse#left - * @type {number} - * @since 3.0.0 - */ - left: { - - get: function () - { - return this.x - (this.width / 2); - }, - - set: function (value) - { - this.x = value + (this.width / 2); - } - - }, - - /** - * The right position of the Ellipse. - * - * @name Phaser.Geom.Ellipse#right - * @type {number} - * @since 3.0.0 - */ - right: { - - get: function () - { - return this.x + (this.width / 2); - }, - - set: function (value) - { - this.x = value - (this.width / 2); - } - - }, - - /** - * The top position of the Ellipse. - * - * @name Phaser.Geom.Ellipse#top - * @type {number} - * @since 3.0.0 - */ - top: { - - get: function () - { - return this.y - (this.height / 2); - }, - - set: function (value) - { - this.y = value + (this.height / 2); - } - - }, - - /** - * The bottom position of the Ellipse. - * - * @name Phaser.Geom.Ellipse#bottom - * @type {number} - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return this.y + (this.height / 2); - }, - - set: function (value) - { - this.y = value - (this.height / 2); - } - - } - -}); - -module.exports = Ellipse; - - -/***/ }), -/* 138 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse based on the given angle. - * - * @function Phaser.Geom.Ellipse.CircumferencePoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on. - * @param {number} angle - The angle from the center of the Ellipse to the circumference to return the point from. Given in radians. - * @param {Phaser.Geom.Point|object} [out] - A Point, or point-like object, to store the results in. If not given a Point will be created. - * - * @return {Phaser.Geom.Point|object} A Point object where the `x` and `y` properties are the point on the circumference. - */ -var CircumferencePoint = function (ellipse, angle, out) -{ - if (out === undefined) { out = new Point(); } - - var halfWidth = ellipse.width / 2; - var halfHeight = ellipse.height / 2; - - out.x = ellipse.x + halfWidth * Math.cos(angle); - out.y = ellipse.y + halfHeight * Math.sin(angle); - - return out; -}; - -module.exports = CircumferencePoint; - - -/***/ }), -/* 139 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var GameObject = __webpack_require__(1); -var GravityWell = __webpack_require__(573); -var List = __webpack_require__(86); -var ParticleEmitter = __webpack_require__(574); -var Render = __webpack_require__(613); - -/** - * @classdesc - * [description] - * - * @class ParticleEmitterManager - * @extends Phaser.GameObjects.Particles.GameObject - * @memberOf Phaser.GameObjects.Particles - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Particles.Components.Depth - * @extends Phaser.GameObjects.Particles.Components.Visible - * @extends Phaser.GameObjects.Particles.Components.Pipeline - * - * @param {Phaser.Scene} scene - [description] - * @param {string} texture - [description] - * @param {string|integer} frame - [description] - * @param {[type]} emitters - [description] - */ -var ParticleEmitterManager = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Depth, - Components.Visible, - Components.Pipeline, - Render - ], - - initialize: - - // frame is optional and can contain the emitters array or object if skipped - function ParticleEmitterManager (scene, texture, frame, emitters) - { - GameObject.call(this, scene, 'ParticleEmitterManager'); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#blendMode - * @type {number} - * @default -1 - * @private - * @since 3.0.0 - */ - this.blendMode = -1; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#timeScale - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#texture - * @type {Phaser.Textures.Texture} - * @default null - * @since 3.0.0 - */ - this.texture = null; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#frame - * @type {Phaser.Textures.Frame} - * @default null - * @since 3.0.0 - */ - this.frame = null; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#frameNames - * @type {array} - * @since 3.0.0 - */ - this.frameNames = []; - - // frame is optional and can contain the emitters array or object if skipped - if (frame !== null && (typeof frame === 'object' || Array.isArray(frame))) - { - emitters = frame; - frame = null; - } - - this.setTexture(texture, frame); - - this.initPipeline('TextureTintPipeline'); - - /** - * A list of Emitters being managed by this Emitter Manager. - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#emitters - * @type {Phaser.Structs.List} - * @since 3.0.0 - */ - this.emitters = new List(this); - - /** - * A list of Gravity Wells being managed by this Emitter Manager. - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#wells - * @type {Phaser.Structs.List} - * @since 3.0.0 - */ - this.wells = new List(this); - - if (emitters) - { - // An array of emitter configs? - if (!Array.isArray(emitters)) - { - emitters = [ emitters ]; - } - - for (var i = 0; i < emitters.length; i++) - { - this.createEmitter(emitters[i]); - } - } - }, - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setTexture - * @since 3.0.0 - * - * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. - * @param {string|integer} [frame] - The name or index of the frame within the Texture. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. - */ - setTexture: function (key, frame) - { - this.texture = this.scene.sys.textures.get(key); - - return this.setFrame(frame); - }, - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * It can be either a string or an index. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setFrame - * @since 3.0.0 - * - * @param {string|integer} [frame] - The name or index of the frame within the Texture. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. - */ - setFrame: function (frame) - { - this.frame = this.texture.get(frame); - - this.frameNames = this.texture.getFramesFromTextureSource(this.frame.sourceIndex); - - this.defaultFrame = this.frame; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setEmitterFrames - * @since 3.0.0 - * - * @param {[type]} frames - [description] - * @param {[type]} emitter - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. - */ - setEmitterFrames: function (frames, emitter) - { - if (!Array.isArray(frames)) - { - frames = [ frames ]; - } - - var out = emitter.frames; - - out.length = 0; - - for (var i = 0; i < frames.length; i++) - { - var frame = frames[i]; - - if (this.frameNames.indexOf(frame) !== -1) - { - out.push(this.texture.get(frame)); - } - } - - if (out.length > 0) - { - emitter.defaultFrame = out[0]; - } - else - { - emitter.defaultFrame = this.defaultFrame; - } - - return this; - }, - - /** - * Adds an existing Particle Emitter to this Manager. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#addEmitter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Particle Emitter to add to this Emitter Manager. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} The Particle Emitter that was added to this Emitter Manager. - */ - addEmitter: function (emitter) - { - return this.emitters.add(emitter); - }, - - /** - * Creates a new Particle Emitter object, adds it to this Manager and returns a reference to it. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#createEmitter - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} The Particle Emitter that was created. - */ - createEmitter: function (config) - { - return this.addEmitter(new ParticleEmitter(this, config)); - }, - - /** - * Adds an existing Gravity Well object to this Manager. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#addGravityWell - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.GravityWell} well - The Gravity Well to add to this Emitter Manager. - * - * @return {Phaser.GameObjects.Particles.GravityWell} The Gravity Well that was added to this Emitter Manager. - */ - addGravityWell: function (well) - { - return this.wells.add(well); - }, - - /** - * Creates a new Gravity Well, adds it to this Manager and returns a reference to it. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#createGravityWell - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Particles.GravityWell} The Gravity Well that was created. - */ - createGravityWell: function (config) - { - return this.addGravityWell(new GravityWell(config)); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#emitParticle - * @since 3.0.0 - * - * @param {integer} count - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. - */ - emitParticle: function (count, x, y) - { - var emitters = this.emitters.list; - - for (var i = 0; i < emitters.length; i++) - { - var emitter = emitters[i]; - - if (emitter.active) - { - emitter.emitParticle(count, x, y); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#emitParticleAt - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {integer} count - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. - */ - emitParticleAt: function (x, y, count) - { - return this.emitParticle(count, x, y); - }, - - /** - * Pauses this Emitter Manager. - * - * This has the effect of pausing all emitters, and all particles of those emitters, currently under its control. - * - * The particles will still render, but they will not have any of their logic updated. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#pause - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. - */ - pause: function () - { - this.active = false; - - return this; - }, - - /** - * Resumes this Emitter Manager, should it have been previously paused. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#resume - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. - */ - resume: function () - { - this.active = true; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#getProcessors - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getProcessors: function () - { - return this.wells.getAll('active', true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#preUpdate - * @since 3.0.0 - * - * @param {[type]} time - [description] - * @param {[type]} delta - [description] - */ - preUpdate: function (time, delta) - { - // Scale the delta - delta *= this.timeScale; - - var emitters = this.emitters.list; - - for (var i = 0; i < emitters.length; i++) - { - var emitter = emitters[i]; - - if (emitter.active) - { - emitter.preUpdate(time, delta); - } - } - } - -}); - -module.exports = ParticleEmitterManager; - - -/***/ }), -/* 140 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Utils.Array.GetRandomElement - * @since 3.0.0 - * - * @param {array} array - The array to select the random entry from. - * @param {integer} [start=0] - [description] - * @param {integer} [length=array.length] - [description] - * - * @return {object} A random element from the array, or `null` if no element could be found in the range given. - */ -var GetRandomElement = function (array, start, length) -{ - if (start === undefined) { start = 0; } - if (length === undefined) { length = array.length; } - - var randomIndex = start + Math.floor(Math.random() * length); - - return (array[randomIndex] === undefined) ? null : array[randomIndex]; -}; - -module.exports = GetRandomElement; - - -/***/ }), -/* 141 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CanvasPool = __webpack_require__(21); -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var CONST = __webpack_require__(19); -var GameObject = __webpack_require__(1); -var Render = __webpack_require__(616); -var RenderTextureCanvas = __webpack_require__(619); -var RenderTextureWebGL = __webpack_require__(620); - -/** - * @classdesc - * A Render Texture. - * - * @class RenderTexture - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.2.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.MatrixStack - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {integer} [width=32] - The width of the Render Texture. - * @param {integer} [height=32] - The height of the Render Texture. - */ -var RenderTexture = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.MatrixStack, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Size, - Components.Tint, - Components.Transform, - Components.Visible, - Render - ], - - initialize: - - function RenderTexture (scene, x, y, width, height) - { - if (width === undefined) { width = 32; } - if (height === undefined) { height = 32; } - - GameObject.call(this, scene, 'RenderTexture'); - - this.initMatrixStack(); - - this.renderer = scene.sys.game.renderer; - this.globalTint = 0xffffff; - this.globalAlpha = 1.0; - - if (this.renderer.type === CONST.WEBGL) - { - var gl = this.renderer.gl; - this.gl = gl; - this.fill = RenderTextureWebGL.fill; - this.clear = RenderTextureWebGL.clear; - this.draw = RenderTextureWebGL.draw; - this.drawFrame = RenderTextureWebGL.drawFrame; - this.texture = this.renderer.createTexture2D(0, gl.NEAREST, gl.NEAREST, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE, gl.RGBA, null, width, height, false); - this.framebuffer = this.renderer.createFramebuffer(width, height, this.texture, false); - } - else if (this.renderer.type === CONST.CANVAS) - { - this.fill = RenderTextureCanvas.fill; - this.clear = RenderTextureCanvas.clear; - this.draw = RenderTextureCanvas.draw; - this.drawFrame = RenderTextureCanvas.drawFrame; - this.canvas = CanvasPool.create2D(null, width, height); - this.context = this.canvas.getContext('2d'); - } - - this.setPosition(x, y); - this.setSize(width, height); - this.initPipeline('TextureTintPipeline'); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.RenderTexture#destroy - * @since 3.2.0 - */ - destroy: function () - { - GameObject.destroy.call(this); - - if (this.renderer.type === CONST.WEBGL) - { - this.renderer.deleteTexture(this.texture); - this.renderer.deleteFramebuffer(this.framebuffer); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.RenderTexture#setGlobalTint - * @since 3.2.0 - * - * @param {int} tint [description] - * - * @return {Phaser.GameObjects.RenderTexture} [description] - */ - setGlobalTint: function (tint) - { - this.globalTint = tint; - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.RenderTexture#setGlobalAlpha - * @since 3.2.0 - * - * @param {float} alpha [description] - * - * @return {Phaser.GameObjects.RenderTexture} [description] - */ - setGlobalAlpha: function (alpha) - { - this.globalAlpha = alpha; - return this; - } - - /** - * Fills the Render Texture with the given color. - * - * @method Phaser.GameObjects.RenderTexture#fill - * @since 3.2.0 - * - * @param {number} rgb - The color to fill the Render Texture with. - * - * @return {Phaser.GameObjects.RenderTexture} This Game Object. - */ - - /** - * Clears the Render Texture. - * - * @method Phaser.GameObjects.RenderTexture#clear - * @since 3.2.0 - * - * @return {Phaser.GameObjects.RenderTexture} This Game Object. - */ - - /** - * Draws a texture frame to the Render Texture at the given position. - * - * @method Phaser.GameObjects.RenderTexture#draw - * @since 3.2.0 - * - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * @param {number} x - The x position to draw the frame at. - * @param {number} y - The y position to draw the frame at. - * - * @return {Phaser.GameObjects.RenderTexture} This Game Object. - */ - -}); - -module.exports = RenderTexture; - - -/***/ }), -/* 142 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var AddToDOM = __webpack_require__(125); -var CanvasPool = __webpack_require__(21); -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var CONST = __webpack_require__(19); -var GameObject = __webpack_require__(1); -var GetTextSize = __webpack_require__(621); -var GetValue = __webpack_require__(4); -var RemoveFromDOM = __webpack_require__(234); -var TextRender = __webpack_require__(622); -var TextStyle = __webpack_require__(625); - -/** - * @classdesc - * [description] - * - * @class Text - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string|string[]} text - The text this Text object will display. - * @param {object} style - The text style configuration object. - */ -var Text = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Tint, - Components.Transform, - Components.Visible, - TextRender - ], - - initialize: - - function Text (scene, x, y, text, style) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - - GameObject.call(this, scene, 'Text'); - - this.setPosition(x, y); - this.setOrigin(0, 0); - this.initPipeline('TextureTintPipeline'); - - /** - * The canvas element that the text is rendered to. - * - * @name Phaser.GameObjects.Text#canvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.canvas = CanvasPool.create(this); - - /** - * The context of the canvas element that the text is rendered to. - * - * @name Phaser.GameObjects.Text#context - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.context = this.canvas.getContext('2d'); - - /** - * [description] - * - * @name Phaser.GameObjects.Text#style - * @type {Phaser.GameObjects.Components.TextStyle} - * @since 3.0.0 - */ - this.style = new TextStyle(this, style); - - /** - * [description] - * - * @name Phaser.GameObjects.Text#autoRound - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.autoRound = true; - - /** - * The Regular Expression that is used to split the text up into lines, in - * multi-line text. By default this is `/(?:\r\n|\r|\n)/`. - * You can change this RegExp to be anything else that you may need. - * - * @name Phaser.GameObjects.Text#splitRegExp - * @type {object} - * @since 3.0.0 - */ - this.splitRegExp = /(?:\r\n|\r|\n)/; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#text - * @type {string} - * @since 3.0.0 - */ - this.text = ''; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#resolution - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.resolution = 1; - - /** - * Specify a padding value which is added to the line width and height when calculating the Text size. - * Allows you to add extra spacing if the browser is unable to accurately determine the true font dimensions. - * - * @name Phaser.GameObjects.Text#padding - * @type {object} - * @since 3.0.0 - */ - this.padding = { left: 0, right: 0, top: 0, bottom: 0 }; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#width - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.width = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#height - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.height = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#canvasTexture - * @type {?[type]} - * @default null - * @since 3.0.0 - */ - this.canvasTexture = null; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#dirty - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.dirty = false; - - this.initRTL(); - - if (style && style.padding) - { - this.setPadding(style.padding); - } - - if (style && style.lineSpacing) - { - this._lineSpacing = style.lineSpacing; - } - - this.setText(text); - - if (scene.sys.game.config.renderType === CONST.WEBGL) - { - scene.sys.game.renderer.onContextRestored(function () - { - this.canvasTexture = null; - this.dirty = true; - }, this); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#initRTL - * @since 3.0.0 - */ - initRTL: function () - { - if (!this.style.rtl) - { - return; - } - - // Here is where the crazy starts. - // - // Due to browser implementation issues, you cannot fillText BiDi text to a canvas - // that is not part of the DOM. It just completely ignores the direction property. - - this.canvas.dir = 'rtl'; - - // Experimental atm, but one day ... - this.context.direction = 'rtl'; - - // Add it to the DOM, but hidden within the parent canvas. - this.canvas.style.display = 'none'; - - AddToDOM(this.canvas, this.scene.sys.canvas); - - // And finally we set the x origin - this.originX = 1; - }, - - /** - * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal - * bounds. - * - * @method Phaser.GameObjects.Text#runWordWrap - * @since 3.0.0 - * - * @param {string} text - The text to perform word wrap detection against. - * - * @return {string} The text after wrapping has been applied. - */ - runWordWrap: function (text) - { - var style = this.style; - - if (style.wordWrapCallback) - { - var wrappedLines = style.wordWrapCallback.call(style.wordWrapCallbackScope, text, this); - - if (Array.isArray(wrappedLines)) - { - wrappedLines = wrappedLines.join('\n'); - } - - return wrappedLines; - } - else if (style.wordWrapWidth) - { - if (style.wordWrapUseAdvanced) - { - return this.advancedWordWrap(text, this.context, this.style.wordWrapWidth); - } - else - { - return this.basicWordWrap(text, this.context, this.style.wordWrapWidth); - } - } - else - { - return text; - } - }, - - /** - * Advanced wrapping algorithm that will wrap words as the line grows longer than its horizontal - * bounds. Consecutive spaces will be collapsed and replaced with a single space. Lines will be - * trimmed of white space before processing. Throws an error if wordWrapWidth is less than a - * single character. - * - * @method Phaser.GameObjects.Text#advancedWordWrap - * @since 3.0.0 - * - * @param {string} text - The text to perform word wrap detection against. - * @param {CanvasRenderingContext2D} context - [description] - * @param {number} wordWrapWidth - [description] - * - * @return {string} The wrapped text. - */ - advancedWordWrap: function (text, context, wordWrapWidth) - { - var output = ''; - - // Condense consecutive spaces and split into lines - var lines = text - .replace(/ +/gi, ' ') - .split(this.splitRegExp); - - var linesCount = lines.length; - - for (var i = 0; i < linesCount; i++) - { - var line = lines[i]; - var out = ''; - - // Trim whitespace - line = line.replace(/^ *|\s*$/gi, ''); - - // If entire line is less than wordWrapWidth append the entire line and exit early - var lineWidth = context.measureText(line).width; - - if (lineWidth < wordWrapWidth) - { - output += line + '\n'; - continue; - } - - // Otherwise, calculate new lines - var currentLineWidth = wordWrapWidth; - - // Split into words - var words = line.split(' '); - - for (var j = 0; j < words.length; j++) - { - var word = words[j]; - var wordWithSpace = word + ' '; - var wordWidth = context.measureText(wordWithSpace).width; - - if (wordWidth > currentLineWidth) - { - // Break word - if (j === 0) - { - // Shave off letters from word until it's small enough - var newWord = wordWithSpace; - - while (newWord.length) - { - newWord = newWord.slice(0, -1); - wordWidth = context.measureText(newWord).width; - - if (wordWidth <= currentLineWidth) - { - break; - } - } - - // If wordWrapWidth is too small for even a single letter, shame user - // failure with a fatal error - if (!newWord.length) - { - throw new Error('This text\'s wordWrapWidth setting is less than a single character!'); - } - - // Replace current word in array with remainder - var secondPart = word.substr(newWord.length); - - words[j] = secondPart; - - // Append first piece to output - out += newWord; - } - - // If existing word length is 0, don't include it - var offset = (words[j].length) ? j : j + 1; - - // Collapse rest of sentence and remove any trailing white space - var remainder = words.slice(offset).join(' ') - .replace(/[ \n]*$/gi, ''); - - // Prepend remainder to next line - lines[i + 1] = remainder + ' ' + (lines[i + 1] || ''); - linesCount = lines.length; - - break; // Processing on this line - - // Append word with space to output - } - else - { - out += wordWithSpace; - currentLineWidth -= wordWidth; - } - } - - // Append processed line to output - output += out.replace(/[ \n]*$/gi, '') + '\n'; - } - - // Trim the end of the string - output = output.replace(/[\s|\n]*$/gi, ''); - - return output; - }, - - /** - * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal - * bounds. Spaces are not collapsed and whitespace is not trimmed. - * - * @method Phaser.GameObjects.Text#basicWordWrap - * @since 3.0.0 - * - * @param {string} text - The text to perform word wrap detection against. - * @param {CanvasRenderingContext2D} context - [description] - * @param {number} wordWrapWidth - [description] - * - * @return {string} The wrapped text. - */ - basicWordWrap: function (text, context, wordWrapWidth) - { - var result = ''; - var lines = text.split(this.splitRegExp); - - for (var i = 0; i < lines.length; i++) - { - var spaceLeft = wordWrapWidth; - var words = lines[i].split(' '); - - for (var j = 0; j < words.length; j++) - { - var wordWidth = context.measureText(words[j]).width; - var wordWidthWithSpace = wordWidth + context.measureText(' ').width; - - if (wordWidthWithSpace > spaceLeft) - { - // Skip printing the newline if it's the first word of the line that is greater - // than the word wrap width. - if (j > 0) - { - result += '\n'; - } - result += words[j] + ' '; - spaceLeft = wordWrapWidth - wordWidth; - } - else - { - spaceLeft -= wordWidthWithSpace; - result += words[j] + ' '; - } - } - - if (i < lines.length - 1) - { - result += '\n'; - } - } - - return result; - }, - - /** - * Runs the given text through this Text objects word wrapping and returns the results as an - * array, where each element of the array corresponds to a wrapped line of text. - * - * @method Phaser.GameObjects.Text#getWrappedText - * @since 3.0.0 - * - * @param {string} text - The text for which the wrapping will be calculated. If unspecified, the Text objects current text will be used. - * - * @return {string[]} An array of strings with the pieces of wrapped text. - */ - getWrappedText: function (text) - { - if (text === undefined) { text = this.text; } - - var wrappedLines = this.runWordWrap(text); - - return wrappedLines.split(this.splitRegExp); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setText - * @since 3.0.0 - * - * @param {string|string[]} value - The string, or array of strings, to be set as the content of this Text object. - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setText: function (value) - { - if (!value && value !== 0) - { - value = ''; - } - - if (Array.isArray(value)) - { - value = value.join('\n'); - } - - if (value !== this.text) - { - this.text = value.toString(); - - this.updateText(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setStyle - * @since 3.0.0 - * - * @param {object} style - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setStyle: function (style) - { - return this.style.setStyle(style); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFont - * @since 3.0.0 - * - * @param {string} font - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFont: function (font) - { - return this.style.setFont(font); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFontFamily - * @since 3.0.0 - * - * @param {string} family - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFontFamily: function (family) - { - return this.style.setFontFamily(family); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFontSize - * @since 3.0.0 - * - * @param {number} size - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFontSize: function (size) - { - return this.style.setFontSize(size); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFontStyle - * @since 3.0.0 - * - * @param {string} style - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFontStyle: function (style) - { - return this.style.setFontStyle(style); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFixedSize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFixedSize: function (width, height) - { - return this.style.setFixedSize(width, height); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setBackgroundColor - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setBackgroundColor: function (color) - { - return this.style.setBackgroundColor(color); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFill - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFill: function (color) - { - return this.style.setFill(color); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setColor - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setColor: function (color) - { - return this.style.setColor(color); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setStroke - * @since 3.0.0 - * - * @param {string} color - [description] - * @param {number} thickness - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setStroke: function (color, thickness) - { - return this.style.setStroke(color, thickness); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadow - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {string} color - [description] - * @param {number} blur - [description] - * @param {boolean} shadowStroke - [description] - * @param {boolean} shadowFill - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadow: function (x, y, color, blur, shadowStroke, shadowFill) - { - return this.style.setShadow(x, y, color, blur, shadowStroke, shadowFill); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowOffset - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowOffset: function (x, y) - { - return this.style.setShadowOffset(x, y); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowColor - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowColor: function (color) - { - return this.style.setShadowColor(color); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowBlur - * @since 3.0.0 - * - * @param {number} blur - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowBlur: function (blur) - { - return this.style.setShadowBlur(blur); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowStroke - * @since 3.0.0 - * - * @param {boolean} enabled - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowStroke: function (enabled) - { - return this.style.setShadowStroke(enabled); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowFill - * @since 3.0.0 - * - * @param {boolean} enabled - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowFill: function (enabled) - { - return this.style.setShadowFill(enabled); - }, - - /** - * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width. - * - * @method Phaser.GameObjects.Text#setWordWrapWidth - * @since 3.0.0 - * - * @param {number|null} width - The maximum width of a line in pixels. Set to null to remove wrapping. - * @param {boolean} [useAdvancedWrap=false] - Whether or not to use the advanced wrapping - * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, - * spaces and whitespace are left as is. - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setWordWrapWidth: function (width, useAdvancedWrap) - { - return this.style.setWordWrapWidth(width, useAdvancedWrap); - }, - - /** - * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback. - * - * @method Phaser.GameObjects.Text#setWordWrapCallback - * @since 3.0.0 - * - * @param {function} callback - A custom function that will be responsible for wrapping the - * text. It will receive two arguments: text (the string to wrap), textObject (this Text - * instance). It should return the wrapped lines either as an array of lines or as a string with - * newline characters in place to indicate where breaks should happen. - * @param {object} [scope=null] - The scope that will be applied when the callback is invoked. - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setWordWrapCallback: function (callback, scope) - { - return this.style.setWordWrapCallback(callback, scope); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setAlign - * @since 3.0.0 - * - * @param {string} align - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setAlign: function (align) - { - return this.style.setAlign(align); - }, - - /** - * 'left' can be an object. - * If only 'left' and 'top' are given they are treated as 'x' and 'y' - * - * @method Phaser.GameObjects.Text#setPadding - * @since 3.0.0 - * - * @param {number|object} left - [description] - * @param {number} top - [description] - * @param {number} right - [description] - * @param {number} bottom - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setPadding: function (left, top, right, bottom) - { - if (typeof left === 'object') - { - var config = left; - - // If they specify x and/or y this applies to all - var x = GetValue(config, 'x', null); - - if (x !== null) - { - left = x; - right = x; - } - else - { - left = GetValue(config, 'left', 0); - right = GetValue(config, 'right', left); - } - - var y = GetValue(config, 'y', null); - - if (y !== null) - { - top = y; - bottom = y; - } - else - { - top = GetValue(config, 'top', 0); - bottom = GetValue(config, 'bottom', top); - } - } - else - { - if (left === undefined) { left = 0; } - if (top === undefined) { top = left; } - if (right === undefined) { right = left; } - if (bottom === undefined) { bottom = top; } - } - - this.padding.left = left; - this.padding.top = top; - this.padding.right = right; - this.padding.bottom = bottom; - - return this.updateText(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setMaxLines - * @since 3.0.0 - * - * @param {integer} [max=0] - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setMaxLines: function (max) - { - return this.style.setMaxLines(max); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#updateText - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - updateText: function () - { - var canvas = this.canvas; - var context = this.context; - var style = this.style; - var resolution = this.resolution; - var size = style.metrics; - - style.syncFont(canvas, context); - - var outputText = this.text; - - if (style.wordWrapWidth || style.wordWrapCallback) - { - outputText = this.runWordWrap(this.text); - } - - // Split text into lines - var lines = outputText.split(this.splitRegExp); - - var textSize = GetTextSize(this, size, lines); - - var padding = this.padding; - - var w = textSize.width + padding.left + padding.right; - var h = textSize.height + padding.top + padding.bottom; - - if (style.fixedWidth === 0) - { - this.width = w; - } - - if (style.fixedHeight === 0) - { - this.height = h; - } - - this.updateDisplayOrigin(); - - w *= resolution; - h *= resolution; - - w = Math.max(w, 1); - h = Math.max(h, 1); - - if (canvas.width !== w || canvas.height !== h) - { - canvas.width = w; - canvas.height = h; - style.syncFont(canvas, context); // Resizing resets the context - } - else - { - context.clearRect(0, 0, w, h); - } - - context.save(); - - // context.scale(resolution, resolution); - - if (style.backgroundColor) - { - context.fillStyle = style.backgroundColor; - context.fillRect(0, 0, w, h); - } - - style.syncStyle(canvas, context); - - context.textBaseline = 'alphabetic'; - - // Apply padding - context.translate(padding.left, padding.top); - - var linePositionX; - var linePositionY; - - // Draw text line by line - for (var i = 0; i < textSize.lines; i++) - { - linePositionX = style.strokeThickness / 2; - linePositionY = (style.strokeThickness / 2 + i * textSize.lineHeight) + size.ascent; - - if (i > 0) - { - linePositionY += (textSize.lineSpacing * i); - } - - if (style.rtl) - { - linePositionX = w - linePositionX; - } - else if (style.align === 'right') - { - linePositionX += textSize.width - textSize.lineWidths[i]; - } - else if (style.align === 'center') - { - linePositionX += (textSize.width - textSize.lineWidths[i]) / 2; - } - - if (this.autoRound) - { - linePositionX = Math.round(linePositionX); - linePositionY = Math.round(linePositionY); - } - - if (style.strokeThickness) - { - this.style.syncShadow(context, style.shadowStroke); - - context.strokeText(lines[i], linePositionX, linePositionY); - } - - if (style.color) - { - this.style.syncShadow(context, style.shadowFill); - - context.fillText(lines[i], linePositionX, linePositionY); - } - } - - context.restore(); - - this.dirty = true; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#getTextMetrics - * @since 3.0.0 - * - * @return {object} [description] - */ - getTextMetrics: function () - { - return this.style.getTextMetrics(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - var out = Components.ToJSON(this); - - // Extra Text data is added here - - var data = { - autoRound: this.autoRound, - text: this.text, - style: this.style.toJSON(), - resolution: this.resolution, - padding: { - left: this.padding.left, - right: this.padding.right, - top: this.padding.top, - bottom: this.padding.bottom - } - }; - - out.data = data; - - return out; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#preDestroy - * @since 3.0.0 - */ - preDestroy: function () - { - if (this.style.rtl) - { - RemoveFromDOM(this.canvas); - } - - CanvasPool.remove(this.canvas); - } - -}); - -module.exports = Text; - - -/***/ }), -/* 143 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CanvasPool = __webpack_require__(21); -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var CONST = __webpack_require__(19); -var GameObject = __webpack_require__(1); -var GetPowerOfTwo = __webpack_require__(291); -var TileSpriteRender = __webpack_require__(627); - -/** - * @classdesc - * [description] - * - * @class TileSprite - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {number} width - The width of the Game Object. - * @param {number} height - The height of the Game Object. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var TileSprite = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Size, - Components.Texture, - Components.Tint, - Components.Transform, - Components.Visible, - TileSpriteRender - ], - - initialize: - - function TileSprite (scene, x, y, width, height, texture, frame) - { - var renderer = scene.sys.game.renderer; - - GameObject.call(this, scene, 'TileSprite'); - - /** - * [description] - * - * @name Phaser.GameObjects.TileSprite#tilePositionX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.tilePositionX = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.TileSprite#tilePositionY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.tilePositionY = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.TileSprite#dirty - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.dirty = true; - - /** - * [description] - * - * @name Phaser.GameObjects.TileSprite#tileTexture - * @type {?[type]} - * @default null - * @since 3.0.0 - */ - this.tileTexture = null; - - /** - * [description] - * - * @name Phaser.GameObjects.TileSprite#renderer - * @type {[type]} - * @since 3.0.0 - */ - this.renderer = renderer; - - this.setTexture(texture, frame); - this.setPosition(x, y); - this.setSize(width, height); - this.setOriginFromFrame(); - this.initPipeline('TextureTintPipeline'); - - /** - * The next power of two value from the width of the Frame. - * - * @name Phaser.GameObjects.TileSprite#potWidth - * @type {integer} - * @since 3.0.0 - */ - this.potWidth = GetPowerOfTwo(this.frame.width); - - /** - * The next power of two value from the height of the Frame. - * - * @name Phaser.GameObjects.TileSprite#potHeight - * @type {integer} - * @since 3.0.0 - */ - this.potHeight = GetPowerOfTwo(this.frame.height); - - /** - * [description] - * - * @name Phaser.GameObjects.TileSprite#canvasPattern - * @type {?CanvasPattern} - * @default null - * @since 3.0.0 - */ - this.canvasPattern = null; - - /** - * [description] - * - * @name Phaser.GameObjects.TileSprite#canvasBuffer - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.canvasBuffer = CanvasPool.create2D(null, this.potWidth, this.potHeight); - - /** - * [description] - * - * @name Phaser.GameObjects.TileSprite#canvasBufferCtx - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.canvasBufferCtx = this.canvasBuffer.getContext('2d'); - - this.oldFrame = null; - - this.updateTileTexture(); - - if (scene.sys.game.config.renderType === CONST.WEBGL) - { - scene.sys.game.renderer.onContextRestored(function (renderer) - { - var gl = renderer.gl; - - this.tileTexture = null; - this.dirty = true; - this.tileTexture = renderer.createTexture2D(0, gl.LINEAR, gl.LINEAR, gl.REPEAT, gl.REPEAT, gl.RGBA, this.canvasBuffer, this.potWidth, this.potHeight); - }, this); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.TileSprite#updateTileTexture - * @since 3.0.0 - */ - updateTileTexture: function () - { - if (!this.dirty && this.oldFrame === this.frame) - { - return; - } - - this.oldFrame = this.frame; - - this.canvasBufferCtx.clearRect(0, 0, this.canvasBuffer.width, this.canvasBuffer.height); - - if (this.renderer.gl) - { - this.canvasBufferCtx.drawImage( - this.frame.source.image, - this.frame.cutX, this.frame.cutY, - this.frame.cutWidth, this.frame.cutHeight, - 0, 0, - this.potWidth, this.potHeight - ); - - this.tileTexture = this.renderer.canvasToTexture(this.canvasBuffer, this.tileTexture, (this.tileTexture === null), this.scaleMode); - } - else - { - this.canvasBuffer.width = this.frame.cutWidth; - this.canvasBuffer.height = this.frame.cutHeight; - this.canvasBufferCtx.drawImage( - this.frame.source.image, - this.frame.cutX, this.frame.cutY, - this.frame.cutWidth, this.frame.cutHeight, - 0, 0, - this.frame.cutWidth, this.frame.cutHeight - ); - - this.canvasPattern = this.canvasBufferCtx.createPattern(this.canvasBuffer, 'repeat'); - } - - this.dirty = false; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.TileSprite#destroy - * @since 3.0.0 - */ - destroy: function () - { - if (this.renderer) - { - this.renderer.deleteTexture(this.tileTexture); - } - - CanvasPool.remove(this.canvasBuffer); - - this.canvasPattern = null; - this.canvasBufferCtx = null; - this.canvasBuffer = null; - - this.renderer = null; - this.visible = false; - } - -}); - -module.exports = TileSprite; - - -/***/ }), -/* 144 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Mesh = __webpack_require__(88); - -/** - * @classdesc - * A Quad Game Object. - * - * A Quad is a Mesh Game Object pre-configured with two triangles arranged into a rectangle, with a single - * texture spread across them. - * - * You can manipulate the corner points of the quad via the getters and setters such as `topLeftX`, and also - * change their alpha and color values. The quad itself can be moved by adjusting the `x` and `y` properties. - * - * @class Quad - * @extends Phaser.GameObjects.Mesh - * @memberOf Phaser.GameObjects - * @constructor - * @webglOnly - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var Quad = new Class({ - - Extends: Mesh, - - initialize: - - function Quad (scene, x, y, texture, frame) - { - // 0----3 - // |\ B| - // | \ | - // | \ | - // | A \| - // | \ - // 1----2 - - var vertices = [ - 0, 0, // tl - 0, 0, // bl - 0, 0, // br - 0, 0, // tl - 0, 0, // br - 0, 0 // tr - ]; - var uv = [ - 0, 0, // tl - 0, 1, // bl - 1, 1, // br - 0, 0, // tl - 1, 1, // br - 1, 0 // tr - ]; - var colors = [ - 0xffffff, // tl - 0xffffff, // bl - 0xffffff, // br - 0xffffff, // tl - 0xffffff, // br - 0xffffff // tr - ]; - var alphas = [ - 1, // tl - 1, // bl - 1, // br - 1, // tl - 1, // br - 1 // tr - ]; - - Mesh.call(this, scene, x, y, vertices, uv, colors, alphas, texture, frame); - - this.resetPosition(); - }, - - /** - * The top-left x vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#topLeftX - * @type {number} - * @since 3.0.0 - */ - topLeftX: { - - get: function () - { - return this.x + this.vertices[0]; - }, - - set: function (value) - { - this.vertices[0] = value - this.x; - this.vertices[6] = value - this.x; - } - - }, - - /** - * The top-left y vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#topLeftY - * @type {number} - * @since 3.0.0 - */ - topLeftY: { - - get: function () - { - return this.y + this.vertices[1]; - }, - - set: function (value) - { - this.vertices[1] = value - this.y; - this.vertices[7] = value - this.y; - } - - }, - - /** - * The top-right x vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#topRightX - * @type {number} - * @since 3.0.0 - */ - topRightX: { - - get: function () - { - return this.x + this.vertices[10]; - }, - - set: function (value) - { - this.vertices[10] = value - this.x; - } - - }, - - /** - * The top-right y vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#topRightY - * @type {number} - * @since 3.0.0 - */ - topRightY: { - - get: function () - { - return this.y + this.vertices[11]; - }, - - set: function (value) - { - this.vertices[11] = value - this.y; - } - - }, - - /** - * The bottom-left x vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomLeftX - * @type {number} - * @since 3.0.0 - */ - bottomLeftX: { - - get: function () - { - return this.x + this.vertices[2]; - }, - - set: function (value) - { - this.vertices[2] = value - this.x; - } - - }, - - /** - * The bottom-left y vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomLeftY - * @type {number} - * @since 3.0.0 - */ - bottomLeftY: { - - get: function () - { - return this.y + this.vertices[3]; - }, - - set: function (value) - { - this.vertices[3] = value - this.y; - } - - }, - - /** - * The bottom-right x vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomRightX - * @type {number} - * @since 3.0.0 - */ - bottomRightX: { - - get: function () - { - return this.x + this.vertices[4]; - }, - - set: function (value) - { - this.vertices[4] = value - this.x; - this.vertices[8] = value - this.x; - } - - }, - - /** - * The bottom-right y vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomRightY - * @type {number} - * @since 3.0.0 - */ - bottomRightY: { - - get: function () - { - return this.y + this.vertices[5]; - }, - - set: function (value) - { - this.vertices[5] = value - this.y; - this.vertices[9] = value - this.y; - } - - }, - - /** - * The top-left alpha value of this Quad. - * - * @name Phaser.GameObjects.Quad#topLeftAlpha - * @type {float} - * @since 3.0.0 - */ - topLeftAlpha: { - - get: function () - { - return this.alphas[0]; - }, - - set: function (value) - { - this.alphas[0] = value; - this.alphas[3] = value; - } - - }, - - /** - * The top-right alpha value of this Quad. - * - * @name Phaser.GameObjects.Quad#topRightAlpha - * @type {float} - * @since 3.0.0 - */ - topRightAlpha: { - - get: function () - { - return this.alphas[5]; - }, - - set: function (value) - { - this.alphas[5] = value; - } - - }, - - /** - * The bottom-left alpha value of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomLeftAlpha - * @type {float} - * @since 3.0.0 - */ - bottomLeftAlpha: { - - get: function () - { - return this.alphas[1]; - }, - - set: function (value) - { - this.alphas[1] = value; - } - - }, - - /** - * The bottom-right alpha value of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomRightAlpha - * @type {float} - * @since 3.0.0 - */ - bottomRightAlpha: { - - get: function () - { - return this.alphas[2]; - }, - - set: function (value) - { - this.alphas[2] = value; - this.alphas[4] = value; - } - - }, - - /** - * The top-left color value of this Quad. - * - * @name Phaser.GameObjects.Quad#topLeftColor - * @type {number} - * @since 3.0.0 - */ - topLeftColor: { - - get: function () - { - return this.colors[0]; - }, - - set: function (value) - { - this.colors[0] = value; - this.colors[3] = value; - } - - }, - - /** - * The top-right color value of this Quad. - * - * @name Phaser.GameObjects.Quad#topRightColor - * @type {number} - * @since 3.0.0 - */ - topRightColor: { - - get: function () - { - return this.colors[5]; - }, - - set: function (value) - { - this.colors[5] = value; - } - - }, - - /** - * The bottom-left color value of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomLeftColor - * @type {number} - * @since 3.0.0 - */ - bottomLeftColor: { - - get: function () - { - return this.colors[1]; - }, - - set: function (value) - { - this.colors[1] = value; - } - - }, - - /** - * The bottom-right color value of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomRightColor - * @type {number} - * @since 3.0.0 - */ - bottomRightColor: { - - get: function () - { - return this.colors[2]; - }, - - set: function (value) - { - this.colors[2] = value; - this.colors[4] = value; - } - - }, - - /** - * Sets the top-left vertex position of this Quad. - * - * @method Phaser.GameObjects.Quad#setTopLeft - * @since 3.0.0 - * - * @param {number} x - The horizontal coordinate of the vertex. - * @param {number} y - The vertical coordinate of the vertex. - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - setTopLeft: function (x, y) - { - this.topLeftX = x; - this.topLeftY = y; - - return this; - }, - - /** - * Sets the top-right vertex position of this Quad. - * - * @method Phaser.GameObjects.Quad#setTopRight - * @since 3.0.0 - * - * @param {number} x - The horizontal coordinate of the vertex. - * @param {number} y - The vertical coordinate of the vertex. - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - setTopRight: function (x, y) - { - this.topRightX = x; - this.topRightY = y; - - return this; - }, - - /** - * Sets the bottom-left vertex position of this Quad. - * - * @method Phaser.GameObjects.Quad#setBottomLeft - * @since 3.0.0 - * - * @param {number} x - The horizontal coordinate of the vertex. - * @param {number} y - The vertical coordinate of the vertex. - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - setBottomLeft: function (x, y) - { - this.bottomLeftX = x; - this.bottomLeftY = y; - - return this; - }, - - /** - * Sets the bottom-right vertex position of this Quad. - * - * @method Phaser.GameObjects.Quad#setBottomRight - * @since 3.0.0 - * - * @param {number} x - The horizontal coordinate of the vertex. - * @param {number} y - The vertical coordinate of the vertex. - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - setBottomRight: function (x, y) - { - this.bottomRightX = x; - this.bottomRightY = y; - - return this; - }, - - /** - * Resets the positions of the four corner vertices of this Quad. - * - * @method Phaser.GameObjects.Quad#resetPosition - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - resetPosition: function () - { - var x = this.x; - var y = this.y; - var halfWidth = Math.floor(this.width / 2); - var halfHeight = Math.floor(this.height / 2); - - this.setTopLeft(x - halfWidth, y - halfHeight); - this.setTopRight(x + halfWidth, y - halfHeight); - this.setBottomLeft(x - halfWidth, y + halfHeight); - this.setBottomRight(x + halfWidth, y + halfHeight); - - return this; - }, - - /** - * Resets the alpha values used by this Quad back to 1. - * - * @method Phaser.GameObjects.Quad#resetAlpha - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - resetAlpha: function () - { - var alphas = this.alphas; - - alphas[0] = 1; - alphas[1] = 1; - alphas[2] = 1; - alphas[3] = 1; - alphas[4] = 1; - alphas[5] = 1; - - return this; - }, - - /** - * Resets the color values used by this Quad back to 0xffffff. - * - * @method Phaser.GameObjects.Quad#resetColors - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - resetColors: function () - { - var colors = this.colors; - - colors[0] = 0xffffff; - colors[1] = 0xffffff; - colors[2] = 0xffffff; - colors[3] = 0xffffff; - colors[4] = 0xffffff; - colors[5] = 0xffffff; - - return this; - }, - - /** - * Resets the position, alpha and color values used by this Quad. - * - * @method Phaser.GameObjects.Quad#reset - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - reset: function () - { - this.resetPosition(); - - this.resetAlpha(); - - return this.resetColors(); - } - -}); - -module.exports = Quad; - - -/***/ }), -/* 145 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// http://www.blackpawn.com/texts/pointinpoly/ - -// points is an array of Point-like objects with public x/y properties -// returns an array containing all points that are within the triangle, or an empty array if none -// if 'returnFirst' is true it will return after the first point within the triangle is found - -/** - * [description] - * - * @function Phaser.Geom.Triangle.ContainsArray - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point[]} points - [description] - * @param {boolean} [returnFirst] - [description] - * @param {array} [out] - [description] - * - * @return {Phaser.Geom.Point[]} [description] - */ -var ContainsArray = function (triangle, points, returnFirst, out) -{ - if (returnFirst === undefined) { returnFirst = false; } - if (out === undefined) { out = []; } - - var v0x = triangle.x3 - triangle.x1; - var v0y = triangle.y3 - triangle.y1; - - var v1x = triangle.x2 - triangle.x1; - var v1y = triangle.y2 - triangle.y1; - - var dot00 = (v0x * v0x) + (v0y * v0y); - var dot01 = (v0x * v1x) + (v0y * v1y); - var dot11 = (v1x * v1x) + (v1y * v1y); - - // Compute barycentric coordinates - var b = ((dot00 * dot11) - (dot01 * dot01)); - var inv = (b === 0) ? 0 : (1 / b); - - var u; - var v; - var v2x; - var v2y; - var dot02; - var dot12; - - var x1 = triangle.x1; - var y1 = triangle.y1; - - for (var i = 0; i < points.length; i++) - { - v2x = points[i].x - x1; - v2y = points[i].y - y1; - - dot02 = (v0x * v2x) + (v0y * v2y); - dot12 = (v1x * v2x) + (v1y * v2y); - - u = ((dot11 * dot02) - (dot01 * dot12)) * inv; - v = ((dot00 * dot12) - (dot01 * dot02)) * inv; - - if (u >= 0 && v >= 0 && (u + v < 1)) - { - out.push({ x: points[i].x, y: points[i].y }); - - if (returnFirst) - { - break; - } - } - } - - return out; -}; - -module.exports = ContainsArray; - - -/***/ }), -/* 146 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.RotateAroundXY - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var RotateAroundXY = function (line, x, y, angle) -{ - var c = Math.cos(angle); - var s = Math.sin(angle); - - var tx = line.x1 - x; - var ty = line.y1 - y; - - line.x1 = tx * c - ty * s + x; - line.y1 = tx * s + ty * c + y; - - tx = line.x2 - x; - ty = line.y2 - y; - - line.x2 = tx * c - ty * s + x; - line.y2 = tx * s + ty * c + y; - - return line; -}; - -module.exports = RotateAroundXY; - - -/***/ }), -/* 147 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Checks whether the x and y coordinates are contained within this polygon. -// Adapted from http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html by Jonas Raoni Soares Silva - -/** - * [description] - * - * @function Phaser.Geom.Polygon.Contains - * @since 3.0.0 - * - * @param {Phaser.Geom.Polygon} polygon - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ -var Contains = function (polygon, x, y) -{ - var inside = false; - - for (var i = -1, j = polygon.points.length - 1; ++i < polygon.points.length; j = i) - { - var ix = polygon.points[i].x; - var iy = polygon.points[i].y; - - var jx = polygon.points[j].x; - var jy = polygon.points[j].y; - - if (((iy <= y && y < jy) || (jy <= y && y < iy)) && (x < (jx - ix) * (y - iy) / (jy - iy) + ix)) - { - inside = !inside; - } - } - - return inside; -}; - -module.exports = Contains; - - -/***/ }), -/* 148 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.GetAspectRatio - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {number} [description] - */ -var GetAspectRatio = function (rect) -{ - return (rect.height === 0) ? NaN : rect.width / rect.height; -}; - -module.exports = GetAspectRatio; - - -/***/ }), -/* 149 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Triangle.RotateAroundXY - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Triangle} [description] - */ -var RotateAroundXY = function (triangle, x, y, angle) -{ - var c = Math.cos(angle); - var s = Math.sin(angle); - - var tx = triangle.x1 - x; - var ty = triangle.y1 - y; - - triangle.x1 = tx * c - ty * s + x; - triangle.y1 = tx * s + ty * c + y; - - tx = triangle.x2 - x; - ty = triangle.y2 - y; - - triangle.x2 = tx * c - ty * s + x; - triangle.y2 = tx * s + ty * c + y; - - tx = triangle.x3 - x; - ty = triangle.y3 - y; - - triangle.x3 = tx * c - ty * s + x; - triangle.y3 = tx * s + ty * c + y; - - return triangle; -}; - -module.exports = RotateAroundXY; - - -/***/ }), -/* 150 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Given a File and a baseURL value this returns the URL the File will use to download from. - * - * @function Phaser.Loader.GetURL - * @since 3.0.0 - * - * @param {Phaser.Loader.File} file - The File object. - * @param {string} baseURL - A default base URL. - * - * @return {string} The URL the File will use. - */ -var GetURL = function (file, baseURL) -{ - if (!file.url) - { - return false; - } - - if (file.url.match(/^(?:blob:|data:|http:\/\/|https:\/\/|\/\/)/)) - { - return file.url; - } - else - { - return baseURL + file.url; - } -}; - -module.exports = GetURL; - - -/***/ }), -/* 151 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Extend = __webpack_require__(23); -var XHRSettings = __webpack_require__(90); - -/** - * Takes two XHRSettings Objects and creates a new XHRSettings object from them. - * - * The new object is seeded by the values given in the global settings, but any setting in - * the local object overrides the global ones. - * - * @function Phaser.Loader.MergeXHRSettings - * @since 3.0.0 - * - * @param {Phaser.Loader.XHRSettings} global - The global XHRSettings object. - * @param {Phaser.Loader.XHRSettings} local - The local XHRSettings object. - * - * @return {Phaser.Loader.XHRSettings} A newly formed XHRSettings object. - */ -var MergeXHRSettings = function (global, local) -{ - var output = (global === undefined) ? XHRSettings() : Extend({}, global); - - if (local) - { - for (var setting in local) - { - if (local[setting] !== undefined) - { - output[setting] = local[setting]; - } - } - } - - return output; -}; - -module.exports = MergeXHRSettings; - - -/***/ }), -/* 152 */ -/***/ (function(module, exports, __webpack_require__) { - /** * The `Matter.Composite` module contains methods for creating and manipulating composite bodies. * A composite body is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`, therefore composites form a tree structure. @@ -33165,9 +23189,9 @@ var Composite = {}; module.exports = Composite; -var Events = __webpack_require__(167); -var Common = __webpack_require__(38); -var Body = __webpack_require__(60); +var Events = __webpack_require__(171); +var Common = __webpack_require__(39); +var Body = __webpack_require__(49); (function() { @@ -33836,6 +23860,8459 @@ var Body = __webpack_require__(60); })(); +/***/ }), +/* 121 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Extend = __webpack_require__(18); +var XHRSettings = __webpack_require__(94); + +/** + * Takes two XHRSettings Objects and creates a new XHRSettings object from them. + * + * The new object is seeded by the values given in the global settings, but any setting in + * the local object overrides the global ones. + * + * @function Phaser.Loader.MergeXHRSettings + * @since 3.0.0 + * + * @param {XHRSettingsObject} global - The global XHRSettings object. + * @param {XHRSettingsObject} local - The local XHRSettings object. + * + * @return {XHRSettingsObject} A newly formed XHRSettings object. + */ +var MergeXHRSettings = function (global, local) +{ + var output = (global === undefined) ? XHRSettings() : Extend({}, global); + + if (local) + { + for (var setting in local) + { + if (local[setting] !== undefined) + { + output[setting] = local[setting]; + } + } + } + + return output; +}; + +module.exports = MergeXHRSettings; + + +/***/ }), +/* 122 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Given a File and a baseURL value this returns the URL the File will use to download from. + * + * @function Phaser.Loader.GetURL + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - The File object. + * @param {string} baseURL - A default base URL. + * + * @return {string} The URL the File will use. + */ +var GetURL = function (file, baseURL) +{ + if (!file.url) + { + return false; + } + + if (file.url.match(/^(?:blob:|data:|http:\/\/|https:\/\/|\/\/)/)) + { + return file.url; + } + else + { + return baseURL + file.url; + } +}; + +module.exports = GetURL; + + +/***/ }), +/* 123 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Triangle.RotateAroundXY + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} angle - [description] + * + * @return {Phaser.Geom.Triangle} [description] + */ +var RotateAroundXY = function (triangle, x, y, angle) +{ + var c = Math.cos(angle); + var s = Math.sin(angle); + + var tx = triangle.x1 - x; + var ty = triangle.y1 - y; + + triangle.x1 = tx * c - ty * s + x; + triangle.y1 = tx * s + ty * c + y; + + tx = triangle.x2 - x; + ty = triangle.y2 - y; + + triangle.x2 = tx * c - ty * s + x; + triangle.y2 = tx * s + ty * c + y; + + tx = triangle.x3 - x; + ty = triangle.y3 - y; + + triangle.x3 = tx * c - ty * s + x; + triangle.y3 = tx * s + ty * c + y; + + return triangle; +}; + +module.exports = RotateAroundXY; + + +/***/ }), +/* 124 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.GetAspectRatio + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {number} [description] + */ +var GetAspectRatio = function (rect) +{ + return (rect.height === 0) ? NaN : rect.width / rect.height; +}; + +module.exports = GetAspectRatio; + + +/***/ }), +/* 125 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Checks whether the x and y coordinates are contained within this polygon. +// Adapted from http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html by Jonas Raoni Soares Silva + +/** + * [description] + * + * @function Phaser.Geom.Polygon.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Polygon} polygon - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ +var Contains = function (polygon, x, y) +{ + var inside = false; + + for (var i = -1, j = polygon.points.length - 1; ++i < polygon.points.length; j = i) + { + var ix = polygon.points[i].x; + var iy = polygon.points[i].y; + + var jx = polygon.points[j].x; + var jy = polygon.points[j].y; + + if (((iy <= y && y < jy) || (jy <= y && y < iy)) && (x < (jx - ix) * (y - iy) / (jy - iy) + ix)) + { + inside = !inside; + } + } + + return inside; +}; + +module.exports = Contains; + + +/***/ }), +/* 126 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Line.RotateAroundXY + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} angle - [description] + * + * @return {Phaser.Geom.Line} [description] + */ +var RotateAroundXY = function (line, x, y, angle) +{ + var c = Math.cos(angle); + var s = Math.sin(angle); + + var tx = line.x1 - x; + var ty = line.y1 - y; + + line.x1 = tx * c - ty * s + x; + line.y1 = tx * s + ty * c + y; + + tx = line.x2 - x; + ty = line.y2 - y; + + line.x2 = tx * c - ty * s + x; + line.y2 = tx * s + ty * c + y; + + return line; +}; + +module.exports = RotateAroundXY; + + +/***/ }), +/* 127 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// http://www.blackpawn.com/texts/pointinpoly/ + +// points is an array of Point-like objects with public x/y properties +// returns an array containing all points that are within the triangle, or an empty array if none +// if 'returnFirst' is true it will return after the first point within the triangle is found + +/** + * [description] + * + * @function Phaser.Geom.Triangle.ContainsArray + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Point[]} points - [description] + * @param {boolean} [returnFirst] - [description] + * @param {array} [out] - [description] + * + * @return {Phaser.Geom.Point[]} [description] + */ +var ContainsArray = function (triangle, points, returnFirst, out) +{ + if (returnFirst === undefined) { returnFirst = false; } + if (out === undefined) { out = []; } + + var v0x = triangle.x3 - triangle.x1; + var v0y = triangle.y3 - triangle.y1; + + var v1x = triangle.x2 - triangle.x1; + var v1y = triangle.y2 - triangle.y1; + + var dot00 = (v0x * v0x) + (v0y * v0y); + var dot01 = (v0x * v1x) + (v0y * v1y); + var dot11 = (v1x * v1x) + (v1y * v1y); + + // Compute barycentric coordinates + var b = ((dot00 * dot11) - (dot01 * dot01)); + var inv = (b === 0) ? 0 : (1 / b); + + var u; + var v; + var v2x; + var v2y; + var dot02; + var dot12; + + var x1 = triangle.x1; + var y1 = triangle.y1; + + for (var i = 0; i < points.length; i++) + { + v2x = points[i].x - x1; + v2y = points[i].y - y1; + + dot02 = (v0x * v2x) + (v0y * v2y); + dot12 = (v1x * v2x) + (v1y * v2y); + + u = ((dot11 * dot02) - (dot01 * dot12)) * inv; + v = ((dot00 * dot12) - (dot01 * dot02)) * inv; + + if (u >= 0 && v >= 0 && (u + v < 1)) + { + out.push({ x: points[i].x, y: points[i].y }); + + if (returnFirst) + { + break; + } + } + } + + return out; +}; + +module.exports = ContainsArray; + + +/***/ }), +/* 128 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Mesh = __webpack_require__(96); + +/** + * @classdesc + * A Quad Game Object. + * + * A Quad is a Mesh Game Object pre-configured with two triangles arranged into a rectangle, with a single + * texture spread across them. + * + * You can manipulate the corner points of the quad via the getters and setters such as `topLeftX`, and also + * change their alpha and color values. The quad itself can be moved by adjusting the `x` and `y` properties. + * + * @class Quad + * @extends Phaser.GameObjects.Mesh + * @memberOf Phaser.GameObjects + * @constructor + * @webglOnly + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var Quad = new Class({ + + Extends: Mesh, + + initialize: + + function Quad (scene, x, y, texture, frame) + { + // 0----3 + // |\ B| + // | \ | + // | \ | + // | A \| + // | \ + // 1----2 + + var vertices = [ + 0, 0, // tl + 0, 0, // bl + 0, 0, // br + 0, 0, // tl + 0, 0, // br + 0, 0 // tr + ]; + var uv = [ + 0, 0, // tl + 0, 1, // bl + 1, 1, // br + 0, 0, // tl + 1, 1, // br + 1, 0 // tr + ]; + var colors = [ + 0xffffff, // tl + 0xffffff, // bl + 0xffffff, // br + 0xffffff, // tl + 0xffffff, // br + 0xffffff // tr + ]; + var alphas = [ + 1, // tl + 1, // bl + 1, // br + 1, // tl + 1, // br + 1 // tr + ]; + + Mesh.call(this, scene, x, y, vertices, uv, colors, alphas, texture, frame); + + this.resetPosition(); + }, + + /** + * The top-left x vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#topLeftX + * @type {number} + * @since 3.0.0 + */ + topLeftX: { + + get: function () + { + return this.x + this.vertices[0]; + }, + + set: function (value) + { + this.vertices[0] = value - this.x; + this.vertices[6] = value - this.x; + } + + }, + + /** + * The top-left y vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#topLeftY + * @type {number} + * @since 3.0.0 + */ + topLeftY: { + + get: function () + { + return this.y + this.vertices[1]; + }, + + set: function (value) + { + this.vertices[1] = value - this.y; + this.vertices[7] = value - this.y; + } + + }, + + /** + * The top-right x vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#topRightX + * @type {number} + * @since 3.0.0 + */ + topRightX: { + + get: function () + { + return this.x + this.vertices[10]; + }, + + set: function (value) + { + this.vertices[10] = value - this.x; + } + + }, + + /** + * The top-right y vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#topRightY + * @type {number} + * @since 3.0.0 + */ + topRightY: { + + get: function () + { + return this.y + this.vertices[11]; + }, + + set: function (value) + { + this.vertices[11] = value - this.y; + } + + }, + + /** + * The bottom-left x vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomLeftX + * @type {number} + * @since 3.0.0 + */ + bottomLeftX: { + + get: function () + { + return this.x + this.vertices[2]; + }, + + set: function (value) + { + this.vertices[2] = value - this.x; + } + + }, + + /** + * The bottom-left y vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomLeftY + * @type {number} + * @since 3.0.0 + */ + bottomLeftY: { + + get: function () + { + return this.y + this.vertices[3]; + }, + + set: function (value) + { + this.vertices[3] = value - this.y; + } + + }, + + /** + * The bottom-right x vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomRightX + * @type {number} + * @since 3.0.0 + */ + bottomRightX: { + + get: function () + { + return this.x + this.vertices[4]; + }, + + set: function (value) + { + this.vertices[4] = value - this.x; + this.vertices[8] = value - this.x; + } + + }, + + /** + * The bottom-right y vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomRightY + * @type {number} + * @since 3.0.0 + */ + bottomRightY: { + + get: function () + { + return this.y + this.vertices[5]; + }, + + set: function (value) + { + this.vertices[5] = value - this.y; + this.vertices[9] = value - this.y; + } + + }, + + /** + * The top-left alpha value of this Quad. + * + * @name Phaser.GameObjects.Quad#topLeftAlpha + * @type {float} + * @since 3.0.0 + */ + topLeftAlpha: { + + get: function () + { + return this.alphas[0]; + }, + + set: function (value) + { + this.alphas[0] = value; + this.alphas[3] = value; + } + + }, + + /** + * The top-right alpha value of this Quad. + * + * @name Phaser.GameObjects.Quad#topRightAlpha + * @type {float} + * @since 3.0.0 + */ + topRightAlpha: { + + get: function () + { + return this.alphas[5]; + }, + + set: function (value) + { + this.alphas[5] = value; + } + + }, + + /** + * The bottom-left alpha value of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomLeftAlpha + * @type {float} + * @since 3.0.0 + */ + bottomLeftAlpha: { + + get: function () + { + return this.alphas[1]; + }, + + set: function (value) + { + this.alphas[1] = value; + } + + }, + + /** + * The bottom-right alpha value of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomRightAlpha + * @type {float} + * @since 3.0.0 + */ + bottomRightAlpha: { + + get: function () + { + return this.alphas[2]; + }, + + set: function (value) + { + this.alphas[2] = value; + this.alphas[4] = value; + } + + }, + + /** + * The top-left color value of this Quad. + * + * @name Phaser.GameObjects.Quad#topLeftColor + * @type {number} + * @since 3.0.0 + */ + topLeftColor: { + + get: function () + { + return this.colors[0]; + }, + + set: function (value) + { + this.colors[0] = value; + this.colors[3] = value; + } + + }, + + /** + * The top-right color value of this Quad. + * + * @name Phaser.GameObjects.Quad#topRightColor + * @type {number} + * @since 3.0.0 + */ + topRightColor: { + + get: function () + { + return this.colors[5]; + }, + + set: function (value) + { + this.colors[5] = value; + } + + }, + + /** + * The bottom-left color value of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomLeftColor + * @type {number} + * @since 3.0.0 + */ + bottomLeftColor: { + + get: function () + { + return this.colors[1]; + }, + + set: function (value) + { + this.colors[1] = value; + } + + }, + + /** + * The bottom-right color value of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomRightColor + * @type {number} + * @since 3.0.0 + */ + bottomRightColor: { + + get: function () + { + return this.colors[2]; + }, + + set: function (value) + { + this.colors[2] = value; + this.colors[4] = value; + } + + }, + + /** + * Sets the top-left vertex position of this Quad. + * + * @method Phaser.GameObjects.Quad#setTopLeft + * @since 3.0.0 + * + * @param {number} x - The horizontal coordinate of the vertex. + * @param {number} y - The vertical coordinate of the vertex. + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + setTopLeft: function (x, y) + { + this.topLeftX = x; + this.topLeftY = y; + + return this; + }, + + /** + * Sets the top-right vertex position of this Quad. + * + * @method Phaser.GameObjects.Quad#setTopRight + * @since 3.0.0 + * + * @param {number} x - The horizontal coordinate of the vertex. + * @param {number} y - The vertical coordinate of the vertex. + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + setTopRight: function (x, y) + { + this.topRightX = x; + this.topRightY = y; + + return this; + }, + + /** + * Sets the bottom-left vertex position of this Quad. + * + * @method Phaser.GameObjects.Quad#setBottomLeft + * @since 3.0.0 + * + * @param {number} x - The horizontal coordinate of the vertex. + * @param {number} y - The vertical coordinate of the vertex. + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + setBottomLeft: function (x, y) + { + this.bottomLeftX = x; + this.bottomLeftY = y; + + return this; + }, + + /** + * Sets the bottom-right vertex position of this Quad. + * + * @method Phaser.GameObjects.Quad#setBottomRight + * @since 3.0.0 + * + * @param {number} x - The horizontal coordinate of the vertex. + * @param {number} y - The vertical coordinate of the vertex. + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + setBottomRight: function (x, y) + { + this.bottomRightX = x; + this.bottomRightY = y; + + return this; + }, + + /** + * Resets the positions of the four corner vertices of this Quad. + * + * @method Phaser.GameObjects.Quad#resetPosition + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + resetPosition: function () + { + var x = this.x; + var y = this.y; + var halfWidth = Math.floor(this.width / 2); + var halfHeight = Math.floor(this.height / 2); + + this.setTopLeft(x - halfWidth, y - halfHeight); + this.setTopRight(x + halfWidth, y - halfHeight); + this.setBottomLeft(x - halfWidth, y + halfHeight); + this.setBottomRight(x + halfWidth, y + halfHeight); + + return this; + }, + + /** + * Resets the alpha values used by this Quad back to 1. + * + * @method Phaser.GameObjects.Quad#resetAlpha + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + resetAlpha: function () + { + var alphas = this.alphas; + + alphas[0] = 1; + alphas[1] = 1; + alphas[2] = 1; + alphas[3] = 1; + alphas[4] = 1; + alphas[5] = 1; + + return this; + }, + + /** + * Resets the color values used by this Quad back to 0xffffff. + * + * @method Phaser.GameObjects.Quad#resetColors + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + resetColors: function () + { + var colors = this.colors; + + colors[0] = 0xffffff; + colors[1] = 0xffffff; + colors[2] = 0xffffff; + colors[3] = 0xffffff; + colors[4] = 0xffffff; + colors[5] = 0xffffff; + + return this; + }, + + /** + * Resets the position, alpha and color values used by this Quad. + * + * @method Phaser.GameObjects.Quad#reset + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + reset: function () + { + this.resetPosition(); + + this.resetAlpha(); + + return this.resetColors(); + } + +}); + +module.exports = Quad; + + +/***/ }), +/* 129 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasPool = __webpack_require__(23); +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var CONST = __webpack_require__(21); +var GameObject = __webpack_require__(1); +var GetPowerOfTwo = __webpack_require__(248); +var TileSpriteRender = __webpack_require__(700); + +/** + * @classdesc + * [description] + * + * @class TileSprite + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number} width - The width of the Game Object. + * @param {number} height - The height of the Game Object. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var TileSprite = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Size, + Components.Texture, + Components.Tint, + Components.Transform, + Components.Visible, + TileSpriteRender + ], + + initialize: + + function TileSprite (scene, x, y, width, height, texture, frame) + { + var renderer = scene.sys.game.renderer; + + GameObject.call(this, scene, 'TileSprite'); + + /** + * [description] + * + * @name Phaser.GameObjects.TileSprite#tilePositionX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.tilePositionX = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.TileSprite#tilePositionY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.tilePositionY = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.TileSprite#dirty + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.dirty = true; + + /** + * [description] + * + * @name Phaser.GameObjects.TileSprite#tileTexture + * @type {?WebGLTexture} + * @default null + * @since 3.0.0 + */ + this.tileTexture = null; + + /** + * [description] + * + * @name Phaser.GameObjects.TileSprite#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.0.0 + */ + this.renderer = renderer; + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.setSize(width, height); + this.setOriginFromFrame(); + this.initPipeline('TextureTintPipeline'); + + /** + * The next power of two value from the width of the Frame. + * + * @name Phaser.GameObjects.TileSprite#potWidth + * @type {integer} + * @since 3.0.0 + */ + this.potWidth = GetPowerOfTwo(this.frame.width); + + /** + * The next power of two value from the height of the Frame. + * + * @name Phaser.GameObjects.TileSprite#potHeight + * @type {integer} + * @since 3.0.0 + */ + this.potHeight = GetPowerOfTwo(this.frame.height); + + /** + * [description] + * + * @name Phaser.GameObjects.TileSprite#canvasPattern + * @type {?CanvasPattern} + * @default null + * @since 3.0.0 + */ + this.canvasPattern = null; + + /** + * [description] + * + * @name Phaser.GameObjects.TileSprite#canvasBuffer + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvasBuffer = CanvasPool.create2D(null, this.potWidth, this.potHeight); + + /** + * [description] + * + * @name Phaser.GameObjects.TileSprite#canvasBufferCtx + * @type {CanvasRenderingContext2D} + * @since 3.0.0 + */ + this.canvasBufferCtx = this.canvasBuffer.getContext('2d'); + + this.oldFrame = null; + + this.updateTileTexture(); + + if (scene.sys.game.config.renderType === CONST.WEBGL) + { + scene.sys.game.renderer.onContextRestored(function (renderer) + { + var gl = renderer.gl; + + this.tileTexture = null; + this.dirty = true; + this.tileTexture = renderer.createTexture2D(0, gl.LINEAR, gl.LINEAR, gl.REPEAT, gl.REPEAT, gl.RGBA, this.canvasBuffer, this.potWidth, this.potHeight); + }, this); + } + }, + + /** + * Sets {@link Phaser.GameObjects.TileSprite#tilePositionX} and {@link Phaser.GameObjects.TileSprite#tilePositionY}. + * + * @method Phaser.GameObjects.TileSprite#setTilePosition + * @since 3.3.0 + * + * @param {number} [x] - The x position of this sprite's tiling texture. + * @param {number} [y] - The y position of this sprite's tiling texture. + * + * @return {Phaser.GameObjects.TileSprite} This Tile Sprite instance. + */ + setTilePosition: function (x, y) + { + if (x !== undefined) + { + this.tilePositionX = x; + } + + if (y !== undefined) + { + this.tilePositionY = y; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.TileSprite#updateTileTexture + * @since 3.0.0 + */ + updateTileTexture: function () + { + if (!this.dirty && this.oldFrame === this.frame) + { + return; + } + + this.oldFrame = this.frame; + + this.canvasBufferCtx.clearRect(0, 0, this.canvasBuffer.width, this.canvasBuffer.height); + + if (this.renderer.gl) + { + this.canvasBufferCtx.drawImage( + this.frame.source.image, + this.frame.cutX, this.frame.cutY, + this.frame.cutWidth, this.frame.cutHeight, + 0, 0, + this.potWidth, this.potHeight + ); + + this.tileTexture = this.renderer.canvasToTexture(this.canvasBuffer, this.tileTexture, (this.tileTexture === null), this.scaleMode); + } + else + { + this.canvasBuffer.width = this.frame.cutWidth; + this.canvasBuffer.height = this.frame.cutHeight; + this.canvasBufferCtx.drawImage( + this.frame.source.image, + this.frame.cutX, this.frame.cutY, + this.frame.cutWidth, this.frame.cutHeight, + 0, 0, + this.frame.cutWidth, this.frame.cutHeight + ); + + this.canvasPattern = this.canvasBufferCtx.createPattern(this.canvasBuffer, 'repeat'); + } + + this.dirty = false; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.TileSprite#destroy + * @since 3.0.0 + */ + destroy: function () + { + if (this.renderer) + { + this.renderer.deleteTexture(this.tileTexture); + } + + CanvasPool.remove(this.canvasBuffer); + + this.canvasPattern = null; + this.canvasBufferCtx = null; + this.canvasBuffer = null; + + this.renderer = null; + this.visible = false; + } + +}); + +module.exports = TileSprite; + + +/***/ }), +/* 130 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var AddToDOM = __webpack_require__(147); +var CanvasPool = __webpack_require__(23); +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var CONST = __webpack_require__(21); +var GameObject = __webpack_require__(1); +var GetTextSize = __webpack_require__(706); +var GetValue = __webpack_require__(5); +var RemoveFromDOM = __webpack_require__(305); +var TextRender = __webpack_require__(705); +var TextStyle = __webpack_require__(702); + +/** + * @classdesc + * [description] + * + * @class Text + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {(string|string[])} text - The text this Text object will display. + * @param {object} style - The text style configuration object. + */ +var Text = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Tint, + Components.Transform, + Components.Visible, + TextRender + ], + + initialize: + + function Text (scene, x, y, text, style) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + GameObject.call(this, scene, 'Text'); + + this.setPosition(x, y); + this.setOrigin(0, 0); + this.initPipeline('TextureTintPipeline'); + + /** + * The canvas element that the text is rendered to. + * + * @name Phaser.GameObjects.Text#canvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvas = CanvasPool.create(this); + + /** + * The context of the canvas element that the text is rendered to. + * + * @name Phaser.GameObjects.Text#context + * @type {CanvasRenderingContext2D} + * @since 3.0.0 + */ + this.context = this.canvas.getContext('2d'); + + /** + * [description] + * + * @name Phaser.GameObjects.Text#style + * @type {Phaser.GameObjects.Components.TextStyle} + * @since 3.0.0 + */ + this.style = new TextStyle(this, style); + + /** + * [description] + * + * @name Phaser.GameObjects.Text#autoRound + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.autoRound = true; + + /** + * The Regular Expression that is used to split the text up into lines, in + * multi-line text. By default this is `/(?:\r\n|\r|\n)/`. + * You can change this RegExp to be anything else that you may need. + * + * @name Phaser.GameObjects.Text#splitRegExp + * @type {object} + * @since 3.0.0 + */ + this.splitRegExp = /(?:\r\n|\r|\n)/; + + /** + * [description] + * + * @name Phaser.GameObjects.Text#text + * @type {string} + * @since 3.0.0 + */ + this.text = ''; + + /** + * [description] + * + * @name Phaser.GameObjects.Text#resolution + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.resolution = 1; + + /** + * Specify a padding value which is added to the line width and height when calculating the Text size. + * Allows you to add extra spacing if the browser is unable to accurately determine the true font dimensions. + * + * @name Phaser.GameObjects.Text#padding + * @type {{left:number,right:number,top:number,bottom:number}} + * @since 3.0.0 + */ + this.padding = { left: 0, right: 0, top: 0, bottom: 0 }; + + /** + * [description] + * + * @name Phaser.GameObjects.Text#width + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.width = 1; + + /** + * [description] + * + * @name Phaser.GameObjects.Text#height + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.height = 1; + + /** + * [description] + * + * @name Phaser.GameObjects.Text#canvasTexture + * @type {HTMLCanvasElement} + * @default null + * @since 3.0.0 + */ + this.canvasTexture = null; + + /** + * [description] + * + * @name Phaser.GameObjects.Text#dirty + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.dirty = false; + + this.initRTL(); + + if (style && style.padding) + { + this.setPadding(style.padding); + } + + if (style && style.lineSpacing) + { + this._lineSpacing = style.lineSpacing; + } + + this.setText(text); + + if (scene.sys.game.config.renderType === CONST.WEBGL) + { + scene.sys.game.renderer.onContextRestored(function () + { + this.canvasTexture = null; + this.dirty = true; + }, this); + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#initRTL + * @since 3.0.0 + */ + initRTL: function () + { + if (!this.style.rtl) + { + return; + } + + // Here is where the crazy starts. + // + // Due to browser implementation issues, you cannot fillText BiDi text to a canvas + // that is not part of the DOM. It just completely ignores the direction property. + + this.canvas.dir = 'rtl'; + + // Experimental atm, but one day ... + this.context.direction = 'rtl'; + + // Add it to the DOM, but hidden within the parent canvas. + this.canvas.style.display = 'none'; + + AddToDOM(this.canvas, this.scene.sys.canvas); + + // And finally we set the x origin + this.originX = 1; + }, + + /** + * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal + * bounds. + * + * @method Phaser.GameObjects.Text#runWordWrap + * @since 3.0.0 + * + * @param {string} text - The text to perform word wrap detection against. + * + * @return {string} The text after wrapping has been applied. + */ + runWordWrap: function (text) + { + var style = this.style; + + if (style.wordWrapCallback) + { + var wrappedLines = style.wordWrapCallback.call(style.wordWrapCallbackScope, text, this); + + if (Array.isArray(wrappedLines)) + { + wrappedLines = wrappedLines.join('\n'); + } + + return wrappedLines; + } + else if (style.wordWrapWidth) + { + if (style.wordWrapUseAdvanced) + { + return this.advancedWordWrap(text, this.context, this.style.wordWrapWidth); + } + else + { + return this.basicWordWrap(text, this.context, this.style.wordWrapWidth); + } + } + else + { + return text; + } + }, + + /** + * Advanced wrapping algorithm that will wrap words as the line grows longer than its horizontal + * bounds. Consecutive spaces will be collapsed and replaced with a single space. Lines will be + * trimmed of white space before processing. Throws an error if wordWrapWidth is less than a + * single character. + * + * @method Phaser.GameObjects.Text#advancedWordWrap + * @since 3.0.0 + * + * @param {string} text - The text to perform word wrap detection against. + * @param {CanvasRenderingContext2D} context - [description] + * @param {number} wordWrapWidth - [description] + * + * @return {string} The wrapped text. + */ + advancedWordWrap: function (text, context, wordWrapWidth) + { + var output = ''; + + // Condense consecutive spaces and split into lines + var lines = text + .replace(/ +/gi, ' ') + .split(this.splitRegExp); + + var linesCount = lines.length; + + for (var i = 0; i < linesCount; i++) + { + var line = lines[i]; + var out = ''; + + // Trim whitespace + line = line.replace(/^ *|\s*$/gi, ''); + + // If entire line is less than wordWrapWidth append the entire line and exit early + var lineWidth = context.measureText(line).width; + + if (lineWidth < wordWrapWidth) + { + output += line + '\n'; + continue; + } + + // Otherwise, calculate new lines + var currentLineWidth = wordWrapWidth; + + // Split into words + var words = line.split(' '); + + for (var j = 0; j < words.length; j++) + { + var word = words[j]; + var wordWithSpace = word + ' '; + var wordWidth = context.measureText(wordWithSpace).width; + + if (wordWidth > currentLineWidth) + { + // Break word + if (j === 0) + { + // Shave off letters from word until it's small enough + var newWord = wordWithSpace; + + while (newWord.length) + { + newWord = newWord.slice(0, -1); + wordWidth = context.measureText(newWord).width; + + if (wordWidth <= currentLineWidth) + { + break; + } + } + + // If wordWrapWidth is too small for even a single letter, shame user + // failure with a fatal error + if (!newWord.length) + { + throw new Error('This text\'s wordWrapWidth setting is less than a single character!'); + } + + // Replace current word in array with remainder + var secondPart = word.substr(newWord.length); + + words[j] = secondPart; + + // Append first piece to output + out += newWord; + } + + // If existing word length is 0, don't include it + var offset = (words[j].length) ? j : j + 1; + + // Collapse rest of sentence and remove any trailing white space + var remainder = words.slice(offset).join(' ') + .replace(/[ \n]*$/gi, ''); + + // Prepend remainder to next line + lines[i + 1] = remainder + ' ' + (lines[i + 1] || ''); + linesCount = lines.length; + + break; // Processing on this line + + // Append word with space to output + } + else + { + out += wordWithSpace; + currentLineWidth -= wordWidth; + } + } + + // Append processed line to output + output += out.replace(/[ \n]*$/gi, '') + '\n'; + } + + // Trim the end of the string + output = output.replace(/[\s|\n]*$/gi, ''); + + return output; + }, + + /** + * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal + * bounds. Spaces are not collapsed and whitespace is not trimmed. + * + * @method Phaser.GameObjects.Text#basicWordWrap + * @since 3.0.0 + * + * @param {string} text - The text to perform word wrap detection against. + * @param {CanvasRenderingContext2D} context - [description] + * @param {number} wordWrapWidth - [description] + * + * @return {string} The wrapped text. + */ + basicWordWrap: function (text, context, wordWrapWidth) + { + var result = ''; + var lines = text.split(this.splitRegExp); + + for (var i = 0; i < lines.length; i++) + { + var spaceLeft = wordWrapWidth; + var words = lines[i].split(' '); + + for (var j = 0; j < words.length; j++) + { + var wordWidth = context.measureText(words[j]).width; + var wordWidthWithSpace = wordWidth + context.measureText(' ').width; + + if (wordWidthWithSpace > spaceLeft) + { + // Skip printing the newline if it's the first word of the line that is greater + // than the word wrap width. + if (j > 0) + { + result += '\n'; + } + result += words[j] + ' '; + spaceLeft = wordWrapWidth - wordWidth; + } + else + { + spaceLeft -= wordWidthWithSpace; + result += words[j] + ' '; + } + } + + if (i < lines.length - 1) + { + result += '\n'; + } + } + + return result; + }, + + /** + * Runs the given text through this Text objects word wrapping and returns the results as an + * array, where each element of the array corresponds to a wrapped line of text. + * + * @method Phaser.GameObjects.Text#getWrappedText + * @since 3.0.0 + * + * @param {string} text - The text for which the wrapping will be calculated. If unspecified, the Text objects current text will be used. + * + * @return {string[]} An array of strings with the pieces of wrapped text. + */ + getWrappedText: function (text) + { + if (text === undefined) { text = this.text; } + + this.style.syncFont(this.canvas, this.context); + + var wrappedLines = this.runWordWrap(text); + + return wrappedLines.split(this.splitRegExp); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setText + * @since 3.0.0 + * + * @param {(string|string[])} value - The string, or array of strings, to be set as the content of this Text object. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setText: function (value) + { + if (!value && value !== 0) + { + value = ''; + } + + if (Array.isArray(value)) + { + value = value.join('\n'); + } + + if (value !== this.text) + { + this.text = value.toString(); + + this.updateText(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setStyle + * @since 3.0.0 + * + * @param {object} style - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setStyle: function (style) + { + return this.style.setStyle(style); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setFont + * @since 3.0.0 + * + * @param {string} font - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFont: function (font) + { + return this.style.setFont(font); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setFontFamily + * @since 3.0.0 + * + * @param {string} family - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFontFamily: function (family) + { + return this.style.setFontFamily(family); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setFontSize + * @since 3.0.0 + * + * @param {number} size - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFontSize: function (size) + { + return this.style.setFontSize(size); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setFontStyle + * @since 3.0.0 + * + * @param {string} style - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFontStyle: function (style) + { + return this.style.setFontStyle(style); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setFixedSize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFixedSize: function (width, height) + { + return this.style.setFixedSize(width, height); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setBackgroundColor + * @since 3.0.0 + * + * @param {string} color - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setBackgroundColor: function (color) + { + return this.style.setBackgroundColor(color); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setFill + * @since 3.0.0 + * + * @param {string} color - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFill: function (color) + { + return this.style.setFill(color); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setColor + * @since 3.0.0 + * + * @param {string} color - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setColor: function (color) + { + return this.style.setColor(color); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setStroke + * @since 3.0.0 + * + * @param {string} color - [description] + * @param {number} thickness - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setStroke: function (color, thickness) + { + return this.style.setStroke(color, thickness); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setShadow + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {string} color - [description] + * @param {number} blur - [description] + * @param {boolean} shadowStroke - [description] + * @param {boolean} shadowFill - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadow: function (x, y, color, blur, shadowStroke, shadowFill) + { + return this.style.setShadow(x, y, color, blur, shadowStroke, shadowFill); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setShadowOffset + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowOffset: function (x, y) + { + return this.style.setShadowOffset(x, y); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setShadowColor + * @since 3.0.0 + * + * @param {string} color - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowColor: function (color) + { + return this.style.setShadowColor(color); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setShadowBlur + * @since 3.0.0 + * + * @param {number} blur - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowBlur: function (blur) + { + return this.style.setShadowBlur(blur); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setShadowStroke + * @since 3.0.0 + * + * @param {boolean} enabled - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowStroke: function (enabled) + { + return this.style.setShadowStroke(enabled); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setShadowFill + * @since 3.0.0 + * + * @param {boolean} enabled - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowFill: function (enabled) + { + return this.style.setShadowFill(enabled); + }, + + /** + * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width. + * + * @method Phaser.GameObjects.Text#setWordWrapWidth + * @since 3.0.0 + * + * @param {?number} width - The maximum width of a line in pixels. Set to null to remove wrapping. + * @param {boolean} [useAdvancedWrap=false] - Whether or not to use the advanced wrapping + * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, + * spaces and whitespace are left as is. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setWordWrapWidth: function (width, useAdvancedWrap) + { + return this.style.setWordWrapWidth(width, useAdvancedWrap); + }, + + /** + * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback. + * + * @method Phaser.GameObjects.Text#setWordWrapCallback + * @since 3.0.0 + * + * @param {TextStyleWordWrapCallback} callback - A custom function that will be responsible for wrapping the + * text. It will receive two arguments: text (the string to wrap), textObject (this Text + * instance). It should return the wrapped lines either as an array of lines or as a string with + * newline characters in place to indicate where breaks should happen. + * @param {object} [scope=null] - The scope that will be applied when the callback is invoked. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setWordWrapCallback: function (callback, scope) + { + return this.style.setWordWrapCallback(callback, scope); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setAlign + * @since 3.0.0 + * + * @param {string} align - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setAlign: function (align) + { + return this.style.setAlign(align); + }, + + /** + * 'left' can be an object. + * If only 'left' and 'top' are given they are treated as 'x' and 'y' + * + * @method Phaser.GameObjects.Text#setPadding + * @since 3.0.0 + * + * @param {(number|object)} left - [description] + * @param {number} top - [description] + * @param {number} right - [description] + * @param {number} bottom - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setPadding: function (left, top, right, bottom) + { + if (typeof left === 'object') + { + var config = left; + + // If they specify x and/or y this applies to all + var x = GetValue(config, 'x', null); + + if (x !== null) + { + left = x; + right = x; + } + else + { + left = GetValue(config, 'left', 0); + right = GetValue(config, 'right', left); + } + + var y = GetValue(config, 'y', null); + + if (y !== null) + { + top = y; + bottom = y; + } + else + { + top = GetValue(config, 'top', 0); + bottom = GetValue(config, 'bottom', top); + } + } + else + { + if (left === undefined) { left = 0; } + if (top === undefined) { top = left; } + if (right === undefined) { right = left; } + if (bottom === undefined) { bottom = top; } + } + + this.padding.left = left; + this.padding.top = top; + this.padding.right = right; + this.padding.bottom = bottom; + + return this.updateText(); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#setMaxLines + * @since 3.0.0 + * + * @param {integer} [max=0] - [description] + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setMaxLines: function (max) + { + return this.style.setMaxLines(max); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#updateText + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + updateText: function () + { + var canvas = this.canvas; + var context = this.context; + var style = this.style; + var resolution = this.resolution; + var size = style.metrics; + + style.syncFont(canvas, context); + + var outputText = this.text; + + if (style.wordWrapWidth || style.wordWrapCallback) + { + outputText = this.runWordWrap(this.text); + } + + // Split text into lines + var lines = outputText.split(this.splitRegExp); + + var textSize = GetTextSize(this, size, lines); + + var padding = this.padding; + + var w = textSize.width + padding.left + padding.right; + var h = textSize.height + padding.top + padding.bottom; + + if (style.fixedWidth === 0) + { + this.width = w; + } + + if (style.fixedHeight === 0) + { + this.height = h; + } + + this.updateDisplayOrigin(); + + w *= resolution; + h *= resolution; + + w = Math.max(w, 1); + h = Math.max(h, 1); + + if (canvas.width !== w || canvas.height !== h) + { + canvas.width = w; + canvas.height = h; + style.syncFont(canvas, context); // Resizing resets the context + } + else + { + context.clearRect(0, 0, w, h); + } + + context.save(); + + // context.scale(resolution, resolution); + + if (style.backgroundColor) + { + context.fillStyle = style.backgroundColor; + context.fillRect(0, 0, w, h); + } + + style.syncStyle(canvas, context); + + context.textBaseline = 'alphabetic'; + + // Apply padding + context.translate(padding.left, padding.top); + + var linePositionX; + var linePositionY; + + // Draw text line by line + for (var i = 0; i < textSize.lines; i++) + { + linePositionX = style.strokeThickness / 2; + linePositionY = (style.strokeThickness / 2 + i * textSize.lineHeight) + size.ascent; + + if (i > 0) + { + linePositionY += (textSize.lineSpacing * i); + } + + if (style.rtl) + { + linePositionX = w - linePositionX; + } + else if (style.align === 'right') + { + linePositionX += textSize.width - textSize.lineWidths[i]; + } + else if (style.align === 'center') + { + linePositionX += (textSize.width - textSize.lineWidths[i]) / 2; + } + + if (this.autoRound) + { + linePositionX = Math.round(linePositionX); + linePositionY = Math.round(linePositionY); + } + + if (style.strokeThickness) + { + this.style.syncShadow(context, style.shadowStroke); + + context.strokeText(lines[i], linePositionX, linePositionY); + } + + if (style.color) + { + this.style.syncShadow(context, style.shadowFill); + + context.fillText(lines[i], linePositionX, linePositionY); + } + } + + context.restore(); + + this.dirty = true; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#getTextMetrics + * @since 3.0.0 + * + * @return {object} [description] + */ + getTextMetrics: function () + { + return this.style.getTextMetrics(); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#toJSON + * @since 3.0.0 + * + * @return {object} [description] + */ + toJSON: function () + { + var out = Components.ToJSON(this); + + // Extra Text data is added here + + var data = { + autoRound: this.autoRound, + text: this.text, + style: this.style.toJSON(), + resolution: this.resolution, + padding: { + left: this.padding.left, + right: this.padding.right, + top: this.padding.top, + bottom: this.padding.bottom + } + }; + + out.data = data; + + return out; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Text#preDestroy + * @since 3.0.0 + */ + preDestroy: function () + { + if (this.style.rtl) + { + RemoveFromDOM(this.canvas); + } + + CanvasPool.remove(this.canvas); + } + +}); + +module.exports = Text; + + +/***/ }), +/* 131 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasPool = __webpack_require__(23); +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var CONST = __webpack_require__(21); +var GameObject = __webpack_require__(1); +var Render = __webpack_require__(711); +var RenderTextureCanvas = __webpack_require__(708); +var RenderTextureWebGL = __webpack_require__(707); + +/** + * @classdesc + * A Render Texture. + * + * @class RenderTexture + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.2.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.MatrixStack + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {integer} [width=32] - The width of the Render Texture. + * @param {integer} [height=32] - The height of the Render Texture. + */ +var RenderTexture = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.MatrixStack, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Size, + Components.Tint, + Components.Transform, + Components.Visible, + Render + ], + + initialize: + + function RenderTexture (scene, x, y, width, height) + { + if (width === undefined) { width = 32; } + if (height === undefined) { height = 32; } + + GameObject.call(this, scene, 'RenderTexture'); + + this.initMatrixStack(); + + this.renderer = scene.sys.game.renderer; + this.globalTint = 0xffffff; + this.globalAlpha = 1.0; + + if (this.renderer.type === CONST.WEBGL) + { + var gl = this.renderer.gl; + this.gl = gl; + this.fill = RenderTextureWebGL.fill; + this.clear = RenderTextureWebGL.clear; + this.draw = RenderTextureWebGL.draw; + this.drawFrame = RenderTextureWebGL.drawFrame; + this.texture = this.renderer.createTexture2D(0, gl.NEAREST, gl.NEAREST, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE, gl.RGBA, null, width, height, false); + this.framebuffer = this.renderer.createFramebuffer(width, height, this.texture, false); + } + else if (this.renderer.type === CONST.CANVAS) + { + this.fill = RenderTextureCanvas.fill; + this.clear = RenderTextureCanvas.clear; + this.draw = RenderTextureCanvas.draw; + this.drawFrame = RenderTextureCanvas.drawFrame; + this.canvas = CanvasPool.create2D(null, width, height); + this.context = this.canvas.getContext('2d'); + } + + this.setPosition(x, y); + this.setSize(width, height); + this.initPipeline('TextureTintPipeline'); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.RenderTexture#destroy + * @since 3.2.0 + */ + destroy: function () + { + GameObject.destroy.call(this); + + if (this.renderer.type === CONST.WEBGL) + { + this.renderer.deleteTexture(this.texture); + this.renderer.deleteFramebuffer(this.framebuffer); + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.RenderTexture#setGlobalTint + * @since 3.2.0 + * + * @param {integer} tint [description] + * + * @return {Phaser.GameObjects.RenderTexture} [description] + */ + setGlobalTint: function (tint) + { + this.globalTint = tint; + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.RenderTexture#setGlobalAlpha + * @since 3.2.0 + * + * @param {float} alpha [description] + * + * @return {Phaser.GameObjects.RenderTexture} [description] + */ + setGlobalAlpha: function (alpha) + { + this.globalAlpha = alpha; + return this; + } + + /** + * Fills the Render Texture with the given color. + * + * @method Phaser.GameObjects.RenderTexture#fill + * @since 3.2.0 + * + * @param {number} rgb - The color to fill the Render Texture with. + * + * @return {Phaser.GameObjects.RenderTexture} This Game Object. + */ + + /** + * Clears the Render Texture. + * + * @method Phaser.GameObjects.RenderTexture#clear + * @since 3.2.0 + * + * @return {Phaser.GameObjects.RenderTexture} This Game Object. + */ + + /** + * Draws a texture frame to the Render Texture at the given position. + * + * @method Phaser.GameObjects.RenderTexture#draw + * @since 3.2.0 + * + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {number} x - The x position to draw the frame at. + * @param {number} y - The y position to draw the frame at. + * + * @return {Phaser.GameObjects.RenderTexture} This Game Object. + */ + +}); + +module.exports = RenderTexture; + + +/***/ }), +/* 132 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Utils.Array.GetRandomElement + * @since 3.0.0 + * + * @param {array} array - The array to select the random entry from. + * @param {integer} [start=0] - [description] + * @param {integer} [length=array.length] - [description] + * + * @return {object} A random element from the array, or `null` if no element could be found in the range given. + */ +var GetRandomElement = function (array, start, length) +{ + if (start === undefined) { start = 0; } + if (length === undefined) { length = array.length; } + + var randomIndex = start + Math.floor(Math.random() * length); + + return (array[randomIndex] === undefined) ? null : array[randomIndex]; +}; + +module.exports = GetRandomElement; + + +/***/ }), +/* 133 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var GameObject = __webpack_require__(1); +var GravityWell = __webpack_require__(754); +var List = __webpack_require__(97); +var ParticleEmitter = __webpack_require__(753); +var Render = __webpack_require__(714); + +/** + * @classdesc + * [description] + * + * @class ParticleEmitterManager + * @extends Phaser.GameObjects.Particles.GameObject + * @memberOf Phaser.GameObjects.Particles + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Particles.Components.Depth + * @extends Phaser.GameObjects.Particles.Components.Visible + * @extends Phaser.GameObjects.Particles.Components.Pipeline + * + * @param {Phaser.Scene} scene - [description] + * @param {string} texture - [description] + * @param {(string|integer)} frame - [description] + * @param {Phaser.GameObjects.Particles.ParticleEmitter[]} emitters - [description] + */ +var ParticleEmitterManager = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Depth, + Components.Visible, + Components.Pipeline, + Render + ], + + initialize: + + // frame is optional and can contain the emitters array or object if skipped + function ParticleEmitterManager (scene, texture, frame, emitters) + { + GameObject.call(this, scene, 'ParticleEmitterManager'); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#blendMode + * @type {number} + * @default -1 + * @private + * @since 3.0.0 + */ + this.blendMode = -1; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#timeScale + * @type {float} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#texture + * @type {Phaser.Textures.Texture} + * @default null + * @since 3.0.0 + */ + this.texture = null; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#frame + * @type {Phaser.Textures.Frame} + * @default null + * @since 3.0.0 + */ + this.frame = null; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#frameNames + * @type {Phaser.Textures.Frame[]} + * @since 3.0.0 + */ + this.frameNames = []; + + // frame is optional and can contain the emitters array or object if skipped + if (frame !== null && (typeof frame === 'object' || Array.isArray(frame))) + { + emitters = frame; + frame = null; + } + + this.setTexture(texture, frame); + + this.initPipeline('TextureTintPipeline'); + + /** + * A list of Emitters being managed by this Emitter Manager. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#emitters + * @type {Phaser.Structs.List} + * @since 3.0.0 + */ + this.emitters = new List(this); + + /** + * A list of Gravity Wells being managed by this Emitter Manager. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#wells + * @type {Phaser.Structs.List} + * @since 3.0.0 + */ + this.wells = new List(this); + + if (emitters) + { + // An array of emitter configs? + if (!Array.isArray(emitters)) + { + emitters = [ emitters ]; + } + + for (var i = 0; i < emitters.length; i++) + { + this.createEmitter(emitters[i]); + } + } + }, + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setTexture + * @since 3.0.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. + */ + setTexture: function (key, frame) + { + this.texture = this.scene.sys.textures.get(key); + + return this.setFrame(frame); + }, + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setFrame + * @since 3.0.0 + * + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. + */ + setFrame: function (frame) + { + this.frame = this.texture.get(frame); + + this.frameNames = this.texture.getFramesFromTextureSource(this.frame.sourceIndex); + + this.defaultFrame = this.frame; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setEmitterFrames + * @since 3.0.0 + * + * @param {(Phaser.Textures.Frame|Phaser.Textures.Frame[])} frames - [description] + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. + */ + setEmitterFrames: function (frames, emitter) + { + if (!Array.isArray(frames)) + { + frames = [ frames ]; + } + + var out = emitter.frames; + + out.length = 0; + + for (var i = 0; i < frames.length; i++) + { + var frame = frames[i]; + + if (this.frameNames.indexOf(frame) !== -1) + { + out.push(this.texture.get(frame)); + } + } + + if (out.length > 0) + { + emitter.defaultFrame = out[0]; + } + else + { + emitter.defaultFrame = this.defaultFrame; + } + + return this; + }, + + /** + * Adds an existing Particle Emitter to this Manager. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#addEmitter + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Particle Emitter to add to this Emitter Manager. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} The Particle Emitter that was added to this Emitter Manager. + */ + addEmitter: function (emitter) + { + return this.emitters.add(emitter); + }, + + /** + * Creates a new Particle Emitter object, adds it to this Manager and returns a reference to it. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#createEmitter + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} The Particle Emitter that was created. + */ + createEmitter: function (config) + { + return this.addEmitter(new ParticleEmitter(this, config)); + }, + + /** + * Adds an existing Gravity Well object to this Manager. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#addGravityWell + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.GravityWell} well - The Gravity Well to add to this Emitter Manager. + * + * @return {Phaser.GameObjects.Particles.GravityWell} The Gravity Well that was added to this Emitter Manager. + */ + addGravityWell: function (well) + { + return this.wells.add(well); + }, + + /** + * Creates a new Gravity Well, adds it to this Manager and returns a reference to it. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#createGravityWell + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Particles.GravityWell} The Gravity Well that was created. + */ + createGravityWell: function (config) + { + return this.addGravityWell(new GravityWell(config)); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#emitParticle + * @since 3.0.0 + * + * @param {integer} count - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. + */ + emitParticle: function (count, x, y) + { + var emitters = this.emitters.list; + + for (var i = 0; i < emitters.length; i++) + { + var emitter = emitters[i]; + + if (emitter.active) + { + emitter.emitParticle(count, x, y); + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#emitParticleAt + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {integer} count - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. + */ + emitParticleAt: function (x, y, count) + { + return this.emitParticle(count, x, y); + }, + + /** + * Pauses this Emitter Manager. + * + * This has the effect of pausing all emitters, and all particles of those emitters, currently under its control. + * + * The particles will still render, but they will not have any of their logic updated. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#pause + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. + */ + pause: function () + { + this.active = false; + + return this; + }, + + /** + * Resumes this Emitter Manager, should it have been previously paused. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#resume + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Game Object. + */ + resume: function () + { + this.active = true; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#getProcessors + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.GravityWell[]} [description] + */ + getProcessors: function () + { + return this.wells.getAll('active', true); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#preUpdate + * @since 3.0.0 + * + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + preUpdate: function (time, delta) + { + // Scale the delta + delta *= this.timeScale; + + var emitters = this.emitters.list; + + for (var i = 0; i < emitters.length; i++) + { + var emitter = emitters[i]; + + if (emitter.active) + { + emitter.preUpdate(time, delta); + } + } + } + +}); + +module.exports = ParticleEmitterManager; + + +/***/ }), +/* 134 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +/** + * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse based on the given angle. + * + * @function Phaser.Geom.Ellipse.CircumferencePoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on. + * @param {number} angle - The angle from the center of the Ellipse to the circumference to return the point from. Given in radians. + * @param {(Phaser.Geom.Point|object)} [out] - A Point, or point-like object, to store the results in. If not given a Point will be created. + * + * @return {(Phaser.Geom.Point|object)} A Point object where the `x` and `y` properties are the point on the circumference. + */ +var CircumferencePoint = function (ellipse, angle, out) +{ + if (out === undefined) { out = new Point(); } + + var halfWidth = ellipse.width / 2; + var halfHeight = ellipse.height / 2; + + out.x = ellipse.x + halfWidth * Math.cos(angle); + out.y = ellipse.y + halfHeight * Math.sin(angle); + + return out; +}; + +module.exports = CircumferencePoint; + + +/***/ }), +/* 135 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Contains = __webpack_require__(74); +var GetPoint = __webpack_require__(268); +var GetPoints = __webpack_require__(267); +var Random = __webpack_require__(162); + +/** + * @classdesc + * An Ellipse object. + * + * This is a geometry object, containing numerical values and related methods to inspect and modify them. + * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. + * To render an Ellipse you should look at the capabilities of the Graphics class. + * + * @class Ellipse + * @memberOf Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of the center of the ellipse. + * @param {number} [y=0] - The y position of the center of the ellipse. + * @param {number} [width=0] - The width of the ellipse. + * @param {number} [height=0] - The height of the ellipse. + */ +var Ellipse = new Class({ + + initialize: + + function Ellipse (x, y, width, height) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 0; } + if (height === undefined) { height = 0; } + + /** + * The x position of the center of the ellipse. + * + * @name Phaser.Geom.Ellipse#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = x; + + /** + * The y position of the center of the ellipse. + * + * @name Phaser.Geom.Ellipse#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = y; + + /** + * The width of the ellipse. + * + * @name Phaser.Geom.Ellipse#width + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.width = width; + + /** + * The height of the ellipse. + * + * @name Phaser.Geom.Ellipse#height + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.height = height; + }, + + /** + * Check to see if the Ellipse contains the given x / y coordinates. + * + * @method Phaser.Geom.Ellipse#contains + * @since 3.0.0 + * + * @param {number} x - The x coordinate to check within the ellipse. + * @param {number} y - The y coordinate to check within the ellipse. + * + * @return {boolean} True if the coordinates are within the ellipse, otherwise false. + */ + contains: function (x, y) + { + return Contains(this, x, y); + }, + + /** + * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse + * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point + * at 180 degrees around the circle. + * + * @method Phaser.Geom.Ellipse#getPoint + * @since 3.0.0 + * + * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. + * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. + * + * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the ellipse. + */ + getPoint: function (position, point) + { + return GetPoint(this, position, point); + }, + + /** + * Returns an array of Point objects containing the coordinates of the points around the circumference of the Ellipse, + * based on the given quantity or stepRate values. + * + * @method Phaser.Geom.Ellipse#getPoints + * @since 3.0.0 + * + * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate. + * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. + * + * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the circumference of the ellipse. + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * Returns a uniformly distributed random point from anywhere within the given Ellipse. + * + * @method Phaser.Geom.Ellipse#getRandomPoint + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} [point] - A Point or point-like object to set the random `x` and `y` values in. + * + * @return {(Phaser.Geom.Point|object)} A Point object with the random values set in the `x` and `y` properties. + */ + getRandomPoint: function (point) + { + return Random(this, point); + }, + + /** + * Sets the x, y, width and height of this ellipse. + * + * @method Phaser.Geom.Ellipse#setTo + * @since 3.0.0 + * + * @param {number} x - The x position of the center of the ellipse. + * @param {number} y - The y position of the center of the ellipse. + * @param {number} width - The width of the ellipse. + * @param {number} height - The height of the ellipse. + * + * @return {Phaser.Geom.Ellipse} This Ellipse object. + */ + setTo: function (x, y, width, height) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + + return this; + }, + + /** + * Sets this Ellipse to be empty with a width and height of zero. + * Does not change its position. + * + * @method Phaser.Geom.Ellipse#setEmpty + * @since 3.0.0 + * + * @return {Phaser.Geom.Ellipse} This Ellipse object. + */ + setEmpty: function () + { + this.width = 0; + this.height = 0; + + return this; + }, + + /** + * Sets the position of this Ellipse. + * + * @method Phaser.Geom.Ellipse#setPosition + * @since 3.0.0 + * + * @param {number} x - The x position of the center of the ellipse. + * @param {number} y - The y position of the center of the ellipse. + * + * @return {Phaser.Geom.Ellipse} This Ellipse object. + */ + setPosition: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * Sets the size of this Ellipse. + * Does not change its position. + * + * @method Phaser.Geom.Ellipse#setSize + * @since 3.0.0 + * + * @param {number} width - The width of the ellipse. + * @param {number} [height=width] - The height of the ellipse. + * + * @return {Phaser.Geom.Ellipse} This Ellipse object. + */ + setSize: function (width, height) + { + if (height === undefined) { height = width; } + + this.width = width; + this.height = height; + + return this; + }, + + /** + * Checks to see if the Ellipse is empty: has a width or height equal to zero. + * + * @method Phaser.Geom.Ellipse#isEmpty + * @since 3.0.0 + * + * @return {boolean} True if the Ellipse is empty, otherwise false. + */ + isEmpty: function () + { + return (this.width <= 0 || this.height <= 0); + }, + + /** + * Returns the minor radius of the ellipse. Also known as the Semi Minor Axis. + * + * @method Phaser.Geom.Ellipse#getMinorRadius + * @since 3.0.0 + * + * @return {number} The minor radius. + */ + getMinorRadius: function () + { + return Math.min(this.width, this.height) / 2; + }, + + /** + * Returns the major radius of the ellipse. Also known as the Semi Major Axis. + * + * @method Phaser.Geom.Ellipse#getMajorRadius + * @since 3.0.0 + * + * @return {number} The major radius. + */ + getMajorRadius: function () + { + return Math.max(this.width, this.height) / 2; + }, + + /** + * The left position of the Ellipse. + * + * @name Phaser.Geom.Ellipse#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () + { + return this.x - (this.width / 2); + }, + + set: function (value) + { + this.x = value + (this.width / 2); + } + + }, + + /** + * The right position of the Ellipse. + * + * @name Phaser.Geom.Ellipse#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return this.x + (this.width / 2); + }, + + set: function (value) + { + this.x = value - (this.width / 2); + } + + }, + + /** + * The top position of the Ellipse. + * + * @name Phaser.Geom.Ellipse#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return this.y - (this.height / 2); + }, + + set: function (value) + { + this.y = value + (this.height / 2); + } + + }, + + /** + * The bottom position of the Ellipse. + * + * @name Phaser.Geom.Ellipse#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return this.y + (this.height / 2); + }, + + set: function (value) + { + this.y = value - (this.height / 2); + } + + } + +}); + +module.exports = Ellipse; + + +/***/ }), +/* 136 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Camera = __webpack_require__(157); +var Class = __webpack_require__(0); +var Commands = __webpack_require__(144); +var Components = __webpack_require__(13); +var Ellipse = __webpack_require__(269); +var GameObject = __webpack_require__(1); +var GetValue = __webpack_require__(5); +var MATH_CONST = __webpack_require__(16); +var Render = __webpack_require__(759); + +/** + * @classdesc + * [description] + * + * @class Graphics + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * @extends Phaser.GameObjects.Components.ScrollFactor + * + * @param {Phaser.Scene} scene - [description] + * @param {object} options - [description] + */ +var Graphics = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Pipeline, + Components.Transform, + Components.Visible, + Components.ScrollFactor, + Render + ], + + initialize: + + function Graphics (scene, options) + { + var x = GetValue(options, 'x', 0); + var y = GetValue(options, 'y', 0); + + GameObject.call(this, scene, 'Graphics'); + + this.setPosition(x, y); + this.initPipeline('FlatTintPipeline'); + + /** + * [description] + * + * @name Phaser.GameObjects.Graphics#displayOriginX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.displayOriginX = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.Graphics#displayOriginY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.displayOriginY = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.Graphics#commandBuffer + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.commandBuffer = []; + + /** + * [description] + * + * @name Phaser.GameObjects.Graphics#defaultFillColor + * @type {number} + * @default -1 + * @since 3.0.0 + */ + this.defaultFillColor = -1; + + /** + * [description] + * + * @name Phaser.GameObjects.Graphics#defaultFillAlpha + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.defaultFillAlpha = 1; + + /** + * [description] + * + * @name Phaser.GameObjects.Graphics#defaultStrokeWidth + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.defaultStrokeWidth = 1; + + /** + * [description] + * + * @name Phaser.GameObjects.Graphics#defaultStrokeColor + * @type {number} + * @default -1 + * @since 3.0.0 + */ + this.defaultStrokeColor = -1; + + /** + * [description] + * + * @name Phaser.GameObjects.Graphics#defaultStrokeAlpha + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.defaultStrokeAlpha = 1; + + /** + * [description] + * + * @name Phaser.GameObjects.Graphics#_lineWidth + * @type {number} + * @private + * @since 3.0.0 + */ + this._lineWidth = 1.0; + + this.setDefaultStyles(options); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#setDefaultStyles + * @since 3.0.0 + * + * @param {object} options - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + setDefaultStyles: function (options) + { + if (GetValue(options, 'lineStyle', null)) + { + this.defaultStrokeWidth = GetValue(options, 'lineStyle.width', 1); + this.defaultStrokeColor = GetValue(options, 'lineStyle.color', 0xffffff); + this.defaultStrokeAlpha = GetValue(options, 'lineStyle.alpha', 1); + + this.lineStyle(this.defaultStrokeWidth, this.defaultStrokeColor, this.defaultStrokeAlpha); + } + + if (GetValue(options, 'fillStyle', null)) + { + this.defaultFillColor = GetValue(options, 'fillStyle.color', 0xffffff); + this.defaultFillAlpha = GetValue(options, 'fillStyle.alpha', 1); + + this.fillStyle(this.defaultFillColor, this.defaultFillAlpha); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#lineStyle + * @since 3.0.0 + * + * @param {number} lineWidth - [description] + * @param {number} color - [description] + * @param {float} [alpha=1] - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + lineStyle: function (lineWidth, color, alpha) + { + if (alpha === undefined) { alpha = 1; } + + this.commandBuffer.push( + Commands.LINE_STYLE, + lineWidth, color, alpha + ); + + this._lineWidth = lineWidth; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillStyle + * @since 3.0.0 + * + * @param {number} color - [description] + * @param {float} [alpha=1] - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillStyle: function (color, alpha) + { + if (alpha === undefined) { alpha = 1; } + + this.commandBuffer.push( + Commands.FILL_STYLE, + color, alpha + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#beginPath + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + beginPath: function () + { + this.commandBuffer.push( + Commands.BEGIN_PATH + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#closePath + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + closePath: function () + { + this.commandBuffer.push( + Commands.CLOSE_PATH + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillPath + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillPath: function () + { + this.commandBuffer.push( + Commands.FILL_PATH + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#strokePath + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokePath: function () + { + this.commandBuffer.push( + Commands.STROKE_PATH + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillCircleShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillCircleShape: function (circle) + { + return this.fillCircle(circle.x, circle.y, circle.radius); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#strokeCircleShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeCircleShape: function (circle) + { + return this.strokeCircle(circle.x, circle.y, circle.radius); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillCircle + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} radius - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillCircle: function (x, y, radius) + { + this.beginPath(); + this.arc(x, y, radius, 0, MATH_CONST.PI2); + this.fillPath(); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#strokeCircle + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} radius - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeCircle: function (x, y, radius) + { + this.beginPath(); + this.arc(x, y, radius, 0, MATH_CONST.PI2); + this.strokePath(); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillRectShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillRectShape: function (rect) + { + return this.fillRect(rect.x, rect.y, rect.width, rect.height); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#strokeRectShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeRectShape: function (rect) + { + return this.strokeRect(rect.x, rect.y, rect.width, rect.height); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillRect + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillRect: function (x, y, width, height) + { + this.commandBuffer.push( + Commands.FILL_RECT, + x, y, width, height + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#strokeRect + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeRect: function (x, y, width, height) + { + var lineWidthHalf = this._lineWidth / 2; + var minx = x - lineWidthHalf; + var maxx = x + lineWidthHalf; + + this.beginPath(); + this.moveTo(x, y); + this.lineTo(x, y + height); + this.strokePath(); + + this.beginPath(); + this.moveTo(x + width, y); + this.lineTo(x + width, y + height); + this.strokePath(); + + this.beginPath(); + this.moveTo(minx, y); + this.lineTo(maxx + width, y); + this.strokePath(); + + this.beginPath(); + this.moveTo(minx, y + height); + this.lineTo(maxx + width, y + height); + this.strokePath(); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillPointShape + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} point - [description] + * @param {number} [size=1] - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillPointShape: function (point, size) + { + return this.fillPoint(point.x, point.y, size); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillPoint + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} [size=1] - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillPoint: function (x, y, size) + { + if (!size || size < 1) + { + size = 1; + } + else + { + x -= (size / 2); + y -= (size / 2); + } + + this.commandBuffer.push( + Commands.FILL_RECT, + x, y, size, size + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillTriangleShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillTriangleShape: function (triangle) + { + return this.fillTriangle(triangle.x1, triangle.y1, triangle.x2, triangle.y2, triangle.x3, triangle.y3); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#strokeTriangleShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeTriangleShape: function (triangle) + { + return this.strokeTriangle(triangle.x1, triangle.y1, triangle.x2, triangle.y2, triangle.x3, triangle.y3); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillTriangle + * @since 3.0.0 + * + * @param {number} x0 - [description] + * @param {number} y0 - [description] + * @param {number} x1 - [description] + * @param {number} y1 - [description] + * @param {number} x2 - [description] + * @param {number} y2 - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillTriangle: function (x0, y0, x1, y1, x2, y2) + { + this.commandBuffer.push( + Commands.FILL_TRIANGLE, + x0, y0, x1, y1, x2, y2 + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#strokeTriangle + * @since 3.0.0 + * + * @param {number} x0 - [description] + * @param {number} y0 - [description] + * @param {number} x1 - [description] + * @param {number} y1 - [description] + * @param {number} x2 - [description] + * @param {number} y2 - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeTriangle: function (x0, y0, x1, y1, x2, y2) + { + this.commandBuffer.push( + Commands.STROKE_TRIANGLE, + x0, y0, x1, y1, x2, y2 + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#strokeLineShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeLineShape: function (line) + { + return this.lineBetween(line.x1, line.y1, line.x2, line.y2); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#lineBetween + * @since 3.0.0 + * + * @param {number} x1 - [description] + * @param {number} y1 - [description] + * @param {number} x2 - [description] + * @param {number} y2 - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + lineBetween: function (x1, y1, x2, y2) + { + this.beginPath(); + this.moveTo(x1, y1); + this.lineTo(x2, y2); + this.strokePath(); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#lineTo + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + lineTo: function (x, y) + { + this.commandBuffer.push( + Commands.LINE_TO, + x, y + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#moveTo + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + moveTo: function (x, y) + { + this.commandBuffer.push( + Commands.MOVE_TO, + x, y + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#lineFxTo + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} rgb - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + lineFxTo: function (x, y, width, rgb) + { + this.commandBuffer.push( + Commands.LINE_FX_TO, + x, y, width, rgb, 1 + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#moveFxTo + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} rgb - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + moveFxTo: function (x, y, width, rgb) + { + this.commandBuffer.push( + Commands.MOVE_FX_TO, + x, y, width, rgb, 1 + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#strokePoints + * @since 3.0.0 + * + * @param {(array|Phaser.Geom.Point[])} points - [description] + * @param {boolean} [autoClose=false] - [description] + * @param {integer} [endIndex] - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokePoints: function (points, autoClose, endIndex) + { + if (autoClose === undefined) { autoClose = false; } + if (endIndex === undefined) { endIndex = points.length; } + + this.beginPath(); + + this.moveTo(points[0].x, points[0].y); + + for (var i = 1; i < endIndex; i++) + { + this.lineTo(points[i].x, points[i].y); + } + + if (autoClose) + { + this.lineTo(points[0].x, points[0].y); + } + + this.strokePath(); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillPoints + * @since 3.0.0 + * + * @param {(array|Phaser.Geom.Point[])} points - [description] + * @param {boolean} [autoClose=false] - [description] + * @param {integer} [endIndex] - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillPoints: function (points, autoClose, endIndex) + { + if (autoClose === undefined) { autoClose = false; } + if (endIndex === undefined) { endIndex = points.length; } + + this.beginPath(); + + this.moveTo(points[0].x, points[0].y); + + for (var i = 1; i < endIndex; i++) + { + this.lineTo(points[i].x, points[i].y); + } + + if (autoClose) + { + this.lineTo(points[0].x, points[0].y); + } + + this.fillPath(); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#strokeEllipseShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - [description] + * @param {integer} [smoothness=32] - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeEllipseShape: function (ellipse, smoothness) + { + if (smoothness === undefined) { smoothness = 32; } + + var points = ellipse.getPoints(smoothness); + + return this.strokePoints(points, true); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#strokeEllipse + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {integer} [smoothness=32] - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeEllipse: function (x, y, width, height, smoothness) + { + if (smoothness === undefined) { smoothness = 32; } + + var ellipse = new Ellipse(x, y, width, height); + + var points = ellipse.getPoints(smoothness); + + return this.strokePoints(points, true); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillEllipseShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - [description] + * @param {integer} [smoothness=32] - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillEllipseShape: function (ellipse, smoothness) + { + if (smoothness === undefined) { smoothness = 32; } + + var points = ellipse.getPoints(smoothness); + + return this.fillPoints(points, true); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#fillEllipse + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {integer} [smoothness=32] - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillEllipse: function (x, y, width, height, smoothness) + { + if (smoothness === undefined) { smoothness = 32; } + + var ellipse = new Ellipse(x, y, width, height); + + var points = ellipse.getPoints(smoothness); + + return this.fillPoints(points, true); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#arc + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} radius - [description] + * @param {number} startAngle - [description] + * @param {number} endAngle - [description] + * @param {boolean} anticlockwise - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + arc: function (x, y, radius, startAngle, endAngle, anticlockwise) + { + this.commandBuffer.push( + Commands.ARC, + x, y, radius, startAngle, endAngle, anticlockwise + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#save + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + save: function () + { + this.commandBuffer.push( + Commands.SAVE + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#restore + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + restore: function () + { + this.commandBuffer.push( + Commands.RESTORE + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#translate + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + translate: function (x, y) + { + this.commandBuffer.push( + Commands.TRANSLATE, + x, y + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#scale + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + scale: function (x, y) + { + this.commandBuffer.push( + Commands.SCALE, + x, y + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#rotate + * @since 3.0.0 + * + * @param {number} radians - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + rotate: function (radians) + { + this.commandBuffer.push( + Commands.ROTATE, + radians + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#clear + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + clear: function () + { + this.commandBuffer.length = 0; + + if (this.defaultFillColor > -1) + { + this.fillStyle(this.defaultFillColor, this.defaultFillAlpha); + } + + if (this.defaultStrokeColor > -1) + { + this.lineStyle(this.defaultStrokeWidth, this.defaultStrokeColor, this.defaultStrokeAlpha); + } + + return this; + }, + + /** + * If key is a string it'll generate a new texture using it and add it into the + * Texture Manager (assuming no key conflict happens). + * + * If key is a Canvas it will draw the texture to that canvas context. Note that it will NOT + * automatically upload it to the GPU in WebGL mode. + * + * @method Phaser.GameObjects.Graphics#generateTexture + * @since 3.0.0 + * + * @param {(string|HTMLCanvasElement)} key - [description] + * @param {integer} [width] - [description] + * @param {integer} [height] - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + generateTexture: function (key, width, height) + { + var sys = this.scene.sys; + + if (width === undefined) { width = sys.game.config.width; } + if (height === undefined) { height = sys.game.config.height; } + + Graphics.TargetCamera.setViewport(0, 0, width, height); + Graphics.TargetCamera.scrollX = this.x; + Graphics.TargetCamera.scrollY = this.y; + + var texture; + var ctx; + + if (typeof key === 'string') + { + if (sys.textures.exists(key)) + { + // Key is a string, it DOES exist in the Texture Manager AND is a canvas, so draw to it + + texture = sys.textures.get(key); + + var src = texture.getSourceImage(); + + if (src instanceof HTMLCanvasElement) + { + ctx = src.getContext('2d'); + } + } + else + { + // Key is a string and doesn't exist in the Texture Manager, so generate and save it + + texture = sys.textures.createCanvas(key, width, height); + + ctx = texture.getSourceImage().getContext('2d'); + } + } + else if (key instanceof HTMLCanvasElement) + { + // Key is a Canvas, so draw to it + + ctx = key.getContext('2d'); + } + + if (ctx) + { + this.renderCanvas(sys.game.renderer, this, 0, Graphics.TargetCamera, ctx); + + if (sys.game.renderer.gl && texture) + { + texture.source[0].glTexture = sys.game.renderer.canvasToTexture(ctx.canvas, texture.source[0].glTexture, true, 0); + } + } + + return this; + } + +}); + +/** + * A Camera used specifically by the Graphics system for rendering to textures. + * + * @name Phaser.GameObjects.Graphics.TargetCamera + * @type {Phaser.Cameras.Scene2D.Camera} + * @since 3.1.0 + */ +Graphics.TargetCamera = new Camera(0, 0, 0, 0); + +module.exports = Graphics; + + +/***/ }), +/* 137 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var GameObject = __webpack_require__(1); +var GetBitmapTextSize = __webpack_require__(271); +var Render = __webpack_require__(771); + +/** + * @callback DisplayCallback + * + * @param {object} display - [description] + * @param {{topLeft:number,topRight:number,bottomLeft:number,bottomRight:number}} display.tint - [description] + * @param {number} display.index - [description] + * @param {number} display.charCode - [description] + * @param {number} display.x - [description] + * @param {number} display.y - [description] + * @param {number} display.scale - [description] + * @param {number} display.rotation - [description] + * @param {[type]} display.data - [description] + */ + +/** + * @classdesc + * [description] + * + * @class DynamicBitmapText + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. + * @param {number} [x=0] - The x coordinate of this Game Object in world space. + * @param {number} [y=0] - The y coordinate of this Game Object in world space. + * @param {string} font - [description] + * @param {(string|string[])} [text] - [description] + * @param {number} [size] - [description] + */ +var DynamicBitmapText = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Origin, + Components.Pipeline, + Components.ScrollFactor, + Components.Texture, + Components.Tint, + Components.Transform, + Components.Visible, + Render + ], + + initialize: + + function DynamicBitmapText (scene, x, y, font, text, size) + { + if (text === undefined) { text = ''; } + + GameObject.call(this, scene, 'DynamicBitmapText'); + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#font + * @type {string} + * @since 3.0.0 + */ + this.font = font; + + var entry = this.scene.sys.cache.bitmapFont.get(font); + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#fontData + * @type {object} + * @since 3.0.0 + */ + this.fontData = entry.data; + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#text + * @type {string} + * @since 3.0.0 + */ + this.text = (Array.isArray(text)) ? text.join('\n') : text; + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#fontSize + * @type {number} + * @since 3.0.0 + */ + this.fontSize = size || this.fontData.size; + + this.setTexture(entry.texture, entry.frame); + this.setPosition(x, y); + this.setOrigin(0, 0); + this.initPipeline('TextureTintPipeline'); + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#_bounds + * @type {TextBounds} + * @private + * @since 3.0.0 + */ + this._bounds = this.getTextBounds(); + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#scrollX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.scrollX = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#scrollY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.scrollY = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#cropWidth + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.cropWidth = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#cropHeight + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.cropHeight = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#displayCallback; + * @type {DisplayCallback} + * @since 3.0.0 + */ + this.displayCallback; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.DynamicBitmapText#setSize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setSize: function (width, height) + { + this.cropWidth = width; + this.cropHeight = height; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.DynamicBitmapText#setDisplayCallback + * @since 3.0.0 + * + * @param {DisplayCallback} callback - [description] + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setDisplayCallback: function (callback) + { + this.displayCallback = callback; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.DynamicBitmapText#setFontSize + * @since 3.0.0 + * + * @param {number} size - [description] + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setFontSize: function (size) + { + this.fontSize = size; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.DynamicBitmapText#setText + * @since 3.0.0 + * + * @param {(string|string[])} value - The string, or array of strings, to be set as the content of this BitmapText. + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setText: function (value) + { + if (!value && value !== 0) + { + value = ''; + } + + if (Array.isArray(value)) + { + value = value.join('\n'); + } + + if (value !== this.text) + { + this.text = value.toString(); + + this.updateDisplayOrigin(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.DynamicBitmapText#setScrollX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setScrollX: function (value) + { + this.scrollX = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.DynamicBitmapText#setScrollY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setScrollY: function (value) + { + this.scrollY = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.DynamicBitmapText#getTextBounds + * @since 3.0.0 + * + * @param {boolean} round - [description] + * + * @return {TextBounds} [description] + */ + getTextBounds: function (round) + { + // local = the BitmapText based on fontSize and 0x0 coords + // global = the BitmapText, taking into account scale and world position + + this._bounds = GetBitmapTextSize(this, round); + + return this._bounds; + }, + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#width + * @type {number} + * @since 3.0.0 + */ + width: { + + get: function () + { + this.getTextBounds(false); + return this._bounds.global.width; + } + + }, + + /** + * [description] + * + * @name Phaser.GameObjects.DynamicBitmapText#height + * @type {number} + * @since 3.0.0 + */ + height: { + + get: function () + { + this.getTextBounds(false); + return this._bounds.global.height; + } + + }, + + /** + * [description] + * + * @method Phaser.GameObjects.DynamicBitmapText#toJSON + * @since 3.0.0 + * + * @return {JSONGameObject.} [description] + */ + toJSON: function () + { + var out = Components.ToJSON(this); + + // Extra data is added here + + var data = { + font: this.font, + text: this.text, + fontSize: this.fontSize + }; + + out.data = data; + + return out; + } + +}); + +module.exports = DynamicBitmapText; + + +/***/ }), +/* 138 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BlitterRender = __webpack_require__(775); +var Bob = __webpack_require__(772); +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var Frame = __webpack_require__(141); +var GameObject = __webpack_require__(1); +var List = __webpack_require__(97); + +/** + * @callback BlitterFromCallback + * + * @param {Phaser.GameObjects.Blitter} blitter - [description] + * @param {integer} index - [description] + */ + +/** + * @classdesc + * A Blitter Game Object. + * + * The Blitter Game Object is a special kind of container that creates, updates and manages Bob objects. + * Bobs are designed for rendering speed rather than flexibility. They consist of a texture, or frame from a texture, + * a position and an alpha value. You cannot scale or rotate them. They use a batched drawing method for speed + * during rendering. + * + * A Blitter Game Object has one texture bound to it. Bobs created by the Blitter can use any Frame from this + * Texture to render with, but they cannot use any other Texture. It is this single texture-bind that allows + * them their speed. + * + * If you have a need to blast a large volume of frames around the screen then Blitter objects are well worth + * investigating. They are especially useful for using as a base for your own special effects systems. + * + * @class Blitter + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. + * @param {number} [x=0] - The x coordinate of this Game Object in world space. + * @param {number} [y=0] - The y coordinate of this Game Object in world space. + * @param {string} [texture='__DEFAULT'] - The key of the texture this Game Object will use for rendering. The Texture must already exist in the Texture Manager. + * @param {(string|integer)} [frame=0] - The Frame of the Texture that this Game Object will use. Only set if the Texture has multiple frames, such as a Texture Atlas or Sprite Sheet. + */ +var Blitter = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Size, + Components.Texture, + Components.Transform, + Components.Visible, + BlitterRender + ], + + initialize: + + function Blitter (scene, x, y, texture, frame) + { + GameObject.call(this, scene, 'Blitter'); + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.initPipeline('TextureTintPipeline'); + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter#children + * @type {Phaser.Structs.List} + * @since 3.0.0 + */ + this.children = new List(); + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter#renderList + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.renderList = []; + + this.dirty = false; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter#create + * @since 3.0.0 + * + * @param {number} x - The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param {number} y - The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param {(string|integer|Phaser.Textures.Frame)} [frame] - The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. + * @param {boolean} [visible=true] - Should the created Bob render or not? + * @param {integer} [index] - The position in the Blitters Display List to add the new Bob at. Defaults to the top of the list. + * + * @return {Phaser.GameObjects.Blitter.Bob} The newly created Bob object. + */ + create: function (x, y, frame, visible, index) + { + if (visible === undefined) { visible = true; } + if (index === undefined) { index = this.children.length; } + + if (frame === undefined) + { + frame = this.frame; + } + else if (!(frame instanceof Frame)) + { + frame = this.texture.get(frame); + } + + var bob = new Bob(this, x, y, frame, visible); + + this.children.addAt(bob, index, false); + + this.dirty = true; + + return bob; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter#createFromCallback + * @since 3.0.0 + * + * @param {BlitterFromCallback} callback - The callback to invoke after creating a bob. It will be sent two arguments: The Bob and the index of the Bob. + * @param {integer} quantity - The quantity of Bob objects to create. + * @param {string} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture. + * @param {boolean} [visible=true] - [description] + * + * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that were created. + */ + createFromCallback: function (callback, quantity, frame, visible) + { + var bobs = this.createMultiple(quantity, frame, visible); + + for (var i = 0; i < bobs.length; i++) + { + var bob = bobs[i]; + + callback.call(this, bob, i); + } + + return bobs; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter#createMultiple + * @since 3.0.0 + * + * @param {integer} quantity - The quantity of Bob objects to create. + * @param {string} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture. + * @param {boolean} [visible=true] - [description] + * + * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that were created. + */ + createMultiple: function (quantity, frame, visible) + { + if (frame === undefined) { frame = this.frame.name; } + if (visible === undefined) { visible = true; } + + if (!Array.isArray(frame)) + { + frame = [ frame ]; + } + + var bobs = []; + var _this = this; + + frame.forEach(function (singleFrame) + { + for (var i = 0; i < quantity; i++) + { + bobs.push(_this.create(0, 0, singleFrame, visible)); + } + }); + + return bobs; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter#childCanRender + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Blitter.Bob} child - [description] + * + * @return {boolean} [description] + */ + childCanRender: function (child) + { + return (child.visible && child.alpha > 0); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter#getRenderList + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that will be rendered this frame. + */ + getRenderList: function () + { + if (this.dirty) + { + this.renderList = this.children.list.filter(this.childCanRender, this); + this.dirty = false; + } + + return this.renderList; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter#clear + * @since 3.0.0 + */ + clear: function () + { + this.children.removeAll(); + this.dirty = true; + } + +}); + +module.exports = Blitter; + + +/***/ }), +/* 139 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var GameObject = __webpack_require__(1); +var GetBitmapTextSize = __webpack_require__(271); +var ParseFromAtlas = __webpack_require__(780); +var ParseRetroFont = __webpack_require__(779); +var Render = __webpack_require__(778); + +/** + * @typedef {object} TextBounds + * + * @property {object} local - [description] + * @property {number} local.x - [description] + * @property {number} local.y - [description] + * @property {number} local.width - [description] + * @property {number} local.height - [description] + * @property {object} global - [description] + * @property {number} global.x - [description] + * @property {number} global.y - [description] + * @property {number} global.width - [description] + * @property {number} global.height - [description] + */ + +/** + * @typedef {object} JSONBitmapText + * + * @property {string} font - [description] + * @property {string} text - [description] + * @property {number} fontSize - [description] + */ + +/** + * @classdesc + * [description] + * + * @class BitmapText + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. + * @param {number} [x=0] - The x coordinate of this Game Object in world space. + * @param {number} [y=0] - The y coordinate of this Game Object in world space. + * @param {string} font - [description] + * @param {(string|string[])} [text] - [description] + * @param {number} [size] - [description] + */ +var BitmapText = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Texture, + Components.Tint, + Components.Transform, + Components.Visible, + Render + ], + + initialize: + + function BitmapText (scene, x, y, font, text, size) + { + if (text === undefined) { text = ''; } + + GameObject.call(this, scene, 'BitmapText'); + + /** + * [description] + * + * @name Phaser.GameObjects.BitmapText#font + * @type {string} + * @since 3.0.0 + */ + this.font = font; + + var entry = this.scene.sys.cache.bitmapFont.get(font); + + /** + * [description] + * + * @name Phaser.GameObjects.BitmapText#fontData + * @type {object} + * @since 3.0.0 + */ + this.fontData = entry.data; + + /** + * [description] + * + * @name Phaser.GameObjects.BitmapText#text + * @type {string} + * @since 3.0.0 + */ + this.text = (Array.isArray(text)) ? text.join('\n') : text; + + /** + * [description] + * + * @name Phaser.GameObjects.BitmapText#fontSize + * @type {number} + * @since 3.0.0 + */ + this.fontSize = size || this.fontData.size; + + this.setTexture(entry.texture, entry.frame); + this.setPosition(x, y); + this.setOrigin(0, 0); + this.initPipeline('TextureTintPipeline'); + + /** + * [description] + * + * @name Phaser.GameObjects.BitmapText#_bounds + * @type {TextBounds} + * @private + * @since 3.0.0 + */ + this._bounds = this.getTextBounds(); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.BitmapText#setFontSize + * @since 3.0.0 + * + * @param {number} size - [description] + * + * @return {Phaser.GameObjects.BitmapText} This Game Object. + */ + setFontSize: function (size) + { + this.fontSize = size; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.BitmapText#setText + * @since 3.0.0 + * + * @param {(string|string[])} value - The string, or array of strings, to be set as the content of this BitmapText. + * + * @return {Phaser.GameObjects.BitmapText} This Game Object. + */ + setText: function (value) + { + if (!value && value !== 0) + { + value = ''; + } + + if (Array.isArray(value)) + { + value = value.join('\n'); + } + + if (value !== this.text) + { + this.text = value.toString(); + + this.updateDisplayOrigin(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.BitmapText#getTextBounds + * @since 3.0.0 + * + * @param {boolean} round - [description] + * + * @return {TextBounds} [description] + */ + getTextBounds: function (round) + { + // local = the BitmapText based on fontSize and 0x0 coords + // global = the BitmapText, taking into account scale and world position + + this._bounds = GetBitmapTextSize(this, round); + + return this._bounds; + }, + + /** + * [description] + * + * @name Phaser.GameObjects.BitmapText#width + * @type {number} + * @since 3.0.0 + */ + width: { + + get: function () + { + this.getTextBounds(false); + + return this._bounds.global.width; + } + + }, + + /** + * [description] + * + * @name Phaser.GameObjects.BitmapText#height + * @type {number} + * @since 3.0.0 + */ + height: { + + get: function () + { + this.getTextBounds(false); + + return this._bounds.global.height; + } + + }, + + /** + * [description] + * + * @method Phaser.GameObjects.BitmapText#toJSON + * @since 3.0.0 + * + * @return {JSONGameObject.} [description] + */ + toJSON: function () + { + var out = Components.ToJSON(this); + + // Extra data is added here + + var data = { + font: this.font, + text: this.text, + fontSize: this.fontSize + }; + + out.data = data; + + return out; + } + +}); + +BitmapText.ParseRetroFont = ParseRetroFont; +BitmapText.ParseFromAtlas = ParseFromAtlas; + +module.exports = BitmapText; + + +/***/ }), +/* 140 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetAdvancedValue = __webpack_require__(8); + +/** + * Adds an Animation component to a Sprite and populates it based on the given config. + * + * @function Phaser.GameObjects.BuildGameObjectAnimation + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Sprite} sprite - [description] + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Sprite} The updated Sprite. + */ +var BuildGameObjectAnimation = function (sprite, config) +{ + var animConfig = GetAdvancedValue(config, 'anims', null); + + if (animConfig === null) + { + return sprite; + } + + if (typeof animConfig === 'string') + { + // { anims: 'key' } + sprite.anims.play(animConfig); + } + else if (typeof animConfig === 'object') + { + // { anims: { + // key: string + // startFrame: [string|integer] + // delay: [float] + // repeat: [integer] + // repeatDelay: [float] + // yoyo: [boolean] + // play: [boolean] + // delayedPlay: [boolean] + // } + // } + + var anims = sprite.anims; + + var key = GetAdvancedValue(animConfig, 'key', undefined); + var startFrame = GetAdvancedValue(animConfig, 'startFrame', undefined); + + var delay = GetAdvancedValue(animConfig, 'delay', 0); + var repeat = GetAdvancedValue(animConfig, 'repeat', 0); + var repeatDelay = GetAdvancedValue(animConfig, 'repeatDelay', 0); + var yoyo = GetAdvancedValue(animConfig, 'yoyo', false); + + var play = GetAdvancedValue(animConfig, 'play', false); + var delayedPlay = GetAdvancedValue(animConfig, 'delayedPlay', 0); + + anims.delay(delay); + anims.repeat(repeat); + anims.repeatDelay(repeatDelay); + anims.yoyo(yoyo); + + if (play) + { + anims.play(key, startFrame); + } + else if (delayedPlay > 0) + { + anims.delayedPlay(delayedPlay, key, startFrame); + } + else + { + anims.load(key); + } + } + + return sprite; +}; + +module.exports = BuildGameObjectAnimation; + + +/***/ }), +/* 141 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Extend = __webpack_require__(18); + +/** + * @classdesc + * A Frame is a section of a Texture. + * + * @class Frame + * @memberOf Phaser.Textures + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture this Frame is a part of. + * @param {(integer|string)} name - The name of this Frame. The name is unique within the Texture. + * @param {integer} sourceIndex - The index of the TextureSource that this Frame is a part of. + * @param {number} x - The x coordinate of the top-left of this Frame. + * @param {number} y - The y coordinate of the top-left of this Frame. + * @param {number} width - The width of this Frame. + * @param {number} height - The height of this Frame. + */ +var Frame = new Class({ + + initialize: + + function Frame (texture, name, sourceIndex, x, y, width, height) + { + /** + * The Texture this Frame is a part of. + * + * @name Phaser.Textures.Frame#texture + * @type {Phaser.Textures.Texture} + * @since 3.0.0 + */ + this.texture = texture; + + /** + * The name of this Frame. + * The name is unique within the Texture. + * + * @name Phaser.Textures.Frame#name + * @type {string} + * @since 3.0.0 + */ + this.name = name; + + /** + * The TextureSource this Frame is part of. + * + * @name Phaser.Textures.Frame#source + * @type {Phaser.Textures.TextureSource} + * @since 3.0.0 + */ + this.source = texture.source[sourceIndex]; + + /** + * The index of the TextureSource in the Texture sources array. + * + * @name Phaser.Textures.Frame#sourceIndex + * @type {integer} + * @since 3.0.0 + */ + this.sourceIndex = sourceIndex; + + /** + * X position within the source image to cut from. + * + * @name Phaser.Textures.Frame#cutX + * @type {integer} + * @since 3.0.0 + */ + this.cutX = x; + + /** + * Y position within the source image to cut from. + * + * @name Phaser.Textures.Frame#cutY + * @type {integer} + * @since 3.0.0 + */ + this.cutY = y; + + /** + * The width of the area in the source image to cut. + * + * @name Phaser.Textures.Frame#cutWidth + * @type {integer} + * @since 3.0.0 + */ + this.cutWidth = width; + + /** + * The height of the area in the source image to cut. + * + * @name Phaser.Textures.Frame#cutHeight + * @type {integer} + * @since 3.0.0 + */ + this.cutHeight = height; + + /** + * The X rendering offset of this Frame, taking trim into account. + * + * @name Phaser.Textures.Frame#x + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.x = 0; + + /** + * The Y rendering offset of this Frame, taking trim into account. + * + * @name Phaser.Textures.Frame#y + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.y = 0; + + /** + * The rendering width of this Frame, taking trim into account. + * + * @name Phaser.Textures.Frame#width + * @type {integer} + * @since 3.0.0 + */ + this.width = width; + + /** + * The rendering height of this Frame, taking trim into account. + * + * @name Phaser.Textures.Frame#height + * @type {integer} + * @since 3.0.0 + */ + this.height = height; + + /** + * Half the width, floored. + * Precalculated for the renderer. + * + * @name Phaser.Textures.Frame#halfWidth + * @type {integer} + * @since 3.0.0 + */ + this.halfWidth = Math.floor(width * 0.5); + + /** + * Half the height, floored. + * Precalculated for the renderer. + * + * @name Phaser.Textures.Frame#halfHeight + * @type {integer} + * @since 3.0.0 + */ + this.halfHeight = Math.floor(height * 0.5); + + /** + * The x center of this frame, floored. + * + * @name Phaser.Textures.Frame#centerX + * @type {integer} + * @since 3.0.0 + */ + this.centerX = Math.floor(width / 2); + + /** + * The y center of this frame, floored. + * + * @name Phaser.Textures.Frame#centerY + * @type {integer} + * @since 3.0.0 + */ + this.centerY = Math.floor(height / 2); + + /** + * The horizontal pivot point of this Frame. + * + * @name Phaser.Textures.Frame#pivotX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.pivotX = 0; + + /** + * The vertical pivot point of this Frame. + * + * @name Phaser.Textures.Frame#pivotY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.pivotY = 0; + + /** + * Does this Frame have a custom pivot point? + * + * @name Phaser.Textures.Frame#customPivot + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customPivot = false; + + /** + * **CURRENTLY UNSUPPORTED** + * + * Is this frame is rotated or not in the Texture? + * Rotation allows you to use rotated frames in texture atlas packing. + * It has nothing to do with Sprite rotation. + * + * @name Phaser.Textures.Frame#rotated + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.rotated = false; + + /** + * Over-rides the Renderer setting. + * -1 = use Renderer Setting + * 0 = No rounding + * 1 = Round + * + * @name Phaser.Textures.Frame#autoRound + * @type {integer} + * @default -1 + * @since 3.0.0 + */ + this.autoRound = -1; + + /** + * Any Frame specific custom data can be stored here. + * + * @name Phaser.Textures.Frame#customData + * @type {object} + * @since 3.0.0 + */ + this.customData = {}; + + /** + * The un-modified source frame, trim and UV data. + * + * @name Phaser.Textures.Frame#data + * @type {object} + * @private + * @since 3.0.0 + */ + this.data = { + cut: { + x: x, + y: y, + w: width, + h: height, + r: x + width, + b: y + height + }, + trim: false, + sourceSize: { + w: width, + h: height + }, + spriteSourceSize: { + x: 0, + y: 0, + w: width, + h: height + }, + uvs: { + x0: 0, + y0: 0, + x1: 0, + y1: 0, + x2: 0, + y2: 0, + x3: 0, + y3: 0 + }, + radius: 0.5 * Math.sqrt(width * width + height * height), + drawImage: { + sx: x, + sy: y, + sWidth: width, + sHeight: height, + dWidth: width, + dHeight: height + } + }; + + this.updateUVs(); + }, + + /** + * If the frame was trimmed when added to the Texture Atlas, this records the trim and source data. + * + * @method Phaser.Textures.Frame#setTrim + * @since 3.0.0 + * + * @param {number} actualWidth - The width of the frame before being trimmed. + * @param {number} actualHeight - The height of the frame before being trimmed. + * @param {number} destX - The destination X position of the trimmed frame for display. + * @param {number} destY - The destination Y position of the trimmed frame for display. + * @param {number} destWidth - The destination width of the trimmed frame for display. + * @param {number} destHeight - The destination height of the trimmed frame for display. + * + * @return {Phaser.Textures.Frame} This Frame object. + */ + setTrim: function (actualWidth, actualHeight, destX, destY, destWidth, destHeight) + { + var data = this.data; + var ss = data.spriteSourceSize; + + // Store actual values + + data.trim = true; + + data.sourceSize.w = actualWidth; + data.sourceSize.h = actualHeight; + + ss.x = destX; + ss.y = destY; + ss.w = destWidth; + ss.h = destHeight; + + // Adjust properties + this.x = destX; + this.y = destY; + + this.width = destWidth; + this.height = destHeight; + + this.halfWidth = destWidth * 0.5; + this.halfHeight = destHeight * 0.5; + + this.centerX = Math.floor(destWidth / 2); + this.centerY = Math.floor(destHeight / 2); + + return this.updateUVs(); + }, + + /** + * Updates the internal WebGL UV cache and the drawImage cache. + * + * @method Phaser.Textures.Frame#updateUVs + * @since 3.0.0 + * + * @return {Phaser.Textures.Frame} This Frame object. + */ + updateUVs: function () + { + var cx = this.cutX; + var cy = this.cutY; + var cw = this.cutWidth; + var ch = this.cutHeight; + + // Canvas data + + var cd = this.data.drawImage; + + cd.sWidth = cw; + cd.sHeight = ch; + cd.dWidth = cw; + cd.dHeight = ch; + + // WebGL data + + var tw = this.source.width; + var th = this.source.height; + var uvs = this.data.uvs; + + uvs.x0 = cx / tw; + uvs.y0 = cy / th; + + uvs.x1 = cx / tw; + uvs.y1 = (cy + ch) / th; + + uvs.x2 = (cx + cw) / tw; + uvs.y2 = (cy + ch) / th; + + uvs.x3 = (cx + cw) / tw; + uvs.y3 = cy / th; + + return this; + }, + + /** + * Updates the internal WebGL UV cache. + * + * @method Phaser.Textures.Frame#updateUVsInverted + * @since 3.0.0 + * + * @return {Phaser.Textures.Frame} This Frame object. + */ + updateUVsInverted: function () + { + var tw = this.source.width; + var th = this.source.height; + var uvs = this.data.uvs; + + uvs.x3 = (this.cutX + this.cutHeight) / tw; + uvs.y3 = (this.cutY + this.cutWidth) / th; + + uvs.x2 = this.cutX / tw; + uvs.y2 = (this.cutY + this.cutWidth) / th; + + uvs.x1 = this.cutX / tw; + uvs.y1 = this.cutY / th; + + uvs.x0 = (this.cutX + this.cutHeight) / tw; + uvs.y0 = this.cutY / th; + + return this; + }, + + /** + * Clones this Frame into a new Frame object. + * + * @method Phaser.Textures.Frame#clone + * @since 3.0.0 + * + * @return {Phaser.Textures.Frame} A clone of this Frame. + */ + clone: function () + { + var clone = new Frame(this.texture, this.name, this.sourceIndex); + + clone.cutX = this.cutX; + clone.cutY = this.cutY; + clone.cutWidth = this.cutWidth; + clone.cutHeight = this.cutHeight; + + clone.x = this.x; + clone.y = this.y; + + clone.width = this.width; + clone.height = this.height; + + clone.halfWidth = this.halfWidth; + clone.halfHeight = this.halfHeight; + + clone.centerX = this.centerX; + clone.centerY = this.centerY; + + clone.rotated = this.rotated; + + clone.data = Extend(true, clone.data, this.data); + + clone.updateUVs(); + + return clone; + }, + + /** + * Destroys this Frames references. + * + * @method Phaser.Textures.Frame#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.texture = null; + + this.source = null; + }, + + /** + * The width of the Frame in its un-trimmed, un-padded state, as prepared in the art package, + * before being packed. + * + * @name Phaser.Textures.Frame#realWidth + * @type {number} + * @readOnly + * @since 3.0.0 + */ + realWidth: { + + get: function () + { + return this.data.sourceSize.w; + } + + }, + + /** + * The height of the Frame in its un-trimmed, un-padded state, as prepared in the art package, + * before being packed. + * + * @name Phaser.Textures.Frame#realHeight + * @type {number} + * @readOnly + * @since 3.0.0 + */ + realHeight: { + + get: function () + { + return this.data.sourceSize.h; + } + + }, + + /** + * The UV data for this Frame. + * + * @name Phaser.Textures.Frame#uvs + * @type {object} + * @readOnly + * @since 3.0.0 + */ + uvs: { + + get: function () + { + return this.data.uvs; + } + + }, + + /** + * The radius of the Frame (derived from sqrt(w * w + h * h) / 2) + * + * @name Phaser.Textures.Frame#radius + * @type {number} + * @readOnly + * @since 3.0.0 + */ + radius: { + + get: function () + { + return this.data.radius; + } + + }, + + /** + * Is the Frame trimmed or not? + * + * @name Phaser.Textures.Frame#trimmed + * @type {boolean} + * @readOnly + * @since 3.0.0 + */ + trimmed: { + + get: function () + { + return this.data.trim; + } + + }, + + /** + * The Canvas drawImage data object. + * + * @name Phaser.Textures.Frame#canvasData + * @type {object} + * @readOnly + * @since 3.0.0 + */ + canvasData: { + + get: function () + { + return this.data.drawImage; + } + + } + +}); + +module.exports = Frame; + + +/***/ }), +/* 142 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(75); +var GetPhysicsPlugins = __webpack_require__(797); +var GetScenePlugins = __webpack_require__(796); +var Plugins = __webpack_require__(303); +var Settings = __webpack_require__(284); + +/** + * @classdesc + * The Scene Systems class. + * + * This class is available from within a Scene under the property `sys`. + * It is responsible for managing all of the plugins a Scene has running, including the display list, and + * handling the update step and renderer. It also contains references to global systems belonging to Game. + * + * @class Systems + * @memberOf Phaser.Scenes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene that owns this Systems instance. + * @param {(string|SettingsConfig)} config - Scene specific configuration settings. + */ +var Systems = new Class({ + + initialize: + + function Systems (scene, config) + { + /** + * [description] + * + * @name Phaser.Scenes.Systems#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#config + * @type {(string|SettingsConfig)} + * @since 3.0.0 + */ + this.config = config; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#settings + * @type {SettingsObject} + * @since 3.0.0 + */ + this.settings = Settings.create(config); + + /** + * A handy reference to the Scene canvas / context. + * + * @name Phaser.Scenes.Systems#canvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvas; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#context + * @type {CanvasRenderingContext2D} + * @since 3.0.0 + */ + this.context; + + // Global Systems - these are single-instance global managers that belong to Game + + /** + * [description] + * + * @name Phaser.Scenes.Systems#anims + * @type {Phaser.Animations.AnimationManager} + * @since 3.0.0 + */ + this.anims; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#cache + * @type {Phaser.Cache.CacheManager} + * @since 3.0.0 + */ + this.cache; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#plugins + * @type {Phaser.Plugins.PluginManager} + * @since 3.0.0 + */ + this.plugins; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#registry + * @type {Phaser.Data.DataManager} + * @since 3.0.0 + */ + this.registry; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#sound + * @type {Phaser.Sound.BaseSoundManager} + * @since 3.0.0 + */ + this.sound; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#textures + * @type {Phaser.Textures.TextureManager} + * @since 3.0.0 + */ + this.textures; + + // Core Plugins - these are non-optional Scene plugins, needed by lots of the other systems + + /** + * [description] + * + * @name Phaser.Scenes.Systems#add + * @type {Phaser.GameObjects.GameObjectFactory} + * @since 3.0.0 + */ + this.add; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#cameras + * @type {Phaser.Cameras.Scene2D.CameraManager} + * @since 3.0.0 + */ + this.cameras; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#displayList + * @type {null} + * @since 3.0.0 + */ + this.displayList; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#events + * @type {EventEmitter} + * @since 3.0.0 + */ + this.events; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#make + * @type {Phaser.GameObjects.GameObjectCreator} + * @since 3.0.0 + */ + this.make; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#scenePlugin + * @type {Phaser.Scenes.ScenePlugin} + * @since 3.0.0 + */ + this.scenePlugin; + + /** + * [description] + * + * @name Phaser.Scenes.Systems#updateList + * @type {Phaser.GameObjects.UpdateList} + * @since 3.0.0 + */ + this.updateList; + }, + + /** + * [description] + * + * @method Phaser.Scenes.Systems#init + * @since 3.0.0 + * + * @param {Phaser.Game} game - A reference to the Phaser Game + */ + init: function (game) + { + this.settings.status = CONST.INIT; + + this.game = game; + + this.canvas = game.canvas; + this.context = game.context; + + var pluginManager = game.plugins; + + this.plugins = pluginManager; + + pluginManager.installGlobal(this, Plugins.Global); + + pluginManager.installLocal(this, Plugins.CoreScene); + + pluginManager.installLocal(this, GetScenePlugins(this)); + + pluginManager.installLocal(this, GetPhysicsPlugins(this)); + + this.events.emit('boot', this); + + this.settings.isBooted = true; + }, + + /** + * [description] + * + * @method Phaser.Scenes.Systems#install + * @private + * @since 3.0.0 + * + * @param {array} plugin - An array of plugins to install into this Scene. + */ + install: function (plugin) + { + if (!Array.isArray(plugin)) + { + plugin = [ plugin ]; + } + + this.plugins.installLocal(this, plugin); + }, + + /** + * [description] + * + * @method Phaser.Scenes.Systems#step + * @since 3.0.0 + * + * @param {number} time - [description] + * @param {number} delta - [description] + */ + step: function (time, delta) + { + this.events.emit('preupdate', time, delta); + + this.events.emit('update', time, delta); + + this.scene.update.call(this.scene, time, delta); + + this.events.emit('postupdate', time, delta); + }, + + /** + * [description] + * + * @method Phaser.Scenes.Systems#render + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + */ + render: function (renderer) + { + var displayList = this.displayList; + + displayList.depthSort(); + + this.cameras.render(renderer, displayList); + + this.events.emit('render', renderer); + }, + + /** + * Force a sort of the display list on the next render. + * + * @method Phaser.Scenes.Systems#queueDepthSort + * @since 3.0.0 + */ + queueDepthSort: function () + { + this.displayList.queueDepthSort(); + }, + + /** + * Immediately sorts the display list if the flag is set. + * + * @method Phaser.Scenes.Systems#depthSort + * @since 3.0.0 + */ + depthSort: function () + { + this.displayList.depthSort(); + }, + + /** + * Pause this Scene. + * A paused Scene still renders, it just doesn't run ANY of its update handlers or systems. + * + * @method Phaser.Scenes.Systems#pause + * @since 3.0.0 + * + * @return {Phaser.Scenes.Systems} This Systems object. + */ + pause: function () + { + if (this.settings.active) + { + this.settings.status = CONST.PAUSED; + + this.settings.active = false; + + this.events.emit('pause', this); + } + + return this; + }, + + /** + * Resume this Scene. + * + * @method Phaser.Scenes.Systems#resume + * @since 3.0.0 + * + * @return {Phaser.Scenes.Systems} This Systems object. + */ + resume: function () + { + if (!this.settings.active) + { + this.settings.status = CONST.RUNNING; + + this.settings.active = true; + + this.events.emit('resume', this); + } + + return this; + }, + + /** + * Send this Scene to sleep. + * + * A sleeping Scene doesn't run it's update step or render anything, but it also isn't destroyed, + * or have any of its systems or children removed, meaning it can be re-activated at any point. + * + * @method Phaser.Scenes.Systems#sleep + * @since 3.0.0 + * + * @return {Phaser.Scenes.Systems} This Systems object. + */ + sleep: function () + { + this.settings.status = CONST.SLEEPING; + + this.settings.active = false; + this.settings.visible = false; + + this.events.emit('sleep', this); + + return this; + }, + + /** + * Wake-up this Scene if it was previously asleep. + * + * @method Phaser.Scenes.Systems#wake + * @since 3.0.0 + * + * @return {Phaser.Scenes.Systems} This Systems object. + */ + wake: function () + { + this.settings.status = CONST.RUNNING; + + this.settings.active = true; + this.settings.visible = true; + + this.events.emit('wake', this); + + return this; + }, + + /** + * Is this Scene sleeping? + * + * @method Phaser.Scenes.Systems#isSleeping + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isSleeping: function () + { + return (this.settings.status === CONST.SLEEPING); + }, + + /** + * Is this Scene active? + * + * @method Phaser.Scenes.Systems#isActive + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isActive: function () + { + return (this.settings.status === CONST.RUNNING); + }, + + /** + * Is this Scene visible and rendering? + * + * @method Phaser.Scenes.Systems#isVisible + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isVisible: function () + { + return this.settings.visible; + }, + + /** + * [description] + * + * @method Phaser.Scenes.Systems#setVisible + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.Scenes.Systems} This Systems object. + */ + setVisible: function (value) + { + this.settings.visible = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.Systems#setActive + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.Scenes.Systems} This Systems object. + */ + setActive: function (value) + { + if (value) + { + return this.resume(); + } + else + { + return this.pause(); + } + }, + + /** + * Start this Scene running and rendering. + * + * @method Phaser.Scenes.Systems#start + * @since 3.0.0 + * + * @param {object} data - [description] + */ + start: function (data) + { + this.settings.status = CONST.START; + + this.settings.data = data; + + this.settings.active = true; + this.settings.visible = true; + + this.events.emit('start', this); + }, + + /** + * Called automatically by the SceneManager if the Game resizes. + * Dispatches an event you can respond to in your game code. + * + * @method Phaser.Scenes.Systems#resize + * @since 3.2.0 + * + * @param {number} width - The new width of the game. + * @param {number} height - The new height of the game. + */ + resize: function (width, height) + { + this.events.emit('resize', width, height); + }, + + /** + * Shutdown this Scene and send a shutdown event to all of its systems. + * + * @method Phaser.Scenes.Systems#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.settings.status = CONST.SHUTDOWN; + + this.settings.active = false; + this.settings.visible = false; + + this.events.emit('shutdown', this); + }, + + /** + * Destroy this Scene and send a destroy event all of its systems. + * + * @method Phaser.Scenes.Systems#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.settings.status = CONST.DESTROYED; + + this.settings.active = false; + this.settings.visible = false; + + this.events.emit('destroy', this); + } + +}); + +module.exports = Systems; + + +/***/ }), +/* 143 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +module.exports = { + + /** + * @name Phaser.Input.Keyboard.KeyCodes.BACKSPACE + * @type {integer} + * @since 3.0.0 + */ + BACKSPACE: 8, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.TAB + * @type {integer} + * @since 3.0.0 + */ + TAB: 9, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.ENTER + * @type {integer} + * @since 3.0.0 + */ + ENTER: 13, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.SHIFT + * @type {integer} + * @since 3.0.0 + */ + SHIFT: 16, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.CTRL + * @type {integer} + * @since 3.0.0 + */ + CTRL: 17, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.ALT + * @type {integer} + * @since 3.0.0 + */ + ALT: 18, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PAUSE + * @type {integer} + * @since 3.0.0 + */ + PAUSE: 19, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.CAPS_LOCK + * @type {integer} + * @since 3.0.0 + */ + CAPS_LOCK: 20, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.ESC + * @type {integer} + * @since 3.0.0 + */ + ESC: 27, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.SPACE + * @type {integer} + * @since 3.0.0 + */ + SPACE: 32, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PAGE_UP + * @type {integer} + * @since 3.0.0 + */ + PAGE_UP: 33, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PAGE_DOWN + * @type {integer} + * @since 3.0.0 + */ + PAGE_DOWN: 34, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.END + * @type {integer} + * @since 3.0.0 + */ + END: 35, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.HOME + * @type {integer} + * @since 3.0.0 + */ + HOME: 36, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.LEFT + * @type {integer} + * @since 3.0.0 + */ + LEFT: 37, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.UP + * @type {integer} + * @since 3.0.0 + */ + UP: 38, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.RIGHT + * @type {integer} + * @since 3.0.0 + */ + RIGHT: 39, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.DOWN + * @type {integer} + * @since 3.0.0 + */ + DOWN: 40, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PRINT_SCREEN + * @type {integer} + * @since 3.0.0 + */ + PRINT_SCREEN: 42, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.INSERT + * @type {integer} + * @since 3.0.0 + */ + INSERT: 45, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.DELETE + * @type {integer} + * @since 3.0.0 + */ + DELETE: 46, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.ZERO + * @type {integer} + * @since 3.0.0 + */ + ZERO: 48, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.ONE + * @type {integer} + * @since 3.0.0 + */ + ONE: 49, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.TWO + * @type {integer} + * @since 3.0.0 + */ + TWO: 50, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.THREE + * @type {integer} + * @since 3.0.0 + */ + THREE: 51, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.FOUR + * @type {integer} + * @since 3.0.0 + */ + FOUR: 52, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.FIVE + * @type {integer} + * @since 3.0.0 + */ + FIVE: 53, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.SIX + * @type {integer} + * @since 3.0.0 + */ + SIX: 54, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.SEVEN + * @type {integer} + * @since 3.0.0 + */ + SEVEN: 55, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.EIGHT + * @type {integer} + * @since 3.0.0 + */ + EIGHT: 56, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NINE + * @type {integer} + * @since 3.0.0 + */ + NINE: 57, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.A + * @type {integer} + * @since 3.0.0 + */ + A: 65, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.B + * @type {integer} + * @since 3.0.0 + */ + B: 66, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.C + * @type {integer} + * @since 3.0.0 + */ + C: 67, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.D + * @type {integer} + * @since 3.0.0 + */ + D: 68, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.E + * @type {integer} + * @since 3.0.0 + */ + E: 69, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F + * @type {integer} + * @since 3.0.0 + */ + F: 70, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.G + * @type {integer} + * @since 3.0.0 + */ + G: 71, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.H + * @type {integer} + * @since 3.0.0 + */ + H: 72, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.I + * @type {integer} + * @since 3.0.0 + */ + I: 73, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.J + * @type {integer} + * @since 3.0.0 + */ + J: 74, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.K + * @type {integer} + * @since 3.0.0 + */ + K: 75, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.L + * @type {integer} + * @since 3.0.0 + */ + L: 76, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.M + * @type {integer} + * @since 3.0.0 + */ + M: 77, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.N + * @type {integer} + * @since 3.0.0 + */ + N: 78, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.O + * @type {integer} + * @since 3.0.0 + */ + O: 79, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.P + * @type {integer} + * @since 3.0.0 + */ + P: 80, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.Q + * @type {integer} + * @since 3.0.0 + */ + Q: 81, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.R + * @type {integer} + * @since 3.0.0 + */ + R: 82, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.S + * @type {integer} + * @since 3.0.0 + */ + S: 83, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.T + * @type {integer} + * @since 3.0.0 + */ + T: 84, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.U + * @type {integer} + * @since 3.0.0 + */ + U: 85, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.V + * @type {integer} + * @since 3.0.0 + */ + V: 86, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.W + * @type {integer} + * @since 3.0.0 + */ + W: 87, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.X + * @type {integer} + * @since 3.0.0 + */ + X: 88, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.Y + * @type {integer} + * @since 3.0.0 + */ + Y: 89, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.Z + * @type {integer} + * @since 3.0.0 + */ + Z: 90, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F1 + * @type {integer} + * @since 3.0.0 + */ + F1: 112, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F2 + * @type {integer} + * @since 3.0.0 + */ + F2: 113, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F3 + * @type {integer} + * @since 3.0.0 + */ + F3: 114, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F4 + * @type {integer} + * @since 3.0.0 + */ + F4: 115, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F5 + * @type {integer} + * @since 3.0.0 + */ + F5: 116, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F6 + * @type {integer} + * @since 3.0.0 + */ + F6: 117, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F7 + * @type {integer} + * @since 3.0.0 + */ + F7: 118, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F8 + * @type {integer} + * @since 3.0.0 + */ + F8: 119, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F9 + * @type {integer} + * @since 3.0.0 + */ + F9: 120, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F10 + * @type {integer} + * @since 3.0.0 + */ + F10: 121, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F11 + * @type {integer} + * @since 3.0.0 + */ + F11: 122, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F12 + * @type {integer} + * @since 3.0.0 + */ + F12: 123, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.SEMICOLON + * @type {integer} + * @since 3.0.0 + */ + SEMICOLON: 186, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PLUS + * @type {integer} + * @since 3.0.0 + */ + PLUS: 187, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.COMMA + * @type {integer} + * @since 3.0.0 + */ + COMMA: 188, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.MINUS + * @type {integer} + * @since 3.0.0 + */ + MINUS: 189, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PERIOD + * @type {integer} + * @since 3.0.0 + */ + PERIOD: 190, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.FORWARD_SLASH + * @type {integer} + * @since 3.0.0 + */ + FORWARD_SLASH: 191, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.BACK_SLASH + * @type {integer} + * @since 3.0.0 + */ + BACK_SLASH: 220, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.QUOTES + * @type {integer} + * @since 3.0.0 + */ + QUOTES: 222, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.BACKTICK + * @type {integer} + * @since 3.0.0 + */ + BACKTICK: 192, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.OPEN_BRACKET + * @type {integer} + * @since 3.0.0 + */ + OPEN_BRACKET: 219, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.CLOSED_BRACKET + * @type {integer} + * @since 3.0.0 + */ + CLOSED_BRACKET: 221 + +}; + + +/***/ }), +/* 144 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.GameObjects.Graphics.Commands + */ + +module.exports = { + + ARC: 0, + BEGIN_PATH: 1, + CLOSE_PATH: 2, + FILL_RECT: 3, + LINE_TO: 4, + MOVE_TO: 5, + LINE_STYLE: 6, + FILL_STYLE: 7, + FILL_PATH: 8, + STROKE_PATH: 9, + FILL_TRIANGLE: 10, + STROKE_TRIANGLE: 11, + LINE_FX_TO: 12, + MOVE_FX_TO: 13, + SAVE: 14, + RESTORE: 15, + TRANSLATE: 16, + SCALE: 17, + ROTATE: 18 + +}; + + +/***/ }), +/* 145 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Checks if the given `width` and `height` are a power of two. + * Useful for checking texture dimensions. + * + * @function Phaser.Math.Pow2.IsSizePowerOfTwo + * @since 3.0.0 + * + * @param {number} width - The width. + * @param {number} height - The height. + * + * @return {boolean} `true` if `width` and `height` are a power of two, otherwise `false`. + */ +var IsSizePowerOfTwo = function (width, height) +{ + return (width > 0 && (width & (width - 1)) === 0 && height > 0 && (height & (height - 1)) === 0); +}; + +module.exports = IsSizePowerOfTwo; + + +/***/ }), +/* 146 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var OS = __webpack_require__(76); +var Browser = __webpack_require__(100); +var CanvasPool = __webpack_require__(23); + +/** + * Determines the features of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.features` from within any Scene. + * + * @name Phaser.Device.Features + * @since 3.0.0 + * + * @type {object} + * @property {?boolean} canvasBitBltShift - True if canvas supports a 'copy' bitblt onto itself when the source and destination regions overlap. + * @property {boolean} canvas - Is canvas available? + * @property {boolean} file - Is file available? + * @property {boolean} fileSystem - Is fileSystem available? + * @property {boolean} getUserMedia - Does the device support the getUserMedia API? + * @property {boolean} littleEndian - Is the device big or little endian? (only detected if the browser supports TypedArrays) + * @property {boolean} localStorage - Is localStorage available? + * @property {boolean} pointerLock - Is Pointer Lock available? + * @property {boolean} support32bit - Does the device context support 32bit pixel manipulation using array buffer views? + * @property {boolean} vibration - Does the device support the Vibration API? + * @property {boolean} webGL - Is webGL available? + * @property {boolean} worker - Is worker available? + */ +var Features = { + + canvas: false, + canvasBitBltShift: null, + file: false, + fileSystem: false, + getUserMedia: true, + littleEndian: false, + localStorage: false, + pointerLock: false, + support32bit: false, + vibration: false, + webGL: false, + worker: false + +}; + +// Check Little or Big Endian system. +// @author Matt DesLauriers (@mattdesl) +function checkIsLittleEndian () +{ + var a = new ArrayBuffer(4); + var b = new Uint8Array(a); + var c = new Uint32Array(a); + + b[0] = 0xa1; + b[1] = 0xb2; + b[2] = 0xc3; + b[3] = 0xd4; + + if (c[0] === 0xd4c3b2a1) + { + return true; + } + + if (c[0] === 0xa1b2c3d4) + { + return false; + } + else + { + // Could not determine endianness + return null; + } +} + +function init () +{ + Features.canvas = !!window['CanvasRenderingContext2D'] || OS.cocoonJS; + + try + { + Features.localStorage = !!localStorage.getItem; + } + catch (error) + { + Features.localStorage = false; + } + + Features.file = !!window['File'] && !!window['FileReader'] && !!window['FileList'] && !!window['Blob']; + Features.fileSystem = !!window['requestFileSystem']; + + var isUint8 = false; + + var testWebGL = function () + { + if (window['WebGLRenderingContext']) + { + try + { + var canvas = CanvasPool.createWebGL(this); + + if (OS.cocoonJS) + { + canvas.screencanvas = false; + } + + var ctx = canvas.getContext('webgl') || canvas.getContext('experimental-webgl'); + + var canvas2D = CanvasPool.create2D(this); + + var ctx2D = canvas2D.getContext('2d'); + + // Can't be done on a webgl context + var image = ctx2D.createImageData(1, 1); + + // Test to see if ImageData uses CanvasPixelArray or Uint8ClampedArray. + // @author Matt DesLauriers (@mattdesl) + isUint8 = image.data instanceof Uint8ClampedArray; + + CanvasPool.remove(canvas); + CanvasPool.remove(canvas2D); + + return !!ctx; + } + catch (e) + { + return false; + } + } + + return false; + }; + + Features.webGL = testWebGL(); + + Features.worker = !!window['Worker']; + + Features.pointerLock = 'pointerLockElement' in document || 'mozPointerLockElement' in document || 'webkitPointerLockElement' in document; + + navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia; + + window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL; + + Features.getUserMedia = Features.getUserMedia && !!navigator.getUserMedia && !!window.URL; + + // Older versions of firefox (< 21) apparently claim support but user media does not actually work + if (Browser.firefox && Browser.firefoxVersion < 21) + { + Features.getUserMedia = false; + } + + // Excludes iOS versions as they generally wrap UIWebView (eg. Safari WebKit) and it + // is safer to not try and use the fast copy-over method. + if (!OS.iOS && (Browser.ie || Browser.firefox || Browser.chrome)) + { + Features.canvasBitBltShift = true; + } + + // Known not to work + if (Browser.safari || Browser.mobileSafari) + { + Features.canvasBitBltShift = false; + } + + navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate; + + if (navigator.vibrate) + { + Features.vibration = true; + } + + if (typeof ArrayBuffer !== 'undefined' && typeof Uint8Array !== 'undefined' && typeof Uint32Array !== 'undefined') + { + Features.littleEndian = checkIsLittleEndian(); + } + + Features.support32bit = ( + typeof ArrayBuffer !== 'undefined' && + typeof Uint8ClampedArray !== 'undefined' && + typeof Int32Array !== 'undefined' && + Features.littleEndian !== null && + isUint8 + ); + + return Features; +} + +module.exports = init(); + + +/***/ }), +/* 147 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Adds the given element to the DOM. If a parent is provided the element is added as a child of the parent, providing it was able to access it. + * If no parent was given or falls back to using `document.body`. + * + * @function Phaser.DOM.AddToDOM + * @since 3.0.0 + * + * @param {HTMLElement} element - The element to be added to the DOM. Usually a Canvas object. + * @param {(string|HTMLElement)} [parent] - The parent in which to add the element. Can be a string which is passed to `getElementById` or an actual DOM object. + * @param {boolean} [overflowHidden=true] - [description] + * + * @return {HTMLElement} The element that was added to the DOM. + */ +var AddToDOM = function (element, parent, overflowHidden) +{ + if (overflowHidden === undefined) { overflowHidden = true; } + + var target; + + if (parent) + { + if (typeof parent === 'string') + { + // Hopefully an element ID + target = document.getElementById(parent); + } + else if (typeof parent === 'object' && parent.nodeType === 1) + { + // Quick test for a HTMLelement + target = parent; + } + } + + // Fallback, covers an invalid ID and a non HTMLelement object + if (!target) + { + target = document.body; + } + + if (overflowHidden && target.style) + { + target.style.overflow = 'hidden'; + } + + target.appendChild(element); + + return element; +}; + +module.exports = AddToDOM; + + +/***/ }), +/* 148 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Linear + * @since 3.0.0 + * + * @param {number} p0 - [description] + * @param {number} p1 - [description] + * @param {float} t - [description] + * + * @return {number} [description] + */ +var Linear = function (p0, p1, t) +{ + return (p1 - p0) * t + p0; +}; + +module.exports = Linear; + + +/***/ }), +/* 149 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.CatmullRom + * @since 3.0.0 + * + * @param {number} t - [description] + * @param {number} p0 - [description] + * @param {number} p1 - [description] + * @param {number} p2 - [description] + * @param {number} p3 - [description] + * + * @return {number} [description] + */ +var CatmullRom = function (t, p0, p1, p2, p3) +{ + var v0 = (p2 - p0) * 0.5; + var v1 = (p3 - p1) * 0.5; + var t2 = t * t; + var t3 = t * t2; + + return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; +}; + +module.exports = CatmullRom; + + +/***/ }), +/* 150 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(10); + +// points is an array of Point-like objects, +// either 2 dimensional arrays, or objects with public x/y properties: +// var points = [ +// [100, 200], +// [200, 400], +// { x: 30, y: 60 } +// ] + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.FromPoints + * @since 3.0.0 + * + * @param {array} points - [description] + * @param {Phaser.Geom.Rectangle} out - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var FromPoints = function (points, out) +{ + if (out === undefined) { out = new Rectangle(); } + + if (points.length === 0) + { + return out; + } + + var minX = Number.MAX_VALUE; + var minY = Number.MAX_VALUE; + + var maxX = Number.MIN_SAFE_INTEGER; + var maxY = Number.MIN_SAFE_INTEGER; + + var p; + var px; + var py; + + for (var i = 0; i < points.length; i++) + { + p = points[i]; + + if (Array.isArray(p)) + { + px = p[0]; + py = p[1]; + } + else + { + px = p.x; + py = p.y; + } + + minX = Math.min(minX, px); + minY = Math.min(minY, py); + + maxX = Math.max(maxX, px); + maxY = Math.max(maxY, py); + } + + out.x = minX; + out.y = minY; + out.width = maxX - minX; + out.height = maxY - minY; + + return out; +}; + +module.exports = FromPoints; + + +/***/ }), +/* 151 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Browser specific prefix, so not going to change between contexts, only between browsers +var prefix = ''; + +/** + * @namespace Phaser.Display.Canvas.Smoothing + * @since 3.0.0 + */ +var Smoothing = function () +{ + /** + * Gets the Smoothing Enabled vendor prefix being used on the given context, or null if not set. + * + * @function Phaser.Display.Canvas.Smoothing.getPrefix + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * + * @return {string} [description] + */ + var getPrefix = function (context) + { + var vendors = [ 'i', 'webkitI', 'msI', 'mozI', 'oI' ]; + + for (var i = 0; i < vendors.length; i++) + { + var s = vendors[i] + 'mageSmoothingEnabled'; + + if (s in context) + { + return s; + } + } + + return null; + }; + + /** + * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. + * By default browsers have image smoothing enabled, which isn't always what you visually want, especially + * when using pixel art in a game. Note that this sets the property on the context itself, so that any image + * drawn to the context will be affected. This sets the property across all current browsers but support is + * patchy on earlier browsers, especially on mobile. + * + * @function Phaser.Display.Canvas.Smoothing.enable + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * + * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} [description] + */ + var enable = function (context) + { + if (prefix === '') + { + prefix = getPrefix(context); + } + + if (prefix) + { + context[prefix] = true; + } + + return context; + }; + + /** + * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. + * By default browsers have image smoothing enabled, which isn't always what you visually want, especially + * when using pixel art in a game. Note that this sets the property on the context itself, so that any image + * drawn to the context will be affected. This sets the property across all current browsers but support is + * patchy on earlier browsers, especially on mobile. + * + * @function Phaser.Display.Canvas.Smoothing.disable + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * + * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} [description] + */ + var disable = function (context) + { + if (prefix === '') + { + prefix = getPrefix(context); + } + + if (prefix) + { + context[prefix] = false; + } + + return context; + }; + + /** + * Returns `true` if the given context has image smoothing enabled, otherwise returns `false`. + * Returns null if no smoothing prefix is available. + * + * @function Phaser.Display.Canvas.Smoothing.isEnabled + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * + * @return {?boolean} [description] + */ + var isEnabled = function (context) + { + return (prefix !== null) ? context[prefix] : null; + }; + + return { + disable: disable, + enable: enable, + getPrefix: getPrefix, + isEnabled: isEnabled + }; + +}; + +module.exports = Smoothing(); + + +/***/ }), +/* 152 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); + +/** + * @classdesc + * [description] + * + * @class Vector4 + * @memberOf Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {number} [x] - [description] + * @param {number} [y] - [description] + * @param {number} [z] - [description] + * @param {number} [w] - [description] + */ +var Vector4 = new Class({ + + initialize: + + function Vector4 (x, y, z, w) + { + /** + * The x component of this Vector. + * + * @name Phaser.Math.Vector4#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The y component of this Vector. + * + * @name Phaser.Math.Vector4#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The z component of this Vector. + * + * @name Phaser.Math.Vector4#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The w component of this Vector. + * + * @name Phaser.Math.Vector4#w + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Vector4} [description] + */ + clone: function () + { + return new Vector4(this.x, this.y, this.z, this.w); + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#copy + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} src - [description] + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + copy: function (src) + { + this.x = src.x; + this.y = src.y; + this.z = src.z || 0; + this.w = src.w || 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#equals + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} v - [description] + * + * @return {boolean} [description] + */ + equals: function (v) + { + return ((this.x === v.x) && (this.y === v.y) && (this.z === v.z) && (this.w === v.w)); + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#set + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} z - [description] + * @param {number} w - [description] + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + set: function (x, y, z, w) + { + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#add + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + add: function (v) + { + this.x += v.x; + this.y += v.y; + this.z += v.z || 0; + this.w += v.w || 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#subtract + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + subtract: function (v) + { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z || 0; + this.w -= v.w || 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#scale + * @since 3.0.0 + * + * @param {number} scale - [description] + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + scale: function (scale) + { + this.x *= scale; + this.y *= scale; + this.z *= scale; + this.w *= scale; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#length + * @since 3.0.0 + * + * @return {number} [description] + */ + length: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return Math.sqrt(x * x + y * y + z * z + w * w); + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#lengthSq + * @since 3.0.0 + * + * @return {number} [description] + */ + lengthSq: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return x * x + y * y + z * z + w * w; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#normalize + * @since 3.0.0 + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + normalize: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + var len = x * x + y * y + z * z + w * w; + + if (len > 0) + { + len = 1 / Math.sqrt(len); + + this.x = x * len; + this.y = y * len; + this.z = z * len; + this.w = w * len; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#dot + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} v - [description] + * + * @return {number} [description] + */ + dot: function (v) + { + return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#lerp + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} v - [description] + * @param {number} [t=0] - [description] + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + lerp: function (v, t) + { + if (t === undefined) { t = 0; } + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + this.x = ax + t * (v.x - ax); + this.y = ay + t * (v.y - ay); + this.z = az + t * (v.z - az); + this.w = aw + t * (v.w - aw); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#multiply + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + multiply: function (v) + { + this.x *= v.x; + this.y *= v.y; + this.z *= v.z || 1; + this.w *= v.w || 1; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#divide + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + divide: function (v) + { + this.x /= v.x; + this.y /= v.y; + this.z /= v.z || 1; + this.w /= v.w || 1; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#distance + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] + * + * @return {number} [description] + */ + distance: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + var dw = v.w - this.w || 0; + + return Math.sqrt(dx * dx + dy * dy + dz * dz + dw * dw); + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#distanceSq + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] + * + * @return {number} [description] + */ + distanceSq: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + var dw = v.w - this.w || 0; + + return dx * dx + dy * dy + dz * dz + dw * dw; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#negate + * @since 3.0.0 + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + negate: function () + { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + this.w = -this.w; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#transformMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - [description] + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + transformMat4: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + var m = mat.val; + + this.x = m[0] * x + m[4] * y + m[8] * z + m[12] * w; + this.y = m[1] * x + m[5] * y + m[9] * z + m[13] * w; + this.z = m[2] * x + m[6] * y + m[10] * z + m[14] * w; + this.w = m[3] * x + m[7] * y + m[11] * z + m[15] * w; + + return this; + }, + + // TODO: is this really the same as Vector3? + // Also, what about this: http://molecularmusings.wordpress.com/2013/05/24/a-faster-quaternion-vector-multiplication/ + + /** + * [description] + * + * @method Phaser.Math.Vector4#transformQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - [description] + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + transformQuat: function (q) + { + // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations + var x = this.x; + var y = this.y; + var z = this.z; + var qx = q.x; + var qy = q.y; + var qz = q.z; + var qw = q.w; + + // calculate quat * vec + var ix = qw * x + qy * z - qz * y; + var iy = qw * y + qz * x - qx * z; + var iz = qw * z + qx * y - qy * x; + var iw = -qx * x - qy * y - qz * z; + + // calculate result * inverse quat + this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; + this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; + this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector4#reset + * @since 3.0.0 + * + * @return {Phaser.Math.Vector4} This Vector4 object. + */ + reset: function () + { + this.x = 0; + this.y = 0; + this.z = 0; + this.w = 0; + + return this; + } + +}); + +// TODO: Check if these are required internally, if not, remove. +Vector4.prototype.sub = Vector4.prototype.subtract; +Vector4.prototype.mul = Vector4.prototype.multiply; +Vector4.prototype.div = Vector4.prototype.divide; +Vector4.prototype.dist = Vector4.prototype.distance; +Vector4.prototype.distSq = Vector4.prototype.distanceSq; +Vector4.prototype.len = Vector4.prototype.length; +Vector4.prototype.lenSq = Vector4.prototype.lengthSq; + +module.exports = Vector4; + + /***/ }), /* 153 */ /***/ (function(module, exports, __webpack_require__) { @@ -33846,69 +32323,1396 @@ var Body = __webpack_require__(60); * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetTileAt = __webpack_require__(97); +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); + +var EPSILON = 0.000001; /** - * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting - * faces are used internally for optimizing collisions against tiles. This method is mostly used - * internally to optimize recalculating faces when only one tile has been changed. + * @classdesc + * [description] * - * @function Phaser.Tilemaps.Components.CalculateFacesAt + * @class Matrix4 + * @memberOf Phaser.Math + * @constructor * @since 3.0.0 - * - * @param {integer} tileX - The x coordinate. - * @param {integer} tileY - The y coordinate. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @param {Phaser.Math.Matrix4} [m] - [description] */ -var CalculateFacesAt = function (tileX, tileY, layer) -{ - var tile = GetTileAt(tileX, tileY, true, layer); - var above = GetTileAt(tileX, tileY - 1, true, layer); - var below = GetTileAt(tileX, tileY + 1, true, layer); - var left = GetTileAt(tileX - 1, tileY, true, layer); - var right = GetTileAt(tileX + 1, tileY, true, layer); - var tileCollides = tile && tile.collides; +var Matrix4 = new Class({ - // Assume the changed tile has all interesting edges - if (tileCollides) + initialize: + + function Matrix4 (m) { - tile.faceBottom = true; - tile.faceBottom = true; - tile.faceLeft = true; - tile.faceRight = true; + /** + * [description] + * + * @name Phaser.Math.Matrix4#val + * @type {Float32Array} + * @since 3.0.0 + */ + this.val = new Float32Array(16); + + if (m) + { + // Assume Matrix4 with val: + this.copy(m); + } + else + { + // Default to identity + this.identity(); + } + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} A new Matrix4 object. + */ + clone: function () + { + return new Matrix4(this); + }, + + // TODO - Should work with basic values + + /** + * [description] + * + * @method Phaser.Math.Matrix4#set + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + set: function (src) + { + return this.copy(src); + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#copy + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + copy: function (src) + { + var out = this.val; + var a = src.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#fromArray + * @since 3.0.0 + * + * @param {array} a - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + fromArray: function (a) + { + var out = this.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#zero + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + zero: function () + { + var out = this.val; + + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 0; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#xyz + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} z - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + xyz: function (x, y, z) + { + this.identity(); + + var out = this.val; + + out[12] = x; + out[13] = y; + out[14] = z; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#scaling + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} z - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + scaling: function (x, y, z) + { + this.zero(); + + var out = this.val; + + out[0] = x; + out[5] = y; + out[10] = z; + out[15] = 1; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#identity + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + identity: function () + { + var out = this.val; + + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 1; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 1; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#transpose + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + transpose: function () + { + var a = this.val; + + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + var a12 = a[6]; + var a13 = a[7]; + var a23 = a[11]; + + a[1] = a[4]; + a[2] = a[8]; + a[3] = a[12]; + a[4] = a01; + a[6] = a[9]; + a[7] = a[13]; + a[8] = a02; + a[9] = a12; + a[11] = a[14]; + a[12] = a03; + a[13] = a13; + a[14] = a23; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#invert + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + invert: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + + if (!det) + { + return null; + } + + det = 1 / det; + + a[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + a[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + a[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + a[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; + a[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + a[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + a[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + a[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; + a[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + a[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + a[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; + a[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; + a[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; + a[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; + a[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; + a[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#adjoint + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + adjoint: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + a[0] = (a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22)); + a[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22)); + a[2] = (a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12)); + a[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12)); + a[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22)); + a[5] = (a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22)); + a[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12)); + a[7] = (a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12)); + a[8] = (a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21)); + a[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21)); + a[10] = (a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11)); + a[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11)); + a[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21)); + a[13] = (a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21)); + a[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11)); + a[15] = (a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11)); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#determinant + * @since 3.0.0 + * + * @return {number} [description] + */ + determinant: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#multiply + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + multiply: function (src) + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b = src.val; + + // Cache only the current line of the second matrix + var b0 = b[0]; + var b1 = b[1]; + var b2 = b[2]; + var b3 = b[3]; + + a[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[4]; + b1 = b[5]; + b2 = b[6]; + b3 = b[7]; + + a[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[8]; + b1 = b[9]; + b2 = b[10]; + b3 = b[11]; + + a[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[12]; + b1 = b[13]; + b2 = b[14]; + b3 = b[15]; + + a[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#multiplyLocal + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + multiplyLocal: function (src) + { + var a = []; + var m1 = this.val; + var m2 = src.val; + + a[0] = m1[0] * m2[0] + m1[1] * m2[4] + m1[2] * m2[8] + m1[3] * m2[12]; + a[1] = m1[0] * m2[1] + m1[1] * m2[5] + m1[2] * m2[9] + m1[3] * m2[13]; + a[2] = m1[0] * m2[2] + m1[1] * m2[6] + m1[2] * m2[10] + m1[3] * m2[14]; + a[3] = m1[0] * m2[3] + m1[1] * m2[7] + m1[2] * m2[11] + m1[3] * m2[15]; + + a[4] = m1[4] * m2[0] + m1[5] * m2[4] + m1[6] * m2[8] + m1[7] * m2[12]; + a[5] = m1[4] * m2[1] + m1[5] * m2[5] + m1[6] * m2[9] + m1[7] * m2[13]; + a[6] = m1[4] * m2[2] + m1[5] * m2[6] + m1[6] * m2[10] + m1[7] * m2[14]; + a[7] = m1[4] * m2[3] + m1[5] * m2[7] + m1[6] * m2[11] + m1[7] * m2[15]; + + a[8] = m1[8] * m2[0] + m1[9] * m2[4] + m1[10] * m2[8] + m1[11] * m2[12]; + a[9] = m1[8] * m2[1] + m1[9] * m2[5] + m1[10] * m2[9] + m1[11] * m2[13]; + a[10] = m1[8] * m2[2] + m1[9] * m2[6] + m1[10] * m2[10] + m1[11] * m2[14]; + a[11] = m1[8] * m2[3] + m1[9] * m2[7] + m1[10] * m2[11] + m1[11] * m2[15]; + + a[12] = m1[12] * m2[0] + m1[13] * m2[4] + m1[14] * m2[8] + m1[15] * m2[12]; + a[13] = m1[12] * m2[1] + m1[13] * m2[5] + m1[14] * m2[9] + m1[15] * m2[13]; + a[14] = m1[12] * m2[2] + m1[13] * m2[6] + m1[14] * m2[10] + m1[15] * m2[14]; + a[15] = m1[12] * m2[3] + m1[13] * m2[7] + m1[14] * m2[11] + m1[15] * m2[15]; + + return this.fromArray(a); + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#translate + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + translate: function (v) + { + var x = v.x; + var y = v.y; + var z = v.z; + var a = this.val; + + a[12] = a[0] * x + a[4] * y + a[8] * z + a[12]; + a[13] = a[1] * x + a[5] * y + a[9] * z + a[13]; + a[14] = a[2] * x + a[6] * y + a[10] * z + a[14]; + a[15] = a[3] * x + a[7] * y + a[11] * z + a[15]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#scale + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + scale: function (v) + { + var x = v.x; + var y = v.y; + var z = v.z; + var a = this.val; + + a[0] = a[0] * x; + a[1] = a[1] * x; + a[2] = a[2] * x; + a[3] = a[3] * x; + + a[4] = a[4] * y; + a[5] = a[5] * y; + a[6] = a[6] * y; + a[7] = a[7] * y; + + a[8] = a[8] * z; + a[9] = a[9] * z; + a[10] = a[10] * z; + a[11] = a[11] * z; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#makeRotationAxis + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} axis - [description] + * @param {float} angle - The angle of rotation in radians. + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + makeRotationAxis: function (axis, angle) + { + // Based on http://www.gamedev.net/reference/articles/article1199.asp + + var c = Math.cos(angle); + var s = Math.sin(angle); + var t = 1 - c; + var x = axis.x; + var y = axis.y; + var z = axis.z; + var tx = t * x; + var ty = t * y; + + this.set( + tx * x + c, tx * y - s * z, tx * z + s * y, 0, + tx * y + s * z, ty * y + c, ty * z - s * x, 0, + tx * z - s * y, ty * z + s * x, t * z * z + c, 0, + 0, 0, 0, 1 + ); + + return this; + }, + + // aka rotationAxis + /** + * [description] + * + * @method Phaser.Math.Matrix4#rotate + * @since 3.0.0 + * + * @param {float} rad - [description] + * @param {Phaser.Math.Vector3} axis - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + rotate: function (rad, axis) + { + var a = this.val; + var x = axis.x; + var y = axis.y; + var z = axis.z; + var len = Math.sqrt(x * x + y * y + z * z); + + if (Math.abs(len) < EPSILON) + { + return null; + } + + len = 1 / len; + x *= len; + y *= len; + z *= len; + + var s = Math.sin(rad); + var c = Math.cos(rad); + var t = 1 - c; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + // Construct the elements of the rotation matrix + var b00 = x * x * t + c; + var b01 = y * x * t + z * s; + var b02 = z * x * t - y * s; + + var b10 = x * y * t - z * s; + var b11 = y * y * t + c; + var b12 = z * y * t + x * s; + + var b20 = x * z * t + y * s; + var b21 = y * z * t - x * s; + var b22 = z * z * t + c; + + // Perform rotation-specific matrix multiplication + a[0] = a00 * b00 + a10 * b01 + a20 * b02; + a[1] = a01 * b00 + a11 * b01 + a21 * b02; + a[2] = a02 * b00 + a12 * b01 + a22 * b02; + a[3] = a03 * b00 + a13 * b01 + a23 * b02; + a[4] = a00 * b10 + a10 * b11 + a20 * b12; + a[5] = a01 * b10 + a11 * b11 + a21 * b12; + a[6] = a02 * b10 + a12 * b11 + a22 * b12; + a[7] = a03 * b10 + a13 * b11 + a23 * b12; + a[8] = a00 * b20 + a10 * b21 + a20 * b22; + a[9] = a01 * b20 + a11 * b21 + a21 * b22; + a[10] = a02 * b20 + a12 * b21 + a22 * b22; + a[11] = a03 * b20 + a13 * b21 + a23 * b22; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#rotateX + * @since 3.0.0 + * + * @param {float} rad - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + rotateX: function (rad) + { + var a = this.val; + var s = Math.sin(rad); + var c = Math.cos(rad); + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + // Perform axis-specific matrix multiplication + a[4] = a10 * c + a20 * s; + a[5] = a11 * c + a21 * s; + a[6] = a12 * c + a22 * s; + a[7] = a13 * c + a23 * s; + a[8] = a20 * c - a10 * s; + a[9] = a21 * c - a11 * s; + a[10] = a22 * c - a12 * s; + a[11] = a23 * c - a13 * s; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#rotateY + * @since 3.0.0 + * + * @param {float} rad - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + rotateY: function (rad) + { + var a = this.val; + var s = Math.sin(rad); + var c = Math.cos(rad); + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + // Perform axis-specific matrix multiplication + a[0] = a00 * c - a20 * s; + a[1] = a01 * c - a21 * s; + a[2] = a02 * c - a22 * s; + a[3] = a03 * c - a23 * s; + a[8] = a00 * s + a20 * c; + a[9] = a01 * s + a21 * c; + a[10] = a02 * s + a22 * c; + a[11] = a03 * s + a23 * c; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#rotateZ + * @since 3.0.0 + * + * @param {float} rad - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + rotateZ: function (rad) + { + var a = this.val; + var s = Math.sin(rad); + var c = Math.cos(rad); + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + // Perform axis-specific matrix multiplication + a[0] = a00 * c + a10 * s; + a[1] = a01 * c + a11 * s; + a[2] = a02 * c + a12 * s; + a[3] = a03 * c + a13 * s; + a[4] = a10 * c - a00 * s; + a[5] = a11 * c - a01 * s; + a[6] = a12 * c - a02 * s; + a[7] = a13 * c - a03 * s; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#fromRotationTranslation + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - [description] + * @param {Phaser.Math.Vector3} v - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + fromRotationTranslation: function (q, v) + { + // Quaternion math + var out = this.val; + + var x = q.x; + var y = q.y; + var z = q.z; + var w = q.w; + + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + + out[0] = 1 - (yy + zz); + out[1] = xy + wz; + out[2] = xz - wy; + out[3] = 0; + + out[4] = xy - wz; + out[5] = 1 - (xx + zz); + out[6] = yz + wx; + out[7] = 0; + + out[8] = xz + wy; + out[9] = yz - wx; + out[10] = 1 - (xx + yy); + out[11] = 0; + + out[12] = v.x; + out[13] = v.y; + out[14] = v.z; + out[15] = 1; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#fromQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + fromQuat: function (q) + { + var out = this.val; + + var x = q.x; + var y = q.y; + var z = q.z; + var w = q.w; + + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + + out[0] = 1 - (yy + zz); + out[1] = xy + wz; + out[2] = xz - wy; + out[3] = 0; + + out[4] = xy - wz; + out[5] = 1 - (xx + zz); + out[6] = yz + wx; + out[7] = 0; + + out[8] = xz + wy; + out[9] = yz - wx; + out[10] = 1 - (xx + yy); + out[11] = 0; + + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + + return this; + }, + + /** + * Generates a frustum matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#frustum + * @since 3.0.0 + * + * @param {number} left - The left bound of the frustum. + * @param {number} right - The right bound of the frustum. + * @param {number} bottom - The bottom bound of the frustum. + * @param {number} top - The top bound of the frustum. + * @param {number} near - The near bound of the frustum. + * @param {number} far - The far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + frustum: function (left, right, bottom, top, near, far) + { + var out = this.val; + + var rl = 1 / (right - left); + var tb = 1 / (top - bottom); + var nf = 1 / (near - far); + + out[0] = (near * 2) * rl; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = (near * 2) * tb; + out[6] = 0; + out[7] = 0; + + out[8] = (right + left) * rl; + out[9] = (top + bottom) * tb; + out[10] = (far + near) * nf; + out[11] = -1; + + out[12] = 0; + out[13] = 0; + out[14] = (far * near * 2) * nf; + out[15] = 0; + + return this; + }, + + /** + * Generates a perspective projection matrix with the given bounds. + * perspective fov lh + * + * @method Phaser.Math.Matrix4#perspective + * @since 3.0.0 + * + * @param {number} fovy - Vertical field of view in radians + * @param {number} aspect - Aspect ratio. Typically viewport width /height. + * @param {number} near - Near bound of the frustum. + * @param {number} far - Far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + perspective: function (fovy, aspect, near, far) + { + var out = this.val; + var f = 1.0 / Math.tan(fovy / 2); + var nf = 1 / (near - far); + + out[0] = f / aspect; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = f; + out[6] = 0; + out[7] = 0; + + out[8] = 0; + out[9] = 0; + out[10] = (far + near) * nf; + out[11] = -1; + + out[12] = 0; + out[13] = 0; + out[14] = (2 * far * near) * nf; + out[15] = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#perspectiveLH + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * @param {number} near - Near bound of the frustum. + * @param {number} far - Far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + perspectiveLH: function (width, height, near, far) + { + var out = this.val; + + out[0] = (2 * near) / width; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = (2 * near) / height; + out[6] = 0; + out[7] = 0; + + out[8] = 0; + out[9] = 0; + out[10] = -far / (near - far); + out[11] = 1; + + out[12] = 0; + out[13] = 0; + out[14] = (near * far) / (near - far); + out[15] = 0; + + return this; + }, + + /** + * Generates a orthogonal projection matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#ortho + * @since 3.0.0 + * + * @param {number} left - The left bound of the frustum. + * @param {number} right - The right bound of the frustum. + * @param {number} bottom - The bottom bound of the frustum. + * @param {number} top - The top bound of the frustum. + * @param {number} near - The near bound of the frustum. + * @param {number} far - The far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + ortho: function (left, right, bottom, top, near, far) + { + var out = this.val; + var lr = left - right; + var bt = bottom - top; + var nf = near - far; + + // Avoid division by zero + lr = (lr === 0) ? lr : 1 / lr; + bt = (bt === 0) ? bt : 1 / bt; + nf = (nf === 0) ? nf : 1 / nf; + + out[0] = -2 * lr; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = -2 * bt; + out[6] = 0; + out[7] = 0; + + out[8] = 0; + out[9] = 0; + out[10] = 2 * nf; + out[11] = 0; + + out[12] = (left + right) * lr; + out[13] = (top + bottom) * bt; + out[14] = (far + near) * nf; + out[15] = 1; + + return this; + }, + + /** + * Generates a look-at matrix with the given eye position, focal point, and up axis. + * + * @method Phaser.Math.Matrix4#lookAt + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} eye - Position of the viewer + * @param {Phaser.Math.Vector3} center - Point the viewer is looking at + * @param {Phaser.Math.Vector3} up - vec3 pointing up. + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + lookAt: function (eye, center, up) + { + var out = this.val; + + var eyex = eye.x; + var eyey = eye.y; + var eyez = eye.z; + + var upx = up.x; + var upy = up.y; + var upz = up.z; + + var centerx = center.x; + var centery = center.y; + var centerz = center.z; + + if (Math.abs(eyex - centerx) < EPSILON && + Math.abs(eyey - centery) < EPSILON && + Math.abs(eyez - centerz) < EPSILON) + { + return this.identity(); + } + + var z0 = eyex - centerx; + var z1 = eyey - centery; + var z2 = eyez - centerz; + + var len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2); + + z0 *= len; + z1 *= len; + z2 *= len; + + var x0 = upy * z2 - upz * z1; + var x1 = upz * z0 - upx * z2; + var x2 = upx * z1 - upy * z0; + + len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2); + + if (!len) + { + x0 = 0; + x1 = 0; + x2 = 0; + } + else + { + len = 1 / len; + x0 *= len; + x1 *= len; + x2 *= len; + } + + var y0 = z1 * x2 - z2 * x1; + var y1 = z2 * x0 - z0 * x2; + var y2 = z0 * x1 - z1 * x0; + + len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2); + + if (!len) + { + y0 = 0; + y1 = 0; + y2 = 0; + } + else + { + len = 1 / len; + y0 *= len; + y1 *= len; + y2 *= len; + } + + out[0] = x0; + out[1] = y0; + out[2] = z0; + out[3] = 0; + + out[4] = x1; + out[5] = y1; + out[6] = z1; + out[7] = 0; + + out[8] = x2; + out[9] = y2; + out[10] = z2; + out[11] = 0; + + out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez); + out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez); + out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez); + out[15] = 1; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#yawPitchRoll + * @since 3.0.0 + * + * @param {number} yaw - [description] + * @param {number} pitch - [description] + * @param {number} roll - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + yawPitchRoll: function (yaw, pitch, roll) + { + this.zero(); + _tempMat1.zero(); + _tempMat2.zero(); + + var m0 = this.val; + var m1 = _tempMat1.val; + var m2 = _tempMat2.val; + + // Rotate Z + var s = Math.sin(roll); + var c = Math.cos(roll); + + m0[10] = 1; + m0[15] = 1; + m0[0] = c; + m0[1] = s; + m0[4] = -s; + m0[5] = c; + + // Rotate X + s = Math.sin(pitch); + c = Math.cos(pitch); + + m1[0] = 1; + m1[15] = 1; + m1[5] = c; + m1[10] = c; + m1[9] = -s; + m1[6] = s; + + // Rotate Y + s = Math.sin(yaw); + c = Math.cos(yaw); + + m2[5] = 1; + m2[15] = 1; + m2[0] = c; + m2[2] = -s; + m2[8] = s; + m2[10] = c; + + this.multiplyLocal(_tempMat1); + this.multiplyLocal(_tempMat2); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#setWorldMatrix + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} rotation - [description] + * @param {Phaser.Math.Vector3} position - [description] + * @param {Phaser.Math.Vector3} scale - [description] + * @param {Phaser.Math.Matrix4} [viewMatrix] - [description] + * @param {Phaser.Math.Matrix4} [projectionMatrix] - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4 object. + */ + setWorldMatrix: function (rotation, position, scale, viewMatrix, projectionMatrix) + { + this.yawPitchRoll(rotation.y, rotation.x, rotation.z); + + _tempMat1.scaling(scale.x, scale.y, scale.z); + _tempMat2.xyz(position.x, position.y, position.z); + + this.multiplyLocal(_tempMat1); + this.multiplyLocal(_tempMat2); + + if (viewMatrix !== undefined) + { + this.multiplyLocal(viewMatrix); + } + + if (projectionMatrix !== undefined) + { + this.multiplyLocal(projectionMatrix); + } + + return this; } - // Reset edges that are shared between tile and its neighbors - if (above && above.collides) - { - if (tileCollides) { tile.faceTop = false; } - above.faceBottom = !tileCollides; - } +}); - if (below && below.collides) - { - if (tileCollides) { tile.faceBottom = false; } - below.faceTop = !tileCollides; - } +var _tempMat1 = new Matrix4(); +var _tempMat2 = new Matrix4(); - if (left && left.collides) - { - if (tileCollides) { tile.faceLeft = false; } - left.faceRight = !tileCollides; - } - - if (right && right.collides) - { - if (tileCollides) { tile.faceRight = false; } - right.faceLeft = !tileCollides; - } - - if (tile && !tile.collides) { tile.resetFaces(); } - - return tile; -}; - -module.exports = CalculateFacesAt; +module.exports = Matrix4; /***/ }), @@ -33921,73 +33725,1069 @@ module.exports = CalculateFacesAt; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Tile = __webpack_require__(44); -var IsInLayerBounds = __webpack_require__(74); -var CalculateFacesAt = __webpack_require__(153); -var SetTileCollision = __webpack_require__(43); +var Class = __webpack_require__(0); +var Matrix4 = __webpack_require__(153); +var RandomXYZ = __webpack_require__(330); +var RandomXYZW = __webpack_require__(329); +var RotateVec3 = __webpack_require__(328); +var Set = __webpack_require__(63); +var Sprite3D = __webpack_require__(101); +var Vector2 = __webpack_require__(6); +var Vector3 = __webpack_require__(57); +var Vector4 = __webpack_require__(152); + +// Local cache vars +var tmpVec3 = new Vector3(); +var tmpVec4 = new Vector4(); +var dirvec = new Vector3(); +var rightvec = new Vector3(); +var billboardMatrix = new Matrix4(); + +// @author attribute https://github.com/mattdesl/cam3d/wiki /** - * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index - * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified - * location. If you pass in an index, only the index at the specified location will be changed. - * Collision information will be recalculated at the specified location. + * @typedef {object} RayDef * - * @function Phaser.Tilemaps.Components.PutTileAt + * @property {Phaser.Math.Vector3} origin - [description] + * @property {Phaser.Math.Vector3} direction - [description] + */ + +/** + * @classdesc + * [description] + * + * @class Camera + * @memberOf Phaser.Cameras.Sprite3D + * @constructor * @since 3.0.0 * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map. + * @param {Phaser.Scene} scene - [description] */ -var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer) -{ - if (!IsInLayerBounds(tileX, tileY, layer)) { return null; } - if (recalculateFaces === undefined) { recalculateFaces = true; } +var Camera = new Class({ - var oldTile = layer.data[tileY][tileX]; - var oldTileCollides = oldTile && oldTile.collides; + initialize: - if (tile instanceof Tile) + function Camera (scene) { - if (layer.data[tileY][tileX] === null) + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#displayList + * @type {Phaser.GameObjects.DisplayList} + * @since 3.0.0 + */ + this.displayList = scene.sys.displayList; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#updateList + * @type {Phaser.GameObjects.UpdateList} + * @since 3.0.0 + */ + this.updateList = scene.sys.updateList; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#direction + * @type {Phaser.Math.Vector3} + * @since 3.0.0 + */ + this.direction = new Vector3(0, 0, -1); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#up + * @type {Phaser.Math.Vector3} + * @since 3.0.0 + */ + this.up = new Vector3(0, 1, 0); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#position + * @type {Phaser.Math.Vector3} + * @since 3.0.0 + */ + this.position = new Vector3(); + + // The mapping from 3D size units to pixels. + // In the default case 1 3D unit = 128 pixels. So a sprite that is + // 256 x 128 px in size will be 2 x 1 units. + // Change to whatever best fits your game assets. + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#pixelScale + * @type {number} + * @since 3.0.0 + */ + this.pixelScale = 128; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#projection + * @type {Phaser.Math.Matrix4} + * @since 3.0.0 + */ + this.projection = new Matrix4(); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#view + * @type {Phaser.Math.Matrix4} + * @since 3.0.0 + */ + this.view = new Matrix4(); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#combined + * @type {Phaser.Math.Matrix4} + * @since 3.0.0 + */ + this.combined = new Matrix4(); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#invProjectionView + * @type {Phaser.Math.Matrix4} + * @since 3.0.0 + */ + this.invProjectionView = new Matrix4(); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#near + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.near = 1; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#far + * @type {number} + * @since 3.0.0 + */ + this.far = 100; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#ray + * @type {RayDef} + * @since 3.0.0 + */ + this.ray = { + origin: new Vector3(), + direction: new Vector3() + }; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#viewportWidth + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.viewportWidth = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#viewportHeight + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.viewportHeight = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#billboardMatrixDirty + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.billboardMatrixDirty = true; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#children + * @type {Phaser.Structs.Set} + * @since 3.0.0 + */ + this.children = new Set(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#setPosition + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} z - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + setPosition: function (x, y, z) + { + this.position.set(x, y, z); + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#setScene + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + setScene: function (scene) + { + this.scene = scene; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#setPixelScale + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + setPixelScale: function (value) + { + this.pixelScale = value; + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#add + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Sprite3D} sprite3D - [description] + * + * @return {Phaser.GameObjects.Sprite3D} [description] + */ + add: function (sprite3D) + { + this.children.set(sprite3D); + + this.updateChildren(); + + return sprite3D; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#remove + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + remove: function (child) + { + this.displayList.remove(child.gameObject); + this.updateList.remove(child.gameObject); + + this.children.delete(child); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#clear + * @since 3.0.0 + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + clear: function () + { + var children = this.getChildren(); + + for (var i = 0; i < children.length; i++) { - layer.data[tileY][tileX] = new Tile(layer, tile.index, tileX, tileY, tile.width, tile.height); + this.remove(children[i]); } - layer.data[tileY][tileX].copy(tile); - } - else + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#getChildren + * @since 3.0.0 + * + * @return {array} [description] + */ + getChildren: function () { - var index = tile; - if (layer.data[tileY][tileX] === null) + return this.children.entries; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#create + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} z - [description] + * @param {string} key - [description] + * @param {(string|number)} frame - [description] + * @param {boolean} [visible=true] - [description] + * + * @return {Phaser.GameObjects.Sprite3D} [description] + */ + create: function (x, y, z, key, frame, visible) + { + if (visible === undefined) { visible = true; } + + var child = new Sprite3D(this.scene, x, y, z, key, frame); + + this.displayList.add(child.gameObject); + this.updateList.add(child.gameObject); + + child.visible = visible; + + this.children.set(child); + + this.updateChildren(); + + return child; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#createMultiple + * @since 3.0.0 + * + * @param {number} quantity - [description] + * @param {string} key - [description] + * @param {(string|number)} frame - [description] + * @param {boolean} [visible=true] - [description] + * + * @return {Phaser.GameObjects.Sprite3D[]} [description] + */ + createMultiple: function (quantity, key, frame, visible) + { + if (visible === undefined) { visible = true; } + + var output = []; + + for (var i = 0; i < quantity; i++) { - layer.data[tileY][tileX] = new Tile(layer, index, tileX, tileY, layer.tileWidth, layer.tileHeight); + var child = new Sprite3D(this.scene, 0, 0, 0, key, frame); + + this.displayList.add(child.gameObject); + this.updateList.add(child.gameObject); + + child.visible = visible; + + this.children.set(child); + + output.push(child); + } + + return output; + }, + + // Create a bunch of Sprite3D objects in a rectangle + // size and spacing are Vec3s (or if integers are converted to vec3s) + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#createRect + * @since 3.0.0 + * + * @param {(number|{x:number,y:number})} size - [description] + * @param {(number|{x:number,y:number,z:number})} spacing - [description] + * @param {string} key - [description] + * @param {(string|number)} [frame] - [description] + * + * @return {Phaser.GameObjects.Sprite3D[]} [description] + */ + createRect: function (size, spacing, key, frame) + { + if (typeof size === 'number') { size = { x: size, y: size, z: size }; } + if (typeof spacing === 'number') { spacing = { x: spacing, y: spacing, z: spacing }; } + + var quantity = size.x * size.y * size.z; + + var sprites = this.createMultiple(quantity, key, frame); + + var i = 0; + + for (var z = 0.5 - (size.z / 2); z < (size.z / 2); z++) + { + for (var y = 0.5 - (size.y / 2); y < (size.y / 2); y++) + { + for (var x = 0.5 - (size.x / 2); x < (size.x / 2); x++) + { + var bx = (x * spacing.x); + var by = (y * spacing.y); + var bz = (z * spacing.z); + + sprites[i].position.set(bx, by, bz); + + i++; + } + } + } + + this.update(); + + return sprites; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#randomSphere + * @since 3.0.0 + * + * @param {number} [radius=1] - [description] + * @param {Phaser.GameObjects.Sprite3D[]} [sprites] - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + randomSphere: function (radius, sprites) + { + if (sprites === undefined) { sprites = this.getChildren(); } + + for (var i = 0; i < sprites.length; i++) + { + RandomXYZ(sprites[i].position, radius); + } + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#randomCube + * @since 3.0.0 + * + * @param {float} [scale=1] - [description] + * @param {Phaser.GameObjects.Sprite3D[]} [sprites] - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + randomCube: function (scale, sprites) + { + if (sprites === undefined) { sprites = this.getChildren(); } + + for (var i = 0; i < sprites.length; i++) + { + RandomXYZW(sprites[i].position, scale); + } + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#translateChildren + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} vec3 - [description] + * @param {Phaser.GameObjects.Sprite3D[]} sprites - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + translateChildren: function (vec3, sprites) + { + if (sprites === undefined) { sprites = this.getChildren(); } + + for (var i = 0; i < sprites.length; i++) + { + sprites[i].position.add(vec3); + } + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#transformChildren + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat4 - [description] + * @param {Phaser.GameObjects.Sprite3D[]} sprites - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + transformChildren: function (mat4, sprites) + { + if (sprites === undefined) { sprites = this.getChildren(); } + + for (var i = 0; i < sprites.length; i++) + { + sprites[i].position.transformMat4(mat4); + } + + return this.update(); + }, + + /** + * Sets the width and height of the viewport. Does not update any matrices. + * + * @method Phaser.Cameras.Sprite3D.Camera#setViewport + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + setViewport: function (width, height) + { + this.viewportWidth = width; + this.viewportHeight = height; + + return this.update(); + }, + + /** + * Translates this camera by a specified Vector3 object + * or x, y, z parameters. Any undefined x y z values will + * default to zero, leaving that component unaffected. + * If you wish to set the camera position directly call setPosition instead. + * + * @method Phaser.Cameras.Sprite3D.Camera#translate + * @since 3.0.0 + * + * @param {(number|object)} x - [description] + * @param {number} [y] - [description] + * @param {number} [z] - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + translate: function (x, y, z) + { + if (typeof x === 'object') + { + this.position.x += x.x || 0; + this.position.y += x.y || 0; + this.position.z += x.z || 0; } else { - layer.data[tileY][tileX].index = index; + this.position.x += x || 0; + this.position.y += y || 0; + this.position.z += z || 0; + } + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#lookAt + * @since 3.0.0 + * + * @param {(number|object)} x - [description] + * @param {number} [y] - [description] + * @param {number} [z] - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + lookAt: function (x, y, z) + { + var dir = this.direction; + var up = this.up; + + if (typeof x === 'object') + { + dir.copy(x); + } + else + { + dir.set(x, y, z); + } + + dir.subtract(this.position).normalize(); + + // Calculate right vector + tmpVec3.copy(dir).cross(up).normalize(); + + // Calculate up vector + up.copy(tmpVec3).cross(dir).normalize(); + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#rotate + * @since 3.0.0 + * + * @param {float} radians - [description] + * @param {Phaser.Math.Vector3} axis - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + rotate: function (radians, axis) + { + RotateVec3(this.direction, axis, radians); + RotateVec3(this.up, axis, radians); + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#rotateAround + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} point - [description] + * @param {float} radians - [description] + * @param {Phaser.Math.Vector3} axis - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + rotateAround: function (point, radians, axis) + { + tmpVec3.copy(point).subtract(this.position); + + this.translate(tmpVec3); + this.rotate(radians, axis); + this.translate(tmpVec3.negate()); + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#project + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} vec - [description] + * @param {Phaser.Math.Vector4} out - [description] + * + * @return {Phaser.Math.Vector4} [description] + */ + project: function (vec, out) + { + if (out === undefined) { out = new Vector4(); } + + // TODO: support viewport XY + var viewportWidth = this.viewportWidth; + var viewportHeight = this.viewportHeight; + var n = Camera.NEAR_RANGE; + var f = Camera.FAR_RANGE; + + // For useful Z and W values we should do the usual steps: clip space -> NDC -> window coords + + // Implicit 1.0 for w component + tmpVec4.set(vec.x, vec.y, vec.z, 1.0); + + // Transform into clip space + tmpVec4.transformMat4(this.combined); + + // Avoid divide by zero when 0x0x0 camera projects to a 0x0x0 vec3 + if (tmpVec4.w === 0) + { + tmpVec4.w = 1; + } + + // Now into NDC + tmpVec4.x = tmpVec4.x / tmpVec4.w; + tmpVec4.y = tmpVec4.y / tmpVec4.w; + tmpVec4.z = tmpVec4.z / tmpVec4.w; + + // And finally into window coordinates + out.x = viewportWidth / 2 * tmpVec4.x + (0 + viewportWidth / 2); + out.y = viewportHeight / 2 * tmpVec4.y + (0 + viewportHeight / 2); + out.z = (f - n) / 2 * tmpVec4.z + (f + n) / 2; + + // If the out vector has a fourth component, we also store (1/clip.w), same idea as gl_FragCoord.w + if (out.w === 0 || out.w) + { + out.w = 1 / tmpVec4.w; + } + + return out; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#unproject + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} vec - [description] + * @param {Phaser.Math.Vector3} out - [description] + * + * @return {Phaser.Math.Vector3} [description] + */ + unproject: function (vec, out) + { + if (out === undefined) { out = new Vector3(); } + + var viewport = tmpVec4.set(0, 0, this.viewportWidth, this.viewportHeight); + + return out.copy(vec).unproject(viewport, this.invProjectionView); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#getPickRay + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y] - [description] + * + * @return {RayDef} [description] + */ + getPickRay: function (x, y) + { + var origin = this.ray.origin.set(x, y, 0); + var direction = this.ray.direction.set(x, y, 1); + var viewport = tmpVec4.set(0, 0, this.viewportWidth, this.viewportHeight); + var mtx = this.invProjectionView; + + origin.unproject(viewport, mtx); + + direction.unproject(viewport, mtx); + + direction.subtract(origin).normalize(); + + return this.ray; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#updateChildren + * @since 3.0.0 + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + updateChildren: function () + { + var children = this.children.entries; + + for (var i = 0; i < children.length; i++) + { + children[i].project(this); + } + + return this; + }, + + // Overriden by subclasses + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#update + * @since 3.0.0 + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + update: function () + { + return this.updateChildren(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#updateBillboardMatrix + * @since 3.0.0 + */ + updateBillboardMatrix: function () + { + var dir = dirvec.set(this.direction).negate(); + + // Better view-aligned billboards might use this: + // var dir = tmp.set(camera.position).subtract(p).normalize(); + + var right = rightvec.set(this.up).cross(dir).normalize(); + var up = tmpVec3.set(dir).cross(right).normalize(); + + var out = billboardMatrix.val; + + out[0] = right.x; + out[1] = right.y; + out[2] = right.z; + out[3] = 0; + + out[4] = up.x; + out[5] = up.y; + out[6] = up.z; + out[7] = 0; + + out[8] = dir.x; + out[9] = dir.y; + out[10] = dir.z; + out[11] = 0; + + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + + this.billboardMatrixDirty = false; + }, + + /** + * This is a utility function for canvas 3D rendering, + * which determines the "point size" of a camera-facing + * sprite billboard given its 3D world position + * (origin at center of sprite) and its world width + * and height in x/y. + * + * We place into the output Vector2 the scaled width + * and height. If no `out` is specified, a new Vector2 + * will be created for convenience (this should be avoided + * in tight loops). + * + * @method Phaser.Cameras.Sprite3D.Camera#getPointSize + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} vec - The position of the 3D Sprite. + * @param {Phaser.Math.Vector2} size - The x and y dimensions. + * @param {Phaser.Math.Vector2} out - The result, scaled x and y dimensions. + * + * @return {Phaser.Math.Vector2} [description] + */ + getPointSize: function (vec, size, out) + { + if (out === undefined) { out = new Vector2(); } + + // TODO: optimize this with a simple distance calculation: + // https://developer.valvesoftware.com/wiki/Field_of_View + + if (this.billboardMatrixDirty) + { + this.updateBillboardMatrix(); + } + + var tmp = tmpVec3; + + var dx = (size.x / this.pixelScale) / 2; + var dy = (size.y / this.pixelScale) / 2; + + tmp.set(-dx, -dy, 0).transformMat4(billboardMatrix).add(vec); + + this.project(tmp, tmp); + + var tlx = tmp.x; + var tly = tmp.y; + + tmp.set(dx, dy, 0).transformMat4(billboardMatrix).add(vec); + + this.project(tmp, tmp); + + var brx = tmp.x; + var bry = tmp.y; + + // var w = Math.abs(brx - tlx); + // var h = Math.abs(bry - tly); + + // Allow the projection to get negative ... + var w = brx - tlx; + var h = bry - tly; + + return out.set(w, h); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.children.clear(); + + this.scene = undefined; + this.children = undefined; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#setX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + setX: function (value) + { + this.position.x = value; + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#setY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + setY: function (value) + { + this.position.y = value; + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#setZ + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + setZ: function (value) + { + this.position.z = value; + + return this.update(); + }, + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.Camera#x + * @type {number} + * @since 3.0.0 + */ + x: { + get: function () + { + return this.position.x; + }, + + set: function (value) + { + this.position.x = value; + this.update(); + } + }, + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.Camera#y + * @type {number} + * @since 3.0.0 + */ + y: { + get: function () + { + return this.position.y; + }, + + set: function (value) + { + this.position.y = value; + this.update(); + } + }, + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.Camera#z + * @type {number} + * @since 3.0.0 + */ + z: { + get: function () + { + return this.position.z; + }, + + set: function (value) + { + this.position.z = value; + this.update(); } } - // Updating colliding flag on the new tile - var newTile = layer.data[tileY][tileX]; - var collides = layer.collideIndexes.indexOf(newTile.index) !== -1; - SetTileCollision(newTile, collides); +}); - // Recalculate faces only if the colliding flag at (tileX, tileY) has changed - if (recalculateFaces && (oldTileCollides !== newTile.collides)) - { - CalculateFacesAt(tileX, tileY, layer); - } - - return newTile; -}; - -module.exports = PutTileAt; +Camera.FAR_RANGE = 1.0; +Camera.NEAR_RANGE = 0.0; +module.exports = Camera; /***/ }), @@ -34001,31 +34801,23 @@ module.exports = PutTileAt; */ /** - * Internally used method to keep track of the tile indexes that collide within a layer. This - * updates LayerData.collideIndexes to either contain or not contain the given `tileIndex`. + * Given 3 separate color values this will return an integer representation of it. * - * @function Phaser.Tilemaps.Components.SetLayerCollisionIndex + * @function Phaser.Display.Color.GetColor * @since 3.0.0 * - * @param {integer} tileIndex - [description] - * @param {boolean} [collides=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * @param {integer} red - The red color value. A number between 0 and 255. + * @param {integer} green - The green color value. A number between 0 and 255. + * @param {integer} blue - The blue color value. A number between 0 and 255. + * + * @return {number} The combined color value. */ -var SetLayerCollisionIndex = function (tileIndex, collides, layer) +var GetColor = function (red, green, blue) { - var loc = layer.collideIndexes.indexOf(tileIndex); - - if (collides && loc === -1) - { - layer.collideIndexes.push(tileIndex); - } - else if (!collides && loc !== -1) - { - layer.collideIndexes.splice(loc, 1); - } + return red << 16 | green << 8 | blue; }; -module.exports = SetLayerCollisionIndex; +module.exports = GetColor; /***/ }), @@ -34038,86 +34830,50 @@ module.exports = SetLayerCollisionIndex; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Formats = __webpack_require__(22); -var LayerData = __webpack_require__(75); -var MapData = __webpack_require__(76); -var Tile = __webpack_require__(44); +var HexStringToColor = __webpack_require__(336); +var IntegerToColor = __webpack_require__(334); +var ObjectToColor = __webpack_require__(332); +var RGBStringToColor = __webpack_require__(331); /** - * Parses a 2D array of tile indexes into a new MapData object with a single layer. + * Converts the given source color value into an instance of a Color class. + * The value can be either a string, prefixed with `rgb` or a hex string, a number or an Object. * - * @function Phaser.Tilemaps.Parsers.Parse2DArray + * @function Phaser.Display.Color.ValueToColor * @since 3.0.0 - * - * @param {string} name - The name of the tilemap, used to set the name on the MapData. - * @param {integer[][]} data - 2D array, CSV string or Tiled JSON object. - * @param {integer} tileWidth - The width of a tile in pixels. - * @param {integer} tileHeight - The height of a tile in pixels. - * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {[type]} [description] + * + * @param {(string|number|InputColorObject)} input - The source color value to convert. + * + * @return {Phaser.Display.Color} A Color object. */ -var Parse2DArray = function (name, data, tileWidth, tileHeight, insertNull) +var ValueToColor = function (input) { - var layerData = new LayerData({ - tileWidth: tileWidth, - tileHeight: tileHeight - }); + var t = typeof input; - var mapData = new MapData({ - name: name, - tileWidth: tileWidth, - tileHeight: tileHeight, - format: Formats.ARRAY_2D, - layers: [ layerData ] - }); - - var tiles = []; - var height = data.length; - var width = 0; - - for (var y = 0; y < data.length; y++) + switch (t) { - tiles[y] = []; - var row = data[y]; + case 'string': - for (var x = 0; x < row.length; x++) - { - var tileIndex = parseInt(row[x], 10); - - if (Number.isNaN(tileIndex) || tileIndex === -1) + if (input.substr(0, 3).toLowerCase() === 'rgb') { - tiles[y][x] = insertNull - ? null - : new Tile(layerData, -1, x, y, tileWidth, tileHeight); + return RGBStringToColor(input); } else { - tiles[y][x] = new Tile(layerData, tileIndex, x, y, tileWidth, tileHeight); + return HexStringToColor(input); } - } - if (width === 0) - { - width = row.length; - } + case 'number': + + return IntegerToColor(input); + + case 'object': + + return ObjectToColor(input); } - - mapData.width = layerData.width = width; - mapData.height = layerData.height = height; - mapData.widthInPixels = layerData.widthInPixels = width * tileWidth; - mapData.heightInPixels = layerData.heightInPixels = height * tileHeight; - layerData.data = tiles; - - return mapData; }; -module.exports = Parse2DArray; +module.exports = ValueToColor; /***/ }), @@ -34130,131 +34886,1489 @@ module.exports = Parse2DArray; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Formats = __webpack_require__(22); -var MapData = __webpack_require__(76); -var Parse = __webpack_require__(347); -var Tilemap = __webpack_require__(355); +var Class = __webpack_require__(0); +var DegToRad = __webpack_require__(42); +var Rectangle = __webpack_require__(10); +var TransformMatrix = __webpack_require__(348); +var ValueToColor = __webpack_require__(156); +var Vector2 = __webpack_require__(6); /** - * Create a Tilemap from the given key or data. If neither is given, make a blank Tilemap. When - * loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing from - * a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map data. For - * an empty map, you should specify tileWidth, tileHeight, width & height. + * @typedef {object} JSONCamera * - * @function Phaser.Tilemaps.ParseToTilemap - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene to which this Tilemap belongs. - * @param {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data. - * @param {integer} [tileWidth=32] - The width of a tile in pixels. - * @param {integer} [tileHeight=32] - The height of a tile in pixels. - * @param {integer} [width=10] - The width of the map in tiles. - * @param {integer} [height=10] - The height of the map in tiles. - * @param {integer[][]} [data] - Instead of loading from the cache, you can also load directly from - * a 2D array of tile indexes. - * @param {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, in the - * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {Phaser.Tilemaps.Tilemap} + * @property {string} name - The name of the camera + * @property {number} x - The horizontal position of camera + * @property {number} y - The vertical position of camera + * @property {number} width - The width size of camera + * @property {number} height - The height size of camera + * @property {number} zoom - The zoom of camera + * @property {number} rotation - The rotation of camera + * @property {boolean} roundPixels - The round pixels st status of camera + * @property {number} scrollX - The horizontal scroll of camera + * @property {number} scrollY - The vertical scroll of camera + * @property {string} backgroundColor - The background color of camera + * @property {object} [bounds] - The bounds of camera + * @property {number} [bounds.x] - The horizontal position of bounds of camera + * @property {number} [bounds.y] - The vertical position of bounds of camera + * @property {number} [bounds.width] - The width of the bounds of camera + * @property {number} [bounds.height] - The height of the bounds of camera */ -var ParseToTilemap = function (scene, key, tileWidth, tileHeight, width, height, data, insertNull) -{ - if (tileWidth === undefined) { tileWidth = 32; } - if (tileHeight === undefined) { tileHeight = 32; } - if (width === undefined) { width = 10; } - if (height === undefined) { height = 10; } - if (insertNull === undefined) { insertNull = false; } - var mapData = null; +/** + * @classdesc + * [description] + * + * @class Camera + * @memberOf Phaser.Cameras.Scene2D + * @constructor + * @since 3.0.0 + * + * @param {number} x - The x position of the Camera, relative to the top-left of the game canvas. + * @param {number} y - The y position of the Camera, relative to the top-left of the game canvas. + * @param {number} width - The width of the Camera, in pixels. + * @param {number} height - The height of the Camera, in pixels. + */ +var Camera = new Class({ - if (Array.isArray(data)) + initialize: + + function Camera (x, y, width, height) { - var name = key !== undefined ? key : 'map'; - mapData = Parse(name, Formats.ARRAY_2D, data, tileWidth, tileHeight, insertNull); - } - else if (key !== undefined) - { - var tilemapData = scene.cache.tilemap.get(key); + /** + * A reference to the Scene this camera belongs to. + * + * @name Phaser.Cameras.Scene2D.Camera#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene; - if (!tilemapData) + /** + * The name of the Camera. This is left empty for your own use. + * + * @name Phaser.Cameras.Scene2D.Camera#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * The x position of the Camera, relative to the top-left of the game canvas. + * + * @name Phaser.Cameras.Scene2D.Camera#x + * @type {number} + * @since 3.0.0 + */ + this.x = x; + + /** + * The y position of the Camera, relative to the top-left of the game canvas. + * + * @name Phaser.Cameras.Scene2D.Camera#y + * @type {number} + * @since 3.0.0 + */ + this.y = y; + + /** + * The width of the Camera, in pixels. + * + * @name Phaser.Cameras.Scene2D.Camera#width + * @type {number} + * @since 3.0.0 + */ + this.width = width; + + /** + * The height of the Camera, in pixels. + * + * @name Phaser.Cameras.Scene2D.Camera#height + * @type {number} + * @since 3.0.0 + */ + this.height = height; + + /** + * Should this camera round its pixel values to integers? + * + * @name Phaser.Cameras.Scene2D.Camera#roundPixels + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.roundPixels = false; + + /** + * Is this Camera using a bounds to restrict scrolling movement? + * Set this property along with the bounds via `Camera.setBounds`. + * + * @name Phaser.Cameras.Scene2D.Camera#useBounds + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.useBounds = false; + + /** + * The bounds the camera is restrained to during scrolling. + * + * @name Phaser.Cameras.Scene2D.Camera#_bounds + * @type {Phaser.Geom.Rectangle} + * @private + * @since 3.0.0 + */ + this._bounds = new Rectangle(); + + /** + * Does this Camera allow the Game Objects it renders to receive input events? + * + * @name Phaser.Cameras.Scene2D.Camera#inputEnabled + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.inputEnabled = true; + + /** + * The horizontal scroll position of this camera. + * Optionally restricted via the Camera bounds. + * + * @name Phaser.Cameras.Scene2D.Camera#scrollX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.scrollX = 0; + + /** + * The vertical scroll position of this camera. + * Optionally restricted via the Camera bounds. + * + * @name Phaser.Cameras.Scene2D.Camera#scrollY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.scrollY = 0; + + /** + * The Camera zoom value. Change this value to zoom in, or out of, a Scene. + * Set to 1 to return to the default zoom level. + * + * @name Phaser.Cameras.Scene2D.Camera#zoom + * @type {float} + * @default 1 + * @since 3.0.0 + */ + this.zoom = 1; + + /** + * The rotation of the Camera. This influences the rendering of all Game Objects visible by this camera. + * + * @name Phaser.Cameras.Scene2D.Camera#rotation + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.rotation = 0; + + /** + * A local transform matrix used for internal calculations. + * + * @name Phaser.Cameras.Scene2D.Camera#matrix + * @type {TransformMatrix} + * @since 3.0.0 + */ + this.matrix = new TransformMatrix(1, 0, 0, 1, 0, 0); + + /** + * Does this Camera have a transparent background? + * + * @name Phaser.Cameras.Scene2D.Camera#transparent + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.transparent = true; + + /** + * TODO + * + * @name Phaser.Cameras.Scene2D.Camera#clearBeforeRender + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.clearBeforeRender = true; + + /** + * The background color of this Camera. Only used if `transparent` is `false`. + * + * @name Phaser.Cameras.Scene2D.Camera#backgroundColor + * @type {Phaser.Display.Color} + * @since 3.0.0 + */ + this.backgroundColor = ValueToColor('rgba(0,0,0,0)'); + + /** + * Should the camera cull Game Objects before rendering? + * In some special cases it may be beneficial to disable this. + * + * @name Phaser.Cameras.Scene2D.Camera#disableCull + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.disableCull = false; + + /** + * A temporary array of culled objects. + * + * @name Phaser.Cameras.Scene2D.Camera#culledObjects + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.culledObjects = []; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_shakeDuration + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._shakeDuration = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_shakeIntensity + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._shakeIntensity = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_shakeOffsetX + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._shakeOffsetX = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_shakeOffsetY + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._shakeOffsetY = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_shakeCallback + * @type {function} + * @private + * @default null + * @since 3.3.0 + */ + this._shakeCallback = null; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_fadeDuration + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._fadeDuration = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_fadeRed + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._fadeRed = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_fadeGreen + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._fadeGreen = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_fadeBlue + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._fadeBlue = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_fadeAlpha + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._fadeAlpha = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_fadeCallback + * @type {function} + * @private + * @default null + * @since 3.3.0 + */ + this._fadeCallback = null; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_flashDuration + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._flashDuration = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_flashRed + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + this._flashRed = 1; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_flashGreen + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + this._flashGreen = 1; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_flashBlue + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + this._flashBlue = 1; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_flashAlpha + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._flashAlpha = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_flashCallback + * @type {function} + * @private + * @default null + * @since 3.3.0 + */ + this._flashCallback = null; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_follow + * @type {?any} + * @private + * @default null + * @since 3.0.0 + */ + this._follow = null; + + /** + * [description] + * + * @name Phaser.Cameras.Scene2D.Camera#_id + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + this._id = 0; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#centerToBounds + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + centerToBounds: function () + { + this.scrollX = (this._bounds.width * 0.5) - (this.width * 0.5); + this.scrollY = (this._bounds.height * 0.5) - (this.height * 0.5); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#centerToSize + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + centerToSize: function () + { + this.scrollX = this.width * 0.5; + this.scrollY = this.height * 0.5; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#cull + * @since 3.0.0 + * + * @param {array} renderableObjects - [description] + * + * @return {array} [description] + */ + cull: function (renderableObjects) + { + if (this.disableCull) { - console.warn('No map data found for key ' + key); + return renderableObjects; + } + + var cameraMatrix = this.matrix.matrix; + + var mva = cameraMatrix[0]; + var mvb = cameraMatrix[1]; + var mvc = cameraMatrix[2]; + var mvd = cameraMatrix[3]; + + /* First Invert Matrix */ + var determinant = (mva * mvd) - (mvb * mvc); + + if (!determinant) + { + return renderableObjects; + } + + var mve = cameraMatrix[4]; + var mvf = cameraMatrix[5]; + + var scrollX = this.scrollX; + var scrollY = this.scrollY; + var cameraW = this.width; + var cameraH = this.height; + var culledObjects = this.culledObjects; + var length = renderableObjects.length; + + determinant = 1 / determinant; + + culledObjects.length = 0; + + for (var index = 0; index < length; ++index) + { + var object = renderableObjects[index]; + + if (!object.hasOwnProperty('width')) + { + culledObjects.push(object); + continue; + } + + var objectW = object.width; + var objectH = object.height; + var objectX = (object.x - (scrollX * object.scrollFactorX)) - (objectW * object.originX); + var objectY = (object.y - (scrollY * object.scrollFactorY)) - (objectH * object.originY); + var tx = (objectX * mva + objectY * mvc + mve); + var ty = (objectX * mvb + objectY * mvd + mvf); + var tw = ((objectX + objectW) * mva + (objectY + objectH) * mvc + mve); + var th = ((objectX + objectW) * mvb + (objectY + objectH) * mvd + mvf); + var cullW = cameraW + objectW; + var cullH = cameraH + objectH; + + if (tx > -objectW || ty > -objectH || tx < cullW || ty < cullH || + tw > -objectW || th > -objectH || tw < cullW || th < cullH) + { + culledObjects.push(object); + } + } + + return culledObjects; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#cullHitTest + * @since 3.0.0 + * + * @param {array} interactiveObjects - [description] + * + * @return {array} [description] + */ + cullHitTest: function (interactiveObjects) + { + if (this.disableCull) + { + return interactiveObjects; + } + + var cameraMatrix = this.matrix.matrix; + + var mva = cameraMatrix[0]; + var mvb = cameraMatrix[1]; + var mvc = cameraMatrix[2]; + var mvd = cameraMatrix[3]; + + /* First Invert Matrix */ + var determinant = (mva * mvd) - (mvb * mvc); + + if (!determinant) + { + return interactiveObjects; + } + + var mve = cameraMatrix[4]; + var mvf = cameraMatrix[5]; + + var scrollX = this.scrollX; + var scrollY = this.scrollY; + var cameraW = this.width; + var cameraH = this.height; + var length = interactiveObjects.length; + + determinant = 1 / determinant; + + var culledObjects = []; + + for (var index = 0; index < length; ++index) + { + var object = interactiveObjects[index].gameObject; + + if (!object.hasOwnProperty('width')) + { + culledObjects.push(interactiveObjects[index]); + continue; + } + + var objectW = object.width; + var objectH = object.height; + var objectX = (object.x - (scrollX * object.scrollFactorX)) - (objectW * object.originX); + var objectY = (object.y - (scrollY * object.scrollFactorY)) - (objectH * object.originY); + var tx = (objectX * mva + objectY * mvc + mve); + var ty = (objectX * mvb + objectY * mvd + mvf); + var tw = ((objectX + objectW) * mva + (objectY + objectH) * mvc + mve); + var th = ((objectX + objectW) * mvb + (objectY + objectH) * mvd + mvf); + var cullW = cameraW + objectW; + var cullH = cameraH + objectH; + + if (tx > -objectW || ty > -objectH || tx < cullW || ty < cullH || + tw > -objectW || th > -objectH || tw < cullW || th < cullH) + { + culledObjects.push(interactiveObjects[index]); + } + } + + return culledObjects; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#cullTilemap + * @since 3.0.0 + * + * @param {array} tilemap - [description] + * + * @return {array} [description] + */ + cullTilemap: function (tilemap) + { + var cameraMatrix = this.matrix.matrix; + + var mva = cameraMatrix[0]; + var mvb = cameraMatrix[1]; + var mvc = cameraMatrix[2]; + var mvd = cameraMatrix[3]; + + /* First Invert Matrix */ + var determinant = (mva * mvd) - (mvb * mvc); + + if (!determinant) + { + return tiles; + } + + var mve = cameraMatrix[4]; + var mvf = cameraMatrix[5]; + var tiles = tilemap.tiles; + var scrollX = this.scrollX; + var scrollY = this.scrollY; + var cameraW = this.width; + var cameraH = this.height; + var culledObjects = this.culledObjects; + var length = tiles.length; + var tileW = tilemap.tileWidth; + var tileH = tilemap.tileHeight; + var cullW = cameraW + tileW; + var cullH = cameraH + tileH; + var scrollFactorX = tilemap.scrollFactorX; + var scrollFactorY = tilemap.scrollFactorY; + + determinant = 1 / determinant; + + culledObjects.length = 0; + + for (var index = 0; index < length; ++index) + { + var tile = tiles[index]; + var tileX = (tile.x - (scrollX * scrollFactorX)); + var tileY = (tile.y - (scrollY * scrollFactorY)); + var tx = (tileX * mva + tileY * mvc + mve); + var ty = (tileX * mvb + tileY * mvd + mvf); + var tw = ((tileX + tileW) * mva + (tileY + tileH) * mvc + mve); + var th = ((tileX + tileW) * mvb + (tileY + tileH) * mvd + mvf); + + if (tx > -tileW && ty > -tileH && tw < cullW && th < cullH) + { + culledObjects.push(tile); + } + } + + return culledObjects; + }, + + /** + * Fades the Camera in from the given color over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#fadeIn + * @since 3.3.0 + * + * @param {number} duration - The duration of the effect in milliseconds. + * @param {function} [callback] - An optional callback to invoke when the fade completes. Will be sent one argument - a reference to this camera. + * @param {number} [red=0] - The value to fade the red channel from. A value between 0 and 1. + * @param {number} [green=0] - The value to fade the green channel from. A value between 0 and 1. + * @param {number} [blue=0] - The value to fade the blue channel from. A value between 0 and 1. + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + fadeIn: function (duration, callback, red, green, blue) + { + if (red === undefined) { red = 0; } + if (green === undefined) { green = 0; } + if (blue === undefined) { blue = 0; } + + return this.flash(duration, red, green, blue, true, callback); + }, + + /** + * Fades the Camera out to the given color over the duration specified. + * This is an alias for Camera.fade that forces the fade to start, regardless of existing fades. + * + * @method Phaser.Cameras.Scene2D.Camera#fadeOut + * @since 3.3.0 + * + * @param {number} duration - The duration of the effect in milliseconds. + * @param {function} [callback] - An optional callback to invoke when the fade completes. Will be sent one argument - a reference to this camera. + * @param {number} [red=0] - The value to fade the red channel from. A value between 0 and 1. + * @param {number} [green=0] - The value to fade the green channel from. A value between 0 and 1. + * @param {number} [blue=0] - The value to fade the blue channel from. A value between 0 and 1. + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + fadeOut: function (duration, callback, red, green, blue) + { + if (red === undefined) { red = 0; } + if (green === undefined) { green = 0; } + if (blue === undefined) { blue = 0; } + + return this.fade(duration, red, green, blue, true, callback); + }, + + /** + * Fades the Camera to the given color over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#fade + * @since 3.0.0 + * + * @param {number} duration - The duration of the effect in milliseconds. + * @param {number} [red=0] - The value to fade the red channel to. A value between 0 and 1. + * @param {number} [green=0] - The value to fade the green channel to. A value between 0 and 1. + * @param {number} [blue=0] - The value to fade the blue channel to. A value between 0 and 1. + * @param {boolean} [force=false] - Force the fade effect to start immediately, even if already running. + * @param {function} [callback] - An optional callback to invoke when the fade completes. Will be sent one argument - a reference to this camera. + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + fade: function (duration, red, green, blue, force, callback) + { + if (!duration) { duration = Number.MIN_VALUE; } + if (red === undefined) { red = 0; } + if (green === undefined) { green = 0; } + if (blue === undefined) { blue = 0; } + if (force === undefined) { force = false; } + if (callback === undefined) { callback = null; } + + if (!force && this._fadeAlpha > 0) + { + return this; + } + + this._fadeRed = red; + this._fadeGreen = green; + this._fadeBlue = blue; + this._fadeCallback = callback; + this._fadeDuration = duration; + this._fadeAlpha = Number.MIN_VALUE; + + return this; + }, + + /** + * Flashes the Camera to the given color over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#flash + * @since 3.0.0 + * + * @param {number} duration - The duration of the effect in milliseconds. + * @param {number} [red=1] - The value to flash the red channel to. A value between 0 and 1. + * @param {number} [green=1] - The value to flash the green channel to. A value between 0 and 1. + * @param {number} [blue=1] - The value to flash the blue channel to. A value between 0 and 1. + * @param {boolean} [force=false] - Force the flash effect to start immediately, even if already running. + * @param {function} [callback] - An optional callback to invoke when the flash completes. Will be sent one argument - a reference to this camera. + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + flash: function (duration, red, green, blue, force, callback) + { + if (!duration) { duration = Number.MIN_VALUE; } + if (red === undefined) { red = 1; } + if (green === undefined) { green = 1; } + if (blue === undefined) { blue = 1; } + if (force === undefined) { force = false; } + if (callback === undefined) { callback = null; } + + if (!force && this._flashAlpha > 0) + { + return this; + } + + this._flashRed = red; + this._flashGreen = green; + this._flashBlue = blue; + this._flashCallback = callback; + this._flashDuration = duration; + this._flashAlpha = 1; + + return this; + }, + + /** + * Shakes the Camera by the given intensity over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#shake + * @since 3.0.0 + * + * @param {number} duration - The duration of the effect in milliseconds. + * @param {number} [intensity=0.05] - The intensity of the shake. + * @param {boolean} [force=false] - Force the shake effect to start immediately, even if already running. + * @param {function} [callback] - An optional callback to invoke when the shake completes. Will be sent one argument - a reference to this camera. + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + shake: function (duration, intensity, force, callback) + { + if (!duration) { duration = Number.MIN_VALUE; } + if (intensity === undefined) { intensity = 0.05; } + if (force === undefined) { force = false; } + if (callback === undefined) { callback = null; } + + if (!force && (this._shakeOffsetX !== 0 || this._shakeOffsetY !== 0)) + { + return this; + } + + this._shakeDuration = duration; + this._shakeIntensity = intensity; + this._shakeOffsetX = 0; + this._shakeOffsetY = 0; + this._shakeCallback = callback; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#getWorldPoint + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {(object|Phaser.Math.Vector2)} output - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + getWorldPoint: function (x, y, output) + { + if (output === undefined) { output = new Vector2(); } + + var cameraMatrix = this.matrix.matrix; + + var mva = cameraMatrix[0]; + var mvb = cameraMatrix[1]; + var mvc = cameraMatrix[2]; + var mvd = cameraMatrix[3]; + var mve = cameraMatrix[4]; + var mvf = cameraMatrix[5]; + + /* First Invert Matrix */ + var determinant = (mva * mvd) - (mvb * mvc); + + if (!determinant) + { + output.x = x; + output.y = y; + + return output; + } + + determinant = 1 / determinant; + + var ima = mvd * determinant; + var imb = -mvb * determinant; + var imc = -mvc * determinant; + var imd = mva * determinant; + var ime = (mvc * mvf - mvd * mve) * determinant; + var imf = (mvb * mve - mva * mvf) * determinant; + + var c = Math.cos(this.rotation); + var s = Math.sin(this.rotation); + + var zoom = this.zoom; + + var scrollX = this.scrollX; + var scrollY = this.scrollY; + + var sx = x + ((scrollX * c - scrollY * s) * zoom); + var sy = y + ((scrollX * s + scrollY * c) * zoom); + + /* Apply transform to point */ + output.x = (sx * ima + sy * imc + ime); + output.y = (sx * imb + sy * imd + imf); + + return output; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#ignore + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjectOrArray - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + ignore: function (gameObjectOrArray) + { + if (gameObjectOrArray instanceof Array) + { + for (var index = 0; index < gameObjectOrArray.length; ++index) + { + gameObjectOrArray[index].cameraFilter |= this._id; + } } else { - mapData = Parse(key, tilemapData.format, tilemapData.data, tileWidth, tileHeight, insertNull); + gameObjectOrArray.cameraFilter |= this._id; } - } - if (mapData === null) + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#preRender + * @since 3.0.0 + * + * @param {number} baseScale - [description] + * @param {number} resolution - [description] + * + */ + preRender: function (baseScale, resolution) { - mapData = new MapData({ - tileWidth: tileWidth, - tileHeight: tileHeight, - width: width, - height: height - }); + var width = this.width; + var height = this.height; + var zoom = this.zoom * baseScale; + var matrix = this.matrix; + var originX = width / 2; + var originY = height / 2; + var follow = this._follow; + + if (follow !== null) + { + originX = follow.x; + originY = follow.y; + + this.scrollX = (originX - width * 0.5) / zoom; + this.scrollY = (originY - height * 0.5) / zoom; + } + + if (this.useBounds) + { + var bounds = this._bounds; + + var bw = Math.max(0, bounds.right - width); + var bh = Math.max(0, bounds.bottom - height); + + if (this.scrollX < bounds.x) + { + this.scrollX = bounds.x; + } + else if (this.scrollX > bw) + { + this.scrollX = bw; + } + + if (this.scrollY < bounds.y) + { + this.scrollY = bounds.y; + } + else if (this.scrollY > bh) + { + this.scrollY = bh; + } + } + + if (this.roundPixels) + { + this.scrollX = Math.round(this.scrollX); + this.scrollY = Math.round(this.scrollY); + } + + matrix.loadIdentity(); + matrix.scale(resolution, resolution); + matrix.translate(this.x + originX, this.y + originY); + matrix.rotate(this.rotation); + matrix.scale(zoom, zoom); + matrix.translate(-originX, -originY); + matrix.translate(this._shakeOffsetX, this._shakeOffsetY); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#removeBounds + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + removeBounds: function () + { + this.useBounds = false; + + this._bounds.setEmpty(); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setAngle + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setAngle: function (value) + { + if (value === undefined) { value = 0; } + + this.rotation = DegToRad(value); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setBackgroundColor + * @since 3.0.0 + * + * @param {(string|number|InputColorObject)} color - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setBackgroundColor: function (color) + { + if (color === undefined) { color = 'rgba(0,0,0,0)'; } + + this.backgroundColor = ValueToColor(color); + + this.transparent = (this.backgroundColor.alpha === 0); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setBounds + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setBounds: function (x, y, width, height) + { + this._bounds.setTo(x, y, width, height); + + this.useBounds = true; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setName + * @since 3.0.0 + * + * @param {string} value - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setName: function (value) + { + if (value === undefined) { value = ''; } + + this.name = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setPosition + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setPosition: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setRotation + * @since 3.0.0 + * + * @param {number} [value=0] - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setRotation: function (value) + { + if (value === undefined) { value = 0; } + + this.rotation = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setRoundPixels + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setRoundPixels: function (value) + { + this.roundPixels = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setScene + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setScene: function (scene) + { + this.scene = scene; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setScroll + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setScroll: function (x, y) + { + if (y === undefined) { y = x; } + + this.scrollX = x; + this.scrollY = y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setSize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} [height=width] - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setSize: function (width, height) + { + if (height === undefined) { height = width; } + + this.width = width; + this.height = height; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setViewport + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setViewport: function (x, y, width, height) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#setZoom + * @since 3.0.0 + * + * @param {float} [value=1] - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setZoom: function (value) + { + if (value === undefined) { value = 1; } + + this.zoom = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#startFollow + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|object)} target - [description] + * @param {boolean} roundPx - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + startFollow: function (target, roundPx) + { + if (roundPx === undefined) { roundPx = false; } + + this._follow = target; + + this.roundPixels = roundPx; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#stopFollow + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + stopFollow: function () + { + this._follow = null; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#toJSON + * @since 3.0.0 + * + * @return {JSONCamera} [description] + */ + toJSON: function () + { + var output = { + name: this.name, + x: this.x, + y: this.y, + width: this.width, + height: this.height, + zoom: this.zoom, + rotation: this.rotation, + roundPixels: this.roundPixels, + scrollX: this.scrollX, + scrollY: this.scrollY, + backgroundColor: this.backgroundColor.rgba + }; + + if (this.useBounds) + { + output['bounds'] = { + x: this._bounds.x, + y: this._bounds.y, + width: this._bounds.width, + height: this._bounds.height + }; + } + + return output; + }, + + /** + * Resets any active FX, such as a fade, flash or shake. Useful to call after a fade in order to + * remove the fade. + * + * @method Phaser.Cameras.Scene2D.Camera#resetFX + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + resetFX: function () + { + this._flashAlpha = 0; + this._fadeAlpha = 0; + this._shakeOffsetX = 0; + this._shakeOffsetY = 0; + this._shakeDuration = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#update + * @since 3.0.0 + * + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + update: function (time, delta) + { + if (this._flashAlpha > 0) + { + this._flashAlpha -= delta / this._flashDuration; + + if (this._flashAlpha <= 0) + { + this._flashAlpha = 0; + + if (this._flashCallback) + { + // Do this in case the callback flashes again (otherwise we'd overwrite the new callback) + var flashCallback = this._flashCallback; + + this._flashCallback = null; + + flashCallback(this); + } + } + } + + if (this._fadeAlpha > 0 && this._fadeAlpha < 1) + { + this._fadeAlpha += delta / this._fadeDuration; + + if (this._fadeAlpha >= 1) + { + this._fadeAlpha = 1; + + if (this._fadeCallback) + { + // Do this in case the callback fades again (otherwise we'd overwrite the new callback) + var fadeCallback = this._fadeCallback; + + this._fadeCallback = null; + + fadeCallback(this); + } + } + } + + if (this._shakeDuration > 0) + { + var intensity = this._shakeIntensity; + + this._shakeDuration -= delta; + + if (this._shakeDuration <= 0) + { + this._shakeOffsetX = 0; + this._shakeOffsetY = 0; + + if (this._shakeCallback) + { + // Do this in case the callback shakes again (otherwise we'd overwrite the new callback) + var shakeCallback = this._shakeCallback; + + this._shakeCallback = null; + + shakeCallback(this); + } + } + else + { + this._shakeOffsetX = (Math.random() * intensity * this.width * 2 - intensity * this.width) * this.zoom; + this._shakeOffsetY = (Math.random() * intensity * this.height * 2 - intensity * this.height) * this.zoom; + + if (this.roundPixels) + { + this._shakeOffsetX |= 0; + this._shakeOffsetY |= 0; + } + } + } + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.Camera#destroy + * @since 3.0.0 + */ + destroy: function () + { + this._bounds = undefined; + this.matrix = undefined; + this.culledObjects = []; + this.scene = undefined; } - return new Tilemap(scene, mapData); -}; +}); -module.exports = ParseToTilemap; +module.exports = Camera; /***/ }), /* 158 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetValue = __webpack_require__(4); - -/** - * [description] - * - * @function Phaser.Tweens.Builders.GetTargets - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {array} [description] - */ -var GetTargets = function (config) -{ - var targets = GetValue(config, 'targets', null); - - if (targets === null) - { - return targets; - } - - if (typeof targets === 'function') - { - targets = targets.call(); - } - - if (!Array.isArray(targets)) - { - targets = [ targets ]; - } - - return targets; -}; - -module.exports = GetTargets; - - -/***/ }), -/* 159 */ /***/ (function(module, exports) { /** @@ -34263,167 +36377,406 @@ module.exports = GetTargets; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -function hasGetStart (def) -{ - return (!!def.getStart && typeof def.getStart === 'function'); -} - -function hasGetEnd (def) -{ - return (!!def.getEnd && typeof def.getEnd === 'function'); -} - -function hasGetters (def) -{ - return hasGetStart(def) || hasGetEnd(def); -} - /** - * [description] + * Takes the given string and pads it out, to the length required, using the character + * specified. For example if you need a string to be 6 characters long, you can call: * - * @function Phaser.Tweens.Builders.GetValueOp + * `pad('bob', 6, '-', 2)` + * + * This would return: `bob---` as it has padded it out to 6 characters, using the `-` on the right. + * + * You can also use it to pad numbers (they are always returned as strings): + * + * `pad(512, 6, '0', 1)` + * + * Would return: `000512` with the string padded to the left. + * + * If you don't specify a direction it'll pad to both sides: + * + * `pad('c64', 7, '*')` + * + * Would return: `**c64**` + * + * @function Phaser.Utils.String.Pad * @since 3.0.0 * - * @param {string} key - [description] - * @param {any} propertyValue - [description] - * - * @return {function} [description] + * @param {string} str - The target string. `toString()` will be called on the string, which means you can also pass in common data types like numbers. + * @param {integer} [len=0] - The number of characters to be added. + * @param {string} [pad=" "] - The string to pad it out with (defaults to a space). + * @param {integer} [dir=3] - The direction dir = 1 (left), 2 (right), 3 (both). + * + * @return {string} The padded string. */ -var GetValueOp = function (key, propertyValue) +var Pad = function (str, len, pad, dir) { - var callbacks; + if (len === undefined) { len = 0; } + if (pad === undefined) { pad = ' '; } + if (dir === undefined) { dir = 3; } - // The returned value sets what the property will be at the END of the Tween (usually called at the start of the Tween) - var getEnd = function (target, key, value) { return value; }; + str = str.toString(); - // The returned value sets what the property will be at the START of the Tween (usually called at the end of the Tween) - var getStart = function (target, key, value) { return value; }; + var padlen = 0; - var t = typeof(propertyValue); - - if (t === 'number') + if (len + 1 >= str.length) { - // props: { - // x: 400, - // y: 300 - // } - - getEnd = function () + switch (dir) { - return propertyValue; - }; - } - else if (t === 'string') - { - // props: { - // x: '+=400', - // y: '-=300', - // z: '*=2', - // w: '/=2' - // } - - var op = propertyValue[0]; - var num = parseFloat(propertyValue.substr(2)); - - switch (op) - { - case '+': - getEnd = function (target, key, value) - { - return value + num; - }; + case 1: + str = new Array(len + 1 - str.length).join(pad) + str; break; - case '-': - getEnd = function (target, key, value) - { - return value - num; - }; - break; - - case '*': - getEnd = function (target, key, value) - { - return value * num; - }; - break; - - case '/': - getEnd = function (target, key, value) - { - return value / num; - }; + case 3: + var right = Math.ceil((padlen = len - str.length) / 2); + var left = padlen - right; + str = new Array(left + 1).join(pad) + str + new Array(right + 1).join(pad); break; default: - getEnd = function () - { - return parseFloat(propertyValue); - }; + str = str + new Array(len + 1 - str.length).join(pad); + break; } } - else if (t === 'function') - { - // The same as setting just the getEnd function and no getStart - // props: { - // x: function (target, key, value) { return value + 50); }, - // } - - getEnd = propertyValue; - } - else if (t === 'object' && hasGetters(propertyValue)) - { - /* - x: { - // Called at the start of the Tween. The returned value sets what the property will be at the END of the Tween. - getEnd: function (target, key, value) - { - return value; - }, - - // Called at the end of the Tween. The returned value sets what the property will be at the START of the Tween. - getStart: function (target, key, value) - { - return value; - } - } - */ - - if (hasGetEnd(propertyValue)) - { - getEnd = propertyValue.getEnd; - } - - if (hasGetStart(propertyValue)) - { - getStart = propertyValue.getStart; - } - } - else if (propertyValue.hasOwnProperty('value')) - { - // Value may still be a string, function or a number - // props: { - // x: { value: 400, ... }, - // y: { value: 300, ... } - // } - - callbacks = GetValueOp(key, propertyValue.value); - } - - // If callback not set by the else if block above then set it here and return it - if (!callbacks) - { - callbacks = { - getEnd: getEnd, - getStart: getStart - }; - } - - return callbacks; + return str; }; -module.exports = GetValueOp; +module.exports = Pad; + + +/***/ }), +/* 159 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @callback EachMapCallback + * + * @param {string} key - [description] + * @param {*} entry - [description] + * + * @return {?boolean} [description] + */ + +/** + * @classdesc + * The keys of a Map can be arbitrary values. + * var map = new Map([ + * [ 1, 'one' ], + * [ 2, 'two' ], + * [ 3, 'three' ] + * ]); + * + * @class Map + * @memberOf Phaser.Structs + * @constructor + * @since 3.0.0 + * + * @param {array} elements - [description] + */ +var Map = new Class({ + + initialize: + + function Map (elements) + { + /** + * [description] + * + * @name Phaser.Structs.Map#entries + * @type {Object.} + * @default {} + * @since 3.0.0 + */ + this.entries = {}; + + /** + * [description] + * + * @name Phaser.Structs.Map#size + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.size = 0; + + if (Array.isArray(elements)) + { + for (var i = 0; i < elements.length; i++) + { + this.set(elements[i][0], elements[i][1]); + } + } + }, + + /** + * [description] + * + * @method Phaser.Structs.Map#set + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {*} value - [description] + * + * @return {Phaser.Structs.Map} This Map object. + */ + set: function (key, value) + { + if (!this.has(key)) + { + this.entries[key] = value; + this.size++; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.Map#get + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {*} [description] + */ + get: function (key) + { + if (this.has(key)) + { + return this.entries[key]; + } + }, + + /** + * [description] + * + * @method Phaser.Structs.Map#getArray + * @since 3.0.0 + * + * @return {array} [description] + */ + getArray: function () + { + var output = []; + var entries = this.entries; + + for (var key in entries) + { + output.push(entries[key]); + } + + return output; + }, + + /** + * [description] + * + * @method Phaser.Structs.Map#has + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {boolean} [description] + */ + has: function (key) + { + return (this.entries.hasOwnProperty(key)); + }, + + /** + * [description] + * + * @method Phaser.Structs.Map#delete + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Structs.Map} This Map object. + */ + delete: function (key) + { + if (this.has(key)) + { + delete this.entries[key]; + this.size--; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.Map#clear + * @since 3.0.0 + * + * @return {Phaser.Structs.Map} This Map object. + */ + clear: function () + { + Object.keys(this.entries).forEach(function (prop) + { + delete this.entries[prop]; + + }, this); + + this.size = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.Map#keys + * @since 3.0.0 + * + * @return {string[]} [description] + */ + keys: function () + { + return Object.keys(this.entries); + }, + + /** + * [description] + * + * @method Phaser.Structs.Map#values + * @since 3.0.0 + * + * @return {array} [description] + */ + values: function () + { + var output = []; + var entries = this.entries; + + for (var key in entries) + { + output.push(entries[key]); + } + + return output; + }, + + /** + * [description] + * + * @method Phaser.Structs.Map#dump + * @since 3.0.0 + */ + dump: function () + { + var entries = this.entries; + + // eslint-disable-next-line no-console + console.group('Map'); + + for (var key in entries) + { + console.log(key, entries[key]); + } + + // eslint-disable-next-line no-console + console.groupEnd(); + }, + + /** + * [description] + * + * @method Phaser.Structs.Map#each + * @since 3.0.0 + * + * @param {EachMapCallback} callback - [description] + * + * @return {Phaser.Structs.Map} This Map object. + */ + each: function (callback) + { + var entries = this.entries; + + for (var key in entries) + { + if (callback(key, entries[key]) === false) + { + break; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.Map#contains + * @since 3.0.0 + * + * @param {*} value - [description] + * + * @return {boolean} [description] + */ + contains: function (value) + { + var entries = this.entries; + + for (var key in entries) + { + if (entries[key] === value) + { + return true; + } + } + + return false; + }, + + /** + * Merges all new keys from the given Map into this one + * If it encounters a key that already exists it will be skipped + * unless override = true. + * + * @method Phaser.Structs.Map#merge + * @since 3.0.0 + * + * @param {Phaser.Structs.Map} map - [description] + * @param {boolean} [override=false] - [description] + * + * @return {Phaser.Structs.Map} This Map object. + */ + merge: function (map, override) + { + if (override === undefined) { override = false; } + + var local = this.entries; + var source = map.entries; + + for (var key in source) + { + if (local.hasOwnProperty(key) && override) + { + local[key] = source[key]; + } + else + { + this.set(key, source[key]); + } + } + + return this; + } + +}); + +module.exports = Map; /***/ }), @@ -34437,35 +36790,30 @@ module.exports = GetValueOp; */ /** - * @typedef {object} Phaser.Tweens.Tween~ConfigDefaults - * @property {object|object[]} targets - [description] - * @property {number} [delay=0] - [description] - * @property {number} [duration=1000] - [description] - * @property {string} [ease='Power0'] - [description] - * @property {array} [easeParams] - [description] - * @property {number} [hold=0] - [description] - * @property {number} [repeat=0] - [description] - * @property {number} [repeatDelay=0] - [description] - * @property {boolean} [yoyo=false] - [description] - * @property {boolean} [flipX=false] - [description] - * @property {boolean} [flipY=false] - [description] + * [description] + * + * @function Phaser.Math.RotateAroundDistance + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point - The Point to be rotated. + * @param {number} x - The horizontal coordinate to rotate around. + * @param {number} y - The vertical coordinate to rotate around. + * @param {number} angle - The angle of rotation in radians. + * @param {number} distance - [description] + * + * @return {Phaser.Geom.Point} [description] */ +var RotateAroundDistance = function (point, x, y, angle, distance) +{ + var t = angle + Math.atan2(point.y - y, point.x - x); -var TWEEN_DEFAULTS = { - targets: null, - delay: 0, - duration: 1000, - ease: 'Power0', - easeParams: null, - hold: 0, - repeat: 0, - repeatDelay: 0, - yoyo: false, - flipX: false, - flipY: false + point.x = x + (distance * Math.cos(t)); + point.y = y + (distance * Math.sin(t)); + + return point; }; -module.exports = TWEEN_DEFAULTS; +module.exports = RotateAroundDistance; /***/ }), @@ -34478,1370 +36826,53 @@ module.exports = TWEEN_DEFAULTS; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var GameObjectCreator = __webpack_require__(13); -var GameObjectFactory = __webpack_require__(9); -var TWEEN_CONST = __webpack_require__(87); +var Point = __webpack_require__(4); /** - * @classdesc * [description] * - * @class Tween - * @memberOf Phaser.Tweens - * @constructor + * @function Phaser.Geom.Triangle.Random * @since 3.0.0 * - * @param {Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline} parent - [description] - * @param {Phaser.Tweens.TweenData[]} data - [description] - * @param {array} targets - [description] + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] */ -var Tween = new Class({ +var Random = function (triangle, out) +{ + if (out === undefined) { out = new Point(); } - initialize: + // Basis vectors + var ux = triangle.x2 - triangle.x1; + var uy = triangle.y2 - triangle.y1; - function Tween (parent, data, targets) + var vx = triangle.x3 - triangle.x1; + var vy = triangle.y3 - triangle.y1; + + // Random point within the unit square + var r = Math.random(); + var s = Math.random(); + + // Point outside the triangle? Remap it. + if (r + s >= 1) { - /** - * [description] - * - * @name Phaser.Tweens.Tween#parent - * @type {Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline} - * @since 3.0.0 - */ - this.parent = parent; - - /** - * Is the parent of this Tween a Timeline? - * - * @name Phaser.Tweens.Tween#parentIsTimeline - * @type {boolean} - * @since 3.0.0 - */ - this.parentIsTimeline = parent.hasOwnProperty('isTimeline'); - - /** - * An array of TweenData objects, each containing a unique property and target being tweened. - * - * @name Phaser.Tweens.Tween#data - * @type {Phaser.Tweens.TweenData[]} - * @since 3.0.0 - */ - this.data = data; - - /** - * data array doesn't change, so we can cache the length - * - * @name Phaser.Tweens.Tween#totalData - * @type {integer} - * @since 3.0.0 - */ - this.totalData = data.length; - - /** - * An array of references to the target/s this Tween is operating on - * - * @name Phaser.Tweens.Tween#targets - * @type {object[]} - * @since 3.0.0 - */ - this.targets = targets; - - /** - * Cached target total (not necessarily the same as the data total) - * - * @name Phaser.Tweens.Tween#totalTargets - * @type {integer} - * @since 3.0.0 - */ - this.totalTargets = targets.length; - - /** - * If true then duration, delay, etc values are all frame totals. - * - * @name Phaser.Tweens.Tween#useFrames - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.useFrames = false; - - /** - * Scales the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. - * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. - * - * @name Phaser.Tweens.Tween#timeScale - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * Loop this tween? Can be -1 for an infinite loop, or an integer. - * When enabled it will play through ALL TweenDatas again (use TweenData.repeat to loop a single TD) - * - * @name Phaser.Tweens.Tween#loop - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loop = 0; - - /** - * Time in ms/frames before the tween loops. - * - * @name Phaser.Tweens.Tween#loopDelay - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loopDelay = 0; - - /** - * How many loops are left to run? - * - * @name Phaser.Tweens.Tween#loopCounter - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loopCounter = 0; - - /** - * Time in ms/frames before the 'onComplete' event fires. This never fires if loop = -1 (as it never completes) - * - * @name Phaser.Tweens.Tween#completeDelay - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.completeDelay = 0; - - /** - * Countdown timer (used by timeline offset, loopDelay and completeDelay) - * - * @name Phaser.Tweens.Tween#countdown - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.countdown = 0; - - /** - * Set only if this Tween is part of a Timeline. - * - * @name Phaser.Tweens.Tween#offset - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.offset = 0; - - /** - * Set only if this Tween is part of a Timeline. The calculated offset amount. - * - * @name Phaser.Tweens.Tween#calculatedOffset - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.calculatedOffset = 0; - - /** - * The current state of the tween - * - * @name Phaser.Tweens.Tween#state - * @type {integer} - * @since 3.0.0 - */ - this.state = TWEEN_CONST.PENDING_ADD; - - /** - * The state of the tween when it was paused (used by Resume) - * - * @name Phaser.Tweens.Tween#_pausedState - * @type {integer} - * @private - * @since 3.0.0 - */ - this._pausedState = TWEEN_CONST.PENDING_ADD; - - /** - * Does the Tween start off paused? (if so it needs to be started with Tween.play) - * - * @name Phaser.Tweens.Tween#paused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.paused = false; - - /** - * Elapsed time in ms/frames of this run through the Tween. - * - * @name Phaser.Tweens.Tween#elapsed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.elapsed = 0; - - /** - * Total elapsed time in ms/frames of the entire Tween, including looping. - * - * @name Phaser.Tweens.Tween#totalElapsed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalElapsed = 0; - - /** - * Time in ms/frames for the whole Tween to play through once, excluding loop amounts and loop delays. - * - * @name Phaser.Tweens.Tween#duration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.duration = 0; - - /** - * Value between 0 and 1. The amount through the Tween, excluding loops. - * - * @name Phaser.Tweens.Tween#progress - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.progress = 0; - - /** - * Time in ms/frames for the Tween to complete (including looping) - * - * @name Phaser.Tweens.Tween#totalDuration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalDuration = 0; - - /** - * Value between 0 and 1. The amount through the entire Tween, including looping. - * - * @name Phaser.Tweens.Tween#totalProgress - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalProgress = 0; - - /** - * An object containing the various Tween callback references. - * - * @name Phaser.Tweens.Tween#callbacks - * @type {object} - * @default 0 - * @since 3.0.0 - */ - this.callbacks = { - onComplete: null, - onLoop: null, - onRepeat: null, - onStart: null, - onUpdate: null, - onYoyo: null - }; - - this.callbackScope; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#getValue - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getValue: function () - { - return this.data[0].current; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#setTimeScale - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - setTimeScale: function (value) - { - this.timeScale = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#getTimeScale - * @since 3.0.0 - * - * @return {number} [description] - */ - getTimeScale: function () - { - return this.timeScale; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#isPlaying - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isPlaying: function () - { - return (this.state === TWEEN_CONST.ACTIVE); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#isPaused - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isPaused: function () - { - return (this.state === TWEEN_CONST.PAUSED); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#hasTarget - * @since 3.0.0 - * - * @param {object} target - [description] - * - * @return {boolean} [description] - */ - hasTarget: function (target) - { - return (this.targets.indexOf(target) !== -1); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#updateTo - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {any} value - [description] - * @param {boolean} startToCurrent - [description] - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - updateTo: function (key, value, startToCurrent) - { - for (var i = 0; i < this.totalData; i++) - { - var tweenData = this.data[i]; - - if (tweenData.key === key) - { - tweenData.end = value; - - if (startToCurrent) - { - tweenData.start = tweenData.current; - } - - break; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#restart - * @since 3.0.0 - */ - restart: function () - { - this.stop(); - this.play(); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#calcDuration - * @since 3.0.0 - */ - calcDuration: function () - { - var max = 0; - - var data = this.data; - - for (var i = 0; i < this.totalData; i++) - { - var tweenData = data[i]; - - // Set t1 (duration + hold + yoyo) - tweenData.t1 = tweenData.duration + tweenData.hold; - - if (tweenData.yoyo) - { - tweenData.t1 += tweenData.duration; - } - - // Set t2 (repeatDelay + duration + hold + yoyo) - tweenData.t2 = tweenData.t1 + tweenData.repeatDelay; - - // Total Duration - tweenData.totalDuration = tweenData.delay + tweenData.t1; - - if (tweenData.repeat === -1) - { - tweenData.totalDuration += (tweenData.t2 * 999999999999); - } - else if (tweenData.repeat > 0) - { - tweenData.totalDuration += (tweenData.t2 * tweenData.repeat); - } - - if (tweenData.totalDuration > max) - { - // Get the longest TweenData from the Tween, used to calculate the Tween TD - max = tweenData.totalDuration; - } - } - - // Excludes loop values - this.duration = max; - - this.loopCounter = (this.loop === -1) ? 999999999999 : this.loop; - - if (this.loopCounter > 0) - { - this.totalDuration = this.duration + this.completeDelay + ((this.duration + this.loopDelay) * this.loopCounter); - } - else - { - this.totalDuration = this.duration + this.completeDelay; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#init - * @since 3.0.0 - * - * @return {boolean} Returns `true` if this Tween should be moved from the pending list to the active list by the Tween Manager. - */ - init: function () - { - var data = this.data; - var totalTargets = this.totalTargets; - - for (var i = 0; i < this.totalData; i++) - { - var tweenData = data[i]; - var target = tweenData.target; - var gen = tweenData.gen; - - tweenData.delay = gen.delay(i, totalTargets, target); - tweenData.duration = gen.duration(i, totalTargets, target); - tweenData.hold = gen.hold(i, totalTargets, target); - tweenData.repeat = gen.repeat(i, totalTargets, target); - tweenData.repeatDelay = gen.repeatDelay(i, totalTargets, target); - } - - this.calcDuration(); - - this.progress = 0; - this.totalProgress = 0; - this.elapsed = 0; - this.totalElapsed = 0; - - // You can't have a paused Tween if it's part of a Timeline - if (this.paused && !this.parentIsTimeline) - { - this.state = TWEEN_CONST.PAUSED; - - return false; - } - else - { - return true; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#nextState - * @since 3.0.0 - */ - nextState: function () - { - if (this.loopCounter > 0) - { - this.elapsed = 0; - this.progress = 0; - this.loopCounter--; - - var onLoop = this.callbacks.onLoop; - - if (onLoop) - { - onLoop.params[1] = this.targets; - - onLoop.func.apply(onLoop.scope, onLoop.params); - } - - this.resetTweenData(true); - - if (this.loopDelay > 0) - { - this.countdown = this.loopDelay; - this.state = TWEEN_CONST.LOOP_DELAY; - } - else - { - this.state = TWEEN_CONST.ACTIVE; - } - } - else if (this.completeDelay > 0) - { - this.countdown = this.completeDelay; - this.state = TWEEN_CONST.COMPLETE_DELAY; - } - else - { - var onComplete = this.callbacks.onComplete; - - if (onComplete) - { - onComplete.params[1] = this.targets; - - onComplete.func.apply(onComplete.scope, onComplete.params); - } - - this.state = TWEEN_CONST.PENDING_REMOVE; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#pause - * @since 3.0.0 - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - pause: function () - { - if (this.state === TWEEN_CONST.PAUSED) - { - return; - } - - this.paused = true; - - this._pausedState = this.state; - - this.state = TWEEN_CONST.PAUSED; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#play - * @since 3.0.0 - * - * @param {boolean} resetFromTimeline - [description] - */ - play: function (resetFromTimeline) - { - if (this.state === TWEEN_CONST.ACTIVE) - { - return; - } - else if (this.state === TWEEN_CONST.PENDING_REMOVE || this.state === TWEEN_CONST.REMOVED) - { - this.init(); - this.parent.makeActive(this); - resetFromTimeline = true; - } - - var onStart = this.callbacks.onStart; - - if (this.parentIsTimeline) - { - this.resetTweenData(resetFromTimeline); - - if (this.calculatedOffset === 0) - { - if (onStart) - { - onStart.params[1] = this.targets; - - onStart.func.apply(onStart.scope, onStart.params); - } - - this.state = TWEEN_CONST.ACTIVE; - } - else - { - this.countdown = this.calculatedOffset; - - this.state = TWEEN_CONST.OFFSET_DELAY; - } - } - else if (this.paused) - { - this.paused = false; - - this.parent.makeActive(this); - } - else - { - this.resetTweenData(resetFromTimeline); - - this.state = TWEEN_CONST.ACTIVE; - - if (onStart) - { - onStart.params[1] = this.targets; - - onStart.func.apply(onStart.scope, onStart.params); - } - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#resetTweenData - * @since 3.0.0 - * - * @param {boolean} resetFromLoop - [description] - */ - resetTweenData: function (resetFromLoop) - { - var data = this.data; - - for (var i = 0; i < this.totalData; i++) - { - var tweenData = data[i]; - - tweenData.progress = 0; - tweenData.elapsed = 0; - - tweenData.repeatCounter = (tweenData.repeat === -1) ? 999999999999 : tweenData.repeat; - - if (resetFromLoop) - { - tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); - - tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.end); - - tweenData.current = tweenData.start; - - tweenData.state = TWEEN_CONST.PLAYING_FORWARD; - } - else if (tweenData.delay > 0) - { - tweenData.elapsed = tweenData.delay; - tweenData.state = TWEEN_CONST.DELAY; - } - else - { - tweenData.state = TWEEN_CONST.PENDING_RENDER; - } - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#resume - * @since 3.0.0 - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - resume: function () - { - if (this.state === TWEEN_CONST.PAUSED) - { - this.paused = false; - - this.state = this._pausedState; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#seek - * @since 3.0.0 - * - * @param {float} toPosition - A value between 0 and 1. - */ - seek: function (toPosition) - { - var data = this.data; - - for (var i = 0; i < this.totalData; i++) - { - // This won't work with loop > 0 yet - var ms = this.totalDuration * toPosition; - - var tweenData = data[i]; - var progress = 0; - var elapsed = 0; - - if (ms <= tweenData.delay) - { - progress = 0; - elapsed = 0; - } - else if (ms >= tweenData.totalDuration) - { - progress = 1; - elapsed = tweenData.duration; - } - else if (ms > tweenData.delay && ms <= tweenData.t1) - { - // Keep it zero bound - ms = Math.max(0, ms - tweenData.delay); - - // Somewhere in the first playthru range - progress = ms / tweenData.t1; - elapsed = tweenData.duration * progress; - } - else if (ms > tweenData.t1 && ms < tweenData.totalDuration) - { - // Somewhere in repeat land - ms -= tweenData.delay; - ms -= tweenData.t1; - - // var repeats = Math.floor(ms / tweenData.t2); - - // remainder - ms = ((ms / tweenData.t2) % 1) * tweenData.t2; - - if (ms > tweenData.repeatDelay) - { - progress = ms / tweenData.t1; - elapsed = tweenData.duration * progress; - } - } - - tweenData.progress = progress; - tweenData.elapsed = elapsed; - - var v = tweenData.ease(tweenData.progress); - - tweenData.current = tweenData.start + ((tweenData.end - tweenData.start) * v); - - // console.log(tweenData.key, 'Seek', tweenData.target[tweenData.key], 'to', tweenData.current, 'pro', tweenData.progress, 'marker', toPosition, progress); - - // if (tweenData.current === 0) - // { - // console.log('zero', tweenData.start, tweenData.end, v, 'progress', progress); - // } - - tweenData.target[tweenData.key] = tweenData.current; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#setCallback - * @since 3.0.0 - * - * @param {string} type - [description] - * @param {function} callback - [description] - * @param {array} [params] - [description] - * @param {object} [scope] - [description] - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - setCallback: function (type, callback, params, scope) - { - this.callbacks[type] = { func: callback, scope: scope, params: params }; - - return this; - }, - - /** - * Flags the Tween as being complete, whatever stage of progress it is at. - * - * If an onComplete callback has been defined it will automatically invoke it, unless a `delay` - * argument is provided, in which case the Tween will delay for that period of time before calling the callback. - * - * If you don't need a delay, or have an onComplete callback, then call `Tween.stop` instead. - * - * @method Phaser.Tweens.Tween#complete - * @since 3.2.0 - * - * @param {number} [delay=0] - The time to wait before invoking the complete callback. If zero it will fire immediately. - */ - complete: function (delay) - { - if (delay === undefined) { delay = 0; } - - if (delay) - { - this.countdown = delay; - this.state = TWEEN_CONST.COMPLETE_DELAY; - } - else - { - var onComplete = this.callbacks.onComplete; - - if (onComplete) - { - onComplete.params[1] = this.targets; - - onComplete.func.apply(onComplete.scope, onComplete.params); - } - - this.state = TWEEN_CONST.PENDING_REMOVE; - } - }, - - /** - * Stops the Tween immediately, whatever stage of progress it is at and flags it for removal by the TweenManager. - * - * @method Phaser.Tweens.Tween#stop - * @since 3.0.0 - * - * @param {float} [resetTo] - A value between 0 and 1. - */ - stop: function (resetTo) - { - if (resetTo !== undefined) - { - this.seek(resetTo); - } - - this.state = TWEEN_CONST.PENDING_REMOVE; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#update - * @since 3.0.0 - * - * @param {number} timestamp - [description] - * @param {number} delta - [description] - * - * @return {boolean} Returns `true` if this Tween has finished and should be removed from the Tween Manager, otherwise returns `false`. - */ - update: function (timestamp, delta) - { - if (this.state === TWEEN_CONST.PAUSED) - { - return false; - } - - if (this.useFrames) - { - delta = 1 * this.parent.timeScale; - } - - delta *= this.timeScale; - - this.elapsed += delta; - this.progress = Math.min(this.elapsed / this.duration, 1); - - this.totalElapsed += delta; - this.totalProgress = Math.min(this.totalElapsed / this.totalDuration, 1); - - switch (this.state) - { - case TWEEN_CONST.ACTIVE: - - var stillRunning = false; - - for (var i = 0; i < this.totalData; i++) - { - if (this.updateTweenData(this, this.data[i], delta)) - { - stillRunning = true; - } - } - - // Anything still running? If not, we're done - if (!stillRunning) - { - this.nextState(); - } - - break; - - case TWEEN_CONST.LOOP_DELAY: - - this.countdown -= delta; - - if (this.countdown <= 0) - { - this.state = TWEEN_CONST.ACTIVE; - } - - break; - - case TWEEN_CONST.OFFSET_DELAY: - - this.countdown -= delta; - - if (this.countdown <= 0) - { - var onStart = this.callbacks.onStart; - - if (onStart) - { - onStart.params[1] = this.targets; - - onStart.func.apply(onStart.scope, onStart.params); - } - - this.state = TWEEN_CONST.ACTIVE; - } - - break; - - case TWEEN_CONST.COMPLETE_DELAY: - - this.countdown -= delta; - - if (this.countdown <= 0) - { - var onComplete = this.callbacks.onComplete; - - if (onComplete) - { - onComplete.func.apply(onComplete.scope, onComplete.params); - } - - this.state = TWEEN_CONST.PENDING_REMOVE; - } - - break; - } - - return (this.state === TWEEN_CONST.PENDING_REMOVE); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#setStateFromEnd - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * @param {Phaser.Tweens.TweenData} tweenData - [description] - * @param {number} diff - [description] - * - * @return {integer} The state of this Tween. - */ - setStateFromEnd: function (tween, tweenData, diff) - { - if (tweenData.yoyo) - { - // We've hit the end of a Playing Forward TweenData and we have a yoyo - - // Account for any extra time we got from the previous frame - tweenData.elapsed = diff; - tweenData.progress = diff / tweenData.duration; - - if (tweenData.flipX) - { - tweenData.target.toggleFlipX(); - } - - // Problem: The flip and callback and so on gets called for every TweenData that triggers it at the same time. - // If you're tweening several properties it can fire for all of them, at once. - - if (tweenData.flipY) - { - tweenData.target.toggleFlipY(); - } - - var onYoyo = tween.callbacks.onYoyo; - - if (onYoyo) - { - // Element 1 is reserved for the target of the yoyo (and needs setting here) - onYoyo.params[1] = tweenData.target; - - onYoyo.func.apply(onYoyo.scope, onYoyo.params); - } - - tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); - - return TWEEN_CONST.PLAYING_BACKWARD; - } - else if (tweenData.repeatCounter > 0) - { - // We've hit the end of a Playing Forward TweenData and we have a Repeat. - // So we're going to go right back to the start to repeat it again. - - tweenData.repeatCounter--; - - // Account for any extra time we got from the previous frame - tweenData.elapsed = diff; - tweenData.progress = diff / tweenData.duration; - - if (tweenData.flipX) - { - tweenData.target.toggleFlipX(); - } - - if (tweenData.flipY) - { - tweenData.target.toggleFlipY(); - } - - var onRepeat = tween.callbacks.onRepeat; - - if (onRepeat) - { - // Element 1 is reserved for the target of the repeat (and needs setting here) - onRepeat.params[1] = tweenData.target; - - onRepeat.func.apply(onRepeat.scope, onRepeat.params); - } - - tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); - - tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); - - // Delay? - if (tweenData.repeatDelay > 0) - { - tweenData.elapsed = tweenData.repeatDelay - diff; - - tweenData.current = tweenData.start; - - tweenData.target[tweenData.key] = tweenData.current; - - return TWEEN_CONST.REPEAT_DELAY; - } - else - { - return TWEEN_CONST.PLAYING_FORWARD; - } - } - - return TWEEN_CONST.COMPLETE; - }, - - /** - * Was PLAYING_BACKWARD and has hit the start. - * - * @method Phaser.Tweens.Tween#setStateFromStart - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * @param {Phaser.Tweens.TweenData} tweenData - [description] - * @param {number} diff - [description] - * - * @return {integer} The state of this Tween. - */ - setStateFromStart: function (tween, tweenData, diff) - { - if (tweenData.repeatCounter > 0) - { - tweenData.repeatCounter--; - - // Account for any extra time we got from the previous frame - tweenData.elapsed = diff; - tweenData.progress = diff / tweenData.duration; - - if (tweenData.flipX) - { - tweenData.target.toggleFlipX(); - } - - if (tweenData.flipY) - { - tweenData.target.toggleFlipY(); - } - - var onRepeat = tween.callbacks.onRepeat; - - if (onRepeat) - { - // Element 1 is reserved for the target of the repeat (and needs setting here) - onRepeat.params[1] = tweenData.target; - - onRepeat.func.apply(onRepeat.scope, onRepeat.params); - } - - tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); - - // Delay? - if (tweenData.repeatDelay > 0) - { - tweenData.elapsed = tweenData.repeatDelay - diff; - - tweenData.current = tweenData.start; - - tweenData.target[tweenData.key] = tweenData.current; - - return TWEEN_CONST.REPEAT_DELAY; - } - else - { - return TWEEN_CONST.PLAYING_FORWARD; - } - } - - return TWEEN_CONST.COMPLETE; - }, - - // - /** - * [description] - * - * @method Phaser.Tweens.Tween#updateTweenData - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * @param {Phaser.Tweens.TweenData} tweenData - [description] - * @param {number} delta - Either a value in ms, or 1 if Tween.useFrames is true - * - * @return {boolean} [description] - */ - updateTweenData: function (tween, tweenData, delta) - { - switch (tweenData.state) - { - case TWEEN_CONST.PLAYING_FORWARD: - case TWEEN_CONST.PLAYING_BACKWARD: - - if (!tweenData.target) - { - tweenData.state = TWEEN_CONST.COMPLETE; - break; - } - - var elapsed = tweenData.elapsed; - var duration = tweenData.duration; - var diff = 0; - - elapsed += delta; - - if (elapsed > duration) - { - diff = elapsed - duration; - elapsed = duration; - } - - var forward = (tweenData.state === TWEEN_CONST.PLAYING_FORWARD); - var progress = elapsed / duration; - - var v; - - if (forward) - { - v = tweenData.ease(progress); - } - else - { - v = tweenData.ease(1 - progress); - } - - tweenData.current = tweenData.start + ((tweenData.end - tweenData.start) * v); - - tweenData.target[tweenData.key] = tweenData.current; - - tweenData.elapsed = elapsed; - tweenData.progress = progress; - - var onUpdate = tween.callbacks.onUpdate; - - if (onUpdate) - { - onUpdate.params[1] = tweenData.target; - - onUpdate.func.apply(onUpdate.scope, onUpdate.params); - } - - if (progress === 1) - { - if (forward) - { - if (tweenData.hold > 0) - { - tweenData.elapsed = tweenData.hold - diff; - - tweenData.state = TWEEN_CONST.HOLD_DELAY; - } - else - { - tweenData.state = this.setStateFromEnd(tween, tweenData, diff); - } - } - else - { - tweenData.state = this.setStateFromStart(tween, tweenData, diff); - } - } - - break; - - case TWEEN_CONST.DELAY: - - tweenData.elapsed -= delta; - - if (tweenData.elapsed <= 0) - { - tweenData.elapsed = Math.abs(tweenData.elapsed); - - tweenData.state = TWEEN_CONST.PENDING_RENDER; - } - - break; - - case TWEEN_CONST.REPEAT_DELAY: - - tweenData.elapsed -= delta; - - if (tweenData.elapsed <= 0) - { - tweenData.elapsed = Math.abs(tweenData.elapsed); - - tweenData.state = TWEEN_CONST.PLAYING_FORWARD; - } - - break; - - case TWEEN_CONST.HOLD_DELAY: - - tweenData.elapsed -= delta; - - if (tweenData.elapsed <= 0) - { - tweenData.state = this.setStateFromEnd(tween, tweenData, Math.abs(tweenData.elapsed)); - } - - break; - - case TWEEN_CONST.PENDING_RENDER: - - if (tweenData.target) - { - tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.target[tweenData.key]); - - tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); - - tweenData.current = tweenData.start; - - tweenData.target[tweenData.key] = tweenData.start; - - tweenData.state = TWEEN_CONST.PLAYING_FORWARD; - } - else - { - tweenData.state = TWEEN_CONST.COMPLETE; - } - - break; - } - - // Return TRUE if this TweenData still playing, otherwise return FALSE - return (tweenData.state !== TWEEN_CONST.COMPLETE); + r = 1 - r; + s = 1 - s; } -}); + out.x = triangle.x1 + ((ux * r) + (vx * s)); + out.y = triangle.y1 + ((uy * r) + (vy * s)); -Tween.TYPES = [ - 'onComplete', - 'onLoop', - 'onRepeat', - 'onStart', - 'onUpdate', - 'onYoyo' -]; + return out; +}; -/** - * Creates a new Tween object. - * - * Note: This method will only be available Tweens have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#tween - * @since 3.0.0 - * - * @param {object} config - The Tween configuration. - * - * @return {Phaser.Tweens.Tween} The Tween that was created. - */ -GameObjectFactory.register('tween', function (config) -{ - return this.scene.sys.tweens.add(config); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - -/** - * Creates a new Tween object and returns it. - * - * Note: This method will only be available if Tweens have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#tween - * @since 3.0.0 - * - * @param {object} config - The Tween configuration. - * - * @return {Phaser.Tweens.Tween} The Tween that was created. - */ -GameObjectCreator.register('tween', function (config) -{ - return this.scene.sys.tweens.create(config); -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - -module.exports = Tween; +module.exports = Random; /***/ }), /* 162 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -35849,108 +36880,33 @@ module.exports = Tween; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Point = __webpack_require__(4); + /** - * [description] + * Returns a uniformly distributed random point from anywhere within the given Ellipse. * - * @function Phaser.Tweens.TweenData + * @function Phaser.Geom.Ellipse.Random * @since 3.0.0 * - * @param {object} target - [description] - * @param {string} key - [description] - * @param {function} getEnd - [description] - * @param {function} getStart - [description] - * @param {function} ease - [description] - * @param {number} delay - [description] - * @param {number} duration - [description] - * @param {boolean} yoyo - [description] - * @param {number} hold - [description] - * @param {number} repeat - [description] - * @param {number} repeatDelay - [description] - * @param {boolean} flipX - [description] - * @param {boolean} flipY - [description] + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get a random point from. + * @param {(Phaser.Geom.Point|object)} [point] - A Point or point-like object to set the random `x` and `y` values in. * - * @return {Phaser.Tweens.TweenData} [description] + * @return {(Phaser.Geom.Point|object)} A Point object with the random values set in the `x` and `y` properties. */ -var TweenData = function (target, key, getEnd, getStart, ease, delay, duration, yoyo, hold, repeat, repeatDelay, flipX, flipY) +var Random = function (ellipse, out) { - return { + if (out === undefined) { out = new Point(); } - // The target to tween - target: target, + var p = Math.random() * Math.PI * 2; + var s = Math.sqrt(Math.random()); - // The property of the target to tween - key: key, + out.x = ellipse.x + ((s * Math.cos(p)) * ellipse.width / 2); + out.y = ellipse.y + ((s * Math.sin(p)) * ellipse.height / 2); - // The returned value sets what the property will be at the END of the Tween. - getEndValue: getEnd, - - // The returned value sets what the property will be at the START of the Tween. - getStartValue: getStart, - - // The ease function this tween uses. - ease: ease, - - // Duration of the tween in ms/frames, excludes time for yoyo or repeats. - duration: 0, - - // The total calculated duration of this TweenData (based on duration, repeat, delay and yoyo) - totalDuration: 0, - - // Time in ms/frames before tween will start. - delay: 0, - - // Cause the tween to return back to its start value after hold has expired. - yoyo: yoyo, - - // Time in ms/frames the tween will pause before running the yoyo or starting a repeat. - hold: 0, - - // Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. - repeat: 0, - - // Time in ms/frames before the repeat will start. - repeatDelay: 0, - - // Automatically call toggleFlipX when the TweenData yoyos or repeats - flipX: flipX, - - // Automatically call toggleFlipY when the TweenData yoyos or repeats - flipY: flipY, - - // Between 0 and 1 showing completion of this TweenData. - progress: 0, - - // Delta counter. - elapsed: 0, - - // How many repeats are left to run? - repeatCounter: 0, - - // Ease Value Data: - - start: 0, - current: 0, - end: 0, - - // Time Durations - t1: 0, - t2: 0, - - // LoadValue generation functions - gen: { - delay: delay, - duration: duration, - hold: hold, - repeat: repeat, - repeatDelay: repeatDelay - }, - - // TWEEN_CONST.CREATED - state: 0 - }; + return out; }; -module.exports = TweenData; +module.exports = Random; /***/ }), @@ -35963,24 +36919,30 @@ module.exports = TweenData; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var MathWrap = __webpack_require__(50); +var Point = __webpack_require__(4); /** * [description] * - * @function Phaser.Math.Angle.Wrap + * @function Phaser.Geom.Rectangle.Random * @since 3.0.0 * - * @param {number} angle - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Point} out - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Point} [description] */ -var Wrap = function (angle) +var Random = function (rect, out) { - return MathWrap(angle, -Math.PI, Math.PI); + if (out === undefined) { out = new Point(); } + + out.x = rect.x + (Math.random() * rect.width); + out.y = rect.y + (Math.random() * rect.height); + + return out; }; -module.exports = Wrap; +module.exports = Random; /***/ }), @@ -35993,24 +36955,32 @@ module.exports = Wrap; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Wrap = __webpack_require__(50); +var Point = __webpack_require__(4); /** * [description] * - * @function Phaser.Math.Angle.WrapDegrees + * @function Phaser.Geom.Line.Random * @since 3.0.0 * - * @param {number} angle - [description] + * @param {Phaser.Geom.Line} line - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] * - * @return {number} [description] + * @return {(Phaser.Geom.Point|object)} [description] */ -var WrapDegrees = function (angle) +var Random = function (line, out) { - return Wrap(angle, -180, 180); + if (out === undefined) { out = new Point(); } + + var t = Math.random(); + + out.x = line.x1 + t * (line.x2 - line.x1); + out.y = line.y1 + t * (line.y2 - line.y1); + + return out; }; -module.exports = WrapDegrees; +module.exports = Random; /***/ }), @@ -36023,402 +36993,920 @@ module.exports = WrapDegrees; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var ShaderSourceFS = __webpack_require__(515); -var TextureTintPipeline = __webpack_require__(166); - -var LIGHT_COUNT = 10; +var Length = __webpack_require__(77); +var Point = __webpack_require__(4); /** - * @classdesc * [description] * - * @class ForwardDiffuseLightPipeline - * @extends Phaser.Renderer.WebGL.TextureTintPipeline - * @memberOf Phaser.Renderer.WebGL - * @constructor + * @function Phaser.Geom.Line.GetPoints * @since 3.0.0 * - * @param {object} config - [description] + * @param {Phaser.Geom.Line} line - [description] + * @param {integer} quantity - [description] + * @param {integer} [stepRate] - [description] + * @param {array} out - [description] + * + * @return {array} [description] */ -var ForwardDiffuseLightPipeline = new Class({ +var GetPoints = function (line, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } - Extends: TextureTintPipeline, - - initialize: - - function ForwardDiffuseLightPipeline (config) + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) { - config.fragShader = ShaderSourceFS.replace('%LIGHT_COUNT%', LIGHT_COUNT.toString()); - - TextureTintPipeline.call(this, config); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#onBind - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline} [description] - */ - onBind: function () - { - TextureTintPipeline.prototype.onBind.call(this); - - var renderer = this.renderer; - var program = this.program; - - this.mvpUpdate(); - - renderer.setInt1(program, 'uNormSampler', 1); - renderer.setFloat2(program, 'uResolution', this.width, this.height); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#onRender - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - * @return {Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline} [description] - */ - onRender: function (scene, camera) - { - var lightManager = scene.sys.lights; - - if (!lightManager) - { - return this; - } - - lightManager.culledLights.length = 0; - - if (lightManager.lights.length <= 0 || !lightManager.active) - { - return this; // If not visible lights just passthrough - } - - var renderer = this.renderer; - var program = this.program; - var lights = lightManager.cull(camera); - var lightCount = Math.min(lights.length, LIGHT_COUNT); - var cameraMatrix = camera.matrix; - var point = {x: 0, y: 0}; - var height = renderer.height; - var index; - - for (index = 0; index < LIGHT_COUNT; ++index) - { - renderer.setFloat1(program, 'uLights[' + index + '].radius', 0); // reset lights - } - - if (lightCount <= 0) { return this; } - - renderer.setFloat4(program, 'uCamera', camera.x, camera.y, camera.rotation, camera.zoom); - renderer.setFloat3(program, 'uAmbientLightColor', lightManager.ambientColor.r, lightManager.ambientColor.g, lightManager.ambientColor.b); - - for (index = 0; index < lightCount; ++index) - { - var light = lights[index]; - var lightName = 'uLights[' + index + '].'; - cameraMatrix.transformPoint(light.x, light.y, point); - renderer.setFloat2(program, lightName + 'position', point.x - (camera.scrollX * light.scrollFactorX * camera.zoom), height - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom)); - renderer.setFloat3(program, lightName + 'color', light.r, light.g, light.b); - renderer.setFloat1(program, lightName + 'intensity', light.intensity); - renderer.setFloat1(program, lightName + 'radius', light.radius); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#drawStaticTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.StaticTilemapLayer} tilemap - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - */ - drawStaticTilemapLayer: function (tilemap, camera) - { - var normalTexture = tilemap.texture.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.drawStaticTilemapLayer.call(this, tilemap, camera); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. StaticTilemapLayer rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.drawStaticTilemapLayer(tilemap, camera); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#drawEmitterManager - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - */ - drawEmitterManager: function (emitterManager, camera) - { - var normalTexture = emitterManager.texture.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.drawEmitterManager.call(this, emitterManager, camera); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. EmitterManager rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.drawEmitterManager(emitterManager, camera); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#drawBlitter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter} blitter - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - */ - drawBlitter: function (blitter, camera) - { - var normalTexture = blitter.texture.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.drawBlitter.call(this, blitter, camera); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. Blitter rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.drawBlitter(blitter, camera); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Sprite} sprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - */ - batchSprite: function (sprite, camera) - { - var normalTexture = sprite.texture.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchSprite.call(this, sprite, camera); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. Sprite rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchSprite(sprite, camera); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchMesh - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Mesh} mesh - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - */ - batchMesh: function (mesh, camera) - { - var normalTexture = mesh.texture.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchMesh.call(this, mesh, camera); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. Mesh rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchMesh(mesh, camera); - - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.BitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - */ - batchBitmapText: function (bitmapText, camera) - { - var normalTexture = bitmapText.texture.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchBitmapText.call(this, bitmapText, camera); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. BitmapText rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchBitmapText(bitmapText, camera); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchDynamicBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.DynamicBitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - */ - batchDynamicBitmapText: function (bitmapText, camera) - { - var normalTexture = bitmapText.texture.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchDynamicBitmapText.call(this, bitmapText, camera); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. DynamicBitmapText rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchDynamicBitmapText(bitmapText, camera); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Text} text - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - */ - batchText: function (text, camera) - { - var normalTexture = text.texture.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchText.call(this, text, camera); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. Text rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchText(text, camera); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchDynamicTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.DynamicTilemapLayer} tilemapLayer - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - */ - batchDynamicTilemapLayer: function (tilemapLayer, camera) - { - var normalTexture = tilemapLayer.texture.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchDynamicTilemapLayer.call(this, tilemapLayer, camera); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. DynamicTilemapLayer rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchDynamicTilemapLayer(tilemapLayer, camera); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchTileSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.TileSprite} tileSprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - */ - batchTileSprite: function (tileSprite, camera) - { - var normalTexture = tileSprite.texture.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchTileSprite.call(this, tileSprite, camera); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. TileSprite rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchTileSprite(tileSprite, camera); - } + quantity = Length(line) / stepRate; } -}); + var x1 = line.x1; + var y1 = line.y1; -ForwardDiffuseLightPipeline.LIGHT_COUNT = LIGHT_COUNT; + var x2 = line.x2; + var y2 = line.y2; -module.exports = ForwardDiffuseLightPipeline; + for (var i = 0; i < quantity; i++) + { + var position = i / quantity; + + var x = x1 + (x2 - x1) * position; + var y = y1 + (y2 - y1) * position; + + out.push(new Point(x, y)); + } + + return out; +}; + +module.exports = GetPoints; /***/ }), /* 166 */ /***/ (function(module, exports, __webpack_require__) { +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Perimeter = __webpack_require__(105); +var Point = __webpack_require__(4); + +/** + * Position is a value between 0 and 1 where 0 = the top-left of the rectangle and 0.5 = the bottom right. + * + * @function Phaser.Geom.Rectangle.GetPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rectangle - [description] + * @param {float} position - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var GetPoint = function (rectangle, position, out) +{ + if (out === undefined) { out = new Point(); } + + if (position <= 0 || position >= 1) + { + out.x = rectangle.x; + out.y = rectangle.y; + + return out; + } + + var p = Perimeter(rectangle) * position; + + if (position > 0.5) + { + p -= (rectangle.width + rectangle.height); + + if (p <= rectangle.width) + { + // Face 3 + out.x = rectangle.right - p; + out.y = rectangle.bottom; + } + else + { + // Face 4 + out.x = rectangle.x; + out.y = rectangle.bottom - (p - rectangle.width); + } + } + else if (p <= rectangle.width) + { + // Face 1 + out.x = rectangle.x + p; + out.y = rectangle.y; + } + else + { + // Face 2 + out.x = rectangle.right; + out.y = rectangle.y + (p - rectangle.width); + } + + return out; +}; + +module.exports = GetPoint; + + +/***/ }), +/* 167 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +/** + * Returns a uniformly distributed random point from anywhere within the given Circle. + * + * @function Phaser.Geom.Circle.Random + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to get a random point from. + * @param {(Phaser.Geom.Point|object)} [point] - A Point or point-like object to set the random `x` and `y` values in. + * + * @return {(Phaser.Geom.Point|object)} A Point object with the random values set in the `x` and `y` properties. + */ +var Random = function (circle, out) +{ + if (out === undefined) { out = new Point(); } + + var t = 2 * Math.PI * Math.random(); + var u = Math.random() + Math.random(); + var r = (u > 1) ? 2 - u : u; + var x = r * Math.cos(t); + var y = r * Math.sin(t); + + out.x = circle.x + (x * circle.radius); + out.y = circle.y + (y * circle.radius); + + return out; +}; + +module.exports = Random; + + +/***/ }), +/* 168 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +/** + * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle. + * + * @function Phaser.Geom.Circle.CircumferencePoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on. + * @param {number} angle - The angle from the center of the Circle to the circumference to return the point from. Given in radians. + * @param {(Phaser.Geom.Point|object)} [out] - A Point, or point-like object, to store the results in. If not given a Point will be created. + * + * @return {(Phaser.Geom.Point|object)} A Point object where the `x` and `y` properties are the point on the circumference. + */ +var CircumferencePoint = function (circle, angle, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = circle.x + (circle.radius * Math.cos(angle)); + out.y = circle.y + (circle.radius * Math.sin(angle)); + + return out; +}; + +module.exports = CircumferencePoint; + + +/***/ }), +/* 169 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ALIGN_CONST = { + + /** + * A constant representing a top-left alignment or position. + * @constant + * @name Phaser.Display.Align.TOP_LEFT + * @since 3.0.0 + * @type {integer} + */ + TOP_LEFT: 0, + + /** + * A constant representing a top-center alignment or position. + * @constant + * @name Phaser.Display.Align.TOP_CENTER + * @since 3.0.0 + * @type {integer} + */ + TOP_CENTER: 1, + + /** + * A constant representing a top-right alignment or position. + * @constant + * @name Phaser.Display.Align.TOP_RIGHT + * @since 3.0.0 + * @type {integer} + */ + TOP_RIGHT: 2, + + /** + * A constant representing a left-top alignment or position. + * @constant + * @name Phaser.Display.Align.LEFT_TOP + * @since 3.0.0 + * @type {integer} + */ + LEFT_TOP: 3, + + /** + * A constant representing a left-center alignment or position. + * @constant + * @name Phaser.Display.Align.LEFT_CENTER + * @since 3.0.0 + * @type {integer} + */ + LEFT_CENTER: 4, + + /** + * A constant representing a left-bottom alignment or position. + * @constant + * @name Phaser.Display.Align.LEFT_BOTTOM + * @since 3.0.0 + * @type {integer} + */ + LEFT_BOTTOM: 5, + + /** + * A constant representing a center alignment or position. + * @constant + * @name Phaser.Display.Align.CENTER + * @since 3.0.0 + * @type {integer} + */ + CENTER: 6, + + /** + * A constant representing a right-top alignment or position. + * @constant + * @name Phaser.Display.Align.RIGHT_TOP + * @since 3.0.0 + * @type {integer} + */ + RIGHT_TOP: 7, + + /** + * A constant representing a right-center alignment or position. + * @constant + * @name Phaser.Display.Align.RIGHT_CENTER + * @since 3.0.0 + * @type {integer} + */ + RIGHT_CENTER: 8, + + /** + * A constant representing a right-bottom alignment or position. + * @constant + * @name Phaser.Display.Align.RIGHT_BOTTOM + * @since 3.0.0 + * @type {integer} + */ + RIGHT_BOTTOM: 9, + + /** + * A constant representing a bottom-left alignment or position. + * @constant + * @name Phaser.Display.Align.BOTTOM_LEFT + * @since 3.0.0 + * @type {integer} + */ + BOTTOM_LEFT: 10, + + /** + * A constant representing a bottom-center alignment or position. + * @constant + * @name Phaser.Display.Align.BOTTOM_CENTER + * @since 3.0.0 + * @type {integer} + */ + BOTTOM_CENTER: 11, + + /** + * A constant representing a bottom-right alignment or position. + * @constant + * @name Phaser.Display.Align.BOTTOM_RIGHT + * @since 3.0.0 + * @type {integer} + */ + BOTTOM_RIGHT: 12 + +}; + +module.exports = ALIGN_CONST; + + +/***/ }), +/* 170 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Constraint` module contains methods for creating and manipulating constraints. +* Constraints are used for specifying that a fixed distance must be maintained between two bodies (or a body and a fixed world-space position). +* The stiffness of constraints can be modified to create springs or elastic. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Constraint +*/ + +var Constraint = {}; + +module.exports = Constraint; + +var Vertices = __webpack_require__(91); +var Vector = __webpack_require__(90); +var Sleeping = __webpack_require__(198); +var Bounds = __webpack_require__(89); +var Axes = __webpack_require__(468); +var Common = __webpack_require__(39); + +(function() { + + Constraint._warming = 0.4; + Constraint._torqueDampen = 1; + Constraint._minLength = 0.000001; + + /** + * Creates a new constraint. + * All properties have default values, and many are pre-calculated automatically based on other properties. + * To simulate a revolute constraint (or pin joint) set `length: 0` and a high `stiffness` value (e.g. `0.7` or above). + * If the constraint is unstable, try lowering the `stiffness` value and / or increasing `engine.constraintIterations`. + * See the properties section below for detailed information on what you can pass via the `options` object. + * @method create + * @param {} options + * @return {constraint} constraint + */ + Constraint.create = function(options) { + var constraint = options; + + // if bodies defined but no points, use body centre + if (constraint.bodyA && !constraint.pointA) + constraint.pointA = { x: 0, y: 0 }; + if (constraint.bodyB && !constraint.pointB) + constraint.pointB = { x: 0, y: 0 }; + + // calculate static length using initial world space points + var initialPointA = constraint.bodyA ? Vector.add(constraint.bodyA.position, constraint.pointA) : constraint.pointA, + initialPointB = constraint.bodyB ? Vector.add(constraint.bodyB.position, constraint.pointB) : constraint.pointB, + length = Vector.magnitude(Vector.sub(initialPointA, initialPointB)); + + constraint.length = typeof constraint.length !== 'undefined' ? constraint.length : length; + + // option defaults + constraint.id = constraint.id || Common.nextId(); + constraint.label = constraint.label || 'Constraint'; + constraint.type = 'constraint'; + constraint.stiffness = constraint.stiffness || (constraint.length > 0 ? 1 : 0.7); + constraint.damping = constraint.damping || 0; + constraint.angularStiffness = constraint.angularStiffness || 0; + constraint.angleA = constraint.bodyA ? constraint.bodyA.angle : constraint.angleA; + constraint.angleB = constraint.bodyB ? constraint.bodyB.angle : constraint.angleB; + constraint.plugin = {}; + + // render + var render = { + visible: true, + lineWidth: 2, + strokeStyle: '#ffffff', + type: 'line', + anchors: true + }; + + if (constraint.length === 0 && constraint.stiffness > 0.1) { + render.type = 'pin'; + render.anchors = false; + } else if (constraint.stiffness < 0.9) { + render.type = 'spring'; + } + + constraint.render = Common.extend(render, constraint.render); + + return constraint; + }; + + /** + * Prepares for solving by constraint warming. + * @private + * @method preSolveAll + * @param {body[]} bodies + */ + Constraint.preSolveAll = function(bodies) { + for (var i = 0; i < bodies.length; i += 1) { + var body = bodies[i], + impulse = body.constraintImpulse; + + if (body.isStatic || (impulse.x === 0 && impulse.y === 0 && impulse.angle === 0)) { + continue; + } + + body.position.x += impulse.x; + body.position.y += impulse.y; + body.angle += impulse.angle; + } + }; + + /** + * Solves all constraints in a list of collisions. + * @private + * @method solveAll + * @param {constraint[]} constraints + * @param {number} timeScale + */ + Constraint.solveAll = function(constraints, timeScale) { + // Solve fixed constraints first. + for (var i = 0; i < constraints.length; i += 1) { + var constraint = constraints[i], + fixedA = !constraint.bodyA || (constraint.bodyA && constraint.bodyA.isStatic), + fixedB = !constraint.bodyB || (constraint.bodyB && constraint.bodyB.isStatic); + + if (fixedA || fixedB) { + Constraint.solve(constraints[i], timeScale); + } + } + + // Solve free constraints last. + for (i = 0; i < constraints.length; i += 1) { + constraint = constraints[i]; + fixedA = !constraint.bodyA || (constraint.bodyA && constraint.bodyA.isStatic); + fixedB = !constraint.bodyB || (constraint.bodyB && constraint.bodyB.isStatic); + + if (!fixedA && !fixedB) { + Constraint.solve(constraints[i], timeScale); + } + } + }; + + /** + * Solves a distance constraint with Gauss-Siedel method. + * @private + * @method solve + * @param {constraint} constraint + * @param {number} timeScale + */ + Constraint.solve = function(constraint, timeScale) { + var bodyA = constraint.bodyA, + bodyB = constraint.bodyB, + pointA = constraint.pointA, + pointB = constraint.pointB; + + if (!bodyA && !bodyB) + return; + + // update reference angle + if (bodyA && !bodyA.isStatic) { + Vector.rotate(pointA, bodyA.angle - constraint.angleA, pointA); + constraint.angleA = bodyA.angle; + } + + // update reference angle + if (bodyB && !bodyB.isStatic) { + Vector.rotate(pointB, bodyB.angle - constraint.angleB, pointB); + constraint.angleB = bodyB.angle; + } + + var pointAWorld = pointA, + pointBWorld = pointB; + + if (bodyA) pointAWorld = Vector.add(bodyA.position, pointA); + if (bodyB) pointBWorld = Vector.add(bodyB.position, pointB); + + if (!pointAWorld || !pointBWorld) + return; + + var delta = Vector.sub(pointAWorld, pointBWorld), + currentLength = Vector.magnitude(delta); + + // prevent singularity + if (currentLength < Constraint._minLength) { + currentLength = Constraint._minLength; + } + + // solve distance constraint with Gauss-Siedel method + var difference = (currentLength - constraint.length) / currentLength, + stiffness = constraint.stiffness < 1 ? constraint.stiffness * timeScale : constraint.stiffness, + force = Vector.mult(delta, difference * stiffness), + massTotal = (bodyA ? bodyA.inverseMass : 0) + (bodyB ? bodyB.inverseMass : 0), + inertiaTotal = (bodyA ? bodyA.inverseInertia : 0) + (bodyB ? bodyB.inverseInertia : 0), + resistanceTotal = massTotal + inertiaTotal, + torque, + share, + normal, + normalVelocity, + relativeVelocity; + + if (constraint.damping) { + var zero = Vector.create(); + normal = Vector.div(delta, currentLength); + + relativeVelocity = Vector.sub( + bodyB && Vector.sub(bodyB.position, bodyB.positionPrev) || zero, + bodyA && Vector.sub(bodyA.position, bodyA.positionPrev) || zero + ); + + normalVelocity = Vector.dot(normal, relativeVelocity); + } + + if (bodyA && !bodyA.isStatic) { + share = bodyA.inverseMass / massTotal; + + // keep track of applied impulses for post solving + bodyA.constraintImpulse.x -= force.x * share; + bodyA.constraintImpulse.y -= force.y * share; + + // apply forces + bodyA.position.x -= force.x * share; + bodyA.position.y -= force.y * share; + + // apply damping + if (constraint.damping) { + bodyA.positionPrev.x -= constraint.damping * normal.x * normalVelocity * share; + bodyA.positionPrev.y -= constraint.damping * normal.y * normalVelocity * share; + } + + // apply torque + torque = (Vector.cross(pointA, force) / resistanceTotal) * Constraint._torqueDampen * bodyA.inverseInertia * (1 - constraint.angularStiffness); + bodyA.constraintImpulse.angle -= torque; + bodyA.angle -= torque; + } + + if (bodyB && !bodyB.isStatic) { + share = bodyB.inverseMass / massTotal; + + // keep track of applied impulses for post solving + bodyB.constraintImpulse.x += force.x * share; + bodyB.constraintImpulse.y += force.y * share; + + // apply forces + bodyB.position.x += force.x * share; + bodyB.position.y += force.y * share; + + // apply damping + if (constraint.damping) { + bodyB.positionPrev.x += constraint.damping * normal.x * normalVelocity * share; + bodyB.positionPrev.y += constraint.damping * normal.y * normalVelocity * share; + } + + // apply torque + torque = (Vector.cross(pointB, force) / resistanceTotal) * Constraint._torqueDampen * bodyB.inverseInertia * (1 - constraint.angularStiffness); + bodyB.constraintImpulse.angle += torque; + bodyB.angle += torque; + } + + }; + + /** + * Performs body updates required after solving constraints. + * @private + * @method postSolveAll + * @param {body[]} bodies + */ + Constraint.postSolveAll = function(bodies) { + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i], + impulse = body.constraintImpulse; + + if (body.isStatic || (impulse.x === 0 && impulse.y === 0 && impulse.angle === 0)) { + continue; + } + + Sleeping.set(body, false); + + // update geometry and reset + for (var j = 0; j < body.parts.length; j++) { + var part = body.parts[j]; + + Vertices.translate(part.vertices, impulse); + + if (j > 0) { + part.position.x += impulse.x; + part.position.y += impulse.y; + } + + if (impulse.angle !== 0) { + Vertices.rotate(part.vertices, impulse.angle, body.position); + Axes.rotate(part.axes, impulse.angle); + if (j > 0) { + Vector.rotateAbout(part.position, impulse.angle, body.position, part.position); + } + } + + Bounds.update(part.bounds, part.vertices, body.velocity); + } + + // dampen the cached impulse for warming next step + impulse.angle *= Constraint._warming; + impulse.x *= Constraint._warming; + impulse.y *= Constraint._warming; + } + }; + + /* + * + * Properties Documentation + * + */ + + /** + * An integer `Number` uniquely identifying number generated in `Composite.create` by `Common.nextId`. + * + * @property id + * @type number + */ + + /** + * A `String` denoting the type of object. + * + * @property type + * @type string + * @default "constraint" + * @readOnly + */ + + /** + * An arbitrary `String` name to help the user identify and manage bodies. + * + * @property label + * @type string + * @default "Constraint" + */ + + /** + * An `Object` that defines the rendering properties to be consumed by the module `Matter.Render`. + * + * @property render + * @type object + */ + + /** + * A flag that indicates if the constraint should be rendered. + * + * @property render.visible + * @type boolean + * @default true + */ + + /** + * A `Number` that defines the line width to use when rendering the constraint outline. + * A value of `0` means no outline will be rendered. + * + * @property render.lineWidth + * @type number + * @default 2 + */ + + /** + * A `String` that defines the stroke style to use when rendering the constraint outline. + * It is the same as when using a canvas, so it accepts CSS style property values. + * + * @property render.strokeStyle + * @type string + * @default a random colour + */ + + /** + * A `String` that defines the constraint rendering type. + * The possible values are 'line', 'pin', 'spring'. + * An appropriate render type will be automatically chosen unless one is given in options. + * + * @property render.type + * @type string + * @default 'line' + */ + + /** + * A `Boolean` that defines if the constraint's anchor points should be rendered. + * + * @property render.anchors + * @type boolean + * @default true + */ + + /** + * The first possible `Body` that this constraint is attached to. + * + * @property bodyA + * @type body + * @default null + */ + + /** + * The second possible `Body` that this constraint is attached to. + * + * @property bodyB + * @type body + * @default null + */ + + /** + * A `Vector` that specifies the offset of the constraint from center of the `constraint.bodyA` if defined, otherwise a world-space position. + * + * @property pointA + * @type vector + * @default { x: 0, y: 0 } + */ + + /** + * A `Vector` that specifies the offset of the constraint from center of the `constraint.bodyA` if defined, otherwise a world-space position. + * + * @property pointB + * @type vector + * @default { x: 0, y: 0 } + */ + + /** + * A `Number` that specifies the stiffness of the constraint, i.e. the rate at which it returns to its resting `constraint.length`. + * A value of `1` means the constraint should be very stiff. + * A value of `0.2` means the constraint acts like a soft spring. + * + * @property stiffness + * @type number + * @default 1 + */ + + /** + * A `Number` that specifies the damping of the constraint, + * i.e. the amount of resistance applied to each body based on their velocities to limit the amount of oscillation. + * Damping will only be apparent when the constraint also has a very low `stiffness`. + * A value of `0.1` means the constraint will apply heavy damping, resulting in little to no oscillation. + * A value of `0` means the constraint will apply no damping. + * + * @property damping + * @type number + * @default 0 + */ + + /** + * A `Number` that specifies the target resting length of the constraint. + * It is calculated automatically in `Constraint.create` from initial positions of the `constraint.bodyA` and `constraint.bodyB`. + * + * @property length + * @type number + */ + + /** + * An object reserved for storing plugin-specific properties. + * + * @property plugin + * @type {} + */ + +})(); + + +/***/ }), +/* 171 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Events` module contains methods to fire and listen to events on other objects. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Events +*/ + +var Events = {}; + +module.exports = Events; + +var Common = __webpack_require__(39); + +(function() { + + /** + * Subscribes a callback function to the given object's `eventName`. + * @method on + * @param {} object + * @param {string} eventNames + * @param {function} callback + */ + Events.on = function(object, eventNames, callback) { + var names = eventNames.split(' '), + name; + + for (var i = 0; i < names.length; i++) { + name = names[i]; + object.events = object.events || {}; + object.events[name] = object.events[name] || []; + object.events[name].push(callback); + } + + return callback; + }; + + /** + * Removes the given event callback. If no callback, clears all callbacks in `eventNames`. If no `eventNames`, clears all events. + * @method off + * @param {} object + * @param {string} eventNames + * @param {function} callback + */ + Events.off = function(object, eventNames, callback) { + if (!eventNames) { + object.events = {}; + return; + } + + // handle Events.off(object, callback) + if (typeof eventNames === 'function') { + callback = eventNames; + eventNames = Common.keys(object.events).join(' '); + } + + var names = eventNames.split(' '); + + for (var i = 0; i < names.length; i++) { + var callbacks = object.events[names[i]], + newCallbacks = []; + + if (callback && callbacks) { + for (var j = 0; j < callbacks.length; j++) { + if (callbacks[j] !== callback) + newCallbacks.push(callbacks[j]); + } + } + + object.events[names[i]] = newCallbacks; + } + }; + + /** + * Fires all the callbacks subscribed to the given object's `eventName`, in the order they subscribed, if any. + * @method trigger + * @param {} object + * @param {string} eventNames + * @param {} event + */ + Events.trigger = function(object, eventNames, event) { + var names, + name, + callbacks, + eventClone; + + if (object.events) { + if (!event) + event = {}; + + names = eventNames.split(' '); + + for (var i = 0; i < names.length; i++) { + name = names[i]; + callbacks = object.events[name]; + + if (callbacks) { + eventClone = Common.clone(event, false); + eventClone.name = name; + eventClone.source = object; + + for (var j = 0; j < callbacks.length; j++) { + callbacks[j].apply(object, [eventClone]); + } + } + } + } + }; + +})(); + + +/***/ }), +/* 172 */ +/***/ (function(module, exports, __webpack_require__) { + /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. @@ -36426,11 +37914,11 @@ module.exports = ForwardDiffuseLightPipeline; */ var Class = __webpack_require__(0); -var ModelViewProjection = __webpack_require__(239); -var ShaderSourceFS = __webpack_require__(516); -var ShaderSourceVS = __webpack_require__(517); -var Utils = __webpack_require__(41); -var WebGLPipeline = __webpack_require__(103); +var ModelViewProjection = __webpack_require__(300); +var ShaderSourceFS = __webpack_require__(811); +var ShaderSourceVS = __webpack_require__(810); +var Utils = __webpack_require__(44); +var WebGLPipeline = __webpack_require__(108); /** * @classdesc @@ -38248,906 +39736,405 @@ module.exports = TextureTintPipeline; /***/ }), -/* 167 */ +/* 173 */ /***/ (function(module, exports, __webpack_require__) { /** -* The `Matter.Events` module contains methods to fire and listen to events on other objects. -* -* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). -* -* @class Events -*/ + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ -var Events = {}; +var Class = __webpack_require__(0); +var ShaderSourceFS = __webpack_require__(812); +var TextureTintPipeline = __webpack_require__(172); -module.exports = Events; - -var Common = __webpack_require__(38); - -(function() { - - /** - * Subscribes a callback function to the given object's `eventName`. - * @method on - * @param {} object - * @param {string} eventNames - * @param {function} callback - */ - Events.on = function(object, eventNames, callback) { - var names = eventNames.split(' '), - name; - - for (var i = 0; i < names.length; i++) { - name = names[i]; - object.events = object.events || {}; - object.events[name] = object.events[name] || []; - object.events[name].push(callback); - } - - return callback; - }; - - /** - * Removes the given event callback. If no callback, clears all callbacks in `eventNames`. If no `eventNames`, clears all events. - * @method off - * @param {} object - * @param {string} eventNames - * @param {function} callback - */ - Events.off = function(object, eventNames, callback) { - if (!eventNames) { - object.events = {}; - return; - } - - // handle Events.off(object, callback) - if (typeof eventNames === 'function') { - callback = eventNames; - eventNames = Common.keys(object.events).join(' '); - } - - var names = eventNames.split(' '); - - for (var i = 0; i < names.length; i++) { - var callbacks = object.events[names[i]], - newCallbacks = []; - - if (callback && callbacks) { - for (var j = 0; j < callbacks.length; j++) { - if (callbacks[j] !== callback) - newCallbacks.push(callbacks[j]); - } - } - - object.events[names[i]] = newCallbacks; - } - }; - - /** - * Fires all the callbacks subscribed to the given object's `eventName`, in the order they subscribed, if any. - * @method trigger - * @param {} object - * @param {string} eventNames - * @param {} event - */ - Events.trigger = function(object, eventNames, event) { - var names, - name, - callbacks, - eventClone; - - if (object.events) { - if (!event) - event = {}; - - names = eventNames.split(' '); - - for (var i = 0; i < names.length; i++) { - name = names[i]; - callbacks = object.events[name]; - - if (callbacks) { - eventClone = Common.clone(event, false); - eventClone.name = name; - eventClone.source = object; - - for (var j = 0; j < callbacks.length; j++) { - callbacks[j].apply(object, [eventClone]); - } - } - } - } - }; - -})(); - - -/***/ }), -/* 168 */ -/***/ (function(module, exports, __webpack_require__) { +var LIGHT_COUNT = 10; /** -* The `Matter.Constraint` module contains methods for creating and manipulating constraints. -* Constraints are used for specifying that a fixed distance must be maintained between two bodies (or a body and a fixed world-space position). -* The stiffness of constraints can be modified to create springs or elastic. -* -* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). -* -* @class Constraint -*/ + * @classdesc + * [description] + * + * @class ForwardDiffuseLightPipeline + * @extends Phaser.Renderer.WebGL.TextureTintPipeline + * @memberOf Phaser.Renderer.WebGL + * @constructor + * @since 3.0.0 + * + * @param {object} config - [description] + */ +var ForwardDiffuseLightPipeline = new Class({ -var Constraint = {}; + Extends: TextureTintPipeline, -module.exports = Constraint; + initialize: -var Vertices = __webpack_require__(93); -var Vector = __webpack_require__(94); -var Sleeping = __webpack_require__(343); -var Bounds = __webpack_require__(95); -var Axes = __webpack_require__(859); -var Common = __webpack_require__(38); + function ForwardDiffuseLightPipeline (config) + { + config.fragShader = ShaderSourceFS.replace('%LIGHT_COUNT%', LIGHT_COUNT.toString()); -(function() { - - Constraint._warming = 0.4; - Constraint._torqueDampen = 1; - Constraint._minLength = 0.000001; + TextureTintPipeline.call(this, config); + }, /** - * Creates a new constraint. - * All properties have default values, and many are pre-calculated automatically based on other properties. - * To simulate a revolute constraint (or pin joint) set `length: 0` and a high `stiffness` value (e.g. `0.7` or above). - * If the constraint is unstable, try lowering the `stiffness` value and / or increasing `engine.constraintIterations`. - * See the properties section below for detailed information on what you can pass via the `options` object. - * @method create - * @param {} options - * @return {constraint} constraint + * [description] + * + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#onBind + * @since 3.0.0 + * + * @return {Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline} [description] */ - Constraint.create = function(options) { - var constraint = options; + onBind: function () + { + TextureTintPipeline.prototype.onBind.call(this); - // if bodies defined but no points, use body centre - if (constraint.bodyA && !constraint.pointA) - constraint.pointA = { x: 0, y: 0 }; - if (constraint.bodyB && !constraint.pointB) - constraint.pointB = { x: 0, y: 0 }; + var renderer = this.renderer; + var program = this.program; - // calculate static length using initial world space points - var initialPointA = constraint.bodyA ? Vector.add(constraint.bodyA.position, constraint.pointA) : constraint.pointA, - initialPointB = constraint.bodyB ? Vector.add(constraint.bodyB.position, constraint.pointB) : constraint.pointB, - length = Vector.magnitude(Vector.sub(initialPointA, initialPointB)); - - constraint.length = typeof constraint.length !== 'undefined' ? constraint.length : length; + this.mvpUpdate(); - // option defaults - constraint.id = constraint.id || Common.nextId(); - constraint.label = constraint.label || 'Constraint'; - constraint.type = 'constraint'; - constraint.stiffness = constraint.stiffness || (constraint.length > 0 ? 1 : 0.7); - constraint.damping = constraint.damping || 0; - constraint.angularStiffness = constraint.angularStiffness || 0; - constraint.angleA = constraint.bodyA ? constraint.bodyA.angle : constraint.angleA; - constraint.angleB = constraint.bodyB ? constraint.bodyB.angle : constraint.angleB; - constraint.plugin = {}; + renderer.setInt1(program, 'uNormSampler', 1); + renderer.setFloat2(program, 'uResolution', this.width, this.height); - // render - var render = { - visible: true, - lineWidth: 2, - strokeStyle: '#ffffff', - type: 'line', - anchors: true - }; - - if (constraint.length === 0 && constraint.stiffness > 0.1) { - render.type = 'pin'; - render.anchors = false; - } else if (constraint.stiffness < 0.9) { - render.type = 'spring'; - } - - constraint.render = Common.extend(render, constraint.render); - - return constraint; - }; + return this; + }, /** - * Prepares for solving by constraint warming. - * @private - * @method preSolveAll - * @param {body[]} bodies + * [description] + * + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#onRender + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + * @return {Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline} [description] */ - Constraint.preSolveAll = function(bodies) { - for (var i = 0; i < bodies.length; i += 1) { - var body = bodies[i], - impulse = body.constraintImpulse; + onRender: function (scene, camera) + { + var lightManager = scene.sys.lights; - if (body.isStatic || (impulse.x === 0 && impulse.y === 0 && impulse.angle === 0)) { - continue; - } - - body.position.x += impulse.x; - body.position.y += impulse.y; - body.angle += impulse.angle; - } - }; - - /** - * Solves all constraints in a list of collisions. - * @private - * @method solveAll - * @param {constraint[]} constraints - * @param {number} timeScale - */ - Constraint.solveAll = function(constraints, timeScale) { - // Solve fixed constraints first. - for (var i = 0; i < constraints.length; i += 1) { - var constraint = constraints[i], - fixedA = !constraint.bodyA || (constraint.bodyA && constraint.bodyA.isStatic), - fixedB = !constraint.bodyB || (constraint.bodyB && constraint.bodyB.isStatic); - - if (fixedA || fixedB) { - Constraint.solve(constraints[i], timeScale); - } + if (!lightManager) + { + return this; } - // Solve free constraints last. - for (i = 0; i < constraints.length; i += 1) { - constraint = constraints[i]; - fixedA = !constraint.bodyA || (constraint.bodyA && constraint.bodyA.isStatic); - fixedB = !constraint.bodyB || (constraint.bodyB && constraint.bodyB.isStatic); + lightManager.culledLights.length = 0; - if (!fixedA && !fixedB) { - Constraint.solve(constraints[i], timeScale); - } + if (lightManager.lights.length <= 0 || !lightManager.active) + { + return this; // If not visible lights just passthrough } - }; - /** - * Solves a distance constraint with Gauss-Siedel method. - * @private - * @method solve - * @param {constraint} constraint - * @param {number} timeScale - */ - Constraint.solve = function(constraint, timeScale) { - var bodyA = constraint.bodyA, - bodyB = constraint.bodyB, - pointA = constraint.pointA, - pointB = constraint.pointB; + var renderer = this.renderer; + var program = this.program; + var lights = lightManager.cull(camera); + var lightCount = Math.min(lights.length, LIGHT_COUNT); + var cameraMatrix = camera.matrix; + var point = {x: 0, y: 0}; + var height = renderer.height; + var index; - if (!bodyA && !bodyB) - return; + for (index = 0; index < LIGHT_COUNT; ++index) + { + renderer.setFloat1(program, 'uLights[' + index + '].radius', 0); // reset lights + } - // update reference angle - if (bodyA && !bodyA.isStatic) { - Vector.rotate(pointA, bodyA.angle - constraint.angleA, pointA); - constraint.angleA = bodyA.angle; + if (lightCount <= 0) { return this; } + + renderer.setFloat4(program, 'uCamera', camera.x, camera.y, camera.rotation, camera.zoom); + renderer.setFloat3(program, 'uAmbientLightColor', lightManager.ambientColor.r, lightManager.ambientColor.g, lightManager.ambientColor.b); + + for (index = 0; index < lightCount; ++index) + { + var light = lights[index]; + var lightName = 'uLights[' + index + '].'; + cameraMatrix.transformPoint(light.x, light.y, point); + renderer.setFloat2(program, lightName + 'position', point.x - (camera.scrollX * light.scrollFactorX * camera.zoom), height - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom)); + renderer.setFloat3(program, lightName + 'color', light.r, light.g, light.b); + renderer.setFloat1(program, lightName + 'intensity', light.intensity); + renderer.setFloat1(program, lightName + 'radius', light.radius); } - // update reference angle - if (bodyB && !bodyB.isStatic) { - Vector.rotate(pointB, bodyB.angle - constraint.angleB, pointB); - constraint.angleB = bodyB.angle; - } - - var pointAWorld = pointA, - pointBWorld = pointB; - - if (bodyA) pointAWorld = Vector.add(bodyA.position, pointA); - if (bodyB) pointBWorld = Vector.add(bodyB.position, pointB); - - if (!pointAWorld || !pointBWorld) - return; - - var delta = Vector.sub(pointAWorld, pointBWorld), - currentLength = Vector.magnitude(delta); - - // prevent singularity - if (currentLength < Constraint._minLength) { - currentLength = Constraint._minLength; - } - - // solve distance constraint with Gauss-Siedel method - var difference = (currentLength - constraint.length) / currentLength, - stiffness = constraint.stiffness < 1 ? constraint.stiffness * timeScale : constraint.stiffness, - force = Vector.mult(delta, difference * stiffness), - massTotal = (bodyA ? bodyA.inverseMass : 0) + (bodyB ? bodyB.inverseMass : 0), - inertiaTotal = (bodyA ? bodyA.inverseInertia : 0) + (bodyB ? bodyB.inverseInertia : 0), - resistanceTotal = massTotal + inertiaTotal, - torque, - share, - normal, - normalVelocity, - relativeVelocity; - - if (constraint.damping) { - var zero = Vector.create(); - normal = Vector.div(delta, currentLength); - - relativeVelocity = Vector.sub( - bodyB && Vector.sub(bodyB.position, bodyB.positionPrev) || zero, - bodyA && Vector.sub(bodyA.position, bodyA.positionPrev) || zero - ); - - normalVelocity = Vector.dot(normal, relativeVelocity); - } - - if (bodyA && !bodyA.isStatic) { - share = bodyA.inverseMass / massTotal; - - // keep track of applied impulses for post solving - bodyA.constraintImpulse.x -= force.x * share; - bodyA.constraintImpulse.y -= force.y * share; - - // apply forces - bodyA.position.x -= force.x * share; - bodyA.position.y -= force.y * share; - - // apply damping - if (constraint.damping) { - bodyA.positionPrev.x -= constraint.damping * normal.x * normalVelocity * share; - bodyA.positionPrev.y -= constraint.damping * normal.y * normalVelocity * share; - } - - // apply torque - torque = (Vector.cross(pointA, force) / resistanceTotal) * Constraint._torqueDampen * bodyA.inverseInertia * (1 - constraint.angularStiffness); - bodyA.constraintImpulse.angle -= torque; - bodyA.angle -= torque; - } - - if (bodyB && !bodyB.isStatic) { - share = bodyB.inverseMass / massTotal; - - // keep track of applied impulses for post solving - bodyB.constraintImpulse.x += force.x * share; - bodyB.constraintImpulse.y += force.y * share; - - // apply forces - bodyB.position.x += force.x * share; - bodyB.position.y += force.y * share; - - // apply damping - if (constraint.damping) { - bodyB.positionPrev.x += constraint.damping * normal.x * normalVelocity * share; - bodyB.positionPrev.y += constraint.damping * normal.y * normalVelocity * share; - } - - // apply torque - torque = (Vector.cross(pointB, force) / resistanceTotal) * Constraint._torqueDampen * bodyB.inverseInertia * (1 - constraint.angularStiffness); - bodyB.constraintImpulse.angle += torque; - bodyB.angle += torque; - } - - }; + return this; + }, /** - * Performs body updates required after solving constraints. - * @private - * @method postSolveAll - * @param {body[]} bodies - */ - Constraint.postSolveAll = function(bodies) { - for (var i = 0; i < bodies.length; i++) { - var body = bodies[i], - impulse = body.constraintImpulse; - - if (body.isStatic || (impulse.x === 0 && impulse.y === 0 && impulse.angle === 0)) { - continue; - } - - Sleeping.set(body, false); - - // update geometry and reset - for (var j = 0; j < body.parts.length; j++) { - var part = body.parts[j]; - - Vertices.translate(part.vertices, impulse); - - if (j > 0) { - part.position.x += impulse.x; - part.position.y += impulse.y; - } - - if (impulse.angle !== 0) { - Vertices.rotate(part.vertices, impulse.angle, body.position); - Axes.rotate(part.axes, impulse.angle); - if (j > 0) { - Vector.rotateAbout(part.position, impulse.angle, body.position, part.position); - } - } - - Bounds.update(part.bounds, part.vertices, body.velocity); - } - - // dampen the cached impulse for warming next step - impulse.angle *= Constraint._warming; - impulse.x *= Constraint._warming; - impulse.y *= Constraint._warming; - } - }; - - /* - * - * Properties Documentation - * - */ - - /** - * An integer `Number` uniquely identifying number generated in `Composite.create` by `Common.nextId`. + * [description] * - * @property id - * @type number - */ - - /** - * A `String` denoting the type of object. + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#drawStaticTilemapLayer + * @since 3.0.0 * - * @property type - * @type string - * @default "constraint" - * @readOnly - */ - - /** - * An arbitrary `String` name to help the user identify and manage bodies. + * @param {Phaser.Tilemaps.StaticTilemapLayer} tilemap - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] * - * @property label - * @type string - * @default "Constraint" */ - - /** - * An `Object` that defines the rendering properties to be consumed by the module `Matter.Render`. - * - * @property render - * @type object - */ - - /** - * A flag that indicates if the constraint should be rendered. - * - * @property render.visible - * @type boolean - * @default true - */ - - /** - * A `Number` that defines the line width to use when rendering the constraint outline. - * A value of `0` means no outline will be rendered. - * - * @property render.lineWidth - * @type number - * @default 2 - */ - - /** - * A `String` that defines the stroke style to use when rendering the constraint outline. - * It is the same as when using a canvas, so it accepts CSS style property values. - * - * @property render.strokeStyle - * @type string - * @default a random colour - */ - - /** - * A `String` that defines the constraint rendering type. - * The possible values are 'line', 'pin', 'spring'. - * An appropriate render type will be automatically chosen unless one is given in options. - * - * @property render.type - * @type string - * @default 'line' - */ - - /** - * A `Boolean` that defines if the constraint's anchor points should be rendered. - * - * @property render.anchors - * @type boolean - * @default true - */ - - /** - * The first possible `Body` that this constraint is attached to. - * - * @property bodyA - * @type body - * @default null - */ - - /** - * The second possible `Body` that this constraint is attached to. - * - * @property bodyB - * @type body - * @default null - */ - - /** - * A `Vector` that specifies the offset of the constraint from center of the `constraint.bodyA` if defined, otherwise a world-space position. - * - * @property pointA - * @type vector - * @default { x: 0, y: 0 } - */ - - /** - * A `Vector` that specifies the offset of the constraint from center of the `constraint.bodyA` if defined, otherwise a world-space position. - * - * @property pointB - * @type vector - * @default { x: 0, y: 0 } - */ - - /** - * A `Number` that specifies the stiffness of the constraint, i.e. the rate at which it returns to its resting `constraint.length`. - * A value of `1` means the constraint should be very stiff. - * A value of `0.2` means the constraint acts like a soft spring. - * - * @property stiffness - * @type number - * @default 1 - */ - - /** - * A `Number` that specifies the damping of the constraint, - * i.e. the amount of resistance applied to each body based on their velocities to limit the amount of oscillation. - * Damping will only be apparent when the constraint also has a very low `stiffness`. - * A value of `0.1` means the constraint will apply heavy damping, resulting in little to no oscillation. - * A value of `0` means the constraint will apply no damping. - * - * @property damping - * @type number - * @default 0 - */ - - /** - * A `Number` that specifies the target resting length of the constraint. - * It is calculated automatically in `Constraint.create` from initial positions of the `constraint.bodyA` and `constraint.bodyB`. - * - * @property length - * @type number - */ - - /** - * An object reserved for storing plugin-specific properties. - * - * @property plugin - * @type {} - */ - -})(); - - -/***/ }), -/* 169 */ -/***/ (function(module, exports) { - -var g; - -// This works in non-strict mode -g = (function() { - return this; -})(); - -try { - // This works if eval is allowed (see CSP) - g = g || Function("return this")() || (1,eval)("this"); -} catch(e) { - // This works if the window reference is available - if(typeof window === "object") - g = window; -} - -// g can still be undefined, but nothing to do about it... -// We return undefined, instead of nothing here, so it's -// easier to handle this case. if(!global) { ...} - -module.exports = g; - - -/***/ }), -/* 170 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * This is a slightly modified version of jQuery.isPlainObject. - * A plain object is an object whose internal class property is [object Object]. - * - * @function Phaser.Utils.Object.IsPlainObject - * @since 3.0.0 - * - * @param {object} obj - The object to inspect. - * - * @return {boolean} `true` if the object is plain, otherwise `false`. - */ -var IsPlainObject = function (obj) -{ - // Not plain objects: - // - Any object or value whose internal [[Class]] property is not "[object Object]" - // - DOM nodes - // - window - if (typeof(obj) !== 'object' || obj.nodeType || obj === obj.window) + drawStaticTilemapLayer: function (tilemap, camera) { - return false; - } + var normalTexture = tilemap.texture.dataSource[0]; - // Support: Firefox <20 - // The try/catch suppresses exceptions thrown when attempting to access - // the "constructor" property of certain host objects, ie. |window.location| - // https://bugzilla.mozilla.org/show_bug.cgi?id=814622 - try - { - if (obj.constructor && !({}).hasOwnProperty.call(obj.constructor.prototype, 'isPrototypeOf')) + if (normalTexture) { - return false; + this.renderer.setPipeline(this); + this.setTexture2D(normalTexture.glTexture, 1); + TextureTintPipeline.prototype.drawStaticTilemapLayer.call(this, tilemap, camera); + } + else + { + console.warn('Normal map texture missing for using Light2D pipeline. StaticTilemapLayer rendered with default pipeline.'); + this.renderer.pipelines.TextureTintPipeline.drawStaticTilemapLayer(tilemap, camera); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#drawEmitterManager + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + */ + drawEmitterManager: function (emitterManager, camera) + { + var normalTexture = emitterManager.texture.dataSource[0]; + + if (normalTexture) + { + this.renderer.setPipeline(this); + this.setTexture2D(normalTexture.glTexture, 1); + TextureTintPipeline.prototype.drawEmitterManager.call(this, emitterManager, camera); + } + else + { + console.warn('Normal map texture missing for using Light2D pipeline. EmitterManager rendered with default pipeline.'); + this.renderer.pipelines.TextureTintPipeline.drawEmitterManager(emitterManager, camera); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#drawBlitter + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Blitter} blitter - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + */ + drawBlitter: function (blitter, camera) + { + var normalTexture = blitter.texture.dataSource[0]; + + if (normalTexture) + { + this.renderer.setPipeline(this); + this.setTexture2D(normalTexture.glTexture, 1); + TextureTintPipeline.prototype.drawBlitter.call(this, blitter, camera); + } + else + { + console.warn('Normal map texture missing for using Light2D pipeline. Blitter rendered with default pipeline.'); + this.renderer.pipelines.TextureTintPipeline.drawBlitter(blitter, camera); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchSprite + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Sprite} sprite - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + */ + batchSprite: function (sprite, camera) + { + var normalTexture = sprite.texture.dataSource[0]; + + if (normalTexture) + { + this.renderer.setPipeline(this); + this.setTexture2D(normalTexture.glTexture, 1); + TextureTintPipeline.prototype.batchSprite.call(this, sprite, camera); + } + else + { + console.warn('Normal map texture missing for using Light2D pipeline. Sprite rendered with default pipeline.'); + this.renderer.pipelines.TextureTintPipeline.batchSprite(sprite, camera); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchMesh + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Mesh} mesh - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + */ + batchMesh: function (mesh, camera) + { + var normalTexture = mesh.texture.dataSource[0]; + + if (normalTexture) + { + this.renderer.setPipeline(this); + this.setTexture2D(normalTexture.glTexture, 1); + TextureTintPipeline.prototype.batchMesh.call(this, mesh, camera); + } + else + { + console.warn('Normal map texture missing for using Light2D pipeline. Mesh rendered with default pipeline.'); + this.renderer.pipelines.TextureTintPipeline.batchMesh(mesh, camera); + + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchBitmapText + * @since 3.0.0 + * + * @param {Phaser.GameObjects.BitmapText} bitmapText - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + */ + batchBitmapText: function (bitmapText, camera) + { + var normalTexture = bitmapText.texture.dataSource[0]; + + if (normalTexture) + { + this.renderer.setPipeline(this); + this.setTexture2D(normalTexture.glTexture, 1); + TextureTintPipeline.prototype.batchBitmapText.call(this, bitmapText, camera); + } + else + { + console.warn('Normal map texture missing for using Light2D pipeline. BitmapText rendered with default pipeline.'); + this.renderer.pipelines.TextureTintPipeline.batchBitmapText(bitmapText, camera); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchDynamicBitmapText + * @since 3.0.0 + * + * @param {Phaser.GameObjects.DynamicBitmapText} bitmapText - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + */ + batchDynamicBitmapText: function (bitmapText, camera) + { + var normalTexture = bitmapText.texture.dataSource[0]; + + if (normalTexture) + { + this.renderer.setPipeline(this); + this.setTexture2D(normalTexture.glTexture, 1); + TextureTintPipeline.prototype.batchDynamicBitmapText.call(this, bitmapText, camera); + } + else + { + console.warn('Normal map texture missing for using Light2D pipeline. DynamicBitmapText rendered with default pipeline.'); + this.renderer.pipelines.TextureTintPipeline.batchDynamicBitmapText(bitmapText, camera); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchText + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Text} text - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + */ + batchText: function (text, camera) + { + var normalTexture = text.texture.dataSource[0]; + + if (normalTexture) + { + this.renderer.setPipeline(this); + this.setTexture2D(normalTexture.glTexture, 1); + TextureTintPipeline.prototype.batchText.call(this, text, camera); + } + else + { + console.warn('Normal map texture missing for using Light2D pipeline. Text rendered with default pipeline.'); + this.renderer.pipelines.TextureTintPipeline.batchText(text, camera); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchDynamicTilemapLayer + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.DynamicTilemapLayer} tilemapLayer - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + */ + batchDynamicTilemapLayer: function (tilemapLayer, camera) + { + var normalTexture = tilemapLayer.texture.dataSource[0]; + + if (normalTexture) + { + this.renderer.setPipeline(this); + this.setTexture2D(normalTexture.glTexture, 1); + TextureTintPipeline.prototype.batchDynamicTilemapLayer.call(this, tilemapLayer, camera); + } + else + { + console.warn('Normal map texture missing for using Light2D pipeline. DynamicTilemapLayer rendered with default pipeline.'); + this.renderer.pipelines.TextureTintPipeline.batchDynamicTilemapLayer(tilemapLayer, camera); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#batchTileSprite + * @since 3.0.0 + * + * @param {Phaser.GameObjects.TileSprite} tileSprite - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + */ + batchTileSprite: function (tileSprite, camera) + { + var normalTexture = tileSprite.texture.dataSource[0]; + + if (normalTexture) + { + this.renderer.setPipeline(this); + this.setTexture2D(normalTexture.glTexture, 1); + TextureTintPipeline.prototype.batchTileSprite.call(this, tileSprite, camera); + } + else + { + console.warn('Normal map texture missing for using Light2D pipeline. TileSprite rendered with default pipeline.'); + this.renderer.pipelines.TextureTintPipeline.batchTileSprite(tileSprite, camera); } } - catch (e) - { - return false; - } - // If the function hasn't returned already, we're confident that - // |obj| is a plain object, created by {} or constructed with new Object - return true; -}; +}); -module.exports = IsPlainObject; +ForwardDiffuseLightPipeline.LIGHT_COUNT = LIGHT_COUNT; - -/***/ }), -/* 171 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Actions - */ - -module.exports = { - - Angle: __webpack_require__(386), - Call: __webpack_require__(387), - GetFirst: __webpack_require__(388), - GridAlign: __webpack_require__(389), - IncAlpha: __webpack_require__(407), - IncX: __webpack_require__(408), - IncXY: __webpack_require__(409), - IncY: __webpack_require__(410), - PlaceOnCircle: __webpack_require__(411), - PlaceOnEllipse: __webpack_require__(412), - PlaceOnLine: __webpack_require__(413), - PlaceOnRectangle: __webpack_require__(414), - PlaceOnTriangle: __webpack_require__(415), - PlayAnimation: __webpack_require__(416), - RandomCircle: __webpack_require__(417), - RandomEllipse: __webpack_require__(418), - RandomLine: __webpack_require__(419), - RandomRectangle: __webpack_require__(420), - RandomTriangle: __webpack_require__(421), - Rotate: __webpack_require__(422), - RotateAround: __webpack_require__(423), - RotateAroundDistance: __webpack_require__(424), - ScaleX: __webpack_require__(425), - ScaleXY: __webpack_require__(426), - ScaleY: __webpack_require__(427), - SetAlpha: __webpack_require__(428), - SetBlendMode: __webpack_require__(429), - SetDepth: __webpack_require__(430), - SetHitArea: __webpack_require__(431), - SetOrigin: __webpack_require__(432), - SetRotation: __webpack_require__(433), - SetScale: __webpack_require__(434), - SetScaleX: __webpack_require__(435), - SetScaleY: __webpack_require__(436), - SetTint: __webpack_require__(437), - SetVisible: __webpack_require__(438), - SetX: __webpack_require__(439), - SetXY: __webpack_require__(440), - SetY: __webpack_require__(441), - ShiftPosition: __webpack_require__(442), - Shuffle: __webpack_require__(443), - SmootherStep: __webpack_require__(444), - SmoothStep: __webpack_require__(445), - Spread: __webpack_require__(446), - ToggleVisible: __webpack_require__(447) - -}; - - -/***/ }), -/* 172 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ALIGN_CONST = __webpack_require__(173); - -var AlignInMap = []; - -AlignInMap[ALIGN_CONST.BOTTOM_CENTER] = __webpack_require__(174); -AlignInMap[ALIGN_CONST.BOTTOM_LEFT] = __webpack_require__(175); -AlignInMap[ALIGN_CONST.BOTTOM_RIGHT] = __webpack_require__(176); -AlignInMap[ALIGN_CONST.CENTER] = __webpack_require__(177); -AlignInMap[ALIGN_CONST.LEFT_CENTER] = __webpack_require__(179); -AlignInMap[ALIGN_CONST.RIGHT_CENTER] = __webpack_require__(180); -AlignInMap[ALIGN_CONST.TOP_CENTER] = __webpack_require__(181); -AlignInMap[ALIGN_CONST.TOP_LEFT] = __webpack_require__(182); -AlignInMap[ALIGN_CONST.TOP_RIGHT] = __webpack_require__(183); - -/** - * Takes given Game Object and aligns it so that it is positioned relative to the other. - * The alignment used is based on the `position` argument, which is an `ALIGN_CONST` value, such as `LEFT_CENTER` or `TOP_RIGHT`. - * - * @function Phaser.Display.Align.In.QuickSet - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {integer} position - The position to align the Game Object with. This is an align constant, such as `ALIGN_CONST.LEFT_CENTER`. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var QuickSet = function (child, alignIn, position, offsetX, offsetY) -{ - return AlignInMap[position](child, alignIn, offsetX, offsetY); -}; - -module.exports = QuickSet; - - -/***/ }), -/* 173 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ALIGN_CONST = { - - /** - * A constant representing a top-left alignment or position. - * @constant - * @name Phaser.Display.Align.TOP_LEFT - * @since 3.0.0 - * @type {integer} - */ - TOP_LEFT: 0, - - /** - * A constant representing a top-center alignment or position. - * @constant - * @name Phaser.Display.Align.TOP_CENTER - * @since 3.0.0 - * @type {integer} - */ - TOP_CENTER: 1, - - /** - * A constant representing a top-right alignment or position. - * @constant - * @name Phaser.Display.Align.TOP_RIGHT - * @since 3.0.0 - * @type {integer} - */ - TOP_RIGHT: 2, - - /** - * A constant representing a left-top alignment or position. - * @constant - * @name Phaser.Display.Align.LEFT_TOP - * @since 3.0.0 - * @type {integer} - */ - LEFT_TOP: 3, - - /** - * A constant representing a left-center alignment or position. - * @constant - * @name Phaser.Display.Align.LEFT_CENTER - * @since 3.0.0 - * @type {integer} - */ - LEFT_CENTER: 4, - - /** - * A constant representing a left-bottom alignment or position. - * @constant - * @name Phaser.Display.Align.LEFT_BOTTOM - * @since 3.0.0 - * @type {integer} - */ - LEFT_BOTTOM: 5, - - /** - * A constant representing a center alignment or position. - * @constant - * @name Phaser.Display.Align.CENTER - * @since 3.0.0 - * @type {integer} - */ - CENTER: 6, - - /** - * A constant representing a right-top alignment or position. - * @constant - * @name Phaser.Display.Align.RIGHT_TOP - * @since 3.0.0 - * @type {integer} - */ - RIGHT_TOP: 7, - - /** - * A constant representing a right-center alignment or position. - * @constant - * @name Phaser.Display.Align.RIGHT_CENTER - * @since 3.0.0 - * @type {integer} - */ - RIGHT_CENTER: 8, - - /** - * A constant representing a right-bottom alignment or position. - * @constant - * @name Phaser.Display.Align.RIGHT_BOTTOM - * @since 3.0.0 - * @type {integer} - */ - RIGHT_BOTTOM: 9, - - /** - * A constant representing a bottom-left alignment or position. - * @constant - * @name Phaser.Display.Align.BOTTOM_LEFT - * @since 3.0.0 - * @type {integer} - */ - BOTTOM_LEFT: 10, - - /** - * A constant representing a bottom-center alignment or position. - * @constant - * @name Phaser.Display.Align.BOTTOM_CENTER - * @since 3.0.0 - * @type {integer} - */ - BOTTOM_CENTER: 11, - - /** - * A constant representing a bottom-right alignment or position. - * @constant - * @name Phaser.Display.Align.BOTTOM_RIGHT - * @since 3.0.0 - * @type {integer} - */ - BOTTOM_RIGHT: 12 - -}; - -module.exports = ALIGN_CONST; +module.exports = ForwardDiffuseLightPipeline; /***/ }), @@ -39160,36 +40147,24 @@ module.exports = ALIGN_CONST; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetBottom = __webpack_require__(24); -var GetCenterX = __webpack_require__(46); -var SetBottom = __webpack_require__(25); -var SetCenterX = __webpack_require__(47); +var Wrap = __webpack_require__(43); /** - * Takes given Game Object and aligns it so that it is positioned in the bottom center of the other. + * [description] * - * @function Phaser.Display.Align.In.BottomCenter + * @function Phaser.Math.Angle.WrapDegrees * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. + * @param {number} angle - [description] * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + * @return {number} [description] */ -var BottomCenter = function (gameObject, alignIn, offsetX, offsetY) +var WrapDegrees = function (angle) { - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetCenterX(gameObject, GetCenterX(alignIn) + offsetX); - SetBottom(gameObject, GetBottom(alignIn) + offsetY); - - return gameObject; + return Wrap(angle, -180, 180); }; -module.exports = BottomCenter; +module.exports = WrapDegrees; /***/ }), @@ -39202,41 +40177,29 @@ module.exports = BottomCenter; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetBottom = __webpack_require__(24); -var GetLeft = __webpack_require__(26); -var SetBottom = __webpack_require__(25); -var SetLeft = __webpack_require__(27); +var MathWrap = __webpack_require__(43); /** - * Takes given Game Object and aligns it so that it is positioned in the bottom left of the other. + * [description] * - * @function Phaser.Display.Align.In.BottomLeft + * @function Phaser.Math.Angle.Wrap * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. + * @param {number} angle - [description] * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + * @return {number} [description] */ -var BottomLeft = function (gameObject, alignIn, offsetX, offsetY) +var Wrap = function (angle) { - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetLeft(alignIn) - offsetX); - SetBottom(gameObject, GetBottom(alignIn) + offsetY); - - return gameObject; + return MathWrap(angle, -Math.PI, Math.PI); }; -module.exports = BottomLeft; +module.exports = Wrap; /***/ }), /* 176 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -39244,41 +40207,46 @@ module.exports = BottomLeft; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetBottom = __webpack_require__(24); -var GetRight = __webpack_require__(28); -var SetBottom = __webpack_require__(25); -var SetRight = __webpack_require__(29); +// Based on code by Mike Reinstein /** - * Takes given Game Object and aligns it so that it is positioned in the bottom right of the other. + * Removes a single item from an array and returns it without creating gc (like the native splice does) * - * @function Phaser.Display.Align.In.BottomRight + * @function Phaser.Utils.Array.SpliceOne * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. + * @param {array} array - [description] + * @param {integer} index - [description] * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + * @return {*} [description] */ -var BottomRight = function (gameObject, alignIn, offsetX, offsetY) +var SpliceOne = function (array, index) { - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } + if (index >= array.length) + { + return; + } - SetRight(gameObject, GetRight(alignIn) + offsetX); - SetBottom(gameObject, GetBottom(alignIn) + offsetY); + var len = array.length - 1; - return gameObject; + var item = array[index]; + + for (var i = index; i < len; i++) + { + array[i] = array[i + 1]; + } + + array.length = len; + + return item; }; -module.exports = BottomRight; +module.exports = SpliceOne; /***/ }), /* 177 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -39286,34 +40254,40 @@ module.exports = BottomRight; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CenterOn = __webpack_require__(178); -var GetCenterX = __webpack_require__(46); -var GetCenterY = __webpack_require__(49); +// Transposes the elements of the given matrix (array of arrays). +// The transpose of a matrix is a new matrix whose rows are the columns of the original. /** - * Takes given Game Object and aligns it so that it is positioned in the center of the other. + * [description] * - * @function Phaser.Display.Align.In.Center + * @function Phaser.Utils.Array.Matrix.TransposeMatrix * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. + * @param {array} array - The array matrix to transpose. * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + * @return {array} A new array matrix which is a transposed version of the given array. */ -var Center = function (gameObject, alignIn, offsetX, offsetY) +var TransposeMatrix = function (array) { - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } + var sourceRowCount = array.length; + var sourceColCount = array[0].length; - CenterOn(gameObject, GetCenterX(alignIn) + offsetX, GetCenterY(alignIn) + offsetY); + var result = new Array(sourceColCount); - return gameObject; + for (var i = 0; i < sourceColCount; i++) + { + result[i] = new Array(sourceRowCount); + + for (var j = sourceRowCount - 1; j > -1; j--) + { + result[i][j] = array[j][i]; + } + } + + return result; }; -module.exports = Center; +module.exports = TransposeMatrix; /***/ }), @@ -39326,29 +40300,863 @@ module.exports = Center; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var SetCenterX = __webpack_require__(47); -var SetCenterY = __webpack_require__(48); +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(15); +var TweenBuilder = __webpack_require__(82); +var TWEEN_CONST = __webpack_require__(68); /** - * Positions the Game Object so that it is centered on the given coordinates. + * @classdesc + * [description] * - * @function Phaser.Display.Bounds.CenterOn + * @class Timeline + * @memberOf Phaser.Tweens + * @extends EventEmitter + * @constructor * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} x - The horizontal coordinate to position the Game Object on. - * @param {number} y - The vertical coordinate to position the Game Object on. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + * @param {Phaser.Tweens.TweenManager} manager - [description] */ -var CenterOn = function (gameObject, x, y) -{ - SetCenterX(gameObject, x); +var Timeline = new Class({ - return SetCenterY(gameObject, y); -}; + Extends: EventEmitter, -module.exports = CenterOn; + initialize: + + function Timeline (manager) + { + EventEmitter.call(this); + + /** + * [description] + * + * @name Phaser.Tweens.Timeline#manager + * @type {Phaser.Tweens.TweenManager} + * @since 3.0.0 + */ + this.manager = manager; + + /** + * [description] + * + * @name Phaser.Tweens.Timeline#isTimeline + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.isTimeline = true; + + /** + * An array of Tween objects, each containing a unique property and target being tweened. + * + * @name Phaser.Tweens.Timeline#data + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.data = []; + + /** + * data array doesn't usually change, so we can cache the length + * + * @name Phaser.Tweens.Timeline#totalData + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalData = 0; + + /** + * If true then duration, delay, etc values are all frame totals. + * + * @name Phaser.Tweens.Timeline#useFrames + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.useFrames = false; + + /** + * Scales the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. + * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. + * + * @name Phaser.Tweens.Timeline#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * Loop this tween? Can be -1 for an infinite loop, or an integer. + * When enabled it will play through ALL TweenDatas again (use TweenData.repeat to loop a single TD) + * + * @name Phaser.Tweens.Timeline#loop + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loop = 0; + + /** + * Time in ms/frames before the tween loops. + * + * @name Phaser.Tweens.Timeline#loopDelay + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loopDelay = 0; + + /** + * How many loops are left to run? + * + * @name Phaser.Tweens.Timeline#loopCounter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loopCounter = 0; + + /** + * Time in ms/frames before the 'onComplete' event fires. This never fires if loop = true (as it never completes) + * + * @name Phaser.Tweens.Timeline#completeDelay + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.completeDelay = 0; + + /** + * Countdown timer (used by loopDelay and completeDelay) + * + * @name Phaser.Tweens.Timeline#countdown + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.countdown = 0; + + /** + * The current state of the tween + * + * @name Phaser.Tweens.Timeline#state + * @type {integer} + * @since 3.0.0 + */ + this.state = TWEEN_CONST.PENDING_ADD; + + /** + * The state of the tween when it was paused (used by Resume) + * + * @name Phaser.Tweens.Timeline#_pausedState + * @type {integer} + * @private + * @since 3.0.0 + */ + this._pausedState = TWEEN_CONST.PENDING_ADD; + + /** + * Does the Tween start off paused? (if so it needs to be started with Tween.play) + * + * @name Phaser.Tweens.Timeline#paused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.paused = false; + + /** + * Elapsed time in ms/frames of this run through the Tween. + * + * @name Phaser.Tweens.Timeline#elapsed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.elapsed = 0; + + /** + * Total elapsed time in ms/frames of the entire Tween, including looping. + * + * @name Phaser.Tweens.Timeline#totalElapsed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalElapsed = 0; + + /** + * Time in ms/frames for the whole Tween to play through once, excluding loop amounts and loop delays. + * + * @name Phaser.Tweens.Timeline#duration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.duration = 0; + + /** + * Value between 0 and 1. The amount through the Tween, excluding loops. + * + * @name Phaser.Tweens.Timeline#progress + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.progress = 0; + + /** + * Time in ms/frames for all Tweens to complete (including looping) + * + * @name Phaser.Tweens.Timeline#totalDuration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalDuration = 0; + + /** + * Value between 0 and 1. The amount through the entire Tween, including looping. + * + * @name Phaser.Tweens.Timeline#totalProgress + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalProgress = 0; + + this.callbacks = { + onComplete: null, + onLoop: null, + onStart: null, + onUpdate: null, + onYoyo: null + }; + + this.callbackScope; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#setTimeScale + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Tweens.Timeline} This Timeline object. + */ + setTimeScale: function (value) + { + this.timeScale = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#getTimeScale + * @since 3.0.0 + * + * @return {number} [description] + */ + getTimeScale: function () + { + return this.timeScale; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#isPlaying + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isPlaying: function () + { + return (this.state === TWEEN_CONST.ACTIVE); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#add + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.Tweens.Timeline} This Timeline object. + */ + add: function (config) + { + return this.queue(TweenBuilder(this, config)); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#queue + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * + * @return {Phaser.Tweens.Timeline} This Timeline object. + */ + queue: function (tween) + { + if (!this.isPlaying()) + { + tween.parent = this; + tween.parentIsTimeline = true; + + this.data.push(tween); + + this.totalData = this.data.length; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#hasOffset + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * + * @return {boolean} [description] + */ + hasOffset: function (tween) + { + return (tween.offset !== null); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#isOffsetAbsolute + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {boolean} [description] + */ + isOffsetAbsolute: function (value) + { + return (typeof(value) === 'number'); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#isOffsetRelative + * @since 3.0.0 + * + * @param {string} value - [description] + * + * @return {boolean} [description] + */ + isOffsetRelative: function (value) + { + var t = typeof(value); + + if (t === 'string') + { + var op = value[0]; + + if (op === '-' || op === '+') + { + return true; + } + } + + return false; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#getRelativeOffset + * @since 3.0.0 + * + * @param {string} value - [description] + * @param {number} base - [description] + * + * @return {number} [description] + */ + getRelativeOffset: function (value, base) + { + var op = value[0]; + var num = parseFloat(value.substr(2)); + var result = base; + + switch (op) + { + case '+': + result += num; + break; + + case '-': + result -= num; + break; + } + + // Cannot ever be < 0 + return Math.max(0, result); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#calcDuration + * @since 3.0.0 + */ + calcDuration: function () + { + var prevEnd = 0; + var totalDuration = 0; + var offsetDuration = 0; + + for (var i = 0; i < this.totalData; i++) + { + var tween = this.data[i]; + + tween.init(); + + if (this.hasOffset(tween)) + { + if (this.isOffsetAbsolute(tween.offset)) + { + // An actual number, so it defines the start point from the beginning of the timeline + tween.calculatedOffset = tween.offset; + + if (tween.offset === 0) + { + offsetDuration = 0; + } + } + else if (this.isOffsetRelative(tween.offset)) + { + // A relative offset (i.e. '-=1000', so starts at 'offset' ms relative to the PREVIOUS Tweens ending time) + tween.calculatedOffset = this.getRelativeOffset(tween.offset, prevEnd); + } + } + else + { + // Sequential + tween.calculatedOffset = offsetDuration; + } + + prevEnd = tween.totalDuration + tween.calculatedOffset; + + totalDuration += tween.totalDuration; + offsetDuration += tween.totalDuration; + } + + // Excludes loop values + this.duration = totalDuration; + + this.loopCounter = (this.loop === -1) ? 999999999999 : this.loop; + + if (this.loopCounter > 0) + { + this.totalDuration = this.duration + this.completeDelay + ((this.duration + this.loopDelay) * this.loopCounter); + } + else + { + this.totalDuration = this.duration + this.completeDelay; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#init + * @since 3.0.0 + * + * @return {boolean} [description] + */ + init: function () + { + this.calcDuration(); + + this.progress = 0; + this.totalProgress = 0; + + if (this.paused) + { + this.state = TWEEN_CONST.PAUSED; + + return false; + } + else + { + return true; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#resetTweens + * @since 3.0.0 + * + * @param {boolean} resetFromLoop - [description] + */ + resetTweens: function (resetFromLoop) + { + for (var i = 0; i < this.totalData; i++) + { + var tween = this.data[i]; + + tween.play(resetFromLoop); + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#setCallback + * @since 3.0.0 + * + * @param {string} type - [description] + * @param {function} callback - [description] + * @param {array} [params] - [description] + * @param {object} [scope] - [description] + * + * @return {Phaser.Tweens.Timeline} This Timeline object. + */ + setCallback: function (type, callback, params, scope) + { + if (Timeline.TYPES.indexOf(type) !== -1) + { + this.callbacks[type] = { func: callback, scope: scope, params: params }; + } + + return this; + }, + + /** + * Delegates #makeActive to the Tween manager. + * + * @method Phaser.Tweens.Timeline#makeActive + * @since 3.3.0 + * + * @param {Phaser.Tweens.Tween} tween - The tween object to make active. + * + * @return {Phaser.Tweens.TweenManager} The Timeline's Tween Manager object. + */ + makeActive: function (tween) + { + return this.manager.makeActive(tween); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#play + * @since 3.0.0 + */ + play: function () + { + if (this.state === TWEEN_CONST.ACTIVE) + { + return; + } + + if (this.paused) + { + this.paused = false; + + this.manager.makeActive(this); + + return; + } + else + { + this.resetTweens(false); + + this.state = TWEEN_CONST.ACTIVE; + } + + var onStart = this.callbacks.onStart; + + if (onStart) + { + onStart.func.apply(onStart.scope, onStart.params); + } + + this.emit('start', this); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#nextState + * @since 3.0.0 + */ + nextState: function () + { + if (this.loopCounter > 0) + { + // Reset the elapsed time + // TODO: Probably ought to be set to the remainder from elapsed - duration + // as the tweens nearly always over-run by a few ms due to rAf + + this.elapsed = 0; + this.progress = 0; + + this.loopCounter--; + + var onLoop = this.callbacks.onLoop; + + if (onLoop) + { + onLoop.func.apply(onLoop.scope, onLoop.params); + } + + this.emit('loop', this, this.loopCounter); + + this.resetTweens(true); + + if (this.loopDelay > 0) + { + this.countdown = this.loopDelay; + this.state = TWEEN_CONST.LOOP_DELAY; + } + else + { + this.state = TWEEN_CONST.ACTIVE; + } + } + else if (this.completeDelay > 0) + { + this.countdown = this.completeDelay; + this.state = TWEEN_CONST.COMPLETE_DELAY; + } + else + { + var onComplete = this.callbacks.onComplete; + + if (onComplete) + { + onComplete.func.apply(onComplete.scope, onComplete.params); + } + + this.emit('complete', this); + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + }, + + /** + * Returns 'true' if this Timeline has finished and should be removed from the Tween Manager. + * Otherwise, returns false. + * + * @method Phaser.Tweens.Timeline#update + * @since 3.0.0 + * + * @param {number} timestamp - [description] + * @param {number} delta - [description] + * + * @return {boolean} Returns `true` if this Timeline has finished and should be removed from the Tween Manager. + */ + update: function (timestamp, delta) + { + if (this.state === TWEEN_CONST.PAUSED) + { + return; + } + + var rawDelta = delta; + + if (this.useFrames) + { + delta = 1 * this.manager.timeScale; + } + + delta *= this.timeScale; + + this.elapsed += delta; + this.progress = Math.min(this.elapsed / this.duration, 1); + + this.totalElapsed += delta; + this.totalProgress = Math.min(this.totalElapsed / this.totalDuration, 1); + + switch (this.state) + { + case TWEEN_CONST.ACTIVE: + + var stillRunning = this.totalData; + + for (var i = 0; i < this.totalData; i++) + { + var tween = this.data[i]; + + if (tween.update(timestamp, rawDelta)) + { + stillRunning--; + } + } + + var onUpdate = this.callbacks.onUpdate; + + if (onUpdate) + { + onUpdate.func.apply(onUpdate.scope, onUpdate.params); + } + + this.emit('update', this); + + // Anything still running? If not, we're done + if (stillRunning === 0) + { + this.nextState(); + } + + break; + + case TWEEN_CONST.LOOP_DELAY: + + this.countdown -= delta; + + if (this.countdown <= 0) + { + this.state = TWEEN_CONST.ACTIVE; + } + + break; + + case TWEEN_CONST.COMPLETE_DELAY: + + this.countdown -= delta; + + if (this.countdown <= 0) + { + var onComplete = this.callbacks.onComplete; + + if (onComplete) + { + onComplete.func.apply(onComplete.scope, onComplete.params); + } + + this.emit('complete', this); + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + + break; + } + + return (this.state === TWEEN_CONST.PENDING_REMOVE); + }, + + /** + * Stops the Tween immediately, whatever stage of progress it is at and flags it for removal by the TweenManager. + * + * @method Phaser.Tweens.Timeline#stop + * @since 3.0.0 + */ + stop: function () + { + this.state = TWEEN_CONST.PENDING_REMOVE; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#pause + * @since 3.0.0 + * + * @return {Phaser.Tweens.Timeline} This Timeline object. + */ + pause: function () + { + if (this.state === TWEEN_CONST.PAUSED) + { + return; + } + + this.paused = true; + + this._pausedState = this.state; + + this.state = TWEEN_CONST.PAUSED; + + this.emit('pause', this); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#resume + * @since 3.0.0 + * + * @return {Phaser.Tweens.Timeline} This Timeline object. + */ + resume: function () + { + if (this.state === TWEEN_CONST.PAUSED) + { + this.paused = false; + + this.state = this._pausedState; + } + + this.emit('resume', this); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#hasTarget + * @since 3.0.0 + * + * @param {object} target - [description] + * + * @return {boolean} [description] + */ + hasTarget: function (target) + { + for (var i = 0; i < this.data.length; i++) + { + if (this.data[i].hasTarget(target)) + { + return true; + } + } + + return false; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#destroy + * @since 3.0.0 + */ + destroy: function () + { + for (var i = 0; i < this.data.length; i++) + { + this.data[i].destroy(); + } + + } +}); + +Timeline.TYPES = [ 'onStart', 'onUpdate', 'onLoop', 'onComplete', 'onYoyo' ]; + +module.exports = Timeline; /***/ }), @@ -39361,36 +41169,146 @@ module.exports = CenterOn; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetCenterY = __webpack_require__(49); -var GetLeft = __webpack_require__(26); -var SetCenterY = __webpack_require__(48); -var SetLeft = __webpack_require__(27); +var Clone = __webpack_require__(55); +var Defaults = __webpack_require__(112); +var GetAdvancedValue = __webpack_require__(8); +var GetBoolean = __webpack_require__(69); +var GetEaseFunction = __webpack_require__(71); +var GetNewValue = __webpack_require__(83); +var GetTargets = __webpack_require__(114); +var GetTweens = __webpack_require__(181); +var GetValue = __webpack_require__(5); +var Timeline = __webpack_require__(178); +var TweenBuilder = __webpack_require__(82); /** - * Takes given Game Object and aligns it so that it is positioned in the left center of the other. + * [description] * - * @function Phaser.Display.Align.In.LeftCenter + * @function Phaser.Tweens.Builders.TimelineBuilder * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. + * @param {Phaser.Tweens.TweenManager} manager - [description] + * @param {object} config - [description] * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + * @return {Phaser.Tweens.Timeline} [description] */ -var LeftCenter = function (gameObject, alignIn, offsetX, offsetY) +var TimelineBuilder = function (manager, config) { - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } + var timeline = new Timeline(manager); - SetLeft(gameObject, GetLeft(alignIn) - offsetX); - SetCenterY(gameObject, GetCenterY(alignIn) + offsetY); + var tweens = GetTweens(config); - return gameObject; + if (tweens.length === 0) + { + timeline.paused = true; + + return timeline; + } + + var defaults = Clone(Defaults); + + defaults.targets = GetTargets(config); + + // totalDuration: If specified each tween in the Timeline is given an equal portion of the totalDuration + + var totalDuration = GetAdvancedValue(config, 'totalDuration', 0); + + if (totalDuration > 0) + { + defaults.duration = Math.floor(totalDuration / tweens.length); + } + else + { + defaults.duration = GetNewValue(config, 'duration', defaults.duration); + } + + defaults.delay = GetNewValue(config, 'delay', defaults.delay); + defaults.easeParams = GetValue(config, 'easeParams', defaults.easeParams); + defaults.ease = GetEaseFunction(GetValue(config, 'ease', defaults.ease), defaults.easeParams); + defaults.hold = GetNewValue(config, 'hold', defaults.hold); + defaults.repeat = GetNewValue(config, 'repeat', defaults.repeat); + defaults.repeatDelay = GetNewValue(config, 'repeatDelay', defaults.repeatDelay); + defaults.yoyo = GetBoolean(config, 'yoyo', defaults.yoyo); + defaults.flipX = GetBoolean(config, 'flipX', defaults.flipX); + defaults.flipY = GetBoolean(config, 'flipY', defaults.flipY); + + // Create the Tweens + for (var i = 0; i < tweens.length; i++) + { + timeline.queue(TweenBuilder(timeline, tweens[i], defaults)); + } + + timeline.completeDelay = GetAdvancedValue(config, 'completeDelay', 0); + timeline.loop = Math.round(GetAdvancedValue(config, 'loop', 0)); + timeline.loopDelay = Math.round(GetAdvancedValue(config, 'loopDelay', 0)); + timeline.paused = GetBoolean(config, 'paused', false); + timeline.useFrames = GetBoolean(config, 'useFrames', false); + + // Callbacks + + var scope = GetValue(config, 'callbackScope', timeline); + + var timelineArray = [ timeline ]; + + var onStart = GetValue(config, 'onStart', false); + + // The Start of the Timeline + if (onStart) + { + var onStartScope = GetValue(config, 'onStartScope', scope); + var onStartParams = GetValue(config, 'onStartParams', []); + + timeline.setCallback('onStart', onStart, timelineArray.concat(onStartParams), onStartScope); + } + + var onUpdate = GetValue(config, 'onUpdate', false); + + // Every time the Timeline updates (regardless which Tweens are running) + if (onUpdate) + { + var onUpdateScope = GetValue(config, 'onUpdateScope', scope); + var onUpdateParams = GetValue(config, 'onUpdateParams', []); + + timeline.setCallback('onUpdate', onUpdate, timelineArray.concat(onUpdateParams), onUpdateScope); + } + + var onLoop = GetValue(config, 'onLoop', false); + + // Called when the whole Timeline loops + if (onLoop) + { + var onLoopScope = GetValue(config, 'onLoopScope', scope); + var onLoopParams = GetValue(config, 'onLoopParams', []); + + timeline.setCallback('onLoop', onLoop, timelineArray.concat(onLoopParams), onLoopScope); + } + + var onYoyo = GetValue(config, 'onYoyo', false); + + // Called when a Timeline yoyos + if (onYoyo) + { + var onYoyoScope = GetValue(config, 'onYoyoScope', scope); + var onYoyoParams = GetValue(config, 'onYoyoParams', []); + + timeline.setCallback('onYoyo', onYoyo, timelineArray.concat(null, onYoyoParams), onYoyoScope); + } + + var onComplete = GetValue(config, 'onComplete', false); + + // Called when the Timeline completes, after the completeDelay, etc. + if (onComplete) + { + var onCompleteScope = GetValue(config, 'onCompleteScope', scope); + var onCompleteParams = GetValue(config, 'onCompleteParams', []); + + timeline.setCallback('onComplete', onComplete, timelineArray.concat(onCompleteParams), onCompleteScope); + } + + return timeline; }; -module.exports = LeftCenter; +module.exports = TimelineBuilder; /***/ }), @@ -39403,36 +41321,122 @@ module.exports = LeftCenter; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetCenterY = __webpack_require__(49); -var GetRight = __webpack_require__(28); -var SetCenterY = __webpack_require__(48); -var SetRight = __webpack_require__(29); +var Defaults = __webpack_require__(112); +var GetAdvancedValue = __webpack_require__(8); +var GetBoolean = __webpack_require__(69); +var GetEaseFunction = __webpack_require__(71); +var GetNewValue = __webpack_require__(83); +var GetValue = __webpack_require__(5); +var GetValueOp = __webpack_require__(113); +var Tween = __webpack_require__(111); +var TweenData = __webpack_require__(110); /** - * Takes given Game Object and aligns it so that it is positioned in the right center of the other. + * [description] * - * @function Phaser.Display.Align.In.RightCenter + * @function Phaser.Tweens.Builders.NumberTweenBuilder * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. + * @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - [description] + * @param {object} config - [description] + * @param {Phaser.Tweens.TweenConfigDefaults} defaults - [description] * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + * @return {Phaser.Tweens.Tween} [description] */ -var RightCenter = function (gameObject, alignIn, offsetX, offsetY) +var NumberTweenBuilder = function (parent, config, defaults) { - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } + if (defaults === undefined) + { + defaults = Defaults; + } - SetRight(gameObject, GetRight(alignIn) + offsetX); - SetCenterY(gameObject, GetCenterY(alignIn) + offsetY); + // var tween = this.tweens.addCounter({ + // from: 100, + // to: 200, + // ... (normal tween properties) + // }) + // + // Then use it in your game via: + // + // tween.getValue() - return gameObject; + var from = GetValue(config, 'from', 0); + var to = GetValue(config, 'to', 1); + + var targets = [ { value: from } ]; + + var delay = GetNewValue(config, 'delay', defaults.delay); + var duration = GetNewValue(config, 'duration', defaults.duration); + var easeParams = GetValue(config, 'easeParams', defaults.easeParams); + var ease = GetEaseFunction(GetValue(config, 'ease', defaults.ease), easeParams); + var hold = GetNewValue(config, 'hold', defaults.hold); + var repeat = GetNewValue(config, 'repeat', defaults.repeat); + var repeatDelay = GetNewValue(config, 'repeatDelay', defaults.repeatDelay); + var yoyo = GetBoolean(config, 'yoyo', defaults.yoyo); + + var data = []; + + var ops = GetValueOp('value', to); + + var tweenData = TweenData( + targets[0], + 'value', + ops.getEnd, + ops.getStart, + ease, + delay, + duration, + yoyo, + hold, + repeat, + repeatDelay, + false, + false + ); + + tweenData.start = from; + tweenData.current = from; + tweenData.to = to; + + data.push(tweenData); + + var tween = new Tween(parent, data, targets); + + tween.offset = GetAdvancedValue(config, 'offset', null); + tween.completeDelay = GetAdvancedValue(config, 'completeDelay', 0); + tween.loop = Math.round(GetAdvancedValue(config, 'loop', 0)); + tween.loopDelay = Math.round(GetAdvancedValue(config, 'loopDelay', 0)); + tween.paused = GetBoolean(config, 'paused', false); + tween.useFrames = GetBoolean(config, 'useFrames', false); + + // Set the Callbacks + var scope = GetValue(config, 'callbackScope', tween); + + // Callback parameters: 0 = a reference to the Tween itself, 1 = the target/s of the Tween, ... your own params + var tweenArray = [ tween, null ]; + + var callbacks = Tween.TYPES; + + for (var i = 0; i < callbacks.length; i++) + { + var type = callbacks[i]; + + var callback = GetValue(config, type, false); + + if (callback) + { + var callbackScope = GetValue(config, type + 'Scope', scope); + var callbackParams = GetValue(config, type + 'Params', []); + + // The null is reset to be the Tween target + tween.setCallback(type, callback, tweenArray.concat(callbackParams), callbackScope); + } + } + + return tween; }; -module.exports = RightCenter; +module.exports = NumberTweenBuilder; /***/ }), @@ -39445,36 +41449,40 @@ module.exports = RightCenter; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetCenterX = __webpack_require__(46); -var GetTop = __webpack_require__(30); -var SetCenterX = __webpack_require__(47); -var SetTop = __webpack_require__(31); +var GetValue = __webpack_require__(5); /** - * Takes given Game Object and aligns it so that it is positioned in the top center of the other. + * [description] * - * @function Phaser.Display.Align.In.TopCenter + * @function Phaser.Tweens.Builders.GetTweens * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. + * @param {object} config - [description] * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + * @return {array} [description] */ -var TopCenter = function (gameObject, alignIn, offsetX, offsetY) +var GetTweens = function (config) { - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } + var tweens = GetValue(config, 'tweens', null); - SetCenterX(gameObject, GetCenterX(alignIn) + offsetX); - SetTop(gameObject, GetTop(alignIn) - offsetY); + if (tweens === null) + { + return []; + } + else if (typeof tweens === 'function') + { + tweens = tweens.call(); + } - return gameObject; + if (!Array.isArray(tweens)) + { + tweens = [ tweens ]; + } + + return tweens; }; -module.exports = TopCenter; +module.exports = GetTweens; /***/ }), @@ -39487,36 +41495,52 @@ module.exports = TopCenter; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetLeft = __webpack_require__(26); -var GetTop = __webpack_require__(30); -var SetLeft = __webpack_require__(27); -var SetTop = __webpack_require__(31); +var RESERVED = __webpack_require__(402); /** - * Takes given Game Object and aligns it so that it is positioned in the top left of the other. + * [description] * - * @function Phaser.Display.Align.In.TopLeft + * @function Phaser.Tweens.Builders.GetProps * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. + * @param {object} config - [description] * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + * @return {array} [description] */ -var TopLeft = function (gameObject, alignIn, offsetX, offsetY) +var GetProps = function (config) { - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } + var key; + var keys = []; - SetLeft(gameObject, GetLeft(alignIn) - offsetX); - SetTop(gameObject, GetTop(alignIn) - offsetY); + // First see if we have a props object - return gameObject; + if (config.hasOwnProperty('props')) + { + for (key in config.props) + { + // Skip any property that starts with an underscore + if (key.substr(0, 1) !== '_') + { + keys.push({ key: key, value: config.props[key] }); + } + } + } + else + { + for (key in config) + { + // Skip any property that is in the ReservedProps list or that starts with an underscore + if (RESERVED.indexOf(key) === -1 && key.substr(0, 1) !== '_') + { + keys.push({ key: key, value: config[key] }); + } + } + } + + return keys; }; -module.exports = TopLeft; +module.exports = GetProps; /***/ }), @@ -39529,36 +41553,311 @@ module.exports = TopLeft; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetRight = __webpack_require__(28); -var GetTop = __webpack_require__(30); -var SetRight = __webpack_require__(29); -var SetTop = __webpack_require__(31); +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(2); /** - * Takes given Game Object and aligns it so that it is positioned in the top right of the other. + * @typedef {object} TimerEventConfig * - * @function Phaser.Display.Align.In.TopRight + * @property {number} [delay=0] - [description] + * @property {number} [repeat=0] - [description] + * @property {boolean} [loop=false] - [description] + * @property {function} [callback] - [description] + * @property {*} [callbackScope] - [description] + * @property {Array.<*>} [args] - [description] + * @property {number} [timeScale=1] - [description] + * @property {number} [startAt=1] - [description] + * @property {boolean} [paused=false] - [description] + */ + +/** + * @classdesc + * [description] + * + * @class TimerEvent + * @memberOf Phaser.Time + * @constructor * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + * @param {TimerEventConfig} config - [description] */ -var TopRight = function (gameObject, alignIn, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } +var TimerEvent = new Class({ - SetRight(gameObject, GetRight(alignIn) + offsetX); - SetTop(gameObject, GetTop(alignIn) - offsetY); + initialize: - return gameObject; -}; + function TimerEvent (config) + { + /** + * The delay in ms at which this TimerEvent fires. + * + * @name Phaser.Time.TimerEvent#delay + * @type {number} + * @default 0 + * @readOnly + * @since 3.0.0 + */ + this.delay = 0; -module.exports = TopRight; + /** + * The total number of times this TimerEvent will repeat before finishing. + * + * @name Phaser.Time.TimerEvent#repeat + * @type {number} + * @default 0 + * @readOnly + * @since 3.0.0 + */ + this.repeat = 0; + + /** + * If repeating this contains the current repeat count. + * + * @name Phaser.Time.TimerEvent#repeatCount + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.repeatCount = 0; + + /** + * True if this TimerEvent loops, otherwise false. + * + * @name Phaser.Time.TimerEvent#loop + * @type {boolean} + * @default false + * @readOnly + * @since 3.0.0 + */ + this.loop = false; + + /** + * The callback that will be called when the TimerEvent occurs. + * + * @name Phaser.Time.TimerEvent#callback + * @type {function} + * @since 3.0.0 + */ + this.callback; + + /** + * The scope in which the callback will be called. + * + * @name Phaser.Time.TimerEvent#callbackScope + * @type {object} + * @since 3.0.0 + */ + this.callbackScope; + + /** + * Additional arguments to be passed to the callback. + * + * @name Phaser.Time.TimerEvent#args + * @type {array} + * @since 3.0.0 + */ + this.args; + + /** + * Scale the time causing this TimerEvent to update. + * + * @name Phaser.Time.TimerEvent#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * Start this many MS into the elapsed (useful if you want a long duration with repeat, but for the first loop to fire quickly) + * + * @name Phaser.Time.TimerEvent#startAt + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.startAt = 0; + + /** + * [description] + * + * @name Phaser.Time.TimerEvent#elapsed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.elapsed = 0; + + /** + * [description] + * + * @name Phaser.Time.TimerEvent#paused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.paused = false; + + /** + * [description] + * + * @name Phaser.Time.TimerEvent#hasDispatched + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.hasDispatched = false; + + this.reset(config); + }, + + /** + * [description] + * + * @method Phaser.Time.TimerEvent#reset + * @since 3.0.0 + * + * @param {TimerEventConfig} config - [description] + * + * @return {Phaser.Time.TimerEvent} This TimerEvent object. + */ + reset: function (config) + { + this.delay = GetFastValue(config, 'delay', 0); + + // Can also be set to -1 for an infinite loop (same as setting loop: true) + this.repeat = GetFastValue(config, 'repeat', 0); + + this.loop = GetFastValue(config, 'loop', false); + + this.callback = GetFastValue(config, 'callback', undefined); + + this.callbackScope = GetFastValue(config, 'callbackScope', this.callback); + + this.args = GetFastValue(config, 'args', []); + + this.timeScale = GetFastValue(config, 'timeScale', 1); + + this.startAt = GetFastValue(config, 'startAt', 0); + + this.paused = GetFastValue(config, 'paused', false); + + this.elapsed = this.startAt; + this.hasDispatched = false; + this.repeatCount = (this.repeat === -1 || this.loop) ? 999999999999 : this.repeat; + + return this; + }, + + /** + * Gets the progress of the current iteration, not factoring in repeats. + * + * @method Phaser.Time.TimerEvent#getProgress + * @since 3.0.0 + * + * @return {number} [description] + */ + getProgress: function () + { + return (this.elapsed / this.delay); + }, + + /** + * Gets the progress of the timer overall, factoring in repeats. + * + * @method Phaser.Time.TimerEvent#getOverallProgress + * @since 3.0.0 + * + * @return {number} [description] + */ + getOverallProgress: function () + { + if (this.repeat > 0) + { + var totalDuration = this.delay + (this.delay * this.repeat); + var totalElapsed = this.elapsed + (this.delay * (this.repeat - this.repeatCount)); + + return (totalElapsed / totalDuration); + } + else + { + return this.getProgress(); + } + }, + + /** + * [description] + * + * @method Phaser.Time.TimerEvent#getRepeatCount + * @since 3.0.0 + * + * @return {number} [description] + */ + getRepeatCount: function () + { + return this.repeatCount; + }, + + /** + * [description] + * + * @method Phaser.Time.TimerEvent#getElapsed + * @since 3.0.0 + * + * @return {number} [description] + */ + getElapsed: function () + { + return this.elapsed; + }, + + /** + * [description] + * + * @method Phaser.Time.TimerEvent#getElapsedSeconds + * @since 3.0.0 + * + * @return {number} [description] + */ + getElapsedSeconds: function () + { + return this.elapsed * 0.001; + }, + + /** + * [description] + * + * @method Phaser.Time.TimerEvent#remove + * @since 3.0.0 + * + * @param {function} dispatchCallback - [description] + */ + remove: function (dispatchCallback) + { + if (dispatchCallback === undefined) { dispatchCallback = false; } + + this.elapsed = this.delay; + + this.hasDispatched = !dispatchCallback; + + this.repeatCount = 0; + }, + + /** + * [description] + * + * @method Phaser.Time.TimerEvent#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.callback = undefined; + this.callbackScope = undefined; + this.args = []; + } + +}); + +module.exports = TimerEvent; /***/ }), @@ -39571,35 +41870,1023 @@ module.exports = TopRight; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CircumferencePoint = __webpack_require__(105); -var FromPercent = __webpack_require__(65); -var MATH_CONST = __webpack_require__(16); -var Point = __webpack_require__(5); +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var CONST = __webpack_require__(21); +var GameObject = __webpack_require__(1); +var StaticTilemapLayerRender = __webpack_require__(411); +var TilemapComponents = __webpack_require__(88); +var Utils = __webpack_require__(44); /** - * Returns a Point object containing the coordinates of a point on the circumference of the Circle - * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point - * at 180 degrees around the circle. + * @classdesc + * A StaticTilemapLayer is a game object that renders LayerData from a Tilemap. A + * StaticTilemapLayer can only render tiles from a single tileset. * - * @function Phaser.Geom.Circle.GetPoint + * A StaticTilemapLayer is optimized for speed over flexibility. You cannot apply per-tile + * effects like tint or alpha. You cannot change the tiles in a StaticTilemapLayer. Use this + * over a DynamicTilemapLayer when you don't need either of those features. + * + * @class StaticTilemapLayer + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.Tilemaps + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on. - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. - * @param {Phaser.Geom.Point|object} [out] - An object to store the return values in. If not given a Point object will be created. + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * @extends Phaser.GameObjects.Components.ScrollFactor * - * @return {Phaser.Geom.Point|object} A Point, or point-like object, containing the coordinates of the point around the circle. + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Tilemaps.Tilemap} tilemap - The Tilemap this layer is a part of. + * @param {integer} layerIndex - The index of the LayerData associated with this layer. + * @param {Phaser.Tilemaps.Tileset} tileset - The tileset used to render the tiles in this layer. + * @param {number} [x=0] - The world x position where the top left of this layer will be placed. + * @param {number} [y=0] - The world y position where the top left of this layer will be placed. */ -var GetPoint = function (circle, position, out) -{ - if (out === undefined) { out = new Point(); } +var StaticTilemapLayer = new Class({ - var angle = FromPercent(position, 0, MATH_CONST.PI2); + Extends: GameObject, - return CircumferencePoint(circle, angle, out); -}; + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.Size, + Components.Transform, + Components.Visible, + Components.ScrollFactor, + StaticTilemapLayerRender + ], -module.exports = GetPoint; + initialize: + + function StaticTilemapLayer (scene, tilemap, layerIndex, tileset, x, y) + { + GameObject.call(this, scene, 'StaticTilemapLayer'); + + /** + * Used internally by physics system to perform fast type checks. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#isTilemap + * @type {boolean} + * @readOnly + * @since 3.0.0 + */ + this.isTilemap = true; + + /** + * The Tilemap that this layer is a part of. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#tilemap + * @type {Phaser.Tilemaps.Tilemap} + * @since 3.0.0 + */ + this.tilemap = tilemap; + + /** + * The index of the LayerData associated with this layer. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#layerIndex + * @type {integer} + * @since 3.0.0 + */ + this.layerIndex = layerIndex; + + /** + * The LayerData associated with this layer. LayerData can only be associated with one + * tilemap layer. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#layer + * @type {Phaser.Tilemaps.LayerData} + * @since 3.0.0 + */ + this.layer = tilemap.layers[layerIndex]; + + this.layer.tilemapLayer = this; // Link the LayerData with this static tilemap layer + + /** + * The Tileset associated with this layer. A tilemap layer can only render from one Tileset. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#tileset + * @type {Phaser.Tilemaps.Tileset} + * @since 3.0.0 + */ + this.tileset = tileset; + + /** + * Used internally with the canvas render. This holds the tiles that are visible within the + * camera. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#culledTiles + * @type {array} + * @since 3.0.0 + */ + this.culledTiles = []; + + /** + * @name Phaser.Tilemaps.StaticTilemapLayer#vertexBuffer + * @type {array} + * @private + * @since 3.0.0 + */ + this.vertexBuffer = null; + + /** + * @name Phaser.Tilemaps.StaticTilemapLayer#renderer + * @type {(Phaser.Renderer.CanvasRenderer|Phaser.Renderer.WebGLRenderer)} + * @private + * @since 3.0.0 + */ + this.renderer = scene.sys.game.renderer; + + /** + * @name Phaser.Tilemaps.StaticTilemapLayer#bufferData + * @type {ArrayBuffer} + * @private + * @since 3.0.0 + */ + this.bufferData = null; + + /** + * @name Phaser.Tilemaps.StaticTilemapLayer#vertexViewF32 + * @type {Float32Array} + * @private + * @since 3.0.0 + */ + this.vertexViewF32 = null; + + /** + * @name Phaser.Tilemaps.StaticTilemapLayer#vertexViewU32 + * @type {Uint32Array} + * @private + * @since 3.0.0 + */ + this.vertexViewU32 = null; + + /** + * @name Phaser.Tilemaps.StaticTilemapLayer#dirty + * @type {boolean} + * @private + * @since 3.0.0 + */ + this.dirty = true; + + /** + * @name Phaser.Tilemaps.StaticTilemapLayer#vertexCount + * @type {integer} + * @private + * @since 3.0.0 + */ + this.vertexCount = 0; + + this.setAlpha(this.layer.alpha); + this.setPosition(x, y); + this.setOrigin(); + this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height); + + this.initPipeline('TextureTintPipeline'); + + if (scene.sys.game.config.renderType === CONST.WEBGL) + { + scene.sys.game.renderer.onContextRestored(function () + { + this.dirty = true; + this.vertexBuffer = null; + }, this); + } + }, + + /** + * Upload the tile data to a VBO. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#upload + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to render to. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + upload: function (camera) + { + var tileset = this.tileset; + var mapWidth = this.layer.width; + var mapHeight = this.layer.height; + var width = tileset.image.get().width; + var height = tileset.image.get().height; + var mapData = this.layer.data; + var renderer = this.renderer; + var tile; + var row; + var col; + var texCoords; + + if (renderer.gl) + { + var pipeline = renderer.pipelines.TextureTintPipeline; + + if (this.dirty) + { + var gl = renderer.gl; + var vertexBuffer = this.vertexBuffer; + var bufferData = this.bufferData; + var voffset = 0; + var vertexCount = 0; + var bufferSize = (mapWidth * mapHeight) * pipeline.vertexSize * 6; + + if (bufferData === null) + { + bufferData = new ArrayBuffer(bufferSize); + this.bufferData = bufferData; + this.vertexViewF32 = new Float32Array(bufferData); + this.vertexViewU32 = new Uint32Array(bufferData); + } + + var vertexViewF32 = this.vertexViewF32; + var vertexViewU32 = this.vertexViewU32; + + for (row = 0; row < mapHeight; ++row) + { + for (col = 0; col < mapWidth; ++col) + { + tile = mapData[row][col]; + if (tile === null || tile.index === -1) { continue; } + + var tx = tile.pixelX; + var ty = tile.pixelY; + var txw = tx + tile.width; + var tyh = ty + tile.height; + + texCoords = tileset.getTileTextureCoordinates(tile.index); + if (texCoords === null) { continue; } + + var u0 = texCoords.x / width; + var v0 = texCoords.y / height; + var u1 = (texCoords.x + tile.width) / width; + var v1 = (texCoords.y + tile.height) / height; + + var tx0 = tx; + var ty0 = ty; + var tx1 = tx; + var ty1 = tyh; + var tx2 = txw; + var ty2 = tyh; + var tx3 = txw; + var ty3 = ty; + var tint = Utils.getTintAppendFloatAlpha(0xffffff, this.alpha * tile.alpha); + + vertexViewF32[voffset + 0] = tx0; + vertexViewF32[voffset + 1] = ty0; + vertexViewF32[voffset + 2] = u0; + vertexViewF32[voffset + 3] = v0; + vertexViewU32[voffset + 4] = tint; + vertexViewF32[voffset + 5] = tx1; + vertexViewF32[voffset + 6] = ty1; + vertexViewF32[voffset + 7] = u0; + vertexViewF32[voffset + 8] = v1; + vertexViewU32[voffset + 9] = tint; + vertexViewF32[voffset + 10] = tx2; + vertexViewF32[voffset + 11] = ty2; + vertexViewF32[voffset + 12] = u1; + vertexViewF32[voffset + 13] = v1; + vertexViewU32[voffset + 14] = tint; + vertexViewF32[voffset + 15] = tx0; + vertexViewF32[voffset + 16] = ty0; + vertexViewF32[voffset + 17] = u0; + vertexViewF32[voffset + 18] = v0; + vertexViewU32[voffset + 19] = tint; + vertexViewF32[voffset + 20] = tx2; + vertexViewF32[voffset + 21] = ty2; + vertexViewF32[voffset + 22] = u1; + vertexViewF32[voffset + 23] = v1; + vertexViewU32[voffset + 24] = tint; + vertexViewF32[voffset + 25] = tx3; + vertexViewF32[voffset + 26] = ty3; + vertexViewF32[voffset + 27] = u1; + vertexViewF32[voffset + 28] = v0; + vertexViewU32[voffset + 29] = tint; + + voffset += 30; + vertexCount += 6; + } + } + + this.vertexCount = vertexCount; + this.dirty = false; + if (vertexBuffer === null) + { + vertexBuffer = renderer.createVertexBuffer(bufferData, gl.STATIC_DRAW); + this.vertexBuffer = vertexBuffer; + } + else + { + renderer.setVertexBuffer(vertexBuffer); + gl.bufferSubData(gl.ARRAY_BUFFER, 0, bufferData); + } + } + + pipeline.modelIdentity(); + pipeline.modelTranslate(this.x - (camera.scrollX * this.scrollFactorX), this.y - (camera.scrollY * this.scrollFactorY), 0.0); + pipeline.modelScale(this.scaleX, this.scaleY, 1.0); + pipeline.viewLoad2D(camera.matrix.matrix); + } + + return this; + }, + + /** + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#calculateFacesAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate. + * @param {integer} tileY - The y coordinate. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + calculateFacesAt: function (tileX, tileY) + { + TilemapComponents.CalculateFacesAt(tileX, tileY, this.layer); + + return this; + }, + + /** + * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the + * layer. Interesting faces are used internally for optimizing collisions against tiles. This method + * is mostly used internally. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#calculateFacesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + calculateFacesWithin: function (tileX, tileY, width, height) + { + TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#createFromTiles + * @since 3.0.0 + * + * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. + * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted + * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a + * one-to-one mapping with the indexes array. + * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. + * scene.make.sprite). + * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY + * + * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. + */ + createFromTiles: function (indexes, replacements, spriteConfig, scene, camera) + { + return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, this.layer); + }, + + /** + * Returns the tiles in the given layer that are within the cameras viewport. + * This is used internally. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#cull + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + cull: function (camera) + { + return TilemapComponents.CullTiles(this.layer, camera, this.culledTiles); + }, + + /** + * Destroys this StaticTilemapLayer and removes its link to the associated LayerData. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#destroy + * @since 3.0.0 + */ + destroy: function () + { + // Uninstall this layer only if it is still installed on the LayerData object + if (this.layer.tilemapLayer === this) + { + this.layer.tilemapLayer = undefined; + } + + this.tilemap = undefined; + this.layer = undefined; + this.tileset = undefined; + + GameObject.prototype.destroy.call(this); + }, + + /** + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#findByIndex + * @since 3.0.0 + * + * @param {integer} index - The tile index value to search for. + * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. + * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the + * bottom-right. Otherwise it scans from the top-left. + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + findByIndex: function (findIndex, skip, reverse) + { + return TilemapComponents.FindByIndex(findIndex, skip, reverse, this.layer); + }, + + /** + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#findTile + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {?Phaser.Tilemaps.Tile} + */ + findTile: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#filterTiles + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#forEachTile + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + + return this; + }, + + /** + * Gets a tile at the given tile coordinates from the given layer. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTileAt + * @since 3.0.0 + * + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). + * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile + * object with an index of -1. + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates were invalid. + */ + getTileAt: function (tileX, tileY, nonNull) + { + return TilemapComponents.GetTileAt(tileX, tileY, nonNull, this.layer); + }, + + /** + * Gets a tile at the given world coordinates from the given layer. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - X position to get the tile from (given in pixels) + * @param {number} worldY - Y position to get the tile from (given in pixels) + * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile + * object with an index of -1. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates + * were invalid. + */ + getTileAtWorldXY: function (worldX, worldY, nonNull, camera) + { + return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, this.layer); + }, + + /** + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithin: function (tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithinWorldXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera) + { + return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, this.layer); + }, + + /** + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithinShape + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithinShape: function (shape, filteringOptions, camera) + { + return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, this.layer); + }, + + /** + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#hasTileAt + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * + * @return {boolean} + */ + hasTileAt: function (tileX, tileY) + { + return TilemapComponents.HasTileAt(tileX, tileY, this.layer); + }, + + /** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#hasTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {boolean} + */ + hasTileAtWorldXY: function (worldX, worldY, camera) + { + return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, this.layer); + }, + + /** + * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#renderDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. + * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. + * @param {?Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at + * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. + * @param {?Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled + * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. + * @param {?Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting + * tile faces. If set to null, interesting tile faces will not be drawn. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + renderDebug: function (graphics, styleConfig) + { + TilemapComponents.RenderDebug(graphics, styleConfig, this.layer); + + return this; + }, + + /** + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollision + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollision: function (indexes, collides, recalculateFaces) + { + TilemapComponents.SetCollision(indexes, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionBetween + * @since 3.0.0 + * + * @param {integer} start - The first index of the tile to be set for collision. + * @param {integer} stop - The last index of the tile to be set for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollisionBetween: function (start, stop, collides, recalculateFaces) + { + TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionByProperty + * @since 3.0.0 + * + * @param {object} properties - An object with tile properties and corresponding values that should + * be checked. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollisionByProperty: function (properties, collides, recalculateFaces) + { + TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionByExclusion + * @since 3.0.0 + * + * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollisionByExclusion: function (indexes, collides, recalculateFaces) + { + TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see setTileLocationCallback. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setTileIndexCallback + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a + * collision callback set for. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setTileIndexCallback: function (indexes, callback, callbackContext) + { + TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, this.layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking each tiles collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tiles collision group, the tile's colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionFromCollisionGroup + * @since 3.0.0 + * + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollisionFromCollisionGroup: function (collides, recalculateFaces) + { + TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setTileLocationCallback + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext) + { + TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, this.layer); + + return this; + }, + + /** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldX + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + tileToWorldX: function (tileX, camera) + { + return TilemapComponents.TileToWorldX(tileX, camera, this.layer); + }, + + /** + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldY + * @since 3.0.0 + * + * @param {integer} tileY - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + tileToWorldY: function (tileY, camera) + { + return TilemapComponents.TileToWorldY(tileY, camera, this.layer); + }, + + /** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldXY + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {Phaser.Math.Vector2} [point] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Math.Vector2} + */ + tileToWorldXY: function (tileX, tileY, point, camera) + { + return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, this.layer); + }, + + /** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileX + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + worldToTileX: function (worldX, snapToFloor, camera) + { + return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, this.layer); + }, + + /** + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileXY + * @since 3.0.0 + * + * @param {number} worldY - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + worldToTileY: function (worldY, snapToFloor, camera) + { + return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, this.layer); + }, + + /** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Math.Vector2} [point] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Math.Vector2} + */ + worldToTileXY: function (worldX, worldY, snapToFloor, point, camera) + { + return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, this.layer); + } + +}); + +module.exports = StaticTilemapLayer; /***/ }), @@ -39612,51 +42899,1117 @@ module.exports = GetPoint; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Circumference = __webpack_require__(186); -var CircumferencePoint = __webpack_require__(105); -var FromPercent = __webpack_require__(65); -var MATH_CONST = __webpack_require__(16); +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var DynamicTilemapLayerRender = __webpack_require__(414); +var GameObject = __webpack_require__(1); +var TilemapComponents = __webpack_require__(88); /** - * Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, - * based on the given quantity or stepRate values. + * @classdesc + * A DynamicTilemapLayer is a game object that renders LayerData from a Tilemap. A + * DynamicTilemapLayer can only render tiles from a single tileset. * - * @function Phaser.Geom.Circle.GetPoints + * A DynamicTilemapLayer trades some speed for being able to apply powerful effects. Unlike a + * StaticTilemapLayer, you can apply per-tile effects like tint or alpha, and you can change the + * tiles in a DynamicTilemapLayer. Use this over a StaticTilemapLayer when you need those + * features. + * + * @class DynamicTilemapLayer + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.Tilemaps + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Circle} circle - The Circle to get the points from. - * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param {number} [stepRate] - Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. - * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * @extends Phaser.GameObjects.Components.ScrollFactor * - * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the circumference of the circle. + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Tilemaps.Tilemap} tilemap - The Tilemap this layer is a part of. + * @param {integer} layerIndex - The index of the LayerData associated with this layer. + * @param {Phaser.Tilemaps.Tileset} tileset - The tileset used to render the tiles in this layer. + * @param {number} [x=0] - The world x position where the top left of this layer will be placed. + * @param {number} [y=0] - The world y position where the top left of this layer will be placed. */ -var GetPoints = function (circle, quantity, stepRate, out) -{ - if (out === undefined) { out = []; } +var DynamicTilemapLayer = new Class({ - // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. - if (!quantity) + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.Size, + Components.Transform, + Components.Visible, + Components.ScrollFactor, + DynamicTilemapLayerRender + ], + + initialize: + + function DynamicTilemapLayer (scene, tilemap, layerIndex, tileset, x, y) { - quantity = Circumference(circle) / stepRate; + GameObject.call(this, scene, 'DynamicTilemapLayer'); + + /** + * Used internally by physics system to perform fast type checks. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#isTilemap + * @type {boolean} + * @readOnly + * @since 3.0.0 + */ + this.isTilemap = true; + + /** + * The Tilemap that this layer is a part of. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#tilemap + * @type {Phaser.Tilemaps.Tilemap} + * @since 3.0.0 + */ + this.tilemap = tilemap; + + /** + * The index of the LayerData associated with this layer. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#layerIndex + * @type {integer} + * @since 3.0.0 + */ + this.layerIndex = layerIndex; + + /** + * The LayerData associated with this layer. LayerData can only be associated with one + * tilemap layer. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#layer + * @type {Phaser.Tilemaps.LayerData} + * @since 3.0.0 + */ + this.layer = tilemap.layers[layerIndex]; + + this.layer.tilemapLayer = this; // Link the LayerData with this static tilemap layer + + /** + * The Tileset associated with this layer. A tilemap layer can only render from one Tileset. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#tileset + * @type {Phaser.Tilemaps.Tileset} + * @since 3.0.0 + */ + this.tileset = tileset; + + /** + * Used internally with the canvas render. This holds the tiles that are visible within the + * camera. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#culledTiles + * @type {array} + * @since 3.0.0 + */ + this.culledTiles = []; + + this.setAlpha(this.layer.alpha); + this.setPosition(x, y); + this.setOrigin(); + this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height); + + this.initPipeline('TextureTintPipeline'); + }, + + /** + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#calculateFacesAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate. + * @param {integer} tileY - The y coordinate. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + calculateFacesAt: function (tileX, tileY) + { + TilemapComponents.CalculateFacesAt(tileX, tileY, this.layer); + + return this; + }, + + /** + * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the + * layer. Interesting faces are used internally for optimizing collisions against tiles. This method + * is mostly used internally. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#calculateFacesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + calculateFacesWithin: function (tileX, tileY, width, height) + { + TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#createFromTiles + * @since 3.0.0 + * + * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. + * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted + * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a + * one-to-one mapping with the indexes array. + * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. + * scene.make.sprite). + * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY + * + * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. + */ + createFromTiles: function (indexes, replacements, spriteConfig, scene, camera) + { + return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, this.layer); + }, + + /** + * Returns the tiles in the given layer that are within the cameras viewport. + * This is used internally. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#cull + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + cull: function (camera) + { + return TilemapComponents.CullTiles(this.layer, camera, this.culledTiles); + }, + + /** + * Copies the tiles in the source rectangular area to a new destination (all specified in tile + * coordinates) within the layer. This copies all tile properties & recalculates collision + * information in the destination region. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#copy + * @since 3.0.0 + * + * @param {integer} srcTileX - [description] + * @param {integer} srcTileY - [description] + * @param {integer} width - [description] + * @param {integer} height - [description] + * @param {integer} destTileX - [description] + * @param {integer} destTileY - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces) + { + TilemapComponents.Copy(srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, this.layer); + + return this; + }, + + /** + * Destroys this DynamicTilemapLayer and removes its link to the associated LayerData. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#destroy + * @since 3.0.0 + */ + destroy: function () + { + // Uninstall this layer only if it is still installed on the LayerData object + if (this.layer.tilemapLayer === this) + { + this.layer.tilemapLayer = undefined; + } + + this.tilemap = undefined; + this.layer = undefined; + this.tileset = undefined; + this.culledTiles.length = 0; + + GameObject.prototype.destroy.call(this); + }, + + /** + * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the + * specified index. Tiles will be set to collide if the given index is a colliding index. + * Collision information in the region will be recalculated. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#fill + * @since 3.0.0 + * + * @param {integer} index - [description] + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + fill: function (index, tileX, tileY, width, height, recalculateFaces) + { + TilemapComponents.Fill(index, tileX, tileY, width, height, recalculateFaces, this.layer); + + return this; + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#filterTiles + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#findByIndex + * @since 3.0.0 + * + * @param {integer} index - The tile index value to search for. + * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. + * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the + * bottom-right. Otherwise it scans from the top-left. + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + findByIndex: function (findIndex, skip, reverse) + { + return TilemapComponents.FindByIndex(findIndex, skip, reverse, this.layer); + }, + + /** + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#findTile + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {?Phaser.Tilemaps.Tile} + */ + findTile: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#forEachTile + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + + return this; + }, + + /** + * Gets a tile at the given tile coordinates from the given layer. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTileAt + * @since 3.0.0 + * + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). + * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile + * object with an index of -1. + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates were invalid. + */ + getTileAt: function (tileX, tileY, nonNull) + { + return TilemapComponents.GetTileAt(tileX, tileY, nonNull, this.layer); + }, + + /** + * Gets a tile at the given world coordinates from the given layer. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - X position to get the tile from (given in pixels) + * @param {number} worldY - Y position to get the tile from (given in pixels) + * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile + * object with an index of -1. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates + * were invalid. + */ + getTileAtWorldXY: function (worldX, worldY, nonNull, camera) + { + return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, this.layer); + }, + + /** + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithin: function (tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithinShape + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithinShape: function (shape, filteringOptions, camera) + { + return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, this.layer); + }, + + /** + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithinWorldXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera) + { + return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, this.layer); + }, + + /** + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#hasTileAt + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * + * @return {boolean} + */ + hasTileAt: function (tileX, tileY) + { + return TilemapComponents.HasTileAt(tileX, tileY, this.layer); + }, + + /** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#hasTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {boolean} + */ + hasTileAtWorldXY: function (worldX, worldY, camera) + { + return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, this.layer); + }, + + /** + * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index + * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified + * location. If you pass in an index, only the index at the specified location will be changed. + * Collision information will be recalculated at the specified location. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#putTileAt + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + putTileAt: function (tile, tileX, tileY, recalculateFaces) + { + return TilemapComponents.PutTileAt(tile, tileX, tileY, recalculateFaces, this.layer); + }, + + /** + * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either + * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the + * specified location. If you pass in an index, only the index at the specified location will be + * changed. Collision information will be recalculated at the specified location. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#putTileAtWorldXY + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} worldX - [description] + * @param {integer} worldY - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - [description] + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + putTileAtWorldXY: function (tile, worldX, worldY, recalculateFaces, camera) + { + return TilemapComponents.PutTileAtWorldXY(tile, worldX, worldY, recalculateFaces, camera, this.layer); + }, + + /** + * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified + * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, + * all attributes will be copied over to the specified location. If you pass in an index, only the + * index at the specified location will be changed. Collision information will be recalculated + * within the region tiles were changed. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#putTilesAt + * @since 3.0.0 + * + * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles + * or tile indexes to place. + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + putTilesAt: function (tilesArray, tileX, tileY, recalculateFaces) + { + TilemapComponents.PutTilesAt(tilesArray, tileX, tileY, recalculateFaces, this.layer); + + return this; + }, + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then + * those will be used for randomly assigning new tile indexes. If an array is not provided, the + * indexes found within the region (excluding -1) will be used for randomly assigning new tile + * indexes. This method only modifies tile indexes and does not change collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#randomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + randomize: function (tileX, tileY, width, height, indexes) + { + TilemapComponents.Randomize(tileX, tileY, width, height, indexes, this.layer); + + return this; + }, + + /** + * Removes the tile at the given tile coordinates in the specified layer and updates the layer's + * collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#removeTileAt + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified + * location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - [description] + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + removeTileAt: function (tileX, tileY, replaceWithNull, recalculateFaces) + { + return TilemapComponents.RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, this.layer); + }, + + /** + * Removes the tile at the given world coordinates in the specified layer and updates the layer's + * collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#removeTileAtWorldXY + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified + * location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + removeTileAtWorldXY: function (worldX, worldY, replaceWithNull, recalculateFaces, camera) + { + return TilemapComponents.RemoveTileAtWorldXY(worldX, worldY, replaceWithNull, recalculateFaces, camera, this.layer); + }, + + /** + * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#renderDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. + * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. + * @param {?Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at + * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. + * @param {?Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled + * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. + * @param {?Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting + * tile faces. If set to null, interesting tile faces will not be drawn. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + renderDebug: function (graphics, styleConfig) + { + TilemapComponents.RenderDebug(graphics, styleConfig, this.layer); + + return this; + }, + + /** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does + * not change collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#replaceByIndex + * @since 3.0.0 + * + * @param {integer} findIndex - [description] + * @param {integer} newIndex - [description] + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + replaceByIndex: function (findIndex, newIndex, tileX, tileY, width, height) + { + TilemapComponents.ReplaceByIndex(findIndex, newIndex, tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollision + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollision: function (indexes, collides, recalculateFaces) + { + TilemapComponents.SetCollision(indexes, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionBetween + * @since 3.0.0 + * + * @param {integer} start - The first index of the tile to be set for collision. + * @param {integer} stop - The last index of the tile to be set for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollisionBetween: function (start, stop, collides, recalculateFaces) + { + TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionByProperty + * @since 3.0.0 + * + * @param {object} properties - An object with tile properties and corresponding values that should + * be checked. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollisionByProperty: function (properties, collides, recalculateFaces) + { + TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionByExclusion + * @since 3.0.0 + * + * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollisionByExclusion: function (indexes, collides, recalculateFaces) + { + TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking each tiles collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tiles collision group, the tile's colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionFromCollisionGroup + * @since 3.0.0 + * + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollisionFromCollisionGroup: function (collides, recalculateFaces) + { + TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see setTileLocationCallback. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setTileIndexCallback + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a + * collision callback set for. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setTileIndexCallback: function (indexes, callback, callbackContext) + { + TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, this.layer); + + return this; + }, + + /** + * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setTileLocationCallback + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext) + { + TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, this.layer); + + return this; + }, + + /** + * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given + * layer. It will only randomize the tiles in that area, so if they're all the same nothing will + * appear to have changed! This method only modifies tile indexes and does not change collision + * information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#shuffle + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + shuffle: function (tileX, tileY, width, height) + { + TilemapComponents.Shuffle(tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision + * information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#swapByIndex + * @since 3.0.0 + * + * @param {integer} tileA - First tile index. + * @param {integer} tileB - Second tile index. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + swapByIndex: function (indexA, indexB, tileX, tileY, width, height) + { + TilemapComponents.SwapByIndex(indexA, indexB, tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldX + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + tileToWorldX: function (tileX, camera) + { + return TilemapComponents.TileToWorldX(tileX, camera, this.layer); + }, + + /** + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldY + * @since 3.0.0 + * + * @param {integer} tileY - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + tileToWorldY: function (tileY, camera) + { + return TilemapComponents.TileToWorldY(tileY, camera, this.layer); + }, + + /** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldXY + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {Phaser.Math.Vector2} [point] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Math.Vector2} + */ + tileToWorldXY: function (tileX, tileY, point, camera) + { + return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, this.layer); + }, + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will recieve a new index. New indexes are drawn from the given + * weightedIndexes array. An example weighted array: + * + * [ + * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 + * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 + * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 + * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 + * ] + * + * The probability of any index being choose is (the index's weight) / (sum of all weights). This + * method only modifies tile indexes and does not change collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#weightedRandomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during + * randomization. They should be in the form: { index: 0, weight: 4 } or + * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + weightedRandomize: function (tileX, tileY, width, height, weightedIndexes) + { + TilemapComponents.WeightedRandomize(tileX, tileY, width, height, weightedIndexes, this.layer); + + return this; + }, + + /** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileX + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + worldToTileX: function (worldX, snapToFloor, camera) + { + return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, this.layer); + }, + + /** + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileXY + * @since 3.0.0 + * + * @param {number} worldY - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + worldToTileY: function (worldY, snapToFloor, camera) + { + return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, this.layer); + }, + + /** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Math.Vector2} [point] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Math.Vector2} + */ + worldToTileXY: function (worldX, worldY, snapToFloor, point, camera) + { + return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, this.layer); } - for (var i = 0; i < quantity; i++) - { - var angle = FromPercent(i / quantity, 0, MATH_CONST.PI2); +}); - out.push(CircumferencePoint(circle, angle)); - } - - return out; -}; - -module.exports = GetPoints; +module.exports = DynamicTilemapLayer; /***/ }), /* 186 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -39664,22 +44017,2273 @@ module.exports = GetPoints; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var DegToRad = __webpack_require__(42); +var DynamicTilemapLayer = __webpack_require__(185); +var Extend = __webpack_require__(18); +var Formats = __webpack_require__(24); +var LayerData = __webpack_require__(66); +var Rotate = __webpack_require__(217); +var StaticTilemapLayer = __webpack_require__(184); +var Tile = __webpack_require__(45); +var TilemapComponents = __webpack_require__(88); +var Tileset = __webpack_require__(84); + /** - * Returns the circumference of the given Circle. + * @callback TilemapFilterCallback * - * @function Phaser.Geom.Circle.Circumference + * @param {Phaser.GameObjects.GameObject} value - [description] + * @param {number} index - [description] + * @param {Phaser.GameObjects.GameObject[]} array - [description] + * + * @return {Phaser.GameObjects.GameObject} [description] + */ + +/** + * @callback TilemapFindCallback + * + * @param {Phaser.GameObjects.GameObject} value - [description] + * @param {number} index - [description] + * @param {Phaser.GameObjects.GameObject[]} array - [description] + * + * @return {boolean} [description] + */ + +/** + * @classdesc + * A Tilemap is a container for Tilemap data. This isn't a display object, rather, it holds data + * about the map and allows you to add tilesets and tilemap layers to it. A map can have one or + * more tilemap layers (StaticTilemapLayer or DynamicTilemapLayer), which are the display + * objects that actually render tiles. + * + * The Tilemap data be parsed from a Tiled JSON file, a CSV file or a 2D array. Tiled is a free + * software package specifically for creating tile maps, and is available from: + * http://www.mapeditor.org + * + * A Tilemap has handy methods for getting & manipulating the tiles within a layer. You can only + * use the methods that change tiles (e.g. removeTileAt) on a DynamicTilemapLayer. + * + * Note that all Tilemaps use a base tile size to calculate dimensions from, but that a + * StaticTilemapLayer or DynamicTilemapLayer may have its own unique tile size that overrides + * it. + * + * @class Tilemap + * @memberOf Phaser.Tilemaps + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference of. - * - * @return {number} The circumference of the Circle. + * @param {Phaser.Scene} scene - The Scene to which this Tilemap belongs. + * @param {Phaser.Tilemaps.MapData} mapData - A MapData instance containing Tilemap data. */ -var Circumference = function (circle) -{ - return 2 * (Math.PI * circle.radius); -}; +var Tilemap = new Class({ -module.exports = Circumference; + initialize: + + function Tilemap (scene, mapData) + { + /** + * @name Phaser.Tilemaps.Tilemap#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * The base width of a tile in pixels. Note that individual layers may have a different tile + * width. + * + * @name Phaser.Tilemaps.Tilemap#tileWidth + * @type {integer} + * @since 3.0.0 + */ + this.tileWidth = mapData.tileWidth; + + /** + * The base height of a tile in pixels. Note that individual layers may have a different + * tile height. + * + * @name Phaser.Tilemaps.Tilemap#tileHeight + * @type {integer} + * @since 3.0.0 + */ + this.tileHeight = mapData.tileHeight; + + /** + * The width of the map (in tiles). + * + * @name Phaser.Tilemaps.Tilemap#width + * @type {number} + * @since 3.0.0 + */ + this.width = mapData.width; + + /** + * The height of the map (in tiles). + * + * @name Phaser.Tilemaps.Tilemap#height + * @type {number} + * @since 3.0.0 + */ + this.height = mapData.height; + + /** + * The orientation of the map data (as specified in Tiled), usually 'orthogonal'. + * + * @name Phaser.Tilemaps.Tilemap#orientation + * @type {string} + * @since 3.0.0 + */ + this.orientation = mapData.orientation; + + /** + * The format of the map data. + * + * @name Phaser.Tilemaps.Tilemap#format + * @type {number} + * @since 3.0.0 + */ + this.format = mapData.format; + + /** + * The version of the map data (as specified in Tiled, usually 1). + * + * @name Phaser.Tilemaps.Tilemap#version + * @type {number} + * @since 3.0.0 + */ + this.version = mapData.version; + + /** + * Map specific properties as specified in Tiled. + * + * @name Phaser.Tilemaps.Tilemap#properties + * @type {object} + * @since 3.0.0 + */ + this.properties = mapData.properties; + + /** + * The width of the map in pixels based on width * tileWidth. + * + * @name Phaser.Tilemaps.Tilemap#widthInPixels + * @type {number} + * @since 3.0.0 + */ + this.widthInPixels = mapData.widthInPixels; + + /** + * The height of the map in pixels based on height * tileHeight. + * + * @name Phaser.Tilemaps.Tilemap#heightInPixels + * @type {number} + * @since 3.0.0 + */ + this.heightInPixels = mapData.heightInPixels; + + /** + * + * @name Phaser.Tilemaps.Tilemap#imageCollections + * @type {Phaser.Tilemaps.ImageCollection[]} + * @since 3.0.0 + */ + this.imageCollections = mapData.imageCollections; + + /** + * An array of Tiled Image Layers. + * + * @name Phaser.Tilemaps.Tilemap#images + * @type {array} + * @since 3.0.0 + */ + this.images = mapData.images; + + /** + * An array of Tilemap layer data. + * + * @name Phaser.Tilemaps.Tilemap#layers + * @type {Phaser.Tilemaps.LayerData[]} + * @since 3.0.0 + */ + this.layers = mapData.layers; + + /** + * An array of Tilesets used in the map. + * + * @name Phaser.Tilemaps.Tilemap#tilesets + * @type {Phaser.Tilemaps.Tileset[]} + * @since 3.0.0 + */ + this.tilesets = mapData.tilesets; + + /** + * An array of ObjectLayer instances parsed from Tiled object layers. + * + * @name Phaser.Tilemaps.Tilemap#objects + * @type {Phaser.Tilemaps.ObjectLayer[]} + * @since 3.0.0 + */ + this.objects = mapData.objects; + + /** + * The index of the currently selected LayerData object. + * + * @name Phaser.Tilemaps.Tilemap#currentLayerIndex + * @type {integer} + * @since 3.0.0 + */ + this.currentLayerIndex = 0; + }, + + /** + * Adds an image to the map to be used as a tileset. A single map may use multiple tilesets. + * Note that the tileset name can be found in the JSON file exported from Tiled, or in the Tiled + * editor. + * + * @method Phaser.Tilemaps.Tilemap#addTilesetImage + * @since 3.0.0 + * + * @param {string} tilesetName - The name of the tileset as specified in the map data. + * @param {string} [key] - The key of the Phaser.Cache image used for this tileset. If + * `undefined` or `null` it will look for an image with a key matching the tileset parameter. + * @param {integer} [tileWidth] - The width of the tile (in pixels) in the Tileset Image. If not + * given it will default to the map's tileWidth value, or the tileWidth specified in the Tiled + * JSON file. + * @param {integer} [tileHeight] - The height of the tiles (in pixels) in the Tileset Image. If + * not given it will default to the map's tileHeight value, or the tileHeight specified in the + * Tiled JSON file. + * @param {integer} [tileMargin] - The margin around the tiles in the sheet (in pixels). If not + * specified, it will default to 0 or the value specified in the Tiled JSON file. + * @param {integer} [tileSpacing] - The spacing between each the tile in the sheet (in pixels). + * If not specified, it will default to 0 or the value specified in the Tiled JSON file. + * @param {integer} [gid=0] - If adding multiple tilesets to a blank map, specify the starting + * GID this set will use here. + * + * @return {?Phaser.Tilemaps.Tileset} Returns the Tileset object that was created or updated, or null if it + * failed. + */ + addTilesetImage: function (tilesetName, key, tileWidth, tileHeight, tileMargin, tileSpacing, gid) + { + if (tilesetName === undefined) { return null; } + if (key === undefined || key === null) { key = tilesetName; } + + if (!this.scene.sys.textures.exists(key)) + { + console.warn('Invalid image key given for tileset: "' + key + '"'); + return null; + } + + var texture = this.scene.sys.textures.get(key); + + var index = this.getTilesetIndex(tilesetName); + + if (index === null && this.format === Formats.TILED_JSON) + { + console.warn('No data found in the JSON tilemap from Tiled matching the tileset name: "' + tilesetName + '"'); + return null; + } + + if (this.tilesets[index]) + { + this.tilesets[index].setTileSize(tileWidth, tileHeight); + this.tilesets[index].setSpacing(tileMargin, tileSpacing); + this.tilesets[index].setImage(texture); + return this.tilesets[index]; + } + + if (tileWidth === undefined) { tileWidth = this.tileWidth; } + if (tileHeight === undefined) { tileHeight = this.tileHeight; } + if (tileMargin === undefined) { tileMargin = 0; } + if (tileSpacing === undefined) { tileSpacing = 0; } + if (gid === undefined) { gid = 0; } + + var tileset = new Tileset(tilesetName, gid, tileWidth, tileHeight, tileMargin, tileSpacing); + tileset.setImage(texture); + this.tilesets.push(tileset); + + return tileset; + }, + + /** + * Turns the StaticTilemapLayer associated with the given layer into a DynamicTilemapLayer. If + * no layer specified, the map's current layer is used. This is useful if you want to manipulate + * a map at the start of a scene, but then make it non-manipulable and optimize it for speed. + * Note: the DynamicTilemapLayer passed in is destroyed, so make sure to store the value + * returned from this method if you want to manipulate the new StaticTilemapLayer. + * + * @method Phaser.Tilemaps.Tilemap#convertLayerToStatic + * @since 3.0.0 + * + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer)} [layer] - The name of the layer from Tiled, the + * index of the layer in the map, or a DynamicTilemapLayer. + * + * @return {?Phaser.Tilemaps.StaticTilemapLayer} Returns the new layer that was created, or null if it + * failed. + */ + convertLayerToStatic: function (layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + var dynamicLayer = layer.tilemapLayer; + + if (!dynamicLayer || !(dynamicLayer instanceof DynamicTilemapLayer)) + { + return null; + } + + var staticLayer = new StaticTilemapLayer( + dynamicLayer.scene, + dynamicLayer.tilemap, + dynamicLayer.layerIndex, + dynamicLayer.tileset, + dynamicLayer.x, + dynamicLayer.y + ); + + this.scene.sys.displayList.add(staticLayer); + + dynamicLayer.destroy(); + + return staticLayer; + }, + + /** + * See component documentation. If no layer specified, the map's current layer is used. This + * cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#copy + * @since 3.0.0 + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'copy')) { return this; } + + if (layer !== null) + { + TilemapComponents.Copy( + srcTileX, srcTileY, + width, height, + destTileX, destTileY, + recalculateFaces, layer + ); + } + + return this; + }, + + /** + * Creates a new and empty DynamicTilemapLayer. The currently selected layer in the map is set + * to this new layer. + * + * @method Phaser.Tilemaps.Tilemap#createBlankDynamicLayer + * @since 3.0.0 + * + * @param {string} name - The name of this layer. Must be unique within the map. + * @param {Phaser.Tilemaps.Tileset} tileset - The tileset the new layer will use. + * @param {integer} width - The width of the layer in tiles. If not specified, it will default + * to the map's width. + * @param {integer} height - The height of the layer in tiles. If not specified, it will default + * to the map's height. + * @param {integer} tileWidth - The width of the tiles the layer uses for calculations. If not + * specified, it will default to the map's tileWidth. + * @param {integer} tileHeight - The height of the tiles the layer uses for calculations. If not + * specified, it will default to the map's tileHeight. + * @return {?Phaser.Tilemaps.DynamicTilemapLayer} Returns the new layer was created, or null if it failed. + */ + createBlankDynamicLayer: function (name, tileset, x, y, width, height, tileWidth, tileHeight) + { + if (tileWidth === undefined) { tileWidth = tileset.tileWidth; } + if (tileHeight === undefined) { tileHeight = tileset.tileHeight; } + if (width === undefined) { width = this.width; } + if (height === undefined) { height = this.height; } + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + var index = this.getLayerIndex(name); + + if (index !== null) + { + console.warn('Cannot create blank layer: layer with matching name already exists ' + name); + return null; + } + + var layerData = new LayerData({ + name: name, + tileWidth: tileWidth, + tileHeight: tileHeight, + width: width, + height: height + }); + + var row; + + for (var tileY = 0; tileY < height; tileY++) + { + row = []; + + for (var tileX = 0; tileX < width; tileX++) + { + row.push(new Tile(layerData, -1, tileX, tileY, tileWidth, tileHeight, this.tileWidth, this.tileHeight)); + } + + layerData.data.push(row); + } + + this.layers.push(layerData); + this.currentLayerIndex = this.layers.length - 1; + + var dynamicLayer = new DynamicTilemapLayer(this.scene, this, this.currentLayerIndex, tileset, x, y); + this.scene.sys.displayList.add(dynamicLayer); + + return dynamicLayer; + }, + + /** + * Creates a new DynamicTilemapLayer that renders the LayerData associated with the given + * `layerID`. The currently selected layer in the map is set to this new layer. + * + * The `layerID` is important. If you've created your map in Tiled then you can get this by + * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and + * look at the layers[].name value. Either way it must match. + * + * Unlike a static layer, a dynamic layer can be modified. See DynamicTilemapLayer for more + * information. + * + * @method Phaser.Tilemaps.Tilemap#createDynamicLayer + * @since 3.0.0 + * + * @param {(integer|string)} layerID - The layer array index value, or if a string is given, the + * layer name from Tiled. + * @param {Phaser.Tilemaps.Tileset} tileset - The tileset the new layer will use. + * @param {number} x - The x position to place the layer in the world. If not specified, it will + * default to the layer offset from Tiled or 0. + * @param {number} y - The y position to place the layer in the world. If not specified, it will + * default to the layer offset from Tiled or 0. + * + * @return {?Phaser.Tilemaps.DynamicTilemapLayer} Returns the new layer was created, or null if it failed. + */ + createDynamicLayer: function (layerID, tileset, x, y) + { + var index = this.getLayerIndex(layerID); + + if (index === null) + { + console.warn('Cannot create tilemap layer, invalid layer ID given: ' + layerID); + return null; + } + + var layerData = this.layers[index]; + + // Check for an associated static or dynamic tilemap layer + if (layerData.tilemapLayer) + { + console.warn('Cannot create dynamic tilemap layer since a static or dynamic tilemap layer exists for layer ID:' + layerID); + return null; + } + + this.currentLayerIndex = index; + + // Make sure that all the LayerData & the tiles have the correct tile size. They usually + // are, but wouldn't match if you try to load a 2x or 4x res tileset when the map was made + // with a 1x res tileset. + if (layerData.tileWidth !== tileset.tileWidth || layerData.tileHeight !== tileset.tileHeight) + { + this.setLayerTileSize(tileset.tileWidth, tileset.tileHeight, index); + } + + // Default the x/y position to match Tiled layer offset, if it exists. + if (x === undefined && this.layers[index].x) { x = this.layers[index].x; } + if (y === undefined && this.layers[index].y) { y = this.layers[index].y; } + + var layer = new DynamicTilemapLayer(this.scene, this, index, tileset, x, y); + this.scene.sys.displayList.add(layer); + + return layer; + }, + + /** + * Creates a Sprite for every object matching the given gid in the map data. All properties from + * the map data objectgroup are copied into the `spriteConfig`, so you can use this as an easy + * way to configure Sprite properties from within the map editor. For example giving an object a + * property of alpha: 0.5 in the map editor will duplicate that when the Sprite is created. + * + * @method Phaser.Tilemaps.Tilemap#createFromObjects + * @since 3.0.0 + * + * @param {string} name - The name of the object layer (from Tiled) to create Sprites from. + * @param {(integer|string)} id - Either the id (object), gid (tile object) or name (object or + * tile object) from Tiled. Ids are unique in Tiled, but a gid is shared by all tile objects + * with the same graphic. The same name can be used on multiple objects. + * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. + * scene.make.sprite). + * @param {Phaser.Scene} [scene=the scene the map is within] - The Scene to create the Sprites within. + * + * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. + */ + createFromObjects: function (name, id, spriteConfig, scene) + { + if (spriteConfig === undefined) { spriteConfig = {}; } + if (scene === undefined) { scene = this.scene; } + + var objectLayer = this.getObjectLayer(name); + if (!objectLayer) + { + console.warn('Cannot create from object. Invalid objectgroup name given: ' + name); + return; + } + + var objects = objectLayer.objects; + var sprites = []; + + for (var i = 0; i < objects.length; i++) + { + var found = false; + var obj = objects[i]; + + if (obj.gid !== undefined && typeof id === 'number' && obj.gid === id || + obj.id !== undefined && typeof id === 'number' && obj.id === id || + obj.name !== undefined && typeof id === 'string' && obj.name === id) + { + found = true; + } + + if (found) + { + var config = Extend({}, spriteConfig, obj.properties); + + config.x = obj.x; + config.y = obj.y; + + var sprite = this.scene.make.sprite(config); + + sprite.name = obj.name; + + if (obj.width) { sprite.displayWidth = obj.width; } + if (obj.height) { sprite.displayHeight = obj.height; } + + // Origin is (0, 1) in Tiled, so find the offset that matches the Sprite's origin. + var offset = { + x: sprite.originX * sprite.displayWidth, + y: (sprite.originY - 1) * sprite.displayHeight + }; + + // If the object is rotated, then the origin offset also needs to be rotated. + if (obj.rotation) + { + var angle = DegToRad(obj.rotation); + Rotate(offset, angle); + sprite.rotation = angle; + } + + sprite.x += offset.x; + sprite.y += offset.y; + + if (obj.flippedHorizontal !== undefined || obj.flippedVertical !== undefined) + { + sprite.setFlip(obj.flippedHorizontal, obj.flippedVertical); + } + + if (!obj.visible) { sprite.visible = false; } + + sprites.push(sprite); + } + } + + return sprites; + }, + + /** + * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. + * + * @method Phaser.Tilemaps.Tilemap#createFromTiles + * @since 3.0.0 + * + * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. + * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted + * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a + * one-to-one mapping with the indexes array. + * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. + * scene.make.sprite). + * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.GameObjects.Sprite[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + createFromTiles: function (indexes, replacements, spriteConfig, scene, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, layer); + }, + + /** + * Creates a new StaticTilemapLayer that renders the LayerData associated with the given + * `layerID`. The currently selected layer in the map is set to this new layer. + * + * The `layerID` is important. If you've created your map in Tiled then you can get this by + * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and + * look at the layers[].name value. Either way it must match. + * + * It's important to remember that a static layer cannot be modified. See StaticTilemapLayer for + * more information. + * + * @method Phaser.Tilemaps.Tilemap#createStaticLayer + * @since 3.0.0 + * + * @param {(integer|string)} layerID - The layer array index value, or if a string is given, the + * layer name from Tiled. + * @param {Phaser.Tilemaps.Tileset} tileset - The tileset the new layer will use. + * @param {number} x - The x position to place the layer in the world. If not specified, it will + * default to the layer offset from Tiled or 0. + * @param {number} y - The y position to place the layer in the world. If not specified, it will + * default to the layer offset from Tiled or 0. + * + * @return {?Phaser.Tilemaps.StaticTilemapLayer} Returns the new layer was created, or null if it failed. + */ + createStaticLayer: function (layerID, tileset, x, y) + { + var index = this.getLayerIndex(layerID); + + if (index === null) + { + console.warn('Cannot create tilemap layer, invalid layer ID given: ' + layerID); + return null; + } + + var layerData = this.layers[index]; + + // Check for an associated static or dynamic tilemap layer + if (layerData.tilemapLayer) + { + console.warn('Cannot create static tilemap layer since a static or dynamic tilemap layer exists for layer ID:' + layerID); + return null; + } + + this.currentLayerIndex = index; + + // Make sure that all the LayerData & the tiles have the correct tile size. They usually + // are, but wouldn't match if you try to load a 2x or 4x res tileset when the map was made + // with a 1x res tileset. + if (layerData.tileWidth !== tileset.tileWidth || layerData.tileHeight !== tileset.tileHeight) + { + this.setLayerTileSize(tileset.tileWidth, tileset.tileHeight, index); + } + + // Default the x/y position to match Tiled layer offset, if it exists. + if (x === undefined && this.layers[index].x) { x = this.layers[index].x; } + if (y === undefined && this.layers[index].y) { y = this.layers[index].y; } + + var layer = new StaticTilemapLayer(this.scene, this, index, tileset, x, y); + this.scene.sys.displayList.add(layer); + + return layer; + }, + + /** + * Removes all layer data from this Tilemap and nulls the scene reference. This will destroy any + * StaticTilemapLayers or DynamicTilemapLayers that have been linked to LayerData. + * + * @method Phaser.Tilemaps.Tilemap#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.removeAllLayers(); + this.tilesets.length = 0; + this.objects.length = 0; + this.scene = undefined; + }, + + /** + * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the + * specified index. Tiles will be set to collide if the given index is a colliding index. + * Collision information in the region will be recalculated. + * + * If no layer specified, the map's current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#fill + * @since 3.0.0 + * + * @param {integer} index - [description] + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + fill: function (index, tileX, tileY, width, height, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'fill')) { return this; } + + if (layer !== null) + { + TilemapComponents.Fill(index, tileX, tileY, width, height, recalculateFaces, layer); + } + + return this; + }, + + /** + * For each object in the given object layer, run the given filter callback function. Any + * objects that pass the filter test (i.e. where the callback returns true) will returned as a + * new array. Similar to Array.prototype.Filter in vanilla JS. + * + * @method Phaser.Tilemaps.Tilemap#filterObjects + * @since 3.0.0 + * + * @param {(Phaser.Tilemaps.ObjectLayer|string)} [objectLayer] - The name of an object layer (from Tiled) or an + * ObjectLayer instance. + * @param {TilemapFilterCallback} callback - The callback. Each object in the given area will be passed to + * this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * + * @return {?Phaser.GameObjects.GameObject[]} An array of object that match the search, or null if the objectLayer + * given was invalid. + */ + filterObjects: function (objectLayer, callback, context) + { + if (typeof objectLayer === 'string') + { + var name = objectLayer; + + objectLayer = this.getObjectLayer(objectLayer); + + if (!objectLayer) + { + console.warn('No object layer found with the name: ' + name); + return null; + } + } + + return objectLayer.objects.filter(callback, context); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#filterTiles + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, layer); + }, + + /** + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#findByIndex + * @since 3.0.0 + * + * @param {integer} index - The tile index value to search for. + * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. + * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the + * bottom-right. Otherwise it scans from the top-left. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tiles, or null if the layer given was invalid. + */ + findByIndex: function (findIndex, skip, reverse, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.FindByIndex(findIndex, skip, reverse, layer); + }, + + /** + * Find the first object in the given object layer that satisfies the provided testing function. + * I.e. finds the first object for which `callback` returns true. Similar to + * Array.prototype.find in vanilla JS. + * + * @method Phaser.Tilemaps.Tilemap#findObject + * @since 3.0.0 + * + * @param {(Phaser.Tilemaps.ObjectLayer|string)} [objectLayer] - The name of an object layer (from Tiled) or an + * ObjectLayer instance. + * @param {TilemapFindCallback} callback - The callback. Each object in the given area will be passed to + * this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * + * @return {?Phaser.GameObjects.GameObject} An object that matches the search, or null if no object found + */ + findObject: function (objectLayer, callback, context) + { + if (typeof objectLayer === 'string') + { + var name = objectLayer; + + objectLayer = this.getObjectLayer(objectLayer); + + if (!objectLayer) + { + console.warn('No object layer found with the name: ' + name); + return null; + } + } + + return objectLayer.objects.find(callback, context) || null; + }, + + /** + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#findTile + * @since 3.0.0 + * + * @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tiles, or null if the layer given was invalid. + */ + findTile: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, layer); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#forEachTile + * @since 3.0.0 + * + * @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) + { + layer = this.getLayer(layer); + + if (layer !== null) + { + TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, layer); + } + + return this; + }, + + /** + * Gets the image layer index based on its name. + * + * @method Phaser.Tilemaps.Tilemap#getImageIndex + * @since 3.0.0 + * + * @param {string} name - The name of the image to get. + * + * @return {integer} The index of the image in this tilemap, or null if not found. + */ + getImageIndex: function (name) + { + return this.getIndex(this.images, name); + }, + + /** + * Internally used. Returns the index of the object in one of the Tilemaps arrays whose name + * property matches the given `name`. + * + * @method Phaser.Tilemaps.Tilemap#getIndex + * @since 3.0.0 + * + * @param {array} location - The Tilemap array to search. + * @param {string} name - The name of the array element to get. + * + * @return {number} The index of the element in the array, or null if not found. + */ + getIndex: function (location, name) + { + for (var i = 0; i < location.length; i++) + { + if (location[i].name === name) + { + return i; + } + } + + return null; + }, + + /** + * Gets the LayerData from this.layers that is associated with `layer`, or null if an invalid + * `layer` is given. + * + * @method Phaser.Tilemaps.Tilemap#getLayer + * @since 3.0.0 + * + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the maps current layer index. + * + * @return {Phaser.Tilemaps.LayerData} The corresponding LayerData within this.layers. + */ + getLayer: function (layer) + { + var index = this.getLayerIndex(layer); + + return index !== null ? this.layers[index] : null; + }, + + /** + * Gets the ObjectLayer from this.objects that has the given `name`, or null if no ObjectLayer + * is found with that name. + * + * @method Phaser.Tilemaps.Tilemap#getObjectLayer + * @since 3.0.0 + * + * @param {string} [name] - The name of the object layer from Tiled. + * + * @return {?Phaser.Tilemaps.ObjectLayer} The corresponding ObjectLayer within this.objects or null. + */ + getObjectLayer: function (name) + { + var index = this.getIndex(this.objects, name); + + return index !== null ? this.objects[index] : null; + }, + + /** + * Gets the LayerData index of the given `layer` within this.layers, or null if an invalid + * `layer` is given. + * + * @method Phaser.Tilemaps.Tilemap#getLayerIndex + * @since 3.0.0 + * + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the map's current layer index. + * + * @return {integer} The LayerData index within this.layers. + */ + getLayerIndex: function (layer) + { + if (layer === undefined) + { + return this.currentLayerIndex; + } + else if (typeof layer === 'string') + { + return this.getLayerIndexByName(layer); + } + else if (typeof layer === 'number' && layer < this.layers.length) + { + return layer; + } + else if (layer instanceof StaticTilemapLayer || layer instanceof DynamicTilemapLayer) + { + return layer.layerIndex; + } + else + { + return null; + } + }, + + /** + * Gets the index of the LayerData within this.layers that has the given `name`, or null if an + * invalid `name` is given. + * + * @method Phaser.Tilemaps.Tilemap#getLayerIndexByName + * @since 3.0.0 + * + * @param {string} name - The name of the layer to get. + * + * @return {integer} The LayerData index within this.layers. + */ + getLayerIndexByName: function (name) + { + return this.getIndex(this.layers, name); + }, + + /** + * Gets a tile at the given tile coordinates from the given layer. + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTileAt + * @since 3.0.0 + * + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). + * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile + * object with an index of -1. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + getTileAt: function (tileX, tileY, nonNull, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.GetTileAt(tileX, tileY, nonNull, layer); + }, + + /** + * Gets a tile at the given world coordinates from the given layer. + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - X position to get the tile from (given in pixels) + * @param {number} worldY - Y position to get the tile from (given in pixels) + * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile + * object with an index of -1. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + getTileAtWorldXY: function (worldX, worldY, nonNull, camera, layer) + { + layer = this.getLayer(layer); + + + if (layer === null) { return null; } + + return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, layer); + }, + + /** + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTilesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + getTilesWithin: function (tileX, tileY, width, height, filteringOptions, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); + }, + + /** + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTilesWithinShape + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + getTilesWithinShape: function (shape, filteringOptions, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, layer); + }, + + /** + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTilesWithinWorldXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, layer); + }, + + /** + * Gets the index of the Tileset within this.tilesets that has the given `name`, or null if an + * invalid `name` is given. + * + * @method Phaser.Tilemaps.Tilemap#getTilesetIndex + * @since 3.0.0 + * + * @param {string} name - The name of the Tileset to get. + * + * @return {integer} The Tileset index within this.tilesets. + */ + getTilesetIndex: function (name) + { + return this.getIndex(this.tilesets, name); + }, + + /** + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#hasTileAt + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?boolean} Returns a boolean, or null if the layer given was invalid. + */ + hasTileAt: function (tileX, tileY, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.HasTileAt(tileX, tileY, layer); + }, + + /** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#hasTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?boolean} Returns a boolean, or null if the layer given was invalid. + */ + hasTileAtWorldXY: function (worldX, worldY, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, layer); + }, + + /** + * The LayerData object that is currently selected in the map. You can set this property using + * any type supported by setLayer. + * + * @name Phaser.Tilemaps.Tilemap#layer + * @type {Phaser.Tilemaps.LayerData} + * @since 3.0.0 + */ + layer: { + get: function () + { + return this.layers[this.currentLayerIndex]; + }, + + set: function (layer) + { + this.setLayer(layer); + } + }, + + /** + * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index + * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified + * location. If you pass in an index, only the index at the specified location will be changed. + * Collision information will be recalculated at the specified location. + * + * If no layer specified, the maps current layer is used. + * + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#putTileAt + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + putTileAt: function (tile, tileX, tileY, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'putTileAt')) { return null; } + + if (layer === null) { return null; } + + return TilemapComponents.PutTileAt(tile, tileX, tileY, recalculateFaces, layer); + }, + + /** + * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either + * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the + * specified location. If you pass in an index, only the index at the specified location will be + * changed. Collision information will be recalculated at the specified location. + * + * If no layer specified, the maps current layer is used. This + * cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#putTileAtWorldXY + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} worldX - [description] + * @param {integer} worldY - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + putTileAtWorldXY: function (tile, worldX, worldY, recalculateFaces, camera, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'putTileAtWorldXY')) { return null; } + + if (layer === null) { return null; } + + return TilemapComponents.PutTileAtWorldXY(tile, worldX, worldY, recalculateFaces, camera, layer); + }, + + /** + * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified + * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, + * all attributes will be copied over to the specified location. If you pass in an index, only the + * index at the specified location will be changed. Collision information will be recalculated + * within the region tiles were changed. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#putTilesAt + * @since 3.0.0 + * + * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles + * or tile indexes to place. + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + putTilesAt: function (tilesArray, tileX, tileY, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'putTilesAt')) { return this; } + + if (layer !== null) + { + TilemapComponents.PutTilesAt(tilesArray, tileX, tileY, recalculateFaces, layer); + } + + return this; + }, + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will recieve a new index. If an array of indexes is passed in, then + * those will be used for randomly assigning new tile indexes. If an array is not provided, the + * indexes found within the region (excluding -1) will be used for randomly assigning new tile + * indexes. This method only modifies tile indexes and does not change collision information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#randomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + randomize: function (tileX, tileY, width, height, indexes, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'randomize')) { return this; } + + if (layer !== null) + { + TilemapComponents.Randomize(tileX, tileY, width, height, indexes, layer); + } + + return this; + }, + + /** + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#calculateFacesAt + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + calculateFacesAt: function (tileX, tileY, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.CalculateFacesAt(tileX, tileY, layer); + + return this; + }, + + /** + * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the + * layer. Interesting faces are used internally for optimizing collisions against tiles. This method + * is mostly used internally. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#calculateFacesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + calculateFacesWithin: function (tileX, tileY, width, height, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, layer); + + return this; + }, + + /** + * Removes all layers from this Tilemap and destroys any associated StaticTilemapLayers or + * DynamicTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#removeAllLayers + * @since 3.0.0 + * + * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. + */ + removeAllLayers: function () + { + // Destroy any StaticTilemapLayers or DynamicTilemapLayers that are stored in LayerData + for (var i = 0; i < this.layers.length; i++) + { + if (this.layers[i].tilemapLayer) + { + this.layers[i].tilemapLayer.destroy(); + } + } + + this.layers.length = 0; + this.currentLayerIndex = 0; + + return this; + }, + + /** + * Removes the tile at the given tile coordinates in the specified layer and updates the layer's + * collision information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#removeTileAt + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified + * location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + removeTileAt: function (tileX, tileY, replaceWithNull, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'removeTileAt')) { return null; } + + if (layer === null) { return null; } + + return TilemapComponents.RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, layer); + }, + + /** + * Removes the tile at the given world coordinates in the specified layer and updates the layer's + * collision information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#removeTileAtWorldXY + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified + * location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + removeTileAtWorldXY: function (worldX, worldY, replaceWithNull, recalculateFaces, camera, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'removeTileAtWorldXY')) { return null; } + + if (layer === null) { return null; } + + return TilemapComponents.RemoveTileAtWorldXY(worldX, worldY, replaceWithNull, recalculateFaces, camera, layer); + }, + + /** + * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#renderDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. + * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. + * @param {?Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at + * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. + * @param {?Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled + * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. + * @param {?Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting + * tile faces. If set to null, interesting tile faces will not be drawn. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + renderDebug: function (graphics, styleConfig, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.RenderDebug(graphics, styleConfig, layer); + + return this; + }, + + /** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does + * not change collision information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#replaceByIndex + * @since 3.0.0 + * + * @param {integer} findIndex - [description] + * @param {integer} newIndex - [description] + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + replaceByIndex: function (findIndex, newIndex, tileX, tileY, width, height, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'replaceByIndex')) { return this; } + + if (layer !== null) + { + TilemapComponents.ReplaceByIndex(findIndex, newIndex, tileX, tileY, width, height, layer); + } + + return this; + }, + + /** + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollision + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollision: function (indexes, collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollision(indexes, collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollisionBetween + * @since 3.0.0 + * + * @param {integer} start - The first index of the tile to be set for collision. + * @param {integer} stop - The last index of the tile to be set for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollisionBetween: function (start, stop, collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollisionByProperty + * @since 3.0.0 + * + * @param {object} properties - An object with tile properties and corresponding values that should + * be checked. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollisionByProperty: function (properties, collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollisionByExclusion + * @since 3.0.0 + * + * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollisionByExclusion: function (indexes, collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking each tile's collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tile's collision group, the tile's colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollisionFromCollisionGroup + * @since 3.0.0 + * + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollisionFromCollisionGroup: function (collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see setTileLocationCallback. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setTileIndexCallback + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a + * collision callback set for. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setTileIndexCallback: function (indexes, callback, callbackContext, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, layer); + + return this; + }, + + /** + * Sets a collision callback for the given rectangular area (in tile coordindates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setTileLocationCallback + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, layer); + + return this; + }, + + /** + * Sets the current layer to the LayerData associated with `layer`. + * + * @method Phaser.Tilemaps.Tilemap#setLayer + * @since 3.0.0 + * + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the map's current layer index. + * + * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. + */ + setLayer: function (layer) + { + var index = this.getLayerIndex(layer); + + if (index !== null) + { + this.currentLayerIndex = index; + } + + return this; + }, + + /** + * Sets the base tile size for the map. Note: this does not necessarily match the tileWidth and + * tileHeight for all layers. This also updates the base size on all tiles across all layers. + * + * @method Phaser.Tilemaps.Tilemap#setBaseTileSize + * @since 3.0.0 + * + * @param {integer} tileWidth - The width of the tiles the map uses for calculations. + * @param {integer} tileHeight - The height of the tiles the map uses for calculations. + * + * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. + */ + setBaseTileSize: function (tileWidth, tileHeight) + { + this.tileWidth = tileWidth; + this.tileHeight = tileHeight; + this.widthInPixels = this.width * tileWidth; + this.heightInPixels = this.height * tileHeight; + + // Update the base tile size on all layers & tiles + for (var i = 0; i < this.layers.length; i++) + { + this.layers[i].baseWidth = tileWidth; + this.layers[i].baseHeight = tileHeight; + + var mapData = this.layers[i].data; + var mapWidth = this.layers[i].width; + var mapHeight = this.layers[i].height; + + for (var row = 0; row < mapHeight; ++row) + { + for (var col = 0; col < mapWidth; ++col) + { + var tile = mapData[row][col]; + + if (tile !== null) + { + tile.setSize(undefined, undefined, tileWidth, tileHeight); + } + } + } + } + + return this; + }, + + /** + * Sets the tile size for a specific `layer`. Note: this does not necessarily match the map's + * tileWidth and tileHeight for all layers. This will set the tile size for the layer and any + * tiles the layer has. + * + * @method Phaser.Tilemaps.Tilemap#setLayerTileSize + * @since 3.0.0 + * + * @param {integer} tileWidth - The width of the tiles (in pixels) in the layer. + * @param {integer} tileHeight - The height of the tiles (in pixels) in the layer. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the map's current layer index. + * + * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. + */ + setLayerTileSize: function (tileWidth, tileHeight, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + layer.tileWidth = tileWidth; + layer.tileHeight = tileHeight; + + var mapData = layer.data; + var mapWidth = layer.width; + var mapHeight = layer.height; + + for (var row = 0; row < mapHeight; ++row) + { + for (var col = 0; col < mapWidth; ++col) + { + var tile = mapData[row][col]; + + if (tile !== null) { tile.setSize(tileWidth, tileHeight); } + } + } + + return this; + }, + + /** + * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given + * layer. It will only randomize the tiles in that area, so if they're all the same nothing will + * appear to have changed! This method only modifies tile indexes and does not change collision + * information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#shuffle + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + shuffle: function (tileX, tileY, width, height, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'shuffle')) { return this; } + + if (layer !== null) + { + TilemapComponents.Shuffle(tileX, tileY, width, height, layer); + } + + return this; + }, + + /** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision + * information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#swapByIndex + * @since 3.0.0 + * + * @param {integer} tileA - First tile index. + * @param {integer} tileB - Second tile index. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + swapByIndex: function (indexA, indexB, tileX, tileY, width, height, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'swapByIndex')) { return this; } + + if (layer !== null) + { + TilemapComponents.SwapByIndex(indexA, indexB, tileX, tileY, width, height, layer); + } + + return this; + }, + + /** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#tileToWorldX + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?number} Returns a number, or null if the layer given was invalid. + */ + tileToWorldX: function (tileX, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.TileToWorldX(tileX, camera, layer); + }, + + /** + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#tileToWorldY + * @since 3.0.0 + * + * @param {integer} tileY - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?number} Returns a number, or null if the layer given was invalid. + */ + tileToWorldY: function (tileX, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.TileToWorldY(tileX, camera, layer); + }, + + /** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#tileToWorldXY + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {Phaser.Math.Vector2} [point] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Math.Vector2} Returns a point, or null if the layer given was invalid. + */ + tileToWorldXY: function (tileX, tileY, point, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, layer); + }, + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. New indexes are drawn from the given + * weightedIndexes array. An example weighted array: + * + * [ + * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 + * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 + * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 + * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 + * ] + * + * The probability of any index being choose is (the index's weight) / (sum of all weights). This + * method only modifies tile indexes and does not change collision information. + * + * If no layer specified, the map's current layer is used. This + * cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#weightedRandomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during + * randomization. They should be in the form: { index: 0, weight: 4 } or + * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + weightedRandomize: function (tileX, tileY, width, height, weightedIndexes, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'weightedRandomize')) { return this; } + + if (layer !== null) + { + TilemapComponents.WeightedRandomize(tileX, tileY, width, height, weightedIndexes, layer); + } + + return this; + }, + + /** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#worldToTileX + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?number} Returns a number, or null if the layer given was invalid. + */ + worldToTileX: function (worldX, snapToFloor, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, layer); + }, + + /** + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#worldToTileY + * @since 3.0.0 + * + * @param {number} worldY - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?number} Returns a number, or null if the layer given was invalid. + */ + worldToTileY: function (worldY, snapToFloor, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, layer); + }, + + /** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#worldToTileXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Math.Vector2} [point] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - [description] + * + * @return {?Phaser.Math.Vector2} Returns a point, or null if the layer given was invalid. + */ + worldToTileXY: function (worldX, worldY, snapToFloor, point, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, layer); + }, + + /** + * Used internally to check if a layer is static and prints out a warning. + * + * @method Phaser.Tilemaps.Tilemap#_isStaticCall + * @private + * @since 3.0.0 + * + * @return {boolean} + */ + _isStaticCall: function (layer, functionName) + { + if (layer.tilemapLayer instanceof StaticTilemapLayer) + { + console.warn(functionName + ': You cannot change the tiles in a static tilemap layer'); + return true; + } + else + { + return false; + } + } + +}); + +module.exports = Tilemap; /***/ }), @@ -39692,51 +46296,66 @@ module.exports = Circumference; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetPoint = __webpack_require__(107); -var Perimeter = __webpack_require__(78); - -// Return an array of points from the perimeter of the rectangle -// each spaced out based on the quantity or step required +var Formats = __webpack_require__(24); +var MapData = __webpack_require__(65); +var ParseTileLayers = __webpack_require__(416); +var ParseTilesets = __webpack_require__(415); /** - * [description] + * Parses a Weltmeister JSON object into a new MapData object. * - * @function Phaser.Geom.Rectangle.GetPoints + * @function Phaser.Tilemaps.Parsers.Impact.ParseWeltmeister * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rectangle - [description] - * @param {number} step - [description] - * @param {integer} quantity - [description] - * @param {array} [out] - [description] + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {object} json - The Weltmeister JSON object. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. * - * @return {Phaser.Geom.Point[]} [description] + * @return {?object} [description] */ -var GetPoints = function (rectangle, quantity, stepRate, out) +var ParseWeltmeister = function (name, json, insertNull) { - if (out === undefined) { out = []; } - - // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. - if (!quantity) + if (json.layer.length === 0) { - quantity = Perimeter(rectangle) / stepRate; + console.warn('No layers found in the Weltmeister map: ' + name); + return null; } - for (var i = 0; i < quantity; i++) - { - var position = i / quantity; + var width = 0; + var height = 0; - out.push(GetPoint(rectangle, position)); + for (var i = 0; i < json.layer.length; i++) + { + if (json.layer[i].width > width) { width = json.layer[i].width; } + if (json.layer[i].height > height) { height = json.layer[i].height; } } - return out; + var mapData = new MapData({ + width: width, + height: height, + name: name, + tileWidth: json.layer[0].tilesize, + tileHeight: json.layer[0].tilesize, + format: Formats.WELTMEISTER + }); + + mapData.layers = ParseTileLayers(json, insertNull); + mapData.tilesets = ParseTilesets(json); + + return mapData; }; -module.exports = GetPoints; +module.exports = ParseWeltmeister; /***/ }), /* 188 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -39744,39 +46363,105 @@ module.exports = GetPoints; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(2); + /** - * [description] + * @classdesc + * A class for representing a Tiled object layer in a map. This mirrors the structure of a Tiled + * object layer, except: + * - "x" & "y" properties are ignored since these cannot be changed in Tiled. + * - "offsetx" & "offsety" are applied to the individual object coordinates directly, so they + * are ignored as well. + * - "draworder" is ignored. * - * @function Phaser.Math.RotateAround + * @class ObjectLayer + * @memberOf Phaser.Tilemaps + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Point|object} point - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Point} [description] + * @param {object} [config] - [description] */ -var RotateAround = function (point, x, y, angle) -{ - var c = Math.cos(angle); - var s = Math.sin(angle); +var ObjectLayer = new Class({ - var tx = point.x - x; - var ty = point.y - y; + initialize: - point.x = tx * c - ty * s + x; - point.y = tx * s + ty * c + y; + function ObjectLayer (config) + { + if (config === undefined) { config = {}; } - return point; -}; + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#name + * @type {string} + * @since 3.0.0 + */ + this.name = GetFastValue(config, 'name', 'object layer'); -module.exports = RotateAround; + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#opacity + * @type {number} + * @since 3.0.0 + */ + this.opacity = GetFastValue(config, 'opacity', 1); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#properties + * @type {object} + * @since 3.0.0 + */ + this.properties = GetFastValue(config, 'properties', {}); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#propertyTypes + * @type {object} + * @since 3.0.0 + */ + this.propertyTypes = GetFastValue(config, 'propertytypes', {}); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#type + * @type {string} + * @since 3.0.0 + */ + this.type = GetFastValue(config, 'type', 'objectgroup'); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#visible + * @type {boolean} + * @since 3.0.0 + */ + this.visible = GetFastValue(config, 'visible', true); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#objects + * @type {Phaser.GameObjects.GameObject[]} + * @since 3.0.0 + */ + this.objects = GetFastValue(config, 'objects', []); + } + +}); + +module.exports = ObjectLayer; /***/ }), /* 189 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -39784,123 +46469,76 @@ module.exports = RotateAround; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Pick = __webpack_require__(420); +var ParseGID = __webpack_require__(191); + +var copyPoints = function (p) { return { x: p.x, y: p.y }; }; + +var commonObjectProps = [ 'id', 'name', 'type', 'rotation', 'properties', 'visible', 'x', 'y', 'width', 'height' ]; + /** - * Provides methods used for setting the WebGL rendering pipeline of a Game Object. - * - * @name Phaser.GameObjects.Components.Pipeline - * @webglOnly + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseObject * @since 3.0.0 + * + * @param {object} tiledObject - [description] + * @param {number} [offsetX=0] - [description] + * @param {number} [offsetY=0] - [description] + * + * @return {object} [description] */ +var ParseObject = function (tiledObject, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } -var Pipeline = { - - /** - * [description] - * - * @name Phaser.GameObjects.Components.Pipeline#defaultPipeline - * @type {Phaser.Renderer.WebGL.WebGLPipeline} - * @default null - * @webglOnly - * @since 3.0.0 - */ - defaultPipeline: null, + var parsedObject = Pick(tiledObject, commonObjectProps); - /** - * [description] - * - * @name Phaser.GameObjects.Components.Pipeline#pipeline - * @type {Phaser.Renderer.WebGL.WebGLPipeline} - * @default null - * @webglOnly - * @since 3.0.0 - */ - pipeline: null, + parsedObject.x += offsetX; + parsedObject.y += offsetY; - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * - * @method Phaser.GameObjects.Components.Pipeline#initPipeline - * @webglOnly - * @since 3.0.0 - * - * @param {string} pipelineName - The name of the pipeline to set on this Game Object. - * - * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. - */ - initPipeline: function (pipelineName) + if (tiledObject.gid) { - var renderer = this.scene.sys.game.renderer; - - if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) - { - this.defaultPipeline = renderer.getPipeline(pipelineName); - this.pipeline = this.defaultPipeline; - - return true; - } - - return false; - }, - - /** - * Sets the active WebGL Pipeline of this Game Object. - * - * @method Phaser.GameObjects.Components.Pipeline#setPipeline - * @webglOnly - * @since 3.0.0 - * - * @param {string} pipelineName - The name of the pipeline to set on this Game Object. - * - * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. - */ - setPipeline: function (pipelineName) + // Object tiles + var gidInfo = ParseGID(tiledObject.gid); + parsedObject.gid = gidInfo.gid; + parsedObject.flippedHorizontal = gidInfo.flippedHorizontal; + parsedObject.flippedVertical = gidInfo.flippedVertical; + parsedObject.flippedAntiDiagonal = gidInfo.flippedAntiDiagonal; + } + else if (tiledObject.polyline) { - var renderer = this.scene.sys.game.renderer; - - if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) - { - this.pipeline = renderer.getPipeline(pipelineName); - - return true; - } - - return false; - }, - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - * - * @method Phaser.GameObjects.Components.Pipeline#resetPipeline - * @webglOnly - * @since 3.0.0 - * - * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. - */ - resetPipeline: function () + parsedObject.polyline = tiledObject.polyline.map(copyPoints); + } + else if (tiledObject.polygon) { - this.pipeline = this.defaultPipeline; - - return (this.pipeline !== null); - }, - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - * - * @method Phaser.GameObjects.Components.Pipeline#getPipelineName - * @webglOnly - * @since 3.0.0 - * - * @return {string} The string-based name of the pipeline being used by this Game Object. - */ - getPipelineName: function () + parsedObject.polygon = tiledObject.polygon.map(copyPoints); + } + else if (tiledObject.ellipse) { - return this.pipeline.name; + parsedObject.ellipse = tiledObject.ellipse; + parsedObject.width = tiledObject.width; + parsedObject.height = tiledObject.height; + } + else if (tiledObject.text) + { + parsedObject.width = tiledObject.width; + parsedObject.height = tiledObject.height; + parsedObject.text = tiledObject.text; + } + else + { + // Otherwise, assume it is a rectangle + parsedObject.rectangle = true; + parsedObject.width = tiledObject.width; + parsedObject.height = tiledObject.height; } + return parsedObject; }; -module.exports = Pipeline; +module.exports = ParseObject; /***/ }), @@ -39917,387 +46555,256 @@ var Class = __webpack_require__(0); /** * @classdesc - * [description] + * An Image Collection is a special Tile Set containing multiple images, with no slicing into each image. * - * @class TransformMatrix - * @memberOf Phaser.GameObjects.Components + * Image Collections are normally created automatically when Tiled data is loaded. + * + * @class ImageCollection + * @memberOf Phaser.Tilemaps * @constructor * @since 3.0.0 - * - * @param {number} [a=1] - [description] - * @param {number} [b=0] - [description] - * @param {number} [c=0] - [description] - * @param {number} [d=1] - [description] - * @param {number} [tx=0] - [description] - * @param {number} [ty=0] - [description] + * + * @param {string} name - The name of the image collection in the map data. + * @param {integer} firstgid - The first image index this image collection contains. + * @param {integer} [width=32] - Width of widest image (in pixels). + * @param {integer} [height=32] - Height of tallest image (in pixels). + * @param {integer} [margin=0] - The margin around all images in the collection (in pixels). + * @param {integer} [spacing=0] - The spacing between each image in the collection (in pixels). + * @param {object} [properties={}] - Custom Image Collection properties. */ -var TransformMatrix = new Class({ +var ImageCollection = new Class({ initialize: - function TransformMatrix (a, b, c, d, tx, ty) + function ImageCollection (name, firstgid, width, height, margin, spacing, properties) { - if (a === undefined) { a = 1; } - if (b === undefined) { b = 0; } - if (c === undefined) { c = 0; } - if (d === undefined) { d = 1; } - if (tx === undefined) { tx = 0; } - if (ty === undefined) { ty = 0; } + if (width === undefined || width <= 0) { width = 32; } + if (height === undefined || height <= 0) { height = 32; } + if (margin === undefined) { margin = 0; } + if (spacing === undefined) { spacing = 0; } /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#matrix - * @type {Float32Array} + * The name of the Image Collection. + * + * @name Phaser.Tilemaps.ImageCollection#name + * @type {string} + * @since 3.0.0 + */ + this.name = name; + + /** + * The Tiled firstgid value. + * This is the starting index of the first image index this Image Collection contains. + * + * @name Phaser.Tilemaps.ImageCollection#firstgid + * @type {integer} * @since 3.0.0 */ - this.matrix = new Float32Array([ a, b, c, d, tx, ty, 0, 0, 1 ]); + this.firstgid = firstgid | 0; /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#decomposedMatrix + * The width of the widest image (in pixels). + * + * @name Phaser.Tilemaps.ImageCollection#imageWidth + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + this.imageWidth = width | 0; + + /** + * The height of the tallest image (in pixels). + * + * @name Phaser.Tilemaps.ImageCollection#imageHeight + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + this.imageHeight = height | 0; + + /** + * The margin around the images in the collection (in pixels). + * Use `setSpacing` to change. + * + * @name Phaser.Tilemaps.ImageCollection#imageMarge + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + this.imageMargin = margin | 0; + + /** + * The spacing between each image in the collection (in pixels). + * Use `setSpacing` to change. + * + * @name Phaser.Tilemaps.ImageCollection#imageSpacing + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + this.imageSpacing = spacing | 0; + + /** + * Image Collection-specific properties that are typically defined in the Tiled editor. + * + * @name Phaser.Tilemaps.ImageCollection#properties * @type {object} * @since 3.0.0 */ - this.decomposedMatrix = { - translateX: 0, - translateY: 0, - scaleX: 1, - scaleY: 1, - rotation: 0 - }; + this.properties = properties || {}; + + /** + * The cached images that are a part of this collection. + * + * @name Phaser.Tilemaps.ImageCollection#images + * @type {array} + * @readOnly + * @since 3.0.0 + */ + this.images = []; + + /** + * The total number of images in the image collection. + * + * @name Phaser.Tilemaps.ImageCollection#total + * @type {integer} + * @readOnly + * @since 3.0.0 + */ + this.total = 0; }, /** - * [description] + * Returns true if and only if this image collection contains the given image index. * - * @method Phaser.GameObjects.Components.TransformMatrix#loadIdentity + * @method Phaser.Tilemaps.ImageCollection#containsImageIndex * @since 3.0.0 - * - * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. + * + * @param {integer} imageIndex - The image index to search for. + * + * @return {boolean} True if this Image Collection contains the given index. */ - loadIdentity: function () + containsImageIndex: function (imageIndex) { - var matrix = this.matrix; - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 1; - matrix[4] = 0; - matrix[5] = 0; - - return this; + return (imageIndex >= this.firstgid && imageIndex < (this.firstgid + this.total)); }, /** - * [description] + * Add an image to this Image Collection. * - * @method Phaser.GameObjects.Components.TransformMatrix#translate + * @method Phaser.Tilemaps.ImageCollection#addImage * @since 3.0.0 + * + * @param {integer} gid - The gid of the image in the Image Collection. + * @param {string} image - The the key of the image in the Image Collection and in the cache. * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. + * @return {Phaser.Tilemaps.ImageCollection} This ImageCollection object. */ - translate: function (x, y) + addImage: function (gid, image) { - var matrix = this.matrix; - - matrix[4] = matrix[0] * x + matrix[2] * y + matrix[4]; - matrix[5] = matrix[1] * x + matrix[3] * y + matrix[5]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#scale - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. - */ - scale: function (x, y) - { - var matrix = this.matrix; - - matrix[0] *= x; - matrix[1] *= x; - matrix[2] *= y; - matrix[3] *= y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#rotate - * @since 3.0.0 - * - * @param {number} radian - [description] - * - * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. - */ - rotate: function (radian) - { - var radianSin = Math.sin(radian); - var radianCos = Math.cos(radian); - - return this.transform(radianCos, radianSin, -radianSin, radianCos, 0, 0); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#multiply - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.TransformMatrix} rhs - [description] - * - * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. - */ - multiply: function (rhs) - { - var matrix = this.matrix; - var otherMatrix = rhs.matrix; - - var a0 = matrix[0]; - var b0 = matrix[1]; - var c0 = matrix[2]; - var d0 = matrix[3]; - var tx0 = matrix[4]; - var ty0 = matrix[5]; - - var a1 = otherMatrix[0]; - var b1 = otherMatrix[1]; - var c1 = otherMatrix[2]; - var d1 = otherMatrix[3]; - var tx1 = otherMatrix[4]; - var ty1 = otherMatrix[5]; - - matrix[0] = a1 * a0 + b1 * c0; - matrix[1] = a1 * b0 + b1 * d0; - matrix[2] = c1 * a0 + d1 * c0; - matrix[3] = c1 * b0 + d1 * d0; - matrix[4] = tx1 * a0 + ty1 * c0 + tx0; - matrix[5] = tx1 * b0 + ty1 * d0 + ty0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#transform - * @since 3.0.0 - * - * @param {number} a - [description] - * @param {number} b - [description] - * @param {number} c - [description] - * @param {number} d - [description] - * @param {number} tx - [description] - * @param {number} ty - [description] - * - * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. - */ - transform: function (a, b, c, d, tx, ty) - { - var matrix = this.matrix; - - var a0 = matrix[0]; - var b0 = matrix[1]; - var c0 = matrix[2]; - var d0 = matrix[3]; - var tx0 = matrix[4]; - var ty0 = matrix[5]; - - matrix[0] = a * a0 + b * c0; - matrix[1] = a * b0 + b * d0; - matrix[2] = c * a0 + d * c0; - matrix[3] = c * b0 + d * d0; - matrix[4] = tx * a0 + ty * c0 + tx0; - matrix[5] = tx * b0 + ty * d0 + ty0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#transformPoint - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {Phaser.Geom.Point|Phaser.Math.Vec2|object} point - [description] - * - * @return {Phaser.Geom.Point|Phaser.Math.Vec2|object} [description] - */ - transformPoint: function (x, y, point) - { - if (point === undefined) { point = { x: 0, y: 0 }; } - - var matrix = this.matrix; - - var a = matrix[0]; - var b = matrix[1]; - var c = matrix[2]; - var d = matrix[3]; - var tx = matrix[4]; - var ty = matrix[5]; - - point.x = x * a + y * c + tx; - point.y = x * b + y * d + ty; - - return point; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#invert - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. - */ - invert: function () - { - var matrix = this.matrix; - - var a = matrix[0]; - var b = matrix[1]; - var c = matrix[2]; - var d = matrix[3]; - var tx = matrix[4]; - var ty = matrix[5]; - - var n = a * d - b * c; - - matrix[0] = d / n; - matrix[1] = -b / n; - matrix[2] = -c / n; - matrix[3] = a / n; - matrix[4] = (c * ty - d * tx) / n; - matrix[5] = -(a * ty - b * tx) / n; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#setTransform - * @since 3.0.0 - * - * @param {number} a - [description] - * @param {number} b - [description] - * @param {number} c - [description] - * @param {number} d - [description] - * @param {number} tx - [description] - * @param {number} ty - [description] - * - * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. - */ - setTransform: function (a, b, c, d, tx, ty) - { - var matrix = this.matrix; - - matrix[0] = a; - matrix[1] = b; - matrix[2] = c; - matrix[3] = d; - matrix[4] = tx; - matrix[5] = ty; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#decomposeMatrix - * @since 3.0.0 - * - * @return {object} [description] - */ - decomposeMatrix: function () - { - var decomposedMatrix = this.decomposedMatrix; - - var matrix = this.matrix; - - var a = matrix[0]; - var b = matrix[1]; - var c = matrix[2]; - var d = matrix[3]; - - var a2 = a * a; - var b2 = b * b; - var c2 = c * c; - var d2 = d * d; - - var sx = Math.sqrt(a2 + c2); - var sy = Math.sqrt(b2 + d2); - - decomposedMatrix.translateX = matrix[4]; - decomposedMatrix.translateY = matrix[5]; - - decomposedMatrix.scaleX = sx; - decomposedMatrix.scaleY = sy; - - decomposedMatrix.rotation = Math.acos(a / sx) * (Math.atan(-c / a) < 0 ? -1 : 1); - - return decomposedMatrix; - }, - - /** - * Identity + Translate + Rotate + Scale - * - * @method Phaser.GameObjects.Components.TransformMatrix#applyITRS - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} rotation - [description] - * @param {number} scaleX - [description] - * @param {number} scaleY - [description] - * - * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. - */ - applyITRS: function (x, y, rotation, scaleX, scaleY) - { - var matrix = this.matrix; - - var sr = Math.sin(rotation); - var cr = Math.cos(rotation); - - // Translate - matrix[4] = x; - matrix[5] = y; - - // Rotate and Scale - matrix[0] = cr * scaleX; - matrix[1] = -sr * scaleX; - matrix[2] = sr * scaleY; - matrix[3] = cr * scaleY; + this.images.push({ gid: gid, image: image }); + this.total++; return this; } }); -module.exports = TransformMatrix; +module.exports = ImageCollection; /***/ }), /* 191 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FLIPPED_HORIZONTAL = 0x80000000; +var FLIPPED_VERTICAL = 0x40000000; +var FLIPPED_ANTI_DIAGONAL = 0x20000000; // Top-right is swapped with bottom-left corners + +/** + * See Tiled documentation on tile flipping: + * http://docs.mapeditor.org/en/latest/reference/tmx-map-format/ + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseGID + * @since 3.0.0 + * + * @param {number} gid - [description] + * + * @return {object} [description] + */ +var ParseGID = function (gid) +{ + var flippedHorizontal = Boolean(gid & FLIPPED_HORIZONTAL); + var flippedVertical = Boolean(gid & FLIPPED_VERTICAL); + var flippedAntiDiagonal = Boolean(gid & FLIPPED_ANTI_DIAGONAL); + gid = gid & ~(FLIPPED_HORIZONTAL | FLIPPED_VERTICAL | FLIPPED_ANTI_DIAGONAL); + + // Parse the flip flags into something Phaser can use + var rotation = 0; + var flipped = false; + + if (flippedHorizontal && flippedVertical && flippedAntiDiagonal) + { + rotation = Math.PI / 2; + flipped = true; + } + else if (flippedHorizontal && flippedVertical && !flippedAntiDiagonal) + { + rotation = Math.PI; + flipped = false; + } + else if (flippedHorizontal && !flippedVertical && flippedAntiDiagonal) + { + rotation = Math.PI / 2; + flipped = false; + } + else if (flippedHorizontal && !flippedVertical && !flippedAntiDiagonal) + { + rotation = 0; + flipped = true; + } + else if (!flippedHorizontal && flippedVertical && flippedAntiDiagonal) + { + rotation = 3 * Math.PI / 2; + flipped = false; + } + else if (!flippedHorizontal && flippedVertical && !flippedAntiDiagonal) + { + rotation = Math.PI; + flipped = true; + } + else if (!flippedHorizontal && !flippedVertical && flippedAntiDiagonal) + { + rotation = 3 * Math.PI / 2; + flipped = true; + } + else if (!flippedHorizontal && !flippedVertical && !flippedAntiDiagonal) + { + rotation = 0; + flipped = false; + } + + return { + gid: gid, + flippedHorizontal: flippedHorizontal, + flippedVertical: flippedVertical, + flippedAntiDiagonal: flippedAntiDiagonal, + rotation: rotation, + flipped: flipped + }; +}; + +module.exports = ParseGID; + + +/***/ }), +/* 192 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -40306,157 +46813,75 @@ module.exports = TransformMatrix; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Perimeter = __webpack_require__(78); -var Point = __webpack_require__(5); - -// Return an array of points from the perimeter of the rectangle -// each spaced out based on the quantity or step required +var Formats = __webpack_require__(24); +var MapData = __webpack_require__(65); +var ParseTileLayers = __webpack_require__(424); +var ParseImageLayers = __webpack_require__(422); +var ParseTilesets = __webpack_require__(421); +var ParseObjectLayers = __webpack_require__(419); +var BuildTilesetIndex = __webpack_require__(418); +var AssignTileProperties = __webpack_require__(417); /** - * [description] + * Parses a Tiled JSON object into a new MapData object. * - * @function Phaser.Geom.Rectangle.MarchingAnts + * @function Phaser.Tilemaps.Parsers.Tiled.ParseJSONTiled * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} step - [description] - * @param {integer} quantity - [description] - * @param {array} [out] - [description] + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {object} json - The Tiled JSON object. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. * - * @return {Phaser.Geom.Point[]} [description] + * @return {?Phaser.Tilemaps.MapData} [description] */ -var MarchingAnts = function (rect, step, quantity, out) +var ParseJSONTiled = function (name, json, insertNull) { - if (out === undefined) { out = []; } - - if (!step && !quantity) + if (json.orientation !== 'orthogonal') { - // Bail out - return out; + console.warn('Only orthogonal map types are supported in this version of Phaser'); + return null; } - // If step is a falsey value (false, null, 0, undefined, etc) then we calculate - // it based on the quantity instead, otherwise we always use the step value - if (!step) - { - step = Perimeter(rect) / quantity; - } - else - { - quantity = Math.round(Perimeter(rect) / step); - } + // Map data will consist of: layers, objects, images, tilesets, sizes + var mapData = new MapData({ + width: json.width, + height: json.height, + name: name, + tileWidth: json.tilewidth, + tileHeight: json.tileheight, + orientation: json.orientation, + format: Formats.TILED_JSON, + version: json.version, + properties: json.properties + }); - var x = rect.x; - var y = rect.y; - var face = 0; + mapData.layers = ParseTileLayers(json, insertNull); + mapData.images = ParseImageLayers(json); - // Loop across each face of the rectangle + var sets = ParseTilesets(json); + mapData.tilesets = sets.tilesets; + mapData.imageCollections = sets.imageCollections; - for (var i = 0; i < quantity; i++) - { - out.push(new Point(x, y)); + mapData.objects = ParseObjectLayers(json); - switch (face) - { + mapData.tiles = BuildTilesetIndex(mapData); - // Top face - case 0: - x += step; + AssignTileProperties(mapData); - if (x >= rect.right) - { - face = 1; - y += (x - rect.right); - x = rect.right; - } - break; - - // Right face - case 1: - y += step; - - if (y >= rect.bottom) - { - face = 2; - x -= (y - rect.bottom); - y = rect.bottom; - } - break; - - // Bottom face - case 2: - x -= step; - - if (x <= rect.left) - { - face = 3; - y -= (rect.left - x); - x = rect.left; - } - break; - - // Left face - case 3: - y -= step; - - if (y <= rect.top) - { - face = 0; - y = rect.top; - } - break; - } - } - - return out; + return mapData; }; -module.exports = MarchingAnts; - - -/***/ }), -/* 192 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Moves the element at the start of the array to the end, shifting all items in the process. - * The "rotation" happens to the left. - * - * @function Phaser.Utils.Array.RotateLeft - * @since 3.0.0 - * - * @param {array} array - The array to shift to the left. This array is modified in place. - * @param {integer} [total=1] - The number of times to shift the array. - * - * @return {any} The most recently shifted element. - */ -var RotateLeft = function (array, total) -{ - if (total === undefined) { total = 1; } - - var element = null; - - for (var i = 0; i < total; i++) - { - element = array.shift(); - array.push(element); - } - - return element; -}; - -module.exports = RotateLeft; +module.exports = ParseJSONTiled; /***/ }), /* 193 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -40464,39 +46889,47 @@ module.exports = RotateLeft; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Formats = __webpack_require__(24); +var Parse2DArray = __webpack_require__(116); + /** - * Moves the element at the end of the array to the start, shifting all items in the process. - * The "rotation" happens to the right. + * Parses a CSV string of tile indexes into a new MapData object with a single layer. * - * @function Phaser.Utils.Array.RotateRight + * @function Phaser.Tilemaps.Parsers.ParseCSV * @since 3.0.0 * - * @param {array} array - The array to shift to the right. This array is modified in place. - * @param {integer} [total=1] - The number of times to shift the array. + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {string} data - CSV string of tile indexes. + * @param {integer} tileWidth - The width of a tile in pixels. + * @param {integer} tileHeight - The height of a tile in pixels. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. * - * @return {any} The most recently shifted element. + * @return {Phaser.Tilemaps.MapData} [description] */ -var RotateRight = function (array, total) +var ParseCSV = function (name, data, tileWidth, tileHeight, insertNull) { - if (total === undefined) { total = 1; } + var array2D = data + .trim() + .split('\n') + .map(function (row) { return row.split(','); }); - var element = null; + var map = Parse2DArray(name, array2D, tileWidth, tileHeight, insertNull); + map.format = Formats.CSV; - for (var i = 0; i < total; i++) - { - element = array.pop(); - array.unshift(element); - } - - return element; + return map; }; -module.exports = RotateRight; +module.exports = ParseCSV; /***/ }), /* 194 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -40504,72 +46937,69 @@ module.exports = RotateRight; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Formats = __webpack_require__(24); +var Parse2DArray = __webpack_require__(116); +var ParseCSV = __webpack_require__(193); +var ParseJSONTiled = __webpack_require__(192); +var ParseWeltmeister = __webpack_require__(187); + /** - * Using Bresenham's line algorithm this will return an array of all coordinates on this line. - * The start and end points are rounded before this runs as the algorithm works on integers. + * Parses raw data of a given Tilemap format into a new MapData object. If no recognized data format + * is found, returns `null`. When loading from CSV or a 2D array, you should specify the tileWidth & + * tileHeight. When parsing from a map from Tiled, the tileWidth & tileHeight will be pulled from + * the map data. * - * @function Phaser.Geom.Line.BresenhamPoints + * @function Phaser.Tilemaps.Parsers.Parse * @since 3.0.0 * - * @param {Phaser.Geom.Line} line - [description] - * @param {integer} [stepRate=1] - [description] - * @param {array} [results] - [description] + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {integer} mapFormat - See ../Formats.js. + * @param {(integer[][]|string|object)} data - 2D array, CSV string or Tiled JSON object. + * @param {integer} tileWidth - The width of a tile in pixels. Required for 2D array and CSV, but + * ignored for Tiled JSON. + * @param {integer} tileHeight - The height of a tile in pixels. Required for 2D array and CSV, but + * ignored for Tiled JSON. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. * - * @return {array} [description] + * @return {Phaser.Tilemaps.MapData} [description] */ -var BresenhamPoints = function (line, stepRate, results) +var Parse = function (name, mapFormat, data, tileWidth, tileHeight, insertNull) { - if (stepRate === undefined) { stepRate = 1; } - if (results === undefined) { results = []; } + var newMap; - var x1 = Math.round(line.x1); - var y1 = Math.round(line.y1); - var x2 = Math.round(line.x2); - var y2 = Math.round(line.y2); - - var dx = Math.abs(x2 - x1); - var dy = Math.abs(y2 - y1); - var sx = (x1 < x2) ? 1 : -1; - var sy = (y1 < y2) ? 1 : -1; - var err = dx - dy; - - results.push({ x: x1, y: y1 }); - - var i = 1; - - while (!((x1 === x2) && (y1 === y2))) + switch (mapFormat) { - var e2 = err << 1; - - if (e2 > -dy) - { - err -= dy; - x1 += sx; - } - - if (e2 < dx) - { - err += dx; - y1 += sy; - } - - if (i % stepRate === 0) - { - results.push({ x: x1, y: y1 }); - } - - i++; + case (Formats.ARRAY_2D): + newMap = Parse2DArray(name, data, tileWidth, tileHeight, insertNull); + break; + case (Formats.CSV): + newMap = ParseCSV(name, data, tileWidth, tileHeight, insertNull); + break; + case (Formats.TILED_JSON): + newMap = ParseJSONTiled(name, data, insertNull); + break; + case (Formats.WELTMEISTER): + newMap = ParseWeltmeister(name, data, insertNull); + break; + default: + console.warn('Unrecognized tilemap data format: ' + mapFormat); + newMap = null; } - return results; + return newMap; }; -module.exports = BresenhamPoints; +module.exports = Parse; /***/ }), /* 195 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -40577,31 +47007,60 @@ module.exports = BresenhamPoints; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Tile = __webpack_require__(45); +var IsInLayerBounds = __webpack_require__(67); +var CalculateFacesAt = __webpack_require__(119); + /** - * [description] + * Removes the tile at the given tile coordinates in the specified layer and updates the layer's + * collision information. * - * @function Phaser.Math.SmootherStep + * @function Phaser.Tilemaps.Components.RemoveTileAt * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} min - [description] - * @param {number} max - [description] + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified + * location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * - * @return {number} [description] + * @return {Phaser.Tilemaps.Tile} The Tile object that was removed. */ -var SmootherStep = function (x, min, max) +var RemoveTileAt = function (tileX, tileY, replaceWithNull, recalculateFaces, layer) { - x = Math.max(0, Math.min(1, (x - min) / (max - min))); + if (replaceWithNull === undefined) { replaceWithNull = false; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + if (!IsInLayerBounds(tileX, tileY, layer)) { return null; } - return x * x * x * (x * (x * 6 - 15) + 10); + var tile = layer.data[tileY][tileX]; + if (tile === null) + { + return null; + } + else + { + layer.data[tileY][tileX] = replaceWithNull + ? null + : new Tile(layer, -1, tileX, tileY, tile.width, tile.height); + } + + // Recalculate faces only if the removed tile was a colliding tile + if (recalculateFaces && tile && tile.collides) + { + CalculateFacesAt(tileX, tileY, layer); + } + + return tile; }; -module.exports = SmootherStep; +module.exports = RemoveTileAt; /***/ }), /* 196 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -40609,26 +47068,36 @@ module.exports = SmootherStep; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var IsInLayerBounds = __webpack_require__(67); + /** - * [description] + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. * - * @function Phaser.Math.SmoothStep + * @function Phaser.Tilemaps.Components.HasTileAt * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} min - [description] - * @param {number} max - [description] - * - * @return {number} [description] + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {boolean} */ -var SmoothStep = function (x, min, max) +var HasTileAt = function (tileX, tileY, layer) { - x = Math.max(0, Math.min(1, (x - min) / (max - min))); + if (IsInLayerBounds(tileX, tileY, layer)) + { + var tile = layer.data[tileY][tileX]; + return (tile !== null && tile.index > -1); + } + else + { + return false; + } - return x * x * (3 - 2 * x); }; -module.exports = SmoothStep; +module.exports = HasTileAt; /***/ }), @@ -40641,896 +47110,37 @@ module.exports = SmoothStep; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Frame = __webpack_require__(198); -var GetValue = __webpack_require__(4); +var GetTilesWithin = __webpack_require__(14); /** - * @classdesc - * A Frame based Animation. - * - * This consists of a key, some default values (like the frame rate) and a bunch of Frame objects. - * - * The Animation Manager creates these. Game Objects don't own an instance of these directly. - * Game Objects have the Animation Component, which are like playheads to global Animations (these objects) - * So multiple Game Objects can have playheads all pointing to this one Animation instance. + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does + * not change collision information. * - * @class Animation - * @memberOf Phaser.Animations - * @constructor + * @function Phaser.Tilemaps.Components.ReplaceByIndex * @since 3.0.0 * - * @param {Phaser.Animations.AnimationManager} manager - [description] - * @param {string} key - [description] - * @param {object} config - [description] + * @param {integer} findIndex - [description] + * @param {integer} newIndex - [description] + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. */ -var Animation = new Class({ - - initialize: - - function Animation (manager, key, config) +var ReplaceByIndex = function (findIndex, newIndex, tileX, tileY, width, height, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + for (var i = 0; i < tiles.length; i++) { - /** - * [description] - * - * @name Phaser.Animations.Animation#manager - * @type {Phaser.Animations.AnimationManager} - * @since 3.0.0 - */ - this.manager = manager; - - /** - * [description] - * - * @name Phaser.Animations.Animation#key - * @type {string} - * @since 3.0.0 - */ - this.key = key; - - /** - * A frame based animation (as opposed to a bone based animation) - * - * @name Phaser.Animations.Animation#type - * @type {string} - * @default frame - * @since 3.0.0 - */ - this.type = 'frame'; - - /** - * Extract all the frame data into the frames array - * - * @name Phaser.Animations.Animation#frames - * @type {array} - * @since 3.0.0 - */ - this.frames = this.getFrames( - manager.textureManager, - GetValue(config, 'frames', []), - GetValue(config, 'defaultTextureKey', null) - ); - - /** - * The frame rate of playback in frames per second (default 24 if duration is null) - * - * @name Phaser.Animations.Animation#frameRate - * @type {integer} - * @default 24 - * @since 3.0.0 - */ - this.frameRate = GetValue(config, 'frameRate', null); - - /** - * How long the animation should play for. - * If frameRate is set it overrides this value otherwise frameRate is derived from duration. - * - * @name Phaser.Animations.Animation#duration - * @type {integer} - * @since 3.0.0 - */ - this.duration = GetValue(config, 'duration', null); - - if (this.duration === null && this.frameRate === null) + if (tiles[i] && tiles[i].index === findIndex) { - // No duration or frameRate given, use default frameRate of 24fps - this.frameRate = 24; - this.duration = this.frameRate / this.frames.length; + tiles[i].index = newIndex; } - else if (this.duration && this.frameRate === null) - { - // Duration given but no frameRate, so set the frameRate based on duration - // I.e. 12 frames in the animation, duration = 4 (4000 ms) - // So frameRate is 12 / 4 = 3 fps - this.frameRate = this.frames.length / this.duration; - } - else - { - // frameRate given, derive duration from it (even if duration also specified) - // I.e. 15 frames in the animation, frameRate = 30 fps - // So duration is 15 / 30 = 0.5 (half a second) - this.duration = this.frames.length / this.frameRate; - } - - /** - * ms per frame (without including frame specific modifiers) - * - * @name Phaser.Animations.Animation#msPerFrame - * @type {integer} - * @since 3.0.0 - */ - this.msPerFrame = 1000 / this.frameRate; - - /** - * Skip frames if the time lags, or always advanced anyway? - * - * @name Phaser.Animations.Animation#skipMissedFrames - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.skipMissedFrames = GetValue(config, 'skipMissedFrames', true); - - /** - * Delay before starting playback (in seconds) - * - * @name Phaser.Animations.Animation#delay - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.delay = GetValue(config, 'delay', 0); - - /** - * Number of times to repeat the animation (-1 for infinity) - * - * @name Phaser.Animations.Animation#repeat - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.repeat = GetValue(config, 'repeat', 0); - - /** - * Delay before the repeat starts (in seconds) - * - * @name Phaser.Animations.Animation#repeatDelay - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.repeatDelay = GetValue(config, 'repeatDelay', 0); - - /** - * Should the animation yoyo? (reverse back down to the start) before repeating? - * - * @name Phaser.Animations.Animation#yoyo - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.yoyo = GetValue(config, 'yoyo', false); - - /** - * Should sprite.visible = true when the animation starts to play? - * - * @name Phaser.Animations.Animation#showOnStart - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.showOnStart = GetValue(config, 'showOnStart', false); - - /** - * Should sprite.visible = false when the animation finishes? - * - * @name Phaser.Animations.Animation#hideOnComplete - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.hideOnComplete = GetValue(config, 'hideOnComplete', false); - - /** - * [description] - * - * @name Phaser.Animations.Animation#callbackScope - * @type {object} - * @since 3.0.0 - */ - this.callbackScope = GetValue(config, 'callbackScope', this); - - /** - * [description] - * - * @name Phaser.Animations.Animation#onStart - * @type {function} - * @since 3.0.0 - */ - this.onStart = GetValue(config, 'onStart', false); - - /** - * [description] - * - * @name Phaser.Animations.Animation#onStartParams - * @type {array} - * @since 3.0.0 - */ - this.onStartParams = GetValue(config, 'onStartParams', []); - - /** - * [description] - * - * @name Phaser.Animations.Animation#onRepeat - * @type {function} - * @since 3.0.0 - */ - this.onRepeat = GetValue(config, 'onRepeat', false); - - /** - * [description] - * - * @name Phaser.Animations.Animation#onRepeatParams - * @type {array} - * @since 3.0.0 - */ - this.onRepeatParams = GetValue(config, 'onRepeatParams', []); - - /** - * Called for EVERY frame of the animation. - * See AnimationFrame.onUpdate for a frame specific callback. - * - * @name Phaser.Animations.Animation#onUpdate - * @type {function} - * @since 3.0.0 - */ - this.onUpdate = GetValue(config, 'onUpdate', false); - - /** - * [description] - * - * @name Phaser.Animations.Animation#onUpdateParams - * @type {array} - * @since 3.0.0 - */ - this.onUpdateParams = GetValue(config, 'onUpdateParams', []); - - /** - * [description] - * - * @name Phaser.Animations.Animation#onComplete - * @type {function} - * @since 3.0.0 - */ - this.onComplete = GetValue(config, 'onComplete', false); - - /** - * [description] - * - * @name Phaser.Animations.Animation#onCompleteParams - * @type {array} - * @since 3.0.0 - */ - this.onCompleteParams = GetValue(config, 'onCompleteParams', []); - - /** - * Global pause, effects all Game Objects using this Animation instance - * - * @name Phaser.Animations.Animation#paused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.paused = false; - - this.manager.on('pauseall', this.pause.bind(this)); - this.manager.on('resumeall', this.resume.bind(this)); - }, - - // config = Array of Animation config objects, like: - // [ - // { key: 'gems', frame: 'diamond0001', [duration], [visible], [onUpdate] } - // ] - - // Add frames to the end of the animation - - /** - * [description] - * - * @method Phaser.Animations.Animation#addFrame - * @since 3.0.0 - * - * @param {[type]} config - [description] - * - * @return {Phaser.Animations.Animation} This Animation object. - */ - addFrame: function (config) - { - return this.addFrameAt(this.frames.length, config); - }, - - // config = Array of Animation config objects, like: - // [ - // { key: 'gems', frame: 'diamond0001', [duration], [visible], [onUpdate] } - // ] - - // Add frame/s into the animation - - /** - * [description] - * - * @method Phaser.Animations.Animation#addFrameAt - * @since 3.0.0 - * - * @param {integer} index - [description] - * @param {[type]} config - [description] - * - * @return {Phaser.Animations.Animation} This Animation object. - */ - addFrameAt: function (index, config) - { - var newFrames = this.getFrames(this.manager.textureManager, config); - - if (newFrames.length > 0) - { - if (index === 0) - { - this.frames = newFrames.concat(this.frames); - } - else if (index === this.frames.length) - { - this.frames = this.frames.concat(newFrames); - } - else - { - var pre = this.frames.slice(0, index); - var post = this.frames.slice(index); - - this.frames = pre.concat(newFrames, post); - } - - this.updateFrameSequence(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#checkFrame - * @since 3.0.0 - * - * @param {integer} index - [description] - * - * @return {boolean} [description] - */ - checkFrame: function (index) - { - return (index < this.frames.length); - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#completeAnimation - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - [description] - */ - completeAnimation: function (component) - { - if (this.hideOnComplete) - { - component.parent.visible = false; - } - - component.stop(true); - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#getFirstTick - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - [description] - * @param {boolean} [includeDelay=true] - [description] - */ - getFirstTick: function (component, includeDelay) - { - if (includeDelay === undefined) { includeDelay = true; } - - // When is the first update due? - component.accumulator = 0; - component.nextTick = component.msPerFrame + component.currentFrame.duration; - - if (includeDelay) - { - component.nextTick += (component._delay * 1000); - } - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#getFrameAt - * @since 3.0.0 - * - * @param {integer} index - [description] - * - * @return {Phaser.Animations.AnimationFrame} [description] - */ - getFrameAt: function (index) - { - return this.frames[index]; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#getFrames - * @since 3.0.0 - * - * @param {[type]} textureManager - [description] - * @param {[type]} frames - [description] - * - * @return {Phaser.Animations.AnimationFrame[]} [description] - */ - getFrames: function (textureManager, frames, defaultTextureKey) - { - // frames: [ - // { key: textureKey, frame: textureFrame }, - // { key: textureKey, frame: textureFrame, duration: float }, - // { key: textureKey, frame: textureFrame, onUpdate: function } - // { key: textureKey, frame: textureFrame, visible: boolean } - // ], - - var out = []; - var prev; - var animationFrame; - var index = 1; - var i; - var textureKey; - - // if frames is a string, we'll get all the frames from the texture manager as if it's a sprite sheet - if (typeof frames === 'string') - { - textureKey = frames; - - var texture = textureManager.get(textureKey); - var frameKeys = texture.getFrameNames(); - - frames = []; - - frameKeys.forEach(function (idx, value) - { - frames.push({ key: textureKey, frame: value }); - }); - } - - if (!Array.isArray(frames) || frames.length === 0) - { - return out; - } - - for (i = 0; i < frames.length; i++) - { - var item = frames[i]; - - var key = GetValue(item, 'key', defaultTextureKey); - - if (!key) - { - continue; - } - - // Could be an integer or a string - var frame = GetValue(item, 'frame', 0); - - // The actual texture frame - var textureFrame = textureManager.getFrame(key, frame); - - animationFrame = new Frame(key, frame, index, textureFrame); - - animationFrame.duration = GetValue(item, 'duration', 0); - animationFrame.onUpdate = GetValue(item, 'onUpdate', null); - - animationFrame.isFirst = (!prev); - - // The previously created animationFrame - if (prev) - { - prev.nextFrame = animationFrame; - - animationFrame.prevFrame = prev; - } - - out.push(animationFrame); - - prev = animationFrame; - - index++; - } - - if (out.length > 0) - { - animationFrame.isLast = true; - - // Link them end-to-end, so they loop - animationFrame.nextFrame = out[0]; - - out[0].prevFrame = animationFrame; - - // Generate the progress data - - var slice = 1 / (out.length - 1); - - for (i = 0; i < out.length; i++) - { - out[i].progress = i * slice; - } - } - - return out; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#getNextTick - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - [description] - */ - getNextTick: function (component) - { - // accumulator += delta * _timeScale - // after a large delta surge (perf issue for example) we need to adjust for it here - - // When is the next update due? - component.accumulator -= component.nextTick; - - component.nextTick = component.msPerFrame + component.currentFrame.duration; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#load - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - [description] - * @param {integer} startFrame - [description] - */ - load: function (component, startFrame) - { - if (startFrame >= this.frames.length) - { - startFrame = 0; - } - - if (component.currentAnim !== this) - { - component.currentAnim = this; - - component._timeScale = 1; - component.frameRate = this.frameRate; - component.duration = this.duration; - component.msPerFrame = this.msPerFrame; - component.skipMissedFrames = this.skipMissedFrames; - component._delay = this.delay; - component._repeat = this.repeat; - component._repeatDelay = this.repeatDelay; - component._yoyo = this.yoyo; - component._callbackArgs[1] = this; - component._updateParams = component._callbackArgs.concat(this.onUpdateParams); - } - - component.updateFrame(this.frames[startFrame]); - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#nextFrame - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - [description] - */ - nextFrame: function (component) - { - var frame = component.currentFrame; - - // TODO: Add frame skip support - - if (frame.isLast) - { - // We're at the end of the animation - - // Yoyo? (happens before repeat) - if (this.yoyo) - { - component.forward = false; - - component.updateFrame(frame.prevFrame); - - // Delay for the current frame - this.getNextTick(component); - } - else if (component.repeatCounter > 0) - { - // Repeat (happens before complete) - this.repeatAnimation(component); - } - else - { - this.completeAnimation(component); - } - } - else - { - component.updateFrame(frame.nextFrame); - - this.getNextTick(component); - } - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#previousFrame - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - [description] - */ - previousFrame: function (component) - { - var frame = component.currentFrame; - - // TODO: Add frame skip support - - if (frame.isFirst) - { - // We're at the start of the animation - - if (component.repeatCounter > 0) - { - // Repeat (happens before complete) - this.repeatAnimation(component); - } - else - { - this.completeAnimation(component); - } - } - else - { - component.updateFrame(frame.prevFrame); - - this.getNextTick(component); - } - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#removeFrame - * @since 3.0.0 - * - * @param {Phaser.Animations.AnimationFrame} frame - [description] - * - * @return {Phaser.Animations.Animation} This Animation object. - */ - removeFrame: function (frame) - { - var index = this.frames.indexOf(frame); - - if (index !== -1) - { - this.removeFrameAt(index); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#removeFrameAt - * @since 3.0.0 - * - * @param {integer} index - [description] - * - * @return {Phaser.Animations.Animation} This Animation object. - */ - removeFrameAt: function (index) - { - this.frames.splice(index, 1); - - this.updateFrameSequence(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#repeatAnimation - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - [description] - */ - repeatAnimation: function (component) - { - if (component._repeatDelay > 0 && component.pendingRepeat === false) - { - component.pendingRepeat = true; - component.accumulator -= component.nextTick; - component.nextTick += (component._repeatDelay * 1000); - } - else - { - component.repeatCounter--; - - component.forward = true; - - component.updateFrame(component.currentFrame.nextFrame); - - this.getNextTick(component); - - component.pendingRepeat = false; - - if (this.onRepeat) - { - this.onRepeat.apply(this.callbackScope, component._callbackArgs.concat(this.onRepeatParams)); - } - } - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#setFrame - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - [description] - */ - setFrame: function (component) - { - // Work out which frame should be set next on the child, and set it - if (component.forward) - { - this.nextFrame(component); - } - else - { - this.previousFrame(component); - } - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - var output = { - key: this.key, - type: this.type, - frames: [], - frameRate: this.frameRate, - duration: this.duration, - skipMissedFrames: this.skipMissedFrames, - delay: this.delay, - repeat: this.repeat, - repeatDelay: this.repeatDelay, - yoyo: this.yoyo, - showOnStart: this.showOnStart, - hideOnComplete: this.hideOnComplete - }; - - this.frames.forEach(function (frame) - { - output.frames.push(frame.toJSON()); - }); - - return output; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#updateFrameSequence - * @since 3.0.0 - * - * @return {Phaser.Animations.Animation} This Animation object. - */ - updateFrameSequence: function () - { - var len = this.frames.length; - var slice = 1 / (len - 1); - - for (var i = 0; i < len; i++) - { - var frame = this.frames[i]; - - frame.index = i + 1; - frame.isFirst = false; - frame.isLast = false; - frame.progress = i * slice; - - if (i === 0) - { - frame.isFirst = true; - frame.isLast = (len === 1); - frame.prevFrame = this.frames[len - 1]; - frame.nextFrame = this.frames[i + 1]; - } - else if (i === len - 1) - { - frame.isLast = true; - frame.prevFrame = this.frames[len - 2]; - frame.nextFrame = this.frames[0]; - } - else if (len > 1) - { - frame.prevFrame = this.frames[i - 1]; - frame.nextFrame = this.frames[i + 1]; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#pause - * @since 3.0.0 - * - * @return {Phaser.Animations.Animation} This Animation object. - */ - pause: function () - { - this.paused = true; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#resume - * @since 3.0.0 - * - * @return {Phaser.Animations.Animation} This Animation object. - */ - resume: function () - { - this.paused = false; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#destroy - * @since 3.0.0 - */ - destroy: function () - { - // TODO } +}; -}); - -module.exports = Animation; +module.exports = ReplaceByIndex; /***/ }), @@ -41538,190 +47148,139 @@ module.exports = Animation; /***/ (function(module, exports, __webpack_require__) { /** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ +* The `Matter.Sleeping` module contains methods to manage the sleeping state of bodies. +* +* @class Sleeping +*/ -var Class = __webpack_require__(0); +var Sleeping = {}; -/** - * @classdesc - * A single frame in an Animation sequence. - * - * An AnimationFrame consists of a reference to the Texture it uses for rendering, references to other - * frames in the animation, and index data. It also has the ability to fire its own `onUpdate` callback - * and modify the animation timing. - * - * AnimationFrames are generated automatically by the Animation class. - * - * @class AnimationFrame - * @memberOf Phaser.Animations - * @constructor - * @since 3.0.0 - * - * @param {string} textureKey - The key of the Texture this AnimationFrame uses. - * @param {string|integer} textureFrame - The key of the Frame within the Texture that this AnimationFrame uses. - * @param {integer} index - The index of this AnimationFrame within the Animation sequence. - * @param {Phaser.Textures.Frame} frame - A reference to the Texture Frame this AnimationFrame uses for rendering. - */ -var AnimationFrame = new Class({ +module.exports = Sleeping; - initialize: +var Events = __webpack_require__(171); - function AnimationFrame (textureKey, textureFrame, index, frame) - { - /** - * The key of the Texture this AnimationFrame uses. - * - * @name Phaser.Animations.AnimationFrame#textureKey - * @type {string} - * @since 3.0.0 - */ - this.textureKey = textureKey; +(function() { - /** - * The key of the Frame within the Texture that this AnimationFrame uses. - * - * @name Phaser.Animations.AnimationFrame#textureFrame - * @type {string|integer} - * @since 3.0.0 - */ - this.textureFrame = textureFrame; - - /** - * The index of this AnimationFrame within the Animation sequence. - * - * @name Phaser.Animations.AnimationFrame#index - * @type {integer} - * @since 3.0.0 - */ - this.index = index; - - /** - * A reference to the Texture Frame this AnimationFrame uses for rendering. - * - * @name Phaser.Animations.AnimationFrame#frame - * @type {Phaser.Textures.Frame} - * @since 3.0.0 - */ - this.frame = frame; - - /** - * Is this the first frame in an animation sequence? - * - * @name Phaser.Animations.AnimationFrame#isFirst - * @type {boolean} - * @default false - * @readOnly - * @since 3.0.0 - */ - this.isFirst = false; - - /** - * Is this the last frame in an animation sequence? - * - * @name Phaser.Animations.AnimationFrame#isLast - * @type {boolean} - * @default false - * @readOnly - * @since 3.0.0 - */ - this.isLast = false; - - /** - * A reference to the AnimationFrame that comes before this one in the animation, if any. - * - * @name Phaser.Animations.AnimationFrame#prevFrame - * @type {?Phaser.Animations.AnimationFrame} - * @default null - * @readOnly - * @since 3.0.0 - */ - this.prevFrame = null; - - /** - * A reference to the AnimationFrame that comes after this one in the animation, if any. - * - * @name Phaser.Animations.AnimationFrame#nextFrame - * @type {?Phaser.Animations.AnimationFrame} - * @default null - * @readOnly - * @since 3.0.0 - */ - this.nextFrame = null; - - /** - * Additional time (in ms) that this frame should appear for during playback. - * The value is added onto the msPerFrame set by the animation. - * - * @name Phaser.Animations.AnimationFrame#duration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.duration = 0; - - /** - * What % through the animation does this frame come? - * This value is generated when the animation is created and cached here. - * - * @name Phaser.Animations.AnimationFrame#progress - * @type {number} - * @default 0 - * @readOnly - * @since 3.0.0 - */ - this.progress = 0; - - /** - * A frame specific callback, invoked if this frame gets displayed and the callback is set. - * - * @name Phaser.Animations.AnimationFrame#onUpdate - * @type {?function} - * @default null - * @since 3.0.0 - */ - this.onUpdate = null; - }, + Sleeping._motionWakeThreshold = 0.18; + Sleeping._motionSleepThreshold = 0.08; + Sleeping._minBias = 0.9; /** - * Generates a JavaScript object suitable for converting to JSON. - * - * @method Phaser.Animations.AnimationFrame#toJSON - * @since 3.0.0 - * - * @return {object} The AnimationFrame data. + * Puts bodies to sleep or wakes them up depending on their motion. + * @method update + * @param {body[]} bodies + * @param {number} timeScale */ - toJSON: function () - { - return { - key: this.textureKey, - frame: this.textureFrame, - duration: this.duration - }; - }, + Sleeping.update = function(bodies, timeScale) { + var timeFactor = timeScale * timeScale * timeScale; + + // update bodies sleeping status + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i], + motion = body.speed * body.speed + body.angularSpeed * body.angularSpeed; + + // wake up bodies if they have a force applied + if (body.force.x !== 0 || body.force.y !== 0) { + Sleeping.set(body, false); + continue; + } + + var minMotion = Math.min(body.motion, motion), + maxMotion = Math.max(body.motion, motion); + + // biased average motion estimation between frames + body.motion = Sleeping._minBias * minMotion + (1 - Sleeping._minBias) * maxMotion; + + if (body.sleepThreshold > 0 && body.motion < Sleeping._motionSleepThreshold * timeFactor) { + body.sleepCounter += 1; + + if (body.sleepCounter >= body.sleepThreshold) + Sleeping.set(body, true); + } else if (body.sleepCounter > 0) { + body.sleepCounter -= 1; + } + } + }; /** - * Destroys this object by removing references to external resources and callbacks. - * - * @method Phaser.Animations.AnimationFrame#destroy - * @since 3.0.0 + * Given a set of colliding pairs, wakes the sleeping bodies involved. + * @method afterCollisions + * @param {pair[]} pairs + * @param {number} timeScale */ - destroy: function () - { - this.frame = undefined; - this.onUpdate = undefined; - } + Sleeping.afterCollisions = function(pairs, timeScale) { + var timeFactor = timeScale * timeScale * timeScale; -}); + // wake up bodies involved in collisions + for (var i = 0; i < pairs.length; i++) { + var pair = pairs[i]; + + // don't wake inactive pairs + if (!pair.isActive) + continue; -module.exports = AnimationFrame; + var collision = pair.collision, + bodyA = collision.bodyA.parent, + bodyB = collision.bodyB.parent; + + // don't wake if at least one body is static + if ((bodyA.isSleeping && bodyB.isSleeping) || bodyA.isStatic || bodyB.isStatic) + continue; + + if (bodyA.isSleeping || bodyB.isSleeping) { + var sleepingBody = (bodyA.isSleeping && !bodyA.isStatic) ? bodyA : bodyB, + movingBody = sleepingBody === bodyA ? bodyB : bodyA; + + if (!sleepingBody.isStatic && movingBody.motion > Sleeping._motionWakeThreshold * timeFactor) { + Sleeping.set(sleepingBody, false); + } + } + } + }; + + /** + * Set a body as sleeping or awake. + * @method set + * @param {body} body + * @param {boolean} isSleeping + */ + Sleeping.set = function(body, isSleeping) { + var wasSleeping = body.isSleeping; + + if (isSleeping) { + body.isSleeping = true; + body.sleepCounter = body.sleepThreshold; + + body.positionImpulse.x = 0; + body.positionImpulse.y = 0; + + body.positionPrev.x = body.position.x; + body.positionPrev.y = body.position.y; + + body.anglePrev = body.angle; + body.speed = 0; + body.angularSpeed = 0; + body.motion = 0; + + if (!wasSleeping) { + Events.trigger(body, 'sleepStart'); + } + } else { + body.isSleeping = false; + body.sleepCounter = 0; + + if (wasSleeping) { + Events.trigger(body, 'sleepEnd'); + } + } + }; + +})(); /***/ }), /* 199 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -41729,591 +47288,58 @@ module.exports = AnimationFrame; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Animation = __webpack_require__(197); -var Class = __webpack_require__(0); -var CustomMap = __webpack_require__(114); -var EventEmitter = __webpack_require__(14); -var GetValue = __webpack_require__(4); -var Pad = __webpack_require__(200); - /** - * @classdesc - * The Animation Manager. - * - * Animations are managed by the global Animation Manager. This is a singleton class that is - * responsible for creating and delivering animations and their corresponding data to all Game Objects. - * Unlike plugins it is owned by the Game instance, not the Scene. - * - * Sprites and other Game Objects get the data they need from the AnimationManager. + * Collision Types - Determine if and how entities collide with each other. * - * @class AnimationManager - * @extends EventEmitter - * @memberOf Phaser.Animations - * @constructor + * In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves, + * while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE + * collisions, both entities are moved. LITE or PASSIVE entities don't collide + * with other LITE or PASSIVE entities at all. The behavior for FIXED vs. + * FIXED collisions is undefined. + * + * @name Phaser.Physics.Impact.TYPES + * @type {object} * @since 3.0.0 - * - * @param {Phaser.Game} game - [description] */ -var AnimationManager = new Class({ - - Extends: EventEmitter, - - initialize: - - function AnimationManager (game) - { - EventEmitter.call(this); - - /** - * [description] - * - * @name Phaser.Animations.AnimationManager#game - * @type {Phaser.Game} - * @protected - * @since 3.0.0 - */ - this.game = game; - - /** - * [description] - * - * @name Phaser.Animations.AnimationManager#textureManager - * @type {Phaser.Textures.TextureManager} - * @protected - * @since 3.0.0 - */ - this.textureManager = null; - - /** - * [description] - * - * @name Phaser.Animations.AnimationManager#globalTimeScale - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.globalTimeScale = 1; - - /** - * [description] - * - * @name Phaser.Animations.AnimationManager#anims - * @type {Phaser.Structs.Map} - * @protected - * @since 3.0.0 - */ - this.anims = new CustomMap(); - - /** - * [description] - * - * @name Phaser.Animations.AnimationManager#paused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.paused = false; - - /** - * [description] - * - * @name Phaser.Animations.AnimationManager#name - * @type {string} - * @since 3.0.0 - */ - this.name = 'AnimationManager'; - - game.events.once('boot', this.boot, this); - }, +module.exports = { /** - * [description] + * Collides with nothing. * - * @method Phaser.Animations.AnimationManager#boot + * @name Phaser.Physics.Impact.TYPES.NONE + * @type {integer} * @since 3.0.0 */ - boot: function () - { - this.textureManager = this.game.textures; - - this.game.events.once('destroy', this.destroy, this); - }, + NONE: 0, /** - * [description] + * Type A. Collides with Type B. * - * @method Phaser.Animations.AnimationManager#add - * @fires AddAnimationEvent + * @name Phaser.Physics.Impact.TYPES.A + * @type {integer} * @since 3.0.0 - * - * @param {string} key - [description] - * @param {Phaser.Animations.Animation} animation - [description] - * - * @return {Phaser.Animations.AnimationManager} This Animation Manager. */ - add: function (key, animation) - { - if (this.anims.has(key)) - { - console.warn('Animation with key', key, 'already exists'); - return; - } - - animation.key = key; - - this.anims.set(key, animation); - - this.emit('add', key, animation); - - return this; - }, + A: 1, /** - * [description] + * Type B. Collides with Type A. * - * @method Phaser.Animations.AnimationManager#create - * @fires AddAnimationEvent + * @name Phaser.Physics.Impact.TYPES.B + * @type {integer} * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.Animations.Animation} The Animation that was created. */ - create: function (config) - { - var key = config.key; - - if (!key || this.anims.has(key)) - { - console.warn('Invalid Animation Key, or Key already in use: ' + key); - return; - } - - var anim = new Animation(this, key, config); - - this.anims.set(key, anim); - - this.emit('add', key, anim); - - return anim; - }, + B: 2, /** - * [description] + * Collides with both types A and B. * - * @method Phaser.Animations.AnimationManager#fromJSON - * @since 3.0.0 - * - * @param {string|object} data - [description] - * @param {boolean} [clearCurrentAnimations=false] - [description] - * - * @return {Phaser.Animations.Animation[]} An array containing all of the Animation objects that were created as a result of this call. - */ - fromJSON: function (data, clearCurrentAnimations) - { - if (clearCurrentAnimations === undefined) { clearCurrentAnimations = false; } - - if (clearCurrentAnimations) - { - this.anims.clear(); - } - - // Do we have a String (i.e. from JSON, or an Object?) - if (typeof data === 'string') - { - data = JSON.parse(data); - } - - var output = []; - - // Array of animations, or a single animation? - if (data.hasOwnProperty('anims') && Array.isArray(data.anims)) - { - for (var i = 0; i < data.anims.length; i++) - { - output.push(this.create(data.anims[i])); - } - - if (data.hasOwnProperty('globalTimeScale')) - { - this.globalTimeScale = data.globalTimeScale; - } - } - else if (data.hasOwnProperty('key') && data.type === 'frame') - { - output.push(this.create(data)); - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#generateFrameNames - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {object} config - [description] - * @param {string} [config.prefix=''] - [description] - * @param {integer} [config.start=0] - [description] - * @param {integer} [config.end=0] - [description] - * @param {string} [config.suffix=''] - [description] - * @param {integer} [config.zeroPad=0] - [description] - * @param {array} [config.outputArray=[]] - [description] - * @param {boolean} [config.frames=false] - [description] - * - * @return {object[]} [description] - */ - generateFrameNames: function (key, config) - { - var prefix = GetValue(config, 'prefix', ''); - var start = GetValue(config, 'start', 0); - var end = GetValue(config, 'end', 0); - var suffix = GetValue(config, 'suffix', ''); - var zeroPad = GetValue(config, 'zeroPad', 0); - var out = GetValue(config, 'outputArray', []); - var frames = GetValue(config, 'frames', false); - - var texture = this.textureManager.get(key); - - if (!texture) - { - return out; - } - - var diff = (start < end) ? 1 : -1; - - // Adjust because we use i !== end in the for loop - end += diff; - - var i; - var frame; - - // Have they provided their own custom frame sequence array? - if (Array.isArray(frames)) - { - for (i = 0; i < frames.length; i++) - { - frame = prefix + Pad(frames[i], zeroPad, '0', 1) + suffix; - - if (texture.has(frame)) - { - out.push({ key: key, frame: frame }); - } - } - } - else - { - for (i = start; i !== end; i += diff) - { - frame = prefix + Pad(i, zeroPad, '0', 1) + suffix; - - if (texture.has(frame)) - { - out.push({ key: key, frame: frame }); - } - } - } - - return out; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#generateFrameNumbers - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {object} config - [description] - * @param {integer} [config.start=0] - [description] - * @param {integer} [config.end=-1] - [description] - * @param {boolean} [config.first=false] - [description] - * @param {array} [config.outputArray=[]] - [description] - * @param {boolean} [config.frames=false] - [description] - * - * @return {object[]} [description] - */ - generateFrameNumbers: function (key, config) - { - var startFrame = GetValue(config, 'start', 0); - var endFrame = GetValue(config, 'end', -1); - var firstFrame = GetValue(config, 'first', false); - var out = GetValue(config, 'outputArray', []); - var frames = GetValue(config, 'frames', false); - - var texture = this.textureManager.get(key); - - if (!texture) - { - return out; - } - - if (firstFrame && texture.has(firstFrame)) - { - out.push({ key: key, frame: firstFrame }); - } - - var i; - - // Have they provided their own custom frame sequence array? - if (Array.isArray(frames)) - { - for (i = 0; i < frames.length; i++) - { - if (texture.has(frames[i])) - { - out.push({ key: key, frame: frames[i] }); - } - } - } - else - { - // No endFrame then see if we can get it - - if (endFrame === -1) - { - endFrame = texture.frameTotal; - } - - for (i = startFrame; i <= endFrame; i++) - { - if (texture.has(i)) - { - out.push({ key: key, frame: i }); - } - } - } - - return out; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#get - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Animations.Animation} [description] - */ - get: function (key) - { - return this.anims.get(key); - }, - - /** - * Load an Animation into a Game Objects Animation Component. - * - * @method Phaser.Animations.AnimationManager#load - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - * @param {string} key - [description] - * @param {string|integer} [startFrame] - [description] - * - * @return {Phaser.GameObjects.GameObject} [description] - */ - load: function (child, key, startFrame) - { - var anim = this.get(key); - - if (anim) - { - anim.load(child, startFrame); - } - - return child; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#pauseAll - * @fires PauseAllAnimationEvent - * @since 3.0.0 - * - * @return {Phaser.Animations.AnimationManager} This Animation Manager. - */ - pauseAll: function () - { - if (!this.paused) - { - this.paused = true; - - this.emit('pauseall'); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#play - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {Phaser.GameObjects.GameObject} child - [description] - * - * @return {Phaser.Animations.AnimationManager} This Animation Manager. - */ - play: function (key, child) - { - if (!Array.isArray(child)) - { - child = [ child ]; - } - - var anim = this.get(key); - - if (!anim) - { - return; - } - - for (var i = 0; i < child.length; i++) - { - child[i].anims.play(key); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#remove - * @fires RemoveAnimationEvent - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Animations.Animation} [description] - */ - remove: function (key) - { - var anim = this.get(key); - - if (anim) - { - this.emit('remove', key, anim); - - this.anims.delete(key); - } - - return anim; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#resumeAll - * @fires ResumeAllAnimationEvent - * @since 3.0.0 - * - * @return {Phaser.Animations.AnimationManager} This Animation Manager. - */ - resumeAll: function () - { - if (this.paused) - { - this.paused = false; - - this.emit('resumeall'); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#staggerPlay - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {Phaser.GameObjects.GameObject} child - [description] - * @param {number} [stagger=0] - [description] - * - * @return {Phaser.Animations.AnimationManager} This Animation Manager. - */ - staggerPlay: function (key, child, stagger) - { - if (stagger === undefined) { stagger = 0; } - - if (!Array.isArray(child)) - { - child = [ child ]; - } - - var anim = this.get(key); - - if (!anim) - { - return; - } - - for (var i = 0; i < child.length; i++) - { - child[i].anims.delayedPlay(stagger * i, key); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#toJSON - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {object} [description] - */ - toJSON: function (key) - { - if (key !== undefined && key !== '') - { - return this.anims.get(key).toJSON(); - } - else - { - var output = { - anims: [], - globalTimeScale: this.globalTimeScale - }; - - this.anims.each(function (animationKey, animation) - { - output.anims.push(animation.toJSON()); - }); - - return output; - } - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#destroy + * @name Phaser.Physics.Impact.TYPES.BOTH + * @type {integer} * @since 3.0.0 */ - destroy: function () - { - this.anims.clear(); + BOTH: 3 - this.textureManager = null; - - this.game = null; - } - -}); - -module.exports = AnimationManager; +}; /***/ }), @@ -42327,70 +47353,67 @@ module.exports = AnimationManager; */ /** - * Takes the given string and pads it out, to the length required, using the character - * specified. For example if you need a string to be 6 characters long, you can call: + * Collision Types - Determine if and how entities collide with each other. * - * `pad('bob', 6, '-', 2)` + * In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves, + * while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE + * collisions, both entities are moved. LITE or PASSIVE entities don't collide + * with other LITE or PASSIVE entities at all. The behavior for FIXED vs. + * FIXED collisions is undefined. * - * This would return: `bob---` as it has padded it out to 6 characters, using the `-` on the right. - * - * You can also use it to pad numbers (they are always returned as strings): - * - * `pad(512, 6, '0', 1)` - * - * Would return: `000512` with the string padded to the left. - * - * If you don't specify a direction it'll pad to both sides: - * - * `pad('c64', 7, '*')` - * - * Would return: `**c64**` - * - * @function Phaser.Utils.String.Pad + * @name Phaser.Physics.Impact.COLLIDES + * @type {object} * @since 3.0.0 - * - * @param {string} str - The target string. `toString()` will be called on the string, which means you can also pass in common data types like numbers. - * @param {integer} [len=0] - The number of characters to be added. - * @param {string} [pad=" "] - The string to pad it out with (defaults to a space). - * @param {integer} [dir=3] - The direction dir = 1 (left), 2 (right), 3 (both). - * - * @return {string} The padded string. */ -var Pad = function (str, len, pad, dir) -{ - if (len === undefined) { len = 0; } - if (pad === undefined) { pad = ' '; } - if (dir === undefined) { dir = 3; } +module.exports = { - str = str.toString(); + /** + * Never collides. + * + * @name Phaser.Physics.Impact.COLLIDES.NEVER + * @type {integer} + * @since 3.0.0 + */ + NEVER: 0, - var padlen = 0; + /** + * Lite collision. + * + * @name Phaser.Physics.Impact.COLLIDES.LITE + * @type {integer} + * @since 3.0.0 + */ + LITE: 1, - if (len + 1 >= str.length) - { - switch (dir) - { - case 1: - str = new Array(len + 1 - str.length).join(pad) + str; - break; + /** + * Passive collision. + * + * @name Phaser.Physics.Impact.COLLIDES.PASSIVE + * @type {integer} + * @since 3.0.0 + */ + PASSIVE: 2, - case 3: - var right = Math.ceil((padlen = len - str.length) / 2); - var left = padlen - right; - str = new Array(left + 1).join(pad) + str + new Array(right + 1).join(pad); - break; + /** + * Active collision. + * + * @name Phaser.Physics.Impact.COLLIDES.ACTIVE + * @type {integer} + * @since 3.0.0 + */ + ACTIVE: 4, - default: - str = str + new Array(len + 1 - str.length).join(pad); - break; - } - } + /** + * Fixed collision. + * + * @name Phaser.Physics.Impact.COLLIDES.FIXED + * @type {integer} + * @since 3.0.0 + */ + FIXED: 8 - return str; }; -module.exports = Pad; - /***/ }), /* 201 */ @@ -42402,452 +47425,854 @@ module.exports = Pad; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var CircleContains = __webpack_require__(28); var Class = __webpack_require__(0); -var CustomMap = __webpack_require__(114); -var EventEmitter = __webpack_require__(14); +var CONST = __webpack_require__(47); +var RectangleContains = __webpack_require__(27); +var Vector2 = __webpack_require__(6); /** * @classdesc - * The BaseCache is a base Cache class that can be used for storing references to any kind of data. + * [description] * - * Data can be added, retrieved and removed based on the given keys. - * - * Keys are string-based. - * - * @class BaseCache - * @memberOf Phaser.Cache + * @class StaticBody + * @memberOf Phaser.Physics.Arcade * @constructor * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - [description] */ -var BaseCache = new Class({ +var StaticBody = new Class({ initialize: - function BaseCache () + function StaticBody (world, gameObject) { /** - * The Map in which the cache objects are stored. + * [description] * - * You can query the Map directly or use the BaseCache methods. - * - * @name Phaser.Cache.BaseCache#entries - * @type {Phaser.Structs.Map} + * @name Phaser.Physics.Arcade.StaticBody#world + * @type {Phaser.Physics.Arcade.World} * @since 3.0.0 */ - this.entries = new CustomMap(); + this.world = world; /** - * An instance of EventEmitter used by the cache to emit related events. + * [description] * - * @name Phaser.Cache.BaseCache#events - * @type {EventEmitter} + * @name Phaser.Physics.Arcade.StaticBody#gameObject + * @type {Phaser.GameObjects.GameObject} * @since 3.0.0 */ - this.events = new EventEmitter(); + this.gameObject = gameObject; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#debugShowBody + * @type {boolean} + * @since 3.0.0 + */ + this.debugShowBody = world.defaults.debugShowStaticBody; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#debugBodyColor + * @type {integer} + * @since 3.0.0 + */ + this.debugBodyColor = world.defaults.staticBodyDebugColor; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#enable + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.enable = true; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#isCircle + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isCircle = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#radius + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.radius = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#offset + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.offset = new Vector2(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#position + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.position = new Vector2(gameObject.x - gameObject.displayOriginX, gameObject.y - gameObject.displayOriginY); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#width + * @type {number} + * @since 3.0.0 + */ + this.width = gameObject.displayWidth; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#height + * @type {number} + * @since 3.0.0 + */ + this.height = gameObject.displayHeight; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#halfWidth + * @type {number} + * @since 3.0.0 + */ + this.halfWidth = Math.abs(this.width / 2); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#halfHeight + * @type {number} + * @since 3.0.0 + */ + this.halfHeight = Math.abs(this.height / 2); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#center + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#velocity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.velocity = Vector2.ZERO; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#allowGravity + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.allowGravity = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#gravity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.gravity = Vector2.ZERO; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#bounce + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.bounce = Vector2.ZERO; + + // If true this Body will dispatch events + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#onWorldBounds + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.onWorldBounds = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#onCollide + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.onCollide = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#onOverlap + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.onOverlap = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#mass + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.mass = 1; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#immovable + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.immovable = true; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#customSeparateX + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customSeparateX = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#customSeparateY + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customSeparateY = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#overlapX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapX = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#overlapY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapY = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#overlapR + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapR = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#embedded + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.embedded = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#collideWorldBounds + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.collideWorldBounds = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#checkCollision + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.checkCollision = { none: false, up: true, down: true, left: true, right: true }; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#touching + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.touching = { none: true, up: false, down: false, left: false, right: false }; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#wasTouching + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.wasTouching = { none: true, up: false, down: false, left: false, right: false }; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#blocked + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.blocked = { none: true, up: false, down: false, left: false, right: false }; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#physicsType + * @type {integer} + * @since 3.0.0 + */ + this.physicsType = CONST.STATIC_BODY; }, /** - * Cache add event. + * Changes the Game Object this Body is bound to. + * First it removes its reference from the old Game Object, then sets the new one. + * You can optionally update the position and dimensions of this Body to reflect that of the new Game Object. * - * This event is fired by the Cache each time a new object is added to it. + * @method Phaser.Physics.Arcade.StaticBody#setGameObject + * @since 3.1.0 * - * @event Phaser.Cache.BaseCache#addEvent - * @param {Phaser.Cache.BaseCache} The BaseCache to which the object was added. - * @param {string} The key of the object added to the cache. - * @param {any} A reference to the object added to the cache. + * @param {Phaser.GameObjects.GameObject} gameObject - The new Game Object that will own this Body. + * @param {boolean} [update=true] - Reposition and resize this Body to match the new Game Object? + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. */ - - /** - * Adds an item to this cache. The item is referenced by a unique string, which you are responsible - * for setting and keeping track of. The item can only be retrieved by using this string. - * - * @method Phaser.Cache.BaseCache#add - * @fires Phaser.Cache.BaseCache#addEvent - * @since 3.0.0 - * - * @param {string} key - The unique key by which the data added to the cache will be referenced. - * @param {any} data - The data to be stored in the cache. - * - * @return {Phaser.Cache.BaseCache} This BaseCache object. - */ - add: function (key, data) + setGameObject: function (gameObject, update) { - this.entries.set(key, data); - - this.events.emit('add', this, key, data); - - return this; - }, - - /** - * Checks if this cache contains an item matching the given key. - * - * @method Phaser.Cache.BaseCache#has - * @since 3.0.0 - * - * @param {string} key - The unique key of the item to be checked in this cache. - * - * @return {boolean} Returns `true` if the cache contains an item matching the given key, otherwise `false`. - */ - has: function (key) - { - return this.entries.has(key); - }, - - /** - * Gets an item from this cache based on the given key. - * - * @method Phaser.Cache.BaseCache#get - * @since 3.0.0 - * - * @param {string} key - The unique key of the item to be retrieved from this cache. - * - * @return {any} The item in the cache, or `null` if no item matching the given key was found. - */ - get: function (key) - { - return this.entries.get(key); - }, - - /** - * Cache remove event. - * - * This event is fired by the Cache each time an object is removed from it. - * - * @event Phaser.Cache.BaseCache#removeEvent - * @param {Phaser.Cache.BaseCache} The BaseCache from which the object was removed. - * @param {string} The key of the object removed from the cache. - * @param {any} The object that was removed from the cache. - */ - - /** - * Removes and item from this cache based on the given key. - * - * If an entry matching the key is found it is removed from the cache and a `remove` event emitted. - * No additional checks are done on the item removed. If other systems or parts of your game code - * are relying on this item, it is up to you to sever those relationships prior to removing the item. - * - * @method Phaser.Cache.BaseCache#remove - * @fires Phaser.Cache.BaseCache#removeEvent - * @since 3.0.0 - * - * @param {string} key - The unique key of the item to remove from the cache. - * - * @return {Phaser.Cache.BaseCache} This BaseCache object. - */ - remove: function (key) - { - var entry = this.get(key); - - if (entry) + if (gameObject && gameObject !== this.gameObject) { - this.entries.delete(key); + // Remove this body from the old game object + this.gameObject.body = null; - this.events.emit('remove', this, key, entry.data); + gameObject.body = this; + + // Update our reference + this.gameObject = gameObject; + } + + if (update) + { + this.updateFromGameObject(); } return this; }, /** - * Destroys this cache and all items within it. + * Updates this Static Body so that its position and dimensions are updated + * based on the current Game Object it is bound to. * - * @method Phaser.Cache.BaseCache#destroy + * @method Phaser.Physics.Arcade.StaticBody#updateFromGameObject + * @since 3.1.0 + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + updateFromGameObject: function () + { + this.world.staticTree.remove(this); + + var gameObject = this.gameObject; + + gameObject.getTopLeft(this.position); + + this.width = gameObject.displayWidth; + this.height = gameObject.displayHeight; + + this.halfWidth = Math.abs(this.width / 2); + this.halfHeight = Math.abs(this.height / 2); + + this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); + + this.world.staticTree.insert(this); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#setSize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * @param {number} [offsetX] - [description] + * @param {number} [offsetY] - [description] + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + setSize: function (width, height, offsetX, offsetY) + { + if (offsetX === undefined) { offsetX = this.offset.x; } + if (offsetY === undefined) { offsetY = this.offset.y; } + + this.world.staticTree.remove(this); + + this.width = width; + this.height = height; + + this.halfWidth = Math.floor(width / 2); + this.halfHeight = Math.floor(height / 2); + + this.offset.set(offsetX, offsetY); + + this.updateCenter(); + + this.isCircle = false; + this.radius = 0; + + this.world.staticTree.insert(this); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#setCircle + * @since 3.0.0 + * + * @param {number} radius - [description] + * @param {number} [offsetX] - [description] + * @param {number} [offsetY] - [description] + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + setCircle: function (radius, offsetX, offsetY) + { + if (offsetX === undefined) { offsetX = this.offset.x; } + if (offsetY === undefined) { offsetY = this.offset.y; } + + if (radius > 0) + { + this.world.staticTree.remove(this); + + this.isCircle = true; + + this.radius = radius; + + this.width = radius * 2; + this.height = radius * 2; + + this.halfWidth = Math.floor(this.width / 2); + this.halfHeight = Math.floor(this.height / 2); + + this.offset.set(offsetX, offsetY); + + this.updateCenter(); + + this.world.staticTree.insert(this); + } + else + { + this.isCircle = false; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#updateCenter + * @since 3.0.0 + */ + updateCenter: function () + { + this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#reset + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + */ + reset: function (x, y) + { + var gameObject = this.gameObject; + + if (x === undefined) { x = gameObject.x; } + if (y === undefined) { y = gameObject.y; } + + this.world.staticTree.remove(this); + + gameObject.getTopLeft(this.position); + + this.updateCenter(); + + this.world.staticTree.insert(this); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#stop + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + stop: function () + { + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#getBounds + * @since 3.0.0 + * + * @param {ArcadeBodyBounds} obj - [description] + * + * @return {ArcadeBodyBounds} [description] + */ + getBounds: function (obj) + { + obj.x = this.x; + obj.y = this.y; + obj.right = this.right; + obj.bottom = this.bottom; + + return obj; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#hitTest + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ + hitTest: function (x, y) + { + return (this.isCircle) ? CircleContains(this, x, y) : RectangleContains(this, x, y); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#deltaAbsX + * @since 3.0.0 + * + * @return {number} [description] + */ + deltaAbsX: function () + { + return 0; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#deltaAbsY + * @since 3.0.0 + * + * @return {number} [description] + */ + deltaAbsY: function () + { + return 0; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#deltaX + * @since 3.0.0 + * + * @return {number} [description] + */ + deltaX: function () + { + return 0; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#deltaY + * @since 3.0.0 + * + * @return {number} [description] + */ + deltaY: function () + { + return 0; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#deltaZ + * @since 3.0.0 + * + * @return {number} [description] + */ + deltaZ: function () + { + return 0; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#destroy * @since 3.0.0 */ destroy: function () { - this.entries.clear(); - this.events.removeAllListeners(); + this.enable = false; + + this.world.pendingDestroy.set(this); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#drawDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphic - [description] + */ + drawDebug: function (graphic) + { + var pos = this.position; + + if (this.debugShowBody) + { + graphic.lineStyle(1, this.debugBodyColor, 1); + graphic.strokeRect(pos.x, pos.y, this.width, this.height); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#willDrawDebug + * @since 3.0.0 + * + * @return {boolean} [description] + */ + willDrawDebug: function () + { + return this.debugShowBody; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#setMass + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + setMass: function (value) + { + if (value <= 0) + { + // Causes havoc otherwise + value = 0.1; + } + + this.mass = value; + + return this; + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.position.x; + }, + + set: function (value) + { + this.world.staticTree.remove(this); + + this.position.x = value; + + this.world.staticTree.insert(this); + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.position.y; + }, + + set: function (value) + { + this.world.staticTree.remove(this); + + this.position.y = value; + + this.world.staticTree.insert(this); + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#left + * @type {number} + * @readOnly + * @since 3.0.0 + */ + left: { + + get: function () + { + return this.position.x; + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#right + * @type {number} + * @readOnly + * @since 3.0.0 + */ + right: { + + get: function () + { + return this.position.x + this.width; + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#top + * @type {number} + * @readOnly + * @since 3.0.0 + */ + top: { + + get: function () + { + return this.position.y; + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#bottom + * @type {number} + * @readOnly + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return this.position.y + this.height; + } - this.entries = null; - this.events = null; } }); -module.exports = BaseCache; +module.exports = StaticBody; /***/ }), /* 202 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BaseCache = __webpack_require__(201); -var Class = __webpack_require__(0); - -/** - * @classdesc - * The Cache Manager is the global cache owned and maintained by the Game instance. - * - * Various systems, such as the file Loader, rely on this cache in order to store the files - * it has loaded. The manager itself doesn't store any files, but instead owns multiple BaseCache - * instances, one per type of file. You can also add your own custom caches. - * - * @class CacheManager - * @memberOf Phaser.Cache - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - A reference to the Phaser.Game instance that owns this CacheManager. - */ -var CacheManager = new Class({ - - initialize: - - function CacheManager (game) - { - /** - * A reference to the Phaser.Game instance that owns this CacheManager. - * - * @name Phaser.Cache.CacheManager#game - * @type {Phaser.Game} - * @protected - * @since 3.0.0 - */ - this.game = game; - - /** - * A Cache storing all binary files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#binary - * @type {Phaser.Cache.BaseCache} - * @protected - * @since 3.0.0 - */ - this.binary = new BaseCache(); - - /** - * A Cache storing all bitmap font data files, typically added via the Loader. - * Only the font data is stored in this cache, the textures are part of the Texture Manager. - * - * @name Phaser.Cache.CacheManager#bitmapFont - * @type {Phaser.Cache.BaseCache} - * @protected - * @since 3.0.0 - */ - this.bitmapFont = new BaseCache(); - - /** - * A Cache storing all JSON data files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#json - * @type {Phaser.Cache.BaseCache} - * @protected - * @since 3.0.0 - */ - this.json = new BaseCache(); - - /** - * A Cache storing all physics data files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#physics - * @type {Phaser.Cache.BaseCache} - * @protected - * @since 3.0.0 - */ - this.physics = new BaseCache(); - - /** - * A Cache storing all shader source files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#shader - * @type {Phaser.Cache.BaseCache} - * @protected - * @since 3.0.0 - */ - this.shader = new BaseCache(); - - /** - * A Cache storing all non-streaming audio files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#audio - * @type {Phaser.Cache.BaseCache} - * @protected - * @since 3.0.0 - */ - this.audio = new BaseCache(); - - /** - * A Cache storing all text files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#text - * @type {Phaser.Cache.BaseCache} - * @protected - * @since 3.0.0 - */ - this.text = new BaseCache(); - - /** - * A Cache storing all WaveFront OBJ files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#obj - * @type {Phaser.Cache.BaseCache} - * @protected - * @since 3.0.0 - */ - this.obj = new BaseCache(); - - /** - * A Cache storing all tilemap data files, typically added via the Loader. - * Only the data is stored in this cache, the textures are part of the Texture Manager. - * - * @name Phaser.Cache.CacheManager#tilemap - * @type {Phaser.Cache.BaseCache} - * @protected - * @since 3.0.0 - */ - this.tilemap = new BaseCache(); - - /** - * A Cache storing all xml data files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#xml - * @type {Phaser.Cache.BaseCache} - * @protected - * @since 3.0.0 - */ - this.xml = new BaseCache(); - - /** - * An object that contains your own custom BaseCache entries. - * Add to this via the `addCustom` method. - * - * @name Phaser.Cache.CacheManager#custom - * @type {object.} - * @protected - * @since 3.0.0 - */ - this.custom = {}; - - this.game.events.once('destroy', this.destroy, this); - }, - - /** - * Add your own custom Cache for storing your own files. - * The cache will be available under `Cache.custom.key`. - * The cache will only be created if the key is not already in use. - * - * @method Phaser.Cache.CacheManager#addCustom - * @since 3.0.0 - * - * @param {string} key - The unique key of your custom cache. - * - * @return {Phaser.Cache.BaseCache} A reference to the BaseCache that was created. If the key was already in use, a reference to the existing cache is returned instead. - */ - addCustom: function (key) - { - if (!this.custom.hasOwnProperty(key)) - { - this.custom[key] = new BaseCache(); - } - - return this.custom[key]; - }, - - /** - * Removes all entries from all BaseCaches and destroys all custom caches. - * - * @method Phaser.Cache.CacheManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - var keys = [ - 'binary', - 'bitmapFont', - 'json', - 'physics', - 'shader', - 'audio', - 'text', - 'obj', - 'tilemap', - 'xml' - ]; - - for (var i = 0; i < keys.length; i++) - { - this[keys[i]].destroy(); - this[keys[i]] = null; - } - - for (var key in this.custom) - { - this.custom[key].destroy(); - } - - this.custom = null; - - this.game = null; - } - -}); - -module.exports = CacheManager; - - -/***/ }), -/* 203 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Color = __webpack_require__(36); - -/** - * Converts a hex string into a Phaser Color object. - * - * The hex string can supplied as `'#0033ff'` or the short-hand format of `'#03f'`; it can begin with an optional "#" or "0x", or be unprefixed. - * - * An alpha channel is _not_ supported. - * - * @function Phaser.Display.Color.HexStringToColor - * @since 3.0.0 - * - * @param {string} hex - The hex color value to convert, such as `#0033ff` or the short-hand format: `#03f`. - * - * @return {Phaser.Display.Color} A Color object populated by the values of the given string. - */ -var HexStringToColor = function (hex) -{ - var color = new Color(); - - // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") - hex = hex.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) - { - return r + r + g + g + b + b; - }); - - var result = (/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i).exec(hex); - - if (result) - { - var r = parseInt(result[1], 16); - var g = parseInt(result[2], 16); - var b = parseInt(result[3], 16); - - color.setTo(r, g, b); - } - - return color; -}; - -module.exports = HexStringToColor; - - -/***/ }), -/* 204 */ /***/ (function(module, exports) { /** @@ -42857,24 +48282,757 @@ module.exports = HexStringToColor; */ /** - * Given an alpha and 3 color values this will return an integer representation of it. + * [description] * - * @function Phaser.Display.Color.GetColor32 + * @function Phaser.Physics.Arcade.Tilemap.TileIntersectsBody * @since 3.0.0 * - * @param {integer} red - The red color value. A number between 0 and 255. - * @param {integer} green - The green color value. A number between 0 and 255. - * @param {integer} blue - The blue color value. A number between 0 and 255. - * @param {integer} alpha - The alpha color value. A number between 0 and 255. + * @param {{ left: number, right: number, top: number, bottom: number }} tileWorldRect - [description] + * @param {Phaser.Physics.Arcade.Body} body - [description] * - * @return {number} The combined color value. + * @return {boolean} [description] */ -var GetColor32 = function (red, green, blue, alpha) +var TileIntersectsBody = function (tileWorldRect, body) { - return alpha << 24 | red << 16 | green << 8 | blue; + // Currently, all bodies are treated as rectangles when colliding with a Tile. Eventually, this + // should support circle bodies when those are less buggy in v3. + + return !( + body.right <= tileWorldRect.left || + body.bottom <= tileWorldRect.top || + body.position.x >= tileWorldRect.right || + body.position.y >= tileWorldRect.bottom + ); }; -module.exports = GetColor32; +module.exports = TileIntersectsBody; + + +/***/ }), +/* 203 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// This is from the quickselect npm package: https://www.npmjs.com/package/quickselect +// Coded by https://www.npmjs.com/~mourner (Vladimir Agafonkin) + +// https://en.wikipedia.org/wiki/Floyd%E2%80%93Rivest_algorithm + +// Floyd-Rivest selection algorithm: +// Rearrange items so that all items in the [left, k] range are smaller than all items in (k, right]; +// The k-th element will have the (k - left + 1)th smallest value in [left, right] + +/** + * [description] + * + * @function Phaser.Utils.Array.QuickSelect + * @since 3.0.0 + * + * @param {array} arr - [description] + * @param {number} k - [description] + * @param {number} left - [description] + * @param {number} right - [description] + * @param {function} compare - [description] + */ +var QuickSelect = function (arr, k, left, right, compare) +{ + left = left || 0; + right = right || (arr.length - 1); + compare = compare || defaultCompare; + + while (right > left) + { + if (right - left > 600) + { + var n = right - left + 1; + var m = k - left + 1; + var z = Math.log(n); + var s = 0.5 * Math.exp(2 * z / 3); + var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1); + var newLeft = Math.max(left, Math.floor(k - m * s / n + sd)); + var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd)); + + QuickSelect(arr, k, newLeft, newRight, compare); + } + + var t = arr[k]; + var i = left; + var j = right; + + swap(arr, left, k); + + if (compare(arr[right], t) > 0) + { + swap(arr, left, right); + } + + while (i < j) + { + swap(arr, i, j); + + i++; + j--; + + while (compare(arr[i], t) < 0) + { + i++; + } + + while (compare(arr[j], t) > 0) + { + j--; + } + } + + if (compare(arr[left], t) === 0) + { + swap(arr, left, j); + } + else + { + j++; + swap(arr, j, right); + } + + if (j <= k) + { + left = j + 1; + } + + if (k <= j) + { + right = j - 1; + } + } +}; + +function swap (arr, i, j) +{ + var tmp = arr[i]; + arr[i] = arr[j]; + arr[j] = tmp; +} + +function defaultCompare (a, b) +{ + return a < b ? -1 : a > b ? 1 : 0; +} + +module.exports = QuickSelect; + + +/***/ }), +/* 204 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var quickselect = __webpack_require__(203); + +/** + * @classdesc + * RBush is a high-performance JavaScript library for 2D spatial indexing of points and rectangles. + * It's based on an optimized R-tree data structure with bulk insertion support. + * + * Spatial index is a special data structure for points and rectangles that allows you to perform queries like + * "all items within this bounding box" very efficiently (e.g. hundreds of times faster than looping over all items). + * + * @class RTree + * @memberOf Phaser.Structs + * @constructor + * @since 3.0.0 + */ + +function rbush (maxEntries, format) +{ + if (!(this instanceof rbush)) return new rbush(maxEntries, format); + + // max entries in a node is 9 by default; min node fill is 40% for best performance + this._maxEntries = Math.max(4, maxEntries || 9); + this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)); + + if (format) + { + this._initFormat(format); + } + + this.clear(); +} + +rbush.prototype = { + + all: function () + { + return this._all(this.data, []); + }, + + search: function (bbox) + { + var node = this.data, + result = [], + toBBox = this.toBBox; + + if (!intersects(bbox, node)) return result; + + var nodesToSearch = [], + i, len, child, childBBox; + + while (node) { + for (i = 0, len = node.children.length; i < len; i++) { + + child = node.children[i]; + childBBox = node.leaf ? toBBox(child) : child; + + if (intersects(bbox, childBBox)) { + if (node.leaf) result.push(child); + else if (contains(bbox, childBBox)) this._all(child, result); + else nodesToSearch.push(child); + } + } + node = nodesToSearch.pop(); + } + + return result; + }, + + collides: function (bbox) + { + var node = this.data, + toBBox = this.toBBox; + + if (!intersects(bbox, node)) return false; + + var nodesToSearch = [], + i, len, child, childBBox; + + while (node) { + for (i = 0, len = node.children.length; i < len; i++) { + + child = node.children[i]; + childBBox = node.leaf ? toBBox(child) : child; + + if (intersects(bbox, childBBox)) { + if (node.leaf || contains(bbox, childBBox)) return true; + nodesToSearch.push(child); + } + } + node = nodesToSearch.pop(); + } + + return false; + }, + + load: function (data) + { + if (!(data && data.length)) return this; + + if (data.length < this._minEntries) { + for (var i = 0, len = data.length; i < len; i++) { + this.insert(data[i]); + } + return this; + } + + // recursively build the tree with the given data from scratch using OMT algorithm + var node = this._build(data.slice(), 0, data.length - 1, 0); + + if (!this.data.children.length) { + // save as is if tree is empty + this.data = node; + + } else if (this.data.height === node.height) { + // split root if trees have the same height + this._splitRoot(this.data, node); + + } else { + if (this.data.height < node.height) { + // swap trees if inserted one is bigger + var tmpNode = this.data; + this.data = node; + node = tmpNode; + } + + // insert the small tree into the large tree at appropriate level + this._insert(node, this.data.height - node.height - 1, true); + } + + return this; + }, + + insert: function (item) + { + if (item) this._insert(item, this.data.height - 1); + return this; + }, + + clear: function () + { + this.data = createNode([]); + return this; + }, + + remove: function (item, equalsFn) + { + if (!item) return this; + + var node = this.data, + bbox = this.toBBox(item), + path = [], + indexes = [], + i, parent, index, goingUp; + + // depth-first iterative tree traversal + while (node || path.length) { + + if (!node) { // go up + node = path.pop(); + parent = path[path.length - 1]; + i = indexes.pop(); + goingUp = true; + } + + if (node.leaf) { // check current node + index = findItem(item, node.children, equalsFn); + + if (index !== -1) { + // item found, remove the item and condense tree upwards + node.children.splice(index, 1); + path.push(node); + this._condense(path); + return this; + } + } + + if (!goingUp && !node.leaf && contains(node, bbox)) { // go down + path.push(node); + indexes.push(i); + i = 0; + parent = node; + node = node.children[0]; + + } else if (parent) { // go right + i++; + node = parent.children[i]; + goingUp = false; + + } else node = null; // nothing found + } + + return this; + }, + + toBBox: function (item) { return item; }, + + compareMinX: compareNodeMinX, + compareMinY: compareNodeMinY, + + toJSON: function () { return this.data; }, + + fromJSON: function (data) + { + this.data = data; + return this; + }, + + _all: function (node, result) + { + var nodesToSearch = []; + while (node) { + if (node.leaf) result.push.apply(result, node.children); + else nodesToSearch.push.apply(nodesToSearch, node.children); + + node = nodesToSearch.pop(); + } + return result; + }, + + _build: function (items, left, right, height) + { + var N = right - left + 1, + M = this._maxEntries, + node; + + if (N <= M) { + // reached leaf level; return leaf + node = createNode(items.slice(left, right + 1)); + calcBBox(node, this.toBBox); + return node; + } + + if (!height) { + // target height of the bulk-loaded tree + height = Math.ceil(Math.log(N) / Math.log(M)); + + // target number of root entries to maximize storage utilization + M = Math.ceil(N / Math.pow(M, height - 1)); + } + + node = createNode([]); + node.leaf = false; + node.height = height; + + // split the items into M mostly square tiles + + var N2 = Math.ceil(N / M), + N1 = N2 * Math.ceil(Math.sqrt(M)), + i, j, right2, right3; + + multiSelect(items, left, right, N1, this.compareMinX); + + for (i = left; i <= right; i += N1) { + + right2 = Math.min(i + N1 - 1, right); + + multiSelect(items, i, right2, N2, this.compareMinY); + + for (j = i; j <= right2; j += N2) { + + right3 = Math.min(j + N2 - 1, right2); + + // pack each entry recursively + node.children.push(this._build(items, j, right3, height - 1)); + } + } + + calcBBox(node, this.toBBox); + + return node; + }, + + _chooseSubtree: function (bbox, node, level, path) + { + var i, len, child, targetNode, area, enlargement, minArea, minEnlargement; + + while (true) { + path.push(node); + + if (node.leaf || path.length - 1 === level) break; + + minArea = minEnlargement = Infinity; + + for (i = 0, len = node.children.length; i < len; i++) { + child = node.children[i]; + area = bboxArea(child); + enlargement = enlargedArea(bbox, child) - area; + + // choose entry with the least area enlargement + if (enlargement < minEnlargement) { + minEnlargement = enlargement; + minArea = area < minArea ? area : minArea; + targetNode = child; + + } else if (enlargement === minEnlargement) { + // otherwise choose one with the smallest area + if (area < minArea) { + minArea = area; + targetNode = child; + } + } + } + + node = targetNode || node.children[0]; + } + + return node; + }, + + _insert: function (item, level, isNode) + { + var toBBox = this.toBBox, + bbox = isNode ? item : toBBox(item), + insertPath = []; + + // find the best node for accommodating the item, saving all nodes along the path too + var node = this._chooseSubtree(bbox, this.data, level, insertPath); + + // put the item into the node + node.children.push(item); + extend(node, bbox); + + // split on node overflow; propagate upwards if necessary + while (level >= 0) { + if (insertPath[level].children.length > this._maxEntries) { + this._split(insertPath, level); + level--; + } else break; + } + + // adjust bboxes along the insertion path + this._adjustParentBBoxes(bbox, insertPath, level); + }, + + // split overflowed node into two + _split: function (insertPath, level) + { + var node = insertPath[level], + M = node.children.length, + m = this._minEntries; + + this._chooseSplitAxis(node, m, M); + + var splitIndex = this._chooseSplitIndex(node, m, M); + + var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex)); + newNode.height = node.height; + newNode.leaf = node.leaf; + + calcBBox(node, this.toBBox); + calcBBox(newNode, this.toBBox); + + if (level) insertPath[level - 1].children.push(newNode); + else this._splitRoot(node, newNode); + }, + + _splitRoot: function (node, newNode) + { + // split root node + this.data = createNode([node, newNode]); + this.data.height = node.height + 1; + this.data.leaf = false; + calcBBox(this.data, this.toBBox); + }, + + _chooseSplitIndex: function (node, m, M) + { + var i, bbox1, bbox2, overlap, area, minOverlap, minArea, index; + + minOverlap = minArea = Infinity; + + for (i = m; i <= M - m; i++) { + bbox1 = distBBox(node, 0, i, this.toBBox); + bbox2 = distBBox(node, i, M, this.toBBox); + + overlap = intersectionArea(bbox1, bbox2); + area = bboxArea(bbox1) + bboxArea(bbox2); + + // choose distribution with minimum overlap + if (overlap < minOverlap) { + minOverlap = overlap; + index = i; + + minArea = area < minArea ? area : minArea; + + } else if (overlap === minOverlap) { + // otherwise choose distribution with minimum area + if (area < minArea) { + minArea = area; + index = i; + } + } + } + + return index; + }, + + // sorts node children by the best axis for split + _chooseSplitAxis: function (node, m, M) + { + var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX, + compareMinY = node.leaf ? this.compareMinY : compareNodeMinY, + xMargin = this._allDistMargin(node, m, M, compareMinX), + yMargin = this._allDistMargin(node, m, M, compareMinY); + + // if total distributions margin value is minimal for x, sort by minX, + // otherwise it's already sorted by minY + if (xMargin < yMargin) node.children.sort(compareMinX); + }, + + // total margin of all possible split distributions where each node is at least m full + _allDistMargin: function (node, m, M, compare) + { + node.children.sort(compare); + + var toBBox = this.toBBox, + leftBBox = distBBox(node, 0, m, toBBox), + rightBBox = distBBox(node, M - m, M, toBBox), + margin = bboxMargin(leftBBox) + bboxMargin(rightBBox), + i, child; + + for (i = m; i < M - m; i++) { + child = node.children[i]; + extend(leftBBox, node.leaf ? toBBox(child) : child); + margin += bboxMargin(leftBBox); + } + + for (i = M - m - 1; i >= m; i--) { + child = node.children[i]; + extend(rightBBox, node.leaf ? toBBox(child) : child); + margin += bboxMargin(rightBBox); + } + + return margin; + }, + + _adjustParentBBoxes: function (bbox, path, level) + { + // adjust bboxes along the given tree path + for (var i = level; i >= 0; i--) { + extend(path[i], bbox); + } + }, + + _condense: function (path) + { + // go through the path, removing empty nodes and updating bboxes + for (var i = path.length - 1, siblings; i >= 0; i--) { + if (path[i].children.length === 0) { + if (i > 0) { + siblings = path[i - 1].children; + siblings.splice(siblings.indexOf(path[i]), 1); + + } else this.clear(); + + } else calcBBox(path[i], this.toBBox); + } + }, + + _initFormat: function (format) + { + // data format (minX, minY, maxX, maxY accessors) + + // uses eval-type function compilation instead of just accepting a toBBox function + // because the algorithms are very sensitive to sorting functions performance, + // so they should be dead simple and without inner calls + + var compareArr = ['return a', ' - b', ';']; + + this.compareMinX = new Function('a', 'b', compareArr.join(format[0])); + this.compareMinY = new Function('a', 'b', compareArr.join(format[1])); + + this.toBBox = new Function('a', + 'return {minX: a' + format[0] + + ', minY: a' + format[1] + + ', maxX: a' + format[2] + + ', maxY: a' + format[3] + '};'); + } +}; + +function findItem (item, items, equalsFn) +{ + if (!equalsFn) return items.indexOf(item); + + for (var i = 0; i < items.length; i++) { + if (equalsFn(item, items[i])) return i; + } + return -1; +} + +// calculate node's bbox from bboxes of its children +function calcBBox (node, toBBox) +{ + distBBox(node, 0, node.children.length, toBBox, node); +} + +// min bounding rectangle of node children from k to p-1 +function distBBox (node, k, p, toBBox, destNode) +{ + if (!destNode) destNode = createNode(null); + destNode.minX = Infinity; + destNode.minY = Infinity; + destNode.maxX = -Infinity; + destNode.maxY = -Infinity; + + for (var i = k, child; i < p; i++) { + child = node.children[i]; + extend(destNode, node.leaf ? toBBox(child) : child); + } + + return destNode; +} + +function extend (a, b) +{ + a.minX = Math.min(a.minX, b.minX); + a.minY = Math.min(a.minY, b.minY); + a.maxX = Math.max(a.maxX, b.maxX); + a.maxY = Math.max(a.maxY, b.maxY); + return a; +} + +function compareNodeMinX (a, b) { return a.minX - b.minX; } +function compareNodeMinY (a, b) { return a.minY - b.minY; } + +function bboxArea (a) { return (a.maxX - a.minX) * (a.maxY - a.minY); } +function bboxMargin (a) { return (a.maxX - a.minX) + (a.maxY - a.minY); } + +function enlargedArea (a, b) +{ + return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) * + (Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY)); +} + +function intersectionArea (a, b) +{ + var minX = Math.max(a.minX, b.minX), + minY = Math.max(a.minY, b.minY), + maxX = Math.min(a.maxX, b.maxX), + maxY = Math.min(a.maxY, b.maxY); + + return Math.max(0, maxX - minX) * + Math.max(0, maxY - minY); +} + +function contains (a, b) +{ + return a.minX <= b.minX && + a.minY <= b.minY && + b.maxX <= a.maxX && + b.maxY <= a.maxY; +} + +function intersects (a, b) +{ + return b.minX <= a.maxX && + b.minY <= a.maxY && + b.maxX >= a.minX && + b.maxY >= a.minY; +} + +function createNode (children) +{ + return { + children: children, + height: 1, + leaf: true, + minX: Infinity, + minY: Infinity, + maxX: -Infinity, + maxY: -Infinity + }; +} + +// sort an array so that items come in groups of n unsorted items, with groups sorted between each other; +// combines selection algorithm with binary divide & conquer approach + +function multiSelect (arr, left, right, n, compare) +{ + var stack = [left, right], + mid; + + while (stack.length) + { + right = stack.pop(); + left = stack.pop(); + + if (right - left <= n) continue; + + mid = left + Math.ceil((right - left) / n / 2) * n; + quickselect(arr, mid, left, right, compare); + + stack.push(left, mid, mid, right); + } +} + +module.exports = rbush; /***/ }), @@ -42887,27 +49045,192 @@ module.exports = GetColor32; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Color = __webpack_require__(36); -var IntegerToRGB = __webpack_require__(206); +var Class = __webpack_require__(0); /** - * Converts the given color value into an instance of a Color object. + * @classdesc + * [description] * - * @function Phaser.Display.Color.IntegerToColor + * @class ProcessQueue + * @memberOf Phaser.Structs + * @constructor * @since 3.0.0 - * - * @param {integer} input - The color value to convert into a Color object. - * - * @return {Phaser.Display.Color} A Color object. */ -var IntegerToColor = function (input) -{ - var rgb = IntegerToRGB(input); +var ProcessQueue = new Class({ - return new Color(rgb.r, rgb.g, rgb.b, rgb.a); -}; + initialize: -module.exports = IntegerToColor; + function ProcessQueue () + { + /** + * [description] + * + * @name Phaser.Structs.ProcessQueue#_pending + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this._pending = []; + + /** + * [description] + * + * @name Phaser.Structs.ProcessQueue#_active + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this._active = []; + + /** + * [description] + * + * @name Phaser.Structs.ProcessQueue#_destroy + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this._destroy = []; + + /** + * [description] + * + * @name Phaser.Structs.ProcessQueue#_toProcess + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + this._toProcess = 0; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#add + * @since 3.0.0 + * + * @param {*} item - [description] + * + * @return {Phaser.Structs.ProcessQueue} This Process Queue object. + */ + add: function (item) + { + this._pending.push(item); + + this._toProcess++; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#remove + * @since 3.0.0 + * + * @param {*} item - [description] + * + * @return {Phaser.Structs.ProcessQueue} This Process Queue object. + */ + remove: function (item) + { + this._destroy.push(item); + + this._toProcess++; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#update + * @since 3.0.0 + * + * @return {array} [description] + */ + update: function () + { + if (this._toProcess === 0) + { + // Quick bail + return this._active; + } + + var list = this._destroy; + var active = this._active; + var i; + var item; + + // Clear the 'destroy' list + for (i = 0; i < list.length; i++) + { + item = list[i]; + + // Remove from the 'active' array + var idx = active.indexOf(item); + + if (idx !== -1) + { + active.splice(idx, 1); + } + } + + list.length = 0; + + // Process the pending addition list + // This stops callbacks and out of sync events from populating the active array mid-way during an update + + list = this._pending; + + for (i = 0; i < list.length; i++) + { + item = list[i]; + + this._active.push(item); + } + + list.length = 0; + + this._toProcess = 0; + + // The owner of this queue can now safely do whatever it needs to with the active list + return this._active; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#getActive + * @since 3.0.0 + * + * @return {array} [description] + */ + getActive: function () + { + return this._active; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#destroy + * @since 3.0.0 + */ + destroy: function () + { + this._pending = []; + this._active = []; + this._destroy = []; + } + +}); + +module.exports = ProcessQueue; /***/ }), @@ -42921,46 +49244,77 @@ module.exports = IntegerToColor; */ /** - * Return the component parts of a color as an Object with the properties alpha, red, green, blue. + * [description] * - * Alpha will only be set if it exists in the given color (0xAARRGGBB) - * - * @function Phaser.Display.Color.IntegerToRGB + * @function Phaser.Physics.Arcade.GetOverlapY * @since 3.0.0 * - * @param {integer} input - The color value to convert into a Color object. + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {boolean} overlapOnly - [description] + * @param {number} bias - [description] * - * @return {ColorObject} An object with the red, green and blue values set in the r, g and b properties. + * @return {number} [description] */ -var IntegerToRGB = function (color) +var GetOverlapY = function (body1, body2, overlapOnly, bias) { - if (color > 16777215) + var overlap = 0; + var maxOverlap = body1.deltaAbsY() + body2.deltaAbsY() + bias; + + if (body1.deltaY() === 0 && body2.deltaY() === 0) { - // The color value has an alpha component - return { - a: color >>> 24, - r: color >> 16 & 0xFF, - g: color >> 8 & 0xFF, - b: color & 0xFF - }; + // They overlap but neither of them are moving + body1.embedded = true; + body2.embedded = true; } - else + else if (body1.deltaY() > body2.deltaY()) { - return { - a: 255, - r: color >> 16 & 0xFF, - g: color >> 8 & 0xFF, - b: color & 0xFF - }; + // Body1 is moving down and/or Body2 is moving up + overlap = body1.bottom - body2.y; + + if ((overlap > maxOverlap && !overlapOnly) || body1.checkCollision.down === false || body2.checkCollision.up === false) + { + overlap = 0; + } + else + { + body1.touching.none = false; + body1.touching.down = true; + body2.touching.none = false; + body2.touching.up = true; + } } + else if (body1.deltaY() < body2.deltaY()) + { + // Body1 is moving up and/or Body2 is moving down + overlap = body1.y - body2.bottom; + + if ((-overlap > maxOverlap && !overlapOnly) || body1.checkCollision.up === false || body2.checkCollision.down === false) + { + overlap = 0; + } + else + { + body1.touching.none = false; + body1.touching.up = true; + body2.touching.none = false; + body2.touching.down = true; + } + } + + // Resets the overlapY to zero if there is no overlap, or to the actual pixel value if there is + body1.overlapY = overlap; + body2.overlapY = overlap; + + return overlap; }; -module.exports = IntegerToRGB; +module.exports = GetOverlapY; /***/ }), /* 207 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -42968,24 +49322,73 @@ module.exports = IntegerToRGB; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Color = __webpack_require__(36); - /** - * Converts an object containing `r`, `g`, `b` and `a` properties into a Color class instance. + * [description] * - * @function Phaser.Display.Color.ObjectToColor + * @function Phaser.Physics.Arcade.GetOverlapX * @since 3.0.0 * - * @param {object} input - An object containing `r`, `g`, `b` and `a` properties in the range 0 to 255. + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {boolean} overlapOnly - [description] + * @param {number} bias - [description] * - * @return {Phaser.Display.Color} A Color object. + * @return {number} [description] */ -var ObjectToColor = function (input) +var GetOverlapX = function (body1, body2, overlapOnly, bias) { - return new Color(input.r, input.g, input.b, input.a); + var overlap = 0; + var maxOverlap = body1.deltaAbsX() + body2.deltaAbsX() + bias; + + if (body1.deltaX() === 0 && body2.deltaX() === 0) + { + // They overlap but neither of them are moving + body1.embedded = true; + body2.embedded = true; + } + else if (body1.deltaX() > body2.deltaX()) + { + // Body1 is moving right and / or Body2 is moving left + overlap = body1.right - body2.x; + + if ((overlap > maxOverlap && !overlapOnly) || body1.checkCollision.right === false || body2.checkCollision.left === false) + { + overlap = 0; + } + else + { + body1.touching.none = false; + body1.touching.right = true; + body2.touching.none = false; + body2.touching.left = true; + } + } + else if (body1.deltaX() < body2.deltaX()) + { + // Body1 is moving left and/or Body2 is moving right + overlap = body1.x - body2.width - body2.x; + + if ((-overlap > maxOverlap && !overlapOnly) || body1.checkCollision.left === false || body2.checkCollision.right === false) + { + overlap = 0; + } + else + { + body1.touching.none = false; + body1.touching.left = true; + body2.touching.none = false; + body2.touching.right = true; + } + } + + // Resets the overlapX to zero if there is no overlap, or to the actual pixel value if there is + body1.overlapX = overlap; + body2.overlapX = overlap; + + return overlap; }; -module.exports = ObjectToColor; +module.exports = GetOverlapX; /***/ }), @@ -42998,121 +49401,178 @@ module.exports = ObjectToColor; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Color = __webpack_require__(36); +var Class = __webpack_require__(0); /** - * Converts a CSS 'web' string into a Phaser Color object. - * - * The web string can be in the format `'rgb(r,g,b)'` or `'rgba(r,g,b,a)'` where r/g/b are in the range [0..255] and a is in the range [0..1]. + * @classdesc + * [description] * - * @function Phaser.Display.Color.RGBStringToColor + * @class Collider + * @memberOf Phaser.Physics.Arcade + * @constructor * @since 3.0.0 * - * @param {string} rgb - The CSS format color string, using the `rgb` or `rgba` format. - * - * @return {Phaser.Display.Color} A Color object. + * @param {Phaser.Physics.Arcade.World} world - [description] + * @param {boolean} overlapOnly - [description] + * @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for collision. + * @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for collision. + * @param {ArcadePhysicsCallback} collideCallback - The callback to invoke when the two objects collide. + * @param {ArcadePhysicsCallback} processCallback - The callback to invoke when the two objects collide. Must return a boolean. + * @param {object} callbackContext - The scope in which to call the callbacks. */ -var RGBStringToColor = function (rgb) -{ - var color = new Color(); +var Collider = new Class({ - var result = (/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/).exec(rgb.toLowerCase()); + initialize: - if (result) + function Collider (world, overlapOnly, object1, object2, collideCallback, processCallback, callbackContext) { - var r = parseInt(result[1], 10); - var g = parseInt(result[2], 10); - var b = parseInt(result[3], 10); - var a = (result[4] !== undefined) ? parseFloat(result[4]) : 1; + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; - color.setTo(r, g, b, a * 255); + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#name + * @type {string} + * @since 3.1.0 + */ + this.name = ''; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#overlapOnly + * @type {boolean} + * @since 3.0.0 + */ + this.overlapOnly = overlapOnly; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#object1 + * @type {Phaser.Physics.Arcade.Body} + * @since 3.0.0 + */ + this.object1 = object1; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#object2 + * @type {Phaser.Physics.Arcade.Body} + * @since 3.0.0 + */ + this.object2 = object2; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#collideCallback + * @type {ArcadePhysicsCallback} + * @since 3.0.0 + */ + this.collideCallback = collideCallback; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#processCallback + * @type {ArcadePhysicsCallback} + * @since 3.0.0 + */ + this.processCallback = processCallback; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#callbackContext + * @type {object} + * @since 3.0.0 + */ + this.callbackContext = callbackContext; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Collider#setName + * @since 3.1.0 + * + * @param {string} name - [description] + * + * @return {Phaser.Physics.Arcade.Collider} [description] + */ + setName: function (name) + { + this.name = name; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Collider#update + * @since 3.0.0 + */ + update: function () + { + this.world.collideObjects( + this.object1, + this.object2, + this.collideCallback, + this.processCallback, + this.callbackContext, + this.overlapOnly + ); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Collider#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.world.removeCollider(this); + + this.active = false; + + this.world = null; + + this.object1 = null; + this.object2 = null; + + this.collideCallback = null; + this.processCallback = null; + this.callbackContext = null; } - return color; -}; +}); -module.exports = RGBStringToColor; +module.exports = Collider; /***/ }), /* 209 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Position Vector randomly in a spherical area defined by the given radius -/** - * [description] - * - * @function Phaser.Math.RandomXYZ - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} vec3 - [description] - * @param {number} [radius=1] - [description] - * - * @return {Phaser.Math.Vector3} [description] - */ -var RandomXYZ = function (vec3, radius) -{ - if (radius === undefined) { radius = 1; } - - var r = Math.random() * 2 * Math.PI; - var z = (Math.random() * 2) - 1; - var zScale = Math.sqrt(1 - z * z) * radius; - - vec3.x = Math.cos(r) * zScale; - vec3.y = Math.sin(r) * zScale; - vec3.z = z * radius; - - return vec3; -}; - -module.exports = RandomXYZ; - - -/***/ }), -/* 210 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.RandomXYZW - * @since 3.0.0 - * - * @param {Phaser.Math.Vector4} vec4 - [description] - * @param {float} [scale=1] - [description] - * - * @return {Phaser.Math.Vector4} [description] - */ -var RandomXYZW = function (vec4, scale) -{ - if (scale === undefined) { scale = 1; } - - // Not spherical; should fix this for more uniform distribution - vec4.x = (Math.random() * 2 - 1) * scale; - vec4.y = (Math.random() * 2 - 1) * scale; - vec4.z = (Math.random() * 2 - 1) * scale; - vec4.w = (Math.random() * 2 - 1) * scale; - - return vec4; -}; - -module.exports = RandomXYZW; - - -/***/ }), -/* 211 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -43121,8261 +49581,601 @@ module.exports = RandomXYZW; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Vector3 = __webpack_require__(51); -var Matrix4 = __webpack_require__(119); -var Quaternion = __webpack_require__(212); - -var tmpMat4 = new Matrix4(); -var tmpQuat = new Quaternion(); -var tmpVec3 = new Vector3(); - -/** - * Rotates a vector in place by axis angle. - * - * This is the same as transforming a point by an - * axis-angle quaternion, but it has higher precision. - * - * @function Phaser.Math.RotateVec3 - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} vec - [description] - * @param {Phaser.Math.Vector3} axis - [description] - * @param {float} radians - [description] - * - * @return {Phaser.Math.Vector3} [description] - */ -var RotateVec3 = function (vec, axis, radians) -{ - // Set the quaternion to our axis angle - tmpQuat.setAxisAngle(axis, radians); - - // Create a rotation matrix from the axis angle - tmpMat4.fromRotationTranslation(tmpQuat, tmpVec3.set(0, 0, 0)); - - // Multiply our vector by the rotation matrix - return vec.transformMat4(tmpMat4); -}; - -module.exports = RotateVec3; - - -/***/ }), -/* 212 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji -// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl - +var CircleContains = __webpack_require__(28); var Class = __webpack_require__(0); -var Vector3 = __webpack_require__(51); -var Matrix3 = __webpack_require__(213); - -var EPSILON = 0.000001; - -// Some shared 'private' arrays -var siNext = new Int8Array([ 1, 2, 0 ]); -var tmp = new Float32Array([ 0, 0, 0 ]); - -var xUnitVec3 = new Vector3(1, 0, 0); -var yUnitVec3 = new Vector3(0, 1, 0); - -var tmpvec = new Vector3(); -var tmpMat3 = new Matrix3(); - -/** - * @classdesc - * [description] - * - * @class Quaternion - * @memberOf Phaser.Math - * @constructor - * @since 3.0.0 - * - * @param {number} [x] - [description] - * @param {number} [y] - [description] - * @param {number} [z] - [description] - * @param {number} [w] - [description] - */ -var Quaternion = new Class({ - - initialize: - - function Quaternion (x, y, z, w) - { - /** - * The x component of this Quaternion. - * - * @name Phaser.Math.Quaternion#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - /** - * The y component of this Quaternion. - * - * @name Phaser.Math.Quaternion#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - /** - * The z component of this Quaternion. - * - * @name Phaser.Math.Quaternion#z - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - /** - * The w component of this Quaternion. - * - * @name Phaser.Math.Quaternion#w - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - if (typeof x === 'object') - { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - this.w = x.w || 0; - } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - this.w = w || 0; - } - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#copy - * @since 3.0.0 - * - * @param {[type]} src - [description] - * - * @return {[type]} [description] - */ - copy: function (src) - { - this.x = src.x; - this.y = src.y; - this.z = src.z; - this.w = src.w; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#set - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} z - [description] - * @param {[type]} w - [description] - * - * @return {[type]} [description] - */ - set: function (x, y, z, w) - { - if (typeof x === 'object') - { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - this.w = x.w || 0; - } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - this.w = w || 0; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#add - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - add: function (v) - { - this.x += v.x; - this.y += v.y; - this.z += v.z; - this.w += v.w; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#subtract - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - subtract: function (v) - { - this.x -= v.x; - this.y -= v.y; - this.z -= v.z; - this.w -= v.w; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#scale - * @since 3.0.0 - * - * @param {[type]} scale - [description] - * - * @return {[type]} [description] - */ - scale: function (scale) - { - this.x *= scale; - this.y *= scale; - this.z *= scale; - this.w *= scale; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#length - * @since 3.0.0 - * - * @return {[type]} [description] - */ - length: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - - return Math.sqrt(x * x + y * y + z * z + w * w); - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#lengthSq - * @since 3.0.0 - * - * @return {[type]} [description] - */ - lengthSq: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - - return x * x + y * y + z * z + w * w; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#normalize - * @since 3.0.0 - * - * @return {[type]} [description] - */ - normalize: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - var len = x * x + y * y + z * z + w * w; - - if (len > 0) - { - len = 1 / Math.sqrt(len); - - this.x = x * len; - this.y = y * len; - this.z = z * len; - this.w = w * len; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#dot - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - dot: function (v) - { - return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#lerp - * @since 3.0.0 - * - * @param {[type]} v - [description] - * @param {[type]} t - [description] - * - * @return {[type]} [description] - */ - lerp: function (v, t) - { - if (t === undefined) { t = 0; } - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - this.x = ax + t * (v.x - ax); - this.y = ay + t * (v.y - ay); - this.z = az + t * (v.z - az); - this.w = aw + t * (v.w - aw); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#rotationTo - * @since 3.0.0 - * - * @param {[type]} a - [description] - * @param {[type]} b - [description] - * - * @return {[type]} [description] - */ - rotationTo: function (a, b) - { - var dot = a.x * b.x + a.y * b.y + a.z * b.z; - - if (dot < -0.999999) - { - if (tmpvec.copy(xUnitVec3).cross(a).length() < EPSILON) - { - tmpvec.copy(yUnitVec3).cross(a); - } - - tmpvec.normalize(); - - return this.setAxisAngle(tmpvec, Math.PI); - - } - else if (dot > 0.999999) - { - this.x = 0; - this.y = 0; - this.z = 0; - this.w = 1; - - return this; - } - else - { - tmpvec.copy(a).cross(b); - - this.x = tmpvec.x; - this.y = tmpvec.y; - this.z = tmpvec.z; - this.w = 1 + dot; - - return this.normalize(); - } - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#setAxes - * @since 3.0.0 - * - * @param {[type]} view - [description] - * @param {[type]} right - [description] - * @param {[type]} up - [description] - * - * @return {[type]} [description] - */ - setAxes: function (view, right, up) - { - var m = tmpMat3.val; - - m[0] = right.x; - m[3] = right.y; - m[6] = right.z; - - m[1] = up.x; - m[4] = up.y; - m[7] = up.z; - - m[2] = -view.x; - m[5] = -view.y; - m[8] = -view.z; - - return this.fromMat3(tmpMat3).normalize(); - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#identity - * @since 3.0.0 - * - * @return {[type]} [description] - */ - identity: function () - { - this.x = 0; - this.y = 0; - this.z = 0; - this.w = 1; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#setAxisAngle - * @since 3.0.0 - * - * @param {[type]} axis - [description] - * @param {[type]} rad - [description] - * - * @return {[type]} [description] - */ - setAxisAngle: function (axis, rad) - { - rad = rad * 0.5; - - var s = Math.sin(rad); - - this.x = s * axis.x; - this.y = s * axis.y; - this.z = s * axis.z; - this.w = Math.cos(rad); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#multiply - * @since 3.0.0 - * - * @param {[type]} b - [description] - * - * @return {[type]} [description] - */ - multiply: function (b) - { - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - var bx = b.x; - var by = b.y; - var bz = b.z; - var bw = b.w; - - this.x = ax * bw + aw * bx + ay * bz - az * by; - this.y = ay * bw + aw * by + az * bx - ax * bz; - this.z = az * bw + aw * bz + ax * by - ay * bx; - this.w = aw * bw - ax * bx - ay * by - az * bz; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#slerp - * @since 3.0.0 - * - * @param {[type]} b - [description] - * @param {[type]} t - [description] - * - * @return {[type]} [description] - */ - slerp: function (b, t) - { - // benchmarks: http://jsperf.com/quaternion-slerp-implementations - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - var bx = b.x; - var by = b.y; - var bz = b.z; - var bw = b.w; - - // calc cosine - var cosom = ax * bx + ay * by + az * bz + aw * bw; - - // adjust signs (if necessary) - if (cosom < 0) - { - cosom = -cosom; - bx = - bx; - by = - by; - bz = - bz; - bw = - bw; - } - - // "from" and "to" quaternions are very close - // ... so we can do a linear interpolation - var scale0 = 1 - t; - var scale1 = t; - - // calculate coefficients - if ((1 - cosom) > EPSILON) - { - // standard case (slerp) - var omega = Math.acos(cosom); - var sinom = Math.sin(omega); - - scale0 = Math.sin((1.0 - t) * omega) / sinom; - scale1 = Math.sin(t * omega) / sinom; - } - - // calculate final values - this.x = scale0 * ax + scale1 * bx; - this.y = scale0 * ay + scale1 * by; - this.z = scale0 * az + scale1 * bz; - this.w = scale0 * aw + scale1 * bw; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#invert - * @since 3.0.0 - * - * @return {[type]} [description] - */ - invert: function () - { - var a0 = this.x; - var a1 = this.y; - var a2 = this.z; - var a3 = this.w; - - var dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3; - var invDot = (dot) ? 1 / dot : 0; - - // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0 - - this.x = -a0 * invDot; - this.y = -a1 * invDot; - this.z = -a2 * invDot; - this.w = a3 * invDot; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#conjugate - * @since 3.0.0 - * - * @return {[type]} [description] - */ - conjugate: function () - { - this.x = -this.x; - this.y = -this.y; - this.z = -this.z; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#rotateX - * @since 3.0.0 - * - * @param {[type]} rad - [description] - * - * @return {[type]} [description] - */ - rotateX: function (rad) - { - rad *= 0.5; - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - var bx = Math.sin(rad); - var bw = Math.cos(rad); - - this.x = ax * bw + aw * bx; - this.y = ay * bw + az * bx; - this.z = az * bw - ay * bx; - this.w = aw * bw - ax * bx; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#rotateY - * @since 3.0.0 - * - * @param {[type]} rad - [description] - * - * @return {[type]} [description] - */ - rotateY: function (rad) - { - rad *= 0.5; - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - var by = Math.sin(rad); - var bw = Math.cos(rad); - - this.x = ax * bw - az * by; - this.y = ay * bw + aw * by; - this.z = az * bw + ax * by; - this.w = aw * bw - ay * by; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#rotateZ - * @since 3.0.0 - * - * @param {[type]} rad - [description] - * - * @return {[type]} [description] - */ - rotateZ: function (rad) - { - rad *= 0.5; - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - var bz = Math.sin(rad); - var bw = Math.cos(rad); - - this.x = ax * bw + ay * bz; - this.y = ay * bw - ax * bz; - this.z = az * bw + aw * bz; - this.w = aw * bw - az * bz; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#calculateW - * @since 3.0.0 - * - * @return {[type]} [description] - */ - calculateW: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - - this.w = -Math.sqrt(Math.abs(1.0 - x * x - y * y - z * z)); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#fromMat3 - * @since 3.0.0 - * - * @param {[type]} mat - [description] - * - * @return {[type]} [description] - */ - fromMat3: function (mat) - { - // benchmarks: - // http://jsperf.com/typed-array-access-speed - // http://jsperf.com/conversion-of-3x3-matrix-to-quaternion - - // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes - // article "Quaternion Calculus and Fast Animation". - var m = mat.val; - var fTrace = m[0] + m[4] + m[8]; - var fRoot; - - if (fTrace > 0) - { - // |w| > 1/2, may as well choose w > 1/2 - fRoot = Math.sqrt(fTrace + 1.0); // 2w - - this.w = 0.5 * fRoot; - - fRoot = 0.5 / fRoot; // 1/(4w) - - this.x = (m[7] - m[5]) * fRoot; - this.y = (m[2] - m[6]) * fRoot; - this.z = (m[3] - m[1]) * fRoot; - } - else - { - // |w| <= 1/2 - var i = 0; - - if (m[4] > m[0]) - { - i = 1; - } - - if (m[8] > m[i * 3 + i]) - { - i = 2; - } - - var j = siNext[i]; - var k = siNext[j]; - - // This isn't quite as clean without array access - fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1); - tmp[i] = 0.5 * fRoot; - - fRoot = 0.5 / fRoot; - - tmp[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot; - tmp[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot; - - this.x = tmp[0]; - this.y = tmp[1]; - this.z = tmp[2]; - this.w = (m[k * 3 + j] - m[j * 3 + k]) * fRoot; - } - - return this; - } - -}); - -module.exports = Quaternion; - - -/***/ }), -/* 213 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji -// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class Matrix3 - * @memberOf Phaser.Math - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix3} [m] - [description] - */ - -var Matrix3 = new Class({ - - initialize: - - function Matrix3 (m) - { - /** - * [description] - * - * @name Phaser.Math.Matrix3#val - * @type {Float32Array} - * @since 3.0.0 - */ - this.val = new Float32Array(9); - - if (m) - { - // Assume Matrix3 with val: - this.copy(m); - } - else - { - // Default to identity - this.identity(); - } - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#clone - * @since 3.0.0 - * - * @return {[type]} [description] - */ - clone: function () - { - return new Matrix3(this); - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#set - * @since 3.0.0 - * - * @param {[type]} src - [description] - * - * @return {[type]} [description] - */ - set: function (src) - { - return this.copy(src); - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#copy - * @since 3.0.0 - * - * @param {[type]} src - [description] - * - * @return {[type]} [description] - */ - copy: function (src) - { - var out = this.val; - var a = src.val; - - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#fromMat4 - * @since 3.0.0 - * - * @param {[type]} m - [description] - * - * @return {[type]} [description] - */ - fromMat4: function (m) - { - var a = m.val; - var out = this.val; - - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[4]; - out[4] = a[5]; - out[5] = a[6]; - out[6] = a[8]; - out[7] = a[9]; - out[8] = a[10]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#fromArray - * @since 3.0.0 - * - * @param {[type]} a - [description] - * - * @return {[type]} [description] - */ - fromArray: function (a) - { - var out = this.val; - - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#identity - * @since 3.0.0 - * - * @return {[type]} [description] - */ - identity: function () - { - var out = this.val; - - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 1; - out[5] = 0; - out[6] = 0; - out[7] = 0; - out[8] = 1; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#transpose - * @since 3.0.0 - * - * @return {[type]} [description] - */ - transpose: function () - { - var a = this.val; - var a01 = a[1]; - var a02 = a[2]; - var a12 = a[5]; - - a[1] = a[3]; - a[2] = a[6]; - a[3] = a01; - a[5] = a[7]; - a[6] = a02; - a[7] = a12; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#invert - * @since 3.0.0 - * - * @return {[type]} [description] - */ - invert: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a10 = a[3]; - var a11 = a[4]; - var a12 = a[5]; - var a20 = a[6]; - var a21 = a[7]; - var a22 = a[8]; - - var b01 = a22 * a11 - a12 * a21; - var b11 = -a22 * a10 + a12 * a20; - var b21 = a21 * a10 - a11 * a20; - - // Calculate the determinant - var det = a00 * b01 + a01 * b11 + a02 * b21; - - if (!det) - { - return null; - } - - det = 1 / det; - - a[0] = b01 * det; - a[1] = (-a22 * a01 + a02 * a21) * det; - a[2] = (a12 * a01 - a02 * a11) * det; - a[3] = b11 * det; - a[4] = (a22 * a00 - a02 * a20) * det; - a[5] = (-a12 * a00 + a02 * a10) * det; - a[6] = b21 * det; - a[7] = (-a21 * a00 + a01 * a20) * det; - a[8] = (a11 * a00 - a01 * a10) * det; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#adjoint - * @since 3.0.0 - * - * @return {[type]} [description] - */ - adjoint: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a10 = a[3]; - var a11 = a[4]; - var a12 = a[5]; - var a20 = a[6]; - var a21 = a[7]; - var a22 = a[8]; - - a[0] = (a11 * a22 - a12 * a21); - a[1] = (a02 * a21 - a01 * a22); - a[2] = (a01 * a12 - a02 * a11); - a[3] = (a12 * a20 - a10 * a22); - a[4] = (a00 * a22 - a02 * a20); - a[5] = (a02 * a10 - a00 * a12); - a[6] = (a10 * a21 - a11 * a20); - a[7] = (a01 * a20 - a00 * a21); - a[8] = (a00 * a11 - a01 * a10); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#determinant - * @since 3.0.0 - * - * @return {[type]} [description] - */ - determinant: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a10 = a[3]; - var a11 = a[4]; - var a12 = a[5]; - var a20 = a[6]; - var a21 = a[7]; - var a22 = a[8]; - - return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20); - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#multiply - * @since 3.0.0 - * - * @param {[type]} src - [description] - * - * @return {[type]} [description] - */ - multiply: function (src) - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a10 = a[3]; - var a11 = a[4]; - var a12 = a[5]; - var a20 = a[6]; - var a21 = a[7]; - var a22 = a[8]; - - var b = src.val; - - var b00 = b[0]; - var b01 = b[1]; - var b02 = b[2]; - var b10 = b[3]; - var b11 = b[4]; - var b12 = b[5]; - var b20 = b[6]; - var b21 = b[7]; - var b22 = b[8]; - - a[0] = b00 * a00 + b01 * a10 + b02 * a20; - a[1] = b00 * a01 + b01 * a11 + b02 * a21; - a[2] = b00 * a02 + b01 * a12 + b02 * a22; - - a[3] = b10 * a00 + b11 * a10 + b12 * a20; - a[4] = b10 * a01 + b11 * a11 + b12 * a21; - a[5] = b10 * a02 + b11 * a12 + b12 * a22; - - a[6] = b20 * a00 + b21 * a10 + b22 * a20; - a[7] = b20 * a01 + b21 * a11 + b22 * a21; - a[8] = b20 * a02 + b21 * a12 + b22 * a22; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#translate - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - translate: function (v) - { - var a = this.val; - var x = v.x; - var y = v.y; - - a[6] = x * a[0] + y * a[3] + a[6]; - a[7] = x * a[1] + y * a[4] + a[7]; - a[8] = x * a[2] + y * a[5] + a[8]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#rotate - * @since 3.0.0 - * - * @param {[type]} rad - [description] - * - * @return {[type]} [description] - */ - rotate: function (rad) - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a10 = a[3]; - var a11 = a[4]; - var a12 = a[5]; - - var s = Math.sin(rad); - var c = Math.cos(rad); - - a[0] = c * a00 + s * a10; - a[1] = c * a01 + s * a11; - a[2] = c * a02 + s * a12; - - a[3] = c * a10 - s * a00; - a[4] = c * a11 - s * a01; - a[5] = c * a12 - s * a02; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#scale - * @since 3.0.0 - * - * @param {[type]} v - [description] - * - * @return {[type]} [description] - */ - scale: function (v) - { - var a = this.val; - var x = v.x; - var y = v.y; - - a[0] = x * a[0]; - a[1] = x * a[1]; - a[2] = x * a[2]; - - a[3] = y * a[3]; - a[4] = y * a[4]; - a[5] = y * a[5]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#fromQuat - * @since 3.0.0 - * - * @param {[type]} q - [description] - * - * @return {[type]} [description] - */ - fromQuat: function (q) - { - var x = q.x; - var y = q.y; - var z = q.z; - var w = q.w; - - var x2 = x + x; - var y2 = y + y; - var z2 = z + z; - - var xx = x * x2; - var xy = x * y2; - var xz = x * z2; - - var yy = y * y2; - var yz = y * z2; - var zz = z * z2; - - var wx = w * x2; - var wy = w * y2; - var wz = w * z2; - - var out = this.val; - - out[0] = 1 - (yy + zz); - out[3] = xy + wz; - out[6] = xz - wy; - - out[1] = xy - wz; - out[4] = 1 - (xx + zz); - out[7] = yz + wx; - - out[2] = xz + wy; - out[5] = yz - wx; - out[8] = 1 - (xx + yy); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#normalFromMat4 - * @since 3.0.0 - * - * @param {[type]} m - [description] - * - * @return {[type]} [description] - */ - normalFromMat4: function (m) - { - var a = m.val; - var out = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - var a30 = a[12]; - var a31 = a[13]; - var a32 = a[14]; - var a33 = a[15]; - - var b00 = a00 * a11 - a01 * a10; - var b01 = a00 * a12 - a02 * a10; - var b02 = a00 * a13 - a03 * a10; - var b03 = a01 * a12 - a02 * a11; - - var b04 = a01 * a13 - a03 * a11; - var b05 = a02 * a13 - a03 * a12; - var b06 = a20 * a31 - a21 * a30; - var b07 = a20 * a32 - a22 * a30; - - var b08 = a20 * a33 - a23 * a30; - var b09 = a21 * a32 - a22 * a31; - var b10 = a21 * a33 - a23 * a31; - var b11 = a22 * a33 - a23 * a32; - - // Calculate the determinant - var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; - - if (!det) - { - return null; - } - - det = 1 / det; - - out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; - out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det; - out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det; - - out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det; - out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det; - out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det; - - out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det; - out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det; - out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det; - - return this; - } - -}); - -module.exports = Matrix3; - - -/***/ }), -/* 214 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Camera = __webpack_require__(118); -var Class = __webpack_require__(0); -var Vector3 = __webpack_require__(51); - -// Local cache vars -var tmpVec3 = new Vector3(); - -/** - * @classdesc - * [description] - * - * @class OrthographicCamera - * @extends Phaser.Cameras.Sprite3D.Camera - * @memberOf Phaser.Cameras.Sprite3D - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {integer} viewportWidth - [description] - * @param {integer} viewportHeight - [description] - */ -var OrthographicCamera = new Class({ - - Extends: Camera, - - initialize: - - function OrthographicCamera (scene, viewportWidth, viewportHeight) - { - if (viewportWidth === undefined) { viewportWidth = 0; } - if (viewportHeight === undefined) { viewportHeight = 0; } - - Camera.call(this, scene); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.OrthographicCamera#viewportWidth - * @type {integer} - * @since 3.0.0 - */ - this.viewportWidth = viewportWidth; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.OrthographicCamera#viewportHeight - * @type {integer} - * @since 3.0.0 - */ - this.viewportHeight = viewportHeight; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.OrthographicCamera#_zoom - * @type {float} - * @private - * @since 3.0.0 - */ - this._zoom = 1.0; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.OrthographicCamera#near - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.near = 0; - - this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.OrthographicCamera#setToOrtho - * @since 3.0.0 - * - * @param {[type]} yDown - [description] - * @param {[type]} viewportWidth - [description] - * @param {[type]} viewportHeight - [description] - * - * @return {[type]} [description] - */ - setToOrtho: function (yDown, viewportWidth, viewportHeight) - { - if (viewportWidth === undefined) { viewportWidth = this.viewportWidth; } - if (viewportHeight === undefined) { viewportHeight = this.viewportHeight; } - - var zoom = this.zoom; - - this.up.set(0, (yDown) ? -1 : 1, 0); - this.direction.set(0, 0, (yDown) ? 1 : -1); - this.position.set(zoom * viewportWidth / 2, zoom * viewportHeight / 2, 0); - - this.viewportWidth = viewportWidth; - this.viewportHeight = viewportHeight; - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.OrthographicCamera#update - * @since 3.0.0 - * - * @return {[type]} [description] - */ - update: function () - { - var w = this.viewportWidth; - var h = this.viewportHeight; - var near = Math.abs(this.near); - var far = Math.abs(this.far); - var zoom = this.zoom; - - if (w === 0 || h === 0) - { - // What to do here... hmm? - return this; - } - - this.projection.ortho( - zoom * -w / 2, zoom * w / 2, - zoom * -h / 2, zoom * h / 2, - near, - far - ); - - // Build the view matrix - tmpVec3.copy(this.position).add(this.direction); - - this.view.lookAt(this.position, tmpVec3, this.up); - - // Projection * view matrix - this.combined.copy(this.projection).multiply(this.view); - - // Invert combined matrix, used for unproject - this.invProjectionView.copy(this.combined).invert(); - - this.billboardMatrixDirty = true; - - this.updateChildren(); - - return this; - }, - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.OrthographicCamera#zoom - * @type {number} - * @since 3.0.0 - */ - zoom: { - - get: function () - { - return this._zoom; - }, - - set: function (value) - { - this._zoom = value; - this.update(); - } - } - -}); - -module.exports = OrthographicCamera; - - -/***/ }), -/* 215 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Camera = __webpack_require__(118); -var Class = __webpack_require__(0); -var Vector3 = __webpack_require__(51); - -// Local cache vars -var tmpVec3 = new Vector3(); - -/** - * @classdesc - * [description] - * - * @class PerspectiveCamera - * @extends Phaser.Cameras.Sprite3D.Camera - * @memberOf Phaser.Cameras.Sprite3D - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {integer} fieldOfView - [description] - * @param {integer} viewportWidth - [description] - * @param {integer} viewportHeight - [description] - */ -var PerspectiveCamera = new Class({ - - Extends: Camera, - - // FOV is converted to radians automatically - initialize: - - function PerspectiveCamera (scene, fieldOfView, viewportWidth, viewportHeight) - { - if (fieldOfView === undefined) { fieldOfView = 80; } - if (viewportWidth === undefined) { viewportWidth = 0; } - if (viewportHeight === undefined) { viewportHeight = 0; } - - Camera.call(this, scene); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.PerspectiveCamera#viewportWidth - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.viewportWidth = viewportWidth; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.PerspectiveCamera#viewportHeight - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.viewportHeight = viewportHeight; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.PerspectiveCamera#fieldOfView - * @type {integer} - * @default 80 - * @since 3.0.0 - */ - this.fieldOfView = fieldOfView * Math.PI / 180; - - this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.PerspectiveCamera#setFOV - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setFOV: function (value) - { - this.fieldOfView = value * Math.PI / 180; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.PerspectiveCamera#update - * @since 3.0.0 - * - * @return {[type]} [description] - */ - update: function () - { - var aspect = this.viewportWidth / this.viewportHeight; - - // Create a perspective matrix for our camera - this.projection.perspective( - this.fieldOfView, - aspect, - Math.abs(this.near), - Math.abs(this.far) - ); - - // Build the view matrix - tmpVec3.copy(this.position).add(this.direction); - - this.view.lookAt(this.position, tmpVec3, this.up); - - // Projection * view matrix - this.combined.copy(this.projection).multiply(this.view); - - // Invert combined matrix, used for unproject - this.invProjectionView.copy(this.combined).invert(); - - this.billboardMatrixDirty = true; - - this.updateChildren(); - - return this; - } - -}); - -module.exports = PerspectiveCamera; - - -/***/ }), -/* 216 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Arne16 = __webpack_require__(217); -var CanvasPool = __webpack_require__(21); -var GetValue = __webpack_require__(4); - -/** - * [description] - * - * @function Phaser.Create.GenerateTexture - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {HTMLCanvasElement} [description] - */ -var GenerateTexture = function (config) -{ - var data = GetValue(config, 'data', []); - var canvas = GetValue(config, 'canvas', null); - var palette = GetValue(config, 'palette', Arne16); - var pixelWidth = GetValue(config, 'pixelWidth', 1); - var pixelHeight = GetValue(config, 'pixelHeight', pixelWidth); - var resizeCanvas = GetValue(config, 'resizeCanvas', true); - var clearCanvas = GetValue(config, 'clearCanvas', true); - var preRender = GetValue(config, 'preRender', null); - var postRender = GetValue(config, 'postRender', null); - - var width = Math.floor(Math.abs(data[0].length * pixelWidth)); - var height = Math.floor(Math.abs(data.length * pixelHeight)); - - if (!canvas) - { - canvas = CanvasPool.create2D(this, width, height); - resizeCanvas = false; - clearCanvas = false; - } - - if (resizeCanvas) - { - canvas.width = width; - canvas.height = height; - } - - var ctx = canvas.getContext('2d'); - - if (clearCanvas) - { - ctx.clearRect(0, 0, width, height); - } - - // preRender Callback? - if (preRender) - { - preRender(canvas, ctx); - } - - // Draw it - for (var y = 0; y < data.length; y++) - { - var row = data[y]; - - for (var x = 0; x < row.length; x++) - { - var d = row[x]; - - if (d !== '.' && d !== ' ') - { - ctx.fillStyle = palette[d]; - ctx.fillRect(x * pixelWidth, y * pixelHeight, pixelWidth, pixelHeight); - } - } - } - - // postRender Callback? - if (postRender) - { - postRender(canvas, ctx); - } - - return canvas; -}; - -module.exports = GenerateTexture; - - -/***/ }), -/* 217 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * A 16 color palette by [Arne](http://androidarts.com/palette/16pal.htm) - * - * @name Phaser.Create.Palettes.ARNE16 - * @since 3.0.0 - * - * @type {object} - * @property {string} 0 - Color value 1. - * @property {string} 1 - Color value 2. - * @property {string} 2 - Color value 3. - * @property {string} 3 - Color value 4. - * @property {string} 4 - Color value 5. - * @property {string} 5 - Color value 6. - * @property {string} 6 - Color value 7. - * @property {string} 7 - Color value 8. - * @property {string} 8 - Color value 9. - * @property {string} 9 - Color value 10. - * @property {string} A - Color value 11. - * @property {string} B - Color value 12. - * @property {string} C - Color value 13. - * @property {string} D - Color value 14. - * @property {string} E - Color value 15. - * @property {string} F - Color value 16. - */ -module.exports = { - 0: '#000', - 1: '#9D9D9D', - 2: '#FFF', - 3: '#BE2633', - 4: '#E06F8B', - 5: '#493C2B', - 6: '#A46422', - 7: '#EB8931', - 8: '#F7E26B', - 9: '#2F484E', - A: '#44891A', - B: '#A3CE27', - C: '#1B2632', - D: '#005784', - E: '#31A2F2', - F: '#B2DCEF' -}; - - -/***/ }), -/* 218 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) - -var Class = __webpack_require__(0); -var CubicBezier = __webpack_require__(219); -var Curve = __webpack_require__(52); +var CONST = __webpack_require__(47); +var Rectangle = __webpack_require__(10); +var RectangleContains = __webpack_require__(27); var Vector2 = __webpack_require__(6); /** - * @classdesc - * [description] + * @typedef {object} ArcadeBodyBounds * - * @class CubicBezierCurve - * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2|Phaser.Math.Vector2[]} p0 - Start point, or an array of point pairs. - * @param {Phaser.Math.Vector2} p1 - Control Point 1. - * @param {Phaser.Math.Vector2} p2 - Control Point 2. - * @param {Phaser.Math.Vector2} p3 - End Point. + * @property {number} x - [description] + * @property {number} y - [description] + * @property {number} right - [description] + * @property {number} bottom - [description] */ -var CubicBezierCurve = new Class({ - - Extends: Curve, - - initialize: - - function CubicBezierCurve (p0, p1, p2, p3) - { - Curve.call(this, 'CubicBezierCurve'); - - if (Array.isArray(p0)) - { - p3 = new Vector2(p0[6], p0[7]); - p2 = new Vector2(p0[4], p0[5]); - p1 = new Vector2(p0[2], p0[3]); - p0 = new Vector2(p0[0], p0[1]); - } - - /** - * [description] - * - * @name Phaser.Curves.CubicBezierCurve#p0 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p0 = p0; - - /** - * [description] - * - * @name Phaser.Curves.CubicBezierCurve#p1 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p1 = p1; - - /** - * [description] - * - * @name Phaser.Curves.CubicBezierCurve#p2 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p2 = p2; - - /** - * [description] - * - * @name Phaser.Curves.CubicBezierCurve#p3 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p3 = p3; - }, - - /** - * [description] - * - * @method Phaser.Curves.CubicBezierCurve#getStartPoint - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} out - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - getStartPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return out.copy(this.p0); - }, - - /** - * [description] - * - * @method Phaser.Curves.CubicBezierCurve#getResolution - * @since 3.0.0 - * - * @param {[type]} divisions - [description] - * - * @return {[type]} [description] - */ - getResolution: function (divisions) - { - return divisions; - }, - - /** - * [description] - * - * @method Phaser.Curves.CubicBezierCurve#getPoint - * @since 3.0.0 - * - * @param {[type]} t - [description] - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - var p0 = this.p0; - var p1 = this.p1; - var p2 = this.p2; - var p3 = this.p3; - - return out.set(CubicBezier(t, p0.x, p1.x, p2.x, p3.x), CubicBezier(t, p0.y, p1.y, p2.y, p3.y)); - }, - - /** - * [description] - * - * @method Phaser.Curves.CubicBezierCurve#draw - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - [description] - * @param {integer} [pointsTotal=32] - [description] - * - * @return {Phaser.GameObjects.Graphics} [description] - */ - draw: function (graphics, pointsTotal) - { - if (pointsTotal === undefined) { pointsTotal = 32; } - - var points = this.getPoints(pointsTotal); - - graphics.beginPath(); - graphics.moveTo(this.p0.x, this.p0.y); - - for (var i = 1; i < points.length; i++) - { - graphics.lineTo(points[i].x, points[i].y); - } - - graphics.strokePath(); - - // So you can chain graphics calls - return graphics; - }, - - /** - * [description] - * - * @method Phaser.Curves.CubicBezierCurve#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - return { - type: this.type, - points: [ - this.p0.x, this.p0.y, - this.p1.x, this.p1.y, - this.p2.x, this.p2.y, - this.p3.x, this.p3.y - ] - }; - } - -}); - -CubicBezierCurve.fromJSON = function (data) -{ - var points = data.points; - - var p0 = new Vector2(points[0], points[1]); - var p1 = new Vector2(points[2], points[3]); - var p2 = new Vector2(points[4], points[5]); - var p3 = new Vector2(points[6], points[7]); - - return new CubicBezierCurve(p0, p1, p2, p3); -}; - -module.exports = CubicBezierCurve; - - -/***/ }), -/* 219 */ -/***/ (function(module, exports) { /** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -function P0 (t, p) -{ - var k = 1 - t; - - return k * k * k * p; -} - -function P1 (t, p) -{ - var k = 1 - t; - - return 3 * k * k * t * p; -} - -function P2 (t, p) -{ - return 3 * (1 - t) * t * t * p; -} - -function P3 (t, p) -{ - return t * t * t * p; -} - -// p0 = start point -// p1 = control point 1 -// p2 = control point 2 -// p3 = end point - -// https://medium.com/@adrian_cooney/bezier-interpolation-13b68563313a - -/** - * [description] + * @typedef {object} ArcadeBodyCollision * - * @function Phaser.Math.Interpolation.CubicBezier - * @since 3.0.0 - * - * @param {float} t - [description] - * @param {number} p0 - [description] - * @param {number} p1 - [description] - * @param {number} p2 - [description] - * @param {number} p3 - [description] - * - * @return {number} [description] + * @property {boolean} none - [description] + * @property {boolean} up - [description] + * @property {boolean} down - [description] + * @property {boolean} left - [description] + * @property {boolean} right - [description] */ -var CubicBezierInterpolation = function (t, p0, p1, p2, p3) -{ - return P0(t, p0) + P1(t, p1) + P2(t, p2) + P3(t, p3); -}; - -module.exports = CubicBezierInterpolation; - - -/***/ }), -/* 220 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) - -var Class = __webpack_require__(0); -var Curve = __webpack_require__(52); -var DegToRad = __webpack_require__(35); -var GetValue = __webpack_require__(4); -var RadToDeg = __webpack_require__(221); -var Vector2 = __webpack_require__(6); /** * @classdesc * [description] * - * @class EllipseCurve - * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves + * @class Body + * @memberOf Phaser.Physics.Arcade * @constructor * @since 3.0.0 * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] - * @param {number} [xRadius=0] - [description] - * @param {number} [yRadius=0] - [description] - * @param {number} [startAngle=0] - [description] - * @param {number} [endAngle=360] - [description] - * @param {boolean} [clockwise=false] - [description] - * @param {number} [rotation=0] - [description] + * @param {Phaser.Physics.Arcade.World} world - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - [description] */ -var EllipseCurve = new Class({ - - Extends: Curve, +var Body = new Class({ initialize: - function EllipseCurve (x, y, xRadius, yRadius, startAngle, endAngle, clockwise, rotation) + function Body (world, gameObject) { - if (typeof x === 'object') - { - var config = x; - - x = GetValue(config, 'x', 0); - y = GetValue(config, 'y', 0); - xRadius = GetValue(config, 'xRadius', 0); - yRadius = GetValue(config, 'yRadius', xRadius); - startAngle = GetValue(config, 'startAngle', 0); - endAngle = GetValue(config, 'endAngle', 360); - clockwise = GetValue(config, 'clockwise', false); - rotation = GetValue(config, 'rotation', 0); - } - else - { - if (yRadius === undefined) { yRadius = xRadius; } - if (startAngle === undefined) { startAngle = 0; } - if (endAngle === undefined) { endAngle = 360; } - if (clockwise === undefined) { clockwise = false; } - if (rotation === undefined) { rotation = 0; } - } - - Curve.call(this, 'EllipseCurve'); - - // Center point + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; /** * [description] * - * @name {Phaser.MathPhaser.Curves.EllipseCurve#p0 - * @type {Phaser.Math.Vector2} + * @name Phaser.Physics.Arcade.Body#gameObject + * @type {Phaser.GameObjects.GameObject} * @since 3.0.0 */ - this.p0 = new Vector2(x, y); + this.gameObject = gameObject; /** * [description] * - * @name Phaser.Curves.EllipseCurve#_xRadius - * @type {number} - * @private - * @since 3.0.0 - */ - this._xRadius = xRadius; - - /** - * [description] - * - * @name Phaser.Curves.EllipseCurve#_yRadius - * @type {number} - * @private - * @since 3.0.0 - */ - this._yRadius = yRadius; - - // Radians - - /** - * [description] - * - * @name Phaser.Curves.EllipseCurve#_startAngle - * @type {number} - * @private - * @since 3.0.0 - */ - this._startAngle = DegToRad(startAngle); - - /** - * [description] - * - * @name Phaser.Curves.EllipseCurve#_endAngle - * @type {number} - * @private - * @since 3.0.0 - */ - this._endAngle = DegToRad(endAngle); - - /** - * Anti-clockwise direction. - * - * @name Phaser.Curves.EllipseCurve#_clockwise + * @name Phaser.Physics.Arcade.Body#debugShowBody * @type {boolean} - * @private * @since 3.0.0 */ - this._clockwise = clockwise; + this.debugShowBody = world.defaults.debugShowBody; /** - * The rotation of the arc. + * [description] * - * @name Phaser.Curves.EllipseCurve#_rotation - * @type {number} - * @private + * @name Phaser.Physics.Arcade.Body#debugShowVelocity + * @type {boolean} * @since 3.0.0 */ - this._rotation = DegToRad(rotation); - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#getStartPoint - * @since 3.0.0 - * - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - getStartPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return this.getPoint(0, out); - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#getResolution - * @since 3.0.0 - * - * @param {[type]} divisions - [description] - * - * @return {[type]} [description] - */ - getResolution: function (divisions) - { - return divisions * 2; - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#getPoint - * @since 3.0.0 - * - * @param {[type]} t - [description] - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - var twoPi = Math.PI * 2; - var deltaAngle = this._endAngle - this._startAngle; - var samePoints = Math.abs(deltaAngle) < Number.EPSILON; - - // ensures that deltaAngle is 0 .. 2 PI - while (deltaAngle < 0) - { - deltaAngle += twoPi; - } - - while (deltaAngle > twoPi) - { - deltaAngle -= twoPi; - } - - if (deltaAngle < Number.EPSILON) - { - if (samePoints) - { - deltaAngle = 0; - } - else - { - deltaAngle = twoPi; - } - } - - if (this._clockwise && !samePoints) - { - if (deltaAngle === twoPi) - { - deltaAngle = - twoPi; - } - else - { - deltaAngle = deltaAngle - twoPi; - } - } - - var angle = this._startAngle + t * deltaAngle; - var x = this.p0.x + this._xRadius * Math.cos(angle); - var y = this.p0.y + this._yRadius * Math.sin(angle); - - if (this._rotation !== 0) - { - var cos = Math.cos(this._rotation); - var sin = Math.sin(this._rotation); - - var tx = x - this.p0.x; - var ty = y - this.p0.y; - - // Rotate the point about the center of the ellipse. - x = tx * cos - ty * sin + this.p0.x; - y = tx * sin + ty * cos + this.p0.y; - } - - return out.set(x, y); - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#setXRadius - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setXRadius: function (value) - { - this.xRadius = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#setYRadius - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setYRadius: function (value) - { - this.yRadius = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#setWidth - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setWidth: function (value) - { - this.xRadius = value * 2; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#setHeight - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setHeight: function (value) - { - this.yRadius = value * 2; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#setStartAngle - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setStartAngle: function (value) - { - this.startAngle = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#setEndAngle - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setEndAngle: function (value) - { - this.endAngle = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#setClockwise - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setClockwise: function (value) - { - this.clockwise = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#setRotation - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setRotation: function (value) - { - this.rotation = value; - - return this; - }, - - /** - * [description] - * - * @name Phaser.Curves.EllipseCurve#x - * @type {number} - * @since 3.0.0 - */ - x: { - - get: function () - { - return this.p0.x; - }, - - set: function (value) - { - this.p0.x = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.EllipseCurve#y - * @type {number} - * @since 3.0.0 - */ - y: { - - get: function () - { - return this.p0.y; - }, - - set: function (value) - { - this.p0.y = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.EllipseCurve#xRadius - * @type {number} - * @since 3.0.0 - */ - xRadius: { - - get: function () - { - return this._xRadius; - }, - - set: function (value) - { - this._xRadius = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.EllipseCurve#yRadius - * @type {number} - * @since 3.0.0 - */ - yRadius: { - - get: function () - { - return this._yRadius; - }, - - set: function (value) - { - this._yRadius = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.EllipseCurve#startAngle - * @type {number} - * @since 3.0.0 - */ - startAngle: { - - get: function () - { - return RadToDeg(this._startAngle); - }, - - set: function (value) - { - this._startAngle = DegToRad(value); - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.EllipseCurve#endAngle - * @type {number} - * @since 3.0.0 - */ - endAngle: { - - get: function () - { - return RadToDeg(this._endAngle); - }, - - set: function (value) - { - this._endAngle = DegToRad(value); - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.EllipseCurve#clockwise - * @type {number} - * @since 3.0.0 - */ - clockwise: { - - get: function () - { - return this._clockwise; - }, - - set: function (value) - { - this._clockwise = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.EllipseCurve#rotation - * @type {number} - * @since 3.0.0 - */ - rotation: { - - get: function () - { - return this._rotation; - }, - - set: function (value) - { - this._rotation = DegToRad(value); - } - - }, - - /** - * [description] - * - * @method Phaser.Curves.EllipseCurve#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - return { - type: this.type, - x: this.p0.x, - y: this.p0.y, - xRadius: this._xRadius, - yRadius: this._yRadius, - startAngle: RadToDeg(this._startAngle), - endAngle: RadToDeg(this._endAngle), - clockwise: this._clockwise, - rotation: RadToDeg(this._rotation) - }; - } - -}); - -EllipseCurve.fromJSON = function (data) -{ - return new EllipseCurve(data); -}; - -module.exports = EllipseCurve; - - -/***/ }), -/* 221 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(16); - -/** - * [description] - * - * @function Phaser.Math.RadToDeg - * @since 3.0.0 - * - * @param {float} radians - [description] - * - * @return {integer} [description] - */ -var RadToDeg = function (radians) -{ - return radians * CONST.RAD_TO_DEG; -}; - -module.exports = RadToDeg; - - -/***/ }), -/* 222 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) - -var Class = __webpack_require__(0); -var Curve = __webpack_require__(52); -var FromPoints = __webpack_require__(122); -var Rectangle = __webpack_require__(8); -var Vector2 = __webpack_require__(6); - -var tmpVec2 = new Vector2(); - -/** - * @classdesc - * [description] - * - * @class LineCurve - * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} p0 - [description] - * @param {Phaser.Math.Vector2} p1 - [description] - */ -var LineCurve = new Class({ - - Extends: Curve, - - initialize: - - // vec2s or array - function LineCurve (p0, p1) - { - Curve.call(this, 'LineCurve'); - - if (Array.isArray(p0)) - { - p1 = new Vector2(p0[2], p0[3]); - p0 = new Vector2(p0[0], p0[1]); - } + this.debugShowVelocity = world.defaults.debugShowVelocity; /** * [description] * - * @name Phaser.Curves.LineCurve#p0 - * @type {Phaser.Math.Vector2} + * @name Phaser.Physics.Arcade.Body#debugBodyColor + * @type {integer} * @since 3.0.0 */ - this.p0 = p0; + this.debugBodyColor = world.defaults.bodyDebugColor; /** * [description] * - * @property Phaser.Curves.LineCurve#p1 - * @type {Phaser.Math.Vector2} + * @name Phaser.Physics.Arcade.Body#enable + * @type {boolean} + * @default true * @since 3.0.0 */ - this.p1 = p1; - }, - - /** - * [description] - * - * @method Phaser.Curves.LineCurve#getBounds - * @since 3.0.0 - * - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - getBounds: function (out) - { - if (out === undefined) { out = new Rectangle(); } - - return FromPoints([ this.p0, this.p1 ], out); - }, - - /** - * [description] - * - * @method Phaser.Curves.LineCurve#getStartPoint - * @since 3.0.0 - * - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - getStartPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return out.copy(this.p0); - }, - - /** - * [description] - * - * @method Phaser.Curves.LineCurve#getResolution - * @since 3.0.0 - * - * @return {integer} [description] - */ - getResolution: function () - { - return 1; - }, - - /** - * [description] - * - * @method Phaser.Curves.LineCurve#getPoint - * @since 3.0.0 - * - * @param {[type]} t - [description] - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - if (t === 1) - { - return out.copy(this.p1); - } - - out.copy(this.p1).subtract(this.p0).scale(t).add(this.p0); - - return out; - }, - - // Line curve is linear, so we can overwrite default getPointAt - /** - * [description] - * - * @method Phaser.Curves.LineCurve#getPointAt - * @since 3.0.0 - * - * @param {[type]} u - [description] - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - getPointAt: function (u, out) - { - return this.getPoint(u, out); - }, - - /** - * [description] - * - * @method Phaser.Curves.LineCurve#getTangent - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getTangent: function () - { - var tangent = tmpVec2.copy(this.p1).subtract(this.p0); - - return tangent.normalize(); - }, - - // Override default Curve.draw because this is better than calling getPoints on a line! - /** - * [description] - * - * @method Phaser.Curves.LineCurve#draw - * @since 3.0.0 - * - * @param {[type]} graphics - [description] - * - * @return {[type]} [description] - */ - draw: function (graphics) - { - graphics.lineBetween(this.p0.x, this.p0.y, this.p1.x, this.p1.y); - - // So you can chain graphics calls - return graphics; - }, - - /** - * [description] - * - * @method Phaser.Curves.LineCurve#toJSON - * @since 3.0.0 - * - * @return {[type]} [description] - */ - toJSON: function () - { - return { - type: this.type, - points: [ - this.p0.x, this.p0.y, - this.p1.x, this.p1.y - ] - }; - } - -}); - -LineCurve.fromJSON = function (data) -{ - var points = data.points; - - var p0 = new Vector2(points[0], points[1]); - var p1 = new Vector2(points[2], points[3]); - - return new LineCurve(p0, p1); -}; - -module.exports = LineCurve; - - -/***/ }), -/* 223 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Curve = __webpack_require__(52); -var QuadraticBezierInterpolation = __webpack_require__(224); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * [description] - * - * @class QuadraticBezier - * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves - * @constructor - * @since 3.2.0 - * - * @param {Phaser.Math.Vector2|Phaser.Math.Vector2[]} p0 - Start point, or an array of point pairs. - * @param {Phaser.Math.Vector2} p1 - Control Point 1. - * @param {Phaser.Math.Vector2} p2 - Control Point 2. - */ -var QuadraticBezier = new Class({ - - Extends: Curve, - - initialize: - - function QuadraticBezier (p0, p1, p2) - { - Curve.call(this, 'QuadraticBezier'); - - if (Array.isArray(p0)) - { - p2 = new Vector2(p0[4], p0[5]); - p1 = new Vector2(p0[2], p0[3]); - p0 = new Vector2(p0[0], p0[1]); - } + this.enable = true; /** * [description] * - * @name Phaser.Curves.QuadraticBezier#p0 - * @type {Phaser.Math.Vector2} - * @since 3.2.0 - */ - this.p0 = p0; - - /** - * [description] - * - * @name Phaser.Curves.QuadraticBezier#p1 - * @type {Phaser.Math.Vector2} - * @since 3.2.0 - */ - this.p1 = p1; - - /** - * [description] - * - * @name Phaser.Curves.QuadraticBezier#p2 - * @type {Phaser.Math.Vector2} - * @since 3.2.0 - */ - this.p2 = p2; - }, - - /** - * [description] - * - * @method Phaser.Curves.QuadraticBezier#getStartPoint - * @since 3.2.0 - * - * @param {Phaser.Math.Vector2} out - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - getStartPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return out.copy(this.p0); - }, - - /** - * [description] - * - * @method Phaser.Curves.QuadraticBezier#getResolution - * @since 3.2.0 - * - * @param {number} divisions - [description] - * - * @return {number} [description] - */ - getResolution: function (divisions) - { - return divisions; - }, - - /** - * [description] - * - * @method Phaser.Curves.QuadraticBezier#getPoint - * @since 3.2.0 - * - * @param {number} t - [description] - * @param {Phaser.Math.Vector2} [out] - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - var p0 = this.p0; - var p1 = this.p1; - var p2 = this.p2; - - return out.set( - QuadraticBezierInterpolation(t, p0.x, p1.x, p2.x), - QuadraticBezierInterpolation(t, p0.y, p1.y, p2.y) - ); - }, - - /** - * [description] - * - * @method Phaser.Curves.QuadraticBezier#draw - * @since 3.2.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - [description] - * @param {integer} [pointsTotal=32] - [description] - * - * @return {Phaser.GameObjects.Graphics} [description] - */ - draw: function (graphics, pointsTotal) - { - if (pointsTotal === undefined) { pointsTotal = 32; } - - var points = this.getPoints(pointsTotal); - - graphics.beginPath(); - graphics.moveTo(this.p0.x, this.p0.y); - - for (var i = 1; i < points.length; i++) - { - graphics.lineTo(points[i].x, points[i].y); - } - - graphics.strokePath(); - - // So you can chain graphics calls - return graphics; - }, - - /** - * [description] - * - * @method Phaser.Curves.QuadraticBezier#toJSON - * @since 3.2.0 - * - * @return {object} [description] - */ - toJSON: function () - { - return { - type: this.type, - points: [ - this.p0.x, this.p0.y, - this.p1.x, this.p1.y, - this.p2.x, this.p2.y - ] - }; - } - -}); - -QuadraticBezier.fromJSON = function (data) -{ - var points = data.points; - - var p0 = new Vector2(points[0], points[1]); - var p1 = new Vector2(points[2], points[3]); - var p2 = new Vector2(points[4], points[5]); - - return new QuadraticBezier(p0, p1, p2); -}; - -module.exports = QuadraticBezier; - - -/***/ }), -/* 224 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -function P0 (t, p) -{ - var k = 1 - t; - - return k * k * p; -} - -function P1 (t, p) -{ - return 2 * (1 - t) * t * p; -} - -function P2 (t, p) -{ - return t * t * p; -} - -// p0 = start point -// p1 = control point 1 -// p2 = end point - -// https://github.com/mrdoob/three.js/blob/master/src/extras/core/Interpolations.js - -/** - * [description] - * - * @function Phaser.Math.Interpolation.QuadraticBezier - * @since 3.2.0 - * - * @param {float} t - [description] - * @param {number} p0 - [description] - * @param {number} p1 - [description] - * @param {number} p2 - [description] - * - * @return {number} [description] - */ -var QuadraticBezierInterpolation = function (t, p0, p1, p2) -{ - return P0(t, p0) + P1(t, p1) + P2(t, p2); -}; - -module.exports = QuadraticBezierInterpolation; - - -/***/ }), -/* 225 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) - -var CatmullRom = __webpack_require__(123); -var Class = __webpack_require__(0); -var Curve = __webpack_require__(52); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * [description] - * - * @class SplineCurve - * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2[]} [points] - [description] - */ -var SplineCurve = new Class({ - - Extends: Curve, - - initialize: - - function SplineCurve (points) - { - if (points === undefined) { points = []; } - - Curve.call(this, 'SplineCurve'); - - /** - * [description] - * - * @name Phaser.Curves.SplineCurve#points - * @type {Phaser.Math.Vector2[]} - * @default [] - * @since 3.0.0 - */ - this.points = []; - - this.addPoints(points); - }, - - /** - * [description] - * - * @method Phaser.Curves.SplineCurve#addPoints - * @since 3.0.0 - * - * @param {[type]} points - [description] - * - * @return {[type]} [description] - */ - addPoints: function (points) - { - for (var i = 0; i < points.length; i++) - { - var p = new Vector2(); - - if (typeof points[i] === 'number') - { - p.x = points[i]; - p.y = points[i + 1]; - i++; - } - else if (Array.isArray(points[i])) - { - // An array of arrays? - p.x = points[i][0]; - p.y = points[i][1]; - } - else - { - p.x = points[i].x; - p.y = points[i].y; - } - - this.points.push(p); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Curves.SplineCurve#addPoint - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - addPoint: function (x, y) - { - var vec = new Vector2(x, y); - - this.points.push(vec); - - return vec; - }, - - /** - * [description] - * - * @method Phaser.Curves.SplineCurve#getStartPoint - * @since 3.0.0 - * - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - getStartPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return out.copy(this.points[0]); - }, - - /** - * [description] - * - * @method Phaser.Curves.SplineCurve#getResolution - * @since 3.0.0 - * - * @param {[type]} divisions - [description] - * - * @return {[type]} [description] - */ - getResolution: function (divisions) - { - return divisions * this.points.length; - }, - - /** - * [description] - * - * @method Phaser.Curves.SplineCurve#getPoint - * @since 3.0.0 - * - * @param {[type]} t - [description] - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - var points = this.points; - - var point = (points.length - 1) * t; - - var intPoint = Math.floor(point); - - var weight = point - intPoint; - - var p0 = points[(intPoint === 0) ? intPoint : intPoint - 1]; - var p1 = points[intPoint]; - var p2 = points[(intPoint > points.length - 2) ? points.length - 1 : intPoint + 1]; - var p3 = points[(intPoint > points.length - 3) ? points.length - 1 : intPoint + 2]; - - return out.set(CatmullRom(weight, p0.x, p1.x, p2.x, p3.x), CatmullRom(weight, p0.y, p1.y, p2.y, p3.y)); - }, - - /** - * [description] - * - * @method Phaser.Curves.SplineCurve#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - var points = []; - - for (var i = 0; i < this.points.length; i++) - { - points.push(this.points[i].x); - points.push(this.points[i].y); - } - - return { - type: this.type, - points: points - }; - } - -}); - -SplineCurve.fromJSON = function (data) -{ - return new SplineCurve(data.points); -}; - -module.exports = SplineCurve; - - -/***/ }), -/* 226 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Canvas.CanvasInterpolation - * @since 3.0.0 - */ -var CanvasInterpolation = { - - /** - * Sets the CSS image-rendering property on the given canvas to be 'crisp' (aka 'optimize contrast' on webkit). - * - * @function Phaser.Display.Canvas.CanvasInterpolation.setCrisp - * @since 3.0.0 - * - * @param {HTMLCanvasElement} canvas - The canvas object to have the style set on. - * - * @return {HTMLCanvasElement} The canvas. - */ - setCrisp: function (canvas) - { - var types = [ 'optimizeSpeed', 'crisp-edges', '-moz-crisp-edges', '-webkit-optimize-contrast', 'optimize-contrast', 'pixelated' ]; - - types.forEach(function (type) - { - canvas.style['image-rendering'] = type; - }); - - canvas.style.msInterpolationMode = 'nearest-neighbor'; - - return canvas; - }, - - /** - * Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto'). - * - * @function Phaser.Display.Canvas.CanvasInterpolation.setBicubic - * @since 3.0.0 - * - * @param {HTMLCanvasElement} canvas - The canvas object to have the style set on. - * - * @return {HTMLCanvasElement} The canvas. - */ - setBicubic: function (canvas) - { - canvas.style['image-rendering'] = 'auto'; - canvas.style.msInterpolationMode = 'bicubic'; - - return canvas; - } - -}; - -module.exports = CanvasInterpolation; - - -/***/ }), -/* 227 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Color - */ - -var Color = __webpack_require__(36); - -Color.ColorToRGBA = __webpack_require__(494); -Color.ComponentToHex = __webpack_require__(228); -Color.GetColor = __webpack_require__(117); -Color.GetColor32 = __webpack_require__(204); -Color.HexStringToColor = __webpack_require__(203); -Color.HSLToColor = __webpack_require__(495); -Color.HSVColorWheel = __webpack_require__(497); -Color.HSVToRGB = __webpack_require__(230); -Color.HueToComponent = __webpack_require__(229); -Color.IntegerToColor = __webpack_require__(205); -Color.IntegerToRGB = __webpack_require__(206); -Color.Interpolate = __webpack_require__(498); -Color.ObjectToColor = __webpack_require__(207); -Color.RandomRGB = __webpack_require__(499); -Color.RGBStringToColor = __webpack_require__(208); -Color.RGBToHSV = __webpack_require__(500); -Color.RGBToString = __webpack_require__(501); -Color.ValueToColor = __webpack_require__(116); - -module.exports = Color; - - -/***/ }), -/* 228 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns a string containing a hex representation of the given color component. - * - * @function Phaser.Display.Color.ComponentToHex - * @since 3.0.0 - * - * @param {integer} color - The color channel to get the hex value for, must be a value between 0 and 255. - * - * @return {string} A string of length 2 characters, i.e. 255 = ff, 100 = 64. - */ -var ComponentToHex = function (color) -{ - var hex = color.toString(16); - - return (hex.length === 1) ? '0' + hex : hex; -}; - -module.exports = ComponentToHex; - - -/***/ }), -/* 229 */ -/***/ (function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(module) {/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Converts a hue to an RGB color. - * Based on code by Michael Jackson (https://github.com/mjijackson) - * - * @function Phaser.Display.Color.HueToComponent - * @since 3.0.0 - * - * @param {number} p - * @param {number} q - * @param {number} t - * - * @return {number} The combined color value. - */ -var HueToComponent = function (p, q, t) -{ - if (t < 0) - { - t += 1; - } - - if (t > 1) - { - t -= 1; - } - - if (t < 1 / 6) - { - return p + (q - p) * 6 * t; - } - - if (t < 1 / 2) - { - return q; - } - - if (t < 2 / 3) - { - return p + (q - p) * (2 / 3 - t) * 6; - } - - return p; -}; - -module.export = HueToComponent; - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(496)(module))) - -/***/ }), -/* 230 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetColor = __webpack_require__(117); - -/** - * Converts an HSV (hue, saturation and value) color value to RGB. - * Conversion formula from http://en.wikipedia.org/wiki/HSL_color_space. - * Assumes HSV values are contained in the set [0, 1]. - * Based on code by Michael Jackson (https://github.com/mjijackson) - * - * @function Phaser.Display.Color.HSVToRGB - * @since 3.0.0 - * - * @param {number} h - The hue, in the range 0 - 1. - * @param {number} s - The saturation, in the range 0 - 1. - * @param {number} v - The value, in the range 0 - 1. - * - * @return {ColorObject} An object with the red, green and blue values set in the r, g and b properties. - */ -var HSVToRGB = function (h, s, v) -{ - if (s === undefined) { s = 1; } - if (v === undefined) { v = 1; } - - var i = Math.floor(h * 6); - var f = h * 6 - i; - - var p = Math.floor((v * (1 - s)) * 255); - var q = Math.floor((v * (1 - f * s)) * 255); - var t = Math.floor((v * (1 - (1 - f) * s)) * 255); - - v = Math.floor(v *= 255); - - var output = { r: v, g: v, b: v, color: 0 }; - - var r = i % 6; - - if (r === 0) - { - output.g = t; - output.b = p; - } - else if (r === 1) - { - output.r = q; - output.b = p; - } - else if (r === 2) - { - output.r = p; - output.b = t; - } - else if (r === 3) - { - output.r = p; - output.g = q; - } - else if (r === 4) - { - output.r = t; - output.g = p; - } - else if (r === 5) - { - output.g = p; - output.b = q; - } - - output.color = GetColor(output.r, output.g, output.b); - - return output; -}; - -module.exports = HSVToRGB; - - -/***/ }), -/* 231 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Between - * @since 3.0.0 - * - * @param {integer} min - [description] - * @param {integer} max - [description] - * - * @return {integer} [description] - */ -var Between = function (min, max) -{ - return Math.floor(Math.random() * (max - min + 1) + min); -}; - -module.exports = Between; - - -/***/ }), -/* 232 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var OS = __webpack_require__(67); - -/** - * Inspects the readyState of the document. If the document is already complete then it invokes the given callback. - * If not complete it sets up several event listeners such as `deviceready`, and once those fire, it invokes the callback. - * Called automatically by the Phaser.Game instance. Should not usually be accessed directly. - * - * @function Phaser.DOM.DOMContentLoaded - * @since 3.0.0 - * - * @param {function} callback - The callback to be invoked when the device is ready and the DOM content is loaded. - */ -var DOMContentLoaded = function (callback) -{ - if (document.readyState === 'complete' || document.readyState === 'interactive') - { - callback(); - - return; - } - - var check = function () - { - document.removeEventListener('deviceready', check, true); - document.removeEventListener('DOMContentLoaded', check, true); - window.removeEventListener('load', check, true); - - callback(); - }; - - if (!document.body) - { - window.setTimeout(check, 20); - } - else if (OS.cordova && !OS.cocoonJS) - { - // Ref. http://docs.phonegap.com/en/3.5.0/cordova_events_events.md.html#deviceready - document.addEventListener('deviceready', check, false); - } - else - { - document.addEventListener('DOMContentLoaded', check, true); - window.addEventListener('load', check, true); - } -}; - -module.exports = DOMContentLoaded; - - -/***/ }), -/* 233 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Takes the given data string and parses it as XML. - * First tries to use the window.DOMParser and reverts to the Microsoft.XMLDOM if that fails. - * The parsed XML object is returned, or `null` if there was an error while parsing the data. - * - * @function Phaser.DOM.ParseXML - * @since 3.0.0 - * - * @param {string} data - The XML source stored in a string. - * - * @return {any} The parsed XML data, or `null` if the data could not be parsed. - */ -var ParseXML = function (data) -{ - var xml = ''; - - try - { - if (window['DOMParser']) - { - var domparser = new DOMParser(); - xml = domparser.parseFromString(data, 'text/xml'); - } - else - { - xml = new ActiveXObject('Microsoft.XMLDOM'); - xml.loadXML(data); - } - } - catch (e) - { - xml = null; - } - - if (!xml || !xml.documentElement || xml.getElementsByTagName('parsererror').length) - { - return null; - } - else - { - return xml; - } -}; - -module.exports = ParseXML; - - -/***/ }), -/* 234 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Attempts to remove the element from its parentNode in the DOM. - * - * @function Phaser.DOM.RemoveFromDOM - * @since 3.0.0 - * - * @param {any} element - The DOM element to remove from its parent node. - */ -var RemoveFromDOM = function (element) -{ - if (element.parentNode) - { - element.parentNode.removeChild(element); - } -}; - -module.exports = RemoveFromDOM; - - -/***/ }), -/* 235 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var NOOP = __webpack_require__(3); - -/** - * @classdesc - * Abstracts away the use of RAF or setTimeOut for the core game update loop. - * This is invoked automatically by the Phaser.Game instance. - * - * @class RequestAnimationFrame - * @memberOf Phaser.DOM - * @constructor - * @since 3.0.0 - */ -var RequestAnimationFrame = new Class({ - - initialize: - - function RequestAnimationFrame () - { - /** - * True if RequestAnimationFrame is running, otherwise false. - * - * @name Phaser.DOM.RequestAnimationFrame#isRunning + * @name Phaser.Physics.Arcade.Body#isCircle * @type {boolean} * @default false * @since 3.0.0 */ - this.isRunning = false; + this.isCircle = false; /** - * The callback to be invoked each step. + * [description] * - * @name Phaser.DOM.RequestAnimationFrame#callback - * @type {function} - * @since 3.0.0 - */ - this.callback = NOOP; - - /** - * The most recent timestamp. Either a DOMHighResTimeStamp under RAF or `Date.now` under SetTimeout. - * - * @name Phaser.DOM.RequestAnimationFrame#tick - * @type {DOMHighResTimeStamp|number} + * @name Phaser.Physics.Arcade.Body#radius + * @type {number} * @default 0 * @since 3.0.0 */ - this.tick = 0; + this.radius = 0; /** - * True if the step is using setTimeout instead of RAF. + * [description] * - * @name Phaser.DOM.RequestAnimationFrame#isSetTimeOut - * @type {boolean} - * @default false + * @name Phaser.Physics.Arcade.Body#offset + * @type {Phaser.Math.Vector2} * @since 3.0.0 */ - this.isSetTimeOut = false; + this.offset = new Vector2(); /** - * The setTimeout or RAF callback ID used when canceling them. + * [description] * - * @name Phaser.DOM.RequestAnimationFrame#timeOutID - * @type {?number} + * @name Phaser.Physics.Arcade.Body#position + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.position = new Vector2(gameObject.x, gameObject.y); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#prev + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.prev = new Vector2(this.position.x, this.position.y); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#allowRotation + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.allowRotation = true; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#rotation + * @type {number} + * @since 3.0.0 + */ + this.rotation = gameObject.angle; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#preRotation + * @type {number} + * @since 3.0.0 + */ + this.preRotation = gameObject.angle; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#width + * @type {number} + * @since 3.0.0 + */ + this.width = gameObject.width; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#height + * @type {number} + * @since 3.0.0 + */ + this.height = gameObject.height; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#sourceWidth + * @type {number} + * @since 3.0.0 + */ + this.sourceWidth = gameObject.width; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#sourceHeight + * @type {number} + * @since 3.0.0 + */ + this.sourceHeight = gameObject.height; + + if (gameObject.frame) + { + this.sourceWidth = gameObject.frame.realWidth; + this.sourceHeight = gameObject.frame.realHeight; + } + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#halfWidth + * @type {number} + * @since 3.0.0 + */ + this.halfWidth = Math.abs(gameObject.width / 2); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#halfHeight + * @type {number} + * @since 3.0.0 + */ + this.halfHeight = Math.abs(gameObject.height / 2); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#center + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#velocity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.velocity = new Vector2(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#newVelocity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.newVelocity = new Vector2(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#deltaMax + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.deltaMax = new Vector2(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#acceleration + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.acceleration = new Vector2(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#allowDrag + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.allowDrag = true; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#drag + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.drag = new Vector2(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#allowGravity + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.allowGravity = true; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#gravity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.gravity = new Vector2(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#bounce + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.bounce = new Vector2(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#worldBounce + * @type {?Phaser.Math.Vector2} * @default null * @since 3.0.0 */ - this.timeOutID = null; + this.worldBounce = null; + + // If true this Body will dispatch events /** - * The previous time the step was called. + * Emit a `worldbounds` event when this body collides with the world bounds (and `collideWorldBounds` is also true). * - * @name Phaser.DOM.RequestAnimationFrame#lastTime - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.lastTime = 0; - - var _this = this; - - /** - * The RAF step function. - * Updates the local tick value, invokes the callback and schedules another call to requestAnimationFrame. - * - * @name Phaser.DOM.RequestAnimationFrame#step - * @type {function} - * @since 3.0.0 - */ - this.step = function step (timestamp) - { - // DOMHighResTimeStamp - _this.lastTime = _this.tick; - - _this.tick = timestamp; - - _this.callback(timestamp); - - _this.timeOutID = window.requestAnimationFrame(step); - }; - - /** - * The SetTimeout step function. - * Updates the local tick value, invokes the callback and schedules another call to setTimeout. - * - * @name Phaser.DOM.RequestAnimationFrame#stepTimeout - * @type {function} - * @since 3.0.0 - */ - this.stepTimeout = function stepTimeout () - { - var d = Date.now(); - - var delay = Math.max(16 + _this.lastTime - d, 0); - - _this.lastTime = _this.tick; - - _this.tick = d; - - _this.callback(d); - - _this.timeOutID = window.setTimeout(stepTimeout, delay); - }; - }, - - /** - * Starts the requestAnimationFrame or setTimeout process running. - * - * @method Phaser.DOM.RequestAnimationFrame#start - * @since 3.0.0 - * - * @param {function} callback - The callback to invoke each step. - * @param {boolean} forceSetTimeOut - Should it use SetTimeout, even if RAF is available? - */ - start: function (callback, forceSetTimeOut) - { - if (this.isRunning) - { - return; - } - - this.callback = callback; - - this.isSetTimeOut = forceSetTimeOut; - - this.isRunning = true; - - this.timeOutID = (forceSetTimeOut) ? window.setTimeout(this.stepTimeout, 0) : window.requestAnimationFrame(this.step); - }, - - /** - * Stops the requestAnimationFrame or setTimeout from running. - * - * @method Phaser.DOM.RequestAnimationFrame#stop - * @since 3.0.0 - */ - stop: function () - { - this.isRunning = false; - - if (this.isSetTimeOut) - { - clearTimeout(this.timeOutID); - } - else - { - window.cancelAnimationFrame(this.timeOutID); - } - }, - - /** - * Stops the step from running and clears the callback reference. - * - * @method Phaser.DOM.RequestAnimationFrame#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.stop(); - - this.callback = NOOP; - } - -}); - -module.exports = RequestAnimationFrame; - - -/***/ }), -/* 236 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Plugins - */ -var Plugins = { - - /** - * These are the Global Managers that are created by the Phaser.Game instance. - * They are referenced from Scene.Systems so that plugins can use them. - * - * @name Phaser.Plugins.Global - * @type {array} - * @since 3.0.0 - */ - Global: [ - - 'anims', - 'cache', - 'registry', - 'sound', - 'textures' - - ], - - /** - * These are the core plugins that are installed into every Scene.Systems instance, no matter what. - * They are optionally exposed in the Scene as well (see the InjectionMap for details) - * - * They are created in the order in which they appear in this array and EventEmitter is always first. - * - * @name Phaser.Plugins.CoreScene - * @type {array} - * @since 3.0.0 - */ - CoreScene: [ - - 'EventEmitter', - - 'CameraManager', - 'GameObjectCreator', - 'GameObjectFactory', - 'ScenePlugin', - 'DisplayList', - 'UpdateList' - - ], - - /** - * These plugins are created in Scene.Systems in addition to the CoreScenePlugins. - * - * You can elect not to have these plugins by either creating a DefaultPlugins object as part - * of the Game Config, by creating a Plugins object as part of a Scene Config, or by modifying this array - * and building your own bundle. - * - * They are optionally exposed in the Scene as well (see the InjectionMap for details) - * - * They are always created in the order in which they appear in the array. - * - * @name Phaser.Plugins.DefaultScene - * @type {array} - * @since 3.0.0 - */ - DefaultScene: [ - - 'CameraManager3D', - 'Clock', - 'DataManagerPlugin', - 'InputPlugin', - 'Loader', - 'TweenManager', - 'LightsPlugin' - - ] - -}; - -/* - * "Sometimes, the elegant implementation is just a function. - * Not a method. Not a class. Not a framework. Just a function." - * -- John Carmack - */ - -module.exports = Plugins; - - -/***/ }), -/* 237 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CanvasPool = __webpack_require__(21); - -/** - * Determines the canvas features of the browser running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.canvasFeatures` from within any Scene. - * - * @name Phaser.Device.CanvasFeatures - * @since 3.0.0 - * - * @type {object} - * @property {boolean} supportInverseAlpha - Set to true if the browser supports inversed alpha. - * @property {boolean} supportNewBlendModes - Set to true if the browser supports new canvas blend modes. - */ -var CanvasFeatures = { - - supportInverseAlpha: false, - supportNewBlendModes: false - -}; - -function checkBlendMode () -{ - var pngHead = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/'; - var pngEnd = 'AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg=='; - - var magenta = new Image(); - - magenta.onload = function () - { - var yellow = new Image(); - - yellow.onload = function () - { - var canvas = CanvasPool.create(yellow, 6, 1); - var context = canvas.getContext('2d'); - - context.globalCompositeOperation = 'multiply'; - - context.drawImage(magenta, 0, 0); - context.drawImage(yellow, 2, 0); - - if (!context.getImageData(2, 0, 1, 1)) - { - return false; - } - - var data = context.getImageData(2, 0, 1, 1).data; - - CanvasPool.remove(yellow); - - CanvasFeatures.supportNewBlendModes = (data[0] === 255 && data[1] === 0 && data[2] === 0); - }; - - yellow.src = pngHead + '/wCKxvRF' + pngEnd; - }; - - magenta.src = pngHead + 'AP804Oa6' + pngEnd; - - return false; -} - -function checkInverseAlpha () -{ - var canvas = CanvasPool.create(this, 2, 1); - var context = canvas.getContext('2d'); - - context.fillStyle = 'rgba(10, 20, 30, 0.5)'; - - // Draw a single pixel - context.fillRect(0, 0, 1, 1); - - // Get the color values - var s1 = context.getImageData(0, 0, 1, 1); - - if (s1 === null) - { - return false; - } - - // Plot them to x2 - context.putImageData(s1, 1, 0); - - // Get those values - var s2 = context.getImageData(1, 0, 1, 1); - - // Compare and return - return (s2.data[0] === s1.data[0] && s2.data[1] === s1.data[1] && s2.data[2] === s1.data[2] && s2.data[3] === s1.data[3]); -} - -function init () -{ - if (document !== undefined) - { - CanvasFeatures.supportNewBlendModes = checkBlendMode(); - CanvasFeatures.supportInverseAlpha = checkInverseAlpha(); - } - - return CanvasFeatures; -} - -module.exports = init(); - - -/***/ }), -/* 238 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// 2.1.1 (Mar 17, 2016) - -/* -ISC License - -Copyright (c) 2016, Mapbox - -Permission to use, copy, modify, and/or distribute this software for any purpose -with or without fee is hereby granted, provided that the above copyright notice -and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS -OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - */ - - - -module.exports = earcut; - -/* -vertices is a flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...]. -holes is an array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). -dimensions is the number of coordinates per vertice in the input array (2 by default). -Each group of three vertice indices in the resulting array forms a triangle. - */ - -function earcut(data, holeIndices, dim) { - - dim = dim || 2; - - var hasHoles = holeIndices && holeIndices.length, - outerLen = hasHoles ? holeIndices[0] * dim : data.length, - outerNode = linkedList(data, 0, outerLen, dim, true), - triangles = []; - - if (!outerNode) return triangles; - - var minX, minY, maxX, maxY, x, y, size; - - if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim); - - // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox - if (data.length > 80 * dim) { - minX = maxX = data[0]; - minY = maxY = data[1]; - - for (var i = dim; i < outerLen; i += dim) { - x = data[i]; - y = data[i + 1]; - if (x < minX) minX = x; - if (y < minY) minY = y; - if (x > maxX) maxX = x; - if (y > maxY) maxY = y; - } - - // minX, minY and size are later used to transform coords into integers for z-order calculation - size = Math.max(maxX - minX, maxY - minY); - } - - earcutLinked(outerNode, triangles, dim, minX, minY, size); - - return triangles; -} - -// create a circular doubly linked list from polygon points in the specified winding order -function linkedList(data, start, end, dim, clockwise) { - var i, last; - - if (clockwise === (signedArea(data, start, end, dim) > 0)) { - for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last); - } else { - for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last); - } - - if (last && equals(last, last.next)) { - removeNode(last); - last = last.next; - } - - return last; -} - -// eliminate colinear or duplicate points -function filterPoints(start, end) { - if (!start) return start; - if (!end) end = start; - - var p = start, - again; - do { - again = false; - - if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) { - removeNode(p); - p = end = p.prev; - if (p === p.next) return null; - again = true; - - } else { - p = p.next; - } - } while (again || p !== end); - - return end; -} - -// main ear slicing loop which triangulates a polygon (given as a linked list) -function earcutLinked(ear, triangles, dim, minX, minY, size, pass) { - if (!ear) return; - - // interlink polygon nodes in z-order - if (!pass && size) indexCurve(ear, minX, minY, size); - - var stop = ear, - prev, next; - - // iterate through ears, slicing them one by one - while (ear.prev !== ear.next) { - prev = ear.prev; - next = ear.next; - - if (size ? isEarHashed(ear, minX, minY, size) : isEar(ear)) { - // cut off the triangle - triangles.push(prev.i / dim); - triangles.push(ear.i / dim); - triangles.push(next.i / dim); - - removeNode(ear); - - // skipping the next vertice leads to less sliver triangles - ear = next.next; - stop = next.next; - - continue; - } - - ear = next; - - // if we looped through the whole remaining polygon and can't find any more ears - if (ear === stop) { - // try filtering points and slicing again - if (!pass) { - earcutLinked(filterPoints(ear), triangles, dim, minX, minY, size, 1); - - // if this didn't work, try curing all small self-intersections locally - } else if (pass === 1) { - ear = cureLocalIntersections(ear, triangles, dim); - earcutLinked(ear, triangles, dim, minX, minY, size, 2); - - // as a last resort, try splitting the remaining polygon into two - } else if (pass === 2) { - splitEarcut(ear, triangles, dim, minX, minY, size); - } - - break; - } - } -} - -// check whether a polygon node forms a valid ear with adjacent nodes -function isEar(ear) { - var a = ear.prev, - b = ear, - c = ear.next; - - if (area(a, b, c) >= 0) return false; // reflex, can't be an ear - - // now make sure we don't have other points inside the potential ear - var p = ear.next.next; - - while (p !== ear.prev) { - if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && - area(p.prev, p, p.next) >= 0) return false; - p = p.next; - } - - return true; -} - -function isEarHashed(ear, minX, minY, size) { - var a = ear.prev, - b = ear, - c = ear.next; - - if (area(a, b, c) >= 0) return false; // reflex, can't be an ear - - // triangle bbox; min & max are calculated like this for speed - var minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : (b.x < c.x ? b.x : c.x), - minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : (b.y < c.y ? b.y : c.y), - maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : (b.x > c.x ? b.x : c.x), - maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : (b.y > c.y ? b.y : c.y); - - // z-order range for the current triangle bbox; - var minZ = zOrder(minTX, minTY, minX, minY, size), - maxZ = zOrder(maxTX, maxTY, minX, minY, size); - - // first look for points inside the triangle in increasing z-order - var p = ear.nextZ; - - while (p && p.z <= maxZ) { - if (p !== ear.prev && p !== ear.next && - pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && - area(p.prev, p, p.next) >= 0) return false; - p = p.nextZ; - } - - // then look for points in decreasing z-order - p = ear.prevZ; - - while (p && p.z >= minZ) { - if (p !== ear.prev && p !== ear.next && - pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && - area(p.prev, p, p.next) >= 0) return false; - p = p.prevZ; - } - - return true; -} - -// go through all polygon nodes and cure small local self-intersections -function cureLocalIntersections(start, triangles, dim) { - var p = start; - do { - var a = p.prev, - b = p.next.next; - - if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) { - - triangles.push(a.i / dim); - triangles.push(p.i / dim); - triangles.push(b.i / dim); - - // remove two nodes involved - removeNode(p); - removeNode(p.next); - - p = start = b; - } - p = p.next; - } while (p !== start); - - return p; -} - -// try splitting polygon into two and triangulate them independently -function splitEarcut(start, triangles, dim, minX, minY, size) { - // look for a valid diagonal that divides the polygon into two - var a = start; - do { - var b = a.next.next; - while (b !== a.prev) { - if (a.i !== b.i && isValidDiagonal(a, b)) { - // split the polygon in two by the diagonal - var c = splitPolygon(a, b); - - // filter colinear points around the cuts - a = filterPoints(a, a.next); - c = filterPoints(c, c.next); - - // run earcut on each half - earcutLinked(a, triangles, dim, minX, minY, size); - earcutLinked(c, triangles, dim, minX, minY, size); - return; - } - b = b.next; - } - a = a.next; - } while (a !== start); -} - -// link every hole into the outer loop, producing a single-ring polygon without holes -function eliminateHoles(data, holeIndices, outerNode, dim) { - var queue = [], - i, len, start, end, list; - - for (i = 0, len = holeIndices.length; i < len; i++) { - start = holeIndices[i] * dim; - end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; - list = linkedList(data, start, end, dim, false); - if (list === list.next) list.steiner = true; - queue.push(getLeftmost(list)); - } - - queue.sort(compareX); - - // process holes from left to right - for (i = 0; i < queue.length; i++) { - eliminateHole(queue[i], outerNode); - outerNode = filterPoints(outerNode, outerNode.next); - } - - return outerNode; -} - -function compareX(a, b) { - return a.x - b.x; -} - -// find a bridge between vertices that connects hole with an outer ring and and link it -function eliminateHole(hole, outerNode) { - outerNode = findHoleBridge(hole, outerNode); - if (outerNode) { - var b = splitPolygon(outerNode, hole); - filterPoints(b, b.next); - } -} - -// David Eberly's algorithm for finding a bridge between hole and outer polygon -function findHoleBridge(hole, outerNode) { - var p = outerNode, - hx = hole.x, - hy = hole.y, - qx = -Infinity, - m; - - // find a segment intersected by a ray from the hole's leftmost point to the left; - // segment's endpoint with lesser x will be potential connection point - do { - if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) { - var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y); - if (x <= hx && x > qx) { - qx = x; - if (x === hx) { - if (hy === p.y) return p; - if (hy === p.next.y) return p.next; - } - m = p.x < p.next.x ? p : p.next; - } - } - p = p.next; - } while (p !== outerNode); - - if (!m) return null; - - if (hx === qx) return m.prev; // hole touches outer segment; pick lower endpoint - - // look for points inside the triangle of hole point, segment intersection and endpoint; - // if there are no points found, we have a valid connection; - // otherwise choose the point of the minimum angle with the ray as connection point - - var stop = m, - mx = m.x, - my = m.y, - tanMin = Infinity, - tan; - - p = m.next; - - while (p !== stop) { - if (hx >= p.x && p.x >= mx && hx !== p.x && - pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) { - - tan = Math.abs(hy - p.y) / (hx - p.x); // tangential - - if ((tan < tanMin || (tan === tanMin && p.x > m.x)) && locallyInside(p, hole)) { - m = p; - tanMin = tan; - } - } - - p = p.next; - } - - return m; -} - -// interlink polygon nodes in z-order -function indexCurve(start, minX, minY, size) { - var p = start; - do { - if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, size); - p.prevZ = p.prev; - p.nextZ = p.next; - p = p.next; - } while (p !== start); - - p.prevZ.nextZ = null; - p.prevZ = null; - - sortLinked(p); -} - -// Simon Tatham's linked list merge sort algorithm -// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html -function sortLinked(list) { - var i, p, q, e, tail, numMerges, pSize, qSize, - inSize = 1; - - do { - p = list; - list = null; - tail = null; - numMerges = 0; - - while (p) { - numMerges++; - q = p; - pSize = 0; - for (i = 0; i < inSize; i++) { - pSize++; - q = q.nextZ; - if (!q) break; - } - qSize = inSize; - - while (pSize > 0 || (qSize > 0 && q)) { - - if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) { - e = p; - p = p.nextZ; - pSize--; - } else { - e = q; - q = q.nextZ; - qSize--; - } - - if (tail) tail.nextZ = e; - else list = e; - - e.prevZ = tail; - tail = e; - } - - p = q; - } - - tail.nextZ = null; - inSize *= 2; - - } while (numMerges > 1); - - return list; -} - -// z-order of a point given coords and size of the data bounding box -function zOrder(x, y, minX, minY, size) { - // coords are transformed into non-negative 15-bit integer range - x = 32767 * (x - minX) / size; - y = 32767 * (y - minY) / size; - - x = (x | (x << 8)) & 0x00FF00FF; - x = (x | (x << 4)) & 0x0F0F0F0F; - x = (x | (x << 2)) & 0x33333333; - x = (x | (x << 1)) & 0x55555555; - - y = (y | (y << 8)) & 0x00FF00FF; - y = (y | (y << 4)) & 0x0F0F0F0F; - y = (y | (y << 2)) & 0x33333333; - y = (y | (y << 1)) & 0x55555555; - - return x | (y << 1); -} - -// find the leftmost node of a polygon ring -function getLeftmost(start) { - var p = start, - leftmost = start; - do { - if (p.x < leftmost.x) leftmost = p; - p = p.next; - } while (p !== start); - - return leftmost; -} - -// check if a point lies within a convex triangle -function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) { - return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && - (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && - (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0; -} - -// check if a diagonal between two polygon nodes is valid (lies in polygon interior) -function isValidDiagonal(a, b) { - return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && - locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b); -} - -// signed area of a triangle -function area(p, q, r) { - return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); -} - -// check if two points are equal -function equals(p1, p2) { - return p1.x === p2.x && p1.y === p2.y; -} - -// check if two segments intersect -function intersects(p1, q1, p2, q2) { - if ((equals(p1, q1) && equals(p2, q2)) || - (equals(p1, q2) && equals(p2, q1))) return true; - return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 && - area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0; -} - -// check if a polygon diagonal intersects any polygon segments -function intersectsPolygon(a, b) { - var p = a; - do { - if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && - intersects(p, p.next, a, b)) return true; - p = p.next; - } while (p !== a); - - return false; -} - -// check if a polygon diagonal is locally inside the polygon -function locallyInside(a, b) { - return area(a.prev, a, a.next) < 0 ? - area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : - area(a, b, a.prev) < 0 || area(a, a.next, b) < 0; -} - -// check if the middle point of a polygon diagonal is inside the polygon -function middleInside(a, b) { - var p = a, - inside = false, - px = (a.x + b.x) / 2, - py = (a.y + b.y) / 2; - do { - if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y && - (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)) - inside = !inside; - p = p.next; - } while (p !== a); - - return inside; -} - -// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two; -// if one belongs to the outer ring and another to a hole, it merges it into a single ring -function splitPolygon(a, b) { - var a2 = new Node(a.i, a.x, a.y), - b2 = new Node(b.i, b.x, b.y), - an = a.next, - bp = b.prev; - - a.next = b; - b.prev = a; - - a2.next = an; - an.prev = a2; - - b2.next = a2; - a2.prev = b2; - - bp.next = b2; - b2.prev = bp; - - return b2; -} - -// create a node and optionally link it with previous one (in a circular doubly linked list) -function insertNode(i, x, y, last) { - var p = new Node(i, x, y); - - if (!last) { - p.prev = p; - p.next = p; - - } else { - p.next = last.next; - p.prev = last; - last.next.prev = p; - last.next = p; - } - return p; -} - -function removeNode(p) { - p.next.prev = p.prev; - p.prev.next = p.next; - - if (p.prevZ) p.prevZ.nextZ = p.nextZ; - if (p.nextZ) p.nextZ.prevZ = p.prevZ; -} - -function Node(i, x, y) { - // vertice index in coordinates array - this.i = i; - - // vertex coordinates - this.x = x; - this.y = y; - - // previous and next vertice nodes in a polygon ring - this.prev = null; - this.next = null; - - // z-order curve value - this.z = null; - - // previous and next nodes in z-order - this.prevZ = null; - this.nextZ = null; - - // indicates whether this is a steiner point - this.steiner = false; -} - -// return a percentage difference between the polygon area and its triangulation area; -// used to verify correctness of triangulation -earcut.deviation = function (data, holeIndices, dim, triangles) { - var hasHoles = holeIndices && holeIndices.length; - var outerLen = hasHoles ? holeIndices[0] * dim : data.length; - - var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim)); - if (hasHoles) { - for (var i = 0, len = holeIndices.length; i < len; i++) { - var start = holeIndices[i] * dim; - var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; - polygonArea -= Math.abs(signedArea(data, start, end, dim)); - } - } - - var trianglesArea = 0; - for (i = 0; i < triangles.length; i += 3) { - var a = triangles[i] * dim; - var b = triangles[i + 1] * dim; - var c = triangles[i + 2] * dim; - trianglesArea += Math.abs( - (data[a] - data[c]) * (data[b + 1] - data[a + 1]) - - (data[a] - data[b]) * (data[c + 1] - data[a + 1])); - } - - return polygonArea === 0 && trianglesArea === 0 ? 0 : - Math.abs((trianglesArea - polygonArea) / polygonArea); -}; - -function signedArea(data, start, end, dim) { - var sum = 0; - for (var i = start, j = end - dim; i < end; i += dim) { - sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]); - j = i; - } - return sum; -} - -// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts -earcut.flatten = function (data) { - var dim = data[0][0].length, - result = {vertices: [], holes: [], dimensions: dim}, - holeIndex = 0; - - for (var i = 0; i < data.length; i++) { - for (var j = 0; j < data[i].length; j++) { - for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]); - } - if (i > 0) { - holeIndex += data[i - 1].length; - result.holes.push(holeIndex); - } - } - return result; -}; - -/***/ }), -/* 239 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ModelViewProjection = { - - modelMatrixDirty: false, - viewMatrixDirty: false, - projectionMatrixDirty: false, - modelMatrix: null, - viewMatrix: null, - projectionMatrix: null, - - mvpInit: function () - { - this.modelMatrixDirty = true; - this.viewMatrixDirty = true; - this.projectionMatrixDirty = true; - - this.modelMatrix = new Float32Array([ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 - ]); - - this.viewMatrix = new Float32Array([ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 - ]); - - this.projectionMatrix = new Float32Array([ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 - ]); - - return this; - }, - - mvpUpdate: function () - { - var program = this.program; - - if (this.modelMatrixDirty) - { - this.renderer.setMatrix4(program, 'uModelMatrix', false, this.modelMatrix); - this.modelMatrixDirty = false; - } - - if (this.viewMatrixDirty) - { - this.renderer.setMatrix4(program, 'uViewMatrix', false, this.viewMatrix); - this.viewMatrixDirty = false; - } - - if (this.projectionMatrixDirty) - { - this.renderer.setMatrix4(program, 'uProjectionMatrix', false, this.projectionMatrix); - this.projectionMatrixDirty = false; - } - - return this; - }, - - modelIdentity: function () - { - var modelMatrix = this.modelMatrix; - - modelMatrix[0] = 1; - modelMatrix[1] = 0; - modelMatrix[2] = 0; - modelMatrix[3] = 0; - modelMatrix[4] = 0; - modelMatrix[5] = 1; - modelMatrix[6] = 0; - modelMatrix[7] = 0; - modelMatrix[8] = 0; - modelMatrix[9] = 0; - modelMatrix[10] = 1; - modelMatrix[11] = 0; - modelMatrix[12] = 0; - modelMatrix[13] = 0; - modelMatrix[14] = 0; - modelMatrix[15] = 1; - - this.modelMatrixDirty = true; - - return this; - }, - - modelScale: function (x, y, z) - { - var modelMatrix = this.modelMatrix; - - modelMatrix[0] = modelMatrix[0] * x; - modelMatrix[1] = modelMatrix[1] * x; - modelMatrix[2] = modelMatrix[2] * x; - modelMatrix[3] = modelMatrix[3] * x; - modelMatrix[4] = modelMatrix[4] * y; - modelMatrix[5] = modelMatrix[5] * y; - modelMatrix[6] = modelMatrix[6] * y; - modelMatrix[7] = modelMatrix[7] * y; - modelMatrix[8] = modelMatrix[8] * z; - modelMatrix[9] = modelMatrix[9] * z; - modelMatrix[10] = modelMatrix[10] * z; - modelMatrix[11] = modelMatrix[11] * z; - - this.modelMatrixDirty = true; - - return this; - }, - - modelTranslate: function (x, y, z) - { - var modelMatrix = this.modelMatrix; - - modelMatrix[12] = modelMatrix[0] * x + modelMatrix[4] * y + modelMatrix[8] * z + modelMatrix[12]; - modelMatrix[13] = modelMatrix[1] * x + modelMatrix[5] * y + modelMatrix[9] * z + modelMatrix[13]; - modelMatrix[14] = modelMatrix[2] * x + modelMatrix[6] * y + modelMatrix[10] * z + modelMatrix[14]; - modelMatrix[15] = modelMatrix[3] * x + modelMatrix[7] * y + modelMatrix[11] * z + modelMatrix[15]; - - this.modelMatrixDirty = true; - - return this; - }, - - modelRotateX: function (radians) - { - var modelMatrix = this.modelMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a10 = modelMatrix[4]; - var a11 = modelMatrix[5]; - var a12 = modelMatrix[6]; - var a13 = modelMatrix[7]; - var a20 = modelMatrix[8]; - var a21 = modelMatrix[9]; - var a22 = modelMatrix[10]; - var a23 = modelMatrix[11]; - - modelMatrix[4] = a10 * c + a20 * s; - modelMatrix[5] = a11 * c + a21 * s; - modelMatrix[6] = a12 * c + a22 * s; - modelMatrix[7] = a13 * c + a23 * s; - modelMatrix[8] = a20 * c - a10 * s; - modelMatrix[9] = a21 * c - a11 * s; - modelMatrix[10] = a22 * c - a12 * s; - modelMatrix[11] = a23 * c - a13 * s; - - this.modelMatrixDirty = true; - - return this; - }, - - modelRotateY: function (radians) - { - var modelMatrix = this.modelMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a00 = modelMatrix[0]; - var a01 = modelMatrix[1]; - var a02 = modelMatrix[2]; - var a03 = modelMatrix[3]; - var a20 = modelMatrix[8]; - var a21 = modelMatrix[9]; - var a22 = modelMatrix[10]; - var a23 = modelMatrix[11]; - - modelMatrix[0] = a00 * c - a20 * s; - modelMatrix[1] = a01 * c - a21 * s; - modelMatrix[2] = a02 * c - a22 * s; - modelMatrix[3] = a03 * c - a23 * s; - modelMatrix[8] = a00 * s + a20 * c; - modelMatrix[9] = a01 * s + a21 * c; - modelMatrix[10] = a02 * s + a22 * c; - modelMatrix[11] = a03 * s + a23 * c; - - this.modelMatrixDirty = true; - - return this; - }, - - modelRotateZ: function (radians) - { - var modelMatrix = this.modelMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a00 = modelMatrix[0]; - var a01 = modelMatrix[1]; - var a02 = modelMatrix[2]; - var a03 = modelMatrix[3]; - var a10 = modelMatrix[4]; - var a11 = modelMatrix[5]; - var a12 = modelMatrix[6]; - var a13 = modelMatrix[7]; - - modelMatrix[0] = a00 * c + a10 * s; - modelMatrix[1] = a01 * c + a11 * s; - modelMatrix[2] = a02 * c + a12 * s; - modelMatrix[3] = a03 * c + a13 * s; - modelMatrix[4] = a10 * c - a00 * s; - modelMatrix[5] = a11 * c - a01 * s; - modelMatrix[6] = a12 * c - a02 * s; - modelMatrix[7] = a13 * c - a03 * s; - - this.modelMatrixDirty = true; - - return this; - }, - - viewIdentity: function () - { - var viewMatrix = this.viewMatrix; - - viewMatrix[0] = 1; - viewMatrix[1] = 0; - viewMatrix[2] = 0; - viewMatrix[3] = 0; - viewMatrix[4] = 0; - viewMatrix[5] = 1; - viewMatrix[6] = 0; - viewMatrix[7] = 0; - viewMatrix[8] = 0; - viewMatrix[9] = 0; - viewMatrix[10] = 1; - viewMatrix[11] = 0; - viewMatrix[12] = 0; - viewMatrix[13] = 0; - viewMatrix[14] = 0; - viewMatrix[15] = 1; - - this.viewMatrixDirty = true; - - return this; - }, - - viewScale: function (x, y, z) - { - var viewMatrix = this.viewMatrix; - - viewMatrix[0] = viewMatrix[0] * x; - viewMatrix[1] = viewMatrix[1] * x; - viewMatrix[2] = viewMatrix[2] * x; - viewMatrix[3] = viewMatrix[3] * x; - viewMatrix[4] = viewMatrix[4] * y; - viewMatrix[5] = viewMatrix[5] * y; - viewMatrix[6] = viewMatrix[6] * y; - viewMatrix[7] = viewMatrix[7] * y; - viewMatrix[8] = viewMatrix[8] * z; - viewMatrix[9] = viewMatrix[9] * z; - viewMatrix[10] = viewMatrix[10] * z; - viewMatrix[11] = viewMatrix[11] * z; - - this.viewMatrixDirty = true; - - return this; - }, - - viewTranslate: function (x, y, z) - { - var viewMatrix = this.viewMatrix; - - viewMatrix[12] = viewMatrix[0] * x + viewMatrix[4] * y + viewMatrix[8] * z + viewMatrix[12]; - viewMatrix[13] = viewMatrix[1] * x + viewMatrix[5] * y + viewMatrix[9] * z + viewMatrix[13]; - viewMatrix[14] = viewMatrix[2] * x + viewMatrix[6] * y + viewMatrix[10] * z + viewMatrix[14]; - viewMatrix[15] = viewMatrix[3] * x + viewMatrix[7] * y + viewMatrix[11] * z + viewMatrix[15]; - - this.viewMatrixDirty = true; - - return this; - }, - - viewRotateX: function (radians) - { - var viewMatrix = this.viewMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a10 = viewMatrix[4]; - var a11 = viewMatrix[5]; - var a12 = viewMatrix[6]; - var a13 = viewMatrix[7]; - var a20 = viewMatrix[8]; - var a21 = viewMatrix[9]; - var a22 = viewMatrix[10]; - var a23 = viewMatrix[11]; - - viewMatrix[4] = a10 * c + a20 * s; - viewMatrix[5] = a11 * c + a21 * s; - viewMatrix[6] = a12 * c + a22 * s; - viewMatrix[7] = a13 * c + a23 * s; - viewMatrix[8] = a20 * c - a10 * s; - viewMatrix[9] = a21 * c - a11 * s; - viewMatrix[10] = a22 * c - a12 * s; - viewMatrix[11] = a23 * c - a13 * s; - - this.viewMatrixDirty = true; - - return this; - }, - - viewRotateY: function (radians) - { - var viewMatrix = this.viewMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a00 = viewMatrix[0]; - var a01 = viewMatrix[1]; - var a02 = viewMatrix[2]; - var a03 = viewMatrix[3]; - var a20 = viewMatrix[8]; - var a21 = viewMatrix[9]; - var a22 = viewMatrix[10]; - var a23 = viewMatrix[11]; - - viewMatrix[0] = a00 * c - a20 * s; - viewMatrix[1] = a01 * c - a21 * s; - viewMatrix[2] = a02 * c - a22 * s; - viewMatrix[3] = a03 * c - a23 * s; - viewMatrix[8] = a00 * s + a20 * c; - viewMatrix[9] = a01 * s + a21 * c; - viewMatrix[10] = a02 * s + a22 * c; - viewMatrix[11] = a03 * s + a23 * c; - - this.viewMatrixDirty = true; - - return this; - }, - - viewRotateZ: function (radians) - { - var viewMatrix = this.viewMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a00 = viewMatrix[0]; - var a01 = viewMatrix[1]; - var a02 = viewMatrix[2]; - var a03 = viewMatrix[3]; - var a10 = viewMatrix[4]; - var a11 = viewMatrix[5]; - var a12 = viewMatrix[6]; - var a13 = viewMatrix[7]; - - viewMatrix[0] = a00 * c + a10 * s; - viewMatrix[1] = a01 * c + a11 * s; - viewMatrix[2] = a02 * c + a12 * s; - viewMatrix[3] = a03 * c + a13 * s; - viewMatrix[4] = a10 * c - a00 * s; - viewMatrix[5] = a11 * c - a01 * s; - viewMatrix[6] = a12 * c - a02 * s; - viewMatrix[7] = a13 * c - a03 * s; - - this.viewMatrixDirty = true; - - return this; - }, - - viewLoad2D: function (matrix2D) - { - var vm = this.viewMatrix; - - vm[0] = matrix2D[0]; - vm[1] = matrix2D[1]; - vm[2] = 0.0; - vm[3] = 0.0; - vm[4] = matrix2D[2]; - vm[5] = matrix2D[3]; - vm[6] = 0.0; - vm[7] = 0.0; - vm[8] = matrix2D[4]; - vm[9] = matrix2D[5]; - vm[10] = 1.0; - vm[11] = 0.0; - vm[12] = 0.0; - vm[13] = 0.0; - vm[14] = 0.0; - vm[15] = 1.0; - - this.viewMatrixDirty = true; - - return this; - }, - - viewLoad: function (matrix) - { - var vm = this.viewMatrix; - - vm[0] = matrix[0]; - vm[1] = matrix[1]; - vm[2] = matrix[2]; - vm[3] = matrix[3]; - vm[4] = matrix[4]; - vm[5] = matrix[5]; - vm[6] = matrix[6]; - vm[7] = matrix[7]; - vm[8] = matrix[8]; - vm[9] = matrix[9]; - vm[10] = matrix[10]; - vm[11] = matrix[11]; - vm[12] = matrix[12]; - vm[13] = matrix[13]; - vm[14] = matrix[14]; - vm[15] = matrix[15]; - - this.viewMatrixDirty = true; - - return this; - }, - - projIdentity: function () - { - var projectionMatrix = this.projectionMatrix; - - projectionMatrix[0] = 1; - projectionMatrix[1] = 0; - projectionMatrix[2] = 0; - projectionMatrix[3] = 0; - projectionMatrix[4] = 0; - projectionMatrix[5] = 1; - projectionMatrix[6] = 0; - projectionMatrix[7] = 0; - projectionMatrix[8] = 0; - projectionMatrix[9] = 0; - projectionMatrix[10] = 1; - projectionMatrix[11] = 0; - projectionMatrix[12] = 0; - projectionMatrix[13] = 0; - projectionMatrix[14] = 0; - projectionMatrix[15] = 1; - - this.projectionMatrixDirty = true; - - return this; - }, - - projOrtho: function (left, right, bottom, top, near, far) - { - var projectionMatrix = this.projectionMatrix; - var leftRight = 1.0 / (left - right); - var bottomTop = 1.0 / (bottom - top); - var nearFar = 1.0 / (near - far); - - projectionMatrix[0] = -2.0 * leftRight; - projectionMatrix[1] = 0.0; - projectionMatrix[2] = 0.0; - projectionMatrix[3] = 0.0; - projectionMatrix[4] = 0.0; - projectionMatrix[5] = -2.0 * bottomTop; - projectionMatrix[6] = 0.0; - projectionMatrix[7] = 0.0; - projectionMatrix[8] = 0.0; - projectionMatrix[9] = 0.0; - projectionMatrix[10] = 2.0 * nearFar; - projectionMatrix[11] = 0.0; - projectionMatrix[12] = (left + right) * leftRight; - projectionMatrix[13] = (top + bottom) * bottomTop; - projectionMatrix[14] = (far + near) * nearFar; - projectionMatrix[15] = 1.0; - - this.projectionMatrixDirty = true; - return this; - }, - - projPersp: function (fovy, aspectRatio, near, far) - { - var projectionMatrix = this.projectionMatrix; - var fov = 1.0 / Math.tan(fovy / 2.0); - var nearFar = 1.0 / (near - far); - - projectionMatrix[0] = fov / aspectRatio; - projectionMatrix[1] = 0.0; - projectionMatrix[2] = 0.0; - projectionMatrix[3] = 0.0; - projectionMatrix[4] = 0.0; - projectionMatrix[5] = fov; - projectionMatrix[6] = 0.0; - projectionMatrix[7] = 0.0; - projectionMatrix[8] = 0.0; - projectionMatrix[9] = 0.0; - projectionMatrix[10] = (far + near) * nearFar; - projectionMatrix[11] = -1.0; - projectionMatrix[12] = 0.0; - projectionMatrix[13] = 0.0; - projectionMatrix[14] = (2.0 * far * near) * nearFar; - projectionMatrix[15] = 0.0; - - this.projectionMatrixDirty = true; - return this; - } -}; - -module.exports = ModelViewProjection; - - -/***/ }), -/* 240 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(14); -var Gamepad = __webpack_require__(241); -var Keyboard = __webpack_require__(245); -var Mouse = __webpack_require__(248); -var Pointer = __webpack_require__(249); -var Rectangle = __webpack_require__(8); -var Touch = __webpack_require__(250); -var TransformXY = __webpack_require__(251); - -/** - * @classdesc - * [description] - * - * @class InputManager - * @memberOf Phaser.Input - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - [description] - * @param {object} config - [description] - */ -var InputManager = new Class({ - - initialize: - - function InputManager (game, config) - { - /** - * [description] - * - * @name Phaser.Input.InputManager#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game = game; - - /** - * [description] - * - * @name Phaser.Input.InputManager#canvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.canvas; - - /** - * [description] - * - * @name Phaser.Input.InputManager#config - * @type {object} - * @since 3.0.0 - */ - this.config = config; - - /** - * [description] - * - * @name Phaser.Input.InputManager#enabled - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.enabled = true; - - /** - * [description] - * - * @name Phaser.Input.InputManager#events - * @type {EventEmitter} - * @since 3.0.0 - */ - this.events = new EventEmitter(); - - /** - * Standard FIFO queue. - * - * @name Phaser.Input.InputManager#queue - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.queue = []; - - /** - * [description] - * - * @name Phaser.Input.InputManager#keyboard - * @type {Phaser.Input.Keyboard.KeyboardManager} - * @since 3.0.0 - */ - this.keyboard = new Keyboard(this); - - /** - * [description] - * - * @name Phaser.Input.InputManager#mouse - * @type {Phaser.Input.Mouse.MouseManager} - * @since 3.0.0 - */ - this.mouse = new Mouse(this); - - /** - * [description] - * - * @name Phaser.Input.InputManager#touch - * @type {Phaser.Input.Touch.TouchManager} - * @since 3.0.0 - */ - this.touch = new Touch(this); - - /** - * [description] - * - * @name Phaser.Input.InputManager#gamepad - * @type {Phaser.Input.Gamepad.GamepadManager} - * @since 3.0.0 - */ - this.gamepad = new Gamepad(this); - - /** - * [description] - * - * @name Phaser.Input.InputManager#activePointer - * @type {[type]} - * @since 3.0.0 - */ - this.activePointer = new Pointer(this, 0); - - /** - * [description] - * - * @name Phaser.Input.InputManager#scale - * @type {object} - * @since 3.0.0 - */ - this.scale = { x: 1, y: 1 }; - - /** - * If the top-most Scene in the Scene List receives an input it will stop input from - * propagating any lower down the scene list, i.e. if you have a UI Scene at the top - * and click something on it, that click will not then be passed down to any other - * Scene below. Disable this to have input events passed through all Scenes, all the time. - * - * @name Phaser.Input.InputManager#globalTopOnly - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.globalTopOnly = true; - - /** - * [description] - * - * @name Phaser.Input.InputManager#ignoreEvents + * @name Phaser.Physics.Arcade.Body#onWorldBounds * @type {boolean} * @default false * @since 3.0.0 */ - this.ignoreEvents = false; + this.onWorldBounds = false; /** * [description] * - * @name Phaser.Input.InputManager#bounds - * @type {Phaser.Geom.Rectangle} - * @since 3.0.0 - */ - this.bounds = new Rectangle(); - - /** - * [description] - * - * @name Phaser.Input.InputManager#_tempPoint - * @type {object} - * @private - * @since 3.0.0 - */ - this._tempPoint = { x: 0, y: 0 }; - - /** - * [description] - * - * @name Phaser.Input.InputManager#_tempHitTest - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._tempHitTest = []; - - game.events.once('boot', this.boot, this); - }, - - /** - * The Boot handler is called by Phaser.Game when it first starts up. - * The renderer is available by now. - * - * @method Phaser.Input.InputManager#boot - * @since 3.0.0 - */ - boot: function () - { - this.canvas = this.game.canvas; - - this.updateBounds(); - - this.keyboard.boot(); - this.mouse.boot(); - this.touch.boot(); - this.gamepad.boot(); - - this.game.events.once('destroy', this.destroy, this); - }, - - /** - * [description] - * - * @method Phaser.Input.InputManager#updateBounds - * @since 3.0.0 - */ - updateBounds: function () - { - var bounds = this.bounds; - - var clientRect = this.canvas.getBoundingClientRect(); - - bounds.x = clientRect.left + window.pageXOffset - document.documentElement.clientLeft; - bounds.y = clientRect.top + window.pageYOffset - document.documentElement.clientTop; - bounds.width = clientRect.width; - bounds.height = clientRect.height; - }, - - /** - * [description] - * - * @method Phaser.Input.InputManager#resize - * @since 3.2.0 - */ - resize: function () - { - this.updateBounds(); - - // Game config size - var gw = this.game.config.width; - var gh = this.game.config.height; - - // Actual canvas size - var bw = this.bounds.width; - var bh = this.bounds.height; - - // Scale factor - this.scale.x = gw / bw; - this.scale.y = gh / bh; - }, - - /** - * [description] - * - * @method Phaser.Input.InputManager#update - * @since 3.0.0 - * - * @param {number} time - [description] - */ - update: function (time) - { - this.keyboard.update(); - this.gamepad.update(); - - this.ignoreEvents = false; - - var len = this.queue.length; - - // Currently just 1 pointer supported - var pointer = this.activePointer; - - pointer.reset(); - - if (!this.enabled || len === 0) - { - return; - } - - this.updateBounds(); - - this.scale.x = this.game.config.width / this.bounds.width; - this.scale.y = this.game.config.height / this.bounds.height; - - // Clears the queue array, and also means we don't work on array data that could potentially - // be modified during the processing phase - var queue = this.queue.splice(0, len); - - // Process the event queue, dispatching all of the events that have stored up - for (var i = 0; i < len; i++) - { - var event = queue[i]; - - // TODO: Move to CONSTs so we can do integer comparisons instead of strings. - switch (event.type) - { - case 'mousemove': - - pointer.move(event, time); - break; - - case 'mousedown': - - pointer.down(event, time); - break; - - case 'mouseup': - - pointer.up(event, time); - break; - - case 'touchmove': - - pointer.touchmove(event, time); - break; - - case 'touchstart': - - pointer.touchstart(event, time); - break; - - case 'touchend': - - pointer.touchend(event, time); - break; - - case 'pointerlockchange': - - this.events.emit('pointerlockchange', event, this.mouse.locked); - break; - } - } - }, - - /** - * Will always return an array. - * Array contains matching Interactive Objects. - * Array will be empty if no objects were matched. - * x/y = pointer x/y (un-translated) - * - * @method Phaser.Input.InputManager#hitTest - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {array} gameObjects - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {array} output - [description] - * - * @return {array} [description] - */ - hitTest: function (x, y, gameObjects, camera, output) - { - if (output === undefined) { output = this._tempHitTest; } - - var tempPoint = this._tempPoint; - var cameraW = camera.width; - var cameraH = camera.height; - - output.length = 0; - - if (!(x >= camera.x && y >= camera.y && x <= camera.x + cameraW && y <= camera.y + cameraH)) - { - return output; - } - - // Stores the world point inside of tempPoint - camera.getWorldPoint(x, y, tempPoint); - - var culledGameObjects = camera.cull(gameObjects); - - var point = { x: 0, y: 0 }; - - for (var i = 0; i < culledGameObjects.length; i++) - { - var gameObject = culledGameObjects[i]; - - if (!gameObject.input || !gameObject.input.enabled || !gameObject.willRender()) - { - continue; - } - - var px = tempPoint.x + (camera.scrollX * gameObject.scrollFactorX) - camera.scrollX; - var py = tempPoint.y + (camera.scrollY * gameObject.scrollFactorY) - camera.scrollY; - - TransformXY(px, py, gameObject.x, gameObject.y, gameObject.rotation, gameObject.scaleX, gameObject.scaleY, point); - - if (this.pointWithinHitArea(gameObject, point.x, point.y)) - { - output.push(gameObject); - } - } - - return output; - }, - - /** - * x/y MUST be translated before being passed to this function, - * unless the gameObject is guaranteed to not be rotated or scaled in any way. - * - * @method Phaser.Input.InputManager#pointWithinHitArea - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ - pointWithinHitArea: function (gameObject, x, y) - { - var input = gameObject.input; - - // Normalize the origin - x += gameObject.displayOriginX; - y += gameObject.displayOriginY; - - if (input.hitAreaCallback(input.hitArea, x, y, gameObject)) - { - input.localX = x; - input.localY = y; - - return true; - } - else - { - return false; - } - }, - - /** - * x/y MUST be translated before being passed to this function, - * unless the gameObject is guaranteed to not be rotated or scaled in any way. - * - * @method Phaser.Input.InputManager#pointWithinInteractiveObject - * @since 3.0.0 - * - * @param {Phaser.Input.InteractiveObject} object - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ - pointWithinInteractiveObject: function (object, x, y) - { - if (!object.hitArea) - { - return false; - } - - // Normalize the origin - x += object.gameObject.displayOriginX; - y += object.gameObject.displayOriginY; - - object.localX = x; - object.localY = y; - - return object.hitAreaCallback(object.hitArea, x, y, object); - }, - - /** - * [description] - * - * @method Phaser.Input.InputManager#transformX - * @since 3.0.0 - * - * @param {number} pageX - [description] - * - * @return {number} [description] - */ - transformX: function (pageX) - { - return (pageX - this.bounds.left) * this.scale.x; - }, - - /** - * [description] - * - * @method Phaser.Input.InputManager#transformY - * @since 3.0.0 - * - * @param {number} pageY - [description] - * - * @return {number} [description] - */ - transformY: function (pageY) - { - return (pageY - this.bounds.top) * this.scale.y; - }, - - /** - * [description] - * - * @method Phaser.Input.InputManager#getOffsetX - * @since 3.0.0 - * - * @return {number} [description] - */ - getOffsetX: function () - { - return this.bounds.left; - }, - - /** - * [description] - * - * @method Phaser.Input.InputManager#getOffsetY - * @since 3.0.0 - * - * @return {number} [description] - */ - getOffsetY: function () - { - return this.bounds.top; - }, - - /** - * [description] - * - * @method Phaser.Input.InputManager#getScaleX - * @since 3.0.0 - * - * @return {number} [description] - */ - getScaleX: function () - { - return this.game.config.width / this.bounds.width; - }, - - /** - * [description] - * - * @method Phaser.Input.InputManager#getScaleY - * @since 3.0.0 - * - * @return {number} [description] - */ - getScaleY: function () - { - return this.game.config.height / this.bounds.height; - }, - - /** - * [description] - * - * @method Phaser.Input.InputManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.events.removeAllListeners(); - - this.keyboard.destroy(); - this.mouse.destroy(); - this.touch.destroy(); - this.gamepad.destroy(); - - this.activePointer.destroy(); - - this.queue = []; - - this.game = null; - } - -}); - -module.exports = InputManager; - - -/***/ }), -/* 241 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Gamepad = __webpack_require__(242); - -// https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API -// https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API -// https://www.smashingmagazine.com/2015/11/gamepad-api-in-web-games/ -// http://html5gamepad.com/ - -/** - * @classdesc - * [description] - * - * @class GamepadManager - * @memberOf Phaser.Input.Gamepad - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Input.InputManager} inputManager - [description] - */ -var GamepadManager = new Class({ - - initialize: - - function GamepadManager (inputManager) - { - /** - * [description] - * - * @name Phaser.Input.Gamepad.GamepadManager#manager - * @type {Phaser.Input.InputManager} - * @since 3.0.0 - */ - this.manager = inputManager; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.GamepadManager#events - * @type {[type]} - * @since 3.0.0 - */ - this.events = inputManager.events; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.GamepadManager#enabled + * @name Phaser.Physics.Arcade.Body#onCollide * @type {boolean} * @default false * @since 3.0.0 */ - this.enabled = false; + this.onCollide = false; /** * [description] * - * @name Phaser.Input.Gamepad.GamepadManager#target - * @type {null} - * @since 3.0.0 - */ - this.target; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.GamepadManager#handler - * @type {null} - * @since 3.0.0 - */ - this.handler; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.GamepadManager#gamepads - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.gamepads = []; - - /** - * Standard FIFO queue. - * - * @name Phaser.Input.Gamepad.GamepadManager#queue - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.queue = []; - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.GamepadManager#boot - * @since 3.0.0 - */ - boot: function () - { - var config = this.manager.config; - - this.enabled = config.inputGamepad && this.manager.game.device.input.gamepads; - - this.target = window; - - if (this.enabled) - { - this.startListeners(); - } - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.GamepadManager#startListeners - * @since 3.0.0 - * - * @return {[type]} [description] - */ - startListeners: function () - { - var queue = this.queue; - - var handler = function handler (event) - { - if (event.defaultPrevented) - { - // Do nothing if event already handled - return; - } - - queue.push(event); - }; - - this.handler = handler; - - var target = this.target; - - target.addEventListener('gamepadconnected', handler, false); - target.addEventListener('gamepaddisconnected', handler, false); - - // FF only for now: - target.addEventListener('gamepadbuttondown', handler, false); - target.addEventListener('gamepadbuttonup', handler, false); - target.addEventListener('gamepadaxismove', handler, false); - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.GamepadManager#stopListeners - * @since 3.0.0 - */ - stopListeners: function () - { - var target = this.target; - var handler = this.handler; - - target.removeEventListener('gamepadconnected', handler); - target.removeEventListener('gamepaddisconnected', handler); - - target.removeEventListener('gamepadbuttondown', handler); - target.removeEventListener('gamepadbuttonup', handler); - target.removeEventListener('gamepadaxismove', handler); - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.GamepadManager#disconnectAll - * @since 3.0.0 - */ - disconnectAll: function () - { - for (var i = 0; i < this.gamepads.length; i++) - { - this.gamepads.connected = false; - } - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.GamepadManager#addPad - * @since 3.0.0 - * - * @param {[type]} pad - [description] - * - * @return {[type]} [description] - */ - addPad: function (pad) - { - var gamepad = new Gamepad(this, pad.id, pad.index); - - this.gamepads[pad.index] = gamepad; - - return gamepad; - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.GamepadManager#removePad - * @since 3.0.0 - * @todo Code this feature - * - * @param {[type]} index - [description] - * @param {[type]} pad - [description] - */ - removePad: function () - { - // TODO - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.GamepadManager#refreshPads - * @since 3.0.0 - * - * @param {[type]} pads - [description] - */ - refreshPads: function (pads) - { - if (!pads) - { - this.disconnectAll(); - } - else - { - for (var i = 0; i < pads.length; i++) - { - var pad = pads[i]; - - if (!pad) - { - // removePad? - continue; - } - - if (this.gamepads[pad.index] === undefined) - { - this.addPad(pad); - } - - this.gamepads[pad.index].update(pad); - } - } - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.GamepadManager#getAll - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getAll: function () - { - var out = []; - - for (var i = 0; i < this.gamepads.length; i++) - { - if (this.gamepads[i]) - { - out.push(this.gamepads[i]); - } - } - - return out; - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.GamepadManager#getPad - * @since 3.0.0 - * - * @param {[type]} index - [description] - * - * @return {[type]} [description] - */ - getPad: function (index) - { - for (var i = 0; i < this.gamepads.length; i++) - { - if (this.gamepads[i].index === index) - { - return this.gamepads[i]; - } - } - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.GamepadManager#update - * @since 3.0.0 - * - * @return {[type]} [description] - */ - update: function () - { - if (!this.enabled) - { - return; - } - - this.refreshPads(navigator.getGamepads()); - - var len = this.queue.length; - - if (len === 0) - { - return; - } - - var queue = this.queue.splice(0, len); - - // Process the event queue, dispatching all of the events that have stored up - for (var i = 0; i < len; i++) - { - var event = queue[i]; - var pad; - - switch (event.type) - { - case 'gamepadconnected': - - pad = this.getPad(event.gamepad.index); - - this.events.emit('connected', pad, event); - - break; - - case 'gamepaddisconnected': - - pad = this.getPad(event.gamepad.index); - - this.events.emit('disconnected', pad, event); - - break; - } - } - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.GamepadManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.stopListeners(); - this.disconnectAll(); - - this.gamepads = []; - }, - - /** - * The total number of connected game pads. - * - * @name Phaser.Input.Gamepad.GamepadManager#total - * @type {number} - * @since 3.0.0 - */ - total: { - - get: function () - { - return this.gamepads.length; - } - - } - -}); - -module.exports = GamepadManager; - - -/***/ }), -/* 242 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Axis = __webpack_require__(243); -var Button = __webpack_require__(244); -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class Gamepad - * @memberOf Phaser.Input.Gamepad - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Input.Gamepad.GamepadManager} manager - [description] - * @param {[type]} id - [description] - * @param {[type]} index - [description] - */ -var Gamepad = new Class({ - - initialize: - - function Gamepad (manager, id, index) - { - /** - * [description] - * - * @name Phaser.Input.Gamepad.Gamepad#manager - * @type {Phaser.Input.Gamepad.GamepadManager} - * @since 3.0.0 - */ - this.manager = manager; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.Gamepad#events - * @type {[type]} - * @since 3.0.0 - */ - this.events = manager.events; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.Gamepad#id - * @type {[type]} - * @since 3.0.0 - */ - this.id = id; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.Gamepad#index - * @type {[type]} - * @since 3.0.0 - */ - this.index = index; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.Gamepad#connected - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.connected = true; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.Gamepad#timestamp - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.timestamp = 0; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.Gamepad#buttons - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.buttons = []; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.Gamepad#axes - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.axes = []; - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.Gamepad#update - * @since 3.0.0 - * - * @param {[type]} data - [description] - */ - update: function (data) - { - this.timestamp = data.timestamp; - this.connected = data.connected; - - var i; - - var axes = this.axes; - var buttons = this.buttons; - - for (i = 0; i < data.buttons.length; i++) - { - var buttonData = data.buttons[i]; - - if (buttons[i] === undefined) - { - buttons[i] = new Button(this, i); - } - - buttons[i].update(buttonData); - } - - // Axes - for (i = 0; i < data.axes.length; i++) - { - var axisData = data.axes[i]; - - if (axes[i] === undefined) - { - axes[i] = new Axis(this, i); - } - - axes[i].update(axisData); - } - } - -}); - -module.exports = Gamepad; - - -/***/ }), -/* 243 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class Axis - * @memberOf Phaser.Input.Gamepad - * @constructor - * @since 3.0.0 - * - * @param {[type]} pad - [description] - * @param {integer} index - [description] - */ -var Axis = new Class({ - - initialize: - - function Axis (pad, index) - { - /** - * [description] - * - * @name Phaser.Input.Gamepad.Axis#pad - * @type {Phaser.Input.Gamepad.Gamepad} - * @since 3.0.0 - */ - this.pad = pad; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.Axis#events - * @type {[type]} - * @since 3.0.0 - */ - this.events = pad.events; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.Axis#index - * @type {integer} - * @since 3.0.0 - */ - this.index = index; - - /** - * Between -1 and 1 with 0 being dead center. - * - * @name Phaser.Input.Gamepad.Axis#value - * @type {float} - * @default 0 - * @since 3.0.0 - */ - this.value = 0; - - this.threshold = 0.05; - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.Axis#update - * @since 3.0.0 - * - * @param {[type]} value - [description] - */ - update: function (value) - { - this.value = value; - }, - - /** - * Applies threshold to the value and returns it. - * - * @method Phaser.Input.Gamepad.Axis#getValue - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getValue: function () - { - var percentage = (Math.abs(this.value) - this.threshold) / (1 - this.threshold); - - if (percentage < 0) - { - percentage = 0; - } - - return percentage * (this.value > 0 ? 1 : -1); - } - -}); - -module.exports = Axis; - - -/***/ }), -/* 244 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class Button - * @memberOf Phaser.Input.Gamepad - * @constructor - * @since 3.0.0 - * - * @param {[type]} pad - [description] - * @param {integer} index - [description] - */ -var Button = new Class({ - - initialize: - - function Button (pad, index) - { - /** - * [description] - * - * @name Phaser.Input.Gamepad.Button#pad - * @type {[type]} - * @since 3.0.0 - */ - this.pad = pad; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.Button#events - * @type {[type]} - * @since 3.0.0 - */ - this.events = pad.events; - - /** - * [description] - * - * @name Phaser.Input.Gamepad.Button#index - * @type {integer} - * @since 3.0.0 - */ - this.index = index; - - /** - * Between 0 and 1. - * - * @name Phaser.Input.Gamepad.Button#value - * @type {float} - * @default 0 - * @since 3.0.0 - */ - this.value = 0; - - /** - * Can be set for Analogue buttons to enable a 'pressure' threshold before considered as 'pressed'. - * - * @name Phaser.Input.Gamepad.Button#threshold - * @type {float} - * @default 0 - * @since 3.0.0 - */ - this.threshold = 0; - - /** - * Is the Button being pressed down or not? - * - * @name Phaser.Input.Gamepad.Button#pressed + * @name Phaser.Physics.Arcade.Body#onOverlap * @type {boolean} * @default false * @since 3.0.0 */ - this.pressed = false; - }, - - /** - * [description] - * - * @method Phaser.Input.Gamepad.Button#update - * @since 3.0.0 - * - * @param {[type]} data - [description] - */ - update: function (data) - { - this.value = data.value; - - if (this.value >= this.threshold) - { - if (!this.pressed) - { - this.pressed = true; - this.events.emit('down', this.pad, this, this.value, data); - } - } - else if (this.pressed) - { - this.pressed = false; - this.events.emit('up', this.pad, this, this.value, data); - } - } - -}); - -module.exports = Button; - - -/***/ }), -/* 245 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(14); -var Key = __webpack_require__(246); -var KeyCodes = __webpack_require__(129); -var KeyCombo = __webpack_require__(247); -var KeyMap = __webpack_require__(527); -var ProcessKeyDown = __webpack_require__(528); -var ProcessKeyUp = __webpack_require__(529); - -/** - * @classdesc - * The Keyboard class monitors keyboard input and dispatches keyboard events. - * - * _Note_: many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. - * See http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/ for more details. - * - * Also please be aware that certain browser extensions can disable or override Phaser keyboard handling. - * For example the Chrome extension vimium is known to disable Phaser from using the D key. And there are others. - * So please check your extensions before opening Phaser issues. - * - * @class KeyboardManager - * @extends EventEmitter - * @memberOf Phaser.Input.Keyboard - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Input.InputManager} inputManager - [description] - */ -var KeyboardManager = new Class({ - - Extends: EventEmitter, - - initialize: - - function KeyboardManager (inputManager) - { - EventEmitter.call(this); + this.onOverlap = false; /** * [description] * - * @name Phaser.Input.Keyboard.KeyboardManager#manager - * @type {Phaser.Input.InputManager} - * @since 3.0.0 - */ - this.manager = inputManager; - - /** - * [description] - * - * @name Phaser.Input.Keyboard.KeyboardManager#enabled - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.enabled = false; - - /** - * [description] - * - * @name Phaser.Input.Keyboard.KeyboardManager#target - * @type {null} - * @since 3.0.0 - */ - this.target; - - /** - * [description] - * - * @name Phaser.Input.Keyboard.KeyboardManager#keys - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.keys = []; - - /** - * [description] - * - * @name Phaser.Input.Keyboard.KeyboardManager#combos - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.combos = []; - - /** - * [description] - * - * @name Phaser.Input.Keyboard.KeyboardManager#captures - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.captures = []; - - /** - * [description] - * - * @name Phaser.Input.Keyboard.KeyboardManager#queue - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.queue = []; - - /** - * [description] - * - * @name Phaser.Input.Keyboard.KeyboardManager#handler - * @type {any} - * @since 3.0.0 - */ - this.handler; - }, - - /** - * The Boot handler is called by Phaser.Game when it first starts up. - * - * @method Phaser.Input.Keyboard.KeyboardManager#boot - * @since 3.0.0 - */ - boot: function () - { - var config = this.manager.config; - - this.enabled = config.inputKeyboard; - this.target = config.inputKeyboardEventTarget; - - if (this.enabled) - { - this.startListeners(); - } - }, - - /** - * [description] - * - * @method Phaser.Input.Keyboard.KeyboardManager#startListeners - * @since 3.0.0 - * - * @return {[type]} [description] - */ - startListeners: function () - { - var queue = this.queue; - var captures = this.captures; - - var handler = function (event) - { - if (event.defaultPrevented) - { - // Do nothing if event already handled - return; - } - - queue.push(event); - - if (captures[event.keyCode]) - { - event.preventDefault(); - } - }; - - this.handler = handler; - - this.target.addEventListener('keydown', handler, false); - this.target.addEventListener('keyup', handler, false); - }, - - /** - * [description] - * - * @method Phaser.Input.Keyboard.KeyboardManager#stopListeners - * @since 3.0.0 - */ - stopListeners: function () - { - this.target.removeEventListener('keydown', this.handler); - this.target.removeEventListener('keyup', this.handler); - }, - - /** - * Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right, and also space and shift. - * - * @method Phaser.Input.Keyboard.KeyboardManager#createCursorKeys - * @since 3.0.0 - * - * @return {[type]} [description] - */ - createCursorKeys: function () - { - return this.addKeys({ - up: KeyCodes.UP, - down: KeyCodes.DOWN, - left: KeyCodes.LEFT, - right: KeyCodes.RIGHT, - space: KeyCodes.SPACE, - shift: KeyCodes.SHIFT - }); - }, - - /** - * A practical way to create an object containing user selected hotkeys. - * - * For example, - * - * addKeys( { 'up': Phaser.KeyCode.W, 'down': Phaser.KeyCode.S, 'left': Phaser.KeyCode.A, 'right': Phaser.KeyCode.D } ); - * - * would return an object containing properties (`up`, `down`, `left` and `right`) referring to {@link Phaser.Key} object. - * - * @method Phaser.Input.Keyboard.KeyboardManager#addKeys - * @since 3.0.0 - * - * @param {[type]} keys - [description] - * - * @return {[type]} [description] - */ - addKeys: function (keys) - { - var output = {}; - - for (var key in keys) - { - output[key] = this.addKey(keys[key]); - } - - return output; - }, - - /** - * If you need more fine-grained control over a Key you can create a new Phaser.Key object via this method. - * The Key object can then be polled, have events attached to it, etc. - * - * @method Phaser.Input.Keyboard.KeyboardManager#addKey - * @since 3.0.0 - * - * @param {[type]} keyCode - [description] - * - * @return {[type]} [description] - */ - addKey: function (keyCode) - { - var keys = this.keys; - - if (!keys[keyCode]) - { - keys[keyCode] = new Key(keyCode); - this.captures[keyCode] = true; - } - - return keys[keyCode]; - }, - - /** - * Removes a Key object from the Keyboard manager. - * - * @method Phaser.Input.Keyboard.KeyboardManager#removeKey - * @since 3.0.0 - * - * @param {[type]} keyCode - [description] - */ - removeKey: function (keyCode) - { - if (this.keys[keyCode]) - { - this.keys[keyCode] = undefined; - this.captures[keyCode] = false; - } - }, - - /** - * [description] - * - * @method Phaser.Input.Keyboard.KeyboardManager#addKeyCapture - * @since 3.0.0 - * - * @param {[type]} keyCodes - [description] - */ - addKeyCapture: function (keyCodes) - { - if (!Array.isArray(keyCodes)) - { - keyCodes = [ keyCodes ]; - } - - for (var i = 0; i < keyCodes.length; i++) - { - this.captures[keyCodes[i]] = true; - } - }, - - /** - * [description] - * - * @method Phaser.Input.Keyboard.KeyboardManager#removeKeyCapture - * @since 3.0.0 - * - * @param {[type]} keyCodes - [description] - */ - removeKeyCapture: function (keyCodes) - { - if (!Array.isArray(keyCodes)) - { - keyCodes = [ keyCodes ]; - } - - for (var i = 0; i < keyCodes.length; i++) - { - this.captures[keyCodes[i]] = false; - } - }, - - /** - * [description] - * - * @method Phaser.Input.Keyboard.KeyboardManager#createCombo - * @since 3.0.0 - * - * @param {[type]} keys - [description] - * @param {[type]} config - [description] - * - * @return {[type]} [description] - */ - createCombo: function (keys, config) - { - return new KeyCombo(this, keys, config); - }, - - /** - * [description] - * - * @method Phaser.Input.Keyboard.KeyboardManager#update - * @since 3.0.0 - * - * @return {[type]} [description] - */ - update: function () - { - var len = this.queue.length; - - if (!this.enabled || len === 0) - { - return; - } - - // Clears the queue array, and also means we don't work on array data that could potentially - // be modified during the processing phase - var queue = this.queue.splice(0, len); - - var keys = this.keys; - - // Process the event queue, dispatching all of the events that have stored up - for (var i = 0; i < len; i++) - { - var event = queue[i]; - var code = event.keyCode; - - if (event.type === 'keydown') - { - if (KeyMap[code] && (keys[code] === undefined || keys[code].isDown === false)) - { - // Will emit a keyboard or keyup event - this.emit(event.type, event); - - this.emit('keydown_' + KeyMap[code], event); - } - - if (keys[code]) - { - ProcessKeyDown(keys[code], event); - } - } - else - { - // Will emit a keyboard or keyup event - this.emit(event.type, event); - - this.emit('keyup_' + KeyMap[code], event); - - if (keys[code]) - { - ProcessKeyUp(keys[code], event); - } - } - } - }, - - /** - * [description] - * - * @method Phaser.Input.Keyboard.KeyboardManager#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this.removeAllListeners(); - }, - - /** - * [description] - * - * @method Phaser.Input.Keyboard.KeyboardManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.stopListeners(); - - this.removeAllListeners(); - - this.keys = []; - this.combos = []; - this.captures = []; - this.queue = []; - this.handler = undefined; - - this.manager = null; - } - -}); - -module.exports = KeyboardManager; - - -/***/ }), -/* 246 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * A generic Key object which can be passed to the Process functions (and so on) - * keycode must be an integer - * - * @class Key - * @memberOf Phaser.Input.Keyboard - * @constructor - * @since 3.0.0 - * - * @param {integer} keyCode - The keycode of this key. - */ -var Key = new Class({ - - initialize: - - function Key (keyCode) - { - /** - * The keycode of this key. - * - * @name Phaser.Input.Keyboard.Key#keyCode - * @type {integer} - * @since 3.0.0 - */ - this.keyCode = keyCode; - - /** - * The original DOM event. - * - * @name Phaser.Input.Keyboard.Key#originalEvent - * @type {KeyboardEvent} - * @since 3.0.0 - */ - this.originalEvent = undefined; - - /** - * Should this Key prevent event propagation? - * - * @name Phaser.Input.Keyboard.Key#preventDefault - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.preventDefault = true; - - /** - * Can this Key be processed? - * - * @name Phaser.Input.Keyboard.Key#enabled - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.enabled = true; - - /** - * The "down" state of the key. This will remain `true` for as long as the keyboard thinks this key is held down. - * - * @name Phaser.Input.Keyboard.Key#isDown - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isDown = false; - - /** - * The "up" state of the key. This will remain `true` for as long as the keyboard thinks this key is up. - * - * @name Phaser.Input.Keyboard.Key#isUp - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.isUp = true; - - /** - * The down state of the ALT key, if pressed at the same time as this key. - * - * @name Phaser.Input.Keyboard.Key#altKey - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.altKey = false; - - /** - * The down state of the CTRL key, if pressed at the same time as this key. - * - * @name Phaser.Input.Keyboard.Key#ctrlKey - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.ctrlKey = false; - - /** - * The down state of the SHIFT key, if pressed at the same time as this key. - * - * @name Phaser.Input.Keyboard.Key#shiftKey - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.shiftKey = false; - - /** - * The location of the modifier key. 0 for standard (or unknown), 1 for left, 2 for right, 3 for numpad. - * - * @name Phaser.Input.Keyboard.Key#location - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.location = 0; - - /** - * The timestamp when the key was last pressed down. - * - * @name Phaser.Input.Keyboard.Key#timeDown - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.timeDown = 0; - - /** - * The number of milliseconds this key has been held down for. - * If the key is down this value holds the duration of that key press and is constantly updated. - * If the key is up it holds the duration of the previous down session. - * - * @name Phaser.Input.Keyboard.Key#duration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.duration = 0; - - /** - * The timestamp when the key was last released. - * - * @name Phaser.Input.Keyboard.Key#timeUp - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.timeUp = 0; - - /** - * If a key is held down this holds down the number of times the key has 'repeated'. - * - * @name Phaser.Input.Keyboard.Key#repeats - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.repeats = 0; - - /** - * True if the key has just been pressed (NOTE: requires to be reset, see justDown getter) - * - * @name Phaser.Input.Keyboard.Key#_justDown - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this._justDown = false; - - /** - * True if the key has just been pressed (NOTE: requires to be reset, see justDown getter) - * - * @name Phaser.Input.Keyboard.Key#_justUp - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this._justUp = false; - } - -}); - -module.exports = Key; - - -/***/ }), -/* 247 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(2); -var ProcessKeyCombo = __webpack_require__(524); -var ResetKeyCombo = __webpack_require__(526); - -/** - * @classdesc - * [description] - * - * `keys` argument can be: - * - * A string (ATARI) - * An array of either integers (key codes) or strings, or a mixture of both - * An array of objects (such as Key objects) with a public 'keyCode' property - * - * @class KeyCombo - * @memberOf Phaser.Input.Keyboard - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Input.Keyboard.KeyboardManager} keyboardManager - [description] - * @param {string|integers[]|object[]} keys - [description] - * @param {object} [config] - [description] - */ -var KeyCombo = new Class({ - - initialize: - - function KeyCombo (keyboardManager, keys, config) - { - if (config === undefined) { config = {}; } - - // Can't have a zero or single length combo (string or array based) - if (keys.length < 2) - { - return false; - } - - /** - * [description] - * - * @name Phaser.Input.Keyboard.KeyCombo#manager - * @type {Phaser.Input.Keyboard.KeyboardManager} - * @since 3.0.0 - */ - this.manager = keyboardManager; - - /** - * [description] - * - * @name Phaser.Input.Keyboard.KeyCombo#enabled - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.enabled = true; - - /** - * [description] - * - * @name Phaser.Input.Keyboard.KeyCombo#keyCodes - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.keyCodes = []; - - // if 'keys' is a string we need to get the keycode of each character in it - - for (var i = 0; i < keys.length; i++) - { - var char = keys[i]; - - if (typeof char === 'string') - { - this.keyCodes.push(char.toUpperCase().charCodeAt(0)); - } - else if (typeof char === 'number') - { - this.keyCodes.push(char); - } - else if (char.hasOwnProperty('keyCode')) - { - this.keyCodes.push(char.keyCode); - } - } - - /** - * The current keyCode the combo is waiting for. - * - * @name Phaser.Input.Keyboard.KeyCombo#current - * @type {integer} - * @since 3.0.0 - */ - this.current = this.keyCodes[0]; - - /** - * The current index of the key being waited for in the 'keys' string. - * - * @name Phaser.Input.Keyboard.KeyCombo#index - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.index = 0; - - /** - * The length of this combo (in keycodes) - * - * @name Phaser.Input.Keyboard.KeyCombo#size - * @type {[type]} - * @since 3.0.0 - */ - this.size = this.keyCodes.length; - - /** - * The time the previous key in the combo was matched. - * - * @name Phaser.Input.Keyboard.KeyCombo#timeLastMatched - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.timeLastMatched = 0; - - /** - * Has this Key Combo been matched yet? - * - * @name Phaser.Input.Keyboard.KeyCombo#matched - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.matched = false; - - /** - * The time the entire combo was matched. - * - * @name Phaser.Input.Keyboard.KeyCombo#timeMatched - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.timeMatched = 0; - - /** - * If they press the wrong key do we reset the combo? - * - * @name Phaser.Input.Keyboard.KeyCombo#resetOnWrongKey - * @type {boolean} - * @default 0 - * @since 3.0.0 - */ - this.resetOnWrongKey = GetFastValue(config, 'resetOnWrongKey', true); - - /** - * The max delay in ms between each key press. Above this the combo is reset. 0 means disabled. - * - * @name Phaser.Input.Keyboard.KeyCombo#maxKeyDelay - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.maxKeyDelay = GetFastValue(config, 'maxKeyDelay', 0); - - /** - * If previously matched and they press Key 1 again, will it reset? - * - * @name Phaser.Input.Keyboard.KeyCombo#resetOnMatch - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.resetOnMatch = GetFastValue(config, 'resetOnMatch', false); - - /** - * If the combo matches, will it delete itself? - * - * @name Phaser.Input.Keyboard.KeyCombo#deleteOnMatch - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.deleteOnMatch = GetFastValue(config, 'deleteOnMatch', false); - - var _this = this; - - var onKeyDownHandler = function (event) - { - if (_this.matched || !_this.enabled) - { - return; - } - - var matched = ProcessKeyCombo(event, _this); - - if (matched) - { - _this.manager.emit('keycombomatch', _this, event); - - if (_this.resetOnMatch) - { - ResetKeyCombo(_this); - } - else if (_this.deleteOnMatch) - { - _this.destroy(); - } - } - }; - - /** - * [description] - * - * @name Phaser.Input.Keyboard.KeyCombo#onKeyDown - * @type {function} - * @since 3.0.0 - */ - this.onKeyDown = onKeyDownHandler; - - this.manager.on('keydown', onKeyDownHandler); - }, - - /** - * How far complete is this combo? A value between 0 and 1. - * - * @name Phaser.Input.Keyboard.KeyCombo#progress - * @type {number} - * @readOnly - * @since 3.0.0 - */ - progress: { - - get: function () - { - return this.index / this.size; - } - - }, - - /** - * [description] - * - * @method Phaser.Input.Keyboard.KeyCombo#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.enabled = false; - this.keyCodes = []; - - this.manager.off('keydown', this.onKeyDown); - this.manager = undefined; - } - -}); - -module.exports = KeyCombo; - - -/***/ }), -/* 248 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Features = __webpack_require__(126); - -// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent -// https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md - -/** - * @classdesc - * [description] - * - * @class MouseManager - * @memberOf Phaser.Input.Mouse - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Input.InputManager} inputManager - [description] - */ -var MouseManager = new Class({ - - initialize: - - function MouseManager (inputManager) - { - /** - * [description] - * - * @name Phaser.Input.Mouse.MouseManager#manager - * @type {Phaser.Input.InputManager} - * @since 3.0.0 - */ - this.manager = inputManager; - - /** - * If true the DOM mouse events will have event.preventDefault applied to them, if false they will propagate fully. - * - * @name Phaser.Input.Mouse.MouseManager#capture - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.capture = true; - - /** - * [description] - * - * @name Phaser.Input.Mouse.MouseManager#enabled - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.enabled = false; - - /** - * [description] - * - * @name Phaser.Input.Mouse.MouseManager#target - * @type {null} - * @since 3.0.0 - */ - this.target; - - /** - * [description] - * - * @name Phaser.Input.Mouse.MouseManager#handler - * @type {null} - * @since 3.0.0 - */ - this.handler; - - /** - * If the mouse has been pointer locked successfully this will be set to true. - * - * @name Phaser.Input.Mouse.MouseManager#locked - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.locked = false; - }, - - /** - * [description] - * - * @method Phaser.Input.Mouse.MouseManager#boot - * @since 3.0.0 - */ - boot: function () - { - var config = this.manager.config; - - this.enabled = config.inputMouse; - this.target = config.inputMouseEventTarget; - this.capture = config.inputMouseCapture; - - if (!this.target) - { - this.target = this.manager.game.canvas; - } - - if (config.disableContextMenu) - { - this.disableContextMenu(); - } - - if (this.enabled) - { - this.startListeners(); - } - }, - - /** - * [description] - * - * @method Phaser.Input.Mouse.MouseManager#disableContextMenu - * @since 3.0.0 - * - * @return {Phaser.Input.Mouse.MouseManager} [description] - */ - disableContextMenu: function () - { - document.body.addEventListener('contextmenu', function (event) - { - event.preventDefault(); - return false; - }); - - return this; - }, - - /** - * If the browser supports it, you can request that the pointer be locked to the browser window. - * - * This is classically known as 'FPS controls', where the pointer can't leave the browser until - * the user presses an exit key. - * - * If the browser successfully enters a locked state, a `POINTER_LOCK_CHANGE_EVENT` will be dispatched, - * from the games Input Manager, with an `isPointerLocked` property. - * - * It is important to note that pointer lock can only be enabled after an 'engagement gesture', - * see: https://w3c.github.io/pointerlock/#dfn-engagement-gesture. - * - * @method Phaser.Input.Mouse.MouseManager#requestPointerLock - * @since 3.0.0 - */ - requestPointerLock: function () - { - if (Features.pointerLock) - { - var element = this.target; - element.requestPointerLock = element.requestPointerLock || element.mozRequestPointerLock || element.webkitRequestPointerLock; - element.requestPointerLock(); - } - }, - - /** - * Internal pointerLockChange handler. - * - * @method Phaser.Input.Mouse.MouseManager#pointerLockChange - * @since 3.0.0 - * - * @param {Event} event - The native event from the browser. - */ - pointerLockChange: function (event) - { - var element = this.target; - - this.locked = (document.pointerLockElement === element || document.mozPointerLockElement === element || document.webkitPointerLockElement === element) ? true : false; - - this.manager.queue.push(event); - }, - - /** - * If the browser supports pointer lock, this will request that the pointer lock is released. If - * the browser successfully enters a locked state, a 'POINTER_LOCK_CHANGE_EVENT' will be - * dispatched - from the game's input manager - with an `isPointerLocked` property. - * - * @method Phaser.Input.Mouse.MouseManager#releasePointerLock - * @since 3.0.0 - */ - releasePointerLock: function () - { - if (Features.pointerLock) - { - document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock || document.webkitExitPointerLock; - document.exitPointerLock(); - } - }, - - /** - * [description] - * - * @method Phaser.Input.Mouse.MouseManager#startListeners - * @since 3.0.0 - */ - startListeners: function () - { - var queue = this.manager.queue; - var target = this.target; - - var passive = { passive: true }; - var nonPassive = { passive: false }; - - var handler; - - if (this.capture) - { - handler = function (event) - { - if (event.defaultPrevented) - { - // Do nothing if event already handled - return; - } - - // console.log('mouse', event); - - queue.push(event); - - event.preventDefault(); - }; - - target.addEventListener('mousemove', handler, nonPassive); - target.addEventListener('mousedown', handler, nonPassive); - target.addEventListener('mouseup', handler, nonPassive); - } - else - { - handler = function (event) - { - if (event.defaultPrevented) - { - // Do nothing if event already handled - return; - } - - queue.push(event); - }; - - target.addEventListener('mousemove', handler, passive); - target.addEventListener('mousedown', handler, passive); - target.addEventListener('mouseup', handler, passive); - } - - this.handler = handler; - - if (Features.pointerLock) - { - this.pointerLockChange = this.pointerLockChange.bind(this); - - document.addEventListener('pointerlockchange', this.pointerLockChange, true); - document.addEventListener('mozpointerlockchange', this.pointerLockChange, true); - document.addEventListener('webkitpointerlockchange', this.pointerLockChange, true); - } - }, - - /** - * [description] - * - * @method Phaser.Input.Mouse.MouseManager#stopListeners - * @since 3.0.0 - */ - stopListeners: function () - { - var target = this.target; - - target.removeEventListener('mousemove', this.handler); - target.removeEventListener('mousedown', this.handler); - target.removeEventListener('mouseup', this.handler); - - if (Features.pointerLock) - { - document.removeEventListener('pointerlockchange', this.pointerLockChange, true); - document.removeEventListener('mozpointerlockchange', this.pointerLockChange, true); - document.removeEventListener('webkitpointerlockchange', this.pointerLockChange, true); - } - }, - - /** - * [description] - * - * @method Phaser.Input.Mouse.MouseManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.stopListeners(); - - this.manager = null; - } - -}); - -module.exports = MouseManager; - - -/***/ }), -/* 249 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Vector2 = __webpack_require__(6); - -// DOM event button value: -// A number representing a given button: -// 0: Main button pressed, usually the left button or the un-initialized state -// 1: Auxiliary button pressed, usually the wheel button or the middle button (if present) -// 2: Secondary button pressed, usually the right button -// 3: Fourth button, typically the Browser Back button -// 4: Fifth button, typically the Browser Forward button -// For a mouse configured for left-handed use, the button actions are reversed. In this case, the values are read from right to left. - -/** - * @classdesc - * [description] - * - * @class Pointer - * @memberOf Phaser.Input - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Input.InputManager} manager - [description] - * @param {integer} id - [description] - */ -var Pointer = new Class({ - - initialize: - - function Pointer (manager, id) - { - /** - * [description] - * - * @name Phaser.Input.Pointer#manager - * @type {Phaser.Input.InputManager} - * @since 3.0.0 - */ - this.manager = manager; - - /** - * [description] - * - * @name Phaser.Input.Pointer#id - * @type {integer} - * @since 3.0.0 - */ - this.id = id; - - /** - * [description] - * - * @name Phaser.Input.Pointer#event - * @type {null} - * @since 3.0.0 - */ - this.event; - - /** - * The camera the Pointer interacted with during its last update. - * A Pointer can only ever interact with one camera at once, which will be the top-most camera - * in the list should multiple cameras be positioned on-top of each other. - * - * @name Phaser.Input.Pointer#camera - * @type {Phaser.Cameras.Scene2D.Camera} - * @default null - * @since 3.0.0 - */ - this.camera = null; - - /** - * 0: No button or un-initialized - * 1: Left button - * 2: Right button - * 4: Wheel button or middle button - * 8: 4th button (typically the "Browser Back" button) - * 16: 5th button (typically the "Browser Forward" button) - * - * @name Phaser.Input.Pointer#buttons - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.buttons = 0; - - /** - * [description] - * - * @name Phaser.Input.Pointer#position + * @name Phaser.Physics.Arcade.Body#maxVelocity * @type {Phaser.Math.Vector2} * @since 3.0.0 */ - this.position = new Vector2(); - - /** - * X coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. - * - * @name Phaser.Input.Pointer#downX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.downX = 0; - - /** - * Y coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. - * - * @name Phaser.Input.Pointer#downY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.downY = 0; - - /** - * Time when Button 1 (left button), or Touch, was pressed, used for dragging objects. - * - * @name Phaser.Input.Pointer#downTime - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.downTime = 0; - - /** - * X coordinate of the Pointer when Button 1 (left button), or Touch, was released, used for dragging objects. - * - * @name Phaser.Input.Pointer#upX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.upX = 0; - - /** - * Y coordinate of the Pointer when Button 1 (left button), or Touch, was released, used for dragging objects. - * - * @name Phaser.Input.Pointer#upY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.upY = 0; - - /** - * Time when Button 1 (left button), or Touch, was released, used for dragging objects. - * - * @name Phaser.Input.Pointer#upTime - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.upTime = 0; - - /** - * Is the primary button down? (usually button 0, the left mouse button) - * - * @name Phaser.Input.Pointer#primaryDown - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.primaryDown = false; - - - /** - * The Drag State of the Pointer: - * - * 0 = Not dragging anything - * 1 = Being checked if dragging - * 2 = Dragging something - * - * @name Phaser.Input.Pointer#dragState - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.dragState = 0; - - /** - * Is _any_ button on this pointer considered as being down? - * - * @name Phaser.Input.Pointer#isDown - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isDown = false; + this.maxVelocity = new Vector2(10000, 10000); /** * [description] * - * @name Phaser.Input.Pointer#dirty + * @name Phaser.Physics.Arcade.Body#friction + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.friction = new Vector2(1, 0); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#angularVelocity + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angularVelocity = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#angularAcceleration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angularAcceleration = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#angularDrag + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angularDrag = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#maxAngular + * @type {number} + * @default 1000 + * @since 3.0.0 + */ + this.maxAngular = 1000; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#mass + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.mass = 1; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#angle + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angle = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#speed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.speed = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#facing + * @type {integer} + * @since 3.0.0 + */ + this.facing = CONST.FACING_NONE; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#immovable + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.immovable = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#moves + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.moves = true; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#customSeparateX + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customSeparateX = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#customSeparateY + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customSeparateY = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#overlapX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapX = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#overlapY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapY = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#overlapR + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapR = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#embedded + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.embedded = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#collideWorldBounds + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.collideWorldBounds = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#checkCollision + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.checkCollision = { none: false, up: true, down: true, left: true, right: true }; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#touching + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.touching = { none: true, up: false, down: false, left: false, right: false }; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#wasTouching + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.wasTouching = { none: true, up: false, down: false, left: false, right: false }; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#blocked + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.blocked = { none: true, up: false, down: false, left: false, right: false }; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#dirty * @type {boolean} * @default false * @since 3.0.0 @@ -51385,87 +50185,1159 @@ var Pointer = new Class({ /** * [description] * - * @name Phaser.Input.Pointer#justDown + * @name Phaser.Physics.Arcade.Body#syncBounds * @type {boolean} * @default false * @since 3.0.0 */ - this.justDown = false; + this.syncBounds = false; /** * [description] * - * @name Phaser.Input.Pointer#justUp + * @name Phaser.Physics.Arcade.Body#isMoving * @type {boolean} * @default false * @since 3.0.0 */ - this.justUp = false; + this.isMoving = false; /** * [description] * - * @name Phaser.Input.Pointer#justMoved + * @name Phaser.Physics.Arcade.Body#stopVelocityOnCollide * @type {boolean} - * @default false + * @default true * @since 3.0.0 */ - this.justMoved = false; + this.stopVelocityOnCollide = true; + + // read-only /** - * Did the previous input event come from a Touch input (true) or Mouse? (false) + * [description] * - * @name Phaser.Input.Pointer#wasTouch - * @type {boolean} - * @default false + * @name Phaser.Physics.Arcade.Body#physicsType + * @type {integer} + * @readOnly * @since 3.0.0 */ - this.wasTouch = false; + this.physicsType = CONST.DYNAMIC_BODY; /** - * If the mouse is locked, the horizontal relative movement of the Pointer in pixels since last frame. + * [description] * - * @name Phaser.Input.Pointer#movementX + * @name Phaser.Physics.Arcade.Body#_reset + * @type {boolean} + * @private + * @default true + * @since 3.0.0 + */ + this._reset = true; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#_sx * @type {number} + * @private + * @since 3.0.0 + */ + this._sx = gameObject.scaleX; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#_sy + * @type {number} + * @private + * @since 3.0.0 + */ + this._sy = gameObject.scaleY; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#_dx + * @type {number} + * @private * @default 0 * @since 3.0.0 */ - this.movementX = 0; + this._dx = 0; /** - * If the mouse is locked, the vertical relative movement of the Pointer in pixels since last frame. + * [description] * - * @name Phaser.Input.Pointer#movementY + * @name Phaser.Physics.Arcade.Body#_dy * @type {number} + * @private * @default 0 * @since 3.0.0 */ - this.movementY = 0; + this._dy = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#_bounds + * @type {Phaser.Geom.Rectangle} + * @private + * @since 3.0.0 + */ + this._bounds = new Rectangle(); }, /** * [description] * - * @method Phaser.Input.Pointer#positionToCamera + * @method Phaser.Physics.Arcade.Body#updateBounds + * @since 3.0.0 + */ + updateBounds: function () + { + var sprite = this.gameObject; + + if (this.syncBounds) + { + var b = sprite.getBounds(this._bounds); + + if (b.width !== this.width || b.height !== this.height) + { + this.width = b.width; + this.height = b.height; + this._reset = true; + } + } + else + { + var asx = Math.abs(sprite.scaleX); + var asy = Math.abs(sprite.scaleY); + + if (asx !== this._sx || asy !== this._sy) + { + this.width = this.sourceWidth * asx; + this.height = this.sourceHeight * asy; + this._sx = asx; + this._sy = asy; + this._reset = true; + } + } + + if (this._reset) + { + this.halfWidth = Math.floor(this.width / 2); + this.halfHeight = Math.floor(this.height / 2); + this.updateCenter(); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#updateCenter + * @since 3.0.0 + */ + updateCenter: function () + { + this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#update * @since 3.0.0 * - * @param {[type]} camera - [description] - * @param {[type]} output - [description] - * - * @return {[type]} [description] + * @param {number} delta - [description] */ - positionToCamera: function (camera, output) + update: function (delta) { - return camera.getWorldPoint(this.x, this.y, output); + this.dirty = true; + + // Store and reset collision flags + this.wasTouching.none = this.touching.none; + this.wasTouching.up = this.touching.up; + this.wasTouching.down = this.touching.down; + this.wasTouching.left = this.touching.left; + this.wasTouching.right = this.touching.right; + + this.touching.none = true; + this.touching.up = false; + this.touching.down = false; + this.touching.left = false; + this.touching.right = false; + + this.blocked.none = true; + this.blocked.up = false; + this.blocked.down = false; + this.blocked.left = false; + this.blocked.right = false; + + this.overlapR = 0; + this.overlapX = 0; + this.overlapY = 0; + + this.embedded = false; + + this.updateBounds(); + + var sprite = this.gameObject; + + this.position.x = sprite.x + sprite.scaleX * (this.offset.x - sprite.displayOriginX); + this.position.y = sprite.y + sprite.scaleY * (this.offset.y - sprite.displayOriginY); + + this.updateCenter(); + + this.rotation = sprite.angle; + + this.preRotation = this.rotation; + + if (this._reset) + { + this.prev.x = this.position.x; + this.prev.y = this.position.y; + } + + if (this.moves) + { + this.world.updateMotion(this); + + this.newVelocity.set(this.velocity.x * delta, this.velocity.y * delta); + + this.position.x += this.newVelocity.x; + this.position.y += this.newVelocity.y; + + this.updateCenter(); + + if (this.position.x !== this.prev.x || this.position.y !== this.prev.y) + { + this.angle = Math.atan2(this.velocity.y, this.velocity.x); + } + + this.speed = Math.sqrt(this.velocity.x * this.velocity.x + this.velocity.y * this.velocity.y); + + // Now the State update will throw collision checks at the Body + // And finally we'll integrate the new position back to the Sprite in postUpdate + + if (this.collideWorldBounds && this.checkWorldBounds() && this.onWorldBounds) + { + this.world.emit('worldbounds', this, this.blocked.up, this.blocked.down, this.blocked.left, this.blocked.right); + } + } + + this._dx = this.deltaX(); + this._dy = this.deltaY(); + + this._reset = false; + }, + + /** + * Feeds the body results back into the parent gameobject. + * + * @method Phaser.Physics.Arcade.Body#postUpdate + * @since 3.0.0 + */ + postUpdate: function () + { + // Only allow postUpdate to be called once per frame + if (!this.enable || !this.dirty) + { + return; + } + + this.dirty = false; + + this._dx = this.deltaX(); + this._dy = this.deltaY(); + + if (this._dx < 0) + { + this.facing = CONST.FACING_LEFT; + } + else if (this._dx > 0) + { + this.facing = CONST.FACING_RIGHT; + } + + if (this._dy < 0) + { + this.facing = CONST.FACING_UP; + } + else if (this._dy > 0) + { + this.facing = CONST.FACING_DOWN; + } + + if (this.moves) + { + if (this.deltaMax.x !== 0 && this._dx !== 0) + { + if (this._dx < 0 && this._dx < -this.deltaMax.x) + { + this._dx = -this.deltaMax.x; + } + else if (this._dx > 0 && this._dx > this.deltaMax.x) + { + this._dx = this.deltaMax.x; + } + } + + if (this.deltaMax.y !== 0 && this._dy !== 0) + { + if (this._dy < 0 && this._dy < -this.deltaMax.y) + { + this._dy = -this.deltaMax.y; + } + else if (this._dy > 0 && this._dy > this.deltaMax.y) + { + this._dy = this.deltaMax.y; + } + } + + this.gameObject.x += this._dx; + this.gameObject.y += this._dy; + + this._reset = true; + } + + this.updateCenter(); + + if (this.allowRotation) + { + this.gameObject.angle += this.deltaZ(); + } + + this.prev.x = this.position.x; + this.prev.y = this.position.y; }, /** * [description] - * - * @name Phaser.Input.Pointer#x + * + * @method Phaser.Physics.Arcade.Body#checkWorldBounds + * @since 3.0.0 + * + * @return {boolean} [description] + */ + checkWorldBounds: function () + { + var pos = this.position; + var bounds = this.world.bounds; + var check = this.world.checkCollision; + + var bx = (this.worldBounce) ? -this.worldBounce.x : -this.bounce.x; + var by = (this.worldBounce) ? -this.worldBounce.y : -this.bounce.y; + + if (pos.x < bounds.x && check.left) + { + pos.x = bounds.x; + this.velocity.x *= bx; + this.blocked.left = true; + this.blocked.none = false; + } + else if (this.right > bounds.right && check.right) + { + pos.x = bounds.right - this.width; + this.velocity.x *= bx; + this.blocked.right = true; + this.blocked.none = false; + } + + if (pos.y < bounds.y && check.up) + { + pos.y = bounds.y; + this.velocity.y *= by; + this.blocked.up = true; + this.blocked.none = false; + } + else if (this.bottom > bounds.bottom && check.down) + { + pos.y = bounds.bottom - this.height; + this.velocity.y *= by; + this.blocked.down = true; + this.blocked.none = false; + } + + return !this.blocked.none; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setOffset + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setOffset: function (x, y) + { + if (y === undefined) { y = x; } + + this.offset.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setSize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * @param {boolean} [center=true] - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setSize: function (width, height, center) + { + if (center === undefined) { center = true; } + + var gameObject = this.gameObject; + + this.sourceWidth = width; + this.sourceHeight = height; + + this.width = this.sourceWidth * this._sx; + this.height = this.sourceHeight * this._sy; + + this.halfWidth = Math.floor(this.width / 2); + this.halfHeight = Math.floor(this.height / 2); + + this.updateCenter(); + + if (center && gameObject.getCenter) + { + var ox = gameObject.displayWidth / 2; + var oy = gameObject.displayHeight / 2; + + this.offset.set(ox - this.halfWidth, oy - this.halfHeight); + } + + this.isCircle = false; + this.radius = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setCircle + * @since 3.0.0 + * + * @param {number} radius - [description] + * @param {number} [offsetX] - [description] + * @param {number} [offsetY] - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setCircle: function (radius, offsetX, offsetY) + { + if (offsetX === undefined) { offsetX = this.offset.x; } + if (offsetY === undefined) { offsetY = this.offset.y; } + + if (radius > 0) + { + this.isCircle = true; + this.radius = radius; + + this.sourceWidth = radius * 2; + this.sourceHeight = radius * 2; + + this.width = this.sourceWidth * this._sx; + this.height = this.sourceHeight * this._sy; + + this.halfWidth = Math.floor(this.width / 2); + this.halfHeight = Math.floor(this.height / 2); + + this.offset.set(offsetX, offsetY); + + this.updateCenter(); + } + else + { + this.isCircle = false; + } + + return this; + }, + + /** + * Resets this Body to the given coordinates. Also positions its parent Game Object to the same coordinates. + * If the body had any velocity or acceleration it is lost as a result of calling this. + * + * @method Phaser.Physics.Arcade.Body#reset + * @since 3.0.0 + * + * @param {number} x - The horizontal position to place the Game Object and Body. + * @param {number} y - The vertical position to place the Game Object and Body. + */ + reset: function (x, y) + { + this.stop(); + + var gameObject = this.gameObject; + + gameObject.setPosition(x, y); + + gameObject.getTopLeft(this.position); + + this.prev.copy(this.position); + + this.rotation = gameObject.angle; + this.preRotation = gameObject.angle; + + this.updateBounds(); + this.updateCenter(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#stop + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + stop: function () + { + this.velocity.set(0); + this.acceleration.set(0); + this.speed = 0; + this.angularVelocity = 0; + this.angularAcceleration = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#getBounds + * @since 3.0.0 + * + * @param {ArcadeBodyBounds} obj - [description] + * + * @return {ArcadeBodyBounds} [description] + */ + getBounds: function (obj) + { + obj.x = this.x; + obj.y = this.y; + obj.right = this.right; + obj.bottom = this.bottom; + + return obj; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#hitTest + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ + hitTest: function (x, y) + { + return (this.isCircle) ? CircleContains(this, x, y) : RectangleContains(this, x, y); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#onFloor + * @since 3.0.0 + * + * @return {boolean} [description] + */ + onFloor: function () + { + return this.blocked.down; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#onCeiling + * @since 3.0.0 + * + * @return {boolean} [description] + */ + onCeiling: function () + { + return this.blocked.up; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#onWall + * @since 3.0.0 + * + * @return {boolean} [description] + */ + onWall: function () + { + return (this.blocked.left || this.blocked.right); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#deltaAbsX + * @since 3.0.0 + * + * @return {number} [description] + */ + deltaAbsX: function () + { + return (this.deltaX() > 0) ? this.deltaX() : -this.deltaX(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#deltaAbsY + * @since 3.0.0 + * + * @return {number} [description] + */ + deltaAbsY: function () + { + return (this.deltaY() > 0) ? this.deltaY() : -this.deltaY(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#deltaX + * @since 3.0.0 + * + * @return {number} [description] + */ + deltaX: function () + { + return this.position.x - this.prev.x; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#deltaY + * @since 3.0.0 + * + * @return {number} [description] + */ + deltaY: function () + { + return this.position.y - this.prev.y; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#deltaZ + * @since 3.0.0 + * + * @return {number} [description] + */ + deltaZ: function () + { + return this.rotation - this.preRotation; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.enable = false; + + this.world.pendingDestroy.set(this); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#drawDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphic - [description] + */ + drawDebug: function (graphic) + { + var pos = this.position; + var x = pos.x + this.halfWidth; + var y = pos.y + this.halfHeight; + + if (this.debugShowBody) + { + graphic.lineStyle(1, this.debugBodyColor); + + if (this.isCircle) + { + graphic.strokeCircle(x, y, this.width / 2); + } + else + { + graphic.strokeRect(pos.x, pos.y, this.width, this.height); + } + } + + if (this.debugShowVelocity) + { + graphic.lineStyle(1, this.world.defaults.velocityDebugColor, 1); + graphic.lineBetween(x, y, x + this.velocity.x / 2, y + this.velocity.y / 2); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#willDrawDebug + * @since 3.0.0 + * + * @return {boolean} [description] + */ + willDrawDebug: function () + { + return (this.debugShowBody || this.debugShowVelocity); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setCollideWorldBounds + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setCollideWorldBounds: function (value) + { + this.collideWorldBounds = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setVelocity + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setVelocity: function (x, y) + { + this.velocity.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setVelocityX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setVelocityX: function (value) + { + this.velocity.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setVelocityY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setVelocityY: function (value) + { + this.velocity.y = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setBounce + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setBounce: function (x, y) + { + this.bounce.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setBounceX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setBounceX: function (value) + { + this.bounce.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setBounceY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setBounceY: function (value) + { + this.bounce.y = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setAcceleration + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAcceleration: function (x, y) + { + this.acceleration.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setAccelerationX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAccelerationX: function (value) + { + this.acceleration.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setAccelerationY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAccelerationY: function (value) + { + this.acceleration.y = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setDrag + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setDrag: function (x, y) + { + this.drag.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setDragX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setDragX: function (value) + { + this.drag.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setDragY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setDragY: function (value) + { + this.drag.y = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setGravity + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setGravity: function (x, y) + { + this.gravity.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setGravityX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setGravityX: function (value) + { + this.gravity.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setGravityY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setGravityY: function (value) + { + this.gravity.y = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setFriction + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setFriction: function (x, y) + { + this.friction.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setFrictionX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setFrictionX: function (value) + { + this.friction.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setFrictionY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setFrictionY: function (value) + { + this.friction.y = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setAngularVelocity + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAngularVelocity: function (value) + { + this.angularVelocity = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setAngularAcceleration + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAngularAcceleration: function (value) + { + this.angularAcceleration = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setAngularDrag + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAngularDrag: function (value) + { + this.angularDrag = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setMass + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setMass: function (value) + { + this.mass = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Body#setImmovable + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setImmovable: function (value) + { + this.immovable = value; + + return this; + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#x * @type {number} * @since 3.0.0 - */ + */ x: { get: function () @@ -51482,11 +51354,11 @@ var Pointer = new Class({ /** * [description] - * - * @name Phaser.Input.Pointer#y + * + * @name Phaser.Physics.Arcade.Body#y * @type {number} * @since 3.0.0 - */ + */ y: { get: function () @@ -51504,317 +51376,2393 @@ var Pointer = new Class({ /** * [description] * - * @method Phaser.Input.Pointer#reset + * @name Phaser.Physics.Arcade.Body#left + * @type {number} + * @readOnly * @since 3.0.0 */ - reset: function () - { - // this.buttons = 0; + left: { - this.dirty = false; - - this.justDown = false; - this.justUp = false; - this.justMoved = false; - - this.movementX = 0; - this.movementY = 0; - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#touchmove - * @since 3.0.0 - * - * @param {[type]} event - [description] - * @param {[type]} time - [description] - */ - touchmove: function (event) - { - this.event = event; - - this.x = this.manager.transformX(event.changedTouches[0].pageX); - this.y = this.manager.transformY(event.changedTouches[0].pageY); - - this.justMoved = true; - - this.dirty = true; - - this.wasTouch = true; - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#move - * @since 3.0.0 - * - * @param {[type]} event - [description] - * @param {[type]} time - [description] - */ - move: function (event) - { - if (event.buttons) + get: function () { - this.buttons = event.buttons; + return this.position.x; } - this.event = event; + }, - this.x = this.manager.transformX(event.pageX); - this.y = this.manager.transformY(event.pageY); + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#right + * @type {number} + * @readOnly + * @since 3.0.0 + */ + right: { - if (this.manager.mouse.locked) + get: function () { - // Multiple DOM events may occur within one frame, but only one Phaser event will fire - this.movementX += event.movementX || event.mozMovementX || event.webkitMovementX || 0; - this.movementY += event.movementY || event.mozMovementY || event.webkitMovementY || 0; + return this.position.x + this.width; } - this.justMoved = true; - - this.dirty = true; - - this.wasTouch = false; }, /** * [description] * - * @method Phaser.Input.Pointer#down + * @name Phaser.Physics.Arcade.Body#top + * @type {number} + * @readOnly * @since 3.0.0 - * - * @param {[type]} event - [description] - * @param {[type]} time - [description] */ - down: function (event, time) - { - if (event.buttons) + top: { + + get: function () { - this.buttons = event.buttons; + return this.position.y; } - this.event = event; + }, - this.x = this.manager.transformX(event.pageX); - this.y = this.manager.transformY(event.pageY); + /** + * [description] + * + * @name Phaser.Physics.Arcade.Body#bottom + * @type {number} + * @readOnly + * @since 3.0.0 + */ + bottom: { - // 0: Main button pressed, usually the left button or the un-initialized state - if (event.button === 0) + get: function () { - this.primaryDown = true; - this.downX = this.x; - this.downY = this.y; - this.downTime = time; + return this.position.y + this.height; } - this.justDown = true; - this.isDown = true; - - this.dirty = true; - - this.wasTouch = false; - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#touchstart - * @since 3.0.0 - * - * @param {[type]} event - [description] - * @param {[type]} time - [description] - */ - touchstart: function (event, time) - { - this.buttons = 1; - - this.event = event; - - this.x = this.manager.transformX(event.changedTouches[0].pageX); - this.y = this.manager.transformY(event.changedTouches[0].pageY); - - this.primaryDown = true; - this.downX = this.x; - this.downY = this.y; - this.downTime = time; - - this.justDown = true; - this.isDown = true; - - this.dirty = true; - - this.wasTouch = true; - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#up - * @since 3.0.0 - * - * @param {[type]} event - [description] - * @param {[type]} time - [description] - */ - up: function (event, time) - { - if (event.buttons) - { - this.buttons = event.buttons; - } - - this.event = event; - - this.x = this.manager.transformX(event.pageX); - this.y = this.manager.transformY(event.pageY); - - // 0: Main button pressed, usually the left button or the un-initialized state - if (event.button === 0) - { - this.primaryDown = false; - this.upX = this.x; - this.upY = this.y; - this.upTime = time; - } - - this.justUp = true; - this.isDown = false; - - this.dirty = true; - - this.wasTouch = false; - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#touchend - * @since 3.0.0 - * - * @param {[type]} event - [description] - * @param {[type]} time - [description] - */ - touchend: function (event, time) - { - this.buttons = 0; - - this.event = event; - - this.x = this.manager.transformX(event.changedTouches[0].pageX); - this.y = this.manager.transformY(event.changedTouches[0].pageY); - - this.primaryDown = false; - this.upX = this.x; - this.upY = this.y; - this.upTime = time; - - this.justUp = true; - this.isDown = false; - - this.dirty = true; - - this.wasTouch = true; - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#noButtonDown - * @since 3.0.0 - * - * @return {boolean} [description] - */ - noButtonDown: function () - { - return (this.buttons === 0); - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#leftButtonDown - * @since 3.0.0 - * - * @return {boolean} [description] - */ - leftButtonDown: function () - { - return (this.buttons & 1); - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#rightButtonDown - * @since 3.0.0 - * - * @return {boolean} [description] - */ - rightButtonDown: function () - { - return (this.buttons & 2); - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#middleButtonDown - * @since 3.0.0 - * - * @return {boolean} [description] - */ - middleButtonDown: function () - { - return (this.buttons & 4); - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#backButtonDown - * @since 3.0.0 - * - * @return {boolean} [description] - */ - backButtonDown: function () - { - return (this.buttons & 8); - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#forwardButtonDown - * @since 3.0.0 - * - * @return {boolean} [description] - */ - forwardButtonDown: function () - { - return (this.buttons & 16); - }, - - /** - * [description] - * - * @method Phaser.Input.Pointer#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.camera = null; - this.manager = null; - this.position = null; } }); -module.exports = Pointer; +module.exports = Body; /***/ }), -/* 250 */ +/* 210 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Body = __webpack_require__(209); +var Clamp = __webpack_require__(64); +var Class = __webpack_require__(0); +var Collider = __webpack_require__(208); +var CONST = __webpack_require__(47); +var DistanceBetween = __webpack_require__(48); +var EventEmitter = __webpack_require__(15); +var GetOverlapX = __webpack_require__(207); +var GetOverlapY = __webpack_require__(206); +var GetValue = __webpack_require__(5); +var ProcessQueue = __webpack_require__(205); +var ProcessTileCallbacks = __webpack_require__(477); +var Rectangle = __webpack_require__(10); +var RTree = __webpack_require__(204); +var SeparateTile = __webpack_require__(476); +var SeparateX = __webpack_require__(471); +var SeparateY = __webpack_require__(470); +var Set = __webpack_require__(63); +var StaticBody = __webpack_require__(201); +var TileIntersectsBody = __webpack_require__(202); +var Vector2 = __webpack_require__(6); +var Wrap = __webpack_require__(43); + +/** + * @typedef {object} ArcadeWorldConfig + * + * @property {object} [gravity] - [description] + * @property {number} [gravity.x=0] - [description] + * @property {number} [gravity.y=0] - [description] + * @property {number} [x=0] - [description] + * @property {number} [y=0] - [description] + * @property {number} [width=0] - [description] + * @property {number} [height=0] - [description] + * @property {object} [checkCollision] - [description] + * @property {boolean} [checkCollision.up=true] - [description] + * @property {boolean} [checkCollision.down=true] - [description] + * @property {boolean} [checkCollision.left=true] - [description] + * @property {boolean} [checkCollision.right=true] - [description] + * @property {number} [overlapBias=4] - [description] + * @property {number} [tileBias=16] - [description] + * @property {boolean} [forceX=false] - [description] + * @property {boolean} [isPaused=false] - [description] + * @property {boolean} [debug=false] - [description] + * @property {boolean} [debugShowBody=true] - [description] + * @property {boolean} [debugShowStaticBody=true] - [description] + * @property {boolean} [debugShowVelocity=true] - [description] + * @property {number} [debugBodyColor=0xff00ff] - [description] + * @property {number} [debugStaticBodyColor=0x0000ff] - [description] + * @property {number} [debugVelocityColor=0x00ff00] - [description] + * @property {number} [maxEntries=16] - [description] + */ + +/** + * @typedef {object} CheckCollisionObject + * + * @property {boolean} up - [description] + * @property {boolean} down - [description] + * @property {boolean} left - [description] + * @property {boolean} right - [description] + */ + +/** + * @typedef {object} ArcadeWorldDefaults + * + * @property {boolean} debugShowBody - [description] + * @property {boolean} debugShowStaticBody - [description] + * @property {boolean} debugShowVelocity - [description] + * @property {number} bodyDebugColor - [description] + * @property {number} staticBodyDebugColor - [description] + * @property {number} velocityDebugColor - [description] + */ + +/** + * @typedef {object} ArcadeWorldTreeMinMax + * + * @property {number} minX - [description] + * @property {number} minY - [description] + * @property {number} maxX - [description] + * @property {number} maxY - [description] + */ + +/** + * @classdesc + * [description] + * + * @class World + * @extends EventEmitter + * @memberOf Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {ArcadeWorldConfig} config - [description] + */ +var World = new Class({ + + Extends: EventEmitter, + + initialize: + + function World (scene, config) + { + EventEmitter.call(this); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * Dynamic Bodies + * + * @name Phaser.Physics.Arcade.World#bodies + * @type {Phaser.Structs.Set} + * @since 3.0.0 + */ + this.bodies = new Set(); + + /** + * Static Bodies + * + * @name Phaser.Physics.Arcade.World#staticBodies + * @type {Phaser.Structs.Set} + * @since 3.0.0 + */ + this.staticBodies = new Set(); + + /** + * Static Bodies + * + * @name Phaser.Physics.Arcade.World#pendingDestroy + * @type {Phaser.Structs.Set} + * @since 3.1.0 + */ + this.pendingDestroy = new Set(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#colliders + * @type {Phaser.Structs.ProcessQueue} + * @since 3.0.0 + */ + this.colliders = new ProcessQueue(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#gravity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.gravity = new Vector2(GetValue(config, 'gravity.x', 0), GetValue(config, 'gravity.y', 0)); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#bounds + * @type {Phaser.Geom.Rectangle} + * @since 3.0.0 + */ + this.bounds = new Rectangle( + GetValue(config, 'x', 0), + GetValue(config, 'y', 0), + GetValue(config, 'width', scene.sys.game.config.width), + GetValue(config, 'height', scene.sys.game.config.height) + ); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#checkCollision + * @type {CheckCollisionObject} + * @since 3.0.0 + */ + this.checkCollision = { + up: GetValue(config, 'checkCollision.up', true), + down: GetValue(config, 'checkCollision.down', true), + left: GetValue(config, 'checkCollision.left', true), + right: GetValue(config, 'checkCollision.right', true) + }; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#OVERLAP_BIAS + * @type {number} + * @default 4 + * @since 3.0.0 + */ + this.OVERLAP_BIAS = GetValue(config, 'overlapBias', 4); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#TILE_BIAS + * @type {number} + * @default 16 + * @since 3.0.0 + */ + this.TILE_BIAS = GetValue(config, 'tileBias', 16); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#forceX + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.forceX = GetValue(config, 'forceX', false); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#isPaused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isPaused = GetValue(config, 'isPaused', false); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#_total + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._total = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#drawDebug + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.drawDebug = GetValue(config, 'debug', false); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#debugGraphic + * @type {Phaser.GameObjects.Graphics} + * @since 3.0.0 + */ + this.debugGraphic; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#defaults + * @type {ArcadeWorldDefaults} + * @since 3.0.0 + */ + this.defaults = { + debugShowBody: GetValue(config, 'debugShowBody', true), + debugShowStaticBody: GetValue(config, 'debugShowStaticBody', true), + debugShowVelocity: GetValue(config, 'debugShowVelocity', true), + bodyDebugColor: GetValue(config, 'debugBodyColor', 0xff00ff), + staticBodyDebugColor: GetValue(config, 'debugStaticBodyColor', 0x0000ff), + velocityDebugColor: GetValue(config, 'debugVelocityColor', 0x00ff00) + }; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#maxEntries + * @type {integer} + * @default 16 + * @since 3.0.0 + */ + this.maxEntries = GetValue(config, 'maxEntries', 16); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#tree + * @type {Phaser.Structs.RTree} + * @since 3.0.0 + */ + this.tree = new RTree(this.maxEntries, [ '.left', '.top', '.right', '.bottom' ]); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#staticTree + * @type {Phaser.Structs.RTree} + * @since 3.0.0 + */ + this.staticTree = new RTree(this.maxEntries, [ '.left', '.top', '.right', '.bottom' ]); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.World#treeMinMax + * @type {ArcadeWorldTreeMinMax} + * @since 3.0.0 + */ + this.treeMinMax = { minX: 0, minY: 0, maxX: 0, maxY: 0 }; + + if (this.drawDebug) + { + this.createDebugGraphic(); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#enable + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} object - [description] + * @param {integer} [bodyType] - The type of Body to create. Either `DYNAMIC_BODY` or `STATIC_BODY`. + */ + enable: function (object, bodyType) + { + if (bodyType === undefined) { bodyType = CONST.DYNAMIC_BODY; } + + var i = 1; + + if (Array.isArray(object)) + { + i = object.length; + + while (i--) + { + if (object[i].hasOwnProperty('children')) + { + // If it's a Group then we do it on the children regardless + this.enable(object[i].children.entries, bodyType); + } + else + { + this.enableBody(object[i], bodyType); + } + } + } + else if (object.hasOwnProperty('children')) + { + // If it's a Group then we do it on the children regardless + this.enable(object.children.entries, bodyType); + } + else + { + this.enableBody(object, bodyType); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#enableBody + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} object - [description] + * @param {integer} [bodyType] - The type of Body to create. Either `DYNAMIC_BODY` or `STATIC_BODY`. + * + * @return {Phaser.GameObjects.GameObject} [description] + */ + enableBody: function (object, bodyType) + { + if (object.body === null) + { + if (bodyType === CONST.DYNAMIC_BODY) + { + object.body = new Body(this, object); + + this.bodies.set(object.body); + } + else if (bodyType === CONST.STATIC_BODY) + { + object.body = new StaticBody(this, object); + + this.staticBodies.set(object.body); + + this.staticTree.insert(object.body); + } + } + + return object; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#remove + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} object - [description] + */ + remove: function (object) + { + this.disableBody(object); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#disable + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} object - [description] + */ + disable: function (object) + { + var i = 1; + + if (Array.isArray(object)) + { + i = object.length; + + while (i--) + { + if (object[i].hasOwnProperty('children')) + { + // If it's a Group then we do it on the children regardless + this.disable(object[i].children.entries); + } + else + { + this.disableGameObjectBody(object[i]); + } + } + } + else if (object.hasOwnProperty('children')) + { + // If it's a Group then we do it on the children regardless + this.disable(object.children.entries); + } + else + { + this.disableGameObjectBody(object); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#disableGameObjectBody + * @since 3.1.0 + * + * @param {Phaser.GameObjects.GameObject} object - [description] + * + * @return {Phaser.GameObjects.GameObject} [description] + */ + disableGameObjectBody: function (object) + { + if (object.body) + { + if (object.body.physicsType === CONST.DYNAMIC_BODY) + { + this.bodies.delete(object.body); + } + else if (object.body.physicsType === CONST.STATIC_BODY) + { + this.staticBodies.delete(object.body); + this.staticTree.remove(object.body); + } + + object.body.enable = false; + } + + return object; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#disableBody + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - [description] + */ + disableBody: function (body) + { + if (body.physicsType === CONST.DYNAMIC_BODY) + { + this.tree.remove(body); + this.bodies.delete(body); + } + else if (body.physicsType === CONST.STATIC_BODY) + { + this.staticBodies.delete(body); + this.staticTree.remove(body); + } + + body.enable = false; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#createDebugGraphic + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} [description] + */ + createDebugGraphic: function () + { + var graphic = this.scene.sys.add.graphics({ x: 0, y: 0 }); + + graphic.setDepth(Number.MAX_VALUE); + + this.debugGraphic = graphic; + + this.drawDebug = true; + + return graphic; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#setBounds + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {boolean} [checkLeft] - [description] + * @param {boolean} [checkRight] - [description] + * @param {boolean} [checkUp] - [description] + * @param {boolean} [checkDown] - [description] + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + setBounds: function (x, y, width, height, checkLeft, checkRight, checkUp, checkDown) + { + this.bounds.setTo(x, y, width, height); + + if (checkLeft !== undefined) + { + this.setBoundsCollision(checkLeft, checkRight, checkUp, checkDown); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#setBoundsCollision + * @since 3.0.0 + * + * @param {boolean} [left=true] - [description] + * @param {boolean} [right=true] - [description] + * @param {boolean} [up=true] - [description] + * @param {boolean} [down=true] - [description] + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + setBoundsCollision: function (left, right, up, down) + { + if (left === undefined) { left = true; } + if (right === undefined) { right = true; } + if (up === undefined) { up = true; } + if (down === undefined) { down = true; } + + this.checkCollision.left = left; + this.checkCollision.right = right; + this.checkCollision.up = up; + this.checkCollision.down = down; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#pause + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + pause: function () + { + this.isPaused = true; + + this.emit('pause'); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#resume + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + resume: function () + { + this.isPaused = false; + + this.emit('resume'); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#addCollider + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for collision. + * @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for collision. + * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects collide. Must return a boolean. + * @param {*} [callbackContext] - The scope in which to call the callbacks. + * + * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. + */ + addCollider: function (object1, object2, collideCallback, processCallback, callbackContext) + { + if (collideCallback === undefined) { collideCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = collideCallback; } + + var collider = new Collider(this, false, object1, object2, collideCallback, processCallback, callbackContext); + + this.colliders.add(collider); + + return collider; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#addOverlap + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for overlap. + * @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for overlap. + * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects overlap. + * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects overlap. Must return a boolean. + * @param {*} [callbackContext] - The scope in which to call the callbacks. + * + * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. + */ + addOverlap: function (object1, object2, collideCallback, processCallback, callbackContext) + { + if (collideCallback === undefined) { collideCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = collideCallback; } + + var collider = new Collider(this, true, object1, object2, collideCallback, processCallback, callbackContext); + + this.colliders.add(collider); + + return collider; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#removeCollider + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Collider} collider - [description] + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + removeCollider: function (collider) + { + this.colliders.remove(collider); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#update + * @since 3.0.0 + * + * @param {number} time - [description] + * @param {number} delta - [description] + */ + update: function (time, delta) + { + if (this.isPaused || this.bodies.size === 0) + { + return; + } + + // this.delta = Math.min(delta / 1000, this.maxStep) * this.timeScale; + delta /= 1000; + + this.delta = delta; + + // Update all active bodies + + var i; + var body; + var bodies = this.bodies.entries; + var len = bodies.length; + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.enable) + { + body.update(delta); + } + } + + // Populate our dynamic collision tree + this.tree.clear(); + this.tree.load(bodies); + + // Process any colliders + var colliders = this.colliders.update(); + + for (i = 0; i < colliders.length; i++) + { + var collider = colliders[i]; + + if (collider.active) + { + collider.update(); + } + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#postUpdate + * @since 3.0.0 + */ + postUpdate: function () + { + var i; + var body; + + var dynamic = this.bodies; + var staticBodies = this.staticBodies; + var pending = this.pendingDestroy; + + var bodies = dynamic.entries; + var len = bodies.length; + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.enable) + { + body.postUpdate(); + } + } + + if (this.drawDebug) + { + var graphics = this.debugGraphic; + + graphics.clear(); + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.willDrawDebug()) + { + body.drawDebug(graphics); + } + } + + bodies = staticBodies.entries; + len = bodies.length; + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.willDrawDebug()) + { + body.drawDebug(graphics); + } + } + } + + if (pending.size > 0) + { + var dynamicTree = this.tree; + var staticTree = this.staticTree; + + bodies = pending.entries; + len = bodies.length; + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.physicsType === CONST.DYNAMIC_BODY) + { + dynamicTree.remove(body); + dynamic.delete(body); + } + else if (body.physicsType === CONST.STATIC_BODY) + { + staticTree.remove(body); + staticBodies.delete(body); + } + + body.world = undefined; + body.gameObject = undefined; + } + + pending.clear(); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#updateMotion + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - [description] + */ + updateMotion: function (body) + { + if (body.allowRotation) + { + var velocityDelta = this.computeVelocity(0, body, body.angularVelocity, body.angularAcceleration, body.angularDrag, body.maxAngular) - body.angularVelocity; + + body.angularVelocity += velocityDelta; + body.rotation += (body.angularVelocity * this.delta); + } + + body.velocity.x = this.computeVelocity(1, body, body.velocity.x, body.acceleration.x, body.drag.x, body.maxVelocity.x); + body.velocity.y = this.computeVelocity(2, body, body.velocity.y, body.acceleration.y, body.drag.y, body.maxVelocity.y); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#computeVelocity + * @since 3.0.0 + * + * @param {integer} axis - [description] + * @param {Phaser.Physics.Arcade.Body} body - [description] + * @param {number} velocity - [description] + * @param {number} acceleration - [description] + * @param {number} drag - [description] + * @param {number} max - [description] + * + * @return {number} [description] + */ + computeVelocity: function (axis, body, velocity, acceleration, drag, max) + { + if (max === undefined) { max = 10000; } + + if (axis === 1 && body.allowGravity) + { + velocity += (this.gravity.x + body.gravity.x) * this.delta; + } + else if (axis === 2 && body.allowGravity) + { + velocity += (this.gravity.y + body.gravity.y) * this.delta; + } + + if (acceleration) + { + velocity += acceleration * this.delta; + } + else if (drag && body.allowDrag) + { + drag *= this.delta; + + if (velocity - drag > 0) + { + velocity -= drag; + } + else if (velocity + drag < 0) + { + velocity += drag; + } + else + { + velocity = 0; + } + } + + if (velocity > max) + { + velocity = max; + } + else if (velocity < -max) + { + velocity = -max; + } + + return velocity; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#separate + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {ArcadePhysicsCallback} [processCallback] - [description] + * @param {*} [callbackContext] - [description] + * @param {boolean} [overlapOnly] - [description] + * + * @return {boolean} [description] + */ + separate: function (body1, body2, processCallback, callbackContext, overlapOnly) + { + if ( + !body1.enable || + !body2.enable || + body1.checkCollision.none || + body2.checkCollision.none || + !this.intersects(body1, body2)) + { + return false; + } + + // They overlap. Is there a custom process callback? If it returns true then we can carry on, otherwise we should abort. + if (processCallback && processCallback.call(callbackContext, body1.gameObject, body2.gameObject) === false) + { + return false; + } + + // Circle vs. Circle quick bail out + if (body1.isCircle && body2.isCircle) + { + return this.separateCircle(body1, body2, overlapOnly); + } + + // We define the behavior of bodies in a collision circle and rectangle + // If a collision occurs in the corner points of the rectangle, the body behave like circles + + // Either body1 or body2 is a circle + if (body1.isCircle !== body2.isCircle) + { + var bodyRect = (body1.isCircle) ? body2 : body1; + var bodyCircle = (body1.isCircle) ? body1 : body2; + + var rect = { + x: bodyRect.x, + y: bodyRect.y, + right: bodyRect.right, + bottom: bodyRect.bottom + }; + + var circle = bodyCircle.center; + + if (circle.y < rect.y || circle.y > rect.bottom) + { + if (circle.x < rect.x || circle.x > rect.right) + { + return this.separateCircle(body1, body2, overlapOnly); + } + } + } + + var resultX = false; + var resultY = false; + + // Do we separate on x or y first? + if (this.forceX || Math.abs(this.gravity.y + body1.gravity.y) < Math.abs(this.gravity.x + body1.gravity.x)) + { + resultX = SeparateX(body1, body2, overlapOnly, this.OVERLAP_BIAS); + + // Are they still intersecting? Let's do the other axis then + if (this.intersects(body1, body2)) + { + resultY = SeparateY(body1, body2, overlapOnly, this.OVERLAP_BIAS); + } + } + else + { + resultY = SeparateY(body1, body2, overlapOnly, this.OVERLAP_BIAS); + + // Are they still intersecting? Let's do the other axis then + if (this.intersects(body1, body2)) + { + resultX = SeparateX(body1, body2, overlapOnly, this.OVERLAP_BIAS); + } + } + + var result = (resultX || resultY); + + if (result) + { + if (overlapOnly && (body1.onOverlap || body2.onOverlap)) + { + this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2); + } + else if (body1.onCollide || body2.onCollide) + { + this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); + } + } + + return result; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#separateCircle + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {boolean} overlapOnly - [description] + * @param {number} bias - [description] + * + * @return {boolean} [description] + */ + separateCircle: function (body1, body2, overlapOnly, bias) + { + // Set the bounding box overlap values into the bodies themselves (hence we don't use the return values here) + GetOverlapX(body1, body2, false, bias); + GetOverlapY(body1, body2, false, bias); + + var dx = body2.center.x - body1.center.x; + var dy = body2.center.y - body1.center.y; + + var angleCollision = Math.atan2(dy, dx); + + var overlap = 0; + + if (body1.isCircle !== body2.isCircle) + { + var rect = { + x: (body2.isCircle) ? body1.position.x : body2.position.x, + y: (body2.isCircle) ? body1.position.y : body2.position.y, + right: (body2.isCircle) ? body1.right : body2.right, + bottom: (body2.isCircle) ? body1.bottom : body2.bottom + }; + + var circle = { + x: (body1.isCircle) ? body1.center.x : body2.center.x, + y: (body1.isCircle) ? body1.center.y : body2.center.y, + radius: (body1.isCircle) ? body1.halfWidth : body2.halfWidth + }; + + if (circle.y < rect.y) + { + if (circle.x < rect.x) + { + overlap = DistanceBetween(circle.x, circle.y, rect.x, rect.y) - circle.radius; + } + else if (circle.x > rect.right) + { + overlap = DistanceBetween(circle.x, circle.y, rect.right, rect.y) - circle.radius; + } + } + else if (circle.y > rect.bottom) + { + if (circle.x < rect.x) + { + overlap = DistanceBetween(circle.x, circle.y, rect.x, rect.bottom) - circle.radius; + } + else if (circle.x > rect.right) + { + overlap = DistanceBetween(circle.x, circle.y, rect.right, rect.bottom) - circle.radius; + } + } + + overlap *= -1; + } + else + { + overlap = (body1.halfWidth + body2.halfWidth) - DistanceBetween(body1.center.x, body1.center.y, body2.center.x, body2.center.y); + } + + // Can't separate two immovable bodies, or a body with its own custom separation logic + if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateX || body2.customSeparateX) + { + if (overlap !== 0 && (body1.onOverlap || body2.onOverlap)) + { + this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2); + } + + // return true if there was some overlap, otherwise false + return (overlap !== 0); + } + + // Transform the velocity vector to the coordinate system oriented along the direction of impact. + // This is done to eliminate the vertical component of the velocity + + var b1vx = body1.velocity.x; + var b1vy = body1.velocity.y; + var b1mass = body1.mass; + + var b2vx = body2.velocity.x; + var b2vy = body2.velocity.y; + var b2mass = body2.mass; + + var v1 = { + x: b1vx * Math.cos(angleCollision) + b1vy * Math.sin(angleCollision), + y: b1vx * Math.sin(angleCollision) - b1vy * Math.cos(angleCollision) + }; + + var v2 = { + x: b2vx * Math.cos(angleCollision) + b2vy * Math.sin(angleCollision), + y: b2vx * Math.sin(angleCollision) - b2vy * Math.cos(angleCollision) + }; + + // We expect the new velocity after impact + var tempVel1 = ((b1mass - b2mass) * v1.x + 2 * b2mass * v2.x) / (b1mass + b2mass); + var tempVel2 = (2 * b1mass * v1.x + (b2mass - b1mass) * v2.x) / (b1mass + b2mass); + + // We convert the vector to the original coordinate system and multiplied by factor of rebound + if (!body1.immovable) + { + body1.velocity.x = (tempVel1 * Math.cos(angleCollision) - v1.y * Math.sin(angleCollision)) * body1.bounce.x; + body1.velocity.y = (v1.y * Math.cos(angleCollision) + tempVel1 * Math.sin(angleCollision)) * body1.bounce.y; + + // Reset local var + b1vx = body1.velocity.x; + b1vy = body1.velocity.y; + } + + if (!body2.immovable) + { + body2.velocity.x = (tempVel2 * Math.cos(angleCollision) - v2.y * Math.sin(angleCollision)) * body2.bounce.x; + body2.velocity.y = (v2.y * Math.cos(angleCollision) + tempVel2 * Math.sin(angleCollision)) * body2.bounce.y; + + // Reset local var + b2vx = body2.velocity.x; + b2vy = body2.velocity.y; + } + + // When the collision angle is almost perpendicular to the total initial velocity vector + // (collision on a tangent) vector direction can be determined incorrectly. + // This code fixes the problem + + if (Math.abs(angleCollision) < Math.PI / 2) + { + if ((b1vx > 0) && !body1.immovable && (b2vx > b1vx)) + { + body1.velocity.x *= -1; + } + else if ((b2vx < 0) && !body2.immovable && (b1vx < b2vx)) + { + body2.velocity.x *= -1; + } + else if ((b1vy > 0) && !body1.immovable && (b2vy > b1vy)) + { + body1.velocity.y *= -1; + } + else if ((b2vy < 0) && !body2.immovable && (b1vy < b2vy)) + { + body2.velocity.y *= -1; + } + } + else if (Math.abs(angleCollision) > Math.PI / 2) + { + if ((b1vx < 0) && !body1.immovable && (b2vx < b1vx)) + { + body1.velocity.x *= -1; + } + else if ((b2vx > 0) && !body2.immovable && (b1vx > b2vx)) + { + body2.velocity.x *= -1; + } + else if ((b1vy < 0) && !body1.immovable && (b2vy < b1vy)) + { + body1.velocity.y *= -1; + } + else if ((b2vy > 0) && !body2.immovable && (b1vx > b2vy)) + { + body2.velocity.y *= -1; + } + } + + if (!body1.immovable) + { + body1.x += (body1.velocity.x * this.delta) - overlap * Math.cos(angleCollision); + body1.y += (body1.velocity.y * this.delta) - overlap * Math.sin(angleCollision); + } + + if (!body2.immovable) + { + body2.x += (body2.velocity.x * this.delta) + overlap * Math.cos(angleCollision); + body2.y += (body2.velocity.y * this.delta) + overlap * Math.sin(angleCollision); + } + + if (body1.onCollide || body2.onCollide) + { + this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); + } + + return true; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#intersects + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * + * @return {boolean} [description] + */ + intersects: function (body1, body2) + { + if (body1 === body2) + { + return false; + } + + if (body1.isCircle) + { + if (body2.isCircle) + { + // Circle vs. Circle + return DistanceBetween(body1.center.x, body1.center.y, body2.center.x, body2.center.y) <= (body1.halfWidth + body2.halfWidth); + } + else + { + // Circle vs. Rect + return this.circleBodyIntersects(body1, body2); + } + } + else if (body2.isCircle) + { + // Rect vs. Circle + return this.circleBodyIntersects(body2, body1); + } + else + { + // Rect vs. Rect + if (body1.right <= body2.position.x) + { + return false; + } + + if (body1.bottom <= body2.position.y) + { + return false; + } + + if (body1.position.x >= body2.right) + { + return false; + } + + if (body1.position.y >= body2.bottom) + { + return false; + } + + return true; + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#circleBodyIntersects + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} circle - [description] + * @param {Phaser.Physics.Arcade.Body} body - [description] + * + * @return {boolean} [description] + */ + circleBodyIntersects: function (circle, body) + { + var x = Clamp(circle.center.x, body.left, body.right); + var y = Clamp(circle.center.y, body.top, body.bottom); + + var dx = (circle.center.x - x) * (circle.center.x - x); + var dy = (circle.center.y - y) * (circle.center.y - y); + + return (dx + dy) <= (circle.halfWidth * circle.halfWidth); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#overlap + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} object1 - [description] + * @param {Phaser.GameObjects.GameObject} object2 - [description] + * @param {ArcadePhysicsCallback} [overlapCallback] - [description] + * @param {ArcadePhysicsCallback} [processCallback] - [description] + * @param {*} [callbackContext] - [description] + * + * @return {boolean} [description] + */ + overlap: function (object1, object2, overlapCallback, processCallback, callbackContext) + { + if (overlapCallback === undefined) { overlapCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = overlapCallback; } + + return this.collideObjects(object1, object2, overlapCallback, processCallback, callbackContext, true); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#collide + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} object1 - [description] + * @param {Phaser.GameObjects.GameObject} object2 - [description] + * @param {ArcadePhysicsCallback} [collideCallback] - [description] + * @param {ArcadePhysicsCallback} [processCallback] - [description] + * @param {*} [callbackContext] - [description] + * + * @return {boolean} [description] + */ + collide: function (object1, object2, collideCallback, processCallback, callbackContext) + { + if (collideCallback === undefined) { collideCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = collideCallback; } + + return this.collideObjects(object1, object2, collideCallback, processCallback, callbackContext, false); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#collideObjects + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} object1 - [description] + * @param {Phaser.GameObjects.GameObject} object2 - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - [description] + * + * @return {boolean} [description] + */ + collideObjects: function (object1, object2, collideCallback, processCallback, callbackContext, overlapOnly) + { + var i; + object1 = object1.isParent && typeof(object1.physicsType) === 'undefined' ? object1.children.entries : object1; + object2 = object2.isParent && typeof(object2.physicsType) === 'undefined' ? object2.children.entries : object2; + var object1isArray = Array.isArray(object1); + var object2isArray = Array.isArray(object2); + + this._total = 0; + + if (!object1isArray && !object2isArray) + { + // Neither of them are arrays - do this first as it's the most common use-case + this.collideHandler(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (!object1isArray && object2isArray) + { + // Object 2 is an Array + for (i = 0; i < object2.length; i++) + { + this.collideHandler(object1, object2[i], collideCallback, processCallback, callbackContext, overlapOnly); + } + } + else if (object1isArray && !object2isArray) + { + // Object 1 is an Array + for (i = 0; i < object1.length; i++) + { + this.collideHandler(object1[i], object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + } + else + { + // They're both arrays + for (i = 0; i < object1.length; i++) + { + for (var j = 0; j < object2.length; j++) + { + this.collideHandler(object1[i], object2[j], collideCallback, processCallback, callbackContext, overlapOnly); + } + } + } + + return (this._total > 0); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#collideHandler + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} object1 - [description] + * @param {Phaser.GameObjects.GameObject} object2 - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - [description] + * + * @return {boolean} [description] + */ + collideHandler: function (object1, object2, collideCallback, processCallback, callbackContext, overlapOnly) + { + // Collide Group with Self + // Only collide valid objects + if (object2 === undefined && object1.isParent) + { + return this.collideGroupVsGroup(object1, object1, collideCallback, processCallback, callbackContext, overlapOnly); + } + + // If neither of the objects are set then bail out + if (!object1 || !object2) + { + return false; + } + + // A Body + if (object1.body) + { + if (object2.body) + { + return this.collideSpriteVsSprite(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isParent) + { + return this.collideSpriteVsGroup(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isTilemap) + { + return this.collideSpriteVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + } + + // GROUPS + else if (object1.isParent) + { + if (object2.body) + { + return this.collideSpriteVsGroup(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isParent) + { + return this.collideGroupVsGroup(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isTilemap) + { + return this.collideGroupVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + } + + // TILEMAP LAYERS + else if (object1.isTilemap) + { + if (object2.body) + { + return this.collideSpriteVsTilemapLayer(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isParent) + { + return this.collideGroupVsTilemapLayer(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); + } + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#collideSpriteVsSprite + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} sprite1 - [description] + * @param {Phaser.GameObjects.GameObject} sprite2 - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - [description] + * + * @return {boolean} [description] + */ + collideSpriteVsSprite: function (sprite1, sprite2, collideCallback, processCallback, callbackContext, overlapOnly) + { + if (!sprite1.body || !sprite2.body) + { + return false; + } + + if (this.separate(sprite1.body, sprite2.body, processCallback, callbackContext, overlapOnly)) + { + if (collideCallback) + { + collideCallback.call(callbackContext, sprite1, sprite2); + } + + this._total++; + } + + return true; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#collideSpriteVsGroup + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} sprite - [description] + * @param {Phaser.GameObjects.Group} group - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - [description] + * + * @return {boolean} [description] + */ + collideSpriteVsGroup: function (sprite, group, collideCallback, processCallback, callbackContext, overlapOnly) + { + var bodyA = sprite.body; + + if (group.length === 0 || !bodyA) + { + return; + } + + // Does sprite collide with anything? + + var minMax = this.treeMinMax; + + minMax.minX = bodyA.left; + minMax.minY = bodyA.top; + minMax.maxX = bodyA.right; + minMax.maxY = bodyA.bottom; + + var results = (group.physicsType === CONST.DYNAMIC_BODY) ? this.tree.search(minMax) : this.staticTree.search(minMax); + + if (results.length === 0) + { + return; + } + + var children = group.getChildren(); + + for (var i = 0; i < children.length; i++) + { + var bodyB = children[i].body; + + if (!bodyB || bodyA === bodyB || results.indexOf(bodyB) === -1) + { + continue; + } + + if (this.separate(bodyA, bodyB, processCallback, callbackContext, overlapOnly)) + { + if (collideCallback) + { + collideCallback.call(callbackContext, bodyA.gameObject, bodyB.gameObject); + } + + this._total++; + } + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#collideGroupVsTilemapLayer + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Group} group - [description] + * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - [description] + * + * @return {boolean} [description] + */ + collideGroupVsTilemapLayer: function (group, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) + { + var children = group.getChildren(); + + if (children.length === 0) + { + return false; + } + + var didCollide = false; + + for (var i = 0; i < children.length; i++) + { + if (children[i].body) + { + if (this.collideSpriteVsTilemapLayer(children[i], tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly)) + { + didCollide = true; + } + } + } + + return didCollide; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#collideSpriteVsTilemapLayer + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} sprite - [description] + * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - [description] + * + * @return {boolean} [description] + */ + collideSpriteVsTilemapLayer: function (sprite, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) + { + var body = sprite.body; + + if (!body.enable) + { + return false; + } + + var x = body.position.x; + var y = body.position.y; + var w = body.width; + var h = body.height; + + // TODO: this logic should be encapsulated within the Tilemap API at some point. + // If the maps base tile size differs from the layer's tile size, we need to adjust the + // selection area by the difference between the two. + var layerData = tilemapLayer.layer; + + if (layerData.tileWidth > layerData.baseTileWidth) + { + // The x origin of a tile is the left side, so x and width need to be adjusted. + var xDiff = (layerData.tileWidth - layerData.baseTileWidth) * tilemapLayer.scaleX; + x -= xDiff; + w += xDiff; + } + + if (layerData.tileHeight > layerData.baseTileHeight) + { + // The y origin of a tile is the bottom side, so just the height needs to be adjusted. + var yDiff = (layerData.tileHeight - layerData.baseTileHeight) * tilemapLayer.scaleY; + h += yDiff; + } + + var mapData = tilemapLayer.getTilesWithinWorldXY(x, y, w, h); + + if (mapData.length === 0) + { + return false; + } + + var tile; + var tileWorldRect = { left: 0, right: 0, top: 0, bottom: 0 }; + + for (var i = 0; i < mapData.length; i++) + { + tile = mapData[i]; + tileWorldRect.left = tilemapLayer.tileToWorldX(tile.x); + tileWorldRect.top = tilemapLayer.tileToWorldY(tile.y); + + // If the map's base tile size differs from the layer's tile size, only the top of the rect + // needs to be adjusted since it's origin is (0, 1). + if (tile.baseHeight !== tile.height) + { + tileWorldRect.top -= (tile.height - tile.baseHeight) * tilemapLayer.scaleY; + } + + tileWorldRect.right = tileWorldRect.left + tile.width * tilemapLayer.scaleX; + tileWorldRect.bottom = tileWorldRect.top + tile.height * tilemapLayer.scaleY; + + if (TileIntersectsBody(tileWorldRect, body) + && (!processCallback || processCallback.call(callbackContext, sprite, tile)) + && ProcessTileCallbacks(tile, sprite) + && (overlapOnly || SeparateTile(i, body, tile, tileWorldRect, tilemapLayer, this.TILE_BIAS))) + { + this._total++; + + if (collideCallback) + { + collideCallback.call(callbackContext, sprite, tile); + } + + if (overlapOnly && body.onOverlap) + { + sprite.emit('overlap', body.gameObject, tile, body, null); + } + else if (body.onCollide) + { + sprite.emit('collide', body.gameObject, tile, body, null); + } + } + } + }, + + /** + * TODO! + * + * @method Phaser.Physics.Arcade.World#collideGroupVsGroup + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Group} group1 - [description] + * @param {Phaser.GameObjects.Group} group2 - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - [description] + * + * @return {boolean} [description] + */ + collideGroupVsGroup: function (group1, group2, collideCallback, processCallback, callbackContext, overlapOnly) + { + if (group1.length === 0 || group2.length === 0) + { + return; + } + + var children = group1.getChildren(); + + for (var i = 0; i < children.length; i++) + { + this.collideSpriteVsGroup(children[i], group2, collideCallback, processCallback, callbackContext, overlapOnly); + } + }, + + /** + * Wrap an object's coordinates (or several objects' coordinates) within {@link Phaser.Physics.Arcade.World#bounds}. + * + * If the object is outside any boundary edge (left, top, right, bottom), it will be moved to the same offset from the opposite edge (the interior). + * + * @method Phaser.Physics.Arcade.World#wrap + * @since 3.3.0 + * + * @param {*} object - A Game Object, a Group, an object with `x` and `y` coordinates, or an array of such objects. + * @param {number} [padding=0] - An amount added to each boundary edge during the operation. + */ + wrap: function (object, padding) + { + if (object.body) + { + this.wrapObject(object, padding); + } + else if (object.getChildren) + { + this.wrapArray(object.getChildren(), padding); + } + else if (Array.isArray(object)) + { + this.wrapArray(object, padding); + } + else + { + this.wrapObject(object, padding); + } + }, + + + /** + * Wrap each object's coordinates within {@link Phaser.Physics.Arcade.World#bounds}. + * + * @method Phaser.Physics.Arcade.World#wrapArray + * @since 3.3.0 + * + * @param {Array.<*>} arr + * @param {number} [padding=0] - An amount added to the boundary. + */ + wrapArray: function (arr, padding) + { + if (arr.length === 0) + { + return; + } + + for (var i = 0, len = arr.length; i < len; i++) + { + this.wrapObject(arr[i], padding); + } + }, + + /** + * Wrap an object's coordinates within {@link Phaser.Physics.Arcade.World#bounds}. + * + * @method Phaser.Physics.Arcade.World#wrapObject + * @since 3.3.0 + * + * @param {*} object - A Game Object, a Physics Body, or any object with `x` and `y` coordinates + * @param {number} [padding=0] - An amount added to the boundary. + */ + wrapObject: function (object, padding) + { + if (padding === undefined) + { + padding = 0; + } + + object.x = Wrap(object.x, this.bounds.left - padding, this.bounds.right + padding); + object.y = Wrap(object.y, this.bounds.top - padding, this.bounds.bottom + padding); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.removeAllListeners(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.World#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.tree.clear(); + this.staticTree.clear(); + this.bodies.clear(); + this.staticBodies.clear(); + this.colliders.destroy(); + + this.removeAllListeners(); + } + +}); + +module.exports = World; + + +/***/ }), +/* 211 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Phaser.Physics.Arcade.StaticGroup + +var ArcadeSprite = __webpack_require__(93); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(47); +var Group = __webpack_require__(73); + +/** + * @classdesc + * [description] + * + * @class StaticGroup + * @extends Phaser.GameObjects.Group + * @memberOf Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - [description] + * @param {Phaser.Scene} scene - [description] + * @param {array} children - [description] + * @param {GroupConfig} config - [description] + */ +var StaticPhysicsGroup = new Class({ + + Extends: Group, + + initialize: + + function StaticPhysicsGroup (world, scene, children, config) + { + if (config === undefined && !Array.isArray(children) && typeof children === 'object') + { + config = children; + children = null; + } + else if (config === undefined) + { + config = {}; + } + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticGroup#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + config.createCallback = this.createCallback; + config.removeCallback = this.removeCallback; + config.createMultipleCallback = this.createMultipleCallback; + + config.classType = ArcadeSprite; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticGroup#physicsType + * @type {integer} + * @since 3.0.0 + */ + this.physicsType = CONST.STATIC_BODY; + + Group.call(this, scene, children, config); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticGroup#createCallback + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - [description] + */ + createCallback: function (child) + { + if (!child.body) + { + this.world.enableBody(child, CONST.STATIC_BODY); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticGroup#removeCallback + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - [description] + */ + removeCallback: function (child) + { + if (child.body) + { + this.world.disableBody(child); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticGroup#createMultipleCallback + * @since 3.0.0 + * + * @param {object} entries - [description] + */ + createMultipleCallback: function () + { + this.refresh(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticGroup#refresh + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.StaticGroup} [description] + */ + refresh: function () + { + var children = this.children.entries; + + for (var i = 0; i < children.length; i++) + { + children[i].body.reset(); + } + + return this; + } + +}); + +module.exports = StaticPhysicsGroup; + + +/***/ }), +/* 212 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArcadeSprite = __webpack_require__(93); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(47); +var GetFastValue = __webpack_require__(2); +var Group = __webpack_require__(73); + +/** + * @typedef {object} PhysicsGroupConfig + * @extends GroupConfig + * + * @property {[type]} [collideWorldBounds=false] - [description] + * @property {number} [accelerationX=0] - [description] + * @property {number} [accelerationY=0] - [description] + * @property {number} [bounceX=0] - [description] + * @property {number} [bounceY=0] - [description] + * @property {number} [dragX=0] - [description] + * @property {number} [dragY=0] - [description] + * @property {number} [gravityX=0] - [description] + * @property {number} [gravityY=0] - [description] + * @property {number} [frictionX=0] - [description] + * @property {number} [frictionY=0] - [description] + * @property {number} [velocityX=0] - [description] + * @property {number} [velocityY=0] - [description] + * @property {number} [angularVelocity=0] - [description] + * @property {number} [angularAcceleration=0] - [description] + * @property {number} [angularDrag=0] - [description] + * @property {number} [mass=0] - [description] + * @property {boolean} [immovable=false] - [description] + */ + +/** + * @typedef {object} PhysicsGroupDefaults + * + * @property {[type]} setCollideWorldBounds - [description] + * @property {number} setAccelerationX - [description] + * @property {number} setAccelerationY - [description] + * @property {number} setBounceX - [description] + * @property {number} setBounceY - [description] + * @property {number} setDragX - [description] + * @property {number} setDragY - [description] + * @property {number} setGravityX - [description] + * @property {number} setGravityY - [description] + * @property {number} setFrictionX - [description] + * @property {number} setFrictionY - [description] + * @property {number} setVelocityX - [description] + * @property {number} setVelocityY - [description] + * @property {number} setAngularVelocity - [description] + * @property {number} setAngularAcceleration - [description] + * @property {number} setAngularDrag - [description] + * @property {number} setMass - [description] + * @property {boolean} setImmovable - [description] + */ + +/** + * @classdesc + * An Arcade Physics Group object. + * + * All Game Objects created by this Group will automatically be dynamic Arcade Physics objects. + * + * @class Group + * @extends Phaser.GameObjects.Group + * @memberOf Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - [description] + * @param {Phaser.Scene} scene - [description] + * @param {array} children - [description] + * @param {PhysicsGroupConfig} [config] - [description] + */ +var PhysicsGroup = new Class({ + + Extends: Group, + + initialize: + + function PhysicsGroup (world, scene, children, config) + { + if (config === undefined && !Array.isArray(children) && typeof children === 'object') + { + config = children; + children = null; + } + else if (config === undefined) + { + config = {}; + } + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Group#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + config.createCallback = this.createCallback; + config.removeCallback = this.removeCallback; + + config.classType = GetFastValue(config, 'classType', ArcadeSprite); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Group#physicsType + * @type {integer} + * @since 3.0.0 + */ + this.physicsType = CONST.DYNAMIC_BODY; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Group#defaults + * @type {PhysicsGroupDefaults} + * @since 3.0.0 + */ + this.defaults = { + setCollideWorldBounds: GetFastValue(config, 'collideWorldBounds', false), + setAccelerationX: GetFastValue(config, 'accelerationX', 0), + setAccelerationY: GetFastValue(config, 'accelerationY', 0), + setBounceX: GetFastValue(config, 'bounceX', 0), + setBounceY: GetFastValue(config, 'bounceY', 0), + setDragX: GetFastValue(config, 'dragX', 0), + setDragY: GetFastValue(config, 'dragY', 0), + setGravityX: GetFastValue(config, 'gravityX', 0), + setGravityY: GetFastValue(config, 'gravityY', 0), + setFrictionX: GetFastValue(config, 'frictionX', 0), + setFrictionY: GetFastValue(config, 'frictionY', 0), + setVelocityX: GetFastValue(config, 'velocityX', 0), + setVelocityY: GetFastValue(config, 'velocityY', 0), + setAngularVelocity: GetFastValue(config, 'angularVelocity', 0), + setAngularAcceleration: GetFastValue(config, 'angularAcceleration', 0), + setAngularDrag: GetFastValue(config, 'angularDrag', 0), + setMass: GetFastValue(config, 'mass', 1), + setImmovable: GetFastValue(config, 'immovable', false) + }; + + Group.call(this, scene, children, config); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Group#createCallback + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - [description] + */ + createCallback: function (child) + { + if (!child.body) + { + this.world.enableBody(child, CONST.DYNAMIC_BODY); + } + + var body = child.body; + + for (var key in this.defaults) + { + body[key](this.defaults[key]); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Group#removeCallback + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - [description] + */ + removeCallback: function (child) + { + if (child.body) + { + this.world.disableBody(child); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Group#setVelocity + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} step - [description] + * + * @return {Phaser.Physics.Arcade.Group} This Physics Group object. + */ + setVelocity: function (x, y, step) + { + if (step === undefined) { step = 0; } + + var items = this.getChildren(); + + for (var i = 0; i < items.length; i++) + { + items[i].body.velocity.set(x + (i * step), y + (i * step)); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Group#setVelocityX + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} step - [description] + * + * @return {Phaser.Physics.Arcade.Group} This Physics Group object. + */ + setVelocityX: function (value, step) + { + if (step === undefined) { step = 0; } + + var items = this.getChildren(); + + for (var i = 0; i < items.length; i++) + { + items[i].body.velocity.x = value + (i * step); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Group#setVelocityY + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} step - [description] + * + * @return {Phaser.Physics.Arcade.Group} This Physics Group object. + */ + setVelocityY: function (value, step) + { + if (step === undefined) { step = 0; } + + var items = this.getChildren(); + + for (var i = 0; i < items.length; i++) + { + items[i].body.velocity.y = value + (i * step); + } + + return this; + } + +}); + +module.exports = PhysicsGroup; + + +/***/ }), +/* 213 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Physics.Arcade.Body.Components + */ + +module.exports = { + + Acceleration: __webpack_require__(489), + Angular: __webpack_require__(488), + Bounce: __webpack_require__(487), + Debug: __webpack_require__(486), + Drag: __webpack_require__(485), + Enable: __webpack_require__(484), + Friction: __webpack_require__(483), + Gravity: __webpack_require__(482), + Immovable: __webpack_require__(481), + Mass: __webpack_require__(480), + Size: __webpack_require__(479), + Velocity: __webpack_require__(478) + +}; + + +/***/ }), +/* 214 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -51824,190 +53772,3390 @@ module.exports = Pointer; */ var Class = __webpack_require__(0); +var Components = __webpack_require__(213); +var Image = __webpack_require__(72); -// https://developer.mozilla.org/en-US/docs/Web/API/Touch_events -// https://patrickhlauke.github.io/touch/tests/results/ -// https://www.html5rocks.com/en/mobile/touch/ +/** + * @classdesc + * An Arcade Physics Image Game Object. + * + * An Image is a light-weight Game Object useful for the display of static images in your game, + * such as logos, backgrounds, scenery or other non-animated elements. Images can have input + * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an + * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. + * + * @class Image + * @extends Phaser.GameObjects.Image + * @memberOf Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @extends Phaser.Physics.Arcade.Components.Acceleration + * @extends Phaser.Physics.Arcade.Components.Angular + * @extends Phaser.Physics.Arcade.Components.Bounce + * @extends Phaser.Physics.Arcade.Components.Debug + * @extends Phaser.Physics.Arcade.Components.Drag + * @extends Phaser.Physics.Arcade.Components.Enable + * @extends Phaser.Physics.Arcade.Components.Friction + * @extends Phaser.Physics.Arcade.Components.Gravity + * @extends Phaser.Physics.Arcade.Components.Immovable + * @extends Phaser.Physics.Arcade.Components.Mass + * @extends Phaser.Physics.Arcade.Components.Size + * @extends Phaser.Physics.Arcade.Components.Velocity + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var ArcadeImage = new Class({ + + Extends: Image, + + Mixins: [ + Components.Acceleration, + Components.Angular, + Components.Bounce, + Components.Debug, + Components.Drag, + Components.Enable, + Components.Friction, + Components.Gravity, + Components.Immovable, + Components.Mass, + Components.Size, + Components.Velocity + ], + + initialize: + + function ArcadeImage (scene, x, y, texture, frame) + { + Image.call(this, scene, x, y, texture, frame); + } + +}); + +module.exports = ArcadeImage; + + +/***/ }), +/* 215 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArcadeImage = __webpack_require__(214); +var ArcadeSprite = __webpack_require__(93); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(47); +var PhysicsGroup = __webpack_require__(212); +var StaticPhysicsGroup = __webpack_require__(211); + +/** + * @classdesc + * The Arcade Physics Factory allows you to easily create Arcade Physics enabled Game Objects. + * Objects that are created by this Factory are automatically added to the physics world. + * + * @class Factory + * @memberOf Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - The Arcade Physics World instance. + */ +var Factory = new Class({ + + initialize: + + function Factory (world) + { + /** + * A reference to the Arcade Physics World. + * + * @name Phaser.Physics.Arcade.Factory#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * A reference to the Scene this Arcade Physics instance belongs to. + * + * @name Phaser.Physics.Arcade.Factory#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = world.scene; + + /** + * A reference to the Scene.Systems this Arcade Physics instance belongs to. + * + * @name Phaser.Physics.Arcade.Factory#sys + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.sys = world.scene.sys; + }, + + /** + * Create a new Arcade Physics Collider object. + * + * @method Phaser.Physics.Arcade.Factory#collider + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for collision. + * @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for collision. + * @param {ArcadePhysicsCallback} collideCallback - The callback to invoke when the two objects collide. + * @param {ArcadePhysicsCallback} processCallback - The callback to invoke when the two objects collide. Must return a boolean. + * @param {*} callbackContext - The scope in which to call the callbacks. + * + * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. + */ + collider: function (object1, object2, collideCallback, processCallback, callbackContext) + { + return this.world.addCollider(object1, object2, collideCallback, processCallback, callbackContext); + }, + + /** + * Create a new Arcade Physics Collider Overlap object. + * + * @method Phaser.Physics.Arcade.Factory#overlap + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for overlap. + * @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for overlap. + * @param {ArcadePhysicsCallback} collideCallback - The callback to invoke when the two objects collide. + * @param {ArcadePhysicsCallback} processCallback - The callback to invoke when the two objects collide. Must return a boolean. + * @param {*} callbackContext - The scope in which to call the callbacks. + * + * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. + */ + overlap: function (object1, object2, collideCallback, processCallback, callbackContext) + { + return this.world.addOverlap(object1, object2, collideCallback, processCallback, callbackContext); + }, + + /** + * Adds an Arcade Physics Body to the given Game Object. + * + * @method Phaser.Physics.Arcade.Factory#existing + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * @param {boolean} [isStatic=false] - Set to true to create a Static body, otherwise it will create a Dynamic body. + * + * @return {Phaser.GameObjects.GameObject} The Game Object. + */ + existing: function (gameObject, isStatic) + { + var type = (isStatic) ? CONST.STATIC_BODY : CONST.DYNAMIC_BODY; + + this.world.enableBody(gameObject, type); + + return gameObject; + }, + + /** + * Creates a new Arcade Image object with a Static body. + * + * @method Phaser.Physics.Arcade.Factory#staticImage + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Arcade.Image} The Image object that was created. + */ + staticImage: function (x, y, key, frame) + { + var image = new ArcadeImage(this.scene, x, y, key, frame); + + this.sys.displayList.add(image); + + this.world.enableBody(image, CONST.STATIC_BODY); + + return image; + }, + + /** + * Creates a new Arcade Image object with a Dynamic body. + * + * @method Phaser.Physics.Arcade.Factory#image + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Arcade.Image} The Image object that was created. + */ + image: function (x, y, key, frame) + { + var image = new ArcadeImage(this.scene, x, y, key, frame); + + this.sys.displayList.add(image); + + this.world.enableBody(image, CONST.DYNAMIC_BODY); + + return image; + }, + + /** + * Creates a new Arcade Sprite object with a Static body. + * + * @method Phaser.Physics.Arcade.Factory#staticSprite + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Arcade.Sprite} The Sprite object that was created. + */ + staticSprite: function (x, y, key, frame) + { + var sprite = new ArcadeSprite(this.scene, x, y, key, frame); + + this.sys.displayList.add(sprite); + this.sys.updateList.add(sprite); + + this.world.enableBody(sprite, CONST.STATIC_BODY); + + return sprite; + }, + + /** + * Creates a new Arcade Sprite object with a Dynamic body. + * + * @method Phaser.Physics.Arcade.Factory#sprite + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Arcade.Sprite} The Sprite object that was created. + */ + sprite: function (x, y, key, frame) + { + var sprite = new ArcadeSprite(this.scene, x, y, key, frame); + + this.sys.displayList.add(sprite); + this.sys.updateList.add(sprite); + + this.world.enableBody(sprite, CONST.DYNAMIC_BODY); + + return sprite; + }, + + /** + * Creates a Static Physics Group object. + * All Game Objects created by this Group will automatically be static Arcade Physics objects. + * + * @method Phaser.Physics.Arcade.Factory#staticGroup + * @since 3.0.0 + * + * @param {array} [children] - [description] + * @param {GroupConfig} [config] - [description] + * + * @return {Phaser.Physics.Arcade.StaticGroup} The Static Group object that was created. + */ + staticGroup: function (children, config) + { + return this.sys.updateList.add(new StaticPhysicsGroup(this.world, this.world.scene, children, config)); + }, + + /** + * Creates a Physics Group object. + * All Game Objects created by this Group will automatically be dynamic Arcade Physics objects. + * + * @method Phaser.Physics.Arcade.Factory#group + * @since 3.0.0 + * + * @param {array} [children] - [description] + * @param {PhysicsGroupConfig} [config] - [description] + * + * @return {Phaser.Physics.Arcade.Group} The Group object that was created. + */ + group: function (children, config) + { + return this.sys.updateList.add(new PhysicsGroup(this.world, this.world.scene, children, config)); + } + +}); + +module.exports = Factory; + + +/***/ }), +/* 216 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.RoundAwayFromZero + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {number} [description] + */ +var RoundAwayFromZero = function (value) +{ + // "Opposite" of truncate. + return (value > 0) ? Math.ceil(value) : Math.floor(value); +}; + +module.exports = RoundAwayFromZero; + + +/***/ }), +/* 217 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Rotate + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point - [description] + * @param {number} angle - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Rotate = function (point, angle) +{ + var x = point.x; + var y = point.y; + + point.x = (x * Math.cos(angle)) - (y * Math.sin(angle)); + point.y = (x * Math.sin(angle)) + (y * Math.cos(angle)); + + return point; +}; + +module.exports = Rotate; + + +/***/ }), +/* 218 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Factorial + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {number} [description] + */ +var Factorial = function (value) +{ + if (value === 0) + { + return 1; + } + + var res = value; + + while (--value) + { + res *= value; + } + + return res; +}; + +module.exports = Factorial; + + +/***/ }), +/* 219 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Factorial = __webpack_require__(218); + +/** + * [description] + * + * @function Phaser.Math.Bernstein + * @since 3.0.0 + * + * @param {number} n - [description] + * @param {number} i - [description] + * + * @return {number} [description] + */ +var Bernstein = function (n, i) +{ + return Factorial(n) / Factorial(i) / Factorial(n - i); +}; + +module.exports = Bernstein; + + +/***/ }), +/* 220 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Angle.Normalize + * @since 3.0.0 + * + * @param {number} angle - [description] + * + * @return {number} [description] + */ +var Normalize = function (angle) +{ + angle = angle % (2 * Math.PI); + + if (angle >= 0) + { + return angle; + } + else + { + return angle + 2 * Math.PI; + } +}; + +module.exports = Normalize; + + +/***/ }), +/* 221 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); /** * @classdesc * [description] * - * @class TouchManager - * @memberOf Phaser.Input.Touch + * @class TextFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * - * @param {Phaser.Input.InputManager} inputManager - [description] + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {XHRSettingsObject} xhrSettings - [description] */ -var TouchManager = new Class({ +var TextFile = new Class({ + + Extends: File, initialize: - function TouchManager (inputManager) + function TextFile (key, url, path, xhrSettings) { - /** - * [description] - * - * @name Phaser.Input.Touch.TouchManager#manager - * @type {Phaser.Input.InputManager} - * @since 3.0.0 - */ - this.manager = inputManager; + var fileConfig = { + type: 'text', + extension: 'txt', + responseType: 'text', + key: key, + url: url, + path: path, + xhrSettings: xhrSettings + }; - /** - * If true the DOM events will have event.preventDefault applied to them, if false they will propagate fully. - * - * @name Phaser.Input.Touch.TouchManager#capture - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.capture = true; - - /** - * [description] - * - * @name Phaser.Input.Touch.TouchManager#enabled - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.enabled = false; - - /** - * [description] - * - * @name Phaser.Input.Touch.TouchManager#target - * @type {null} - * @since 3.0.0 - */ - this.target; - - /** - * [description] - * - * @name Phaser.Input.Touch.TouchManager#handler - * @type {function} - * @since 3.0.0 - */ - this.handler; + File.call(this, fileConfig); }, - /** - * [description] - * - * @method Phaser.Input.Touch.TouchManager#boot - * @since 3.0.0 - */ - boot: function () + onProcess: function (callback) { - var config = this.manager.config; + this.state = CONST.FILE_PROCESSING; - this.enabled = config.inputTouch; - this.target = config.inputTouchEventTarget; - this.capture = config.inputTouchCapture; + this.data = this.xhrLoader.responseText; - if (!this.target) - { - this.target = this.manager.game.canvas; - } + this.onComplete(); - if (this.enabled) - { - this.startListeners(); - } - }, - - /** - * [description] - * - * @method Phaser.Input.Touch.TouchManager#startListeners - * @since 3.0.0 - */ - startListeners: function () - { - var queue = this.manager.queue; - var target = this.target; - - var passive = { passive: true }; - var nonPassive = { passive: false }; - - var handler; - - if (this.capture) - { - handler = function (event) - { - if (event.defaultPrevented) - { - // Do nothing if event already handled - return; - } - - // console.log('touch', event); - - queue.push(event); - - event.preventDefault(); - }; - - target.addEventListener('touchstart', handler, nonPassive); - target.addEventListener('touchmove', handler, nonPassive); - target.addEventListener('touchend', handler, nonPassive); - } - else - { - handler = function (event) - { - if (event.defaultPrevented) - { - // Do nothing if event already handled - return; - } - - queue.push(event); - }; - - target.addEventListener('touchstart', handler, passive); - target.addEventListener('touchmove', handler, passive); - target.addEventListener('touchend', handler, passive); - } - - this.handler = handler; - }, - - /** - * [description] - * - * @method Phaser.Input.Touch.TouchManager#stopListeners - * @since 3.0.0 - */ - stopListeners: function () - { - var target = this.target; - - target.removeEventListener('touchstart', this.handler); - target.removeEventListener('touchmove', this.handler); - target.removeEventListener('touchend', this.handler); - }, - - /** - * [description] - * - * @method Phaser.Input.Touch.TouchManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.stopListeners(); - - this.manager = null; + callback(this); } }); -module.exports = TouchManager; +/** + * Adds a Text file to the current load queue. + * + * Note: This method will only be available if the Text File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#text + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('text', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new TextFile(key[i], url, this.path, xhrSettings)); + } + } + else + { + this.addFile(new TextFile(key, url, this.path, xhrSettings)); + } + + // For method chaining + return this; +}); + +module.exports = TextFile; + + +/***/ }), +/* 222 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Create an array representing the range of numbers (usually integers), between, and inclusive of, + * the given `start` and `end` arguments. For example: + * + * `var array = numberArray(2, 4); // array = [2, 3, 4]` + * `var array = numberArray(0, 9); // array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]` + * + * This is equivalent to `numberArrayStep(start, end, 1)`. + * + * You can optionally provide a prefix and / or suffix string. If given the array will contain + * strings, not integers. For example: + * + * `var array = numberArray(1, 4, 'Level '); // array = ["Level 1", "Level 2", "Level 3", "Level 4"]` + * `var array = numberArray(5, 7, 'HD-', '.png'); // array = ["HD-5.png", "HD-6.png", "HD-7.png"]` + * + * @function Phaser.Utils.Array.NumberArray + * @since 3.0.0 + * + * @param {number} start - The minimum value the array starts with. + * @param {number} end - The maximum value the array contains. + * @param {string} [prefix] - Optional prefix to place before the number. If provided the array will contain strings, not integers. + * @param {string} [suffix] - Optional suffix to place after the number. If provided the array will contain strings, not integers. + * + * @return {(number[]|string[])} The array of number values, or strings if a prefix or suffix was provided. + */ +var NumberArray = function (start, end, prefix, suffix) +{ + var result = []; + + for (var i = start; i <= end; i++) + { + if (prefix || suffix) + { + var key = (prefix) ? prefix + i.toString() : i.toString(); + + if (suffix) + { + key = key.concat(suffix); + } + + result.push(key); + } + else + { + result.push(i); + } + } + + return result; +}; + +module.exports = NumberArray; + + +/***/ }), +/* 223 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var ParseXML = __webpack_require__(306); + +/** + * @classdesc + * [description] + * + * @class XMLFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + */ +var XMLFile = new Class({ + + Extends: File, + + initialize: + + function XMLFile (key, url, path, xhrSettings) + { + var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); + + var fileConfig = { + type: 'xml', + extension: GetFastValue(key, 'extension', 'xml'), + responseType: 'text', + key: fileKey, + url: GetFastValue(key, 'file', url), + path: path, + xhrSettings: GetFastValue(key, 'xhr', xhrSettings) + }; + + File.call(this, fileConfig); + }, + + onProcess: function (callback) + { + this.state = CONST.FILE_PROCESSING; + + this.data = ParseXML(this.xhrLoader.responseText); + + if (this.data === null) + { + throw new Error('XMLFile: Invalid XML'); + } + + this.onComplete(); + + callback(this); + } + +}); + +/** + * Adds an XML file to the current load queue. + * + * Note: This method will only be available if the XML File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#xml + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('xml', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new XMLFile(key[i], url, this.path, xhrSettings)); + } + } + else + { + this.addFile(new XMLFile(key, url, this.path, xhrSettings)); + } + + // For method chaining + return this; +}); + +module.exports = XMLFile; + + +/***/ }), +/* 224 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var File = __webpack_require__(19); +var GetFastValue = __webpack_require__(2); +var GetURL = __webpack_require__(122); + +/** + * @classdesc + * [description] + * + * @class HTML5AudioFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {Phaser.Loader.XHRSettingsConfig} config - [description] + * @param {boolean} locked - [description] + */ +var HTML5AudioFile = new Class({ + + Extends: File, + + initialize: + + function HTML5AudioFile (key, url, path, config, locked) + { + this.locked = locked; + + this.loaded = false; + + var fileConfig = { + type: 'audio', + extension: GetFastValue(url, 'type', ''), + key: key, + url: GetFastValue(url, 'uri', url), + path: path, + config: config + }; + + File.call(this, fileConfig); + }, + + onLoad: function () + { + if(this.loaded) + { + return; + } + + this.loaded = true; + + this.loader.nextFile(this, true); + }, + + onError: function () + { + for (var i = 0; i < this.data.length; i++) + { + var audio = this.data[i]; + audio.oncanplaythrough = null; + audio.onerror = null; + } + + this.loader.nextFile(this, false); + }, + + onProgress: function (event) + { + var audio = event.target; + audio.oncanplaythrough = null; + audio.onerror = null; + + this.filesLoaded++; + + this.percentComplete = Math.min((this.filesLoaded / this.filesTotal), 1); + + this.loader.emit('fileprogress', this, this.percentComplete); + + if(this.filesLoaded === this.filesTotal) + { + this.onLoad(); + } + }, + + // Called by the Loader, starts the actual file downloading + load: function (loader) + { + this.loader = loader; + + this.data = []; + + var instances = (this.config && this.config.instances) || 1; + + this.filesTotal = instances; + this.filesLoaded = 0; + this.percentComplete = 0; + + for(var i = 0; i < instances; i++) + { + var audio = new Audio(); + audio.dataset.name = this.key + ('0' + i).slice(-2); // Useful for debugging + audio.dataset.used = 'false'; + + if (!this.locked) + { + audio.preload = 'auto'; + audio.oncanplaythrough = this.onProgress.bind(this); + audio.onerror = this.onError.bind(this); + } + + this.data.push(audio); + } + + for (i = 0; i < this.data.length; i++) + { + audio = this.data[i]; + audio.src = GetURL(this, loader.baseURL); + + if (!this.locked) + { + audio.load(); + } + } + + if (this.locked) + { + setTimeout(this.onLoad.bind(this)); + } + } + +}); + +module.exports = HTML5AudioFile; + + +/***/ }), +/* 225 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(21); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var HTML5AudioFile = __webpack_require__(224); + +/** + * @classdesc + * [description] + * + * @class AudioFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * @param {AudioContext} audioContext - [description] + */ +var AudioFile = new Class({ + + Extends: File, + + initialize: + + function AudioFile (key, url, path, xhrSettings, audioContext) + { + /** + * [description] + * + * @property {AudioContext} context + * @since 3.0.0 + */ + this.context = audioContext; + + var fileConfig = { + type: 'audio', + extension: GetFastValue(url, 'type', ''), + responseType: 'arraybuffer', + key: key, + url: GetFastValue(url, 'uri', url), + path: path, + xhrSettings: xhrSettings + }; + + File.call(this, fileConfig); + }, + + /** + * [description] + * + * @method Phaser.Loader.FileTypes.AudioFile#onProcess + * @since 3.0.0 + * + * @param {FileProcessCallback} callback - [description] + */ + onProcess: function (callback) + { + this.state = CONST.FILE_PROCESSING; + + var _this = this; + + // interesting read https://github.com/WebAudio/web-audio-api/issues/1305 + this.context.decodeAudioData(this.xhrLoader.response, + function (audioBuffer) + { + _this.data = audioBuffer; + + _this.onComplete(); + + callback(_this); + }, + function (e) + { + // eslint-disable-next-line no-console + console.error('Error with decoding audio data for \'' + this.key + '\':', e.message); + + _this.state = CONST.FILE_ERRORED; + + callback(_this); + } + ); + + this.context = null; + } + +}); + +AudioFile.create = function (loader, key, urls, config, xhrSettings) +{ + var game = loader.systems.game; + var audioConfig = game.config.audio; + var deviceAudio = game.device.audio; + + if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) + { + // console.info('Skipping loading audio \'' + key + '\' since sounds are disabled.'); + return null; + } + + var url = AudioFile.findAudioURL(game, urls); + + if (!url) + { + // console.warn('No supported url provided for audio \'' + key + '\'!'); + return null; + } + + if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio)) + { + return new AudioFile(key, url, loader.path, xhrSettings, game.sound.context); + } + else + { + return new HTML5AudioFile(key, url, loader.path, config, game.sound.locked); + } +}; + +/** + * Adds an Audio file to the current load queue. + * + * Note: This method will only be available if the Audio File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#audio + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {(string|string[])} urls - [description] + * @param {object} config - [description] + * @param {object} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('audio', function (key, urls, config, xhrSettings) +{ + var audioFile = AudioFile.create(this, key, urls, config, xhrSettings); + + if (audioFile) + { + this.addFile(audioFile); + } + + return this; +}); + +// this.load.audio('sound', 'assets/audio/booom.ogg', config, xhrSettings); +// +// this.load.audio('sound', +// [ +// 'assets/audio/booom.ogg', +// 'assets/audio/booom.m4a', +// 'assets/audio/booom.mp3' +// ], +// config, xhrSettings); +// +// this.load.audio('sound', +// { +// uri: 'assets/audio/boooooom', +// type: 'ogg' +// }, +// config, xhrSettings); +// +// this.load.audio('sound', +// [ +// { +// uri: 'assets/audio/booooooo', +// type: 'ogg' +// }, +// { +// uri: 'assets/audio/boooooom', +// type: 'mp3' +// } +// ], +// config, xhrSettings); +// +// this.load.audio('sound', +// [ +// { +// uri: 'assets/audio/booooooo', +// type: 'ogg' +// }, +// 'assets/audio/booom.m4a', +// { +// uri: 'assets/audio/boooooom', +// type: 'mp3' +// } +// ], +// config, xhrSettings); + +AudioFile.findAudioURL = function (game, urls) +{ + if (urls.constructor !== Array) + { + urls = [ urls ]; + } + + for (var i = 0; i < urls.length; i++) + { + var url = GetFastValue(urls[i], 'uri', urls[i]); + + if (url.indexOf('blob:') === 0 || url.indexOf('data:') === 0) + { + return url; + } + + var audioType = url.match(/\.([a-zA-Z0-9]+)($|\?)/); + + audioType = GetFastValue(urls[i], 'type', (audioType) ? audioType[1] : '').toLowerCase(); + + if (game.device.audio[audioType]) + { + return { + uri: url, + type: audioType + }; + } + } + + return null; +}; + +module.exports = AudioFile; + + +/***/ }), +/* 226 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MergeXHRSettings = __webpack_require__(121); + +/** + * Creates a new XMLHttpRequest (xhr) object based on the given File and XHRSettings + * and starts the download of it. It uses the Files own XHRSettings and merges them + * with the global XHRSettings object to set the xhr values before download. + * + * @function Phaser.Loader.XHRLoader + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - The File to download. + * @param {XHRSettingsObject} globalXHRSettings - The global XHRSettings object. + * + * @return {XMLHttpRequest} The XHR object. + */ +var XHRLoader = function (file, globalXHRSettings) +{ + var config = MergeXHRSettings(globalXHRSettings, file.xhrSettings); + + var xhr = new XMLHttpRequest(); + + xhr.open('GET', file.src, config.async, config.user, config.password); + + xhr.responseType = file.xhrSettings.responseType; + xhr.timeout = config.timeout; + + if (config.header && config.headerValue) + { + xhr.setRequestHeader(config.header, config.headerValue); + } + + if (config.overrideMimeType) + { + xhr.overrideMimeType(config.overrideMimeType); + } + + // After a successful request, the xhr.response property will contain the requested data as a DOMString, ArrayBuffer, Blob, or Document (depending on what was set for responseType.) + + xhr.onload = file.onLoad.bind(file); + xhr.onerror = file.onError.bind(file); + xhr.onprogress = file.onProgress.bind(file); + + // This is the only standard method, the ones above are browser additions (maybe not universal?) + // xhr.onreadystatechange + + xhr.send(); + + return xhr; +}; + +module.exports = XHRLoader; + + +/***/ }), +/* 227 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Phaser.Input.InteractiveObject + +/** + * @callback HitAreaCallback + * + * @param {*} hitArea - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * + * @return {boolean} [description] + */ + +/** + * @typedef {object} InteractiveObject + * + * @property {Phaser.GameObjects.GameObject} gameObject - [description] + * @property {boolean} enabled - [description] + * @property {boolean} draggable - [description] + * @property {boolean} dropZone - [description] + * @property {[type]} target - [description] + * @property {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @property {*} hitArea - [description] + * @property {HitAreaCallback} hitAreaCallback - [description] + * @property {number} localX - [description] + * @property {number} localY - [description] + * @property {(0|1|2)} dragState - [description] + * @property {number} dragStartX - [description] + * @property {number} dragStartY - [description] + * @property {number} dragX - [description] + * @property {number} dragY - [description] + */ + +/** + * [description] + * + * @method Phaser.Input.Pointer#positionToCamera + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * @param {*} hitArea - [description] + * @param {HitAreaCallback} hitAreaCallback - [description] + * + * @return {InteractiveObject} [description] + */ +var InteractiveObject = function (gameObject, hitArea, hitAreaCallback) +{ + return { + + gameObject: gameObject, + + enabled: true, + draggable: false, + dropZone: false, + + target: null, + + camera: null, + + hitArea: hitArea, + hitAreaCallback: hitAreaCallback, + + localX: 0, + localY: 0, + + // 0 = Not being dragged + // 1 = Being checked for dragging + // 2 = Being dragged + dragState: 0, + + dragStartX: 0, + dragStartY: 0, + + dragX: 0, + dragY: 0 + + }; +}; + +module.exports = InteractiveObject; + + +/***/ }), +/* 228 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +// The three angle bisectors of a triangle meet in one point called the incenter. +// It is the center of the incircle, the circle inscribed in the triangle. + +function getLength (x1, y1, x2, y2) +{ + var x = x1 - x2; + var y = y1 - y2; + var magnitude = (x * x) + (y * y); + + return Math.sqrt(magnitude); +} + +/** + * [description] + * + * @function Phaser.Geom.Triangle.InCenter + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var InCenter = function (triangle, out) +{ + if (out === undefined) { out = new Point(); } + + var x1 = triangle.x1; + var y1 = triangle.y1; + + var x2 = triangle.x2; + var y2 = triangle.y2; + + var x3 = triangle.x3; + var y3 = triangle.y3; + + var d1 = getLength(x3, y3, x2, y2); + var d2 = getLength(x1, y1, x3, y3); + var d3 = getLength(x2, y2, x1, y1); + + var p = d1 + d2 + d3; + + out.x = (x1 * d1 + x2 * d2 + x3 * d3) / p; + out.y = (y1 * d1 + y2 * d2 + y3 * d3) / p; + + return out; +}; + +module.exports = InCenter; + + +/***/ }), +/* 229 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Offset + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Geom.Triangle} [description] + */ +var Offset = function (triangle, x, y) +{ + triangle.x1 += x; + triangle.y1 += y; + + triangle.x2 += x; + triangle.y2 += y; + + triangle.x3 += x; + triangle.y3 += y; + + return triangle; +}; + +module.exports = Offset; + + +/***/ }), +/* 230 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +// The three medians (the lines drawn from the vertices to the bisectors of the opposite sides) +// meet in the centroid or center of mass (center of gravity). +// The centroid divides each median in a ratio of 2:1 + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Centroid + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ +var Centroid = function (triangle, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = (triangle.x1 + triangle.x2 + triangle.x3) / 3; + out.y = (triangle.y1 + triangle.y2 + triangle.y3) / 3; + + return out; +}; + +module.exports = Centroid; + + +/***/ }), +/* 231 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Length = __webpack_require__(77); +var Point = __webpack_require__(4); + +/** + * [description] + * + * @function Phaser.Geom.Triangle.GetPoints + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {integer} quantity - [description] + * @param {number} stepRate - [description] + * @param {(array|Phaser.Geom.Point[])} out - [description] + * + * @return {(array|Phaser.Geom.Point[])} [description] + */ +var GetPoints = function (triangle, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + var line1 = triangle.getLineA(); + var line2 = triangle.getLineB(); + var line3 = triangle.getLineC(); + + var length1 = Length(line1); + var length2 = Length(line2); + var length3 = Length(line3); + + var perimeter = length1 + length2 + length3; + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) + { + quantity = perimeter / stepRate; + } + + for (var i = 0; i < quantity; i++) + { + var p = perimeter * (i / quantity); + var localPosition = 0; + + var point = new Point(); + + // Which line is it on? + + if (p < length1) + { + // Line 1 + localPosition = p / length1; + + point.x = line1.x1 + (line1.x2 - line1.x1) * localPosition; + point.y = line1.y1 + (line1.y2 - line1.y1) * localPosition; + } + else if (p > length1 + length2) + { + // Line 3 + p -= length1 + length2; + localPosition = p / length3; + + point.x = line3.x1 + (line3.x2 - line3.x1) * localPosition; + point.y = line3.y1 + (line3.y2 - line3.y1) * localPosition; + } + else + { + // Line 2 + p -= length1; + localPosition = p / length2; + + point.x = line2.x1 + (line2.x2 - line2.x1) * localPosition; + point.y = line2.y1 + (line2.y2 - line2.y1) * localPosition; + } + + out.push(point); + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }), +/* 232 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); +var Length = __webpack_require__(77); + +// Position is a value between 0 and 1 +/** + * [description] + * + * @function Phaser.Geom.Triangle.GetPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {float} position - [description] + * @param {(Phaser.Geom.Point|object)} out - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ +var GetPoint = function (triangle, position, out) +{ + if (out === undefined) { out = new Point(); } + + var line1 = triangle.getLineA(); + var line2 = triangle.getLineB(); + var line3 = triangle.getLineC(); + + if (position <= 0 || position >= 1) + { + out.x = line1.x1; + out.y = line1.y1; + + return out; + } + + var length1 = Length(line1); + var length2 = Length(line2); + var length3 = Length(line3); + + var perimeter = length1 + length2 + length3; + + var p = perimeter * position; + var localPosition = 0; + + // Which line is it on? + + if (p < length1) + { + // Line 1 + localPosition = p / length1; + + out.x = line1.x1 + (line1.x2 - line1.x1) * localPosition; + out.y = line1.y1 + (line1.y2 - line1.y1) * localPosition; + } + else if (p > length1 + length2) + { + // Line 3 + p -= length1 + length2; + localPosition = p / length3; + + out.x = line3.x1 + (line3.x2 - line3.x1) * localPosition; + out.y = line3.y1 + (line3.y2 - line3.y1) * localPosition; + } + else + { + // Line 2 + p -= length1; + localPosition = p / length2; + + out.x = line2.x1 + (line2.x2 - line2.x1) * localPosition; + out.y = line2.y1 + (line2.y2 - line2.y1) * localPosition; + } + + return out; +}; + +module.exports = GetPoint; + + +/***/ }), +/* 233 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Centers this Rectangle so that the center coordinates match the given x and y values. + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.CenterOn + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var CenterOn = function (rect, x, y) +{ + rect.x = x - (rect.width / 2); + rect.y = y - (rect.height / 2); + + return rect; +}; + +module.exports = CenterOn; + + +/***/ }), +/* 234 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(10); + +Rectangle.Area = __webpack_require__(605); +Rectangle.Ceil = __webpack_require__(604); +Rectangle.CeilAll = __webpack_require__(603); +Rectangle.CenterOn = __webpack_require__(233); +Rectangle.Clone = __webpack_require__(602); +Rectangle.Contains = __webpack_require__(27); +Rectangle.ContainsPoint = __webpack_require__(601); +Rectangle.ContainsRect = __webpack_require__(600); +Rectangle.CopyFrom = __webpack_require__(599); +Rectangle.Decompose = __webpack_require__(240); +Rectangle.Equals = __webpack_require__(598); +Rectangle.FitInside = __webpack_require__(597); +Rectangle.FitOutside = __webpack_require__(596); +Rectangle.Floor = __webpack_require__(595); +Rectangle.FloorAll = __webpack_require__(594); +Rectangle.FromPoints = __webpack_require__(150); +Rectangle.GetAspectRatio = __webpack_require__(124); +Rectangle.GetCenter = __webpack_require__(593); +Rectangle.GetPoint = __webpack_require__(166); +Rectangle.GetPoints = __webpack_require__(352); +Rectangle.GetSize = __webpack_require__(592); +Rectangle.Inflate = __webpack_require__(591); +Rectangle.MarchingAnts = __webpack_require__(347); +Rectangle.MergePoints = __webpack_require__(590); +Rectangle.MergeRect = __webpack_require__(589); +Rectangle.MergeXY = __webpack_require__(588); +Rectangle.Offset = __webpack_require__(587); +Rectangle.OffsetPoint = __webpack_require__(586); +Rectangle.Overlaps = __webpack_require__(585); +Rectangle.Perimeter = __webpack_require__(105); +Rectangle.PerimeterPoint = __webpack_require__(584); +Rectangle.Random = __webpack_require__(163); +Rectangle.Scale = __webpack_require__(583); +Rectangle.Union = __webpack_require__(582); + +module.exports = Rectangle; + + +/***/ }), +/* 235 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Contains = __webpack_require__(125); + +/** + * @classdesc + * [description] + * + * @class Polygon + * @memberOf Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Geom.Point[]} [points] - [description] + */ +var Polygon = new Class({ + + initialize: + + function Polygon (points) + { + /** + * The area of this Polygon. + * + * @name Phaser.Geom.Polygon#area + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.area = 0; + + /** + * An array of number pair objects that make up this polygon. I.e. [ {x,y}, {x,y}, {x,y} ] + * + * @name Phaser.Geom.Polygon#points + * @type {Phaser.Geom.Point[]} + * @since 3.0.0 + */ + this.points = []; + + if (points) + { + this.setTo(points); + } + }, + + /** + * [description] + * + * @method Phaser.Geom.Polygon#contains + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ + contains: function (x, y) + { + return Contains(this, x, y); + }, + + /** + * Sets this Polygon to the given points. + * + * The points can be set from a variety of formats: + * + * - An array of Point objects: `[new Phaser.Point(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * + * `setTo` may also be called without any arguments to remove all points. + * + * @method Phaser.Geom.Polygon#setTo + * @since 3.0.0 + * + * @param {array} points - [description] + * + * @return {Phaser.Geom.Polygon} This Polygon object. + */ + setTo: function (points) + { + this.area = 0; + this.points = []; + + if (!Array.isArray(points)) + { + return this; + } + + var entry; + var y0 = Number.MAX_VALUE; + var p; + + // The points argument is an array, so iterate through it + for (var i = 0; i < points.length; i++) + { + p = { x: 0, y: 0 }; + + if (typeof points[i] === 'number') + { + p.x = points[i]; + p.y = points[i + 1]; + i++; + } + else if (Array.isArray(entry)) + { + // An array of arrays? + p.x = points[i][0]; + p.y = points[i][1]; + } + else + { + p.x = points[i].x; + p.y = points[i].y; + } + + this.points.push(p); + + // Lowest boundary + if (p.y < y0) + { + y0 = p.y; + } + } + + this.calculateArea(y0); + + return this; + }, + + /** + * Calculates the area of the Polygon. This is available in the property Polygon.area + * + * @method Phaser.Geom.Polygon#calculateArea + * @since 3.0.0 + * + * @return {number} [description] + */ + calculateArea: function () + { + if (this.points.length < 3) + { + this.area = 0; + + return this.area; + } + + var sum = 0; + var p1; + var p2; + + for (var i = 0; i < this.points.length - 1; i++) + { + p1 = this.points[i]; + p2 = this.points[i + 1]; + + sum += (p2.x - p1.x) * (p1.y + p2.y); + } + + p1 = this.points[0]; + p2 = this.points[this.points.length - 1]; + + sum += (p1.x - p2.x) * (p2.y + p1.y); + + this.area = -sum * 0.5; + + return this.area; + } + +}); + +module.exports = Polygon; + + +/***/ }), +/* 236 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Point.GetMagnitudeSq + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * + * @return {number} [description] + */ +var GetMagnitudeSq = function (point) +{ + return (point.x * point.x) + (point.y * point.y); +}; + +module.exports = GetMagnitudeSq; + + +/***/ }), +/* 237 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Point.GetMagnitude + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * + * @return {number} [description] + */ +var GetMagnitude = function (point) +{ + return Math.sqrt((point.x * point.x) + (point.y * point.y)); +}; + +module.exports = GetMagnitude; + + +/***/ }), +/* 238 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(16); +var Wrap = __webpack_require__(43); +var Angle = __webpack_require__(53); + +/** + * [description] + * + * @function Phaser.Geom.Line.NormalAngle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * + * @return {number} [description] + */ +var NormalAngle = function (line) +{ + var angle = Angle(line) - MATH_CONST.TAU; + + return Wrap(angle, -Math.PI, Math.PI); +}; + +module.exports = NormalAngle; + + +/***/ }), +/* 239 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Decompose + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {array} [out] - [description] + * + * @return {array} [description] + */ +var Decompose = function (triangle, out) +{ + if (out === undefined) { out = []; } + + out.push({ x: triangle.x1, y: triangle.y1 }); + out.push({ x: triangle.x2, y: triangle.y2 }); + out.push({ x: triangle.x3, y: triangle.y3 }); + + return out; +}; + +module.exports = Decompose; + + +/***/ }), +/* 240 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Decompose + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {array} [out] - [description] + * + * @return {array} [description] + */ +var Decompose = function (rect, out) +{ + if (out === undefined) { out = []; } + + out.push({ x: rect.x, y: rect.y }); + out.push({ x: rect.right, y: rect.y }); + out.push({ x: rect.right, y: rect.bottom }); + out.push({ x: rect.x, y: rect.bottom }); + + return out; +}; + +module.exports = Decompose; + + +/***/ }), +/* 241 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Intersects.PointToLine + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * @param {Phaser.Geom.Line} line - [description] + * + * @return {boolean} [description] + */ +var PointToLine = function (point, line) +{ + return ((point.x - line.x1) * (line.y2 - line.y1) === (line.x2 - line.x1) * (point.y - line.y1)); +}; + +module.exports = PointToLine; + + +/***/ }), +/* 242 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on code by Matt DesLauriers +// https://github.com/mattdesl/line-circle-collision/blob/master/LICENSE.md + +var Contains = __webpack_require__(28); +var Point = __webpack_require__(4); + +var tmp = new Point(); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.LineToCircle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {Phaser.Geom.Circle} circle - [description] + * @param {Phaser.Geom.Point} [nearest] - [description] + * + * @return {boolean} [description] + */ +var LineToCircle = function (line, circle, nearest) +{ + if (nearest === undefined) { nearest = tmp; } + + if (Contains(circle, line.x1, line.y1)) + { + nearest.x = line.x1; + nearest.y = line.y1; + + return true; + } + + if (Contains(circle, line.x2, line.y2)) + { + nearest.x = line.x2; + nearest.y = line.y2; + + return true; + } + + var dx = line.x2 - line.x1; + var dy = line.y2 - line.y1; + + var lcx = circle.x - line.x1; + var lcy = circle.y - line.y1; + + // project lc onto d, resulting in vector p + var dLen2 = (dx * dx) + (dy * dy); + var px = dx; + var py = dy; + + if (dLen2 > 0) + { + var dp = ((lcx * dx) + (lcy * dy)) / dLen2; + + px *= dp; + py *= dp; + } + + nearest.x = line.x1 + px; + nearest.y = line.y1 + py; + + // len2 of p + var pLen2 = (px * px) + (py * py); + + return ( + pLen2 <= dLen2 && + ((px * dx) + (py * dy)) >= 0 && + Contains(circle, nearest.x, nearest.y) + ); +}; + +module.exports = LineToCircle; + + +/***/ }), +/* 243 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Intersects.RectangleToRectangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rectA - [description] + * @param {Phaser.Geom.Rectangle} rectB - [description] + * + * @return {boolean} [description] + */ +var RectangleToRectangle = function (rectA, rectB) +{ + if (rectA.width <= 0 || rectA.height <= 0 || rectB.width <= 0 || rectB.height <= 0) + { + return false; + } + + return !(rectA.right < rectB.x || rectA.bottom < rectB.y || rectA.x > rectB.right || rectA.y > rectB.bottom); +}; + +module.exports = RectangleToRectangle; + + +/***/ }), +/* 244 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Geom.Intersects + */ + +module.exports = { + + CircleToCircle: __webpack_require__(652), + CircleToRectangle: __webpack_require__(651), + GetRectangleIntersection: __webpack_require__(650), + LineToCircle: __webpack_require__(242), + LineToLine: __webpack_require__(95), + LineToRectangle: __webpack_require__(649), + PointToLine: __webpack_require__(241), + PointToLineSegment: __webpack_require__(648), + RectangleToRectangle: __webpack_require__(243), + RectangleToTriangle: __webpack_require__(647), + RectangleToValues: __webpack_require__(646), + TriangleToCircle: __webpack_require__(645), + TriangleToLine: __webpack_require__(644), + TriangleToTriangle: __webpack_require__(643) + +}; + + +/***/ }), +/* 245 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Geom + */ + +module.exports = { + + Circle: __webpack_require__(662), + Ellipse: __webpack_require__(269), + Intersects: __webpack_require__(244), + Line: __webpack_require__(642), + Point: __webpack_require__(624), + Polygon: __webpack_require__(610), + Rectangle: __webpack_require__(234), + Triangle: __webpack_require__(581) + +}; + + +/***/ }), +/* 246 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Light = __webpack_require__(247); +var LightPipeline = __webpack_require__(173); +var Utils = __webpack_require__(44); + +/** + * @callback LightForEach + * + * @param {Phaser.GameObjects.Light} light - [description] + */ + +/** + * @classdesc + * [description] + * + * @class LightsManager + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + */ +var LightsManager = new Class({ + + initialize: + + function LightsManager () + { + /** + * [description] + * + * @name Phaser.GameObjects.LightsManager#lightPool + * @type {Phaser.GameObjects.Light[]} + * @default [] + * @since 3.0.0 + */ + this.lightPool = []; + + /** + * [description] + * + * @name Phaser.GameObjects.LightsManager#lights + * @type {Phaser.GameObjects.Light[]} + * @default [] + * @since 3.0.0 + */ + this.lights = []; + + /** + * [description] + * + * @name Phaser.GameObjects.LightsManager#culledLights + * @type {Phaser.GameObjects.Light[]} + * @default [] + * @since 3.0.0 + */ + this.culledLights = []; + + /** + * [description] + * + * @name Phaser.GameObjects.LightsManager#ambientColor + * @type {{ r: float, g: float, b: float }} + * @since 3.0.0 + */ + this.ambientColor = { r: 0.1, g: 0.1, b: 0.1 }; + + /** + * [description] + * + * @name Phaser.GameObjects.LightsManager#active + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.active = false; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsManager#enable + * @since 3.0.0 + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + enable: function () + { + this.active = true; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsManager#disable + * @since 3.0.0 + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + disable: function () + { + this.active = false; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsManager#cull + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + * @return {Phaser.GameObjects.Light[]} [description] + */ + cull: function (camera) + { + var lights = this.lights; + var culledLights = this.culledLights; + var length = lights.length; + var cameraCenterX = camera.x + camera.width / 2.0; + var cameraCenterY = camera.y + camera.height / 2.0; + var cameraRadius = (camera.width + camera.height) / 2.0; + var point = { x: 0, y: 0 }; + var cameraMatrix = camera.matrix; + var viewportHeight = this.systems.game.config.height; + + culledLights.length = 0; + + for (var index = 0; index < length && culledLights.length < LightPipeline.LIGHT_COUNT; ++index) + { + var light = lights[index]; + + cameraMatrix.transformPoint(light.x, light.y, point); + + // We'll just use bounding spheres to test + // if lights should be rendered + var dx = cameraCenterX - (point.x - (camera.scrollX * light.scrollFactorX * camera.zoom)); + var dy = cameraCenterY - (viewportHeight - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom)); + var distance = Math.sqrt(dx * dx + dy * dy); + + if (distance < light.radius + cameraRadius) + { + culledLights.push(lights[index]); + } + } + + return culledLights; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsManager#forEachLight + * @since 3.0.0 + * + * @param {LightForEach} callback - [description] + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + forEachLight: function (callback) + { + if (!callback) + { + return; + } + + var lights = this.lights; + var length = lights.length; + + for (var index = 0; index < length; ++index) + { + callback(lights[index]); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsManager#setAmbientColor + * @since 3.0.0 + * + * @param {number} rgb - [description] + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + setAmbientColor: function (rgb) + { + var color = Utils.getFloatsFromUintRGB(rgb); + + this.ambientColor.r = color[0]; + this.ambientColor.g = color[1]; + this.ambientColor.b = color[2]; + + return this; + }, + + /** + * Returns the maximum number of Lights allowed to appear at once. + * + * @method Phaser.GameObjects.LightsManager#getMaxVisibleLights + * @since 3.0.0 + * + * @return {integer} [description] + */ + getMaxVisibleLights: function () + { + return 10; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsManager#getLightCount + * @since 3.0.0 + * + * @return {integer} [description] + */ + getLightCount: function () + { + return this.lights.length; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsManager#addLight + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} radius - [description] + * @param {number} rgb - [description] + * @param {number} intensity - [description] + * + * @return {Phaser.GameObjects.Light} [description] + */ + addLight: function (x, y, radius, rgb, intensity) + { + var color = null; + var light = null; + + x = (x === undefined) ? 0.0 : x; + y = (y === undefined) ? 0.0 : y; + rgb = (rgb === undefined) ? 0xffffff : rgb; + radius = (radius === undefined) ? 100.0 : radius; + intensity = (intensity === undefined) ? 1.0 : intensity; + + color = Utils.getFloatsFromUintRGB(rgb); + light = null; + + if (this.lightPool.length > 0) + { + light = this.lightPool.pop(); + light.set(x, y, radius, color[0], color[1], color[2], intensity); + } + else + { + light = new Light(x, y, radius, color[0], color[1], color[2], intensity); + } + + this.lights.push(light); + + return light; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsManager#removeLight + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Light} light - [description] + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + removeLight: function (light) + { + var index = this.lights.indexOf(light); + + if (index >= 0) + { + this.lightPool.push(light); + this.lights.splice(index, 1); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsManager#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + while (this.lights.length > 0) + { + this.lightPool.push(this.lights.pop()); + } + + this.ambientColor = { r: 0.1, g: 0.1, b: 0.1 }; + this.culledLights.length = 0; + this.lights.length = 0; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + } + +}); + +module.exports = LightsManager; + + +/***/ }), +/* 247 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Utils = __webpack_require__(44); + +/** + * @classdesc + * [description] + * + * @class Light + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {number} x - The horizontal position of the light. + * @param {number} y - The vertical position of the light. + * @param {number} radius - The radius of the light. + * @param {number} r - The red color. A value between 0 and 1. + * @param {number} g - The green color. A value between 0 and 1. + * @param {number} b - The blue color. A value between 0 and 1. + * @param {number} intensity - The intensity of the light. + */ +var Light = new Class({ + + initialize: + + function Light (x, y, radius, r, g, b, intensity) + { + /** + * [description] + * + * @name Phaser.GameObjects.Light#x + * @type {number} + * @since 3.0.0 + */ + this.x = x; + + /** + * [description] + * + * @name Phaser.GameObjects.Light#y + * @type {number} + * @since 3.0.0 + */ + this.y = y; + + /** + * [description] + * + * @name Phaser.GameObjects.Light#radius + * @type {number} + * @since 3.0.0 + */ + this.radius = radius; + + /** + * [description] + * + * @name Phaser.GameObjects.Light#r + * @type {number} + * @since 3.0.0 + */ + this.r = r; + + /** + * [description] + * + * @name Phaser.GameObjects.Light#g + * @type {number} + * @since 3.0.0 + */ + this.g = g; + + /** + * [description] + * + * @name Phaser.GameObjects.Light#b + * @type {number} + * @since 3.0.0 + */ + this.b = b; + + /** + * [description] + * + * @name Phaser.GameObjects.Light#intensity + * @type {number} + * @since 3.0.0 + */ + this.intensity = intensity; + + /** + * [description] + * + * @name Phaser.GameObjects.Light#scrollFactorX + * @type {number} + * @since 3.0.0 + */ + this.scrollFactorX = 1.0; + + /** + * [description] + * + * @name Phaser.GameObjects.Light#scrollFactorY + * @type {number} + * @since 3.0.0 + */ + this.scrollFactorY = 1.0; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Light#set + * @since 3.0.0 + * + * @param {number} x - The horizontal position of the light. + * @param {number} y - The vertical position of the light. + * @param {number} radius - The radius of the light. + * @param {number} r - The red color. A value between 0 and 1. + * @param {number} g - The green color. A value between 0 and 1. + * @param {number} b - The blue color. A value between 0 and 1. + * @param {number} intensity - The intensity of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + set: function (x, y, radius, r, g, b, intensity) + { + this.x = x; + this.y = y; + + this.radius = radius; + + this.r = r; + this.g = g; + this.b = b; + + this.intensity = intensity; + + this.scrollFactorX = 1; + this.scrollFactorY = 1; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Light#setScrollFactor + * @since 3.0.0 + * + * @param {number} x - The horizontal scroll factor of the light. + * @param {number} y - The vertical scroll factor of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setScrollFactor: function (x, y) + { + if (x === undefined) { x = 1; } + if (y === undefined) { y = x; } + + this.scrollFactorX = x; + this.scrollFactorY = y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Light#setColor + * @since 3.0.0 + * + * @param {number} rgb - [description] + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setColor: function (rgb) + { + var color = Utils.getFloatsFromUintRGB(rgb); + + this.r = color[0]; + this.g = color[1]; + this.b = color[2]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Light#setIntensity + * @since 3.0.0 + * + * @param {number} intensity - [description] + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setIntensity: function (intensity) + { + this.intensity = intensity; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Light#setPosition + * @since 3.0.0 + * + * @param {number} x - The horizontal position of the light. + * @param {number} y - The vertical position of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setPosition: function (x, y) + { + this.x = x; + this.y = y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Light#setRadius + * @since 3.0.0 + * + * @param {number} radius - [description] + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setRadius: function (radius) + { + this.radius = radius; + + return this; + } + +}); + +module.exports = Light; + + +/***/ }), +/* 248 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the nearest power of 2 to the given `value`. + * + * @function Phaser.Math.Pow2.GetPowerOfTwo + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {integer} [description] + */ +var GetPowerOfTwo = function (value) +{ + // Math.log(2) + var index = Math.log(value) / 0.6931471805599453; + + return (1 << Math.ceil(index)); +}; + +module.exports = GetPowerOfTwo; + + +/***/ }), +/* 249 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var DegToRad = __webpack_require__(42); +var GetBoolean = __webpack_require__(69); +var GetValue = __webpack_require__(5); +var Sprite = __webpack_require__(40); +var TWEEN_CONST = __webpack_require__(68); +var Vector2 = __webpack_require__(6); + +/** + * @typedef {object} PathConfig + * + * @property {number} duration - [description] + * @property {number} from - [description] + * @property {number} to - [description] + * @property {boolean} [positionOnPath=false] - [description] + * @property {boolean} [rotateToPath=false] - [description] + * @property {number} [rotationOffset=0] - [description] + * @property {boolean} [verticalAdjust=false] - [description] + */ + +/** + * @classdesc + * A PathFollower Game Object. + * + * A PathFollower is a Sprite Game Object with some extra helpers to allow it to follow a Path automatically. + * + * Anything you can do with a standard Sprite can be done with this PathFollower, such as animate it, tint it, + * scale it and so on. + * + * PathFollowers are bound to a single Path at any one time and can traverse the length of the Path, from start + * to finish, forwards or backwards, or from any given point on the Path to its end. They can optionally rotate + * to face the direction of the path, be offset from the path coordinates or rotate independently of the Path. + * + * @class PathFollower + * @extends Phaser.GameObjects.Sprite + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Curves.Path} path - The Path this PathFollower is following. It can only follow one Path at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var PathFollower = new Class({ + + Extends: Sprite, + + initialize: + + function PathFollower (scene, path, x, y, texture, frame) + { + Sprite.call(this, scene, x, y, texture, frame); + + /** + * The Path this PathFollower is following. It can only follow one Path at a time. + * + * @name Phaser.GameObjects.PathFollower#path + * @type {Phaser.Curves.Path} + * @since 3.0.0 + */ + this.path = path; + + /** + * Should the PathFollower automatically rotate to point in the direction of the Path? + * + * @name Phaser.GameObjects.PathFollower#rotateToPath + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.rotateToPath = false; + + /** + * [description] + * + * @name Phaser.GameObjects.PathFollower#pathRotationVerticalAdjust + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.pathRotationVerticalAdjust = false; + + /** + * If the PathFollower is rotating to match the Path (@see Phaser.GameObjects.PathFollower#rotateToPath) + * this value is added to the rotation value. This allows you to rotate objects to a path but control + * the angle of the rotation as well. + * + * @name Phaser.GameObjects.PathFollower#pathRotationOffset + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.pathRotationOffset = 0; + + /** + * An additional vector to add to the PathFollowers position, allowing you to offset it from the + * Path coordinates. + * + * @name Phaser.GameObjects.PathFollower#pathOffset + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.pathOffset = new Vector2(x, y); + + /** + * [description] + * + * @name Phaser.GameObjects.PathFollower#pathVector + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.pathVector = new Vector2(); + + /** + * [description] + * + * @name Phaser.GameObjects.PathFollower#pathTween + * @type {Phaser.Tweens.Tween} + * @since 3.0.0 + */ + this.pathTween; + + /** + * [description] + * + * @name Phaser.GameObjects.PathFollower#pathConfig + * @type {?PathConfig} + * @default null + * @since 3.0.0 + */ + this.pathConfig = null; + + /** + * Records the direction of the follower so it can change direction. + * + * @name Phaser.GameObjects.PathFollower#_prevDirection + * @type {integer} + * @private + * @since 3.0.0 + */ + this._prevDirection = TWEEN_CONST.PLAYING_FORWARD; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.PathFollower#setPath + * @since 3.0.0 + * + * @param {Phaser.Curves.Path} path - The Path this PathFollower is following. It can only follow one Path at a time. + * @param {PathConfig} [config] - [description] + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + setPath: function (path, config) + { + if (config === undefined) { config = this.pathConfig; } + + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.stop(); + } + + this.path = path; + + if (config) + { + this.start(config); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.PathFollower#setRotateToPath + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} [offset=0] - Rotation offset in degrees. + * @param {boolean} [verticalAdjust=false] - [description] + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + setRotateToPath: function (value, offset, verticalAdjust) + { + if (offset === undefined) { offset = 0; } + if (verticalAdjust === undefined) { verticalAdjust = false; } + + this.rotateToPath = value; + + this.pathRotationOffset = offset; + this.pathRotationVerticalAdjust = verticalAdjust; + + return this; + }, + + /** + * Is this PathFollower actively following a Path or not? + * To be considered as `isFollowing` it must be currently moving on a Path, and not paused. + * + * @method Phaser.GameObjects.PathFollower#isFollowing + * @since 3.0.0 + * + * @return {boolean} `true` is this PathFollower is actively following a Path, otherwise `false`. + */ + isFollowing: function () + { + var tween = this.pathTween; + + return (tween && tween.isPlaying()); + }, + + /** + * Starts this PathFollower following its given Path. + * + * @method Phaser.GameObjects.PathFollower#startFollow + * @since 3.3.0 + * + * @param {(number|PathConfig)} [config={}] - [description] + * @param {number} [startAt=0] - [description] + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + startFollow: function (config, startAt) + { + if (config === undefined) { config = {}; } + if (startAt === undefined) { startAt = 0; } + + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.stop(); + } + + if (typeof config === 'number') + { + config = { duration: config }; + } + + // Override in case they've been specified in the config + config.from = 0; + config.to = 1; + + // Can also read extra values out of the config: + + var positionOnPath = GetBoolean(config, 'positionOnPath', false); + + this.rotateToPath = GetBoolean(config, 'rotateToPath', false); + this.pathRotationOffset = GetValue(config, 'rotationOffset', 0); + this.pathRotationVerticalAdjust = GetBoolean(config, 'verticalAdjust', false); + + this.pathTween = this.scene.sys.tweens.addCounter(config); + + // The starting point of the path, relative to this follower + this.path.getStartPoint(this.pathOffset); + + if (positionOnPath) + { + this.x = this.pathOffset.x; + this.y = this.pathOffset.y; + } + + this.pathOffset.x = this.x - this.pathOffset.x; + this.pathOffset.y = this.y - this.pathOffset.y; + + this._prevDirection = TWEEN_CONST.PLAYING_FORWARD; + + if (this.rotateToPath) + { + // Set the rotation now (in case the tween has a delay on it, etc) + var nextPoint = this.path.getPoint(0.1); + + this.rotation = Math.atan2(nextPoint.y - this.y, nextPoint.x - this.x) + DegToRad(this.pathRotationOffset); + } + + this.pathConfig = config; + + return this; + }, + + /** + * Pauses this PathFollower. It will still continue to render, but it will remain motionless at the + * point on the Path at which you paused it. + * + * @method Phaser.GameObjects.PathFollower#pauseFollow + * @since 3.3.0 + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + pauseFollow: function () + { + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.pause(); + } + + return this; + }, + + /** + * Resumes a previously paused PathFollower. + * If the PathFollower was not paused this has no effect. + * + * @method Phaser.GameObjects.PathFollower#resumeFollow + * @since 3.3.0 + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + resumeFollow: function () + { + var tween = this.pathTween; + + if (tween && tween.isPaused()) + { + tween.resume(); + } + + return this; + }, + + /** + * Stops this PathFollower from following the path any longer. + * This will invoke any 'stop' conditions that may exist on the Path, or for the follower. + * + * @method Phaser.GameObjects.PathFollower#stopFollow + * @since 3.3.0 + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + stopFollow: function () + { + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.stop(); + } + + return this; + }, + + /** + * Internal update handler that advances this PathFollower along the path. + * Called automatically by the Scene step, should not typically be called directly. + * + * @method Phaser.GameObjects.PathFollower#preUpdate + * @protected + * @since 3.0.0 + * + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + preUpdate: function (time, delta) + { + this.anims.update(time, delta); + + var tween = this.pathTween; + + if (tween) + { + var tweenData = tween.data[0]; + + if (tweenData.state !== TWEEN_CONST.PLAYING_FORWARD && tweenData.state !== TWEEN_CONST.PLAYING_BACKWARD) + { + // If delayed, etc then bail out + return; + } + + var pathVector = this.pathVector; + + this.path.getPoint(tween.getValue(), pathVector); + + pathVector.add(this.pathOffset); + + var oldX = this.x; + var oldY = this.y; + + this.setPosition(pathVector.x, pathVector.y); + + var speedX = this.x - oldX; + var speedY = this.y - oldY; + + if (speedX === 0 && speedY === 0) + { + // Bail out early + return; + } + + if (tweenData.state !== this._prevDirection) + { + // We've changed direction, so don't do a rotate this frame + this._prevDirection = tweenData.state; + + return; + } + + if (this.rotateToPath) + { + this.rotation = Math.atan2(speedY, speedX) + DegToRad(this.pathRotationOffset); + + if (this.pathRotationVerticalAdjust) + { + this.flipY = (this.rotation !== 0 && tweenData.state === TWEEN_CONST.PLAYING_BACKWARD); + } + } + } + } + +}); + +module.exports = PathFollower; + + +/***/ }), +/* 250 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Utils.Object.HasAny + * @since 3.0.0 + * + * @param {object} source - [description] + * @param {string[]} keys - [description] + * + * @return {boolean} [description] + */ +var HasAny = function (source, keys) +{ + for (var i = 0; i < keys.length; i++) + { + if (source.hasOwnProperty(keys[i])) + { + return true; + } + } + + return false; +}; + +module.exports = HasAny; /***/ }), @@ -52020,60 +57168,9 @@ module.exports = TouchManager; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Vector2 = __webpack_require__(6); +// Phaser.Math.Easing.Stepped -/** - * Takes the `x` and `y` coordinates and transforms them into the same space as - * defined by the position, rotation and scale values. - * - * @function Phaser.Math.TransformXY - * @since 3.0.0 - * - * @param {number} x - The x coordinate to be transformed. - * @param {number} y - The y coordinate to be transformed. - * @param {number} positionX - Horizontal position of the transform point. - * @param {number} positionY - Vertical position of the transform point. - * @param {number} rotation - Rotation of the transform point, in radians. - * @param {number} scaleX - Horizontal scale of the transform point. - * @param {number} scaleY - Vertical scale of the transform point. - * @param {Vector2|Point|object} [output] - [description] - * - * @return {Vector2|Point|object} The translated point. - */ -var TransformXY = function (x, y, positionX, positionY, rotation, scaleX, scaleY, output) -{ - if (output === undefined) { output = new Vector2(); } - - // ITRS - - var sr = Math.sin(-rotation); - var cr = Math.cos(-rotation); - - var a = cr * scaleX; - var b = -sr * scaleX; - var c = sr * scaleY; - var d = cr * scaleY; - - // Invert - - var n = a * d - b * c; - - var m0 = d / n; - var m1 = -b / n; - var m2 = -c / n; - var m3 = a / n; - var m4 = (c * positionY - d * positionX) / n; - var m5 = -(a * positionY - b * positionX) / n; - - // Transform - - output.x = x * m0 + y * m2 + m4; - output.y = x * m1 + y * m3 + m5; - - return output; -}; - -module.exports = TransformXY; +module.exports = __webpack_require__(717); /***/ }), @@ -52086,1392 +57183,15 @@ module.exports = TransformXY; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var CONST = __webpack_require__(83); -var GetValue = __webpack_require__(4); -var NOOP = __webpack_require__(3); -var Scene = __webpack_require__(253); -var Systems = __webpack_require__(130); +// Phaser.Math.Easing.Sine -/** - * @classdesc - * The Scene Manager. - * - * The Scene Manager is a Game level system, responsible for creating, processing and updating all of the - * Scenes in a Game instance. - * - * - * @class SceneManager - * @memberOf Phaser.Scenes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - The Phaser.Game instance this Scene Manager belongs to. - * @param {object} sceneConfig - Scene specific configuration settings. - */ -var SceneManager = new Class({ +module.exports = { - initialize: + In: __webpack_require__(720), + Out: __webpack_require__(719), + InOut: __webpack_require__(718) - function SceneManager (game, sceneConfig) - { - /** - * [description] - * - * @name Phaser.Scenes.SceneManager#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game = game; - - /** - * An object that maps the keys to the scene so we can quickly get a scene from a key without iteration. - * - * @name Phaser.Scenes.SceneManager#keys - * @type {object} - * @since 3.0.0 - */ - this.keys = {}; - - /** - * The array in which all of the scenes are kept. - * - * @name Phaser.Scenes.SceneManager#scenes - * @type {array} - * @since 3.0.0 - */ - this.scenes = []; - - /** - * Scenes pending to be added are stored in here until the manager has time to add it. - * - * @name Phaser.Scenes.SceneManager#_pending - * @type {array} - * @private - * @since 3.0.0 - */ - this._pending = []; - - /** - * An array of scenes waiting to be started once the game has booted. - * - * @name Phaser.Scenes.SceneManager#_start - * @type {array} - * @private - * @since 3.0.0 - */ - this._start = []; - - /** - * An operations queue, because we don't manipulate the scenes array during processing. - * - * @name Phaser.Scenes.SceneManager#_queue - * @type {array} - * @private - * @since 3.0.0 - */ - this._queue = []; - - /** - * The number of Scenes to process. - * - * @name Phaser.Scenes.SceneManager#_processing - * @type {integer} - * @private - * @since 3.0.0 - */ - this._processing = 0; - - if (sceneConfig) - { - if (!Array.isArray(sceneConfig)) - { - sceneConfig = [ sceneConfig ]; - } - - for (var i = 0; i < sceneConfig.length; i++) - { - // The i === 0 part just autostarts the first Scene given (unless it says otherwise in its config) - this._pending.push({ - key: 'default', - scene: sceneConfig[i], - autoStart: (i === 0), - data: {} - }); - } - - // Only need to wait for the boot event if we've scenes to actually boot - game.events.once('ready', this.bootQueue, this); - } - }, - - /** - * Internal first-time Scene boot handler. - * - * @method Phaser.Scenes.SceneManager#bootQueue - * @private - * @since 3.2.0 - */ - bootQueue: function () - { - var i; - var entry; - var key; - var sceneConfig; - - for (i = 0; i < this._pending.length; i++) - { - entry = this._pending[i]; - - key = entry.key; - sceneConfig = entry.scene; - - var newScene; - - if (sceneConfig instanceof Scene) - { - newScene = this.createSceneFromInstance(key, sceneConfig); - } - else if (typeof sceneConfig === 'object') - { - newScene = this.createSceneFromObject(key, sceneConfig); - } - else if (typeof sceneConfig === 'function') - { - newScene = this.createSceneFromFunction(key, sceneConfig); - } - - // Replace key in case the scene changed it - key = newScene.sys.settings.key; - - this.keys[key] = newScene; - - this.scenes.push(newScene); - - if (entry.autoStart || newScene.sys.settings.active) - { - this._start.push(key); - } - } - - // Clear the pending lists - this._pending.length = 0; - - // _start might have been populated by the above - for (i = 0; i < this._start.length; i++) - { - entry = this._start[i]; - - this.start(entry); - } - - this._start.length = 0; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#processQueue - * @since 3.0.0 - */ - processQueue: function () - { - var pendingLength = this._pending.length; - var queueLength = this._queue.length; - - if (pendingLength === 0 && queueLength === 0) - { - return; - } - - var i; - var entry; - - if (pendingLength) - { - for (i = 0; i < pendingLength; i++) - { - entry = this._pending[i]; - - this.add(entry.key, entry.scene, entry.autoStart); - } - - // _start might have been populated by this.add - for (i = 0; i < this._start.length; i++) - { - entry = this._start[i]; - - this.start(entry); - } - - // Clear the pending lists - this._start.length = 0; - this._pending.length = 0; - - return; - } - - for (i = 0; i < this._queue.length; i++) - { - entry = this._queue[i]; - - this[entry.op](entry.keyA, entry.keyB); - } - - this._queue.length = 0; - }, - - /** - * Adds a new Scene into the SceneManager. - * You must give each Scene a unique key by which you'll identify it. - * - * The `sceneConfig` can be: - * - * * A `Phaser.Scene` object, or an object that extends it. - * * A plain JavaScript object - * * A JavaScript ES6 Class that extends `Phaser.Scene` - * * A JavaScript ES5 prototype based Class - * * A JavaScript function - * - * If a function is given then a new Scene will be created by calling it. - * - * @method Phaser.Scenes.SceneManager#add - * @since 3.0.0 - * - * @param {string} key - A unique key used to reference the Scene, i.e. `MainMenu` or `Level1`. - * @param {Phaser.Scene|object|function} sceneConfig - [description] - * @param {boolean} [autoStart=false] - If `true` the Scene will be started immediately after being added. - * - * @return {Phaser.Scene|null} [description] - */ - add: function (key, sceneConfig, autoStart) - { - if (autoStart === undefined) { autoStart = false; } - - // if not booted, then put scene into a holding pattern - if (this._processing === 1 || !this.game.isBooted) - { - this._pending.push({ - key: key, - scene: sceneConfig, - autoStart: autoStart, - data: {} - }); - - return null; - } - - key = this.getKey(key, sceneConfig); - - var newScene; - - if (sceneConfig instanceof Scene) - { - newScene = this.createSceneFromInstance(key, sceneConfig); - } - else if (typeof sceneConfig === 'object') - { - sceneConfig.key = key; - - newScene = this.createSceneFromObject(key, sceneConfig); - } - else if (typeof sceneConfig === 'function') - { - newScene = this.createSceneFromFunction(key, sceneConfig); - } - - // Replace key in case the scene changed it - key = newScene.sys.settings.key; - - this.keys[key] = newScene; - - this.scenes.push(newScene); - - if (autoStart || newScene.sys.settings.active) - { - if (this.game.isBooted) - { - this.start(key); - } - else - { - this._start.push(key); - } - } - - return newScene; - }, - - /** - * Removes a Scene from the SceneManager. - * - * The Scene is removed from the local scenes array, it's key is cleared from the keys - * cache and Scene.Systems.destroy is then called on it. - * - * If the SceneManager is processing the Scenes when this method is called it wil - * queue the operation for the next update sequence. - * - * @method Phaser.Scenes.SceneManager#remove - * @since 3.2.0 - * - * @param {string|Phaser.Scene} scene - The Scene to be removed. - * - * @return {Phaser.Scenes.SceneManager} This SceneManager. - */ - remove: function (key) - { - if (this._processing) - { - this._queue.push({ op: 'remove', keyA: key, keyB: null }); - } - else - { - var sceneToRemove = this.getScene(key); - - if (!sceneToRemove) - { - return this; - } - - var index = this.scenes.indexOf(sceneToRemove); - var sceneKey = sceneToRemove.sys.settings.key; - - if (index > -1) - { - this.keys[sceneKey] = undefined; - this.scenes.splice(index, 1); - - if (this._start.indexOf(sceneKey) > -1) - { - index = this._start.indexOf(sceneKey); - this._start.splice(index, 1); - } - - sceneToRemove.sys.destroy(); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#bootScene - * @private - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ - bootScene: function (scene) - { - if (scene.init) - { - scene.init.call(scene, scene.sys.settings.data); - } - - var loader; - - if (scene.sys.load) - { - loader = scene.sys.load; - - loader.reset(); - } - - if (loader && scene.preload) - { - scene.preload.call(scene); - - // Is the loader empty? - if (loader.list.size === 0) - { - this.create(scene); - } - else - { - scene.sys.settings.status = CONST.LOADING; - - // Start the loader going as we have something in the queue - loader.once('complete', this.loadComplete, this); - - loader.start(); - } - } - else - { - // No preload? Then there was nothing to load either - this.create(scene); - } - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#loadComplete - * @private - * @since 3.0.0 - * - * @param {object} loader - [description] - */ - loadComplete: function (loader) - { - var scene = loader.scene; - - this.create(scene); - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#payloadComplete - * @private - * @since 3.0.0 - * - * @param {object} loader - [description] - */ - payloadComplete: function (loader) - { - this.bootScene(loader.scene); - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#update - * @since 3.0.0 - * - * @param {number} time - [description] - * @param {number} delta - [description] - */ - update: function (time, delta) - { - this.processQueue(); - - this._processing = 1; - - // Loop through the active scenes in reverse order - for (var i = this.scenes.length - 1; i >= 0; i--) - { - var sys = this.scenes[i].sys; - - if (sys.settings.status === CONST.RUNNING) - { - sys.step(time, delta); - } - } - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#resize - * @since 3.2.0 - * - * @param {number} width - The new width of the game. - * @param {number} height - The new height of the game. - */ - resize: function (width, height) - { - // Loop through the scenes in forward order - for (var i = 0; i < this.scenes.length; i++) - { - var sys = this.scenes[i].sys; - - sys.resize(width, height); - } - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#render - * @since 3.0.0 - * - * @param {any} renderer - [description] - */ - render: function (renderer) - { - // Loop through the scenes in forward order - for (var i = 0; i < this.scenes.length; i++) - { - var sys = this.scenes[i].sys; - - if (sys.settings.visible && sys.settings.status >= CONST.LOADING && sys.settings.status < CONST.SLEEPING) - { - sys.render(renderer); - } - } - - this._processing = 0; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#create - * @private - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ - create: function (scene) - { - if (scene.create) - { - scene.sys.settings.status = CONST.CREATING; - - scene.create.call(scene, scene.sys.settings.data); - } - - scene.sys.settings.status = CONST.RUNNING; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#createSceneFromFunction - * @private - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {function} scene - [description] - * - * @return {Phaser.Scene} [description] - */ - createSceneFromFunction: function (key, scene) - { - var newScene = new scene(); - - if (newScene instanceof Scene) - { - var configKey = newScene.sys.settings.key; - - if (configKey !== '') - { - key = configKey; - } - - if (this.keys.hasOwnProperty(key)) - { - throw new Error('Cannot add a Scene with duplicate key: ' + key); - } - - return this.createSceneFromInstance(key, newScene); - } - else - { - newScene.sys = new Systems(newScene); - - newScene.sys.settings.key = key; - - newScene.sys.init(this.game); - - if (!newScene.update) - { - newScene.update = NOOP; - } - - return newScene; - } - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#createSceneFromInstance - * @private - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {Phaser.Scene} newScene - [description] - * - * @return {Phaser.Scene} [description] - */ - createSceneFromInstance: function (key, newScene) - { - var configKey = newScene.sys.settings.key; - - if (configKey !== '') - { - key = configKey; - } - else - { - newScene.sys.settings.key = key; - } - - newScene.sys.init(this.game); - - return newScene; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#createSceneFromObject - * @private - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {object} sceneConfig - [description] - * - * @return {Phaser.Scene} [description] - */ - createSceneFromObject: function (key, sceneConfig) - { - var newScene = new Scene(sceneConfig); - - var configKey = newScene.sys.settings.key; - - if (configKey !== '') - { - key = configKey; - } - else - { - newScene.sys.settings.key = key; - } - - newScene.sys.init(this.game); - - // Extract callbacks - - var defaults = [ 'init', 'preload', 'create', 'update', 'render', 'shutdown', 'destroy' ]; - - for (var i = 0; i < defaults.length; i++) - { - var sceneCallback = GetValue(sceneConfig, defaults[i], null); - - // Must always have an update function, no matter what (the rest are optional) - if (defaults[i] === 'update' && !sceneCallback) - { - sceneCallback = NOOP; - } - - if (sceneCallback) - { - newScene[defaults[i]] = sceneCallback; - } - } - - // Now let's move across any other functions or properties that may exist in the extend object: - - /* - scene: { - preload: preload, - create: create, - extend: { - hello: 1, - test: 'atari', - addImage: addImage - } - } - */ - - if (sceneConfig.hasOwnProperty('extend')) - { - for (var propertyKey in sceneConfig.extend) - { - newScene[propertyKey] = sceneConfig.extend[propertyKey]; - } - } - - return newScene; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#getKey - * @private - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {Phaser.Scene|object|function} sceneConfig - [description] - * - * @return {string} [description] - */ - getKey: function (key, sceneConfig) - { - if (!key) { key = 'default'; } - - if (typeof sceneConfig === 'function') - { - return key; - } - else if (sceneConfig instanceof Scene) - { - key = sceneConfig.sys.settings.key; - } - else if (typeof sceneConfig === 'object' && sceneConfig.hasOwnProperty('key')) - { - key = sceneConfig.key; - } - - // By this point it's either 'default' or extracted from the Scene - - if (this.keys.hasOwnProperty(key)) - { - throw new Error('Cannot add a Scene with duplicate key: ' + key); - } - else - { - return key; - } - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#getScene - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scene|null} [description] - */ - getScene: function (key) - { - if (typeof key === 'string') - { - if (this.keys[key]) - { - return this.keys[key]; - } - } - else - { - for (var i = 0; i < this.scenes.length; i++) - { - if (key === this.scenes[i]) - { - return key; - } - } - } - - return null; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#isActive - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {boolean} [description] - */ - isActive: function (key) - { - var scene = this.getScene(key); - - if (scene) - { - return scene.sys.isActive(); - } - - return null; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#isVisible - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {boolean} [description] - */ - isVisible: function (key) - { - var scene = this.getScene(key); - - if (scene) - { - return scene.sys.isVisible(); - } - - return null; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#isSleeping - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {boolean} [description] - */ - isSleeping: function (key) - { - var scene = this.getScene(key); - - if (scene) - { - return scene.sys.isSleeping(); - } - - return null; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#pause - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - pause: function (key) - { - var scene = this.getScene(key); - - if (scene) - { - scene.sys.pause(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#resume - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - resume: function (key) - { - var scene = this.getScene(key); - - if (scene) - { - scene.sys.resume(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#sleep - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - sleep: function (key) - { - var scene = this.getScene(key); - - if (scene) - { - scene.sys.sleep(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#wake - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - wake: function (key) - { - var scene = this.getScene(key); - - if (scene) - { - scene.sys.wake(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#start - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {object} [data] - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - start: function (key, data) - { - if (data === undefined) { data = {}; } - - // if not booted, then put scene into a holding pattern - if (!this.game.isBooted) - { - for (var i = 0; i < this._pending.length; i++) - { - var entry = this._pending[i]; - - if (entry.key === key) - { - entry.autoStart = true; - entry.data = data; - } - } - - return this; - } - - var scene = this.getScene(key); - - if (scene) - { - scene.sys.start(data); - - var loader; - - if (scene.sys.load) - { - loader = scene.sys.load; - } - - // Files payload? - if (loader && Array.isArray(scene.sys.settings.files)) - { - loader.reset(); - - if (loader.loadArray(scene.sys.settings.files)) - { - scene.sys.settings.status = CONST.LOADING; - - loader.once('complete', this.payloadComplete, this); - - loader.start(); - - return this; - } - } - - this.bootScene(scene); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#stop - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - stop: function (key) - { - var scene = this.getScene(key); - - if (scene) - { - scene.sys.shutdown(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#switch - * @since 3.0.0 - * - * @param {string} from - [description] - * @param {string} to - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - switch: function (from, to) - { - var sceneA = this.getScene(from); - var sceneB = this.getScene(to); - - if (sceneA && sceneB && sceneA !== sceneB) - { - this.sleep(from); - - if (this.isSleeping(to)) - { - this.wake(to); - } - else - { - this.start(to); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#getAt - * @since 3.0.0 - * - * @param {integer} index - [description] - * - * @return {Phaser.Scene|undefined} [description] - */ - getAt: function (index) - { - return this.scenes[index]; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#getIndex - * @since 3.0.0 - * - * @param {string|Phaser.Scene} key - [description] - * - * @return {integer} [description] - */ - getIndex: function (key) - { - var scene = this.getScene(key); - - return this.scenes.indexOf(scene); - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#bringToTop - * @since 3.0.0 - * - * @param {string|Phaser.Scene} key - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - bringToTop: function (key) - { - if (this._processing) - { - this._queue.push({ op: 'bringToTop', keyA: key, keyB: null }); - } - else - { - var index = this.getIndex(key); - - if (index !== -1 && index < this.scenes.length) - { - var scene = this.getScene(key); - - this.scenes.splice(index, 1); - this.scenes.push(scene); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#sendToBack - * @since 3.0.0 - * - * @param {string|Phaser.Scene} key - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - sendToBack: function (key) - { - if (this._processing) - { - this._queue.push({ op: 'sendToBack', keyA: key, keyB: null }); - } - else - { - var index = this.getIndex(key); - - if (index !== -1 && index > 0) - { - var scene = this.getScene(key); - - this.scenes.splice(index, 1); - this.scenes.unshift(scene); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#moveDown - * @since 3.0.0 - * - * @param {string|Phaser.Scene} key - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - moveDown: function (key) - { - if (this._processing) - { - this._queue.push({ op: 'moveDown', keyA: key, keyB: null }); - } - else - { - var indexA = this.getIndex(key); - - if (indexA > 0) - { - var indexB = indexA - 1; - var sceneA = this.getScene(key); - var sceneB = this.getAt(indexB); - - this.scenes[indexA] = sceneB; - this.scenes[indexB] = sceneA; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#moveUp - * @since 3.0.0 - * - * @param {string|Phaser.Scene} key - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - moveUp: function (key) - { - if (this._processing) - { - this._queue.push({ op: 'moveUp', keyA: key, keyB: null }); - } - else - { - var indexA = this.getIndex(key); - - if (indexA < this.scenes.length - 1) - { - var indexB = indexA + 1; - var sceneA = this.getScene(key); - var sceneB = this.getAt(indexB); - - this.scenes[indexA] = sceneB; - this.scenes[indexB] = sceneA; - } - } - - return this; - }, - - /** - * Moves a Scene so it is immediately above another Scene in the Scenes list. - * This means it will render over the top of the other Scene. - * - * @method Phaser.Scenes.SceneManager#moveAbove - * @since 3.2.0 - * - * @param {string|Phaser.Scene} keyA - The Scene that Scene B will be moved above. - * @param {string|Phaser.Scene} keyB - The Scene to be moved. - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - moveAbove: function (keyA, keyB) - { - if (keyA === keyB) - { - return this; - } - - if (this._processing) - { - this._queue.push({ op: 'moveAbove', keyA: keyA, keyB: keyB }); - } - else - { - var indexA = this.getIndex(keyA); - var indexB = this.getIndex(keyB); - - if (indexA > indexB && indexA !== -1 && indexB !== -1) - { - var tempScene = this.getAt(indexB); - - // Remove - this.scenes.splice(indexB, 1); - - // Add in new location - this.scenes.splice(indexA, 0, tempScene); - } - } - - return this; - }, - - /** - * Moves a Scene so it is immediately below another Scene in the Scenes list. - * This means it will render behind the other Scene. - * - * @method Phaser.Scenes.SceneManager#moveBelow - * @since 3.2.0 - * - * @param {string|Phaser.Scene} keyA - The Scene that Scene B will be moved above. - * @param {string|Phaser.Scene} keyB - The Scene to be moved. - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - moveBelow: function (keyA, keyB) - { - if (keyA === keyB) - { - return this; - } - - if (this._processing) - { - this._queue.push({ op: 'moveBelow', keyA: keyA, keyB: keyB }); - } - else - { - var indexA = this.getIndex(keyA); - var indexB = this.getIndex(keyB); - - if (indexA < indexB && indexA !== -1 && indexB !== -1) - { - var tempScene = this.getAt(indexB); - - // Remove - this.scenes.splice(indexB, 1); - - // Add in new location - this.scenes.splice(indexA, 0, tempScene); - } - } - - return this; - }, - - queueOp: function (op, keyA, keyB) - { - this._queue.push({ op: op, keyA: keyA, keyB: keyB }); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#swapPosition - * @since 3.0.0 - * - * @param {string|Phaser.Scene} keyA - [description] - * @param {string|Phaser.Scene} keyB - [description] - * - * @return {Phaser.Scenes.SceneManager} [description] - */ - swapPosition: function (keyA, keyB) - { - if (keyA === keyB) - { - return this; - } - - if (this._processing) - { - this._queue.push({ op: 'swapPosition', keyA: keyA, keyB: keyB }); - } - else - { - var indexA = this.getIndex(keyA); - var indexB = this.getIndex(keyB); - - if (indexA !== indexB && indexA !== -1 && indexB !== -1) - { - var tempScene = this.getAt(indexA); - - this.scenes[indexA] = this.scenes[indexB]; - this.scenes[indexB] = tempScene; - } - } - - return this; - }, - - dump: function () - { - var out = []; - var map = [ 'pending', 'init', 'start', 'loading', 'creating', 'running', 'paused', 'sleeping', 'shutdown', 'destroyed' ]; - - for (var i = 0; i < this.scenes.length; i++) - { - var sys = this.scenes[i].sys; - - var key = (sys.settings.visible && (sys.settings.status === CONST.RUNNING || sys.settings.status === CONST.PAUSED)) ? '[*] ' : '[-] '; - key += sys.settings.key + ' (' + map[sys.settings.status] + ')'; - - out.push(key); - } - - console.log(out.join('\n')); - }, - - /** - * [description] - * - * @method Phaser.Scenes.SceneManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - for (var i = this.scenes.length - 1; i >= 0; i--) - { - var sys = this.scenes[i].sys; - - sys.destroy(); - } - - this.scenes = []; - - this._pending = []; - this._start = []; - this._queue = []; - - this.game = null; - } - -}); - -module.exports = SceneManager; +}; /***/ }), @@ -53484,55 +57204,20 @@ module.exports = SceneManager; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Systems = __webpack_require__(130); +// Phaser.Math.Easing.Quintic -/** - * @classdesc - * [description] - * - * @class Scene - * @memberOf Phaser - * @constructor - * @since 3.0.0 - * - * @param {object} config - [description] - */ -var Scene = new Class({ +module.exports = { - initialize: + In: __webpack_require__(723), + Out: __webpack_require__(722), + InOut: __webpack_require__(721) - function Scene (config) - { - /** - * The Scene Systems. You must never overwrite this property, or all hell will break lose. - * - * @name Phaser.Scene#sys - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.sys = new Systems(this, config); - }, - - /** - * Should be overridden by your own Scenes. - * - * @method Phaser.Scene#update - * @override - * @since 3.0.0 - */ - update: function () - { - } - -}); - -module.exports = Scene; +}; /***/ }), /* 254 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -53540,22 +57225,15 @@ module.exports = Scene; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * [description] - * - * @function Phaser.Utils.String.UppercaseFirst - * @since 3.0.0 - * - * @param {string} str - [description] - * - * @return {string} [description] - */ -var UppercaseFirst = function (str) -{ - return str && str[0].toUpperCase() + str.slice(1); -}; +// Phaser.Math.Easing.Quartic -module.exports = UppercaseFirst; +module.exports = { + + In: __webpack_require__(726), + Out: __webpack_require__(725), + InOut: __webpack_require__(724) + +}; /***/ }), @@ -53568,77 +57246,16 @@ module.exports = UppercaseFirst; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CONST = __webpack_require__(83); -var GetValue = __webpack_require__(4); -var InjectionMap = __webpack_require__(532); +// Phaser.Math.Easing.Quadratic -/** - * Takes a Scene configuration object and returns a fully formed Systems object. - * - * @function Phaser.Scenes.Settings.create - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {object} [description] - */ -var Settings = { +module.exports = { - create: function (config) - { - if (typeof config === 'string') - { - config = { key: config }; - } - else if (config === undefined) - { - // Pass the 'hasOwnProperty' checks - config = {}; - } - - return { - - status: CONST.PENDING, - - key: GetValue(config, 'key', ''), - active: GetValue(config, 'active', false), - visible: GetValue(config, 'visible', true), - - isBooted: false, - - // Loader payload array - - data: {}, - - files: GetValue(config, 'files', false), - - // Cameras - - cameras: GetValue(config, 'cameras', null), - - // Scene Property Injection Map - - map: GetValue(config, 'map', InjectionMap), - - // Physics - - physics: GetValue(config, 'physics', {}), - - // Loader - - loader: GetValue(config, 'loader', {}), - - // Plugins - - plugins: GetValue(config, 'plugins', false) - - }; - } + In: __webpack_require__(729), + Out: __webpack_require__(728), + InOut: __webpack_require__(727) }; -module.exports = Settings; - /***/ }), /* 256 */ @@ -53650,42 +57267,9 @@ module.exports = Settings; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var HTML5AudioSoundManager = __webpack_require__(257); -var NoAudioSoundManager = __webpack_require__(259); -var WebAudioSoundManager = __webpack_require__(261); +// Phaser.Math.Easing.Linear -/** - * Creates a Web Audio, HTML5 Audio or No Audio Sound Manager based on config and device settings. - * - * @function Phaser.Sound.SoundManagerCreator - * @author Pavle Goloskokovic (http://prunegames.com) - * @since 3.0.0 - * - * @param {Phaser.Game} game - Reference to the current game instance. - */ -var SoundManagerCreator = { - - create: function (game) - { - var audioConfig = game.config.audio; - var deviceAudio = game.device.audio; - - if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) - { - return new NoAudioSoundManager(game); - } - - if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio)) - { - return new WebAudioSoundManager(game); - } - - return new HTML5AudioSoundManager(game); - } - -}; - -module.exports = SoundManagerCreator; +module.exports = __webpack_require__(730); /***/ }), @@ -53698,388 +57282,15 @@ module.exports = SoundManagerCreator; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BaseSoundManager = __webpack_require__(84); -var Class = __webpack_require__(0); -var HTML5AudioSound = __webpack_require__(258); +// Phaser.Math.Easing.Expo -/** - * HTML5 Audio implementation of the sound manager. - * - * @class HTML5AudioSoundManager - * @extends Phaser.Sound.BaseSoundManager - * @memberOf Phaser.Sound - * @constructor - * @author Pavle Goloskokovic (http://prunegames.com) - * @since 3.0.0 - * - * @param {Phaser.Game} game - Reference to the current game instance. - */ -var HTML5AudioSoundManager = new Class({ +module.exports = { - Extends: BaseSoundManager, + In: __webpack_require__(733), + Out: __webpack_require__(732), + InOut: __webpack_require__(731) - initialize: - - function HTML5AudioSoundManager (game) - { - /** - * Flag indicating whether if there are no idle instances of HTML5 Audio tag, - * for any particular sound, if one of the used tags should be hijacked and used - * for succeeding playback or if succeeding Phaser.Sound.HTML5AudioSound#play - * call should be ignored. - * - * @name Phaser.Sound.HTML5AudioSoundManager#override - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.override = true; - - /** - * Value representing time difference, in seconds, between calling - * play method on an audio tag and when it actually starts playing. - * It is used to achieve more accurate delayed sound playback. - * - * You might need to tweak this value to get the desired results - * since audio play delay varies depending on the browser/platform. - * - * @name Phaser.Sound.HTML5AudioSoundManager#audioPlayDelay - * @type {number} - * @default 0.1 - * @since 3.0.0 - */ - this.audioPlayDelay = 0.1; - - /** - * A value by which we should offset the loop end marker of the - * looping sound to compensate for lag, caused by changing audio - * tag playback position, in order to achieve gapless looping. - * - * You might need to tweak this value to get the desired results - * since loop lag varies depending on the browser/platform. - * - * @name Phaser.Sound.HTML5AudioSoundManager#loopEndOffset - * @type {number} - * @default 0.05 - * @since 3.0.0 - */ - this.loopEndOffset = 0.05; - - /** - * An array for keeping track of all the sounds - * that were paused when game lost focus. - * - * @name Phaser.Sound.HTML5AudioSoundManager#onBlurPausedSounds - * @type {Phaser.Sound.HTML5AudioSound[]} - * @private - * @default [] - * @since 3.0.0 - */ - this.onBlurPausedSounds = []; - - this.locked = 'ontouchstart' in window; - - /** - * A queue of all actions performed on sound objects while audio was locked. - * Once the audio gets unlocked, after an explicit user interaction, - * all actions will be performed in chronological order. - * Array of object types: { sound: Phaser.Sound.HTML5AudioSound, name: string, value?: * } - * - * @name Phaser.Sound.HTML5AudioSoundManager#lockedActionsQueue - * @type {array} - * @private - * @since 3.0.0 - */ - this.lockedActionsQueue = this.locked ? [] : null; - - /** - * Property that actually holds the value of global mute - * for HTML5 Audio sound manager implementation. - * - * @name Phaser.Sound.HTML5AudioSoundManager#_mute - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this._mute = false; - - /** - * Property that actually holds the value of global volume - * for HTML5 Audio sound manager implementation. - * - * @name Phaser.Sound.HTML5AudioSoundManager#_volume - * @type {boolean} - * @private - * @default 1 - * @since 3.0.0 - */ - this._volume = 1; - - BaseSoundManager.call(this, game); - }, - - /** - * Adds a new sound into the sound manager. - * - * @method Phaser.Sound.HTML5AudioSoundManager#add - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - * - * @return {Phaser.Sound.HTML5AudioSound} The new sound instance. - */ - add: function (key, config) - { - var sound = new HTML5AudioSound(this, key, config); - - this.sounds.push(sound); - - return sound; - }, - - /** - * Unlocks HTML5 Audio loading and playback on mobile - * devices on the initial explicit user interaction. - * - * @method Phaser.Sound.HTML5AudioSoundManager#unlock - * @private - * @since 3.0.0 - */ - unlock: function () - { - var _this = this; - - var moved = false; - - var detectMove = function () - { - moved = true; - }; - - var unlock = function () - { - if (!_this.game.cache.audio.entries.size) - { - return; - } - - if (moved) - { - moved = false; - return; - } - - document.body.removeEventListener('touchmove', detectMove); - document.body.removeEventListener('touchend', unlock); - - var allTags = []; - - _this.game.cache.audio.entries.each(function (key, tags) - { - for (var i = 0; i < tags.length; i++) - { - allTags.push(tags[i]); - } - return true; - }); - - var lastTag = allTags[allTags.length - 1]; - - lastTag.oncanplaythrough = function () - { - lastTag.oncanplaythrough = null; - _this.unlocked = true; - }; - - allTags.forEach(function (tag) - { - tag.load(); - }); - }; - - this.once('unlocked', function () - { - this.forEachActiveSound(function (sound) - { - sound.duration = sound.tags[0].duration; - sound.totalDuration = sound.tags[0].duration; - }); - - this.lockedActionsQueue.forEach(function (lockedAction) - { - if (lockedAction.sound[lockedAction.prop].apply) - { - lockedAction.sound[lockedAction.prop].apply(lockedAction.sound, lockedAction.value || []); - } - else - { - lockedAction.sound[lockedAction.prop] = lockedAction.value; - } - }); - - this.lockedActionsQueue.length = 0; - this.lockedActionsQueue = null; - }, this); - - document.body.addEventListener('touchmove', detectMove, false); - document.body.addEventListener('touchend', unlock, false); - }, - - /** - * Method used internally for pausing sound manager if - * Phaser.Sound.HTML5AudioSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.HTML5AudioSoundManager#onBlur - * @protected - * @since 3.0.0 - */ - onBlur: function () - { - this.forEachActiveSound(function (sound) - { - if (sound.isPlaying) - { - this.onBlurPausedSounds.push(sound); - sound.onBlur(); - } - }); - }, - - /** - * Method used internally for resuming sound manager if - * Phaser.Sound.HTML5AudioSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.HTML5AudioSoundManager#onFocus - * @protected - * @since 3.0.0 - */ - onFocus: function () - { - this.onBlurPausedSounds.forEach(function (sound) - { - sound.onFocus(); - }); - - this.onBlurPausedSounds.length = 0; - }, - - /** - * Calls Phaser.Sound.BaseSoundManager#destroy method - * and cleans up all HTML5 Audio related stuff. - * - * @method Phaser.Sound.HTML5AudioSoundManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - BaseSoundManager.prototype.destroy.call(this); - - this.onBlurPausedSounds.length = 0; - this.onBlurPausedSounds = null; - }, - - /** - * Method used internally by Phaser.Sound.HTML5AudioSound class methods and property setters - * to check if sound manager is locked and then either perform action immediately or queue it - * to be performed once the sound manager gets unlocked. - * - * @method Phaser.Sound.HTML5AudioSoundManager#isLocked - * @protected - * @since 3.0.0 - * - * @param {Phaser.Sound.HTML5AudioSound} sound - Sound object on which to perform queued action. - * @param {string} prop - Name of the method to be called or property to be assigned a value to. - * @param {*} [value] - An optional parameter that either holds an array of arguments to be passed to the method call or value to be set to the property. - * - * @return {boolean} Whether the sound manager is locked. - */ - isLocked: function (sound, prop, value) - { - if (this.locked) - { - this.lockedActionsQueue.push({ - sound: sound, - prop: prop, - value: value - }); - - return true; - } - - return false; - }, - - /** - * @event Phaser.Sound.HTML5AudioSoundManager#MuteEvent - * @param {Phaser.Sound.HTML5AudioSoundManager} soundManager - Reference to the sound manager that emitted event. - * @param {boolean} value - An updated value of Phaser.Sound.HTML5AudioSoundManager#mute property. - */ - - /** - * @name Phaser.Sound.HTML5AudioSoundManager#mute - * @type {boolean} - * @fires Phaser.Sound.HTML5AudioSoundManager#MuteEvent - * @since 3.0.0 - */ - mute: { - - get: function () - { - return this._mute; - }, - - set: function (value) - { - this._mute = value; - - this.forEachActiveSound(function (sound) - { - sound.setMute(); - }); - - this.emit('mute', this, value); - } - - }, - - /** - * @event Phaser.Sound.HTML5AudioSoundManager#VolumeEvent - * @param {Phaser.Sound.HTML5AudioSoundManager} soundManager - Reference to the sound manager that emitted event. - * @param {number} value - An updated value of Phaser.Sound.HTML5AudioSoundManager#volume property. - */ - - /** - * @name Phaser.Sound.HTML5AudioSoundManager#volume - * @type {number} - * @fires Phaser.Sound.HTML5AudioSoundManager#VolumeEvent - * @since 3.0.0 - */ - volume: { - - get: function () - { - return this._volume; - }, - - set: function (value) - { - this._volume = value; - - this.forEachActiveSound(function (sound) - { - sound.setVolume(); - }); - - this.emit('volume', this, value); - } - - } - -}); - -module.exports = HTML5AudioSoundManager; +}; /***/ }), @@ -54091,8 +57302,3765 @@ module.exports = HTML5AudioSoundManager; * @copyright 2018 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ + +// Phaser.Math.Easing.Elastic + +module.exports = { + + In: __webpack_require__(736), + Out: __webpack_require__(735), + InOut: __webpack_require__(734) + +}; + + +/***/ }), +/* 259 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Phaser.Math.Easing.Cubic + +module.exports = { + + In: __webpack_require__(739), + Out: __webpack_require__(738), + InOut: __webpack_require__(737) + +}; + + +/***/ }), +/* 260 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Phaser.Math.Easing.Circular + +module.exports = { + + In: __webpack_require__(742), + Out: __webpack_require__(741), + InOut: __webpack_require__(740) + +}; + + +/***/ }), +/* 261 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Phaser.Math.Easing.Bounce + +module.exports = { + + In: __webpack_require__(745), + Out: __webpack_require__(744), + InOut: __webpack_require__(743) + +}; + + +/***/ }), +/* 262 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Phaser.Math.Easing.Back + +module.exports = { + + In: __webpack_require__(748), + Out: __webpack_require__(747), + InOut: __webpack_require__(746) + +}; + + +/***/ }), +/* 263 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.FloatBetween + * @since 3.0.0 + * + * @param {float} min - [description] + * @param {float} max - [description] + * + * @return {float} [description] + */ +var FloatBetween = function (min, max) +{ + return Math.random() * (max - min) + min; +}; + +module.exports = FloatBetween; + + +/***/ }), +/* 264 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetValue = __webpack_require__(5); +var Shuffle = __webpack_require__(102); + +var BuildChunk = function (a, b, qty) +{ + var out = []; + + for (var aIndex = 0; aIndex < a.length; aIndex++) + { + for (var bIndex = 0; bIndex < b.length; bIndex++) + { + for (var i = 0; i < qty; i++) + { + out.push({ a: a[aIndex], b: b[bIndex] }); + } + } + } + + return out; +}; + +// options = repeat, random, randomB, yoyo, max, qty + +// Range ([a,b,c], [1,2,3]) = +// a1, a2, a3, b1, b2, b3, c1, c2, c3 + +// Range ([a,b], [1,2,3], qty = 3) = +// a1, a1, a1, a2, a2, a2, a3, a3, a3, b1, b1, b1, b2, b2, b2, b3, b3, b3 + +// Range ([a,b,c], [1,2,3], repeat x1) = +// a1, a2, a3, b1, b2, b3, c1, c2, c3, a1, a2, a3, b1, b2, b3, c1, c2, c3 + +// Range ([a,b], [1,2], repeat -1 = endless, max = 14) = +// Maybe if max is set then repeat goes to -1 automatically? +// a1, a2, b1, b2, a1, a2, b1, b2, a1, a2, b1, b2, a1, a2 (capped at 14 elements) + +// Range ([a], [1,2,3,4,5], random = true) = +// a4, a1, a5, a2, a3 + +// Range ([a, b], [1,2,3], random = true) = +// b3, a2, a1, b1, a3, b2 + +// Range ([a, b, c], [1,2,3], randomB = true) = +// a3, a1, a2, b2, b3, b1, c1, c3, c2 + +// Range ([a], [1,2,3,4,5], yoyo = true) = +// a1, a2, a3, a4, a5, a5, a4, a3, a2, a1 + +// Range ([a, b], [1,2,3], yoyo = true) = +// a1, a2, a3, b1, b2, b3, b3, b2, b1, a3, a2, a1 + +/** + * [description] + * + * @function Phaser.Utils.Array.Range + * @since 3.0.0 + * + * @param {array} a - [description] + * @param {array} b - [description] + * @param {object} options - [description] + * + * @return {array} [description] + */ +var Range = function (a, b, options) +{ + var max = GetValue(options, 'max', 0); + var qty = GetValue(options, 'qty', 1); + var random = GetValue(options, 'random', false); + var randomB = GetValue(options, 'randomB', false); + var repeat = GetValue(options, 'repeat', 0); + var yoyo = GetValue(options, 'yoyo', false); + + var out = []; + + if (randomB) + { + Shuffle(b); + } + + // Endless repeat, so limit by max + if (repeat === -1) + { + if (max === 0) + { + repeat = 0; + } + else + { + // Work out how many repeats we need + var total = (a.length * b.length) * qty; + + if (yoyo) + { + total *= 2; + } + + repeat = Math.ceil(max / total); + } + } + + for (var i = 0; i <= repeat; i++) + { + var chunk = BuildChunk(a, b, qty); + + if (random) + { + Shuffle(chunk); + } + + out = out.concat(chunk); + + if (yoyo) + { + chunk.reverse(); + + out = out.concat(chunk); + } + } + + if (max) + { + out.splice(max); + } + + return out; +}; + +module.exports = Range; + + +/***/ }), +/* 265 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Commands = __webpack_require__(144); +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Graphics#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Graphics} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {CanvasRenderingContext2D} renderTargetCtx - [description] + * @param {boolean} allowClip - [description] + */ +var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, camera, renderTargetCtx, allowClip) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + var cameraScrollX = camera.scrollX * src.scrollFactorX; + var cameraScrollY = camera.scrollY * src.scrollFactorY; + var srcX = src.x; + var srcY = src.y; + var srcScaleX = src.scaleX; + var srcScaleY = src.scaleY; + var srcRotation = src.rotation; + var commandBuffer = src.commandBuffer; + var ctx = renderTargetCtx || renderer.currentContext; + var lineAlpha = 1.0; + var fillAlpha = 1.0; + var lineColor = 0; + var fillColor = 0; + var lineWidth = 1.0; + var red = 0; + var green = 0; + var blue = 0; + + // Blend Mode + if (renderer.currentBlendMode !== src.blendMode) + { + renderer.currentBlendMode = src.blendMode; + ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; + } + + // Alpha + if (renderer.currentAlpha !== src.alpha) + { + renderer.currentAlpha = src.alpha; + ctx.globalAlpha = src.alpha; + } + + // Smoothing + if (renderer.currentScaleMode !== src.scaleMode) + { + renderer.currentScaleMode = src.scaleMode; + } + + ctx.save(); + ctx.translate(srcX - cameraScrollX, srcY - cameraScrollY); + ctx.rotate(srcRotation); + ctx.scale(srcScaleX, srcScaleY); + ctx.fillStyle = '#fff'; + ctx.globalAlpha = src.alpha; + + for (var index = 0, length = commandBuffer.length; index < length; ++index) + { + var commandID = commandBuffer[index]; + + switch (commandID) + { + case Commands.ARC: + ctx.arc( + commandBuffer[index + 1], + commandBuffer[index + 2], + commandBuffer[index + 3], + commandBuffer[index + 4], + commandBuffer[index + 5], + commandBuffer[index + 6] + ); + index += 6; + break; + + case Commands.LINE_STYLE: + lineWidth = commandBuffer[index + 1]; + lineColor = commandBuffer[index + 2]; + lineAlpha = commandBuffer[index + 3]; + red = ((lineColor & 0xFF0000) >>> 16); + green = ((lineColor & 0xFF00) >>> 8); + blue = (lineColor & 0xFF); + ctx.strokeStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + lineAlpha + ')'; + ctx.lineWidth = lineWidth; + index += 3; + break; + + case Commands.FILL_STYLE: + fillColor = commandBuffer[index + 1]; + fillAlpha = commandBuffer[index + 2]; + red = ((fillColor & 0xFF0000) >>> 16); + green = ((fillColor & 0xFF00) >>> 8); + blue = (fillColor & 0xFF); + ctx.fillStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + fillAlpha + ')'; + index += 2; + break; + + case Commands.BEGIN_PATH: + ctx.beginPath(); + break; + + case Commands.CLOSE_PATH: + ctx.closePath(); + break; + + case Commands.FILL_PATH: + if (!allowClip) + { + ctx.fill(); + } + break; + + case Commands.STROKE_PATH: + if (!allowClip) + { + ctx.stroke(); + } + break; + + case Commands.FILL_RECT: + if (!allowClip) + { + ctx.fillRect( + commandBuffer[index + 1], + commandBuffer[index + 2], + commandBuffer[index + 3], + commandBuffer[index + 4] + ); + } + else + { + ctx.rect( + commandBuffer[index + 1], + commandBuffer[index + 2], + commandBuffer[index + 3], + commandBuffer[index + 4] + ); + } + index += 4; + break; + + case Commands.FILL_TRIANGLE: + ctx.beginPath(); + ctx.moveTo(commandBuffer[index + 1], commandBuffer[index + 2]); + ctx.lineTo(commandBuffer[index + 3], commandBuffer[index + 4]); + ctx.lineTo(commandBuffer[index + 5], commandBuffer[index + 6]); + ctx.closePath(); + if (!allowClip) + { + ctx.fill(); + } + index += 6; + break; + + case Commands.STROKE_TRIANGLE: + ctx.beginPath(); + ctx.moveTo(commandBuffer[index + 1], commandBuffer[index + 2]); + ctx.lineTo(commandBuffer[index + 3], commandBuffer[index + 4]); + ctx.lineTo(commandBuffer[index + 5], commandBuffer[index + 6]); + ctx.closePath(); + if (!allowClip) + { + ctx.stroke(); + } + index += 6; + break; + + case Commands.LINE_TO: + ctx.lineTo( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 2; + break; + + case Commands.MOVE_TO: + ctx.moveTo( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 2; + break; + + case Commands.LINE_FX_TO: + ctx.lineTo( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 5; + break; + + case Commands.MOVE_FX_TO: + ctx.moveTo( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 5; + break; + + case Commands.SAVE: + ctx.save(); + break; + + case Commands.RESTORE: + ctx.restore(); + break; + + case Commands.TRANSLATE: + ctx.translate( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 2; + break; + + case Commands.SCALE: + ctx.scale( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 2; + break; + + case Commands.ROTATE: + ctx.rotate( + commandBuffer[index + 1] + ); + index += 1; + break; + + default: + // console.error('Phaser: Invalid Graphics Command ID ' + commandID); + break; + } + } + + ctx.restore(); +}; + +module.exports = GraphicsCanvasRenderer; + + +/***/ }), +/* 266 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the circumference of the given Ellipse. + * + * @function Phaser.Geom.Ellipse.Circumference + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference of. + * + * @return {number} The circumference of th Ellipse. + */ +var Circumference = function (ellipse) +{ + var rx = ellipse.width / 2; + var ry = ellipse.height / 2; + var h = Math.pow((rx - ry), 2) / Math.pow((rx + ry), 2); + + return (Math.PI * (rx + ry)) * (1 + ((3 * h) / (10 + Math.sqrt(4 - (3 * h))))); +}; + +module.exports = Circumference; + + +/***/ }), +/* 267 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Circumference = __webpack_require__(266); +var CircumferencePoint = __webpack_require__(134); +var FromPercent = __webpack_require__(78); +var MATH_CONST = __webpack_require__(16); + +/** + * Returns an array of Point objects containing the coordinates of the points around the circumference of the Ellipse, + * based on the given quantity or stepRate values. + * + * @function Phaser.Geom.Ellipse.GetPoints + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the points from. + * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate. + * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. + * + * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the circumference of the ellipse. + */ +var GetPoints = function (ellipse, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) + { + quantity = Circumference(ellipse) / stepRate; + } + + for (var i = 0; i < quantity; i++) + { + var angle = FromPercent(i / quantity, 0, MATH_CONST.PI2); + + out.push(CircumferencePoint(ellipse, angle)); + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }), +/* 268 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CircumferencePoint = __webpack_require__(134); +var FromPercent = __webpack_require__(78); +var MATH_CONST = __webpack_require__(16); +var Point = __webpack_require__(4); + +/** + * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse + * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point + * at 180 degrees around the circle. + * + * @function Phaser.Geom.Ellipse.GetPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on. + * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. + * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. + * + * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the ellipse. + */ +var GetPoint = function (ellipse, position, out) +{ + if (out === undefined) { out = new Point(); } + + var angle = FromPercent(position, 0, MATH_CONST.PI2); + + return CircumferencePoint(ellipse, angle, out); +}; + +module.exports = GetPoint; + + +/***/ }), +/* 269 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Ellipse = __webpack_require__(135); + +Ellipse.Area = __webpack_require__(768); +Ellipse.Circumference = __webpack_require__(266); +Ellipse.CircumferencePoint = __webpack_require__(134); +Ellipse.Clone = __webpack_require__(767); +Ellipse.Contains = __webpack_require__(74); +Ellipse.ContainsPoint = __webpack_require__(766); +Ellipse.ContainsRect = __webpack_require__(765); +Ellipse.CopyFrom = __webpack_require__(764); +Ellipse.Equals = __webpack_require__(763); +Ellipse.GetBounds = __webpack_require__(762); +Ellipse.GetPoint = __webpack_require__(268); +Ellipse.GetPoints = __webpack_require__(267); +Ellipse.Offset = __webpack_require__(761); +Ellipse.OffsetPoint = __webpack_require__(760); +Ellipse.Random = __webpack_require__(162); + +module.exports = Ellipse; + + +/***/ }), +/* 270 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @function getValue + * @since 3.0.0 + * @private + */ +function getValue (node, attribute) +{ + return parseInt(node.getAttribute(attribute), 10); +} + +/** + * @function ParseXMLBitmapFont + * @since 3.0.0 + * @private + * + * @param {XMLDocument} xml - [description] + * @param {integer} [xSpacing=0] - [description] + * @param {integer} [ySpacing=0] - [description] + * @param {Phaser.Textures.Frame} [frame] - [description] + */ +var ParseXMLBitmapFont = function (xml, xSpacing, ySpacing, frame) +{ + if (xSpacing === undefined) { xSpacing = 0; } + if (ySpacing === undefined) { ySpacing = 0; } + + var data = {}; + var info = xml.getElementsByTagName('info')[0]; + var common = xml.getElementsByTagName('common')[0]; + + data.font = info.getAttribute('face'); + data.size = getValue(info, 'size'); + data.lineHeight = getValue(common, 'lineHeight') + ySpacing; + data.chars = {}; + + var letters = xml.getElementsByTagName('char'); + + var adjustForTrim = (frame !== undefined && frame.trimmed); + + if (adjustForTrim) + { + var top = frame.height; + var left = frame.width; + } + + for (var i = 0; i < letters.length; i++) + { + var node = letters[i]; + + var charCode = getValue(node, 'id'); + var gx = getValue(node, 'x'); + var gy = getValue(node, 'y'); + var gw = getValue(node, 'width'); + var gh = getValue(node, 'height'); + + // Handle frame trim issues + + if (adjustForTrim) + { + if (gx < left) + { + left = gx; + } + + if (gy < top) + { + top = gy; + } + } + + data.chars[charCode] = + { + x: gx, + y: gy, + width: gw, + height: gh, + centerX: Math.floor(gw / 2), + centerY: Math.floor(gh / 2), + xOffset: getValue(node, 'xoffset'), + yOffset: getValue(node, 'yoffset'), + xAdvance: getValue(node, 'xadvance') + xSpacing, + data: {}, + kerning: {} + }; + } + + if (adjustForTrim && top !== 0 && left !== 0) + { + // console.log('top and left', top, left, frame.x, frame.y); + + // Now we know the top and left coordinates of the glyphs in the original data + // so we can work out how much to adjust the glyphs by + + for (var code in data.chars) + { + var glyph = data.chars[code]; + + glyph.x -= frame.x; + glyph.y -= frame.y; + } + } + + var kernings = xml.getElementsByTagName('kerning'); + + for (i = 0; i < kernings.length; i++) + { + var kern = kernings[i]; + + var first = getValue(kern, 'first'); + var second = getValue(kern, 'second'); + var amount = getValue(kern, 'amount'); + + data.chars[second].kerning[first] = amount; + } + + return data; +}; + +module.exports = ParseXMLBitmapFont; + + +/***/ }), +/* 271 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function GetBitmapTextSize + * @since 3.0.0 + * @private + * + * @param {(Phaser.GameObjects.DynamicBitmapText|Phaser.GameObjects.BitmapText)} src - [description] + * @param {boolean} round - [description] + */ +var GetBitmapTextSize = function (src, round) +{ + var text = src.text; + var textLength = text.length; + + var bx = Number.MAX_VALUE; + var by = Number.MAX_VALUE; + var bw = 0; + var bh = 0; + + var chars = src.fontData.chars; + var lineHeight = src.fontData.lineHeight; + + var xAdvance = 0; + var yAdvance = 0; + + var indexCount = 0; + var charCode = 0; + + var glyph = null; + var glyphW = 0; + var glyphH = 0; + + var x = 0; + var y = 0; + + var lastGlyph = null; + var lastCharCode = 0; + + for (var index = 0; index < textLength; ++index) + { + charCode = text.charCodeAt(index); + + if (charCode === 10) + { + xAdvance = 0; + indexCount = 0; + yAdvance += lineHeight; + lastGlyph = null; + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + glyphW = glyph.width; + glyphH = glyph.height; + + x = indexCount + glyph.xOffset + xAdvance; + y = glyph.yOffset + yAdvance; + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + if (bx > x) + { + bx = x; + } + + if (by > y) + { + by = y; + } + + var gw = x + glyphW - bx; + var gh = y + glyphH - by; + + if (bw < gw) + { + bw = gw; + } + + if (bh < gh) + { + bh = gh; + } + + xAdvance += glyph.xAdvance; + indexCount += 1; + lastGlyph = glyph; + lastCharCode = charCode; + } + + var scale = (src.fontSize / src.fontData.size); + var sx = scale * src.scaleX; + var sy = scale * src.scaleY; + + var out = { + local: { + x: bx * scale, + y: by * scale, + width: bw * scale, + height: bh * scale + }, + global: { + x: src.x + (bx * sx), + y: src.y + (by * sy), + width: bw * sx, + height: bh * sy + } + }; + + if (round) + { + out.local.x = Math.round(out.local.x); + out.local.y = Math.round(out.local.y); + out.local.width = Math.round(out.local.width); + out.local.height = Math.round(out.local.height); + + out.global.x = Math.round(out.global.x); + out.global.y = Math.round(out.global.y); + out.global.width = Math.round(out.global.width); + out.global.height = Math.round(out.global.height); + } + + return out; +}; + +module.exports = GetBitmapTextSize; + + +/***/ }), +/* 272 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +//! stable.js 0.1.6, https://github.com/Two-Screen/stable +//! © 2017 Angry Bytes and contributors. MIT licensed. + +(function() { + +// A stable array sort, because `Array#sort()` is not guaranteed stable. +// This is an implementation of merge sort, without recursion. + +var stable = function(arr, comp) { + return exec(arr.slice(), comp); +}; + +stable.inplace = function(arr, comp) { + var result = exec(arr, comp); + + // This simply copies back if the result isn't in the original array, + // which happens on an odd number of passes. + if (result !== arr) { + pass(result, null, arr.length, arr); + } + + return arr; +}; + +// Execute the sort using the input array and a second buffer as work space. +// Returns one of those two, containing the final result. +function exec(arr, comp) { + if (typeof(comp) !== 'function') { + comp = function(a, b) { + return String(a).localeCompare(b); + }; + } + + // Short-circuit when there's nothing to sort. + var len = arr.length; + if (len <= 1) { + return arr; + } + + // Rather than dividing input, simply iterate chunks of 1, 2, 4, 8, etc. + // Chunks are the size of the left or right hand in merge sort. + // Stop when the left-hand covers all of the array. + var buffer = new Array(len); + for (var chk = 1; chk < len; chk *= 2) { + pass(arr, comp, chk, buffer); + + var tmp = arr; + arr = buffer; + buffer = tmp; + } + + return arr; +} + +// Run a single pass with the given chunk size. +var pass = function(arr, comp, chk, result) { + var len = arr.length; + var i = 0; + // Step size / double chunk size. + var dbl = chk * 2; + // Bounds of the left and right chunks. + var l, r, e; + // Iterators over the left and right chunk. + var li, ri; + + // Iterate over pairs of chunks. + for (l = 0; l < len; l += dbl) { + r = l + chk; + e = r + chk; + if (r > len) r = len; + if (e > len) e = len; + + // Iterate both chunks in parallel. + li = l; + ri = r; + while (true) { + // Compare the chunks. + if (li < r && ri < e) { + // This works for a regular `sort()` compatible comparator, + // but also for a simple comparator like: `a > b` + if (comp(arr[li], arr[ri]) <= 0) { + result[i++] = arr[li++]; + } + else { + result[i++] = arr[ri++]; + } + } + // Nothing to compare, just flush what's left. + else if (li < r) { + result[i++] = arr[li++]; + } + else if (ri < e) { + result[i++] = arr[ri++]; + } + // Both iterators are at the chunk ends. + else { + break; + } + } + } +}; + +// Export using CommonJS or to the window. +if (true) { + module.exports = stable; +} +else {} + +})(); + +/***/ }), +/* 273 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + var Class = __webpack_require__(0); -var BaseSound = __webpack_require__(85); +var CONST = __webpack_require__(21); +var IsSizePowerOfTwo = __webpack_require__(145); +var ScaleModes = __webpack_require__(80); + +/** + * @classdesc + * A Texture Source is the encapsulation of the actual source data for a Texture. + * This is typically an Image Element, loaded from the file system or network, or a Canvas Element. + * + * A Texture can contain multiple Texture Sources, which only happens when a multi-atlas is loaded. + * + * @class TextureSource + * @memberOf Phaser.Textures + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture this TextureSource belongs to. + * @param {(Image|HTMLCanvasElement)} source - The source image data. + * @param {integer} [width] - Optional width of the source image. If not given it's derived from the source itself. + * @param {integer} [height] - Optional height of the source image. If not given it's derived from the source itself. + */ +var TextureSource = new Class({ + + initialize: + + function TextureSource (texture, source, width, height) + { + var game = texture.manager.game; + + /** + * The Texture this TextureSource belongs to. + * + * @name Phaser.Textures.TextureSource#texture + * @type {string} + * @since 3.0.0 + */ + this.texture = texture; + + /** + * The source image data. This is either an Image Element, or a Canvas Element. + * + * @name Phaser.Textures.TextureSource#image + * @type {(HTMLImageElement|HTMLCanvasElement)} + * @since 3.0.0 + */ + this.image = source; + + /** + * Currently un-used. + * + * @name Phaser.Textures.TextureSource#compressionAlgorithm + * @type {integer} + * @default null + * @since 3.0.0 + */ + this.compressionAlgorithm = null; + + /** + * The resolution of the source image. + * + * @name Phaser.Textures.TextureSource#resolution + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.resolution = 1; + + /** + * The width of the source image. If not specified in the constructor it will check + * the `naturalWidth` and then `width` properties of the source image. + * + * @name Phaser.Textures.TextureSource#width + * @type {integer} + * @since 3.0.0 + */ + this.width = width || source.naturalWidth || source.width || 0; + + /** + * The height of the source image. If not specified in the constructor it will check + * the `naturalHeight` and then `height` properties of the source image. + * + * @name Phaser.Textures.TextureSource#height + * @type {integer} + * @since 3.0.0 + */ + this.height = height || source.naturalHeight || source.height || 0; + + /** + * The Scale Mode the image will use when rendering. + * Either Linear or Nearest. + * + * @name Phaser.Textures.TextureSource#scaleMode + * @type {number} + * @since 3.0.0 + */ + this.scaleMode = ScaleModes.DEFAULT; + + /** + * Is the source image a Canvas Element? + * + * @name Phaser.Textures.TextureSource#isCanvas + * @type {boolean} + * @since 3.0.0 + */ + this.isCanvas = (source instanceof HTMLCanvasElement); + + /** + * Are the source image dimensions a power of two? + * + * @name Phaser.Textures.TextureSource#isPowerOf2 + * @type {boolean} + * @since 3.0.0 + */ + this.isPowerOf2 = IsSizePowerOfTwo(this.width, this.height); + + /** + * The WebGL Texture of the source image. + * + * @name Phaser.Textures.TextureSource#glTexture + * @type {?WebGLTexture} + * @default null + * @since 3.0.0 + */ + this.glTexture = null; + + this.init(game); + }, + + /** + * Creates a WebGL Texture, if required, and sets the Texture filter mode. + * + * @method Phaser.Textures.TextureSource#init + * @since 3.0.0 + * + * @param {Phaser.Game} game - A reference to the Phaser Game instance. + */ + init: function (game) + { + if (game.config.renderType === CONST.WEBGL) + { + this.glTexture = game.renderer.createTextureFromSource(this.image, this.width, this.height, this.scaleMode); + } + + if (game.config.pixelArt) + { + this.setFilter(1); + } + }, + + /** + * Sets the Filter Mode for this Texture. + * + * The mode can be either Linear, the default, or Nearest. + * + * For pixel-art you should use Nearest. + * + * @method Phaser.Textures.TextureSource#setFilter + * @since 3.0.0 + * + * @param {(Phaser.Textures.LINEAR|Phaser.Textures.NEAREST)} filterMode - The Filter Mode. + */ + setFilter: function (filterMode) + { + var game = this.texture.manager.game; + + if (game.config.renderType === CONST.WEBGL) + { + game.renderer.setTextureFilter(this.glTexture, filterMode); + } + }, + + /** + * Destroys this Texture Source and nulls the source image reference. + * + * @method Phaser.Textures.TextureSource#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.texture = null; + + this.image = null; + } + +}); + +module.exports = TextureSource; + + +/***/ }), +/* 274 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Frame = __webpack_require__(141); +var TextureSource = __webpack_require__(273); + +/** + * @classdesc + * A Texture consists of a source, usually an Image from the Cache, or a Canvas, and a collection + * of Frames. The Frames represent the different areas of the Texture. For example a texture atlas + * may have many Frames, one for each element within the atlas. Where-as a single image would have + * just one frame, that encompasses the whole image. + * + * Textures are managed by the global TextureManager. This is a singleton class that is + * responsible for creating and delivering Textures and their corresponding Frames to Game Objects. + * + * Sprites and other Game Objects get the texture data they need from the TextureManager. + * + * @class Texture + * @memberOf Phaser.Textures + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Textures.TextureManager} manager - A reference to the Texture Manager this Texture belongs to. + * @param {string} key - The unique string-based key of this Texture. + * @param {(Image|HTMLCanvasElement)} source - The source that is used to create the texture. Usually an Image, but can also be a Canvas. + * @param {number} [width] - The width of the Texture. This is optional and automatically derived from the source images. + * @param {number} [height] - The height of the Texture. This is optional and automatically derived from the source images. + */ +var Texture = new Class({ + + initialize: + + function Texture (manager, key, source, width, height) + { + if (!Array.isArray(source)) + { + source = [ source ]; + } + + /** + * A reference to the Texture Manager this Texture belongs to. + * + * @name Phaser.Textures.Texture#manager + * @type {Phaser.Textures.TextureManager} + * @since 3.0.0 + */ + this.manager = manager; + + /** + * The unique string-based key of this Texture. + * + * @name Phaser.Textures.Texture#key + * @type {string} + * @since 3.0.0 + */ + this.key = key; + + /** + * An array of TextureSource instances. + * These are unique to this Texture and contain the actual Image (or Canvas) data. + * + * @name Phaser.Textures.Texture#source + * @type {Phaser.Textures.TextureSource[]} + * @since 3.0.0 + */ + this.source = []; + + /** + * An array of TextureSource data instances. + * Used to store additional data images, such as normal maps or specular maps. + * + * @name Phaser.Textures.Texture#dataSource + * @type {array} + * @since 3.0.0 + */ + this.dataSource = []; + + /** + * A key-value object pair associating the unique Frame keys with the Frames objects. + * + * @name Phaser.Textures.Texture#frames + * @type {object} + * @since 3.0.0 + */ + this.frames = {}; + + /** + * Any additional data that was set in the source JSON (if any), + * or any extra data you'd like to store relating to this texture + * + * @name Phaser.Textures.Texture#customData + * @type {object} + * @since 3.0.0 + */ + this.customData = {}; + + /** + * The name of the first frame of the Texture. + * + * @name Phaser.Textures.Texture#firstFrame + * @type {string} + * @since 3.0.0 + */ + this.firstFrame = '__BASE'; + + /** + * The total number of Frames in this Texture. + * + * @name Phaser.Textures.Texture#frameTotal + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.frameTotal = 0; + + // Load the Sources + for (var i = 0; i < source.length; i++) + { + this.source.push(new TextureSource(this, source[i], width, height)); + } + }, + + /** + * Adds a new Frame to this Texture. + * + * A Frame is a rectangular region of a TextureSource with a unique index or string-based key. + * + * @method Phaser.Textures.Texture#add + * @since 3.0.0 + * + * @param {(integer|string)} name - The name of this Frame. The name is unique within the Texture. + * @param {integer} sourceIndex - The index of the TextureSource that this Frame is a part of. + * @param {number} x - The x coordinate of the top-left of this Frame. + * @param {number} y - The y coordinate of the top-left of this Frame. + * @param {number} width - The width of this Frame. + * @param {number} height - The height of this Frame. + * + * @return {Phaser.Textures.Frame} The Frame that was added to this Texture. + */ + add: function (name, sourceIndex, x, y, width, height) + { + var frame = new Frame(this, name, sourceIndex, x, y, width, height); + + this.frames[name] = frame; + + // Set the first frame of the Texture (other than __BASE) + // This is used to ensure we don't spam the display with entire + // atlases of sprite sheets, but instead just the first frame of them + // should the dev incorrectly specify the frame index + if (this.frameTotal === 1) + { + this.firstFrame = name; + } + + this.frameTotal++; + + return frame; + }, + + /** + * Checks to see if a Frame matching the given key exists within this Texture. + * + * @method Phaser.Textures.Texture#has + * @since 3.0.0 + * + * @param {string} name - The key of the Frame to check for. + * + * @return {boolean} True if a Frame with the matching key exists in this Texture. + */ + has: function (name) + { + return (this.frames[name]); + }, + + /** + * Gets a Frame from this Texture based on either the key or the index of the Frame. + * + * In a Texture Atlas Frames are typically referenced by a key. + * In a Sprite Sheet Frames are referenced by an index. + * Passing no value for the name returns the base texture. + * + * @method Phaser.Textures.Texture#get + * @since 3.0.0 + * + * @param {(string|integer)} [name] - The string-based name, or integer based index, of the Frame to get from this Texture. + * + * @return {Phaser.Textures.Frame} The Texture Frame. + */ + get: function (name) + { + // null, undefined, empty string, zero + if (!name) + { + name = this.firstFrame; + } + + var frame = this.frames[name]; + + if (!frame) + { + console.warn('No Texture.frame found with name ' + name); + + frame = this.frames[this.firstFrame]; + } + + return frame; + }, + + /** + * Takes the given TextureSource and returns the index of it within this Texture. + * If it's not in this Texture, it returns -1. + * Unless this Texture has multiple TextureSources, such as with a multi-atlas, this + * method will always return zero or -1. + * + * @method Phaser.Textures.Texture#getTextureSourceIndex + * @since 3.0.0 + * + * @param {Phaser.Textures.TextureSource} source - The TextureSource to check. + * + * @return {integer} The index of the TextureSource within this Texture, or -1 if not in this Texture. + */ + getTextureSourceIndex: function (source) + { + for (var i = 0; i < this.source.length; i++) + { + if (this.source[i] === source) + { + return i; + } + } + + return -1; + }, + + /** + * Returns an array of all the Frames in the given TextureSource. + * + * @method Phaser.Textures.Texture#getFramesFromTextureSource + * @since 3.0.0 + * + * @param {integer} sourceIndex - The index of the TextureSource to get the Frames from. + * + * @return {Phaser.Textures.Frame[]} An array of Texture Frames. + */ + getFramesFromTextureSource: function (sourceIndex) + { + var out = []; + + for (var frameName in this.frames) + { + if (frameName === '__BASE') + { + continue; + } + + var frame = this.frames[frameName]; + + if (frame.sourceIndex === sourceIndex) + { + out.push(frame.name); + } + } + + return out; + }, + + /** + * Returns an array with all of the names of the Frames in this Texture. + * + * Useful if you want to randomly assign a Frame to a Game Object, as you can + * pick a random element from the returned array. + * + * @method Phaser.Textures.Texture#getFrameNames + * @since 3.0.0 + * + * @param {boolean} [includeBase=false] - Include the `__BASE` Frame in the output array? + * + * @return {string[]} An array of all Frame names in this Texture. + */ + getFrameNames: function (includeBase) + { + if (includeBase === undefined) { includeBase = false; } + + var out = Object.keys(this.frames); + + if (!includeBase) + { + var idx = out.indexOf('__BASE'); + + if (idx !== -1) + { + out.splice(idx, 1); + } + } + + return out; + }, + + /** + * Given a Frame name, return the source image it uses to render with. + * + * This will return the actual DOM Image or Canvas element. + * + * @method Phaser.Textures.Texture#getSourceImage + * @since 3.0.0 + * + * @param {(string|integer)} [name] - The string-based name, or integer based index, of the Frame to get from this Texture. + * + * @return {(HTMLImageElement|HTMLCanvasElement)} The DOM Image or Canvas Element. + */ + getSourceImage: function (name) + { + if (name === undefined || name === null || this.frameTotal === 1) + { + name = '__BASE'; + } + + var frame = this.frames[name]; + + if (!frame) + { + console.warn('No Texture.frame found with name ' + name); + + return this.frames['__BASE'].source.image; + } + else + { + return frame.source.image; + } + }, + + /** + * Adds a data source image to this Texture. + * + * An example of a data source image would be a normal map, where all of the Frames for this Texture + * equally apply to the normal map. + * + * @method Phaser.Textures.Texture#setDataSource + * @since 3.0.0 + * + * @param {(Image|HTMLCanvasElement)} data - The source image. + */ + setDataSource: function (data) + { + if (!Array.isArray(data)) + { + data = [ data ]; + } + + for (var i = 0; i < data.length; i++) + { + var source = this.source[i]; + + this.dataSource.push(new TextureSource(this, data[i], source.width, source.height)); + } + }, + + /** + * Sets the Filter Mode for this Texture. + * + * The mode can be either Linear, the default, or Nearest. + * + * For pixel-art you should use Nearest. + * + * The mode applies to the entire Texture, not just a specific Frame of it. + * + * @method Phaser.Textures.Texture#setFilter + * @since 3.0.0 + * + * @param {(Phaser.Textures.LINEAR|Phaser.Textures.NEAREST)} filterMode - The Filter Mode. + */ + setFilter: function (filterMode) + { + var i; + + for (i = 0; i < this.source.length; i++) + { + this.source[i].setFilter(filterMode); + } + + for (i = 0; i < this.dataSource.length; i++) + { + this.dataSource[i].setFilter(filterMode); + } + }, + + /** + * Destroys this Texture and releases references to its sources and frames. + * + * @method Phaser.Textures.Texture#destroy + * @since 3.0.0 + */ + destroy: function () + { + var i; + + for (i = 0; i < this.source.length; i++) + { + this.source[i].destroy(); + } + + for (i = 0; i < this.dataSource.length; i++) + { + this.dataSource[i].destroy(); + } + + for (var frameName in this.frames) + { + var frame = this.frames[frameName]; + + frame.destroy(); + } + + this.source = []; + this.dataSource = []; + this.frames = {}; + } + +}); + +module.exports = Texture; + + +/***/ }), +/* 275 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Textures.Parsers + */ + +module.exports = { + + Canvas: __webpack_require__(794), + Image: __webpack_require__(793), + JSONArray: __webpack_require__(792), + JSONHash: __webpack_require__(791), + Pyxel: __webpack_require__(790), + SpriteSheet: __webpack_require__(789), + SpriteSheetFromAtlas: __webpack_require__(788), + StarlingXML: __webpack_require__(787), + UnityYAML: __webpack_require__(786) + +}; + + +/***/ }), +/* 276 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasPool = __webpack_require__(23); +var Class = __webpack_require__(0); +var Color = __webpack_require__(41); +var EventEmitter = __webpack_require__(15); +var GenerateTexture = __webpack_require__(323); +var GetValue = __webpack_require__(5); +var Parser = __webpack_require__(275); +var Texture = __webpack_require__(274); + +/** + * @callback EachTextureCallback + * + * @param {Phaser.Textures.Texture} texture - [description] + * @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the child. + */ + +/** + * @classdesc + * Textures are managed by the global TextureManager. This is a singleton class that is + * responsible for creating and delivering Textures and their corresponding Frames to Game Objects. + * + * Sprites and other Game Objects get the texture data they need from the TextureManager. + * + * Access it via `scene.textures`. + * + * @class TextureManager + * @extends EventEmitter + * @memberOf Phaser.Textures + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - [description] + */ +var TextureManager = new Class({ + + Extends: EventEmitter, + + initialize: + + function TextureManager (game) + { + EventEmitter.call(this); + + /** + * [description] + * + * @name Phaser.Textures.TextureManager#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game = game; + + /** + * [description] + * + * @name Phaser.Textures.TextureManager#name + * @type {string} + * @since 3.0.0 + */ + this.name = 'TextureManager'; + + /** + * [description] + * + * @name Phaser.Textures.TextureManager#list + * @type {object} + * @default {} + * @since 3.0.0 + */ + this.list = {}; + + /** + * [description] + * + * @name Phaser.Textures.TextureManager#_tempCanvas + * @type {HTMLCanvasElement} + * @private + * @since 3.0.0 + */ + this._tempCanvas = CanvasPool.create2D(this, 1, 1); + + /** + * [description] + * + * @name Phaser.Textures.TextureManager#_tempContext + * @type {CanvasRenderingContext2D} + * @private + * @since 3.0.0 + */ + this._tempContext = this._tempCanvas.getContext('2d'); + + /** + * [description] + * + * @name Phaser.Textures.TextureManager#_pending + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + this._pending = 0; + + game.events.once('boot', this.boot, this); + }, + + /** + * [description] + * + * @method Phaser.Textures.TextureManager#boot + * @since 3.0.0 + */ + boot: function () + { + this._pending = 2; + + this.on('onload', this.updatePending, this); + this.on('onerror', this.updatePending, this); + + this.addBase64('__DEFAULT', this.game.config.defaultImage); + this.addBase64('__MISSING', this.game.config.missingImage); + + this.game.events.once('destroy', this.destroy, this); + }, + + /** + * [description] + * + * @method Phaser.Textures.TextureManager#updatePending + * @since 3.0.0 + */ + updatePending: function () + { + this._pending--; + + if (this._pending === 0) + { + this.off('onload'); + this.off('onerror'); + + this.game.events.emit('ready'); + } + }, + + /** + * Adds a new Texture to the Texture Manager created from the given Base64 encoded data. + * + * @method Phaser.Textures.TextureManager#addBase64 + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {*} data - The Base64 encoded data. + */ + addBase64: function (key, data) + { + var _this = this; + + var image = new Image(); + + image.onerror = function () + { + _this.emit('onerror', key); + }; + + image.onload = function () + { + var texture = _this.create(key, image); + + Parser.Image(texture, 0); + + _this.emit('onload', key, texture); + }; + + image.src = data; + }, + + /** + * Adds a new Texture to the Texture Manager created from the given Image element. + * + * @method Phaser.Textures.TextureManager#addImage + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {HTMLImageElement} [dataSource] - An optional data Image element. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + addImage: function (key, source, dataSource) + { + var texture = this.create(key, source); + + Parser.Image(texture, 0); + + if (dataSource) + { + texture.setDataSource(dataSource); + } + + return texture; + }, + + /** + * Creates a new Texture using the given config values. + * Generated textures consist of a Canvas element to which the texture data is drawn. + * See the Phaser.Create function for the more direct way to create textures. + * + * @method Phaser.Textures.TextureManager#generate + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {object} config - [description] + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + generate: function (key, config) + { + var canvas = CanvasPool.create(this, 1, 1); + + config.canvas = canvas; + + GenerateTexture(config); + + return this.addCanvas(key, canvas); + }, + + /** + * Creates a new Texture using a blank Canvas element of the size given. + * + * Canvas elements are automatically pooled and calling this method will + * extract a free canvas from the CanvasPool, or create one if none are available. + * + * @method Phaser.Textures.TextureManager#createCanvas + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {integer} width - The width of the Canvas element. + * @param {integer} height - The height of the Canvas element. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + createCanvas: function (key, width, height) + { + if (width === undefined) { width = 256; } + if (height === undefined) { height = 256; } + + var canvas = CanvasPool.create(this, width, height); + + return this.addCanvas(key, canvas); + }, + + /** + * Creates a new Texture object from an existing Canvas element and adds + * it to this Texture Manager. + * + * @method Phaser.Textures.TextureManager#addCanvas + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLCanvasElement} source - The Canvas element to form the base of the new Texture. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + addCanvas: function (key, source) + { + var texture = this.create(key, source); + + Parser.Canvas(texture, 0); + + return texture; + }, + + /** + * Adds a new Texture Atlas to this Texture Manager. + * It can accept either JSON Array or JSON Hash formats, as exported by Texture Packer and similar software. + * + * @method Phaser.Textures.TextureManager#addAtlas + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {object} data - The Texture Atlas data. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + addAtlas: function (key, source, data) + { + // New Texture Packer format? + if (Array.isArray(data.textures) || Array.isArray(data.frames)) + { + return this.addAtlasJSONArray(key, source, data); + } + else + { + return this.addAtlasJSONHash(key, source, data); + } + }, + + /** + * Adds a Texture Atlas to this Texture Manager. + * The frame data of the atlas must be stored in an Array within the JSON. + * This is known as a JSON Array in software such as Texture Packer. + * + * @method Phaser.Textures.TextureManager#addAtlasJSONArray + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {object} data - The Texture Atlas data. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + addAtlasJSONArray: function (key, source, data) + { + var texture = this.create(key, source); + + if (Array.isArray(data)) + { + var singleAtlasFile = (data.length === 1); // multi-pack with one atlas file for all images + for (var i = 0; i < texture.source.length; i++) + { + var atlasData = singleAtlasFile ? data[0] : data[i]; + Parser.JSONArray(texture, i, atlasData); + } + } + else + { + Parser.JSONArray(texture, 0, data); + } + + return texture; + }, + + /** + * Adds a Texture Atlas to this Texture Manager. + * The frame data of the atlas must be stored in an Object within the JSON. + * This is known as a JSON Hash in software such as Texture Packer. + * + * @method Phaser.Textures.TextureManager#addAtlasJSONHash + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {object} data - The Texture Atlas data. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + addAtlasJSONHash: function (key, source, data) + { + var texture = this.create(key, source); + + if (Array.isArray(data)) + { + for (var i = 0; i < data.length; i++) + { + Parser.JSONHash(texture, i, data[i]); + } + } + else + { + Parser.JSONHash(texture, 0, data); + } + + return texture; + }, + + /** + * Adds a Unity Texture Atlas to this Texture Manager. + * The data must be in the form of a Unity YAML file. + * + * @method Phaser.Textures.TextureManager#addUnityAtlas + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {object} data - The Texture Atlas data. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + addUnityAtlas: function (key, source, data) + { + var texture = this.create(key, source); + + Parser.UnityYAML(texture, 0, data); + + return texture; + }, + + /** + * Adds a Sprite Sheet to this Texture Manager. + * + * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact + * same size and cannot be trimmed or rotated. + * + * @method Phaser.Textures.TextureManager#addSpriteSheet + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {object} config - The configuration object for this Sprite Sheet. + * @param {integer} config.frameWidth - The fixed width of each frame. + * @param {integer} [config.frameHeight] - The fixed height of each frame. If not set it will use the frameWidth as the height. + * @param {integer} [config.startFrame=0] - Skip a number of frames. Useful when there are multiple sprite sheets in one Texture. + * @param {integer} [config.endFrame=-1] - The total number of frames to extract from the Sprite Sheet. The default value of -1 means "extract all frames". + * @param {integer} [config.margin=0] - If the frames have been drawn with a margin, specify the amount here. + * @param {integer} [config.spacing=0] - If the frames have been drawn with spacing between them, specify the amount here. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + addSpriteSheet: function (key, source, config) + { + var texture = this.create(key, source); + + var width = texture.source[0].width; + var height = texture.source[0].height; + + Parser.SpriteSheet(texture, 0, 0, 0, width, height, config); + + return texture; + }, + + /** + * Adds a Sprite Sheet to this Texture Manager, where the Sprite Sheet exists as a Frame within a Texture Atlas. + * + * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact + * same size and cannot be trimmed or rotated. + * + * @method Phaser.Textures.TextureManager#addSpriteSheetFromAtlas + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {object} config - The configuration object for this Sprite Sheet. + * @param {string} config.atlas - The key of the Texture Atlas in which this Sprite Sheet can be found. + * @param {string} config.frame - The key of the Texture Atlas Frame in which this Sprite Sheet can be found. + * @param {integer} config.frameWidth - The fixed width of each frame. + * @param {integer} [config.frameHeight] - The fixed height of each frame. If not set it will use the frameWidth as the height. + * @param {integer} [config.startFrame=0] - Skip a number of frames. Useful when there are multiple sprite sheets in one Texture. + * @param {integer} [config.endFrame=-1] - The total number of frames to extract from the Sprite Sheet. The default value of -1 means "extract all frames". + * @param {integer} [config.margin=0] - If the frames have been drawn with a margin, specify the amount here. + * @param {integer} [config.spacing=0] - If the frames have been drawn with spacing between them, specify the amount here. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + addSpriteSheetFromAtlas: function (key, config) + { + var atlasKey = GetValue(config, 'atlas', null); + var atlasFrame = GetValue(config, 'frame', null); + + if (!atlasKey || !atlasFrame) + { + return; + } + + var atlas = this.get(atlasKey); + var sheet = atlas.get(atlasFrame); + + if (sheet) + { + var texture = this.create(key, sheet.source.image); + + if (sheet.trimmed) + { + // If trimmed we need to help the parser adjust + Parser.SpriteSheetFromAtlas(texture, sheet, config); + } + else + { + Parser.SpriteSheet(texture, 0, sheet.cutX, sheet.cutY, sheet.cutWidth, sheet.cutHeight, config); + } + + return texture; + } + }, + + /** + * Adds a Texture Atlas to this Texture Manager, where the atlas data is given + * in the Starling XML format. + * + * @method Phaser.Textures.TextureManager#addAtlasStarlingXML + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {object} data - The Texture Atlas XML data. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + addAtlasStarlingXML: function (key, source, data) + { + var texture = this.create(key, source); + + if (Array.isArray(data)) + { + for (var i = 0; i < data.length; i++) + { + Parser.StarlingXML(texture, i, data[i]); + } + } + else + { + Parser.StarlingXML(texture, 0, data); + } + + return texture; + }, + + /** + * Adds a Texture Atlas to this Texture Manager, where the atlas data is given + * in the Pyxel JSON format. + * + * @method Phaser.Textures.TextureManager#addAtlasPyxel + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {object} data - The Texture Atlas XML data. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + addAtlasPyxel: function (key, source, data) + { + var texture = this.create(key, source); + + if (Array.isArray(data)) + { + for (var i = 0; i < data.length; i++) + { + Parser.Pyxel(texture, i, data[i]); + } + } + else + { + Parser.Pyxel(texture, 0, data); + } + + return texture; + }, + + /** + * Creates a new Texture using the given source and dimensions. + * + * @method Phaser.Textures.TextureManager#create + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {integer} width - The width of the Texture. + * @param {integer} height - The height of the Texture. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + create: function (key, source, width, height) + { + var texture = new Texture(this, key, source, width, height); + + this.list[key] = texture; + + return texture; + }, + + /** + * Checks the given key to see if a Texture using it exists within this Texture Manager. + * + * @method Phaser.Textures.TextureManager#exists + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * + * @return {boolean} Returns `true` if a Texture matching the given key exists in this Texture Manager. + */ + exists: function (key) + { + return (this.list.hasOwnProperty(key)); + }, + + /** + * Returns a Texture from the Texture Manager that matches the given key. + * If the key is undefined it will return the `__DEFAULT` Texture. + * If the key is given, but not found, it will return the `__MISSING` Texture. + * + * @method Phaser.Textures.TextureManager#get + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + get: function (key) + { + if (key === undefined) { key = '__DEFAULT'; } + + if (this.list[key]) + { + return this.list[key]; + } + else + { + return this.list['__MISSING']; + } + }, + + /** + * Takes a Texture key and Frame name and returns a clone of that Frame if found. + * + * @method Phaser.Textures.TextureManager#cloneFrame + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {(string|integer)} frame - The string or index of the Frame to be cloned. + * + * @return {Phaser.Textures.Frame} A Clone of the given Frame. + */ + cloneFrame: function (key, frame) + { + if (this.list[key]) + { + return this.list[key].get(frame).clone(); + } + }, + + /** + * Takes a Texture key and Frame name and returns a reference to that Frame, if found. + * + * @method Phaser.Textures.TextureManager#getFrame + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {(string|integer)} frame - The string or index of the Frame. + * + * @return {Phaser.Textures.Frame} A Texture Frame object. + */ + getFrame: function (key, frame) + { + if (this.list[key]) + { + return this.list[key].get(frame); + } + }, + + /** + * Returns an array with all of the keys of all Textures in this Texture Manager. + * The output array will exclude the `__DEFAULT` and `__MISSING` keys. + * + * @method Phaser.Textures.TextureManager#getTextureKeys + * @since 3.0.0 + * + * @return {string[]} An array containing all of the Texture keys stored in this Texture Manager. + */ + getTextureKeys: function () + { + var output = []; + + for (var key in this.list) + { + if (key !== '__DEFAULT' && key !== '__MISSING') + { + output.push(key); + } + } + + return output; + }, + + /** + * Given a Texture and an `x` and `y` coordinate this method will return a new + * Color object that has been populated with the color and alpha values of the pixel + * at that location in the Texture. + * + * @method Phaser.Textures.TextureManager#getPixel + * @since 3.0.0 + * + * @param {integer} x - The x coordinate of the pixel within the Texture. + * @param {integer} y - The y coordinate of the pixel within the Texture. + * @param {string} key - The unique string-based key of the Texture. + * @param {(string|integer)} frame - The string or index of the Frame. + * + * @return {?Phaser.Display.Color} A Color object populated with the color values of the requested pixel, + * or `null` if the coordinates were out of bounds. + */ + getPixel: function (x, y, key, frame) + { + var textureFrame = this.getFrame(key, frame); + + if (textureFrame) + { + var source = textureFrame.source.image; + + if (x >= 0 && x <= source.width && y >= 0 && y <= source.height) + { + x += textureFrame.cutX; + y += textureFrame.cutY; + + // if (textureFrame.trimmed) + // { + // x -= this.sprite.texture.trim.x; + // y -= this.sprite.texture.trim.y; + // } + + var context = this._tempContext; + + context.clearRect(0, 0, 1, 1); + context.drawImage(source, x, y, 1, 1, 0, 0, 1, 1); + + var rgb = context.getImageData(0, 0, 1, 1); + + return new Color(rgb.data[0], rgb.data[1], rgb.data[2], rgb.data[3]); + } + } + + return null; + }, + + /** + * Sets the given Game Objects `texture` and `frame` properties so that it uses + * the Texture and Frame specified in the `key` and `frame` arguments to this method. + * + * @method Phaser.Textures.TextureManager#setTexture + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * @param {string} key - The unique string-based key of the Texture. + * @param {(string|integer)} frame - The string or index of the Frame. + * + * @return {Phaser.GameObjects.GameObject} The Game Object the texture was set on. + */ + setTexture: function (gameObject, key, frame) + { + if (this.list[key]) + { + gameObject.texture = this.list[key]; + gameObject.frame = gameObject.texture.get(frame); + } + + return gameObject; + }, + + /** + * Passes all Textures to the given callback. + * + * @method Phaser.Textures.TextureManager#each + * @since 3.0.0 + * + * @param {EachTextureCallback} callback - The callback function to be sent the Textures. + * @param {object} scope - The value to use as `this` when executing the callback. + * @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the child. + */ + each: function (callback, scope) + { + var args = [ null ]; + + for (var i = 1; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (var texture in this.list) + { + args[0] = this.list[texture]; + + callback.apply(scope, args); + } + }, + + /** + * Destroys the Texture Manager and all Textures stored within it. + * + * @method Phaser.Textures.TextureManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + for (var texture in this.list) + { + this.list[texture].destroy(); + } + + this.list = {}; + + this.game = null; + } + +}); + +module.exports = TextureManager; + + +/***/ }), +/* 277 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ +var Class = __webpack_require__(0); +var BaseSound = __webpack_require__(98); + +/** + * @classdesc + * Web Audio API implementation of the sound. + * + * @class WebAudioSound + * @extends Phaser.Sound.BaseSound + * @memberOf Phaser.Sound + * @constructor + * @author Pavle Goloskokovic (http://prunegames.com) + * @since 3.0.0 + * + * @param {Phaser.Sound.WebAudioSoundManager} manager - Reference to the current sound manager instance. + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config={}] - An optional config object containing default sound settings. + */ +var WebAudioSound = new Class({ + Extends: BaseSound, + initialize: function WebAudioSound (manager, key, config) + { + if (config === void 0) { config = {}; } + + /** + * Audio buffer containing decoded data of the audio asset to be played. + * + * @name Phaser.Sound.WebAudioSound#audioBuffer + * @type {AudioBuffer} + * @private + * @since 3.0.0 + */ + this.audioBuffer = manager.game.cache.audio.get(key); + if (!this.audioBuffer) + { + // eslint-disable-next-line no-console + console.error('No audio loaded in cache with key: \'' + key + '\'!'); + return; + } + + /** + * A reference to an audio source node used for playing back audio from + * audio data stored in Phaser.Sound.WebAudioSound#audioBuffer. + * + * @name Phaser.Sound.WebAudioSound#source + * @type {AudioBufferSourceNode} + * @private + * @default null + * @since 3.0.0 + */ + this.source = null; + + /** + * A reference to a second audio source used for gapless looped playback. + * + * @name Phaser.Sound.WebAudioSound#loopSource + * @type {AudioBufferSourceNode} + * @private + * @default null + * @since 3.0.0 + */ + this.loopSource = null; + + /** + * Gain node responsible for controlling this sound's muting. + * + * @name Phaser.Sound.WebAudioSound#muteNode + * @type {GainNode} + * @private + * @since 3.0.0 + */ + this.muteNode = manager.context.createGain(); + + /** + * Gain node responsible for controlling this sound's volume. + * + * @name Phaser.Sound.WebAudioSound#volumeNode + * @type {GainNode} + * @private + * @since 3.0.0 + */ + this.volumeNode = manager.context.createGain(); + + /** + * The time at which the sound should have started playback from the beginning. + * Based on BaseAudioContext.currentTime value. + * + * @name Phaser.Sound.WebAudioSound#playTime + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.playTime = 0; + + /** + * The time at which the sound source should have actually started playback. + * Based on BaseAudioContext.currentTime value. + * + * @name Phaser.Sound.WebAudioSound#startTime + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.startTime = 0; + + /** + * The time at which the sound loop source should actually start playback. + * Based on BaseAudioContext.currentTime value. + * + * @name Phaser.Sound.WebAudioSound#loopTime + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.loopTime = 0; + + /** + * An array where we keep track of all rate updates during playback. + * Array of object types: { time: number, rate: number } + * + * @name Phaser.Sound.WebAudioSound#rateUpdates + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this.rateUpdates = []; + + /** + * Used for keeping track when sound source playback has ended + * so its state can be updated accordingly. + * + * @name Phaser.Sound.WebAudioSound#hasEnded + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this.hasEnded = false; + + /** + * Used for keeping track when sound source has looped + * so its state can be updated accordingly. + * + * @name Phaser.Sound.WebAudioSound#hasLooped + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this.hasLooped = false; + this.muteNode.connect(this.volumeNode); + this.volumeNode.connect(manager.destination); + this.duration = this.audioBuffer.duration; + this.totalDuration = this.audioBuffer.duration; + BaseSound.call(this, manager, key, config); + }, + + /** + * Play this sound, or a marked section of it. + * It always plays the sound from the start. If you want to start playback from a specific time + * you can set 'seek' setting of the config object, provided to this call, to that value. + * + * @method Phaser.Sound.WebAudioSound#play + * @since 3.0.0 + * + * @param {string} [markerName=''] - If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. + * @param {SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. + * + * @return {boolean} Whether the sound started playing successfully. + */ + play: function (markerName, config) + { + if (!BaseSound.prototype.play.call(this, markerName, config)) + { + return false; + } + + // \/\/\/ isPlaying = true, isPaused = false \/\/\/ + this.stopAndRemoveBufferSource(); + this.createAndStartBufferSource(); + + /** + * @event Phaser.Sound.WebAudioSound#play + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + */ + this.emit('play', this); + return true; + }, + + /** + * Pauses the sound. + * + * @method Phaser.Sound.WebAudioSound#pause + * @since 3.0.0 + * + * @return {boolean} Whether the sound was paused successfully. + */ + pause: function () + { + if (this.manager.context.currentTime < this.startTime) + { + return false; + } + if (!BaseSound.prototype.pause.call(this)) + { + return false; + } + + // \/\/\/ isPlaying = false, isPaused = true \/\/\/ + this.currentConfig.seek = this.getCurrentTime(); // Equivalent to setting paused time + this.stopAndRemoveBufferSource(); + + /** + * @event Phaser.Sound.WebAudioSound#pause + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + */ + this.emit('pause', this); + return true; + }, + + /** + * Resumes the sound. + * + * @method Phaser.Sound.WebAudioSound#resume + * @since 3.0.0 + * + * @return {boolean} Whether the sound was resumed successfully. + */ + resume: function () + { + if (this.manager.context.currentTime < this.startTime) + { + return false; + } + if (!BaseSound.prototype.resume.call(this)) + { + return false; + } + + // \/\/\/ isPlaying = true, isPaused = false \/\/\/ + this.createAndStartBufferSource(); + + /** + * @event Phaser.Sound.WebAudioSound#resume + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + */ + this.emit('resume', this); + return true; + }, + + /** + * Stop playing this sound. + * + * @method Phaser.Sound.WebAudioSound#stop + * @since 3.0.0 + * + * @return {boolean} Whether the sound was stopped successfully. + */ + stop: function () + { + if (!BaseSound.prototype.stop.call(this)) + { + return false; + } + + // \/\/\/ isPlaying = false, isPaused = false \/\/\/ + this.stopAndRemoveBufferSource(); + + /** + * @event Phaser.Sound.WebAudioSound#stop + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + */ + this.emit('stop', this); + return true; + }, + + /** + * Used internally to do what the name says. + * + * @method Phaser.Sound.WebAudioSound#createAndStartBufferSource + * @private + * @since 3.0.0 + */ + createAndStartBufferSource: function () + { + var seek = this.currentConfig.seek; + var delay = this.currentConfig.delay; + var when = this.manager.context.currentTime + delay; + var offset = (this.currentMarker ? this.currentMarker.start : 0) + seek; + var duration = this.duration - seek; + this.playTime = when - seek; + this.startTime = when; + this.source = this.createBufferSource(); + this.applyConfig(); + this.source.start(Math.max(0, when), Math.max(0, offset), Math.max(0, duration)); + this.resetConfig(); + }, + + /** + * Used internally to do what the name says. + * + * @method Phaser.Sound.WebAudioSound#createAndStartLoopBufferSource + * @private + * @since 3.0.0 + */ + createAndStartLoopBufferSource: function () + { + var when = this.getLoopTime(); + var offset = this.currentMarker ? this.currentMarker.start : 0; + var duration = this.duration; + this.loopTime = when; + this.loopSource = this.createBufferSource(); + this.loopSource.playbackRate.setValueAtTime(this.totalRate, 0); + this.loopSource.start(Math.max(0, when), Math.max(0, offset), Math.max(0, duration)); + }, + + /** + * Used internally to do what the name says. + * + * @method Phaser.Sound.WebAudioSound#createBufferSource + * @private + * @since 3.0.0 + * + * @return {AudioBufferSourceNode} + */ + createBufferSource: function () + { + var _this = this; + var source = this.manager.context.createBufferSource(); + source.buffer = this.audioBuffer; + source.connect(this.muteNode); + source.onended = function (ev) + { + if (ev.target === _this.source) + { + // sound ended + if (_this.currentConfig.loop) + { + _this.hasLooped = true; + } + else + { + _this.hasEnded = true; + } + } + + // else was stopped + }; + return source; + }, + + /** + * Used internally to do what the name says. + * + * @method Phaser.Sound.WebAudioSound#stopAndRemoveBufferSource + * @private + * @since 3.0.0 + */ + stopAndRemoveBufferSource: function () + { + if (this.source) + { + this.source.stop(); + this.source.disconnect(); + this.source = null; + } + this.playTime = 0; + this.startTime = 0; + this.stopAndRemoveLoopBufferSource(); + }, + + /** + * Used internally to do what the name says. + * + * @method Phaser.Sound.WebAudioSound#stopAndRemoveLoopBufferSource + * @private + * @since 3.0.0 + */ + stopAndRemoveLoopBufferSource: function () + { + if (this.loopSource) + { + this.loopSource.stop(); + this.loopSource.disconnect(); + this.loopSource = null; + } + this.loopTime = 0; + }, + + /** + * Method used internally for applying config values to some of the sound properties. + * + * @method Phaser.Sound.WebAudioSound#applyConfig + * @protected + * @since 3.0.0 + */ + applyConfig: function () + { + this.rateUpdates.length = 0; + this.rateUpdates.push({ + time: 0, + rate: 1 + }); + BaseSound.prototype.applyConfig.call(this); + }, + + /** + * Update method called automatically by sound manager on every game step. + * + * @method Phaser.Sound.WebAudioSound#update + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time elapsed since the last frame. + */ + // eslint-disable-next-line no-unused-vars + update: function (time, delta) + { + if (this.hasEnded) + { + this.hasEnded = false; + BaseSound.prototype.stop.call(this); + this.stopAndRemoveBufferSource(); + + /** + * @event Phaser.Sound.WebAudioSound#ended + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + */ + this.emit('ended', this); + } + else if (this.hasLooped) + { + this.hasLooped = false; + this.source = this.loopSource; + this.loopSource = null; + this.playTime = this.startTime = this.loopTime; + this.rateUpdates.length = 0; + this.rateUpdates.push({ + time: 0, + rate: this.totalRate + }); + this.createAndStartLoopBufferSource(); + + /** + * @event Phaser.Sound.WebAudioSound#looped + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + */ + this.emit('looped', this); + } + }, + + /** + * Calls Phaser.Sound.BaseSound#destroy method + * and cleans up all Web Audio API related stuff. + * + * @method Phaser.Sound.WebAudioSound#destroy + * @since 3.0.0 + */ + destroy: function () + { + BaseSound.prototype.destroy.call(this); + this.audioBuffer = null; + this.stopAndRemoveBufferSource(); + this.muteNode.disconnect(); + this.muteNode = null; + this.volumeNode.disconnect(); + this.volumeNode = null; + this.rateUpdates.length = 0; + this.rateUpdates = null; + }, + + /** + * Method used internally to calculate total playback rate of the sound. + * + * @method Phaser.Sound.WebAudioSound#setRate + * @protected + * @since 3.0.0 + */ + setRate: function () + { + BaseSound.prototype.setRate.call(this); + var now = this.manager.context.currentTime; + if (this.source) + { + this.source.playbackRate.setValueAtTime(this.totalRate, now); + } + if (this.isPlaying) + { + this.rateUpdates.push({ + time: Math.max(this.startTime, now) - this.playTime, + rate: this.totalRate + }); + if (this.loopSource) + { + this.stopAndRemoveLoopBufferSource(); + this.createAndStartLoopBufferSource(); + } + } + }, + + /** + * Method used internally for calculating current playback time of a playing sound. + * + * @method Phaser.Sound.WebAudioSound#getCurrentTime + * @private + * @since 3.0.0 + */ + getCurrentTime: function () + { + var currentTime = 0; + for (var i = 0; i < this.rateUpdates.length; i++) + { + var nextTime = void 0; + if (i < this.rateUpdates.length - 1) + { + nextTime = this.rateUpdates[i + 1].time; + } + else + { + nextTime = this.manager.context.currentTime - this.playTime; + } + currentTime += (nextTime - this.rateUpdates[i].time) * this.rateUpdates[i].rate; + } + return currentTime; + }, + + /** + * Method used internally for calculating the time + * at witch the loop source should start playing. + * + * @method Phaser.Sound.WebAudioSound#getLoopTime + * @private + * @since 3.0.0 + */ + getLoopTime: function () + { + var lastRateUpdateCurrentTime = 0; + for (var i = 0; i < this.rateUpdates.length - 1; i++) + { + lastRateUpdateCurrentTime += + (this.rateUpdates[i + 1].time - this.rateUpdates[i].time) * this.rateUpdates[i].rate; + } + var lastRateUpdate = this.rateUpdates[this.rateUpdates.length - 1]; + return this.playTime + lastRateUpdate.time + + (this.duration - lastRateUpdateCurrentTime) / lastRateUpdate.rate; + } +}); +Object.defineProperty(WebAudioSound.prototype, 'mute', { + get: function () + { + return this.muteNode.gain.value === 0; + }, + set: function (value) + { + this.currentConfig.mute = value; + this.muteNode.gain.setValueAtTime(value ? 0 : 1, 0); + + /** + * @event Phaser.Sound.WebAudioSound#mute + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + * @param {boolean} value - An updated value of Phaser.Sound.WebAudioSound#mute property. + */ + this.emit('mute', this, value); + } +}); +Object.defineProperty(WebAudioSound.prototype, 'volume', { + get: function () + { + return this.volumeNode.gain.value; + }, + set: function (value) + { + this.currentConfig.volume = value; + this.volumeNode.gain.setValueAtTime(value, 0); + + /** + * @event Phaser.Sound.WebAudioSound#volume + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + * @param {number} value - An updated value of Phaser.Sound.WebAudioSound#volume property. + */ + this.emit('volume', this, value); + } +}); +Object.defineProperty(WebAudioSound.prototype, 'seek', { + get: function () + { + if (this.isPlaying) + { + if (this.manager.context.currentTime < this.startTime) + { + return this.startTime - this.playTime; + } + return this.getCurrentTime(); + } + else if (this.isPaused) + { + return this.currentConfig.seek; + } + else + { + return 0; + } + }, + set: function (value) + { + if (this.manager.context.currentTime < this.startTime) + { + return; + } + if (this.isPlaying || this.isPaused) + { + value = Math.min(Math.max(0, value), this.duration); + this.currentConfig.seek = value; + if (this.isPlaying) + { + this.stopAndRemoveBufferSource(); + this.createAndStartBufferSource(); + } + + /** + * @event Phaser.Sound.WebAudioSound#seek + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + * @param {number} value - An updated value of Phaser.Sound.WebAudioSound#seek property. + */ + this.emit('seek', this, value); + } + } +}); +Object.defineProperty(WebAudioSound.prototype, 'loop', { + get: function () + { + return this.currentConfig.loop; + }, + set: function (value) + { + this.currentConfig.loop = value; + if (this.isPlaying) + { + this.stopAndRemoveLoopBufferSource(); + if (value) + { + this.createAndStartLoopBufferSource(); + } + } + + /** + * @event Phaser.Sound.WebAudioSound#loop + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + * @param {boolean} value - An updated value of Phaser.Sound.WebAudioSound#loop property. + */ + this.emit('loop', this, value); + } +}); +module.exports = WebAudioSound; + + +/***/ }), +/* 278 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Pavle Goloskokovic (http://prunegames.com) + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BaseSoundManager = __webpack_require__(99); +var Class = __webpack_require__(0); +var WebAudioSound = __webpack_require__(277); + +/** + * @classdesc + * Web Audio API implementation of the sound manager. + * + * @class WebAudioSoundManager + * @extends Phaser.Sound.BaseSoundManager + * @memberOf Phaser.Sound + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - Reference to the current game instance. + */ +var WebAudioSoundManager = new Class({ + + Extends: BaseSoundManager, + + initialize: + + function WebAudioSoundManager (game) + { + /** + * The AudioContext being used for playback. + * + * @name Phaser.Sound.WebAudioSoundManager#context + * @type {AudioContext} + * @private + * @since 3.0.0 + */ + this.context = this.createAudioContext(game); + + /** + * Gain node responsible for controlling global muting. + * + * @name Phaser.Sound.WebAudioSoundManager#masterMuteNode + * @type {GainNode} + * @private + * @since 3.0.0 + */ + this.masterMuteNode = this.context.createGain(); + + /** + * Gain node responsible for controlling global volume. + * + * @name Phaser.Sound.WebAudioSoundManager#masterVolumeNode + * @type {GainNode} + * @private + * @since 3.0.0 + */ + this.masterVolumeNode = this.context.createGain(); + + this.masterMuteNode.connect(this.masterVolumeNode); + + this.masterVolumeNode.connect(this.context.destination); + + /** + * Destination node for connecting individual sounds to. + * + * @name Phaser.Sound.WebAudioSoundManager#destination + * @type {AudioNode} + * @private + * @since 3.0.0 + */ + this.destination = this.masterMuteNode; + + this.locked = this.context.state === 'suspended' && 'ontouchstart' in window; + + BaseSoundManager.call(this, game); + }, + + /** + * Method responsible for instantiating and returning AudioContext instance. + * If an instance of an AudioContext class was provided trough the game config, + * that instance will be returned instead. This can come in handy if you are reloading + * a Phaser game on a page that never properly refreshes (such as in an SPA project) + * and you want to reuse already instantiated AudioContext. + * + * @method Phaser.Sound.WebAudioSoundManager#createAudioContext + * @private + * @since 3.0.0 + * + * @param {Phaser.Game} game - Reference to the current game instance. + * + * @return {AudioContext} The AudioContext instance to be used for playback. + */ + createAudioContext: function (game) + { + var audioConfig = game.config.audio; + + if (audioConfig && audioConfig.context) + { + audioConfig.context.resume(); + + return audioConfig.context; + } + + return new AudioContext(); + }, + + /** + * Adds a new sound into the sound manager. + * + * @method Phaser.Sound.WebAudioSoundManager#add + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * + * @return {Phaser.Sound.WebAudioSound} The new sound instance. + */ + add: function (key, config) + { + var sound = new WebAudioSound(this, key, config); + + this.sounds.push(sound); + + return sound; + }, + + /** + * Unlocks Web Audio API on iOS devices on the initial touch event. + * + * Read more about how this issue is handled here in [this article](https://medium.com/@pgoloskokovic/unlocking-web-audio-the-smarter-way-8858218c0e09). + * + * @method Phaser.Sound.WebAudioSoundManager#unlock + * @since 3.0.0 + */ + unlock: function () + { + var _this = this; + + var unlock = function () + { + _this.context.resume().then(function () + { + document.body.removeEventListener('touchstart', unlock); + document.body.removeEventListener('touchend', unlock); + _this.unlocked = true; + }); + }; + + document.body.addEventListener('touchstart', unlock, false); + document.body.addEventListener('touchend', unlock, false); + }, + + /** + * Method used internally for pausing sound manager if + * Phaser.Sound.WebAudioSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.WebAudioSoundManager#onBlur + * @protected + * @since 3.0.0 + */ + onBlur: function () + { + this.context.suspend(); + }, + + /** + * Method used internally for resuming sound manager if + * Phaser.Sound.WebAudioSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.WebAudioSoundManager#onFocus + * @protected + * @since 3.0.0 + */ + onFocus: function () + { + this.context.resume(); + }, + + /** + * Calls Phaser.Sound.BaseSoundManager#destroy method + * and cleans up all Web Audio API related stuff. + * + * @method Phaser.Sound.WebAudioSoundManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.destination = null; + this.masterVolumeNode.disconnect(); + this.masterVolumeNode = null; + this.masterMuteNode.disconnect(); + this.masterMuteNode = null; + + if (this.game.config.audio && this.game.config.audio.context) + { + this.context.suspend(); + } + else + { + this.context.close(); + } + + this.context = null; + + BaseSoundManager.prototype.destroy.call(this); + }, + + /** + * @event Phaser.Sound.WebAudioSoundManager#MuteEvent + * @param {Phaser.Sound.WebAudioSoundManager} soundManager - Reference to the sound manager that emitted event. + * @param {boolean} value - An updated value of Phaser.Sound.WebAudioSoundManager#mute property. + */ + + /** + * Sets the muted state of all this Sound Manager. + * + * @method Phaser.Sound.WebAudioSoundManager#setMute + * @fires Phaser.Sound.WebAudioSoundManager#MuteEvent + * @since 3.3.0 + * + * @param {boolean} value - `true` to mute all sounds, `false` to unmute them. + * + * @return {Phaser.Sound.WebAudioSoundManager} This Sound Manager. + */ + setMute: function (value) + { + this.mute = value; + + return this; + }, + + /** + * @name Phaser.Sound.WebAudioSoundManager#mute + * @type {boolean} + * @fires Phaser.Sound.WebAudioSoundManager#MuteEvent + * @since 3.0.0 + */ + mute: { + + get: function () + { + return (this.masterMuteNode.gain.value === 0); + }, + + set: function (value) + { + this.masterMuteNode.gain.setValueAtTime(value ? 0 : 1, 0); + + this.emit('mute', this, value); + } + + }, + + /** + * @event Phaser.Sound.WebAudioSoundManager#VolumeEvent + * @param {Phaser.Sound.WebAudioSoundManager} soundManager - Reference to the sound manager that emitted event. + * @param {number} value - An updated value of Phaser.Sound.WebAudioSoundManager#volume property. + */ + + /** + * Sets the volume of this Sound Manager. + * + * @method Phaser.Sound.WebAudioSoundManager#setVolume + * @fires Phaser.Sound.WebAudioSoundManager#VolumeEvent + * @since 3.3.0 + * + * @param {number} value - The global volume of this Sound Manager. + * + * @return {Phaser.Sound.WebAudioSoundManager} This Sound Manager. + */ + setVolume: function (value) + { + this.volume = value; + + return this; + }, + + /** + * @name Phaser.Sound.WebAudioSoundManager#volume + * @type {number} + * @fires Phaser.Sound.WebAudioSoundManager#VolumeEvent + * @since 3.0.0 + */ + volume: { + + get: function () + { + return this.masterVolumeNode.gain.value; + }, + + set: function (value) + { + this.masterVolumeNode.gain.setValueAtTime(value, 0); + + this.emit('volume', this, value); + } + + } + +}); + +module.exports = WebAudioSoundManager; + + +/***/ }), +/* 279 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ +var BaseSound = __webpack_require__(98); +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(15); +var Extend = __webpack_require__(18); + +/** + * @classdesc + * No audio implementation of the sound. It is used if audio has been + * disabled in the game config or the device doesn't support any audio. + * + * It represents a graceful degradation of sound logic that provides + * minimal functionality and prevents Phaser projects that use audio from + * breaking on devices that don't support any audio playback technologies. + * + * @class NoAudioSound + * @extends Phaser.Sound.BaseSound + * @memberOf Phaser.Sound + * @constructor + * @author Pavle Goloskokovic (http://prunegames.com) + * @since 3.0.0 + * + * @param {Phaser.Sound.NoAudioSoundManager} manager - Reference to the current sound manager instance. + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config={}] - An optional config object containing default sound settings. + */ +var NoAudioSound = new Class({ + Extends: EventEmitter, + initialize: function NoAudioSound (manager, key, config) + { + if (config === void 0) { config = {}; } + EventEmitter.call(this); + this.manager = manager; + this.key = key; + this.isPlaying = false; + this.isPaused = false; + this.totalRate = 1; + this.duration = 0; + this.totalDuration = 0; + this.config = Extend({ + mute: false, + volume: 1, + rate: 1, + detune: 0, + seek: 0, + loop: false, + delay: 0 + }, config); + this.currentConfig = this.config; + this.mute = false; + this.volume = 1; + this.rate = 1; + this.detune = 0; + this.seek = 0; + this.loop = false; + this.markers = {}; + this.currentMarker = null; + this.pendingRemove = false; + }, + // eslint-disable-next-line no-unused-vars + addMarker: function (marker) + { + return false; + }, + // eslint-disable-next-line no-unused-vars + updateMarker: function (marker) + { + return false; + }, + // eslint-disable-next-line no-unused-vars + removeMarker: function (markerName) + { + return null; + }, + // eslint-disable-next-line no-unused-vars + play: function (markerName, config) + { + return false; + }, + pause: function () + { + return false; + }, + resume: function () + { + return false; + }, + stop: function () + { + return false; + }, + destroy: function () + { + this.manager.remove(this); + BaseSound.prototype.destroy.call(this); + } +}); +module.exports = NoAudioSound; + + +/***/ }), +/* 280 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Pavle Goloskokovic (http://prunegames.com) + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BaseSoundManager = __webpack_require__(99); +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(15); +var NoAudioSound = __webpack_require__(279); +var NOOP = __webpack_require__(3); + +/** + * @classdesc + * No audio implementation of the sound manager. It is used if audio has been + * disabled in the game config or the device doesn't support any audio. + * + * It represents a graceful degradation of sound manager logic that provides + * minimal functionality and prevents Phaser projects that use audio from + * breaking on devices that don't support any audio playback technologies. + * + * @class NoAudioSoundManager + * @extends Phaser.Sound.BaseSoundManager + * @memberOf Phaser.Sound + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - Reference to the current game instance. + */ +var NoAudioSoundManager = new Class({ + + Extends: EventEmitter, + + initialize: + + function NoAudioSoundManager (game) + { + EventEmitter.call(this); + + this.game = game; + this.sounds = []; + this.mute = false; + this.volume = 1; + this.rate = 1; + this.detune = 0; + this.pauseOnBlur = true; + this.locked = false; + }, + + add: function (key, config) + { + var sound = new NoAudioSound(this, key, config); + + this.sounds.push(sound); + + return sound; + }, + + addAudioSprite: function (key, config) + { + var sound = this.add(key, config); + + sound.spritemap = {}; + + return sound; + }, + + // eslint-disable-next-line no-unused-vars + play: function (key, extra) + { + return false; + }, + + // eslint-disable-next-line no-unused-vars + playAudioSprite: function (key, spriteName, config) + { + return false; + }, + + remove: function (sound) + { + return BaseSoundManager.prototype.remove.call(this, sound); + }, + + removeByKey: function (key) + { + return BaseSoundManager.prototype.removeByKey.call(this, key); + }, + + pauseAll: NOOP, + resumeAll: NOOP, + stopAll: NOOP, + update: NOOP, + setRate: NOOP, + setDetune: NOOP, + setMute: NOOP, + setVolume: NOOP, + + forEachActiveSound: function (callbackfn, scope) + { + BaseSoundManager.prototype.forEachActiveSound.call(this, callbackfn, scope); + }, + + destroy: function () + { + BaseSoundManager.prototype.destroy.call(this); + } + +}); + +module.exports = NoAudioSoundManager; + + +/***/ }), +/* 281 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ +var Class = __webpack_require__(0); +var BaseSound = __webpack_require__(98); /** * @classdesc @@ -54783,3674 +61751,6 @@ Object.defineProperty(HTML5AudioSound.prototype, 'loop', { module.exports = HTML5AudioSound; -/***/ }), -/* 259 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ -var BaseSoundManager = __webpack_require__(84); -var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(14); -var NoAudioSound = __webpack_require__(260); -var NOOP = __webpack_require__(3); - -/** - * @classdesc - * No audio implementation of the sound manager. It is used if audio has been - * disabled in the game config or the device doesn't support any audio. - * - * It represents a graceful degradation of sound manager logic that provides - * minimal functionality and prevents Phaser projects that use audio from - * breaking on devices that don't support any audio playback technologies. - * - * @class NoAudioSoundManager - * @extends Phaser.Sound.BaseSoundManager - * @memberOf Phaser.Sound - * @constructor - * @author Pavle Goloskokovic (http://prunegames.com) - * @since 3.0.0 - * - * @param {Phaser.Game} game - Reference to the current game instance. - */ -var NoAudioSoundManager = new Class({ - Extends: EventEmitter, - initialize: function NoAudioSoundManager (game) - { - EventEmitter.call(this); - this.game = game; - this.sounds = []; - this.mute = false; - this.volume = 1; - this.rate = 1; - this.detune = 0; - this.pauseOnBlur = true; - this.locked = false; - }, - add: function (key, config) - { - var sound = new NoAudioSound(this, key, config); - this.sounds.push(sound); - return sound; - }, - addAudioSprite: function (key, config) - { - var sound = this.add(key, config); - sound.spritemap = {}; - return sound; - }, - // eslint-disable-next-line no-unused-vars - play: function (key, extra) - { - return false; - }, - // eslint-disable-next-line no-unused-vars - playAudioSprite: function (key, spriteName, config) - { - return false; - }, - remove: function (sound) - { - return BaseSoundManager.prototype.remove.call(this, sound); - }, - removeByKey: function (key) - { - return BaseSoundManager.prototype.removeByKey.call(this, key); - }, - pauseAll: NOOP, - resumeAll: NOOP, - stopAll: NOOP, - update: NOOP, - destroy: function () - { - BaseSoundManager.prototype.destroy.call(this); - }, - forEachActiveSound: function (callbackfn, scope) - { - BaseSoundManager.prototype.forEachActiveSound.call(this, callbackfn, scope); - } -}); -module.exports = NoAudioSoundManager; - - -/***/ }), -/* 260 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ -var BaseSound = __webpack_require__(85); -var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(14); -var Extend = __webpack_require__(23); - -/** - * @classdesc - * No audio implementation of the sound. It is used if audio has been - * disabled in the game config or the device doesn't support any audio. - * - * It represents a graceful degradation of sound logic that provides - * minimal functionality and prevents Phaser projects that use audio from - * breaking on devices that don't support any audio playback technologies. - * - * @class NoAudioSound - * @extends Phaser.Sound.BaseSound - * @memberOf Phaser.Sound - * @constructor - * @author Pavle Goloskokovic (http://prunegames.com) - * @since 3.0.0 - * - * @param {Phaser.Sound.NoAudioSoundManager} manager - Reference to the current sound manager instance. - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config={}] - An optional config object containing default sound settings. - */ -var NoAudioSound = new Class({ - Extends: EventEmitter, - initialize: function NoAudioSound (manager, key, config) - { - if (config === void 0) { config = {}; } - EventEmitter.call(this); - this.manager = manager; - this.key = key; - this.isPlaying = false; - this.isPaused = false; - this.totalRate = 1; - this.duration = 0; - this.totalDuration = 0; - this.config = Extend({ - mute: false, - volume: 1, - rate: 1, - detune: 0, - seek: 0, - loop: false, - delay: 0 - }, config); - this.currentConfig = this.config; - this.mute = false; - this.volume = 1; - this.rate = 1; - this.detune = 0; - this.seek = 0; - this.loop = false; - this.markers = {}; - this.currentMarker = null; - this.pendingRemove = false; - }, - // eslint-disable-next-line no-unused-vars - addMarker: function (marker) - { - return false; - }, - // eslint-disable-next-line no-unused-vars - updateMarker: function (marker) - { - return false; - }, - // eslint-disable-next-line no-unused-vars - removeMarker: function (markerName) - { - return null; - }, - // eslint-disable-next-line no-unused-vars - play: function (markerName, config) - { - return false; - }, - pause: function () - { - return false; - }, - resume: function () - { - return false; - }, - stop: function () - { - return false; - }, - destroy: function () - { - this.manager.remove(this); - BaseSound.prototype.destroy.call(this); - } -}); -module.exports = NoAudioSound; - - -/***/ }), -/* 261 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BaseSoundManager = __webpack_require__(84); -var Class = __webpack_require__(0); -var WebAudioSound = __webpack_require__(262); - -/** - * @classdesc - * Web Audio API implementation of the sound manager. - * - * @class WebAudioSoundManager - * @extends Phaser.Sound.BaseSoundManager - * @memberOf Phaser.Sound - * @constructor - * @author Pavle Goloskokovic (http://prunegames.com) - * @since 3.0.0 - * - * @param {Phaser.Game} game - Reference to the current game instance. - */ -var WebAudioSoundManager = new Class({ - - Extends: BaseSoundManager, - - initialize: - - function WebAudioSoundManager (game) - { - /** - * The AudioContext being used for playback. - * - * @name Phaser.Sound.WebAudioSoundManager#context - * @type {AudioContext} - * @private - * @since 3.0.0 - */ - this.context = this.createAudioContext(game); - - /** - * Gain node responsible for controlling global muting. - * - * @name Phaser.Sound.WebAudioSoundManager#masterMuteNode - * @type {GainNode} - * @private - * @since 3.0.0 - */ - this.masterMuteNode = this.context.createGain(); - - /** - * Gain node responsible for controlling global volume. - * - * @name Phaser.Sound.WebAudioSoundManager#masterVolumeNode - * @type {GainNode} - * @private - * @since 3.0.0 - */ - this.masterVolumeNode = this.context.createGain(); - - this.masterMuteNode.connect(this.masterVolumeNode); - - this.masterVolumeNode.connect(this.context.destination); - - /** - * Destination node for connecting individual sounds to. - * - * @name Phaser.Sound.WebAudioSoundManager#destination - * @type {AudioNode} - * @private - * @since 3.0.0 - */ - this.destination = this.masterMuteNode; - - this.locked = this.context.state === 'suspended' && 'ontouchstart' in window; - - BaseSoundManager.call(this, game); - }, - - /** - * Method responsible for instantiating and returning AudioContext instance. - * If an instance of an AudioContext class was provided trough the game config, - * that instance will be returned instead. This can come in handy if you are reloading - * a Phaser game on a page that never properly refreshes (such as in an SPA project) - * and you want to reuse already instantiated AudioContext. - * - * @method Phaser.Sound.WebAudioSoundManager#createAudioContext - * @private - * @since 3.0.0 - * - * @param {Phaser.Game} game - Reference to the current game instance. - * - * @return {AudioContext} The AudioContext instance to be used for playback. - */ - createAudioContext: function (game) - { - var audioConfig = game.config.audio; - - if (audioConfig && audioConfig.context) - { - audioConfig.context.resume(); - return audioConfig.context; - } - - return new AudioContext(); - }, - - /** - * Adds a new sound into the sound manager. - * - * @method Phaser.Sound.WebAudioSoundManager#add - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - * - * @return {Phaser.Sound.WebAudioSound} The new sound instance. - */ - add: function (key, config) - { - - var sound = new WebAudioSound(this, key, config); - - this.sounds.push(sound); - - return sound; - }, - - /** - * Unlocks Web Audio API on iOS devices on the initial touch event. - * - * Read more about how this issue is handled here in [this article](https://medium.com/@pgoloskokovic/unlocking-web-audio-the-smarter-way-8858218c0e09). - * - * @method Phaser.Sound.WebAudioSoundManager#unlock - * @private - * @since 3.0.0 - */ - unlock: function () - { - var _this = this; - - var unlock = function () - { - _this.context.resume().then(function () - { - document.body.removeEventListener('touchstart', unlock); - document.body.removeEventListener('touchend', unlock); - _this.unlocked = true; - }); - }; - - document.body.addEventListener('touchstart', unlock, false); - document.body.addEventListener('touchend', unlock, false); - }, - - /** - * Method used internally for pausing sound manager if - * Phaser.Sound.WebAudioSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.WebAudioSoundManager#onBlur - * @protected - * @since 3.0.0 - */ - onBlur: function () - { - this.context.suspend(); - }, - - /** - * Method used internally for resuming sound manager if - * Phaser.Sound.WebAudioSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.WebAudioSoundManager#onFocus - * @protected - * @since 3.0.0 - */ - onFocus: function () - { - this.context.resume(); - }, - - /** - * Calls Phaser.Sound.BaseSoundManager#destroy method - * and cleans up all Web Audio API related stuff. - * - * @method Phaser.Sound.WebAudioSoundManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.destination = null; - this.masterVolumeNode.disconnect(); - this.masterVolumeNode = null; - this.masterMuteNode.disconnect(); - this.masterMuteNode = null; - - if (this.game.config.audio && this.game.config.audio.context) - { - this.context.suspend(); - } - else - { - this.context.close(); - } - - this.context = null; - - BaseSoundManager.prototype.destroy.call(this); - }, - - /** - * @event Phaser.Sound.WebAudioSoundManager#MuteEvent - * @param {Phaser.Sound.WebAudioSoundManager} soundManager - Reference to the sound manager that emitted event. - * @param {boolean} value - An updated value of Phaser.Sound.WebAudioSoundManager#mute property. - */ - - /** - * @name Phaser.Sound.WebAudioSoundManager#mute - * @type {boolean} - * @fires Phaser.Sound.WebAudioSoundManager#MuteEvent - * @since 3.0.0 - */ - mute: { - - get: function () - { - return (this.masterMuteNode.gain.value === 0); - }, - - set: function (value) - { - this.masterMuteNode.gain.setValueAtTime(value ? 0 : 1, 0); - - this.emit('mute', this, value); - } - - }, - - /** - * @event Phaser.Sound.WebAudioSoundManager#VolumeEvent - * @param {Phaser.Sound.WebAudioSoundManager} soundManager - Reference to the sound manager that emitted event. - * @param {number} value - An updated value of Phaser.Sound.WebAudioSoundManager#volume property. - */ - - /** - * @name Phaser.Sound.WebAudioSoundManager#volume - * @type {number} - * @fires Phaser.Sound.WebAudioSoundManager#VolumeEvent - * @since 3.0.0 - */ - volume: { - - get: function () - { - return this.masterVolumeNode.gain.value; - }, - - set: function (value) - { - this.masterVolumeNode.gain.setValueAtTime(value, 0); - - this.emit('volume', this, value); - } - - } - -}); - -module.exports = WebAudioSoundManager; - - -/***/ }), -/* 262 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ -var Class = __webpack_require__(0); -var BaseSound = __webpack_require__(85); - -/** - * @classdesc - * Web Audio API implementation of the sound. - * - * @class WebAudioSound - * @extends Phaser.Sound.BaseSound - * @memberOf Phaser.Sound - * @constructor - * @author Pavle Goloskokovic (http://prunegames.com) - * @since 3.0.0 - * - * @param {Phaser.Sound.WebAudioSoundManager} manager - Reference to the current sound manager instance. - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config={}] - An optional config object containing default sound settings. - */ -var WebAudioSound = new Class({ - Extends: BaseSound, - initialize: function WebAudioSound (manager, key, config) - { - if (config === void 0) { config = {}; } - - /** - * Audio buffer containing decoded data of the audio asset to be played. - * - * @name Phaser.Sound.WebAudioSound#audioBuffer - * @type {AudioBuffer} - * @private - * @since 3.0.0 - */ - this.audioBuffer = manager.game.cache.audio.get(key); - if (!this.audioBuffer) - { - // eslint-disable-next-line no-console - console.error('No audio loaded in cache with key: \'' + key + '\'!'); - return; - } - - /** - * A reference to an audio source node used for playing back audio from - * audio data stored in Phaser.Sound.WebAudioSound#audioBuffer. - * - * @name Phaser.Sound.WebAudioSound#source - * @type {AudioBufferSourceNode} - * @private - * @default null - * @since 3.0.0 - */ - this.source = null; - - /** - * A reference to a second audio source used for gapless looped playback. - * - * @name Phaser.Sound.WebAudioSound#loopSource - * @type {AudioBufferSourceNode} - * @private - * @default null - * @since 3.0.0 - */ - this.loopSource = null; - - /** - * Gain node responsible for controlling this sound's muting. - * - * @name Phaser.Sound.WebAudioSound#muteNode - * @type {GainNode} - * @private - * @since 3.0.0 - */ - this.muteNode = manager.context.createGain(); - - /** - * Gain node responsible for controlling this sound's volume. - * - * @name Phaser.Sound.WebAudioSound#volumeNode - * @type {GainNode} - * @private - * @since 3.0.0 - */ - this.volumeNode = manager.context.createGain(); - - /** - * The time at which the sound should have started playback from the beginning. - * Based on BaseAudioContext.currentTime value. - * - * @name Phaser.Sound.WebAudioSound#playTime - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this.playTime = 0; - - /** - * The time at which the sound source should have actually started playback. - * Based on BaseAudioContext.currentTime value. - * - * @name Phaser.Sound.WebAudioSound#startTime - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this.startTime = 0; - - /** - * The time at which the sound loop source should actually start playback. - * Based on BaseAudioContext.currentTime value. - * - * @name Phaser.Sound.WebAudioSound#loopTime - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this.loopTime = 0; - - /** - * An array where we keep track of all rate updates during playback. - * Array of object types: { time: number, rate: number } - * - * @name Phaser.Sound.WebAudioSound#rateUpdates - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this.rateUpdates = []; - - /** - * Used for keeping track when sound source playback has ended - * so its state can be updated accordingly. - * - * @name Phaser.Sound.WebAudioSound#hasEnded - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this.hasEnded = false; - - /** - * Used for keeping track when sound source has looped - * so its state can be updated accordingly. - * - * @name Phaser.Sound.WebAudioSound#hasLooped - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this.hasLooped = false; - this.muteNode.connect(this.volumeNode); - this.volumeNode.connect(manager.destination); - this.duration = this.audioBuffer.duration; - this.totalDuration = this.audioBuffer.duration; - BaseSound.call(this, manager, key, config); - }, - - /** - * Play this sound, or a marked section of it. - * It always plays the sound from the start. If you want to start playback from a specific time - * you can set 'seek' setting of the config object, provided to this call, to that value. - * - * @method Phaser.Sound.WebAudioSound#play - * @since 3.0.0 - * - * @param {string} [markerName=''] - If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. - * @param {SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. - * - * @return {boolean} Whether the sound started playing successfully. - */ - play: function (markerName, config) - { - if (!BaseSound.prototype.play.call(this, markerName, config)) - { - return false; - } - - // \/\/\/ isPlaying = true, isPaused = false \/\/\/ - this.stopAndRemoveBufferSource(); - this.createAndStartBufferSource(); - - /** - * @event Phaser.Sound.WebAudioSound#play - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - */ - this.emit('play', this); - return true; - }, - - /** - * Pauses the sound. - * - * @method Phaser.Sound.WebAudioSound#pause - * @since 3.0.0 - * - * @return {boolean} Whether the sound was paused successfully. - */ - pause: function () - { - if (this.manager.context.currentTime < this.startTime) - { - return false; - } - if (!BaseSound.prototype.pause.call(this)) - { - return false; - } - - // \/\/\/ isPlaying = false, isPaused = true \/\/\/ - this.currentConfig.seek = this.getCurrentTime(); // Equivalent to setting paused time - this.stopAndRemoveBufferSource(); - - /** - * @event Phaser.Sound.WebAudioSound#pause - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - */ - this.emit('pause', this); - return true; - }, - - /** - * Resumes the sound. - * - * @method Phaser.Sound.WebAudioSound#resume - * @since 3.0.0 - * - * @return {boolean} Whether the sound was resumed successfully. - */ - resume: function () - { - if (this.manager.context.currentTime < this.startTime) - { - return false; - } - if (!BaseSound.prototype.resume.call(this)) - { - return false; - } - - // \/\/\/ isPlaying = true, isPaused = false \/\/\/ - this.createAndStartBufferSource(); - - /** - * @event Phaser.Sound.WebAudioSound#resume - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - */ - this.emit('resume', this); - return true; - }, - - /** - * Stop playing this sound. - * - * @method Phaser.Sound.WebAudioSound#stop - * @since 3.0.0 - * - * @return {boolean} Whether the sound was stopped successfully. - */ - stop: function () - { - if (!BaseSound.prototype.stop.call(this)) - { - return false; - } - - // \/\/\/ isPlaying = false, isPaused = false \/\/\/ - this.stopAndRemoveBufferSource(); - - /** - * @event Phaser.Sound.WebAudioSound#stop - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - */ - this.emit('stop', this); - return true; - }, - - /** - * Used internally to do what the name says. - * - * @method Phaser.Sound.WebAudioSound#createAndStartBufferSource - * @private - * @since 3.0.0 - */ - createAndStartBufferSource: function () - { - var seek = this.currentConfig.seek; - var delay = this.currentConfig.delay; - var when = this.manager.context.currentTime + delay; - var offset = (this.currentMarker ? this.currentMarker.start : 0) + seek; - var duration = this.duration - seek; - this.playTime = when - seek; - this.startTime = when; - this.source = this.createBufferSource(); - this.applyConfig(); - this.source.start(Math.max(0, when), Math.max(0, offset), Math.max(0, duration)); - this.resetConfig(); - }, - - /** - * Used internally to do what the name says. - * - * @method Phaser.Sound.WebAudioSound#createAndStartLoopBufferSource - * @private - * @since 3.0.0 - */ - createAndStartLoopBufferSource: function () - { - var when = this.getLoopTime(); - var offset = this.currentMarker ? this.currentMarker.start : 0; - var duration = this.duration; - this.loopTime = when; - this.loopSource = this.createBufferSource(); - this.loopSource.playbackRate.setValueAtTime(this.totalRate, 0); - this.loopSource.start(Math.max(0, when), Math.max(0, offset), Math.max(0, duration)); - }, - - /** - * Used internally to do what the name says. - * - * @method Phaser.Sound.WebAudioSound#createBufferSource - * @private - * @since 3.0.0 - * - * @return {AudioBufferSourceNode} - */ - createBufferSource: function () - { - var _this = this; - var source = this.manager.context.createBufferSource(); - source.buffer = this.audioBuffer; - source.connect(this.muteNode); - source.onended = function (ev) - { - if (ev.target === _this.source) - { - // sound ended - if (_this.currentConfig.loop) - { - _this.hasLooped = true; - } - else - { - _this.hasEnded = true; - } - } - - // else was stopped - }; - return source; - }, - - /** - * Used internally to do what the name says. - * - * @method Phaser.Sound.WebAudioSound#stopAndRemoveBufferSource - * @private - * @since 3.0.0 - */ - stopAndRemoveBufferSource: function () - { - if (this.source) - { - this.source.stop(); - this.source.disconnect(); - this.source = null; - } - this.playTime = 0; - this.startTime = 0; - this.stopAndRemoveLoopBufferSource(); - }, - - /** - * Used internally to do what the name says. - * - * @method Phaser.Sound.WebAudioSound#stopAndRemoveLoopBufferSource - * @private - * @since 3.0.0 - */ - stopAndRemoveLoopBufferSource: function () - { - if (this.loopSource) - { - this.loopSource.stop(); - this.loopSource.disconnect(); - this.loopSource = null; - } - this.loopTime = 0; - }, - - /** - * Method used internally for applying config values to some of the sound properties. - * - * @method Phaser.Sound.WebAudioSound#applyConfig - * @protected - * @since 3.0.0 - */ - applyConfig: function () - { - this.rateUpdates.length = 0; - this.rateUpdates.push({ - time: 0, - rate: 1 - }); - BaseSound.prototype.applyConfig.call(this); - }, - - /** - * Update method called automatically by sound manager on every game step. - * - * @method Phaser.Sound.WebAudioSound#update - * @protected - * @since 3.0.0 - * - * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {number} delta - The delta time elapsed since the last frame. - */ - // eslint-disable-next-line no-unused-vars - update: function (time, delta) - { - if (this.hasEnded) - { - this.hasEnded = false; - BaseSound.prototype.stop.call(this); - this.stopAndRemoveBufferSource(); - - /** - * @event Phaser.Sound.WebAudioSound#ended - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - */ - this.emit('ended', this); - } - else if (this.hasLooped) - { - this.hasLooped = false; - this.source = this.loopSource; - this.loopSource = null; - this.playTime = this.startTime = this.loopTime; - this.rateUpdates.length = 0; - this.rateUpdates.push({ - time: 0, - rate: this.totalRate - }); - this.createAndStartLoopBufferSource(); - - /** - * @event Phaser.Sound.WebAudioSound#looped - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - */ - this.emit('looped', this); - } - }, - - /** - * Calls Phaser.Sound.BaseSound#destroy method - * and cleans up all Web Audio API related stuff. - * - * @method Phaser.Sound.WebAudioSound#destroy - * @since 3.0.0 - */ - destroy: function () - { - BaseSound.prototype.destroy.call(this); - this.audioBuffer = null; - this.stopAndRemoveBufferSource(); - this.muteNode.disconnect(); - this.muteNode = null; - this.volumeNode.disconnect(); - this.volumeNode = null; - this.rateUpdates.length = 0; - this.rateUpdates = null; - }, - - /** - * Method used internally to calculate total playback rate of the sound. - * - * @method Phaser.Sound.WebAudioSound#setRate - * @protected - * @since 3.0.0 - */ - setRate: function () - { - BaseSound.prototype.setRate.call(this); - var now = this.manager.context.currentTime; - if (this.source) - { - this.source.playbackRate.setValueAtTime(this.totalRate, now); - } - if (this.isPlaying) - { - this.rateUpdates.push({ - time: Math.max(this.startTime, now) - this.playTime, - rate: this.totalRate - }); - if (this.loopSource) - { - this.stopAndRemoveLoopBufferSource(); - this.createAndStartLoopBufferSource(); - } - } - }, - - /** - * Method used internally for calculating current playback time of a playing sound. - * - * @method Phaser.Sound.WebAudioSound#getCurrentTime - * @private - * @since 3.0.0 - */ - getCurrentTime: function () - { - var currentTime = 0; - for (var i = 0; i < this.rateUpdates.length; i++) - { - var nextTime = void 0; - if (i < this.rateUpdates.length - 1) - { - nextTime = this.rateUpdates[i + 1].time; - } - else - { - nextTime = this.manager.context.currentTime - this.playTime; - } - currentTime += (nextTime - this.rateUpdates[i].time) * this.rateUpdates[i].rate; - } - return currentTime; - }, - - /** - * Method used internally for calculating the time - * at witch the loop source should start playing. - * - * @method Phaser.Sound.WebAudioSound#getLoopTime - * @private - * @since 3.0.0 - */ - getLoopTime: function () - { - var lastRateUpdateCurrentTime = 0; - for (var i = 0; i < this.rateUpdates.length - 1; i++) - { - lastRateUpdateCurrentTime += - (this.rateUpdates[i + 1].time - this.rateUpdates[i].time) * this.rateUpdates[i].rate; - } - var lastRateUpdate = this.rateUpdates[this.rateUpdates.length - 1]; - return this.playTime + lastRateUpdate.time - + (this.duration - lastRateUpdateCurrentTime) / lastRateUpdate.rate; - } -}); -Object.defineProperty(WebAudioSound.prototype, 'mute', { - get: function () - { - return this.muteNode.gain.value === 0; - }, - set: function (value) - { - this.currentConfig.mute = value; - this.muteNode.gain.setValueAtTime(value ? 0 : 1, 0); - - /** - * @event Phaser.Sound.WebAudioSound#mute - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - * @param {boolean} value - An updated value of Phaser.Sound.WebAudioSound#mute property. - */ - this.emit('mute', this, value); - } -}); -Object.defineProperty(WebAudioSound.prototype, 'volume', { - get: function () - { - return this.volumeNode.gain.value; - }, - set: function (value) - { - this.currentConfig.volume = value; - this.volumeNode.gain.setValueAtTime(value, 0); - - /** - * @event Phaser.Sound.WebAudioSound#volume - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - * @param {number} value - An updated value of Phaser.Sound.WebAudioSound#volume property. - */ - this.emit('volume', this, value); - } -}); -Object.defineProperty(WebAudioSound.prototype, 'seek', { - get: function () - { - if (this.isPlaying) - { - if (this.manager.context.currentTime < this.startTime) - { - return this.startTime - this.playTime; - } - return this.getCurrentTime(); - } - else if (this.isPaused) - { - return this.currentConfig.seek; - } - else - { - return 0; - } - }, - set: function (value) - { - if (this.manager.context.currentTime < this.startTime) - { - return; - } - if (this.isPlaying || this.isPaused) - { - value = Math.min(Math.max(0, value), this.duration); - this.currentConfig.seek = value; - if (this.isPlaying) - { - this.stopAndRemoveBufferSource(); - this.createAndStartBufferSource(); - } - - /** - * @event Phaser.Sound.WebAudioSound#seek - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - * @param {number} value - An updated value of Phaser.Sound.WebAudioSound#seek property. - */ - this.emit('seek', this, value); - } - } -}); -Object.defineProperty(WebAudioSound.prototype, 'loop', { - get: function () - { - return this.currentConfig.loop; - }, - set: function (value) - { - this.currentConfig.loop = value; - if (this.isPlaying) - { - this.stopAndRemoveLoopBufferSource(); - if (value) - { - this.createAndStartLoopBufferSource(); - } - } - - /** - * @event Phaser.Sound.WebAudioSound#loop - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - * @param {boolean} value - An updated value of Phaser.Sound.WebAudioSound#loop property. - */ - this.emit('loop', this, value); - } -}); -module.exports = WebAudioSound; - - -/***/ }), -/* 263 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CanvasPool = __webpack_require__(21); -var Class = __webpack_require__(0); -var Color = __webpack_require__(36); -var EventEmitter = __webpack_require__(14); -var GenerateTexture = __webpack_require__(216); -var GetValue = __webpack_require__(4); -var Parser = __webpack_require__(264); -var Texture = __webpack_require__(265); - -/** - * @classdesc - * Textures are managed by the global TextureManager. This is a singleton class that is - * responsible for creating and delivering Textures and their corresponding Frames to Game Objects. - * - * Sprites and other Game Objects get the texture data they need from the TextureManager. - * - * Access it via `scene.textures`. - * - * @class TextureManager - * @extends EventEmitter - * @memberOf Phaser.Textures - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - [description] - */ -var TextureManager = new Class({ - - Extends: EventEmitter, - - initialize: - - function TextureManager (game) - { - EventEmitter.call(this); - - /** - * [description] - * - * @name Phaser.Textures.TextureManager#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game = game; - - /** - * [description] - * - * @name Phaser.Textures.TextureManager#name - * @type {string} - * @since 3.0.0 - */ - this.name = 'TextureManager'; - - /** - * [description] - * - * @name Phaser.Textures.TextureManager#list - * @type {object} - * @default {} - * @since 3.0.0 - */ - this.list = {}; - - /** - * [description] - * - * @name Phaser.Textures.TextureManager#_tempCanvas - * @type {HTMLCanvasElement} - * @private - * @since 3.0.0 - */ - this._tempCanvas = CanvasPool.create2D(this, 1, 1); - - /** - * [description] - * - * @name Phaser.Textures.TextureManager#_tempContext - * @type {CanvasRenderingContext2D} - * @private - * @since 3.0.0 - */ - this._tempContext = this._tempCanvas.getContext('2d'); - - /** - * [description] - * - * @name Phaser.Textures.TextureManager#_pending - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - this._pending = 0; - - game.events.once('boot', this.boot, this); - }, - - /** - * [description] - * - * @method Phaser.Textures.TextureManager#boot - * @since 3.0.0 - */ - boot: function () - { - this._pending = 2; - - this.on('onload', this.updatePending, this); - this.on('onerror', this.updatePending, this); - - this.addBase64('__DEFAULT', this.game.config.defaultImage); - this.addBase64('__MISSING', this.game.config.missingImage); - - this.game.events.once('destroy', this.destroy, this); - }, - - /** - * [description] - * - * @method Phaser.Textures.TextureManager#updatePending - * @since 3.0.0 - */ - updatePending: function () - { - this._pending--; - - if (this._pending === 0) - { - this.off('onload'); - this.off('onerror'); - - this.game.events.emit('ready'); - } - }, - - /** - * Adds a new Texture to the Texture Manager created from the given Base64 encoded data. - * - * @method Phaser.Textures.TextureManager#addBase64 - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {any} data - The Base64 encoded data. - */ - addBase64: function (key, data) - { - var _this = this; - - var image = new Image(); - - image.onerror = function () - { - _this.emit('onerror', key); - }; - - image.onload = function () - { - var texture = _this.create(key, image); - - Parser.Image(texture, 0); - - _this.emit('onload', key, texture); - }; - - image.src = data; - }, - - /** - * Adds a new Texture to the Texture Manager created from the given Image element. - * - * @method Phaser.Textures.TextureManager#addImage - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {Image} source - The source Image element. - * @param {Image} [dataSource] - An optional data Image element. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - addImage: function (key, source, dataSource) - { - var texture = this.create(key, source); - - Parser.Image(texture, 0); - - if (dataSource) - { - texture.setDataSource(dataSource); - } - - return texture; - }, - - /** - * Creates a new Texture using the given config values. - * Generated textures consist of a Canvas element to which the texture data is drawn. - * See the Phaser.Create function for the more direct way to create textures. - * - * @method Phaser.Textures.TextureManager#generate - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {object} config - [description] - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - generate: function (key, config) - { - var canvas = CanvasPool.create(this, 1, 1); - - config.canvas = canvas; - - GenerateTexture(config); - - return this.addCanvas(key, canvas); - }, - - /** - * Creates a new Texture using a blank Canvas element of the size given. - * - * Canvas elements are automatically pooled and calling this method will - * extract a free canvas from the CanvasPool, or create one if none are available. - * - * @method Phaser.Textures.TextureManager#createCanvas - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {integer} width - The width of the Canvas element. - * @param {integer} height - The height of the Canvas element. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - createCanvas: function (key, width, height) - { - if (width === undefined) { width = 256; } - if (height === undefined) { height = 256; } - - var canvas = CanvasPool.create(this, width, height); - - return this.addCanvas(key, canvas); - }, - - /** - * Creates a new Texture object from an existing Canvas element and adds - * it to this Texture Manager. - * - * @method Phaser.Textures.TextureManager#addCanvas - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {HTMLCanvasElement} source - The Canvas element to form the base of the new Texture. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - addCanvas: function (key, source) - { - var texture = this.create(key, source); - - Parser.Canvas(texture, 0); - - return texture; - }, - - /** - * Adds a new Texture Atlas to this Texture Manager. - * It can accept either JSON Array or JSON Hash formats, as exported by Texture Packer and similar software. - * - * @method Phaser.Textures.TextureManager#addAtlas - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {Image} source - The source Image element. - * @param {object} data - The Texture Atlas data. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - addAtlas: function (key, source, data) - { - // New Texture Packer format? - if (Array.isArray(data.textures) || Array.isArray(data.frames)) - { - return this.addAtlasJSONArray(key, source, data); - } - else - { - return this.addAtlasJSONHash(key, source, data); - } - }, - - /** - * Adds a Texture Atlas to this Texture Manager. - * The frame data of the atlas must be stored in an Array within the JSON. - * This is known as a JSON Array in software such as Texture Packer. - * - * @method Phaser.Textures.TextureManager#addAtlasJSONArray - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {Image} source - The source Image element. - * @param {object} data - The Texture Atlas data. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - addAtlasJSONArray: function (key, source, data) - { - var texture = this.create(key, source); - - if (Array.isArray(data)) - { - var singleAtlasFile = (data.length === 1); // multi-pack with one atlas file for all images - for (var i = 0; i < texture.source.length; i++) - { - var atlasData = singleAtlasFile ? data[0] : data[i]; - Parser.JSONArray(texture, i, atlasData); - } - } - else - { - Parser.JSONArray(texture, 0, data); - } - - return texture; - }, - - /** - * Adds a Texture Atlas to this Texture Manager. - * The frame data of the atlas must be stored in an Object within the JSON. - * This is known as a JSON Hash in software such as Texture Packer. - * - * @method Phaser.Textures.TextureManager#addAtlasJSONHash - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {Image} source - The source Image element. - * @param {object} data - The Texture Atlas data. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - addAtlasJSONHash: function (key, source, data) - { - var texture = this.create(key, source); - - if (Array.isArray(data)) - { - for (var i = 0; i < data.length; i++) - { - Parser.JSONHash(texture, i, data[i]); - } - } - else - { - Parser.JSONHash(texture, 0, data); - } - - return texture; - }, - - /** - * Adds a Unity Texture Atlas to this Texture Manager. - * The data must be in the form of a Unity YAML file. - * - * @method Phaser.Textures.TextureManager#addUnityAtlas - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {Image} source - The source Image element. - * @param {object} data - The Texture Atlas data. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - addUnityAtlas: function (key, source, data) - { - var texture = this.create(key, source); - - Parser.UnityYAML(texture, 0, data); - - return texture; - }, - - /** - * Adds a Sprite Sheet to this Texture Manager. - * - * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact - * same size and cannot be trimmed or rotated. - * - * @method Phaser.Textures.TextureManager#addSpriteSheet - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {Image} source - The source Image element. - * @param {object} config - The configuration object for this Sprite Sheet. - * @param {integer} config.frameWidth - The fixed width of each frame. - * @param {integer} [config.frameHeight] - The fixed height of each frame. If not set it will use the frameWidth as the height. - * @param {integer} [config.startFrame=0] - Skip a number of frames. Useful when there are multiple sprite sheets in one Texture. - * @param {integer} [config.endFrame=-1] - The total number of frames to extract from the Sprite Sheet. The default value of -1 means "extract all frames". - * @param {integer} [config.margin=0] - If the frames have been drawn with a margin, specify the amount here. - * @param {integer} [config.spacing=0] - If the frames have been drawn with spacing between them, specify the amount here. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - addSpriteSheet: function (key, source, config) - { - var texture = this.create(key, source); - - var width = texture.source[0].width; - var height = texture.source[0].height; - - Parser.SpriteSheet(texture, 0, 0, 0, width, height, config); - - return texture; - }, - - /** - * Adds a Sprite Sheet to this Texture Manager, where the Sprite Sheet exists as a Frame within a Texture Atlas. - * - * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact - * same size and cannot be trimmed or rotated. - * - * @method Phaser.Textures.TextureManager#addSpriteSheetFromAtlas - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {object} config - The configuration object for this Sprite Sheet. - * @param {string} config.atlas - The key of the Texture Atlas in which this Sprite Sheet can be found. - * @param {string} config.frame - The key of the Texture Atlas Frame in which this Sprite Sheet can be found. - * @param {integer} config.frameWidth - The fixed width of each frame. - * @param {integer} [config.frameHeight] - The fixed height of each frame. If not set it will use the frameWidth as the height. - * @param {integer} [config.startFrame=0] - Skip a number of frames. Useful when there are multiple sprite sheets in one Texture. - * @param {integer} [config.endFrame=-1] - The total number of frames to extract from the Sprite Sheet. The default value of -1 means "extract all frames". - * @param {integer} [config.margin=0] - If the frames have been drawn with a margin, specify the amount here. - * @param {integer} [config.spacing=0] - If the frames have been drawn with spacing between them, specify the amount here. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - addSpriteSheetFromAtlas: function (key, config) - { - var atlasKey = GetValue(config, 'atlas', null); - var atlasFrame = GetValue(config, 'frame', null); - - if (!atlasKey || !atlasFrame) - { - return; - } - - var atlas = this.get(atlasKey); - var sheet = atlas.get(atlasFrame); - - if (sheet) - { - var texture = this.create(key, sheet.source.image); - - if (sheet.trimmed) - { - // If trimmed we need to help the parser adjust - Parser.SpriteSheetFromAtlas(texture, sheet, config); - } - else - { - Parser.SpriteSheet(texture, 0, sheet.cutX, sheet.cutY, sheet.cutWidth, sheet.cutHeight, config); - } - - return texture; - } - }, - - /** - * Adds a Texture Atlas to this Texture Manager, where the atlas data is given - * in the Starling XML format. - * - * @method Phaser.Textures.TextureManager#addAtlasStarlingXML - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {Image} source - The source Image element. - * @param {object} data - The Texture Atlas XML data. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - addAtlasStarlingXML: function (key, source, data) - { - var texture = this.create(key, source); - - if (Array.isArray(data)) - { - for (var i = 0; i < data.length; i++) - { - Parser.StarlingXML(texture, i, data[i]); - } - } - else - { - Parser.StarlingXML(texture, 0, data); - } - - return texture; - }, - - /** - * Adds a Texture Atlas to this Texture Manager, where the atlas data is given - * in the Pyxel JSON format. - * - * @method Phaser.Textures.TextureManager#addAtlasPyxel - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {Image} source - The source Image element. - * @param {object} data - The Texture Atlas XML data. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - addAtlasPyxel: function (key, source, data) - { - var texture = this.create(key, source); - - if (Array.isArray(data)) - { - for (var i = 0; i < data.length; i++) - { - Parser.Pyxel(texture, i, data[i]); - } - } - else - { - Parser.Pyxel(texture, 0, data); - } - - return texture; - }, - - /** - * Creates a new Texture using the given source and dimensions. - * - * @method Phaser.Textures.TextureManager#create - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {Image} source - The source Image element. - * @param {integer} width - The width of the Texture. - * @param {integer} height - The height of the Texture. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - create: function (key, source, width, height) - { - var texture = new Texture(this, key, source, width, height); - - this.list[key] = texture; - - return texture; - }, - - /** - * Checks the given key to see if a Texture using it exists within this Texture Manager. - * - * @method Phaser.Textures.TextureManager#exists - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * - * @return {boolean} Returns `true` if a Texture matching the given key exists in this Texture Manager. - */ - exists: function (key) - { - return (this.list.hasOwnProperty(key)); - }, - - /** - * Returns a Texture from the Texture Manager that matches the given key. - * If the key is undefined it will return the `__DEFAULT` Texture. - * If the key is given, but not found, it will return the `__MISSING` Texture. - * - * @method Phaser.Textures.TextureManager#get - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - get: function (key) - { - if (key === undefined) { key = '__DEFAULT'; } - - if (this.list[key]) - { - return this.list[key]; - } - else - { - return this.list['__MISSING']; - } - }, - - /** - * Takes a Texture key and Frame name and returns a clone of that Frame if found. - * - * @method Phaser.Textures.TextureManager#cloneFrame - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {string|integer} frame - The string or index of the Frame to be cloned. - * - * @return {Phaser.Textures.Frame} A Clone of the given Frame. - */ - cloneFrame: function (key, frame) - { - if (this.list[key]) - { - return this.list[key].get(frame).clone(); - } - }, - - /** - * Takes a Texture key and Frame name and returns a reference to that Frame, if found. - * - * @method Phaser.Textures.TextureManager#getFrame - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {string|integer} frame - The string or index of the Frame. - * - * @return {Phaser.Textures.Frame} A Texture Frame object. - */ - getFrame: function (key, frame) - { - if (this.list[key]) - { - return this.list[key].get(frame); - } - }, - - /** - * Returns an array with all of the keys of all Textures in this Texture Manager. - * The output array will exclude the `__DEFAULT` and `__MISSING` keys. - * - * @method Phaser.Textures.TextureManager#getTextureKeys - * @since 3.0.0 - * - * @return {string[]} An array containing all of the Texture keys stored in this Texture Manager. - */ - getTextureKeys: function () - { - var output = []; - - for (var key in this.list) - { - if (key !== '__DEFAULT' && key !== '__MISSING') - { - output.push(key); - } - } - - return output; - }, - - /** - * Given a Texture and an `x` and `y` coordinate this method will return a new - * Color object that has been populated with the color and alpha values of the pixel - * at that location in the Texture. - * - * @method Phaser.Textures.TextureManager#getPixel - * @since 3.0.0 - * - * @param {integer} x - The x coordinate of the pixel within the Texture. - * @param {integer} y - The y coordinate of the pixel within the Texture. - * @param {string} key - The unique string-based key of the Texture. - * @param {string|integer} frame - The string or index of the Frame. - * - * @return {Phaser.Display.Color|null} A Color object populated with the color values of the requested pixel, - * or `null` if the coordinates were out of bounds. - */ - getPixel: function (x, y, key, frame) - { - var textureFrame = this.getFrame(key, frame); - - if (textureFrame) - { - var source = textureFrame.source.image; - - if (x >= 0 && x <= source.width && y >= 0 && y <= source.height) - { - x += textureFrame.cutX; - y += textureFrame.cutY; - - // if (textureFrame.trimmed) - // { - // x -= this.sprite.texture.trim.x; - // y -= this.sprite.texture.trim.y; - // } - - var context = this._tempContext; - - context.clearRect(0, 0, 1, 1); - context.drawImage(source, x, y, 1, 1, 0, 0, 1, 1); - - var rgb = context.getImageData(0, 0, 1, 1); - - return new Color(rgb.data[0], rgb.data[1], rgb.data[2], rgb.data[3]); - } - } - - return null; - }, - - /** - * Sets the given Game Objects `texture` and `frame` properties so that it uses - * the Texture and Frame specified in the `key` and `frame` arguments to this method. - * - * @method Phaser.Textures.TextureManager#setTexture - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - * @param {string} key - The unique string-based key of the Texture. - * @param {string|integer} frame - The string or index of the Frame. - * - * @return {Phaser.GameObjects.GameObject} The Game Object the texture was set on. - */ - setTexture: function (gameObject, key, frame) - { - if (this.list[key]) - { - gameObject.texture = this.list[key]; - gameObject.frame = gameObject.texture.get(frame); - } - - return gameObject; - }, - - /** - * Passes all Textures to the given callback. - * - * @method Phaser.Textures.TextureManager#each - * @since 3.0.0 - * - * @param {function} callback - The callback function to be sent the Textures. - * @param {object} scope - The value to use as `this` when executing the callback. - * @param {...*} [arguments] - Additional arguments that will be passed to the callback, after the child. - */ - each: function (callback, scope) - { - var args = [ null ]; - - for (var i = 1; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - for (var texture in this.list) - { - args[0] = this.list[texture]; - - callback.apply(scope, args); - } - }, - - /** - * Destroys the Texture Manager and all Textures stored within it. - * - * @method Phaser.Textures.TextureManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - for (var texture in this.list) - { - this.list[texture].destroy(); - } - - this.list = {}; - - this.game = null; - } - -}); - -module.exports = TextureManager; - - -/***/ }), -/* 264 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Textures.Parsers - */ - -module.exports = { - - Canvas: __webpack_require__(533), - Image: __webpack_require__(534), - JSONArray: __webpack_require__(535), - JSONHash: __webpack_require__(536), - Pyxel: __webpack_require__(537), - SpriteSheet: __webpack_require__(538), - SpriteSheetFromAtlas: __webpack_require__(539), - StarlingXML: __webpack_require__(540), - UnityYAML: __webpack_require__(541) - -}; - - -/***/ }), -/* 265 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Frame = __webpack_require__(131); -var TextureSource = __webpack_require__(266); - -/** - * @classdesc - * A Texture consists of a source, usually an Image from the Cache, or a Canvas, and a collection - * of Frames. The Frames represent the different areas of the Texture. For example a texture atlas - * may have many Frames, one for each element within the atlas. Where-as a single image would have - * just one frame, that encompasses the whole image. - * - * Textures are managed by the global TextureManager. This is a singleton class that is - * responsible for creating and delivering Textures and their corresponding Frames to Game Objects. - * - * Sprites and other Game Objects get the texture data they need from the TextureManager. - * - * @class Texture - * @memberOf Phaser.Textures - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Textures.TextureManager} manager - A reference to the Texture Manager this Texture belongs to. - * @param {string} key - The unique string-based key of this Texture. - * @param {Image|HTMLCanvasElement} source - The source that is used to create the texture. Usually an Image, but can also be a Canvas. - * @param {number} [width] - The width of the Texture. This is optional and automatically derived from the source images. - * @param {number} [height] - The height of the Texture. This is optional and automatically derived from the source images. - */ -var Texture = new Class({ - - initialize: - - function Texture (manager, key, source, width, height) - { - if (!Array.isArray(source)) - { - source = [ source ]; - } - - /** - * A reference to the Texture Manager this Texture belongs to. - * - * @name Phaser.Textures.Texture#manager - * @type {Phaser.Textures.TextureManager} - * @since 3.0.0 - */ - this.manager = manager; - - /** - * The unique string-based key of this Texture. - * - * @name Phaser.Textures.Texture#key - * @type {string} - * @since 3.0.0 - */ - this.key = key; - - /** - * An array of TextureSource instances. - * These are unique to this Texture and contain the actual Image (or Canvas) data. - * - * @name Phaser.Textures.Texture#source - * @type {Phaser.Textures.TextureSource[]} - * @since 3.0.0 - */ - this.source = []; - - /** - * An array of TextureSource data instances. - * Used to store additional data images, such as normal maps or specular maps. - * - * @name Phaser.Textures.Texture#dataSource - * @type {array} - * @since 3.0.0 - */ - this.dataSource = []; - - /** - * A key-value object pair associating the unique Frame keys with the Frames objects. - * - * @name Phaser.Textures.Texture#frames - * @type {object} - * @since 3.0.0 - */ - this.frames = {}; - - /** - * Any additional data that was set in the source JSON (if any), - * or any extra data you'd like to store relating to this texture - * - * @name Phaser.Textures.Texture#customData - * @type {object} - * @since 3.0.0 - */ - this.customData = {}; - - /** - * The name of the first frame of the Texture. - * - * @name Phaser.Textures.Texture#firstFrame - * @type {string} - * @since 3.0.0 - */ - this.firstFrame = '__BASE'; - - /** - * The total number of Frames in this Texture. - * - * @name Phaser.Textures.Texture#frameTotal - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.frameTotal = 0; - - // Load the Sources - for (var i = 0; i < source.length; i++) - { - this.source.push(new TextureSource(this, source[i], width, height)); - } - }, - - /** - * Adds a new Frame to this Texture. - * - * A Frame is a rectangular region of a TextureSource with a unique index or string-based key. - * - * @method Phaser.Textures.Texture#add - * @since 3.0.0 - * - * @param {integer|string} name - The name of this Frame. The name is unique within the Texture. - * @param {integer} sourceIndex - The index of the TextureSource that this Frame is a part of. - * @param {number} x - The x coordinate of the top-left of this Frame. - * @param {number} y - The y coordinate of the top-left of this Frame. - * @param {number} width - The width of this Frame. - * @param {number} height - The height of this Frame. - * - * @return {Phaser.Textures.Frame} The Frame that was added to this Texture. - */ - add: function (name, sourceIndex, x, y, width, height) - { - var frame = new Frame(this, name, sourceIndex, x, y, width, height); - - this.frames[name] = frame; - - // Set the first frame of the Texture (other than __BASE) - // This is used to ensure we don't spam the display with entire - // atlases of sprite sheets, but instead just the first frame of them - // should the dev incorrectly specify the frame index - if (this.frameTotal === 1) - { - this.firstFrame = name; - } - - this.frameTotal++; - - return frame; - }, - - /** - * Checks to see if a Frame matching the given key exists within this Texture. - * - * @method Phaser.Textures.Texture#has - * @since 3.0.0 - * - * @param {string} name - The key of the Frame to check for. - * - * @return {boolean} True if a Frame with the matching key exists in this Texture. - */ - has: function (name) - { - return (this.frames[name]); - }, - - /** - * Gets a Frame from this Texture based on either the key or the index of the Frame. - * - * In a Texture Atlas Frames are typically referenced by a key. - * In a Sprite Sheet Frames are referenced by an index. - * Passing no value for the name returns the base texture. - * - * @method Phaser.Textures.Texture#get - * @since 3.0.0 - * - * @param {string|integer} [name] - The string-based name, or integer based index, of the Frame to get from this Texture. - * - * @return {Phaser.Textures.Frame} The Texture Frame. - */ - get: function (name) - { - // null, undefined, empty string, zero - if (!name) - { - name = this.firstFrame; - } - - var frame = this.frames[name]; - - if (!frame) - { - console.warn('No Texture.frame found with name ' + name); - - frame = this.frames[this.firstFrame]; - } - - return frame; - }, - - /** - * Takes the given TextureSource and returns the index of it within this Texture. - * If it's not in this Texture, it returns -1. - * Unless this Texture has multiple TextureSources, such as with a multi-atlas, this - * method will always return zero or -1. - * - * @method Phaser.Textures.Texture#getTextureSourceIndex - * @since 3.0.0 - * - * @param {Phaser.Textures.TextureSource} source - The TextureSource to check. - * - * @return {integer} The index of the TextureSource within this Texture, or -1 if not in this Texture. - */ - getTextureSourceIndex: function (source) - { - for (var i = 0; i < this.source.length; i++) - { - if (this.source[i] === source) - { - return i; - } - } - - return -1; - }, - - /** - * Returns an array of all the Frames in the given TextureSource. - * - * @method Phaser.Textures.Texture#getFramesFromTextureSource - * @since 3.0.0 - * - * @param {integer} sourceIndex - The index of the TextureSource to get the Frames from. - * - * @return {Phaser.Textures.Frame[]} An array of Texture Frames. - */ - getFramesFromTextureSource: function (sourceIndex) - { - var out = []; - - for (var frameName in this.frames) - { - if (frameName === '__BASE') - { - continue; - } - - var frame = this.frames[frameName]; - - if (frame.sourceIndex === sourceIndex) - { - out.push(frame.name); - } - } - - return out; - }, - - /** - * Returns an array with all of the names of the Frames in this Texture. - * - * Useful if you want to randomly assign a Frame to a Game Object, as you can - * pick a random element from the returned array. - * - * @method Phaser.Textures.Texture#getFrameNames - * @since 3.0.0 - * - * @param {boolean} [includeBase=false] - Include the `__BASE` Frame in the output array? - * - * @return {string[]} An array of all Frame names in this Texture. - */ - getFrameNames: function (includeBase) - { - if (includeBase === undefined) { includeBase = false; } - - var out = Object.keys(this.frames); - - if (!includeBase) - { - var idx = out.indexOf('__BASE'); - - if (idx !== -1) - { - out.splice(idx, 1); - } - } - - return out; - }, - - /** - * Given a Frame name, return the source image it uses to render with. - * - * This will return the actual DOM Image or Canvas element. - * - * @method Phaser.Textures.Texture#getSourceImage - * @since 3.0.0 - * - * @param {string|integer} [name] - The string-based name, or integer based index, of the Frame to get from this Texture. - * - * @return {Image|HTMLCanvasElement} The DOM Image or Canvas Element. - */ - getSourceImage: function (name) - { - if (name === undefined || name === null || this.frameTotal === 1) - { - name = '__BASE'; - } - - var frame = this.frames[name]; - - if (!frame) - { - console.warn('No Texture.frame found with name ' + name); - - return this.frames['__BASE'].source.image; - } - else - { - return frame.source.image; - } - }, - - /** - * Adds a data source image to this Texture. - * - * An example of a data source image would be a normal map, where all of the Frames for this Texture - * equally apply to the normal map. - * - * @method Phaser.Textures.Texture#setDataSource - * @since 3.0.0 - * - * @param {Image|HTMLCanvasElement} data - The source image. - */ - setDataSource: function (data) - { - if (!Array.isArray(data)) - { - data = [ data ]; - } - - for (var i = 0; i < data.length; i++) - { - var source = this.source[i]; - - this.dataSource.push(new TextureSource(this, data[i], source.width, source.height)); - } - }, - - /** - * Sets the Filter Mode for this Texture. - * - * The mode can be either Linear, the default, or Nearest. - * - * For pixel-art you should use Nearest. - * - * The mode applies to the entire Texture, not just a specific Frame of it. - * - * @method Phaser.Textures.Texture#setFilter - * @since 3.0.0 - * - * @param {Phaser.Textures.FilterMode.LINEAR|Phaser.Textures.FilterMode.NEAREST} filterMode - The Filter Mode. - */ - setFilter: function (filterMode) - { - var i; - - for (i = 0; i < this.source.length; i++) - { - this.source[i].setFilter(filterMode); - } - - for (i = 0; i < this.dataSource.length; i++) - { - this.dataSource[i].setFilter(filterMode); - } - }, - - /** - * Destroys this Texture and releases references to its sources and frames. - * - * @method Phaser.Textures.Texture#destroy - * @since 3.0.0 - */ - destroy: function () - { - var i; - - for (i = 0; i < this.source.length; i++) - { - this.source[i].destroy(); - } - - for (i = 0; i < this.dataSource.length; i++) - { - this.dataSource[i].destroy(); - } - - for (var frameName in this.frames) - { - var frame = this.frames[frameName]; - - frame.destroy(); - } - - this.source = []; - this.dataSource = []; - this.frames = {}; - } - -}); - -module.exports = Texture; - - -/***/ }), -/* 266 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(19); -var IsSizePowerOfTwo = __webpack_require__(127); -var ScaleModes = __webpack_require__(63); - -/** - * @classdesc - * A Texture Source is the encapsulation of the actual source data for a Texture. - * This is typically an Image Element, loaded from the file system or network, or a Canvas Element. - * - * A Texture can contain multiple Texture Sources, which only happens when a multi-atlas is loaded. - * - * @class TextureSource - * @memberOf Phaser.Textures - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture this TextureSource belongs to. - * @param {Image|HTMLCanvasElement} source - The source image data. - * @param {integer} [width] - Optional width of the source image. If not given it's derived from the source itself. - * @param {integer} [height] - Optional height of the source image. If not given it's derived from the source itself. - */ -var TextureSource = new Class({ - - initialize: - - function TextureSource (texture, source, width, height) - { - var game = texture.manager.game; - - /** - * The Texture this TextureSource belongs to. - * - * @name Phaser.Textures.TextureSource#texture - * @type {string} - * @since 3.0.0 - */ - this.texture = texture; - - /** - * The source image data. This is either an Image Element, or a Canvas Element. - * - * @name Phaser.Textures.TextureSource#image - * @type {Image|HTMLCanvasElement} - * @since 3.0.0 - */ - this.image = source; - - /** - * Currently un-used. - * - * @name Phaser.Textures.TextureSource#compressionAlgorithm - * @type {integer} - * @default null - * @since 3.0.0 - */ - this.compressionAlgorithm = null; - - /** - * The resolution of the source image. - * - * @name Phaser.Textures.TextureSource#resolution - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.resolution = 1; - - /** - * The width of the source image. If not specified in the constructor it will check - * the `naturalWidth` and then `width` properties of the source image. - * - * @name Phaser.Textures.TextureSource#width - * @type {integer} - * @since 3.0.0 - */ - this.width = width || source.naturalWidth || source.width || 0; - - /** - * The height of the source image. If not specified in the constructor it will check - * the `naturalHeight` and then `height` properties of the source image. - * - * @name Phaser.Textures.TextureSource#height - * @type {integer} - * @since 3.0.0 - */ - this.height = height || source.naturalHeight || source.height || 0; - - /** - * The Scale Mode the image will use when rendering. - * Either Linear or Nearest. - * - * @name Phaser.Textures.TextureSource#scaleMode - * @type {[type]} - * @since 3.0.0 - */ - this.scaleMode = ScaleModes.DEFAULT; - - /** - * Is the source image a Canvas Element? - * - * @name Phaser.Textures.TextureSource#isCanvas - * @type {boolean} - * @since 3.0.0 - */ - this.isCanvas = (source instanceof HTMLCanvasElement); - - /** - * Are the source image dimensions a power of two? - * - * @name Phaser.Textures.TextureSource#isPowerOf2 - * @type {boolean} - * @since 3.0.0 - */ - this.isPowerOf2 = IsSizePowerOfTwo(this.width, this.height); - - /** - * The WebGL Texture of the source image. - * - * @name Phaser.Textures.TextureSource#glTexture - * @type {?[type]} - * @default null - * @since 3.0.0 - */ - this.glTexture = null; - - this.init(game); - }, - - /** - * Creates a WebGL Texture, if required, and sets the Texture filter mode. - * - * @method Phaser.Textures.TextureSource#init - * @since 3.0.0 - * - * @param {Phaser.Game} game - A reference to the Phaser Game instance. - */ - init: function (game) - { - if (game.config.renderType === CONST.WEBGL) - { - this.glTexture = game.renderer.createTextureFromSource(this.image, this.width, this.height, this.scaleMode); - } - - if (game.config.pixelArt) - { - this.setFilter(1); - } - }, - - /** - * Sets the Filter Mode for this Texture. - * - * The mode can be either Linear, the default, or Nearest. - * - * For pixel-art you should use Nearest. - * - * @method Phaser.Textures.TextureSource#setFilter - * @since 3.0.0 - * - * @param {Phaser.Textures.FilterMode.LINEAR|Phaser.Textures.FilterMode.NEAREST} filterMode - The Filter Mode. - */ - setFilter: function (filterMode) - { - var game = this.texture.manager.game; - - if (game.config.renderType === CONST.WEBGL) - { - game.renderer.setTextureFilter(this.glTexture, filterMode); - } - }, - - /** - * Destroys this Texture Source and nulls the source image reference. - * - * @method Phaser.Textures.TextureSource#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.texture = null; - - this.image = null; - } - -}); - -module.exports = TextureSource; - - -/***/ }), -/* 267 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -//! stable.js 0.1.6, https://github.com/Two-Screen/stable -//! © 2017 Angry Bytes and contributors. MIT licensed. - -(function() { - -// A stable array sort, because `Array#sort()` is not guaranteed stable. -// This is an implementation of merge sort, without recursion. - -var stable = function(arr, comp) { - return exec(arr.slice(), comp); -}; - -stable.inplace = function(arr, comp) { - var result = exec(arr, comp); - - // This simply copies back if the result isn't in the original array, - // which happens on an odd number of passes. - if (result !== arr) { - pass(result, null, arr.length, arr); - } - - return arr; -}; - -// Execute the sort using the input array and a second buffer as work space. -// Returns one of those two, containing the final result. -function exec(arr, comp) { - if (typeof(comp) !== 'function') { - comp = function(a, b) { - return String(a).localeCompare(b); - }; - } - - // Short-circuit when there's nothing to sort. - var len = arr.length; - if (len <= 1) { - return arr; - } - - // Rather than dividing input, simply iterate chunks of 1, 2, 4, 8, etc. - // Chunks are the size of the left or right hand in merge sort. - // Stop when the left-hand covers all of the array. - var buffer = new Array(len); - for (var chk = 1; chk < len; chk *= 2) { - pass(arr, comp, chk, buffer); - - var tmp = arr; - arr = buffer; - buffer = tmp; - } - - return arr; -} - -// Run a single pass with the given chunk size. -var pass = function(arr, comp, chk, result) { - var len = arr.length; - var i = 0; - // Step size / double chunk size. - var dbl = chk * 2; - // Bounds of the left and right chunks. - var l, r, e; - // Iterators over the left and right chunk. - var li, ri; - - // Iterate over pairs of chunks. - for (l = 0; l < len; l += dbl) { - r = l + chk; - e = r + chk; - if (r > len) r = len; - if (e > len) e = len; - - // Iterate both chunks in parallel. - li = l; - ri = r; - while (true) { - // Compare the chunks. - if (li < r && ri < e) { - // This works for a regular `sort()` compatible comparator, - // but also for a simple comparator like: `a > b` - if (comp(arr[li], arr[ri]) <= 0) { - result[i++] = arr[li++]; - } - else { - result[i++] = arr[ri++]; - } - } - // Nothing to compare, just flush what's left. - else if (li < r) { - result[i++] = arr[li++]; - } - else if (ri < e) { - result[i++] = arr[ri++]; - } - // Both iterators are at the chunk ends. - else { - break; - } - } - } -}; - -// Export using CommonJS or to the window. -if (true) { - module.exports = stable; -} -else { - window.stable = stable; -} - -})(); - -/***/ }), -/* 268 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - - -var GetBitmapTextSize = function (src, round) -{ - var text = src.text; - var textLength = text.length; - - var bx = Number.MAX_VALUE; - var by = Number.MAX_VALUE; - var bw = 0; - var bh = 0; - - var chars = src.fontData.chars; - var lineHeight = src.fontData.lineHeight; - - var xAdvance = 0; - var yAdvance = 0; - - var indexCount = 0; - var charCode = 0; - - var glyph = null; - var glyphW = 0; - var glyphH = 0; - - var x = 0; - var y = 0; - - var lastGlyph = null; - var lastCharCode = 0; - - for (var index = 0; index < textLength; ++index) - { - charCode = text.charCodeAt(index); - - if (charCode === 10) - { - xAdvance = 0; - indexCount = 0; - yAdvance += lineHeight; - lastGlyph = null; - continue; - } - - glyph = chars[charCode]; - - if (!glyph) - { - continue; - } - - glyphW = glyph.width; - glyphH = glyph.height; - - x = indexCount + glyph.xOffset + xAdvance; - y = glyph.yOffset + yAdvance; - - if (lastGlyph !== null) - { - var kerningOffset = glyph.kerning[lastCharCode]; - x += (kerningOffset !== undefined) ? kerningOffset : 0; - } - - if (bx > x) - { - bx = x; - } - - if (by > y) - { - by = y; - } - - var gw = x + glyphW - bx; - var gh = y + glyphH - by; - - if (bw < gw) - { - bw = gw; - } - - if (bh < gh) - { - bh = gh; - } - - xAdvance += glyph.xAdvance; - indexCount += 1; - lastGlyph = glyph; - lastCharCode = charCode; - } - - var scale = (src.fontSize / src.fontData.size); - var sx = scale * src.scaleX; - var sy = scale * src.scaleY; - - var out = { - local: { - x: bx * scale, - y: by * scale, - width: bw * scale, - height: bh * scale - }, - global: { - x: src.x + (bx * sx), - y: src.y + (by * sy), - width: bw * sx, - height: bh * sy - } - }; - - if (round) - { - out.local.x = Math.round(out.local.x); - out.local.y = Math.round(out.local.y); - out.local.width = Math.round(out.local.width); - out.local.height = Math.round(out.local.height); - - out.global.x = Math.round(out.global.x); - out.global.y = Math.round(out.global.y); - out.global.width = Math.round(out.global.width); - out.global.height = Math.round(out.global.height); - } - - return out; -}; - -module.exports = GetBitmapTextSize; - - -/***/ }), -/* 269 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -function getValue (node, attribute) -{ - return parseInt(node.getAttribute(attribute), 10); -} - -var ParseXMLBitmapFont = function (xml, xSpacing, ySpacing, frame) -{ - if (xSpacing === undefined) { xSpacing = 0; } - if (ySpacing === undefined) { ySpacing = 0; } - - var data = {}; - var info = xml.getElementsByTagName('info')[0]; - var common = xml.getElementsByTagName('common')[0]; - - data.font = info.getAttribute('face'); - data.size = getValue(info, 'size'); - data.lineHeight = getValue(common, 'lineHeight') + ySpacing; - data.chars = {}; - - var letters = xml.getElementsByTagName('char'); - - var adjustForTrim = (frame !== undefined && frame.trimmed); - - if (adjustForTrim) - { - var top = frame.height; - var left = frame.width; - } - - for (var i = 0; i < letters.length; i++) - { - var node = letters[i]; - - var charCode = getValue(node, 'id'); - var gx = getValue(node, 'x'); - var gy = getValue(node, 'y'); - var gw = getValue(node, 'width'); - var gh = getValue(node, 'height'); - - // Handle frame trim issues - - if (adjustForTrim) - { - if (gx < left) - { - left = gx; - } - - if (gy < top) - { - top = gy; - } - } - - data.chars[charCode] = - { - x: gx, - y: gy, - width: gw, - height: gh, - centerX: Math.floor(gw / 2), - centerY: Math.floor(gh / 2), - xOffset: getValue(node, 'xoffset'), - yOffset: getValue(node, 'yoffset'), - xAdvance: getValue(node, 'xadvance') + xSpacing, - data: {}, - kerning: {} - }; - } - - if (adjustForTrim && top !== 0 && left !== 0) - { - // console.log('top and left', top, left, frame.x, frame.y); - - // Now we know the top and left coordinates of the glyphs in the original data - // so we can work out how much to adjust the glyphs by - - for (var code in data.chars) - { - var glyph = data.chars[code]; - - glyph.x -= frame.x; - glyph.y -= frame.y; - } - } - - var kernings = xml.getElementsByTagName('kerning'); - - for (i = 0; i < kernings.length; i++) - { - var kern = kernings[i]; - - var first = getValue(kern, 'first'); - var second = getValue(kern, 'second'); - var amount = getValue(kern, 'amount'); - - data.chars[second].kerning[first] = amount; - } - - return data; -}; - -module.exports = ParseXMLBitmapFont; - - -/***/ }), -/* 270 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Ellipse = __webpack_require__(137); - -Ellipse.Area = __webpack_require__(559); -Ellipse.Circumference = __webpack_require__(273); -Ellipse.CircumferencePoint = __webpack_require__(138); -Ellipse.Clone = __webpack_require__(560); -Ellipse.Contains = __webpack_require__(68); -Ellipse.ContainsPoint = __webpack_require__(561); -Ellipse.ContainsRect = __webpack_require__(562); -Ellipse.CopyFrom = __webpack_require__(563); -Ellipse.Equals = __webpack_require__(564); -Ellipse.GetBounds = __webpack_require__(565); -Ellipse.GetPoint = __webpack_require__(271); -Ellipse.GetPoints = __webpack_require__(272); -Ellipse.Offset = __webpack_require__(566); -Ellipse.OffsetPoint = __webpack_require__(567); -Ellipse.Random = __webpack_require__(110); - -module.exports = Ellipse; - - -/***/ }), -/* 271 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CircumferencePoint = __webpack_require__(138); -var FromPercent = __webpack_require__(65); -var MATH_CONST = __webpack_require__(16); -var Point = __webpack_require__(5); - -/** - * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse - * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point - * at 180 degrees around the circle. - * - * @function Phaser.Geom.Ellipse.GetPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on. - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. - * @param {Phaser.Geom.Point|object} [out] - An object to store the return values in. If not given a Point object will be created. - * - * @return {Phaser.Geom.Point|object} A Point, or point-like object, containing the coordinates of the point around the ellipse. - */ -var GetPoint = function (ellipse, position, out) -{ - if (out === undefined) { out = new Point(); } - - var angle = FromPercent(position, 0, MATH_CONST.PI2); - - return CircumferencePoint(ellipse, angle, out); -}; - -module.exports = GetPoint; - - -/***/ }), -/* 272 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Circumference = __webpack_require__(273); -var CircumferencePoint = __webpack_require__(138); -var FromPercent = __webpack_require__(65); -var MATH_CONST = __webpack_require__(16); - -/** - * Returns an array of Point objects containing the coordinates of the points around the circumference of the Ellipse, - * based on the given quantity or stepRate values. - * - * @function Phaser.Geom.Ellipse.GetPoints - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the points from. - * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param {number} [stepRate] - Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate. - * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. - * - * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the circumference of the ellipse. - */ -var GetPoints = function (ellipse, quantity, stepRate, out) -{ - if (out === undefined) { out = []; } - - // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. - if (!quantity) - { - quantity = Circumference(ellipse) / stepRate; - } - - for (var i = 0; i < quantity; i++) - { - var angle = FromPercent(i / quantity, 0, MATH_CONST.PI2); - - out.push(CircumferencePoint(ellipse, angle)); - } - - return out; -}; - -module.exports = GetPoints; - - -/***/ }), -/* 273 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the circumference of the given Ellipse. - * - * @function Phaser.Geom.Ellipse.Circumference - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference of. - * - * @return {number} The circumference of th Ellipse. - */ -var Circumference = function (ellipse) -{ - var rx = ellipse.width / 2; - var ry = ellipse.height / 2; - var h = Math.pow((rx - ry), 2) / Math.pow((rx + ry), 2); - - return (Math.PI * (rx + ry)) * (1 + ((3 * h) / (10 + Math.sqrt(4 - (3 * h))))); -}; - -module.exports = Circumference; - - -/***/ }), -/* 274 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Commands = __webpack_require__(128); -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Graphics#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Graphics} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {[type]} renderTargetCtx - [description] - * @param {boolean} allowClip - [description] - */ -var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, camera, renderTargetCtx, allowClip) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - var cameraScrollX = camera.scrollX * src.scrollFactorX; - var cameraScrollY = camera.scrollY * src.scrollFactorY; - var srcX = src.x; - var srcY = src.y; - var srcScaleX = src.scaleX; - var srcScaleY = src.scaleY; - var srcRotation = src.rotation; - var commandBuffer = src.commandBuffer; - var ctx = renderTargetCtx || renderer.currentContext; - var lineAlpha = 1.0; - var fillAlpha = 1.0; - var lineColor = 0; - var fillColor = 0; - var lineWidth = 1.0; - var red = 0; - var green = 0; - var blue = 0; - - // Blend Mode - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - ctx.save(); - ctx.translate(srcX - cameraScrollX, srcY - cameraScrollY); - ctx.rotate(srcRotation); - ctx.scale(srcScaleX, srcScaleY); - ctx.fillStyle = '#fff'; - ctx.globalAlpha = src.alpha; - - for (var index = 0, length = commandBuffer.length; index < length; ++index) - { - var commandID = commandBuffer[index]; - - switch (commandID) - { - case Commands.ARC: - ctx.arc( - commandBuffer[index + 1], - commandBuffer[index + 2], - commandBuffer[index + 3], - commandBuffer[index + 4], - commandBuffer[index + 5], - commandBuffer[index + 6] - ); - index += 6; - break; - - case Commands.LINE_STYLE: - lineWidth = commandBuffer[index + 1]; - lineColor = commandBuffer[index + 2]; - lineAlpha = commandBuffer[index + 3]; - red = ((lineColor & 0xFF0000) >>> 16); - green = ((lineColor & 0xFF00) >>> 8); - blue = (lineColor & 0xFF); - ctx.strokeStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + lineAlpha + ')'; - ctx.lineWidth = lineWidth; - index += 3; - break; - - case Commands.FILL_STYLE: - fillColor = commandBuffer[index + 1]; - fillAlpha = commandBuffer[index + 2]; - red = ((fillColor & 0xFF0000) >>> 16); - green = ((fillColor & 0xFF00) >>> 8); - blue = (fillColor & 0xFF); - ctx.fillStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + fillAlpha + ')'; - index += 2; - break; - - case Commands.BEGIN_PATH: - ctx.beginPath(); - break; - - case Commands.CLOSE_PATH: - ctx.closePath(); - break; - - case Commands.FILL_PATH: - if (!allowClip) - { - ctx.fill(); - } - break; - - case Commands.STROKE_PATH: - if (!allowClip) - { - ctx.stroke(); - } - break; - - case Commands.FILL_RECT: - if (!allowClip) - { - ctx.fillRect( - commandBuffer[index + 1], - commandBuffer[index + 2], - commandBuffer[index + 3], - commandBuffer[index + 4] - ); - } - else - { - ctx.rect( - commandBuffer[index + 1], - commandBuffer[index + 2], - commandBuffer[index + 3], - commandBuffer[index + 4] - ); - } - index += 4; - break; - - case Commands.FILL_TRIANGLE: - ctx.beginPath(); - ctx.moveTo(commandBuffer[index + 1], commandBuffer[index + 2]); - ctx.lineTo(commandBuffer[index + 3], commandBuffer[index + 4]); - ctx.lineTo(commandBuffer[index + 5], commandBuffer[index + 6]); - ctx.closePath(); - if (!allowClip) - { - ctx.fill(); - } - index += 6; - break; - - case Commands.STROKE_TRIANGLE: - ctx.beginPath(); - ctx.moveTo(commandBuffer[index + 1], commandBuffer[index + 2]); - ctx.lineTo(commandBuffer[index + 3], commandBuffer[index + 4]); - ctx.lineTo(commandBuffer[index + 5], commandBuffer[index + 6]); - ctx.closePath(); - if (!allowClip) - { - ctx.stroke(); - } - index += 6; - break; - - case Commands.LINE_TO: - ctx.lineTo( - commandBuffer[index + 1], - commandBuffer[index + 2] - ); - index += 2; - break; - - case Commands.MOVE_TO: - ctx.moveTo( - commandBuffer[index + 1], - commandBuffer[index + 2] - ); - index += 2; - break; - - case Commands.LINE_FX_TO: - ctx.lineTo( - commandBuffer[index + 1], - commandBuffer[index + 2] - ); - index += 5; - break; - - case Commands.MOVE_FX_TO: - ctx.moveTo( - commandBuffer[index + 1], - commandBuffer[index + 2] - ); - index += 5; - break; - - case Commands.SAVE: - ctx.save(); - break; - - case Commands.RESTORE: - ctx.restore(); - break; - - case Commands.TRANSLATE: - ctx.translate( - commandBuffer[index + 1], - commandBuffer[index + 2] - ); - index += 2; - break; - - case Commands.SCALE: - ctx.scale( - commandBuffer[index + 1], - commandBuffer[index + 2] - ); - index += 2; - break; - - case Commands.ROTATE: - ctx.rotate( - commandBuffer[index + 1] - ); - index += 1; - break; - - default: - // console.error('Phaser: Invalid Graphics Command ID ' + commandID); - break; - } - } - - ctx.restore(); -}; - -module.exports = GraphicsCanvasRenderer; - - -/***/ }), -/* 275 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetValue = __webpack_require__(4); -var Shuffle = __webpack_require__(80); - -var BuildChunk = function (a, b, qty) -{ - var out = []; - - for (var aIndex = 0; aIndex < a.length; aIndex++) - { - for (var bIndex = 0; bIndex < b.length; bIndex++) - { - for (var i = 0; i < qty; i++) - { - out.push({ a: a[aIndex], b: b[bIndex] }); - } - } - } - - return out; -}; - -// options = repeat, random, randomB, yoyo, max, qty - -// Range ([a,b,c], [1,2,3]) = -// a1, a2, a3, b1, b2, b3, c1, c2, c3 - -// Range ([a,b], [1,2,3], qty = 3) = -// a1, a1, a1, a2, a2, a2, a3, a3, a3, b1, b1, b1, b2, b2, b2, b3, b3, b3 - -// Range ([a,b,c], [1,2,3], repeat x1) = -// a1, a2, a3, b1, b2, b3, c1, c2, c3, a1, a2, a3, b1, b2, b3, c1, c2, c3 - -// Range ([a,b], [1,2], repeat -1 = endless, max = 14) = -// Maybe if max is set then repeat goes to -1 automatically? -// a1, a2, b1, b2, a1, a2, b1, b2, a1, a2, b1, b2, a1, a2 (capped at 14 elements) - -// Range ([a], [1,2,3,4,5], random = true) = -// a4, a1, a5, a2, a3 - -// Range ([a, b], [1,2,3], random = true) = -// b3, a2, a1, b1, a3, b2 - -// Range ([a, b, c], [1,2,3], randomB = true) = -// a3, a1, a2, b2, b3, b1, c1, c3, c2 - -// Range ([a], [1,2,3,4,5], yoyo = true) = -// a1, a2, a3, a4, a5, a5, a4, a3, a2, a1 - -// Range ([a, b], [1,2,3], yoyo = true) = -// a1, a2, a3, b1, b2, b3, b3, b2, b1, a3, a2, a1 - -/** - * [description] - * - * @function Phaser.Utils.Array.Range - * @since 3.0.0 - * - * @param {[type]} a - [description] - * @param {[type]} b - [description] - * @param {[type]} options - [description] - * - * @return {[type]} [description] - */ -var Range = function (a, b, options) -{ - var max = GetValue(options, 'max', 0); - var qty = GetValue(options, 'qty', 1); - var random = GetValue(options, 'random', false); - var randomB = GetValue(options, 'randomB', false); - var repeat = GetValue(options, 'repeat', 0); - var yoyo = GetValue(options, 'yoyo', false); - - var out = []; - - if (randomB) - { - Shuffle(b); - } - - // Endless repeat, so limit by max - if (repeat === -1) - { - if (max === 0) - { - repeat = 0; - } - else - { - // Work out how many repeats we need - var total = (a.length * b.length) * qty; - - if (yoyo) - { - total *= 2; - } - - repeat = Math.ceil(max / total); - } - } - - for (var i = 0; i <= repeat; i++) - { - var chunk = BuildChunk(a, b, qty); - - if (random) - { - Shuffle(chunk); - } - - out = out.concat(chunk); - - if (yoyo) - { - chunk.reverse(); - - out = out.concat(chunk); - } - } - - if (max) - { - out.splice(max); - } - - return out; -}; - -module.exports = Range; - - -/***/ }), -/* 276 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.FloatBetween - * @since 3.0.0 - * - * @param {float} min - [description] - * @param {float} max - [description] - * - * @return {float} [description] - */ -var FloatBetween = function (min, max) -{ - return Math.random() * (max - min) + min; -}; - -module.exports = FloatBetween; - - -/***/ }), -/* 277 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Phaser.Math.Easing.Back - -module.exports = { - - In: __webpack_require__(579), - Out: __webpack_require__(580), - InOut: __webpack_require__(581) - -}; - - -/***/ }), -/* 278 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Phaser.Math.Easing.Bounce - -module.exports = { - - In: __webpack_require__(582), - Out: __webpack_require__(583), - InOut: __webpack_require__(584) - -}; - - -/***/ }), -/* 279 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Phaser.Math.Easing.Circular - -module.exports = { - - In: __webpack_require__(585), - Out: __webpack_require__(586), - InOut: __webpack_require__(587) - -}; - - -/***/ }), -/* 280 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Phaser.Math.Easing.Cubic - -module.exports = { - - In: __webpack_require__(588), - Out: __webpack_require__(589), - InOut: __webpack_require__(590) - -}; - - -/***/ }), -/* 281 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Phaser.Math.Easing.Elastic - -module.exports = { - - In: __webpack_require__(591), - Out: __webpack_require__(592), - InOut: __webpack_require__(593) - -}; - - /***/ }), /* 282 */ /***/ (function(module, exports, __webpack_require__) { @@ -58461,15 +61761,423 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Phaser.Math.Easing.Expo +var BaseSoundManager = __webpack_require__(99); +var Class = __webpack_require__(0); +var HTML5AudioSound = __webpack_require__(281); -module.exports = { +/** + * HTML5 Audio implementation of the sound manager. + * + * @class HTML5AudioSoundManager + * @extends Phaser.Sound.BaseSoundManager + * @memberOf Phaser.Sound + * @constructor + * @author Pavle Goloskokovic (http://prunegames.com) + * @since 3.0.0 + * + * @param {Phaser.Game} game - Reference to the current game instance. + */ +var HTML5AudioSoundManager = new Class({ - In: __webpack_require__(594), - Out: __webpack_require__(595), - InOut: __webpack_require__(596) + Extends: BaseSoundManager, -}; + initialize: + + function HTML5AudioSoundManager (game) + { + /** + * Flag indicating whether if there are no idle instances of HTML5 Audio tag, + * for any particular sound, if one of the used tags should be hijacked and used + * for succeeding playback or if succeeding Phaser.Sound.HTML5AudioSound#play + * call should be ignored. + * + * @name Phaser.Sound.HTML5AudioSoundManager#override + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.override = true; + + /** + * Value representing time difference, in seconds, between calling + * play method on an audio tag and when it actually starts playing. + * It is used to achieve more accurate delayed sound playback. + * + * You might need to tweak this value to get the desired results + * since audio play delay varies depending on the browser/platform. + * + * @name Phaser.Sound.HTML5AudioSoundManager#audioPlayDelay + * @type {number} + * @default 0.1 + * @since 3.0.0 + */ + this.audioPlayDelay = 0.1; + + /** + * A value by which we should offset the loop end marker of the + * looping sound to compensate for lag, caused by changing audio + * tag playback position, in order to achieve gapless looping. + * + * You might need to tweak this value to get the desired results + * since loop lag varies depending on the browser/platform. + * + * @name Phaser.Sound.HTML5AudioSoundManager#loopEndOffset + * @type {number} + * @default 0.05 + * @since 3.0.0 + */ + this.loopEndOffset = 0.05; + + /** + * An array for keeping track of all the sounds + * that were paused when game lost focus. + * + * @name Phaser.Sound.HTML5AudioSoundManager#onBlurPausedSounds + * @type {Phaser.Sound.HTML5AudioSound[]} + * @private + * @default [] + * @since 3.0.0 + */ + this.onBlurPausedSounds = []; + + this.locked = 'ontouchstart' in window; + + /** + * A queue of all actions performed on sound objects while audio was locked. + * Once the audio gets unlocked, after an explicit user interaction, + * all actions will be performed in chronological order. + * Array of object types: { sound: Phaser.Sound.HTML5AudioSound, name: string, value?: * } + * + * @name Phaser.Sound.HTML5AudioSoundManager#lockedActionsQueue + * @type {array} + * @private + * @since 3.0.0 + */ + this.lockedActionsQueue = this.locked ? [] : null; + + /** + * Property that actually holds the value of global mute + * for HTML5 Audio sound manager implementation. + * + * @name Phaser.Sound.HTML5AudioSoundManager#_mute + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._mute = false; + + /** + * Property that actually holds the value of global volume + * for HTML5 Audio sound manager implementation. + * + * @name Phaser.Sound.HTML5AudioSoundManager#_volume + * @type {boolean} + * @private + * @default 1 + * @since 3.0.0 + */ + this._volume = 1; + + BaseSoundManager.call(this, game); + }, + + /** + * Adds a new sound into the sound manager. + * + * @method Phaser.Sound.HTML5AudioSoundManager#add + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * + * @return {Phaser.Sound.HTML5AudioSound} The new sound instance. + */ + add: function (key, config) + { + var sound = new HTML5AudioSound(this, key, config); + + this.sounds.push(sound); + + return sound; + }, + + /** + * Unlocks HTML5 Audio loading and playback on mobile + * devices on the initial explicit user interaction. + * + * @method Phaser.Sound.HTML5AudioSoundManager#unlock + * @since 3.0.0 + */ + unlock: function () + { + var _this = this; + + var moved = false; + + var detectMove = function () + { + moved = true; + }; + + var unlock = function () + { + if (!_this.game.cache.audio.entries.size) + { + return; + } + + if (moved) + { + moved = false; + return; + } + + document.body.removeEventListener('touchmove', detectMove); + document.body.removeEventListener('touchend', unlock); + + var allTags = []; + + _this.game.cache.audio.entries.each(function (key, tags) + { + for (var i = 0; i < tags.length; i++) + { + allTags.push(tags[i]); + } + return true; + }); + + var lastTag = allTags[allTags.length - 1]; + + lastTag.oncanplaythrough = function () + { + lastTag.oncanplaythrough = null; + _this.unlocked = true; + }; + + allTags.forEach(function (tag) + { + tag.load(); + }); + }; + + this.once('unlocked', function () + { + this.forEachActiveSound(function (sound) + { + sound.duration = sound.tags[0].duration; + sound.totalDuration = sound.tags[0].duration; + }); + + this.lockedActionsQueue.forEach(function (lockedAction) + { + if (lockedAction.sound[lockedAction.prop].apply) + { + lockedAction.sound[lockedAction.prop].apply(lockedAction.sound, lockedAction.value || []); + } + else + { + lockedAction.sound[lockedAction.prop] = lockedAction.value; + } + }); + + this.lockedActionsQueue.length = 0; + this.lockedActionsQueue = null; + }, this); + + document.body.addEventListener('touchmove', detectMove, false); + document.body.addEventListener('touchend', unlock, false); + }, + + /** + * Method used internally for pausing sound manager if + * Phaser.Sound.HTML5AudioSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.HTML5AudioSoundManager#onBlur + * @protected + * @since 3.0.0 + */ + onBlur: function () + { + this.forEachActiveSound(function (sound) + { + if (sound.isPlaying) + { + this.onBlurPausedSounds.push(sound); + sound.onBlur(); + } + }); + }, + + /** + * Method used internally for resuming sound manager if + * Phaser.Sound.HTML5AudioSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.HTML5AudioSoundManager#onFocus + * @protected + * @since 3.0.0 + */ + onFocus: function () + { + this.onBlurPausedSounds.forEach(function (sound) + { + sound.onFocus(); + }); + + this.onBlurPausedSounds.length = 0; + }, + + /** + * Calls Phaser.Sound.BaseSoundManager#destroy method + * and cleans up all HTML5 Audio related stuff. + * + * @method Phaser.Sound.HTML5AudioSoundManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + BaseSoundManager.prototype.destroy.call(this); + + this.onBlurPausedSounds.length = 0; + this.onBlurPausedSounds = null; + }, + + /** + * Method used internally by Phaser.Sound.HTML5AudioSound class methods and property setters + * to check if sound manager is locked and then either perform action immediately or queue it + * to be performed once the sound manager gets unlocked. + * + * @method Phaser.Sound.HTML5AudioSoundManager#isLocked + * @protected + * @since 3.0.0 + * + * @param {Phaser.Sound.HTML5AudioSound} sound - Sound object on which to perform queued action. + * @param {string} prop - Name of the method to be called or property to be assigned a value to. + * @param {*} [value] - An optional parameter that either holds an array of arguments to be passed to the method call or value to be set to the property. + * + * @return {boolean} Whether the sound manager is locked. + */ + isLocked: function (sound, prop, value) + { + if (this.locked) + { + this.lockedActionsQueue.push({ + sound: sound, + prop: prop, + value: value + }); + + return true; + } + + return false; + }, + + /** + * @event Phaser.Sound.HTML5AudioSoundManager#MuteEvent + * @param {Phaser.Sound.HTML5AudioSoundManager} soundManager - Reference to the sound manager that emitted event. + * @param {boolean} value - An updated value of Phaser.Sound.HTML5AudioSoundManager#mute property. + */ + + /** + * Sets the muted state of all this Sound Manager. + * + * @method Phaser.Sound.HTML5AudioSoundManager#setMute + * @fires Phaser.Sound.HTML5AudioSoundManager#MuteEvent + * @since 3.3.0 + * + * @param {boolean} value - `true` to mute all sounds, `false` to unmute them. + * + * @return {Phaser.Sound.HTML5AudioSoundManager} This Sound Manager. + */ + setMute: function (value) + { + this.mute = value; + + return this; + }, + + /** + * @name Phaser.Sound.HTML5AudioSoundManager#mute + * @type {boolean} + * @fires Phaser.Sound.HTML5AudioSoundManager#MuteEvent + * @since 3.0.0 + */ + mute: { + + get: function () + { + return this._mute; + }, + + set: function (value) + { + this._mute = value; + + this.forEachActiveSound(function (sound) + { + sound.setMute(); + }); + + this.emit('mute', this, value); + } + + }, + + /** + * @event Phaser.Sound.HTML5AudioSoundManager#VolumeEvent + * @param {Phaser.Sound.HTML5AudioSoundManager} soundManager - Reference to the sound manager that emitted event. + * @param {number} value - An updated value of Phaser.Sound.HTML5AudioSoundManager#volume property. + */ + + /** + * Sets the volume of this Sound Manager. + * + * @method Phaser.Sound.HTML5AudioSoundManager#setVolume + * @fires Phaser.Sound.HTML5AudioSoundManager#VolumeEvent + * @since 3.3.0 + * + * @param {number} value - The global volume of this Sound Manager. + * + * @return {Phaser.Sound.HTML5AudioSoundManager} This Sound Manager. + */ + setVolume: function (value) + { + this.volume = value; + + return this; + }, + + /** + * @name Phaser.Sound.HTML5AudioSoundManager#volume + * @type {number} + * @fires Phaser.Sound.HTML5AudioSoundManager#VolumeEvent + * @since 3.0.0 + */ + volume: { + + get: function () + { + return this._volume; + }, + + set: function (value) + { + this._volume = value; + + this.forEachActiveSound(function (sound) + { + sound.setVolume(); + }); + + this.emit('volume', this, value); + } + + } + +}); + +module.exports = HTML5AudioSoundManager; /***/ }), @@ -58482,9 +62190,42 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Phaser.Math.Easing.Linear +var HTML5AudioSoundManager = __webpack_require__(282); +var NoAudioSoundManager = __webpack_require__(280); +var WebAudioSoundManager = __webpack_require__(278); -module.exports = __webpack_require__(597); +/** + * Creates a Web Audio, HTML5 Audio or No Audio Sound Manager based on config and device settings. + * + * @function Phaser.Sound.SoundManagerCreator + * @author Pavle Goloskokovic (http://prunegames.com) + * @since 3.0.0 + * + * @param {Phaser.Game} game - Reference to the current game instance. + */ +var SoundManagerCreator = { + + create: function (game) + { + var audioConfig = game.config.audio; + var deviceAudio = game.device.audio; + + if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) + { + return new NoAudioSoundManager(game); + } + + if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio)) + { + return new WebAudioSoundManager(game); + } + + return new HTML5AudioSoundManager(game); + } + +}; + +module.exports = SoundManagerCreator; /***/ }), @@ -58497,20 +62238,114 @@ module.exports = __webpack_require__(597); * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Phaser.Math.Easing.Quadratic +var CONST = __webpack_require__(75); +var GetValue = __webpack_require__(5); +var InjectionMap = __webpack_require__(795); -module.exports = { +// TODO 22/03/2018 Fix "plugins" type - In: __webpack_require__(598), - Out: __webpack_require__(599), - InOut: __webpack_require__(600) +/** + * @typedef {object} SettingsConfig + * + * @property {string} [key] - [description] + * @property {boolean} [active=false] - [description] + * @property {boolean} [visible=true] - [description] + * @property {(false|LoaderFileObject[])} [files=false] - [description] + * @property {?(InputJSONCameraObject|InputJSONCameraObject[])} [cameras=null] - [description] + * @property {Object.} [map] - [description] + * @property {object} [physics={}] - [description] + * @property {object} [loader={}] - [description] + * @property {(false|*)} [plugins=false] - [description] + */ + +/** + * @typedef {object} SettingsObject + * + * @property {number} status - [description] + * @property {string} key - [description] + * @property {boolean} active - [description] + * @property {boolean} visible - [description] + * @property {boolean} isBooted - [description] + * @property {object} data - [description] + * @property {(false|LoaderFileObject[])} files - [description] + * @property {?(InputJSONCameraObject|InputJSONCameraObject[])} cameras - [description] + * @property {Object.} map - [description] + * @property {object} physics - [description] + * @property {object} loader - [description] + * @property {(false|*)} plugins - [description] + */ + +var Settings = { + + /** + * Takes a Scene configuration object and returns a fully formed Systems object. + * + * @function Phaser.Scenes.Settings.create + * @since 3.0.0 + * + * @param {(string|SettingsConfig)} config - [description] + * + * @return {SettingsObject} [description] + */ + create: function (config) + { + if (typeof config === 'string') + { + config = { key: config }; + } + else if (config === undefined) + { + // Pass the 'hasOwnProperty' checks + config = {}; + } + + return { + + status: CONST.PENDING, + + key: GetValue(config, 'key', ''), + active: GetValue(config, 'active', false), + visible: GetValue(config, 'visible', true), + + isBooted: false, + + // Loader payload array + + data: {}, + + files: GetValue(config, 'files', false), + + // Cameras + + cameras: GetValue(config, 'cameras', null), + + // Scene Property Injection Map + + map: GetValue(config, 'map', InjectionMap), + + // Physics + + physics: GetValue(config, 'physics', {}), + + // Loader + + loader: GetValue(config, 'loader', {}), + + // Plugins + + plugins: GetValue(config, 'plugins', false) + + }; + } }; +module.exports = Settings; + /***/ }), /* 285 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -58518,16 +62353,23 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Phaser.Math.Easing.Quartic - -module.exports = { - - In: __webpack_require__(601), - Out: __webpack_require__(602), - InOut: __webpack_require__(603) - +/** + * [description] + * + * @function Phaser.Utils.String.UppercaseFirst + * @since 3.0.0 + * + * @param {string} str - [description] + * + * @return {string} [description] + */ +var UppercaseFirst = function (str) +{ + return str && str[0].toUpperCase() + str.slice(1); }; +module.exports = UppercaseFirst; + /***/ }), /* 286 */ @@ -58539,15 +62381,50 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Phaser.Math.Easing.Quintic +var Class = __webpack_require__(0); +var Systems = __webpack_require__(142); -module.exports = { +/** + * @classdesc + * [description] + * + * @class Scene + * @memberOf Phaser + * @constructor + * @since 3.0.0 + * + * @param {(string|SettingsConfig)} config - Scene specific configuration settings. + */ +var Scene = new Class({ - In: __webpack_require__(604), - Out: __webpack_require__(605), - InOut: __webpack_require__(606) + initialize: -}; + function Scene (config) + { + /** + * The Scene Systems. You must never overwrite this property, or all hell will break lose. + * + * @name Phaser.Scene#sys + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.sys = new Systems(this, config); + }, + + /** + * Should be overridden by your own Scenes. + * + * @method Phaser.Scene#update + * @override + * @since 3.0.0 + */ + update: function () + { + } + +}); + +module.exports = Scene; /***/ }), @@ -58560,15 +62437,1392 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Phaser.Math.Easing.Sine +var Class = __webpack_require__(0); +var CONST = __webpack_require__(75); +var GetValue = __webpack_require__(5); +var NOOP = __webpack_require__(3); +var Scene = __webpack_require__(286); +var Systems = __webpack_require__(142); -module.exports = { +/** + * @classdesc + * The Scene Manager. + * + * The Scene Manager is a Game level system, responsible for creating, processing and updating all of the + * Scenes in a Game instance. + * + * + * @class SceneManager + * @memberOf Phaser.Scenes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Phaser.Game instance this Scene Manager belongs to. + * @param {object} sceneConfig - Scene specific configuration settings. + */ +var SceneManager = new Class({ - In: __webpack_require__(607), - Out: __webpack_require__(608), - InOut: __webpack_require__(609) + initialize: -}; + function SceneManager (game, sceneConfig) + { + /** + * [description] + * + * @name Phaser.Scenes.SceneManager#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game = game; + + /** + * An object that maps the keys to the scene so we can quickly get a scene from a key without iteration. + * + * @name Phaser.Scenes.SceneManager#keys + * @type {object} + * @since 3.0.0 + */ + this.keys = {}; + + /** + * The array in which all of the scenes are kept. + * + * @name Phaser.Scenes.SceneManager#scenes + * @type {array} + * @since 3.0.0 + */ + this.scenes = []; + + /** + * Scenes pending to be added are stored in here until the manager has time to add it. + * + * @name Phaser.Scenes.SceneManager#_pending + * @type {array} + * @private + * @since 3.0.0 + */ + this._pending = []; + + /** + * An array of scenes waiting to be started once the game has booted. + * + * @name Phaser.Scenes.SceneManager#_start + * @type {array} + * @private + * @since 3.0.0 + */ + this._start = []; + + /** + * An operations queue, because we don't manipulate the scenes array during processing. + * + * @name Phaser.Scenes.SceneManager#_queue + * @type {array} + * @private + * @since 3.0.0 + */ + this._queue = []; + + /** + * The number of Scenes to process. + * + * @name Phaser.Scenes.SceneManager#_processing + * @type {integer} + * @private + * @since 3.0.0 + */ + this._processing = 0; + + if (sceneConfig) + { + if (!Array.isArray(sceneConfig)) + { + sceneConfig = [ sceneConfig ]; + } + + for (var i = 0; i < sceneConfig.length; i++) + { + // The i === 0 part just autostarts the first Scene given (unless it says otherwise in its config) + this._pending.push({ + key: 'default', + scene: sceneConfig[i], + autoStart: (i === 0), + data: {} + }); + } + + // Only need to wait for the boot event if we've scenes to actually boot + game.events.once('ready', this.bootQueue, this); + } + }, + + /** + * Internal first-time Scene boot handler. + * + * @method Phaser.Scenes.SceneManager#bootQueue + * @private + * @since 3.2.0 + */ + bootQueue: function () + { + var i; + var entry; + var key; + var sceneConfig; + + for (i = 0; i < this._pending.length; i++) + { + entry = this._pending[i]; + + key = entry.key; + sceneConfig = entry.scene; + + var newScene; + + if (sceneConfig instanceof Scene) + { + newScene = this.createSceneFromInstance(key, sceneConfig); + } + else if (typeof sceneConfig === 'object') + { + newScene = this.createSceneFromObject(key, sceneConfig); + } + else if (typeof sceneConfig === 'function') + { + newScene = this.createSceneFromFunction(key, sceneConfig); + } + + // Replace key in case the scene changed it + key = newScene.sys.settings.key; + + this.keys[key] = newScene; + + this.scenes.push(newScene); + + if (entry.autoStart || newScene.sys.settings.active) + { + this._start.push(key); + } + } + + // Clear the pending lists + this._pending.length = 0; + + // _start might have been populated by the above + for (i = 0; i < this._start.length; i++) + { + entry = this._start[i]; + + this.start(entry); + } + + this._start.length = 0; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#processQueue + * @since 3.0.0 + */ + processQueue: function () + { + var pendingLength = this._pending.length; + var queueLength = this._queue.length; + + if (pendingLength === 0 && queueLength === 0) + { + return; + } + + var i; + var entry; + + if (pendingLength) + { + for (i = 0; i < pendingLength; i++) + { + entry = this._pending[i]; + + this.add(entry.key, entry.scene, entry.autoStart); + } + + // _start might have been populated by this.add + for (i = 0; i < this._start.length; i++) + { + entry = this._start[i]; + + this.start(entry); + } + + // Clear the pending lists + this._start.length = 0; + this._pending.length = 0; + + return; + } + + for (i = 0; i < this._queue.length; i++) + { + entry = this._queue[i]; + + this[entry.op](entry.keyA, entry.keyB); + } + + this._queue.length = 0; + }, + + /** + * Adds a new Scene into the SceneManager. + * You must give each Scene a unique key by which you'll identify it. + * + * The `sceneConfig` can be: + * + * * A `Phaser.Scene` object, or an object that extends it. + * * A plain JavaScript object + * * A JavaScript ES6 Class that extends `Phaser.Scene` + * * A JavaScript ES5 prototype based Class + * * A JavaScript function + * + * If a function is given then a new Scene will be created by calling it. + * + * @method Phaser.Scenes.SceneManager#add + * @since 3.0.0 + * + * @param {string} key - A unique key used to reference the Scene, i.e. `MainMenu` or `Level1`. + * @param {(Phaser.Scene|SettingsConfig|function)} sceneConfig - [description] + * @param {boolean} [autoStart=false] - If `true` the Scene will be started immediately after being added. + * + * @return {?Phaser.Scene} [description] + */ + add: function (key, sceneConfig, autoStart) + { + if (autoStart === undefined) { autoStart = false; } + + // if not booted, then put scene into a holding pattern + if (this._processing === 1 || !this.game.isBooted) + { + this._pending.push({ + key: key, + scene: sceneConfig, + autoStart: autoStart, + data: {} + }); + + return null; + } + + key = this.getKey(key, sceneConfig); + + var newScene; + + if (sceneConfig instanceof Scene) + { + newScene = this.createSceneFromInstance(key, sceneConfig); + } + else if (typeof sceneConfig === 'object') + { + sceneConfig.key = key; + + newScene = this.createSceneFromObject(key, sceneConfig); + } + else if (typeof sceneConfig === 'function') + { + newScene = this.createSceneFromFunction(key, sceneConfig); + } + + // Replace key in case the scene changed it + key = newScene.sys.settings.key; + + this.keys[key] = newScene; + + this.scenes.push(newScene); + + if (autoStart || newScene.sys.settings.active) + { + if (this.game.isBooted) + { + this.start(key); + } + else + { + this._start.push(key); + } + } + + return newScene; + }, + + /** + * Removes a Scene from the SceneManager. + * + * The Scene is removed from the local scenes array, it's key is cleared from the keys + * cache and Scene.Systems.destroy is then called on it. + * + * If the SceneManager is processing the Scenes when this method is called it wil + * queue the operation for the next update sequence. + * + * @method Phaser.Scenes.SceneManager#remove + * @since 3.2.0 + * + * @param {(string|Phaser.Scene)} scene - The Scene to be removed. + * + * @return {Phaser.Scenes.SceneManager} This SceneManager. + */ + remove: function (key) + { + if (this._processing) + { + this._queue.push({ op: 'remove', keyA: key, keyB: null }); + } + else + { + var sceneToRemove = this.getScene(key); + + if (!sceneToRemove) + { + return this; + } + + var index = this.scenes.indexOf(sceneToRemove); + var sceneKey = sceneToRemove.sys.settings.key; + + if (index > -1) + { + delete this.keys[sceneKey]; + this.scenes.splice(index, 1); + + if (this._start.indexOf(sceneKey) > -1) + { + index = this._start.indexOf(sceneKey); + this._start.splice(index, 1); + } + + sceneToRemove.sys.destroy(); + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#bootScene + * @private + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ + bootScene: function (scene) + { + if (scene.init) + { + scene.init.call(scene, scene.sys.settings.data); + } + + var loader; + + if (scene.sys.load) + { + loader = scene.sys.load; + + loader.reset(); + } + + if (loader && scene.preload) + { + scene.preload.call(scene); + + // Is the loader empty? + if (loader.list.size === 0) + { + this.create(scene); + } + else + { + scene.sys.settings.status = CONST.LOADING; + + // Start the loader going as we have something in the queue + loader.once('complete', this.loadComplete, this); + + loader.start(); + } + } + else + { + // No preload? Then there was nothing to load either + this.create(scene); + } + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#loadComplete + * @private + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - [description] + */ + loadComplete: function (loader) + { + var scene = loader.scene; + + this.create(scene); + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#payloadComplete + * @private + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - [description] + */ + payloadComplete: function (loader) + { + this.bootScene(loader.scene); + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#update + * @since 3.0.0 + * + * @param {number} time - [description] + * @param {number} delta - [description] + */ + update: function (time, delta) + { + this.processQueue(); + + this._processing = 1; + + // Loop through the active scenes in reverse order + for (var i = this.scenes.length - 1; i >= 0; i--) + { + var sys = this.scenes[i].sys; + + if (sys.settings.status === CONST.RUNNING) + { + sys.step(time, delta); + } + } + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#resize + * @since 3.2.0 + * + * @param {number} width - The new width of the game. + * @param {number} height - The new height of the game. + */ + resize: function (width, height) + { + // Loop through the scenes in forward order + for (var i = 0; i < this.scenes.length; i++) + { + var sys = this.scenes[i].sys; + + sys.resize(width, height); + } + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#render + * @since 3.0.0 + * + * @param {*} renderer - [description] + */ + render: function (renderer) + { + // Loop through the scenes in forward order + for (var i = 0; i < this.scenes.length; i++) + { + var sys = this.scenes[i].sys; + + if (sys.settings.visible && sys.settings.status >= CONST.LOADING && sys.settings.status < CONST.SLEEPING) + { + sys.render(renderer); + } + } + + this._processing = 0; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#create + * @private + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ + create: function (scene) + { + if (scene.create) + { + scene.sys.settings.status = CONST.CREATING; + + scene.create.call(scene, scene.sys.settings.data); + } + + scene.sys.settings.status = CONST.RUNNING; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#createSceneFromFunction + * @private + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {function} scene - [description] + * + * @return {Phaser.Scene} [description] + */ + createSceneFromFunction: function (key, scene) + { + var newScene = new scene(); + + if (newScene instanceof Scene) + { + var configKey = newScene.sys.settings.key; + + if (configKey !== '') + { + key = configKey; + } + + if (this.keys.hasOwnProperty(key)) + { + throw new Error('Cannot add a Scene with duplicate key: ' + key); + } + + return this.createSceneFromInstance(key, newScene); + } + else + { + newScene.sys = new Systems(newScene); + + newScene.sys.settings.key = key; + + newScene.sys.init(this.game); + + if (!newScene.update) + { + newScene.update = NOOP; + } + + return newScene; + } + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#createSceneFromInstance + * @private + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {Phaser.Scene} newScene - [description] + * + * @return {Phaser.Scene} [description] + */ + createSceneFromInstance: function (key, newScene) + { + var configKey = newScene.sys.settings.key; + + if (configKey !== '') + { + key = configKey; + } + else + { + newScene.sys.settings.key = key; + } + + newScene.sys.init(this.game); + + return newScene; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#createSceneFromObject + * @private + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {(string|SettingsConfig)} sceneConfig - [description] + * + * @return {Phaser.Scene} [description] + */ + createSceneFromObject: function (key, sceneConfig) + { + var newScene = new Scene(sceneConfig); + + var configKey = newScene.sys.settings.key; + + if (configKey !== '') + { + key = configKey; + } + else + { + newScene.sys.settings.key = key; + } + + newScene.sys.init(this.game); + + // Extract callbacks + + var defaults = [ 'init', 'preload', 'create', 'update', 'render' ]; + + for (var i = 0; i < defaults.length; i++) + { + var sceneCallback = GetValue(sceneConfig, defaults[i], null); + + // Must always have an update function, no matter what (the rest are optional) + if (defaults[i] === 'update' && !sceneCallback) + { + sceneCallback = NOOP; + } + + if (sceneCallback) + { + newScene[defaults[i]] = sceneCallback; + } + } + + // Now let's move across any other functions or properties that may exist in the extend object: + + /* + scene: { + preload: preload, + create: create, + extend: { + hello: 1, + test: 'atari', + addImage: addImage + } + } + */ + + if (sceneConfig.hasOwnProperty('extend')) + { + for (var propertyKey in sceneConfig.extend) + { + newScene[propertyKey] = sceneConfig.extend[propertyKey]; + } + } + + return newScene; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#getKey + * @private + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {(Phaser.Scene|SettingsConfig|function)} sceneConfig - [description] + * + * @return {string} [description] + */ + getKey: function (key, sceneConfig) + { + if (!key) { key = 'default'; } + + if (typeof sceneConfig === 'function') + { + return key; + } + else if (sceneConfig instanceof Scene) + { + key = sceneConfig.sys.settings.key; + } + else if (typeof sceneConfig === 'object' && sceneConfig.hasOwnProperty('key')) + { + key = sceneConfig.key; + } + + // By this point it's either 'default' or extracted from the Scene + + if (this.keys.hasOwnProperty(key)) + { + throw new Error('Cannot add a Scene with duplicate key: ' + key); + } + else + { + return key; + } + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#getScene + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {?Phaser.Scene} [description] + */ + getScene: function (key) + { + if (typeof key === 'string') + { + if (this.keys[key]) + { + return this.keys[key]; + } + } + else + { + for (var i = 0; i < this.scenes.length; i++) + { + if (key === this.scenes[i]) + { + return key; + } + } + } + + return null; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#isActive + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {boolean} [description] + */ + isActive: function (key) + { + var scene = this.getScene(key); + + if (scene) + { + return scene.sys.isActive(); + } + + return null; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#isVisible + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {boolean} [description] + */ + isVisible: function (key) + { + var scene = this.getScene(key); + + if (scene) + { + return scene.sys.isVisible(); + } + + return null; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#isSleeping + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {boolean} [description] + */ + isSleeping: function (key) + { + var scene = this.getScene(key); + + if (scene) + { + return scene.sys.isSleeping(); + } + + return null; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#pause + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + pause: function (key) + { + var scene = this.getScene(key); + + if (scene) + { + scene.sys.pause(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#resume + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + resume: function (key) + { + var scene = this.getScene(key); + + if (scene) + { + scene.sys.resume(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#sleep + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + sleep: function (key) + { + var scene = this.getScene(key); + + if (scene) + { + scene.sys.sleep(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#wake + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + wake: function (key) + { + var scene = this.getScene(key); + + if (scene) + { + scene.sys.wake(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#start + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {object} [data] - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + start: function (key, data) + { + if (data === undefined) { data = {}; } + + // if not booted, then put scene into a holding pattern + if (!this.game.isBooted) + { + for (var i = 0; i < this._pending.length; i++) + { + var entry = this._pending[i]; + + if (entry.key === key) + { + entry.autoStart = true; + entry.data = data; + } + } + + return this; + } + + var scene = this.getScene(key); + + if (scene) + { + scene.sys.start(data); + + var loader; + + if (scene.sys.load) + { + loader = scene.sys.load; + } + + // Files payload? + if (loader && Array.isArray(scene.sys.settings.files)) + { + loader.reset(); + + if (loader.loadArray(scene.sys.settings.files)) + { + scene.sys.settings.status = CONST.LOADING; + + loader.once('complete', this.payloadComplete, this); + + loader.start(); + + return this; + } + } + + this.bootScene(scene); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#stop + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + stop: function (key) + { + var scene = this.getScene(key); + + if (scene) + { + scene.sys.shutdown(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#switch + * @since 3.0.0 + * + * @param {string} from - [description] + * @param {string} to - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + switch: function (from, to) + { + var sceneA = this.getScene(from); + var sceneB = this.getScene(to); + + if (sceneA && sceneB && sceneA !== sceneB) + { + this.sleep(from); + + if (this.isSleeping(to)) + { + this.wake(to); + } + else + { + this.start(to); + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#getAt + * @since 3.0.0 + * + * @param {integer} index - [description] + * + * @return {(Phaser.Scene|undefined)} [description] + */ + getAt: function (index) + { + return this.scenes[index]; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#getIndex + * @since 3.0.0 + * + * @param {(string|Phaser.Scene)} key - [description] + * + * @return {integer} [description] + */ + getIndex: function (key) + { + var scene = this.getScene(key); + + return this.scenes.indexOf(scene); + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#bringToTop + * @since 3.0.0 + * + * @param {(string|Phaser.Scene)} key - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + bringToTop: function (key) + { + if (this._processing) + { + this._queue.push({ op: 'bringToTop', keyA: key, keyB: null }); + } + else + { + var index = this.getIndex(key); + + if (index !== -1 && index < this.scenes.length) + { + var scene = this.getScene(key); + + this.scenes.splice(index, 1); + this.scenes.push(scene); + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#sendToBack + * @since 3.0.0 + * + * @param {(string|Phaser.Scene)} key - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + sendToBack: function (key) + { + if (this._processing) + { + this._queue.push({ op: 'sendToBack', keyA: key, keyB: null }); + } + else + { + var index = this.getIndex(key); + + if (index !== -1 && index > 0) + { + var scene = this.getScene(key); + + this.scenes.splice(index, 1); + this.scenes.unshift(scene); + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#moveDown + * @since 3.0.0 + * + * @param {(string|Phaser.Scene)} key - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + moveDown: function (key) + { + if (this._processing) + { + this._queue.push({ op: 'moveDown', keyA: key, keyB: null }); + } + else + { + var indexA = this.getIndex(key); + + if (indexA > 0) + { + var indexB = indexA - 1; + var sceneA = this.getScene(key); + var sceneB = this.getAt(indexB); + + this.scenes[indexA] = sceneB; + this.scenes[indexB] = sceneA; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#moveUp + * @since 3.0.0 + * + * @param {(string|Phaser.Scene)} key - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + moveUp: function (key) + { + if (this._processing) + { + this._queue.push({ op: 'moveUp', keyA: key, keyB: null }); + } + else + { + var indexA = this.getIndex(key); + + if (indexA < this.scenes.length - 1) + { + var indexB = indexA + 1; + var sceneA = this.getScene(key); + var sceneB = this.getAt(indexB); + + this.scenes[indexA] = sceneB; + this.scenes[indexB] = sceneA; + } + } + + return this; + }, + + /** + * Moves a Scene so it is immediately above another Scene in the Scenes list. + * This means it will render over the top of the other Scene. + * + * @method Phaser.Scenes.SceneManager#moveAbove + * @since 3.2.0 + * + * @param {(string|Phaser.Scene)} keyA - The Scene that Scene B will be moved above. + * @param {(string|Phaser.Scene)} keyB - The Scene to be moved. + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + moveAbove: function (keyA, keyB) + { + if (keyA === keyB) + { + return this; + } + + if (this._processing) + { + this._queue.push({ op: 'moveAbove', keyA: keyA, keyB: keyB }); + } + else + { + var indexA = this.getIndex(keyA); + var indexB = this.getIndex(keyB); + + if (indexA > indexB && indexA !== -1 && indexB !== -1) + { + var tempScene = this.getAt(indexB); + + // Remove + this.scenes.splice(indexB, 1); + + // Add in new location + this.scenes.splice(indexA, 0, tempScene); + } + } + + return this; + }, + + /** + * Moves a Scene so it is immediately below another Scene in the Scenes list. + * This means it will render behind the other Scene. + * + * @method Phaser.Scenes.SceneManager#moveBelow + * @since 3.2.0 + * + * @param {(string|Phaser.Scene)} keyA - The Scene that Scene B will be moved above. + * @param {(string|Phaser.Scene)} keyB - The Scene to be moved. + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + moveBelow: function (keyA, keyB) + { + if (keyA === keyB) + { + return this; + } + + if (this._processing) + { + this._queue.push({ op: 'moveBelow', keyA: keyA, keyB: keyB }); + } + else + { + var indexA = this.getIndex(keyA); + var indexB = this.getIndex(keyB); + + if (indexA < indexB && indexA !== -1 && indexB !== -1) + { + var tempScene = this.getAt(indexB); + + // Remove + this.scenes.splice(indexB, 1); + + // Add in new location + this.scenes.splice(indexA, 0, tempScene); + } + } + + return this; + }, + + queueOp: function (op, keyA, keyB) + { + this._queue.push({ op: op, keyA: keyA, keyB: keyB }); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#swapPosition + * @since 3.0.0 + * + * @param {(string|Phaser.Scene)} keyA - [description] + * @param {(string|Phaser.Scene)} keyB - [description] + * + * @return {Phaser.Scenes.SceneManager} [description] + */ + swapPosition: function (keyA, keyB) + { + if (keyA === keyB) + { + return this; + } + + if (this._processing) + { + this._queue.push({ op: 'swapPosition', keyA: keyA, keyB: keyB }); + } + else + { + var indexA = this.getIndex(keyA); + var indexB = this.getIndex(keyB); + + if (indexA !== indexB && indexA !== -1 && indexB !== -1) + { + var tempScene = this.getAt(indexA); + + this.scenes[indexA] = this.scenes[indexB]; + this.scenes[indexB] = tempScene; + } + } + + return this; + }, + + dump: function () + { + var out = []; + var map = [ 'pending', 'init', 'start', 'loading', 'creating', 'running', 'paused', 'sleeping', 'shutdown', 'destroyed' ]; + + for (var i = 0; i < this.scenes.length; i++) + { + var sys = this.scenes[i].sys; + + var key = (sys.settings.visible && (sys.settings.status === CONST.RUNNING || sys.settings.status === CONST.PAUSED)) ? '[*] ' : '[-] '; + key += sys.settings.key + ' (' + map[sys.settings.status] + ')'; + + out.push(key); + } + + console.log(out.join('\n')); + }, + + /** + * [description] + * + * @method Phaser.Scenes.SceneManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + for (var i = this.scenes.length - 1; i >= 0; i--) + { + var sys = this.scenes[i].sys; + + sys.destroy(); + } + + this.scenes = []; + + this._pending = []; + this._start = []; + this._queue = []; + + this.game = null; + } + +}); + +module.exports = SceneManager; /***/ }), @@ -58581,14 +63835,65 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Phaser.Math.Easing.Stepped +var Vector2 = __webpack_require__(6); -module.exports = __webpack_require__(610); +/** + * Takes the `x` and `y` coordinates and transforms them into the same space as + * defined by the position, rotation and scale values. + * + * @function Phaser.Math.TransformXY + * @since 3.0.0 + * + * @param {number} x - The x coordinate to be transformed. + * @param {number} y - The y coordinate to be transformed. + * @param {number} positionX - Horizontal position of the transform point. + * @param {number} positionY - Vertical position of the transform point. + * @param {number} rotation - Rotation of the transform point, in radians. + * @param {number} scaleX - Horizontal scale of the transform point. + * @param {number} scaleY - Vertical scale of the transform point. + * @param {(Phaser.Math.Vector2|Phaser.Geom.Point|object)} [output] - [description] + * + * @return {(Phaser.Math.Vector2|Phaser.Geom.Point|object)} The translated point. + */ +var TransformXY = function (x, y, positionX, positionY, rotation, scaleX, scaleY, output) +{ + if (output === undefined) { output = new Vector2(); } + + // ITRS + + var sr = Math.sin(-rotation); + var cr = Math.cos(-rotation); + + var a = cr * scaleX; + var b = -sr * scaleX; + var c = sr * scaleY; + var d = cr * scaleY; + + // Invert + + var n = a * d - b * c; + + var m0 = d / n; + var m1 = -b / n; + var m2 = -c / n; + var m3 = a / n; + var m4 = (c * positionY - d * positionX) / n; + var m5 = -(a * positionY - b * positionX) / n; + + // Transform + + output.x = x * m0 + y * m2 + m4; + output.y = x * m1 + y * m3 + m5; + + return output; +}; + +module.exports = TransformXY; /***/ }), /* 289 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -58596,31 +63901,197 @@ module.exports = __webpack_require__(610); * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); + +// https://developer.mozilla.org/en-US/docs/Web/API/Touch_events +// https://patrickhlauke.github.io/touch/tests/results/ +// https://www.html5rocks.com/en/mobile/touch/ + /** + * @callback TouchHandler + * + * @param {TouchEvent} event - [description] + */ + +/** + * @classdesc * [description] * - * @function Phaser.Utils.Object.HasAny + * @class TouchManager + * @memberOf Phaser.Input.Touch + * @constructor * @since 3.0.0 * - * @param {object} source - [description] - * @param {string[]} keys - [description] - * - * @return {boolean} [description] + * @param {Phaser.Input.InputManager} inputManager - [description] */ -var HasAny = function (source, keys) -{ - for (var i = 0; i < keys.length; i++) +var TouchManager = new Class({ + + initialize: + + function TouchManager (inputManager) { - if (source.hasOwnProperty(keys[i])) + /** + * [description] + * + * @name Phaser.Input.Touch.TouchManager#manager + * @type {Phaser.Input.InputManager} + * @since 3.0.0 + */ + this.manager = inputManager; + + /** + * If true the DOM events will have event.preventDefault applied to them, if false they will propagate fully. + * + * @name Phaser.Input.Touch.TouchManager#capture + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.capture = true; + + /** + * [description] + * + * @name Phaser.Input.Touch.TouchManager#enabled + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.enabled = false; + + /** + * [description] + * + * @name Phaser.Input.Touch.TouchManager#target + * @type {null} + * @since 3.0.0 + */ + this.target; + + /** + * [description] + * + * @name Phaser.Input.Touch.TouchManager#handler + * @type {TouchHandler} + * @since 3.0.0 + */ + this.handler; + }, + + /** + * [description] + * + * @method Phaser.Input.Touch.TouchManager#boot + * @since 3.0.0 + */ + boot: function () + { + var config = this.manager.config; + + this.enabled = config.inputTouch; + this.target = config.inputTouchEventTarget; + this.capture = config.inputTouchCapture; + + if (!this.target) { - return true; + this.target = this.manager.game.canvas; } + + if (this.enabled) + { + this.startListeners(); + } + }, + + /** + * [description] + * + * @method Phaser.Input.Touch.TouchManager#startListeners + * @since 3.0.0 + */ + startListeners: function () + { + var queue = this.manager.queue; + var target = this.target; + + var passive = { passive: true }; + var nonPassive = { passive: false }; + + var handler; + + if (this.capture) + { + handler = function (event) + { + if (event.defaultPrevented) + { + // Do nothing if event already handled + return; + } + + // console.log('touch', event); + + queue.push(event); + + event.preventDefault(); + }; + + target.addEventListener('touchstart', handler, nonPassive); + target.addEventListener('touchmove', handler, nonPassive); + target.addEventListener('touchend', handler, nonPassive); + } + else + { + handler = function (event) + { + if (event.defaultPrevented) + { + // Do nothing if event already handled + return; + } + + queue.push(event); + }; + + target.addEventListener('touchstart', handler, passive); + target.addEventListener('touchmove', handler, passive); + target.addEventListener('touchend', handler, passive); + } + + this.handler = handler; + }, + + /** + * [description] + * + * @method Phaser.Input.Touch.TouchManager#stopListeners + * @since 3.0.0 + */ + stopListeners: function () + { + var target = this.target; + + target.removeEventListener('touchstart', this.handler); + target.removeEventListener('touchmove', this.handler); + target.removeEventListener('touchend', this.handler); + }, + + /** + * [description] + * + * @method Phaser.Input.Touch.TouchManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.stopListeners(); + + this.manager = null; } - return false; -}; +}); -module.exports = HasAny; +module.exports = TouchManager; /***/ }), @@ -58634,420 +64105,637 @@ module.exports = HasAny; */ var Class = __webpack_require__(0); -var DegToRad = __webpack_require__(35); -var GetBoolean = __webpack_require__(73); -var GetValue = __webpack_require__(4); -var Sprite = __webpack_require__(37); -var TWEEN_CONST = __webpack_require__(87); var Vector2 = __webpack_require__(6); +// DOM event button value: +// A number representing a given button: +// 0: Main button pressed, usually the left button or the un-initialized state +// 1: Auxiliary button pressed, usually the wheel button or the middle button (if present) +// 2: Secondary button pressed, usually the right button +// 3: Fourth button, typically the Browser Back button +// 4: Fifth button, typically the Browser Forward button +// For a mouse configured for left-handed use, the button actions are reversed. In this case, the values are read from right to left. + /** * @classdesc - * A PathFollower Game Object. + * [description] * - * A PathFollower is a Sprite Game Object with some extra helpers to allow it to follow a Path automatically. - * - * Anything you can do with a standard Sprite can be done with this PathFollower, such as animate it, tint it, - * scale it and so on. - * - * PathFollowers are bound to a single Path at any one time and can traverse the length of the Path, from start - * to finish, forwards or backwards, or from any given point on the Path to its end. They can optionally rotate - * to face the direction of the path, be offset from the path coordinates or rotate independently of the Path. - * - * @class PathFollower - * @extends Phaser.GameObjects.Sprite - * @memberOf Phaser.GameObjects + * @class Pointer + * @memberOf Phaser.Input * @constructor * @since 3.0.0 * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.Curves.Path} path - The Path this PathFollower is following. It can only follow one Path at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {Phaser.Input.InputManager} manager - [description] + * @param {integer} id - [description] */ -var PathFollower = new Class({ - - Extends: Sprite, +var Pointer = new Class({ initialize: - function PathFollower (scene, path, x, y, texture, frame) + function Pointer (manager, id) { - Sprite.call(this, scene, x, y, texture, frame); - /** - * The Path this PathFollower is following. It can only follow one Path at a time. + * [description] * - * @name Phaser.GameObjects.PathFollower#path - * @type {Phaser.Curves.Path} + * @name Phaser.Input.Pointer#manager + * @type {Phaser.Input.InputManager} * @since 3.0.0 */ - this.path = path; - - /** - * Should the PathFollower automatically rotate to point in the direction of the Path? - * - * @name Phaser.GameObjects.PathFollower#rotateToPath - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.rotateToPath = false; + this.manager = manager; /** * [description] * - * @name Phaser.GameObjects.PathFollower#pathRotationVerticalAdjust - * @type {boolean} - * @default false + * @name Phaser.Input.Pointer#id + * @type {integer} * @since 3.0.0 */ - this.pathRotationVerticalAdjust = false; + this.id = id; /** - * If the PathFollower is rotating to match the Path (@see Phaser.GameObjects.PathFollower#rotateToPath) - * this value is added to the rotation value. This allows you to rotate objects to a path but control - * the angle of the rotation as well. + * [description] * - * @name Phaser.GameObjects.PathFollower#pathRotationOffset + * @name Phaser.Input.Pointer#event + * @type {null} + * @since 3.0.0 + */ + this.event; + + /** + * The camera the Pointer interacted with during its last update. + * A Pointer can only ever interact with one camera at once, which will be the top-most camera + * in the list should multiple cameras be positioned on-top of each other. + * + * @name Phaser.Input.Pointer#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @default null + * @since 3.0.0 + */ + this.camera = null; + + /** + * 0: No button or un-initialized + * 1: Left button + * 2: Right button + * 4: Wheel button or middle button + * 8: 4th button (typically the "Browser Back" button) + * 16: 5th button (typically the "Browser Forward" button) + * + * @name Phaser.Input.Pointer#buttons * @type {number} * @default 0 * @since 3.0.0 */ - this.pathRotationOffset = 0; + this.buttons = 0; /** - * An additional vector to add to the PathFollowers position, allowing you to offset it from the - * Path coordinates. + * [description] * - * @name Phaser.GameObjects.PathFollower#pathOffset + * @name Phaser.Input.Pointer#position * @type {Phaser.Math.Vector2} * @since 3.0.0 */ - this.pathOffset = new Vector2(x, y); + this.position = new Vector2(); + + /** + * X coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. + * + * @name Phaser.Input.Pointer#downX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.downX = 0; + + /** + * Y coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. + * + * @name Phaser.Input.Pointer#downY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.downY = 0; + + /** + * Time when Button 1 (left button), or Touch, was pressed, used for dragging objects. + * + * @name Phaser.Input.Pointer#downTime + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.downTime = 0; + + /** + * X coordinate of the Pointer when Button 1 (left button), or Touch, was released, used for dragging objects. + * + * @name Phaser.Input.Pointer#upX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.upX = 0; + + /** + * Y coordinate of the Pointer when Button 1 (left button), or Touch, was released, used for dragging objects. + * + * @name Phaser.Input.Pointer#upY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.upY = 0; + + /** + * Time when Button 1 (left button), or Touch, was released, used for dragging objects. + * + * @name Phaser.Input.Pointer#upTime + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.upTime = 0; + + /** + * Is the primary button down? (usually button 0, the left mouse button) + * + * @name Phaser.Input.Pointer#primaryDown + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.primaryDown = false; + + + /** + * The Drag State of the Pointer: + * + * 0 = Not dragging anything + * 1 = Being checked if dragging + * 2 = Dragging something + * + * @name Phaser.Input.Pointer#dragState + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.dragState = 0; + + /** + * Is _any_ button on this pointer considered as being down? + * + * @name Phaser.Input.Pointer#isDown + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isDown = false; /** * [description] * - * @name Phaser.GameObjects.PathFollower#pathVector - * @type {Phaser.Math.Vector2} + * @name Phaser.Input.Pointer#dirty + * @type {boolean} + * @default false * @since 3.0.0 */ - this.pathVector = new Vector2(); + this.dirty = false; /** * [description] * - * @name Phaser.GameObjects.PathFollower#pathTween - * @type {null} + * @name Phaser.Input.Pointer#justDown + * @type {boolean} + * @default false * @since 3.0.0 */ - this.pathTween; + this.justDown = false; /** * [description] * - * @name Phaser.GameObjects.PathFollower#pathConfig - * @type {?[type]} - * @default null + * @name Phaser.Input.Pointer#justUp + * @type {boolean} + * @default false * @since 3.0.0 */ - this.pathConfig = null; + this.justUp = false; /** - * Records the direction of the follower so it can change direction. + * [description] * - * @name Phaser.GameObjects.PathFollower#_prevDirection - * @type {integer} - * @private + * @name Phaser.Input.Pointer#justMoved + * @type {boolean} + * @default false * @since 3.0.0 */ - this._prevDirection = TWEEN_CONST.PLAYING_FORWARD; + this.justMoved = false; + + /** + * Did the previous input event come from a Touch input (true) or Mouse? (false) + * + * @name Phaser.Input.Pointer#wasTouch + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.wasTouch = false; + + /** + * If the mouse is locked, the horizontal relative movement of the Pointer in pixels since last frame. + * + * @name Phaser.Input.Pointer#movementX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.movementX = 0; + + /** + * If the mouse is locked, the vertical relative movement of the Pointer in pixels since last frame. + * + * @name Phaser.Input.Pointer#movementY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.movementY = 0; }, /** * [description] * - * @method Phaser.GameObjects.PathFollower#setPath + * @method Phaser.Input.Pointer#positionToCamera * @since 3.0.0 * - * @param {Phaser.Curves.Path} path - The Path this PathFollower is following. It can only follow one Path at a time. - * @param {[type]} config - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @param {(Phaser.Math.Vector2|object)} output - [description] * - * @return {Phaser.GameObjects.PathFollower} This Game Object. + * @return {(Phaser.Math.Vector2|object)} [description] */ - setPath: function (path, config) + positionToCamera: function (camera, output) { - if (config === undefined) { config = this.pathConfig; } - - var tween = this.pathTween; - - if (tween && tween.isPlaying()) - { - tween.stop(); - } - - this.path = path; - - if (config) - { - this.start(config); - } - - return this; + return camera.getWorldPoint(this.x, this.y, output); }, - // rotation offset in degrees /** * [description] * - * @method Phaser.GameObjects.PathFollower#setRotateToPath + * @name Phaser.Input.Pointer#x + * @type {number} * @since 3.0.0 - * - * @param {[type]} value - [description] - * @param {[type]} offset - [description] - * @param {[type]} verticalAdjust - [description] - * - * @return {Phaser.GameObjects.PathFollower} This Game Object. */ - setRotateToPath: function (value, offset, verticalAdjust) - { - if (offset === undefined) { offset = 0; } - if (verticalAdjust === undefined) { verticalAdjust = false; } + x: { - this.rotateToPath = value; + get: function () + { + return this.position.x; + }, - this.pathRotationOffset = offset; - this.pathRotationVerticalAdjust = verticalAdjust; + set: function (value) + { + this.position.x = value; + } - return this; }, /** - * Is this PathFollower actively following a Path or not? - * To be considered as `isFollowing` it must be currently moving on a Path, and not paused. + * [description] * - * @method Phaser.GameObjects.PathFollower#isFollowing + * @name Phaser.Input.Pointer#y + * @type {number} * @since 3.0.0 - * - * @return {boolean} `true` is this PathFollower is actively following a Path, otherwise `false`. */ - isFollowing: function () - { - var tween = this.pathTween; + y: { + + get: function () + { + return this.position.y; + }, + + set: function (value) + { + this.position.y = value; + } - return (tween && tween.isPlaying()); }, /** - * Starts this PathFollower following its given Path. + * [description] * - * @method Phaser.GameObjects.PathFollower#start + * @method Phaser.Input.Pointer#reset * @since 3.0.0 - * - * @param {object} config - [description] - * @param {number} [startAt=0] - [description] - * - * @return {Phaser.GameObjects.PathFollower} This Game Object. */ - start: function (config, startAt) + reset: function () { - if (config === undefined) { config = {}; } - if (startAt === undefined) { startAt = 0; } + // this.buttons = 0; - var tween = this.pathTween; + this.dirty = false; - if (tween && tween.isPlaying()) - { - tween.stop(); - } + this.justDown = false; + this.justUp = false; + this.justMoved = false; - if (typeof config === 'number') - { - config = { duration: config }; - } - - // Override in case they've been specified in the config - config.from = 0; - config.to = 1; - - // Can also read extra values out of the config: - - var positionOnPath = GetBoolean(config, 'positionOnPath', false); - - this.rotateToPath = GetBoolean(config, 'rotateToPath', false); - this.pathRotationOffset = GetValue(config, 'rotationOffset', 0); - this.pathRotationVerticalAdjust = GetBoolean(config, 'verticalAdjust', false); - - this.pathTween = this.scene.sys.tweens.addCounter(config); - - // The starting point of the path, relative to this follower - this.path.getStartPoint(this.pathOffset); - - if (positionOnPath) - { - this.x = this.pathOffset.x; - this.y = this.pathOffset.y; - } - - this.pathOffset.x = this.x - this.pathOffset.x; - this.pathOffset.y = this.y - this.pathOffset.y; - - this._prevDirection = TWEEN_CONST.PLAYING_FORWARD; - - if (this.rotateToPath) - { - // Set the rotation now (in case the tween has a delay on it, etc) - var nextPoint = this.path.getPoint(0.1); - - this.rotation = Math.atan2(nextPoint.y - this.y, nextPoint.x - this.x) + DegToRad(this.pathRotationOffset); - } - - this.pathConfig = config; - - return this; + this.movementX = 0; + this.movementY = 0; }, /** - * Pauses this PathFollower. It will still continue to render, but it will remain motionless at the - * point on the Path at which you paused it. + * [description] * - * @method Phaser.GameObjects.PathFollower#pause + * @method Phaser.Input.Pointer#touchmove * @since 3.0.0 * - * @return {Phaser.GameObjects.PathFollower} This Game Object. + * @param {TouchEvent} event - [description] + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. */ - pause: function () + touchmove: function (event) { - var tween = this.pathTween; + this.event = event; - if (tween && tween.isPlaying()) - { - tween.pause(); - } + this.x = this.manager.transformX(event.changedTouches[0].pageX); + this.y = this.manager.transformY(event.changedTouches[0].pageY); - return this; + this.justMoved = true; + + this.dirty = true; + + this.wasTouch = true; }, /** - * Resumes a previously paused PathFollower. - * If the PathFollower was not paused this has no effect. + * [description] * - * @method Phaser.GameObjects.PathFollower#resume + * @method Phaser.Input.Pointer#move * @since 3.0.0 * - * @return {Phaser.GameObjects.PathFollower} This Game Object. + * @param {MouseEvent} event - [description] + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. */ - resume: function () + move: function (event) { - var tween = this.pathTween; - - if (tween && tween.isPaused()) + if (event.buttons) { - tween.resume(); + this.buttons = event.buttons; } - return this; + this.event = event; + + this.x = this.manager.transformX(event.pageX); + this.y = this.manager.transformY(event.pageY); + + if (this.manager.mouse.locked) + { + // Multiple DOM events may occur within one frame, but only one Phaser event will fire + this.movementX += event.movementX || event.mozMovementX || event.webkitMovementX || 0; + this.movementY += event.movementY || event.mozMovementY || event.webkitMovementY || 0; + } + + this.justMoved = true; + + this.dirty = true; + + this.wasTouch = false; }, /** - * Stops this PathFollower from following the path any longer. - * This will invoke any 'stop' conditions that may exist on the Path, or for the follower. + * [description] * - * @method Phaser.GameObjects.PathFollower#stop + * @method Phaser.Input.Pointer#down * @since 3.0.0 * - * @return {Phaser.GameObjects.PathFollower} This Game Object. + * @param {MouseEvent} event - [description] + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. */ - stop: function () + down: function (event, time) { - var tween = this.pathTween; - - if (tween && tween.isPlaying()) + if (event.buttons) { - tween.stop(); + this.buttons = event.buttons; } - return this; + this.event = event; + + this.x = this.manager.transformX(event.pageX); + this.y = this.manager.transformY(event.pageY); + + // 0: Main button pressed, usually the left button or the un-initialized state + if (event.button === 0) + { + this.primaryDown = true; + this.downX = this.x; + this.downY = this.y; + this.downTime = time; + } + + this.justDown = true; + this.isDown = true; + + this.dirty = true; + + this.wasTouch = false; }, /** - * Internal update handler that advances this PathFollower along the path. - * Called automatically by the Scene step, should not typically be called directly. + * [description] * - * @method Phaser.GameObjects.PathFollower#preUpdate - * @protected + * @method Phaser.Input.Pointer#touchstart * @since 3.0.0 * - * @param {[type]} time - [description] - * @param {[type]} delta - [description] + * @param {TouchEvent} event - [description] + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. */ - preUpdate: function (time, delta) + touchstart: function (event, time) { - this.anims.update(time, delta); + this.buttons = 1; - var tween = this.pathTween; + this.event = event; - if (tween) + this.x = this.manager.transformX(event.changedTouches[0].pageX); + this.y = this.manager.transformY(event.changedTouches[0].pageY); + + this.primaryDown = true; + this.downX = this.x; + this.downY = this.y; + this.downTime = time; + + this.justDown = true; + this.isDown = true; + + this.dirty = true; + + this.wasTouch = true; + }, + + /** + * [description] + * + * @method Phaser.Input.Pointer#up + * @since 3.0.0 + * + * @param {MouseEvent} event - [description] + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + */ + up: function (event, time) + { + if (event.buttons) { - var tweenData = tween.data[0]; - - if (tweenData.state !== TWEEN_CONST.PLAYING_FORWARD && tweenData.state !== TWEEN_CONST.PLAYING_BACKWARD) - { - // If delayed, etc then bail out - return; - } - - var pathVector = this.pathVector; - - this.path.getPoint(tween.getValue(), pathVector); - - pathVector.add(this.pathOffset); - - var oldX = this.x; - var oldY = this.y; - - this.setPosition(pathVector.x, pathVector.y); - - var speedX = this.x - oldX; - var speedY = this.y - oldY; - - if (speedX === 0 && speedY === 0) - { - // Bail out early - return; - } - - if (tweenData.state !== this._prevDirection) - { - // We've changed direction, so don't do a rotate this frame - this._prevDirection = tweenData.state; - - return; - } - - if (this.rotateToPath) - { - this.rotation = Math.atan2(speedY, speedX) + DegToRad(this.pathRotationOffset); - - if (this.pathRotationVerticalAdjust) - { - this.flipY = (this.rotation !== 0 && tweenData.state === TWEEN_CONST.PLAYING_BACKWARD); - } - } + this.buttons = event.buttons; } + + this.event = event; + + this.x = this.manager.transformX(event.pageX); + this.y = this.manager.transformY(event.pageY); + + // 0: Main button pressed, usually the left button or the un-initialized state + if (event.button === 0) + { + this.primaryDown = false; + this.upX = this.x; + this.upY = this.y; + this.upTime = time; + } + + this.justUp = true; + this.isDown = false; + + this.dirty = true; + + this.wasTouch = false; + }, + + /** + * [description] + * + * @method Phaser.Input.Pointer#touchend + * @since 3.0.0 + * + * @param {TouchEvent} event - [description] + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + */ + touchend: function (event, time) + { + this.buttons = 0; + + this.event = event; + + this.x = this.manager.transformX(event.changedTouches[0].pageX); + this.y = this.manager.transformY(event.changedTouches[0].pageY); + + this.primaryDown = false; + this.upX = this.x; + this.upY = this.y; + this.upTime = time; + + this.justUp = true; + this.isDown = false; + + this.dirty = true; + + this.wasTouch = true; + }, + + /** + * [description] + * + * @method Phaser.Input.Pointer#noButtonDown + * @since 3.0.0 + * + * @return {boolean} [description] + */ + noButtonDown: function () + { + return (this.buttons === 0); + }, + + /** + * [description] + * + * @method Phaser.Input.Pointer#leftButtonDown + * @since 3.0.0 + * + * @return {boolean} [description] + */ + leftButtonDown: function () + { + return (this.buttons & 1); + }, + + /** + * [description] + * + * @method Phaser.Input.Pointer#rightButtonDown + * @since 3.0.0 + * + * @return {boolean} [description] + */ + rightButtonDown: function () + { + return (this.buttons & 2); + }, + + /** + * [description] + * + * @method Phaser.Input.Pointer#middleButtonDown + * @since 3.0.0 + * + * @return {boolean} [description] + */ + middleButtonDown: function () + { + return (this.buttons & 4); + }, + + /** + * [description] + * + * @method Phaser.Input.Pointer#backButtonDown + * @since 3.0.0 + * + * @return {boolean} [description] + */ + backButtonDown: function () + { + return (this.buttons & 8); + }, + + /** + * [description] + * + * @method Phaser.Input.Pointer#forwardButtonDown + * @since 3.0.0 + * + * @return {boolean} [description] + */ + forwardButtonDown: function () + { + return (this.buttons & 16); + }, + + /** + * [description] + * + * @method Phaser.Input.Pointer#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.camera = null; + this.manager = null; + this.position = null; } }); -module.exports = PathFollower; +module.exports = Pointer; /***/ }), /* 291 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -59055,25 +64743,300 @@ module.exports = PathFollower; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var Features = __webpack_require__(146); + +// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent +// https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md + /** - * Returns the nearest power of 2 to the given `value`. + * @classdesc + * [description] * - * @function Phaser.Math.Pow2.GetPowerOfTwo + * @class MouseManager + * @memberOf Phaser.Input.Mouse + * @constructor * @since 3.0.0 * - * @param {number} value - [description] - * - * @return {integer} [description] + * @param {Phaser.Input.InputManager} inputManager - [description] */ -var GetPowerOfTwo = function (value) -{ - // Math.log(2) - var index = Math.log(value) / 0.6931471805599453; +var MouseManager = new Class({ - return (1 << Math.ceil(index)); -}; + initialize: -module.exports = GetPowerOfTwo; + function MouseManager (inputManager) + { + /** + * [description] + * + * @name Phaser.Input.Mouse.MouseManager#manager + * @type {Phaser.Input.InputManager} + * @since 3.0.0 + */ + this.manager = inputManager; + + /** + * If true the DOM mouse events will have event.preventDefault applied to them, if false they will propagate fully. + * + * @name Phaser.Input.Mouse.MouseManager#capture + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.capture = true; + + /** + * [description] + * + * @name Phaser.Input.Mouse.MouseManager#enabled + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.enabled = false; + + /** + * [description] + * + * @name Phaser.Input.Mouse.MouseManager#target + * @type {null} + * @since 3.0.0 + */ + this.target; + + /** + * [description] + * + * @name Phaser.Input.Mouse.MouseManager#handler + * @type {null} + * @since 3.0.0 + */ + this.handler; + + /** + * If the mouse has been pointer locked successfully this will be set to true. + * + * @name Phaser.Input.Mouse.MouseManager#locked + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.locked = false; + }, + + /** + * [description] + * + * @method Phaser.Input.Mouse.MouseManager#boot + * @since 3.0.0 + */ + boot: function () + { + var config = this.manager.config; + + this.enabled = config.inputMouse; + this.target = config.inputMouseEventTarget; + this.capture = config.inputMouseCapture; + + if (!this.target) + { + this.target = this.manager.game.canvas; + } + + if (config.disableContextMenu) + { + this.disableContextMenu(); + } + + if (this.enabled) + { + this.startListeners(); + } + }, + + /** + * [description] + * + * @method Phaser.Input.Mouse.MouseManager#disableContextMenu + * @since 3.0.0 + * + * @return {Phaser.Input.Mouse.MouseManager} [description] + */ + disableContextMenu: function () + { + document.body.addEventListener('contextmenu', function (event) + { + event.preventDefault(); + return false; + }); + + return this; + }, + + /** + * If the browser supports it, you can request that the pointer be locked to the browser window. + * + * This is classically known as 'FPS controls', where the pointer can't leave the browser until + * the user presses an exit key. + * + * If the browser successfully enters a locked state, a `POINTER_LOCK_CHANGE_EVENT` will be dispatched, + * from the games Input Manager, with an `isPointerLocked` property. + * + * It is important to note that pointer lock can only be enabled after an 'engagement gesture', + * see: https://w3c.github.io/pointerlock/#dfn-engagement-gesture. + * + * @method Phaser.Input.Mouse.MouseManager#requestPointerLock + * @since 3.0.0 + */ + requestPointerLock: function () + { + if (Features.pointerLock) + { + var element = this.target; + element.requestPointerLock = element.requestPointerLock || element.mozRequestPointerLock || element.webkitRequestPointerLock; + element.requestPointerLock(); + } + }, + + /** + * Internal pointerLockChange handler. + * + * @method Phaser.Input.Mouse.MouseManager#pointerLockChange + * @since 3.0.0 + * + * @param {Event} event - The native event from the browser. + */ + pointerLockChange: function (event) + { + var element = this.target; + + this.locked = (document.pointerLockElement === element || document.mozPointerLockElement === element || document.webkitPointerLockElement === element) ? true : false; + + this.manager.queue.push(event); + }, + + /** + * If the browser supports pointer lock, this will request that the pointer lock is released. If + * the browser successfully enters a locked state, a 'POINTER_LOCK_CHANGE_EVENT' will be + * dispatched - from the game's input manager - with an `isPointerLocked` property. + * + * @method Phaser.Input.Mouse.MouseManager#releasePointerLock + * @since 3.0.0 + */ + releasePointerLock: function () + { + if (Features.pointerLock) + { + document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock || document.webkitExitPointerLock; + document.exitPointerLock(); + } + }, + + /** + * [description] + * + * @method Phaser.Input.Mouse.MouseManager#startListeners + * @since 3.0.0 + */ + startListeners: function () + { + var queue = this.manager.queue; + var target = this.target; + + var passive = { passive: true }; + var nonPassive = { passive: false }; + + var handler; + + if (this.capture) + { + handler = function (event) + { + if (event.defaultPrevented) + { + // Do nothing if event already handled + return; + } + + // console.log('mouse', event); + + queue.push(event); + + event.preventDefault(); + }; + + target.addEventListener('mousemove', handler, nonPassive); + target.addEventListener('mousedown', handler, nonPassive); + target.addEventListener('mouseup', handler, nonPassive); + } + else + { + handler = function (event) + { + if (event.defaultPrevented) + { + // Do nothing if event already handled + return; + } + + queue.push(event); + }; + + target.addEventListener('mousemove', handler, passive); + target.addEventListener('mousedown', handler, passive); + target.addEventListener('mouseup', handler, passive); + } + + this.handler = handler; + + if (Features.pointerLock) + { + this.pointerLockChange = this.pointerLockChange.bind(this); + + document.addEventListener('pointerlockchange', this.pointerLockChange, true); + document.addEventListener('mozpointerlockchange', this.pointerLockChange, true); + document.addEventListener('webkitpointerlockchange', this.pointerLockChange, true); + } + }, + + /** + * [description] + * + * @method Phaser.Input.Mouse.MouseManager#stopListeners + * @since 3.0.0 + */ + stopListeners: function () + { + var target = this.target; + + target.removeEventListener('mousemove', this.handler); + target.removeEventListener('mousedown', this.handler); + target.removeEventListener('mouseup', this.handler); + + if (Features.pointerLock) + { + document.removeEventListener('pointerlockchange', this.pointerLockChange, true); + document.removeEventListener('mozpointerlockchange', this.pointerLockChange, true); + document.removeEventListener('webkitpointerlockchange', this.pointerLockChange, true); + } + }, + + /** + * [description] + * + * @method Phaser.Input.Mouse.MouseManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.stopListeners(); + + this.manager = null; + } + +}); + +module.exports = MouseManager; /***/ }), @@ -59087,247 +65050,278 @@ module.exports = GetPowerOfTwo; */ var Class = __webpack_require__(0); -var Utils = __webpack_require__(41); +var GetFastValue = __webpack_require__(2); +var ProcessKeyCombo = __webpack_require__(803); +var ResetKeyCombo = __webpack_require__(801); + +/** + * @callback KeyboardKeydownCallback + * + * @param {KeyboardEvent} event - [description] + */ + +/** + * @typedef {object} KeyComboConfig + * + * @property {boolean} [resetOnWrongKey=true] - [description] + * @property {number} [maxKeyDelay=0] - [description] + * @property {boolean} [resetOnMatch=false] - [description] + * @property {boolean} [deleteOnMatch=false] - [description] + */ /** * @classdesc * [description] * - * @class Light - * @memberOf Phaser.GameObjects + * `keys` argument can be: + * + * A string (ATARI) + * An array of either integers (key codes) or strings, or a mixture of both + * An array of objects (such as Key objects) with a public 'keyCode' property + * + * @class KeyCombo + * @memberOf Phaser.Input.Keyboard * @constructor * @since 3.0.0 * - * @param {number} x - The horizontal position of the light. - * @param {number} y - The vertical position of the light. - * @param {number} radius - The radius of the light. - * @param {number} r - The red color. A value between 0 and 1. - * @param {number} g - The green color. A value between 0 and 1. - * @param {number} b - The blue color. A value between 0 and 1. - * @param {number} intensity - The intensity of the light. + * @param {Phaser.Input.Keyboard.KeyboardManager} keyboardManager - [description] + * @param {(string|integer[]|object[])} keys - [description] + * @param {KeyComboConfig} [config] - [description] */ -var Light = new Class({ +var KeyCombo = new Class({ initialize: - function Light (x, y, radius, r, g, b, intensity) + function KeyCombo (keyboardManager, keys, config) { - /** - * [description] - * - * @name Phaser.GameObjects.Light#x - * @type {number} - * @since 3.0.0 - */ - this.x = x; + if (config === undefined) { config = {}; } + + // Can't have a zero or single length combo (string or array based) + if (keys.length < 2) + { + return false; + } /** * [description] * - * @name Phaser.GameObjects.Light#y - * @type {number} + * @name Phaser.Input.Keyboard.KeyCombo#manager + * @type {Phaser.Input.Keyboard.KeyboardManager} * @since 3.0.0 */ - this.y = y; + this.manager = keyboardManager; /** * [description] * - * @name Phaser.GameObjects.Light#radius - * @type {number} + * @name Phaser.Input.Keyboard.KeyCombo#enabled + * @type {boolean} + * @default true * @since 3.0.0 */ - this.radius = radius; + this.enabled = true; /** * [description] * - * @name Phaser.GameObjects.Light#r + * @name Phaser.Input.Keyboard.KeyCombo#keyCodes + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.keyCodes = []; + + // if 'keys' is a string we need to get the keycode of each character in it + + for (var i = 0; i < keys.length; i++) + { + var char = keys[i]; + + if (typeof char === 'string') + { + this.keyCodes.push(char.toUpperCase().charCodeAt(0)); + } + else if (typeof char === 'number') + { + this.keyCodes.push(char); + } + else if (char.hasOwnProperty('keyCode')) + { + this.keyCodes.push(char.keyCode); + } + } + + /** + * The current keyCode the combo is waiting for. + * + * @name Phaser.Input.Keyboard.KeyCombo#current + * @type {integer} + * @since 3.0.0 + */ + this.current = this.keyCodes[0]; + + /** + * The current index of the key being waited for in the 'keys' string. + * + * @name Phaser.Input.Keyboard.KeyCombo#index + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.index = 0; + + /** + * The length of this combo (in keycodes) + * + * @name Phaser.Input.Keyboard.KeyCombo#size * @type {number} * @since 3.0.0 */ - this.r = r; + this.size = this.keyCodes.length; + + /** + * The time the previous key in the combo was matched. + * + * @name Phaser.Input.Keyboard.KeyCombo#timeLastMatched + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.timeLastMatched = 0; + + /** + * Has this Key Combo been matched yet? + * + * @name Phaser.Input.Keyboard.KeyCombo#matched + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.matched = false; + + /** + * The time the entire combo was matched. + * + * @name Phaser.Input.Keyboard.KeyCombo#timeMatched + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.timeMatched = 0; + + /** + * If they press the wrong key do we reset the combo? + * + * @name Phaser.Input.Keyboard.KeyCombo#resetOnWrongKey + * @type {boolean} + * @default 0 + * @since 3.0.0 + */ + this.resetOnWrongKey = GetFastValue(config, 'resetOnWrongKey', true); + + /** + * The max delay in ms between each key press. Above this the combo is reset. 0 means disabled. + * + * @name Phaser.Input.Keyboard.KeyCombo#maxKeyDelay + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.maxKeyDelay = GetFastValue(config, 'maxKeyDelay', 0); + + /** + * If previously matched and they press Key 1 again, will it reset? + * + * @name Phaser.Input.Keyboard.KeyCombo#resetOnMatch + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.resetOnMatch = GetFastValue(config, 'resetOnMatch', false); + + /** + * If the combo matches, will it delete itself? + * + * @name Phaser.Input.Keyboard.KeyCombo#deleteOnMatch + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.deleteOnMatch = GetFastValue(config, 'deleteOnMatch', false); + + var _this = this; + + var onKeyDownHandler = function (event) + { + if (_this.matched || !_this.enabled) + { + return; + } + + var matched = ProcessKeyCombo(event, _this); + + if (matched) + { + _this.manager.emit('keycombomatch', _this, event); + + if (_this.resetOnMatch) + { + ResetKeyCombo(_this); + } + else if (_this.deleteOnMatch) + { + _this.destroy(); + } + } + }; /** * [description] * - * @name Phaser.GameObjects.Light#g - * @type {number} + * @name Phaser.Input.Keyboard.KeyCombo#onKeyDown + * @type {KeyboardKeydownCallback} * @since 3.0.0 */ - this.g = g; + this.onKeyDown = onKeyDownHandler; - /** - * [description] - * - * @name Phaser.GameObjects.Light#b - * @type {number} - * @since 3.0.0 - */ - this.b = b; + this.manager.on('keydown', onKeyDownHandler); + }, - /** - * [description] - * - * @name Phaser.GameObjects.Light#intensity - * @type {number} - * @since 3.0.0 - */ - this.intensity = intensity; + /** + * How far complete is this combo? A value between 0 and 1. + * + * @name Phaser.Input.Keyboard.KeyCombo#progress + * @type {number} + * @readOnly + * @since 3.0.0 + */ + progress: { - /** - * [description] - * - * @name Phaser.GameObjects.Light#scrollFactorX - * @type {number} - * @since 3.0.0 - */ - this.scrollFactorX = 1.0; + get: function () + { + return this.index / this.size; + } - /** - * [description] - * - * @name Phaser.GameObjects.Light#scrollFactorY - * @type {number} - * @since 3.0.0 - */ - this.scrollFactorY = 1.0; }, /** * [description] * - * @method Phaser.GameObjects.Light#set + * @method Phaser.Input.Keyboard.KeyCombo#destroy * @since 3.0.0 - * - * @param {number} x - The horizontal position of the light. - * @param {number} y - The vertical position of the light. - * @param {number} radius - The radius of the light. - * @param {number} r - The red color. A value between 0 and 1. - * @param {number} g - The green color. A value between 0 and 1. - * @param {number} b - The blue color. A value between 0 and 1. - * @param {number} intensity - The intensity of the light. - * - * @return {Phaser.GameObjects.Light} This Light object. */ - set: function (x, y, radius, r, g, b, intensity) + destroy: function () { - this.x = x; - this.y = y; + this.enabled = false; + this.keyCodes = []; - this.radius = radius; - - this.r = r; - this.g = g; - this.b = b; - - this.intensity = intensity; - - this.scrollFactorX = 1; - this.scrollFactorY = 1; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Light#setScrollFactor - * @since 3.0.0 - * - * @param {number} x - The horizontal scroll factor of the light. - * @param {number} y - The vertical scroll factor of the light. - * - * @return {Phaser.GameObjects.Light} This Light object. - */ - setScrollFactor: function (x, y) - { - if (x === undefined) { x = 1; } - if (y === undefined) { y = x; } - - this.scrollFactorX = x; - this.scrollFactorY = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Light#setColor - * @since 3.0.0 - * - * @param {number} rgb - [description] - * - * @return {Phaser.GameObjects.Light} This Light object. - */ - setColor: function (rgb) - { - var color = Utils.getFloatsFromUintRGB(rgb); - - this.r = color[0]; - this.g = color[1]; - this.b = color[2]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Light#setIntensity - * @since 3.0.0 - * - * @param {number} intensity - [description] - * - * @return {Phaser.GameObjects.Light} This Light object. - */ - setIntensity: function (intensity) - { - this.intensity = intensity; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Light#setPosition - * @since 3.0.0 - * - * @param {number} x - The horizontal position of the light. - * @param {number} y - The vertical position of the light. - * - * @return {Phaser.GameObjects.Light} This Light object. - */ - setPosition: function (x, y) - { - this.x = x; - this.y = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Light#setRadius - * @since 3.0.0 - * - * @param {number} radius - [description] - * - * @return {Phaser.GameObjects.Light} This Light object. - */ - setRadius: function (radius) - { - this.radius = radius; - - return this; + this.manager.off('keydown', this.onKeyDown); + this.manager = undefined; } }); -module.exports = Light; +module.exports = KeyCombo; /***/ }), @@ -59341,323 +65335,191 @@ module.exports = Light; */ var Class = __webpack_require__(0); -var Light = __webpack_require__(292); -var LightPipeline = __webpack_require__(165); -var Utils = __webpack_require__(41); /** * @classdesc - * [description] + * A generic Key object which can be passed to the Process functions (and so on) + * keycode must be an integer * - * @class LightsManager - * @memberOf Phaser.GameObjects + * @class Key + * @memberOf Phaser.Input.Keyboard * @constructor * @since 3.0.0 + * + * @param {integer} keyCode - The keycode of this key. */ -var LightsManager = new Class({ +var Key = new Class({ initialize: - function LightsManager () + function Key (keyCode) { /** - * [description] + * The keycode of this key. * - * @name Phaser.GameObjects.LightsManager#lightPool - * @type {array} - * @default [] + * @name Phaser.Input.Keyboard.Key#keyCode + * @type {integer} * @since 3.0.0 */ - this.lightPool = []; + this.keyCode = keyCode; /** - * [description] + * The original DOM event. * - * @name Phaser.GameObjects.LightsManager#lights - * @type {array} - * @default [] + * @name Phaser.Input.Keyboard.Key#originalEvent + * @type {KeyboardEvent} * @since 3.0.0 */ - this.lights = []; + this.originalEvent = undefined; /** - * [description] + * Should this Key prevent event propagation? * - * @name Phaser.GameObjects.LightsManager#culledLights - * @type {array} - * @default [] + * @name Phaser.Input.Keyboard.Key#preventDefault + * @type {boolean} + * @default true * @since 3.0.0 */ - this.culledLights = []; + this.preventDefault = true; /** - * [description] + * Can this Key be processed? * - * @name Phaser.GameObjects.LightsManager#ambientColor - * @type {{ r: float, g: float, b: float }} + * @name Phaser.Input.Keyboard.Key#enabled + * @type {boolean} + * @default true * @since 3.0.0 */ - this.ambientColor = { r: 0.1, g: 0.1, b: 0.1 }; + this.enabled = true; /** - * [description] + * The "down" state of the key. This will remain `true` for as long as the keyboard thinks this key is held down. * - * @name Phaser.GameObjects.LightsManager#active + * @name Phaser.Input.Keyboard.Key#isDown * @type {boolean} * @default false * @since 3.0.0 */ - this.active = false; - }, + this.isDown = false; - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#enable - * @since 3.0.0 - * - * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. - */ - enable: function () - { - this.active = true; + /** + * The "up" state of the key. This will remain `true` for as long as the keyboard thinks this key is up. + * + * @name Phaser.Input.Keyboard.Key#isUp + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.isUp = true; - return this; - }, + /** + * The down state of the ALT key, if pressed at the same time as this key. + * + * @name Phaser.Input.Keyboard.Key#altKey + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.altKey = false; - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#disable - * @since 3.0.0 - * - * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. - */ - disable: function () - { - this.active = false; + /** + * The down state of the CTRL key, if pressed at the same time as this key. + * + * @name Phaser.Input.Keyboard.Key#ctrlKey + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.ctrlKey = false; - return this; - }, + /** + * The down state of the SHIFT key, if pressed at the same time as this key. + * + * @name Phaser.Input.Keyboard.Key#shiftKey + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.shiftKey = false; - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#cull - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - * @return {Phaser.GameObjects.Light[]} [description] - */ - cull: function (camera) - { - var lights = this.lights; - var culledLights = this.culledLights; - var length = lights.length; - var cameraCenterX = camera.x + camera.width / 2.0; - var cameraCenterY = camera.y + camera.height / 2.0; - var cameraRadius = (camera.width + camera.height) / 2.0; - var point = { x: 0, y: 0 }; - var cameraMatrix = camera.matrix; - var viewportHeight = this.systems.game.config.height; + /** + * The location of the modifier key. 0 for standard (or unknown), 1 for left, 2 for right, 3 for numpad. + * + * @name Phaser.Input.Keyboard.Key#location + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.location = 0; - culledLights.length = 0; + /** + * The timestamp when the key was last pressed down. + * + * @name Phaser.Input.Keyboard.Key#timeDown + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.timeDown = 0; - for (var index = 0; index < length && culledLights.length < LightPipeline.LIGHT_COUNT; ++index) - { - var light = lights[index]; + /** + * The number of milliseconds this key has been held down for. + * If the key is down this value holds the duration of that key press and is constantly updated. + * If the key is up it holds the duration of the previous down session. + * + * @name Phaser.Input.Keyboard.Key#duration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.duration = 0; - cameraMatrix.transformPoint(light.x, light.y, point); + /** + * The timestamp when the key was last released. + * + * @name Phaser.Input.Keyboard.Key#timeUp + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.timeUp = 0; - // We'll just use bounding spheres to test - // if lights should be rendered - var dx = cameraCenterX - (point.x - (camera.scrollX * light.scrollFactorX * camera.zoom)); - var dy = cameraCenterY - (viewportHeight - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom)); - var distance = Math.sqrt(dx * dx + dy * dy); + /** + * If a key is held down this holds down the number of times the key has 'repeated'. + * + * @name Phaser.Input.Keyboard.Key#repeats + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.repeats = 0; - if (distance < light.radius + cameraRadius) - { - culledLights.push(lights[index]); - } - } + /** + * True if the key has just been pressed (NOTE: requires to be reset, see justDown getter) + * + * @name Phaser.Input.Keyboard.Key#_justDown + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._justDown = false; - return culledLights; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#forEachLight - * @since 3.0.0 - * - * @param {function} callback - [description] - * - * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. - */ - forEachLight: function (callback) - { - if (!callback) - { - return; - } - - var lights = this.lights; - var length = lights.length; - - for (var index = 0; index < length; ++index) - { - callback(lights[index]); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#setAmbientColor - * @since 3.0.0 - * - * @param {[type]} rgb - [description] - * - * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. - */ - setAmbientColor: function (rgb) - { - var color = Utils.getFloatsFromUintRGB(rgb); - - this.ambientColor.r = color[0]; - this.ambientColor.g = color[1]; - this.ambientColor.b = color[2]; - - return this; - }, - - /** - * Returns the maximum number of Lights allowed to appear at once. - * - * @method Phaser.GameObjects.LightsManager#getMaxVisibleLights - * @since 3.0.0 - * - * @return {integer} [description] - */ - getMaxVisibleLights: function () - { - return 10; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#getLightCount - * @since 3.0.0 - * - * @return {integer} [description] - */ - getLightCount: function () - { - return this.lights.length; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#addLight - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} radius - [description] - * @param {number} rgb - [description] - * @param {number} intensity - [description] - * - * @return {Phaser.GameObjects.Light} [description] - */ - addLight: function (x, y, radius, rgb, intensity) - { - var color = null; - var light = null; - - x = (x === undefined) ? 0.0 : x; - y = (y === undefined) ? 0.0 : y; - rgb = (rgb === undefined) ? 0xffffff : rgb; - radius = (radius === undefined) ? 100.0 : radius; - intensity = (intensity === undefined) ? 1.0 : intensity; - - color = Utils.getFloatsFromUintRGB(rgb); - light = null; - - if (this.lightPool.length > 0) - { - light = this.lightPool.pop(); - light.set(x, y, radius, color[0], color[1], color[2], intensity); - } - else - { - light = new Light(x, y, radius, color[0], color[1], color[2], intensity); - } - - this.lights.push(light); - - return light; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#removeLight - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Light} light - [description] - * - * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. - */ - removeLight: function (light) - { - var index = this.lights.indexOf(light); - - if (index >= 0) - { - this.lightPool.push(light); - this.lights.splice(index, 1); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - while (this.lights.length > 0) - { - this.lightPool.push(this.lights.pop()); - } - - this.ambientColor = { r: 0.1, g: 0.1, b: 0.1 }; - this.culledLights.length = 0; - this.lights.length = 0; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.shutdown(); + /** + * True if the key has just been pressed (NOTE: requires to be reset, see justDown getter) + * + * @name Phaser.Input.Keyboard.Key#_justUp + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._justUp = false; } }); -module.exports = LightsManager; +module.exports = Key; /***/ }), @@ -59670,22 +65532,425 @@ module.exports = LightsManager; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(15); +var Key = __webpack_require__(293); +var KeyCodes = __webpack_require__(143); +var KeyCombo = __webpack_require__(292); +var KeyMap = __webpack_require__(800); +var ProcessKeyDown = __webpack_require__(799); +var ProcessKeyUp = __webpack_require__(798); + /** - * @namespace Phaser.Geom + * @classdesc + * The Keyboard class monitors keyboard input and dispatches keyboard events. + * + * _Note_: many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. + * See http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/ for more details. + * + * Also please be aware that certain browser extensions can disable or override Phaser keyboard handling. + * For example the Chrome extension vimium is known to disable Phaser from using the D key. And there are others. + * So please check your extensions before opening Phaser issues. + * + * @class KeyboardManager + * @extends EventEmitter + * @memberOf Phaser.Input.Keyboard + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Input.InputManager} inputManager - [description] */ +var KeyboardManager = new Class({ -module.exports = { - - Circle: __webpack_require__(665), - Ellipse: __webpack_require__(270), - Intersects: __webpack_require__(295), - Line: __webpack_require__(685), - Point: __webpack_require__(703), - Polygon: __webpack_require__(717), - Rectangle: __webpack_require__(307), - Triangle: __webpack_require__(746) + Extends: EventEmitter, -}; + initialize: + + function KeyboardManager (inputManager) + { + EventEmitter.call(this); + + /** + * [description] + * + * @name Phaser.Input.Keyboard.KeyboardManager#manager + * @type {Phaser.Input.InputManager} + * @since 3.0.0 + */ + this.manager = inputManager; + + /** + * [description] + * + * @name Phaser.Input.Keyboard.KeyboardManager#enabled + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.enabled = false; + + /** + * [description] + * + * @name Phaser.Input.Keyboard.KeyboardManager#target + * @type {?object} + * @since 3.0.0 + */ + this.target; + + /** + * [description] + * + * @name Phaser.Input.Keyboard.KeyboardManager#keys + * @type {Phaser.Input.Keyboard.Key[]} + * @default [] + * @since 3.0.0 + */ + this.keys = []; + + /** + * [description] + * + * @name Phaser.Input.Keyboard.KeyboardManager#combos + * @type {Phaser.Input.Keyboard.KeyCombo[]} + * @default [] + * @since 3.0.0 + */ + this.combos = []; + + /** + * [description] + * + * @name Phaser.Input.Keyboard.KeyboardManager#captures + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.captures = []; + + /** + * [description] + * + * @name Phaser.Input.Keyboard.KeyboardManager#queue + * @type {KeyboardEvent[]} + * @default [] + * @since 3.0.0 + */ + this.queue = []; + + /** + * [description] + * + * @name Phaser.Input.Keyboard.KeyboardManager#handler + * @type {?function} + * @since 3.0.0 + */ + this.handler; + }, + + /** + * The Boot handler is called by Phaser.Game when it first starts up. + * + * @method Phaser.Input.Keyboard.KeyboardManager#boot + * @since 3.0.0 + */ + boot: function () + { + var config = this.manager.config; + + this.enabled = config.inputKeyboard; + this.target = config.inputKeyboardEventTarget; + + if (this.enabled) + { + this.startListeners(); + } + }, + + /** + * [description] + * + * @method Phaser.Input.Keyboard.KeyboardManager#startListeners + * @since 3.0.0 + */ + startListeners: function () + { + var queue = this.queue; + var captures = this.captures; + + var handler = function (event) + { + if (event.defaultPrevented) + { + // Do nothing if event already handled + return; + } + + queue.push(event); + + if (captures[event.keyCode]) + { + event.preventDefault(); + } + }; + + this.handler = handler; + + this.target.addEventListener('keydown', handler, false); + this.target.addEventListener('keyup', handler, false); + }, + + /** + * [description] + * + * @method Phaser.Input.Keyboard.KeyboardManager#stopListeners + * @since 3.0.0 + */ + stopListeners: function () + { + this.target.removeEventListener('keydown', this.handler); + this.target.removeEventListener('keyup', this.handler); + }, + + /** + * Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right, and also space and shift. + * + * @method Phaser.Input.Keyboard.KeyboardManager#createCursorKeys + * @since 3.0.0 + * + * @return {object} [description] + */ + createCursorKeys: function () + { + return this.addKeys({ + up: KeyCodes.UP, + down: KeyCodes.DOWN, + left: KeyCodes.LEFT, + right: KeyCodes.RIGHT, + space: KeyCodes.SPACE, + shift: KeyCodes.SHIFT + }); + }, + + /** + * A practical way to create an object containing user selected hotkeys. + * + * For example, + * + * addKeys( { 'up': Phaser.KeyCode.W, 'down': Phaser.KeyCode.S, 'left': Phaser.KeyCode.A, 'right': Phaser.KeyCode.D } ); + * + * would return an object containing properties (`up`, `down`, `left` and `right`) referring to {@link Phaser.Key} object. + * + * @method Phaser.Input.Keyboard.KeyboardManager#addKeys + * @since 3.0.0 + * + * @param {object} keys - [description] + * + * @return {object} [description] + */ + addKeys: function (keys) + { + var output = {}; + + for (var key in keys) + { + output[key] = this.addKey(keys[key]); + } + + return output; + }, + + /** + * If you need more fine-grained control over a Key you can create a new Phaser.Key object via this method. + * The Key object can then be polled, have events attached to it, etc. + * + * @method Phaser.Input.Keyboard.KeyboardManager#addKey + * @since 3.0.0 + * + * @param {(string|integer)} keyCode - [description] + * + * @return {Phaser.Input.Keyboard.Key} [description] + */ + addKey: function (keyCode) + { + var keys = this.keys; + + if (!keys[keyCode]) + { + keys[keyCode] = new Key(keyCode); + this.captures[keyCode] = true; + } + + return keys[keyCode]; + }, + + /** + * Removes a Key object from the Keyboard manager. + * + * @method Phaser.Input.Keyboard.KeyboardManager#removeKey + * @since 3.0.0 + * + * @param {(string|integer)} keyCode - [description] + */ + removeKey: function (keyCode) + { + if (this.keys[keyCode]) + { + this.keys[keyCode] = undefined; + this.captures[keyCode] = false; + } + }, + + /** + * [description] + * + * @method Phaser.Input.Keyboard.KeyboardManager#addKeyCapture + * @since 3.0.0 + * + * @param {(string|integer|string[]|integer[])} keyCodes - [description] + */ + addKeyCapture: function (keyCodes) + { + if (!Array.isArray(keyCodes)) + { + keyCodes = [ keyCodes ]; + } + + for (var i = 0; i < keyCodes.length; i++) + { + this.captures[keyCodes[i]] = true; + } + }, + + /** + * [description] + * + * @method Phaser.Input.Keyboard.KeyboardManager#removeKeyCapture + * @since 3.0.0 + * + * @param {(string|integer|string[]|integer[])} keyCodes - [description] + */ + removeKeyCapture: function (keyCodes) + { + if (!Array.isArray(keyCodes)) + { + keyCodes = [ keyCodes ]; + } + + for (var i = 0; i < keyCodes.length; i++) + { + this.captures[keyCodes[i]] = false; + } + }, + + /** + * [description] + * + * @method Phaser.Input.Keyboard.KeyboardManager#createCombo + * @since 3.0.0 + * + * @param {(string|integer[]|object[])} keys - [description] + * @param {KeyComboConfig} config - [description] + * + * @return {Phaser.Input.Keyboard.KeyCombo} [description] + */ + createCombo: function (keys, config) + { + return new KeyCombo(this, keys, config); + }, + + /** + * [description] + * + * @method Phaser.Input.Keyboard.KeyboardManager#update + * @since 3.0.0 + */ + update: function () + { + var len = this.queue.length; + + if (!this.enabled || len === 0) + { + return; + } + + // Clears the queue array, and also means we don't work on array data that could potentially + // be modified during the processing phase + var queue = this.queue.splice(0, len); + + var keys = this.keys; + + // Process the event queue, dispatching all of the events that have stored up + for (var i = 0; i < len; i++) + { + var event = queue[i]; + var code = event.keyCode; + + if (event.type === 'keydown') + { + if (KeyMap[code] && (keys[code] === undefined || keys[code].isDown === false)) + { + // Will emit a keyboard or keyup event + this.emit(event.type, event); + + this.emit('keydown_' + KeyMap[code], event); + } + + if (keys[code]) + { + ProcessKeyDown(keys[code], event); + } + } + else + { + // Will emit a keyboard or keyup event + this.emit(event.type, event); + + this.emit('keyup_' + KeyMap[code], event); + + if (keys[code]) + { + ProcessKeyUp(keys[code], event); + } + } + } + }, + + /** + * [description] + * + * @method Phaser.Input.Keyboard.KeyboardManager#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.removeAllListeners(); + }, + + /** + * [description] + * + * @method Phaser.Input.Keyboard.KeyboardManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.stopListeners(); + + this.removeAllListeners(); + + this.keys = []; + this.combos = []; + this.captures = []; + this.queue = []; + this.handler = undefined; + + this.manager = null; + } + +}); + +module.exports = KeyboardManager; /***/ }), @@ -59698,33 +65963,119 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); + /** - * @namespace Phaser.Geom.Intersects + * @classdesc + * [description] + * + * @class Button + * @memberOf Phaser.Input.Gamepad + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Input.Gamepad.Gamepad} pad - [description] + * @param {integer} index - [description] */ +var Button = new Class({ -module.exports = { + initialize: - CircleToCircle: __webpack_require__(675), - CircleToRectangle: __webpack_require__(676), - GetRectangleIntersection: __webpack_require__(677), - LineToCircle: __webpack_require__(297), - LineToLine: __webpack_require__(89), - LineToRectangle: __webpack_require__(678), - PointToLine: __webpack_require__(298), - PointToLineSegment: __webpack_require__(679), - RectangleToRectangle: __webpack_require__(296), - RectangleToTriangle: __webpack_require__(680), - RectangleToValues: __webpack_require__(681), - TriangleToCircle: __webpack_require__(682), - TriangleToLine: __webpack_require__(683), - TriangleToTriangle: __webpack_require__(684) + function Button (pad, index) + { + /** + * [description] + * + * @name Phaser.Input.Gamepad.Button#pad + * @type {Phaser.Input.Gamepad.Gamepad} + * @since 3.0.0 + */ + this.pad = pad; -}; + /** + * [description] + * + * @name Phaser.Input.Gamepad.Button#events + * @type {EventEmitter} + * @since 3.0.0 + */ + this.events = pad.events; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.Button#index + * @type {integer} + * @since 3.0.0 + */ + this.index = index; + + /** + * Between 0 and 1. + * + * @name Phaser.Input.Gamepad.Button#value + * @type {float} + * @default 0 + * @since 3.0.0 + */ + this.value = 0; + + /** + * Can be set for Analogue buttons to enable a 'pressure' threshold before considered as 'pressed'. + * + * @name Phaser.Input.Gamepad.Button#threshold + * @type {float} + * @default 1 + * @since 3.0.0 + */ + this.threshold = 1; + + /** + * Is the Button being pressed down or not? + * + * @name Phaser.Input.Gamepad.Button#pressed + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.pressed = false; + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.Button#update + * @since 3.0.0 + * + * @param {GamepadButton} data - [description] + */ + update: function (data) + { + this.value = data.value; + + if (this.value >= this.threshold) + { + if (!this.pressed) + { + this.pressed = true; + this.events.emit('down', this.pad, this, this.value, data); + } + } + else if (this.pressed) + { + this.pressed = false; + this.events.emit('up', this.pad, this, this.value, data); + } + } + +}); + +module.exports = Button; /***/ }), /* 296 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -59732,28 +66083,102 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); + /** + * @classdesc * [description] * - * @function Phaser.Geom.Intersects.RectangleToRectangle + * @class Axis + * @memberOf Phaser.Input.Gamepad + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] - * - * @return {boolean} [description] + * @param {Phaser.Input.Gamepad.Gamepad} pad - [description] + * @param {integer} index - [description] */ -var RectangleToRectangle = function (rectA, rectB) -{ - if (rectA.width <= 0 || rectA.height <= 0 || rectB.width <= 0 || rectB.height <= 0) +var Axis = new Class({ + + initialize: + + function Axis (pad, index) { - return false; + /** + * [description] + * + * @name Phaser.Input.Gamepad.Axis#pad + * @type {Phaser.Input.Gamepad.Gamepad} + * @since 3.0.0 + */ + this.pad = pad; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.Axis#events + * @type {EventEmitter} + * @since 3.0.0 + */ + this.events = pad.events; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.Axis#index + * @type {integer} + * @since 3.0.0 + */ + this.index = index; + + /** + * Between -1 and 1 with 0 being dead center. + * + * @name Phaser.Input.Gamepad.Axis#value + * @type {float} + * @default 0 + * @since 3.0.0 + */ + this.value = 0; + + this.threshold = 0.05; + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.Axis#update + * @since 3.0.0 + * + * @param {float} value - [description] + */ + update: function (value) + { + this.value = value; + }, + + /** + * Applies threshold to the value and returns it. + * + * @method Phaser.Input.Gamepad.Axis#getValue + * @since 3.0.0 + * + * @return {float} [description] + */ + getValue: function () + { + var percentage = (Math.abs(this.value) - this.threshold) / (1 - this.threshold); + + if (percentage < 0) + { + percentage = 0; + } + + return percentage * (this.value > 0 ? 1 : -1); } - return !(rectA.right < rectB.x || rectA.bottom < rectB.y || rectA.x > rectB.right || rectA.y > rectB.bottom); -}; +}); -module.exports = RectangleToRectangle; +module.exports = Axis; /***/ }), @@ -59766,84 +66191,158 @@ module.exports = RectangleToRectangle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Based on code by Matt DesLauriers -// https://github.com/mattdesl/line-circle-collision/blob/master/LICENSE.md - -var Contains = __webpack_require__(32); -var Point = __webpack_require__(5); - -var tmp = new Point(); +var Axis = __webpack_require__(296); +var Button = __webpack_require__(295); +var Class = __webpack_require__(0); /** + * @classdesc * [description] * - * @function Phaser.Geom.Intersects.LineToCircle + * @class Gamepad + * @memberOf Phaser.Input.Gamepad + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Line} line - [description] - * @param {Phaser.Geom.Circle} circle - [description] - * @param {Phaser.Geom.Point} [nearest] - [description] - * - * @return {boolean} [description] + * @param {Phaser.Input.Gamepad.GamepadManager} manager - [description] + * @param {string} id - [description] + * @param {number} index - [description] */ -var LineToCircle = function (line, circle, nearest) -{ - if (nearest === undefined) { nearest = tmp; } +var Gamepad = new Class({ - if (Contains(circle, line.x1, line.y1)) + initialize: + + function Gamepad (manager, id, index) { - nearest.x = line.x1; - nearest.y = line.y1; + /** + * [description] + * + * @name Phaser.Input.Gamepad.Gamepad#manager + * @type {Phaser.Input.Gamepad.GamepadManager} + * @since 3.0.0 + */ + this.manager = manager; - return true; + /** + * [description] + * + * @name Phaser.Input.Gamepad.Gamepad#events + * @type {EventEmitter} + * @since 3.0.0 + */ + this.events = manager.events; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.Gamepad#id + * @type {string} + * @since 3.0.0 + */ + this.id = id; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.Gamepad#index + * @type {number} + * @since 3.0.0 + */ + this.index = index; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.Gamepad#connected + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.connected = true; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.Gamepad#timestamp + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.timestamp = 0; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.Gamepad#buttons + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.buttons = []; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.Gamepad#axes + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.axes = []; + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.Gamepad#update + * @since 3.0.0 + * + * @param {Gamepad} data - [description] + */ + update: function (data) + { + this.timestamp = data.timestamp; + this.connected = data.connected; + + var i; + + var axes = this.axes; + var buttons = this.buttons; + + for (i = 0; i < data.buttons.length; i++) + { + var buttonData = data.buttons[i]; + + if (buttons[i] === undefined) + { + buttons[i] = new Button(this, i); + } + + buttons[i].update(buttonData); + } + + // Axes + for (i = 0; i < data.axes.length; i++) + { + var axisData = data.axes[i]; + + if (axes[i] === undefined) + { + axes[i] = new Axis(this, i); + } + + axes[i].update(axisData); + } } - if (Contains(circle, line.x2, line.y2)) - { - nearest.x = line.x2; - nearest.y = line.y2; +}); - return true; - } - - var dx = line.x2 - line.x1; - var dy = line.y2 - line.y1; - - var lcx = circle.x - line.x1; - var lcy = circle.y - line.y1; - - // project lc onto d, resulting in vector p - var dLen2 = (dx * dx) + (dy * dy); - var px = dx; - var py = dy; - - if (dLen2 > 0) - { - var dp = ((lcx * dx) + (lcy * dy)) / dLen2; - - px *= dp; - py *= dp; - } - - nearest.x = line.x1 + px; - nearest.y = line.y1 + py; - - // len2 of p - var pLen2 = (px * px) + (py * py); - - return ( - pLen2 <= dLen2 && - ((px * dx) + (py * dy)) >= 0 && - Contains(circle, nearest.x, nearest.y) - ); -}; - -module.exports = LineToCircle; +module.exports = Gamepad; /***/ }), /* 298 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -59851,28 +66350,395 @@ module.exports = LineToCircle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var Gamepad = __webpack_require__(297); + +// https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API +// https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API +// https://www.smashingmagazine.com/2015/11/gamepad-api-in-web-games/ +// http://html5gamepad.com/ + /** + * @typedef {object} Pad + * + * @property {string} id - [description] + * @property {number} index - [description] + */ + +/** + * @classdesc * [description] * - * @function Phaser.Geom.Intersects.PointToLine + * @class GamepadManager + * @memberOf Phaser.Input.Gamepad + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Point} point - [description] - * @param {Phaser.Geom.Line} line - [description] - * - * @return {boolean} [description] + * @param {Phaser.Input.InputManager} inputManager - [description] */ -var PointToLine = function (point, line) -{ - return ((point.x - line.x1) * (line.y2 - line.y1) === (line.x2 - line.x1) * (point.y - line.y1)); -}; +var GamepadManager = new Class({ -module.exports = PointToLine; + initialize: + + function GamepadManager (inputManager) + { + /** + * [description] + * + * @name Phaser.Input.Gamepad.GamepadManager#manager + * @type {Phaser.Input.InputManager} + * @since 3.0.0 + */ + this.manager = inputManager; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.GamepadManager#events + * @type {EventEmitter} + * @since 3.0.0 + */ + this.events = inputManager.events; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.GamepadManager#enabled + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.enabled = false; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.GamepadManager#target + * @type {?object} + * @since 3.0.0 + */ + this.target; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.GamepadManager#handler + * @type {?function} + * @since 3.0.0 + */ + this.handler; + + /** + * [description] + * + * @name Phaser.Input.Gamepad.GamepadManager#gamepads + * @type {Phaser.Input.Gamepad.Gamepad[]} + * @default [] + * @since 3.0.0 + */ + this.gamepads = []; + + /** + * Standard FIFO queue. + * + * @name Phaser.Input.Gamepad.GamepadManager#queue + * @type {GamepadEvent[]} + * @default [] + * @since 3.0.0 + */ + this.queue = []; + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.GamepadManager#boot + * @since 3.0.0 + */ + boot: function () + { + var config = this.manager.config; + + this.enabled = config.inputGamepad && this.manager.game.device.input.gamepads; + + this.target = window; + + if (this.enabled) + { + this.startListeners(); + } + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.GamepadManager#startListeners + * @since 3.0.0 + */ + startListeners: function () + { + var queue = this.queue; + + var handler = function handler (event) + { + if (event.defaultPrevented) + { + // Do nothing if event already handled + return; + } + + queue.push(event); + }; + + this.handler = handler; + + var target = this.target; + + target.addEventListener('gamepadconnected', handler, false); + target.addEventListener('gamepaddisconnected', handler, false); + + // FF only for now: + target.addEventListener('gamepadbuttondown', handler, false); + target.addEventListener('gamepadbuttonup', handler, false); + target.addEventListener('gamepadaxismove', handler, false); + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.GamepadManager#stopListeners + * @since 3.0.0 + */ + stopListeners: function () + { + var target = this.target; + var handler = this.handler; + + target.removeEventListener('gamepadconnected', handler); + target.removeEventListener('gamepaddisconnected', handler); + + target.removeEventListener('gamepadbuttondown', handler); + target.removeEventListener('gamepadbuttonup', handler); + target.removeEventListener('gamepadaxismove', handler); + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.GamepadManager#disconnectAll + * @since 3.0.0 + */ + disconnectAll: function () + { + for (var i = 0; i < this.gamepads.length; i++) + { + this.gamepads.connected = false; + } + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.GamepadManager#addPad + * @since 3.0.0 + * + * @param {Pad} pad - [description] + * + * @return {Phaser.Input.Gamepad.Gamepad} [description] + */ + addPad: function (pad) + { + var gamepad = new Gamepad(this, pad.id, pad.index); + + this.gamepads[pad.index] = gamepad; + + return gamepad; + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.GamepadManager#removePad + * @since 3.0.0 + * @todo Code this feature + * + * @param {number} index - [description] + * @param {Pad} pad - [description] + */ + removePad: function () + { + // TODO + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.GamepadManager#refreshPads + * @since 3.0.0 + * + * @param {Pad[]} pads - [description] + */ + refreshPads: function (pads) + { + if (!pads) + { + this.disconnectAll(); + } + else + { + for (var i = 0; i < pads.length; i++) + { + var pad = pads[i]; + + if (!pad) + { + // removePad? + continue; + } + + if (this.gamepads[pad.index] === undefined) + { + this.addPad(pad); + } + + this.gamepads[pad.index].update(pad); + } + } + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.GamepadManager#getAll + * @since 3.0.0 + * + * @return {Phaser.Input.Gamepad.Gamepad[]} [description] + */ + getAll: function () + { + var out = []; + + for (var i = 0; i < this.gamepads.length; i++) + { + if (this.gamepads[i]) + { + out.push(this.gamepads[i]); + } + } + + return out; + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.GamepadManager#getPad + * @since 3.0.0 + * + * @param {number} index - [description] + * + * @return {Phaser.Input.Gamepad.Gamepad} [description] + */ + getPad: function (index) + { + for (var i = 0; i < this.gamepads.length; i++) + { + if (this.gamepads[i].index === index) + { + return this.gamepads[i]; + } + } + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.GamepadManager#update + * @since 3.0.0 + */ + update: function () + { + if (!this.enabled) + { + return; + } + + this.refreshPads(navigator.getGamepads()); + + var len = this.queue.length; + + if (len === 0) + { + return; + } + + var queue = this.queue.splice(0, len); + + // Process the event queue, dispatching all of the events that have stored up + for (var i = 0; i < len; i++) + { + var event = queue[i]; + var pad; + + switch (event.type) + { + case 'gamepadconnected': + + pad = this.getPad(event.gamepad.index); + + this.events.emit('connected', pad, event); + + break; + + case 'gamepaddisconnected': + + pad = this.getPad(event.gamepad.index); + + this.events.emit('disconnected', pad, event); + + break; + } + } + }, + + /** + * [description] + * + * @method Phaser.Input.Gamepad.GamepadManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.stopListeners(); + this.disconnectAll(); + + this.gamepads = []; + }, + + /** + * The total number of connected game pads. + * + * @name Phaser.Input.Gamepad.GamepadManager#total + * @type {number} + * @since 3.0.0 + */ + total: { + + get: function () + { + return this.gamepads.length; + } + + } + +}); + +module.exports = GamepadManager; /***/ }), /* 299 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -59880,30 +66746,579 @@ module.exports = PointToLine; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(15); +var Gamepad = __webpack_require__(298); +var Keyboard = __webpack_require__(294); +var Mouse = __webpack_require__(291); +var Pointer = __webpack_require__(290); +var Rectangle = __webpack_require__(10); +var Touch = __webpack_require__(289); +var TransformXY = __webpack_require__(288); + /** + * @classdesc * [description] * - * @function Phaser.Geom.Rectangle.Decompose + * @class InputManager + * @memberOf Phaser.Input + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {array} [out] - [description] - * - * @return {array} [description] + * @param {Phaser.Game} game - [description] + * @param {object} config - [description] */ -var Decompose = function (rect, out) -{ - if (out === undefined) { out = []; } +var InputManager = new Class({ - out.push({ x: rect.x, y: rect.y }); - out.push({ x: rect.right, y: rect.y }); - out.push({ x: rect.right, y: rect.bottom }); - out.push({ x: rect.x, y: rect.bottom }); + initialize: - return out; -}; + function InputManager (game, config) + { + /** + * [description] + * + * @name Phaser.Input.InputManager#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game = game; -module.exports = Decompose; + /** + * [description] + * + * @name Phaser.Input.InputManager#canvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvas; + + /** + * [description] + * + * @name Phaser.Input.InputManager#config + * @type {object} + * @since 3.0.0 + */ + this.config = config; + + /** + * [description] + * + * @name Phaser.Input.InputManager#enabled + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.enabled = true; + + /** + * [description] + * + * @name Phaser.Input.InputManager#events + * @type {EventEmitter} + * @since 3.0.0 + */ + this.events = new EventEmitter(); + + /** + * Standard FIFO queue. + * + * @name Phaser.Input.InputManager#queue + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.queue = []; + + /** + * [description] + * + * @name Phaser.Input.InputManager#keyboard + * @type {Phaser.Input.Keyboard.KeyboardManager} + * @since 3.0.0 + */ + this.keyboard = new Keyboard(this); + + /** + * [description] + * + * @name Phaser.Input.InputManager#mouse + * @type {Phaser.Input.Mouse.MouseManager} + * @since 3.0.0 + */ + this.mouse = new Mouse(this); + + /** + * [description] + * + * @name Phaser.Input.InputManager#touch + * @type {Phaser.Input.Touch.TouchManager} + * @since 3.0.0 + */ + this.touch = new Touch(this); + + /** + * [description] + * + * @name Phaser.Input.InputManager#gamepad + * @type {Phaser.Input.Gamepad.GamepadManager} + * @since 3.0.0 + */ + this.gamepad = new Gamepad(this); + + /** + * [description] + * + * @name Phaser.Input.InputManager#activePointer + * @type {Phaser.Input.Pointer} + * @since 3.0.0 + */ + this.activePointer = new Pointer(this, 0); + + /** + * [description] + * + * @name Phaser.Input.InputManager#scale + * @type {{x:number,y:number}} + * @since 3.0.0 + */ + this.scale = { x: 1, y: 1 }; + + /** + * If the top-most Scene in the Scene List receives an input it will stop input from + * propagating any lower down the scene list, i.e. if you have a UI Scene at the top + * and click something on it, that click will not then be passed down to any other + * Scene below. Disable this to have input events passed through all Scenes, all the time. + * + * @name Phaser.Input.InputManager#globalTopOnly + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.globalTopOnly = true; + + /** + * [description] + * + * @name Phaser.Input.InputManager#ignoreEvents + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.ignoreEvents = false; + + /** + * [description] + * + * @name Phaser.Input.InputManager#bounds + * @type {Phaser.Geom.Rectangle} + * @since 3.0.0 + */ + this.bounds = new Rectangle(); + + /** + * [description] + * + * @name Phaser.Input.InputManager#_tempPoint + * @type {{x:number,y:number}} + * @private + * @since 3.0.0 + */ + this._tempPoint = { x: 0, y: 0 }; + + /** + * [description] + * + * @name Phaser.Input.InputManager#_tempHitTest + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this._tempHitTest = []; + + game.events.once('boot', this.boot, this); + }, + + /** + * The Boot handler is called by Phaser.Game when it first starts up. + * The renderer is available by now. + * + * @method Phaser.Input.InputManager#boot + * @since 3.0.0 + */ + boot: function () + { + this.canvas = this.game.canvas; + + this.updateBounds(); + + this.keyboard.boot(); + this.mouse.boot(); + this.touch.boot(); + this.gamepad.boot(); + + this.game.events.once('destroy', this.destroy, this); + }, + + /** + * [description] + * + * @method Phaser.Input.InputManager#updateBounds + * @since 3.0.0 + */ + updateBounds: function () + { + var bounds = this.bounds; + + var clientRect = this.canvas.getBoundingClientRect(); + + bounds.x = clientRect.left + window.pageXOffset - document.documentElement.clientLeft; + bounds.y = clientRect.top + window.pageYOffset - document.documentElement.clientTop; + bounds.width = clientRect.width; + bounds.height = clientRect.height; + }, + + /** + * [description] + * + * @method Phaser.Input.InputManager#resize + * @since 3.2.0 + */ + resize: function () + { + this.updateBounds(); + + // Game config size + var gw = this.game.config.width; + var gh = this.game.config.height; + + // Actual canvas size + var bw = this.bounds.width; + var bh = this.bounds.height; + + // Scale factor + this.scale.x = gw / bw; + this.scale.y = gh / bh; + }, + + /** + * [description] + * + * @method Phaser.Input.InputManager#update + * @since 3.0.0 + * + * @param {number} time - [description] + */ + update: function (time) + { + this.keyboard.update(); + this.gamepad.update(); + + this.ignoreEvents = false; + + var len = this.queue.length; + + // Currently just 1 pointer supported + var pointer = this.activePointer; + + pointer.reset(); + + if (!this.enabled || len === 0) + { + return; + } + + this.updateBounds(); + + this.scale.x = this.game.config.width / this.bounds.width; + this.scale.y = this.game.config.height / this.bounds.height; + + // Clears the queue array, and also means we don't work on array data that could potentially + // be modified during the processing phase + var queue = this.queue.splice(0, len); + + // Process the event queue, dispatching all of the events that have stored up + for (var i = 0; i < len; i++) + { + var event = queue[i]; + + // TODO: Move to CONSTs so we can do integer comparisons instead of strings. + switch (event.type) + { + case 'mousemove': + + pointer.move(event, time); + break; + + case 'mousedown': + + pointer.down(event, time); + break; + + case 'mouseup': + + pointer.up(event, time); + break; + + case 'touchmove': + + pointer.touchmove(event, time); + break; + + case 'touchstart': + + pointer.touchstart(event, time); + break; + + case 'touchend': + + pointer.touchend(event, time); + break; + + case 'pointerlockchange': + + this.events.emit('pointerlockchange', event, this.mouse.locked); + break; + } + } + }, + + /** + * Will always return an array. + * Array contains matching Interactive Objects. + * Array will be empty if no objects were matched. + * x/y = pointer x/y (un-translated) + * + * @method Phaser.Input.InputManager#hitTest + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {array} gameObjects - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @param {array} output - [description] + * + * @return {array} [description] + */ + hitTest: function (x, y, gameObjects, camera, output) + { + if (output === undefined) { output = this._tempHitTest; } + + var tempPoint = this._tempPoint; + var cameraW = camera.width; + var cameraH = camera.height; + + output.length = 0; + + if (!(x >= camera.x && y >= camera.y && x <= camera.x + cameraW && y <= camera.y + cameraH)) + { + return output; + } + + // Stores the world point inside of tempPoint + camera.getWorldPoint(x, y, tempPoint); + + var culledGameObjects = camera.cull(gameObjects); + + var point = { x: 0, y: 0 }; + + var res = this.game.config.resolution; + + for (var i = 0; i < culledGameObjects.length; i++) + { + var gameObject = culledGameObjects[i]; + + if (!gameObject.input || !gameObject.input.enabled || !gameObject.willRender()) + { + continue; + } + + var px = tempPoint.x * res + (camera.scrollX * gameObject.scrollFactorX) - camera.scrollX; + var py = tempPoint.y * res + (camera.scrollY * gameObject.scrollFactorY) - camera.scrollY; + + TransformXY(px, py, gameObject.x, gameObject.y, gameObject.rotation, gameObject.scaleX, gameObject.scaleY, point); + + if (this.pointWithinHitArea(gameObject, point.x, point.y)) + { + output.push(gameObject); + } + } + + return output; + }, + + /** + * x/y MUST be translated before being passed to this function, + * unless the gameObject is guaranteed to not be rotated or scaled in any way. + * + * @method Phaser.Input.InputManager#pointWithinHitArea + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ + pointWithinHitArea: function (gameObject, x, y) + { + var input = gameObject.input; + + // Normalize the origin + x += gameObject.displayOriginX; + y += gameObject.displayOriginY; + + if (input.hitAreaCallback(input.hitArea, x, y, gameObject)) + { + input.localX = x; + input.localY = y; + + return true; + } + else + { + return false; + } + }, + + /** + * x/y MUST be translated before being passed to this function, + * unless the gameObject is guaranteed to not be rotated or scaled in any way. + * + * @method Phaser.Input.InputManager#pointWithinInteractiveObject + * @since 3.0.0 + * + * @param {Phaser.Input.InteractiveObject} object - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ + pointWithinInteractiveObject: function (object, x, y) + { + if (!object.hitArea) + { + return false; + } + + // Normalize the origin + x += object.gameObject.displayOriginX; + y += object.gameObject.displayOriginY; + + object.localX = x; + object.localY = y; + + return object.hitAreaCallback(object.hitArea, x, y, object); + }, + + /** + * [description] + * + * @method Phaser.Input.InputManager#transformX + * @since 3.0.0 + * + * @param {number} pageX - [description] + * + * @return {number} [description] + */ + transformX: function (pageX) + { + return (pageX - this.bounds.left) * this.scale.x; + }, + + /** + * [description] + * + * @method Phaser.Input.InputManager#transformY + * @since 3.0.0 + * + * @param {number} pageY - [description] + * + * @return {number} [description] + */ + transformY: function (pageY) + { + return (pageY - this.bounds.top) * this.scale.y; + }, + + /** + * [description] + * + * @method Phaser.Input.InputManager#getOffsetX + * @since 3.0.0 + * + * @return {number} [description] + */ + getOffsetX: function () + { + return this.bounds.left; + }, + + /** + * [description] + * + * @method Phaser.Input.InputManager#getOffsetY + * @since 3.0.0 + * + * @return {number} [description] + */ + getOffsetY: function () + { + return this.bounds.top; + }, + + /** + * [description] + * + * @method Phaser.Input.InputManager#getScaleX + * @since 3.0.0 + * + * @return {number} [description] + */ + getScaleX: function () + { + return this.game.config.width / this.bounds.width; + }, + + /** + * [description] + * + * @method Phaser.Input.InputManager#getScaleY + * @since 3.0.0 + * + * @return {number} [description] + */ + getScaleY: function () + { + return this.game.config.height / this.bounds.height; + }, + + /** + * [description] + * + * @method Phaser.Input.InputManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.events.removeAllListeners(); + + this.keyboard.destroy(); + this.mouse.destroy(); + this.touch.destroy(); + this.gamepad.destroy(); + + this.activePointer.destroy(); + + this.queue = []; + + this.game = null; + } + +}); + +module.exports = InputManager; /***/ }), @@ -59916,327 +67331,1173 @@ module.exports = Decompose; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * [description] - * - * @function Phaser.Geom.Triangle.Decompose - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {array} [out] - [description] - * - * @return {array} [description] - */ -var Decompose = function (triangle, out) -{ - if (out === undefined) { out = []; } +var ModelViewProjection = { - out.push({ x: triangle.x1, y: triangle.y1 }); - out.push({ x: triangle.x2, y: triangle.y2 }); - out.push({ x: triangle.x3, y: triangle.y3 }); + modelMatrixDirty: false, + viewMatrixDirty: false, + projectionMatrixDirty: false, + modelMatrix: null, + viewMatrix: null, + projectionMatrix: null, - return out; + mvpInit: function () + { + this.modelMatrixDirty = true; + this.viewMatrixDirty = true; + this.projectionMatrixDirty = true; + + this.modelMatrix = new Float32Array([ + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + ]); + + this.viewMatrix = new Float32Array([ + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + ]); + + this.projectionMatrix = new Float32Array([ + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + ]); + + return this; + }, + + mvpUpdate: function () + { + var program = this.program; + + if (this.modelMatrixDirty) + { + this.renderer.setMatrix4(program, 'uModelMatrix', false, this.modelMatrix); + this.modelMatrixDirty = false; + } + + if (this.viewMatrixDirty) + { + this.renderer.setMatrix4(program, 'uViewMatrix', false, this.viewMatrix); + this.viewMatrixDirty = false; + } + + if (this.projectionMatrixDirty) + { + this.renderer.setMatrix4(program, 'uProjectionMatrix', false, this.projectionMatrix); + this.projectionMatrixDirty = false; + } + + return this; + }, + + modelIdentity: function () + { + var modelMatrix = this.modelMatrix; + + modelMatrix[0] = 1; + modelMatrix[1] = 0; + modelMatrix[2] = 0; + modelMatrix[3] = 0; + modelMatrix[4] = 0; + modelMatrix[5] = 1; + modelMatrix[6] = 0; + modelMatrix[7] = 0; + modelMatrix[8] = 0; + modelMatrix[9] = 0; + modelMatrix[10] = 1; + modelMatrix[11] = 0; + modelMatrix[12] = 0; + modelMatrix[13] = 0; + modelMatrix[14] = 0; + modelMatrix[15] = 1; + + this.modelMatrixDirty = true; + + return this; + }, + + modelScale: function (x, y, z) + { + var modelMatrix = this.modelMatrix; + + modelMatrix[0] = modelMatrix[0] * x; + modelMatrix[1] = modelMatrix[1] * x; + modelMatrix[2] = modelMatrix[2] * x; + modelMatrix[3] = modelMatrix[3] * x; + modelMatrix[4] = modelMatrix[4] * y; + modelMatrix[5] = modelMatrix[5] * y; + modelMatrix[6] = modelMatrix[6] * y; + modelMatrix[7] = modelMatrix[7] * y; + modelMatrix[8] = modelMatrix[8] * z; + modelMatrix[9] = modelMatrix[9] * z; + modelMatrix[10] = modelMatrix[10] * z; + modelMatrix[11] = modelMatrix[11] * z; + + this.modelMatrixDirty = true; + + return this; + }, + + modelTranslate: function (x, y, z) + { + var modelMatrix = this.modelMatrix; + + modelMatrix[12] = modelMatrix[0] * x + modelMatrix[4] * y + modelMatrix[8] * z + modelMatrix[12]; + modelMatrix[13] = modelMatrix[1] * x + modelMatrix[5] * y + modelMatrix[9] * z + modelMatrix[13]; + modelMatrix[14] = modelMatrix[2] * x + modelMatrix[6] * y + modelMatrix[10] * z + modelMatrix[14]; + modelMatrix[15] = modelMatrix[3] * x + modelMatrix[7] * y + modelMatrix[11] * z + modelMatrix[15]; + + this.modelMatrixDirty = true; + + return this; + }, + + modelRotateX: function (radians) + { + var modelMatrix = this.modelMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a10 = modelMatrix[4]; + var a11 = modelMatrix[5]; + var a12 = modelMatrix[6]; + var a13 = modelMatrix[7]; + var a20 = modelMatrix[8]; + var a21 = modelMatrix[9]; + var a22 = modelMatrix[10]; + var a23 = modelMatrix[11]; + + modelMatrix[4] = a10 * c + a20 * s; + modelMatrix[5] = a11 * c + a21 * s; + modelMatrix[6] = a12 * c + a22 * s; + modelMatrix[7] = a13 * c + a23 * s; + modelMatrix[8] = a20 * c - a10 * s; + modelMatrix[9] = a21 * c - a11 * s; + modelMatrix[10] = a22 * c - a12 * s; + modelMatrix[11] = a23 * c - a13 * s; + + this.modelMatrixDirty = true; + + return this; + }, + + modelRotateY: function (radians) + { + var modelMatrix = this.modelMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a00 = modelMatrix[0]; + var a01 = modelMatrix[1]; + var a02 = modelMatrix[2]; + var a03 = modelMatrix[3]; + var a20 = modelMatrix[8]; + var a21 = modelMatrix[9]; + var a22 = modelMatrix[10]; + var a23 = modelMatrix[11]; + + modelMatrix[0] = a00 * c - a20 * s; + modelMatrix[1] = a01 * c - a21 * s; + modelMatrix[2] = a02 * c - a22 * s; + modelMatrix[3] = a03 * c - a23 * s; + modelMatrix[8] = a00 * s + a20 * c; + modelMatrix[9] = a01 * s + a21 * c; + modelMatrix[10] = a02 * s + a22 * c; + modelMatrix[11] = a03 * s + a23 * c; + + this.modelMatrixDirty = true; + + return this; + }, + + modelRotateZ: function (radians) + { + var modelMatrix = this.modelMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a00 = modelMatrix[0]; + var a01 = modelMatrix[1]; + var a02 = modelMatrix[2]; + var a03 = modelMatrix[3]; + var a10 = modelMatrix[4]; + var a11 = modelMatrix[5]; + var a12 = modelMatrix[6]; + var a13 = modelMatrix[7]; + + modelMatrix[0] = a00 * c + a10 * s; + modelMatrix[1] = a01 * c + a11 * s; + modelMatrix[2] = a02 * c + a12 * s; + modelMatrix[3] = a03 * c + a13 * s; + modelMatrix[4] = a10 * c - a00 * s; + modelMatrix[5] = a11 * c - a01 * s; + modelMatrix[6] = a12 * c - a02 * s; + modelMatrix[7] = a13 * c - a03 * s; + + this.modelMatrixDirty = true; + + return this; + }, + + viewIdentity: function () + { + var viewMatrix = this.viewMatrix; + + viewMatrix[0] = 1; + viewMatrix[1] = 0; + viewMatrix[2] = 0; + viewMatrix[3] = 0; + viewMatrix[4] = 0; + viewMatrix[5] = 1; + viewMatrix[6] = 0; + viewMatrix[7] = 0; + viewMatrix[8] = 0; + viewMatrix[9] = 0; + viewMatrix[10] = 1; + viewMatrix[11] = 0; + viewMatrix[12] = 0; + viewMatrix[13] = 0; + viewMatrix[14] = 0; + viewMatrix[15] = 1; + + this.viewMatrixDirty = true; + + return this; + }, + + viewScale: function (x, y, z) + { + var viewMatrix = this.viewMatrix; + + viewMatrix[0] = viewMatrix[0] * x; + viewMatrix[1] = viewMatrix[1] * x; + viewMatrix[2] = viewMatrix[2] * x; + viewMatrix[3] = viewMatrix[3] * x; + viewMatrix[4] = viewMatrix[4] * y; + viewMatrix[5] = viewMatrix[5] * y; + viewMatrix[6] = viewMatrix[6] * y; + viewMatrix[7] = viewMatrix[7] * y; + viewMatrix[8] = viewMatrix[8] * z; + viewMatrix[9] = viewMatrix[9] * z; + viewMatrix[10] = viewMatrix[10] * z; + viewMatrix[11] = viewMatrix[11] * z; + + this.viewMatrixDirty = true; + + return this; + }, + + viewTranslate: function (x, y, z) + { + var viewMatrix = this.viewMatrix; + + viewMatrix[12] = viewMatrix[0] * x + viewMatrix[4] * y + viewMatrix[8] * z + viewMatrix[12]; + viewMatrix[13] = viewMatrix[1] * x + viewMatrix[5] * y + viewMatrix[9] * z + viewMatrix[13]; + viewMatrix[14] = viewMatrix[2] * x + viewMatrix[6] * y + viewMatrix[10] * z + viewMatrix[14]; + viewMatrix[15] = viewMatrix[3] * x + viewMatrix[7] * y + viewMatrix[11] * z + viewMatrix[15]; + + this.viewMatrixDirty = true; + + return this; + }, + + viewRotateX: function (radians) + { + var viewMatrix = this.viewMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a10 = viewMatrix[4]; + var a11 = viewMatrix[5]; + var a12 = viewMatrix[6]; + var a13 = viewMatrix[7]; + var a20 = viewMatrix[8]; + var a21 = viewMatrix[9]; + var a22 = viewMatrix[10]; + var a23 = viewMatrix[11]; + + viewMatrix[4] = a10 * c + a20 * s; + viewMatrix[5] = a11 * c + a21 * s; + viewMatrix[6] = a12 * c + a22 * s; + viewMatrix[7] = a13 * c + a23 * s; + viewMatrix[8] = a20 * c - a10 * s; + viewMatrix[9] = a21 * c - a11 * s; + viewMatrix[10] = a22 * c - a12 * s; + viewMatrix[11] = a23 * c - a13 * s; + + this.viewMatrixDirty = true; + + return this; + }, + + viewRotateY: function (radians) + { + var viewMatrix = this.viewMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a00 = viewMatrix[0]; + var a01 = viewMatrix[1]; + var a02 = viewMatrix[2]; + var a03 = viewMatrix[3]; + var a20 = viewMatrix[8]; + var a21 = viewMatrix[9]; + var a22 = viewMatrix[10]; + var a23 = viewMatrix[11]; + + viewMatrix[0] = a00 * c - a20 * s; + viewMatrix[1] = a01 * c - a21 * s; + viewMatrix[2] = a02 * c - a22 * s; + viewMatrix[3] = a03 * c - a23 * s; + viewMatrix[8] = a00 * s + a20 * c; + viewMatrix[9] = a01 * s + a21 * c; + viewMatrix[10] = a02 * s + a22 * c; + viewMatrix[11] = a03 * s + a23 * c; + + this.viewMatrixDirty = true; + + return this; + }, + + viewRotateZ: function (radians) + { + var viewMatrix = this.viewMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a00 = viewMatrix[0]; + var a01 = viewMatrix[1]; + var a02 = viewMatrix[2]; + var a03 = viewMatrix[3]; + var a10 = viewMatrix[4]; + var a11 = viewMatrix[5]; + var a12 = viewMatrix[6]; + var a13 = viewMatrix[7]; + + viewMatrix[0] = a00 * c + a10 * s; + viewMatrix[1] = a01 * c + a11 * s; + viewMatrix[2] = a02 * c + a12 * s; + viewMatrix[3] = a03 * c + a13 * s; + viewMatrix[4] = a10 * c - a00 * s; + viewMatrix[5] = a11 * c - a01 * s; + viewMatrix[6] = a12 * c - a02 * s; + viewMatrix[7] = a13 * c - a03 * s; + + this.viewMatrixDirty = true; + + return this; + }, + + viewLoad2D: function (matrix2D) + { + var vm = this.viewMatrix; + + vm[0] = matrix2D[0]; + vm[1] = matrix2D[1]; + vm[2] = 0.0; + vm[3] = 0.0; + vm[4] = matrix2D[2]; + vm[5] = matrix2D[3]; + vm[6] = 0.0; + vm[7] = 0.0; + vm[8] = matrix2D[4]; + vm[9] = matrix2D[5]; + vm[10] = 1.0; + vm[11] = 0.0; + vm[12] = 0.0; + vm[13] = 0.0; + vm[14] = 0.0; + vm[15] = 1.0; + + this.viewMatrixDirty = true; + + return this; + }, + + viewLoad: function (matrix) + { + var vm = this.viewMatrix; + + vm[0] = matrix[0]; + vm[1] = matrix[1]; + vm[2] = matrix[2]; + vm[3] = matrix[3]; + vm[4] = matrix[4]; + vm[5] = matrix[5]; + vm[6] = matrix[6]; + vm[7] = matrix[7]; + vm[8] = matrix[8]; + vm[9] = matrix[9]; + vm[10] = matrix[10]; + vm[11] = matrix[11]; + vm[12] = matrix[12]; + vm[13] = matrix[13]; + vm[14] = matrix[14]; + vm[15] = matrix[15]; + + this.viewMatrixDirty = true; + + return this; + }, + + projIdentity: function () + { + var projectionMatrix = this.projectionMatrix; + + projectionMatrix[0] = 1; + projectionMatrix[1] = 0; + projectionMatrix[2] = 0; + projectionMatrix[3] = 0; + projectionMatrix[4] = 0; + projectionMatrix[5] = 1; + projectionMatrix[6] = 0; + projectionMatrix[7] = 0; + projectionMatrix[8] = 0; + projectionMatrix[9] = 0; + projectionMatrix[10] = 1; + projectionMatrix[11] = 0; + projectionMatrix[12] = 0; + projectionMatrix[13] = 0; + projectionMatrix[14] = 0; + projectionMatrix[15] = 1; + + this.projectionMatrixDirty = true; + + return this; + }, + + projOrtho: function (left, right, bottom, top, near, far) + { + var projectionMatrix = this.projectionMatrix; + var leftRight = 1.0 / (left - right); + var bottomTop = 1.0 / (bottom - top); + var nearFar = 1.0 / (near - far); + + projectionMatrix[0] = -2.0 * leftRight; + projectionMatrix[1] = 0.0; + projectionMatrix[2] = 0.0; + projectionMatrix[3] = 0.0; + projectionMatrix[4] = 0.0; + projectionMatrix[5] = -2.0 * bottomTop; + projectionMatrix[6] = 0.0; + projectionMatrix[7] = 0.0; + projectionMatrix[8] = 0.0; + projectionMatrix[9] = 0.0; + projectionMatrix[10] = 2.0 * nearFar; + projectionMatrix[11] = 0.0; + projectionMatrix[12] = (left + right) * leftRight; + projectionMatrix[13] = (top + bottom) * bottomTop; + projectionMatrix[14] = (far + near) * nearFar; + projectionMatrix[15] = 1.0; + + this.projectionMatrixDirty = true; + return this; + }, + + projPersp: function (fovy, aspectRatio, near, far) + { + var projectionMatrix = this.projectionMatrix; + var fov = 1.0 / Math.tan(fovy / 2.0); + var nearFar = 1.0 / (near - far); + + projectionMatrix[0] = fov / aspectRatio; + projectionMatrix[1] = 0.0; + projectionMatrix[2] = 0.0; + projectionMatrix[3] = 0.0; + projectionMatrix[4] = 0.0; + projectionMatrix[5] = fov; + projectionMatrix[6] = 0.0; + projectionMatrix[7] = 0.0; + projectionMatrix[8] = 0.0; + projectionMatrix[9] = 0.0; + projectionMatrix[10] = (far + near) * nearFar; + projectionMatrix[11] = -1.0; + projectionMatrix[12] = 0.0; + projectionMatrix[13] = 0.0; + projectionMatrix[14] = (2.0 * far * near) * nearFar; + projectionMatrix[15] = 0.0; + + this.projectionMatrixDirty = true; + return this; + } }; -module.exports = Decompose; +module.exports = ModelViewProjection; /***/ }), /* 301 */ /***/ (function(module, exports, __webpack_require__) { +"use strict"; /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var GetPoint = __webpack_require__(302); -var GetPoints = __webpack_require__(109); -var Random = __webpack_require__(111); +// 2.1.1 (Mar 17, 2016) -/** - * @classdesc - * Defines a Line segment, a part of a line between two endpoints. - * - * @class Line - * @memberOf Phaser.Geom - * @constructor - * @since 3.0.0 - * - * @param {number} [x1] - [description] - * @param {number} [y1] - [description] - * @param {number} [x2] - [description] - * @param {number} [y2] - [description] +/* +ISC License + +Copyright (c) 2016, Mapbox + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. */ -var Line = new Class({ - initialize: - function Line (x1, y1, x2, y2) - { - if (x1 === undefined) { x1 = 0; } - if (y1 === undefined) { y1 = 0; } - if (x2 === undefined) { x2 = 0; } - if (y2 === undefined) { y2 = 0; } - /** - * [description] - * - * @name Phaser.Geom.Line#x1 - * @type {number} - * @since 3.0.0 - */ - this.x1 = x1; +module.exports = earcut; - /** - * [description] - * - * @name Phaser.Geom.Line#y1 - * @type {number} - * @since 3.0.0 - */ - this.y1 = y1; +/* +vertices is a flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...]. +holes is an array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). +dimensions is the number of coordinates per vertice in the input array (2 by default). +Each group of three vertice indices in the resulting array forms a triangle. + */ - /** - * [description] - * - * @name Phaser.Geom.Line#x2 - * @type {number} - * @since 3.0.0 - */ - this.x2 = x2; +function earcut(data, holeIndices, dim) { - /** - * [description] - * - * @name Phaser.Geom.Line#y2 - * @type {number} - * @since 3.0.0 - */ - this.y2 = y2; - }, + dim = dim || 2; - /** - * [description] - * - * @method Phaser.Geom.Line#getPoint - * @since 3.0.0 - * - * @param {[type]} position - [description] - * @param {[type]} output - [description] - * - * @return {Phaser.Geom.Point|object} A Point, or point-like object, containing the coordinates of the point around the ellipse. - */ - getPoint: function (position, output) - { - return GetPoint(this, position, output); - }, + var hasHoles = holeIndices && holeIndices.length, + outerLen = hasHoles ? holeIndices[0] * dim : data.length, + outerNode = linkedList(data, 0, outerLen, dim, true), + triangles = []; - /** - * [description] - * - * @method Phaser.Geom.Line#getPoints - * @since 3.0.0 - * - * @param {[type]} quantity - [description] - * @param {[type]} stepRate - [description] - * @param {[type]} output - [description] - * - * @return {[type]} [description] - */ - getPoints: function (quantity, stepRate, output) - { - return GetPoints(this, quantity, stepRate, output); - }, + if (!outerNode) return triangles; - /** - * [description] - * - * @method Phaser.Geom.Line#getRandomPoint - * @since 3.0.0 - * - * @param {[type]} point - [description] - * - * @return {[type]} [description] - */ - getRandomPoint: function (point) - { - return Random(this, point); - }, + var minX, minY, maxX, maxY, x, y, size; - /** - * [description] - * - * @method Phaser.Geom.Line#setTo - * @since 3.0.0 - * - * @param {[type]} x1 - [description] - * @param {[type]} y1 - [description] - * @param {[type]} x2 - [description] - * @param {[type]} y2 - [description] - * - * @return {Phaser.Geom.Line} This Line object. - */ - setTo: function (x1, y1, x2, y2) - { - if (x1 === undefined) { x1 = 0; } - if (y1 === undefined) { y1 = 0; } - if (x2 === undefined) { x2 = 0; } - if (y2 === undefined) { y2 = 0; } + if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim); - this.x1 = x1; - this.y1 = y1; + // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox + if (data.length > 80 * dim) { + minX = maxX = data[0]; + minY = maxY = data[1]; - this.x2 = x2; - this.y2 = y2; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Geom.Line#getPointA - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getPointA: function () - { - return { x: this.x1, y: this.y1 }; - }, - - /** - * [description] - * - * @method Phaser.Geom.Line#getPointB - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getPointB: function () - { - return { x: this.x2, y: this.y2 }; - }, - - /** - * The left position of the Line. - * - * @name Phaser.Geom.Line#left - * @type {number} - * @since 3.0.0 - */ - left: { - - get: function () - { - return Math.min(this.x1, this.x2); - }, - - set: function (value) - { - if (this.x1 <= this.x2) - { - this.x1 = value; - } - else - { - this.x2 = value; - } - } - - }, - - /** - * The right position of the Line. - * - * @name Phaser.Geom.Line#right - * @type {number} - * @since 3.0.0 - */ - right: { - - get: function () - { - return Math.max(this.x1, this.x2); - }, - - set: function (value) - { - if (this.x1 > this.x2) - { - this.x1 = value; - } - else - { - this.x2 = value; - } - } - - }, - - /** - * The top position of the Line. - * - * @name Phaser.Geom.Line#top - * @type {number} - * @since 3.0.0 - */ - top: { - - get: function () - { - return Math.min(this.y1, this.y2); - }, - - set: function (value) - { - if (this.y1 <= this.y2) - { - this.y1 = value; - } - else - { - this.y2 = value; - } - } - - }, - - /** - * The bottom position of the Line. - * - * @name Phaser.Geom.Line#bottom - * @type {number} - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return Math.max(this.y1, this.y2); - }, - - set: function (value) - { - if (this.y1 > this.y2) - { - this.y1 = value; - } - else - { - this.y2 = value; - } + for (var i = dim; i < outerLen; i += dim) { + x = data[i]; + y = data[i + 1]; + if (x < minX) minX = x; + if (y < minY) minY = y; + if (x > maxX) maxX = x; + if (y > maxY) maxY = y; } + // minX, minY and size are later used to transform coords into integers for z-order calculation + size = Math.max(maxX - minX, maxY - minY); } -}); + earcutLinked(outerNode, triangles, dim, minX, minY, size); -module.exports = Line; + return triangles; +} +// create a circular doubly linked list from polygon points in the specified winding order +function linkedList(data, start, end, dim, clockwise) { + var i, last; + + if (clockwise === (signedArea(data, start, end, dim) > 0)) { + for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last); + } else { + for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last); + } + + if (last && equals(last, last.next)) { + removeNode(last); + last = last.next; + } + + return last; +} + +// eliminate colinear or duplicate points +function filterPoints(start, end) { + if (!start) return start; + if (!end) end = start; + + var p = start, + again; + do { + again = false; + + if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) { + removeNode(p); + p = end = p.prev; + if (p === p.next) return null; + again = true; + + } else { + p = p.next; + } + } while (again || p !== end); + + return end; +} + +// main ear slicing loop which triangulates a polygon (given as a linked list) +function earcutLinked(ear, triangles, dim, minX, minY, size, pass) { + if (!ear) return; + + // interlink polygon nodes in z-order + if (!pass && size) indexCurve(ear, minX, minY, size); + + var stop = ear, + prev, next; + + // iterate through ears, slicing them one by one + while (ear.prev !== ear.next) { + prev = ear.prev; + next = ear.next; + + if (size ? isEarHashed(ear, minX, minY, size) : isEar(ear)) { + // cut off the triangle + triangles.push(prev.i / dim); + triangles.push(ear.i / dim); + triangles.push(next.i / dim); + + removeNode(ear); + + // skipping the next vertice leads to less sliver triangles + ear = next.next; + stop = next.next; + + continue; + } + + ear = next; + + // if we looped through the whole remaining polygon and can't find any more ears + if (ear === stop) { + // try filtering points and slicing again + if (!pass) { + earcutLinked(filterPoints(ear), triangles, dim, minX, minY, size, 1); + + // if this didn't work, try curing all small self-intersections locally + } else if (pass === 1) { + ear = cureLocalIntersections(ear, triangles, dim); + earcutLinked(ear, triangles, dim, minX, minY, size, 2); + + // as a last resort, try splitting the remaining polygon into two + } else if (pass === 2) { + splitEarcut(ear, triangles, dim, minX, minY, size); + } + + break; + } + } +} + +// check whether a polygon node forms a valid ear with adjacent nodes +function isEar(ear) { + var a = ear.prev, + b = ear, + c = ear.next; + + if (area(a, b, c) >= 0) return false; // reflex, can't be an ear + + // now make sure we don't have other points inside the potential ear + var p = ear.next.next; + + while (p !== ear.prev) { + if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && + area(p.prev, p, p.next) >= 0) return false; + p = p.next; + } + + return true; +} + +function isEarHashed(ear, minX, minY, size) { + var a = ear.prev, + b = ear, + c = ear.next; + + if (area(a, b, c) >= 0) return false; // reflex, can't be an ear + + // triangle bbox; min & max are calculated like this for speed + var minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : (b.x < c.x ? b.x : c.x), + minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : (b.y < c.y ? b.y : c.y), + maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : (b.x > c.x ? b.x : c.x), + maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : (b.y > c.y ? b.y : c.y); + + // z-order range for the current triangle bbox; + var minZ = zOrder(minTX, minTY, minX, minY, size), + maxZ = zOrder(maxTX, maxTY, minX, minY, size); + + // first look for points inside the triangle in increasing z-order + var p = ear.nextZ; + + while (p && p.z <= maxZ) { + if (p !== ear.prev && p !== ear.next && + pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && + area(p.prev, p, p.next) >= 0) return false; + p = p.nextZ; + } + + // then look for points in decreasing z-order + p = ear.prevZ; + + while (p && p.z >= minZ) { + if (p !== ear.prev && p !== ear.next && + pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && + area(p.prev, p, p.next) >= 0) return false; + p = p.prevZ; + } + + return true; +} + +// go through all polygon nodes and cure small local self-intersections +function cureLocalIntersections(start, triangles, dim) { + var p = start; + do { + var a = p.prev, + b = p.next.next; + + if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) { + + triangles.push(a.i / dim); + triangles.push(p.i / dim); + triangles.push(b.i / dim); + + // remove two nodes involved + removeNode(p); + removeNode(p.next); + + p = start = b; + } + p = p.next; + } while (p !== start); + + return p; +} + +// try splitting polygon into two and triangulate them independently +function splitEarcut(start, triangles, dim, minX, minY, size) { + // look for a valid diagonal that divides the polygon into two + var a = start; + do { + var b = a.next.next; + while (b !== a.prev) { + if (a.i !== b.i && isValidDiagonal(a, b)) { + // split the polygon in two by the diagonal + var c = splitPolygon(a, b); + + // filter colinear points around the cuts + a = filterPoints(a, a.next); + c = filterPoints(c, c.next); + + // run earcut on each half + earcutLinked(a, triangles, dim, minX, minY, size); + earcutLinked(c, triangles, dim, minX, minY, size); + return; + } + b = b.next; + } + a = a.next; + } while (a !== start); +} + +// link every hole into the outer loop, producing a single-ring polygon without holes +function eliminateHoles(data, holeIndices, outerNode, dim) { + var queue = [], + i, len, start, end, list; + + for (i = 0, len = holeIndices.length; i < len; i++) { + start = holeIndices[i] * dim; + end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; + list = linkedList(data, start, end, dim, false); + if (list === list.next) list.steiner = true; + queue.push(getLeftmost(list)); + } + + queue.sort(compareX); + + // process holes from left to right + for (i = 0; i < queue.length; i++) { + eliminateHole(queue[i], outerNode); + outerNode = filterPoints(outerNode, outerNode.next); + } + + return outerNode; +} + +function compareX(a, b) { + return a.x - b.x; +} + +// find a bridge between vertices that connects hole with an outer ring and and link it +function eliminateHole(hole, outerNode) { + outerNode = findHoleBridge(hole, outerNode); + if (outerNode) { + var b = splitPolygon(outerNode, hole); + filterPoints(b, b.next); + } +} + +// David Eberly's algorithm for finding a bridge between hole and outer polygon +function findHoleBridge(hole, outerNode) { + var p = outerNode, + hx = hole.x, + hy = hole.y, + qx = -Infinity, + m; + + // find a segment intersected by a ray from the hole's leftmost point to the left; + // segment's endpoint with lesser x will be potential connection point + do { + if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) { + var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y); + if (x <= hx && x > qx) { + qx = x; + if (x === hx) { + if (hy === p.y) return p; + if (hy === p.next.y) return p.next; + } + m = p.x < p.next.x ? p : p.next; + } + } + p = p.next; + } while (p !== outerNode); + + if (!m) return null; + + if (hx === qx) return m.prev; // hole touches outer segment; pick lower endpoint + + // look for points inside the triangle of hole point, segment intersection and endpoint; + // if there are no points found, we have a valid connection; + // otherwise choose the point of the minimum angle with the ray as connection point + + var stop = m, + mx = m.x, + my = m.y, + tanMin = Infinity, + tan; + + p = m.next; + + while (p !== stop) { + if (hx >= p.x && p.x >= mx && hx !== p.x && + pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) { + + tan = Math.abs(hy - p.y) / (hx - p.x); // tangential + + if ((tan < tanMin || (tan === tanMin && p.x > m.x)) && locallyInside(p, hole)) { + m = p; + tanMin = tan; + } + } + + p = p.next; + } + + return m; +} + +// interlink polygon nodes in z-order +function indexCurve(start, minX, minY, size) { + var p = start; + do { + if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, size); + p.prevZ = p.prev; + p.nextZ = p.next; + p = p.next; + } while (p !== start); + + p.prevZ.nextZ = null; + p.prevZ = null; + + sortLinked(p); +} + +// Simon Tatham's linked list merge sort algorithm +// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html +function sortLinked(list) { + var i, p, q, e, tail, numMerges, pSize, qSize, + inSize = 1; + + do { + p = list; + list = null; + tail = null; + numMerges = 0; + + while (p) { + numMerges++; + q = p; + pSize = 0; + for (i = 0; i < inSize; i++) { + pSize++; + q = q.nextZ; + if (!q) break; + } + qSize = inSize; + + while (pSize > 0 || (qSize > 0 && q)) { + + if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) { + e = p; + p = p.nextZ; + pSize--; + } else { + e = q; + q = q.nextZ; + qSize--; + } + + if (tail) tail.nextZ = e; + else list = e; + + e.prevZ = tail; + tail = e; + } + + p = q; + } + + tail.nextZ = null; + inSize *= 2; + + } while (numMerges > 1); + + return list; +} + +// z-order of a point given coords and size of the data bounding box +function zOrder(x, y, minX, minY, size) { + // coords are transformed into non-negative 15-bit integer range + x = 32767 * (x - minX) / size; + y = 32767 * (y - minY) / size; + + x = (x | (x << 8)) & 0x00FF00FF; + x = (x | (x << 4)) & 0x0F0F0F0F; + x = (x | (x << 2)) & 0x33333333; + x = (x | (x << 1)) & 0x55555555; + + y = (y | (y << 8)) & 0x00FF00FF; + y = (y | (y << 4)) & 0x0F0F0F0F; + y = (y | (y << 2)) & 0x33333333; + y = (y | (y << 1)) & 0x55555555; + + return x | (y << 1); +} + +// find the leftmost node of a polygon ring +function getLeftmost(start) { + var p = start, + leftmost = start; + do { + if (p.x < leftmost.x) leftmost = p; + p = p.next; + } while (p !== start); + + return leftmost; +} + +// check if a point lies within a convex triangle +function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) { + return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && + (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && + (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0; +} + +// check if a diagonal between two polygon nodes is valid (lies in polygon interior) +function isValidDiagonal(a, b) { + return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && + locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b); +} + +// signed area of a triangle +function area(p, q, r) { + return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); +} + +// check if two points are equal +function equals(p1, p2) { + return p1.x === p2.x && p1.y === p2.y; +} + +// check if two segments intersect +function intersects(p1, q1, p2, q2) { + if ((equals(p1, q1) && equals(p2, q2)) || + (equals(p1, q2) && equals(p2, q1))) return true; + return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 && + area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0; +} + +// check if a polygon diagonal intersects any polygon segments +function intersectsPolygon(a, b) { + var p = a; + do { + if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && + intersects(p, p.next, a, b)) return true; + p = p.next; + } while (p !== a); + + return false; +} + +// check if a polygon diagonal is locally inside the polygon +function locallyInside(a, b) { + return area(a.prev, a, a.next) < 0 ? + area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : + area(a, b, a.prev) < 0 || area(a, a.next, b) < 0; +} + +// check if the middle point of a polygon diagonal is inside the polygon +function middleInside(a, b) { + var p = a, + inside = false, + px = (a.x + b.x) / 2, + py = (a.y + b.y) / 2; + do { + if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y && + (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)) + inside = !inside; + p = p.next; + } while (p !== a); + + return inside; +} + +// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two; +// if one belongs to the outer ring and another to a hole, it merges it into a single ring +function splitPolygon(a, b) { + var a2 = new Node(a.i, a.x, a.y), + b2 = new Node(b.i, b.x, b.y), + an = a.next, + bp = b.prev; + + a.next = b; + b.prev = a; + + a2.next = an; + an.prev = a2; + + b2.next = a2; + a2.prev = b2; + + bp.next = b2; + b2.prev = bp; + + return b2; +} + +// create a node and optionally link it with previous one (in a circular doubly linked list) +function insertNode(i, x, y, last) { + var p = new Node(i, x, y); + + if (!last) { + p.prev = p; + p.next = p; + + } else { + p.next = last.next; + p.prev = last; + last.next.prev = p; + last.next = p; + } + return p; +} + +function removeNode(p) { + p.next.prev = p.prev; + p.prev.next = p.next; + + if (p.prevZ) p.prevZ.nextZ = p.nextZ; + if (p.nextZ) p.nextZ.prevZ = p.prevZ; +} + +function Node(i, x, y) { + // vertice index in coordinates array + this.i = i; + + // vertex coordinates + this.x = x; + this.y = y; + + // previous and next vertice nodes in a polygon ring + this.prev = null; + this.next = null; + + // z-order curve value + this.z = null; + + // previous and next nodes in z-order + this.prevZ = null; + this.nextZ = null; + + // indicates whether this is a steiner point + this.steiner = false; +} + +// return a percentage difference between the polygon area and its triangulation area; +// used to verify correctness of triangulation +earcut.deviation = function (data, holeIndices, dim, triangles) { + var hasHoles = holeIndices && holeIndices.length; + var outerLen = hasHoles ? holeIndices[0] * dim : data.length; + + var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim)); + if (hasHoles) { + for (var i = 0, len = holeIndices.length; i < len; i++) { + var start = holeIndices[i] * dim; + var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; + polygonArea -= Math.abs(signedArea(data, start, end, dim)); + } + } + + var trianglesArea = 0; + for (i = 0; i < triangles.length; i += 3) { + var a = triangles[i] * dim; + var b = triangles[i + 1] * dim; + var c = triangles[i + 2] * dim; + trianglesArea += Math.abs( + (data[a] - data[c]) * (data[b + 1] - data[a + 1]) - + (data[a] - data[b]) * (data[c + 1] - data[a + 1])); + } + + return polygonArea === 0 && trianglesArea === 0 ? 0 : + Math.abs((trianglesArea - polygonArea) / polygonArea); +}; + +function signedArea(data, start, end, dim) { + var sum = 0; + for (var i = start, j = end - dim; i < end; i += dim) { + sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]); + j = i; + } + return sum; +} + +// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts +earcut.flatten = function (data) { + var dim = data[0][0].length, + result = {vertices: [], holes: [], dimensions: dim}, + holeIndex = 0; + + for (var i = 0; i < data.length; i++) { + for (var j = 0; j < data[i].length; j++) { + for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]); + } + if (i > 0) { + holeIndex += data[i - 1].length; + result.holes.push(holeIndex); + } + } + return result; +}; /***/ }), /* 302 */ @@ -60248,7 +68509,7767 @@ module.exports = Line; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); +var CanvasPool = __webpack_require__(23); + +/** + * Determines the canvas features of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.canvasFeatures` from within any Scene. + * + * @name Phaser.Device.CanvasFeatures + * @since 3.0.0 + * + * @type {object} + * @property {boolean} supportInverseAlpha - Set to true if the browser supports inversed alpha. + * @property {boolean} supportNewBlendModes - Set to true if the browser supports new canvas blend modes. + */ +var CanvasFeatures = { + + supportInverseAlpha: false, + supportNewBlendModes: false + +}; + +function checkBlendMode () +{ + var pngHead = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/'; + var pngEnd = 'AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg=='; + + var magenta = new Image(); + + magenta.onload = function () + { + var yellow = new Image(); + + yellow.onload = function () + { + var canvas = CanvasPool.create(yellow, 6, 1); + var context = canvas.getContext('2d'); + + context.globalCompositeOperation = 'multiply'; + + context.drawImage(magenta, 0, 0); + context.drawImage(yellow, 2, 0); + + if (!context.getImageData(2, 0, 1, 1)) + { + return false; + } + + var data = context.getImageData(2, 0, 1, 1).data; + + CanvasPool.remove(yellow); + + CanvasFeatures.supportNewBlendModes = (data[0] === 255 && data[1] === 0 && data[2] === 0); + }; + + yellow.src = pngHead + '/wCKxvRF' + pngEnd; + }; + + magenta.src = pngHead + 'AP804Oa6' + pngEnd; + + return false; +} + +function checkInverseAlpha () +{ + var canvas = CanvasPool.create(this, 2, 1); + var context = canvas.getContext('2d'); + + context.fillStyle = 'rgba(10, 20, 30, 0.5)'; + + // Draw a single pixel + context.fillRect(0, 0, 1, 1); + + // Get the color values + var s1 = context.getImageData(0, 0, 1, 1); + + if (s1 === null) + { + return false; + } + + // Plot them to x2 + context.putImageData(s1, 1, 0); + + // Get those values + var s2 = context.getImageData(1, 0, 1, 1); + + // Compare and return + return (s2.data[0] === s1.data[0] && s2.data[1] === s1.data[1] && s2.data[2] === s1.data[2] && s2.data[3] === s1.data[3]); +} + +function init () +{ + if (document !== undefined) + { + CanvasFeatures.supportNewBlendModes = checkBlendMode(); + CanvasFeatures.supportInverseAlpha = checkInverseAlpha(); + } + + return CanvasFeatures; +} + +module.exports = init(); + + +/***/ }), +/* 303 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Plugins + */ +var Plugins = { + + /** + * These are the Global Managers that are created by the Phaser.Game instance. + * They are referenced from Scene.Systems so that plugins can use them. + * + * @name Phaser.Plugins.Global + * @type {array} + * @since 3.0.0 + */ + Global: [ + + 'anims', + 'cache', + 'registry', + 'sound', + 'textures' + + ], + + /** + * These are the core plugins that are installed into every Scene.Systems instance, no matter what. + * They are optionally exposed in the Scene as well (see the InjectionMap for details) + * + * They are created in the order in which they appear in this array and EventEmitter is always first. + * + * @name Phaser.Plugins.CoreScene + * @type {array} + * @since 3.0.0 + */ + CoreScene: [ + + 'EventEmitter', + + 'CameraManager', + 'GameObjectCreator', + 'GameObjectFactory', + 'ScenePlugin', + 'DisplayList', + 'UpdateList' + + ], + + /** + * These plugins are created in Scene.Systems in addition to the CoreScenePlugins. + * + * You can elect not to have these plugins by either creating a DefaultPlugins object as part + * of the Game Config, by creating a Plugins object as part of a Scene Config, or by modifying this array + * and building your own bundle. + * + * They are optionally exposed in the Scene as well (see the InjectionMap for details) + * + * They are always created in the order in which they appear in the array. + * + * @name Phaser.Plugins.DefaultScene + * @type {array} + * @since 3.0.0 + */ + DefaultScene: [ + + 'CameraManager3D', + 'Clock', + 'DataManagerPlugin', + 'InputPlugin', + 'Loader', + 'TweenManager', + 'LightsPlugin' + + ] + +}; + +/* + * "Sometimes, the elegant implementation is just a function. + * Not a method. Not a class. Not a framework. Just a function." + * -- John Carmack + */ + +module.exports = Plugins; + + +/***/ }), +/* 304 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var NOOP = __webpack_require__(3); + +/** + * @classdesc + * Abstracts away the use of RAF or setTimeOut for the core game update loop. + * This is invoked automatically by the Phaser.Game instance. + * + * @class RequestAnimationFrame + * @memberOf Phaser.DOM + * @constructor + * @since 3.0.0 + */ +var RequestAnimationFrame = new Class({ + + initialize: + + function RequestAnimationFrame () + { + /** + * True if RequestAnimationFrame is running, otherwise false. + * + * @name Phaser.DOM.RequestAnimationFrame#isRunning + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isRunning = false; + + /** + * The callback to be invoked each step. + * + * @name Phaser.DOM.RequestAnimationFrame#callback + * @type {FrameRequestCallback} + * @since 3.0.0 + */ + this.callback = NOOP; + + /** + * The most recent timestamp. Either a DOMHighResTimeStamp under RAF or `Date.now` under SetTimeout. + * + * @name Phaser.DOM.RequestAnimationFrame#tick + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.tick = 0; + + /** + * True if the step is using setTimeout instead of RAF. + * + * @name Phaser.DOM.RequestAnimationFrame#isSetTimeOut + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isSetTimeOut = false; + + /** + * The setTimeout or RAF callback ID used when canceling them. + * + * @name Phaser.DOM.RequestAnimationFrame#timeOutID + * @type {?number} + * @default null + * @since 3.0.0 + */ + this.timeOutID = null; + + /** + * The previous time the step was called. + * + * @name Phaser.DOM.RequestAnimationFrame#lastTime + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.lastTime = 0; + + var _this = this; + + /** + * The RAF step function. + * Updates the local tick value, invokes the callback and schedules another call to requestAnimationFrame. + * + * @name Phaser.DOM.RequestAnimationFrame#step + * @type {FrameRequestCallback} + * @since 3.0.0 + */ + this.step = function step (timestamp) + { + // DOMHighResTimeStamp + _this.lastTime = _this.tick; + + _this.tick = timestamp; + + _this.callback(timestamp); + + _this.timeOutID = window.requestAnimationFrame(step); + }; + + /** + * The SetTimeout step function. + * Updates the local tick value, invokes the callback and schedules another call to setTimeout. + * + * @name Phaser.DOM.RequestAnimationFrame#stepTimeout + * @type {function} + * @since 3.0.0 + */ + this.stepTimeout = function stepTimeout () + { + var d = Date.now(); + + var delay = Math.max(16 + _this.lastTime - d, 0); + + _this.lastTime = _this.tick; + + _this.tick = d; + + _this.callback(d); + + _this.timeOutID = window.setTimeout(stepTimeout, delay); + }; + }, + + /** + * Starts the requestAnimationFrame or setTimeout process running. + * + * @method Phaser.DOM.RequestAnimationFrame#start + * @since 3.0.0 + * + * @param {FrameRequestCallback} callback - The callback to invoke each step. + * @param {boolean} forceSetTimeOut - Should it use SetTimeout, even if RAF is available? + */ + start: function (callback, forceSetTimeOut) + { + if (this.isRunning) + { + return; + } + + this.callback = callback; + + this.isSetTimeOut = forceSetTimeOut; + + this.isRunning = true; + + this.timeOutID = (forceSetTimeOut) ? window.setTimeout(this.stepTimeout, 0) : window.requestAnimationFrame(this.step); + }, + + /** + * Stops the requestAnimationFrame or setTimeout from running. + * + * @method Phaser.DOM.RequestAnimationFrame#stop + * @since 3.0.0 + */ + stop: function () + { + this.isRunning = false; + + if (this.isSetTimeOut) + { + clearTimeout(this.timeOutID); + } + else + { + window.cancelAnimationFrame(this.timeOutID); + } + }, + + /** + * Stops the step from running and clears the callback reference. + * + * @method Phaser.DOM.RequestAnimationFrame#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.stop(); + + this.callback = NOOP; + } + +}); + +module.exports = RequestAnimationFrame; + + +/***/ }), +/* 305 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Attempts to remove the element from its parentNode in the DOM. + * + * @function Phaser.DOM.RemoveFromDOM + * @since 3.0.0 + * + * @param {HTMLElement} element - The DOM element to remove from its parent node. + */ +var RemoveFromDOM = function (element) +{ + if (element.parentNode) + { + element.parentNode.removeChild(element); + } +}; + +module.exports = RemoveFromDOM; + + +/***/ }), +/* 306 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes the given data string and parses it as XML. + * First tries to use the window.DOMParser and reverts to the Microsoft.XMLDOM if that fails. + * The parsed XML object is returned, or `null` if there was an error while parsing the data. + * + * @function Phaser.DOM.ParseXML + * @since 3.0.0 + * + * @param {string} data - The XML source stored in a string. + * + * @return {?(DOMParser|ActiveXObject)} The parsed XML data, or `null` if the data could not be parsed. + */ +var ParseXML = function (data) +{ + var xml = ''; + + try + { + if (window['DOMParser']) + { + var domparser = new DOMParser(); + xml = domparser.parseFromString(data, 'text/xml'); + } + else + { + xml = new ActiveXObject('Microsoft.XMLDOM'); + xml.loadXML(data); + } + } + catch (e) + { + xml = null; + } + + if (!xml || !xml.documentElement || xml.getElementsByTagName('parsererror').length) + { + return null; + } + else + { + return xml; + } +}; + +module.exports = ParseXML; + + +/***/ }), +/* 307 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var OS = __webpack_require__(76); + +/** + * @callback ContentLoadedCallback + */ + +/** + * Inspects the readyState of the document. If the document is already complete then it invokes the given callback. + * If not complete it sets up several event listeners such as `deviceready`, and once those fire, it invokes the callback. + * Called automatically by the Phaser.Game instance. Should not usually be accessed directly. + * + * @function Phaser.DOM.DOMContentLoaded + * @since 3.0.0 + * + * @param {ContentLoadedCallback} callback - The callback to be invoked when the device is ready and the DOM content is loaded. + */ +var DOMContentLoaded = function (callback) +{ + if (document.readyState === 'complete' || document.readyState === 'interactive') + { + callback(); + + return; + } + + var check = function () + { + document.removeEventListener('deviceready', check, true); + document.removeEventListener('DOMContentLoaded', check, true); + window.removeEventListener('load', check, true); + + callback(); + }; + + if (!document.body) + { + window.setTimeout(check, 20); + } + else if (OS.cordova && !OS.cocoonJS) + { + // Ref. http://docs.phonegap.com/en/3.5.0/cordova_events_events.md.html#deviceready + document.addEventListener('deviceready', check, false); + } + else + { + document.addEventListener('DOMContentLoaded', check, true); + window.addEventListener('load', check, true); + } +}; + +module.exports = DOMContentLoaded; + + +/***/ }), +/* 308 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Between + * @since 3.0.0 + * + * @param {integer} min - [description] + * @param {integer} max - [description] + * + * @return {integer} [description] + */ +var Between = function (min, max) +{ + return Math.floor(Math.random() * (max - min + 1) + min); +}; + +module.exports = Between; + + +/***/ }), +/* 309 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetColor = __webpack_require__(155); + +/** + * Converts an HSV (hue, saturation and value) color value to RGB. + * Conversion formula from http://en.wikipedia.org/wiki/HSL_color_space. + * Assumes HSV values are contained in the set [0, 1]. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * + * @function Phaser.Display.Color.HSVToRGB + * @since 3.0.0 + * + * @param {number} h - The hue, in the range 0 - 1. + * @param {number} s - The saturation, in the range 0 - 1. + * @param {number} v - The value, in the range 0 - 1. + * + * @return {ColorObject} An object with the red, green and blue values set in the r, g and b properties. + */ +var HSVToRGB = function (h, s, v) +{ + if (s === undefined) { s = 1; } + if (v === undefined) { v = 1; } + + var i = Math.floor(h * 6); + var f = h * 6 - i; + + var p = Math.floor((v * (1 - s)) * 255); + var q = Math.floor((v * (1 - f * s)) * 255); + var t = Math.floor((v * (1 - (1 - f) * s)) * 255); + + v = Math.floor(v *= 255); + + var output = { r: v, g: v, b: v, color: 0 }; + + var r = i % 6; + + if (r === 0) + { + output.g = t; + output.b = p; + } + else if (r === 1) + { + output.r = q; + output.b = p; + } + else if (r === 2) + { + output.r = p; + output.b = t; + } + else if (r === 3) + { + output.r = p; + output.g = q; + } + else if (r === 4) + { + output.r = t; + output.g = p; + } + else if (r === 5) + { + output.g = p; + output.b = q; + } + + output.color = GetColor(output.r, output.g, output.b); + + return output; +}; + +module.exports = HSVToRGB; + + +/***/ }), +/* 310 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(module) {/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts a hue to an RGB color. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * + * @function Phaser.Display.Color.HueToComponent + * @since 3.0.0 + * + * @param {number} p + * @param {number} q + * @param {number} t + * + * @return {number} The combined color value. + */ +var HueToComponent = function (p, q, t) +{ + if (t < 0) + { + t += 1; + } + + if (t > 1) + { + t -= 1; + } + + if (t < 1 / 6) + { + return p + (q - p) * 6 * t; + } + + if (t < 1 / 2) + { + return q; + } + + if (t < 2 / 3) + { + return p + (q - p) * (2 / 3 - t) * 6; + } + + return p; +}; + +module.export = HueToComponent; + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(831)(module))) + +/***/ }), +/* 311 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns a string containing a hex representation of the given color component. + * + * @function Phaser.Display.Color.ComponentToHex + * @since 3.0.0 + * + * @param {integer} color - The color channel to get the hex value for, must be a value between 0 and 255. + * + * @return {string} A string of length 2 characters, i.e. 255 = ff, 100 = 64. + */ +var ComponentToHex = function (color) +{ + var hex = color.toString(16); + + return (hex.length === 1) ? '0' + hex : hex; +}; + +module.exports = ComponentToHex; + + +/***/ }), +/* 312 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} InputColorObject + * + * @property {number} [r] - The red color value in the range 0 to 255. + * @property {number} [g] - The green color value in the range 0 to 255. + * @property {number} [b] - The blue color value in the range 0 to 255. + * @property {number} [a] - The alpha color value in the range 0 to 255. + */ + +/** + * @typedef {Object} ColorObject + * @property {number} r - The red color value in the range 0 to 255. + * @property {number} g - The green color value in the range 0 to 255. + * @property {number} b - The blue color value in the range 0 to 255. + * @property {number} a - The alpha color value in the range 0 to 255. + */ + +/** + * @namespace Phaser.Display.Color + */ + +var Color = __webpack_require__(41); + +Color.ColorToRGBA = __webpack_require__(833); +Color.ComponentToHex = __webpack_require__(311); +Color.GetColor = __webpack_require__(155); +Color.GetColor32 = __webpack_require__(335); +Color.HexStringToColor = __webpack_require__(336); +Color.HSLToColor = __webpack_require__(832); +Color.HSVColorWheel = __webpack_require__(830); +Color.HSVToRGB = __webpack_require__(309); +Color.HueToComponent = __webpack_require__(310); +Color.IntegerToColor = __webpack_require__(334); +Color.IntegerToRGB = __webpack_require__(333); +Color.Interpolate = __webpack_require__(829); +Color.ObjectToColor = __webpack_require__(332); +Color.RandomRGB = __webpack_require__(828); +Color.RGBStringToColor = __webpack_require__(331); +Color.RGBToHSV = __webpack_require__(827); +Color.RGBToString = __webpack_require__(826); +Color.ValueToColor = __webpack_require__(156); + +module.exports = Color; + + +/***/ }), +/* 313 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Canvas.CanvasInterpolation + * @since 3.0.0 + */ +var CanvasInterpolation = { + + /** + * Sets the CSS image-rendering property on the given canvas to be 'crisp' (aka 'optimize contrast' on webkit). + * + * @function Phaser.Display.Canvas.CanvasInterpolation.setCrisp + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The canvas object to have the style set on. + * + * @return {HTMLCanvasElement} The canvas. + */ + setCrisp: function (canvas) + { + var types = [ 'optimizeSpeed', 'crisp-edges', '-moz-crisp-edges', '-webkit-optimize-contrast', 'optimize-contrast', 'pixelated' ]; + + types.forEach(function (type) + { + canvas.style['image-rendering'] = type; + }); + + canvas.style.msInterpolationMode = 'nearest-neighbor'; + + return canvas; + }, + + /** + * Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto'). + * + * @function Phaser.Display.Canvas.CanvasInterpolation.setBicubic + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The canvas object to have the style set on. + * + * @return {HTMLCanvasElement} The canvas. + */ + setBicubic: function (canvas) + { + canvas.style['image-rendering'] = 'auto'; + canvas.style.msInterpolationMode = 'bicubic'; + + return canvas; + } + +}; + +module.exports = CanvasInterpolation; + + +/***/ }), +/* 314 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var CatmullRom = __webpack_require__(149); +var Class = __webpack_require__(0); +var Curve = __webpack_require__(56); +var Vector2 = __webpack_require__(6); + +/** + * @classdesc + * [description] + * + * @class SplineCurve + * @extends Phaser.Curves.Curve + * @memberOf Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2[]} [points] - [description] + */ +var SplineCurve = new Class({ + + Extends: Curve, + + initialize: + + function SplineCurve (points) + { + if (points === undefined) { points = []; } + + Curve.call(this, 'SplineCurve'); + + /** + * [description] + * + * @name Phaser.Curves.SplineCurve#points + * @type {Phaser.Math.Vector2[]} + * @default [] + * @since 3.0.0 + */ + this.points = []; + + this.addPoints(points); + }, + + /** + * [description] + * + * @method Phaser.Curves.SplineCurve#addPoints + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2[]} points - [description] + * + * @return {Phaser.Curves.SplineCurve} This curve object. + */ + addPoints: function (points) + { + for (var i = 0; i < points.length; i++) + { + var p = new Vector2(); + + if (typeof points[i] === 'number') + { + p.x = points[i]; + p.y = points[i + 1]; + i++; + } + else if (Array.isArray(points[i])) + { + // An array of arrays? + p.x = points[i][0]; + p.y = points[i][1]; + } + else + { + p.x = points[i].x; + p.y = points[i].y; + } + + this.points.push(p); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Curves.SplineCurve#addPoint + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + addPoint: function (x, y) + { + var vec = new Vector2(x, y); + + this.points.push(vec); + + return vec; + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.SplineCurve#getStartPoint + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.points[0]); + }, + + /** + * [description] + * + * @method Phaser.Curves.SplineCurve#getResolution + * @since 3.0.0 + * + * @param {number} divisions - [description] + * + * @return {number} [description] + */ + getResolution: function (divisions) + { + return divisions * this.points.length; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.SplineCurve#getPoint + * @since 3.0.0 + * + * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var points = this.points; + + var point = (points.length - 1) * t; + + var intPoint = Math.floor(point); + + var weight = point - intPoint; + + var p0 = points[(intPoint === 0) ? intPoint : intPoint - 1]; + var p1 = points[intPoint]; + var p2 = points[(intPoint > points.length - 2) ? points.length - 1 : intPoint + 1]; + var p3 = points[(intPoint > points.length - 3) ? points.length - 1 : intPoint + 2]; + + return out.set(CatmullRom(weight, p0.x, p1.x, p2.x, p3.x), CatmullRom(weight, p0.y, p1.y, p2.y, p3.y)); + }, + + /** + * [description] + * + * @method Phaser.Curves.SplineCurve#toJSON + * @since 3.0.0 + * + * @return {JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + var points = []; + + for (var i = 0; i < this.points.length; i++) + { + points.push(this.points[i].x); + points.push(this.points[i].y); + } + + return { + type: this.type, + points: points + }; + } + +}); + +/** + * [description] + * + * @function Phaser.Curves.SplineCurve.fromJSON + * @since 3.0.0 + * + * @param {JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.SplineCurve} [description] + */ +SplineCurve.fromJSON = function (data) +{ + return new SplineCurve(data.points); +}; + +module.exports = SplineCurve; + + +/***/ }), +/* 315 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +function P0 (t, p) +{ + var k = 1 - t; + + return k * k * p; +} + +function P1 (t, p) +{ + return 2 * (1 - t) * t * p; +} + +function P2 (t, p) +{ + return t * t * p; +} + +// p0 = start point +// p1 = control point 1 +// p2 = end point + +// https://github.com/mrdoob/three.js/blob/master/src/extras/core/Interpolations.js + +/** + * [description] + * + * @function Phaser.Math.Interpolation.QuadraticBezier + * @since 3.2.0 + * + * @param {float} t - [description] + * @param {number} p0 - [description] + * @param {number} p1 - [description] + * @param {number} p2 - [description] + * + * @return {number} [description] + */ +var QuadraticBezierInterpolation = function (t, p0, p1, p2) +{ + return P0(t, p0) + P1(t, p1) + P2(t, p2); +}; + +module.exports = QuadraticBezierInterpolation; + + +/***/ }), +/* 316 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Curve = __webpack_require__(56); +var QuadraticBezierInterpolation = __webpack_require__(315); +var Vector2 = __webpack_require__(6); + +/** + * @classdesc + * [description] + * + * @class QuadraticBezier + * @extends Phaser.Curves.Curve + * @memberOf Phaser.Curves + * @constructor + * @since 3.2.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector2[])} p0 - Start point, or an array of point pairs. + * @param {Phaser.Math.Vector2} p1 - Control Point 1. + * @param {Phaser.Math.Vector2} p2 - Control Point 2. + */ +var QuadraticBezier = new Class({ + + Extends: Curve, + + initialize: + + function QuadraticBezier (p0, p1, p2) + { + Curve.call(this, 'QuadraticBezier'); + + if (Array.isArray(p0)) + { + p2 = new Vector2(p0[4], p0[5]); + p1 = new Vector2(p0[2], p0[3]); + p0 = new Vector2(p0[0], p0[1]); + } + + /** + * [description] + * + * @name Phaser.Curves.QuadraticBezier#p0 + * @type {Phaser.Math.Vector2} + * @since 3.2.0 + */ + this.p0 = p0; + + /** + * [description] + * + * @name Phaser.Curves.QuadraticBezier#p1 + * @type {Phaser.Math.Vector2} + * @since 3.2.0 + */ + this.p1 = p1; + + /** + * [description] + * + * @name Phaser.Curves.QuadraticBezier#p2 + * @type {Phaser.Math.Vector2} + * @since 3.2.0 + */ + this.p2 = p2; + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.QuadraticBezier#getStartPoint + * @since 3.2.0 + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.p0); + }, + + /** + * [description] + * + * @method Phaser.Curves.QuadraticBezier#getResolution + * @since 3.2.0 + * + * @param {number} divisions - [description] + * + * @return {number} [description] + */ + getResolution: function (divisions) + { + return divisions; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.QuadraticBezier#getPoint + * @since 3.2.0 + * + * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var p0 = this.p0; + var p1 = this.p1; + var p2 = this.p2; + + return out.set( + QuadraticBezierInterpolation(t, p0.x, p1.x, p2.x), + QuadraticBezierInterpolation(t, p0.y, p1.y, p2.y) + ); + }, + + /** + * [description] + * + * @method Phaser.Curves.QuadraticBezier#draw + * @since 3.2.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - [description] + * @param {integer} [pointsTotal=32] - [description] + * + * @return {Phaser.GameObjects.Graphics} [description] + */ + draw: function (graphics, pointsTotal) + { + if (pointsTotal === undefined) { pointsTotal = 32; } + + var points = this.getPoints(pointsTotal); + + graphics.beginPath(); + graphics.moveTo(this.p0.x, this.p0.y); + + for (var i = 1; i < points.length; i++) + { + graphics.lineTo(points[i].x, points[i].y); + } + + graphics.strokePath(); + + // So you can chain graphics calls + return graphics; + }, + + /** + * [description] + * + * @method Phaser.Curves.QuadraticBezier#toJSON + * @since 3.2.0 + * + * @return {JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + points: [ + this.p0.x, this.p0.y, + this.p1.x, this.p1.y, + this.p2.x, this.p2.y + ] + }; + } + +}); + +/** + * [description] + * + * @function Phaser.Curves.QuadraticBezier.fromJSON + * @since 3.2.0 + * + * @param {JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.QuadraticBezier} [description] + */ +QuadraticBezier.fromJSON = function (data) +{ + var points = data.points; + + var p0 = new Vector2(points[0], points[1]); + var p1 = new Vector2(points[2], points[3]); + var p2 = new Vector2(points[4], points[5]); + + return new QuadraticBezier(p0, p1, p2); +}; + +module.exports = QuadraticBezier; + + +/***/ }), +/* 317 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var Class = __webpack_require__(0); +var Curve = __webpack_require__(56); +var FromPoints = __webpack_require__(150); +var Rectangle = __webpack_require__(10); +var Vector2 = __webpack_require__(6); + +var tmpVec2 = new Vector2(); + +/** + * @classdesc + * [description] + * + * @class LineCurve + * @extends Phaser.Curves.Curve + * @memberOf Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} p0 - [description] + * @param {Phaser.Math.Vector2} p1 - [description] + */ +var LineCurve = new Class({ + + Extends: Curve, + + initialize: + + // vec2s or array + function LineCurve (p0, p1) + { + Curve.call(this, 'LineCurve'); + + if (Array.isArray(p0)) + { + p1 = new Vector2(p0[2], p0[3]); + p0 = new Vector2(p0[0], p0[1]); + } + + /** + * [description] + * + * @name Phaser.Curves.LineCurve#p0 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p0 = p0; + + /** + * [description] + * + * @property Phaser.Curves.LineCurve#p1 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p1 = p1; + }, + + /** + * Returns a Rectangle where the position and dimensions match the bounds of this Curve. + * + * @method Phaser.Curves.LineCurve#getBounds + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} [out] - A Rectangle object to store the bounds in. If not given a new Rectangle will be created. + * + * @return {Phaser.Geom.Rectangle} A Rectangle object holding the bounds of this curve. If `out` was given it will be this object. + */ + getBounds: function (out) + { + if (out === undefined) { out = new Rectangle(); } + + return FromPoints([ this.p0, this.p1 ], out); + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.LineCurve#getStartPoint + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.p0); + }, + + /** + * [description] + * + * @method Phaser.Curves.LineCurve#getResolution + * @since 3.0.0 + * + * @return {integer} [description] + */ + getResolution: function () + { + return 1; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.LineCurve#getPoint + * @since 3.0.0 + * + * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + if (t === 1) + { + return out.copy(this.p1); + } + + out.copy(this.p1).subtract(this.p0).scale(t).add(this.p0); + + return out; + }, + + // Line curve is linear, so we can overwrite default getPointAt + + /** + * [description] + * + * @method Phaser.Curves.LineCurve#getPointAt + * @since 3.0.0 + * + * @param {float} u - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPointAt: function (u, out) + { + return this.getPoint(u, out); + }, + + /** + * [description] + * + * @method Phaser.Curves.LineCurve#getTangent + * @since 3.0.0 + * + * @return {Phaser.Math.Vector2} [description] + */ + getTangent: function () + { + var tangent = tmpVec2.copy(this.p1).subtract(this.p0); + + return tangent.normalize(); + }, + + // Override default Curve.draw because this is better than calling getPoints on a line! + + /** + * Draws this curve on the given Graphics object. + * + * The curve is drawn using `Graphics.lineBetween` so will be drawn at whatever the present Graphics line color is. + * The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it. + * + * @method Phaser.Curves.LineCurve#draw + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - The Graphics instance onto which this curve will be drawn. + * + * @return {Phaser.GameObjects.Graphics} The Graphics object to which the curve was drawn. + */ + draw: function (graphics) + { + graphics.lineBetween(this.p0.x, this.p0.y, this.p1.x, this.p1.y); + + // So you can chain graphics calls + return graphics; + }, + + /** + * [description] + * + * @method Phaser.Curves.LineCurve#toJSON + * @since 3.0.0 + * + * @return {JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + points: [ + this.p0.x, this.p0.y, + this.p1.x, this.p1.y + ] + }; + } + +}); + +/** + * [description] + * + * @function Phaser.Curves.LineCurve.fromJSON + * @since 3.0.0 + * + * @param {JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.LineCurve} [description] + */ +LineCurve.fromJSON = function (data) +{ + var points = data.points; + + var p0 = new Vector2(points[0], points[1]); + var p1 = new Vector2(points[2], points[3]); + + return new LineCurve(p0, p1); +}; + +module.exports = LineCurve; + + +/***/ }), +/* 318 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(16); + +/** + * [description] + * + * @function Phaser.Math.RadToDeg + * @since 3.0.0 + * + * @param {float} radians - [description] + * + * @return {integer} [description] + */ +var RadToDeg = function (radians) +{ + return radians * CONST.RAD_TO_DEG; +}; + +module.exports = RadToDeg; + + +/***/ }), +/* 319 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var Class = __webpack_require__(0); +var Curve = __webpack_require__(56); +var DegToRad = __webpack_require__(42); +var GetValue = __webpack_require__(5); +var RadToDeg = __webpack_require__(318); +var Vector2 = __webpack_require__(6); + +/** + * @typedef {object} JSONEllipseCurve + * + * @property {string} type - The of the curve. + * @property {number} x - [description] + * @property {number} y - [description] + * @property {number} xRadius - The horizontal radius of ellipse. + * @property {number} yRadius - The vertical radius of ellipse. + * @property {integer} startAngle - The start angle of ellipse. + * @property {integer} endAngle - The end angle of ellipse. + * @property {boolean} clockwise - The clockwise of ellipse. + * @property {integer} rotation - The rotation of ellipse. + */ + +/** + * @classdesc + * [description] + * + * @class EllipseCurve + * @extends Phaser.Curves.Curve + * @memberOf Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - [description] + * @param {number} [y=0] - [description] + * @param {number} [xRadius=0] - [description] + * @param {number} [yRadius=0] - [description] + * @param {number} [startAngle=0] - [description] + * @param {number} [endAngle=360] - [description] + * @param {boolean} [clockwise=false] - [description] + * @param {number} [rotation=0] - [description] + */ +var EllipseCurve = new Class({ + + Extends: Curve, + + initialize: + + function EllipseCurve (x, y, xRadius, yRadius, startAngle, endAngle, clockwise, rotation) + { + if (typeof x === 'object') + { + var config = x; + + x = GetValue(config, 'x', 0); + y = GetValue(config, 'y', 0); + xRadius = GetValue(config, 'xRadius', 0); + yRadius = GetValue(config, 'yRadius', xRadius); + startAngle = GetValue(config, 'startAngle', 0); + endAngle = GetValue(config, 'endAngle', 360); + clockwise = GetValue(config, 'clockwise', false); + rotation = GetValue(config, 'rotation', 0); + } + else + { + if (yRadius === undefined) { yRadius = xRadius; } + if (startAngle === undefined) { startAngle = 0; } + if (endAngle === undefined) { endAngle = 360; } + if (clockwise === undefined) { clockwise = false; } + if (rotation === undefined) { rotation = 0; } + } + + Curve.call(this, 'EllipseCurve'); + + // Center point + + /** + * [description] + * + * @name {Phaser.Curves.EllipseCurve#p0 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p0 = new Vector2(x, y); + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#_xRadius + * @type {number} + * @private + * @since 3.0.0 + */ + this._xRadius = xRadius; + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#_yRadius + * @type {number} + * @private + * @since 3.0.0 + */ + this._yRadius = yRadius; + + // Radians + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#_startAngle + * @type {number} + * @private + * @since 3.0.0 + */ + this._startAngle = DegToRad(startAngle); + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#_endAngle + * @type {number} + * @private + * @since 3.0.0 + */ + this._endAngle = DegToRad(endAngle); + + /** + * Anti-clockwise direction. + * + * @name Phaser.Curves.EllipseCurve#_clockwise + * @type {boolean} + * @private + * @since 3.0.0 + */ + this._clockwise = clockwise; + + /** + * The rotation of the arc. + * + * @name Phaser.Curves.EllipseCurve#_rotation + * @type {number} + * @private + * @since 3.0.0 + */ + this._rotation = DegToRad(rotation); + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.EllipseCurve#getStartPoint + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return this.getPoint(0, out); + }, + + /** + * [description] + * + * @method Phaser.Curves.EllipseCurve#getResolution + * @since 3.0.0 + * + * @param {number} divisions - [description] + * + * @return {number} [description] + */ + getResolution: function (divisions) + { + return divisions * 2; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.EllipseCurve#getPoint + * @since 3.0.0 + * + * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var twoPi = Math.PI * 2; + var deltaAngle = this._endAngle - this._startAngle; + var samePoints = Math.abs(deltaAngle) < Number.EPSILON; + + // ensures that deltaAngle is 0 .. 2 PI + while (deltaAngle < 0) + { + deltaAngle += twoPi; + } + + while (deltaAngle > twoPi) + { + deltaAngle -= twoPi; + } + + if (deltaAngle < Number.EPSILON) + { + if (samePoints) + { + deltaAngle = 0; + } + else + { + deltaAngle = twoPi; + } + } + + if (this._clockwise && !samePoints) + { + if (deltaAngle === twoPi) + { + deltaAngle = - twoPi; + } + else + { + deltaAngle = deltaAngle - twoPi; + } + } + + var angle = this._startAngle + t * deltaAngle; + var x = this.p0.x + this._xRadius * Math.cos(angle); + var y = this.p0.y + this._yRadius * Math.sin(angle); + + if (this._rotation !== 0) + { + var cos = Math.cos(this._rotation); + var sin = Math.sin(this._rotation); + + var tx = x - this.p0.x; + var ty = y - this.p0.y; + + // Rotate the point about the center of the ellipse. + x = tx * cos - ty * sin + this.p0.x; + y = tx * sin + ty * cos + this.p0.y; + } + + return out.set(x, y); + }, + + /** + * Sets the horizontal radius of this curve. + * + * @method Phaser.Curves.EllipseCurve#setXRadius + * @since 3.0.0 + * + * @param {number} value - The horizontal radius of this curve. + * + * @return {Phaser.Curves.EllipseCurve} This curve object. + */ + setXRadius: function (value) + { + this.xRadius = value; + + return this; + }, + + /** + * Sets the vertical radius of this curve. + * + * @method Phaser.Curves.EllipseCurve#setYRadius + * @since 3.0.0 + * + * @param {number} value - The vertical radius of this curve. + * + * @return {Phaser.Curves.EllipseCurve} This curve object. + */ + setYRadius: function (value) + { + this.yRadius = value; + + return this; + }, + + /** + * Sets the width of this curve. + * + * @method Phaser.Curves.EllipseCurve#setWidth + * @since 3.0.0 + * + * @param {number} value - The width of this curve. + * + * @return {Phaser.Curves.EllipseCurve} This curve object. + */ + setWidth: function (value) + { + this.xRadius = value * 2; + + return this; + }, + + /** + * Sets the height of this curve. + * + * @method Phaser.Curves.EllipseCurve#setHeight + * @since 3.0.0 + * + * @param {number} value - The height of this curve. + * + * @return {Phaser.Curves.EllipseCurve} This curve object. + */ + setHeight: function (value) + { + this.yRadius = value * 2; + + return this; + }, + + /** + * Sets the start angle of this curve. + * + * @method Phaser.Curves.EllipseCurve#setStartAngle + * @since 3.0.0 + * + * @param {number} value - The start angle of this curve, in radians. + * + * @return {Phaser.Curves.EllipseCurve} This curve object. + */ + setStartAngle: function (value) + { + this.startAngle = value; + + return this; + }, + + /** + * Sets the end angle of this curve. + * + * @method Phaser.Curves.EllipseCurve#setEndAngle + * @since 3.0.0 + * + * @param {number} value - The end angle of this curve, in radians. + * + * @return {Phaser.Curves.EllipseCurve} This curve object. + */ + setEndAngle: function (value) + { + this.endAngle = value; + + return this; + }, + + /** + * Sets if this curve extends clockwise or anti-clockwise. + * + * @method Phaser.Curves.EllipseCurve#setClockwise + * @since 3.0.0 + * + * @param {boolean} value - The clockwise state of this curve. + * + * @return {Phaser.Curves.EllipseCurve} This curve object. + */ + setClockwise: function (value) + { + this.clockwise = value; + + return this; + }, + + /** + * Sets the rotation of this curve. + * + * @method Phaser.Curves.EllipseCurve#setRotation + * @since 3.0.0 + * + * @param {number} value - The rotation of this curve, in radians. + * + * @return {Phaser.Curves.EllipseCurve} This curve object. + */ + setRotation: function (value) + { + this.rotation = value; + + return this; + }, + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.p0.x; + }, + + set: function (value) + { + this.p0.x = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.p0.y; + }, + + set: function (value) + { + this.p0.y = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#xRadius + * @type {number} + * @since 3.0.0 + */ + xRadius: { + + get: function () + { + return this._xRadius; + }, + + set: function (value) + { + this._xRadius = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#yRadius + * @type {number} + * @since 3.0.0 + */ + yRadius: { + + get: function () + { + return this._yRadius; + }, + + set: function (value) + { + this._yRadius = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#startAngle + * @type {number} + * @since 3.0.0 + */ + startAngle: { + + get: function () + { + return RadToDeg(this._startAngle); + }, + + set: function (value) + { + this._startAngle = DegToRad(value); + } + + }, + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#endAngle + * @type {number} + * @since 3.0.0 + */ + endAngle: { + + get: function () + { + return RadToDeg(this._endAngle); + }, + + set: function (value) + { + this._endAngle = DegToRad(value); + } + + }, + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#clockwise + * @type {boolean} + * @since 3.0.0 + */ + clockwise: { + + get: function () + { + return this._clockwise; + }, + + set: function (value) + { + this._clockwise = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Curves.EllipseCurve#rotation + * @type {number} + * @since 3.0.0 + */ + rotation: { + + get: function () + { + return this._rotation; + }, + + set: function (value) + { + this._rotation = DegToRad(value); + } + + }, + + /** + * [description] + * + * @method Phaser.Curves.EllipseCurve#toJSON + * @since 3.0.0 + * + * @return {JSONEllipseCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + x: this.p0.x, + y: this.p0.y, + xRadius: this._xRadius, + yRadius: this._yRadius, + startAngle: RadToDeg(this._startAngle), + endAngle: RadToDeg(this._endAngle), + clockwise: this._clockwise, + rotation: RadToDeg(this._rotation) + }; + } + +}); + +/** + * [description] + * + * @function Phaser.Curves.EllipseCurve.fromJSON + * @since 3.0.0 + * + * @param {JSONEllipseCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.EllipseCurve} [description] + */ +EllipseCurve.fromJSON = function (data) +{ + return new EllipseCurve(data); +}; + +module.exports = EllipseCurve; + + +/***/ }), +/* 320 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +function P0 (t, p) +{ + var k = 1 - t; + + return k * k * k * p; +} + +function P1 (t, p) +{ + var k = 1 - t; + + return 3 * k * k * t * p; +} + +function P2 (t, p) +{ + return 3 * (1 - t) * t * t * p; +} + +function P3 (t, p) +{ + return t * t * t * p; +} + +// p0 = start point +// p1 = control point 1 +// p2 = control point 2 +// p3 = end point + +// https://medium.com/@adrian_cooney/bezier-interpolation-13b68563313a + +/** + * [description] + * + * @function Phaser.Math.Interpolation.CubicBezier + * @since 3.0.0 + * + * @param {float} t - [description] + * @param {number} p0 - [description] + * @param {number} p1 - [description] + * @param {number} p2 - [description] + * @param {number} p3 - [description] + * + * @return {number} [description] + */ +var CubicBezierInterpolation = function (t, p0, p1, p2, p3) +{ + return P0(t, p0) + P1(t, p1) + P2(t, p2) + P3(t, p3); +}; + +module.exports = CubicBezierInterpolation; + + +/***/ }), +/* 321 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var Class = __webpack_require__(0); +var CubicBezier = __webpack_require__(320); +var Curve = __webpack_require__(56); +var Vector2 = __webpack_require__(6); + +/** + * @classdesc + * [description] + * + * @class CubicBezierCurve + * @extends Phaser.Curves.Curve + * @memberOf Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector2[])} p0 - Start point, or an array of point pairs. + * @param {Phaser.Math.Vector2} p1 - Control Point 1. + * @param {Phaser.Math.Vector2} p2 - Control Point 2. + * @param {Phaser.Math.Vector2} p3 - End Point. + */ +var CubicBezierCurve = new Class({ + + Extends: Curve, + + initialize: + + function CubicBezierCurve (p0, p1, p2, p3) + { + Curve.call(this, 'CubicBezierCurve'); + + if (Array.isArray(p0)) + { + p3 = new Vector2(p0[6], p0[7]); + p2 = new Vector2(p0[4], p0[5]); + p1 = new Vector2(p0[2], p0[3]); + p0 = new Vector2(p0[0], p0[1]); + } + + /** + * [description] + * + * @name Phaser.Curves.CubicBezierCurve#p0 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p0 = p0; + + /** + * [description] + * + * @name Phaser.Curves.CubicBezierCurve#p1 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p1 = p1; + + /** + * [description] + * + * @name Phaser.Curves.CubicBezierCurve#p2 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p2 = p2; + + /** + * [description] + * + * @name Phaser.Curves.CubicBezierCurve#p3 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p3 = p3; + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.CubicBezierCurve#getStartPoint + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.p0); + }, + + /** + * [description] + * + * @method Phaser.Curves.CubicBezierCurve#getResolution + * @since 3.0.0 + * + * @param {number} divisions - The amount of divisions used by this curve. + * + * @return {number} The resolution of the curve. + */ + getResolution: function (divisions) + { + return divisions; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.CubicBezierCurve#getPoint + * @since 3.0.0 + * + * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var p0 = this.p0; + var p1 = this.p1; + var p2 = this.p2; + var p3 = this.p3; + + return out.set(CubicBezier(t, p0.x, p1.x, p2.x, p3.x), CubicBezier(t, p0.y, p1.y, p2.y, p3.y)); + }, + + /** + * [description] + * + * @method Phaser.Curves.CubicBezierCurve#draw + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - [description] + * @param {integer} [pointsTotal=32] - [description] + * + * @return {Phaser.GameObjects.Graphics} [description] + */ + draw: function (graphics, pointsTotal) + { + if (pointsTotal === undefined) { pointsTotal = 32; } + + var points = this.getPoints(pointsTotal); + + graphics.beginPath(); + graphics.moveTo(this.p0.x, this.p0.y); + + for (var i = 1; i < points.length; i++) + { + graphics.lineTo(points[i].x, points[i].y); + } + + graphics.strokePath(); + + // So you can chain graphics calls + return graphics; + }, + + /** + * [description] + * + * @method Phaser.Curves.CubicBezierCurve#toJSON + * @since 3.0.0 + * + * @return {JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + points: [ + this.p0.x, this.p0.y, + this.p1.x, this.p1.y, + this.p2.x, this.p2.y, + this.p3.x, this.p3.y + ] + }; + } + +}); + +/** + * [description] + * + * @function Phaser.Curves.CubicBezierCurve.fromJSON + * @since 3.0.0 + * + * @param {JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.CubicBezierCurve} [description] + */ +CubicBezierCurve.fromJSON = function (data) +{ + var points = data.points; + + var p0 = new Vector2(points[0], points[1]); + var p1 = new Vector2(points[2], points[3]); + var p2 = new Vector2(points[4], points[5]); + var p3 = new Vector2(points[6], points[7]); + + return new CubicBezierCurve(p0, p1, p2, p3); +}; + +module.exports = CubicBezierCurve; + + +/***/ }), +/* 322 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A 16 color palette by [Arne](http://androidarts.com/palette/16pal.htm) + * + * @name Phaser.Create.Palettes.ARNE16 + * @since 3.0.0 + * + * @type {Palette} + */ +module.exports = { + 0: '#000', + 1: '#9D9D9D', + 2: '#FFF', + 3: '#BE2633', + 4: '#E06F8B', + 5: '#493C2B', + 6: '#A46422', + 7: '#EB8931', + 8: '#F7E26B', + 9: '#2F484E', + A: '#44891A', + B: '#A3CE27', + C: '#1B2632', + D: '#005784', + E: '#31A2F2', + F: '#B2DCEF' +}; + + +/***/ }), +/* 323 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Arne16 = __webpack_require__(322); +var CanvasPool = __webpack_require__(23); +var GetValue = __webpack_require__(5); + +/** + * @callback GenerateTextureRendererCallback + * + * @param {HTMLCanvasElement} canvas - [description] + * @param {CanvasRenderingContext2D} context - [description] + */ + +/** + * @typedef {object} GenerateTextureConfig + * + * @property {array} [data=[]] - [description] + * @property {HTMLCanvasElement} [canvas=null] - [description] + * @property {Palette} [palette=Arne16] - [description] + * @property {number} [pixelWidth=1] - [description] + * @property {number} [pixelHeight=1] - [description] + * @property {boolean} [resizeCanvas=true] - [description] + * @property {boolean} [clearCanvas=true] - [description] + * @property {GenerateTextureRendererCallback} [preRender] - [description] + * @property {GenerateTextureRendererCallback} [postRender] - [description] + */ + +/** + * [description] + * + * @function Phaser.Create.GenerateTexture + * @since 3.0.0 + * + * @param {GenerateTextureConfig} config - [description] + * + * @return {HTMLCanvasElement} [description] + */ +var GenerateTexture = function (config) +{ + var data = GetValue(config, 'data', []); + var canvas = GetValue(config, 'canvas', null); + var palette = GetValue(config, 'palette', Arne16); + var pixelWidth = GetValue(config, 'pixelWidth', 1); + var pixelHeight = GetValue(config, 'pixelHeight', pixelWidth); + var resizeCanvas = GetValue(config, 'resizeCanvas', true); + var clearCanvas = GetValue(config, 'clearCanvas', true); + var preRender = GetValue(config, 'preRender', null); + var postRender = GetValue(config, 'postRender', null); + + var width = Math.floor(Math.abs(data[0].length * pixelWidth)); + var height = Math.floor(Math.abs(data.length * pixelHeight)); + + if (!canvas) + { + canvas = CanvasPool.create2D(this, width, height); + resizeCanvas = false; + clearCanvas = false; + } + + if (resizeCanvas) + { + canvas.width = width; + canvas.height = height; + } + + var ctx = canvas.getContext('2d'); + + if (clearCanvas) + { + ctx.clearRect(0, 0, width, height); + } + + // preRender Callback? + if (preRender) + { + preRender(canvas, ctx); + } + + // Draw it + for (var y = 0; y < data.length; y++) + { + var row = data[y]; + + for (var x = 0; x < row.length; x++) + { + var d = row[x]; + + if (d !== '.' && d !== ' ') + { + ctx.fillStyle = palette[d]; + ctx.fillRect(x * pixelWidth, y * pixelHeight, pixelWidth, pixelHeight); + } + } + } + + // postRender Callback? + if (postRender) + { + postRender(canvas, ctx); + } + + return canvas; +}; + +module.exports = GenerateTexture; + + +/***/ }), +/* 324 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Camera = __webpack_require__(154); +var Class = __webpack_require__(0); +var Vector3 = __webpack_require__(57); + +// Local cache vars +var tmpVec3 = new Vector3(); + +/** + * @classdesc + * [description] + * + * @class PerspectiveCamera + * @extends Phaser.Cameras.Sprite3D.Camera + * @memberOf Phaser.Cameras.Sprite3D + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {integer} fieldOfView - [description] + * @param {integer} viewportWidth - [description] + * @param {integer} viewportHeight - [description] + */ +var PerspectiveCamera = new Class({ + + Extends: Camera, + + // FOV is converted to radians automatically + initialize: + + function PerspectiveCamera (scene, fieldOfView, viewportWidth, viewportHeight) + { + if (fieldOfView === undefined) { fieldOfView = 80; } + if (viewportWidth === undefined) { viewportWidth = 0; } + if (viewportHeight === undefined) { viewportHeight = 0; } + + Camera.call(this, scene); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.PerspectiveCamera#viewportWidth + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.viewportWidth = viewportWidth; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.PerspectiveCamera#viewportHeight + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.viewportHeight = viewportHeight; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.PerspectiveCamera#fieldOfView + * @type {integer} + * @default 80 + * @since 3.0.0 + */ + this.fieldOfView = fieldOfView * Math.PI / 180; + + this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.PerspectiveCamera#setFOV + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description] + */ + setFOV: function (value) + { + this.fieldOfView = value * Math.PI / 180; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.PerspectiveCamera#update + * @since 3.0.0 + * + * @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description] + */ + update: function () + { + var aspect = this.viewportWidth / this.viewportHeight; + + // Create a perspective matrix for our camera + this.projection.perspective( + this.fieldOfView, + aspect, + Math.abs(this.near), + Math.abs(this.far) + ); + + // Build the view matrix + tmpVec3.copy(this.position).add(this.direction); + + this.view.lookAt(this.position, tmpVec3, this.up); + + // Projection * view matrix + this.combined.copy(this.projection).multiply(this.view); + + // Invert combined matrix, used for unproject + this.invProjectionView.copy(this.combined).invert(); + + this.billboardMatrixDirty = true; + + this.updateChildren(); + + return this; + } + +}); + +module.exports = PerspectiveCamera; + + +/***/ }), +/* 325 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Camera = __webpack_require__(154); +var Class = __webpack_require__(0); +var Vector3 = __webpack_require__(57); + +// Local cache vars +var tmpVec3 = new Vector3(); + +/** + * @classdesc + * [description] + * + * @class OrthographicCamera + * @extends Phaser.Cameras.Sprite3D.Camera + * @memberOf Phaser.Cameras.Sprite3D + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {integer} viewportWidth - [description] + * @param {integer} viewportHeight - [description] + */ +var OrthographicCamera = new Class({ + + Extends: Camera, + + initialize: + + function OrthographicCamera (scene, viewportWidth, viewportHeight) + { + if (viewportWidth === undefined) { viewportWidth = 0; } + if (viewportHeight === undefined) { viewportHeight = 0; } + + Camera.call(this, scene); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.OrthographicCamera#viewportWidth + * @type {integer} + * @since 3.0.0 + */ + this.viewportWidth = viewportWidth; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.OrthographicCamera#viewportHeight + * @type {integer} + * @since 3.0.0 + */ + this.viewportHeight = viewportHeight; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.OrthographicCamera#_zoom + * @type {float} + * @private + * @since 3.0.0 + */ + this._zoom = 1.0; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.OrthographicCamera#near + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.near = 0; + + this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.OrthographicCamera#setToOrtho + * @since 3.0.0 + * + * @param {number} yDown - [description] + * @param {number} [viewportWidth] - [description] + * @param {number} [viewportHeight] - [description] + * + * @return {Phaser.Cameras.Sprite3D.OrthographicCamera} [description] + */ + setToOrtho: function (yDown, viewportWidth, viewportHeight) + { + if (viewportWidth === undefined) { viewportWidth = this.viewportWidth; } + if (viewportHeight === undefined) { viewportHeight = this.viewportHeight; } + + var zoom = this.zoom; + + this.up.set(0, (yDown) ? -1 : 1, 0); + this.direction.set(0, 0, (yDown) ? 1 : -1); + this.position.set(zoom * viewportWidth / 2, zoom * viewportHeight / 2, 0); + + this.viewportWidth = viewportWidth; + this.viewportHeight = viewportHeight; + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.OrthographicCamera#update + * @since 3.0.0 + * + * @return {Phaser.Cameras.Sprite3D.OrthographicCamera} [description] + */ + update: function () + { + var w = this.viewportWidth; + var h = this.viewportHeight; + var near = Math.abs(this.near); + var far = Math.abs(this.far); + var zoom = this.zoom; + + if (w === 0 || h === 0) + { + // What to do here... hmm? + return this; + } + + this.projection.ortho( + zoom * -w / 2, zoom * w / 2, + zoom * -h / 2, zoom * h / 2, + near, + far + ); + + // Build the view matrix + tmpVec3.copy(this.position).add(this.direction); + + this.view.lookAt(this.position, tmpVec3, this.up); + + // Projection * view matrix + this.combined.copy(this.projection).multiply(this.view); + + // Invert combined matrix, used for unproject + this.invProjectionView.copy(this.combined).invert(); + + this.billboardMatrixDirty = true; + + this.updateChildren(); + + return this; + }, + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.OrthographicCamera#zoom + * @type {number} + * @since 3.0.0 + */ + zoom: { + + get: function () + { + return this._zoom; + }, + + set: function (value) + { + this._zoom = value; + this.update(); + } + } + +}); + +module.exports = OrthographicCamera; + + +/***/ }), +/* 326 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); + +/** + * @classdesc + * [description] + * + * @class Matrix3 + * @memberOf Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} [m] - [description] + */ + +var Matrix3 = new Class({ + + initialize: + + function Matrix3 (m) + { + /** + * [description] + * + * @name Phaser.Math.Matrix3#val + * @type {Float32Array} + * @since 3.0.0 + */ + this.val = new Float32Array(9); + + if (m) + { + // Assume Matrix3 with val: + this.copy(m); + } + else + { + // Default to identity + this.identity(); + } + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} A new Matrix3 object. + */ + clone: function () + { + return new Matrix3(this); + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#set + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} src - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + set: function (src) + { + return this.copy(src); + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#copy + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} src - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + copy: function (src) + { + var out = this.val; + var a = src.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#fromMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} m - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + fromMat4: function (m) + { + var a = m.val; + var out = this.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[4]; + out[4] = a[5]; + out[5] = a[6]; + out[6] = a[8]; + out[7] = a[9]; + out[8] = a[10]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#fromArray + * @since 3.0.0 + * + * @param {array} a - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + fromArray: function (a) + { + var out = this.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#identity + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + identity: function () + { + var out = this.val; + + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 1; + out[5] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 1; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#transpose + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + transpose: function () + { + var a = this.val; + var a01 = a[1]; + var a02 = a[2]; + var a12 = a[5]; + + a[1] = a[3]; + a[2] = a[6]; + a[3] = a01; + a[5] = a[7]; + a[6] = a02; + a[7] = a12; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#invert + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + invert: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + var b01 = a22 * a11 - a12 * a21; + var b11 = -a22 * a10 + a12 * a20; + var b21 = a21 * a10 - a11 * a20; + + // Calculate the determinant + var det = a00 * b01 + a01 * b11 + a02 * b21; + + if (!det) + { + return null; + } + + det = 1 / det; + + a[0] = b01 * det; + a[1] = (-a22 * a01 + a02 * a21) * det; + a[2] = (a12 * a01 - a02 * a11) * det; + a[3] = b11 * det; + a[4] = (a22 * a00 - a02 * a20) * det; + a[5] = (-a12 * a00 + a02 * a10) * det; + a[6] = b21 * det; + a[7] = (-a21 * a00 + a01 * a20) * det; + a[8] = (a11 * a00 - a01 * a10) * det; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#adjoint + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + adjoint: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + a[0] = (a11 * a22 - a12 * a21); + a[1] = (a02 * a21 - a01 * a22); + a[2] = (a01 * a12 - a02 * a11); + a[3] = (a12 * a20 - a10 * a22); + a[4] = (a00 * a22 - a02 * a20); + a[5] = (a02 * a10 - a00 * a12); + a[6] = (a10 * a21 - a11 * a20); + a[7] = (a01 * a20 - a00 * a21); + a[8] = (a00 * a11 - a01 * a10); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#determinant + * @since 3.0.0 + * + * @return {number} [description] + */ + determinant: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20); + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#multiply + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} src - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + multiply: function (src) + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + var b = src.val; + + var b00 = b[0]; + var b01 = b[1]; + var b02 = b[2]; + var b10 = b[3]; + var b11 = b[4]; + var b12 = b[5]; + var b20 = b[6]; + var b21 = b[7]; + var b22 = b[8]; + + a[0] = b00 * a00 + b01 * a10 + b02 * a20; + a[1] = b00 * a01 + b01 * a11 + b02 * a21; + a[2] = b00 * a02 + b01 * a12 + b02 * a22; + + a[3] = b10 * a00 + b11 * a10 + b12 * a20; + a[4] = b10 * a01 + b11 * a11 + b12 * a21; + a[5] = b10 * a02 + b11 * a12 + b12 * a22; + + a[6] = b20 * a00 + b21 * a10 + b22 * a20; + a[7] = b20 * a01 + b21 * a11 + b22 * a21; + a[8] = b20 * a02 + b21 * a12 + b22 * a22; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#translate + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + translate: function (v) + { + var a = this.val; + var x = v.x; + var y = v.y; + + a[6] = x * a[0] + y * a[3] + a[6]; + a[7] = x * a[1] + y * a[4] + a[7]; + a[8] = x * a[2] + y * a[5] + a[8]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#rotate + * @since 3.0.0 + * + * @param {number} rad - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + rotate: function (rad) + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + + var s = Math.sin(rad); + var c = Math.cos(rad); + + a[0] = c * a00 + s * a10; + a[1] = c * a01 + s * a11; + a[2] = c * a02 + s * a12; + + a[3] = c * a10 - s * a00; + a[4] = c * a11 - s * a01; + a[5] = c * a12 - s * a02; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#scale + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + scale: function (v) + { + var a = this.val; + var x = v.x; + var y = v.y; + + a[0] = x * a[0]; + a[1] = x * a[1]; + a[2] = x * a[2]; + + a[3] = y * a[3]; + a[4] = y * a[4]; + a[5] = y * a[5]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#fromQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + fromQuat: function (q) + { + var x = q.x; + var y = q.y; + var z = q.z; + var w = q.w; + + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + + var out = this.val; + + out[0] = 1 - (yy + zz); + out[3] = xy + wz; + out[6] = xz - wy; + + out[1] = xy - wz; + out[4] = 1 - (xx + zz); + out[7] = yz + wx; + + out[2] = xz + wy; + out[5] = yz - wx; + out[8] = 1 - (xx + yy); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#normalFromMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} m - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3 object. + */ + normalFromMat4: function (m) + { + var a = m.val; + var out = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + + if (!det) + { + return null; + } + + det = 1 / det; + + out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + + out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + + out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det; + + return this; + } + +}); + +module.exports = Matrix3; + + +/***/ }), +/* 327 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); +var Vector3 = __webpack_require__(57); +var Matrix3 = __webpack_require__(326); + +var EPSILON = 0.000001; + +// Some shared 'private' arrays +var siNext = new Int8Array([ 1, 2, 0 ]); +var tmp = new Float32Array([ 0, 0, 0 ]); + +var xUnitVec3 = new Vector3(1, 0, 0); +var yUnitVec3 = new Vector3(0, 1, 0); + +var tmpvec = new Vector3(); +var tmpMat3 = new Matrix3(); + +/** + * @classdesc + * [description] + * + * @class Quaternion + * @memberOf Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {number} [x] - [description] + * @param {number} [y] - [description] + * @param {number} [z] - [description] + * @param {number} [w] - [description] + */ +var Quaternion = new Class({ + + initialize: + + function Quaternion (x, y, z, w) + { + /** + * The x component of this Quaternion. + * + * @name Phaser.Math.Quaternion#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The y component of this Quaternion. + * + * @name Phaser.Math.Quaternion#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The z component of this Quaternion. + * + * @name Phaser.Math.Quaternion#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The w component of this Quaternion. + * + * @name Phaser.Math.Quaternion#w + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#copy + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} src - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + copy: function (src) + { + this.x = src.x; + this.y = src.y; + this.z = src.z; + this.w = src.w; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#set + * @since 3.0.0 + * + * @param {(number|object)} [x=0] - [description] + * @param {number} [y=0] - [description] + * @param {number} [z=0] - [description] + * @param {number} [w=0] - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + set: function (x, y, z, w) + { + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#add + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + add: function (v) + { + this.x += v.x; + this.y += v.y; + this.z += v.z; + this.w += v.w; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#subtract + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + subtract: function (v) + { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z; + this.w -= v.w; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#scale + * @since 3.0.0 + * + * @param {number} scale - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + scale: function (scale) + { + this.x *= scale; + this.y *= scale; + this.z *= scale; + this.w *= scale; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#length + * @since 3.0.0 + * + * @return {number} [description] + */ + length: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return Math.sqrt(x * x + y * y + z * z + w * w); + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#lengthSq + * @since 3.0.0 + * + * @return {number} [description] + */ + lengthSq: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return x * x + y * y + z * z + w * w; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#normalize + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + normalize: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + var len = x * x + y * y + z * z + w * w; + + if (len > 0) + { + len = 1 / Math.sqrt(len); + + this.x = x * len; + this.y = y * len; + this.z = z * len; + this.w = w * len; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#dot + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - [description] + * + * @return {number} [description] + */ + dot: function (v) + { + return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#lerp + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - [description] + * @param {number} [t=0] - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + lerp: function (v, t) + { + if (t === undefined) { t = 0; } + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + this.x = ax + t * (v.x - ax); + this.y = ay + t * (v.y - ay); + this.z = az + t * (v.z - az); + this.w = aw + t * (v.w - aw); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#rotationTo + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} a - [description] + * @param {Phaser.Math.Vector3} b - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + rotationTo: function (a, b) + { + var dot = a.x * b.x + a.y * b.y + a.z * b.z; + + if (dot < -0.999999) + { + if (tmpvec.copy(xUnitVec3).cross(a).length() < EPSILON) + { + tmpvec.copy(yUnitVec3).cross(a); + } + + tmpvec.normalize(); + + return this.setAxisAngle(tmpvec, Math.PI); + + } + else if (dot > 0.999999) + { + this.x = 0; + this.y = 0; + this.z = 0; + this.w = 1; + + return this; + } + else + { + tmpvec.copy(a).cross(b); + + this.x = tmpvec.x; + this.y = tmpvec.y; + this.z = tmpvec.z; + this.w = 1 + dot; + + return this.normalize(); + } + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#setAxes + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} view - [description] + * @param {Phaser.Math.Vector3} right - [description] + * @param {Phaser.Math.Vector3} up - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + setAxes: function (view, right, up) + { + var m = tmpMat3.val; + + m[0] = right.x; + m[3] = right.y; + m[6] = right.z; + + m[1] = up.x; + m[4] = up.y; + m[7] = up.z; + + m[2] = -view.x; + m[5] = -view.y; + m[8] = -view.z; + + return this.fromMat3(tmpMat3).normalize(); + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#identity + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + identity: function () + { + this.x = 0; + this.y = 0; + this.z = 0; + this.w = 1; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#setAxisAngle + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} axis - [description] + * @param {number} rad - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + setAxisAngle: function (axis, rad) + { + rad = rad * 0.5; + + var s = Math.sin(rad); + + this.x = s * axis.x; + this.y = s * axis.y; + this.z = s * axis.z; + this.w = Math.cos(rad); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#multiply + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} b - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + multiply: function (b) + { + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bx = b.x; + var by = b.y; + var bz = b.z; + var bw = b.w; + + this.x = ax * bw + aw * bx + ay * bz - az * by; + this.y = ay * bw + aw * by + az * bx - ax * bz; + this.z = az * bw + aw * bz + ax * by - ay * bx; + this.w = aw * bw - ax * bx - ay * by - az * bz; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#slerp + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} b - [description] + * @param {number} t - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + slerp: function (b, t) + { + // benchmarks: http://jsperf.com/quaternion-slerp-implementations + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bx = b.x; + var by = b.y; + var bz = b.z; + var bw = b.w; + + // calc cosine + var cosom = ax * bx + ay * by + az * bz + aw * bw; + + // adjust signs (if necessary) + if (cosom < 0) + { + cosom = -cosom; + bx = - bx; + by = - by; + bz = - bz; + bw = - bw; + } + + // "from" and "to" quaternions are very close + // ... so we can do a linear interpolation + var scale0 = 1 - t; + var scale1 = t; + + // calculate coefficients + if ((1 - cosom) > EPSILON) + { + // standard case (slerp) + var omega = Math.acos(cosom); + var sinom = Math.sin(omega); + + scale0 = Math.sin((1.0 - t) * omega) / sinom; + scale1 = Math.sin(t * omega) / sinom; + } + + // calculate final values + this.x = scale0 * ax + scale1 * bx; + this.y = scale0 * ay + scale1 * by; + this.z = scale0 * az + scale1 * bz; + this.w = scale0 * aw + scale1 * bw; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#invert + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + invert: function () + { + var a0 = this.x; + var a1 = this.y; + var a2 = this.z; + var a3 = this.w; + + var dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3; + var invDot = (dot) ? 1 / dot : 0; + + // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0 + + this.x = -a0 * invDot; + this.y = -a1 * invDot; + this.z = -a2 * invDot; + this.w = a3 * invDot; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#conjugate + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + conjugate: function () + { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#rotateX + * @since 3.0.0 + * + * @param {number} rad - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + rotateX: function (rad) + { + rad *= 0.5; + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bx = Math.sin(rad); + var bw = Math.cos(rad); + + this.x = ax * bw + aw * bx; + this.y = ay * bw + az * bx; + this.z = az * bw - ay * bx; + this.w = aw * bw - ax * bx; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#rotateY + * @since 3.0.0 + * + * @param {number} rad - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + rotateY: function (rad) + { + rad *= 0.5; + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var by = Math.sin(rad); + var bw = Math.cos(rad); + + this.x = ax * bw - az * by; + this.y = ay * bw + aw * by; + this.z = az * bw + ax * by; + this.w = aw * bw - ay * by; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#rotateZ + * @since 3.0.0 + * + * @param {number} rad - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + rotateZ: function (rad) + { + rad *= 0.5; + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bz = Math.sin(rad); + var bw = Math.cos(rad); + + this.x = ax * bw + ay * bz; + this.y = ay * bw - ax * bz; + this.z = az * bw + aw * bz; + this.w = aw * bw - az * bz; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#calculateW + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + calculateW: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + + this.w = -Math.sqrt(Math.abs(1.0 - x * x - y * y - z * z)); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#fromMat3 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} mat - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion object. + */ + fromMat3: function (mat) + { + // benchmarks: + // http://jsperf.com/typed-array-access-speed + // http://jsperf.com/conversion-of-3x3-matrix-to-quaternion + + // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes + // article "Quaternion Calculus and Fast Animation". + var m = mat.val; + var fTrace = m[0] + m[4] + m[8]; + var fRoot; + + if (fTrace > 0) + { + // |w| > 1/2, may as well choose w > 1/2 + fRoot = Math.sqrt(fTrace + 1.0); // 2w + + this.w = 0.5 * fRoot; + + fRoot = 0.5 / fRoot; // 1/(4w) + + this.x = (m[7] - m[5]) * fRoot; + this.y = (m[2] - m[6]) * fRoot; + this.z = (m[3] - m[1]) * fRoot; + } + else + { + // |w| <= 1/2 + var i = 0; + + if (m[4] > m[0]) + { + i = 1; + } + + if (m[8] > m[i * 3 + i]) + { + i = 2; + } + + var j = siNext[i]; + var k = siNext[j]; + + // This isn't quite as clean without array access + fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1); + tmp[i] = 0.5 * fRoot; + + fRoot = 0.5 / fRoot; + + tmp[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot; + tmp[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot; + + this.x = tmp[0]; + this.y = tmp[1]; + this.z = tmp[2]; + this.w = (m[k * 3 + j] - m[j * 3 + k]) * fRoot; + } + + return this; + } + +}); + +module.exports = Quaternion; + + +/***/ }), +/* 328 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Vector3 = __webpack_require__(57); +var Matrix4 = __webpack_require__(153); +var Quaternion = __webpack_require__(327); + +var tmpMat4 = new Matrix4(); +var tmpQuat = new Quaternion(); +var tmpVec3 = new Vector3(); + +/** + * Rotates a vector in place by axis angle. + * + * This is the same as transforming a point by an + * axis-angle quaternion, but it has higher precision. + * + * @function Phaser.Math.RotateVec3 + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} vec - [description] + * @param {Phaser.Math.Vector3} axis - [description] + * @param {float} radians - [description] + * + * @return {Phaser.Math.Vector3} [description] + */ +var RotateVec3 = function (vec, axis, radians) +{ + // Set the quaternion to our axis angle + tmpQuat.setAxisAngle(axis, radians); + + // Create a rotation matrix from the axis angle + tmpMat4.fromRotationTranslation(tmpQuat, tmpVec3.set(0, 0, 0)); + + // Multiply our vector by the rotation matrix + return vec.transformMat4(tmpMat4); +}; + +module.exports = RotateVec3; + + +/***/ }), +/* 329 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.RandomXYZW + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} vec4 - [description] + * @param {float} [scale=1] - [description] + * + * @return {Phaser.Math.Vector4} [description] + */ +var RandomXYZW = function (vec4, scale) +{ + if (scale === undefined) { scale = 1; } + + // Not spherical; should fix this for more uniform distribution + vec4.x = (Math.random() * 2 - 1) * scale; + vec4.y = (Math.random() * 2 - 1) * scale; + vec4.z = (Math.random() * 2 - 1) * scale; + vec4.w = (Math.random() * 2 - 1) * scale; + + return vec4; +}; + +module.exports = RandomXYZW; + + +/***/ }), +/* 330 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Position Vector randomly in a spherical area defined by the given radius +/** + * [description] + * + * @function Phaser.Math.RandomXYZ + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} vec3 - [description] + * @param {number} [radius=1] - [description] + * + * @return {Phaser.Math.Vector3} [description] + */ +var RandomXYZ = function (vec3, radius) +{ + if (radius === undefined) { radius = 1; } + + var r = Math.random() * 2 * Math.PI; + var z = (Math.random() * 2) - 1; + var zScale = Math.sqrt(1 - z * z) * radius; + + vec3.x = Math.cos(r) * zScale; + vec3.y = Math.sin(r) * zScale; + vec3.z = z * radius; + + return vec3; +}; + +module.exports = RandomXYZ; + + +/***/ }), +/* 331 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Color = __webpack_require__(41); + +/** + * Converts a CSS 'web' string into a Phaser Color object. + * + * The web string can be in the format `'rgb(r,g,b)'` or `'rgba(r,g,b,a)'` where r/g/b are in the range [0..255] and a is in the range [0..1]. + * + * @function Phaser.Display.Color.RGBStringToColor + * @since 3.0.0 + * + * @param {string} rgb - The CSS format color string, using the `rgb` or `rgba` format. + * + * @return {Phaser.Display.Color} A Color object. + */ +var RGBStringToColor = function (rgb) +{ + var color = new Color(); + + var result = (/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/).exec(rgb.toLowerCase()); + + if (result) + { + var r = parseInt(result[1], 10); + var g = parseInt(result[2], 10); + var b = parseInt(result[3], 10); + var a = (result[4] !== undefined) ? parseFloat(result[4]) : 1; + + color.setTo(r, g, b, a * 255); + } + + return color; +}; + +module.exports = RGBStringToColor; + + +/***/ }), +/* 332 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Color = __webpack_require__(41); + +/** + * Converts an object containing `r`, `g`, `b` and `a` properties into a Color class instance. + * + * @function Phaser.Display.Color.ObjectToColor + * @since 3.0.0 + * + * @param {InputColorObject} input - An object containing `r`, `g`, `b` and `a` properties in the range 0 to 255. + * + * @return {Phaser.Display.Color} A Color object. + */ +var ObjectToColor = function (input) +{ + return new Color(input.r, input.g, input.b, input.a); +}; + +module.exports = ObjectToColor; + + +/***/ }), +/* 333 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Return the component parts of a color as an Object with the properties alpha, red, green, blue. + * + * Alpha will only be set if it exists in the given color (0xAARRGGBB) + * + * @function Phaser.Display.Color.IntegerToRGB + * @since 3.0.0 + * + * @param {integer} input - The color value to convert into a Color object. + * + * @return {ColorObject} An object with the red, green and blue values set in the r, g and b properties. + */ +var IntegerToRGB = function (color) +{ + if (color > 16777215) + { + // The color value has an alpha component + return { + a: color >>> 24, + r: color >> 16 & 0xFF, + g: color >> 8 & 0xFF, + b: color & 0xFF + }; + } + else + { + return { + a: 255, + r: color >> 16 & 0xFF, + g: color >> 8 & 0xFF, + b: color & 0xFF + }; + } +}; + +module.exports = IntegerToRGB; + + +/***/ }), +/* 334 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Color = __webpack_require__(41); +var IntegerToRGB = __webpack_require__(333); + +/** + * Converts the given color value into an instance of a Color object. + * + * @function Phaser.Display.Color.IntegerToColor + * @since 3.0.0 + * + * @param {integer} input - The color value to convert into a Color object. + * + * @return {Phaser.Display.Color} A Color object. + */ +var IntegerToColor = function (input) +{ + var rgb = IntegerToRGB(input); + + return new Color(rgb.r, rgb.g, rgb.b, rgb.a); +}; + +module.exports = IntegerToColor; + + +/***/ }), +/* 335 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Given an alpha and 3 color values this will return an integer representation of it. + * + * @function Phaser.Display.Color.GetColor32 + * @since 3.0.0 + * + * @param {integer} red - The red color value. A number between 0 and 255. + * @param {integer} green - The green color value. A number between 0 and 255. + * @param {integer} blue - The blue color value. A number between 0 and 255. + * @param {integer} alpha - The alpha color value. A number between 0 and 255. + * + * @return {number} The combined color value. + */ +var GetColor32 = function (red, green, blue, alpha) +{ + return alpha << 24 | red << 16 | green << 8 | blue; +}; + +module.exports = GetColor32; + + +/***/ }), +/* 336 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Color = __webpack_require__(41); + +/** + * Converts a hex string into a Phaser Color object. + * + * The hex string can supplied as `'#0033ff'` or the short-hand format of `'#03f'`; it can begin with an optional "#" or "0x", or be unprefixed. + * + * An alpha channel is _not_ supported. + * + * @function Phaser.Display.Color.HexStringToColor + * @since 3.0.0 + * + * @param {string} hex - The hex color value to convert, such as `#0033ff` or the short-hand format: `#03f`. + * + * @return {Phaser.Display.Color} A Color object populated by the values of the given string. + */ +var HexStringToColor = function (hex) +{ + var color = new Color(); + + // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") + hex = hex.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) + { + return r + r + g + g + b + b; + }); + + var result = (/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i).exec(hex); + + if (result) + { + var r = parseInt(result[1], 16); + var g = parseInt(result[2], 16); + var b = parseInt(result[3], 16); + + color.setTo(r, g, b); + } + + return color; +}; + +module.exports = HexStringToColor; + + +/***/ }), +/* 337 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BaseCache = __webpack_require__(338); +var Class = __webpack_require__(0); + +/** + * @classdesc + * The Cache Manager is the global cache owned and maintained by the Game instance. + * + * Various systems, such as the file Loader, rely on this cache in order to store the files + * it has loaded. The manager itself doesn't store any files, but instead owns multiple BaseCache + * instances, one per type of file. You can also add your own custom caches. + * + * @class CacheManager + * @memberOf Phaser.Cache + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - A reference to the Phaser.Game instance that owns this CacheManager. + */ +var CacheManager = new Class({ + + initialize: + + function CacheManager (game) + { + /** + * A reference to the Phaser.Game instance that owns this CacheManager. + * + * @name Phaser.Cache.CacheManager#game + * @type {Phaser.Game} + * @protected + * @since 3.0.0 + */ + this.game = game; + + /** + * A Cache storing all binary files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#binary + * @type {Phaser.Cache.BaseCache} + * @protected + * @since 3.0.0 + */ + this.binary = new BaseCache(); + + /** + * A Cache storing all bitmap font data files, typically added via the Loader. + * Only the font data is stored in this cache, the textures are part of the Texture Manager. + * + * @name Phaser.Cache.CacheManager#bitmapFont + * @type {Phaser.Cache.BaseCache} + * @protected + * @since 3.0.0 + */ + this.bitmapFont = new BaseCache(); + + /** + * A Cache storing all JSON data files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#json + * @type {Phaser.Cache.BaseCache} + * @protected + * @since 3.0.0 + */ + this.json = new BaseCache(); + + /** + * A Cache storing all physics data files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#physics + * @type {Phaser.Cache.BaseCache} + * @protected + * @since 3.0.0 + */ + this.physics = new BaseCache(); + + /** + * A Cache storing all shader source files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#shader + * @type {Phaser.Cache.BaseCache} + * @protected + * @since 3.0.0 + */ + this.shader = new BaseCache(); + + /** + * A Cache storing all non-streaming audio files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#audio + * @type {Phaser.Cache.BaseCache} + * @protected + * @since 3.0.0 + */ + this.audio = new BaseCache(); + + /** + * A Cache storing all text files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#text + * @type {Phaser.Cache.BaseCache} + * @protected + * @since 3.0.0 + */ + this.text = new BaseCache(); + + /** + * A Cache storing all WaveFront OBJ files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#obj + * @type {Phaser.Cache.BaseCache} + * @protected + * @since 3.0.0 + */ + this.obj = new BaseCache(); + + /** + * A Cache storing all tilemap data files, typically added via the Loader. + * Only the data is stored in this cache, the textures are part of the Texture Manager. + * + * @name Phaser.Cache.CacheManager#tilemap + * @type {Phaser.Cache.BaseCache} + * @protected + * @since 3.0.0 + */ + this.tilemap = new BaseCache(); + + /** + * A Cache storing all xml data files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#xml + * @type {Phaser.Cache.BaseCache} + * @protected + * @since 3.0.0 + */ + this.xml = new BaseCache(); + + /** + * An object that contains your own custom BaseCache entries. + * Add to this via the `addCustom` method. + * + * @name Phaser.Cache.CacheManager#custom + * @type {object.} + * @protected + * @since 3.0.0 + */ + this.custom = {}; + + this.game.events.once('destroy', this.destroy, this); + }, + + /** + * Add your own custom Cache for storing your own files. + * The cache will be available under `Cache.custom.key`. + * The cache will only be created if the key is not already in use. + * + * @method Phaser.Cache.CacheManager#addCustom + * @since 3.0.0 + * + * @param {string} key - The unique key of your custom cache. + * + * @return {Phaser.Cache.BaseCache} A reference to the BaseCache that was created. If the key was already in use, a reference to the existing cache is returned instead. + */ + addCustom: function (key) + { + if (!this.custom.hasOwnProperty(key)) + { + this.custom[key] = new BaseCache(); + } + + return this.custom[key]; + }, + + /** + * Removes all entries from all BaseCaches and destroys all custom caches. + * + * @method Phaser.Cache.CacheManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + var keys = [ + 'binary', + 'bitmapFont', + 'json', + 'physics', + 'shader', + 'audio', + 'text', + 'obj', + 'tilemap', + 'xml' + ]; + + for (var i = 0; i < keys.length; i++) + { + this[keys[i]].destroy(); + this[keys[i]] = null; + } + + for (var key in this.custom) + { + this.custom[key].destroy(); + } + + this.custom = null; + + this.game = null; + } + +}); + +module.exports = CacheManager; + + +/***/ }), +/* 338 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CustomMap = __webpack_require__(159); +var EventEmitter = __webpack_require__(15); + +/** + * @classdesc + * The BaseCache is a base Cache class that can be used for storing references to any kind of data. + * + * Data can be added, retrieved and removed based on the given keys. + * + * Keys are string-based. + * + * @class BaseCache + * @memberOf Phaser.Cache + * @constructor + * @since 3.0.0 + */ +var BaseCache = new Class({ + + initialize: + + function BaseCache () + { + /** + * The Map in which the cache objects are stored. + * + * You can query the Map directly or use the BaseCache methods. + * + * @name Phaser.Cache.BaseCache#entries + * @type {Phaser.Structs.Map} + * @since 3.0.0 + */ + this.entries = new CustomMap(); + + /** + * An instance of EventEmitter used by the cache to emit related events. + * + * @name Phaser.Cache.BaseCache#events + * @type {EventEmitter} + * @since 3.0.0 + */ + this.events = new EventEmitter(); + }, + + /** + * Cache add event. + * + * This event is fired by the Cache each time a new object is added to it. + * + * @event Phaser.Cache.BaseCache#addEvent + * @param {Phaser.Cache.BaseCache} The BaseCache to which the object was added. + * @param {string} The key of the object added to the cache. + * @param {*} A reference to the object added to the cache. + */ + + /** + * Adds an item to this cache. The item is referenced by a unique string, which you are responsible + * for setting and keeping track of. The item can only be retrieved by using this string. + * + * @method Phaser.Cache.BaseCache#add + * @fires Phaser.Cache.BaseCache#addEvent + * @since 3.0.0 + * + * @param {string} key - The unique key by which the data added to the cache will be referenced. + * @param {*} data - The data to be stored in the cache. + * + * @return {Phaser.Cache.BaseCache} This BaseCache object. + */ + add: function (key, data) + { + this.entries.set(key, data); + + this.events.emit('add', this, key, data); + + return this; + }, + + /** + * Checks if this cache contains an item matching the given key. + * + * @method Phaser.Cache.BaseCache#has + * @since 3.0.0 + * + * @param {string} key - The unique key of the item to be checked in this cache. + * + * @return {boolean} Returns `true` if the cache contains an item matching the given key, otherwise `false`. + */ + has: function (key) + { + return this.entries.has(key); + }, + + /** + * Gets an item from this cache based on the given key. + * + * @method Phaser.Cache.BaseCache#get + * @since 3.0.0 + * + * @param {string} key - The unique key of the item to be retrieved from this cache. + * + * @return {*} The item in the cache, or `null` if no item matching the given key was found. + */ + get: function (key) + { + return this.entries.get(key); + }, + + /** + * Cache remove event. + * + * This event is fired by the Cache each time an object is removed from it. + * + * @event Phaser.Cache.BaseCache#removeEvent + * @param {Phaser.Cache.BaseCache} The BaseCache from which the object was removed. + * @param {string} The key of the object removed from the cache. + * @param {*} The object that was removed from the cache. + */ + + /** + * Removes and item from this cache based on the given key. + * + * If an entry matching the key is found it is removed from the cache and a `remove` event emitted. + * No additional checks are done on the item removed. If other systems or parts of your game code + * are relying on this item, it is up to you to sever those relationships prior to removing the item. + * + * @method Phaser.Cache.BaseCache#remove + * @fires Phaser.Cache.BaseCache#removeEvent + * @since 3.0.0 + * + * @param {string} key - The unique key of the item to remove from the cache. + * + * @return {Phaser.Cache.BaseCache} This BaseCache object. + */ + remove: function (key) + { + var entry = this.get(key); + + if (entry) + { + this.entries.delete(key); + + this.events.emit('remove', this, key, entry.data); + } + + return this; + }, + + /** + * Destroys this cache and all items within it. + * + * @method Phaser.Cache.BaseCache#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.entries.clear(); + this.events.removeAllListeners(); + + this.entries = null; + this.events = null; + } + +}); + +module.exports = BaseCache; + + +/***/ }), +/* 339 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Animation = __webpack_require__(341); +var Class = __webpack_require__(0); +var CustomMap = __webpack_require__(159); +var EventEmitter = __webpack_require__(15); +var GetValue = __webpack_require__(5); +var Pad = __webpack_require__(158); + +/** + * @typedef {object} JSONAnimationManager + * + * @property {JSONAnimation[]} anims - [description] + * @property {number} globalTimeScale - [description] + */ + +/** + * @classdesc + * The Animation Manager. + * + * Animations are managed by the global Animation Manager. This is a singleton class that is + * responsible for creating and delivering animations and their corresponding data to all Game Objects. + * Unlike plugins it is owned by the Game instance, not the Scene. + * + * Sprites and other Game Objects get the data they need from the AnimationManager. + * + * @class AnimationManager + * @extends EventEmitter + * @memberOf Phaser.Animations + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - [description] + */ +var AnimationManager = new Class({ + + Extends: EventEmitter, + + initialize: + + function AnimationManager (game) + { + EventEmitter.call(this); + + /** + * [description] + * + * @name Phaser.Animations.AnimationManager#game + * @type {Phaser.Game} + * @protected + * @since 3.0.0 + */ + this.game = game; + + /** + * [description] + * + * @name Phaser.Animations.AnimationManager#textureManager + * @type {Phaser.Textures.TextureManager} + * @protected + * @since 3.0.0 + */ + this.textureManager = null; + + /** + * [description] + * + * @name Phaser.Animations.AnimationManager#globalTimeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.globalTimeScale = 1; + + /** + * [description] + * + * @name Phaser.Animations.AnimationManager#anims + * @type {Phaser.Structs.Map} + * @protected + * @since 3.0.0 + */ + this.anims = new CustomMap(); + + /** + * [description] + * + * @name Phaser.Animations.AnimationManager#paused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.paused = false; + + /** + * [description] + * + * @name Phaser.Animations.AnimationManager#name + * @type {string} + * @since 3.0.0 + */ + this.name = 'AnimationManager'; + + game.events.once('boot', this.boot, this); + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#boot + * @since 3.0.0 + */ + boot: function () + { + this.textureManager = this.game.textures; + + this.game.events.once('destroy', this.destroy, this); + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#add + * @fires AddAnimationEvent + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {Phaser.Animations.Animation} animation - [description] + * + * @return {Phaser.Animations.AnimationManager} This Animation Manager. + */ + add: function (key, animation) + { + if (this.anims.has(key)) + { + console.warn('Animation with key', key, 'already exists'); + return; + } + + animation.key = key; + + this.anims.set(key, animation); + + this.emit('add', key, animation); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#create + * @fires AddAnimationEvent + * @since 3.0.0 + * + * @param {AnimationConfig} config - [description] + * + * @return {Phaser.Animations.Animation} The Animation that was created. + */ + create: function (config) + { + var key = config.key; + + if (!key || this.anims.has(key)) + { + console.warn('Invalid Animation Key, or Key already in use: ' + key); + return; + } + + var anim = new Animation(this, key, config); + + this.anims.set(key, anim); + + this.emit('add', key, anim); + + return anim; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#fromJSON + * @since 3.0.0 + * + * @param {(string|object)} data - [description] + * @param {boolean} [clearCurrentAnimations=false] - [description] + * + * @return {Phaser.Animations.Animation[]} An array containing all of the Animation objects that were created as a result of this call. + */ + fromJSON: function (data, clearCurrentAnimations) + { + if (clearCurrentAnimations === undefined) { clearCurrentAnimations = false; } + + if (clearCurrentAnimations) + { + this.anims.clear(); + } + + // Do we have a String (i.e. from JSON, or an Object?) + if (typeof data === 'string') + { + data = JSON.parse(data); + } + + var output = []; + + // Array of animations, or a single animation? + if (data.hasOwnProperty('anims') && Array.isArray(data.anims)) + { + for (var i = 0; i < data.anims.length; i++) + { + output.push(this.create(data.anims[i])); + } + + if (data.hasOwnProperty('globalTimeScale')) + { + this.globalTimeScale = data.globalTimeScale; + } + } + else if (data.hasOwnProperty('key') && data.type === 'frame') + { + output.push(this.create(data)); + } + + return output; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#generateFrameNames + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {object} config - [description] + * @param {string} [config.prefix=''] - [description] + * @param {integer} [config.start=0] - [description] + * @param {integer} [config.end=0] - [description] + * @param {string} [config.suffix=''] - [description] + * @param {integer} [config.zeroPad=0] - [description] + * @param {array} [config.outputArray=[]] - [description] + * @param {boolean} [config.frames=false] - [description] + * + * @return {AnimationFrameConfig[]} [description] + */ + generateFrameNames: function (key, config) + { + var prefix = GetValue(config, 'prefix', ''); + var start = GetValue(config, 'start', 0); + var end = GetValue(config, 'end', 0); + var suffix = GetValue(config, 'suffix', ''); + var zeroPad = GetValue(config, 'zeroPad', 0); + var out = GetValue(config, 'outputArray', []); + var frames = GetValue(config, 'frames', false); + + var texture = this.textureManager.get(key); + + if (!texture) + { + return out; + } + + var diff = (start < end) ? 1 : -1; + + // Adjust because we use i !== end in the for loop + end += diff; + + var i; + var frame; + + // Have they provided their own custom frame sequence array? + if (Array.isArray(frames)) + { + for (i = 0; i < frames.length; i++) + { + frame = prefix + Pad(frames[i], zeroPad, '0', 1) + suffix; + + if (texture.has(frame)) + { + out.push({ key: key, frame: frame }); + } + } + } + else + { + for (i = start; i !== end; i += diff) + { + frame = prefix + Pad(i, zeroPad, '0', 1) + suffix; + + if (texture.has(frame)) + { + out.push({ key: key, frame: frame }); + } + } + } + + return out; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#generateFrameNumbers + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {object} config - [description] + * @param {integer} [config.start=0] - [description] + * @param {integer} [config.end=-1] - [description] + * @param {boolean} [config.first=false] - [description] + * @param {array} [config.outputArray=[]] - [description] + * @param {boolean} [config.frames=false] - [description] + * + * @return {AnimationFrameConfig[]} [description] + */ + generateFrameNumbers: function (key, config) + { + var startFrame = GetValue(config, 'start', 0); + var endFrame = GetValue(config, 'end', -1); + var firstFrame = GetValue(config, 'first', false); + var out = GetValue(config, 'outputArray', []); + var frames = GetValue(config, 'frames', false); + + var texture = this.textureManager.get(key); + + if (!texture) + { + return out; + } + + if (firstFrame && texture.has(firstFrame)) + { + out.push({ key: key, frame: firstFrame }); + } + + var i; + + // Have they provided their own custom frame sequence array? + if (Array.isArray(frames)) + { + for (i = 0; i < frames.length; i++) + { + if (texture.has(frames[i])) + { + out.push({ key: key, frame: frames[i] }); + } + } + } + else + { + // No endFrame then see if we can get it + + if (endFrame === -1) + { + endFrame = texture.frameTotal; + } + + for (i = startFrame; i <= endFrame; i++) + { + if (texture.has(i)) + { + out.push({ key: key, frame: i }); + } + } + } + + return out; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#get + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Animations.Animation} [description] + */ + get: function (key) + { + return this.anims.get(key); + }, + + /** + * Load an Animation into a Game Objects Animation Component. + * + * @method Phaser.Animations.AnimationManager#load + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - [description] + * @param {string} key - [description] + * @param {(string|integer)} [startFrame] - [description] + * + * @return {Phaser.GameObjects.GameObject} [description] + */ + load: function (child, key, startFrame) + { + var anim = this.get(key); + + if (anim) + { + anim.load(child, startFrame); + } + + return child; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#pauseAll + * @fires PauseAllAnimationEvent + * @since 3.0.0 + * + * @return {Phaser.Animations.AnimationManager} This Animation Manager. + */ + pauseAll: function () + { + if (!this.paused) + { + this.paused = true; + + this.emit('pauseall'); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#play + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {Phaser.GameObjects.GameObject} child - [description] + * + * @return {Phaser.Animations.AnimationManager} This Animation Manager. + */ + play: function (key, child) + { + if (!Array.isArray(child)) + { + child = [ child ]; + } + + var anim = this.get(key); + + if (!anim) + { + return; + } + + for (var i = 0; i < child.length; i++) + { + child[i].anims.play(key); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#remove + * @fires RemoveAnimationEvent + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Animations.Animation} [description] + */ + remove: function (key) + { + var anim = this.get(key); + + if (anim) + { + this.emit('remove', key, anim); + + this.anims.delete(key); + } + + return anim; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#resumeAll + * @fires ResumeAllAnimationEvent + * @since 3.0.0 + * + * @return {Phaser.Animations.AnimationManager} This Animation Manager. + */ + resumeAll: function () + { + if (this.paused) + { + this.paused = false; + + this.emit('resumeall'); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#staggerPlay + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {Phaser.GameObjects.GameObject} child - [description] + * @param {number} [stagger=0] - [description] + * + * @return {Phaser.Animations.AnimationManager} This Animation Manager. + */ + staggerPlay: function (key, child, stagger) + { + if (stagger === undefined) { stagger = 0; } + + if (!Array.isArray(child)) + { + child = [ child ]; + } + + var anim = this.get(key); + + if (!anim) + { + return; + } + + for (var i = 0; i < child.length; i++) + { + child[i].anims.delayedPlay(stagger * i, key); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#toJSON + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {JSONAnimationManager} [description] + */ + toJSON: function (key) + { + if (key !== undefined && key !== '') + { + return this.anims.get(key).toJSON(); + } + else + { + var output = { + anims: [], + globalTimeScale: this.globalTimeScale + }; + + this.anims.each(function (animationKey, animation) + { + output.anims.push(animation.toJSON()); + }); + + return output; + } + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.anims.clear(); + + this.textureManager = null; + + this.game = null; + } + +}); + +module.exports = AnimationManager; + + +/***/ }), +/* 340 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @typedef {object} JSONAnimationFrame + * + * @property {string} key - The key of the Texture this AnimationFrame uses. + * @property {(string|integer)} frame - The key of the Frame within the Texture that this AnimationFrame uses. + * @property {number} duration - Additional time (in ms) that this frame should appear for during playback. + */ + +/** + * @classdesc + * A single frame in an Animation sequence. + * + * An AnimationFrame consists of a reference to the Texture it uses for rendering, references to other + * frames in the animation, and index data. It also has the ability to fire its own `onUpdate` callback + * and modify the animation timing. + * + * AnimationFrames are generated automatically by the Animation class. + * + * @class AnimationFrame + * @memberOf Phaser.Animations + * @constructor + * @since 3.0.0 + * + * @param {string} textureKey - The key of the Texture this AnimationFrame uses. + * @param {(string|integer)} textureFrame - The key of the Frame within the Texture that this AnimationFrame uses. + * @param {integer} index - The index of this AnimationFrame within the Animation sequence. + * @param {Phaser.Textures.Frame} frame - A reference to the Texture Frame this AnimationFrame uses for rendering. + */ +var AnimationFrame = new Class({ + + initialize: + + function AnimationFrame (textureKey, textureFrame, index, frame) + { + /** + * The key of the Texture this AnimationFrame uses. + * + * @name Phaser.Animations.AnimationFrame#textureKey + * @type {string} + * @since 3.0.0 + */ + this.textureKey = textureKey; + + /** + * The key of the Frame within the Texture that this AnimationFrame uses. + * + * @name Phaser.Animations.AnimationFrame#textureFrame + * @type {(string|integer)} + * @since 3.0.0 + */ + this.textureFrame = textureFrame; + + /** + * The index of this AnimationFrame within the Animation sequence. + * + * @name Phaser.Animations.AnimationFrame#index + * @type {integer} + * @since 3.0.0 + */ + this.index = index; + + /** + * A reference to the Texture Frame this AnimationFrame uses for rendering. + * + * @name Phaser.Animations.AnimationFrame#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + this.frame = frame; + + /** + * Is this the first frame in an animation sequence? + * + * @name Phaser.Animations.AnimationFrame#isFirst + * @type {boolean} + * @default false + * @readOnly + * @since 3.0.0 + */ + this.isFirst = false; + + /** + * Is this the last frame in an animation sequence? + * + * @name Phaser.Animations.AnimationFrame#isLast + * @type {boolean} + * @default false + * @readOnly + * @since 3.0.0 + */ + this.isLast = false; + + /** + * A reference to the AnimationFrame that comes before this one in the animation, if any. + * + * @name Phaser.Animations.AnimationFrame#prevFrame + * @type {?Phaser.Animations.AnimationFrame} + * @default null + * @readOnly + * @since 3.0.0 + */ + this.prevFrame = null; + + /** + * A reference to the AnimationFrame that comes after this one in the animation, if any. + * + * @name Phaser.Animations.AnimationFrame#nextFrame + * @type {?Phaser.Animations.AnimationFrame} + * @default null + * @readOnly + * @since 3.0.0 + */ + this.nextFrame = null; + + /** + * Additional time (in ms) that this frame should appear for during playback. + * The value is added onto the msPerFrame set by the animation. + * + * @name Phaser.Animations.AnimationFrame#duration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.duration = 0; + + /** + * What % through the animation does this frame come? + * This value is generated when the animation is created and cached here. + * + * @name Phaser.Animations.AnimationFrame#progress + * @type {number} + * @default 0 + * @readOnly + * @since 3.0.0 + */ + this.progress = 0; + + /** + * A frame specific callback, invoked if this frame gets displayed and the callback is set. + * + * @name Phaser.Animations.AnimationFrame#onUpdate + * @type {?function} + * @default null + * @since 3.0.0 + */ + this.onUpdate = null; + }, + + /** + * Generates a JavaScript object suitable for converting to JSON. + * + * @method Phaser.Animations.AnimationFrame#toJSON + * @since 3.0.0 + * + * @return {JSONAnimationFrame} The AnimationFrame data. + */ + toJSON: function () + { + return { + key: this.textureKey, + frame: this.textureFrame, + duration: this.duration + }; + }, + + /** + * Destroys this object by removing references to external resources and callbacks. + * + * @method Phaser.Animations.AnimationFrame#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.frame = undefined; + this.onUpdate = undefined; + } + +}); + +module.exports = AnimationFrame; + + +/***/ }), +/* 341 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Frame = __webpack_require__(340); +var GetValue = __webpack_require__(5); + +/** + * @typedef {object} JSONAnimation + * + * @property {string} key - [description] + * @property {string} type - A frame based animation (as opposed to a bone based animation) + * @property {JSONAnimationFrame[]} frames - [description] + * @property {integer} frameRate - The frame rate of playback in frames per second (default 24 if duration is null) + * @property {integer} duration - How long the animation should play for. + * @property {boolean} skipMissedFrames - Skip frames if the time lags, or always advanced anyway? + * @property {integer} delay - Delay before starting playback (in seconds) + * @property {integer} repeat - Number of times to repeat the animation (-1 for infinity) + * @property {integer} repeatDelay - Delay before the repeat starts (in seconds) + * @property {boolean} yoyo - Should the animation yoyo? (reverse back down to the start) before repeating? + * @property {boolean} showOnStart - Should sprite.visible = true when the animation starts to play? + * @property {boolean} hideOnComplete - Should sprite.visible = false when the animation finishes? + */ + +/** + * @typedef {object} AnimationFrameConfig + * + * @property {string} key - [description] + * @property {(string|number)} frame - [description] + * @property {float} [duration=0] - [description] + * @property {boolean} [visible] - [description] + * @property {function} [onUpdate] - [description] + */ + +/** + * @typedef {object} AnimationConfig // TODO 19/03/2018 fix type + * + * @property {AnimationFrameConfig[]} [frames] - [description] + * @property {string} [defaultTextureKey=null] - [description] + * @property {integer} [frameRate] - The frame rate of playback in frames per second (default 24 if duration is null) + * @property {integer} [duration] - How long the animation should play for. + * @property {boolean} [skipMissedFrames=true] - Skip frames if the time lags, or always advanced anyway? + * @property {integer} [delay=0] - Delay before starting playback (in seconds) + * @property {integer} [repeat=0] - Number of times to repeat the animation (-1 for infinity) + * @property {integer} [repeatDelay=0] - Delay before the repeat starts (in seconds) + * @property {boolean} [yoyo=false] - Should the animation yoyo? (reverse back down to the start) before repeating? + * @property {boolean} [showOnStart=false] - Should sprite.visible = true when the animation starts to play? + * @property {boolean} [hideOnComplete=false] - Should sprite.visible = false when the animation finishes? + * @property {object} [callbackScope] - [description] + * @property {boolean} [onStart=false] - [description] + * @property {array} [onStartParams] - [description] + * @property {boolean} [onRepeat=false] - [description] + * @property {array} [onRepeatParams] - [description] + * @property {boolean} [onUpdate=false] - [description] + * @property {array} [onUpdateParams] - [description] + * @property {boolean} [onComplete=false] - [description] + * @property {array} [onCompleteParams] - [description] + */ + +/** + * @classdesc + * A Frame based Animation. + * + * This consists of a key, some default values (like the frame rate) and a bunch of Frame objects. + * + * The Animation Manager creates these. Game Objects don't own an instance of these directly. + * Game Objects have the Animation Component, which are like playheads to global Animations (these objects) + * So multiple Game Objects can have playheads all pointing to this one Animation instance. + * + * @class Animation + * @memberOf Phaser.Animations + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationManager} manager - [description] + * @param {string} key - [description] + * @param {AnimationConfig} config - [description] + */ +var Animation = new Class({ + + initialize: + + function Animation (manager, key, config) + { + /** + * [description] + * + * @name Phaser.Animations.Animation#manager + * @type {Phaser.Animations.AnimationManager} + * @since 3.0.0 + */ + this.manager = manager; + + /** + * [description] + * + * @name Phaser.Animations.Animation#key + * @type {string} + * @since 3.0.0 + */ + this.key = key; + + /** + * A frame based animation (as opposed to a bone based animation) + * + * @name Phaser.Animations.Animation#type + * @type {string} + * @default frame + * @since 3.0.0 + */ + this.type = 'frame'; + + /** + * Extract all the frame data into the frames array + * + * @name Phaser.Animations.Animation#frames + * @type {Phaser.Animations.AnimationFrame[]} + * @since 3.0.0 + */ + this.frames = this.getFrames( + manager.textureManager, + GetValue(config, 'frames', []), + GetValue(config, 'defaultTextureKey', null) + ); + + /** + * The frame rate of playback in frames per second (default 24 if duration is null) + * + * @name Phaser.Animations.Animation#frameRate + * @type {integer} + * @default 24 + * @since 3.0.0 + */ + this.frameRate = GetValue(config, 'frameRate', null); + + /** + * How long the animation should play for. + * If frameRate is set it overrides this value otherwise frameRate is derived from duration. + * + * @name Phaser.Animations.Animation#duration + * @type {integer} + * @since 3.0.0 + */ + this.duration = GetValue(config, 'duration', null); + + if (this.duration === null && this.frameRate === null) + { + // No duration or frameRate given, use default frameRate of 24fps + this.frameRate = 24; + this.duration = this.frameRate / this.frames.length; + } + else if (this.duration && this.frameRate === null) + { + // Duration given but no frameRate, so set the frameRate based on duration + // I.e. 12 frames in the animation, duration = 4 (4000 ms) + // So frameRate is 12 / 4 = 3 fps + this.frameRate = this.frames.length / this.duration; + } + else + { + // frameRate given, derive duration from it (even if duration also specified) + // I.e. 15 frames in the animation, frameRate = 30 fps + // So duration is 15 / 30 = 0.5 (half a second) + this.duration = this.frames.length / this.frameRate; + } + + /** + * ms per frame (without including frame specific modifiers) + * + * @name Phaser.Animations.Animation#msPerFrame + * @type {integer} + * @since 3.0.0 + */ + this.msPerFrame = 1000 / this.frameRate; + + /** + * Skip frames if the time lags, or always advanced anyway? + * + * @name Phaser.Animations.Animation#skipMissedFrames + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.skipMissedFrames = GetValue(config, 'skipMissedFrames', true); + + /** + * Delay before starting playback (in seconds) + * + * @name Phaser.Animations.Animation#delay + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.delay = GetValue(config, 'delay', 0); + + /** + * Number of times to repeat the animation (-1 for infinity) + * + * @name Phaser.Animations.Animation#repeat + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.repeat = GetValue(config, 'repeat', 0); + + /** + * Delay before the repeat starts (in seconds) + * + * @name Phaser.Animations.Animation#repeatDelay + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.repeatDelay = GetValue(config, 'repeatDelay', 0); + + /** + * Should the animation yoyo? (reverse back down to the start) before repeating? + * + * @name Phaser.Animations.Animation#yoyo + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.yoyo = GetValue(config, 'yoyo', false); + + /** + * Should sprite.visible = true when the animation starts to play? + * + * @name Phaser.Animations.Animation#showOnStart + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.showOnStart = GetValue(config, 'showOnStart', false); + + /** + * Should sprite.visible = false when the animation finishes? + * + * @name Phaser.Animations.Animation#hideOnComplete + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.hideOnComplete = GetValue(config, 'hideOnComplete', false); + + /** + * [description] + * + * @name Phaser.Animations.Animation#callbackScope + * @type {object} + * @since 3.0.0 + */ + this.callbackScope = GetValue(config, 'callbackScope', this); + + /** + * [description] + * + * @name Phaser.Animations.Animation#onStart + * @type {function} + * @since 3.0.0 + */ + this.onStart = GetValue(config, 'onStart', false); + + /** + * [description] + * + * @name Phaser.Animations.Animation#onStartParams + * @type {array} + * @since 3.0.0 + */ + this.onStartParams = GetValue(config, 'onStartParams', []); + + /** + * [description] + * + * @name Phaser.Animations.Animation#onRepeat + * @type {function} + * @since 3.0.0 + */ + this.onRepeat = GetValue(config, 'onRepeat', false); + + /** + * [description] + * + * @name Phaser.Animations.Animation#onRepeatParams + * @type {array} + * @since 3.0.0 + */ + this.onRepeatParams = GetValue(config, 'onRepeatParams', []); + + /** + * Called for EVERY frame of the animation. + * See AnimationFrame.onUpdate for a frame specific callback. + * + * @name Phaser.Animations.Animation#onUpdate + * @type {function} + * @since 3.0.0 + */ + this.onUpdate = GetValue(config, 'onUpdate', false); + + /** + * [description] + * + * @name Phaser.Animations.Animation#onUpdateParams + * @type {array} + * @since 3.0.0 + */ + this.onUpdateParams = GetValue(config, 'onUpdateParams', []); + + /** + * [description] + * + * @name Phaser.Animations.Animation#onComplete + * @type {function} + * @since 3.0.0 + */ + this.onComplete = GetValue(config, 'onComplete', false); + + /** + * [description] + * + * @name Phaser.Animations.Animation#onCompleteParams + * @type {array} + * @since 3.0.0 + */ + this.onCompleteParams = GetValue(config, 'onCompleteParams', []); + + /** + * Global pause, effects all Game Objects using this Animation instance + * + * @name Phaser.Animations.Animation#paused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.paused = false; + + this.manager.on('pauseall', this.pause.bind(this)); + this.manager.on('resumeall', this.resume.bind(this)); + }, + + // Add frames to the end of the animation + + /** + * [description] + * + * @method Phaser.Animations.Animation#addFrame + * @since 3.0.0 + * + * @param {(string|AnimationFrameConfig[])} config - [description] + * + * @return {Phaser.Animations.Animation} This Animation object. + */ + addFrame: function (config) + { + return this.addFrameAt(this.frames.length, config); + }, + + // Add frame/s into the animation + + /** + * [description] + * + * @method Phaser.Animations.Animation#addFrameAt + * @since 3.0.0 + * + * @param {integer} index - [description] + * @param {(string|AnimationFrameConfig[])} config - [description] + * + * @return {Phaser.Animations.Animation} This Animation object. + */ + addFrameAt: function (index, config) + { + var newFrames = this.getFrames(this.manager.textureManager, config); + + if (newFrames.length > 0) + { + if (index === 0) + { + this.frames = newFrames.concat(this.frames); + } + else if (index === this.frames.length) + { + this.frames = this.frames.concat(newFrames); + } + else + { + var pre = this.frames.slice(0, index); + var post = this.frames.slice(index); + + this.frames = pre.concat(newFrames, post); + } + + this.updateFrameSequence(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#checkFrame + * @since 3.0.0 + * + * @param {integer} index - [description] + * + * @return {boolean} [description] + */ + checkFrame: function (index) + { + return (index < this.frames.length); + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#completeAnimation + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - [description] + */ + completeAnimation: function (component) + { + if (this.hideOnComplete) + { + component.parent.visible = false; + } + + component.stop(true); + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#getFirstTick + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - [description] + * @param {boolean} [includeDelay=true] - [description] + */ + getFirstTick: function (component, includeDelay) + { + if (includeDelay === undefined) { includeDelay = true; } + + // When is the first update due? + component.accumulator = 0; + component.nextTick = component.msPerFrame + component.currentFrame.duration; + + if (includeDelay) + { + component.nextTick += (component._delay * 1000); + } + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#getFrameAt + * @since 3.0.0 + * + * @param {integer} index - [description] + * + * @return {Phaser.Animations.AnimationFrame} [description] + */ + getFrameAt: function (index) + { + return this.frames[index]; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#getFrames + * @since 3.0.0 + * + * @param {Phaser.Textures.TextureManager} textureManager - [description] + * @param {(string|AnimationFrameConfig[])} frames - [description] + * @param {string} [defaultTextureKey] - [description] + * + * @return {Phaser.Animations.AnimationFrame[]} [description] + */ + getFrames: function (textureManager, frames, defaultTextureKey) + { + var out = []; + var prev; + var animationFrame; + var index = 1; + var i; + var textureKey; + + // if frames is a string, we'll get all the frames from the texture manager as if it's a sprite sheet + if (typeof frames === 'string') + { + textureKey = frames; + + var texture = textureManager.get(textureKey); + var frameKeys = texture.getFrameNames(); + + frames = []; + + frameKeys.forEach(function (idx, value) + { + frames.push({ key: textureKey, frame: value }); + }); + } + + if (!Array.isArray(frames) || frames.length === 0) + { + return out; + } + + for (i = 0; i < frames.length; i++) + { + var item = frames[i]; + + var key = GetValue(item, 'key', defaultTextureKey); + + if (!key) + { + continue; + } + + // Could be an integer or a string + var frame = GetValue(item, 'frame', 0); + + // The actual texture frame + var textureFrame = textureManager.getFrame(key, frame); + + animationFrame = new Frame(key, frame, index, textureFrame); + + animationFrame.duration = GetValue(item, 'duration', 0); + animationFrame.onUpdate = GetValue(item, 'onUpdate', null); + + animationFrame.isFirst = (!prev); + + // The previously created animationFrame + if (prev) + { + prev.nextFrame = animationFrame; + + animationFrame.prevFrame = prev; + } + + out.push(animationFrame); + + prev = animationFrame; + + index++; + } + + if (out.length > 0) + { + animationFrame.isLast = true; + + // Link them end-to-end, so they loop + animationFrame.nextFrame = out[0]; + + out[0].prevFrame = animationFrame; + + // Generate the progress data + + var slice = 1 / (out.length - 1); + + for (i = 0; i < out.length; i++) + { + out[i].progress = i * slice; + } + } + + return out; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#getNextTick + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - [description] + */ + getNextTick: function (component) + { + // accumulator += delta * _timeScale + // after a large delta surge (perf issue for example) we need to adjust for it here + + // When is the next update due? + component.accumulator -= component.nextTick; + + component.nextTick = component.msPerFrame + component.currentFrame.duration; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#load + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - [description] + * @param {integer} startFrame - [description] + */ + load: function (component, startFrame) + { + if (startFrame >= this.frames.length) + { + startFrame = 0; + } + + if (component.currentAnim !== this) + { + component.currentAnim = this; + + component._timeScale = 1; + component.frameRate = this.frameRate; + component.duration = this.duration; + component.msPerFrame = this.msPerFrame; + component.skipMissedFrames = this.skipMissedFrames; + component._delay = this.delay; + component._repeat = this.repeat; + component._repeatDelay = this.repeatDelay; + component._yoyo = this.yoyo; + component._callbackArgs[1] = this; + component._updateParams = component._callbackArgs.concat(this.onUpdateParams); + } + + component.updateFrame(this.frames[startFrame]); + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#nextFrame + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - [description] + */ + nextFrame: function (component) + { + var frame = component.currentFrame; + + // TODO: Add frame skip support + + if (frame.isLast) + { + // We're at the end of the animation + + // Yoyo? (happens before repeat) + if (this.yoyo) + { + component.forward = false; + + component.updateFrame(frame.prevFrame); + + // Delay for the current frame + this.getNextTick(component); + } + else if (component.repeatCounter > 0) + { + // Repeat (happens before complete) + this.repeatAnimation(component); + } + else + { + this.completeAnimation(component); + } + } + else + { + component.updateFrame(frame.nextFrame); + + this.getNextTick(component); + } + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#previousFrame + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - [description] + */ + previousFrame: function (component) + { + var frame = component.currentFrame; + + // TODO: Add frame skip support + + if (frame.isFirst) + { + // We're at the start of the animation + + if (component.repeatCounter > 0) + { + // Repeat (happens before complete) + this.repeatAnimation(component); + } + else + { + this.completeAnimation(component); + } + } + else + { + component.updateFrame(frame.prevFrame); + + this.getNextTick(component); + } + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#removeFrame + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationFrame} frame - [description] + * + * @return {Phaser.Animations.Animation} This Animation object. + */ + removeFrame: function (frame) + { + var index = this.frames.indexOf(frame); + + if (index !== -1) + { + this.removeFrameAt(index); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#removeFrameAt + * @since 3.0.0 + * + * @param {integer} index - [description] + * + * @return {Phaser.Animations.Animation} This Animation object. + */ + removeFrameAt: function (index) + { + this.frames.splice(index, 1); + + this.updateFrameSequence(); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#repeatAnimation + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - [description] + */ + repeatAnimation: function (component) + { + if (component._repeatDelay > 0 && component.pendingRepeat === false) + { + component.pendingRepeat = true; + component.accumulator -= component.nextTick; + component.nextTick += (component._repeatDelay * 1000); + } + else + { + component.repeatCounter--; + + component.forward = true; + + component.updateFrame(component.currentFrame.nextFrame); + + this.getNextTick(component); + + component.pendingRepeat = false; + + if (this.onRepeat) + { + this.onRepeat.apply(this.callbackScope, component._callbackArgs.concat(this.onRepeatParams)); + } + } + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#setFrame + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - [description] + */ + setFrame: function (component) + { + // Work out which frame should be set next on the child, and set it + if (component.forward) + { + this.nextFrame(component); + } + else + { + this.previousFrame(component); + } + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#toJSON + * @since 3.0.0 + * + * @return {JSONAnimation} [description] + */ + toJSON: function () + { + var output = { + key: this.key, + type: this.type, + frames: [], + frameRate: this.frameRate, + duration: this.duration, + skipMissedFrames: this.skipMissedFrames, + delay: this.delay, + repeat: this.repeat, + repeatDelay: this.repeatDelay, + yoyo: this.yoyo, + showOnStart: this.showOnStart, + hideOnComplete: this.hideOnComplete + }; + + this.frames.forEach(function (frame) + { + output.frames.push(frame.toJSON()); + }); + + return output; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#updateFrameSequence + * @since 3.0.0 + * + * @return {Phaser.Animations.Animation} This Animation object. + */ + updateFrameSequence: function () + { + var len = this.frames.length; + var slice = 1 / (len - 1); + + for (var i = 0; i < len; i++) + { + var frame = this.frames[i]; + + frame.index = i + 1; + frame.isFirst = false; + frame.isLast = false; + frame.progress = i * slice; + + if (i === 0) + { + frame.isFirst = true; + frame.isLast = (len === 1); + frame.prevFrame = this.frames[len - 1]; + frame.nextFrame = this.frames[i + 1]; + } + else if (i === len - 1) + { + frame.isLast = true; + frame.prevFrame = this.frames[len - 2]; + frame.nextFrame = this.frames[0]; + } + else if (len > 1) + { + frame.prevFrame = this.frames[i - 1]; + frame.nextFrame = this.frames[i + 1]; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#pause + * @since 3.0.0 + * + * @return {Phaser.Animations.Animation} This Animation object. + */ + pause: function () + { + this.paused = true; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#resume + * @since 3.0.0 + * + * @return {Phaser.Animations.Animation} This Animation object. + */ + resume: function () + { + this.paused = false; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#destroy + * @since 3.0.0 + */ + destroy: function () + { + // TODO + } + +}); + +module.exports = Animation; + + +/***/ }), +/* 342 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.SmoothStep + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} min - [description] + * @param {number} max - [description] + * + * @return {number} [description] + */ +var SmoothStep = function (x, min, max) +{ + x = Math.max(0, Math.min(1, (x - min) / (max - min))); + + return x * x * (3 - 2 * x); +}; + +module.exports = SmoothStep; + + +/***/ }), +/* 343 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.SmootherStep + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} min - [description] + * @param {number} max - [description] + * + * @return {number} [description] + */ +var SmootherStep = function (x, min, max) +{ + x = Math.max(0, Math.min(1, (x - min) / (max - min))); + + return x * x * x * (x * (x * 6 - 15) + 10); +}; + +module.exports = SmootherStep; + + +/***/ }), +/* 344 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Using Bresenham's line algorithm this will return an array of all coordinates on this line. + * The start and end points are rounded before this runs as the algorithm works on integers. + * + * @function Phaser.Geom.Line.BresenhamPoints + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {integer} [stepRate=1] - [description] + * @param {array} [results] - [description] + * + * @return {array} [description] + */ +var BresenhamPoints = function (line, stepRate, results) +{ + if (stepRate === undefined) { stepRate = 1; } + if (results === undefined) { results = []; } + + var x1 = Math.round(line.x1); + var y1 = Math.round(line.y1); + var x2 = Math.round(line.x2); + var y2 = Math.round(line.y2); + + var dx = Math.abs(x2 - x1); + var dy = Math.abs(y2 - y1); + var sx = (x1 < x2) ? 1 : -1; + var sy = (y1 < y2) ? 1 : -1; + var err = dx - dy; + + results.push({ x: x1, y: y1 }); + + var i = 1; + + while (!((x1 === x2) && (y1 === y2))) + { + var e2 = err << 1; + + if (e2 > -dy) + { + err -= dy; + x1 += sx; + } + + if (e2 < dx) + { + err += dx; + y1 += sy; + } + + if (i % stepRate === 0) + { + results.push({ x: x1, y: y1 }); + } + + i++; + } + + return results; +}; + +module.exports = BresenhamPoints; + + +/***/ }), +/* 345 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Moves the element at the end of the array to the start, shifting all items in the process. + * The "rotation" happens to the right. + * + * @function Phaser.Utils.Array.RotateRight + * @since 3.0.0 + * + * @param {array} array - The array to shift to the right. This array is modified in place. + * @param {integer} [total=1] - The number of times to shift the array. + * + * @return {*} The most recently shifted element. + */ +var RotateRight = function (array, total) +{ + if (total === undefined) { total = 1; } + + var element = null; + + for (var i = 0; i < total; i++) + { + element = array.pop(); + array.unshift(element); + } + + return element; +}; + +module.exports = RotateRight; + + +/***/ }), +/* 346 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Moves the element at the start of the array to the end, shifting all items in the process. + * The "rotation" happens to the left. + * + * @function Phaser.Utils.Array.RotateLeft + * @since 3.0.0 + * + * @param {array} array - The array to shift to the left. This array is modified in place. + * @param {integer} [total=1] - The number of times to shift the array. + * + * @return {*} The most recently shifted element. + */ +var RotateLeft = function (array, total) +{ + if (total === undefined) { total = 1; } + + var element = null; + + for (var i = 0; i < total; i++) + { + element = array.shift(); + array.push(element); + } + + return element; +}; + +module.exports = RotateLeft; + + +/***/ }), +/* 347 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Perimeter = __webpack_require__(105); +var Point = __webpack_require__(4); + +// Return an array of points from the perimeter of the rectangle +// each spaced out based on the quantity or step required + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.MarchingAnts + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} step - [description] + * @param {integer} quantity - [description] + * @param {array} [out] - [description] + * + * @return {Phaser.Geom.Point[]} [description] + */ +var MarchingAnts = function (rect, step, quantity, out) +{ + if (out === undefined) { out = []; } + + if (!step && !quantity) + { + // Bail out + return out; + } + + // If step is a falsey value (false, null, 0, undefined, etc) then we calculate + // it based on the quantity instead, otherwise we always use the step value + if (!step) + { + step = Perimeter(rect) / quantity; + } + else + { + quantity = Math.round(Perimeter(rect) / step); + } + + var x = rect.x; + var y = rect.y; + var face = 0; + + // Loop across each face of the rectangle + + for (var i = 0; i < quantity; i++) + { + out.push(new Point(x, y)); + + switch (face) + { + + // Top face + case 0: + x += step; + + if (x >= rect.right) + { + face = 1; + y += (x - rect.right); + x = rect.right; + } + break; + + // Right face + case 1: + y += step; + + if (y >= rect.bottom) + { + face = 2; + x -= (y - rect.bottom); + y = rect.bottom; + } + break; + + // Bottom face + case 2: + x -= step; + + if (x <= rect.left) + { + face = 3; + y -= (rect.left - x); + x = rect.left; + } + break; + + // Left face + case 3: + y -= step; + + if (y <= rect.top) + { + face = 0; + y = rect.top; + } + break; + } + } + + return out; +}; + +module.exports = MarchingAnts; + + +/***/ }), +/* 348 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * [description] + * + * @class TransformMatrix + * @memberOf Phaser.GameObjects.Components + * @constructor + * @since 3.0.0 + * + * @param {number} [a=1] - [description] + * @param {number} [b=0] - [description] + * @param {number} [c=0] - [description] + * @param {number} [d=1] - [description] + * @param {number} [tx=0] - [description] + * @param {number} [ty=0] - [description] + */ +var TransformMatrix = new Class({ + + initialize: + + function TransformMatrix (a, b, c, d, tx, ty) + { + if (a === undefined) { a = 1; } + if (b === undefined) { b = 0; } + if (c === undefined) { c = 0; } + if (d === undefined) { d = 1; } + if (tx === undefined) { tx = 0; } + if (ty === undefined) { ty = 0; } + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TransformMatrix#matrix + * @type {Float32Array} + * @since 3.0.0 + */ + this.matrix = new Float32Array([ a, b, c, d, tx, ty, 0, 0, 1 ]); + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TransformMatrix#decomposedMatrix + * @type {object} + * @since 3.0.0 + */ + this.decomposedMatrix = { + translateX: 0, + translateY: 0, + scaleX: 1, + scaleY: 1, + rotation: 0 + }; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TransformMatrix#loadIdentity + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. + */ + loadIdentity: function () + { + var matrix = this.matrix; + + matrix[0] = 1; + matrix[1] = 0; + matrix[2] = 0; + matrix[3] = 1; + matrix[4] = 0; + matrix[5] = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TransformMatrix#translate + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. + */ + translate: function (x, y) + { + var matrix = this.matrix; + + matrix[4] = matrix[0] * x + matrix[2] * y + matrix[4]; + matrix[5] = matrix[1] * x + matrix[3] * y + matrix[5]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TransformMatrix#scale + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. + */ + scale: function (x, y) + { + var matrix = this.matrix; + + matrix[0] *= x; + matrix[1] *= x; + matrix[2] *= y; + matrix[3] *= y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TransformMatrix#rotate + * @since 3.0.0 + * + * @param {number} radian - [description] + * + * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. + */ + rotate: function (radian) + { + var radianSin = Math.sin(radian); + var radianCos = Math.cos(radian); + + return this.transform(radianCos, radianSin, -radianSin, radianCos, 0, 0); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TransformMatrix#multiply + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} rhs - [description] + * + * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. + */ + multiply: function (rhs) + { + var matrix = this.matrix; + var otherMatrix = rhs.matrix; + + var a0 = matrix[0]; + var b0 = matrix[1]; + var c0 = matrix[2]; + var d0 = matrix[3]; + var tx0 = matrix[4]; + var ty0 = matrix[5]; + + var a1 = otherMatrix[0]; + var b1 = otherMatrix[1]; + var c1 = otherMatrix[2]; + var d1 = otherMatrix[3]; + var tx1 = otherMatrix[4]; + var ty1 = otherMatrix[5]; + + matrix[0] = a1 * a0 + b1 * c0; + matrix[1] = a1 * b0 + b1 * d0; + matrix[2] = c1 * a0 + d1 * c0; + matrix[3] = c1 * b0 + d1 * d0; + matrix[4] = tx1 * a0 + ty1 * c0 + tx0; + matrix[5] = tx1 * b0 + ty1 * d0 + ty0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TransformMatrix#transform + * @since 3.0.0 + * + * @param {number} a - [description] + * @param {number} b - [description] + * @param {number} c - [description] + * @param {number} d - [description] + * @param {number} tx - [description] + * @param {number} ty - [description] + * + * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. + */ + transform: function (a, b, c, d, tx, ty) + { + var matrix = this.matrix; + + var a0 = matrix[0]; + var b0 = matrix[1]; + var c0 = matrix[2]; + var d0 = matrix[3]; + var tx0 = matrix[4]; + var ty0 = matrix[5]; + + matrix[0] = a * a0 + b * c0; + matrix[1] = a * b0 + b * d0; + matrix[2] = c * a0 + d * c0; + matrix[3] = c * b0 + d * d0; + matrix[4] = tx * a0 + ty * c0 + tx0; + matrix[5] = tx * b0 + ty * d0 + ty0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TransformMatrix#transformPoint + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} point - [description] + * + * @return {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} [description] + */ + transformPoint: function (x, y, point) + { + if (point === undefined) { point = { x: 0, y: 0 }; } + + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + var tx = matrix[4]; + var ty = matrix[5]; + + point.x = x * a + y * c + tx; + point.y = x * b + y * d + ty; + + return point; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TransformMatrix#invert + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. + */ + invert: function () + { + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + var tx = matrix[4]; + var ty = matrix[5]; + + var n = a * d - b * c; + + matrix[0] = d / n; + matrix[1] = -b / n; + matrix[2] = -c / n; + matrix[3] = a / n; + matrix[4] = (c * ty - d * tx) / n; + matrix[5] = -(a * ty - b * tx) / n; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TransformMatrix#setTransform + * @since 3.0.0 + * + * @param {number} a - [description] + * @param {number} b - [description] + * @param {number} c - [description] + * @param {number} d - [description] + * @param {number} tx - [description] + * @param {number} ty - [description] + * + * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. + */ + setTransform: function (a, b, c, d, tx, ty) + { + var matrix = this.matrix; + + matrix[0] = a; + matrix[1] = b; + matrix[2] = c; + matrix[3] = d; + matrix[4] = tx; + matrix[5] = ty; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TransformMatrix#decomposeMatrix + * @since 3.0.0 + * + * @return {object} [description] + */ + decomposeMatrix: function () + { + var decomposedMatrix = this.decomposedMatrix; + + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + + var a2 = a * a; + var b2 = b * b; + var c2 = c * c; + var d2 = d * d; + + var sx = Math.sqrt(a2 + c2); + var sy = Math.sqrt(b2 + d2); + + decomposedMatrix.translateX = matrix[4]; + decomposedMatrix.translateY = matrix[5]; + + decomposedMatrix.scaleX = sx; + decomposedMatrix.scaleY = sy; + + decomposedMatrix.rotation = Math.acos(a / sx) * (Math.atan(-c / a) < 0 ? -1 : 1); + + return decomposedMatrix; + }, + + /** + * Identity + Translate + Rotate + Scale + * + * @method Phaser.GameObjects.Components.TransformMatrix#applyITRS + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} rotation - [description] + * @param {number} scaleX - [description] + * @param {number} scaleY - [description] + * + * @return {Phaser.GameObjects.Components.TransformMatrix} This TransformMatrix. + */ + applyITRS: function (x, y, rotation, scaleX, scaleY) + { + var matrix = this.matrix; + + var sr = Math.sin(rotation); + var cr = Math.cos(rotation); + + // Translate + matrix[4] = x; + matrix[5] = y; + + // Rotate and Scale + matrix[0] = cr * scaleX; + matrix[1] = -sr * scaleX; + matrix[2] = sr * scaleY; + matrix[3] = cr * scaleY; + + return this; + } + +}); + +module.exports = TransformMatrix; + + +/***/ }), +/* 349 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for setting the WebGL rendering pipeline of a Game Object. + * + * @name Phaser.GameObjects.Components.Pipeline + * @webglOnly + * @since 3.0.0 + */ + +var Pipeline = { + + /** + * [description] + * + * @name Phaser.GameObjects.Components.Pipeline#defaultPipeline + * @type {Phaser.Renderer.WebGL.WebGLPipeline} + * @default null + * @webglOnly + * @since 3.0.0 + */ + defaultPipeline: null, + + /** + * [description] + * + * @name Phaser.GameObjects.Components.Pipeline#pipeline + * @type {Phaser.Renderer.WebGL.WebGLPipeline} + * @default null + * @webglOnly + * @since 3.0.0 + */ + pipeline: null, + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * + * @method Phaser.GameObjects.Components.Pipeline#initPipeline + * @webglOnly + * @since 3.0.0 + * + * @param {string} pipelineName - The name of the pipeline to set on this Game Object. + * + * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. + */ + initPipeline: function (pipelineName) + { + var renderer = this.scene.sys.game.renderer; + + if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) + { + this.defaultPipeline = renderer.getPipeline(pipelineName); + this.pipeline = this.defaultPipeline; + + return true; + } + + return false; + }, + + /** + * Sets the active WebGL Pipeline of this Game Object. + * + * @method Phaser.GameObjects.Components.Pipeline#setPipeline + * @webglOnly + * @since 3.0.0 + * + * @param {string} pipelineName - The name of the pipeline to set on this Game Object. + * + * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. + */ + setPipeline: function (pipelineName) + { + var renderer = this.scene.sys.game.renderer; + + if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) + { + this.pipeline = renderer.getPipeline(pipelineName); + + return true; + } + + return false; + }, + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + * + * @method Phaser.GameObjects.Components.Pipeline#resetPipeline + * @webglOnly + * @since 3.0.0 + * + * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. + */ + resetPipeline: function () + { + this.pipeline = this.defaultPipeline; + + return (this.pipeline !== null); + }, + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + * + * @method Phaser.GameObjects.Components.Pipeline#getPipelineName + * @webglOnly + * @since 3.0.0 + * + * @return {string} The string-based name of the pipeline being used by this Game Object. + */ + getPipelineName: function () + { + return this.pipeline.name; + } + +}; + +module.exports = Pipeline; + + +/***/ }), +/* 350 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.RotateAround + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} angle - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var RotateAround = function (point, x, y, angle) +{ + var c = Math.cos(angle); + var s = Math.sin(angle); + + var tx = point.x - x; + var ty = point.y - y; + + point.x = tx * c - ty * s + x; + point.y = tx * s + ty * c + y; + + return point; +}; + +module.exports = RotateAround; + + +/***/ }), +/* 351 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); // Get a point on the given line 'progress' percentage along its length. // progress is a value between 0 and 1. @@ -60261,9 +76282,9 @@ var Point = __webpack_require__(5); * * @param {Phaser.Geom.Line} line - [description] * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. - * @param {Phaser.Geom.Point|object} [out] - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] * - * @return {Phaser.Geom.Point|object} [description] + * @return {(Phaser.Geom.Point|object)} [description] */ var GetPoint = function (line, position, out) { @@ -60278,9004 +76299,6 @@ var GetPoint = function (line, position, out) module.exports = GetPoint; -/***/ }), -/* 303 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH_CONST = __webpack_require__(16); -var Wrap = __webpack_require__(50); -var Angle = __webpack_require__(55); - -/** - * [description] - * - * @function Phaser.Geom.Line.NormalAngle - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var NormalAngle = function (line) -{ - var angle = Angle(line) - MATH_CONST.TAU; - - return Wrap(angle, -Math.PI, Math.PI); -}; - -module.exports = NormalAngle; - - -/***/ }), -/* 304 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.GetMagnitude - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} point - [description] - * - * @return {number} [description] - */ -var GetMagnitude = function (point) -{ - return Math.sqrt((point.x * point.x) + (point.y * point.y)); -}; - -module.exports = GetMagnitude; - - -/***/ }), -/* 305 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.GetMagnitudeSq - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} point - [description] - * - * @return {number} [description] - */ -var GetMagnitudeSq = function (point) -{ - return (point.x * point.x) + (point.y * point.y); -}; - -module.exports = GetMagnitudeSq; - - -/***/ }), -/* 306 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Contains = __webpack_require__(147); - -/** - * @classdesc - * [description] - * - * @class Polygon - * @memberOf Phaser.Geom - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Geom.Point[]} [points] - [description] - */ -var Polygon = new Class({ - - initialize: - - function Polygon (points) - { - /** - * The area of this Polygon. - * - * @name Phaser.Geom.Polygon#area - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.area = 0; - - /** - * An array of number pair objects that make up this polygon. I.e. [ {x,y}, {x,y}, {x,y} ] - * - * @name Phaser.Geom.Polygon#points - * @type {Phaser.Geom.Point[]} - * @since 3.0.0 - */ - this.points = []; - - if (points) - { - this.setTo(points); - } - }, - - /** - * [description] - * - * @method Phaser.Geom.Polygon#contains - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - contains: function (x, y) - { - return Contains(this, x, y); - }, - - /** - * Sets this Polygon to the given points. - * - * The points can be set from a variety of formats: - * - * - An array of Point objects: `[new Phaser.Point(x1, y1), ...]` - * - An array of objects with public x/y properties: `[obj1, obj2, ...]` - * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` - * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` - * - * `setTo` may also be called without any arguments to remove all points. - * - * @method Phaser.Geom.Polygon#setTo - * @since 3.0.0 - * - * @param {[type]} points - [description] - * - * @return {Phaser.Geom.Polygon} This Polygon object. - */ - setTo: function (points) - { - this.area = 0; - this.points = []; - - if (!Array.isArray(points)) - { - return this; - } - - var entry; - var y0 = Number.MAX_VALUE; - var p; - - // The points argument is an array, so iterate through it - for (var i = 0; i < points.length; i++) - { - p = { x: 0, y: 0 }; - - if (typeof points[i] === 'number') - { - p.x = points[i]; - p.y = points[i + 1]; - i++; - } - else if (Array.isArray(entry)) - { - // An array of arrays? - p.x = points[i][0]; - p.y = points[i][1]; - } - else - { - p.x = points[i].x; - p.y = points[i].y; - } - - this.points.push(p); - - // Lowest boundary - if (p.y < y0) - { - y0 = p.y; - } - } - - this.calculateArea(y0); - - return this; - }, - - /** - * Calculates the area of the Polygon. This is available in the property Polygon.area - * - * @method Phaser.Geom.Polygon#calculateArea - * @since 3.0.0 - * - * @return {number} [description] - */ - calculateArea: function () - { - if (this.points.length < 3) - { - this.area = 0; - - return this.area; - } - - var sum = 0; - var p1; - var p2; - - for (var i = 0; i < this.points.length - 1; i++) - { - p1 = this.points[i]; - p2 = this.points[i + 1]; - - sum += (p2.x - p1.x) * (p1.y + p2.y); - } - - p1 = this.points[0]; - p2 = this.points[this.points.length - 1]; - - sum += (p1.x - p2.x) * (p2.y + p1.y); - - this.area = -sum * 0.5; - - return this.area; - } - -}); - -module.exports = Polygon; - - -/***/ }), -/* 307 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(8); - -Rectangle.Area = __webpack_require__(722); -Rectangle.Ceil = __webpack_require__(723); -Rectangle.CeilAll = __webpack_require__(724); -Rectangle.CenterOn = __webpack_require__(308); -Rectangle.Clone = __webpack_require__(725); -Rectangle.Contains = __webpack_require__(33); -Rectangle.ContainsPoint = __webpack_require__(726); -Rectangle.ContainsRect = __webpack_require__(727); -Rectangle.CopyFrom = __webpack_require__(728); -Rectangle.Decompose = __webpack_require__(299); -Rectangle.Equals = __webpack_require__(729); -Rectangle.FitInside = __webpack_require__(730); -Rectangle.FitOutside = __webpack_require__(731); -Rectangle.Floor = __webpack_require__(732); -Rectangle.FloorAll = __webpack_require__(733); -Rectangle.FromPoints = __webpack_require__(122); -Rectangle.GetAspectRatio = __webpack_require__(148); -Rectangle.GetCenter = __webpack_require__(734); -Rectangle.GetPoint = __webpack_require__(107); -Rectangle.GetPoints = __webpack_require__(187); -Rectangle.GetSize = __webpack_require__(735); -Rectangle.Inflate = __webpack_require__(736); -Rectangle.MarchingAnts = __webpack_require__(191); -Rectangle.MergePoints = __webpack_require__(737); -Rectangle.MergeRect = __webpack_require__(738); -Rectangle.MergeXY = __webpack_require__(739); -Rectangle.Offset = __webpack_require__(740); -Rectangle.OffsetPoint = __webpack_require__(741); -Rectangle.Overlaps = __webpack_require__(742); -Rectangle.Perimeter = __webpack_require__(78); -Rectangle.PerimeterPoint = __webpack_require__(743); -Rectangle.Random = __webpack_require__(108); -Rectangle.Scale = __webpack_require__(744); -Rectangle.Union = __webpack_require__(745); - -module.exports = Rectangle; - - -/***/ }), -/* 308 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Centers this Rectangle so that the center coordinates match the given x and y values. - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.CenterOn - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var CenterOn = function (rect, x, y) -{ - rect.x = x - (rect.width / 2); - rect.y = y - (rect.height / 2); - - return rect; -}; - -module.exports = CenterOn; - - -/***/ }), -/* 309 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); -var Length = __webpack_require__(66); - -// Position is a value between 0 and 1 -/** - * [description] - * - * @function Phaser.Geom.Triangle.GetPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {float} position - [description] - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ -var GetPoint = function (triangle, position, out) -{ - if (out === undefined) { out = new Point(); } - - var line1 = triangle.getLineA(); - var line2 = triangle.getLineB(); - var line3 = triangle.getLineC(); - - if (position <= 0 || position >= 1) - { - out.x = line1.x1; - out.y = line1.y1; - - return out; - } - - var length1 = Length(line1); - var length2 = Length(line2); - var length3 = Length(line3); - - var perimeter = length1 + length2 + length3; - - var p = perimeter * position; - var localPosition = 0; - - // Which line is it on? - - if (p < length1) - { - // Line 1 - localPosition = p / length1; - - out.x = line1.x1 + (line1.x2 - line1.x1) * localPosition; - out.y = line1.y1 + (line1.y2 - line1.y1) * localPosition; - } - else if (p > length1 + length2) - { - // Line 3 - p -= length1 + length2; - localPosition = p / length3; - - out.x = line3.x1 + (line3.x2 - line3.x1) * localPosition; - out.y = line3.y1 + (line3.y2 - line3.y1) * localPosition; - } - else - { - // Line 2 - p -= length1; - localPosition = p / length2; - - out.x = line2.x1 + (line2.x2 - line2.x1) * localPosition; - out.y = line2.y1 + (line2.y2 - line2.y1) * localPosition; - } - - return out; -}; - -module.exports = GetPoint; - - -/***/ }), -/* 310 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Length = __webpack_require__(66); -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Triangle.GetPoints - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {integer} quantity - [description] - * @param {number} stepRate - [description] - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ -var GetPoints = function (triangle, quantity, stepRate, out) -{ - if (out === undefined) { out = []; } - - var line1 = triangle.getLineA(); - var line2 = triangle.getLineB(); - var line3 = triangle.getLineC(); - - var length1 = Length(line1); - var length2 = Length(line2); - var length3 = Length(line3); - - var perimeter = length1 + length2 + length3; - - // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. - if (!quantity) - { - quantity = perimeter / stepRate; - } - - for (var i = 0; i < quantity; i++) - { - var p = perimeter * (i / quantity); - var localPosition = 0; - - var point = new Point(); - - // Which line is it on? - - if (p < length1) - { - // Line 1 - localPosition = p / length1; - - point.x = line1.x1 + (line1.x2 - line1.x1) * localPosition; - point.y = line1.y1 + (line1.y2 - line1.y1) * localPosition; - } - else if (p > length1 + length2) - { - // Line 3 - p -= length1 + length2; - localPosition = p / length3; - - point.x = line3.x1 + (line3.x2 - line3.x1) * localPosition; - point.y = line3.y1 + (line3.y2 - line3.y1) * localPosition; - } - else - { - // Line 2 - p -= length1; - localPosition = p / length2; - - point.x = line2.x1 + (line2.x2 - line2.x1) * localPosition; - point.y = line2.y1 + (line2.y2 - line2.y1) * localPosition; - } - - out.push(point); - } - - return out; -}; - -module.exports = GetPoints; - - -/***/ }), -/* 311 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -// The three medians (the lines drawn from the vertices to the bisectors of the opposite sides) -// meet in the centroid or center of mass (center of gravity). -// The centroid divides each median in a ratio of 2:1 - -/** - * [description] - * - * @function Phaser.Geom.Triangle.Centroid - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point|object} [out] - [description] - * - * @return {Phaser.Geom.Point|object} [description] - */ -var Centroid = function (triangle, out) -{ - if (out === undefined) { out = new Point(); } - - out.x = (triangle.x1 + triangle.x2 + triangle.x3) / 3; - out.y = (triangle.y1 + triangle.y2 + triangle.y3) / 3; - - return out; -}; - -module.exports = Centroid; - - -/***/ }), -/* 312 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Triangle.Offset - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Geom.Triangle} [description] - */ -var Offset = function (triangle, x, y) -{ - triangle.x1 += x; - triangle.y1 += y; - - triangle.x2 += x; - triangle.y2 += y; - - triangle.x3 += x; - triangle.y3 += y; - - return triangle; -}; - -module.exports = Offset; - - -/***/ }), -/* 313 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -// The three angle bisectors of a triangle meet in one point called the incenter. -// It is the center of the incircle, the circle inscribed in the triangle. - -function getLength (x1, y1, x2, y2) -{ - var x = x1 - x2; - var y = y1 - y2; - var magnitude = (x * x) + (y * y); - - return Math.sqrt(magnitude); -} - -/** - * [description] - * - * @function Phaser.Geom.Triangle.InCenter - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var InCenter = function (triangle, out) -{ - if (out === undefined) { out = new Point(); } - - var x1 = triangle.x1; - var y1 = triangle.y1; - - var x2 = triangle.x2; - var y2 = triangle.y2; - - var x3 = triangle.x3; - var y3 = triangle.y3; - - var d1 = getLength(x3, y3, x2, y2); - var d2 = getLength(x1, y1, x3, y3); - var d3 = getLength(x2, y2, x1, y1); - - var p = d1 + d2 + d3; - - out.x = (x1 * d1 + x2 * d2 + x3 * d3) / p; - out.y = (y1 * d1 + y2 * d2 + y3 * d3) / p; - - return out; -}; - -module.exports = InCenter; - - -/***/ }), -/* 314 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Phaser.Input.InteractiveObject - -var InteractiveObject = function (gameObject, hitArea, hitAreaCallback) -{ - return { - - gameObject: gameObject, - - enabled: true, - draggable: false, - dropZone: false, - - target: null, - - camera: null, - - hitArea: hitArea, - hitAreaCallback: hitAreaCallback, - - localX: 0, - localY: 0, - - // 0 = Not being dragged - // 1 = Being checked for dragging - // 2 = Being dragged - dragState: 0, - - dragStartX: 0, - dragStartY: 0, - - dragX: 0, - dragY: 0 - - }; -}; - -module.exports = InteractiveObject; - - -/***/ }), -/* 315 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MergeXHRSettings = __webpack_require__(151); - -/** - * Creates a new XMLHttpRequest (xhr) object based on the given File and XHRSettings - * and starts the download of it. It uses the Files own XHRSettings and merges them - * with the global XHRSettings object to set the xhr values before download. - * - * @function Phaser.Loader.XHRLoader - * @since 3.0.0 - * - * @param {Phaser.Loader.File} file - The File to download. - * @param {Phaser.Loader.XHRSettings} globalXHRSettings - The global XHRSettings object. - * - * @return {XMLHttpRequest} The XHR object. - */ -var XHRLoader = function (file, globalXHRSettings) -{ - var config = MergeXHRSettings(globalXHRSettings, file.xhrSettings); - - var xhr = new XMLHttpRequest(); - - xhr.open('GET', file.src, config.async, config.user, config.password); - - xhr.responseType = file.xhrSettings.responseType; - xhr.timeout = config.timeout; - - if (config.header && config.headerValue) - { - xhr.setRequestHeader(config.header, config.headerValue); - } - - if (config.overrideMimeType) - { - xhr.overrideMimeType(config.overrideMimeType); - } - - // After a successful request, the xhr.response property will contain the requested data as a DOMString, ArrayBuffer, Blob, or Document (depending on what was set for responseType.) - - xhr.onload = file.onLoad.bind(file); - xhr.onerror = file.onError.bind(file); - xhr.onprogress = file.onProgress.bind(file); - - // This is the only standard method, the ones above are browser additions (maybe not universal?) - // xhr.onreadystatechange - - xhr.send(); - - return xhr; -}; - -module.exports = XHRLoader; - - -/***/ }), -/* 316 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(19); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(2); -var HTML5AudioFile = __webpack_require__(317); - -/** - * @classdesc - * [description] - * - * @class AudioFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {object} xhrSettings - [description] - * @param {[type]} audioContext - [description] - */ -var AudioFile = new Class({ - - Extends: File, - - initialize: - - function AudioFile (key, url, path, xhrSettings, audioContext) - { - /** - * [description] - * - * @property {[type]} context - * @since 3.0.0 - */ - this.context = audioContext; - - var fileConfig = { - type: 'audio', - extension: GetFastValue(url, 'type', ''), - responseType: 'arraybuffer', - key: key, - url: GetFastValue(url, 'uri', url), - path: path, - xhrSettings: xhrSettings - }; - - File.call(this, fileConfig); - }, - - /** - * [description] - * - * @method Phaser.Loader.FileTypes.AudioFile#onProcess - * @since 3.0.0 - * - * @param {[type]} callback - [description] - */ - onProcess: function (callback) - { - this.state = CONST.FILE_PROCESSING; - - var _this = this; - - // interesting read https://github.com/WebAudio/web-audio-api/issues/1305 - this.context.decodeAudioData(this.xhrLoader.response, - function (audioBuffer) - { - _this.data = audioBuffer; - - _this.onComplete(); - - callback(_this); - }, - function (e) - { - // eslint-disable-next-line no-console - console.error('Error with decoding audio data for \'' + this.key + '\':', e.message); - - _this.state = CONST.FILE_ERRORED; - - callback(_this); - } - ); - - this.context = null; - } - -}); - -AudioFile.create = function (loader, key, urls, config, xhrSettings) -{ - var game = loader.systems.game; - var audioConfig = game.config.audio; - var deviceAudio = game.device.audio; - - if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) - { - // console.info('Skipping loading audio \'' + key + '\' since sounds are disabled.'); - return null; - } - - var url = AudioFile.findAudioURL(game, urls); - - if (!url) - { - // console.warn('No supported url provided for audio \'' + key + '\'!'); - return null; - } - - if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio)) - { - return new AudioFile(key, url, loader.path, xhrSettings, game.sound.context); - } - else - { - return new HTML5AudioFile(key, url, loader.path, config, game.sound.locked); - } -}; - -/** - * Adds an Audio file to the current load queue. - * - * Note: This method will only be available if the Audio File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#audio - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string|string[]} urls - [description] - * @param {object} config - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('audio', function (key, urls, config, xhrSettings) -{ - var audioFile = AudioFile.create(this, key, urls, config, xhrSettings); - - if (audioFile) - { - this.addFile(audioFile); - } - - return this; -}); - -// this.load.audio('sound', 'assets/audio/booom.ogg', config, xhrSettings); -// -// this.load.audio('sound', -// [ -// 'assets/audio/booom.ogg', -// 'assets/audio/booom.m4a', -// 'assets/audio/booom.mp3' -// ], -// config, xhrSettings); -// -// this.load.audio('sound', -// { -// uri: 'assets/audio/boooooom', -// type: 'ogg' -// }, -// config, xhrSettings); -// -// this.load.audio('sound', -// [ -// { -// uri: 'assets/audio/booooooo', -// type: 'ogg' -// }, -// { -// uri: 'assets/audio/boooooom', -// type: 'mp3' -// } -// ], -// config, xhrSettings); -// -// this.load.audio('sound', -// [ -// { -// uri: 'assets/audio/booooooo', -// type: 'ogg' -// }, -// 'assets/audio/booom.m4a', -// { -// uri: 'assets/audio/boooooom', -// type: 'mp3' -// } -// ], -// config, xhrSettings); - -AudioFile.findAudioURL = function (game, urls) -{ - if (urls.constructor !== Array) - { - urls = [ urls ]; - } - - for (var i = 0; i < urls.length; i++) - { - var url = GetFastValue(urls[i], 'uri', urls[i]); - - if (url.indexOf('blob:') === 0 || url.indexOf('data:') === 0) - { - return url; - } - - var type = url.match(/\.([a-zA-Z0-9]+)($|\?)/); - type = GetFastValue(urls[i], 'type', type ? type[1] : '').toLowerCase(); - - if (game.device.audio[type]) - { - return { - uri: url, - type: type - }; - } - } - - return null; -}; - -module.exports = AudioFile; - - -/***/ }), -/* 317 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var File = __webpack_require__(18); -var GetFastValue = __webpack_require__(2); -var GetURL = __webpack_require__(150); - -/** - * @classdesc - * [description] - * - * @class HTML5AudioFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {object} config - [description] - * @param {boolean} locked - [description] - */ -var HTML5AudioFile = new Class({ - - Extends: File, - - initialize: - - function HTML5AudioFile (key, url, path, config, locked) - { - this.locked = locked; - - this.loaded = false; - - var fileConfig = { - type: 'audio', - extension: GetFastValue(url, 'type', ''), - key: key, - url: GetFastValue(url, 'uri', url), - path: path, - config: config - }; - - File.call(this, fileConfig); - }, - - onLoad: function () - { - if(this.loaded) - { - return; - } - - this.loaded = true; - - this.loader.nextFile(this, true); - }, - - onError: function () - { - for (var i = 0; i < this.data.length; i++) - { - var audio = this.data[i]; - audio.oncanplaythrough = null; - audio.onerror = null; - } - - this.loader.nextFile(this, false); - }, - - onProgress: function (event) - { - var audio = event.target; - audio.oncanplaythrough = null; - audio.onerror = null; - - this.filesLoaded++; - - this.percentComplete = Math.min((this.filesLoaded / this.filesTotal), 1); - - this.loader.emit('fileprogress', this, this.percentComplete); - - if(this.filesLoaded === this.filesTotal) - { - this.onLoad(); - } - }, - - // Called by the Loader, starts the actual file downloading - load: function (loader) - { - this.loader = loader; - - this.data = []; - - var instances = (this.config && this.config.instances) || 1; - - this.filesTotal = instances; - this.filesLoaded = 0; - this.percentComplete = 0; - - for(var i = 0; i < instances; i++) - { - var audio = new Audio(); - audio.dataset.name = this.key + ('0' + i).slice(-2); // Useful for debugging - audio.dataset.used = 'false'; - - if (!this.locked) - { - audio.preload = 'auto'; - audio.oncanplaythrough = this.onProgress.bind(this); - audio.onerror = this.onError.bind(this); - } - - this.data.push(audio); - } - - for (i = 0; i < this.data.length; i++) - { - audio = this.data[i]; - audio.src = GetURL(this, loader.baseURL); - - if (!this.locked) - { - audio.load(); - } - } - - if (this.locked) - { - setTimeout(this.onLoad.bind(this)); - } - } - -}); - -module.exports = HTML5AudioFile; - - -/***/ }), -/* 318 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(2); -var ParseXML = __webpack_require__(233); - -/** - * @classdesc - * [description] - * - * @class XMLFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {object} xhrSettings - [description] - */ -var XMLFile = new Class({ - - Extends: File, - - initialize: - - function XMLFile (key, url, path, xhrSettings) - { - var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); - - var fileConfig = { - type: 'xml', - extension: GetFastValue(key, 'extension', 'xml'), - responseType: 'text', - key: fileKey, - url: GetFastValue(key, 'file', url), - path: path, - xhrSettings: GetFastValue(key, 'xhr', xhrSettings) - }; - - File.call(this, fileConfig); - }, - - onProcess: function (callback) - { - this.state = CONST.FILE_PROCESSING; - - this.data = ParseXML(this.xhrLoader.responseText); - - if (this.data === null) - { - throw new Error('XMLFile: Invalid XML'); - } - - this.onComplete(); - - callback(this); - } - -}); - -/** - * Adds an XML file to the current load queue. - * - * Note: This method will only be available if the XML File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#xml - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('xml', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new XMLFile(key[i], url, this.path, xhrSettings)); - } - } - else - { - this.addFile(new XMLFile(key, url, this.path, xhrSettings)); - } - - // For method chaining - return this; -}); - -module.exports = XMLFile; - - -/***/ }), -/* 319 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Create an array representing the range of numbers (usually integers), between, and inclusive of, - * the given `start` and `end` arguments. For example: - * - * `var array = numberArray(2, 4); // array = [2, 3, 4]` - * `var array = numberArray(0, 9); // array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]` - * - * This is equivalent to `numberArrayStep(start, end, 1)`. - * - * You can optionally provide a prefix and / or suffix string. If given the array will contain - * strings, not integers. For example: - * - * `var array = numberArray(1, 4, 'Level '); // array = ["Level 1", "Level 2", "Level 3", "Level 4"]` - * `var array = numberArray(5, 7, 'HD-', '.png'); // array = ["HD-5.png", "HD-6.png", "HD-7.png"]` - * - * @function Phaser.Utils.Array.NumberArray - * @since 3.0.0 - * - * @param {number} start - The minimum value the array starts with. - * @param {number} end - The maximum value the array contains. - * @param {string} [prefix] - Optional prefix to place before the number. If provided the array will contain strings, not integers. - * @param {string} [suffix] - Optional suffix to place after the number. If provided the array will contain strings, not integers. - * - * @return {number[]|string[]} The array of number values, or strings if a prefix or suffix was provided. - */ -var NumberArray = function (start, end, prefix, suffix) -{ - var result = []; - - for (var i = start; i <= end; i++) - { - if (prefix || suffix) - { - var key = (prefix) ? prefix + i.toString() : i.toString(); - - if (suffix) - { - key = key.concat(suffix); - } - - result.push(key); - } - else - { - result.push(i); - } - } - - return result; -}; - -module.exports = NumberArray; - - -/***/ }), -/* 320 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); - -/** - * @classdesc - * [description] - * - * @class TextFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {object} xhrSettings - [description] - */ -var TextFile = new Class({ - - Extends: File, - - initialize: - - function TextFile (key, url, path, xhrSettings) - { - var fileConfig = { - type: 'text', - extension: 'txt', - responseType: 'text', - key: key, - url: url, - path: path, - xhrSettings: xhrSettings - }; - - File.call(this, fileConfig); - }, - - onProcess: function (callback) - { - this.state = CONST.FILE_PROCESSING; - - this.data = this.xhrLoader.responseText; - - this.onComplete(); - - callback(this); - } - -}); - -/** - * Adds a Text file to the current load queue. - * - * Note: This method will only be available if the Text File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#text - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('text', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new TextFile(key[i], url, this.path, xhrSettings)); - } - } - else - { - this.addFile(new TextFile(key, url, this.path, xhrSettings)); - } - - // For method chaining - return this; -}); - -module.exports = TextFile; - - -/***/ }), -/* 321 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Angle.Normalize - * @since 3.0.0 - * - * @param {number} angle - [description] - * - * @return {number} [description] - */ -var Normalize = function (angle) -{ - angle = angle % (2 * Math.PI); - - if (angle >= 0) - { - return angle; - } - else - { - return angle + 2 * Math.PI; - } -}; - -module.exports = Normalize; - - -/***/ }), -/* 322 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Factorial = __webpack_require__(323); - -/** - * [description] - * - * @function Phaser.Math.Bernstein - * @since 3.0.0 - * - * @param {number} n - [description] - * @param {number} i - [description] - * - * @return {number} [description] - */ -var Bernstein = function (n, i) -{ - return Factorial(n) / Factorial(i) / Factorial(n - i); -}; - -module.exports = Bernstein; - - -/***/ }), -/* 323 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Factorial - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {number} [description] - */ -var Factorial = function (value) -{ - if (value === 0) - { - return 1; - } - - var res = value; - - while (--value) - { - res *= value; - } - - return res; -}; - -module.exports = Factorial; - - -/***/ }), -/* 324 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Rotate - * @since 3.0.0 - * - * @param {Phaser.Geom.Point|object} point - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Rotate = function (point, angle) -{ - var x = point.x; - var y = point.y; - - point.x = (x * Math.cos(angle)) - (y * Math.sin(angle)); - point.y = (x * Math.sin(angle)) + (y * Math.cos(angle)); - - return point; -}; - -module.exports = Rotate; - - -/***/ }), -/* 325 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.RoundAwayFromZero - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {number} [description] - */ -var RoundAwayFromZero = function (value) -{ - // "Opposite" of truncate. - return (value > 0) ? Math.ceil(value) : Math.floor(value); -}; - -module.exports = RoundAwayFromZero; - - -/***/ }), -/* 326 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ArcadeImage = __webpack_require__(327); -var ArcadeSprite = __webpack_require__(91); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(59); -var PhysicsGroup = __webpack_require__(329); -var StaticPhysicsGroup = __webpack_require__(330); - -/** - * @classdesc - * The Arcade Physics Factory allows you to easily create Arcade Physics enabled Game Objects. - * Objects that are created by this Factory are automatically added to the physics world. - * - * @class Factory - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.World} world - The Arcade Physics World instance. - */ -var Factory = new Class({ - - initialize: - - function Factory (world) - { - /** - * A reference to the Arcade Physics World. - * - * @name Phaser.Physics.Arcade.Factory#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world = world; - - /** - * A reference to the Scene this Arcade Physics instance belongs to. - * - * @name Phaser.Physics.Arcade.Factory#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = world.scene; - - /** - * A reference to the Scene.Systems this Arcade Physics instance belongs to. - * - * @name Phaser.Physics.Arcade.Factory#sys - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.sys = world.scene.sys; - }, - - /** - * Create a new Arcade Physics Collider object. - * - * @method Phaser.Physics.Arcade.Factory#collider - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for collision. - * @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for collision. - * @param {function} collideCallback - The callback to invoke when the two objects collide. - * @param {function} processCallback - The callback to invoke when the two objects collide. Must return a boolean. - * @param {object} callbackContext - The scope in which to call the callbacks. - * - * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. - */ - collider: function (object1, object2, collideCallback, processCallback, callbackContext) - { - return this.world.addCollider(object1, object2, collideCallback, processCallback, callbackContext); - }, - - /** - * Create a new Arcade Physics Collider Overlap object. - * - * @method Phaser.Physics.Arcade.Factory#overlap - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for overlap. - * @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for overlap. - * @param {function} collideCallback - The callback to invoke when the two objects collide. - * @param {function} processCallback - The callback to invoke when the two objects collide. Must return a boolean. - * @param {object} callbackContext - The scope in which to call the callbacks. - * - * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. - */ - overlap: function (object1, object2, collideCallback, processCallback, callbackContext) - { - return this.world.addOverlap(object1, object2, collideCallback, processCallback, callbackContext); - }, - - /** - * Adds an Arcade Physics Body to the given Game Object. - * - * @method Phaser.Physics.Arcade.Factory#existing - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - * @param {boolean} [isStatic=false] - Set to true to create a Static body, otherwise it will create a Dynamic body. - * - * @return {Phaser.GameObjects.GameObject} The Game Object. - */ - existing: function (gameObject, isStatic) - { - var type = (isStatic) ? CONST.STATIC_BODY : CONST.DYNAMIC_BODY; - - this.world.enableBody(gameObject, type); - - return gameObject; - }, - - /** - * Creates a new Arcade Image object with a Static body. - * - * @method Phaser.Physics.Arcade.Factory#staticImage - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.Physics.Arcade.Image} The Image object that was created. - */ - staticImage: function (x, y, key, frame) - { - var image = new ArcadeImage(this.scene, x, y, key, frame); - - this.sys.displayList.add(image); - - this.world.enableBody(image, CONST.STATIC_BODY); - - return image; - }, - - /** - * Creates a new Arcade Image object with a Dynamic body. - * - * @method Phaser.Physics.Arcade.Factory#image - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.Physics.Arcade.Image} The Image object that was created. - */ - image: function (x, y, key, frame) - { - var image = new ArcadeImage(this.scene, x, y, key, frame); - - this.sys.displayList.add(image); - - this.world.enableBody(image, CONST.DYNAMIC_BODY); - - return image; - }, - - /** - * Creates a new Arcade Sprite object with a Static body. - * - * @method Phaser.Physics.Arcade.Factory#staticSprite - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.Physics.Arcade.Sprite} The Sprite object that was created. - */ - staticSprite: function (x, y, key, frame) - { - var sprite = new ArcadeSprite(this.scene, x, y, key, frame); - - this.sys.displayList.add(sprite); - this.sys.updateList.add(sprite); - - this.world.enableBody(sprite, CONST.STATIC_BODY); - - return sprite; - }, - - /** - * Creates a new Arcade Sprite object with a Dynamic body. - * - * @method Phaser.Physics.Arcade.Factory#sprite - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.Physics.Arcade.Sprite} The Sprite object that was created. - */ - sprite: function (x, y, key, frame) - { - var sprite = new ArcadeSprite(this.scene, x, y, key, frame); - - this.sys.displayList.add(sprite); - this.sys.updateList.add(sprite); - - this.world.enableBody(sprite, CONST.DYNAMIC_BODY); - - return sprite; - }, - - /** - * Creates a Static Physics Group object. - * All Game Objects created by this Group will automatically be static Arcade Physics objects. - * - * @method Phaser.Physics.Arcade.Factory#staticGroup - * @since 3.0.0 - * - * @param {array} [children] - [description] - * @param {object} [config] - [description] - * - * @return {Phaser.Physics.Arcade.StaticGroup} The Static Group object that was created. - */ - staticGroup: function (children, config) - { - return this.sys.updateList.add(new StaticPhysicsGroup(this.world, this.world.scene, children, config)); - }, - - /** - * Creates a Physics Group object. - * All Game Objects created by this Group will automatically be dynamic Arcade Physics objects. - * - * @method Phaser.Physics.Arcade.Factory#group - * @since 3.0.0 - * - * @param {array} [children] - [description] - * @param {object} [config] - [description] - * - * @return {Phaser.Physics.Arcade.Group} The Group object that was created. - */ - group: function (children, config) - { - return this.sys.updateList.add(new PhysicsGroup(this.world, this.world.scene, children, config)); - } - -}); - -module.exports = Factory; - - -/***/ }), -/* 327 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(328); -var Image = __webpack_require__(70); - -/** - * @classdesc - * An Arcade Physics Image Game Object. - * - * An Image is a light-weight Game Object useful for the display of static images in your game, - * such as logos, backgrounds, scenery or other non-animated elements. Images can have input - * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an - * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. - * - * @class Image - * @extends Phaser.GameObjects.Image - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @extends Phaser.Physics.Arcade.Components.Acceleration - * @extends Phaser.Physics.Arcade.Components.Angular - * @extends Phaser.Physics.Arcade.Components.Bounce - * @extends Phaser.Physics.Arcade.Components.Debug - * @extends Phaser.Physics.Arcade.Components.Drag - * @extends Phaser.Physics.Arcade.Components.Enable - * @extends Phaser.Physics.Arcade.Components.Friction - * @extends Phaser.Physics.Arcade.Components.Gravity - * @extends Phaser.Physics.Arcade.Components.Immovable - * @extends Phaser.Physics.Arcade.Components.Mass - * @extends Phaser.Physics.Arcade.Components.Size - * @extends Phaser.Physics.Arcade.Components.Velocity - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var ArcadeImage = new Class({ - - Extends: Image, - - Mixins: [ - Components.Acceleration, - Components.Angular, - Components.Bounce, - Components.Debug, - Components.Drag, - Components.Enable, - Components.Friction, - Components.Gravity, - Components.Immovable, - Components.Mass, - Components.Size, - Components.Velocity - ], - - initialize: - - function ArcadeImage (scene, x, y, texture, frame) - { - Image.call(this, scene, x, y, texture, frame); - } - -}); - -module.exports = ArcadeImage; - - -/***/ }), -/* 328 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Phaser.Physics.Arcade.Body.Components - -module.exports = { - - Acceleration: __webpack_require__(838), - Angular: __webpack_require__(839), - Bounce: __webpack_require__(840), - Debug: __webpack_require__(841), - Drag: __webpack_require__(842), - Enable: __webpack_require__(843), - Friction: __webpack_require__(844), - Gravity: __webpack_require__(845), - Immovable: __webpack_require__(846), - Mass: __webpack_require__(847), - Size: __webpack_require__(848), - Velocity: __webpack_require__(849) - -}; - - -/***/ }), -/* 329 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ArcadeSprite = __webpack_require__(91); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(59); -var GetFastValue = __webpack_require__(2); -var Group = __webpack_require__(69); - -/** - * @classdesc - * An Arcade Physics Group object. - * - * All Game Objects created by this Group will automatically be dynamic Arcade Physics objects. - * - * @class Group - * @extends Phaser.GameObjects.Group - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.World} world - [description] - * @param {Phaser.Scene} scene - [description] - * @param {array} children - [description] - * @param {object} config - [description] - */ -var PhysicsGroup = new Class({ - - Extends: Group, - - initialize: - - function PhysicsGroup (world, scene, children, config) - { - if (config === undefined && !Array.isArray(children) && typeof children === 'object') - { - config = children; - children = null; - } - else if (config === undefined) - { - config = {}; - } - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Group#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world = world; - - config.createCallback = this.createCallback; - config.removeCallback = this.removeCallback; - - config.classType = GetFastValue(config, 'classType', ArcadeSprite); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Group#physicsType - * @type {integer} - * @since 3.0.0 - */ - this.physicsType = CONST.DYNAMIC_BODY; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Group#defaults - * @type {object} - * @since 3.0.0 - */ - this.defaults = { - setCollideWorldBounds: GetFastValue(config, 'collideWorldBounds', false), - setAccelerationX: GetFastValue(config, 'accelerationX', 0), - setAccelerationY: GetFastValue(config, 'accelerationY', 0), - setBounceX: GetFastValue(config, 'bounceX', 0), - setBounceY: GetFastValue(config, 'bounceY', 0), - setDragX: GetFastValue(config, 'dragX', 0), - setDragY: GetFastValue(config, 'dragY', 0), - setGravityX: GetFastValue(config, 'gravityX', 0), - setGravityY: GetFastValue(config, 'gravityY', 0), - setFrictionX: GetFastValue(config, 'frictionX', 0), - setFrictionY: GetFastValue(config, 'frictionY', 0), - setVelocityX: GetFastValue(config, 'velocityX', 0), - setVelocityY: GetFastValue(config, 'velocityY', 0), - setAngularVelocity: GetFastValue(config, 'angularVelocity', 0), - setAngularAcceleration: GetFastValue(config, 'angularAcceleration', 0), - setAngularDrag: GetFastValue(config, 'angularDrag', 0), - setMass: GetFastValue(config, 'mass', 1), - setImmovable: GetFastValue(config, 'immovable', false) - }; - - Group.call(this, scene, children, config); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Group#createCallback - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - */ - createCallback: function (child) - { - if (!child.body) - { - this.world.enableBody(child, CONST.DYNAMIC_BODY); - } - - var body = child.body; - - for (var key in this.defaults) - { - body[key](this.defaults[key]); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Group#removeCallback - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - */ - removeCallback: function (child) - { - if (child.body) - { - this.world.disableBody(child); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Group#setVelocity - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} step - [description] - * - * @return {Phaser.Physics.Arcade.Group} This Physics Group object. - */ - setVelocity: function (x, y, step) - { - if (step === undefined) { step = 0; } - - var items = this.getChildren(); - - for (var i = 0; i < items.length; i++) - { - items[i].body.velocity.set(x + (i * step), y + (i * step)); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Group#setVelocityX - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} step - [description] - * - * @return {Phaser.Physics.Arcade.Group} This Physics Group object. - */ - setVelocityX: function (value, step) - { - if (step === undefined) { step = 0; } - - var items = this.getChildren(); - - for (var i = 0; i < items.length; i++) - { - items[i].body.velocity.x = value + (i * step); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Group#setVelocityY - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} step - [description] - * - * @return {Phaser.Physics.Arcade.Group} This Physics Group object. - */ - setVelocityY: function (value, step) - { - if (step === undefined) { step = 0; } - - var items = this.getChildren(); - - for (var i = 0; i < items.length; i++) - { - items[i].body.velocity.y = value + (i * step); - } - - return this; - } - -}); - -module.exports = PhysicsGroup; - - -/***/ }), -/* 330 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Phaser.Physics.Arcade.StaticGroup - -var ArcadeSprite = __webpack_require__(91); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(59); -var Group = __webpack_require__(69); - -/** - * @classdesc - * [description] - * - * @class StaticGroup - * @extends Phaser.GameObjects.Group - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.World} world - [description] - * @param {Phaser.Scene} scene - [description] - * @param {array} children - [description] - * @param {object} config - [description] - */ -var StaticPhysicsGroup = new Class({ - - Extends: Group, - - initialize: - - function StaticPhysicsGroup (world, scene, children, config) - { - if (config === undefined && !Array.isArray(children) && typeof children === 'object') - { - config = children; - children = null; - } - else if (config === undefined) - { - config = {}; - } - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticGroup#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world = world; - - config.createCallback = this.createCallback; - config.removeCallback = this.removeCallback; - config.createMultipleCallback = this.createMultipleCallback; - - config.classType = ArcadeSprite; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticGroup#physicsType - * @type {integer} - * @since 3.0.0 - */ - this.physicsType = CONST.STATIC_BODY; - - Group.call(this, scene, children, config); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticGroup#createCallback - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - */ - createCallback: function (child) - { - if (!child.body) - { - this.world.enableBody(child, CONST.STATIC_BODY); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticGroup#removeCallback - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - */ - removeCallback: function (child) - { - if (child.body) - { - this.world.disableBody(child); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticGroup#createMultipleCallback - * @since 3.0.0 - * - * @param {object} entries - [description] - */ - createMultipleCallback: function () - { - this.refresh(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticGroup#refresh - * @since 3.0.0 - * - * @return {Phaser.Physics.Arcade.StaticGroup} [description] - */ - refresh: function () - { - var children = this.children.entries; - - for (var i = 0; i < children.length; i++) - { - children[i].body.reset(); - } - - return this; - } - -}); - -module.exports = StaticPhysicsGroup; - - -/***/ }), -/* 331 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Body = __webpack_require__(332); -var Clamp = __webpack_require__(61); -var Class = __webpack_require__(0); -var Collider = __webpack_require__(333); -var CONST = __webpack_require__(59); -var DistanceBetween = __webpack_require__(42); -var EventEmitter = __webpack_require__(14); -var GetOverlapX = __webpack_require__(334); -var GetOverlapY = __webpack_require__(335); -var GetValue = __webpack_require__(4); -var ProcessQueue = __webpack_require__(336); -var ProcessTileCallbacks = __webpack_require__(850); -var Rectangle = __webpack_require__(8); -var RTree = __webpack_require__(337); -var SeparateTile = __webpack_require__(851); -var SeparateX = __webpack_require__(856); -var SeparateY = __webpack_require__(857); -var Set = __webpack_require__(62); -var StaticBody = __webpack_require__(340); -var TileIntersectsBody = __webpack_require__(339); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * [description] - * - * @class World - * @extends EventEmitter - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {object} config - [description] - */ -var World = new Class({ - - Extends: EventEmitter, - - initialize: - - function World (scene, config) - { - EventEmitter.call(this); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * Dynamic Bodies - * - * @name Phaser.Physics.Arcade.World#bodies - * @type {Phaser.Structs.Set} - * @since 3.0.0 - */ - this.bodies = new Set(); - - /** - * Static Bodies - * - * @name Phaser.Physics.Arcade.World#staticBodies - * @type {Phaser.Structs.Set} - * @since 3.0.0 - */ - this.staticBodies = new Set(); - - /** - * Static Bodies - * - * @name Phaser.Physics.Arcade.World#pendingDestroy - * @type {Phaser.Structs.Set} - * @since 3.1.0 - */ - this.pendingDestroy = new Set(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#colliders - * @type {Phaser.Structs.ProcessQueue} - * @since 3.0.0 - */ - this.colliders = new ProcessQueue(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#gravity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.gravity = new Vector2(GetValue(config, 'gravity.x', 0), GetValue(config, 'gravity.y', 0)); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#bounds - * @type {Phaser.Geom.Rectangle} - * @since 3.0.0 - */ - this.bounds = new Rectangle( - GetValue(config, 'x', 0), - GetValue(config, 'y', 0), - GetValue(config, 'width', scene.sys.game.config.width), - GetValue(config, 'height', scene.sys.game.config.height) - ); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#checkCollision - * @type {object} - * @since 3.0.0 - */ - this.checkCollision = { - up: GetValue(config, 'checkCollision.up', true), - down: GetValue(config, 'checkCollision.down', true), - left: GetValue(config, 'checkCollision.left', true), - right: GetValue(config, 'checkCollision.right', true) - }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#OVERLAP_BIAS - * @type {number} - * @default 4 - * @since 3.0.0 - */ - this.OVERLAP_BIAS = GetValue(config, 'overlapBias', 4); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#TILE_BIAS - * @type {number} - * @default 16 - * @since 3.0.0 - */ - this.TILE_BIAS = GetValue(config, 'tileBias', 16); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#forceX - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.forceX = GetValue(config, 'forceX', false); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#isPaused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isPaused = GetValue(config, 'isPaused', false); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#_total - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._total = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#drawDebug - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.drawDebug = GetValue(config, 'debug', false); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#debugGraphic - * @type {Phaser.GameObjects.Graphics} - * @since 3.0.0 - */ - this.debugGraphic; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#defaults - * @type {object} - * @since 3.0.0 - */ - this.defaults = { - debugShowBody: GetValue(config, 'debugShowBody', true), - debugShowStaticBody: GetValue(config, 'debugShowStaticBody', true), - debugShowVelocity: GetValue(config, 'debugShowVelocity', true), - bodyDebugColor: GetValue(config, 'debugBodyColor', 0xff00ff), - staticBodyDebugColor: GetValue(config, 'debugBodyColor', 0x0000ff), - velocityDebugColor: GetValue(config, 'debugVelocityColor', 0x00ff00) - }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#maxEntries - * @type {integer} - * @default 16 - * @since 3.0.0 - */ - this.maxEntries = GetValue(config, 'maxEntries', 16); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#tree - * @type {Phaser.Structs.RTree} - * @since 3.0.0 - */ - this.tree = new RTree(this.maxEntries, [ '.left', '.top', '.right', '.bottom' ]); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#staticTree - * @type {Phaser.Structs.RTree} - * @since 3.0.0 - */ - this.staticTree = new RTree(this.maxEntries, [ '.left', '.top', '.right', '.bottom' ]); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.World#treeMinMax - * @type {object} - * @since 3.0.0 - */ - this.treeMinMax = { minX: 0, minY: 0, maxX: 0, maxY: 0 }; - - if (this.drawDebug) - { - this.createDebugGraphic(); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#enable - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} object - [description] - * @param {integer} [type] - [description] - */ - enable: function (object, type) - { - if (type === undefined) { type = CONST.DYNAMIC_BODY; } - - var i = 1; - - if (Array.isArray(object)) - { - i = object.length; - - while (i--) - { - if (object[i].hasOwnProperty('children')) - { - // If it's a Group then we do it on the children regardless - this.enable(object[i].children.entries, type); - } - else - { - this.enableBody(object[i], type); - } - } - } - else if (object.hasOwnProperty('children')) - { - // If it's a Group then we do it on the children regardless - this.enable(object.children.entries, type); - } - else - { - this.enableBody(object, type); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#enableBody - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} object - [description] - * @param {integer} type - [description] - * - * @return {Phaser.GameObjects.GameObject} [description] - */ - enableBody: function (object, type) - { - if (object.body === null) - { - if (type === CONST.DYNAMIC_BODY) - { - object.body = new Body(this, object); - - this.bodies.set(object.body); - } - else if (type === CONST.STATIC_BODY) - { - object.body = new StaticBody(this, object); - - this.staticBodies.set(object.body); - - this.staticTree.insert(object.body); - } - } - - return object; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#remove - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} object - [description] - */ - remove: function (object) - { - this.disableBody(object); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#disable - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} object - [description] - */ - disable: function (object) - { - var i = 1; - - if (Array.isArray(object)) - { - i = object.length; - - while (i--) - { - if (object[i].hasOwnProperty('children')) - { - // If it's a Group then we do it on the children regardless - this.disable(object[i].children.entries); - } - else - { - this.disableGameObjectBody(object[i]); - } - } - } - else if (object.hasOwnProperty('children')) - { - // If it's a Group then we do it on the children regardless - this.disable(object.children.entries); - } - else - { - this.disableGameObjectBody(object); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#disableGameObjectBody - * @since 3.1.0 - * - * @param {Phaser.GameObjects.GameObject} object - [description] - * - * @return {Phaser.GameObjects.GameObject} [description] - */ - disableGameObjectBody: function (object) - { - if (object.body) - { - if (object.body.physicsType === CONST.DYNAMIC_BODY) - { - this.bodies.delete(object.body); - } - else if (object.body.physicsType === CONST.STATIC_BODY) - { - this.staticBodies.delete(object.body); - this.staticTree.remove(object.body); - } - - object.body.enable = false; - } - - return object; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#disableBody - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - [description] - */ - disableBody: function (body) - { - if (body.physicsType === CONST.DYNAMIC_BODY) - { - this.tree.remove(body); - this.bodies.delete(body); - } - else if (body.physicsType === CONST.STATIC_BODY) - { - this.staticBodies.delete(body); - this.staticTree.remove(body); - } - - body.enable = false; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#createDebugGraphic - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} [description] - */ - createDebugGraphic: function () - { - var graphic = this.scene.sys.add.graphics({ x: 0, y: 0 }); - - graphic.setDepth(Number.MAX_VALUE); - - this.debugGraphic = graphic; - - this.drawDebug = true; - - return graphic; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#setBounds - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {boolean} [checkLeft] - [description] - * @param {boolean} [checkRight] - [description] - * @param {boolean} [checkUp] - [description] - * @param {boolean} [checkDown] - [description] - * - * @return {Phaser.Physics.Arcade.World} This World object. - */ - setBounds: function (x, y, width, height, checkLeft, checkRight, checkUp, checkDown) - { - this.bounds.setTo(x, y, width, height); - - if (checkLeft !== undefined) - { - this.setBoundsCollision(checkLeft, checkRight, checkUp, checkDown); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#setBoundsCollision - * @since 3.0.0 - * - * @param {boolean} [left=true] - [description] - * @param {boolean} [right=true] - [description] - * @param {boolean} [up=true] - [description] - * @param {boolean} [down=true] - [description] - * - * @return {Phaser.Physics.Arcade.World} This World object. - */ - setBoundsCollision: function (left, right, up, down) - { - if (left === undefined) { left = true; } - if (right === undefined) { right = true; } - if (up === undefined) { up = true; } - if (down === undefined) { down = true; } - - this.checkCollision.left = left; - this.checkCollision.right = right; - this.checkCollision.up = up; - this.checkCollision.down = down; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#pause - * @since 3.0.0 - * - * @return {Phaser.Physics.Arcade.World} This World object. - */ - pause: function () - { - this.isPaused = true; - - this.emit('pause'); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#resume - * @since 3.0.0 - * - * @return {Phaser.Physics.Arcade.World} This World object. - */ - resume: function () - { - this.isPaused = false; - - this.emit('resume'); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#addCollider - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for collision. - * @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for collision. - * @param {function} collideCallback - The callback to invoke when the two objects collide. - * @param {function} processCallback - The callback to invoke when the two objects collide. Must return a boolean. - * @param {object} callbackContext - The scope in which to call the callbacks. - * - * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. - */ - addCollider: function (object1, object2, collideCallback, processCallback, callbackContext) - { - if (collideCallback === undefined) { collideCallback = null; } - if (processCallback === undefined) { processCallback = null; } - if (callbackContext === undefined) { callbackContext = collideCallback; } - - var collider = new Collider(this, false, object1, object2, collideCallback, processCallback, callbackContext); - - this.colliders.add(collider); - - return collider; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#addOverlap - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for overlap. - * @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for overlap. - * @param {function} collideCallback - The callback to invoke when the two objects overlap. - * @param {function} processCallback - The callback to invoke when the two objects overlap. Must return a boolean. - * @param {object} callbackContext - The scope in which to call the callbacks. - * - * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. - */ - addOverlap: function (object1, object2, collideCallback, processCallback, callbackContext) - { - if (collideCallback === undefined) { collideCallback = null; } - if (processCallback === undefined) { processCallback = null; } - if (callbackContext === undefined) { callbackContext = collideCallback; } - - var collider = new Collider(this, true, object1, object2, collideCallback, processCallback, callbackContext); - - this.colliders.add(collider); - - return collider; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#removeCollider - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Collider} collider - [description] - * - * @return {Phaser.Physics.Arcade.World} This World object. - */ - removeCollider: function (collider) - { - this.colliders.remove(collider); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#update - * @since 3.0.0 - * - * @param {number} time - [description] - * @param {number} delta - [description] - */ - update: function (time, delta) - { - if (this.isPaused || this.bodies.size === 0) - { - return; - } - - // this.delta = Math.min(delta / 1000, this.maxStep) * this.timeScale; - delta /= 1000; - - this.delta = delta; - - // Update all active bodies - - var i; - var body; - var bodies = this.bodies.entries; - var len = bodies.length; - - for (i = 0; i < len; i++) - { - body = bodies[i]; - - if (body.enable) - { - body.update(delta); - } - } - - // Populate our dynamic collision tree - this.tree.clear(); - this.tree.load(bodies); - - // Process any colliders - var colliders = this.colliders.update(); - - for (i = 0; i < colliders.length; i++) - { - var collider = colliders[i]; - - if (collider.active) - { - collider.update(); - } - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#postUpdate - * @since 3.0.0 - */ - postUpdate: function () - { - var i; - var body; - - var dynamic = this.bodies; - var staticBodies = this.staticBodies; - var pending = this.pendingDestroy; - - var bodies = dynamic.entries; - var len = bodies.length; - - for (i = 0; i < len; i++) - { - body = bodies[i]; - - if (body.enable) - { - body.postUpdate(); - } - } - - if (this.drawDebug) - { - var graphics = this.debugGraphic; - - graphics.clear(); - - for (i = 0; i < len; i++) - { - body = bodies[i]; - - if (body.willDrawDebug()) - { - body.drawDebug(graphics); - } - } - - bodies = staticBodies.entries; - len = bodies.length; - - for (i = 0; i < len; i++) - { - body = bodies[i]; - - if (body.willDrawDebug()) - { - body.drawDebug(graphics); - } - } - } - - if (pending.size > 0) - { - var dynamicTree = this.tree; - var staticTree = this.staticTree; - - bodies = pending.entries; - len = bodies.length; - - for (i = 0; i < len; i++) - { - body = bodies[i]; - - if (body.physicsType === CONST.DYNAMIC_BODY) - { - dynamicTree.remove(body); - dynamic.delete(body); - } - else if (body.physicsType === CONST.STATIC_BODY) - { - staticTree.remove(body); - staticBodies.delete(body); - } - - body.world = undefined; - body.gameObject = undefined; - } - - pending.clear(); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#updateMotion - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - [description] - */ - updateMotion: function (body) - { - if (body.allowRotation) - { - var velocityDelta = this.computeVelocity(0, body, body.angularVelocity, body.angularAcceleration, body.angularDrag, body.maxAngular) - body.angularVelocity; - - body.angularVelocity += velocityDelta; - body.rotation += (body.angularVelocity * this.delta); - } - - body.velocity.x = this.computeVelocity(1, body, body.velocity.x, body.acceleration.x, body.drag.x, body.maxVelocity.x); - body.velocity.y = this.computeVelocity(2, body, body.velocity.y, body.acceleration.y, body.drag.y, body.maxVelocity.y); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#computeVelocity - * @since 3.0.0 - * - * @param {integer} axis - [description] - * @param {Phaser.Physics.Arcade.Body} body - [description] - * @param {number} velocity - [description] - * @param {number} acceleration - [description] - * @param {number} drag - [description] - * @param {number} max - [description] - * - * @return {number} [description] - */ - computeVelocity: function (axis, body, velocity, acceleration, drag, max) - { - if (max === undefined) { max = 10000; } - - if (axis === 1 && body.allowGravity) - { - velocity += (this.gravity.x + body.gravity.x) * this.delta; - } - else if (axis === 2 && body.allowGravity) - { - velocity += (this.gravity.y + body.gravity.y) * this.delta; - } - - if (acceleration) - { - velocity += acceleration * this.delta; - } - else if (drag && body.allowDrag) - { - drag *= this.delta; - - if (velocity - drag > 0) - { - velocity -= drag; - } - else if (velocity + drag < 0) - { - velocity += drag; - } - else - { - velocity = 0; - } - } - - if (velocity > max) - { - velocity = max; - } - else if (velocity < -max) - { - velocity = -max; - } - - return velocity; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#separate - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {function} processCallback - [description] - * @param {object} callbackContext - [description] - * @param {boolean} overlapOnly - [description] - * - * @return {boolean} [description] - */ - separate: function (body1, body2, processCallback, callbackContext, overlapOnly) - { - if ( - !body1.enable || - !body2.enable || - body1.checkCollision.none || - body2.checkCollision.none || - !this.intersects(body1, body2)) - { - return false; - } - - // They overlap. Is there a custom process callback? If it returns true then we can carry on, otherwise we should abort. - if (processCallback && processCallback.call(callbackContext, body1.gameObject, body2.gameObject) === false) - { - return false; - } - - // Circle vs. Circle quick bail out - if (body1.isCircle && body2.isCircle) - { - return this.separateCircle(body1, body2, overlapOnly); - } - - // We define the behavior of bodies in a collision circle and rectangle - // If a collision occurs in the corner points of the rectangle, the body behave like circles - - // Either body1 or body2 is a circle - if (body1.isCircle !== body2.isCircle) - { - var bodyRect = (body1.isCircle) ? body2 : body1; - var bodyCircle = (body1.isCircle) ? body1 : body2; - - var rect = { - x: bodyRect.x, - y: bodyRect.y, - right: bodyRect.right, - bottom: bodyRect.bottom - }; - - var circle = bodyCircle.center; - - if (circle.y < rect.y || circle.y > rect.bottom) - { - if (circle.x < rect.x || circle.x > rect.right) - { - return this.separateCircle(body1, body2, overlapOnly); - } - } - } - - var resultX = false; - var resultY = false; - - // Do we separate on x or y first? - if (this.forceX || Math.abs(this.gravity.y + body1.gravity.y) < Math.abs(this.gravity.x + body1.gravity.x)) - { - resultX = SeparateX(body1, body2, overlapOnly, this.OVERLAP_BIAS); - - // Are they still intersecting? Let's do the other axis then - if (this.intersects(body1, body2)) - { - resultY = SeparateY(body1, body2, overlapOnly, this.OVERLAP_BIAS); - } - } - else - { - resultY = SeparateY(body1, body2, overlapOnly, this.OVERLAP_BIAS); - - // Are they still intersecting? Let's do the other axis then - if (this.intersects(body1, body2)) - { - resultX = SeparateX(body1, body2, overlapOnly, this.OVERLAP_BIAS); - } - } - - var result = (resultX || resultY); - - if (result) - { - if (overlapOnly && (body1.onOverlap || body2.onOverlap)) - { - this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2); - } - else if (body1.onCollide || body2.onCollide) - { - this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); - } - } - - return result; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#separateCircle - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {boolean} overlapOnly - [description] - * @param {number} bias - [description] - * - * @return {boolean} [description] - */ - separateCircle: function (body1, body2, overlapOnly, bias) - { - // Set the bounding box overlap values into the bodies themselves (hence we don't use the return values here) - GetOverlapX(body1, body2, false, bias); - GetOverlapY(body1, body2, false, bias); - - var dx = body2.center.x - body1.center.x; - var dy = body2.center.y - body1.center.y; - - var angleCollision = Math.atan2(dy, dx); - - var overlap = 0; - - if (body1.isCircle !== body2.isCircle) - { - var rect = { - x: (body2.isCircle) ? body1.position.x : body2.position.x, - y: (body2.isCircle) ? body1.position.y : body2.position.y, - right: (body2.isCircle) ? body1.right : body2.right, - bottom: (body2.isCircle) ? body1.bottom : body2.bottom - }; - - var circle = { - x: (body1.isCircle) ? body1.center.x : body2.center.x, - y: (body1.isCircle) ? body1.center.y : body2.center.y, - radius: (body1.isCircle) ? body1.halfWidth : body2.halfWidth - }; - - if (circle.y < rect.y) - { - if (circle.x < rect.x) - { - overlap = DistanceBetween(circle.x, circle.y, rect.x, rect.y) - circle.radius; - } - else if (circle.x > rect.right) - { - overlap = DistanceBetween(circle.x, circle.y, rect.right, rect.y) - circle.radius; - } - } - else if (circle.y > rect.bottom) - { - if (circle.x < rect.x) - { - overlap = DistanceBetween(circle.x, circle.y, rect.x, rect.bottom) - circle.radius; - } - else if (circle.x > rect.right) - { - overlap = DistanceBetween(circle.x, circle.y, rect.right, rect.bottom) - circle.radius; - } - } - - overlap *= -1; - } - else - { - overlap = (body1.halfWidth + body2.halfWidth) - DistanceBetween(body1.center.x, body1.center.y, body2.center.x, body2.center.y); - } - - // Can't separate two immovable bodies, or a body with its own custom separation logic - if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateX || body2.customSeparateX) - { - if (overlap !== 0 && (body1.onOverlap || body2.onOverlap)) - { - this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2); - } - - // return true if there was some overlap, otherwise false - return (overlap !== 0); - } - - // Transform the velocity vector to the coordinate system oriented along the direction of impact. - // This is done to eliminate the vertical component of the velocity - - var b1vx = body1.velocity.x; - var b1vy = body1.velocity.y; - var b1mass = body1.mass; - - var b2vx = body2.velocity.x; - var b2vy = body2.velocity.y; - var b2mass = body2.mass; - - var v1 = { - x: b1vx * Math.cos(angleCollision) + b1vy * Math.sin(angleCollision), - y: b1vx * Math.sin(angleCollision) - b1vy * Math.cos(angleCollision) - }; - - var v2 = { - x: b2vx * Math.cos(angleCollision) + b2vy * Math.sin(angleCollision), - y: b2vx * Math.sin(angleCollision) - b2vy * Math.cos(angleCollision) - }; - - // We expect the new velocity after impact - var tempVel1 = ((b1mass - b2mass) * v1.x + 2 * b2mass * v2.x) / (b1mass + b2mass); - var tempVel2 = (2 * b1mass * v1.x + (b2mass - b1mass) * v2.x) / (b1mass + b2mass); - - // We convert the vector to the original coordinate system and multiplied by factor of rebound - if (!body1.immovable) - { - body1.velocity.x = (tempVel1 * Math.cos(angleCollision) - v1.y * Math.sin(angleCollision)) * body1.bounce.x; - body1.velocity.y = (v1.y * Math.cos(angleCollision) + tempVel1 * Math.sin(angleCollision)) * body1.bounce.y; - - // Reset local var - b1vx = body1.velocity.x; - b1vy = body1.velocity.y; - } - - if (!body2.immovable) - { - body2.velocity.x = (tempVel2 * Math.cos(angleCollision) - v2.y * Math.sin(angleCollision)) * body2.bounce.x; - body2.velocity.y = (v2.y * Math.cos(angleCollision) + tempVel2 * Math.sin(angleCollision)) * body2.bounce.y; - - // Reset local var - b2vx = body2.velocity.x; - b2vy = body2.velocity.y; - } - - // When the collision angle is almost perpendicular to the total initial velocity vector - // (collision on a tangent) vector direction can be determined incorrectly. - // This code fixes the problem - - if (Math.abs(angleCollision) < Math.PI / 2) - { - if ((b1vx > 0) && !body1.immovable && (b2vx > b1vx)) - { - body1.velocity.x *= -1; - } - else if ((b2vx < 0) && !body2.immovable && (b1vx < b2vx)) - { - body2.velocity.x *= -1; - } - else if ((b1vy > 0) && !body1.immovable && (b2vy > b1vy)) - { - body1.velocity.y *= -1; - } - else if ((b2vy < 0) && !body2.immovable && (b1vy < b2vy)) - { - body2.velocity.y *= -1; - } - } - else if (Math.abs(angleCollision) > Math.PI / 2) - { - if ((b1vx < 0) && !body1.immovable && (b2vx < b1vx)) - { - body1.velocity.x *= -1; - } - else if ((b2vx > 0) && !body2.immovable && (b1vx > b2vx)) - { - body2.velocity.x *= -1; - } - else if ((b1vy < 0) && !body1.immovable && (b2vy < b1vy)) - { - body1.velocity.y *= -1; - } - else if ((b2vy > 0) && !body2.immovable && (b1vx > b2vy)) - { - body2.velocity.y *= -1; - } - } - - if (!body1.immovable) - { - body1.x += (body1.velocity.x * this.delta) - overlap * Math.cos(angleCollision); - body1.y += (body1.velocity.y * this.delta) - overlap * Math.sin(angleCollision); - } - - if (!body2.immovable) - { - body2.x += (body2.velocity.x * this.delta) + overlap * Math.cos(angleCollision); - body2.y += (body2.velocity.y * this.delta) + overlap * Math.sin(angleCollision); - } - - if (body1.onCollide || body2.onCollide) - { - this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); - } - - return true; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#intersects - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * - * @return {boolean} [description] - */ - intersects: function (body1, body2) - { - if (body1 === body2) - { - return false; - } - - if (body1.isCircle) - { - if (body2.isCircle) - { - // Circle vs. Circle - return DistanceBetween(body1.center.x, body1.center.y, body2.center.x, body2.center.y) <= (body1.halfWidth + body2.halfWidth); - } - else - { - // Circle vs. Rect - return this.circleBodyIntersects(body1, body2); - } - } - else if (body2.isCircle) - { - // Rect vs. Circle - return this.circleBodyIntersects(body2, body1); - } - else - { - // Rect vs. Rect - if (body1.right <= body2.position.x) - { - return false; - } - - if (body1.bottom <= body2.position.y) - { - return false; - } - - if (body1.position.x >= body2.right) - { - return false; - } - - if (body1.position.y >= body2.bottom) - { - return false; - } - - return true; - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#circleBodyIntersects - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} circle - [description] - * @param {Phaser.Physics.Arcade.Body} body - [description] - * - * @return {boolean} [description] - */ - circleBodyIntersects: function (circle, body) - { - var x = Clamp(circle.center.x, body.left, body.right); - var y = Clamp(circle.center.y, body.top, body.bottom); - - var dx = (circle.center.x - x) * (circle.center.x - x); - var dy = (circle.center.y - y) * (circle.center.y - y); - - return (dx + dy) <= (circle.halfWidth * circle.halfWidth); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#overlap - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} object1 - [description] - * @param {Phaser.GameObjects.GameObject} object2 - [description] - * @param {function} overlapCallback - [description] - * @param {function} processCallback - [description] - * @param {object} callbackContext - [description] - * - * @return {boolean} [description] - */ - overlap: function (object1, object2, overlapCallback, processCallback, callbackContext) - { - if (overlapCallback === undefined) { overlapCallback = null; } - if (processCallback === undefined) { processCallback = null; } - if (callbackContext === undefined) { callbackContext = overlapCallback; } - - return this.collideObjects(object1, object2, overlapCallback, processCallback, callbackContext, true); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#collide - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} object1 - [description] - * @param {Phaser.GameObjects.GameObject} object2 - [description] - * @param {function} collideCallback - [description] - * @param {function} processCallback - [description] - * @param {object} callbackContext - [description] - * - * @return {boolean} [description] - */ - collide: function (object1, object2, collideCallback, processCallback, callbackContext) - { - if (collideCallback === undefined) { collideCallback = null; } - if (processCallback === undefined) { processCallback = null; } - if (callbackContext === undefined) { callbackContext = collideCallback; } - - return this.collideObjects(object1, object2, collideCallback, processCallback, callbackContext, false); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#collideObjects - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} object1 - [description] - * @param {Phaser.GameObjects.GameObject} object2 - [description] - * @param {function} collideCallback - [description] - * @param {function} processCallback - [description] - * @param {object} callbackContext - [description] - * @param {boolean} overlapOnly - [description] - * - * @return {boolean} [description] - */ - collideObjects: function (object1, object2, collideCallback, processCallback, callbackContext, overlapOnly) - { - var i; - object1 = object1.isParent && typeof(object1.physicsType) === 'undefined' ? object1.children.entries : object1; - object2 = object2.isParent && typeof(object2.physicsType) === 'undefined' ? object2.children.entries : object2; - var object1isArray = Array.isArray(object1); - var object2isArray = Array.isArray(object2); - - this._total = 0; - - if (!object1isArray && !object2isArray) - { - // Neither of them are arrays - do this first as it's the most common use-case - this.collideHandler(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (!object1isArray && object2isArray) - { - // Object 2 is an Array - for (i = 0; i < object2.length; i++) - { - this.collideHandler(object1, object2[i], collideCallback, processCallback, callbackContext, overlapOnly); - } - } - else if (object1isArray && !object2isArray) - { - // Object 1 is an Array - for (i = 0; i < object1.length; i++) - { - this.collideHandler(object1[i], object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - } - else - { - // They're both arrays - for (i = 0; i < object1.length; i++) - { - for (var j = 0; j < object2.length; j++) - { - this.collideHandler(object1[i], object2[j], collideCallback, processCallback, callbackContext, overlapOnly); - } - } - } - - return (this._total > 0); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#collideHandler - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} object1 - [description] - * @param {Phaser.GameObjects.GameObject} object2 - [description] - * @param {function} collideCallback - [description] - * @param {function} processCallback - [description] - * @param {object} callbackContext - [description] - * @param {boolean} overlapOnly - [description] - * - * @return {boolean} [description] - */ - collideHandler: function (object1, object2, collideCallback, processCallback, callbackContext, overlapOnly) - { - // Collide Group with Self - // Only collide valid objects - if (object2 === undefined && object1.isParent) - { - return this.collideGroupVsGroup(object1, object1, collideCallback, processCallback, callbackContext, overlapOnly); - } - - // If neither of the objects are set then bail out - if (!object1 || !object2) - { - return false; - } - - // A Body - if (object1.body) - { - if (object2.body) - { - return this.collideSpriteVsSprite(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (object2.isParent) - { - return this.collideSpriteVsGroup(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (object2.isTilemap) - { - return this.collideSpriteVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - } - - // GROUPS - else if (object1.isParent) - { - if (object2.body) - { - return this.collideSpriteVsGroup(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (object2.isParent) - { - return this.collideGroupVsGroup(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (object2.isTilemap) - { - return this.collideGroupVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - } - - // TILEMAP LAYERS - else if (object1.isTilemap) - { - if (object2.body) - { - return this.collideSpriteVsTilemapLayer(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (object2.isParent) - { - return this.collideGroupVsTilemapLayer(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); - } - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#collideSpriteVsSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} sprite1 - [description] - * @param {Phaser.GameObjects.GameObject} sprite2 - [description] - * @param {function} collideCallback - [description] - * @param {function} processCallback - [description] - * @param {object} callbackContext - [description] - * @param {boolean} overlapOnly - [description] - * - * @return {boolean} [description] - */ - collideSpriteVsSprite: function (sprite1, sprite2, collideCallback, processCallback, callbackContext, overlapOnly) - { - if (!sprite1.body || !sprite2.body) - { - return false; - } - - if (this.separate(sprite1.body, sprite2.body, processCallback, callbackContext, overlapOnly)) - { - if (collideCallback) - { - collideCallback.call(callbackContext, sprite1, sprite2); - } - - this._total++; - } - - return true; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#collideSpriteVsGroup - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} sprite - [description] - * @param {Phaser.GameObjects.Group} group - [description] - * @param {function} collideCallback - [description] - * @param {function} processCallback - [description] - * @param {object} callbackContext - [description] - * @param {boolean} overlapOnly - [description] - * - * @return {boolean} [description] - */ - collideSpriteVsGroup: function (sprite, group, collideCallback, processCallback, callbackContext, overlapOnly) - { - var bodyA = sprite.body; - - if (group.length === 0 || !bodyA) - { - return; - } - - // Does sprite collide with anything? - - var minMax = this.treeMinMax; - - minMax.minX = bodyA.left; - minMax.minY = bodyA.top; - minMax.maxX = bodyA.right; - minMax.maxY = bodyA.bottom; - - var results = (group.physicsType === CONST.DYNAMIC_BODY) ? this.tree.search(minMax) : this.staticTree.search(minMax); - - if (results.length === 0) - { - return; - } - - var children = group.getChildren(); - - for (var i = 0; i < children.length; i++) - { - var bodyB = children[i].body; - - if (!bodyB || bodyA === bodyB || results.indexOf(bodyB) === -1) - { - continue; - } - - if (this.separate(bodyA, bodyB, processCallback, callbackContext, overlapOnly)) - { - if (collideCallback) - { - collideCallback.call(callbackContext, bodyA.gameObject, bodyB.gameObject); - } - - this._total++; - } - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#collideGroupVsTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Group} group - [description] - * @param {[type]} tilemapLayer - [description] - * @param {function} collideCallback - [description] - * @param {function} processCallback - [description] - * @param {object} callbackContext - [description] - * @param {boolean} overlapOnly - [description] - * - * @return {boolean} [description] - */ - collideGroupVsTilemapLayer: function (group, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) - { - var children = group.getChildren(); - - if (children.length === 0) - { - return false; - } - - var didCollide = false; - - for (var i = 0; i < children.length; i++) - { - if (children[i].body) - { - if (this.collideSpriteVsTilemapLayer(children[i], tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly)) - { - didCollide = true; - } - } - } - - return didCollide; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#collideSpriteVsTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} sprite - [description] - * @param {[type]} tilemapLayer - [description] - * @param {function} collideCallback - [description] - * @param {function} processCallback - [description] - * @param {object} callbackContext - [description] - * @param {boolean} overlapOnly - [description] - * - * @return {boolean} [description] - */ - collideSpriteVsTilemapLayer: function (sprite, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) - { - var body = sprite.body; - - if (!body.enable) - { - return false; - } - - var x = body.position.x; - var y = body.position.y; - var w = body.width; - var h = body.height; - - // TODO: this logic should be encapsulated within the Tilemap API at some point. - // If the maps base tile size differs from the layer's tile size, we need to adjust the - // selection area by the difference between the two. - var layerData = tilemapLayer.layer; - - if (layerData.tileWidth > layerData.baseTileWidth) - { - // The x origin of a tile is the left side, so x and width need to be adjusted. - var xDiff = (layerData.tileWidth - layerData.baseTileWidth) * tilemapLayer.scaleX; - x -= xDiff; - w += xDiff; - } - - if (layerData.tileHeight > layerData.baseTileHeight) - { - // The y origin of a tile is the bottom side, so just the height needs to be adjusted. - var yDiff = (layerData.tileHeight - layerData.baseTileHeight) * tilemapLayer.scaleY; - h += yDiff; - } - - var mapData = tilemapLayer.getTilesWithinWorldXY(x, y, w, h); - - if (mapData.length === 0) - { - return false; - } - - var tile; - var tileWorldRect = { left: 0, right: 0, top: 0, bottom: 0 }; - - for (var i = 0; i < mapData.length; i++) - { - tile = mapData[i]; - tileWorldRect.left = tilemapLayer.tileToWorldX(tile.x); - tileWorldRect.top = tilemapLayer.tileToWorldY(tile.y); - - // If the map's base tile size differs from the layer's tile size, only the top of the rect - // needs to be adjusted since it's origin is (0, 1). - if (tile.baseHeight !== tile.height) - { - tileWorldRect.top -= (tile.height - tile.baseHeight) * tilemapLayer.scaleY; - } - - tileWorldRect.right = tileWorldRect.left + tile.width * tilemapLayer.scaleX; - tileWorldRect.bottom = tileWorldRect.top + tile.height * tilemapLayer.scaleY; - - if (TileIntersectsBody(tileWorldRect, body) - && (!processCallback || processCallback.call(callbackContext, sprite, tile)) - && ProcessTileCallbacks(tile, sprite) - && (overlapOnly || SeparateTile(i, body, tile, tileWorldRect, tilemapLayer, this.TILE_BIAS))) - { - this._total++; - - if (collideCallback) - { - collideCallback.call(callbackContext, sprite, tile); - } - - if (overlapOnly && body.onOverlap) - { - sprite.emit('overlap', body.gameObject, tile, body, null); - } - else if (body.onCollide) - { - sprite.emit('collide', body.gameObject, tile, body, null); - } - } - } - }, - - /** - * TODO! - * - * @method Phaser.Physics.Arcade.World#collideGroupVsGroup - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Group} group1 - [description] - * @param {Phaser.GameObjects.Group} group2 - [description] - * @param {function} collideCallback - [description] - * @param {function} processCallback - [description] - * @param {object} callbackContext - [description] - * @param {boolean} overlapOnly - [description] - * - * @return {boolean} [description] - */ - collideGroupVsGroup: function (group1, group2, collideCallback, processCallback, callbackContext, overlapOnly) - { - if (group1.length === 0 || group2.length === 0) - { - return; - } - - var children = group1.getChildren(); - - for (var i = 0; i < children.length; i++) - { - this.collideSpriteVsGroup(children[i], group2, collideCallback, processCallback, callbackContext, overlapOnly); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this.removeAllListeners(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.World#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.tree.clear(); - this.staticTree.clear(); - this.bodies.clear(); - this.staticBodies.clear(); - this.colliders.destroy(); - - this.removeAllListeners(); - } - -}); - -module.exports = World; - - -/***/ }), -/* 332 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CircleContains = __webpack_require__(32); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(59); -var Rectangle = __webpack_require__(8); -var RectangleContains = __webpack_require__(33); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * [description] - * - * @class Body - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.World} world - [description] - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - */ -var Body = new Class({ - - initialize: - - function Body (world, gameObject) - { - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world = world; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#gameObject - * @type {Phaser.GameObjects.GameObject} - * @since 3.0.0 - */ - this.gameObject = gameObject; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#debugShowBody - * @type {boolean} - * @since 3.0.0 - */ - this.debugShowBody = world.defaults.debugShowBody; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#debugShowVelocity - * @type {boolean} - * @since 3.0.0 - */ - this.debugShowVelocity = world.defaults.debugShowVelocity; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#debugBodyColor - * @type {integer} - * @since 3.0.0 - */ - this.debugBodyColor = world.defaults.bodyDebugColor; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#enable - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.enable = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#isCircle - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isCircle = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#radius - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.radius = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#offset - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.offset = new Vector2(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#position - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.position = new Vector2(gameObject.x, gameObject.y); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#prev - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.prev = new Vector2(this.position.x, this.position.y); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#allowRotation - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.allowRotation = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#rotation - * @type {number} - * @since 3.0.0 - */ - this.rotation = gameObject.angle; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#preRotation - * @type {number} - * @since 3.0.0 - */ - this.preRotation = gameObject.angle; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#width - * @type {number} - * @since 3.0.0 - */ - this.width = gameObject.width; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#height - * @type {number} - * @since 3.0.0 - */ - this.height = gameObject.height; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#sourceWidth - * @type {number} - * @since 3.0.0 - */ - this.sourceWidth = gameObject.width; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#sourceHeight - * @type {number} - * @since 3.0.0 - */ - this.sourceHeight = gameObject.height; - - if (gameObject.frame) - { - this.sourceWidth = gameObject.frame.realWidth; - this.sourceHeight = gameObject.frame.realHeight; - } - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#halfWidth - * @type {number} - * @since 3.0.0 - */ - this.halfWidth = Math.abs(gameObject.width / 2); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#halfHeight - * @type {number} - * @since 3.0.0 - */ - this.halfHeight = Math.abs(gameObject.height / 2); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#center - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#velocity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.velocity = new Vector2(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#newVelocity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.newVelocity = new Vector2(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#deltaMax - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.deltaMax = new Vector2(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#acceleration - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.acceleration = new Vector2(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#allowDrag - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.allowDrag = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#drag - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.drag = new Vector2(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#allowGravity - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.allowGravity = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#gravity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.gravity = new Vector2(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#bounce - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.bounce = new Vector2(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#worldBounce - * @type {?[type]} - * @default null - * @since 3.0.0 - */ - this.worldBounce = null; - - // If true this Body will dispatch events - - /** - * Emit a `worldbounds` event when this body collides with the world bounds (and `collideWorldBounds` is also true). - * - * @name Phaser.Physics.Arcade.Body#onWorldBounds - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.onWorldBounds = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#onCollide - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.onCollide = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#onOverlap - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.onOverlap = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#maxVelocity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.maxVelocity = new Vector2(10000, 10000); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#friction - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.friction = new Vector2(1, 0); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#angularVelocity - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.angularVelocity = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#angularAcceleration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.angularAcceleration = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#angularDrag - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.angularDrag = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#maxAngular - * @type {number} - * @default 1000 - * @since 3.0.0 - */ - this.maxAngular = 1000; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#mass - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.mass = 1; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#angle - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.angle = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#speed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.speed = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#facing - * @type {integer} - * @since 3.0.0 - */ - this.facing = CONST.FACING_NONE; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#immovable - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.immovable = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#moves - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.moves = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#customSeparateX - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.customSeparateX = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#customSeparateY - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.customSeparateY = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#overlapX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapX = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#overlapY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapY = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#overlapR - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapR = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#embedded - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.embedded = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#collideWorldBounds - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.collideWorldBounds = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#checkCollision - * @type {object} - * @since 3.0.0 - */ - this.checkCollision = { none: false, up: true, down: true, left: true, right: true }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#touching - * @type {object} - * @since 3.0.0 - */ - this.touching = { none: true, up: false, down: false, left: false, right: false }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#wasTouching - * @type {object} - * @since 3.0.0 - */ - this.wasTouching = { none: true, up: false, down: false, left: false, right: false }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#blocked - * @type {object} - * @since 3.0.0 - */ - this.blocked = { none: true, up: false, down: false, left: false, right: false }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#dirty - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.dirty = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#syncBounds - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.syncBounds = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#isMoving - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isMoving = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#stopVelocityOnCollide - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.stopVelocityOnCollide = true; - - // read-only - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#physicsType - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.physicsType = CONST.DYNAMIC_BODY; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#_reset - * @type {boolean} - * @private - * @default true - * @since 3.0.0 - */ - this._reset = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#_sx - * @type {number} - * @private - * @since 3.0.0 - */ - this._sx = gameObject.scaleX; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#_sy - * @type {number} - * @private - * @since 3.0.0 - */ - this._sy = gameObject.scaleY; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#_dx - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._dx = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#_dy - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._dy = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#_bounds - * @type {Phaser.Geom.Rectangle} - * @private - * @since 3.0.0 - */ - this._bounds = new Rectangle(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#updateBounds - * @since 3.0.0 - */ - updateBounds: function () - { - var sprite = this.gameObject; - - if (this.syncBounds) - { - var b = sprite.getBounds(this._bounds); - - if (b.width !== this.width || b.height !== this.height) - { - this.width = b.width; - this.height = b.height; - this._reset = true; - } - } - else - { - var asx = Math.abs(sprite.scaleX); - var asy = Math.abs(sprite.scaleY); - - if (asx !== this._sx || asy !== this._sy) - { - this.width = this.sourceWidth * asx; - this.height = this.sourceHeight * asy; - this._sx = asx; - this._sy = asy; - this._reset = true; - } - } - - if (this._reset) - { - this.halfWidth = Math.floor(this.width / 2); - this.halfHeight = Math.floor(this.height / 2); - this.updateCenter(); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#updateCenter - * @since 3.0.0 - */ - updateCenter: function () - { - this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#update - * @since 3.0.0 - * - * @param {number} delta - [description] - */ - update: function (delta) - { - this.dirty = true; - - // Store and reset collision flags - this.wasTouching.none = this.touching.none; - this.wasTouching.up = this.touching.up; - this.wasTouching.down = this.touching.down; - this.wasTouching.left = this.touching.left; - this.wasTouching.right = this.touching.right; - - this.touching.none = true; - this.touching.up = false; - this.touching.down = false; - this.touching.left = false; - this.touching.right = false; - - this.blocked.none = true; - this.blocked.up = false; - this.blocked.down = false; - this.blocked.left = false; - this.blocked.right = false; - - this.overlapR = 0; - this.overlapX = 0; - this.overlapY = 0; - - this.embedded = false; - - this.updateBounds(); - - var sprite = this.gameObject; - - this.position.x = sprite.x + sprite.scaleX * (this.offset.x - sprite.displayOriginX); - this.position.y = sprite.y + sprite.scaleY * (this.offset.y - sprite.displayOriginY); - - this.updateCenter(); - - this.rotation = sprite.angle; - - this.preRotation = this.rotation; - - if (this._reset) - { - this.prev.x = this.position.x; - this.prev.y = this.position.y; - } - - if (this.moves) - { - this.world.updateMotion(this); - - this.newVelocity.set(this.velocity.x * delta, this.velocity.y * delta); - - this.position.x += this.newVelocity.x; - this.position.y += this.newVelocity.y; - - this.updateCenter(); - - if (this.position.x !== this.prev.x || this.position.y !== this.prev.y) - { - this.angle = Math.atan2(this.velocity.y, this.velocity.x); - } - - this.speed = Math.sqrt(this.velocity.x * this.velocity.x + this.velocity.y * this.velocity.y); - - // Now the State update will throw collision checks at the Body - // And finally we'll integrate the new position back to the Sprite in postUpdate - - if (this.collideWorldBounds && this.checkWorldBounds() && this.onWorldBounds) - { - this.world.emit('worldbounds', this, this.blocked.up, this.blocked.down, this.blocked.left, this.blocked.right); - } - } - - this._dx = this.deltaX(); - this._dy = this.deltaY(); - - this._reset = false; - }, - - /** - * Feeds the body results back into the parent gameobject. - * - * @method Phaser.Physics.Arcade.Body#postUpdate - * @since 3.0.0 - */ - postUpdate: function () - { - // Only allow postUpdate to be called once per frame - if (!this.enable || !this.dirty) - { - return; - } - - this.dirty = false; - - this._dx = this.deltaX(); - this._dy = this.deltaY(); - - if (this._dx < 0) - { - this.facing = CONST.FACING_LEFT; - } - else if (this._dx > 0) - { - this.facing = CONST.FACING_RIGHT; - } - - if (this._dy < 0) - { - this.facing = CONST.FACING_UP; - } - else if (this._dy > 0) - { - this.facing = CONST.FACING_DOWN; - } - - if (this.moves) - { - if (this.deltaMax.x !== 0 && this._dx !== 0) - { - if (this._dx < 0 && this._dx < -this.deltaMax.x) - { - this._dx = -this.deltaMax.x; - } - else if (this._dx > 0 && this._dx > this.deltaMax.x) - { - this._dx = this.deltaMax.x; - } - } - - if (this.deltaMax.y !== 0 && this._dy !== 0) - { - if (this._dy < 0 && this._dy < -this.deltaMax.y) - { - this._dy = -this.deltaMax.y; - } - else if (this._dy > 0 && this._dy > this.deltaMax.y) - { - this._dy = this.deltaMax.y; - } - } - - this.gameObject.x += this._dx; - this.gameObject.y += this._dy; - - this._reset = true; - } - - this.updateCenter(); - - if (this.allowRotation) - { - this.gameObject.angle += this.deltaZ(); - } - - this.prev.x = this.position.x; - this.prev.y = this.position.y; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#checkWorldBounds - * @since 3.0.0 - * - * @return {boolean} [description] - */ - checkWorldBounds: function () - { - var pos = this.position; - var bounds = this.world.bounds; - var check = this.world.checkCollision; - - var bx = (this.worldBounce) ? -this.worldBounce.x : -this.bounce.x; - var by = (this.worldBounce) ? -this.worldBounce.y : -this.bounce.y; - - if (pos.x < bounds.x && check.left) - { - pos.x = bounds.x; - this.velocity.x *= bx; - this.blocked.left = true; - this.blocked.none = false; - } - else if (this.right > bounds.right && check.right) - { - pos.x = bounds.right - this.width; - this.velocity.x *= bx; - this.blocked.right = true; - this.blocked.none = false; - } - - if (pos.y < bounds.y && check.up) - { - pos.y = bounds.y; - this.velocity.y *= by; - this.blocked.up = true; - this.blocked.none = false; - } - else if (this.bottom > bounds.bottom && check.down) - { - pos.y = bounds.bottom - this.height; - this.velocity.y *= by; - this.blocked.down = true; - this.blocked.none = false; - } - - return !this.blocked.none; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setOffset - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setOffset: function (x, y) - { - if (y === undefined) { y = x; } - - this.offset.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setSize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {boolean} [center=true] - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setSize: function (width, height, center) - { - if (center === undefined) { center = true; } - - var gameObject = this.gameObject; - - this.sourceWidth = width; - this.sourceHeight = height; - - this.width = this.sourceWidth * this._sx; - this.height = this.sourceHeight * this._sy; - - this.halfWidth = Math.floor(this.width / 2); - this.halfHeight = Math.floor(this.height / 2); - - this.updateCenter(); - - if (center && gameObject.getCenter) - { - var ox = gameObject.displayWidth / 2; - var oy = gameObject.displayHeight / 2; - - this.offset.set(ox - this.halfWidth, oy - this.halfHeight); - } - - this.isCircle = false; - this.radius = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setCircle - * @since 3.0.0 - * - * @param {number} radius - [description] - * @param {number} [offsetX] - [description] - * @param {number} [offsetY] - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setCircle: function (radius, offsetX, offsetY) - { - if (offsetX === undefined) { offsetX = this.offset.x; } - if (offsetY === undefined) { offsetY = this.offset.y; } - - if (radius > 0) - { - this.isCircle = true; - this.radius = radius; - - this.sourceWidth = radius * 2; - this.sourceHeight = radius * 2; - - this.width = this.sourceWidth * this._sx; - this.height = this.sourceHeight * this._sy; - - this.halfWidth = Math.floor(this.width / 2); - this.halfHeight = Math.floor(this.height / 2); - - this.offset.set(offsetX, offsetY); - - this.updateCenter(); - } - else - { - this.isCircle = false; - } - - return this; - }, - - /** - * Resets this Body to the given coordinates. Also positions its parent Game Object to the same coordinates. - * If the body had any velocity or acceleration it is lost as a result of calling this. - * - * @method Phaser.Physics.Arcade.Body#reset - * @since 3.0.0 - * - * @param {number} x - The horizontal position to place the Game Object and Body. - * @param {number} y - The vertical position to place the Game Object and Body. - */ - reset: function (x, y) - { - this.stop(); - - var gameObject = this.gameObject; - - gameObject.setPosition(x, y); - - gameObject.getTopLeft(this.position); - - this.prev.copy(this.position); - - this.rotation = gameObject.angle; - this.preRotation = gameObject.angle; - - this.updateBounds(); - this.updateCenter(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#stop - * @since 3.0.0 - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - stop: function () - { - this.velocity.set(0); - this.acceleration.set(0); - this.speed = 0; - this.angularVelocity = 0; - this.angularAcceleration = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#getBounds - * @since 3.0.0 - * - * @param {object} obj - [description] - * - * @return {object} [description] - */ - getBounds: function (obj) - { - obj.x = this.x; - obj.y = this.y; - obj.right = this.right; - obj.bottom = this.bottom; - - return obj; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#hitTest - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ - hitTest: function (x, y) - { - return (this.isCircle) ? CircleContains(this, x, y) : RectangleContains(this, x, y); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#onFloor - * @since 3.0.0 - * - * @return {boolean} [description] - */ - onFloor: function () - { - return this.blocked.down; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#onCeiling - * @since 3.0.0 - * - * @return {boolean} [description] - */ - onCeiling: function () - { - return this.blocked.up; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#onWall - * @since 3.0.0 - * - * @return {boolean} [description] - */ - onWall: function () - { - return (this.blocked.left || this.blocked.right); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#deltaAbsX - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaAbsX: function () - { - return (this.deltaX() > 0) ? this.deltaX() : -this.deltaX(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#deltaAbsY - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaAbsY: function () - { - return (this.deltaY() > 0) ? this.deltaY() : -this.deltaY(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#deltaX - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaX: function () - { - return this.position.x - this.prev.x; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#deltaY - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaY: function () - { - return this.position.y - this.prev.y; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#deltaZ - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaZ: function () - { - return this.rotation - this.preRotation; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.enable = false; - - this.world.pendingDestroy.set(this); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#drawDebug - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphic - [description] - */ - drawDebug: function (graphic) - { - var pos = this.position; - var x = pos.x + this.halfWidth; - var y = pos.y + this.halfHeight; - - if (this.debugShowBody) - { - graphic.lineStyle(1, this.debugBodyColor); - - if (this.isCircle) - { - graphic.strokeCircle(x, y, this.radius); - } - else - { - graphic.strokeRect(pos.x, pos.y, this.width, this.height); - } - } - - if (this.debugShowVelocity) - { - graphic.lineStyle(1, this.world.defaults.velocityDebugColor, 1); - graphic.lineBetween(x, y, x + this.velocity.x / 2, y + this.velocity.y / 2); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#willDrawDebug - * @since 3.0.0 - * - * @return {boolean} [description] - */ - willDrawDebug: function () - { - return (this.debugShowBody || this.debugShowVelocity); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setCollideWorldBounds - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setCollideWorldBounds: function (value) - { - this.collideWorldBounds = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setVelocity - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setVelocity: function (x, y) - { - this.velocity.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setVelocityX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setVelocityX: function (value) - { - this.velocity.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setVelocityY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setVelocityY: function (value) - { - this.velocity.y = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setBounce - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setBounce: function (x, y) - { - this.bounce.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setBounceX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setBounceX: function (value) - { - this.bounce.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setBounceY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setBounceY: function (value) - { - this.bounce.y = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setAcceleration - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAcceleration: function (x, y) - { - this.acceleration.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setAccelerationX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAccelerationX: function (value) - { - this.acceleration.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setAccelerationY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAccelerationY: function (value) - { - this.acceleration.y = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setDrag - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setDrag: function (x, y) - { - this.drag.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setDragX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setDragX: function (value) - { - this.drag.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setDragY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setDragY: function (value) - { - this.drag.y = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setGravity - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setGravity: function (x, y) - { - this.gravity.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setGravityX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setGravityX: function (value) - { - this.gravity.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setGravityY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setGravityY: function (value) - { - this.gravity.y = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setFriction - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setFriction: function (x, y) - { - this.friction.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setFrictionX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setFrictionX: function (value) - { - this.friction.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setFrictionY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setFrictionY: function (value) - { - this.friction.y = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setAngularVelocity - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAngularVelocity: function (value) - { - this.angularVelocity = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setAngularAcceleration - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAngularAcceleration: function (value) - { - this.angularAcceleration = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setAngularDrag - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAngularDrag: function (value) - { - this.angularDrag = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setMass - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setMass: function (value) - { - this.mass = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Body#setImmovable - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setImmovable: function (value) - { - this.immovable = value; - - return this; - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#x - * @type {number} - * @since 3.0.0 - */ - x: { - - get: function () - { - return this.position.x; - }, - - set: function (value) - { - this.position.x = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#y - * @type {number} - * @since 3.0.0 - */ - y: { - - get: function () - { - return this.position.y; - }, - - set: function (value) - { - this.position.y = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#left - * @type {number} - * @readOnly - * @since 3.0.0 - */ - left: { - - get: function () - { - return this.position.x; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#right - * @type {number} - * @readOnly - * @since 3.0.0 - */ - right: { - - get: function () - { - return this.position.x + this.width; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#top - * @type {number} - * @readOnly - * @since 3.0.0 - */ - top: { - - get: function () - { - return this.position.y; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Body#bottom - * @type {number} - * @readOnly - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return this.position.y + this.height; - } - - } - -}); - -module.exports = Body; - - -/***/ }), -/* 333 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class Collider - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.World} world - [description] - * @param {boolean} overlapOnly - [description] - * @param {Phaser.Physics.Arcade.Body} object1 - The first object to check for collision. - * @param {Phaser.Physics.Arcade.Body} object2 - The second object to check for collision. - * @param {function} collideCallback - The callback to invoke when the two objects collide. - * @param {function} processCallback - The callback to invoke when the two objects collide. Must return a boolean. - * @param {object} callbackContext - The scope in which to call the callbacks. - */ -var Collider = new Class({ - - initialize: - - function Collider (world, overlapOnly, object1, object2, collideCallback, processCallback, callbackContext) - { - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world = world; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#name - * @type {string} - * @since 3.1.0 - */ - this.name = ''; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#active - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.active = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#overlapOnly - * @type {boolean} - * @since 3.0.0 - */ - this.overlapOnly = overlapOnly; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#object1 - * @type {Phaser.Physics.Arcade.Body} - * @since 3.0.0 - */ - this.object1 = object1; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#object2 - * @type {Phaser.Physics.Arcade.Body} - * @since 3.0.0 - */ - this.object2 = object2; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#collideCallback - * @type {function} - * @since 3.0.0 - */ - this.collideCallback = collideCallback; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#processCallback - * @type {function} - * @since 3.0.0 - */ - this.processCallback = processCallback; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#callbackContext - * @type {object} - * @since 3.0.0 - */ - this.callbackContext = callbackContext; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Collider#setName - * @since 3.1.0 - * - * @param {string} name - [description] - * - * @return {Phaser.Physics.Arcade.Collider} [description] - */ - setName: function (name) - { - this.name = name; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Collider#update - * @since 3.0.0 - */ - update: function () - { - this.world.collideObjects( - this.object1, - this.object2, - this.collideCallback, - this.processCallback, - this.callbackContext, - this.overlapOnly - ); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Collider#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.world.removeCollider(this); - - this.active = false; - - this.world = null; - - this.object1 = null; - this.object2 = null; - - this.collideCallback = null; - this.processCallback = null; - this.callbackContext = null; - } - -}); - -module.exports = Collider; - - -/***/ }), -/* 334 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Physics.Arcade.GetOverlapX - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {boolean} overlapOnly - [description] - * @param {number} bias - [description] - * - * @return {number} [description] - */ -var GetOverlapX = function (body1, body2, overlapOnly, bias) -{ - var overlap = 0; - var maxOverlap = body1.deltaAbsX() + body2.deltaAbsX() + bias; - - if (body1.deltaX() === 0 && body2.deltaX() === 0) - { - // They overlap but neither of them are moving - body1.embedded = true; - body2.embedded = true; - } - else if (body1.deltaX() > body2.deltaX()) - { - // Body1 is moving right and / or Body2 is moving left - overlap = body1.right - body2.x; - - if ((overlap > maxOverlap && !overlapOnly) || body1.checkCollision.right === false || body2.checkCollision.left === false) - { - overlap = 0; - } - else - { - body1.touching.none = false; - body1.touching.right = true; - body2.touching.none = false; - body2.touching.left = true; - } - } - else if (body1.deltaX() < body2.deltaX()) - { - // Body1 is moving left and/or Body2 is moving right - overlap = body1.x - body2.width - body2.x; - - if ((-overlap > maxOverlap && !overlapOnly) || body1.checkCollision.left === false || body2.checkCollision.right === false) - { - overlap = 0; - } - else - { - body1.touching.none = false; - body1.touching.left = true; - body2.touching.none = false; - body2.touching.right = true; - } - } - - // Resets the overlapX to zero if there is no overlap, or to the actual pixel value if there is - body1.overlapX = overlap; - body2.overlapX = overlap; - - return overlap; -}; - -module.exports = GetOverlapX; - - -/***/ }), -/* 335 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Physics.Arcade.GetOverlapY - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {boolean} overlapOnly - [description] - * @param {number} bias - [description] - * - * @return {number} [description] - */ -var GetOverlapY = function (body1, body2, overlapOnly, bias) -{ - var overlap = 0; - var maxOverlap = body1.deltaAbsY() + body2.deltaAbsY() + bias; - - if (body1.deltaY() === 0 && body2.deltaY() === 0) - { - // They overlap but neither of them are moving - body1.embedded = true; - body2.embedded = true; - } - else if (body1.deltaY() > body2.deltaY()) - { - // Body1 is moving down and/or Body2 is moving up - overlap = body1.bottom - body2.y; - - if ((overlap > maxOverlap && !overlapOnly) || body1.checkCollision.down === false || body2.checkCollision.up === false) - { - overlap = 0; - } - else - { - body1.touching.none = false; - body1.touching.down = true; - body2.touching.none = false; - body2.touching.up = true; - } - } - else if (body1.deltaY() < body2.deltaY()) - { - // Body1 is moving up and/or Body2 is moving down - overlap = body1.y - body2.bottom; - - if ((-overlap > maxOverlap && !overlapOnly) || body1.checkCollision.up === false || body2.checkCollision.down === false) - { - overlap = 0; - } - else - { - body1.touching.none = false; - body1.touching.up = true; - body2.touching.none = false; - body2.touching.down = true; - } - } - - // Resets the overlapY to zero if there is no overlap, or to the actual pixel value if there is - body1.overlapY = overlap; - body2.overlapY = overlap; - - return overlap; -}; - -module.exports = GetOverlapY; - - -/***/ }), -/* 336 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class ProcessQueue - * @memberOf Phaser.Structs - * @constructor - * @since 3.0.0 - */ -var ProcessQueue = new Class({ - - initialize: - - function ProcessQueue () - { - /** - * [description] - * - * @name Phaser.Structs.ProcessQueue#_pending - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._pending = []; - - /** - * [description] - * - * @name Phaser.Structs.ProcessQueue#_active - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._active = []; - - /** - * [description] - * - * @name Phaser.Structs.ProcessQueue#_destroy - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._destroy = []; - - /** - * [description] - * - * @name Phaser.Structs.ProcessQueue#_toProcess - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - this._toProcess = 0; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#add - * @since 3.0.0 - * - * @param {any} item - [description] - * - * @return {Phaser.Structs.ProcessQueue} This Process Queue object. - */ - add: function (item) - { - this._pending.push(item); - - this._toProcess++; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#remove - * @since 3.0.0 - * - * @param {any} item - [description] - * - * @return {Phaser.Structs.ProcessQueue} This Process Queue object. - */ - remove: function (item) - { - this._destroy.push(item); - - this._toProcess++; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#update - * @since 3.0.0 - * - * @return {array} [description] - */ - update: function () - { - if (this._toProcess === 0) - { - // Quick bail - return this._active; - } - - var list = this._destroy; - var active = this._active; - var i; - var item; - - // Clear the 'destroy' list - for (i = 0; i < list.length; i++) - { - item = list[i]; - - // Remove from the 'active' array - var idx = active.indexOf(item); - - if (idx !== -1) - { - active.splice(idx, 1); - } - } - - list.length = 0; - - // Process the pending addition list - // This stops callbacks and out of sync events from populating the active array mid-way during an update - - list = this._pending; - - for (i = 0; i < list.length; i++) - { - item = list[i]; - - this._active.push(item); - } - - list.length = 0; - - this._toProcess = 0; - - // The owner of this queue can now safely do whatever it needs to with the active list - return this._active; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#getActive - * @since 3.0.0 - * - * @return {array} [description] - */ - getActive: function () - { - return this._active; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#destroy - * @since 3.0.0 - */ - destroy: function () - { - this._pending = []; - this._active = []; - this._destroy = []; - } - -}); - -module.exports = ProcessQueue; - - -/***/ }), -/* 337 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var quickselect = __webpack_require__(338); - -/** - * @classdesc - * RBush is a high-performance JavaScript library for 2D spatial indexing of points and rectangles. - * It's based on an optimized R-tree data structure with bulk insertion support. - * - * Spatial index is a special data structure for points and rectangles that allows you to perform queries like - * "all items within this bounding box" very efficiently (e.g. hundreds of times faster than looping over all items). - * - * @class RTree - * @memberOf Phaser.Structs - * @constructor - * @since 3.0.0 - */ - -function rbush (maxEntries, format) -{ - if (!(this instanceof rbush)) return new rbush(maxEntries, format); - - // max entries in a node is 9 by default; min node fill is 40% for best performance - this._maxEntries = Math.max(4, maxEntries || 9); - this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)); - - if (format) - { - this._initFormat(format); - } - - this.clear(); -} - -rbush.prototype = { - - all: function () - { - return this._all(this.data, []); - }, - - search: function (bbox) - { - var node = this.data, - result = [], - toBBox = this.toBBox; - - if (!intersects(bbox, node)) return result; - - var nodesToSearch = [], - i, len, child, childBBox; - - while (node) { - for (i = 0, len = node.children.length; i < len; i++) { - - child = node.children[i]; - childBBox = node.leaf ? toBBox(child) : child; - - if (intersects(bbox, childBBox)) { - if (node.leaf) result.push(child); - else if (contains(bbox, childBBox)) this._all(child, result); - else nodesToSearch.push(child); - } - } - node = nodesToSearch.pop(); - } - - return result; - }, - - collides: function (bbox) - { - var node = this.data, - toBBox = this.toBBox; - - if (!intersects(bbox, node)) return false; - - var nodesToSearch = [], - i, len, child, childBBox; - - while (node) { - for (i = 0, len = node.children.length; i < len; i++) { - - child = node.children[i]; - childBBox = node.leaf ? toBBox(child) : child; - - if (intersects(bbox, childBBox)) { - if (node.leaf || contains(bbox, childBBox)) return true; - nodesToSearch.push(child); - } - } - node = nodesToSearch.pop(); - } - - return false; - }, - - load: function (data) - { - if (!(data && data.length)) return this; - - if (data.length < this._minEntries) { - for (var i = 0, len = data.length; i < len; i++) { - this.insert(data[i]); - } - return this; - } - - // recursively build the tree with the given data from scratch using OMT algorithm - var node = this._build(data.slice(), 0, data.length - 1, 0); - - if (!this.data.children.length) { - // save as is if tree is empty - this.data = node; - - } else if (this.data.height === node.height) { - // split root if trees have the same height - this._splitRoot(this.data, node); - - } else { - if (this.data.height < node.height) { - // swap trees if inserted one is bigger - var tmpNode = this.data; - this.data = node; - node = tmpNode; - } - - // insert the small tree into the large tree at appropriate level - this._insert(node, this.data.height - node.height - 1, true); - } - - return this; - }, - - insert: function (item) - { - if (item) this._insert(item, this.data.height - 1); - return this; - }, - - clear: function () - { - this.data = createNode([]); - return this; - }, - - remove: function (item, equalsFn) - { - if (!item) return this; - - var node = this.data, - bbox = this.toBBox(item), - path = [], - indexes = [], - i, parent, index, goingUp; - - // depth-first iterative tree traversal - while (node || path.length) { - - if (!node) { // go up - node = path.pop(); - parent = path[path.length - 1]; - i = indexes.pop(); - goingUp = true; - } - - if (node.leaf) { // check current node - index = findItem(item, node.children, equalsFn); - - if (index !== -1) { - // item found, remove the item and condense tree upwards - node.children.splice(index, 1); - path.push(node); - this._condense(path); - return this; - } - } - - if (!goingUp && !node.leaf && contains(node, bbox)) { // go down - path.push(node); - indexes.push(i); - i = 0; - parent = node; - node = node.children[0]; - - } else if (parent) { // go right - i++; - node = parent.children[i]; - goingUp = false; - - } else node = null; // nothing found - } - - return this; - }, - - toBBox: function (item) { return item; }, - - compareMinX: compareNodeMinX, - compareMinY: compareNodeMinY, - - toJSON: function () { return this.data; }, - - fromJSON: function (data) - { - this.data = data; - return this; - }, - - _all: function (node, result) - { - var nodesToSearch = []; - while (node) { - if (node.leaf) result.push.apply(result, node.children); - else nodesToSearch.push.apply(nodesToSearch, node.children); - - node = nodesToSearch.pop(); - } - return result; - }, - - _build: function (items, left, right, height) - { - var N = right - left + 1, - M = this._maxEntries, - node; - - if (N <= M) { - // reached leaf level; return leaf - node = createNode(items.slice(left, right + 1)); - calcBBox(node, this.toBBox); - return node; - } - - if (!height) { - // target height of the bulk-loaded tree - height = Math.ceil(Math.log(N) / Math.log(M)); - - // target number of root entries to maximize storage utilization - M = Math.ceil(N / Math.pow(M, height - 1)); - } - - node = createNode([]); - node.leaf = false; - node.height = height; - - // split the items into M mostly square tiles - - var N2 = Math.ceil(N / M), - N1 = N2 * Math.ceil(Math.sqrt(M)), - i, j, right2, right3; - - multiSelect(items, left, right, N1, this.compareMinX); - - for (i = left; i <= right; i += N1) { - - right2 = Math.min(i + N1 - 1, right); - - multiSelect(items, i, right2, N2, this.compareMinY); - - for (j = i; j <= right2; j += N2) { - - right3 = Math.min(j + N2 - 1, right2); - - // pack each entry recursively - node.children.push(this._build(items, j, right3, height - 1)); - } - } - - calcBBox(node, this.toBBox); - - return node; - }, - - _chooseSubtree: function (bbox, node, level, path) - { - var i, len, child, targetNode, area, enlargement, minArea, minEnlargement; - - while (true) { - path.push(node); - - if (node.leaf || path.length - 1 === level) break; - - minArea = minEnlargement = Infinity; - - for (i = 0, len = node.children.length; i < len; i++) { - child = node.children[i]; - area = bboxArea(child); - enlargement = enlargedArea(bbox, child) - area; - - // choose entry with the least area enlargement - if (enlargement < minEnlargement) { - minEnlargement = enlargement; - minArea = area < minArea ? area : minArea; - targetNode = child; - - } else if (enlargement === minEnlargement) { - // otherwise choose one with the smallest area - if (area < minArea) { - minArea = area; - targetNode = child; - } - } - } - - node = targetNode || node.children[0]; - } - - return node; - }, - - _insert: function (item, level, isNode) - { - var toBBox = this.toBBox, - bbox = isNode ? item : toBBox(item), - insertPath = []; - - // find the best node for accommodating the item, saving all nodes along the path too - var node = this._chooseSubtree(bbox, this.data, level, insertPath); - - // put the item into the node - node.children.push(item); - extend(node, bbox); - - // split on node overflow; propagate upwards if necessary - while (level >= 0) { - if (insertPath[level].children.length > this._maxEntries) { - this._split(insertPath, level); - level--; - } else break; - } - - // adjust bboxes along the insertion path - this._adjustParentBBoxes(bbox, insertPath, level); - }, - - // split overflowed node into two - _split: function (insertPath, level) - { - var node = insertPath[level], - M = node.children.length, - m = this._minEntries; - - this._chooseSplitAxis(node, m, M); - - var splitIndex = this._chooseSplitIndex(node, m, M); - - var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex)); - newNode.height = node.height; - newNode.leaf = node.leaf; - - calcBBox(node, this.toBBox); - calcBBox(newNode, this.toBBox); - - if (level) insertPath[level - 1].children.push(newNode); - else this._splitRoot(node, newNode); - }, - - _splitRoot: function (node, newNode) - { - // split root node - this.data = createNode([node, newNode]); - this.data.height = node.height + 1; - this.data.leaf = false; - calcBBox(this.data, this.toBBox); - }, - - _chooseSplitIndex: function (node, m, M) - { - var i, bbox1, bbox2, overlap, area, minOverlap, minArea, index; - - minOverlap = minArea = Infinity; - - for (i = m; i <= M - m; i++) { - bbox1 = distBBox(node, 0, i, this.toBBox); - bbox2 = distBBox(node, i, M, this.toBBox); - - overlap = intersectionArea(bbox1, bbox2); - area = bboxArea(bbox1) + bboxArea(bbox2); - - // choose distribution with minimum overlap - if (overlap < minOverlap) { - minOverlap = overlap; - index = i; - - minArea = area < minArea ? area : minArea; - - } else if (overlap === minOverlap) { - // otherwise choose distribution with minimum area - if (area < minArea) { - minArea = area; - index = i; - } - } - } - - return index; - }, - - // sorts node children by the best axis for split - _chooseSplitAxis: function (node, m, M) - { - var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX, - compareMinY = node.leaf ? this.compareMinY : compareNodeMinY, - xMargin = this._allDistMargin(node, m, M, compareMinX), - yMargin = this._allDistMargin(node, m, M, compareMinY); - - // if total distributions margin value is minimal for x, sort by minX, - // otherwise it's already sorted by minY - if (xMargin < yMargin) node.children.sort(compareMinX); - }, - - // total margin of all possible split distributions where each node is at least m full - _allDistMargin: function (node, m, M, compare) - { - node.children.sort(compare); - - var toBBox = this.toBBox, - leftBBox = distBBox(node, 0, m, toBBox), - rightBBox = distBBox(node, M - m, M, toBBox), - margin = bboxMargin(leftBBox) + bboxMargin(rightBBox), - i, child; - - for (i = m; i < M - m; i++) { - child = node.children[i]; - extend(leftBBox, node.leaf ? toBBox(child) : child); - margin += bboxMargin(leftBBox); - } - - for (i = M - m - 1; i >= m; i--) { - child = node.children[i]; - extend(rightBBox, node.leaf ? toBBox(child) : child); - margin += bboxMargin(rightBBox); - } - - return margin; - }, - - _adjustParentBBoxes: function (bbox, path, level) - { - // adjust bboxes along the given tree path - for (var i = level; i >= 0; i--) { - extend(path[i], bbox); - } - }, - - _condense: function (path) - { - // go through the path, removing empty nodes and updating bboxes - for (var i = path.length - 1, siblings; i >= 0; i--) { - if (path[i].children.length === 0) { - if (i > 0) { - siblings = path[i - 1].children; - siblings.splice(siblings.indexOf(path[i]), 1); - - } else this.clear(); - - } else calcBBox(path[i], this.toBBox); - } - }, - - _initFormat: function (format) - { - // data format (minX, minY, maxX, maxY accessors) - - // uses eval-type function compilation instead of just accepting a toBBox function - // because the algorithms are very sensitive to sorting functions performance, - // so they should be dead simple and without inner calls - - var compareArr = ['return a', ' - b', ';']; - - this.compareMinX = new Function('a', 'b', compareArr.join(format[0])); - this.compareMinY = new Function('a', 'b', compareArr.join(format[1])); - - this.toBBox = new Function('a', - 'return {minX: a' + format[0] + - ', minY: a' + format[1] + - ', maxX: a' + format[2] + - ', maxY: a' + format[3] + '};'); - } -}; - -function findItem (item, items, equalsFn) -{ - if (!equalsFn) return items.indexOf(item); - - for (var i = 0; i < items.length; i++) { - if (equalsFn(item, items[i])) return i; - } - return -1; -} - -// calculate node's bbox from bboxes of its children -function calcBBox (node, toBBox) -{ - distBBox(node, 0, node.children.length, toBBox, node); -} - -// min bounding rectangle of node children from k to p-1 -function distBBox (node, k, p, toBBox, destNode) -{ - if (!destNode) destNode = createNode(null); - destNode.minX = Infinity; - destNode.minY = Infinity; - destNode.maxX = -Infinity; - destNode.maxY = -Infinity; - - for (var i = k, child; i < p; i++) { - child = node.children[i]; - extend(destNode, node.leaf ? toBBox(child) : child); - } - - return destNode; -} - -function extend (a, b) -{ - a.minX = Math.min(a.minX, b.minX); - a.minY = Math.min(a.minY, b.minY); - a.maxX = Math.max(a.maxX, b.maxX); - a.maxY = Math.max(a.maxY, b.maxY); - return a; -} - -function compareNodeMinX (a, b) { return a.minX - b.minX; } -function compareNodeMinY (a, b) { return a.minY - b.minY; } - -function bboxArea (a) { return (a.maxX - a.minX) * (a.maxY - a.minY); } -function bboxMargin (a) { return (a.maxX - a.minX) + (a.maxY - a.minY); } - -function enlargedArea (a, b) -{ - return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) * - (Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY)); -} - -function intersectionArea (a, b) -{ - var minX = Math.max(a.minX, b.minX), - minY = Math.max(a.minY, b.minY), - maxX = Math.min(a.maxX, b.maxX), - maxY = Math.min(a.maxY, b.maxY); - - return Math.max(0, maxX - minX) * - Math.max(0, maxY - minY); -} - -function contains (a, b) -{ - return a.minX <= b.minX && - a.minY <= b.minY && - b.maxX <= a.maxX && - b.maxY <= a.maxY; -} - -function intersects (a, b) -{ - return b.minX <= a.maxX && - b.minY <= a.maxY && - b.maxX >= a.minX && - b.maxY >= a.minY; -} - -function createNode (children) -{ - return { - children: children, - height: 1, - leaf: true, - minX: Infinity, - minY: Infinity, - maxX: -Infinity, - maxY: -Infinity - }; -} - -// sort an array so that items come in groups of n unsorted items, with groups sorted between each other; -// combines selection algorithm with binary divide & conquer approach - -function multiSelect (arr, left, right, n, compare) -{ - var stack = [left, right], - mid; - - while (stack.length) - { - right = stack.pop(); - left = stack.pop(); - - if (right - left <= n) continue; - - mid = left + Math.ceil((right - left) / n / 2) * n; - quickselect(arr, mid, left, right, compare); - - stack.push(left, mid, mid, right); - } -} - -module.exports = rbush; - - -/***/ }), -/* 338 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// This is from the quickselect npm package: https://www.npmjs.com/package/quickselect -// Coded by https://www.npmjs.com/~mourner (Vladimir Agafonkin) - -// https://en.wikipedia.org/wiki/Floyd%E2%80%93Rivest_algorithm - -// Floyd-Rivest selection algorithm: -// Rearrange items so that all items in the [left, k] range are smaller than all items in (k, right]; -// The k-th element will have the (k - left + 1)th smallest value in [left, right] - -/** - * [description] - * - * @function Phaser.Utils.Array.QuickSelect - * @since 3.0.0 - * - * @param {[type]} arr - [description] - * @param {[type]} k - [description] - * @param {[type]} left - [description] - * @param {[type]} right - [description] - * @param {[type]} compare - [description] - */ -var QuickSelect = function (arr, k, left, right, compare) -{ - left = left || 0; - right = right || (arr.length - 1); - compare = compare || defaultCompare; - - while (right > left) - { - if (right - left > 600) - { - var n = right - left + 1; - var m = k - left + 1; - var z = Math.log(n); - var s = 0.5 * Math.exp(2 * z / 3); - var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1); - var newLeft = Math.max(left, Math.floor(k - m * s / n + sd)); - var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd)); - - QuickSelect(arr, k, newLeft, newRight, compare); - } - - var t = arr[k]; - var i = left; - var j = right; - - swap(arr, left, k); - - if (compare(arr[right], t) > 0) - { - swap(arr, left, right); - } - - while (i < j) - { - swap(arr, i, j); - - i++; - j--; - - while (compare(arr[i], t) < 0) - { - i++; - } - - while (compare(arr[j], t) > 0) - { - j--; - } - } - - if (compare(arr[left], t) === 0) - { - swap(arr, left, j); - } - else - { - j++; - swap(arr, j, right); - } - - if (j <= k) - { - left = j + 1; - } - - if (k <= j) - { - right = j - 1; - } - } -}; - -function swap (arr, i, j) -{ - var tmp = arr[i]; - arr[i] = arr[j]; - arr[j] = tmp; -} - -function defaultCompare (a, b) -{ - return a < b ? -1 : a > b ? 1 : 0; -} - -module.exports = QuickSelect; - - -/***/ }), -/* 339 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Physics.Arcade.Tilemap.TileIntersectsBody - * @since 3.0.0 - * - * @param {[type]} tileWorldRect - [description] - * @param {[type]} body - [description] - * - * @return {boolean} [description] - */ -var TileIntersectsBody = function (tileWorldRect, body) -{ - // Currently, all bodies are treated as rectangles when colliding with a Tile. Eventually, this - // should support circle bodies when those are less buggy in v3. - - return !( - body.right <= tileWorldRect.left || - body.bottom <= tileWorldRect.top || - body.position.x >= tileWorldRect.right || - body.position.y >= tileWorldRect.bottom - ); -}; - -module.exports = TileIntersectsBody; - - -/***/ }), -/* 340 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CircleContains = __webpack_require__(32); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(59); -var RectangleContains = __webpack_require__(33); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * [description] - * - * @class StaticBody - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.World} world - [description] - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - */ -var StaticBody = new Class({ - - initialize: - - function StaticBody (world, gameObject) - { - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world = world; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#gameObject - * @type {Phaser.GameObjects.GameObject} - * @since 3.0.0 - */ - this.gameObject = gameObject; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#debugShowBody - * @type {boolean} - * @since 3.0.0 - */ - this.debugShowBody = world.defaults.debugShowStaticBody; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#debugBodyColor - * @type {integer} - * @since 3.0.0 - */ - this.debugBodyColor = world.defaults.staticBodyDebugColor; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#enable - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.enable = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#isCircle - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isCircle = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#radius - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.radius = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#offset - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.offset = new Vector2(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#position - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.position = new Vector2(gameObject.x - gameObject.displayOriginX, gameObject.y - gameObject.displayOriginY); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#width - * @type {number} - * @since 3.0.0 - */ - this.width = gameObject.displayWidth; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#height - * @type {number} - * @since 3.0.0 - */ - this.height = gameObject.displayHeight; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#halfWidth - * @type {number} - * @since 3.0.0 - */ - this.halfWidth = Math.abs(this.width / 2); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#halfHeight - * @type {number} - * @since 3.0.0 - */ - this.halfHeight = Math.abs(this.height / 2); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#center - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#velocity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.velocity = Vector2.ZERO; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#allowGravity - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.allowGravity = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#gravity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.gravity = Vector2.ZERO; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#bounce - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.bounce = Vector2.ZERO; - - // If true this Body will dispatch events - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#onWorldBounds - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.onWorldBounds = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#onCollide - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.onCollide = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#onOverlap - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.onOverlap = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#mass - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.mass = 1; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#immovable - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.immovable = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#customSeparateX - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.customSeparateX = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#customSeparateY - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.customSeparateY = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#overlapX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapX = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#overlapY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapY = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#overlapR - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapR = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#embedded - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.embedded = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#collideWorldBounds - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.collideWorldBounds = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#checkCollision - * @type {object} - * @since 3.0.0 - */ - this.checkCollision = { none: false, up: true, down: true, left: true, right: true }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#touching - * @type {object} - * @since 3.0.0 - */ - this.touching = { none: true, up: false, down: false, left: false, right: false }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#wasTouching - * @type {object} - * @since 3.0.0 - */ - this.wasTouching = { none: true, up: false, down: false, left: false, right: false }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#blocked - * @type {object} - * @since 3.0.0 - */ - this.blocked = { none: true, up: false, down: false, left: false, right: false }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#physicsType - * @type {integer} - * @since 3.0.0 - */ - this.physicsType = CONST.STATIC_BODY; - }, - - /** - * Changes the Game Object this Body is bound to. - * First it removes its reference from the old Game Object, then sets the new one. - * You can optionally update the position and dimensions of this Body to reflect that of the new Game Object. - * - * @method Phaser.Physics.Arcade.StaticBody#setGameObject - * @since 3.1.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The new Game Object that will own this Body. - * @param {boolean} [update=true] - Reposition and resize this Body to match the new Game Object? - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - setGameObject: function (gameObject, update) - { - if (gameObject && gameObject !== this.gameObject) - { - // Remove this body from the old game object - this.gameObject.body = null; - - gameObject.body = this; - - // Update our reference - this.gameObject = gameObject; - } - - if (update) - { - this.updateFromGameObject(); - } - - return this; - }, - - /** - * Updates this Static Body so that its position and dimensions are updated - * based on the current Game Object it is bound to. - * - * @method Phaser.Physics.Arcade.StaticBody#updateFromGameObject - * @since 3.1.0 - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - updateFromGameObject: function () - { - this.world.staticTree.remove(this); - - var gameObject = this.gameObject; - - gameObject.getTopLeft(this.position); - - this.width = gameObject.displayWidth; - this.height = gameObject.displayHeight; - - this.halfWidth = Math.abs(this.width / 2); - this.halfHeight = Math.abs(this.height / 2); - - this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); - - this.world.staticTree.insert(this); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#setSize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} [offsetX] - [description] - * @param {number} [offsetY] - [description] - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - setSize: function (width, height, offsetX, offsetY) - { - if (offsetX === undefined) { offsetX = this.offset.x; } - if (offsetY === undefined) { offsetY = this.offset.y; } - - this.world.staticTree.remove(this); - - this.width = width; - this.height = height; - - this.halfWidth = Math.floor(width / 2); - this.halfHeight = Math.floor(height / 2); - - this.offset.set(offsetX, offsetY); - - this.updateCenter(); - - this.isCircle = false; - this.radius = 0; - - this.world.staticTree.insert(this); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#setCircle - * @since 3.0.0 - * - * @param {number} radius - [description] - * @param {number} [offsetX] - [description] - * @param {number} [offsetY] - [description] - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - setCircle: function (radius, offsetX, offsetY) - { - if (offsetX === undefined) { offsetX = this.offset.x; } - if (offsetY === undefined) { offsetY = this.offset.y; } - - if (radius > 0) - { - this.world.staticTree.remove(this); - - this.isCircle = true; - - this.radius = radius; - - this.width = radius * 2; - this.height = radius * 2; - - this.halfWidth = Math.floor(this.width / 2); - this.halfHeight = Math.floor(this.height / 2); - - this.offset.set(offsetX, offsetY); - - this.updateCenter(); - - this.world.staticTree.insert(this); - } - else - { - this.isCircle = false; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#updateCenter - * @since 3.0.0 - */ - updateCenter: function () - { - this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#reset - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - */ - reset: function (x, y) - { - var gameObject = this.gameObject; - - if (x === undefined) { x = gameObject.x; } - if (y === undefined) { y = gameObject.y; } - - this.world.staticTree.remove(this); - - gameObject.getTopLeft(this.position); - - this.updateCenter(); - - this.world.staticTree.insert(this); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#stop - * @since 3.0.0 - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - stop: function () - { - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#getBounds - * @since 3.0.0 - * - * @param {object} obj - [description] - * - * @return {object} [description] - */ - getBounds: function (obj) - { - obj.x = this.x; - obj.y = this.y; - obj.right = this.right; - obj.bottom = this.bottom; - - return obj; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#hitTest - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ - hitTest: function (x, y) - { - return (this.isCircle) ? CircleContains(this, x, y) : RectangleContains(this, x, y); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#deltaAbsX - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaAbsX: function () - { - return 0; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#deltaAbsY - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaAbsY: function () - { - return 0; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#deltaX - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaX: function () - { - return 0; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#deltaY - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaY: function () - { - return 0; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#deltaZ - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaZ: function () - { - return 0; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.enable = false; - - this.world.pendingDestroy.set(this); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#drawDebug - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphic - [description] - */ - drawDebug: function (graphic) - { - var pos = this.position; - - if (this.debugShowBody) - { - graphic.lineStyle(1, this.debugBodyColor, 1); - graphic.strokeRect(pos.x, pos.y, this.width, this.height); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#willDrawDebug - * @since 3.0.0 - * - * @return {boolean} [description] - */ - willDrawDebug: function () - { - return this.debugShowBody; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#setMass - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - setMass: function (value) - { - if (value <= 0) - { - // Causes havoc otherwise - value = 0.1; - } - - this.mass = value; - - return this; - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#x - * @type {number} - * @since 3.0.0 - */ - x: { - - get: function () - { - return this.position.x; - }, - - set: function (value) - { - this.world.staticTree.remove(this); - - this.position.x = value; - - this.world.staticTree.insert(this); - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#y - * @type {number} - * @since 3.0.0 - */ - y: { - - get: function () - { - return this.position.y; - }, - - set: function (value) - { - this.world.staticTree.remove(this); - - this.position.y = value; - - this.world.staticTree.insert(this); - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#left - * @type {number} - * @readOnly - * @since 3.0.0 - */ - left: { - - get: function () - { - return this.position.x; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#right - * @type {number} - * @readOnly - * @since 3.0.0 - */ - right: { - - get: function () - { - return this.position.x + this.width; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#top - * @type {number} - * @readOnly - * @since 3.0.0 - */ - top: { - - get: function () - { - return this.position.y; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#bottom - * @type {number} - * @readOnly - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return this.position.y + this.height; - } - - } - -}); - -module.exports = StaticBody; - - -/***/ }), -/* 341 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Collision Types - Determine if and how entities collide with each other. - * - * In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves, - * while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE - * collisions, both entities are moved. LITE or PASSIVE entities don't collide - * with other LITE or PASSIVE entities at all. The behavior for FIXED vs. - * FIXED collisions is undefined. - * - * @namespace Phaser.Physics.Impact.COLLIDES - */ - -module.exports = { - - /** - * Never collides. - * - * @name Phaser.Physics.Impact.COLLIDES.NEVER - * @type {integer} - * @since 3.0.0 - */ - NEVER: 0, - - /** - * Lite collision. - * - * @name Phaser.Physics.Impact.COLLIDES.LITE - * @type {integer} - * @since 3.0.0 - */ - LITE: 1, - - /** - * Passive collision. - * - * @name Phaser.Physics.Impact.COLLIDES.PASSIVE - * @type {integer} - * @since 3.0.0 - */ - PASSIVE: 2, - - /** - * Active collision. - * - * @name Phaser.Physics.Impact.COLLIDES.ACTIVE - * @type {integer} - * @since 3.0.0 - */ - ACTIVE: 4, - - /** - * Fixed collision. - * - * @name Phaser.Physics.Impact.COLLIDES.FIXED - * @type {integer} - * @since 3.0.0 - */ - FIXED: 8 - -}; - - -/***/ }), -/* 342 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Collision Types - Determine if and how entities collide with each other. - * - * In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves, - * while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE - * collisions, both entities are moved. LITE or PASSIVE entities don't collide - * with other LITE or PASSIVE entities at all. The behavior for FIXED vs. - * FIXED collisions is undefined. - * - * @namespace Phaser.Physics.Impact.TYPES - */ - -module.exports = { - - /** - * Collides with nothing. - * - * @name Phaser.Physics.Impact.TYPES.NONE - * @type {integer} - * @since 3.0.0 - */ - NONE: 0, - - /** - * Type A. Collides with Type B. - * - * @name Phaser.Physics.Impact.TYPES.A - * @type {integer} - * @since 3.0.0 - */ - A: 1, - - /** - * Type B. Collides with Type A. - * - * @name Phaser.Physics.Impact.TYPES.B - * @type {integer} - * @since 3.0.0 - */ - B: 2, - - /** - * Collides with both types A and B. - * - * @name Phaser.Physics.Impact.TYPES.BOTH - * @type {integer} - * @since 3.0.0 - */ - BOTH: 3 - -}; - - -/***/ }), -/* 343 */ -/***/ (function(module, exports, __webpack_require__) { - -/** -* The `Matter.Sleeping` module contains methods to manage the sleeping state of bodies. -* -* @class Sleeping -*/ - -var Sleeping = {}; - -module.exports = Sleeping; - -var Events = __webpack_require__(167); - -(function() { - - Sleeping._motionWakeThreshold = 0.18; - Sleeping._motionSleepThreshold = 0.08; - Sleeping._minBias = 0.9; - - /** - * Puts bodies to sleep or wakes them up depending on their motion. - * @method update - * @param {body[]} bodies - * @param {number} timeScale - */ - Sleeping.update = function(bodies, timeScale) { - var timeFactor = timeScale * timeScale * timeScale; - - // update bodies sleeping status - for (var i = 0; i < bodies.length; i++) { - var body = bodies[i], - motion = body.speed * body.speed + body.angularSpeed * body.angularSpeed; - - // wake up bodies if they have a force applied - if (body.force.x !== 0 || body.force.y !== 0) { - Sleeping.set(body, false); - continue; - } - - var minMotion = Math.min(body.motion, motion), - maxMotion = Math.max(body.motion, motion); - - // biased average motion estimation between frames - body.motion = Sleeping._minBias * minMotion + (1 - Sleeping._minBias) * maxMotion; - - if (body.sleepThreshold > 0 && body.motion < Sleeping._motionSleepThreshold * timeFactor) { - body.sleepCounter += 1; - - if (body.sleepCounter >= body.sleepThreshold) - Sleeping.set(body, true); - } else if (body.sleepCounter > 0) { - body.sleepCounter -= 1; - } - } - }; - - /** - * Given a set of colliding pairs, wakes the sleeping bodies involved. - * @method afterCollisions - * @param {pair[]} pairs - * @param {number} timeScale - */ - Sleeping.afterCollisions = function(pairs, timeScale) { - var timeFactor = timeScale * timeScale * timeScale; - - // wake up bodies involved in collisions - for (var i = 0; i < pairs.length; i++) { - var pair = pairs[i]; - - // don't wake inactive pairs - if (!pair.isActive) - continue; - - var collision = pair.collision, - bodyA = collision.bodyA.parent, - bodyB = collision.bodyB.parent; - - // don't wake if at least one body is static - if ((bodyA.isSleeping && bodyB.isSleeping) || bodyA.isStatic || bodyB.isStatic) - continue; - - if (bodyA.isSleeping || bodyB.isSleeping) { - var sleepingBody = (bodyA.isSleeping && !bodyA.isStatic) ? bodyA : bodyB, - movingBody = sleepingBody === bodyA ? bodyB : bodyA; - - if (!sleepingBody.isStatic && movingBody.motion > Sleeping._motionWakeThreshold * timeFactor) { - Sleeping.set(sleepingBody, false); - } - } - } - }; - - /** - * Set a body as sleeping or awake. - * @method set - * @param {body} body - * @param {boolean} isSleeping - */ - Sleeping.set = function(body, isSleeping) { - var wasSleeping = body.isSleeping; - - if (isSleeping) { - body.isSleeping = true; - body.sleepCounter = body.sleepThreshold; - - body.positionImpulse.x = 0; - body.positionImpulse.y = 0; - - body.positionPrev.x = body.position.x; - body.positionPrev.y = body.position.y; - - body.anglePrev = body.angle; - body.speed = 0; - body.angularSpeed = 0; - body.motion = 0; - - if (!wasSleeping) { - Events.trigger(body, 'sleepStart'); - } - } else { - body.isSleeping = false; - body.sleepCounter = 0; - - if (wasSleeping) { - Events.trigger(body, 'sleepEnd'); - } - } - }; - -})(); - - -/***/ }), -/* 344 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); - -/** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does - * not change collision information. - * - * @function Phaser.Tilemaps.Components.ReplaceByIndex - * @since 3.0.0 - * - * @param {integer} findIndex - [description] - * @param {integer} newIndex - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var ReplaceByIndex = function (findIndex, newIndex, tileX, tileY, width, height, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - for (var i = 0; i < tiles.length; i++) - { - if (tiles[i] && tiles[i].index === findIndex) - { - tiles[i].index = newIndex; - } - } -}; - -module.exports = ReplaceByIndex; - - -/***/ }), -/* 345 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var IsInLayerBounds = __webpack_require__(74); - -/** - * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @function Phaser.Tilemaps.Components.HasTileAt - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {boolean} - */ -var HasTileAt = function (tileX, tileY, layer) -{ - if (IsInLayerBounds(tileX, tileY, layer)) - { - var tile = layer.data[tileY][tileX]; - return (tile !== null && tile.index > -1); - } - else - { - return false; - } - -}; - -module.exports = HasTileAt; - - -/***/ }), -/* 346 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Tile = __webpack_require__(44); -var IsInLayerBounds = __webpack_require__(74); -var CalculateFacesAt = __webpack_require__(153); - -/** - * Removes the tile at the given tile coordinates in the specified layer and updates the layer's - * collision information. - * - * @function Phaser.Tilemaps.Components.RemoveTileAt - * @since 3.0.0 - * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The Tile object that was removed. - */ -var RemoveTileAt = function (tileX, tileY, replaceWithNull, recalculateFaces, layer) -{ - if (replaceWithNull === undefined) { replaceWithNull = false; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - if (!IsInLayerBounds(tileX, tileY, layer)) { return null; } - - var tile = layer.data[tileY][tileX]; - if (tile === null) - { - return null; - } - else - { - layer.data[tileY][tileX] = replaceWithNull - ? null - : new Tile(layer, -1, tileX, tileY, tile.width, tile.height); - } - - // Recalculate faces only if the removed tile was a colliding tile - if (recalculateFaces && tile && tile.collides) - { - CalculateFacesAt(tileX, tileY, layer); - } - - return tile; -}; - -module.exports = RemoveTileAt; - - -/***/ }), -/* 347 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Formats = __webpack_require__(22); -var Parse2DArray = __webpack_require__(156); -var ParseCSV = __webpack_require__(348); -var ParseJSONTiled = __webpack_require__(349); -var ParseWeltmeister = __webpack_require__(354); - -/** - * Parses raw data of a given Tilemap format into a new MapData object. If no recognized data format - * is found, returns `null`. When loading from CSV or a 2D array, you should specify the tileWidth & - * tileHeight. When parsing from a map from Tiled, the tileWidth & tileHeight will be pulled from - * the map data. - * - * @function Phaser.Tilemaps.Parsers.Parse - * @since 3.0.0 - * - * @param {string} name - The name of the tilemap, used to set the name on the MapData. - * @param {integer} mapFormat - See ../Formats.js. - * @param {integer[][]|string|object} data - 2D array, CSV string or Tiled JSON object. - * @param {integer} tileWidth - The width of a tile in pixels. Required for 2D array and CSV, but - * ignored for Tiled JSON. - * @param {integer} tileHeight - The height of a tile in pixels. Required for 2D array and CSV, but - * ignored for Tiled JSON. - * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {[type]} [description] - */ -var Parse = function (name, mapFormat, data, tileWidth, tileHeight, insertNull) -{ - var newMap; - - switch (mapFormat) - { - case (Formats.ARRAY_2D): - newMap = Parse2DArray(name, data, tileWidth, tileHeight, insertNull); - break; - case (Formats.CSV): - newMap = ParseCSV(name, data, tileWidth, tileHeight, insertNull); - break; - case (Formats.TILED_JSON): - newMap = ParseJSONTiled(name, data, insertNull); - break; - case (Formats.WELTMEISTER): - newMap = ParseWeltmeister(name, data, insertNull); - break; - default: - console.warn('Unrecognized tilemap data format: ' + mapFormat); - newMap = null; - } - - return newMap; -}; - -module.exports = Parse; - - -/***/ }), -/* 348 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Formats = __webpack_require__(22); -var Parse2DArray = __webpack_require__(156); - -/** - * Parses a CSV string of tile indexes into a new MapData object with a single layer. - * - * @function Phaser.Tilemaps.Parsers.ParseCSV - * @since 3.0.0 - * - * @param {string} name - The name of the tilemap, used to set the name on the MapData. - * @param {string} data - CSV string of tile indexes. - * @param {integer} tileWidth - The width of a tile in pixels. - * @param {integer} tileHeight - The height of a tile in pixels. - * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {[type]} [description] - */ -var ParseCSV = function (name, data, tileWidth, tileHeight, insertNull) -{ - var array2D = data - .trim() - .split('\n') - .map(function (row) { return row.split(','); }); - - var map = Parse2DArray(name, array2D, tileWidth, tileHeight, insertNull); - map.format = Formats.CSV; - - return map; -}; - -module.exports = ParseCSV; - - -/***/ }), -/* 349 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Formats = __webpack_require__(22); -var MapData = __webpack_require__(76); -var ParseTileLayers = __webpack_require__(904); -var ParseImageLayers = __webpack_require__(906); -var ParseTilesets = __webpack_require__(907); -var ParseObjectLayers = __webpack_require__(909); -var BuildTilesetIndex = __webpack_require__(910); -var AssignTileProperties = __webpack_require__(911); - -/** - * Parses a Tiled JSON object into a new MapData object. - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseJSONTiled - * @since 3.0.0 - * - * @param {string} name - The name of the tilemap, used to set the name on the MapData. - * @param {object} json - The Tiled JSON object. - * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {Phaser.Tilemaps.MapData|null} [description] - */ -var ParseJSONTiled = function (name, json, insertNull) -{ - if (json.orientation !== 'orthogonal') - { - console.warn('Only orthogonal map types are supported in this version of Phaser'); - return null; - } - - // Map data will consist of: layers, objects, images, tilesets, sizes - var mapData = new MapData({ - width: json.width, - height: json.height, - name: name, - tileWidth: json.tilewidth, - tileHeight: json.tileheight, - orientation: json.orientation, - format: Formats.TILED_JSON, - version: json.version, - properties: json.properties - }); - - mapData.layers = ParseTileLayers(json, insertNull); - mapData.images = ParseImageLayers(json); - - var sets = ParseTilesets(json); - mapData.tilesets = sets.tilesets; - mapData.imageCollections = sets.imageCollections; - - mapData.objects = ParseObjectLayers(json); - - mapData.tiles = BuildTilesetIndex(mapData); - - AssignTileProperties(mapData); - - return mapData; -}; - -module.exports = ParseJSONTiled; - - -/***/ }), -/* 350 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var FLIPPED_HORIZONTAL = 0x80000000; -var FLIPPED_VERTICAL = 0x40000000; -var FLIPPED_ANTI_DIAGONAL = 0x20000000; // Top-right is swapped with bottom-left corners - -/** - * See Tiled documentation on tile flipping: - * http://docs.mapeditor.org/en/latest/reference/tmx-map-format/ - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseGID - * @since 3.0.0 - * - * @param {number} gid - [description] - * - * @return {object} [description] - */ -var ParseGID = function (gid) -{ - var flippedHorizontal = Boolean(gid & FLIPPED_HORIZONTAL); - var flippedVertical = Boolean(gid & FLIPPED_VERTICAL); - var flippedAntiDiagonal = Boolean(gid & FLIPPED_ANTI_DIAGONAL); - gid = gid & ~(FLIPPED_HORIZONTAL | FLIPPED_VERTICAL | FLIPPED_ANTI_DIAGONAL); - - // Parse the flip flags into something Phaser can use - var rotation = 0; - var flipped = false; - - if (flippedHorizontal && flippedVertical && flippedAntiDiagonal) - { - rotation = Math.PI / 2; - flipped = true; - } - else if (flippedHorizontal && flippedVertical && !flippedAntiDiagonal) - { - rotation = Math.PI; - flipped = false; - } - else if (flippedHorizontal && !flippedVertical && flippedAntiDiagonal) - { - rotation = Math.PI / 2; - flipped = false; - } - else if (flippedHorizontal && !flippedVertical && !flippedAntiDiagonal) - { - rotation = 0; - flipped = true; - } - else if (!flippedHorizontal && flippedVertical && flippedAntiDiagonal) - { - rotation = 3 * Math.PI / 2; - flipped = false; - } - else if (!flippedHorizontal && flippedVertical && !flippedAntiDiagonal) - { - rotation = Math.PI; - flipped = true; - } - else if (!flippedHorizontal && !flippedVertical && flippedAntiDiagonal) - { - rotation = 3 * Math.PI / 2; - flipped = true; - } - else if (!flippedHorizontal && !flippedVertical && !flippedAntiDiagonal) - { - rotation = 0; - flipped = false; - } - - return { - gid: gid, - flippedHorizontal: flippedHorizontal, - flippedVertical: flippedVertical, - flippedAntiDiagonal: flippedAntiDiagonal, - rotation: rotation, - flipped: flipped - }; -}; - -module.exports = ParseGID; - - -/***/ }), -/* 351 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * An Image Collection is a special Tile Set containing multiple images, with no slicing into each image. - * - * Image Collections are normally created automatically when Tiled data is loaded. - * - * @class ImageCollection - * @memberOf Phaser.Tilemaps - * @constructor - * @since 3.0.0 - * - * @param {string} name - The name of the image collection in the map data. - * @param {integer} firstgid - The first image index this image collection contains. - * @param {integer} [width=32] - Width of widest image (in pixels). - * @param {integer} [height=32] - Height of tallest image (in pixels). - * @param {integer} [margin=0] - The margin around all images in the collection (in pixels). - * @param {integer} [spacing=0] - The spacing between each image in the collection (in pixels). - * @param {object} [properties={}] - Custom Image Collection properties. - */ -var ImageCollection = new Class({ - - initialize: - - function ImageCollection (name, firstgid, width, height, margin, spacing, properties) - { - if (width === undefined || width <= 0) { width = 32; } - if (height === undefined || height <= 0) { height = 32; } - if (margin === undefined) { margin = 0; } - if (spacing === undefined) { spacing = 0; } - - /** - * The name of the Image Collection. - * - * @name Phaser.Tilemaps.ImageCollection#name - * @type {string} - * @since 3.0.0 - */ - this.name = name; - - /** - * The Tiled firstgid value. - * This is the starting index of the first image index this Image Collection contains. - * - * @name Phaser.Tilemaps.ImageCollection#firstgid - * @type {integer} - * @since 3.0.0 - */ - this.firstgid = firstgid | 0; - - /** - * The width of the widest image (in pixels). - * - * @name Phaser.Tilemaps.ImageCollection#imageWidth - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.imageWidth = width | 0; - - /** - * The height of the tallest image (in pixels). - * - * @name Phaser.Tilemaps.ImageCollection#imageHeight - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.imageHeight = height | 0; - - /** - * The margin around the images in the collection (in pixels). - * Use `setSpacing` to change. - * - * @name Phaser.Tilemaps.ImageCollection#imageMarge - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.imageMargin = margin | 0; - - /** - * The spacing between each image in the collection (in pixels). - * Use `setSpacing` to change. - * - * @name Phaser.Tilemaps.ImageCollection#imageSpacing - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.imageSpacing = spacing | 0; - - /** - * Image Collection-specific properties that are typically defined in the Tiled editor. - * - * @name Phaser.Tilemaps.ImageCollection#properties - * @type {object} - * @since 3.0.0 - */ - this.properties = properties || {}; - - /** - * The cached images that are a part of this collection. - * - * @name Phaser.Tilemaps.ImageCollection#images - * @type {array} - * @readOnly - * @since 3.0.0 - */ - this.images = []; - - /** - * The total number of images in the image collection. - * - * @name Phaser.Tilemaps.ImageCollection#total - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.total = 0; - }, - - /** - * Returns true if and only if this image collection contains the given image index. - * - * @method Phaser.Tilemaps.ImageCollection#containsImageIndex - * @since 3.0.0 - * - * @param {integer} imageIndex - The image index to search for. - * - * @return {boolean} True if this Image Collection contains the given index. - */ - containsImageIndex: function (imageIndex) - { - return (imageIndex >= this.firstgid && imageIndex < (this.firstgid + this.total)); - }, - - /** - * Add an image to this Image Collection. - * - * @method Phaser.Tilemaps.ImageCollection#addImage - * @since 3.0.0 - * - * @param {integer} gid - The gid of the image in the Image Collection. - * @param {string} image - The the key of the image in the Image Collection and in the cache. - * - * @return {Phaser.Tilemaps.ImageCollection} This ImageCollection object. - */ - addImage: function (gid, image) - { - this.images.push({ gid: gid, image: image }); - this.total++; - - return this; - } - -}); - -module.exports = ImageCollection; - - /***/ }), /* 352 */ /***/ (function(module, exports, __webpack_require__) { @@ -69286,81 +76309,51 @@ module.exports = ImageCollection; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Pick = __webpack_require__(908); -var ParseGID = __webpack_require__(350); +var GetPoint = __webpack_require__(166); +var Perimeter = __webpack_require__(105); -var copyPoints = function (p) { return { x: p.x, y: p.y }; }; - -var commonObjectProps = [ 'id', 'name', 'type', 'rotation', 'properties', 'visible', 'x', 'y', 'width', 'height' ]; +// Return an array of points from the perimeter of the rectangle +// each spaced out based on the quantity or step required /** * [description] * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseObject + * @function Phaser.Geom.Rectangle.GetPoints * @since 3.0.0 * - * @param {object} tiledObject - [description] - * @param {number} [offsetX=0] - [description] - * @param {number} [offsetY=0] - [description] + * @param {Phaser.Geom.Rectangle} rectangle - [description] + * @param {number} step - [description] + * @param {integer} quantity - [description] + * @param {array} [out] - [description] * - * @return {object} [description] + * @return {Phaser.Geom.Point[]} [description] */ -var ParseObject = function (tiledObject, offsetX, offsetY) +var GetPoints = function (rectangle, quantity, stepRate, out) { - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } + if (out === undefined) { out = []; } - var parsedObject = Pick(tiledObject, commonObjectProps); - - parsedObject.x += offsetX; - parsedObject.y += offsetY; - - if (tiledObject.gid) + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) { - // Object tiles - var gidInfo = ParseGID(tiledObject.gid); - parsedObject.gid = gidInfo.gid; - parsedObject.flippedHorizontal = gidInfo.flippedHorizontal; - parsedObject.flippedVertical = gidInfo.flippedVertical; - parsedObject.flippedAntiDiagonal = gidInfo.flippedAntiDiagonal; - } - else if (tiledObject.polyline) - { - parsedObject.polyline = tiledObject.polyline.map(copyPoints); - } - else if (tiledObject.polygon) - { - parsedObject.polygon = tiledObject.polygon.map(copyPoints); - } - else if (tiledObject.ellipse) - { - parsedObject.ellipse = tiledObject.ellipse; - parsedObject.width = tiledObject.width; - parsedObject.height = tiledObject.height; - } - else if (tiledObject.text) - { - parsedObject.width = tiledObject.width; - parsedObject.height = tiledObject.height; - parsedObject.text = tiledObject.text; - } - else - { - // Otherwise, assume it is a rectangle - parsedObject.rectangle = true; - parsedObject.width = tiledObject.width; - parsedObject.height = tiledObject.height; + quantity = Perimeter(rectangle) / stepRate; } - return parsedObject; + for (var i = 0; i < quantity; i++) + { + var position = i / quantity; + + out.push(GetPoint(rectangle, position)); + } + + return out; }; -module.exports = ParseObject; +module.exports = GetPoints; /***/ }), /* 353 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -69368,100 +76361,22 @@ module.exports = ParseObject; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(2); - /** - * @classdesc - * A class for representing a Tiled object layer in a map. This mirrors the structure of a Tiled - * object layer, except: - * - "x" & "y" properties are ignored since these cannot be changed in Tiled. - * - "offsetx" & "offsety" are applied to the individual object coordinates directly, so they - * are ignored as well. - * - "draworder" is ignored. + * Returns the circumference of the given Circle. * - * @class ObjectLayer - * @memberOf Phaser.Tilemaps - * @constructor + * @function Phaser.Geom.Circle.Circumference * @since 3.0.0 * - * @param {object} [config] - [description] + * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference of. + * + * @return {number} The circumference of the Circle. */ -var ObjectLayer = new Class({ +var Circumference = function (circle) +{ + return 2 * (Math.PI * circle.radius); +}; - initialize: - - function ObjectLayer (config) - { - if (config === undefined) { config = {}; } - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#name - * @type {string} - * @since 3.0.0 - */ - this.name = GetFastValue(config, 'name', 'object layer'); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#opacity - * @type {number} - * @since 3.0.0 - */ - this.opacity = GetFastValue(config, 'opacity', 1); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#properties - * @type {object} - * @since 3.0.0 - */ - this.properties = GetFastValue(config, 'properties', {}); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#propertyTypes - * @type {object} - * @since 3.0.0 - */ - this.propertyTypes = GetFastValue(config, 'propertytypes', {}); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#type - * @type {string} - * @since 3.0.0 - */ - this.type = GetFastValue(config, 'type', 'objectgroup'); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#visible - * @type {boolean} - * @since 3.0.0 - */ - this.visible = GetFastValue(config, 'visible', true); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#objects - * @type {array} - * @since 3.0.0 - */ - this.objects = GetFastValue(config, 'objects', []); - } - -}); - -module.exports = ObjectLayer; +module.exports = Circumference; /***/ }), @@ -69474,61 +76389,46 @@ module.exports = ObjectLayer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Formats = __webpack_require__(22); -var MapData = __webpack_require__(76); -var ParseTileLayers = __webpack_require__(912); -var ParseTilesets = __webpack_require__(913); +var Circumference = __webpack_require__(353); +var CircumferencePoint = __webpack_require__(168); +var FromPercent = __webpack_require__(78); +var MATH_CONST = __webpack_require__(16); /** - * Parses a Weltmeister JSON object into a new MapData object. + * Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, + * based on the given quantity or stepRate values. * - * @function Phaser.Tilemaps.Parsers.Impact.ParseWeltmeister + * @function Phaser.Geom.Circle.GetPoints * @since 3.0.0 * - * @param {string} name - The name of the tilemap, used to set the name on the MapData. - * @param {object} json - The Weltmeister JSON object. - * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. + * @param {Phaser.Geom.Circle} circle - The Circle to get the points from. + * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. + * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. * - * @return {object|null} [description] + * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the circumference of the circle. */ -var ParseWeltmeister = function (name, json, insertNull) +var GetPoints = function (circle, quantity, stepRate, out) { - if (json.layer.length === 0) + if (out === undefined) { out = []; } + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) { - console.warn('No layers found in the Weltmeister map: ' + name); - return null; + quantity = Circumference(circle) / stepRate; } - var width = 0; - var height = 0; - - for (var i = 0; i < json.layer.length; i++) + for (var i = 0; i < quantity; i++) { - if (json.layer[i].width > width) { width = json.layer[i].width; } - if (json.layer[i].height > height) { height = json.layer[i].height; } + var angle = FromPercent(i / quantity, 0, MATH_CONST.PI2); + + out.push(CircumferencePoint(circle, angle)); } - var mapData = new MapData({ - width: width, - height: height, - name: name, - tileWidth: json.layer[0].tilesize, - tileHeight: json.layer[0].tilesize, - format: Formats.WELTMEISTER - }); - - mapData.layers = ParseTileLayers(json, insertNull); - mapData.tilesets = ParseTilesets(json); - - return mapData; + return out; }; -module.exports = ParseWeltmeister; +module.exports = GetPoints; /***/ }), @@ -69541,2253 +76441,35 @@ module.exports = ParseWeltmeister; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var DegToRad = __webpack_require__(35); -var DynamicTilemapLayer = __webpack_require__(356); -var Extend = __webpack_require__(23); -var Formats = __webpack_require__(22); -var LayerData = __webpack_require__(75); -var Rotate = __webpack_require__(324); -var StaticTilemapLayer = __webpack_require__(357); -var Tile = __webpack_require__(44); -var TilemapComponents = __webpack_require__(96); -var Tileset = __webpack_require__(100); +var CircumferencePoint = __webpack_require__(168); +var FromPercent = __webpack_require__(78); +var MATH_CONST = __webpack_require__(16); +var Point = __webpack_require__(4); /** - * @classdesc - * A Tilemap is a container for Tilemap data. This isn't a display object, rather, it holds data - * about the map and allows you to add tilesets and tilemap layers to it. A map can have one or - * more tilemap layers (StaticTilemapLayer or DynamicTilemapLayer), which are the display - * objects that actually render tiles. + * Returns a Point object containing the coordinates of a point on the circumference of the Circle + * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point + * at 180 degrees around the circle. * - * The Tilemap data be parsed from a Tiled JSON file, a CSV file or a 2D array. Tiled is a free - * software package specifically for creating tile maps, and is available from: - * http://www.mapeditor.org - * - * A Tilemap has handy methods for getting & manipulating the tiles within a layer. You can only - * use the methods that change tiles (e.g. removeTileAt) on a DynamicTilemapLayer. - * - * Note that all Tilemaps use a base tile size to calculate dimensions from, but that a - * StaticTilemapLayer or DynamicTilemapLayer may have its own unique tile size that overrides - * it. - * - * @class Tilemap - * @memberOf Phaser.Tilemaps - * @constructor + * @function Phaser.Geom.Circle.GetPoint * @since 3.0.0 * - * @param {Phaser.Scene} scene - The Scene to which this Tilemap belongs. - * @param {Phaser.Tilemaps.MapData} mapData - A MapData instance containing Tilemap data. + * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on. + * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. + * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. + * + * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the circle. */ -var Tilemap = new Class({ +var GetPoint = function (circle, position, out) +{ + if (out === undefined) { out = new Point(); } - initialize: + var angle = FromPercent(position, 0, MATH_CONST.PI2); - function Tilemap (scene, mapData) - { - /** - * @name Phaser.Tilemaps.Tilemap#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; + return CircumferencePoint(circle, angle, out); +}; - /** - * The base width of a tile in pixels. Note that individual layers may have a different tile - * width. - * - * @name Phaser.Tilemaps.Tilemap#tileWidth - * @type {integer} - * @since 3.0.0 - */ - this.tileWidth = mapData.tileWidth; - - /** - * The base height of a tile in pixels. Note that individual layers may have a different - * tile height. - * - * @name Phaser.Tilemaps.Tilemap#tileHeight - * @type {integer} - * @since 3.0.0 - */ - this.tileHeight = mapData.tileHeight; - - /** - * The width of the map (in tiles). - * - * @name Phaser.Tilemaps.Tilemap#width - * @type {number} - * @since 3.0.0 - */ - this.width = mapData.width; - - /** - * The height of the map (in tiles). - * - * @name Phaser.Tilemaps.Tilemap#height - * @type {number} - * @since 3.0.0 - */ - this.height = mapData.height; - - /** - * The orientation of the map data (as specified in Tiled), usually 'orthogonal'. - * - * @name Phaser.Tilemaps.Tilemap#orientation - * @type {string} - * @since 3.0.0 - */ - this.orientation = mapData.orientation; - - /** - * The format of the map data. - * - * @name Phaser.Tilemaps.Tilemap#format - * @type {number} - * @since 3.0.0 - */ - this.format = mapData.format; - - /** - * The version of the map data (as specified in Tiled, usually 1). - * - * @name Phaser.Tilemaps.Tilemap#version - * @type {number} - * @since 3.0.0 - */ - this.version = mapData.version; - - /** - * Map specific properties as specified in Tiled. - * - * @name Phaser.Tilemaps.Tilemap#properties - * @type {object} - * @since 3.0.0 - */ - this.properties = mapData.properties; - - /** - * The width of the map in pixels based on width * tileWidth. - * - * @name Phaser.Tilemaps.Tilemap#widthInPixels - * @type {number} - * @since 3.0.0 - */ - this.widthInPixels = mapData.widthInPixels; - - /** - * The height of the map in pixels based on height * tileHeight. - * - * @name Phaser.Tilemaps.Tilemap#heightInPixels - * @type {number} - * @since 3.0.0 - */ - this.heightInPixels = mapData.heightInPixels; - - /** - * - * @name Phaser.Tilemaps.Tilemap#imageCollections - * @type {Phaser.Tilemaps.ImageCollection[]} - * @since 3.0.0 - */ - this.imageCollections = mapData.imageCollections; - - /** - * An array of Tiled Image Layers. - * - * @name Phaser.Tilemaps.Tilemap#images - * @type {array} - * @since 3.0.0 - */ - this.images = mapData.images; - - /** - * An array of Tilemap layer data. - * - * @name Phaser.Tilemaps.Tilemap#layers - * @type {Phaser.Tilemaps.LayerData[]} - * @since 3.0.0 - */ - this.layers = mapData.layers; - - /** - * An array of Tilesets used in the map. - * - * @name Phaser.Tilemaps.Tilemap#tilesets - * @type {Phaser.Tilemaps.Tileset[]} - * @since 3.0.0 - */ - this.tilesets = mapData.tilesets; - - /** - * An array of ObjectLayer instances parsed from Tiled object layers. - * - * @name Phaser.Tilemaps.Tilemap#objects - * @type {Phaser.Tilemaps.ObjectLayer[]} - * @since 3.0.0 - */ - this.objects = mapData.objects; - - /** - * The index of the currently selected LayerData object. - * - * @name Phaser.Tilemaps.Tilemap#currentLayerIndex - * @type {integer} - * @since 3.0.0 - */ - this.currentLayerIndex = 0; - }, - - /** - * Adds an image to the map to be used as a tileset. A single map may use multiple tilesets. - * Note that the tileset name can be found in the JSON file exported from Tiled, or in the Tiled - * editor. - * - * @method Phaser.Tilemaps.Tilemap#addTilesetImage - * @since 3.0.0 - * - * @param {string} tilesetName - The name of the tileset as specified in the map data. - * @param {string} [key] - The key of the Phaser.Cache image used for this tileset. If - * `undefined` or `null` it will look for an image with a key matching the tileset parameter. - * @param {integer} [tileWidth] - The width of the tile (in pixels) in the Tileset Image. If not - * given it will default to the map's tileWidth value, or the tileWidth specified in the Tiled - * JSON file. - * @param {integer} [tileHeight] - The height of the tiles (in pixels) in the Tileset Image. If - * not given it will default to the map's tileHeight value, or the tileHeight specified in the - * Tiled JSON file. - * @param {integer} [tileMargin] - The margin around the tiles in the sheet (in pixels). If not - * specified, it will default to 0 or the value specified in the Tiled JSON file. - * @param {integer} [tileSpacing] - The spacing between each the tile in the sheet (in pixels). - * If not specified, it will default to 0 or the value specified in the Tiled JSON file. - * @param {integer} [gid=0] - If adding multiple tilesets to a blank map, specify the starting - * GID this set will use here. - * - * @return {Phaser.Tilemaps.Tileset|null} Returns the Tileset object that was created or updated, or null if it - * failed. - */ - addTilesetImage: function (tilesetName, key, tileWidth, tileHeight, tileMargin, tileSpacing, gid) - { - if (tilesetName === undefined) { return null; } - if (key === undefined || key === null) { key = tilesetName; } - - if (!this.scene.sys.textures.exists(key)) - { - console.warn('Invalid image key given for tileset: "' + key + '"'); - return null; - } - - var texture = this.scene.sys.textures.get(key); - - var index = this.getTilesetIndex(tilesetName); - - if (index === null && this.format === Formats.TILED_JSON) - { - console.warn('No data found in the JSON tilemap from Tiled matching the tileset name: "' + tilesetName + '"'); - return null; - } - - if (this.tilesets[index]) - { - this.tilesets[index].setTileSize(tileWidth, tileHeight); - this.tilesets[index].setSpacing(tileMargin, tileSpacing); - this.tilesets[index].setImage(texture); - return this.tilesets[index]; - } - - if (tileWidth === undefined) { tileWidth = this.tileWidth; } - if (tileHeight === undefined) { tileHeight = this.tileHeight; } - if (tileMargin === undefined) { tileMargin = 0; } - if (tileSpacing === undefined) { tileSpacing = 0; } - if (gid === undefined) { gid = 0; } - - var tileset = new Tileset(tilesetName, gid, tileWidth, tileHeight, tileMargin, tileSpacing); - tileset.setImage(texture); - this.tilesets.push(tileset); - - return tileset; - }, - - /** - * Turns the StaticTilemapLayer associated with the given layer into a DynamicTilemapLayer. If - * no layer specified, the map's current layer is used. This is useful if you want to manipulate - * a map at the start of a scene, but then make it non-manipulable and optimize it for speed. - * Note: the DynamicTilemapLayer passed in is destroyed, so make sure to store the value - * returned from this method if you want to manipulate the new StaticTilemapLayer. - * - * @method Phaser.Tilemaps.Tilemap#convertLayerToStatic - * @since 3.0.0 - * - * @param {string|integer|Phaser.Tilemaps.DynamicTilemapLayer} [layer] - The name of the layer from Tiled, the - * index of the layer in the map, or a DynamicTilemapLayer. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer|null} Returns the new layer that was created, or null if it - * failed. - */ - convertLayerToStatic: function (layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - var dynamicLayer = layer.tilemapLayer; - - if (!dynamicLayer || !(dynamicLayer instanceof DynamicTilemapLayer)) - { - return null; - } - - var staticLayer = new StaticTilemapLayer( - dynamicLayer.scene, - dynamicLayer.tilemap, - dynamicLayer.layerIndex, - dynamicLayer.tileset, - dynamicLayer.x, - dynamicLayer.y - ); - - this.scene.sys.displayList.add(staticLayer); - - dynamicLayer.destroy(); - - return staticLayer; - }, - - /** - * See component documentation. If no layer specified, the map's current layer is used. This - * cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#copy - * @since 3.0.0 - * - * @return {Phaser.Tilemaps.Tilemap|null} Returns this, or null if the layer given was invalid. - */ - copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'copy')) { return this; } - - if (layer !== null) - { - TilemapComponents.Copy( - srcTileX, srcTileY, - width, height, - destTileX, destTileY, - recalculateFaces, layer - ); - } - - return this; - }, - - /** - * Creates a new and empty DynamicTilemapLayer. The currently selected layer in the map is set - * to this new layer. - * - * @method Phaser.Tilemaps.Tilemap#createBlankDynamicLayer - * @since 3.0.0 - * - * @param {string} name - The name of this layer. Must be unique within the map. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset the new layer will use. - * @param {integer} width - The width of the layer in tiles. If not specified, it will default - * to the map's width. - * @param {integer} height - The height of the layer in tiles. If not specified, it will default - * to the map's height. - * @param {integer} tileWidth - The width of the tiles the layer uses for calculations. If not - * specified, it will default to the map's tileWidth. - * @param {integer} tileHeight - The height of the tiles the layer uses for calculations. If not - * specified, it will default to the map's tileHeight. - * @return {Phaser.Tilemaps.DynamicTilemapLayer|null} Returns the new layer was created, or null if it failed. - */ - createBlankDynamicLayer: function (name, tileset, x, y, width, height, tileWidth, tileHeight) - { - if (tileWidth === undefined) { tileWidth = tileset.tileWidth; } - if (tileHeight === undefined) { tileHeight = tileset.tileHeight; } - if (width === undefined) { width = this.width; } - if (height === undefined) { height = this.height; } - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - - var index = this.getLayerIndex(name); - - if (index !== null) - { - console.warn('Cannot create blank layer: layer with matching name already exists ' + name); - return null; - } - - var layerData = new LayerData({ - name: name, - tileWidth: tileWidth, - tileHeight: tileHeight, - width: width, - height: height - }); - - var row; - - for (var tileY = 0; tileY < height; tileY++) - { - row = []; - - for (var tileX = 0; tileX < width; tileX++) - { - row.push(new Tile(layerData, -1, tileX, tileY, tileWidth, tileHeight, this.tileWidth, this.tileHeight)); - } - - layerData.data.push(row); - } - - this.layers.push(layerData); - this.currentLayerIndex = this.layers.length - 1; - - var dynamicLayer = new DynamicTilemapLayer(this.scene, this, this.currentLayerIndex, tileset, x, y); - this.scene.sys.displayList.add(dynamicLayer); - - return dynamicLayer; - }, - - /** - * Creates a new DynamicTilemapLayer that renders the LayerData associated with the given - * `layerID`. The currently selected layer in the map is set to this new layer. - * - * The `layerID` is important. If you've created your map in Tiled then you can get this by - * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and - * look at the layers[].name value. Either way it must match. - * - * Unlike a static layer, a dynamic layer can be modified. See DynamicTilemapLayer for more - * information. - * - * @method Phaser.Tilemaps.Tilemap#createDynamicLayer - * @since 3.0.0 - * - * @param {integer|string} layerID - The layer array index value, or if a string is given, the - * layer name from Tiled. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset the new layer will use. - * @param {number} x - The x position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. - * @param {number} y - The y position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer|null} Returns the new layer was created, or null if it failed. - */ - createDynamicLayer: function (layerID, tileset, x, y) - { - var index = this.getLayerIndex(layerID); - - if (index === null) - { - console.warn('Cannot create tilemap layer, invalid layer ID given: ' + layerID); - return null; - } - - var layerData = this.layers[index]; - - // Check for an associated static or dynamic tilemap layer - if (layerData.tilemapLayer) - { - console.warn('Cannot create dynamic tilemap layer since a static or dynamic tilemap layer exists for layer ID:' + layerID); - return null; - } - - this.currentLayerIndex = index; - - // Make sure that all the LayerData & the tiles have the correct tile size. They usually - // are, but wouldn't match if you try to load a 2x or 4x res tileset when the map was made - // with a 1x res tileset. - if (layerData.tileWidth !== tileset.tileWidth || layerData.tileHeight !== tileset.tileHeight) - { - this.setLayerTileSize(tileset.tileWidth, tileset.tileHeight, index); - } - - // Default the x/y position to match Tiled layer offset, if it exists. - if (x === undefined && this.layers[index].x) { x = this.layers[index].x; } - if (y === undefined && this.layers[index].y) { y = this.layers[index].y; } - - var layer = new DynamicTilemapLayer(this.scene, this, index, tileset, x, y); - this.scene.sys.displayList.add(layer); - - return layer; - }, - - /** - * Creates a Sprite for every object matching the given gid in the map data. All properties from - * the map data objectgroup are copied into the `spriteConfig`, so you can use this as an easy - * way to configure Sprite properties from within the map editor. For example giving an object a - * property of alpha: 0.5 in the map editor will duplicate that when the Sprite is created. - * - * @method Phaser.Tilemaps.Tilemap#createFromObjects - * @since 3.0.0 - * - * @param {string} name - The name of the object layer (from Tiled) to create Sprites from. - * @param {integer|string} id - Either the id (object), gid (tile object) or name (object or - * tile object) from Tiled. Ids are unique in Tiled, but a gid is shared by all tile objects - * with the same graphic. The same name can be used on multiple objects. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). - * @param {Phaser.Scene} [scene=the scene the map is within] - The Scene to create the Sprites within. - * - * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. - */ - createFromObjects: function (name, id, spriteConfig, scene) - { - if (spriteConfig === undefined) { spriteConfig = {}; } - if (scene === undefined) { scene = this.scene; } - - var objectLayer = this.getObjectLayer(name); - if (!objectLayer) - { - console.warn('Cannot create from object. Invalid objectgroup name given: ' + name); - return; - } - - var objects = objectLayer.objects; - var sprites = []; - - for (var i = 0; i < objects.length; i++) - { - var found = false; - var obj = objects[i]; - - if (obj.gid !== undefined && typeof id === 'number' && obj.gid === id || - obj.id !== undefined && typeof id === 'number' && obj.id === id || - obj.name !== undefined && typeof id === 'string' && obj.name === id) - { - found = true; - } - - if (found) - { - var config = Extend({}, spriteConfig, obj.properties); - - config.x = obj.x; - config.y = obj.y; - - var sprite = this.scene.make.sprite(config); - - sprite.name = obj.name; - - if (obj.width) { sprite.displayWidth = obj.width; } - if (obj.height) { sprite.displayHeight = obj.height; } - - // Origin is (0, 1) in Tiled, so find the offset that matches the Sprite's origin. - var offset = { - x: sprite.originX * sprite.displayWidth, - y: (sprite.originY - 1) * sprite.displayHeight - }; - - // If the object is rotated, then the origin offset also needs to be rotated. - if (obj.rotation) - { - var angle = DegToRad(obj.rotation); - Rotate(offset, angle); - sprite.rotation = angle; - } - - sprite.x += offset.x; - sprite.y += offset.y; - - if (obj.flippedHorizontal !== undefined || obj.flippedVertical !== undefined) - { - sprite.setFlip(obj.flippedHorizontal, obj.flippedVertical); - } - - if (!obj.visible) { sprite.visible = false; } - - sprites.push(sprite); - } - } - - return sprites; - }, - - /** - * Creates a Sprite for every object matching the given tile indexes in the layer. You can - * optionally specify if each tile will be replaced with a new tile after the Sprite has been - * created. This is useful if you want to lay down special tiles in a level that are converted to - * Sprites, but want to replace the tile itself with a floor tile or similar once converted. - * - * @method Phaser.Tilemaps.Tilemap#createFromTiles - * @since 3.0.0 - * - * @param {integer|array} indexes - The tile index, or array of indexes, to create Sprites from. - * @param {integer|array} replacements - The tile index, or array of indexes, to change a converted - * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a - * one-to-one mapping with the indexes array. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). - * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.GameObjects.Sprite[]|null} Returns an array of Tiles, or null if the layer given was invalid. - */ - createFromTiles: function (indexes, replacements, spriteConfig, scene, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, layer); - }, - - /** - * Creates a new StaticTilemapLayer that renders the LayerData associated with the given - * `layerID`. The currently selected layer in the map is set to this new layer. - * - * The `layerID` is important. If you've created your map in Tiled then you can get this by - * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and - * look at the layers[].name value. Either way it must match. - * - * It's important to remember that a static layer cannot be modified. See StaticTilemapLayer for - * more information. - * - * @method Phaser.Tilemaps.Tilemap#createStaticLayer - * @since 3.0.0 - * - * @param {integer|string} layerID - The layer array index value, or if a string is given, the - * layer name from Tiled. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset the new layer will use. - * @param {number} x - The x position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. - * @param {number} y - The y position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer|null} Returns the new layer was created, or null if it failed. - */ - createStaticLayer: function (layerID, tileset, x, y) - { - var index = this.getLayerIndex(layerID); - - if (index === null) - { - console.warn('Cannot create tilemap layer, invalid layer ID given: ' + layerID); - return null; - } - - var layerData = this.layers[index]; - - // Check for an associated static or dynamic tilemap layer - if (layerData.tilemapLayer) - { - console.warn('Cannot create static tilemap layer since a static or dynamic tilemap layer exists for layer ID:' + layerID); - return null; - } - - this.currentLayerIndex = index; - - // Make sure that all the LayerData & the tiles have the correct tile size. They usually - // are, but wouldn't match if you try to load a 2x or 4x res tileset when the map was made - // with a 1x res tileset. - if (layerData.tileWidth !== tileset.tileWidth || layerData.tileHeight !== tileset.tileHeight) - { - this.setLayerTileSize(tileset.tileWidth, tileset.tileHeight, index); - } - - // Default the x/y position to match Tiled layer offset, if it exists. - if (x === undefined && this.layers[index].x) { x = this.layers[index].x; } - if (y === undefined && this.layers[index].y) { y = this.layers[index].y; } - - var layer = new StaticTilemapLayer(this.scene, this, index, tileset, x, y); - this.scene.sys.displayList.add(layer); - - return layer; - }, - - /** - * Removes all layer data from this Tilemap and nulls the scene reference. This will destroy any - * StaticTilemapLayers or DynamicTilemapLayers that have been linked to LayerData. - * - * @method Phaser.Tilemaps.Tilemap#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.removeAllLayers(); - this.tilesets.length = 0; - this.objects.length = 0; - this.scene = undefined; - }, - - /** - * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the - * specified index. Tiles will be set to collide if the given index is a colliding index. - * Collision information in the region will be recalculated. - * - * If no layer specified, the map's current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#fill - * @since 3.0.0 - * - * @param {integer} index - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Returns this, or null if the layer given was invalid. - */ - fill: function (index, tileX, tileY, width, height, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'fill')) { return this; } - - if (layer !== null) - { - TilemapComponents.Fill(index, tileX, tileY, width, height, recalculateFaces, layer); - } - - return this; - }, - - /** - * For each object in the given object layer, run the given filter callback function. Any - * objects that pass the filter test (i.e. where the callback returns true) will returned as a - * new array. Similar to Array.prototype.Filter in vanilla JS. - * - * @method Phaser.Tilemaps.Tilemap#filterObjects - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.ObjectLayer|string} [objectLayer] - The name of an object layer (from Tiled) or an - * ObjectLayer instance. - * @param {function} callback - The callback. Each object in the given area will be passed to - * this callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * - * @return {object[]|null} An array of object that match the search, or null if the objectLayer - * given was invalid. - */ - filterObjects: function (objectLayer, callback, context) - { - if (typeof objectLayer === 'string') - { - var name = objectLayer; - - objectLayer = this.getObjectLayer(objectLayer); - - if (!objectLayer) - { - console.warn('No object layer found with the name: ' + name); - return null; - } - } - - return objectLayer.objects.filter(callback, context); - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns - * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#filterTiles - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. The callback should return true for tiles that pass the - * filter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile[]|null} Returns an array of Tiles, or null if the layer given was invalid. - */ - filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, layer); - }, - - /** - * Searches the entire map layer for the first tile matching the given index, then returns that Tile - * object. If no match is found, it returns null. The search starts from the top-left tile and - * continues horizontally until it hits the end of the row, then it drops down to the next column. - * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to - * the top-left. - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#findByIndex - * @since 3.0.0 - * - * @param {integer} index - The tile index value to search for. - * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. - * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the - * bottom-right. Otherwise it scans from the top-left. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile|null} Returns a Tiles, or null if the layer given was invalid. - */ - findByIndex: function (findIndex, skip, reverse, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.FindByIndex(findIndex, skip, reverse, layer); - }, - - /** - * Find the first object in the given object layer that satisfies the provided testing function. - * I.e. finds the first object for which `callback` returns true. Similar to - * Array.prototype.find in vanilla JS. - * - * @method Phaser.Tilemaps.Tilemap#findObject - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.ObjectLayer|string} [objectLayer] - The name of an object layer (from Tiled) or an - * ObjectLayer instance. - * @param {function} callback - The callback. Each object in the given area will be passed to - * this callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * - * @return {object|null} An object that matches the search, or null if no object found - */ - findObject: function (objectLayer, callback, context) - { - if (typeof objectLayer === 'string') - { - var name = objectLayer; - - objectLayer = this.getObjectLayer(objectLayer); - - if (!objectLayer) - { - console.warn('No object layer found with the name: ' + name); - return null; - } - } - - return objectLayer.objects.find(callback, context) || null; - }, - - /** - * Find the first tile in the given rectangular area (in tile coordinates) of the layer that - * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns - * true. Similar to Array.prototype.find in vanilla JS. - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#findTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile|null} Returns a Tiles, or null if the layer given was invalid. - */ - findTile: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, layer); - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * callback. Similar to Array.prototype.forEach in vanilla JS. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#forEachTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Returns this, or null if the layer given was invalid. - */ - forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) - { - layer = this.getLayer(layer); - - if (layer !== null) - { - TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, layer); - } - - return this; - }, - - /** - * Gets the image layer index based on its name. - * - * @method Phaser.Tilemaps.Tilemap#getImageIndex - * @since 3.0.0 - * - * @param {string} name - The name of the image to get. - * - * @return {integer} The index of the image in this tilemap, or null if not found. - */ - getImageIndex: function (name) - { - return this.getIndex(this.images, name); - }, - - /** - * Internally used. Returns the index of the object in one of the Tilemaps arrays whose name - * property matches the given `name`. - * - * @method Phaser.Tilemaps.Tilemap#getIndex - * @since 3.0.0 - * - * @param {array} location - The Tilemap array to search. - * @param {string} name - The name of the array element to get. - * - * @return {number} The index of the element in the array, or null if not found. - */ - getIndex: function (location, name) - { - for (var i = 0; i < location.length; i++) - { - if (location[i].name === name) - { - return i; - } - } - - return null; - }, - - /** - * Gets the LayerData from this.layers that is associated with `layer`, or null if an invalid - * `layer` is given. - * - * @method Phaser.Tilemaps.Tilemap#getLayer - * @since 3.0.0 - * - * @param {string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer} [layer] - The name of the - * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a - * StaticTilemapLayer. If not given will default to the maps current layer index. - * - * @return {Phaser.Tilemaps.LayerData} The corresponding LayerData within this.layers. - */ - getLayer: function (layer) - { - var index = this.getLayerIndex(layer); - - return index !== null ? this.layers[index] : null; - }, - - /** - * Gets the ObjectLayer from this.objects that has the given `name`, or null if no ObjectLayer - * is found with that name. - * - * @method Phaser.Tilemaps.Tilemap#getObjectLayer - * @since 3.0.0 - * - * @param {string} [name] - The name of the object layer from Tiled. - * - * @return {Phaser.Tilemaps.ObjectLayer|null} The corresponding ObjectLayer within this.objects or null. - */ - getObjectLayer: function (name) - { - var index = this.getIndex(this.objects, name); - - return index !== null ? this.objects[index] : null; - }, - - /** - * Gets the LayerData index of the given `layer` within this.layers, or null if an invalid - * `layer` is given. - * - * @method Phaser.Tilemaps.Tilemap#getLayerIndex - * @since 3.0.0 - * - * @param {string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer} [layer] - The name of the - * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a - * StaticTilemapLayer. If not given will default to the map's current layer index. - * - * @return {integer} The LayerData index within this.layers. - */ - getLayerIndex: function (layer) - { - if (layer === undefined) - { - return this.currentLayerIndex; - } - else if (typeof layer === 'string') - { - return this.getLayerIndexByName(layer); - } - else if (typeof layer === 'number' && layer < this.layers.length) - { - return layer; - } - else if (layer instanceof StaticTilemapLayer || layer instanceof DynamicTilemapLayer) - { - return layer.layerIndex; - } - else - { - return null; - } - }, - - /** - * Gets the index of the LayerData within this.layers that has the given `name`, or null if an - * invalid `name` is given. - * - * @method Phaser.Tilemaps.Tilemap#getLayerIndexByName - * @since 3.0.0 - * - * @param {string} name - The name of the layer to get. - * - * @return {integer} The LayerData index within this.layers. - */ - getLayerIndexByName: function (name) - { - return this.getIndex(this.layers, name); - }, - - /** - * Gets a tile at the given tile coordinates from the given layer. - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#getTileAt - * @since 3.0.0 - * - * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). - * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). - * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile|null} Returns a Tile, or null if the layer given was invalid. - */ - getTileAt: function (tileX, tileY, nonNull, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.GetTileAt(tileX, tileY, nonNull, layer); - }, - - /** - * Gets a tile at the given world coordinates from the given layer. - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#getTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - X position to get the tile from (given in pixels) - * @param {number} worldY - Y position to get the tile from (given in pixels) - * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile|null} Returns a Tile, or null if the layer given was invalid. - */ - getTileAtWorldXY: function (worldX, worldY, nonNull, camera, layer) - { - layer = this.getLayer(layer); - - - if (layer === null) { return null; } - - return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, layer); - }, - - /** - * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#getTilesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile[]|null} Returns an array of Tiles, or null if the layer given was invalid. - */ - getTilesWithin: function (tileX, tileY, width, height, filteringOptions, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); - }, - - /** - * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, - * Line, Rectangle or Triangle. The shape should be in world coordinates. - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#getTilesWithinShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle} shape - A shape in world (pixel) coordinates - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile[]|null} Returns an array of Tiles, or null if the layer given was invalid. - */ - getTilesWithinShape: function (shape, filteringOptions, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, layer); - }, - - /** - * Gets the tiles in the given rectangular area (in world coordinates) of the layer. - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#getTilesWithinWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile[]|null} Returns an array of Tiles, or null if the layer given was invalid. - */ - getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, layer); - }, - - /** - * Gets the index of the Tileset within this.tilesets that has the given `name`, or null if an - * invalid `name` is given. - * - * @method Phaser.Tilemaps.Tilemap#getTilesetIndex - * @since 3.0.0 - * - * @param {string} name - The name of the Tileset to get. - * - * @return {integer} The Tileset index within this.tilesets. - */ - getTilesetIndex: function (name) - { - return this.getIndex(this.tilesets, name); - }, - - /** - * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#hasTileAt - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {boolean|null} Returns a boolean, or null if the layer given was invalid. - */ - hasTileAt: function (tileX, tileY, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.HasTileAt(tileX, tileY, layer); - }, - - /** - * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#hasTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {boolean|null} Returns a boolean, or null if the layer given was invalid. - */ - hasTileAtWorldXY: function (worldX, worldY, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, layer); - }, - - /** - * The LayerData object that is currently selected in the map. You can set this property using - * any type supported by setLayer. - * - * @name Phaser.Tilemaps.Tilemap#layer - * @type {Phaser.Tilemaps.LayerData} - * @since 3.0.0 - */ - layer: { - get: function () - { - return this.layers[this.currentLayerIndex]; - }, - - set: function (layer) - { - this.setLayer(layer); - } - }, - - /** - * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index - * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified - * location. If you pass in an index, only the index at the specified location will be changed. - * Collision information will be recalculated at the specified location. - * - * If no layer specified, the maps current layer is used. - * - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#putTileAt - * @since 3.0.0 - * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile|null} Returns a Tile, or null if the layer given was invalid. - */ - putTileAt: function (tile, tileX, tileY, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'putTileAt')) { return null; } - - if (layer === null) { return null; } - - return TilemapComponents.PutTileAt(tile, tileX, tileY, recalculateFaces, layer); - }, - - /** - * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either - * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the - * specified location. If you pass in an index, only the index at the specified location will be - * changed. Collision information will be recalculated at the specified location. - * - * If no layer specified, the maps current layer is used. This - * cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#putTileAtWorldXY - * @since 3.0.0 - * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {integer} worldX - [description] - * @param {integer} worldY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile|null} Returns a Tile, or null if the layer given was invalid. - */ - putTileAtWorldXY: function (tile, worldX, worldY, recalculateFaces, camera, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'putTileAtWorldXY')) { return null; } - - if (layer === null) { return null; } - - return TilemapComponents.PutTileAtWorldXY(tile, worldX, worldY, recalculateFaces, camera, layer); - }, - - /** - * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified - * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, - * all attributes will be copied over to the specified location. If you pass in an index, only the - * index at the specified location will be changed. Collision information will be recalculated - * within the region tiles were changed. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#putTilesAt - * @since 3.0.0 - * - * @param {integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][]} tile - A row (array) or grid (2D array) of Tiles - * or tile indexes to place. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Returns this, or null if the layer given was invalid. - */ - putTilesAt: function (tilesArray, tileX, tileY, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'putTilesAt')) { return this; } - - if (layer !== null) - { - TilemapComponents.PutTilesAt(tilesArray, tileX, tileY, recalculateFaces, layer); - } - - return this; - }, - - /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will recieve a new index. If an array of indexes is passed in, then - * those will be used for randomly assigning new tile indexes. If an array is not provided, the - * indexes found within the region (excluding -1) will be used for randomly assigning new tile - * indexes. This method only modifies tile indexes and does not change collision information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#randomize - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Returns this, or null if the layer given was invalid. - */ - randomize: function (tileX, tileY, width, height, indexes, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'randomize')) { return this; } - - if (layer !== null) - { - TilemapComponents.Randomize(tileX, tileY, width, height, indexes, layer); - } - - return this; - }, - - /** - * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting - * faces are used internally for optimizing collisions against tiles. This method is mostly used - * internally to optimize recalculating faces when only one tile has been changed. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#calculateFacesAt - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Returns this, or null if the layer given was invalid. - */ - calculateFacesAt: function (tileX, tileY, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.CalculateFacesAt(tileX, tileY, layer); - - return this; - }, - - /** - * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the - * layer. Interesting faces are used internally for optimizing collisions against tiles. This method - * is mostly used internally. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#calculateFacesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Returns this, or null if the layer given was invalid. - */ - calculateFacesWithin: function (tileX, tileY, width, height, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, layer); - - return this; - }, - - /** - * Removes all layers from this Tilemap and destroys any associated StaticTilemapLayers or - * DynamicTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#removeAllLayers - * @since 3.0.0 - * - * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. - */ - removeAllLayers: function () - { - // Destroy any StaticTilemapLayers or DynamicTilemapLayers that are stored in LayerData - for (var i = 0; i < this.layers.length; i++) - { - if (this.layers[i].tilemapLayer) - { - this.layers[i].tilemapLayer.destroy(); - } - } - - this.layers.length = 0; - this.currentLayerIndex = 0; - - return this; - }, - - /** - * Removes the tile at the given tile coordinates in the specified layer and updates the layer's - * collision information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#removeTileAt - * @since 3.0.0 - * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile|null} Returns a Tile, or null if the layer given was invalid. - */ - removeTileAt: function (tileX, tileY, replaceWithNull, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'removeTileAt')) { return null; } - - if (layer === null) { return null; } - - return TilemapComponents.RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, layer); - }, - - /** - * Removes the tile at the given world coordinates in the specified layer and updates the layer's - * collision information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#removeTileAtWorldXY - * @since 3.0.0 - * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tile|null} Returns a Tile, or null if the layer given was invalid. - */ - removeTileAtWorldXY: function (worldX, worldY, replaceWithNull, recalculateFaces, camera, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'removeTileAtWorldXY')) { return null; } - - if (layer === null) { return null; } - - return TilemapComponents.RemoveTileAtWorldXY(worldX, worldY, replaceWithNull, recalculateFaces, camera, layer); - }, - - /** - * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to - * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles - * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation - * wherever you want on the screen. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#renderDebug - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. - * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. - * @param {Color|null} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at - * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. - * @param {Color|null} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled - * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. - * @param {Color|null} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting - * tile faces. If set to null, interesting tile faces will not be drawn. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - renderDebug: function (graphics, styleConfig, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.RenderDebug(graphics, styleConfig, layer); - - return this; - }, - - /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does - * not change collision information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#replaceByIndex - * @since 3.0.0 - * - * @param {integer} findIndex - [description] - * @param {integer} newIndex - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - replaceByIndex: function (findIndex, newIndex, tileX, tileY, width, height, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'replaceByIndex')) { return this; } - - if (layer !== null) - { - TilemapComponents.ReplaceByIndex(findIndex, newIndex, tileX, tileY, width, height, layer); - } - - return this; - }, - - /** - * Sets collision on the given tile or tiles within a layer by index. You can pass in either a - * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if - * collision will be enabled (true) or disabled (false). - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setCollision - * @since 3.0.0 - * - * @param {integer|array} indexes - Either a single tile index, or an array of tile indexes. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - setCollision: function (indexes, collides, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetCollision(indexes, collides, recalculateFaces, layer); - - return this; - }, - - /** - * Sets collision on a range of tiles in a layer whose index is between the specified `start` and - * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set - * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be - * enabled (true) or disabled (false). - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setCollisionBetween - * @since 3.0.0 - * - * @param {integer} start - The first index of the tile to be set for collision. - * @param {integer} stop - The last index of the tile to be set for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - setCollisionBetween: function (start, stop, collides, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property - * that matches the given properties object, its collision flag will be set. The `collides` - * parameter controls if collision will be enabled (true) or disabled (false). Passing in - * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that - * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can - * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a - * "types" property that matches any of those values, its collision flag will be updated. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setCollisionByProperty - * @since 3.0.0 - * - * @param {object} properties - An object with tile properties and corresponding values that should - * be checked. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - setCollisionByProperty: function (properties, collides, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, layer); - - return this; - }, - - /** - * Sets collision on all tiles in the given layer, except for tiles that have an index specified in - * the given array. The `collides` parameter controls if collision will be enabled (true) or - * disabled (false). - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setCollisionByExclusion - * @since 3.0.0 - * - * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - setCollisionByExclusion: function (indexes, collides, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking each tile's collision group data - * (typically defined in Tiled within the tileset collision editor). If any objects are found within - * a tile's collision group, the tile's colliding information will be set. The `collides` parameter - * controls if collision will be enabled (true) or disabled (false). - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setCollisionFromCollisionGroup - * @since 3.0.0 - * - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - setCollisionFromCollisionGroup: function (collides, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, layer); - - return this; - }, - - /** - * Sets a global collision callback for the given tile index within the layer. This will affect all - * tiles on this layer that have the same index. If a callback is already set for the tile index it - * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile - * at a specific location on the map then see setTileLocationCallback. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setTileIndexCallback - * @since 3.0.0 - * - * @param {integer|array} indexes - Either a single tile index, or an array of tile indexes to have a - * collision callback set for. - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - setTileIndexCallback: function (indexes, callback, callbackContext, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, layer); - - return this; - }, - - /** - * Sets a collision callback for the given rectangular area (in tile coordindates) within the layer. - * If a callback is already set for the tile index it will be replaced. Set the callback to null to - * remove it. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setTileLocationCallback - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, layer); - - return this; - }, - - /** - * Sets the current layer to the LayerData associated with `layer`. - * - * @method Phaser.Tilemaps.Tilemap#setLayer - * @since 3.0.0 - * - * @param {string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer} [layer] - The name of the - * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a - * StaticTilemapLayer. If not given will default to the map's current layer index. - * - * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. - */ - setLayer: function (layer) - { - var index = this.getLayerIndex(layer); - - if (index !== null) - { - this.currentLayerIndex = index; - } - - return this; - }, - - /** - * Sets the base tile size for the map. Note: this does not necessarily match the tileWidth and - * tileHeight for all layers. This also updates the base size on all tiles across all layers. - * - * @method Phaser.Tilemaps.Tilemap#setBaseTileSize - * @since 3.0.0 - * - * @param {integer} tileWidth - The width of the tiles the map uses for calculations. - * @param {integer} tileHeight - The height of the tiles the map uses for calculations. - * - * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. - */ - setBaseTileSize: function (tileWidth, tileHeight) - { - this.tileWidth = tileWidth; - this.tileHeight = tileHeight; - this.widthInPixels = this.width * tileWidth; - this.heightInPixels = this.height * tileHeight; - - // Update the base tile size on all layers & tiles - for (var i = 0; i < this.layers.length; i++) - { - this.layers[i].baseWidth = tileWidth; - this.layers[i].baseHeight = tileHeight; - - var mapData = this.layers[i].data; - var mapWidth = this.layers[i].width; - var mapHeight = this.layers[i].height; - - for (var row = 0; row < mapHeight; ++row) - { - for (var col = 0; col < mapWidth; ++col) - { - var tile = mapData[row][col]; - - if (tile !== null) - { - tile.setSize(undefined, undefined, tileWidth, tileHeight); - } - } - } - } - - return this; - }, - - /** - * Sets the tile size for a specific `layer`. Note: this does not necessarily match the map's - * tileWidth and tileHeight for all layers. This will set the tile size for the layer and any - * tiles the layer has. - * - * @method Phaser.Tilemaps.Tilemap#setLayerTileSize - * @since 3.0.0 - * - * @param {integer} tileWidth - The width of the tiles (in pixels) in the layer. - * @param {integer} tileHeight - The height of the tiles (in pixels) in the layer. - * @param {string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer} [layer] - The name of the - * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a - * StaticTilemapLayer. If not given will default to the map's current layer index. - * - * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. - */ - setLayerTileSize: function (tileWidth, tileHeight, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - layer.tileWidth = tileWidth; - layer.tileHeight = tileHeight; - - var mapData = layer.data; - var mapWidth = layer.width; - var mapHeight = layer.height; - - for (var row = 0; row < mapHeight; ++row) - { - for (var col = 0; col < mapWidth; ++col) - { - var tile = mapData[row][col]; - - if (tile !== null) { tile.setSize(tileWidth, tileHeight); } - } - } - - return this; - }, - - /** - * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given - * layer. It will only randomize the tiles in that area, so if they're all the same nothing will - * appear to have changed! This method only modifies tile indexes and does not change collision - * information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#shuffle - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - shuffle: function (tileX, tileY, width, height, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'shuffle')) { return this; } - - if (layer !== null) - { - TilemapComponents.Shuffle(tileX, tileY, width, height, layer); - } - - return this; - }, - - /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision - * information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#swapByIndex - * @since 3.0.0 - * - * @param {integer} tileA - First tile index. - * @param {integer} tileB - Second tile index. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - swapByIndex: function (indexA, indexB, tileX, tileY, width, height, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'swapByIndex')) { return this; } - - if (layer !== null) - { - TilemapComponents.SwapByIndex(indexA, indexB, tileX, tileY, width, height, layer); - } - - return this; - }, - - /** - * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#tileToWorldX - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {number|null} Returns a number, or null if the layer given was invalid. - */ - tileToWorldX: function (tileX, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.TileToWorldX(tileX, camera, layer); - }, - - /** - * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#tileToWorldY - * @since 3.0.0 - * - * @param {integer} tileY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {number|null} Returns a number, or null if the layer given was invalid. - */ - tileToWorldY: function (tileX, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.TileToWorldY(tileX, camera, layer); - }, - - /** - * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#tileToWorldXY - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Math.Vector2|null} Returns a point, or null if the layer given was invalid. - */ - tileToWorldXY: function (tileX, tileY, point, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, layer); - }, - - /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will receive a new index. New indexes are drawn from the given - * weightedIndexes array. An example weighted array: - * - * [ - * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 - * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 - * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 - * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 - * ] - * - * The probability of any index being choose is (the index's weight) / (sum of all weights). This - * method only modifies tile indexes and does not change collision information. - * - * If no layer specified, the map's current layer is used. This - * cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#weightedRandomize - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during - * randomization. They should be in the form: { index: 0, weight: 4 } or - * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Tilemaps.Tilemap|null} Return this Tilemap object, or null if the layer given was invalid. - */ - weightedRandomize: function (tileX, tileY, width, height, weightedIndexes, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'weightedRandomize')) { return this; } - - if (layer !== null) - { - TilemapComponents.WeightedRandomize(tileX, tileY, width, height, weightedIndexes, layer); - } - - return this; - }, - - /** - * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#worldToTileX - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {number|null} Returns a number, or null if the layer given was invalid. - */ - worldToTileX: function (worldX, snapToFloor, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, layer); - }, - - /** - * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#worldToTileY - * @since 3.0.0 - * - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {number|null} Returns a number, or null if the layer given was invalid. - */ - worldToTileY: function (worldY, snapToFloor, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, layer); - }, - - /** - * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#worldToTileXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - [description] - * - * @return {Phaser.Math.Vector2|null} Returns a point, or null if the layer given was invalid. - */ - worldToTileXY: function (worldX, worldY, snapToFloor, point, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, layer); - }, - - /** - * Used internally to check if a layer is static and prints out a warning. - * - * @method Phaser.Tilemaps.Tilemap#_isStaticCall - * @private - * @since 3.0.0 - * - * @return {boolean} - */ - _isStaticCall: function (layer, functionName) - { - if (layer.tilemapLayer instanceof StaticTilemapLayer) - { - console.warn(functionName + ': You cannot change the tiles in a static tilemap layer'); - return true; - } - else - { - return false; - } - } - -}); - -module.exports = Tilemap; +module.exports = GetPoint; /***/ }), @@ -71800,1113 +76482,36 @@ module.exports = Tilemap; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var DynamicTilemapLayerRender = __webpack_require__(914); -var GameObject = __webpack_require__(1); -var TilemapComponents = __webpack_require__(96); +var GetRight = __webpack_require__(32); +var GetTop = __webpack_require__(30); +var SetRight = __webpack_require__(31); +var SetTop = __webpack_require__(29); /** - * @classdesc - * A DynamicTilemapLayer is a game object that renders LayerData from a Tilemap. A - * DynamicTilemapLayer can only render tiles from a single tileset. + * Takes given Game Object and aligns it so that it is positioned in the top right of the other. * - * A DynamicTilemapLayer trades some speed for being able to apply powerful effects. Unlike a - * StaticTilemapLayer, you can apply per-tile effects like tint or alpha, and you can change the - * tiles in a DynamicTilemapLayer. Use this over a StaticTilemapLayer when you need those - * features. - * - * @class DynamicTilemapLayer - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.Tilemaps - * @constructor + * @function Phaser.Display.Align.In.TopRight * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * @extends Phaser.GameObjects.Components.ScrollFactor * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.Tilemaps.Tilemap} tilemap - The Tilemap this layer is a part of. - * @param {integer} layerIndex - The index of the LayerData associated with this layer. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset used to render the tiles in this layer. - * @param {number} [x=0] - The world x position where the top left of this layer will be placed. - * @param {number} [y=0] - The world y position where the top left of this layer will be placed. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. */ -var DynamicTilemapLayer = new Class({ +var TopRight = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } - Extends: GameObject, + SetRight(gameObject, GetRight(alignIn) + offsetX); + SetTop(gameObject, GetTop(alignIn) - offsetY); - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.Size, - Components.Transform, - Components.Visible, - Components.ScrollFactor, - DynamicTilemapLayerRender - ], + return gameObject; +}; - initialize: - - function DynamicTilemapLayer (scene, tilemap, layerIndex, tileset, x, y) - { - GameObject.call(this, scene, 'DynamicTilemapLayer'); - - /** - * Used internally by physics system to perform fast type checks. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#isTilemap - * @type {boolean} - * @readOnly - * @since 3.0.0 - */ - this.isTilemap = true; - - /** - * The Tilemap that this layer is a part of. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#tilemap - * @type {Phaser.Tilemaps.Tilemap} - * @since 3.0.0 - */ - this.tilemap = tilemap; - - /** - * The index of the LayerData associated with this layer. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#layerIndex - * @type {integer} - * @since 3.0.0 - */ - this.layerIndex = layerIndex; - - /** - * The LayerData associated with this layer. LayerData can only be associated with one - * tilemap layer. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#layer - * @type {Phaser.Tilemaps.LayerData} - * @since 3.0.0 - */ - this.layer = tilemap.layers[layerIndex]; - - this.layer.tilemapLayer = this; // Link the LayerData with this static tilemap layer - - /** - * The Tileset associated with this layer. A tilemap layer can only render from one Tileset. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#tileset - * @type {Phaser.Tilemaps.Tileset} - * @since 3.0.0 - */ - this.tileset = tileset; - - /** - * Used internally with the canvas render. This holds the tiles that are visible within the - * camera. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#culledTiles - * @type {array} - * @since 3.0.0 - */ - this.culledTiles = []; - - this.setAlpha(this.layer.alpha); - this.setPosition(x, y); - this.setOrigin(); - this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height); - - this.initPipeline('TextureTintPipeline'); - }, - - /** - * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting - * faces are used internally for optimizing collisions against tiles. This method is mostly used - * internally to optimize recalculating faces when only one tile has been changed. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#calculateFacesAt - * @since 3.0.0 - * - * @param {integer} tileX - The x coordinate. - * @param {integer} tileY - The y coordinate. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - calculateFacesAt: function (tileX, tileY) - { - TilemapComponents.CalculateFacesAt(tileX, tileY, this.layer); - - return this; - }, - - /** - * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the - * layer. Interesting faces are used internally for optimizing collisions against tiles. This method - * is mostly used internally. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#calculateFacesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - calculateFacesWithin: function (tileX, tileY, width, height) - { - TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, this.layer); - - return this; - }, - - /** - * Creates a Sprite for every object matching the given tile indexes in the layer. You can - * optionally specify if each tile will be replaced with a new tile after the Sprite has been - * created. This is useful if you want to lay down special tiles in a level that are converted to - * Sprites, but want to replace the tile itself with a floor tile or similar once converted. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#createFromTiles - * @since 3.0.0 - * - * @param {integer|array} indexes - The tile index, or array of indexes, to create Sprites from. - * @param {integer|array} replacements - The tile index, or array of indexes, to change a converted - * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a - * one-to-one mapping with the indexes array. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). - * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY - * - * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. - */ - createFromTiles: function (indexes, replacements, spriteConfig, scene, camera) - { - return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, this.layer); - }, - - /** - * Returns the tiles in the given layer that are within the cameras viewport. - * This is used internally. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#cull - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - cull: function (camera) - { - return TilemapComponents.CullTiles(this.layer, camera, this.culledTiles); - }, - - /** - * Copies the tiles in the source rectangular area to a new destination (all specified in tile - * coordinates) within the layer. This copies all tile properties & recalculates collision - * information in the destination region. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#copy - * @since 3.0.0 - * - * @param {integer} srcTileX - [description] - * @param {integer} srcTileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {integer} destTileX - [description] - * @param {integer} destTileY - [description] - * @param {integer} destTileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces) - { - TilemapComponents.Copy(srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, this.layer); - - return this; - }, - - /** - * Destroys this DynamicTilemapLayer and removes its link to the associated LayerData. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#destroy - * @since 3.0.0 - */ - destroy: function () - { - // Uninstall this layer only if it is still installed on the LayerData object - if (this.layer.tilemapLayer === this) - { - this.layer.tilemapLayer = undefined; - } - - this.tilemap = undefined; - this.layer = undefined; - this.tileset = undefined; - this.culledTiles.length = 0; - - GameObject.prototype.destroy.call(this); - }, - - /** - * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the - * specified index. Tiles will be set to collide if the given index is a colliding index. - * Collision information in the region will be recalculated. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#fill - * @since 3.0.0 - * - * @param {integer} index - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - fill: function (index, tileX, tileY, width, height, recalculateFaces) - { - TilemapComponents.Fill(index, tileX, tileY, width, height, recalculateFaces, this.layer); - - return this; - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns - * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#filterTiles - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. The callback should return true for tiles that pass the - * filter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * Searches the entire map layer for the first tile matching the given index, then returns that Tile - * object. If no match is found, it returns null. The search starts from the top-left tile and - * continues horizontally until it hits the end of the row, then it drops down to the next column. - * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to - * the top-left. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#findByIndex - * @since 3.0.0 - * - * @param {integer} index - The tile index value to search for. - * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. - * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the - * bottom-right. Otherwise it scans from the top-left. - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - findByIndex: function (findIndex, skip, reverse) - { - return TilemapComponents.FindByIndex(findIndex, skip, reverse, this.layer); - }, - - /** - * Find the first tile in the given rectangular area (in tile coordinates) of the layer that - * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns - * true. Similar to Array.prototype.find in vanilla JS. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#findTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.Tile|null} - */ - findTile: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * callback. Similar to Array.prototype.forEach in vanilla JS. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#forEachTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - - return this; - }, - - /** - * Gets a tile at the given tile coordinates from the given layer. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#getTileAt - * @since 3.0.0 - * - * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). - * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). - * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile - * object with an index of -1. - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates were invalid. - */ - getTileAt: function (tileX, tileY, nonNull) - { - return TilemapComponents.GetTileAt(tileX, tileY, nonNull, this.layer); - }, - - /** - * Gets a tile at the given world coordinates from the given layer. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#getTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - X position to get the tile from (given in pixels) - * @param {number} worldY - Y position to get the tile from (given in pixels) - * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates - * were invalid. - */ - getTileAtWorldXY: function (worldX, worldY, nonNull, camera) - { - return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, this.layer); - }, - - /** - * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithin: function (tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, - * Line, Rectangle or Triangle. The shape should be in world coordinates. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithinShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle} shape - A shape in world (pixel) coordinates - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithinShape: function (shape, filteringOptions, camera) - { - return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, this.layer); - }, - - /** - * Gets the tiles in the given rectangular area (in world coordinates) of the layer. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithinWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera) - { - return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, this.layer); - }, - - /** - * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#hasTileAt - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * - * @return {boolean} - */ - hasTileAt: function (tileX, tileY) - { - return TilemapComponents.HasTileAt(tileX, tileY, this.layer); - }, - - /** - * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#hasTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {boolean} - */ - hasTileAtWorldXY: function (worldX, worldY, camera) - { - return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, this.layer); - }, - - /** - * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index - * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified - * location. If you pass in an index, only the index at the specified location will be changed. - * Collision information will be recalculated at the specified location. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#putTileAt - * @since 3.0.0 - * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - putTileAt: function (tile, tileX, tileY, recalculateFaces) - { - return TilemapComponents.PutTileAt(tile, tileX, tileY, recalculateFaces, this.layer); - }, - - /** - * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either - * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the - * specified location. If you pass in an index, only the index at the specified location will be - * changed. Collision information will be recalculated at the specified location. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#putTileAtWorldXY - * @since 3.0.0 - * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {integer} worldX - [description] - * @param {integer} worldY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera] - [description] - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - putTileAtWorldXY: function (tile, worldX, worldY, recalculateFaces, camera) - { - return TilemapComponents.PutTileAtWorldXY(tile, worldX, worldY, recalculateFaces, camera, this.layer); - }, - - /** - * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified - * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, - * all attributes will be copied over to the specified location. If you pass in an index, only the - * index at the specified location will be changed. Collision information will be recalculated - * within the region tiles were changed. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#putTilesAt - * @since 3.0.0 - * - * @param {integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][]} tile - A row (array) or grid (2D array) of Tiles - * or tile indexes to place. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - putTilesAt: function (tilesArray, tileX, tileY, recalculateFaces) - { - TilemapComponents.PutTilesAt(tilesArray, tileX, tileY, recalculateFaces, this.layer); - - return this; - }, - - /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then - * those will be used for randomly assigning new tile indexes. If an array is not provided, the - * indexes found within the region (excluding -1) will be used for randomly assigning new tile - * indexes. This method only modifies tile indexes and does not change collision information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#randomize - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - randomize: function (tileX, tileY, width, height, indexes) - { - TilemapComponents.Randomize(tileX, tileY, width, height, indexes, this.layer); - - return this; - }, - - /** - * Removes the tile at the given tile coordinates in the specified layer and updates the layer's - * collision information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#removeTileAt - * @since 3.0.0 - * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - removeTileAt: function (tileX, tileY, replaceWithNull, recalculateFaces) - { - return TilemapComponents.RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, this.layer); - }, - - /** - * Removes the tile at the given world coordinates in the specified layer and updates the layer's - * collision information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#removeTileAtWorldXY - * @since 3.0.0 - * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - removeTileAtWorldXY: function (worldX, worldY, replaceWithNull, recalculateFaces, camera) - { - return TilemapComponents.RemoveTileAtWorldXY(worldX, worldY, replaceWithNull, recalculateFaces, camera, this.layer); - }, - - /** - * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to - * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles - * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation - * wherever you want on the screen. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#renderDebug - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. - * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. - * @param {Color|null} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at - * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. - * @param {Color|null} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled - * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. - * @param {Color|null} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting - * tile faces. If set to null, interesting tile faces will not be drawn. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - renderDebug: function (graphics, styleConfig) - { - TilemapComponents.RenderDebug(graphics, styleConfig, this.layer); - - return this; - }, - - /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does - * not change collision information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#replaceByIndex - * @since 3.0.0 - * - * @param {integer} findIndex - [description] - * @param {integer} newIndex - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - replaceByIndex: function (findIndex, newIndex, tileX, tileY, width, height) - { - TilemapComponents.ReplaceByIndex(findIndex, newIndex, tileX, tileY, width, height, this.layer); - - return this; - }, - - /** - * Sets collision on the given tile or tiles within a layer by index. You can pass in either a - * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if - * collision will be enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollision - * @since 3.0.0 - * - * @param {integer|array} indexes - Either a single tile index, or an array of tile indexes. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setCollision: function (indexes, collides, recalculateFaces) - { - TilemapComponents.SetCollision(indexes, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on a range of tiles in a layer whose index is between the specified `start` and - * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set - * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be - * enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionBetween - * @since 3.0.0 - * - * @param {integer} start - The first index of the tile to be set for collision. - * @param {integer} stop - The last index of the tile to be set for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setCollisionBetween: function (start, stop, collides, recalculateFaces) - { - TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property - * that matches the given properties object, its collision flag will be set. The `collides` - * parameter controls if collision will be enabled (true) or disabled (false). Passing in - * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that - * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can - * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a - * "types" property that matches any of those values, its collision flag will be updated. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionByProperty - * @since 3.0.0 - * - * @param {object} properties - An object with tile properties and corresponding values that should - * be checked. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setCollisionByProperty: function (properties, collides, recalculateFaces) - { - TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on all tiles in the given layer, except for tiles that have an index specified in - * the given array. The `collides` parameter controls if collision will be enabled (true) or - * disabled (false). - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionByExclusion - * @since 3.0.0 - * - * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setCollisionByExclusion: function (indexes, collides, recalculateFaces) - { - TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking each tiles collision group data - * (typically defined in Tiled within the tileset collision editor). If any objects are found within - * a tiles collision group, the tile's colliding information will be set. The `collides` parameter - * controls if collision will be enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionFromCollisionGroup - * @since 3.0.0 - * - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setCollisionFromCollisionGroup: function (collides, recalculateFaces) - { - TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets a global collision callback for the given tile index within the layer. This will affect all - * tiles on this layer that have the same index. If a callback is already set for the tile index it - * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile - * at a specific location on the map then see setTileLocationCallback. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setTileIndexCallback - * @since 3.0.0 - * - * @param {integer|array} indexes - Either a single tile index, or an array of tile indexes to have a - * collision callback set for. - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setTileIndexCallback: function (indexes, callback, callbackContext) - { - TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, this.layer); - - return this; - }, - - /** - * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. - * If a callback is already set for the tile index it will be replaced. Set the callback to null to - * remove it. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setTileLocationCallback - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext) - { - TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, this.layer); - - return this; - }, - - /** - * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given - * layer. It will only randomize the tiles in that area, so if they're all the same nothing will - * appear to have changed! This method only modifies tile indexes and does not change collision - * information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#shuffle - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - shuffle: function (tileX, tileY, width, height) - { - TilemapComponents.Shuffle(tileX, tileY, width, height, this.layer); - - return this; - }, - - /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision - * information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#swapByIndex - * @since 3.0.0 - * - * @param {integer} tileA - First tile index. - * @param {integer} tileB - Second tile index. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - swapByIndex: function (indexA, indexB, tileX, tileY, width, height) - { - TilemapComponents.SwapByIndex(indexA, indexB, tileX, tileY, width, height, this.layer); - - return this; - }, - - /** - * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldX - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - tileToWorldX: function (tileX, camera) - { - return TilemapComponents.TileToWorldX(tileX, camera, this.layer); - }, - - /** - * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldY - * @since 3.0.0 - * - * @param {integer} tileY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - tileToWorldY: function (tileY, camera) - { - return TilemapComponents.TileToWorldY(tileY, camera, this.layer); - }, - - /** - * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldXY - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Math.Vector2} - */ - tileToWorldXY: function (tileX, tileY, point, camera) - { - return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, this.layer); - }, - - /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will recieve a new index. New indexes are drawn from the given - * weightedIndexes array. An example weighted array: - * - * [ - * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 - * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 - * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 - * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 - * ] - * - * The probability of any index being choose is (the index's weight) / (sum of all weights). This - * method only modifies tile indexes and does not change collision information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#weightedRandomize - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during - * randomization. They should be in the form: { index: 0, weight: 4 } or - * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - weightedRandomize: function (tileX, tileY, width, height, weightedIndexes) - { - TilemapComponents.WeightedRandomize(tileX, tileY, width, height, weightedIndexes, this.layer); - - return this; - }, - - /** - * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileX - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - worldToTileX: function (worldX, snapToFloor, camera) - { - return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, this.layer); - }, - - /** - * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileXY - * @since 3.0.0 - * - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - worldToTileY: function (worldY, snapToFloor, camera) - { - return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, this.layer); - }, - - /** - * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Math.Vector2} - */ - worldToTileXY: function (worldX, worldY, snapToFloor, point, camera) - { - return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, this.layer); - } - -}); - -module.exports = DynamicTilemapLayer; +module.exports = TopRight; /***/ }), @@ -72919,1023 +76524,36 @@ module.exports = DynamicTilemapLayer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var CONST = __webpack_require__(19); -var GameObject = __webpack_require__(1); -var StaticTilemapLayerRender = __webpack_require__(917); -var TilemapComponents = __webpack_require__(96); -var Utils = __webpack_require__(41); +var GetLeft = __webpack_require__(34); +var GetTop = __webpack_require__(30); +var SetLeft = __webpack_require__(33); +var SetTop = __webpack_require__(29); /** - * @classdesc - * A StaticTilemapLayer is a game object that renders LayerData from a Tilemap. A - * StaticTilemapLayer can only render tiles from a single tileset. + * Takes given Game Object and aligns it so that it is positioned in the top left of the other. * - * A StaticTilemapLayer is optimized for speed over flexibility. You cannot apply per-tile - * effects like tint or alpha. You cannot change the tiles in a StaticTilemapLayer. Use this - * over a DynamicTilemapLayer when you don't need either of those features. - * - * @class StaticTilemapLayer - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.Tilemaps - * @constructor + * @function Phaser.Display.Align.In.TopLeft * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * @extends Phaser.GameObjects.Components.ScrollFactor * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.Tilemaps.Tilemap} tilemap - The Tilemap this layer is a part of. - * @param {integer} layerIndex - The index of the LayerData associated with this layer. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset used to render the tiles in this layer. - * @param {number} [x=0] - The world x position where the top left of this layer will be placed. - * @param {number} [y=0] - The world y position where the top left of this layer will be placed. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. */ -var StaticTilemapLayer = new Class({ +var TopLeft = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } - Extends: GameObject, + SetLeft(gameObject, GetLeft(alignIn) - offsetX); + SetTop(gameObject, GetTop(alignIn) - offsetY); - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.Size, - Components.Transform, - Components.Visible, - Components.ScrollFactor, - StaticTilemapLayerRender - ], + return gameObject; +}; - initialize: - - function StaticTilemapLayer (scene, tilemap, layerIndex, tileset, x, y) - { - GameObject.call(this, scene, 'StaticTilemapLayer'); - - /** - * Used internally by physics system to perform fast type checks. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#isTilemap - * @type {boolean} - * @readOnly - * @since 3.0.0 - */ - this.isTilemap = true; - - /** - * The Tilemap that this layer is a part of. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#tilemap - * @type {Phaser.Tilemaps.Tilemap} - * @since 3.0.0 - */ - this.tilemap = tilemap; - - /** - * The index of the LayerData associated with this layer. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#layerIndex - * @type {integer} - * @since 3.0.0 - */ - this.layerIndex = layerIndex; - - /** - * The LayerData associated with this layer. LayerData can only be associated with one - * tilemap layer. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#layer - * @type {Phaser.Tilemaps.LayerData} - * @since 3.0.0 - */ - this.layer = tilemap.layers[layerIndex]; - - this.layer.tilemapLayer = this; // Link the LayerData with this static tilemap layer - - /** - * The Tileset associated with this layer. A tilemap layer can only render from one Tileset. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#tileset - * @type {Phaser.Tilemaps.Tileset} - * @since 3.0.0 - */ - this.tileset = tileset; - - /** - * Used internally with the canvas render. This holds the tiles that are visible within the - * camera. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#culledTiles - * @type {array} - * @since 3.0.0 - */ - this.culledTiles = []; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#vertexBuffer - * @type {array} - * @private - * @since 3.0.0 - */ - this.vertexBuffer = null; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#renderer - * @type {Phaser.Renderer.CanvasRenderer|Phaser.Renderer.WebGLRenderer} - * @private - * @since 3.0.0 - */ - this.renderer = scene.sys.game.renderer; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#bufferData - * @type {ArrayBuffer} - * @private - * @since 3.0.0 - */ - this.bufferData = null; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#vertexViewF32 - * @type {Float32Array} - * @private - * @since 3.0.0 - */ - this.vertexViewF32 = null; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#vertexViewU32 - * @type {Uint32Array} - * @private - * @since 3.0.0 - */ - this.vertexViewU32 = null; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#dirty - * @type {boolean} - * @private - * @since 3.0.0 - */ - this.dirty = true; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#vertexCount - * @type {integer} - * @private - * @since 3.0.0 - */ - this.vertexCount = 0; - - this.setAlpha(this.layer.alpha); - this.setPosition(x, y); - this.setOrigin(); - this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height); - - this.initPipeline('TextureTintPipeline'); - - if (scene.sys.game.config.renderType === CONST.WEBGL) - { - scene.sys.game.renderer.onContextRestored(function () - { - this.dirty = true; - this.vertexBuffer = null; - }, this); - } - }, - - /** - * Upload the tile data to a VBO. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#upload - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to render to. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - upload: function (camera) - { - var tileset = this.tileset; - var mapWidth = this.layer.width; - var mapHeight = this.layer.height; - var width = tileset.image.get().width; - var height = tileset.image.get().height; - var mapData = this.layer.data; - var renderer = this.renderer; - var tile; - var row; - var col; - var texCoords; - - if (renderer.gl) - { - var pipeline = renderer.pipelines.TextureTintPipeline; - - if (this.dirty) - { - var gl = renderer.gl; - var vertexBuffer = this.vertexBuffer; - var bufferData = this.bufferData; - var voffset = 0; - var vertexCount = 0; - var bufferSize = (mapWidth * mapHeight) * pipeline.vertexSize * 6; - - if (bufferData === null) - { - bufferData = new ArrayBuffer(bufferSize); - this.bufferData = bufferData; - this.vertexViewF32 = new Float32Array(bufferData); - this.vertexViewU32 = new Uint32Array(bufferData); - } - - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - - for (row = 0; row < mapHeight; ++row) - { - for (col = 0; col < mapWidth; ++col) - { - tile = mapData[row][col]; - if (tile === null || tile.index === -1) { continue; } - - var tx = tile.pixelX; - var ty = tile.pixelY; - var txw = tx + tile.width; - var tyh = ty + tile.height; - - texCoords = tileset.getTileTextureCoordinates(tile.index); - if (texCoords === null) { continue; } - - var u0 = texCoords.x / width; - var v0 = texCoords.y / height; - var u1 = (texCoords.x + tile.width) / width; - var v1 = (texCoords.y + tile.height) / height; - - var tx0 = tx; - var ty0 = ty; - var tx1 = tx; - var ty1 = tyh; - var tx2 = txw; - var ty2 = tyh; - var tx3 = txw; - var ty3 = ty; - var tint = Utils.getTintAppendFloatAlpha(0xffffff, this.alpha * tile.alpha); - - vertexViewF32[voffset + 0] = tx0; - vertexViewF32[voffset + 1] = ty0; - vertexViewF32[voffset + 2] = u0; - vertexViewF32[voffset + 3] = v0; - vertexViewU32[voffset + 4] = tint; - vertexViewF32[voffset + 5] = tx1; - vertexViewF32[voffset + 6] = ty1; - vertexViewF32[voffset + 7] = u0; - vertexViewF32[voffset + 8] = v1; - vertexViewU32[voffset + 9] = tint; - vertexViewF32[voffset + 10] = tx2; - vertexViewF32[voffset + 11] = ty2; - vertexViewF32[voffset + 12] = u1; - vertexViewF32[voffset + 13] = v1; - vertexViewU32[voffset + 14] = tint; - vertexViewF32[voffset + 15] = tx0; - vertexViewF32[voffset + 16] = ty0; - vertexViewF32[voffset + 17] = u0; - vertexViewF32[voffset + 18] = v0; - vertexViewU32[voffset + 19] = tint; - vertexViewF32[voffset + 20] = tx2; - vertexViewF32[voffset + 21] = ty2; - vertexViewF32[voffset + 22] = u1; - vertexViewF32[voffset + 23] = v1; - vertexViewU32[voffset + 24] = tint; - vertexViewF32[voffset + 25] = tx3; - vertexViewF32[voffset + 26] = ty3; - vertexViewF32[voffset + 27] = u1; - vertexViewF32[voffset + 28] = v0; - vertexViewU32[voffset + 29] = tint; - - voffset += 30; - vertexCount += 6; - } - } - - this.vertexCount = vertexCount; - this.dirty = false; - if (vertexBuffer === null) - { - vertexBuffer = renderer.createVertexBuffer(bufferData, gl.STATIC_DRAW); - this.vertexBuffer = vertexBuffer; - } - else - { - renderer.setVertexBuffer(vertexBuffer); - gl.bufferSubData(gl.ARRAY_BUFFER, 0, bufferData); - } - } - - pipeline.modelIdentity(); - pipeline.modelTranslate(this.x - (camera.scrollX * this.scrollFactorX), this.y - (camera.scrollY * this.scrollFactorY), 0.0); - pipeline.modelScale(this.scaleX, this.scaleY, 1.0); - pipeline.viewLoad2D(camera.matrix.matrix); - } - - return this; - }, - - /** - * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting - * faces are used internally for optimizing collisions against tiles. This method is mostly used - * internally to optimize recalculating faces when only one tile has been changed. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#calculateFacesAt - * @since 3.0.0 - * - * @param {integer} tileX - The x coordinate. - * @param {integer} tileY - The y coordinate. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - calculateFacesAt: function (tileX, tileY) - { - TilemapComponents.CalculateFacesAt(tileX, tileY, this.layer); - - return this; - }, - - /** - * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the - * layer. Interesting faces are used internally for optimizing collisions against tiles. This method - * is mostly used internally. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#calculateFacesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - calculateFacesWithin: function (tileX, tileY, width, height) - { - TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, this.layer); - - return this; - }, - - /** - * Creates a Sprite for every object matching the given tile indexes in the layer. You can - * optionally specify if each tile will be replaced with a new tile after the Sprite has been - * created. This is useful if you want to lay down special tiles in a level that are converted to - * Sprites, but want to replace the tile itself with a floor tile or similar once converted. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#createFromTiles - * @since 3.0.0 - * - * @param {integer|array} indexes - The tile index, or array of indexes, to create Sprites from. - * @param {integer|array} replacements - The tile index, or array of indexes, to change a converted - * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a - * one-to-one mapping with the indexes array. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). - * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY - * - * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. - */ - createFromTiles: function (indexes, replacements, spriteConfig, scene, camera) - { - return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, this.layer); - }, - - /** - * Returns the tiles in the given layer that are within the cameras viewport. - * This is used internally. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#cull - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - cull: function (camera) - { - return TilemapComponents.CullTiles(this.layer, camera, this.culledTiles); - }, - - /** - * Destroys this StaticTilemapLayer and removes its link to the associated LayerData. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#destroy - * @since 3.0.0 - */ - destroy: function () - { - // Uninstall this layer only if it is still installed on the LayerData object - if (this.layer.tilemapLayer === this) - { - this.layer.tilemapLayer = undefined; - } - - this.tilemap = undefined; - this.layer = undefined; - this.tileset = undefined; - - GameObject.prototype.destroy.call(this); - }, - - /** - * Searches the entire map layer for the first tile matching the given index, then returns that Tile - * object. If no match is found, it returns null. The search starts from the top-left tile and - * continues horizontally until it hits the end of the row, then it drops down to the next column. - * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to - * the top-left. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#findByIndex - * @since 3.0.0 - * - * @param {integer} index - The tile index value to search for. - * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. - * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the - * bottom-right. Otherwise it scans from the top-left. - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - findByIndex: function (findIndex, skip, reverse) - { - return TilemapComponents.FindByIndex(findIndex, skip, reverse, this.layer); - }, - - /** - * Find the first tile in the given rectangular area (in tile coordinates) of the layer that - * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns - * true. Similar to Array.prototype.find in vanilla JS. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#findTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.Tile|null} - */ - findTile: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns - * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#filterTiles - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. The callback should return true for tiles that pass the - * filter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * callback. Similar to Array.prototype.forEach in vanilla JS. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#forEachTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - - return this; - }, - - /** - * Gets a tile at the given tile coordinates from the given layer. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#getTileAt - * @since 3.0.0 - * - * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). - * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). - * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile - * object with an index of -1. - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates were invalid. - */ - getTileAt: function (tileX, tileY, nonNull) - { - return TilemapComponents.GetTileAt(tileX, tileY, nonNull, this.layer); - }, - - /** - * Gets a tile at the given world coordinates from the given layer. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#getTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - X position to get the tile from (given in pixels) - * @param {number} worldY - Y position to get the tile from (given in pixels) - * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates - * were invalid. - */ - getTileAtWorldXY: function (worldX, worldY, nonNull, camera) - { - return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, this.layer); - }, - - /** - * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithin: function (tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * Gets the tiles in the given rectangular area (in world coordinates) of the layer. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithinWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera) - { - return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, this.layer); - }, - - /** - * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, - * Line, Rectangle or Triangle. The shape should be in world coordinates. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithinShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle} shape - A shape in world (pixel) coordinates - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithinShape: function (shape, filteringOptions, camera) - { - return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, this.layer); - }, - - /** - * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#hasTileAt - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * - * @return {boolean} - */ - hasTileAt: function (tileX, tileY) - { - return TilemapComponents.HasTileAt(tileX, tileY, this.layer); - }, - - /** - * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#hasTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {boolean} - */ - hasTileAtWorldXY: function (worldX, worldY, camera) - { - return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, this.layer); - }, - - /** - * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to - * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles - * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation - * wherever you want on the screen. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#renderDebug - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. - * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. - * @param {Color|null} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at - * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. - * @param {Color|null} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled - * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. - * @param {Color|null} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting - * tile faces. If set to null, interesting tile faces will not be drawn. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - renderDebug: function (graphics, styleConfig) - { - TilemapComponents.RenderDebug(graphics, styleConfig, this.layer); - - return this; - }, - - /** - * Sets collision on the given tile or tiles within a layer by index. You can pass in either a - * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if - * collision will be enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setCollision - * @since 3.0.0 - * - * @param {integer|array} indexes - Either a single tile index, or an array of tile indexes. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setCollision: function (indexes, collides, recalculateFaces) - { - TilemapComponents.SetCollision(indexes, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on a range of tiles in a layer whose index is between the specified `start` and - * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set - * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be - * enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionBetween - * @since 3.0.0 - * - * @param {integer} start - The first index of the tile to be set for collision. - * @param {integer} stop - The last index of the tile to be set for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setCollisionBetween: function (start, stop, collides, recalculateFaces) - { - TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property - * that matches the given properties object, its collision flag will be set. The `collides` - * parameter controls if collision will be enabled (true) or disabled (false). Passing in - * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that - * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can - * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a - * "types" property that matches any of those values, its collision flag will be updated. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionByProperty - * @since 3.0.0 - * - * @param {object} properties - An object with tile properties and corresponding values that should - * be checked. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setCollisionByProperty: function (properties, collides, recalculateFaces) - { - TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on all tiles in the given layer, except for tiles that have an index specified in - * the given array. The `collides` parameter controls if collision will be enabled (true) or - * disabled (false). - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionByExclusion - * @since 3.0.0 - * - * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setCollisionByExclusion: function (indexes, collides, recalculateFaces) - { - TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets a global collision callback for the given tile index within the layer. This will affect all - * tiles on this layer that have the same index. If a callback is already set for the tile index it - * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile - * at a specific location on the map then see setTileLocationCallback. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setTileIndexCallback - * @since 3.0.0 - * - * @param {integer|array} indexes - Either a single tile index, or an array of tile indexes to have a - * collision callback set for. - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setTileIndexCallback: function (indexes, callback, callbackContext) - { - TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, this.layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking each tiles collision group data - * (typically defined in Tiled within the tileset collision editor). If any objects are found within - * a tiles collision group, the tile's colliding information will be set. The `collides` parameter - * controls if collision will be enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionFromCollisionGroup - * @since 3.0.0 - * - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setCollisionFromCollisionGroup: function (collides, recalculateFaces) - { - TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. - * If a callback is already set for the tile index it will be replaced. Set the callback to null to - * remove it. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setTileLocationCallback - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext) - { - TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, this.layer); - - return this; - }, - - /** - * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldX - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - tileToWorldX: function (tileX, camera) - { - return TilemapComponents.TileToWorldX(tileX, camera, this.layer); - }, - - /** - * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldY - * @since 3.0.0 - * - * @param {integer} tileY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - tileToWorldY: function (tileY, camera) - { - return TilemapComponents.TileToWorldY(tileY, camera, this.layer); - }, - - /** - * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldXY - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Math.Vector2} - */ - tileToWorldXY: function (tileX, tileY, point, camera) - { - return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, this.layer); - }, - - /** - * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileX - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - worldToTileX: function (worldX, snapToFloor, camera) - { - return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, this.layer); - }, - - /** - * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileXY - * @since 3.0.0 - * - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - worldToTileY: function (worldY, snapToFloor, camera) - { - return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, this.layer); - }, - - /** - * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Math.Vector2} - */ - worldToTileXY: function (worldX, worldY, snapToFloor, point, camera) - { - return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, this.layer); - } - -}); - -module.exports = StaticTilemapLayer; +module.exports = TopLeft; /***/ }), @@ -73948,297 +76566,36 @@ module.exports = StaticTilemapLayer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(2); +var GetCenterX = __webpack_require__(61); +var GetTop = __webpack_require__(30); +var SetCenterX = __webpack_require__(60); +var SetTop = __webpack_require__(29); /** - * @classdesc - * [description] + * Takes given Game Object and aligns it so that it is positioned in the top center of the other. * - * @class TimerEvent - * @memberOf Phaser.Time - * @constructor + * @function Phaser.Display.Align.In.TopCenter * @since 3.0.0 * - * @param {object} config - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. */ -var TimerEvent = new Class({ +var TopCenter = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } - initialize: + SetCenterX(gameObject, GetCenterX(alignIn) + offsetX); + SetTop(gameObject, GetTop(alignIn) - offsetY); - function TimerEvent (config) - { - /** - * The delay in ms at which this TimerEvent fires. - * - * @name Phaser.Time.TimerEvent#delay - * @type {number} - * @default 0 - * @readOnly - * @since 3.0.0 - */ - this.delay = 0; + return gameObject; +}; - /** - * The total number of times this TimerEvent will repeat before finishing. - * - * @name Phaser.Time.TimerEvent#repeat - * @type {number} - * @default 0 - * @readOnly - * @since 3.0.0 - */ - this.repeat = 0; - - /** - * If repeating this contains the current repeat count. - * - * @name Phaser.Time.TimerEvent#repeatCount - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.repeatCount = 0; - - /** - * True if this TimerEvent loops, otherwise false. - * - * @name Phaser.Time.TimerEvent#loop - * @type {boolean} - * @default false - * @readOnly - * @since 3.0.0 - */ - this.loop = false; - - /** - * The callback that will be called when the TimerEvent occurs. - * - * @name Phaser.Time.TimerEvent#callback - * @type {function} - * @since 3.0.0 - */ - this.callback; - - /** - * The scope in which the callback will be called. - * - * @name Phaser.Time.TimerEvent#callbackScope - * @type {object} - * @since 3.0.0 - */ - this.callbackScope; - - /** - * Additional arguments to be passed to the callback. - * - * @name Phaser.Time.TimerEvent#args - * @type {array} - * @since 3.0.0 - */ - this.args; - - /** - * Scale the time causing this TimerEvent to update. - * - * @name Phaser.Time.TimerEvent#timeScale - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * Start this many MS into the elapsed (useful if you want a long duration with repeat, but for the first loop to fire quickly) - * - * @name Phaser.Time.TimerEvent#startAt - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.startAt = 0; - - /** - * [description] - * - * @name Phaser.Time.TimerEvent#elapsed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.elapsed = 0; - - /** - * [description] - * - * @name Phaser.Time.TimerEvent#paused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.paused = false; - - /** - * [description] - * - * @name Phaser.Time.TimerEvent#hasDispatched - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.hasDispatched = false; - - this.reset(config); - }, - - /** - * [description] - * - * @method Phaser.Time.TimerEvent#reset - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.Time.TimerEvent} This TimerEvent object. - */ - reset: function (config) - { - this.delay = GetFastValue(config, 'delay', 0); - - // Can also be set to -1 for an infinite loop (same as setting loop: true) - this.repeat = GetFastValue(config, 'repeat', 0); - - this.loop = GetFastValue(config, 'loop', false); - - this.callback = GetFastValue(config, 'callback', undefined); - - this.callbackScope = GetFastValue(config, 'callbackScope', this.callback); - - this.args = GetFastValue(config, 'args', []); - - this.timeScale = GetFastValue(config, 'timeScale', 1); - - this.startAt = GetFastValue(config, 'startAt', 0); - - this.paused = GetFastValue(config, 'paused', false); - - this.elapsed = this.startAt; - this.hasDispatched = false; - this.repeatCount = (this.repeat === -1 || this.loop) ? 999999999999 : this.repeat; - - return this; - }, - - /** - * Gets the progress of the current iteration, not factoring in repeats. - * - * @method Phaser.Time.TimerEvent#getProgress - * @since 3.0.0 - * - * @return {number} [description] - */ - getProgress: function () - { - return (this.elapsed / this.delay); - }, - - /** - * Gets the progress of the timer overall, factoring in repeats. - * - * @method Phaser.Time.TimerEvent#getOverallProgress - * @since 3.0.0 - * - * @return {number} [description] - */ - getOverallProgress: function () - { - if (this.repeat > 0) - { - var totalDuration = this.delay + (this.delay * this.repeat); - var totalElapsed = this.elapsed + (this.delay * (this.repeat - this.repeatCount)); - - return (totalElapsed / totalDuration); - } - else - { - return this.getProgress(); - } - }, - - /** - * [description] - * - * @method Phaser.Time.TimerEvent#getRepeatCount - * @since 3.0.0 - * - * @return {number} [description] - */ - getRepeatCount: function () - { - return this.repeatCount; - }, - - /** - * [description] - * - * @method Phaser.Time.TimerEvent#getElapsed - * @since 3.0.0 - * - * @return {number} [description] - */ - getElapsed: function () - { - return this.elapsed; - }, - - /** - * [description] - * - * @method Phaser.Time.TimerEvent#getElapsedSeconds - * @since 3.0.0 - * - * @return {number} [description] - */ - getElapsedSeconds: function () - { - return this.elapsed * 0.001; - }, - - /** - * [description] - * - * @method Phaser.Time.TimerEvent#remove - * @since 3.0.0 - * - * @param {function} dispatchCallback - [description] - */ - remove: function (dispatchCallback) - { - if (dispatchCallback === undefined) { dispatchCallback = false; } - - this.elapsed = this.delay; - - this.hasDispatched = !dispatchCallback; - - this.repeatCount = 0; - }, - - /** - * [description] - * - * @method Phaser.Time.TimerEvent#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.callback = undefined; - this.callbackScope = undefined; - this.args = []; - } - -}); - -module.exports = TimerEvent; +module.exports = TopCenter; /***/ }), @@ -74251,52 +76608,36 @@ module.exports = TimerEvent; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RESERVED = __webpack_require__(926); +var GetCenterY = __webpack_require__(58); +var GetRight = __webpack_require__(32); +var SetCenterY = __webpack_require__(59); +var SetRight = __webpack_require__(31); /** - * [description] + * Takes given Game Object and aligns it so that it is positioned in the right center of the other. * - * @function Phaser.Tweens.Builders.GetProps + * @function Phaser.Display.Align.In.RightCenter * @since 3.0.0 * - * @param {object} config - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. * - * @return {array} [description] + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. */ -var GetProps = function (config) +var RightCenter = function (gameObject, alignIn, offsetX, offsetY) { - var key; - var keys = []; + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } - // First see if we have a props object + SetRight(gameObject, GetRight(alignIn) + offsetX); + SetCenterY(gameObject, GetCenterY(alignIn) + offsetY); - if (config.hasOwnProperty('props')) - { - for (key in config.props) - { - // Skip any property that starts with an underscore - if (key.substr(0, 1) !== '_') - { - keys.push({ key: key, value: config.props[key] }); - } - } - } - else - { - for (key in config) - { - // Skip any property that is in the ReservedProps list or that starts with an underscore - if (RESERVED.indexOf(key) === -1 && key.substr(0, 1) !== '_') - { - keys.push({ key: key, value: config[key] }); - } - } - } - - return keys; + return gameObject; }; -module.exports = GetProps; +module.exports = RightCenter; /***/ }), @@ -74309,40 +76650,36 @@ module.exports = GetProps; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetValue = __webpack_require__(4); +var GetCenterY = __webpack_require__(58); +var GetLeft = __webpack_require__(34); +var SetCenterY = __webpack_require__(59); +var SetLeft = __webpack_require__(33); /** - * [description] + * Takes given Game Object and aligns it so that it is positioned in the left center of the other. * - * @function Phaser.Tweens.Builders.GetTweens + * @function Phaser.Display.Align.In.LeftCenter * @since 3.0.0 * - * @param {object} config - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. * - * @return {array} [description] + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. */ -var GetTweens = function (config) +var LeftCenter = function (gameObject, alignIn, offsetX, offsetY) { - var tweens = GetValue(config, 'tweens', null); + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } - if (tweens === null) - { - return []; - } - else if (typeof tweens === 'function') - { - tweens = tweens.call(); - } + SetLeft(gameObject, GetLeft(alignIn) - offsetX); + SetCenterY(gameObject, GetCenterY(alignIn) + offsetY); - if (!Array.isArray(tweens)) - { - tweens = [ tweens ]; - } - - return tweens; + return gameObject; }; -module.exports = GetTweens; +module.exports = LeftCenter; /***/ }), @@ -74355,122 +76692,29 @@ module.exports = GetTweens; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Defaults = __webpack_require__(160); -var GetAdvancedValue = __webpack_require__(10); -var GetBoolean = __webpack_require__(73); -var GetEaseFunction = __webpack_require__(71); -var GetNewValue = __webpack_require__(101); -var GetValue = __webpack_require__(4); -var GetValueOp = __webpack_require__(159); -var Tween = __webpack_require__(161); -var TweenData = __webpack_require__(162); +var SetCenterX = __webpack_require__(60); +var SetCenterY = __webpack_require__(59); /** - * [description] + * Positions the Game Object so that it is centered on the given coordinates. * - * @function Phaser.Tweens.Builders.NumberTweenBuilder + * @function Phaser.Display.Bounds.CenterOn * @since 3.0.0 * - * @param {Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline} parent - [description] - * @param {object} config - [description] - * @param {Phaser.Tweens.Tween~ConfigDefaults} defaults - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} x - The horizontal coordinate to position the Game Object on. + * @param {number} y - The vertical coordinate to position the Game Object on. * - * @return {Phaser.Tweens.Tween} [description] + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. */ -var NumberTweenBuilder = function (parent, config, defaults) +var CenterOn = function (gameObject, x, y) { - if (defaults === undefined) - { - defaults = Defaults; - } + SetCenterX(gameObject, x); - // var tween = this.tweens.addCounter({ - // from: 100, - // to: 200, - // ... (normal tween properties) - // }) - // - // Then use it in your game via: - // - // tween.getValue() - - var from = GetValue(config, 'from', 0); - var to = GetValue(config, 'to', 1); - - var targets = [ { value: from } ]; - - var delay = GetNewValue(config, 'delay', defaults.delay); - var duration = GetNewValue(config, 'duration', defaults.duration); - var easeParams = GetValue(config, 'easeParams', defaults.easeParams); - var ease = GetEaseFunction(GetValue(config, 'ease', defaults.ease), easeParams); - var hold = GetNewValue(config, 'hold', defaults.hold); - var repeat = GetNewValue(config, 'repeat', defaults.repeat); - var repeatDelay = GetNewValue(config, 'repeatDelay', defaults.repeatDelay); - var yoyo = GetBoolean(config, 'yoyo', defaults.yoyo); - - var data = []; - - var ops = GetValueOp('value', to); - - var tweenData = TweenData( - targets[0], - 'value', - ops.getEnd, - ops.getStart, - ease, - delay, - duration, - yoyo, - hold, - repeat, - repeatDelay, - false, - false - ); - - tweenData.start = from; - tweenData.current = from; - tweenData.to = to; - - data.push(tweenData); - - var tween = new Tween(parent, data, targets); - - tween.offset = GetAdvancedValue(config, 'offset', null); - tween.completeDelay = GetAdvancedValue(config, 'completeDelay', 0); - tween.loop = Math.round(GetAdvancedValue(config, 'loop', 0)); - tween.loopDelay = Math.round(GetAdvancedValue(config, 'loopDelay', 0)); - tween.paused = GetBoolean(config, 'paused', false); - tween.useFrames = GetBoolean(config, 'useFrames', false); - - // Set the Callbacks - var scope = GetValue(config, 'callbackScope', tween); - - // Callback parameters: 0 = a reference to the Tween itself, 1 = the target/s of the Tween, ... your own params - var tweenArray = [ tween, null ]; - - var callbacks = Tween.TYPES; - - for (var i = 0; i < callbacks.length; i++) - { - var type = callbacks[i]; - - var callback = GetValue(config, type, false); - - if (callback) - { - var callbackScope = GetValue(config, type + 'Scope', scope); - var callbackParams = GetValue(config, type + 'Params', []); - - // The null is reset to be the Tween target - tween.setCallback(type, callback, tweenArray.concat(callbackParams), callbackScope); - } - } - - return tween; + return SetCenterY(gameObject, y); }; -module.exports = NumberTweenBuilder; +module.exports = CenterOn; /***/ }), @@ -74483,146 +76727,34 @@ module.exports = NumberTweenBuilder; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Clone = __webpack_require__(53); -var Defaults = __webpack_require__(160); -var GetAdvancedValue = __webpack_require__(10); -var GetBoolean = __webpack_require__(73); -var GetEaseFunction = __webpack_require__(71); -var GetNewValue = __webpack_require__(101); -var GetTargets = __webpack_require__(158); -var GetTweens = __webpack_require__(360); -var GetValue = __webpack_require__(4); -var Timeline = __webpack_require__(363); -var TweenBuilder = __webpack_require__(102); +var CenterOn = __webpack_require__(361); +var GetCenterX = __webpack_require__(61); +var GetCenterY = __webpack_require__(58); /** - * [description] + * Takes given Game Object and aligns it so that it is positioned in the center of the other. * - * @function Phaser.Tweens.Builders.TimelineBuilder + * @function Phaser.Display.Align.In.Center * @since 3.0.0 * - * @param {Phaser.Tweens.TweenManager} manager - [description] - * @param {object} config - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. * - * @return {Phaser.Tweens.Timeline} [description] + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. */ -var TimelineBuilder = function (manager, config) +var Center = function (gameObject, alignIn, offsetX, offsetY) { - var timeline = new Timeline(manager); + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } - var tweens = GetTweens(config); + CenterOn(gameObject, GetCenterX(alignIn) + offsetX, GetCenterY(alignIn) + offsetY); - if (tweens.length === 0) - { - timeline.paused = true; - - return timeline; - } - - var defaults = Clone(Defaults); - - defaults.targets = GetTargets(config); - - // totalDuration: If specified each tween in the Timeline is given an equal portion of the totalDuration - - var totalDuration = GetAdvancedValue(config, 'totalDuration', 0); - - if (totalDuration > 0) - { - defaults.duration = Math.floor(totalDuration / tweens.length); - } - else - { - defaults.duration = GetNewValue(config, 'duration', defaults.duration); - } - - defaults.delay = GetNewValue(config, 'delay', defaults.delay); - defaults.easeParams = GetValue(config, 'easeParams', defaults.easeParams); - defaults.ease = GetEaseFunction(GetValue(config, 'ease', defaults.ease), defaults.easeParams); - defaults.hold = GetNewValue(config, 'hold', defaults.hold); - defaults.repeat = GetNewValue(config, 'repeat', defaults.repeat); - defaults.repeatDelay = GetNewValue(config, 'repeatDelay', defaults.repeatDelay); - defaults.yoyo = GetBoolean(config, 'yoyo', defaults.yoyo); - defaults.flipX = GetBoolean(config, 'flipX', defaults.flipX); - defaults.flipY = GetBoolean(config, 'flipY', defaults.flipY); - - // Create the Tweens - for (var i = 0; i < tweens.length; i++) - { - timeline.queue(TweenBuilder(timeline, tweens[i], defaults)); - } - - timeline.completeDelay = GetAdvancedValue(config, 'completeDelay', 0); - timeline.loop = Math.round(GetAdvancedValue(config, 'loop', 0)); - timeline.loopDelay = Math.round(GetAdvancedValue(config, 'loopDelay', 0)); - timeline.paused = GetBoolean(config, 'paused', false); - timeline.useFrames = GetBoolean(config, 'useFrames', false); - - // Callbacks - - var scope = GetValue(config, 'callbackScope', timeline); - - var timelineArray = [ timeline ]; - - var onStart = GetValue(config, 'onStart', false); - - // The Start of the Timeline - if (onStart) - { - var onStartScope = GetValue(config, 'onStartScope', scope); - var onStartParams = GetValue(config, 'onStartParams', []); - - timeline.setCallback('onStart', onStart, timelineArray.concat(onStartParams), onStartScope); - } - - var onUpdate = GetValue(config, 'onUpdate', false); - - // Every time the Timeline updates (regardless which Tweens are running) - if (onUpdate) - { - var onUpdateScope = GetValue(config, 'onUpdateScope', scope); - var onUpdateParams = GetValue(config, 'onUpdateParams', []); - - timeline.setCallback('onUpdate', onUpdate, timelineArray.concat(onUpdateParams), onUpdateScope); - } - - var onLoop = GetValue(config, 'onLoop', false); - - // Called when the whole Timeline loops - if (onLoop) - { - var onLoopScope = GetValue(config, 'onLoopScope', scope); - var onLoopParams = GetValue(config, 'onLoopParams', []); - - timeline.setCallback('onLoop', onLoop, timelineArray.concat(onLoopParams), onLoopScope); - } - - var onYoyo = GetValue(config, 'onYoyo', false); - - // Called when a Timeline yoyos - if (onYoyo) - { - var onYoyoScope = GetValue(config, 'onYoyoScope', scope); - var onYoyoParams = GetValue(config, 'onYoyoParams', []); - - timeline.setCallback('onYoyo', onYoyo, timelineArray.concat(null, onYoyoParams), onYoyoScope); - } - - var onComplete = GetValue(config, 'onComplete', false); - - // Called when the Timeline completes, after the completeDelay, etc. - if (onComplete) - { - var onCompleteScope = GetValue(config, 'onCompleteScope', scope); - var onCompleteParams = GetValue(config, 'onCompleteParams', []); - - timeline.setCallback('onComplete', onComplete, timelineArray.concat(onCompleteParams), onCompleteScope); - } - - return timeline; + return gameObject; }; -module.exports = TimelineBuilder; +module.exports = Center; /***/ }), @@ -74635,853 +76767,41 @@ module.exports = TimelineBuilder; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(14); -var TweenBuilder = __webpack_require__(102); -var TWEEN_CONST = __webpack_require__(87); +var GetBottom = __webpack_require__(36); +var GetRight = __webpack_require__(32); +var SetBottom = __webpack_require__(35); +var SetRight = __webpack_require__(31); /** - * @classdesc - * [description] + * Takes given Game Object and aligns it so that it is positioned in the bottom right of the other. * - * @class Timeline - * @memberOf Phaser.Tweens - * @extends EventEmitter - * @constructor + * @function Phaser.Display.Align.In.BottomRight * @since 3.0.0 * - * @param {Phaser.Tweens.TweenManager} manager - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. */ -var Timeline = new Class({ +var BottomRight = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } - Extends: EventEmitter, + SetRight(gameObject, GetRight(alignIn) + offsetX); + SetBottom(gameObject, GetBottom(alignIn) + offsetY); - initialize: + return gameObject; +}; - function Timeline (manager) - { - EventEmitter.call(this); - - /** - * [description] - * - * @name Phaser.Tweens.Timeline#manager - * @type {Phaser.Tweens.TweenManager} - * @since 3.0.0 - */ - this.manager = manager; - - /** - * [description] - * - * @name Phaser.Tweens.Timeline#isTimeline - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.isTimeline = true; - - /** - * An array of Tween objects, each containing a unique property and target being tweened. - * - * @name Phaser.Tweens.Timeline#data - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.data = []; - - /** - * data array doesn't usually change, so we can cache the length - * - * @name Phaser.Tweens.Timeline#totalData - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalData = 0; - - /** - * If true then duration, delay, etc values are all frame totals. - * - * @name Phaser.Tweens.Timeline#useFrames - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.useFrames = false; - - /** - * Scales the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. - * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. - * - * @name Phaser.Tweens.Timeline#timeScale - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * Loop this tween? Can be -1 for an infinite loop, or an integer. - * When enabled it will play through ALL TweenDatas again (use TweenData.repeat to loop a single TD) - * - * @name Phaser.Tweens.Timeline#loop - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loop = 0; - - /** - * Time in ms/frames before the tween loops. - * - * @name Phaser.Tweens.Timeline#loopDelay - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loopDelay = 0; - - /** - * How many loops are left to run? - * - * @name Phaser.Tweens.Timeline#loopCounter - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loopCounter = 0; - - /** - * Time in ms/frames before the 'onComplete' event fires. This never fires if loop = true (as it never completes) - * - * @name Phaser.Tweens.Timeline#completeDelay - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.completeDelay = 0; - - /** - * Countdown timer (used by loopDelay and completeDelay) - * - * @name Phaser.Tweens.Timeline#countdown - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.countdown = 0; - - /** - * The current state of the tween - * - * @name Phaser.Tweens.Timeline#state - * @type {integer} - * @since 3.0.0 - */ - this.state = TWEEN_CONST.PENDING_ADD; - - /** - * The state of the tween when it was paused (used by Resume) - * - * @name Phaser.Tweens.Timeline#_pausedState - * @type {integer} - * @private - * @since 3.0.0 - */ - this._pausedState = TWEEN_CONST.PENDING_ADD; - - /** - * Does the Tween start off paused? (if so it needs to be started with Tween.play) - * - * @name Phaser.Tweens.Timeline#paused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.paused = false; - - /** - * Elapsed time in ms/frames of this run through the Tween. - * - * @name Phaser.Tweens.Timeline#elapsed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.elapsed = 0; - - /** - * Total elapsed time in ms/frames of the entire Tween, including looping. - * - * @name Phaser.Tweens.Timeline#totalElapsed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalElapsed = 0; - - /** - * Time in ms/frames for the whole Tween to play through once, excluding loop amounts and loop delays. - * - * @name Phaser.Tweens.Timeline#duration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.duration = 0; - - /** - * Value between 0 and 1. The amount through the Tween, excluding loops. - * - * @name Phaser.Tweens.Timeline#progress - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.progress = 0; - - /** - * Time in ms/frames for all Tweens to complete (including looping) - * - * @name Phaser.Tweens.Timeline#totalDuration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalDuration = 0; - - /** - * Value between 0 and 1. The amount through the entire Tween, including looping. - * - * @name Phaser.Tweens.Timeline#totalProgress - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalProgress = 0; - - this.callbacks = { - onComplete: null, - onLoop: null, - onStart: null, - onUpdate: null, - onYoyo: null - }; - - this.callbackScope; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#setTimeScale - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Tweens.Timeline} This Timeline object. - */ - setTimeScale: function (value) - { - this.timeScale = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#getTimeScale - * @since 3.0.0 - * - * @return {number} [description] - */ - getTimeScale: function () - { - return this.timeScale; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#isPlaying - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isPlaying: function () - { - return (this.state === TWEEN_CONST.ACTIVE); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#add - * @since 3.0.0 - * - * @param {[type]} config - [description] - * - * @return {Phaser.Tweens.Timeline} This Timeline object. - */ - add: function (config) - { - return this.queue(TweenBuilder(this, config)); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#queue - * @since 3.0.0 - * - * @param {[type]} tween - [description] - * - * @return {Phaser.Tweens.Timeline} This Timeline object. - */ - queue: function (tween) - { - if (!this.isPlaying()) - { - tween.parent = this; - tween.parentIsTimeline = true; - - this.data.push(tween); - - this.totalData = this.data.length; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#hasOffset - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * - * @return {boolean} [description] - */ - hasOffset: function (tween) - { - return (tween.offset !== null); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#isOffsetAbsolute - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {boolean} [description] - */ - isOffsetAbsolute: function (value) - { - return (typeof(value) === 'number'); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#isOffsetRelative - * @since 3.0.0 - * - * @param {string} value - [description] - * - * @return {boolean} [description] - */ - isOffsetRelative: function (value) - { - var t = typeof(value); - - if (t === 'string') - { - var op = value[0]; - - if (op === '-' || op === '+') - { - return true; - } - } - - return false; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#getRelativeOffset - * @since 3.0.0 - * - * @param {string} value - [description] - * @param {number} base - [description] - * - * @return {number} [description] - */ - getRelativeOffset: function (value, base) - { - var op = value[0]; - var num = parseFloat(value.substr(2)); - var result = base; - - switch (op) - { - case '+': - result += num; - break; - - case '-': - result -= num; - break; - } - - // Cannot ever be < 0 - return Math.max(0, result); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#calcDuration - * @since 3.0.0 - */ - calcDuration: function () - { - var prevEnd = 0; - var totalDuration = 0; - var offsetDuration = 0; - - for (var i = 0; i < this.totalData; i++) - { - var tween = this.data[i]; - - tween.init(); - - if (this.hasOffset(tween)) - { - if (this.isOffsetAbsolute(tween.offset)) - { - // An actual number, so it defines the start point from the beginning of the timeline - tween.calculatedOffset = tween.offset; - - if (tween.offset === 0) - { - offsetDuration = 0; - } - } - else if (this.isOffsetRelative(tween.offset)) - { - // A relative offset (i.e. '-=1000', so starts at 'offset' ms relative to the PREVIOUS Tweens ending time) - tween.calculatedOffset = this.getRelativeOffset(tween.offset, prevEnd); - } - } - else - { - // Sequential - tween.calculatedOffset = offsetDuration; - } - - prevEnd = tween.totalDuration + tween.calculatedOffset; - - totalDuration += tween.totalDuration; - offsetDuration += tween.totalDuration; - } - - // Excludes loop values - this.duration = totalDuration; - - this.loopCounter = (this.loop === -1) ? 999999999999 : this.loop; - - if (this.loopCounter > 0) - { - this.totalDuration = this.duration + this.completeDelay + ((this.duration + this.loopDelay) * this.loopCounter); - } - else - { - this.totalDuration = this.duration + this.completeDelay; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#init - * @since 3.0.0 - * - * @return {boolean} [description] - */ - init: function () - { - this.calcDuration(); - - this.progress = 0; - this.totalProgress = 0; - - if (this.paused) - { - this.state = TWEEN_CONST.PAUSED; - - return false; - } - else - { - return true; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#resetTweens - * @since 3.0.0 - * - * @param {boolean} resetFromLoop - [description] - */ - resetTweens: function (resetFromLoop) - { - for (var i = 0; i < this.totalData; i++) - { - var tween = this.data[i]; - - tween.play(resetFromLoop); - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#setCallback - * @since 3.0.0 - * - * @param {string} type - [description] - * @param {function} callback - [description] - * @param {array} [params] - [description] - * @param {object} [scope] - [description] - * - * @return {Phaser.Tweens.Timeline} This Timeline object. - */ - setCallback: function (type, callback, params, scope) - { - if (Timeline.TYPES.indexOf(type) !== -1) - { - this.callbacks[type] = { func: callback, scope: scope, params: params }; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#play - * @since 3.0.0 - */ - play: function () - { - if (this.state === TWEEN_CONST.ACTIVE) - { - return; - } - - if (this.paused) - { - this.paused = false; - - this.manager.makeActive(this); - - return; - } - else - { - this.resetTweens(false); - - this.state = TWEEN_CONST.ACTIVE; - } - - var onStart = this.callbacks.onStart; - - if (onStart) - { - onStart.func.apply(onStart.scope, onStart.params); - } - - this.emit('start', this); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#nextState - * @since 3.0.0 - */ - nextState: function () - { - if (this.loopCounter > 0) - { - // Reset the elapsed time - // TODO: Probably ought to be set to the remainder from elapsed - duration - // as the tweens nearly always over-run by a few ms due to rAf - - this.elapsed = 0; - this.progress = 0; - - this.loopCounter--; - - var onLoop = this.callbacks.onLoop; - - if (onLoop) - { - onLoop.func.apply(onLoop.scope, onLoop.params); - } - - this.emit('loop', this, this.loopCounter); - - this.resetTweens(true); - - if (this.loopDelay > 0) - { - this.countdown = this.loopDelay; - this.state = TWEEN_CONST.LOOP_DELAY; - } - else - { - this.state = TWEEN_CONST.ACTIVE; - } - } - else if (this.completeDelay > 0) - { - this.countdown = this.completeDelay; - this.state = TWEEN_CONST.COMPLETE_DELAY; - } - else - { - var onComplete = this.callbacks.onComplete; - - if (onComplete) - { - onComplete.func.apply(onComplete.scope, onComplete.params); - } - - this.emit('complete', this); - - this.state = TWEEN_CONST.PENDING_REMOVE; - } - }, - - /** - * Returns 'true' if this Timeline has finished and should be removed from the Tween Manager. - * Otherwise, returns false. - * - * @method Phaser.Tweens.Timeline#update - * @since 3.0.0 - * - * @param {number} timestamp - [description] - * @param {number} delta - [description] - * - * @return {boolean} Returns `true` if this Timeline has finished and should be removed from the Tween Manager. - */ - update: function (timestamp, delta) - { - if (this.state === TWEEN_CONST.PAUSED) - { - return; - } - - var rawDelta = delta; - - if (this.useFrames) - { - delta = 1 * this.manager.timeScale; - } - - delta *= this.timeScale; - - this.elapsed += delta; - this.progress = Math.min(this.elapsed / this.duration, 1); - - this.totalElapsed += delta; - this.totalProgress = Math.min(this.totalElapsed / this.totalDuration, 1); - - switch (this.state) - { - case TWEEN_CONST.ACTIVE: - - var stillRunning = this.totalData; - - for (var i = 0; i < this.totalData; i++) - { - var tween = this.data[i]; - - if (tween.update(timestamp, rawDelta)) - { - stillRunning--; - } - } - - var onUpdate = this.callbacks.onUpdate; - - if (onUpdate) - { - onUpdate.func.apply(onUpdate.scope, onUpdate.params); - } - - this.emit('update', this); - - // Anything still running? If not, we're done - if (stillRunning === 0) - { - this.nextState(); - } - - break; - - case TWEEN_CONST.LOOP_DELAY: - - this.countdown -= delta; - - if (this.countdown <= 0) - { - this.state = TWEEN_CONST.ACTIVE; - } - - break; - - case TWEEN_CONST.COMPLETE_DELAY: - - this.countdown -= delta; - - if (this.countdown <= 0) - { - var onComplete = this.callbacks.onComplete; - - if (onComplete) - { - onComplete.func.apply(onComplete.scope, onComplete.params); - } - - this.emit('complete', this); - - this.state = TWEEN_CONST.PENDING_REMOVE; - } - - break; - } - - return (this.state === TWEEN_CONST.PENDING_REMOVE); - }, - - /** - * Stops the Tween immediately, whatever stage of progress it is at and flags it for removal by the TweenManager. - * - * @method Phaser.Tweens.Timeline#stop - * @since 3.0.0 - */ - stop: function () - { - this.state = TWEEN_CONST.PENDING_REMOVE; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#pause - * @since 3.0.0 - * - * @return {Phaser.Tweens.Timeline} This Timeline object. - */ - pause: function () - { - if (this.state === TWEEN_CONST.PAUSED) - { - return; - } - - this.paused = true; - - this._pausedState = this.state; - - this.state = TWEEN_CONST.PAUSED; - - this.emit('pause', this); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#resume - * @since 3.0.0 - * - * @return {Phaser.Tweens.Timeline} This Timeline object. - */ - resume: function () - { - if (this.state === TWEEN_CONST.PAUSED) - { - this.paused = false; - - this.state = this._pausedState; - } - - this.emit('resume', this); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#hasTarget - * @since 3.0.0 - * - * @param {object} target - [description] - * - * @return {boolean} [description] - */ - hasTarget: function (target) - { - for (var i = 0; i < this.data.length; i++) - { - if (this.data[i].hasTarget(target)) - { - return true; - } - } - - return false; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#destroy - * @since 3.0.0 - */ - destroy: function () - { - for (var i = 0; i < this.data.length; i++) - { - this.data[i].destroy(); - } - - } -}); - -Timeline.TYPES = [ 'onStart', 'onUpdate', 'onLoop', 'onComplete', 'onYoyo' ]; - -module.exports = Timeline; +module.exports = BottomRight; /***/ }), /* 364 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -75489,41 +76809,36 @@ module.exports = Timeline; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Based on code by Mike Reinstein +var GetBottom = __webpack_require__(36); +var GetLeft = __webpack_require__(34); +var SetBottom = __webpack_require__(35); +var SetLeft = __webpack_require__(33); /** - * Removes a single item from an array and returns it without creating gc (like the native splice does) + * Takes given Game Object and aligns it so that it is positioned in the bottom left of the other. * - * @function Phaser.Utils.Array.SpliceOne + * @function Phaser.Display.Align.In.BottomLeft * @since 3.0.0 * - * @param {array} array - [description] - * @param {integer} index - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. * - * @return {any} [description] + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. */ -var SpliceOne = function (array, index) +var BottomLeft = function (gameObject, alignIn, offsetX, offsetY) { - if (index >= array.length) - { - return; - } + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } - var len = array.length - 1; + SetLeft(gameObject, GetLeft(alignIn) - offsetX); + SetBottom(gameObject, GetBottom(alignIn) + offsetY); - var item = array[index]; - - for (var i = index; i < len; i++) - { - array[i] = array[i + 1]; - } - - array.length = len; - - return item; + return gameObject; }; -module.exports = SpliceOne; +module.exports = BottomLeft; /***/ }), @@ -75536,818 +76851,36 @@ module.exports = SpliceOne; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); +var GetBottom = __webpack_require__(36); +var GetCenterX = __webpack_require__(61); +var SetBottom = __webpack_require__(35); +var SetCenterX = __webpack_require__(60); /** - * @classdesc - * A Game Object Animation Controller. + * Takes given Game Object and aligns it so that it is positioned in the bottom center of the other. * - * This controller lives as an instance within a Game Object, accessible as `sprite.anims`. - * - * @class Animation - * @memberOf Phaser.GameObjects.Components - * @constructor + * @function Phaser.Display.Align.In.BottomCenter * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} parent - The Game Object to which this animation controller belongs. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. */ -var Animation = new Class({ +var BottomCenter = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } - initialize: + SetCenterX(gameObject, GetCenterX(alignIn) + offsetX); + SetBottom(gameObject, GetBottom(alignIn) + offsetY); - function Animation (parent) - { - /** - * The Game Object to which this animation controller belongs. - * - * @name Phaser.GameObjects.Components.Animation#parent - * @type {Phaser.GameObjects.GameObject} - * @since 3.0.0 - */ - this.parent = parent; + return gameObject; +}; - /** - * A reference to the global Animation Manager. - * - * @name Phaser.GameObjects.Components.Animation#animationManager - * @type {Phaser.Animations.AnimationManager} - * @since 3.0.0 - */ - this.animationManager = parent.scene.sys.anims; - - this.animationManager.once('remove', this.remove, this); - - /** - * Is an animation currently playing or not? - * - * @name Phaser.GameObjects.Components.Animation#isPlaying - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isPlaying = false; - - // Reference to the Phaser.Animation object - - /** - * The current Animation loaded into this Animation Controller. - * - * @name Phaser.GameObjects.Components.Animation#currentAnim - * @type {?Phaser.Animations.Animation} - * @default null - * @since 3.0.0 - */ - this.currentAnim = null; - - /** - * The current AnimationFrame being displayed by this Animation Controller. - * - * @name Phaser.GameObjects.Components.Animation#currentFrame - * @type {?Phaser.Animations.AnimationFrame} - * @default null - * @since 3.0.0 - */ - this.currentFrame = null; - - /** - * Time scale factor. - * - * @name Phaser.GameObjects.Components.Animation#_timeScale - * @type {number} - * @private - * @default 1 - * @since 3.0.0 - */ - this._timeScale = 1; - - /** - * The frame rate of playback in frames per second. - * The default is 24 if the `duration` property is `null`. - * - * @name Phaser.GameObjects.Components.Animation#frameRate - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.frameRate = 0; - - /** - * How long the animation should play for. - * If the `frameRate` property has been set then it overrides this value, - * otherwise frameRate is derived from `duration`. - * - * @name Phaser.GameObjects.Components.Animation#duration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.duration = 0; - - /** - * ms per frame, not including frame specific modifiers that may be present in the Animation data. - * - * @name Phaser.GameObjects.Components.Animation#msPerFrame - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.msPerFrame = 0; - - /** - * Skip frames if the time lags, or always advanced anyway? - * - * @name Phaser.GameObjects.Components.Animation#skipMissedFrames - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.skipMissedFrames = true; - - /** - * A delay before starting playback, in seconds. - * - * @name Phaser.GameObjects.Components.Animation#_delay - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._delay = 0; - - /** - * Number of times to repeat the animation (-1 for infinity) - * - * @name Phaser.GameObjects.Components.Animation#_repeat - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._repeat = 0; - - /** - * Delay before the repeat starts, in seconds. - * - * @name Phaser.GameObjects.Components.Animation#_repeatDelay - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._repeatDelay = 0; - - /** - * Should the animation yoyo? (reverse back down to the start) before repeating? - * - * @name Phaser.GameObjects.Components.Animation#_yoyo - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this._yoyo = false; - - /** - * Will the playhead move forwards (`true`) or in reverse (`false`) - * - * @name Phaser.GameObjects.Components.Animation#forward - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.forward = true; - - /** - * Internal time overflow accumulator. - * - * @name Phaser.GameObjects.Components.Animation#accumulator - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.accumulator = 0; - - /** - * The time point at which the next animation frame will change. - * - * @name Phaser.GameObjects.Components.Animation#nextTick - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.nextTick = 0; - - /** - * An internal counter keeping track of how many repeats are left to play. - * - * @name Phaser.GameObjects.Components.Animation#repeatCounter - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.repeatCounter = 0; - - /** - * An internal flag keeping track of pending repeats. - * - * @name Phaser.GameObjects.Components.Animation#pendingRepeat - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.pendingRepeat = false; - - /** - * Is the Animation paused? - * - * @name Phaser.GameObjects.Components.Animation#_paused - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this._paused = false; - - /** - * Was the animation previously playing before being paused? - * - * @name Phaser.GameObjects.Components.Animation#_wasPlaying - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this._wasPlaying = false; - - /** - * Container for the callback arguments. - * - * @name Phaser.GameObjects.Components.Animation#_callbackArgs - * @type {array} - * @private - * @since 3.0.0 - */ - this._callbackArgs = [ parent, null ]; - - /** - * Container for the update arguments. - * - * @name Phaser.GameObjects.Components.Animation#_updateParams - * @type {array} - * @private - * @since 3.0.0 - */ - this._updateParams = []; - }, - - /** - * Sets the amount of time, in seconds that the animation will be delayed before starting playback. - * - * @method Phaser.GameObjects.Components.Animation#delay - * @since 3.0.0 - * - * @param {number} value - The amount of time, in seconds, to wait before starting playback. - * - * @return {Phaser.GameObjects.GameObject} This Game Object. - */ - delay: function (value) - { - if (value === undefined) - { - return this._delay; - } - else - { - this._delay = value; - - return this; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#delayedPlay - * @since 3.0.0 - * - * @param {[type]} delay - [description] - * @param {[type]} key - [description] - * @param {[type]} startFrame - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object. - */ - delayedPlay: function (delay, key, startFrame) - { - this.play(key, true, startFrame); - - this.nextTick += (delay * 1000); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#getCurrentKey - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getCurrentKey: function () - { - if (this.currentAnim) - { - return this.currentAnim.key; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#load - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {integer} [startFrame=0] - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object. - */ - load: function (key, startFrame) - { - if (startFrame === undefined) { startFrame = 0; } - - if (this.isPlaying) - { - this.stop(); - } - - // Load the new animation in - this.animationManager.load(this, key, startFrame); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#pause - * @since 3.0.0 - * - * @param {[type]} atFrame - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object. - */ - pause: function (atFrame) - { - if (!this._paused) - { - this._paused = true; - this._wasPlaying = this.isPlaying; - this.isPlaying = false; - } - - if (atFrame !== undefined) - { - this.updateFrame(atFrame); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#paused - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - paused: function (value) - { - if (value !== undefined) - { - // Setter - if (value) - { - return this.pause(); - } - else - { - return this.resume(); - } - } - else - { - return this._paused; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#play - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {boolean} [ignoreIfPlaying=false] - [description] - * @param {integer} [startFrame=0] - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object. - */ - play: function (key, ignoreIfPlaying, startFrame) - { - if (ignoreIfPlaying === undefined) { ignoreIfPlaying = false; } - if (startFrame === undefined) { startFrame = 0; } - - if (ignoreIfPlaying && this.isPlaying && this.currentAnim.key === key) - { - return this; - } - - this.load(key, startFrame); - - var anim = this.currentAnim; - var gameObject = this.parent; - - // Should give us 9,007,199,254,740,991 safe repeats - this.repeatCounter = (this._repeat === -1) ? Number.MAX_VALUE : this._repeat; - - anim.getFirstTick(this); - - this.forward = true; - this.isPlaying = true; - this.pendingRepeat = false; - - if (anim.showOnStart) - { - gameObject.visible = true; - } - - if (anim.onStart) - { - anim.onStart.apply(anim.callbackScope, this._callbackArgs.concat(anim.onStartParams)); - } - - gameObject.setSizeToFrame(); - gameObject.updateDisplayOrigin(); - - return this; - }, - - // Value between 0 and 1. How far this animation is through, ignoring repeats and yoyos. - // If the animation has a non-zero repeat defined, progress and totalProgress will be different - // because progress doesn't include any repeats or repeatDelays whereas totalProgress does. - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#progress - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - progress: function (value) - { - if (value === undefined) - { - var p = this.currentFrame.progress; - - if (!this.forward) - { - p = 1 - p; - } - - return p; - } - else - { - // TODO: Set progress - - return this; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#remove - * @since 3.0.0 - * - * @param {[type]} event - [description] - */ - remove: function (event) - { - if (event === undefined) { event = this.currentAnim; } - - if (this.isPlaying && event.key === this.currentAnim.key) - { - this.stop(); - - var sprite = this.parent; - var frame = this.currentAnim.frames[0]; - - this.currentFrame = frame; - - sprite.texture = frame.frame.texture; - sprite.frame = frame.frame; - } - }, - - // Gets or sets the number of times that the animation should repeat - // after its first iteration. For example, if repeat is 1, the animation will - // play a total of twice (the initial play plus 1 repeat). - // To repeat indefinitely, use -1. repeat should always be an integer. - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#repeat - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - repeat: function (value) - { - if (value === undefined) - { - return this._repeat; - } - else - { - this._repeat = value; - this.repeatCounter = 0; - - return this; - } - }, - - // Gets or sets the amount of time in seconds between repeats. - // For example, if repeat is 2 and repeatDelay is 1, the animation will play initially, - // then wait for 1 second before it repeats, then play again, then wait 1 second again - // before doing its final repeat. - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#repeatDelay - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - repeatDelay: function (value) - { - if (value === undefined) - { - return this._repeatDelay; - } - else - { - this._repeatDelay = value; - - return this; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#restart - * @since 3.0.0 - * - * @param {[type]} includeDelay - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object. - */ - restart: function (includeDelay) - { - if (includeDelay === undefined) { includeDelay = false; } - - this.currentAnim.getFirstTick(this, includeDelay); - - this.forward = true; - this.isPlaying = true; - this.pendingRepeat = false; - this._paused = false; - - // Set frame - this.updateFrame(this.currentAnim.frames[0]); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#resume - * @since 3.0.0 - * - * @param {[type]} fromFrame - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object. - */ - resume: function (fromFrame) - { - if (this._paused) - { - this._paused = false; - this.isPlaying = this._wasPlaying; - } - - if (fromFrame !== undefined) - { - this.updateFrame(fromFrame); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#stop - * @since 3.0.0 - * - * @param {[type]} dispatchCallbacks - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object. - */ - stop: function (dispatchCallbacks) - { - if (dispatchCallbacks === undefined) { dispatchCallbacks = false; } - - this.isPlaying = false; - - var anim = this.currentAnim; - - if (dispatchCallbacks && anim.onComplete) - { - anim.onComplete.apply(anim.callbackScope, this._callbackArgs.concat(anim.onCompleteParams)); - } - - return this; - }, - - // Scale the time (make it go faster / slower) - // Factor that's used to scale time where 1 = normal speed (the default), 0.5 = half speed, 2 = double speed, etc. - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#timeScale - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - timeScale: function (value) - { - if (value === undefined) - { - return this._timeScale; - } - else - { - this._timeScale = value; - - return this; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#totalFrames - * @since 3.0.0 - * - * @return {[type]} [description] - */ - totalFrames: function () - { - return this.currentAnim.frames.length; - }, - - // Value between 0 and 1. How far this animation is through, including things like delays - // repeats, custom frame durations, etc. If the animation is set to repeat -1 it can never - // have a duration, therefore this will return -1. - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#totalProgres - * @since 3.0.0 - */ - totalProgres: function () - { - // TODO - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#update - * @since 3.0.0 - * - * @param {[type]} timestamp - [description] - * @param {[type]} delta - [description] - */ - update: function (timestamp, delta) - { - if (!this.isPlaying || this.currentAnim.paused) - { - return; - } - - this.accumulator += delta * this._timeScale; - - if (this.accumulator >= this.nextTick) - { - this.currentAnim.setFrame(this); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#updateFrame - * @since 3.0.0 - * - * @param {[type]} animationFrame - [description] - */ - updateFrame: function (animationFrame) - { - var sprite = this.parent; - - this.currentFrame = animationFrame; - - sprite.texture = animationFrame.frame.texture; - sprite.frame = animationFrame.frame; - - if (this.isPlaying) - { - if (animationFrame.setAlpha) - { - sprite.alpha = animationFrame.alpha; - } - - var anim = this.currentAnim; - - if (anim.onUpdate) - { - anim.onUpdate.apply(anim.callbackScope, this._updateParams); - } - - if (animationFrame.onUpdate) - { - animationFrame.onUpdate(sprite, animationFrame); - } - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#yoyo - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - yoyo: function (value) - { - if (value === undefined) - { - return this._yoyo; - } - else - { - this._yoyo = value; - - return this; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.Animation#destroy - * @since 3.0.0 - */ - destroy: function () - { - // TODO - } - -}); - -module.exports = Animation; +module.exports = BottomCenter; /***/ }), @@ -76360,529 +76893,46 @@ module.exports = Animation; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BlitImage = __webpack_require__(367); -var CanvasSnapshot = __webpack_require__(368); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(19); -var DrawImage = __webpack_require__(369); -var GetBlendModes = __webpack_require__(370); -var ScaleModes = __webpack_require__(63); -var Smoothing = __webpack_require__(121); +var ALIGN_CONST = __webpack_require__(169); + +var AlignInMap = []; + +AlignInMap[ALIGN_CONST.BOTTOM_CENTER] = __webpack_require__(365); +AlignInMap[ALIGN_CONST.BOTTOM_LEFT] = __webpack_require__(364); +AlignInMap[ALIGN_CONST.BOTTOM_RIGHT] = __webpack_require__(363); +AlignInMap[ALIGN_CONST.CENTER] = __webpack_require__(362); +AlignInMap[ALIGN_CONST.LEFT_CENTER] = __webpack_require__(360); +AlignInMap[ALIGN_CONST.RIGHT_CENTER] = __webpack_require__(359); +AlignInMap[ALIGN_CONST.TOP_CENTER] = __webpack_require__(358); +AlignInMap[ALIGN_CONST.TOP_LEFT] = __webpack_require__(357); +AlignInMap[ALIGN_CONST.TOP_RIGHT] = __webpack_require__(356); /** - * @classdesc - * [description] + * Takes given Game Object and aligns it so that it is positioned relative to the other. + * The alignment used is based on the `position` argument, which is an `ALIGN_CONST` value, such as `LEFT_CENTER` or `TOP_RIGHT`. * - * @class CanvasRenderer - * @memberOf Phaser.Renderer.Canvas - * @constructor + * @function Phaser.Display.Align.In.QuickSet * @since 3.0.0 * - * @param {Phaser.Game} game - The Phaser Game instance that owns this renderer. + * @param {Phaser.GameObjects.GameObject} child - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {integer} position - The position to align the Game Object with. This is an align constant, such as `ALIGN_CONST.LEFT_CENTER`. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. */ -var CanvasRenderer = new Class({ +var QuickSet = function (child, alignIn, position, offsetX, offsetY) +{ + return AlignInMap[position](child, alignIn, offsetX, offsetY); +}; - initialize: - - function CanvasRenderer (game) - { - /** - * The Phaser Game instance that owns this renderer. - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game = game; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#type - * @type {integer} - * @since 3.0.0 - */ - this.type = CONST.CANVAS; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#drawCount - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.drawCount = 0; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#width - * @type {number} - * @since 3.0.0 - */ - this.width = game.config.width; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#height - * @type {number} - * @since 3.0.0 - */ - this.height = game.config.height; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#config - * @type {object} - * @since 3.0.0 - */ - this.config = { - clearBeforeRender: game.config.clearBeforeRender, - pixelArt: game.config.pixelArt, - backgroundColor: game.config.backgroundColor, - resolution: game.config.resolution, - autoResize: game.config.autoResize, - roundPixels: game.config.roundPixels - }; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#scaleMode - * @type {integer} - * @since 3.0.0 - */ - this.scaleMode = (game.config.pixelArt) ? ScaleModes.NEAREST : ScaleModes.LINEAR; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#gameCanvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.gameCanvas = game.canvas; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#gameContext - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.gameContext = this.gameCanvas.getContext('2d'); - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#currentContext - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.currentContext = this.gameContext; - - /** - * Map to the required function. - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#drawImage - * @type {function} - * @since 3.0.0 - */ - this.drawImage = DrawImage(this.config.roundPixels); - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#blitImage - * @type {function} - * @since 3.0.0 - */ - this.blitImage = BlitImage(this.config.roundPixels); - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#blendModes - * @type {array} - * @since 3.0.0 - */ - this.blendModes = GetBlendModes(); - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#currentAlpha - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.currentAlpha = 1; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#currentBlendMode - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.currentBlendMode = 0; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#currentScaleMode - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.currentScaleMode = 0; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotCallback - * @type {?function} - * @default null - * @since 3.0.0 - */ - this.snapshotCallback = null; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotType - * @type {?[type]} - * @default null - * @since 3.0.0 - */ - this.snapshotType = null; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotEncoder - * @type {?[type]} - * @default null - * @since 3.0.0 - */ - this.snapshotEncoder = null; - - this.init(); - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#init - * @since 3.0.0 - */ - init: function () - { - this.resize(this.width, this.height); - }, - - /** - * Resize the main game canvas. - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#resize - * @since 3.0.0 - * - * @param {integer} width - [description] - * @param {integer} height - [description] - */ - resize: function (width, height) - { - var resolution = this.config.resolution; - - this.width = width * resolution; - this.height = height * resolution; - - this.gameCanvas.width = this.width; - this.gameCanvas.height = this.height; - - if (this.config.autoResize) - { - this.gameCanvas.style.width = (this.width / resolution) + 'px'; - this.gameCanvas.style.height = (this.height / resolution) + 'px'; - } - - // Resizing a canvas will reset imageSmoothingEnabled (and probably other properties) - if (this.scaleMode === ScaleModes.NEAREST) - { - Smoothing.disable(this.gameContext); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#onContextLost - * @since 3.0.0 - * - * @param {function} callback - [description] - */ - onContextLost: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#onContextRestored - * @since 3.0.0 - * - * @param {function} callback - [description] - */ - onContextRestored: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#resetTransform - * @since 3.0.0 - */ - resetTransform: function () - { - this.currentContext.setTransform(1, 0, 0, 1, 0, 0); - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#setBlendMode - * @since 3.0.0 - * - * @param {[type]} blendMode - [description] - * - * @return {[type]} [description] - */ - setBlendMode: function (blendMode) - { - if (this.currentBlendMode !== blendMode) - { - this.currentContext.globalCompositeOperation = blendMode; - this.currentBlendMode = blendMode; - } - - return this.currentBlendMode; - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#setAlpha - * @since 3.0.0 - * - * @param {float} alpha - [description] - * - * @return {float} [description] - */ - setAlpha: function (alpha) - { - if (this.currentAlpha !== alpha) - { - this.currentContext.globalAlpha = alpha; - this.currentAlpha = alpha; - } - - return this.currentAlpha; - }, - - /** - * Called at the start of the render loop. - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#preRender - * @since 3.0.0 - */ - preRender: function () - { - var ctx = this.gameContext; - var config = this.config; - - var width = this.width; - var height = this.height; - - if (config.clearBeforeRender) - { - ctx.clearRect(0, 0, width, height); - } - - if (!config.transparent) - { - ctx.fillStyle = config.backgroundColor.rgba; - ctx.fillRect(0, 0, width, height); - } - - this.drawCount = 0; - }, - - /** - * Renders the Scene to the given Camera. - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#render - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.GameObjects.DisplayList} children - [description] - * @param {float} interpolationPercentage - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - render: function (scene, children, interpolationPercentage, camera) - { - var ctx = scene.sys.context; - var scissor = (camera.x !== 0 || camera.y !== 0 || camera.width !== ctx.canvas.width || camera.height !== ctx.canvas.height); - var list = children.list; - var resolution = this.config.resolution; - - this.currentContext = ctx; - - // If the alpha or blend mode didn't change since the last render, then don't set them again (saves 2 ops) - - if (!camera.transparent) - { - ctx.fillStyle = camera.backgroundColor.rgba; - ctx.fillRect(camera.x, camera.y, camera.width, camera.height); - } - - if (this.currentAlpha !== 1) - { - ctx.globalAlpha = 1; - this.currentAlpha = 1; - } - - if (this.currentBlendMode !== 0) - { - ctx.globalCompositeOperation = 'source-over'; - this.currentBlendMode = 0; - } - - this.currentScaleMode = 0; - - this.drawCount += list.length; - - if (scissor) - { - ctx.save(); - ctx.beginPath(); - ctx.rect(camera.x * resolution, camera.y * resolution, camera.width * resolution, camera.height * resolution); - ctx.clip(); - } - - var matrix = camera.matrix.matrix; - - ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - - for (var c = 0; c < list.length; c++) - { - var child = list[c]; - - if (child.mask) - { - child.mask.preRenderCanvas(this, child, camera); - } - - child.renderCanvas(this, child, interpolationPercentage, camera); - - if (child.mask) - { - child.mask.postRenderCanvas(this, child, camera); - } - } - - ctx.setTransform(1, 0, 0, 1, 0, 0); - - if (camera._fadeAlpha > 0 || camera._flashAlpha > 0) - { - ctx.globalCompositeOperation = 'source-over'; - - // fade rendering - ctx.fillStyle = 'rgb(' + (camera._fadeRed * 255) + ',' + (camera._fadeGreen * 255) + ',' + (camera._fadeBlue * 255) + ')'; - ctx.globalAlpha = camera._fadeAlpha; - ctx.fillRect(camera.x, camera.y, camera.width, camera.height); - - // flash rendering - ctx.fillStyle = 'rgb(' + (camera._flashRed * 255) + ',' + (camera._flashGreen * 255) + ',' + (camera._flashBlue * 255) + ')'; - ctx.globalAlpha = camera._flashAlpha; - ctx.fillRect(camera.x, camera.y, camera.width, camera.height); - - ctx.globalAlpha = 1.0; - } - - // Reset the camera scissor - if (scissor) - { - ctx.restore(); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#postRender - * @since 3.0.0 - */ - postRender: function () - { - var ctx = this.gameContext; - - ctx.globalAlpha = 1; - ctx.globalCompositeOperation = 'source-over'; - - this.currentAlpha = 1; - this.currentBlendMode = 0; - - if (this.snapshotCallback) - { - this.snapshotCallback(CanvasSnapshot(this.gameCanvas, this.snapshotType, this.snapshotEncoder)); - this.snapshotCallback = null; - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#snapshot - * @since 3.0.0 - * - * @param {[type]} callback - [description] - * @param {[type]} type - [description] - * @param {[type]} encoderOptions - [description] - */ - snapshot: function (callback, type, encoderOptions) - { - this.snapshotCallback = callback; - this.snapshotType = type; - this.snapshotEncoder = encoderOptions; - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.gameCanvas = null; - this.gameContext = null; - - this.game = null; - } - -}); - -module.exports = CanvasRenderer; +module.exports = QuickSet; /***/ }), /* 367 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -76890,49 +76940,62 @@ module.exports = CanvasRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var roundPixels = false; - /** - * No scaling, anchor, rotation or effects, literally draws the frame directly to the canvas. - * - * @function Phaser.Renderer.Canvas.BlitImage - * @since 3.0.0 - * - * @param {number} dx - The x coordinate to render the Frame to. - * @param {number} dy - The y coordinate to render the Frame to. - * @param {Phaser.Textures.Frame} frame - The Frame to render. + * @namespace Phaser.Actions */ -var BlitImage = function (dx, dy, frame) -{ - var ctx = this.currentContext; - var cd = frame.canvasData; - if (roundPixels) - { - dx |= 0; - dy |= 0; - } +module.exports = { - ctx.drawImage( - frame.source.image, - cd.sx, - cd.sy, - cd.sWidth, - cd.sHeight, - dx, - dy, - cd.dWidth, - cd.dHeight - ); -}; + Angle: __webpack_require__(943), + Call: __webpack_require__(942), + GetFirst: __webpack_require__(941), + GetLast: __webpack_require__(940), + GridAlign: __webpack_require__(939), + IncAlpha: __webpack_require__(921), + IncX: __webpack_require__(920), + IncXY: __webpack_require__(919), + IncY: __webpack_require__(918), + PlaceOnCircle: __webpack_require__(917), + PlaceOnEllipse: __webpack_require__(916), + PlaceOnLine: __webpack_require__(915), + PlaceOnRectangle: __webpack_require__(914), + PlaceOnTriangle: __webpack_require__(913), + PlayAnimation: __webpack_require__(912), + PropertyValueInc: __webpack_require__(25), + PropertyValueSet: __webpack_require__(20), + RandomCircle: __webpack_require__(911), + RandomEllipse: __webpack_require__(910), + RandomLine: __webpack_require__(909), + RandomRectangle: __webpack_require__(908), + RandomTriangle: __webpack_require__(907), + Rotate: __webpack_require__(906), + RotateAround: __webpack_require__(905), + RotateAroundDistance: __webpack_require__(904), + ScaleX: __webpack_require__(903), + ScaleXY: __webpack_require__(902), + ScaleY: __webpack_require__(901), + SetAlpha: __webpack_require__(900), + SetBlendMode: __webpack_require__(899), + SetDepth: __webpack_require__(898), + SetHitArea: __webpack_require__(897), + SetOrigin: __webpack_require__(896), + SetRotation: __webpack_require__(895), + SetScale: __webpack_require__(894), + SetScaleX: __webpack_require__(893), + SetScaleY: __webpack_require__(892), + SetTint: __webpack_require__(891), + SetVisible: __webpack_require__(890), + SetX: __webpack_require__(889), + SetXY: __webpack_require__(888), + SetY: __webpack_require__(887), + ShiftPosition: __webpack_require__(886), + Shuffle: __webpack_require__(885), + SmootherStep: __webpack_require__(884), + SmoothStep: __webpack_require__(883), + Spread: __webpack_require__(882), + ToggleVisible: __webpack_require__(881), + WrapInRectangle: __webpack_require__(880) -// Special return so we can store the config value locally - -module.exports = function (configRoundPixels) -{ - roundPixels = configRoundPixels; - - return BlitImage; }; @@ -76947,197 +77010,215 @@ module.exports = function (configRoundPixels) */ /** - * [description] + * This is a slightly modified version of jQuery.isPlainObject. + * A plain object is an object whose internal class property is [object Object]. * - * @function Phaser.Renderer.Snapshot.Canvas + * @function Phaser.Utils.Object.IsPlainObject * @since 3.0.0 * - * @param {HTMLCanvasElement} canvas - [description] - * @param {string} [type='image/png'] - [description] - * @param {float} [encoderOptions=0.92] - [description] + * @param {object} obj - The object to inspect. * - * @return {Image} [description] + * @return {boolean} `true` if the object is plain, otherwise `false`. */ -var CanvasSnapshot = function (canvas, type, encoderOptions) +var IsPlainObject = function (obj) { - if (type === undefined) { type = 'image/png'; } - if (encoderOptions === undefined) { encoderOptions = 0.92; } + // Not plain objects: + // - Any object or value whose internal [[Class]] property is not "[object Object]" + // - DOM nodes + // - window + if (typeof(obj) !== 'object' || obj.nodeType || obj === obj.window) + { + return false; + } - var src = canvas.toDataURL(type, encoderOptions); + // Support: Firefox <20 + // The try/catch suppresses exceptions thrown when attempting to access + // the "constructor" property of certain host objects, ie. |window.location| + // https://bugzilla.mozilla.org/show_bug.cgi?id=814622 + try + { + if (obj.constructor && !({}).hasOwnProperty.call(obj.constructor.prototype, 'isPrototypeOf')) + { + return false; + } + } + catch (e) + { + return false; + } - var image = new Image(); - - image.src = src; - - return image; + // If the function hasn't returned already, we're confident that + // |obj| is a plain object, created by {} or constructed with new Object + return true; }; -module.exports = CanvasSnapshot; +module.exports = IsPlainObject; /***/ }), /* 369 */ /***/ (function(module, exports) { -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ +var g; -var roundPixels = false; +// This works in non-strict mode +g = (function() { + return this; +})(); -/** - * [description] - * - * @function Phaser.Renderer.Canvas.DrawImage - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} src - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ -var DrawImage = function (src, camera) -{ - var ctx = this.currentContext; - var frame = src.frame; - var cd = frame.canvasData; +try { + // This works if eval is allowed (see CSP) + g = g || Function("return this")() || (1, eval)("this"); +} catch (e) { + // This works if the window reference is available + if (typeof window === "object") g = window; +} - // Blend Mode +// g can still be undefined, but nothing to do about it... +// We return undefined, instead of nothing here, so it's +// easier to handle this case. if(!global) { ...} - if (this.currentBlendMode !== src.blendMode) - { - this.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = this.blendModes[src.blendMode]; - } - - // Alpha - - if (this.currentAlpha !== src.alpha) - { - this.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - - if (this.currentScaleMode !== src.scaleMode) - { - this.currentScaleMode = src.scaleMode; - - // ctx[this.smoothProperty] = (source.scaleMode === ScaleModes.LINEAR); - } - - var dx = frame.x; - var dy = frame.y; - - var fx = 1; - var fy = 1; - - if (src.flipX) - { - fx = -1; - dx -= cd.dWidth - src.displayOriginX; - } - else - { - dx -= src.displayOriginX; - } - - if (src.flipY) - { - fy = -1; - dy -= cd.dHeight - src.displayOriginY; - } - else - { - dy -= src.displayOriginY; - } - - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - - if (roundPixels) - { - tx |= 0; - ty |= 0; - dx |= 0; - dy |= 0; - } - - // Perform Matrix ITRS - - ctx.save(); - - ctx.translate(tx, ty); - - ctx.rotate(src.rotation); - - ctx.scale(src.scaleX, src.scaleY); - ctx.scale(fx, fy); - - ctx.drawImage(frame.source.image, cd.sx, cd.sy, cd.sWidth, cd.sHeight, dx, dy, cd.dWidth, cd.dHeight); - - ctx.restore(); -}; - -// Special return so we can store the config value locally - -module.exports = function (configRoundPixels) -{ - roundPixels = configRoundPixels; - - return DrawImage; -}; +module.exports = g; /***/ }), /* 370 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ +* The `Matter.Pair` module contains methods for creating and manipulating collision pairs. +* +* @class Pair +*/ -var modes = __webpack_require__(45); -var CanvasFeatures = __webpack_require__(237); +var Pair = {}; -/** - * [description] - * - * @function Phaser.Renderer.Canvas.GetBlendModes - * @since 3.0.0 - * - * @return {array} [description] - */ -var GetBlendModes = function () -{ - var output = []; - var useNew = CanvasFeatures.supportNewBlendModes; +module.exports = Pair; - output[modes.NORMAL] = 'source-over'; - output[modes.ADD] = 'lighter'; - output[modes.MULTIPLY] = (useNew) ? 'multiply' : 'source-over'; - output[modes.SCREEN] = (useNew) ? 'screen' : 'source-over'; - output[modes.OVERLAY] = (useNew) ? 'overlay' : 'source-over'; - output[modes.DARKEN] = (useNew) ? 'darken' : 'source-over'; - output[modes.LIGHTEN] = (useNew) ? 'lighten' : 'source-over'; - output[modes.COLOR_DODGE] = (useNew) ? 'color-dodge' : 'source-over'; - output[modes.COLOR_BURN] = (useNew) ? 'color-burn' : 'source-over'; - output[modes.HARD_LIGHT] = (useNew) ? 'hard-light' : 'source-over'; - output[modes.SOFT_LIGHT] = (useNew) ? 'soft-light' : 'source-over'; - output[modes.DIFFERENCE] = (useNew) ? 'difference' : 'source-over'; - output[modes.EXCLUSION] = (useNew) ? 'exclusion' : 'source-over'; - output[modes.HUE] = (useNew) ? 'hue' : 'source-over'; - output[modes.SATURATION] = (useNew) ? 'saturation' : 'source-over'; - output[modes.COLOR] = (useNew) ? 'color' : 'source-over'; - output[modes.LUMINOSITY] = (useNew) ? 'luminosity' : 'source-over'; +(function() { + + /** + * Creates a pair. + * @method create + * @param {collision} collision + * @param {number} timestamp + * @return {pair} A new pair + */ + Pair.create = function(collision, timestamp) { + var bodyA = collision.bodyA, + bodyB = collision.bodyB; - return output; -}; + var pair = { + id: Pair.id(bodyA, bodyB), + bodyA: bodyA, + bodyB: bodyB, + activeContacts: [], + separation: 0, + isActive: true, + confirmedActive: true, + isSensor: bodyA.isSensor || bodyB.isSensor, + timeCreated: timestamp, + timeUpdated: timestamp, -module.exports = GetBlendModes; + collision: null, + inverseMass: 0, + friction: 0, + frictionStatic: 0, + restitution: 0, + slop: 0 + }; + + Pair.update(pair, collision, timestamp); + + return pair; + }; + + /** + * Updates a pair given a collision. + * @method update + * @param {pair} pair + * @param {collision} collision + * @param {number} timestamp + */ + Pair.update = function(pair, collision, timestamp) { + // var contacts = pair.contacts, + // supports = collision.supports, + // activeContacts = pair.activeContacts, + // parentA = collision.parentA, + // parentB = collision.parentB; + + pair.collision = collision; + // pair.inverseMass = parentA.inverseMass + parentB.inverseMass; + // pair.friction = Math.min(parentA.friction, parentB.friction); + // pair.frictionStatic = Math.max(parentA.frictionStatic, parentB.frictionStatic); + // pair.restitution = Math.max(parentA.restitution, parentB.restitution); + // pair.slop = Math.max(parentA.slop, parentB.slop); + // activeContacts.length = 0; + + if (collision.collided) { + + var supports = collision.supports, + activeContacts = pair.activeContacts, + parentA = collision.parentA, + parentB = collision.parentB; + + pair.inverseMass = parentA.inverseMass + parentB.inverseMass; + pair.friction = Math.min(parentA.friction, parentB.friction); + pair.frictionStatic = Math.max(parentA.frictionStatic, parentB.frictionStatic); + pair.restitution = Math.max(parentA.restitution, parentB.restitution); + pair.slop = Math.max(parentA.slop, parentB.slop); + + for (var i = 0; i < supports.length; i++) { + activeContacts[i] = supports[i].contact; + } + + var supportCount = supports.length; + + if (supportCount < activeContacts.length) { + activeContacts.length = supportCount; + } + + pair.separation = collision.depth; + Pair.setActive(pair, true, timestamp); + } else { + if (pair.isActive === true) + Pair.setActive(pair, false, timestamp); + } + }; + + /** + * Set a pair as active or inactive. + * @method setActive + * @param {pair} pair + * @param {bool} isActive + * @param {number} timestamp + */ + Pair.setActive = function(pair, isActive, timestamp) { + if (isActive) { + pair.isActive = true; + pair.timeUpdated = timestamp; + } else { + pair.isActive = false; + pair.activeContacts.length = 0; + } + }; + + /** + * Get the id for the given pair. + * @method id + * @param {body} bodyA + * @param {body} bodyB + * @return {string} Unique pairId + */ + Pair.id = function(bodyA, bodyB) { + if (bodyA.id < bodyB.id) { + return 'A' + bodyA.id + 'B' + bodyB.id; + } else { + return 'A' + bodyB.id + 'B' + bodyA.id; + } + }; + +})(); /***/ }), @@ -77150,1890 +77231,30 @@ module.exports = GetBlendModes; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var CONST = __webpack_require__(19); -var IsSizePowerOfTwo = __webpack_require__(127); -var Utils = __webpack_require__(41); -var WebGLSnapshot = __webpack_require__(372); - -// Default Pipelines -var BitmapMaskPipeline = __webpack_require__(373); -var FlatTintPipeline = __webpack_require__(374); -var ForwardDiffuseLightPipeline = __webpack_require__(165); -var TextureTintPipeline = __webpack_require__(166); - /** - * @classdesc - * [description] - * - * @class WebGLRenderer - * @memberOf Phaser.Renderer.WebGL - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - [description] + * @namespace Phaser.Physics.Matter.Body.Components */ -var WebGLRenderer = new Class({ - initialize: - - function WebGLRenderer (game) - { - // eslint-disable-next-line consistent-this - var renderer = this; - - var contextCreationConfig = { - alpha: game.config.transparent, - depth: false, // enable when 3D is added in the future - antialias: game.config.antialias, - premultipliedAlpha: game.config.transparent, - stencil: true, - preserveDrawingBuffer: game.config.preserveDrawingBuffer, - failIfMajorPerformanceCaveat: false, - powerPreference: game.config.powerPreference - }; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#config - * @type {object} - * @since 3.0.0 - */ - this.config = { - clearBeforeRender: game.config.clearBeforeRender, - pixelArt: game.config.pixelArt, - backgroundColor: game.config.backgroundColor, - contextCreation: contextCreationConfig, - resolution: game.config.resolution, - autoResize: game.config.autoResize, - roundPixels: game.config.roundPixels - }; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game = game; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#type - * @type {integer} - * @since 3.0.0 - */ - this.type = CONST.WEBGL; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#width - * @type {number} - * @since 3.0.0 - */ - this.width = game.config.width; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#height - * @type {number} - * @since 3.0.0 - */ - this.height = game.config.height; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#canvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.canvas = game.canvas; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#lostContextCallbacks - * @type {function[]} - * @since 3.0.0 - */ - this.lostContextCallbacks = []; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#restoredContextCallbacks - * @type {function[]} - * @since 3.0.0 - */ - this.restoredContextCallbacks = []; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#blendModes - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.blendModes = []; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#nativeTextures - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.nativeTextures = []; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#contextLost - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.contextLost = false; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#pipelines - * @type {object} - * @default null - * @since 3.0.0 - */ - this.pipelines = null; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#snapshotState - * @type {object} - * @since 3.0.0 - */ - this.snapshotState = { - callback: null, - type: null, - encoder: null - }; - - // Internal Renderer State (Textures, Framebuffers, Pipelines, Buffers, etc) - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentActiveTextureUnit - * @type {integer} - * @since 3.1.0 - */ - this.currentActiveTextureUnit = 0; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentTextures - * @type {array} - * @since 3.0.0 - */ - this.currentTextures = new Array(16); - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentFramebuffer - * @type {WebGLFramebuffer} - * @default null - * @since 3.0.0 - */ - this.currentFramebuffer = null; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentPipeline - * @type {Phaser.Renderer.WebGL.WebGLPipeline} - * @default null - * @since 3.0.0 - */ - this.currentPipeline = null; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentProgram - * @type {WebGLProgram} - * @default null - * @since 3.0.0 - */ - this.currentProgram = null; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentVertexBuffer - * @type {WebGLBuffer} - * @default null - * @since 3.0.0 - */ - this.currentVertexBuffer = null; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentIndexBuffer - * @type {WebGLBuffer} - * @default null - * @since 3.0.0 - */ - this.currentIndexBuffer = null; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentBlendMode - * @type {integer} - * @since 3.0.0 - */ - this.currentBlendMode = Infinity; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissorEnabled - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.currentScissorEnabled = false; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissor - * @type {Uint32Array} - * @since 3.0.0 - */ - this.currentScissor = new Uint32Array([ 0, 0, this.width, this.height ]); - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissorIdx - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.currentScissorIdx = 0; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#scissorStack - * @type {Uint32Array} - * @since 3.0.0 - */ - this.scissorStack = new Uint32Array(4 * 1000); - - // Setup context lost and restore event listeners - - this.canvas.addEventListener('webglcontextlost', function (event) - { - renderer.contextLost = true; - event.preventDefault(); - - for (var index = 0; index < renderer.lostContextCallbacks.length; ++index) - { - var callback = renderer.lostContextCallbacks[index]; - callback[0].call(callback[1], renderer); - } - }, false); - - this.canvas.addEventListener('webglcontextrestored', function () - { - renderer.contextLost = false; - renderer.init(renderer.config); - for (var index = 0; index < renderer.restoredContextCallbacks.length; ++index) - { - var callback = renderer.restoredContextCallbacks[index]; - callback[0].call(callback[1], renderer); - } - }, false); - - // This are initialized post context creation - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#gl - * @type {WebGLRenderingContext} - * @default null - * @since 3.0.0 - */ - this.gl = null; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#supportedExtensions - * @type {object} - * @default null - * @since 3.0.0 - */ - this.supportedExtensions = null; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#extensions - * @type {object} - * @default {} - * @since 3.0.0 - */ - this.extensions = {}; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#glFormats - * @type {array} - * @default [] - * @since 3.2.0 - */ - this.glFormats = []; - - this.init(this.config); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#init - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - init: function (config) - { - var canvas = this.canvas; - var clearColor = config.backgroundColor; - var gl = canvas.getContext('webgl', config.contextCreation) || canvas.getContext('experimental-webgl', config.contextCreation); - - if (!gl) - { - this.contextLost = true; - throw new Error('This browser does not support WebGL. Try using the Canvas pipeline.'); - } - - this.gl = gl; - - for (var i = 0; i <= 16; i++) - { - this.blendModes.push({ func: [ gl.ONE, gl.ONE_MINUS_SRC_ALPHA ], equation: gl.FUNC_ADD }); - } - - this.blendModes[1].func = [ gl.ONE, gl.DST_ALPHA ]; - this.blendModes[2].func = [ gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA ]; - this.blendModes[3].func = [ gl.ONE, gl.ONE_MINUS_SRC_COLOR ]; - - this.glFormats[0] = gl.BYTE; - this.glFormats[1] = gl.SHORT; - this.glFormats[2] = gl.UNSIGNED_BYTE; - this.glFormats[3] = gl.UNSIGNED_SHORT; - this.glFormats[4] = gl.FLOAT; - - // Load supported extensions - this.supportedExtensions = gl.getSupportedExtensions(); - - // Setup initial WebGL state - gl.disable(gl.DEPTH_TEST); - gl.disable(gl.CULL_FACE); - gl.disable(gl.SCISSOR_TEST); - gl.enable(gl.BLEND); - gl.clearColor(clearColor.redGL, clearColor.greenGL, clearColor.blueGL, 1.0); - - // Initialize all textures to null - for (var index = 0; index < this.currentTextures.length; ++index) - { - this.currentTextures[index] = null; - } - - // Clear previous pipelines and reload default ones - this.pipelines = {}; - - this.addPipeline('TextureTintPipeline', new TextureTintPipeline({ game: this.game, renderer: this })); - this.addPipeline('FlatTintPipeline', new FlatTintPipeline({ game: this.game, renderer: this })); - this.addPipeline('BitmapMaskPipeline', new BitmapMaskPipeline({ game: this.game, renderer: this })); - this.addPipeline('Light2D', new ForwardDiffuseLightPipeline({ game: this.game, renderer: this })); - - this.setBlendMode(CONST.BlendModes.NORMAL); - this.resize(this.width, this.height); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#resize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - resize: function (width, height) - { - var gl = this.gl; - var pipelines = this.pipelines; - var resolution = this.config.resolution; - - this.width = width * resolution; - this.height = height * resolution; - - this.canvas.width = this.width; - this.canvas.height = this.height; - - if (this.config.autoResize) - { - this.canvas.style.width = (this.width / resolution) + 'px'; - this.canvas.style.height = (this.height / resolution) + 'px'; - } - - gl.viewport(0, 0, this.width, this.height); - - // Update all registered pipelines - for (var pipelineName in pipelines) - { - pipelines[pipelineName].resize(width, height, resolution); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#onContextRestored - * @since 3.0.0 - * - * @param {function} callback - [description] - * @param {object} target - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - onContextRestored: function (callback, target) - { - this.restoredContextCallbacks.push([ callback, target ]); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#onContextLost - * @since 3.0.0 - * - * @param {function} callback - [description] - * @param {object} target - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - onContextLost: function (callback, target) - { - this.lostContextCallbacks.push([ callback, target ]); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#hasExtension - * @since 3.0.0 - * - * @param {string} extensionName - [description] - * - * @return {boolean} [description] - */ - hasExtension: function (extensionName) - { - return this.supportedExtensions ? this.supportedExtensions.indexOf(extensionName) : false; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#getExtension - * @since 3.0.0 - * - * @param {string} extensionName - [description] - * - * @return {object} [description] - */ - getExtension: function (extensionName) - { - if (!this.hasExtension(extensionName)) { return null; } - - if (!(extensionName in this.extensions)) - { - this.extensions[extensionName] = this.gl.getExtension(extensionName); - } - - return this.extensions[extensionName]; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#flush - * @since 3.0.0 - */ - flush: function () - { - if (this.currentPipeline) - { - this.currentPipeline.flush(); - } - }, - - /* Renderer State Manipulation Functions */ - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#hasPipeline - * @since 3.0.0 - * - * @param {string} pipelineName - [description] - * - * @return {boolean} [description] - */ - hasPipeline: function (pipelineName) - { - return (pipelineName in this.pipelines); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#getPipeline - * @since 3.0.0 - * - * @param {string} pipelineName - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - getPipeline: function (pipelineName) - { - return (this.hasPipeline(pipelineName)) ? this.pipelines[pipelineName] : null; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#removePipeline - * @since 3.0.0 - * - * @param {string} pipelineName - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - removePipeline: function (pipelineName) - { - delete this.pipelines[pipelineName]; - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#addPipeline - * @since 3.0.0 - * - * @param {string} pipelineName - [description] - * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - addPipeline: function (pipelineName, pipelineInstance) - { - if (!this.hasPipeline(pipelineName)) { this.pipelines[pipelineName] = pipelineInstance; } - else { console.warn('Pipeline', pipelineName, ' already exists.'); } - - pipelineInstance.name = pipelineName; - this.pipelines[pipelineName].resize(this.width, this.height, this.config.resolution); - - return pipelineInstance; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setScissor - * @since 3.0.0 - * - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} w - [description] - * @param {integer} h - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setScissor: function (x, y, w, h) - { - var gl = this.gl; - var currentScissor = this.currentScissor; - var enabled = (x === 0 && y === 0 && w === gl.canvas.width && h === gl.canvas.height && w >= 0 && h >= 0); - - if (currentScissor[0] !== x || - currentScissor[1] !== y || - currentScissor[2] !== w || - currentScissor[3] !== h) - { - this.flush(); - } - - currentScissor[0] = x; - currentScissor[1] = y; - currentScissor[2] = w; - currentScissor[3] = h; - - this.currentScissorEnabled = enabled; - - if (enabled) - { - gl.disable(gl.SCISSOR_TEST); - return; - } - - gl.enable(gl.SCISSOR_TEST); - gl.scissor(x, (gl.drawingBufferHeight - y - h), w, h); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#pushScissor - * @since 3.0.0 - * - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} w - [description] - * @param {integer} h - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - pushScissor: function (x, y, w, h) - { - var scissorStack = this.scissorStack; - var stackIndex = this.currentScissorIdx; - var currentScissor = this.currentScissor; - - scissorStack[stackIndex + 0] = currentScissor[0]; - scissorStack[stackIndex + 1] = currentScissor[1]; - scissorStack[stackIndex + 2] = currentScissor[2]; - scissorStack[stackIndex + 3] = currentScissor[3]; - - this.currentScissorIdx += 4; - this.setScissor(x, y, w, h); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#popScissor - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - popScissor: function () - { - var scissorStack = this.scissorStack; - var stackIndex = this.currentScissorIdx - 4; - - var x = scissorStack[stackIndex + 0]; - var y = scissorStack[stackIndex + 1]; - var w = scissorStack[stackIndex + 2]; - var h = scissorStack[stackIndex + 3]; - - this.currentScissorIdx = stackIndex; - this.setScissor(x, y, w, h); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setPipeline - * @since 3.0.0 - * - * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setPipeline: function (pipelineInstance) - { - if (this.currentPipeline !== pipelineInstance || - this.currentPipeline.vertexBuffer !== this.currentVertexBuffer || - this.currentPipeline.program !== this.currentProgram) - { - this.flush(); - this.currentPipeline = pipelineInstance; - this.currentPipeline.bind(); - } - - this.currentPipeline.onBind(); - - return this.currentPipeline; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setBlendMode - * @since 3.0.0 - * - * @param {integer} blendModeId - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setBlendMode: function (blendModeId) - { - var gl = this.gl; - var blendMode = this.blendModes[blendModeId]; - - if (blendModeId !== CONST.BlendModes.SKIP_CHECK && - this.currentBlendMode !== blendModeId) - { - this.flush(); - - gl.enable(gl.BLEND); - gl.blendEquation(blendMode.equation); - - if (blendMode.func.length > 2) - { - gl.blendFuncSeparate(blendMode.func[0], blendMode.func[1], blendMode.func[2], blendMode.func[3]); - } - else - { - gl.blendFunc(blendMode.func[0], blendMode.func[1]); - } - - this.currentBlendMode = blendModeId; - } - - return this; - }, - - addBlendMode: function (func, equation) - { - var index = this.blendModes.push({ func: func, equation: equation }); - - return index - 1; - }, - - updateBlendMode: function (index, func, equation) - { - if (this.blendModes[index]) - { - this.blendModes[index].func = func; - - if (equation) - { - this.blendModes[index].equation = equation; - } - } - - return this; - }, - - removeBlendMode: function (index) - { - if (index > 16 && this.blendModes[index]) - { - this.blendModes.splice(index, 1); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setTexture2D - * @since 3.0.0 - * - * @param {WebGLTexture} texture - [description] - * @param {integer} textureUnit - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setTexture2D: function (texture, textureUnit) - { - var gl = this.gl; - - if (texture !== this.currentTextures[textureUnit]) - { - this.flush(); - - if (this.currentActiveTextureUnit !== textureUnit) - { - gl.activeTexture(gl.TEXTURE0 + textureUnit); - this.currentActiveTextureUnit = textureUnit; - } - gl.bindTexture(gl.TEXTURE_2D, texture); - - this.currentTextures[textureUnit] = texture; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFramebuffer - * @since 3.0.0 - * - * @param {WebGLFramebuffer} framebuffer - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setFramebuffer: function (framebuffer) - { - var gl = this.gl; - - if (framebuffer !== this.currentFramebuffer) - { - this.flush(); - - gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); - this.currentFramebuffer = framebuffer; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setProgram - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setProgram: function (program) - { - var gl = this.gl; - - if (program !== this.currentProgram) - { - this.flush(); - - gl.useProgram(program); - this.currentProgram = program; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setVertexBuffer - * @since 3.0.0 - * - * @param {WebGLBuffer} vertexBuffer - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setVertexBuffer: function (vertexBuffer) - { - var gl = this.gl; - - if (vertexBuffer !== this.currentVertexBuffer) - { - this.flush(); - - gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); - this.currentVertexBuffer = vertexBuffer; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setIndexBuffer - * @since 3.0.0 - * - * @param {WebGLBuffer} indexBuffer - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setIndexBuffer: function (indexBuffer) - { - var gl = this.gl; - - if (indexBuffer !== this.currentIndexBuffer) - { - this.flush(); - - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer); - this.currentIndexBuffer = indexBuffer; - } - - return this; - }, - - /* Renderer Resource Creation Functions */ - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createTextureFromSource - * @since 3.0.0 - * - * @param {object} source - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {integer} scaleMode - [description] - * - * @return {WebGLTexture} [description] - */ - createTextureFromSource: function (source, width, height, scaleMode) - { - var gl = this.gl; - var filter = gl.NEAREST; - var wrap = gl.CLAMP_TO_EDGE; - var texture = null; - - width = source ? source.width : width; - height = source ? source.height : height; - - if (IsSizePowerOfTwo(width, height)) - { - wrap = gl.REPEAT; - } - - if (scaleMode === CONST.ScaleModes.LINEAR) - { - filter = gl.LINEAR; - } - else if (scaleMode === CONST.ScaleModes.NEAREST || this.config.pixelArt) - { - filter = gl.NEAREST; - } - - if (!source && typeof width === 'number' && typeof height === 'number') - { - texture = this.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); - } - else - { - texture = this.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, source); - } - - return texture; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createTexture2D - * @since 3.0.0 - * - * @param {integer} mipLevel - [description] - * @param {integer} minFilter - [description] - * @param {integer} magFilter - [description] - * @param {integer} wrapT - [description] - * @param {integer} wrapS - [description] - * @param {integer} format - [description] - * @param {object} pixels - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {boolean} pma - [description] - * - * @return {WebGLTexture} [description] - */ - createTexture2D: function (mipLevel, minFilter, magFilter, wrapT, wrapS, format, pixels, width, height, pma) - { - var gl = this.gl; - var texture = gl.createTexture(); - - pma = (pma === undefined || pma === null) ? true : pma; - - this.setTexture2D(texture, 0); - - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT); - gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, pma); - - if (pixels === null || pixels === undefined) - { - gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, width, height, 0, format, gl.UNSIGNED_BYTE, null); - } - else - { - gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, format, gl.UNSIGNED_BYTE, pixels); - width = pixels.width; - height = pixels.height; - } - - this.setTexture2D(null, 0); - - texture.isAlphaPremultiplied = pma; - texture.isRenderTexture = false; - texture.width = width; - texture.height = height; - - this.nativeTextures.push(texture); - - return texture; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createFramebuffer - * @since 3.0.0 - * - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {WebGLFramebuffer} renderTexture - [description] - * @param {boolean} addDepthStencilBuffer - [description] - * - * @return {WebGLFramebuffer} [description] - */ - createFramebuffer: function (width, height, renderTexture, addDepthStencilBuffer) - { - var gl = this.gl; - var framebuffer = gl.createFramebuffer(); - var complete = 0; - - this.setFramebuffer(framebuffer); - - if (addDepthStencilBuffer) - { - var depthStencilBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer); - } - - renderTexture.isRenderTexture = true; - renderTexture.isAlphaPremultiplied = false; - - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, renderTexture, 0); - - complete = gl.checkFramebufferStatus(gl.FRAMEBUFFER); - - if (complete !== gl.FRAMEBUFFER_COMPLETE) - { - var errors = { - 36054: 'Incomplete Attachment', - 36055: 'Missing Attachment', - 36057: 'Incomplete Dimensions', - 36061: 'Framebuffer Unsupported' - }; - throw new Error('Framebuffer incomplete. Framebuffer status: ' + errors[complete]); - } - - framebuffer.renderTexture = renderTexture; - - this.setFramebuffer(null); - - return framebuffer; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createProgram - * @since 3.0.0 - * - * @param {string} vertexShader - [description] - * @param {string} fragmentShader - [description] - * - * @return {WebGLProgram} [description] - */ - createProgram: function (vertexShader, fragmentShader) - { - var gl = this.gl; - var program = gl.createProgram(); - var vs = gl.createShader(gl.VERTEX_SHADER); - var fs = gl.createShader(gl.FRAGMENT_SHADER); - - gl.shaderSource(vs, vertexShader); - gl.shaderSource(fs, fragmentShader); - gl.compileShader(vs); - gl.compileShader(fs); - - if (!gl.getShaderParameter(vs, gl.COMPILE_STATUS)) - { - throw new Error('Failed to compile Vertex Shader:\n' + gl.getShaderInfoLog(vs)); - } - if (!gl.getShaderParameter(fs, gl.COMPILE_STATUS)) - { - throw new Error('Failed to compile Fragment Shader:\n' + gl.getShaderInfoLog(fs)); - } - - gl.attachShader(program, vs); - gl.attachShader(program, fs); - gl.linkProgram(program); - - if (!gl.getProgramParameter(program, gl.LINK_STATUS)) - { - throw new Error('Failed to link program:\n' + gl.getProgramInfoLog(program)); - } - - return program; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createVertexBuffer - * @since 3.0.0 - * - * @param {ArrayBuffer} initialDataOrSize - [description] - * @param {integer} bufferUsage - [description] - * - * @return {WebGLBuffer} [description] - */ - createVertexBuffer: function (initialDataOrSize, bufferUsage) - { - var gl = this.gl; - var vertexBuffer = gl.createBuffer(); - - this.setVertexBuffer(vertexBuffer); - gl.bufferData(gl.ARRAY_BUFFER, initialDataOrSize, bufferUsage); - this.setVertexBuffer(null); - - return vertexBuffer; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createIndexBuffer - * @since 3.0.0 - * - * @param {ArrayBuffer} initialDataOrSize - [description] - * @param {integer} bufferUsage - [description] - * - * @return {WebGLBuffer} [description] - */ - createIndexBuffer: function (initialDataOrSize, bufferUsage) - { - var gl = this.gl; - var indexBuffer = gl.createBuffer(); - - this.setIndexBuffer(indexBuffer); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, initialDataOrSize, bufferUsage); - this.setIndexBuffer(null); - - return indexBuffer; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteTexture - * @since 3.0.0 - * - * @param {WebGLTexture} texture - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - deleteTexture: function (texture) - { - this.gl.deleteTexture(texture); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteFramebuffer - * @since 3.0.0 - * - * @param {WebGLFramebuffer} framebuffer - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - deleteFramebuffer: function (framebuffer) - { - this.gl.deleteFramebuffer(framebuffer); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteProgram - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - deleteProgram: function (program) - { - this.gl.deleteProgram(program); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteBuffer - * @since 3.0.0 - * - * @param {WebGLBuffer} vertexBuffer - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - deleteBuffer: function (buffer) - { - this.gl.deleteBuffer(buffer); - return this; - }, - - /* Rendering Functions */ - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#preRenderCamera - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - preRenderCamera: function (camera) - { - var resolution = this.config.resolution; - - this.pushScissor(camera.x * resolution, camera.y * resolution, camera.width * resolution, camera.height * resolution); - - if (camera.backgroundColor.alphaGL > 0) - { - var color = camera.backgroundColor; - var FlatTintPipeline = this.pipelines.FlatTintPipeline; - - FlatTintPipeline.batchFillRect( - 0, 0, 1, 1, 0, - camera.x, camera.y, camera.width, camera.height, - Utils.getTintFromFloats(color.redGL, color.greenGL, color.blueGL, 1.0), - color.alphaGL, - 1, 0, 0, 1, 0, 0, - [ 1, 0, 0, 1, 0, 0 ] - ); - - FlatTintPipeline.flush(); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#postRenderCamera - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - postRenderCamera: function (camera) - { - if (camera._fadeAlpha > 0 || camera._flashAlpha > 0) - { - var FlatTintPipeline = this.pipelines.FlatTintPipeline; - - // Fade - FlatTintPipeline.batchFillRect( - 0, 0, 1, 1, 0, - camera.x, camera.y, camera.width, camera.height, - Utils.getTintFromFloats(camera._fadeRed, camera._fadeGreen, camera._fadeBlue, 1.0), - camera._fadeAlpha, - 1, 0, 0, 1, 0, 0, - [ 1, 0, 0, 1, 0, 0 ] - ); - - // Flash - FlatTintPipeline.batchFillRect( - 0, 0, 1, 1, 0, - camera.x, camera.y, camera.width, camera.height, - Utils.getTintFromFloats(camera._flashRed, camera._flashGreen, camera._flashBlue, 1.0), - camera._flashAlpha, - 1, 0, 0, 1, 0, 0, - [ 1, 0, 0, 1, 0, 0 ] - ); - - FlatTintPipeline.flush(); - } - - this.popScissor(); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#preRender - * @since 3.0.0 - */ - preRender: function () - { - if (this.contextLost) { return; } - - var gl = this.gl; - var color = this.config.backgroundColor; - var pipelines = this.pipelines; - - // Bind custom framebuffer here - gl.clearColor(color.redGL, color.greenGL, color.blueGL, color.alphaGL); - - if (this.config.clearBeforeRender) - { gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT); } - - for (var key in pipelines) - { - pipelines[key].onPreRender(); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#render - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.GameObjects.GameObject} children - [description] - * @param {number} interpolationPercentage - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - render: function (scene, children, interpolationPercentage, camera) - { - if (this.contextLost) { return; } - - var list = children.list; - var childCount = list.length; - var pipelines = this.pipelines; - - for (var key in pipelines) - { - pipelines[key].onRender(scene, camera); - } - - this.preRenderCamera(camera); - - for (var index = 0; index < childCount; ++index) - { - var child = list[index]; - - if (!child.willRender()) - { - continue; - } - - if (child.blendMode !== this.currentBlendMode) - { - this.setBlendMode(child.blendMode); - } - - if (child.mask) - { - child.mask.preRenderWebGL(this, child, camera); - } - - child.renderWebGL(this, child, interpolationPercentage, camera); - - if (child.mask) - { - child.mask.postRenderWebGL(this, child); - } - } - - this.flush(); - this.setBlendMode(CONST.BlendModes.NORMAL); - this.postRenderCamera(camera); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#postRender - * @since 3.0.0 - */ - postRender: function () - { - if (this.contextLost) { return; } - - // Unbind custom framebuffer here - - if (this.snapshotState.callback) - { - this.snapshotState.callback(WebGLSnapshot(this.canvas, this.snapshotState.type, this.snapshotState.encoder)); - this.snapshotState.callback = null; - } - - var pipelines = this.pipelines; - - for (var key in pipelines) - { - pipelines[key].onPostRender(); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#snapshot - * @since 3.0.0 - * - * @param {function} callback - [description] - * @param {string} type - [description] - * @param {float} encoderOptions - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - snapshot: function (callback, type, encoderOptions) - { - this.snapshotState.callback = callback; - this.snapshotState.type = type; - this.snapshotState.encoder = encoderOptions; - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#canvasToTexture - * @since 3.0.0 - * - * @param {HTMLCanvasElement} srcCanvas - [description] - * @param {WebGLTexture} dstTexture - [description] - * @param {boolean} shouldReallocate - [description] - * @param {integer} scaleMode - [description] - * - * @return {WebGLTexture} [description] - */ - canvasToTexture: function (srcCanvas, dstTexture) - { - var gl = this.gl; - - if (!dstTexture) - { - var wrapping = gl.CLAMP_TO_EDGE; - - if (IsSizePowerOfTwo(srcCanvas.width, srcCanvas.height)) - { - wrapping = gl.REPEAT; - } - - dstTexture = this.createTexture2D(0, gl.NEAREST, gl.NEAREST, wrapping, wrapping, gl.RGBA, srcCanvas, srcCanvas.width, srcCanvas.height, true); - } - else - { - this.setTexture2D(dstTexture, 0); - - // if (!shouldReallocate && dstTexture.width >= srcCanvas.width || dstTexture.height >= srcCanvas.height) - // { - // gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, srcCanvas.width, srcCanvas.height, gl.RGBA, gl.UNSIGNED_BYTE, srcCanvas); - // } - // else - { - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, srcCanvas); - dstTexture.width = srcCanvas.width; - dstTexture.height = srcCanvas.height; - } - - this.setTexture2D(null, 0); - } - - return dstTexture; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setTextureFilter - * @since 3.0.0 - * - * @param {integer} texture - [description] - * @param {integer} filter - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setTextureFilter: function (texture, filter) - { - var gl = this.gl; - var glFilter = [ gl.LINEAR, gl.NEAREST ][filter]; - - this.setTexture2D(texture, 0); - - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, glFilter); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, glFilter); - - this.setTexture2D(null, 0); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat1 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {float} x - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setFloat1: function (program, name, x) - { - this.setProgram(program); - this.gl.uniform1f(this.gl.getUniformLocation(program, name), x); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat2 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setFloat2: function (program, name, x, y) - { - this.setProgram(program); - this.gl.uniform2f(this.gl.getUniformLocation(program, name), x, y); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat3 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] - * @param {float} z - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setFloat3: function (program, name, x, y, z) - { - this.setProgram(program); - this.gl.uniform3f(this.gl.getUniformLocation(program, name), x, y, z); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat4 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] - * @param {float} z - [description] - * @param {float} w - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setFloat4: function (program, name, x, y, z, w) - { - this.setProgram(program); - this.gl.uniform4f(this.gl.getUniformLocation(program, name), x, y, z, w); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt1 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {integer} x - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setInt1: function (program, name, x) - { - this.setProgram(program); - this.gl.uniform1i(this.gl.getUniformLocation(program, name), x); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt2 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {integer} x - [description] - * @param {integer} y - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setInt2: function (program, name, x, y) - { - this.setProgram(program); - this.gl.uniform2i(this.gl.getUniformLocation(program, name), x, y); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt3 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} z - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setInt3: function (program, name, x, y, z) - { - this.setProgram(program); - this.gl.uniform3i(this.gl.getUniformLocation(program, name), x, y, z); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt4 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} z - [description] - * @param {integer} w - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setInt4: function (program, name, x, y, z, w) - { - this.setProgram(program); - this.gl.uniform4i(this.gl.getUniformLocation(program, name), x, y, z, w); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix2 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {boolean} transpose - [description] - * @param {Float32Array} matrix - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setMatrix2: function (program, name, transpose, matrix) - { - this.setProgram(program); - this.gl.uniformMatrix2fv(this.gl.getUniformLocation(program, name), transpose, matrix); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix3 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {boolean} transpose - [description] - * @param {Float32Array} matrix - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setMatrix3: function (program, name, transpose, matrix) - { - this.setProgram(program); - this.gl.uniformMatrix3fv(this.gl.getUniformLocation(program, name), transpose, matrix); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix4 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {boolean} transpose - [description] - * @param {Float32Array} matrix - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setMatrix4: function (program, name, transpose, matrix) - { - this.setProgram(program); - this.gl.uniformMatrix4fv(this.gl.getUniformLocation(program, name), transpose, matrix); - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#destroy - * @since 3.0.0 - */ - destroy: function () - { - // Clear-up anything that should be cleared :) - for (var key in this.pipelines) - { - this.pipelines[key].destroy(); - delete this.pipelines[key]; - } - - for (var index = 0; index < this.nativeTextures.length; ++index) - { - this.deleteTexture(this.nativeTextures[index]); - delete this.nativeTextures[index]; - } - - if (this.hasExtension('WEBGL_lose_context')) - { - this.getExtension('WEBGL_lose_context').loseContext(); - } - - delete this.gl; - delete this.game; - - this.contextLost = true; - this.extensions = {}; - this.nativeTextures.length = 0; - } - -}); - -module.exports = WebGLRenderer; +module.exports = { + + Bounce: __webpack_require__(996), + Collision: __webpack_require__(995), + Force: __webpack_require__(994), + Friction: __webpack_require__(993), + Gravity: __webpack_require__(992), + Mass: __webpack_require__(991), + Static: __webpack_require__(990), + Sensor: __webpack_require__(989), + SetBody: __webpack_require__(988), + Sleep: __webpack_require__(987), + Transform: __webpack_require__(986), + Velocity: __webpack_require__(985) + +}; /***/ }), /* 372 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Renderer.Snapshot.WebGL - * @since 3.0.0 - * - * @param {HTMLCanvasElement} sourceCanvas - [description] - * @param {string} [type='image/png'] - [description] - * @param {float} [encoderOptions=0.92] - [description] - * - * @return {Image} [description] - */ -var WebGLSnapshot = function (sourceCanvas, type, encoderOptions) -{ - if (!type) { type = 'image/png'; } - if (!encoderOptions) { encoderOptions = 0.92; } - - var gl = sourceCanvas.getContext('experimental-webgl'); - var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); - gl.readPixels(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, gl.RGBA, gl.UNSIGNED_BYTE, pixels); - - // CanvasPool? - var canvas = document.createElement('canvas'); - var ctx = canvas.getContext('2d'); - var imageData; - - canvas.width = gl.drawingBufferWidth; - canvas.height = gl.drawingBufferHeight; - - imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); - - var data = imageData.data; - - for (var y = 0; y < canvas.height; y += 1) - { - for (var x = 0; x < canvas.width; x += 1) - { - var si = ((canvas.height - y) * canvas.width + x) * 4; - var di = (y * canvas.width + x) * 4; - data[di + 0] = pixels[si + 0]; - data[di + 1] = pixels[si + 1]; - data[di + 2] = pixels[si + 2]; - data[di + 3] = pixels[si + 3]; - } - } - - ctx.putImageData(imageData, 0, 0); - - var src = canvas.toDataURL(type, encoderOptions); - var image = new Image(); - - image.src = src; - - return image; -}; - -module.exports = WebGLSnapshot; - - -/***/ }), -/* 373 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -79043,223 +77264,13 @@ module.exports = WebGLSnapshot; */ var Class = __webpack_require__(0); -var ShaderSourceFS = __webpack_require__(511); -var ShaderSourceVS = __webpack_require__(512); -var WebGLPipeline = __webpack_require__(103); - -/** - * @classdesc - * [description] - * - * @class BitmapMaskPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline - * @memberOf Phaser.Renderer.WebGL - * @constructor - * @since 3.0.0 - * - * @param {object} config - [description] - */ -var BitmapMaskPipeline = new Class({ - - Extends: WebGLPipeline, - - initialize: - - function BitmapMaskPipeline (config) - { - WebGLPipeline.call(this, { - game: config.game, - renderer: config.renderer, - gl: config.renderer.gl, - topology: (config.topology ? config.topology : config.renderer.gl.TRIANGLES), - vertShader: (config.vertShader ? config.vertShader : ShaderSourceVS), - fragShader: (config.fragShader ? config.fragShader : ShaderSourceFS), - vertexCapacity: (config.vertexCapacity ? config.vertexCapacity : 3), - - vertexSize: (config.vertexSize ? config.vertexSize : - Float32Array.BYTES_PER_ELEMENT * 2), - - vertices: new Float32Array([ - -1, +1, -1, -7, +7, +1 - ]).buffer, - - attributes: [ - { - name: 'inPosition', - size: 2, - type: config.renderer.gl.FLOAT, - normalized: false, - offset: 0 - } - ] - }); - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.BitmapMaskPipeline#vertexViewF32 - * @type {Float32Array} - * @since 3.0.0 - */ - this.vertexViewF32 = new Float32Array(this.vertexData); - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.BitmapMaskPipeline#maxQuads - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.maxQuads = 1; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.BitmapMaskPipeline#resolutionDirty - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.resolutionDirty = true; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.BitmapMaskPipeline#onBind - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.BitmapMaskPipeline} [description] - */ - onBind: function () - { - WebGLPipeline.prototype.onBind.call(this); - - var renderer = this.renderer; - var program = this.program; - - if (this.resolutionDirty) - { - renderer.setFloat2(program, 'uResolution', this.width, this.height); - renderer.setInt1(program, 'uMainSampler', 0); - renderer.setInt1(program, 'uMaskSampler', 1); - this.resolutionDirty = false; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.BitmapMaskPipeline#resize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} resolution - [description] - * - * @return {Phaser.Renderer.WebGL.BitmapMaskPipeline} [description] - */ - resize: function (width, height, resolution) - { - WebGLPipeline.prototype.resize.call(this, width, height, resolution); - this.resolutionDirty = true; - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.BitmapMaskPipeline#beginMask - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} mask - [description] - * @param {Phaser.GameObjects.GameObject} maskedObject - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - beginMask: function (mask, maskedObject, camera) - { - var bitmapMask = mask.bitmapMask; - var renderer = this.renderer; - var gl = this.gl; - var visible = bitmapMask.visible; - - if (bitmapMask && gl) - { - // First we clear the mask framebuffer - renderer.setFramebuffer(mask.maskFramebuffer); - gl.clearColor(0, 0, 0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); - - // We render out mask source - bitmapMask.visible = true; - bitmapMask.renderWebGL(renderer, bitmapMask, 0.0, camera); - bitmapMask.visible = visible; - renderer.flush(); - - // Bind and clear our main source (masked object) - renderer.setFramebuffer(mask.mainFramebuffer); - gl.clearColor(0, 0, 0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.BitmapMaskPipeline#endMask - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} mask - [description] - */ - endMask: function (mask) - { - var bitmapMask = mask.bitmapMask; - var renderer = this.renderer; - var gl = this.gl; - - if (bitmapMask) - { - // Return to default framebuffer - renderer.setFramebuffer(null); - - // Bind bitmap mask pipeline and draw - renderer.setPipeline(this); - - renderer.setTexture2D(mask.maskTexture, 1); - renderer.setTexture2D(mask.mainTexture, 0); - renderer.setInt1(this.program, 'uInvertMaskAlpha', mask.invertAlpha); - - // Finally draw a triangle filling the whole screen - gl.drawArrays(this.topology, 0, 3); - } - } - -}); - -module.exports = BitmapMaskPipeline; - - -/***/ }), -/* 374 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Commands = __webpack_require__(128); -var Earcut = __webpack_require__(238); -var ModelViewProjection = __webpack_require__(239); -var ShaderSourceFS = __webpack_require__(513); -var ShaderSourceVS = __webpack_require__(514); -var Utils = __webpack_require__(41); -var WebGLPipeline = __webpack_require__(103); +var Commands = __webpack_require__(144); +var Earcut = __webpack_require__(301); +var ModelViewProjection = __webpack_require__(300); +var ShaderSourceFS = __webpack_require__(814); +var ShaderSourceVS = __webpack_require__(813); +var Utils = __webpack_require__(44); +var WebGLPipeline = __webpack_require__(108); var Point = function (x, y, width, rgb, alpha) { @@ -79961,6 +77972,7 @@ var FlatTintPipeline = new Class({ var srcScaleY = graphics.scaleY; var srcRotation = -graphics.rotation; var commands = graphics.commandBuffer; + var alpha = graphics.alpha; var lineAlpha = 1.0; var fillAlpha = 1.0; var lineColor = 0; @@ -80026,12 +78038,13 @@ var FlatTintPipeline = new Class({ if (lastPath === null) { - lastPath = new Path(x + cos(startAngle) * radius, y + sin(startAngle) * radius, lineWidth, lineColor, lineAlpha); + lastPath = new Path(x + cos(startAngle) * radius, y + sin(startAngle) * radius, lineWidth, lineColor, lineAlpha * alpha); pathArray.push(lastPath); iteration += iterStep; } endAngle -= startAngle; + if (anticlockwise) { if (endAngle < -PI2) @@ -80058,7 +78071,7 @@ var FlatTintPipeline = new Class({ tx = x + cos(ta) * radius; ty = y + sin(ta) * radius; - lastPath.points.push(new Point(tx, ty, lineWidth, lineColor, lineAlpha)); + lastPath.points.push(new Point(tx, ty, lineWidth, lineColor, lineAlpha * alpha)); iteration += iterStep; } @@ -80067,7 +78080,7 @@ var FlatTintPipeline = new Class({ tx = x + cos(ta) * radius; ty = y + sin(ta) * radius; - lastPath.points.push(new Point(tx, ty, lineWidth, lineColor, lineAlpha)); + lastPath.points.push(new Point(tx, ty, lineWidth, lineColor, lineAlpha * alpha)); cmdIndex += 6; break; @@ -80110,7 +78123,7 @@ var FlatTintPipeline = new Class({ /* Rectangle properties */ pathArray[pathArrayIndex].points, fillColor, - fillAlpha, + fillAlpha * alpha, /* Transform */ mva, mvb, mvc, mvd, mve, mvf, @@ -80134,7 +78147,7 @@ var FlatTintPipeline = new Class({ path.points, lineWidth, lineColor, - lineAlpha, + lineAlpha * alpha, /* Transform */ mva, mvb, mvc, mvd, mve, mvf, @@ -80156,7 +78169,7 @@ var FlatTintPipeline = new Class({ commands[cmdIndex + 3], commands[cmdIndex + 4], fillColor, - fillAlpha, + fillAlpha * alpha, /* Transform */ mva, mvb, mvc, mvd, mve, mvf, @@ -80180,7 +78193,7 @@ var FlatTintPipeline = new Class({ commands[cmdIndex + 5], commands[cmdIndex + 6], fillColor, - fillAlpha, + fillAlpha * alpha, /* Transform */ mva, mvb, mvc, mvd, mve, mvf, @@ -80205,7 +78218,7 @@ var FlatTintPipeline = new Class({ commands[cmdIndex + 6], lineWidth, lineColor, - lineAlpha, + lineAlpha * alpha, /* Transform */ mva, mvb, mvc, mvd, mve, mvf, @@ -80218,18 +78231,18 @@ var FlatTintPipeline = new Class({ case Commands.LINE_TO: if (lastPath !== null) { - lastPath.points.push(new Point(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha)); + lastPath.points.push(new Point(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha * alpha)); } else { - lastPath = new Path(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha); + lastPath = new Path(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha * alpha); pathArray.push(lastPath); } cmdIndex += 2; break; case Commands.MOVE_TO: - lastPath = new Path(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha); + lastPath = new Path(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha * alpha); pathArray.push(lastPath); cmdIndex += 2; break; @@ -80242,7 +78255,7 @@ var FlatTintPipeline = new Class({ commands[cmdIndex + 2], commands[cmdIndex + 3], commands[cmdIndex + 4], - commands[cmdIndex + 5] + commands[cmdIndex + 5] * alpha )); } else @@ -80252,7 +78265,7 @@ var FlatTintPipeline = new Class({ commands[cmdIndex + 2], commands[cmdIndex + 3], commands[cmdIndex + 4], - commands[cmdIndex + 5] + commands[cmdIndex + 5] * alpha ); pathArray.push(lastPath); } @@ -80265,7 +78278,7 @@ var FlatTintPipeline = new Class({ commands[cmdIndex + 2], commands[cmdIndex + 3], commands[cmdIndex + 4], - commands[cmdIndex + 5] + commands[cmdIndex + 5] * alpha ); pathArray.push(lastPath); cmdIndex += 5; @@ -80470,158 +78483,2262 @@ module.exports = FlatTintPipeline; /***/ }), -/* 375 */ +/* 373 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var ShaderSourceFS = __webpack_require__(816); +var ShaderSourceVS = __webpack_require__(815); +var WebGLPipeline = __webpack_require__(108); + +/** + * @classdesc + * [description] + * + * @class BitmapMaskPipeline + * @extends Phaser.Renderer.WebGL.WebGLPipeline + * @memberOf Phaser.Renderer.WebGL + * @constructor + * @since 3.0.0 + * + * @param {object} config - [description] + */ +var BitmapMaskPipeline = new Class({ + + Extends: WebGLPipeline, + + initialize: + + function BitmapMaskPipeline (config) + { + WebGLPipeline.call(this, { + game: config.game, + renderer: config.renderer, + gl: config.renderer.gl, + topology: (config.topology ? config.topology : config.renderer.gl.TRIANGLES), + vertShader: (config.vertShader ? config.vertShader : ShaderSourceVS), + fragShader: (config.fragShader ? config.fragShader : ShaderSourceFS), + vertexCapacity: (config.vertexCapacity ? config.vertexCapacity : 3), + + vertexSize: (config.vertexSize ? config.vertexSize : + Float32Array.BYTES_PER_ELEMENT * 2), + + vertices: new Float32Array([ + -1, +1, -1, -7, +7, +1 + ]).buffer, + + attributes: [ + { + name: 'inPosition', + size: 2, + type: config.renderer.gl.FLOAT, + normalized: false, + offset: 0 + } + ] + }); + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.BitmapMaskPipeline#vertexViewF32 + * @type {Float32Array} + * @since 3.0.0 + */ + this.vertexViewF32 = new Float32Array(this.vertexData); + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.BitmapMaskPipeline#maxQuads + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.maxQuads = 1; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.BitmapMaskPipeline#resolutionDirty + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.resolutionDirty = true; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.BitmapMaskPipeline#onBind + * @since 3.0.0 + * + * @return {Phaser.Renderer.WebGL.BitmapMaskPipeline} [description] + */ + onBind: function () + { + WebGLPipeline.prototype.onBind.call(this); + + var renderer = this.renderer; + var program = this.program; + + if (this.resolutionDirty) + { + renderer.setFloat2(program, 'uResolution', this.width, this.height); + renderer.setInt1(program, 'uMainSampler', 0); + renderer.setInt1(program, 'uMaskSampler', 1); + this.resolutionDirty = false; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.BitmapMaskPipeline#resize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * @param {number} resolution - [description] + * + * @return {Phaser.Renderer.WebGL.BitmapMaskPipeline} [description] + */ + resize: function (width, height, resolution) + { + WebGLPipeline.prototype.resize.call(this, width, height, resolution); + this.resolutionDirty = true; + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.BitmapMaskPipeline#beginMask + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} mask - [description] + * @param {Phaser.GameObjects.GameObject} maskedObject - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + beginMask: function (mask, maskedObject, camera) + { + var bitmapMask = mask.bitmapMask; + var renderer = this.renderer; + var gl = this.gl; + var visible = bitmapMask.visible; + + if (bitmapMask && gl) + { + // First we clear the mask framebuffer + renderer.setFramebuffer(mask.maskFramebuffer); + gl.clearColor(0, 0, 0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); + + // We render out mask source + bitmapMask.visible = true; + bitmapMask.renderWebGL(renderer, bitmapMask, 0.0, camera); + bitmapMask.visible = visible; + renderer.flush(); + + // Bind and clear our main source (masked object) + renderer.setFramebuffer(mask.mainFramebuffer); + gl.clearColor(0, 0, 0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.BitmapMaskPipeline#endMask + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} mask - [description] + */ + endMask: function (mask) + { + var bitmapMask = mask.bitmapMask; + var renderer = this.renderer; + var gl = this.gl; + + if (bitmapMask) + { + // Return to default framebuffer + renderer.setFramebuffer(null); + + // Bind bitmap mask pipeline and draw + renderer.setPipeline(this); + + renderer.setTexture2D(mask.maskTexture, 1); + renderer.setTexture2D(mask.mainTexture, 0); + renderer.setInt1(this.program, 'uInvertMaskAlpha', mask.invertAlpha); + + // Finally draw a triangle filling the whole screen + gl.drawArrays(this.topology, 0, 3); + } + } + +}); + +module.exports = BitmapMaskPipeline; + + +/***/ }), +/* 374 */ /***/ (function(module, exports) { /** -* The `Matter.Pair` module contains methods for creating and manipulating collision pairs. -* -* @class Pair -*/ + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ -var Pair = {}; +/** + * [description] + * + * @function Phaser.Renderer.Snapshot.WebGL + * @since 3.0.0 + * + * @param {HTMLCanvasElement} sourceCanvas - [description] + * @param {string} [type='image/png'] - [description] + * @param {float} [encoderOptions=0.92] - [description] + * + * @return {HTMLImageElement} [description] + */ +var WebGLSnapshot = function (sourceCanvas, type, encoderOptions) +{ + if (!type) { type = 'image/png'; } + if (!encoderOptions) { encoderOptions = 0.92; } -module.exports = Pair; + var gl = sourceCanvas.getContext('experimental-webgl'); + var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); + gl.readPixels(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, gl.RGBA, gl.UNSIGNED_BYTE, pixels); -(function() { - - /** - * Creates a pair. - * @method create - * @param {collision} collision - * @param {number} timestamp - * @return {pair} A new pair - */ - Pair.create = function(collision, timestamp) { - var bodyA = collision.bodyA, - bodyB = collision.bodyB; + // CanvasPool? + var canvas = document.createElement('canvas'); + var ctx = canvas.getContext('2d'); + var imageData; - var pair = { - id: Pair.id(bodyA, bodyB), - bodyA: bodyA, - bodyB: bodyB, - activeContacts: [], - separation: 0, - isActive: true, - confirmedActive: true, - isSensor: bodyA.isSensor || bodyB.isSensor, - timeCreated: timestamp, - timeUpdated: timestamp, + canvas.width = gl.drawingBufferWidth; + canvas.height = gl.drawingBufferHeight; - collision: null, - inverseMass: 0, - friction: 0, - frictionStatic: 0, - restitution: 0, - slop: 0 + imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); + + var data = imageData.data; + + for (var y = 0; y < canvas.height; y += 1) + { + for (var x = 0; x < canvas.width; x += 1) + { + var si = ((canvas.height - y) * canvas.width + x) * 4; + var di = (y * canvas.width + x) * 4; + data[di + 0] = pixels[si + 0]; + data[di + 1] = pixels[si + 1]; + data[di + 2] = pixels[si + 2]; + data[di + 3] = pixels[si + 3]; + } + } + + ctx.putImageData(imageData, 0, 0); + + var src = canvas.toDataURL(type, encoderOptions); + var image = new Image(); + + image.src = src; + + return image; +}; + +module.exports = WebGLSnapshot; + + +/***/ }), +/* 375 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(21); +var IsSizePowerOfTwo = __webpack_require__(145); +var Utils = __webpack_require__(44); +var WebGLSnapshot = __webpack_require__(374); + +// Default Pipelines +var BitmapMaskPipeline = __webpack_require__(373); +var FlatTintPipeline = __webpack_require__(372); +var ForwardDiffuseLightPipeline = __webpack_require__(173); +var TextureTintPipeline = __webpack_require__(172); + +/** + * @callback WebGLContextCallback + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - [description] + */ + +/** + * @typedef {object} SnapshotState + * + * @property {SnapshotCallback} callback - [description] + * @property {string} type - [description] + * @property {float} encoder - [description] + */ + +/** + * @classdesc + * [description] + * + * @class WebGLRenderer + * @memberOf Phaser.Renderer.WebGL + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - [description] + */ +var WebGLRenderer = new Class({ + + initialize: + + function WebGLRenderer (game) + { + // eslint-disable-next-line consistent-this + var renderer = this; + + var gameConfig = game.config; + + var contextCreationConfig = { + alpha: gameConfig.transparent, + depth: false, // enable when 3D is added in the future + antialias: gameConfig.antialias, + premultipliedAlpha: gameConfig.premultipliedAlpha, + stencil: true, + preserveDrawingBuffer: gameConfig.preserveDrawingBuffer, + failIfMajorPerformanceCaveat: gameConfig.failIfMajorPerformanceCaveat, + powerPreference: gameConfig.powerPreference }; - Pair.update(pair, collision, timestamp); + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#config + * @type {RendererConfig} + * @since 3.0.0 + */ + this.config = { + clearBeforeRender: gameConfig.clearBeforeRender, + pixelArt: gameConfig.pixelArt, + backgroundColor: gameConfig.backgroundColor, + contextCreation: contextCreationConfig, + resolution: gameConfig.resolution, + autoResize: gameConfig.autoResize, + roundPixels: gameConfig.roundPixels + }; - return pair; - }; + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game = game; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#type + * @type {integer} + * @since 3.0.0 + */ + this.type = CONST.WEBGL; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#width + * @type {number} + * @since 3.0.0 + */ + this.width = game.config.width; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#height + * @type {number} + * @since 3.0.0 + */ + this.height = game.config.height; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#canvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvas = game.canvas; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#lostContextCallbacks + * @type {WebGLContextCallback[]} + * @since 3.0.0 + */ + this.lostContextCallbacks = []; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#restoredContextCallbacks + * @type {WebGLContextCallback[]} + * @since 3.0.0 + */ + this.restoredContextCallbacks = []; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#blendModes + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.blendModes = []; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#nativeTextures + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.nativeTextures = []; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#contextLost + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.contextLost = false; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#pipelines + * @type {object} + * @default null + * @since 3.0.0 + */ + this.pipelines = null; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#snapshotState + * @type {SnapshotState} + * @since 3.0.0 + */ + this.snapshotState = { + callback: null, + type: null, + encoder: null + }; + + // Internal Renderer State (Textures, Framebuffers, Pipelines, Buffers, etc) + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentActiveTextureUnit + * @type {integer} + * @since 3.1.0 + */ + this.currentActiveTextureUnit = 0; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentTextures + * @type {array} + * @since 3.0.0 + */ + this.currentTextures = new Array(16); + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentFramebuffer + * @type {WebGLFramebuffer} + * @default null + * @since 3.0.0 + */ + this.currentFramebuffer = null; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentPipeline + * @type {Phaser.Renderer.WebGL.WebGLPipeline} + * @default null + * @since 3.0.0 + */ + this.currentPipeline = null; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentProgram + * @type {WebGLProgram} + * @default null + * @since 3.0.0 + */ + this.currentProgram = null; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentVertexBuffer + * @type {WebGLBuffer} + * @default null + * @since 3.0.0 + */ + this.currentVertexBuffer = null; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentIndexBuffer + * @type {WebGLBuffer} + * @default null + * @since 3.0.0 + */ + this.currentIndexBuffer = null; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentBlendMode + * @type {integer} + * @since 3.0.0 + */ + this.currentBlendMode = Infinity; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissorEnabled + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.currentScissorEnabled = false; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissor + * @type {Uint32Array} + * @since 3.0.0 + */ + this.currentScissor = new Uint32Array([ 0, 0, this.width, this.height ]); + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissorIdx + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.currentScissorIdx = 0; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#scissorStack + * @type {Uint32Array} + * @since 3.0.0 + */ + this.scissorStack = new Uint32Array(4 * 1000); + + // Setup context lost and restore event listeners + + this.canvas.addEventListener('webglcontextlost', function (event) + { + renderer.contextLost = true; + event.preventDefault(); + + for (var index = 0; index < renderer.lostContextCallbacks.length; ++index) + { + var callback = renderer.lostContextCallbacks[index]; + callback[0].call(callback[1], renderer); + } + }, false); + + this.canvas.addEventListener('webglcontextrestored', function () + { + renderer.contextLost = false; + renderer.init(renderer.config); + for (var index = 0; index < renderer.restoredContextCallbacks.length; ++index) + { + var callback = renderer.restoredContextCallbacks[index]; + callback[0].call(callback[1], renderer); + } + }, false); + + // This are initialized post context creation + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#gl + * @type {WebGLRenderingContext} + * @default null + * @since 3.0.0 + */ + this.gl = null; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#supportedExtensions + * @type {object} + * @default null + * @since 3.0.0 + */ + this.supportedExtensions = null; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#extensions + * @type {object} + * @default {} + * @since 3.0.0 + */ + this.extensions = {}; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#glFormats + * @type {array} + * @default [] + * @since 3.2.0 + */ + this.glFormats = []; + + this.init(this.config); + }, /** - * Updates a pair given a collision. - * @method update - * @param {pair} pair - * @param {collision} collision - * @param {number} timestamp + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#init + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] */ - Pair.update = function(pair, collision, timestamp) { - // var contacts = pair.contacts, - // supports = collision.supports, - // activeContacts = pair.activeContacts, - // parentA = collision.parentA, - // parentB = collision.parentB; - - pair.collision = collision; - // pair.inverseMass = parentA.inverseMass + parentB.inverseMass; - // pair.friction = Math.min(parentA.friction, parentB.friction); - // pair.frictionStatic = Math.max(parentA.frictionStatic, parentB.frictionStatic); - // pair.restitution = Math.max(parentA.restitution, parentB.restitution); - // pair.slop = Math.max(parentA.slop, parentB.slop); - // activeContacts.length = 0; - - if (collision.collided) { + init: function (config) + { + var canvas = this.canvas; + var clearColor = config.backgroundColor; + var gl = canvas.getContext('webgl', config.contextCreation) || canvas.getContext('experimental-webgl', config.contextCreation); - var supports = collision.supports, - activeContacts = pair.activeContacts, - parentA = collision.parentA, - parentB = collision.parentB; + if (!gl) + { + this.contextLost = true; + throw new Error('This browser does not support WebGL. Try using the Canvas pipeline.'); + } - pair.inverseMass = parentA.inverseMass + parentB.inverseMass; - pair.friction = Math.min(parentA.friction, parentB.friction); - pair.frictionStatic = Math.max(parentA.frictionStatic, parentB.frictionStatic); - pair.restitution = Math.max(parentA.restitution, parentB.restitution); - pair.slop = Math.max(parentA.slop, parentB.slop); + this.gl = gl; - for (var i = 0; i < supports.length; i++) { - activeContacts[i] = supports[i].contact; + for (var i = 0; i <= 16; i++) + { + this.blendModes.push({ func: [ gl.ONE, gl.ONE_MINUS_SRC_ALPHA ], equation: gl.FUNC_ADD }); + } + + this.blendModes[1].func = [ gl.ONE, gl.DST_ALPHA ]; + this.blendModes[2].func = [ gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA ]; + this.blendModes[3].func = [ gl.ONE, gl.ONE_MINUS_SRC_COLOR ]; + + this.glFormats[0] = gl.BYTE; + this.glFormats[1] = gl.SHORT; + this.glFormats[2] = gl.UNSIGNED_BYTE; + this.glFormats[3] = gl.UNSIGNED_SHORT; + this.glFormats[4] = gl.FLOAT; + + // Load supported extensions + this.supportedExtensions = gl.getSupportedExtensions(); + + // Setup initial WebGL state + gl.disable(gl.DEPTH_TEST); + gl.disable(gl.CULL_FACE); + gl.disable(gl.SCISSOR_TEST); + gl.enable(gl.BLEND); + gl.clearColor(clearColor.redGL, clearColor.greenGL, clearColor.blueGL, 1.0); + + // Initialize all textures to null + for (var index = 0; index < this.currentTextures.length; ++index) + { + this.currentTextures[index] = null; + } + + // Clear previous pipelines and reload default ones + this.pipelines = {}; + + this.addPipeline('TextureTintPipeline', new TextureTintPipeline({ game: this.game, renderer: this })); + this.addPipeline('FlatTintPipeline', new FlatTintPipeline({ game: this.game, renderer: this })); + this.addPipeline('BitmapMaskPipeline', new BitmapMaskPipeline({ game: this.game, renderer: this })); + this.addPipeline('Light2D', new ForwardDiffuseLightPipeline({ game: this.game, renderer: this })); + + this.setBlendMode(CONST.BlendModes.NORMAL); + this.resize(this.width, this.height); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#resize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + resize: function (width, height) + { + var gl = this.gl; + var pipelines = this.pipelines; + var resolution = this.config.resolution; + + this.width = Math.floor(width * resolution); + this.height = Math.floor(height * resolution); + + this.canvas.width = this.width; + this.canvas.height = this.height; + + if (this.config.autoResize) + { + this.canvas.style.width = (this.width / resolution) + 'px'; + this.canvas.style.height = (this.height / resolution) + 'px'; + } + + gl.viewport(0, 0, this.width, this.height); + + // Update all registered pipelines + for (var pipelineName in pipelines) + { + pipelines[pipelineName].resize(width, height, resolution); + } + + this.currentScissor.set([ 0, 0, this.width, this.height ]); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#onContextRestored + * @since 3.0.0 + * + * @param {WebGLContextCallback} callback - [description] + * @param {object} target - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + onContextRestored: function (callback, target) + { + this.restoredContextCallbacks.push([ callback, target ]); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#onContextLost + * @since 3.0.0 + * + * @param {WebGLContextCallback} callback - [description] + * @param {object} target - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + onContextLost: function (callback, target) + { + this.lostContextCallbacks.push([ callback, target ]); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#hasExtension + * @since 3.0.0 + * + * @param {string} extensionName - [description] + * + * @return {boolean} [description] + */ + hasExtension: function (extensionName) + { + return this.supportedExtensions ? this.supportedExtensions.indexOf(extensionName) : false; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#getExtension + * @since 3.0.0 + * + * @param {string} extensionName - [description] + * + * @return {object} [description] + */ + getExtension: function (extensionName) + { + if (!this.hasExtension(extensionName)) { return null; } + + if (!(extensionName in this.extensions)) + { + this.extensions[extensionName] = this.gl.getExtension(extensionName); + } + + return this.extensions[extensionName]; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#flush + * @since 3.0.0 + */ + flush: function () + { + if (this.currentPipeline) + { + this.currentPipeline.flush(); + } + }, + + /* Renderer State Manipulation Functions */ + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#hasPipeline + * @since 3.0.0 + * + * @param {string} pipelineName - [description] + * + * @return {boolean} [description] + */ + hasPipeline: function (pipelineName) + { + return (pipelineName in this.pipelines); + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#getPipeline + * @since 3.0.0 + * + * @param {string} pipelineName - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + */ + getPipeline: function (pipelineName) + { + return (this.hasPipeline(pipelineName)) ? this.pipelines[pipelineName] : null; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#removePipeline + * @since 3.0.0 + * + * @param {string} pipelineName - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + removePipeline: function (pipelineName) + { + delete this.pipelines[pipelineName]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#addPipeline + * @since 3.0.0 + * + * @param {string} pipelineName - [description] + * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + */ + addPipeline: function (pipelineName, pipelineInstance) + { + if (!this.hasPipeline(pipelineName)) + { + this.pipelines[pipelineName] = pipelineInstance; + } + else + { + console.warn('Pipeline', pipelineName, ' already exists.'); + } + + pipelineInstance.name = pipelineName; + + this.pipelines[pipelineName].resize(this.width, this.height, this.config.resolution); + + return pipelineInstance; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setScissor + * @since 3.0.0 + * + * @param {integer} x - [description] + * @param {integer} y - [description] + * @param {integer} w - [description] + * @param {integer} h - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setScissor: function (x, y, w, h) + { + var gl = this.gl; + var currentScissor = this.currentScissor; + var enabled = (x === 0 && y === 0 && w === gl.canvas.width && h === gl.canvas.height && w >= 0 && h >= 0); + + if (currentScissor[0] !== x || + currentScissor[1] !== y || + currentScissor[2] !== w || + currentScissor[3] !== h) + { + this.flush(); + } + + currentScissor[0] = x; + currentScissor[1] = y; + currentScissor[2] = w; + currentScissor[3] = h; + + this.currentScissorEnabled = enabled; + + if (enabled) + { + gl.disable(gl.SCISSOR_TEST); + + return this; + } + + gl.enable(gl.SCISSOR_TEST); + gl.scissor(x, (gl.drawingBufferHeight - y - h), w, h); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#pushScissor + * @since 3.0.0 + * + * @param {integer} x - [description] + * @param {integer} y - [description] + * @param {integer} w - [description] + * @param {integer} h - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + pushScissor: function (x, y, w, h) + { + var scissorStack = this.scissorStack; + var stackIndex = this.currentScissorIdx; + var currentScissor = this.currentScissor; + + scissorStack[stackIndex + 0] = currentScissor[0]; + scissorStack[stackIndex + 1] = currentScissor[1]; + scissorStack[stackIndex + 2] = currentScissor[2]; + scissorStack[stackIndex + 3] = currentScissor[3]; + + this.currentScissorIdx += 4; + this.setScissor(x, y, w, h); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#popScissor + * @since 3.0.0 + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + popScissor: function () + { + var scissorStack = this.scissorStack; + var stackIndex = this.currentScissorIdx - 4; + + var x = scissorStack[stackIndex + 0]; + var y = scissorStack[stackIndex + 1]; + var w = scissorStack[stackIndex + 2]; + var h = scissorStack[stackIndex + 3]; + + this.currentScissorIdx = stackIndex; + this.setScissor(x, y, w, h); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setPipeline + * @since 3.0.0 + * + * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + */ + setPipeline: function (pipelineInstance) + { + if (this.currentPipeline !== pipelineInstance || + this.currentPipeline.vertexBuffer !== this.currentVertexBuffer || + this.currentPipeline.program !== this.currentProgram) + { + this.flush(); + this.currentPipeline = pipelineInstance; + this.currentPipeline.bind(); + } + + this.currentPipeline.onBind(); + + return this.currentPipeline; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setBlendMode + * @since 3.0.0 + * + * @param {integer} blendModeId - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setBlendMode: function (blendModeId) + { + var gl = this.gl; + var blendMode = this.blendModes[blendModeId]; + + if (blendModeId !== CONST.BlendModes.SKIP_CHECK && + this.currentBlendMode !== blendModeId) + { + this.flush(); + + gl.enable(gl.BLEND); + gl.blendEquation(blendMode.equation); + + if (blendMode.func.length > 2) + { + gl.blendFuncSeparate(blendMode.func[0], blendMode.func[1], blendMode.func[2], blendMode.func[3]); + } + else + { + gl.blendFunc(blendMode.func[0], blendMode.func[1]); } - var supportCount = supports.length; + this.currentBlendMode = blendModeId; + } - if (supportCount < activeContacts.length) { - activeContacts.length = supportCount; + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#addBlendMode + * @since 3.0.0 + * + * @param {function} func - [description] + * @param {function} equation - [description] + * + * @return {integer} [description] + */ + addBlendMode: function (func, equation) + { + var index = this.blendModes.push({ func: func, equation: equation }); + + return index - 1; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#updateBlendMode + * @since 3.0.0 + * + * @param {integer} index - [description] + * @param {function} func - [description] + * @param {function} equation - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + */ + updateBlendMode: function (index, func, equation) + { + if (this.blendModes[index]) + { + this.blendModes[index].func = func; + + if (equation) + { + this.blendModes[index].equation = equation; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#removeBlendMode + * @since 3.0.0 + * + * @param {integer} index - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + */ + removeBlendMode: function (index) + { + if (index > 16 && this.blendModes[index]) + { + this.blendModes.splice(index, 1); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setTexture2D + * @since 3.0.0 + * + * @param {WebGLTexture} texture - [description] + * @param {integer} textureUnit - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + */ + setTexture2D: function (texture, textureUnit) + { + var gl = this.gl; + + if (texture !== this.currentTextures[textureUnit]) + { + this.flush(); + + if (this.currentActiveTextureUnit !== textureUnit) + { + gl.activeTexture(gl.TEXTURE0 + textureUnit); + + this.currentActiveTextureUnit = textureUnit; } - pair.separation = collision.depth; - Pair.setActive(pair, true, timestamp); - } else { - if (pair.isActive === true) - Pair.setActive(pair, false, timestamp); + gl.bindTexture(gl.TEXTURE_2D, texture); + + this.currentTextures[textureUnit] = texture; } - }; - - /** - * Set a pair as active or inactive. - * @method setActive - * @param {pair} pair - * @param {bool} isActive - * @param {number} timestamp - */ - Pair.setActive = function(pair, isActive, timestamp) { - if (isActive) { - pair.isActive = true; - pair.timeUpdated = timestamp; - } else { - pair.isActive = false; - pair.activeContacts.length = 0; - } - }; + + return this; + }, /** - * Get the id for the given pair. - * @method id - * @param {body} bodyA - * @param {body} bodyB - * @return {string} Unique pairId + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFramebuffer + * @since 3.0.0 + * + * @param {WebGLFramebuffer} framebuffer - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. */ - Pair.id = function(bodyA, bodyB) { - if (bodyA.id < bodyB.id) { - return 'A' + bodyA.id + 'B' + bodyB.id; - } else { - return 'A' + bodyB.id + 'B' + bodyA.id; - } - }; + setFramebuffer: function (framebuffer) + { + var gl = this.gl; -})(); + if (framebuffer !== this.currentFramebuffer) + { + this.flush(); + + gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); + + this.currentFramebuffer = framebuffer; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setProgram + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + */ + setProgram: function (program) + { + var gl = this.gl; + + if (program !== this.currentProgram) + { + this.flush(); + + gl.useProgram(program); + + this.currentProgram = program; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setVertexBuffer + * @since 3.0.0 + * + * @param {WebGLBuffer} vertexBuffer - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + */ + setVertexBuffer: function (vertexBuffer) + { + var gl = this.gl; + + if (vertexBuffer !== this.currentVertexBuffer) + { + this.flush(); + + gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); + + this.currentVertexBuffer = vertexBuffer; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setIndexBuffer + * @since 3.0.0 + * + * @param {WebGLBuffer} indexBuffer - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + */ + setIndexBuffer: function (indexBuffer) + { + var gl = this.gl; + + if (indexBuffer !== this.currentIndexBuffer) + { + this.flush(); + + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer); + + this.currentIndexBuffer = indexBuffer; + } + + return this; + }, + + /* Renderer Resource Creation Functions */ + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createTextureFromSource + * @since 3.0.0 + * + * @param {object} source - [description] + * @param {integer} width - [description] + * @param {integer} height - [description] + * @param {integer} scaleMode - [description] + * + * @return {WebGLTexture} [description] + */ + createTextureFromSource: function (source, width, height, scaleMode) + { + var gl = this.gl; + var filter = gl.NEAREST; + var wrap = gl.CLAMP_TO_EDGE; + var texture = null; + + width = source ? source.width : width; + height = source ? source.height : height; + + if (IsSizePowerOfTwo(width, height)) + { + wrap = gl.REPEAT; + } + + if (scaleMode === CONST.ScaleModes.LINEAR) + { + filter = gl.LINEAR; + } + else if (scaleMode === CONST.ScaleModes.NEAREST || this.config.pixelArt) + { + filter = gl.NEAREST; + } + + if (!source && typeof width === 'number' && typeof height === 'number') + { + texture = this.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); + } + else + { + texture = this.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, source); + } + + return texture; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createTexture2D + * @since 3.0.0 + * + * @param {integer} mipLevel - [description] + * @param {integer} minFilter - [description] + * @param {integer} magFilter - [description] + * @param {integer} wrapT - [description] + * @param {integer} wrapS - [description] + * @param {integer} format - [description] + * @param {object} pixels - [description] + * @param {integer} width - [description] + * @param {integer} height - [description] + * @param {boolean} pma - [description] + * + * @return {WebGLTexture} [description] + */ + createTexture2D: function (mipLevel, minFilter, magFilter, wrapT, wrapS, format, pixels, width, height, pma) + { + var gl = this.gl; + var texture = gl.createTexture(); + + pma = (pma === undefined || pma === null) ? true : pma; + + this.setTexture2D(texture, 0); + + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT); + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, pma); + + if (pixels === null || pixels === undefined) + { + gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, width, height, 0, format, gl.UNSIGNED_BYTE, null); + } + else + { + gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, format, gl.UNSIGNED_BYTE, pixels); + width = pixels.width; + height = pixels.height; + } + + this.setTexture2D(null, 0); + + texture.isAlphaPremultiplied = pma; + texture.isRenderTexture = false; + texture.width = width; + texture.height = height; + + this.nativeTextures.push(texture); + + return texture; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createFramebuffer + * @since 3.0.0 + * + * @param {integer} width - [description] + * @param {integer} height - [description] + * @param {WebGLFramebuffer} renderTexture - [description] + * @param {boolean} addDepthStencilBuffer - [description] + * + * @return {WebGLFramebuffer} [description] + */ + createFramebuffer: function (width, height, renderTexture, addDepthStencilBuffer) + { + var gl = this.gl; + var framebuffer = gl.createFramebuffer(); + var complete = 0; + + this.setFramebuffer(framebuffer); + + if (addDepthStencilBuffer) + { + var depthStencilBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer); + } + + renderTexture.isRenderTexture = true; + renderTexture.isAlphaPremultiplied = false; + + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, renderTexture, 0); + + complete = gl.checkFramebufferStatus(gl.FRAMEBUFFER); + + if (complete !== gl.FRAMEBUFFER_COMPLETE) + { + var errors = { + 36054: 'Incomplete Attachment', + 36055: 'Missing Attachment', + 36057: 'Incomplete Dimensions', + 36061: 'Framebuffer Unsupported' + }; + + throw new Error('Framebuffer incomplete. Framebuffer status: ' + errors[complete]); + } + + framebuffer.renderTexture = renderTexture; + + this.setFramebuffer(null); + + return framebuffer; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createProgram + * @since 3.0.0 + * + * @param {string} vertexShader - [description] + * @param {string} fragmentShader - [description] + * + * @return {WebGLProgram} [description] + */ + createProgram: function (vertexShader, fragmentShader) + { + var gl = this.gl; + var program = gl.createProgram(); + var vs = gl.createShader(gl.VERTEX_SHADER); + var fs = gl.createShader(gl.FRAGMENT_SHADER); + + gl.shaderSource(vs, vertexShader); + gl.shaderSource(fs, fragmentShader); + gl.compileShader(vs); + gl.compileShader(fs); + + if (!gl.getShaderParameter(vs, gl.COMPILE_STATUS)) + { + throw new Error('Failed to compile Vertex Shader:\n' + gl.getShaderInfoLog(vs)); + } + if (!gl.getShaderParameter(fs, gl.COMPILE_STATUS)) + { + throw new Error('Failed to compile Fragment Shader:\n' + gl.getShaderInfoLog(fs)); + } + + gl.attachShader(program, vs); + gl.attachShader(program, fs); + gl.linkProgram(program); + + if (!gl.getProgramParameter(program, gl.LINK_STATUS)) + { + throw new Error('Failed to link program:\n' + gl.getProgramInfoLog(program)); + } + + return program; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createVertexBuffer + * @since 3.0.0 + * + * @param {ArrayBuffer} initialDataOrSize - [description] + * @param {integer} bufferUsage - [description] + * + * @return {WebGLBuffer} [description] + */ + createVertexBuffer: function (initialDataOrSize, bufferUsage) + { + var gl = this.gl; + var vertexBuffer = gl.createBuffer(); + + this.setVertexBuffer(vertexBuffer); + + gl.bufferData(gl.ARRAY_BUFFER, initialDataOrSize, bufferUsage); + + this.setVertexBuffer(null); + + return vertexBuffer; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createIndexBuffer + * @since 3.0.0 + * + * @param {ArrayBuffer} initialDataOrSize - [description] + * @param {integer} bufferUsage - [description] + * + * @return {WebGLBuffer} [description] + */ + createIndexBuffer: function (initialDataOrSize, bufferUsage) + { + var gl = this.gl; + var indexBuffer = gl.createBuffer(); + + this.setIndexBuffer(indexBuffer); + + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, initialDataOrSize, bufferUsage); + + this.setIndexBuffer(null); + + return indexBuffer; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteTexture + * @since 3.0.0 + * + * @param {WebGLTexture} texture - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + */ + deleteTexture: function (texture) + { + this.gl.deleteTexture(texture); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteFramebuffer + * @since 3.0.0 + * + * @param {WebGLFramebuffer} framebuffer - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + */ + deleteFramebuffer: function (framebuffer) + { + this.gl.deleteFramebuffer(framebuffer); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteProgram + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + */ + deleteProgram: function (program) + { + this.gl.deleteProgram(program); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteBuffer + * @since 3.0.0 + * + * @param {WebGLBuffer} vertexBuffer - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + */ + deleteBuffer: function (buffer) + { + this.gl.deleteBuffer(buffer); + + return this; + }, + + /* Rendering Functions */ + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#preRenderCamera + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + preRenderCamera: function (camera) + { + var resolution = this.config.resolution; + + var cx = Math.floor(camera.x * resolution); + var cy = Math.floor(camera.y * resolution); + var cw = Math.floor(camera.width * resolution); + var ch = Math.floor(camera.height * resolution); + + this.pushScissor(cx, cy, cw, ch); + + if (camera.backgroundColor.alphaGL > 0) + { + var color = camera.backgroundColor; + var FlatTintPipeline = this.pipelines.FlatTintPipeline; + + FlatTintPipeline.batchFillRect( + 0, 0, 1, 1, 0, + camera.x, camera.y, camera.width, camera.height, + Utils.getTintFromFloats(color.redGL, color.greenGL, color.blueGL, 1.0), + color.alphaGL, + 1, 0, 0, 1, 0, 0, + [ 1, 0, 0, 1, 0, 0 ] + ); + + FlatTintPipeline.flush(); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#postRenderCamera + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + postRenderCamera: function (camera) + { + if (camera._fadeAlpha > 0 || camera._flashAlpha > 0) + { + var FlatTintPipeline = this.pipelines.FlatTintPipeline; + + // Fade + FlatTintPipeline.batchFillRect( + 0, 0, 1, 1, 0, + camera.x, camera.y, camera.width, camera.height, + Utils.getTintFromFloats(camera._fadeRed, camera._fadeGreen, camera._fadeBlue, 1.0), + camera._fadeAlpha, + 1, 0, 0, 1, 0, 0, + [ 1, 0, 0, 1, 0, 0 ] + ); + + // Flash + FlatTintPipeline.batchFillRect( + 0, 0, 1, 1, 0, + camera.x, camera.y, camera.width, camera.height, + Utils.getTintFromFloats(camera._flashRed, camera._flashGreen, camera._flashBlue, 1.0), + camera._flashAlpha, + 1, 0, 0, 1, 0, 0, + [ 1, 0, 0, 1, 0, 0 ] + ); + + FlatTintPipeline.flush(); + } + + this.popScissor(); + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#preRender + * @since 3.0.0 + */ + preRender: function () + { + if (this.contextLost) { return; } + + var gl = this.gl; + var color = this.config.backgroundColor; + var pipelines = this.pipelines; + + // Bind custom framebuffer here + gl.clearColor(color.redGL, color.greenGL, color.blueGL, color.alphaGL); + + if (this.config.clearBeforeRender) + { + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT); + } + + for (var key in pipelines) + { + pipelines[key].onPreRender(); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#render + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.GameObjects.GameObject} children - [description] + * @param {number} interpolationPercentage - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + render: function (scene, children, interpolationPercentage, camera) + { + if (this.contextLost) { return; } + + var list = children.list; + var childCount = list.length; + var pipelines = this.pipelines; + + for (var key in pipelines) + { + pipelines[key].onRender(scene, camera); + } + + this.preRenderCamera(camera); + + for (var index = 0; index < childCount; ++index) + { + var child = list[index]; + + if (!child.willRender()) + { + continue; + } + + if (child.blendMode !== this.currentBlendMode) + { + this.setBlendMode(child.blendMode); + } + + if (child.mask) + { + child.mask.preRenderWebGL(this, child, camera); + } + + child.renderWebGL(this, child, interpolationPercentage, camera); + + if (child.mask) + { + child.mask.postRenderWebGL(this, child); + } + } + + this.flush(); + this.setBlendMode(CONST.BlendModes.NORMAL); + this.postRenderCamera(camera); + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#postRender + * @since 3.0.0 + */ + postRender: function () + { + if (this.contextLost) { return; } + + // Unbind custom framebuffer here + + if (this.snapshotState.callback) + { + this.snapshotState.callback(WebGLSnapshot(this.canvas, this.snapshotState.type, this.snapshotState.encoder)); + this.snapshotState.callback = null; + } + + var pipelines = this.pipelines; + + for (var key in pipelines) + { + pipelines[key].onPostRender(); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#snapshot + * @since 3.0.0 + * + * @param {SnapshotCallback} callback - [description] + * @param {string} type - [description] + * @param {float} encoderOptions - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + snapshot: function (callback, type, encoderOptions) + { + this.snapshotState.callback = callback; + this.snapshotState.type = type; + this.snapshotState.encoder = encoderOptions; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#canvasToTexture + * @since 3.0.0 + * + * @param {HTMLCanvasElement} srcCanvas - [description] + * @param {WebGLTexture} dstTexture - [description] + * @param {boolean} shouldReallocate - [description] + * @param {integer} scaleMode - [description] + * + * @return {WebGLTexture} [description] + */ + canvasToTexture: function (srcCanvas, dstTexture) + { + var gl = this.gl; + + if (!dstTexture) + { + var wrapping = gl.CLAMP_TO_EDGE; + + if (IsSizePowerOfTwo(srcCanvas.width, srcCanvas.height)) + { + wrapping = gl.REPEAT; + } + + dstTexture = this.createTexture2D(0, gl.NEAREST, gl.NEAREST, wrapping, wrapping, gl.RGBA, srcCanvas, srcCanvas.width, srcCanvas.height, true); + } + else + { + this.setTexture2D(dstTexture, 0); + + // if (!shouldReallocate && dstTexture.width >= srcCanvas.width || dstTexture.height >= srcCanvas.height) + // { + // gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, srcCanvas.width, srcCanvas.height, gl.RGBA, gl.UNSIGNED_BYTE, srcCanvas); + // } + // else + { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, srcCanvas); + dstTexture.width = srcCanvas.width; + dstTexture.height = srcCanvas.height; + } + + this.setTexture2D(null, 0); + } + + return dstTexture; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setTextureFilter + * @since 3.0.0 + * + * @param {integer} texture - [description] + * @param {integer} filter - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setTextureFilter: function (texture, filter) + { + var gl = this.gl; + var glFilter = [ gl.LINEAR, gl.NEAREST ][filter]; + + this.setTexture2D(texture, 0); + + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, glFilter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, glFilter); + + this.setTexture2D(null, 0); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat1 + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * @param {string} name - [description] + * @param {float} x - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setFloat1: function (program, name, x) + { + this.setProgram(program); + + this.gl.uniform1f(this.gl.getUniformLocation(program, name), x); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat2 + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * @param {string} name - [description] + * @param {float} x - [description] + * @param {float} y - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setFloat2: function (program, name, x, y) + { + this.setProgram(program); + + this.gl.uniform2f(this.gl.getUniformLocation(program, name), x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat3 + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * @param {string} name - [description] + * @param {float} x - [description] + * @param {float} y - [description] + * @param {float} z - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setFloat3: function (program, name, x, y, z) + { + this.setProgram(program); + + this.gl.uniform3f(this.gl.getUniformLocation(program, name), x, y, z); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat4 + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * @param {string} name - [description] + * @param {float} x - [description] + * @param {float} y - [description] + * @param {float} z - [description] + * @param {float} w - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setFloat4: function (program, name, x, y, z, w) + { + this.setProgram(program); + + this.gl.uniform4f(this.gl.getUniformLocation(program, name), x, y, z, w); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt1 + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * @param {string} name - [description] + * @param {integer} x - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setInt1: function (program, name, x) + { + this.setProgram(program); + + this.gl.uniform1i(this.gl.getUniformLocation(program, name), x); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt2 + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * @param {string} name - [description] + * @param {integer} x - [description] + * @param {integer} y - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setInt2: function (program, name, x, y) + { + this.setProgram(program); + + this.gl.uniform2i(this.gl.getUniformLocation(program, name), x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt3 + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * @param {string} name - [description] + * @param {integer} x - [description] + * @param {integer} y - [description] + * @param {integer} z - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setInt3: function (program, name, x, y, z) + { + this.setProgram(program); + + this.gl.uniform3i(this.gl.getUniformLocation(program, name), x, y, z); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt4 + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * @param {string} name - [description] + * @param {integer} x - [description] + * @param {integer} y - [description] + * @param {integer} z - [description] + * @param {integer} w - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setInt4: function (program, name, x, y, z, w) + { + this.setProgram(program); + + this.gl.uniform4i(this.gl.getUniformLocation(program, name), x, y, z, w); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix2 + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * @param {string} name - [description] + * @param {boolean} transpose - [description] + * @param {Float32Array} matrix - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setMatrix2: function (program, name, transpose, matrix) + { + this.setProgram(program); + + this.gl.uniformMatrix2fv(this.gl.getUniformLocation(program, name), transpose, matrix); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix3 + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * @param {string} name - [description] + * @param {boolean} transpose - [description] + * @param {Float32Array} matrix - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setMatrix3: function (program, name, transpose, matrix) + { + this.setProgram(program); + + this.gl.uniformMatrix3fv(this.gl.getUniformLocation(program, name), transpose, matrix); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix4 + * @since 3.0.0 + * + * @param {WebGLProgram} program - [description] + * @param {string} name - [description] + * @param {boolean} transpose - [description] + * @param {Float32Array} matrix - [description] + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + */ + setMatrix4: function (program, name, transpose, matrix) + { + this.setProgram(program); + + this.gl.uniformMatrix4fv(this.gl.getUniformLocation(program, name), transpose, matrix); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#destroy + * @since 3.0.0 + */ + destroy: function () + { + // Clear-up anything that should be cleared :) + for (var key in this.pipelines) + { + this.pipelines[key].destroy(); + delete this.pipelines[key]; + } + + for (var index = 0; index < this.nativeTextures.length; ++index) + { + this.deleteTexture(this.nativeTextures[index]); + delete this.nativeTextures[index]; + } + + if (this.hasExtension('WEBGL_lose_context')) + { + this.getExtension('WEBGL_lose_context').loseContext(); + } + + delete this.gl; + delete this.game; + + this.contextLost = true; + this.extensions = {}; + this.nativeTextures.length = 0; + } + +}); + +module.exports = WebGLRenderer; /***/ }), /* 376 */ /***/ (function(module, exports, __webpack_require__) { -__webpack_require__(377); -__webpack_require__(378); -__webpack_require__(379); -__webpack_require__(380); -__webpack_require__(381); -__webpack_require__(382); -__webpack_require__(383); -__webpack_require__(384); -__webpack_require__(385); +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var modes = __webpack_require__(62); +var CanvasFeatures = __webpack_require__(302); + +/** + * [description] + * + * @function Phaser.Renderer.Canvas.GetBlendModes + * @since 3.0.0 + * + * @return {array} [description] + */ +var GetBlendModes = function () +{ + var output = []; + var useNew = CanvasFeatures.supportNewBlendModes; + + output[modes.NORMAL] = 'source-over'; + output[modes.ADD] = 'lighter'; + output[modes.MULTIPLY] = (useNew) ? 'multiply' : 'source-over'; + output[modes.SCREEN] = (useNew) ? 'screen' : 'source-over'; + output[modes.OVERLAY] = (useNew) ? 'overlay' : 'source-over'; + output[modes.DARKEN] = (useNew) ? 'darken' : 'source-over'; + output[modes.LIGHTEN] = (useNew) ? 'lighten' : 'source-over'; + output[modes.COLOR_DODGE] = (useNew) ? 'color-dodge' : 'source-over'; + output[modes.COLOR_BURN] = (useNew) ? 'color-burn' : 'source-over'; + output[modes.HARD_LIGHT] = (useNew) ? 'hard-light' : 'source-over'; + output[modes.SOFT_LIGHT] = (useNew) ? 'soft-light' : 'source-over'; + output[modes.DIFFERENCE] = (useNew) ? 'difference' : 'source-over'; + output[modes.EXCLUSION] = (useNew) ? 'exclusion' : 'source-over'; + output[modes.HUE] = (useNew) ? 'hue' : 'source-over'; + output[modes.SATURATION] = (useNew) ? 'saturation' : 'source-over'; + output[modes.COLOR] = (useNew) ? 'color' : 'source-over'; + output[modes.LUMINOSITY] = (useNew) ? 'luminosity' : 'source-over'; + + return output; +}; + +module.exports = GetBlendModes; /***/ }), @@ -80629,39 +80746,114 @@ __webpack_require__(385); /***/ (function(module, exports) { /** -* A polyfill for Array.forEach -* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach -*/ -if (!Array.prototype.forEach) + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var roundPixels = false; + +/** + * [description] + * + * @function Phaser.Renderer.Canvas.DrawImage + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} src - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ +var DrawImage = function (src, camera) { - Array.prototype.forEach = function (fun /*, thisArg */) + var ctx = this.currentContext; + var frame = src.frame; + var cd = frame.canvasData; + + // Blend Mode + + if (this.currentBlendMode !== src.blendMode) { - 'use strict'; + this.currentBlendMode = src.blendMode; + ctx.globalCompositeOperation = this.blendModes[src.blendMode]; + } - if (this === void 0 || this === null) - { - throw new TypeError(); - } + // Alpha - var t = Object(this); - var len = t.length >>> 0; + if (this.currentAlpha !== src.alpha) + { + this.currentAlpha = src.alpha; + ctx.globalAlpha = src.alpha; + } - if (typeof fun !== 'function') - { - throw new TypeError(); - } + // Smoothing - var thisArg = arguments.length >= 2 ? arguments[1] : void 0; + if (this.currentScaleMode !== src.scaleMode) + { + this.currentScaleMode = src.scaleMode; - for (var i = 0; i < len; i++) - { - if (i in t) - { - fun.call(thisArg, t[i], i, t); - } - } - }; -} + // ctx[this.smoothProperty] = (source.scaleMode === ScaleModes.LINEAR); + } + + var dx = frame.x; + var dy = frame.y; + + var fx = 1; + var fy = 1; + + if (src.flipX) + { + fx = -1; + dx -= cd.dWidth - src.displayOriginX; + } + else + { + dx -= src.displayOriginX; + } + + if (src.flipY) + { + fy = -1; + dy -= cd.dHeight - src.displayOriginY; + } + else + { + dy -= src.displayOriginY; + } + + var tx = src.x - camera.scrollX * src.scrollFactorX; + var ty = src.y - camera.scrollY * src.scrollFactorY; + + if (roundPixels) + { + tx |= 0; + ty |= 0; + dx |= 0; + dy |= 0; + } + + // Perform Matrix ITRS + + ctx.save(); + + ctx.translate(tx, ty); + + ctx.rotate(src.rotation); + + ctx.scale(src.scaleX, src.scaleY); + ctx.scale(fx, fy); + + ctx.drawImage(frame.source.image, cd.sx, cd.sy, cd.sWidth, cd.sHeight, dx, dy, cd.dWidth, cd.dHeight); + + ctx.restore(); +}; + +// Special return so we can store the config value locally + +module.exports = function (configRoundPixels) +{ + roundPixels = configRoundPixels; + + return DrawImage; +}; /***/ }), @@ -80669,278 +80861,1470 @@ if (!Array.prototype.forEach) /***/ (function(module, exports) { /** -* A polyfill for Array.isArray -*/ -if (!Array.isArray) + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Renderer.Snapshot.Canvas + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - [description] + * @param {string} [type='image/png'] - [description] + * @param {float} [encoderOptions=0.92] - [description] + * + * @return {HTMLImageElement} [description] + */ +var CanvasSnapshot = function (canvas, type, encoderOptions) { - Array.isArray = function (arg) - { - return Object.prototype.toString.call(arg) === '[object Array]'; - }; -} + if (type === undefined) { type = 'image/png'; } + if (encoderOptions === undefined) { encoderOptions = 0.92; } + + var src = canvas.toDataURL(type, encoderOptions); + + var image = new Image(); + + image.src = src; + + return image; +}; + +module.exports = CanvasSnapshot; /***/ }), /* 379 */ /***/ (function(module, exports) { -/* Copyright 2013 Chris Wilson +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at +var roundPixels = false; - http://www.apache.org/licenses/LICENSE-2.0 +/** + * No scaling, anchor, rotation or effects, literally draws the frame directly to the canvas. + * + * @function Phaser.Renderer.Canvas.BlitImage + * @since 3.0.0 + * + * @param {number} dx - The x coordinate to render the Frame to. + * @param {number} dy - The y coordinate to render the Frame to. + * @param {Phaser.Textures.Frame} frame - The Frame to render. + */ +var BlitImage = function (dx, dy, frame) +{ + var ctx = this.currentContext; + var cd = frame.canvasData; - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/* - -This monkeypatch library is intended to be included in projects that are -written to the proper AudioContext spec (instead of webkitAudioContext), -and that use the new naming and proper bits of the Web Audio API (e.g. -using BufferSourceNode.start() instead of BufferSourceNode.noteOn()), but may -have to run on systems that only support the deprecated bits. - -This library should be harmless to include if the browser supports -unprefixed "AudioContext", and/or if it supports the new names. - -The patches this library handles: -if window.AudioContext is unsupported, it will be aliased to webkitAudioContext(). -if AudioBufferSourceNode.start() is unimplemented, it will be routed to noteOn() or -noteGrainOn(), depending on parameters. - -The following aliases only take effect if the new names are not already in place: - -AudioBufferSourceNode.stop() is aliased to noteOff() -AudioContext.createGain() is aliased to createGainNode() -AudioContext.createDelay() is aliased to createDelayNode() -AudioContext.createScriptProcessor() is aliased to createJavaScriptNode() -AudioContext.createPeriodicWave() is aliased to createWaveTable() -OscillatorNode.start() is aliased to noteOn() -OscillatorNode.stop() is aliased to noteOff() -OscillatorNode.setPeriodicWave() is aliased to setWaveTable() -AudioParam.setTargetAtTime() is aliased to setTargetValueAtTime() - -This library does NOT patch the enumerated type changes, as it is -recommended in the specification that implementations support both integer -and string types for AudioPannerNode.panningModel, AudioPannerNode.distanceModel -BiquadFilterNode.type and OscillatorNode.type. - -*/ -(function (global, exports, perf) { - 'use strict'; - - function fixSetTarget(param) { - if (!param) // if NYI, just return - return; - if (!param.setTargetAtTime) - param.setTargetAtTime = param.setTargetValueAtTime; - } - - if (window.hasOwnProperty('webkitAudioContext') && - !window.hasOwnProperty('AudioContext')) { - window.AudioContext = webkitAudioContext; - - if (!AudioContext.prototype.hasOwnProperty('createGain')) - AudioContext.prototype.createGain = AudioContext.prototype.createGainNode; - if (!AudioContext.prototype.hasOwnProperty('createDelay')) - AudioContext.prototype.createDelay = AudioContext.prototype.createDelayNode; - if (!AudioContext.prototype.hasOwnProperty('createScriptProcessor')) - AudioContext.prototype.createScriptProcessor = AudioContext.prototype.createJavaScriptNode; - if (!AudioContext.prototype.hasOwnProperty('createPeriodicWave')) - AudioContext.prototype.createPeriodicWave = AudioContext.prototype.createWaveTable; - - - AudioContext.prototype.internal_createGain = AudioContext.prototype.createGain; - AudioContext.prototype.createGain = function() { - var node = this.internal_createGain(); - fixSetTarget(node.gain); - return node; - }; - - AudioContext.prototype.internal_createDelay = AudioContext.prototype.createDelay; - AudioContext.prototype.createDelay = function(maxDelayTime) { - var node = maxDelayTime ? this.internal_createDelay(maxDelayTime) : this.internal_createDelay(); - fixSetTarget(node.delayTime); - return node; - }; - - AudioContext.prototype.internal_createBufferSource = AudioContext.prototype.createBufferSource; - AudioContext.prototype.createBufferSource = function() { - var node = this.internal_createBufferSource(); - if (!node.start) { - node.start = function ( when, offset, duration ) { - if ( offset || duration ) - this.noteGrainOn( when || 0, offset, duration ); - else - this.noteOn( when || 0 ); - }; - } else { - node.internal_start = node.start; - node.start = function( when, offset, duration ) { - if( typeof duration !== 'undefined' ) - node.internal_start( when || 0, offset, duration ); - else - node.internal_start( when || 0, offset || 0 ); - }; - } - if (!node.stop) { - node.stop = function ( when ) { - this.noteOff( when || 0 ); - }; - } else { - node.internal_stop = node.stop; - node.stop = function( when ) { - node.internal_stop( when || 0 ); - }; - } - fixSetTarget(node.playbackRate); - return node; - }; - - AudioContext.prototype.internal_createDynamicsCompressor = AudioContext.prototype.createDynamicsCompressor; - AudioContext.prototype.createDynamicsCompressor = function() { - var node = this.internal_createDynamicsCompressor(); - fixSetTarget(node.threshold); - fixSetTarget(node.knee); - fixSetTarget(node.ratio); - fixSetTarget(node.reduction); - fixSetTarget(node.attack); - fixSetTarget(node.release); - return node; - }; - - AudioContext.prototype.internal_createBiquadFilter = AudioContext.prototype.createBiquadFilter; - AudioContext.prototype.createBiquadFilter = function() { - var node = this.internal_createBiquadFilter(); - fixSetTarget(node.frequency); - fixSetTarget(node.detune); - fixSetTarget(node.Q); - fixSetTarget(node.gain); - return node; - }; - - if (AudioContext.prototype.hasOwnProperty( 'createOscillator' )) { - AudioContext.prototype.internal_createOscillator = AudioContext.prototype.createOscillator; - AudioContext.prototype.createOscillator = function() { - var node = this.internal_createOscillator(); - if (!node.start) { - node.start = function ( when ) { - this.noteOn( when || 0 ); - }; - } else { - node.internal_start = node.start; - node.start = function ( when ) { - node.internal_start( when || 0); - }; - } - if (!node.stop) { - node.stop = function ( when ) { - this.noteOff( when || 0 ); - }; - } else { - node.internal_stop = node.stop; - node.stop = function( when ) { - node.internal_stop( when || 0 ); - }; - } - if (!node.setPeriodicWave) - node.setPeriodicWave = node.setWaveTable; - fixSetTarget(node.frequency); - fixSetTarget(node.detune); - return node; - }; + if (roundPixels) + { + dx |= 0; + dy |= 0; } - } - if (window.hasOwnProperty('webkitOfflineAudioContext') && - !window.hasOwnProperty('OfflineAudioContext')) { - window.OfflineAudioContext = webkitOfflineAudioContext; - } + ctx.drawImage( + frame.source.image, + cd.sx, + cd.sy, + cd.sWidth, + cd.sHeight, + dx, + dy, + cd.dWidth, + cd.dHeight + ); +}; -}(window)); +// Special return so we can store the config value locally +module.exports = function (configRoundPixels) +{ + roundPixels = configRoundPixels; + + return BlitImage; +}; /***/ }), /* 380 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** - * Also fix for the absent console in IE9 + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -if (!window.console) -{ - window.console = {}; - window.console.log = window.console.assert = function(){}; - window.console.warn = window.console.assert = function(){}; -} + +var BlitImage = __webpack_require__(379); +var CanvasSnapshot = __webpack_require__(378); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(21); +var DrawImage = __webpack_require__(377); +var GetBlendModes = __webpack_require__(376); +var ScaleModes = __webpack_require__(80); +var Smoothing = __webpack_require__(151); + +/** + * @classdesc + * [description] + * + * @class CanvasRenderer + * @memberOf Phaser.Renderer.Canvas + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Phaser Game instance that owns this renderer. + */ +var CanvasRenderer = new Class({ + + initialize: + + function CanvasRenderer (game) + { + /** + * The Phaser Game instance that owns this renderer. + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game = game; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#type + * @type {integer} + * @since 3.0.0 + */ + this.type = CONST.CANVAS; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#drawCount + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.drawCount = 0; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#width + * @type {number} + * @since 3.0.0 + */ + this.width = game.config.width; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#height + * @type {number} + * @since 3.0.0 + */ + this.height = game.config.height; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#config + * @type {RendererConfig} + * @since 3.0.0 + */ + this.config = { + clearBeforeRender: game.config.clearBeforeRender, + pixelArt: game.config.pixelArt, + backgroundColor: game.config.backgroundColor, + resolution: game.config.resolution, + autoResize: game.config.autoResize, + roundPixels: game.config.roundPixels + }; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#scaleMode + * @type {integer} + * @since 3.0.0 + */ + this.scaleMode = (game.config.pixelArt) ? ScaleModes.NEAREST : ScaleModes.LINEAR; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#gameCanvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.gameCanvas = game.canvas; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#gameContext + * @type {CanvasRenderingContext2D} + * @since 3.0.0 + */ + this.gameContext = this.gameCanvas.getContext('2d'); + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#currentContext + * @type {CanvasRenderingContext2D} + * @since 3.0.0 + */ + this.currentContext = this.gameContext; + + /** + * Map to the required function. + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#drawImage + * @type {Phaser.Renderer.Canvas.DrawImage} + * @since 3.0.0 + */ + this.drawImage = DrawImage(this.config.roundPixels); + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#blitImage + * @type {Phaser.Renderer.Canvas.BlitImage} + * @since 3.0.0 + */ + this.blitImage = BlitImage(this.config.roundPixels); + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#blendModes + * @type {array} + * @since 3.0.0 + */ + this.blendModes = GetBlendModes(); + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#currentAlpha + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.currentAlpha = 1; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#currentBlendMode + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.currentBlendMode = 0; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#currentScaleMode + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.currentScaleMode = 0; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotCallback + * @type {?SnapshotCallback} + * @default null + * @since 3.0.0 + */ + this.snapshotCallback = null; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotType + * @type {?string} + * @default null + * @since 3.0.0 + */ + this.snapshotType = null; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotEncoder + * @type {?number} + * @default null + * @since 3.0.0 + */ + this.snapshotEncoder = null; + + this.init(); + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#init + * @since 3.0.0 + */ + init: function () + { + this.resize(this.width, this.height); + }, + + /** + * Resize the main game canvas. + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#resize + * @since 3.0.0 + * + * @param {integer} width - [description] + * @param {integer} height - [description] + */ + resize: function (width, height) + { + var resolution = this.config.resolution; + + this.width = width * resolution; + this.height = height * resolution; + + this.gameCanvas.width = this.width; + this.gameCanvas.height = this.height; + + if (this.config.autoResize) + { + this.gameCanvas.style.width = (this.width / resolution) + 'px'; + this.gameCanvas.style.height = (this.height / resolution) + 'px'; + } + + // Resizing a canvas will reset imageSmoothingEnabled (and probably other properties) + if (this.scaleMode === ScaleModes.NEAREST) + { + Smoothing.disable(this.gameContext); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#onContextLost + * @since 3.0.0 + * + * @param {function} callback - [description] + */ + onContextLost: function () + { + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#onContextRestored + * @since 3.0.0 + * + * @param {function} callback - [description] + */ + onContextRestored: function () + { + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#resetTransform + * @since 3.0.0 + */ + resetTransform: function () + { + this.currentContext.setTransform(1, 0, 0, 1, 0, 0); + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#setBlendMode + * @since 3.0.0 + * + * @param {number} blendMode - [description] + * + * @return {number} [description] + */ + setBlendMode: function (blendMode) + { + if (this.currentBlendMode !== blendMode) + { + this.currentContext.globalCompositeOperation = blendMode; + this.currentBlendMode = blendMode; + } + + return this.currentBlendMode; + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#setAlpha + * @since 3.0.0 + * + * @param {float} alpha - [description] + * + * @return {float} [description] + */ + setAlpha: function (alpha) + { + if (this.currentAlpha !== alpha) + { + this.currentContext.globalAlpha = alpha; + this.currentAlpha = alpha; + } + + return this.currentAlpha; + }, + + /** + * Called at the start of the render loop. + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#preRender + * @since 3.0.0 + */ + preRender: function () + { + var ctx = this.gameContext; + var config = this.config; + + var width = this.width; + var height = this.height; + + if (config.clearBeforeRender) + { + ctx.clearRect(0, 0, width, height); + } + + if (!config.transparent) + { + ctx.fillStyle = config.backgroundColor.rgba; + ctx.fillRect(0, 0, width, height); + } + + this.drawCount = 0; + }, + + /** + * Renders the Scene to the given Camera. + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#render + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.GameObjects.DisplayList} children - [description] + * @param {float} interpolationPercentage - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + render: function (scene, children, interpolationPercentage, camera) + { + var ctx = scene.sys.context; + var scissor = (camera.x !== 0 || camera.y !== 0 || camera.width !== ctx.canvas.width || camera.height !== ctx.canvas.height); + var list = children.list; + var resolution = this.config.resolution; + + this.currentContext = ctx; + + // If the alpha or blend mode didn't change since the last render, then don't set them again (saves 2 ops) + + if (!camera.transparent) + { + ctx.fillStyle = camera.backgroundColor.rgba; + ctx.fillRect(camera.x, camera.y, camera.width, camera.height); + } + + if (this.currentAlpha !== 1) + { + ctx.globalAlpha = 1; + this.currentAlpha = 1; + } + + if (this.currentBlendMode !== 0) + { + ctx.globalCompositeOperation = 'source-over'; + this.currentBlendMode = 0; + } + + this.currentScaleMode = 0; + + this.drawCount += list.length; + + if (scissor) + { + ctx.save(); + ctx.beginPath(); + ctx.rect(camera.x * resolution, camera.y * resolution, camera.width * resolution, camera.height * resolution); + ctx.clip(); + } + + var matrix = camera.matrix.matrix; + + ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + + for (var c = 0; c < list.length; c++) + { + var child = list[c]; + + if (child.mask) + { + child.mask.preRenderCanvas(this, child, camera); + } + + child.renderCanvas(this, child, interpolationPercentage, camera); + + if (child.mask) + { + child.mask.postRenderCanvas(this, child, camera); + } + } + + ctx.setTransform(1, 0, 0, 1, 0, 0); + + if (camera._fadeAlpha > 0 || camera._flashAlpha > 0) + { + ctx.globalCompositeOperation = 'source-over'; + + // fade rendering + ctx.fillStyle = 'rgb(' + (camera._fadeRed * 255) + ',' + (camera._fadeGreen * 255) + ',' + (camera._fadeBlue * 255) + ')'; + ctx.globalAlpha = camera._fadeAlpha; + ctx.fillRect(camera.x, camera.y, camera.width, camera.height); + + // flash rendering + ctx.fillStyle = 'rgb(' + (camera._flashRed * 255) + ',' + (camera._flashGreen * 255) + ',' + (camera._flashBlue * 255) + ')'; + ctx.globalAlpha = camera._flashAlpha; + ctx.fillRect(camera.x, camera.y, camera.width, camera.height); + + ctx.globalAlpha = 1.0; + } + + // Reset the camera scissor + if (scissor) + { + ctx.restore(); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#postRender + * @since 3.0.0 + */ + postRender: function () + { + var ctx = this.gameContext; + + ctx.globalAlpha = 1; + ctx.globalCompositeOperation = 'source-over'; + + this.currentAlpha = 1; + this.currentBlendMode = 0; + + if (this.snapshotCallback) + { + this.snapshotCallback(CanvasSnapshot(this.gameCanvas, this.snapshotType, this.snapshotEncoder)); + this.snapshotCallback = null; + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#snapshot + * @since 3.0.0 + * + * @param {SnapshotCallback} callback - [description] + * @param {string} type - [description] + * @param {number} encoderOptions - [description] + */ + snapshot: function (callback, type, encoderOptions) + { + this.snapshotCallback = callback; + this.snapshotType = type; + this.snapshotEncoder = encoderOptions; + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.gameCanvas = null; + this.gameContext = null; + + this.game = null; + } + +}); + +module.exports = CanvasRenderer; /***/ }), /* 381 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** -* A polyfill for Function.prototype.bind -*/ -if (!Function.prototype.bind) { + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ - /* jshint freeze: false */ - Function.prototype.bind = (function () { +var Class = __webpack_require__(0); - var slice = Array.prototype.slice; +/** + * @classdesc + * A Game Object Animation Controller. + * + * This controller lives as an instance within a Game Object, accessible as `sprite.anims`. + * + * @class Animation + * @memberOf Phaser.GameObjects.Components + * @constructor + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} parent - The Game Object to which this animation controller belongs. + */ +var Animation = new Class({ - return function (thisArg) { + initialize: - var target = this, boundArgs = slice.call(arguments, 1); + function Animation (parent) + { + /** + * The Game Object to which this animation controller belongs. + * + * @name Phaser.GameObjects.Components.Animation#parent + * @type {Phaser.GameObjects.GameObject} + * @since 3.0.0 + */ + this.parent = parent; - if (typeof target !== 'function') + /** + * A reference to the global Animation Manager. + * + * @name Phaser.GameObjects.Components.Animation#animationManager + * @type {Phaser.Animations.AnimationManager} + * @since 3.0.0 + */ + this.animationManager = parent.scene.sys.anims; + + this.animationManager.once('remove', this.remove, this); + + /** + * Is an animation currently playing or not? + * + * @name Phaser.GameObjects.Components.Animation#isPlaying + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isPlaying = false; + + // Reference to the Phaser.Animation object + + /** + * The current Animation loaded into this Animation Controller. + * + * @name Phaser.GameObjects.Components.Animation#currentAnim + * @type {?Phaser.Animations.Animation} + * @default null + * @since 3.0.0 + */ + this.currentAnim = null; + + /** + * The current AnimationFrame being displayed by this Animation Controller. + * + * @name Phaser.GameObjects.Components.Animation#currentFrame + * @type {?Phaser.Animations.AnimationFrame} + * @default null + * @since 3.0.0 + */ + this.currentFrame = null; + + /** + * Time scale factor. + * + * @name Phaser.GameObjects.Components.Animation#_timeScale + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + this._timeScale = 1; + + /** + * The frame rate of playback in frames per second. + * The default is 24 if the `duration` property is `null`. + * + * @name Phaser.GameObjects.Components.Animation#frameRate + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.frameRate = 0; + + /** + * How long the animation should play for. + * If the `frameRate` property has been set then it overrides this value, + * otherwise frameRate is derived from `duration`. + * + * @name Phaser.GameObjects.Components.Animation#duration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.duration = 0; + + /** + * ms per frame, not including frame specific modifiers that may be present in the Animation data. + * + * @name Phaser.GameObjects.Components.Animation#msPerFrame + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.msPerFrame = 0; + + /** + * Skip frames if the time lags, or always advanced anyway? + * + * @name Phaser.GameObjects.Components.Animation#skipMissedFrames + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.skipMissedFrames = true; + + /** + * A delay before starting playback, in seconds. + * + * @name Phaser.GameObjects.Components.Animation#_delay + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._delay = 0; + + /** + * Number of times to repeat the animation (-1 for infinity) + * + * @name Phaser.GameObjects.Components.Animation#_repeat + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._repeat = 0; + + /** + * Delay before the repeat starts, in seconds. + * + * @name Phaser.GameObjects.Components.Animation#_repeatDelay + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._repeatDelay = 0; + + /** + * Should the animation yoyo? (reverse back down to the start) before repeating? + * + * @name Phaser.GameObjects.Components.Animation#_yoyo + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._yoyo = false; + + /** + * Will the playhead move forwards (`true`) or in reverse (`false`) + * + * @name Phaser.GameObjects.Components.Animation#forward + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.forward = true; + + /** + * Internal time overflow accumulator. + * + * @name Phaser.GameObjects.Components.Animation#accumulator + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accumulator = 0; + + /** + * The time point at which the next animation frame will change. + * + * @name Phaser.GameObjects.Components.Animation#nextTick + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.nextTick = 0; + + /** + * An internal counter keeping track of how many repeats are left to play. + * + * @name Phaser.GameObjects.Components.Animation#repeatCounter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.repeatCounter = 0; + + /** + * An internal flag keeping track of pending repeats. + * + * @name Phaser.GameObjects.Components.Animation#pendingRepeat + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.pendingRepeat = false; + + /** + * Is the Animation paused? + * + * @name Phaser.GameObjects.Components.Animation#_paused + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._paused = false; + + /** + * Was the animation previously playing before being paused? + * + * @name Phaser.GameObjects.Components.Animation#_wasPlaying + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._wasPlaying = false; + + /** + * Container for the callback arguments. + * + * @name Phaser.GameObjects.Components.Animation#_callbackArgs + * @type {array} + * @private + * @since 3.0.0 + */ + this._callbackArgs = [ parent, null ]; + + /** + * Container for the update arguments. + * + * @name Phaser.GameObjects.Components.Animation#_updateParams + * @type {array} + * @private + * @since 3.0.0 + */ + this._updateParams = []; + }, + + /** + * Sets the amount of time, in seconds that the animation will be delayed before starting playback. + * + * @method Phaser.GameObjects.Components.Animation#delay + * @since 3.0.0 + * + * @param {number} value - The amount of time, in seconds, to wait before starting playback. + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + delay: function (value) + { + if (value === undefined) + { + return this._delay; + } + else + { + this._delay = value; + + return this; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#delayedPlay + * @since 3.0.0 + * + * @param {number} delay - [description] + * @param {string} key - [description] + * @param {integer} startFrame - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + delayedPlay: function (delay, key, startFrame) + { + this.play(key, true, startFrame); + + this.nextTick += (delay * 1000); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#getCurrentKey + * @since 3.0.0 + * + * @return {string} [description] + */ + getCurrentKey: function () + { + if (this.currentAnim) + { + return this.currentAnim.key; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#load + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {integer} [startFrame=0] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + load: function (key, startFrame) + { + if (startFrame === undefined) { startFrame = 0; } + + if (this.isPlaying) + { + this.stop(); + } + + // Load the new animation in + this.animationManager.load(this, key, startFrame); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#pause + * @since 3.0.0 + * + * @param {Phaser.Animations.Animation} [atFrame] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + pause: function (atFrame) + { + if (!this._paused) + { + this._paused = true; + this._wasPlaying = this.isPlaying; + this.isPlaying = false; + } + + if (atFrame !== undefined) + { + this.updateFrame(atFrame); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#paused + * @since 3.0.0 + * + * @param {boolean} [value] - [description] + * + * @return {(boolean|Phaser.GameObjects.GameObject)} [description] + */ + paused: function (value) + { + if (value !== undefined) + { + // Setter + if (value) { - throw new TypeError(); + return this.pause(); + } + else + { + return this.resume(); + } + } + else + { + return this._paused; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#play + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {boolean} [ignoreIfPlaying=false] - [description] + * @param {integer} [startFrame=0] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + play: function (key, ignoreIfPlaying, startFrame) + { + if (ignoreIfPlaying === undefined) { ignoreIfPlaying = false; } + if (startFrame === undefined) { startFrame = 0; } + + if (ignoreIfPlaying && this.isPlaying && this.currentAnim.key === key) + { + return this; + } + + this.load(key, startFrame); + + var anim = this.currentAnim; + var gameObject = this.parent; + + // Should give us 9,007,199,254,740,991 safe repeats + this.repeatCounter = (this._repeat === -1) ? Number.MAX_VALUE : this._repeat; + + anim.getFirstTick(this); + + this.forward = true; + this.isPlaying = true; + this.pendingRepeat = false; + + if (anim.showOnStart) + { + gameObject.visible = true; + } + + if (anim.onStart) + { + anim.onStart.apply(anim.callbackScope, this._callbackArgs.concat(anim.onStartParams)); + } + + gameObject.setSizeToFrame(); + gameObject.updateDisplayOrigin(); + + return this; + }, + + /** + * Value between 0 and 1. How far this animation is through, ignoring repeats and yoyos. + * If the animation has a non-zero repeat defined, progress and totalProgress will be different + * because progress doesn't include any repeats or repeatDelays whereas totalProgress does. + * + * @method Phaser.GameObjects.Components.Animation#progress + * @since 3.0.0 + * + * @param {number} [value] - [description] + * + * @return {(number|Phaser.GameObjects.GameObject)} [description] + */ + progress: function (value) + { + if (value === undefined) + { + var p = this.currentFrame.progress; + + if (!this.forward) + { + p = 1 - p; } - function bound() { - var args = boundArgs.concat(slice.call(arguments)); - target.apply(this instanceof bound ? this : thisArg, args); + return p; + } + else + { + // TODO: Set progress + + return this; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#remove + * @since 3.0.0 + * + * @param {Phaser.Animations.Animation} [event] - [description] + */ + remove: function (event) + { + if (event === undefined) { event = this.currentAnim; } + + if (this.isPlaying && event.key === this.currentAnim.key) + { + this.stop(); + + var sprite = this.parent; + var frame = this.currentAnim.frames[0]; + + this.currentFrame = frame; + + sprite.texture = frame.frame.texture; + sprite.frame = frame.frame; + } + }, + + /** + * Gets or sets the number of times that the animation should repeat + * after its first iteration. For example, if repeat is 1, the animation will + * play a total of twice (the initial play plus 1 repeat). + * To repeat indefinitely, use -1. repeat should always be an integer. + * + * @method Phaser.GameObjects.Components.Animation#repeat + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {(number|Phaser.GameObjects.GameObject)} [description] + */ + repeat: function (value) + { + if (value === undefined) + { + return this._repeat; + } + else + { + this._repeat = value; + this.repeatCounter = 0; + + return this; + } + }, + + /** + * Gets or sets the amount of time in seconds between repeats. + * For example, if repeat is 2 and repeatDelay is 1, the animation will play initially, + * then wait for 1 second before it repeats, then play again, then wait 1 second again + * before doing its final repeat. + * + * @method Phaser.GameObjects.Components.Animation#repeatDelay + * @since 3.0.0 + * + * @param {number} [value] - [description] + * + * @return {(number|Phaser.GameObjects.GameObject)} [description] + */ + repeatDelay: function (value) + { + if (value === undefined) + { + return this._repeatDelay; + } + else + { + this._repeatDelay = value; + + return this; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#restart + * @since 3.0.0 + * + * @param {boolean} [includeDelay=false] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + restart: function (includeDelay) + { + if (includeDelay === undefined) { includeDelay = false; } + + this.currentAnim.getFirstTick(this, includeDelay); + + this.forward = true; + this.isPlaying = true; + this.pendingRepeat = false; + this._paused = false; + + // Set frame + this.updateFrame(this.currentAnim.frames[0]); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#resume + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationFrame} fromFrame - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + resume: function (fromFrame) + { + if (this._paused) + { + this._paused = false; + this.isPlaying = this._wasPlaying; + } + + if (fromFrame !== undefined) + { + this.updateFrame(fromFrame); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#stop + * @since 3.0.0 + * + * @param {boolean} [dispatchCallbacks=false] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + stop: function (dispatchCallbacks) + { + if (dispatchCallbacks === undefined) { dispatchCallbacks = false; } + + this.isPlaying = false; + + var anim = this.currentAnim; + + if (dispatchCallbacks && anim.onComplete) + { + anim.onComplete.apply(anim.callbackScope, this._callbackArgs.concat(anim.onCompleteParams)); + } + + return this; + }, + + /** + * Scale the time (make it go faster / slower) + * Factor that's used to scale time where 1 = normal speed (the default), 0.5 = half speed, 2 = double speed, etc. + * + * @method Phaser.GameObjects.Components.Animation#timeScale + * @since 3.0.0 + * + * @param {number} [value] - [description] + * + * @return {(number|Phaser.GameObjects.GameObject)} [description] + */ + timeScale: function (value) + { + if (value === undefined) + { + return this._timeScale; + } + else + { + this._timeScale = value; + + return this; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#totalFrames + * @since 3.0.0 + * + * @return {number} [description] + */ + totalFrames: function () + { + return this.currentAnim.frames.length; + }, + + // Value between 0 and 1. How far this animation is through, including things like delays + // repeats, custom frame durations, etc. If the animation is set to repeat -1 it can never + // have a duration, therefore this will return -1. + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#totalProgres + * @since 3.0.0 + */ + totalProgres: function () + { + // TODO + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#update + * @since 3.0.0 + * + * @param {number} timestamp - [description] + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + update: function (timestamp, delta) + { + if (!this.isPlaying || this.currentAnim.paused) + { + return; + } + + this.accumulator += delta * this._timeScale; + + if (this.accumulator >= this.nextTick) + { + this.currentAnim.setFrame(this); + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#updateFrame + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationFrame} animationFrame - [description] + */ + updateFrame: function (animationFrame) + { + var sprite = this.parent; + + this.currentFrame = animationFrame; + + sprite.texture = animationFrame.frame.texture; + sprite.frame = animationFrame.frame; + + if (this.isPlaying) + { + if (animationFrame.setAlpha) + { + sprite.alpha = animationFrame.alpha; } - bound.prototype = (function F(proto) { - if (proto) - { - F.prototype = proto; - } + var anim = this.currentAnim; - if (!(this instanceof F)) - { - /* jshint supernew: true */ - return new F; - } - })(target.prototype); + if (anim.onUpdate) + { + anim.onUpdate.apply(anim.callbackScope, this._updateParams); + } - return bound; - }; - })(); -} + if (animationFrame.onUpdate) + { + animationFrame.onUpdate(sprite, animationFrame); + } + } + }, + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#yoyo + * @since 3.0.0 + * + * @param {boolean} [value] - [description] + * + * @return {(boolean|Phaser.GameObjects.GameObject)} [description] + */ + yoyo: function (value) + { + if (value === undefined) + { + return this._yoyo; + } + else + { + this._yoyo = value; + + return this; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.Animation#destroy + * @since 3.0.0 + */ + destroy: function () + { + // TODO + } + +}); + +module.exports = Animation; /***/ }), /* 382 */ /***/ (function(module, exports) { -// ES6 Math.trunc - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc -if (!Math.trunc) { - Math.trunc = function trunc(x) { - return x < 0 ? Math.ceil(x) : Math.floor(x); - }; -} +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes the given string and reverses it, returning the reversed string. + * For example if given the string `Atari 520ST` it would return `TS025 iratA`. + * + * @function Phaser.Utils.String.ReverseString + * @since 3.0.0 + * + * @param {string} string - The string to be reversed. + * + * @return {string} The reversed string. + */ +var ReverseString = function (string) +{ + return string.split('').reverse().join(''); +}; + +module.exports = ReverseString; /***/ }), @@ -80948,161 +82332,101 @@ if (!Math.trunc) { /***/ (function(module, exports) { /** - * performance.now + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -(function () { - if ('performance' in window === false) +/** + * Takes a string and replaces instances of markers with values in the given array. + * The markers take the form of `%1`, `%2`, etc. I.e.: + * + * `Format("The %1 is worth %2 gold", [ 'Sword', 500 ])` + * + * @function Phaser.Utils.String.Format + * @since 3.0.0 + * + * @param {string} string - The string containing the replacement markers. + * @param {array} values - An array containing values that will replace the markers. If no value exists an empty string is inserted instead. + * + * @return {string} The string containing replaced values. + */ +var Format = function (string, values) +{ + return string.replace(/%([0-9]+)/g, function (s, n) { - window.performance = {}; - } - - // Thanks IE8 - Date.now = (Date.now || function () { - return new Date().getTime(); + return values[Number(n) - 1]; }); +}; - if ('now' in window.performance === false) - { - var nowOffset = Date.now(); - - if (performance.timing && performance.timing.navigationStart) - { - nowOffset = performance.timing.navigationStart; - } - - window.performance.now = function now () - { - return Date.now() - nowOffset; - } - } - -})(); +module.exports = Format; /***/ }), /* 384 */ /***/ (function(module, exports, __webpack_require__) { -/* WEBPACK VAR INJECTION */(function(global) {// References: -// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ -// https://gist.github.com/1579671 -// http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision -// https://gist.github.com/timhall/4078614 -// https://github.com/Financial-Times/polyfill-service/tree/master/polyfills/requestAnimationFrame +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ -// Expected to be used with Browserfiy -// Browserify automatically detects the use of `global` and passes the -// correct reference of `global`, `self`, and finally `window` +/** + * @namespace Phaser.Utils.String + */ -// Date.now -if (!(Date.now && Date.prototype.getTime)) { - Date.now = function now() { - return new Date().getTime(); - }; -} +module.exports = { -// performance.now -if (!(global.performance && global.performance.now)) { - var startTime = Date.now(); - if (!global.performance) { - global.performance = {}; - } - global.performance.now = function () { - return Date.now() - startTime; - }; -} + Format: __webpack_require__(383), + Pad: __webpack_require__(158), + Reverse: __webpack_require__(382), + UppercaseFirst: __webpack_require__(285) -// requestAnimationFrame -var lastTime = Date.now(); -var vendors = ['ms', 'moz', 'webkit', 'o']; +}; -for(var x = 0; x < vendors.length && !global.requestAnimationFrame; ++x) { - global.requestAnimationFrame = global[vendors[x] + 'RequestAnimationFrame']; - global.cancelAnimationFrame = global[vendors[x] + 'CancelAnimationFrame'] || - global[vendors[x] + 'CancelRequestAnimationFrame']; -} - -if (!global.requestAnimationFrame) { - global.requestAnimationFrame = function (callback) { - if (typeof callback !== 'function') { - throw new TypeError(callback + 'is not a function'); - } - - var currentTime = Date.now(), - delay = 16 + lastTime - currentTime; - - if (delay < 0) { - delay = 0; - } - - lastTime = currentTime; - - return setTimeout(function () { - lastTime = Date.now(); - callback(performance.now()); - }, delay); - }; -} - -if (!global.cancelAnimationFrame) { - global.cancelAnimationFrame = function(id) { - clearTimeout(id); - }; -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(169))) /***/ }), /* 385 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** -* Low-budget Float32Array knock-off, suitable for use with P2.js in IE9 -* Source: http://www.html5gamedevs.com/topic/5988-phaser-12-ie9/ -* Cameron Foale (http://www.kibibu.com) -*/ -if (typeof window.Uint32Array !== "function" && typeof window.Uint32Array !== "object") + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clone = __webpack_require__(55); + +/** + * Creates a new Object using all values from obj1. + * + * Then scans obj2. If a property is found in obj2 that *also* exists in obj1, the value from obj2 is used, otherwise the property is skipped. + * + * @function Phaser.Utils.Object.MergeRight + * @since 3.0.0 + * + * @param {object} obj1 - [description] + * @param {object} obj2 - [description] + * + * @return {object} [description] + */ +var MergeRight = function (obj1, obj2) { - var CheapArray = function(type) + var clone = Clone(obj1); + + for (var key in obj2) { - var proto = new Array(); // jshint ignore:line + if (clone.hasOwnProperty(key)) + { + clone[key] = obj2[key]; + } + } - window[type] = function(arg) { + return clone; +}; - if (typeof(arg) === "number") - { - Array.call(this, arg); - this.length = arg; - - for (var i = 0; i < this.length; i++) - { - this[i] = 0; - } - } - else - { - Array.call(this, arg.length); - - this.length = arg.length; - - for (var i = 0; i < this.length; i++) - { - this[i] = arg[i]; - } - } - }; - - window[type].prototype = proto; - window[type].constructor = window[type]; - }; - - CheapArray('Float32Array'); // jshint ignore:line - CheapArray('Uint32Array'); // jshint ignore:line - CheapArray('Uint16Array'); // jshint ignore:line - CheapArray('Int16Array'); // jshint ignore:line - CheapArray('ArrayBuffer'); // jshint ignore:line -} +module.exports = MergeRight; /***/ }), @@ -81118,30 +82442,33 @@ if (typeof window.Uint32Array !== "function" && typeof window.Uint32Array !== "o /** * [description] * - * @function Phaser.Actions.Angle + * @function Phaser.Utils.Object.HasAll * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] * - * @return {array} The array of Game Objects that was passed to this Action. + * @param {object} source - [description] + * @param {string[]} keys - [description] + * + * @return {boolean} [description] */ -var Angle = function (items, value) +var HasAll = function (source, keys) { - for (var i = 0; i < items.length; i++) + for (var i = 0; i < keys.length; i++) { - items[i].angle += value; + if (!source.hasOwnProperty(keys[i])) + { + return false; + } } - return items; + return true; }; -module.exports = Angle; +module.exports = HasAll; /***/ }), /* 387 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -81149,36 +82476,38 @@ module.exports = Angle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var GetValue = __webpack_require__(5); +var Clamp = __webpack_require__(64); + /** * [description] * - * @function Phaser.Actions.Call + * @function Phaser.Utils.Object.GetMinMaxValue * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {function} callback - [description] - * @param {object} thisArg - [description] * - * @return {array} The array of Game Objects that was passed to this Action. + * @param {object} source - [description] + * @param {string} key - [description] + * @param {number} min - [description] + * @param {number} max - [description] + * @param {number} defaultValue - [description] + * + * @return {number} [description] */ -var Call = function (items, callback, thisArg) +var GetMinMaxValue = function (source, key, min, max, defaultValue) { - for (var i = 0; i < items.length; i++) - { - var item = items[i]; + if (defaultValue === undefined) { defaultValue = min; } - callback.call(thisArg, item); - } + var value = GetValue(source, key, defaultValue); - return items; + return Clamp(value, min, max); }; -module.exports = Call; +module.exports = GetMinMaxValue; /***/ }), /* 388 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -81186,51 +82515,27 @@ module.exports = Call; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// compare = Object: -// { -// scaleX: 0.5, -// scaleY: 1 -// } - /** - * [description] - * - * @function Phaser.Actions.GetFirst - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {object} compare - [description] - * @param {integer} index - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. + * @namespace Phaser.Utils.Object */ -var GetFirst = function (items, compare, index) -{ - for (var i = index; i < items.length; i++) - { - var item = items[i]; - var match = true; +module.exports = { - for (var property in compare) - { - if (item[property] !== compare[property]) - { - match = false; - } - } + Clone: __webpack_require__(55), + Extend: __webpack_require__(18), + GetAdvancedValue: __webpack_require__(8), + GetFastValue: __webpack_require__(2), + GetMinMaxValue: __webpack_require__(387), + GetValue: __webpack_require__(5), + HasAll: __webpack_require__(386), + HasAny: __webpack_require__(250), + HasValue: __webpack_require__(70), + IsPlainObject: __webpack_require__(368), + Merge: __webpack_require__(107), + MergeRight: __webpack_require__(385) - if (match) - { - return item; - } - } - - return null; }; -module.exports = GetFirst; - /***/ }), /* 389 */ @@ -81242,108 +82547,32 @@ module.exports = GetFirst; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var AlignIn = __webpack_require__(172); -var CONST = __webpack_require__(173); -var GetValue = __webpack_require__(4); -var NOOP = __webpack_require__(3); -var Zone = __webpack_require__(77); - -var tempZone = new Zone({ sys: { queueDepthSort: NOOP }}, 0, 0, 1, 1); +var SpliceOne = __webpack_require__(176); /** - * [description] + * Removes a random object from the given array and returns it. + * Will return null if there are no array items that fall within the specified range or if there is no item for the randomly chosen index. * - * @function Phaser.Actions.GridAlign + * @function Phaser.Utils.Array.RemoveRandomElement * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {object} options - [description] * - * @return {array} The array of Game Objects that was passed to this Action. + * @param {array} array - The array to removed a random element from. + * @param {integer} [start=0] - The array index to start the search from. + * @param {integer} [length=array.length] - Optional restriction on the number of elements to randomly select from. + * + * @return {object} The random element that was removed, or `null` if there were no array elements that fell within the given range. */ -var GridAlign = function (items, options) +var RemoveRandomElement = function (array, start, length) { - var width = GetValue(options, 'width', -1); - var height = GetValue(options, 'height', -1); - var cellWidth = GetValue(options, 'cellWidth', 1); - var cellHeight = GetValue(options, 'cellHeight', cellWidth); - var position = GetValue(options, 'position', CONST.TOP_LEFT); - var x = GetValue(options, 'x', 0); - var y = GetValue(options, 'y', 0); + if (start === undefined) { start = 0; } + if (length === undefined) { length = array.length; } - // var centerX = GetValue(options, 'centerX', null); - // var centerY = GetValue(options, 'centerY', null); + var randomIndex = start + Math.floor(Math.random() * length); - var cx = 0; - var cy = 0; - var w = (width * cellWidth); - var h = (height * cellHeight); - - // If the Grid is centered on a position then we need to calculate it now - // if (centerX !== null && centerY !== null) - // { - // - // } - - tempZone.setPosition(x, y); - tempZone.setSize(cellWidth, cellHeight); - - for (var i = 0; i < items.length; i++) - { - AlignIn(items[i], tempZone, position); - - if (width === -1) - { - // We keep laying them out horizontally until we've done them all - cy += cellHeight; - tempZone.y += cellHeight; - - if (cy === h) - { - cy = 0; - tempZone.x += cellWidth; - tempZone.y = y; - } - } - else if (height === -1) - { - // We keep laying them out vertically until we've done them all - cx += cellWidth; - tempZone.x += cellWidth; - - if (cx === w) - { - cx = 0; - tempZone.x = x; - tempZone.y += cellHeight; - } - } - else - { - // We keep laying them out until we hit the column limit - cx += cellWidth; - tempZone.x += cellWidth; - - if (cx === w) - { - cx = 0; - cy += cellHeight; - tempZone.x = x; - tempZone.y += cellHeight; - - if (cy === h) - { - // We've hit the column limit, so return, even if there are items left - break; - } - } - } - } - - return items; + return SpliceOne(array, randomIndex); }; -module.exports = GridAlign; +module.exports = RemoveRandomElement; /***/ }), @@ -81356,456 +82585,71 @@ module.exports = GridAlign; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); +var RoundAwayFromZero = __webpack_require__(216); /** - * @classdesc - * [description] + * Create an array of numbers (positive and/or negative) progressing from `start` + * up to but not including `end` by advancing by `step`. * - * @class RandomDataGenerator - * @memberOf Phaser.Math - * @constructor + * If `start` is less than `end` a zero-length range is created unless a negative `step` is specified. + * + * Certain values for `start` and `end` (eg. NaN/undefined/null) are currently coerced to 0; + * for forward compatibility make sure to pass in actual numbers. + * + * @example + * NumberArrayStep(4); + * // => [0, 1, 2, 3] + * + * NumberArrayStep(1, 5); + * // => [1, 2, 3, 4] + * + * NumberArrayStep(0, 20, 5); + * // => [0, 5, 10, 15] + * + * NumberArrayStep(0, -4, -1); + * // => [0, -1, -2, -3] + * + * NumberArrayStep(1, 4, 0); + * // => [1, 1, 1] + * + * NumberArrayStep(0); + * // => [] + * + * @function Phaser.Utils.Array.NumberArrayStep * @since 3.0.0 * - * @param {array} [seeds] - [description] + * @param {number} [start=0] - The start of the range. + * @param {number} [end=null] - The end of the range. + * @param {number} [step=1] - The value to increment or decrement by. + * + * @return {number[]} [description] */ -var RandomDataGenerator = new Class({ +var NumberArrayStep = function (start, end, step) +{ + if (start === undefined) { start = 0; } + if (end === undefined) { end = null; } + if (step === undefined) { step = 1; } - initialize: - - function RandomDataGenerator (seeds) + if (end === null) { - /** - * Internal var. - * - * @name Phaser.Math.RandomDataGenerator#c - * @type {number} - * @default 1 - * @private - * @since 3.0.0 - */ - this.c = 1; - - /** - * Internal var. - * - * @name Phaser.Math.RandomDataGenerator#s0 - * @type {number} - * @default 0 - * @private - * @since 3.0.0 - */ - this.s0 = 0; - - /** - * Internal var. - * - * @name Phaser.Math.RandomDataGenerator#s1 - * @type {number} - * @default 0 - * @private - * @since 3.0.0 - */ - this.s1 = 0; - - /** - * Internal var. - * - * @name Phaser.Math.RandomDataGenerator#s2 - * @type {number} - * @default 0 - * @private - * @since 3.0.0 - */ - this.s2 = 0; - - /** - * Internal var. - * - * @name Phaser.Math.RandomDataGenerator#n - * @type {number} - * @default 0 - * @private - * @since 3.2.0 - */ - this.n = 0; - - /** - * [description] - * - * @name Phaser.Math.RandomDataGenerator#sign - * @type {array} - * @since 3.0.0 - */ - this.signs = [ -1, 1 ]; - - if (seeds) - { - this.init(seeds); - } - }, - - /** - * Private random helper. - * - * @method Phaser.Math.RandomDataGenerator#rnd - * @since 3.0.0 - * @private - * - * @return {number} [description] - */ - rnd: function () - { - var t = 2091639 * this.s0 + this.c * 2.3283064365386963e-10; // 2^-32 - - this.c = t | 0; - this.s0 = this.s1; - this.s1 = this.s2; - this.s2 = t - this.c; - - return this.s2; - }, - - /** - * Internal method that creates a seed hash. - * - * @method Phaser.Math.RandomDataGenerator#hash - * @since 3.0.0 - * @private - * - * @param {[type]} data - [description] - * - * @return {number} The hashed value. - */ - hash: function (data) - { - var h; - var n = this.n; - - data = data.toString(); - - for (var i = 0; i < data.length; i++) - { - n += data.charCodeAt(i); - h = 0.02519603282416938 * n; - n = h >>> 0; - h -= n; - h *= n; - n = h >>> 0; - h -= n; - n += h * 0x100000000;// 2^32 - } - - this.n = n; - - return (n >>> 0) * 2.3283064365386963e-10;// 2^-32 - }, - - /** - * [description] - * - * @method Phaser.Math.RandomDataGenerator#init - * @since 3.0.0 - * - * @param {string|array} seeds - [description] - */ - init: function (seeds) - { - if (typeof seeds === 'string') - { - this.state(seeds); - } - else - { - this.sow(seeds); - } - }, - - /** - * Reset the seed of the random data generator. - * - * _Note_: the seed array is only processed up to the first `undefined` (or `null`) value, should such be present. - * - * @method Phaser.Math.RandomDataGenerator#sow - * @since 3.0.0 - * - * @param {any[]} seeds - The array of seeds: the `toString()` of each value is used. - */ - sow: function (seeds) - { - // Always reset to default seed - this.n = 0xefc8249d; - this.s0 = this.hash(' '); - this.s1 = this.hash(' '); - this.s2 = this.hash(' '); - this.c = 1; - - if (!seeds) - { - return; - } - - // Apply any seeds - for (var i = 0; i < seeds.length && (seeds[i] != null); i++) - { - var seed = seeds[i]; - - this.s0 -= this.hash(seed); - this.s0 += ~~(this.s0 < 0); - this.s1 -= this.hash(seed); - this.s1 += ~~(this.s1 < 0); - this.s2 -= this.hash(seed); - this.s2 += ~~(this.s2 < 0); - } - }, - - /** - * Returns a random integer between 0 and 2^32. - * - * @method Phaser.Math.RandomDataGenerator#integer - * @since 3.0.0 - * - * @return {number} A random integer between 0 and 2^32. - */ - integer: function () - { - // 2^32 - return this.rnd() * 0x100000000; - }, - - /** - * Returns a random real number between 0 and 1. - * - * @method Phaser.Math.RandomDataGenerator#frac - * @since 3.0.0 - * - * @return {number} A random real number between 0 and 1. - */ - frac: function () - { - // 2^-53 - return this.rnd() + (this.rnd() * 0x200000 | 0) * 1.1102230246251565e-16; - }, - - /** - * Returns a random real number between 0 and 2^32. - * - * @method Phaser.Math.RandomDataGenerator#real - * @since 3.0.0 - * - * @return {number} A random real number between 0 and 2^32. - */ - real: function () - { - return this.integer() + this.frac(); - }, - - /** - * Returns a random integer between and including min and max. - * - * @method Phaser.Math.RandomDataGenerator#integerInRange - * @since 3.0.0 - * - * @param {number} min - The minimum value in the range. - * @param {number} max - The maximum value in the range. - * - * @return {number} A random number between min and max. - */ - integerInRange: function (min, max) - { - return Math.floor(this.realInRange(0, max - min + 1) + min); - }, - - /** - * Returns a random integer between and including min and max. - * This method is an alias for RandomDataGenerator.integerInRange. - * - * @method Phaser.Math.RandomDataGenerator#between - * @since 3.0.0 - * - * @param {number} min - The minimum value in the range. - * @param {number} max - The maximum value in the range. - * - * @return {number} A random number between min and max. - */ - between: function (min, max) - { - return Math.floor(this.realInRange(0, max - min + 1) + min); - }, - - /** - * Returns a random real number between min and max. - * - * @method Phaser.Math.RandomDataGenerator#realInRange - * @since 3.0.0 - * - * @param {number} min - The minimum value in the range. - * @param {number} max - The maximum value in the range. - * - * @return {number} A random number between min and max. - */ - realInRange: function (min, max) - { - return this.frac() * (max - min) + min; - }, - - /** - * Returns a random real number between -1 and 1. - * - * @method Phaser.Math.RandomDataGenerator#normal - * @since 3.0.0 - * - * @return {number} A random real number between -1 and 1. - */ - normal: function () - { - return 1 - (2 * this.frac()); - }, - - /** - * Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368 - * - * @method Phaser.Math.RandomDataGenerator#uuid - * @since 3.0.0 - * - * @return {string} A valid RFC4122 version4 ID hex string - */ - uuid: function () - { - var a = ''; - var b = ''; - - for (b = a = ''; a++ < 36; b += ~a % 5 | a * 3 & 4 ? (a ^ 15 ? 8 ^ this.frac() * (a ^ 20 ? 16 : 4) : 4).toString(16) : '-') - { - // eslint-disable-next-line no-empty - } - - return b; - }, - - /** - * Returns a random element from within the given array. - * - * @method Phaser.Math.RandomDataGenerator#pick - * @since 3.0.0 - * - * @param {array} array - The array to pick a random element from. - * - * @return {any} A random member of the array. - */ - pick: function (array) - { - return array[this.integerInRange(0, array.length - 1)]; - }, - - /** - * Returns a sign to be used with multiplication operator. - * - * @method Phaser.Math.RandomDataGenerator#sign - * @since 3.0.0 - * - * @return {number} -1 or +1. - */ - sign: function () - { - return this.pick(this.signs); - }, - - /** - * Returns a random element from within the given array, favoring the earlier entries. - * - * @method Phaser.Math.RandomDataGenerator#weightedPick - * @since 3.0.0 - * - * @param {array} array - The array to pick a random element from. - * - * @return {any} A random member of the array. - */ - weightedPick: function (array) - { - return array[~~(Math.pow(this.frac(), 2) * (array.length - 1) + 0.5)]; - }, - - /** - * Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified. - * - * @method Phaser.Math.RandomDataGenerator#timestamp - * @since 3.0.0 - * - * @param {number} min - The minimum value in the range. - * @param {number} max - The maximum value in the range. - * - * @return {number} A random timestamp between min and max. - */ - timestamp: function (min, max) - { - return this.realInRange(min || 946684800000, max || 1577862000000); - }, - - /** - * Returns a random angle between -180 and 180. - * - * @method Phaser.Math.RandomDataGenerator#angle - * @since 3.0.0 - * - * @return {number} A random number between -180 and 180. - */ - angle: function () - { - return this.integerInRange(-180, 180); - }, - - /** - * Returns a random rotation in radians, between -3.141 and 3.141 - * - * @method Phaser.Math.RandomDataGenerator#rotation - * @since 3.0.0 - * - * @return {number} A random number between -3.141 and 3.141 - */ - rotation: function () - { - return this.realInRange(-3.1415926, 3.1415926); - }, - - /** - * Gets or Sets the state of the generator. This allows you to retain the values - * that the generator is using between games, i.e. in a game save file. - * - * To seed this generator with a previously saved state you can pass it as the - * `seed` value in your game config, or call this method directly after Phaser has booted. - * - * Call this method with no parameters to return the current state. - * - * If providing a state it should match the same format that this method - * returns, which is a string with a header `!rnd` followed by the `c`, - * `s0`, `s1` and `s2` values respectively, each comma-delimited. - * - * @method Phaser.Math.RandomDataGenerator#state - * @since 3.0.0 - * - * @param {string} [state] - Generator state to be set. - * - * @return {string} The current state of the generator. - */ - state: function (state) - { - if (typeof state === 'string' && state.match(/^!rnd/)) - { - state = state.split(','); - - this.c = parseFloat(state[1]); - this.s0 = parseFloat(state[2]); - this.s1 = parseFloat(state[3]); - this.s2 = parseFloat(state[4]); - } - - return [ '!rnd', this.c, this.s0, this.s1, this.s2 ].join(','); + end = start; + start = 0; } -}); + var result = []; -module.exports = RandomDataGenerator; + var total = Math.max(RoundAwayFromZero((end - start) / (step || 1)), 0); + + for (var i = 0; i < total; i++) + { + result.push(start); + start += step; + } + + return result; +}; + +module.exports = NumberArrayStep; /***/ }), @@ -81818,240 +82662,24 @@ module.exports = RandomDataGenerator; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Clamp = __webpack_require__(61); - -// bitmask flag for GameObject.renderMask -var _FLAG = 2; // 0010 +var RotateMatrix = __webpack_require__(81); /** - * Provides methods used for setting the alpha properties of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Alpha + * [description] + * + * @function Phaser.Utils.Array.Matrix.RotateRight * @since 3.0.0 + * + * @param {array} matrix - [description] + * + * @return {array} [description] */ - -var Alpha = { - - _alpha: 1, - - _alphaTL: 1, - _alphaTR: 1, - _alphaBL: 1, - _alphaBR: 1, - - /** - * Clears all alpha values associated with this Game Object. - * Immediately sets the alpha levels back to 1 (fully opaque) - * - * @method Phaser.GameObjects.Components.Alpha#clearAlpha - * @since 3.0.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - clearAlpha: function () - { - return this.setAlpha(1); - }, - - /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * - * If your game is running under WebGL you can optionally specify four different alpha values, each of which - * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. - * - * @method Phaser.GameObjects.Components.Alpha#setAlpha - * @since 3.0.0 - * - * @param {float} [topLeft=1] - The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. - * @param {float} [topRight] - The alpha value used for the top-right of the Game Object. WebGL only. - * @param {float} [bottomLeft] - The alpha value used for the bottom-left of the Game Object. WebGL only. - * @param {float} [bottomRight] - The alpha value used for the bottom-right of the Game Object. WebGL only. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setAlpha: function (topLeft, topRight, bottomLeft, bottomRight) - { - if (topLeft === undefined) { topLeft = 1; } - - // Treat as if there is only one alpha value for the whole Game Object - if (topRight === undefined) - { - this.alpha = topLeft; - } - else - { - this._alphaTL = Clamp(topLeft, 0, 1); - this._alphaTR = Clamp(topRight, 0, 1); - this._alphaBL = Clamp(bottomLeft, 0, 1); - this._alphaBR = Clamp(bottomRight, 0, 1); - } - - return this; - }, - - /** - * The alpha value of the Game Object. - * - * This is a global value, impacting the entire Game Object, not just a region of it. - * - * @name Phaser.GameObjects.Components.Alpha#alpha - * @type {float} - * @since 3.0.0 - */ - alpha: { - - get: function () - { - return this._alpha; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alpha = v; - this._alphaTL = v; - this._alphaTR = v; - this._alphaBL = v; - this._alphaBR = v; - - if (v === 0) - { - this.renderFlags &= ~_FLAG; - } - else - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The alpha value starting from the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Alpha#alphaTopLeft - * @type {float} - * @webglOnly - * @since 3.0.0 - */ - alphaTopLeft: { - - get: function () - { - return this._alphaTL; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alphaTL = v; - - if (v !== 0) - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The alpha value starting from the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Alpha#alphaTopRight - * @type {float} - * @webglOnly - * @since 3.0.0 - */ - alphaTopRight: { - - get: function () - { - return this._alphaTR; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alphaTR = v; - - if (v !== 0) - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The alpha value starting from the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Alpha#alphaBottomLeft - * @type {float} - * @webglOnly - * @since 3.0.0 - */ - alphaBottomLeft: { - - get: function () - { - return this._alphaBL; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alphaBL = v; - - if (v !== 0) - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The alpha value starting from the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Alpha#alphaBottomRight - * @type {float} - * @webglOnly - * @since 3.0.0 - */ - alphaBottomRight: { - - get: function () - { - return this._alphaBR; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alphaBR = v; - - if (v !== 0) - { - this.renderFlags |= _FLAG; - } - } - - } - +var RotateRight = function (matrix) +{ + return RotateMatrix(matrix, -90); }; -module.exports = Alpha; +module.exports = RotateRight; /***/ }), @@ -82064,110 +82692,29 @@ module.exports = Alpha; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BlendModes = __webpack_require__(45); +var RotateMatrix = __webpack_require__(81); /** - * Provides methods used for setting the blend mode of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.BlendMode + * [description] + * + * @function Phaser.Utils.Array.Matrix.RotateLeft * @since 3.0.0 + * + * @param {array} matrix - [description] + * + * @return {array} [description] */ - -var BlendMode = { - - _blendMode: BlendModes.NORMAL, - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - * - * @name Phaser.GameObjects.Components.BlendMode#blendMode - * @type {integer|string} - * @since 3.0.0 - */ - blendMode: { - - get: function () - { - return this._blendMode; - }, - - set: function (value) - { - if (typeof value === 'string') - { - value = BlendModes[value]; - } - - value | 0; - - if (value >= 0) - { - this._blendMode = value; - } - } - - }, - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - * - * @method Phaser.GameObjects.Components.BlendMode#setBlendMode - * @since 3.0.0 - * - * @param {string|integer} value - The BlendMode value. Either a string or a CONST. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setBlendMode: function (value) - { - this.blendMode = value; - - return this; - } - +var RotateLeft = function (matrix) +{ + return RotateMatrix(matrix, 90); }; -module.exports = BlendMode; +module.exports = RotateLeft; /***/ }), /* 393 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -82175,81 +82722,24 @@ module.exports = BlendMode; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var RotateMatrix = __webpack_require__(81); + /** - * Provides methods used for setting the blend mode of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.ComputedSize + * [description] + * + * @function Phaser.Utils.Array.Matrix.Rotate180 * @since 3.0.0 + * + * @param {array} matrix - [description] + * + * @return {array} [description] */ - -var ComputedSize = { - - /** - * The native (un-scaled) width of this Game Object. - * - * @name Phaser.GameObjects.Components.ComputedSize#width - * @type {number} - * @since 3.0.0 - */ - width: 0, - - /** - * The native (un-scaled) height of this Game Object. - * - * @name Phaser.GameObjects.Components.ComputedSize#height - * @type {number} - * @since 3.0.0 - */ - height: 0, - - /** - * The displayed width of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Components.ComputedSize#displayWidth - * @type {number} - * @since 3.0.0 - */ - displayWidth: { - - get: function () - { - return this.scaleX * this.width; - }, - - set: function (value) - { - this.scaleX = value / this.width; - } - - }, - - /** - * The displayed height of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Components.ComputedSize#displayHeight - * @type {number} - * @since 3.0.0 - */ - displayHeight: { - - get: function () - { - return this.scaleY * this.height; - }, - - set: function (value) - { - this.scaleY = value / this.height; - } - - } - +var Rotate180 = function (matrix) +{ + return RotateMatrix(matrix, 180); }; -module.exports = ComputedSize; +module.exports = Rotate180; /***/ }), @@ -82263,77 +82753,21 @@ module.exports = ComputedSize; */ /** - * Provides methods used for setting the depth of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Depth + * [description] + * + * @function Phaser.Utils.Array.Matrix.ReverseRows * @since 3.0.0 + * + * @param {array} matrix - [description] + * + * @return {array} [description] */ - -var Depth = { - - _depth: 0, - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * - * @name Phaser.GameObjects.Components.Depth#depth - * @type {number} - * @since 3.0.0 - */ - depth: { - - get: function () - { - return this._depth; - }, - - set: function (value) - { - this.scene.sys.queueDepthSort(); - this._depth = value; - } - - }, - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * - * @method Phaser.GameObjects.Components.Depth#setDepth - * @since 3.0.0 - * - * @param {integer} value - The depth of this Game Object. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setDepth: function (value) - { - if (value === undefined) { value = 0; } - - this.depth = value; - - return this; - } - +var ReverseRows = function (matrix) +{ + return matrix.reverse(); }; -module.exports = Depth; +module.exports = ReverseRows; /***/ }), @@ -82347,141 +82781,26 @@ module.exports = Depth; */ /** - * Provides methods used for visually flipping a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Flip + * [description] + * + * @function Phaser.Utils.Array.Matrix.ReverseColumns * @since 3.0.0 + * + * @param {array} matrix - [description] + * + * @return {array} [description] */ - -var Flip = { - - /** - * The horizontally flipped state of the Game Object. - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * - * @name Phaser.GameObjects.Components.Flip#flipX - * @type {boolean} - * @default false - * @since 3.0.0 - */ - flipX: false, - - /** - * The vertically flipped state of the Game Object. - * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * - * @name Phaser.GameObjects.Components.Flip#flipY - * @type {boolean} - * @default false - * @since 3.0.0 - */ - flipY: false, - - /** - * Toggles the horizontal flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#toggleFlipX - * @since 3.0.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - toggleFlipX: function () +var ReverseColumns = function (matrix) +{ + for (var i = 0; i < matrix.length; i++) { - this.flipX = !this.flipX; - - return this; - }, - - /** - * Toggles the vertical flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#toggleFlipY - * @since 3.0.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - toggleFlipY: function () - { - this.flipY = !this.flipY; - - return this; - }, - - /** - * Sets the horizontal flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#setFlipX - * @since 3.0.0 - * - * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setFlipX: function (value) - { - this.flipX = value; - - return this; - }, - - /** - * Sets the vertical flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#setFlipY - * @since 3.0.0 - * - * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setFlipY: function (value) - { - this.flipY = value; - - return this; - }, - - /** - * Sets the horizontal and vertical flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#setFlip - * @since 3.0.0 - * - * @param {boolean} x - The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * @param {boolean} y - The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setFlip: function (x, y) - { - this.flipX = x; - this.flipY = y; - - return this; - }, - - /** - * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. - * - * @method Phaser.GameObjects.Components.Flip#resetFlip - * @since 3.0.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - resetFlip: function () - { - this.flipX = false; - this.flipY = false; - - return this; + matrix[i].reverse(); } + return matrix; }; -module.exports = Flip; +module.exports = ReverseColumns; /***/ }), @@ -82494,193 +82813,80 @@ module.exports = Flip; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Rectangle = __webpack_require__(8); -var RotateAround = __webpack_require__(188); -var Vector2 = __webpack_require__(6); +var Pad = __webpack_require__(158); +var CheckMatrix = __webpack_require__(109); + +// Generates a string (which you can pass to console.log) from the given +// Array Matrix. /** - * Provides methods used for obtaining the bounds of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.GetBounds + * [description] + * + * @function Phaser.Utils.Array.Matrix.MatrixToString * @since 3.0.0 + * + * @param {array} matrix - [description] + * + * @return {string} [description] */ +var MatrixToString = function (matrix) +{ + var str = ''; -var GetBounds = { - - /** - * Gets the center coordinate of this Game Object, regardless of origin. - * - * @method Phaser.GameObjects.Components.GetBounds#getCenter - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2|object} [output] - An object to store the values in. If not provided a new Vector2 will be created. - * - * @return {Phaser.Math.Vector2|object} The values stored in the output object. - */ - getCenter: function (output) + if (!CheckMatrix(matrix)) { - if (output === undefined) { output = new Vector2(); } - - output.x = this.x - (this.displayWidth * this.originX) + (this.displayWidth / 2); - output.y = this.y - (this.displayHeight * this.originY) + (this.displayHeight / 2); - - return output; - }, - - /** - * Gets the top-left corner coordinate of this Game Object, regardless of origin. - * - * @method Phaser.GameObjects.Components.GetBounds#getTopLeft - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2|object} [output] - An object to store the values in. If not provided a new Vector2 will be created. - * - * @return {Phaser.Math.Vector2|object} The values stored in the output object. - */ - getTopLeft: function (output) - { - if (output === undefined) { output = new Vector2(); } - - output.x = this.x - (this.displayWidth * this.originX); - output.y = this.y - (this.displayHeight * this.originY); - - if (this.rotation !== 0) - { - RotateAround(output, this.x, this.y, this.rotation); - } - - return output; - }, - - /** - * Gets the top-right corner coordinate of this Game Object, regardless of origin. - * - * @method Phaser.GameObjects.Components.GetBounds#getTopRight - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2|object} [output] - An object to store the values in. If not provided a new Vector2 will be created. - * - * @return {Phaser.Math.Vector2|object} The values stored in the output object. - */ - getTopRight: function (output) - { - if (output === undefined) { output = new Vector2(); } - - output.x = (this.x - (this.displayWidth * this.originX)) + this.displayWidth; - output.y = this.y - (this.displayHeight * this.originY); - - if (this.rotation !== 0) - { - RotateAround(output, this.x, this.y, this.rotation); - } - - return output; - }, - - /** - * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. - * - * @method Phaser.GameObjects.Components.GetBounds#getBottomLeft - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2|object} [output] - An object to store the values in. If not provided a new Vector2 will be created. - * - * @return {Phaser.Math.Vector2|object} The values stored in the output object. - */ - getBottomLeft: function (output) - { - if (output === undefined) { output = new Vector2(); } - - output.x = this.x - (this.displayWidth * this.originX); - output.y = (this.y - (this.displayHeight * this.originY)) + this.displayHeight; - - if (this.rotation !== 0) - { - RotateAround(output, this.x, this.y, this.rotation); - } - - return output; - }, - - /** - * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. - * - * @method Phaser.GameObjects.Components.GetBounds#getBottomRight - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2|object} [output] - An object to store the values in. If not provided a new Vector2 will be created. - * - * @return {Phaser.Math.Vector2|object} The values stored in the output object. - */ - getBottomRight: function (output) - { - if (output === undefined) { output = new Vector2(); } - - output.x = (this.x - (this.displayWidth * this.originX)) + this.displayWidth; - output.y = (this.y - (this.displayHeight * this.originY)) + this.displayHeight; - - if (this.rotation !== 0) - { - RotateAround(output, this.x, this.y, this.rotation); - } - - return output; - }, - - /** - * Gets the bounds of this Game Object, regardless of origin. - * The values are stored and returned in a Rectangle, or Rectangle-like, object. - * - * @method Phaser.GameObjects.Components.GetBounds#getBounds - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle|object} [output] - An object to store the values in. If not provided a new Rectangle will be created. - * - * @return {Phaser.Geom.Rectangle|object} The values stored in the output object. - */ - getBounds: function (output) - { - if (output === undefined) { output = new Rectangle(); } - - // We can use the output object to temporarily store the x/y coords in: - - this.getTopLeft(output); - - var TLx = output.x; - var TLy = output.y; - - this.getTopRight(output); - - var TRx = output.x; - var TRy = output.y; - - this.getBottomLeft(output); - - var BLx = output.x; - var BLy = output.y; - - this.getBottomRight(output); - - var BRx = output.x; - var BRy = output.y; - - output.x = Math.min(TLx, TRx, BLx, BRx); - output.y = Math.min(TLy, TRy, BLy, BRy); - output.width = Math.max(TLx, TRx, BLx, BRx) - output.x; - output.height = Math.max(TLy, TRy, BLy, BRy) - output.y; - - return output; + return str; } + for (var r = 0; r < matrix.length; r++) + { + for (var c = 0; c < matrix[r].length; c++) + { + var cell = matrix[r][c].toString(); + + if (cell !== 'undefined') + { + str += Pad(cell, 2); + } + else + { + str += '?'; + } + + if (c < matrix[r].length - 1) + { + str += ' |'; + } + } + + if (r < matrix.length - 1) + { + str += '\n'; + + for (var i = 0; i < matrix[r].length; i++) + { + str += '---'; + + if (i < matrix[r].length - 1) + { + str += '+'; + } + } + + str += '\n'; + } + + } + + return str; }; -module.exports = GetBounds; +module.exports = MatrixToString; /***/ }), /* 397 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -82689,282 +82895,23 @@ module.exports = GetBounds; */ /** - * Provides methods used for getting and setting the transform values of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.MatrixStack - * @since 3.2.0 + * @namespace Phaser.Utils.Array.Matrix */ -var MatrixStack = { +module.exports = { - /** - * [description] - * - * @name Phaser.GameObjects.Components.MatrixStack#matrixStack - * @type {Float32Array} - * @private - * @since 3.2.0 - */ - matrixStack: null, - - /** - * [description] - * - * @name Phaser.GameObjects.Components.MatrixStack#currentMatrix - * @type {Float32Array} - * @private - * @since 3.2.0 - */ - currentMatrix: null, - - /** - * [description] - * - * @name Phaser.GameObjects.Components.MatrixStack#currentMatrixIndex - * @type {integer} - * @private - * @since 3.2.0 - */ - currentMatrixIndex: 0, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.MatrixStack#initMatrixStack - * @since 3.2.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - initMatrixStack: function () - { - this.matrixStack = new Float32Array(6000); // up to 1000 matrices - this.currentMatrix = new Float32Array([ 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 ]); - this.currentMatrixIndex = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.MatrixStack#save - * @since 3.2.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - save: function () - { - if (this.currentMatrixIndex >= this.matrixStack.length) { return this; } - - var matrixStack = this.matrixStack; - var currentMatrix = this.currentMatrix; - var currentMatrixIndex = this.currentMatrixIndex; - this.currentMatrixIndex += 6; - - matrixStack[currentMatrixIndex + 0] = currentMatrix[0]; - matrixStack[currentMatrixIndex + 1] = currentMatrix[1]; - matrixStack[currentMatrixIndex + 2] = currentMatrix[2]; - matrixStack[currentMatrixIndex + 3] = currentMatrix[3]; - matrixStack[currentMatrixIndex + 4] = currentMatrix[4]; - matrixStack[currentMatrixIndex + 5] = currentMatrix[5]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.MatrixStack#restore - * @since 3.2.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - restore: function () - { - if (this.currentMatrixIndex <= 0) { return this; } - - this.currentMatrixIndex -= 6; - - var matrixStack = this.matrixStack; - var currentMatrix = this.currentMatrix; - var currentMatrixIndex = this.currentMatrixIndex; - - currentMatrix[0] = matrixStack[currentMatrixIndex + 0]; - currentMatrix[1] = matrixStack[currentMatrixIndex + 1]; - currentMatrix[2] = matrixStack[currentMatrixIndex + 2]; - currentMatrix[3] = matrixStack[currentMatrixIndex + 3]; - currentMatrix[4] = matrixStack[currentMatrixIndex + 4]; - currentMatrix[5] = matrixStack[currentMatrixIndex + 5]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.MatrixStack#loadIdentity - * @since 3.2.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - loadIdentity: function () - { - this.setTransform(1.0, 0.0, 0.0, 1.0, 0.0, 0.0); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.MatrixStack#transform - * @since 3.2.0 - * - * @param {number} a - [description] - * @param {number} b - [description] - * @param {number} c - [description] - * @param {number} d - [description] - * @param {number} tx - [description] - * @param {number} ty - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - transform: function (a, b, c, d, tx, ty) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - var m4 = currentMatrix[4]; - var m5 = currentMatrix[5]; - - currentMatrix[0] = m0 * a + m2 * b; - currentMatrix[1] = m1 * a + m3 * b; - currentMatrix[2] = m0 * c + m2 * d; - currentMatrix[3] = m1 * c + m3 * d; - currentMatrix[4] = m0 * tx + m2 * ty + m4; - currentMatrix[5] = m1 * tx + m3 * ty + m5; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.MatrixStack#setTransform - * @since 3.2.0 - * - * @param {number} a - [description] - * @param {number} b - [description] - * @param {number} c - [description] - * @param {number} d - [description] - * @param {number} tx - [description] - * @param {number} ty - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setTransform: function (a, b, c, d, tx, ty) - { - var currentMatrix = this.currentMatrix; - - currentMatrix[0] = a; - currentMatrix[1] = b; - currentMatrix[2] = c; - currentMatrix[3] = d; - currentMatrix[4] = tx; - currentMatrix[5] = ty; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.MatrixStack#translate - * @since 3.2.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - translate: function (x, y) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - var m4 = currentMatrix[4]; - var m5 = currentMatrix[5]; - - currentMatrix[4] = m0 * x + m2 * y + m4; - currentMatrix[5] = m1 * x + m3 * y + m5; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.MatrixStack#scale - * @since 3.2.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - scale: function (x, y) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - - currentMatrix[0] = m0 * x; - currentMatrix[1] = m1 * x; - currentMatrix[2] = m2 * y; - currentMatrix[3] = m3 * y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.MatrixStack#rotate - * @since 3.2.0 - * - * @param {number} t - The angle of rotation, in radians. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - rotate: function (t) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - var st = Math.sin(t); - var ct = Math.cos(t); - - currentMatrix[0] = m0 * ct + m2 * st; - currentMatrix[1] = m1 * ct + m3 * st; - currentMatrix[2] = m0 * -st + m2 * ct; - currentMatrix[3] = m1 * -st + m3 * ct; - - return this; - } + CheckMatrix: __webpack_require__(109), + MatrixToString: __webpack_require__(396), + ReverseColumns: __webpack_require__(395), + ReverseRows: __webpack_require__(394), + Rotate180: __webpack_require__(393), + RotateLeft: __webpack_require__(392), + RotateMatrix: __webpack_require__(81), + RotateRight: __webpack_require__(391), + TransposeMatrix: __webpack_require__(177) }; -module.exports = MatrixStack; - /***/ }), /* 398 */ @@ -82977,196 +82924,41 @@ module.exports = MatrixStack; */ /** - * Provides methods used for getting and setting the origin of a Game Object. - * Values are normalized, given in the range 0 to 1. - * Display values contain the calculated pixel values. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Origin + * [description] + * + * @function Phaser.Utils.Array.FindClosestInSorted * @since 3.0.0 + * + * @param {number} value - The value to search for in the array. + * @param {array} array - The array to search, which must be sorted. + * + * @return {number} The nearest value found in the array. */ - -var Origin = { - - /** - * A property indicating that a Game Object has this component. - * - * @name Phaser.GameObjects.Components.Origin#_originComponent - * @type {boolean} - * @private - * @default true - * @since 3.2.0 - */ - _originComponent: true, - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - * - * @name Phaser.GameObjects.Components.Origin#originX - * @type {float} - * @default 0.5 - * @since 3.0.0 - */ - originX: 0.5, - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - * - * @name Phaser.GameObjects.Components.Origin#originY - * @type {float} - * @default 0.5 - * @since 3.0.0 - */ - originY: 0.5, - - // private + read only - _displayOriginX: 0, - _displayOriginY: 0, - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - * - * @name Phaser.GameObjects.Components.Origin#displayOriginX - * @type {float} - * @since 3.0.0 - */ - displayOriginX: { - - get: function () - { - return this._displayOriginX; - }, - - set: function (value) - { - this._displayOriginX = value; - this.originX = value / this.width; - } - - }, - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - * - * @name Phaser.GameObjects.Components.Origin#displayOriginY - * @type {float} - * @since 3.0.0 - */ - displayOriginY: { - - get: function () - { - return this._displayOriginY; - }, - - set: function (value) - { - this._displayOriginY = value; - this.originY = value / this.height; - } - - }, - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * - * @method Phaser.GameObjects.Components.Origin#setOrigin - * @since 3.0.0 - * - * @param {number} [x=0.5] - The horizontal origin value. - * @param {number} [y=0.5] - The vertical origin value. If not defined it will be set to the value of `x`. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setOrigin: function (x, y) +var FindClosestInSorted = function (value, array) +{ + if (!array.length) { - if (x === undefined) { x = 0.5; } - if (y === undefined) { y = x; } - - this.originX = x; - this.originY = y; - - return this.updateDisplayOrigin(); - }, - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - * - * @method Phaser.GameObjects.Components.Origin#setOriginFromFrame - * @since 3.0.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setOriginFromFrame: function () + return NaN; + } + else if (array.length === 1 || value < array[0]) { - if (!this.frame || !this.frame.customPivot) - { - return this.setOrigin(); - } - else - { - this.originX = this.frame.pivotX; - this.originY = this.frame.pivotY; - } - - return this.updateDisplayOrigin(); - }, - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * - * @method Phaser.GameObjects.Components.Origin#setDisplayOrigin - * @since 3.0.0 - * - * @param {number} [x=0] - The horizontal display origin value. - * @param {number} [y=0] - The vertical display origin value. If not defined it will be set to the value of `x`. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setDisplayOrigin: function (x, y) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = x; } - - this.displayOriginX = x; - this.displayOriginY = y; - - return this; - }, - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - * - * @method Phaser.GameObjects.Components.Origin#updateDisplayOrigin - * @since 3.0.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - updateDisplayOrigin: function () - { - this._displayOriginX = Math.round(this.originX * this.width); - this._displayOriginY = Math.round(this.originY * this.height); - - return this; + return array[0]; } + var i = 1; + + while (array[i] < value) + { + i++; + } + + var low = array[i - 1]; + var high = (i < array.length) ? array[i] : Number.POSITIVE_INFINITY; + + return ((high - value) <= (value - low)) ? high : low; }; -module.exports = Origin; +module.exports = FindClosestInSorted; /***/ }), @@ -83179,70 +82971,31 @@ module.exports = Origin; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var ScaleModes = __webpack_require__(63); - /** - * Provides methods used for getting and setting the scale of a Game Object. - * - * @name Phaser.GameObjects.Components.ScaleMode - * @since 3.0.0 + * @namespace Phaser.Utils.Array */ -var ScaleMode = { +module.exports = { - _scaleMode: ScaleModes.DEFAULT, - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * - * @name Phaser.GameObjects.Components.ScaleMode#scaleMode - * @type {integer} - * @since 3.0.0 - */ - scaleMode: { - - get: function () - { - return this._scaleMode; - }, - - set: function (value) - { - if (value === ScaleModes.LINEAR || value === ScaleModes.NEAREST) - { - this._scaleMode = value; - } - } - - }, - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * - * @method Phaser.GameObjects.Components.ScaleMode#setScaleMode - * @since 3.0.0 - * - * @param {integer} value - The Scale Mode to be used by this Game Object. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setScaleMode: function (value) - { - this.scaleMode = value; - - return this; - } + FindClosestInSorted: __webpack_require__(398), + GetRandomElement: __webpack_require__(132), + Matrix: __webpack_require__(397), + NumberArray: __webpack_require__(222), + NumberArrayStep: __webpack_require__(390), + QuickSelect: __webpack_require__(203), + Range: __webpack_require__(264), + RemoveRandomElement: __webpack_require__(389), + RotateLeft: __webpack_require__(346), + RotateRight: __webpack_require__(345), + Shuffle: __webpack_require__(102), + SpliceOne: __webpack_require__(176) }; -module.exports = ScaleMode; - /***/ }), /* 400 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -83251,90 +83004,21 @@ module.exports = ScaleMode; */ /** - * Provides methods used for getting and setting the Scroll Factor of a Game Object. - * - * @name Phaser.GameObjects.Components.ScrollFactor - * @since 3.0.0 + * @namespace Phaser.Utils */ -var ScrollFactor = { +module.exports = { - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorX - * @type {number} - * @default 1 - * @since 3.0.0 - */ - scrollFactorX: 1, - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorY - * @type {number} - * @default 1 - * @since 3.0.0 - */ - scrollFactorY: 1, - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * @method Phaser.GameObjects.Components.ScrollFactor#setScrollFactor - * @since 3.0.0 - * - * @param {number} x - The horizontal scroll factor of this Game Object. - * @param {number} [y] - The vertical scroll factor of this Game Object. If not set it will use the `x` value. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setScrollFactor: function (x, y) - { - if (y === undefined) { y = x; } - - this.scrollFactorX = x; - this.scrollFactorY = y; - - return this; - } + Array: __webpack_require__(399), + Objects: __webpack_require__(388), + String: __webpack_require__(384) }; -module.exports = ScrollFactor; - /***/ }), /* 401 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -83342,150 +83026,651 @@ module.exports = ScrollFactor; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var NumberTweenBuilder = __webpack_require__(180); +var PluginManager = __webpack_require__(12); +var TimelineBuilder = __webpack_require__(179); +var TWEEN_CONST = __webpack_require__(68); +var TweenBuilder = __webpack_require__(82); + +// Phaser.Tweens.TweenManager + /** - * Provides methods used for getting and setting the size of a Game Object. - * - * @name Phaser.GameObjects.Components.Size + * @classdesc + * [description] + * + * @class TweenManager + * @memberOf Phaser.Tweens + * @constructor * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] */ +var TweenManager = new Class({ -var Size = { + initialize: - /** - * A property indicating that a Game Object has this component. - * - * @name Phaser.GameObjects.Components.Size#_sizeComponent - * @type {boolean} - * @private - * @default true - * @since 3.2.0 - */ - _sizeComponent: true, + function TweenManager (scene) + { + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; - /** - * The native (un-scaled) width of this Game Object. - * - * @name Phaser.GameObjects.Components.Size#width - * @type {number} - * @since 3.0.0 - */ - width: 0, + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; - /** - * The native (un-scaled) height of this Game Object. - * - * @name Phaser.GameObjects.Components.Size#height - * @type {number} - * @since 3.0.0 - */ - height: 0, - - /** - * The displayed width of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Components.Size#displayWidth - * @type {number} - * @since 3.0.0 - */ - displayWidth: { - - get: function () + if (!scene.sys.settings.isBooted) { - return this.scaleX * this.frame.realWidth; - }, - - set: function (value) - { - this.scaleX = value / this.frame.realWidth; + scene.sys.events.once('boot', this.boot, this); } + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#_add + * @type {array} + * @private + * @since 3.0.0 + */ + this._add = []; + + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#_pending + * @type {array} + * @private + * @since 3.0.0 + */ + this._pending = []; + + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#_active + * @type {array} + * @private + * @since 3.0.0 + */ + this._active = []; + + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#_destroy + * @type {array} + * @private + * @since 3.0.0 + */ + this._destroy = []; + + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#_toProcess + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + this._toProcess = 0; }, /** - * The displayed height of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Components.Size#displayHeight - * @type {number} + * [description] + * + * @method Phaser.Tweens.TweenManager#boot * @since 3.0.0 */ - displayHeight: { + boot: function () + { + var eventEmitter = this.systems.events; - get: function () - { - return this.scaleY * this.frame.realHeight; - }, + eventEmitter.on('preupdate', this.preUpdate, this); + eventEmitter.on('update', this.update, this); + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); - set: function (value) + this.timeScale = 1; + }, + + /** + * Create a Tween Timeline and return it, but do NOT add it to the active or pending Tween lists. + * + * @method Phaser.Tweens.TweenManager#createTimeline + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.Tweens.Timeline} [description] + */ + createTimeline: function (config) + { + return TimelineBuilder(this, config); + }, + + /** + * Create a Tween Timeline and add it to the active Tween list/ + * + * @method Phaser.Tweens.TweenManager#timeline + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.Tweens.Timeline} [description] + */ + timeline: function (config) + { + var timeline = TimelineBuilder(this, config); + + if (!timeline.paused) { - this.scaleY = value / this.frame.realHeight; + this._add.push(timeline); + + this._toProcess++; } + return timeline; }, /** - * Sets the size of this Game Object to be that of the given Frame. - * - * @method Phaser.GameObjects.Components.Size#setSizeToFrame + * Create a Tween and return it, but do NOT add it to the active or pending Tween lists. + * + * @method Phaser.Tweens.TweenManager#create * @since 3.0.0 * - * @param {Phaser.Textures.Frame} frame - The frame to base the size of this Game Object on. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. + * @param {object} config - [description] + * + * @return {Phaser.Tweens.Tween} [description] */ - setSizeToFrame: function (frame) + create: function (config) { - if (frame === undefined) { frame = this.frame; } + return TweenBuilder(this, config); + }, - this.width = frame.realWidth; - this.height = frame.realHeight; + /** + * Create a Tween and add it to the active Tween list. + * + * @method Phaser.Tweens.TweenManager#add + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.Tweens.Tween} [description] + */ + add: function (config) + { + var tween = TweenBuilder(this, config); + + this._add.push(tween); + + this._toProcess++; + + return tween; + }, + + /** + * Add an existing tween into the active Tween list. + * + * @method Phaser.Tweens.TweenManager#existing + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * + * @return {Phaser.Tweens.TweenManager} This Tween Manager object. + */ + existing: function (tween) + { + this._add.push(tween); + + this._toProcess++; return this; }, /** - * Sets the size of this Game Object. - * - * @method Phaser.GameObjects.Components.Size#setSize + * Create a Tween and add it to the active Tween list. + * + * @method Phaser.Tweens.TweenManager#addCounter * @since 3.0.0 * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. + * @param {object} config - [description] + * + * @return {Phaser.Tweens.Tween} [description] */ - setSize: function (width, height) + addCounter: function (config) { - this.width = width; - this.height = height; + var tween = NumberTweenBuilder(this, config); + + this._add.push(tween); + + this._toProcess++; + + return tween; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#preUpdate + * @since 3.0.0 + */ + preUpdate: function () + { + if (this._toProcess === 0) + { + // Quick bail + return; + } + + var list = this._destroy; + var active = this._active; + var i; + var tween; + + // Clear the 'destroy' list + for (i = 0; i < list.length; i++) + { + tween = list[i]; + + // Remove from the 'active' array + var idx = active.indexOf(tween); + + if (idx !== -1) + { + tween.state = TWEEN_CONST.REMOVED; + active.splice(idx, 1); + } + } + + list.length = 0; + + // Process the addition list + // This stops callbacks and out of sync events from populating the active array mid-way during the update + + list = this._add; + + for (i = 0; i < list.length; i++) + { + tween = list[i]; + + if (tween.state === TWEEN_CONST.PENDING_ADD) + { + // Return true if the Tween should be started right away, otherwise false + if (tween.init()) + { + tween.play(); + + this._active.push(tween); + } + else + { + this._pending.push(tween); + } + } + } + + list.length = 0; + + this._toProcess = 0; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#update + * @since 3.0.0 + * + * @param {number} timestamp - [description] + * @param {number} delta - [description] + */ + update: function (timestamp, delta) + { + // Process active tweens + var list = this._active; + var tween; + + // Scale the delta + delta *= this.timeScale; + + for (var i = 0; i < list.length; i++) + { + tween = list[i]; + + // If Tween.update returns 'true' then it means it has completed, + // so move it to the destroy list + if (tween.update(timestamp, delta)) + { + this._destroy.push(tween); + this._toProcess++; + } + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#makeActive + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * + * @return {Phaser.Tweens.TweenManager} This Tween Manager object. + */ + makeActive: function (tween) + { + if (this._add.indexOf(tween) !== -1 || this._active.indexOf(tween) !== -1) + { + return; + } + + var idx = this._pending.indexOf(tween); + + if (idx !== -1) + { + this._pending.splice(idx, 1); + } + + this._add.push(tween); + + tween.state = TWEEN_CONST.PENDING_ADD; + + this._toProcess++; return this; }, /** - * Sets the display size of this Game Object. - * Calling this will adjust the scale. - * - * @method Phaser.GameObjects.Components.Size#setDisplaySize + * Passes all Tweens to the given callback. + * + * @method Phaser.Tweens.TweenManager#each * @since 3.0.0 * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. + * @param {function} callback - [description] + * @param {object} [scope] - [description] + * @param {...*} [arguments] - [description] */ - setDisplaySize: function (width, height) + each: function (callback, scope) { - this.displayWidth = width; - this.displayHeight = height; + var args = [ null ]; + + for (var i = 1; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (var texture in this.list) + { + args[0] = this.list[texture]; + + callback.apply(scope, args); + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#getAllTweens + * @since 3.0.0 + * + * @return {Phaser.Tweens.Tween[]} [description] + */ + getAllTweens: function () + { + var list = this._active; + var output = []; + + for (var i = 0; i < list.length; i++) + { + output.push(list[i]); + } + + return output; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#getGlobalTimeScale + * @since 3.0.0 + * + * @return {number} [description] + */ + getGlobalTimeScale: function () + { + return this.timeScale; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#getTweensOf + * @since 3.0.0 + * + * @param {(object|array)} target - [description] + * + * @return {Phaser.Tweens.Tween[]} [description] + */ + getTweensOf: function (target) + { + var list = this._active; + var tween; + var output = []; + var i; + + if (Array.isArray(target)) + { + for (i = 0; i < list.length; i++) + { + tween = list[i]; + + for (var t = 0; t < target.length; i++) + { + if (tween.hasTarget(target[t])) + { + output.push(tween); + } + } + } + } + else + { + for (i = 0; i < list.length; i++) + { + tween = list[i]; + + if (tween.hasTarget(target)) + { + output.push(tween); + } + } + } + + return output; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#isTweening + * @since 3.0.0 + * + * @param {object} target - [description] + * + * @return {boolean} [description] + */ + isTweening: function (target) + { + var list = this._active; + var tween; + + for (var i = 0; i < list.length; i++) + { + tween = list[i]; + + if (tween.hasTarget(target) && tween.isPlaying()) + { + return true; + } + } + + return false; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#killAll + * @since 3.0.0 + * + * @return {Phaser.Tweens.TweenManager} [description] + */ + killAll: function () + { + var tweens = this.getAllTweens(); + + for (var i = 0; i < tweens.length; i++) + { + tweens[i].stop(); + } return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#killTweensOf + * @since 3.0.0 + * + * @param {(object|array)} target - [description] + * + * @return {Phaser.Tweens.TweenManager} [description] + */ + killTweensOf: function (target) + { + var tweens = this.getTweensOf(target); + + for (var i = 0; i < tweens.length; i++) + { + tweens[i].stop(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#pauseAll + * @since 3.0.0 + * + * @return {Phaser.Tweens.TweenManager} [description] + */ + pauseAll: function () + { + var list = this._active; + + for (var i = 0; i < list.length; i++) + { + list[i].pause(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#resumeAll + * @since 3.0.0 + * + * @return {Phaser.Tweens.TweenManager} [description] + */ + resumeAll: function () + { + var list = this._active; + + for (var i = 0; i < list.length; i++) + { + list[i].resume(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#setGlobalTimeScale + * @since 3.0.0 + * + * @param {float} value - [description] + * + * @return {Phaser.Tweens.TweenManager} [description] + */ + setGlobalTimeScale: function (value) + { + this.timeScale = value; + + return this; + }, + + /** + * Scene that owns this manager is shutting down. + * + * @method Phaser.Tweens.TweenManager#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.killAll(); + + this._add = []; + this._pending = []; + this._active = []; + this._destroy = []; + + this._toProcess = 0; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); } -}; +}); -module.exports = Size; +PluginManager.register('TweenManager', TweenManager, 'tweens'); + +module.exports = TweenManager; /***/ }), @@ -83498,119 +83683,71 @@ module.exports = Size; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// bitmask flag for GameObject.renderMask -var _FLAG = 8; // 1000 +// RESERVED properties that a Tween config object uses -/** - * Provides methods used for getting and setting the texture of a Game Object. - * - * @name Phaser.GameObjects.Components.Texture - * @since 3.0.0 - */ +// completeDelay: The time the tween will wait before the onComplete event is dispatched once it has completed +// delay: The time the tween will wait before it first starts +// duration: The duration of the tween +// ease: The ease function used by the tween +// easeParams: The parameters to go with the ease function (if any) +// flipX: flip X the GameObject on tween end +// flipY: flip Y the GameObject on tween end// hold: The time the tween will pause before running a yoyo +// hold: The time the tween will pause before running a yoyo +// loop: The time the tween will pause before starting either a yoyo or returning to the start for a repeat +// loopDelay: +// offset: Used when the Tween is part of a Timeline +// paused: Does the tween start in a paused state, or playing? +// props: The properties being tweened by the tween +// repeat: The number of times the tween will repeat itself (a value of 1 means the tween will play twice, as it repeated once) +// repeatDelay: The time the tween will pause for before starting a repeat. The tween holds in the start state. +// targets: The targets the tween is updating. +// useFrames: Use frames or milliseconds? +// yoyo: boolean - Does the tween reverse itself (yoyo) when it reaches the end? -var Texture = { - - /** - * The Texture this Game Object is using to render with. - * - * @name Phaser.GameObjects.Components.Texture#texture - * @type {Phaser.Textures.Texture} - * @since 3.0.0 - */ - texture: null, - - /** - * The Texture Frame this Game Object is using to render with. - * - * @name Phaser.GameObjects.Components.Texture#frame - * @type {Phaser.Textures.Frame} - * @since 3.0.0 - */ - frame: null, - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * - * @method Phaser.GameObjects.Components.Texture#setTexture - * @since 3.0.0 - * - * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. - * @param {string|integer} [frame] - The name or index of the frame within the Texture. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setTexture: function (key, frame) - { - this.texture = this.scene.sys.textures.get(key); - - return this.setFrame(frame); - }, - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * It can be either a string or an index. - * - * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * - * @method Phaser.GameObjects.Components.Texture#setFrame - * @since 3.0.0 - * - * @param {string|integer} frame - The name or index of the frame within the Texture. - * @param {boolean} [updateSize=true] - Should this call adjust the size of the Game Object? - * @param {boolean} [updateOrigin=true] - Should this call adjust the origin of the Game Object? - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setFrame: function (frame, updateSize, updateOrigin) - { - if (updateSize === undefined) { updateSize = true; } - if (updateOrigin === undefined) { updateOrigin = true; } - - this.frame = this.texture.get(frame); - - if (!this.frame.cutWidth || !this.frame.cutHeight) - { - this.renderFlags &= ~_FLAG; - } - else - { - this.renderFlags |= _FLAG; - } - - if (this._sizeComponent && updateSize) - { - this.setSizeToFrame(); - } - - if (this._originComponent && updateOrigin) - { - if (this.frame.customPivot) - { - this.setOrigin(this.frame.pivotX, this.frame.pivotY); - } - else - { - this.updateDisplayOrigin(); - } - } - - return this; - } - -}; - -module.exports = Texture; +module.exports = [ + 'callbackScope', + 'completeDelay', + 'delay', + 'duration', + 'ease', + 'easeParams', + 'flipX', + 'flipY', + 'hold', + 'loop', + 'loopDelay', + 'offset', + 'onComplete', + 'onCompleteParams', + 'onCompleteScope', + 'onLoop', + 'onLoopParams', + 'onLoopScope', + 'onRepeat', + 'onRepeatParams', + 'onRepeatScope', + 'onStart', + 'onStartParams', + 'onStartScope', + 'onUpdate', + 'onUpdateParams', + 'onUpdateScope', + 'onYoyo', + 'onYoyoParams', + 'onYoyoScope', + 'paused', + 'props', + 'repeat', + 'repeatDelay', + 'targets', + 'useFrames', + 'yoyo' +]; /***/ }), /* 403 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -83618,194 +83755,29 @@ module.exports = Texture; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetColor = function (value) -{ - return (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16); -}; - /** - * Provides methods used for setting the tint of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Tint - * @webglOnly - * @since 3.0.0 + * @namespace Phaser.Tweens.Builders */ -var Tint = { +module.exports = { - // 0: topLeft, 1: topRight, 2: bottomLeft, 3: bottomRight - _tintTL: 16777215, - _tintTR: 16777215, - _tintBL: 16777215, - _tintBR: 16777215, - - /** - * Clears all tint values associated with this Game Object. - * Immediately sets the alpha levels back to 0xffffff (no tint) - * - * @method Phaser.GameObjects.Components.Tint#clearTint - * @webglOnly - * @since 3.0.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - clearTint: function () - { - this.setTint(0xffffff); - - return this; - }, - - /** - * Sets the tint values for this Game Object. - * - * @method Phaser.GameObjects.Components.Tint#setTint - * @webglOnly - * @since 3.0.0 - * - * @param {integer} [topLeft=0xffffff] - The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. - * @param {integer} [topRight] - The tint being applied to the top-right of the Game Object. - * @param {integer} [bottomLeft] - The tint being applied to the bottom-left of the Game Object. - * @param {integer} [bottomRight] - The tint being applied to the bottom-right of the Game Object. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setTint: function (topLeft, topRight, bottomLeft, bottomRight) - { - if (topLeft === undefined) { topLeft = 0xffffff; } - - if (topRight === undefined) - { - topRight = topLeft; - bottomLeft = topLeft; - bottomRight = topLeft; - } - - this._tintTL = GetColor(topLeft); - this._tintTR = GetColor(topRight); - this._tintBL = GetColor(bottomLeft); - this._tintBR = GetColor(bottomRight); - - return this; - }, - - /** - * The tint value being applied to the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tintTopLeft - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tintTopLeft: { - - get: function () - { - return this._tintTL; - }, - - set: function (value) - { - this._tintTL = GetColor(value); - } - - }, - - /** - * The tint value being applied to the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tintTopRight - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tintTopRight: { - - get: function () - { - return this._tintTR; - }, - - set: function (value) - { - this._tintTR = GetColor(value); - } - - }, - - /** - * The tint value being applied to the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tintBottomLeft - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tintBottomLeft: { - - get: function () - { - return this._tintBL; - }, - - set: function (value) - { - this._tintBL = GetColor(value); - } - - }, - - /** - * The tint value being applied to the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tintBottomRight - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tintBottomRight: { - - get: function () - { - return this._tintBR; - }, - - set: function (value) - { - this._tintBR = GetColor(value); - } - - }, - - /** - * The tint value being applied to the whole of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tint - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tint: { - - set: function (value) - { - this.setTint(value, value, value, value); - } - } + GetBoolean: __webpack_require__(69), + GetEaseFunction: __webpack_require__(71), + GetNewValue: __webpack_require__(83), + GetProps: __webpack_require__(182), + GetTargets: __webpack_require__(114), + GetTweens: __webpack_require__(181), + GetValueOp: __webpack_require__(113), + NumberTweenBuilder: __webpack_require__(180), + TimelineBuilder: __webpack_require__(179), + TweenBuilder: __webpack_require__(82) }; -module.exports = Tint; - /***/ }), /* 404 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -83813,2280 +83785,34 @@ module.exports = Tint; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Default Game Object JSON export -// Is extended further by Game Object specific implementations +var CONST = __webpack_require__(68); +var Extend = __webpack_require__(18); -var ToJSON = function (gameObject) -{ - var out = { - name: gameObject.name, - type: gameObject.type, - x: gameObject.x, - y: gameObject.y, - depth: gameObject.depth, - scale: { - x: gameObject.scaleX, - y: gameObject.scaleY - }, - origin: { - x: gameObject.originX, - y: gameObject.originY - }, - flipX: gameObject.flipX, - flipY: gameObject.flipY, - rotation: gameObject.rotation, - alpha: gameObject.alpha, - visible: gameObject.visible, - scaleMode: gameObject.scaleMode, - blendMode: gameObject.blendMode, - textureKey: '', - frameKey: '', - data: {} - }; +/** + * @namespace Phaser.Tweens + */ - if (gameObject.texture) - { - out.textureKey = gameObject.texture.key; - out.frameKey = gameObject.frame.name; - } +var Tweens = { + + Builders: __webpack_require__(403), + + TweenManager: __webpack_require__(401), + Tween: __webpack_require__(111), + TweenData: __webpack_require__(110), + Timeline: __webpack_require__(178) - return out; }; -module.exports = ToJSON; +// Merge in the consts +Tweens = Extend(false, Tweens, CONST); + +module.exports = Tweens; /***/ }), /* 405 */ /***/ (function(module, exports, __webpack_require__) { -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH_CONST = __webpack_require__(16); -var WrapAngle = __webpack_require__(163); -var WrapAngleDegrees = __webpack_require__(164); - -// global bitmask flag for GameObject.renderMask (used by Scale) -var _FLAG = 4; // 0100 - -/** - * Provides methods used for getting and setting the position, scale and rotation of a Game Object. - * - * @name Phaser.GameObjects.Components.Transform - * @since 3.0.0 - */ - -var Transform = { - - // "private" properties - _scaleX: 1, - _scaleY: 1, - _rotation: 0, - - /** - * The x position of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - x: 0, - - /** - * The y position of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - y: 0, - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - * - * @name Phaser.GameObjects.Components.Transform#z - * @type {number} - * @default 0 - * @since 3.0.0 - */ - z: 0, - - /** - * The w position of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#w - * @type {number} - * @default 0 - * @since 3.0.0 - */ - w: 0, - - /** - * The horizontal scale of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#scaleX - * @type {number} - * @default 1 - * @since 3.0.0 - */ - scaleX: { - - get: function () - { - return this._scaleX; - }, - - set: function (value) - { - this._scaleX = value; - - if (this._scaleX === 0) - { - this.renderFlags &= ~_FLAG; - } - else - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The vertical scale of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#scaleY - * @type {number} - * @default 1 - * @since 3.0.0 - */ - scaleY: { - - get: function () - { - return this._scaleY; - }, - - set: function (value) - { - this._scaleY = value; - - if (this._scaleY === 0) - { - this.renderFlags &= ~_FLAG; - } - else - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The angle of this Game Object as expressed in degrees. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - * - * @name Phaser.GameObjects.Components.Transform#angle - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - angle: { - - get: function () - { - return WrapAngleDegrees(this._rotation * MATH_CONST.RAD_TO_DEG); - }, - - set: function (value) - { - // value is in degrees - this.rotation = WrapAngleDegrees(value) * MATH_CONST.DEG_TO_RAD; - } - }, - - /** - * The angle of this Game Object in radians. - * - * If you prefer to work in degrees, see the `angle` property instead. - * - * @name Phaser.GameObjects.Components.Transform#rotation - * @type {number} - * @default 1 - * @since 3.0.0 - */ - rotation: { - - get: function () - { - return this._rotation; - }, - - set: function (value) - { - // value is in radians - this._rotation = WrapAngle(value); - } - }, - - /** - * Sets the position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setPosition - * @since 3.0.0 - * - * @param {number} [x=0] - The x position of this Game Object. - * @param {number} [y] - The y position of this Game Object. If not set it will use the `x` value. - * @param {number} [z=0] - The z position of this Game Object. - * @param {number} [w=0] - The w position of this Game Object. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setPosition: function (x, y, z, w) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = x; } - if (z === undefined) { z = 0; } - if (w === undefined) { w = 0; } - - this.x = x; - this.y = y; - this.z = z; - this.w = w; - - return this; - }, - - /** - * Sets the rotation of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setRotation - * @since 3.0.0 - * - * @param {number} [radians=0] - The rotation of this Game Object, in radians. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setRotation: function (radians) - { - if (radians === undefined) { radians = 0; } - - this.rotation = radians; - - return this; - }, - - /** - * Sets the angle of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setAngle - * @since 3.0.0 - * - * @param {number} [degrees=0] - The rotation of this Game Object, in degrees. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setAngle: function (degrees) - { - if (degrees === undefined) { degrees = 0; } - - this.angle = degrees; - - return this; - }, - - /** - * Sets the scale of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setScale - * @since 3.0.0 - * - * @param {number} x - The horizontal scale of this Game Object. - * @param {number} [y] - The vertical scale of this Game Object. If not set it will use the `x` value. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setScale: function (x, y) - { - if (x === undefined) { x = 1; } - if (y === undefined) { y = x; } - - this.scaleX = x; - this.scaleY = y; - - return this; - }, - - /** - * Sets the x position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setX - * @since 3.0.0 - * - * @param {number} [value=0] - The x position of this Game Object. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setX: function (value) - { - if (value === undefined) { value = 0; } - - this.x = value; - - return this; - }, - - /** - * Sets the y position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setY - * @since 3.0.0 - * - * @param {number} [value=0] - The y position of this Game Object. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setY: function (value) - { - if (value === undefined) { value = 0; } - - this.y = value; - - return this; - }, - - /** - * Sets the z position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setZ - * @since 3.0.0 - * - * @param {number} [value=0] - The z position of this Game Object. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setZ: function (value) - { - if (value === undefined) { value = 0; } - - this.z = value; - - return this; - }, - - /** - * Sets the w position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setW - * @since 3.0.0 - * - * @param {number} [value=0] - The w position of this Game Object. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setW: function (value) - { - if (value === undefined) { value = 0; } - - this.w = value; - - return this; - } - -}; - -module.exports = Transform; - - -/***/ }), -/* 406 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// bitmask flag for GameObject.renderMask -var _FLAG = 1; // 0001 - -/** - * Provides methods used for setting the visibility of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Visible - * @since 3.0.0 - */ - -var Visible = { - - _visible: true, - - /** - * The visible state of the Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - * - * @name Phaser.GameObjects.Components.Visible#visible - * @type {boolean} - * @since 3.0.0 - */ - visible: { - - get: function () - { - return this._visible; - }, - - set: function (value) - { - if (value) - { - this._visible = true; - this.renderFlags |= _FLAG; - } - else - { - this._visible = false; - this.renderFlags &= ~_FLAG; - } - } - - }, - - /** - * Sets the visibility of this Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - * - * @method Phaser.GameObjects.Components.Visible#setVisible - * @since 3.0.0 - * - * @param {boolean} value - The visible state of the Game Object. - * - * @return {Phaser.GameObjects.GameObject} This Game Object instance. - */ - setVisible: function (value) - { - this.visible = value; - - return this; - } -}; - -module.exports = Visible; - - -/***/ }), -/* 407 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.IncAlpha - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var IncAlpha = function (items, value) -{ - for (var i = 0; i < items.length; i++) - { - items[i].alpha += value; - } - - return items; -}; - -module.exports = IncAlpha; - - -/***/ }), -/* 408 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.IncX - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var IncX = function (items, value) -{ - for (var i = 0; i < items.length; i++) - { - items[i].x += value; - } - - return items; -}; - -module.exports = IncX; - - -/***/ }), -/* 409 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.IncXY - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var IncXY = function (items, x, y) -{ - for (var i = 0; i < items.length; i++) - { - items[i].x += x; - items[i].y += y; - } - - return items; -}; - -module.exports = IncXY; - - -/***/ }), -/* 410 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.IncY - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var IncY = function (items, value) -{ - for (var i = 0; i < items.length; i++) - { - items[i].y += value; - } - - return items; -}; - -module.exports = IncY; - - -/***/ }), -/* 411 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.PlaceOnCircle - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Circle} circle - [description] - * @param {number} [startAngle=0] - [description] - * @param {number} [endAngle=6.28] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var PlaceOnCircle = function (items, circle, startAngle, endAngle) -{ - if (startAngle === undefined) { startAngle = 0; } - if (endAngle === undefined) { endAngle = 6.28; } - - var angle = startAngle; - var angleStep = (endAngle - startAngle) / items.length; - - for (var i = 0; i < items.length; i++) - { - items[i].x = circle.x + (circle.radius * Math.cos(angle)); - items[i].y = circle.y + (circle.radius * Math.sin(angle)); - - angle += angleStep; - } - - return items; -}; - -module.exports = PlaceOnCircle; - - -/***/ }), -/* 412 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.PlaceOnEllipse - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Ellipse} ellipse - [description] - * @param {number} [startAngle=0] - [description] - * @param {number} [endAngle=6.28] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var PlaceOnEllipse = function (items, ellipse, startAngle, endAngle) -{ - if (startAngle === undefined) { startAngle = 0; } - if (endAngle === undefined) { endAngle = 6.28; } - - var angle = startAngle; - var angleStep = (endAngle - startAngle) / items.length; - - var a = ellipse.width / 2; - var b = ellipse.height / 2; - - for (var i = 0; i < items.length; i++) - { - items[i].x = ellipse.x + a * Math.cos(angle); - items[i].y = ellipse.y + b * Math.sin(angle); - - angle += angleStep; - } - - return items; -}; - -module.exports = PlaceOnEllipse; - - -/***/ }), -/* 413 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetPoints = __webpack_require__(109); - -/** - * [description] - * - * @function Phaser.Actions.PlaceOnLine - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Line} line - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var PlaceOnLine = function (items, line) -{ - var points = GetPoints(line, items.length); - - for (var i = 0; i < items.length; i++) - { - var item = items[i]; - var point = points[i]; - - item.x = point.x; - item.y = point.y; - } - - return items; -}; - -module.exports = PlaceOnLine; - - -/***/ }), -/* 414 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MarchingAnts = __webpack_require__(191); -var RotateLeft = __webpack_require__(192); -var RotateRight = __webpack_require__(193); - -// Place the items in the array around the perimeter of the given rectangle. - -// Placement starts from the top-left of the rectangle, and proceeds in a -// clockwise direction. If the shift parameter is given you can offset where -// placement begins. - -/** - * [description] - * - * @function Phaser.Actions.PlaceOnRectangle - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {integer} [shift=1] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var PlaceOnRectangle = function (items, rect, shift) -{ - if (shift === undefined) { shift = 0; } - - var points = MarchingAnts(rect, false, items.length); - - if (shift > 0) - { - RotateLeft(points, shift); - } - else if (shift < 0) - { - RotateRight(points, Math.abs(shift)); - } - - for (var i = 0; i < items.length; i++) - { - items[i].x = points[i].x; - items[i].y = points[i].y; - } - - return items; -}; - -module.exports = PlaceOnRectangle; - - -/***/ }), -/* 415 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// var GetPointsOnLine = require('../geom/line/GetPointsOnLine'); -var BresenhamPoints = __webpack_require__(194); - -/** - * [description] - * - * @function Phaser.Actions.PlaceOnTriangle - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} [stepRate=1] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var PlaceOnTriangle = function (items, triangle, stepRate) -{ - var p1 = BresenhamPoints({ x1: triangle.x1, y1: triangle.y1, x2: triangle.x2, y2: triangle.y2 }, stepRate); - var p2 = BresenhamPoints({ x1: triangle.x2, y1: triangle.y2, x2: triangle.x3, y2: triangle.y3 }, stepRate); - var p3 = BresenhamPoints({ x1: triangle.x3, y1: triangle.y3, x2: triangle.x1, y2: triangle.y1 }, stepRate); - - // Remove overlaps - p1.pop(); - p2.pop(); - p3.pop(); - - p1 = p1.concat(p2, p3); - - var step = p1.length / items.length; - var p = 0; - - for (var i = 0; i < items.length; i++) - { - var item = items[i]; - var point = p1[Math.floor(p)]; - - item.x = point.x; - item.y = point.y; - - p += step; - } - - return items; -}; - -module.exports = PlaceOnTriangle; - - -/***/ }), -/* 416 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.PlayAnimation - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {string} key - [description] - * @param {string|integer} [startFrame] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var PlayAnimation = function (items, key, startFrame) -{ - for (var i = 0; i < items.length; i++) - { - items[i].anims.play(key, startFrame); - } - - return items; -}; - -module.exports = PlayAnimation; - - -/***/ }), -/* 417 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Random = __webpack_require__(106); - -/** - * [description] - * - * @function Phaser.Actions.RandomCircle - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Circle} circle - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var RandomCircle = function (items, circle) -{ - for (var i = 0; i < items.length; i++) - { - Random(circle, items[i]); - } - - return items; -}; - -module.exports = RandomCircle; - - -/***/ }), -/* 418 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Random = __webpack_require__(110); - -/** - * [description] - * - * @function Phaser.Actions.RandomEllipse - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Ellipse} ellipse - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var RandomEllipse = function (items, ellipse) -{ - for (var i = 0; i < items.length; i++) - { - Random(ellipse, items[i]); - } - - return items; -}; - -module.exports = RandomEllipse; - - -/***/ }), -/* 419 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Random = __webpack_require__(111); - -/** - * [description] - * - * @function Phaser.Actions.RandomLine - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Line} line - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var RandomLine = function (items, line) -{ - for (var i = 0; i < items.length; i++) - { - Random(line, items[i]); - } - - return items; -}; - -module.exports = RandomLine; - - -/***/ }), -/* 420 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Random = __webpack_require__(108); - -/** - * [description] - * - * @function Phaser.Actions.RandomRectangle - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var RandomRectangle = function (items, rect) -{ - for (var i = 0; i < items.length; i++) - { - Random(rect, items[i]); - } - - return items; -}; - -module.exports = RandomRectangle; - - -/***/ }), -/* 421 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Random = __webpack_require__(112); - -/** - * [description] - * - * @function Phaser.Actions.RandomTriangle - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Triangle} triangle - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var RandomTriangle = function (items, triangle) -{ - for (var i = 0; i < items.length; i++) - { - Random(triangle, items[i]); - } - - return items; -}; - -module.exports = RandomTriangle; - - -/***/ }), -/* 422 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.Rotate - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * @param {number} [step=0] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var Rotate = function (items, value, step) -{ - if (step === undefined) { step = 0; } - - for (var i = 0; i < items.length; i++) - { - items[i].rotation += value + (i * step); - } - - return items; -}; - -module.exports = Rotate; - - -/***/ }), -/* 423 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RotateAroundDistance = __webpack_require__(113); -var DistanceBetween = __webpack_require__(42); - -/** - * [description] - * - * @function Phaser.Actions.RotateAround - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {object} point - Any object with public `x` and `y` properties. - * @param {number} angle - The angle to rotate by, in radians. - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var RotateAround = function (items, point, angle) -{ - var x = point.x; - var y = point.y; - - for (var i = 0; i < items.length; i++) - { - var item = items[i]; - - RotateAroundDistance(item, x, y, angle, Math.max(1, DistanceBetween(item.x, item.y, x, y))); - } - - return items; -}; - -module.exports = RotateAround; - - -/***/ }), -/* 424 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MathRotateAroundDistance = __webpack_require__(113); - -/** - * [description] - * - * @function Phaser.Actions.RotateAroundDistance - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {object} point - Any object with public `x` and `y` properties. - * @param {number} angle - The angle to rotate by, in radians. - * @param {number} distance - The distance from the point of rotation in pixels. - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var RotateAroundDistance = function (items, point, angle, distance) -{ - var x = point.x; - var y = point.y; - - // There's nothing to do - if (distance === 0) - { - return items; - } - - for (var i = 0; i < items.length; i++) - { - MathRotateAroundDistance(items[i], x, y, angle, distance); - } - - return items; -}; - -module.exports = RotateAroundDistance; - - -/***/ }), -/* 425 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.ScaleX - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var ScaleX = function (items, value) -{ - for (var i = 0; i < items.length; i++) - { - items[i].scaleX += value; - } - - return items; -}; - -module.exports = ScaleX; - - -/***/ }), -/* 426 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.ScaleXY - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var ScaleXY = function (items, x, y) -{ - for (var i = 0; i < items.length; i++) - { - items[i].scaleX += x; - items[i].scaleY += y; - } - - return items; -}; - -module.exports = ScaleXY; - - -/***/ }), -/* 427 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.ScaleY - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var ScaleY = function (items, value) -{ - for (var i = 0; i < items.length; i++) - { - items[i].scaleY += value; - } - - return items; -}; - -module.exports = ScaleY; - - -/***/ }), -/* 428 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetAlpha - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * @param {number} [step=0] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetAlpha = function (items, value, step) -{ - if (step === undefined) { step = 0; } - - for (var i = 0; i < items.length; i++) - { - items[i].alpha = value + (i * step); - } - - return items; -}; - -module.exports = SetAlpha; - - -/***/ }), -/* 429 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetBlendMode - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetBlendMode = function (items, value) -{ - for (var i = 0; i < items.length; i++) - { - items[i].setBlendMode(value); - } - - return items; -}; - -module.exports = SetBlendMode; - - -/***/ }), -/* 430 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetDepth - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * @param {number} [step=0] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetDepth = function (items, value, step) -{ - if (step === undefined) { step = 0; } - - for (var i = 0; i < items.length; i++) - { - items[i].depth = value + (i * step); - } - - return items; -}; - -module.exports = SetDepth; - - -/***/ }), -/* 431 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetHitArea - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {any} hitArea - [description] - * @param {function} hitAreaCallback - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetHitArea = function (items, hitArea, hitAreaCallback) -{ - for (var i = 0; i < items.length; i++) - { - items[i].setInteractive(hitArea, hitAreaCallback); - } - - return items; -}; - -module.exports = SetHitArea; - - -/***/ }), -/* 432 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetOrigin - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetOrigin = function (items, x, y) -{ - for (var i = 0; i < items.length; i++) - { - items[i].setOrigin(x, y); - } - - return items; -}; - -module.exports = SetOrigin; - - -/***/ }), -/* 433 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetRotation - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * @param {number} [step=0] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetRotation = function (items, value, step) -{ - if (step === undefined) { step = 0; } - - for (var i = 0; i < items.length; i++) - { - items[i].rotation = value + (i * step); - } - - return items; -}; - -module.exports = SetRotation; - - -/***/ }), -/* 434 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetScale - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} [stepX=0] - [description] - * @param {number} [stepY=0] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetScale = function (items, x, y, stepX, stepY) -{ - if (stepX === undefined) { stepX = 0; } - if (stepY === undefined) { stepY = 0; } - - for (var i = 0; i < items.length; i++) - { - items[i].setScale( - x + (i * stepX), - y + (i * stepY) - ); - } - - return items; -}; - -module.exports = SetScale; - - -/***/ }), -/* 435 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetScaleX - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * @param {number} [step=0] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetScaleX = function (items, value, step) -{ - if (step === undefined) { step = 0; } - - for (var i = 0; i < items.length; i++) - { - items[i].scaleX = value + (i * step); - } - - return items; -}; - -module.exports = SetScaleX; - - -/***/ }), -/* 436 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetScaleY - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * @param {number} [step=0] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetScaleY = function (items, value, step) -{ - if (step === undefined) { step = 0; } - - for (var i = 0; i < items.length; i++) - { - items[i].scaleY = value + (i * step); - } - - return items; -}; - -module.exports = SetScaleY; - - -/***/ }), -/* 437 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetTint - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} topLeft - [description] - * @param {number} [topRight] - [description] - * @param {number} [bottomLeft] - [description] - * @param {number} [bottomRight] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetTint = function (items, topLeft, topRight, bottomLeft, bottomRight) -{ - for (var i = 0; i < items.length; i++) - { - items[i].setTint(topLeft, topRight, bottomLeft, bottomRight); - } - - return items; -}; - -module.exports = SetTint; - - -/***/ }), -/* 438 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetVisible - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {boolean} value - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetVisible = function (items, value) -{ - for (var i = 0; i < items.length; i++) - { - items[i].visible = value; - } - - return items; -}; - -module.exports = SetVisible; - - -/***/ }), -/* 439 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetX - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * @param {number} [step=0] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetX = function (items, value, step) -{ - if (step === undefined) { step = 0; } - - for (var i = 0; i < items.length; i++) - { - items[i].x = value + (i * step); - } - - return items; -}; - -module.exports = SetX; - - -/***/ }), -/* 440 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetXY - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} [stepX=0] - [description] - * @param {number} [stepY=0] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetXY = function (items, x, y, stepX, stepY) -{ - if (stepX === undefined) { stepX = 0; } - if (stepY === undefined) { stepY = 0; } - - for (var i = 0; i < items.length; i++) - { - items[i].x = x + (i * stepX); - items[i].y = y + (i * stepY); - } - - return items; -}; - -module.exports = SetXY; - - -/***/ }), -/* 441 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.SetY - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} value - [description] - * @param {number} [step=0] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SetY = function (items, value, step) -{ - if (step === undefined) { step = 0; } - - for (var i = 0; i < items.length; i++) - { - items[i].y = value + (i * step); - } - - return items; -}; - -module.exports = SetY; - - -/***/ }), -/* 442 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Vector2 = __webpack_require__(6); - -// Iterate through items changing the position of each element to -// be that of the element that came before it in the array (or after it if direction = 1) -// The first items position is set to x/y. -// The final x/y coords are returned - -/** - * [description] - * - * @function Phaser.Actions.ShiftPosition - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} x - [description] - * @param {number} y - [description] - * @param {integer} [direction=0] - [description] - * @param {Phaser.Math.Vector2|object} [output] - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var ShiftPosition = function (items, x, y, direction, output) -{ - if (direction === undefined) { direction = 0; } - if (output === undefined) { output = new Vector2(); } - - var px; - var py; - - if (items.length > 1) - { - var i; - var cx; - var cy; - var cur; - - if (direction === 0) - { - // Bottom to Top - - var len = items.length - 1; - - px = items[len].x; - py = items[len].y; - - for (i = len - 1; i >= 0; i--) - { - // Current item - cur = items[i]; - - // Get current item x/y, to be passed to the next item in the list - cx = cur.x; - cy = cur.y; - - // Set current item to the previous items x/y - cur.x = px; - cur.y = py; - - // Set current as previous - px = cx; - py = cy; - } - - // Update the head item to the new x/y coordinates - items[len].x = x; - items[len].y = y; - } - else - { - // Top to Bottom - - px = items[0].x; - py = items[0].y; - - for (i = 1; i < items.length; i++) - { - // Current item - cur = items[i]; - - // Get current item x/y, to be passed to the next item in the list - cx = cur.x; - cy = cur.y; - - // Set current item to the previous items x/y - cur.x = px; - cur.y = py; - - // Set current as previous - px = cx; - py = cy; - } - - // Update the head item to the new x/y coordinates - items[0].x = x; - items[0].y = y; - } - } - else - { - px = items[0].x; - py = items[0].y; - - items[0].x = x; - items[0].y = y; - } - - // Return the final set of coordinates as they're effectively lost from the shift and may be needed - - output.x = px; - output.y = py; - - return output; -}; - -module.exports = ShiftPosition; - - -/***/ }), -/* 443 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ArrayShuffle = __webpack_require__(80); - -/** - * [description] - * - * @function Phaser.Actions.Shuffle - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var Shuffle = function (items) -{ - return ArrayShuffle(items); -}; - -module.exports = Shuffle; - - -/***/ }), -/* 444 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MathSmootherStep = __webpack_require__(195); - -/** - * [description] - * - * @function Phaser.Actions.SmootherStep - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {string} property - [description] - * @param {number} min - [description] - * @param {number} max - [description] - * @param {number} inc - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SmootherStep = function (items, property, min, max, inc) -{ - if (inc === undefined) { inc = false; } - - var step = Math.abs(max - min) / items.length; - var i; - - if (inc) - { - for (i = 0; i < items.length; i++) - { - items[i][property] += MathSmootherStep(i * step, min, max); - } - } - else - { - for (i = 0; i < items.length; i++) - { - items[i][property] = MathSmootherStep(i * step, min, max); - } - } - - return items; -}; - -module.exports = SmootherStep; - - -/***/ }), -/* 445 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MathSmoothStep = __webpack_require__(196); - -/** - * [description] - * - * @function Phaser.Actions.SmoothStep - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {string} property - [description] - * @param {number} min - [description] - * @param {number} max - [description] - * @param {number} inc - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var SmoothStep = function (items, property, min, max, inc) -{ - if (inc === undefined) { inc = false; } - - var step = Math.abs(max - min) / items.length; - var i; - - if (inc) - { - for (i = 0; i < items.length; i++) - { - items[i][property] += MathSmoothStep(i * step, min, max); - } - } - else - { - for (i = 0; i < items.length; i++) - { - items[i][property] = MathSmoothStep(i * step, min, max); - } - } - - return items; -}; - -module.exports = SmoothStep; - - -/***/ }), -/* 446 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.Spread - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {string} property - [description] - * @param {number} min - [description] - * @param {number} max - [description] - * @param {number} inc - [description] - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var Spread = function (items, property, min, max, inc) -{ - if (inc === undefined) { inc = false; } - - var step = Math.abs(max - min) / items.length; - var i; - - if (inc) - { - for (i = 0; i < items.length; i++) - { - items[i][property] += i * step; - } - } - else - { - for (i = 0; i < items.length; i++) - { - items[i][property] = i * step; - } - } - - return items; -}; - -module.exports = Spread; - - -/***/ }), -/* 447 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Actions.ToggleVisible - * @since 3.0.0 - * - * @param {array} items - An array of Game Objects. The contents of this array are updated by this Action. - * - * @return {array} The array of Game Objects that was passed to this Action. - */ -var ToggleVisible = function (items) -{ - for (var i = 0; i < items.length; i++) - { - items[i].visible = !items[i].visible; - } - - return items; -}; - -module.exports = ToggleVisible; - - -/***/ }), -/* 448 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Animations - */ - -module.exports = { - - Animation: __webpack_require__(197), - AnimationFrame: __webpack_require__(198), - AnimationManager: __webpack_require__(199) - -}; - - -/***/ }), -/* 449 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Cache - */ - -module.exports = { - - BaseCache: __webpack_require__(201), - CacheManager: __webpack_require__(202) - -}; - - -/***/ }), -/* 450 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Cameras - */ - -module.exports = { - - Controls: __webpack_require__(451), - Scene2D: __webpack_require__(454), - Sprite3D: __webpack_require__(456) - -}; - - -/***/ }), -/* 451 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Cameras.Controls - */ - -module.exports = { - - Fixed: __webpack_require__(452), - Smoothed: __webpack_require__(453) - -}; - - -/***/ }), -/* 452 */ -/***/ (function(module, exports, __webpack_require__) { - /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. @@ -86094,821 +83820,39 @@ module.exports = { */ var Class = __webpack_require__(0); -var GetValue = __webpack_require__(4); - -// var camControl = new CameraControl({ -// camera: this.cameras.main, -// left: cursors.left, -// right: cursors.right, -// speed: float OR { x: 0, y: 0 } -// }) - -/** - * @classdesc - * [description] - * - * @class FixedKeyControl - * @memberOf Phaser.Cameras.Controls - * @constructor - * @since 3.0.0 - * - * @param {object} config - [description] - */ -var FixedKeyControl = new Class({ - - initialize: - - function FixedKeyControl (config) - { - /** - * The Camera that this Control will update. - * - * @name Phaser.Cameras.Controls.FixedKeyControl#camera - * @type {Phaser.Cameras.Scene2D.Camera} - * @default null - * @since 3.0.0 - */ - this.camera = GetValue(config, 'camera', null); - - /** - * The Key to be pressed that will move the Camera left. - * - * @name Phaser.Cameras.Controls.FixedKeyControl#left - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.left = GetValue(config, 'left', null); - - /** - * The Key to be pressed that will move the Camera right. - * - * @name Phaser.Cameras.Controls.FixedKeyControl#right - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.right = GetValue(config, 'right', null); - - /** - * The Key to be pressed that will move the Camera up. - * - * @name Phaser.Cameras.Controls.FixedKeyControl#up - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.up = GetValue(config, 'up', null); - - /** - * The Key to be pressed that will move the Camera down. - * - * @name Phaser.Cameras.Controls.FixedKeyControl#down - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.down = GetValue(config, 'down', null); - - /** - * The Key to be pressed that will zoom the Camera in. - * - * @name Phaser.Cameras.Controls.FixedKeyControl#zoomIn - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.zoomIn = GetValue(config, 'zoomIn', null); - - /** - * The Key to be pressed that will zoom the Camera out. - * - * @name Phaser.Cameras.Controls.FixedKeyControl#zoomOut - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.zoomOut = GetValue(config, 'zoomOut', null); - - /** - * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. - * - * @name Phaser.Cameras.Controls.FixedKeyControl#zoomSpeed - * @type {float} - * @default 0.01 - * @since 3.0.0 - */ - this.zoomSpeed = GetValue(config, 'zoomSpeed', 0.01); - - /** - * The horizontal speed the camera will move. - * - * @name Phaser.Cameras.Controls.FixedKeyControl#speedX - * @type {float} - * @default 0 - * @since 3.0.0 - */ - - /** - * The vertical speed the camera will move. - * - * @name Phaser.Cameras.Controls.FixedKeyControl#speedY - * @type {float} - * @default 0 - * @since 3.0.0 - */ - var speed = GetValue(config, 'speed', null); - - if (typeof speed === 'number') - { - this.speedX = speed; - this.speedY = speed; - } - else - { - this.speedX = GetValue(config, 'speed.x', 0); - this.speedY = GetValue(config, 'speed.y', 0); - } - - /** - * [description] - * - * @name Phaser.Cameras.Controls.FixedKeyControl#_zoom - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._zoom = 0; - - /** - * A flag controlling if the Controls will update the Camera or not. - * - * @name Phaser.Cameras.Controls.FixedKeyControl#active - * @type {boolean} - * @since 3.0.0 - */ - this.active = (this.camera !== null); - }, - - /** - * Starts the Key Control running, providing it has been linked to a camera. - * - * @method Phaser.Cameras.Controls.FixedKeyControl#start - * @since 3.0.0 - * - * @return {Phaser.Cameras.Controls.FixedKeyControl} This Key Control instance. - */ - start: function () - { - this.active = (this.camera !== null); - - return this; - }, - - /** - * Stops this Key Control from running. Call `start` to start it again. - * - * @method Phaser.Cameras.Controls.FixedKeyControl#stop - * @since 3.0.0 - * - * @return {Phaser.Cameras.Controls.FixedKeyControl} This Key Control instance. - */ - stop: function () - { - this.active = false; - - return this; - }, - - /** - * Binds this Key Control to a camera. - * - * @method Phaser.Cameras.Controls.FixedKeyControl#setCamera - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to bind this Key Control to. - * - * @return {Phaser.Cameras.Controls.FixedKeyControl} This Key Control instance. - */ - setCamera: function (camera) - { - this.camera = camera; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Controls.FixedKeyControl#update - * @since 3.0.0 - * - * @param {number} delta - [description] - */ - update: function (delta) - { - if (!this.active) - { - return; - } - - if (delta === undefined) { delta = 1; } - - var cam = this.camera; - - if (this.up && this.up.isDown) - { - cam.scrollY -= ((this.speedY * delta) | 0); - } - else if (this.down && this.down.isDown) - { - cam.scrollY += ((this.speedY * delta) | 0); - } - - if (this.left && this.left.isDown) - { - cam.scrollX -= ((this.speedX * delta) | 0); - } - else if (this.right && this.right.isDown) - { - cam.scrollX += ((this.speedX * delta) | 0); - } - - // Camera zoom - - if (this.zoomIn && this.zoomIn.isDown) - { - cam.zoom -= this.zoomSpeed; - - if (cam.zoom < 0.1) - { - cam.zoom = 0.1; - } - } - else if (this.zoomOut && this.zoomOut.isDown) - { - cam.zoom += this.zoomSpeed; - } - }, - - /** - * Destroys this Key Control. - * - * @method Phaser.Cameras.Controls.FixedKeyControl#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.camera = null; - - this.left = null; - this.right = null; - this.up = null; - this.down = null; - - this.zoomIn = null; - this.zoomOut = null; - } - -}); - -module.exports = FixedKeyControl; - - -/***/ }), -/* 453 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GetValue = __webpack_require__(4); - -// var controlConfig = { -// camera: this.cameras.main, -// left: cursors.left, -// right: cursors.right, -// up: cursors.up, -// down: cursors.down, -// zoomIn: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q), -// zoomOut: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E), -// zoomSpeed: 0.02, -// acceleration: 0.06, -// drag: 0.0005, -// maxSpeed: 1.0 -// }; - -/** - * @classdesc - * [description] - * - * @class SmoothedKeyControl - * @memberOf Phaser.Cameras.Controls - * @constructor - * @since 3.0.0 - * - * @param {object} config - [description] - */ -var SmoothedKeyControl = new Class({ - - initialize: - - function SmoothedKeyControl (config) - { - /** - * The Camera that this Control will update. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#camera - * @type {Phaser.Cameras.Scene2D.Camera} - * @default null - * @since 3.0.0 - */ - this.camera = GetValue(config, 'camera', null); - - /** - * The Key to be pressed that will move the Camera left. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#left - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.left = GetValue(config, 'left', null); - - /** - * The Key to be pressed that will move the Camera right. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#right - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.right = GetValue(config, 'right', null); - - /** - * The Key to be pressed that will move the Camera up. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#up - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.up = GetValue(config, 'up', null); - - /** - * The Key to be pressed that will move the Camera down. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#down - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.down = GetValue(config, 'down', null); - - /** - * The Key to be pressed that will zoom the Camera in. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomIn - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.zoomIn = GetValue(config, 'zoomIn', null); - - /** - * The Key to be pressed that will zoom the Camera out. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomOut - * @type {Phaser.Input.Keyboard} - * @default null - * @since 3.0.0 - */ - this.zoomOut = GetValue(config, 'zoomOut', null); - - /** - * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomSpeed - * @type {float} - * @default 0.01 - * @since 3.0.0 - */ - this.zoomSpeed = GetValue(config, 'zoomSpeed', 0.01); - - /** - * The horizontal acceleration the camera will move. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#accelX - * @type {float} - * @default 0 - * @since 3.0.0 - */ - - /** - * The vertical acceleration the camera will move. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#accelY - * @type {float} - * @default 0 - * @since 3.0.0 - */ - var accel = GetValue(config, 'acceleration', null); - - if (typeof accel === 'number') - { - this.accelX = accel; - this.accelY = accel; - } - else - { - this.accelX = GetValue(config, 'acceleration.x', 0); - this.accelY = GetValue(config, 'acceleration.y', 0); - } - - /** - * The horizontal drag applied to the camera when it is moving. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#dragX - * @type {float} - * @default 0 - * @since 3.0.0 - */ - - /** - * The vertical drag applied to the camera when it is moving. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#dragY - * @type {float} - * @default 0 - * @since 3.0.0 - */ - var drag = GetValue(config, 'drag', null); - - if (typeof drag === 'number') - { - this.dragX = drag; - this.dragY = drag; - } - else - { - this.dragX = GetValue(config, 'drag.x', 0); - this.dragY = GetValue(config, 'drag.y', 0); - } - - /** - * The maximum horizontal speed the camera will move. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#maxSpeedX - * @type {float} - * @default 0 - * @since 3.0.0 - */ - - /** - * The maximum vertical speed the camera will move. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#maxSpeedY - * @type {float} - * @default 0 - * @since 3.0.0 - */ - var maxSpeed = GetValue(config, 'maxSpeed', null); - - if (typeof maxSpeed === 'number') - { - this.maxSpeedX = maxSpeed; - this.maxSpeedY = maxSpeed; - } - else - { - this.maxSpeedX = GetValue(config, 'maxSpeed.x', 0); - this.maxSpeedY = GetValue(config, 'maxSpeed.y', 0); - } - - /** - * [description] - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#_speedX - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._speedX = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#_speedY - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._speedY = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#_zoom - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._zoom = 0; - - /** - * A flag controlling if the Controls will update the Camera or not. - * - * @name Phaser.Cameras.Controls.SmoothedKeyControl#active - * @type {boolean} - * @since 3.0.0 - */ - this.active = (this.camera !== null); - }, - - /** - * Starts the Key Control running, providing it has been linked to a camera. - * - * @method Phaser.Cameras.Controls.SmoothedKeyControl#start - * @since 3.0.0 - * - * @return {Phaser.Cameras.Controls.SmoothedKeyControl} This Key Control instance. - */ - start: function () - { - this.active = (this.camera !== null); - - return this; - }, - - /** - * Stops this Key Control from running. Call `start` to start it again. - * - * @method Phaser.Cameras.Controls.SmoothedKeyControl#stop - * @since 3.0.0 - * - * @return {Phaser.Cameras.Controls.SmoothedKeyControl} This Key Control instance. - */ - stop: function () - { - this.active = false; - - return this; - }, - - /** - * Binds this Key Control to a camera. - * - * @method Phaser.Cameras.Controls.SmoothedKeyControl#setCamera - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to bind this Key Control to. - * - * @return {Phaser.Cameras.Controls.SmoothedKeyControl} This Key Control instance. - */ - setCamera: function (camera) - { - this.camera = camera; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Controls.SmoothedKeyControl#update - * @since 3.0.0 - * - * @param {[type]} delta - [description] - */ - update: function (delta) - { - if (!this.active) - { - return; - } - - if (delta === undefined) { delta = 1; } - - var cam = this.camera; - - // Apply Deceleration - - if (this._speedX > 0) - { - this._speedX -= this.dragX * delta; - - if (this._speedX < 0) - { - this._speedX = 0; - } - } - else if (this._speedX < 0) - { - this._speedX += this.dragX * delta; - - if (this._speedX > 0) - { - this._speedX = 0; - } - } - - if (this._speedY > 0) - { - this._speedY -= this.dragY * delta; - - if (this._speedY < 0) - { - this._speedY = 0; - } - } - else if (this._speedY < 0) - { - this._speedY += this.dragY * delta; - - if (this._speedY > 0) - { - this._speedY = 0; - } - } - - // Check for keys - - if (this.up && this.up.isDown) - { - this._speedY += this.accelY; - - if (this._speedY > this.maxSpeedY) - { - this._speedY = this.maxSpeedY; - } - } - else if (this.down && this.down.isDown) - { - this._speedY -= this.accelY; - - if (this._speedY < -this.maxSpeedY) - { - this._speedY = -this.maxSpeedY; - } - } - - if (this.left && this.left.isDown) - { - this._speedX += this.accelX; - - if (this._speedX > this.maxSpeedX) - { - this._speedX = this.maxSpeedX; - } - } - else if (this.right && this.right.isDown) - { - this._speedX -= this.accelX; - - if (this._speedX < -this.maxSpeedX) - { - this._speedX = -this.maxSpeedX; - } - } - - // Camera zoom - - if (this.zoomIn && this.zoomIn.isDown) - { - this._zoom = -this.zoomSpeed; - } - else if (this.zoomOut && this.zoomOut.isDown) - { - this._zoom = this.zoomSpeed; - } - else - { - this._zoom = 0; - } - - // Apply to Camera - - if (this._speedX !== 0) - { - cam.scrollX -= ((this._speedX * delta) | 0); - } - - if (this._speedY !== 0) - { - cam.scrollY -= ((this._speedY * delta) | 0); - } - - if (this._zoom !== 0) - { - cam.zoom += this._zoom; - - if (cam.zoom < 0.1) - { - cam.zoom = 0.1; - } - } - }, - - /** - * Destroys this Key Control. - * - * @method Phaser.Cameras.Controls.SmoothedKeyControl#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.camera = null; - - this.left = null; - this.right = null; - this.up = null; - this.down = null; - - this.zoomIn = null; - this.zoomOut = null; - } - -}); - -module.exports = SmoothedKeyControl; - - -/***/ }), -/* 454 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Cameras.Scene2D - */ - -module.exports = { - - Camera: __webpack_require__(115), - CameraManager: __webpack_require__(455) - -}; - - -/***/ }), -/* 455 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Camera = __webpack_require__(115); -var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(2); var PluginManager = __webpack_require__(12); -var RectangleContains = __webpack_require__(33); +var TimerEvent = __webpack_require__(183); /** * @classdesc * [description] * - * @class CameraManager - * @memberOf Phaser.Cameras.Scene2D + * @class Clock + * @memberOf Phaser.Time * @constructor * @since 3.0.0 * - * @param {Phaser.Scene} scene - The Scene that owns the Camera Manager plugin. + * @param {Phaser.Scene} scene - [description] */ -var CameraManager = new Class({ +var Clock = new Class({ initialize: - function CameraManager (scene) + function Clock (scene) { /** - * The Scene that owns the Camera Manager plugin. + * [description] * - * @name Phaser.Cameras.Scene2D.CameraManager#scene + * @name Phaser.Time.Clock#scene * @type {Phaser.Scene} * @since 3.0.0 */ this.scene = scene; /** - * A reference to the Scene.Systems handler for the Scene that owns the Camera Manager. + * [description] * - * @name Phaser.Cameras.Scene2D.CameraManager#systems + * @name Phaser.Time.Clock#systems * @type {Phaser.Scenes.Systems} * @since 3.0.0 */ @@ -86920,8150 +83864,53 @@ var CameraManager = new Class({ } /** - * The current Camera ID. + * [description] * - * @name Phaser.Cameras.Scene2D.CameraManager#currentCameraId + * @name Phaser.Time.Clock#now * @type {number} + * @since 3.0.0 + */ + this.now = Date.now(); + + // Scale the delta time coming into the Clock by this factor + // which then influences anything using this Clock for calculations, like TimerEvents + + /** + * [description] + * + * @name Phaser.Time.Clock#timeScale + * @type {float} * @default 1 - * @readOnly * @since 3.0.0 */ - this.currentCameraId = 1; - - /** - * An Array of the Camera objects being managed by this Camera Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#cameras - * @type {Phaser.Cameras.Scene2D.Camera[]} - * @since 3.0.0 - */ - this.cameras = []; - - /** - * A pool of Camera objects available to be used by the Camera Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#cameraPool - * @type {Phaser.Cameras.Scene2D.Camera[]} - * @since 3.0.0 - */ - this.cameraPool = []; - - if (scene.sys.settings.cameras) - { - // We have cameras to create - this.fromJSON(scene.sys.settings.cameras); - } - else - { - // Make one - this.add(); - } - - /** - * The default Camera in the Camera Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#main - * @type {Phaser.Cameras.Scene2D.Camera} - * @since 3.0.0 - */ - this.main = this.cameras[0]; - - /** - * This scale affects all cameras. It's used by Scale Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#baseScale - * @type {number} - * @since 3.0.0 - */ - this.baseScale = 1.0; - }, - - /** - * Called when the Camera Manager boots. - * Starts the event listeners running. - * - * @method Phaser.Cameras.Scene2D.CameraManager#boot - * @since 3.0.0 - */ - boot: function () - { - var eventEmitter = this.systems.events; - - eventEmitter.on('update', this.update, this); - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#add - * @since 3.0.0 - * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] - * @param {number} [width] - [description] - * @param {number} [height] - [description] - * @param {boolean} [makeMain=false] - [description] - * @param {string} [name=''] - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} [description] - */ - add: function (x, y, width, height, makeMain, name) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (width === undefined) { width = this.scene.sys.game.config.width; } - if (height === undefined) { height = this.scene.sys.game.config.height; } - if (makeMain === undefined) { makeMain = false; } - if (name === undefined) { name = ''; } - - var camera = null; - - if (this.cameraPool.length > 0) - { - camera = this.cameraPool.pop(); - - camera.setViewport(x, y, width, height); - } - else - { - camera = new Camera(x, y, width, height); - } - - camera.setName(name); - camera.setScene(this.scene); - - this.cameras.push(camera); - - if (makeMain) - { - this.main = camera; - } - - camera._id = this.currentCameraId; - - this.currentCameraId = this.currentCameraId << 1; - - return camera; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#addExisting - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} [description] - */ - addExisting: function (camera) - { - var index = this.cameras.indexOf(camera); - var poolIndex = this.cameraPool.indexOf(camera); - - if (index < 0 && poolIndex >= 0) - { - this.cameras.push(camera); - this.cameraPool.slice(poolIndex, 1); - return camera; - } - - return null; - }, - - /* - { - cameras: [ - { - name: string - x: int - y: int - width: int - height: int - zoom: float - rotation: float - roundPixels: bool - scrollX: float - scrollY: float - backgroundColor: string - bounds: { - x: int - y: int - width: int - height: int - } - } - ] - } - */ - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#fromJSON - * @since 3.0.0 - * - * @param {[type]} config - [description] - * - * @return {[type]} [description] - */ - fromJSON: function (config) - { - if (!Array.isArray(config)) - { - config = [ config ]; - } - - var gameWidth = this.scene.sys.game.config.width; - var gameHeight = this.scene.sys.game.config.height; - - for (var i = 0; i < config.length; i++) - { - var cameraConfig = config[i]; - - var x = GetFastValue(cameraConfig, 'x', 0); - var y = GetFastValue(cameraConfig, 'y', 0); - var width = GetFastValue(cameraConfig, 'width', gameWidth); - var height = GetFastValue(cameraConfig, 'height', gameHeight); - - var camera = this.add(x, y, width, height); - - // Direct properties - camera.name = GetFastValue(cameraConfig, 'name', ''); - camera.zoom = GetFastValue(cameraConfig, 'zoom', 1); - camera.rotation = GetFastValue(cameraConfig, 'rotation', 0); - camera.scrollX = GetFastValue(cameraConfig, 'scrollX', 0); - camera.scrollY = GetFastValue(cameraConfig, 'scrollY', 0); - camera.roundPixels = GetFastValue(cameraConfig, 'roundPixels', false); - - // Background Color - - var backgroundColor = GetFastValue(cameraConfig, 'backgroundColor', false); - - if (backgroundColor) - { - camera.setBackgroundColor(backgroundColor); - } - - // Bounds - - var boundsConfig = GetFastValue(cameraConfig, 'bounds', null); - - if (boundsConfig) - { - var bx = GetFastValue(boundsConfig, 'x', 0); - var by = GetFastValue(boundsConfig, 'y', 0); - var bwidth = GetFastValue(boundsConfig, 'width', gameWidth); - var bheight = GetFastValue(boundsConfig, 'height', gameHeight); - - camera.setBounds(bx, by, bwidth, bheight); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#getCamera - * @since 3.0.0 - * - * @param {string} name - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} [description] - */ - getCamera: function (name) - { - this.cameras.forEach(function (camera) - { - if (camera.name === name) - { - return camera; - } - }); - - return null; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#getCameraBelowPointer - * @since 3.0.0 - * - * @param {[type]} pointer - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} [description] - */ - getCameraBelowPointer: function (pointer) - { - var cameras = this.cameras; - - // Start from the most recently added camera (the 'top' camera) - for (var i = cameras.length - 1; i >= 0; i--) - { - var camera = cameras[i]; - - if (camera.inputEnabled && RectangleContains(camera, pointer.x, pointer.y)) - { - return camera; - } - } - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#remove - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - remove: function (camera) - { - var cameraIndex = this.cameras.indexOf(camera); - - if (cameraIndex >= 0 && this.cameras.length > 1) - { - this.cameraPool.push(this.cameras[cameraIndex]); - this.cameras.splice(cameraIndex, 1); - - if (this.main === camera) - { - this.main = this.cameras[0]; - } - } - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#render - * @since 3.0.0 - * - * @param {[type]} renderer - [description] - * @param {[type]} children - [description] - * @param {[type]} interpolation - [description] - */ - render: function (renderer, children, interpolation) - { - var cameras = this.cameras; - var baseScale = this.baseScale; - - for (var i = 0, l = cameras.length; i < l; ++i) - { - var camera = cameras[i]; - - camera.preRender(baseScale, renderer.config.resolution); - - renderer.render(this.scene, children, interpolation, camera); - } - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#resetAll - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} [description] - */ - resetAll: function () - { - while (this.cameras.length > 0) - { - this.cameraPool.push(this.cameras.pop()); - } - - this.main = this.add(); - - return this.main; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#update - * @since 3.0.0 - * - * @param {number} timestep - [description] - * @param {number} delta - [description] - */ - update: function (timestep, delta) - { - for (var i = 0, l = this.cameras.length; i < l; ++i) - { - this.cameras[i].update(timestep, delta); - } - }, - - /** - * Resizes all cameras to the given dimensions. - * - * @method Phaser.Cameras.Scene2D.CameraManager#resize - * @since 3.2.0 - * - * @param {number} width - The new width of the camera. - * @param {number} height - The new height of the camera. - */ - resize: function (width, height) - { - for (var i = 0, l = this.cameras.length; i < l; ++i) - { - this.cameras[i].setSize(width, height); - } - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - // TODO - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.main = undefined; - - for (var i = 0; i < this.cameras.length; i++) - { - this.cameras[i].destroy(); - } - - for (i = 0; i < this.cameraPool.length; i++) - { - this.cameraPool[i].destroy(); - } - - this.cameras = []; - this.cameraPool = []; - this.scene = undefined; - } - -}); - -PluginManager.register('CameraManager', CameraManager, 'cameras'); - -module.exports = CameraManager; - - -/***/ }), -/* 456 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Cameras.Sprite3D - */ - -module.exports = { - - Camera: __webpack_require__(118), - CameraManager: __webpack_require__(460), - OrthographicCamera: __webpack_require__(214), - PerspectiveCamera: __webpack_require__(215) - -}; - - -/***/ }), -/* 457 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(458); -} - -if (true) -{ - renderCanvas = __webpack_require__(459); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 458 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Sprite#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var SpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.batchSprite(src, camera); -}; - -module.exports = SpriteWebGLRenderer; - - -/***/ }), -/* 459 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Sprite#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var SpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - renderer.drawImage(src, camera); -}; - -module.exports = SpriteCanvasRenderer; - - -/***/ }), -/* 460 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var OrthographicCamera = __webpack_require__(214); -var PerspectiveCamera = __webpack_require__(215); -var PluginManager = __webpack_require__(12); - -/** - * @classdesc - * [description] - * - * @class CameraManager - * @memberOf Phaser.Cameras.Sprite3D - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var CameraManager = new Class({ - - initialize: - - function CameraManager (scene) - { - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.CameraManager#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; + this.timeScale = 1; /** * [description] * - * @name Phaser.Cameras.Sprite3D.CameraManager#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - /** - * An Array of the Camera objects being managed by this Camera Manager. - * - * @name Phaser.Cameras.Sprite3D.CameraManager#cameras - * @type {array} - * @since 3.0.0 - */ - this.cameras = []; - - if (!scene.sys.settings.isBooted) - { - scene.sys.events.once('boot', this.boot, this); - } - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.CameraManager#boot - * @since 3.0.0 - */ - boot: function () - { - var eventEmitter = this.systems.events; - - eventEmitter.on('update', this.update, this); - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.CameraManager#add - * @since 3.0.0 - * - * @param {[type]} fieldOfView - [description] - * @param {[type]} width - [description] - * @param {[type]} height - [description] - * - * @return {[type]} [description] - */ - add: function (fieldOfView, width, height) - { - return this.addPerspectiveCamera(fieldOfView, width, height); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.CameraManager#addOrthographicCamera - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {[type]} [description] - */ - addOrthographicCamera: function (width, height) - { - var config = this.scene.sys.game.config; - - if (width === undefined) { width = config.width; } - if (height === undefined) { height = config.height; } - - var camera = new OrthographicCamera(this.scene, width, height); - - this.cameras.push(camera); - - return camera; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.CameraManager#addPerspectiveCamera - * @since 3.0.0 - * - * @param {number} [fieldOfView=80] - [description] - * @param {number} [width] - [description] - * @param {number} [height] - [description] - * - * @return {[type]} [description] - */ - addPerspectiveCamera: function (fieldOfView, width, height) - { - var config = this.scene.sys.game.config; - - if (fieldOfView === undefined) { fieldOfView = 80; } - if (width === undefined) { width = config.width; } - if (height === undefined) { height = config.height; } - - var camera = new PerspectiveCamera(this.scene, fieldOfView, width, height); - - this.cameras.push(camera); - - return camera; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.CameraManager#getCamera - * @since 3.0.0 - * - * @param {string} name - [description] - * - * @return {[type]} [description] - */ - getCamera: function (name) - { - this.cameras.forEach(function (camera) - { - if (camera.name === name) - { - return camera; - } - }); - - return null; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.CameraManager#removeCamera - * @since 3.0.0 - * - * @param {[type]} camera - [description] - */ - removeCamera: function (camera) - { - var cameraIndex = this.cameras.indexOf(camera); - - if (cameraIndex !== -1) - { - this.cameras.splice(cameraIndex, 1); - } - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.CameraManager#removeAll - * @since 3.0.0 - * - * @return {[type]} [description] - */ - removeAll: function () - { - while (this.cameras.length > 0) - { - var camera = this.cameras.pop(); - - camera.destroy(); - } - - return this.main; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.CameraManager#update - * @since 3.0.0 - * - * @param {number} timestep - [description] - * @param {number} delta - [description] - */ - update: function (timestep, delta) - { - for (var i = 0, l = this.cameras.length; i < l; ++i) - { - this.cameras[i].update(timestep, delta); - } - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.CameraManager#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.CameraManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.scene = undefined; - } - -}); - -PluginManager.register('CameraManager3D', CameraManager, 'cameras3d'); - -module.exports = CameraManager; - - -/***/ }), -/* 461 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Create - */ - -module.exports = { - - GenerateTexture: __webpack_require__(216), - Palettes: __webpack_require__(462) - -}; - - -/***/ }), -/* 462 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Create.Palettes - */ - -module.exports = { - - ARNE16: __webpack_require__(217), - C64: __webpack_require__(463), - CGA: __webpack_require__(464), - JMP: __webpack_require__(465), - MSX: __webpack_require__(466) - -}; - - -/***/ }), -/* 463 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * A 16 color palette inspired by the Commodore 64. - * - * @name Phaser.Create.Palettes.C64 - * @since 3.0.0 - * - * @type {object} - * @property {string} 0 - Color value 1. - * @property {string} 1 - Color value 2. - * @property {string} 2 - Color value 3. - * @property {string} 3 - Color value 4. - * @property {string} 4 - Color value 5. - * @property {string} 5 - Color value 6. - * @property {string} 6 - Color value 7. - * @property {string} 7 - Color value 8. - * @property {string} 8 - Color value 9. - * @property {string} 9 - Color value 10. - * @property {string} A - Color value 11. - * @property {string} B - Color value 12. - * @property {string} C - Color value 13. - * @property {string} D - Color value 14. - * @property {string} E - Color value 15. - * @property {string} F - Color value 16. - */ -module.exports = { - 0: '#000', - 1: '#fff', - 2: '#8b4131', - 3: '#7bbdc5', - 4: '#8b41ac', - 5: '#6aac41', - 6: '#3931a4', - 7: '#d5de73', - 8: '#945a20', - 9: '#5a4100', - A: '#bd736a', - B: '#525252', - C: '#838383', - D: '#acee8b', - E: '#7b73de', - F: '#acacac' -}; - - -/***/ }), -/* 464 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * A 16 color CGA inspired palette by [Arne](http://androidarts.com/palette/16pal.htm) - * - * @name Phaser.Create.Palettes.CGA - * @since 3.0.0 - * - * @type {object} - * @property {string} 0 - Color value 1. - * @property {string} 1 - Color value 2. - * @property {string} 2 - Color value 3. - * @property {string} 3 - Color value 4. - * @property {string} 4 - Color value 5. - * @property {string} 5 - Color value 6. - * @property {string} 6 - Color value 7. - * @property {string} 7 - Color value 8. - * @property {string} 8 - Color value 9. - * @property {string} 9 - Color value 10. - * @property {string} A - Color value 11. - * @property {string} B - Color value 12. - * @property {string} C - Color value 13. - * @property {string} D - Color value 14. - * @property {string} E - Color value 15. - * @property {string} F - Color value 16. - */ -module.exports = { - 0: '#000', - 1: '#2234d1', - 2: '#0c7e45', - 3: '#44aacc', - 4: '#8a3622', - 5: '#5c2e78', - 6: '#aa5c3d', - 7: '#b5b5b5', - 8: '#5e606e', - 9: '#4c81fb', - A: '#6cd947', - B: '#7be2f9', - C: '#eb8a60', - D: '#e23d69', - E: '#ffd93f', - F: '#fff' -}; - - -/***/ }), -/* 465 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * A 16 color JMP palette by [Arne](http://androidarts.com/palette/16pal.htm) - * - * @name Phaser.Create.Palettes.JMP - * @type {object} - * @since 3.0.0 - * - * @property {string} 0 - Color value 1. - * @property {string} 1 - Color value 2. - * @property {string} 2 - Color value 3. - * @property {string} 3 - Color value 4. - * @property {string} 4 - Color value 5. - * @property {string} 5 - Color value 6. - * @property {string} 6 - Color value 7. - * @property {string} 7 - Color value 8. - * @property {string} 8 - Color value 9. - * @property {string} 9 - Color value 10. - * @property {string} A - Color value 11. - * @property {string} B - Color value 12. - * @property {string} C - Color value 13. - * @property {string} D - Color value 14. - * @property {string} E - Color value 15. - * @property {string} F - Color value 16. - */ -module.exports = { - 0: '#000', - 1: '#191028', - 2: '#46af45', - 3: '#a1d685', - 4: '#453e78', - 5: '#7664fe', - 6: '#833129', - 7: '#9ec2e8', - 8: '#dc534b', - 9: '#e18d79', - A: '#d6b97b', - B: '#e9d8a1', - C: '#216c4b', - D: '#d365c8', - E: '#afaab9', - F: '#f5f4eb' -}; - - -/***/ }), -/* 466 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * A 16 color palette inspired by Japanese computers like the MSX. - * - * @name Phaser.Create.Palettes.MSX - * @since 3.0.0 - * - * @type {object} - * @property {string} 0 - Color value 1. - * @property {string} 1 - Color value 2. - * @property {string} 2 - Color value 3. - * @property {string} 3 - Color value 4. - * @property {string} 4 - Color value 5. - * @property {string} 5 - Color value 6. - * @property {string} 6 - Color value 7. - * @property {string} 7 - Color value 8. - * @property {string} 8 - Color value 9. - * @property {string} 9 - Color value 10. - * @property {string} A - Color value 11. - * @property {string} B - Color value 12. - * @property {string} C - Color value 13. - * @property {string} D - Color value 14. - * @property {string} E - Color value 15. - * @property {string} F - Color value 16. - */ -module.exports = { - 0: '#000', - 1: '#191028', - 2: '#46af45', - 3: '#a1d685', - 4: '#453e78', - 5: '#7664fe', - 6: '#833129', - 7: '#9ec2e8', - 8: '#dc534b', - 9: '#e18d79', - A: '#d6b97b', - B: '#e9d8a1', - C: '#216c4b', - D: '#d365c8', - E: '#afaab9', - F: '#fff' -}; - - -/***/ }), -/* 467 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Curves - */ - -module.exports = { - Path: __webpack_require__(468), - - CubicBezier: __webpack_require__(218), - Curve: __webpack_require__(52), - Ellipse: __webpack_require__(220), - Line: __webpack_require__(222), - QuadraticBezier: __webpack_require__(223), - Spline: __webpack_require__(225) -}; - - -/***/ }), -/* 468 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) - -var Class = __webpack_require__(0); -var CubicBezierCurve = __webpack_require__(218); -var EllipseCurve = __webpack_require__(220); -var GameObjectFactory = __webpack_require__(9); -var LineCurve = __webpack_require__(222); -var MovePathTo = __webpack_require__(469); -var QuadraticBezierCurve = __webpack_require__(223); -var Rectangle = __webpack_require__(8); -var SplineCurve = __webpack_require__(225); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * [description] - * - * @class Path - * @memberOf Phaser.Curves - * @constructor - * @since 3.0.0 - * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] - */ -var Path = new Class({ - - initialize: - - function Path (x, y) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - - /** - * [description] - * - * @name Phaser.Curves.Path#name - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.name = ''; - - /** - * [description] - * - * @name Phaser.Curves.Path#curves - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.curves = []; - - /** - * [description] - * - * @name Phaser.Curves.Path#cacheLengths - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.cacheLengths = []; - - /** - * Automatically closes the path. - * - * @name Phaser.Curves.Path#autoClose + * @name Phaser.Time.Clock#paused * @type {boolean} * @default false * @since 3.0.0 */ - this.autoClose = false; + this.paused = false; /** * [description] * - * @name {Phaser.MathPhaser.Curves.Path#startPoint - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.startPoint = new Vector2(); - - /** - * [description] - * - * @name {Phaser.MathPhaser.Curves.Path#_tmpVec2A - * @type {Phaser.Math.Vector2} - * @private - * @since 3.0.0 - */ - this._tmpVec2A = new Vector2(); - - /** - * [description] - * - * @name {Phaser.MathPhaser.Curves.Path#_tmpVec2B - * @type {Phaser.Math.Vector2} - * @private - * @since 3.0.0 - */ - this._tmpVec2B = new Vector2(); - - if (typeof x === 'object') - { - this.fromJSON(x); - } - else - { - this.startPoint.set(x, y); - } - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#add - * @since 3.0.0 - * - * @param {Phaser.Curves.Curve} curve - [description] - * - * @return {Phaser.Curves.Path} [description] - */ - add: function (curve) - { - this.curves.push(curve); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#circleTo - * @since 3.0.0 - * - * @param {number} radius - [description] - * @param {boolean} [clockwise=false] - [description] - * @param {number} [rotation=0] - [description] - * - * @return {Phaser.Curves.Path} [description] - */ - circleTo: function (radius, clockwise, rotation) - { - if (clockwise === undefined) { clockwise = false; } - - return this.ellipseTo(radius, radius, 0, 360, clockwise, rotation); - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#closePath - * @since 3.0.0 - * - * @return {Phaser.Curves.Path} [description] - */ - closePath: function () - { - // Add a line curve if start and end of lines are not connected - var startPoint = this.curves[0].getPoint(0); - var endPoint = this.curves[this.curves.length - 1].getPoint(1); - - if (!startPoint.equals(endPoint)) - { - // This will copy a reference to the vectors, which probably isn't sensible - this.curves.push(new LineCurve(endPoint, startPoint)); - } - - return this; - }, - - // Creates a cubic bezier curve starting at the previous end point and ending at p3, using p1 and p2 as control points - - /** - * [description] - * - * @method Phaser.Curves.Path#cubicBezierTo - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {Phaser.Math.Vector2} control1X - [description] - * @param {Phaser.Math.Vector2} control1Y - [description] - * @param {Phaser.Math.Vector2} control2X - [description] - * @param {Phaser.Math.Vector2} control2Y - [description] - * - * @return {Phaser.Curves.Path} [description] - */ - cubicBezierTo: function (x, y, control1X, control1Y, control2X, control2Y) - { - var p0 = this.getEndPoint(); - var p1; - var p2; - var p3; - - // Assume they're all vec2s - if (x instanceof Vector2) - { - p1 = x; - p2 = y; - p3 = control1X; - } - else - { - p1 = new Vector2(control1X, control1Y); - p2 = new Vector2(control2X, control2Y); - p3 = new Vector2(x, y); - } - - return this.add(new CubicBezierCurve(p0, p1, p2, p3)); - }, - - // Creates a quadratic bezier curve starting at the previous end point and ending at p2, using p1 as a control point - - /** - * [description] - * - * @method Phaser.Curves.Path#quadraticBezierTo - * @since 3.2.0 - * - * @param {number|Phaser.Math.Vector2[]} x - [description] - * @param {number} [y] - [description] - * @param {number} [controlX] - [description] - * @param {number} [controlY] - [description] - * - * @return {Phaser.Curves.Path} [description] - */ - quadraticBezierTo: function (x, y, controlX, controlY) - { - var p0 = this.getEndPoint(); - var p1; - var p2; - - // Assume they're all vec2s - if (x instanceof Vector2) - { - p1 = x; - p2 = y; - } - else - { - p1 = new Vector2(controlX, controlY); - p2 = new Vector2(x, y); - } - - return this.add(new QuadraticBezierCurve(p0, p1, p2)); - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#draw - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - [description] - * @param {integer} [pointsTotal=32] - [description] - * - * @return {Phaser.GameObjects.Graphics} [description] - */ - draw: function (graphics, pointsTotal) - { - for (var i = 0; i < this.curves.length; i++) - { - var curve = this.curves[i]; - - if (!curve.active) - { - continue; - } - - curve.draw(graphics, pointsTotal); - } - - return graphics; - }, - - /** - * Creates an ellipse curve positioned at the previous end point, using the given parameters. - * - * @method Phaser.Curves.Path#ellipseTo - * @since 3.0.0 - * - * @param {number} xRadius - [description] - * @param {number} yRadius - [description] - * @param {number} startAngle - [description] - * @param {number} endAngle - [description] - * @param {boolean} clockwise - [description] - * @param {number} rotation - [description] - * - * @return {Phaser.Curves.Path} [description] - */ - ellipseTo: function (xRadius, yRadius, startAngle, endAngle, clockwise, rotation) - { - var ellipse = new EllipseCurve(0, 0, xRadius, yRadius, startAngle, endAngle, clockwise, rotation); - - var end = this.getEndPoint(this._tmpVec2A); - - // Calculate where to center the ellipse - var start = ellipse.getStartPoint(this._tmpVec2B); - - end.subtract(start); - - ellipse.x = end.x; - ellipse.y = end.y; - - return this.add(ellipse); - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#fromJSON - * @since 3.0.0 - * - * @param {object} data - [description] - * - * @return {Phaser.Curves.Path} [description] - */ - fromJSON: function (data) - { - // data should be an object matching the Path.toJSON object structure. - - this.curves = []; - this.cacheLengths = []; - - this.startPoint.set(data.x, data.y); - - this.autoClose = data.autoClose; - - for (var i = 0; i < data.curves.length; i++) - { - var curve = data.curves[i]; - - switch (curve.type) - { - case 'LineCurve': - this.add(LineCurve.fromJSON(curve)); - break; - - case 'EllipseCurve': - this.add(EllipseCurve.fromJSON(curve)); - break; - - case 'SplineCurve': - this.add(SplineCurve.fromJSON(curve)); - break; - - case 'CubicBezierCurve': - this.add(CubicBezierCurve.fromJSON(curve)); - break; - - case 'QuadraticBezierCurve': - this.add(QuadraticBezierCurve.fromJSON(curve)); - break; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#getBounds - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} [out] - [description] - * @param {integer} [accuracy=16] - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ - getBounds: function (out, accuracy) - { - if (out === undefined) { out = new Rectangle(); } - if (accuracy === undefined) { accuracy = 16; } - - out.x = Number.MAX_VALUE; - out.y = Number.MAX_VALUE; - - var bounds = new Rectangle(); - var maxRight = Number.MIN_SAFE_INTEGER; - var maxBottom = Number.MIN_SAFE_INTEGER; - - for (var i = 0; i < this.curves.length; i++) - { - var curve = this.curves[i]; - - if (!curve.active) - { - continue; - } - - curve.getBounds(bounds, accuracy); - - out.x = Math.min(out.x, bounds.x); - out.y = Math.min(out.y, bounds.y); - - maxRight = Math.max(maxRight, bounds.right); - maxBottom = Math.max(maxBottom, bounds.bottom); - } - - out.right = maxRight; - out.bottom = maxBottom; - - return out; - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#getCurveLengths - * @since 3.0.0 - * - * @return {array} [description] - */ - getCurveLengths: function () - { - // We use cache values if curves and cache array are same length - - if (this.cacheLengths.length === this.curves.length) - { - return this.cacheLengths; - } - - // Get length of sub-curve - // Push sums into cached array - - var lengths = []; - var sums = 0; - - for (var i = 0; i < this.curves.length; i++) - { - sums += this.curves[i].getLength(); - - lengths.push(sums); - } - - this.cacheLengths = lengths; - - return lengths; - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#getEndPoint - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} [out] - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - getEndPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - if (this.curves.length > 0) - { - this.curves[this.curves.length - 1].getPoint(1, out); - } - else - { - out.copy(this.startPoint); - } - - return out; - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#getLength - * @since 3.0.0 - * - * @return {number} [description] - */ - getLength: function () - { - var lens = this.getCurveLengths(); - - return lens[lens.length - 1]; - }, - - // To get accurate point with reference to - // entire path distance at time t, - // following has to be done: - - // 1. Length of each sub path have to be known - // 2. Locate and identify type of curve - // 3. Get t for the curve - // 4. Return curve.getPointAt(t') - - /** - * [description] - * - * @method Phaser.Curves.Path#getPoint - * @since 3.0.0 - * - * @param {number} t - [description] - * @param {Phaser.Math.Vector2} [out] - [description] - * - * @return {Phaser.Math.Vector2|null} [description] - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - var d = t * this.getLength(); - var curveLengths = this.getCurveLengths(); - var i = 0; - - while (i < curveLengths.length) - { - if (curveLengths[i] >= d) - { - var diff = curveLengths[i] - d; - var curve = this.curves[i]; - - var segmentLength = curve.getLength(); - var u = (segmentLength === 0) ? 0 : 1 - diff / segmentLength; - - return curve.getPointAt(u, out); - } - - i++; - } - - // loop where sum != 0, sum > d , sum+1 1 && !points[points.length - 1].equals(points[0])) - { - points.push(points[0]); - } - - return points; - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#getRandomPoint - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} [out] - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - getRandomPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return this.getPoint(Math.random(), out); - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#getSpacedPoints - * @since 3.0.0 - * - * @param {integer} [divisions=40] - [description] - * - * @return {Phaser.Math.Vector2[]} [description] - */ - getSpacedPoints: function (divisions) - { - if (divisions === undefined) { divisions = 40; } - - var points = []; - - for (var i = 0; i <= divisions; i++) - { - points.push(this.getPoint(i / divisions)); - } - - if (this.autoClose) - { - points.push(points[0]); - } - - return points; - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#getStartPoint - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} [out] - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - getStartPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return out.copy(this.startPoint); - }, - - // Creates a line curve from the previous end point to x/y - - /** - * [description] - * - * @method Phaser.Curves.Path#lineTo - * @since 3.0.0 - * - * @param {number|Phaser.Math.Vector2} x - [description] - * @param {number} [y] - [description] - * - * @return {Phaser.Curves.Path} [description] - */ - lineTo: function (x, y) - { - if (x instanceof Vector2) - { - this._tmpVec2B.copy(x); - } - else - { - this._tmpVec2B.set(x, y); - } - - var end = this.getEndPoint(this._tmpVec2A); - - return this.add(new LineCurve([ end.x, end.y, this._tmpVec2B.x, this._tmpVec2B.y ])); - }, - - // Creates a spline curve starting at the previous end point, using the given parameters - - /** - * [description] - * - * @method Phaser.Curves.Path#splineTo - * @since 3.0.0 - * - * @param {[type]} points - [description] - * - * @return {Phaser.Curves.Path} [description] - */ - splineTo: function (points) - { - points.unshift(this.getEndPoint()); - - return this.add(new SplineCurve(points)); - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#moveTo - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Curves.Path} [description] - */ - moveTo: function (x, y) - { - return this.add(new MovePathTo(x, y)); - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - var out = []; - - for (var i = 0; i < this.curves.length; i++) - { - out.push(this.curves[i].toJSON()); - } - - return { - type: 'Path', - x: this.startPoint.x, - y: this.startPoint.y, - autoClose: this.autoClose, - curves: out - }; - }, - - // cacheLengths must be recalculated. - - /** - * [description] - * - * @method Phaser.Curves.Path#updateArcLengths - * @since 3.0.0 - */ - updateArcLengths: function () - { - this.cacheLengths = []; - - this.getCurveLengths(); - }, - - /** - * [description] - * - * @method Phaser.Curves.Path#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.curves.length = 0; - this.cacheLengths.length = 0; - this.startPoint = undefined; - } - -}); - -/** - * Creates a new Path Object. - * - * @method Phaser.GameObjects.GameObjectFactory#path - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Path. - * @param {number} y - The vertical position of this Path. - * - * @return {Phaser.Curves.Path} The Path Object that was created. - */ -GameObjectFactory.register('path', function (x, y) -{ - return new Path(x, y); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - -module.exports = Path; - - -/***/ }), -/* 469 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * [description] - * - * @class MoveTo - * @memberOf Phaser.Curves - * @constructor - * @since 3.0.0 - * - * @param {number} [x] - [description] - * @param {number} [y] - [description] - */ -var MoveTo = new Class({ - - initialize: - - function MoveTo (x, y) - { - // Skip length calcs in paths - - /** - * [description] - * - * @name Phaser.Curves.MoveTo#active - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.active = false; - - /** - * [description] - * - * @name Phaser.Curves.MoveTo#p0 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p0 = new Vector2(x, y); - }, - - /** - * [description] - * - * @method Phaser.Curves.MoveTo#getPoint - * @since 3.0.0 - * - * @param {[type]} t - [description] - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - return out.copy(this.p0); - }, - - /** - * [description] - * - * @method Phaser.Curves.MoveTo#getPointAt - * @since 3.0.0 - * - * @param {[type]} u - [description] - * @param {[type]} out - [description] - * - * @return {[type]} [description] - */ - getPointAt: function (u, out) - { - return this.getPoint(u, out); - }, - - /** - * [description] - * - * @method Phaser.Curves.MoveTo#getResolution - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getResolution: function () - { - return 1; - }, - - /** - * [description] - * - * @method Phaser.Curves.MoveTo#getLength - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getLength: function () - { - return 0; - }, - - /** - * [description] - * - * @method Phaser.Curves.MoveTo#toJSON - * @since 3.0.0 - * - * @return {[type]} [description] - */ - toJSON: function () - { - return { - type: 'MoveTo', - points: [ - this.p0.x, this.p0.y - ] - }; - } - -}); - -module.exports = MoveTo; - - -/***/ }), -/* 470 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Data - */ - -module.exports = { - - DataManager: __webpack_require__(79), - DataManagerPlugin: __webpack_require__(471) - -}; - - -/***/ }), -/* 471 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var DataManager = __webpack_require__(79); -var PluginManager = __webpack_require__(12); - -/** - * @classdesc - * The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin. - * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter, - * or have a property called `events` that is an instance of it. - * - * @class DataManagerPlugin - * @extends Phaser.Data.DataManager - * @memberOf Phaser.Data - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var DataManagerPlugin = new Class({ - - Extends: DataManager, - - initialize: - - function DataManagerPlugin (scene) - { - /** - * [description] - * - * @name Phaser.Data.DataManagerPlugin#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.Data.DataManagerPlugin#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - if (!scene.sys.settings.isBooted) - { - scene.sys.events.once('boot', this.boot, this); - } - - DataManager.call(this, this.scene, scene.sys.events); - }, - - /** - * [description] - * - * @method Phaser.Data.DataManagerPlugin#boot - * @since 3.0.0 - */ - boot: function () - { - var eventEmitter = this.systems.events; - - eventEmitter.on('shutdown', this.shutdownPlugin, this); - eventEmitter.on('destroy', this.destroyPlugin, this); - }, - - /** - * [description] - * - * @method Phaser.Data.DataManagerPlugin#shutdownPlugin - * @since 3.0.0 - */ - shutdownPlugin: function () - { - // Should we reset the events? - }, - - /** - * [description] - * - * @method Phaser.Data.DataManagerPlugin#destroyPlugin - * @since 3.0.0 - */ - destroyPlugin: function () - { - this.destroy(); - - this.scene = undefined; - this.systems = undefined; - } - -}); - -PluginManager.register('DataManagerPlugin', DataManagerPlugin, 'data'); - -module.exports = DataManagerPlugin; - - -/***/ }), -/* 472 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display - */ - -module.exports = { - - Align: __webpack_require__(473), - Bounds: __webpack_require__(488), - Canvas: __webpack_require__(491), - Color: __webpack_require__(227), - Masks: __webpack_require__(502) - -}; - - -/***/ }), -/* 473 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Align - */ - -module.exports = { - - In: __webpack_require__(474), - To: __webpack_require__(475) - -}; - - -/***/ }), -/* 474 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Align.In - */ - -module.exports = { - - BottomCenter: __webpack_require__(174), - BottomLeft: __webpack_require__(175), - BottomRight: __webpack_require__(176), - Center: __webpack_require__(177), - LeftCenter: __webpack_require__(179), - QuickSet: __webpack_require__(172), - RightCenter: __webpack_require__(180), - TopCenter: __webpack_require__(181), - TopLeft: __webpack_require__(182), - TopRight: __webpack_require__(183) - -}; - - -/***/ }), -/* 475 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Align.To - */ - -module.exports = { - - BottomCenter: __webpack_require__(476), - BottomLeft: __webpack_require__(477), - BottomRight: __webpack_require__(478), - LeftBottom: __webpack_require__(479), - LeftCenter: __webpack_require__(480), - LeftTop: __webpack_require__(481), - RightBottom: __webpack_require__(482), - RightCenter: __webpack_require__(483), - RightTop: __webpack_require__(484), - TopCenter: __webpack_require__(485), - TopLeft: __webpack_require__(486), - TopRight: __webpack_require__(487) - -}; - - -/***/ }), -/* 476 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(24); -var GetCenterX = __webpack_require__(46); -var SetCenterX = __webpack_require__(47); -var SetTop = __webpack_require__(31); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the bottom center position of the other. - * - * @function Phaser.Display.Align.To.BottomCenter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var BottomCenter = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetCenterX(gameObject, GetCenterX(alignTo) + offsetX); - SetTop(gameObject, GetBottom(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = BottomCenter; - - -/***/ }), -/* 477 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(24); -var GetLeft = __webpack_require__(26); -var SetLeft = __webpack_require__(27); -var SetTop = __webpack_require__(31); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the bottom left position of the other. - * - * @function Phaser.Display.Align.To.BottomLeft - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var BottomLeft = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetLeft(alignTo) - offsetX); - SetTop(gameObject, GetBottom(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = BottomLeft; - - -/***/ }), -/* 478 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(24); -var GetRight = __webpack_require__(28); -var SetRight = __webpack_require__(29); -var SetTop = __webpack_require__(31); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the bottom right position of the other. - * - * @function Phaser.Display.Align.To.BottomRight - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var BottomRight = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetRight(alignTo) + offsetX); - SetTop(gameObject, GetBottom(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = BottomRight; - - -/***/ }), -/* 479 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(24); -var GetLeft = __webpack_require__(26); -var SetBottom = __webpack_require__(25); -var SetRight = __webpack_require__(29); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the left bottom position of the other. - * - * @function Phaser.Display.Align.To.LeftBottom - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var LeftBottom = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetLeft(alignTo) - offsetX); - SetBottom(gameObject, GetBottom(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = LeftBottom; - - -/***/ }), -/* 480 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetCenterY = __webpack_require__(49); -var GetLeft = __webpack_require__(26); -var SetCenterY = __webpack_require__(48); -var SetRight = __webpack_require__(29); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the left center position of the other. - * - * @function Phaser.Display.Align.To.LeftCenter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var LeftCenter = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetLeft(alignTo) - offsetX); - SetCenterY(gameObject, GetCenterY(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = LeftCenter; - - -/***/ }), -/* 481 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetLeft = __webpack_require__(26); -var GetTop = __webpack_require__(30); -var SetRight = __webpack_require__(29); -var SetTop = __webpack_require__(31); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the left top position of the other. - * - * @function Phaser.Display.Align.To.LeftTop - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var LeftTop = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetLeft(alignTo) - offsetX); - SetTop(gameObject, GetTop(alignTo) - offsetY); - - return gameObject; -}; - -module.exports = LeftTop; - - -/***/ }), -/* 482 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(24); -var GetRight = __webpack_require__(28); -var SetBottom = __webpack_require__(25); -var SetLeft = __webpack_require__(27); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the right bottom position of the other. - * - * @function Phaser.Display.Align.To.RightBottom - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var RightBottom = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetRight(alignTo) + offsetX); - SetBottom(gameObject, GetBottom(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = RightBottom; - - -/***/ }), -/* 483 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetCenterY = __webpack_require__(49); -var GetRight = __webpack_require__(28); -var SetCenterY = __webpack_require__(48); -var SetLeft = __webpack_require__(27); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the right center position of the other. - * - * @function Phaser.Display.Align.To.RightCenter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var RightCenter = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetRight(alignTo) + offsetX); - SetCenterY(gameObject, GetCenterY(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = RightCenter; - - -/***/ }), -/* 484 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetRight = __webpack_require__(28); -var GetTop = __webpack_require__(30); -var SetLeft = __webpack_require__(27); -var SetTop = __webpack_require__(31); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the right top position of the other. - * - * @function Phaser.Display.Align.To.RightTop - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var RightTop = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetRight(alignTo) + offsetX); - SetTop(gameObject, GetTop(alignTo) - offsetY); - - return gameObject; -}; - -module.exports = RightTop; - - -/***/ }), -/* 485 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetCenterX = __webpack_require__(46); -var GetTop = __webpack_require__(30); -var SetBottom = __webpack_require__(25); -var SetCenterX = __webpack_require__(47); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the top center position of the other. - * - * @function Phaser.Display.Align.To.TopCenter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var TopCenter = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetCenterX(gameObject, GetCenterX(alignTo) + offsetX); - SetBottom(gameObject, GetTop(alignTo) - offsetY); - - return gameObject; -}; - -module.exports = TopCenter; - - -/***/ }), -/* 486 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetLeft = __webpack_require__(26); -var GetTop = __webpack_require__(30); -var SetBottom = __webpack_require__(25); -var SetLeft = __webpack_require__(27); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the top left position of the other. - * - * @function Phaser.Display.Align.To.TopLeft - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var TopLeft = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetLeft(alignTo) - offsetX); - SetBottom(gameObject, GetTop(alignTo) - offsetY); - - return gameObject; -}; - -module.exports = TopLeft; - - -/***/ }), -/* 487 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetRight = __webpack_require__(28); -var GetTop = __webpack_require__(30); -var SetBottom = __webpack_require__(25); -var SetRight = __webpack_require__(29); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the top right position of the other. - * - * @function Phaser.Display.Align.To.TopRight - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var TopRight = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetRight(alignTo) + offsetX); - SetBottom(gameObject, GetTop(alignTo) - offsetY); - - return gameObject; -}; - -module.exports = TopRight; - - -/***/ }), -/* 488 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Bounds - */ - -module.exports = { - - CenterOn: __webpack_require__(178), - GetBottom: __webpack_require__(24), - GetCenterX: __webpack_require__(46), - GetCenterY: __webpack_require__(49), - GetLeft: __webpack_require__(26), - GetOffsetX: __webpack_require__(489), - GetOffsetY: __webpack_require__(490), - GetRight: __webpack_require__(28), - GetTop: __webpack_require__(30), - SetBottom: __webpack_require__(25), - SetCenterX: __webpack_require__(47), - SetCenterY: __webpack_require__(48), - SetLeft: __webpack_require__(27), - SetRight: __webpack_require__(29), - SetTop: __webpack_require__(31) - -}; - - -/***/ }), -/* 489 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the amount the Game Object is visually offset from its x coordinate. - * This is the same as `width * origin.x`. - * This value will only be > 0 if `origin.x` is not equal to zero. - * - * @function Phaser.Display.Bounds.GetOffsetX - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The horizontal offset of the Game Object. - */ -var GetOffsetX = function (gameObject) -{ - return gameObject.width * gameObject.originX; -}; - -module.exports = GetOffsetX; - - -/***/ }), -/* 490 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the amount the Game Object is visually offset from its y coordinate. - * This is the same as `width * origin.y`. - * This value will only be > 0 if `origin.y` is not equal to zero. - * - * @function Phaser.Display.Bounds.GetOffsetY - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The vertical offset of the Game Object. - */ -var GetOffsetY = function (gameObject) -{ - return gameObject.height * gameObject.originY; -}; - -module.exports = GetOffsetY; - - -/***/ }), -/* 491 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Canvas - */ - -module.exports = { - - Interpolation: __webpack_require__(226), - Pool: __webpack_require__(21), - Smoothing: __webpack_require__(121), - TouchAction: __webpack_require__(492), - UserSelect: __webpack_require__(493) - -}; - - -/***/ }), -/* 492 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions. - * - * @function Phaser.Display.Canvas.TouchAction - * @since 3.0.0 - * - * @param {HTMLCanvasElement} canvas - The canvas element to have the style applied to. - * @param {string} [value='none'] - The touch action value to set on the canvas. Set to `none` to disable touch actions. - * - * @return {HTMLCanvasElement} The canvas element. - */ -var TouchAction = function (canvas, value) -{ - if (value === undefined) { value = 'none'; } - - canvas.style['msTouchAction'] = value; - canvas.style['ms-touch-action'] = value; - canvas.style['touch-action'] = value; - - return canvas; -}; - -module.exports = TouchAction; - - -/***/ }), -/* 493 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Sets the user-select property on the canvas style. Can be used to disable default browser selection actions. - * - * @function Phaser.Display.Canvas.UserSelect - * @since 3.0.0 - * - * @param {HTMLCanvasElement} canvas - The canvas element to have the style applied to. - * @param {string} [value='none'] - The touch callout value to set on the canvas. Set to `none` to disable touch callouts. - * - * @return {HTMLCanvasElement} The canvas element. - */ -var UserSelect = function (canvas, value) -{ - if (value === undefined) { value = 'none'; } - - var vendors = [ - '-webkit-', - '-khtml-', - '-moz-', - '-ms-', - '' - ]; - - vendors.forEach(function (vendor) - { - canvas.style[vendor + 'user-select'] = value; - }); - - canvas.style['-webkit-touch-callout'] = value; - canvas.style['-webkit-tap-highlight-color'] = 'rgba(0, 0, 0, 0)'; - - return canvas; -}; - -module.exports = UserSelect; - - -/***/ }), -/* 494 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @typedef {Object} ColorObject - * @property {number} r - The red color value in the range 0 to 255. - * @property {number} g - The green color value in the range 0 to 255. - * @property {number} b - The blue color value in the range 0 to 255. - * @property {number} a - The alpha color value in the range 0 to 255. - */ - -/** - * Converts the given color value into an Object containing r,g,b and a properties. - * - * @function Phaser.Display.Color.ColorToRGBA - * @since 3.0.0 - * - * @param {number} color - A color value, optionally including the alpha value. - * - * @return {ColorObject} An object containing the parsed color values. - */ -var ColorToRGBA = function (color) -{ - var output = { - r: color >> 16 & 0xFF, - g: color >> 8 & 0xFF, - b: color & 0xFF, - a: 255 - }; - - if (color > 16777215) - { - output.a = color >>> 24; - } - - return output; -}; - -module.exports = ColorToRGBA; - - -/***/ }), -/* 495 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Color = __webpack_require__(36); -var HueToComponent = __webpack_require__(229); - -/** - * Converts HSL (hue, saturation and lightness) values to a Phaser Color object. - * - * @function Phaser.Display.Color.HSLToColor - * @since 3.0.0 - * - * @param {number} h - The hue value in the range 0 to 1. - * @param {number} s - The saturation value in the range 0 to 1. - * @param {number} l - The lightness value in the range 0 to 1. - * - * @return {Phaser.Display.Color} A Color object created from the results of the h, s and l values. - */ -var HSLToColor = function (h, s, l) -{ - // achromatic by default - var r = l; - var g = l; - var b = l; - - if (s !== 0) - { - var q = (l < 0.5) ? l * (1 + s) : l + s - l * s; - var p = 2 * l - q; - - r = HueToComponent(p, q, h + 1 / 3); - g = HueToComponent(p, q, h); - b = HueToComponent(p, q, h - 1 / 3); - } - - var color = new Color(); - - return color.setGLTo(r, g, b, 1); -}; - -module.exports = HSLToColor; - - -/***/ }), -/* 496 */ -/***/ (function(module, exports) { - -module.exports = function(module) { - if(!module.webpackPolyfill) { - module.deprecate = function() {}; - module.paths = []; - // module.parent = undefined by default - if(!module.children) module.children = []; - Object.defineProperty(module, "loaded", { - enumerable: true, - get: function() { - return module.l; - } - }); - Object.defineProperty(module, "id", { - enumerable: true, - get: function() { - return module.i; - } - }); - module.webpackPolyfill = 1; - } - return module; -}; - - -/***/ }), -/* 497 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var HSVToRGB = __webpack_require__(230); - -/** - * Get HSV color wheel values in an array which will be 360 elements in size. - * - * @function Phaser.Display.Color.HSVColorWheel - * @since 3.0.0 - * - * @param {number} [s=1] - The saturation, in the range 0 - 1. - * @param {number} [v=1] - The value, in the range 0 - 1. - * - * @return {array} An array containing 360 elements, where each contains a single numeric value corresponding to the color at that point in the HSV color wheel. - */ -var HSVColorWheel = function (s, v) -{ - if (s === undefined) { s = 1; } - if (v === undefined) { v = 1; } - - var colors = []; - - for (var c = 0; c <= 359; c++) - { - colors.push(HSVToRGB(c / 359, s, v)); - } - - return colors; -}; - -module.exports = HSVColorWheel; - - -/***/ }), -/* 498 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Linear = __webpack_require__(124); - -/** - * Interpolates color values - * - * @namespace Phaser.Display.Color.Interpolate - * @since 3.0.0 - */ - -/** - * Interpolates between the two given color ranges over the length supplied. - * - * @function Phaser.Display.Color.Interpolate.RGBWithRGB - * @since 3.0.0 - * - * @param {number} r1 - Red value. - * @param {number} g1 - Blue value. - * @param {number} b1 - Green value. - * @param {number} r2 - Red value. - * @param {number} g2 - Blue value. - * @param {number} b2 - Green value. - * @param {number} [length=100] - Distance to interpolate over. - * @param {number} [index=0] - Index to start from. - * - * @return {ColorObject} An object containing the interpolated color values. - */ -var RGBWithRGB = function (r1, g1, b1, r2, g2, b2, length, index) -{ - if (length === undefined) { length = 100; } - if (index === undefined) { index = 0; } - - var t = index / length; - - return { - r: Linear(r1, r2, t), - g: Linear(g1, g2, t), - b: Linear(b1, b2, t) - }; -}; - -/** - * Interpolates between the two given color objects over the length supplied. - * - * @function Phaser.Display.Color.Interpolate.ColorWithColor - * @since 3.0.0 - * - * @param {Phaser.Display.Color} color1 - The first Color object. - * @param {Phaser.Display.Color} color2 - The second Color object. - * @param {number} [length=100] - Distance to interpolate over. - * @param {number} [index=0] - Index to start from. - * - * @return {ColorObject} An object containing the interpolated color values. - */ -var ColorWithColor = function (color1, color2, length, index) -{ - if (length === undefined) { length = 100; } - if (index === undefined) { index = 0; } - - return RGBWithRGB(color1.r, color1.g, color1.b, color2.r, color2.g, color2.b, length, index); -}; - -/** - * Interpolates between the Color object and color values over the length supplied. - * - * @function Phaser.Display.Color.Interpolate.ColorWithRGB - * @since 3.0.0 - * - * @param {Phaser.Display.Color} color1 - The first Color object. - * @param {number} r - Red value. - * @param {number} g - Blue value. - * @param {number} b - Green value. - * @param {number} [length=100] - Distance to interpolate over. - * @param {number} [index=0] - Index to start from. - * - * @return {ColorObject} An object containing the interpolated color values. - */ -var ColorWithRGB = function (color, r, g, b, length, index) -{ - if (length === undefined) { length = 100; } - if (index === undefined) { index = 0; } - - return RGBWithRGB(color.r, color.g, color.b, r, g, b, length, index); -}; - -module.exports = { - - RGBWithRGB: RGBWithRGB, - ColorWithRGB: ColorWithRGB, - ColorWithColor: ColorWithColor - -}; - - -/***/ }), -/* 499 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Between = __webpack_require__(231); -var Color = __webpack_require__(36); - -/** - * Creates a new Color object where the r, g, and b values have been set to random values - * based on the given min max values. - * - * @function Phaser.Display.Color.RandomRGB - * @since 3.0.0 - * - * @param {integer} [min=0] - The minimum value to set the random range from (between 0 and 255) - * @param {integer} [max=255] - The maximum value to set the random range from (between 0 and 255) - * - * @return {Phaser.Display.Color} A Color object. - */ -var RandomRGB = function (min, max) -{ - if (min === undefined) { min = 0; } - if (max === undefined) { max = 255; } - - return new Color(Between(min, max), Between(min, max), Between(min, max)); -}; - -module.exports = RandomRGB; - - -/***/ }), -/* 500 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Converts an RGB color value to HSV (hue, saturation and value). - * Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space. - * Assumes RGB values are contained in the set [0, 255] and returns h, s and v in the set [0, 1]. - * Based on code by Michael Jackson (https://github.com/mjijackson) - * - * @function Phaser.Display.Color.RGBToHSV - * @since 3.0.0 - * - * @param {integer} r - The red color value. A number between 0 and 255. - * @param {integer} g - The green color value. A number between 0 and 255. - * @param {integer} b - The blue color value. A number between 0 and 255. - * - * @return {object} An object with the properties `h`, `s` and `v`. - */ -var RGBToHSV = function (r, g, b) -{ - r /= 255; - g /= 255; - b /= 255; - - var min = Math.min(r, g, b); - var max = Math.max(r, g, b); - var d = max - min; - - // achromatic by default - var h = 0; - var s = (max === 0) ? 0 : d / max; - var v = max; - - if (max !== min) - { - if (max === r) - { - h = (g - b) / d + ((g < b) ? 6 : 0); - } - else if (max === g) - { - h = (b - r) / d + 2; - } - else if (max === b) - { - h = (r - g) / d + 4; - } - - h /= 6; - } - - return { h: h, s: s, v: v }; -}; - -module.exports = RGBToHSV; - - -/***/ }), -/* 501 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ComponentToHex = __webpack_require__(228); - -/** - * Converts the color values into an HTML compatible color string, prefixed with either `#` or `0x`. - * - * @function Phaser.Display.Color.RGBToString - * @since 3.0.0 - * - * @param {integer} r - The red color value. A number between 0 and 255. - * @param {integer} g - The green color value. A number between 0 and 255. - * @param {integer} b - The blue color value. A number between 0 and 255. - * @param {integer} [a=255] - The alpha value. A number between 0 and 255. - * @param {string} [prefix=#] - The prefix of the string. Either `#` or `0x`. - * - * @return {string} A string-based representation of the color values. - */ -var RGBToString = function (r, g, b, a, prefix) -{ - if (a === undefined) { a = 255; } - if (prefix === undefined) { prefix = '#'; } - - if (prefix === '#') - { - return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); - } - else - { - return '0x' + ComponentToHex(a) + ComponentToHex(r) + ComponentToHex(g) + ComponentToHex(b); - } -}; - -module.exports = RGBToString; - - -/***/ }), -/* 502 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Masks - */ - -module.exports = { - - BitmapMask: __webpack_require__(503), - GeometryMask: __webpack_require__(504) - -}; - - -/***/ }), -/* 503 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class BitmapMask - * @memberOf Phaser.Display.Masks - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {[type]} renderable - [description] - */ -var BitmapMask = new Class({ - - initialize: - - function BitmapMask (scene, renderable) - { - var renderer = scene.sys.game.renderer; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#bitmapMask - * @type {[type]} - * @since 3.0.0 - */ - this.bitmapMask = renderable; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#maskRenderTarget - * @type {[type]} - * @default null - * @since 3.0.0 - */ - this.maskRenderTarget = null; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#mainRenderTarget - * @type {[type]} - * @default null - * @since 3.0.0 - */ - this.mainRenderTarget = null; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#maskTexture - * @type {[type]} - * @default null - * @since 3.0.0 - */ - this.maskTexture = null; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#mainTexture - * @type {[type]} - * @default null - * @since 3.0.0 - */ - this.mainTexture = null; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#dirty - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.dirty = true; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#mainFramebuffer - * @type {WebGLFramebuffer} - * @since 3.0.0 - */ - this.mainFramebuffer = null; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#maskFramebuffer - * @type {WebGLFramebuffer} - * @since 3.0.0 - */ - this.maskFramebuffer = null; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#invertAlpha - * @type {boolean} - * @since 3.1.2 - */ - this.invertAlpha = false; - - if (renderer && renderer.gl) - { - var width = renderer.width; - var height = renderer.height; - var pot = ((width & (width - 1)) === 0 && (height & (height - 1)) === 0); - var gl = renderer.gl; - var wrap = pot ? gl.REPEAT : gl.CLAMP_TO_EDGE; - var filter = gl.LINEAR; - - this.mainTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); - this.maskTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); - this.mainFramebuffer = renderer.createFramebuffer(width, height, this.mainTexture, false); - this.maskFramebuffer = renderer.createFramebuffer(width, height, this.maskTexture, false); - - renderer.onContextRestored(function (renderer) - { - var width = renderer.width; - var height = renderer.height; - var pot = ((width & (width - 1)) === 0 && (height & (height - 1)) === 0); - var gl = renderer.gl; - var wrap = pot ? gl.REPEAT : gl.CLAMP_TO_EDGE; - var filter = gl.LINEAR; - - this.mainTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); - this.maskTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); - this.mainFramebuffer = renderer.createFramebuffer(width, height, this.mainTexture, false); - this.maskFramebuffer = renderer.createFramebuffer(width, height, this.maskTexture, false); - - }, this); - } - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.BitmapMask#setBitmap - * @since 3.0.0 - * - * @param {[type]} renderable - [description] - */ - setBitmap: function (renderable) - { - this.bitmapMask = renderable; - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.BitmapMask#preRenderWebGL - * @since 3.0.0 - * - * @param {[type]} renderer - [description] - * @param {[type]} maskedObject - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to render to. - */ - preRenderWebGL: function (renderer, maskedObject, camera) - { - renderer.pipelines.BitmapMaskPipeline.beginMask(this, maskedObject, camera); - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.BitmapMask#postRenderWebGL - * @since 3.0.0 - * - * @param {[type]} renderer - [description] - */ - postRenderWebGL: function (renderer) - { - renderer.pipelines.BitmapMaskPipeline.endMask(this); - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.BitmapMask#preRenderCanvas - * @since 3.0.0 - * - * @param {[type]} renderer - [description] - * @param {[type]} mask - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to render to. - */ - preRenderCanvas: function () - { - // NOOP - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.BitmapMask#postRenderCanvas - * @since 3.0.0 - * - * @param {[type]} renderer - [description] - */ - postRenderCanvas: function () - { - // NOOP - } - -}); - -module.exports = BitmapMask; - - -/***/ }), -/* 504 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class GeometryMask - * @memberOf Phaser.Display.Masks - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {[type]} graphicsGeometry - [description] - */ -var GeometryMask = new Class({ - - initialize: - - function GeometryMask (scene, graphicsGeometry) - { - /** - * [description] - * - * @name Phaser.Display.Masks.GeometryMask#geometryMask - * @type {Phaser.GameObjects.Graphics} - * @since 3.0.0 - */ - this.geometryMask = graphicsGeometry; - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.GeometryMask#setShape - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphicsGeometry - [description] - */ - setShape: function (graphicsGeometry) - { - this.geometryMask = graphicsGeometry; - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.GeometryMask#preRenderWebGL - * @since 3.0.0 - * - * @param {[type]} renderer - [description] - * @param {[type]} mask - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - preRenderWebGL: function (renderer, mask, camera) - { - var gl = renderer.gl; - var geometryMask = this.geometryMask; - - // Force flushing before drawing to stencil buffer - renderer.flush(); - - // Enable and setup GL state to write to stencil buffer - gl.enable(gl.STENCIL_TEST); - gl.clear(gl.STENCIL_BUFFER_BIT); - gl.colorMask(false, false, false, false); - gl.stencilFunc(gl.NOTEQUAL, 1, 1); - gl.stencilOp(gl.REPLACE, gl.REPLACE, gl.REPLACE); - - // Write stencil buffer - geometryMask.renderWebGL(renderer, geometryMask, 0.0, camera); - renderer.flush(); - - // Use stencil buffer to affect next rendering object - gl.colorMask(true, true, true, true); - gl.stencilFunc(gl.EQUAL, 1, 1); - gl.stencilOp(gl.INVERT, gl.INVERT, gl.INVERT); - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.GeometryMask#postRenderWebGL - * @since 3.0.0 - * - * @param {[type]} renderer - [description] - */ - postRenderWebGL: function (renderer) - { - var gl = renderer.gl; - - // Force flush before disabling stencil test - renderer.flush(); - gl.disable(gl.STENCIL_TEST); - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.GeometryMask#preRenderCanvas - * @since 3.0.0 - * - * @param {[type]} renderer - [description] - * @param {[type]} mask - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - preRenderCanvas: function (renderer, mask, camera) - { - var geometryMask = this.geometryMask; - - renderer.currentContext.save(); - - geometryMask.renderCanvas(renderer, geometryMask, 0.0, camera, null, true); - - renderer.currentContext.clip(); - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.GeometryMask#postRenderCanvas - * @since 3.0.0 - * - * @param {[type]} renderer - [description] - */ - postRenderCanvas: function (renderer) - { - renderer.currentContext.restore(); - } - -}); - -module.exports = GeometryMask; - - -/***/ }), -/* 505 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.DOM - */ - -module.exports = { - - AddToDOM: __webpack_require__(125), - DOMContentLoaded: __webpack_require__(232), - ParseXML: __webpack_require__(233), - RemoveFromDOM: __webpack_require__(234), - RequestAnimationFrame: __webpack_require__(235) - -}; - - -/***/ }), -/* 506 */ -/***/ (function(module, exports) { - -// shim for using process in browser -var process = module.exports = {}; - -// cached from whatever global is present so that test runners that stub it -// don't break things. But we need to wrap it in a try catch in case it is -// wrapped in strict mode code which doesn't define any globals. It's inside a -// function because try/catches deoptimize in certain engines. - -var cachedSetTimeout; -var cachedClearTimeout; - -function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); -} -function defaultClearTimeout () { - throw new Error('clearTimeout has not been defined'); -} -(function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } -} ()) -function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); - } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); - } - } - - -} -function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); - } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); - } - } - - - -} -var queue = []; -var draining = false; -var currentQueue; -var queueIndex = -1; - -function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - if (queue.length) { - drainQueue(); - } -} - -function drainQueue() { - if (draining) { - return; - } - var timeout = runTimeout(cleanUpNextTick); - draining = true; - - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - runClearTimeout(timeout); -} - -process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; -process.prependListener = noop; -process.prependOnceListener = noop; - -process.listeners = function (name) { return [] } - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - - -/***/ }), -/* 507 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var EE = __webpack_require__(14); -var PluginManager = __webpack_require__(12); - -/** - * @namespace Phaser.Events - */ - -/** - * @classdesc - * EventEmitter is a Scene Systems plugin compatible version of eventemitter3. - * - * @class EventEmitter - * @extends EventEmitter - * @memberOf Phaser.Events - * @constructor - * @since 3.0.0 - */ -var EventEmitter = new Class({ - - Extends: EE, - - initialize: - - function EventEmitter () - { - EE.call(this); - }, - - /** - * Removes all listeners. - * - * @method Phaser.Events.EventEmitter#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this.removeAllListeners(); - }, - - /** - * Removes all listeners. - * - * @method Phaser.Events.EventEmitter#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.removeAllListeners(); - } - -}); - -/** - * @namespace EventEmitter - */ - -/** - * Return an array listing the events for which the emitter has registered listeners. - * - * @method EventEmitter#eventNames - * - * @return {array} - */ - -/** - * Return the listeners registered for a given event. - * - * @method EventEmitter#listeners - * - * @param {string|symbol} event - The event name. - * - * @return {array} The registered listeners. - */ - -/** - * Return the number of listeners listening to a given event. - * - * @method EventEmitter#listenerCount - * - * @param {string|symbol} event - The event name. - * - * @return {number} The number of listeners. - */ - -/** - * Calls each of the listeners registered for a given event. - * - * @method EventEmitter#emit - * - * @param {string|symbol} event - The event name. - * - * @return {Boolean} `true` if the event had listeners, else `false`. - */ - -/** - * Add a listener for a given event. - * - * @method EventEmitter#on - * - * @param {string|symbol} event - The event name. - * @param {function} fn - The listener function. - * @param {*} [context=this] - The context to invoke the listener with. - * - * @return {EventEmitter} `this`. - */ - -/** - * Add a listener for a given event. - * - * @method EventEmitter#addListener - * - * @param {string|symbol} event - The event name. - * @param {function} fn - The listener function. - * @param {*} [context=this] - The context to invoke the listener with. - * - * @return {EventEmitter} `this`. - */ - -/** - * Add a one-time listener for a given event. - * - * @method EventEmitter#once - * - * @param {string|symbol} event - The event name. - * @param {function} fn - The listener function. - * @param {*} [context=this] - The context to invoke the listener with. - * - * @return {EventEmitter} `this`. - */ - -/** - * Remove the listeners of a given event. - * - * @method EventEmitter#removeListener - * - * @param {string|symbol} event - The event name. - * @param {function} fn - Only remove the listeners that match this function. - * @param {*} context - Only remove the listeners that have this context. - * @param {boolean} once - Only remove one-time listeners. - * - * @return {EventEmitter} `this`. - */ - -/** - * Remove the listeners of a given event. - * - * @method EventEmitter#off - * - * @param {string|symbol} event - The event name. - * @param {function} fn - Only remove the listeners that match this function. - * @param {*} context - Only remove the listeners that have this context. - * @param {boolean} once - Only remove one-time listeners. - * - * @return {EventEmitter} `this`. - */ - -/** - * Remove all listeners, or those of the specified event. - * - * @method EventEmitter#removeAllListeners - * - * @param {string|symbol} [event] - The event name. - * - * @return {EventEmitter} `this`. - */ - -PluginManager.register('EventEmitter', EventEmitter, 'events'); - -module.exports = EventEmitter; - - -/***/ }), -/* 508 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var AddToDOM = __webpack_require__(125); -var AnimationManager = __webpack_require__(199); -var CacheManager = __webpack_require__(202); -var CanvasPool = __webpack_require__(21); -var Class = __webpack_require__(0); -var Config = __webpack_require__(509); -var CreateRenderer = __webpack_require__(510); -var DataManager = __webpack_require__(79); -var DebugHeader = __webpack_require__(518); -var Device = __webpack_require__(519); -var DOMContentLoaded = __webpack_require__(232); -var EventEmitter = __webpack_require__(14); -var InputManager = __webpack_require__(240); -var NOOP = __webpack_require__(3); -var PluginManager = __webpack_require__(12); -var SceneManager = __webpack_require__(252); -var SoundManagerCreator = __webpack_require__(256); -var TextureManager = __webpack_require__(263); -var TimeStep = __webpack_require__(542); -var VisibilityHandler = __webpack_require__(543); - -/** - * @classdesc - * The Phaser.Game instance is the main controller for the entire Phaser game. It is responsible - * for handling the boot process, parsing the configuration values, creating the renderer, - * and setting-up all of the global Phaser systems, such as sound and input. - * Once that is complete it will start the Scene Manager and then begin the main game loop. - * - * You should generally avoid accessing any of the systems created by Game, and instead use those - * made available to you via the Phaser.Scene Systems class instead. - * - * @class Game - * @memberOf Phaser - * @constructor - * @since 3.0.0 - * - * @param {object} [GameConfig] - The configuration object for your Phaser Game instance. - */ -var Game = new Class({ - - initialize: - - function Game (config) - { - /** - * The parsed Game Configuration object. - * - * The values stored within this object are read-only and should not be changed at run-time. - * - * @name Phaser.Game#config - * @type {Phaser.Boot.Config} - * @readOnly - * @since 3.0.0 - */ - this.config = new Config(config); - - /** - * A reference to either the Canvas or WebGL Renderer that this Game is using. - * - * @name Phaser.Game#renderer - * @type {Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer} - * @since 3.0.0 - */ - this.renderer = null; - - /** - * A reference to the HTML Canvas Element on which the renderer is drawing. - * - * @name Phaser.Game#canvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.canvas = null; - - /** - * A reference to the Canvas Rendering Context belonging to the Canvas Element this game is rendering to. - * - * @name Phaser.Game#context - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.context = null; - - /** - * A flag indicating when this Game instance has finished its boot process. - * - * @name Phaser.Game#isBooted - * @type {boolean} - * @readOnly - * @since 3.0.0 - */ - this.isBooted = false; - - /** - * A flag indicating if this Game is currently running its game step or not. - * - * @name Phaser.Game#isRunning - * @type {boolean} - * @readOnly - * @since 3.0.0 - */ - this.isRunning = false; - - /** - * An Event Emitter which is used to broadcast game-level events from the global systems. - * - * @name Phaser.Game#events - * @type {EventEmitter} - * @since 3.0.0 - */ - this.events = new EventEmitter(); - - /** - * An instance of the Animation Manager. - * - * The Animation Manager is a global system responsible for managing all animations used within your game. - * - * @name Phaser.Game#anims - * @type {Phaser.Animations.AnimationManager} - * @since 3.0.0 - */ - this.anims = new AnimationManager(this); - - /** - * An instance of the Texture Manager. - * - * The Texture Manager is a global system responsible for managing all textures being used by your game. - * - * @name Phaser.Game#textures - * @type {Phaser.Textures.TextureManager} - * @since 3.0.0 - */ - this.textures = new TextureManager(this); - - /** - * An instance of the Cache Manager. - * - * The Cache Manager is a global system responsible for caching, accessing and releasing external game assets. - * - * @name Phaser.Game#cache - * @type {Phaser.Cache.CacheManager} - * @since 3.0.0 - */ - this.cache = new CacheManager(this); - - /** - * [description] - * - * @name Phaser.Game#registry - * @type {Phaser.Data.DataManager} - * @since 3.0.0 - */ - this.registry = new DataManager(this); - - /** - * An instance of the Input Manager. - * - * The Input Manager is a global system responsible for the capture of browser-level input events. - * - * @name Phaser.Game#input - * @type {Phaser.Input.InputManager} - * @since 3.0.0 - */ - this.input = new InputManager(this, this.config); - - /** - * An instance of the Scene Manager. - * - * The Scene Manager is a global system responsible for creating, modifying and updating the Scenes in your game. - * - * @name Phaser.Game#scene - * @type {Phaser.Scenes.SceneManager} - * @since 3.0.0 - */ - this.scene = new SceneManager(this, this.config.sceneConfig); - - /** - * A reference to the Device inspector. - * - * Contains information about the device running this game, such as OS, browser vendor and feature support. - * Used by various systems to determine capabilities and code paths. - * - * @name Phaser.Game#device - * @type {Phaser.Device} - * @since 3.0.0 - */ - this.device = Device; - - /** - * An instance of the base Sound Manager. - * - * The Sound Manager is a global system responsible for the playback and updating of all audio in your game. - * - * @name Phaser.Game#sound - * @type {Phaser.BaseSoundManager} - * @since 3.0.0 - */ - this.sound = SoundManagerCreator.create(this); - - /** - * An instance of the Time Step. - * - * The Time Step is a global system responsible for setting-up and responding to the browser frame events, processing - * them and calculating delta values. It then automatically calls the game step. - * - * @name Phaser.Game#loop - * @type {Phaser.Boot.TimeStep} - * @since 3.0.0 - */ - this.loop = new TimeStep(this, this.config.fps); - - /** - * An instance of the Plugin Manager. - * - * The Plugin Manager is a global system that allows plugins to register themselves with it, and can then install - * those plugins into Scenes as required. - * - * @name Phaser.Game#plugins - * @type {Phaser.Boot.PluginManager} - * @since 3.0.0 - */ - this.plugins = new PluginManager(this, this.config); - - /** - * The `onStepCallback` is a callback that is fired each time the Time Step ticks. - * It is set automatically when the Game boot process has completed. - * - * @name Phaser.Game#onStepCallback - * @type {function} - * @private - * @since 3.0.0 - */ - this.onStepCallback = NOOP; - - // Wait for the DOM Ready event, then call boot. - DOMContentLoaded(this.boot.bind(this)); - }, - - /** - * Game boot event. - * - * This is an internal event dispatched when the game has finished booting, but before it is ready to start running. - * The global systems use this event to know when to set themselves up, dispatching their own `ready` events as required. - * - * @event Phaser.Game#boot - */ - - /** - * This method is called automatically when the DOM is ready. It is responsible for creating the renderer, - * displaying the Debug Header, adding the game canvas to the DOM and emitting the 'boot' event. - * It listens for a 'ready' event from the base systems and once received it will call `Game.start`. - * - * @method Phaser.Game#boot - * @protected - * @fires Phaser.Game#boot - * @since 3.0.0 - */ - boot: function () - { - this.isBooted = true; - - this.config.preBoot(this); - - CreateRenderer(this); - - DebugHeader(this); - - AddToDOM(this.canvas, this.config.parent); - - this.events.emit('boot'); - - // The Texture Manager has to wait on a couple of non-blocking events before it's fully ready, so it will emit this event - this.events.once('ready', this.start, this); - }, - - /** - * Called automatically by Game.boot once all of the global systems have finished setting themselves up. - * By this point the Game is now ready to start the main loop running. - * It will also enable the Visibility Handler. - * - * @method Phaser.Game#start - * @protected - * @since 3.0.0 - */ - start: function () - { - this.isRunning = true; - - this.config.postBoot(this); - - if (this.renderer) - { - this.loop.start(this.step.bind(this)); - } - else - { - this.loop.start(this.headlessStep.bind(this)); - } - - VisibilityHandler(this.events); - - this.events.on('hidden', this.onHidden, this); - this.events.on('visible', this.onVisible, this); - this.events.on('blur', this.onBlur, this); - this.events.on('focus', this.onFocus, this); - }, - - /** - * Game Pre-Render event. - * - * This event is dispatched immediately before any of the Scenes have started to render. - * The renderer will already have been initialized this frame, clearing itself and preparing to receive - * the Scenes for rendering, but it won't have actually drawn anything yet. - * - * @event Phaser.Game#prerenderEvent - * @param {Phaser.Renderer.CanvasRenderer|Phaser.Renderer.WebGLRenderer} renderer - A reference to the current renderer. - */ - - /** - * Game Post-Render event. - * - * This event is dispatched right at the end of the render process. - * Every Scene will have rendered and drawn to the canvas. - * - * @event Phaser.Game#postrenderEvent - * @param {Phaser.Renderer.CanvasRenderer|Phaser.Renderer.WebGLRenderer} renderer - A reference to the current renderer. - */ - - /** - * The main Game Step. Called automatically by the Time Step, once per browser frame (typically as a result of - * Request Animation Frame, or Set Timeout on very old browsers.) - * - * The step will update the global managers first, then proceed to update each Scene in turn, via the Scene Manager. - * - * It will then render each Scene in turn, via the Renderer. This process emits `prerender` and `postrender` events. - * - * @method Phaser.Game#step - * @fires Phaser.Game#prerenderEvent - * @fires Phaser.Game#postrenderEvent - * @since 3.0.0 - * - * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {number} delta - The delta time elapsed since the last frame. - */ - step: function (time, delta) - { - // Global Managers - - this.input.update(time, delta); - - this.sound.update(time, delta); - - // Scenes - - this.onStepCallback(); - - this.scene.update(time, delta); - - // Render - - var renderer = this.renderer; - - renderer.preRender(); - - this.events.emit('prerender', renderer); - - this.scene.render(renderer); - - renderer.postRender(); - - this.events.emit('postrender', renderer); - }, - - /** - * A special version of the Game Step for the HEADLESS renderer only. - * - * The main Game Step. Called automatically by the Time Step, once per browser frame (typically as a result of - * Request Animation Frame, or Set Timeout on very old browsers.) - * - * The step will update the global managers first, then proceed to update each Scene in turn, via the Scene Manager. - * - * This process emits `prerender` and `postrender` events, even though nothing actually displays. - * - * @method Phaser.Game#headlessStep - * @fires Phaser.Game#prerenderEvent - * @fires Phaser.Game#postrenderEvent - * @since 3.2.0 - * - * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {number} delta - The delta time elapsed since the last frame. - */ - headlessStep: function (time, delta) - { - // Global Managers - - this.input.update(time, delta); - - this.sound.update(time, delta); - - // Scenes - - this.onStepCallback(); - - this.scene.update(time, delta); - - // Render - - this.events.emit('prerender'); - - this.events.emit('postrender'); - }, - - /** - * Game Pause event. - * - * This event is dispatched when the game loop enters a paused state, usually as a result of the Visibility Handler. - * - * @event Phaser.Game#pauseEvent - */ - - /** - * Called automatically by the Visibility Handler. - * This will pause the main loop and then emit a pause event. - * - * @method Phaser.Game#onHidden - * @protected - * @fires Phaser.Game#pauseEvent - * @since 3.0.0 - */ - onHidden: function () - { - this.loop.pause(); - - this.events.emit('pause'); - }, - - /** - * Game Resume event. - * - * This event is dispatched when the game loop leaves a paused state and resumes running. - * - * @event Phaser.Game#resumeEvent - */ - - /** - * Called automatically by the Visibility Handler. - * This will resume the main loop and then emit a resume event. - * - * @method Phaser.Game#onVisible - * @protected - * @fires Phaser.Game#resumeEvent - * @since 3.0.0 - */ - onVisible: function () - { - this.loop.resume(); - - this.events.emit('resume'); - }, - - /** - * Called automatically by the Visibility Handler. - * This will set the main loop into a 'blurred' state, which pauses it. - * - * @method Phaser.Game#onBlur - * @protected - * @since 3.0.0 - */ - onBlur: function () - { - this.loop.blur(); - }, - - /** - * Called automatically by the Visibility Handler. - * This will set the main loop into a 'focused' state, which resumes it. - * - * @method Phaser.Game#onFocus - * @protected - * @since 3.0.0 - */ - onFocus: function () - { - this.loop.focus(); - }, - - /** - * Game Resize event. - * - * @event Phaser.Game#resizeEvent - * @param {number} width - The new width of the Game. - * @param {number} height - The new height of the Game. - */ - - /** - * Updates the Game Config with the new width and height values given. - * Then resizes the Renderer and Input Manager scale. - * - * @method Phaser.Game#resize - * @since 3.2.0 - * - * @param {number} width - The new width of the game. - * @param {number} height - The new height of the game. - */ - resize: function (width, height) - { - this.config.width = width; - this.config.height = height; - - this.renderer.resize(width, height); - - this.input.resize(); - - this.scene.resize(width, height); - - this.events.emit('resize', width, height); - }, - - /** - * Destroys this Phaser.Game instance, all global systems, all sub-systems and all Scenes. - * - * @method Phaser.Game#destroy - * @since 3.0.0 - */ - destroy: function (removeCanvas) - { - this.loop.destroy(); - - this.scene.destroy(); - - this.renderer.destroy(); - - this.events.emit('destroy'); - - this.events.removeAllListeners(); - - this.onStepCallback = null; - - if (removeCanvas) - { - CanvasPool.remove(this.canvas); - } - } - -}); - -module.exports = Game; - - -/***/ }), -/* 509 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(19); -var GetValue = __webpack_require__(4); -var MATH = __webpack_require__(16); -var NOOP = __webpack_require__(3); -var Plugins = __webpack_require__(236); -var ValueToColor = __webpack_require__(116); - -/** - * This callback type is completely empty, a no-operation. - * - * @callback NOOP - */ - -/** - * @typedef {object} FPSConfig - * - * @property {integer} [min=10] - [description] - * @property {integer} [target=60] - [description] - * @property {boolean} [forceSetTimeOut=false] - [description] - * @property {integer} [deltaHistory=10] - [description] - * @property {integer} [panicMax=120] - [description] - */ - -/** - * @typedef {object} LoaderConfig - * - * @property {string} [baseURL] - [description] - * @property {string} [path] - [description] - * @property {boolean} [enableParallel=true] - [description] - * @property {integer} [maxParallelDownloads=4] - [description] - * @property {string|undefined} [crossOrigin=undefined] - [description] - * @property {string} [responseType] - [description] - * @property {boolean} [async=true] - [description] - * @property {string} [user] - [description] - * @property {string} [password] - [description] - * @property {integer} [timeout=0] - [description] - */ - -/** - * @typedef {object} GameConfig - * - * @property {integer|string} [width=1024] - [description] - * @property {integer|string} [height=768] - [description] - * @property {number} [zoom=1] - [description] - * @property {number} [resolution=1] - [description] - * @property {number} [type=CONST.AUTO] - [description] - * @property {object} [?parent=null] - [description] - * @property {HTMLCanvasElement} [?canvas=null] - [description] - * @property {string} [?canvasStyle=null] - [description] - * @property {object} [?scene=null] - [description] - * @property {array} [seed] - [description] - * @property {string} [title=''] - [description] - * @property {string} [url='http://phaser.io'] - [description] - * @property {string} [version=''] - [description] - * @property {object} [input] - [description] - * @property {boolean} [input.keyboard=true] - [description] - * @property {object} [input.keyboard.target=window] - [description] - * @property {boolean} [input.mouse=true] - [description] - * @property {object} [?input.mouse.target=null] - [description] - * @property {boolean} [input.touch=true] - [description] - * @property {object} [?input.touch.target=null] - [description] - * @property {object} [?input.touch.capture=true] - [description] - * @property {boolean} [input.gamepad=false] - [description] - * @property {boolean} [disableContextMenu=false] - [description] - * @property {boolean} [banner=false] - [description] - * @property {boolean} [banner.hidePhaser=false] - [description] - * @property {string} [banner.text='#ffffff'] - [description] - * @property {array} [banner.background] - [description] - * @property {FPSConfig} [?fps] - [description] - * @property {boolean} [pixelArt=false] - [description] - * @property {boolean} [autoResize=false] - [description] - * @property {boolean} [roundPixels=false] - [description] - * @property {boolean} [transparent=false] - [description] - * @property {boolean} [clearBeforeRender=true] - [description] - * @property {string|number} [backgroundColor=0x000000] - [description] - * @property {object} [?callbacks] - [description] - * @property {function} [callbacks.preBoot=NOOP] - [description] - * @property {function} [callbacks.postBoot=NOOP] - [description] - * @property {LoaderConfig} [?loader] - [description] - * @property {object} [?images] - [description] - * @property {string} [images.default] - [description] - * @property {string} [images.missing] - [description] - */ - -/** - * @classdesc - * [description] - * - * @class Config - * @memberOf Phaser.Boot - * @constructor - * @since 3.0.0 - * - * @param {object} [GameConfig] - The configuration object for your Phaser Game instance. - * - */ -var Config = new Class({ - - initialize: - - function Config (config) - { - if (config === undefined) { config = {}; } - - var defaultBannerColor = [ - '#ff0000', - '#ffff00', - '#00ff00', - '#00ffff', - '#000000' - ]; - - var defaultBannerTextColor = '#ffffff'; - - this.width = GetValue(config, 'width', 1024); - this.height = GetValue(config, 'height', 768); - this.zoom = GetValue(config, 'zoom', 1); - - this.resolution = GetValue(config, 'resolution', 1); - - this.renderType = GetValue(config, 'type', CONST.AUTO); - - this.parent = GetValue(config, 'parent', null); - this.canvas = GetValue(config, 'canvas', null); - this.canvasStyle = GetValue(config, 'canvasStyle', null); - - this.sceneConfig = GetValue(config, 'scene', null); - - this.seed = GetValue(config, 'seed', [ (Date.now() * Math.random()).toString() ]); - - MATH.RND.init(this.seed); - - this.gameTitle = GetValue(config, 'title', ''); - this.gameURL = GetValue(config, 'url', 'https://phaser.io'); - this.gameVersion = GetValue(config, 'version', ''); - - // Input - this.inputKeyboard = GetValue(config, 'input.keyboard', true); - this.inputKeyboardEventTarget = GetValue(config, 'input.keyboard.target', window); - - this.inputMouse = GetValue(config, 'input.mouse', true); - this.inputMouseEventTarget = GetValue(config, 'input.mouse.target', null); - this.inputMouseCapture = GetValue(config, 'input.mouse.capture', true); - - this.inputTouch = GetValue(config, 'input.touch', true); - this.inputTouchEventTarget = GetValue(config, 'input.touch.target', null); - this.inputTouchCapture = GetValue(config, 'input.touch.capture', true); - - this.inputGamepad = GetValue(config, 'input.gamepad', false); - - this.disableContextMenu = GetValue(config, 'disableContextMenu', false); - - this.audio = GetValue(config, 'audio'); - - // If you do: { banner: false } it won't display any banner at all - this.hideBanner = (GetValue(config, 'banner', null) === false); - - this.hidePhaser = GetValue(config, 'banner.hidePhaser', false); - this.bannerTextColor = GetValue(config, 'banner.text', defaultBannerTextColor); - this.bannerBackgroundColor = GetValue(config, 'banner.background', defaultBannerColor); - - if (this.gameTitle === '' && this.hidePhaser) - { - this.hideBanner = true; - } - - // Frame Rate config - // fps: { - // min: 10, - // target: 60, - // forceSetTimeOut: false, - // deltaHistory: 10 - // } - - this.fps = GetValue(config, 'fps', null); - - this.pixelArt = GetValue(config, 'pixelArt', false); - this.autoResize = GetValue(config, 'autoResize', false); - this.roundPixels = GetValue(config, 'roundPixels', false); - this.transparent = GetValue(config, 'transparent', false); - this.clearBeforeRender = GetValue(config, 'clearBeforeRender', true); - - var bgc = GetValue(config, 'backgroundColor', 0); - - this.backgroundColor = ValueToColor(bgc); - - if (bgc === 0 && this.transparent) - { - this.backgroundColor.alpha = 0; - } - - // Callbacks - this.preBoot = GetValue(config, 'callbacks.preBoot', NOOP); - this.postBoot = GetValue(config, 'callbacks.postBoot', NOOP); - - // Physics - // physics: { - // system: 'impact', - // setBounds: true, - // gravity: 0, - // cellSize: 64 - // } - this.physics = GetValue(config, 'physics', {}); - this.defaultPhysicsSystem = GetValue(this.physics, 'default', false); - - // Loader Defaults - this.loaderBaseURL = GetValue(config, 'loader.baseURL', ''); - this.loaderPath = GetValue(config, 'loader.path', ''); - this.loaderEnableParallel = GetValue(config, 'loader.enableParallel', true); - this.loaderMaxParallelDownloads = GetValue(config, 'loader.maxParallelDownloads', 4); - this.loaderCrossOrigin = GetValue(config, 'loader.crossOrigin', undefined); - this.loaderResponseType = GetValue(config, 'loader.responseType', ''); - this.loaderAsync = GetValue(config, 'loader.async', true); - this.loaderUser = GetValue(config, 'loader.user', ''); - this.loaderPassword = GetValue(config, 'loader.password', ''); - this.loaderTimeout = GetValue(config, 'loader.timeout', 0); - - // Scene Plugins - this.defaultPlugins = GetValue(config, 'plugins', Plugins.DefaultScene); - - // Default / Missing Images - var pngPrefix = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAg'; - - this.defaultImage = GetValue(config, 'images.default', pngPrefix + 'AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=='); - this.missingImage = GetValue(config, 'images.missing', pngPrefix + 'CAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg=='); - } - -}); - -module.exports = Config; - - -/***/ }), -/* 510 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CanvasInterpolation = __webpack_require__(226); -var CanvasPool = __webpack_require__(21); -var CONST = __webpack_require__(19); -var Features = __webpack_require__(126); - -/** - * Called automatically by Phaser.Game and responsible for creating the renderer it will use. - * - * Relies upon two webpack global flags to be defined: `WEBGL_RENDERER` and `CANVAS_RENDERER` during build time, but not at run-time. - * - * @function Phaser.Boot.CreateRenderer - * @since 3.0.0 - * - * @param {Phaser.Game} game - The Phaser.Game instance on which the renderer will be set. - */ -var CreateRenderer = function (game) -{ - var config = game.config; - - // Game either requested Canvas, - // or requested AUTO or WEBGL but the browser doesn't support it, so fall back to Canvas - - if (config.renderType !== CONST.HEADLESS) - { - if (config.renderType === CONST.CANVAS || (config.renderType !== CONST.CANVAS && !Features.webGL)) - { - if (Features.canvas) - { - // They requested Canvas and their browser supports it - config.renderType = CONST.CANVAS; - } - else - { - throw new Error('Cannot create Canvas or WebGL context, aborting.'); - } - } - else - { - // Game requested WebGL and browser says it supports it - config.renderType = CONST.WEBGL; - } - } - - // Pixel Art mode? - if (config.pixelArt) - { - CanvasPool.disableSmoothing(); - } - - // Does the game config provide its own canvas element to use? - if (config.canvas) - { - game.canvas = config.canvas; - } - else - { - game.canvas = CanvasPool.create(game, config.width, config.height, config.renderType); - } - - // Does the game config provide some canvas css styles to use? - if (config.canvasStyle) - { - game.canvas.style = config.canvasStyle; - } - - // Pixel Art mode? - if (config.pixelArt) - { - CanvasInterpolation.setCrisp(game.canvas); - } - - // Zoomed? - if (config.zoom !== 1) - { - game.canvas.style.width = (config.width * config.zoom).toString() + 'px'; - game.canvas.style.height = (config.height * config.zoom).toString() + 'px'; - } - - if (config.renderType === CONST.HEADLESS) - { - // Nothing more to do here - return; - } - - var CanvasRenderer; - var WebGLRenderer; - - if (true) - { - CanvasRenderer = __webpack_require__(366); - WebGLRenderer = __webpack_require__(371); - - // Let the config pick the renderer type, both are included - if (config.renderType === CONST.WEBGL) - { - game.renderer = new WebGLRenderer(game); - game.context = null; - } - else - { - game.renderer = new CanvasRenderer(game); - game.context = game.renderer.gameContext; - } - } - - if (false) - { - WebGLRenderer = require('../renderer/webgl/WebGLRenderer'); - - // Force the type to WebGL, regardless what was requested - config.renderType = CONST.WEBGL; - game.renderer = new WebGLRenderer(game); - game.context = null; - } - - if (false) - { - CanvasRenderer = require('../renderer/canvas/CanvasRenderer'); - - // Force the type to Canvas, regardless what was requested - config.renderType = CONST.CANVAS; - game.renderer = new CanvasRenderer(game); - game.context = game.renderer.gameContext; - } -}; - -module.exports = CreateRenderer; - - -/***/ }), -/* 511 */ -/***/ (function(module, exports) { - -module.exports = "#define SHADER_NAME PHASER_BITMAP_MASK_FS\r\n\r\nprecision mediump float;\r\n\r\nuniform vec2 uResolution;\r\nuniform sampler2D uMainSampler;\r\nuniform sampler2D uMaskSampler;\r\nuniform bool uInvertMaskAlpha;\r\n\r\nvoid main()\r\n{\r\n vec2 uv = gl_FragCoord.xy / uResolution;\r\n vec4 mainColor = texture2D(uMainSampler, uv);\r\n vec4 maskColor = texture2D(uMaskSampler, uv);\r\n float alpha = mainColor.a;\r\n\r\n if (!uInvertMaskAlpha)\r\n {\r\n alpha *= (maskColor.a);\r\n }\r\n else\r\n {\r\n alpha *= (1.0 - maskColor.a);\r\n }\r\n \r\n gl_FragColor = vec4(mainColor.rgb * alpha, alpha);\r\n}\r\n" - -/***/ }), -/* 512 */ -/***/ (function(module, exports) { - -module.exports = "#define SHADER_NAME PHASER_BITMAP_MASK_VS\r\n\r\nprecision mediump float;\r\n\r\nattribute vec2 inPosition;\r\n\r\nvoid main()\r\n{\r\n gl_Position = vec4(inPosition, 0.0, 1.0);\r\n}\r\n" - -/***/ }), -/* 513 */ -/***/ (function(module, exports) { - -module.exports = "#define SHADER_NAME PHASER_FLAT_TINT_FS\r\n\r\nprecision mediump float;\r\n\r\nvarying vec4 outTint;\r\n\r\nvoid main() {\r\n gl_FragColor = vec4(outTint.rgb * outTint.a, outTint.a);\r\n}\r\n" - -/***/ }), -/* 514 */ -/***/ (function(module, exports) { - -module.exports = "#define SHADER_NAME PHASER_FLAT_TINT_VS\r\n\r\nprecision mediump float;\r\n\r\nuniform mat4 uProjectionMatrix;\r\nuniform mat4 uViewMatrix;\r\nuniform mat4 uModelMatrix;\r\n\r\nattribute vec2 inPosition;\r\nattribute vec4 inTint;\r\n\r\nvarying vec4 outTint;\r\n\r\nvoid main () {\r\n gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);\r\n outTint = inTint;\r\n}\r\n" - -/***/ }), -/* 515 */ -/***/ (function(module, exports) { - -module.exports = "#define SHADER_NAME PHASER_FORWARD_DIFFUSE_FS\r\n\r\nprecision mediump float;\r\n\r\nstruct Light\r\n{\r\n vec2 position;\r\n vec3 color;\r\n float intensity;\r\n float radius;\r\n};\r\n\r\nconst int kMaxLights = %LIGHT_COUNT%;\r\n\r\nuniform vec4 uCamera; /* x, y, rotation, zoom */\r\nuniform vec2 uResolution;\r\nuniform sampler2D uMainSampler;\r\nuniform sampler2D uNormSampler;\r\nuniform vec3 uAmbientLightColor;\r\nuniform Light uLights[kMaxLights];\r\n\r\nvarying vec2 outTexCoord;\r\nvarying vec4 outTint;\r\n\r\nvoid main()\r\n{\r\n vec3 finalColor = vec3(0.0, 0.0, 0.0);\r\n vec4 color = texture2D(uMainSampler, outTexCoord) * vec4(outTint.rgb * outTint.a, outTint.a);\r\n vec3 normalMap = texture2D(uNormSampler, outTexCoord).rgb;\r\n vec3 normal = normalize(vec3(normalMap * 2.0 - 1.0));\r\n vec2 res = vec2(min(uResolution.x, uResolution.y)) * uCamera.w;\r\n\r\n for (int index = 0; index < kMaxLights; ++index)\r\n {\r\n Light light = uLights[index];\r\n vec3 lightDir = vec3((light.position.xy / res) - (gl_FragCoord.xy / res), 0.1);\r\n vec3 lightNormal = normalize(lightDir);\r\n float distToSurf = length(lightDir) * uCamera.w;\r\n float diffuseFactor = max(dot(normal, lightNormal), 0.0);\r\n float radius = (light.radius / res.x * uCamera.w) * uCamera.w;\r\n float attenuation = clamp(1.0 - distToSurf * distToSurf / (radius * radius), 0.0, 1.0);\r\n vec3 diffuse = light.color * diffuseFactor;\r\n finalColor += (attenuation * diffuse) * light.intensity;\r\n }\r\n\r\n vec4 colorOutput = vec4(uAmbientLightColor + finalColor, 1.0);\r\n gl_FragColor = color * vec4(colorOutput.rgb * colorOutput.a, colorOutput.a);\r\n\r\n}\r\n" - -/***/ }), -/* 516 */ -/***/ (function(module, exports) { - -module.exports = "#define SHADER_NAME PHASER_TEXTURE_TINT_FS\r\n\r\nprecision mediump float;\r\n\r\nuniform sampler2D uMainSampler;\r\n\r\nvarying vec2 outTexCoord;\r\nvarying vec4 outTint;\r\n\r\nvoid main() \r\n{\r\n vec4 texel = texture2D(uMainSampler, outTexCoord);\r\n texel *= vec4(outTint.rgb * outTint.a, outTint.a);\r\n gl_FragColor = texel;\r\n}\r\n" - -/***/ }), -/* 517 */ -/***/ (function(module, exports) { - -module.exports = "#define SHADER_NAME PHASER_TEXTURE_TINT_VS\r\n\r\nprecision mediump float;\r\n\r\nuniform mat4 uProjectionMatrix;\r\nuniform mat4 uViewMatrix;\r\nuniform mat4 uModelMatrix;\r\n\r\nattribute vec2 inPosition;\r\nattribute vec2 inTexCoord;\r\nattribute vec4 inTint;\r\n\r\nvarying vec2 outTexCoord;\r\nvarying vec4 outTint;\r\n\r\nvoid main () \r\n{\r\n gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);\r\n outTexCoord = inTexCoord;\r\n outTint = inTint;\r\n}\r\n\r\n" - -/***/ }), -/* 518 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(19); - -/** - * Called automatically by Phaser.Game and responsible for creating the console.log debug header. - * - * You can customize or disable the header via the Game Config object. - * - * @function Phaser.Boot.DebugHeader - * @since 3.0.0 - * - * @param {Phaser.Game} game - The Phaser.Game instance which will output this debug header. - */ -var DebugHeader = function (game) -{ - var config = game.config; - - if (config.hideBanner) - { - return; - } - - var renderType = 'WebGL'; - - if (config.renderType === CONST.CANVAS) - { - renderType = 'Canvas'; - } - else if (config.renderType === CONST.HEADLESS) - { - renderType = 'Headless'; - } - - var audioConfig = config.audio; - var deviceAudio = game.device.audio; - - var audioType; - - if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio)) - { - audioType = 'Web Audio'; - } - else if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) - { - audioType = 'No Audio'; - } - else - { - audioType = 'HTML5 Audio'; - } - - if (!game.device.browser.ie) - { - var c = ''; - var args = [ c ]; - - if (Array.isArray(config.bannerBackgroundColor)) - { - var lastColor; - - config.bannerBackgroundColor.forEach(function (color) - { - c = c.concat('%c '); - - args.push('background: ' + color); - - lastColor = color; - - }); - - // inject the text color - args[args.length - 1] = 'color: ' + config.bannerTextColor + '; background: ' + lastColor; - } - else - { - c = c.concat('%c '); - - args.push('color: ' + config.bannerTextColor + '; background: ' + config.bannerBackgroundColor); - } - - // URL link background color (always white) - args.push('background: #fff'); - - if (config.gameTitle) - { - c = c.concat(config.gameTitle); - - if (config.gameVersion) - { - c = c.concat(' v' + config.gameVersion); - } - - if (!config.hidePhaser) - { - c = c.concat(' / '); - } - } - - if (!config.hidePhaser) - { - c = c.concat('Phaser v' + CONST.VERSION + ' (' + renderType + ' | ' + audioType + ')'); - } - - c = c.concat(' %c ' + config.gameURL); - - // Inject the new string back into the args array - args[0] = c; - - console.log.apply(console, args); - } - else if (window['console']) - { - console.log('Phaser v' + CONST.VERSION + ' / https://phaser.io'); - } -}; - -module.exports = DebugHeader; - - -/***/ }), -/* 519 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// This singleton is instantiated as soon as Phaser loads, -// before a Phaser.Game instance has even been created. -// Which means all instances of Phaser Games can share it, -// without having to re-poll the device all over again - -/** - * @namespace Phaser.Device - */ - -module.exports = { - - os: __webpack_require__(67), - browser: __webpack_require__(82), - features: __webpack_require__(126), - input: __webpack_require__(520), - audio: __webpack_require__(521), - video: __webpack_require__(522), - fullscreen: __webpack_require__(523), - canvasFeatures: __webpack_require__(237) - -}; - - -/***/ }), -/* 520 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var OS = __webpack_require__(67); -var Browser = __webpack_require__(82); - -/** - * Determines the input support of the browser running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.input` from within any Scene. - * - * @name Phaser.Device.Input - * @since 3.0.0 - * - * @type {object} - * @property {?string} wheelType - The newest type of Wheel/Scroll event supported: 'wheel', 'mousewheel', 'DOMMouseScroll' - * @property {boolean} gamepads - Is navigator.getGamepads available? - * @property {boolean} mspointer - Is mspointer available? - * @property {boolean} touch - Is touch available? - */ -var Input = { - - gamepads: false, - mspointer: false, - touch: false, - wheelEvent: null - -}; - -function init () -{ - if ('ontouchstart' in document.documentElement || (navigator.maxTouchPoints && navigator.maxTouchPoints >= 1)) - { - Input.touch = true; - } - - if (navigator.msPointerEnabled || navigator.pointerEnabled) - { - Input.mspointer = true; - } - - if (navigator.getGamepads) - { - Input.gamepads = true; - } - - if (!OS.cocoonJS) - { - // See https://developer.mozilla.org/en-US/docs/Web/Events/wheel - if ('onwheel' in window || (Browser.ie && 'WheelEvent' in window)) - { - // DOM3 Wheel Event: FF 17+, IE 9+, Chrome 31+, Safari 7+ - Input.wheelEvent = 'wheel'; - } - else if ('onmousewheel' in window) - { - // Non-FF legacy: IE 6-9, Chrome 1-31, Safari 5-7. - Input.wheelEvent = 'mousewheel'; - } - else if (Browser.firefox && 'MouseScrollEvent' in window) - { - // FF prior to 17. This should probably be scrubbed. - Input.wheelEvent = 'DOMMouseScroll'; - } - } - - return Input; -} - -module.exports = init(); - - -/***/ }), -/* 521 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Browser = __webpack_require__(82); - -/** - * Determines the audio playback capabilities of the device running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.audio` from within any Scene. - * - * @name Phaser.Device.Audio - * @since 3.0.0 - * - * @type {object} - * @property {boolean} audioData - Can this device play HTML Audio tags? - * @property {boolean} dolby - Can this device play EC-3 Dolby Digital Plus files? - * @property {boolean} m4a - Can this device can play m4a files. - * @property {boolean} mp3 - Can this device play mp3 files? - * @property {boolean} ogg - Can this device play ogg files? - * @property {boolean} opus - Can this device play opus files? - * @property {boolean} wav - Can this device play wav files? - * @property {boolean} webAudio - Does this device have the Web Audio API? - * @property {boolean} webm - Can this device play webm files? - */ -var Audio = { - - audioData: false, - dolby: false, - m4a: false, - mp3: false, - ogg: false, - opus: false, - wav: false, - webAudio: false, - webm: false - -}; - -function init () -{ - Audio.audioData = !!(window['Audio']); - - Audio.webAudio = !!(window['AudioContext'] || window['webkitAudioContext']); - - var audioElement = document.createElement('audio'); - - var result = !!audioElement.canPlayType; - - try - { - if (result) - { - if (audioElement.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) - { - Audio.ogg = true; - } - - if (audioElement.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, '') || audioElement.canPlayType('audio/opus;').replace(/^no$/, '')) - { - Audio.opus = true; - } - - if (audioElement.canPlayType('audio/mpeg;').replace(/^no$/, '')) - { - Audio.mp3 = true; - } - - // Mimetypes accepted: - // developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements - // bit.ly/iphoneoscodecs - if (audioElement.canPlayType('audio/wav; codecs="1"').replace(/^no$/, '')) - { - Audio.wav = true; - } - - if (audioElement.canPlayType('audio/x-m4a;') || audioElement.canPlayType('audio/aac;').replace(/^no$/, '')) - { - Audio.m4a = true; - } - - if (audioElement.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, '')) - { - Audio.webm = true; - } - - if (audioElement.canPlayType('audio/mp4;codecs="ec-3"') !== '') - { - if (Browser.edge) - { - Audio.dolby = true; - } - else if (Browser.safari && Browser.safariVersion >= 9) - { - if ((/Mac OS X (\d+)_(\d+)/).test(navigator.userAgent)) - { - var major = parseInt(RegExp.$1, 10); - var minor = parseInt(RegExp.$2, 10); - - if ((major === 10 && minor >= 11) || major > 10) - { - Audio.dolby = true; - } - } - } - } - } - } - catch (e) - { - // Nothing to do here - } - - return Audio; -} - -module.exports = init(); - - -/***/ }), -/* 522 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Determines the video support of the browser running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.video` from within any Scene. - * - * @name Phaser.Device.Video - * @since 3.0.0 - * - * @type {object} - * @property {boolean} h264Video - Can this device play h264 mp4 video files? - * @property {boolean} hlsVideo - Can this device play hls video files? - * @property {boolean} mp4Video - Can this device play h264 mp4 video files? - * @property {boolean} oggVideo - Can this device play ogg video files? - * @property {boolean} vp9Video - Can this device play vp9 video files? - * @property {boolean} webmVideo - Can this device play webm video files? - */ -var Video = { - - h264Video: false, - hlsVideo: false, - mp4Video: false, - oggVideo: false, - vp9Video: false, - webmVideo: false - -}; - -function init () -{ - var videoElement = document.createElement('video'); - var result = !!videoElement.canPlayType; - - try - { - if (result) - { - if (videoElement.canPlayType('video/ogg; codecs="theora"').replace(/^no$/, '')) - { - Video.oggVideo = true; - } - - if (videoElement.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/, '')) - { - // Without QuickTime, this value will be `undefined`. github.com/Modernizr/Modernizr/issues/546 - Video.h264Video = true; - Video.mp4Video = true; - } - - if (videoElement.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/, '')) - { - Video.webmVideo = true; - } - - if (videoElement.canPlayType('video/webm; codecs="vp9"').replace(/^no$/, '')) - { - Video.vp9Video = true; - } - - if (videoElement.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(/^no$/, '')) - { - Video.hlsVideo = true; - } - } - } - catch (e) - { - // Nothing to do - } - - return Video; -} - -module.exports = init(); - - -/***/ }), -/* 523 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Determines the full screen support of the browser running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.fullscreen` from within any Scene. - * - * @name Phaser.Device.Fullscreen - * @since 3.0.0 - * - * @type {object} - * @property {boolean} available - Does the browser support the Full Screen API? - * @property {boolean} keyboard - Does the browser support access to the Keyboard during Full Screen mode? - * @property {string} cancel - If the browser supports the Full Screen API this holds the call you need to use to cancel it. - * @property {string} request - If the browser supports the Full Screen API this holds the call you need to use to activate it. - */ -var Fullscreen = { - - available: false, - cancel: '', - keyboard: false, - request: '' - -}; - -/** -* Checks for support of the Full Screen API. -*/ -function init () -{ - var i; - - var fs = [ - 'requestFullscreen', - 'requestFullScreen', - 'webkitRequestFullscreen', - 'webkitRequestFullScreen', - 'msRequestFullscreen', - 'msRequestFullScreen', - 'mozRequestFullScreen', - 'mozRequestFullscreen' - ]; - - var element = document.createElement('div'); - - for (i = 0; i < fs.length; i++) - { - if (element[fs[i]]) - { - Fullscreen.available = true; - Fullscreen.request = fs[i]; - break; - } - } - - var cfs = [ - 'cancelFullScreen', - 'exitFullscreen', - 'webkitCancelFullScreen', - 'webkitExitFullscreen', - 'msCancelFullScreen', - 'msExitFullscreen', - 'mozCancelFullScreen', - 'mozExitFullscreen' - ]; - - if (Fullscreen.available) - { - for (i = 0; i < cfs.length; i++) - { - if (document[cfs[i]]) - { - Fullscreen.cancel = cfs[i]; - break; - } - } - } - - // Keyboard Input? - if (window['Element'] && Element['ALLOW_KEYBOARD_INPUT']) - { - Fullscreen.keyboard = true; - } - - return Fullscreen; -} - -module.exports = init(); - - -/***/ }), -/* 524 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var AdvanceKeyCombo = __webpack_require__(525); - -/** - * Used internally by the KeyCombo class. - * - * @function Phaser.Input.Keyboard.KeyCombo.ProcessKeyCombo - * @since 3.0.0 - * - * @param {[type]} event - [description] - * @param {[type]} combo - [description] - * - * @return {[type]} [description] - */ -var ProcessKeyCombo = function (event, combo) -{ - if (combo.matched) - { - return true; - } - - var comboMatched = false; - var keyMatched = false; - - if (event.keyCode === combo.current) - { - // Key was correct - - if (combo.index > 0 && combo.maxKeyDelay > 0) - { - // We have to check to see if the delay between - // the new key and the old one was too long (if enabled) - - var timeLimit = combo.timeLastMatched + combo.maxKeyDelay; - - // Check if they pressed it in time or not - if (event.timeStamp <= timeLimit) - { - keyMatched = true; - comboMatched = AdvanceKeyCombo(event, combo); - } - } - else - { - keyMatched = true; - - // We don't check the time for the first key pressed, so just advance it - comboMatched = AdvanceKeyCombo(event, combo); - } - } - - if (!keyMatched && combo.resetOnWrongKey) - { - // Wrong key was pressed - combo.index = 0; - combo.current = combo.keyCodes[0]; - } - - if (comboMatched) - { - combo.timeLastMatched = event.timeStamp; - combo.matched = true; - combo.timeMatched = event.timeStamp; - } - - return comboMatched; -}; - -module.exports = ProcessKeyCombo; - - -/***/ }), -/* 525 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Used internally by the KeyCombo class. - * Return `true` if it reached the end of the combo, `false` if not. - * - * @function Phaser.Input.Keyboard.KeyCombo.AdvanceKeyCombo - * @since 3.0.0 - * - * @param {[type]} event - [description] - * @param {[type]} combo - [description] - * - * @return {boolean} `true` if it reached the end of the combo, `false` if not. - */ -var AdvanceKeyCombo = function (event, combo) -{ - combo.timeLastMatched = event.timeStamp; - combo.index++; - - if (combo.index === combo.size) - { - return true; - } - else - { - combo.current = combo.keyCodes[combo.index]; - return false; - } -}; - -module.exports = AdvanceKeyCombo; - - -/***/ }), -/* 526 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Used internally by the KeyCombo class. - * - * @function Phaser.Input.Keyboard.KeyCombo.ResetKeyCombo - * @since 3.0.0 - * - * @param {Phaser.Input.Keyboard.KeyCombo} combo - The KeyCombo to reset. - * - * @return {Phaser.Input.Keyboard.KeyCombo} The KeyCombo. - */ -var ResetKeyCombo = function (combo) -{ - combo.current = combo.keyCodes[0]; - combo.index = 0; - combo.timeLastMatched = 0; - combo.matched = false; - combo.timeMatched = 0; - - return combo; -}; - -module.exports = ResetKeyCombo; - - -/***/ }), -/* 527 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var KeyCodes = __webpack_require__(129); - -var KeyMap = {}; - -for (var key in KeyCodes) -{ - KeyMap[KeyCodes[key]] = key; -} - -module.exports = KeyMap; - - -/***/ }), -/* 528 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Used internally by the KeyboardManager. - * - * @function Phaser.Input.Keyboard.Keys.ProcessKeyDown - * @since 3.0.0 - * - * @param {Phaser.Input.Keyboard.Key} key - [description] - * @param {[type]} event - [description] - * - * @return {Phaser.Input.Keyboard.Key} [description] - */ -var ProcessKeyDown = function (key, event) -{ - key.originalEvent = event; - - if (key.preventDefault) - { - event.preventDefault(); - } - - if (!key.enabled) - { - return; - } - - key.altKey = event.altKey; - key.ctrlKey = event.ctrlKey; - key.shiftKey = event.shiftKey; - key.location = event.location; - - if (key.isDown === false) - { - key.isDown = true; - key.isUp = false; - key.timeDown = event.timeStamp; - key.duration = 0; - } - - key.repeats++; - - key._justDown = true; - key._justUp = false; - - return key; -}; - -module.exports = ProcessKeyDown; - - -/***/ }), -/* 529 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Used internally by the KeyboardManager. - * - * @function Phaser.Input.Keyboard.Keys.ProcessKeyUp - * @since 3.0.0 - * - * @param {Phaser.Input.Keyboard.Key} key - [description] - * @param {[type]} event - [description] - * - * @return {Phaser.Input.Keyboard.Key} [description] - */ -var ProcessKeyUp = function (key, event) -{ - key.originalEvent = event; - - if (key.preventDefault) - { - event.preventDefault(); - } - - if (!key.enabled) - { - return; - } - - key.isDown = false; - key.isUp = true; - key.timeUp = event.timeStamp; - key.duration = key.timeUp - key.timeDown; - key.repeats = 0; - - key._justDown = false; - key._justUp = true; - - return key; -}; - -module.exports = ProcessKeyUp; - - -/***/ }), -/* 530 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetFastValue = __webpack_require__(2); -var UppercaseFirst = __webpack_require__(254); - -/** - * Builds an array of which physics plugins should be activated for the given Scene. - * - * @function Phaser.Scenes.GetPhysicsPlugins - * @since 3.0.0 - * - * @param {Phaser.Scenes.Systems} sys - [description] - * - * @return {array} [description] - */ -var GetPhysicsPlugins = function (sys) -{ - var defaultSystem = sys.game.config.defaultPhysicsSystem; - var sceneSystems = GetFastValue(sys.settings, 'physics', false); - - if (!defaultSystem && !sceneSystems) - { - // No default physics system or systems in this scene - return; - } - - // Let's build the systems array - var output = []; - - if (defaultSystem) - { - output.push(UppercaseFirst(defaultSystem + 'Physics')); - } - - if (sceneSystems) - { - for (var key in sceneSystems) - { - key = UppercaseFirst(key.concat('Physics')); - - if (output.indexOf(key) === -1) - { - output.push(key); - } - } - } - - // An array of Physics systems to start for this Scene - return output; -}; - -module.exports = GetPhysicsPlugins; - - -/***/ }), -/* 531 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetFastValue = __webpack_require__(2); - -/** - * Builds an array of which plugins (not including physics plugins) should be activated for the given Scene. - * - * @function Phaser.Scenes.GetScenePlugins - * @since 3.0.0 - * - * @param {Phaser.Scenes.Systems} sys - [description] - * - * @return {array} [description] - */ -var GetScenePlugins = function (sys) -{ - var defaultPlugins = sys.game.config.defaultPlugins; - var scenePlugins = GetFastValue(sys.settings, 'plugins', false); - - // Scene Plugins always override Default Plugins - if (Array.isArray(scenePlugins)) - { - return scenePlugins; - } - else if (defaultPlugins) - { - return defaultPlugins; - } - else - { - // No default plugins or plugins in this scene - return []; - } -}; - -module.exports = GetScenePlugins; - - -/***/ }), -/* 532 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// These properties get injected into the Scene and map to local systems -// The map key is the property that is added to the Scene, the value is the Scene.Systems reference -// These defaults can be modified via the Scene config object - -var InjectionMap = { - - game: 'game', - - anims: 'anims', - cache: 'cache', - registry: 'registry', - sound: 'sound', - textures: 'textures', - - events: 'events', - cameras: 'cameras', - cameras3d: 'cameras3d', - add: 'add', - make: 'make', - scenePlugin: 'scene', - displayList: 'children', - lights: 'lights', - - data: 'data', - input: 'input', - load: 'load', - time: 'time', - tweens: 'tweens', - - arcadePhysics: 'physics', - impactPhysics: 'impact', - matterPhysics: 'matter' - -}; - -module.exports = InjectionMap; - - -/***/ }), -/* 533 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Adds a Canvas Element to a Texture. - * - * @function Phaser.Textures.Parsers.Canvas - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {integer} sourceIndex - The index of the TextureSource. - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var Canvas = function (texture, sourceIndex) -{ - var source = texture.source[sourceIndex]; - - texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); - - return texture; -}; - -module.exports = Canvas; - - -/***/ }), -/* 534 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Adds an Image Element to a Texture. - * - * @function Phaser.Textures.Parsers.Image - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {integer} sourceIndex - The index of the TextureSource. - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var Image = function (texture, sourceIndex) -{ - var source = texture.source[sourceIndex]; - - texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); - - return texture; -}; - -module.exports = Image; - - -/***/ }), -/* 535 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clone = __webpack_require__(53); - -/** - * Parses a Texture Atlas JSON Array and adds the Frames to the Texture. - * JSON format expected to match that defined by Texture Packer, with the frames property containing an array of Frames. - * - * @function Phaser.Textures.Parsers.JSONArray - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {integer} sourceIndex - The index of the TextureSource. - * @param {object} json - The JSON data. - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var JSONArray = function (texture, sourceIndex, json) -{ - // Malformed? - if (!json['frames'] && !json['textures']) - { - console.warn('Invalid Texture Atlas JSON Array given, missing \'frames\' and \'textures\' array'); - return; - } - - // Add in a __BASE entry (for the entire atlas) - var source = texture.source[sourceIndex]; - - texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); - - // By this stage frames is a fully parsed array - var frames = (Array.isArray(json.textures)) ? json.textures[sourceIndex].frames : json.frames; - - var newFrame; - - for (var i = 0; i < frames.length; i++) - { - var src = frames[i]; - - // The frame values are the exact coordinates to cut the frame out of the atlas from - newFrame = texture.add(src.filename, sourceIndex, src.frame.x, src.frame.y, src.frame.w, src.frame.h); - - // These are the original (non-trimmed) sprite values - if (src.trimmed) - { - newFrame.setTrim( - src.sourceSize.w, - src.sourceSize.h, - src.spriteSourceSize.x, - src.spriteSourceSize.y, - src.spriteSourceSize.w, - src.spriteSourceSize.h - ); - } - - if (src.rotated) - { - newFrame.rotated = true; - newFrame.updateUVsInverted(); - } - - if (src.anchor) - { - newFrame.customPivot = true; - newFrame.pivotX = src.anchor.x; - newFrame.pivotY = src.anchor.y; - } - - // Copy over any extra data - newFrame.customData = Clone(src); - } - - // Copy over any additional data that was in the JSON to Texture.customData - for (var dataKey in json) - { - if (dataKey === 'frames') - { - continue; - } - - if (Array.isArray(json[dataKey])) - { - texture.customData[dataKey] = json[dataKey].slice(0); - } - else - { - texture.customData[dataKey] = json[dataKey]; - } - } - - return texture; -}; - -module.exports = JSONArray; - - -/***/ }), -/* 536 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clone = __webpack_require__(53); - -/** - * Parses a Texture Atlas JSON Hash and adds the Frames to the Texture. - * JSON format expected to match that defined by Texture Packer, with the frames property containing an object of Frames. - * - * @function Phaser.Textures.Parsers.JSONHash - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {integer} sourceIndex - The index of the TextureSource. - * @param {object} json - The JSON data. - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var JSONHash = function (texture, sourceIndex, json) -{ - // Malformed? - if (!json['frames']) - { - console.warn('Invalid Texture Atlas JSON Hash given, missing \'frames\' Object'); - return; - } - - // Add in a __BASE entry (for the entire atlas) - var source = texture.source[sourceIndex]; - - texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); - - // By this stage frames is a fully parsed Object - var frames = json['frames']; - var newFrame; - - for (var key in frames) - { - var src = frames[key]; - - // The frame values are the exact coordinates to cut the frame out of the atlas from - newFrame = texture.add(key, sourceIndex, src.frame.x, src.frame.y, src.frame.w, src.frame.h); - - // These are the original (non-trimmed) sprite values - if (src.trimmed) - { - newFrame.setTrim( - src.sourceSize.w, - src.sourceSize.h, - src.spriteSourceSize.x, - src.spriteSourceSize.y, - src.spriteSourceSize.w, - src.spriteSourceSize.h - ); - } - - if (src.rotated) - { - newFrame.rotated = true; - newFrame.updateUVsInverted(); - } - - // Copy over any extra data - newFrame.customData = Clone(src); - } - - // Copy over any additional data that was in the JSON to Texture.customData - for (var dataKey in json) - { - if (dataKey === 'frames') - { - continue; - } - - if (Array.isArray(json[dataKey])) - { - texture.customData[dataKey] = json[dataKey].slice(0); - } - else - { - texture.customData[dataKey] = json[dataKey]; - } - } - - return texture; -}; - -module.exports = JSONHash; - - -/***/ }), -/* 537 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Parses a Pyxel JSON object and adds the Frames to a Texture. - * - * @function Phaser.Textures.Parsers.Pyxel - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {object} json - The JSON data. - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var Pyxel = function (texture, json) -{ - // Malformed? There are a few keys to check here. - var signature = [ 'layers', 'tilewidth', 'tileheight', 'tileswide', 'tileshigh' ]; - - signature.forEach(function (key) - { - if (!json[key]) - { - // console.warn('Phaser.AnimationParser.JSONDataPyxel: Invalid Pyxel Tilemap JSON given, missing "' + key + '" key.'); - // console.log(json); - return; - } - }); - - // For this purpose, I only care about parsing tilemaps with a single layer. - if (json['layers'].length !== 1) - { - // console.warn('Phaser.AnimationParser.JSONDataPyxel: Too many layers, this parser only supports flat Tilemaps.'); - // console.log(json); - return; - } - - var data = new Phaser.FrameData(); - - var tileheight = json['tileheight']; - var tilewidth = json['tilewidth']; - - var frames = json['layers'][0]['tiles']; - var newFrame; - - for (var i = 0; i < frames.length; i++) - { - newFrame = data.addFrame(new Phaser.Frame( - i, - frames[i].x, - frames[i].y, - tilewidth, - tileheight, - 'frame_' + i // No names are included in pyxel tilemap data. - )); - - // No trim data is included. - newFrame.setTrim(false); - } - - return data; -}; - -module.exports = Pyxel; - - -/***/ }), -/* 538 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetFastValue = __webpack_require__(2); - -/** - * Parses a Sprite Sheet and adds the Frames to the Texture. - * - * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact - * same size and cannot be trimmed or rotated. - * - * @function Phaser.Textures.Parsers.SpriteSheet - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {integer} sourceIndex - The index of the TextureSource. - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {object} config - [description] - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var SpriteSheet = function (texture, sourceIndex, x, y, width, height, config) -{ - var frameWidth = GetFastValue(config, 'frameWidth', null); - var frameHeight = GetFastValue(config, 'frameHeight', frameWidth); - - // If missing we can't proceed - if (frameWidth === null) - { - throw new Error('TextureManager.SpriteSheet: Invalid frameWidth given.'); - } - - // Add in a __BASE entry (for the entire atlas) - var source = texture.source[sourceIndex]; - - texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); - - var startFrame = GetFastValue(config, 'startFrame', 0); - var endFrame = GetFastValue(config, 'endFrame', -1); - var margin = GetFastValue(config, 'margin', 0); - var spacing = GetFastValue(config, 'spacing', 0); - - var row = Math.floor((width - margin + spacing) / (frameWidth + spacing)); - var column = Math.floor((height - margin + spacing) / (frameHeight + spacing)); - var total = row * column; - - if (startFrame > total || startFrame < -total) - { - startFrame = 0; - } - - if (startFrame < 0) - { - // Allow negative skipframes. - startFrame = total + startFrame; - } - - if (endFrame !== -1) - { - total = startFrame + (endFrame + 1); - } - - var fx = margin; - var fy = margin; - var ax = 0; - var ay = 0; - - for (var i = 0; i < total; i++) - { - ax = 0; - ay = 0; - - var w = fx + frameWidth; - var h = fy + frameHeight; - - if (w > width) - { - ax = w - width; - } - - if (h > height) - { - ay = h - height; - } - - texture.add(i, sourceIndex, x + fx, y + fy, frameWidth - ax, frameHeight - ay); - - fx += frameWidth + spacing; - - if (fx + frameWidth > width) - { - fx = margin; - fy += frameHeight + spacing; - } - } - - return texture; -}; - -module.exports = SpriteSheet; - - -/***/ }), -/* 539 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetFastValue = __webpack_require__(2); - -/** - * Parses a Sprite Sheet and adds the Frames to the Texture, where the Sprite Sheet is stored as a frame within an Atlas. - * - * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact - * same size and cannot be trimmed or rotated. - * - * @function Phaser.Textures.Parsers.SpriteSheetFromAtlas - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {Phaser.Textures.Frame} frame - The Frame that contains the Sprite Sheet. - * @param {object} config - [description] - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var SpriteSheetFromAtlas = function (texture, frame, config) -{ - var frameWidth = GetFastValue(config, 'frameWidth', null); - var frameHeight = GetFastValue(config, 'frameHeight', frameWidth); - - // If missing we can't proceed - if (!frameWidth) - { - throw new Error('TextureManager.SpriteSheetFromAtlas: Invalid frameWidth given.'); - } - - // Add in a __BASE entry (for the entire atlas) - // var source = texture.source[sourceIndex]; - // texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); - - var startFrame = GetFastValue(config, 'startFrame', 0); - var endFrame = GetFastValue(config, 'endFrame', -1); - var margin = GetFastValue(config, 'margin', 0); - var spacing = GetFastValue(config, 'spacing', 0); - - var x = frame.cutX; - var y = frame.cutY; - - var cutWidth = frame.cutWidth; - var cutHeight = frame.cutHeight; - var sheetWidth = frame.realWidth; - var sheetHeight = frame.realHeight; - - var row = Math.floor((sheetWidth - margin + spacing) / (frameWidth + spacing)); - var column = Math.floor((sheetHeight - margin + spacing) / (frameHeight + spacing)); - var total = row * column; - - // trim offsets - - var leftPad = frame.x; - var leftWidth = frameWidth - leftPad; - - var rightWidth = frameWidth - ((sheetWidth - cutWidth) - leftPad); - - var topPad = frame.y; - var topHeight = frameHeight - topPad; - - var bottomHeight = frameHeight - ((sheetHeight - cutHeight) - topPad); - - // console.log('x / y', x, y); - // console.log('cutW / H', cutWidth, cutHeight); - // console.log('sheetW / H', sheetWidth, sheetHeight); - // console.log('row', row, 'column', column, 'total', total); - // console.log('LW', leftWidth, 'RW', rightWidth, 'TH', topHeight, 'BH', bottomHeight); - - if (startFrame > total || startFrame < -total) - { - startFrame = 0; - } - - if (startFrame < 0) - { - // Allow negative skipframes. - startFrame = total + startFrame; - } - - if (endFrame !== -1) - { - total = startFrame + (endFrame + 1); - } - - var sheetFrame; - var frameX = margin; - var frameY = margin; - var frameIndex = 0; - var sourceIndex = frame.sourceIndex; - - for (var sheetY = 0; sheetY < column; sheetY++) - { - var topRow = (sheetY === 0); - var bottomRow = (sheetY === column - 1); - - for (var sheetX = 0; sheetX < row; sheetX++) - { - var leftRow = (sheetX === 0); - var rightRow = (sheetX === row - 1); - - sheetFrame = texture.add(frameIndex, sourceIndex, x + frameX, y + frameY, frameWidth, frameHeight); - - if (leftRow || topRow || rightRow || bottomRow) - { - var destX = (leftRow) ? leftPad : 0; - var destY = (topRow) ? topPad : 0; - var destWidth = frameWidth; - var destHeight = frameHeight; - - if (leftRow) - { - destWidth = leftWidth; - } - else if (rightRow) - { - destWidth = rightWidth; - } - - if (topRow) - { - destHeight = topHeight; - } - else if (bottomRow) - { - destHeight = bottomHeight; - } - - sheetFrame.cutWidth = destWidth; - sheetFrame.cutHeight = destHeight; - - sheetFrame.setTrim(frameWidth, frameHeight, destX, destY, destWidth, destHeight); - } - - frameX += spacing; - - if (leftRow) - { - frameX += leftWidth; - } - else if (rightRow) - { - frameX += rightRow; - } - else - { - frameX += frameWidth; - } - - frameIndex++; - } - - frameX = margin; - frameY += spacing; - - if (topRow) - { - frameY += topHeight; - } - else if (bottomRow) - { - frameY += bottomHeight; - } - else - { - frameY += frameHeight; - } - } - - return texture; -}; - -module.exports = SpriteSheetFromAtlas; - - -/***/ }), -/* 540 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Parses a Starling XML object and adds all the Frames into a Texture. - * - * @function Phaser.Textures.Parsers.StarlingXML - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {any} xml - The XML data. - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var StarlingXML = function (texture, xml) -{ - // Malformed? - if (!xml.getElementsByTagName('TextureAtlas')) - { - // console.warn("Phaser.AnimationParser.XMLData: Invalid Texture Atlas XML given, missing tag"); - return; - } - - // Let's create some frames then - var data = new Phaser.FrameData(); - var frames = xml.getElementsByTagName('SubTexture'); - var newFrame; - - var name; - var frame; - var x; - var y; - var width; - var height; - var frameX; - var frameY; - var frameWidth; - var frameHeight; - - for (var i = 0; i < frames.length; i++) - { - frame = frames[i].attributes; - - name = frame.name.value; - x = parseInt(frame.x.value, 10); - y = parseInt(frame.y.value, 10); - width = parseInt(frame.width.value, 10); - height = parseInt(frame.height.value, 10); - - frameX = null; - frameY = null; - - if (frame.frameX) - { - frameX = Math.abs(parseInt(frame.frameX.value, 10)); - frameY = Math.abs(parseInt(frame.frameY.value, 10)); - frameWidth = parseInt(frame.frameWidth.value, 10); - frameHeight = parseInt(frame.frameHeight.value, 10); - } - - newFrame = data.addFrame(new Phaser.Frame(i, x, y, width, height, name)); - - // Trimmed? - if (frameX !== null || frameY !== null) - { - newFrame.setTrim(true, width, height, frameX, frameY, frameWidth, frameHeight); - } - } - - return data; - -}; - -module.exports = StarlingXML; - - -/***/ }), -/* 541 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var imageHeight = 0; - -var addFrame = function (texture, sourceIndex, name, frame) -{ - // The frame values are the exact coordinates to cut the frame out of the atlas from - - var y = imageHeight - frame.y - frame.height; - - // var newFrame = texture.add(name, sourceIndex, frame.x, y, frame.width, frame.height); - - texture.add(name, sourceIndex, frame.x, y, frame.width, frame.height); - - // console.log('name', name, 'rect', frame.x, y, frame.width, frame.height); - - // These are the original (non-trimmed) sprite values - /* - if (src.trimmed) - { - newFrame.setTrim( - src.sourceSize.w, - src.sourceSize.h, - src.spriteSourceSize.x, - src.spriteSourceSize.y, - src.spriteSourceSize.w, - src.spriteSourceSize.h - ); - } - */ -}; - -/** - * Parses a Unity YAML File and creates Frames in the Texture. - * For more details about Sprite Meta Data see https://docs.unity3d.com/ScriptReference/SpriteMetaData.html - * - * @function Phaser.Textures.Parsers.UnityYAML - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {integer} sourceIndex - The index of the TextureSource. - * @param {object} yaml - The YAML data. - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var UnityYAML = function (texture, sourceIndex, yaml) -{ - // Add in a __BASE entry (for the entire atlas) - var source = texture.source[sourceIndex]; - - texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); - - imageHeight = source.height; - - var data = yaml.split('\n'); - - var lineRegExp = /^[ ]*(- )*(\w+)+[: ]+(.*)/; - - var prevSprite = ''; - var currentSprite = ''; - var rect = { x: 0, y: 0, width: 0, height: 0 }; - - // var pivot = { x: 0, y: 0 }; - // var border = { x: 0, y: 0, z: 0, w: 0 }; - - for (var i = 0; i < data.length; i++) - { - var results = data[i].match(lineRegExp); - - if (!results) - { - continue; - } - - var isList = (results[1] === '- '); - var key = results[2]; - var value = results[3]; - - if (isList) - { - if (currentSprite !== prevSprite) - { - addFrame(texture, sourceIndex, currentSprite, rect); - - prevSprite = currentSprite; - } - - rect = { x: 0, y: 0, width: 0, height: 0 }; - } - - if (key === 'name') - { - // Start new list - currentSprite = value; - continue; - } - - switch (key) - { - case 'x': - case 'y': - case 'width': - case 'height': - rect[key] = parseInt(value, 10); - break; - - // case 'pivot': - // pivot = eval('var obj = ' + value); - // break; - - // case 'border': - // border = eval('var obj = ' + value); - // break; - } - } - - if (currentSprite !== prevSprite) - { - addFrame(texture, sourceIndex, currentSprite, rect); - } - - return texture; -}; - -module.exports = UnityYAML; - -/* -Example data: - -TextureImporter: - spritePivot: {x: .5, y: .5} - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spritePixelsToUnits: 100 - spriteSheet: - sprites: - - name: asteroids_0 - rect: - serializedVersion: 2 - x: 5 - y: 328 - width: 65 - height: 82 - alignment: 0 - pivot: {x: 0, y: 0} - border: {x: 0, y: 0, z: 0, w: 0} - - name: asteroids_1 - rect: - serializedVersion: 2 - x: 80 - y: 322 - width: 53 - height: 88 - alignment: 0 - pivot: {x: 0, y: 0} - border: {x: 0, y: 0, z: 0, w: 0} - spritePackingTag: Asteroids -*/ - - -/***/ }), -/* 542 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GetValue = __webpack_require__(4); -var NOOP = __webpack_require__(3); -var RequestAnimationFrame = __webpack_require__(235); - -// Frame Rate config -// fps: { -// min: 10, -// target: 60, -// forceSetTimeOut: false, -// deltaHistory: 10, -// panicMax: 120 -// } - -// http://www.testufo.com/#test=animation-time-graph - -/** - * @classdesc - * [description] - * - * @class TimeStep - * @memberOf Phaser.Boot - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - A reference to the Phaser.Game instance that owns this Time Step. - * @param {FPSConfig} config - */ -var TimeStep = new Class({ - - initialize: - - function TimeStep (game, config) - { - /** - * A reference to the Phaser.Game instance. - * - * @property {Phaser.Game} game - * @readOnly - * @since 3.0.0 - */ - this.game = game; - - /** - * [description] - * - * @property {Phaser.DOM.RequestAnimationFrame} raf - * @readOnly - * @since 3.0.0 - */ - this.raf = new RequestAnimationFrame(); - - /** - * A flag that is set once the TimeStep has started running and toggled when it stops. - * - * @property {boolean} started - * @readOnly - * @default false - * @since 3.0.0 - */ - this.started = false; - - /** - * A flag that is set once the TimeStep has started running and toggled when it stops. - * The difference between this value and `started` is that `running` is toggled when - * the TimeStep is sent to sleep, where-as `started` remains `true`, only changing if - * the TimeStep is actually stopped, not just paused. - * - * @property {boolean} running - * @readOnly - * @default false - * @since 3.0.0 - */ - this.running = false; - - /** - * The minimum fps rate you want the Time Step to run at. - * - * @property {integer} minFps - * @default 5 - * @since 3.0.0 - */ - this.minFps = GetValue(config, 'min', 5); - - /** - * The target fps rate for the Time Step to run at. - * - * Setting this value will not actually change the speed at which the browser runs, that is beyond - * the control of Phaser. Instead, it allows you to determine performance issues and if the Time Step - * is spiraling out of control. - * - * @property {integer} targetFps - * @default 60 - * @since 3.0.0 - */ - this.targetFps = GetValue(config, 'target', 60); - - /** - * The minFps value in ms. - * Defaults to 200ms between frames (i.e. super slow!) - * - * @property {number} _min - * @private - * @since 3.0.0 - */ - this._min = 1000 / this.minFps; - - /** - * The targetFps value in ms. - * Defaults to 16.66ms between frames (i.e. normal) - * - * @property {number} _target - * @private - * @since 3.0.0 - */ - this._target = 1000 / this.targetFps; - - /** - * An exponential moving average of the frames per second. - * - * @property {integer} actualFps - * @readOnly - * @default 60 - * @since 3.0.0 - */ - this.actualFps = this.targetFps; - - /** - * [description] - * - * @property {integer} nextFpsUpdate - * @readOnly - * @default 0 - * @since 3.0.0 - */ - this.nextFpsUpdate = 0; - - /** - * The number of frames processed this second. - * - * @property {integer} framesThisSecond - * @readOnly - * @default 0 - * @since 3.0.0 - */ - this.framesThisSecond = 0; - - /** - * A callback to be invoked each time the Time Step steps. - * - * @property {function} callback - * @default NOOP - * @since 3.0.0 - */ - this.callback = NOOP; - - /** - * You can force the Time Step to use Set Timeout instead of Request Animation Frame by setting - * the `forceSetTimeOut` property to `true` in the Game Configuration object. It cannot be changed at run-time. - * - * @property {boolean} forceSetTimeOut - * @readOnly - * @default false - * @since 3.0.0 - */ - this.forceSetTimeOut = GetValue(config, 'forceSetTimeOut', false); - - /** - * [description] - * - * @property {integer} time - * @default 0 - * @since 3.0.0 - */ - this.time = 0; - - /** - * [description] - * - * @property {integer} startTime - * @default 0 - * @since 3.0.0 - */ - this.startTime = 0; - - /** - * [description] - * - * @property {integer} lastTime - * @default 0 - * @since 3.0.0 - */ - this.lastTime = 0; - - /** - * [description] - * - * @property {integer} frame - * @readOnly - * @default 0 - * @since 3.0.0 - */ - this.frame = 0; - - /** - * [description] - * - * @property {boolean} inFocus - * @readOnly - * @default true - * @since 3.0.0 - */ - this.inFocus = true; - - /** - * [description] - * - * @property {integer} _pauseTime - * @private - * @default 0 - * @since 3.0.0 - */ - this._pauseTime = 0; - - /** - * [description] - * - * @property {integer} _coolDown - * @private - * @default 0 - * @since 3.0.0 - */ - this._coolDown = 0; - - /** - * [description] - * - * @property {integer} delta - * @default 0 - * @since 3.0.0 - */ - this.delta = 0; - - /** - * [description] - * - * @property {integer} deltaIndex - * @default 0 - * @since 3.0.0 - */ - this.deltaIndex = 0; - - /** - * [description] - * - * @property {array} deltaHistory - * @default 0 - * @since 3.0.0 - */ - this.deltaHistory = []; - - /** - * [description] - * - * @property {integer} deltaSmoothingMax - * @default 10 - * @since 3.0.0 - */ - this.deltaSmoothingMax = GetValue(config, 'deltaHistory', 10); - - /** - * [description] - * - * @property {integer} panicMax - * @default 120 - * @since 3.0.0 - */ - this.panicMax = GetValue(config, 'panicMax', 120); - - /** - * The actual elapsed time in ms between one update and the next. - * Unlike with `delta` no smoothing, capping, or averaging is applied to this value. - * So please be careful when using this value in calculations. - * - * @property {number} rawDelta - * @default 0 - * @since 3.0.0 - */ - this.rawDelta = 0; - }, - - /** - * Called when the DOM window.onBlur event triggers. - * - * @method Phaser.Boot.TimeStep#blur - * @since 3.0.0 - */ - blur: function () - { - this.inFocus = false; - }, - - /** - * Called when the DOM window.onFocus event triggers. - * - * @method Phaser.Boot.TimeStep#focus - * @since 3.0.0 - */ - focus: function () - { - this.inFocus = true; - - this.resetDelta(); - }, - - /** - * Called when the visibility API says the game is 'hidden' (tab switch out of view, etc) - * - * @method Phaser.Boot.TimeStep#pause - * @since 3.0.0 - */ - pause: function () - { - this._pauseTime = window.performance.now(); - }, - - /** - * Called when the visibility API says the game is 'visible' again (tab switch back into view, etc) - * - * @method Phaser.Boot.TimeStep#resume - * @since 3.0.0 - */ - resume: function () - { - this.resetDelta(); - - this.startTime += this.time - this._pauseTime; - }, - - /** - * [description] - * - * @method Phaser.Boot.TimeStep#resetDelta - * @since 3.0.0 - */ - resetDelta: function () - { - var now = window.performance.now(); - - this.time = now; - this.lastTime = now; - this.nextFpsUpdate = now + 1000; - this.framesThisSecond = 0; - this.frame = 0; - - // Pre-populate smoothing array - - for (var i = 0; i < this.deltaSmoothingMax; i++) - { - this.deltaHistory[i] = Math.min(this._target, this.deltaHistory[i]); - } - - this.delta = 0; - this.deltaIndex = 0; - - this._coolDown = this.panicMax; - }, - - /** - * Starts the Time Step running, if it is not already doing so. - * Called automatically by the Game Boot process. - * - * @method Phaser.Boot.TimeStep#start - * @since 3.0.0 - * - * @param {function} callback - The callback to be invoked each time the Time Step steps. - */ - start: function (callback) - { - if (this.started) - { - return this; - } - - this.started = true; - this.running = true; - - for (var i = 0; i < this.deltaSmoothingMax; i++) - { - this.deltaHistory[i] = this._target; - } - - this.resetDelta(); - - this.startTime = window.performance.now(); - - this.callback = callback; - - this.raf.start(this.step.bind(this), this.forceSetTimeOut); - }, - - /** - * The main step method. This is called each time the browser updates, either by Request Animation Frame, - * or by Set Timeout. It is responsible for calculating the delta values, frame totals, cool down history and more. - * You generally should never call this method directly. - * - * @method Phaser.Boot.TimeStep#step - * @since 3.0.0 - * - * @param {integer} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. - */ - step: function (time) - { - this.frame++; - - this.rawDelta = time - this.lastTime; - - var idx = this.deltaIndex; - var history = this.deltaHistory; - var max = this.deltaSmoothingMax; - - // delta time (time is in ms) - var dt = (time - this.lastTime); - - // When a browser switches tab, then comes back again, it takes around 10 frames before - // the delta time settles down so we employ a 'cooling down' period before we start - // trusting the delta values again, to avoid spikes flooding through our delta average - - if (this._coolDown > 0 || !this.inFocus) - { - this._coolDown--; - - dt = Math.min(dt, this._target); - } - - if (dt > this._min) - { - // Probably super bad start time or browser tab context loss, - // so use the last 'sane' dt value - - dt = history[idx]; - - // Clamp delta to min (in case history has become corrupted somehow) - dt = Math.min(dt, this._min); - } - - // Smooth out the delta over the previous X frames - - // add the delta to the smoothing array - history[idx] = dt; - - // adjusts the delta history array index based on the smoothing count - // this stops the array growing beyond the size of deltaSmoothingMax - this.deltaIndex++; - - if (this.deltaIndex > max) - { - this.deltaIndex = 0; - } - - // Delta Average - var avg = 0; - - // Loop the history array, adding the delta values together - - for (var i = 0; i < max; i++) - { - avg += history[i]; - } - - // Then divide by the array length to get the average delta - avg /= max; - - // Set as the world delta value - this.delta = avg; - - // Real-world timer advance - this.time += this.rawDelta; - - // Update the estimate of the frame rate, `fps`. Every second, the number - // of frames that occurred in that second are included in an exponential - // moving average of all frames per second, with an alpha of 0.25. This - // means that more recent seconds affect the estimated frame rate more than - // older seconds. - // - // When a browser window is NOT minimized, but is covered up (i.e. you're using - // another app which has spawned a window over the top of the browser), then it - // will start to throttle the raf callback time. It waits for a while, and then - // starts to drop the frame rate at 1 frame per second until it's down to just over 1fps. - // So if the game was running at 60fps, and the player opens a new window, then - // after 60 seconds (+ the 'buffer time') it'll be down to 1fps, so rafin'g at 1Hz. - // - // When they make the game visible again, the frame rate is increased at a rate of - // approx. 8fps, back up to 60fps (or the max it can obtain) - // - // There is no easy way to determine if this drop in frame rate is because the - // browser is throttling raf, or because the game is struggling with performance - // because you're asking it to do too much on the device. - - if (time > this.nextFpsUpdate) - { - // Compute the new exponential moving average with an alpha of 0.25. - this.actualFps = 0.25 * this.framesThisSecond + 0.75 * this.actualFps; - this.nextFpsUpdate = time + 1000; - this.framesThisSecond = 0; - } - - this.framesThisSecond++; - - // Interpolation - how far between what is expected and where we are? - var interpolation = avg / this._target; - - this.callback(time, avg, interpolation); - - // Shift time value over - this.lastTime = time; - }, - - /** - * Manually calls TimeStep.step, passing in the performance.now value to it. - * - * @method Phaser.Boot.TimeStep#tick - * @since 3.0.0 - */ - tick: function () - { - this.step(window.performance.now()); - }, - - /** - * Sends the TimeStep to sleep, stopping Request Animation Frame (or SetTimeout) and toggling the `running` flag to false. - * - * @method Phaser.Boot.TimeStep#sleep - * @since 3.0.0 - */ - sleep: function () - { - if (this.running) - { - this.raf.stop(); - - this.running = false; - } - }, - - /** - * Wakes-up the TimeStep, restarting Request Animation Frame (or SetTimeout) and toggling the `running` flag to true. - * The `seamless` argument controls if the wake-up should adjust the start time or not. - * - * @method Phaser.Boot.TimeStep#wake - * @since 3.0.0 - * - * @param {boolean} [seamless=false] - Adjust the startTime based on the lastTime values. - */ - wake: function (seamless) - { - if (this.running) - { - this.sleep(); - } - else if (seamless) - { - this.startTime += -this.lastTime + (this.lastTime = window.performance.now()); - } - - this.raf.start(this.step.bind(this), this.useRAF); - - this.running = true; - - this.step(window.performance.now()); - }, - - /** - * Stops the TimeStep running. - * - * @method Phaser.Boot.TimeStep#stop - * @since 3.0.0 - * - * @return {Phaser.Boot.TimeStep} The TimeStep object. - */ - stop: function () - { - this.running = false; - this.started = false; - - this.raf.stop(); - - return this; - }, - - /** - * Destroys the TimeStep. This will stop Request Animation Frame, stop the step, clear the callbacks and null - * any objects. - * - * @method Phaser.Boot.TimeStep#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.stop(); - - this.callback = NOOP; - - this.raf = null; - this.game = null; - } - -}); - -module.exports = TimeStep; - - -/***/ }), -/* 543 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Visibility Handler hidden event. - * - * The document in which the Game is embedded has entered a hidden state. - * - * @event Phaser.Boot.VisibilityHandler#hidden - */ - -/** - * Visibility Handler visible event. - * - * The document in which the Game is embedded has entered a visible state. - * - * @event Phaser.Boot.VisibilityHandler#visible - */ - -/** - * Visibility Handler blur event. - * - * The window in which the Game is embedded has entered a blurred state. - * - * @event Phaser.Boot.VisibilityHandler#blur - */ - -/** - * Visibility Handler focus event. - * - * The window in which the Game is embedded has entered a focused state. - * - * @event Phaser.Boot.VisibilityHandler#focus - */ - -/** - * The Visibility Handler is responsible for listening out for document level visibility change events. - * This includes `visibilitychange` if the browser supports it, and blur and focus events. It then uses - * the provided Event Emitter and fires the related events. - * - * @function Phaser.Boot.VisibilityHandler - * @fires Phaser.Boot.VisibilityHandler#hidden - * @fires Phaser.Boot.VisibilityHandler#visible - * @fires Phaser.Boot.VisibilityHandler#blur - * @fires Phaser.Boot.VisibilityHandler#focus - * @since 3.0.0 - * - * @param {Phaser.EventEmitter} eventEmitter - The EventEmitter that will emit the visibility events. - */ -var VisibilityHandler = function (eventEmitter) -{ - var hiddenVar; - - if (document.hidden !== undefined) - { - hiddenVar = 'visibilitychange'; - } - else - { - var vendors = [ 'webkit', 'moz', 'ms' ]; - - vendors.forEach(function (prefix) - { - if (document[prefix + 'Hidden'] !== undefined) - { - document.hidden = function () - { - return document[prefix + 'Hidden']; - }; - - hiddenVar = prefix + 'visibilitychange'; - } - - }); - } - - var onChange = function (event) - { - if (document.hidden || event.type === 'pause') - { - eventEmitter.emit('hidden'); - } - else - { - eventEmitter.emit('visible'); - } - }; - - if (hiddenVar) - { - document.addEventListener(hiddenVar, onChange, false); - } - - window.onblur = function () - { - eventEmitter.emit('blur'); - }; - - window.onfocus = function () - { - eventEmitter.emit('focus'); - }; -}; - -module.exports = VisibilityHandler; - - -/***/ }), -/* 544 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.GameObjects - */ - -var GameObjects = { - - DisplayList: __webpack_require__(545), - GameObjectCreator: __webpack_require__(13), - GameObjectFactory: __webpack_require__(9), - UpdateList: __webpack_require__(546), - - Components: __webpack_require__(11), - - BuildGameObject: __webpack_require__(20), - BuildGameObjectAnimation: __webpack_require__(132), - GameObject: __webpack_require__(1), - BitmapText: __webpack_require__(133), - Blitter: __webpack_require__(134), - DynamicBitmapText: __webpack_require__(135), - Graphics: __webpack_require__(136), - Group: __webpack_require__(69), - Image: __webpack_require__(70), - Particles: __webpack_require__(139), - PathFollower: __webpack_require__(290), - RenderTexture: __webpack_require__(141), - Sprite3D: __webpack_require__(81), - Sprite: __webpack_require__(37), - Text: __webpack_require__(142), - TileSprite: __webpack_require__(143), - Zone: __webpack_require__(77), - - // Game Object Factories - - Factories: { - Blitter: __webpack_require__(630), - DynamicBitmapText: __webpack_require__(631), - Graphics: __webpack_require__(632), - Group: __webpack_require__(633), - Image: __webpack_require__(634), - Particles: __webpack_require__(635), - PathFollower: __webpack_require__(636), - RenderTexture: __webpack_require__(637), - Sprite3D: __webpack_require__(638), - Sprite: __webpack_require__(639), - StaticBitmapText: __webpack_require__(640), - Text: __webpack_require__(641), - TileSprite: __webpack_require__(642), - Zone: __webpack_require__(643) - }, - - Creators: { - Blitter: __webpack_require__(644), - DynamicBitmapText: __webpack_require__(645), - Graphics: __webpack_require__(646), - Group: __webpack_require__(647), - Image: __webpack_require__(648), - Particles: __webpack_require__(649), - RenderTexture: __webpack_require__(650), - Sprite3D: __webpack_require__(651), - Sprite: __webpack_require__(652), - StaticBitmapText: __webpack_require__(653), - Text: __webpack_require__(654), - TileSprite: __webpack_require__(655), - Zone: __webpack_require__(656) - } - -}; - -if (true) -{ - // WebGL only Game Objects - GameObjects.Mesh = __webpack_require__(88); - GameObjects.Quad = __webpack_require__(144); - - GameObjects.Factories.Mesh = __webpack_require__(660); - GameObjects.Factories.Quad = __webpack_require__(661); - - GameObjects.Creators.Mesh = __webpack_require__(662); - GameObjects.Creators.Quad = __webpack_require__(663); - - GameObjects.Light = __webpack_require__(292); - - __webpack_require__(293); - __webpack_require__(664); -} - -module.exports = GameObjects; - - -/***/ }), -/* 545 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var List = __webpack_require__(86); -var PluginManager = __webpack_require__(12); -var StableSort = __webpack_require__(267); - -/** - * @classdesc - * [description] - * - * @class DisplayList - * @extends Phaser.Structs.List - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var DisplayList = new Class({ - - Extends: List, - - initialize: - - function DisplayList (scene) - { - List.call(this, scene); - - /** - * [description] - * - * @name Phaser.GameObjects.DisplayList#sortChildrenFlag - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.sortChildrenFlag = false; - - /** - * [description] - * - * @name Phaser.GameObjects.DisplayList#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.GameObjects.DisplayList#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - if (!scene.sys.settings.isBooted) - { - scene.sys.events.once('boot', this.boot, this); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.DisplayList#boot - * @since 3.0.0 - */ - boot: function () - { - var eventEmitter = this.systems.events; - - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); - }, - - /** - * Force a sort of the display list on the next call to depthSort. - * - * @method Phaser.GameObjects.DisplayList#queueDepthSort - * @since 3.0.0 - */ - queueDepthSort: function () - { - this.sortChildrenFlag = true; - }, - - /** - * Immediately sorts the display list if the flag is set. - * - * @method Phaser.GameObjects.DisplayList#depthSort - * @since 3.0.0 - */ - depthSort: function () - { - if (this.sortChildrenFlag) - { - StableSort.inplace(this.list, this.sortByDepth); - - this.sortChildrenFlag = false; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.DisplayList#sortByDepth - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} childA - [description] - * @param {Phaser.GameObjects.GameObject} childB - [description] - * - * @return {integer} [description] - */ - sortByDepth: function (childA, childB) - { - return childA._depth - childB._depth; - }, - - /** - * Given an array of Game Objects, sort the array and return it, - * so that the objects are in index order with the lowest at the bottom. - * - * @method Phaser.GameObjects.DisplayList#sortGameObjects - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject[]} gameObjects - [description] - * - * @return {array} [description] - */ - sortGameObjects: function (gameObjects) - { - if (gameObjects === undefined) { gameObjects = this.list; } - - this.scene.sys.depthSort(); - - return gameObjects.sort(this.sortIndexHandler.bind(this)); - }, - - /** - * Note that the given array is sorted in place, even though it isn't returned directly it will still be updated. - * - * @method Phaser.GameObjects.DisplayList#getTopGameObject - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject[]} gameObjects - [description] - * - * @return {Phaser.GameObjects.GameObject} The top-most Game Object on the Display List. - */ - getTopGameObject: function (gameObjects) - { - this.sortGameObjects(gameObjects); - - return gameObjects[gameObjects.length - 1]; - } - -}); - -PluginManager.register('DisplayList', DisplayList, 'displayList'); - -module.exports = DisplayList; - - -/***/ }), -/* 546 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var PluginManager = __webpack_require__(12); - -/** - * @classdesc - * [description] - * - * @class UpdateList - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var UpdateList = new Class({ - - initialize: - - function UpdateList (scene) - { - /** - * [description] - * - * @name Phaser.GameObjects.UpdateList#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.GameObjects.UpdateList#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - if (!scene.sys.settings.isBooted) - { - scene.sys.events.once('boot', this.boot, this); - } - - /** - * [description] - * - * @name Phaser.GameObjects.UpdateList#_list - * @type {array} + * @name Phaser.Time.Clock#_active + * @type {Phaser.Time.TimerEvent[]} * @private * @default [] * @since 3.0.0 */ - this._list = []; + this._active = []; /** * [description] * - * @name Phaser.GameObjects.UpdateList#_pendingInsertion - * @type {array} + * @name Phaser.Time.Clock#_pendingInsertion + * @type {Phaser.Time.TimerEvent[]} * @private * @default [] * @since 3.0.0 @@ -95073,8 +83920,8 @@ var UpdateList = new Class({ /** * [description] * - * @name Phaser.GameObjects.UpdateList#_pendingRemoval - * @type {array} + * @name Phaser.Time.Clock#_pendingRemoval + * @type {Phaser.Time.TimerEvent[]} * @private * @default [] * @since 3.0.0 @@ -95085,7 +83932,7 @@ var UpdateList = new Class({ /** * [description] * - * @method Phaser.GameObjects.UpdateList#boot + * @method Phaser.Time.Clock#boot * @since 3.0.0 */ boot: function () @@ -95101,29 +83948,74 @@ var UpdateList = new Class({ /** * [description] * - * @method Phaser.GameObjects.UpdateList#add + * @method Phaser.Time.Clock#addEvent * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} child - [description] + * @param {TimerEventConfig} config - [description] * - * @return {Phaser.GameObjects.GameObject} [description] + * @return {Phaser.Time.TimerEvent} [description] */ - add: function (child) + addEvent: function (config) { - // Is child already in this list? + var event = new TimerEvent(config); - if (this._list.indexOf(child) === -1 && this._pendingInsertion.indexOf(child) === -1) - { - this._pendingInsertion.push(child); - } + this._pendingInsertion.push(event); - return child; + return event; }, /** * [description] * - * @method Phaser.GameObjects.UpdateList#preUpdate + * @method Phaser.Time.Clock#delayedCall + * @since 3.0.0 + * + * @param {number} delay - [description] + * @param {function} callback - [description] + * @param {Array.<*>} args - [description] + * @param {*} callbackScope - [description] + * + * @return {Phaser.Time.TimerEvent} [description] + */ + delayedCall: function (delay, callback, args, callbackScope) + { + return this.addEvent({ delay: delay, callback: callback, args: args, callbackScope: callbackScope }); + }, + + /** + * [description] + * + * @method Phaser.Time.Clock#clearPendingEvents + * @since 3.0.0 + * + * @return {Phaser.Time.Clock} [description] + */ + clearPendingEvents: function () + { + this._pendingInsertion = []; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Time.Clock#removeAllEvents + * @since 3.0.0 + * + * @return {Phaser.Time.Clock} [description] + */ + removeAllEvents: function () + { + this._pendingRemoval = this._pendingRemoval.concat(this._active); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Time.Clock#preUpdate * @since 3.0.0 * * @param {number} time - [description] @@ -95141,23 +84033,30 @@ var UpdateList = new Class({ } var i; - var gameObject; + var event; - // Delete old gameObjects + // Delete old events for (i = 0; i < toRemove; i++) { - gameObject = this._pendingRemoval[i]; + event = this._pendingRemoval[i]; - var index = this._list.indexOf(gameObject); + var index = this._active.indexOf(event); if (index > -1) { - this._list.splice(index, 1); + this._active.splice(index, 1); } + + // Pool them? + event.destroy(); } - // Move pending to active - this._list = this._list.concat(this._pendingInsertion.splice(0)); + for (i = 0; i < toInsert; i++) + { + event = this._pendingInsertion[i]; + + this._active.push(event); + } // Clear the lists this._pendingRemoval.length = 0; @@ -95167,7 +84066,7 @@ var UpdateList = new Class({ /** * [description] * - * @method Phaser.GameObjects.UpdateList#update + * @method Phaser.Time.Clock#update * @since 3.0.0 * * @param {number} time - [description] @@ -95175,13 +84074,55 @@ var UpdateList = new Class({ */ update: function (time, delta) { - for (var i = 0; i < this._list.length; i++) - { - var gameObject = this._list[i]; + this.now = time; - if (gameObject.active) + if (this.paused) + { + return; + } + + delta *= this.timeScale; + + for (var i = 0; i < this._active.length; i++) + { + var event = this._active[i]; + + if (event.paused) { - gameObject.preUpdate.call(gameObject, time, delta); + continue; + } + + // Use delta time to increase elapsed. + // Avoids needing to adjust for pause / resume. + // Automatically smoothed by TimeStep class. + // In testing accurate to +- 1ms! + event.elapsed += delta * event.timeScale; + + if (event.elapsed >= event.delay) + { + var remainder = event.elapsed - event.delay; + + // Limit it, in case it's checked in the callback + event.elapsed = event.delay; + + // Process the event + if (!event.hasDispatched && event.callback) + { + event.hasDispatched = true; + event.callback.apply(event.callbackScope, event.args); + } + + if (event.repeatCount > 0) + { + event.repeatCount--; + + event.elapsed = remainder; + event.hasDispatched = false; + } + else + { + this._pendingRemoval.push(event); + } } } }, @@ -95189,56 +84130,29 @@ var UpdateList = new Class({ /** * [description] * - * @method Phaser.GameObjects.UpdateList#remove - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - * - * @return {Phaser.GameObjects.GameObject} [description] - */ - remove: function (child) - { - var index = this._list.indexOf(child); - - if (index !== -1) - { - this._list.splice(index, 1); - } - - return child; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.UpdateList#removeAll - * @since 3.0.0 - * - * @return {Phaser.GameObjects.UpdateList} The UpdateList object. - */ - removeAll: function () - { - var i = this._list.length; - - while (i--) - { - this.remove(this._list[i]); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.UpdateList#shutdown + * @method Phaser.Time.Clock#shutdown * @since 3.0.0 */ shutdown: function () { - this.removeAll(); + var i; - this._list.length = 0; + for (i = 0; i < this._pendingInsertion.length; i++) + { + this._pendingInsertion[i].destroy(); + } + + for (i = 0; i < this._active.length; i++) + { + this._active[i].destroy(); + } + + for (i = 0; i < this._pendingRemoval.length; i++) + { + this._pendingRemoval[i].destroy(); + } + + this._active.length = 0; this._pendingRemoval.length = 0; this._pendingInsertion.length = 0; }, @@ -95246,7 +84160,7 @@ var UpdateList = new Class({ /** * [description] * - * @method Phaser.GameObjects.UpdateList#destroy + * @method Phaser.Time.Clock#destroy * @since 3.0.0 */ destroy: function () @@ -95254,15 +84168,10879 @@ var UpdateList = new Class({ this.shutdown(); this.scene = undefined; - this.systems = undefined; - } }); -PluginManager.register('UpdateList', UpdateList, 'updateList'); +PluginManager.register('Clock', Clock, 'time'); -module.exports = UpdateList; +module.exports = Clock; + + +/***/ }), +/* 406 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Time + */ + +module.exports = { + + Clock: __webpack_require__(405), + TimerEvent: __webpack_require__(183) + +}; + + +/***/ }), +/* 407 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(9); +var ParseToTilemap = __webpack_require__(115); + +/** + * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. + * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing + * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map + * data. For an empty map, you should specify tileWidth, tileHeight, width & height. + * + * @method Phaser.GameObjects.GameObjectFactory#tilemap + * @since 3.0.0 + * + * @param {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data. + * @param {integer} [tileWidth=32] - The width of a tile in pixels. Pass in `null` to leave as the + * default. + * @param {integer} [tileHeight=32] - The height of a tile in pixels. Pass in `null` to leave as the + * default. + * @param {integer} [width=10] - The width of the map in tiles. Pass in `null` to leave as the + * default. + * @param {integer} [height=10] - The height of the map in tiles. Pass in `null` to leave as the + * default. + * @param {integer[][]} [data] - Instead of loading from the cache, you can also load directly from + * a 2D array of tile indexes. Pass in `null` for no data. + * @param {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, in the + * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + * + * @return {Phaser.Tilemaps.Tilemap} + */ +GameObjectFactory.register('tilemap', function (key, tileWidth, tileHeight, width, height, data, insertNull) +{ + // Allow users to specify null to indicate that they want the default value, since null is + // shorter & more legible than undefined. Convert null to undefined to allow ParseToTilemap + // defaults to take effect. + + if (key === null) { key = undefined; } + if (tileWidth === null) { tileWidth = undefined; } + if (tileHeight === null) { tileHeight = undefined; } + if (width === null) { width = undefined; } + if (height === null) { height = undefined; } + + return ParseToTilemap(this.scene, key, tileWidth, tileHeight, width, height, data, insertNull); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 408 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectCreator = __webpack_require__(11); +var ParseToTilemap = __webpack_require__(115); + +/** + * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. + * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing + * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map + * data. For an empty map, you should specify tileWidth, tileHeight, width & height. + * + * @method Phaser.GameObjects.GameObjectCreator#tilemap + * @since 3.0.0 + * + * @param {object} [config] - The config options for the Tilemap. + * @param {string} [config.key] - The key in the Phaser cache that corresponds to the loaded tilemap + * data. + * @param {integer[][]} [config.data] - Instead of loading from the cache, you can also load + * directly from a 2D array of tile indexes. + * @param {integer} [config.tileWidth=32] - The width of a tile in pixels. + * @param {integer} [config.tileHeight=32] - The height of a tile in pixels. + * @param {integer} [config.width=10] - The width of the map in tiles. + * @param {integer} [config.height=10] - The height of the map in tiles. + * @param {boolean} [config.insertNull=false] - Controls how empty tiles, tiles with an index of -1, + * in the map data are handled. If `true`, empty locations will get a value of `null`. If `false`, + * empty location will get a Tile object with an index of -1. If you've a large sparsely populated + * map and the tile data doesn't need to change then setting this value to `true` will help with + * memory consumption. However if your map is small or you need to update the tiles dynamically, + * then leave the default value set. + * + * @return {Phaser.Tilemaps.Tilemap} + */ +GameObjectCreator.register('tilemap', function (config) +{ + // Defaults are applied in ParseToTilemap + var c = (config !== undefined) ? config : {}; + + return ParseToTilemap( + this.scene, + c.key, + c.tileWidth, + c.tileHeight, + c.width, + c.height, + c.data, + c.insertNull + ); +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 409 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.Tilemaps.StaticTilemapLayer} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + src.cull(camera); + + var renderTiles = src.culledTiles; + var tileset = this.tileset; + var ctx = renderer.gameContext; + var tileCount = renderTiles.length; + var image = tileset.image.getSourceImage(); + var tx = src.x - camera.scrollX * src.scrollFactorX; + var ty = src.y - camera.scrollY * src.scrollFactorY; + + ctx.save(); + ctx.translate(tx, ty); + ctx.rotate(src.rotation); + ctx.scale(src.scaleX, src.scaleY); + ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); + ctx.globalAlpha = src.alpha; + + for (var index = 0; index < tileCount; ++index) + { + var tile = renderTiles[index]; + + var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); + + if (tileTexCoords === null) { continue; } + + ctx.drawImage( + image, + tileTexCoords.x, tileTexCoords.y, + tile.width, tile.height, + tile.pixelX, tile.pixelY, + tile.width, tile.height + ); + } + + ctx.restore(); +}; + +module.exports = StaticTilemapLayerCanvasRenderer; + + +/***/ }), +/* 410 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.Tilemaps.StaticTilemapLayer} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + src.upload(camera); + + this.pipeline.drawStaticTilemapLayer(src, camera); +}; + +module.exports = StaticTilemapLayerWebGLRenderer; + + +/***/ }), +/* 411 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); + +if (true) +{ + renderWebGL = __webpack_require__(410); +} + +if (true) +{ + renderCanvas = __webpack_require__(409); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 412 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.Tilemaps.DynamicTilemapLayer} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + src.cull(camera); + + var renderTiles = src.culledTiles; + var length = renderTiles.length; + var image = src.tileset.image.getSourceImage(); + var tileset = this.tileset; + + var tx = src.x - camera.scrollX * src.scrollFactorX; + var ty = src.y - camera.scrollY * src.scrollFactorY; + var ctx = renderer.gameContext; + + ctx.save(); + ctx.translate(tx, ty); + ctx.rotate(src.rotation); + ctx.scale(src.scaleX, src.scaleY); + ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); + + for (var index = 0; index < length; ++index) + { + var tile = renderTiles[index]; + + var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); + if (tileTexCoords === null) { continue; } + + var halfWidth = tile.width / 2; + var halfHeight = tile.height / 2; + + ctx.save(); + ctx.translate(tile.pixelX + halfWidth, tile.pixelY + halfHeight); + + if (tile.rotation !== 0) + { + ctx.rotate(tile.rotation); + } + + if (tile.flipX || tile.flipY) + { + ctx.scale(tile.flipX ? -1 : 1, tile.flipY ? -1 : 1); + } + + ctx.globalAlpha = src.alpha * tile.alpha; + + ctx.drawImage( + image, + tileTexCoords.x, tileTexCoords.y, + tile.width, tile.height, + -halfWidth, -halfHeight, + tile.width, tile.height + ); + + ctx.restore(); + } + + ctx.restore(); +}; + +module.exports = DynamicTilemapLayerCanvasRenderer; + + +/***/ }), +/* 413 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.Tilemaps.DynamicTilemapLayer} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var DynamicTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + src.cull(camera); + + this.pipeline.batchDynamicTilemapLayer(src, camera); +}; + +module.exports = DynamicTilemapLayerWebGLRenderer; + + +/***/ }), +/* 414 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); + +if (true) +{ + renderWebGL = __webpack_require__(413); +} + +if (true) +{ + renderCanvas = __webpack_require__(412); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 415 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Tileset = __webpack_require__(84); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Impact.ParseTilesets + * @since 3.0.0 + * + * @param {object} json - [description] + * + * @return {array} [description] + */ +var ParseTilesets = function (json) +{ + var tilesets = []; + var tilesetsNames = []; + + for (var i = 0; i < json.layer.length; i++) + { + var layer = json.layer[i]; + + // A relative filepath to the source image (within Weltmeister) is used for the name + var tilesetName = layer.tilesetName; + + // Only add unique tilesets that have a valid name. Collision layers will have a blank name. + if (tilesetName !== '' && tilesetsNames.indexOf(tilesetName) === -1) + { + tilesetsNames.push(tilesetName); + + // Tiles are stored with an ID relative to the tileset, rather than a globally unique ID + // across all tilesets. Also, tilesets in Weltmeister have no margin or padding. + tilesets.push(new Tileset(tilesetName, 0, layer.tilesize, layer.tilesize, 0, 0)); + } + } + + return tilesets; +}; + +module.exports = ParseTilesets; + + +/***/ }), +/* 416 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var LayerData = __webpack_require__(66); +var Tile = __webpack_require__(45); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Impact.ParseTileLayers + * @since 3.0.0 + * + * @param {object} json - [description] + * @param {boolean} insertNull - [description] + * + * @return {array} [description] + */ +var ParseTileLayers = function (json, insertNull) +{ + var tileLayers = []; + + for (var i = 0; i < json.layer.length; i++) + { + var layer = json.layer[i]; + + var layerData = new LayerData({ + name: layer.name, + width: layer.width, + height: layer.height, + tileWidth: layer.tilesize, + tileHeight: layer.tilesize, + visible: layer.visible === 1 + }); + + var row = []; + var tileGrid = []; + + // Loop through the data field in the JSON. This is a 2D array containing the tile indexes, + // one after the other. The indexes are relative to the tileset that contains the tile. + for (var y = 0; y < layer.data.length; y++) + { + for (var x = 0; x < layer.data[y].length; x++) + { + // In Weltmeister, 0 = no tile, but the Tilemap API expects -1 = no tile. + var index = layer.data[y][x] - 1; + + var tile; + + if (index > -1) + { + tile = new Tile(layerData, index, x, y, layer.tilesize, layer.tilesize); + } + else + { + tile = insertNull + ? null + : new Tile(layerData, -1, x, y, layer.tilesize, layer.tilesize); + } + + row.push(tile); + } + + tileGrid.push(row); + row = []; + } + + layerData.data = tileGrid; + + tileLayers.push(layerData); + } + + return tileLayers; +}; + +module.exports = ParseTileLayers; + + +/***/ }), +/* 417 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Extend = __webpack_require__(18); + +/** + * Copy properties from tileset to tiles. + * + * @function Phaser.Tilemaps.Parsers.Tiled.AssignTileProperties + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.MapData} mapData - [description] + */ +var AssignTileProperties = function (mapData) +{ + var layerData; + var tile; + var sid; + var set; + var row; + + // go through each of the map data layers + for (var i = 0; i < mapData.layers.length; i++) + { + layerData = mapData.layers[i]; + + set = null; + + // rows of tiles + for (var j = 0; j < layerData.data.length; j++) + { + row = layerData.data[j]; + + // individual tiles + for (var k = 0; k < row.length; k++) + { + tile = row[k]; + + if (tile === null || tile.index < 0) + { + continue; + } + + // find the relevant tileset + sid = mapData.tiles[tile.index][2]; + set = mapData.tilesets[sid]; + + // Ensure that a tile's size matches its tileset + tile.width = set.tileWidth; + tile.height = set.tileHeight; + + // if that tile type has any properties, add them to the tile object + if (set.tileProperties && set.tileProperties[tile.index - set.firstgid]) + { + tile.properties = Extend( + tile.properties, set.tileProperties[tile.index - set.firstgid] + ); + } + } + } + } +}; + +module.exports = AssignTileProperties; + + +/***/ }), +/* 418 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Master list of tiles -> x, y, index in tileset. + * + * @function Phaser.Tilemaps.Parsers.Tiled.BuildTilesetIndex + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.MapData} mapData - [description] + * + * @return {array} [description] + */ +var BuildTilesetIndex = function (mapData) +{ + var tiles = []; + + for (var i = 0; i < mapData.tilesets.length; i++) + { + var set = mapData.tilesets[i]; + + var x = set.tileMargin; + var y = set.tileMargin; + + var count = 0; + var countX = 0; + var countY = 0; + + for (var t = set.firstgid; t < set.firstgid + set.total; t++) + { + // Can add extra properties here as needed + tiles[t] = [ x, y, i ]; + + x += set.tileWidth + set.tileSpacing; + + count++; + + if (count === set.total) + { + break; + } + + countX++; + + if (countX === set.columns) + { + x = set.tileMargin; + y += set.tileHeight + set.tileSpacing; + + countX = 0; + countY++; + + if (countY === set.rows) + { + break; + } + } + } + } + + return tiles; +}; + +module.exports = BuildTilesetIndex; + + +/***/ }), +/* 419 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(2); +var ParseObject = __webpack_require__(189); +var ObjectLayer = __webpack_require__(188); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseObjectLayers + * @since 3.0.0 + * + * @param {object} json - [description] + * + * @return {array} [description] + */ +var ParseObjectLayers = function (json) +{ + var objectLayers = []; + + for (var i = 0; i < json.layers.length; i++) + { + if (json.layers[i].type !== 'objectgroup') + { + continue; + } + + var curo = json.layers[i]; + var offsetX = GetFastValue(curo, 'offsetx', 0); + var offsetY = GetFastValue(curo, 'offsety', 0); + var objects = []; + + for (var j = 0; j < curo.objects.length; j++) + { + var parsedObject = ParseObject(curo.objects[j], offsetX, offsetY); + + objects.push(parsedObject); + } + + var objectLayer = new ObjectLayer(curo); + objectLayer.objects = objects; + + objectLayers.push(objectLayer); + } + + return objectLayers; +}; + +module.exports = ParseObjectLayers; + + +/***/ }), +/* 420 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var HasValue = __webpack_require__(70); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.Pick + * @since 3.0.0 + * + * @param {object} object - [description] + * @param {array} keys - [description] + * + * @return {object} [description] + */ +var Pick = function (object, keys) +{ + var obj = {}; + + for (var i = 0; i < keys.length; i++) + { + var key = keys[i]; + + if (HasValue(object, key)) + { + obj[key] = object[key]; + } + } + + return obj; +}; + +module.exports = Pick; + + +/***/ }), +/* 421 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Tileset = __webpack_require__(84); +var ImageCollection = __webpack_require__(190); +var ParseObject = __webpack_require__(189); + +/** + * Tilesets & Image Collections + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseTilesets + * @since 3.0.0 + * + * @param {object} json - [description] + * + * @return {object} [description] + */ +var ParseTilesets = function (json) +{ + var tilesets = []; + var imageCollections = []; + var lastSet = null; + var stringID; + + for (var i = 0; i < json.tilesets.length; i++) + { + // name, firstgid, width, height, margin, spacing, properties + var set = json.tilesets[i]; + + if (set.source) + { + console.warn('Phaser can\'t load external tilesets. Use the Embed Tileset button and then export the map again.'); + } + else if (set.image) + { + var newSet = new Tileset(set.name, set.firstgid, set.tilewidth, set.tileheight, set.margin, set.spacing); + + // Properties stored per-tile in object with string indexes starting at "0" + if (set.tileproperties) + { + newSet.tileProperties = set.tileproperties; + } + + // Object & terrain shapes stored per-tile in object with string indexes starting at "0" + if (set.tiles) + { + newSet.tileData = set.tiles; + + // Parse the objects into Phaser format to match handling of other Tiled objects + for (stringID in newSet.tileData) + { + var objectGroup = newSet.tileData[stringID].objectgroup; + if (objectGroup && objectGroup.objects) + { + var parsedObjects = objectGroup.objects.map( + function (obj) { return ParseObject(obj); } + ); + newSet.tileData[stringID].objectgroup.objects = parsedObjects; + } + } + } + + // For a normal sliced tileset the row/count/size information is computed when updated. + // This is done (again) after the image is set. + newSet.updateTileData(set.imagewidth, set.imageheight); + + tilesets.push(newSet); + } + else + { + var newCollection = new ImageCollection(set.name, set.firstgid, set.tilewidth, + set.tileheight, set.margin, set.spacing, set.properties); + + for (stringID in set.tiles) + { + var image = set.tiles[stringID].image; + var gid = set.firstgid + parseInt(stringID, 10); + newCollection.addImage(gid, image); + } + + imageCollections.push(newCollection); + } + + // We've got a new Tileset, so set the lastgid into the previous one + if (lastSet) + { + lastSet.lastgid = set.firstgid - 1; + } + + lastSet = set; + } + + return { tilesets: tilesets, imageCollections: imageCollections }; +}; + +module.exports = ParseTilesets; + + +/***/ }), +/* 422 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(2); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseImageLayers + * @since 3.0.0 + * + * @param {object} json - [description] + * + * @return {array} [description] + */ +var ParseImageLayers = function (json) +{ + var images = []; + + for (var i = 0; i < json.layers.length; i++) + { + if (json.layers[i].type !== 'imagelayer') + { + continue; + } + + var curi = json.layers[i]; + + images.push({ + name: curi.name, + image: curi.image, + x: GetFastValue(curi, 'offsetx', 0) + curi.x, + y: GetFastValue(curi, 'offsety', 0) + curi.y, + alpha: curi.opacity, + visible: curi.visible, + properties: GetFastValue(curi, 'properties', {}) + }); + } + + return images; +}; + +module.exports = ParseImageLayers; + + +/***/ }), +/* 423 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.Base64Decode + * @since 3.0.0 + * + * @param {object} data - [description] + * + * @return {array} [description] + */ +var Base64Decode = function (data) +{ + var binaryString = window.atob(data); + var len = binaryString.length; + var bytes = new Array(len); + + // Interpret binaryString as an array of bytes representing little-endian encoded uint32 values. + for (var i = 0; i < len; i += 4) + { + bytes[i / 4] = ( + binaryString.charCodeAt(i) | + binaryString.charCodeAt(i + 1) << 8 | + binaryString.charCodeAt(i + 2) << 16 | + binaryString.charCodeAt(i + 3) << 24 + ) >>> 0; + } + + return bytes; +}; + +module.exports = Base64Decode; + + +/***/ }), +/* 424 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Base64Decode = __webpack_require__(423); +var GetFastValue = __webpack_require__(2); +var LayerData = __webpack_require__(66); +var ParseGID = __webpack_require__(191); +var Tile = __webpack_require__(45); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseTileLayers + * @since 3.0.0 + * + * @param {object} json - [description] + * @param {boolean} insertNull - [description] + * + * @return {array} [description] + */ +var ParseTileLayers = function (json, insertNull) +{ + var tileLayers = []; + + for (var i = 0; i < json.layers.length; i++) + { + if (json.layers[i].type !== 'tilelayer') + { + continue; + } + + var curl = json.layers[i]; + + // Base64 decode data if necessary. NOTE: uncompressed base64 only. + if (curl.compression) + { + console.warn( + 'TilemapParser.parseTiledJSON - Layer compression is unsupported, skipping layer \'' + + curl.name + '\'' + ); + continue; + } + else if (curl.encoding && curl.encoding === 'base64') + { + curl.data = Base64Decode(curl.data); + delete curl.encoding; // Allow the same map to be parsed multiple times + } + + var layerData = new LayerData({ + name: curl.name, + x: GetFastValue(curl, 'offsetx', 0) + curl.x, + y: GetFastValue(curl, 'offsety', 0) + curl.y, + width: curl.width, + height: curl.height, + tileWidth: json.tilewidth, + tileHeight: json.tileheight, + alpha: curl.opacity, + visible: curl.visible, + properties: GetFastValue(curl, 'properties', {}) + }); + + var x = 0; + var row = []; + var output = []; + + // Loop through the data field in the JSON. + + // This is an array containing the tile indexes, one after the other. -1 = no tile, + // everything else = the tile index (starting at 1 for Tiled, 0 for CSV) If the map + // contains multiple tilesets then the indexes are relative to that which the set starts + // from. Need to set which tileset in the cache = which tileset in the JSON, if you do this + // manually it means you can use the same map data but a new tileset. + + for (var t = 0, len = curl.data.length; t < len; t++) + { + var gidInfo = ParseGID(curl.data[t]); + + // index, x, y, width, height + if (gidInfo.gid > 0) + { + var tile = new Tile(layerData, gidInfo.gid, x, output.length, json.tilewidth, + json.tileheight); + + // Turning Tiled's FlippedHorizontal, FlippedVertical and FlippedAntiDiagonal + // propeties into flipX, flipY and rotation + tile.rotation = gidInfo.rotation; + tile.flipX = gidInfo.flipped; + + row.push(tile); + } + else + { + var blankTile = insertNull + ? null + : new Tile(layerData, -1, x, output.length, json.tilewidth, json.tileheight); + row.push(blankTile); + } + + x++; + + if (x === curl.width) + { + output.push(row); + x = 0; + row = []; + } + } + + layerData.data = output; + + tileLayers.push(layerData); + } + + return tileLayers; +}; + +module.exports = ParseTileLayers; + + +/***/ }), +/* 425 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Tilemaps.Parsers + */ + +module.exports = { + + Parse: __webpack_require__(194), + Parse2DArray: __webpack_require__(116), + ParseCSV: __webpack_require__(193), + + Impact: __webpack_require__(187), + Tiled: __webpack_require__(192) + +}; + + +/***/ }), +/* 426 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var WorldToTileX = __webpack_require__(38); +var WorldToTileY = __webpack_require__(37); +var Vector2 = __webpack_require__(6); + +/** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @function Phaser.Tilemaps.Components.WorldToTileXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Math.Vector2} [point] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Math.Vector2} The XY location in tile units. + */ +var WorldToTileXY = function (worldX, worldY, snapToFloor, point, camera, layer) +{ + if (point === undefined) { point = new Vector2(0, 0); } + + point.x = WorldToTileX(worldX, snapToFloor, camera, layer); + point.y = WorldToTileY(worldY, snapToFloor, camera, layer); + + return point; +}; + +module.exports = WorldToTileXY; + + +/***/ }), +/* 427 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); + +/** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will recieve a new index. New indexes are drawn from the given + * weightedIndexes array. An example weighted array: + * + * [ + * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 + * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 + * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 + * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 + * ] + * + * The probability of any index being choose is (the index's weight) / (sum of all weights). This + * method only modifies tile indexes and does not change collision information. + * + * @function Phaser.Tilemaps.Components.WeightedRandomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during + * randomization. They should be in the form: { index: 0, weight: 4 } or + * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var WeightedRandomize = function (tileX, tileY, width, height, weightedIndexes, layer) +{ + if (weightedIndexes === undefined) { return; } + + var i; + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + var weightTotal = 0; + for (i = 0; i < weightedIndexes.length; i++) + { + weightTotal += weightedIndexes[i].weight; + } + + if (weightTotal <= 0) { return; } + + for (i = 0; i < tiles.length; i++) + { + var rand = Math.random() * weightTotal; + var sum = 0; + var randomIndex = -1; + for (var j = 0; j < weightedIndexes.length; j++) + { + sum += weightedIndexes[j].weight; + if (rand <= sum) + { + var chosen = weightedIndexes[j].index; + randomIndex = Array.isArray(chosen) + ? chosen[Math.floor(Math.random() * chosen.length)] + : chosen; + break; + } + } + + tiles[i].index = randomIndex; + } +}; + +module.exports = WeightedRandomize; + + +/***/ }), +/* 428 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TileToWorldX = __webpack_require__(86); +var TileToWorldY = __webpack_require__(85); +var Vector2 = __webpack_require__(6); + +/** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @function Phaser.Tilemaps.Components.TileToWorldXY + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {Phaser.Math.Vector2} [point] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Math.Vector2} The XY location in world coordinates. + */ +var TileToWorldXY = function (tileX, tileY, point, camera, layer) +{ + if (point === undefined) { point = new Vector2(0, 0); } + + point.x = TileToWorldX(tileX, camera, layer); + point.y = TileToWorldY(tileY, camera, layer); + + return point; +}; + +module.exports = TileToWorldXY; + + +/***/ }), +/* 429 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); + +/** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision + * information. + * + * @function Phaser.Tilemaps.Components.SwapByIndex + * @since 3.0.0 + * + * @param {integer} tileA - First tile index. + * @param {integer} tileB - Second tile index. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SwapByIndex = function (indexA, indexB, tileX, tileY, width, height, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + for (var i = 0; i < tiles.length; i++) + { + if (tiles[i]) + { + if (tiles[i].index === indexA) + { + tiles[i].index = indexB; + } + else if (tiles[i].index === indexB) + { + tiles[i].index = indexA; + } + } + } +}; + +module.exports = SwapByIndex; + + +/***/ }), +/* 430 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); +var ShuffleArray = __webpack_require__(102); + +/** + * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given + * layer. It will only randomize the tiles in that area, so if they're all the same nothing will + * appear to have changed! This method only modifies tile indexes and does not change collision + * information. + * + * @function Phaser.Tilemaps.Components.Shuffle + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var Shuffle = function (tileX, tileY, width, height, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + var indexes = tiles.map(function (tile) { return tile.index; }); + ShuffleArray(indexes); + + for (var i = 0; i < tiles.length; i++) + { + tiles[i].index = indexes[i]; + } +}; + +module.exports = Shuffle; + + +/***/ }), +/* 431 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); + +/** + * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * + * @function Phaser.Tilemaps.Components.SetTileLocationCallback + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetTileLocationCallback = function (tileX, tileY, width, height, callback, callbackContext, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + for (var i = 0; i < tiles.length; i++) + { + tiles[i].setCollisionCallback(callback, callbackContext); + } + +}; + +module.exports = SetTileLocationCallback; + + +/***/ }), +/* 432 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see setTileLocationCallback. + * + * @function Phaser.Tilemaps.Components.SetTileIndexCallback + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a + * collision callback set for. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetTileIndexCallback = function (indexes, callback, callbackContext, layer) +{ + if (typeof indexes === 'number') + { + layer.callbacks[indexes] = (callback !== null) + ? { callback: callback, callbackContext: callbackContext } + : undefined; + } + else + { + for (var i = 0, len = indexes.length; i < len; i++) + { + layer.callbacks[indexes[i]] = (callback !== null) + ? { callback: callback, callbackContext: callbackContext } + : undefined; + } + } +}; + +module.exports = SetTileIndexCallback; + + +/***/ }), +/* 433 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(46); +var CalculateFacesWithin = __webpack_require__(26); + +/** + * Sets collision on the tiles within a layer by checking each tile's collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tile's collision group, the tile's colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * + * @function Phaser.Tilemaps.Components.SetCollisionFromCollisionGroup + * @since 3.0.0 + * + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollisionFromCollisionGroup = function (collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + + if (!tile) { continue; } + + var collisionGroup = tile.getCollisionGroup(); + + // It's possible in Tiled to have a collision group without any shapes, e.g. create a + // shape and then delete the shape. + if (collisionGroup && collisionGroup.objects && collisionGroup.objects.length > 0) + { + SetTileCollision(tile, collides); + } + } + } + + if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } +}; + +module.exports = SetCollisionFromCollisionGroup; + + +/***/ }), +/* 434 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(46); +var CalculateFacesWithin = __webpack_require__(26); +var HasValue = __webpack_require__(70); + +/** + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. + * + * @function Phaser.Tilemaps.Components.SetCollisionByProperty + * @since 3.0.0 + * + * @param {object} properties - An object with tile properties and corresponding values that should + * be checked. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollisionByProperty = function (properties, collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + + if (!tile) { continue; } + + for (var property in properties) + { + if (!HasValue(tile.properties, property)) { continue; } + + var values = properties[property]; + if (!Array.isArray(values)) + { + values = [ values ]; + } + + for (var i = 0; i < values.length; i++) + { + if (tile.properties[property] === values[i]) + { + SetTileCollision(tile, collides); + } + } + } + } + } + + if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } +}; + +module.exports = SetCollisionByProperty; + + +/***/ }), +/* 435 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(46); +var CalculateFacesWithin = __webpack_require__(26); +var SetLayerCollisionIndex = __webpack_require__(117); + +/** + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). + * + * @function Phaser.Tilemaps.Components.SetCollisionByExclusion + * @since 3.0.0 + * + * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollisionByExclusion = function (indexes, collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + if (!Array.isArray(indexes)) { indexes = [ indexes ]; } + + // Note: this only updates layer.collideIndexes for tile indexes found currently in the layer + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + if (tile && indexes.indexOf(tile.index) === -1) + { + SetTileCollision(tile, collides); + SetLayerCollisionIndex(tile.index, collides, layer); + } + } + } + + if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } +}; + +module.exports = SetCollisionByExclusion; + + +/***/ }), +/* 436 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(46); +var CalculateFacesWithin = __webpack_require__(26); +var SetLayerCollisionIndex = __webpack_require__(117); + +/** + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * + * @function Phaser.Tilemaps.Components.SetCollisionBetween + * @since 3.0.0 + * + * @param {integer} start - The first index of the tile to be set for collision. + * @param {integer} stop - The last index of the tile to be set for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollisionBetween = function (start, stop, collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + if (start > stop) { return; } + + // Update the array of colliding indexes + for (var index = start; index <= stop; index++) + { + SetLayerCollisionIndex(index, collides, layer); + } + + // Update the tiles + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + if (tile) + { + if (tile.index >= start && tile.index <= stop) + { + SetTileCollision(tile, collides); + } + } + } + } + + if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } +}; + +module.exports = SetCollisionBetween; + + +/***/ }), +/* 437 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(46); +var CalculateFacesWithin = __webpack_require__(26); +var SetLayerCollisionIndex = __webpack_require__(117); + +/** + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * + * @function Phaser.Tilemaps.Components.SetCollision + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollision = function (indexes, collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + if (!Array.isArray(indexes)) { indexes = [ indexes ]; } + + // Update the array of colliding indexes + for (var i = 0; i < indexes.length; i++) + { + SetLayerCollisionIndex(indexes[i], collides, layer); + } + + // Update the tiles + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + + if (tile && indexes.indexOf(tile.index) !== -1) + { + SetTileCollision(tile, collides); + } + } + } + + if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } +}; + +module.exports = SetCollision; + + +/***/ }), +/* 438 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); +var Color = __webpack_require__(312); + +/** + * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * + * @function Phaser.Tilemaps.Components.RenderDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. + * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. + * @param {?Phaser.Display.Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at + * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. + * @param {?Phaser.Display.Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled + * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. + * @param {?Phaser.Display.Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting + * tile faces. If set to null, interesting tile faces will not be drawn. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var RenderDebug = function (graphics, styleConfig, layer) +{ + if (styleConfig === undefined) { styleConfig = {}; } + + // Default colors without needlessly creating Color objects + var tileColor = styleConfig.tileColor !== undefined + ? styleConfig.tileColor + : new Color(105, 210, 231, 150); + var collidingTileColor = styleConfig.collidingTileColor !== undefined + ? styleConfig.collidingTileColor + : new Color(243, 134, 48, 200); + var faceColor = styleConfig.faceColor !== undefined + ? styleConfig.faceColor + : new Color(40, 39, 37, 150); + + var tiles = GetTilesWithin(0, 0, layer.width, layer.height, null, layer); + + for (var i = 0; i < tiles.length; i++) + { + var tile = tiles[i]; + + var tw = tile.width; + var th = tile.height; + var x = tile.pixelX; + var y = tile.pixelY; + + var color = tile.collides ? collidingTileColor : tileColor; + if (color !== null) + { + graphics.fillStyle(color.color, color.alpha / 255); + graphics.fillRect(x, y, tw, th); + } + + // Inset the face line to prevent neighboring tile's lines from overlapping + x += 1; + y += 1; + tw -= 2; + th -= 2; + + if (faceColor !== null) + { + graphics.lineStyle(1, faceColor.color, faceColor.alpha / 255); + if (tile.faceTop) { graphics.lineBetween(x, y, x + tw, y); } + if (tile.faceRight) { graphics.lineBetween(x + tw, y, x + tw, y + th); } + if (tile.faceBottom) { graphics.lineBetween(x, y + th, x + tw, y + th); } + if (tile.faceLeft) { graphics.lineBetween(x, y, x, y + th); } + } + } +}; + +module.exports = RenderDebug; + + +/***/ }), +/* 439 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RemoveTileAt = __webpack_require__(195); +var WorldToTileX = __webpack_require__(38); +var WorldToTileY = __webpack_require__(37); + +/** + * Removes the tile at the given world coordinates in the specified layer and updates the layer's + * collision information. + * + * @function Phaser.Tilemaps.Components.RemoveTileAtWorldXY + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified + * location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The Tile object that was removed. + */ +var RemoveTileAtWorldXY = function (worldX, worldY, replaceWithNull, recalculateFaces, camera, layer) +{ + var tileX = WorldToTileX(worldX, true, camera, layer); + var tileY = WorldToTileY(worldY, true, camera, layer); + return RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, layer); +}; + +module.exports = RemoveTileAtWorldXY; + + +/***/ }), +/* 440 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); +var GetRandomElement = __webpack_require__(132); + +/** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then + * those will be used for randomly assigning new tile indexes. If an array is not provided, the + * indexes found within the region (excluding -1) will be used for randomly assigning new tile + * indexes. This method only modifies tile indexes and does not change collision information. + * + * @function Phaser.Tilemaps.Components.Randomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var Randomize = function (tileX, tileY, width, height, indexes, layer) +{ + var i; + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + // If no indicies are given, then find all the unique indexes within the specified region + if (indexes === undefined) + { + indexes = []; + for (i = 0; i < tiles.length; i++) + { + if (indexes.indexOf(tiles[i].index) === -1) + { + indexes.push(tiles[i].index); + } + } + } + + for (i = 0; i < tiles.length; i++) + { + tiles[i].index = GetRandomElement(indexes); + } +}; + +module.exports = Randomize; + + +/***/ }), +/* 441 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CalculateFacesWithin = __webpack_require__(26); +var PutTileAt = __webpack_require__(118); + +/** + * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified + * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, + * all attributes will be copied over to the specified location. If you pass in an index, only the + * index at the specified location will be changed. Collision information will be recalculated + * within the region tiles were changed. + * + * @function Phaser.Tilemaps.Components.PutTilesAt + * @since 3.0.0 + * + * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles + * or tile indexes to place. + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var PutTilesAt = function (tilesArray, tileX, tileY, recalculateFaces, layer) +{ + if (!Array.isArray(tilesArray)) { return null; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + // Force the input array to be a 2D array + if (!Array.isArray(tilesArray[0])) + { + tilesArray = [ tilesArray ]; + } + + var height = tilesArray.length; + var width = tilesArray[0].length; + + for (var ty = 0; ty < height; ty++) + { + for (var tx = 0; tx < width; tx++) + { + var tile = tilesArray[ty][tx]; + PutTileAt(tile, tileX + tx, tileY + ty, false, layer); + } + } + + if (recalculateFaces) + { + // Recalculate the faces within the destination area and neighboring tiles + CalculateFacesWithin(tileX - 1, tileY - 1, width + 2, height + 2, layer); + } +}; + +module.exports = PutTilesAt; + + + +/***/ }), +/* 442 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PutTileAt = __webpack_require__(118); +var WorldToTileX = __webpack_require__(38); +var WorldToTileY = __webpack_require__(37); + +/** + * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either + * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the + * specified location. If you pass in an index, only the index at the specified location will be + * changed. Collision information will be recalculated at the specified location. + * + * @function Phaser.Tilemaps.Components.PutTileAtWorldXY + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} worldX - [description] + * @param {integer} worldY - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map. + */ +var PutTileAtWorldXY = function (tile, worldX, worldY, recalculateFaces, camera, layer) +{ + var tileX = WorldToTileX(worldX, true, camera, layer); + var tileY = WorldToTileY(worldY, true, camera, layer); + return PutTileAt(tile, tileX, tileY, recalculateFaces, layer); +}; + +module.exports = PutTileAtWorldXY; + + +/***/ }), +/* 443 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var HasTileAt = __webpack_require__(196); +var WorldToTileX = __webpack_require__(38); +var WorldToTileY = __webpack_require__(37); + +/** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @function Phaser.Tilemaps.Components.HasTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {boolean} + */ +var HasTileAtWorldXY = function (worldX, worldY, camera, layer) +{ + var tileX = WorldToTileX(worldX, true, camera, layer); + var tileY = WorldToTileY(worldY, true, camera, layer); + + return HasTileAt(tileX, tileY, layer); +}; + +module.exports = HasTileAtWorldXY; + + +/***/ }), +/* 444 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); +var WorldToTileX = __webpack_require__(38); +var WorldToTileY = __webpack_require__(37); + +/** + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * + * @function Phaser.Tilemaps.Components.GetTilesWithinWorldXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. + */ +var GetTilesWithinWorldXY = function (worldX, worldY, width, height, filteringOptions, camera, layer) +{ + // Top left corner of the rect, rounded down to include partial tiles + var xStart = WorldToTileX(worldX, true, camera, layer); + var yStart = WorldToTileY(worldY, true, camera, layer); + + // Bottom right corner of the rect, rounded up to include partial tiles + var xEnd = Math.ceil(WorldToTileX(worldX + width, false, camera, layer)); + var yEnd = Math.ceil(WorldToTileY(worldY + height, false, camera, layer)); + + return GetTilesWithin(xStart, yStart, xEnd - xStart, yEnd - yStart, filteringOptions, layer); +}; + +module.exports = GetTilesWithinWorldXY; + + +/***/ }), +/* 445 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Geom = __webpack_require__(245); +var GetTilesWithin = __webpack_require__(14); +var Intersects = __webpack_require__(244); +var NOOP = __webpack_require__(3); +var TileToWorldX = __webpack_require__(86); +var TileToWorldY = __webpack_require__(85); +var WorldToTileX = __webpack_require__(38); +var WorldToTileY = __webpack_require__(37); + +var TriangleToRectangle = function (triangle, rect) +{ + return Intersects.RectangleToTriangle(rect, triangle); +}; + +// Note: Could possibly be optimized by copying the shape and shifting it into tilemapLayer +// coordinates instead of shifting the tiles. + +/** + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * + * @function Phaser.Tilemaps.Components.GetTilesWithinShape + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. + */ +var GetTilesWithinShape = function (shape, filteringOptions, camera, layer) +{ + if (shape === undefined) { return []; } + + // intersectTest is a function with parameters: shape, rect + var intersectTest = NOOP; + if (shape instanceof Geom.Circle) { intersectTest = Intersects.CircleToRectangle; } + else if (shape instanceof Geom.Rectangle) { intersectTest = Intersects.RectangleToRectangle; } + else if (shape instanceof Geom.Triangle) { intersectTest = TriangleToRectangle; } + else if (shape instanceof Geom.Line) { intersectTest = Intersects.LineToRectangle; } + + // Top left corner of the shapes's bounding box, rounded down to include partial tiles + var xStart = WorldToTileX(shape.left, true, camera, layer); + var yStart = WorldToTileY(shape.top, true, camera, layer); + + // Bottom right corner of the shapes's bounding box, rounded up to include partial tiles + var xEnd = Math.ceil(WorldToTileX(shape.right, false, camera, layer)); + var yEnd = Math.ceil(WorldToTileY(shape.bottom, false, camera, layer)); + + // Tiles within bounding rectangle of shape. Bounds are forced to be at least 1 x 1 tile in size + // to grab tiles for shapes that don't have a height or width (e.g. a horizontal line). + var width = Math.max(xEnd - xStart, 1); + var height = Math.max(yEnd - yStart, 1); + var tiles = GetTilesWithin(xStart, yStart, width, height, filteringOptions, layer); + + var tileWidth = layer.tileWidth; + var tileHeight = layer.tileHeight; + if (layer.tilemapLayer) + { + tileWidth *= layer.tilemapLayer.scaleX; + tileHeight *= layer.tilemapLayer.scaleY; + } + + var results = []; + var tileRect = new Geom.Rectangle(0, 0, tileWidth, tileHeight); + for (var i = 0; i < tiles.length; i++) + { + var tile = tiles[i]; + tileRect.x = TileToWorldX(tile.x, camera, layer); + tileRect.y = TileToWorldY(tile.y, camera, layer); + if (intersectTest(shape, tileRect)) + { + results.push(tile); + } + } + + return results; +}; + +module.exports = GetTilesWithinShape; + + +/***/ }), +/* 446 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTileAt = __webpack_require__(87); +var WorldToTileX = __webpack_require__(38); +var WorldToTileY = __webpack_require__(37); + +/** + * Gets a tile at the given world coordinates from the given layer. + * + * @function Phaser.Tilemaps.Components.GetTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - X position to get the tile from (given in pixels) + * @param {number} worldY - Y position to get the tile from (given in pixels) + * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile + * object with an index of -1. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates + * were invalid. + */ +var GetTileAtWorldXY = function (worldX, worldY, nonNull, camera, layer) +{ + var tileX = WorldToTileX(worldX, true, camera, layer); + var tileY = WorldToTileY(worldY, true, camera, layer); + + return GetTileAt(tileX, tileY, nonNull, layer); +}; + +module.exports = GetTileAtWorldXY; + + +/***/ }), +/* 447 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); + +/** + * @callback EachTileCallback + * + * @param {Phaser.Tilemaps.Tile} value - [description] + * @param {number} index - [description] + * @param {Phaser.Tilemaps.Tile[]} array - [description] + */ + +/** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * + * @function Phaser.Tilemaps.Components.ForEachTile + * @since 3.0.0 + * + * @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var ForEachTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); + tiles.forEach(callback, context); +}; + +module.exports = ForEachTile; + + +/***/ }), +/* 448 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); + +/** + * @callback FindTileCallback + * + * @param {Phaser.Tilemaps.Tile} value - [description] + * @param {number} index - [description] + * @param {Phaser.Tilemaps.Tile[]} array - [description] + * + * @return {boolean} [description] + */ + +/** + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * + * @function Phaser.Tilemaps.Components.FindTile + * @since 3.0.0 + * + * @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {?Phaser.Tilemaps.Tile} A Tile that matches the search, or null if no Tile found + */ +var FindTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); + return tiles.find(callback, context) || null; +}; + +module.exports = FindTile; + + +/***/ }), +/* 449 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * + * @function Phaser.Tilemaps.Components.FindByIndex + * @since 3.0.0 + * + * @param {integer} index - The tile index value to search for. + * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. + * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the + * bottom-right. Otherwise it scans from the top-left. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {?Phaser.Tilemaps.Tile} The first (or n skipped) tile with the matching index. + */ +var FindByIndex = function (findIndex, skip, reverse, layer) +{ + if (skip === undefined) { skip = 0; } + if (reverse === undefined) { reverse = false; } + + var count = 0; + var tx; + var ty; + var tile; + + if (reverse) + { + for (ty = layer.height - 1; ty >= 0; ty--) + { + for (tx = layer.width - 1; tx >= 0; tx--) + { + tile = layer.data[ty][tx]; + if (tile && tile.index === findIndex) + { + if (count === skip) + { + return tile; + } + else + { + count += 1; + } + } + } + } + } + else + { + for (ty = 0; ty < layer.height; ty++) + { + for (tx = 0; tx < layer.width; tx++) + { + tile = layer.data[ty][tx]; + if (tile && tile.index === findIndex) + { + if (count === skip) + { + return tile; + } + else + { + count += 1; + } + } + } + } + } + + return null; +}; + +module.exports = FindByIndex; + + +/***/ }), +/* 450 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); + +/** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * + * @function Phaser.Tilemaps.Components.FilterTiles + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile[]} The filtered array of Tiles. + */ +var FilterTiles = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); + return tiles.filter(callback, context); +}; + +module.exports = FilterTiles; + + + +/***/ }), +/* 451 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); +var CalculateFacesWithin = __webpack_require__(26); +var SetTileCollision = __webpack_require__(46); + +/** + * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the + * specified index. Tiles will be set to collide if the given index is a colliding index. + * Collision information in the region will be recalculated. + * + * @function Phaser.Tilemaps.Components.Fill + * @since 3.0.0 + * + * @param {integer} index - [description] + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var Fill = function (index, tileX, tileY, width, height, recalculateFaces, layer) +{ + if (recalculateFaces === undefined) { recalculateFaces = true; } + + var doesIndexCollide = (layer.collideIndexes.indexOf(index) !== -1); + + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + for (var i = 0; i < tiles.length; i++) + { + tiles[i].index = index; + + SetTileCollision(tiles[i], doesIndexCollide); + } + + if (recalculateFaces) + { + // Recalculate the faces within the area and neighboring tiles + CalculateFacesWithin(tileX - 1, tileY - 1, width + 2, height + 2, layer); + } +}; + +module.exports = Fill; + + +/***/ }), +/* 452 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the tiles in the given layer that are within the camera's viewport. This is used + * internally. + * + * @function Phaser.Tilemaps.Components.CullTiles + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. + * @param {array} [outputArray] - [description] + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ +var CullTiles = function (layer, camera, outputArray) +{ + if (outputArray === undefined) { outputArray = []; } + + outputArray.length = 0; + + var tilemapLayer = layer.tilemapLayer; + var mapData = layer.data; + var mapWidth = layer.width; + var mapHeight = layer.height; + var left = (camera.scrollX * camera.zoom * tilemapLayer.scrollFactorX) - tilemapLayer.x; + var top = (camera.scrollY * camera.zoom * tilemapLayer.scrollFactorY) - tilemapLayer.y; + var sx = tilemapLayer.scaleX; + var sy = tilemapLayer.scaleY; + var tileWidth = layer.tileWidth * sx; + var tileHeight = layer.tileHeight * sy; + + for (var row = 0; row < mapHeight; ++row) + { + for (var col = 0; col < mapWidth; ++col) + { + var tile = mapData[row][col]; + + if (tile === null || tile.index === -1) { continue; } + + var tileX = tile.pixelX * sx - left; + var tileY = tile.pixelY * sy - top; + var cullW = camera.width + tileWidth; + var cullH = camera.height + tileHeight; + + if (tile.visible && + tileX > -tileWidth && tileY > -tileHeight && + tileX < cullW && tileY < cullH) + { + outputArray.push(tile); + } + } + } + + return outputArray; +}; + +module.exports = CullTiles; + + +/***/ }), +/* 453 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TileToWorldX = __webpack_require__(86); +var TileToWorldY = __webpack_require__(85); +var GetTilesWithin = __webpack_require__(14); +var ReplaceByIndex = __webpack_require__(197); + +/** + * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. + * + * @function Phaser.Tilemaps.Components.CreateFromTiles + * @since 3.0.0 + * + * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. + * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted + * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a + * one-to-one mapping with the indexes array. + * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. + * scene.make.sprite). + * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. + */ +var CreateFromTiles = function (indexes, replacements, spriteConfig, scene, camera, layer) +{ + if (spriteConfig === undefined) { spriteConfig = {}; } + + if (!Array.isArray(indexes)) { indexes = [ indexes ]; } + + var tilemapLayer = layer.tilemapLayer; + if (scene === undefined) { scene = tilemapLayer.scene; } + if (camera === undefined) { camera = scene.cameras.main; } + + var tiles = GetTilesWithin(0, 0, layer.width, layer.height, null, layer); + var sprites = []; + var i; + + for (i = 0; i < tiles.length; i++) + { + var tile = tiles[i]; + + if (indexes.indexOf(tile.index) !== -1) + { + spriteConfig.x = TileToWorldX(tile.x, camera, layer); + spriteConfig.y = TileToWorldY(tile.y, camera, layer); + + var sprite = scene.make.sprite(spriteConfig); + sprites.push(sprite); + } + } + + if (typeof replacements === 'number') + { + // Assume 1 replacement for all types of tile given + for (i = 0; i < indexes.length; i++) + { + ReplaceByIndex(indexes[i], replacements, 0, 0, layer.width, layer.height, layer); + } + } + else if (Array.isArray(replacements)) + { + // Assume 1 to 1 mapping with indexes array + for (i = 0; i < indexes.length; i++) + { + ReplaceByIndex(indexes[i], replacements[i], 0, 0, layer.width, layer.height, layer); + } + } + + return sprites; +}; + +module.exports = CreateFromTiles; + + +/***/ }), +/* 454 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(14); +var CalculateFacesWithin = __webpack_require__(26); + +/** + * Copies the tiles in the source rectangular area to a new destination (all specified in tile + * coordinates) within the layer. This copies all tile properties & recalculates collision + * information in the destination region. + * + * @function Phaser.Tilemaps.Components.Copy + * @since 3.0.0 + * + * @param {integer} srcTileX - [description] + * @param {integer} srcTileY - [description] + * @param {integer} width - [description] + * @param {integer} height - [description] + * @param {integer} destTileX - [description] + * @param {integer} destTileY - [description] + * @param {boolean} [recalculateFaces=true] - [description] + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var Copy = function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer) +{ + if (srcTileX < 0) { srcTileX = 0; } + if (srcTileY < 0) { srcTileY = 0; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + var srcTiles = GetTilesWithin(srcTileX, srcTileY, width, height, null, layer); + + var offsetX = destTileX - srcTileX; + var offsetY = destTileY - srcTileY; + + for (var i = 0; i < srcTiles.length; i++) + { + var tileX = srcTiles[i].x + offsetX; + var tileY = srcTiles[i].y + offsetY; + if (tileX >= 0 && tileX < layer.width && tileY >= 0 && tileY < layer.height) + { + if (layer.data[tileY][tileX]) + { + layer.data[tileY][tileX].copy(srcTiles[i]); + } + } + } + + if (recalculateFaces) + { + // Recalculate the faces within the destination area and neighboring tiles + CalculateFacesWithin(destTileX - 1, destTileY - 1, width + 2, height + 2, layer); + } +}; + +module.exports = Copy; + + +/***/ }), +/* 455 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Tilemaps + */ + +module.exports = { + + Components: __webpack_require__(88), + Parsers: __webpack_require__(425), + + Formats: __webpack_require__(24), + ImageCollection: __webpack_require__(190), + ParseToTilemap: __webpack_require__(115), + Tile: __webpack_require__(45), + Tilemap: __webpack_require__(186), + TilemapCreator: __webpack_require__(408), + TilemapFactory: __webpack_require__(407), + Tileset: __webpack_require__(84), + + LayerData: __webpack_require__(66), + MapData: __webpack_require__(65), + ObjectLayer: __webpack_require__(188), + + DynamicTilemapLayer: __webpack_require__(185), + StaticTilemapLayer: __webpack_require__(184) + +}; + + +/***/ }), +/* 456 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = { + + /** + * Linear filter type. + * + * @name Phaser.Textures.LINEAR + * @type {integer} + * @since 3.0.0 + */ + LINEAR: 0, + + /** + * Nearest neighbor filter type. + * + * @name Phaser.Textures.NEAREST + * @type {integer} + * @since 3.0.0 + */ + NEAREST: 1 + +}; + +module.exports = CONST; + + +/***/ }), +/* 457 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(456); +var Extend = __webpack_require__(18); + +/** + * @namespace Phaser.Textures + */ + +var Textures = { + + Parsers: __webpack_require__(275), + + Frame: __webpack_require__(141), + Texture: __webpack_require__(274), + TextureManager: __webpack_require__(276), + TextureSource: __webpack_require__(273) + +}; + +// Merge in the consts +Textures = Extend(false, Textures, CONST); + +module.exports = Textures; + + +/***/ }), +/* 458 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Structs + */ + +module.exports = { + + List: __webpack_require__(97), + Map: __webpack_require__(159), + ProcessQueue: __webpack_require__(205), + RTree: __webpack_require__(204), + Set: __webpack_require__(63) + +}; + + +/***/ }), +/* 459 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Sound + * + * @author Pavle Goloskokovic (http://prunegames.com) + */ + +/** + * Config object containing various sound settings. + * + * @typedef {object} SoundConfig + * + * @property {boolean} [mute=false] - Boolean indicating whether the sound should be muted or not. + * @property {number} [volume=1] - A value between 0 (silence) and 1 (full volume). + * @property {number} [rate=1] - Defines the speed at which the sound should be played. + * @property {number} [detune=0] - Represents detuning of sound in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * @property {number} [seek=0] - Position of playback for this sound, in seconds. + * @property {boolean} [loop=false] - Whether or not the sound or current sound marker should loop. + * @property {number} [delay=0] - Time, in seconds, that should elapse before the sound actually starts its playback. + */ + +/** + * Marked section of a sound represented by name, and optionally start time, duration, and config object. + * + * @typedef {object} SoundMarker + * + * @property {string} name - Unique identifier of a sound marker. + * @property {number} [start=0] - Sound position offset at witch playback should start. + * @property {number} [duration] - Playback duration of this marker. + * @property {SoundConfig} [config] - An optional config object containing default marker settings. + */ + +module.exports = { + + SoundManagerCreator: __webpack_require__(283), + + BaseSound: __webpack_require__(98), + BaseSoundManager: __webpack_require__(99), + + WebAudioSound: __webpack_require__(277), + WebAudioSoundManager: __webpack_require__(278), + + HTML5AudioSound: __webpack_require__(281), + HTML5AudioSoundManager: __webpack_require__(282), + + NoAudioSound: __webpack_require__(279), + NoAudioSoundManager: __webpack_require__(280) + +}; + + +/***/ }), +/* 460 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(75); +var PluginManager = __webpack_require__(12); + +/** + * @classdesc + * A proxy class to the Global Scene Manager. + * + * @class ScenePlugin + * @memberOf Phaser.Scenes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ +var ScenePlugin = new Class({ + + initialize: + + function ScenePlugin (scene) + { + /** + * [description] + * + * @name Phaser.Scenes.ScenePlugin#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Scenes.ScenePlugin#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + if (!scene.sys.settings.isBooted) + { + scene.sys.events.once('boot', this.boot, this); + } + + /** + * [description] + * + * @name Phaser.Scenes.ScenePlugin#settings + * @type {SettingsObject} + * @since 3.0.0 + */ + this.settings = scene.sys.settings; + + /** + * [description] + * + * @name Phaser.Scenes.ScenePlugin#key + * @type {string} + * @since 3.0.0 + */ + this.key = scene.sys.settings.key; + + /** + * [description] + * + * @name Phaser.Scenes.ScenePlugin#manager + * @type {Phaser.Scenes.SceneManager} + * @since 3.0.0 + */ + this.manager = scene.sys.game.scene; + }, + + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#boot + * @since 3.0.0 + */ + boot: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); + }, + + /** + * Shutdown this Scene and run the given one. + * + * @method Phaser.Scenes.ScenePlugin#start + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {object} [data] - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + start: function (key, data) + { + if (key === undefined) { key = this.key; } + + if (this.settings.status !== CONST.RUNNING) + { + this.manager.queueOp('stop', this.key); + this.manager.queueOp('start', key, data); + } + else + { + this.manager.stop(this.key); + this.manager.start(key, data); + } + + return this; + }, + + /** + * Add the Scene into the Scene Manager and start it if 'autoStart' is true or the Scene config 'active' property is set. + * + * @method Phaser.Scenes.ScenePlugin#add + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {object} sceneConfig - [description] + * @param {boolean} autoStart - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + add: function (key, sceneConfig, autoStart) + { + this.manager.add(key, sceneConfig, autoStart); + + return this; + }, + + /** + * Launch the given Scene and run it in parallel with this one. + * + * @method Phaser.Scenes.ScenePlugin#launch + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {object} [data] - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + launch: function (key, data) + { + if (key && key !== this.key) + { + if (this.settings.status !== CONST.RUNNING) + { + this.manager.queueOp('start', key, data); + } + else + { + this.manager.start(key, data); + } + } + + return this; + }, + + /** + * Pause the Scene - this stops the update step from happening but it still renders. + * + * @method Phaser.Scenes.ScenePlugin#pause + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + pause: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.pause(key); + + return this; + }, + + /** + * Resume the Scene - starts the update loop again. + * + * @method Phaser.Scenes.ScenePlugin#resume + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + resume: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.resume(key); + + return this; + }, + + /** + * Makes the Scene sleep (no update, no render) but doesn't shutdown. + * + * @method Phaser.Scenes.ScenePlugin#sleep + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + sleep: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.sleep(key); + + return this; + }, + + /** + * Makes the Scene wake-up (starts update and render) + * + * @method Phaser.Scenes.ScenePlugin#wake + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + wake: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.wake(key); + + return this; + }, + + /** + * Makes this Scene sleep then starts the Scene given. + * + * @method Phaser.Scenes.ScenePlugin#switch + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + switch: function (key) + { + if (key !== this.key) + { + if (this.settings.status !== CONST.RUNNING) + { + this.manager.queueOp('switch', this.key, key); + } + else + { + this.manager.switch(this.key, key); + } + } + + return this; + }, + + /** + * Shutdown the Scene, clearing display list, timers, etc. + * + * @method Phaser.Scenes.ScenePlugin#stop + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + stop: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.stop(key); + + return this; + }, + + /** + * Sets the active state of the given Scene. + * + * @method Phaser.Scenes.ScenePlugin#setActive + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + setActive: function (value) + { + this.settings.active = value; + + return this; + }, + + /** + * Sets the visible state of the given Scene. + * + * @method Phaser.Scenes.ScenePlugin#setVisible + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + setVisible: function (value) + { + this.settings.visible = value; + + return this; + }, + + /** + * Checks if the given Scene is sleeping or not? + * + * @method Phaser.Scenes.ScenePlugin#isSleeping + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {boolean} [description] + */ + isSleeping: function (key) + { + if (key === undefined) { key = this.key; } + + return this.manager.isSleeping(key); + }, + + /** + * Checks if the given Scene is active or not? + * + * @method Phaser.Scenes.ScenePlugin#isActive + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {boolean} [description] + */ + isActive: function (key) + { + if (key === undefined) { key = this.key; } + + return this.manager.isActive(key); + }, + + /** + * Checks if the given Scene is visible or not? + * + * @method Phaser.Scenes.ScenePlugin#isVisible + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {boolean} [description] + */ + isVisible: function (key) + { + if (key === undefined) { key = this.key; } + + return this.manager.isVisible(key); + }, + + /** + * Swaps the position of two scenes in the Scenes list. + * This controls the order in which they are rendered and updated. + * + * @method Phaser.Scenes.ScenePlugin#swapPosition + * @since 3.2.0 + * + * @param {string} keyA - The first Scene to swap. + * @param {string} [keyB] - The second Scene to swap. If none is given it defaults to this Scene. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + swapPosition: function (keyA, keyB) + { + if (keyB === undefined) { keyB = this.key; } + + if (keyA !== keyB) + { + this.manager.swapPosition(keyA, keyB); + } + + return this; + }, + + /** + * Swaps the position of two scenes in the Scenes list, so that Scene B is directly above Scene A. + * This controls the order in which they are rendered and updated. + * + * @method Phaser.Scenes.ScenePlugin#moveAbove + * @since 3.2.0 + * + * @param {string} keyA - The Scene that Scene B will be moved to be above. + * @param {string} [keyB] - The Scene to be moved. If none is given it defaults to this Scene. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + moveAbove: function (keyA, keyB) + { + if (keyB === undefined) { keyB = this.key; } + + if (keyA !== keyB) + { + this.manager.moveAbove(keyA, keyB); + } + + return this; + }, + + /** + * Swaps the position of two scenes in the Scenes list, so that Scene B is directly below Scene A. + * This controls the order in which they are rendered and updated. + * + * @method Phaser.Scenes.ScenePlugin#moveBelow + * @since 3.2.0 + * + * @param {string} keyA - The Scene that Scene B will be moved to be below. + * @param {string} [keyB] - The Scene to be moved. If none is given it defaults to this Scene. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + moveBelow: function (keyA, keyB) + { + if (keyB === undefined) { keyB = this.key; } + + if (keyA !== keyB) + { + this.manager.moveBelow(keyA, keyB); + } + + return this; + }, + + /** + * Removes a Scene from the SceneManager. + * + * The Scene is removed from the local scenes array, it's key is cleared from the keys + * cache and Scene.Systems.destroy is then called on it. + * + * If the SceneManager is processing the Scenes when this method is called it wil + * queue the operation for the next update sequence. + * + * @method Phaser.Scenes.ScenePlugin#remove + * @since 3.2.0 + * + * @param {(string|Phaser.Scene)} scene - The Scene to be removed. + * + * @return {Phaser.Scenes.SceneManager} This SceneManager. + */ + remove: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.remove(key); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#moveUp + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + moveUp: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.moveUp(key); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#moveDown + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + moveDown: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.moveDown(key); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#bringToTop + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + bringToTop: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.bringToTop(key); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#sendToBack + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + sendToBack: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.sendToBack(key); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#get + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scene} [description] + */ + get: function (key) + { + return this.manager.getScene(key); + }, + + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + // TODO + }, + + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#destroy + * @since 3.0.0 + */ + destroy: function () + { + // TODO + } + +}); + +PluginManager.register('ScenePlugin', ScenePlugin, 'scenePlugin'); + +module.exports = ScenePlugin; + + +/***/ }), +/* 461 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(75); +var Extend = __webpack_require__(18); + +/** + * @namespace Phaser.Scenes + */ + +var Scene = { + + SceneManager: __webpack_require__(287), + ScenePlugin: __webpack_require__(460), + Settings: __webpack_require__(284), + Systems: __webpack_require__(142) + +}; + +// Merge in the consts +Scene = Extend(false, Scene, CONST); + +module.exports = Scene; + + +/***/ }), +/* 462 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.World` module contains methods for creating and manipulating the world composite. +* A `Matter.World` is a `Matter.Composite` body, which is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`. +* A `Matter.World` has a few additional properties including `gravity` and `bounds`. +* It is important to use the functions in the `Matter.Composite` module to modify the world composite, rather than directly modifying its properties. +* There are also a few methods here that alias those in `Matter.Composite` for easier readability. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class World +* @extends Composite +*/ + +var World = {}; + +module.exports = World; + +var Composite = __webpack_require__(120); +var Constraint = __webpack_require__(170); +var Common = __webpack_require__(39); + +(function() { + + /** + * Creates a new world composite. The options parameter is an object that specifies any properties you wish to override the defaults. + * See the properties section below for detailed information on what you can pass via the `options` object. + * @method create + * @constructor + * @param {} options + * @return {world} A new world + */ + World.create = function(options) { + var composite = Composite.create(); + + var defaults = { + label: 'World', + gravity: { + x: 0, + y: 1, + scale: 0.001 + }, + bounds: { + min: { x: -Infinity, y: -Infinity }, + max: { x: Infinity, y: Infinity } + } + }; + + return Common.extend(composite, defaults, options); + }; + + /* + * + * Properties Documentation + * + */ + + /** + * The gravity to apply on the world. + * + * @property gravity + * @type object + */ + + /** + * The gravity x component. + * + * @property gravity.x + * @type object + * @default 0 + */ + + /** + * The gravity y component. + * + * @property gravity.y + * @type object + * @default 1 + */ + + /** + * The gravity scale factor. + * + * @property gravity.scale + * @type object + * @default 0.001 + */ + + /** + * A `Bounds` object that defines the world bounds for collision detection. + * + * @property bounds + * @type bounds + * @default { min: { x: -Infinity, y: -Infinity }, max: { x: Infinity, y: Infinity } } + */ + + // World is a Composite body + // see src/module/Outro.js for these aliases: + + /** + * An alias for Composite.clear + * @method clear + * @param {world} world + * @param {boolean} keepStatic + */ + + /** + * An alias for Composite.add + * @method addComposite + * @param {world} world + * @param {composite} composite + * @return {world} The original world with the objects from composite added + */ + + /** + * An alias for Composite.addBody + * @method addBody + * @param {world} world + * @param {body} body + * @return {world} The original world with the body added + */ + + /** + * An alias for Composite.addConstraint + * @method addConstraint + * @param {world} world + * @param {constraint} constraint + * @return {world} The original world with the constraint added + */ + +})(); + + +/***/ }), +/* 463 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Plugin` module contains functions for registering and installing plugins on modules. +* +* @class Plugin +*/ + +var Plugin = {}; + +module.exports = Plugin; + +var Common = __webpack_require__(39); + +(function() { + + Plugin._registry = {}; + + /** + * Registers a plugin object so it can be resolved later by name. + * @method register + * @param plugin {} The plugin to register. + * @return {object} The plugin. + */ + Plugin.register = function(plugin) { + if (!Plugin.isPlugin(plugin)) { + Common.warn('Plugin.register:', Plugin.toString(plugin), 'does not implement all required fields.'); + } + + if (plugin.name in Plugin._registry) { + var registered = Plugin._registry[plugin.name], + pluginVersion = Plugin.versionParse(plugin.version).number, + registeredVersion = Plugin.versionParse(registered.version).number; + + if (pluginVersion > registeredVersion) { + Common.warn('Plugin.register:', Plugin.toString(registered), 'was upgraded to', Plugin.toString(plugin)); + Plugin._registry[plugin.name] = plugin; + } else if (pluginVersion < registeredVersion) { + Common.warn('Plugin.register:', Plugin.toString(registered), 'can not be downgraded to', Plugin.toString(plugin)); + } else if (plugin !== registered) { + Common.warn('Plugin.register:', Plugin.toString(plugin), 'is already registered to different plugin object'); + } + } else { + Plugin._registry[plugin.name] = plugin; + } + + return plugin; + }; + + /** + * Resolves a dependency to a plugin object from the registry if it exists. + * The `dependency` may contain a version, but only the name matters when resolving. + * @method resolve + * @param dependency {string} The dependency. + * @return {object} The plugin if resolved, otherwise `undefined`. + */ + Plugin.resolve = function(dependency) { + return Plugin._registry[Plugin.dependencyParse(dependency).name]; + }; + + /** + * Returns a pretty printed plugin name and version. + * @method toString + * @param plugin {} The plugin. + * @return {string} Pretty printed plugin name and version. + */ + Plugin.toString = function(plugin) { + return typeof plugin === 'string' ? plugin : (plugin.name || 'anonymous') + '@' + (plugin.version || plugin.range || '0.0.0'); + }; + + /** + * Returns `true` if the object meets the minimum standard to be considered a plugin. + * This means it must define the following properties: + * - `name` + * - `version` + * - `install` + * @method isPlugin + * @param obj {} The obj to test. + * @return {boolean} `true` if the object can be considered a plugin otherwise `false`. + */ + Plugin.isPlugin = function(obj) { + return obj && obj.name && obj.version && obj.install; + }; + + /** + * Returns `true` if a plugin with the given `name` been installed on `module`. + * @method isUsed + * @param module {} The module. + * @param name {string} The plugin name. + * @return {boolean} `true` if a plugin with the given `name` been installed on `module`, otherwise `false`. + */ + Plugin.isUsed = function(module, name) { + return module.used.indexOf(name) > -1; + }; + + /** + * Returns `true` if `plugin.for` is applicable to `module` by comparing against `module.name` and `module.version`. + * If `plugin.for` is not specified then it is assumed to be applicable. + * The value of `plugin.for` is a string of the format `'module-name'` or `'module-name@version'`. + * @method isFor + * @param plugin {} The plugin. + * @param module {} The module. + * @return {boolean} `true` if `plugin.for` is applicable to `module`, otherwise `false`. + */ + Plugin.isFor = function(plugin, module) { + var parsed = plugin.for && Plugin.dependencyParse(plugin.for); + return !plugin.for || (module.name === parsed.name && Plugin.versionSatisfies(module.version, parsed.range)); + }; + + /** + * Installs the plugins by calling `plugin.install` on each plugin specified in `plugins` if passed, otherwise `module.uses`. + * For installing plugins on `Matter` see the convenience function `Matter.use`. + * Plugins may be specified either by their name or a reference to the plugin object. + * Plugins themselves may specify further dependencies, but each plugin is installed only once. + * Order is important, a topological sort is performed to find the best resulting order of installation. + * This sorting attempts to satisfy every dependency's requested ordering, but may not be exact in all cases. + * This function logs the resulting status of each dependency in the console, along with any warnings. + * - A green tick ✅ indicates a dependency was resolved and installed. + * - An orange diamond 🔶 indicates a dependency was resolved but a warning was thrown for it or one if its dependencies. + * - A red cross ❌ indicates a dependency could not be resolved. + * Avoid calling this function multiple times on the same module unless you intend to manually control installation order. + * @method use + * @param module {} The module install plugins on. + * @param [plugins=module.uses] {} The plugins to install on module (optional, defaults to `module.uses`). + */ + Plugin.use = function(module, plugins) { + module.uses = (module.uses || []).concat(plugins || []); + + if (module.uses.length === 0) { + Common.warn('Plugin.use:', Plugin.toString(module), 'does not specify any dependencies to install.'); + return; + } + + var dependencies = Plugin.dependencies(module), + sortedDependencies = Common.topologicalSort(dependencies), + status = []; + + for (var i = 0; i < sortedDependencies.length; i += 1) { + if (sortedDependencies[i] === module.name) { + continue; + } + + var plugin = Plugin.resolve(sortedDependencies[i]); + + if (!plugin) { + status.push('❌ ' + sortedDependencies[i]); + continue; + } + + if (Plugin.isUsed(module, plugin.name)) { + continue; + } + + if (!Plugin.isFor(plugin, module)) { + Common.warn('Plugin.use:', Plugin.toString(plugin), 'is for', plugin.for, 'but installed on', Plugin.toString(module) + '.'); + plugin._warned = true; + } + + if (plugin.install) { + plugin.install(module); + } else { + Common.warn('Plugin.use:', Plugin.toString(plugin), 'does not specify an install function.'); + plugin._warned = true; + } + + if (plugin._warned) { + status.push('🔶 ' + Plugin.toString(plugin)); + delete plugin._warned; + } else { + status.push('✅ ' + Plugin.toString(plugin)); + } + + module.used.push(plugin.name); + } + + if (status.length > 0 && !plugin.silent) { + Common.info(status.join(' ')); + } + }; + + /** + * Recursively finds all of a module's dependencies and returns a flat dependency graph. + * @method dependencies + * @param module {} The module. + * @return {object} A dependency graph. + */ + Plugin.dependencies = function(module, tracked) { + var parsedBase = Plugin.dependencyParse(module), + name = parsedBase.name; + + tracked = tracked || {}; + + if (name in tracked) { + return; + } + + module = Plugin.resolve(module) || module; + + tracked[name] = Common.map(module.uses || [], function(dependency) { + if (Plugin.isPlugin(dependency)) { + Plugin.register(dependency); + } + + var parsed = Plugin.dependencyParse(dependency), + resolved = Plugin.resolve(dependency); + + if (resolved && !Plugin.versionSatisfies(resolved.version, parsed.range)) { + Common.warn( + 'Plugin.dependencies:', Plugin.toString(resolved), 'does not satisfy', + Plugin.toString(parsed), 'used by', Plugin.toString(parsedBase) + '.' + ); + + resolved._warned = true; + module._warned = true; + } else if (!resolved) { + Common.warn( + 'Plugin.dependencies:', Plugin.toString(dependency), 'used by', + Plugin.toString(parsedBase), 'could not be resolved.' + ); + + module._warned = true; + } + + return parsed.name; + }); + + for (var i = 0; i < tracked[name].length; i += 1) { + Plugin.dependencies(tracked[name][i], tracked); + } + + return tracked; + }; + + /** + * Parses a dependency string into its components. + * The `dependency` is a string of the format `'module-name'` or `'module-name@version'`. + * See documentation for `Plugin.versionParse` for a description of the format. + * This function can also handle dependencies that are already resolved (e.g. a module object). + * @method dependencyParse + * @param dependency {string} The dependency of the format `'module-name'` or `'module-name@version'`. + * @return {object} The dependency parsed into its components. + */ + Plugin.dependencyParse = function(dependency) { + if (Common.isString(dependency)) { + var pattern = /^[\w-]+(@(\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-]+)?))?$/; + + if (!pattern.test(dependency)) { + Common.warn('Plugin.dependencyParse:', dependency, 'is not a valid dependency string.'); + } + + return { + name: dependency.split('@')[0], + range: dependency.split('@')[1] || '*' + }; + } + + return { + name: dependency.name, + range: dependency.range || dependency.version + }; + }; + + /** + * Parses a version string into its components. + * Versions are strictly of the format `x.y.z` (as in [semver](http://semver.org/)). + * Versions may optionally have a prerelease tag in the format `x.y.z-alpha`. + * Ranges are a strict subset of [npm ranges](https://docs.npmjs.com/misc/semver#advanced-range-syntax). + * Only the following range types are supported: + * - Tilde ranges e.g. `~1.2.3` + * - Caret ranges e.g. `^1.2.3` + * - Exact version e.g. `1.2.3` + * - Any version `*` + * @method versionParse + * @param range {string} The version string. + * @return {object} The version range parsed into its components. + */ + Plugin.versionParse = function(range) { + var pattern = /^\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-]+)?$/; + + if (!pattern.test(range)) { + Common.warn('Plugin.versionParse:', range, 'is not a valid version or range.'); + } + + var identifiers = range.split('-'); + range = identifiers[0]; + + var isRange = isNaN(Number(range[0])), + version = isRange ? range.substr(1) : range, + parts = Common.map(version.split('.'), function(part) { + return Number(part); + }); + + return { + isRange: isRange, + version: version, + range: range, + operator: isRange ? range[0] : '', + parts: parts, + prerelease: identifiers[1], + number: parts[0] * 1e8 + parts[1] * 1e4 + parts[2] + }; + }; + + /** + * Returns `true` if `version` satisfies the given `range`. + * See documentation for `Plugin.versionParse` for a description of the format. + * If a version or range is not specified, then any version (`*`) is assumed to satisfy. + * @method versionSatisfies + * @param version {string} The version string. + * @param range {string} The range string. + * @return {boolean} `true` if `version` satisfies `range`, otherwise `false`. + */ + Plugin.versionSatisfies = function(version, range) { + range = range || '*'; + + var rangeParsed = Plugin.versionParse(range), + rangeParts = rangeParsed.parts, + versionParsed = Plugin.versionParse(version), + versionParts = versionParsed.parts; + + if (rangeParsed.isRange) { + if (rangeParsed.operator === '*' || version === '*') { + return true; + } + + if (rangeParsed.operator === '~') { + return versionParts[0] === rangeParts[0] && versionParts[1] === rangeParts[1] && versionParts[2] >= rangeParts[2]; + } + + if (rangeParsed.operator === '^') { + if (rangeParts[0] > 0) { + return versionParts[0] === rangeParts[0] && versionParsed.number >= rangeParsed.number; + } + + if (rangeParts[1] > 0) { + return versionParts[1] === rangeParts[1] && versionParts[2] >= rangeParts[2]; + } + + return versionParts[2] === rangeParts[2]; + } + } + + return version === range || version === '*'; + }; + +})(); + + +/***/ }), +/* 464 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Matter = __webpack_require__(959); + +Matter.Body = __webpack_require__(49); +Matter.Composite = __webpack_require__(120); +Matter.World = __webpack_require__(462); + +Matter.Detector = __webpack_require__(466); +Matter.Grid = __webpack_require__(958); +Matter.Pairs = __webpack_require__(957); +Matter.Pair = __webpack_require__(370); +Matter.Query = __webpack_require__(983); +Matter.Resolver = __webpack_require__(956); +Matter.SAT = __webpack_require__(465); + +Matter.Constraint = __webpack_require__(170); + +Matter.Common = __webpack_require__(39); +Matter.Engine = __webpack_require__(955); +Matter.Events = __webpack_require__(171); +Matter.Sleeping = __webpack_require__(198); +Matter.Plugin = __webpack_require__(463); + +Matter.Bodies = __webpack_require__(92); +Matter.Composites = __webpack_require__(962); + +Matter.Axes = __webpack_require__(468); +Matter.Bounds = __webpack_require__(89); +Matter.Svg = __webpack_require__(981); +Matter.Vector = __webpack_require__(90); +Matter.Vertices = __webpack_require__(91); + +// aliases + +Matter.World.add = Matter.Composite.add; +Matter.World.remove = Matter.Composite.remove; +Matter.World.addComposite = Matter.Composite.addComposite; +Matter.World.addBody = Matter.Composite.addBody; +Matter.World.addConstraint = Matter.Composite.addConstraint; +Matter.World.clear = Matter.Composite.clear; + +module.exports = Matter; + + +/***/ }), +/* 465 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.SAT` module contains methods for detecting collisions using the Separating Axis Theorem. +* +* @class SAT +*/ + +// TODO: true circles and curves + +var SAT = {}; + +module.exports = SAT; + +var Vertices = __webpack_require__(91); +var Vector = __webpack_require__(90); + +(function() { + + /** + * Detect collision between two bodies using the Separating Axis Theorem. + * @method collides + * @param {body} bodyA + * @param {body} bodyB + * @param {collision} previousCollision + * @return {collision} collision + */ + SAT.collides = function(bodyA, bodyB, previousCollision) { + var overlapAB, + overlapBA, + minOverlap, + collision, + canReusePrevCol = false; + + if (previousCollision) { + // estimate total motion + var parentA = bodyA.parent, + parentB = bodyB.parent, + motion = parentA.speed * parentA.speed + parentA.angularSpeed * parentA.angularSpeed + + parentB.speed * parentB.speed + parentB.angularSpeed * parentB.angularSpeed; + + // we may be able to (partially) reuse collision result + // but only safe if collision was resting + canReusePrevCol = previousCollision && previousCollision.collided && motion < 0.2; + + // reuse collision object + collision = previousCollision; + } else { + collision = { collided: false, bodyA: bodyA, bodyB: bodyB }; + } + + if (previousCollision && canReusePrevCol) { + // if we can reuse the collision result + // we only need to test the previously found axis + var axisBodyA = collision.axisBody, + axisBodyB = axisBodyA === bodyA ? bodyB : bodyA, + axes = [axisBodyA.axes[previousCollision.axisNumber]]; + + minOverlap = _overlapAxes(axisBodyA.vertices, axisBodyB.vertices, axes); + collision.reused = true; + + if (minOverlap.overlap <= 0) { + collision.collided = false; + return collision; + } + } else { + // if we can't reuse a result, perform a full SAT test + + overlapAB = _overlapAxes(bodyA.vertices, bodyB.vertices, bodyA.axes); + + if (overlapAB.overlap <= 0) { + collision.collided = false; + return collision; + } + + overlapBA = _overlapAxes(bodyB.vertices, bodyA.vertices, bodyB.axes); + + if (overlapBA.overlap <= 0) { + collision.collided = false; + return collision; + } + + if (overlapAB.overlap < overlapBA.overlap) { + minOverlap = overlapAB; + collision.axisBody = bodyA; + } else { + minOverlap = overlapBA; + collision.axisBody = bodyB; + } + + // important for reuse later + collision.axisNumber = minOverlap.axisNumber; + } + + collision.bodyA = bodyA.id < bodyB.id ? bodyA : bodyB; + collision.bodyB = bodyA.id < bodyB.id ? bodyB : bodyA; + collision.collided = true; + collision.depth = minOverlap.overlap; + collision.parentA = collision.bodyA.parent; + collision.parentB = collision.bodyB.parent; + + bodyA = collision.bodyA; + bodyB = collision.bodyB; + + // ensure normal is facing away from bodyA + if (Vector.dot(minOverlap.axis, Vector.sub(bodyB.position, bodyA.position)) < 0) { + collision.normal = { + x: minOverlap.axis.x, + y: minOverlap.axis.y + }; + } else { + collision.normal = { + x: -minOverlap.axis.x, + y: -minOverlap.axis.y + }; + } + + collision.tangent = Vector.perp(collision.normal); + + collision.penetration = collision.penetration || {}; + collision.penetration.x = collision.normal.x * collision.depth; + collision.penetration.y = collision.normal.y * collision.depth; + + // find support points, there is always either exactly one or two + var verticesB = _findSupports(bodyA, bodyB, collision.normal), + supports = []; + + // find the supports from bodyB that are inside bodyA + if (Vertices.contains(bodyA.vertices, verticesB[0])) + supports.push(verticesB[0]); + + if (Vertices.contains(bodyA.vertices, verticesB[1])) + supports.push(verticesB[1]); + + // find the supports from bodyA that are inside bodyB + if (supports.length < 2) { + var verticesA = _findSupports(bodyB, bodyA, Vector.neg(collision.normal)); + + if (Vertices.contains(bodyB.vertices, verticesA[0])) + supports.push(verticesA[0]); + + if (supports.length < 2 && Vertices.contains(bodyB.vertices, verticesA[1])) + supports.push(verticesA[1]); + } + + // account for the edge case of overlapping but no vertex containment + if (supports.length < 1) + supports = [verticesB[0]]; + + collision.supports = supports; + + return collision; + }; + + /** + * Find the overlap between two sets of vertices. + * @method _overlapAxes + * @private + * @param {} verticesA + * @param {} verticesB + * @param {} axes + * @return result + */ + var _overlapAxes = function(verticesA, verticesB, axes) { + var projectionA = Vector._temp[0], + projectionB = Vector._temp[1], + result = { overlap: Number.MAX_VALUE }, + overlap, + axis; + + for (var i = 0; i < axes.length; i++) { + axis = axes[i]; + + _projectToAxis(projectionA, verticesA, axis); + _projectToAxis(projectionB, verticesB, axis); + + overlap = Math.min(projectionA.max - projectionB.min, projectionB.max - projectionA.min); + + if (overlap <= 0) { + result.overlap = overlap; + return result; + } + + if (overlap < result.overlap) { + result.overlap = overlap; + result.axis = axis; + result.axisNumber = i; + } + } + + return result; + }; + + /** + * Projects vertices on an axis and returns an interval. + * @method _projectToAxis + * @private + * @param {} projection + * @param {} vertices + * @param {} axis + */ + var _projectToAxis = function(projection, vertices, axis) { + var min = Vector.dot(vertices[0], axis), + max = min; + + for (var i = 1; i < vertices.length; i += 1) { + var dot = Vector.dot(vertices[i], axis); + + if (dot > max) { + max = dot; + } else if (dot < min) { + min = dot; + } + } + + projection.min = min; + projection.max = max; + }; + + /** + * Finds supporting vertices given two bodies along a given direction using hill-climbing. + * @method _findSupports + * @private + * @param {} bodyA + * @param {} bodyB + * @param {} normal + * @return [vector] + */ + var _findSupports = function(bodyA, bodyB, normal) { + var nearestDistance = Number.MAX_VALUE, + vertexToBody = Vector._temp[0], + vertices = bodyB.vertices, + bodyAPosition = bodyA.position, + distance, + vertex, + vertexA, + vertexB; + + // find closest vertex on bodyB + for (var i = 0; i < vertices.length; i++) { + vertex = vertices[i]; + vertexToBody.x = vertex.x - bodyAPosition.x; + vertexToBody.y = vertex.y - bodyAPosition.y; + distance = -Vector.dot(normal, vertexToBody); + + if (distance < nearestDistance) { + nearestDistance = distance; + vertexA = vertex; + } + } + + // find next closest vertex using the two connected to it + var prevIndex = vertexA.index - 1 >= 0 ? vertexA.index - 1 : vertices.length - 1; + vertex = vertices[prevIndex]; + vertexToBody.x = vertex.x - bodyAPosition.x; + vertexToBody.y = vertex.y - bodyAPosition.y; + nearestDistance = -Vector.dot(normal, vertexToBody); + vertexB = vertex; + + var nextIndex = (vertexA.index + 1) % vertices.length; + vertex = vertices[nextIndex]; + vertexToBody.x = vertex.x - bodyAPosition.x; + vertexToBody.y = vertex.y - bodyAPosition.y; + distance = -Vector.dot(normal, vertexToBody); + if (distance < nearestDistance) { + vertexB = vertex; + } + + return [vertexA, vertexB]; + }; + +})(); + + +/***/ }), +/* 466 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Detector` module contains methods for detecting collisions given a set of pairs. +* +* @class Detector +*/ + +// TODO: speculative contacts + +var Detector = {}; + +module.exports = Detector; + +var SAT = __webpack_require__(465); +var Pair = __webpack_require__(370); +var Bounds = __webpack_require__(89); + +(function() { + + /** + * Finds all collisions given a list of pairs. + * @method collisions + * @param {pair[]} broadphasePairs + * @param {engine} engine + * @return {array} collisions + */ + Detector.collisions = function(broadphasePairs, engine) { + var collisions = [], + pairsTable = engine.pairs.table; + + // @if DEBUG + var metrics = engine.metrics; + // @endif + + for (var i = 0; i < broadphasePairs.length; i++) { + var bodyA = broadphasePairs[i][0], + bodyB = broadphasePairs[i][1]; + + if ((bodyA.isStatic || bodyA.isSleeping) && (bodyB.isStatic || bodyB.isSleeping)) + continue; + + if (!Detector.canCollide(bodyA.collisionFilter, bodyB.collisionFilter)) + continue; + + // @if DEBUG + metrics.midphaseTests += 1; + // @endif + + // mid phase + if (Bounds.overlaps(bodyA.bounds, bodyB.bounds)) { + for (var j = bodyA.parts.length > 1 ? 1 : 0; j < bodyA.parts.length; j++) { + var partA = bodyA.parts[j]; + + for (var k = bodyB.parts.length > 1 ? 1 : 0; k < bodyB.parts.length; k++) { + var partB = bodyB.parts[k]; + + if ((partA === bodyA && partB === bodyB) || Bounds.overlaps(partA.bounds, partB.bounds)) { + // find a previous collision we could reuse + var pairId = Pair.id(partA, partB), + pair = pairsTable[pairId], + previousCollision; + + if (pair && pair.isActive) { + previousCollision = pair.collision; + } else { + previousCollision = null; + } + + // narrow phase + var collision = SAT.collides(partA, partB, previousCollision); + + // @if DEBUG + metrics.narrowphaseTests += 1; + if (collision.reused) + metrics.narrowReuseCount += 1; + // @endif + + if (collision.collided) { + collisions.push(collision); + // @if DEBUG + metrics.narrowDetections += 1; + // @endif + } + } + } + } + } + } + + return collisions; + }; + + /** + * Returns `true` if both supplied collision filters will allow a collision to occur. + * See `body.collisionFilter` for more information. + * @method canCollide + * @param {} filterA + * @param {} filterB + * @return {bool} `true` if collision can occur + */ + Detector.canCollide = function(filterA, filterB) { + if (filterA.group === filterB.group && filterA.group !== 0) + return filterA.group > 0; + + return (filterA.mask & filterB.category) !== 0 && (filterB.mask & filterA.category) !== 0; + }; + +})(); + + +/***/ }), +/* 467 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Bodies = __webpack_require__(92); +var Body = __webpack_require__(49); +var Class = __webpack_require__(0); +var Components = __webpack_require__(371); +var GetFastValue = __webpack_require__(2); +var HasValue = __webpack_require__(70); +var Vertices = __webpack_require__(91); + +/** + * @classdesc + * A wrapper around a Tile that provides access to a corresponding Matter body. A tile can only + * have one Matter body associated with it. You can either pass in an existing Matter body for + * the tile or allow the constructor to create the corresponding body for you. If the Tile has a + * collision group (defined in Tiled), those shapes will be used to create the body. If not, the + * tile's rectangle bounding box will be used. + * + * The corresponding body will be accessible on the Tile itself via Tile.physics.matterBody. + * + * Note: not all Tiled collision shapes are supported. See + * Phaser.Physics.Matter.TileBody#setFromTileCollision for more information. + * + * @class TileBody + * @memberOf Phaser.Physics.Matter + * @constructor + * @since 3.0.0 + * + * @extends Phaser.Physics.Matter.Components.Bounce + * @extends Phaser.Physics.Matter.Components.Collision + * @extends Phaser.Physics.Matter.Components.Friction + * @extends Phaser.Physics.Matter.Components.Gravity + * @extends Phaser.Physics.Matter.Components.Mass + * @extends Phaser.Physics.Matter.Components.Sensor + * @extends Phaser.Physics.Matter.Components.Sleep + * @extends Phaser.Physics.Matter.Components.Static + * + * @param {Phaser.Physics.Matter.World} world - [description] + * @param {Phaser.GameObjects.Tile} tile - The target tile that should have a Matter body. + * @param {object} [options] - Options to be used when creating the Matter body. See + * Phaser.Physics.Matter.Matter.Body for a list of what Matter accepts. + * @param {Phaser.Physics.Matter.Matter.Body} [options.body=null] - An existing Matter body to + * be used instead of creating a new one. + * @param {boolean} [options.isStatic=true] - Whether or not the newly created body should be + * made static. This defaults to true since typically tiles should not be moved. + * @param {boolean} [options.addToWorld=true] - Whether or not to add the newly created body (or + * existing body if options.body is used) to the Matter world. + */ +var MatterTileBody = new Class({ + + Mixins: [ + Components.Bounce, + Components.Collision, + Components.Friction, + Components.Gravity, + Components.Mass, + Components.Sensor, + Components.Sleep, + Components.Static + ], + + initialize: + + function MatterTileBody (world, tile, options) + { + /** + * The tile object the body is associated with. + * + * @name Phaser.Physics.Matter.TileBody#tile + * @type {Phaser.GameObjects.Tile} + * @since 3.0.0 + */ + this.tile = tile; + + /** + * The Matter world the body exists within. + * + * @name Phaser.Physics.Matter.TileBody#world + * @type {Phaser.Physics.Matter.World} + * @since 3.0.0 + */ + this.world = world; + + // Install a reference to 'this' on the tile and ensure there can only be one matter body + // associated with the tile + if (tile.physics.matterBody) + { + tile.physics.matterBody.destroy(); + } + + tile.physics.matterBody = this; + + // Set the body either from an existing body (if provided), the shapes in the tileset + // collision layer (if it exists) or a rectangle matching the tile. + var body = GetFastValue(options, 'body', null); + + var addToWorld = GetFastValue(options, 'addToWorld', true); + + if (!body) + { + var collisionGroup = tile.getCollisionGroup(); + var collisionObjects = GetFastValue(collisionGroup, 'objects', []); + + if (collisionObjects.length > 0) + { + this.setFromTileCollision(options); + } + else + { + this.setFromTileRectangle(options); + } + } + else + { + this.setBody(body, addToWorld); + } + }, + + /** + * Sets the current body to a rectangle that matches the bounds of the tile. + * + * @method Phaser.Physics.Matter.TileBody#setFromTileRectangle + * @since 3.0.0 + * + * @param {object} [options] - Options to be used when creating the Matter body. See + * Phaser.Physics.Matter.Matter.Body for a list of what Matter accepts. + * @param {boolean} [options.isStatic=true] - Whether or not the newly created body should be + * made static. This defaults to true since typically tiles should not be moved. + * @param {boolean} [options.addToWorld=true] - Whether or not to add the newly created body (or + * existing body if options.body is used) to the Matter world. + * + * @return {Phaser.Physics.Matter.TileBody} This TileBody object. + */ + setFromTileRectangle: function (options) + { + if (options === undefined) { options = {}; } + if (!HasValue(options, 'isStatic')) { options.isStatic = true; } + if (!HasValue(options, 'addToWorld')) { options.addToWorld = true; } + + var bounds = this.tile.getBounds(); + var cx = bounds.x + (bounds.width / 2); + var cy = bounds.y + (bounds.height / 2); + var body = Bodies.rectangle(cx, cy, bounds.width, bounds.height, options); + + this.setBody(body, options.addToWorld); + + return this; + }, + + /** + * Sets the current body from the collision group associated with the Tile. This is typically + * set up in Tiled's collision editor. + * + * Note: Matter doesn't support all shapes from Tiled. Rectangles and polygons are directly + * supported. Ellipses are converted into circle bodies. Polylines are treated as if they are + * closed polygons. If a tile has multiple shapes, a multi-part body will be created. Concave + * shapes are supported if poly-decomp library is included. Decomposition is not guaranteed to + * work for complex shapes (e.g. holes), so it's often best to manually decompose a concave + * polygon into multiple convex polygons yourself. + * + * @method Phaser.Physics.Matter.TileBody#setFromTileCollision + * @since 3.0.0 + * + * @param {object} [options] - Options to be used when creating the Matter body. See + * Phaser.Physics.Matter.Matter.Body for a list of what Matter accepts. + * @param {boolean} [options.isStatic=true] - Whether or not the newly created body should be + * made static. This defaults to true since typically tiles should not be moved. + * @param {boolean} [options.addToWorld=true] - Whether or not to add the newly created body (or + * existing body if options.body is used) to the Matter world. + * + * @return {Phaser.Physics.Matter.TileBody} This TileBody object. + */ + setFromTileCollision: function (options) + { + if (options === undefined) { options = {}; } + if (!HasValue(options, 'isStatic')) { options.isStatic = true; } + if (!HasValue(options, 'addToWorld')) { options.addToWorld = true; } + + var sx = this.tile.tilemapLayer.scaleX; + var sy = this.tile.tilemapLayer.scaleY; + var tileX = this.tile.getLeft(); + var tileY = this.tile.getTop(); + var collisionGroup = this.tile.getCollisionGroup(); + var collisionObjects = GetFastValue(collisionGroup, 'objects', []); + + var parts = []; + + for (var i = 0; i < collisionObjects.length; i++) + { + var object = collisionObjects[i]; + var ox = tileX + (object.x * sx); + var oy = tileY + (object.y * sy); + var ow = object.width * sx; + var oh = object.height * sy; + var body = null; + + if (object.rectangle) + { + body = Bodies.rectangle(ox + ow / 2, oy + oh / 2, ow, oh, options); + } + else if (object.ellipse) + { + body = Bodies.circle(ox + ow / 2, oy + oh / 2, ow / 2, options); + } + else if (object.polygon || object.polyline) + { + // Polygons and polylines are both treated as closed polygons + var originalPoints = object.polygon ? object.polygon : object.polyline; + + var points = originalPoints.map(function (p) + { + return { x: p.x * sx, y: p.y * sy }; + }); + + var vertices = Vertices.create(points); + + // Points are relative to the object's origin (first point placed in Tiled), but + // matter expects points to be relative to the center of mass. This only applies to + // convex shapes. When a concave shape is decomposed, multiple parts are created and + // the individual parts are positioned relative to (ox, oy). + if (Vertices.isConvex(points)) + { + var center = Vertices.centre(vertices); + ox += center.x; + oy += center.y; + } + + body = Bodies.fromVertices(ox, oy, vertices, options); + } + + if (body) + { + parts.push(body); + } + } + + if (parts.length === 1) + { + this.setBody(parts[0], options.addToWorld); + } + else if (parts.length > 1) + { + options.parts = parts; + this.setBody(Body.create(options), options.addToWorld); + } + + return this; + }, + + /** + * Sets the current body to the given body. This will remove the previous body, if one already + * exists. + * + * @method Phaser.Physics.Matter.TileBody#setBody + * @since 3.0.0 + * + * @param {Phaser.Physics.Matter.Matter.Body} body - The new Matter body to use. + * @param {boolean} [addToWorld=true] - Whether or not to add the body to the Matter world. + * + * @return {Phaser.Physics.Matter.TileBody} This TileBody object. + */ + setBody: function (body, addToWorld) + { + if (addToWorld === undefined) { addToWorld = true; } + + if (this.body) + { + this.removeBody(); + } + + this.body = body; + this.body.gameObject = this; + + if (addToWorld) + { + this.world.add(this.body); + } + + return this; + }, + + /** + * Removes the current body from the TileBody and from the Matter world + * + * @method Phaser.Physics.Matter.TileBody#removeBody + * @since 3.0.0 + * + * @return {Phaser.Physics.Matter.TileBody} This TileBody object. + */ + removeBody: function () + { + if (this.body) + { + this.world.remove(this.body); + this.body.gameObject = undefined; + this.body = undefined; + } + + return this; + }, + + /** + * Removes the current body from the tile and the world. + * + * @method Phaser.Physics.Matter.TileBody#removeBody + * @since 3.0.0 + * + * @return {Phaser.Physics.Matter.TileBody} This TileBody object. + */ + destroy: function () + { + this.removeBody(); + this.tile.physics.matterBody = undefined; + } + +}); + +module.exports = MatterTileBody; + + +/***/ }), +/* 468 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Axes` module contains methods for creating and manipulating sets of axes. +* +* @class Axes +*/ + +var Axes = {}; + +module.exports = Axes; + +var Vector = __webpack_require__(90); +var Common = __webpack_require__(39); + +(function() { + + /** + * Creates a new set of axes from the given vertices. + * @method fromVertices + * @param {vertices} vertices + * @return {axes} A new axes from the given vertices + */ + Axes.fromVertices = function(vertices) { + var axes = {}; + + // find the unique axes, using edge normal gradients + for (var i = 0; i < vertices.length; i++) { + var j = (i + 1) % vertices.length, + normal = Vector.normalise({ + x: vertices[j].y - vertices[i].y, + y: vertices[i].x - vertices[j].x + }), + gradient = (normal.y === 0) ? Infinity : (normal.x / normal.y); + + // limit precision + gradient = gradient.toFixed(3).toString(); + axes[gradient] = normal; + } + + return Common.values(axes); + }; + + /** + * Rotates a set of axes by the given angle. + * @method rotate + * @param {axes} axes + * @param {number} angle + */ + Axes.rotate = function(axes, angle) { + if (angle === 0) + return; + + var cos = Math.cos(angle), + sin = Math.sin(angle); + + for (var i = 0; i < axes.length; i++) { + var axis = axes[i], + xx; + xx = axis.x * cos - axis.y * sin; + axis.y = axis.x * sin + axis.y * cos; + axis.x = xx; + } + }; + +})(); + + +/***/ }), +/* 469 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Physics.Impact.Body.Components + */ + +module.exports = { + + Acceleration: __webpack_require__(1014), + BodyScale: __webpack_require__(1013), + BodyType: __webpack_require__(1012), + Bounce: __webpack_require__(1011), + CheckAgainst: __webpack_require__(1010), + Collides: __webpack_require__(1009), + Debug: __webpack_require__(1008), + Friction: __webpack_require__(1007), + Gravity: __webpack_require__(1006), + Offset: __webpack_require__(1005), + SetGameObject: __webpack_require__(1004), + Velocity: __webpack_require__(1003) + +}; + + +/***/ }), +/* 470 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetOverlapY = __webpack_require__(206); + +/** + * [description] + * + * @function Phaser.Physics.Arcade.SeparateY + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {boolean} overlapOnly - [description] + * @param {number} bias - [description] + * + * @return {boolean} [description] + */ +var SeparateY = function (body1, body2, overlapOnly, bias) +{ + var overlap = GetOverlapY(body1, body2, overlapOnly, bias); + + // Can't separate two immovable bodies, or a body with its own custom separation logic + if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateY || body2.customSeparateY) + { + // return true if there was some overlap, otherwise false + return (overlap !== 0) || (body1.embedded && body2.embedded); + } + + // Adjust their positions and velocities accordingly (if there was any overlap) + var v1 = body1.velocity.y; + var v2 = body2.velocity.y; + + if (!body1.immovable && !body2.immovable) + { + overlap *= 0.5; + + body1.y -= overlap; + body2.y += overlap; + + var nv1 = Math.sqrt((v2 * v2 * body2.mass) / body1.mass) * ((v2 > 0) ? 1 : -1); + var nv2 = Math.sqrt((v1 * v1 * body1.mass) / body2.mass) * ((v1 > 0) ? 1 : -1); + var avg = (nv1 + nv2) * 0.5; + + nv1 -= avg; + nv2 -= avg; + + body1.velocity.y = avg + nv1 * body1.bounce.y; + body2.velocity.y = avg + nv2 * body2.bounce.y; + } + else if (!body1.immovable) + { + body1.y -= overlap; + body1.velocity.y = v2 - v1 * body1.bounce.y; + + // This is special case code that handles things like horizontal moving platforms you can ride + if (body2.moves) + { + body1.x += (body2.x - body2.prev.x) * body2.friction.x; + } + } + else + { + body2.y += overlap; + body2.velocity.y = v1 - v2 * body2.bounce.y; + + // This is special case code that handles things like horizontal moving platforms you can ride + if (body1.moves) + { + body2.x += (body1.x - body1.prev.x) * body1.friction.x; + } + } + + // If we got this far then there WAS overlap, and separation is complete, so return true + return true; +}; + +module.exports = SeparateY; + + +/***/ }), +/* 471 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetOverlapX = __webpack_require__(207); + +/** + * [description] + * + * @function Phaser.Physics.Arcade.SeparateX + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {boolean} overlapOnly - [description] + * @param {number} bias - [description] + * + * @return {boolean} [description] + */ +var SeparateX = function (body1, body2, overlapOnly, bias) +{ + var overlap = GetOverlapX(body1, body2, overlapOnly, bias); + + // Can't separate two immovable bodies, or a body with its own custom separation logic + if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateX || body2.customSeparateX) + { + // return true if there was some overlap, otherwise false + return (overlap !== 0) || (body1.embedded && body2.embedded); + } + + // Adjust their positions and velocities accordingly (if there was any overlap) + var v1 = body1.velocity.x; + var v2 = body2.velocity.x; + + if (!body1.immovable && !body2.immovable) + { + overlap *= 0.5; + + body1.x -= overlap; + body2.x += overlap; + + var nv1 = Math.sqrt((v2 * v2 * body2.mass) / body1.mass) * ((v2 > 0) ? 1 : -1); + var nv2 = Math.sqrt((v1 * v1 * body1.mass) / body2.mass) * ((v1 > 0) ? 1 : -1); + var avg = (nv1 + nv2) * 0.5; + + nv1 -= avg; + nv2 -= avg; + + body1.velocity.x = avg + nv1 * body1.bounce.x; + body2.velocity.x = avg + nv2 * body2.bounce.x; + } + else if (!body1.immovable) + { + body1.x -= overlap; + body1.velocity.x = v2 - v1 * body1.bounce.x; + + // This is special case code that handles things like vertically moving platforms you can ride + if (body2.moves) + { + body1.y += (body2.y - body2.prev.y) * body2.friction.y; + } + } + else + { + body2.x += overlap; + body2.velocity.x = v1 - v2 * body2.bounce.x; + + // This is special case code that handles things like vertically moving platforms you can ride + if (body1.moves) + { + body2.y += (body1.y - body1.prev.y) * body1.friction.y; + } + } + + // If we got this far then there WAS overlap, and separation is complete, so return true + return true; +}; + +module.exports = SeparateX; + + +/***/ }), +/* 472 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Internal function to process the separation of a physics body from a tile. + * + * @function Phaser.Physics.Arcade.Tilemap.ProcessTileSeparationY + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {number} y - The y separation amount. + */ +var ProcessTileSeparationY = function (body, y) +{ + if (y < 0) + { + body.blocked.up = true; + } + else if (y > 0) + { + body.blocked.down = true; + } + + body.position.y -= y; + + if (body.bounce.y === 0) + { + body.velocity.y = 0; + } + else + { + body.velocity.y = -body.velocity.y * body.bounce.y; + } +}; + +module.exports = ProcessTileSeparationY; + + +/***/ }), +/* 473 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ProcessTileSeparationY = __webpack_require__(472); + +/** + * Check the body against the given tile on the Y axis. + * + * @function Phaser.Physics.Arcade.Tilemap.TileCheckY + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {Phaser.Tilemaps.Tile} tile - The tile to check. + * @param {number} tileTop - [description] + * @param {number} tileBottom - [description] + * @param {number} tileBias - [description] + * + * @return {number} The amount of separation that occurred. + */ +var TileCheckY = function (body, tile, tileTop, tileBottom, tileBias) +{ + var oy = 0; + + if (body.deltaY() < 0 && !body.blocked.up && tile.collideDown && body.checkCollision.up) + { + // Body is moving UP + if (tile.faceBottom && body.y < tileBottom) + { + oy = body.y - tileBottom; + + if (oy < -tileBias) + { + oy = 0; + } + } + } + else if (body.deltaY() > 0 && !body.blocked.down && tile.collideUp && body.checkCollision.down) + { + // Body is moving DOWN + if (tile.faceTop && body.bottom > tileTop) + { + oy = body.bottom - tileTop; + + if (oy > tileBias) + { + oy = 0; + } + } + } + + if (oy !== 0) + { + if (body.customSeparateY) + { + body.overlapY = oy; + } + else + { + ProcessTileSeparationY(body, oy); + } + } + + return oy; +}; + +module.exports = TileCheckY; + + +/***/ }), +/* 474 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Internal function to process the separation of a physics body from a tile. + * + * @function Phaser.Physics.Arcade.Tilemap.ProcessTileSeparationX + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {number} x - The x separation amount. + */ +var ProcessTileSeparationX = function (body, x) +{ + if (x < 0) + { + body.blocked.left = true; + } + else if (x > 0) + { + body.blocked.right = true; + } + + body.position.x -= x; + + if (body.bounce.x === 0) + { + body.velocity.x = 0; + } + else + { + body.velocity.x = -body.velocity.x * body.bounce.x; + } +}; + +module.exports = ProcessTileSeparationX; + + +/***/ }), +/* 475 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ProcessTileSeparationX = __webpack_require__(474); + +/** + * Check the body against the given tile on the X axis. + * + * @function Phaser.Physics.Arcade.Tilemap.TileCheckX + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {Phaser.Tilemaps.Tile} tile - The tile to check. + * @param {number} tileLeft - [description] + * @param {number} tileRight - [description] + * @param {number} tileBias - [description] + * + * @return {number} The amount of separation that occurred. + */ +var TileCheckX = function (body, tile, tileLeft, tileRight, tileBias) +{ + var ox = 0; + + if (body.deltaX() < 0 && !body.blocked.left && tile.collideRight && body.checkCollision.left) + { + // Body is moving LEFT + if (tile.faceRight && body.x < tileRight) + { + ox = body.x - tileRight; + + if (ox < -tileBias) + { + ox = 0; + } + } + } + else if (body.deltaX() > 0 && !body.blocked.right && tile.collideLeft && body.checkCollision.right) + { + // Body is moving RIGHT + if (tile.faceLeft && body.right > tileLeft) + { + ox = body.right - tileLeft; + + if (ox > tileBias) + { + ox = 0; + } + } + } + + if (ox !== 0) + { + if (body.customSeparateX) + { + body.overlapX = ox; + } + else + { + ProcessTileSeparationX(body, ox); + } + } + + return ox; +}; + +module.exports = TileCheckX; + + +/***/ }), +/* 476 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TileCheckX = __webpack_require__(475); +var TileCheckY = __webpack_require__(473); +var TileIntersectsBody = __webpack_require__(202); + +/** + * The core separation function to separate a physics body and a tile. + * + * @function Phaser.Physics.Arcade.Tilemap.SeparateTile + * @since 3.0.0 + * + * @param {number} i - [description] + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {Phaser.Tilemaps.Tile} tile - The tile to collide against. + * @param {Phaser.Geom.Rectangle} tileWorldRect - [description] + * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - The tilemapLayer to collide against. + * @param {number} tileBias - [description] + * + * @return {boolean} Returns true if the body was separated, otherwise false. + */ +var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer, tileBias) +{ + var tileLeft = tileWorldRect.left; + var tileTop = tileWorldRect.top; + var tileRight = tileWorldRect.right; + var tileBottom = tileWorldRect.bottom; + var faceHorizontal = tile.faceLeft || tile.faceRight; + var faceVertical = tile.faceTop || tile.faceBottom; + + // We don't need to go any further if this tile doesn't actually have any colliding faces. This + // could happen if the tile was meant to be collided with re: a callback, but otherwise isn't + // needed for separation. + if (!faceHorizontal && !faceVertical) + { + return false; + } + + var ox = 0; + var oy = 0; + var minX = 0; + var minY = 1; + + if (body.deltaAbsX() > body.deltaAbsY()) + { + // Moving faster horizontally, check X axis first + minX = -1; + } + else if (body.deltaAbsX() < body.deltaAbsY()) + { + // Moving faster vertically, check Y axis first + minY = -1; + } + + if (body.deltaX() !== 0 && body.deltaY() !== 0 && faceHorizontal && faceVertical) + { + // We only need do this if both axes have colliding faces AND we're moving in both + // directions + minX = Math.min(Math.abs(body.position.x - tileRight), Math.abs(body.right - tileLeft)); + minY = Math.min(Math.abs(body.position.y - tileBottom), Math.abs(body.bottom - tileTop)); + } + + if (minX < minY) + { + if (faceHorizontal) + { + ox = TileCheckX(body, tile, tileLeft, tileRight, tileBias); + + // That's horizontal done, check if we still intersects? If not then we can return now + if (ox !== 0 && !TileIntersectsBody(tileWorldRect, body)) + { + return true; + } + } + + if (faceVertical) + { + oy = TileCheckY(body, tile, tileTop, tileBottom, tileBias); + } + } + else + { + if (faceVertical) + { + oy = TileCheckY(body, tile, tileTop, tileBottom, tileBias); + + // That's vertical done, check if we still intersects? If not then we can return now + if (oy !== 0 && !TileIntersectsBody(tileWorldRect, body)) + { + return true; + } + } + + if (faceHorizontal) + { + ox = TileCheckX(body, tile, tileLeft, tileRight, tileBias); + } + } + + return (ox !== 0 || oy !== 0); +}; + +module.exports = SeparateTile; + + +/***/ }), +/* 477 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Physics.Arcade.Tilemap.ProcessTileCallbacks + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.Tilemap} tile - [description] + * @param {Phaser.GameObjects.Sprite} sprite - [description] + * + * @return {boolean} [description] + */ +var ProcessTileCallbacks = function (tile, sprite) +{ + // Tile callbacks take priority over layer level callbacks + if (tile.collisionCallback) + { + return !tile.collisionCallback.call(tile.collisionCallbackContext, sprite, tile); + } + else if (tile.layer.callbacks[tile.index]) + { + return !tile.layer.callbacks[tile.index].callback.call( + tile.layer.callbacks[tile.index].callbackContext, sprite, tile + ); + } + + return true; +}; + +module.exports = ProcessTileCallbacks; + + +/***/ }), +/* 478 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Velocity + * @since 3.0.0 + */ +var Velocity = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Velocity#setVelocity + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setVelocity: function (x, y) + { + this.body.velocity.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Velocity#setVelocityX + * @since 3.0.0 + * + * @param {number} x - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setVelocityX: function (x) + { + this.body.velocity.x = x; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Velocity#setVelocityY + * @since 3.0.0 + * + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setVelocityY: function (y) + { + this.body.velocity.y = y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Velocity#setMaxVelocity + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setMaxVelocity: function (x, y) + { + this.body.maxVelocity.set(x, y); + + return this; + } + +}; + +module.exports = Velocity; + + +/***/ }), +/* 479 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Size + * @since 3.0.0 + */ +var Size = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Size#setOffset + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setOffset: function (x, y) + { + this.body.setOffset(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Size#setSize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * @param {boolean} [center=true] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setSize: function (width, height, center) + { + this.body.setSize(width, height, center); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Size#setCircle + * @since 3.0.0 + * + * @param {number} radius - [description] + * @param {number} [offsetX] - [description] + * @param {number} [offsetY] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setCircle: function (radius, offsetX, offsetY) + { + this.body.setCircle(radius, offsetX, offsetY); + + return this; + } + +}; + +module.exports = Size; + + +/***/ }), +/* 480 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Mass + * @since 3.0.0 + */ +var Mass = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Mass#setMass + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setMass: function (value) + { + this.body.mass = value; + + return this; + } + +}; + +module.exports = Mass; + + +/***/ }), +/* 481 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Immovable + * @since 3.0.0 + */ +var Immovable = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Immovable#setImmovable + * @since 3.0.0 + * + * @param {boolean} [value=true] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setImmovable: function (value) + { + if (value === undefined) { value = true; } + + this.body.immovable = value; + + return this; + } + +}; + +module.exports = Immovable; + + +/***/ }), +/* 482 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Gravity + * @since 3.0.0 + */ +var Gravity = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Gravity#setGravity + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setGravity: function (x, y) + { + this.body.gravity.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Gravity#setGravityX + * @since 3.0.0 + * + * @param {number} x - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setGravityX: function (x) + { + this.body.gravity.x = x; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Gravity#setGravityY + * @since 3.0.0 + * + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setGravityY: function (y) + { + this.body.gravity.y = y; + + return this; + } + +}; + +module.exports = Gravity; + + +/***/ }), +/* 483 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Friction + * @since 3.0.0 + */ +var Friction = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Friction#setFriction + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setFriction: function (x, y) + { + this.body.friction.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Friction#setFrictionX + * @since 3.0.0 + * + * @param {number} x - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setFrictionX: function (x) + { + this.body.friction.x = x; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Friction#setFrictionY + * @since 3.0.0 + * + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setFrictionY: function (y) + { + this.body.friction.y = y; + + return this; + } + +}; + +module.exports = Friction; + + +/***/ }), +/* 484 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Enable + * @since 3.0.0 + */ +var Enable = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Enable#enableBody + * @since 3.0.0 + * + * @param {boolean} reset - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {boolean} enableGameObject - [description] + * @param {boolean} showGameObject - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + enableBody: function (reset, x, y, enableGameObject, showGameObject) + { + if (reset) + { + this.body.reset(x, y); + } + + if (enableGameObject) + { + this.body.gameObject.active = true; + } + + if (showGameObject) + { + this.body.gameObject.visible = true; + } + + this.body.enable = true; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Enable#disableBody + * @since 3.0.0 + * + * @param {boolean} [disableGameObject=false] - [description] + * @param {boolean} [hideGameObject=false] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + disableBody: function (disableGameObject, hideGameObject) + { + if (disableGameObject === undefined) { disableGameObject = false; } + if (hideGameObject === undefined) { hideGameObject = false; } + + this.body.stop(); + + this.body.enable = false; + + if (disableGameObject) + { + this.body.gameObject.active = false; + } + + if (hideGameObject) + { + this.body.gameObject.visible = false; + } + + return this; + }, + + /** + * Syncs the Bodies position and size with its parent Game Object. + * You don't need to call this for Dynamic Bodies, as it happens automatically. + * But for Static bodies it's a useful way of modifying the position of a Static Body + * in the Physics World, based on its Game Object. + * + * @method Phaser.Physics.Arcade.Components.Enable#refreshBody + * @since 3.1.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + refreshBody: function () + { + this.body.updateFromGameObject(); + + return this; + } + +}; + +module.exports = Enable; + + +/***/ }), +/* 485 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Drag + * @since 3.0.0 + */ +var Drag = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Drag#setDrag + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setDrag: function (x, y) + { + this.body.drag.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Drag#setDragX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setDragX: function (value) + { + this.body.drag.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Drag#setDragY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setDragY: function (value) + { + this.body.drag.y = value; + + return this; + } + +}; + +module.exports = Drag; + + +/***/ }), +/* 486 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Debug + * @since 3.0.0 + */ +var Debug = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Debug#setDebug + * @since 3.0.0 + * + * @param {boolean} showBody - [description] + * @param {boolean} showVelocity - [description] + * @param {number} bodyColor - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setDebug: function (showBody, showVelocity, bodyColor) + { + this.debugShowBody = showBody; + this.debugShowVelocity = showVelocity; + this.debugBodyColor = bodyColor; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Debug#setDebugBodyColor + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setDebugBodyColor: function (value) + { + this.body.debugBodyColor = value; + + return this; + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Debug#debugShowBody + * @type {boolean} + * @since 3.0.0 + */ + debugShowBody: { + + get: function () + { + return this.body.debugShowBody; + }, + + set: function (value) + { + this.body.debugShowBody = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Debug#debugShowVelocity + * @type {boolean} + * @since 3.0.0 + */ + debugShowVelocity: { + + get: function () + { + return this.body.debugShowVelocity; + }, + + set: function (value) + { + this.body.debugShowVelocity = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Debug#debugBodyColor + * @type {number} + * @since 3.0.0 + */ + debugBodyColor: { + + get: function () + { + return this.body.debugBodyColor; + }, + + set: function (value) + { + this.body.debugBodyColor = value; + } + + } + +}; + +module.exports = Debug; + + +/***/ }), +/* 487 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Bounce + * @since 3.0.0 + */ +var Bounce = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Bounce#setBounce + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setBounce: function (x, y) + { + this.body.bounce.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Bounce#setBounceX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setBounceX: function (value) + { + this.body.bounce.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Bounce#setBounceY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setBounceY: function (value) + { + this.body.bounce.y = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Bounce#setCollideWorldBounds + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setCollideWorldBounds: function (value) + { + this.body.collideWorldBounds = value; + + return this; + } + +}; + +module.exports = Bounce; + + +/***/ }), +/* 488 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Angular + * @since 3.0.0 + */ +var Angular = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Angular#setAngularVelocity + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setAngularVelocity: function (value) + { + this.body.angularVelocity = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Angular#setAngularAcceleration + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setAngularAcceleration: function (value) + { + this.body.angularAcceleration = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Angular#setAngularDrag + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setAngularDrag: function (value) + { + this.body.angularDrag = value; + + return this; + } + +}; + +module.exports = Angular; + + +/***/ }), +/* 489 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Acceleration + * @since 3.0.0 + */ +var Acceleration = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Acceleration#setAcceleration + * @since 3.0.0 + * + * @param {number} x - The horizontal acceleration + * @param {number} [y=x] - The vertical acceleration + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setAcceleration: function (x, y) + { + this.body.acceleration.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Acceleration#setAccelerationX + * @since 3.0.0 + * + * @param {number} value - The horizontal acceleration + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setAccelerationX: function (value) + { + this.body.acceleration.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Acceleration#setAccelerationY + * @since 3.0.0 + * + * @param {number} value - The vertical acceleration + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setAccelerationY: function (value) + { + this.body.acceleration.y = value; + + return this; + } + +}; + +module.exports = Acceleration; + + +/***/ }), +/* 490 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Factory = __webpack_require__(215); +var GetFastValue = __webpack_require__(2); +var Merge = __webpack_require__(107); +var PluginManager = __webpack_require__(12); +var World = __webpack_require__(210); +var DistanceBetween = __webpack_require__(48); +var DegToRad = __webpack_require__(42); + +// All methods in this class are available under `this.physics` in a Scene. + +/** + * @classdesc + * [description] + * + * @class ArcadePhysics + * @memberOf Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ +var ArcadePhysics = new Class({ + + initialize: + + function ArcadePhysics (scene) + { + /** + * [description] + * + * @name Phaser.Physics.Arcade.ArcadePhysics#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.ArcadePhysics#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + if (!scene.sys.settings.isBooted) + { + scene.sys.events.once('boot', this.boot, this); + } + + /** + * [description] + * + * @name Phaser.Physics.Arcade.ArcadePhysics#config + * @type {object} + * @since 3.0.0 + */ + this.config = this.getConfig(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.ArcadePhysics#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.ArcadePhysics#add + * @type {Phaser.Physics.Arcade.Factory} + * @since 3.0.0 + */ + this.add; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.ArcadePhysics#getConfig + * @since 3.0.0 + * + * @return {object} [description] + */ + getConfig: function () + { + var gameConfig = this.systems.game.config.physics; + var sceneConfig = this.systems.settings.physics; + + var config = Merge( + GetFastValue(sceneConfig, 'arcade', {}), + GetFastValue(gameConfig, 'arcade', {}) + ); + + return config; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.ArcadePhysics#boot + * @since 3.0.0 + */ + boot: function () + { + this.world = new World(this.scene, this.config); + this.add = new Factory(this.world); + + var eventEmitter = this.systems.events; + + eventEmitter.on('update', this.world.update, this.world); + eventEmitter.on('postupdate', this.world.postUpdate, this.world); + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); + }, + + /** + * Checks for overlaps between two Game Objects. The objects can be any Game Object that have an Arcade Physics Body. + * + * Unlike {@link #collide} the objects are NOT automatically separated or have any physics applied, they merely test for overlap results. + * + * Both the first and second parameter can be arrays of objects, of differing types. + * If two arrays are passed, the contents of the first parameter will be tested against all contents of the 2nd parameter. + * + * ##### Tilemaps + * + * Any overlapping tiles, including blank/null tiles, will give a positive result. Tiles marked via {@link Phaser.Tilemap#setCollision} (and similar methods) have no special status, and callbacks added via {@link Phaser.Tilemap#setTileIndexCallback} or {@link Phaser.Tilemap#setTileLocationCallback} are not invoked. So calling this method without any callbacks isn't very useful. + * + * If you're interested only in whether an object overlaps a certain tile or class of tiles, filter the tiles with `processCallback` and then use the result returned by this method. Blank/null tiles can be excluded by their {@link Phaser.Tile#index index} (-1). + * + * If you want to take action on certain overlaps, examine the tiles in `collideCallback` and then handle as you like. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#overlap + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|array)} object1 - The first object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. + * @param {(Phaser.GameObjects.GameObject|array)} object2 - The second object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. + * @param {ArcadePhysicsCallback} [overlapCallback=null] - An optional callback function that is called if the objects overlap. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter. + * @param {ArcadePhysicsCallback} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `overlapCallback` will only be called if this callback returns `true`. + * @param {*} [callbackContext] - The context in which to run the callbacks. + * + * @return {boolean} True if an overlap occurred otherwise false. + */ + overlap: function (object1, object2, overlapCallback, processCallback, callbackContext) + { + if (overlapCallback === undefined) { overlapCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = overlapCallback; } + + return this.world.collideObjects(object1, object2, overlapCallback, processCallback, callbackContext, true); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.ArcadePhysics#collide + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|array)} object1 - The first object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. + * @param {(Phaser.GameObjects.GameObject|array)} object2 - The second object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. + * @param {ArcadePhysicsCallback} [collideCallback=null] - An optional callback function that is called if the objects collide. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter. + * @param {ArcadePhysicsCallback} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param {*} [callbackContext] - The context in which to run the callbacks. + * + * @return {boolean} True if a collision occurred otherwise false. + */ + collide: function (object1, object2, collideCallback, processCallback, callbackContext) + { + if (collideCallback === undefined) { collideCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = collideCallback; } + + return this.world.collideObjects(object1, object2, collideCallback, processCallback, callbackContext, false); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.ArcadePhysics#pause + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.World} [description] + */ + pause: function () + { + return this.world.pause(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.ArcadePhysics#resume + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.World} [description] + */ + resume: function () + { + return this.world.resume(); + }, + + /** + * Sets the acceleration.x/y property on the game object so it will move towards the x/y coordinates at the given speed (in pixels per second sq.) + * + * You must give a maximum speed value, beyond which the game object won't go any faster. + * + * Note: The game object does not continuously track the target. If the target changes location during transit the game object will not modify its course. + * Note: The game object doesn't stop moving once it reaches the destination coordinates. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#accelerateTo + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. + * @param {number} x - The x coordinate to accelerate towards. + * @param {number} y - The y coordinate to accelerate towards. + * @param {number} [speed=60] - The speed it will accelerate in pixels per second. + * @param {number} [xSpeedMax=500] - The maximum x velocity the game object can reach. + * @param {number} [ySpeedMax=500] - The maximum y velocity the game object can reach. + * + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. + */ + accelerateTo: function (gameObject, x, y, speed, xSpeedMax, ySpeedMax) + { + if (speed === undefined) { speed = 60; } + + var angle = Math.atan2(y - gameObject.y, x - gameObject.x); + + gameObject.body.acceleration.setToPolar(angle, speed); + + if (xSpeedMax !== undefined && ySpeedMax !== undefined) + { + gameObject.body.maxVelocity.set(xSpeedMax, ySpeedMax); + } + + return angle; + }, + + /** + * Sets the acceleration.x/y property on the game object so it will move towards the x/y coordinates at the given speed (in pixels per second sq.) + * + * You must give a maximum speed value, beyond which the game object won't go any faster. + * + * Note: The game object does not continuously track the target. If the target changes location during transit the game object will not modify its course. + * Note: The game object doesn't stop moving once it reaches the destination coordinates. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#accelerateToObject + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. + * @param {Phaser.GameObjects.GameObject} destination - The Game Object to move towards. Can be any object but must have visible x/y properties. + * @param {number} [speed=60] - The speed it will accelerate in pixels per second. + * @param {number} [xSpeedMax=500] - The maximum x velocity the game object can reach. + * @param {number} [ySpeedMax=500] - The maximum y velocity the game object can reach. + * + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. + */ + accelerateToObject: function (gameObject, destination, speed, xSpeedMax, ySpeedMax) + { + return this.accelerateTo(gameObject, destination.x, destination.y, speed, xSpeedMax, ySpeedMax); + }, + + /** + * From a set of points or display objects, find the one closest to a source point or object. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#closest + * @since 3.0.0 + * + * @param {object} source - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. + * + * @return {Phaser.Physics.Arcade.Body} The closest Body to the given source point. + */ + closest: function (source) + { + var bodies = this.tree.all(); + + var min = Number.MAX_VALUE; + var closest = null; + var x = source.x; + var y = source.y; + + for (var i = bodies.length - 1; i >= 0; i--) + { + var target = bodies[i]; + var distance = DistanceBetween(x, y, target.x, target.y); + + if (distance < min) + { + closest = target; + min = distance; + } + } + + return closest; + }, + + /** + * From a set of points or display objects, find the one farthest from a source point or object. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#furthest + * @since 3.0.0 + * + * @param {object} source - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. + * + * @return {Phaser.Physics.Arcade.Body} The Body furthest from the given source point. + */ + furthest: function (source) + { + var bodies = this.tree.all(); + + var max = -1; + var farthest = null; + var x = source.x; + var y = source.y; + + for (var i = bodies.length - 1; i >= 0; i--) + { + var target = bodies[i]; + var distance = DistanceBetween(x, y, target.x, target.y); + + if (distance > max) + { + farthest = target; + max = distance; + } + } + + return farthest; + }, + + /** + * Move the given display object towards the x/y coordinates at a steady velocity. + * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. + * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) + * + * @method Phaser.Physics.Arcade.ArcadePhysics#moveTo + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. + * @param {number} x - The x coordinate to move towards. + * @param {number} y - The y coordinate to move towards. + * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) + * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. + * + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. + */ + moveTo: function (gameObject, x, y, speed, maxTime) + { + if (speed === undefined) { speed = 60; } + if (maxTime === undefined) { maxTime = 0; } + + var angle = Math.atan2(y - gameObject.y, x - gameObject.x); + + if (maxTime > 0) + { + // We know how many pixels we need to move, but how fast? + speed = DistanceBetween(gameObject.x, gameObject.y, x, y) / (maxTime / 1000); + } + + gameObject.body.velocity.setToPolar(angle, speed); + + return angle; + }, + + /** + * Move the given display object towards the destination object at a steady velocity. + * If you specify a maxTime then it will adjust the speed (overwriting what you set) so it arrives at the destination in that number of seconds. + * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) + * + * @method Phaser.Physics.Arcade.ArcadePhysics#moveToObject + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. + * @param {object} destination - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. + * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) + * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. + * + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. + */ + moveToObject: function (gameObject, destination, speed, maxTime) + { + return this.moveTo(gameObject, destination.x, destination.y, speed, maxTime); + }, + + /** + * Given the angle (in degrees) and speed calculate the velocity and return it as a Point object, or set it to the given point object. + * One way to use this is: velocityFromAngle(angle, 200, sprite.velocity) which will set the values directly to the sprites velocity and not create a new Point object. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#velocityFromAngle + * @since 3.0.0 + * + * @param {number} angle - The angle in degrees calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) + * @param {number} [speed=60] - The speed it will move, in pixels per second sq. + * @param {Phaser.Math.Vector2} vec2 - The Vector2 in which the x and y properties will be set to the calculated velocity. + * + * @return {Phaser.Math.Vector2} The Vector2 that stores the velocity. + */ + velocityFromAngle: function (angle, speed, vec2) + { + if (speed === undefined) { speed = 60; } + + return vec2.setToPolar(DegToRad(angle), speed); + }, + + /** + * Given the rotation (in radians) and speed calculate the velocity and return it as a Point object, or set it to the given point object. + * One way to use this is: velocityFromRotation(rotation, 200, sprite.velocity) which will set the values directly to the sprites velocity and not create a new Point object. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#velocityFromRotation + * @since 3.0.0 + * + * @param {number} rotation - The angle in radians. + * @param {number} [speed=60] - The speed it will move, in pixels per second sq. + * @param {Phaser.Math.Vector2} vec2 - The Vector2 in which the x and y properties will be set to the calculated velocity. + * + * @return {Phaser.Math.Vector2} The Vector2 that stores the velocity. + */ + velocityFromRotation: function (rotation, speed, vec2) + { + if (speed === undefined) { speed = 60; } + + return vec2.setToPolar(rotation, speed); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.ArcadePhysics#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.world.shutdown(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.ArcadePhysics#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.world.destroy(); + } + +}); + +PluginManager.register('ArcadePhysics', ArcadePhysics, 'arcadePhysics'); + +module.exports = ArcadePhysics; + + +/***/ }), +/* 491 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(47); +var Extend = __webpack_require__(18); + +/** + * @callback ArcadePhysicsCallback + * + * @param {Phaser.GameObjects.GameObject} object1 - [description] + * @param {Phaser.GameObjects.GameObject} object2 - [description] + */ + +/** + * @namespace Phaser.Physics.Arcade + */ + +var Arcade = { + + ArcadePhysics: __webpack_require__(490), + Body: __webpack_require__(209), + Collider: __webpack_require__(208), + Factory: __webpack_require__(215), + Group: __webpack_require__(212), + Image: __webpack_require__(214), + Sprite: __webpack_require__(93), + StaticBody: __webpack_require__(201), + StaticGroup: __webpack_require__(211), + World: __webpack_require__(210) + +}; + +// Merge in the consts +Arcade = Extend(false, Arcade, CONST); + +module.exports = Arcade; + + +/***/ }), +/* 492 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Checks if the two values are within the given `tolerance` of each other. + * + * @function Phaser.Math.Within + * @since 3.0.0 + * + * @param {number} a - [description] + * @param {number} b - [description] + * @param {number} tolerance - The tolerance. Anything equal to or less than this value is considered as being within range. + * + * @return {boolean} Returns `true` if `a` is less than or equal to the tolerance of `b`. + */ +var Within = function (a, b, tolerance) +{ + return (Math.abs(a - b) <= tolerance); +}; + +module.exports = Within; + + +/***/ }), +/* 493 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} SinCosTable + * + * @property {number} sin - [description] + * @property {number} cos - [description] + * @property {number} length - [description] + */ + +/** + * [description] + * + * @function Phaser.Math.SinCosTableGenerator + * @since 3.0.0 + * + * @param {number} length - [description] + * @param {number} sinAmp - [description] + * @param {number} cosAmp - [description] + * @param {number} frequency - [description] + * + * @return {SinCosTable} [description] + */ +var SinCosTableGenerator = function (length, sinAmp, cosAmp, frequency) +{ + if (sinAmp === undefined) { sinAmp = 1; } + if (cosAmp === undefined) { cosAmp = 1; } + if (frequency === undefined) { frequency = 1; } + + frequency *= Math.PI / length; + + var cos = []; + var sin = []; + + for (var c = 0; c < length; c++) + { + cosAmp -= sinAmp * frequency; + sinAmp += cosAmp * frequency; + + cos[c] = cosAmp; + sin[c] = sinAmp; + } + + return { + sin: sin, + cos: cos, + length: length + }; +}; + +module.exports = SinCosTableGenerator; + + +/***/ }), +/* 494 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.RoundTo + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {integer} [place=0] - [description] + * @param {integer} [base=10] - [description] + * + * @return {number} [description] + */ +var RoundTo = function (value, place, base) +{ + if (place === undefined) { place = 0; } + if (base === undefined) { base = 10; } + + var p = Math.pow(base, -place); + + return Math.round(value * p) / p; +}; + +module.exports = RoundTo; + + +/***/ }), +/* 495 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.RandomXY + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} vector - [description] + * @param {float} scale - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ +var RandomXY = function (vector, scale) +{ + if (scale === undefined) { scale = 1; } + + var r = Math.random() * 2 * Math.PI; + + vector.x = Math.cos(r) * scale; + vector.y = Math.sin(r) * scale; + + return vector; +}; + +module.exports = RandomXY; + + +/***/ }), +/* 496 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Work out what percentage `value` is of the range between `min` and `max`. + * If `max` isn't given then it will return the percentage of `value` to `min`. + * + * You can optionally specify an `upperMax` value, which is a mid-way point in the range that represents 100%, after which the % starts to go down to zero again. + * + * @function Phaser.Math.Percent + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} min - [description] + * @param {number} [max] - [description] + * @param {number} [upperMax] - [description] + * + * @return {float} A value between 0 and 1 representing the percentage. + */ +var Percent = function (value, min, max, upperMax) +{ + if (max === undefined) { max = min + 1; } + + var percentage = (value - min) / (max - min); + + if (percentage > 1) + { + if (upperMax !== undefined) + { + percentage = ((upperMax - value)) / (upperMax - max); + + if (percentage < 0) + { + percentage = 0; + } + } + else + { + percentage = 1; + } + } + else if (percentage < 0) + { + percentage = 0; + } + + return percentage; +}; + +module.exports = Percent; + + +/***/ }), +/* 497 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.MinSub + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} amount - [description] + * @param {number} min - [description] + * + * @return {number} [description] + */ +var MinSub = function (value, amount, min) +{ + return Math.max(value - amount, min); +}; + +module.exports = MinSub; + + +/***/ }), +/* 498 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.MaxAdd + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} amount - [description] + * @param {number} max - [description] + * + * @return {number} [description] + */ +var MaxAdd = function (value, amount, max) +{ + return Math.min(value + amount, max); +}; + +module.exports = MaxAdd; + + +/***/ }), +/* 499 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.IsEvenStrict + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {boolean} [description] + */ +var IsEvenStrict = function (value) +{ + // Use strict equality === for "is number" test + return (value === parseFloat(value)) ? !(value % 2) : void 0; +}; + +module.exports = IsEvenStrict; + + +/***/ }), +/* 500 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.IsEven + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {boolean} [description] + */ +var IsEven = function (value) +{ + // Use abstract equality == for "is number" test + + // eslint-disable-next-line eqeqeq + return (value == parseFloat(value)) ? !(value % 2) : void 0; +}; + +module.exports = IsEven; + + +/***/ }), +/* 501 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.GetSpeed + * @since 3.0.0 + * + * @param {number} distance - The distance to travel in pixels. + * @param {integer} time - The time, in ms, to cover the distance in. + * + * @return {number} The amount you will need to increment the position by each step in order to cover the distance in the time given. + */ +var GetSpeed = function (distance, time) +{ + return (distance / time) / 1000; +}; + +module.exports = GetSpeed; + + +/***/ }), +/* 502 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.FloorTo + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {integer} [place=0 - [description] + * @param {integer} [base=10] - [description] + * + * @return {number} [description] + */ +var FloorTo = function (value, place, base) +{ + if (place === undefined) { place = 0; } + if (base === undefined) { base = 10; } + + var p = Math.pow(base, -place); + + return Math.floor(value * p) / p; +}; + +module.exports = FloorTo; + + +/***/ }), +/* 503 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Difference + * @since 3.0.0 + * + * @param {number} a - [description] + * @param {number} b - [description] + * + * @return {number} [description] + */ +var Difference = function (a, b) +{ + return Math.abs(a - b); +}; + +module.exports = Difference; + + +/***/ }), +/* 504 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.CeilTo + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} [place=0] - [description] + * @param {integer} [base=10] - [description] + * + * @return {number} [description] + */ +var CeilTo = function (value, place, base) +{ + if (place === undefined) { place = 0; } + if (base === undefined) { base = 10; } + + var p = Math.pow(base, -place); + + return Math.ceil(value * p) / p; +}; + +module.exports = CeilTo; + + +/***/ }), +/* 505 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Average + * @since 3.0.0 + * + * @param {number[]} values - [description] + * + * @return {number} [description] + */ +var Average = function (values) +{ + var sum = 0; + + for (var i = 0; i < values.length; i++) + { + sum += (+values[i]); + } + + return sum / values.length; +}; + +module.exports = Average; + + +/***/ }), +/* 506 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Snap.To + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} gap - [description] + * @param {number} [start=0] - [description] + * + * @return {number} [description] + */ +var SnapTo = function (value, gap, start) +{ + if (start === undefined) { start = 0; } + + if (gap === 0) + { + return value; + } + + value -= start; + value = gap * Math.round(value / gap); + + return start + value; +}; + +module.exports = SnapTo; + + +/***/ }), +/* 507 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Snap.Floor + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} gap - [description] + * @param {number} [start=0] - [description] + * + * @return {number} [description] + */ +var SnapFloor = function (value, gap, start) +{ + if (start === undefined) { start = 0; } + + if (gap === 0) + { + return value; + } + + value -= start; + value = gap * Math.floor(value / gap); + + return start + value; +}; + +module.exports = SnapFloor; + + +/***/ }), +/* 508 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Snap.Ceil + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} gap - [description] + * @param {number} [start=0] - [description] + * + * @return {number} [description] + */ +var SnapCeil = function (value, gap, start) +{ + if (start === undefined) { start = 0; } + + if (gap === 0) + { + return value; + } + + value -= start; + value = gap * Math.ceil(value / gap); + + return start + value; +}; + +module.exports = SnapCeil; + + +/***/ }), +/* 509 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Snap + */ + +module.exports = { + + Ceil: __webpack_require__(508), + Floor: __webpack_require__(507), + To: __webpack_require__(506) + +}; + + +/***/ }), +/* 510 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Tests the value and returns `true` if it is a power of two. + * + * @function Phaser.Math.Pow2.IsValuePowerOfTwo + * @since 3.0.0 + * + * @param {number} value - The value to check if it's a power of two. + * + * @return {boolean} Returns `true` if `value` is a power of two, otherwise `false`. + */ +var IsValuePowerOfTwo = function (value) +{ + return (value > 0 && (value & (value - 1)) === 0); +}; + +module.exports = IsValuePowerOfTwo; + + +/***/ }), +/* 511 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Pow2 + */ + +module.exports = { + + GetNext: __webpack_require__(248), + IsSize: __webpack_require__(145), + IsValue: __webpack_require__(510) + +}; + + +/***/ }), +/* 512 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Linear = __webpack_require__(148); + +/** + * [description] + * + * @function Phaser.Math.Interpolation.Linear + * @since 3.0.0 + * + * @param {float} v - [description] + * @param {number} k - [description] + * + * @return {number} [description] + */ +var LinearInterpolation = function (v, k) +{ + var m = v.length - 1; + var f = m * k; + var i = Math.floor(f); + + if (k < 0) + { + return Linear(v[0], v[1], f); + } + + if (k > 1) + { + return Linear(v[m], v[m - 1], m - f); + } + + return Linear(v[i], v[(i + 1 > m) ? m : i + 1], f - i); +}; + +module.exports = LinearInterpolation; + + +/***/ }), +/* 513 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CatmullRom = __webpack_require__(149); + +/** + * [description] + * + * @function Phaser.Math.Interpolation.CatmullRom + * @since 3.0.0 + * + * @param {number} v - [description] + * @param {number} k - [description] + * + * @return {number} [description] + */ +var CatmullRomInterpolation = function (v, k) +{ + var m = v.length - 1; + var f = m * k; + var i = Math.floor(f); + + if (v[0] === v[m]) + { + if (k < 0) + { + i = Math.floor(f = m * (1 + k)); + } + + return CatmullRom(f - i, v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m]); + } + else + { + if (k < 0) + { + return v[0] - (CatmullRom(-f, v[0], v[0], v[1], v[1]) - v[0]); + } + + if (k > 1) + { + return v[m] - (CatmullRom(f - m, v[m], v[m], v[m - 1], v[m - 1]) - v[m]); + } + + return CatmullRom(f - i, v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2]); + } +}; + +module.exports = CatmullRomInterpolation; + + +/***/ }), +/* 514 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Bernstein = __webpack_require__(219); + +/** + * [description] + * + * @function Phaser.Math.Interpolation.Bezier + * @since 3.0.0 + * + * @param {number} v - [description] + * @param {number} k - [description] + * + * @return {number} [description] + */ +var BezierInterpolation = function (v, k) +{ + var b = 0; + var n = v.length - 1; + + for (var i = 0; i <= n; i++) + { + b += Math.pow(1 - k, n - i) * Math.pow(k, i) * v[i] * Bernstein(n, i); + } + + return b; +}; + +module.exports = BezierInterpolation; + + +/***/ }), +/* 515 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Interpolation + */ + +module.exports = { + Bezier: __webpack_require__(514), + CatmullRom: __webpack_require__(513), + CubicBezier: __webpack_require__(320), + Linear: __webpack_require__(512), + QuadraticBezier: __webpack_require__(315) +}; + + +/***/ }), +/* 516 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Fuzzy.LessThan + * @since 3.0.0 + * + * @param {number} a - [description] + * @param {number} b - [description] + * @param {float} [epsilon=0.0001] - [description] + * + * @return {boolean} [description] + */ +var LessThan = function (a, b, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return a < b + epsilon; +}; + +module.exports = LessThan; + + +/***/ }), +/* 517 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Fuzzy.GreaterThan + * @since 3.0.0 + * + * @param {number} a - [description] + * @param {number} b - [description] + * @param {float} [epsilon=0.0001] - [description] + * + * @return {boolean} [description] + */ +var GreaterThan = function (a, b, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return a > b - epsilon; +}; + +module.exports = GreaterThan; + + +/***/ }), +/* 518 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Fuzzy.Floor + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {float} [epsilon=0.0001] - [description] + * + * @return {number} [description] + */ +var Floor = function (value, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return Math.floor(value + epsilon); +}; + +module.exports = Floor; + + +/***/ }), +/* 519 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Fuzzy.Equal + * @since 3.0.0 + * + * @param {number} a - [description] + * @param {number} b - [description] + * @param {float} [epsilon=0.0001] - [description] + * + * @return {boolean} [description] + */ +var Equal = function (a, b, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return Math.abs(a - b) < epsilon; +}; + +module.exports = Equal; + + +/***/ }), +/* 520 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Fuzzy.Ceil + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {float} [epsilon=0.0001] - [description] + * + * @return {number} [description] + */ +var Ceil = function (value, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return Math.ceil(value - epsilon); +}; + +module.exports = Ceil; + + +/***/ }), +/* 521 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Fuzzy + */ + +module.exports = { + + Ceil: __webpack_require__(520), + Equal: __webpack_require__(519), + Floor: __webpack_require__(518), + GreaterThan: __webpack_require__(517), + LessThan: __webpack_require__(516) + +}; + + +/***/ }), +/* 522 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing + */ + +module.exports = { + + Back: __webpack_require__(262), + Bounce: __webpack_require__(261), + Circular: __webpack_require__(260), + Cubic: __webpack_require__(259), + Elastic: __webpack_require__(258), + Expo: __webpack_require__(257), + Linear: __webpack_require__(256), + Quadratic: __webpack_require__(255), + Quartic: __webpack_require__(254), + Quintic: __webpack_require__(253), + Sine: __webpack_require__(252), + Stepped: __webpack_require__(251) + +}; + + +/***/ }), +/* 523 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Distance.Squared + * @since 3.0.0 + * + * @param {number} x1 - [description] + * @param {number} y1 - [description] + * @param {number} x2 - [description] + * @param {number} y2 - [description] + * + * @return {number} [description] + */ +var DistanceSquared = function (x1, y1, x2, y2) +{ + var dx = x1 - x2; + var dy = y1 - y2; + + return dx * dx + dy * dy; +}; + +module.exports = DistanceSquared; + + +/***/ }), +/* 524 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Distance.Power + * @since 3.0.0 + * + * @param {number} x1 - [description] + * @param {number} y1 - [description] + * @param {number} x2 - [description] + * @param {number} y2 - [description] + * @param {number} pow - [description] + * + * @return {number} [description] + */ +var DistancePower = function (x1, y1, x2, y2, pow) +{ + if (pow === undefined) { pow = 2; } + + return Math.sqrt(Math.pow(x2 - x1, pow) + Math.pow(y2 - y1, pow)); +}; + +module.exports = DistancePower; + + +/***/ }), +/* 525 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Distance + */ + +module.exports = { + + Between: __webpack_require__(48), + Power: __webpack_require__(524), + Squared: __webpack_require__(523) + +}; + + +/***/ }), +/* 526 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Gets the shortest angle between `angle1` and `angle2`. + * Both angles must be in the range -180 to 180, which is the same clamped + * range that `sprite.angle` uses, so you can pass in two sprite angles to + * this method and get the shortest angle back between the two of them. + * + * The angle returned will be in the same range. If the returned angle is + * greater than 0 then it's a counter-clockwise rotation, if < 0 then it's + * a clockwise rotation. + * + * @function Phaser.Math.Angle.ShortestBetween + * @since 3.0.0 + * + * @param {number} angle1 - The first angle in the range -180 to 180. + * @param {number} angle2 - The second angle in the range -180 to 180. + * + * @return {number} The shortest angle, in degrees. If greater than zero it's a counter-clockwise rotation. + */ +var ShortestBetween = function (angle1, angle2) +{ + var difference = angle2 - angle1; + + if (difference === 0) + { + return 0; + } + + var times = Math.floor((difference - (-180)) / 360); + + return difference - (times * 360); + +}; + +module.exports = ShortestBetween; + + +/***/ }), +/* 527 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(16); + +/** + * Rotates `currentAngle` towards `targetAngle`, taking the shortest rotation distance. The `lerp` argument is the amount to rotate by in this call. + * + * @function Phaser.Math.Angle.RotateTo + * @since 3.0.0 + * + * @param {number} currentAngle - The current angle, in radians. + * @param {number} targetAngle - The target angle to rotate to, in radians. + * @param {number} [lerp=0.05] - The lerp value to add to the current angle. + * + * @return {number} The adjusted angle. + */ +var RotateTo = function (currentAngle, targetAngle, lerp) +{ + if (lerp === undefined) { lerp = 0.05; } + + if (currentAngle === targetAngle) + { + return currentAngle; + } + + if (Math.abs(targetAngle - currentAngle) <= lerp || Math.abs(targetAngle - currentAngle) >= (MATH_CONST.PI2 - lerp)) + { + currentAngle = targetAngle; + } + else + { + if (Math.abs(targetAngle - currentAngle) > Math.PI) + { + if (targetAngle < currentAngle) + { + targetAngle += MATH_CONST.PI2; + } + else + { + targetAngle -= MATH_CONST.PI2; + } + } + + if (targetAngle > currentAngle) + { + currentAngle += lerp; + } + else if (targetAngle < currentAngle) + { + currentAngle -= lerp; + } + } + + return currentAngle; +}; + +module.exports = RotateTo; + + +/***/ }), +/* 528 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Normalize = __webpack_require__(220); + +/** + * [description] + * + * @function Phaser.Math.Angle.Reverse + * @since 3.0.0 + * + * @param {number} angle - [description] + * + * @return {number} [description] + */ +var Reverse = function (angle) +{ + return Normalize(angle + Math.PI); +}; + +module.exports = Reverse; + + +/***/ }), +/* 529 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Angle.BetweenPointsY + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point1 - [description] + * @param {(Phaser.Geom.Point|object)} point2 - [description] + * + * @return {number} [description] + */ +var BetweenPointsY = function (point1, point2) +{ + return Math.atan2(point2.x - point1.x, point2.y - point1.y); +}; + +module.exports = BetweenPointsY; + + +/***/ }), +/* 530 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Angle.BetweenPoints + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point1 - [description] + * @param {(Phaser.Geom.Point|object)} point2 - [description] + * + * @return {number} [description] + */ +var BetweenPoints = function (point1, point2) +{ + return Math.atan2(point2.y - point1.y, point2.x - point1.x); +}; + +module.exports = BetweenPoints; + + +/***/ }), +/* 531 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Angle.BetweenY + * @since 3.0.0 + * + * @param {number} x1 - [description] + * @param {number} y1 - [description] + * @param {number} x2 - [description] + * @param {number} y2 - [description] + * + * @return {number} [description] + */ +var BetweenY = function (x1, y1, x2, y2) +{ + return Math.atan2(x2 - x1, y2 - y1); +}; + +module.exports = BetweenY; + + +/***/ }), +/* 532 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.Angle.Between + * @since 3.0.0 + * + * @param {number} x1 - [description] + * @param {number} y1 - [description] + * @param {number} x2 - [description] + * @param {number} y2 - [description] + * + * @return {number} [description] + */ +var Between = function (x1, y1, x2, y2) +{ + return Math.atan2(y2 - y1, x2 - x1); +}; + +module.exports = Between; + + +/***/ }), +/* 533 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Angle + */ + +module.exports = { + + Between: __webpack_require__(532), + BetweenY: __webpack_require__(531), + BetweenPoints: __webpack_require__(530), + BetweenPointsY: __webpack_require__(529), + Reverse: __webpack_require__(528), + RotateTo: __webpack_require__(527), + ShortestBetween: __webpack_require__(526), + Normalize: __webpack_require__(220), + Wrap: __webpack_require__(175), + WrapDegrees: __webpack_require__(174) + +}; + + +/***/ }), +/* 534 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(16); +var Extend = __webpack_require__(18); + +/** + * @namespace Phaser.Math + */ + +var PhaserMath = { + + // Collections of functions + Angle: __webpack_require__(533), + Distance: __webpack_require__(525), + Easing: __webpack_require__(522), + Fuzzy: __webpack_require__(521), + Interpolation: __webpack_require__(515), + Pow2: __webpack_require__(511), + Snap: __webpack_require__(509), + + // Single functions + Average: __webpack_require__(505), + Bernstein: __webpack_require__(219), + Between: __webpack_require__(308), + CatmullRom: __webpack_require__(149), + CeilTo: __webpack_require__(504), + Clamp: __webpack_require__(64), + DegToRad: __webpack_require__(42), + Difference: __webpack_require__(503), + Factorial: __webpack_require__(218), + FloatBetween: __webpack_require__(263), + FloorTo: __webpack_require__(502), + FromPercent: __webpack_require__(78), + GetSpeed: __webpack_require__(501), + IsEven: __webpack_require__(500), + IsEvenStrict: __webpack_require__(499), + Linear: __webpack_require__(148), + MaxAdd: __webpack_require__(498), + MinSub: __webpack_require__(497), + Percent: __webpack_require__(496), + RadToDeg: __webpack_require__(318), + RandomXY: __webpack_require__(495), + RandomXYZ: __webpack_require__(330), + RandomXYZW: __webpack_require__(329), + Rotate: __webpack_require__(217), + RotateAround: __webpack_require__(350), + RotateAroundDistance: __webpack_require__(160), + RoundAwayFromZero: __webpack_require__(216), + RoundTo: __webpack_require__(494), + SinCosTableGenerator: __webpack_require__(493), + SmootherStep: __webpack_require__(343), + SmoothStep: __webpack_require__(342), + TransformXY: __webpack_require__(288), + Within: __webpack_require__(492), + Wrap: __webpack_require__(43), + + // Vector classes + Vector2: __webpack_require__(6), + Vector3: __webpack_require__(57), + Vector4: __webpack_require__(152), + Matrix3: __webpack_require__(326), + Matrix4: __webpack_require__(153), + Quaternion: __webpack_require__(327), + RotateVec3: __webpack_require__(328) + +}; + +// Merge in the consts + +PhaserMath = Extend(false, PhaserMath, CONST); + +// Export it + +module.exports = PhaserMath; + + +/***/ }), +/* 535 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var CustomSet = __webpack_require__(63); +var EventEmitter = __webpack_require__(15); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var ParseXMLBitmapFont = __webpack_require__(270); +var PluginManager = __webpack_require__(12); +var XHRSettings = __webpack_require__(94); + +/** + * @typedef {object} LoaderFileObject + * + * @property {string} key - [description] + * @property {string} type - [description] + * @property {string} [url] - [description] + * @property {string[]} [urls] - [description] + * @property {string} [textureURL] - [description] + * @property {string} [atlasURL] - [description] + * @property {string} [xmlURL] - [description] + * @property {string[]} [textureURLs] - [description] + * @property {string[]} [atlasURLs] - [description] + * @property {object} [config] - [description] + * @property {object} [json] - [description] + * @property {XHRSettingsObject} [xhrSettings] - [description] + * @property {XHRSettingsObject} [textureXhrSettings] - [description] + * @property {XHRSettingsObject} [atlasXhrSettings] - [description] + * @property {XHRSettingsObject} [xmlXhrSettings] - [description] + * @property {XHRSettingsObject} [audioXhrSettings] - [description] + * @property {XHRSettingsObject} [jsonXhrSettings] - [description] + */ + +/** + * @classdesc + * [description] + * + * @class LoaderPlugin + * @extends EventEmitter + * @memberOf Phaser.Loader + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ +var LoaderPlugin = new Class({ + + Extends: EventEmitter, + + initialize: + + function LoaderPlugin (scene) + { + EventEmitter.call(this); + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + if (!scene.sys.settings.isBooted) + { + scene.sys.events.once('boot', this.boot, this); + } + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#_multilist + * @type {object} + * @private + * @default {} + * @since 3.0.0 + */ + this._multilist = {}; + + // Inject the available filetypes into the Loader + FileTypesManager.install(this); + + var gameConfig = this.systems.game.config; + var sceneConfig = this.systems.settings.loader; + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#path + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.path = ''; + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#baseURL + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.baseURL = ''; + + this.setBaseURL(GetFastValue(sceneConfig, 'baseURL', gameConfig.loaderBaseURL)); + + this.setPath(GetFastValue(sceneConfig, 'path', gameConfig.loaderPath)); + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#enableParallel + * @type {boolean} + * @since 3.0.0 + */ + this.enableParallel = GetFastValue(sceneConfig, 'enableParallel', gameConfig.loaderEnableParallel); + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#maxParallelDownloads + * @type {integer} + * @since 3.0.0 + */ + this.maxParallelDownloads = GetFastValue(sceneConfig, 'maxParallelDownloads', gameConfig.loaderMaxParallelDownloads); + + /** + * xhr specific global settings (can be overridden on a per-file basis) + * + * @name Phaser.Loader.LoaderPlugin#xhr + * @type {XHRSettingsObject} + * @since 3.0.0 + */ + this.xhr = XHRSettings( + GetFastValue(sceneConfig, 'responseType', gameConfig.loaderResponseType), + GetFastValue(sceneConfig, 'async', gameConfig.loaderAsync), + GetFastValue(sceneConfig, 'user', gameConfig.loaderUser), + GetFastValue(sceneConfig, 'password', gameConfig.loaderPassword), + GetFastValue(sceneConfig, 'timeout', gameConfig.loaderTimeout) + ); + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#crossOrigin + * @type {string} + * @since 3.0.0 + */ + this.crossOrigin = GetFastValue(sceneConfig, 'crossOrigin', gameConfig.loaderCrossOrigin); + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#totalToLoad + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalToLoad = 0; + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#progress + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.progress = 0; + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#list + * @type {Phaser.Structs.Set} + * @since 3.0.0 + */ + this.list = new CustomSet(); + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#inflight + * @type {Phaser.Structs.Set} + * @since 3.0.0 + */ + this.inflight = new CustomSet(); + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#failed + * @type {Phaser.Structs.Set} + * @since 3.0.0 + */ + this.failed = new CustomSet(); + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#queue + * @type {Phaser.Structs.Set} + * @since 3.0.0 + */ + this.queue = new CustomSet(); + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#storage + * @type {Phaser.Structs.Set} + * @since 3.0.0 + */ + this.storage = new CustomSet(); + + /** + * [description] + * + * @name Phaser.Loader.LoaderPlugin#state + * @type {integer} + * @since 3.0.0 + */ + this.state = CONST.LOADER_IDLE; + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#boot + * @since 3.0.0 + */ + boot: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#setBaseURL + * @since 3.0.0 + * + * @param {string} url - [description] + * + * @return {Phaser.Loader.LoaderPlugin} This Loader object. + */ + setBaseURL: function (url) + { + if (url !== '' && url.substr(-1) !== '/') + { + url = url.concat('/'); + } + + this.baseURL = url; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#setPath + * @since 3.0.0 + * + * @param {string} path - [description] + * + * @return {Phaser.Loader.LoaderPlugin} This Loader object. + */ + setPath: function (path) + { + if (path !== '' && path.substr(-1) !== '/') + { + path = path.concat('/'); + } + + this.path = path; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#setCORS + * @since 3.0.0 + * + * @param {string} crossOrigin - [description] + * + * @return {Phaser.Loader.LoaderPlugin} This Loader object. + */ + setCORS: function (crossOrigin) + { + this.crossOrigin = crossOrigin; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#addFile + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - [description] + * + * @return {Phaser.Loader.File} [description] + */ + addFile: function (file) + { + if (!this.isReady()) + { + return -1; + } + + file.path = this.path; + + this.list.set(file); + + return file; + }, + + /** + * Is the Loader actively loading (or processing loaded files) + * + * @method Phaser.Loader.LoaderPlugin#isLoading + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isLoading: function () + { + return (this.state === CONST.LOADER_LOADING || this.state === CONST.LOADER_PROCESSING); + }, + + /** + * Is the Loader ready to start a new load? + * + * @method Phaser.Loader.LoaderPlugin#isReady + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isReady: function () + { + return (this.state === CONST.LOADER_IDLE || this.state === CONST.LOADER_COMPLETE || this.state === CONST.LOADER_FAILED); + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#start + * @since 3.0.0 + */ + start: function () + { + if (!this.isReady()) + { + return; + } + + this.progress = 0; + this.totalToLoad = this.list.size; + + this.emit('start', this); + + if (this.list.size === 0) + { + this.finishedLoading(); + } + else + { + this.state = CONST.LOADER_LOADING; + + this.failed.clear(); + this.inflight.clear(); + this.queue.clear(); + + this.queue.debug = true; + + this.updateProgress(); + + this.processLoadQueue(); + } + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#updateProgress + * @since 3.0.0 + */ + updateProgress: function () + { + this.progress = 1 - ((this.list.size + this.inflight.size) / this.totalToLoad); + + this.emit('progress', this.progress); + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#processLoadQueue + * @since 3.0.0 + */ + processLoadQueue: function () + { + this.list.each(function (file) + { + if (file.state === CONST.FILE_POPULATED || (file.state === CONST.FILE_PENDING && this.inflight.size < this.maxParallelDownloads)) + { + this.inflight.set(file); + + this.list.delete(file); + + this.loadFile(file); + } + + if (this.inflight.size === this.maxParallelDownloads) + { + // Tells the Set iterator to abort + return false; + } + + }, this); + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#loadFile + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - [description] + */ + loadFile: function (file) + { + // If the file doesn't have its own crossOrigin set, + // we'll use the Loaders (which is undefined by default) + if (!file.crossOrigin) + { + file.crossOrigin = this.crossOrigin; + } + + file.load(this); + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#nextFile + * @since 3.0.0 + * + * @param {Phaser.Loader.File} previousFile - [description] + * @param {boolean} success - [description] + */ + nextFile: function (previousFile, success) + { + // Move the file that just loaded from the inflight list to the queue or failed Set + + if (success) + { + this.emit('load', previousFile); + this.queue.set(previousFile); + } + else + { + this.emit('loaderror', previousFile); + this.failed.set(previousFile); + } + + this.inflight.delete(previousFile); + + this.updateProgress(); + + if (this.list.size > 0) + { + this.processLoadQueue(); + } + else if (this.inflight.size === 0) + { + this.finishedLoading(); + } + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#finishedLoading + * @since 3.0.0 + */ + finishedLoading: function () + { + if (this.state === CONST.LOADER_PROCESSING) + { + return; + } + + this.progress = 1; + + this.state = CONST.LOADER_PROCESSING; + + this.storage.clear(); + + if (this.queue.size === 0) + { + // Everything failed, so nothing to process + this.processComplete(); + } + else + { + this.queue.each(function (file) + { + file.onProcess(this.processUpdate.bind(this)); + }, this); + } + }, + + /** + * Called automatically by the File when it has finished processing. + * + * @method Phaser.Loader.LoaderPlugin#processUpdate + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - [description] + */ + processUpdate: function (file) + { + // This file has failed to load, so move it to the failed Set + if (file.state === CONST.FILE_ERRORED) + { + this.failed.set(file); + + if (file.linkFile) + { + this.queue.delete(file.linkFile); + } + + return this.removeFromQueue(file); + } + + // If we got here, then the file loaded + + // Special handling for multi-part files + + if (file.linkFile) + { + if (file.state === CONST.FILE_COMPLETE && file.linkFile.state === CONST.FILE_COMPLETE) + { + // Partner has loaded, so add them both to Storage + + this.storage.set({ type: file.linkType, fileA: file, fileB: file.linkFile }); + + this.queue.delete(file.linkFile); + + this.removeFromQueue(file); + } + } + else + { + this.storage.set(file); + + this.removeFromQueue(file); + } + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#removeFromQueue + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - [description] + */ + removeFromQueue: function (file) + { + this.queue.delete(file); + + if (this.queue.size === 0 && this.state === CONST.LOADER_PROCESSING) + { + // We've processed all the files we loaded + this.processComplete(); + } + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#processComplete + * @since 3.0.0 + */ + processComplete: function () + { + this.list.clear(); + this.inflight.clear(); + this.queue.clear(); + + this.processCallback(); + + this.state = CONST.LOADER_COMPLETE; + + this.emit('complete', this, this.storage.size, this.failed.size); + + // Move to a User setting: + // this.removeAllListeners(); + }, + + /** + * The Loader has finished. + * + * @method Phaser.Loader.LoaderPlugin#processCallback + * @since 3.0.0 + */ + processCallback: function () + { + if (this.storage.size === 0) + { + return; + } + + // The global Texture Manager + var cache = this.scene.sys.cache; + var textures = this.scene.sys.textures; + var anims = this.scene.sys.anims; + + // Process multiatlas groups first + + var file; + var fileA; + var fileB; + + for (var key in this._multilist) + { + var data = []; + var images = []; + var keys = this._multilist[key]; + + for (var i = 0; i < keys.length; i++) + { + file = this.storage.get('key', keys[i]); + + if (file) + { + if (file.type === 'image') + { + images.push(file.data); + } + else if (file.type === 'json') + { + data.push(file.data); + } + + this.storage.delete(file); + } + } + + // Do we have everything needed? + if (images.length + data.length === keys.length) + { + // Yup, add them to the Texture Manager + + // Is the data JSON Hash or JSON Array? + if (Array.isArray(data[0].textures) || Array.isArray(data[0].frames)) + { + textures.addAtlasJSONArray(key, images, data); + } + else + { + textures.addAtlasJSONHash(key, images, data); + } + } + } + + // Process all of the files + + // Because AnimationJSON may require images to be loaded first, we process them last + var animJSON = []; + + this.storage.each(function (file) + { + switch (file.type) + { + case 'animationJSON': + animJSON.push(file); + break; + + case 'image': + case 'svg': + case 'html': + textures.addImage(file.key, file.data); + break; + + case 'atlasjson': + + fileA = file.fileA; + fileB = file.fileB; + + if (fileA.type === 'image') + { + textures.addAtlas(fileA.key, fileA.data, fileB.data); + } + else + { + textures.addAtlas(fileB.key, fileB.data, fileA.data); + } + break; + + case 'dataimage': + + fileA = file.fileA; + fileB = file.fileB; + + if (fileA.linkParent) + { + textures.addImage(fileA.key, fileA.data, fileB.data); + } + else + { + textures.addImage(fileB.key, fileB.data, fileA.data); + } + break; + + case 'unityatlas': + + fileA = file.fileA; + fileB = file.fileB; + + if (fileA.type === 'image') + { + textures.addUnityAtlas(fileA.key, fileA.data, fileB.data); + } + else + { + textures.addUnityAtlas(fileB.key, fileB.data, fileA.data); + } + break; + + case 'bitmapfont': + + fileA = file.fileA; + fileB = file.fileB; + + if (fileA.type === 'image') + { + cache.bitmapFont.add(fileB.key, { data: ParseXMLBitmapFont(fileB.data), texture: fileA.key, frame: null }); + textures.addImage(fileA.key, fileA.data); + } + else + { + cache.bitmapFont.add(fileA.key, { data: ParseXMLBitmapFont(fileA.data), texture: fileB.key, frame: null }); + textures.addImage(fileB.key, fileB.data); + } + break; + + case 'spritesheet': + textures.addSpriteSheet(file.key, file.data, file.config); + break; + + case 'json': + cache.json.add(file.key, file.data); + break; + + case 'xml': + cache.xml.add(file.key, file.data); + break; + + case 'text': + cache.text.add(file.key, file.data); + break; + + case 'obj': + cache.obj.add(file.key, file.data); + break; + + case 'binary': + cache.binary.add(file.key, file.data); + break; + + case 'audio': + cache.audio.add(file.key, file.data); + break; + + case 'audioSprite': + + var files = [ file.fileA, file.fileB ]; + + files.forEach(function (file) + { + cache[file.type].add(file.key, file.data); + }); + + break; + + case 'glsl': + cache.shader.add(file.key, file.data); + break; + + case 'tilemapCSV': + case 'tilemapJSON': + cache.tilemap.add(file.key, { format: file.tilemapFormat, data: file.data }); + break; + } + }); + + animJSON.forEach(function (file) + { + anims.fromJSON(file.data); + }); + + this.storage.clear(); + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#saveJSON + * @since 3.0.0 + * + * @param {*} data - [description] + * @param {string} [filename=file.json] - [description] + * + * @return {Phaser.Loader.LoaderPlugin} This Loader plugin. + */ + saveJSON: function (data, filename) + { + return this.save(JSON.stringify(data), filename); + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#save + * @since 3.0.0 + * + * @param {*} data - [description] + * @param {string} [filename=file.json] - [description] + * @param {string} [filetype=application/json] - [description] + * + * @return {Phaser.Loader.LoaderPlugin} This Loader plugin. + */ + save: function (data, filename, filetype) + { + if (filename === undefined) { filename = 'file.json'; } + if (filetype === undefined) { filetype = 'application/json'; } + + var blob = new Blob([ data ], { type: filetype }); + + var url = URL.createObjectURL(blob); + + var a = document.createElement('a'); + + a.download = filename; + a.textContent = 'Download ' + filename; + a.href = url; + a.click(); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#reset + * @since 3.0.0 + */ + reset: function () + { + this.list.clear(); + this.inflight.clear(); + this.failed.clear(); + this.queue.clear(); + this.storage.clear(); + + var gameConfig = this.systems.game.config; + var sceneConfig = this.systems.settings.loader; + + this.setBaseURL(GetFastValue(sceneConfig, 'baseURL', gameConfig.loaderBaseURL)); + this.setPath(GetFastValue(sceneConfig, 'path', gameConfig.loaderPath)); + + this.state = CONST.LOADER_IDLE; + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#loadArray + * @since 3.0.0 + * + * @param {LoaderFileObject[]} files - [description] + * + * @return {boolean} [description] + */ + loadArray: function (files) + { + if (Array.isArray(files)) + { + for (var i = 0; i < files.length; i++) + { + this.file(files[i]); + } + } + + return (this.list.size > 0); + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#file + * @since 3.0.0 + * + * @param {LoaderFileObject} file - [description] + * + * @return {Phaser.Loader.File} [description] + */ + file: function (file) + { + var entry; + var key = file.key; + + switch (file.type) + { + case 'spritesheet': + entry = this.spritesheet(key, file.url, file.config, file.xhrSettings); + break; + + case 'atlas': + entry = this.atlas(key, file.textureURL, file.atlasURL, file.textureXhrSettings, file.atlasXhrSettings); + break; + + case 'bitmapFont': + entry = this.bitmapFont(key, file.textureURL, file.xmlURL, file.textureXhrSettings, file.xmlXhrSettings); + break; + + case 'multiatlas': + entry = this.multiatlas(key, file.textureURLs, file.atlasURLs, file.textureXhrSettings, file.atlasXhrSettings); + break; + + case 'audioSprite': + entry = this.audioSprite(key, file.urls, file.json, file.config, file.audioXhrSettings, file.jsonXhrSettings); + break; + + // image, json, xml, binary, text, glsl, svg, obj + default: + entry = this[file.type](key, file.url, file.xhrSettings); + break; + } + + return entry; + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.reset(); + this.state = CONST.LOADER_SHUTDOWN; + }, + + /** + * [description] + * + * @method Phaser.Loader.LoaderPlugin#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.reset(); + this.state = CONST.LOADER_DESTROYED; + } + +}); + +PluginManager.register('Loader', LoaderPlugin, 'load'); + +module.exports = LoaderPlugin; + + +/***/ }), +/* 536 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FileTypesManager = __webpack_require__(7); +var ImageFile = __webpack_require__(50); +var TextFile = __webpack_require__(221); + +/** + * An Atlas JSON File. + * + * @function Phaser.Loader.FileTypes.UnityAtlasFile + * @since 3.0.0 + * + * @param {string} key - The key of the file within the loader. + * @param {string} textureURL - The url to load the texture file from. + * @param {string} atlasURL - The url to load the atlas file from. + * @param {string} path - The path of the file. + * @param {XHRSettingsObject} textureXhrSettings - Optional texture file specific XHR settings. + * @param {XHRSettingsObject} atlasXhrSettings - Optional atlas file specific XHR settings. + * + * @return {object} An object containing two File objects to be added to the loader. + */ +var UnityAtlasFile = function (key, textureURL, atlasURL, path, textureXhrSettings, atlasXhrSettings) +{ + var image = new ImageFile(key, textureURL, path, textureXhrSettings); + var data = new TextFile(key, atlasURL, path, atlasXhrSettings); + + // Link them together + image.linkFile = data; + data.linkFile = image; + + // Set the type + image.linkType = 'unityatlas'; + data.linkType = 'unityatlas'; + + return { texture: image, data: data }; +}; + +/** + * Adds a Unity Texture Atlas file to the current load queue. + * + * Note: This method will only be available if the Unity Atlas File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#unityAtlas + * @since 3.0.0 + * + * @param {string} key - The key of the file within the loader. + * @param {string} textureURL - The url to load the texture file from. + * @param {string} atlasURL - The url to load the atlas file from. + * @param {XHRSettingsObject} textureXhrSettings - Optional texture file specific XHR settings. + * @param {XHRSettingsObject} atlasXhrSettings - Optional atlas file specific XHR settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('unityAtlas', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) +{ + // Returns an object with two properties: 'texture' and 'data' + var files = new UnityAtlasFile(key, textureURL, atlasURL, this.path, textureXhrSettings, atlasXhrSettings); + + this.addFile(files.texture); + this.addFile(files.data); + + return this; + +}); + +module.exports = UnityAtlasFile; + + +/***/ }), +/* 537 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FileTypesManager = __webpack_require__(7); +var JSONFile = __webpack_require__(51); +var TILEMAP_FORMATS = __webpack_require__(24); + +/** + * A Tilemap File. + * + * @function Phaser.Loader.FileTypes.TilemapJSONFile + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {string} format - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {object} An object containing two File objects to be added to the loader. + */ +var TilemapJSONFile = function (key, url, path, format, xhrSettings) +{ + var json = new JSONFile(key, url, path, xhrSettings); + + // Override the File type + json.type = 'tilemapJSON'; + + json.tilemapFormat = format; + + return json; +}; + +/** + * Adds a Tilemap (Tiled JSON Format) file to the current load queue. + * + * Note: This method will only be available if the Tilemap File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#tilemapTiledJSON + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('tilemapTiledJSON', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(TilemapJSONFile(key[i], url, this.path, TILEMAP_FORMATS.TILED_JSON, xhrSettings)); + } + } + else + { + this.addFile(TilemapJSONFile(key, url, this.path, TILEMAP_FORMATS.TILED_JSON, xhrSettings)); + } + + // For method chaining + return this; +}); + +/** + * Adds a Tilemap (Weltmeister Format) file to the current load queue. + * + * Note: This method will only be available if the Tilemap File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#tilemapWeltmeister + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('tilemapWeltmeister', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(TilemapJSONFile(key[i], url, this.path, TILEMAP_FORMATS.WELTMEISTER, xhrSettings)); + } + } + else + { + this.addFile(TilemapJSONFile(key, url, this.path, TILEMAP_FORMATS.WELTMEISTER, xhrSettings)); + } + + // For method chaining + return this; +}); + +module.exports = TilemapJSONFile; + + +/***/ }), +/* 538 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); +var TILEMAP_FORMATS = __webpack_require__(24); + +/** + * @classdesc + * [description] + * + * @class TilemapCSVFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {string} format - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + */ +var TilemapCSVFile = new Class({ + + Extends: File, + + initialize: + + function TilemapCSVFile (key, url, path, format, xhrSettings) + { + var fileConfig = { + type: 'tilemapCSV', + extension: '.csv', + responseType: 'text', + key: key, + url: url, + path: path, + xhrSettings: xhrSettings + }; + + File.call(this, fileConfig); + + this.tilemapFormat = format; + }, + + onProcess: function (callback) + { + this.state = CONST.FILE_PROCESSING; + + this.data = this.xhrLoader.responseText; + + this.onComplete(); + + callback(this); + } + +}); + +/** + * Adds a Tilemap CSV file to the current load queue. + * + * Note: This method will only be available if the Tilemap CSV File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#tilemapCSV + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('tilemapCSV', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new TilemapCSVFile(key[i], url, this.path, TILEMAP_FORMATS.CSV, xhrSettings)); + } + } + else + { + this.addFile(new TilemapCSVFile(key, url, this.path, TILEMAP_FORMATS.CSV, xhrSettings)); + } + + // For method chaining + return this; +}); + +module.exports = TilemapCSVFile; + + +/***/ }), +/* 539 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); + +/** + * @classdesc + * [description] + * + * @class SVGFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + */ +var SVGFile = new Class({ + + Extends: File, + + initialize: + + function SVGFile (key, url, path, xhrSettings) + { + var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); + + var fileConfig = { + type: 'svg', + extension: GetFastValue(key, 'extension', 'svg'), + responseType: 'text', + key: fileKey, + url: GetFastValue(key, 'file', url), + path: path, + xhrSettings: GetFastValue(key, 'xhr', xhrSettings) + }; + + File.call(this, fileConfig); + }, + + onProcess: function (callback) + { + this.state = CONST.FILE_PROCESSING; + + var svg = [ this.xhrLoader.responseText ]; + var _this = this; + + try + { + var blob = new window.Blob(svg, { type: 'image/svg+xml;charset=utf-8' }); + } + catch (e) + { + _this.state = CONST.FILE_ERRORED; + + callback(_this); + + return; + } + + this.data = new Image(); + + this.data.crossOrigin = this.crossOrigin; + + var retry = false; + + this.data.onload = function () + { + if(!retry) + { + File.revokeObjectURL(_this.data); + } + + _this.onComplete(); + + callback(_this); + }; + + this.data.onerror = function () + { + // Safari 8 re-try + if (!retry) + { + retry = true; + + File.revokeObjectURL(_this.data); + + _this.data.src = 'data:image/svg+xml,' + encodeURIComponent(svg.join('')); + } + else + { + _this.state = CONST.FILE_ERRORED; + + callback(_this); + } + }; + + File.createObjectURL(this.data, blob, 'image/svg+xml'); + } + +}); + +/** + * Adds an SVG file to the current load queue. + * + * Note: This method will only be available if the SVG File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#svg + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('svg', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new SVGFile(key[i], url, this.path, xhrSettings)); + } + } + else + { + this.addFile(new SVGFile(key, url, this.path, xhrSettings)); + } + + // For method chaining + return this; +}); + +module.exports = SVGFile; + + +/***/ }), +/* 540 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FileTypesManager = __webpack_require__(7); +var ImageFile = __webpack_require__(50); + +/** + * A Sprite Sheet File. + * + * @function Phaser.Loader.FileTypes.SpriteSheetFile + * @since 3.0.0 + * + * @param {string} key - The key of the file within the loader. + * @param {string} url - The url to load the texture file from. + * @param {object} config - Optional texture file specific XHR settings. + * @param {string} path - Optional texture file specific XHR settings. + * @param {XHRSettingsObject} xhrSettings - Optional atlas file specific XHR settings. + * + * @return {object} An object containing two File objects to be added to the loader. + */ +var SpriteSheetFile = function (key, url, config, path, xhrSettings) +{ + var image = new ImageFile(key, url, path, xhrSettings, config); + + // Override the File type + image.type = 'spritesheet'; + + return image; +}; + +/** + * Adds a Sprite Sheet file to the current load queue. + * + * Note: This method will only be available if the Sprite Sheet File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#spritesheet + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {object} config - config can include: frameWidth, frameHeight, startFrame, endFrame, margin, spacing. + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('spritesheet', function (key, url, config, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new SpriteSheetFile(key[i], url, null, this.path, xhrSettings)); + } + } + else + { + this.addFile(new SpriteSheetFile(key, url, config, this.path, xhrSettings)); + } + + // For method chaining + return this; +}); + +module.exports = SpriteSheetFile; + + +/***/ }), +/* 541 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); + +/** + * @classdesc + * [description] + * + * @class ScriptFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + */ +var ScriptFile = new Class({ + + Extends: File, + + initialize: + + function ScriptFile (key, url, path, xhrSettings) + { + var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); + + var fileConfig = { + type: 'script', + extension: GetFastValue(key, 'extension', 'js'), + responseType: 'text', + key: fileKey, + url: GetFastValue(key, 'file', url), + path: path, + xhrSettings: GetFastValue(key, 'xhr', xhrSettings) + }; + + File.call(this, fileConfig); + }, + + onProcess: function (callback) + { + this.state = CONST.FILE_PROCESSING; + + this.data = document.createElement('script'); + this.data.language = 'javascript'; + this.data.type = 'text/javascript'; + this.data.defer = false; + this.data.text = this.xhrLoader.responseText; + + document.head.appendChild(this.data); + + this.onComplete(); + + callback(this); + } + +}); + +/** + * Adds a JavaScript file to the current load queue. + * + * Note: This method will only be available if the Script File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#script + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('script', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new ScriptFile(key[i], url, this.path, xhrSettings)); + } + } + else + { + this.addFile(new ScriptFile(key, url, this.path, xhrSettings)); + } + + // For method chaining + return this; +}); + +module.exports = ScriptFile; + + +/***/ }), +/* 542 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var PluginManager = __webpack_require__(12); + +/** + * @classdesc + * [description] + * + * @class PluginFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + */ +var PluginFile = new Class({ + + Extends: File, + + initialize: + + function PluginFile (key, url, path, xhrSettings) + { + // If the url variable refers to a class, add the plugin directly + if (typeof url === 'function') + { + this.key = key; + window[key] = url; + window[key].register(PluginManager); + } + + var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); + + var fileConfig = { + type: 'script', + extension: GetFastValue(key, 'extension', 'js'), + responseType: 'text', + key: fileKey, + url: GetFastValue(key, 'file', url), + path: path, + xhrSettings: GetFastValue(key, 'xhr', xhrSettings) + }; + + File.call(this, fileConfig); + }, + + onProcess: function (callback) + { + this.state = CONST.FILE_PROCESSING; + + this.data = document.createElement('script'); + this.data.language = 'javascript'; + this.data.type = 'text/javascript'; + this.data.defer = false; + this.data.text = this.xhrLoader.responseText; + + document.head.appendChild(this.data); + + // Need to wait for onload? + window[this.key].register(PluginManager); + + this.onComplete(); + + callback(this); + } + +}); + +/** + * Adds a Plugin file to the current load queue. + * + * Note: This method will only be available if the Plugin File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#plugin + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('plugin', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new PluginFile(key[i], url, this.path, xhrSettings)); + } + } + else + { + this.addFile(new PluginFile(key, url, this.path, xhrSettings)); + } + + // For method chaining + return this; +}); + +module.exports = PluginFile; + + +/***/ }), +/* 543 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FileTypesManager = __webpack_require__(7); +var ImageFile = __webpack_require__(50); +var JSONFile = __webpack_require__(51); +var NumberArray = __webpack_require__(222); + +/** + * Adds a Multi File Texture Atlas to the current load queue. + * + * Note: This method will only be available if the Multi Atlas File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#multiatlas + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string[]} textureURLs - [description] + * @param {string[]} atlasURLs - [description] + * @param {XHRSettingsObject} textureXhrSettings - [description] + * @param {XHRSettingsObject} atlasXhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('multiatlas', function (key, textureURLs, atlasURLs, textureXhrSettings, atlasXhrSettings) +{ + if (typeof textureURLs === 'number') + { + var total = textureURLs; + var suffix = (atlasURLs === undefined) ? '' : atlasURLs; + + textureURLs = NumberArray(0, total, key + suffix, '.png'); + atlasURLs = NumberArray(0, total, key + suffix, '.json'); + } + else + { + if (!Array.isArray(textureURLs)) + { + textureURLs = [ textureURLs ]; + } + + if (!Array.isArray(atlasURLs)) + { + atlasURLs = [ atlasURLs ]; + } + } + + var file; + var i = 0; + var multiKey; + + this._multilist[key] = []; + + for (i = 0; i < textureURLs.length; i++) + { + multiKey = '_MA_IMG_' + key + '_' + i.toString(); + + file = new ImageFile(multiKey, textureURLs[i], this.path, textureXhrSettings); + + this.addFile(file); + + this._multilist[key].push(multiKey); + } + + for (i = 0; i < atlasURLs.length; i++) + { + multiKey = '_MA_JSON_' + key + '_' + i.toString(); + + file = new JSONFile(multiKey, atlasURLs[i], this.path, atlasXhrSettings); + + this.addFile(file); + + this._multilist[key].push(multiKey); + } + + return this; +}); + + +/***/ }), +/* 544 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); + +/** + * @classdesc + * [description] + * + * @class HTMLFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {string} path - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + */ +var HTMLFile = new Class({ + + Extends: File, + + initialize: + + function HTMLFile (key, url, width, height, path, xhrSettings) + { + if (width === undefined) { width = 512; } + if (height === undefined) { height = 512; } + + var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); + + var fileConfig = { + type: 'html', + extension: GetFastValue(key, 'extension', 'html'), + responseType: 'text', + key: fileKey, + url: GetFastValue(key, 'file', url), + path: path, + xhrSettings: GetFastValue(key, 'xhr', xhrSettings), + config: { + width: width, + height: height + } + }; + + File.call(this, fileConfig); + }, + + onProcess: function (callback) + { + this.state = CONST.FILE_PROCESSING; + + var w = this.config.width; + var h = this.config.height; + + var data = []; + + data.push(''); + data.push(''); + data.push(''); + data.push(this.xhrLoader.responseText); + data.push(''); + data.push(''); + data.push(''); + + var svg = [ data.join('\n') ]; + var _this = this; + + try + { + var blob = new window.Blob(svg, { type: 'image/svg+xml;charset=utf-8' }); + } + catch (e) + { + _this.state = CONST.FILE_ERRORED; + + callback(_this); + + return; + } + + this.data = new Image(); + + this.data.crossOrigin = this.crossOrigin; + + this.data.onload = function () + { + File.revokeObjectURL(_this.data); + + _this.onComplete(); + + callback(_this); + }; + + this.data.onerror = function () + { + File.revokeObjectURL(_this.data); + + _this.state = CONST.FILE_ERRORED; + + callback(_this); + }; + + File.createObjectURL(this.data, blob, 'image/svg+xml'); + } + +}); + +/** + * Adds an HTML file to the current load queue. + * + * Note: This method will only be available if the HTML File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#html + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('html', function (key, url, width, height, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new HTMLFile(key[i], url, width, height, this.path, xhrSettings)); + } + } + else + { + this.addFile(new HTMLFile(key, url, width, height, this.path, xhrSettings)); + } + + // For method chaining + return this; +}); + +module.exports = HTMLFile; + + +/***/ }), +/* 545 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); + +/** + * @classdesc + * [description] + * + * @class GLSLFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + */ +var GLSLFile = new Class({ + + Extends: File, + + initialize: + + function GLSLFile (key, url, path, xhrSettings) + { + var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); + + var fileConfig = { + type: 'glsl', + extension: GetFastValue(key, 'extension', 'glsl'), + responseType: 'text', + key: fileKey, + url: GetFastValue(key, 'file', url), + path: path, + xhrSettings: GetFastValue(key, 'xhr', xhrSettings) + }; + + File.call(this, fileConfig); + }, + + onProcess: function (callback) + { + this.state = CONST.FILE_PROCESSING; + + this.data = this.xhrLoader.responseText; + + this.onComplete(); + + callback(this); + } + +}); + +/** + * Adds a GLSL file to the current load queue. + * + * Note: This method will only be available if the GLSL File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#glsl + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('glsl', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new GLSLFile(key[i], url, this.path, xhrSettings)); + } + } + else + { + this.addFile(new GLSLFile(key, url, this.path, xhrSettings)); + } + + // For method chaining + return this; +}); + +module.exports = GLSLFile; + + +/***/ }), +/* 546 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FileTypesManager = __webpack_require__(7); +var ImageFile = __webpack_require__(50); +var XMLFile = __webpack_require__(223); + +/** + * An Bitmap Font File. + * + * @function Phaser.Loader.FileTypes.BitmapFontFile + * @since 3.0.0 + * + * @param {string} key - The key of the file within the loader. + * @param {string} textureURL - The url to load the texture file from. + * @param {string} xmlURL - The url to load the atlas file from. + * @param {string} path - The path of the file. + * @param {XHRSettingsObject} textureXhrSettings - Optional texture file specific XHR settings. + * @param {XHRSettingsObject} xmlXhrSettings - Optional atlas file specific XHR settings. + * + * @return {object} An object containing two File objects to be added to the loader. + */ +var BitmapFontFile = function (key, textureURL, xmlURL, path, textureXhrSettings, xmlXhrSettings) +{ + var image = new ImageFile(key, textureURL, path, textureXhrSettings); + var data = new XMLFile(key, xmlURL, path, xmlXhrSettings); + + // Link them together + image.linkFile = data; + data.linkFile = image; + + // Set the type + image.linkType = 'bitmapfont'; + data.linkType = 'bitmapfont'; + + return { texture: image, data: data }; +}; + +/** + * Adds a Bitmap Font file to the current load queue. + * + * Note: This method will only be available if the Bitmap Font File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#bitmapFont + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} textureURL - [description] + * @param {string} xmlURL - [description] + * @param {XHRSettingsObject} textureXhrSettings - [description] + * @param {XHRSettingsObject} xmlXhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('bitmapFont', function (key, textureURL, xmlURL, textureXhrSettings, xmlXhrSettings) +{ + // Returns an object with two properties: 'texture' and 'data' + var files = new BitmapFontFile(key, textureURL, xmlURL, this.path, textureXhrSettings, xmlXhrSettings); + + this.addFile(files.texture); + this.addFile(files.data); + + return this; +}); + +module.exports = BitmapFontFile; /***/ }), @@ -95275,28 +95053,100 @@ module.exports = UpdateList; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var ParseXMLBitmapFont = __webpack_require__(269); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(17); +var File = __webpack_require__(19); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); -var ParseFromAtlas = function (scene, fontName, textureKey, frameKey, xmlKey, xSpacing, ySpacing) -{ - var frame = scene.sys.textures.getFrame(textureKey, frameKey); - var xml = scene.sys.cache.xml.get(xmlKey); +/** + * @classdesc + * [description] + * + * @class BinaryFile + * @extends Phaser.Loader.File + * @memberOf Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {string} path - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + */ +var BinaryFile = new Class({ - if (frame && xml) + Extends: File, + + initialize: + + function BinaryFile (key, url, path, xhrSettings) { - var data = ParseXMLBitmapFont(xml, xSpacing, ySpacing, frame); + var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); - scene.sys.cache.bitmapFont.add(fontName, { data: data, texture: textureKey, frame: frameKey }); + var fileConfig = { + type: 'binary', + extension: GetFastValue(key, 'extension', 'bin'), + responseType: 'arraybuffer', + key: fileKey, + url: GetFastValue(key, 'file', url), + path: path, + xhrSettings: GetFastValue(key, 'xhr', xhrSettings) + }; - return true; + File.call(this, fileConfig); + }, + + onProcess: function (callback) + { + this.state = CONST.FILE_PROCESSING; + + this.data = this.xhrLoader.response; + + this.onComplete(); + + callback(this); + } + +}); + +/** + * Adds Binary file to the current load queue. + * + * Note: This method will only be available if the Binary File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#binary + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {string} url - [description] + * @param {XHRSettingsObject} xhrSettings - [description] + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('binary', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new BinaryFile(key[i], url, this.path, xhrSettings)); + } } else { - return false; + this.addFile(new BinaryFile(key, url, this.path, xhrSettings)); } -}; -module.exports = ParseFromAtlas; + // For method chaining + return this; +}); + +module.exports = BinaryFile; /***/ }), @@ -95309,189 +95159,68 @@ module.exports = ParseFromAtlas; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetValue = __webpack_require__(4); +var AudioFile = __webpack_require__(225); +var CONST = __webpack_require__(17); +var FileTypesManager = __webpack_require__(7); +var JSONFile = __webpack_require__(51); -// * @param {number} characterWidth - The width of each character in the font set. -// * @param {number} characterHeight - The height of each character in the font set. -// * @param {string} chars - The characters used in the font set, in display order. You can use the TEXT_SET consts for common font set arrangements. -// * @param {number} [charsPerRow] - The number of characters per row in the font set. If not given charsPerRow will be the image width / characterWidth. -// * @param {number} [xSpacing=0] - If the characters in the font set have horizontal spacing between them set the required amount here. -// * @param {number} [ySpacing=0] - If the characters in the font set have vertical spacing between them set the required amount here. -// * @param {number} [xOffset=0] - If the font set doesn't start at the top left of the given image, specify the X coordinate offset here. -// * @param {number} [yOffset=0] - If the font set doesn't start at the top left of the given image, specify the Y coordinate offset here. -// Phaser.GameObject.RetroFont = function (game, key, characterWidth, characterHeight, chars, charsPerRow, xSpacing, ySpacing, xOffset, yOffset) - -// { -// image: key, -// width: 32, -// height: 32, -// chars: 'string', -// charsPerRow: null, -// spacing: { x: 0, y: 0 }, -// offset: { x: 0, y: 0 } -// } - -var ParseRetroFont = function (scene, config) +/** + * Adds an Audio Sprite file to the current load queue. + * + * Note: This method will only be available if the Audio Sprite File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#audioSprite + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {(string|string[])} urls - [description] + * @param {object} json - [description] + * @param {object} config - [description] + * @param {XHRSettingsObject} audioXhrSettings - Optional file specific XHR settings. + * @param {XHRSettingsObject} jsonXhrSettings - Optional file specific XHR settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('audioSprite', function (key, urls, json, config, audioXhrSettings, jsonXhrSettings) { - var w = config.width; - var h = config.height; - var cx = Math.floor(w / 2); - var cy = Math.floor(h / 2); - var letters = config.chars; + var audioFile = AudioFile.create(this, key, urls, config, audioXhrSettings); - var key = GetValue(config, 'image', ''); - var offsetX = GetValue(config, 'offset.x', 0); - var offsetY = GetValue(config, 'offset.y', 0); - var spacingX = GetValue(config, 'spacing.x', 0); - var spacingY = GetValue(config, 'spacing.y', 0); - - var charsPerRow = GetValue(config, 'charsPerRow', null); - - if (charsPerRow === null) + if (audioFile) { - charsPerRow = scene.sys.textures.getFrame(key).width / w; + var jsonFile; - if (charsPerRow > letters.length) + if (typeof json === 'string') { - charsPerRow = letters.length; - } - } + jsonFile = new JSONFile(key, json, this.path, jsonXhrSettings); - var x = offsetX; - var y = offsetY; - - var data = { - retroFont: true, - font: key, - size: w, - lineHeight: h, - chars: {} - }; - - var r = 0; - - for (var i = 0; i < letters.length; i++) - { - // var node = letters[i]; - - var charCode = letters.charCodeAt(i); - - data.chars[charCode] = - { - x: x, - y: y, - width: w, - height: h, - centerX: cx, - centerY: cy, - xOffset: 0, - yOffset: 0, - xAdvance: w, - data: {}, - kerning: {} - }; - - r++; - - if (r === charsPerRow) - { - r = 0; - x = offsetX; - y += h + spacingY; + this.addFile(jsonFile); } else { - x += w + spacingX; + jsonFile = { + type: 'json', + key: key, + data: json, + state: CONST.FILE_WAITING_LINKFILE + }; } + + // Link them together + audioFile.linkFile = jsonFile; + jsonFile.linkFile = audioFile; + + // Set the type + audioFile.linkType = 'audioSprite'; + jsonFile.linkType = 'audioSprite'; + + this.addFile(audioFile); } - var entry = { - data: data, - frame: null, - texture: key - }; - - return entry; -}; - -/** -* Text Set 1 = !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ -* @constant -* @type {string} -*/ -ParseRetroFont.TEXT_SET1 = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; - -/** -* Text Set 2 = !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ -* @constant -* @type {string} -*/ -ParseRetroFont.TEXT_SET2 = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ'; - -/** -* Text Set 3 = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 -* @constant -* @type {string} -*/ -ParseRetroFont.TEXT_SET3 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 '; - -/** -* Text Set 4 = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 -* @constant -* @type {string} -*/ -ParseRetroFont.TEXT_SET4 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789'; - -/** -* Text Set 5 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789 -* @constant -* @type {string} -*/ -ParseRetroFont.TEXT_SET5 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() \'!?-*:0123456789'; - -/** -* Text Set 6 = ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.' -* @constant -* @type {string} -*/ -ParseRetroFont.TEXT_SET6 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.\' '; - -/** -* Text Set 7 = AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-'39 -* @constant -* @type {string} -*/ -ParseRetroFont.TEXT_SET7 = 'AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-\'39'; - -/** -* Text Set 8 = 0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ -* @constant -* @type {string} -*/ -ParseRetroFont.TEXT_SET8 = '0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ'; - -/** -* Text Set 9 = ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'"?! -* @constant -* @type {string} -*/ -ParseRetroFont.TEXT_SET9 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,\'"?!'; - -/** -* Text Set 10 = ABCDEFGHIJKLMNOPQRSTUVWXYZ -* @constant -* @type {string} -*/ -ParseRetroFont.TEXT_SET10 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; - -/** -* Text Set 11 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()':;0123456789 -* @constant -* @type {string} -*/ -ParseRetroFont.TEXT_SET11 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()\':;0123456789'; - -module.exports = ParseRetroFont; + return this; +}); /***/ }), @@ -95504,26 +95233,86 @@ module.exports = ParseRetroFont; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); +var FileTypesManager = __webpack_require__(7); +var ImageFile = __webpack_require__(50); +var JSONFile = __webpack_require__(51); -if (true) +/** + * An Atlas JSON File. + * + * @function Phaser.Loader.FileTypes.AtlasJSONFile + * @since 3.0.0 + * + * @param {string} key - The key of the file within the loader. + * @param {string} textureURL - The url to load the texture file from. + * @param {string} atlasURL - The url to load the atlas file from. + * @param {string} path - The path of the file. + * @param {XHRSettingsObject} textureXhrSettings - Optional texture file specific XHR settings. + * @param {XHRSettingsObject} atlasXhrSettings - Optional atlas file specific XHR settings. + * + * @return {object} An object containing two File objects to be added to the loader. + */ +var AtlasJSONFile = function (key, textureURL, atlasURL, path, textureXhrSettings, atlasXhrSettings) { - renderWebGL = __webpack_require__(550); -} + var image = new ImageFile(key, textureURL, path, textureXhrSettings); + var data = new JSONFile(key, atlasURL, path, atlasXhrSettings); -if (true) -{ - renderCanvas = __webpack_require__(551); -} + // Link them together + image.linkFile = data; + data.linkFile = image; -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas + // Set the type + image.linkType = 'atlasjson'; + data.linkType = 'atlasjson'; + return { texture: image, data: data }; }; +/** + * Adds a Texture Atlas file to the current load queue. + * + * Note: This method will only be available if the Atlas JSON File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#atlas + * @since 3.0.0 + * + * @param {string} key - The key of the file within the loader. + * @param {string} textureURL - The url to load the texture file from. + * @param {string} atlasURL - The url to load the atlas file from. + * @param {XHRSettingsObject} textureXhrSettings - Optional texture file specific XHR settings. + * @param {XHRSettingsObject} atlasXhrSettings - Optional atlas file specific XHR settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('atlas', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) +{ + + var files; + + // If param key is an object, use object based loading method + if ((typeof key === 'object') && (key !== null)) + { + files = new AtlasJSONFile(key.key, key.texture, key.data, this.path, textureXhrSettings, atlasXhrSettings); + } + + // Else just use the parameters like normal + else + { + // Returns an object with two properties: 'texture' and 'data' + files = new AtlasJSONFile(key, textureURL, atlasURL, this.path, textureXhrSettings, atlasXhrSettings); + } + + this.addFile(files.texture); + this.addFile(files.data); + + return this; +}); + +module.exports = AtlasJSONFile; + /***/ }), /* 550 */ @@ -95535,36 +95324,76 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(1); +var FileTypesManager = __webpack_require__(7); +var JSONFile = __webpack_require__(51); /** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. + * An Animation JSON File. * - * @method Phaser.GameObjects.BitmapText#renderWebGL + * @function Phaser.Loader.FileTypes.AnimationJSONFile * @since 3.0.0 - * @private * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.BitmapText} gameObject - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {string} key - The key of the file within the loader. + * @param {string} url - The url to load the file from. + * @param {string} path - The path of the file. + * @param {XHRSettingsObject} xhrSettings - Optional file specific XHR settings. + * + * @return {Phaser.Loader.FileTypes.AnimationJSONFile} A File instance to be added to the Loader. */ -var BitmapTextWebGLRenderer = function (renderer, gameObject, interpolationPercentage, camera) +var AnimationJSONFile = function (key, url, path, xhrSettings) { - var text = gameObject.text; - var textLength = text.length; + var json = new JSONFile(key, url, path, xhrSettings); - if (GameObject.RENDER_MASK !== gameObject.renderFlags || textLength === 0 || (gameObject.cameraFilter > 0 && (gameObject.cameraFilter & camera._id))) - { - return; - } + // Override the File type + json.type = 'animationJSON'; - this.pipeline.batchBitmapText(this, camera); + return json; }; -module.exports = BitmapTextWebGLRenderer; +/** + * Adds an Animation JSON file to the current load queue. + * + * Note: This method will only be available if the Animation JSON File type has been built into Phaser. + * + * The file is **not** loaded immediately after calling this method. + * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. + * + * @method Phaser.Loader.LoaderPlugin#animation + * @since 3.0.0 + * + * @param {(string|array|object)} key - A unique string to be used as the key to reference this file from the Cache. Must be unique within this file type. + * @param {string} [url] - URL of the file. If `undefined` or `null` the url will be set to `.json`, + * i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {XHRSettingsObject} [xhrSettings] - File specific XHR settings to be used during the load. These settings are merged with the global Loader XHR settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('animation', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new AnimationJSONFile(key[i], url, this.path, xhrSettings)); + } + } + else + { + this.addFile(new AnimationJSONFile(key, url, this.path, xhrSettings)); + } + + // For method chaining + return this; +}); + +// When registering a factory function 'this' refers to the Loader context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory + +module.exports = AnimationJSONFile; /***/ }), @@ -95577,175 +95406,59 @@ module.exports = BitmapTextWebGLRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(1); +/** + * @namespace Phaser.Loader.FileTypes + */ /** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. + * @typedef {object} XHRConfig * - * @method Phaser.GameObjects.BitmapText#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.BitmapText} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @property {string} key - [description] + * @property {string} texture - [description] + * @property {string} [data] - [description] + * @property {XHRConfig} [xhr] - [description] */ -var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera) -{ - var text = src.text; - var textLength = text.length; - if (GameObject.RENDER_MASK !== src.renderFlags || textLength === 0 || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - var textureFrame = src.frame; +/** + * @typedef {object} FileTypeConfig + * + * @property {string} key - [description] + * @property {string} texture - [description] + * @property {string} [data] - [description] + * @property {string} [url] - [description] + * @property {string} [path] - [description] + * @property {string} [extension] - [description] + * @property {string} [responseType] - [description] + * @property {object} [config] - [description] + * @property {XHRConfig} [xhr] - [description] + */ - var chars = src.fontData.chars; - var lineHeight = src.fontData.lineHeight; +module.exports = { - var xAdvance = 0; - var yAdvance = 0; + AnimationJSONFile: __webpack_require__(550), + AtlasJSONFile: __webpack_require__(549), + AudioFile: __webpack_require__(225), + AudioSprite: __webpack_require__(548), + BinaryFile: __webpack_require__(547), + BitmapFontFile: __webpack_require__(546), + GLSLFile: __webpack_require__(545), + HTML5AudioFile: __webpack_require__(224), + HTMLFile: __webpack_require__(544), + ImageFile: __webpack_require__(50), + JSONFile: __webpack_require__(51), + MultiAtlas: __webpack_require__(543), + PluginFile: __webpack_require__(542), + ScriptFile: __webpack_require__(541), + SpriteSheetFile: __webpack_require__(540), + SVGFile: __webpack_require__(539), + TextFile: __webpack_require__(221), + TilemapCSVFile: __webpack_require__(538), + TilemapJSONFile: __webpack_require__(537), + UnityAtlasFile: __webpack_require__(536), + XMLFile: __webpack_require__(223) - var indexCount = 0; - var charCode = 0; - - var glyph = null; - var glyphX = 0; - var glyphY = 0; - var glyphW = 0; - var glyphH = 0; - - var x = 0; - var y = 0; - - var lastGlyph = null; - var lastCharCode = 0; - - var ctx = renderer.currentContext; - var image = src.frame.source.image; - - var textureX = textureFrame.cutX; - var textureY = textureFrame.cutY; - - var scale = (src.fontSize / src.fontData.size); - - // Blend Mode - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - var roundPixels = renderer.config.roundPixels; - - var tx = (src.x - camera.scrollX * src.scrollFactorX) + src.frame.x; - var ty = (src.y - camera.scrollY * src.scrollFactorY) + src.frame.y; - - if (roundPixels) - { - tx |= 0; - ty |= 0; - } - - ctx.save(); - - ctx.translate(tx, ty); - - ctx.rotate(src.rotation); - - ctx.translate(-src.displayOriginX, -src.displayOriginY); - - ctx.scale(src.scaleX, src.scaleY); - - for (var index = 0; index < textLength; ++index) - { - charCode = text.charCodeAt(index); - - if (charCode === 10) - { - xAdvance = 0; - indexCount = 0; - yAdvance += lineHeight; - lastGlyph = null; - continue; - } - - glyph = chars[charCode]; - - if (!glyph) - { - continue; - } - - glyphX = textureX + glyph.x; - glyphY = textureY + glyph.y; - - glyphW = glyph.width; - glyphH = glyph.height; - - x = indexCount + glyph.xOffset + xAdvance; - y = glyph.yOffset + yAdvance; - - if (lastGlyph !== null) - { - var kerningOffset = glyph.kerning[lastCharCode]; - x += (kerningOffset !== undefined) ? kerningOffset : 0; - } - - x *= scale; - y *= scale; - - xAdvance += glyph.xAdvance; - indexCount += 1; - lastGlyph = glyph; - lastCharCode = charCode; - - // Nothing to render or a space? Then skip to the next glyph - if (glyphW === 0 || glyphH === 0 || charCode === 32) - { - continue; - } - - if (roundPixels) - { - x |= 0; - y |= 0; - } - - ctx.save(); - - ctx.translate(x, y); - - ctx.scale(scale, scale); - - ctx.drawImage(image, glyphX, glyphY, glyphW, glyphH, 0, 0, glyphW, glyphH); - - ctx.restore(); - } - - ctx.restore(); }; -module.exports = BitmapTextCanvasRenderer; - /***/ }), /* 552 */ @@ -95757,26 +95470,32 @@ module.exports = BitmapTextCanvasRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); +var CONST = __webpack_require__(17); +var Extend = __webpack_require__(18); -if (true) -{ - renderWebGL = __webpack_require__(553); -} +/** + * @namespace Phaser.Loader + */ -if (true) -{ - renderCanvas = __webpack_require__(554); -} +var Loader = { -module.exports = { + FileTypes: __webpack_require__(551), - renderWebGL: renderWebGL, - renderCanvas: renderCanvas + File: __webpack_require__(19), + FileTypesManager: __webpack_require__(7), + GetURL: __webpack_require__(122), + LoaderPlugin: __webpack_require__(535), + MergeXHRSettings: __webpack_require__(121), + XHRLoader: __webpack_require__(226), + XHRSettings: __webpack_require__(94) }; +// Merge in the consts +Loader = Extend(false, Loader, CONST); + +module.exports = Loader; + /***/ }), /* 553 */ @@ -95788,33 +95507,17 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(1); - /** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Blitter#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Blitter} gameObject - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @namespace Phaser.Input.Touch */ -var BlitterWebGLRenderer = function (renderer, gameObject, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== gameObject.renderFlags || (gameObject.cameraFilter > 0 && (gameObject.cameraFilter & camera._id))) - { - return; - } - this.pipeline.drawBlitter(gameObject, camera); +/* eslint-disable */ +module.exports = { + + TouchManager: __webpack_require__(289) + }; - -module.exports = BlitterWebGLRenderer; +/* eslint-enable */ /***/ }), @@ -95827,704 +95530,21 @@ module.exports = BlitterWebGLRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(1); - /** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Blitter#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Blitter} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @namespace Phaser.Input.Mouse */ -var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - var list = src.getRenderList(); +/* eslint-disable */ +module.exports = { - renderer.setBlendMode(src.blendMode); - - var ctx = renderer.gameContext; - var cameraScrollX = src.x - camera.scrollX * src.scrollFactorX; - var cameraScrollY = src.y - camera.scrollY * src.scrollFactorY; - - // Render bobs - for (var i = 0; i < list.length; i++) - { - var bob = list[i]; - var flip = (bob.flipX || bob.flipY); - var frame = bob.frame; - var cd = frame.canvasData; - var dx = frame.x; - var dy = frame.y; - var fx = 1; - var fy = 1; - - if (!flip) - { - renderer.blitImage(dx + bob.x + cameraScrollX, dy + bob.y + cameraScrollY, bob.frame); - } - else - { - if (bob.flipX) - { - fx = -1; - dx -= cd.dWidth; - } - - if (bob.flipY) - { - fy = -1; - dy -= cd.dHeight; - } - - ctx.save(); - ctx.translate(bob.x + cameraScrollX, bob.y + cameraScrollY); - ctx.scale(fx, fy); - ctx.drawImage(frame.source.image, cd.sx, cd.sy, cd.sWidth, cd.sHeight, dx, dy, cd.dWidth, cd.dHeight); - ctx.restore(); - } - } + MouseManager: __webpack_require__(291) + }; - -module.exports = BlitterCanvasRenderer; +/* eslint-enable */ /***/ }), /* 555 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * A Bob Game Object. - * - * A Bob belongs to a Blitter Game Object. The Blitter is responsible for managing and rendering this object. - * - * A Bob has a position, alpha value and a frame from a texture that it uses to render with. You can also toggle - * the flipped and visible state of the Bob. The Frame the Bob uses to render can be changed dynamically, but it - * must be a Frame within the Texture used by the parent Blitter. - * - * Bob positions are relative to the Blitter parent. So if you move the Blitter parent, all Bob children will - * have their positions impacted by this change as well. - * - * You can manipulate Bob objects directly from your game code, but the creation and destruction of them should be - * handled via the Blitter parent. - * - * @class Bob - * @memberOf Phaser.GameObjects.Blitter - * @constructor - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter} blitter - The parent Blitter object is responsible for updating this Bob. - * @param {number} x - The horizontal position of this Game Object in the world, relative to the parent Blitter position. - * @param {number} y - The vertical position of this Game Object in the world, relative to the parent Blitter position. - * @param {string|integer} frame - The Frame this Bob will render with, as defined in the Texture the parent Blitter is using. - * @param {boolean} visible - Should the Bob render visible or not to start with? - */ -var Bob = new Class({ - - initialize: - - function Bob (blitter, x, y, frame, visible) - { - /** - * [description] - * - * @name Phaser.GameObjects.Blitter.Bob#parent - * @type {Phaser.GameObjects.Blitter} - * @since 3.0.0 - */ - this.parent = blitter; - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter.Bob#x - * @type {number} - * @since 3.0.0 - */ - this.x = x; - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter.Bob#y - * @type {number} - * @since 3.0.0 - */ - this.y = y; - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter.Bob#frame - * @type {string|integer} - * @since 3.0.0 - */ - this.frame = frame; - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter.Bob#data - * @type {object} - * @default {} - * @since 3.0.0 - */ - this.data = {}; - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter.Bob#_visible - * @type {boolean} - * @private - * @since 3.0.0 - */ - this._visible = visible; - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter.Bob#_alpha - * @type {number} - * @private - * @default 1 - * @since 3.0.0 - */ - this._alpha = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter.Bob#flipX - * @type {boolean} - * @since 3.0.0 - */ - this.flipX = false; - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter.Bob#flipY - * @type {boolean} - * @since 3.0.0 - */ - this.flipY = false; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter.Bob#setFrame - * @since 3.0.0 - * - * @param {[type]} frame - [description] - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setFrame: function (frame) - { - if (frame === undefined) - { - frame = this.parent.frame; - } - else - { - frame = this.parent.texture.get(frame); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter.Bob#resetFlip - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - resetFlip: function () - { - this.flipX = false; - this.flipY = false; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter.Bob#reset - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} frame - [description] - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - reset: function (x, y, frame) - { - this.x = x; - this.y = y; - this.frame = frame; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter.Bob#setFlipX - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setFlipX: function (value) - { - this.flipX = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter.Bob#setFlipY - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setFlipY: function (value) - { - this.flipY = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter.Bob#setFlip - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setFlip: function (x, y) - { - this.flipX = x; - this.flipY = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter.Bob#setVisible - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setVisible: function (value) - { - this.visible = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter.Bob#setAlpha - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setAlpha: function (value) - { - this.alpha = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Blitter.Bob#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.parent.dirty = true; - - this.parent.children.remove(this); - - this.parent = undefined; - this.frame = undefined; - this.data = undefined; - }, - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter.Bob#visible - * @type {boolean} - * @since 3.0.0 - */ - visible: { - - get: function () - { - return this._visible; - }, - - set: function (value) - { - this._visible = value; - this.parent.dirty = true; - } - - }, - - /** - * [description] - * - * @name Phaser.GameObjects.Blitter.Bob#alpha - * @type {number} - * @since 3.0.0 - */ - alpha: { - - get: function () - { - return this._alpha; - }, - - set: function (value) - { - this._alpha = value; - this.parent.dirty = true; - } - - } - -}); - -module.exports = Bob; - - -/***/ }), -/* 556 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(557); -} - -if (true) -{ - renderCanvas = __webpack_require__(558); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 557 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.DynamicBitmapText#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.DynamicBitmapText} gameObject - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var DynamicBitmapTextWebGLRenderer = function (renderer, bitmapText, interpolationPercentage, camera) -{ - var text = bitmapText.text; - var textLength = text.length; - - if (GameObject.RENDER_MASK !== bitmapText.renderFlags || textLength === 0 || (bitmapText.cameraFilter > 0 && (bitmapText.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.batchDynamicBitmapText(bitmapText, camera); -}; - -module.exports = DynamicBitmapTextWebGLRenderer; - - -/***/ }), -/* 558 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.DynamicBitmapText#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.DynamicBitmapText} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera) -{ - var text = src.text; - var textLength = text.length; - - if (GameObject.RENDER_MASK !== src.renderFlags || textLength === 0 || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - var textureFrame = src.frame; - - var displayCallback = src.displayCallback; - - var cameraScrollX = camera.scrollX * src.scrollFactorX; - var cameraScrollY = camera.scrollY * src.scrollFactorY; - - var chars = src.fontData.chars; - var lineHeight = src.fontData.lineHeight; - - var xAdvance = 0; - var yAdvance = 0; - - var indexCount = 0; - var charCode = 0; - - var glyph = null; - var glyphX = 0; - var glyphY = 0; - var glyphW = 0; - var glyphH = 0; - - var x = 0; - var y = 0; - - var lastGlyph = null; - var lastCharCode = 0; - - var ctx = renderer.currentContext; - var image = src.frame.source.image; - - var textureX = textureFrame.cutX; - var textureY = textureFrame.cutY; - - var rotation = 0; - var scale = (src.fontSize / src.fontData.size); - - // Blend Mode - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - ctx.save(); - - ctx.translate(src.x, src.y); - - ctx.rotate(src.rotation); - - ctx.translate(-src.displayOriginX, -src.displayOriginY); - - ctx.scale(src.scaleX, src.scaleY); - - if (src.cropWidth > 0 && src.cropHeight > 0) - { - ctx.save(); - ctx.beginPath(); - ctx.rect(0, 0, src.cropWidth, src.cropHeight); - ctx.clip(); - } - - var roundPixels = renderer.config.roundPixels; - - for (var index = 0; index < textLength; ++index) - { - // Reset the scale (in case the callback changed it) - scale = (src.fontSize / src.fontData.size); - rotation = 0; - - charCode = text.charCodeAt(index); - - if (charCode === 10) - { - xAdvance = 0; - indexCount = 0; - yAdvance += lineHeight; - lastGlyph = null; - continue; - } - - glyph = chars[charCode]; - - if (!glyph) - { - continue; - } - - glyphX = textureX + glyph.x; - glyphY = textureY + glyph.y; - - glyphW = glyph.width; - glyphH = glyph.height; - - x = (indexCount + glyph.xOffset + xAdvance) - src.scrollX; - y = (glyph.yOffset + yAdvance) - src.scrollY; - - // This could be optimized so that it doesn't even bother drawing it if the x/y is out of range - - if (lastGlyph !== null) - { - var kerningOffset = glyph.kerning[lastCharCode]; - x += (kerningOffset !== undefined) ? kerningOffset : 0; - } - - if (displayCallback) - { - var output = displayCallback({ tint: { topLeft: 0, topRight: 0, bottomLeft: 0, bottomRight: 0 }, index: index, charCode: charCode, x: x, y: y, scale: scale, rotation: 0, data: glyph.data }); - - x = output.x; - y = output.y; - scale = output.scale; - rotation = output.rotation; - } - - x *= scale; - y *= scale; - - x -= cameraScrollX; - y -= cameraScrollY; - - if (roundPixels) - { - x |= 0; - y |= 0; - } - - ctx.save(); - - ctx.translate(x, y); - - ctx.rotate(rotation); - - ctx.scale(scale, scale); - - ctx.drawImage(image, glyphX, glyphY, glyphW, glyphH, 0, 0, glyphW, glyphH); - - ctx.restore(); - - xAdvance += glyph.xAdvance; - indexCount += 1; - lastGlyph = glyph; - lastCharCode = charCode; - } - - if (src.cropWidth > 0 && src.cropHeight > 0) - { - ctx.restore(); - } - - ctx.restore(); -}; - -module.exports = DynamicBitmapTextCanvasRenderer; - - -/***/ }), -/* 559 */ /***/ (function(module, exports) { /** @@ -96534,27 +95554,166 @@ module.exports = DynamicBitmapTextCanvasRenderer; */ /** - * Calculates the area of the Ellipse. + * Returns `true` if the Key was released within the `duration` value given, or `false` if it either isn't up, + * or was released longer ago than then given duration. * - * @function Phaser.Geom.Ellipse.Area + * @function Phaser.Input.Keyboard.UpDuration * @since 3.0.0 * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the area of. + * @param {Phaser.Input.Keyboard.Key} key - [description] + * @param {integer} [duration=50] - [description] * - * @return {number} The area of the Ellipse. + * @return {boolean} [description] */ -var Area = function (ellipse) +var UpDuration = function (key, duration) { - if (ellipse.isEmpty()) - { - return 0; - } + if (duration === undefined) { duration = 50; } - // units squared - return (ellipse.getMajorRadius() * ellipse.getMinorRadius() * Math.PI); + return (key.isUp && key.duration < duration); }; -module.exports = Area; +module.exports = UpDuration; + + +/***/ }), +/* 556 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns `true` if the Key was pressed down within the `duration` value given, or `false` if it either isn't down, + * or was pressed down longer ago than then given duration. + * + * @function Phaser.Input.Keyboard.DownDuration + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.Key} key - [description] + * @param {integer} [duration=50] - [description] + * + * @return {boolean} [description] + */ +var DownDuration = function (key, duration) +{ + if (duration === undefined) { duration = 50; } + + return (key.isDown && key.duration < duration); +}; + +module.exports = DownDuration; + + +/***/ }), +/* 557 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * The justUp value allows you to test if this Key has just been released or not. + * When you check this value it will return `true` if the Key is up, otherwise `false`. + * You can only call justUp once per key release. It will only return `true` once, until the Key is pressed down and released again. + * This allows you to use it in situations where you want to check if this key is up without using a Signal, such as in a core game loop. + * + * @function Phaser.Input.Keyboard.JustUp + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.Key} key - [description] + * + * @return {boolean} [description] + */ +var JustUp = function (key) +{ + var current = false; + + if (key.isDown) + { + current = key._justUp; + key._justUp = false; + } + + return current; +}; + +module.exports = JustUp; + + +/***/ }), +/* 558 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * The justDown value allows you to test if this Key has just been pressed down or not. + * When you check this value it will return `true` if the Key is down, otherwise `false`. + * You can only call justDown once per key press. It will only return `true` once, until the Key is released and pressed down again. + * This allows you to use it in situations where you want to check if this key is down without using a Signal, such as in a core game loop. + * + * @function Phaser.Input.Keyboard.JustDown + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.Key} key - [description] + * + * @return {boolean} [description] + */ +var JustDown = function (key) +{ + var current = false; + + if (key.isDown) + { + current = key._justDown; + key._justDown = false; + } + + return current; +}; + +module.exports = JustDown; + + +/***/ }), +/* 559 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Input.Keyboard + */ + +module.exports = { + + KeyboardManager: __webpack_require__(294), + + Key: __webpack_require__(293), + KeyCodes: __webpack_require__(143), + + KeyCombo: __webpack_require__(292), + + JustDown: __webpack_require__(558), + JustUp: __webpack_require__(557), + DownDuration: __webpack_require__(556), + UpDuration: __webpack_require__(555) + +}; /***/ }), @@ -96567,29 +95726,1642 @@ module.exports = Area; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Ellipse = __webpack_require__(137); +var Circle = __webpack_require__(79); +var CircleContains = __webpack_require__(28); +var Class = __webpack_require__(0); +var DistanceBetween = __webpack_require__(48); +var Ellipse = __webpack_require__(135); +var EllipseContains = __webpack_require__(74); +var EventEmitter = __webpack_require__(15); +var InteractiveObject = __webpack_require__(227); +var PluginManager = __webpack_require__(12); +var Rectangle = __webpack_require__(10); +var RectangleContains = __webpack_require__(27); +var Triangle = __webpack_require__(52); +var TriangleContains = __webpack_require__(54); /** - * Creates a new Ellipse instance based on the values contained in the given source. + * @classdesc + * [description] * - * @function Phaser.Geom.Ellipse.Clone + * @class InputPlugin + * @extends EventEmitter + * @memberOf Phaser.Input + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Ellipse} source - The Ellipse to be cloned. Can be an instance of an Ellipse or a ellipse-like object, with x, y, width and height properties. - * - * @return {Phaser.Geom.Ellipse} A clone of the source Ellipse. + * @param {Phaser.Scene} scene - The Scene that owns this plugin. */ -var Clone = function (source) -{ - return new Ellipse(source.x, source.y, source.width, source.height); -}; +var InputPlugin = new Class({ -module.exports = Clone; + Extends: EventEmitter, + + initialize: + + function InputPlugin (scene) + { + EventEmitter.call(this); + + /** + * The Scene that owns this plugin. + * + * @name Phaser.Input.InputPlugin#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Input.InputPlugin#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + if (!scene.sys.settings.isBooted) + { + scene.sys.events.once('boot', this.boot, this); + } + + /** + * [description] + * + * @name Phaser.Input.InputPlugin#manager + * @type {Phaser.Input.InputManager} + * @since 3.0.0 + */ + this.manager = scene.sys.game.input; + + /** + * A reference to this.scene.sys.displayList (set in boot) + * + * @name Phaser.Input.InputPlugin#displayList + * @type {Phaser.GameObjects.DisplayList} + * @since 3.0.0 + */ + this.displayList; + + /** + * A reference to the this.scene.sys.cameras (set in boot) + * + * @name Phaser.Input.InputPlugin#cameras + * @type {null} + * @since 3.0.0 + */ + this.cameras; + + /** + * [description] + * + * @name Phaser.Input.InputPlugin#keyboard + * @type {Phaser.Input.Keyboard.KeyboardManager} + * @since 3.0.0 + */ + this.keyboard = this.manager.keyboard; + + /** + * [description] + * + * @name Phaser.Input.InputPlugin#mouse + * @type {Phaser.Input.Mouse.MouseManager} + * @since 3.0.0 + */ + this.mouse = this.manager.mouse; + + /** + * [description] + * + * @name Phaser.Input.InputPlugin#gamepad + * @type {Phaser.Input.Gamepad.GamepadManager} + * @since 3.0.0 + */ + this.gamepad = this.manager.gamepad; + + /** + * Only fire callbacks and events on the top-most Game Object in the display list (emulating DOM behavior) + * and ignore any GOs below it, or call them all? + * + * @name Phaser.Input.InputPlugin#topOnly + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.topOnly = true; + + /** + * How often should the pointer input be checked? + * Time given in ms + * Pointer will *always* be checked if it has been moved by the user. + * This controls how often it will be polled if it hasn't been moved. + * Set to 0 to poll constantly. Set to -1 to only poll on user movement. + * + * @name Phaser.Input.InputPlugin#pollRate + * @type {integer} + * @default -1 + * @since 3.0.0 + */ + this.pollRate = -1; + + /** + * [description] + * + * @name Phaser.Input.InputPlugin#_pollTimer + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._pollTimer = 0; + + /** + * The distance, in pixels, the pointer has to move while being held down, before it thinks it is being dragged. + * + * @name Phaser.Input.InputPlugin#dragDistanceThreshold + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.dragDistanceThreshold = 0; + + /** + * The amount of time, in ms, the pointer has to be held down before it thinks it is dragging. + * + * @name Phaser.Input.InputPlugin#dragTimeThreshold + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.dragTimeThreshold = 0; + + /** + * Used to temporarily store the results of the Hit Test + * + * @name Phaser.Input.InputPlugin#_temp + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this._temp = []; + + /** + * Used to temporarily store the results of the Hit Test dropZones + * + * @name Phaser.Input.InputPlugin#_tempZones + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this._tempZones = []; + + /** + * A list of all Game Objects that have been set to be interactive. + * + * @name Phaser.Input.InputPlugin#_list + * @type {Phaser.GameObjects.GameObject[]} + * @private + * @default [] + * @since 3.0.0 + */ + this._list = []; + + /** + * Objects waiting to be inserted to the list on the next call to 'begin'. + * + * @name Phaser.Input.InputPlugin#_pendingInsertion + * @type {Phaser.GameObjects.GameObject[]} + * @private + * @default [] + * @since 3.0.0 + */ + this._pendingInsertion = []; + + /** + * Objects waiting to be removed from the list on the next call to 'begin'. + * + * @name Phaser.Input.InputPlugin#_pendingRemoval + * @type {Phaser.GameObjects.GameObject[]} + * @private + * @default [] + * @since 3.0.0 + */ + this._pendingRemoval = []; + + /** + * A list of all Game Objects that have been enabled for dragging. + * + * @name Phaser.Input.InputPlugin#_draggable + * @type {Phaser.GameObjects.GameObject[]} + * @private + * @default [] + * @since 3.0.0 + */ + this._draggable = []; + + /** + * A list of all Interactive Objects currently considered as being 'draggable' by any pointer, indexed by pointer ID. + * + * @name Phaser.Input.InputPlugin#_drag + * @type {{0:Array,2:Array,3:Array,4:Array,5:Array,6:Array,7:Array,8:Array,9:Array}} + * @private + * @since 3.0.0 + */ + this._drag = { 0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [] }; + + /** + * A list of all Interactive Objects currently considered as being 'over' by any pointer, indexed by pointer ID. + * + * @name Phaser.Input.InputPlugin#_over + * @type {{0:Array,2:Array,3:Array,4:Array,5:Array,6:Array,7:Array,8:Array,9:Array}} + * @private + * @since 3.0.0 + */ + this._over = { 0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [] }; + + /** + * [description] + * + * @name Phaser.Input.InputPlugin#_validTypes + * @type {string[]} + * @private + * @since 3.0.0 + */ + this._validTypes = [ 'onDown', 'onUp', 'onOver', 'onOut', 'onMove', 'onDragStart', 'onDrag', 'onDragEnd', 'onDragEnter', 'onDragLeave', 'onDragOver', 'onDrop' ]; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#boot + * @since 3.0.0 + */ + boot: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on('preupdate', this.preUpdate, this); + eventEmitter.on('update', this.update, this); + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); + + this.cameras = this.systems.cameras; + + this.displayList = this.systems.displayList; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#preUpdate + * @since 3.0.0 + */ + preUpdate: function () + { + var removeList = this._pendingRemoval; + var insertList = this._pendingInsertion; + + var toRemove = removeList.length; + var toInsert = insertList.length; + + if (toRemove === 0 && toInsert === 0) + { + // Quick bail + return; + } + + var current = this._list; + + // Delete old gameObjects + for (var i = 0; i < toRemove; i++) + { + var gameObject = removeList[i]; + + var index = current.indexOf(gameObject); + + if (index > -1) + { + current.splice(index, 1); + + this.clear(gameObject); + } + } + + // Clear the removal list + removeList.length = 0; + + // Move pendingInsertion to list (also clears pendingInsertion at the same time) + this._list = current.concat(insertList.splice(0)); + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#clear + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * + * @return {Phaser.GameObjects.GameObject} [description] + */ + clear: function (gameObject) + { + var input = gameObject.input; + + input.gameObject = undefined; + input.target = undefined; + input.hitArea = undefined; + input.hitAreaCallback = undefined; + input.callbackContext = undefined; + + gameObject.input = null; + + // Clear from _draggable, _drag and _over + var index = this._draggable.indexOf(gameObject); + + if (index > -1) + { + this._draggable.splice(index, 1); + } + + index = this._drag[0].indexOf(gameObject); + + if (index > -1) + { + this._drag[0].splice(index, 1); + } + + index = this._over[0].indexOf(gameObject); + + if (index > -1) + { + this._over[0].splice(index, 1); + } + + return gameObject; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#disable + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + */ + disable: function (gameObject) + { + gameObject.input.enabled = false; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#enable + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * @param {object} shape - [description] + * @param {HitAreaCallback} callback - [description] + * @param {boolean} [dropZone=false] - [description] + * + * @return {Phaser.Input.InputPlugin} This Input Plugin. + */ + enable: function (gameObject, shape, callback, dropZone) + { + if (dropZone === undefined) { dropZone = false; } + + if (gameObject.input) + { + // If it is already has an InteractiveObject then just enable it and return + gameObject.input.enabled = true; + } + else + { + // Create an InteractiveObject and enable it + this.setHitArea(gameObject, shape, callback); + } + + gameObject.input.dropZone = dropZone; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#hitTestPointer + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - [description] + * + * @return {array} [description] + */ + hitTestPointer: function (pointer) + { + var camera = this.cameras.getCameraBelowPointer(pointer); + + if (camera) + { + pointer.camera = camera; + + // Get a list of all objects that can be seen by the camera below the pointer in the scene and store in 'output' array. + // All objects in this array are input enabled, as checked by the hitTest method, so we don't need to check later on as well. + var over = this.manager.hitTest(pointer.x, pointer.y, this._list, camera); + + // Filter out the drop zones + for (var i = 0; i < over.length; i++) + { + var obj = over[i]; + + if (obj.input.dropZone) + { + this._tempZones.push(obj); + } + } + + return over; + } + else + { + return []; + } + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#processDownEvents + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer to check for events against. + * + * @return {integer} The total number of objects interacted with. + */ + processDownEvents: function (pointer) + { + var currentlyOver = this._temp; + + // Contains ALL Game Objects currently over in the array + this.emit('pointerdown', pointer, currentlyOver); + + var total = 0; + + // Go through all objects the pointer was over and fire their events / callbacks + for (var i = 0; i < currentlyOver.length; i++) + { + var gameObject = currentlyOver[i]; + + if (!gameObject.input) + { + continue; + } + + total++; + + gameObject.emit('pointerdown', pointer, gameObject.input.localX, gameObject.input.localY, pointer.camera); + + this.emit('gameobjectdown', pointer, gameObject); + } + + return total; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#processDragEvents + * @since 3.0.0 + * + * @param {number} pointer - [description] + * @param {number} time - [description] + * + * @return {integer} [description] + */ + processDragEvents: function (pointer, time) + { + if (this._draggable.length === 0) + { + // There are no draggable items, so let's not even bother going further + return 0; + } + + var i; + var gameObject; + var list; + var input; + var currentlyOver = this._temp; + + // 0 = Not dragging anything + // 1 = Primary button down and objects below, so collect a draglist + // 2 = Pointer being checked if meets drag criteria + // 3 = Pointer meets criteria, notify the draglist + // 4 = Pointer actively dragging the draglist and has moved + // 5 = Pointer actively dragging but has been released, notify draglist + + if (pointer.dragState === 0 && pointer.primaryDown && pointer.justDown && currentlyOver.length > 0) + { + pointer.dragState = 1; + } + else if (pointer.dragState > 0 && !pointer.primaryDown && pointer.justUp) + { + pointer.dragState = 5; + } + + // Process the various drag states + + // 1 = Primary button down and objects below, so collect a draglist + if (pointer.dragState === 1) + { + // Get draggable objects, sort them, pick the top (or all) and store them somewhere + var draglist = []; + + for (i = 0; i < currentlyOver.length; i++) + { + gameObject = currentlyOver[i]; + + if (gameObject.input.draggable) + { + draglist.push(gameObject); + } + } + + if (draglist.length === 0) + { + pointer.dragState = 0; + + return 0; + } + else if (draglist.length > 1) + { + this.sortGameObjects(draglist); + + if (this.topOnly) + { + draglist.splice(1); + } + } + + // draglist now contains all potential candidates for dragging + this._drag[pointer.id] = draglist; + + if (this.dragDistanceThreshold === 0 && this.dragTimeThreshold === 0) + { + // No drag criteria, so snap immediately to mode 3 + pointer.dragState = 3; + } + else + { + // Check the distance / time + pointer.dragState = 2; + } + } + + // 2 = Pointer being checked if meets drag criteria + if (pointer.dragState === 2) + { + // Has it moved far enough to be considered a drag? + if (this.dragDistanceThreshold > 0 && DistanceBetween(pointer.x, pointer.y, pointer.downX, pointer.downY) >= this.dragDistanceThreshold) + { + // Alrighty, we've got a drag going on ... + pointer.dragState = 3; + } + + // Held down long enough to be considered a drag? + if (this.dragTimeThreshold > 0 && (time >= pointer.downTime + this.dragTimeThreshold)) + { + // Alrighty, we've got a drag going on ... + pointer.dragState = 3; + } + } + + // 3 = Pointer meets criteria and is freshly down, notify the draglist + if (pointer.dragState === 3) + { + list = this._drag[pointer.id]; + + for (i = 0; i < list.length; i++) + { + gameObject = list[i]; + + input = gameObject.input; + + input.dragState = 2; + + input.dragX = pointer.x - gameObject.x; + input.dragY = pointer.y - gameObject.y; + + input.dragStartX = gameObject.x; + input.dragStartY = gameObject.y; + + gameObject.emit('dragstart', pointer, input.dragX, input.dragY); + + this.emit('dragstart', pointer, gameObject); + } + + pointer.dragState = 4; + + return list.length; + } + + // 4 = Pointer actively dragging the draglist and has moved + if (pointer.dragState === 4 && pointer.justMoved) + { + var dropZones = this._tempZones; + + list = this._drag[pointer.id]; + + for (i = 0; i < list.length; i++) + { + gameObject = list[i]; + + input = gameObject.input; + + // If this GO has a target then let's check it + if (input.target) + { + var index = dropZones.indexOf(input.target); + + // Got a target, are we still over it? + if (index === 0) + { + // We're still over it, and it's still the top of the display list, phew ... + gameObject.emit('dragover', pointer, input.target); + + this.emit('dragover', pointer, gameObject, input.target); + } + else if (index > 0) + { + // Still over it but it's no longer top of the display list (targets must always be at the top) + gameObject.emit('dragleave', pointer, input.target); + + this.emit('dragleave', pointer, gameObject, input.target); + + input.target = dropZones[0]; + + gameObject.emit('dragenter', pointer, input.target); + + this.emit('dragenter', pointer, gameObject, input.target); + } + else + { + // Nope, we've moved on (or the target has!), leave the old target + gameObject.emit('dragleave', pointer, input.target); + + this.emit('dragleave', pointer, gameObject, input.target); + + // Anything new to replace it? + // Yup! + if (dropZones[0]) + { + input.target = dropZones[0]; + + gameObject.emit('dragenter', pointer, input.target); + + this.emit('dragenter', pointer, gameObject, input.target); + } + else + { + // Nope + input.target = null; + } + } + } + else if (!input.target && dropZones[0]) + { + input.target = dropZones[0]; + + gameObject.emit('dragenter', pointer, input.target); + + this.emit('dragenter', pointer, gameObject, input.target); + } + + var dragX = pointer.x - gameObject.input.dragX; + var dragY = pointer.y - gameObject.input.dragY; + + gameObject.emit('drag', pointer, dragX, dragY); + + this.emit('drag', pointer, gameObject, dragX, dragY); + } + + return list.length; + } + + // 5 = Pointer was actively dragging but has been released, notify draglist + if (pointer.dragState === 5) + { + list = this._drag[pointer.id]; + + for (i = 0; i < list.length; i++) + { + gameObject = list[i]; + + input = gameObject.input; + + input.dragState = 0; + + input.dragX = input.localX - gameObject.displayOriginX; + input.dragY = input.localY - gameObject.displayOriginY; + + var dropped = false; + + if (input.target) + { + gameObject.emit('drop', pointer, input.target); + + this.emit('drop', pointer, gameObject, input.target); + + input.target = null; + + dropped = true; + } + + // And finally the dragend event + + gameObject.emit('dragend', pointer, input.dragX, input.dragY, dropped); + + this.emit('dragend', pointer, gameObject, dropped); + } + + pointer.dragState = 0; + } + + return 0; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#processMoveEvents + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The pointer to check for events against. + * + * @return {integer} The total number of objects interacted with. + */ + processMoveEvents: function (pointer) + { + var currentlyOver = this._temp; + + this.emit('pointermove', pointer, currentlyOver); + + var total = 0; + + // Go through all objects the pointer was over and fire their events / callbacks + for (var i = 0; i < currentlyOver.length; i++) + { + var gameObject = currentlyOver[i]; + + if (!gameObject.input) + { + continue; + } + + total++; + + gameObject.emit('pointermove', pointer, gameObject.input.localX, gameObject.input.localY); + + this.emit('gameobjectmove', pointer, gameObject); + + if (this.topOnly) + { + break; + } + } + + return total; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#processOverOutEvents + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - [description] + * + * @return {integer} The number of objects interacted with. + */ + processOverOutEvents: function (pointer) + { + var currentlyOver = this._temp; + + var i; + var gameObject; + var justOut = []; + var justOver = []; + var stillOver = []; + var previouslyOver = this._over[pointer.id]; + var currentlyDragging = this._drag[pointer.id]; + + // Go through all objects the pointer was previously over, and see if it still is. + // Splits the previouslyOver array into two parts: justOut and stillOver + + for (i = 0; i < previouslyOver.length; i++) + { + gameObject = previouslyOver[i]; + + if (currentlyOver.indexOf(gameObject) === -1 && currentlyDragging.indexOf(gameObject) === -1) + { + // Not in the currentlyOver array, so must be outside of this object now + justOut.push(gameObject); + } + else + { + // In the currentlyOver array + stillOver.push(gameObject); + } + } + + // Go through all objects the pointer is currently over (the hit test results) + // and if not in the previouslyOver array we know it's a new entry, so add to justOver + for (i = 0; i < currentlyOver.length; i++) + { + gameObject = currentlyOver[i]; + + // Is this newly over? + + if (previouslyOver.indexOf(gameObject) === -1) + { + justOver.push(gameObject); + } + } + + // By this point the arrays are filled, so now we can process what happened... + + // Process the Just Out objects + var total = justOut.length; + + var totalInteracted = 0; + + if (total > 0) + { + this.sortGameObjects(justOut); + + this.emit('pointerout', pointer, justOut); + + // Call onOut for everything in the justOut array + for (i = 0; i < total; i++) + { + gameObject = justOut[i]; + + if (!gameObject.input) + { + continue; + } + + this.emit('gameobjectout', pointer, gameObject); + + gameObject.emit('pointerout', pointer); + + totalInteracted++; + } + } + + // Process the Just Over objects + total = justOver.length; + + if (total > 0) + { + this.sortGameObjects(justOver); + + this.emit('pointerover', pointer, justOver); + + // Call onOver for everything in the justOver array + for (i = 0; i < total; i++) + { + gameObject = justOver[i]; + + if (!gameObject.input) + { + continue; + } + + this.emit('gameobjectover', pointer, gameObject); + + gameObject.emit('pointerover', pointer, gameObject.input.localX, gameObject.input.localY); + + totalInteracted++; + } + } + + // Add the contents of justOver to the previously over array + previouslyOver = stillOver.concat(justOver); + + // Then sort it into display list order + this._over[pointer.id] = this.sortGameObjects(previouslyOver); + + return totalInteracted; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#processUpEvents + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - [description] + */ + processUpEvents: function (pointer) + { + var currentlyOver = this._temp; + + // Contains ALL Game Objects currently up in the array + this.emit('pointerup', pointer, currentlyOver); + + // Go through all objects the pointer was over and fire their events / callbacks + for (var i = 0; i < currentlyOver.length; i++) + { + var gameObject = currentlyOver[i]; + + if (!gameObject.input) + { + continue; + } + + // pointerupoutside + + gameObject.emit('pointerup', pointer, gameObject.input.localX, gameObject.input.localY); + + this.emit('gameobjectup', pointer, gameObject); + } + + return currentlyOver.length; + }, + + /** + * Queues a Game Object for insertion into this Input Manager on the next update. + * + * @method Phaser.Input.InputPlugin#queueForInsertion + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to add. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + queueForInsertion: function (child) + { + if (this._pendingInsertion.indexOf(child) === -1 && this._list.indexOf(child) === -1) + { + this._pendingInsertion.push(child); + } + + return this; + }, + + /** + * Queues a Game Object for removal from this Input Manager on the next update. + * + * @method Phaser.Input.InputPlugin#queueForRemoval + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to remove. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + queueForRemoval: function (child) + { + this._pendingRemoval.push(child); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setDraggable + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to change the draggable state on. + * @param {boolean} [value=true] - Set to `true` if the Game Objects should be made draggable, `false` if they should be unset. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setDraggable: function (gameObjects, value) + { + if (value === undefined) { value = true; } + + if (!Array.isArray(gameObjects)) + { + gameObjects = [ gameObjects ]; + } + + for (var i = 0; i < gameObjects.length; i++) + { + var gameObject = gameObjects[i]; + + gameObject.input.draggable = value; + + var index = this._draggable.indexOf(gameObject); + + if (value && index === -1) + { + this._draggable.push(gameObject); + } + else if (!value && index > -1) + { + this._draggable.splice(index, 1); + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setHitArea + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set the hit area on. + * @param {object} [shape] - The shape or object to check if the pointer is within for hit area checks. + * @param {HitAreaCallback} [callback] - The 'contains' function to invoke to check if the pointer is within the hit area. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setHitArea: function (gameObjects, shape, callback) + { + if (shape === undefined) + { + return this.setHitAreaFromTexture(gameObjects); + } + + if (!Array.isArray(gameObjects)) + { + gameObjects = [ gameObjects ]; + } + + for (var i = 0; i < gameObjects.length; i++) + { + var gameObject = gameObjects[i]; + + gameObject.input = InteractiveObject(gameObject, shape, callback); + + this.queueForInsertion(gameObject); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setHitAreaCircle + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having a circle hit area. + * @param {number} x - The center of the circle. + * @param {number} y - The center of the circle. + * @param {number} radius - The radius of the circle. + * @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Circle.Contains. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setHitAreaCircle: function (gameObjects, x, y, radius, callback) + { + if (callback === undefined) { callback = CircleContains; } + + var shape = new Circle(x, y, radius); + + return this.setHitArea(gameObjects, shape, callback); + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setHitAreaEllipse + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having an ellipse hit area. + * @param {number} x - The center of the ellipse. + * @param {number} y - The center of the ellipse. + * @param {number} width - The width of the ellipse. + * @param {number} height - The height of the ellipse. + * @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Ellipse.Contains. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setHitAreaEllipse: function (gameObjects, x, y, width, height, callback) + { + if (callback === undefined) { callback = EllipseContains; } + + var shape = new Ellipse(x, y, width, height); + + return this.setHitArea(gameObjects, shape, callback); + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setHitAreaFromTexture + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having an ellipse hit area. + * @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Rectangle.Contains. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setHitAreaFromTexture: function (gameObjects, callback) + { + if (callback === undefined) { callback = RectangleContains; } + + if (!Array.isArray(gameObjects)) + { + gameObjects = [ gameObjects ]; + } + + for (var i = 0; i < gameObjects.length; i++) + { + var gameObject = gameObjects[i]; + var frame = gameObject.frame; + + var width = 0; + var height = 0; + + if (frame) + { + width = frame.realWidth; + height = frame.realHeight; + } + else if (gameObject.width) + { + width = gameObject.width; + height = gameObject.height; + } + + if (width !== 0 && height !== 0) + { + gameObject.input = InteractiveObject(gameObject, new Rectangle(0, 0, width, height), callback); + + this.queueForInsertion(gameObject); + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setHitAreaRectangle + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having a rectangular hit area. + * @param {number} x - The top-left of the rectangle. + * @param {number} y - The top-left of the rectangle. + * @param {number} width - The width of the rectangle. + * @param {number} height - The height of the rectangle. + * @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Rectangle.Contains. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setHitAreaRectangle: function (gameObjects, x, y, width, height, callback) + { + if (callback === undefined) { callback = RectangleContains; } + + var shape = new Rectangle(x, y, width, height); + + return this.setHitArea(gameObjects, shape, callback); + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setHitAreaTriangle + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having a triangular hit area. + * @param {number} x1 - The x coordinate of the first point of the triangle. + * @param {number} y1 - The y coordinate of the first point of the triangle. + * @param {number} x2 - The x coordinate of the second point of the triangle. + * @param {number} y2 - The y coordinate of the second point of the triangle. + * @param {number} x3 - The x coordinate of the third point of the triangle. + * @param {number} y3 - The y coordinate of the third point of the triangle. + * @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Triangle.Contains. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setHitAreaTriangle: function (gameObjects, x1, y1, x2, y2, x3, y3, callback) + { + if (callback === undefined) { callback = TriangleContains; } + + var shape = new Triangle(x1, y1, x2, y2, x3, y3); + + return this.setHitArea(gameObjects, shape, callback); + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setPollAlways + * @since 3.0.0 + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setPollAlways: function () + { + this.pollRate = 0; + this._pollTimer = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setPollOnMove + * @since 3.0.0 + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setPollOnMove: function () + { + this.pollRate = -1; + this._pollTimer = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setPollRate + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setPollRate: function (value) + { + this.pollRate = value; + this._pollTimer = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setGlobalTopOnly + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setGlobalTopOnly: function (value) + { + this.manager.globalTopOnly = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#setTopOnly + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setTopOnly: function (value) + { + this.topOnly = value; + + return this; + }, + + /** + * Given an array of Game Objects, sort the array and return it, + * so that the objects are in index order with the lowest at the bottom. + * + * @method Phaser.Input.InputPlugin#sortGameObjects + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject[]} gameObjects - [description] + * + * @return {Phaser.GameObjects.GameObject[]} [description] + */ + sortGameObjects: function (gameObjects) + { + if (gameObjects.length < 2) + { + return gameObjects; + } + + this.scene.sys.depthSort(); + + return gameObjects.sort(this.sortHandlerGO.bind(this)); + }, + + /** + * Return the child lowest down the display list (with the smallest index) + * + * @method Phaser.Input.InputPlugin#sortHandlerGO + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} childA - [description] + * @param {Phaser.GameObjects.GameObject} childB - [description] + * + * @return {integer} [description] + */ + sortHandlerGO: function (childA, childB) + { + // The higher the index, the lower down the display list they are. + // So entry 0 will be the top-most item (visually) + var indexA = this.displayList.getIndex(childA); + var indexB = this.displayList.getIndex(childB); + + if (indexA < indexB) + { + return 1; + } + else if (indexA > indexB) + { + return -1; + } + + // Technically this shouldn't happen, but if the GO wasn't part of this display list then it'll + // have an index of -1, so in some cases it can + return 0; + }, + + /** + * Return the child lowest down the display list (with the smallest index) + * + * @method Phaser.Input.InputPlugin#sortHandlerIO + * @since 3.0.0 + * + * @param {Phaser.Input.InteractiveObject} childA - [description] + * @param {Phaser.Input.InteractiveObject} childB - [description] + * + * @return {integer} [description] + */ + sortHandlerIO: function (childA, childB) + { + // The higher the index, the lower down the display list they are. + // So entry 0 will be the top-most item (visually) + var indexA = this.displayList.getIndex(childA.gameObject); + var indexB = this.displayList.getIndex(childB.gameObject); + + if (indexA < indexB) + { + return 1; + } + else if (indexA > indexB) + { + return -1; + } + + // Technically this shouldn't happen, but if the GO wasn't part of this display list then it'll + // have an index of -1, so in some cases it can + return 0; + }, + + /** + * Given an array of Interactive Objects, sort the array and return it, + * so that the objects are in index order with the lowest at the bottom. + * + * @method Phaser.Input.InputPlugin#sortInteractiveObjects + * @since 3.0.0 + * + * @param {Phaser.Input.InteractiveObject[]} interactiveObjects - [description] + * + * @return {Phaser.Input.InteractiveObject[]} [description] + */ + sortInteractiveObjects: function (interactiveObjects) + { + if (interactiveObjects.length < 2) + { + return interactiveObjects; + } + + this.scene.sys.depthSort(); + + return interactiveObjects.sort(this.sortHandlerIO.bind(this)); + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#stopPropagation + * @since 3.0.0 + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + stopPropagation: function () + { + if (this.manager.globalTopOnly) + { + this.manager.ignoreEvents = true; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#update + * @since 3.0.0 + * + * @param {number} time - [description] + * @param {number} delta - [description] + */ + update: function (time, delta) + { + var manager = this.manager; + + // Another Scene above this one has already consumed the input events + if (manager.globalTopOnly && manager.ignoreEvents) + { + return; + } + + var pointer = manager.activePointer; + + var runUpdate = (pointer.dirty || this.pollRate === 0); + + if (this.pollRate > -1) + { + this._pollTimer -= delta; + + if (this._pollTimer < 0) + { + runUpdate = true; + + // Discard timer diff + this._pollTimer = this.pollRate; + } + } + + if (!runUpdate) + { + return; + } + + // Always reset this array + this._tempZones = []; + + // _temp contains a hit tested and camera culled list of IO objects + this._temp = this.hitTestPointer(pointer); + + this.sortGameObjects(this._temp); + this.sortGameObjects(this._tempZones); + + if (this.topOnly) + { + // Only the top-most one counts now, so safely ignore the rest + if (this._temp.length) + { + this._temp.splice(1); + } + + if (this._tempZones.length) + { + this._tempZones.splice(1); + } + } + + var total = this.processDragEvents(pointer, time); + + if (!pointer.wasTouch) + { + total += this.processOverOutEvents(pointer); + } + + if (pointer.justDown) + { + total += this.processDownEvents(pointer); + } + + if (pointer.justUp) + { + total += this.processUpEvents(pointer); + } + + if (pointer.justMoved) + { + total += this.processMoveEvents(pointer); + } + + if (total > 0 && manager.globalTopOnly) + { + // We interacted with an event in this Scene, so block any Scenes below us from doing the same this frame + manager.ignoreEvents = true; + } + }, + + /** + * The Scene that owns this plugin is shutting down. + * + * @method Phaser.Input.InputPlugin#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this._temp.length = 0; + this._list.length = 0; + this._draggable.length = 0; + this._pendingRemoval.length = 0; + this._pendingInsertion.length = 0; + + for (var i = 0; i < 10; i++) + { + this._drag[i] = []; + this._over[i] = []; + } + + this.removeAllListeners(); + }, + + /** + * [description] + * + * @method Phaser.Input.InputPlugin#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + + this.scene = undefined; + this.cameras = undefined; + this.manager = undefined; + this.events = undefined; + this.keyboard = undefined; + this.mouse = undefined; + this.gamepad = undefined; + }, + + /** + * The current active input Pointer. + * + * @name Phaser.Input.InputPlugin#activePointer + * @type {Phaser.Input.Pointer} + * @readOnly + * @since 3.0.0 + */ + activePointer: { + + get: function () + { + return this.manager.activePointer; + } + + }, + + /** + * The x coordinates of the ActivePointer based on the first camera in the camera list. + * This is only safe to use if your game has just 1 non-transformed camera and doesn't use multi-touch. + * + * @name Phaser.Input.InputPlugin#x + * @type {number} + * @readOnly + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.manager.activePointer.x; + } + + }, + + /** + * The y coordinates of the ActivePointer based on the first camera in the camera list. + * This is only safe to use if your game has just 1 non-transformed camera and doesn't use multi-touch. + * + * @name Phaser.Input.InputPlugin#y + * @type {number} + * @readOnly + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.manager.activePointer.y; + } + + } + +}); + +PluginManager.register('InputPlugin', InputPlugin, 'input'); + +module.exports = InputPlugin; /***/ }), /* 561 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -96597,30 +97369,50 @@ module.exports = Clone; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Contains = __webpack_require__(68); - /** - * Check to see if the Ellipse contains the given Point object. + * XBox 360 Gamepad Configuration. * - * @function Phaser.Geom.Ellipse.ContainsPoint + * @name Phaser.Input.Gamepad.Configs.XBOX_360 + * @type {object} * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. - * @param {Phaser.Geom.Point|object} point - The Point object to check if it's within the Circle or not. - * - * @return {boolean} True if the Point coordinates are within the circle, otherwise false. */ -var ContainsPoint = function (ellipse, point) -{ - return Contains(ellipse, point.x, point.y); -}; +module.exports = { -module.exports = ContainsPoint; + UP: 12, + DOWN: 13, + LEFT: 14, + RIGHT: 15, + + MENU: 16, + + A: 0, + B: 1, + X: 2, + Y: 3, + + LB: 4, + RB: 5, + + LT: 6, + RT: 7, + + BACK: 8, + START: 9, + + LS: 10, + RS: 11, + + LEFT_STICK_H: 0, + LEFT_STICK_V: 1, + RIGHT_STICK_H: 2, + RIGHT_STICK_V: 3 + +}; /***/ }), /* 562 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -96628,30 +97420,33 @@ module.exports = ContainsPoint; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Contains = __webpack_require__(68); - /** - * Check to see if the Ellipse contains all four points of the given Rectangle object. + * Tatar SNES USB Controller Gamepad Configuration. + * USB Gamepad (STANDARD GAMEPAD Vendor: 0079 Product: 0011) * - * @function Phaser.Geom.Ellipse.ContainsRect + * @name Phaser.Input.Gamepad.Configs.SNES_USB + * @type {object} * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - [description] - * @param {Phaser.Geom.Rectangle|object} rect - The Rectangle object to check if it's within the Ellipse or not. - * - * @return {boolean} True if all of the Rectangle coordinates are within the ellipse, otherwise false. */ -var ContainsRect = function (ellipse, rect) -{ - return ( - Contains(ellipse, rect.x, rect.y) && - Contains(ellipse, rect.right, rect.y) && - Contains(ellipse, rect.x, rect.bottom) && - Contains(ellipse, rect.right, rect.bottom) - ); -}; +module.exports = { -module.exports = ContainsRect; + UP: 12, + DOWN: 13, + LEFT: 14, + RIGHT: 15, + + SELECT: 8, + START: 9, + + B: 0, + A: 1, + Y: 2, + X: 3, + + LEFT_SHOULDER: 4, + RIGHT_SHOULDER: 5 + +}; /***/ }), @@ -96665,28 +97460,48 @@ module.exports = ContainsRect; */ /** - * Copies the `x`, `y`, `width` and `height` properties from the `source` Ellipse - * into the given `dest` Ellipse, then returns the `dest` Ellipse. + * PlayStation DualShock 4 Gamepad Configuration. + * Sony PlayStation DualShock 4 (v2) wireless controller * - * @function Phaser.Geom.Ellipse.CopyFrom + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4 + * @type {object} * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} source - The source Ellipse to copy the values from. - * @param {Phaser.Geom.Ellipse} dest - The destination Ellipse to copy the values to. - * - * @return {Phaser.Geom.Ellipse} The dest Ellipse. */ -var CopyFrom = function (source, dest) -{ - return dest.setTo(source.x, source.y, source.width, source.height); -}; +module.exports = { -module.exports = CopyFrom; + UP: 12, + DOWN: 13, + LEFT: 14, + RIGHT: 15, + + SHARE: 8, + OPTIONS: 9, + PS: 16, + TOUCHBAR: 17, + + X: 0, + CIRCLE: 1, + SQUARE: 2, + TRIANGLE: 3, + + L1: 4, + R1: 5, + L2: 6, + R2: 7, + L3: 10, + R3: 11, + + LEFT_STICK_H: 0, + LEFT_STICK_V: 1, + RIGHT_STICK_H: 2, + RIGHT_STICK_V: 3 + +}; /***/ }), /* 564 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -96695,28 +97510,16 @@ module.exports = CopyFrom; */ /** - * Compares the `x`, `y`, `width` and `height` properties of the two given Ellipses. - * Returns `true` if they all match, otherwise returns `false`. - * - * @function Phaser.Geom.Ellipse.Equals - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The first Ellipse to compare. - * @param {Phaser.Geom.Ellipse} toCompare - The second Ellipse to compare. - * - * @return {boolean} `true` if the two Ellipse equal each other, otherwise `false`. + * @namespace Phaser.Input.Gamepad.Configs */ -var Equals = function (ellipse, toCompare) -{ - return ( - ellipse.x === toCompare.x && - ellipse.y === toCompare.y && - ellipse.width === toCompare.width && - ellipse.height === toCompare.height - ); -}; -module.exports = Equals; +module.exports = { + + DUALSHOCK_4: __webpack_require__(563), + SNES_USB: __webpack_require__(562), + XBOX_360: __webpack_require__(561) + +}; /***/ }), @@ -96729,37 +97532,24 @@ module.exports = Equals; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Rectangle = __webpack_require__(8); - /** - * Returns the bounds of the Ellipse object. - * - * @function Phaser.Geom.Ellipse.GetBounds - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the bounds from. - * @param {Phaser.Geom.Rectangle|object} [out] - A Rectangle, or rectangle-like object, to store the ellipse bounds in. If not given a new Rectangle will be created. - * - * @return {Phaser.Geom.Rectangle|object} The Rectangle object containing the Ellipse bounds. + * @namespace Phaser.Input.Gamepad */ -var GetBounds = function (ellipse, out) -{ - if (out === undefined) { out = new Rectangle(); } - out.x = ellipse.left; - out.y = ellipse.top; - out.width = ellipse.width; - out.height = ellipse.height; +module.exports = { - return out; + Axis: __webpack_require__(296), + Button: __webpack_require__(295), + Gamepad: __webpack_require__(297), + GamepadManager: __webpack_require__(298), + + Configs: __webpack_require__(564) }; -module.exports = GetBounds; - /***/ }), /* 566 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -96768,31 +97558,26 @@ module.exports = GetBounds; */ /** - * Offsets the Ellipse by the values given. - * - * @function Phaser.Geom.Ellipse.Offset - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to be offset (translated.) - * @param {number} x - The amount to horizontally offset the Ellipse by. - * @param {number} y - The amount to vertically offset the Ellipse by. - * - * @return {Phaser.Geom.Ellipse} The Ellipse that was offset. + * @namespace Phaser.Input */ -var Offset = function (ellipse, x, y) -{ - ellipse.x += x; - ellipse.y += y; - return ellipse; +module.exports = { + + Gamepad: __webpack_require__(565), + InputManager: __webpack_require__(299), + InputPlugin: __webpack_require__(560), + InteractiveObject: __webpack_require__(227), + Keyboard: __webpack_require__(559), + Mouse: __webpack_require__(554), + Pointer: __webpack_require__(290), + Touch: __webpack_require__(553) + }; -module.exports = Offset; - /***/ }), /* 567 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -96800,26 +97585,26 @@ module.exports = Offset; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var RotateAroundXY = __webpack_require__(123); + /** - * Offsets the Ellipse by the values given in the `x` and `y` properties of the Point object. + * [description] * - * @function Phaser.Geom.Ellipse.OffsetPoint + * @function Phaser.Geom.Triangle.RotateAroundPoint * @since 3.0.0 * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to be offset (translated.) - * @param {Phaser.Geom.Point|object} point - The Point object containing the values to offset the Ellipse by. + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Point} point - [description] + * @param {number} angle - [description] * - * @return {Phaser.Geom.Ellipse} The Ellipse that was offset. + * @return {Phaser.Geom.Triangle} [description] */ -var OffsetPoint = function (ellipse, point) +var RotateAroundPoint = function (triangle, point, angle) { - ellipse.x += point.x; - ellipse.y += point.y; - - return ellipse; + return RotateAroundXY(triangle, point.x, point.y, angle); }; -module.exports = OffsetPoint; +module.exports = RotateAroundPoint; /***/ }), @@ -96832,29 +97617,29 @@ module.exports = OffsetPoint; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); +var RotateAroundXY = __webpack_require__(123); +var InCenter = __webpack_require__(228); -if (true) +/** + * [description] + * + * @function Phaser.Geom.Triangle.Rotate + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} angle - [description] + * + * @return {Phaser.Geom.Triangle} [description] + */ +var Rotate = function (triangle, angle) { - renderWebGL = __webpack_require__(569); - - // Needed for Graphics.generateTexture - renderCanvas = __webpack_require__(274); -} - -if (true) -{ - renderCanvas = __webpack_require__(274); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas + var point = InCenter(triangle); + return RotateAroundXY(triangle, point.x, point.y, angle); }; +module.exports = Rotate; + /***/ }), /* 569 */ @@ -96866,38 +97651,35 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(1); +var Length = __webpack_require__(77); + +// The 2D area of a triangle. The area value is always non-negative. /** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. + * [description] * - * @method Phaser.GameObjects.Graphics#renderWebGL + * @function Phaser.Geom.Triangle.Perimeter * @since 3.0.0 - * @private * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Graphics} graphics - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.Geom.Triangle} triangle - [description] + * + * @return {number} [description] */ -var GraphicsWebGLRenderer = function (renderer, graphics, interpolationPercentage, camera) +var Perimeter = function (triangle) { - if (GameObject.RENDER_MASK !== graphics.renderFlags || (graphics.cameraFilter > 0 && (graphics.cameraFilter & camera._id))) - { - return; - } + var line1 = triangle.getLineA(); + var line2 = triangle.getLineB(); + var line3 = triangle.getLineC(); - this.pipeline.batchGraphics(this, camera); + return (Length(line1) + Length(line2) + Length(line3)); }; -module.exports = GraphicsWebGLRenderer; +module.exports = Perimeter; /***/ }), /* 570 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -96905,30 +97687,35 @@ module.exports = GraphicsWebGLRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) +/** + * [description] + * + * @function Phaser.Geom.Triangle.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Triangle} toCompare - [description] + * + * @return {boolean} [description] + */ +var Equals = function (triangle, toCompare) { - renderWebGL = __webpack_require__(571); -} - -if (true) -{ - renderCanvas = __webpack_require__(572); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - + return ( + triangle.x1 === toCompare.x1 && + triangle.y1 === toCompare.y1 && + triangle.x2 === toCompare.x2 && + triangle.y2 === toCompare.y2 && + triangle.x3 === toCompare.x3 && + triangle.y3 === toCompare.y3 + ); }; +module.exports = Equals; + /***/ }), /* 571 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -96936,33 +97723,23 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(1); - /** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. + * [description] * - * @method Phaser.GameObjects.Image#renderWebGL + * @function Phaser.Geom.Triangle.CopyFrom * @since 3.0.0 - * @private * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Image} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.Geom.Triangle} source - [description] + * @param {Phaser.Geom.Triangle} dest - [description] + * + * @return {Phaser.Geom.Triangle} [description] */ -var ImageWebGLRenderer = function (renderer, src, interpolationPercentage, camera) +var CopyFrom = function (source, dest) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.batchSprite(src, camera); + return dest.setTo(source.x1, source.y1, source.x2, source.y2, source.x3, source.y3); }; -module.exports = ImageWebGLRenderer; +module.exports = CopyFrom; /***/ }), @@ -96975,33 +97752,25 @@ module.exports = ImageWebGLRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(1); +var Contains = __webpack_require__(54); /** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. + * [description] * - * @method Phaser.GameObjects.Image#renderCanvas + * @function Phaser.Geom.Triangle.ContainsPoint * @since 3.0.0 - * @private * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Image} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Point} point - [description] + * + * @return {boolean} [description] */ -var ImageCanvasRenderer = function (renderer, src, interpolationPercentage, camera) +var ContainsPoint = function (triangle, point) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - renderer.drawImage(src, camera); + return Contains(triangle, point.x, point.y); }; -module.exports = ImageCanvasRenderer; +module.exports = ContainsPoint; /***/ }), @@ -97014,209 +97783,24 @@ module.exports = ImageCanvasRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(2); +var Triangle = __webpack_require__(52); /** - * @classdesc * [description] * - * @class GravityWell - * @memberOf Phaser.GameObjects.Particles - * @constructor + * @function Phaser.Geom.Triangle.Clone * @since 3.0.0 * - * @param {number|object} [x=0] - The x coordinate of the Gravity Well, in world space. - * @param {number} [y=0] - The y coordinate of the Gravity Well, in world space. - * @param {number} [power=0] - The power of the Gravity Well. - * @param {number} [epsilon=100] - [description] - * @param {number} [gravity=50] - The gravitational force of this Gravity Well. + * @param {Phaser.Geom.Triangle} source - [description] + * + * @return {Phaser.Geom.Triangle} [description] */ -var GravityWell = new Class({ +var Clone = function (source) +{ + return new Triangle(source.x1, source.y1, source.x2, source.y2, source.x3, source.y3); +}; - initialize: - - function GravityWell (x, y, power, epsilon, gravity) - { - if (typeof x === 'object') - { - var config = x; - - x = GetFastValue(config, 'x', 0); - y = GetFastValue(config, 'y', 0); - power = GetFastValue(config, 'power', 0); - epsilon = GetFastValue(config, 'epsilon', 100); - gravity = GetFastValue(config, 'gravity', 50); - } - else - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (power === undefined) { power = 0; } - if (epsilon === undefined) { epsilon = 100; } - if (gravity === undefined) { gravity = 50; } - } - - /** - * The x coordinate of the Gravity Well, in world space. - * - * @name Phaser.GameObjects.Particles.GravityWell#x - * @type {number} - * @since 3.0.0 - */ - this.x = x; - - /** - * The y coordinate of the Gravity Well, in world space. - * - * @name Phaser.GameObjects.Particles.GravityWell#y - * @type {number} - * @since 3.0.0 - */ - this.y = y; - - /** - * The active state of the Gravity Well. An inactive Gravity Well will not influence any particles. - * - * @name Phaser.GameObjects.Particles.GravityWell#active - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.active = true; - - /** - * Internal gravity value. - * - * @name Phaser.GameObjects.Particles.GravityWell#_gravity - * @type {number} - * @private - * @since 3.0.0 - */ - this._gravity = gravity; - - /** - * Internal power value. - * - * @name Phaser.GameObjects.Particles.GravityWell#_power - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._power = 0; - - /** - * Internal epsilon value. - * - * @name Phaser.GameObjects.Particles.GravityWell#_epsilon - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._epsilon = 0; - - /** - * The power of the Gravity Well. - * - * @name Phaser.GameObjects.Particles.GravityWell#power - * @type {number} - * @since 3.0.0 - */ - this.power = power; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.GravityWell#epsilon - * @type {number} - * @since 3.0.0 - */ - this.epsilon = epsilon; - }, - - /** - * Takes a Particle and updates it based on the properties of this Gravity Well. - * - * @method Phaser.GameObjects.Particles.GravityWell#update - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle to update. - * @param {number} delta - The delta time in ms. - * @param {float} step - The delta value divided by 1000. - */ - update: function (particle, delta) - { - var x = this.x - particle.x; - var y = this.y - particle.y; - var dSq = x * x + y * y; - - if (dSq === 0) - { - return; - } - - var d = Math.sqrt(dSq); - - if (dSq < this._epsilon) - { - dSq = this._epsilon; - } - - var factor = ((this._power * delta) / (dSq * d)) * 100; - - particle.velocityX += x * factor; - particle.velocityY += y * factor; - }, - - epsilon: { - - get: function () - { - return Math.sqrt(this._epsilon); - }, - - set: function (value) - { - this._epsilon = value * value; - } - - }, - - power: { - - get: function () - { - return this._power / this._gravity; - }, - - set: function (value) - { - this._power = value * this._gravity; - } - - }, - - gravity: { - - get: function () - { - return this._gravity; - }, - - set: function (value) - { - var pwr = this.power; - this._gravity = value; - this.power = pwr; - } - - } - -}); - -module.exports = GravityWell; +module.exports = Clone; /***/ }), @@ -97229,1975 +97813,75 @@ module.exports = GravityWell; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BlendModes = __webpack_require__(45); -var Class = __webpack_require__(0); -var Components = __webpack_require__(11); -var DeathZone = __webpack_require__(575); -var EdgeZone = __webpack_require__(576); -var EmitterOp = __webpack_require__(577); -var GetFastValue = __webpack_require__(2); -var GetRandomElement = __webpack_require__(140); -var HasAny = __webpack_require__(289); -var HasValue = __webpack_require__(72); -var Particle = __webpack_require__(611); -var RandomZone = __webpack_require__(612); -var Rectangle = __webpack_require__(8); -var StableSort = __webpack_require__(267); -var Vector2 = __webpack_require__(6); -var Wrap = __webpack_require__(50); +var Circle = __webpack_require__(79); + +// Adapted from https://gist.github.com/mutoo/5617691 /** - * @classdesc * [description] * - * @class ParticleEmitter - * @memberOf Phaser.GameObjects.Particles - * @constructor + * @function Phaser.Geom.Triangle.CircumCircle * @since 3.0.0 * - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Visible + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Circle} [out] - [description] * - * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} manager - The Emitter Manager this Emitter belongs to. - * @param {object} config - [description] + * @return {Phaser.Geom.Circle} [description] */ -var ParticleEmitter = new Class({ +var CircumCircle = function (triangle, out) +{ + if (out === undefined) { out = new Circle(); } - Mixins: [ - Components.BlendMode, - Components.ScrollFactor, - Components.Visible - ], + // A + var x1 = triangle.x1; + var y1 = triangle.y1; - initialize: + // B + var x2 = triangle.x2; + var y2 = triangle.y2; - function ParticleEmitter (manager, config) + // C + var x3 = triangle.x3; + var y3 = triangle.y3; + + var A = x2 - x1; + var B = y2 - y1; + var C = x3 - x1; + var D = y3 - y1; + var E = A * (x1 + x2) + B * (y1 + y2); + var F = C * (x1 + x3) + D * (y1 + y3); + var G = 2 * (A * (y3 - y2) - B * (x3 - x2)); + + var dx; + var dy; + + // If the points of the triangle are collinear, then just find the + // extremes and use the midpoint as the center of the circumcircle. + + if (Math.abs(G) < 0.000001) { - /** - * The Emitter Manager this Emitter belongs to. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#manager - * @type {Phaser.GameObjects.Particles.ParticleEmitterManager} - * @since 3.0.0 - */ - this.manager = manager; + var minX = Math.min(x1, x2, x3); + var minY = Math.min(y1, y2, y3); + dx = (Math.max(x1, x2, x3) - minX) * 0.5; + dy = (Math.max(y1, y2, y3) - minY) * 0.5; - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#texture - * @type {Phaser.Textures.Texture} - * @since 3.0.0 - */ - this.texture = manager.texture; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#frames - * @type {Phaser.Textures.Frame[]} - * @since 3.0.0 - */ - this.frames = [ manager.defaultFrame ]; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#defaultFrame - * @type {Phaser.Textures.Frame} - * @since 3.0.0 - */ - this.defaultFrame = manager.defaultFrame; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#configFastMap - * @type {object} - * @since 3.0.0 - */ - this.configFastMap = [ - 'active', - 'blendMode', - 'collideBottom', - 'collideLeft', - 'collideRight', - 'collideTop', - 'deathCallback', - 'deathCallbackScope', - 'emitCallback', - 'emitCallbackScope', - 'follow', - 'frequency', - 'gravityX', - 'gravityY', - 'maxParticles', - 'name', - 'on', - 'particleBringToTop', - 'particleClass', - 'radial', - 'timeScale', - 'trackVisible', - 'visible' - ]; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#configOpMap - * @type {object} - * @since 3.0.0 - */ - this.configOpMap = [ - 'accelerationX', - 'accelerationY', - 'alpha', - 'bounce', - 'delay', - 'lifespan', - 'maxVelocityX', - 'maxVelocityY', - 'moveToX', - 'moveToY', - 'quantity', - 'rotate', - 'scaleX', - 'scaleY', - 'speedX', - 'speedY', - 'tint', - 'x', - 'y' - ]; - - /** - * The name of this Game Object. - * - * Empty by default and never populated by Phaser, this is left for developers to use. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#name - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.name = ''; - - /** - * The Particle Class which will be emitted by this Emitter. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#particleClass - * @type {Phaser.GameObjects.Particles.Particle} - * @since 3.0.0 - */ - this.particleClass = Particle; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#x - * @type {number} - * @since 3.0.0 - */ - this.x = new EmitterOp(config, 'x', 0); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#y - * @type {number} - * @since 3.0.0 - */ - this.y = new EmitterOp(config, 'y', 0); - - /** - * A radial emitter will emit particles in all directions between angle min and max, - * using speed as the value. If set to false then this acts as a point Emitter. - * A point emitter will emit particles only in the direction derived from the speedX and speedY values. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#radial - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.radial = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#gravityX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.gravityX = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#gravityY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.gravityY = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#acceleration - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.acceleration = false; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#accelerationX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.accelerationX = new EmitterOp(config, 'accelerationX', 0, true); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#accelerationY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.accelerationY = new EmitterOp(config, 'accelerationY', 0, true); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityX - * @type {number} - * @default 10000 - * @since 3.0.0 - */ - this.maxVelocityX = new EmitterOp(config, 'maxVelocityX', 10000, true); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityY - * @type {number} - * @default 10000 - * @since 3.0.0 - */ - this.maxVelocityY = new EmitterOp(config, 'maxVelocityY', 10000, true); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#speedX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.speedX = new EmitterOp(config, 'speedX', 0, true); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#speedY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.speedY = new EmitterOp(config, 'speedY', 0, true); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#moveTo - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.moveTo = false; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#moveToX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.moveToX = new EmitterOp(config, 'moveToX', 0, true); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#moveToY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.moveToY = new EmitterOp(config, 'moveToY', 0, true); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#bounce - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.bounce = new EmitterOp(config, 'bounce', 0, true); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#scaleX - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.scaleX = new EmitterOp(config, 'scaleX', 1); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#scaleY - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.scaleY = new EmitterOp(config, 'scaleY', 1); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#tint - * @type {integer} - * @since 3.0.0 - */ - this.tint = new EmitterOp(config, 'tint', 0xffffffff); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#alpha - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.alpha = new EmitterOp(config, 'alpha', 1); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#lifespan - * @type {number} - * @default 1000 - * @since 3.0.0 - */ - this.lifespan = new EmitterOp(config, 'lifespan', 1000); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#angle - * @type {number} - * @since 3.0.0 - */ - this.angle = new EmitterOp(config, 'angle', { min: 0, max: 360 }); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#rotate - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.rotate = new EmitterOp(config, 'rotate', 0); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#emitCallback - * @type {?function} - * @default null - * @since 3.0.0 - */ - this.emitCallback = null; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope - * @type {?object} - * @default null - * @since 3.0.0 - */ - this.emitCallbackScope = null; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#deathCallback - * @type {?function} - * @default null - * @since 3.0.0 - */ - this.deathCallback = null; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope - * @type {?object} - * @default null - * @since 3.0.0 - */ - this.deathCallbackScope = null; - - /** - * Set to hard limit the amount of particle objects this emitter is allowed to create. - * 0 means unlimited. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#maxParticles - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.maxParticles = 0; - - /** - * How many particles are emitted each time the emitter updates. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#quantity - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.quantity = new EmitterOp(config, 'quantity', 1, true); - - /** - * How many ms to wait after emission before the particles start updating. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#delay - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.delay = new EmitterOp(config, 'delay', 0, true); - - /** - * How often a particle is emitted in ms (if emitter is a constant / flow emitter) - * If emitter is an explosion emitter this value will be -1. - * Anything > -1 sets this to be a flow emitter. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#frequency - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.frequency = 0; - - /** - * Controls if the emitter is currently emitting particles. - * Already alive particles will continue to update until they expire. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#on - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.on = true; - - /** - * Newly emitted particles are added to the top of the particle list, i.e. rendered above those already alive. - * Set to false to send them to the back. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#particleBringToTop - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.particleBringToTop = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#timeScale - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#emitZone - * @type {?object} - * @default null - * @since 3.0.0 - */ - this.emitZone = null; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#deathZone - * @type {?object} - * @default null - * @since 3.0.0 - */ - this.deathZone = null; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#bounds - * @type {?Phaser.Geom.Rectangle} - * @default null - * @since 3.0.0 - */ - this.bounds = null; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#collideLeft - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.collideLeft = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#collideRight - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.collideRight = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#collideTop - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.collideTop = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#collideBottom - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.collideBottom = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#active - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.active = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#visible - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.visible = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#blendMode - * @type {integer} - * @since 3.0.0 - */ - this.blendMode = BlendModes.NORMAL; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#follow - * @type {?[type]} - * @default null - * @since 3.0.0 - */ - this.follow = null; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#followOffset - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.followOffset = new Vector2(); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#trackVisible - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.trackVisible = false; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#currentFrame - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.currentFrame = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#randomFrame - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.randomFrame = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#frameQuantity - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.frameQuantity = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#dead - * @type {array} - * @private - * @since 3.0.0 - */ - this.dead = []; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#alive - * @type {array} - * @private - * @since 3.0.0 - */ - this.alive = []; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#_counter - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._counter = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#_frameCounter - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._frameCounter = 0; - - if (config) - { - this.fromJSON(config); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#fromJSON - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - fromJSON: function (config) + out.x = minX + dx; + out.y = minY + dy; + out.radius = Math.sqrt(dx * dx + dy * dy); + } + else { - if (!config) - { - return this; - } - - // Only update properties from their current state if they exist in the given config - - var i = 0; - var key = ''; - - for (i = 0; i < this.configFastMap.length; i++) - { - key = this.configFastMap[i]; - - if (HasValue(config, key)) - { - this[key] = GetFastValue(config, key); - } - } - - for (i = 0; i < this.configOpMap.length; i++) - { - key = this.configOpMap[i]; - - if (HasValue(config, key)) - { - this[key].loadConfig(config); - } - } - - this.acceleration = (this.accelerationX.propertyValue !== 0 || this.accelerationY.propertyValue !== 0); - - this.moveTo = (this.moveToX.propertyValue !== 0 || this.moveToY.propertyValue !== 0); - - // Special 'speed' override - - if (HasValue(config, 'speed')) - { - this.speedX.loadConfig(config, 'speed'); - this.speedY = null; - } - - // If you specify speedX, speedY ot moveTo then it changes the emitter from radial to a point emitter - if (HasAny(config, [ 'speedX', 'speedY' ]) || this.moveTo) - { - this.radial = false; - } - - // Special 'scale' override - - if (HasValue(config, 'scale')) - { - this.scaleX.loadConfig(config, 'scale'); - this.scaleY = null; - } - - if (HasValue(config, 'callbackScope')) - { - var callbackScope = GetFastValue(config, 'callbackScope', null); - - this.emitCallbackScope = callbackScope; - this.deathCallbackScope = callbackScope; - } - - if (HasValue(config, 'emitZone')) - { - this.setEmitZone(config.emitZone); - } - - if (HasValue(config, 'deathZone')) - { - this.setDeathZone(config.deathZone); - } - - if (HasValue(config, 'bounds')) - { - this.setBounds(config.bounds); - } - - if (HasValue(config, 'followOffset')) - { - this.followOffset.setFromObject(GetFastValue(config, 'followOffset', 0)); - } - - if (HasValue(config, 'frame')) - { - this.setFrame(config.frame); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#toJSON - * @since 3.0.0 - * - * @param {object} output - [description] - * - * @return {object} [description] - */ - toJSON: function (output) - { - if (output === undefined) { output = {}; } - - var i = 0; - var key = ''; - - for (i = 0; i < this.configFastMap.length; i++) - { - key = this.configFastMap[i]; - - output[key] = this[key]; - } - - for (i = 0; i < this.configOpMap.length; i++) - { - key = this.configOpMap[i]; - - if (this[key]) - { - output[key] = this[key].toJSON(); - } - } - - // special handlers - if (!this.speedY) - { - delete output.speedX; - output.speed = this.speedX.toJSON(); - } - - if (!this.scaleY) - { - delete output.scaleX; - output.scale = this.scaleX.toJSON(); - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#startFollow - * @since 3.0.0 - * - * @param {[type]} target - [description] - * @param {number} offsetX - [description] - * @param {number} offsetY - [description] - * @param {boolean} trackVisible - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - startFollow: function (target, offsetX, offsetY, trackVisible) - { - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - if (trackVisible === undefined) { trackVisible = false; } - - this.follow = target; - this.followOffset.set(offsetX, offsetY); - this.trackVisible = trackVisible; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#stopFollow - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - stopFollow: function () - { - this.follow = null; - this.followOffset.set(0, 0); - this.trackVisible = false; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#getFrame - * @since 3.0.0 - * - * @return {Phaser.Textures.Frame} [description] - */ - getFrame: function () - { - if (this.frames.length === 1) - { - return this.defaultFrame; - } - else if (this.randomFrame) - { - return GetRandomElement(this.frames); - } - else - { - var frame = this.frames[this.currentFrame]; - - this._frameCounter++; - - if (this._frameCounter === this.frameQuantity) - { - this._frameCounter = 0; - this.currentFrame = Wrap(this.currentFrame + 1, 0, this._frameLength); - } - - return frame; - } - }, - - // frame: 0 - // frame: 'red' - // frame: [ 0, 1, 2, 3 ] - // frame: [ 'red', 'green', 'blue', 'pink', 'white' ] - // frame: { frames: [ 'red', 'green', 'blue', 'pink', 'white' ], [cycle: bool], [quantity: int] } - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setFrame - * @since 3.0.0 - * - * @param {array|string|integer|object} frames - [description] - * @param {boolean} [pickRandom=true] - [description] - * @param {integer} [quantity=1] - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setFrame: function (frames, pickRandom, quantity) - { - if (pickRandom === undefined) { pickRandom = true; } - if (quantity === undefined) { quantity = 1; } - - this.randomFrame = pickRandom; - this.frameQuantity = quantity; - this.currentFrame = 0; - this._frameCounter = 0; - - var t = typeof (frames); - - if (Array.isArray(frames) || t === 'string' || t === 'number') - { - this.manager.setEmitterFrames(frames, this); - } - else if (t === 'object') - { - var frameConfig = frames; - - frames = GetFastValue(frameConfig, 'frames', null); - - if (frames) - { - this.manager.setEmitterFrames(frames, this); - } - - var isCycle = GetFastValue(frameConfig, 'cycle', false); - - this.randomFrame = (isCycle) ? false : true; - - this.frameQuantity = GetFastValue(frameConfig, 'quantity', quantity); - } - - this._frameLength = this.frames.length; - - if (this._frameLength === 1) - { - this.frameQuantity = 1; - this.randomFrame = false; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setRadial - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setRadial: function (value) - { - if (value === undefined) { value = true; } - - this.radial = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setPosition - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setPosition: function (x, y) - { - this.x.onChange(x); - this.y.onChange(y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setBounds - * @since 3.0.0 - * - * @param {number|object} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setBounds: function (x, y, width, height) - { - if (typeof x === 'object') - { - var obj = x; - - x = obj.x; - y = obj.y; - width = (HasValue(obj, 'w')) ? obj.w : obj.width; - height = (HasValue(obj, 'h')) ? obj.h : obj.height; - } - - if (this.bounds) - { - this.bounds.setTo(x, y, width, height); - } - else - { - this.bounds = new Rectangle(x, y, width, height); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeedX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setSpeedX: function (value) - { - this.speedX.onChange(value); - - // If you specify speedX and Y then it changes the emitter from radial to a point emitter - this.radial = false; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeedY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setSpeedY: function (value) - { - if (this.speedY) - { - this.speedY.onChange(value); - - // If you specify speedX and Y then it changes the emitter from radial to a point emitter - this.radial = false; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeed - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setSpeed: function (value) - { - this.speedX.onChange(value); - this.speedY = null; - - // If you specify speedX and Y then it changes the emitter from radial to a point emitter - this.radial = true; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setScaleX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setScaleX: function (value) - { - this.scaleX.onChange(value); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setScaleY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setScaleY: function (value) - { - this.scaleY.onChange(value); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setScale - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setScale: function (value) - { - this.scaleX.onChange(value); - this.scaleY = null; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravityX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setGravityX: function (value) - { - this.gravityX = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravityY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setGravityY: function (value) - { - this.gravityY = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravity - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setGravity: function (x, y) - { - this.gravityX = x; - this.gravityY = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setAlpha - * @since 3.0.0 - * - * @param {float} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setAlpha: function (value) - { - this.alpha.onChange(value); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setEmitterAngle - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setEmitterAngle: function (value) - { - this.angle.onChange(value); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setAngle - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setAngle: function (value) - { - this.angle.onChange(value); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setLifespan - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setLifespan: function (value) - { - this.lifespan.onChange(value); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setQuantity - * @since 3.0.0 - * - * @param {integer} quantity - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setQuantity: function (quantity) - { - this.quantity.onChange(quantity); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setFrequency - * @since 3.0.0 - * - * @param {number} frequency - [description] - * @param {integer} [quantity] - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setFrequency: function (frequency, quantity) - { - this.frequency = frequency; - - this._counter = 0; - - if (quantity) - { - this.quantity.onChange(quantity); - } - - return this; - }, - - /** - * The zone must have a function called `getPoint` that takes a particle object and sets - * its x and y properties accordingly then returns that object. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone - * @since 3.0.0 - * - * @param {[type]} zoneConfig - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setEmitZone: function (zoneConfig) - { - if (zoneConfig === undefined) - { - this.emitZone = null; - } - else - { - // Where source = Geom like Circle, or a Path or Curve - // emitZone: { type: 'random', source: X } - // emitZone: { type: 'edge', source: X, quantity: 32, [stepRate=0], [yoyo=false], [seamless=true] } - - var type = GetFastValue(zoneConfig, 'type', 'random'); - var source = GetFastValue(zoneConfig, 'source', null); - - if (source && typeof source.getPoint === 'function') - { - switch (type) - { - case 'random': - - this.emitZone = new RandomZone(source); - - break; - - case 'edge': - - var quantity = GetFastValue(zoneConfig, 'quantity', 1); - var stepRate = GetFastValue(zoneConfig, 'stepRate', 0); - var yoyo = GetFastValue(zoneConfig, 'yoyo', false); - var seamless = GetFastValue(zoneConfig, 'seamless', true); - - this.emitZone = new EdgeZone(source, quantity, stepRate, yoyo, seamless); - - break; - } - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setDeathZone - * @since 3.0.0 - * - * @param {[type]} zoneConfig - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setDeathZone: function (zoneConfig) - { - if (zoneConfig === undefined) - { - this.deathZone = null; - } - else - { - // Where source = Geom like Circle or Rect that supports a 'contains' function - // deathZone: { type: 'onEnter', source: X } - // deathZone: { type: 'onLeave', source: X } - - var type = GetFastValue(zoneConfig, 'type', 'onEnter'); - var source = GetFastValue(zoneConfig, 'source', null); - - if (source && typeof source.contains === 'function') - { - var killOnEnter = (type === 'onEnter') ? true : false; - - this.deathZone = new DeathZone(source, killOnEnter); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#reserve - * @since 3.0.0 - * - * @param {integer} particleCount - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - reserve: function (particleCount) - { - var dead = this.dead; - - for (var i = 0; i < particleCount; i++) - { - dead.push(new this.particleClass(this)); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#getAliveParticleCount - * @since 3.0.0 - * - * @return {integer} The number of currently alive Particles in this Emitter. - */ - getAliveParticleCount: function () - { - return this.alive.length; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#getDeadParticleCount - * @since 3.0.0 - * - * @return {integer} The number of currently dead Particles in this Emitter. - */ - getDeadParticleCount: function () - { - return this.dead.length; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#getParticleCount - * @since 3.0.0 - * - * @return {integer} The number of Particles in this Emitter, including both alive and dead. - */ - getParticleCount: function () - { - return this.getAliveParticleCount() + this.getDeadParticleCount(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#atLimit - * @since 3.0.0 - * - * @return {boolean} Returns `true` if this Emitter is at its limit, or `false` if no limit, or below the `maxParticles` level. - */ - atLimit: function () - { - return (this.maxParticles > 0 && this.getParticleCount() === this.maxParticles); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#onParticleEmit - * @since 3.0.0 - * - * @param {[type]} callback - [description] - * @param {[type]} context - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - onParticleEmit: function (callback, context) - { - if (callback === undefined) - { - // Clear any previously set callback - this.emitCallback = null; - this.emitCallbackScope = null; - } - else if (typeof callback === 'function') - { - this.emitCallback = callback; - - if (context) - { - this.emitCallbackScope = context; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#onParticleDeath - * @since 3.0.0 - * - * @param {[type]} callback - [description] - * @param {[type]} context - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - onParticleDeath: function (callback, context) - { - if (callback === undefined) - { - // Clear any previously set callback - this.deathCallback = null; - this.deathCallbackScope = null; - } - else if (typeof callback === 'function') - { - this.deathCallback = callback; - - if (context) - { - this.deathCallbackScope = context; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#killAll - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - killAll: function () - { - var dead = this.dead; - var alive = this.alive; - - while (alive.length > 0) - { - dead.push(alive.pop()); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#forEachAlive - * @since 3.0.0 - * - * @param {[type]} callback - [description] - * @param {[type]} thisArg - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - forEachAlive: function (callback, thisArg) - { - var alive = this.alive; - var length = alive.length; - - for (var index = 0; index < length; ++index) - { - // Sends the Particle and the Emitter - callback.call(thisArg, alive[index], this); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#forEachDead - * @since 3.0.0 - * - * @param {[type]} callback - [description] - * @param {[type]} thisArg - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - forEachDead: function (callback, thisArg) - { - var dead = this.dead; - var length = dead.length; - - for (var index = 0; index < length; ++index) - { - // Sends the Particle and the Emitter - callback.call(thisArg, dead[index], this); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#start - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - start: function () - { - this.on = true; - - this._counter = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#pause - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - pause: function () - { - this.active = false; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#resume - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - resume: function () - { - this.active = true; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#depthSort - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - depthSort: function () - { - StableSort.inplace(this.alive, this.depthSortCallback); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#flow - * @since 3.0.0 - * - * @param {number} frequency - [description] - * @param {integer} [count=1] - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - flow: function (frequency, count) - { - if (count === undefined) { count = 1; } - - this.frequency = frequency; - - this.quantity.onChange(count); - - return this.start(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#explode - * @since 3.0.0 - * - * @param {integer} count - The amount of Particles to emit. - * @param {number} x - The x coordinate to emit the Particles from. - * @param {number} y - The y coordinate to emit the Particles from. - * - * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. - */ - explode: function (count, x, y) - { - this.frequency = -1; - - return this.emitParticle(count, x, y); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#emitParticleAt - * @since 3.0.0 - * - * @param {number} x - The x coordinate to emit the Particles from. - * @param {number} y - The y coordinate to emit the Particles from. - * @param {integer} count - The amount of Particles to emit. - * - * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. - */ - emitParticleAt: function (x, y, count) - { - return this.emitParticle(count, x, y); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#emitParticle - * @since 3.0.0 - * - * @param {integer} count - The amount of Particles to emit. - * @param {number} x - The x coordinate to emit the Particles from. - * @param {number} y - The y coordinate to emit the Particles from. - * - * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. - */ - emitParticle: function (count, x, y) - { - if (this.atLimit()) - { - return; - } - - if (count === undefined) - { - count = this.quantity.onEmit(); - } - - var dead = this.dead; - - for (var i = 0; i < count; i++) - { - var particle; - - if (dead.length > 0) - { - particle = dead.pop(); - } - else - { - particle = new this.particleClass(this); - } - - particle.fire(x, y); - - if (this.particleBringToTop) - { - this.alive.push(particle); - } - else - { - this.alive.unshift(particle); - } - - if (this.emitCallback) - { - this.emitCallback.call(this.emitCallbackScope, particle, this); - } - - if (this.atLimit()) - { - break; - } - } - - return particle; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#preUpdate - * @since 3.0.0 - * - * @param {[type]} time - [description] - * @param {[type]} delta - [description] - */ - preUpdate: function (time, delta) - { - // Scale the delta - delta *= this.timeScale; - - var step = (delta / 1000); - - if (this.trackVisible) - { - this.visible = this.follow.visible; - } - - // Any particle processors? - var processors = this.manager.getProcessors(); - - var particles = this.alive; - var length = particles.length; - - for (var index = 0; index < length; index++) - { - var particle = particles[index]; - - // update returns `true` if the particle is now dead (lifeStep < 0) - if (particle.update(delta, step, processors)) - { - // Moves the dead particle to the end of the particles array (ready for splicing out later) - var last = particles[length - 1]; - - particles[length - 1] = particle; - particles[index] = last; - - index -= 1; - length -= 1; - } - } - - // Move dead particles to the dead array - var deadLength = particles.length - length; - - if (deadLength > 0) - { - var rip = particles.splice(particles.length - deadLength, deadLength); - - var deathCallback = this.deathCallback; - var deathCallbackScope = this.deathCallbackScope; - - if (deathCallback) - { - for (var i = 0; i < rip.length; i++) - { - deathCallback.call(deathCallbackScope, rip[i]); - } - } - - this.dead.concat(rip); - - StableSort.inplace(particles, this.indexSortCallback); - } - - if (!this.on) - { - return; - } - - if (this.frequency === 0) - { - this.emitParticle(); - } - else if (this.frequency > 0) - { - this._counter -= delta; - - if (this._counter <= 0) - { - this.emitParticle(); - - // counter = frequency - remained from previous delta - this._counter = (this.frequency - Math.abs(this._counter)); - } - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#depthSortCallback - * @since 3.0.0 - * - * @param {object} a - [description] - * @param {object} b - [description] - * - * @return {integer} [description] - */ - depthSortCallback: function (a, b) - { - return a.y - b.y; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#indexSortCallback - * @since 3.0.0 - * - * @param {object} a - [description] - * @param {object} b - [description] - * - * @return {integer} [description] - */ - indexSortCallback: function (a, b) - { - return a.index - b.index; + out.x = (D * E - B * F) / G; + out.y = (A * F - C * E) / G; + dx = out.x - x1; + dy = out.y - y1; + out.radius = Math.sqrt(dx * dx + dy * dy); } -}); + return out; +}; -module.exports = ParticleEmitter; +module.exports = CircumCircle; /***/ }), @@ -99210,72 +97894,68 @@ module.exports = ParticleEmitter; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); +var Vector2 = __webpack_require__(6); + +// Adapted from http://bjornharrtell.github.io/jsts/doc/api/jsts_geom_Triangle.js.html /** - * @classdesc - * A Death Zone. - * - * A Death Zone is a special type of zone that will kill a Particle as soon as it either enters, or leaves, the zone. - * - * The zone consists of a `source` which could be a Geometric shape, such as a Rectangle or Ellipse, or your own - * object as long as it includes a `contains` method for which the Particles can be tested against. - * - * @class DeathZone - * @memberOf Phaser.GameObjects.Particles.Zones - * @constructor + * Computes the determinant of a 2x2 matrix. Uses standard double-precision arithmetic, so is susceptible to round-off error. + * + * @function det + * @private * @since 3.0.0 * - * @param {object} source - An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. - * @param {boolean} killOnEnter - Should the Particle be killed when it enters the zone? `true` or leaves it? `false` + * @param {number} m00 - The [0,0] entry of the matrix. + * @param {number} m01 - The [0,1] entry of the matrix. + * @param {number} m10 - The [1,0] entry of the matrix. + * @param {number} m11 - The [1,1] entry of the matrix. + * + * @return {number} the determinant. */ -var DeathZone = new Class({ +function det (m00, m01, m10, m11) +{ + return (m00 * m11) - (m01 * m10); +} - initialize: +/** + * Computes the circumcentre of a triangle. The circumcentre is the centre of + * the circumcircle, the smallest circle which encloses the triangle. It is also + * the common intersection point of the perpendicular bisectors of the sides of + * the triangle, and is the only point which has equal distance to all three + * vertices of the triangle. + * + * @function Phaser.Geom.Triangle.CircumCenter + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ +var CircumCenter = function (triangle, out) +{ + if (out === undefined) { out = new Vector2(); } - function DeathZone (source, killOnEnter) - { - /** - * An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. - * This could be a Geometry shape, such as `Phaser.Geom.Circle`, or your own custom object. - * - * @name Phaser.GameObjects.Particles.Zones.DeathZone#source - * @type {object} - * @since 3.0.0 - */ - this.source = source; + var cx = triangle.x3; + var cy = triangle.y3; - /** - * Set to `true` if the Particle should be killed if it enters this zone. - * Set to `false` to kill the Particle if it leaves this zone. - * - * @name Phaser.GameObjects.Particles.Zones.DeathZone#killOnEnter - * @type {boolean} - * @since 3.0.0 - */ - this.killOnEnter = killOnEnter; - }, + var ax = triangle.x1 - cx; + var ay = triangle.y1 - cy; - /** - * Checks if the given Particle will be killed or not by this zone. - * - * @method Phaser.GameObjects.Particles.Zones.DeathZone#willKill - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle to be checked against this zone. - * - * @return {boolean} Return `true` if the Particle is to be killed, otherwise return `false`. - */ - willKill: function (particle) - { - var withinZone = this.source.contains(particle.x, particle.y); + var bx = triangle.x2 - cx; + var by = triangle.y2 - cy; - return (withinZone && this.killOnEnter || !withinZone && !this.killOnEnter); - } + var denom = 2 * det(ax, ay, bx, by); + var numx = det(ay, ax * ax + ay * ay, by, bx * bx + by * by); + var numy = det(ax, ax * ax + ay * ay, bx, bx * bx + by * by); -}); + out.x = cx - numx / denom; + out.y = cy + numy / denom; -module.exports = DeathZone; + return out; +}; + +module.exports = CircumCenter; /***/ }), @@ -99288,233 +97968,45 @@ module.exports = DeathZone; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); +var Centroid = __webpack_require__(230); +var Offset = __webpack_require__(229); + +/** + * @callback CenterFunction + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ /** - * @classdesc * [description] * - * @class EdgeZone - * @memberOf Phaser.GameObjects.Particles.Zones - * @constructor + * @function Phaser.Geom.Triangle.CenterOn * @since 3.0.0 * - * @param {object} source - [description] - * @param {number} quantity - [description] - * @param {number} stepRate - [description] - * @param {boolean} yoyo - [description] - * @param {boolean} seamless - [description] + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {CenterFunction} [centerFunc] - [description] + * + * @return {Phaser.Geom.Triangle} [description] */ -var EdgeZone = new Class({ +var CenterOn = function (triangle, x, y, centerFunc) +{ + if (centerFunc === undefined) { centerFunc = Centroid; } - initialize: + // Get the center of the triangle + var center = centerFunc(triangle); - function EdgeZone (source, quantity, stepRate, yoyo, seamless) - { - if (yoyo === undefined) { yoyo = false; } - if (seamless === undefined) { seamless = true; } + // Difference + var diffX = x - center.x; + var diffY = y - center.y; - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#source - * @type {object} - * @since 3.0.0 - */ - this.source = source; + return Offset(triangle, diffX, diffY); +}; - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#points - * @type {Phaser.Geom.Point[]} - * @default [] - * @since 3.0.0 - */ - this.points = []; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#quantity - * @type {number} - * @since 3.0.0 - */ - this.quantity = quantity; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#stepRate - * @type {number} - * @since 3.0.0 - */ - this.stepRate = stepRate; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#yoyo - * @type {boolean} - * @since 3.0.0 - */ - this.yoyo = yoyo; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#counter - * @type {number} - * @default -1 - * @since 3.0.0 - */ - this.counter = -1; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#seamless - * @type {boolean} - * @since 3.0.0 - */ - this.seamless = seamless; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#_length - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._length = 0; - - /** - * 0 = forwards, 1 = backwards - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#_direction - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._direction = 0; - - this.updateSource(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.Zones.EdgeZone#updateSource - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.Zones.EdgeZone} This Edge Zone. - */ - updateSource: function () - { - this.points = this.source.getPoints(this.quantity, this.stepRate); - - // Remove ends? - if (this.seamless) - { - var a = this.points[0]; - var b = this.points[this.points.length - 1]; - - if (a.x === b.x && a.y === b.y) - { - this.points.pop(); - } - } - - var oldLength = this._length; - - this._length = this.points.length; - - // Adjust counter if we now have less points than before - if (this._length < oldLength && this.counter > this._length) - { - this.counter = this._length - 1; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.Zones.EdgeZone#changeSource - * @since 3.0.0 - * - * @param {object} source - [description] - * - * @return {Phaser.GameObjects.Particles.Zones.EdgeZone} This Edge Zone. - */ - changeSource: function (source) - { - this.source = source; - - return this.updateSource(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.Zones.EdgeZone#getPoint - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - */ - getPoint: function (particle) - { - if (this._direction === 0) - { - this.counter++; - - if (this.counter >= this._length) - { - if (this.yoyo) - { - this._direction = 1; - this.counter = this._length - 1; - } - else - { - this.counter = 0; - } - } - } - else - { - this.counter--; - - if (this.counter === -1) - { - if (this.yoyo) - { - this._direction = 0; - this.counter = 0; - } - else - { - this.counter = this._length - 1; - } - } - } - - var point = this.points[this.counter]; - - if (point) - { - particle.x = point.x; - particle.y = point.y; - } - } - -}); - -module.exports = EdgeZone; +module.exports = CenterOn; /***/ }), @@ -99527,553 +98019,43 @@ module.exports = EdgeZone; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var FloatBetween = __webpack_require__(276); -var GetEaseFunction = __webpack_require__(71); -var GetFastValue = __webpack_require__(2); -var Wrap = __webpack_require__(50); +var Triangle = __webpack_require__(52); + +// Builds a right triangle, with one 90 degree angle and two acute angles +// The x/y is the coordinate of the 90 degree angle (and will map to x1/y1 in the resulting Triangle) +// w/h can be positive or negative and represent the length of each side /** - * @classdesc * [description] * - * @class EmitterOp - * @memberOf Phaser.GameObjects.Particles - * @constructor + * @function Phaser.Geom.Triangle.BuildRight * @since 3.0.0 * - * @param {object} config - [description] - * @param {string} key - [description] - * @param {number} defaultValue - [description] - * @param {boolean} [emitOnly=false] - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.Geom.Triangle} [description] */ -var EmitterOp = new Class({ +var BuildRight = function (x, y, width, height) +{ + if (height === undefined) { height = width; } - initialize: + // 90 degree angle + var x1 = x; + var y1 = y; - function EmitterOp (config, key, defaultValue, emitOnly) - { - if (emitOnly === undefined) { emitOnly = false; } + var x2 = x; + var y2 = y - height; - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#propertyKey - * @type {string} - * @since 3.0.0 - */ - this.propertyKey = key; + var x3 = x + width; + var y3 = y; - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#propertyValue - * @type {number} - * @since 3.0.0 - */ - this.propertyValue = defaultValue; + return new Triangle(x1, y1, x2, y2, x3, y3); +}; - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#defaultValue - * @type {number} - * @since 3.0.0 - */ - this.defaultValue = defaultValue; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#steps - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.steps = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#counter - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.counter = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#start - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.start = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#end - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.end = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#ease - * @type {?function} - * @since 3.0.0 - */ - this.ease; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#emitOnly - * @type {boolean} - * @since 3.0.0 - */ - this.emitOnly = emitOnly; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#onEmit - * @type {[type]} - * @since 3.0.0 - */ - this.onEmit = this.defaultEmit; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#onUpdate - * @type {[type]} - * @since 3.0.0 - */ - this.onUpdate = this.defaultUpdate; - - this.loadConfig(config); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#loadConfig - * @since 3.0.0 - * - * @param {object} config - [description] - * @param {string} newKey - [description] - */ - loadConfig: function (config, newKey) - { - if (config === undefined) { config = {}; } - - if (newKey) - { - this.propertyKey = newKey; - } - - this.propertyValue = GetFastValue(config, this.propertyKey, this.defaultValue); - - this.setMethods(); - - if (this.emitOnly) - { - // Reset it back again - this.onUpdate = this.defaultUpdate; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - return JSON.stringify(this.propertyValue); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#onChange - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {Phaser.GameObjects.Particles.EmitterOp} This Emitter Op object. - */ - onChange: function (value) - { - this.propertyValue = value; - - return this.setMethods(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#setMethods - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.EmitterOp} This Emitter Op object. - */ - setMethods: function () - { - var value = this.propertyValue; - - var t = typeof(value); - - if (t === 'number') - { - // Explicit static value: - // x: 400 - - this.onEmit = this.staticValueEmit; - this.onUpdate = this.staticValueUpdate; - } - else if (Array.isArray(value)) - { - // Picks a random element from the array: - // x: [ 100, 200, 300, 400 ] - - this.onEmit = this.randomStaticValueEmit; - } - else if (t === 'function') - { - // The same as setting just the onUpdate function and no onEmit (unless this op is an emitOnly one) - // Custom callback, must return a value: - - /* - x: function (particle, key, t, value) - { - return value + 50; - } - */ - - if (this.emitOnly) - { - this.onEmit = value; - } - else - { - this.onUpdate = value; - } - } - else if (t === 'object' && (this.has(value, 'random') || this.hasBoth(value, 'start', 'end') || this.hasBoth(value, 'min', 'max'))) - { - this.start = (this.has(value, 'start')) ? value.start : value.min; - this.end = (this.has(value, 'end')) ? value.end : value.max; - - var isRandom = (this.hasBoth(value, 'min', 'max') || this.has(value, 'random')); - - // A random starting value (using 'min | max' instead of 'start | end' automatically implies a random value) - - // x: { start: 100, end: 400, random: true } OR { min: 100, max: 400 } OR { random: [ 100, 400 ] } - - if (isRandom) - { - var rnd = value.random; - - // x: { random: [ 100, 400 ] } = the same as doing: x: { start: 100, end: 400, random: true } - if (Array.isArray(rnd)) - { - this.start = rnd[0]; - this.end = rnd[1]; - } - - this.onEmit = this.randomRangedValueEmit; - } - - if (this.has(value, 'steps')) - { - // A stepped (per emit) range - - // x: { start: 100, end: 400, steps: 64 } - - // Increments a value stored in the emitter - - this.steps = value.steps; - this.counter = this.start; - - this.onEmit = this.steppedEmit; - } - else - { - // An eased range (defaults to Linear if not specified) - - // x: { start: 100, end: 400, [ ease: 'Linear' ] } - - var easeType = (this.has(value, 'ease')) ? value.ease : 'Linear'; - - this.ease = GetEaseFunction(easeType); - - if (!isRandom) - { - this.onEmit = this.easedValueEmit; - } - - this.onUpdate = this.easeValueUpdate; - } - } - else if (t === 'object' && this.hasEither(value, 'onEmit', 'onUpdate')) - { - // Custom onEmit and onUpdate callbacks - - /* - x: { - // Called at the start of the particles life, when it is being created - onEmit: function (particle, key, t, value) - { - return value; - }, - - // Called during the particles life on each update - onUpdate: function (particle, key, t, value) - { - return value; - } - } - */ - - if (this.has(value, 'onEmit')) - { - this.onEmit = value.onEmit; - } - - if (this.has(value, 'onUpdate')) - { - this.onUpdate = value.onUpdate; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#has - * @since 3.0.0 - * - * @param {object} object - [description] - * @param {string} key - [description] - * - * @return {boolean} [description] - */ - has: function (object, key) - { - return (object.hasOwnProperty(key)); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#hasBoth - * @since 3.0.0 - * - * @param {object} object - [description] - * @param {string} key1 - [description] - * @param {string} key2 - [description] - * - * @return {boolean} [description] - */ - hasBoth: function (object, key1, key2) - { - return (object.hasOwnProperty(key1) && object.hasOwnProperty(key2)); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#hasEither - * @since 3.0.0 - * - * @param {object} object - [description] - * @param {string} key1 - [description] - * @param {string} key2 - [description] - * - * @return {boolean} [description] - */ - hasEither: function (object, key1, key2) - { - return (object.hasOwnProperty(key1) || object.hasOwnProperty(key2)); - }, - - /** - * The returned value sets what the property will be at the START of the particles life, on emit. - * - * @method Phaser.GameObjects.Particles.EmitterOp#defaultEmit - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - * @param {string} key - [description] - * @param {number} value - [description] - * - * @return {number} [description] - */ - defaultEmit: function (particle, key, value) - { - return value; - }, - - /** - * The returned value updates the property for the duration of the particles life. - * - * @method Phaser.GameObjects.Particles.EmitterOp#defaultUpdate - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - * @param {string} key - [description] - * @param {float} t - The T value (between 0 and 1) - * @param {number} value - [description] - * - * @return {number} [description] - */ - defaultUpdate: function (particle, key, t, value) - { - return value; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#staticValueEmit - * @since 3.0.0 - * - * @return {number} [description] - */ - staticValueEmit: function () - { - return this.propertyValue; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#staticValueUpdate - * @since 3.0.0 - * - * @return {number} [description] - */ - staticValueUpdate: function () - { - return this.propertyValue; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#randomStaticValueEmit - * @since 3.0.0 - * - * @return {number} [description] - */ - randomStaticValueEmit: function () - { - var randomIndex = Math.floor(Math.random() * this.propertyValue.length); - - return this.propertyValue[randomIndex]; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#randomRangedValueEmit - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - * @param {string} key - [description] - * - * @return {number} [description] - */ - randomRangedValueEmit: function (particle, key) - { - var value = FloatBetween(this.start, this.end); - - if (particle && particle.data[key]) - { - particle.data[key].min = value; - } - - return value; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#steppedEmit - * @since 3.0.0 - * - * @return {number} [description] - */ - steppedEmit: function () - { - var current = this.counter; - - var next = this.counter + ((this.end - this.start) / this.steps); - - this.counter = Wrap(next, this.start, this.end); - - return current; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#easedValueEmit - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - * @param {string} key - [description] - * - * @return {number} [description] - */ - easedValueEmit: function (particle, key) - { - if (particle && particle.data[key]) - { - var data = particle.data[key]; - - data.min = this.start; - data.max = this.end; - } - - return this.start; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#easeValueUpdate - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - * @param {string} key - [description] - * @param {float} t - The T value (between 0 and 1) - * - * @return {number} [description] - */ - easeValueUpdate: function (particle, key, t) - { - var data = particle.data[key]; - - return (data.max - data.min) * this.ease(t) + data.min; - } - -}); - -module.exports = EmitterOp; +module.exports = BuildRight; /***/ }), @@ -100086,80 +98068,72 @@ module.exports = EmitterOp; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Back = __webpack_require__(277); -var Bounce = __webpack_require__(278); -var Circular = __webpack_require__(279); -var Cubic = __webpack_require__(280); -var Elastic = __webpack_require__(281); -var Expo = __webpack_require__(282); -var Linear = __webpack_require__(283); -var Quadratic = __webpack_require__(284); -var Quartic = __webpack_require__(285); -var Quintic = __webpack_require__(286); -var Sine = __webpack_require__(287); -var Stepped = __webpack_require__(288); +var EarCut = __webpack_require__(301); +var Triangle = __webpack_require__(52); -// EaseMap -module.exports = { +/** + * [description] + * + * @function Phaser.Geom.Triangle.BuildFromPolygon + * @since 3.0.0 + * + * @param {array} data - A flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...] + * @param {array} [?holes] - An array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). + * @param {float} [scaleX=1] - [description] + * @param {float} [scaleY=1] - [description] + * @param {array} [out] - [description] + * + * @return {Phaser.Geom.Triangle[]} [description] + */ +var BuildFromPolygon = function (data, holes, scaleX, scaleY, out) +{ + if (holes === undefined) { holes = null; } + if (scaleX === undefined) { scaleX = 1; } + if (scaleY === undefined) { scaleY = 1; } + if (out === undefined) { out = []; } - Power0: Linear, - Power1: Quadratic.Out, - Power2: Cubic.Out, - Power3: Quartic.Out, - Power4: Quintic.Out, + var tris = EarCut(data, holes); - Linear: Linear, - Quad: Quadratic.Out, - Cubic: Cubic.Out, - Quart: Quartic.Out, - Quint: Quintic.Out, - Sine: Sine.Out, - Expo: Expo.Out, - Circ: Circular.Out, - Elastic: Elastic.Out, - Back: Back.Out, - Bounce: Bounce.Out, - Stepped: Stepped, + var a; + var b; + var c; - 'Quad.easeIn': Quadratic.In, - 'Cubic.easeIn': Cubic.In, - 'Quart.easeIn': Quartic.In, - 'Quint.easeIn': Quintic.In, - 'Sine.easeIn': Sine.In, - 'Expo.easeIn': Expo.In, - 'Circ.easeIn': Circular.In, - 'Elastic.easeIn': Elastic.In, - 'Back.easeIn': Back.In, - 'Bounce.easeIn': Bounce.In, + var x1; + var y1; - 'Quad.easeOut': Quadratic.Out, - 'Cubic.easeOut': Cubic.Out, - 'Quart.easeOut': Quartic.Out, - 'Quint.easeOut': Quintic.Out, - 'Sine.easeOut': Sine.Out, - 'Expo.easeOut': Expo.Out, - 'Circ.easeOut': Circular.Out, - 'Elastic.easeOut': Elastic.Out, - 'Back.easeOut': Back.Out, - 'Bounce.easeOut': Bounce.Out, + var x2; + var y2; - 'Quad.easeInOut': Quadratic.InOut, - 'Cubic.easeInOut': Cubic.InOut, - 'Quart.easeInOut': Quartic.InOut, - 'Quint.easeInOut': Quintic.InOut, - 'Sine.easeInOut': Sine.InOut, - 'Expo.easeInOut': Expo.InOut, - 'Circ.easeInOut': Circular.InOut, - 'Elastic.easeInOut': Elastic.InOut, - 'Back.easeInOut': Back.InOut, - 'Bounce.easeInOut': Bounce.InOut + var x3; + var y3; + for (var i = 0; i < tris.length; i += 3) + { + a = tris[i]; + b = tris[i + 1]; + c = tris[i + 2]; + + x1 = data[a * 2] * scaleX; + y1 = data[(a * 2) + 1] * scaleY; + + x2 = data[b * 2] * scaleX; + y2 = data[(b * 2) + 1] * scaleY; + + x3 = data[c * 2] * scaleX; + y3 = data[(c * 2) + 1] * scaleY; + + out.push(new Triangle(x1, y1, x2, y2, x3, y3)); + } + + return out; }; +module.exports = BuildFromPolygon; + /***/ }), /* 579 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -100167,25 +98141,44 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Triangle = __webpack_require__(52); + +// Builds an equilateral triangle. +// In the equilateral triangle, all the sides are the same length (congruent) +// and all the angles are the same size (congruent). + +// The x/y specifies the top-middle of the triangle (x1/y1) and length +// is the length of each side + /** * [description] * - * @function Phaser.Math.Easing.Back.In + * @function Phaser.Geom.Triangle.BuildEquilateral * @since 3.0.0 * - * @param {number} v - [description] - * @param {number} [overshoot=1.70158] - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} length - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Triangle} [description] */ -var In = function (v, overshoot) +var BuildEquilateral = function (x, y, length) { - if (overshoot === undefined) { overshoot = 1.70158; } + var height = length * (Math.sqrt(3) / 2); - return v * v * ((overshoot + 1) * v - overshoot); + var x1 = x; + var y1 = y; + + var x2 = x + (length / 2); + var y2 = y + height; + + var x3 = x - (length / 2); + var y3 = y + height; + + return new Triangle(x1, y1, x2, y2, x3, y3); }; -module.exports = In; +module.exports = BuildEquilateral; /***/ }), @@ -100198,30 +98191,38 @@ module.exports = In; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +// The 2D area of a triangle. The area value is always non-negative. + /** * [description] * - * @function Phaser.Math.Easing.Back.Out + * @function Phaser.Geom.Triangle.Area * @since 3.0.0 * - * @param {number} v - [description] - * @param {number} [overshoot=1.70158] - [description] + * @param {Phaser.Geom.Triangle} triangle - [description] * * @return {number} [description] */ -var Out = function (v, overshoot) +var Area = function (triangle) { - if (overshoot === undefined) { overshoot = 1.70158; } + var x1 = triangle.x1; + var y1 = triangle.y1; - return --v * v * ((overshoot + 1) * v + overshoot) + 1; + var x2 = triangle.x2; + var y2 = triangle.y2; + + var x3 = triangle.x3; + var y3 = triangle.y3; + + return Math.abs(((x3 - x1) * (y2 - y1) - (x2 - x1) * (y3 - y1)) / 2); }; -module.exports = Out; +module.exports = Area; /***/ }), /* 581 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -100229,39 +98230,39 @@ module.exports = Out; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * [description] - * - * @function Phaser.Math.Easing.Back.InOut - * @since 3.0.0 - * - * @param {number} v - [description] - * @param {number} [overshoot=1.70158] - [description] - * - * @return {number} [description] - */ -var InOut = function (v, overshoot) -{ - if (overshoot === undefined) { overshoot = 1.70158; } +var Triangle = __webpack_require__(52); - var s = overshoot * 1.525; +Triangle.Area = __webpack_require__(580); +Triangle.BuildEquilateral = __webpack_require__(579); +Triangle.BuildFromPolygon = __webpack_require__(578); +Triangle.BuildRight = __webpack_require__(577); +Triangle.CenterOn = __webpack_require__(576); +Triangle.Centroid = __webpack_require__(230); +Triangle.CircumCenter = __webpack_require__(575); +Triangle.CircumCircle = __webpack_require__(574); +Triangle.Clone = __webpack_require__(573); +Triangle.Contains = __webpack_require__(54); +Triangle.ContainsArray = __webpack_require__(127); +Triangle.ContainsPoint = __webpack_require__(572); +Triangle.CopyFrom = __webpack_require__(571); +Triangle.Decompose = __webpack_require__(239); +Triangle.Equals = __webpack_require__(570); +Triangle.GetPoint = __webpack_require__(232); +Triangle.GetPoints = __webpack_require__(231); +Triangle.InCenter = __webpack_require__(228); +Triangle.Perimeter = __webpack_require__(569); +Triangle.Offset = __webpack_require__(229); +Triangle.Random = __webpack_require__(161); +Triangle.Rotate = __webpack_require__(568); +Triangle.RotateAroundPoint = __webpack_require__(567); +Triangle.RotateAroundXY = __webpack_require__(123); - if ((v *= 2) < 1) - { - return 0.5 * (v * v * ((s + 1) * v - s)); - } - else - { - return 0.5 * ((v -= 2) * v * ((s + 1) * v + s) + 2); - } -}; - -module.exports = InOut; +module.exports = Triangle; /***/ }), /* 582 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -100269,39 +98270,36 @@ module.exports = InOut; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Rectangle = __webpack_require__(10); + /** * [description] * - * @function Phaser.Math.Easing.Bounce.In + * @function Phaser.Geom.Rectangle.Union * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rectA - [description] + * @param {Phaser.Geom.Rectangle} rectB - [description] + * @param {Phaser.Geom.Rectangle} [out] - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var In = function (v) +var Union = function (rectA, rectB, out) { - v = 1 - v; + if (out === undefined) { out = new Rectangle(); } - if (v < 1 / 2.75) - { - return 1 - (7.5625 * v * v); - } - else if (v < 2 / 2.75) - { - return 1 - (7.5625 * (v -= 1.5 / 2.75) * v + 0.75); - } - else if (v < 2.5 / 2.75) - { - return 1 - (7.5625 * (v -= 2.25 / 2.75) * v + 0.9375); - } - else - { - return 1 - (7.5625 * (v -= 2.625 / 2.75) * v + 0.984375); - } + var x = Math.min(rectA.x, rectB.x); + var y = Math.min(rectA.y, rectB.y); + + return out.setTo( + x, + y, + Math.max(rectA.right, rectB.right) - x, + Math.max(rectA.bottom, rectB.bottom) - y + ); }; -module.exports = In; +module.exports = Union; /***/ }), @@ -100314,42 +98312,36 @@ module.exports = In; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +// Scales the width and height of this Rectangle by the given amounts. + /** * [description] * - * @function Phaser.Math.Easing.Bounce.Out + * @function Phaser.Geom.Rectangle.Scale * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} x - [description] + * @param {number} y - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var Out = function (v) +var Scale = function (rect, x, y) { - if (v < 1 / 2.75) - { - return 7.5625 * v * v; - } - else if (v < 2 / 2.75) - { - return 7.5625 * (v -= 1.5 / 2.75) * v + 0.75; - } - else if (v < 2.5 / 2.75) - { - return 7.5625 * (v -= 2.25 / 2.75) * v + 0.9375; - } - else - { - return 7.5625 * (v -= 2.625 / 2.75) * v + 0.984375; - } + if (y === undefined) { y = x; } + + rect.width *= x; + rect.height *= y; + + return rect; }; -module.exports = Out; +module.exports = Scale; /***/ }), /* 584 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -100357,58 +98349,49 @@ module.exports = Out; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Point = __webpack_require__(4); +var DegToRad = __webpack_require__(42); + /** * [description] * - * @function Phaser.Math.Easing.Bounce.InOut + * @function Phaser.Geom.Rectangle.PerimeterPoint * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rectangle - [description] + * @param {integer} angle - [description] + * @param {Phaser.Geom.Point} [out] - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Point} [description] */ -var InOut = function (v) +var PerimeterPoint = function (rectangle, angle, out) { - var reverse = false; + if (out === undefined) { out = new Point(); } - if (v < 0.5) + angle = DegToRad(angle); + + var s = Math.sin(angle); + var c = Math.cos(angle); + + var dx = (c > 0) ? rectangle.width / 2 : rectangle.width / -2; + var dy = (s > 0) ? rectangle.height / 2 : rectangle.height / -2; + + if (Math.abs(dx * s) < Math.abs(dy * c)) { - v = 1 - (v * 2); - reverse = true; + dy = (dx * s) / c; } else { - v = (v * 2) - 1; + dx = (dy * c) / s; } - if (v < 1 / 2.75) - { - v = 7.5625 * v * v; - } - else if (v < 2 / 2.75) - { - v = 7.5625 * (v -= 1.5 / 2.75) * v + 0.75; - } - else if (v < 2.5 / 2.75) - { - v = 7.5625 * (v -= 2.25 / 2.75) * v + 0.9375; - } - else - { - v = 7.5625 * (v -= 2.625 / 2.75) * v + 0.984375; - } + out.x = dx + rectangle.centerX; + out.y = dy + rectangle.centerY; - if (reverse) - { - return (1 - v) * 0.5; - } - else - { - return v * 0.5 + 0.5; - } + return out; }; -module.exports = InOut; +module.exports = PerimeterPoint; /***/ }), @@ -100424,19 +98407,25 @@ module.exports = InOut; /** * [description] * - * @function Phaser.Math.Easing.Circular.In + * @function Phaser.Geom.Rectangle.Overlaps * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rectA - [description] + * @param {Phaser.Geom.Rectangle} rectB - [description] * - * @return {number} [description] + * @return {boolean} [description] */ -var In = function (v) +var Overlaps = function (rectA, rectB) { - return 1 - Math.sqrt(1 - v * v); + return ( + rectA.x < rectB.right && + rectA.right > rectB.x && + rectA.y < rectB.bottom && + rectA.bottom > rectB.y + ); }; -module.exports = In; +module.exports = Overlaps; /***/ }), @@ -100452,19 +98441,23 @@ module.exports = In; /** * [description] * - * @function Phaser.Math.Easing.Circular.Out + * @function Phaser.Geom.Rectangle.OffsetPoint * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Point} point - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var Out = function (v) +var OffsetPoint = function (rect, point) { - return Math.sqrt(1 - (--v * v)); + rect.x += point.x; + rect.y += point.y; + + return rect; }; -module.exports = Out; +module.exports = OffsetPoint; /***/ }), @@ -100480,26 +98473,24 @@ module.exports = Out; /** * [description] * - * @function Phaser.Math.Easing.Circular.InOut + * @function Phaser.Geom.Rectangle.Offset * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} x - [description] + * @param {number} y - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var InOut = function (v) +var Offset = function (rect, x, y) { - if ((v *= 2) < 1) - { - return -0.5 * (Math.sqrt(1 - v * v) - 1); - } - else - { - return 0.5 * (Math.sqrt(1 - (v -= 2) * v) + 1); - } + rect.x += x; + rect.y += y; + + return rect; }; -module.exports = InOut; +module.exports = Offset; /***/ }), @@ -100515,19 +98506,33 @@ module.exports = InOut; /** * [description] * - * @function Phaser.Math.Easing.Cubic.In + * @function Phaser.Geom.Rectangle.MergeXY * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} target - [description] + * @param {number} x - [description] + * @param {number} y - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var In = function (v) +var MergeXY = function (target, x, y) { - return v * v * v; + var minX = Math.min(target.x, x); + var maxX = Math.max(target.right, x); + + target.x = minX; + target.width = maxX - minX; + + var minY = Math.min(target.y, y); + var maxY = Math.max(target.bottom, y); + + target.y = minY; + target.height = maxY - minY; + + return target; }; -module.exports = In; +module.exports = MergeXY; /***/ }), @@ -100540,22 +98545,38 @@ module.exports = In; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +// Merges source rectangle into target rectangle and returns target +// Neither rect should have negative widths or heights + /** * [description] * - * @function Phaser.Math.Easing.Cubic.Out + * @function Phaser.Geom.Rectangle.MergeRect * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} target - [description] + * @param {Phaser.Geom.Rectangle} source - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var Out = function (v) +var MergeRect = function (target, source) { - return --v * v * v + 1; + var minX = Math.min(target.x, source.x); + var maxX = Math.max(target.right, source.right); + + target.x = minX; + target.width = maxX - minX; + + var minY = Math.min(target.y, source.y); + var maxY = Math.max(target.bottom, source.bottom); + + target.y = minY; + target.height = maxY - minY; + + return target; }; -module.exports = Out; +module.exports = MergeRect; /***/ }), @@ -100568,34 +98589,49 @@ module.exports = Out; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +// Merges the target Rectangle with a list of points. +// The points is an array of objects with public x/y properties. + /** * [description] * - * @function Phaser.Math.Easing.Cubic.InOut + * @function Phaser.Geom.Rectangle.MergePoints * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} target - [description] + * @param {Phaser.Geom.Point[]} points - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var InOut = function (v) +var MergePoints = function (target, points) { - if ((v *= 2) < 1) + var minX = target.x; + var maxX = target.right; + var minY = target.y; + var maxY = target.bottom; + + for (var i = 0; i < points.length; i++) { - return 0.5 * v * v * v; - } - else - { - return 0.5 * ((v -= 2) * v * v + 2); + minX = Math.min(minX, points[i].x); + maxX = Math.max(maxX, points[i].x); + minY = Math.min(minY, points[i].y); + maxY = Math.max(maxY, points[i].y); } + + target.x = minX; + target.y = minY; + target.width = maxX - minX; + target.height = maxY - minY; + + return target; }; -module.exports = InOut; +module.exports = MergePoints; /***/ }), /* 591 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -100603,54 +98639,40 @@ module.exports = InOut; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var CenterOn = __webpack_require__(233); + +// Increases the size of the Rectangle object by the specified amounts. +// The center point of the Rectangle object stays the same, and its size increases +// to the left and right by the x value, and to the top and the bottom by the y value. + /** * [description] * - * @function Phaser.Math.Easing.Elastic.In + * @function Phaser.Geom.Rectangle.Inflate * @since 3.0.0 * - * @param {number} v - [description] - * @param {float} [amplitude=0.1] - [description] - * @param {float} [period=0.1] - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} x - [description] + * @param {number} y - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var In = function (v, amplitude, period) +var Inflate = function (rect, x, y) { - if (amplitude === undefined) { amplitude = 0.1; } - if (period === undefined) { period = 0.1; } + var cx = rect.centerX; + var cy = rect.centerY; - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - var s = period / 4; + rect.setSize(rect.width + (x * 2), rect.height + (y * 2)); - if (amplitude < 1) - { - amplitude = 1; - } - else - { - s = period * Math.asin(1 / amplitude) / (2 * Math.PI); - } - - return -(amplitude * Math.pow(2, 10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period)); - } + return CenterOn(rect, cx, cy); }; -module.exports = In; +module.exports = Inflate; /***/ }), /* 592 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -100658,54 +98680,38 @@ module.exports = In; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Point = __webpack_require__(4); + +// The size of the Rectangle object, expressed as a Point object +// with the values of the width and height properties. + /** * [description] * - * @function Phaser.Math.Easing.Elastic.Out + * @function Phaser.Geom.Rectangle.GetSize * @since 3.0.0 * - * @param {number} v - [description] - * @param {float} [amplitude=0.1] - [description] - * @param {float} [period=0.1] - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] * - * @return {number} [description] + * @return {(Phaser.Geom.Point|object)} [description] */ -var Out = function (v, amplitude, period) +var GetSize = function (rect, out) { - if (amplitude === undefined) { amplitude = 0.1; } - if (period === undefined) { period = 0.1; } + if (out === undefined) { out = new Point(); } - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - var s = period / 4; + out.x = rect.width; + out.y = rect.height; - if (amplitude < 1) - { - amplitude = 1; - } - else - { - s = period * Math.asin(1 / amplitude) / (2 * Math.PI); - } - - return (amplitude * Math.pow(2, -10 * v) * Math.sin((v - s) * (2 * Math.PI) / period) + 1); - } + return out; }; -module.exports = Out; +module.exports = GetSize; /***/ }), /* 593 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -100713,56 +98719,32 @@ module.exports = Out; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Point = __webpack_require__(4); + +// The center of the Rectangle object, expressed as a Point object + /** * [description] * - * @function Phaser.Math.Easing.Elastic.InOut + * @function Phaser.Geom.Rectangle.GetCenter * @since 3.0.0 * - * @param {number} v - [description] - * @param {float} [amplitude=0.1] - [description] - * @param {float} [period=0.1] - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] * - * @return {number} [description] + * @return {(Phaser.Geom.Point|object)} [description] */ -var InOut = function (v, amplitude, period) +var GetCenter = function (rect, out) { - if (amplitude === undefined) { amplitude = 0.1; } - if (period === undefined) { period = 0.1; } + if (out === undefined) { out = new Point(); } - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - var s = period / 4; + out.x = rect.centerX; + out.y = rect.centerY; - if (amplitude < 1) - { - amplitude = 1; - } - else - { - s = period * Math.asin(1 / amplitude) / (2 * Math.PI); - } - - if ((v *= 2) < 1) - { - return -0.5 * (amplitude * Math.pow(2, 10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period)); - } - else - { - return amplitude * Math.pow(2, -10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period) * 0.5 + 1; - } - } + return out; }; -module.exports = InOut; +module.exports = GetCenter; /***/ }), @@ -100778,19 +98760,24 @@ module.exports = InOut; /** * [description] * - * @function Phaser.Math.Easing.Expo.In + * @function Phaser.Geom.Rectangle.FloorAll * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var In = function (v) +var FloorAll = function (rect) { - return Math.pow(2, 10 * (v - 1)) - 0.001; + rect.x = Math.floor(rect.x); + rect.y = Math.floor(rect.y); + rect.width = Math.floor(rect.width); + rect.height = Math.floor(rect.height); + + return rect; }; -module.exports = In; +module.exports = FloorAll; /***/ }), @@ -100806,24 +98793,27 @@ module.exports = In; /** * [description] * - * @function Phaser.Math.Easing.Expo.Out + * @function Phaser.Geom.Rectangle.Floor * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var Out = function (v) +var Floor = function (rect) { - return 1 - Math.pow(2, -10 * v); + rect.x = Math.floor(rect.x); + rect.y = Math.floor(rect.y); + + return rect; }; -module.exports = Out; +module.exports = Floor; /***/ }), /* 596 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -100831,34 +98821,50 @@ module.exports = Out; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var GetAspectRatio = __webpack_require__(124); + +// Fits the target rectangle around the source rectangle. +// Preserves aspect ration. +// Scales and centers the target rectangle to the source rectangle + /** * [description] * - * @function Phaser.Math.Easing.Expo.InOut + * @function Phaser.Geom.Rectangle.FitOutside * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} target - [description] + * @param {Phaser.Geom.Rectangle} source - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var InOut = function (v) +var FitOutside = function (target, source) { - if ((v *= 2) < 1) + var ratio = GetAspectRatio(target); + + if (ratio > GetAspectRatio(source)) { - return 0.5 * Math.pow(2, 10 * (v - 1)); + // Wider than Tall + target.setSize(source.height * ratio, source.height); } else { - return 0.5 * (2 - Math.pow(2, -10 * (v - 1))); + // Taller than Wide + target.setSize(source.width, source.width / ratio); } + + return target.setPosition( + source.centerX - target.width / 2, + source.centerY - target.height / 2 + ); }; -module.exports = InOut; +module.exports = FitOutside; /***/ }), /* 597 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -100866,22 +98872,45 @@ module.exports = InOut; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var GetAspectRatio = __webpack_require__(124); + +// Fits the target rectangle into the source rectangle. +// Preserves aspect ratio. +// Scales and centers the target rectangle to the source rectangle + /** * [description] * - * @function Phaser.Math.Easing.Linear + * @function Phaser.Geom.Rectangle.FitInside * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} target - [description] + * @param {Phaser.Geom.Rectangle} source - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var Linear = function (v) +var FitInside = function (target, source) { - return v; + var ratio = GetAspectRatio(target); + + if (ratio < GetAspectRatio(source)) + { + // Taller than Wide + target.setSize(source.height * ratio, source.height); + } + else + { + // Wider than Tall + target.setSize(source.width, source.width / ratio); + } + + return target.setPosition( + source.centerX - (target.width / 2), + source.centerY - (target.height / 2) + ); }; -module.exports = Linear; +module.exports = FitInside; /***/ }), @@ -100897,19 +98926,25 @@ module.exports = Linear; /** * [description] * - * @function Phaser.Math.Easing.Quadratic.In + * @function Phaser.Geom.Rectangle.Equals * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Rectangle} toCompare - [description] * - * @return {number} [description] + * @return {boolean} [description] */ -var In = function (v) +var Equals = function (rect, toCompare) { - return v * v; + return ( + rect.x === toCompare.x && + rect.y === toCompare.y && + rect.width === toCompare.width && + rect.height === toCompare.height + ); }; -module.exports = In; +module.exports = Equals; /***/ }), @@ -100925,19 +98960,20 @@ module.exports = In; /** * [description] * - * @function Phaser.Math.Easing.Quadratic.Out + * @function Phaser.Geom.Rectangle.CopyFrom * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} source - [description] + * @param {Phaser.Geom.Rectangle} dest - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var Out = function (v) +var CopyFrom = function (source, dest) { - return v * (2 - v); + return dest.setTo(source.x, source.y, source.width, source.height); }; -module.exports = Out; +module.exports = CopyFrom; /***/ }), @@ -100950,34 +98986,41 @@ module.exports = Out; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +// Checks if rectB is fully contained within rectA + /** * [description] * - * @function Phaser.Math.Easing.Quadratic.InOut + * @function Phaser.Geom.Rectangle.ContainsRect * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rectA - [description] + * @param {Phaser.Geom.Rectangle} rectB - [description] * - * @return {number} [description] + * @return {boolean} [description] */ -var InOut = function (v) +var ContainsRect = function (rectA, rectB) { - if ((v *= 2) < 1) + // Volume check (if rectB volume > rectA then rectA cannot contain it) + if ((rectB.width * rectB.height) > (rectA.width * rectA.height)) { - return 0.5 * v * v; - } - else - { - return -0.5 * (--v * (v - 2) - 1); + return false; } + + return ( + (rectB.x > rectA.x && rectB.x < rectA.right) && + (rectB.right > rectA.x && rectB.right < rectA.right) && + (rectB.y > rectA.y && rectB.y < rectA.bottom) && + (rectB.bottom > rectA.y && rectB.bottom < rectA.bottom) + ); }; -module.exports = InOut; +module.exports = ContainsRect; /***/ }), /* 601 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -100985,27 +99028,30 @@ module.exports = InOut; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Contains = __webpack_require__(27); + /** * [description] * - * @function Phaser.Math.Easing.Quartic.In + * @function Phaser.Geom.Rectangle.ContainsPoint * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Point} point - [description] * - * @return {number} [description] + * @return {boolean} [description] */ -var In = function (v) +var ContainsPoint = function (rect, point) { - return v * v * v * v; + return Contains(rect, point.x, point.y); }; -module.exports = In; +module.exports = ContainsPoint; /***/ }), /* 602 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -101013,22 +99059,24 @@ module.exports = In; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Rectangle = __webpack_require__(10); + /** * [description] * - * @function Phaser.Math.Easing.Quartic.Out + * @function Phaser.Geom.Rectangle.Clone * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} source - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var Out = function (v) +var Clone = function (source) { - return 1 - (--v * v * v * v); + return new Rectangle(source.x, source.y, source.width, source.height); }; -module.exports = Out; +module.exports = Clone; /***/ }), @@ -101044,26 +99092,24 @@ module.exports = Out; /** * [description] * - * @function Phaser.Math.Easing.Quartic.InOut + * @function Phaser.Geom.Rectangle.CeilAll * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var InOut = function (v) +var CeilAll = function (rect) { - if ((v *= 2) < 1) - { - return 0.5 * v * v * v * v; - } - else - { - return -0.5 * ((v -= 2) * v * v * v - 2); - } + rect.x = Math.ceil(rect.x); + rect.y = Math.ceil(rect.y); + rect.width = Math.ceil(rect.width); + rect.height = Math.ceil(rect.height); + + return rect; }; -module.exports = InOut; +module.exports = CeilAll; /***/ }), @@ -101079,19 +99125,22 @@ module.exports = InOut; /** * [description] * - * @function Phaser.Math.Easing.Quintic.In + * @function Phaser.Geom.Rectangle.Ceil * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Rectangle} [description] */ -var In = function (v) +var Ceil = function (rect) { - return v * v * v * v * v; + rect.x = Math.ceil(rect.x); + rect.y = Math.ceil(rect.y); + + return rect; }; -module.exports = In; +module.exports = Ceil; /***/ }), @@ -101107,19 +99156,19 @@ module.exports = In; /** * [description] * - * @function Phaser.Math.Easing.Quintic.Out + * @function Phaser.Geom.Rectangle.Area * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] * * @return {number} [description] */ -var Out = function (v) +var Area = function (rect) { - return --v * v * v * v * v + 1; + return rect.width * rect.height; }; -module.exports = Out; +module.exports = Area; /***/ }), @@ -101132,34 +99181,38 @@ module.exports = Out; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +// Export the points as an array of flat numbers, following the sequence [ x,y, x,y, x,y ] + /** * [description] * - * @function Phaser.Math.Easing.Quintic.InOut + * @function Phaser.Geom.Polygon.GetNumberArray * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Polygon} polygon - [description] + * @param {array} [output] - [description] * - * @return {number} [description] + * @return {number[]} [description] */ -var InOut = function (v) +var GetNumberArray = function (polygon, output) { - if ((v *= 2) < 1) + if (output === undefined) { output = []; } + + for (var i = 0; i < polygon.points.length; i++) { - return 0.5 * v * v * v * v * v; - } - else - { - return 0.5 * ((v -= 2) * v * v * v * v + 2); + output.push(polygon.points[i].x); + output.push(polygon.points[i].y); } + + return output; }; -module.exports = InOut; +module.exports = GetNumberArray; /***/ }), /* 607 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -101167,38 +99220,53 @@ module.exports = InOut; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Rectangle = __webpack_require__(10); + /** * [description] * - * @function Phaser.Math.Easing.Sine.In + * @function Phaser.Geom.Polygon.GetAABB * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Polygon} polygon - [description] + * @param {(Phaser.Geom.Rectangle|object)} [out] - [description] * - * @return {number} [description] + * @return {(Phaser.Geom.Rectangle|object)} [description] */ -var In = function (v) +var GetAABB = function (polygon, out) { - if (v === 0) + if (out === undefined) { out = new Rectangle(); } + + var minX = Infinity; + var minY = Infinity; + var maxX = -minX; + var maxY = -minY; + var p; + + for (var i = 0; i < polygon.points.length; i++) { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - return 1 - Math.cos(v * Math.PI / 2); + p = polygon.points[i]; + + minX = Math.min(minX, p.x); + minY = Math.min(minY, p.y); + maxX = Math.max(maxX, p.x); + maxY = Math.max(maxY, p.y); } + + out.x = minX; + out.y = minY; + out.width = maxX - minX; + out.height = maxY - minY; + + return out; }; -module.exports = In; +module.exports = GetAABB; /***/ }), /* 608 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -101206,38 +99274,30 @@ module.exports = In; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Contains = __webpack_require__(125); + /** * [description] * - * @function Phaser.Math.Easing.Sine.Out + * @function Phaser.Geom.Polygon.ContainsPoint * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Polygon} polygon - [description] + * @param {Phaser.Geom.Point} point - [description] * - * @return {number} [description] + * @return {boolean} [description] */ -var Out = function (v) +var ContainsPoint = function (polygon, point) { - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - return Math.sin(v * Math.PI / 2); - } + return Contains(polygon, point.x, point.y); }; -module.exports = Out; +module.exports = ContainsPoint; /***/ }), /* 609 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -101245,38 +99305,29 @@ module.exports = Out; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Polygon = __webpack_require__(235); + /** * [description] * - * @function Phaser.Math.Easing.Sine.InOut + * @function Phaser.Geom.Polygon.Clone * @since 3.0.0 * - * @param {number} v - [description] + * @param {Phaser.Geom.Polygon} polygon - [description] * - * @return {number} [description] + * @return {Phaser.Geom.Polygon} [description] */ -var InOut = function (v) +var Clone = function (polygon) { - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - return 0.5 * (1 - Math.cos(Math.PI * v)); - } + return new Polygon(polygon.points); }; -module.exports = InOut; +module.exports = Clone; /***/ }), /* 610 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -101284,42 +99335,2084 @@ module.exports = InOut; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * [description] - * - * @function Phaser.Math.Easing.Stepped - * @since 3.0.0 - * - * @param {number} v - [description] - * @param {float} [steps=1] - [description] - * - * @return {number} [description] - */ -var Stepped = function (v, steps) -{ - if (steps === undefined) { steps = 1; } +var Polygon = __webpack_require__(235); - if (v <= 0) - { - return 0; - } - else if (v >= 1) - { - return 1; - } - else - { - return (((steps * v) | 0) + 1) * (1 / steps); - } -}; +Polygon.Clone = __webpack_require__(609); +Polygon.Contains = __webpack_require__(125); +Polygon.ContainsPoint = __webpack_require__(608); +Polygon.GetAABB = __webpack_require__(607); +Polygon.GetNumberArray = __webpack_require__(606); -module.exports = Stepped; +module.exports = Polygon; /***/ }), /* 611 */ /***/ (function(module, exports, __webpack_require__) { +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetMagnitude = __webpack_require__(237); + +/** + * [description] + * + * @function Phaser.Geom.Point.SetMagnitude + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * @param {number} magnitude - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var SetMagnitude = function (point, magnitude) +{ + if (point.x !== 0 || point.y !== 0) + { + var m = GetMagnitude(point); + + point.x /= m; + point.y /= m; + } + + point.x *= magnitude; + point.y *= magnitude; + + return point; +}; + +module.exports = SetMagnitude; + + +/***/ }), +/* 612 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +/** + * [description] + * + * @function Phaser.Geom.Point.ProjectUnit + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} pointA - [description] + * @param {Phaser.Geom.Point} pointB - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var ProjectUnit = function (pointA, pointB, out) +{ + if (out === undefined) { out = new Point(); } + + var amt = ((pointA.x * pointB.x) + (pointA.y * pointB.y)); + + if (amt !== 0) + { + out.x = amt * pointB.x; + out.y = amt * pointB.y; + } + + return out; +}; + +module.exports = ProjectUnit; + + +/***/ }), +/* 613 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); +var GetMagnitudeSq = __webpack_require__(236); + +/** + * [description] + * + * @function Phaser.Geom.Point.Project + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} pointA - [description] + * @param {Phaser.Geom.Point} pointB - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Project = function (pointA, pointB, out) +{ + if (out === undefined) { out = new Point(); } + + var dot = ((pointA.x * pointB.x) + (pointA.y * pointB.y)); + var amt = dot / GetMagnitudeSq(pointB); + + if (amt !== 0) + { + out.x = amt * pointB.x; + out.y = amt * pointB.y; + } + + return out; +}; + +module.exports = Project; + + +/***/ }), +/* 614 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +/** + * [description] + * + * @function Phaser.Geom.Point.Negative + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Negative = function (point, out) +{ + if (out === undefined) { out = new Point(); } + + return out.setTo(-point.x, -point.y); +}; + +module.exports = Negative; + + +/***/ }), +/* 615 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Point.Invert + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Invert = function (point) +{ + return point.setTo(point.y, point.x); +}; + +module.exports = Invert; + + +/***/ }), +/* 616 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +/** + * [description] + * + * @function Phaser.Geom.Point.Interpolate + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} pointA - [description] + * @param {Phaser.Geom.Point} pointB - [description] + * @param {float} [t=0] - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ +var Interpolate = function (pointA, pointB, t, out) +{ + if (t === undefined) { t = 0; } + if (out === undefined) { out = new Point(); } + + out.x = pointA.x + ((pointB.x - pointA.x) * t); + out.y = pointA.y + ((pointB.y - pointA.y) * t); + + return out; +}; + +module.exports = Interpolate; + + +/***/ }), +/* 617 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(10); + +/** + * Calculates the Axis Aligned Bounding Box (or aabb) from an array of points. + * + * @function Phaser.Geom.Point.GetRectangleFromPoints + * @since 3.0.0 + * + * @param {Phaser.Geom.Point[]} points - [description] + * @param {Phaser.Geom.Rectangle} [out] - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var GetRectangleFromPoints = function (points, out) +{ + if (out === undefined) { out = new Rectangle(); } + + var xMax = Number.NEGATIVE_INFINITY; + var xMin = Number.POSITIVE_INFINITY; + var yMax = Number.NEGATIVE_INFINITY; + var yMin = Number.POSITIVE_INFINITY; + + for (var i = 0; i < points.length; i++) + { + var point = points[i]; + + if (point.x > xMax) + { + xMax = point.x; + } + + if (point.x < xMin) + { + xMin = point.x; + } + + if (point.y > yMax) + { + yMax = point.y; + } + + if (point.y < yMin) + { + yMin = point.y; + } + } + + out.x = xMin; + out.y = yMin; + out.width = xMax - xMin; + out.height = yMax - yMin; + + return out; +}; + +module.exports = GetRectangleFromPoints; + + +/***/ }), +/* 618 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +/** + * [description] + * + * @function Phaser.Geom.Point.GetCentroid + * @since 3.0.0 + * + * @param {Phaser.Geom.Point[]} points - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var GetCentroid = function (points, out) +{ + if (out === undefined) { out = new Point(); } + + if (!Array.isArray(points)) + { + throw new Error('GetCentroid points argument must be an array'); + } + + var len = points.length; + + if (len < 1) + { + throw new Error('GetCentroid points array must not be empty'); + } + else if (len === 1) + { + out.x = points[0].x; + out.y = points[0].y; + } + else + { + for (var i = 0; i < len; i++) + { + out.x += points[i].x; + out.y += points[i].y; + } + + out.x /= len; + out.y /= len; + } + + return out; +}; + +module.exports = GetCentroid; + + +/***/ }), +/* 619 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Point.Floor + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Floor = function (point) +{ + return point.setTo(Math.floor(point.x), Math.floor(point.y)); +}; + +module.exports = Floor; + + +/***/ }), +/* 620 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Point.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * @param {Phaser.Geom.Point} toCompare - [description] + * + * @return {boolean} [description] + */ +var Equals = function (point, toCompare) +{ + return (point.x === toCompare.x && point.y === toCompare.y); +}; + +module.exports = Equals; + + +/***/ }), +/* 621 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Point.CopyFrom + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} source - [description] + * @param {Phaser.Geom.Point} dest - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x, source.y); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 622 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +/** + * [description] + * + * @function Phaser.Geom.Point.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} source - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Clone = function (source) +{ + return new Point(source.x, source.y); +}; + +module.exports = Clone; + + +/***/ }), +/* 623 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Point.Ceil + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Ceil = function (point) +{ + return point.setTo(Math.ceil(point.x), Math.ceil(point.y)); +}; + +module.exports = Ceil; + + +/***/ }), +/* 624 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +Point.Ceil = __webpack_require__(623); +Point.Clone = __webpack_require__(622); +Point.CopyFrom = __webpack_require__(621); +Point.Equals = __webpack_require__(620); +Point.Floor = __webpack_require__(619); +Point.GetCentroid = __webpack_require__(618); +Point.GetMagnitude = __webpack_require__(237); +Point.GetMagnitudeSq = __webpack_require__(236); +Point.GetRectangleFromPoints = __webpack_require__(617); +Point.Interpolate = __webpack_require__(616); +Point.Invert = __webpack_require__(615); +Point.Negative = __webpack_require__(614); +Point.Project = __webpack_require__(613); +Point.ProjectUnit = __webpack_require__(612); +Point.SetMagnitude = __webpack_require__(611); + +module.exports = Point; + + +/***/ }), +/* 625 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Line.Width + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * + * @return {number} [description] + */ +var Width = function (line) +{ + return Math.abs(line.x1 - line.x2); +}; + +module.exports = Width; + + +/***/ }), +/* 626 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Line.Slope + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * + * @return {number} [description] + */ +var Slope = function (line) +{ + return (line.y2 - line.y1) / (line.x2 - line.x1); +}; + +module.exports = Slope; + + +/***/ }), +/* 627 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Line.SetToAngle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} angle - [description] + * @param {number} length - [description] + * + * @return {Phaser.Geom.Line} [description] + */ +var SetToAngle = function (line, x, y, angle, length) +{ + line.x1 = x; + line.y1 = y; + + line.x2 = x + (Math.cos(angle) * length); + line.y2 = y + (Math.sin(angle) * length); + + return line; +}; + +module.exports = SetToAngle; + + +/***/ }), +/* 628 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RotateAroundXY = __webpack_require__(126); + +/** + * [description] + * + * @function Phaser.Geom.Line.RotateAroundPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {(Phaser.Geom.Point|object)} point - [description] + * @param {number} angle - [description] + * + * @return {Phaser.Geom.Line} [description] + */ +var RotateAroundPoint = function (line, point, angle) +{ + return RotateAroundXY(line, point.x, point.y, angle); +}; + +module.exports = RotateAroundPoint; + + +/***/ }), +/* 629 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RotateAroundXY = __webpack_require__(126); + +/** + * [description] + * + * @function Phaser.Geom.Line.Rotate + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {number} angle - [description] + * + * @return {Phaser.Geom.Line} [description] + */ +var Rotate = function (line, angle) +{ + var x = (line.x1 + line.x2) / 2; + var y = (line.y1 + line.y2) / 2; + + return RotateAroundXY(line, x, y, angle); +}; + +module.exports = Rotate; + + +/***/ }), +/* 630 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Angle = __webpack_require__(53); +var NormalAngle = __webpack_require__(238); + +/** +* Returns the reflected angle between two lines. +* This is the outgoing angle based on the angle of Line 1 and the normalAngle of Line 2. +*/ +/** + * [description] + * + * @function Phaser.Geom.Line.ReflectAngle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} lineA - [description] + * @param {Phaser.Geom.Line} lineB - [description] + * + * @return {number} [description] + */ +var ReflectAngle = function (lineA, lineB) +{ + return (2 * NormalAngle(lineB) - Math.PI - Angle(lineA)); +}; + +module.exports = ReflectAngle; + + +/***/ }), +/* 631 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Line.PerpSlope + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * + * @return {number} [description] + */ +var PerpSlope = function (line) +{ + return -((line.x2 - line.x1) / (line.y2 - line.y1)); +}; + +module.exports = PerpSlope; + + +/***/ }), +/* 632 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Line.Offset + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Geom.Line} [description] + */ +var Offset = function (line, x, y) +{ + line.x1 += x; + line.y1 += y; + + line.x2 += x; + line.y2 += y; + + return line; +}; + +module.exports = Offset; + + +/***/ }), +/* 633 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(16); +var Angle = __webpack_require__(53); + +/** + * [description] + * + * @function Phaser.Geom.Line.NormalY + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * + * @return {number} [description] + */ +var NormalY = function (line) +{ + return Math.sin(Angle(line) - MATH_CONST.TAU); +}; + +module.exports = NormalY; + + +/***/ }), +/* 634 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(16); +var Angle = __webpack_require__(53); + +/** + * [description] + * + * @function Phaser.Geom.Line.NormalX + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * + * @return {number} [description] + */ +var NormalX = function (line) +{ + return Math.cos(Angle(line) - MATH_CONST.TAU); +}; + +module.exports = NormalX; + + +/***/ }), +/* 635 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Line.Height + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * + * @return {number} [description] + */ +var Height = function (line) +{ + return Math.abs(line.y1 - line.y2); +}; + +module.exports = Height; + + +/***/ }), +/* 636 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(16); +var Angle = __webpack_require__(53); +var Point = __webpack_require__(4); + +/** + * [description] + * + * @function Phaser.Geom.Line.GetNormal + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ +var GetNormal = function (line, out) +{ + if (out === undefined) { out = new Point(); } + + var a = Angle(line) - MATH_CONST.TAU; + + out.x = Math.cos(a); + out.y = Math.sin(a); + + return out; +}; + +module.exports = GetNormal; + + +/***/ }), +/* 637 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(4); + +/** + * [description] + * + * @function Phaser.Geom.Line.GetMidPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ +var GetMidPoint = function (line, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = (line.x1 + line.x2) / 2; + out.y = (line.y1 + line.y2) / 2; + + return out; +}; + +module.exports = GetMidPoint; + + +/***/ }), +/* 638 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Line.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {Phaser.Geom.Line} toCompare - [description] + * + * @return {boolean} [description] + */ +var Equals = function (line, toCompare) +{ + return ( + line.x1 === toCompare.x1 && + line.y1 === toCompare.y1 && + line.x2 === toCompare.x2 && + line.y2 === toCompare.y2 + ); +}; + +module.exports = Equals; + + +/***/ }), +/* 639 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Line.CopyFrom + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} source - [description] + * @param {Phaser.Geom.Line} dest - [description] + * + * @return {Phaser.Geom.Line} [description] + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x1, source.y1, source.x2, source.y2); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 640 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Line = __webpack_require__(104); + +/** + * [description] + * + * @function Phaser.Geom.Line.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} source - [description] + * + * @return {Phaser.Geom.Line} [description] + */ +var Clone = function (source) +{ + return new Line(source.x1, source.y1, source.x2, source.y2); +}; + +module.exports = Clone; + + +/***/ }), +/* 641 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + + +/** + * [description] + * + * @function Phaser.Geom.Line.CenterOn + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Geom.Line} [description] + */ +var CenterOn = function (line, x, y) +{ + var tx = x - ((line.x1 + line.x2) / 2); + var ty = y - ((line.y1 + line.y2) / 2); + + line.x1 += tx; + line.y1 += ty; + + line.x2 += tx; + line.y2 += ty; + + return line; +}; + +module.exports = CenterOn; + + +/***/ }), +/* 642 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Line = __webpack_require__(104); + +Line.Angle = __webpack_require__(53); +Line.BresenhamPoints = __webpack_require__(344); +Line.CenterOn = __webpack_require__(641); +Line.Clone = __webpack_require__(640); +Line.CopyFrom = __webpack_require__(639); +Line.Equals = __webpack_require__(638); +Line.GetMidPoint = __webpack_require__(637); +Line.GetNormal = __webpack_require__(636); +Line.GetPoint = __webpack_require__(351); +Line.GetPoints = __webpack_require__(165); +Line.Height = __webpack_require__(635); +Line.Length = __webpack_require__(77); +Line.NormalAngle = __webpack_require__(238); +Line.NormalX = __webpack_require__(634); +Line.NormalY = __webpack_require__(633); +Line.Offset = __webpack_require__(632); +Line.PerpSlope = __webpack_require__(631); +Line.Random = __webpack_require__(164); +Line.ReflectAngle = __webpack_require__(630); +Line.Rotate = __webpack_require__(629); +Line.RotateAroundPoint = __webpack_require__(628); +Line.RotateAroundXY = __webpack_require__(126); +Line.SetToAngle = __webpack_require__(627); +Line.Slope = __webpack_require__(626); +Line.Width = __webpack_require__(625); + +module.exports = Line; + + +/***/ }), +/* 643 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ContainsArray = __webpack_require__(127); +var Decompose = __webpack_require__(239); +var LineToLine = __webpack_require__(95); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.TriangleToTriangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangleA - [description] + * @param {Phaser.Geom.Triangle} triangleB - [description] + * + * @return {boolean} [description] + */ +var TriangleToTriangle = function (triangleA, triangleB) +{ + // First the cheapest ones: + + if ( + triangleA.left > triangleB.right || + triangleA.right < triangleB.left || + triangleA.top > triangleB.bottom || + triangleA.bottom < triangleB.top) + { + return false; + } + + var lineAA = triangleA.getLineA(); + var lineAB = triangleA.getLineB(); + var lineAC = triangleA.getLineC(); + + var lineBA = triangleB.getLineA(); + var lineBB = triangleB.getLineB(); + var lineBC = triangleB.getLineC(); + + // Now check the lines against each line of TriangleB + if (LineToLine(lineAA, lineBA) || LineToLine(lineAA, lineBB) || LineToLine(lineAA, lineBC)) + { + return true; + } + + if (LineToLine(lineAB, lineBA) || LineToLine(lineAB, lineBB) || LineToLine(lineAB, lineBC)) + { + return true; + } + + if (LineToLine(lineAC, lineBA) || LineToLine(lineAC, lineBB) || LineToLine(lineAC, lineBC)) + { + return true; + } + + // Nope, so check to see if any of the points of triangleA are within triangleB + + var points = Decompose(triangleA); + var within = ContainsArray(triangleB, points, true); + + if (within.length > 0) + { + return true; + } + + // Finally check to see if any of the points of triangleB are within triangleA + + points = Decompose(triangleB); + within = ContainsArray(triangleA, points, true); + + if (within.length > 0) + { + return true; + } + + return false; +}; + +module.exports = TriangleToTriangle; + + +/***/ }), +/* 644 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(54); +var LineToLine = __webpack_require__(95); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.TriangleToLine + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Line} line - [description] + * + * @return {boolean} [description] + */ +var TriangleToLine = function (triangle, line) +{ + // If the Triangle contains either the start or end point of the line, it intersects + if (Contains(triangle, line.getPointA()) || Contains(triangle, line.getPointB())) + { + return true; + } + + // Now check the line against each line of the Triangle + if (LineToLine(triangle.getLineA(), line)) + { + return true; + } + + if (LineToLine(triangle.getLineB(), line)) + { + return true; + } + + if (LineToLine(triangle.getLineC(), line)) + { + return true; + } + + return false; +}; + +module.exports = TriangleToLine; + + +/***/ }), +/* 645 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var LineToCircle = __webpack_require__(242); +var Contains = __webpack_require__(54); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.TriangleToCircle + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Circle} circle - [description] + * + * @return {boolean} [description] + */ +var TriangleToCircle = function (triangle, circle) +{ + // First the cheapest ones: + + if ( + triangle.left > circle.right || + triangle.right < circle.left || + triangle.top > circle.bottom || + triangle.bottom < circle.top) + { + return false; + } + + if (Contains(triangle, circle.x, circle.y)) + { + return true; + } + + if (LineToCircle(triangle.getLineA(), circle)) + { + return true; + } + + if (LineToCircle(triangle.getLineB(), circle)) + { + return true; + } + + if (LineToCircle(triangle.getLineC(), circle)) + { + return true; + } + + return false; +}; + +module.exports = TriangleToCircle; + + +/***/ }), +/* 646 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Intersects.RectangleToValues + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} left - [description] + * @param {number} right - [description] + * @param {number} top - [description] + * @param {number} bottom - [description] + * @param {float} [tolerance=0] - [description] + * + * @return {boolean} [description] + */ +var RectangleToValues = function (rect, left, right, top, bottom, tolerance) +{ + if (tolerance === undefined) { tolerance = 0; } + + return !( + left > rect.right + tolerance || + right < rect.left - tolerance || + top > rect.bottom + tolerance || + bottom < rect.top - tolerance + ); +}; + +module.exports = RectangleToValues; + + +/***/ }), +/* 647 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var LineToLine = __webpack_require__(95); +var Contains = __webpack_require__(27); +var ContainsArray = __webpack_require__(127); +var Decompose = __webpack_require__(240); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.RectangleToTriangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Triangle} triangle - [description] + * + * @return {boolean} [description] + */ +var RectangleToTriangle = function (rect, triangle) +{ + // First the cheapest ones: + + if ( + triangle.left > rect.right || + triangle.right < rect.left || + triangle.top > rect.bottom || + triangle.bottom < rect.top) + { + return false; + } + + var triA = triangle.getLineA(); + var triB = triangle.getLineB(); + var triC = triangle.getLineC(); + + // Are any of the triangle points within the rectangle? + + if (Contains(rect, triA.x1, triA.y1) || Contains(rect, triA.x2, triA.y2)) + { + return true; + } + + if (Contains(rect, triB.x1, triB.y1) || Contains(rect, triB.x2, triB.y2)) + { + return true; + } + + if (Contains(rect, triC.x1, triC.y1) || Contains(rect, triC.x2, triC.y2)) + { + return true; + } + + // Cheap tests over, now to see if any of the lines intersect ... + + var rectA = rect.getLineA(); + var rectB = rect.getLineB(); + var rectC = rect.getLineC(); + var rectD = rect.getLineD(); + + if (LineToLine(triA, rectA) || LineToLine(triA, rectB) || LineToLine(triA, rectC) || LineToLine(triA, rectD)) + { + return true; + } + + if (LineToLine(triB, rectA) || LineToLine(triB, rectB) || LineToLine(triB, rectC) || LineToLine(triB, rectD)) + { + return true; + } + + if (LineToLine(triC, rectA) || LineToLine(triC, rectB) || LineToLine(triC, rectC) || LineToLine(triC, rectD)) + { + return true; + } + + // None of the lines intersect, so are any rectangle points within the triangle? + + var points = Decompose(rect); + var within = ContainsArray(triangle, points, true); + + return (within.length > 0); +}; + +module.exports = RectangleToTriangle; + + +/***/ }), +/* 648 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PointToLine = __webpack_require__(241); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.PointToLineSegment + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * @param {Phaser.Geom.Line} line - [description] + * + * @return {boolean} [description] + */ +var PointToLineSegment = function (point, line) +{ + if (!PointToLine(point, line)) + { + return false; + } + + var xMin = Math.min(line.x1, line.x2); + var xMax = Math.max(line.x1, line.x2); + var yMin = Math.min(line.y1, line.y2); + var yMax = Math.max(line.y1, line.y2); + + return ((point.x >= xMin && point.x <= xMax) && (point.y >= yMin && point.y <= yMax)); +}; + +module.exports = PointToLineSegment; + + +/***/ }), +/* 649 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Checks for intersection between the Line and a Rectangle shape, or a rectangle-like + * object, with public `x`, `y`, `right` and `bottom` properties, such as a Sprite or Body. + * + * An intersection is considered valid if: + * + * The line starts within, or ends within, the Rectangle. + * The line segment intersects one of the 4 rectangle edges. + * + * The for the purposes of this function rectangles are considered 'solid'. + * + * @function Phaser.Geom.Intersects.LineToRectangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {(Phaser.Geom.Rectangle|object)} rect - [description] + * + * @return {boolean} [description] + */ +var LineToRectangle = function (line, rect) +{ + var x1 = line.x1; + var y1 = line.y1; + + var x2 = line.x2; + var y2 = line.y2; + + var bx1 = rect.x; + var by1 = rect.y; + var bx2 = rect.right; + var by2 = rect.bottom; + + var t = 0; + + // If the start or end of the line is inside the rect then we assume + // collision, as rects are solid for our use-case. + + if ((x1 >= bx1 && x1 <= bx2 && y1 >= by1 && y1 <= by2) || + (x2 >= bx1 && x2 <= bx2 && y2 >= by1 && y2 <= by2)) + { + return true; + } + + if (x1 < bx1 && x2 >= bx1) + { + // Left edge + t = y1 + (y2 - y1) * (bx1 - x1) / (x2 - x1); + + if (t > by1 && t <= by2) + { + return true; + } + } + else if (x1 > bx2 && x2 <= bx2) + { + // Right edge + t = y1 + (y2 - y1) * (bx2 - x1) / (x2 - x1); + + if (t >= by1 && t <= by2) + { + return true; + } + } + + if (y1 < by1 && y2 >= by1) + { + // Top edge + t = x1 + (x2 - x1) * (by1 - y1) / (y2 - y1); + + if (t >= bx1 && t <= bx2) + { + return true; + } + } + else if (y1 > by2 && y2 <= by2) + { + // Bottom edge + t = x1 + (x2 - x1) * (by2 - y1) / (y2 - y1); + + if (t >= bx1 && t <= bx2) + { + return true; + } + } + + return false; +}; + +module.exports = LineToRectangle; + + +/***/ }), +/* 650 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(10); +var RectangleToRectangle = __webpack_require__(243); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.GetRectangleIntersection + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rectA - [description] + * @param {Phaser.Geom.Rectangle} rectB - [description] + * @param {Phaser.Geom.Rectangle} [output] - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var GetRectangleIntersection = function (rectA, rectB, output) +{ + if (output === undefined) { output = new Rectangle(); } + + if (RectangleToRectangle(rectA, rectB)) + { + output.x = Math.max(rectA.x, rectB.x); + output.y = Math.max(rectA.y, rectB.y); + output.width = Math.min(rectA.right, rectB.right) - output.x; + output.height = Math.min(rectA.bottom, rectB.bottom) - output.y; + } + + return output; +}; + +module.exports = GetRectangleIntersection; + + +/***/ }), +/* 651 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Intersects.CircleToRectangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {boolean} [description] + */ +var CircleToRectangle = function (circle, rect) +{ + var halfWidth = rect.width / 2; + var halfHeight = rect.height / 2; + + var cx = Math.abs(circle.x - rect.x - halfWidth); + var cy = Math.abs(circle.y - rect.y - halfHeight); + var xDist = halfWidth + circle.radius; + var yDist = halfHeight + circle.radius; + + if (cx > xDist || cy > yDist) + { + return false; + } + else if (cx <= halfWidth || cy <= halfHeight) + { + return true; + } + else + { + var xCornerDist = cx - halfWidth; + var yCornerDist = cy - halfHeight; + var xCornerDistSq = xCornerDist * xCornerDist; + var yCornerDistSq = yCornerDist * yCornerDist; + var maxCornerDistSq = circle.radius * circle.radius; + + return (xCornerDistSq + yCornerDistSq <= maxCornerDistSq); + } +}; + +module.exports = CircleToRectangle; + + +/***/ }), +/* 652 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var DistanceBetween = __webpack_require__(48); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.CircleToCircle + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circleA - [description] + * @param {Phaser.Geom.Circle} circleB - [description] + * + * @return {boolean} [description] + */ +var CircleToCircle = function (circleA, circleB) +{ + return (DistanceBetween(circleA.x, circleA.y, circleB.x, circleB.y) <= (circleA.radius + circleB.radius)); +}; + +module.exports = CircleToCircle; + + +/***/ }), +/* 653 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Offsets the Circle by the values given in the `x` and `y` properties of the Point object. + * + * @function Phaser.Geom.Circle.OffsetPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to be offset (translated.) + * @param {(Phaser.Geom.Point|object)} point - The Point object containing the values to offset the Circle by. + * + * @return {Phaser.Geom.Circle} The Circle that was offset. + */ +var OffsetPoint = function (circle, point) +{ + circle.x += point.x; + circle.y += point.y; + + return circle; +}; + +module.exports = OffsetPoint; + + +/***/ }), +/* 654 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Offsets the Circle by the values given. + * + * @function Phaser.Geom.Circle.Offset + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to be offset (translated.) + * @param {number} x - The amount to horizontally offset the Circle by. + * @param {number} y - The amount to vertically offset the Circle by. + * + * @return {Phaser.Geom.Circle} The Circle that was offset. + */ +var Offset = function (circle, x, y) +{ + circle.x += x; + circle.y += y; + + return circle; +}; + +module.exports = Offset; + + +/***/ }), +/* 655 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(10); + +/** + * Returns the bounds of the Circle object. + * + * @function Phaser.Geom.Circle.GetBounds + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the bounds from. + * @param {(Phaser.Geom.Rectangle|object)} [out] - A Rectangle, or rectangle-like object, to store the circle bounds in. If not given a new Rectangle will be created. + * + * @return {(Phaser.Geom.Rectangle|object)} The Rectangle object containing the Circles bounds. + */ +var GetBounds = function (circle, out) +{ + if (out === undefined) { out = new Rectangle(); } + + out.x = circle.left; + out.y = circle.top; + out.width = circle.diameter; + out.height = circle.diameter; + + return out; +}; + +module.exports = GetBounds; + + +/***/ }), +/* 656 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Compares the `x`, `y` and `radius` properties of the two given Circles. + * Returns `true` if they all match, otherwise returns `false`. + * + * @function Phaser.Geom.Circle.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The first Circle to compare. + * @param {Phaser.Geom.Circle} toCompare - The second Circle to compare. + * + * @return {boolean} `true` if the two Circles equal each other, otherwise `false`. + */ +var Equals = function (circle, toCompare) +{ + return ( + circle.x === toCompare.x && + circle.y === toCompare.y && + circle.radius === toCompare.radius + ); +}; + +module.exports = Equals; + + +/***/ }), +/* 657 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Copies the `x`, `y` and `radius` properties from the `source` Circle + * into the given `dest` Circle, then returns the `dest` Circle. + * + * @function Phaser.Geom.Circle.CopyFrom + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} source - The source Circle to copy the values from. + * @param {Phaser.Geom.Circle} dest - The destination Circle to copy the values to. + * + * @return {Phaser.Geom.Circle} The dest Circle. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x, source.y, source.radius); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 658 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(28); + +/** + * Check to see if the Circle contains all four points of the given Rectangle object. + * + * @function Phaser.Geom.Circle.ContainsRect + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to check. + * @param {(Phaser.Geom.Rectangle|object)} rect - The Rectangle object to check if it's within the Circle or not. + * + * @return {boolean} True if all of the Rectangle coordinates are within the circle, otherwise false. + */ +var ContainsRect = function (circle, rect) +{ + return ( + Contains(circle, rect.x, rect.y) && + Contains(circle, rect.right, rect.y) && + Contains(circle, rect.x, rect.bottom) && + Contains(circle, rect.right, rect.bottom) + ); +}; + +module.exports = ContainsRect; + + +/***/ }), +/* 659 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(28); + +/** + * Check to see if the Circle contains the given Point object. + * + * @function Phaser.Geom.Circle.ContainsPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to check. + * @param {(Phaser.Geom.Point|object)} point - The Point object to check if it's within the Circle or not. + * + * @return {boolean} True if the Point coordinates are within the circle, otherwise false. + */ +var ContainsPoint = function (circle, point) +{ + return Contains(circle, point.x, point.y); +}; + +module.exports = ContainsPoint; + + +/***/ }), +/* 660 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Circle = __webpack_require__(79); + +/** + * Creates a new Circle instance based on the values contained in the given source. + * + * @function Phaser.Geom.Circle.Clone + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|object)} source - The Circle to be cloned. Can be an instance of a Circle or a circle-like object, with x, y and radius properties. + * + * @return {Phaser.Geom.Circle} A clone of the source Circle. + */ +var Clone = function (source) +{ + return new Circle(source.x, source.y, source.radius); +}; + +module.exports = Clone; + + +/***/ }), +/* 661 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculates the area of the circle. + * + * @function Phaser.Geom.Circle.Area + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the area of. + * + * @return {number} The area of the Circle. + */ +var Area = function (circle) +{ + return (circle.radius > 0) ? Math.PI * circle.radius * circle.radius : 0; +}; + +module.exports = Area; + + +/***/ }), +/* 662 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Circle = __webpack_require__(79); + +Circle.Area = __webpack_require__(661); +Circle.Circumference = __webpack_require__(353); +Circle.CircumferencePoint = __webpack_require__(168); +Circle.Clone = __webpack_require__(660); +Circle.Contains = __webpack_require__(28); +Circle.ContainsPoint = __webpack_require__(659); +Circle.ContainsRect = __webpack_require__(658); +Circle.CopyFrom = __webpack_require__(657); +Circle.Equals = __webpack_require__(656); +Circle.GetBounds = __webpack_require__(655); +Circle.GetPoint = __webpack_require__(355); +Circle.GetPoints = __webpack_require__(354); +Circle.Offset = __webpack_require__(654); +Circle.OffsetPoint = __webpack_require__(653); +Circle.Random = __webpack_require__(167); + +module.exports = Circle; + + +/***/ }), +/* 663 */ +/***/ (function(module, exports, __webpack_require__) { + /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. @@ -101327,8 +101420,3672 @@ module.exports = Stepped; */ var Class = __webpack_require__(0); -var DegToRad = __webpack_require__(35); -var DistanceBetween = __webpack_require__(42); +var LightsManager = __webpack_require__(246); +var PluginManager = __webpack_require__(12); + +/** + * @classdesc + * [description] + * + * @class LightsPlugin + * @extends Phaser.GameObjects.LightsManager + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ +var LightsPlugin = new Class({ + + Extends: LightsManager, + + initialize: + + function LightsPlugin (scene) + { + /** + * [description] + * + * @name Phaser.GameObjects.LightsPlugin#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.GameObjects.LightsPlugin#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + if (!scene.sys.settings.isBooted) + { + scene.sys.events.once('boot', this.boot, this); + } + + LightsManager.call(this); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsPlugin#boot + * @since 3.0.0 + */ + boot: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.LightsPlugin#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + + this.scene = undefined; + this.systems = undefined; + } + +}); + +PluginManager.register('LightsPlugin', LightsPlugin, 'lights'); + +module.exports = LightsPlugin; + + +/***/ }), +/* 664 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(22); +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); +var Quad = __webpack_require__(128); + +/** + * Creates a new Quad Game Object and returns it. + * + * Note: This method will only be available if the Quad Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#quad + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Quad} The Game Object that was created. + */ +GameObjectCreator.register('quad', function (config) +{ + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + + var quad = new Quad(this.scene, x, y, key, frame); + + BuildGameObject(this.scene, quad, config); + + return quad; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 665 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(22); +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); +var GetValue = __webpack_require__(5); +var Mesh = __webpack_require__(96); + +/** + * Creates a new Mesh Game Object and returns it. + * + * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#mesh + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Mesh} The Game Object that was created. + */ +GameObjectCreator.register('mesh', function (config) +{ + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + var vertices = GetValue(config, 'vertices', []); + var colors = GetValue(config, 'colors', []); + var alphas = GetValue(config, 'alphas', []); + var uv = GetValue(config, 'uv', []); + + var mesh = new Mesh(this.scene, 0, 0, vertices, uv, colors, alphas, key, frame); + + BuildGameObject(this.scene, mesh, config); + + return mesh; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 666 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Quad = __webpack_require__(128); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new Quad Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Quad Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#quad + * @webglOnly + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Quad} The Game Object that was created. + */ +if (true) +{ + GameObjectFactory.register('quad', function (x, y, key, frame) + { + return this.displayList.add(new Quad(this.scene, x, y, key, frame)); + }); +} + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 667 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Mesh = __webpack_require__(96); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new Mesh Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#mesh + * @webglOnly + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {array} vertices - An array containing the vertices data for this Mesh. + * @param {array} uv - An array containing the uv data for this Mesh. + * @param {array} colors - An array containing the color data for this Mesh. + * @param {array} alphas - An array containing the alpha data for this Mesh. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Mesh} The Game Object that was created. + */ +if (true) +{ + GameObjectFactory.register('mesh', function (x, y, vertices, uv, colors, alphas, texture, frame) + { + return this.displayList.add(new Mesh(this.scene, x, y, vertices, uv, colors, alphas, texture, frame)); + }); +} + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 668 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * This is a stub function for Mesh.Render. There is no Canvas renderer for Mesh objects. + * + * @method Phaser.GameObjects.Mesh#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Mesh} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var MeshCanvasRenderer = function () +{ +}; + +module.exports = MeshCanvasRenderer; + + +/***/ }), +/* 669 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Mesh#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Mesh} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var MeshWebGLRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + this.pipeline.batchMesh(src, camera); +}; + +module.exports = MeshWebGLRenderer; + + +/***/ }), +/* 670 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); + +if (true) +{ + renderWebGL = __webpack_require__(669); +} + +if (true) +{ + renderCanvas = __webpack_require__(668); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 671 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); +var Zone = __webpack_require__(106); + +/** + * Creates a new Zone Game Object and returns it. + * + * Note: This method will only be available if the Zone Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#zone + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Zone} The Game Object that was created. + */ +GameObjectCreator.register('zone', function (config) +{ + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 1); + var height = GetAdvancedValue(config, 'height', width); + + return new Zone(this.scene, x, y, width, height); +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 672 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(22); +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); +var TileSprite = __webpack_require__(129); + +/** + * @typedef {object} TileSprite + * @extends GameObjectConfig + * + * @property {number} [x=0] - [description] + * @property {number} [y=0] - [description] + * @property {number} [width=512] - [description] + * @property {number} [height=512] - [description] + * @property {string} [key=''] - [description] + * @property {string} [frame=''] - [description] + */ + +/** + * Creates a new TileSprite Game Object and returns it. + * + * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#tileSprite + * @since 3.0.0 + * + * @param {TileSprite} config - [description] + * + * @return {Phaser.GameObjects.TileSprite} The Game Object that was created. + */ +GameObjectCreator.register('tileSprite', function (config) +{ + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 512); + var height = GetAdvancedValue(config, 'height', 512); + var key = GetAdvancedValue(config, 'key', ''); + var frame = GetAdvancedValue(config, 'frame', ''); + + var tile = new TileSprite(this.scene, x, y, width, height, key, frame); + + BuildGameObject(this.scene, tile, config); + + return tile; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 673 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(22); +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); +var Text = __webpack_require__(130); + +/** + * Creates a new Text Game Object and returns it. + * + * Note: This method will only be available if the Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#text + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Text} The Game Object that was created. + */ +GameObjectCreator.register('text', function (config) +{ + // style Object = { + // font: [ 'font', '16px Courier' ], + // backgroundColor: [ 'backgroundColor', null ], + // fill: [ 'fill', '#fff' ], + // stroke: [ 'stroke', '#fff' ], + // strokeThickness: [ 'strokeThickness', 0 ], + // shadowOffsetX: [ 'shadow.offsetX', 0 ], + // shadowOffsetY: [ 'shadow.offsetY', 0 ], + // shadowColor: [ 'shadow.color', '#000' ], + // shadowBlur: [ 'shadow.blur', 0 ], + // shadowStroke: [ 'shadow.stroke', false ], + // shadowFill: [ 'shadow.fill', false ], + // align: [ 'align', 'left' ], + // maxLines: [ 'maxLines', 0 ], + // fixedWidth: [ 'fixedWidth', false ], + // fixedHeight: [ 'fixedHeight', false ], + // rtl: [ 'rtl', false ] + // } + + var content = GetAdvancedValue(config, 'text', ''); + var style = GetAdvancedValue(config, 'style', null); + + // Padding + // { padding: 2 } + // { padding: { x: , y: }} + // { padding: { left: , top: }} + // { padding: { left: , right: , top: , bottom: }} + + var padding = GetAdvancedValue(config, 'padding', null); + + if (padding !== null) + { + style.padding = padding; + } + + var text = new Text(this.scene, 0, 0, content, style); + + BuildGameObject(this.scene, text, config); + + // Text specific config options: + + text.autoRound = GetAdvancedValue(config, 'autoRound', true); + text.resolution = GetAdvancedValue(config, 'resolution', 1); + + return text; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 674 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BitmapText = __webpack_require__(139); +var BuildGameObject = __webpack_require__(22); +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); +var GetValue = __webpack_require__(5); + +/** + * Creates a new Bitmap Text Game Object and returns it. + * + * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#bitmapText + * @since 3.0.0 + * + * @param {BitmapTextConfig} config - [description] + * + * @return {Phaser.GameObjects.BitmapText} The Game Object that was created. + */ +GameObjectCreator.register('bitmapText', function (config) +{ + var font = GetValue(config, 'font', ''); + var text = GetAdvancedValue(config, 'text', ''); + var size = GetAdvancedValue(config, 'size', false); + + // var align = GetValue(config, 'align', 'left'); + + var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size); + + BuildGameObject(this.scene, bitmapText, config); + + return bitmapText; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 675 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(22); +var BuildGameObjectAnimation = __webpack_require__(140); +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); +var Sprite = __webpack_require__(40); + +/** + * Creates a new Sprite Game Object and returns it. + * + * Note: This method will only be available if the Sprite Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#sprite + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Sprite} The Game Object that was created. + */ +GameObjectCreator.register('sprite', function (config) +{ + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + + var sprite = new Sprite(this.scene, 0, 0, key, frame); + + BuildGameObject(this.scene, sprite, config); + + // Sprite specific config options: + + BuildGameObjectAnimation(sprite, config); + + // Physics, Input, etc to follow ... + + return sprite; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 676 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(22); +var BuildGameObjectAnimation = __webpack_require__(140); +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); +var Sprite3D = __webpack_require__(101); + +/** + * Creates a new Sprite3D Game Object and returns it. + * + * Note: This method will only be available if the Sprite3D Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#sprite3D + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Sprite3D} The Game Object that was created. + */ +GameObjectCreator.register('sprite3D', function (config) +{ + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + + var sprite = new Sprite3D(this.scene, 0, 0, key, frame); + + BuildGameObject(this.scene, sprite, config); + + // Sprite specific config options: + + BuildGameObjectAnimation(sprite, config); + + // Physics, Input, etc to follow ... + + return sprite; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 677 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(22); +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); +var RenderTexture = __webpack_require__(131); + +/** + * @typedef {object} RenderTextureConfig + * + * @property {number} [x=0] - [description] + * @property {number} [y=0] - [description] + * @property {number} [width=32] - [description] + * @property {number} [height=32] - [description] + */ + +/** + * Creates a new Render Texture Game Object and returns it. + * + * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#renderTexture + * @since 3.2.0 + * + * @param {RenderTextureConfig} config - [description] + * + * @return {Phaser.GameObjects.RenderTexture} The Game Object that was created. + */ +GameObjectCreator.register('renderTexture', function (config) +{ + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 32); + var height = GetAdvancedValue(config, 'height', 32); + var renderTexture = new RenderTexture(this.scene, x, y, width, height); + + BuildGameObject(this.scene, renderTexture, config); + + return renderTexture; +}); + + +/***/ }), +/* 678 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); +var GetFastValue = __webpack_require__(2); +var ParticleEmitterManager = __webpack_require__(133); + +/** + * Creates a new Particle Emitter Manager Game Object and returns it. + * + * Note: This method will only be available if the Particles Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#particles + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} The Game Object that was created. + */ +GameObjectCreator.register('particles', function (config) +{ + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + var emitters = GetFastValue(config, 'emitters', null); + + // frame is optional and can contain the emitters array or object if skipped + var manager = new ParticleEmitterManager(this.scene, key, frame, emitters); + + var add = GetFastValue(config, 'add', false); + + if (add) + { + this.displayList.add(manager); + } + + this.updateList.add(manager); + + return manager; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 679 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(22); +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); +var Image = __webpack_require__(72); + +/** + * Creates a new Image Game Object and returns it. + * + * Note: This method will only be available if the Image Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#image + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Image} The Game Object that was created. + */ +GameObjectCreator.register('image', function (config) +{ + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + + var image = new Image(this.scene, 0, 0, key, frame); + + BuildGameObject(this.scene, image, config); + + return image; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 680 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectCreator = __webpack_require__(11); +var Group = __webpack_require__(73); + +/** + * Creates a new Group Game Object and returns it. + * + * Note: This method will only be available if the Group Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#group + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Group} The Game Object that was created. + */ +GameObjectCreator.register('group', function (config) +{ + return new Group(this.scene, null, config); +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 681 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectCreator = __webpack_require__(11); +var Graphics = __webpack_require__(136); + +/** + * Creates a new Graphics Game Object and returns it. + * + * Note: This method will only be available if the Graphics Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#graphics + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Graphics} The Game Object that was created. + */ +GameObjectCreator.register('graphics', function (config) +{ + return new Graphics(this.scene, config); +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 682 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BitmapText = __webpack_require__(137); +var BuildGameObject = __webpack_require__(22); +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); + +/** + * @typedef {object} BitmapTextConfig + * @extends GameObjectConfig + * + * @property {string} [font=''] - [description] + * @property {string} [text=''] - [description] + * @property {(number|false)} [size=false] - [description] + * @property {string} [align=''] - [description] + */ + +/** + * Creates a new Dynamic Bitmap Text Game Object and returns it. + * + * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#dynamicBitmapText + * @since 3.0.0 + *² + * @param {BitmapTextConfig} config - [description] + * + * @return {Phaser.GameObjects.DynamicBitmapText} The Game Object that was created. + */ +GameObjectCreator.register('dynamicBitmapText', function (config) +{ + var font = GetAdvancedValue(config, 'font', ''); + var text = GetAdvancedValue(config, 'text', ''); + var size = GetAdvancedValue(config, 'size', false); + var align = GetAdvancedValue(config, 'align', 'left'); + + var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size, align); + + BuildGameObject(this.scene, bitmapText, config); + + return bitmapText; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 683 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Blitter = __webpack_require__(138); +var BuildGameObject = __webpack_require__(22); +var GameObjectCreator = __webpack_require__(11); +var GetAdvancedValue = __webpack_require__(8); + +/** + * Creates a new Blitter Game Object and returns it. + * + * Note: This method will only be available if the Blitter Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#blitter + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Blitter} The Game Object that was created. + */ +GameObjectCreator.register('blitter', function (config) +{ + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + + var blitter = new Blitter(this.scene, 0, 0, key, frame); + + BuildGameObject(this.scene, blitter, config); + + return blitter; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 684 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Zone = __webpack_require__(106); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new Zone Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Zone Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#zone + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number} width - The width of the Game Object. + * @param {number} height - The height of the Game Object. + * + * @return {Phaser.GameObjects.Zone} The Game Object that was created. + */ +GameObjectFactory.register('zone', function (x, y, width, height) +{ + return this.displayList.add(new Zone(this.scene, x, y, width, height)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 685 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TileSprite = __webpack_require__(129); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new TileSprite Game Object and adds it to the Scene. + * + * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#tileSprite + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number} width - The width of the Game Object. + * @param {number} height - The height of the Game Object. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.TileSprite} The Game Object that was created. + */ +GameObjectFactory.register('tileSprite', function (x, y, width, height, key, frame) +{ + return this.displayList.add(new TileSprite(this.scene, x, y, width, height, key, frame)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 686 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Text = __webpack_require__(130); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new Text Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#text + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {(string|string[])} text - The text this Text object will display. + * @param {object} [style] - The Text style configuration object. + * + * @return {Phaser.GameObjects.Text} The Game Object that was created. + */ +GameObjectFactory.register('text', function (x, y, text, style) +{ + return this.displayList.add(new Text(this.scene, x, y, text, style)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 687 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BitmapText = __webpack_require__(139); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new Bitmap Text Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#bitmapText + * @since 3.0.0 + * + * @param {number} x - The x position of the Game Object. + * @param {number} y - The y position of the Game Object. + * @param {string} font - [description] + * @param {(string|string[])} [text] - [description] + * @param {number} [size] - [description] + * + * @return {Phaser.GameObjects.BitmapText} The Game Object that was created. + */ +GameObjectFactory.register('bitmapText', function (x, y, font, text, size) +{ + return this.displayList.add(new BitmapText(this.scene, x, y, font, text, size)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 688 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(9); +var Sprite = __webpack_require__(40); + +/** + * Creates a new Sprite Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Sprite Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#sprite + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Sprite} The Game Object that was created. + */ +GameObjectFactory.register('sprite', function (x, y, key, frame) +{ + var sprite = new Sprite(this.scene, x, y, key, frame); + + this.displayList.add(sprite); + this.updateList.add(sprite); + + return sprite; +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 689 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Sprite3D = __webpack_require__(101); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new Sprite3D Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Sprite3D Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#sprite3D + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object. + * @param {number} y - The vertical position of this Game Object. + * @param {number} z - The z position of this Game Object. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Sprite3D} The Game Object that was created. + */ +GameObjectFactory.register('sprite3D', function (x, y, z, key, frame) +{ + var sprite = new Sprite3D(this.scene, x, y, z, key, frame); + + this.displayList.add(sprite.gameObject); + this.updateList.add(sprite.gameObject); + + return sprite; +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 690 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(9); +var RenderTexture = __webpack_require__(131); + +/** + * Creates a new Render Texture Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#renderTexture + * @since 3.2.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {integer} [width=32] - The width of the Render Texture. + * @param {integer} [height=32] - The height of the Render Texture. + * + * @return {Phaser.GameObjects.RenderTexture} The Game Object that was created. + */ +GameObjectFactory.register('renderTexture', function (x, y, width, height) +{ + return this.displayList.add(new RenderTexture(this.scene, x, y, width, height)); +}); + + +/***/ }), +/* 691 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(9); +var PathFollower = __webpack_require__(249); + +/** + * Creates a new PathFollower Game Object and adds it to the Scene. + * + * Note: This method will only be available if the PathFollower Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#follower + * @since 3.0.0 + * + * @param {Phaser.Curves.Path} path - The Path this PathFollower is connected to. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.PathFollower} The Game Object that was created. + */ +GameObjectFactory.register('follower', function (path, x, y, key, frame) +{ + var sprite = new PathFollower(this.scene, path, x, y, key, frame); + + this.displayList.add(sprite); + this.updateList.add(sprite); + + return sprite; +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 692 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(9); +var ParticleEmitterManager = __webpack_require__(133); + +/** + * Creates a new Particle Emitter Manager Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Particles Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#particles + * @since 3.0.0 + * + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer|object)} [frame] - [description] + * @param {object} [emitters] - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} The Game Object that was created. + */ +GameObjectFactory.register('particles', function (key, frame, emitters) +{ + var manager = new ParticleEmitterManager(this.scene, key, frame, emitters); + + this.displayList.add(manager); + this.updateList.add(manager); + + return manager; +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 693 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Image = __webpack_require__(72); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new Image Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Image Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#image + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Image} The Game Object that was created. + */ +GameObjectFactory.register('image', function (x, y, key, frame) +{ + return this.displayList.add(new Image(this.scene, x, y, key, frame)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 694 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Group = __webpack_require__(73); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new Group Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Group Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#group + * @since 3.0.0 + * + * @param {(array|object)} children - [description] + * @param {object} [config] - [description] + * + * @return {Phaser.GameObjects.Group} The Game Object that was created. + */ +GameObjectFactory.register('group', function (children, config) +{ + if (typeof children === 'object' && config === undefined) + { + config = children; + children = []; + } + + return this.updateList.add(new Group(this.scene, children, config)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 695 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Graphics = __webpack_require__(136); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new Graphics Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Graphics Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#graphics + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Graphics} The Game Object that was created. + */ +GameObjectFactory.register('graphics', function (config) +{ + return this.displayList.add(new Graphics(this.scene, config)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 696 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var DynamicBitmapText = __webpack_require__(137); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new Dynamic Bitmap Text Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#dynamicBitmapText + * @since 3.0.0 + * + * @param {number} x - The x position of the Game Object. + * @param {number} y - The y position of the Game Object. + * @param {string} font - [description] + * @param {(string|string[])} [text] - [description] + * @param {number} [size] - [description] + * + * @return {Phaser.GameObjects.DynamicBitmapText} The Game Object that was created. + */ +GameObjectFactory.register('dynamicBitmapText', function (x, y, font, text, size) +{ + return this.displayList.add(new DynamicBitmapText(this.scene, x, y, font, text, size)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 697 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Blitter = __webpack_require__(138); +var GameObjectFactory = __webpack_require__(9); + +/** + * Creates a new Blitter Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Blitter Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#blitter + * @since 3.0.0 + * + * @param {number} x - The x position of the Game Object. + * @param {number} y - The y position of the Game Object. + * @param {string} key - The key of the Texture the Blitter object will use. + * @param {(string|integer)} [frame] - The default Frame children of the Blitter will use. + * + * @return {Phaser.GameObjects.Blitter} The Game Object that was created. + */ +GameObjectFactory.register('blitter', function (x, y, key, frame) +{ + return this.displayList.add(new Blitter(this.scene, x, y, key, frame)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 698 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.TileSprite#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.TileSprite} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + var ctx = renderer.currentContext; + var frame = src.frame; + + src.updateTileTexture(); + + // Blend Mode + + if (renderer.currentBlendMode !== src.blendMode) + { + renderer.currentBlendMode = src.blendMode; + ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; + } + + // Alpha + + if (renderer.currentAlpha !== src.alpha) + { + renderer.currentAlpha = src.alpha; + ctx.globalAlpha = src.alpha; + } + + // Smoothing + + if (renderer.currentScaleMode !== src.scaleMode) + { + renderer.currentScaleMode = src.scaleMode; + } + + var dx = frame.x - (src.originX * src.width); + var dy = frame.y - (src.originY * src.height); + + var tx = src.x - camera.scrollX * src.scrollFactorX; + var ty = src.y - camera.scrollY * src.scrollFactorY; + + var fx = 1; + var fy = 1; + + // Flipping + + if (src.flipX) + { + fx = -1; + dx += src.width; + } + + if (src.flipY) + { + fy = -1; + dy += src.height; + } + + if (renderer.config.roundPixels) + { + dx |= 0; + dy |= 0; + tx |= 0; + ty |= 0; + } + + ctx.save(); + + ctx.translate(dx, dy); + + ctx.translate(tx, ty); + + // Flip + ctx.scale(fx, fy); + + // Rotate and scale around center + ctx.translate((src.originX * src.width), (src.originY * src.height)); + ctx.rotate(fx * fy * src.rotation); + ctx.scale(this.scaleX, this.scaleY); + ctx.translate(-(src.originX * src.width), -(src.originY * src.height)); + + // Draw + ctx.translate(-this.tilePositionX, -this.tilePositionY); + ctx.fillStyle = src.canvasPattern; + ctx.fillRect(this.tilePositionX, this.tilePositionY, src.width, src.height); + + ctx.restore(); +}; + +module.exports = TileSpriteCanvasRenderer; + + +/***/ }), +/* 699 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.TileSprite#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.TileSprite} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var TileSpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + src.updateTileTexture(); + + this.pipeline.batchTileSprite(this, camera); +}; + +module.exports = TileSpriteWebGLRenderer; + + +/***/ }), +/* 700 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); + +if (true) +{ + renderWebGL = __webpack_require__(699); +} + +if (true) +{ + renderCanvas = __webpack_require__(698); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 701 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasPool = __webpack_require__(23); + +/** + * Calculates the ascent, descent and fontSize of a given font style. + * + * @function Phaser.GameObjects.Text.MeasureText + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Text.TextStyle} textStyle - The TextStyle object to measure. + * + * @return {object} An object containing the ascent, descent and fontSize of the TextStyle. + */ +var MeasureText = function (textStyle) +{ + // @property {HTMLCanvasElement} canvas - The canvas element that the text is rendered. + var canvas = CanvasPool.create(this); + + // @property {HTMLCanvasElement} context - The context of the canvas element that the text is rendered to. + var context = canvas.getContext('2d'); + + textStyle.syncFont(canvas, context); + + var width = Math.ceil(context.measureText(textStyle.testString).width * textStyle.baselineX); + var baseline = width; + var height = 2 * baseline; + + baseline = baseline * textStyle.baselineY | 0; + + canvas.width = width; + canvas.height = height; + + context.fillStyle = '#f00'; + context.fillRect(0, 0, width, height); + + context.font = textStyle._font; + + context.textBaseline = 'alphabetic'; + context.fillStyle = '#000'; + context.fillText(textStyle.testString, 0, baseline); + + var output = { + ascent: 0, + descent: 0, + fontSize: 0 + }; + + if (!context.getImageData(0, 0, width, height)) + { + output.ascent = baseline; + output.descent = baseline + 6; + output.fontSize = output.ascent + output.descent; + + CanvasPool.remove(canvas); + + return output; + } + + var imagedata = context.getImageData(0, 0, width, height).data; + var pixels = imagedata.length; + var line = width * 4; + var i; + var j; + var idx = 0; + var stop = false; + + // ascent. scan from top to bottom until we find a non red pixel + for (i = 0; i < baseline; i++) + { + for (j = 0; j < line; j += 4) + { + if (imagedata[idx + j] !== 255) + { + stop = true; + break; + } + } + + if (!stop) + { + idx += line; + } + else + { + break; + } + } + + output.ascent = baseline - i; + + idx = pixels - line; + stop = false; + + // descent. scan from bottom to top until we find a non red pixel + for (i = height; i > baseline; i--) + { + for (j = 0; j < line; j += 4) + { + if (imagedata[idx + j] !== 255) + { + stop = true; + break; + } + } + + if (!stop) + { + idx -= line; + } + else + { + break; + } + } + + output.descent = (i - baseline); + output.fontSize = output.ascent + output.descent; + + CanvasPool.remove(canvas); + + return output; +}; + +module.exports = MeasureText; + + +/***/ }), +/* 702 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetAdvancedValue = __webpack_require__(8); +var GetValue = __webpack_require__(5); +var MeasureText = __webpack_require__(701); + +// Key: [ Object Key, Default Value ] + +/** + * A custom function that will be responsible for wrapping the text. + * @callback TextStyleWordWrapCallback + * + * @param {string} text - The string to wrap. + * @param {Phaser.GameObjects.Text} textObject - The Text instance. + * + * @return {(string|string[])} Should return the wrapped lines either as an array of lines or as a string with + * newline characters in place to indicate where breaks should happen. + */ + +var propertyMap = { + fontFamily: [ 'fontFamily', 'Courier' ], + fontSize: [ 'fontSize', '16px' ], + fontStyle: [ 'fontStyle', '' ], + backgroundColor: [ 'backgroundColor', null ], + color: [ 'color', '#fff' ], + stroke: [ 'stroke', '#fff' ], + strokeThickness: [ 'strokeThickness', 0 ], + shadowOffsetX: [ 'shadow.offsetX', 0 ], + shadowOffsetY: [ 'shadow.offsetY', 0 ], + shadowColor: [ 'shadow.color', '#000' ], + shadowBlur: [ 'shadow.blur', 0 ], + shadowStroke: [ 'shadow.stroke', false ], + shadowFill: [ 'shadow.fill', false ], + align: [ 'align', 'left' ], + maxLines: [ 'maxLines', 0 ], + fixedWidth: [ 'fixedWidth', 0 ], + fixedHeight: [ 'fixedHeight', 0 ], + rtl: [ 'rtl', false ], + testString: [ 'testString', '|MÉqgy' ], + baselineX: [ 'baselineX', 1.2 ], + baselineY: [ 'baselineY', 1.4 ], + wordWrapWidth: [ 'wordWrap.width', null ], + wordWrapCallback: [ 'wordWrap.callback', null ], + wordWrapCallbackScope: [ 'wordWrap.callbackScope', null ], + wordWrapUseAdvanced: [ 'wordWrap.useAdvancedWrap', false ] +}; + +/** + * @classdesc + * [description] + * + * @class TextStyle + * @memberOf Phaser.GameObjects.Text + * @constructor + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Text} text - The Text object that this TextStyle is styling. + * @param {object} style - [description] + */ +var TextStyle = new Class({ + + initialize: + + function TextStyle (text, style) + { + /** + * The Text object that this TextStyle is styling. + * + * @name Phaser.GameObjects.Components.TextStyle#parent + * @type {Phaser.GameObjects.Text} + * @since 3.0.0 + */ + this.parent = text; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#fontFamily + * @type {string} + * @default 'Courier' + * @since 3.0.0 + */ + this.fontFamily; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#fontSize + * @type {string} + * @default '16px' + * @since 3.0.0 + */ + this.fontSize; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#fontStyle + * @type {string} + * @since 3.0.0 + */ + this.fontStyle; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#backgroundColor + * @type {string} + * @since 3.0.0 + */ + this.backgroundColor; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#color + * @type {string} + * @default '#fff' + * @since 3.0.0 + */ + this.color; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#stroke + * @type {string} + * @default '#fff' + * @since 3.0.0 + */ + this.stroke; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#strokeThickness + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.strokeThickness; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#shadowOffsetX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.shadowOffsetX; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#shadowOffsetY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.shadowOffsetY; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#shadowColor + * @type {string} + * @default '#000' + * @since 3.0.0 + */ + this.shadowColor; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#shadowBlur + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.shadowBlur; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#shadowStroke + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.shadowStroke; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#shadowFill + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.shadowFill; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#align + * @type {string} + * @default 'left' + * @since 3.0.0 + */ + this.align; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#maxLines + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.maxLines; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#fixedWidth + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.fixedWidth; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#fixedHeight + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.fixedHeight; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#rtl + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.rtl; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#testString + * @type {string} + * @default '|MÉqgy' + * @since 3.0.0 + */ + this.testString; + + /** + * The amount of horizontal padding adding to the width of the text when calculating the font metrics. + * + * @name Phaser.GameObjects.Components.TextStyle#baselineX + * @type {number} + * @default 1.2 + * @since 3.3.0 + */ + this.baselineX; + + /** + * The amount of vertical padding adding to the width of the text when calculating the font metrics. + * + * @name Phaser.GameObjects.Components.TextStyle#baselineY + * @type {number} + * @default 1.4 + * @since 3.3.0 + */ + this.baselineY; + + /** + * [description] + * + * @name Phaser.GameObjects.Components.TextStyle#_font + * @type {string} + * @private + * @since 3.0.0 + */ + this._font; + + // Set to defaults + user style + this.setStyle(style, false); + + var metrics = GetValue(style, 'metrics', false); + + // Provide optional TextMetrics in the style object to avoid the canvas look-up / scanning + // Doing this is reset if you then change the font of this TextStyle after creation + if (metrics) + { + this.metrics = { + ascent: GetValue(metrics, 'ascent', 0), + descent: GetValue(metrics, 'descent', 0), + fontSize: GetValue(metrics, 'fontSize', 0) + }; + } + else + { + this.metrics = MeasureText(this); + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setStyle + * @since 3.0.0 + * + * @param {CSSStyleRule} style - [description] + * @param {boolean} [updateText=true] - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setStyle: function (style, updateText) + { + if (updateText === undefined) { updateText = true; } + + // Avoid type mutation + if (style && style.hasOwnProperty('fontSize') && typeof style.fontSize === 'number') + { + style.fontSize = style.fontSize.toString() + 'px'; + } + + for (var key in propertyMap) + { + if (key === 'wordWrapCallback' || key === 'wordWrapCallbackScope') + { + // Callback & scope should be set without processing the values + this[key] = GetValue(style, propertyMap[key][0], propertyMap[key][1]); + } + else + { + this[key] = GetAdvancedValue(style, propertyMap[key][0], propertyMap[key][1]); + } + } + + // Allow for 'font' override + var font = GetValue(style, 'font', null); + + if (font === null) + { + this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' '); + } + else + { + this._font = font; + } + + // Allow for 'fill' to be used in place of 'color' + var fill = GetValue(style, 'fill', null); + + if (fill !== null) + { + this.color = fill; + } + + if (updateText) + { + return this.update(true); + } + else + { + return this.parent; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#syncFont + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - [description] + * @param {CanvasRenderingContext2D} context - [description] + */ + syncFont: function (canvas, context) + { + context.font = this._font; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#syncStyle + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - [description] + * @param {CanvasRenderingContext2D} context - [description] + */ + syncStyle: function (canvas, context) + { + context.textBaseline = 'alphabetic'; + + context.fillStyle = this.color; + context.strokeStyle = this.stroke; + + context.lineWidth = this.strokeThickness; + context.lineCap = 'round'; + context.lineJoin = 'round'; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#syncShadow + * @since 3.0.0 + * + * @param {CanvasRenderingContext2D} context - [description] + * @param {boolean} enabled - [description] + */ + syncShadow: function (context, enabled) + { + if (enabled) + { + context.shadowOffsetX = this.shadowOffsetX; + context.shadowOffsetY = this.shadowOffsetY; + context.shadowColor = this.shadowColor; + context.shadowBlur = this.shadowBlur; + } + else + { + context.shadowOffsetX = 0; + context.shadowOffsetY = 0; + context.shadowColor = 0; + context.shadowBlur = 0; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#update + * @since 3.0.0 + * + * @param {boolean} recalculateMetrics - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + update: function (recalculateMetrics) + { + if (recalculateMetrics) + { + this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' '); + + this.metrics = MeasureText(this); + } + + return this.parent.updateText(); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setFont + * @since 3.0.0 + * + * @param {(string|object)} font - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFont: function (font) + { + if (typeof font === 'string') + { + this.fontFamily = font; + this.fontSize = ''; + this.fontStyle = ''; + } + else + { + this.fontFamily = GetValue(font, 'fontFamily', 'Courier'); + this.fontSize = GetValue(font, 'fontSize', '16px'); + this.fontStyle = GetValue(font, 'fontStyle', ''); + } + + return this.update(true); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setFontFamily + * @since 3.0.0 + * + * @param {string} family - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFontFamily: function (family) + { + this.fontFamily = family; + + return this.update(true); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setFontStyle + * @since 3.0.0 + * + * @param {string} style - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFontStyle: function (style) + { + this.fontStyle = style; + + return this.update(true); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setFontSize + * @since 3.0.0 + * + * @param {(number|string)} size - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFontSize: function (size) + { + if (typeof size === 'number') + { + size = size.toString() + 'px'; + } + + this.fontSize = size; + + return this.update(true); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setTestString + * @since 3.0.0 + * + * @param {string} string - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setTestString: function (string) + { + this.testString = string; + + return this.update(true); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setFixedSize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFixedSize: function (width, height) + { + this.fixedWidth = width; + this.fixedHeight = height; + + if (width) + { + this.parent.width = width; + } + + if (height) + { + this.parent.height = height; + } + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setBackgroundColor + * @since 3.0.0 + * + * @param {string} color - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setBackgroundColor: function (color) + { + this.backgroundColor = color; + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setFill + * @since 3.0.0 + * + * @param {string} color - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFill: function (color) + { + this.color = color; + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setColor + * @since 3.0.0 + * + * @param {string} color - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setColor: function (color) + { + this.color = color; + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setStroke + * @since 3.0.0 + * + * @param {string} color - [description] + * @param {number} thickness - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setStroke: function (color, thickness) + { + if (color === undefined) + { + // Reset the stroke to zero (disabling it) + this.strokeThickness = 0; + } + else + { + if (thickness === undefined) { thickness = this.strokeThickness; } + + this.stroke = color; + this.strokeThickness = thickness; + } + + return this.update(true); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setShadow + * @since 3.0.0 + * + * @param {number} [x=0] - [description] + * @param {number} [y=0] - [description] + * @param {string} [color='#000'] - [description] + * @param {number} [blur=0] - [description] + * @param {boolean} [shadowStroke=false] - [description] + * @param {boolean} [shadowFill=true] - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadow: function (x, y, color, blur, shadowStroke, shadowFill) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (color === undefined) { color = '#000'; } + if (blur === undefined) { blur = 0; } + if (shadowStroke === undefined) { shadowStroke = false; } + if (shadowFill === undefined) { shadowFill = true; } + + this.shadowOffsetX = x; + this.shadowOffsetY = y; + this.shadowColor = color; + this.shadowBlur = blur; + this.shadowStroke = shadowStroke; + this.shadowFill = shadowFill; + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setShadowOffset + * @since 3.0.0 + * + * @param {number} [x=0] - [description] + * @param {number} [y=0] - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadowOffset: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + + this.shadowOffsetX = x; + this.shadowOffsetY = y; + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setShadowColor + * @since 3.0.0 + * + * @param {string} [color='#000'] - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadowColor: function (color) + { + if (color === undefined) { color = '#000'; } + + this.shadowColor = color; + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setShadowBlur + * @since 3.0.0 + * + * @param {number} [blur=0] - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadowBlur: function (blur) + { + if (blur === undefined) { blur = 0; } + + this.shadowBlur = blur; + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setShadowStroke + * @since 3.0.0 + * + * @param {boolean} enabled - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadowStroke: function (enabled) + { + this.shadowStroke = enabled; + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setShadowFill + * @since 3.0.0 + * + * @param {boolean} enabled - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadowFill: function (enabled) + { + this.shadowFill = enabled; + + return this.update(false); + }, + + /** + * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width. + * + * @method Phaser.GameObjects.Components.TextStyle#setWordWrapWidth + * @since 3.0.0 + * + * @param {number} width - The maximum width of a line in pixels. Set to null to remove wrapping. + * @param {boolean} [useAdvancedWrap=false] - Whether or not to use the advanced wrapping + * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, + * spaces and whitespace are left as is. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setWordWrapWidth: function (width, useAdvancedWrap) + { + if (useAdvancedWrap === undefined) { useAdvancedWrap = false; } + + this.wordWrapWidth = width; + this.wordWrapUseAdvanced = useAdvancedWrap; + + return this.update(false); + }, + + /** + * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback. + * + * @method Phaser.GameObjects.Components.TextStyle#setWordWrapCallback + * @since 3.0.0 + * + * @param {TextStyleWordWrapCallback} callback - A custom function that will be responsible for wrapping the + * text. It will receive two arguments: text (the string to wrap), textObject (this Text + * instance). It should return the wrapped lines either as an array of lines or as a string with + * newline characters in place to indicate where breaks should happen. + * @param {object} [scope=null] - The scope that will be applied when the callback is invoked. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setWordWrapCallback: function (callback, scope) + { + if (scope === undefined) { scope = null; } + + this.wordWrapCallback = callback; + this.wordWrapCallbackScope = scope; + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setAlign + * @since 3.0.0 + * + * @param {string} align - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setAlign: function (align) + { + if (align === undefined) { align = 'left'; } + + this.align = align; + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#setMaxLines + * @since 3.0.0 + * + * @param {integer} [max=0] - [description] + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setMaxLines: function (max) + { + if (max === undefined) { max = 0; } + + this.maxLines = max; + + return this.update(false); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#getTextMetrics + * @since 3.0.0 + * + * @return {object} [description] + */ + getTextMetrics: function () + { + var metrics = this.metrics; + + return { + ascent: metrics.ascent, + descent: metrics.descent, + fontSize: metrics.fontSize + }; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#toJSON + * @since 3.0.0 + * + * @return {object} [description] + */ + toJSON: function () + { + var output = {}; + + for (var key in propertyMap) + { + output[key] = this[key]; + } + + output.metrics = this.getTextMetrics(); + + return output; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.TextStyle#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.parent = undefined; + } + +}); + +module.exports = TextStyle; + + +/***/ }), +/* 703 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Text#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Text} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var TextCanvasRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)) || src.text === '') + { + return; + } + + var ctx = renderer.currentContext; + + // var resolution = src.resolution; + + // Blend Mode + if (renderer.currentBlendMode !== src.blendMode) + { + renderer.currentBlendMode = src.blendMode; + ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; + } + + // Alpha + if (renderer.currentAlpha !== src.alpha) + { + renderer.currentAlpha = src.alpha; + ctx.globalAlpha = src.alpha; + } + + // Smoothing + if (renderer.currentScaleMode !== src.scaleMode) + { + renderer.currentScaleMode = src.scaleMode; + } + + var canvas = src.canvas; + + ctx.save(); + + var tx = src.x - camera.scrollX * src.scrollFactorX; + var ty = src.y - camera.scrollY * src.scrollFactorY; + + if (renderer.config.roundPixels) + { + tx |= 0; + ty |= 0; + } + + ctx.translate(tx, ty); + + ctx.rotate(src.rotation); + + ctx.scale(src.scaleX, src.scaleY); + + ctx.translate(canvas.width * (src.flipX ? 1 : 0), canvas.height * (src.flipY ? 1 : 0)); + + ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); + + ctx.drawImage(canvas, 0, 0, canvas.width, canvas.height, -src.displayOriginX, -src.displayOriginY, canvas.width, canvas.height); + + ctx.restore(); +}; + +module.exports = TextCanvasRenderer; + + +/***/ }), +/* 704 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Text#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Text} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var TextWebGLRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)) || src.text === '') + { + return; + } + + if (src.dirty) + { + src.canvasTexture = renderer.canvasToTexture(src.canvas, src.canvasTexture, true, src.scaleMode); + src.dirty = false; + } + + this.pipeline.batchText(this, camera); +}; + +module.exports = TextWebGLRenderer; + + +/***/ }), +/* 705 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); + +if (true) +{ + renderWebGL = __webpack_require__(704); +} + +if (true) +{ + renderCanvas = __webpack_require__(703); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 706 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns an object containing dimensions of the Text object. + * + * @function Phaser.GameObjects.Text.GetTextSize + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Text} text - The Text object to get the size from. + * @param {number} size - [description] + * @param {array} lines - [description] + * + * @return {object} An object containing dimensions of the Text object. + */ +var GetTextSize = function (text, size, lines) +{ + var canvas = text.canvas; + var context = text.context; + var style = text.style; + + var lineWidths = []; + var maxLineWidth = 0; + var drawnLines = lines.length; + + if (style.maxLines > 0 && style.maxLines < lines.length) + { + drawnLines = style.maxLines; + } + + style.syncFont(canvas, context); + + // Text Width + + for (var i = 0; i < drawnLines; i++) + { + var lineWidth = style.strokeThickness; + + lineWidth += context.measureText(lines[i]).width; + + // Adjust for wrapped text + if (style.wordWrap) + { + lineWidth -= context.measureText(' ').width; + } + + lineWidths[i] = Math.ceil(lineWidth); + maxLineWidth = Math.max(maxLineWidth, lineWidths[i]); + } + + // Text Height + + var lineHeight = size.fontSize + style.strokeThickness; + var height = lineHeight * drawnLines; + var lineSpacing = text._lineSpacing || 0; + + if (lineSpacing < 0 && Math.abs(lineSpacing) > lineHeight) + { + lineSpacing = -lineHeight; + } + + // Adjust for line spacing + if (lineSpacing !== 0) + { + height += (lineSpacing > 0) ? lineSpacing * lines.length : lineSpacing * (lines.length - 1); + } + + return { + width: maxLineWidth, + height: height, + lines: drawnLines, + lineWidths: lineWidths, + lineSpacing: lineSpacing, + lineHeight: lineHeight + }; +}; + +module.exports = GetTextSize; + + +/***/ }), +/* 707 */ +/***/ (function(module, exports) { + +var RenderTextureWebGL = { + + fill: function (rgb) + { + var ur = ((rgb >> 16)|0) & 0xff; + var ug = ((rgb >> 8)|0) & 0xff; + var ub = (rgb|0) & 0xff; + + this.renderer.setFramebuffer(this.framebuffer); + var gl = this.gl; + gl.clearColor(ur / 255.0, ug / 255.0, ub / 255.0, 1); + gl.clear(gl.COLOR_BUFFER_BIT); + this.renderer.setFramebuffer(null); + return this; + }, + + clear: function () + { + this.renderer.setFramebuffer(this.framebuffer); + var gl = this.gl; + gl.clearColor(0, 0, 0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); + this.renderer.setFramebuffer(null); + return this; + }, + + draw: function (texture, frame, x, y) + { + var glTexture = texture.source[frame.sourceIndex].glTexture; + var tint = (this.globalTint >> 16) + (this.globalTint & 0xff00) + ((this.globalTint & 0xff) << 16); + this.renderer.setFramebuffer(this.framebuffer); + this.renderer.pipelines.TextureTintPipeline.drawTexture(glTexture, x, y, tint, this.globalAlpha, frame.cutX, frame.cutY, frame.cutWidth, frame.cutHeight, this.currentMatrix); + this.renderer.setFramebuffer(null); + return this; + } + +}; + +module.exports = RenderTextureWebGL; + + +/***/ }), +/* 708 */ +/***/ (function(module, exports) { + +var RenderTextureCanvas = { + + fill: function (rgb) + { + var ur = ((rgb >> 16)|0) & 0xff; + var ug = ((rgb >> 8)|0) & 0xff; + var ub = (rgb|0) & 0xff; + + this.context.fillStyle = 'rgb(' + ur + ',' + ug + ',' + ub + ')'; + this.context.fillRect(0, 0, this.canvas.width, this.canvas.height); + return this; + }, + + clear: function () + { + this.context.save(); + this.context.setTransform(1, 0, 0, 1, 0, 0); + this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); + this.context.restore(); + return this; + }, + + draw: function (texture, frame, x, y) + { + var matrix = this.currentMatrix; + + this.context.globalAlpha = this.globalAlpha; + this.context.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + this.context.drawImage(texture.source[frame.sourceIndex].image, frame.cutX, frame.cutY, frame.cutWidth, frame.cutHeight, x, y, frame.cutWidth, frame.cutWidth); + + return this; + } + +}; + +module.exports = RenderTextureCanvas; + + +/***/ }), +/* 709 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.RenderTexture#renderCanvas + * @since 3.2.0 + * @private + * + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.RenderTexture} renderTexture - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var RenderTextureCanvasRenderer = function (renderer, renderTexture, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== renderTexture.renderFlags || (renderTexture.cameraFilter > 0 && (renderTexture.cameraFilter & camera._id))) + { + return; + } + + var ctx = renderer.currentContext; + + if (renderer.currentBlendMode !== renderTexture.blendMode) + { + renderer.currentBlendMode = renderTexture.blendMode; + ctx.globalCompositeOperation = renderer.blendModes[renderTexture.blendMode]; + } + + if (renderer.currentAlpha !== renderTexture.alpha) + { + renderer.currentAlpha = renderTexture.alpha; + ctx.globalAlpha = renderTexture.alpha; + } + + if (renderer.currentScaleMode !== renderTexture.scaleMode) + { + renderer.currentScaleMode = renderTexture.scaleMode; + } + + var dx = 0; + var dy = 0; + + var fx = 1; + var fy = 1; + + if (renderTexture.flipX) + { + fx = -1; + dx -= renderTexture.canvas.width - renderTexture.displayOriginX; + } + else + { + dx -= renderTexture.displayOriginX; + } + + if (renderTexture.flipY) + { + fy = -1; + dy -= renderTexture.canvas.height - renderTexture.displayOriginY; + } + else + { + dy -= renderTexture.displayOriginY; + } + + ctx.save(); + ctx.translate(renderTexture.x - camera.scrollX * renderTexture.scrollFactorX, renderTexture.y - camera.scrollY * renderTexture.scrollFactorY); + ctx.rotate(renderTexture.rotation); + ctx.scale(renderTexture.scaleX, renderTexture.scaleY); + ctx.scale(fx, fy); + ctx.drawImage(renderTexture.canvas, dx, dy); + ctx.restore(); +}; + +module.exports = RenderTextureCanvasRenderer; + + +/***/ }), +/* 710 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.RenderTexture#renderWebgl + * @since 3.2.0 + * @private + * + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.RenderTexture} renderTexture - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var RenderTextureWebGLRenderer = function (renderer, renderTexture, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== renderTexture.renderFlags || (renderTexture.cameraFilter > 0 && (renderTexture.cameraFilter & camera._id))) + { + return; + } + + this.pipeline.batchTexture( + renderTexture, + renderTexture.texture, + renderTexture.texture.width, renderTexture.texture.height, + renderTexture.x, renderTexture.y, + renderTexture.width, renderTexture.height, + renderTexture.scaleX, renderTexture.scaleY, + renderTexture.rotation, + renderTexture.flipX, renderTexture.flipY, + renderTexture.scrollFactorX, renderTexture.scrollFactorY, + renderTexture.displayOriginX, renderTexture.displayOriginY, + 0, 0, renderTexture.texture.width, renderTexture.texture.height, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0, 0, + camera + ); +}; + +module.exports = RenderTextureWebGLRenderer; + + +/***/ }), +/* 711 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); + +if (true) +{ + renderWebGL = __webpack_require__(710); +} + +if (true) +{ + renderCanvas = __webpack_require__(709); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 712 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Particles.EmitterManager#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Particles} emitterManager - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpolationPercentage, camera) +{ + var emitters = emitterManager.emitters.list; + + if (emitters.length === 0 || GameObject.RENDER_MASK !== emitterManager.renderFlags || (emitterManager.cameraFilter > 0 && (emitterManager.cameraFilter & camera._id))) + { + return; + } + + for (var i = 0; i < emitters.length; i++) + { + var emitter = emitters[i]; + + var particles = emitter.alive; + var length = particles.length; + + if (!emitter.visible || length === 0) + { + continue; + } + + var ctx = renderer.currentContext; + + var lastAlpha = ctx.globalAlpha; + var cameraScrollX = camera.scrollX * emitter.scrollFactorX; + var cameraScrollY = camera.scrollY * emitter.scrollFactorY; + + if (renderer.currentBlendMode !== emitter.blendMode) + { + renderer.currentBlendMode = emitter.blendMode; + ctx.globalCompositeOperation = renderer.blendModes[emitter.blendMode]; + } + + var roundPixels = renderer.config.roundPixels; + + for (var index = 0; index < length; ++index) + { + var particle = particles[index]; + + var alpha = ((particle.color >> 24) & 0xFF) / 255.0; + + if (alpha <= 0) + { + continue; + } + + var frame = particle.frame; + var width = frame.width; + var height = frame.height; + var ox = width * 0.5; + var oy = height * 0.5; + var cd = frame.canvasData; + + var x = -ox; + var y = -oy; + + var tx = particle.x - cameraScrollX * particle.scrollFactorX; + var ty = particle.y - cameraScrollY * particle.scrollFactorY; + + if (roundPixels) + { + tx |= 0; + ty |= 0; + } + + ctx.globalAlpha = alpha; + + ctx.save(); + + ctx.translate(tx, ty); + + ctx.rotate(particle.rotation); + + ctx.scale(particle.scaleX, particle.scaleY); + + ctx.drawImage(frame.source.image, cd.sx, cd.sy, cd.sWidth, cd.sHeight, x, y, cd.dWidth, cd.dHeight); + + ctx.restore(); + } + + ctx.globalAlpha = lastAlpha; + } +}; + +module.exports = ParticleManagerCanvasRenderer; + + +/***/ }), +/* 713 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Particles.EmitterManager#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Particles} emitterManager - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var ParticleManagerWebGLRenderer = function (renderer, emitterManager, interpolationPercentage, camera) +{ + var emitters = emitterManager.emitters; + + if (emitters.length === 0 || GameObject.RENDER_MASK !== emitterManager.renderFlags || (emitterManager.cameraFilter > 0 && (emitterManager.cameraFilter & camera._id))) + { + return; + } + + this.pipeline.drawEmitterManager(emitterManager, camera); +}; + +module.exports = ParticleManagerWebGLRenderer; + + +/***/ }), +/* 714 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); + +if (true) +{ + renderWebGL = __webpack_require__(713); +} + +if (true) +{ + renderCanvas = __webpack_require__(712); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 715 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Vector2 = __webpack_require__(6); + +/** + * @classdesc + * [description] + * + * @class RandomZone + * @memberOf Phaser.GameObjects.Particles.Zones + * @constructor + * @since 3.0.0 + * + * @param {object} source - [description] + */ +var RandomZone = new Class({ + + initialize: + + function RandomZone (source) + { + /** + * [description] + * + * @name Phaser.GameObjects.Particles.Zones.RandomZone#source + * @type {object} + * @since 3.0.0 + */ + this.source = source; + + /** + * Internal calculation vector. + * + * @name Phaser.GameObjects.Particles.Zones.RandomZone#_tempVec + * @type {Phaser.Math.Vector2} + * @private + * @since 3.0.0 + */ + this._tempVec = new Vector2(); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.Zones.RandomZone#getPoint + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - [description] + */ + getPoint: function (particle) + { + var vec = this._tempVec; + + this.source.getRandomPoint(vec); + + particle.x = vec.x; + particle.y = vec.y; + } + +}); + +module.exports = RandomZone; + + +/***/ }), +/* 716 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var DegToRad = __webpack_require__(42); +var DistanceBetween = __webpack_require__(48); /** * @classdesc @@ -101917,5658 +105674,9 @@ var Particle = new Class({ module.exports = Particle; -/***/ }), -/* 612 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * [description] - * - * @class RandomZone - * @memberOf Phaser.GameObjects.Particles.Zones - * @constructor - * @since 3.0.0 - * - * @param {object} source - [description] - */ -var RandomZone = new Class({ - - initialize: - - function RandomZone (source) - { - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.RandomZone#source - * @type {object} - * @since 3.0.0 - */ - this.source = source; - - /** - * Internal calculation vector. - * - * @name Phaser.GameObjects.Particles.Zones.RandomZone#_tempVec - * @type {Phaser.Math.Vector2} - * @private - * @since 3.0.0 - */ - this._tempVec = new Vector2(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.Zones.RandomZone#getPoint - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - */ - getPoint: function (particle) - { - var vec = this._tempVec; - - this.source.getRandomPoint(vec); - - particle.x = vec.x; - particle.y = vec.y; - } - -}); - -module.exports = RandomZone; - - -/***/ }), -/* 613 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(614); -} - -if (true) -{ - renderCanvas = __webpack_require__(615); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 614 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Particles.EmitterManager#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Particles} emitterManager - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var ParticleManagerWebGLRenderer = function (renderer, emitterManager, interpolationPercentage, camera) -{ - var emitters = emitterManager.emitters; - - if (emitters.length === 0 || GameObject.RENDER_MASK !== emitterManager.renderFlags || (emitterManager.cameraFilter > 0 && (emitterManager.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.drawEmitterManager(emitterManager, camera); -}; - -module.exports = ParticleManagerWebGLRenderer; - - -/***/ }), -/* 615 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Particles.EmitterManager#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Particles} emitterManager - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpolationPercentage, camera) -{ - var emitters = emitterManager.emitters.list; - - if (emitters.length === 0 || GameObject.RENDER_MASK !== emitterManager.renderFlags || (emitterManager.cameraFilter > 0 && (emitterManager.cameraFilter & camera._id))) - { - return; - } - - for (var i = 0; i < emitters.length; i++) - { - var emitter = emitters[i]; - - var particles = emitter.alive; - var length = particles.length; - - if (!emitter.visible || length === 0) - { - continue; - } - - var ctx = renderer.currentContext; - - var lastAlpha = ctx.globalAlpha; - var cameraScrollX = camera.scrollX * emitter.scrollFactorX; - var cameraScrollY = camera.scrollY * emitter.scrollFactorY; - - if (renderer.currentBlendMode !== emitter.blendMode) - { - renderer.currentBlendMode = emitter.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[emitter.blendMode]; - } - - var roundPixels = renderer.config.roundPixels; - - for (var index = 0; index < length; ++index) - { - var particle = particles[index]; - - var alpha = ((particle.color >> 24) & 0xFF) / 255.0; - - if (alpha <= 0) - { - continue; - } - - var frame = particle.frame; - var width = frame.width; - var height = frame.height; - var ox = width * 0.5; - var oy = height * 0.5; - var cd = frame.canvasData; - - var x = -ox; - var y = -oy; - - var tx = particle.x - cameraScrollX * particle.scrollFactorX; - var ty = particle.y - cameraScrollY * particle.scrollFactorY; - - if (roundPixels) - { - tx |= 0; - ty |= 0; - } - - ctx.globalAlpha = alpha; - - ctx.save(); - - ctx.translate(tx, ty); - - ctx.rotate(particle.rotation); - - ctx.scale(particle.scaleX, particle.scaleY); - - ctx.drawImage(frame.source.image, cd.sx, cd.sy, cd.sWidth, cd.sHeight, x, y, cd.dWidth, cd.dHeight); - - ctx.restore(); - } - - ctx.globalAlpha = lastAlpha; - } -}; - -module.exports = ParticleManagerCanvasRenderer; - - -/***/ }), -/* 616 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(617); -} - -if (true) -{ - renderCanvas = __webpack_require__(618); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 617 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.RenderTexture#renderWebgl - * @since 3.2.0 - * @private - * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.RenderTexture} renderTexture - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var RenderTextureWebGLRenderer = function (renderer, renderTexture, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== renderTexture.renderFlags || (renderTexture.cameraFilter > 0 && (renderTexture.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.batchTexture( - renderTexture, - renderTexture.texture, - renderTexture.texture.width, renderTexture.texture.height, - renderTexture.x, renderTexture.y, - renderTexture.width, renderTexture.height, - renderTexture.scaleX, renderTexture.scaleY, - renderTexture.rotation, - renderTexture.flipX, renderTexture.flipY, - renderTexture.scrollFactorX, renderTexture.scrollFactorY, - renderTexture.displayOriginX, renderTexture.displayOriginY, - 0, 0, renderTexture.texture.width, renderTexture.texture.height, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0, 0, - camera - ); -}; - -module.exports = RenderTextureWebGLRenderer; - - -/***/ }), -/* 618 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.RenderTexture#renderCanvas - * @since 3.2.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.RenderTexture} renderTexture - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var RenderTextureCanvasRenderer = function (renderer, renderTexture, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== renderTexture.renderFlags || (renderTexture.cameraFilter > 0 && (renderTexture.cameraFilter & camera._id))) - { - return; - } - - var ctx = renderer.currentContext; - - if (renderer.currentBlendMode !== renderTexture.blendMode) - { - renderer.currentBlendMode = renderTexture.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[renderTexture.blendMode]; - } - - if (renderer.currentAlpha !== renderTexture.alpha) - { - renderer.currentAlpha = renderTexture.alpha; - ctx.globalAlpha = renderTexture.alpha; - } - - if (renderer.currentScaleMode !== renderTexture.scaleMode) - { - renderer.currentScaleMode = renderTexture.scaleMode; - } - - var dx = 0; - var dy = 0; - - var fx = 1; - var fy = 1; - - if (renderTexture.flipX) - { - fx = -1; - dx -= renderTexture.canvas.width - renderTexture.displayOriginX; - } - else - { - dx -= renderTexture.displayOriginX; - } - - if (renderTexture.flipY) - { - fy = -1; - dy -= renderTexture.canvas.height - renderTexture.displayOriginY; - } - else - { - dy -= renderTexture.displayOriginY; - } - - ctx.save(); - ctx.translate(renderTexture.x - camera.scrollX * renderTexture.scrollFactorX, renderTexture.y - camera.scrollY * renderTexture.scrollFactorY); - ctx.rotate(renderTexture.rotation); - ctx.scale(renderTexture.scaleX, renderTexture.scaleY); - ctx.scale(fx, fy); - ctx.drawImage(renderTexture.canvas, dx, dy); - ctx.restore(); -}; - -module.exports = RenderTextureCanvasRenderer; - - -/***/ }), -/* 619 */ -/***/ (function(module, exports) { - -var RenderTextureCanvas = { - - fill: function (rgb) - { - var ur = ((rgb >> 16)|0) & 0xff; - var ug = ((rgb >> 8)|0) & 0xff; - var ub = (rgb|0) & 0xff; - - this.context.fillStyle = 'rgb(' + ur + ',' + ug + ',' + ub + ')'; - this.context.fillRect(0, 0, this.canvas.width, this.canvas.height); - return this; - }, - - clear: function () - { - this.context.save(); - this.context.setTransform(1, 0, 0, 1, 0, 0); - this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); - this.context.restore(); - return this; - }, - - draw: function (texture, frame, x, y) - { - var matrix = this.currentMatrix; - - this.context.globalAlpha = this.globalAlpha; - this.context.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - this.context.drawImage(texture.source[frame.sourceIndex].image, frame.cutX, frame.cutY, frame.cutWidth, frame.cutHeight, x, y, frame.cutWidth, frame.cutWidth); - - return this; - } - -}; - -module.exports = RenderTextureCanvas; - - -/***/ }), -/* 620 */ -/***/ (function(module, exports) { - -var RenderTextureWebGL = { - - fill: function (rgb) - { - var ur = ((rgb >> 16)|0) & 0xff; - var ug = ((rgb >> 8)|0) & 0xff; - var ub = (rgb|0) & 0xff; - - this.renderer.setFramebuffer(this.framebuffer); - var gl = this.gl; - gl.clearColor(ur / 255.0, ug / 255.0, ub / 255.0, 1); - gl.clear(gl.COLOR_BUFFER_BIT); - this.renderer.setFramebuffer(null); - return this; - }, - - clear: function () - { - this.renderer.setFramebuffer(this.framebuffer); - var gl = this.gl; - gl.clearColor(0, 0, 0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); - this.renderer.setFramebuffer(null); - return this; - }, - - draw: function (texture, frame, x, y) - { - var glTexture = texture.source[frame.sourceIndex].glTexture; - var tint = (this.globalTint >> 16) + (this.globalTint & 0xff00) + ((this.globalTint & 0xff) << 16); - this.renderer.setFramebuffer(this.framebuffer); - this.renderer.pipelines.TextureTintPipeline.drawTexture(glTexture, x, y, tint, this.globalAlpha, frame.cutX, frame.cutY, frame.cutWidth, frame.cutHeight, this.currentMatrix); - this.renderer.setFramebuffer(null); - return this; - } - -}; - -module.exports = RenderTextureWebGL; - - -/***/ }), -/* 621 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns an object containing dimensions of the Text object. - */ - -var GetTextSize = function (text, size, lines) -{ - var canvas = text.canvas; - var context = text.context; - var style = text.style; - - var lineWidths = []; - var maxLineWidth = 0; - var drawnLines = lines.length; - - if (style.maxLines > 0 && style.maxLines < lines.length) - { - drawnLines = style.maxLines; - } - - style.syncFont(canvas, context); - - // Text Width - - for (var i = 0; i < drawnLines; i++) - { - var lineWidth = style.strokeThickness; - - lineWidth += context.measureText(lines[i]).width; - - // Adjust for wrapped text - if (style.wordWrap) - { - lineWidth -= context.measureText(' ').width; - } - - lineWidths[i] = Math.ceil(lineWidth); - maxLineWidth = Math.max(maxLineWidth, lineWidths[i]); - } - - // Text Height - - var lineHeight = size.fontSize + style.strokeThickness; - var height = lineHeight * drawnLines; - var lineSpacing = text._lineSpacing || 0; - - if (lineSpacing < 0 && Math.abs(lineSpacing) > lineHeight) - { - lineSpacing = -lineHeight; - } - - // Adjust for line spacing - if (lineSpacing !== 0) - { - height += (lineSpacing > 0) ? lineSpacing * lines.length : lineSpacing * (lines.length - 1); - } - - return { - width: maxLineWidth, - height: height, - lines: drawnLines, - lineWidths: lineWidths, - lineSpacing: lineSpacing, - lineHeight: lineHeight - }; -}; - -module.exports = GetTextSize; - - -/***/ }), -/* 622 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(623); -} - -if (true) -{ - renderCanvas = __webpack_require__(624); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 623 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Text#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Text} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var TextWebGLRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)) || src.text === '') - { - return; - } - - if (src.dirty) - { - src.canvasTexture = renderer.canvasToTexture(src.canvas, src.canvasTexture, true, src.scaleMode); - src.dirty = false; - } - - this.pipeline.batchText(this, camera); -}; - -module.exports = TextWebGLRenderer; - - -/***/ }), -/* 624 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Text#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Text} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var TextCanvasRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)) || src.text === '') - { - return; - } - - var ctx = renderer.currentContext; - - // var resolution = src.resolution; - - // Blend Mode - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - var canvas = src.canvas; - - ctx.save(); - - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - - if (renderer.config.roundPixels) - { - tx |= 0; - ty |= 0; - } - - ctx.translate(tx, ty); - - ctx.rotate(src.rotation); - - ctx.scale(src.scaleX, src.scaleY); - - ctx.translate(canvas.width * (src.flipX ? 1 : 0), canvas.height * (src.flipY ? 1 : 0)); - - ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); - - ctx.drawImage(canvas, 0, 0, canvas.width, canvas.height, -src.displayOriginX, -src.displayOriginY, canvas.width, canvas.height); - - ctx.restore(); -}; - -module.exports = TextCanvasRenderer; - - -/***/ }), -/* 625 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GetAdvancedValue = __webpack_require__(10); -var GetValue = __webpack_require__(4); -var MeasureText = __webpack_require__(626); - -// Key: [ Object Key, Default Value ] - -var propertyMap = { - fontFamily: [ 'fontFamily', 'Courier' ], - fontSize: [ 'fontSize', '16px' ], - fontStyle: [ 'fontStyle', '' ], - backgroundColor: [ 'backgroundColor', null ], - color: [ 'color', '#fff' ], - stroke: [ 'stroke', '#fff' ], - strokeThickness: [ 'strokeThickness', 0 ], - shadowOffsetX: [ 'shadow.offsetX', 0 ], - shadowOffsetY: [ 'shadow.offsetY', 0 ], - shadowColor: [ 'shadow.color', '#000' ], - shadowBlur: [ 'shadow.blur', 0 ], - shadowStroke: [ 'shadow.stroke', false ], - shadowFill: [ 'shadow.fill', false ], - align: [ 'align', 'left' ], - maxLines: [ 'maxLines', 0 ], - fixedWidth: [ 'fixedWidth', 0 ], - fixedHeight: [ 'fixedHeight', 0 ], - rtl: [ 'rtl', false ], - testString: [ 'testString', '|MÉqgy' ], - wordWrapWidth: [ 'wordWrap.width', null ], - wordWrapCallback: [ 'wordWrap.callback', null ], - wordWrapCallbackScope: [ 'wordWrap.callbackScope', null ], - wordWrapUseAdvanced: [ 'wordWrap.useAdvancedWrap', false ] -}; - -/** - * @classdesc - * [description] - * - * @class TextStyle - * @memberOf Phaser.GameObjects.Components - * @constructor - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Text} text - The Text object that this TextStyle is styling. - * @param {object} style - [description] - */ -var TextStyle = new Class({ - - initialize: - - function TextStyle (text, style) - { - /** - * The Text object that this TextStyle is styling. - * - * @name Phaser.GameObjects.Components.TextStyle#parent - * @type {Phaser.GameObjects.Text} - * @since 3.0.0 - */ - this.parent = text; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#fontFamily - * @type {string} - * @default 'Courier' - * @since 3.0.0 - */ - this.fontFamily; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#fontSize - * @type {string} - * @default '16px' - * @since 3.0.0 - */ - this.fontSize; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#fontStyle - * @type {string} - * @since 3.0.0 - */ - this.fontStyle; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#backgroundColor - * @type {string} - * @since 3.0.0 - */ - this.backgroundColor; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#color - * @type {string} - * @default '#fff' - * @since 3.0.0 - */ - this.color; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#stroke - * @type {string} - * @default '#fff' - * @since 3.0.0 - */ - this.stroke; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#strokeThickness - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.strokeThickness; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#shadowOffsetX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.shadowOffsetX; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#shadowOffsetY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.shadowOffsetY; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#shadowColor - * @type {string} - * @default '#000' - * @since 3.0.0 - */ - this.shadowColor; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#shadowBlur - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.shadowBlur; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#shadowStroke - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.shadowStroke; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#shadowFill - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.shadowFill; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#align - * @type {string} - * @default 'left' - * @since 3.0.0 - */ - this.align; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#maxLines - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.maxLines; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#fixedWidth - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.fixedWidth; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#fixedHeight - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.fixedHeight; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#rtl - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.rtl; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#testString - * @type {string} - * @default '|MÉqgy' - * @since 3.0.0 - */ - this.testString; - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TextStyle#_font - * @type {string} - * @private - * @since 3.0.0 - */ - this._font; - - // Set to defaults + user style - this.setStyle(style, false); - - var metrics = GetValue(style, 'metrics', false); - - // Provide optional TextMetrics in the style object to avoid the canvas look-up / scanning - // Doing this is reset if you then change the font of this TextStyle after creation - if (metrics) - { - this.metrics = { - ascent: GetValue(metrics, 'ascent', 0), - descent: GetValue(metrics, 'descent', 0), - fontSize: GetValue(metrics, 'fontSize', 0) - }; - } - else - { - this.metrics = MeasureText(this); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setStyle - * @since 3.0.0 - * - * @param {[type]} style - [description] - * @param {boolean} [updateText=true] - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setStyle: function (style, updateText) - { - if (updateText === undefined) { updateText = true; } - - // Avoid type mutation - if (style && style.hasOwnProperty('fontSize') && typeof style.fontSize === 'number') - { - style.fontSize = style.fontSize.toString() + 'px'; - } - - for (var key in propertyMap) - { - if (key === 'wordWrapCallback' || key === 'wordWrapCallbackScope') - { - // Callback & scope should be set without processing the values - this[key] = GetValue(style, propertyMap[key][0], propertyMap[key][1]); - } - else - { - this[key] = GetAdvancedValue(style, propertyMap[key][0], propertyMap[key][1]); - } - } - - // Allow for 'font' override - var font = GetValue(style, 'font', null); - - if (font === null) - { - this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' '); - } - else - { - this._font = font; - } - - // Allow for 'fill' to be used in place of 'color' - var fill = GetValue(style, 'fill', null); - - if (fill !== null) - { - this.color = fill; - } - - if (updateText) - { - return this.update(true); - } - else - { - return this.parent; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#syncFont - * @since 3.0.0 - * - * @param {[type]} canvas - [description] - * @param {[type]} context - [description] - */ - syncFont: function (canvas, context) - { - context.font = this._font; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#syncStyle - * @since 3.0.0 - * - * @param {[type]} canvas - [description] - * @param {[type]} context - [description] - */ - syncStyle: function (canvas, context) - { - context.textBaseline = 'alphabetic'; - - context.fillStyle = this.color; - context.strokeStyle = this.stroke; - - context.lineWidth = this.strokeThickness; - context.lineCap = 'round'; - context.lineJoin = 'round'; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#syncShadow - * @since 3.0.0 - * - * @param {[type]} context - [description] - * @param {[type]} enabled - [description] - */ - syncShadow: function (context, enabled) - { - if (enabled) - { - context.shadowOffsetX = this.shadowOffsetX; - context.shadowOffsetY = this.shadowOffsetY; - context.shadowColor = this.shadowColor; - context.shadowBlur = this.shadowBlur; - } - else - { - context.shadowOffsetX = 0; - context.shadowOffsetY = 0; - context.shadowColor = 0; - context.shadowBlur = 0; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#update - * @since 3.0.0 - * - * @param {boolean} recalculateMetrics - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - update: function (recalculateMetrics) - { - if (recalculateMetrics) - { - this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' '); - - this.metrics = MeasureText(this); - } - - return this.parent.updateText(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setFont - * @since 3.0.0 - * - * @param {string|object} font - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setFont: function (font) - { - if (typeof font === 'string') - { - this.fontFamily = font; - this.fontSize = ''; - this.fontStyle = ''; - } - else - { - this.fontFamily = GetValue(font, 'fontFamily', 'Courier'); - this.fontSize = GetValue(font, 'fontSize', '16px'); - this.fontStyle = GetValue(font, 'fontStyle', ''); - } - - return this.update(true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setFontFamily - * @since 3.0.0 - * - * @param {[type]} family - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setFontFamily: function (family) - { - this.fontFamily = family; - - return this.update(true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setFontStyle - * @since 3.0.0 - * - * @param {[type]} style - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setFontStyle: function (style) - { - this.fontStyle = style; - - return this.update(true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setFontSize - * @since 3.0.0 - * - * @param {[type]} size - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setFontSize: function (size) - { - if (typeof size === 'number') - { - size = size.toString() + 'px'; - } - - this.fontSize = size; - - return this.update(true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setTestString - * @since 3.0.0 - * - * @param {[type]} string - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setTestString: function (string) - { - this.testString = string; - - return this.update(true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setFixedSize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setFixedSize: function (width, height) - { - this.fixedWidth = width; - this.fixedHeight = height; - - if (width) - { - this.parent.width = width; - } - - if (height) - { - this.parent.height = height; - } - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setBackgroundColor - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setBackgroundColor: function (color) - { - this.backgroundColor = color; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setFill - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setFill: function (color) - { - this.color = color; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setColor - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setColor: function (color) - { - this.color = color; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setStroke - * @since 3.0.0 - * - * @param {string} color - [description] - * @param {number} thickness - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setStroke: function (color, thickness) - { - if (color === undefined) - { - // Reset the stroke to zero (disabling it) - this.strokeThickness = 0; - } - else - { - if (thickness === undefined) { thickness = this.strokeThickness; } - - this.stroke = color; - this.strokeThickness = thickness; - } - - return this.update(true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setShadow - * @since 3.0.0 - * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] - * @param {string} [color='#000'] - [description] - * @param {number} [blur=0] - [description] - * @param {boolean} [shadowStroke=false] - [description] - * @param {boolean} [shadowFill=true] - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setShadow: function (x, y, color, blur, shadowStroke, shadowFill) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (color === undefined) { color = '#000'; } - if (blur === undefined) { blur = 0; } - if (shadowStroke === undefined) { shadowStroke = false; } - if (shadowFill === undefined) { shadowFill = true; } - - this.shadowOffsetX = x; - this.shadowOffsetY = y; - this.shadowColor = color; - this.shadowBlur = blur; - this.shadowStroke = shadowStroke; - this.shadowFill = shadowFill; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setShadowOffset - * @since 3.0.0 - * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setShadowOffset: function (x, y) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = x; } - - this.shadowOffsetX = x; - this.shadowOffsetY = y; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setShadowColor - * @since 3.0.0 - * - * @param {string} [color='#000'] - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setShadowColor: function (color) - { - if (color === undefined) { color = '#000'; } - - this.shadowColor = color; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setShadowBlur - * @since 3.0.0 - * - * @param {number} [blur=0] - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setShadowBlur: function (blur) - { - if (blur === undefined) { blur = 0; } - - this.shadowBlur = blur; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setShadowStroke - * @since 3.0.0 - * - * @param {boolean} enabled - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setShadowStroke: function (enabled) - { - this.shadowStroke = enabled; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setShadowFill - * @since 3.0.0 - * - * @param {boolean} enabled - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setShadowFill: function (enabled) - { - this.shadowFill = enabled; - - return this.update(false); - }, - - /** - * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width. - * - * @method Phaser.GameObjects.Components.TextStyle#setWordWrapWidth - * @since 3.0.0 - * - * @param {number} width - The maximum width of a line in pixels. Set to null to remove wrapping. - * @param {boolean} [useAdvancedWrap=false] - Whether or not to use the advanced wrapping - * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, - * spaces and whitespace are left as is. - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setWordWrapWidth: function (width, useAdvancedWrap) - { - if (useAdvancedWrap === undefined) { useAdvancedWrap = false; } - - this.wordWrapWidth = width; - this.wordWrapUseAdvanced = useAdvancedWrap; - - return this.update(false); - }, - - /** - * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback. - * - * @method Phaser.GameObjects.Components.TextStyle#setWordWrapCallback - * @since 3.0.0 - * - * @param {function} callback - A custom function that will be responsible for wrapping the - * text. It will receive two arguments: text (the string to wrap), textObject (this Text - * instance). It should return the wrapped lines either as an array of lines or as a string with - * newline characters in place to indicate where breaks should happen. - * @param {object} [scope=null] - The scope that will be applied when the callback is invoked. - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setWordWrapCallback: function (callback, scope) - { - if (scope === undefined) { scope = null; } - - this.wordWrapCallback = callback; - this.wordWrapCallbackScope = scope; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setAlign - * @since 3.0.0 - * - * @param {string} align - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setAlign: function (align) - { - if (align === undefined) { align = 'left'; } - - this.align = align; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#setMaxLines - * @since 3.0.0 - * - * @param {integer} [max=0] - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setMaxLines: function (max) - { - if (max === undefined) { max = 0; } - - this.maxLines = max; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#getTextMetrics - * @since 3.0.0 - * - * @return {object} [description] - */ - getTextMetrics: function () - { - var metrics = this.metrics; - - return { - ascent: metrics.ascent, - descent: metrics.descent, - fontSize: metrics.fontSize - }; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - var output = {}; - - for (var key in propertyMap) - { - output[key] = this[key]; - } - - output.metrics = this.getTextMetrics(); - - return output; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TextStyle#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.parent = undefined; - } - -}); - -module.exports = TextStyle; - - -/***/ }), -/* 626 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CanvasPool = __webpack_require__(21); - -/** - * Calculates the ascent, descent and fontSize of a given font style. - */ - -var MeasureText = function (textStyle) -{ - // @property {HTMLCanvasElement} canvas - The canvas element that the text is rendered. - var canvas = CanvasPool.create(this); - - // @property {HTMLCanvasElement} context - The context of the canvas element that the text is rendered to. - var context = canvas.getContext('2d'); - - textStyle.syncFont(canvas, context); - - var width = Math.ceil(context.measureText(textStyle.testString).width * 1.2); - var baseline = width; - var height = 2 * baseline; - - baseline = baseline * 1.4 | 0; - - canvas.width = width; - canvas.height = height; - - context.fillStyle = '#f00'; - context.fillRect(0, 0, width, height); - - context.font = textStyle._font; - - context.textBaseline = 'alphabetic'; - context.fillStyle = '#000'; - context.fillText(textStyle.testString, 0, baseline); - - var output = { - ascent: 0, - descent: 0, - fontSize: 0 - }; - - if (!context.getImageData(0, 0, width, height)) - { - output.ascent = baseline; - output.descent = baseline + 6; - output.fontSize = output.ascent + output.descent; - - CanvasPool.remove(canvas); - - return output; - } - - var imagedata = context.getImageData(0, 0, width, height).data; - var pixels = imagedata.length; - var line = width * 4; - var i; - var j; - var idx = 0; - var stop = false; - - // ascent. scan from top to bottom until we find a non red pixel - for (i = 0; i < baseline; i++) - { - for (j = 0; j < line; j += 4) - { - if (imagedata[idx + j] !== 255) - { - stop = true; - break; - } - } - - if (!stop) - { - idx += line; - } - else - { - break; - } - } - - output.ascent = baseline - i; - - idx = pixels - line; - stop = false; - - // descent. scan from bottom to top until we find a non red pixel - for (i = height; i > baseline; i--) - { - for (j = 0; j < line; j += 4) - { - if (imagedata[idx + j] !== 255) - { - stop = true; - break; - } - } - - if (!stop) - { - idx -= line; - } - else - { - break; - } - } - - output.descent = (i - baseline); - output.fontSize = output.ascent + output.descent; - - CanvasPool.remove(canvas); - - return output; -}; - -module.exports = MeasureText; - - -/***/ }), -/* 627 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(628); -} - -if (true) -{ - renderCanvas = __webpack_require__(629); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 628 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.TileSprite#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.TileSprite} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var TileSpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - src.updateTileTexture(); - - this.pipeline.batchTileSprite(this, camera); -}; - -module.exports = TileSpriteWebGLRenderer; - - -/***/ }), -/* 629 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.TileSprite#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.TileSprite} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - var ctx = renderer.currentContext; - var frame = src.frame; - - src.updateTileTexture(); - - // Blend Mode - - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Alpha - - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - var dx = frame.x - (src.originX * src.width); - var dy = frame.y - (src.originY * src.height); - - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - - var fx = 1; - var fy = 1; - - // Flipping - - if (src.flipX) - { - fx = -1; - dx += src.width; - } - - if (src.flipY) - { - fy = -1; - dy += src.height; - } - - if (renderer.config.roundPixels) - { - dx |= 0; - dy |= 0; - tx |= 0; - ty |= 0; - } - - ctx.save(); - - ctx.translate(dx, dy); - - ctx.translate(tx, ty); - - // Flip - ctx.scale(fx, fy); - - // Rotate and scale around center - ctx.translate((src.originX * src.width), (src.originY * src.height)); - ctx.rotate(fx * fy * src.rotation); - ctx.scale(this.scaleX, this.scaleY); - ctx.translate(-(src.originX * src.width), -(src.originY * src.height)); - - // Draw - ctx.translate(-this.tilePositionX, -this.tilePositionY); - ctx.fillStyle = src.canvasPattern; - ctx.fillRect(this.tilePositionX, this.tilePositionY, src.width, src.height); - - ctx.restore(); -}; - -module.exports = TileSpriteCanvasRenderer; - - -/***/ }), -/* 630 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Blitter = __webpack_require__(134); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new Blitter Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Blitter Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#blitter - * @since 3.0.0 - * - * @param {number} x - The x position of the Game Object. - * @param {number} y - The y position of the Game Object. - * @param {string} key - The key of the Texture the Blitter object will use. - * @param {string|integer} [frame] - The default Frame children of the Blitter will use. - * - * @return {Phaser.GameObjects.Blitter} The Game Object that was created. - */ -GameObjectFactory.register('blitter', function (x, y, key, frame) -{ - return this.displayList.add(new Blitter(this.scene, x, y, key, frame)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 631 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var DynamicBitmapText = __webpack_require__(135); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new Dynamic Bitmap Text Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#dynamicBitmapText - * @since 3.0.0 - * - * @param {number} x - The x position of the Game Object. - * @param {number} y - The y position of the Game Object. - * @param {string} font - [description] - * @param {string|string[]} [text] - [description] - * @param {number} [size] - [description] - * - * @return {Phaser.GameObjects.DynamicBitmapText} The Game Object that was created. - */ -GameObjectFactory.register('dynamicBitmapText', function (x, y, font, text, size) -{ - return this.displayList.add(new DynamicBitmapText(this.scene, x, y, font, text, size)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 632 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Graphics = __webpack_require__(136); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new Graphics Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Graphics Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#graphics - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Graphics} The Game Object that was created. - */ -GameObjectFactory.register('graphics', function (config) -{ - return this.displayList.add(new Graphics(this.scene, config)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 633 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Group = __webpack_require__(69); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new Group Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Group Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#group - * @since 3.0.0 - * - * @param {array|object} children - [description] - * @param {object} [config] - [description] - * - * @return {Phaser.GameObjects.Group} The Game Object that was created. - */ -GameObjectFactory.register('group', function (children, config) -{ - if (typeof children === 'object' && config === undefined) - { - config = children; - children = []; - } - - return this.updateList.add(new Group(this.scene, children, config)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 634 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Image = __webpack_require__(70); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new Image Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Image Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#image - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.Image} The Game Object that was created. - */ -GameObjectFactory.register('image', function (x, y, key, frame) -{ - return this.displayList.add(new Image(this.scene, x, y, key, frame)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 635 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectFactory = __webpack_require__(9); -var ParticleEmitterManager = __webpack_require__(139); - -/** - * Creates a new Particle Emitter Manager Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Particles Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#particles - * @since 3.0.0 - * - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer|object} [frame] - [description] - * @param {object} [emitters] - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} The Game Object that was created. - */ -GameObjectFactory.register('particles', function (key, frame, emitters) -{ - var manager = new ParticleEmitterManager(this.scene, key, frame, emitters); - - this.displayList.add(manager); - this.updateList.add(manager); - - return manager; -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 636 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectFactory = __webpack_require__(9); -var PathFollower = __webpack_require__(290); - -/** - * Creates a new PathFollower Game Object and adds it to the Scene. - * - * Note: This method will only be available if the PathFollower Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#follower - * @since 3.0.0 - * - * @param {Phaser.Curves.Path} path - The Path this PathFollower is connected to. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.PathFollower} The Game Object that was created. - */ -GameObjectFactory.register('follower', function (path, x, y, key, frame) -{ - var sprite = new PathFollower(this.scene, path, x, y, key, frame); - - this.displayList.add(sprite); - this.updateList.add(sprite); - - return sprite; -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 637 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectFactory = __webpack_require__(9); -var RenderTexture = __webpack_require__(141); - -/** - * Creates a new Render Texture Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#renderTexture - * @since 3.2.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {integer} [width=32] - The width of the Render Texture. - * @param {integer} [height=32] - The height of the Render Texture. - * - * @return {Phaser.GameObjects.RenderTexture} The Game Object that was created. - */ -GameObjectFactory.register('renderTexture', function (x, y, width, height) -{ - return this.displayList.add(new RenderTexture(this.scene, x, y, width, height)); -}); - - -/***/ }), -/* 638 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Sprite3D = __webpack_require__(81); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new Sprite3D Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Sprite3D Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#sprite3D - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object. - * @param {number} y - The vertical position of this Game Object. - * @param {number} z - The z position of this Game Object. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.Sprite3D} The Game Object that was created. - */ -GameObjectFactory.register('sprite3D', function (x, y, z, key, frame) -{ - var sprite = new Sprite3D(this.scene, x, y, z, key, frame); - - this.displayList.add(sprite.gameObject); - this.updateList.add(sprite.gameObject); - - return sprite; -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 639 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectFactory = __webpack_require__(9); -var Sprite = __webpack_require__(37); - -/** - * Creates a new Sprite Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Sprite Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#sprite - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.Sprite} The Game Object that was created. - */ -GameObjectFactory.register('sprite', function (x, y, key, frame) -{ - var sprite = new Sprite(this.scene, x, y, key, frame); - - this.displayList.add(sprite); - this.updateList.add(sprite); - - return sprite; -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 640 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BitmapText = __webpack_require__(133); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new Bitmap Text Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#bitmapText - * @since 3.0.0 - * - * @param {number} x - The x position of the Game Object. - * @param {number} y - The y position of the Game Object. - * @param {string} font - [description] - * @param {string|string[]} [text] - [description] - * @param {number} [size] - [description] - * - * @return {Phaser.GameObjects.BitmapText} The Game Object that was created. - */ -GameObjectFactory.register('bitmapText', function (x, y, font, text, size) -{ - return this.displayList.add(new BitmapText(this.scene, x, y, font, text, size)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 641 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Text = __webpack_require__(142); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new Text Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Text Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#text - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string|string[]} text - The text this Text object will display. - * @param {object} [style] - The Text style configuration object. - * - * @return {Phaser.GameObjects.Text} The Game Object that was created. - */ -GameObjectFactory.register('text', function (x, y, text, style) -{ - return this.displayList.add(new Text(this.scene, x, y, text, style)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 642 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var TileSprite = __webpack_require__(143); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new TileSprite Game Object and adds it to the Scene. - * - * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#tileSprite - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {number} width - The width of the Game Object. - * @param {number} height - The height of the Game Object. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.TileSprite} The Game Object that was created. - */ -GameObjectFactory.register('tileSprite', function (x, y, width, height, key, frame) -{ - return this.displayList.add(new TileSprite(this.scene, x, y, width, height, key, frame)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 643 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Zone = __webpack_require__(77); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new Zone Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Zone Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#zone - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {number} width - The width of the Game Object. - * @param {number} height - The height of the Game Object. - * - * @return {Phaser.GameObjects.Zone} The Game Object that was created. - */ -GameObjectFactory.register('zone', function (x, y, width, height) -{ - return this.displayList.add(new Zone(this.scene, x, y, width, height)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 644 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Blitter = __webpack_require__(134); -var BuildGameObject = __webpack_require__(20); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); - -/** - * Creates a new Blitter Game Object and returns it. - * - * Note: This method will only be available if the Blitter Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#blitter - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Blitter} The Game Object that was created. - */ -GameObjectCreator.register('blitter', function (config) -{ - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - - var blitter = new Blitter(this.scene, 0, 0, key, frame); - - BuildGameObject(this.scene, blitter, config); - - return blitter; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 645 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BitmapText = __webpack_require__(135); -var BuildGameObject = __webpack_require__(20); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); - -/** - * Creates a new Dynamic Bitmap Text Game Object and returns it. - * - * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#dynamicBitmapText - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.DynamicBitmapText} The Game Object that was created. - */ -GameObjectCreator.register('dynamicBitmapText', function (config) -{ - var font = GetAdvancedValue(config, 'font', ''); - var text = GetAdvancedValue(config, 'text', ''); - var size = GetAdvancedValue(config, 'size', false); - var align = GetAdvancedValue(config, 'align', 'left'); - - var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size, align); - - BuildGameObject(this.scene, bitmapText, config); - - return bitmapText; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 646 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectCreator = __webpack_require__(13); -var Graphics = __webpack_require__(136); - -/** - * Creates a new Graphics Game Object and returns it. - * - * Note: This method will only be available if the Graphics Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#graphics - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Graphics} The Game Object that was created. - */ -GameObjectCreator.register('graphics', function (config) -{ - return new Graphics(this.scene, config); -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 647 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectCreator = __webpack_require__(13); -var Group = __webpack_require__(69); - -/** - * Creates a new Group Game Object and returns it. - * - * Note: This method will only be available if the Group Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#group - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Group} The Game Object that was created. - */ -GameObjectCreator.register('group', function (config) -{ - return new Group(this.scene, null, config); -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 648 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(20); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Image = __webpack_require__(70); - -/** - * Creates a new Image Game Object and returns it. - * - * Note: This method will only be available if the Image Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#image - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Image} The Game Object that was created. - */ -GameObjectCreator.register('image', function (config) -{ - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - - var image = new Image(this.scene, 0, 0, key, frame); - - BuildGameObject(this.scene, image, config); - - return image; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 649 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var GetFastValue = __webpack_require__(2); -var ParticleEmitterManager = __webpack_require__(139); - -/** - * Creates a new Particle Emitter Manager Game Object and returns it. - * - * Note: This method will only be available if the Particles Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#particles - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} The Game Object that was created. - */ -GameObjectCreator.register('particles', function (config) -{ - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - var emitters = GetFastValue(config, 'emitters', null); - - // frame is optional and can contain the emitters array or object if skipped - var manager = new ParticleEmitterManager(this.scene, key, frame, emitters); - - var add = GetFastValue(config, 'add', false); - - if (add) - { - this.displayList.add(manager); - } - - this.updateList.add(manager); - - return manager; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 650 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(20); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var RenderTexture = __webpack_require__(141); - -/** - * Creates a new Render Texture Game Object and returns it. - * - * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#renderTexture - * @since 3.2.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.RenderTexture} The Game Object that was created. - */ -GameObjectCreator.register('renderTexture', function (config) -{ - var x = GetAdvancedValue(config, 'x', 0); - var y = GetAdvancedValue(config, 'y', 0); - var width = GetAdvancedValue(config, 'width', 32); - var height = GetAdvancedValue(config, 'height', 32); - var renderTexture = new RenderTexture(this.scene, x, y, width, height); - - BuildGameObject(this.scene, renderTexture, config); - - return renderTexture; -}); - - -/***/ }), -/* 651 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(20); -var BuildGameObjectAnimation = __webpack_require__(132); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Sprite3D = __webpack_require__(81); - -/** - * Creates a new Sprite3D Game Object and returns it. - * - * Note: This method will only be available if the Sprite3D Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#sprite3D - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Sprite3D} The Game Object that was created. - */ -GameObjectCreator.register('sprite3D', function (config) -{ - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - - var sprite = new Sprite3D(this.scene, 0, 0, key, frame); - - BuildGameObject(this.scene, sprite, config); - - // Sprite specific config options: - - BuildGameObjectAnimation(sprite, config); - - // Physics, Input, etc to follow ... - - return sprite; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 652 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(20); -var BuildGameObjectAnimation = __webpack_require__(132); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Sprite = __webpack_require__(37); - -/** - * Creates a new Sprite Game Object and returns it. - * - * Note: This method will only be available if the Sprite Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#sprite - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Sprite} The Game Object that was created. - */ -GameObjectCreator.register('sprite', function (config) -{ - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - - var sprite = new Sprite(this.scene, 0, 0, key, frame); - - BuildGameObject(this.scene, sprite, config); - - // Sprite specific config options: - - BuildGameObjectAnimation(sprite, config); - - // Physics, Input, etc to follow ... - - return sprite; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 653 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BitmapText = __webpack_require__(133); -var BuildGameObject = __webpack_require__(20); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var GetValue = __webpack_require__(4); - -/** - * Creates a new Bitmap Text Game Object and returns it. - * - * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#bitmapText - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.BitmapText} The Game Object that was created. - */ -GameObjectCreator.register('bitmapText', function (config) -{ - var font = GetValue(config, 'font', ''); - var text = GetAdvancedValue(config, 'text', ''); - var size = GetAdvancedValue(config, 'size', false); - - // var align = GetValue(config, 'align', 'left'); - - var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size); - - BuildGameObject(this.scene, bitmapText, config); - - return bitmapText; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 654 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(20); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Text = __webpack_require__(142); - -/** - * Creates a new Text Game Object and returns it. - * - * Note: This method will only be available if the Text Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#text - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Text} The Game Object that was created. - */ -GameObjectCreator.register('text', function (config) -{ - // style Object = { - // font: [ 'font', '16px Courier' ], - // backgroundColor: [ 'backgroundColor', null ], - // fill: [ 'fill', '#fff' ], - // stroke: [ 'stroke', '#fff' ], - // strokeThickness: [ 'strokeThickness', 0 ], - // shadowOffsetX: [ 'shadow.offsetX', 0 ], - // shadowOffsetY: [ 'shadow.offsetY', 0 ], - // shadowColor: [ 'shadow.color', '#000' ], - // shadowBlur: [ 'shadow.blur', 0 ], - // shadowStroke: [ 'shadow.stroke', false ], - // shadowFill: [ 'shadow.fill', false ], - // align: [ 'align', 'left' ], - // maxLines: [ 'maxLines', 0 ], - // fixedWidth: [ 'fixedWidth', false ], - // fixedHeight: [ 'fixedHeight', false ], - // rtl: [ 'rtl', false ] - // } - - var content = GetAdvancedValue(config, 'text', ''); - var style = GetAdvancedValue(config, 'style', null); - - // Padding - // { padding: 2 } - // { padding: { x: , y: }} - // { padding: { left: , top: }} - // { padding: { left: , right: , top: , bottom: }} - - var padding = GetAdvancedValue(config, 'padding', null); - - if (padding !== null) - { - style.padding = padding; - } - - var text = new Text(this.scene, 0, 0, content, style); - - BuildGameObject(this.scene, text, config); - - // Text specific config options: - - text.autoRound = GetAdvancedValue(config, 'autoRound', true); - text.resolution = GetAdvancedValue(config, 'resolution', 1); - - return text; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 655 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(20); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var TileSprite = __webpack_require__(143); - -/** - * Creates a new TileSprite Game Object and returns it. - * - * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#tileSprite - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.TileSprite} The Game Object that was created. - */ -GameObjectCreator.register('tileSprite', function (config) -{ - var x = GetAdvancedValue(config, 'x', 0); - var y = GetAdvancedValue(config, 'y', 0); - var width = GetAdvancedValue(config, 'width', 512); - var height = GetAdvancedValue(config, 'height', 512); - var key = GetAdvancedValue(config, 'key', ''); - var frame = GetAdvancedValue(config, 'frame', ''); - - var tile = new TileSprite(this.scene, x, y, width, height, key, frame); - - BuildGameObject(this.scene, tile, config); - - return tile; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 656 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Zone = __webpack_require__(77); - -/** - * Creates a new Zone Game Object and returns it. - * - * Note: This method will only be available if the Zone Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#zone - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Zone} The Game Object that was created. - */ -GameObjectCreator.register('zone', function (config) -{ - var x = GetAdvancedValue(config, 'x', 0); - var y = GetAdvancedValue(config, 'y', 0); - var width = GetAdvancedValue(config, 'width', 1); - var height = GetAdvancedValue(config, 'height', width); - - return new Zone(this.scene, x, y, width, height); -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 657 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(658); -} - -if (true) -{ - renderCanvas = __webpack_require__(659); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 658 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Mesh#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Mesh} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var MeshWebGLRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.batchMesh(src, camera); -}; - -module.exports = MeshWebGLRenderer; - - -/***/ }), -/* 659 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * This is a stub function for Mesh.Render. There is no Canvas renderer for Mesh objects. - * - * @method Phaser.GameObjects.Mesh#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Mesh} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var MeshCanvasRenderer = function () -{ -}; - -module.exports = MeshCanvasRenderer; - - -/***/ }), -/* 660 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Mesh = __webpack_require__(88); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new Mesh Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#mesh - * @webglOnly - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {array} vertices - An array containing the vertices data for this Mesh. - * @param {array} uv - An array containing the uv data for this Mesh. - * @param {array} colors - An array containing the color data for this Mesh. - * @param {array} alphas - An array containing the alpha data for this Mesh. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.Mesh} The Game Object that was created. - */ -if (true) -{ - GameObjectFactory.register('mesh', function (x, y, vertices, uv, colors, alphas, texture, frame) - { - return this.displayList.add(new Mesh(this.scene, x, y, vertices, uv, colors, alphas, texture, frame)); - }); -} - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 661 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Quad = __webpack_require__(144); -var GameObjectFactory = __webpack_require__(9); - -/** - * Creates a new Quad Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Quad Game Object and WebGL support have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#quad - * @webglOnly - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.Quad} The Game Object that was created. - */ -if (true) -{ - GameObjectFactory.register('quad', function (x, y, key, frame) - { - return this.displayList.add(new Quad(this.scene, x, y, key, frame)); - }); -} - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 662 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(20); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var GetValue = __webpack_require__(4); -var Mesh = __webpack_require__(88); - -/** - * Creates a new Mesh Game Object and returns it. - * - * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#mesh - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Mesh} The Game Object that was created. - */ -GameObjectCreator.register('mesh', function (config) -{ - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - var vertices = GetValue(config, 'vertices', []); - var colors = GetValue(config, 'colors', []); - var alphas = GetValue(config, 'alphas', []); - var uv = GetValue(config, 'uv', []); - - var mesh = new Mesh(this.scene, 0, 0, vertices, uv, colors, alphas, key, frame); - - BuildGameObject(this.scene, mesh, config); - - return mesh; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 663 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(20); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Quad = __webpack_require__(144); - -/** - * Creates a new Quad Game Object and returns it. - * - * Note: This method will only be available if the Quad Game Object and WebGL support have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#quad - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Quad} The Game Object that was created. - */ -GameObjectCreator.register('quad', function (config) -{ - var x = GetAdvancedValue(config, 'x', 0); - var y = GetAdvancedValue(config, 'y', 0); - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - - var quad = new Quad(this.scene, x, y, key, frame); - - BuildGameObject(this.scene, quad, config); - - return quad; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 664 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var LightsManager = __webpack_require__(293); -var PluginManager = __webpack_require__(12); - -/** - * @classdesc - * [description] - * - * @class LightsPlugin - * @extends Phaser.GameObjects.LightsManager - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var LightsPlugin = new Class({ - - Extends: LightsManager, - - initialize: - - function LightsPlugin (scene) - { - /** - * [description] - * - * @name Phaser.GameObjects.LightsPlugin#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.GameObjects.LightsPlugin#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - if (!scene.sys.settings.isBooted) - { - scene.sys.events.once('boot', this.boot, this); - } - - LightsManager.call(this); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsPlugin#boot - * @since 3.0.0 - */ - boot: function () - { - var eventEmitter = this.systems.events; - - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsPlugin#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.shutdown(); - - this.scene = undefined; - this.systems = undefined; - } - -}); - -PluginManager.register('LightsPlugin', LightsPlugin, 'lights'); - -module.exports = LightsPlugin; - - -/***/ }), -/* 665 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Circle = __webpack_require__(64); - -Circle.Area = __webpack_require__(666); -Circle.Circumference = __webpack_require__(186); -Circle.CircumferencePoint = __webpack_require__(105); -Circle.Clone = __webpack_require__(667); -Circle.Contains = __webpack_require__(32); -Circle.ContainsPoint = __webpack_require__(668); -Circle.ContainsRect = __webpack_require__(669); -Circle.CopyFrom = __webpack_require__(670); -Circle.Equals = __webpack_require__(671); -Circle.GetBounds = __webpack_require__(672); -Circle.GetPoint = __webpack_require__(184); -Circle.GetPoints = __webpack_require__(185); -Circle.Offset = __webpack_require__(673); -Circle.OffsetPoint = __webpack_require__(674); -Circle.Random = __webpack_require__(106); - -module.exports = Circle; - - -/***/ }), -/* 666 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculates the area of the circle. - * - * @function Phaser.Geom.Circle.Area - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to get the area of. - * - * @return {number} The area of the Circle. - */ -var Area = function (circle) -{ - return (circle.radius > 0) ? Math.PI * circle.radius * circle.radius : 0; -}; - -module.exports = Area; - - -/***/ }), -/* 667 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Circle = __webpack_require__(64); - -/** - * Creates a new Circle instance based on the values contained in the given source. - * - * @function Phaser.Geom.Circle.Clone - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle|object} source - The Circle to be cloned. Can be an instance of a Circle or a circle-like object, with x, y and radius properties. - * - * @return {Phaser.Geom.Circle} A clone of the source Circle. - */ -var Clone = function (source) -{ - return new Circle(source.x, source.y, source.radius); -}; - -module.exports = Clone; - - -/***/ }), -/* 668 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(32); - -/** - * Check to see if the Circle contains the given Point object. - * - * @function Phaser.Geom.Circle.ContainsPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to check. - * @param {Phaser.Geom.Point|object} point - The Point object to check if it's within the Circle or not. - * - * @return {boolean} True if the Point coordinates are within the circle, otherwise false. - */ -var ContainsPoint = function (circle, point) -{ - return Contains(circle, point.x, point.y); -}; - -module.exports = ContainsPoint; - - -/***/ }), -/* 669 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(32); - -/** - * Check to see if the Circle contains all four points of the given Rectangle object. - * - * @function Phaser.Geom.Circle.ContainsRect - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to check. - * @param {Phaser.Geom.Rectangle|object} rect - The Rectangle object to check if it's within the Circle or not. - * - * @return {boolean} True if all of the Rectangle coordinates are within the circle, otherwise false. - */ -var ContainsRect = function (circle, rect) -{ - return ( - Contains(circle, rect.x, rect.y) && - Contains(circle, rect.right, rect.y) && - Contains(circle, rect.x, rect.bottom) && - Contains(circle, rect.right, rect.bottom) - ); -}; - -module.exports = ContainsRect; - - -/***/ }), -/* 670 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Copies the `x`, `y` and `radius` properties from the `source` Circle - * into the given `dest` Circle, then returns the `dest` Circle. - * - * @function Phaser.Geom.Circle.CopyFrom - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} source - The source Circle to copy the values from. - * @param {Phaser.Geom.Circle} dest - The destination Circle to copy the values to. - * - * @return {Phaser.Geom.Circle} The dest Circle. - */ -var CopyFrom = function (source, dest) -{ - return dest.setTo(source.x, source.y, source.radius); -}; - -module.exports = CopyFrom; - - -/***/ }), -/* 671 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Compares the `x`, `y` and `radius` properties of the two given Circles. - * Returns `true` if they all match, otherwise returns `false`. - * - * @function Phaser.Geom.Circle.Equals - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The first Circle to compare. - * @param {Phaser.Geom.Circle} toCompare - The second Circle to compare. - * - * @return {boolean} `true` if the two Circles equal each other, otherwise `false`. - */ -var Equals = function (circle, toCompare) -{ - return ( - circle.x === toCompare.x && - circle.y === toCompare.y && - circle.radius === toCompare.radius - ); -}; - -module.exports = Equals; - - -/***/ }), -/* 672 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(8); - -/** - * Returns the bounds of the Circle object. - * - * @function Phaser.Geom.Circle.GetBounds - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to get the bounds from. - * @param {Phaser.Geom.Rectangle|object} [out] - A Rectangle, or rectangle-like object, to store the circle bounds in. If not given a new Rectangle will be created. - * - * @return {Phaser.Geom.Rectangle|object} The Rectangle object containing the Circles bounds. - */ -var GetBounds = function (circle, out) -{ - if (out === undefined) { out = new Rectangle(); } - - out.x = circle.left; - out.y = circle.top; - out.width = circle.diameter; - out.height = circle.diameter; - - return out; -}; - -module.exports = GetBounds; - - -/***/ }), -/* 673 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Offsets the Circle by the values given. - * - * @function Phaser.Geom.Circle.Offset - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to be offset (translated.) - * @param {number} x - The amount to horizontally offset the Circle by. - * @param {number} y - The amount to vertically offset the Circle by. - * - * @return {Phaser.Geom.Circle} The Circle that was offset. - */ -var Offset = function (circle, x, y) -{ - circle.x += x; - circle.y += y; - - return circle; -}; - -module.exports = Offset; - - -/***/ }), -/* 674 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Offsets the Circle by the values given in the `x` and `y` properties of the Point object. - * - * @function Phaser.Geom.Circle.OffsetPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to be offset (translated.) - * @param {Phaser.Geom.Point|object} point - The Point object containing the values to offset the Circle by. - * - * @return {Phaser.Geom.Circle} The Circle that was offset. - */ -var OffsetPoint = function (circle, point) -{ - circle.x += point.x; - circle.y += point.y; - - return circle; -}; - -module.exports = OffsetPoint; - - -/***/ }), -/* 675 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var DistanceBetween = __webpack_require__(42); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.CircleToCircle - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circleA - [description] - * @param {Phaser.Geom.Circle} circleB - [description] - * - * @return {boolean} [description] - */ -var CircleToCircle = function (circleA, circleB) -{ - return (DistanceBetween(circleA.x, circleA.y, circleB.x, circleB.y) <= (circleA.radius + circleB.radius)); -}; - -module.exports = CircleToCircle; - - -/***/ }), -/* 676 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Intersects.CircleToRectangle - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - [description] - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {boolean} [description] - */ -var CircleToRectangle = function (circle, rect) -{ - var halfWidth = rect.width / 2; - var halfHeight = rect.height / 2; - - var cx = Math.abs(circle.x - rect.x - halfWidth); - var cy = Math.abs(circle.y - rect.y - halfHeight); - var xDist = halfWidth + circle.radius; - var yDist = halfHeight + circle.radius; - - if (cx > xDist || cy > yDist) - { - return false; - } - else if (cx <= halfWidth || cy <= halfHeight) - { - return true; - } - else - { - var xCornerDist = cx - halfWidth; - var yCornerDist = cy - halfHeight; - var xCornerDistSq = xCornerDist * xCornerDist; - var yCornerDistSq = yCornerDist * yCornerDist; - var maxCornerDistSq = circle.radius * circle.radius; - - return (xCornerDistSq + yCornerDistSq <= maxCornerDistSq); - } -}; - -module.exports = CircleToRectangle; - - -/***/ }), -/* 677 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(8); -var RectangleToRectangle = __webpack_require__(296); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.GetRectangleIntersection - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] - * @param {Phaser.Geom.Rectangle} [output] - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var GetRectangleIntersection = function (rectA, rectB, output) -{ - if (output === undefined) { output = new Rectangle(); } - - if (RectangleToRectangle(rectA, rectB)) - { - output.x = Math.max(rectA.x, rectB.x); - output.y = Math.max(rectA.y, rectB.y); - output.width = Math.min(rectA.right, rectB.right) - output.x; - output.height = Math.min(rectA.bottom, rectB.bottom) - output.y; - } - - return output; -}; - -module.exports = GetRectangleIntersection; - - -/***/ }), -/* 678 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Checks for intersection between the Line and a Rectangle shape, or a rectangle-like - * object, with public `x`, `y`, `right` and `bottom` properties, such as a Sprite or Body. - * - * An intersection is considered valid if: - * - * The line starts within, or ends within, the Rectangle. - * The line segment intersects one of the 4 rectangle edges. - * - * The for the purposes of this function rectangles are considered 'solid'. - * - * @function Phaser.Geom.Intersects.LineToRectangle - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {Phaser.Geom.Rectangle|object} rect - [description] - * - * @return {boolean} [description] - */ -var LineToRectangle = function (line, rect) -{ - var x1 = line.x1; - var y1 = line.y1; - - var x2 = line.x2; - var y2 = line.y2; - - var bx1 = rect.x; - var by1 = rect.y; - var bx2 = rect.right; - var by2 = rect.bottom; - - var t = 0; - - // If the start or end of the line is inside the rect then we assume - // collision, as rects are solid for our use-case. - - if ((x1 >= bx1 && x1 <= bx2 && y1 >= by1 && y1 <= by2) || - (x2 >= bx1 && x2 <= bx2 && y2 >= by1 && y2 <= by2)) - { - return true; - } - - if (x1 < bx1 && x2 >= bx1) - { - // Left edge - t = y1 + (y2 - y1) * (bx1 - x1) / (x2 - x1); - - if (t > by1 && t <= by2) - { - return true; - } - } - else if (x1 > bx2 && x2 <= bx2) - { - // Right edge - t = y1 + (y2 - y1) * (bx2 - x1) / (x2 - x1); - - if (t >= by1 && t <= by2) - { - return true; - } - } - - if (y1 < by1 && y2 >= by1) - { - // Top edge - t = x1 + (x2 - x1) * (by1 - y1) / (y2 - y1); - - if (t >= bx1 && t <= bx2) - { - return true; - } - } - else if (y1 > by2 && y2 <= by2) - { - // Bottom edge - t = x1 + (x2 - x1) * (by2 - y1) / (y2 - y1); - - if (t >= bx1 && t <= bx2) - { - return true; - } - } - - return false; -}; - -module.exports = LineToRectangle; - - -/***/ }), -/* 679 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var PointToLine = __webpack_require__(298); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.PointToLineSegment - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} point - [description] - * @param {Phaser.Geom.Line} line - [description] - * - * @return {boolean} [description] - */ -var PointToLineSegment = function (point, line) -{ - if (!PointToLine(point, line)) - { - return false; - } - - var xMin = Math.min(line.x1, line.x2); - var xMax = Math.max(line.x1, line.x2); - var yMin = Math.min(line.y1, line.y2); - var yMax = Math.max(line.y1, line.y2); - - return ((point.x >= xMin && point.x <= xMax) && (point.y >= yMin && point.y <= yMax)); -}; - -module.exports = PointToLineSegment; - - -/***/ }), -/* 680 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var LineToLine = __webpack_require__(89); -var Contains = __webpack_require__(33); -var ContainsArray = __webpack_require__(145); -var Decompose = __webpack_require__(299); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.RectangleToTriangle - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Triangle} triangle - [description] - * - * @return {boolean} [description] - */ -var RectangleToTriangle = function (rect, triangle) -{ - // First the cheapest ones: - - if ( - triangle.left > rect.right || - triangle.right < rect.left || - triangle.top > rect.bottom || - triangle.bottom < rect.top) - { - return false; - } - - var triA = triangle.getLineA(); - var triB = triangle.getLineB(); - var triC = triangle.getLineC(); - - // Are any of the triangle points within the rectangle? - - if (Contains(rect, triA.x1, triA.y1) || Contains(rect, triA.x2, triA.y2)) - { - return true; - } - - if (Contains(rect, triB.x1, triB.y1) || Contains(rect, triB.x2, triB.y2)) - { - return true; - } - - if (Contains(rect, triC.x1, triC.y1) || Contains(rect, triC.x2, triC.y2)) - { - return true; - } - - // Cheap tests over, now to see if any of the lines intersect ... - - var rectA = rect.getLineA(); - var rectB = rect.getLineB(); - var rectC = rect.getLineC(); - var rectD = rect.getLineD(); - - if (LineToLine(triA, rectA) || LineToLine(triA, rectB) || LineToLine(triA, rectC) || LineToLine(triA, rectD)) - { - return true; - } - - if (LineToLine(triB, rectA) || LineToLine(triB, rectB) || LineToLine(triB, rectC) || LineToLine(triB, rectD)) - { - return true; - } - - if (LineToLine(triC, rectA) || LineToLine(triC, rectB) || LineToLine(triC, rectC) || LineToLine(triC, rectD)) - { - return true; - } - - // None of the lines intersect, so are any rectangle points within the triangle? - - var points = Decompose(rect); - var within = ContainsArray(triangle, points, true); - - return (within.length > 0); -}; - -module.exports = RectangleToTriangle; - - -/***/ }), -/* 681 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Intersects.RectangleToValues - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} left - [description] - * @param {number} right - [description] - * @param {number} top - [description] - * @param {number} bottom - [description] - * @param {float} [tolerance=0] - [description] - * - * @return {boolean} [description] - */ -var RectangleToValues = function (rect, left, right, top, bottom, tolerance) -{ - if (tolerance === undefined) { tolerance = 0; } - - return !( - left > rect.right + tolerance || - right < rect.left - tolerance || - top > rect.bottom + tolerance || - bottom < rect.top - tolerance - ); -}; - -module.exports = RectangleToValues; - - -/***/ }), -/* 682 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var LineToCircle = __webpack_require__(297); -var Contains = __webpack_require__(54); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.TriangleToCircle - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Circle} circle - [description] - * - * @return {boolean} [description] - */ -var TriangleToCircle = function (triangle, circle) -{ - // First the cheapest ones: - - if ( - triangle.left > circle.right || - triangle.right < circle.left || - triangle.top > circle.bottom || - triangle.bottom < circle.top) - { - return false; - } - - if (Contains(triangle, circle.x, circle.y)) - { - return true; - } - - if (LineToCircle(triangle.getLineA(), circle)) - { - return true; - } - - if (LineToCircle(triangle.getLineB(), circle)) - { - return true; - } - - if (LineToCircle(triangle.getLineC(), circle)) - { - return true; - } - - return false; -}; - -module.exports = TriangleToCircle; - - -/***/ }), -/* 683 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(54); -var LineToLine = __webpack_require__(89); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.TriangleToLine - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Line} line - [description] - * - * @return {boolean} [description] - */ -var TriangleToLine = function (triangle, line) -{ - // If the Triangle contains either the start or end point of the line, it intersects - if (Contains(triangle, line.getPointA()) || Contains(triangle, line.getPointB())) - { - return true; - } - - // Now check the line against each line of the Triangle - if (LineToLine(triangle.getLineA(), line)) - { - return true; - } - - if (LineToLine(triangle.getLineB(), line)) - { - return true; - } - - if (LineToLine(triangle.getLineC(), line)) - { - return true; - } - - return false; -}; - -module.exports = TriangleToLine; - - -/***/ }), -/* 684 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ContainsArray = __webpack_require__(145); -var Decompose = __webpack_require__(300); -var LineToLine = __webpack_require__(89); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.TriangleToTriangle - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangleA - [description] - * @param {Phaser.Geom.Triangle} triangleB - [description] - * - * @return {boolean} [description] - */ -var TriangleToTriangle = function (triangleA, triangleB) -{ - // First the cheapest ones: - - if ( - triangleA.left > triangleB.right || - triangleA.right < triangleB.left || - triangleA.top > triangleB.bottom || - triangleA.bottom < triangleB.top) - { - return false; - } - - var lineAA = triangleA.getLineA(); - var lineAB = triangleA.getLineB(); - var lineAC = triangleA.getLineC(); - - var lineBA = triangleB.getLineA(); - var lineBB = triangleB.getLineB(); - var lineBC = triangleB.getLineC(); - - // Now check the lines against each line of TriangleB - if (LineToLine(lineAA, lineBA) || LineToLine(lineAA, lineBB) || LineToLine(lineAA, lineBC)) - { - return true; - } - - if (LineToLine(lineAB, lineBA) || LineToLine(lineAB, lineBB) || LineToLine(lineAB, lineBC)) - { - return true; - } - - if (LineToLine(lineAC, lineBA) || LineToLine(lineAC, lineBB) || LineToLine(lineAC, lineBC)) - { - return true; - } - - // Nope, so check to see if any of the points of triangleA are within triangleB - - var points = Decompose(triangleA); - var within = ContainsArray(triangleB, points, true); - - if (within.length > 0) - { - return true; - } - - // Finally check to see if any of the points of triangleB are within triangleA - - points = Decompose(triangleB); - within = ContainsArray(triangleA, points, true); - - if (within.length > 0) - { - return true; - } - - return false; -}; - -module.exports = TriangleToTriangle; - - -/***/ }), -/* 685 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Line = __webpack_require__(301); - -Line.Angle = __webpack_require__(55); -Line.BresenhamPoints = __webpack_require__(194); -Line.CenterOn = __webpack_require__(686); -Line.Clone = __webpack_require__(687); -Line.CopyFrom = __webpack_require__(688); -Line.Equals = __webpack_require__(689); -Line.GetMidPoint = __webpack_require__(690); -Line.GetNormal = __webpack_require__(691); -Line.GetPoint = __webpack_require__(302); -Line.GetPoints = __webpack_require__(109); -Line.Height = __webpack_require__(692); -Line.Length = __webpack_require__(66); -Line.NormalAngle = __webpack_require__(303); -Line.NormalX = __webpack_require__(693); -Line.NormalY = __webpack_require__(694); -Line.Offset = __webpack_require__(695); -Line.PerpSlope = __webpack_require__(696); -Line.Random = __webpack_require__(111); -Line.ReflectAngle = __webpack_require__(697); -Line.Rotate = __webpack_require__(698); -Line.RotateAroundPoint = __webpack_require__(699); -Line.RotateAroundXY = __webpack_require__(146); -Line.SetToAngle = __webpack_require__(700); -Line.Slope = __webpack_require__(701); -Line.Width = __webpack_require__(702); - -module.exports = Line; - - -/***/ }), -/* 686 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - - -/** - * [description] - * - * @function Phaser.Geom.Line.CenterOn - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var CenterOn = function (line, x, y) -{ - var tx = x - ((line.x1 + line.x2) / 2); - var ty = y - ((line.y1 + line.y2) / 2); - - line.x1 += tx; - line.y1 += ty; - - line.x2 += tx; - line.y2 += ty; - - return line; -}; - -module.exports = CenterOn; - - -/***/ }), -/* 687 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Line = __webpack_require__(301); - -/** - * [description] - * - * @function Phaser.Geom.Line.Clone - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} source - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var Clone = function (source) -{ - return new Line(source.x1, source.y1, source.x2, source.y2); -}; - -module.exports = Clone; - - -/***/ }), -/* 688 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.CopyFrom - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} source - [description] - * @param {Phaser.Geom.Line} dest - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var CopyFrom = function (source, dest) -{ - return dest.setTo(source.x1, source.y1, source.x2, source.y2); -}; - -module.exports = CopyFrom; - - -/***/ }), -/* 689 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Equals - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {Phaser.Geom.Line} toCompare - [description] - * - * @return {boolean} [description] - */ -var Equals = function (line, toCompare) -{ - return ( - line.x1 === toCompare.x1 && - line.y1 === toCompare.y1 && - line.x2 === toCompare.x2 && - line.y2 === toCompare.y2 - ); -}; - -module.exports = Equals; - - -/***/ }), -/* 690 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Line.GetMidPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {Phaser.Geom.Point|object} [out] - [description] - * - * @return {Phaser.Geom.Point|object} [description] - */ -var GetMidPoint = function (line, out) -{ - if (out === undefined) { out = new Point(); } - - out.x = (line.x1 + line.x2) / 2; - out.y = (line.y1 + line.y2) / 2; - - return out; -}; - -module.exports = GetMidPoint; - - -/***/ }), -/* 691 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH_CONST = __webpack_require__(16); -var Angle = __webpack_require__(55); -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Line.GetNormal - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {Phaser.Geom.Point|object} [out] - [description] - * - * @return {Phaser.Geom.Point|object} [description] - */ -var GetNormal = function (line, out) -{ - if (out === undefined) { out = new Point(); } - - var a = Angle(line) - MATH_CONST.TAU; - - out.x = Math.cos(a); - out.y = Math.sin(a); - - return out; -}; - -module.exports = GetNormal; - - -/***/ }), -/* 692 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Height - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var Height = function (line) -{ - return Math.abs(line.y1 - line.y2); -}; - -module.exports = Height; - - -/***/ }), -/* 693 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH_CONST = __webpack_require__(16); -var Angle = __webpack_require__(55); - -/** - * [description] - * - * @function Phaser.Geom.Line.NormalX - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var NormalX = function (line) -{ - return Math.cos(Angle(line) - MATH_CONST.TAU); -}; - -module.exports = NormalX; - - -/***/ }), -/* 694 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH_CONST = __webpack_require__(16); -var Angle = __webpack_require__(55); - -/** - * [description] - * - * @function Phaser.Geom.Line.NormalY - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var NormalY = function (line) -{ - return Math.sin(Angle(line) - MATH_CONST.TAU); -}; - -module.exports = NormalY; - - -/***/ }), -/* 695 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Offset - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var Offset = function (line, x, y) -{ - line.x1 += x; - line.y1 += y; - - line.x2 += x; - line.y2 += y; - - return line; -}; - -module.exports = Offset; - - -/***/ }), -/* 696 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.PerpSlope - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var PerpSlope = function (line) -{ - return -((line.x2 - line.x1) / (line.y2 - line.y1)); -}; - -module.exports = PerpSlope; - - -/***/ }), -/* 697 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Angle = __webpack_require__(55); -var NormalAngle = __webpack_require__(303); - -/** -* Returns the reflected angle between two lines. -* This is the outgoing angle based on the angle of Line 1 and the normalAngle of Line 2. -*/ -/** - * [description] - * - * @function Phaser.Geom.Line.ReflectAngle - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} lineA - [description] - * @param {Phaser.Geom.Line} lineB - [description] - * - * @return {number} [description] - */ -var ReflectAngle = function (lineA, lineB) -{ - return (2 * NormalAngle(lineB) - Math.PI - Angle(lineA)); -}; - -module.exports = ReflectAngle; - - -/***/ }), -/* 698 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RotateAroundXY = __webpack_require__(146); - -/** - * [description] - * - * @function Phaser.Geom.Line.Rotate - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var Rotate = function (line, angle) -{ - var x = (line.x1 + line.x2) / 2; - var y = (line.y1 + line.y2) / 2; - - return RotateAroundXY(line, x, y, angle); -}; - -module.exports = Rotate; - - -/***/ }), -/* 699 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RotateAroundXY = __webpack_require__(146); - -/** - * [description] - * - * @function Phaser.Geom.Line.RotateAroundPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {Phaser.Geom.Point|object} point - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var RotateAroundPoint = function (line, point, angle) -{ - return RotateAroundXY(line, point.x, point.y, angle); -}; - -module.exports = RotateAroundPoint; - - -/***/ }), -/* 700 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.SetToAngle - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} angle - [description] - * @param {number} length - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var SetToAngle = function (line, x, y, angle, length) -{ - line.x1 = x; - line.y1 = y; - - line.x2 = x + (Math.cos(angle) * length); - line.y2 = y + (Math.sin(angle) * length); - - return line; -}; - -module.exports = SetToAngle; - - -/***/ }), -/* 701 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Slope - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var Slope = function (line) -{ - return (line.y2 - line.y1) / (line.x2 - line.x1); -}; - -module.exports = Slope; - - -/***/ }), -/* 702 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Width - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var Width = function (line) -{ - return Math.abs(line.x1 - line.x2); -}; - -module.exports = Width; - - -/***/ }), -/* 703 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -Point.Ceil = __webpack_require__(704); -Point.Clone = __webpack_require__(705); -Point.CopyFrom = __webpack_require__(706); -Point.Equals = __webpack_require__(707); -Point.Floor = __webpack_require__(708); -Point.GetCentroid = __webpack_require__(709); -Point.GetMagnitude = __webpack_require__(304); -Point.GetMagnitudeSq = __webpack_require__(305); -Point.GetRectangleFromPoints = __webpack_require__(710); -Point.Interpolate = __webpack_require__(711); -Point.Invert = __webpack_require__(712); -Point.Negative = __webpack_require__(713); -Point.Project = __webpack_require__(714); -Point.ProjectUnit = __webpack_require__(715); -Point.SetMagnitude = __webpack_require__(716); - -module.exports = Point; - - -/***/ }), -/* 704 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.Ceil - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} point - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Ceil = function (point) -{ - return point.setTo(Math.ceil(point.x), Math.ceil(point.y)); -}; - -module.exports = Ceil; - - -/***/ }), -/* 705 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Point.Clone - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} source - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Clone = function (source) -{ - return new Point(source.x, source.y); -}; - -module.exports = Clone; - - -/***/ }), -/* 706 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.CopyFrom - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} source - [description] - * @param {Phaser.Geom.Point} dest - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var CopyFrom = function (source, dest) -{ - return dest.setTo(source.x, source.y); -}; - -module.exports = CopyFrom; - - -/***/ }), -/* 707 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.Equals - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} point - [description] - * @param {Phaser.Geom.Point} toCompare - [description] - * - * @return {boolean} [description] - */ -var Equals = function (point, toCompare) -{ - return (point.x === toCompare.x && point.y === toCompare.y); -}; - -module.exports = Equals; - - -/***/ }), -/* 708 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.Floor - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} point - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Floor = function (point) -{ - return point.setTo(Math.floor(point.x), Math.floor(point.y)); -}; - -module.exports = Floor; - - -/***/ }), -/* 709 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Point.GetCentroid - * @since 3.0.0 - * - * @param {Phaser.Geom.Point[]} points - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var GetCentroid = function (points, out) -{ - if (out === undefined) { out = new Point(); } - - if (!Array.isArray(points)) - { - throw new Error('GetCentroid points argument must be an array'); - } - - var len = points.length; - - if (len < 1) - { - throw new Error('GetCentroid points array must not be empty'); - } - else if (len === 1) - { - out.x = points[0].x; - out.y = points[0].y; - } - else - { - for (var i = 0; i < len; i++) - { - out.x += points[i].x; - out.y += points[i].y; - } - - out.x /= len; - out.y /= len; - } - - return out; -}; - -module.exports = GetCentroid; - - -/***/ }), -/* 710 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(8); - -/** - * Calculates the Axis Aligned Bounding Box (or aabb) from an array of points. - * - * @function Phaser.Geom.Point.GetRectangleFromPoints - * @since 3.0.0 - * - * @param {Phaser.Geom.Point[]} points - [description] - * @param {Phaser.Geom.Rectangle} [out] - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var GetRectangleFromPoints = function (points, out) -{ - if (out === undefined) { out = new Rectangle(); } - - var xMax = Number.NEGATIVE_INFINITY; - var xMin = Number.POSITIVE_INFINITY; - var yMax = Number.NEGATIVE_INFINITY; - var yMin = Number.POSITIVE_INFINITY; - - for (var i = 0; i < points.length; i++) - { - var point = points[i]; - - if (point.x > xMax) - { - xMax = point.x; - } - - if (point.x < xMin) - { - xMin = point.x; - } - - if (point.y > yMax) - { - yMax = point.y; - } - - if (point.y < yMin) - { - yMin = point.y; - } - } - - out.x = xMin; - out.y = yMin; - out.width = xMax - xMin; - out.height = yMax - yMin; - - return out; -}; - -module.exports = GetRectangleFromPoints; - - -/***/ }), -/* 711 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Point.Interpolate - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} pointA - [description] - * @param {Phaser.Geom.Point} pointB - [description] - * @param {float} [t=0] - [description] - * @param {Phaser.Geom.Point|object} [out] - [description] - * - * @return {Phaser.Geom.Point|object} [description] - */ -var Interpolate = function (pointA, pointB, t, out) -{ - if (t === undefined) { t = 0; } - if (out === undefined) { out = new Point(); } - - out.x = pointA.x + ((pointB.x - pointA.x) * t); - out.y = pointA.y + ((pointB.y - pointA.y) * t); - - return out; -}; - -module.exports = Interpolate; - - -/***/ }), -/* 712 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.Invert - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} point - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Invert = function (point) -{ - return point.setTo(point.y, point.x); -}; - -module.exports = Invert; - - -/***/ }), -/* 713 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Point.Negative - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} point - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Negative = function (point, out) -{ - if (out === undefined) { out = new Point(); } - - return out.setTo(-point.x, -point.y); -}; - -module.exports = Negative; - - -/***/ }), -/* 714 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); -var GetMagnitudeSq = __webpack_require__(305); - -/** - * [description] - * - * @function Phaser.Geom.Point.Project - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} pointA - [description] - * @param {Phaser.Geom.Point} pointB - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Project = function (pointA, pointB, out) -{ - if (out === undefined) { out = new Point(); } - - var dot = ((pointA.x * pointB.x) + (pointA.y * pointB.y)); - var amt = dot / GetMagnitudeSq(pointB); - - if (amt !== 0) - { - out.x = amt * pointB.x; - out.y = amt * pointB.y; - } - - return out; -}; - -module.exports = Project; - - -/***/ }), -/* 715 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Point.ProjectUnit - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} pointA - [description] - * @param {Phaser.Geom.Point} pointB - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var ProjectUnit = function (pointA, pointB, out) -{ - if (out === undefined) { out = new Point(); } - - var amt = ((pointA.x * pointB.x) + (pointA.y * pointB.y)); - - if (amt !== 0) - { - out.x = amt * pointB.x; - out.y = amt * pointB.y; - } - - return out; -}; - -module.exports = ProjectUnit; - - -/***/ }), -/* 716 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetMagnitude = __webpack_require__(304); - -/** - * [description] - * - * @function Phaser.Geom.Point.SetMagnitude - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} point - [description] - * @param {number} magnitude - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var SetMagnitude = function (point, magnitude) -{ - if (point.x !== 0 || point.y !== 0) - { - var m = GetMagnitude(point); - - point.x /= m; - point.y /= m; - } - - point.x *= magnitude; - point.y *= magnitude; - - return point; -}; - -module.exports = SetMagnitude; - - /***/ }), /* 717 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -107576,20 +105684,41 @@ module.exports = SetMagnitude; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Polygon = __webpack_require__(306); +/** + * [description] + * + * @function Phaser.Math.Easing.Stepped + * @since 3.0.0 + * + * @param {number} v - [description] + * @param {float} [steps=1] - [description] + * + * @return {number} [description] + */ +var Stepped = function (v, steps) +{ + if (steps === undefined) { steps = 1; } -Polygon.Clone = __webpack_require__(718); -Polygon.Contains = __webpack_require__(147); -Polygon.ContainsPoint = __webpack_require__(719); -Polygon.GetAABB = __webpack_require__(720); -Polygon.GetNumberArray = __webpack_require__(721); + if (v <= 0) + { + return 0; + } + else if (v >= 1) + { + return 1; + } + else + { + return (((steps * v) | 0) + 1) * (1 / steps); + } +}; -module.exports = Polygon; +module.exports = Stepped; /***/ }), /* 718 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -107597,29 +105726,38 @@ module.exports = Polygon; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Polygon = __webpack_require__(306); - /** * [description] * - * @function Phaser.Geom.Polygon.Clone + * @function Phaser.Math.Easing.Sine.InOut * @since 3.0.0 * - * @param {Phaser.Geom.Polygon} polygon - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Polygon} [description] + * @return {number} [description] */ -var Clone = function (polygon) +var InOut = function (v) { - return new Polygon(polygon.points); + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + return 0.5 * (1 - Math.cos(Math.PI * v)); + } }; -module.exports = Clone; +module.exports = InOut; /***/ }), /* 719 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -107627,30 +105765,38 @@ module.exports = Clone; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Contains = __webpack_require__(147); - /** * [description] * - * @function Phaser.Geom.Polygon.ContainsPoint + * @function Phaser.Math.Easing.Sine.Out * @since 3.0.0 * - * @param {Phaser.Geom.Polygon} polygon - [description] - * @param {Phaser.Geom.Point} point - [description] + * @param {number} v - [description] * - * @return {boolean} [description] + * @return {number} [description] */ -var ContainsPoint = function (polygon, point) +var Out = function (v) { - return Contains(polygon, point.x, point.y); + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + return Math.sin(v * Math.PI / 2); + } }; -module.exports = ContainsPoint; +module.exports = Out; /***/ }), /* 720 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -107658,48 +105804,33 @@ module.exports = ContainsPoint; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Rectangle = __webpack_require__(8); - /** * [description] * - * @function Phaser.Geom.Polygon.GetAABB + * @function Phaser.Math.Easing.Sine.In * @since 3.0.0 * - * @param {Phaser.Geom.Polygon} polygon - [description] - * @param {Phaser.Geom.Rectangle|object} [out] - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle|object} [description] + * @return {number} [description] */ -var GetAABB = function (polygon, out) +var In = function (v) { - if (out === undefined) { out = new Rectangle(); } - - var minX = Infinity; - var minY = Infinity; - var maxX = -minX; - var maxY = -minY; - var p; - - for (var i = 0; i < polygon.points.length; i++) + if (v === 0) { - p = polygon.points[i]; - - minX = Math.min(minX, p.x); - minY = Math.min(minY, p.y); - maxX = Math.max(maxX, p.x); - maxY = Math.max(maxY, p.y); + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + return 1 - Math.cos(v * Math.PI / 2); } - - out.x = minX; - out.y = minY; - out.width = maxX - minX; - out.height = maxY - minY; - - return out; }; -module.exports = GetAABB; +module.exports = In; /***/ }), @@ -107712,33 +105843,29 @@ module.exports = GetAABB; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Export the points as an array of flat numbers, following the sequence [ x,y, x,y, x,y ] - /** * [description] * - * @function Phaser.Geom.Polygon.GetNumberArray + * @function Phaser.Math.Easing.Quintic.InOut * @since 3.0.0 * - * @param {Phaser.Geom.Polygon} polygon - [description] - * @param {array} [output] - [description] + * @param {number} v - [description] * - * @return {number[]} [description] + * @return {number} [description] */ -var GetNumberArray = function (polygon, output) +var InOut = function (v) { - if (output === undefined) { output = []; } - - for (var i = 0; i < polygon.points.length; i++) + if ((v *= 2) < 1) { - output.push(polygon.points[i].x); - output.push(polygon.points[i].y); + return 0.5 * v * v * v * v * v; + } + else + { + return 0.5 * ((v -= 2) * v * v * v * v + 2); } - - return output; }; -module.exports = GetNumberArray; +module.exports = InOut; /***/ }), @@ -107754,19 +105881,19 @@ module.exports = GetNumberArray; /** * [description] * - * @function Phaser.Geom.Rectangle.Area + * @function Phaser.Math.Easing.Quintic.Out * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} v - [description] * * @return {number} [description] */ -var Area = function (rect) +var Out = function (v) { - return rect.width * rect.height; + return --v * v * v * v * v + 1; }; -module.exports = Area; +module.exports = Out; /***/ }), @@ -107782,22 +105909,19 @@ module.exports = Area; /** * [description] * - * @function Phaser.Geom.Rectangle.Ceil + * @function Phaser.Math.Easing.Quintic.In * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var Ceil = function (rect) +var In = function (v) { - rect.x = Math.ceil(rect.x); - rect.y = Math.ceil(rect.y); - - return rect; + return v * v * v * v * v; }; -module.exports = Ceil; +module.exports = In; /***/ }), @@ -107813,29 +105937,31 @@ module.exports = Ceil; /** * [description] * - * @function Phaser.Geom.Rectangle.CeilAll + * @function Phaser.Math.Easing.Quartic.InOut * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var CeilAll = function (rect) +var InOut = function (v) { - rect.x = Math.ceil(rect.x); - rect.y = Math.ceil(rect.y); - rect.width = Math.ceil(rect.width); - rect.height = Math.ceil(rect.height); - - return rect; + if ((v *= 2) < 1) + { + return 0.5 * v * v * v * v; + } + else + { + return -0.5 * ((v -= 2) * v * v * v - 2); + } }; -module.exports = CeilAll; +module.exports = InOut; /***/ }), /* 725 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -107843,29 +105969,27 @@ module.exports = CeilAll; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Rectangle = __webpack_require__(8); - /** * [description] * - * @function Phaser.Geom.Rectangle.Clone + * @function Phaser.Math.Easing.Quartic.Out * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} source - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var Clone = function (source) +var Out = function (v) { - return new Rectangle(source.x, source.y, source.width, source.height); + return 1 - (--v * v * v * v); }; -module.exports = Clone; +module.exports = Out; /***/ }), /* 726 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -107873,25 +105997,22 @@ module.exports = Clone; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Contains = __webpack_require__(33); - /** * [description] * - * @function Phaser.Geom.Rectangle.ContainsPoint + * @function Phaser.Math.Easing.Quartic.In * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Point} point - [description] + * @param {number} v - [description] * - * @return {boolean} [description] + * @return {number} [description] */ -var ContainsPoint = function (rect, point) +var In = function (v) { - return Contains(rect, point.x, point.y); + return v * v * v * v; }; -module.exports = ContainsPoint; +module.exports = In; /***/ }), @@ -107904,36 +106025,29 @@ module.exports = ContainsPoint; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Checks if rectB is fully contained within rectA - /** * [description] * - * @function Phaser.Geom.Rectangle.ContainsRect + * @function Phaser.Math.Easing.Quadratic.InOut * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] + * @param {number} v - [description] * - * @return {boolean} [description] + * @return {number} [description] */ -var ContainsRect = function (rectA, rectB) +var InOut = function (v) { - // Volume check (if rectB volume > rectA then rectA cannot contain it) - if ((rectB.width * rectB.height) > (rectA.width * rectA.height)) + if ((v *= 2) < 1) { - return false; + return 0.5 * v * v; + } + else + { + return -0.5 * (--v * (v - 2) - 1); } - - return ( - (rectB.x > rectA.x && rectB.x < rectA.right) && - (rectB.right > rectA.x && rectB.right < rectA.right) && - (rectB.y > rectA.y && rectB.y < rectA.bottom) && - (rectB.bottom > rectA.y && rectB.bottom < rectA.bottom) - ); }; -module.exports = ContainsRect; +module.exports = InOut; /***/ }), @@ -107949,20 +106063,19 @@ module.exports = ContainsRect; /** * [description] * - * @function Phaser.Geom.Rectangle.CopyFrom + * @function Phaser.Math.Easing.Quadratic.Out * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} source - [description] - * @param {Phaser.Geom.Rectangle} dest - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var CopyFrom = function (source, dest) +var Out = function (v) { - return dest.setTo(source.x, source.y, source.width, source.height); + return v * (2 - v); }; -module.exports = CopyFrom; +module.exports = Out; /***/ }), @@ -107978,30 +106091,24 @@ module.exports = CopyFrom; /** * [description] * - * @function Phaser.Geom.Rectangle.Equals + * @function Phaser.Math.Easing.Quadratic.In * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Rectangle} toCompare - [description] + * @param {number} v - [description] * - * @return {boolean} [description] + * @return {number} [description] */ -var Equals = function (rect, toCompare) +var In = function (v) { - return ( - rect.x === toCompare.x && - rect.y === toCompare.y && - rect.width === toCompare.width && - rect.height === toCompare.height - ); + return v * v; }; -module.exports = Equals; +module.exports = In; /***/ }), /* 730 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -108009,50 +106116,27 @@ module.exports = Equals; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetAspectRatio = __webpack_require__(148); - -// Fits the target rectangle into the source rectangle. -// Preserves aspect ratio. -// Scales and centers the target rectangle to the source rectangle - /** * [description] * - * @function Phaser.Geom.Rectangle.FitInside + * @function Phaser.Math.Easing.Linear * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} target - [description] - * @param {Phaser.Geom.Rectangle} source - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var FitInside = function (target, source) +var Linear = function (v) { - var ratio = GetAspectRatio(target); - - if (ratio < GetAspectRatio(source)) - { - // Taller than Wide - target.setSize(source.height * ratio, source.height); - } - else - { - // Wider than Tall - target.setSize(source.width, source.width / ratio); - } - - return target.setPosition( - source.centerX - (target.width / 2), - source.centerY - (target.height / 2) - ); + return v; }; -module.exports = FitInside; +module.exports = Linear; /***/ }), /* 731 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -108060,45 +106144,29 @@ module.exports = FitInside; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetAspectRatio = __webpack_require__(148); - -// Fits the target rectangle around the source rectangle. -// Preserves aspect ration. -// Scales and centers the target rectangle to the source rectangle - /** * [description] * - * @function Phaser.Geom.Rectangle.FitOutside + * @function Phaser.Math.Easing.Expo.InOut * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} target - [description] - * @param {Phaser.Geom.Rectangle} source - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var FitOutside = function (target, source) +var InOut = function (v) { - var ratio = GetAspectRatio(target); - - if (ratio > GetAspectRatio(source)) + if ((v *= 2) < 1) { - // Wider than Tall - target.setSize(source.height * ratio, source.height); + return 0.5 * Math.pow(2, 10 * (v - 1)); } else { - // Taller than Wide - target.setSize(source.width, source.width / ratio); + return 0.5 * (2 - Math.pow(2, -10 * (v - 1))); } - - return target.setPosition( - source.centerX - target.width / 2, - source.centerY - target.height / 2 - ); }; -module.exports = FitOutside; +module.exports = InOut; /***/ }), @@ -108114,22 +106182,19 @@ module.exports = FitOutside; /** * [description] * - * @function Phaser.Geom.Rectangle.Floor + * @function Phaser.Math.Easing.Expo.Out * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var Floor = function (rect) +var Out = function (v) { - rect.x = Math.floor(rect.x); - rect.y = Math.floor(rect.y); - - return rect; + return 1 - Math.pow(2, -10 * v); }; -module.exports = Floor; +module.exports = Out; /***/ }), @@ -108145,29 +106210,24 @@ module.exports = Floor; /** * [description] * - * @function Phaser.Geom.Rectangle.FloorAll + * @function Phaser.Math.Easing.Expo.In * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var FloorAll = function (rect) +var In = function (v) { - rect.x = Math.floor(rect.x); - rect.y = Math.floor(rect.y); - rect.width = Math.floor(rect.width); - rect.height = Math.floor(rect.height); - - return rect; + return Math.pow(2, 10 * (v - 1)) - 0.001; }; -module.exports = FloorAll; +module.exports = In; /***/ }), /* 734 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -108175,37 +106235,61 @@ module.exports = FloorAll; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); - -// The center of the Rectangle object, expressed as a Point object - /** * [description] * - * @function Phaser.Geom.Rectangle.GetCenter + * @function Phaser.Math.Easing.Elastic.InOut * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Point|object} [out] - [description] + * @param {number} v - [description] + * @param {float} [amplitude=0.1] - [description] + * @param {float} [period=0.1] - [description] * - * @return {Phaser.Geom.Point|object} [description] + * @return {number} [description] */ -var GetCenter = function (rect, out) +var InOut = function (v, amplitude, period) { - if (out === undefined) { out = new Point(); } + if (amplitude === undefined) { amplitude = 0.1; } + if (period === undefined) { period = 0.1; } - out.x = rect.centerX; - out.y = rect.centerY; + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + var s = period / 4; - return out; + if (amplitude < 1) + { + amplitude = 1; + } + else + { + s = period * Math.asin(1 / amplitude) / (2 * Math.PI); + } + + if ((v *= 2) < 1) + { + return -0.5 * (amplitude * Math.pow(2, 10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period)); + } + else + { + return amplitude * Math.pow(2, -10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period) * 0.5 + 1; + } + } }; -module.exports = GetCenter; +module.exports = InOut; /***/ }), /* 735 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -108213,38 +106297,54 @@ module.exports = GetCenter; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); - -// The size of the Rectangle object, expressed as a Point object -// with the values of the width and height properties. - /** * [description] * - * @function Phaser.Geom.Rectangle.GetSize + * @function Phaser.Math.Easing.Elastic.Out * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Point|object} [out] - [description] + * @param {number} v - [description] + * @param {float} [amplitude=0.1] - [description] + * @param {float} [period=0.1] - [description] * - * @return {Phaser.Geom.Point|object} [description] + * @return {number} [description] */ -var GetSize = function (rect, out) +var Out = function (v, amplitude, period) { - if (out === undefined) { out = new Point(); } + if (amplitude === undefined) { amplitude = 0.1; } + if (period === undefined) { period = 0.1; } - out.x = rect.width; - out.y = rect.height; + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + var s = period / 4; - return out; + if (amplitude < 1) + { + amplitude = 1; + } + else + { + s = period * Math.asin(1 / amplitude) / (2 * Math.PI); + } + + return (amplitude * Math.pow(2, -10 * v) * Math.sin((v - s) * (2 * Math.PI) / period) + 1); + } }; -module.exports = GetSize; +module.exports = Out; /***/ }), /* 736 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -108252,35 +106352,49 @@ module.exports = GetSize; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CenterOn = __webpack_require__(308); - -// Increases the size of the Rectangle object by the specified amounts. -// The center point of the Rectangle object stays the same, and its size increases -// to the left and right by the x value, and to the top and the bottom by the y value. - /** * [description] * - * @function Phaser.Geom.Rectangle.Inflate + * @function Phaser.Math.Easing.Elastic.In * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] + * @param {number} v - [description] + * @param {float} [amplitude=0.1] - [description] + * @param {float} [period=0.1] - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var Inflate = function (rect, x, y) +var In = function (v, amplitude, period) { - var cx = rect.centerX; - var cy = rect.centerY; + if (amplitude === undefined) { amplitude = 0.1; } + if (period === undefined) { period = 0.1; } - rect.setSize(rect.width + (x * 2), rect.height + (y * 2)); + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + var s = period / 4; - return CenterOn(rect, cx, cy); + if (amplitude < 1) + { + amplitude = 1; + } + else + { + s = period * Math.asin(1 / amplitude) / (2 * Math.PI); + } + + return -(amplitude * Math.pow(2, 10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period)); + } }; -module.exports = Inflate; +module.exports = In; /***/ }), @@ -108293,44 +106407,29 @@ module.exports = Inflate; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Merges the target Rectangle with a list of points. -// The points is an array of objects with public x/y properties. - /** * [description] * - * @function Phaser.Geom.Rectangle.MergePoints + * @function Phaser.Math.Easing.Cubic.InOut * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} target - [description] - * @param {Phaser.Geom.Point[]} points - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var MergePoints = function (target, points) +var InOut = function (v) { - var minX = target.x; - var maxX = target.right; - var minY = target.y; - var maxY = target.bottom; - - for (var i = 0; i < points.length; i++) + if ((v *= 2) < 1) { - minX = Math.min(minX, points[i].x); - maxX = Math.max(maxX, points[i].x); - minY = Math.min(minY, points[i].y); - maxY = Math.max(maxY, points[i].y); + return 0.5 * v * v * v; + } + else + { + return 0.5 * ((v -= 2) * v * v + 2); } - - target.x = minX; - target.y = minY; - target.width = maxX - minX; - target.height = maxY - minY; - - return target; }; -module.exports = MergePoints; +module.exports = InOut; /***/ }), @@ -108343,38 +106442,22 @@ module.exports = MergePoints; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Merges source rectangle into target rectangle and returns target -// Neither rect should have negative widths or heights - /** * [description] * - * @function Phaser.Geom.Rectangle.MergeRect + * @function Phaser.Math.Easing.Cubic.Out * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} target - [description] - * @param {Phaser.Geom.Rectangle} source - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var MergeRect = function (target, source) +var Out = function (v) { - var minX = Math.min(target.x, source.x); - var maxX = Math.max(target.right, source.right); - - target.x = minX; - target.width = maxX - minX; - - var minY = Math.min(target.y, source.y); - var maxY = Math.max(target.bottom, source.bottom); - - target.y = minY; - target.height = maxY - minY; - - return target; + return --v * v * v + 1; }; -module.exports = MergeRect; +module.exports = Out; /***/ }), @@ -108390,33 +106473,19 @@ module.exports = MergeRect; /** * [description] * - * @function Phaser.Geom.Rectangle.MergeXY + * @function Phaser.Math.Easing.Cubic.In * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} target - [description] - * @param {number} x - [description] - * @param {number} y - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var MergeXY = function (target, x, y) +var In = function (v) { - var minX = Math.min(target.x, x); - var maxX = Math.max(target.right, x); - - target.x = minX; - target.width = maxX - minX; - - var minY = Math.min(target.y, y); - var maxY = Math.max(target.bottom, y); - - target.y = minY; - target.height = maxY - minY; - - return target; + return v * v * v; }; -module.exports = MergeXY; +module.exports = In; /***/ }), @@ -108432,24 +106501,26 @@ module.exports = MergeXY; /** * [description] * - * @function Phaser.Geom.Rectangle.Offset + * @function Phaser.Math.Easing.Circular.InOut * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var Offset = function (rect, x, y) +var InOut = function (v) { - rect.x += x; - rect.y += y; - - return rect; + if ((v *= 2) < 1) + { + return -0.5 * (Math.sqrt(1 - v * v) - 1); + } + else + { + return 0.5 * (Math.sqrt(1 - (v -= 2) * v) + 1); + } }; -module.exports = Offset; +module.exports = InOut; /***/ }), @@ -108465,23 +106536,19 @@ module.exports = Offset; /** * [description] * - * @function Phaser.Geom.Rectangle.OffsetPoint + * @function Phaser.Math.Easing.Circular.Out * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Point} point - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var OffsetPoint = function (rect, point) +var Out = function (v) { - rect.x += point.x; - rect.y += point.y; - - return rect; + return Math.sqrt(1 - (--v * v)); }; -module.exports = OffsetPoint; +module.exports = Out; /***/ }), @@ -108497,30 +106564,24 @@ module.exports = OffsetPoint; /** * [description] * - * @function Phaser.Geom.Rectangle.Overlaps + * @function Phaser.Math.Easing.Circular.In * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] + * @param {number} v - [description] * - * @return {boolean} [description] + * @return {number} [description] */ -var Overlaps = function (rectA, rectB) +var In = function (v) { - return ( - rectA.x < rectB.right && - rectA.right > rectB.x && - rectA.y < rectB.bottom && - rectA.bottom > rectB.y - ); + return 1 - Math.sqrt(1 - v * v); }; -module.exports = Overlaps; +module.exports = In; /***/ }), /* 743 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -108528,49 +106589,58 @@ module.exports = Overlaps; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); -var DegToRad = __webpack_require__(35); - /** * [description] * - * @function Phaser.Geom.Rectangle.PerimeterPoint + * @function Phaser.Math.Easing.Bounce.InOut * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rectangle - [description] - * @param {integer} angle - [description] - * @param {Phaser.Geom.Point} [out] - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Point} [description] + * @return {number} [description] */ -var PerimeterPoint = function (rectangle, angle, out) +var InOut = function (v) { - if (out === undefined) { out = new Point(); } + var reverse = false; - angle = DegToRad(angle); - - var s = Math.sin(angle); - var c = Math.cos(angle); - - var dx = (c > 0) ? rectangle.width / 2 : rectangle.width / -2; - var dy = (s > 0) ? rectangle.height / 2 : rectangle.height / -2; - - if (Math.abs(dx * s) < Math.abs(dy * c)) + if (v < 0.5) { - dy = (dx * s) / c; + v = 1 - (v * 2); + reverse = true; } else { - dx = (dy * c) / s; + v = (v * 2) - 1; } - out.x = dx + rectangle.centerX; - out.y = dy + rectangle.centerY; + if (v < 1 / 2.75) + { + v = 7.5625 * v * v; + } + else if (v < 2 / 2.75) + { + v = 7.5625 * (v -= 1.5 / 2.75) * v + 0.75; + } + else if (v < 2.5 / 2.75) + { + v = 7.5625 * (v -= 2.25 / 2.75) * v + 0.9375; + } + else + { + v = 7.5625 * (v -= 2.625 / 2.75) * v + 0.984375; + } - return out; + if (reverse) + { + return (1 - v) * 0.5; + } + else + { + return v * 0.5 + 0.5; + } }; -module.exports = PerimeterPoint; +module.exports = InOut; /***/ }), @@ -108583,36 +106653,42 @@ module.exports = PerimeterPoint; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Scales the width and height of this Rectangle by the given amounts. - /** * [description] * - * @function Phaser.Geom.Rectangle.Scale + * @function Phaser.Math.Easing.Bounce.Out * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var Scale = function (rect, x, y) +var Out = function (v) { - if (y === undefined) { y = x; } - - rect.width *= x; - rect.height *= y; - - return rect; + if (v < 1 / 2.75) + { + return 7.5625 * v * v; + } + else if (v < 2 / 2.75) + { + return 7.5625 * (v -= 1.5 / 2.75) * v + 0.75; + } + else if (v < 2.5 / 2.75) + { + return 7.5625 * (v -= 2.25 / 2.75) * v + 0.9375; + } + else + { + return 7.5625 * (v -= 2.625 / 2.75) * v + 0.984375; + } }; -module.exports = Scale; +module.exports = Out; /***/ }), /* 745 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -108620,41 +106696,44 @@ module.exports = Scale; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Rectangle = __webpack_require__(8); - /** * [description] * - * @function Phaser.Geom.Rectangle.Union + * @function Phaser.Math.Easing.Bounce.In * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] - * @param {Phaser.Geom.Rectangle} [out] - [description] + * @param {number} v - [description] * - * @return {Phaser.Geom.Rectangle} [description] + * @return {number} [description] */ -var Union = function (rectA, rectB, out) +var In = function (v) { - if (out === undefined) { out = new Rectangle(); } + v = 1 - v; - var x = Math.min(rectA.x, rectB.x); - var y = Math.min(rectA.y, rectB.y); - - return out.setTo( - x, - y, - Math.max(rectA.right, rectB.right) - x, - Math.max(rectA.bottom, rectB.bottom) - y - ); + if (v < 1 / 2.75) + { + return 1 - (7.5625 * v * v); + } + else if (v < 2 / 2.75) + { + return 1 - (7.5625 * (v -= 1.5 / 2.75) * v + 0.75); + } + else if (v < 2.5 / 2.75) + { + return 1 - (7.5625 * (v -= 2.25 / 2.75) * v + 0.9375); + } + else + { + return 1 - (7.5625 * (v -= 2.625 / 2.75) * v + 0.984375); + } }; -module.exports = Union; +module.exports = In; /***/ }), /* 746 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -108662,34 +106741,34 @@ module.exports = Union; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Triangle = __webpack_require__(56); +/** + * [description] + * + * @function Phaser.Math.Easing.Back.InOut + * @since 3.0.0 + * + * @param {number} v - [description] + * @param {number} [overshoot=1.70158] - [description] + * + * @return {number} [description] + */ +var InOut = function (v, overshoot) +{ + if (overshoot === undefined) { overshoot = 1.70158; } -Triangle.Area = __webpack_require__(747); -Triangle.BuildEquilateral = __webpack_require__(748); -Triangle.BuildFromPolygon = __webpack_require__(749); -Triangle.BuildRight = __webpack_require__(750); -Triangle.CenterOn = __webpack_require__(751); -Triangle.Centroid = __webpack_require__(311); -Triangle.CircumCenter = __webpack_require__(752); -Triangle.CircumCircle = __webpack_require__(753); -Triangle.Clone = __webpack_require__(754); -Triangle.Contains = __webpack_require__(54); -Triangle.ContainsArray = __webpack_require__(145); -Triangle.ContainsPoint = __webpack_require__(755); -Triangle.CopyFrom = __webpack_require__(756); -Triangle.Decompose = __webpack_require__(300); -Triangle.Equals = __webpack_require__(757); -Triangle.GetPoint = __webpack_require__(309); -Triangle.GetPoints = __webpack_require__(310); -Triangle.InCenter = __webpack_require__(313); -Triangle.Perimeter = __webpack_require__(758); -Triangle.Offset = __webpack_require__(312); -Triangle.Random = __webpack_require__(112); -Triangle.Rotate = __webpack_require__(759); -Triangle.RotateAroundPoint = __webpack_require__(760); -Triangle.RotateAroundXY = __webpack_require__(149); + var s = overshoot * 1.525; -module.exports = Triangle; + if ((v *= 2) < 1) + { + return 0.5 * (v * v * ((s + 1) * v - s)); + } + else + { + return 0.5 * ((v -= 2) * v * ((s + 1) * v + s) + 2); + } +}; + +module.exports = InOut; /***/ }), @@ -108702,38 +106781,30 @@ module.exports = Triangle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// The 2D area of a triangle. The area value is always non-negative. - /** * [description] * - * @function Phaser.Geom.Triangle.Area + * @function Phaser.Math.Easing.Back.Out * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} v - [description] + * @param {number} [overshoot=1.70158] - [description] * * @return {number} [description] */ -var Area = function (triangle) +var Out = function (v, overshoot) { - var x1 = triangle.x1; - var y1 = triangle.y1; + if (overshoot === undefined) { overshoot = 1.70158; } - var x2 = triangle.x2; - var y2 = triangle.y2; - - var x3 = triangle.x3; - var y3 = triangle.y3; - - return Math.abs(((x3 - x1) * (y2 - y1) - (x2 - x1) * (y3 - y1)) / 2); + return --v * v * ((overshoot + 1) * v + overshoot) + 1; }; -module.exports = Area; +module.exports = Out; /***/ }), /* 748 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -108741,44 +106812,25 @@ module.exports = Area; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Triangle = __webpack_require__(56); - -// Builds an equilateral triangle. -// In the equilateral triangle, all the sides are the same length (congruent) -// and all the angles are the same size (congruent). - -// The x/y specifies the top-middle of the triangle (x1/y1) and length -// is the length of each side - /** * [description] * - * @function Phaser.Geom.Triangle.BuildEquilateral + * @function Phaser.Math.Easing.Back.In * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} length - [description] + * @param {number} v - [description] + * @param {number} [overshoot=1.70158] - [description] * - * @return {Phaser.Geom.Triangle} [description] + * @return {number} [description] */ -var BuildEquilateral = function (x, y, length) +var In = function (v, overshoot) { - var height = length * (Math.sqrt(3) / 2); + if (overshoot === undefined) { overshoot = 1.70158; } - var x1 = x; - var y1 = y; - - var x2 = x + (length / 2); - var y2 = y + height; - - var x3 = x - (length / 2); - var y3 = y + height; - - return new Triangle(x1, y1, x2, y2, x3, y3); + return v * v * ((overshoot + 1) * v - overshoot); }; -module.exports = BuildEquilateral; +module.exports = In; /***/ }), @@ -108791,68 +106843,76 @@ module.exports = BuildEquilateral; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var EarCut = __webpack_require__(238); -var Triangle = __webpack_require__(56); +var Back = __webpack_require__(262); +var Bounce = __webpack_require__(261); +var Circular = __webpack_require__(260); +var Cubic = __webpack_require__(259); +var Elastic = __webpack_require__(258); +var Expo = __webpack_require__(257); +var Linear = __webpack_require__(256); +var Quadratic = __webpack_require__(255); +var Quartic = __webpack_require__(254); +var Quintic = __webpack_require__(253); +var Sine = __webpack_require__(252); +var Stepped = __webpack_require__(251); -/** - * [description] - * - * @function Phaser.Geom.Triangle.BuildFromPolygon - * @since 3.0.0 - * - * @param {array} data - A flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...] - * @param {array} [?holes] - An array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). - * @param {float} [scaleX=1] - [description] - * @param {float} [scaleY=1] - [description] - * @param {array} [out] - [description] - * - * @return {Phaser.Geom.Triangle[]} [description] - */ -var BuildFromPolygon = function (data, holes, scaleX, scaleY, out) -{ - if (holes === undefined) { holes = null; } - if (scaleX === undefined) { scaleX = 1; } - if (scaleY === undefined) { scaleY = 1; } - if (out === undefined) { out = []; } +// EaseMap +module.exports = { - var tris = EarCut(data, holes); + Power0: Linear, + Power1: Quadratic.Out, + Power2: Cubic.Out, + Power3: Quartic.Out, + Power4: Quintic.Out, - var a; - var b; - var c; + Linear: Linear, + Quad: Quadratic.Out, + Cubic: Cubic.Out, + Quart: Quartic.Out, + Quint: Quintic.Out, + Sine: Sine.Out, + Expo: Expo.Out, + Circ: Circular.Out, + Elastic: Elastic.Out, + Back: Back.Out, + Bounce: Bounce.Out, + Stepped: Stepped, - var x1; - var y1; + 'Quad.easeIn': Quadratic.In, + 'Cubic.easeIn': Cubic.In, + 'Quart.easeIn': Quartic.In, + 'Quint.easeIn': Quintic.In, + 'Sine.easeIn': Sine.In, + 'Expo.easeIn': Expo.In, + 'Circ.easeIn': Circular.In, + 'Elastic.easeIn': Elastic.In, + 'Back.easeIn': Back.In, + 'Bounce.easeIn': Bounce.In, - var x2; - var y2; + 'Quad.easeOut': Quadratic.Out, + 'Cubic.easeOut': Cubic.Out, + 'Quart.easeOut': Quartic.Out, + 'Quint.easeOut': Quintic.Out, + 'Sine.easeOut': Sine.Out, + 'Expo.easeOut': Expo.Out, + 'Circ.easeOut': Circular.Out, + 'Elastic.easeOut': Elastic.Out, + 'Back.easeOut': Back.Out, + 'Bounce.easeOut': Bounce.Out, - var x3; - var y3; + 'Quad.easeInOut': Quadratic.InOut, + 'Cubic.easeInOut': Cubic.InOut, + 'Quart.easeInOut': Quartic.InOut, + 'Quint.easeInOut': Quintic.InOut, + 'Sine.easeInOut': Sine.InOut, + 'Expo.easeInOut': Expo.InOut, + 'Circ.easeInOut': Circular.InOut, + 'Elastic.easeInOut': Elastic.InOut, + 'Back.easeInOut': Back.InOut, + 'Bounce.easeInOut': Bounce.InOut - for (var i = 0; i < tris.length; i += 3) - { - a = tris[i]; - b = tris[i + 1]; - c = tris[i + 2]; - - x1 = data[a * 2] * scaleX; - y1 = data[(a * 2) + 1] * scaleY; - - x2 = data[b * 2] * scaleX; - y2 = data[(b * 2) + 1] * scaleY; - - x3 = data[c * 2] * scaleX; - y3 = data[(c * 2) + 1] * scaleY; - - out.push(new Triangle(x1, y1, x2, y2, x3, y3)); - } - - return out; }; -module.exports = BuildFromPolygon; - /***/ }), /* 750 */ @@ -108864,43 +106924,576 @@ module.exports = BuildFromPolygon; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Triangle = __webpack_require__(56); - -// Builds a right triangle, with one 90 degree angle and two acute angles -// The x/y is the coordinate of the 90 degree angle (and will map to x1/y1 in the resulting Triangle) -// w/h can be positive or negative and represent the length of each side +var Class = __webpack_require__(0); +var FloatBetween = __webpack_require__(263); +var GetEaseFunction = __webpack_require__(71); +var GetFastValue = __webpack_require__(2); +var Wrap = __webpack_require__(43); /** + * The returned value sets what the property will be at the START of the particles life, on emit. + * @callback EmitterOpOnEmitCallback + * + * @param {Phaser.GameObjects.Particles.Particle} particle - [description] + * @param {string} key - [description] + * @param {number} value - [description] + * + * @return {number} [description] + */ + +/** + * The returned value updates the property for the duration of the particles life. + * @callback EmitterOpOnUpdateCallback + * + * @param {Phaser.GameObjects.Particles.Particle} particle - [description] + * @param {string} key - [description] + * @param {float} t - The T value (between 0 and 1) + * @param {number} value - [description] + * + * @return {number} [description] + */ + +/** + * @classdesc * [description] * - * @function Phaser.Geom.Triangle.BuildRight + * @class EmitterOp + * @memberOf Phaser.GameObjects.Particles + * @constructor * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Geom.Triangle} [description] + * @param {object} config - [description] + * @param {string} key - [description] + * @param {number} defaultValue - [description] + * @param {boolean} [emitOnly=false] - [description] */ -var BuildRight = function (x, y, width, height) -{ - if (height === undefined) { height = width; } +var EmitterOp = new Class({ - // 90 degree angle - var x1 = x; - var y1 = y; + initialize: - var x2 = x; - var y2 = y - height; + function EmitterOp (config, key, defaultValue, emitOnly) + { + if (emitOnly === undefined) { emitOnly = false; } - var x3 = x + width; - var y3 = y; + /** + * [description] + * + * @name Phaser.GameObjects.Particles.EmitterOp#propertyKey + * @type {string} + * @since 3.0.0 + */ + this.propertyKey = key; - return new Triangle(x1, y1, x2, y2, x3, y3); -}; + /** + * [description] + * + * @name Phaser.GameObjects.Particles.EmitterOp#propertyValue + * @type {number} + * @since 3.0.0 + */ + this.propertyValue = defaultValue; -module.exports = BuildRight; + /** + * [description] + * + * @name Phaser.GameObjects.Particles.EmitterOp#defaultValue + * @type {number} + * @since 3.0.0 + */ + this.defaultValue = defaultValue; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.EmitterOp#steps + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.steps = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.EmitterOp#counter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.counter = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.EmitterOp#start + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.start = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.EmitterOp#end + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.end = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.EmitterOp#ease + * @type {?function} + * @since 3.0.0 + */ + this.ease; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.EmitterOp#emitOnly + * @type {boolean} + * @since 3.0.0 + */ + this.emitOnly = emitOnly; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.EmitterOp#onEmit + * @type {EmitterOpOnEmitCallback} + * @since 3.0.0 + */ + this.onEmit = this.defaultEmit; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.EmitterOp#onUpdate + * @type {EmitterOpOnUpdateCallback} + * @since 3.0.0 + */ + this.onUpdate = this.defaultUpdate; + + this.loadConfig(config); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#loadConfig + * @since 3.0.0 + * + * @param {object} config - [description] + * @param {string} newKey - [description] + */ + loadConfig: function (config, newKey) + { + if (config === undefined) { config = {}; } + + if (newKey) + { + this.propertyKey = newKey; + } + + this.propertyValue = GetFastValue(config, this.propertyKey, this.defaultValue); + + this.setMethods(); + + if (this.emitOnly) + { + // Reset it back again + this.onUpdate = this.defaultUpdate; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#toJSON + * @since 3.0.0 + * + * @return {object} [description] + */ + toJSON: function () + { + return JSON.stringify(this.propertyValue); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#onChange + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.EmitterOp} This Emitter Op object. + */ + onChange: function (value) + { + this.propertyValue = value; + + return this.setMethods(); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#setMethods + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.EmitterOp} This Emitter Op object. + */ + setMethods: function () + { + var value = this.propertyValue; + + var t = typeof(value); + + if (t === 'number') + { + // Explicit static value: + // x: 400 + + this.onEmit = this.staticValueEmit; + this.onUpdate = this.staticValueUpdate; + } + else if (Array.isArray(value)) + { + // Picks a random element from the array: + // x: [ 100, 200, 300, 400 ] + + this.onEmit = this.randomStaticValueEmit; + } + else if (t === 'function') + { + // The same as setting just the onUpdate function and no onEmit (unless this op is an emitOnly one) + // Custom callback, must return a value: + + /* + x: function (particle, key, t, value) + { + return value + 50; + } + */ + + if (this.emitOnly) + { + this.onEmit = value; + } + else + { + this.onUpdate = value; + } + } + else if (t === 'object' && (this.has(value, 'random') || this.hasBoth(value, 'start', 'end') || this.hasBoth(value, 'min', 'max'))) + { + this.start = (this.has(value, 'start')) ? value.start : value.min; + this.end = (this.has(value, 'end')) ? value.end : value.max; + + var isRandom = (this.hasBoth(value, 'min', 'max') || this.has(value, 'random')); + + // A random starting value (using 'min | max' instead of 'start | end' automatically implies a random value) + + // x: { start: 100, end: 400, random: true } OR { min: 100, max: 400 } OR { random: [ 100, 400 ] } + + if (isRandom) + { + var rnd = value.random; + + // x: { random: [ 100, 400 ] } = the same as doing: x: { start: 100, end: 400, random: true } + if (Array.isArray(rnd)) + { + this.start = rnd[0]; + this.end = rnd[1]; + } + + this.onEmit = this.randomRangedValueEmit; + } + + if (this.has(value, 'steps')) + { + // A stepped (per emit) range + + // x: { start: 100, end: 400, steps: 64 } + + // Increments a value stored in the emitter + + this.steps = value.steps; + this.counter = this.start; + + this.onEmit = this.steppedEmit; + } + else + { + // An eased range (defaults to Linear if not specified) + + // x: { start: 100, end: 400, [ ease: 'Linear' ] } + + var easeType = (this.has(value, 'ease')) ? value.ease : 'Linear'; + + this.ease = GetEaseFunction(easeType); + + if (!isRandom) + { + this.onEmit = this.easedValueEmit; + } + + this.onUpdate = this.easeValueUpdate; + } + } + else if (t === 'object' && this.hasEither(value, 'onEmit', 'onUpdate')) + { + // Custom onEmit and onUpdate callbacks + + /* + x: { + // Called at the start of the particles life, when it is being created + onEmit: function (particle, key, t, value) + { + return value; + }, + + // Called during the particles life on each update + onUpdate: function (particle, key, t, value) + { + return value; + } + } + */ + + if (this.has(value, 'onEmit')) + { + this.onEmit = value.onEmit; + } + + if (this.has(value, 'onUpdate')) + { + this.onUpdate = value.onUpdate; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#has + * @since 3.0.0 + * + * @param {object} object - [description] + * @param {string} key - [description] + * + * @return {boolean} [description] + */ + has: function (object, key) + { + return (object.hasOwnProperty(key)); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#hasBoth + * @since 3.0.0 + * + * @param {object} object - [description] + * @param {string} key1 - [description] + * @param {string} key2 - [description] + * + * @return {boolean} [description] + */ + hasBoth: function (object, key1, key2) + { + return (object.hasOwnProperty(key1) && object.hasOwnProperty(key2)); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#hasEither + * @since 3.0.0 + * + * @param {object} object - [description] + * @param {string} key1 - [description] + * @param {string} key2 - [description] + * + * @return {boolean} [description] + */ + hasEither: function (object, key1, key2) + { + return (object.hasOwnProperty(key1) || object.hasOwnProperty(key2)); + }, + + /** + * The returned value sets what the property will be at the START of the particles life, on emit. + * + * @method Phaser.GameObjects.Particles.EmitterOp#defaultEmit + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - [description] + * @param {string} key - [description] + * @param {number} value - [description] + * + * @return {number} [description] + */ + defaultEmit: function (particle, key, value) + { + return value; + }, + + /** + * The returned value updates the property for the duration of the particles life. + * + * @method Phaser.GameObjects.Particles.EmitterOp#defaultUpdate + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - [description] + * @param {string} key - [description] + * @param {float} t - The T value (between 0 and 1) + * @param {number} value - [description] + * + * @return {number} [description] + */ + defaultUpdate: function (particle, key, t, value) + { + return value; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#staticValueEmit + * @since 3.0.0 + * + * @return {number} [description] + */ + staticValueEmit: function () + { + return this.propertyValue; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#staticValueUpdate + * @since 3.0.0 + * + * @return {number} [description] + */ + staticValueUpdate: function () + { + return this.propertyValue; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#randomStaticValueEmit + * @since 3.0.0 + * + * @return {number} [description] + */ + randomStaticValueEmit: function () + { + var randomIndex = Math.floor(Math.random() * this.propertyValue.length); + + return this.propertyValue[randomIndex]; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#randomRangedValueEmit + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - [description] + * @param {string} key - [description] + * + * @return {number} [description] + */ + randomRangedValueEmit: function (particle, key) + { + var value = FloatBetween(this.start, this.end); + + if (particle && particle.data[key]) + { + particle.data[key].min = value; + } + + return value; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#steppedEmit + * @since 3.0.0 + * + * @return {number} [description] + */ + steppedEmit: function () + { + var current = this.counter; + + var next = this.counter + ((this.end - this.start) / this.steps); + + this.counter = Wrap(next, this.start, this.end); + + return current; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#easedValueEmit + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - [description] + * @param {string} key - [description] + * + * @return {number} [description] + */ + easedValueEmit: function (particle, key) + { + if (particle && particle.data[key]) + { + var data = particle.data[key]; + + data.min = this.start; + data.max = this.end; + } + + return this.start; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.EmitterOp#easeValueUpdate + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - [description] + * @param {string} key - [description] + * @param {float} t - The T value (between 0 and 1) + * + * @return {number} [description] + */ + easeValueUpdate: function (particle, key, t) + { + var data = particle.data[key]; + + return (data.max - data.min) * this.ease(t) + data.min; + } + +}); + +module.exports = EmitterOp; /***/ }), @@ -108913,42 +107506,238 @@ module.exports = BuildRight; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Centroid = __webpack_require__(311); -var Offset = __webpack_require__(312); +var Class = __webpack_require__(0); /** + * @classdesc * [description] * - * @function Phaser.Geom.Triangle.CenterOn + * @class EdgeZone + * @memberOf Phaser.GameObjects.Particles.Zones + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {function} [centerFunc] - [description] - * - * @return {Phaser.Geom.Triangle} [description] + * @param {object} source - [description] + * @param {number} quantity - [description] + * @param {number} stepRate - [description] + * @param {boolean} yoyo - [description] + * @param {boolean} seamless - [description] */ -var CenterOn = function (triangle, x, y, centerFunc) -{ - if (centerFunc === undefined) { centerFunc = Centroid; } +var EdgeZone = new Class({ - // Get the center of the triangle - var center = centerFunc(triangle); + initialize: - // Difference - var diffX = x - center.x; - var diffY = y - center.y; + function EdgeZone (source, quantity, stepRate, yoyo, seamless) + { + if (yoyo === undefined) { yoyo = false; } + if (seamless === undefined) { seamless = true; } - return Offset(triangle, diffX, diffY); -}; + /** + * [description] + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#source + * @type {object} + * @since 3.0.0 + */ + this.source = source; -module.exports = CenterOn; + /** + * [description] + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#points + * @type {Phaser.Geom.Point[]} + * @default [] + * @since 3.0.0 + */ + this.points = []; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#quantity + * @type {number} + * @since 3.0.0 + */ + this.quantity = quantity; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#stepRate + * @type {number} + * @since 3.0.0 + */ + this.stepRate = stepRate; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#yoyo + * @type {boolean} + * @since 3.0.0 + */ + this.yoyo = yoyo; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#counter + * @type {number} + * @default -1 + * @since 3.0.0 + */ + this.counter = -1; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#seamless + * @type {boolean} + * @since 3.0.0 + */ + this.seamless = seamless; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#_length + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._length = 0; + + /** + * 0 = forwards, 1 = backwards + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#_direction + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._direction = 0; + + this.updateSource(); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.Zones.EdgeZone#updateSource + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.Zones.EdgeZone} This Edge Zone. + */ + updateSource: function () + { + this.points = this.source.getPoints(this.quantity, this.stepRate); + + // Remove ends? + if (this.seamless) + { + var a = this.points[0]; + var b = this.points[this.points.length - 1]; + + if (a.x === b.x && a.y === b.y) + { + this.points.pop(); + } + } + + var oldLength = this._length; + + this._length = this.points.length; + + // Adjust counter if we now have less points than before + if (this._length < oldLength && this.counter > this._length) + { + this.counter = this._length - 1; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.Zones.EdgeZone#changeSource + * @since 3.0.0 + * + * @param {object} source - [description] + * + * @return {Phaser.GameObjects.Particles.Zones.EdgeZone} This Edge Zone. + */ + changeSource: function (source) + { + this.source = source; + + return this.updateSource(); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.Zones.EdgeZone#getPoint + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - [description] + */ + getPoint: function (particle) + { + if (this._direction === 0) + { + this.counter++; + + if (this.counter >= this._length) + { + if (this.yoyo) + { + this._direction = 1; + this.counter = this._length - 1; + } + else + { + this.counter = 0; + } + } + } + else + { + this.counter--; + + if (this.counter === -1) + { + if (this.yoyo) + { + this._direction = 0; + this.counter = 0; + } + else + { + this.counter = this._length - 1; + } + } + } + + var point = this.points[this.counter]; + + if (point) + { + particle.x = point.x; + particle.y = point.y; + } + } + +}); + +module.exports = EdgeZone; /***/ }), /* 752 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -108956,62 +107745,72 @@ module.exports = CenterOn; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Adapted from http://bjornharrtell.github.io/jsts/doc/api/jsts_geom_Triangle.js.html +var Class = __webpack_require__(0); /** - * Computes the determinant of a 2x2 matrix. Uses standard double-precision - * arithmetic, so is susceptible to round-off error. + * @classdesc + * A Death Zone. * - * @param {Number} - * m00 the [0,0] entry of the matrix. - * @param {Number} - * m01 the [0,1] entry of the matrix. - * @param {Number} - * m10 the [1,0] entry of the matrix. - * @param {Number} - * m11 the [1,1] entry of the matrix. - * @return {Number} the determinant. + * A Death Zone is a special type of zone that will kill a Particle as soon as it either enters, or leaves, the zone. + * + * The zone consists of a `source` which could be a Geometric shape, such as a Rectangle or Ellipse, or your own + * object as long as it includes a `contains` method for which the Particles can be tested against. + * + * @class DeathZone + * @memberOf Phaser.GameObjects.Particles.Zones + * @constructor + * @since 3.0.0 + * + * @param {object} source - An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. + * @param {boolean} killOnEnter - Should the Particle be killed when it enters the zone? `true` or leaves it? `false` */ -function det (m00, m01, m10, m11) -{ - return (m00 * m11) - (m01 * m10); -} +var DeathZone = new Class({ -/** - * Computes the circumcentre of a triangle. The circumcentre is the centre of - * the circumcircle, the smallest circle which encloses the triangle. It is also - * the common intersection point of the perpendicular bisectors of the sides of - * the triangle, and is the only point which has equal distance to all three - * vertices of the triangle. - *

- * This method uses an algorithm due to J.R.Shewchuk which uses normalization to - * the origin to improve the accuracy of computation. (See Lecture Notes on - * Geometric Robustness, Jonathan Richard Shewchuk, 1999). - */ -var CircumCenter = function (triangle, out) -{ - if (out === undefined) { out = { x: 0, y: 0 }; } + initialize: - var cx = triangle.x3; - var cy = triangle.y3; + function DeathZone (source, killOnEnter) + { + /** + * An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. + * This could be a Geometry shape, such as `Phaser.Geom.Circle`, or your own custom object. + * + * @name Phaser.GameObjects.Particles.Zones.DeathZone#source + * @type {object} + * @since 3.0.0 + */ + this.source = source; - var ax = triangle.x1 - cx; - var ay = triangle.y1 - cy; + /** + * Set to `true` if the Particle should be killed if it enters this zone. + * Set to `false` to kill the Particle if it leaves this zone. + * + * @name Phaser.GameObjects.Particles.Zones.DeathZone#killOnEnter + * @type {boolean} + * @since 3.0.0 + */ + this.killOnEnter = killOnEnter; + }, - var bx = triangle.x2 - cx; - var by = triangle.y2 - cy; + /** + * Checks if the given Particle will be killed or not by this zone. + * + * @method Phaser.GameObjects.Particles.Zones.DeathZone#willKill + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle to be checked against this zone. + * + * @return {boolean} Return `true` if the Particle is to be killed, otherwise return `false`. + */ + willKill: function (particle) + { + var withinZone = this.source.contains(particle.x, particle.y); - var denom = 2 * det(ax, ay, bx, by); - var numx = det(ay, ax * ax + ay * ay, by, bx * bx + by * by); - var numy = det(ax, ax * ax + ay * ay, bx, bx * bx + by * by); + return (withinZone && this.killOnEnter || !withinZone && !this.killOnEnter); + } - out.x = cx - numx / denom; - out.y = cy + numy / denom; +}); - return out; -}; - -module.exports = CircumCenter; +module.exports = DeathZone; /***/ }), @@ -109024,75 +107823,1988 @@ module.exports = CircumCenter; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Circle = __webpack_require__(64); - -// Adapted from https://gist.github.com/mutoo/5617691 +var BlendModes = __webpack_require__(62); +var Class = __webpack_require__(0); +var Components = __webpack_require__(13); +var DeathZone = __webpack_require__(752); +var EdgeZone = __webpack_require__(751); +var EmitterOp = __webpack_require__(750); +var GetFastValue = __webpack_require__(2); +var GetRandomElement = __webpack_require__(132); +var HasAny = __webpack_require__(250); +var HasValue = __webpack_require__(70); +var Particle = __webpack_require__(716); +var RandomZone = __webpack_require__(715); +var Rectangle = __webpack_require__(10); +var StableSort = __webpack_require__(272); +var Vector2 = __webpack_require__(6); +var Wrap = __webpack_require__(43); /** + * @callback ParticleEmitterCallback + * + * @param {Phaser.GameObjects.Particles.Particle} particle - [description] + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - [description] + */ + +/** + * @callback ParticleDeathCallback + * + * @param {Phaser.GameObjects.Particles.Particle} particle - [description] + */ + +/** + * @classdesc * [description] * - * @function Phaser.Geom.Triangle.CircumCircle + * @class ParticleEmitter + * @memberOf Phaser.GameObjects.Particles + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Circle} [out] - [description] + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Visible * - * @return {Phaser.Geom.Circle} [description] + * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} manager - The Emitter Manager this Emitter belongs to. + * @param {object} config - [description] */ -var CircumCircle = function (triangle, out) -{ - if (out === undefined) { out = new Circle(); } +var ParticleEmitter = new Class({ - // A - var x1 = triangle.x1; - var y1 = triangle.y1; + Mixins: [ + Components.BlendMode, + Components.ScrollFactor, + Components.Visible + ], - // B - var x2 = triangle.x2; - var y2 = triangle.y2; + initialize: - // C - var x3 = triangle.x3; - var y3 = triangle.y3; - - var A = x2 - x1; - var B = y2 - y1; - var C = x3 - x1; - var D = y3 - y1; - var E = A * (x1 + x2) + B * (y1 + y2); - var F = C * (x1 + x3) + D * (y1 + y3); - var G = 2 * (A * (y3 - y2) - B * (x3 - x2)); - - var dx; - var dy; - - // If the points of the triangle are collinear, then just find the - // extremes and use the midpoint as the center of the circumcircle. - - if (Math.abs(G) < 0.000001) + function ParticleEmitter (manager, config) { - var minX = Math.min(x1, x2, x3); - var minY = Math.min(y1, y2, y3); - dx = (Math.max(x1, x2, x3) - minX) * 0.5; - dy = (Math.max(y1, y2, y3) - minY) * 0.5; + /** + * The Emitter Manager this Emitter belongs to. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#manager + * @type {Phaser.GameObjects.Particles.ParticleEmitterManager} + * @since 3.0.0 + */ + this.manager = manager; - out.x = minX + dx; - out.y = minY + dy; - out.radius = Math.sqrt(dx * dx + dy * dy); - } - else + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#texture + * @type {Phaser.Textures.Texture} + * @since 3.0.0 + */ + this.texture = manager.texture; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#frames + * @type {Phaser.Textures.Frame[]} + * @since 3.0.0 + */ + this.frames = [ manager.defaultFrame ]; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#defaultFrame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + this.defaultFrame = manager.defaultFrame; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#configFastMap + * @type {object} + * @since 3.0.0 + */ + this.configFastMap = [ + 'active', + 'blendMode', + 'collideBottom', + 'collideLeft', + 'collideRight', + 'collideTop', + 'deathCallback', + 'deathCallbackScope', + 'emitCallback', + 'emitCallbackScope', + 'follow', + 'frequency', + 'gravityX', + 'gravityY', + 'maxParticles', + 'name', + 'on', + 'particleBringToTop', + 'particleClass', + 'radial', + 'timeScale', + 'trackVisible', + 'visible' + ]; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#configOpMap + * @type {object} + * @since 3.0.0 + */ + this.configOpMap = [ + 'accelerationX', + 'accelerationY', + 'alpha', + 'bounce', + 'delay', + 'lifespan', + 'maxVelocityX', + 'maxVelocityY', + 'moveToX', + 'moveToY', + 'quantity', + 'rotate', + 'scaleX', + 'scaleY', + 'speedX', + 'speedY', + 'tint', + 'x', + 'y' + ]; + + /** + * The name of this Game Object. + * + * Empty by default and never populated by Phaser, this is left for developers to use. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * The Particle Class which will be emitted by this Emitter. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#particleClass + * @type {Phaser.GameObjects.Particles.Particle} + * @since 3.0.0 + */ + this.particleClass = Particle; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#x + * @type {number} + * @since 3.0.0 + */ + this.x = new EmitterOp(config, 'x', 0); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#y + * @type {number} + * @since 3.0.0 + */ + this.y = new EmitterOp(config, 'y', 0); + + /** + * A radial emitter will emit particles in all directions between angle min and max, + * using speed as the value. If set to false then this acts as a point Emitter. + * A point emitter will emit particles only in the direction derived from the speedX and speedY values. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#radial + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.radial = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#gravityX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.gravityX = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#gravityY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.gravityY = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#acceleration + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.acceleration = false; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#accelerationX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accelerationX = new EmitterOp(config, 'accelerationX', 0, true); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#accelerationY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accelerationY = new EmitterOp(config, 'accelerationY', 0, true); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityX + * @type {number} + * @default 10000 + * @since 3.0.0 + */ + this.maxVelocityX = new EmitterOp(config, 'maxVelocityX', 10000, true); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityY + * @type {number} + * @default 10000 + * @since 3.0.0 + */ + this.maxVelocityY = new EmitterOp(config, 'maxVelocityY', 10000, true); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#speedX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.speedX = new EmitterOp(config, 'speedX', 0, true); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#speedY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.speedY = new EmitterOp(config, 'speedY', 0, true); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#moveTo + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.moveTo = false; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#moveToX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.moveToX = new EmitterOp(config, 'moveToX', 0, true); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#moveToY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.moveToY = new EmitterOp(config, 'moveToY', 0, true); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#bounce + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.bounce = new EmitterOp(config, 'bounce', 0, true); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#scaleX + * @type {float} + * @default 1 + * @since 3.0.0 + */ + this.scaleX = new EmitterOp(config, 'scaleX', 1); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#scaleY + * @type {float} + * @default 1 + * @since 3.0.0 + */ + this.scaleY = new EmitterOp(config, 'scaleY', 1); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#tint + * @type {integer} + * @since 3.0.0 + */ + this.tint = new EmitterOp(config, 'tint', 0xffffffff); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#alpha + * @type {float} + * @default 1 + * @since 3.0.0 + */ + this.alpha = new EmitterOp(config, 'alpha', 1); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#lifespan + * @type {number} + * @default 1000 + * @since 3.0.0 + */ + this.lifespan = new EmitterOp(config, 'lifespan', 1000); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#angle + * @type {number} + * @since 3.0.0 + */ + this.angle = new EmitterOp(config, 'angle', { min: 0, max: 360 }); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#rotate + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.rotate = new EmitterOp(config, 'rotate', 0); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#emitCallback + * @type {?ParticleEmitterCallback} + * @default null + * @since 3.0.0 + */ + this.emitCallback = null; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope + * @type {?*} + * @default null + * @since 3.0.0 + */ + this.emitCallbackScope = null; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#deathCallback + * @type {?ParticleDeathCallback} + * @default null + * @since 3.0.0 + */ + this.deathCallback = null; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope + * @type {?*} + * @default null + * @since 3.0.0 + */ + this.deathCallbackScope = null; + + /** + * Set to hard limit the amount of particle objects this emitter is allowed to create. + * 0 means unlimited. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#maxParticles + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.maxParticles = 0; + + /** + * How many particles are emitted each time the emitter updates. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#quantity + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.quantity = new EmitterOp(config, 'quantity', 1, true); + + /** + * How many ms to wait after emission before the particles start updating. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#delay + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.delay = new EmitterOp(config, 'delay', 0, true); + + /** + * How often a particle is emitted in ms (if emitter is a constant / flow emitter) + * If emitter is an explosion emitter this value will be -1. + * Anything > -1 sets this to be a flow emitter. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#frequency + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.frequency = 0; + + /** + * Controls if the emitter is currently emitting particles. + * Already alive particles will continue to update until they expire. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#on + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.on = true; + + /** + * Newly emitted particles are added to the top of the particle list, i.e. rendered above those already alive. + * Set to false to send them to the back. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#particleBringToTop + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.particleBringToTop = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#emitZone + * @type {?object} + * @default null + * @since 3.0.0 + */ + this.emitZone = null; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#deathZone + * @type {?object} + * @default null + * @since 3.0.0 + */ + this.deathZone = null; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#bounds + * @type {?Phaser.Geom.Rectangle} + * @default null + * @since 3.0.0 + */ + this.bounds = null; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#collideLeft + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.collideLeft = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#collideRight + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.collideRight = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#collideTop + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.collideTop = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#collideBottom + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.collideBottom = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#visible + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.visible = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#blendMode + * @type {integer} + * @since 3.0.0 + */ + this.blendMode = BlendModes.NORMAL; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#follow + * @type {?Phaser.GameObjects.Particles.Particle} + * @default null + * @since 3.0.0 + */ + this.follow = null; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#followOffset + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.followOffset = new Vector2(); + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#trackVisible + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.trackVisible = false; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#currentFrame + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.currentFrame = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#randomFrame + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.randomFrame = true; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#frameQuantity + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.frameQuantity = 1; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#dead + * @type {Phaser.GameObjects.Particles.Particle[]} + * @private + * @since 3.0.0 + */ + this.dead = []; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#alive + * @type {Phaser.GameObjects.Particles.Particle[]} + * @private + * @since 3.0.0 + */ + this.alive = []; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#_counter + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._counter = 0; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#_frameCounter + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._frameCounter = 0; + + if (config) + { + this.fromJSON(config); + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#fromJSON + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + fromJSON: function (config) { - out.x = (D * E - B * F) / G; - out.y = (A * F - C * E) / G; - dx = out.x - x1; - dy = out.y - y1; - out.radius = Math.sqrt(dx * dx + dy * dy); + if (!config) + { + return this; + } + + // Only update properties from their current state if they exist in the given config + + var i = 0; + var key = ''; + + for (i = 0; i < this.configFastMap.length; i++) + { + key = this.configFastMap[i]; + + if (HasValue(config, key)) + { + this[key] = GetFastValue(config, key); + } + } + + for (i = 0; i < this.configOpMap.length; i++) + { + key = this.configOpMap[i]; + + if (HasValue(config, key)) + { + this[key].loadConfig(config); + } + } + + this.acceleration = (this.accelerationX.propertyValue !== 0 || this.accelerationY.propertyValue !== 0); + + this.moveTo = (this.moveToX.propertyValue !== 0 || this.moveToY.propertyValue !== 0); + + // Special 'speed' override + + if (HasValue(config, 'speed')) + { + this.speedX.loadConfig(config, 'speed'); + this.speedY = null; + } + + // If you specify speedX, speedY ot moveTo then it changes the emitter from radial to a point emitter + if (HasAny(config, [ 'speedX', 'speedY' ]) || this.moveTo) + { + this.radial = false; + } + + // Special 'scale' override + + if (HasValue(config, 'scale')) + { + this.scaleX.loadConfig(config, 'scale'); + this.scaleY = null; + } + + if (HasValue(config, 'callbackScope')) + { + var callbackScope = GetFastValue(config, 'callbackScope', null); + + this.emitCallbackScope = callbackScope; + this.deathCallbackScope = callbackScope; + } + + if (HasValue(config, 'emitZone')) + { + this.setEmitZone(config.emitZone); + } + + if (HasValue(config, 'deathZone')) + { + this.setDeathZone(config.deathZone); + } + + if (HasValue(config, 'bounds')) + { + this.setBounds(config.bounds); + } + + if (HasValue(config, 'followOffset')) + { + this.followOffset.setFromObject(GetFastValue(config, 'followOffset', 0)); + } + + if (HasValue(config, 'frame')) + { + this.setFrame(config.frame); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#toJSON + * @since 3.0.0 + * + * @param {object} output - [description] + * + * @return {object} [description] + */ + toJSON: function (output) + { + if (output === undefined) { output = {}; } + + var i = 0; + var key = ''; + + for (i = 0; i < this.configFastMap.length; i++) + { + key = this.configFastMap[i]; + + output[key] = this[key]; + } + + for (i = 0; i < this.configOpMap.length; i++) + { + key = this.configOpMap[i]; + + if (this[key]) + { + output[key] = this[key].toJSON(); + } + } + + // special handlers + if (!this.speedY) + { + delete output.speedX; + output.speed = this.speedX.toJSON(); + } + + if (!this.scaleY) + { + delete output.scaleX; + output.scale = this.scaleX.toJSON(); + } + + return output; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#startFollow + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} target - [description] + * @param {number} [offsetX=0] - [description] + * @param {number} [offsetY=0] - [description] + * @param {boolean} [trackVisible=false] - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + startFollow: function (target, offsetX, offsetY, trackVisible) + { + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + if (trackVisible === undefined) { trackVisible = false; } + + this.follow = target; + this.followOffset.set(offsetX, offsetY); + this.trackVisible = trackVisible; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#stopFollow + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + stopFollow: function () + { + this.follow = null; + this.followOffset.set(0, 0); + this.trackVisible = false; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getFrame + * @since 3.0.0 + * + * @return {Phaser.Textures.Frame} [description] + */ + getFrame: function () + { + if (this.frames.length === 1) + { + return this.defaultFrame; + } + else if (this.randomFrame) + { + return GetRandomElement(this.frames); + } + else + { + var frame = this.frames[this.currentFrame]; + + this._frameCounter++; + + if (this._frameCounter === this.frameQuantity) + { + this._frameCounter = 0; + this.currentFrame = Wrap(this.currentFrame + 1, 0, this._frameLength); + } + + return frame; + } + }, + + // frame: 0 + // frame: 'red' + // frame: [ 0, 1, 2, 3 ] + // frame: [ 'red', 'green', 'blue', 'pink', 'white' ] + // frame: { frames: [ 'red', 'green', 'blue', 'pink', 'white' ], [cycle: bool], [quantity: int] } + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setFrame + * @since 3.0.0 + * + * @param {(array|string|integer|object)} frames - [description] + * @param {boolean} [pickRandom=true] - [description] + * @param {integer} [quantity=1] - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setFrame: function (frames, pickRandom, quantity) + { + if (pickRandom === undefined) { pickRandom = true; } + if (quantity === undefined) { quantity = 1; } + + this.randomFrame = pickRandom; + this.frameQuantity = quantity; + this.currentFrame = 0; + this._frameCounter = 0; + + var t = typeof (frames); + + if (Array.isArray(frames) || t === 'string' || t === 'number') + { + this.manager.setEmitterFrames(frames, this); + } + else if (t === 'object') + { + var frameConfig = frames; + + frames = GetFastValue(frameConfig, 'frames', null); + + if (frames) + { + this.manager.setEmitterFrames(frames, this); + } + + var isCycle = GetFastValue(frameConfig, 'cycle', false); + + this.randomFrame = (isCycle) ? false : true; + + this.frameQuantity = GetFastValue(frameConfig, 'quantity', quantity); + } + + this._frameLength = this.frames.length; + + if (this._frameLength === 1) + { + this.frameQuantity = 1; + this.randomFrame = false; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setRadial + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setRadial: function (value) + { + if (value === undefined) { value = true; } + + this.radial = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setPosition + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setPosition: function (x, y) + { + this.x.onChange(x); + this.y.onChange(y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setBounds + * @since 3.0.0 + * + * @param {(number|object)} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setBounds: function (x, y, width, height) + { + if (typeof x === 'object') + { + var obj = x; + + x = obj.x; + y = obj.y; + width = (HasValue(obj, 'w')) ? obj.w : obj.width; + height = (HasValue(obj, 'h')) ? obj.h : obj.height; + } + + if (this.bounds) + { + this.bounds.setTo(x, y, width, height); + } + else + { + this.bounds = new Rectangle(x, y, width, height); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeedX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setSpeedX: function (value) + { + this.speedX.onChange(value); + + // If you specify speedX and Y then it changes the emitter from radial to a point emitter + this.radial = false; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeedY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setSpeedY: function (value) + { + if (this.speedY) + { + this.speedY.onChange(value); + + // If you specify speedX and Y then it changes the emitter from radial to a point emitter + this.radial = false; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeed + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setSpeed: function (value) + { + this.speedX.onChange(value); + this.speedY = null; + + // If you specify speedX and Y then it changes the emitter from radial to a point emitter + this.radial = true; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setScaleX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setScaleX: function (value) + { + this.scaleX.onChange(value); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setScaleY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setScaleY: function (value) + { + this.scaleY.onChange(value); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setScale + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setScale: function (value) + { + this.scaleX.onChange(value); + this.scaleY = null; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravityX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setGravityX: function (value) + { + this.gravityX = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravityY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setGravityY: function (value) + { + this.gravityY = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravity + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setGravity: function (x, y) + { + this.gravityX = x; + this.gravityY = y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setAlpha + * @since 3.0.0 + * + * @param {float} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setAlpha: function (value) + { + this.alpha.onChange(value); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setEmitterAngle + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setEmitterAngle: function (value) + { + this.angle.onChange(value); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setAngle + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setAngle: function (value) + { + this.angle.onChange(value); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setLifespan + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setLifespan: function (value) + { + this.lifespan.onChange(value); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setQuantity + * @since 3.0.0 + * + * @param {integer} quantity - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setQuantity: function (quantity) + { + this.quantity.onChange(quantity); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setFrequency + * @since 3.0.0 + * + * @param {number} frequency - [description] + * @param {integer} [quantity] - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setFrequency: function (frequency, quantity) + { + this.frequency = frequency; + + this._counter = 0; + + if (quantity) + { + this.quantity.onChange(quantity); + } + + return this; + }, + + /** + * The zone must have a function called `getPoint` that takes a particle object and sets + * its x and y properties accordingly then returns that object. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone + * @since 3.0.0 + * + * @param {object} [zoneConfig] - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setEmitZone: function (zoneConfig) + { + if (zoneConfig === undefined) + { + this.emitZone = null; + } + else + { + // Where source = Geom like Circle, or a Path or Curve + // emitZone: { type: 'random', source: X } + // emitZone: { type: 'edge', source: X, quantity: 32, [stepRate=0], [yoyo=false], [seamless=true] } + + var type = GetFastValue(zoneConfig, 'type', 'random'); + var source = GetFastValue(zoneConfig, 'source', null); + + if (source && typeof source.getPoint === 'function') + { + switch (type) + { + case 'random': + + this.emitZone = new RandomZone(source); + + break; + + case 'edge': + + var quantity = GetFastValue(zoneConfig, 'quantity', 1); + var stepRate = GetFastValue(zoneConfig, 'stepRate', 0); + var yoyo = GetFastValue(zoneConfig, 'yoyo', false); + var seamless = GetFastValue(zoneConfig, 'seamless', true); + + this.emitZone = new EdgeZone(source, quantity, stepRate, yoyo, seamless); + + break; + } + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setDeathZone + * @since 3.0.0 + * + * @param {object} [zoneConfig] - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setDeathZone: function (zoneConfig) + { + if (zoneConfig === undefined) + { + this.deathZone = null; + } + else + { + // Where source = Geom like Circle or Rect that supports a 'contains' function + // deathZone: { type: 'onEnter', source: X } + // deathZone: { type: 'onLeave', source: X } + + var type = GetFastValue(zoneConfig, 'type', 'onEnter'); + var source = GetFastValue(zoneConfig, 'source', null); + + if (source && typeof source.contains === 'function') + { + var killOnEnter = (type === 'onEnter') ? true : false; + + this.deathZone = new DeathZone(source, killOnEnter); + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#reserve + * @since 3.0.0 + * + * @param {integer} particleCount - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + reserve: function (particleCount) + { + var dead = this.dead; + + for (var i = 0; i < particleCount; i++) + { + dead.push(new this.particleClass(this)); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getAliveParticleCount + * @since 3.0.0 + * + * @return {integer} The number of currently alive Particles in this Emitter. + */ + getAliveParticleCount: function () + { + return this.alive.length; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getDeadParticleCount + * @since 3.0.0 + * + * @return {integer} The number of currently dead Particles in this Emitter. + */ + getDeadParticleCount: function () + { + return this.dead.length; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getParticleCount + * @since 3.0.0 + * + * @return {integer} The number of Particles in this Emitter, including both alive and dead. + */ + getParticleCount: function () + { + return this.getAliveParticleCount() + this.getDeadParticleCount(); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#atLimit + * @since 3.0.0 + * + * @return {boolean} Returns `true` if this Emitter is at its limit, or `false` if no limit, or below the `maxParticles` level. + */ + atLimit: function () + { + return (this.maxParticles > 0 && this.getParticleCount() === this.maxParticles); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#onParticleEmit + * @since 3.0.0 + * + * @param {ParticleEmitterCallback} callback - [description] + * @param {*} [context] - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + onParticleEmit: function (callback, context) + { + if (callback === undefined) + { + // Clear any previously set callback + this.emitCallback = null; + this.emitCallbackScope = null; + } + else if (typeof callback === 'function') + { + this.emitCallback = callback; + + if (context) + { + this.emitCallbackScope = context; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#onParticleDeath + * @since 3.0.0 + * + * @param {ParticleDeathCallback} callback - [description] + * @param {*} [context] - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + onParticleDeath: function (callback, context) + { + if (callback === undefined) + { + // Clear any previously set callback + this.deathCallback = null; + this.deathCallbackScope = null; + } + else if (typeof callback === 'function') + { + this.deathCallback = callback; + + if (context) + { + this.deathCallbackScope = context; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#killAll + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + killAll: function () + { + var dead = this.dead; + var alive = this.alive; + + while (alive.length > 0) + { + dead.push(alive.pop()); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#forEachAlive + * @since 3.0.0 + * + * @param {ParticleEmitterCallback} callback - [description] + * @param {*} thisArg - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + forEachAlive: function (callback, thisArg) + { + var alive = this.alive; + var length = alive.length; + + for (var index = 0; index < length; ++index) + { + // Sends the Particle and the Emitter + callback.call(thisArg, alive[index], this); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#forEachDead + * @since 3.0.0 + * + * @param {ParticleEmitterCallback} callback - [description] + * @param {*} thisArg - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + forEachDead: function (callback, thisArg) + { + var dead = this.dead; + var length = dead.length; + + for (var index = 0; index < length; ++index) + { + // Sends the Particle and the Emitter + callback.call(thisArg, dead[index], this); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#start + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + start: function () + { + this.on = true; + + this._counter = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#pause + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + pause: function () + { + this.active = false; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#resume + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + resume: function () + { + this.active = true; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#depthSort + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + depthSort: function () + { + StableSort.inplace(this.alive, this.depthSortCallback); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#flow + * @since 3.0.0 + * + * @param {number} frequency - [description] + * @param {integer} [count=1] - [description] + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + flow: function (frequency, count) + { + if (count === undefined) { count = 1; } + + this.frequency = frequency; + + this.quantity.onChange(count); + + return this.start(); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#explode + * @since 3.0.0 + * + * @param {integer} count - The amount of Particles to emit. + * @param {number} x - The x coordinate to emit the Particles from. + * @param {number} y - The y coordinate to emit the Particles from. + * + * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. + */ + explode: function (count, x, y) + { + this.frequency = -1; + + return this.emitParticle(count, x, y); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#emitParticleAt + * @since 3.0.0 + * + * @param {number} x - The x coordinate to emit the Particles from. + * @param {number} y - The y coordinate to emit the Particles from. + * @param {integer} count - The amount of Particles to emit. + * + * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. + */ + emitParticleAt: function (x, y, count) + { + return this.emitParticle(count, x, y); + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#emitParticle + * @since 3.0.0 + * + * @param {integer} count - The amount of Particles to emit. + * @param {number} x - The x coordinate to emit the Particles from. + * @param {number} y - The y coordinate to emit the Particles from. + * + * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. + */ + emitParticle: function (count, x, y) + { + if (this.atLimit()) + { + return; + } + + if (count === undefined) + { + count = this.quantity.onEmit(); + } + + var dead = this.dead; + + for (var i = 0; i < count; i++) + { + var particle; + + if (dead.length > 0) + { + particle = dead.pop(); + } + else + { + particle = new this.particleClass(this); + } + + particle.fire(x, y); + + if (this.particleBringToTop) + { + this.alive.push(particle); + } + else + { + this.alive.unshift(particle); + } + + if (this.emitCallback) + { + this.emitCallback.call(this.emitCallbackScope, particle, this); + } + + if (this.atLimit()) + { + break; + } + } + + return particle; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#preUpdate + * @since 3.0.0 + * + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + preUpdate: function (time, delta) + { + // Scale the delta + delta *= this.timeScale; + + var step = (delta / 1000); + + if (this.trackVisible) + { + this.visible = this.follow.visible; + } + + // Any particle processors? + var processors = this.manager.getProcessors(); + + var particles = this.alive; + var length = particles.length; + + for (var index = 0; index < length; index++) + { + var particle = particles[index]; + + // update returns `true` if the particle is now dead (lifeStep < 0) + if (particle.update(delta, step, processors)) + { + // Moves the dead particle to the end of the particles array (ready for splicing out later) + var last = particles[length - 1]; + + particles[length - 1] = particle; + particles[index] = last; + + index -= 1; + length -= 1; + } + } + + // Move dead particles to the dead array + var deadLength = particles.length - length; + + if (deadLength > 0) + { + var rip = particles.splice(particles.length - deadLength, deadLength); + + var deathCallback = this.deathCallback; + var deathCallbackScope = this.deathCallbackScope; + + if (deathCallback) + { + for (var i = 0; i < rip.length; i++) + { + deathCallback.call(deathCallbackScope, rip[i]); + } + } + + this.dead.concat(rip); + + StableSort.inplace(particles, this.indexSortCallback); + } + + if (!this.on) + { + return; + } + + if (this.frequency === 0) + { + this.emitParticle(); + } + else if (this.frequency > 0) + { + this._counter -= delta; + + if (this._counter <= 0) + { + this.emitParticle(); + + // counter = frequency - remained from previous delta + this._counter = (this.frequency - Math.abs(this._counter)); + } + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#depthSortCallback + * @since 3.0.0 + * + * @param {object} a - [description] + * @param {object} b - [description] + * + * @return {integer} [description] + */ + depthSortCallback: function (a, b) + { + return a.y - b.y; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#indexSortCallback + * @since 3.0.0 + * + * @param {object} a - [description] + * @param {object} b - [description] + * + * @return {integer} [description] + */ + indexSortCallback: function (a, b) + { + return a.index - b.index; } - return out; -}; +}); -module.exports = CircumCircle; +module.exports = ParticleEmitter; /***/ }), @@ -109105,24 +109817,209 @@ module.exports = CircumCircle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Triangle = __webpack_require__(56); +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(2); /** + * @classdesc * [description] * - * @function Phaser.Geom.Triangle.Clone + * @class GravityWell + * @memberOf Phaser.GameObjects.Particles + * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} source - [description] - * - * @return {Phaser.Geom.Triangle} [description] + * @param {(number|object)} [x=0] - The x coordinate of the Gravity Well, in world space. + * @param {number} [y=0] - The y coordinate of the Gravity Well, in world space. + * @param {number} [power=0] - The power of the Gravity Well. + * @param {number} [epsilon=100] - [description] + * @param {number} [gravity=50] - The gravitational force of this Gravity Well. */ -var Clone = function (source) -{ - return new Triangle(source.x1, source.y1, source.x2, source.y2, source.x3, source.y3); -}; +var GravityWell = new Class({ -module.exports = Clone; + initialize: + + function GravityWell (x, y, power, epsilon, gravity) + { + if (typeof x === 'object') + { + var config = x; + + x = GetFastValue(config, 'x', 0); + y = GetFastValue(config, 'y', 0); + power = GetFastValue(config, 'power', 0); + epsilon = GetFastValue(config, 'epsilon', 100); + gravity = GetFastValue(config, 'gravity', 50); + } + else + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (power === undefined) { power = 0; } + if (epsilon === undefined) { epsilon = 100; } + if (gravity === undefined) { gravity = 50; } + } + + /** + * The x coordinate of the Gravity Well, in world space. + * + * @name Phaser.GameObjects.Particles.GravityWell#x + * @type {number} + * @since 3.0.0 + */ + this.x = x; + + /** + * The y coordinate of the Gravity Well, in world space. + * + * @name Phaser.GameObjects.Particles.GravityWell#y + * @type {number} + * @since 3.0.0 + */ + this.y = y; + + /** + * The active state of the Gravity Well. An inactive Gravity Well will not influence any particles. + * + * @name Phaser.GameObjects.Particles.GravityWell#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * Internal gravity value. + * + * @name Phaser.GameObjects.Particles.GravityWell#_gravity + * @type {number} + * @private + * @since 3.0.0 + */ + this._gravity = gravity; + + /** + * Internal power value. + * + * @name Phaser.GameObjects.Particles.GravityWell#_power + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._power = 0; + + /** + * Internal epsilon value. + * + * @name Phaser.GameObjects.Particles.GravityWell#_epsilon + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._epsilon = 0; + + /** + * The power of the Gravity Well. + * + * @name Phaser.GameObjects.Particles.GravityWell#power + * @type {number} + * @since 3.0.0 + */ + this.power = power; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.GravityWell#epsilon + * @type {number} + * @since 3.0.0 + */ + this.epsilon = epsilon; + }, + + /** + * Takes a Particle and updates it based on the properties of this Gravity Well. + * + * @method Phaser.GameObjects.Particles.GravityWell#update + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle to update. + * @param {number} delta - The delta time in ms. + * @param {float} step - The delta value divided by 1000. + */ + update: function (particle, delta) + { + var x = this.x - particle.x; + var y = this.y - particle.y; + var dSq = x * x + y * y; + + if (dSq === 0) + { + return; + } + + var d = Math.sqrt(dSq); + + if (dSq < this._epsilon) + { + dSq = this._epsilon; + } + + var factor = ((this._power * delta) / (dSq * d)) * 100; + + particle.velocityX += x * factor; + particle.velocityY += y * factor; + }, + + epsilon: { + + get: function () + { + return Math.sqrt(this._epsilon); + }, + + set: function (value) + { + this._epsilon = value * value; + } + + }, + + power: { + + get: function () + { + return this._power / this._gravity; + }, + + set: function (value) + { + this._power = value * this._gravity; + } + + }, + + gravity: { + + get: function () + { + return this._gravity; + }, + + set: function (value) + { + var pwr = this.power; + this._gravity = value; + this.power = pwr; + } + + } + +}); + +module.exports = GravityWell; /***/ }), @@ -109135,30 +110032,38 @@ module.exports = Clone; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Contains = __webpack_require__(54); +var GameObject = __webpack_require__(1); /** - * [description] + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. * - * @function Phaser.Geom.Triangle.ContainsPoint + * @method Phaser.GameObjects.Image#renderCanvas * @since 3.0.0 + * @private * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point} point - [description] - * - * @return {boolean} [description] + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Image} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. */ -var ContainsPoint = function (triangle, point) +var ImageCanvasRenderer = function (renderer, src, interpolationPercentage, camera) { - return Contains(triangle, point.x, point.y); + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + renderer.drawImage(src, camera); }; -module.exports = ContainsPoint; +module.exports = ImageCanvasRenderer; /***/ }), /* 756 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -109166,28 +110071,38 @@ module.exports = ContainsPoint; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var GameObject = __webpack_require__(1); + /** - * [description] + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. * - * @function Phaser.Geom.Triangle.CopyFrom + * @method Phaser.GameObjects.Image#renderWebGL * @since 3.0.0 + * @private * - * @param {Phaser.Geom.Triangle} source - [description] - * @param {Phaser.Geom.Triangle} dest - [description] - * - * @return {Phaser.Geom.Triangle} [description] + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Image} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. */ -var CopyFrom = function (source, dest) +var ImageWebGLRenderer = function (renderer, src, interpolationPercentage, camera) { - return dest.setTo(source.x1, source.y1, source.x2, source.y2, source.x3, source.y3); + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + this.pipeline.batchSprite(src, camera); }; -module.exports = CopyFrom; +module.exports = ImageWebGLRenderer; /***/ }), /* 757 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -109195,30 +110110,25 @@ module.exports = CopyFrom; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * [description] - * - * @function Phaser.Geom.Triangle.Equals - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Triangle} toCompare - [description] - * - * @return {boolean} [description] - */ -var Equals = function (triangle, toCompare) -{ - return ( - triangle.x1 === toCompare.x1 && - triangle.y1 === toCompare.y1 && - triangle.x2 === toCompare.x2 && - triangle.y2 === toCompare.y2 && - triangle.x3 === toCompare.x3 && - triangle.y3 === toCompare.y3 - ); -}; +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); -module.exports = Equals; +if (true) +{ + renderWebGL = __webpack_require__(756); +} + +if (true) +{ + renderCanvas = __webpack_require__(755); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; /***/ }), @@ -109231,30 +110141,33 @@ module.exports = Equals; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Length = __webpack_require__(66); - -// The 2D area of a triangle. The area value is always non-negative. +var GameObject = __webpack_require__(1); /** - * [description] + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. * - * @function Phaser.Geom.Triangle.Perimeter + * @method Phaser.GameObjects.Graphics#renderWebGL * @since 3.0.0 + * @private * - * @param {Phaser.Geom.Triangle} triangle - [description] - * - * @return {number} [description] + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Graphics} graphics - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. */ -var Perimeter = function (triangle) +var GraphicsWebGLRenderer = function (renderer, graphics, interpolationPercentage, camera) { - var line1 = triangle.getLineA(); - var line2 = triangle.getLineB(); - var line3 = triangle.getLineC(); + if (GameObject.RENDER_MASK !== graphics.renderFlags || (graphics.cameraFilter > 0 && (graphics.cameraFilter & camera._id))) + { + return; + } - return (Length(line1) + Length(line2) + Length(line3)); + this.pipeline.batchGraphics(this, camera); }; -module.exports = Perimeter; +module.exports = GraphicsWebGLRenderer; /***/ }), @@ -109267,33 +110180,33 @@ module.exports = Perimeter; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RotateAroundXY = __webpack_require__(149); -var InCenter = __webpack_require__(313); +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); -/** - * [description] - * - * @function Phaser.Geom.Triangle.Rotate - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Triangle} [description] - */ -var Rotate = function (triangle, angle) +if (true) { - var point = InCenter(triangle); + renderWebGL = __webpack_require__(758); + + // Needed for Graphics.generateTexture + renderCanvas = __webpack_require__(265); +} + +if (true) +{ + renderCanvas = __webpack_require__(265); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas - return RotateAroundXY(triangle, point.x, point.y, angle); }; -module.exports = Rotate; - /***/ }), /* 760 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -109301,31 +110214,31 @@ module.exports = Rotate; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RotateAroundXY = __webpack_require__(149); - /** - * [description] + * Offsets the Ellipse by the values given in the `x` and `y` properties of the Point object. * - * @function Phaser.Geom.Triangle.RotateAroundPoint + * @function Phaser.Geom.Ellipse.OffsetPoint * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point} point - [description] - * @param {number} angle - [description] + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to be offset (translated.) + * @param {(Phaser.Geom.Point|object)} point - The Point object containing the values to offset the Ellipse by. * - * @return {Phaser.Geom.Triangle} [description] + * @return {Phaser.Geom.Ellipse} The Ellipse that was offset. */ -var RotateAroundPoint = function (triangle, point, angle) +var OffsetPoint = function (ellipse, point) { - return RotateAroundXY(triangle, point.x, point.y, angle); + ellipse.x += point.x; + ellipse.y += point.y; + + return ellipse; }; -module.exports = RotateAroundPoint; +module.exports = OffsetPoint; /***/ }), /* 761 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -109334,22 +110247,27 @@ module.exports = RotateAroundPoint; */ /** - * @namespace Phaser.Input + * Offsets the Ellipse by the values given. + * + * @function Phaser.Geom.Ellipse.Offset + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to be offset (translated.) + * @param {number} x - The amount to horizontally offset the Ellipse by. + * @param {number} y - The amount to vertically offset the Ellipse by. + * + * @return {Phaser.Geom.Ellipse} The Ellipse that was offset. */ +var Offset = function (ellipse, x, y) +{ + ellipse.x += x; + ellipse.y += y; -module.exports = { - - Gamepad: __webpack_require__(762), - InputManager: __webpack_require__(240), - InputPlugin: __webpack_require__(767), - InteractiveObject: __webpack_require__(314), - Keyboard: __webpack_require__(768), - Mouse: __webpack_require__(773), - Pointer: __webpack_require__(249), - Touch: __webpack_require__(774) - + return ellipse; }; +module.exports = Offset; + /***/ }), /* 762 */ @@ -109361,24 +110279,37 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Rectangle = __webpack_require__(10); + /** - * @namespace Phaser.Input.Gamepad + * Returns the bounds of the Ellipse object. + * + * @function Phaser.Geom.Ellipse.GetBounds + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the bounds from. + * @param {(Phaser.Geom.Rectangle|object)} [out] - A Rectangle, or rectangle-like object, to store the ellipse bounds in. If not given a new Rectangle will be created. + * + * @return {(Phaser.Geom.Rectangle|object)} The Rectangle object containing the Ellipse bounds. */ +var GetBounds = function (ellipse, out) +{ + if (out === undefined) { out = new Rectangle(); } -module.exports = { + out.x = ellipse.left; + out.y = ellipse.top; + out.width = ellipse.width; + out.height = ellipse.height; - Axis: __webpack_require__(243), - Button: __webpack_require__(244), - Gamepad: __webpack_require__(242), - GamepadManager: __webpack_require__(241), - - Configs: __webpack_require__(763) + return out; }; +module.exports = GetBounds; + /***/ }), /* 763 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -109387,17 +110318,29 @@ module.exports = { */ /** - * @namespace Phaser.Input.Gamepad.Configs + * Compares the `x`, `y`, `width` and `height` properties of the two given Ellipses. + * Returns `true` if they all match, otherwise returns `false`. + * + * @function Phaser.Geom.Ellipse.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The first Ellipse to compare. + * @param {Phaser.Geom.Ellipse} toCompare - The second Ellipse to compare. + * + * @return {boolean} `true` if the two Ellipse equal each other, otherwise `false`. */ - -module.exports = { - - DUALSHOCK_4: __webpack_require__(764), - SNES_USB: __webpack_require__(765), - XBOX_360: __webpack_require__(766) - +var Equals = function (ellipse, toCompare) +{ + return ( + ellipse.x === toCompare.x && + ellipse.y === toCompare.y && + ellipse.width === toCompare.width && + ellipse.height === toCompare.height + ); }; +module.exports = Equals; + /***/ }), /* 764 */ @@ -109410,49 +110353,28 @@ module.exports = { */ /** - * PlayStation DualShock 4 Gamepad Configuration. - * Sony PlayStation DualShock 4 (v2) wireless controller - * - * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4 - * @type {object} + * Copies the `x`, `y`, `width` and `height` properties from the `source` Ellipse + * into the given `dest` Ellipse, then returns the `dest` Ellipse. + * + * @function Phaser.Geom.Ellipse.CopyFrom * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} source - The source Ellipse to copy the values from. + * @param {Phaser.Geom.Ellipse} dest - The destination Ellipse to copy the values to. + * + * @return {Phaser.Geom.Ellipse} The dest Ellipse. */ - -module.exports = { - - UP: 12, - DOWN: 13, - LEFT: 14, - RIGHT: 15, - - SHARE: 8, - OPTIONS: 9, - PS: 16, - TOUCHBAR: 17, - - X: 0, - CIRCLE: 1, - SQUARE: 2, - TRIANGLE: 3, - - L1: 4, - R1: 5, - L2: 6, - R2: 7, - L3: 10, - R3: 11, - - LEFT_STICK_H: 0, - LEFT_STICK_V: 1, - RIGHT_STICK_H: 2, - RIGHT_STICK_V: 3 - +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x, source.y, source.width, source.height); }; +module.exports = CopyFrom; + /***/ }), /* 765 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -109460,39 +110382,35 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Contains = __webpack_require__(74); + /** - * Tatar SNES USB Controller Gamepad Configuration. - * USB Gamepad (STANDARD GAMEPAD Vendor: 0079 Product: 0011) - * - * @name Phaser.Input.Gamepad.Configs.SNES_USB - * @type {object} + * Check to see if the Ellipse contains all four points of the given Rectangle object. + * + * @function Phaser.Geom.Ellipse.ContainsRect * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - [description] + * @param {(Phaser.Geom.Rectangle|object)} rect - The Rectangle object to check if it's within the Ellipse or not. + * + * @return {boolean} True if all of the Rectangle coordinates are within the ellipse, otherwise false. */ - -module.exports = { - - UP: 12, - DOWN: 13, - LEFT: 14, - RIGHT: 15, - - SELECT: 8, - START: 9, - - B: 0, - A: 1, - Y: 2, - X: 3, - - LEFT_SHOULDER: 4, - RIGHT_SHOULDER: 5 - +var ContainsRect = function (ellipse, rect) +{ + return ( + Contains(ellipse, rect.x, rect.y) && + Contains(ellipse, rect.right, rect.y) && + Contains(ellipse, rect.x, rect.bottom) && + Contains(ellipse, rect.right, rect.bottom) + ); }; +module.exports = ContainsRect; + /***/ }), /* 766 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -109500,47 +110418,26 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Contains = __webpack_require__(74); + /** - * XBox 360 Gamepad Configuration. - * - * @name Phaser.Input.Gamepad.Configs.XBOX_360 - * @type {object} + * Check to see if the Ellipse contains the given Point object. + * + * @function Phaser.Geom.Ellipse.ContainsPoint * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. + * @param {(Phaser.Geom.Point|object)} point - The Point object to check if it's within the Circle or not. + * + * @return {boolean} True if the Point coordinates are within the circle, otherwise false. */ - -module.exports = { - - UP: 12, - DOWN: 13, - LEFT: 14, - RIGHT: 15, - - MENU: 16, - - A: 0, - B: 1, - X: 2, - Y: 3, - - LB: 4, - RB: 5, - - LT: 6, - RT: 7, - - BACK: 8, - START: 9, - - LS: 10, - RS: 11, - - LEFT_STICK_H: 0, - LEFT_STICK_V: 1, - RIGHT_STICK_H: 2, - RIGHT_STICK_V: 3 - +var ContainsPoint = function (ellipse, point) +{ + return Contains(ellipse, point.x, point.y); }; +module.exports = ContainsPoint; + /***/ }), /* 767 */ @@ -109552,1633 +110449,62 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Circle = __webpack_require__(64); -var CircleContains = __webpack_require__(32); -var Class = __webpack_require__(0); -var DistanceBetween = __webpack_require__(42); -var Ellipse = __webpack_require__(137); -var EllipseContains = __webpack_require__(68); -var EventEmitter = __webpack_require__(14); -var InteractiveObject = __webpack_require__(314); -var PluginManager = __webpack_require__(12); -var Rectangle = __webpack_require__(8); -var RectangleContains = __webpack_require__(33); -var Triangle = __webpack_require__(56); -var TriangleContains = __webpack_require__(54); +var Ellipse = __webpack_require__(135); /** - * @classdesc - * [description] + * Creates a new Ellipse instance based on the values contained in the given source. * - * @class InputPlugin - * @extends EventEmitter - * @memberOf Phaser.Input - * @constructor + * @function Phaser.Geom.Ellipse.Clone * @since 3.0.0 * - * @param {Phaser.Scene} scene - The Scene that owns this plugin. + * @param {Phaser.Geom.Ellipse} source - The Ellipse to be cloned. Can be an instance of an Ellipse or a ellipse-like object, with x, y, width and height properties. + * + * @return {Phaser.Geom.Ellipse} A clone of the source Ellipse. */ -var InputPlugin = new Class({ +var Clone = function (source) +{ + return new Ellipse(source.x, source.y, source.width, source.height); +}; - Extends: EventEmitter, - - initialize: - - function InputPlugin (scene) - { - EventEmitter.call(this); - - /** - * The Scene that owns this plugin. - * - * @name Phaser.Input.InputPlugin#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.Input.InputPlugin#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - if (!scene.sys.settings.isBooted) - { - scene.sys.events.once('boot', this.boot, this); - } - - /** - * [description] - * - * @name Phaser.Input.InputPlugin#manager - * @type {Phaser.Input.InputManager} - * @since 3.0.0 - */ - this.manager = scene.sys.game.input; - - /** - * A reference to this.scene.sys.displayList (set in boot) - * - * @name Phaser.Input.InputPlugin#displayList - * @type {Phaser.GameObjects.DisplayList} - * @since 3.0.0 - */ - this.displayList; - - /** - * A reference to the this.scene.sys.cameras (set in boot) - * - * @name Phaser.Input.InputPlugin#cameras - * @type {null} - * @since 3.0.0 - */ - this.cameras; - - /** - * [description] - * - * @name Phaser.Input.InputPlugin#keyboard - * @type {Phaser.Input.Keyboard.KeyboardManager} - * @since 3.0.0 - */ - this.keyboard = this.manager.keyboard; - - /** - * [description] - * - * @name Phaser.Input.InputPlugin#mouse - * @type {Phaser.Input.Mouse.MouseManager} - * @since 3.0.0 - */ - this.mouse = this.manager.mouse; - - /** - * [description] - * - * @name Phaser.Input.InputPlugin#gamepad - * @type {Phaser.Input.Gamepad.GamepadManager} - * @since 3.0.0 - */ - this.gamepad = this.manager.gamepad; - - /** - * Only fire callbacks and events on the top-most Game Object in the display list (emulating DOM behavior) - * and ignore any GOs below it, or call them all? - * - * @name Phaser.Input.InputPlugin#topOnly - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.topOnly = true; - - /** - * How often should the pointer input be checked? - * Time given in ms - * Pointer will *always* be checked if it has been moved by the user. - * This controls how often it will be polled if it hasn't been moved. - * Set to 0 to poll constantly. Set to -1 to only poll on user movement. - * - * @name Phaser.Input.InputPlugin#pollRate - * @type {integer} - * @default -1 - * @since 3.0.0 - */ - this.pollRate = -1; - - /** - * [description] - * - * @name Phaser.Input.InputPlugin#_pollTimer - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._pollTimer = 0; - - /** - * The distance, in pixels, the pointer has to move while being held down, before it thinks it is being dragged. - * - * @name Phaser.Input.InputPlugin#dragDistanceThreshold - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.dragDistanceThreshold = 0; - - /** - * The amount of time, in ms, the pointer has to be held down before it thinks it is dragging. - * - * @name Phaser.Input.InputPlugin#dragTimeThreshold - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.dragTimeThreshold = 0; - - /** - * Used to temporarily store the results of the Hit Test - * - * @name Phaser.Input.InputPlugin#_temp - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._temp = []; - - /** - * Used to temporarily store the results of the Hit Test dropZones - * - * @name Phaser.Input.InputPlugin#_tempZones - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._tempZones = []; - - /** - * A list of all Game Objects that have been set to be interactive. - * - * @name Phaser.Input.InputPlugin#_list - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._list = []; - - /** - * Objects waiting to be inserted to the list on the next call to 'begin'. - * - * @name Phaser.Input.InputPlugin#_pendingInsertion - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._pendingInsertion = []; - - /** - * Objects waiting to be removed from the list on the next call to 'begin'. - * - * @name Phaser.Input.InputPlugin#_pendingRemoval - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._pendingRemoval = []; - - /** - * A list of all Game Objects that have been enabled for dragging. - * - * @name Phaser.Input.InputPlugin#_draggable - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._draggable = []; - - /** - * A list of all Interactive Objects currently considered as being 'draggable' by any pointer, indexed by pointer ID. - * - * @name Phaser.Input.InputPlugin#_drag - * @type {[type]} - * @private - * @since 3.0.0 - */ - this._drag = { 0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [] }; - - /** - * A list of all Interactive Objects currently considered as being 'over' by any pointer, indexed by pointer ID. - * - * @name Phaser.Input.InputPlugin#_over - * @type {[type]} - * @private - * @since 3.0.0 - */ - this._over = { 0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [] }; - - /** - * [description] - * - * @name Phaser.Input.InputPlugin#_validTypes - * @type {[type]} - * @private - * @since 3.0.0 - */ - this._validTypes = [ 'onDown', 'onUp', 'onOver', 'onOut', 'onMove', 'onDragStart', 'onDrag', 'onDragEnd', 'onDragEnter', 'onDragLeave', 'onDragOver', 'onDrop' ]; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#boot - * @since 3.0.0 - */ - boot: function () - { - var eventEmitter = this.systems.events; - - eventEmitter.on('preupdate', this.preUpdate, this); - eventEmitter.on('update', this.update, this); - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); - - this.cameras = this.systems.cameras; - - this.displayList = this.systems.displayList; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#preUpdate - * @since 3.0.0 - * - * @return {[type]} [description] - */ - preUpdate: function () - { - var removeList = this._pendingRemoval; - var insertList = this._pendingInsertion; - - var toRemove = removeList.length; - var toInsert = insertList.length; - - if (toRemove === 0 && toInsert === 0) - { - // Quick bail - return; - } - - var current = this._list; - - // Delete old gameObjects - for (var i = 0; i < toRemove; i++) - { - var gameObject = removeList[i]; - - var index = current.indexOf(gameObject); - - if (index > -1) - { - current.splice(index, 1); - - this.clear(gameObject); - } - } - - // Clear the removal list - removeList.length = 0; - - // Move pendingInsertion to list (also clears pendingInsertion at the same time) - this._list = current.concat(insertList.splice(0)); - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#clear - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - * - * @return {Phaser.GameObjects.GameObject} [description] - */ - clear: function (gameObject) - { - var input = gameObject.input; - - input.gameObject = undefined; - input.target = undefined; - input.hitArea = undefined; - input.hitAreaCallback = undefined; - input.callbackContext = undefined; - - gameObject.input = null; - - // Clear from _draggable, _drag and _over - var index = this._draggable.indexOf(gameObject); - - if (index > -1) - { - this._draggable.splice(index, 1); - } - - index = this._drag[0].indexOf(gameObject); - - if (index > -1) - { - this._drag[0].splice(index, 1); - } - - index = this._over[0].indexOf(gameObject); - - if (index > -1) - { - this._over[0].splice(index, 1); - } - - return gameObject; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#disable - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - */ - disable: function (gameObject) - { - gameObject.input.enabled = false; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#enable - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - * @param {object} shape - [description] - * @param {function} callback - [description] - * @param {boolean} [dropZone=false] - [description] - * - * @return {Phaser.Input.InputPlugin} This Input Plugin. - */ - enable: function (gameObject, shape, callback, dropZone) - { - if (dropZone === undefined) { dropZone = false; } - - if (gameObject.input) - { - // If it is already has an InteractiveObject then just enable it and return - gameObject.input.enabled = true; - } - else - { - // Create an InteractiveObject and enable it - this.setHitArea(gameObject, shape, callback); - } - - gameObject.input.dropZone = dropZone; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#hitTestPointer - * @since 3.0.0 - * - * @param {Phaser.Input.Pointer} pointer - [description] - * - * @return {array} [description] - */ - hitTestPointer: function (pointer) - { - var camera = this.cameras.getCameraBelowPointer(pointer); - - if (camera) - { - pointer.camera = camera; - - // Get a list of all objects that can be seen by the camera below the pointer in the scene and store in 'output' array. - // All objects in this array are input enabled, as checked by the hitTest method, so we don't need to check later on as well. - var over = this.manager.hitTest(pointer.x, pointer.y, this._list, camera); - - // Filter out the drop zones - for (var i = 0; i < over.length; i++) - { - var obj = over[i]; - - if (obj.input.dropZone) - { - this._tempZones.push(obj); - } - } - - return over; - } - else - { - return []; - } - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#processDownEvents - * @since 3.0.0 - * - * @param {Phaser.Input.Pointer} pointer - [description] - * - * @return {[type]} [description] - */ - processDownEvents: function (pointer) - { - var currentlyOver = this._temp; - - // Contains ALL Game Objects currently over in the array - this.emit('pointerdown', pointer, currentlyOver); - - var total = 0; - - // Go through all objects the pointer was over and fire their events / callbacks - for (var i = 0; i < currentlyOver.length; i++) - { - var gameObject = currentlyOver[i]; - - if (!gameObject.input) - { - continue; - } - - total++; - - gameObject.emit('pointerdown', pointer, gameObject.input.localX, gameObject.input.localY, pointer.camera); - - this.emit('gameobjectdown', pointer, gameObject); - } - - return total; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#processDragEvents - * @since 3.0.0 - * - * @param {number} pointer - [description] - * @param {number} time - [description] - * - * @return {integer} [description] - */ - processDragEvents: function (pointer, time) - { - if (this._draggable.length === 0) - { - // There are no draggable items, so let's not even bother going further - return 0; - } - - var i; - var gameObject; - var list; - var input; - var currentlyOver = this._temp; - - // 0 = Not dragging anything - // 1 = Primary button down and objects below, so collect a draglist - // 2 = Pointer being checked if meets drag criteria - // 3 = Pointer meets criteria, notify the draglist - // 4 = Pointer actively dragging the draglist and has moved - // 5 = Pointer actively dragging but has been released, notify draglist - - if (pointer.dragState === 0 && pointer.primaryDown && pointer.justDown && currentlyOver.length > 0) - { - pointer.dragState = 1; - } - else if (pointer.dragState > 0 && !pointer.primaryDown && pointer.justUp) - { - pointer.dragState = 5; - } - - // Process the various drag states - - // 1 = Primary button down and objects below, so collect a draglist - if (pointer.dragState === 1) - { - // Get draggable objects, sort them, pick the top (or all) and store them somewhere - var draglist = []; - - for (i = 0; i < currentlyOver.length; i++) - { - gameObject = currentlyOver[i]; - - if (gameObject.input.draggable) - { - draglist.push(gameObject); - } - } - - if (draglist.length === 0) - { - pointer.dragState = 0; - - return 0; - } - else if (draglist.length > 1) - { - this.sortGameObjects(draglist); - - if (this.topOnly) - { - draglist.splice(1); - } - } - - // draglist now contains all potential candidates for dragging - this._drag[pointer.id] = draglist; - - if (this.dragDistanceThreshold === 0 && this.dragTimeThreshold === 0) - { - // No drag criteria, so snap immediately to mode 3 - pointer.dragState = 3; - } - else - { - // Check the distance / time - pointer.dragState = 2; - } - } - - // 2 = Pointer being checked if meets drag criteria - if (pointer.dragState === 2) - { - // Has it moved far enough to be considered a drag? - if (this.dragDistanceThreshold > 0 && DistanceBetween(pointer.x, pointer.y, pointer.downX, pointer.downY) >= this.dragDistanceThreshold) - { - // Alrighty, we've got a drag going on ... - pointer.dragState = 3; - } - - // Held down long enough to be considered a drag? - if (this.dragTimeThreshold > 0 && (time >= pointer.downTime + this.dragTimeThreshold)) - { - // Alrighty, we've got a drag going on ... - pointer.dragState = 3; - } - } - - // 3 = Pointer meets criteria and is freshly down, notify the draglist - if (pointer.dragState === 3) - { - list = this._drag[pointer.id]; - - for (i = 0; i < list.length; i++) - { - gameObject = list[i]; - - input = gameObject.input; - - input.dragState = 2; - - input.dragX = pointer.x - gameObject.x; - input.dragY = pointer.y - gameObject.y; - - input.dragStartX = gameObject.x; - input.dragStartY = gameObject.y; - - gameObject.emit('dragstart', pointer, input.dragX, input.dragY); - - this.emit('dragstart', pointer, gameObject); - } - - pointer.dragState = 4; - - return 1; - } - - // 4 = Pointer actively dragging the draglist and has moved - if (pointer.dragState === 4 && pointer.justMoved) - { - var dropZones = this._tempZones; - - list = this._drag[pointer.id]; - - for (i = 0; i < list.length; i++) - { - gameObject = list[i]; - - input = gameObject.input; - - // If this GO has a target then let's check it - if (input.target) - { - var index = dropZones.indexOf(input.target); - - // Got a target, are we still over it? - if (index === 0) - { - // We're still over it, and it's still the top of the display list, phew ... - gameObject.emit('dragover', pointer, input.target); - - this.emit('dragover', pointer, gameObject, input.target); - } - else if (index > 0) - { - // Still over it but it's no longer top of the display list (targets must always be at the top) - gameObject.emit('dragleave', pointer, input.target); - - this.emit('dragleave', pointer, gameObject, input.target); - - input.target = dropZones[0]; - - gameObject.emit('dragenter', pointer, input.target); - - this.emit('dragenter', pointer, gameObject, input.target); - } - else - { - // Nope, we've moved on (or the target has!), leave the old target - gameObject.emit('dragleave', pointer, input.target); - - this.emit('dragleave', pointer, gameObject, input.target); - - // Anything new to replace it? - // Yup! - if (dropZones[0]) - { - input.target = dropZones[0]; - - gameObject.emit('dragenter', pointer, input.target); - - this.emit('dragenter', pointer, gameObject, input.target); - } - else - { - // Nope - input.target = null; - } - } - } - else if (!input.target && dropZones[0]) - { - input.target = dropZones[0]; - - gameObject.emit('dragenter', pointer, input.target); - - this.emit('dragenter', pointer, gameObject, input.target); - } - - var dragX = pointer.x - gameObject.input.dragX; - var dragY = pointer.y - gameObject.input.dragY; - - gameObject.emit('drag', pointer, dragX, dragY); - - this.emit('drag', pointer, gameObject, dragX, dragY); - } - } - - // 5 = Pointer actively dragging but has been released, notify draglist - if (pointer.dragState === 5) - { - list = this._drag[pointer.id]; - - for (i = 0; i < list.length; i++) - { - gameObject = list[i]; - - input = gameObject.input; - - input.dragState = 0; - - input.dragX = input.localX - gameObject.displayOriginX; - input.dragY = input.localY - gameObject.displayOriginY; - - var dropped = false; - - if (input.target) - { - gameObject.emit('drop', pointer, input.target); - - this.emit('drop', pointer, gameObject, input.target); - - input.target = null; - - dropped = true; - } - - // And finally the dragend event - - gameObject.emit('dragend', pointer, input.dragX, input.dragY, dropped); - - this.emit('dragend', pointer, gameObject, dropped); - } - - pointer.dragState = 0; - } - - return (pointer.dragState > 0); - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#processMoveEvents - * @since 3.0.0 - * - * @param {Phaser.Input.Pointer} pointer - [description] - * - * @return {[type]} [description] - */ - processMoveEvents: function (pointer) - { - var currentlyOver = this._temp; - - this.emit('pointermove', pointer, currentlyOver); - - var total = 0; - - // Go through all objects the pointer was over and fire their events / callbacks - for (var i = 0; i < currentlyOver.length; i++) - { - var gameObject = currentlyOver[i]; - - if (!gameObject.input) - { - continue; - } - - total++; - - gameObject.emit('pointermove', pointer, gameObject.input.localX, gameObject.input.localY); - - this.emit('gameobjectmove', pointer, gameObject); - - if (this.topOnly) - { - break; - } - } - - return total; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#processOverOutEvents - * @since 3.0.0 - * - * @param {Phaser.Input.Pointer} pointer - [description] - * - * @return {[type]} [description] - */ - processOverOutEvents: function (pointer) - { - var currentlyOver = this._temp; - - var i; - var gameObject; - var justOut = []; - var justOver = []; - var stillOver = []; - var previouslyOver = this._over[pointer.id]; - var currentlyDragging = this._drag[pointer.id]; - - // Go through all objects the pointer was previously over, and see if it still is. - // Splits the previouslyOver array into two parts: justOut and stillOver - - for (i = 0; i < previouslyOver.length; i++) - { - gameObject = previouslyOver[i]; - - if (currentlyOver.indexOf(gameObject) === -1 && currentlyDragging.indexOf(gameObject) === -1) - { - // Not in the currentlyOver array, so must be outside of this object now - justOut.push(gameObject); - } - else - { - // In the currentlyOver array - stillOver.push(gameObject); - } - } - - // Go through all objects the pointer is currently over (the hit test results) - // and if not in the previouslyOver array we know it's a new entry, so add to justOver - for (i = 0; i < currentlyOver.length; i++) - { - gameObject = currentlyOver[i]; - - // Is this newly over? - - if (previouslyOver.indexOf(gameObject) === -1) - { - justOver.push(gameObject); - } - } - - // By this point the arrays are filled, so now we can process what happened... - - // Process the Just Out objects - var total = justOut.length; - - if (total > 0) - { - this.sortGameObjects(justOut); - - this.emit('pointerout', pointer, justOut); - - // Call onOut for everything in the justOut array - for (i = 0; i < total; i++) - { - gameObject = justOut[i]; - - if (!gameObject.input) - { - continue; - } - - this.emit('gameobjectout', pointer, gameObject); - - gameObject.emit('pointerout', pointer); - } - } - - // Process the Just Over objects - total = justOver.length; - - if (total > 0) - { - this.sortGameObjects(justOver); - - this.emit('pointerover', pointer, justOver); - - // Call onOver for everything in the justOver array - for (i = 0; i < total; i++) - { - gameObject = justOver[i]; - - if (!gameObject.input) - { - continue; - } - - this.emit('gameobjectover', pointer, gameObject); - - gameObject.emit('pointerover', pointer, gameObject.input.localX, gameObject.input.localY); - } - } - - // Add the contents of justOver to the previously over array - previouslyOver = stillOver.concat(justOver); - - // Then sort it into display list order - this._over[pointer.id] = this.sortGameObjects(previouslyOver); - - return previouslyOver.length; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#processUpEvents - * @since 3.0.0 - * - * @param {Phaser.Input.Pointer} pointer - [description] - */ - processUpEvents: function (pointer) - { - var currentlyOver = this._temp; - - // Contains ALL Game Objects currently up in the array - this.emit('pointerup', pointer, currentlyOver); - - // Go through all objects the pointer was over and fire their events / callbacks - for (var i = 0; i < currentlyOver.length; i++) - { - var gameObject = currentlyOver[i]; - - if (!gameObject.input) - { - continue; - } - - gameObject.emit('pointerup', pointer, gameObject.input.localX, gameObject.input.localY); - - this.emit('gameobjectup', pointer, gameObject); - } - - return currentlyOver.length; - }, - - /** - * Queues a Game Object for insertion into this Input Manager on the next update. - * - * @method Phaser.Input.InputPlugin#queueForInsertion - * @since 3.0.0 - * - * @param {[type]} child - [description] - * - * @return {[type]} [description] - */ - queueForInsertion: function (child) - { - if (this._pendingInsertion.indexOf(child) === -1 && this._list.indexOf(child) === -1) - { - this._pendingInsertion.push(child); - } - - return this; - }, - - /** - * Queues a Game Object for removal from this Input Manager on the next update. - * - * @method Phaser.Input.InputPlugin#queueForRemoval - * @since 3.0.0 - * - * @param {[type]} child - [description] - * - * @return {[type]} [description] - */ - queueForRemoval: function (child) - { - this._pendingRemoval.push(child); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setDraggable - * @since 3.0.0 - * - * @param {[type]} gameObjects - [description] - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setDraggable: function (gameObjects, value) - { - if (value === undefined) { value = true; } - - if (!Array.isArray(gameObjects)) - { - gameObjects = [ gameObjects ]; - } - - for (var i = 0; i < gameObjects.length; i++) - { - var gameObject = gameObjects[i]; - - gameObject.input.draggable = value; - - var index = this._draggable.indexOf(gameObject); - - if (value && index === -1) - { - this._draggable.push(gameObject); - } - else if (!value && index > -1) - { - this._draggable.splice(index, 1); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setHitArea - * @since 3.0.0 - * - * @param {[type]} gameObjects - [description] - * @param {[type]} shape - [description] - * @param {[type]} callback - [description] - * - * @return {[type]} [description] - */ - setHitArea: function (gameObjects, shape, callback) - { - if (shape === undefined) - { - return this.setHitAreaFromTexture(gameObjects); - } - - if (!Array.isArray(gameObjects)) - { - gameObjects = [ gameObjects ]; - } - - for (var i = 0; i < gameObjects.length; i++) - { - var gameObject = gameObjects[i]; - - gameObject.input = InteractiveObject(gameObject, shape, callback); - - this.queueForInsertion(gameObject); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setHitAreaCircle - * @since 3.0.0 - * - * @param {[type]} gameObjects - [description] - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} radius - [description] - * @param {[type]} callback - [description] - * - * @return {[type]} [description] - */ - setHitAreaCircle: function (gameObjects, x, y, radius, callback) - { - if (callback === undefined) { callback = CircleContains; } - - var shape = new Circle(x, y, radius); - - return this.setHitArea(gameObjects, shape, callback); - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setHitAreaEllipse - * @since 3.0.0 - * - * @param {[type]} gameObjects - [description] - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} width - [description] - * @param {[type]} height - [description] - * @param {[type]} callback - [description] - * - * @return {[type]} [description] - */ - setHitAreaEllipse: function (gameObjects, x, y, width, height, callback) - { - if (callback === undefined) { callback = EllipseContains; } - - var shape = new Ellipse(x, y, width, height); - - return this.setHitArea(gameObjects, shape, callback); - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setHitAreaFromTexture - * @since 3.0.0 - * - * @param {[type]} gameObjects - [description] - * @param {[type]} callback - [description] - * - * @return {[type]} [description] - */ - setHitAreaFromTexture: function (gameObjects, callback) - { - if (callback === undefined) { callback = RectangleContains; } - - if (!Array.isArray(gameObjects)) - { - gameObjects = [ gameObjects ]; - } - - for (var i = 0; i < gameObjects.length; i++) - { - var gameObject = gameObjects[i]; - var frame = gameObject.frame; - - var width = 0; - var height = 0; - - if (frame) - { - width = frame.realWidth; - height = frame.realHeight; - } - else if (gameObject.width) - { - width = gameObject.width; - height = gameObject.height; - } - - if (width !== 0 && height !== 0) - { - gameObject.input = InteractiveObject(gameObject, new Rectangle(0, 0, width, height), callback); - - this.queueForInsertion(gameObject); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setHitAreaRectangle - * @since 3.0.0 - * - * @param {[type]} gameObjects - [description] - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} width - [description] - * @param {[type]} height - [description] - * @param {[type]} callback - [description] - * - * @return {[type]} [description] - */ - setHitAreaRectangle: function (gameObjects, x, y, width, height, callback) - { - if (callback === undefined) { callback = RectangleContains; } - - var shape = new Rectangle(x, y, width, height); - - return this.setHitArea(gameObjects, shape, callback); - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setHitAreaTriangle - * @since 3.0.0 - * - * @param {[type]} gameObjects - [description] - * @param {[type]} x1 - [description] - * @param {[type]} y1 - [description] - * @param {[type]} x2 - [description] - * @param {[type]} y2 - [description] - * @param {[type]} x3 - [description] - * @param {[type]} y3 - [description] - * @param {[type]} callback - [description] - * - * @return {[type]} [description] - */ - setHitAreaTriangle: function (gameObjects, x1, y1, x2, y2, x3, y3, callback) - { - if (callback === undefined) { callback = TriangleContains; } - - var shape = new Triangle(x1, y1, x2, y2, x3, y3); - - return this.setHitArea(gameObjects, shape, callback); - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setPollAlways - * @since 3.0.0 - * - * @return {[type]} [description] - */ - setPollAlways: function () - { - this.pollRate = 0; - this._pollTimer = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setPollOnMove - * @since 3.0.0 - * - * @return {[type]} [description] - */ - setPollOnMove: function () - { - this.pollRate = -1; - this._pollTimer = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setPollRate - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setPollRate: function (value) - { - this.pollRate = value; - this._pollTimer = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setGlobalTopOnly - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setGlobalTopOnly: function (value) - { - this.manager.globalTopOnly = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#setTopOnly - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setTopOnly: function (value) - { - this.topOnly = value; - - return this; - }, - - /** - * Given an array of Game Objects, sort the array and return it, - * so that the objects are in index order with the lowest at the bottom. - * - * @method Phaser.Input.InputPlugin#sortGameObjects - * @since 3.0.0 - * - * @param {[type]} gameObjects - [description] - * - * @return {[type]} [description] - */ - sortGameObjects: function (gameObjects) - { - if (gameObjects.length < 2) - { - return gameObjects; - } - - this.scene.sys.depthSort(); - - return gameObjects.sort(this.sortHandlerGO.bind(this)); - }, - - /** - * Return the child lowest down the display list (with the smallest index) - * - * @method Phaser.Input.InputPlugin#sortHandlerGO - * @since 3.0.0 - * - * @param {[type]} childA - [description] - * @param {[type]} childB - [description] - * - * @return {[type]} [description] - */ - sortHandlerGO: function (childA, childB) - { - // The higher the index, the lower down the display list they are. - // So entry 0 will be the top-most item (visually) - var indexA = this.displayList.getIndex(childA); - var indexB = this.displayList.getIndex(childB); - - if (indexA < indexB) - { - return 1; - } - else if (indexA > indexB) - { - return -1; - } - - // Technically this shouldn't happen, but if the GO wasn't part of this display list then it'll - // have an index of -1, so in some cases it can - return 0; - }, - - /** - * Return the child lowest down the display list (with the smallest index) - * - * @method Phaser.Input.InputPlugin#sortHandlerIO - * @since 3.0.0 - * - * @param {[type]} childA - [description] - * @param {[type]} childB - [description] - * - * @return {[type]} [description] - */ - sortHandlerIO: function (childA, childB) - { - // The higher the index, the lower down the display list they are. - // So entry 0 will be the top-most item (visually) - var indexA = this.displayList.getIndex(childA.gameObject); - var indexB = this.displayList.getIndex(childB.gameObject); - - if (indexA < indexB) - { - return 1; - } - else if (indexA > indexB) - { - return -1; - } - - // Technically this shouldn't happen, but if the GO wasn't part of this display list then it'll - // have an index of -1, so in some cases it can - return 0; - }, - - /** - * Given an array of Interactive Objects, sort the array and return it, - * so that the objects are in index order with the lowest at the bottom. - * - * @method Phaser.Input.InputPlugin#sortInteractiveObjects - * @since 3.0.0 - * - * @param {[type]} interactiveObjects - [description] - * - * @return {[type]} [description] - */ - sortInteractiveObjects: function (interactiveObjects) - { - if (interactiveObjects.length < 2) - { - return interactiveObjects; - } - - this.scene.sys.depthSort(); - - return interactiveObjects.sort(this.sortHandlerIO.bind(this)); - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#stopPropagation - * @since 3.0.0 - * - * @return {[type]} [description] - */ - stopPropagation: function () - { - if (this.manager.globalTopOnly) - { - this.manager.ignoreEvents = true; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#update - * @since 3.0.0 - * - * @param {number} time - [description] - * @param {number} delta - [description] - */ - update: function (time, delta) - { - var manager = this.manager; - - // Another Scene above this one has already consumed the input events - if (manager.globalTopOnly && manager.ignoreEvents) - { - return; - } - - var pointer = manager.activePointer; - - var runUpdate = (pointer.dirty || this.pollRate === 0); - - if (this.pollRate > -1) - { - this._pollTimer -= delta; - - if (this._pollTimer < 0) - { - runUpdate = true; - - // Discard timer diff - this._pollTimer = this.pollRate; - } - } - - if (!runUpdate) - { - return; - } - - // Always reset this array - this._tempZones = []; - - // _temp contains a hit tested and camera culled list of IO objects - this._temp = this.hitTestPointer(pointer); - - this.sortGameObjects(this._temp); - this.sortGameObjects(this._tempZones); - - if (this.topOnly) - { - // Only the top-most one counts now, so safely ignore the rest - if (this._temp.length) - { - this._temp.splice(1); - } - - if (this._tempZones.length) - { - this._tempZones.splice(1); - } - } - - var total = this.processDragEvents(pointer, time); - - if (!pointer.wasTouch) - { - total += this.processOverOutEvents(pointer); - } - - if (pointer.justDown) - { - total += this.processDownEvents(pointer); - } - - if (pointer.justUp) - { - total += this.processUpEvents(pointer); - } - - if (pointer.justMoved) - { - total += this.processMoveEvents(pointer); - } - - if (total > 0 && manager.globalTopOnly) - { - // We interacted with an event in this Scene, so block any Scenes below us from doing the same this frame - manager.ignoreEvents = true; - } - }, - - /** - * The Scene that owns this plugin is shutting down. - * - * @method Phaser.Input.InputPlugin#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this._temp.length = 0; - this._list.length = 0; - this._draggable.length = 0; - this._pendingRemoval.length = 0; - this._pendingInsertion.length = 0; - - for (var i = 0; i < 10; i++) - { - this._drag[i] = []; - this._over[i] = []; - } - - this.removeAllListeners(); - }, - - /** - * [description] - * - * @method Phaser.Input.InputPlugin#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.shutdown(); - - this.scene = undefined; - this.cameras = undefined; - this.manager = undefined; - this.events = undefined; - this.keyboard = undefined; - this.mouse = undefined; - this.gamepad = undefined; - }, - - /** - * The current active input Pointer. - * - * @name Phaser.Input.InputPlugin#activePointer - * @type {Phaser.Input.Pointer} - * @readOnly - * @since 3.0.0 - */ - activePointer: { - - get: function () - { - return this.manager.activePointer; - } - - }, - - /** - * The x coordinates of the ActivePointer based on the first camera in the camera list. - * This is only safe to use if your game has just 1 non-transformed camera and doesn't use multi-touch. - * - * @name Phaser.Input.InputPlugin#x - * @type {number} - * @readOnly - * @since 3.0.0 - */ - x: { - - get: function () - { - return this.manager.activePointer.x; - } - - }, - - /** - * The y coordinates of the ActivePointer based on the first camera in the camera list. - * This is only safe to use if your game has just 1 non-transformed camera and doesn't use multi-touch. - * - * @name Phaser.Input.InputPlugin#y - * @type {number} - * @readOnly - * @since 3.0.0 - */ - y: { - - get: function () - { - return this.manager.activePointer.y; - } - - } - -}); - -PluginManager.register('InputPlugin', InputPlugin, 'input'); - -module.exports = InputPlugin; +module.exports = Clone; /***/ }), /* 768 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculates the area of the Ellipse. + * + * @function Phaser.Geom.Ellipse.Area + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the area of. + * + * @return {number} The area of the Ellipse. + */ +var Area = function (ellipse) +{ + if (ellipse.isEmpty()) + { + return 0; + } + + // units squared + return (ellipse.getMajorRadius() * ellipse.getMinorRadius() * Math.PI); +}; + +module.exports = Area; + + +/***/ }), +/* 769 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -111187,69 +110513,204 @@ module.exports = InputPlugin; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * @namespace Phaser.Input.Keyboard - */ - -module.exports = { - - KeyboardManager: __webpack_require__(245), - - Key: __webpack_require__(246), - KeyCodes: __webpack_require__(129), - - KeyCombo: __webpack_require__(247), - - JustDown: __webpack_require__(769), - JustUp: __webpack_require__(770), - DownDuration: __webpack_require__(771), - UpDuration: __webpack_require__(772) - -}; - - -/***/ }), -/* 769 */ -/***/ (function(module, exports) { +var GameObject = __webpack_require__(1); /** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * The justDown value allows you to test if this Key has just been pressed down or not. - * When you check this value it will return `true` if the Key is down, otherwise `false`. - * You can only call justDown once per key press. It will only return `true` once, until the Key is released and pressed down again. - * This allows you to use it in situations where you want to check if this key is down without using a Signal, such as in a core game loop. + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. * - * @function Phaser.Input.Keyboard.JustDown + * @method Phaser.GameObjects.DynamicBitmapText#renderCanvas * @since 3.0.0 + * @private * - * @param {Phaser.Input.Keyboard.Key} key - [description] - * - * @return {boolean} [description] + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.DynamicBitmapText} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. */ -var JustDown = function (key) +var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera) { - var current = false; + var text = src.text; + var textLength = text.length; - if (key.isDown) + if (GameObject.RENDER_MASK !== src.renderFlags || textLength === 0 || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) { - current = key._justDown; - key._justDown = false; + return; + } + + var textureFrame = src.frame; + + var displayCallback = src.displayCallback; + + var cameraScrollX = camera.scrollX * src.scrollFactorX; + var cameraScrollY = camera.scrollY * src.scrollFactorY; + + var chars = src.fontData.chars; + var lineHeight = src.fontData.lineHeight; + + var xAdvance = 0; + var yAdvance = 0; + + var indexCount = 0; + var charCode = 0; + + var glyph = null; + var glyphX = 0; + var glyphY = 0; + var glyphW = 0; + var glyphH = 0; + + var x = 0; + var y = 0; + + var lastGlyph = null; + var lastCharCode = 0; + + var ctx = renderer.currentContext; + var image = src.frame.source.image; + + var textureX = textureFrame.cutX; + var textureY = textureFrame.cutY; + + var rotation = 0; + var scale = (src.fontSize / src.fontData.size); + + // Blend Mode + if (renderer.currentBlendMode !== src.blendMode) + { + renderer.currentBlendMode = src.blendMode; + ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; } - return current; + // Alpha + if (renderer.currentAlpha !== src.alpha) + { + renderer.currentAlpha = src.alpha; + ctx.globalAlpha = src.alpha; + } + + // Smoothing + if (renderer.currentScaleMode !== src.scaleMode) + { + renderer.currentScaleMode = src.scaleMode; + } + + ctx.save(); + + ctx.translate(src.x, src.y); + + ctx.rotate(src.rotation); + + ctx.translate(-src.displayOriginX, -src.displayOriginY); + + ctx.scale(src.scaleX, src.scaleY); + + if (src.cropWidth > 0 && src.cropHeight > 0) + { + ctx.save(); + ctx.beginPath(); + ctx.rect(0, 0, src.cropWidth, src.cropHeight); + ctx.clip(); + } + + var roundPixels = renderer.config.roundPixels; + + for (var index = 0; index < textLength; ++index) + { + // Reset the scale (in case the callback changed it) + scale = (src.fontSize / src.fontData.size); + rotation = 0; + + charCode = text.charCodeAt(index); + + if (charCode === 10) + { + xAdvance = 0; + indexCount = 0; + yAdvance += lineHeight; + lastGlyph = null; + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + glyphX = textureX + glyph.x; + glyphY = textureY + glyph.y; + + glyphW = glyph.width; + glyphH = glyph.height; + + x = (indexCount + glyph.xOffset + xAdvance) - src.scrollX; + y = (glyph.yOffset + yAdvance) - src.scrollY; + + // This could be optimized so that it doesn't even bother drawing it if the x/y is out of range + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + if (displayCallback) + { + var output = displayCallback({ tint: { topLeft: 0, topRight: 0, bottomLeft: 0, bottomRight: 0 }, index: index, charCode: charCode, x: x, y: y, scale: scale, rotation: 0, data: glyph.data }); + + x = output.x; + y = output.y; + scale = output.scale; + rotation = output.rotation; + } + + x *= scale; + y *= scale; + + x -= cameraScrollX; + y -= cameraScrollY; + + if (roundPixels) + { + x |= 0; + y |= 0; + } + + ctx.save(); + + ctx.translate(x, y); + + ctx.rotate(rotation); + + ctx.scale(scale, scale); + + ctx.drawImage(image, glyphX, glyphY, glyphW, glyphH, 0, 0, glyphW, glyphH); + + ctx.restore(); + + xAdvance += glyph.xAdvance; + indexCount += 1; + lastGlyph = glyph; + lastCharCode = charCode; + } + + if (src.cropWidth > 0 && src.cropHeight > 0) + { + ctx.restore(); + } + + ctx.restore(); }; -module.exports = JustDown; +module.exports = DynamicBitmapTextCanvasRenderer; /***/ }), /* 770 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -111257,38 +110718,41 @@ module.exports = JustDown; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * The justUp value allows you to test if this Key has just been released or not. - * When you check this value it will return `true` if the Key is up, otherwise `false`. - * You can only call justUp once per key release. It will only return `true` once, until the Key is pressed down and released again. - * This allows you to use it in situations where you want to check if this key is up without using a Signal, such as in a core game loop. - * - * @function Phaser.Input.Keyboard.JustUp - * @since 3.0.0 - * - * @param {Phaser.Input.Keyboard.Key} key - [description] - * - * @return {boolean} [description] - */ -var JustUp = function (key) -{ - var current = false; +var GameObject = __webpack_require__(1); - if (key.isDown) +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.DynamicBitmapText#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.DynamicBitmapText} gameObject - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var DynamicBitmapTextWebGLRenderer = function (renderer, bitmapText, interpolationPercentage, camera) +{ + var text = bitmapText.text; + var textLength = text.length; + + if (GameObject.RENDER_MASK !== bitmapText.renderFlags || textLength === 0 || (bitmapText.cameraFilter > 0 && (bitmapText.cameraFilter & camera._id))) { - current = key._justUp; - key._justUp = false; + return; } - return current; + this.pipeline.batchDynamicBitmapText(bitmapText, camera); }; -module.exports = JustUp; +module.exports = DynamicBitmapTextWebGLRenderer; /***/ }), /* 771 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -111296,31 +110760,30 @@ module.exports = JustUp; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * Returns `true` if the Key was pressed down within the `duration` value given, or `false` if it either isn't down, - * or was pressed down longer ago than then given duration. - * - * @function Phaser.Input.Keyboard.DownDuration - * @since 3.0.0 - * - * @param {Phaser.Input.Keyboard.Key} key - [description] - * @param {integer} duration - [description] - * - * @return {boolean} [description] - */ -var DownDuration = function (key, duration) +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); + +if (true) { - if (duration === undefined) { duration = 50; } + renderWebGL = __webpack_require__(770); +} + +if (true) +{ + renderCanvas = __webpack_require__(769); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas - return (key.isDown && key.duration < duration); }; -module.exports = DownDuration; - /***/ }), /* 772 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -111328,26 +110791,339 @@ module.exports = DownDuration; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); + /** - * Returns `true` if the Key was released within the `duration` value given, or `false` if it either isn't up, - * or was released longer ago than then given duration. + * @classdesc + * A Bob Game Object. * - * @function Phaser.Input.Keyboard.UpDuration + * A Bob belongs to a Blitter Game Object. The Blitter is responsible for managing and rendering this object. + * + * A Bob has a position, alpha value and a frame from a texture that it uses to render with. You can also toggle + * the flipped and visible state of the Bob. The Frame the Bob uses to render can be changed dynamically, but it + * must be a Frame within the Texture used by the parent Blitter. + * + * Bob positions are relative to the Blitter parent. So if you move the Blitter parent, all Bob children will + * have their positions impacted by this change as well. + * + * You can manipulate Bob objects directly from your game code, but the creation and destruction of them should be + * handled via the Blitter parent. + * + * @class Bob + * @memberOf Phaser.GameObjects.Blitter + * @constructor * @since 3.0.0 * - * @param {Phaser.Input.Keyboard.Key} key - [description] - * @param {integer} [duration] - [description] - * - * @return {boolean} [description] + * @param {Phaser.GameObjects.Blitter} blitter - The parent Blitter object is responsible for updating this Bob. + * @param {number} x - The horizontal position of this Game Object in the world, relative to the parent Blitter position. + * @param {number} y - The vertical position of this Game Object in the world, relative to the parent Blitter position. + * @param {(string|integer)} frame - The Frame this Bob will render with, as defined in the Texture the parent Blitter is using. + * @param {boolean} visible - Should the Bob render visible or not to start with? */ -var UpDuration = function (key, duration) -{ - if (duration === undefined) { duration = 50; } +var Bob = new Class({ - return (key.isUp && key.duration < duration); -}; + initialize: -module.exports = UpDuration; + function Bob (blitter, x, y, frame, visible) + { + /** + * [description] + * + * @name Phaser.GameObjects.Blitter.Bob#parent + * @type {Phaser.GameObjects.Blitter} + * @since 3.0.0 + */ + this.parent = blitter; + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter.Bob#x + * @type {number} + * @since 3.0.0 + */ + this.x = x; + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter.Bob#y + * @type {number} + * @since 3.0.0 + */ + this.y = y; + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter.Bob#frame + * @type {(string|integer)} + * @since 3.0.0 + */ + this.frame = frame; + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter.Bob#data + * @type {object} + * @default {} + * @since 3.0.0 + */ + this.data = {}; + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter.Bob#_visible + * @type {boolean} + * @private + * @since 3.0.0 + */ + this._visible = visible; + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter.Bob#_alpha + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + this._alpha = 1; + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter.Bob#flipX + * @type {boolean} + * @since 3.0.0 + */ + this.flipX = false; + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter.Bob#flipY + * @type {boolean} + * @since 3.0.0 + */ + this.flipY = false; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter.Bob#setFrame + * @since 3.0.0 + * + * @param {Phaser.Textures.Frame} [frame] - [description] + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setFrame: function (frame) + { + if (frame === undefined) + { + frame = this.parent.frame; + } + else + { + frame = this.parent.texture.get(frame); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter.Bob#resetFlip + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + resetFlip: function () + { + this.flipX = false; + this.flipY = false; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter.Bob#reset + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {Phaser.Textures.Frame} frame - [description] + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + reset: function (x, y, frame) + { + this.x = x; + this.y = y; + this.frame = frame; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter.Bob#setFlipX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setFlipX: function (value) + { + this.flipX = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter.Bob#setFlipY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setFlipY: function (value) + { + this.flipY = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter.Bob#setFlip + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setFlip: function (x, y) + { + this.flipX = x; + this.flipY = y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter.Bob#setVisible + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setVisible: function (value) + { + this.visible = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter.Bob#setAlpha + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setAlpha: function (value) + { + this.alpha = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Blitter.Bob#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.parent.dirty = true; + + this.parent.children.remove(this); + + this.parent = undefined; + this.frame = undefined; + this.data = undefined; + }, + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter.Bob#visible + * @type {boolean} + * @since 3.0.0 + */ + visible: { + + get: function () + { + return this._visible; + }, + + set: function (value) + { + this._visible = value; + this.parent.dirty = true; + } + + }, + + /** + * [description] + * + * @name Phaser.GameObjects.Blitter.Bob#alpha + * @type {number} + * @since 3.0.0 + */ + alpha: { + + get: function () + { + return this._alpha; + }, + + set: function (value) + { + this._alpha = value; + this.parent.dirty = true; + } + + } + +}); + +module.exports = Bob; /***/ }), @@ -111360,17 +111136,77 @@ module.exports = UpDuration; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var GameObject = __webpack_require__(1); + /** - * @namespace Phaser.Input.Mouse + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Blitter#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Blitter} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. */ +var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } -/* eslint-disable */ -module.exports = { + var list = src.getRenderList(); - MouseManager: __webpack_require__(248) - + renderer.setBlendMode(src.blendMode); + + var ctx = renderer.gameContext; + var cameraScrollX = src.x - camera.scrollX * src.scrollFactorX; + var cameraScrollY = src.y - camera.scrollY * src.scrollFactorY; + + // Render bobs + for (var i = 0; i < list.length; i++) + { + var bob = list[i]; + var flip = (bob.flipX || bob.flipY); + var frame = bob.frame; + var cd = frame.canvasData; + var dx = frame.x; + var dy = frame.y; + var fx = 1; + var fy = 1; + + if (!flip) + { + renderer.blitImage(dx + bob.x + cameraScrollX, dy + bob.y + cameraScrollY, bob.frame); + } + else + { + if (bob.flipX) + { + fx = -1; + dx -= cd.dWidth; + } + + if (bob.flipY) + { + fy = -1; + dy -= cd.dHeight; + } + + ctx.save(); + ctx.translate(bob.x + cameraScrollX, bob.y + cameraScrollY); + ctx.scale(fx, fy); + ctx.drawImage(frame.source.image, cd.sx, cd.sy, cd.sWidth, cd.sHeight, dx, dy, cd.dWidth, cd.dHeight); + ctx.restore(); + } + } }; -/* eslint-enable */ + +module.exports = BlitterCanvasRenderer; /***/ }), @@ -111383,17 +111219,33 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var GameObject = __webpack_require__(1); + /** - * @namespace Phaser.Input.Touch + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Blitter#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Blitter} gameObject - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. */ +var BlitterWebGLRenderer = function (renderer, gameObject, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== gameObject.renderFlags || (gameObject.cameraFilter > 0 && (gameObject.cameraFilter & camera._id))) + { + return; + } -/* eslint-disable */ -module.exports = { - - TouchManager: __webpack_require__(250) - + this.pipeline.drawBlitter(gameObject, camera); }; -/* eslint-enable */ + +module.exports = BlitterWebGLRenderer; /***/ }), @@ -111406,21 +111258,23 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * @namespace Phaser.Loader - */ +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); + +if (true) +{ + renderWebGL = __webpack_require__(774); +} + +if (true) +{ + renderCanvas = __webpack_require__(773); +} module.exports = { - FileTypes: __webpack_require__(776), - - File: __webpack_require__(18), - FileTypesManager: __webpack_require__(7), - GetURL: __webpack_require__(150), - LoaderPlugin: __webpack_require__(792), - MergeXHRSettings: __webpack_require__(151), - XHRLoader: __webpack_require__(315), - XHRSettings: __webpack_require__(90) + renderWebGL: renderWebGL, + renderCanvas: renderCanvas }; @@ -111435,59 +111289,175 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * @namespace Phaser.Loader.FileTypes - */ +var GameObject = __webpack_require__(1); /** - * @typedef {object} XHRConfig + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. * - * @property {string} key - [description] - * @property {string} texture - [description] - * @property {string} [data] - [description] - * @property {XHRConfig} [xhr] - [description] - */ - -/** - * @typedef {object} FileTypeConfig + * @method Phaser.GameObjects.BitmapText#renderCanvas + * @since 3.0.0 + * @private * - * @property {string} key - [description] - * @property {string} texture - [description] - * @property {string} [data] - [description] - * @property {string} [url] - [description] - * @property {string} [path] - [description] - * @property {string} [extension] - [description] - * @property {string} [responseType] - [description] - * @property {object} [config] - [description] - * @property {XHRConfig} [xhr] - [description] + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.BitmapText} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. */ +var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera) +{ + var text = src.text; + var textLength = text.length; -module.exports = { + if (GameObject.RENDER_MASK !== src.renderFlags || textLength === 0 || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + var textureFrame = src.frame; - AnimationJSONFile: __webpack_require__(777), - AtlasJSONFile: __webpack_require__(778), - AudioFile: __webpack_require__(316), - AudioSprite: __webpack_require__(779), - BinaryFile: __webpack_require__(780), - BitmapFontFile: __webpack_require__(781), - GLSLFile: __webpack_require__(782), - HTML5AudioFile: __webpack_require__(317), - HTMLFile: __webpack_require__(783), - ImageFile: __webpack_require__(58), - JSONFile: __webpack_require__(57), - MultiAtlas: __webpack_require__(784), - PluginFile: __webpack_require__(785), - ScriptFile: __webpack_require__(786), - SpriteSheetFile: __webpack_require__(787), - SVGFile: __webpack_require__(788), - TextFile: __webpack_require__(320), - TilemapCSVFile: __webpack_require__(789), - TilemapJSONFile: __webpack_require__(790), - UnityAtlasFile: __webpack_require__(791), - XMLFile: __webpack_require__(318) + var chars = src.fontData.chars; + var lineHeight = src.fontData.lineHeight; + var xAdvance = 0; + var yAdvance = 0; + + var indexCount = 0; + var charCode = 0; + + var glyph = null; + var glyphX = 0; + var glyphY = 0; + var glyphW = 0; + var glyphH = 0; + + var x = 0; + var y = 0; + + var lastGlyph = null; + var lastCharCode = 0; + + var ctx = renderer.currentContext; + var image = src.frame.source.image; + + var textureX = textureFrame.cutX; + var textureY = textureFrame.cutY; + + var scale = (src.fontSize / src.fontData.size); + + // Blend Mode + if (renderer.currentBlendMode !== src.blendMode) + { + renderer.currentBlendMode = src.blendMode; + ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; + } + + // Alpha + if (renderer.currentAlpha !== src.alpha) + { + renderer.currentAlpha = src.alpha; + ctx.globalAlpha = src.alpha; + } + + // Smoothing + if (renderer.currentScaleMode !== src.scaleMode) + { + renderer.currentScaleMode = src.scaleMode; + } + + var roundPixels = renderer.config.roundPixels; + + var tx = (src.x - camera.scrollX * src.scrollFactorX) + src.frame.x; + var ty = (src.y - camera.scrollY * src.scrollFactorY) + src.frame.y; + + if (roundPixels) + { + tx |= 0; + ty |= 0; + } + + ctx.save(); + + ctx.translate(tx, ty); + + ctx.rotate(src.rotation); + + ctx.translate(-src.displayOriginX, -src.displayOriginY); + + ctx.scale(src.scaleX, src.scaleY); + + for (var index = 0; index < textLength; ++index) + { + charCode = text.charCodeAt(index); + + if (charCode === 10) + { + xAdvance = 0; + indexCount = 0; + yAdvance += lineHeight; + lastGlyph = null; + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + glyphX = textureX + glyph.x; + glyphY = textureY + glyph.y; + + glyphW = glyph.width; + glyphH = glyph.height; + + x = indexCount + glyph.xOffset + xAdvance; + y = glyph.yOffset + yAdvance; + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + x *= scale; + y *= scale; + + xAdvance += glyph.xAdvance; + indexCount += 1; + lastGlyph = glyph; + lastCharCode = charCode; + + // Nothing to render or a space? Then skip to the next glyph + if (glyphW === 0 || glyphH === 0 || charCode === 32) + { + continue; + } + + if (roundPixels) + { + x |= 0; + y |= 0; + } + + ctx.save(); + + ctx.translate(x, y); + + ctx.scale(scale, scale); + + ctx.drawImage(image, glyphX, glyphY, glyphW, glyphH, 0, 0, glyphW, glyphH); + + ctx.restore(); + } + + ctx.restore(); }; +module.exports = BitmapTextCanvasRenderer; + /***/ }), /* 777 */ @@ -111499,76 +111469,36 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var FileTypesManager = __webpack_require__(7); -var JSONFile = __webpack_require__(57); +var GameObject = __webpack_require__(1); /** - * An Animation JSON File. + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. * - * @function Phaser.Loader.Filetypes.AnimationJSONFile + * @method Phaser.GameObjects.BitmapText#renderWebGL * @since 3.0.0 + * @private * - * @param {string} key - The key of the file within the loader. - * @param {string} url - The url to load the file from. - * @param {string} path - The path of the file. - * @param {object} xhrSettings - Optional file specific XHR settings. - * - * @return {Phaser.Loader.Filetypes.AnimationJSONFile} A File instance to be added to the Loader. + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.BitmapText} gameObject - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. */ -var AnimationJSONFile = function (key, url, path, xhrSettings) +var BitmapTextWebGLRenderer = function (renderer, gameObject, interpolationPercentage, camera) { - var json = new JSONFile(key, url, path, xhrSettings); + var text = gameObject.text; + var textLength = text.length; - // Override the File type - json.type = 'animationJSON'; + if (GameObject.RENDER_MASK !== gameObject.renderFlags || textLength === 0 || (gameObject.cameraFilter > 0 && (gameObject.cameraFilter & camera._id))) + { + return; + } - return json; + this.pipeline.batchBitmapText(this, camera); }; -/** - * Adds an Animation JSON file to the current load queue. - * - * Note: This method will only be available if the Animation JSON File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#animation - * @since 3.0.0 - * - * @param {string|array|object} key - A unique string to be used as the key to reference this file from the Cache. Must be unique within this file type. - * @param {string} [url] - URL of the file. If `undefined` or `null` the url will be set to `.json`, - * i.e. if `key` was "alien" then the URL will be "alien.json". - * @param {object} [xhrSettings] - File specific XHR settings to be used during the load. These settings are merged with the global Loader XHR settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('animation', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new AnimationJSONFile(key[i], url, this.path, xhrSettings)); - } - } - else - { - this.addFile(new AnimationJSONFile(key, url, this.path, xhrSettings)); - } - - // For method chaining - return this; -}); - -// When registering a factory function 'this' refers to the Loader context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory - -module.exports = AnimationJSONFile; +module.exports = BitmapTextWebGLRenderer; /***/ }), @@ -111581,86 +111511,26 @@ module.exports = AnimationJSONFile; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var FileTypesManager = __webpack_require__(7); -var ImageFile = __webpack_require__(58); -var JSONFile = __webpack_require__(57); +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); -/** - * An Atlas JSON File. - * - * @function Phaser.Loader.Filetypes.AtlasJSONFile - * @since 3.0.0 - * - * @param {string} key - The key of the file within the loader. - * @param {string} textureURL - The url to load the texture file from. - * @param {string} atlasURL - The url to load the atlas file from. - * @param {string} path - The path of the file. - * @param {object} textureXhrSettings - Optional texture file specific XHR settings. - * @param {object} atlasXhrSettings - Optional atlas file specific XHR settings. - * - * @return {object} An object containing two File objects to be added to the loader. - */ -var AtlasJSONFile = function (key, textureURL, atlasURL, path, textureXhrSettings, atlasXhrSettings) +if (true) { - var image = new ImageFile(key, textureURL, path, textureXhrSettings); - var data = new JSONFile(key, atlasURL, path, atlasXhrSettings); + renderWebGL = __webpack_require__(777); +} - // Link them together - image.linkFile = data; - data.linkFile = image; +if (true) +{ + renderCanvas = __webpack_require__(776); +} - // Set the type - image.linkType = 'atlasjson'; - data.linkType = 'atlasjson'; +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas - return { texture: image, data: data }; }; -/** - * Adds a Texture Atlas file to the current load queue. - * - * Note: This method will only be available if the Atlas JSON File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#atlas - * @since 3.0.0 - * - * @param {string} key - The key of the file within the loader. - * @param {string} textureURL - The url to load the texture file from. - * @param {string} atlasURL - The url to load the atlas file from. - * @param {object} textureXhrSettings - Optional texture file specific XHR settings. - * @param {object} atlasXhrSettings - Optional atlas file specific XHR settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('atlas', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) -{ - - var files; - - // If param key is an object, use object based loading method - if ((typeof key === 'object') && (key !== null)) - { - files = new AtlasJSONFile(key.key, key.texture, key.data, this.path, textureXhrSettings, atlasXhrSettings); - } - - // Else just use the parameters like normal - else - { - // Returns an object with two properties: 'texture' and 'data' - files = new AtlasJSONFile(key, textureURL, atlasURL, this.path, textureXhrSettings, atlasXhrSettings); - } - - this.addFile(files.texture); - this.addFile(files.data); - - return this; -}); - -module.exports = AtlasJSONFile; - /***/ }), /* 779 */ @@ -111672,68 +111542,196 @@ module.exports = AtlasJSONFile; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var AudioFile = __webpack_require__(316); -var CONST = __webpack_require__(17); -var FileTypesManager = __webpack_require__(7); -var JSONFile = __webpack_require__(57); +var GetValue = __webpack_require__(5); + +// * @param {number} characterWidth - The width of each character in the font set. +// * @param {number} characterHeight - The height of each character in the font set. +// * @param {string} chars - The characters used in the font set, in display order. You can use the TEXT_SET consts for common font set arrangements. +// * @param {number} [charsPerRow] - The number of characters per row in the font set. If not given charsPerRow will be the image width / characterWidth. +// * @param {number} [xSpacing=0] - If the characters in the font set have horizontal spacing between them set the required amount here. +// * @param {number} [ySpacing=0] - If the characters in the font set have vertical spacing between them set the required amount here. +// * @param {number} [xOffset=0] - If the font set doesn't start at the top left of the given image, specify the X coordinate offset here. +// * @param {number} [yOffset=0] - If the font set doesn't start at the top left of the given image, specify the Y coordinate offset here. +// Phaser.GameObject.RetroFont = function (game, key, characterWidth, characterHeight, chars, charsPerRow, xSpacing, ySpacing, xOffset, yOffset) + +// { +// image: key, +// width: 32, +// height: 32, +// chars: 'string', +// charsPerRow: null, +// spacing: { x: 0, y: 0 }, +// offset: { x: 0, y: 0 } +// } /** - * Adds an Audio Sprite file to the current load queue. - * - * Note: This method will only be available if the Audio Sprite File type has been built into Phaser. + * [description] * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#audioSprite + * @function ParseRetroFont * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string|string[]} urls - [description] - * @param {object} json - [description] - * @param {object} config - [description] - * @param {object} audioXhrSettings - Optional file specific XHR settings. - * @param {object} jsonXhrSettings - Optional file specific XHR settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. + * @private */ -FileTypesManager.register('audioSprite', function (key, urls, json, config, audioXhrSettings, jsonXhrSettings) +var ParseRetroFont = function (scene, config) { - var audioFile = AudioFile.create(this, key, urls, config, audioXhrSettings); + var w = config.width; + var h = config.height; + var cx = Math.floor(w / 2); + var cy = Math.floor(h / 2); + var letters = config.chars; - if (audioFile) + var key = GetValue(config, 'image', ''); + var offsetX = GetValue(config, 'offset.x', 0); + var offsetY = GetValue(config, 'offset.y', 0); + var spacingX = GetValue(config, 'spacing.x', 0); + var spacingY = GetValue(config, 'spacing.y', 0); + + var charsPerRow = GetValue(config, 'charsPerRow', null); + + if (charsPerRow === null) { - var jsonFile; + charsPerRow = scene.sys.textures.getFrame(key).width / w; - if (typeof json === 'string') + if (charsPerRow > letters.length) { - jsonFile = new JSONFile(key, json, this.path, jsonXhrSettings); + charsPerRow = letters.length; + } + } - this.addFile(jsonFile); + var x = offsetX; + var y = offsetY; + + var data = { + retroFont: true, + font: key, + size: w, + lineHeight: h, + chars: {} + }; + + var r = 0; + + for (var i = 0; i < letters.length; i++) + { + // var node = letters[i]; + + var charCode = letters.charCodeAt(i); + + data.chars[charCode] = + { + x: x, + y: y, + width: w, + height: h, + centerX: cx, + centerY: cy, + xOffset: 0, + yOffset: 0, + xAdvance: w, + data: {}, + kerning: {} + }; + + r++; + + if (r === charsPerRow) + { + r = 0; + x = offsetX; + y += h + spacingY; } else { - jsonFile = { - type: 'json', - key: key, - data: json, - state: CONST.FILE_WAITING_LINKFILE - }; + x += w + spacingX; } - - // Link them together - audioFile.linkFile = jsonFile; - jsonFile.linkFile = audioFile; - - // Set the type - audioFile.linkType = 'audioSprite'; - jsonFile.linkType = 'audioSprite'; - - this.addFile(audioFile); } - return this; -}); + var entry = { + data: data, + frame: null, + texture: key + }; + + return entry; +}; + +/** +* Text Set 1 = !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ +* @constant +* @type {string} +*/ +ParseRetroFont.TEXT_SET1 = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + +/** +* Text Set 2 = !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ +* @constant +* @type {string} +*/ +ParseRetroFont.TEXT_SET2 = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + +/** +* Text Set 3 = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 +* @constant +* @type {string} +*/ +ParseRetroFont.TEXT_SET3 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 '; + +/** +* Text Set 4 = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 +* @constant +* @type {string} +*/ +ParseRetroFont.TEXT_SET4 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789'; + +/** +* Text Set 5 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789 +* @constant +* @type {string} +*/ +ParseRetroFont.TEXT_SET5 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() \'!?-*:0123456789'; + +/** +* Text Set 6 = ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.' +* @constant +* @type {string} +*/ +ParseRetroFont.TEXT_SET6 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.\' '; + +/** +* Text Set 7 = AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-'39 +* @constant +* @type {string} +*/ +ParseRetroFont.TEXT_SET7 = 'AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-\'39'; + +/** +* Text Set 8 = 0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ +* @constant +* @type {string} +*/ +ParseRetroFont.TEXT_SET8 = '0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + +/** +* Text Set 9 = ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'"?! +* @constant +* @type {string} +*/ +ParseRetroFont.TEXT_SET9 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,\'"?!'; + +/** +* Text Set 10 = ABCDEFGHIJKLMNOPQRSTUVWXYZ +* @constant +* @type {string} +*/ +ParseRetroFont.TEXT_SET10 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + +/** +* Text Set 11 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()':;0123456789 +* @constant +* @type {string} +*/ +ParseRetroFont.TEXT_SET11 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()\':;0123456789'; + +module.exports = ParseRetroFont; /***/ }), @@ -111746,184 +111744,41 @@ FileTypesManager.register('audioSprite', function (key, urls, json, config, audi * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(2); +var ParseXMLBitmapFont = __webpack_require__(270); /** - * @classdesc * [description] * - * @class BinaryFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor + * @function ParseFromAtlas * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {object} xhrSettings - [description] + * @private */ -var BinaryFile = new Class({ - - Extends: File, - - initialize: - - function BinaryFile (key, url, path, xhrSettings) - { - var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); - - var fileConfig = { - type: 'binary', - extension: GetFastValue(key, 'extension', 'bin'), - responseType: 'arraybuffer', - key: fileKey, - url: GetFastValue(key, 'file', url), - path: path, - xhrSettings: GetFastValue(key, 'xhr', xhrSettings) - }; - - File.call(this, fileConfig); - }, - - onProcess: function (callback) - { - this.state = CONST.FILE_PROCESSING; - - this.data = this.xhrLoader.response; - - this.onComplete(); - - callback(this); - } - -}); - -/** - * Adds Binary file to the current load queue. - * - * Note: This method will only be available if the Binary File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#binary - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('binary', function (key, url, xhrSettings) +var ParseFromAtlas = function (scene, fontName, textureKey, frameKey, xmlKey, xSpacing, ySpacing) { - if (Array.isArray(key)) + var frame = scene.sys.textures.getFrame(textureKey, frameKey); + var xml = scene.sys.cache.xml.get(xmlKey); + + if (frame && xml) { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new BinaryFile(key[i], url, this.path, xhrSettings)); - } + var data = ParseXMLBitmapFont(xml, xSpacing, ySpacing, frame); + + scene.sys.cache.bitmapFont.add(fontName, { data: data, texture: textureKey, frame: frameKey }); + + return true; } else { - this.addFile(new BinaryFile(key, url, this.path, xhrSettings)); + return false; } +}; - // For method chaining - return this; -}); - -module.exports = BinaryFile; +module.exports = ParseFromAtlas; /***/ }), /* 781 */ /***/ (function(module, exports, __webpack_require__) { -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var FileTypesManager = __webpack_require__(7); -var ImageFile = __webpack_require__(58); -var XMLFile = __webpack_require__(318); - -/** - * An Bitmap Font File. - * - * @function Phaser.Loader.Filetypes.BitmapFontFile - * @since 3.0.0 - * - * @param {string} key - The key of the file within the loader. - * @param {string} textureURL - The url to load the texture file from. - * @param {string} xmlURL - The url to load the atlas file from. - * @param {string} path - The path of the file. - * @param {object} textureXhrSettings - Optional texture file specific XHR settings. - * @param {object} xmlXhrSettings - Optional atlas file specific XHR settings. - * - * @return {object} An object containing two File objects to be added to the loader. - */ -var BitmapFontFile = function (key, textureURL, xmlURL, path, textureXhrSettings, xmlXhrSettings) -{ - var image = new ImageFile(key, textureURL, path, textureXhrSettings); - var data = new XMLFile(key, xmlURL, path, xmlXhrSettings); - - // Link them together - image.linkFile = data; - data.linkFile = image; - - // Set the type - image.linkType = 'bitmapfont'; - data.linkType = 'bitmapfont'; - - return { texture: image, data: data }; -}; - -/** - * Adds a Bitmap Font file to the current load queue. - * - * Note: This method will only be available if the Bitmap Font File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#bitmapFont - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} textureURL - [description] - * @param {string} xmlURL - [description] - * @param {object} textureXhrSettings - [description] - * @param {object} xmlXhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('bitmapFont', function (key, textureURL, xmlURL, textureXhrSettings, xmlXhrSettings) -{ - // Returns an object with two properties: 'texture' and 'data' - var files = new BitmapFontFile(key, textureURL, xmlURL, this.path, textureXhrSettings, xmlXhrSettings); - - this.addFile(files.texture); - this.addFile(files.data); - - return this; -}); - -module.exports = BitmapFontFile; - - -/***/ }), -/* 782 */ -/***/ (function(module, exports, __webpack_require__) { - /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. @@ -111931,1169 +111786,29 @@ module.exports = BitmapFontFile; */ var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(2); - -/** - * @classdesc - * [description] - * - * @class GLSLFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {object} xhrSettings - [description] - */ -var GLSLFile = new Class({ - - Extends: File, - - initialize: - - function GLSLFile (key, url, path, xhrSettings) - { - var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); - - var fileConfig = { - type: 'glsl', - extension: GetFastValue(key, 'extension', 'glsl'), - responseType: 'text', - key: fileKey, - url: GetFastValue(key, 'file', url), - path: path, - xhrSettings: GetFastValue(key, 'xhr', xhrSettings) - }; - - File.call(this, fileConfig); - }, - - onProcess: function (callback) - { - this.state = CONST.FILE_PROCESSING; - - this.data = this.xhrLoader.responseText; - - this.onComplete(); - - callback(this); - } - -}); - -/** - * Adds a GLSL file to the current load queue. - * - * Note: This method will only be available if the GLSL File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#glsl - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('glsl', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new GLSLFile(key[i], url, this.path, xhrSettings)); - } - } - else - { - this.addFile(new GLSLFile(key, url, this.path, xhrSettings)); - } - - // For method chaining - return this; -}); - -module.exports = GLSLFile; - - -/***/ }), -/* 783 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(2); - -/** - * @classdesc - * [description] - * - * @class HTMLFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {string} path - [description] - * @param {object} xhrSettings - [description] - */ -var HTMLFile = new Class({ - - Extends: File, - - initialize: - - function HTMLFile (key, url, width, height, path, xhrSettings) - { - if (width === undefined) { width = 512; } - if (height === undefined) { height = 512; } - - var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); - - var fileConfig = { - type: 'html', - extension: GetFastValue(key, 'extension', 'html'), - responseType: 'text', - key: fileKey, - url: GetFastValue(key, 'file', url), - path: path, - xhrSettings: GetFastValue(key, 'xhr', xhrSettings), - config: { - width: width, - height: height - } - }; - - File.call(this, fileConfig); - }, - - onProcess: function (callback) - { - this.state = CONST.FILE_PROCESSING; - - var w = this.config.width; - var h = this.config.height; - - var data = []; - - data.push(''); - data.push(''); - data.push(''); - data.push(this.xhrLoader.responseText); - data.push(''); - data.push(''); - data.push(''); - - var svg = [ data.join('\n') ]; - var _this = this; - - try - { - var blob = new window.Blob(svg, { type: 'image/svg+xml;charset=utf-8' }); - } - catch (e) - { - _this.state = CONST.FILE_ERRORED; - - callback(_this); - - return; - } - - this.data = new Image(); - - this.data.crossOrigin = this.crossOrigin; - - this.data.onload = function () - { - File.revokeObjectURL(_this.data); - - _this.onComplete(); - - callback(_this); - }; - - this.data.onerror = function () - { - File.revokeObjectURL(_this.data); - - _this.state = CONST.FILE_ERRORED; - - callback(_this); - }; - - File.createObjectURL(this.data, blob, 'image/svg+xml'); - } - -}); - -/** - * Adds an HTML file to the current load queue. - * - * Note: This method will only be available if the HTML File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#html - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('html', function (key, url, width, height, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new HTMLFile(key[i], url, width, height, this.path, xhrSettings)); - } - } - else - { - this.addFile(new HTMLFile(key, url, width, height, this.path, xhrSettings)); - } - - // For method chaining - return this; -}); - -module.exports = HTMLFile; - - -/***/ }), -/* 784 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var FileTypesManager = __webpack_require__(7); -var ImageFile = __webpack_require__(58); -var JSONFile = __webpack_require__(57); -var NumberArray = __webpack_require__(319); - -/** - * Adds a Multi File Texture Atlas to the current load queue. - * - * Note: This method will only be available if the Multi Atlas File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#multiatlas - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string[]} textureURLs - [description] - * @param {string[]} atlasURLs - [description] - * @param {object} textureXhrSettings - [description] - * @param {object} atlasXhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('multiatlas', function (key, textureURLs, atlasURLs, textureXhrSettings, atlasXhrSettings) -{ - if (typeof textureURLs === 'number') - { - var total = textureURLs; - var suffix = (atlasURLs === undefined) ? '' : atlasURLs; - - textureURLs = NumberArray(0, total, key + suffix, '.png'); - atlasURLs = NumberArray(0, total, key + suffix, '.json'); - } - else - { - if (!Array.isArray(textureURLs)) - { - textureURLs = [ textureURLs ]; - } - - if (!Array.isArray(atlasURLs)) - { - atlasURLs = [ atlasURLs ]; - } - } - - var file; - var i = 0; - var multiKey; - - this._multilist[key] = []; - - for (i = 0; i < textureURLs.length; i++) - { - multiKey = '_MA_IMG_' + key + '_' + i.toString(); - - file = new ImageFile(multiKey, textureURLs[i], this.path, textureXhrSettings); - - this.addFile(file); - - this._multilist[key].push(multiKey); - } - - for (i = 0; i < atlasURLs.length; i++) - { - multiKey = '_MA_JSON_' + key + '_' + i.toString(); - - file = new JSONFile(multiKey, atlasURLs[i], this.path, atlasXhrSettings); - - this.addFile(file); - - this._multilist[key].push(multiKey); - } - - return this; -}); - - -/***/ }), -/* 785 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(2); var PluginManager = __webpack_require__(12); /** * @classdesc * [description] * - * @class PluginFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {object} xhrSettings - [description] - */ -var PluginFile = new Class({ - - Extends: File, - - initialize: - - function PluginFile (key, url, path, xhrSettings) - { - // If the url variable refers to a class, add the plugin directly - if (typeof url === 'function') - { - this.key = key; - window[key] = url; - window[key].register(PluginManager); - } - - var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); - - var fileConfig = { - type: 'script', - extension: GetFastValue(key, 'extension', 'js'), - responseType: 'text', - key: fileKey, - url: GetFastValue(key, 'file', url), - path: path, - xhrSettings: GetFastValue(key, 'xhr', xhrSettings) - }; - - File.call(this, fileConfig); - }, - - onProcess: function (callback) - { - this.state = CONST.FILE_PROCESSING; - - this.data = document.createElement('script'); - this.data.language = 'javascript'; - this.data.type = 'text/javascript'; - this.data.defer = false; - this.data.text = this.xhrLoader.responseText; - - document.head.appendChild(this.data); - - // Need to wait for onload? - window[this.key].register(PluginManager); - - this.onComplete(); - - callback(this); - } - -}); - -/** - * Adds a Plugin file to the current load queue. - * - * Note: This method will only be available if the Plugin File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#plugin - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('plugin', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new PluginFile(key[i], url, this.path, xhrSettings)); - } - } - else - { - this.addFile(new PluginFile(key, url, this.path, xhrSettings)); - } - - // For method chaining - return this; -}); - -module.exports = PluginFile; - - -/***/ }), -/* 786 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(2); - -/** - * @classdesc - * [description] - * - * @class ScriptFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {object} xhrSettings - [description] - */ -var ScriptFile = new Class({ - - Extends: File, - - initialize: - - function ScriptFile (key, url, path, xhrSettings) - { - var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); - - var fileConfig = { - type: 'script', - extension: GetFastValue(key, 'extension', 'js'), - responseType: 'text', - key: fileKey, - url: GetFastValue(key, 'file', url), - path: path, - xhrSettings: GetFastValue(key, 'xhr', xhrSettings) - }; - - File.call(this, fileConfig); - }, - - onProcess: function (callback) - { - this.state = CONST.FILE_PROCESSING; - - this.data = document.createElement('script'); - this.data.language = 'javascript'; - this.data.type = 'text/javascript'; - this.data.defer = false; - this.data.text = this.xhrLoader.responseText; - - document.head.appendChild(this.data); - - this.onComplete(); - - callback(this); - } - -}); - -/** - * Adds a JavaScript file to the current load queue. - * - * Note: This method will only be available if the Script File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#script - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('script', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new ScriptFile(key[i], url, this.path, xhrSettings)); - } - } - else - { - this.addFile(new ScriptFile(key, url, this.path, xhrSettings)); - } - - // For method chaining - return this; -}); - -module.exports = ScriptFile; - - -/***/ }), -/* 787 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var FileTypesManager = __webpack_require__(7); -var ImageFile = __webpack_require__(58); - -/** - * A Sprite Sheet File. - * - * @function Phaser.Loader.Filetypes.SpriteSheetFile - * @since 3.0.0 - * - * @param {string} key - The key of the file within the loader. - * @param {string} url - The url to load the texture file from. - * @param {object} config - Optional texture file specific XHR settings. - * @param {string} path - Optional texture file specific XHR settings. - * @param {object} xhrSettings - Optional atlas file specific XHR settings. - * - * @return {object} An object containing two File objects to be added to the loader. - */ -var SpriteSheetFile = function (key, url, config, path, xhrSettings) -{ - var image = new ImageFile(key, url, path, xhrSettings, config); - - // Override the File type - image.type = 'spritesheet'; - - return image; -}; - -/** - * Adds a Sprite Sheet file to the current load queue. - * - * Note: This method will only be available if the Sprite Sheet File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#spritesheet - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} config - config can include: frameWidth, frameHeight, startFrame, endFrame, margin, spacing. - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('spritesheet', function (key, url, config, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new SpriteSheetFile(key[i], url, null, this.path, xhrSettings)); - } - } - else - { - this.addFile(new SpriteSheetFile(key, url, config, this.path, xhrSettings)); - } - - // For method chaining - return this; -}); - -module.exports = SpriteSheetFile; - - -/***/ }), -/* 788 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(2); - -/** - * @classdesc - * [description] - * - * @class SVGFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {object} xhrSettings - [description] - */ -var SVGFile = new Class({ - - Extends: File, - - initialize: - - function SVGFile (key, url, path, xhrSettings) - { - var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); - - var fileConfig = { - type: 'svg', - extension: GetFastValue(key, 'extension', 'svg'), - responseType: 'text', - key: fileKey, - url: GetFastValue(key, 'file', url), - path: path, - xhrSettings: GetFastValue(key, 'xhr', xhrSettings) - }; - - File.call(this, fileConfig); - }, - - onProcess: function (callback) - { - this.state = CONST.FILE_PROCESSING; - - var svg = [ this.xhrLoader.responseText ]; - var _this = this; - - try - { - var blob = new window.Blob(svg, { type: 'image/svg+xml;charset=utf-8' }); - } - catch (e) - { - _this.state = CONST.FILE_ERRORED; - - callback(_this); - - return; - } - - this.data = new Image(); - - this.data.crossOrigin = this.crossOrigin; - - var retry = false; - - this.data.onload = function () - { - if(!retry) - { - File.revokeObjectURL(_this.data); - } - - _this.onComplete(); - - callback(_this); - }; - - this.data.onerror = function () - { - // Safari 8 re-try - if (!retry) - { - retry = true; - - File.revokeObjectURL(_this.data); - - _this.data.src = 'data:image/svg+xml,' + encodeURIComponent(svg.join('')); - } - else - { - _this.state = CONST.FILE_ERRORED; - - callback(_this); - } - }; - - File.createObjectURL(this.data, blob, 'image/svg+xml'); - } - -}); - -/** - * Adds an SVG file to the current load queue. - * - * Note: This method will only be available if the SVG File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#svg - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('svg', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new SVGFile(key[i], url, this.path, xhrSettings)); - } - } - else - { - this.addFile(new SVGFile(key, url, this.path, xhrSettings)); - } - - // For method chaining - return this; -}); - -module.exports = SVGFile; - - -/***/ }), -/* 789 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var File = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var TILEMAP_FORMATS = __webpack_require__(22); - -/** - * @classdesc - * [description] - * - * @class TilemapCSVFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {string} format - [description] - * @param {object} xhrSettings - [description] - */ -var TilemapCSVFile = new Class({ - - Extends: File, - - initialize: - - function TilemapCSVFile (key, url, path, format, xhrSettings) - { - var fileConfig = { - type: 'tilemapCSV', - extension: '.csv', - responseType: 'text', - key: key, - url: url, - path: path, - xhrSettings: xhrSettings - }; - - File.call(this, fileConfig); - - this.tilemapFormat = format; - }, - - onProcess: function (callback) - { - this.state = CONST.FILE_PROCESSING; - - this.data = this.xhrLoader.responseText; - - this.onComplete(); - - callback(this); - } - -}); - -/** - * Adds a Tilemap CSV file to the current load queue. - * - * Note: This method will only be available if the Tilemap CSV File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#tilemapCSV - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('tilemapCSV', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new TilemapCSVFile(key[i], url, this.path, TILEMAP_FORMATS.CSV, xhrSettings)); - } - } - else - { - this.addFile(new TilemapCSVFile(key, url, this.path, TILEMAP_FORMATS.CSV, xhrSettings)); - } - - // For method chaining - return this; -}); - -module.exports = TilemapCSVFile; - - -/***/ }), -/* 790 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var FileTypesManager = __webpack_require__(7); -var JSONFile = __webpack_require__(57); -var TILEMAP_FORMATS = __webpack_require__(22); - -/** - * A Tilemap File. - * - * @function Phaser.Loader.Filetypes.TilemapJSONFile - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {string} path - [description] - * @param {string} format - [description] - * @param {object} xhrSettings - [description] - * - * @return {object} An object containing two File objects to be added to the loader. - */ -var TilemapJSONFile = function (key, url, path, format, xhrSettings) -{ - var json = new JSONFile(key, url, path, xhrSettings); - - // Override the File type - json.type = 'tilemapJSON'; - - json.tilemapFormat = format; - - return json; -}; - -/** - * Adds a Tilemap (Tiled JSON Format) file to the current load queue. - * - * Note: This method will only be available if the Tilemap File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#tilemapTiledJSON - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('tilemapTiledJSON', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(TilemapJSONFile(key[i], url, this.path, TILEMAP_FORMATS.TILED_JSON, xhrSettings)); - } - } - else - { - this.addFile(TilemapJSONFile(key, url, this.path, TILEMAP_FORMATS.TILED_JSON, xhrSettings)); - } - - // For method chaining - return this; -}); - -/** - * Adds a Tilemap (Weltmeister Format) file to the current load queue. - * - * Note: This method will only be available if the Tilemap File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#tilemapWeltmeister - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {string} url - [description] - * @param {object} xhrSettings - [description] - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('tilemapWeltmeister', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(TilemapJSONFile(key[i], url, this.path, TILEMAP_FORMATS.WELTMEISTER, xhrSettings)); - } - } - else - { - this.addFile(TilemapJSONFile(key, url, this.path, TILEMAP_FORMATS.WELTMEISTER, xhrSettings)); - } - - // For method chaining - return this; -}); - -module.exports = TilemapJSONFile; - - -/***/ }), -/* 791 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var FileTypesManager = __webpack_require__(7); -var ImageFile = __webpack_require__(58); -var TextFile = __webpack_require__(320); - -/** - * An Atlas JSON File. - * - * @function Phaser.Loader.Filetypes.UnityAtlasFile - * @since 3.0.0 - * - * @param {string} key - The key of the file within the loader. - * @param {string} textureURL - The url to load the texture file from. - * @param {string} atlasURL - The url to load the atlas file from. - * @param {string} path - The path of the file. - * @param {object} textureXhrSettings - Optional texture file specific XHR settings. - * @param {object} atlasXhrSettings - Optional atlas file specific XHR settings. - * - * @return {object} An object containing two File objects to be added to the loader. - */ -var UnityAtlasFile = function (key, textureURL, atlasURL, path, textureXhrSettings, atlasXhrSettings) -{ - var image = new ImageFile(key, textureURL, path, textureXhrSettings); - var data = new TextFile(key, atlasURL, path, atlasXhrSettings); - - // Link them together - image.linkFile = data; - data.linkFile = image; - - // Set the type - image.linkType = 'unityatlas'; - data.linkType = 'unityatlas'; - - return { texture: image, data: data }; -}; - -/** - * Adds a Unity Texture Atlas file to the current load queue. - * - * Note: This method will only be available if the Unity Atlas File type has been built into Phaser. - * - * The file is **not** loaded immediately after calling this method. - * Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts. - * - * @method Phaser.Loader.LoaderPlugin#unityAtlas - * @since 3.0.0 - * - * @param {string} key - The key of the file within the loader. - * @param {string} textureURL - The url to load the texture file from. - * @param {string} atlasURL - The url to load the atlas file from. - * @param {object} textureXhrSettings - Optional texture file specific XHR settings. - * @param {object} atlasXhrSettings - Optional atlas file specific XHR settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('unityAtlas', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) -{ - // Returns an object with two properties: 'texture' and 'data' - var files = new UnityAtlasFile(key, textureURL, atlasURL, this.path, textureXhrSettings, atlasXhrSettings); - - this.addFile(files.texture); - this.addFile(files.data); - - return this; - -}); - -module.exports = UnityAtlasFile; - - -/***/ }), -/* 792 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(17); -var CustomSet = __webpack_require__(62); -var EventEmitter = __webpack_require__(14); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(2); -var ParseXMLBitmapFont = __webpack_require__(269); -var PluginManager = __webpack_require__(12); -var XHRSettings = __webpack_require__(90); - -/** - * @classdesc - * [description] - * - * @class LoaderPlugin - * @extends EventEmitter - * @memberOf Phaser.Loader + * @class UpdateList + * @memberOf Phaser.GameObjects * @constructor * @since 3.0.0 * * @param {Phaser.Scene} scene - [description] */ -var LoaderPlugin = new Class({ - - Extends: EventEmitter, +var UpdateList = new Class({ initialize: - function LoaderPlugin (scene) + function UpdateList (scene) { - EventEmitter.call(this); - /** * [description] * - * @name Phaser.Loader.LoaderPlugin#scene + * @name Phaser.GameObjects.UpdateList#scene * @type {Phaser.Scene} * @since 3.0.0 */ @@ -113102,7 +111817,7 @@ var LoaderPlugin = new Class({ /** * [description] * - * @name Phaser.Loader.LoaderPlugin#systems + * @name Phaser.GameObjects.UpdateList#systems * @type {Phaser.Scenes.Systems} * @since 3.0.0 */ @@ -113116,9657 +111831,19 @@ var LoaderPlugin = new Class({ /** * [description] * - * @name Phaser.Loader.LoaderPlugin#_multilist - * @type {object} - * @private - * @default {} - * @since 3.0.0 - */ - this._multilist = {}; - - // Inject the available filetypes into the Loader - FileTypesManager.install(this); - - var gameConfig = this.systems.game.config; - var sceneConfig = this.systems.settings.loader; - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#path - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.path = ''; - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#baseURL - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.baseURL = ''; - - this.setBaseURL(GetFastValue(sceneConfig, 'baseURL', gameConfig.loaderBaseURL)); - - this.setPath(GetFastValue(sceneConfig, 'path', gameConfig.loaderPath)); - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#enableParallel - * @type {boolean} - * @since 3.0.0 - */ - this.enableParallel = GetFastValue(sceneConfig, 'enableParallel', gameConfig.loaderEnableParallel); - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#maxParallelDownloads - * @type {integer} - * @since 3.0.0 - */ - this.maxParallelDownloads = GetFastValue(sceneConfig, 'maxParallelDownloads', gameConfig.loaderMaxParallelDownloads); - - /** - * xhr specific global settings (can be overridden on a per-file basis) - * - * @name Phaser.Loader.LoaderPlugin#xhr - * @type {Phaser.Loader.XHRSettings} - * @since 3.0.0 - */ - this.xhr = XHRSettings( - GetFastValue(sceneConfig, 'responseType', gameConfig.loaderResponseType), - GetFastValue(sceneConfig, 'async', gameConfig.loaderAsync), - GetFastValue(sceneConfig, 'user', gameConfig.loaderUser), - GetFastValue(sceneConfig, 'password', gameConfig.loaderPassword), - GetFastValue(sceneConfig, 'timeout', gameConfig.loaderTimeout) - ); - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#crossOrigin - * @type {string} - * @since 3.0.0 - */ - this.crossOrigin = GetFastValue(sceneConfig, 'crossOrigin', gameConfig.loaderCrossOrigin); - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#totalToLoad - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalToLoad = 0; - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#progress - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.progress = 0; - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#list - * @type {Phaser.Structs.Set} - * @since 3.0.0 - */ - this.list = new CustomSet(); - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#inflight - * @type {Phaser.Structs.Set} - * @since 3.0.0 - */ - this.inflight = new CustomSet(); - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#failed - * @type {Phaser.Structs.Set} - * @since 3.0.0 - */ - this.failed = new CustomSet(); - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#queue - * @type {Phaser.Structs.Set} - * @since 3.0.0 - */ - this.queue = new CustomSet(); - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#storage - * @type {Phaser.Structs.Set} - * @since 3.0.0 - */ - this.storage = new CustomSet(); - - /** - * [description] - * - * @name Phaser.Loader.LoaderPlugin#state - * @type {integer} - * @since 3.0.0 - */ - this.state = CONST.LOADER_IDLE; - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#boot - * @since 3.0.0 - */ - boot: function () - { - var eventEmitter = this.systems.events; - - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#setBaseURL - * @since 3.0.0 - * - * @param {string} url - [description] - * - * @return {Phaser.Loader.LoaderPlugin} This Loader object. - */ - setBaseURL: function (url) - { - if (url !== '' && url.substr(-1) !== '/') - { - url = url.concat('/'); - } - - this.baseURL = url; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#setPath - * @since 3.0.0 - * - * @param {string} path - [description] - * - * @return {Phaser.Loader.LoaderPlugin} This Loader object. - */ - setPath: function (path) - { - if (path !== '' && path.substr(-1) !== '/') - { - path = path.concat('/'); - } - - this.path = path; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#setCORS - * @since 3.0.0 - * - * @param {string} crossOrigin - [description] - * - * @return {Phaser.Loader.LoaderPlugin} This Loader object. - */ - setCORS: function (crossOrigin) - { - this.crossOrigin = crossOrigin; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#addFile - * @since 3.0.0 - * - * @param {Phaser.Loader.File} file - [description] - * - * @return {Phaser.Loader.File} [description] - */ - addFile: function (file) - { - if (!this.isReady()) - { - return -1; - } - - file.path = this.path; - - this.list.set(file); - - return file; - }, - - /** - * Is the Loader actively loading (or processing loaded files) - * - * @method Phaser.Loader.LoaderPlugin#isLoading - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isLoading: function () - { - return (this.state === CONST.LOADER_LOADING || this.state === CONST.LOADER_PROCESSING); - }, - - /** - * Is the Loader ready to start a new load? - * - * @method Phaser.Loader.LoaderPlugin#isReady - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isReady: function () - { - return (this.state === CONST.LOADER_IDLE || this.state === CONST.LOADER_COMPLETE || this.state === CONST.LOADER_FAILED); - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#start - * @since 3.0.0 - */ - start: function () - { - if (!this.isReady()) - { - return; - } - - this.progress = 0; - this.totalToLoad = this.list.size; - - this.emit('start', this); - - if (this.list.size === 0) - { - this.finishedLoading(); - } - else - { - this.state = CONST.LOADER_LOADING; - - this.failed.clear(); - this.inflight.clear(); - this.queue.clear(); - - this.queue.debug = true; - - this.updateProgress(); - - this.processLoadQueue(); - } - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#updateProgress - * @since 3.0.0 - */ - updateProgress: function () - { - this.progress = 1 - (this.list.size / this.totalToLoad); - - this.emit('progress', this.progress); - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#processLoadQueue - * @since 3.0.0 - */ - processLoadQueue: function () - { - this.list.each(function (file) - { - if (file.state === CONST.FILE_POPULATED || (file.state === CONST.FILE_PENDING && this.inflight.size < this.maxParallelDownloads)) - { - this.inflight.set(file); - - this.list.delete(file); - - this.loadFile(file); - } - - if (this.inflight.size === this.maxParallelDownloads) - { - // Tells the Set iterator to abort - return false; - } - - }, this); - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#loadFile - * @since 3.0.0 - * - * @param {Phaser.Loader.File} file - [description] - */ - loadFile: function (file) - { - // If the file doesn't have its own crossOrigin set, - // we'll use the Loaders (which is undefined by default) - if (!file.crossOrigin) - { - file.crossOrigin = this.crossOrigin; - } - - file.load(this); - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#nextFile - * @since 3.0.0 - * - * @param {Phaser.Loader.File} previousFile - [description] - * @param {boolean} success - [description] - */ - nextFile: function (previousFile, success) - { - // Move the file that just loaded from the inflight list to the queue or failed Set - - if (success) - { - this.emit('load', previousFile); - this.queue.set(previousFile); - } - else - { - this.emit('loaderror', previousFile); - this.failed.set(previousFile); - } - - this.inflight.delete(previousFile); - - this.updateProgress(); - - if (this.list.size > 0) - { - this.processLoadQueue(); - } - else if (this.inflight.size === 0) - { - this.finishedLoading(); - } - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#finishedLoading - * @since 3.0.0 - */ - finishedLoading: function () - { - if (this.state === CONST.LOADER_PROCESSING) - { - return; - } - - this.progress = 1; - - this.state = CONST.LOADER_PROCESSING; - - this.storage.clear(); - - if (this.queue.size === 0) - { - // Everything failed, so nothing to process - this.processComplete(); - } - else - { - this.queue.each(function (file) - { - file.onProcess(this.processUpdate.bind(this)); - }, this); - } - }, - - /** - * Called automatically by the File when it has finished processing. - * - * @method Phaser.Loader.LoaderPlugin#processUpdate - * @since 3.0.0 - * - * @param {Phaser.Loader.File} file - [description] - */ - processUpdate: function (file) - { - // This file has failed to load, so move it to the failed Set - if (file.state === CONST.FILE_ERRORED) - { - this.failed.set(file); - - if (file.linkFile) - { - this.queue.delete(file.linkFile); - } - - return this.removeFromQueue(file); - } - - // If we got here, then the file loaded - - // Special handling for multi-part files - - if (file.linkFile) - { - if (file.state === CONST.FILE_COMPLETE && file.linkFile.state === CONST.FILE_COMPLETE) - { - // Partner has loaded, so add them both to Storage - - this.storage.set({ type: file.linkType, fileA: file, fileB: file.linkFile }); - - this.queue.delete(file.linkFile); - - this.removeFromQueue(file); - } - } - else - { - this.storage.set(file); - - this.removeFromQueue(file); - } - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#removeFromQueue - * @since 3.0.0 - * - * @param {Phaser.Loader.File} file - [description] - */ - removeFromQueue: function (file) - { - this.queue.delete(file); - - if (this.queue.size === 0 && this.state === CONST.LOADER_PROCESSING) - { - // We've processed all the files we loaded - this.processComplete(); - } - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#processComplete - * @since 3.0.0 - */ - processComplete: function () - { - this.list.clear(); - this.inflight.clear(); - this.queue.clear(); - - this.processCallback(); - - this.state = CONST.LOADER_COMPLETE; - - this.emit('complete', this, this.storage.size, this.failed.size); - - // Move to a User setting: - // this.removeAllListeners(); - }, - - /** - * The Loader has finished. - * - * @method Phaser.Loader.LoaderPlugin#processCallback - * @since 3.0.0 - */ - processCallback: function () - { - if (this.storage.size === 0) - { - return; - } - - // The global Texture Manager - var cache = this.scene.sys.cache; - var textures = this.scene.sys.textures; - var anims = this.scene.sys.anims; - - // Process multiatlas groups first - - var file; - var fileA; - var fileB; - - for (var key in this._multilist) - { - var data = []; - var images = []; - var keys = this._multilist[key]; - - for (var i = 0; i < keys.length; i++) - { - file = this.storage.get('key', keys[i]); - - if (file) - { - if (file.type === 'image') - { - images.push(file.data); - } - else if (file.type === 'json') - { - data.push(file.data); - } - - this.storage.delete(file); - } - } - - // Do we have everything needed? - if (images.length + data.length === keys.length) - { - // Yup, add them to the Texture Manager - - // Is the data JSON Hash or JSON Array? - if (Array.isArray(data[0].textures) || Array.isArray(data[0].frames)) - { - textures.addAtlasJSONArray(key, images, data); - } - else - { - textures.addAtlasJSONHash(key, images, data); - } - } - } - - // Process all of the files - - // Because AnimationJSON may require images to be loaded first, we process them last - var animJSON = []; - - this.storage.each(function (file) - { - switch (file.type) - { - case 'animationJSON': - animJSON.push(file); - break; - - case 'image': - case 'svg': - case 'html': - textures.addImage(file.key, file.data); - break; - - case 'atlasjson': - - fileA = file.fileA; - fileB = file.fileB; - - if (fileA.type === 'image') - { - textures.addAtlas(fileA.key, fileA.data, fileB.data); - } - else - { - textures.addAtlas(fileB.key, fileB.data, fileA.data); - } - break; - - case 'dataimage': - - fileA = file.fileA; - fileB = file.fileB; - - if (fileA.linkParent) - { - textures.addImage(fileA.key, fileA.data, fileB.data); - } - else - { - textures.addImage(fileB.key, fileB.data, fileA.data); - } - break; - - case 'unityatlas': - - fileA = file.fileA; - fileB = file.fileB; - - if (fileA.type === 'image') - { - textures.addUnityAtlas(fileA.key, fileA.data, fileB.data); - } - else - { - textures.addUnityAtlas(fileB.key, fileB.data, fileA.data); - } - break; - - case 'bitmapfont': - - fileA = file.fileA; - fileB = file.fileB; - - if (fileA.type === 'image') - { - cache.bitmapFont.add(fileB.key, { data: ParseXMLBitmapFont(fileB.data), texture: fileA.key, frame: null }); - textures.addImage(fileA.key, fileA.data); - } - else - { - cache.bitmapFont.add(fileA.key, { data: ParseXMLBitmapFont(fileA.data), texture: fileB.key, frame: null }); - textures.addImage(fileB.key, fileB.data); - } - break; - - case 'spritesheet': - textures.addSpriteSheet(file.key, file.data, file.config); - break; - - case 'json': - cache.json.add(file.key, file.data); - break; - - case 'xml': - cache.xml.add(file.key, file.data); - break; - - case 'text': - cache.text.add(file.key, file.data); - break; - - case 'obj': - cache.obj.add(file.key, file.data); - break; - - case 'binary': - cache.binary.add(file.key, file.data); - break; - - case 'audio': - cache.audio.add(file.key, file.data); - break; - - case 'audioSprite': - - var files = [ file.fileA, file.fileB ]; - - files.forEach(function (file) - { - cache[file.type].add(file.key, file.data); - }); - - break; - - case 'glsl': - cache.shader.add(file.key, file.data); - break; - - case 'tilemapCSV': - case 'tilemapJSON': - cache.tilemap.add(file.key, { format: file.tilemapFormat, data: file.data }); - break; - } - }); - - animJSON.forEach(function (file) - { - anims.fromJSON(file.data); - }); - - this.storage.clear(); - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#saveJSON - * @since 3.0.0 - * - * @param {[type]} data - [description] - * @param {[type]} filename - [description] - * - * @return {[type]} [description] - */ - saveJSON: function (data, filename) - { - return this.save(JSON.stringify(data), filename); - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#save - * @since 3.0.0 - * - * @param {[type]} data - [description] - * @param {[type]} filename - [description] - * @param {[type]} filetype - [description] - * - * @return {Phaser.Loader.LoaderPlugin} This Loader plugin. - */ - save: function (data, filename, filetype) - { - if (filename === undefined) { filename = 'file.json'; } - if (filetype === undefined) { filetype = 'application/json'; } - - var blob = new Blob([ data ], { type: filetype }); - - var url = URL.createObjectURL(blob); - - var a = document.createElement('a'); - - a.download = filename; - a.textContent = 'Download ' + filename; - a.href = url; - a.click(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#reset - * @since 3.0.0 - */ - reset: function () - { - this.list.clear(); - this.inflight.clear(); - this.failed.clear(); - this.queue.clear(); - this.storage.clear(); - - var gameConfig = this.systems.game.config; - var sceneConfig = this.systems.settings.loader; - - this.setBaseURL(GetFastValue(sceneConfig, 'baseURL', gameConfig.loaderBaseURL)); - this.setPath(GetFastValue(sceneConfig, 'path', gameConfig.loaderPath)); - - this.state = CONST.LOADER_IDLE; - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#loadArray - * @since 3.0.0 - * - * @param {array} files - [description] - * - * @return {boolean} [description] - */ - loadArray: function (files) - { - if (Array.isArray(files)) - { - for (var i = 0; i < files.length; i++) - { - this.file(files[i]); - } - } - - return (this.list.size > 0); - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#file - * @since 3.0.0 - * - * @param {object} file - [description] - * - * @return {Phaser.Loader.File} [description] - */ - file: function (file) - { - var entry; - var key = file.key; - - switch (file.type) - { - case 'spritesheet': - entry = this.spritesheet(key, file.url, file.config, file.xhrSettings); - break; - - case 'atlas': - entry = this.atlas(key, file.textureURL, file.atlasURL, file.textureXhrSettings, file.atlasXhrSettings); - break; - - case 'bitmapFont': - entry = this.bitmapFont(key, file.textureURL, file.xmlURL, file.textureXhrSettings, file.xmlXhrSettings); - break; - - case 'multiatlas': - entry = this.multiatlas(key, file.textureURLs, file.atlasURLs, file.textureXhrSettings, file.atlasXhrSettings); - break; - - case 'audioSprite': - entry = this.audioSprite(key, file.urls, file.json, file.config, file.audioXhrSettings, file.jsonXhrSettings); - break; - - // image, json, xml, binary, text, glsl, svg, obj - default: - entry = this[file.type](key, file.url, file.xhrSettings); - break; - } - - return entry; - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this.reset(); - this.state = CONST.LOADER_SHUTDOWN; - }, - - /** - * [description] - * - * @method Phaser.Loader.LoaderPlugin#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.reset(); - this.state = CONST.LOADER_DESTROYED; - } - -}); - -PluginManager.register('Loader', LoaderPlugin, 'load'); - -module.exports = LoaderPlugin; - - -/***/ }), -/* 793 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(16); -var Extend = __webpack_require__(23); - -/** - * @namespace Phaser.Math - */ - -var PhaserMath = { - - // Collections of functions - Angle: __webpack_require__(794), - Distance: __webpack_require__(802), - Easing: __webpack_require__(805), - Fuzzy: __webpack_require__(806), - Interpolation: __webpack_require__(812), - Pow2: __webpack_require__(816), - Snap: __webpack_require__(818), - - // Single functions - Average: __webpack_require__(822), - Bernstein: __webpack_require__(322), - Between: __webpack_require__(231), - CatmullRom: __webpack_require__(123), - CeilTo: __webpack_require__(823), - Clamp: __webpack_require__(61), - DegToRad: __webpack_require__(35), - Difference: __webpack_require__(824), - Factorial: __webpack_require__(323), - FloatBetween: __webpack_require__(276), - FloorTo: __webpack_require__(825), - FromPercent: __webpack_require__(65), - GetSpeed: __webpack_require__(826), - IsEven: __webpack_require__(827), - IsEvenStrict: __webpack_require__(828), - Linear: __webpack_require__(124), - MaxAdd: __webpack_require__(829), - MinSub: __webpack_require__(830), - Percent: __webpack_require__(831), - RadToDeg: __webpack_require__(221), - RandomXY: __webpack_require__(832), - RandomXYZ: __webpack_require__(209), - RandomXYZW: __webpack_require__(210), - Rotate: __webpack_require__(324), - RotateAround: __webpack_require__(188), - RotateAroundDistance: __webpack_require__(113), - RoundAwayFromZero: __webpack_require__(325), - RoundTo: __webpack_require__(833), - SinCosTableGenerator: __webpack_require__(834), - SmootherStep: __webpack_require__(195), - SmoothStep: __webpack_require__(196), - TransformXY: __webpack_require__(251), - Within: __webpack_require__(835), - Wrap: __webpack_require__(50), - - // Vector classes - Vector2: __webpack_require__(6), - Vector3: __webpack_require__(51), - Vector4: __webpack_require__(120), - Matrix3: __webpack_require__(213), - Matrix4: __webpack_require__(119), - Quaternion: __webpack_require__(212), - RotateVec3: __webpack_require__(211) - -}; - -// Merge in the consts - -PhaserMath = Extend(false, PhaserMath, CONST); - -// Export it - -module.exports = PhaserMath; - - -/***/ }), -/* 794 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Angle - */ - -module.exports = { - - Between: __webpack_require__(795), - BetweenY: __webpack_require__(796), - BetweenPoints: __webpack_require__(797), - BetweenPointsY: __webpack_require__(798), - Reverse: __webpack_require__(799), - RotateTo: __webpack_require__(800), - ShortestBetween: __webpack_require__(801), - Normalize: __webpack_require__(321), - Wrap: __webpack_require__(163), - WrapDegrees: __webpack_require__(164) - -}; - - -/***/ }), -/* 795 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Angle.Between - * @since 3.0.0 - * - * @param {number} x1 - [description] - * @param {number} y1 - [description] - * @param {number} x2 - [description] - * @param {number} y2 - [description] - * - * @return {number} [description] - */ -var Between = function (x1, y1, x2, y2) -{ - return Math.atan2(y2 - y1, x2 - x1); -}; - -module.exports = Between; - - -/***/ }), -/* 796 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Angle.BetweenY - * @since 3.0.0 - * - * @param {number} x1 - [description] - * @param {number} y1 - [description] - * @param {number} x2 - [description] - * @param {number} y2 - [description] - * - * @return {number} [description] - */ -var BetweenY = function (x1, y1, x2, y2) -{ - return Math.atan2(x2 - x1, y2 - y1); -}; - -module.exports = BetweenY; - - -/***/ }), -/* 797 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Angle.BetweenPoints - * @since 3.0.0 - * - * @param {Phaser.Geom.Point|object} point1 - [description] - * @param {Phaser.Geom.Point|object} point2 - [description] - * - * @return {number} [description] - */ -var BetweenPoints = function (point1, point2) -{ - return Math.atan2(point2.y - point1.y, point2.x - point1.x); -}; - -module.exports = BetweenPoints; - - -/***/ }), -/* 798 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Angle.BetweenPointsY - * @since 3.0.0 - * - * @param {Phaser.Geom.Point|object} point1 - [description] - * @param {Phaser.Geom.Point|object} point2 - [description] - * - * @return {number} [description] - */ -var BetweenPointsY = function (point1, point2) -{ - return Math.atan2(point2.x - point1.x, point2.y - point1.y); -}; - -module.exports = BetweenPointsY; - - -/***/ }), -/* 799 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Normalize = __webpack_require__(321); - -/** - * [description] - * - * @function Phaser.Math.Angle.Reverse - * @since 3.0.0 - * - * @param {number} angle - [description] - * - * @return {number} [description] - */ -var Reverse = function (angle) -{ - return Normalize(angle + Math.PI); -}; - -module.exports = Reverse; - - -/***/ }), -/* 800 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH_CONST = __webpack_require__(16); - -/** - * Rotates `currentAngle` towards `targetAngle`, taking the shortest rotation distance. The `lerp` argument is the amount to rotate by in this call. - * - * @function Phaser.Math.Angle.RotateTo - * @since 3.0.0 - * - * @param {number} currentAngle - The current angle, in radians. - * @param {number} targetAngle - The target angle to rotate to, in radians. - * @param {number} [lerp=0.05] - The lerp value to add to the current angle. - * - * @return {number} The adjusted angle. - */ -var RotateTo = function (currentAngle, targetAngle, lerp) -{ - if (lerp === undefined) { lerp = 0.05; } - - if (currentAngle === targetAngle) - { - return currentAngle; - } - - if (Math.abs(targetAngle - currentAngle) <= lerp || Math.abs(targetAngle - currentAngle) >= (MATH_CONST.PI2 - lerp)) - { - currentAngle = targetAngle; - } - else - { - if (Math.abs(targetAngle - currentAngle) > Math.PI) - { - if (targetAngle < currentAngle) - { - targetAngle += MATH_CONST.PI2; - } - else - { - targetAngle -= MATH_CONST.PI2; - } - } - - if (targetAngle > currentAngle) - { - currentAngle += lerp; - } - else if (targetAngle < currentAngle) - { - currentAngle -= lerp; - } - } - - return currentAngle; -}; - -module.exports = RotateTo; - - -/***/ }), -/* 801 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Gets the shortest angle between `angle1` and `angle2`. - * Both angles must be in the range -180 to 180, which is the same clamped - * range that `sprite.angle` uses, so you can pass in two sprite angles to - * this method and get the shortest angle back between the two of them. - * - * The angle returned will be in the same range. If the returned angle is - * greater than 0 then it's a counter-clockwise rotation, if < 0 then it's - * a clockwise rotation. - * - * @function Phaser.Math.Angle.ShortestBetween - * @since 3.0.0 - * - * @param {number} angle1 - The first angle in the range -180 to 180. - * @param {number} angle2 - The second angle in the range -180 to 180. - * - * @return {number} The shortest angle, in degrees. If greater than zero it's a counter-clockwise rotation. - */ -var ShortestBetween = function (angle1, angle2) -{ - var difference = angle2 - angle1; - - if (difference === 0) - { - return 0; - } - - var times = Math.floor((difference - (-180)) / 360); - - return difference - (times * 360); - -}; - -module.exports = ShortestBetween; - - -/***/ }), -/* 802 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Distance - */ - -module.exports = { - - Between: __webpack_require__(42), - Power: __webpack_require__(803), - Squared: __webpack_require__(804) - -}; - - -/***/ }), -/* 803 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Distance.Power - * @since 3.0.0 - * - * @param {number} x1 - [description] - * @param {number} y1 - [description] - * @param {number} x2 - [description] - * @param {number} y2 - [description] - * @param {number} pow - [description] - * - * @return {number} [description] - */ -var DistancePower = function (x1, y1, x2, y2, pow) -{ - if (pow === undefined) { pow = 2; } - - return Math.sqrt(Math.pow(x2 - x1, pow) + Math.pow(y2 - y1, pow)); -}; - -module.exports = DistancePower; - - -/***/ }), -/* 804 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Distance.Squared - * @since 3.0.0 - * - * @param {number} x1 - [description] - * @param {number} y1 - [description] - * @param {number} x2 - [description] - * @param {number} y2 - [description] - * - * @return {number} [description] - */ -var DistanceSquared = function (x1, y1, x2, y2) -{ - var dx = x1 - x2; - var dy = y1 - y2; - - return dx * dx + dy * dy; -}; - -module.exports = DistanceSquared; - - -/***/ }), -/* 805 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing - */ - -module.exports = { - - Back: __webpack_require__(277), - Bounce: __webpack_require__(278), - Circular: __webpack_require__(279), - Cubic: __webpack_require__(280), - Elastic: __webpack_require__(281), - Expo: __webpack_require__(282), - Linear: __webpack_require__(283), - Quadratic: __webpack_require__(284), - Quartic: __webpack_require__(285), - Quintic: __webpack_require__(286), - Sine: __webpack_require__(287), - Stepped: __webpack_require__(288) - -}; - - -/***/ }), -/* 806 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Fuzzy - */ - -module.exports = { - - Ceil: __webpack_require__(807), - Equal: __webpack_require__(808), - Floor: __webpack_require__(809), - GreaterThan: __webpack_require__(810), - LessThan: __webpack_require__(811) - -}; - - -/***/ }), -/* 807 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Fuzzy.Ceil - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {float} [epsilon=0.0001] - [description] - * - * @return {number} [description] - */ -var Ceil = function (value, epsilon) -{ - if (epsilon === undefined) { epsilon = 0.0001; } - - return Math.ceil(value - epsilon); -}; - -module.exports = Ceil; - - -/***/ }), -/* 808 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Fuzzy.Equal - * @since 3.0.0 - * - * @param {number} a - [description] - * @param {number} b - [description] - * @param {float} [epsilon=0.0001] - [description] - * - * @return {boolean} [description] - */ -var Equal = function (a, b, epsilon) -{ - if (epsilon === undefined) { epsilon = 0.0001; } - - return Math.abs(a - b) < epsilon; -}; - -module.exports = Equal; - - -/***/ }), -/* 809 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Fuzzy.Floor - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {float} [epsilon=0.0001] - [description] - * - * @return {number} [description] - */ -var Floor = function (value, epsilon) -{ - if (epsilon === undefined) { epsilon = 0.0001; } - - return Math.floor(value + epsilon); -}; - -module.exports = Floor; - - -/***/ }), -/* 810 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Fuzzy.GreaterThan - * @since 3.0.0 - * - * @param {number} a - [description] - * @param {number} b - [description] - * @param {float} [epsilon=0.0001] - [description] - * - * @return {boolean} [description] - */ -var GreaterThan = function (a, b, epsilon) -{ - if (epsilon === undefined) { epsilon = 0.0001; } - - return a > b - epsilon; -}; - -module.exports = GreaterThan; - - -/***/ }), -/* 811 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Fuzzy.LessThan - * @since 3.0.0 - * - * @param {number} a - [description] - * @param {number} b - [description] - * @param {float} [epsilon=0.0001] - [description] - * - * @return {boolean} [description] - */ -var LessThan = function (a, b, epsilon) -{ - if (epsilon === undefined) { epsilon = 0.0001; } - - return a < b + epsilon; -}; - -module.exports = LessThan; - - -/***/ }), -/* 812 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Interpolation - */ - -module.exports = { - Bezier: __webpack_require__(813), - CatmullRom: __webpack_require__(814), - CubicBezier: __webpack_require__(219), - Linear: __webpack_require__(815), - QuadraticBezier: __webpack_require__(224) -}; - - -/***/ }), -/* 813 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Bernstein = __webpack_require__(322); - -/** - * [description] - * - * @function Phaser.Math.Interpolation.Bezier - * @since 3.0.0 - * - * @param {number} v - [description] - * @param {number} k - [description] - * - * @return {number} [description] - */ -var BezierInterpolation = function (v, k) -{ - var b = 0; - var n = v.length - 1; - - for (var i = 0; i <= n; i++) - { - b += Math.pow(1 - k, n - i) * Math.pow(k, i) * v[i] * Bernstein(n, i); - } - - return b; -}; - -module.exports = BezierInterpolation; - - -/***/ }), -/* 814 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CatmullRom = __webpack_require__(123); - -/** - * [description] - * - * @function Phaser.Math.Interpolation.CatmullRom - * @since 3.0.0 - * - * @param {number} v - [description] - * @param {number} k - [description] - * - * @return {number} [description] - */ -var CatmullRomInterpolation = function (v, k) -{ - var m = v.length - 1; - var f = m * k; - var i = Math.floor(f); - - if (v[0] === v[m]) - { - if (k < 0) - { - i = Math.floor(f = m * (1 + k)); - } - - return CatmullRom(f - i, v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m]); - } - else - { - if (k < 0) - { - return v[0] - (CatmullRom(-f, v[0], v[0], v[1], v[1]) - v[0]); - } - - if (k > 1) - { - return v[m] - (CatmullRom(f - m, v[m], v[m], v[m - 1], v[m - 1]) - v[m]); - } - - return CatmullRom(f - i, v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2]); - } -}; - -module.exports = CatmullRomInterpolation; - - -/***/ }), -/* 815 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Linear = __webpack_require__(124); - -/** - * [description] - * - * @function Phaser.Math.Interpolation.Linear - * @since 3.0.0 - * - * @param {float} v - [description] - * @param {number} k - [description] - * - * @return {number} [description] - */ -var LinearInterpolation = function (v, k) -{ - var m = v.length - 1; - var f = m * k; - var i = Math.floor(f); - - if (k < 0) - { - return Linear(v[0], v[1], f); - } - - if (k > 1) - { - return Linear(v[m], v[m - 1], m - f); - } - - return Linear(v[i], v[(i + 1 > m) ? m : i + 1], f - i); -}; - -module.exports = LinearInterpolation; - - -/***/ }), -/* 816 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Pow2 - */ - -module.exports = { - - GetNext: __webpack_require__(291), - IsSize: __webpack_require__(127), - IsValue: __webpack_require__(817) - -}; - - -/***/ }), -/* 817 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Tests the value and returns `true` if it is a power of two. - * - * @function Phaser.Math.Pow2.IsValuePowerOfTwo - * @since 3.0.0 - * - * @param {number} value - The value to check if it's a power of two. - * - * @return {boolean} Returns `true` if `value` is a power of two, otherwise `false`. - */ -var IsValuePowerOfTwo = function (value) -{ - return (value > 0 && (value & (value - 1)) === 0); -}; - -module.exports = IsValuePowerOfTwo; - - -/***/ }), -/* 818 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Snap - */ - -module.exports = { - - Ceil: __webpack_require__(819), - Floor: __webpack_require__(820), - To: __webpack_require__(821) - -}; - - -/***/ }), -/* 819 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Snap.Ceil - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} gap - [description] - * @param {number} [start=0] - [description] - * - * @return {number} [description] - */ -var SnapCeil = function (value, gap, start) -{ - if (start === undefined) { start = 0; } - - if (gap === 0) - { - return value; - } - - value -= start; - value = gap * Math.ceil(value / gap); - - return start + value; -}; - -module.exports = SnapCeil; - - -/***/ }), -/* 820 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Snap.Floor - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} gap - [description] - * @param {number} [start=0] - [description] - * - * @return {number} [description] - */ -var SnapFloor = function (value, gap, start) -{ - if (start === undefined) { start = 0; } - - if (gap === 0) - { - return value; - } - - value -= start; - value = gap * Math.floor(value / gap); - - return start + value; -}; - -module.exports = SnapFloor; - - -/***/ }), -/* 821 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Snap.To - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} gap - [description] - * @param {number} [start=0] - [description] - * - * @return {number} [description] - */ -var SnapTo = function (value, gap, start) -{ - if (start === undefined) { start = 0; } - - if (gap === 0) - { - return value; - } - - value -= start; - value = gap * Math.round(value / gap); - - return start + value; -}; - -module.exports = SnapTo; - - -/***/ }), -/* 822 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Average - * @since 3.0.0 - * - * @param {number[]} values - [description] - * - * @return {number} [description] - */ -var Average = function (values) -{ - var sum = 0; - - for (var i = 0; i < values.length; i++) - { - sum += (+values[i]); - } - - return sum / values.length; -}; - -module.exports = Average; - - -/***/ }), -/* 823 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.CeilTo - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} [place=0] - [description] - * @param {integer} [base=10] - [description] - * - * @return {number} [description] - */ -var CeilTo = function (value, place, base) -{ - if (place === undefined) { place = 0; } - if (base === undefined) { base = 10; } - - var p = Math.pow(base, -place); - - return Math.ceil(value * p) / p; -}; - -module.exports = CeilTo; - - -/***/ }), -/* 824 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.Difference - * @since 3.0.0 - * - * @param {number} a - [description] - * @param {number} b - [description] - * - * @return {number} [description] - */ -var Difference = function (a, b) -{ - return Math.abs(a - b); -}; - -module.exports = Difference; - - -/***/ }), -/* 825 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.FloorTo - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {integer} [place=0 - [description] - * @param {integer} [base=10] - [description] - * - * @return {number} [description] - */ -var FloorTo = function (value, place, base) -{ - if (place === undefined) { place = 0; } - if (base === undefined) { base = 10; } - - var p = Math.pow(base, -place); - - return Math.floor(value * p) / p; -}; - -module.exports = FloorTo; - - -/***/ }), -/* 826 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.GetSpeed - * @since 3.0.0 - * - * @param {number} distance - The distance to travel in pixels. - * @param {integer} time - The time, in ms, to cover the distance in. - * - * @return {number} The amount you will need to increment the position by each step in order to cover the distance in the time given. - */ -var GetSpeed = function (distance, time) -{ - return (distance / time) / 1000; -}; - -module.exports = GetSpeed; - - -/***/ }), -/* 827 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.IsEven - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {boolean} [description] - */ -var IsEven = function (value) -{ - // Use abstract equality == for "is number" test - - // eslint-disable-next-line eqeqeq - return (value == parseFloat(value)) ? !(value % 2) : void 0; -}; - -module.exports = IsEven; - - -/***/ }), -/* 828 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.IsEvenStrict - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {boolean} [description] - */ -var IsEvenStrict = function (value) -{ - // Use strict equality === for "is number" test - return (value === parseFloat(value)) ? !(value % 2) : void 0; -}; - -module.exports = IsEvenStrict; - - -/***/ }), -/* 829 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.MaxAdd - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} amount - [description] - * @param {number} max - [description] - * - * @return {number} [description] - */ -var MaxAdd = function (value, amount, max) -{ - return Math.min(value + amount, max); -}; - -module.exports = MaxAdd; - - -/***/ }), -/* 830 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.MinSub - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} amount - [description] - * @param {number} min - [description] - * - * @return {number} [description] - */ -var MinSub = function (value, amount, min) -{ - return Math.max(value - amount, min); -}; - -module.exports = MinSub; - - -/***/ }), -/* 831 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Work out what percentage `value` is of the range between `min` and `max`. - * If `max` isn't given then it will return the percentage of `value` to `min`. - * - * You can optionally specify an `upperMax` value, which is a mid-way point in the range that represents 100%, after which the % starts to go down to zero again. - * - * @function Phaser.Math.Percent - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} min - [description] - * @param {number} [max] - [description] - * @param {number} [upperMax] - [description] - * - * @return {float} A value between 0 and 1 representing the percentage. - */ -var Percent = function (value, min, max, upperMax) -{ - if (max === undefined) { max = min + 1; } - - var percentage = (value - min) / (max - min); - - if (percentage > 1) - { - if (upperMax !== undefined) - { - percentage = ((upperMax - value)) / (upperMax - max); - - if (percentage < 0) - { - percentage = 0; - } - } - else - { - percentage = 1; - } - } - else if (percentage < 0) - { - percentage = 0; - } - - return percentage; -}; - -module.exports = Percent; - - -/***/ }), -/* 832 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.RandomXY - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} vector - [description] - * @param {float} scale - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ -var RandomXY = function (vector, scale) -{ - if (scale === undefined) { scale = 1; } - - var r = Math.random() * 2 * Math.PI; - - vector.x = Math.cos(r) * scale; - vector.y = Math.sin(r) * scale; - - return vector; -}; - -module.exports = RandomXY; - - -/***/ }), -/* 833 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.RoundTo - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {integer} [place=0] - [description] - * @param {integer} [base=10] - [description] - * - * @return {number} [description] - */ -var RoundTo = function (value, place, base) -{ - if (place === undefined) { place = 0; } - if (base === undefined) { base = 10; } - - var p = Math.pow(base, -place); - - return Math.round(value * p) / p; -}; - -module.exports = RoundTo; - - -/***/ }), -/* 834 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - - -/** - * [description] - * - * @function Phaser.Math.SinCosTableGenerator - * @since 3.0.0 - * - * @param {number} length - [description] - * @param {number} sinAmp - [description] - * @param {number} cosAmp - [description] - * @param {number} frequency - [description] - * - * @return {object} [description] - */ -var SinCosTableGenerator = function (length, sinAmp, cosAmp, frequency) -{ - if (sinAmp === undefined) { sinAmp = 1; } - if (cosAmp === undefined) { cosAmp = 1; } - if (frequency === undefined) { frequency = 1; } - - frequency *= Math.PI / length; - - var cos = []; - var sin = []; - - for (var c = 0; c < length; c++) - { - cosAmp -= sinAmp * frequency; - sinAmp += cosAmp * frequency; - - cos[c] = cosAmp; - sin[c] = sinAmp; - } - - return { - sin: sin, - cos: cos, - length: length - }; -}; - -module.exports = SinCosTableGenerator; - - -/***/ }), -/* 835 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Checks if the two values are within the given `tolerance` of each other. - * - * @function Phaser.Math.Within - * @since 3.0.0 - * - * @param {number} a - [description] - * @param {number} b - [description] - * @param {number} tolerance - The tolerance. Anything equal to or less than this value is considered as being within range. - * - * @return {boolean} Returns `true` if `a` is less than or equal to the tolerance of `b`. - */ -var Within = function (a, b, tolerance) -{ - return (Math.abs(a - b) <= tolerance); -}; - -module.exports = Within; - - -/***/ }), -/* 836 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Physics.Arcade - */ - -module.exports = { - - ArcadePhysics: __webpack_require__(837), - Body: __webpack_require__(332), - Collider: __webpack_require__(333), - Factory: __webpack_require__(326), - Group: __webpack_require__(329), - Image: __webpack_require__(327), - Sprite: __webpack_require__(91), - StaticBody: __webpack_require__(340), - StaticGroup: __webpack_require__(330), - World: __webpack_require__(331) - -}; - - -/***/ }), -/* 837 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Factory = __webpack_require__(326); -var GetFastValue = __webpack_require__(2); -var Merge = __webpack_require__(104); -var PluginManager = __webpack_require__(12); -var World = __webpack_require__(331); -var DistanceBetween = __webpack_require__(42); -var DegToRad = __webpack_require__(35); - -// All methods in this class are available under `this.physics` in a Scene. - -/** - * @classdesc - * [description] - * - * @class ArcadePhysics - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var ArcadePhysics = new Class({ - - initialize: - - function ArcadePhysics (scene) - { - /** - * [description] - * - * @name Phaser.Physics.Arcade.ArcadePhysics#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.ArcadePhysics#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - if (!scene.sys.settings.isBooted) - { - scene.sys.events.once('boot', this.boot, this); - } - - /** - * [description] - * - * @name Phaser.Physics.Arcade.ArcadePhysics#config - * @type {object} - * @since 3.0.0 - */ - this.config = this.getConfig(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.ArcadePhysics#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.ArcadePhysics#add - * @type {Phaser.Physics.Arcade.Factory} - * @since 3.0.0 - */ - this.add; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.ArcadePhysics#getConfig - * @since 3.0.0 - * - * @return {object} [description] - */ - getConfig: function () - { - var gameConfig = this.systems.game.config.physics; - var sceneConfig = this.systems.settings.physics; - - var config = Merge( - GetFastValue(sceneConfig, 'arcade', {}), - GetFastValue(gameConfig, 'arcade', {}) - ); - - return config; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.ArcadePhysics#boot - * @since 3.0.0 - */ - boot: function () - { - this.world = new World(this.scene, this.config); - this.add = new Factory(this.world); - - var eventEmitter = this.systems.events; - - eventEmitter.on('update', this.world.update, this.world); - eventEmitter.on('postupdate', this.world.postUpdate, this.world); - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); - }, - - /** - * Checks for overlaps between two Game Objects. The objects can be any Game Object that have an Arcade Physics Body. - * - * Unlike {@link #collide} the objects are NOT automatically separated or have any physics applied, they merely test for overlap results. - * - * Both the first and second parameter can be arrays of objects, of differing types. - * If two arrays are passed, the contents of the first parameter will be tested against all contents of the 2nd parameter. - * - * ##### Tilemaps - * - * Any overlapping tiles, including blank/null tiles, will give a positive result. Tiles marked via {@link Phaser.Tilemap#setCollision} (and similar methods) have no special status, and callbacks added via {@link Phaser.Tilemap#setTileIndexCallback} or {@link Phaser.Tilemap#setTileLocationCallback} are not invoked. So calling this method without any callbacks isn't very useful. - * - * If you're interested only in whether an object overlaps a certain tile or class of tiles, filter the tiles with `processCallback` and then use the result returned by this method. Blank/null tiles can be excluded by their {@link Phaser.Tile#index index} (-1). - * - * If you want to take action on certain overlaps, examine the tiles in `collideCallback` and then handle as you like. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#overlap - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject|array} object1 - The first object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param {Phaser.GameObjects.GameObject|array} object2 - The second object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param {function} [overlapCallback=null] - An optional callback function that is called if the objects overlap. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter. - * @param {function} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `overlapCallback` will only be called if this callback returns `true`. - * @param {object} [callbackContext] - The context in which to run the callbacks. - * - * @return {boolean} True if an overlap occurred otherwise false. - */ - overlap: function (object1, object2, overlapCallback, processCallback, callbackContext) - { - if (overlapCallback === undefined) { overlapCallback = null; } - if (processCallback === undefined) { processCallback = null; } - if (callbackContext === undefined) { callbackContext = overlapCallback; } - - return this.world.collideObjects(object1, object2, overlapCallback, processCallback, callbackContext, true); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.ArcadePhysics#collide - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject|array} object1 - The first object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param {Phaser.GameObjects.GameObject|array} object2 - The second object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param {function} [collideCallback=null] - An optional callback function that is called if the objects collide. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter. - * @param {function} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. - * @param {object} [callbackContext] - The context in which to run the callbacks. - * - * @return {boolean} True if a collision occurred otherwise false. - */ - collide: function (object1, object2, collideCallback, processCallback, callbackContext) - { - if (collideCallback === undefined) { collideCallback = null; } - if (processCallback === undefined) { processCallback = null; } - if (callbackContext === undefined) { callbackContext = collideCallback; } - - return this.world.collideObjects(object1, object2, collideCallback, processCallback, callbackContext, false); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.ArcadePhysics#pause - * @since 3.0.0 - * - * @return {[type]} [description] - */ - pause: function () - { - return this.world.pause(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.ArcadePhysics#resume - * @since 3.0.0 - * - * @return {[type]} [description] - */ - resume: function () - { - return this.world.resume(); - }, - - /** - * Sets the acceleration.x/y property on the game object so it will move towards the x/y coordinates at the given speed (in pixels per second sq.) - * - * You must give a maximum speed value, beyond which the game object won't go any faster. - * - * Note: The game object does not continuously track the target. If the target changes location during transit the game object will not modify its course. - * Note: The game object doesn't stop moving once it reaches the destination coordinates. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#accelerateTo - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. - * @param {number} x - The x coordinate to accelerate towards. - * @param {number} y - The y coordinate to accelerate towards. - * @param {number} [speed=60] - The speed it will accelerate in pixels per second. - * @param {number} [xSpeedMax=500] - The maximum x velocity the game object can reach. - * @param {number} [ySpeedMax=500] - The maximum y velocity the game object can reach. - * - * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. - */ - accelerateTo: function (gameObject, x, y, speed, xSpeedMax, ySpeedMax) - { - if (speed === undefined) { speed = 60; } - - var angle = Math.atan2(y - gameObject.y, x - gameObject.x); - - gameObject.body.acceleration.setToPolar(angle, speed); - - if (xSpeedMax !== undefined && ySpeedMax !== undefined) - { - gameObject.body.maxVelocity.set(xSpeedMax, ySpeedMax); - } - - return angle; - }, - - /** - * Sets the acceleration.x/y property on the game object so it will move towards the x/y coordinates at the given speed (in pixels per second sq.) - * - * You must give a maximum speed value, beyond which the game object won't go any faster. - * - * Note: The game object does not continuously track the target. If the target changes location during transit the game object will not modify its course. - * Note: The game object doesn't stop moving once it reaches the destination coordinates. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#accelerateToObject - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. - * @param {Phaser.GameObjects.GameObject} destination - The Game Object to move towards. Can be any object but must have visible x/y properties. - * @param {number} [speed=60] - The speed it will accelerate in pixels per second. - * @param {number} [xSpeedMax=500] - The maximum x velocity the game object can reach. - * @param {number} [ySpeedMax=500] - The maximum y velocity the game object can reach. - * - * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. - */ - accelerateToObject: function (gameObject, destination, speed, xSpeedMax, ySpeedMax) - { - return this.accelerateTo(gameObject, destination.x, destination.y, speed, xSpeedMax, ySpeedMax); - }, - - /** - * From a set of points or display objects, find the one closest to a source point or object. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#closest - * @since 3.0.0 - * - * @param {object} source - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. - * - * @return {Phaser.Physics.Arcade.Body} The closest Body to the given source point. - */ - closest: function (source) - { - var bodies = this.tree.all(); - - var min = Number.MAX_VALUE; - var closest = null; - var x = source.x; - var y = source.y; - - for (var i = bodies.length - 1; i >= 0; i--) - { - var target = bodies[i]; - var distance = DistanceBetween(x, y, target.x, target.y); - - if (distance < min) - { - closest = target; - min = distance; - } - } - - return closest; - }, - - /** - * From a set of points or display objects, find the one farthest from a source point or object. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#furthest - * @since 3.0.0 - * - * @param {object} source - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. - * - * @return {Phaser.Physics.Arcade.Body} The Body furthest from the given source point. - */ - furthest: function (source) - { - var bodies = this.tree.all(); - - var max = -1; - var farthest = null; - var x = source.x; - var y = source.y; - - for (var i = bodies.length - 1; i >= 0; i--) - { - var target = bodies[i]; - var distance = DistanceBetween(x, y, target.x, target.y); - - if (distance > max) - { - farthest = target; - max = distance; - } - } - - return farthest; - }, - - /** - * Move the given display object towards the x/y coordinates at a steady velocity. - * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. - * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. - * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. - * Note: The display object doesn't stop moving once it reaches the destination coordinates. - * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) - * - * @method Phaser.Physics.Arcade.ArcadePhysics#moveTo - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. - * @param {number} x - The x coordinate to move towards. - * @param {number} y - The y coordinate to move towards. - * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) - * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. - * - * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. - */ - moveTo: function (gameObject, x, y, speed, maxTime) - { - if (speed === undefined) { speed = 60; } - if (maxTime === undefined) { maxTime = 0; } - - var angle = Math.atan2(y - gameObject.y, x - gameObject.x); - - if (maxTime > 0) - { - // We know how many pixels we need to move, but how fast? - speed = DistanceBetween(gameObject.x, gameObject.y, x, y) / (maxTime / 1000); - } - - gameObject.body.velocity.setToPolar(angle, speed); - - return angle; - }, - - /** - * Move the given display object towards the destination object at a steady velocity. - * If you specify a maxTime then it will adjust the speed (overwriting what you set) so it arrives at the destination in that number of seconds. - * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. - * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. - * Note: The display object doesn't stop moving once it reaches the destination coordinates. - * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) - * - * @method Phaser.Physics.Arcade.ArcadePhysics#moveToObject - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. - * @param {object} destination - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. - * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) - * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. - * - * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. - */ - moveToObject: function (gameObject, destination, speed, maxTime) - { - return this.moveTo(gameObject, destination.x, destination.y, speed, maxTime); - }, - - /** - * Given the angle (in degrees) and speed calculate the velocity and return it as a Point object, or set it to the given point object. - * One way to use this is: velocityFromAngle(angle, 200, sprite.velocity) which will set the values directly to the sprites velocity and not create a new Point object. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#velocityFromAngle - * @since 3.0.0 - * - * @param {number} angle - The angle in degrees calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) - * @param {number} [speed=60] - The speed it will move, in pixels per second sq. - * @param {Phaser.Math.Vector2} vec2 - The Vector2 in which the x and y properties will be set to the calculated velocity. - * - * @return {Phaser.Math.Vector2} The Vector2 that stores the velocity. - */ - velocityFromAngle: function (angle, speed, vec2) - { - if (speed === undefined) { speed = 60; } - - return vec2.setToPolar(DegToRad(angle), speed); - }, - - /** - * Given the rotation (in radians) and speed calculate the velocity and return it as a Point object, or set it to the given point object. - * One way to use this is: velocityFromRotation(rotation, 200, sprite.velocity) which will set the values directly to the sprites velocity and not create a new Point object. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#velocityFromRotation - * @since 3.0.0 - * - * @param {number} rotation - The angle in radians. - * @param {number} [speed=60] - The speed it will move, in pixels per second sq. - * @param {Phaser.Math.Vector2} vec2 - The Vector2 in which the x and y properties will be set to the calculated velocity. - * - * @return {Phaser.Math.Vector2} The Vector2 that stores the velocity. - */ - velocityFromRotation: function (rotation, speed, vec2) - { - if (speed === undefined) { speed = 60; } - - return vec2.setToPolar(rotation, speed); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.ArcadePhysics#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this.world.shutdown(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.ArcadePhysics#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.world.destroy(); - } - -}); - -PluginManager.register('ArcadePhysics', ArcadePhysics, 'arcadePhysics'); - -module.exports = ArcadePhysics; - - -/***/ }), -/* 838 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Acceleration - * @since 3.0.0 - */ -var Acceleration = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Acceleration#setAcceleration - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setAcceleration: function (x, y) - { - this.body.acceleration.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Acceleration#setAccelerationX - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setAccelerationX: function (value) - { - this.body.acceleration.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Acceleration#setAccelerationY - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setAccelerationY: function (value) - { - this.body.acceleration.y = value; - - return this; - } - -}; - -module.exports = Acceleration; - - -/***/ }), -/* 839 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Angular - * @since 3.0.0 - */ -var Angular = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Angular#setAngularVelocity - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setAngularVelocity: function (value) - { - this.body.angularVelocity = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Angular#setAngularAcceleration - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setAngularAcceleration: function (value) - { - this.body.angularAcceleration = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Angular#setAngularDrag - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setAngularDrag: function (value) - { - this.body.angularDrag = value; - - return this; - } - -}; - -module.exports = Angular; - - -/***/ }), -/* 840 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Bounce - * @since 3.0.0 - */ -var Bounce = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Bounce#setBounce - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setBounce: function (x, y) - { - this.body.bounce.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Bounce#setBounceX - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setBounceX: function (value) - { - this.body.bounce.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Bounce#setBounceY - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setBounceY: function (value) - { - this.body.bounce.y = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Bounce#setCollideWorldBounds - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setCollideWorldBounds: function (value) - { - this.body.collideWorldBounds = value; - - return this; - } - -}; - -module.exports = Bounce; - - -/***/ }), -/* 841 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Debug - * @since 3.0.0 - */ -var Debug = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Debug#setDebug - * @since 3.0.0 - * - * @param {[type]} showBody - [description] - * @param {[type]} showVelocity - [description] - * @param {[type]} bodyColor - [description] - * - * @return {[type]} [description] - */ - setDebug: function (showBody, showVelocity, bodyColor) - { - this.debugShowBody = showBody; - this.debugShowVelocity = showVelocity; - this.debugBodyColor = bodyColor; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Debug#setDebugBodyColor - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setDebugBodyColor: function (value) - { - this.body.debugBodyColor = value; - - return this; - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Debug#debugShowBody - * @type {[type]} - * @since 3.0.0 - */ - debugShowBody: { - - get: function () - { - return this.body.debugShowBody; - }, - - set: function (value) - { - this.body.debugShowBody = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Debug#debugShowVelocity - * @type {[type]} - * @since 3.0.0 - */ - debugShowVelocity: { - - get: function () - { - return this.body.debugShowVelocity; - }, - - set: function (value) - { - this.body.debugShowVelocity = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Debug#debugBodyColor - * @type {[type]} - * @since 3.0.0 - */ - debugBodyColor: { - - get: function () - { - return this.body.debugBodyColor; - }, - - set: function (value) - { - this.body.debugBodyColor = value; - } - - } - -}; - -module.exports = Debug; - - -/***/ }), -/* 842 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Drag - * @since 3.0.0 - */ -var Drag = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Drag#setDrag - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setDrag: function (x, y) - { - this.body.drag.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Drag#setDragX - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setDragX: function (value) - { - this.body.drag.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Drag#setDragY - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setDragY: function (value) - { - this.body.drag.y = value; - - return this; - } - -}; - -module.exports = Drag; - - -/***/ }), -/* 843 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Enable - * @since 3.0.0 - */ -var Enable = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Enable#enableBody - * @since 3.0.0 - * - * @param {boolean} reset - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {boolean} enableGameObject - [description] - * @param {boolean} showGameObject - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object. - */ - enableBody: function (reset, x, y, enableGameObject, showGameObject) - { - if (reset) - { - this.body.reset(x, y); - } - - if (enableGameObject) - { - this.body.gameObject.active = true; - } - - if (showGameObject) - { - this.body.gameObject.visible = true; - } - - this.body.enable = true; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Enable#disableBody - * @since 3.0.0 - * - * @param {boolean} [disableGameObject=false] - [description] - * @param {boolean} [hideGameObject=false] - [description] - * - * @return {Phaser.GameObjects.GameObject} This Game Object. - */ - disableBody: function (disableGameObject, hideGameObject) - { - if (disableGameObject === undefined) { disableGameObject = false; } - if (hideGameObject === undefined) { hideGameObject = false; } - - this.body.stop(); - - this.body.enable = false; - - if (disableGameObject) - { - this.body.gameObject.active = false; - } - - if (hideGameObject) - { - this.body.gameObject.visible = false; - } - - return this; - }, - - /** - * Syncs the Bodies position and size with its parent Game Object. - * You don't need to call this for Dynamic Bodies, as it happens automatically. - * But for Static bodies it's a useful way of modifying the position of a Static Body - * in the Physics World, based on its Game Object. - * - * @method Phaser.Physics.Arcade.Components.Enable#refreshBody - * @since 3.1.0 - * - * @return {Phaser.GameObjects.GameObject} This Game Object. - */ - refreshBody: function () - { - this.body.updateFromGameObject(); - - return this; - } - -}; - -module.exports = Enable; - - -/***/ }), -/* 844 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Friction - * @since 3.0.0 - */ -var Friction = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Friction#setFriction - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setFriction: function (x, y) - { - this.body.friction.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Friction#setFrictionX - * @since 3.0.0 - * - * @param {[type]} x - [description] - * - * @return {[type]} [description] - */ - setFrictionX: function (x) - { - this.body.friction.x = x; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Friction#setFrictionY - * @since 3.0.0 - * - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setFrictionY: function (y) - { - this.body.friction.y = y; - - return this; - } - -}; - -module.exports = Friction; - - -/***/ }), -/* 845 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Gravity - * @since 3.0.0 - */ -var Gravity = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Gravity#setGravity - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setGravity: function (x, y) - { - this.body.gravity.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Gravity#setGravityX - * @since 3.0.0 - * - * @param {[type]} x - [description] - * - * @return {[type]} [description] - */ - setGravityX: function (x) - { - this.body.gravity.x = x; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Gravity#setGravityY - * @since 3.0.0 - * - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setGravityY: function (y) - { - this.body.gravity.y = y; - - return this; - } - -}; - -module.exports = Gravity; - - -/***/ }), -/* 846 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Immovable - * @since 3.0.0 - */ -var Immovable = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Immovable#setImmovable - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setImmovable: function (value) - { - if (value === undefined) { value = true; } - - this.body.immovable = value; - - return this; - } - -}; - -module.exports = Immovable; - - -/***/ }), -/* 847 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Mass - * @since 3.0.0 - */ -var Mass = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Mass#setMass - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setMass: function (value) - { - this.body.mass = value; - - return this; - } - -}; - -module.exports = Mass; - - -/***/ }), -/* 848 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Size - * @since 3.0.0 - */ -var Size = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Size#setOffset - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setOffset: function (x, y) - { - this.body.setOffset(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Size#setSize - * @since 3.0.0 - * - * @param {[type]} width - [description] - * @param {[type]} height - [description] - * @param {[type]} center - [description] - * - * @return {[type]} [description] - */ - setSize: function (width, height, center) - { - this.body.setSize(width, height, center); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Size#setCircle - * @since 3.0.0 - * - * @param {[type]} radius - [description] - * @param {[type]} offsetX - [description] - * @param {[type]} offsetY - [description] - * - * @return {[type]} [description] - */ - setCircle: function (radius, offsetX, offsetY) - { - this.body.setCircle(radius, offsetX, offsetY); - - return this; - } - -}; - -module.exports = Size; - - -/***/ }), -/* 849 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Velocity - * @since 3.0.0 - */ -var Velocity = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Velocity#setVelocity - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setVelocity: function (x, y) - { - this.body.velocity.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Velocity#setVelocityX - * @since 3.0.0 - * - * @param {[type]} x - [description] - * - * @return {[type]} [description] - */ - setVelocityX: function (x) - { - this.body.velocity.x = x; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Velocity#setVelocityY - * @since 3.0.0 - * - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setVelocityY: function (y) - { - this.body.velocity.y = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Velocity#setMaxVelocity - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setMaxVelocity: function (x, y) - { - if (y === undefined) { y = x; } - - this.body.maxVelocity.set(x, y); - - return this; - } - -}; - -module.exports = Velocity; - - -/***/ }), -/* 850 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Physics.Arcade.Tilemap.ProcessTileCallbacks - * @since 3.0.0 - * - * @param {[type]} tile - [description] - * @param {Phaser.GameObjects.Sprite} sprite - [description] - * - * @return {boolean} [description] - */ -var ProcessTileCallbacks = function (tile, sprite) -{ - // Tile callbacks take priority over layer level callbacks - if (tile.collisionCallback) - { - return !tile.collisionCallback.call(tile.collisionCallbackContext, sprite, tile); - } - else if (tile.layer.callbacks[tile.index]) - { - return !tile.layer.callbacks[tile.index].callback.call( - tile.layer.callbacks[tile.index].callbackContext, sprite, tile - ); - } - - return true; -}; - -module.exports = ProcessTileCallbacks; - - -/***/ }), -/* 851 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var TileCheckX = __webpack_require__(852); -var TileCheckY = __webpack_require__(854); -var TileIntersectsBody = __webpack_require__(339); - -/** - * The core separation function to separate a physics body and a tile. - * - * @function Phaser.Physics.Arcade.Tilemap.SeparateTile - * @since 3.0.0 - * - * @param {number} i - [description] - * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. - * @param {Phaser.Tilemaps.Tile} tile - The tile to collide against. - * @param {Phaser.Geom.Rectangle} tileWorldRect - [description] - * @param {Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer} tilemapLayer - The tilemapLayer to collide against. - * @param {number} tileBias - [description] - * - * @return {boolean} Returns true if the body was separated, otherwise false. - */ -var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer, tileBias) -{ - var tileLeft = tileWorldRect.left; - var tileTop = tileWorldRect.top; - var tileRight = tileWorldRect.right; - var tileBottom = tileWorldRect.bottom; - var faceHorizontal = tile.faceLeft || tile.faceRight; - var faceVertical = tile.faceTop || tile.faceBottom; - - // We don't need to go any further if this tile doesn't actually have any colliding faces. This - // could happen if the tile was meant to be collided with re: a callback, but otherwise isn't - // needed for separation. - if (!faceHorizontal && !faceVertical) - { - return false; - } - - var ox = 0; - var oy = 0; - var minX = 0; - var minY = 1; - - if (body.deltaAbsX() > body.deltaAbsY()) - { - // Moving faster horizontally, check X axis first - minX = -1; - } - else if (body.deltaAbsX() < body.deltaAbsY()) - { - // Moving faster vertically, check Y axis first - minY = -1; - } - - if (body.deltaX() !== 0 && body.deltaY() !== 0 && faceHorizontal && faceVertical) - { - // We only need do this if both axes have colliding faces AND we're moving in both - // directions - minX = Math.min(Math.abs(body.position.x - tileRight), Math.abs(body.right - tileLeft)); - minY = Math.min(Math.abs(body.position.y - tileBottom), Math.abs(body.bottom - tileTop)); - } - - if (minX < minY) - { - if (faceHorizontal) - { - ox = TileCheckX(body, tile, tileLeft, tileRight, tileBias); - - // That's horizontal done, check if we still intersects? If not then we can return now - if (ox !== 0 && !TileIntersectsBody(tileWorldRect, body)) - { - return true; - } - } - - if (faceVertical) - { - oy = TileCheckY(body, tile, tileTop, tileBottom, tileBias); - } - } - else - { - if (faceVertical) - { - oy = TileCheckY(body, tile, tileTop, tileBottom, tileBias); - - // That's vertical done, check if we still intersects? If not then we can return now - if (oy !== 0 && !TileIntersectsBody(tileWorldRect, body)) - { - return true; - } - } - - if (faceHorizontal) - { - ox = TileCheckX(body, tile, tileLeft, tileRight, tileBias); - } - } - - return (ox !== 0 || oy !== 0); -}; - -module.exports = SeparateTile; - - -/***/ }), -/* 852 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ProcessTileSeparationX = __webpack_require__(853); - -/** - * Check the body against the given tile on the X axis. - * - * @function Phaser.Physics.Arcade.Tilemap.TileCheckX - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. - * @param {Phaser.Tilemaps.Tile} tile - The tile to check. - * @param {number} tileLeft - [description] - * @param {number} tileRight - [description] - * @param {number} tileBias - [description] - * - * @return {number} The amount of separation that occurred. - */ -var TileCheckX = function (body, tile, tileLeft, tileRight, tileBias) -{ - var ox = 0; - - if (body.deltaX() < 0 && !body.blocked.left && tile.collideRight && body.checkCollision.left) - { - // Body is moving LEFT - if (tile.faceRight && body.x < tileRight) - { - ox = body.x - tileRight; - - if (ox < -tileBias) - { - ox = 0; - } - } - } - else if (body.deltaX() > 0 && !body.blocked.right && tile.collideLeft && body.checkCollision.right) - { - // Body is moving RIGHT - if (tile.faceLeft && body.right > tileLeft) - { - ox = body.right - tileLeft; - - if (ox > tileBias) - { - ox = 0; - } - } - } - - if (ox !== 0) - { - if (body.customSeparateX) - { - body.overlapX = ox; - } - else - { - ProcessTileSeparationX(body, ox); - } - } - - return ox; -}; - -module.exports = TileCheckX; - - -/***/ }), -/* 853 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Internal function to process the separation of a physics body from a tile. - * - * @function Phaser.Physics.Arcade.Tilemap.ProcessTileSeparationX - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. - * @param {number} x - The x separation amount. - */ -var ProcessTileSeparationX = function (body, x) -{ - if (x < 0) - { - body.blocked.left = true; - } - else if (x > 0) - { - body.blocked.right = true; - } - - body.position.x -= x; - - if (body.bounce.x === 0) - { - body.velocity.x = 0; - } - else - { - body.velocity.x = -body.velocity.x * body.bounce.x; - } -}; - -module.exports = ProcessTileSeparationX; - - -/***/ }), -/* 854 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ProcessTileSeparationY = __webpack_require__(855); - -/** - * Check the body against the given tile on the Y axis. - * - * @function Phaser.Physics.Arcade.Tilemap.TileCheckY - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. - * @param {Phaser.Tilemaps.Tile} tile - The tile to check. - * @param {number} tileTop - [description] - * @param {number} tileBottom - [description] - * @param {number} tileBias - [description] - * - * @return {number} The amount of separation that occurred. - */ -var TileCheckY = function (body, tile, tileTop, tileBottom, tileBias) -{ - var oy = 0; - - if (body.deltaY() < 0 && !body.blocked.up && tile.collideDown && body.checkCollision.up) - { - // Body is moving UP - if (tile.faceBottom && body.y < tileBottom) - { - oy = body.y - tileBottom; - - if (oy < -tileBias) - { - oy = 0; - } - } - } - else if (body.deltaY() > 0 && !body.blocked.down && tile.collideUp && body.checkCollision.down) - { - // Body is moving DOWN - if (tile.faceTop && body.bottom > tileTop) - { - oy = body.bottom - tileTop; - - if (oy > tileBias) - { - oy = 0; - } - } - } - - if (oy !== 0) - { - if (body.customSeparateY) - { - body.overlapY = oy; - } - else - { - ProcessTileSeparationY(body, oy); - } - } - - return oy; -}; - -module.exports = TileCheckY; - - -/***/ }), -/* 855 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Internal function to process the separation of a physics body from a tile. - * - * @function Phaser.Physics.Arcade.Tilemap.ProcessTileSeparationY - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. - * @param {number} y - The y separation amount. - */ -var ProcessTileSeparationY = function (body, y) -{ - if (y < 0) - { - body.blocked.up = true; - } - else if (y > 0) - { - body.blocked.down = true; - } - - body.position.y -= y; - - if (body.bounce.y === 0) - { - body.velocity.y = 0; - } - else - { - body.velocity.y = -body.velocity.y * body.bounce.y; - } -}; - -module.exports = ProcessTileSeparationY; - - -/***/ }), -/* 856 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetOverlapX = __webpack_require__(334); - -/** - * [description] - * - * @function Phaser.Physics.Arcade.SeparateX - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {boolean} overlapOnly - [description] - * @param {number} bias - [description] - * - * @return {boolean} [description] - */ -var SeparateX = function (body1, body2, overlapOnly, bias) -{ - var overlap = GetOverlapX(body1, body2, overlapOnly, bias); - - // Can't separate two immovable bodies, or a body with its own custom separation logic - if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateX || body2.customSeparateX) - { - // return true if there was some overlap, otherwise false - return (overlap !== 0) || (body1.embedded && body2.embedded); - } - - // Adjust their positions and velocities accordingly (if there was any overlap) - var v1 = body1.velocity.x; - var v2 = body2.velocity.x; - - if (!body1.immovable && !body2.immovable) - { - overlap *= 0.5; - - body1.x -= overlap; - body2.x += overlap; - - var nv1 = Math.sqrt((v2 * v2 * body2.mass) / body1.mass) * ((v2 > 0) ? 1 : -1); - var nv2 = Math.sqrt((v1 * v1 * body1.mass) / body2.mass) * ((v1 > 0) ? 1 : -1); - var avg = (nv1 + nv2) * 0.5; - - nv1 -= avg; - nv2 -= avg; - - body1.velocity.x = avg + nv1 * body1.bounce.x; - body2.velocity.x = avg + nv2 * body2.bounce.x; - } - else if (!body1.immovable) - { - body1.x -= overlap; - body1.velocity.x = v2 - v1 * body1.bounce.x; - - // This is special case code that handles things like vertically moving platforms you can ride - if (body2.moves) - { - body1.y += (body2.y - body2.prev.y) * body2.friction.y; - } - } - else - { - body2.x += overlap; - body2.velocity.x = v1 - v2 * body2.bounce.x; - - // This is special case code that handles things like vertically moving platforms you can ride - if (body1.moves) - { - body2.y += (body1.y - body1.prev.y) * body1.friction.y; - } - } - - // If we got this far then there WAS overlap, and separation is complete, so return true - return true; -}; - -module.exports = SeparateX; - - -/***/ }), -/* 857 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetOverlapY = __webpack_require__(335); - -/** - * [description] - * - * @function Phaser.Physics.Arcade.SeparateY - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {boolean} overlapOnly - [description] - * @param {number} bias - [description] - * - * @return {boolean} [description] - */ -var SeparateY = function (body1, body2, overlapOnly, bias) -{ - var overlap = GetOverlapY(body1, body2, overlapOnly, bias); - - // Can't separate two immovable bodies, or a body with its own custom separation logic - if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateY || body2.customSeparateY) - { - // return true if there was some overlap, otherwise false - return (overlap !== 0) || (body1.embedded && body2.embedded); - } - - // Adjust their positions and velocities accordingly (if there was any overlap) - var v1 = body1.velocity.y; - var v2 = body2.velocity.y; - - if (!body1.immovable && !body2.immovable) - { - overlap *= 0.5; - - body1.y -= overlap; - body2.y += overlap; - - var nv1 = Math.sqrt((v2 * v2 * body2.mass) / body1.mass) * ((v2 > 0) ? 1 : -1); - var nv2 = Math.sqrt((v1 * v1 * body1.mass) / body2.mass) * ((v1 > 0) ? 1 : -1); - var avg = (nv1 + nv2) * 0.5; - - nv1 -= avg; - nv2 -= avg; - - body1.velocity.y = avg + nv1 * body1.bounce.y; - body2.velocity.y = avg + nv2 * body2.bounce.y; - } - else if (!body1.immovable) - { - body1.y -= overlap; - body1.velocity.y = v2 - v1 * body1.bounce.y; - - // This is special case code that handles things like horizontal moving platforms you can ride - if (body2.moves) - { - body1.x += (body2.x - body2.prev.x) * body2.friction.x; - } - } - else - { - body2.y += overlap; - body2.velocity.y = v1 - v2 * body2.bounce.y; - - // This is special case code that handles things like horizontal moving platforms you can ride - if (body1.moves) - { - body2.x += (body1.x - body1.prev.x) * body1.friction.x; - } - } - - // If we got this far then there WAS overlap, and separation is complete, so return true - return true; -}; - -module.exports = SeparateY; - - -/***/ }), -/* 858 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Phaser.Physics.Impact.Body.Components - -module.exports = { - - Acceleration: __webpack_require__(964), - BodyScale: __webpack_require__(965), - BodyType: __webpack_require__(966), - Bounce: __webpack_require__(967), - CheckAgainst: __webpack_require__(968), - Collides: __webpack_require__(969), - Debug: __webpack_require__(970), - Friction: __webpack_require__(971), - Gravity: __webpack_require__(972), - Offset: __webpack_require__(973), - SetGameObject: __webpack_require__(974), - Velocity: __webpack_require__(975) - -}; - - -/***/ }), -/* 859 */ -/***/ (function(module, exports, __webpack_require__) { - -/** -* The `Matter.Axes` module contains methods for creating and manipulating sets of axes. -* -* @class Axes -*/ - -var Axes = {}; - -module.exports = Axes; - -var Vector = __webpack_require__(94); -var Common = __webpack_require__(38); - -(function() { - - /** - * Creates a new set of axes from the given vertices. - * @method fromVertices - * @param {vertices} vertices - * @return {axes} A new axes from the given vertices - */ - Axes.fromVertices = function(vertices) { - var axes = {}; - - // find the unique axes, using edge normal gradients - for (var i = 0; i < vertices.length; i++) { - var j = (i + 1) % vertices.length, - normal = Vector.normalise({ - x: vertices[j].y - vertices[i].y, - y: vertices[i].x - vertices[j].x - }), - gradient = (normal.y === 0) ? Infinity : (normal.x / normal.y); - - // limit precision - gradient = gradient.toFixed(3).toString(); - axes[gradient] = normal; - } - - return Common.values(axes); - }; - - /** - * Rotates a set of axes by the given angle. - * @method rotate - * @param {axes} axes - * @param {number} angle - */ - Axes.rotate = function(axes, angle) { - if (angle === 0) - return; - - var cos = Math.cos(angle), - sin = Math.sin(angle); - - for (var i = 0; i < axes.length; i++) { - var axis = axes[i], - xx; - xx = axis.x * cos - axis.y * sin; - axis.y = axis.x * sin + axis.y * cos; - axis.x = xx; - } - }; - -})(); - - -/***/ }), -/* 860 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Phaser.Physics.Matter.Body.Components - -module.exports = { - - Bounce: __webpack_require__(981), - Collision: __webpack_require__(982), - Force: __webpack_require__(983), - Friction: __webpack_require__(984), - Gravity: __webpack_require__(985), - Mass: __webpack_require__(986), - Static: __webpack_require__(987), - Sensor: __webpack_require__(988), - SetBody: __webpack_require__(989), - Sleep: __webpack_require__(990), - Transform: __webpack_require__(991), - Velocity: __webpack_require__(992) - -}; - - -/***/ }), -/* 861 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Bodies = __webpack_require__(92); -var Body = __webpack_require__(60); -var Class = __webpack_require__(0); -var Components = __webpack_require__(860); -var GetFastValue = __webpack_require__(2); -var HasValue = __webpack_require__(72); -var Vertices = __webpack_require__(93); - -/** - * @classdesc - * A wrapper around a Tile that provides access to a corresponding Matter body. A tile can only - * have one Matter body associated with it. You can either pass in an existing Matter body for - * the tile or allow the constructor to create the corresponding body for you. If the Tile has a - * collision group (defined in Tiled), those shapes will be used to create the body. If not, the - * tile's rectangle bounding box will be used. - * - * The corresponding body will be accessible on the Tile itself via Tile.physics.matterBody. - * - * Note: not all Tiled collision shapes are supported. See - * Phaser.Physics.Matter.TileBody#setFromTileCollision for more information. - * - * @class MatterTileBody - * @memberOf Phaser.Physics.Matter.TileBody - * @constructor - * @since 3.0.0 - * - * @extends Phaser.Physics.Matter.Components.Bounce - * @extends Phaser.Physics.Matter.Components.Collision - * @extends Phaser.Physics.Matter.Components.Friction - * @extends Phaser.Physics.Matter.Components.Gravity - * @extends Phaser.Physics.Matter.Components.Mass - * @extends Phaser.Physics.Matter.Components.Sensor - * @extends Phaser.Physics.Matter.Components.Sleep - * @extends Phaser.Physics.Matter.Components.Static - * - * @param {Phaser.Physics.Matter.World} world - [description] - * @param {Phaser.GameObjects.Tile} tile - The target tile that should have a Matter body. - * @param {object} [options] - Options to be used when creating the Matter body. See - * Phaser.Physics.Matter.Matter.Body for a list of what Matter accepts. - * @param {Phaser.Physics.Matter.Matter.Body} [options.body=null] - An existing Matter body to - * be used instead of creating a new one. - * @param {boolean} [options.isStatic=true] - Whether or not the newly created body should be - * made static. This defaults to true since typically tiles should not be moved. - * @param {boolean} [options.addToWorld=true] - Whether or not to add the newly created body (or - * existing body if options.body is used) to the Matter world. - */ -var MatterTileBody = new Class({ - - Mixins: [ - Components.Bounce, - Components.Collision, - Components.Friction, - Components.Gravity, - Components.Mass, - Components.Sensor, - Components.Sleep, - Components.Static - ], - - initialize: - - function MatterTileBody (world, tile, options) - { - /** - * The tile object the body is associated with. - * - * @name Phaser.Physics.Matter.MatterTileBody#tile - * @type {Phaser.GameObjects.Tile} - * @since 3.0.0 - */ - this.tile = tile; - - /** - * The Matter world the body exists within. - * - * @name Phaser.Physics.Matter.MatterTileBody#world - * @type {Phaser.Physics.Matter.World} - * @since 3.0.0 - */ - this.world = world; - - // Install a reference to 'this' on the tile and ensure there can only be one matter body - // associated with the tile - if (tile.physics.matterBody) - { - tile.physics.matterBody.destroy(); - } - - tile.physics.matterBody = this; - - // Set the body either from an existing body (if provided), the shapes in the tileset - // collision layer (if it exists) or a rectangle matching the tile. - var body = GetFastValue(options, 'body', null); - var addToWorld = GetFastValue(options, 'addToWorld', true); - - if (!body) - { - var collisionGroup = tile.getCollisionGroup(); - var collisionObjects = GetFastValue(collisionGroup, 'objects', []); - - if (collisionObjects.length > 0) - { - this.setFromTileCollision(options); - } - else - { - this.setFromTileRectangle(options); - } - } - else - { - this.setBody(body, addToWorld); - } - }, - - /** - * Sets the current body to a rectangle that matches the bounds of the tile. - * - * @method Phaser.Physics.Matter.TileBody#setFromTileRectangle - * @since 3.0.0 - * - * @param {object} [options] - Options to be used when creating the Matter body. See - * Phaser.Physics.Matter.Matter.Body for a list of what Matter accepts. - * @param {boolean} [options.isStatic=true] - Whether or not the newly created body should be - * made static. This defaults to true since typically tiles should not be moved. - * @param {boolean} [options.addToWorld=true] - Whether or not to add the newly created body (or - * existing body if options.body is used) to the Matter world. - * - * @return {Phaser.Physics.Matter.TileBody} This TileBody object. - */ - setFromTileRectangle: function (options) - { - if (options === undefined) { options = {}; } - if (!HasValue(options, 'isStatic')) { options.isStatic = true; } - if (!HasValue(options, 'addToWorld')) { options.addToWorld = true; } - - var bounds = this.tile.getBounds(); - var cx = bounds.x + (bounds.width / 2); - var cy = bounds.y + (bounds.height / 2); - var body = Bodies.rectangle(cx, cy, bounds.width, bounds.height, options); - - this.setBody(body, options.addToWorld); - - return this; - }, - - /** - * Sets the current body from the collision group associated with the Tile. This is typically - * set up in Tiled's collision editor. - * - * Note: Matter doesn't support all shapes from Tiled. Rectangles and polygons are directly - * supported. Ellipses are converted into circle bodies. Polylines are treated as if they are - * closed polygons. If a tile has multiple shapes, a multi-part body will be created. Concave - * shapes are supported if poly-decomp library is included. Decomposition is not guaranteed to - * work for complex shapes (e.g. holes), so it's often best to manually decompose a concave - * polygon into multiple convex polygons yourself. - * - * @method Phaser.Physics.Matter.TileBody#setFromTileCollision - * @since 3.0.0 - * - * @param {object} [options] - Options to be used when creating the Matter body. See - * Phaser.Physics.Matter.Matter.Body for a list of what Matter accepts. - * @param {boolean} [options.isStatic=true] - Whether or not the newly created body should be - * made static. This defaults to true since typically tiles should not be moved. - * @param {boolean} [options.addToWorld=true] - Whether or not to add the newly created body (or - * existing body if options.body is used) to the Matter world. - * - * @return {Phaser.Physics.Matter.TileBody} This TileBody object. - */ - setFromTileCollision: function (options) - { - if (options === undefined) { options = {}; } - if (!HasValue(options, 'isStatic')) { options.isStatic = true; } - if (!HasValue(options, 'addToWorld')) { options.addToWorld = true; } - - var sx = this.tile.tilemapLayer.scaleX; - var sy = this.tile.tilemapLayer.scaleY; - var tileX = this.tile.getLeft(); - var tileY = this.tile.getTop(); - var collisionGroup = this.tile.getCollisionGroup(); - var collisionObjects = GetFastValue(collisionGroup, 'objects', []); - - var parts = []; - - for (var i = 0; i < collisionObjects.length; i++) - { - var object = collisionObjects[i]; - var ox = tileX + (object.x * sx); - var oy = tileY + (object.y * sy); - var ow = object.width * sx; - var oh = object.height * sy; - var body = null; - - if (object.rectangle) - { - body = Bodies.rectangle(ox + ow / 2, oy + oh / 2, ow, oh, options); - } - else if (object.ellipse) - { - body = Bodies.circle(ox + ow / 2, oy + oh / 2, ow / 2, options); - } - else if (object.polygon || object.polyline) - { - // Polygons and polylines are both treated as closed polygons - var originalPoints = object.polygon ? object.polygon : object.polyline; - - var points = originalPoints.map(function (p) - { - return { x: p.x * sx, y: p.y * sy }; - }); - - var vertices = Vertices.create(points); - - // Points are relative to the object's origin (first point placed in Tiled), but - // matter expects points to be relative to the center of mass. This only applies to - // convex shapes. When a concave shape is decomposed, multiple parts are created and - // the individual parts are positioned relative to (ox, oy). - if (Vertices.isConvex(points)) - { - var center = Vertices.centre(vertices); - ox += center.x; - oy += center.y; - } - - body = Bodies.fromVertices(ox, oy, vertices, options); - } - - if (body) - { - parts.push(body); - } - } - - if (parts.length === 1) - { - this.setBody(parts[0], options.addToWorld); - } - else if (parts.length > 1) - { - options.parts = parts; - this.setBody(Body.create(options), options.addToWorld); - } - - return this; - }, - - /** - * Sets the current body to the given body. This will remove the previous body, if one already - * exists. - * - * @method Phaser.Physics.Matter.TileBody#setBody - * @since 3.0.0 - * - * @param {Phaser.Physics.Matter.Matter.Body} body - The new Matter body to use. - * @param {boolean} [addToWorld=true] - Whether or not to add the body to the Matter world. - * - * @return {Phaser.Physics.Matter.TileBody} This TileBody object. - */ - setBody: function (body, addToWorld) - { - if (addToWorld === undefined) { addToWorld = true; } - - if (this.body) - { - this.removeBody(); - } - - this.body = body; - this.body.gameObject = this; - - if (addToWorld) - { - this.world.add(this.body); - } - - return this; - }, - - /** - * Removes the current body from the MatterTileBody and from the Matter world - * - * @method Phaser.Physics.Matter.TileBody#removeBody - * @since 3.0.0 - * - * @return {Phaser.Physics.Matter.TileBody} This TileBody object. - */ - removeBody: function () - { - if (this.body) - { - this.world.remove(this.body); - this.body.gameObject = undefined; - this.body = undefined; - } - - return this; - }, - - /** - * Removes the current body from the tile and the world. - * - * @method Phaser.Physics.Matter.TileBody#removeBody - * @since 3.0.0 - * - * @return {Phaser.Physics.Matter.TileBody} This TileBody object. - */ - destroy: function () - { - this.removeBody(); - this.tile.physics.matterBody = undefined; - } - -}); - -module.exports = MatterTileBody; - - -/***/ }), -/* 862 */ -/***/ (function(module, exports, __webpack_require__) { - -/** -* The `Matter.Detector` module contains methods for detecting collisions given a set of pairs. -* -* @class Detector -*/ - -// TODO: speculative contacts - -var Detector = {}; - -module.exports = Detector; - -var SAT = __webpack_require__(863); -var Pair = __webpack_require__(375); -var Bounds = __webpack_require__(95); - -(function() { - - /** - * Finds all collisions given a list of pairs. - * @method collisions - * @param {pair[]} broadphasePairs - * @param {engine} engine - * @return {array} collisions - */ - Detector.collisions = function(broadphasePairs, engine) { - var collisions = [], - pairsTable = engine.pairs.table; - - // @if DEBUG - var metrics = engine.metrics; - // @endif - - for (var i = 0; i < broadphasePairs.length; i++) { - var bodyA = broadphasePairs[i][0], - bodyB = broadphasePairs[i][1]; - - if ((bodyA.isStatic || bodyA.isSleeping) && (bodyB.isStatic || bodyB.isSleeping)) - continue; - - if (!Detector.canCollide(bodyA.collisionFilter, bodyB.collisionFilter)) - continue; - - // @if DEBUG - metrics.midphaseTests += 1; - // @endif - - // mid phase - if (Bounds.overlaps(bodyA.bounds, bodyB.bounds)) { - for (var j = bodyA.parts.length > 1 ? 1 : 0; j < bodyA.parts.length; j++) { - var partA = bodyA.parts[j]; - - for (var k = bodyB.parts.length > 1 ? 1 : 0; k < bodyB.parts.length; k++) { - var partB = bodyB.parts[k]; - - if ((partA === bodyA && partB === bodyB) || Bounds.overlaps(partA.bounds, partB.bounds)) { - // find a previous collision we could reuse - var pairId = Pair.id(partA, partB), - pair = pairsTable[pairId], - previousCollision; - - if (pair && pair.isActive) { - previousCollision = pair.collision; - } else { - previousCollision = null; - } - - // narrow phase - var collision = SAT.collides(partA, partB, previousCollision); - - // @if DEBUG - metrics.narrowphaseTests += 1; - if (collision.reused) - metrics.narrowReuseCount += 1; - // @endif - - if (collision.collided) { - collisions.push(collision); - // @if DEBUG - metrics.narrowDetections += 1; - // @endif - } - } - } - } - } - } - - return collisions; - }; - - /** - * Returns `true` if both supplied collision filters will allow a collision to occur. - * See `body.collisionFilter` for more information. - * @method canCollide - * @param {} filterA - * @param {} filterB - * @return {bool} `true` if collision can occur - */ - Detector.canCollide = function(filterA, filterB) { - if (filterA.group === filterB.group && filterA.group !== 0) - return filterA.group > 0; - - return (filterA.mask & filterB.category) !== 0 && (filterB.mask & filterA.category) !== 0; - }; - -})(); - - -/***/ }), -/* 863 */ -/***/ (function(module, exports, __webpack_require__) { - -/** -* The `Matter.SAT` module contains methods for detecting collisions using the Separating Axis Theorem. -* -* @class SAT -*/ - -// TODO: true circles and curves - -var SAT = {}; - -module.exports = SAT; - -var Vertices = __webpack_require__(93); -var Vector = __webpack_require__(94); - -(function() { - - /** - * Detect collision between two bodies using the Separating Axis Theorem. - * @method collides - * @param {body} bodyA - * @param {body} bodyB - * @param {collision} previousCollision - * @return {collision} collision - */ - SAT.collides = function(bodyA, bodyB, previousCollision) { - var overlapAB, - overlapBA, - minOverlap, - collision, - canReusePrevCol = false; - - if (previousCollision) { - // estimate total motion - var parentA = bodyA.parent, - parentB = bodyB.parent, - motion = parentA.speed * parentA.speed + parentA.angularSpeed * parentA.angularSpeed - + parentB.speed * parentB.speed + parentB.angularSpeed * parentB.angularSpeed; - - // we may be able to (partially) reuse collision result - // but only safe if collision was resting - canReusePrevCol = previousCollision && previousCollision.collided && motion < 0.2; - - // reuse collision object - collision = previousCollision; - } else { - collision = { collided: false, bodyA: bodyA, bodyB: bodyB }; - } - - if (previousCollision && canReusePrevCol) { - // if we can reuse the collision result - // we only need to test the previously found axis - var axisBodyA = collision.axisBody, - axisBodyB = axisBodyA === bodyA ? bodyB : bodyA, - axes = [axisBodyA.axes[previousCollision.axisNumber]]; - - minOverlap = _overlapAxes(axisBodyA.vertices, axisBodyB.vertices, axes); - collision.reused = true; - - if (minOverlap.overlap <= 0) { - collision.collided = false; - return collision; - } - } else { - // if we can't reuse a result, perform a full SAT test - - overlapAB = _overlapAxes(bodyA.vertices, bodyB.vertices, bodyA.axes); - - if (overlapAB.overlap <= 0) { - collision.collided = false; - return collision; - } - - overlapBA = _overlapAxes(bodyB.vertices, bodyA.vertices, bodyB.axes); - - if (overlapBA.overlap <= 0) { - collision.collided = false; - return collision; - } - - if (overlapAB.overlap < overlapBA.overlap) { - minOverlap = overlapAB; - collision.axisBody = bodyA; - } else { - minOverlap = overlapBA; - collision.axisBody = bodyB; - } - - // important for reuse later - collision.axisNumber = minOverlap.axisNumber; - } - - collision.bodyA = bodyA.id < bodyB.id ? bodyA : bodyB; - collision.bodyB = bodyA.id < bodyB.id ? bodyB : bodyA; - collision.collided = true; - collision.depth = minOverlap.overlap; - collision.parentA = collision.bodyA.parent; - collision.parentB = collision.bodyB.parent; - - bodyA = collision.bodyA; - bodyB = collision.bodyB; - - // ensure normal is facing away from bodyA - if (Vector.dot(minOverlap.axis, Vector.sub(bodyB.position, bodyA.position)) < 0) { - collision.normal = { - x: minOverlap.axis.x, - y: minOverlap.axis.y - }; - } else { - collision.normal = { - x: -minOverlap.axis.x, - y: -minOverlap.axis.y - }; - } - - collision.tangent = Vector.perp(collision.normal); - - collision.penetration = collision.penetration || {}; - collision.penetration.x = collision.normal.x * collision.depth; - collision.penetration.y = collision.normal.y * collision.depth; - - // find support points, there is always either exactly one or two - var verticesB = _findSupports(bodyA, bodyB, collision.normal), - supports = []; - - // find the supports from bodyB that are inside bodyA - if (Vertices.contains(bodyA.vertices, verticesB[0])) - supports.push(verticesB[0]); - - if (Vertices.contains(bodyA.vertices, verticesB[1])) - supports.push(verticesB[1]); - - // find the supports from bodyA that are inside bodyB - if (supports.length < 2) { - var verticesA = _findSupports(bodyB, bodyA, Vector.neg(collision.normal)); - - if (Vertices.contains(bodyB.vertices, verticesA[0])) - supports.push(verticesA[0]); - - if (supports.length < 2 && Vertices.contains(bodyB.vertices, verticesA[1])) - supports.push(verticesA[1]); - } - - // account for the edge case of overlapping but no vertex containment - if (supports.length < 1) - supports = [verticesB[0]]; - - collision.supports = supports; - - return collision; - }; - - /** - * Find the overlap between two sets of vertices. - * @method _overlapAxes - * @private - * @param {} verticesA - * @param {} verticesB - * @param {} axes - * @return result - */ - var _overlapAxes = function(verticesA, verticesB, axes) { - var projectionA = Vector._temp[0], - projectionB = Vector._temp[1], - result = { overlap: Number.MAX_VALUE }, - overlap, - axis; - - for (var i = 0; i < axes.length; i++) { - axis = axes[i]; - - _projectToAxis(projectionA, verticesA, axis); - _projectToAxis(projectionB, verticesB, axis); - - overlap = Math.min(projectionA.max - projectionB.min, projectionB.max - projectionA.min); - - if (overlap <= 0) { - result.overlap = overlap; - return result; - } - - if (overlap < result.overlap) { - result.overlap = overlap; - result.axis = axis; - result.axisNumber = i; - } - } - - return result; - }; - - /** - * Projects vertices on an axis and returns an interval. - * @method _projectToAxis - * @private - * @param {} projection - * @param {} vertices - * @param {} axis - */ - var _projectToAxis = function(projection, vertices, axis) { - var min = Vector.dot(vertices[0], axis), - max = min; - - for (var i = 1; i < vertices.length; i += 1) { - var dot = Vector.dot(vertices[i], axis); - - if (dot > max) { - max = dot; - } else if (dot < min) { - min = dot; - } - } - - projection.min = min; - projection.max = max; - }; - - /** - * Finds supporting vertices given two bodies along a given direction using hill-climbing. - * @method _findSupports - * @private - * @param {} bodyA - * @param {} bodyB - * @param {} normal - * @return [vector] - */ - var _findSupports = function(bodyA, bodyB, normal) { - var nearestDistance = Number.MAX_VALUE, - vertexToBody = Vector._temp[0], - vertices = bodyB.vertices, - bodyAPosition = bodyA.position, - distance, - vertex, - vertexA, - vertexB; - - // find closest vertex on bodyB - for (var i = 0; i < vertices.length; i++) { - vertex = vertices[i]; - vertexToBody.x = vertex.x - bodyAPosition.x; - vertexToBody.y = vertex.y - bodyAPosition.y; - distance = -Vector.dot(normal, vertexToBody); - - if (distance < nearestDistance) { - nearestDistance = distance; - vertexA = vertex; - } - } - - // find next closest vertex using the two connected to it - var prevIndex = vertexA.index - 1 >= 0 ? vertexA.index - 1 : vertices.length - 1; - vertex = vertices[prevIndex]; - vertexToBody.x = vertex.x - bodyAPosition.x; - vertexToBody.y = vertex.y - bodyAPosition.y; - nearestDistance = -Vector.dot(normal, vertexToBody); - vertexB = vertex; - - var nextIndex = (vertexA.index + 1) % vertices.length; - vertex = vertices[nextIndex]; - vertexToBody.x = vertex.x - bodyAPosition.x; - vertexToBody.y = vertex.y - bodyAPosition.y; - distance = -Vector.dot(normal, vertexToBody); - if (distance < nearestDistance) { - vertexB = vertex; - } - - return [vertexA, vertexB]; - }; - -})(); - - -/***/ }), -/* 864 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Matter = __webpack_require__(952); - -Matter.Body = __webpack_require__(60); -Matter.Composite = __webpack_require__(152); -Matter.World = __webpack_require__(866); - -Matter.Detector = __webpack_require__(862); -Matter.Grid = __webpack_require__(953); -Matter.Pairs = __webpack_require__(954); -Matter.Pair = __webpack_require__(375); -Matter.Query = __webpack_require__(994); -Matter.Resolver = __webpack_require__(955); -Matter.SAT = __webpack_require__(863); - -Matter.Constraint = __webpack_require__(168); - -Matter.Common = __webpack_require__(38); -Matter.Engine = __webpack_require__(956); -Matter.Events = __webpack_require__(167); -Matter.Sleeping = __webpack_require__(343); -Matter.Plugin = __webpack_require__(865); - -Matter.Bodies = __webpack_require__(92); -Matter.Composites = __webpack_require__(949); - -Matter.Axes = __webpack_require__(859); -Matter.Bounds = __webpack_require__(95); -Matter.Svg = __webpack_require__(996); -Matter.Vector = __webpack_require__(94); -Matter.Vertices = __webpack_require__(93); - -// aliases - -Matter.World.add = Matter.Composite.add; -Matter.World.remove = Matter.Composite.remove; -Matter.World.addComposite = Matter.Composite.addComposite; -Matter.World.addBody = Matter.Composite.addBody; -Matter.World.addConstraint = Matter.Composite.addConstraint; -Matter.World.clear = Matter.Composite.clear; - -module.exports = Matter; - - -/***/ }), -/* 865 */ -/***/ (function(module, exports, __webpack_require__) { - -/** -* The `Matter.Plugin` module contains functions for registering and installing plugins on modules. -* -* @class Plugin -*/ - -var Plugin = {}; - -module.exports = Plugin; - -var Common = __webpack_require__(38); - -(function() { - - Plugin._registry = {}; - - /** - * Registers a plugin object so it can be resolved later by name. - * @method register - * @param plugin {} The plugin to register. - * @return {object} The plugin. - */ - Plugin.register = function(plugin) { - if (!Plugin.isPlugin(plugin)) { - Common.warn('Plugin.register:', Plugin.toString(plugin), 'does not implement all required fields.'); - } - - if (plugin.name in Plugin._registry) { - var registered = Plugin._registry[plugin.name], - pluginVersion = Plugin.versionParse(plugin.version).number, - registeredVersion = Plugin.versionParse(registered.version).number; - - if (pluginVersion > registeredVersion) { - Common.warn('Plugin.register:', Plugin.toString(registered), 'was upgraded to', Plugin.toString(plugin)); - Plugin._registry[plugin.name] = plugin; - } else if (pluginVersion < registeredVersion) { - Common.warn('Plugin.register:', Plugin.toString(registered), 'can not be downgraded to', Plugin.toString(plugin)); - } else if (plugin !== registered) { - Common.warn('Plugin.register:', Plugin.toString(plugin), 'is already registered to different plugin object'); - } - } else { - Plugin._registry[plugin.name] = plugin; - } - - return plugin; - }; - - /** - * Resolves a dependency to a plugin object from the registry if it exists. - * The `dependency` may contain a version, but only the name matters when resolving. - * @method resolve - * @param dependency {string} The dependency. - * @return {object} The plugin if resolved, otherwise `undefined`. - */ - Plugin.resolve = function(dependency) { - return Plugin._registry[Plugin.dependencyParse(dependency).name]; - }; - - /** - * Returns a pretty printed plugin name and version. - * @method toString - * @param plugin {} The plugin. - * @return {string} Pretty printed plugin name and version. - */ - Plugin.toString = function(plugin) { - return typeof plugin === 'string' ? plugin : (plugin.name || 'anonymous') + '@' + (plugin.version || plugin.range || '0.0.0'); - }; - - /** - * Returns `true` if the object meets the minimum standard to be considered a plugin. - * This means it must define the following properties: - * - `name` - * - `version` - * - `install` - * @method isPlugin - * @param obj {} The obj to test. - * @return {boolean} `true` if the object can be considered a plugin otherwise `false`. - */ - Plugin.isPlugin = function(obj) { - return obj && obj.name && obj.version && obj.install; - }; - - /** - * Returns `true` if a plugin with the given `name` been installed on `module`. - * @method isUsed - * @param module {} The module. - * @param name {string} The plugin name. - * @return {boolean} `true` if a plugin with the given `name` been installed on `module`, otherwise `false`. - */ - Plugin.isUsed = function(module, name) { - return module.used.indexOf(name) > -1; - }; - - /** - * Returns `true` if `plugin.for` is applicable to `module` by comparing against `module.name` and `module.version`. - * If `plugin.for` is not specified then it is assumed to be applicable. - * The value of `plugin.for` is a string of the format `'module-name'` or `'module-name@version'`. - * @method isFor - * @param plugin {} The plugin. - * @param module {} The module. - * @return {boolean} `true` if `plugin.for` is applicable to `module`, otherwise `false`. - */ - Plugin.isFor = function(plugin, module) { - var parsed = plugin.for && Plugin.dependencyParse(plugin.for); - return !plugin.for || (module.name === parsed.name && Plugin.versionSatisfies(module.version, parsed.range)); - }; - - /** - * Installs the plugins by calling `plugin.install` on each plugin specified in `plugins` if passed, otherwise `module.uses`. - * For installing plugins on `Matter` see the convenience function `Matter.use`. - * Plugins may be specified either by their name or a reference to the plugin object. - * Plugins themselves may specify further dependencies, but each plugin is installed only once. - * Order is important, a topological sort is performed to find the best resulting order of installation. - * This sorting attempts to satisfy every dependency's requested ordering, but may not be exact in all cases. - * This function logs the resulting status of each dependency in the console, along with any warnings. - * - A green tick ✅ indicates a dependency was resolved and installed. - * - An orange diamond 🔶 indicates a dependency was resolved but a warning was thrown for it or one if its dependencies. - * - A red cross ❌ indicates a dependency could not be resolved. - * Avoid calling this function multiple times on the same module unless you intend to manually control installation order. - * @method use - * @param module {} The module install plugins on. - * @param [plugins=module.uses] {} The plugins to install on module (optional, defaults to `module.uses`). - */ - Plugin.use = function(module, plugins) { - module.uses = (module.uses || []).concat(plugins || []); - - if (module.uses.length === 0) { - Common.warn('Plugin.use:', Plugin.toString(module), 'does not specify any dependencies to install.'); - return; - } - - var dependencies = Plugin.dependencies(module), - sortedDependencies = Common.topologicalSort(dependencies), - status = []; - - for (var i = 0; i < sortedDependencies.length; i += 1) { - if (sortedDependencies[i] === module.name) { - continue; - } - - var plugin = Plugin.resolve(sortedDependencies[i]); - - if (!plugin) { - status.push('❌ ' + sortedDependencies[i]); - continue; - } - - if (Plugin.isUsed(module, plugin.name)) { - continue; - } - - if (!Plugin.isFor(plugin, module)) { - Common.warn('Plugin.use:', Plugin.toString(plugin), 'is for', plugin.for, 'but installed on', Plugin.toString(module) + '.'); - plugin._warned = true; - } - - if (plugin.install) { - plugin.install(module); - } else { - Common.warn('Plugin.use:', Plugin.toString(plugin), 'does not specify an install function.'); - plugin._warned = true; - } - - if (plugin._warned) { - status.push('🔶 ' + Plugin.toString(plugin)); - delete plugin._warned; - } else { - status.push('✅ ' + Plugin.toString(plugin)); - } - - module.used.push(plugin.name); - } - - if (status.length > 0 && !plugin.silent) { - Common.info(status.join(' ')); - } - }; - - /** - * Recursively finds all of a module's dependencies and returns a flat dependency graph. - * @method dependencies - * @param module {} The module. - * @return {object} A dependency graph. - */ - Plugin.dependencies = function(module, tracked) { - var parsedBase = Plugin.dependencyParse(module), - name = parsedBase.name; - - tracked = tracked || {}; - - if (name in tracked) { - return; - } - - module = Plugin.resolve(module) || module; - - tracked[name] = Common.map(module.uses || [], function(dependency) { - if (Plugin.isPlugin(dependency)) { - Plugin.register(dependency); - } - - var parsed = Plugin.dependencyParse(dependency), - resolved = Plugin.resolve(dependency); - - if (resolved && !Plugin.versionSatisfies(resolved.version, parsed.range)) { - Common.warn( - 'Plugin.dependencies:', Plugin.toString(resolved), 'does not satisfy', - Plugin.toString(parsed), 'used by', Plugin.toString(parsedBase) + '.' - ); - - resolved._warned = true; - module._warned = true; - } else if (!resolved) { - Common.warn( - 'Plugin.dependencies:', Plugin.toString(dependency), 'used by', - Plugin.toString(parsedBase), 'could not be resolved.' - ); - - module._warned = true; - } - - return parsed.name; - }); - - for (var i = 0; i < tracked[name].length; i += 1) { - Plugin.dependencies(tracked[name][i], tracked); - } - - return tracked; - }; - - /** - * Parses a dependency string into its components. - * The `dependency` is a string of the format `'module-name'` or `'module-name@version'`. - * See documentation for `Plugin.versionParse` for a description of the format. - * This function can also handle dependencies that are already resolved (e.g. a module object). - * @method dependencyParse - * @param dependency {string} The dependency of the format `'module-name'` or `'module-name@version'`. - * @return {object} The dependency parsed into its components. - */ - Plugin.dependencyParse = function(dependency) { - if (Common.isString(dependency)) { - var pattern = /^[\w-]+(@(\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-]+)?))?$/; - - if (!pattern.test(dependency)) { - Common.warn('Plugin.dependencyParse:', dependency, 'is not a valid dependency string.'); - } - - return { - name: dependency.split('@')[0], - range: dependency.split('@')[1] || '*' - }; - } - - return { - name: dependency.name, - range: dependency.range || dependency.version - }; - }; - - /** - * Parses a version string into its components. - * Versions are strictly of the format `x.y.z` (as in [semver](http://semver.org/)). - * Versions may optionally have a prerelease tag in the format `x.y.z-alpha`. - * Ranges are a strict subset of [npm ranges](https://docs.npmjs.com/misc/semver#advanced-range-syntax). - * Only the following range types are supported: - * - Tilde ranges e.g. `~1.2.3` - * - Caret ranges e.g. `^1.2.3` - * - Exact version e.g. `1.2.3` - * - Any version `*` - * @method versionParse - * @param range {string} The version string. - * @return {object} The version range parsed into its components. - */ - Plugin.versionParse = function(range) { - var pattern = /^\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-]+)?$/; - - if (!pattern.test(range)) { - Common.warn('Plugin.versionParse:', range, 'is not a valid version or range.'); - } - - var identifiers = range.split('-'); - range = identifiers[0]; - - var isRange = isNaN(Number(range[0])), - version = isRange ? range.substr(1) : range, - parts = Common.map(version.split('.'), function(part) { - return Number(part); - }); - - return { - isRange: isRange, - version: version, - range: range, - operator: isRange ? range[0] : '', - parts: parts, - prerelease: identifiers[1], - number: parts[0] * 1e8 + parts[1] * 1e4 + parts[2] - }; - }; - - /** - * Returns `true` if `version` satisfies the given `range`. - * See documentation for `Plugin.versionParse` for a description of the format. - * If a version or range is not specified, then any version (`*`) is assumed to satisfy. - * @method versionSatisfies - * @param version {string} The version string. - * @param range {string} The range string. - * @return {boolean} `true` if `version` satisfies `range`, otherwise `false`. - */ - Plugin.versionSatisfies = function(version, range) { - range = range || '*'; - - var rangeParsed = Plugin.versionParse(range), - rangeParts = rangeParsed.parts, - versionParsed = Plugin.versionParse(version), - versionParts = versionParsed.parts; - - if (rangeParsed.isRange) { - if (rangeParsed.operator === '*' || version === '*') { - return true; - } - - if (rangeParsed.operator === '~') { - return versionParts[0] === rangeParts[0] && versionParts[1] === rangeParts[1] && versionParts[2] >= rangeParts[2]; - } - - if (rangeParsed.operator === '^') { - if (rangeParts[0] > 0) { - return versionParts[0] === rangeParts[0] && versionParsed.number >= rangeParsed.number; - } - - if (rangeParts[1] > 0) { - return versionParts[1] === rangeParts[1] && versionParts[2] >= rangeParts[2]; - } - - return versionParts[2] === rangeParts[2]; - } - } - - return version === range || version === '*'; - }; - -})(); - - -/***/ }), -/* 866 */ -/***/ (function(module, exports, __webpack_require__) { - -/** -* The `Matter.World` module contains methods for creating and manipulating the world composite. -* A `Matter.World` is a `Matter.Composite` body, which is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`. -* A `Matter.World` has a few additional properties including `gravity` and `bounds`. -* It is important to use the functions in the `Matter.Composite` module to modify the world composite, rather than directly modifying its properties. -* There are also a few methods here that alias those in `Matter.Composite` for easier readability. -* -* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). -* -* @class World -* @extends Composite -*/ - -var World = {}; - -module.exports = World; - -var Composite = __webpack_require__(152); -var Constraint = __webpack_require__(168); -var Common = __webpack_require__(38); - -(function() { - - /** - * Creates a new world composite. The options parameter is an object that specifies any properties you wish to override the defaults. - * See the properties section below for detailed information on what you can pass via the `options` object. - * @method create - * @constructor - * @param {} options - * @return {world} A new world - */ - World.create = function(options) { - var composite = Composite.create(); - - var defaults = { - label: 'World', - gravity: { - x: 0, - y: 1, - scale: 0.001 - }, - bounds: { - min: { x: -Infinity, y: -Infinity }, - max: { x: Infinity, y: Infinity } - } - }; - - return Common.extend(composite, defaults, options); - }; - - /* - * - * Properties Documentation - * - */ - - /** - * The gravity to apply on the world. - * - * @property gravity - * @type object - */ - - /** - * The gravity x component. - * - * @property gravity.x - * @type object - * @default 0 - */ - - /** - * The gravity y component. - * - * @property gravity.y - * @type object - * @default 1 - */ - - /** - * The gravity scale factor. - * - * @property gravity.scale - * @type object - * @default 0.001 - */ - - /** - * A `Bounds` object that defines the world bounds for collision detection. - * - * @property bounds - * @type bounds - * @default { min: { x: -Infinity, y: -Infinity }, max: { x: Infinity, y: Infinity } } - */ - - // World is a Composite body - // see src/module/Outro.js for these aliases: - - /** - * An alias for Composite.clear - * @method clear - * @param {world} world - * @param {boolean} keepStatic - */ - - /** - * An alias for Composite.add - * @method addComposite - * @param {world} world - * @param {composite} composite - * @return {world} The original world with the objects from composite added - */ - - /** - * An alias for Composite.addBody - * @method addBody - * @param {world} world - * @param {body} body - * @return {world} The original world with the body added - */ - - /** - * An alias for Composite.addConstraint - * @method addConstraint - * @param {world} world - * @param {constraint} constraint - * @return {world} The original world with the constraint added - */ - -})(); - - -/***/ }), -/* 867 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Scenes - */ - -module.exports = { - - SceneManager: __webpack_require__(252), - ScenePlugin: __webpack_require__(868), - Settings: __webpack_require__(255), - Systems: __webpack_require__(130) - -}; - - -/***/ }), -/* 868 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(83); -var PluginManager = __webpack_require__(12); - -/** - * @classdesc - * A proxy class to the Global Scene Manager. - * - * @class ScenePlugin - * @memberOf Phaser.Scenes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var ScenePlugin = new Class({ - - initialize: - - function ScenePlugin (scene) - { - /** - * [description] - * - * @name Phaser.Scenes.ScenePlugin#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.Scenes.ScenePlugin#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - if (!scene.sys.settings.isBooted) - { - scene.sys.events.once('boot', this.boot, this); - } - - /** - * [description] - * - * @name Phaser.Scenes.ScenePlugin#settings - * @type {object} - * @since 3.0.0 - */ - this.settings = scene.sys.settings; - - /** - * [description] - * - * @name Phaser.Scenes.ScenePlugin#key - * @type {string} - * @since 3.0.0 - */ - this.key = scene.sys.settings.key; - - /** - * [description] - * - * @name Phaser.Scenes.ScenePlugin#manager - * @type {Phaser.Scenes.SceneManager} - * @since 3.0.0 - */ - this.manager = scene.sys.game.scene; - }, - - /** - * [description] - * - * @method Phaser.Scenes.ScenePlugin#boot - * @since 3.0.0 - */ - boot: function () - { - var eventEmitter = this.systems.events; - - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); - }, - - /** - * Shutdown this Scene and run the given one. - * - * @method Phaser.Scenes.ScenePlugin#start - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {object} [data] - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - start: function (key, data) - { - if (key === undefined) { key = this.key; } - - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('stop', this.key); - this.manager.queueOp('start', key); - } - else - { - this.manager.stop(this.key); - this.manager.start(key, data); - } - - return this; - }, - - /** - * Add the Scene into the Scene Manager and start it if 'autoStart' is true or the Scene config 'active' property is set. - * - * @method Phaser.Scenes.ScenePlugin#add - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {object} sceneConfig - [description] - * @param {boolean} autoStart - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - add: function (key, sceneConfig, autoStart) - { - this.manager.add(key, sceneConfig, autoStart); - - return this; - }, - - /** - * Launch the given Scene and run it in parallel with this one. - * - * @method Phaser.Scenes.ScenePlugin#launch - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {object} [data] - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - launch: function (key, data) - { - if (key && key !== this.key) - { - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('start', key, data); - } - else - { - this.manager.start(key, data); - } - } - - return this; - }, - - /** - * Pause the Scene - this stops the update step from happening but it still renders. - * - * @method Phaser.Scenes.ScenePlugin#pause - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - pause: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.pause(key); - - return this; - }, - - /** - * Resume the Scene - starts the update loop again. - * - * @method Phaser.Scenes.ScenePlugin#resume - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - resume: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.resume(key); - - return this; - }, - - /** - * Makes the Scene sleep (no update, no render) but doesn't shutdown. - * - * @method Phaser.Scenes.ScenePlugin#sleep - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - sleep: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.sleep(key); - - return this; - }, - - /** - * Makes the Scene wake-up (starts update and render) - * - * @method Phaser.Scenes.ScenePlugin#wake - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - wake: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.wake(key); - - return this; - }, - - /** - * Makes this Scene sleep then starts the Scene given. - * - * @method Phaser.Scenes.ScenePlugin#switch - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - switch: function (key) - { - if (key !== this.key) - { - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('switch', this.key, key); - } - else - { - this.manager.switch(this.key, key); - } - } - - return this; - }, - - /** - * Shutdown the Scene, clearing display list, timers, etc. - * - * @method Phaser.Scenes.ScenePlugin#stop - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - stop: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.stop(key); - - return this; - }, - - /** - * Sets the active state of the given Scene. - * - * @method Phaser.Scenes.ScenePlugin#setActive - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - setActive: function (value) - { - this.settings.active = value; - - return this; - }, - - /** - * Sets the visible state of the given Scene. - * - * @method Phaser.Scenes.ScenePlugin#setVisible - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - setVisible: function (value) - { - this.settings.visible = value; - - return this; - }, - - /** - * Checks if the given Scene is sleeping or not? - * - * @method Phaser.Scenes.ScenePlugin#isSleeping - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {boolean} [description] - */ - isSleeping: function (key) - { - if (key === undefined) { key = this.key; } - - return this.manager.isSleeping(key); - }, - - /** - * Checks if the given Scene is active or not? - * - * @method Phaser.Scenes.ScenePlugin#isActive - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {boolean} [description] - */ - isActive: function (key) - { - if (key === undefined) { key = this.key; } - - return this.manager.isActive(key); - }, - - /** - * Checks if the given Scene is visible or not? - * - * @method Phaser.Scenes.ScenePlugin#isVisible - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {boolean} [description] - */ - isVisible: function (key) - { - if (key === undefined) { key = this.key; } - - return this.manager.isVisible(key); - }, - - /** - * Swaps the position of two scenes in the Scenes list. - * This controls the order in which they are rendered and updated. - * - * @method Phaser.Scenes.ScenePlugin#swapPosition - * @since 3.2.0 - * - * @param {string} keyA - The first Scene to swap. - * @param {string} [keyB] - The second Scene to swap. If none is given it defaults to this Scene. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - swapPosition: function (keyA, keyB) - { - if (keyB === undefined) { keyB = this.key; } - - if (keyA !== keyB) - { - this.manager.swapPosition(keyA, keyB); - } - - return this; - }, - - /** - * Swaps the position of two scenes in the Scenes list, so that Scene B is directly above Scene A. - * This controls the order in which they are rendered and updated. - * - * @method Phaser.Scenes.ScenePlugin#moveAbove - * @since 3.2.0 - * - * @param {string} keyA - The Scene that Scene B will be moved to be above. - * @param {string} [keyB] - The Scene to be moved. If none is given it defaults to this Scene. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - moveAbove: function (keyA, keyB) - { - if (keyB === undefined) { keyB = this.key; } - - if (keyA !== keyB) - { - this.manager.moveAbove(keyA, keyB); - } - - return this; - }, - - /** - * Swaps the position of two scenes in the Scenes list, so that Scene B is directly below Scene A. - * This controls the order in which they are rendered and updated. - * - * @method Phaser.Scenes.ScenePlugin#moveBelow - * @since 3.2.0 - * - * @param {string} keyA - The Scene that Scene B will be moved to be below. - * @param {string} [keyB] - The Scene to be moved. If none is given it defaults to this Scene. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - moveBelow: function (keyA, keyB) - { - if (keyB === undefined) { keyB = this.key; } - - if (keyA !== keyB) - { - this.manager.moveBelow(keyA, keyB); - } - - return this; - }, - - /** - * Removes a Scene from the SceneManager. - * - * The Scene is removed from the local scenes array, it's key is cleared from the keys - * cache and Scene.Systems.destroy is then called on it. - * - * If the SceneManager is processing the Scenes when this method is called it wil - * queue the operation for the next update sequence. - * - * @method Phaser.Scenes.ScenePlugin#remove - * @since 3.2.0 - * - * @param {string|Phaser.Scene} scene - The Scene to be removed. - * - * @return {Phaser.Scenes.SceneManager} This SceneManager. - */ - remove: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.remove(key); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.ScenePlugin#moveUp - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - moveUp: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.moveUp(key); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.ScenePlugin#moveDown - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - moveDown: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.moveDown(key); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.ScenePlugin#bringToTop - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - bringToTop: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.bringToTop(key); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.ScenePlugin#sendToBack - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - sendToBack: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.sendToBack(key); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Scenes.ScenePlugin#get - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Scene} [description] - */ - get: function (key) - { - return this.manager.getScene(key); - }, - - /** - * [description] - * - * @method Phaser.Scenes.ScenePlugin#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - // TODO - }, - - /** - * [description] - * - * @method Phaser.Scenes.ScenePlugin#destroy - * @since 3.0.0 - */ - destroy: function () - { - // TODO - } - -}); - -PluginManager.register('ScenePlugin', ScenePlugin, 'scenePlugin'); - -module.exports = ScenePlugin; - - -/***/ }), -/* 869 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Sound - * - * @author Pavle Goloskokovic (http://prunegames.com) - */ - -/** - * Config object containing various sound settings. - * - * @typedef {object} SoundConfig - * - * @property {boolean} [mute=false] - Boolean indicating whether the sound should be muted or not. - * @property {number} [volume=1] - A value between 0 (silence) and 1 (full volume). - * @property {number} [rate=1] - Defines the speed at which the sound should be played. - * @property {number} [detune=0] - Represents detuning of sound in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * @property {number} [seek=0] - Position of playback for this sound, in seconds. - * @property {boolean} [loop=false] - Whether or not the sound or current sound marker should loop. - * @property {number} [delay=0] - Time, in seconds, that should elapse before the sound actually starts its playback. - */ - -/** - * Marked section of a sound represented by name, and optionally start time, duration, and config object. - * - * @typedef {object} SoundMarker - * - * @property {string} name - Unique identifier of a sound marker. - * @property {number} [start=0] - Sound position offset at witch playback should start. - * @property {number} [duration] - Playback duration of this marker. - * @property {SoundConfig} [config] - An optional config object containing default marker settings. - */ - -module.exports = { - - SoundManagerCreator: __webpack_require__(256), - - BaseSound: __webpack_require__(85), - BaseSoundManager: __webpack_require__(84), - - WebAudioSound: __webpack_require__(262), - WebAudioSoundManager: __webpack_require__(261), - - HTML5AudioSound: __webpack_require__(258), - HTML5AudioSoundManager: __webpack_require__(257), - - NoAudioSound: __webpack_require__(260), - NoAudioSoundManager: __webpack_require__(259) - -}; - - -/***/ }), -/* 870 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Structs - */ - -module.exports = { - - List: __webpack_require__(86), - Map: __webpack_require__(114), - ProcessQueue: __webpack_require__(336), - RTree: __webpack_require__(337), - Set: __webpack_require__(62) - -}; - - -/***/ }), -/* 871 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Textures - */ - -module.exports = { - - Parsers: __webpack_require__(264), - - FilterMode: __webpack_require__(872), - Frame: __webpack_require__(131), - Texture: __webpack_require__(265), - TextureManager: __webpack_require__(263), - TextureSource: __webpack_require__(266) - -}; - - -/***/ }), -/* 872 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Textures.FilterMode - */ - -var CONST = { - - /** - * CSV Map Type - * - * @name Phaser.Textures.FilterMode.LINEAR - * @type {number} - * @since 3.0.0 - */ - LINEAR: 0, - - /** - * CSV Map Type - * - * @name Phaser.Textures.FilterMode.NEAREST - * @type {number} - * @since 3.0.0 - */ - NEAREST: 1 - -}; - -module.exports = CONST; - - -/***/ }), -/* 873 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Tilemaps - */ - -module.exports = { - - Components: __webpack_require__(96), - Parsers: __webpack_require__(903), - - Formats: __webpack_require__(22), - ImageCollection: __webpack_require__(351), - ParseToTilemap: __webpack_require__(157), - Tile: __webpack_require__(44), - Tilemap: __webpack_require__(355), - TilemapCreator: __webpack_require__(920), - TilemapFactory: __webpack_require__(921), - Tileset: __webpack_require__(100), - - LayerData: __webpack_require__(75), - MapData: __webpack_require__(76), - ObjectLayer: __webpack_require__(353), - - DynamicTilemapLayer: __webpack_require__(356), - StaticTilemapLayer: __webpack_require__(357) - -}; - - -/***/ }), -/* 874 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); -var CalculateFacesWithin = __webpack_require__(34); - -/** - * Copies the tiles in the source rectangular area to a new destination (all specified in tile - * coordinates) within the layer. This copies all tile properties & recalculates collision - * information in the destination region. - * - * @function Phaser.Tilemaps.Components.Copy - * @since 3.0.0 - * - * @param {integer} srcTileX - [description] - * @param {integer} srcTileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {integer} destTileX - [description] - * @param {integer} destTileY - [description] - * @param {integer} destTileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var Copy = function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer) -{ - if (srcTileX < 0) { srcTileX = 0; } - if (srcTileY < 0) { srcTileY = 0; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - - var srcTiles = GetTilesWithin(srcTileX, srcTileY, width, height, null, layer); - - var offsetX = destTileX - srcTileX; - var offsetY = destTileY - srcTileY; - - for (var i = 0; i < srcTiles.length; i++) - { - var tileX = srcTiles[i].x + offsetX; - var tileY = srcTiles[i].y + offsetY; - if (tileX >= 0 && tileX < layer.width && tileY >= 0 && tileY < layer.height) - { - if (layer.data[tileY][tileX]) - { - layer.data[tileY][tileX].copy(srcTiles[i]); - } - } - } - - if (recalculateFaces) - { - // Recalculate the faces within the destination area and neighboring tiles - CalculateFacesWithin(destTileX - 1, destTileY - 1, width + 2, height + 2, layer); - } -}; - -module.exports = Copy; - - -/***/ }), -/* 875 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var TileToWorldX = __webpack_require__(98); -var TileToWorldY = __webpack_require__(99); -var GetTilesWithin = __webpack_require__(15); -var ReplaceByIndex = __webpack_require__(344); - -/** - * Creates a Sprite for every object matching the given tile indexes in the layer. You can - * optionally specify if each tile will be replaced with a new tile after the Sprite has been - * created. This is useful if you want to lay down special tiles in a level that are converted to - * Sprites, but want to replace the tile itself with a floor tile or similar once converted. - * - * @function Phaser.Tilemaps.Components.CreateFromTiles - * @since 3.0.0 - * - * @param {integer|array} indexes - The tile index, or array of indexes, to create Sprites from. - * @param {integer|array} replacements - The tile index, or array of indexes, to change a converted - * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a - * one-to-one mapping with the indexes array. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). - * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. - */ -var CreateFromTiles = function (indexes, replacements, spriteConfig, scene, camera, layer) -{ - if (spriteConfig === undefined) { spriteConfig = {}; } - - if (!Array.isArray(indexes)) { indexes = [ indexes ]; } - - var tilemapLayer = layer.tilemapLayer; - if (scene === undefined) { scene = tilemapLayer.scene; } - if (camera === undefined) { camera = scene.cameras.main; } - - var tiles = GetTilesWithin(0, 0, layer.width, layer.height, null, layer); - var sprites = []; - var i; - - for (i = 0; i < tiles.length; i++) - { - var tile = tiles[i]; - - if (indexes.indexOf(tile.index) !== -1) - { - spriteConfig.x = TileToWorldX(tile.x, camera, layer); - spriteConfig.y = TileToWorldY(tile.y, camera, layer); - - var sprite = scene.make.sprite(spriteConfig); - sprites.push(sprite); - } - } - - if (typeof replacements === 'number') - { - // Assume 1 replacement for all types of tile given - for (i = 0; i < indexes.length; i++) - { - ReplaceByIndex(indexes[i], replacements, 0, 0, layer.width, layer.height, layer); - } - } - else if (Array.isArray(replacements)) - { - // Assume 1 to 1 mapping with indexes array - for (i = 0; i < indexes.length; i++) - { - ReplaceByIndex(indexes[i], replacements[i], 0, 0, layer.width, layer.height, layer); - } - } - - return sprites; -}; - -module.exports = CreateFromTiles; - - -/***/ }), -/* 876 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the tiles in the given layer that are within the camera's viewport. This is used - * internally. - * - * @function Phaser.Tilemaps.Components.CullTiles - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. - * @param {array} [outputArray] - [description] - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ -var CullTiles = function (layer, camera, outputArray) -{ - if (outputArray === undefined) { outputArray = []; } - - outputArray.length = 0; - - var tilemapLayer = layer.tilemapLayer; - var mapData = layer.data; - var mapWidth = layer.width; - var mapHeight = layer.height; - var left = (camera.scrollX * tilemapLayer.scrollFactorX) - tilemapLayer.x; - var top = (camera.scrollY * tilemapLayer.scrollFactorY) - tilemapLayer.y; - var sx = tilemapLayer.scaleX; - var sy = tilemapLayer.scaleY; - var tileWidth = layer.tileWidth * sx; - var tileHeight = layer.tileHeight * sy; - - for (var row = 0; row < mapHeight; ++row) - { - for (var col = 0; col < mapWidth; ++col) - { - var tile = mapData[row][col]; - - if (tile === null || tile.index === -1) { continue; } - - var tileX = tile.pixelX * sx - left; - var tileY = tile.pixelY * sy - top; - var cullW = camera.width + tileWidth; - var cullH = camera.height + tileHeight; - - if (tile.visible && - tileX > -tileWidth && tileY > -tileHeight && - tileX < cullW && tileY < cullH) - { - outputArray.push(tile); - } - } - } - - return outputArray; -}; - -module.exports = CullTiles; - - -/***/ }), -/* 877 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); -var CalculateFacesWithin = __webpack_require__(34); -var SetTileCollision = __webpack_require__(43); - -/** - * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the - * specified index. Tiles will be set to collide if the given index is a colliding index. - * Collision information in the region will be recalculated. - * - * @function Phaser.Tilemaps.Components.Fill - * @since 3.0.0 - * - * @param {integer} index - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var Fill = function (index, tileX, tileY, width, height, recalculateFaces, layer) -{ - if (recalculateFaces === undefined) { recalculateFaces = true; } - - var doesIndexCollide = (layer.collideIndexes.indexOf(index) !== -1); - - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - for (var i = 0; i < tiles.length; i++) - { - tiles[i].index = index; - - SetTileCollision(tiles[i], doesIndexCollide); - } - - if (recalculateFaces) - { - // Recalculate the faces within the area and neighboring tiles - CalculateFacesWithin(tileX - 1, tileY - 1, width + 2, height + 2, layer); - } -}; - -module.exports = Fill; - - -/***/ }), -/* 878 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); - -/** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns - * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. - * - * @function Phaser.Tilemaps.Components.FilterTiles - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. The callback should return true for tiles that pass the - * filter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile[]} The filtered array of Tiles. - */ -var FilterTiles = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); - return tiles.filter(callback, context); -}; - -module.exports = FilterTiles; - - - -/***/ }), -/* 879 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Searches the entire map layer for the first tile matching the given index, then returns that Tile - * object. If no match is found, it returns null. The search starts from the top-left tile and - * continues horizontally until it hits the end of the row, then it drops down to the next column. - * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to - * the top-left. - * - * @function Phaser.Tilemaps.Components.FindByIndex - * @since 3.0.0 - * - * @param {integer} index - The tile index value to search for. - * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. - * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the - * bottom-right. Otherwise it scans from the top-left. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile|null} The first (or n skipped) tile with the matching index. - */ -var FindByIndex = function (findIndex, skip, reverse, layer) -{ - if (skip === undefined) { skip = 0; } - if (reverse === undefined) { reverse = false; } - - var count = 0; - var tx; - var ty; - var tile; - - if (reverse) - { - for (ty = layer.height - 1; ty >= 0; ty--) - { - for (tx = layer.width - 1; tx >= 0; tx--) - { - tile = layer.data[ty][tx]; - if (tile && tile.index === findIndex) - { - if (count === skip) - { - return tile; - } - else - { - count += 1; - } - } - } - } - } - else - { - for (ty = 0; ty < layer.height; ty++) - { - for (tx = 0; tx < layer.width; tx++) - { - tile = layer.data[ty][tx]; - if (tile && tile.index === findIndex) - { - if (count === skip) - { - return tile; - } - else - { - count += 1; - } - } - } - } - } - - return null; -}; - -module.exports = FindByIndex; - - -/***/ }), -/* 880 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); - -/** - * Find the first tile in the given rectangular area (in tile coordinates) of the layer that - * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns - * true. Similar to Array.prototype.find in vanilla JS. - * - * @function Phaser.Tilemaps.Components.FindTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile|null} A Tile that matches the search, or null if no Tile found - */ -var FindTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); - return tiles.find(callback, context) || null; -}; - -module.exports = FindTile; - - -/***/ }), -/* 881 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); - -/** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * callback. Similar to Array.prototype.forEach in vanilla JS. - * - * @function Phaser.Tilemaps.Components.ForEachTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var ForEachTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); - tiles.forEach(callback, context); -}; - -module.exports = ForEachTile; - - -/***/ }), -/* 882 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTileAt = __webpack_require__(97); -var WorldToTileX = __webpack_require__(39); -var WorldToTileY = __webpack_require__(40); - -/** - * Gets a tile at the given world coordinates from the given layer. - * - * @function Phaser.Tilemaps.Components.GetTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - X position to get the tile from (given in pixels) - * @param {number} worldY - Y position to get the tile from (given in pixels) - * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates - * were invalid. - */ -var GetTileAtWorldXY = function (worldX, worldY, nonNull, camera, layer) -{ - var tileX = WorldToTileX(worldX, true, camera, layer); - var tileY = WorldToTileY(worldY, true, camera, layer); - - return GetTileAt(tileX, tileY, nonNull, layer); -}; - -module.exports = GetTileAtWorldXY; - - -/***/ }), -/* 883 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Geom = __webpack_require__(294); -var GetTilesWithin = __webpack_require__(15); -var Intersects = __webpack_require__(295); -var NOOP = __webpack_require__(3); -var TileToWorldX = __webpack_require__(98); -var TileToWorldY = __webpack_require__(99); -var WorldToTileX = __webpack_require__(39); -var WorldToTileY = __webpack_require__(40); - -var TriangleToRectangle = function (triangle, rect) -{ - return Intersects.RectangleToTriangle(rect, triangle); -}; - -// Note: Could possibly be optimized by copying the shape and shifting it into tilemapLayer -// coordinates instead of shifting the tiles. - -/** - * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, - * Line, Rectangle or Triangle. The shape should be in world coordinates. - * - * @function Phaser.Tilemaps.Components.GetTilesWithinShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle} shape - A shape in world (pixel) coordinates - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. - */ -var GetTilesWithinShape = function (shape, filteringOptions, camera, layer) -{ - if (shape === undefined) { return []; } - - // intersectTest is a function with parameters: shape, rect - var intersectTest = NOOP; - if (shape instanceof Geom.Circle) { intersectTest = Intersects.CircleToRectangle; } - else if (shape instanceof Geom.Rectangle) { intersectTest = Intersects.RectangleToRectangle; } - else if (shape instanceof Geom.Triangle) { intersectTest = TriangleToRectangle; } - else if (shape instanceof Geom.Line) { intersectTest = Intersects.LineToRectangle; } - - // Top left corner of the shapes's bounding box, rounded down to include partial tiles - var xStart = WorldToTileX(shape.left, true, camera, layer); - var yStart = WorldToTileY(shape.top, true, camera, layer); - - // Bottom right corner of the shapes's bounding box, rounded up to include partial tiles - var xEnd = Math.ceil(WorldToTileX(shape.right, false, camera, layer)); - var yEnd = Math.ceil(WorldToTileY(shape.bottom, false, camera, layer)); - - // Tiles within bounding rectangle of shape. Bounds are forced to be at least 1 x 1 tile in size - // to grab tiles for shapes that don't have a height or width (e.g. a horizontal line). - var width = Math.max(xEnd - xStart, 1); - var height = Math.max(yEnd - yStart, 1); - var tiles = GetTilesWithin(xStart, yStart, width, height, filteringOptions, layer); - - var tileWidth = layer.tileWidth; - var tileHeight = layer.tileHeight; - if (layer.tilemapLayer) - { - tileWidth *= layer.tilemapLayer.scaleX; - tileHeight *= layer.tilemapLayer.scaleY; - } - - var results = []; - var tileRect = new Geom.Rectangle(0, 0, tileWidth, tileHeight); - for (var i = 0; i < tiles.length; i++) - { - var tile = tiles[i]; - tileRect.x = TileToWorldX(tile.x, camera, layer); - tileRect.y = TileToWorldY(tile.y, camera, layer); - if (intersectTest(shape, tileRect)) - { - results.push(tile); - } - } - - return results; -}; - -module.exports = GetTilesWithinShape; - - -/***/ }), -/* 884 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); -var WorldToTileX = __webpack_require__(39); -var WorldToTileY = __webpack_require__(40); - -/** - * Gets the tiles in the given rectangular area (in world coordinates) of the layer. - * - * @function Phaser.Tilemaps.Components.GetTilesWithinWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. - */ -var GetTilesWithinWorldXY = function (worldX, worldY, width, height, filteringOptions, camera, layer) -{ - // Top left corner of the rect, rounded down to include partial tiles - var xStart = WorldToTileX(worldX, true, camera, layer); - var yStart = WorldToTileY(worldY, true, camera, layer); - - // Bottom right corner of the rect, rounded up to include partial tiles - var xEnd = Math.ceil(WorldToTileX(worldX + width, false, camera, layer)); - var yEnd = Math.ceil(WorldToTileY(worldY + height, false, camera, layer)); - - return GetTilesWithin(xStart, yStart, xEnd - xStart, yEnd - yStart, filteringOptions, layer); -}; - -module.exports = GetTilesWithinWorldXY; - - -/***/ }), -/* 885 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var HasTileAt = __webpack_require__(345); -var WorldToTileX = __webpack_require__(39); -var WorldToTileY = __webpack_require__(40); - -/** - * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @function Phaser.Tilemaps.Components.HasTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {boolean} - */ -var HasTileAtWorldXY = function (worldX, worldY, camera, layer) -{ - var tileX = WorldToTileX(worldX, true, camera, layer); - var tileY = WorldToTileY(worldY, true, camera, layer); - - return HasTileAt(tileX, tileY, layer); -}; - -module.exports = HasTileAtWorldXY; - - -/***/ }), -/* 886 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var PutTileAt = __webpack_require__(154); -var WorldToTileX = __webpack_require__(39); -var WorldToTileY = __webpack_require__(40); - -/** - * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either - * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the - * specified location. If you pass in an index, only the index at the specified location will be - * changed. Collision information will be recalculated at the specified location. - * - * @function Phaser.Tilemaps.Components.PutTileAtWorldXY - * @since 3.0.0 - * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {integer} worldX - [description] - * @param {integer} worldY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map. - */ -var PutTileAtWorldXY = function (tile, worldX, worldY, recalculateFaces, camera, layer) -{ - var tileX = WorldToTileX(worldX, true, camera, layer); - var tileY = WorldToTileY(worldY, true, camera, layer); - return PutTileAt(tile, tileX, tileY, recalculateFaces, layer); -}; - -module.exports = PutTileAtWorldXY; - - -/***/ }), -/* 887 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CalculateFacesWithin = __webpack_require__(34); -var PutTileAt = __webpack_require__(154); - -/** - * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified - * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, - * all attributes will be copied over to the specified location. If you pass in an index, only the - * index at the specified location will be changed. Collision information will be recalculated - * within the region tiles were changed. - * - * @function Phaser.Tilemaps.Components.PutTilesAt - * @since 3.0.0 - * - * @param {integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][]} tile - A row (array) or grid (2D array) of Tiles - * or tile indexes to place. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var PutTilesAt = function (tilesArray, tileX, tileY, recalculateFaces, layer) -{ - if (!Array.isArray(tilesArray)) { return null; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - - // Force the input array to be a 2D array - if (!Array.isArray(tilesArray[0])) - { - tilesArray = [ tilesArray ]; - } - - var height = tilesArray.length; - var width = tilesArray[0].length; - - for (var ty = 0; ty < height; ty++) - { - for (var tx = 0; tx < width; tx++) - { - var tile = tilesArray[ty][tx]; - PutTileAt(tile, tileX + tx, tileY + ty, false, layer); - } - } - - if (recalculateFaces) - { - // Recalculate the faces within the destination area and neighboring tiles - CalculateFacesWithin(tileX - 1, tileY - 1, width + 2, height + 2, layer); - } -}; - -module.exports = PutTilesAt; - - - -/***/ }), -/* 888 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); -var GetRandomElement = __webpack_require__(140); - -/** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then - * those will be used for randomly assigning new tile indexes. If an array is not provided, the - * indexes found within the region (excluding -1) will be used for randomly assigning new tile - * indexes. This method only modifies tile indexes and does not change collision information. - * - * @function Phaser.Tilemaps.Components.Randomize - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var Randomize = function (tileX, tileY, width, height, indexes, layer) -{ - var i; - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - - // If no indicies are given, then find all the unique indexes within the specified region - if (indexes === undefined) - { - indexes = []; - for (i = 0; i < tiles.length; i++) - { - if (indexes.indexOf(tiles[i].index) === -1) - { - indexes.push(tiles[i].index); - } - } - } - - for (i = 0; i < tiles.length; i++) - { - tiles[i].index = GetRandomElement(indexes); - } -}; - -module.exports = Randomize; - - -/***/ }), -/* 889 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RemoveTileAt = __webpack_require__(346); -var WorldToTileX = __webpack_require__(39); -var WorldToTileY = __webpack_require__(40); - -/** - * Removes the tile at the given world coordinates in the specified layer and updates the layer's - * collision information. - * - * @function Phaser.Tilemaps.Components.RemoveTileAtWorldXY - * @since 3.0.0 - * - * @param {integer|Phaser.Tilemaps.Tile} tile - The index of this tile to set or a Tile object. - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The Tile object that was removed. - */ -var RemoveTileAtWorldXY = function (worldX, worldY, replaceWithNull, recalculateFaces, camera, layer) -{ - var tileX = WorldToTileX(worldX, true, camera, layer); - var tileY = WorldToTileY(worldY, true, camera, layer); - return RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, layer); -}; - -module.exports = RemoveTileAtWorldXY; - - -/***/ }), -/* 890 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); -var Color = __webpack_require__(227); - -/** - * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to - * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles - * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation - * wherever you want on the screen. - * - * @function Phaser.Tilemaps.Components.RenderDebug - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. - * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. - * @param {Color|null} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at - * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. - * @param {Color|null} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled - * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. - * @param {Color|null} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting - * tile faces. If set to null, interesting tile faces will not be drawn. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var RenderDebug = function (graphics, styleConfig, layer) -{ - if (styleConfig === undefined) { styleConfig = {}; } - - // Default colors without needlessly creating Color objects - var tileColor = styleConfig.tileColor !== undefined - ? styleConfig.tileColor - : new Color(105, 210, 231, 150); - var collidingTileColor = styleConfig.collidingTileColor !== undefined - ? styleConfig.collidingTileColor - : new Color(243, 134, 48, 200); - var faceColor = styleConfig.faceColor !== undefined - ? styleConfig.faceColor - : new Color(40, 39, 37, 150); - - var tiles = GetTilesWithin(0, 0, layer.width, layer.height, null, layer); - - for (var i = 0; i < tiles.length; i++) - { - var tile = tiles[i]; - - var tw = tile.width; - var th = tile.height; - var x = tile.pixelX; - var y = tile.pixelY; - - var color = tile.collides ? collidingTileColor : tileColor; - if (color !== null) - { - graphics.fillStyle(color.color, color.alpha / 255); - graphics.fillRect(x, y, tw, th); - } - - // Inset the face line to prevent neighboring tile's lines from overlapping - x += 1; - y += 1; - tw -= 2; - th -= 2; - - if (faceColor !== null) - { - graphics.lineStyle(1, faceColor.color, faceColor.alpha / 255); - if (tile.faceTop) { graphics.lineBetween(x, y, x + tw, y); } - if (tile.faceRight) { graphics.lineBetween(x + tw, y, x + tw, y + th); } - if (tile.faceBottom) { graphics.lineBetween(x, y + th, x + tw, y + th); } - if (tile.faceLeft) { graphics.lineBetween(x, y, x, y + th); } - } - } -}; - -module.exports = RenderDebug; - - -/***/ }), -/* 891 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SetTileCollision = __webpack_require__(43); -var CalculateFacesWithin = __webpack_require__(34); -var SetLayerCollisionIndex = __webpack_require__(155); - -/** - * Sets collision on the given tile or tiles within a layer by index. You can pass in either a - * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if - * collision will be enabled (true) or disabled (false). - * - * @function Phaser.Tilemaps.Components.SetCollision - * @since 3.0.0 - * - * @param {integer|array} indexes - Either a single tile index, or an array of tile indexes. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetCollision = function (indexes, collides, recalculateFaces, layer) -{ - if (collides === undefined) { collides = true; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - if (!Array.isArray(indexes)) { indexes = [ indexes ]; } - - // Update the array of colliding indexes - for (var i = 0; i < indexes.length; i++) - { - SetLayerCollisionIndex(indexes[i], collides, layer); - } - - // Update the tiles - for (var ty = 0; ty < layer.height; ty++) - { - for (var tx = 0; tx < layer.width; tx++) - { - var tile = layer.data[ty][tx]; - - if (tile && indexes.indexOf(tile.index) !== -1) - { - SetTileCollision(tile, collides); - } - } - } - - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } -}; - -module.exports = SetCollision; - - -/***/ }), -/* 892 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SetTileCollision = __webpack_require__(43); -var CalculateFacesWithin = __webpack_require__(34); -var SetLayerCollisionIndex = __webpack_require__(155); - -/** - * Sets collision on a range of tiles in a layer whose index is between the specified `start` and - * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set - * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be - * enabled (true) or disabled (false). - * - * @function Phaser.Tilemaps.Components.SetCollisionBetween - * @since 3.0.0 - * - * @param {integer} start - The first index of the tile to be set for collision. - * @param {integer} stop - The last index of the tile to be set for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetCollisionBetween = function (start, stop, collides, recalculateFaces, layer) -{ - if (collides === undefined) { collides = true; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - - if (start > stop) { return; } - - // Update the array of colliding indexes - for (var index = start; index <= stop; index++) - { - SetLayerCollisionIndex(index, collides, layer); - } - - // Update the tiles - for (var ty = 0; ty < layer.height; ty++) - { - for (var tx = 0; tx < layer.width; tx++) - { - var tile = layer.data[ty][tx]; - if (tile) - { - if (tile.index >= start && tile.index <= stop) - { - SetTileCollision(tile, collides); - } - } - } - } - - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } -}; - -module.exports = SetCollisionBetween; - - -/***/ }), -/* 893 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SetTileCollision = __webpack_require__(43); -var CalculateFacesWithin = __webpack_require__(34); -var SetLayerCollisionIndex = __webpack_require__(155); - -/** - * Sets collision on all tiles in the given layer, except for tiles that have an index specified in - * the given array. The `collides` parameter controls if collision will be enabled (true) or - * disabled (false). - * - * @function Phaser.Tilemaps.Components.SetCollisionByExclusion - * @since 3.0.0 - * - * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetCollisionByExclusion = function (indexes, collides, recalculateFaces, layer) -{ - if (collides === undefined) { collides = true; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - if (!Array.isArray(indexes)) { indexes = [ indexes ]; } - - // Note: this only updates layer.collideIndexes for tile indexes found currently in the layer - for (var ty = 0; ty < layer.height; ty++) - { - for (var tx = 0; tx < layer.width; tx++) - { - var tile = layer.data[ty][tx]; - if (tile && indexes.indexOf(tile.index) === -1) - { - SetTileCollision(tile, collides); - SetLayerCollisionIndex(tile.index, collides, layer); - } - } - } - - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } -}; - -module.exports = SetCollisionByExclusion; - - -/***/ }), -/* 894 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SetTileCollision = __webpack_require__(43); -var CalculateFacesWithin = __webpack_require__(34); -var HasValue = __webpack_require__(72); - -/** - * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property - * that matches the given properties object, its collision flag will be set. The `collides` - * parameter controls if collision will be enabled (true) or disabled (false). Passing in - * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that - * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can - * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a - * "types" property that matches any of those values, its collision flag will be updated. - * - * @function Phaser.Tilemaps.Components.SetCollisionByProperty - * @since 3.0.0 - * - * @param {object} properties - An object with tile properties and corresponding values that should - * be checked. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetCollisionByProperty = function (properties, collides, recalculateFaces, layer) -{ - if (collides === undefined) { collides = true; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - - for (var ty = 0; ty < layer.height; ty++) - { - for (var tx = 0; tx < layer.width; tx++) - { - var tile = layer.data[ty][tx]; - - if (!tile) { continue; } - - for (var property in properties) - { - if (!HasValue(tile.properties, property)) { continue; } - - var values = properties[property]; - if (!Array.isArray(values)) - { - values = [ values ]; - } - - for (var i = 0; i < values.length; i++) - { - if (tile.properties[property] === values[i]) - { - SetTileCollision(tile, collides); - } - } - } - } - } - - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } -}; - -module.exports = SetCollisionByProperty; - - -/***/ }), -/* 895 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SetTileCollision = __webpack_require__(43); -var CalculateFacesWithin = __webpack_require__(34); - -/** - * Sets collision on the tiles within a layer by checking each tile's collision group data - * (typically defined in Tiled within the tileset collision editor). If any objects are found within - * a tile's collision group, the tile's colliding information will be set. The `collides` parameter - * controls if collision will be enabled (true) or disabled (false). - * - * @function Phaser.Tilemaps.Components.SetCollisionFromCollisionGroup - * @since 3.0.0 - * - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetCollisionFromCollisionGroup = function (collides, recalculateFaces, layer) -{ - if (collides === undefined) { collides = true; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - - for (var ty = 0; ty < layer.height; ty++) - { - for (var tx = 0; tx < layer.width; tx++) - { - var tile = layer.data[ty][tx]; - - if (!tile) { continue; } - - var collisionGroup = tile.getCollisionGroup(); - - // It's possible in Tiled to have a collision group without any shapes, e.g. create a - // shape and then delete the shape. - if (collisionGroup && collisionGroup.objects && collisionGroup.objects.length > 0) - { - SetTileCollision(tile, collides); - } - } - } - - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } -}; - -module.exports = SetCollisionFromCollisionGroup; - - -/***/ }), -/* 896 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Sets a global collision callback for the given tile index within the layer. This will affect all - * tiles on this layer that have the same index. If a callback is already set for the tile index it - * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile - * at a specific location on the map then see setTileLocationCallback. - * - * @function Phaser.Tilemaps.Components.SetTileIndexCallback - * @since 3.0.0 - * - * @param {integer|array} indexes - Either a single tile index, or an array of tile indexes to have a - * collision callback set for. - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetTileIndexCallback = function (indexes, callback, callbackContext, layer) -{ - if (typeof indexes === 'number') - { - layer.callbacks[indexes] = (callback !== null) - ? { callback: callback, callbackContext: callbackContext } - : undefined; - } - else - { - for (var i = 0, len = indexes.length; i < len; i++) - { - layer.callbacks[indexes[i]] = (callback !== null) - ? { callback: callback, callbackContext: callbackContext } - : undefined; - } - } -}; - -module.exports = SetTileIndexCallback; - - -/***/ }), -/* 897 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); - -/** - * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. - * If a callback is already set for the tile index it will be replaced. Set the callback to null to - * remove it. - * - * @function Phaser.Tilemaps.Components.SetTileLocationCallback - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetTileLocationCallback = function (tileX, tileY, width, height, callback, callbackContext, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - - for (var i = 0; i < tiles.length; i++) - { - tiles[i].setCollisionCallback(callback, callbackContext); - } - -}; - -module.exports = SetTileLocationCallback; - - -/***/ }), -/* 898 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); -var ShuffleArray = __webpack_require__(80); - -/** - * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given - * layer. It will only randomize the tiles in that area, so if they're all the same nothing will - * appear to have changed! This method only modifies tile indexes and does not change collision - * information. - * - * @function Phaser.Tilemaps.Components.Shuffle - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var Shuffle = function (tileX, tileY, width, height, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - - var indexes = tiles.map(function (tile) { return tile.index; }); - ShuffleArray(indexes); - - for (var i = 0; i < tiles.length; i++) - { - tiles[i].index = indexes[i]; - } -}; - -module.exports = Shuffle; - - -/***/ }), -/* 899 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); - -/** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision - * information. - * - * @function Phaser.Tilemaps.Components.SwapByIndex - * @since 3.0.0 - * - * @param {integer} tileA - First tile index. - * @param {integer} tileB - Second tile index. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SwapByIndex = function (indexA, indexB, tileX, tileY, width, height, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - for (var i = 0; i < tiles.length; i++) - { - if (tiles[i]) - { - if (tiles[i].index === indexA) - { - tiles[i].index = indexB; - } - else if (tiles[i].index === indexB) - { - tiles[i].index = indexA; - } - } - } -}; - -module.exports = SwapByIndex; - - -/***/ }), -/* 900 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var TileToWorldX = __webpack_require__(98); -var TileToWorldY = __webpack_require__(99); -var Vector2 = __webpack_require__(6); - -/** - * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layer's position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @function Phaser.Tilemaps.Components.TileToWorldXY - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Math.Vector2} The XY location in world coordinates. - */ -var TileToWorldXY = function (tileX, tileY, point, camera, layer) -{ - if (point === undefined) { point = new Vector2(0, 0); } - - point.x = TileToWorldX(tileX, camera, layer); - point.y = TileToWorldY(tileY, camera, layer); - - return point; -}; - -module.exports = TileToWorldXY; - - -/***/ }), -/* 901 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(15); - -/** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will recieve a new index. New indexes are drawn from the given - * weightedIndexes array. An example weighted array: - * - * [ - * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 - * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 - * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 - * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 - * ] - * - * The probability of any index being choose is (the index's weight) / (sum of all weights). This - * method only modifies tile indexes and does not change collision information. - * - * @function Phaser.Tilemaps.Components.WeightedRandomize - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during - * randomization. They should be in the form: { index: 0, weight: 4 } or - * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var WeightedRandomize = function (tileX, tileY, width, height, weightedIndexes, layer) -{ - if (weightedIndexes === undefined) { return; } - - var i; - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - - var weightTotal = 0; - for (i = 0; i < weightedIndexes.length; i++) - { - weightTotal += weightedIndexes[i].weight; - } - - if (weightTotal <= 0) { return; } - - for (i = 0; i < tiles.length; i++) - { - var rand = Math.random() * weightTotal; - var sum = 0; - var randomIndex = -1; - for (var j = 0; j < weightedIndexes.length; j++) - { - sum += weightedIndexes[j].weight; - if (rand <= sum) - { - var chosen = weightedIndexes[j].index; - randomIndex = Array.isArray(chosen) - ? chosen[Math.floor(Math.random() * chosen.length)] - : chosen; - break; - } - } - - tiles[i].index = randomIndex; - } -}; - -module.exports = WeightedRandomize; - - -/***/ }), -/* 902 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var WorldToTileX = __webpack_require__(39); -var WorldToTileY = __webpack_require__(40); -var Vector2 = __webpack_require__(6); - -/** - * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the - * layer's position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @function Phaser.Tilemaps.Components.WorldToTileXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Math.Vector2} The XY location in tile units. - */ -var WorldToTileXY = function (worldX, worldY, snapToFloor, point, camera, layer) -{ - if (point === undefined) { point = new Vector2(0, 0); } - - point.x = WorldToTileX(worldX, snapToFloor, camera, layer); - point.y = WorldToTileY(worldY, snapToFloor, camera, layer); - - return point; -}; - -module.exports = WorldToTileXY; - - -/***/ }), -/* 903 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Tilemaps.Parsers - */ - -module.exports = { - - Parse: __webpack_require__(347), - Parse2DArray: __webpack_require__(156), - ParseCSV: __webpack_require__(348), - - Impact: __webpack_require__(354), - Tiled: __webpack_require__(349) - -}; - - -/***/ }), -/* 904 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Base64Decode = __webpack_require__(905); -var GetFastValue = __webpack_require__(2); -var LayerData = __webpack_require__(75); -var ParseGID = __webpack_require__(350); -var Tile = __webpack_require__(44); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseTileLayers - * @since 3.0.0 - * - * @param {object} json - [description] - * @param {boolean} insertNull - [description] - * - * @return {array} [description] - */ -var ParseTileLayers = function (json, insertNull) -{ - var tileLayers = []; - - for (var i = 0; i < json.layers.length; i++) - { - if (json.layers[i].type !== 'tilelayer') - { - continue; - } - - var curl = json.layers[i]; - - // Base64 decode data if necessary. NOTE: uncompressed base64 only. - if (curl.compression) - { - console.warn( - 'TilemapParser.parseTiledJSON - Layer compression is unsupported, skipping layer \'' - + curl.name + '\'' - ); - continue; - } - else if (curl.encoding && curl.encoding === 'base64') - { - curl.data = Base64Decode(curl.data); - delete curl.encoding; // Allow the same map to be parsed multiple times - } - - var layerData = new LayerData({ - name: curl.name, - x: GetFastValue(curl, 'offsetx', 0) + curl.x, - y: GetFastValue(curl, 'offsety', 0) + curl.y, - width: curl.width, - height: curl.height, - tileWidth: json.tilewidth, - tileHeight: json.tileheight, - alpha: curl.opacity, - visible: curl.visible, - properties: GetFastValue(curl, 'properties', {}) - }); - - var x = 0; - var row = []; - var output = []; - - // Loop through the data field in the JSON. - - // This is an array containing the tile indexes, one after the other. -1 = no tile, - // everything else = the tile index (starting at 1 for Tiled, 0 for CSV) If the map - // contains multiple tilesets then the indexes are relative to that which the set starts - // from. Need to set which tileset in the cache = which tileset in the JSON, if you do this - // manually it means you can use the same map data but a new tileset. - - for (var t = 0, len = curl.data.length; t < len; t++) - { - var gidInfo = ParseGID(curl.data[t]); - - // index, x, y, width, height - if (gidInfo.gid > 0) - { - var tile = new Tile(layerData, gidInfo.gid, x, output.length, json.tilewidth, - json.tileheight); - - // Turning Tiled's FlippedHorizontal, FlippedVertical and FlippedAntiDiagonal - // propeties into flipX, flipY and rotation - tile.rotation = gidInfo.rotation; - tile.flipX = gidInfo.flipped; - - row.push(tile); - } - else - { - var blankTile = insertNull - ? null - : new Tile(layerData, -1, x, output.length, json.tilewidth, json.tileheight); - row.push(blankTile); - } - - x++; - - if (x === curl.width) - { - output.push(row); - x = 0; - row = []; - } - } - - layerData.data = output; - - tileLayers.push(layerData); - } - - return tileLayers; -}; - -module.exports = ParseTileLayers; - - -/***/ }), -/* 905 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Tiled.Base64Decode - * @since 3.0.0 - * - * @param {object} data - [description] - * - * @return {array} [description] - */ -var Base64Decode = function (data) -{ - var binaryString = window.atob(data); - var len = binaryString.length; - var bytes = new Array(len); - - // Interpret binaryString as an array of bytes representing little-endian encoded uint32 values. - for (var i = 0; i < len; i += 4) - { - bytes[i / 4] = ( - binaryString.charCodeAt(i) | - binaryString.charCodeAt(i + 1) << 8 | - binaryString.charCodeAt(i + 2) << 16 | - binaryString.charCodeAt(i + 3) << 24 - ) >>> 0; - } - - return bytes; -}; - -module.exports = Base64Decode; - - -/***/ }), -/* 906 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetFastValue = __webpack_require__(2); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseImageLayers - * @since 3.0.0 - * - * @param {object} json - [description] - * - * @return {array} [description] - */ -var ParseImageLayers = function (json) -{ - var images = []; - - for (var i = 0; i < json.layers.length; i++) - { - if (json.layers[i].type !== 'imagelayer') - { - continue; - } - - var curi = json.layers[i]; - - images.push({ - name: curi.name, - image: curi.image, - x: GetFastValue(curi, 'offsetx', 0) + curi.x, - y: GetFastValue(curi, 'offsety', 0) + curi.y, - alpha: curi.opacity, - visible: curi.visible, - properties: GetFastValue(curi, 'properties', {}) - }); - } - - return images; -}; - -module.exports = ParseImageLayers; - - -/***/ }), -/* 907 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Tileset = __webpack_require__(100); -var ImageCollection = __webpack_require__(351); -var ParseObject = __webpack_require__(352); - -/** - * Tilesets & Image Collections - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseTilesets - * @since 3.0.0 - * - * @param {object} json - [description] - * - * @return {object} [description] - */ -var ParseTilesets = function (json) -{ - var tilesets = []; - var imageCollections = []; - var lastSet = null; - var stringID; - - for (var i = 0; i < json.tilesets.length; i++) - { - // name, firstgid, width, height, margin, spacing, properties - var set = json.tilesets[i]; - - if (set.source) - { - console.warn('Phaser can\'t load external tilesets. Use the Embed Tileset button and then export the map again.'); - } - else if (set.image) - { - var newSet = new Tileset(set.name, set.firstgid, set.tilewidth, set.tileheight, set.margin, set.spacing); - - // Properties stored per-tile in object with string indexes starting at "0" - if (set.tileproperties) - { - newSet.tileProperties = set.tileproperties; - } - - // Object & terrain shapes stored per-tile in object with string indexes starting at "0" - if (set.tiles) - { - newSet.tileData = set.tiles; - - // Parse the objects into Phaser format to match handling of other Tiled objects - for (stringID in newSet.tileData) - { - var objectGroup = newSet.tileData[stringID].objectgroup; - if (objectGroup && objectGroup.objects) - { - var parsedObjects = objectGroup.objects.map( - function (obj) { return ParseObject(obj); } - ); - newSet.tileData[stringID].objectgroup.objects = parsedObjects; - } - } - } - - // For a normal sliced tileset the row/count/size information is computed when updated. - // This is done (again) after the image is set. - newSet.updateTileData(set.imagewidth, set.imageheight); - - tilesets.push(newSet); - } - else - { - var newCollection = new ImageCollection(set.name, set.firstgid, set.tilewidth, - set.tileheight, set.margin, set.spacing, set.properties); - - for (stringID in set.tiles) - { - var image = set.tiles[stringID].image; - var gid = set.firstgid + parseInt(stringID, 10); - newCollection.addImage(gid, image); - } - - imageCollections.push(newCollection); - } - - // We've got a new Tileset, so set the lastgid into the previous one - if (lastSet) - { - lastSet.lastgid = set.firstgid - 1; - } - - lastSet = set; - } - - return { tilesets: tilesets, imageCollections: imageCollections }; -}; - -module.exports = ParseTilesets; - - -/***/ }), -/* 908 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var HasValue = __webpack_require__(72); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Tiled.Pick - * @since 3.0.0 - * - * @param {object} object - [description] - * @param {array} keys - [description] - * - * @return {object} [description] - */ -var Pick = function (object, keys) -{ - var obj = {}; - - for (var i = 0; i < keys.length; i++) - { - var key = keys[i]; - - if (HasValue(object, key)) - { - obj[key] = object[key]; - } - } - - return obj; -}; - -module.exports = Pick; - - -/***/ }), -/* 909 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetFastValue = __webpack_require__(2); -var ParseObject = __webpack_require__(352); -var ObjectLayer = __webpack_require__(353); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseObjectLayers - * @since 3.0.0 - * - * @param {object} json - [description] - * - * @return {array} [description] - */ -var ParseObjectLayers = function (json) -{ - var objectLayers = []; - - for (var i = 0; i < json.layers.length; i++) - { - if (json.layers[i].type !== 'objectgroup') - { - continue; - } - - var curo = json.layers[i]; - var offsetX = GetFastValue(curo, 'offsetx', 0); - var offsetY = GetFastValue(curo, 'offsety', 0); - var objects = []; - - for (var j = 0; j < curo.objects.length; j++) - { - var parsedObject = ParseObject(curo.objects[j], offsetX, offsetY); - - objects.push(parsedObject); - } - - var objectLayer = new ObjectLayer(curo); - objectLayer.objects = objects; - - objectLayers.push(objectLayer); - } - - return objectLayers; -}; - -module.exports = ParseObjectLayers; - - -/***/ }), -/* 910 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Master list of tiles -> x, y, index in tileset. - * - * @function Phaser.Tilemaps.Parsers.Tiled.BuildTilesetIndex - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.MapData} mapData - [description] - * - * @return {array} [description] - */ -var BuildTilesetIndex = function (mapData) -{ - var tiles = []; - - for (var i = 0; i < mapData.tilesets.length; i++) - { - var set = mapData.tilesets[i]; - - var x = set.tileMargin; - var y = set.tileMargin; - - var count = 0; - var countX = 0; - var countY = 0; - - for (var t = set.firstgid; t < set.firstgid + set.total; t++) - { - // Can add extra properties here as needed - tiles[t] = [ x, y, i ]; - - x += set.tileWidth + set.tileSpacing; - - count++; - - if (count === set.total) - { - break; - } - - countX++; - - if (countX === set.columns) - { - x = set.tileMargin; - y += set.tileHeight + set.tileSpacing; - - countX = 0; - countY++; - - if (countY === set.rows) - { - break; - } - } - } - } - - return tiles; -}; - -module.exports = BuildTilesetIndex; - - -/***/ }), -/* 911 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Extend = __webpack_require__(23); - -/** - * Copy properties from tileset to tiles. - * - * @function Phaser.Tilemaps.Parsers.Tiled.AssignTileProperties - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.MapData} mapData - [description] - */ -var AssignTileProperties = function (mapData) -{ - var layerData; - var tile; - var sid; - var set; - var row; - - // go through each of the map data layers - for (var i = 0; i < mapData.layers.length; i++) - { - layerData = mapData.layers[i]; - - set = null; - - // rows of tiles - for (var j = 0; j < layerData.data.length; j++) - { - row = layerData.data[j]; - - // individual tiles - for (var k = 0; k < row.length; k++) - { - tile = row[k]; - - if (tile === null || tile.index < 0) - { - continue; - } - - // find the relevant tileset - sid = mapData.tiles[tile.index][2]; - set = mapData.tilesets[sid]; - - // Ensure that a tile's size matches its tileset - tile.width = set.tileWidth; - tile.height = set.tileHeight; - - // if that tile type has any properties, add them to the tile object - if (set.tileProperties && set.tileProperties[tile.index - set.firstgid]) - { - tile.properties = Extend( - tile.properties, set.tileProperties[tile.index - set.firstgid] - ); - } - } - } - } -}; - -module.exports = AssignTileProperties; - - -/***/ }), -/* 912 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var LayerData = __webpack_require__(75); -var Tile = __webpack_require__(44); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Impact.ParseTileLayers - * @since 3.0.0 - * - * @param {object} json - [description] - * @param {boolean} insertNull - [description] - * - * @return {array} [description] - */ -var ParseTileLayers = function (json, insertNull) -{ - var tileLayers = []; - - for (var i = 0; i < json.layer.length; i++) - { - var layer = json.layer[i]; - - var layerData = new LayerData({ - name: layer.name, - width: layer.width, - height: layer.height, - tileWidth: layer.tilesize, - tileHeight: layer.tilesize, - visible: layer.visible === 1 - }); - - var row = []; - var tileGrid = []; - - // Loop through the data field in the JSON. This is a 2D array containing the tile indexes, - // one after the other. The indexes are relative to the tileset that contains the tile. - for (var y = 0; y < layer.data.length; y++) - { - for (var x = 0; x < layer.data[y].length; x++) - { - // In Weltmeister, 0 = no tile, but the Tilemap API expects -1 = no tile. - var index = layer.data[y][x] - 1; - - var tile; - - if (index > -1) - { - tile = new Tile(layerData, index, x, y, layer.tilesize, layer.tilesize); - } - else - { - tile = insertNull - ? null - : new Tile(layerData, -1, x, y, layer.tilesize, layer.tilesize); - } - - row.push(tile); - } - - tileGrid.push(row); - row = []; - } - - layerData.data = tileGrid; - - tileLayers.push(layerData); - } - - return tileLayers; -}; - -module.exports = ParseTileLayers; - - -/***/ }), -/* 913 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Tileset = __webpack_require__(100); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Impact.ParseTilesets - * @since 3.0.0 - * - * @param {object} json - [description] - * - * @return {array} [description] - */ -var ParseTilesets = function (json) -{ - var tilesets = []; - var tilesetsNames = []; - - for (var i = 0; i < json.layer.length; i++) - { - var layer = json.layer[i]; - - // A relative filepath to the source image (within Weltmeister) is used for the name - var tilesetName = layer.tilesetName; - - // Only add unique tilesets that have a valid name. Collision layers will have a blank name. - if (tilesetName !== '' && tilesetsNames.indexOf(tilesetName) === -1) - { - tilesetsNames.push(tilesetName); - - // Tiles are stored with an ID relative to the tileset, rather than a globally unique ID - // across all tilesets. Also, tilesets in Weltmeister have no margin or padding. - tilesets.push(new Tileset(tilesetName, 0, layer.tilesize, layer.tilesize, 0, 0)); - } - } - - return tilesets; -}; - -module.exports = ParseTilesets; - - -/***/ }), -/* 914 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(915); -} - -if (true) -{ - renderCanvas = __webpack_require__(916); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 915 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.Tilemaps.DynamicTilemapLayer} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var DynamicTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - src.cull(camera); - - this.pipeline.batchDynamicTilemapLayer(src, camera); -}; - -module.exports = DynamicTilemapLayerWebGLRenderer; - - -/***/ }), -/* 916 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.Tilemaps.DynamicTilemapLayer} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - src.cull(camera); - - var renderTiles = src.culledTiles; - var length = renderTiles.length; - var image = src.tileset.image.getSourceImage(); - var tileset = this.tileset; - - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - var ctx = renderer.gameContext; - - ctx.save(); - ctx.translate(tx, ty); - ctx.rotate(src.rotation); - ctx.scale(src.scaleX, src.scaleY); - ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); - - for (var index = 0; index < length; ++index) - { - var tile = renderTiles[index]; - - var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); - if (tileTexCoords === null) { continue; } - - var halfWidth = tile.width / 2; - var halfHeight = tile.height / 2; - - ctx.save(); - ctx.translate(tile.pixelX + halfWidth, tile.pixelY + halfHeight); - - if (tile.rotation !== 0) - { - ctx.rotate(tile.rotation); - } - - if (tile.flipX || tile.flipY) - { - ctx.scale(tile.flipX ? -1 : 1, tile.flipY ? -1 : 1); - } - - ctx.globalAlpha = src.alpha * tile.alpha; - - ctx.drawImage( - image, - tileTexCoords.x, tileTexCoords.y, - tile.width, tile.height, - -halfWidth, -halfHeight, - tile.width, tile.height - ); - - ctx.restore(); - } - - ctx.restore(); -}; - -module.exports = DynamicTilemapLayerCanvasRenderer; - - -/***/ }), -/* 917 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(918); -} - -if (true) -{ - renderCanvas = __webpack_require__(919); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 918 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.Tilemaps.StaticTilemapLayer} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - src.upload(camera); - - this.pipeline.drawStaticTilemapLayer(src, camera); -}; - -module.exports = StaticTilemapLayerWebGLRenderer; - - -/***/ }), -/* 919 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(1); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.Tilemaps.StaticTilemapLayer} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - src.cull(camera); - - var renderTiles = src.culledTiles; - var tileset = this.tileset; - var ctx = renderer.gameContext; - var tileCount = renderTiles.length; - var image = tileset.image.getSourceImage(); - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - - ctx.save(); - ctx.translate(tx, ty); - ctx.rotate(src.rotation); - ctx.scale(src.scaleX, src.scaleY); - ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); - ctx.globalAlpha = src.alpha; - - for (var index = 0; index < tileCount; ++index) - { - var tile = renderTiles[index]; - - var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); - - if (tileTexCoords === null) { continue; } - - ctx.drawImage( - image, - tileTexCoords.x, tileTexCoords.y, - tile.width, tile.height, - tile.pixelX, tile.pixelY, - tile.width, tile.height - ); - } - - ctx.restore(); -}; - -module.exports = StaticTilemapLayerCanvasRenderer; - - -/***/ }), -/* 920 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectCreator = __webpack_require__(13); -var ParseToTilemap = __webpack_require__(157); - -/** - * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. - * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing - * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map - * data. For an empty map, you should specify tileWidth, tileHeight, width & height. - * - * @method Phaser.GameObjects.GameObjectCreator#tilemap - * @since 3.0.0 - * - * @param {object} [config] - The config options for the Tilemap. - * @param {string} [config.key] - The key in the Phaser cache that corresponds to the loaded tilemap - * data. - * @param {integer[][]} [config.data] - Instead of loading from the cache, you can also load - * directly from a 2D array of tile indexes. - * @param {integer} [config.tileWidth=32] - The width of a tile in pixels. - * @param {integer} [config.tileHeight=32] - The height of a tile in pixels. - * @param {integer} [config.width=10] - The width of the map in tiles. - * @param {integer} [config.height=10] - The height of the map in tiles. - * @param {boolean} [config.insertNull=false] - Controls how empty tiles, tiles with an index of -1, - * in the map data are handled. If `true`, empty locations will get a value of `null`. If `false`, - * empty location will get a Tile object with an index of -1. If you've a large sparsely populated - * map and the tile data doesn't need to change then setting this value to `true` will help with - * memory consumption. However if your map is small or you need to update the tiles dynamically, - * then leave the default value set. - * - * @return {Phaser.Tilemaps.Tilemap} - */ -GameObjectCreator.register('tilemap', function (config) -{ - // Defaults are applied in ParseToTilemap - var c = (config !== undefined) ? config : {}; - - return ParseToTilemap( - this.scene, - c.key, - c.tileWidth, - c.tileHeight, - c.width, - c.height, - c.data, - c.insertNull - ); -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 921 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectFactory = __webpack_require__(9); -var ParseToTilemap = __webpack_require__(157); - -/** - * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. - * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing - * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map - * data. For an empty map, you should specify tileWidth, tileHeight, width & height. - * - * @method Phaser.GameObjects.GameObjectFactory#tilemap - * @since 3.0.0 - * - * @param {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data. - * @param {integer} [tileWidth=32] - The width of a tile in pixels. Pass in `null` to leave as the - * default. - * @param {integer} [tileHeight=32] - The height of a tile in pixels. Pass in `null` to leave as the - * default. - * @param {integer} [width=10] - The width of the map in tiles. Pass in `null` to leave as the - * default. - * @param {integer} [height=10] - The height of the map in tiles. Pass in `null` to leave as the - * default. - * @param {integer[][]} [data] - Instead of loading from the cache, you can also load directly from - * a 2D array of tile indexes. Pass in `null` for no data. - * @param {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, in the - * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {Phaser.Tilemaps.Tilemap} - */ -GameObjectFactory.register('tilemap', function (key, tileWidth, tileHeight, width, height, data, insertNull) -{ - // Allow users to specify null to indicate that they want the default value, since null is - // shorter & more legible than undefined. Convert null to undefined to allow ParseToTilemap - // defaults to take effect. - - if (key === null) { key = undefined; } - if (tileWidth === null) { tileWidth = undefined; } - if (tileHeight === null) { tileHeight = undefined; } - if (width === null) { width = undefined; } - if (height === null) { height = undefined; } - - return ParseToTilemap(this.scene, key, tileWidth, tileHeight, width, height, data, insertNull); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 922 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Time - */ - -module.exports = { - - Clock: __webpack_require__(923), - TimerEvent: __webpack_require__(358) - -}; - - -/***/ }), -/* 923 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var PluginManager = __webpack_require__(12); -var TimerEvent = __webpack_require__(358); - -/** - * @classdesc - * [description] - * - * @class Clock - * @memberOf Phaser.Time - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var Clock = new Class({ - - initialize: - - function Clock (scene) - { - /** - * [description] - * - * @name Phaser.Time.Clock#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.Time.Clock#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - if (!scene.sys.settings.isBooted) - { - scene.sys.events.once('boot', this.boot, this); - } - - /** - * [description] - * - * @name Phaser.Time.Clock#now - * @type {number} - * @since 3.0.0 - */ - this.now = Date.now(); - - // Scale the delta time coming into the Clock by this factor - // which then influences anything using this Clock for calculations, like TimerEvents - - /** - * [description] - * - * @name Phaser.Time.Clock#timeScale - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * [description] - * - * @name Phaser.Time.Clock#paused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.paused = false; - - /** - * [description] - * - * @name Phaser.Time.Clock#_active - * @type {Phaser.Time.TimerEvent[]} + * @name Phaser.GameObjects.UpdateList#_list + * @type {array} * @private * @default [] * @since 3.0.0 */ - this._active = []; + this._list = []; /** * [description] * - * @name Phaser.Time.Clock#_pendingInsertion - * @type {Phaser.Time.TimerEvent[]} + * @name Phaser.GameObjects.UpdateList#_pendingInsertion + * @type {array} * @private * @default [] * @since 3.0.0 @@ -122776,8 +111853,8 @@ var Clock = new Class({ /** * [description] * - * @name Phaser.Time.Clock#_pendingRemoval - * @type {Phaser.Time.TimerEvent[]} + * @name Phaser.GameObjects.UpdateList#_pendingRemoval + * @type {array} * @private * @default [] * @since 3.0.0 @@ -122788,7 +111865,7 @@ var Clock = new Class({ /** * [description] * - * @method Phaser.Time.Clock#boot + * @method Phaser.GameObjects.UpdateList#boot * @since 3.0.0 */ boot: function () @@ -122804,74 +111881,29 @@ var Clock = new Class({ /** * [description] * - * @method Phaser.Time.Clock#addEvent + * @method Phaser.GameObjects.UpdateList#add * @since 3.0.0 * - * @param {object} config - [description] + * @param {Phaser.GameObjects.GameObject} child - [description] * - * @return {Phaser.Time.TimerEvent} [description] + * @return {Phaser.GameObjects.GameObject} [description] */ - addEvent: function (config) + add: function (child) { - var event = new TimerEvent(config); + // Is child already in this list? - this._pendingInsertion.push(event); + if (this._list.indexOf(child) === -1 && this._pendingInsertion.indexOf(child) === -1) + { + this._pendingInsertion.push(child); + } - return event; + return child; }, /** * [description] * - * @method Phaser.Time.Clock#delayedCall - * @since 3.0.0 - * - * @param {number} delay - [description] - * @param {function} callback - [description] - * @param {array} args - [description] - * @param {object} callbackScope - [description] - * - * @return {[type]} [description] - */ - delayedCall: function (delay, callback, args, callbackScope) - { - return this.addEvent({ delay: delay, callback: callback, args: args, callbackScope: callbackScope }); - }, - - /** - * [description] - * - * @method Phaser.Time.Clock#clearPendingEvents - * @since 3.0.0 - * - * @return {Phaser.Time.Clock} [description] - */ - clearPendingEvents: function () - { - this._pendingInsertion = []; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Time.Clock#removeAllEvents - * @since 3.0.0 - * - * @return {Phaser.Time.Clock} [description] - */ - removeAllEvents: function () - { - this._pendingRemoval = this._pendingRemoval.concat(this._active); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Time.Clock#preUpdate + * @method Phaser.GameObjects.UpdateList#preUpdate * @since 3.0.0 * * @param {number} time - [description] @@ -122889,30 +111921,23 @@ var Clock = new Class({ } var i; - var event; + var gameObject; - // Delete old events + // Delete old gameObjects for (i = 0; i < toRemove; i++) { - event = this._pendingRemoval[i]; + gameObject = this._pendingRemoval[i]; - var index = this._active.indexOf(event); + var index = this._list.indexOf(gameObject); if (index > -1) { - this._active.splice(index, 1); + this._list.splice(index, 1); } - - // Pool them? - event.destroy(); } - for (i = 0; i < toInsert; i++) - { - event = this._pendingInsertion[i]; - - this._active.push(event); - } + // Move pending to active + this._list = this._list.concat(this._pendingInsertion.splice(0)); // Clear the lists this._pendingRemoval.length = 0; @@ -122922,7 +111947,7 @@ var Clock = new Class({ /** * [description] * - * @method Phaser.Time.Clock#update + * @method Phaser.GameObjects.UpdateList#update * @since 3.0.0 * * @param {number} time - [description] @@ -122930,55 +111955,13 @@ var Clock = new Class({ */ update: function (time, delta) { - this.now = time; - - if (this.paused) + for (var i = 0; i < this._list.length; i++) { - return; - } + var gameObject = this._list[i]; - delta *= this.timeScale; - - for (var i = 0; i < this._active.length; i++) - { - var event = this._active[i]; - - if (event.paused) + if (gameObject.active) { - continue; - } - - // Use delta time to increase elapsed. - // Avoids needing to adjust for pause / resume. - // Automatically smoothed by TimeStep class. - // In testing accurate to +- 1ms! - event.elapsed += delta * event.timeScale; - - if (event.elapsed >= event.delay) - { - var remainder = event.elapsed - event.delay; - - // Limit it, in case it's checked in the callback - event.elapsed = event.delay; - - // Process the event - if (!event.hasDispatched && event.callback) - { - event.hasDispatched = true; - event.callback.apply(event.callbackScope, event.args); - } - - if (event.repeatCount > 0) - { - event.repeatCount--; - - event.elapsed = remainder; - event.hasDispatched = false; - } - else - { - this._pendingRemoval.push(event); - } + gameObject.preUpdate.call(gameObject, time, delta); } } }, @@ -122986,29 +111969,56 @@ var Clock = new Class({ /** * [description] * - * @method Phaser.Time.Clock#shutdown + * @method Phaser.GameObjects.UpdateList#remove + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - [description] + * + * @return {Phaser.GameObjects.GameObject} [description] + */ + remove: function (child) + { + var index = this._list.indexOf(child); + + if (index !== -1) + { + this._list.splice(index, 1); + } + + return child; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.UpdateList#removeAll + * @since 3.0.0 + * + * @return {Phaser.GameObjects.UpdateList} The UpdateList object. + */ + removeAll: function () + { + var i = this._list.length; + + while (i--) + { + this.remove(this._list[i]); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.UpdateList#shutdown * @since 3.0.0 */ shutdown: function () { - var i; + this.removeAll(); - for (i = 0; i < this._pendingInsertion.length; i++) - { - this._pendingInsertion[i].destroy(); - } - - for (i = 0; i < this._active.length; i++) - { - this._active[i].destroy(); - } - - for (i = 0; i < this._pendingRemoval.length; i++) - { - this._pendingRemoval[i].destroy(); - } - - this._active.length = 0; + this._list.length = 0; this._pendingRemoval.length = 0; this._pendingInsertion.length = 0; }, @@ -123016,7 +112026,7 @@ var Clock = new Class({ /** * [description] * - * @method Phaser.Time.Clock#destroy + * @method Phaser.GameObjects.UpdateList#destroy * @since 3.0.0 */ destroy: function () @@ -123024,18 +112034,11331 @@ var Clock = new Class({ this.shutdown(); this.scene = undefined; + this.systems = undefined; + } }); -PluginManager.register('Clock', Clock, 'time'); +PluginManager.register('UpdateList', UpdateList, 'updateList'); -module.exports = Clock; +module.exports = UpdateList; + + +/***/ }), +/* 782 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var List = __webpack_require__(97); +var PluginManager = __webpack_require__(12); +var StableSort = __webpack_require__(272); + +/** + * @classdesc + * [description] + * + * @class DisplayList + * @extends Phaser.Structs.List + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ +var DisplayList = new Class({ + + Extends: List, + + initialize: + + function DisplayList (scene) + { + List.call(this, scene); + + /** + * [description] + * + * @name Phaser.GameObjects.DisplayList#sortChildrenFlag + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.sortChildrenFlag = false; + + /** + * [description] + * + * @name Phaser.GameObjects.DisplayList#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.GameObjects.DisplayList#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + if (!scene.sys.settings.isBooted) + { + scene.sys.events.once('boot', this.boot, this); + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.DisplayList#boot + * @since 3.0.0 + */ + boot: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); + }, + + /** + * Force a sort of the display list on the next call to depthSort. + * + * @method Phaser.GameObjects.DisplayList#queueDepthSort + * @since 3.0.0 + */ + queueDepthSort: function () + { + this.sortChildrenFlag = true; + }, + + /** + * Immediately sorts the display list if the flag is set. + * + * @method Phaser.GameObjects.DisplayList#depthSort + * @since 3.0.0 + */ + depthSort: function () + { + if (this.sortChildrenFlag) + { + StableSort.inplace(this.list, this.sortByDepth); + + this.sortChildrenFlag = false; + } + }, + + /** + * [description] + * + * @method Phaser.GameObjects.DisplayList#sortByDepth + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} childA - [description] + * @param {Phaser.GameObjects.GameObject} childB - [description] + * + * @return {integer} [description] + */ + sortByDepth: function (childA, childB) + { + return childA._depth - childB._depth; + }, + + /** + * Given an array of Game Objects, sort the array and return it, + * so that the objects are in index order with the lowest at the bottom. + * + * @method Phaser.GameObjects.DisplayList#sortGameObjects + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject[]} gameObjects - [description] + * + * @return {array} [description] + */ + sortGameObjects: function (gameObjects) + { + if (gameObjects === undefined) { gameObjects = this.list; } + + this.scene.sys.depthSort(); + + return gameObjects.sort(this.sortIndexHandler.bind(this)); + }, + + /** + * Note that the given array is sorted in place, even though it isn't returned directly it will still be updated. + * + * @method Phaser.GameObjects.DisplayList#getTopGameObject + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject[]} gameObjects - [description] + * + * @return {Phaser.GameObjects.GameObject} The top-most Game Object on the Display List. + */ + getTopGameObject: function (gameObjects) + { + this.sortGameObjects(gameObjects); + + return gameObjects[gameObjects.length - 1]; + } + +}); + +PluginManager.register('DisplayList', DisplayList, 'displayList'); + +module.exports = DisplayList; + + +/***/ }), +/* 783 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.GameObjects + */ + +var GameObjects = { + + DisplayList: __webpack_require__(782), + GameObjectCreator: __webpack_require__(11), + GameObjectFactory: __webpack_require__(9), + UpdateList: __webpack_require__(781), + + Components: __webpack_require__(13), + + BuildGameObject: __webpack_require__(22), + BuildGameObjectAnimation: __webpack_require__(140), + GameObject: __webpack_require__(1), + BitmapText: __webpack_require__(139), + Blitter: __webpack_require__(138), + DynamicBitmapText: __webpack_require__(137), + Graphics: __webpack_require__(136), + Group: __webpack_require__(73), + Image: __webpack_require__(72), + Particles: __webpack_require__(133), + PathFollower: __webpack_require__(249), + RenderTexture: __webpack_require__(131), + Sprite3D: __webpack_require__(101), + Sprite: __webpack_require__(40), + Text: __webpack_require__(130), + TileSprite: __webpack_require__(129), + Zone: __webpack_require__(106), + + // Game Object Factories + + Factories: { + Blitter: __webpack_require__(697), + DynamicBitmapText: __webpack_require__(696), + Graphics: __webpack_require__(695), + Group: __webpack_require__(694), + Image: __webpack_require__(693), + Particles: __webpack_require__(692), + PathFollower: __webpack_require__(691), + RenderTexture: __webpack_require__(690), + Sprite3D: __webpack_require__(689), + Sprite: __webpack_require__(688), + StaticBitmapText: __webpack_require__(687), + Text: __webpack_require__(686), + TileSprite: __webpack_require__(685), + Zone: __webpack_require__(684) + }, + + Creators: { + Blitter: __webpack_require__(683), + DynamicBitmapText: __webpack_require__(682), + Graphics: __webpack_require__(681), + Group: __webpack_require__(680), + Image: __webpack_require__(679), + Particles: __webpack_require__(678), + RenderTexture: __webpack_require__(677), + Sprite3D: __webpack_require__(676), + Sprite: __webpack_require__(675), + StaticBitmapText: __webpack_require__(674), + Text: __webpack_require__(673), + TileSprite: __webpack_require__(672), + Zone: __webpack_require__(671) + } + +}; + +if (true) +{ + // WebGL only Game Objects + GameObjects.Mesh = __webpack_require__(96); + GameObjects.Quad = __webpack_require__(128); + + GameObjects.Factories.Mesh = __webpack_require__(667); + GameObjects.Factories.Quad = __webpack_require__(666); + + GameObjects.Creators.Mesh = __webpack_require__(665); + GameObjects.Creators.Quad = __webpack_require__(664); + + GameObjects.Light = __webpack_require__(247); + + __webpack_require__(246); + __webpack_require__(663); +} + +module.exports = GameObjects; + + +/***/ }), +/* 784 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Visibility Handler hidden event. + * + * The document in which the Game is embedded has entered a hidden state. + * + * @event Phaser.Boot.VisibilityHandler#hidden + */ + +/** + * Visibility Handler visible event. + * + * The document in which the Game is embedded has entered a visible state. + * + * @event Phaser.Boot.VisibilityHandler#visible + */ + +/** + * Visibility Handler blur event. + * + * The window in which the Game is embedded has entered a blurred state. + * + * @event Phaser.Boot.VisibilityHandler#blur + */ + +/** + * Visibility Handler focus event. + * + * The window in which the Game is embedded has entered a focused state. + * + * @event Phaser.Boot.VisibilityHandler#focus + */ + +/** + * The Visibility Handler is responsible for listening out for document level visibility change events. + * This includes `visibilitychange` if the browser supports it, and blur and focus events. It then uses + * the provided Event Emitter and fires the related events. + * + * @function Phaser.Boot.VisibilityHandler + * @fires Phaser.Boot.VisibilityHandler#hidden + * @fires Phaser.Boot.VisibilityHandler#visible + * @fires Phaser.Boot.VisibilityHandler#blur + * @fires Phaser.Boot.VisibilityHandler#focus + * @since 3.0.0 + * + * @param {Phaser.Events.EventEmitter} eventEmitter - The EventEmitter that will emit the visibility events. + */ +var VisibilityHandler = function (eventEmitter) +{ + var hiddenVar; + + if (document.hidden !== undefined) + { + hiddenVar = 'visibilitychange'; + } + else + { + var vendors = [ 'webkit', 'moz', 'ms' ]; + + vendors.forEach(function (prefix) + { + if (document[prefix + 'Hidden'] !== undefined) + { + document.hidden = function () + { + return document[prefix + 'Hidden']; + }; + + hiddenVar = prefix + 'visibilitychange'; + } + + }); + } + + var onChange = function (event) + { + if (document.hidden || event.type === 'pause') + { + eventEmitter.emit('hidden'); + } + else + { + eventEmitter.emit('visible'); + } + }; + + if (hiddenVar) + { + document.addEventListener(hiddenVar, onChange, false); + } + + window.onblur = function () + { + eventEmitter.emit('blur'); + }; + + window.onfocus = function () + { + eventEmitter.emit('focus'); + }; +}; + +module.exports = VisibilityHandler; + + +/***/ }), +/* 785 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetValue = __webpack_require__(5); +var NOOP = __webpack_require__(3); +var RequestAnimationFrame = __webpack_require__(304); + +// Frame Rate config +// fps: { +// min: 10, +// target: 60, +// forceSetTimeOut: false, +// deltaHistory: 10, +// panicMax: 120 +// } + +// http://www.testufo.com/#test=animation-time-graph + +/** + * @callback TimeStepCallback + * + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} average - The Delta Average. + * @param {number} interpolation - Interpolation - how far between what is expected and where we are? + */ + +/** + * @classdesc + * [description] + * + * @class TimeStep + * @memberOf Phaser.Boot + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - A reference to the Phaser.Game instance that owns this Time Step. + * @param {FPSConfig} config + */ +var TimeStep = new Class({ + + initialize: + + function TimeStep (game, config) + { + /** + * A reference to the Phaser.Game instance. + * + * @property {Phaser.Game} game + * @readOnly + * @since 3.0.0 + */ + this.game = game; + + /** + * [description] + * + * @property {Phaser.DOM.RequestAnimationFrame} raf + * @readOnly + * @since 3.0.0 + */ + this.raf = new RequestAnimationFrame(); + + /** + * A flag that is set once the TimeStep has started running and toggled when it stops. + * + * @property {boolean} started + * @readOnly + * @default false + * @since 3.0.0 + */ + this.started = false; + + /** + * A flag that is set once the TimeStep has started running and toggled when it stops. + * The difference between this value and `started` is that `running` is toggled when + * the TimeStep is sent to sleep, where-as `started` remains `true`, only changing if + * the TimeStep is actually stopped, not just paused. + * + * @property {boolean} running + * @readOnly + * @default false + * @since 3.0.0 + */ + this.running = false; + + /** + * The minimum fps rate you want the Time Step to run at. + * + * @property {integer} minFps + * @default 5 + * @since 3.0.0 + */ + this.minFps = GetValue(config, 'min', 5); + + /** + * The target fps rate for the Time Step to run at. + * + * Setting this value will not actually change the speed at which the browser runs, that is beyond + * the control of Phaser. Instead, it allows you to determine performance issues and if the Time Step + * is spiraling out of control. + * + * @property {integer} targetFps + * @default 60 + * @since 3.0.0 + */ + this.targetFps = GetValue(config, 'target', 60); + + /** + * The minFps value in ms. + * Defaults to 200ms between frames (i.e. super slow!) + * + * @property {number} _min + * @private + * @since 3.0.0 + */ + this._min = 1000 / this.minFps; + + /** + * The targetFps value in ms. + * Defaults to 16.66ms between frames (i.e. normal) + * + * @property {number} _target + * @private + * @since 3.0.0 + */ + this._target = 1000 / this.targetFps; + + /** + * An exponential moving average of the frames per second. + * + * @property {integer} actualFps + * @readOnly + * @default 60 + * @since 3.0.0 + */ + this.actualFps = this.targetFps; + + /** + * [description] + * + * @property {integer} nextFpsUpdate + * @readOnly + * @default 0 + * @since 3.0.0 + */ + this.nextFpsUpdate = 0; + + /** + * The number of frames processed this second. + * + * @property {integer} framesThisSecond + * @readOnly + * @default 0 + * @since 3.0.0 + */ + this.framesThisSecond = 0; + + /** + * A callback to be invoked each time the Time Step steps. + * + * @property {TimeStepCallback} callback + * @default NOOP + * @since 3.0.0 + */ + this.callback = NOOP; + + /** + * You can force the Time Step to use Set Timeout instead of Request Animation Frame by setting + * the `forceSetTimeOut` property to `true` in the Game Configuration object. It cannot be changed at run-time. + * + * @property {boolean} forceSetTimeOut + * @readOnly + * @default false + * @since 3.0.0 + */ + this.forceSetTimeOut = GetValue(config, 'forceSetTimeOut', false); + + /** + * [description] + * + * @property {integer} time + * @default 0 + * @since 3.0.0 + */ + this.time = 0; + + /** + * [description] + * + * @property {integer} startTime + * @default 0 + * @since 3.0.0 + */ + this.startTime = 0; + + /** + * [description] + * + * @property {integer} lastTime + * @default 0 + * @since 3.0.0 + */ + this.lastTime = 0; + + /** + * [description] + * + * @property {integer} frame + * @readOnly + * @default 0 + * @since 3.0.0 + */ + this.frame = 0; + + /** + * [description] + * + * @property {boolean} inFocus + * @readOnly + * @default true + * @since 3.0.0 + */ + this.inFocus = true; + + /** + * [description] + * + * @property {integer} _pauseTime + * @private + * @default 0 + * @since 3.0.0 + */ + this._pauseTime = 0; + + /** + * [description] + * + * @property {integer} _coolDown + * @private + * @default 0 + * @since 3.0.0 + */ + this._coolDown = 0; + + /** + * [description] + * + * @property {integer} delta + * @default 0 + * @since 3.0.0 + */ + this.delta = 0; + + /** + * [description] + * + * @property {integer} deltaIndex + * @default 0 + * @since 3.0.0 + */ + this.deltaIndex = 0; + + /** + * [description] + * + * @property {array} deltaHistory + * @default 0 + * @since 3.0.0 + */ + this.deltaHistory = []; + + /** + * [description] + * + * @property {integer} deltaSmoothingMax + * @default 10 + * @since 3.0.0 + */ + this.deltaSmoothingMax = GetValue(config, 'deltaHistory', 10); + + /** + * [description] + * + * @property {integer} panicMax + * @default 120 + * @since 3.0.0 + */ + this.panicMax = GetValue(config, 'panicMax', 120); + + /** + * The actual elapsed time in ms between one update and the next. + * Unlike with `delta` no smoothing, capping, or averaging is applied to this value. + * So please be careful when using this value in calculations. + * + * @property {number} rawDelta + * @default 0 + * @since 3.0.0 + */ + this.rawDelta = 0; + }, + + /** + * Called when the DOM window.onBlur event triggers. + * + * @method Phaser.Boot.TimeStep#blur + * @since 3.0.0 + */ + blur: function () + { + this.inFocus = false; + }, + + /** + * Called when the DOM window.onFocus event triggers. + * + * @method Phaser.Boot.TimeStep#focus + * @since 3.0.0 + */ + focus: function () + { + this.inFocus = true; + + this.resetDelta(); + }, + + /** + * Called when the visibility API says the game is 'hidden' (tab switch out of view, etc) + * + * @method Phaser.Boot.TimeStep#pause + * @since 3.0.0 + */ + pause: function () + { + this._pauseTime = window.performance.now(); + }, + + /** + * Called when the visibility API says the game is 'visible' again (tab switch back into view, etc) + * + * @method Phaser.Boot.TimeStep#resume + * @since 3.0.0 + */ + resume: function () + { + this.resetDelta(); + + this.startTime += this.time - this._pauseTime; + }, + + /** + * [description] + * + * @method Phaser.Boot.TimeStep#resetDelta + * @since 3.0.0 + */ + resetDelta: function () + { + var now = window.performance.now(); + + this.time = now; + this.lastTime = now; + this.nextFpsUpdate = now + 1000; + this.framesThisSecond = 0; + this.frame = 0; + + // Pre-populate smoothing array + + for (var i = 0; i < this.deltaSmoothingMax; i++) + { + this.deltaHistory[i] = Math.min(this._target, this.deltaHistory[i]); + } + + this.delta = 0; + this.deltaIndex = 0; + + this._coolDown = this.panicMax; + }, + + /** + * Starts the Time Step running, if it is not already doing so. + * Called automatically by the Game Boot process. + * + * @method Phaser.Boot.TimeStep#start + * @since 3.0.0 + * + * @param {TimeStepCallback} callback - The callback to be invoked each time the Time Step steps. + */ + start: function (callback) + { + if (this.started) + { + return this; + } + + this.started = true; + this.running = true; + + for (var i = 0; i < this.deltaSmoothingMax; i++) + { + this.deltaHistory[i] = this._target; + } + + this.resetDelta(); + + this.startTime = window.performance.now(); + + this.callback = callback; + + this.raf.start(this.step.bind(this), this.forceSetTimeOut); + }, + + /** + * The main step method. This is called each time the browser updates, either by Request Animation Frame, + * or by Set Timeout. It is responsible for calculating the delta values, frame totals, cool down history and more. + * You generally should never call this method directly. + * + * @method Phaser.Boot.TimeStep#step + * @since 3.0.0 + * + * @param {integer} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + */ + step: function (time) + { + this.frame++; + + this.rawDelta = time - this.lastTime; + + var idx = this.deltaIndex; + var history = this.deltaHistory; + var max = this.deltaSmoothingMax; + + // delta time (time is in ms) + var dt = (time - this.lastTime); + + // When a browser switches tab, then comes back again, it takes around 10 frames before + // the delta time settles down so we employ a 'cooling down' period before we start + // trusting the delta values again, to avoid spikes flooding through our delta average + + if (this._coolDown > 0 || !this.inFocus) + { + this._coolDown--; + + dt = Math.min(dt, this._target); + } + + if (dt > this._min) + { + // Probably super bad start time or browser tab context loss, + // so use the last 'sane' dt value + + dt = history[idx]; + + // Clamp delta to min (in case history has become corrupted somehow) + dt = Math.min(dt, this._min); + } + + // Smooth out the delta over the previous X frames + + // add the delta to the smoothing array + history[idx] = dt; + + // adjusts the delta history array index based on the smoothing count + // this stops the array growing beyond the size of deltaSmoothingMax + this.deltaIndex++; + + if (this.deltaIndex > max) + { + this.deltaIndex = 0; + } + + // Delta Average + var avg = 0; + + // Loop the history array, adding the delta values together + + for (var i = 0; i < max; i++) + { + avg += history[i]; + } + + // Then divide by the array length to get the average delta + avg /= max; + + // Set as the world delta value + this.delta = avg; + + // Real-world timer advance + this.time += this.rawDelta; + + // Update the estimate of the frame rate, `fps`. Every second, the number + // of frames that occurred in that second are included in an exponential + // moving average of all frames per second, with an alpha of 0.25. This + // means that more recent seconds affect the estimated frame rate more than + // older seconds. + // + // When a browser window is NOT minimized, but is covered up (i.e. you're using + // another app which has spawned a window over the top of the browser), then it + // will start to throttle the raf callback time. It waits for a while, and then + // starts to drop the frame rate at 1 frame per second until it's down to just over 1fps. + // So if the game was running at 60fps, and the player opens a new window, then + // after 60 seconds (+ the 'buffer time') it'll be down to 1fps, so rafin'g at 1Hz. + // + // When they make the game visible again, the frame rate is increased at a rate of + // approx. 8fps, back up to 60fps (or the max it can obtain) + // + // There is no easy way to determine if this drop in frame rate is because the + // browser is throttling raf, or because the game is struggling with performance + // because you're asking it to do too much on the device. + + if (time > this.nextFpsUpdate) + { + // Compute the new exponential moving average with an alpha of 0.25. + this.actualFps = 0.25 * this.framesThisSecond + 0.75 * this.actualFps; + this.nextFpsUpdate = time + 1000; + this.framesThisSecond = 0; + } + + this.framesThisSecond++; + + // Interpolation - how far between what is expected and where we are? + var interpolation = avg / this._target; + + this.callback(time, avg, interpolation); + + // Shift time value over + this.lastTime = time; + }, + + /** + * Manually calls TimeStep.step, passing in the performance.now value to it. + * + * @method Phaser.Boot.TimeStep#tick + * @since 3.0.0 + */ + tick: function () + { + this.step(window.performance.now()); + }, + + /** + * Sends the TimeStep to sleep, stopping Request Animation Frame (or SetTimeout) and toggling the `running` flag to false. + * + * @method Phaser.Boot.TimeStep#sleep + * @since 3.0.0 + */ + sleep: function () + { + if (this.running) + { + this.raf.stop(); + + this.running = false; + } + }, + + /** + * Wakes-up the TimeStep, restarting Request Animation Frame (or SetTimeout) and toggling the `running` flag to true. + * The `seamless` argument controls if the wake-up should adjust the start time or not. + * + * @method Phaser.Boot.TimeStep#wake + * @since 3.0.0 + * + * @param {boolean} [seamless=false] - Adjust the startTime based on the lastTime values. + */ + wake: function (seamless) + { + if (this.running) + { + this.sleep(); + } + else if (seamless) + { + this.startTime += -this.lastTime + (this.lastTime = window.performance.now()); + } + + this.raf.start(this.step.bind(this), this.useRAF); + + this.running = true; + + this.step(window.performance.now()); + }, + + /** + * Stops the TimeStep running. + * + * @method Phaser.Boot.TimeStep#stop + * @since 3.0.0 + * + * @return {Phaser.Boot.TimeStep} The TimeStep object. + */ + stop: function () + { + this.running = false; + this.started = false; + + this.raf.stop(); + + return this; + }, + + /** + * Destroys the TimeStep. This will stop Request Animation Frame, stop the step, clear the callbacks and null + * any objects. + * + * @method Phaser.Boot.TimeStep#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.stop(); + + this.callback = NOOP; + + this.raf = null; + this.game = null; + } + +}); + +module.exports = TimeStep; + + +/***/ }), +/* 786 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var imageHeight = 0; + +/** + * @function addFrame + * @private + * @since 3.0.0 + */ +var addFrame = function (texture, sourceIndex, name, frame) +{ + // The frame values are the exact coordinates to cut the frame out of the atlas from + + var y = imageHeight - frame.y - frame.height; + + texture.add(name, sourceIndex, frame.x, y, frame.width, frame.height); + + // These are the original (non-trimmed) sprite values + /* + if (src.trimmed) + { + newFrame.setTrim( + src.sourceSize.w, + src.sourceSize.h, + src.spriteSourceSize.x, + src.spriteSourceSize.y, + src.spriteSourceSize.w, + src.spriteSourceSize.h + ); + } + */ +}; + +/** + * Parses a Unity YAML File and creates Frames in the Texture. + * For more details about Sprite Meta Data see https://docs.unity3d.com/ScriptReference/SpriteMetaData.html + * + * @function Phaser.Textures.Parsers.UnityYAML + * @memberOf Phaser.Textures.Parsers + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {integer} sourceIndex - The index of the TextureSource. + * @param {object} yaml - The YAML data. + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var UnityYAML = function (texture, sourceIndex, yaml) +{ + // Add in a __BASE entry (for the entire atlas) + var source = texture.source[sourceIndex]; + + texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); + + imageHeight = source.height; + + var data = yaml.split('\n'); + + var lineRegExp = /^[ ]*(- )*(\w+)+[: ]+(.*)/; + + var prevSprite = ''; + var currentSprite = ''; + var rect = { x: 0, y: 0, width: 0, height: 0 }; + + // var pivot = { x: 0, y: 0 }; + // var border = { x: 0, y: 0, z: 0, w: 0 }; + + for (var i = 0; i < data.length; i++) + { + var results = data[i].match(lineRegExp); + + if (!results) + { + continue; + } + + var isList = (results[1] === '- '); + var key = results[2]; + var value = results[3]; + + if (isList) + { + if (currentSprite !== prevSprite) + { + addFrame(texture, sourceIndex, currentSprite, rect); + + prevSprite = currentSprite; + } + + rect = { x: 0, y: 0, width: 0, height: 0 }; + } + + if (key === 'name') + { + // Start new list + currentSprite = value; + continue; + } + + switch (key) + { + case 'x': + case 'y': + case 'width': + case 'height': + rect[key] = parseInt(value, 10); + break; + + // case 'pivot': + // pivot = eval('var obj = ' + value); + // break; + + // case 'border': + // border = eval('var obj = ' + value); + // break; + } + } + + if (currentSprite !== prevSprite) + { + addFrame(texture, sourceIndex, currentSprite, rect); + } + + return texture; +}; + +module.exports = UnityYAML; + +/* +Example data: + +TextureImporter: + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + spriteSheet: + sprites: + - name: asteroids_0 + rect: + serializedVersion: 2 + x: 5 + y: 328 + width: 65 + height: 82 + alignment: 0 + pivot: {x: 0, y: 0} + border: {x: 0, y: 0, z: 0, w: 0} + - name: asteroids_1 + rect: + serializedVersion: 2 + x: 80 + y: 322 + width: 53 + height: 88 + alignment: 0 + pivot: {x: 0, y: 0} + border: {x: 0, y: 0, z: 0, w: 0} + spritePackingTag: Asteroids +*/ + + +/***/ }), +/* 787 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Parses a Starling XML object and adds all the Frames into a Texture. + * + * @function Phaser.Textures.Parsers.StarlingXML + * @memberOf Phaser.Textures.Parsers + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {*} xml - The XML data. + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var StarlingXML = function (texture, xml) +{ + // Malformed? + if (!xml.getElementsByTagName('TextureAtlas')) + { + // console.warn("Phaser.AnimationParser.XMLData: Invalid Texture Atlas XML given, missing tag"); + return; + } + + // Let's create some frames then + var data = new Phaser.FrameData(); + var frames = xml.getElementsByTagName('SubTexture'); + var newFrame; + + var name; + var frame; + var x; + var y; + var width; + var height; + var frameX; + var frameY; + var frameWidth; + var frameHeight; + + for (var i = 0; i < frames.length; i++) + { + frame = frames[i].attributes; + + name = frame.name.value; + x = parseInt(frame.x.value, 10); + y = parseInt(frame.y.value, 10); + width = parseInt(frame.width.value, 10); + height = parseInt(frame.height.value, 10); + + frameX = null; + frameY = null; + + if (frame.frameX) + { + frameX = Math.abs(parseInt(frame.frameX.value, 10)); + frameY = Math.abs(parseInt(frame.frameY.value, 10)); + frameWidth = parseInt(frame.frameWidth.value, 10); + frameHeight = parseInt(frame.frameHeight.value, 10); + } + + newFrame = data.addFrame(new Phaser.Frame(i, x, y, width, height, name)); + + // Trimmed? + if (frameX !== null || frameY !== null) + { + newFrame.setTrim(true, width, height, frameX, frameY, frameWidth, frameHeight); + } + } + + return data; + +}; + +module.exports = StarlingXML; + + +/***/ }), +/* 788 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(2); + +/** + * Parses a Sprite Sheet and adds the Frames to the Texture, where the Sprite Sheet is stored as a frame within an Atlas. + * + * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact + * same size and cannot be trimmed or rotated. + * + * @function Phaser.Textures.Parsers.SpriteSheetFromAtlas + * @memberOf Phaser.Textures.Parsers + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {Phaser.Textures.Frame} frame - The Frame that contains the Sprite Sheet. + * @param {object} config - [description] + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var SpriteSheetFromAtlas = function (texture, frame, config) +{ + var frameWidth = GetFastValue(config, 'frameWidth', null); + var frameHeight = GetFastValue(config, 'frameHeight', frameWidth); + + // If missing we can't proceed + if (!frameWidth) + { + throw new Error('TextureManager.SpriteSheetFromAtlas: Invalid frameWidth given.'); + } + + // Add in a __BASE entry (for the entire atlas) + // var source = texture.source[sourceIndex]; + // texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); + + var startFrame = GetFastValue(config, 'startFrame', 0); + var endFrame = GetFastValue(config, 'endFrame', -1); + var margin = GetFastValue(config, 'margin', 0); + var spacing = GetFastValue(config, 'spacing', 0); + + var x = frame.cutX; + var y = frame.cutY; + + var cutWidth = frame.cutWidth; + var cutHeight = frame.cutHeight; + var sheetWidth = frame.realWidth; + var sheetHeight = frame.realHeight; + + var row = Math.floor((sheetWidth - margin + spacing) / (frameWidth + spacing)); + var column = Math.floor((sheetHeight - margin + spacing) / (frameHeight + spacing)); + var total = row * column; + + // trim offsets + + var leftPad = frame.x; + var leftWidth = frameWidth - leftPad; + + var rightWidth = frameWidth - ((sheetWidth - cutWidth) - leftPad); + + var topPad = frame.y; + var topHeight = frameHeight - topPad; + + var bottomHeight = frameHeight - ((sheetHeight - cutHeight) - topPad); + + // console.log('x / y', x, y); + // console.log('cutW / H', cutWidth, cutHeight); + // console.log('sheetW / H', sheetWidth, sheetHeight); + // console.log('row', row, 'column', column, 'total', total); + // console.log('LW', leftWidth, 'RW', rightWidth, 'TH', topHeight, 'BH', bottomHeight); + + if (startFrame > total || startFrame < -total) + { + startFrame = 0; + } + + if (startFrame < 0) + { + // Allow negative skipframes. + startFrame = total + startFrame; + } + + if (endFrame !== -1) + { + total = startFrame + (endFrame + 1); + } + + var sheetFrame; + var frameX = margin; + var frameY = margin; + var frameIndex = 0; + var sourceIndex = frame.sourceIndex; + + for (var sheetY = 0; sheetY < column; sheetY++) + { + var topRow = (sheetY === 0); + var bottomRow = (sheetY === column - 1); + + for (var sheetX = 0; sheetX < row; sheetX++) + { + var leftRow = (sheetX === 0); + var rightRow = (sheetX === row - 1); + + sheetFrame = texture.add(frameIndex, sourceIndex, x + frameX, y + frameY, frameWidth, frameHeight); + + if (leftRow || topRow || rightRow || bottomRow) + { + var destX = (leftRow) ? leftPad : 0; + var destY = (topRow) ? topPad : 0; + var destWidth = frameWidth; + var destHeight = frameHeight; + + if (leftRow) + { + destWidth = leftWidth; + } + else if (rightRow) + { + destWidth = rightWidth; + } + + if (topRow) + { + destHeight = topHeight; + } + else if (bottomRow) + { + destHeight = bottomHeight; + } + + sheetFrame.cutWidth = destWidth; + sheetFrame.cutHeight = destHeight; + + sheetFrame.setTrim(frameWidth, frameHeight, destX, destY, destWidth, destHeight); + } + + frameX += spacing; + + if (leftRow) + { + frameX += leftWidth; + } + else if (rightRow) + { + frameX += rightRow; + } + else + { + frameX += frameWidth; + } + + frameIndex++; + } + + frameX = margin; + frameY += spacing; + + if (topRow) + { + frameY += topHeight; + } + else if (bottomRow) + { + frameY += bottomHeight; + } + else + { + frameY += frameHeight; + } + } + + return texture; +}; + +module.exports = SpriteSheetFromAtlas; + + +/***/ }), +/* 789 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(2); + +/** + * Parses a Sprite Sheet and adds the Frames to the Texture. + * + * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact + * same size and cannot be trimmed or rotated. + * + * @function Phaser.Textures.Parsers.SpriteSheet + * @memberOf Phaser.Textures.Parsers + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {integer} sourceIndex - The index of the TextureSource. + * @param {integer} x - [description] + * @param {integer} y - [description] + * @param {integer} width - [description] + * @param {integer} height - [description] + * @param {object} config - [description] + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var SpriteSheet = function (texture, sourceIndex, x, y, width, height, config) +{ + var frameWidth = GetFastValue(config, 'frameWidth', null); + var frameHeight = GetFastValue(config, 'frameHeight', frameWidth); + + // If missing we can't proceed + if (frameWidth === null) + { + throw new Error('TextureManager.SpriteSheet: Invalid frameWidth given.'); + } + + // Add in a __BASE entry (for the entire atlas) + var source = texture.source[sourceIndex]; + + texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); + + var startFrame = GetFastValue(config, 'startFrame', 0); + var endFrame = GetFastValue(config, 'endFrame', -1); + var margin = GetFastValue(config, 'margin', 0); + var spacing = GetFastValue(config, 'spacing', 0); + + var row = Math.floor((width - margin + spacing) / (frameWidth + spacing)); + var column = Math.floor((height - margin + spacing) / (frameHeight + spacing)); + var total = row * column; + + if (startFrame > total || startFrame < -total) + { + startFrame = 0; + } + + if (startFrame < 0) + { + // Allow negative skipframes. + startFrame = total + startFrame; + } + + if (endFrame !== -1) + { + total = startFrame + (endFrame + 1); + } + + var fx = margin; + var fy = margin; + var ax = 0; + var ay = 0; + + for (var i = 0; i < total; i++) + { + ax = 0; + ay = 0; + + var w = fx + frameWidth; + var h = fy + frameHeight; + + if (w > width) + { + ax = w - width; + } + + if (h > height) + { + ay = h - height; + } + + texture.add(i, sourceIndex, x + fx, y + fy, frameWidth - ax, frameHeight - ay); + + fx += frameWidth + spacing; + + if (fx + frameWidth > width) + { + fx = margin; + fy += frameHeight + spacing; + } + } + + return texture; +}; + +module.exports = SpriteSheet; + + +/***/ }), +/* 790 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Parses a Pyxel JSON object and adds the Frames to a Texture. + * + * @function Phaser.Textures.Parsers.Pyxel + * @memberOf Phaser.Textures.Parsers + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {object} json - The JSON data. + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var Pyxel = function (texture, json) +{ + // Malformed? There are a few keys to check here. + var signature = [ 'layers', 'tilewidth', 'tileheight', 'tileswide', 'tileshigh' ]; + + signature.forEach(function (key) + { + if (!json[key]) + { + // console.warn('Phaser.AnimationParser.JSONDataPyxel: Invalid Pyxel Tilemap JSON given, missing "' + key + '" key.'); + // console.log(json); + return; + } + }); + + // For this purpose, I only care about parsing tilemaps with a single layer. + if (json['layers'].length !== 1) + { + // console.warn('Phaser.AnimationParser.JSONDataPyxel: Too many layers, this parser only supports flat Tilemaps.'); + // console.log(json); + return; + } + + var data = new Phaser.FrameData(); + + var tileheight = json['tileheight']; + var tilewidth = json['tilewidth']; + + var frames = json['layers'][0]['tiles']; + var newFrame; + + for (var i = 0; i < frames.length; i++) + { + newFrame = data.addFrame(new Phaser.Frame( + i, + frames[i].x, + frames[i].y, + tilewidth, + tileheight, + 'frame_' + i // No names are included in pyxel tilemap data. + )); + + // No trim data is included. + newFrame.setTrim(false); + } + + return data; +}; + +module.exports = Pyxel; + + +/***/ }), +/* 791 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clone = __webpack_require__(55); + +/** + * Parses a Texture Atlas JSON Hash and adds the Frames to the Texture. + * JSON format expected to match that defined by Texture Packer, with the frames property containing an object of Frames. + * + * @function Phaser.Textures.Parsers.JSONHash + * @memberOf Phaser.Textures.Parsers + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {integer} sourceIndex - The index of the TextureSource. + * @param {object} json - The JSON data. + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var JSONHash = function (texture, sourceIndex, json) +{ + // Malformed? + if (!json['frames']) + { + console.warn('Invalid Texture Atlas JSON Hash given, missing \'frames\' Object'); + return; + } + + // Add in a __BASE entry (for the entire atlas) + var source = texture.source[sourceIndex]; + + texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); + + // By this stage frames is a fully parsed Object + var frames = json['frames']; + var newFrame; + + for (var key in frames) + { + var src = frames[key]; + + // The frame values are the exact coordinates to cut the frame out of the atlas from + newFrame = texture.add(key, sourceIndex, src.frame.x, src.frame.y, src.frame.w, src.frame.h); + + // These are the original (non-trimmed) sprite values + if (src.trimmed) + { + newFrame.setTrim( + src.sourceSize.w, + src.sourceSize.h, + src.spriteSourceSize.x, + src.spriteSourceSize.y, + src.spriteSourceSize.w, + src.spriteSourceSize.h + ); + } + + if (src.rotated) + { + newFrame.rotated = true; + newFrame.updateUVsInverted(); + } + + // Copy over any extra data + newFrame.customData = Clone(src); + } + + // Copy over any additional data that was in the JSON to Texture.customData + for (var dataKey in json) + { + if (dataKey === 'frames') + { + continue; + } + + if (Array.isArray(json[dataKey])) + { + texture.customData[dataKey] = json[dataKey].slice(0); + } + else + { + texture.customData[dataKey] = json[dataKey]; + } + } + + return texture; +}; + +module.exports = JSONHash; + + +/***/ }), +/* 792 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clone = __webpack_require__(55); + +/** + * Parses a Texture Atlas JSON Array and adds the Frames to the Texture. + * JSON format expected to match that defined by Texture Packer, with the frames property containing an array of Frames. + * + * @function Phaser.Textures.Parsers.JSONArray + * @memberOf Phaser.Textures.Parsers + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {integer} sourceIndex - The index of the TextureSource. + * @param {object} json - The JSON data. + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var JSONArray = function (texture, sourceIndex, json) +{ + // Malformed? + if (!json['frames'] && !json['textures']) + { + console.warn('Invalid Texture Atlas JSON Array given, missing \'frames\' and \'textures\' array'); + return; + } + + // Add in a __BASE entry (for the entire atlas) + var source = texture.source[sourceIndex]; + + texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); + + // By this stage frames is a fully parsed array + var frames = (Array.isArray(json.textures)) ? json.textures[sourceIndex].frames : json.frames; + + var newFrame; + + for (var i = 0; i < frames.length; i++) + { + var src = frames[i]; + + // The frame values are the exact coordinates to cut the frame out of the atlas from + newFrame = texture.add(src.filename, sourceIndex, src.frame.x, src.frame.y, src.frame.w, src.frame.h); + + // These are the original (non-trimmed) sprite values + if (src.trimmed) + { + newFrame.setTrim( + src.sourceSize.w, + src.sourceSize.h, + src.spriteSourceSize.x, + src.spriteSourceSize.y, + src.spriteSourceSize.w, + src.spriteSourceSize.h + ); + } + + if (src.rotated) + { + newFrame.rotated = true; + newFrame.updateUVsInverted(); + } + + if (src.anchor) + { + newFrame.customPivot = true; + newFrame.pivotX = src.anchor.x; + newFrame.pivotY = src.anchor.y; + } + + // Copy over any extra data + newFrame.customData = Clone(src); + } + + // Copy over any additional data that was in the JSON to Texture.customData + for (var dataKey in json) + { + if (dataKey === 'frames') + { + continue; + } + + if (Array.isArray(json[dataKey])) + { + texture.customData[dataKey] = json[dataKey].slice(0); + } + else + { + texture.customData[dataKey] = json[dataKey]; + } + } + + return texture; +}; + +module.exports = JSONArray; + + +/***/ }), +/* 793 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Adds an Image Element to a Texture. + * + * @function Phaser.Textures.Parsers.Image + * @memberOf Phaser.Textures.Parsers + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {integer} sourceIndex - The index of the TextureSource. + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var Image = function (texture, sourceIndex) +{ + var source = texture.source[sourceIndex]; + + texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); + + return texture; +}; + +module.exports = Image; + + +/***/ }), +/* 794 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Adds a Canvas Element to a Texture. + * + * @function Phaser.Textures.Parsers.Canvas + * @memberOf Phaser.Textures.Parsers + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {integer} sourceIndex - The index of the TextureSource. + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var Canvas = function (texture, sourceIndex) +{ + var source = texture.source[sourceIndex]; + + texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); + + return texture; +}; + +module.exports = Canvas; + + +/***/ }), +/* 795 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// These properties get injected into the Scene and map to local systems +// The map key is the property that is added to the Scene, the value is the Scene.Systems reference +// These defaults can be modified via the Scene config object + +var InjectionMap = { + + game: 'game', + + anims: 'anims', + cache: 'cache', + registry: 'registry', + sound: 'sound', + textures: 'textures', + + events: 'events', + cameras: 'cameras', + cameras3d: 'cameras3d', + add: 'add', + make: 'make', + scenePlugin: 'scene', + displayList: 'children', + lights: 'lights', + + data: 'data', + input: 'input', + load: 'load', + time: 'time', + tweens: 'tweens', + + arcadePhysics: 'physics', + impactPhysics: 'impact', + matterPhysics: 'matter' + +}; + +module.exports = InjectionMap; + + +/***/ }), +/* 796 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(2); + +/** + * Builds an array of which plugins (not including physics plugins) should be activated for the given Scene. + * + * @function Phaser.Scenes.GetScenePlugins + * @since 3.0.0 + * + * @param {Phaser.Scenes.Systems} sys - [description] + * + * @return {array} [description] + */ +var GetScenePlugins = function (sys) +{ + var defaultPlugins = sys.game.config.defaultPlugins; + var scenePlugins = GetFastValue(sys.settings, 'plugins', false); + + // Scene Plugins always override Default Plugins + if (Array.isArray(scenePlugins)) + { + return scenePlugins; + } + else if (defaultPlugins) + { + return defaultPlugins; + } + else + { + // No default plugins or plugins in this scene + return []; + } +}; + +module.exports = GetScenePlugins; + + +/***/ }), +/* 797 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(2); +var UppercaseFirst = __webpack_require__(285); + +/** + * Builds an array of which physics plugins should be activated for the given Scene. + * + * @function Phaser.Scenes.GetPhysicsPlugins + * @since 3.0.0 + * + * @param {Phaser.Scenes.Systems} sys - [description] + * + * @return {array} [description] + */ +var GetPhysicsPlugins = function (sys) +{ + var defaultSystem = sys.game.config.defaultPhysicsSystem; + var sceneSystems = GetFastValue(sys.settings, 'physics', false); + + if (!defaultSystem && !sceneSystems) + { + // No default physics system or systems in this scene + return; + } + + // Let's build the systems array + var output = []; + + if (defaultSystem) + { + output.push(UppercaseFirst(defaultSystem + 'Physics')); + } + + if (sceneSystems) + { + for (var key in sceneSystems) + { + key = UppercaseFirst(key.concat('Physics')); + + if (output.indexOf(key) === -1) + { + output.push(key); + } + } + } + + // An array of Physics systems to start for this Scene + return output; +}; + +module.exports = GetPhysicsPlugins; + + +/***/ }), +/* 798 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Used internally by the KeyboardManager. + * + * @function Phaser.Input.Keyboard.Keys.ProcessKeyUp + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.Key} key - [description] + * @param {KeyboardEvent} event - [description] + * + * @return {Phaser.Input.Keyboard.Key} [description] + */ +var ProcessKeyUp = function (key, event) +{ + key.originalEvent = event; + + if (key.preventDefault) + { + event.preventDefault(); + } + + if (!key.enabled) + { + return; + } + + key.isDown = false; + key.isUp = true; + key.timeUp = event.timeStamp; + key.duration = key.timeUp - key.timeDown; + key.repeats = 0; + + key._justDown = false; + key._justUp = true; + + return key; +}; + +module.exports = ProcessKeyUp; + + +/***/ }), +/* 799 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Used internally by the KeyboardManager. + * + * @function Phaser.Input.Keyboard.Keys.ProcessKeyDown + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.Key} key - [description] + * @param {KeyboardEvent} event - [description] + * + * @return {Phaser.Input.Keyboard.Key} [description] + */ +var ProcessKeyDown = function (key, event) +{ + key.originalEvent = event; + + if (key.preventDefault) + { + event.preventDefault(); + } + + if (!key.enabled) + { + return; + } + + key.altKey = event.altKey; + key.ctrlKey = event.ctrlKey; + key.shiftKey = event.shiftKey; + key.location = event.location; + + if (key.isDown === false) + { + key.isDown = true; + key.isUp = false; + key.timeDown = event.timeStamp; + key.duration = 0; + } + + key.repeats++; + + key._justDown = true; + key._justUp = false; + + return key; +}; + +module.exports = ProcessKeyDown; + + +/***/ }), +/* 800 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var KeyCodes = __webpack_require__(143); + +var KeyMap = {}; + +for (var key in KeyCodes) +{ + KeyMap[KeyCodes[key]] = key; +} + +module.exports = KeyMap; + + +/***/ }), +/* 801 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Used internally by the KeyCombo class. + * + * @function Phaser.Input.Keyboard.KeyCombo.ResetKeyCombo + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.KeyCombo} combo - The KeyCombo to reset. + * + * @return {Phaser.Input.Keyboard.KeyCombo} The KeyCombo. + */ +var ResetKeyCombo = function (combo) +{ + combo.current = combo.keyCodes[0]; + combo.index = 0; + combo.timeLastMatched = 0; + combo.matched = false; + combo.timeMatched = 0; + + return combo; +}; + +module.exports = ResetKeyCombo; + + +/***/ }), +/* 802 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Used internally by the KeyCombo class. + * Return `true` if it reached the end of the combo, `false` if not. + * + * @function Phaser.Input.Keyboard.KeyCombo.AdvanceKeyCombo + * @since 3.0.0 + * + * @param {KeyboardEvent} event - [description] + * @param {Phaser.Input.Keyboard.KeyCombo} combo - [description] + * + * @return {boolean} `true` if it reached the end of the combo, `false` if not. + */ +var AdvanceKeyCombo = function (event, combo) +{ + combo.timeLastMatched = event.timeStamp; + combo.index++; + + if (combo.index === combo.size) + { + return true; + } + else + { + combo.current = combo.keyCodes[combo.index]; + return false; + } +}; + +module.exports = AdvanceKeyCombo; + + +/***/ }), +/* 803 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var AdvanceKeyCombo = __webpack_require__(802); + +/** + * Used internally by the KeyCombo class. + * + * @function Phaser.Input.Keyboard.KeyCombo.ProcessKeyCombo + * @since 3.0.0 + * + * @param {KeyboardEvent} event - [description] + * @param {Phaser.Input.Keyboard.KeyCombo} combo - [description] + * + * @return {boolean} [description] + */ +var ProcessKeyCombo = function (event, combo) +{ + if (combo.matched) + { + return true; + } + + var comboMatched = false; + var keyMatched = false; + + if (event.keyCode === combo.current) + { + // Key was correct + + if (combo.index > 0 && combo.maxKeyDelay > 0) + { + // We have to check to see if the delay between + // the new key and the old one was too long (if enabled) + + var timeLimit = combo.timeLastMatched + combo.maxKeyDelay; + + // Check if they pressed it in time or not + if (event.timeStamp <= timeLimit) + { + keyMatched = true; + comboMatched = AdvanceKeyCombo(event, combo); + } + } + else + { + keyMatched = true; + + // We don't check the time for the first key pressed, so just advance it + comboMatched = AdvanceKeyCombo(event, combo); + } + } + + if (!keyMatched && combo.resetOnWrongKey) + { + // Wrong key was pressed + combo.index = 0; + combo.current = combo.keyCodes[0]; + } + + if (comboMatched) + { + combo.timeLastMatched = event.timeStamp; + combo.matched = true; + combo.timeMatched = event.timeStamp; + } + + return comboMatched; +}; + +module.exports = ProcessKeyCombo; + + +/***/ }), +/* 804 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Determines the full screen support of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.fullscreen` from within any Scene. + * + * @name Phaser.Device.Fullscreen + * @since 3.0.0 + * + * @type {object} + * @property {boolean} available - Does the browser support the Full Screen API? + * @property {boolean} keyboard - Does the browser support access to the Keyboard during Full Screen mode? + * @property {string} cancel - If the browser supports the Full Screen API this holds the call you need to use to cancel it. + * @property {string} request - If the browser supports the Full Screen API this holds the call you need to use to activate it. + */ +var Fullscreen = { + + available: false, + cancel: '', + keyboard: false, + request: '' + +}; + +/** +* Checks for support of the Full Screen API. +*/ +function init () +{ + var i; + + var fs = [ + 'requestFullscreen', + 'requestFullScreen', + 'webkitRequestFullscreen', + 'webkitRequestFullScreen', + 'msRequestFullscreen', + 'msRequestFullScreen', + 'mozRequestFullScreen', + 'mozRequestFullscreen' + ]; + + var element = document.createElement('div'); + + for (i = 0; i < fs.length; i++) + { + if (element[fs[i]]) + { + Fullscreen.available = true; + Fullscreen.request = fs[i]; + break; + } + } + + var cfs = [ + 'cancelFullScreen', + 'exitFullscreen', + 'webkitCancelFullScreen', + 'webkitExitFullscreen', + 'msCancelFullScreen', + 'msExitFullscreen', + 'mozCancelFullScreen', + 'mozExitFullscreen' + ]; + + if (Fullscreen.available) + { + for (i = 0; i < cfs.length; i++) + { + if (document[cfs[i]]) + { + Fullscreen.cancel = cfs[i]; + break; + } + } + } + + // Keyboard Input? + if (window['Element'] && Element['ALLOW_KEYBOARD_INPUT']) + { + Fullscreen.keyboard = true; + } + + return Fullscreen; +} + +module.exports = init(); + + +/***/ }), +/* 805 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Determines the video support of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.video` from within any Scene. + * + * @name Phaser.Device.Video + * @since 3.0.0 + * + * @type {object} + * @property {boolean} h264Video - Can this device play h264 mp4 video files? + * @property {boolean} hlsVideo - Can this device play hls video files? + * @property {boolean} mp4Video - Can this device play h264 mp4 video files? + * @property {boolean} oggVideo - Can this device play ogg video files? + * @property {boolean} vp9Video - Can this device play vp9 video files? + * @property {boolean} webmVideo - Can this device play webm video files? + */ +var Video = { + + h264Video: false, + hlsVideo: false, + mp4Video: false, + oggVideo: false, + vp9Video: false, + webmVideo: false + +}; + +function init () +{ + var videoElement = document.createElement('video'); + var result = !!videoElement.canPlayType; + + try + { + if (result) + { + if (videoElement.canPlayType('video/ogg; codecs="theora"').replace(/^no$/, '')) + { + Video.oggVideo = true; + } + + if (videoElement.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/, '')) + { + // Without QuickTime, this value will be `undefined`. github.com/Modernizr/Modernizr/issues/546 + Video.h264Video = true; + Video.mp4Video = true; + } + + if (videoElement.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/, '')) + { + Video.webmVideo = true; + } + + if (videoElement.canPlayType('video/webm; codecs="vp9"').replace(/^no$/, '')) + { + Video.vp9Video = true; + } + + if (videoElement.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(/^no$/, '')) + { + Video.hlsVideo = true; + } + } + } + catch (e) + { + // Nothing to do + } + + return Video; +} + +module.exports = init(); + + +/***/ }), +/* 806 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Browser = __webpack_require__(100); + +/** + * Determines the audio playback capabilities of the device running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.audio` from within any Scene. + * + * @name Phaser.Device.Audio + * @since 3.0.0 + * + * @type {object} + * @property {boolean} audioData - Can this device play HTML Audio tags? + * @property {boolean} dolby - Can this device play EC-3 Dolby Digital Plus files? + * @property {boolean} m4a - Can this device can play m4a files. + * @property {boolean} mp3 - Can this device play mp3 files? + * @property {boolean} ogg - Can this device play ogg files? + * @property {boolean} opus - Can this device play opus files? + * @property {boolean} wav - Can this device play wav files? + * @property {boolean} webAudio - Does this device have the Web Audio API? + * @property {boolean} webm - Can this device play webm files? + */ +var Audio = { + + audioData: false, + dolby: false, + m4a: false, + mp3: false, + ogg: false, + opus: false, + wav: false, + webAudio: false, + webm: false + +}; + +function init () +{ + Audio.audioData = !!(window['Audio']); + + Audio.webAudio = !!(window['AudioContext'] || window['webkitAudioContext']); + + var audioElement = document.createElement('audio'); + + var result = !!audioElement.canPlayType; + + try + { + if (result) + { + if (audioElement.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) + { + Audio.ogg = true; + } + + if (audioElement.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, '') || audioElement.canPlayType('audio/opus;').replace(/^no$/, '')) + { + Audio.opus = true; + } + + if (audioElement.canPlayType('audio/mpeg;').replace(/^no$/, '')) + { + Audio.mp3 = true; + } + + // Mimetypes accepted: + // developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements + // bit.ly/iphoneoscodecs + if (audioElement.canPlayType('audio/wav; codecs="1"').replace(/^no$/, '')) + { + Audio.wav = true; + } + + if (audioElement.canPlayType('audio/x-m4a;') || audioElement.canPlayType('audio/aac;').replace(/^no$/, '')) + { + Audio.m4a = true; + } + + if (audioElement.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, '')) + { + Audio.webm = true; + } + + if (audioElement.canPlayType('audio/mp4;codecs="ec-3"') !== '') + { + if (Browser.edge) + { + Audio.dolby = true; + } + else if (Browser.safari && Browser.safariVersion >= 9) + { + if ((/Mac OS X (\d+)_(\d+)/).test(navigator.userAgent)) + { + var major = parseInt(RegExp.$1, 10); + var minor = parseInt(RegExp.$2, 10); + + if ((major === 10 && minor >= 11) || major > 10) + { + Audio.dolby = true; + } + } + } + } + } + } + catch (e) + { + // Nothing to do here + } + + return Audio; +} + +module.exports = init(); + + +/***/ }), +/* 807 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var OS = __webpack_require__(76); +var Browser = __webpack_require__(100); + +/** + * Determines the input support of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.input` from within any Scene. + * + * @name Phaser.Device.Input + * @since 3.0.0 + * + * @type {object} + * @property {?string} wheelType - The newest type of Wheel/Scroll event supported: 'wheel', 'mousewheel', 'DOMMouseScroll' + * @property {boolean} gamepads - Is navigator.getGamepads available? + * @property {boolean} mspointer - Is mspointer available? + * @property {boolean} touch - Is touch available? + */ +var Input = { + + gamepads: false, + mspointer: false, + touch: false, + wheelEvent: null + +}; + +function init () +{ + if ('ontouchstart' in document.documentElement || (navigator.maxTouchPoints && navigator.maxTouchPoints >= 1)) + { + Input.touch = true; + } + + if (navigator.msPointerEnabled || navigator.pointerEnabled) + { + Input.mspointer = true; + } + + if (navigator.getGamepads) + { + Input.gamepads = true; + } + + if (!OS.cocoonJS) + { + // See https://developer.mozilla.org/en-US/docs/Web/Events/wheel + if ('onwheel' in window || (Browser.ie && 'WheelEvent' in window)) + { + // DOM3 Wheel Event: FF 17+, IE 9+, Chrome 31+, Safari 7+ + Input.wheelEvent = 'wheel'; + } + else if ('onmousewheel' in window) + { + // Non-FF legacy: IE 6-9, Chrome 1-31, Safari 5-7. + Input.wheelEvent = 'mousewheel'; + } + else if (Browser.firefox && 'MouseScrollEvent' in window) + { + // FF prior to 17. This should probably be scrubbed. + Input.wheelEvent = 'DOMMouseScroll'; + } + } + + return Input; +} + +module.exports = init(); + + +/***/ }), +/* 808 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// This singleton is instantiated as soon as Phaser loads, +// before a Phaser.Game instance has even been created. +// Which means all instances of Phaser Games can share it, +// without having to re-poll the device all over again + +/** + * @namespace Phaser.Device + * @since 3.0.0 + */ + +/** + * @typedef {object} Phaser.DeviceConf + * + * @property {Phaser.Device.OS} os - The OS Device functions. + * @property {Phaser.Device.Browser} browser - The Browser Device functions. + * @property {Phaser.Device.Features} features - The Features Device functions. + * @property {Phaser.Device.Input} input - The Input Device functions. + * @property {Phaser.Device.Audio} audio - The Audio Device functions. + * @property {Phaser.Device.Video} video - The Video Device functions. + * @property {Phaser.Device.Fullscreen} fullscreen - The Fullscreen Device functions. + * @property {Phaser.Device.CanvasFeatures} canvasFeatures - The Canvas Device functions. + */ + +module.exports = { + + os: __webpack_require__(76), + browser: __webpack_require__(100), + features: __webpack_require__(146), + input: __webpack_require__(807), + audio: __webpack_require__(806), + video: __webpack_require__(805), + fullscreen: __webpack_require__(804), + canvasFeatures: __webpack_require__(302) + +}; + + +/***/ }), +/* 809 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(21); + +/** + * Called automatically by Phaser.Game and responsible for creating the console.log debug header. + * + * You can customize or disable the header via the Game Config object. + * + * @function Phaser.Boot.DebugHeader + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Phaser.Game instance which will output this debug header. + */ +var DebugHeader = function (game) +{ + var config = game.config; + + if (config.hideBanner) + { + return; + } + + var renderType = 'WebGL'; + + if (config.renderType === CONST.CANVAS) + { + renderType = 'Canvas'; + } + else if (config.renderType === CONST.HEADLESS) + { + renderType = 'Headless'; + } + + var audioConfig = config.audio; + var deviceAudio = game.device.audio; + + var audioType; + + if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio)) + { + audioType = 'Web Audio'; + } + else if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) + { + audioType = 'No Audio'; + } + else + { + audioType = 'HTML5 Audio'; + } + + if (!game.device.browser.ie) + { + var c = ''; + var args = [ c ]; + + if (Array.isArray(config.bannerBackgroundColor)) + { + var lastColor; + + config.bannerBackgroundColor.forEach(function (color) + { + c = c.concat('%c '); + + args.push('background: ' + color); + + lastColor = color; + + }); + + // inject the text color + args[args.length - 1] = 'color: ' + config.bannerTextColor + '; background: ' + lastColor; + } + else + { + c = c.concat('%c '); + + args.push('color: ' + config.bannerTextColor + '; background: ' + config.bannerBackgroundColor); + } + + // URL link background color (always white) + args.push('background: #fff'); + + if (config.gameTitle) + { + c = c.concat(config.gameTitle); + + if (config.gameVersion) + { + c = c.concat(' v' + config.gameVersion); + } + + if (!config.hidePhaser) + { + c = c.concat(' / '); + } + } + + if (!config.hidePhaser) + { + c = c.concat('Phaser v' + CONST.VERSION + ' (' + renderType + ' | ' + audioType + ')'); + } + + c = c.concat(' %c ' + config.gameURL); + + // Inject the new string back into the args array + args[0] = c; + + console.log.apply(console, args); + } + else if (window['console']) + { + console.log('Phaser v' + CONST.VERSION + ' / https://phaser.io'); + } +}; + +module.exports = DebugHeader; + + +/***/ }), +/* 810 */ +/***/ (function(module, exports) { + +module.exports = "#define SHADER_NAME PHASER_TEXTURE_TINT_VS\r\n\r\nprecision mediump float;\r\n\r\nuniform mat4 uProjectionMatrix;\r\nuniform mat4 uViewMatrix;\r\nuniform mat4 uModelMatrix;\r\n\r\nattribute vec2 inPosition;\r\nattribute vec2 inTexCoord;\r\nattribute vec4 inTint;\r\n\r\nvarying vec2 outTexCoord;\r\nvarying vec4 outTint;\r\n\r\nvoid main () \r\n{\r\n gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);\r\n outTexCoord = inTexCoord;\r\n outTint = inTint;\r\n}\r\n\r\n" + +/***/ }), +/* 811 */ +/***/ (function(module, exports) { + +module.exports = "#define SHADER_NAME PHASER_TEXTURE_TINT_FS\r\n\r\nprecision mediump float;\r\n\r\nuniform sampler2D uMainSampler;\r\n\r\nvarying vec2 outTexCoord;\r\nvarying vec4 outTint;\r\n\r\nvoid main() \r\n{\r\n vec4 texel = texture2D(uMainSampler, outTexCoord);\r\n texel *= vec4(outTint.rgb * outTint.a, outTint.a);\r\n gl_FragColor = texel;\r\n}\r\n" + +/***/ }), +/* 812 */ +/***/ (function(module, exports) { + +module.exports = "#define SHADER_NAME PHASER_FORWARD_DIFFUSE_FS\r\n\r\nprecision mediump float;\r\n\r\nstruct Light\r\n{\r\n vec2 position;\r\n vec3 color;\r\n float intensity;\r\n float radius;\r\n};\r\n\r\nconst int kMaxLights = %LIGHT_COUNT%;\r\n\r\nuniform vec4 uCamera; /* x, y, rotation, zoom */\r\nuniform vec2 uResolution;\r\nuniform sampler2D uMainSampler;\r\nuniform sampler2D uNormSampler;\r\nuniform vec3 uAmbientLightColor;\r\nuniform Light uLights[kMaxLights];\r\n\r\nvarying vec2 outTexCoord;\r\nvarying vec4 outTint;\r\n\r\nvoid main()\r\n{\r\n vec3 finalColor = vec3(0.0, 0.0, 0.0);\r\n vec4 color = texture2D(uMainSampler, outTexCoord) * vec4(outTint.rgb * outTint.a, outTint.a);\r\n vec3 normalMap = texture2D(uNormSampler, outTexCoord).rgb;\r\n vec3 normal = normalize(vec3(normalMap * 2.0 - 1.0));\r\n vec2 res = vec2(min(uResolution.x, uResolution.y)) * uCamera.w;\r\n\r\n for (int index = 0; index < kMaxLights; ++index)\r\n {\r\n Light light = uLights[index];\r\n vec3 lightDir = vec3((light.position.xy / res) - (gl_FragCoord.xy / res), 0.1);\r\n vec3 lightNormal = normalize(lightDir);\r\n float distToSurf = length(lightDir) * uCamera.w;\r\n float diffuseFactor = max(dot(normal, lightNormal), 0.0);\r\n float radius = (light.radius / res.x * uCamera.w) * uCamera.w;\r\n float attenuation = clamp(1.0 - distToSurf * distToSurf / (radius * radius), 0.0, 1.0);\r\n vec3 diffuse = light.color * diffuseFactor;\r\n finalColor += (attenuation * diffuse) * light.intensity;\r\n }\r\n\r\n vec4 colorOutput = vec4(uAmbientLightColor + finalColor, 1.0);\r\n gl_FragColor = color * vec4(colorOutput.rgb * colorOutput.a, colorOutput.a);\r\n\r\n}\r\n" + +/***/ }), +/* 813 */ +/***/ (function(module, exports) { + +module.exports = "#define SHADER_NAME PHASER_FLAT_TINT_VS\r\n\r\nprecision mediump float;\r\n\r\nuniform mat4 uProjectionMatrix;\r\nuniform mat4 uViewMatrix;\r\nuniform mat4 uModelMatrix;\r\n\r\nattribute vec2 inPosition;\r\nattribute vec4 inTint;\r\n\r\nvarying vec4 outTint;\r\n\r\nvoid main () {\r\n gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);\r\n outTint = inTint;\r\n}\r\n" + +/***/ }), +/* 814 */ +/***/ (function(module, exports) { + +module.exports = "#define SHADER_NAME PHASER_FLAT_TINT_FS\r\n\r\nprecision mediump float;\r\n\r\nvarying vec4 outTint;\r\n\r\nvoid main() {\r\n gl_FragColor = vec4(outTint.rgb * outTint.a, outTint.a);\r\n}\r\n" + +/***/ }), +/* 815 */ +/***/ (function(module, exports) { + +module.exports = "#define SHADER_NAME PHASER_BITMAP_MASK_VS\r\n\r\nprecision mediump float;\r\n\r\nattribute vec2 inPosition;\r\n\r\nvoid main()\r\n{\r\n gl_Position = vec4(inPosition, 0.0, 1.0);\r\n}\r\n" + +/***/ }), +/* 816 */ +/***/ (function(module, exports) { + +module.exports = "#define SHADER_NAME PHASER_BITMAP_MASK_FS\r\n\r\nprecision mediump float;\r\n\r\nuniform vec2 uResolution;\r\nuniform sampler2D uMainSampler;\r\nuniform sampler2D uMaskSampler;\r\nuniform bool uInvertMaskAlpha;\r\n\r\nvoid main()\r\n{\r\n vec2 uv = gl_FragCoord.xy / uResolution;\r\n vec4 mainColor = texture2D(uMainSampler, uv);\r\n vec4 maskColor = texture2D(uMaskSampler, uv);\r\n float alpha = mainColor.a;\r\n\r\n if (!uInvertMaskAlpha)\r\n {\r\n alpha *= (maskColor.a);\r\n }\r\n else\r\n {\r\n alpha *= (1.0 - maskColor.a);\r\n }\r\n \r\n gl_FragColor = vec4(mainColor.rgb * alpha, alpha);\r\n}\r\n" + +/***/ }), +/* 817 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasInterpolation = __webpack_require__(313); +var CanvasPool = __webpack_require__(23); +var CONST = __webpack_require__(21); +var Features = __webpack_require__(146); + +/** + * Called automatically by Phaser.Game and responsible for creating the renderer it will use. + * + * Relies upon two webpack global flags to be defined: `WEBGL_RENDERER` and `CANVAS_RENDERER` during build time, but not at run-time. + * + * @function Phaser.Boot.CreateRenderer + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Phaser.Game instance on which the renderer will be set. + */ +var CreateRenderer = function (game) +{ + var config = game.config; + + // Game either requested Canvas, + // or requested AUTO or WEBGL but the browser doesn't support it, so fall back to Canvas + + if (config.renderType !== CONST.HEADLESS) + { + if (config.renderType === CONST.CANVAS || (config.renderType !== CONST.CANVAS && !Features.webGL)) + { + if (Features.canvas) + { + // They requested Canvas and their browser supports it + config.renderType = CONST.CANVAS; + } + else + { + throw new Error('Cannot create Canvas or WebGL context, aborting.'); + } + } + else + { + // Game requested WebGL and browser says it supports it + config.renderType = CONST.WEBGL; + } + } + + // Pixel Art mode? + if (config.pixelArt) + { + CanvasPool.disableSmoothing(); + } + + // Does the game config provide its own canvas element to use? + if (config.canvas) + { + game.canvas = config.canvas; + } + else + { + game.canvas = CanvasPool.create(game, config.width, config.height, config.renderType); + } + + // Does the game config provide some canvas css styles to use? + if (config.canvasStyle) + { + game.canvas.style = config.canvasStyle; + } + + // Pixel Art mode? + if (config.pixelArt) + { + CanvasInterpolation.setCrisp(game.canvas); + } + + // Zoomed? + if (config.zoom !== 1) + { + game.canvas.style.width = (config.width * config.zoom).toString() + 'px'; + game.canvas.style.height = (config.height * config.zoom).toString() + 'px'; + } + + if (config.renderType === CONST.HEADLESS) + { + // Nothing more to do here + return; + } + + var CanvasRenderer; + var WebGLRenderer; + + if (true) + { + CanvasRenderer = __webpack_require__(380); + WebGLRenderer = __webpack_require__(375); + + // Let the config pick the renderer type, both are included + if (config.renderType === CONST.WEBGL) + { + game.renderer = new WebGLRenderer(game); + game.context = null; + } + else + { + game.renderer = new CanvasRenderer(game); + game.context = game.renderer.gameContext; + } + } + + if (false) + {} + + if (false) + {} +}; + +module.exports = CreateRenderer; + + +/***/ }), +/* 818 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(21); +var GetValue = __webpack_require__(5); +var MATH = __webpack_require__(16); +var NOOP = __webpack_require__(3); +var Plugins = __webpack_require__(303); +var ValueToColor = __webpack_require__(156); + +/** + * This callback type is completely empty, a no-operation. + * + * @callback NOOP + */ + +/** + * @callback BootCallback + * + * @param {Phaser.Game} game - [description] + */ + +/** + * @typedef {object} FPSConfig + * + * @property {integer} [min=10] - [description] + * @property {integer} [target=60] - [description] + * @property {boolean} [forceSetTimeOut=false] - [description] + * @property {integer} [deltaHistory=10] - [description] + * @property {integer} [panicMax=120] - [description] + */ + +/** + * @typedef {object} LoaderConfig + * + * @property {string} [baseURL] - [description] + * @property {string} [path] - [description] + * @property {boolean} [enableParallel=true] - [description] + * @property {integer} [maxParallelDownloads=4] - [description] + * @property {(string|undefined)} [crossOrigin=undefined] - [description] + * @property {string} [responseType] - [description] + * @property {boolean} [async=true] - [description] + * @property {string} [user] - [description] + * @property {string} [password] - [description] + * @property {integer} [timeout=0] - [description] + */ + +/** + * @typedef {object} GameConfig + * + * @property {(integer|string)} [width=1024] - [description] + * @property {(integer|string)} [height=768] - [description] + * @property {number} [zoom=1] - [description] + * @property {number} [resolution=1] - [description] + * @property {number} [type=CONST.AUTO] - [description] + * @property {object} [?parent=null] - [description] + * @property {HTMLCanvasElement} [?canvas=null] - [description] + * @property {string} [?canvasStyle=null] - [description] + * @property {object} [?scene=null] - [description] + * @property {string[]} [seed] - [description] + * @property {string} [title=''] - [description] + * @property {string} [url='http://phaser.io'] - [description] + * @property {string} [version=''] - [description] + * @property {object} [input] - [description] + * @property {boolean} [input.keyboard=true] - [description] + * @property {object} [input.keyboard.target=window] - [description] + * @property {boolean} [input.mouse=true] - [description] + * @property {object} [?input.mouse.target=null] - [description] + * @property {boolean} [input.touch=true] - [description] + * @property {object} [?input.touch.target=null] - [description] + * @property {object} [?input.touch.capture=true] - [description] + * @property {boolean} [input.gamepad=false] - [description] + * @property {boolean} [disableContextMenu=false] - [description] + * @property {boolean} [banner=false] - [description] + * @property {boolean} [banner.hidePhaser=false] - [description] + * @property {string} [banner.text='#ffffff'] - [description] + * @property {string[]} [banner.background] - [description] + * @property {FPSConfig} [?fps] - [description] + * @property {boolean} [antialias=true] - [description] + * @property {boolean} [pixelArt=false] - [description] + * @property {boolean} [autoResize=false] - [description] + * @property {boolean} [roundPixels=false] - [description] + * @property {boolean} [transparent=false] - [description] + * @property {boolean} [clearBeforeRender=true] - [description] + * @property {boolean} [premultipliedAlpha=true] - [description] + * @property {boolean} [preserveDrawingBuffer=false] - [description] + * @property {boolean} [failIfMajorPerformanceCaveat=false] - [description] + * @property {boolean} [powerPreference='default'] - "high-performance", "low-power" or "default" + * @property {(string|number)} [backgroundColor=0x000000] - [description] + * @property {object} [?callbacks] - [description] + * @property {BootCallback} [callbacks.preBoot=NOOP] - [description] + * @property {BootCallback} [callbacks.postBoot=NOOP] - [description] + * @property {LoaderConfig} [?loader] - [description] + * @property {object} [?images] - [description] + * @property {string} [images.default] - [description] + * @property {string} [images.missing] - [description] + */ + +/** + * @classdesc + * [description] + * + * @class Config + * @memberOf Phaser.Boot + * @constructor + * @since 3.0.0 + * + * @param {GameConfig} [GameConfig] - The configuration object for your Phaser Game instance. + * + */ +var Config = new Class({ + + initialize: + + function Config (config) + { + if (config === undefined) { config = {}; } + + var defaultBannerColor = [ + '#ff0000', + '#ffff00', + '#00ff00', + '#00ffff', + '#000000' + ]; + + var defaultBannerTextColor = '#ffffff'; + + this.width = GetValue(config, 'width', 1024); + this.height = GetValue(config, 'height', 768); + this.zoom = GetValue(config, 'zoom', 1); + + this.resolution = GetValue(config, 'resolution', 1); + + this.renderType = GetValue(config, 'type', CONST.AUTO); + + this.parent = GetValue(config, 'parent', null); + this.canvas = GetValue(config, 'canvas', null); + this.canvasStyle = GetValue(config, 'canvasStyle', null); + + this.sceneConfig = GetValue(config, 'scene', null); + + this.seed = GetValue(config, 'seed', [ (Date.now() * Math.random()).toString() ]); + + MATH.RND.init(this.seed); + + this.gameTitle = GetValue(config, 'title', ''); + this.gameURL = GetValue(config, 'url', 'https://phaser.io'); + this.gameVersion = GetValue(config, 'version', ''); + + // Input + this.inputKeyboard = GetValue(config, 'input.keyboard', true); + this.inputKeyboardEventTarget = GetValue(config, 'input.keyboard.target', window); + + this.inputMouse = GetValue(config, 'input.mouse', true); + this.inputMouseEventTarget = GetValue(config, 'input.mouse.target', null); + this.inputMouseCapture = GetValue(config, 'input.mouse.capture', true); + + this.inputTouch = GetValue(config, 'input.touch', true); + this.inputTouchEventTarget = GetValue(config, 'input.touch.target', null); + this.inputTouchCapture = GetValue(config, 'input.touch.capture', true); + + this.inputGamepad = GetValue(config, 'input.gamepad', false); + + this.disableContextMenu = GetValue(config, 'disableContextMenu', false); + + this.audio = GetValue(config, 'audio'); + + // If you do: { banner: false } it won't display any banner at all + this.hideBanner = (GetValue(config, 'banner', null) === false); + + this.hidePhaser = GetValue(config, 'banner.hidePhaser', false); + this.bannerTextColor = GetValue(config, 'banner.text', defaultBannerTextColor); + this.bannerBackgroundColor = GetValue(config, 'banner.background', defaultBannerColor); + + if (this.gameTitle === '' && this.hidePhaser) + { + this.hideBanner = true; + } + + // Frame Rate config + // fps: { + // min: 10, + // target: 60, + // forceSetTimeOut: false, + // deltaHistory: 10 + // } + + this.fps = GetValue(config, 'fps', null); + + // Renderer Settings + // These can either be in a `render` object within the Config, or specified on their own + + var renderConfig = GetValue(config, 'render', config); + + this.antialias = GetValue(renderConfig, 'antialias', true); + this.pixelArt = GetValue(renderConfig, 'pixelArt', false); + this.autoResize = GetValue(renderConfig, 'autoResize', false); + this.roundPixels = GetValue(renderConfig, 'roundPixels', false); + this.transparent = GetValue(renderConfig, 'transparent', false); + this.clearBeforeRender = GetValue(renderConfig, 'clearBeforeRender', true); + this.premultipliedAlpha = GetValue(renderConfig, 'premultipliedAlpha', true); + this.preserveDrawingBuffer = GetValue(renderConfig, 'preserveDrawingBuffer', false); + this.failIfMajorPerformanceCaveat = GetValue(renderConfig, 'failIfMajorPerformanceCaveat', false); + this.powerPreference = GetValue(renderConfig, 'powerPreference', 'default'); + + var bgc = GetValue(config, 'backgroundColor', 0); + + this.backgroundColor = ValueToColor(bgc); + + if (bgc === 0 && this.transparent) + { + this.backgroundColor.alpha = 0; + } + + // Callbacks + this.preBoot = GetValue(config, 'callbacks.preBoot', NOOP); + this.postBoot = GetValue(config, 'callbacks.postBoot', NOOP); + + // Physics + // physics: { + // system: 'impact', + // setBounds: true, + // gravity: 0, + // cellSize: 64 + // } + + this.physics = GetValue(config, 'physics', {}); + this.defaultPhysicsSystem = GetValue(this.physics, 'default', false); + + // Loader Defaults + this.loaderBaseURL = GetValue(config, 'loader.baseURL', ''); + this.loaderPath = GetValue(config, 'loader.path', ''); + this.loaderEnableParallel = GetValue(config, 'loader.enableParallel', true); + this.loaderMaxParallelDownloads = GetValue(config, 'loader.maxParallelDownloads', 4); + this.loaderCrossOrigin = GetValue(config, 'loader.crossOrigin', undefined); + this.loaderResponseType = GetValue(config, 'loader.responseType', ''); + this.loaderAsync = GetValue(config, 'loader.async', true); + this.loaderUser = GetValue(config, 'loader.user', ''); + this.loaderPassword = GetValue(config, 'loader.password', ''); + this.loaderTimeout = GetValue(config, 'loader.timeout', 0); + + // Scene Plugins + this.defaultPlugins = GetValue(config, 'plugins', Plugins.DefaultScene); + + // Default / Missing Images + var pngPrefix = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAg'; + + this.defaultImage = GetValue(config, 'images.default', pngPrefix + 'AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=='); + this.missingImage = GetValue(config, 'images.missing', pngPrefix + 'CAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg=='); + } + +}); + +module.exports = Config; + + +/***/ }), +/* 819 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var AddToDOM = __webpack_require__(147); +var AnimationManager = __webpack_require__(339); +var CacheManager = __webpack_require__(337); +var CanvasPool = __webpack_require__(23); +var Class = __webpack_require__(0); +var Config = __webpack_require__(818); +var CreateRenderer = __webpack_require__(817); +var DataManager = __webpack_require__(103); +var DebugHeader = __webpack_require__(809); +var Device = __webpack_require__(808); +var DOMContentLoaded = __webpack_require__(307); +var EventEmitter = __webpack_require__(15); +var InputManager = __webpack_require__(299); +var NOOP = __webpack_require__(3); +var PluginManager = __webpack_require__(12); +var SceneManager = __webpack_require__(287); +var SoundManagerCreator = __webpack_require__(283); +var TextureManager = __webpack_require__(276); +var TimeStep = __webpack_require__(785); +var VisibilityHandler = __webpack_require__(784); + +/** + * @callback GameStepCallback + */ + +/** + * @classdesc + * The Phaser.Game instance is the main controller for the entire Phaser game. It is responsible + * for handling the boot process, parsing the configuration values, creating the renderer, + * and setting-up all of the global Phaser systems, such as sound and input. + * Once that is complete it will start the Scene Manager and then begin the main game loop. + * + * You should generally avoid accessing any of the systems created by Game, and instead use those + * made available to you via the Phaser.Scene Systems class instead. + * + * @class Game + * @memberOf Phaser + * @constructor + * @since 3.0.0 + * + * @param {object} [GameConfig] - The configuration object for your Phaser Game instance. + */ +var Game = new Class({ + + initialize: + + function Game (config) + { + /** + * The parsed Game Configuration object. + * + * The values stored within this object are read-only and should not be changed at run-time. + * + * @name Phaser.Game#config + * @type {Phaser.Boot.Config} + * @readOnly + * @since 3.0.0 + */ + this.config = new Config(config); + + /** + * A reference to either the Canvas or WebGL Renderer that this Game is using. + * + * @name Phaser.Game#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.0.0 + */ + this.renderer = null; + + /** + * A reference to the HTML Canvas Element on which the renderer is drawing. + * + * @name Phaser.Game#canvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvas = null; + + /** + * A reference to the Canvas Rendering Context belonging to the Canvas Element this game is rendering to. + * + * @name Phaser.Game#context + * @type {CanvasRenderingContext2D} + * @since 3.0.0 + */ + this.context = null; + + /** + * A flag indicating when this Game instance has finished its boot process. + * + * @name Phaser.Game#isBooted + * @type {boolean} + * @readOnly + * @since 3.0.0 + */ + this.isBooted = false; + + /** + * A flag indicating if this Game is currently running its game step or not. + * + * @name Phaser.Game#isRunning + * @type {boolean} + * @readOnly + * @since 3.0.0 + */ + this.isRunning = false; + + /** + * An Event Emitter which is used to broadcast game-level events from the global systems. + * + * @name Phaser.Game#events + * @type {EventEmitter} + * @since 3.0.0 + */ + this.events = new EventEmitter(); + + /** + * An instance of the Animation Manager. + * + * The Animation Manager is a global system responsible for managing all animations used within your game. + * + * @name Phaser.Game#anims + * @type {Phaser.Animations.AnimationManager} + * @since 3.0.0 + */ + this.anims = new AnimationManager(this); + + /** + * An instance of the Texture Manager. + * + * The Texture Manager is a global system responsible for managing all textures being used by your game. + * + * @name Phaser.Game#textures + * @type {Phaser.Textures.TextureManager} + * @since 3.0.0 + */ + this.textures = new TextureManager(this); + + /** + * An instance of the Cache Manager. + * + * The Cache Manager is a global system responsible for caching, accessing and releasing external game assets. + * + * @name Phaser.Game#cache + * @type {Phaser.Cache.CacheManager} + * @since 3.0.0 + */ + this.cache = new CacheManager(this); + + /** + * [description] + * + * @name Phaser.Game#registry + * @type {Phaser.Data.DataManager} + * @since 3.0.0 + */ + this.registry = new DataManager(this); + + /** + * An instance of the Input Manager. + * + * The Input Manager is a global system responsible for the capture of browser-level input events. + * + * @name Phaser.Game#input + * @type {Phaser.Input.InputManager} + * @since 3.0.0 + */ + this.input = new InputManager(this, this.config); + + /** + * An instance of the Scene Manager. + * + * The Scene Manager is a global system responsible for creating, modifying and updating the Scenes in your game. + * + * @name Phaser.Game#scene + * @type {Phaser.Scenes.SceneManager} + * @since 3.0.0 + */ + this.scene = new SceneManager(this, this.config.sceneConfig); + + /** + * A reference to the Device inspector. + * + * Contains information about the device running this game, such as OS, browser vendor and feature support. + * Used by various systems to determine capabilities and code paths. + * + * @name Phaser.Game#device + * @type {Phaser.DeviceConf} + * @since 3.0.0 + */ + this.device = Device; + + /** + * An instance of the base Sound Manager. + * + * The Sound Manager is a global system responsible for the playback and updating of all audio in your game. + * + * @name Phaser.Game#sound + * @type {Phaser.BaseSoundManager} + * @since 3.0.0 + */ + this.sound = SoundManagerCreator.create(this); + + /** + * An instance of the Time Step. + * + * The Time Step is a global system responsible for setting-up and responding to the browser frame events, processing + * them and calculating delta values. It then automatically calls the game step. + * + * @name Phaser.Game#loop + * @type {Phaser.Boot.TimeStep} + * @since 3.0.0 + */ + this.loop = new TimeStep(this, this.config.fps); + + /** + * An instance of the Plugin Manager. + * + * The Plugin Manager is a global system that allows plugins to register themselves with it, and can then install + * those plugins into Scenes as required. + * + * @name Phaser.Game#plugins + * @type {Phaser.Boot.PluginManager} + * @since 3.0.0 + */ + this.plugins = new PluginManager(this, this.config); + + /** + * The `onStepCallback` is a callback that is fired each time the Time Step ticks. + * It is set automatically when the Game boot process has completed. + * + * @name Phaser.Game#onStepCallback + * @type {GameStepCallback} + * @private + * @since 3.0.0 + */ + this.onStepCallback = NOOP; + + // Wait for the DOM Ready event, then call boot. + DOMContentLoaded(this.boot.bind(this)); + }, + + /** + * Game boot event. + * + * This is an internal event dispatched when the game has finished booting, but before it is ready to start running. + * The global systems use this event to know when to set themselves up, dispatching their own `ready` events as required. + * + * @event Phaser.Game#boot + */ + + /** + * This method is called automatically when the DOM is ready. It is responsible for creating the renderer, + * displaying the Debug Header, adding the game canvas to the DOM and emitting the 'boot' event. + * It listens for a 'ready' event from the base systems and once received it will call `Game.start`. + * + * @method Phaser.Game#boot + * @protected + * @fires Phaser.Game#boot + * @since 3.0.0 + */ + boot: function () + { + this.isBooted = true; + + this.config.preBoot(this); + + CreateRenderer(this); + + DebugHeader(this); + + AddToDOM(this.canvas, this.config.parent); + + this.events.emit('boot'); + + // The Texture Manager has to wait on a couple of non-blocking events before it's fully ready, so it will emit this event + this.events.once('ready', this.start, this); + }, + + /** + * Called automatically by Game.boot once all of the global systems have finished setting themselves up. + * By this point the Game is now ready to start the main loop running. + * It will also enable the Visibility Handler. + * + * @method Phaser.Game#start + * @protected + * @since 3.0.0 + */ + start: function () + { + this.isRunning = true; + + this.config.postBoot(this); + + if (this.renderer) + { + this.loop.start(this.step.bind(this)); + } + else + { + this.loop.start(this.headlessStep.bind(this)); + } + + VisibilityHandler(this.events); + + this.events.on('hidden', this.onHidden, this); + this.events.on('visible', this.onVisible, this); + this.events.on('blur', this.onBlur, this); + this.events.on('focus', this.onFocus, this); + }, + + /** + * Game Pre-Render event. + * + * This event is dispatched immediately before any of the Scenes have started to render. + * The renderer will already have been initialized this frame, clearing itself and preparing to receive + * the Scenes for rendering, but it won't have actually drawn anything yet. + * + * @event Phaser.Game#prerenderEvent + * @param {(Phaser.Renderer.CanvasRenderer|Phaser.Renderer.WebGLRenderer)} renderer - A reference to the current renderer. + */ + + /** + * Game Post-Render event. + * + * This event is dispatched right at the end of the render process. + * Every Scene will have rendered and drawn to the canvas. + * + * @event Phaser.Game#postrenderEvent + * @param {(Phaser.Renderer.CanvasRenderer|Phaser.Renderer.WebGLRenderer)} renderer - A reference to the current renderer. + */ + + /** + * The main Game Step. Called automatically by the Time Step, once per browser frame (typically as a result of + * Request Animation Frame, or Set Timeout on very old browsers.) + * + * The step will update the global managers first, then proceed to update each Scene in turn, via the Scene Manager. + * + * It will then render each Scene in turn, via the Renderer. This process emits `prerender` and `postrender` events. + * + * @method Phaser.Game#step + * @fires Phaser.Game#prerenderEvent + * @fires Phaser.Game#postrenderEvent + * @since 3.0.0 + * + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + step: function (time, delta) + { + // Global Managers + + this.input.update(time, delta); + + this.sound.update(time, delta); + + // Scenes + + this.onStepCallback(); + + this.scene.update(time, delta); + + // Render + + var renderer = this.renderer; + + renderer.preRender(); + + this.events.emit('prerender', renderer); + + this.scene.render(renderer); + + renderer.postRender(); + + this.events.emit('postrender', renderer); + }, + + /** + * A special version of the Game Step for the HEADLESS renderer only. + * + * The main Game Step. Called automatically by the Time Step, once per browser frame (typically as a result of + * Request Animation Frame, or Set Timeout on very old browsers.) + * + * The step will update the global managers first, then proceed to update each Scene in turn, via the Scene Manager. + * + * This process emits `prerender` and `postrender` events, even though nothing actually displays. + * + * @method Phaser.Game#headlessStep + * @fires Phaser.Game#prerenderEvent + * @fires Phaser.Game#postrenderEvent + * @since 3.2.0 + * + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time elapsed since the last frame. + */ + headlessStep: function (time, delta) + { + // Global Managers + + this.input.update(time, delta); + + this.sound.update(time, delta); + + // Scenes + + this.onStepCallback(); + + this.scene.update(time, delta); + + // Render + + this.events.emit('prerender'); + + this.events.emit('postrender'); + }, + + /** + * Game Pause event. + * + * This event is dispatched when the game loop enters a paused state, usually as a result of the Visibility Handler. + * + * @event Phaser.Game#pauseEvent + */ + + /** + * Called automatically by the Visibility Handler. + * This will pause the main loop and then emit a pause event. + * + * @method Phaser.Game#onHidden + * @protected + * @fires Phaser.Game#pauseEvent + * @since 3.0.0 + */ + onHidden: function () + { + this.loop.pause(); + + this.events.emit('pause'); + }, + + /** + * Game Resume event. + * + * This event is dispatched when the game loop leaves a paused state and resumes running. + * + * @event Phaser.Game#resumeEvent + */ + + /** + * Called automatically by the Visibility Handler. + * This will resume the main loop and then emit a resume event. + * + * @method Phaser.Game#onVisible + * @protected + * @fires Phaser.Game#resumeEvent + * @since 3.0.0 + */ + onVisible: function () + { + this.loop.resume(); + + this.events.emit('resume'); + }, + + /** + * Called automatically by the Visibility Handler. + * This will set the main loop into a 'blurred' state, which pauses it. + * + * @method Phaser.Game#onBlur + * @protected + * @since 3.0.0 + */ + onBlur: function () + { + this.loop.blur(); + }, + + /** + * Called automatically by the Visibility Handler. + * This will set the main loop into a 'focused' state, which resumes it. + * + * @method Phaser.Game#onFocus + * @protected + * @since 3.0.0 + */ + onFocus: function () + { + this.loop.focus(); + }, + + /** + * Game Resize event. + * + * @event Phaser.Game#resizeEvent + * @param {number} width - The new width of the Game. + * @param {number} height - The new height of the Game. + */ + + /** + * Updates the Game Config with the new width and height values given. + * Then resizes the Renderer and Input Manager scale. + * + * @method Phaser.Game#resize + * @since 3.2.0 + * + * @param {number} width - The new width of the game. + * @param {number} height - The new height of the game. + */ + resize: function (width, height) + { + this.config.width = width; + this.config.height = height; + + this.renderer.resize(width, height); + + this.input.resize(); + + this.scene.resize(width, height); + + this.events.emit('resize', width, height); + }, + + /** + * Destroys this Phaser.Game instance, all global systems, all sub-systems and all Scenes. + * + * @method Phaser.Game#destroy + * @since 3.0.0 + */ + destroy: function (removeCanvas) + { + this.loop.destroy(); + + this.scene.destroy(); + + this.renderer.destroy(); + + this.events.emit('destroy'); + + this.events.removeAllListeners(); + + this.onStepCallback = null; + + if (removeCanvas) + { + CanvasPool.remove(this.canvas); + } + } + +}); + +module.exports = Game; + + +/***/ }), +/* 820 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var EE = __webpack_require__(15); +var PluginManager = __webpack_require__(12); + +/** + * @namespace Phaser.Events + */ + +/** + * @classdesc + * EventEmitter is a Scene Systems plugin compatible version of eventemitter3. + * + * @class EventEmitter + * @memberOf Phaser.Events + * @constructor + * @since 3.0.0 + */ +var EventEmitter = new Class({ + + Extends: EE, + + initialize: + + function EventEmitter () + { + EE.call(this); + }, + + /** + * Removes all listeners. + * + * @method Phaser.Events.EventEmitter#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.removeAllListeners(); + }, + + /** + * Removes all listeners. + * + * @method Phaser.Events.EventEmitter#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.removeAllListeners(); + } + +}); + +/** + * Return an array listing the events for which the emitter has registered listeners. + * + * @method Phaser.Events.EventEmitter#eventNames + * @since 3.0.0 + * + * @return {array} + */ + +/** + * Return the listeners registered for a given event. + * + * @method Phaser.Events.EventEmitter#listeners + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * + * @return {array} The registered listeners. + */ + +/** + * Return the number of listeners listening to a given event. + * + * @method Phaser.Events.EventEmitter#listenerCount + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * + * @return {number} The number of listeners. + */ + +/** + * Calls each of the listeners registered for a given event. + * + * @method Phaser.Events.EventEmitter#emit + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * + * @return {boolean} `true` if the event had listeners, else `false`. + */ + +/** + * Add a listener for a given event. + * + * @method Phaser.Events.EventEmitter#on + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} fn - The listener function. + * @param {*} [context=this] - The context to invoke the listener with. + * + * @return {Phaser.Events.EventEmitter} `this`. + */ + +/** + * Add a listener for a given event. + * + * @method Phaser.Events.EventEmitter#addListener + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} fn - The listener function. + * @param {*} [context=this] - The context to invoke the listener with. + * + * @return {Phaser.Events.EventEmitter} `this`. + */ + +/** + * Add a one-time listener for a given event. + * + * @method Phaser.Events.EventEmitter#once + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} fn - The listener function. + * @param {*} [context=this] - The context to invoke the listener with. + * + * @return {Phaser.Events.EventEmitter} `this`. + */ + +/** + * Remove the listeners of a given event. + * + * @method Phaser.Events.EventEmitter#removeListener + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} fn - Only remove the listeners that match this function. + * @param {*} context - Only remove the listeners that have this context. + * @param {boolean} once - Only remove one-time listeners. + * + * @return {Phaser.Events.EventEmitter} `this`. + */ + +/** + * Remove the listeners of a given event. + * + * @method Phaser.Events.EventEmitter#off + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} fn - Only remove the listeners that match this function. + * @param {*} context - Only remove the listeners that have this context. + * @param {boolean} once - Only remove one-time listeners. + * + * @return {Phaser.Events.EventEmitter} `this`. + */ + +/** + * Remove all listeners, or those of the specified event. + * + * @method Phaser.Events.EventEmitter#removeAllListeners + * @since 3.0.0 + * + * @param {(string|symbol)} [event] - The event name. + * + * @return {Phaser.Events.EventEmitter} `this`. + */ + +PluginManager.register('EventEmitter', EventEmitter, 'events'); + +module.exports = EventEmitter; + + +/***/ }), +/* 821 */ +/***/ (function(module, exports) { + +// shim for using process in browser +var process = module.exports = {}; + +// cached from whatever global is present so that test runners that stub it +// don't break things. But we need to wrap it in a try catch in case it is +// wrapped in strict mode code which doesn't define any globals. It's inside a +// function because try/catches deoptimize in certain engines. + +var cachedSetTimeout; +var cachedClearTimeout; + +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} + +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; +process.prependListener = noop; +process.prependOnceListener = noop; + +process.listeners = function (name) { return [] } + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + + +/***/ }), +/* 822 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.DOM + */ + +module.exports = { + + AddToDOM: __webpack_require__(147), + DOMContentLoaded: __webpack_require__(307), + ParseXML: __webpack_require__(306), + RemoveFromDOM: __webpack_require__(305), + RequestAnimationFrame: __webpack_require__(304) + +}; + + +/***/ }), +/* 823 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * [description] + * + * @class GeometryMask + * @memberOf Phaser.Display.Masks + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.GameObjects.Graphics} graphicsGeometry - [description] + */ +var GeometryMask = new Class({ + + initialize: + + function GeometryMask (scene, graphicsGeometry) + { + /** + * [description] + * + * @name Phaser.Display.Masks.GeometryMask#geometryMask + * @type {Phaser.GameObjects.Graphics} + * @since 3.0.0 + */ + this.geometryMask = graphicsGeometry; + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.GeometryMask#setShape + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphicsGeometry - [description] + */ + setShape: function (graphicsGeometry) + { + this.geometryMask = graphicsGeometry; + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.GeometryMask#preRenderWebGL + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + * @param {Phaser.GameObjects.GameObject} mask - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + preRenderWebGL: function (renderer, mask, camera) + { + var gl = renderer.gl; + var geometryMask = this.geometryMask; + + // Force flushing before drawing to stencil buffer + renderer.flush(); + + // Enable and setup GL state to write to stencil buffer + gl.enable(gl.STENCIL_TEST); + gl.clear(gl.STENCIL_BUFFER_BIT); + gl.colorMask(false, false, false, false); + gl.stencilFunc(gl.NOTEQUAL, 1, 1); + gl.stencilOp(gl.REPLACE, gl.REPLACE, gl.REPLACE); + + // Write stencil buffer + geometryMask.renderWebGL(renderer, geometryMask, 0.0, camera); + renderer.flush(); + + // Use stencil buffer to affect next rendering object + gl.colorMask(true, true, true, true); + gl.stencilFunc(gl.EQUAL, 1, 1); + gl.stencilOp(gl.INVERT, gl.INVERT, gl.INVERT); + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.GeometryMask#postRenderWebGL + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + */ + postRenderWebGL: function (renderer) + { + var gl = renderer.gl; + + // Force flush before disabling stencil test + renderer.flush(); + gl.disable(gl.STENCIL_TEST); + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.GeometryMask#preRenderCanvas + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + * @param {Phaser.GameObjects.GameObject} mask - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + preRenderCanvas: function (renderer, mask, camera) + { + var geometryMask = this.geometryMask; + + renderer.currentContext.save(); + + geometryMask.renderCanvas(renderer, geometryMask, 0.0, camera, null, true); + + renderer.currentContext.clip(); + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.GeometryMask#postRenderCanvas + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + */ + postRenderCanvas: function (renderer) + { + renderer.currentContext.restore(); + } + +}); + +module.exports = GeometryMask; + + +/***/ }), +/* 824 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * [description] + * + * @class BitmapMask + * @memberOf Phaser.Display.Masks + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.GameObjects.GameObject} renderable - A renderable Game Object that uses a texture, such as a Sprite. + */ +var BitmapMask = new Class({ + + initialize: + + function BitmapMask (scene, renderable) + { + var renderer = scene.sys.game.renderer; + + /** + * A renderable Game Object that uses a texture, such as a Sprite. + * + * @name Phaser.Display.Masks.BitmapMask#bitmapMask + * @type {Phaser.GameObjects.GameObject} + * @since 3.0.0 + */ + this.bitmapMask = renderable; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#maskTexture + * @type {WebGLTexture} + * @default null + * @since 3.0.0 + */ + this.maskTexture = null; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#mainTexture + * @type {WebGLTexture} + * @default null + * @since 3.0.0 + */ + this.mainTexture = null; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#dirty + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.dirty = true; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#mainFramebuffer + * @type {WebGLFramebuffer} + * @since 3.0.0 + */ + this.mainFramebuffer = null; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#maskFramebuffer + * @type {WebGLFramebuffer} + * @since 3.0.0 + */ + this.maskFramebuffer = null; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#invertAlpha + * @type {boolean} + * @since 3.1.2 + */ + this.invertAlpha = false; + + if (renderer && renderer.gl) + { + var width = renderer.width; + var height = renderer.height; + var pot = ((width & (width - 1)) === 0 && (height & (height - 1)) === 0); + var gl = renderer.gl; + var wrap = pot ? gl.REPEAT : gl.CLAMP_TO_EDGE; + var filter = gl.LINEAR; + + this.mainTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); + this.maskTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); + this.mainFramebuffer = renderer.createFramebuffer(width, height, this.mainTexture, false); + this.maskFramebuffer = renderer.createFramebuffer(width, height, this.maskTexture, false); + + renderer.onContextRestored(function (renderer) + { + var width = renderer.width; + var height = renderer.height; + var pot = ((width & (width - 1)) === 0 && (height & (height - 1)) === 0); + var gl = renderer.gl; + var wrap = pot ? gl.REPEAT : gl.CLAMP_TO_EDGE; + var filter = gl.LINEAR; + + this.mainTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); + this.maskTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); + this.mainFramebuffer = renderer.createFramebuffer(width, height, this.mainTexture, false); + this.maskFramebuffer = renderer.createFramebuffer(width, height, this.maskTexture, false); + + }, this); + } + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.BitmapMask#setBitmap + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} renderable - A renderable Game Object that uses a texture, such as a Sprite. + */ + setBitmap: function (renderable) + { + this.bitmapMask = renderable; + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.BitmapMask#preRenderWebGL + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + * @param {Phaser.GameObjects.GameObject} maskedObject - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to render to. + */ + preRenderWebGL: function (renderer, maskedObject, camera) + { + renderer.pipelines.BitmapMaskPipeline.beginMask(this, maskedObject, camera); + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.BitmapMask#postRenderWebGL + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + */ + postRenderWebGL: function (renderer) + { + renderer.pipelines.BitmapMaskPipeline.endMask(this); + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.BitmapMask#preRenderCanvas + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + * @param {Phaser.GameObjects.GameObject} mask - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to render to. + */ + preRenderCanvas: function () + { + // NOOP + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.BitmapMask#postRenderCanvas + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + */ + postRenderCanvas: function () + { + // NOOP + } + +}); + +module.exports = BitmapMask; + + +/***/ }), +/* 825 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Masks + */ + +module.exports = { + + BitmapMask: __webpack_require__(824), + GeometryMask: __webpack_require__(823) + +}; + + +/***/ }), +/* 826 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ComponentToHex = __webpack_require__(311); + +/** + * Converts the color values into an HTML compatible color string, prefixed with either `#` or `0x`. + * + * @function Phaser.Display.Color.RGBToString + * @since 3.0.0 + * + * @param {integer} r - The red color value. A number between 0 and 255. + * @param {integer} g - The green color value. A number between 0 and 255. + * @param {integer} b - The blue color value. A number between 0 and 255. + * @param {integer} [a=255] - The alpha value. A number between 0 and 255. + * @param {string} [prefix=#] - The prefix of the string. Either `#` or `0x`. + * + * @return {string} A string-based representation of the color values. + */ +var RGBToString = function (r, g, b, a, prefix) +{ + if (a === undefined) { a = 255; } + if (prefix === undefined) { prefix = '#'; } + + if (prefix === '#') + { + return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); + } + else + { + return '0x' + ComponentToHex(a) + ComponentToHex(r) + ComponentToHex(g) + ComponentToHex(b); + } +}; + +module.exports = RGBToString; + + +/***/ }), +/* 827 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} HSLColorObject + * + * @property {number} h - The hue color value. A number between 0 and 1 + * @property {number} s - The saturation color value. A number between 0 and 1 + * @property {number} l - The lightness color value. A number between 0 and 1 + */ + +/** + * Converts an RGB color value to HSV (hue, saturation and value). + * Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space. + * Assumes RGB values are contained in the set [0, 255] and returns h, s and v in the set [0, 1]. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * + * @function Phaser.Display.Color.RGBToHSV + * @since 3.0.0 + * + * @param {integer} r - The red color value. A number between 0 and 255. + * @param {integer} g - The green color value. A number between 0 and 255. + * @param {integer} b - The blue color value. A number between 0 and 255. + * + * @return {HSLColorObject} An object with the properties `h`, `s` and `v`. + */ +var RGBToHSV = function (r, g, b) +{ + r /= 255; + g /= 255; + b /= 255; + + var min = Math.min(r, g, b); + var max = Math.max(r, g, b); + var d = max - min; + + // achromatic by default + var h = 0; + var s = (max === 0) ? 0 : d / max; + var v = max; + + if (max !== min) + { + if (max === r) + { + h = (g - b) / d + ((g < b) ? 6 : 0); + } + else if (max === g) + { + h = (b - r) / d + 2; + } + else if (max === b) + { + h = (r - g) / d + 4; + } + + h /= 6; + } + + return { h: h, s: s, v: v }; +}; + +module.exports = RGBToHSV; + + +/***/ }), +/* 828 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Between = __webpack_require__(308); +var Color = __webpack_require__(41); + +/** + * Creates a new Color object where the r, g, and b values have been set to random values + * based on the given min max values. + * + * @function Phaser.Display.Color.RandomRGB + * @since 3.0.0 + * + * @param {integer} [min=0] - The minimum value to set the random range from (between 0 and 255) + * @param {integer} [max=255] - The maximum value to set the random range from (between 0 and 255) + * + * @return {Phaser.Display.Color} A Color object. + */ +var RandomRGB = function (min, max) +{ + if (min === undefined) { min = 0; } + if (max === undefined) { max = 255; } + + return new Color(Between(min, max), Between(min, max), Between(min, max)); +}; + +module.exports = RandomRGB; + + +/***/ }), +/* 829 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Linear = __webpack_require__(148); + +/** + * Interpolates color values + * + * @namespace Phaser.Display.Color.Interpolate + * @since 3.0.0 + */ + +/** + * Interpolates between the two given color ranges over the length supplied. + * + * @function Phaser.Display.Color.Interpolate.RGBWithRGB + * @since 3.0.0 + * + * @param {number} r1 - Red value. + * @param {number} g1 - Blue value. + * @param {number} b1 - Green value. + * @param {number} r2 - Red value. + * @param {number} g2 - Blue value. + * @param {number} b2 - Green value. + * @param {number} [length=100] - Distance to interpolate over. + * @param {number} [index=0] - Index to start from. + * + * @return {ColorObject} An object containing the interpolated color values. + */ +var RGBWithRGB = function (r1, g1, b1, r2, g2, b2, length, index) +{ + if (length === undefined) { length = 100; } + if (index === undefined) { index = 0; } + + var t = index / length; + + return { + r: Linear(r1, r2, t), + g: Linear(g1, g2, t), + b: Linear(b1, b2, t) + }; +}; + +/** + * Interpolates between the two given color objects over the length supplied. + * + * @function Phaser.Display.Color.Interpolate.ColorWithColor + * @since 3.0.0 + * + * @param {Phaser.Display.Color} color1 - The first Color object. + * @param {Phaser.Display.Color} color2 - The second Color object. + * @param {number} [length=100] - Distance to interpolate over. + * @param {number} [index=0] - Index to start from. + * + * @return {ColorObject} An object containing the interpolated color values. + */ +var ColorWithColor = function (color1, color2, length, index) +{ + if (length === undefined) { length = 100; } + if (index === undefined) { index = 0; } + + return RGBWithRGB(color1.r, color1.g, color1.b, color2.r, color2.g, color2.b, length, index); +}; + +/** + * Interpolates between the Color object and color values over the length supplied. + * + * @function Phaser.Display.Color.Interpolate.ColorWithRGB + * @since 3.0.0 + * + * @param {Phaser.Display.Color} color1 - The first Color object. + * @param {number} r - Red value. + * @param {number} g - Blue value. + * @param {number} b - Green value. + * @param {number} [length=100] - Distance to interpolate over. + * @param {number} [index=0] - Index to start from. + * + * @return {ColorObject} An object containing the interpolated color values. + */ +var ColorWithRGB = function (color, r, g, b, length, index) +{ + if (length === undefined) { length = 100; } + if (index === undefined) { index = 0; } + + return RGBWithRGB(color.r, color.g, color.b, r, g, b, length, index); +}; + +module.exports = { + + RGBWithRGB: RGBWithRGB, + ColorWithRGB: ColorWithRGB, + ColorWithColor: ColorWithColor + +}; + + +/***/ }), +/* 830 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var HSVToRGB = __webpack_require__(309); + +/** + * Get HSV color wheel values in an array which will be 360 elements in size. + * + * @function Phaser.Display.Color.HSVColorWheel + * @since 3.0.0 + * + * @param {number} [s=1] - The saturation, in the range 0 - 1. + * @param {number} [v=1] - The value, in the range 0 - 1. + * + * @return {array} An array containing 360 elements, where each contains a single numeric value corresponding to the color at that point in the HSV color wheel. + */ +var HSVColorWheel = function (s, v) +{ + if (s === undefined) { s = 1; } + if (v === undefined) { v = 1; } + + var colors = []; + + for (var c = 0; c <= 359; c++) + { + colors.push(HSVToRGB(c / 359, s, v)); + } + + return colors; +}; + +module.exports = HSVColorWheel; + + +/***/ }), +/* 831 */ +/***/ (function(module, exports) { + +module.exports = function(module) { + if (!module.webpackPolyfill) { + module.deprecate = function() {}; + module.paths = []; + // module.parent = undefined by default + if (!module.children) module.children = []; + Object.defineProperty(module, "loaded", { + enumerable: true, + get: function() { + return module.l; + } + }); + Object.defineProperty(module, "id", { + enumerable: true, + get: function() { + return module.i; + } + }); + module.webpackPolyfill = 1; + } + return module; +}; + + +/***/ }), +/* 832 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Color = __webpack_require__(41); +var HueToComponent = __webpack_require__(310); + +/** + * Converts HSL (hue, saturation and lightness) values to a Phaser Color object. + * + * @function Phaser.Display.Color.HSLToColor + * @since 3.0.0 + * + * @param {number} h - The hue value in the range 0 to 1. + * @param {number} s - The saturation value in the range 0 to 1. + * @param {number} l - The lightness value in the range 0 to 1. + * + * @return {Phaser.Display.Color} A Color object created from the results of the h, s and l values. + */ +var HSLToColor = function (h, s, l) +{ + // achromatic by default + var r = l; + var g = l; + var b = l; + + if (s !== 0) + { + var q = (l < 0.5) ? l * (1 + s) : l + s - l * s; + var p = 2 * l - q; + + r = HueToComponent(p, q, h + 1 / 3); + g = HueToComponent(p, q, h); + b = HueToComponent(p, q, h - 1 / 3); + } + + var color = new Color(); + + return color.setGLTo(r, g, b, 1); +}; + +module.exports = HSLToColor; + + +/***/ }), +/* 833 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts the given color value into an Object containing r,g,b and a properties. + * + * @function Phaser.Display.Color.ColorToRGBA + * @since 3.0.0 + * + * @param {number} color - A color value, optionally including the alpha value. + * + * @return {ColorObject} An object containing the parsed color values. + */ +var ColorToRGBA = function (color) +{ + var output = { + r: color >> 16 & 0xFF, + g: color >> 8 & 0xFF, + b: color & 0xFF, + a: 255 + }; + + if (color > 16777215) + { + output.a = color >>> 24; + } + + return output; +}; + +module.exports = ColorToRGBA; + + +/***/ }), +/* 834 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sets the user-select property on the canvas style. Can be used to disable default browser selection actions. + * + * @function Phaser.Display.Canvas.UserSelect + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The canvas element to have the style applied to. + * @param {string} [value='none'] - The touch callout value to set on the canvas. Set to `none` to disable touch callouts. + * + * @return {HTMLCanvasElement} The canvas element. + */ +var UserSelect = function (canvas, value) +{ + if (value === undefined) { value = 'none'; } + + var vendors = [ + '-webkit-', + '-khtml-', + '-moz-', + '-ms-', + '' + ]; + + vendors.forEach(function (vendor) + { + canvas.style[vendor + 'user-select'] = value; + }); + + canvas.style['-webkit-touch-callout'] = value; + canvas.style['-webkit-tap-highlight-color'] = 'rgba(0, 0, 0, 0)'; + + return canvas; +}; + +module.exports = UserSelect; + + +/***/ }), +/* 835 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions. + * + * @function Phaser.Display.Canvas.TouchAction + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The canvas element to have the style applied to. + * @param {string} [value='none'] - The touch action value to set on the canvas. Set to `none` to disable touch actions. + * + * @return {HTMLCanvasElement} The canvas element. + */ +var TouchAction = function (canvas, value) +{ + if (value === undefined) { value = 'none'; } + + canvas.style['msTouchAction'] = value; + canvas.style['ms-touch-action'] = value; + canvas.style['touch-action'] = value; + + return canvas; +}; + +module.exports = TouchAction; + + +/***/ }), +/* 836 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Canvas + */ + +module.exports = { + + Interpolation: __webpack_require__(313), + Pool: __webpack_require__(23), + Smoothing: __webpack_require__(151), + TouchAction: __webpack_require__(835), + UserSelect: __webpack_require__(834) + +}; + + +/***/ }), +/* 837 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the amount the Game Object is visually offset from its y coordinate. + * This is the same as `width * origin.y`. + * This value will only be > 0 if `origin.y` is not equal to zero. + * + * @function Phaser.Display.Bounds.GetOffsetY + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The vertical offset of the Game Object. + */ +var GetOffsetY = function (gameObject) +{ + return gameObject.height * gameObject.originY; +}; + +module.exports = GetOffsetY; + + +/***/ }), +/* 838 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the amount the Game Object is visually offset from its x coordinate. + * This is the same as `width * origin.x`. + * This value will only be > 0 if `origin.x` is not equal to zero. + * + * @function Phaser.Display.Bounds.GetOffsetX + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The horizontal offset of the Game Object. + */ +var GetOffsetX = function (gameObject) +{ + return gameObject.width * gameObject.originX; +}; + +module.exports = GetOffsetX; + + +/***/ }), +/* 839 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Bounds + */ + +module.exports = { + + CenterOn: __webpack_require__(361), + GetBottom: __webpack_require__(36), + GetCenterX: __webpack_require__(61), + GetCenterY: __webpack_require__(58), + GetLeft: __webpack_require__(34), + GetOffsetX: __webpack_require__(838), + GetOffsetY: __webpack_require__(837), + GetRight: __webpack_require__(32), + GetTop: __webpack_require__(30), + SetBottom: __webpack_require__(35), + SetCenterX: __webpack_require__(60), + SetCenterY: __webpack_require__(59), + SetLeft: __webpack_require__(33), + SetRight: __webpack_require__(31), + SetTop: __webpack_require__(29) + +}; + + +/***/ }), +/* 840 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetRight = __webpack_require__(32); +var GetTop = __webpack_require__(30); +var SetBottom = __webpack_require__(35); +var SetRight = __webpack_require__(31); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the top right position of the other. + * + * @function Phaser.Display.Align.To.TopRight + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopRight = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignTo) + offsetX); + SetBottom(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = TopRight; + + +/***/ }), +/* 841 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetLeft = __webpack_require__(34); +var GetTop = __webpack_require__(30); +var SetBottom = __webpack_require__(35); +var SetLeft = __webpack_require__(33); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the top left position of the other. + * + * @function Phaser.Display.Align.To.TopLeft + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopLeft = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignTo) - offsetX); + SetBottom(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = TopLeft; + + +/***/ }), +/* 842 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterX = __webpack_require__(61); +var GetTop = __webpack_require__(30); +var SetBottom = __webpack_require__(35); +var SetCenterX = __webpack_require__(60); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the top center position of the other. + * + * @function Phaser.Display.Align.To.TopCenter + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetCenterX(gameObject, GetCenterX(alignTo) + offsetX); + SetBottom(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = TopCenter; + + +/***/ }), +/* 843 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetRight = __webpack_require__(32); +var GetTop = __webpack_require__(30); +var SetLeft = __webpack_require__(33); +var SetTop = __webpack_require__(29); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the right top position of the other. + * + * @function Phaser.Display.Align.To.RightTop + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var RightTop = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetRight(alignTo) + offsetX); + SetTop(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = RightTop; + + +/***/ }), +/* 844 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterY = __webpack_require__(58); +var GetRight = __webpack_require__(32); +var SetCenterY = __webpack_require__(59); +var SetLeft = __webpack_require__(33); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the right center position of the other. + * + * @function Phaser.Display.Align.To.RightCenter + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var RightCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetRight(alignTo) + offsetX); + SetCenterY(gameObject, GetCenterY(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = RightCenter; + + +/***/ }), +/* 845 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(36); +var GetRight = __webpack_require__(32); +var SetBottom = __webpack_require__(35); +var SetLeft = __webpack_require__(33); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the right bottom position of the other. + * + * @function Phaser.Display.Align.To.RightBottom + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var RightBottom = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetRight(alignTo) + offsetX); + SetBottom(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = RightBottom; + + +/***/ }), +/* 846 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetLeft = __webpack_require__(34); +var GetTop = __webpack_require__(30); +var SetRight = __webpack_require__(31); +var SetTop = __webpack_require__(29); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the left top position of the other. + * + * @function Phaser.Display.Align.To.LeftTop + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var LeftTop = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetLeft(alignTo) - offsetX); + SetTop(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = LeftTop; + + +/***/ }), +/* 847 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterY = __webpack_require__(58); +var GetLeft = __webpack_require__(34); +var SetCenterY = __webpack_require__(59); +var SetRight = __webpack_require__(31); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the left center position of the other. + * + * @function Phaser.Display.Align.To.LeftCenter + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var LeftCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetLeft(alignTo) - offsetX); + SetCenterY(gameObject, GetCenterY(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = LeftCenter; + + +/***/ }), +/* 848 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(36); +var GetLeft = __webpack_require__(34); +var SetBottom = __webpack_require__(35); +var SetRight = __webpack_require__(31); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the left bottom position of the other. + * + * @function Phaser.Display.Align.To.LeftBottom + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var LeftBottom = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetLeft(alignTo) - offsetX); + SetBottom(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = LeftBottom; + + +/***/ }), +/* 849 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(36); +var GetRight = __webpack_require__(32); +var SetRight = __webpack_require__(31); +var SetTop = __webpack_require__(29); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the bottom right position of the other. + * + * @function Phaser.Display.Align.To.BottomRight + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomRight = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignTo) + offsetX); + SetTop(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = BottomRight; + + +/***/ }), +/* 850 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(36); +var GetLeft = __webpack_require__(34); +var SetLeft = __webpack_require__(33); +var SetTop = __webpack_require__(29); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the bottom left position of the other. + * + * @function Phaser.Display.Align.To.BottomLeft + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomLeft = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignTo) - offsetX); + SetTop(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = BottomLeft; + + +/***/ }), +/* 851 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(36); +var GetCenterX = __webpack_require__(61); +var SetCenterX = __webpack_require__(60); +var SetTop = __webpack_require__(29); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the bottom center position of the other. + * + * @function Phaser.Display.Align.To.BottomCenter + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetCenterX(gameObject, GetCenterX(alignTo) + offsetX); + SetTop(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = BottomCenter; + + +/***/ }), +/* 852 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Align.To + */ + +module.exports = { + + BottomCenter: __webpack_require__(851), + BottomLeft: __webpack_require__(850), + BottomRight: __webpack_require__(849), + LeftBottom: __webpack_require__(848), + LeftCenter: __webpack_require__(847), + LeftTop: __webpack_require__(846), + RightBottom: __webpack_require__(845), + RightCenter: __webpack_require__(844), + RightTop: __webpack_require__(843), + TopCenter: __webpack_require__(842), + TopLeft: __webpack_require__(841), + TopRight: __webpack_require__(840) + +}; + + +/***/ }), +/* 853 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Align.In + */ + +module.exports = { + + BottomCenter: __webpack_require__(365), + BottomLeft: __webpack_require__(364), + BottomRight: __webpack_require__(363), + Center: __webpack_require__(362), + LeftCenter: __webpack_require__(360), + QuickSet: __webpack_require__(366), + RightCenter: __webpack_require__(359), + TopCenter: __webpack_require__(358), + TopLeft: __webpack_require__(357), + TopRight: __webpack_require__(356) + +}; + + +/***/ }), +/* 854 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(169); +var Extend = __webpack_require__(18); + +/** + * @namespace Phaser.Display.Align + */ + +var Align = { + + In: __webpack_require__(853), + To: __webpack_require__(852) + +}; + +// Merge in the consts +Align = Extend(false, Align, CONST); + +module.exports = Align; + + +/***/ }), +/* 855 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display + */ + +module.exports = { + + Align: __webpack_require__(854), + Bounds: __webpack_require__(839), + Canvas: __webpack_require__(836), + Color: __webpack_require__(312), + Masks: __webpack_require__(825) + +}; + + +/***/ }), +/* 856 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var DataManager = __webpack_require__(103); +var PluginManager = __webpack_require__(12); + +/** + * @classdesc + * The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin. + * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter, + * or have a property called `events` that is an instance of it. + * + * @class DataManagerPlugin + * @extends Phaser.Data.DataManager + * @memberOf Phaser.Data + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ +var DataManagerPlugin = new Class({ + + Extends: DataManager, + + initialize: + + function DataManagerPlugin (scene) + { + /** + * [description] + * + * @name Phaser.Data.DataManagerPlugin#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Data.DataManagerPlugin#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + if (!scene.sys.settings.isBooted) + { + scene.sys.events.once('boot', this.boot, this); + } + + DataManager.call(this, this.scene, scene.sys.events); + }, + + /** + * [description] + * + * @method Phaser.Data.DataManagerPlugin#boot + * @since 3.0.0 + */ + boot: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on('shutdown', this.shutdownPlugin, this); + eventEmitter.on('destroy', this.destroyPlugin, this); + }, + + /** + * [description] + * + * @method Phaser.Data.DataManagerPlugin#shutdownPlugin + * @since 3.0.0 + */ + shutdownPlugin: function () + { + // Should we reset the events? + }, + + /** + * [description] + * + * @method Phaser.Data.DataManagerPlugin#destroyPlugin + * @since 3.0.0 + */ + destroyPlugin: function () + { + this.destroy(); + + this.scene = undefined; + this.systems = undefined; + } + +}); + +PluginManager.register('DataManagerPlugin', DataManagerPlugin, 'data'); + +module.exports = DataManagerPlugin; + + +/***/ }), +/* 857 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Data + */ + +module.exports = { + + DataManager: __webpack_require__(103), + DataManagerPlugin: __webpack_require__(856) + +}; + + +/***/ }), +/* 858 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Vector2 = __webpack_require__(6); + +/** + * @classdesc + * [description] + * + * @class MoveTo + * @memberOf Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {number} [x] - [description] + * @param {number} [y] - [description] + */ +var MoveTo = new Class({ + + initialize: + + function MoveTo (x, y) + { + // Skip length calcs in paths + + /** + * [description] + * + * @name Phaser.Curves.MoveTo#active + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.active = false; + + /** + * [description] + * + * @name Phaser.Curves.MoveTo#p0 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p0 = new Vector2(x, y); + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.MoveTo#getPoint + * @since 3.0.0 + * + * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.p0); + }, + + /** + * [description] + * + * @method Phaser.Curves.MoveTo#getPointAt + * @since 3.0.0 + * + * @param {float} u - [description] + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + getPointAt: function (u, out) + { + return this.getPoint(u, out); + }, + + /** + * Gets the resolution of this curve. + * + * @method Phaser.Curves.MoveTo#getResolution + * @since 3.0.0 + * + * @return {number} The resolution of this curve. For a MoveTo the value is always 1. + */ + getResolution: function () + { + return 1; + }, + + /** + * Gets the length of this curve. + * + * @method Phaser.Curves.MoveTo#getLength + * @since 3.0.0 + * + * @return {number} The length of this curve. For a MoveTo the value is always 0. + */ + getLength: function () + { + return 0; + }, + + /** + * [description] + * + * @method Phaser.Curves.MoveTo#toJSON + * @since 3.0.0 + * + * @return {JSONCurve} [description] + */ + toJSON: function () + { + return { + type: 'MoveTo', + points: [ + this.p0.x, this.p0.y + ] + }; + } + +}); + +module.exports = MoveTo; + + +/***/ }), +/* 859 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var Class = __webpack_require__(0); +var CubicBezierCurve = __webpack_require__(321); +var EllipseCurve = __webpack_require__(319); +var GameObjectFactory = __webpack_require__(9); +var LineCurve = __webpack_require__(317); +var MovePathTo = __webpack_require__(858); +var QuadraticBezierCurve = __webpack_require__(316); +var Rectangle = __webpack_require__(10); +var SplineCurve = __webpack_require__(314); +var Vector2 = __webpack_require__(6); + +/** + * @typedef {object} JSONPath + * + * @property {string} type - The of the curve. + * @property {number} x - [description] + * @property {number} y - [description] + * @property {boolean} autoClose - The path is auto closed. + * @property {JSONCurve[]} curves - The list of the curves + */ + +/** + * @classdesc + * [description] + * + * @class Path + * @memberOf Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - [description] + * @param {number} [y=0] - [description] + */ +var Path = new Class({ + + initialize: + + function Path (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + /** + * [description] + * + * @name Phaser.Curves.Path#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * [description] + * + * @name Phaser.Curves.Path#curves + * @type {Phaser.Curves.Curve[]} + * @default [] + * @since 3.0.0 + */ + this.curves = []; + + /** + * [description] + * + * @name Phaser.Curves.Path#cacheLengths + * @type {number[]} + * @default [] + * @since 3.0.0 + */ + this.cacheLengths = []; + + /** + * Automatically closes the path. + * + * @name Phaser.Curves.Path#autoClose + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.autoClose = false; + + /** + * [description] + * + * @name {Phaser.Curves.Path#startPoint + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.startPoint = new Vector2(); + + /** + * [description] + * + * @name {Phaser.Curves.Path#_tmpVec2A + * @type {Phaser.Math.Vector2} + * @private + * @since 3.0.0 + */ + this._tmpVec2A = new Vector2(); + + /** + * [description] + * + * @name {Phaser.Curves.Path#_tmpVec2B + * @type {Phaser.Math.Vector2} + * @private + * @since 3.0.0 + */ + this._tmpVec2B = new Vector2(); + + if (typeof x === 'object') + { + this.fromJSON(x); + } + else + { + this.startPoint.set(x, y); + } + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#add + * @since 3.0.0 + * + * @param {Phaser.Curves.Curve} curve - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + add: function (curve) + { + this.curves.push(curve); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#circleTo + * @since 3.0.0 + * + * @param {number} radius - [description] + * @param {boolean} [clockwise=false] - [description] + * @param {number} [rotation=0] - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + circleTo: function (radius, clockwise, rotation) + { + if (clockwise === undefined) { clockwise = false; } + + return this.ellipseTo(radius, radius, 0, 360, clockwise, rotation); + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#closePath + * @since 3.0.0 + * + * @return {Phaser.Curves.Path} [description] + */ + closePath: function () + { + // Add a line curve if start and end of lines are not connected + var startPoint = this.curves[0].getPoint(0); + var endPoint = this.curves[this.curves.length - 1].getPoint(1); + + if (!startPoint.equals(endPoint)) + { + // This will copy a reference to the vectors, which probably isn't sensible + this.curves.push(new LineCurve(endPoint, startPoint)); + } + + return this; + }, + + // Creates a cubic bezier curve starting at the previous end point and ending at p3, using p1 and p2 as control points + + /** + * [description] + * + * @method Phaser.Curves.Path#cubicBezierTo + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {Phaser.Math.Vector2} control1X - [description] + * @param {Phaser.Math.Vector2} control1Y - [description] + * @param {Phaser.Math.Vector2} control2X - [description] + * @param {Phaser.Math.Vector2} control2Y - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + cubicBezierTo: function (x, y, control1X, control1Y, control2X, control2Y) + { + var p0 = this.getEndPoint(); + var p1; + var p2; + var p3; + + // Assume they're all vec2s + if (x instanceof Vector2) + { + p1 = x; + p2 = y; + p3 = control1X; + } + else + { + p1 = new Vector2(control1X, control1Y); + p2 = new Vector2(control2X, control2Y); + p3 = new Vector2(x, y); + } + + return this.add(new CubicBezierCurve(p0, p1, p2, p3)); + }, + + // Creates a quadratic bezier curve starting at the previous end point and ending at p2, using p1 as a control point + + /** + * [description] + * + * @method Phaser.Curves.Path#quadraticBezierTo + * @since 3.2.0 + * + * @param {(number|Phaser.Math.Vector2[])} x - [description] + * @param {number} [y] - [description] + * @param {number} [controlX] - [description] + * @param {number} [controlY] - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + quadraticBezierTo: function (x, y, controlX, controlY) + { + var p0 = this.getEndPoint(); + var p1; + var p2; + + // Assume they're all vec2s + if (x instanceof Vector2) + { + p1 = x; + p2 = y; + } + else + { + p1 = new Vector2(controlX, controlY); + p2 = new Vector2(x, y); + } + + return this.add(new QuadraticBezierCurve(p0, p1, p2)); + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#draw + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - [description] + * @param {integer} [pointsTotal=32] - [description] + * + * @return {Phaser.GameObjects.Graphics} [description] + */ + draw: function (graphics, pointsTotal) + { + for (var i = 0; i < this.curves.length; i++) + { + var curve = this.curves[i]; + + if (!curve.active) + { + continue; + } + + curve.draw(graphics, pointsTotal); + } + + return graphics; + }, + + /** + * Creates an ellipse curve positioned at the previous end point, using the given parameters. + * + * @method Phaser.Curves.Path#ellipseTo + * @since 3.0.0 + * + * @param {number} xRadius - [description] + * @param {number} yRadius - [description] + * @param {number} startAngle - [description] + * @param {number} endAngle - [description] + * @param {boolean} clockwise - [description] + * @param {number} rotation - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + ellipseTo: function (xRadius, yRadius, startAngle, endAngle, clockwise, rotation) + { + var ellipse = new EllipseCurve(0, 0, xRadius, yRadius, startAngle, endAngle, clockwise, rotation); + + var end = this.getEndPoint(this._tmpVec2A); + + // Calculate where to center the ellipse + var start = ellipse.getStartPoint(this._tmpVec2B); + + end.subtract(start); + + ellipse.x = end.x; + ellipse.y = end.y; + + return this.add(ellipse); + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#fromJSON + * @since 3.0.0 + * + * @param {object} data - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + fromJSON: function (data) + { + // data should be an object matching the Path.toJSON object structure. + + this.curves = []; + this.cacheLengths = []; + + this.startPoint.set(data.x, data.y); + + this.autoClose = data.autoClose; + + for (var i = 0; i < data.curves.length; i++) + { + var curve = data.curves[i]; + + switch (curve.type) + { + case 'LineCurve': + this.add(LineCurve.fromJSON(curve)); + break; + + case 'EllipseCurve': + this.add(EllipseCurve.fromJSON(curve)); + break; + + case 'SplineCurve': + this.add(SplineCurve.fromJSON(curve)); + break; + + case 'CubicBezierCurve': + this.add(CubicBezierCurve.fromJSON(curve)); + break; + + case 'QuadraticBezierCurve': + this.add(QuadraticBezierCurve.fromJSON(curve)); + break; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#getBounds + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} [out] - [description] + * @param {integer} [accuracy=16] - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ + getBounds: function (out, accuracy) + { + if (out === undefined) { out = new Rectangle(); } + if (accuracy === undefined) { accuracy = 16; } + + out.x = Number.MAX_VALUE; + out.y = Number.MAX_VALUE; + + var bounds = new Rectangle(); + var maxRight = Number.MIN_SAFE_INTEGER; + var maxBottom = Number.MIN_SAFE_INTEGER; + + for (var i = 0; i < this.curves.length; i++) + { + var curve = this.curves[i]; + + if (!curve.active) + { + continue; + } + + curve.getBounds(bounds, accuracy); + + out.x = Math.min(out.x, bounds.x); + out.y = Math.min(out.y, bounds.y); + + maxRight = Math.max(maxRight, bounds.right); + maxBottom = Math.max(maxBottom, bounds.bottom); + } + + out.right = maxRight; + out.bottom = maxBottom; + + return out; + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#getCurveLengths + * @since 3.0.0 + * + * @return {array} [description] + */ + getCurveLengths: function () + { + // We use cache values if curves and cache array are same length + + if (this.cacheLengths.length === this.curves.length) + { + return this.cacheLengths; + } + + // Get length of sub-curve + // Push sums into cached array + + var lengths = []; + var sums = 0; + + for (var i = 0; i < this.curves.length; i++) + { + sums += this.curves[i].getLength(); + + lengths.push(sums); + } + + this.cacheLengths = lengths; + + return lengths; + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#getEndPoint + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + getEndPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + if (this.curves.length > 0) + { + this.curves[this.curves.length - 1].getPoint(1, out); + } + else + { + out.copy(this.startPoint); + } + + return out; + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#getLength + * @since 3.0.0 + * + * @return {number} [description] + */ + getLength: function () + { + var lens = this.getCurveLengths(); + + return lens[lens.length - 1]; + }, + + // To get accurate point with reference to + // entire path distance at time t, + // following has to be done: + + // 1. Length of each sub path have to be known + // 2. Locate and identify type of curve + // 3. Get t for the curve + // 4. Return curve.getPointAt(t') + + /** + * [description] + * + * @method Phaser.Curves.Path#getPoint + * @since 3.0.0 + * + * @param {number} t - [description] + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {?Phaser.Math.Vector2} [description] + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var d = t * this.getLength(); + var curveLengths = this.getCurveLengths(); + var i = 0; + + while (i < curveLengths.length) + { + if (curveLengths[i] >= d) + { + var diff = curveLengths[i] - d; + var curve = this.curves[i]; + + var segmentLength = curve.getLength(); + var u = (segmentLength === 0) ? 0 : 1 - diff / segmentLength; + + return curve.getPointAt(u, out); + } + + i++; + } + + // loop where sum != 0, sum > d , sum+1 1 && !points[points.length - 1].equals(points[0])) + { + points.push(points[0]); + } + + return points; + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#getRandomPoint + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + getRandomPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return this.getPoint(Math.random(), out); + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#getSpacedPoints + * @since 3.0.0 + * + * @param {integer} [divisions=40] - [description] + * + * @return {Phaser.Math.Vector2[]} [description] + */ + getSpacedPoints: function (divisions) + { + if (divisions === undefined) { divisions = 40; } + + var points = []; + + for (var i = 0; i <= divisions; i++) + { + points.push(this.getPoint(i / divisions)); + } + + if (this.autoClose) + { + points.push(points[0]); + } + + return points; + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#getStartPoint + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.startPoint); + }, + + // Creates a line curve from the previous end point to x/y + + /** + * [description] + * + * @method Phaser.Curves.Path#lineTo + * @since 3.0.0 + * + * @param {(number|Phaser.Math.Vector2)} x - [description] + * @param {number} [y] - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + lineTo: function (x, y) + { + if (x instanceof Vector2) + { + this._tmpVec2B.copy(x); + } + else + { + this._tmpVec2B.set(x, y); + } + + var end = this.getEndPoint(this._tmpVec2A); + + return this.add(new LineCurve([ end.x, end.y, this._tmpVec2B.x, this._tmpVec2B.y ])); + }, + + // Creates a spline curve starting at the previous end point, using the given parameters + + /** + * [description] + * + * @method Phaser.Curves.Path#splineTo + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2[]} points - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + splineTo: function (points) + { + points.unshift(this.getEndPoint()); + + return this.add(new SplineCurve(points)); + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#moveTo + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + moveTo: function (x, y) + { + return this.add(new MovePathTo(x, y)); + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#toJSON + * @since 3.0.0 + * + * @return {JSONPath} [description] + */ + toJSON: function () + { + var out = []; + + for (var i = 0; i < this.curves.length; i++) + { + out.push(this.curves[i].toJSON()); + } + + return { + type: 'Path', + x: this.startPoint.x, + y: this.startPoint.y, + autoClose: this.autoClose, + curves: out + }; + }, + + // cacheLengths must be recalculated. + + /** + * [description] + * + * @method Phaser.Curves.Path#updateArcLengths + * @since 3.0.0 + */ + updateArcLengths: function () + { + this.cacheLengths = []; + + this.getCurveLengths(); + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.curves.length = 0; + this.cacheLengths.length = 0; + this.startPoint = undefined; + } + +}); + +/** + * Creates a new Path Object. + * + * @method Phaser.GameObjects.GameObjectFactory#path + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Path. + * @param {number} y - The vertical position of this Path. + * + * @return {Phaser.Curves.Path} The Path Object that was created. + */ +GameObjectFactory.register('path', function (x, y) +{ + return new Path(x, y); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +module.exports = Path; + + +/***/ }), +/* 860 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Curves + */ + +/** + * @typedef {object} JSONCurve + * + * @property {string} type - The of the curve + * @property {number[]} points - The arrays of points like `[x1, y1, x2, y2]` + */ + +module.exports = { + Path: __webpack_require__(859), + + CubicBezier: __webpack_require__(321), + Curve: __webpack_require__(56), + Ellipse: __webpack_require__(319), + Line: __webpack_require__(317), + QuadraticBezier: __webpack_require__(316), + Spline: __webpack_require__(314) +}; + + +/***/ }), +/* 861 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A 16 color palette inspired by Japanese computers like the MSX. + * + * @name Phaser.Create.Palettes.MSX + * @since 3.0.0 + * + * @type {Palette} + */ +module.exports = { + 0: '#000', + 1: '#191028', + 2: '#46af45', + 3: '#a1d685', + 4: '#453e78', + 5: '#7664fe', + 6: '#833129', + 7: '#9ec2e8', + 8: '#dc534b', + 9: '#e18d79', + A: '#d6b97b', + B: '#e9d8a1', + C: '#216c4b', + D: '#d365c8', + E: '#afaab9', + F: '#fff' +}; + + +/***/ }), +/* 862 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A 16 color JMP palette by [Arne](http://androidarts.com/palette/16pal.htm) + * + * @name Phaser.Create.Palettes.JMP + * @since 3.0.0 + * + * @type {Palette} + */ +module.exports = { + 0: '#000', + 1: '#191028', + 2: '#46af45', + 3: '#a1d685', + 4: '#453e78', + 5: '#7664fe', + 6: '#833129', + 7: '#9ec2e8', + 8: '#dc534b', + 9: '#e18d79', + A: '#d6b97b', + B: '#e9d8a1', + C: '#216c4b', + D: '#d365c8', + E: '#afaab9', + F: '#f5f4eb' +}; + + +/***/ }), +/* 863 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A 16 color CGA inspired palette by [Arne](http://androidarts.com/palette/16pal.htm) + * + * @name Phaser.Create.Palettes.CGA + * @since 3.0.0 + * + * @type {Palette} + */ +module.exports = { + 0: '#000', + 1: '#2234d1', + 2: '#0c7e45', + 3: '#44aacc', + 4: '#8a3622', + 5: '#5c2e78', + 6: '#aa5c3d', + 7: '#b5b5b5', + 8: '#5e606e', + 9: '#4c81fb', + A: '#6cd947', + B: '#7be2f9', + C: '#eb8a60', + D: '#e23d69', + E: '#ffd93f', + F: '#fff' +}; + + +/***/ }), +/* 864 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A 16 color palette inspired by the Commodore 64. + * + * @name Phaser.Create.Palettes.C64 + * @since 3.0.0 + * + * @type {Palette} + */ +module.exports = { + 0: '#000', + 1: '#fff', + 2: '#8b4131', + 3: '#7bbdc5', + 4: '#8b41ac', + 5: '#6aac41', + 6: '#3931a4', + 7: '#d5de73', + 8: '#945a20', + 9: '#5a4100', + A: '#bd736a', + B: '#525252', + C: '#838383', + D: '#acee8b', + E: '#7b73de', + F: '#acacac' +}; + + +/***/ }), +/* 865 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} Palette + * + * @property {string} 0 - Color value 1. + * @property {string} 1 - Color value 2. + * @property {string} 2 - Color value 3. + * @property {string} 3 - Color value 4. + * @property {string} 4 - Color value 5. + * @property {string} 5 - Color value 6. + * @property {string} 6 - Color value 7. + * @property {string} 7 - Color value 8. + * @property {string} 8 - Color value 9. + * @property {string} 9 - Color value 10. + * @property {string} A - Color value 11. + * @property {string} B - Color value 12. + * @property {string} C - Color value 13. + * @property {string} D - Color value 14. + * @property {string} E - Color value 15. + * @property {string} F - Color value 16. + */ + +/** + * @namespace Phaser.Create.Palettes + */ + +module.exports = { + + ARNE16: __webpack_require__(322), + C64: __webpack_require__(864), + CGA: __webpack_require__(863), + JMP: __webpack_require__(862), + MSX: __webpack_require__(861) + +}; + + +/***/ }), +/* 866 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Create + */ + +module.exports = { + + GenerateTexture: __webpack_require__(323), + Palettes: __webpack_require__(865) + +}; + + +/***/ }), +/* 867 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var OrthographicCamera = __webpack_require__(325); +var PerspectiveCamera = __webpack_require__(324); +var PluginManager = __webpack_require__(12); + +/** + * @classdesc + * [description] + * + * @class CameraManager + * @memberOf Phaser.Cameras.Sprite3D + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ +var CameraManager = new Class({ + + initialize: + + function CameraManager (scene) + { + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.CameraManager#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.CameraManager#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + /** + * An Array of the Camera objects being managed by this Camera Manager. + * + * @name Phaser.Cameras.Sprite3D.CameraManager#cameras + * @type {array} + * @since 3.0.0 + */ + this.cameras = []; + + if (!scene.sys.settings.isBooted) + { + scene.sys.events.once('boot', this.boot, this); + } + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.CameraManager#boot + * @since 3.0.0 + */ + boot: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on('update', this.update, this); + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.CameraManager#add + * @since 3.0.0 + * + * @param {number} [fieldOfView=80] - [description] + * @param {number} [width] - [description] + * @param {number} [height] - [description] + * + * @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description] + */ + add: function (fieldOfView, width, height) + { + return this.addPerspectiveCamera(fieldOfView, width, height); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.CameraManager#addOrthographicCamera + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.Cameras.Sprite3D.OrthographicCamera} [description] + */ + addOrthographicCamera: function (width, height) + { + var config = this.scene.sys.game.config; + + if (width === undefined) { width = config.width; } + if (height === undefined) { height = config.height; } + + var camera = new OrthographicCamera(this.scene, width, height); + + this.cameras.push(camera); + + return camera; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.CameraManager#addPerspectiveCamera + * @since 3.0.0 + * + * @param {number} [fieldOfView=80] - [description] + * @param {number} [width] - [description] + * @param {number} [height] - [description] + * + * @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description] + */ + addPerspectiveCamera: function (fieldOfView, width, height) + { + var config = this.scene.sys.game.config; + + if (fieldOfView === undefined) { fieldOfView = 80; } + if (width === undefined) { width = config.width; } + if (height === undefined) { height = config.height; } + + var camera = new PerspectiveCamera(this.scene, fieldOfView, width, height); + + this.cameras.push(camera); + + return camera; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.CameraManager#getCamera + * @since 3.0.0 + * + * @param {string} name - [description] + * + * @return {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} [description] + */ + getCamera: function (name) + { + for (var i = 0; i < this.cameras.length; i++) + { + if (this.cameras[i].name === name) + { + return this.cameras[i]; + } + } + + return null; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.CameraManager#removeCamera + * @since 3.0.0 + * + * @param {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} camera - [description] + */ + removeCamera: function (camera) + { + var cameraIndex = this.cameras.indexOf(camera); + + if (cameraIndex !== -1) + { + this.cameras.splice(cameraIndex, 1); + } + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.CameraManager#removeAll + * @since 3.0.0 + * + * @return {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} [description] + */ + removeAll: function () + { + while (this.cameras.length > 0) + { + var camera = this.cameras.pop(); + + camera.destroy(); + } + + return this.main; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.CameraManager#update + * @since 3.0.0 + * + * @param {number} timestep - [description] + * @param {number} delta - [description] + */ + update: function (timestep, delta) + { + for (var i = 0, l = this.cameras.length; i < l; ++i) + { + this.cameras[i].update(timestep, delta); + } + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.CameraManager#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.CameraManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.scene = undefined; + } + +}); + +PluginManager.register('CameraManager3D', CameraManager, 'cameras3d'); + +module.exports = CameraManager; + + +/***/ }), +/* 868 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Sprite#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var SpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + renderer.drawImage(src, camera); +}; + +module.exports = SpriteCanvasRenderer; + + +/***/ }), +/* 869 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObject = __webpack_require__(1); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Sprite#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var SpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera) +{ + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + { + return; + } + + this.pipeline.batchSprite(src, camera); +}; + +module.exports = SpriteWebGLRenderer; + + +/***/ }), +/* 870 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(3); +var renderCanvas = __webpack_require__(3); + +if (true) +{ + renderWebGL = __webpack_require__(869); +} + +if (true) +{ + renderCanvas = __webpack_require__(868); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 871 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Cameras.Sprite3D + */ + +module.exports = { + + Camera: __webpack_require__(154), + CameraManager: __webpack_require__(867), + OrthographicCamera: __webpack_require__(325), + PerspectiveCamera: __webpack_require__(324) + +}; + + +/***/ }), +/* 872 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Camera = __webpack_require__(157); +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(2); +var PluginManager = __webpack_require__(12); +var RectangleContains = __webpack_require__(27); + +/** + * @typedef {object} InputJSONCameraObject + * + * @property {string} [name=''] - [description] + * @property {integer} [x=0] - [description] + * @property {integer} [y=0] - [description] + * @property {integer} [width] - [description] + * @property {integer} [height] - [description] + * @property {float} [zoom=1] - [description] + * @property {float} [rotation=0] - [description] + * @property {boolean} [roundPixels=false] - [description] + * @property {float} [scrollX=0] - [description] + * @property {float} [scrollY=0] - [description] + * @property {(false|string)} [backgroundColor=false] - [description] + * @property {?object} [bounds] - [description] + * @property {number} [bounds.x=0] - [description] + * @property {number} [bounds.y=0] - [description] + * @property {number} [bounds.width] - [description] + * @property {number} [bounds.height] - [description] + */ + +/** + * @classdesc + * [description] + * + * @class CameraManager + * @memberOf Phaser.Cameras.Scene2D + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene that owns the Camera Manager plugin. + */ +var CameraManager = new Class({ + + initialize: + + function CameraManager (scene) + { + /** + * The Scene that owns the Camera Manager plugin. + * + * @name Phaser.Cameras.Scene2D.CameraManager#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A reference to the Scene.Systems handler for the Scene that owns the Camera Manager. + * + * @name Phaser.Cameras.Scene2D.CameraManager#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + if (!scene.sys.settings.isBooted) + { + scene.sys.events.once('boot', this.boot, this); + } + + /** + * The current Camera ID. + * + * @name Phaser.Cameras.Scene2D.CameraManager#currentCameraId + * @type {number} + * @default 1 + * @readOnly + * @since 3.0.0 + */ + this.currentCameraId = 1; + + /** + * An Array of the Camera objects being managed by this Camera Manager. + * + * @name Phaser.Cameras.Scene2D.CameraManager#cameras + * @type {Phaser.Cameras.Scene2D.Camera[]} + * @since 3.0.0 + */ + this.cameras = []; + + /** + * A pool of Camera objects available to be used by the Camera Manager. + * + * @name Phaser.Cameras.Scene2D.CameraManager#cameraPool + * @type {Phaser.Cameras.Scene2D.Camera[]} + * @since 3.0.0 + */ + this.cameraPool = []; + + if (scene.sys.settings.cameras) + { + // We have cameras to create + this.fromJSON(scene.sys.settings.cameras); + } + else + { + // Make one + this.add(); + } + + /** + * The default Camera in the Camera Manager. + * + * @name Phaser.Cameras.Scene2D.CameraManager#main + * @type {Phaser.Cameras.Scene2D.Camera} + * @since 3.0.0 + */ + this.main = this.cameras[0]; + + /** + * This scale affects all cameras. It's used by Scale Manager. + * + * @name Phaser.Cameras.Scene2D.CameraManager#baseScale + * @type {number} + * @since 3.0.0 + */ + this.baseScale = 1.0; + }, + + /** + * Called when the Camera Manager boots. + * Starts the event listeners running. + * + * @method Phaser.Cameras.Scene2D.CameraManager#boot + * @since 3.0.0 + */ + boot: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on('update', this.update, this); + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.CameraManager#add + * @since 3.0.0 + * + * @param {number} [x=0] - [description] + * @param {number} [y=0] - [description] + * @param {number} [width] - [description] + * @param {number} [height] - [description] + * @param {boolean} [makeMain=false] - [description] + * @param {string} [name=''] - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} [description] + */ + add: function (x, y, width, height, makeMain, name) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = this.scene.sys.game.config.width; } + if (height === undefined) { height = this.scene.sys.game.config.height; } + if (makeMain === undefined) { makeMain = false; } + if (name === undefined) { name = ''; } + + var camera = null; + + if (this.cameraPool.length > 0) + { + camera = this.cameraPool.pop(); + + camera.setViewport(x, y, width, height); + } + else + { + camera = new Camera(x, y, width, height); + } + + camera.setName(name); + camera.setScene(this.scene); + + this.cameras.push(camera); + + if (makeMain) + { + this.main = camera; + } + + camera._id = this.currentCameraId; + + this.currentCameraId = this.currentCameraId << 1; + + return camera; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.CameraManager#addExisting + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} [description] + */ + addExisting: function (camera) + { + var index = this.cameras.indexOf(camera); + var poolIndex = this.cameraPool.indexOf(camera); + + if (index < 0 && poolIndex >= 0) + { + this.cameras.push(camera); + this.cameraPool.slice(poolIndex, 1); + return camera; + } + + return null; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.CameraManager#fromJSON + * @since 3.0.0 + * + * @param {(InputJSONCameraObject|InputJSONCameraObject[])} config - [description] + * + * @return {Phaser.Cameras.Scene2D.CameraManager} [description] + */ + fromJSON: function (config) + { + if (!Array.isArray(config)) + { + config = [ config ]; + } + + var gameWidth = this.scene.sys.game.config.width; + var gameHeight = this.scene.sys.game.config.height; + + for (var i = 0; i < config.length; i++) + { + var cameraConfig = config[i]; + + var x = GetFastValue(cameraConfig, 'x', 0); + var y = GetFastValue(cameraConfig, 'y', 0); + var width = GetFastValue(cameraConfig, 'width', gameWidth); + var height = GetFastValue(cameraConfig, 'height', gameHeight); + + var camera = this.add(x, y, width, height); + + // Direct properties + camera.name = GetFastValue(cameraConfig, 'name', ''); + camera.zoom = GetFastValue(cameraConfig, 'zoom', 1); + camera.rotation = GetFastValue(cameraConfig, 'rotation', 0); + camera.scrollX = GetFastValue(cameraConfig, 'scrollX', 0); + camera.scrollY = GetFastValue(cameraConfig, 'scrollY', 0); + camera.roundPixels = GetFastValue(cameraConfig, 'roundPixels', false); + + // Background Color + + var backgroundColor = GetFastValue(cameraConfig, 'backgroundColor', false); + + if (backgroundColor) + { + camera.setBackgroundColor(backgroundColor); + } + + // Bounds + + var boundsConfig = GetFastValue(cameraConfig, 'bounds', null); + + if (boundsConfig) + { + var bx = GetFastValue(boundsConfig, 'x', 0); + var by = GetFastValue(boundsConfig, 'y', 0); + var bwidth = GetFastValue(boundsConfig, 'width', gameWidth); + var bheight = GetFastValue(boundsConfig, 'height', gameHeight); + + camera.setBounds(bx, by, bwidth, bheight); + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.CameraManager#getCamera + * @since 3.0.0 + * + * @param {string} name - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} [description] + */ + getCamera: function (name) + { + for (var i = 0; i < this.cameras.length; i++) + { + if (this.cameras[i].name === name) + { + return this.cameras[i]; + } + } + + return null; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.CameraManager#getCameraBelowPointer + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - [description] + * + * @return {Phaser.Cameras.Scene2D.Camera} [description] + */ + getCameraBelowPointer: function (pointer) + { + var cameras = this.cameras; + + // Start from the most recently added camera (the 'top' camera) + for (var i = cameras.length - 1; i >= 0; i--) + { + var camera = cameras[i]; + + if (camera.inputEnabled && RectangleContains(camera, pointer.x, pointer.y)) + { + return camera; + } + } + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.CameraManager#remove + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + remove: function (camera) + { + var cameraIndex = this.cameras.indexOf(camera); + + if (cameraIndex >= 0 && this.cameras.length > 1) + { + this.cameraPool.push(this.cameras[cameraIndex]); + this.cameras.splice(cameraIndex, 1); + + if (this.main === camera) + { + this.main = this.cameras[0]; + } + } + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.CameraManager#render + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - The Renderer that will render the children to this camera. + * @param {Phaser.GameObjects.GameObject[]} children - An array of renderable Game Objects. + * @param {number} interpolation - Interpolation value. Reserved for future use. + */ + render: function (renderer, children, interpolation) + { + var cameras = this.cameras; + var baseScale = this.baseScale; + + for (var i = 0, l = cameras.length; i < l; ++i) + { + var camera = cameras[i]; + + camera.preRender(baseScale, renderer.config.resolution); + + renderer.render(this.scene, children, interpolation, camera); + } + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.CameraManager#resetAll + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} [description] + */ + resetAll: function () + { + while (this.cameras.length > 0) + { + this.cameraPool.push(this.cameras.pop()); + } + + this.main = this.add(); + + return this.main; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.CameraManager#update + * @since 3.0.0 + * + * @param {number} timestep - [description] + * @param {number} delta - [description] + */ + update: function (timestep, delta) + { + for (var i = 0, l = this.cameras.length; i < l; ++i) + { + this.cameras[i].update(timestep, delta); + } + }, + + /** + * Resizes all cameras to the given dimensions. + * + * @method Phaser.Cameras.Scene2D.CameraManager#resize + * @since 3.2.0 + * + * @param {number} width - The new width of the camera. + * @param {number} height - The new height of the camera. + */ + resize: function (width, height) + { + for (var i = 0, l = this.cameras.length; i < l; ++i) + { + this.cameras[i].setSize(width, height); + } + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.CameraManager#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + // TODO + }, + + /** + * [description] + * + * @method Phaser.Cameras.Scene2D.CameraManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.main = undefined; + + for (var i = 0; i < this.cameras.length; i++) + { + this.cameras[i].destroy(); + } + + for (i = 0; i < this.cameraPool.length; i++) + { + this.cameraPool[i].destroy(); + } + + this.cameras = []; + this.cameraPool = []; + this.scene = undefined; + } + +}); + +PluginManager.register('CameraManager', CameraManager, 'cameras'); + +module.exports = CameraManager; + + +/***/ }), +/* 873 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Cameras.Scene2D + */ + +module.exports = { + + Camera: __webpack_require__(157), + CameraManager: __webpack_require__(872) + +}; + + +/***/ }), +/* 874 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetValue = __webpack_require__(5); + +// var controlConfig = { +// camera: this.cameras.main, +// left: cursors.left, +// right: cursors.right, +// up: cursors.up, +// down: cursors.down, +// zoomIn: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q), +// zoomOut: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E), +// zoomSpeed: 0.02, +// acceleration: 0.06, +// drag: 0.0005, +// maxSpeed: 1.0 +// }; + +/** + * @typedef {object} SmoothedKeyControlConfig + * + * @property {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera that this Control will update. + * @property {Phaser.Input.Keyboard.Key} [left] - The Key to be pressed that will move the Camera left. + * @property {Phaser.Input.Keyboard.Key} [right] - The Key to be pressed that will move the Camera right. + * @property {Phaser.Input.Keyboard.Key} [up] - The Key to be pressed that will move the Camera up. + * @property {Phaser.Input.Keyboard.Key} [zoomIn] - The Key to be pressed that will zoom the Camera in. + * @property {Phaser.Input.Keyboard.Key} [zoomOut] - The Key to be pressed that will zoom the Camera out. + * @property {float} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + * @property {(float|{x:float,y:float})} [acceleration=0] - The horizontal and vertical acceleration the camera will move. + * @property {(float|{x:float,y:float})} [drag=0] - The horizontal and vertical drag applied to the camera when it is moving. + * @property {(float|{x:float,y:float})} [maxSpeed=0] - The maximum horizontal and vertical speed the camera will move. + */ + +/** + * @classdesc + * [description] + * + * @class SmoothedKeyControl + * @memberOf Phaser.Cameras.Controls + * @constructor + * @since 3.0.0 + * + * @param {SmoothedKeyControlConfig} config - [description] + */ +var SmoothedKeyControl = new Class({ + + initialize: + + function SmoothedKeyControl (config) + { + /** + * The Camera that this Control will update. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @default null + * @since 3.0.0 + */ + this.camera = GetValue(config, 'camera', null); + + /** + * The Key to be pressed that will move the Camera left. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#left + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.left = GetValue(config, 'left', null); + + /** + * The Key to be pressed that will move the Camera right. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#right + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.right = GetValue(config, 'right', null); + + /** + * The Key to be pressed that will move the Camera up. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#up + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.up = GetValue(config, 'up', null); + + /** + * The Key to be pressed that will move the Camera down. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#down + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.down = GetValue(config, 'down', null); + + /** + * The Key to be pressed that will zoom the Camera in. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomIn + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.zoomIn = GetValue(config, 'zoomIn', null); + + /** + * The Key to be pressed that will zoom the Camera out. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomOut + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.zoomOut = GetValue(config, 'zoomOut', null); + + /** + * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomSpeed + * @type {float} + * @default 0.01 + * @since 3.0.0 + */ + this.zoomSpeed = GetValue(config, 'zoomSpeed', 0.01); + + /** + * The horizontal acceleration the camera will move. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#accelX + * @type {float} + * @default 0 + * @since 3.0.0 + */ + this.accelX = 0; + + /** + * The vertical acceleration the camera will move. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#accelY + * @type {float} + * @default 0 + * @since 3.0.0 + */ + this.accelY = 0; + + var accel = GetValue(config, 'acceleration', null); + + if (typeof accel === 'number') + { + this.accelX = accel; + this.accelY = accel; + } + else + { + this.accelX = GetValue(config, 'acceleration.x', 0); + this.accelY = GetValue(config, 'acceleration.y', 0); + } + + /** + * The horizontal drag applied to the camera when it is moving. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#dragX + * @type {float} + * @default 0 + * @since 3.0.0 + */ + this.dragX = 0; + + /** + * The vertical drag applied to the camera when it is moving. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#dragY + * @type {float} + * @default 0 + * @since 3.0.0 + */ + this.dragY = 0; + + var drag = GetValue(config, 'drag', null); + + if (typeof drag === 'number') + { + this.dragX = drag; + this.dragY = drag; + } + else + { + this.dragX = GetValue(config, 'drag.x', 0); + this.dragY = GetValue(config, 'drag.y', 0); + } + + /** + * The maximum horizontal speed the camera will move. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#maxSpeedX + * @type {float} + * @default 0 + * @since 3.0.0 + */ + this.maxSpeedX = 0; + + /** + * The maximum vertical speed the camera will move. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#maxSpeedY + * @type {float} + * @default 0 + * @since 3.0.0 + */ + this.maxSpeedY = 0; + + var maxSpeed = GetValue(config, 'maxSpeed', null); + + if (typeof maxSpeed === 'number') + { + this.maxSpeedX = maxSpeed; + this.maxSpeedY = maxSpeed; + } + else + { + this.maxSpeedX = GetValue(config, 'maxSpeed.x', 0); + this.maxSpeedY = GetValue(config, 'maxSpeed.y', 0); + } + + /** + * [description] + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#_speedX + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._speedX = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#_speedY + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._speedY = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#_zoom + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._zoom = 0; + + /** + * A flag controlling if the Controls will update the Camera or not. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#active + * @type {boolean} + * @since 3.0.0 + */ + this.active = (this.camera !== null); + }, + + /** + * Starts the Key Control running, providing it has been linked to a camera. + * + * @method Phaser.Cameras.Controls.SmoothedKeyControl#start + * @since 3.0.0 + * + * @return {Phaser.Cameras.Controls.SmoothedKeyControl} This Key Control instance. + */ + start: function () + { + this.active = (this.camera !== null); + + return this; + }, + + /** + * Stops this Key Control from running. Call `start` to start it again. + * + * @method Phaser.Cameras.Controls.SmoothedKeyControl#stop + * @since 3.0.0 + * + * @return {Phaser.Cameras.Controls.SmoothedKeyControl} This Key Control instance. + */ + stop: function () + { + this.active = false; + + return this; + }, + + /** + * Binds this Key Control to a camera. + * + * @method Phaser.Cameras.Controls.SmoothedKeyControl#setCamera + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to bind this Key Control to. + * + * @return {Phaser.Cameras.Controls.SmoothedKeyControl} This Key Control instance. + */ + setCamera: function (camera) + { + this.camera = camera; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Controls.SmoothedKeyControl#update + * @since 3.0.0 + * + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + update: function (delta) + { + if (!this.active) + { + return; + } + + if (delta === undefined) { delta = 1; } + + var cam = this.camera; + + // Apply Deceleration + + if (this._speedX > 0) + { + this._speedX -= this.dragX * delta; + + if (this._speedX < 0) + { + this._speedX = 0; + } + } + else if (this._speedX < 0) + { + this._speedX += this.dragX * delta; + + if (this._speedX > 0) + { + this._speedX = 0; + } + } + + if (this._speedY > 0) + { + this._speedY -= this.dragY * delta; + + if (this._speedY < 0) + { + this._speedY = 0; + } + } + else if (this._speedY < 0) + { + this._speedY += this.dragY * delta; + + if (this._speedY > 0) + { + this._speedY = 0; + } + } + + // Check for keys + + if (this.up && this.up.isDown) + { + this._speedY += this.accelY; + + if (this._speedY > this.maxSpeedY) + { + this._speedY = this.maxSpeedY; + } + } + else if (this.down && this.down.isDown) + { + this._speedY -= this.accelY; + + if (this._speedY < -this.maxSpeedY) + { + this._speedY = -this.maxSpeedY; + } + } + + if (this.left && this.left.isDown) + { + this._speedX += this.accelX; + + if (this._speedX > this.maxSpeedX) + { + this._speedX = this.maxSpeedX; + } + } + else if (this.right && this.right.isDown) + { + this._speedX -= this.accelX; + + if (this._speedX < -this.maxSpeedX) + { + this._speedX = -this.maxSpeedX; + } + } + + // Camera zoom + + if (this.zoomIn && this.zoomIn.isDown) + { + this._zoom = -this.zoomSpeed; + } + else if (this.zoomOut && this.zoomOut.isDown) + { + this._zoom = this.zoomSpeed; + } + else + { + this._zoom = 0; + } + + // Apply to Camera + + if (this._speedX !== 0) + { + cam.scrollX -= ((this._speedX * delta) | 0); + } + + if (this._speedY !== 0) + { + cam.scrollY -= ((this._speedY * delta) | 0); + } + + if (this._zoom !== 0) + { + cam.zoom += this._zoom; + + if (cam.zoom < 0.1) + { + cam.zoom = 0.1; + } + } + }, + + /** + * Destroys this Key Control. + * + * @method Phaser.Cameras.Controls.SmoothedKeyControl#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.camera = null; + + this.left = null; + this.right = null; + this.up = null; + this.down = null; + + this.zoomIn = null; + this.zoomOut = null; + } + +}); + +module.exports = SmoothedKeyControl; + + +/***/ }), +/* 875 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetValue = __webpack_require__(5); + +// var camControl = new CameraControl({ +// camera: this.cameras.main, +// left: cursors.left, +// right: cursors.right, +// speed: float OR { x: 0, y: 0 } +// }) + +/** + * @typedef {object} FixedKeyControlConfig + * + * @property {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera that this Control will update. + * @property {Phaser.Input.Keyboard.Key} [left] - The Key to be pressed that will move the Camera left. + * @property {Phaser.Input.Keyboard.Key} [right] - The Key to be pressed that will move the Camera right. + * @property {Phaser.Input.Keyboard.Key} [up] - The Key to be pressed that will move the Camera up. + * @property {Phaser.Input.Keyboard.Key} [zoomIn] - The Key to be pressed that will zoom the Camera in. + * @property {Phaser.Input.Keyboard.Key} [zoomOut] - The Key to be pressed that will zoom the Camera out. + * @property {float} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + * @property {(float|{x:float,y:float})} [speed=0] - The horizontal and vertical speed the camera will move. + */ + +/** + * @classdesc + * [description] + * + * @class FixedKeyControl + * @memberOf Phaser.Cameras.Controls + * @constructor + * @since 3.0.0 + * + * @param {FixedKeyControlConfig} config - [description] + */ +var FixedKeyControl = new Class({ + + initialize: + + function FixedKeyControl (config) + { + /** + * The Camera that this Control will update. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @default null + * @since 3.0.0 + */ + this.camera = GetValue(config, 'camera', null); + + /** + * The Key to be pressed that will move the Camera left. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#left + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.left = GetValue(config, 'left', null); + + /** + * The Key to be pressed that will move the Camera right. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#right + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.right = GetValue(config, 'right', null); + + /** + * The Key to be pressed that will move the Camera up. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#up + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.up = GetValue(config, 'up', null); + + /** + * The Key to be pressed that will move the Camera down. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#down + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.down = GetValue(config, 'down', null); + + /** + * The Key to be pressed that will zoom the Camera in. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#zoomIn + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.zoomIn = GetValue(config, 'zoomIn', null); + + /** + * The Key to be pressed that will zoom the Camera out. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#zoomOut + * @type {Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.zoomOut = GetValue(config, 'zoomOut', null); + + /** + * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#zoomSpeed + * @type {float} + * @default 0.01 + * @since 3.0.0 + */ + this.zoomSpeed = GetValue(config, 'zoomSpeed', 0.01); + + /** + * The horizontal speed the camera will move. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#speedX + * @type {float} + * @default 0 + * @since 3.0.0 + */ + this.speedX = 0; + + /** + * The vertical speed the camera will move. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#speedY + * @type {float} + * @default 0 + * @since 3.0.0 + */ + this.speedY = 0; + + var speed = GetValue(config, 'speed', null); + + if (typeof speed === 'number') + { + this.speedX = speed; + this.speedY = speed; + } + else + { + this.speedX = GetValue(config, 'speed.x', 0); + this.speedY = GetValue(config, 'speed.y', 0); + } + + /** + * [description] + * + * @name Phaser.Cameras.Controls.FixedKeyControl#_zoom + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._zoom = 0; + + /** + * A flag controlling if the Controls will update the Camera or not. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#active + * @type {boolean} + * @since 3.0.0 + */ + this.active = (this.camera !== null); + }, + + /** + * Starts the Key Control running, providing it has been linked to a camera. + * + * @method Phaser.Cameras.Controls.FixedKeyControl#start + * @since 3.0.0 + * + * @return {Phaser.Cameras.Controls.FixedKeyControl} This Key Control instance. + */ + start: function () + { + this.active = (this.camera !== null); + + return this; + }, + + /** + * Stops this Key Control from running. Call `start` to start it again. + * + * @method Phaser.Cameras.Controls.FixedKeyControl#stop + * @since 3.0.0 + * + * @return {Phaser.Cameras.Controls.FixedKeyControl} This Key Control instance. + */ + stop: function () + { + this.active = false; + + return this; + }, + + /** + * Binds this Key Control to a camera. + * + * @method Phaser.Cameras.Controls.FixedKeyControl#setCamera + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to bind this Key Control to. + * + * @return {Phaser.Cameras.Controls.FixedKeyControl} This Key Control instance. + */ + setCamera: function (camera) + { + this.camera = camera; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Controls.FixedKeyControl#update + * @since 3.0.0 + * + * @param {number} delta - [description] + */ + update: function (delta) + { + if (!this.active) + { + return; + } + + if (delta === undefined) { delta = 1; } + + var cam = this.camera; + + if (this.up && this.up.isDown) + { + cam.scrollY -= ((this.speedY * delta) | 0); + } + else if (this.down && this.down.isDown) + { + cam.scrollY += ((this.speedY * delta) | 0); + } + + if (this.left && this.left.isDown) + { + cam.scrollX -= ((this.speedX * delta) | 0); + } + else if (this.right && this.right.isDown) + { + cam.scrollX += ((this.speedX * delta) | 0); + } + + // Camera zoom + + if (this.zoomIn && this.zoomIn.isDown) + { + cam.zoom -= this.zoomSpeed; + + if (cam.zoom < 0.1) + { + cam.zoom = 0.1; + } + } + else if (this.zoomOut && this.zoomOut.isDown) + { + cam.zoom += this.zoomSpeed; + } + }, + + /** + * Destroys this Key Control. + * + * @method Phaser.Cameras.Controls.FixedKeyControl#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.camera = null; + + this.left = null; + this.right = null; + this.up = null; + this.down = null; + + this.zoomIn = null; + this.zoomOut = null; + } + +}); + +module.exports = FixedKeyControl; + + +/***/ }), +/* 876 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Cameras.Controls + */ + +module.exports = { + + Fixed: __webpack_require__(875), + Smoothed: __webpack_require__(874) + +}; + + +/***/ }), +/* 877 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Cameras + */ + +module.exports = { + + Controls: __webpack_require__(876), + Scene2D: __webpack_require__(873), + Sprite3D: __webpack_require__(871) + +}; + + +/***/ }), +/* 878 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Cache + */ + +module.exports = { + + BaseCache: __webpack_require__(338), + CacheManager: __webpack_require__(337) + +}; + + +/***/ }), +/* 879 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Animations + */ + +module.exports = { + + Animation: __webpack_require__(341), + AnimationFrame: __webpack_require__(340), + AnimationManager: __webpack_require__(339) + +}; + + +/***/ }), +/* 880 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author samme + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Wrap = __webpack_require__(43); + +/** + * Wrap each item's coordinates within a rectangle's area. + * + * @function Phaser.Actions.WrapInRectangle + * @since 3.0.0 + * @see Phaser.Math.Wrap + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Rectangle} rect - The rectangle. + * @param {number} [padding=0] - An amount added to each side of the rectangle during the operation. + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var WrapInRectangle = function (items, rect, padding) +{ + if (padding === undefined) + { + padding = 0; + } + + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + + item.x = Wrap(item.x, rect.left - padding, rect.right + padding); + item.y = Wrap(item.y, rect.top - padding, rect.bottom + padding); + } + + return items; +}; + +module.exports = WrapInRectangle; + + +/***/ }), +/* 881 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Actions.ToggleVisible + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var ToggleVisible = function (items) +{ + for (var i = 0; i < items.length; i++) + { + items[i].visible = !items[i].visible; + } + + return items; +}; + +module.exports = ToggleVisible; + + +/***/ }), +/* 882 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Actions.Spread + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {string} property - [description] + * @param {number} min - [description] + * @param {number} max - [description] + * @param {number} [inc=false] - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var Spread = function (items, property, min, max, inc) +{ + if (inc === undefined) { inc = false; } + + var step = Math.abs(max - min) / items.length; + var i; + + if (inc) + { + for (i = 0; i < items.length; i++) + { + items[i][property] += i * step; + } + } + else + { + for (i = 0; i < items.length; i++) + { + items[i][property] = i * step; + } + } + + return items; +}; + +module.exports = Spread; + + +/***/ }), +/* 883 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MathSmoothStep = __webpack_require__(342); + +/** + * [description] + * + * @function Phaser.Actions.SmoothStep + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {string} property - [description] + * @param {number} min - [description] + * @param {number} max - [description] + * @param {number} inc - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var SmoothStep = function (items, property, min, max, inc) +{ + if (inc === undefined) { inc = false; } + + var step = Math.abs(max - min) / items.length; + var i; + + if (inc) + { + for (i = 0; i < items.length; i++) + { + items[i][property] += MathSmoothStep(i * step, min, max); + } + } + else + { + for (i = 0; i < items.length; i++) + { + items[i][property] = MathSmoothStep(i * step, min, max); + } + } + + return items; +}; + +module.exports = SmoothStep; + + +/***/ }), +/* 884 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MathSmootherStep = __webpack_require__(343); + +/** + * [description] + * + * @function Phaser.Actions.SmootherStep + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {string} property - [description] + * @param {number} min - [description] + * @param {number} max - [description] + * @param {number} inc - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var SmootherStep = function (items, property, min, max, inc) +{ + if (inc === undefined) { inc = false; } + + var step = Math.abs(max - min) / items.length; + var i; + + if (inc) + { + for (i = 0; i < items.length; i++) + { + items[i][property] += MathSmootherStep(i * step, min, max); + } + } + else + { + for (i = 0; i < items.length; i++) + { + items[i][property] = MathSmootherStep(i * step, min, max); + } + } + + return items; +}; + +module.exports = SmootherStep; + + +/***/ }), +/* 885 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArrayShuffle = __webpack_require__(102); + +/** + * [description] + * + * @function Phaser.Actions.Shuffle + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var Shuffle = function (items) +{ + return ArrayShuffle(items); +}; + +module.exports = Shuffle; + + +/***/ }), +/* 886 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Vector2 = __webpack_require__(6); + +/** + * Iterate through items changing the position of each element to + * be that of the element that came before it in the array (or after it if direction = 1) + * The first items position is set to x/y. + * The final x/y coords are returned + * + * @function Phaser.Actions.ShiftPosition + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {number} x - [description] + * @param {number} y - [description] + * @param {integer} [direction=0] - [description] + * @param {(Phaser.Math.Vector2|object)} [output] - [description] + * + * @return {Phaser.Math.Vector2} The output vector. + */ +var ShiftPosition = function (items, x, y, direction, output) +{ + if (direction === undefined) { direction = 0; } + if (output === undefined) { output = new Vector2(); } + + var px; + var py; + + if (items.length > 1) + { + var i; + var cx; + var cy; + var cur; + + if (direction === 0) + { + // Bottom to Top + + var len = items.length - 1; + + px = items[len].x; + py = items[len].y; + + for (i = len - 1; i >= 0; i--) + { + // Current item + cur = items[i]; + + // Get current item x/y, to be passed to the next item in the list + cx = cur.x; + cy = cur.y; + + // Set current item to the previous items x/y + cur.x = px; + cur.y = py; + + // Set current as previous + px = cx; + py = cy; + } + + // Update the head item to the new x/y coordinates + items[len].x = x; + items[len].y = y; + } + else + { + // Top to Bottom + + px = items[0].x; + py = items[0].y; + + for (i = 1; i < items.length; i++) + { + // Current item + cur = items[i]; + + // Get current item x/y, to be passed to the next item in the list + cx = cur.x; + cy = cur.y; + + // Set current item to the previous items x/y + cur.x = px; + cur.y = py; + + // Set current as previous + px = cx; + py = cy; + } + + // Update the head item to the new x/y coordinates + items[0].x = x; + items[0].y = y; + } + } + else + { + px = items[0].x; + py = items[0].y; + + items[0].x = x; + items[0].y = y; + } + + // Return the final set of coordinates as they're effectively lost from the shift and may be needed + + output.x = px; + output.y = py; + + return output; +}; + +module.exports = ShiftPosition; + + +/***/ }), +/* 887 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public property `y` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetY(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetY + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetY = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'y', value, step, index, direction); +}; + +module.exports = SetY; + + +/***/ }), +/* 888 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public properties `x` and `y` + * and then sets them to the given values. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetXY(group.getChildren(), x, y, stepX, stepY)` + * + * @function Phaser.Actions.SetXY + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} x - The amount to set the `x` property to. + * @param {number} [y=x] - The amount to set the `y` property to. If `undefined` or `null` it uses the `x` value. + * @param {number} [stepX=0] - This is added to the `x` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `y` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetXY = function (items, x, y, stepX, stepY, index, direction) +{ + if (y === undefined || y === null) { y = x; } + + PropertyValueSet(items, 'x', x, stepX, index, direction); + + return PropertyValueSet(items, 'y', y, stepY, index, direction); +}; + +module.exports = SetXY; + + +/***/ }), +/* 889 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public property `x` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetX(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetX + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetX = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'x', value, step, index, direction); +}; + +module.exports = SetX; + + +/***/ }), +/* 890 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public property `visible` + * and then sets it to the given value. + * + * To use this with a Group: `SetVisible(group.getChildren(), value)` + * + * @function Phaser.Actions.SetVisible + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {boolean} value - The value to set the property to. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetVisible = function (items, value, index, direction) +{ + return PropertyValueSet(items, 'visible', value, 0, index, direction); +}; + +module.exports = SetVisible; + + +/***/ }), +/* 891 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Actions.SetTint + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {number} topLeft - [description] + * @param {number} [topRight] - [description] + * @param {number} [bottomLeft] - [description] + * @param {number} [bottomRight] - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var SetTint = function (items, topLeft, topRight, bottomLeft, bottomRight) +{ + for (var i = 0; i < items.length; i++) + { + items[i].setTint(topLeft, topRight, bottomLeft, bottomRight); + } + + return items; +}; + +module.exports = SetTint; + + +/***/ }), +/* 892 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public property `scaleY` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetScaleY(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetScaleY + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetScaleY = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'scaleY', value, step, index, direction); +}; + +module.exports = SetScaleY; + + +/***/ }), +/* 893 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public property `scaleX` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetScaleX(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetScaleX + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetScaleX = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'scaleX', value, step, index, direction); +}; + +module.exports = SetScaleX; + + +/***/ }), +/* 894 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public properties `scaleX` and `scaleY` + * and then sets them to the given values. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetScale(group.getChildren(), scaleX, scaleY, stepX, stepY)` + * + * @function Phaser.Actions.SetScale + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} scaleX - The amount to set the `scaleX` property to. + * @param {number} [scaleY] - The amount to set the `scaleY` property to. If `undefined` or `null` it uses the `scaleX` value. + * @param {number} [stepX=0] - This is added to the `scaleX` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `scaleY` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetScale = function (items, scaleX, scaleY, stepX, stepY, index, direction) +{ + if (scaleY === undefined || scaleY === null) { scaleY = scaleX; } + + PropertyValueSet(items, 'scaleX', scaleX, stepX, index, direction); + + return PropertyValueSet(items, 'scaleY', scaleY, stepY, index, direction); +}; + +module.exports = SetScale; + + +/***/ }), +/* 895 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public property `rotation` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetRotation(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetRotation + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetRotation = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'rotation', value, step, index, direction); +}; + +module.exports = SetRotation; + + +/***/ }), +/* 896 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public properties `originX` and `originY` + * and then sets them to the given values. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetOrigin(group.getChildren(), originX, originY, stepX, stepY)` + * + * @function Phaser.Actions.SetOrigin + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} originX - The amount to set the `originX` property to. + * @param {number} [originY] - The amount to set the `originY` property to. If `undefined` or `null` it uses the `originX` value. + * @param {number} [stepX=0] - This is added to the `originX` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `originY` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetOrigin = function (items, originX, originY, stepX, stepY, index, direction) +{ + if (originY === undefined || originY === null) { originY = originX; } + + PropertyValueSet(items, 'originX', originX, stepX, index, direction); + + return PropertyValueSet(items, 'originY', originY, stepY, index, direction); +}; + +module.exports = SetOrigin; + + +/***/ }), +/* 897 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Actions.SetHitArea + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {*} hitArea - [description] + * @param {HitAreaCallback} hitAreaCallback - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var SetHitArea = function (items, hitArea, hitAreaCallback) +{ + for (var i = 0; i < items.length; i++) + { + items[i].setInteractive(hitArea, hitAreaCallback); + } + + return items; +}; + +module.exports = SetHitArea; + + +/***/ }), +/* 898 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public property `depth` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetDepth(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetDepth + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetDepth = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'depth', value, step, index, direction); +}; + +module.exports = SetDepth; + + +/***/ }), +/* 899 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public property `blendMode` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetBlendMode(group.getChildren(), value)` + * + * @function Phaser.Actions.SetBlendMode + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetBlendMode = function (items, value, index, direction) +{ + return PropertyValueSet(items, 'blendMode', value, 0, index, direction); +}; + +module.exports = SetBlendMode; + + +/***/ }), +/* 900 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(20); + +/** + * Takes an array of Game Objects, or any objects that have the public property `alpha` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetAlpha(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetAlpha + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var SetAlpha = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'alpha', value, step, index, direction); +}; + +module.exports = SetAlpha; + + +/***/ }), +/* 901 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(25); + +/** + * Takes an array of Game Objects, or any objects that have a public `scaleY` property, + * and then adds the given value to each of their `scaleY` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `ScaleY(group.getChildren(), value, step)` + * + * @function Phaser.Actions.ScaleY + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `scaleY` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var ScaleY = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'scaleY', value, step, index, direction); +}; + +module.exports = ScaleY; + + +/***/ }), +/* 902 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(25); + +/** + * Takes an array of Game Objects, or any objects that have public `scaleX` and `scaleY` properties, + * and then adds the given value to each of them. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `ScaleXY(group.getChildren(), scaleX, scaleY, stepX, stepY)` + * + * @function Phaser.Actions.ScaleXY + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} scaleX - The amount to be added to the `scaleX` property. + * @param {number} [scaleY] - The amount to be added to the `scaleY` property. If `undefined` or `null` it uses the `scaleX` value. + * @param {number} [stepX=0] - This is added to the `scaleX` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `y` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var ScaleXY = function (items, scaleX, scaleY, stepX, stepY, index, direction) +{ + if (scaleY === undefined || scaleY === null) { scaleY = scaleX; } + + PropertyValueInc(items, 'scaleX', scaleX, stepX, index, direction); + + return PropertyValueInc(items, 'scaleY', scaleY, stepY, index, direction); +}; + +module.exports = ScaleXY; + + +/***/ }), +/* 903 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(25); + +/** + * Takes an array of Game Objects, or any objects that have a public `scaleX` property, + * and then adds the given value to each of their `scaleX` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `ScaleX(group.getChildren(), value, step)` + * + * @function Phaser.Actions.ScaleX + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `scaleX` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var ScaleX = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'scaleX', value, step, index, direction); +}; + +module.exports = ScaleX; + + +/***/ }), +/* 904 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MathRotateAroundDistance = __webpack_require__(160); + +/** + * [description] + * + * @function Phaser.Actions.RotateAroundDistance + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {object} point - Any object with public `x` and `y` properties. + * @param {number} angle - The angle to rotate by, in radians. + * @param {number} distance - The distance from the point of rotation in pixels. + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var RotateAroundDistance = function (items, point, angle, distance) +{ + var x = point.x; + var y = point.y; + + // There's nothing to do + if (distance === 0) + { + return items; + } + + for (var i = 0; i < items.length; i++) + { + MathRotateAroundDistance(items[i], x, y, angle, distance); + } + + return items; +}; + +module.exports = RotateAroundDistance; + + +/***/ }), +/* 905 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RotateAroundDistance = __webpack_require__(160); +var DistanceBetween = __webpack_require__(48); + +/** + * [description] + * + * @function Phaser.Actions.RotateAround + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {object} point - Any object with public `x` and `y` properties. + * @param {number} angle - The angle to rotate by, in radians. + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var RotateAround = function (items, point, angle) +{ + var x = point.x; + var y = point.y; + + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + + RotateAroundDistance(item, x, y, angle, Math.max(1, DistanceBetween(item.x, item.y, x, y))); + } + + return items; +}; + +module.exports = RotateAround; + + +/***/ }), +/* 906 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(25); + +/** + * Takes an array of Game Objects, or any objects that have a public `rotation` property, + * and then adds the given value to each of their `rotation` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `Rotate(group.getChildren(), value, step)` + * + * @function Phaser.Actions.Rotate + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `rotation` property (in radians). + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var Rotate = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'rotation', value, step, index, direction); +}; + +module.exports = Rotate; + + +/***/ }), +/* 907 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Random = __webpack_require__(161); + +/** + * [description] + * + * @function Phaser.Actions.RandomTriangle + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Triangle} triangle - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var RandomTriangle = function (items, triangle) +{ + for (var i = 0; i < items.length; i++) + { + Random(triangle, items[i]); + } + + return items; +}; + +module.exports = RandomTriangle; + + +/***/ }), +/* 908 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Random = __webpack_require__(163); + +/** + * [description] + * + * @function Phaser.Actions.RandomRectangle + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var RandomRectangle = function (items, rect) +{ + for (var i = 0; i < items.length; i++) + { + Random(rect, items[i]); + } + + return items; +}; + +module.exports = RandomRectangle; + + +/***/ }), +/* 909 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Random = __webpack_require__(164); + +/** + * [description] + * + * @function Phaser.Actions.RandomLine + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Line} line - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var RandomLine = function (items, line) +{ + for (var i = 0; i < items.length; i++) + { + Random(line, items[i]); + } + + return items; +}; + +module.exports = RandomLine; + + +/***/ }), +/* 910 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Random = __webpack_require__(162); + +/** + * [description] + * + * @function Phaser.Actions.RandomEllipse + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Ellipse} ellipse - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var RandomEllipse = function (items, ellipse) +{ + for (var i = 0; i < items.length; i++) + { + Random(ellipse, items[i]); + } + + return items; +}; + +module.exports = RandomEllipse; + + +/***/ }), +/* 911 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Random = __webpack_require__(167); + +/** + * [description] + * + * @function Phaser.Actions.RandomCircle + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Circle} circle - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var RandomCircle = function (items, circle) +{ + for (var i = 0; i < items.length; i++) + { + Random(circle, items[i]); + } + + return items; +}; + +module.exports = RandomCircle; + + +/***/ }), +/* 912 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Actions.PlayAnimation + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {string} key - [description] + * @param {(string|integer)} [startFrame] - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var PlayAnimation = function (items, key, startFrame) +{ + for (var i = 0; i < items.length; i++) + { + items[i].anims.play(key, startFrame); + } + + return items; +}; + +module.exports = PlayAnimation; + + +/***/ }), +/* 913 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// var GetPointsOnLine = require('../geom/line/GetPointsOnLine'); +var BresenhamPoints = __webpack_require__(344); + +/** + * [description] + * + * @function Phaser.Actions.PlaceOnTriangle + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} [stepRate=1] - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var PlaceOnTriangle = function (items, triangle, stepRate) +{ + var p1 = BresenhamPoints({ x1: triangle.x1, y1: triangle.y1, x2: triangle.x2, y2: triangle.y2 }, stepRate); + var p2 = BresenhamPoints({ x1: triangle.x2, y1: triangle.y2, x2: triangle.x3, y2: triangle.y3 }, stepRate); + var p3 = BresenhamPoints({ x1: triangle.x3, y1: triangle.y3, x2: triangle.x1, y2: triangle.y1 }, stepRate); + + // Remove overlaps + p1.pop(); + p2.pop(); + p3.pop(); + + p1 = p1.concat(p2, p3); + + var step = p1.length / items.length; + var p = 0; + + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + var point = p1[Math.floor(p)]; + + item.x = point.x; + item.y = point.y; + + p += step; + } + + return items; +}; + +module.exports = PlaceOnTriangle; + + +/***/ }), +/* 914 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MarchingAnts = __webpack_require__(347); +var RotateLeft = __webpack_require__(346); +var RotateRight = __webpack_require__(345); + +// Place the items in the array around the perimeter of the given rectangle. + +// Placement starts from the top-left of the rectangle, and proceeds in a +// clockwise direction. If the shift parameter is given you can offset where +// placement begins. + +/** + * [description] + * + * @function Phaser.Actions.PlaceOnRectangle + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {integer} [shift=1] - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var PlaceOnRectangle = function (items, rect, shift) +{ + if (shift === undefined) { shift = 0; } + + var points = MarchingAnts(rect, false, items.length); + + if (shift > 0) + { + RotateLeft(points, shift); + } + else if (shift < 0) + { + RotateRight(points, Math.abs(shift)); + } + + for (var i = 0; i < items.length; i++) + { + items[i].x = points[i].x; + items[i].y = points[i].y; + } + + return items; +}; + +module.exports = PlaceOnRectangle; + + +/***/ }), +/* 915 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetPoints = __webpack_require__(165); + +/** + * [description] + * + * @function Phaser.Actions.PlaceOnLine + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Line} line - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var PlaceOnLine = function (items, line) +{ + var points = GetPoints(line, items.length); + + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + var point = points[i]; + + item.x = point.x; + item.y = point.y; + } + + return items; +}; + +module.exports = PlaceOnLine; + + +/***/ }), +/* 916 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Actions.PlaceOnEllipse + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Ellipse} ellipse - [description] + * @param {number} [startAngle=0] - [description] + * @param {number} [endAngle=6.28] - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var PlaceOnEllipse = function (items, ellipse, startAngle, endAngle) +{ + if (startAngle === undefined) { startAngle = 0; } + if (endAngle === undefined) { endAngle = 6.28; } + + var angle = startAngle; + var angleStep = (endAngle - startAngle) / items.length; + + var a = ellipse.width / 2; + var b = ellipse.height / 2; + + for (var i = 0; i < items.length; i++) + { + items[i].x = ellipse.x + a * Math.cos(angle); + items[i].y = ellipse.y + b * Math.sin(angle); + + angle += angleStep; + } + + return items; +}; + +module.exports = PlaceOnEllipse; + + +/***/ }), +/* 917 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Actions.PlaceOnCircle + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Circle} circle - [description] + * @param {number} [startAngle=0] - [description] + * @param {number} [endAngle=6.28] - [description] + * + * @return {array} The array of Game Objects that was passed to this Action. + */ +var PlaceOnCircle = function (items, circle, startAngle, endAngle) +{ + if (startAngle === undefined) { startAngle = 0; } + if (endAngle === undefined) { endAngle = 6.28; } + + var angle = startAngle; + var angleStep = (endAngle - startAngle) / items.length; + + for (var i = 0; i < items.length; i++) + { + items[i].x = circle.x + (circle.radius * Math.cos(angle)); + items[i].y = circle.y + (circle.radius * Math.sin(angle)); + + angle += angleStep; + } + + return items; +}; + +module.exports = PlaceOnCircle; + + +/***/ }), +/* 918 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(25); + +/** + * Takes an array of Game Objects, or any objects that have a public `y` property, + * and then adds the given value to each of their `y` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `IncY(group.getChildren(), value, step)` + * + * @function Phaser.Actions.IncY + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `y` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var IncY = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'y', value, step, index, direction); +}; + +module.exports = IncY; + + +/***/ }), +/* 919 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(25); + +/** + * Takes an array of Game Objects, or any objects that have public `x` and `y` properties, + * and then adds the given value to each of them. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `IncXY(group.getChildren(), x, y, stepX, stepY)` + * + * @function Phaser.Actions.IncXY + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} x - The amount to be added to the `x` property. + * @param {number} [y=x] - The amount to be added to the `y` property. If `undefined` or `null` it uses the `x` value. + * @param {number} [stepX=0] - This is added to the `x` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `y` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var IncXY = function (items, x, y, stepX, stepY, index, direction) +{ + if (y === undefined || y === null) { y = x; } + + PropertyValueInc(items, 'x', x, stepX, index, direction); + + return PropertyValueInc(items, 'y', y, stepY, index, direction); +}; + +module.exports = IncXY; + + +/***/ }), +/* 920 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(25); + +/** + * Takes an array of Game Objects, or any objects that have a public `x` property, + * and then adds the given value to each of their `x` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `IncX(group.getChildren(), value, step)` + * + * @function Phaser.Actions.IncX + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `x` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var IncX = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'x', value, step, index, direction); +}; + +module.exports = IncX; + + +/***/ }), +/* 921 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(25); + +/** + * Takes an array of Game Objects, or any objects that have a public `alpha` property, + * and then adds the given value to each of their `alpha` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `IncAlpha(group.getChildren(), value, step)` + * + * @function Phaser.Actions.IncAlpha + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `alpha` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {array} The array of objects that were passed to this Action. + */ +var IncAlpha = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'alpha', value, step, index, direction); +}; + +module.exports = IncAlpha; + + +/***/ }), +/* 922 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// bitmask flag for GameObject.renderMask +var _FLAG = 1; // 0001 + +/** + * Provides methods used for setting the visibility of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Visible + * @since 3.0.0 + */ + +var Visible = { + + _visible: true, + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * + * @name Phaser.GameObjects.Components.Visible#visible + * @type {boolean} + * @since 3.0.0 + */ + visible: { + + get: function () + { + return this._visible; + }, + + set: function (value) + { + if (value) + { + this._visible = true; + this.renderFlags |= _FLAG; + } + else + { + this._visible = false; + this.renderFlags &= ~_FLAG; + } + } + + }, + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * + * @method Phaser.GameObjects.Components.Visible#setVisible + * @since 3.0.0 + * + * @param {boolean} value - The visible state of the Game Object. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setVisible: function (value) + { + this.visible = value; + + return this; + } +}; + +module.exports = Visible; + + +/***/ }), +/* 923 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(16); +var WrapAngle = __webpack_require__(175); +var WrapAngleDegrees = __webpack_require__(174); + +// global bitmask flag for GameObject.renderMask (used by Scale) +var _FLAG = 4; // 0100 + +/** + * Provides methods used for getting and setting the position, scale and rotation of a Game Object. + * + * @name Phaser.GameObjects.Components.Transform + * @since 3.0.0 + */ + +var Transform = { + + // "private" properties + _scaleX: 1, + _scaleY: 1, + _rotation: 0, + + /** + * The x position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + x: 0, + + /** + * The y position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + y: 0, + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + * + * @name Phaser.GameObjects.Components.Transform#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + z: 0, + + /** + * The w position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#w + * @type {number} + * @default 0 + * @since 3.0.0 + */ + w: 0, + + /** + * The horizontal scale of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#scaleX + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scaleX: { + + get: function () + { + return this._scaleX; + }, + + set: function (value) + { + this._scaleX = value; + + if (this._scaleX === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The vertical scale of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#scaleY + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scaleY: { + + get: function () + { + return this._scaleY; + }, + + set: function (value) + { + this._scaleY = value; + + if (this._scaleY === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The angle of this Game Object as expressed in degrees. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + * + * @name Phaser.GameObjects.Components.Transform#angle + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + angle: { + + get: function () + { + return WrapAngleDegrees(this._rotation * MATH_CONST.RAD_TO_DEG); + }, + + set: function (value) + { + // value is in degrees + this.rotation = WrapAngleDegrees(value) * MATH_CONST.DEG_TO_RAD; + } + }, + + /** + * The angle of this Game Object in radians. + * + * If you prefer to work in degrees, see the `angle` property instead. + * + * @name Phaser.GameObjects.Components.Transform#rotation + * @type {number} + * @default 1 + * @since 3.0.0 + */ + rotation: { + + get: function () + { + return this._rotation; + }, + + set: function (value) + { + // value is in radians + this._rotation = WrapAngle(value); + } + }, + + /** + * Sets the position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setPosition + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of this Game Object. + * @param {number} [y] - The y position of this Game Object. If not set it will use the `x` value. + * @param {number} [z=0] - The z position of this Game Object. + * @param {number} [w=0] - The w position of this Game Object. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setPosition: function (x, y, z, w) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + if (z === undefined) { z = 0; } + if (w === undefined) { w = 0; } + + this.x = x; + this.y = y; + this.z = z; + this.w = w; + + return this; + }, + + /** + * Sets the rotation of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setRotation + * @since 3.0.0 + * + * @param {number} [radians=0] - The rotation of this Game Object, in radians. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setRotation: function (radians) + { + if (radians === undefined) { radians = 0; } + + this.rotation = radians; + + return this; + }, + + /** + * Sets the angle of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setAngle + * @since 3.0.0 + * + * @param {number} [degrees=0] - The rotation of this Game Object, in degrees. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setAngle: function (degrees) + { + if (degrees === undefined) { degrees = 0; } + + this.angle = degrees; + + return this; + }, + + /** + * Sets the scale of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setScale + * @since 3.0.0 + * + * @param {number} x - The horizontal scale of this Game Object. + * @param {number} [y=x] - The vertical scale of this Game Object. If not set it will use the `x` value. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setScale: function (x, y) + { + if (x === undefined) { x = 1; } + if (y === undefined) { y = x; } + + this.scaleX = x; + this.scaleY = y; + + return this; + }, + + /** + * Sets the x position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setX + * @since 3.0.0 + * + * @param {number} [value=0] - The x position of this Game Object. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setX: function (value) + { + if (value === undefined) { value = 0; } + + this.x = value; + + return this; + }, + + /** + * Sets the y position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setY + * @since 3.0.0 + * + * @param {number} [value=0] - The y position of this Game Object. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setY: function (value) + { + if (value === undefined) { value = 0; } + + this.y = value; + + return this; + }, + + /** + * Sets the z position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setZ + * @since 3.0.0 + * + * @param {number} [value=0] - The z position of this Game Object. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setZ: function (value) + { + if (value === undefined) { value = 0; } + + this.z = value; + + return this; + }, + + /** + * Sets the w position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setW + * @since 3.0.0 + * + * @param {number} [value=0] - The w position of this Game Object. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setW: function (value) + { + if (value === undefined) { value = 0; } + + this.w = value; + + return this; + } + +}; + +module.exports = Transform; /***/ }), /* 924 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -123044,24 +123367,87 @@ module.exports = Clock; */ /** - * @namespace Phaser.Tweens + * @typedef {object} JSONGameObject + * @template DATA + * + * @property {string} name - The name of this Game Object. + * @property {string} type - A textual representation of this Game Object, i.e. `sprite`. + * @property {number} x - The x position of this Game Object. + * @property {number} y - The y position of this Game Object. + * @property {object} scale - The scale of this Game Object + * @property {number} scale.x - The horizontal scale of this Game Object. + * @property {number} scale.y - The vertical scale of this Game Object. + * @property {object} origin - The origin of this Game Object. + * @property {float} origin.x - The horizontal origin of this Game Object. + * @property {float} origin.y - The vertical origin of this Game Object. + * @property {boolean} flipX - The horizontally flipped state of the Game Object. + * @property {boolean} flipY - The vertically flipped state of the Game Object. + * @property {number} rotation - The angle of this Game Object in radians. + * @property {float} alpha - The alpha value of the Game Object. + * @property {boolean} visible - The visible state of the Game Object. + * @property {integer} scaleMode - The Scale Mode being used by this Game Object. + * @property {(integer|string)} blendMode - Sets the Blend Mode being used by this Game Object. + * @property {string} textureKey - The texture key of this Game Object. + * @property {string} frameKey - The frame key of this Game Object. + * @property {DATA} data - The data of this Game Object. */ -module.exports = { +// Default Game Object JSON export +// Is extended further by Game Object specific implementations - Builders: __webpack_require__(925), +/** + * [description] + * + * @method Phaser.GameObjects.Components.ToJSON + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * + * @return {JSONGameObject} [description] + */ +var ToJSON = function (gameObject) +{ + var out = { + name: gameObject.name, + type: gameObject.type, + x: gameObject.x, + y: gameObject.y, + depth: gameObject.depth, + scale: { + x: gameObject.scaleX, + y: gameObject.scaleY + }, + origin: { + x: gameObject.originX, + y: gameObject.originY + }, + flipX: gameObject.flipX, + flipY: gameObject.flipY, + rotation: gameObject.rotation, + alpha: gameObject.alpha, + visible: gameObject.visible, + scaleMode: gameObject.scaleMode, + blendMode: gameObject.blendMode, + textureKey: '', + frameKey: '', + data: {} + }; - TweenManager: __webpack_require__(927), - Tween: __webpack_require__(161), - TweenData: __webpack_require__(162), - Timeline: __webpack_require__(363) + if (gameObject.texture) + { + out.textureKey = gameObject.texture.key; + out.frameKey = gameObject.frame.name; + } + return out; }; +module.exports = ToJSON; + /***/ }), /* 925 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -123070,24 +123456,194 @@ module.exports = { */ /** - * @namespace Phaser.Tweens.Builders + * @function GetColor + * @since 3.0.0 + * @private + */ +var GetColor = function (value) +{ + return (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16); +}; + +/** + * Provides methods used for setting the tint of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Tint + * @webglOnly + * @since 3.0.0 */ -module.exports = { +var Tint = { - GetBoolean: __webpack_require__(73), - GetEaseFunction: __webpack_require__(71), - GetNewValue: __webpack_require__(101), - GetProps: __webpack_require__(359), - GetTargets: __webpack_require__(158), - GetTweens: __webpack_require__(360), - GetValueOp: __webpack_require__(159), - NumberTweenBuilder: __webpack_require__(361), - TimelineBuilder: __webpack_require__(362), - TweenBuilder: __webpack_require__(102) + // 0: topLeft, 1: topRight, 2: bottomLeft, 3: bottomRight + _tintTL: 16777215, + _tintTR: 16777215, + _tintBL: 16777215, + _tintBR: 16777215, + + /** + * Clears all tint values associated with this Game Object. + * Immediately sets the alpha levels back to 0xffffff (no tint) + * + * @method Phaser.GameObjects.Components.Tint#clearTint + * @webglOnly + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + clearTint: function () + { + this.setTint(0xffffff); + + return this; + }, + + /** + * Sets the tint values for this Game Object. + * + * @method Phaser.GameObjects.Components.Tint#setTint + * @webglOnly + * @since 3.0.0 + * + * @param {integer} [topLeft=0xffffff] - The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. + * @param {integer} [topRight] - The tint being applied to the top-right of the Game Object. + * @param {integer} [bottomLeft] - The tint being applied to the bottom-left of the Game Object. + * @param {integer} [bottomRight] - The tint being applied to the bottom-right of the Game Object. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setTint: function (topLeft, topRight, bottomLeft, bottomRight) + { + if (topLeft === undefined) { topLeft = 0xffffff; } + + if (topRight === undefined) + { + topRight = topLeft; + bottomLeft = topLeft; + bottomRight = topLeft; + } + + this._tintTL = GetColor(topLeft); + this._tintTR = GetColor(topRight); + this._tintBL = GetColor(bottomLeft); + this._tintBR = GetColor(bottomRight); + + return this; + }, + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintTopLeft + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintTopLeft: { + + get: function () + { + return this._tintTL; + }, + + set: function (value) + { + this._tintTL = GetColor(value); + } + + }, + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintTopRight + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintTopRight: { + + get: function () + { + return this._tintTR; + }, + + set: function (value) + { + this._tintTR = GetColor(value); + } + + }, + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintBottomLeft + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintBottomLeft: { + + get: function () + { + return this._tintBL; + }, + + set: function (value) + { + this._tintBL = GetColor(value); + } + + }, + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintBottomRight + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintBottomRight: { + + get: function () + { + return this._tintBR; + }, + + set: function (value) + { + this._tintBR = GetColor(value); + } + + }, + + /** + * The tint value being applied to the whole of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tint + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tint: { + + set: function (value) + { + this.setTint(value, value, value, value); + } + } }; +module.exports = Tint; + /***/ }), /* 926 */ @@ -123099,71 +123655,119 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// RESERVED properties that a Tween config object uses +// bitmask flag for GameObject.renderMask +var _FLAG = 8; // 1000 -// completeDelay: The time the tween will wait before the onComplete event is dispatched once it has completed -// delay: The time the tween will wait before it first starts -// duration: The duration of the tween -// ease: The ease function used by the tween -// easeParams: The parameters to go with the ease function (if any) -// flipX: flip X the GameObject on tween end -// flipY: flip Y the GameObject on tween end// hold: The time the tween will pause before running a yoyo -// hold: The time the tween will pause before running a yoyo -// loop: The time the tween will pause before starting either a yoyo or returning to the start for a repeat -// loopDelay: -// offset: Used when the Tween is part of a Timeline -// paused: Does the tween start in a paused state, or playing? -// props: The properties being tweened by the tween -// repeat: The number of times the tween will repeat itself (a value of 1 means the tween will play twice, as it repeated once) -// repeatDelay: The time the tween will pause for before starting a repeat. The tween holds in the start state. -// targets: The targets the tween is updating. -// useFrames: Use frames or milliseconds? -// yoyo: boolean - Does the tween reverse itself (yoyo) when it reaches the end? +/** + * Provides methods used for getting and setting the texture of a Game Object. + * + * @name Phaser.GameObjects.Components.Texture + * @since 3.0.0 + */ -module.exports = [ - 'callbackScope', - 'completeDelay', - 'delay', - 'duration', - 'ease', - 'easeParams', - 'flipX', - 'flipY', - 'hold', - 'loop', - 'loopDelay', - 'offset', - 'onComplete', - 'onCompleteParams', - 'onCompleteScope', - 'onLoop', - 'onLoopParams', - 'onLoopScope', - 'onRepeat', - 'onRepeatParams', - 'onRepeatScope', - 'onStart', - 'onStartParams', - 'onStartScope', - 'onUpdate', - 'onUpdateParams', - 'onUpdateScope', - 'onYoyo', - 'onYoyoParams', - 'onYoyoScope', - 'paused', - 'props', - 'repeat', - 'repeatDelay', - 'targets', - 'useFrames', - 'yoyo' -]; +var Texture = { + + /** + * The Texture this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Texture#texture + * @type {Phaser.Textures.Texture} + * @since 3.0.0 + */ + texture: null, + + /** + * The Texture Frame this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Texture#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + frame: null, + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * @method Phaser.GameObjects.Components.Texture#setTexture + * @since 3.0.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setTexture: function (key, frame) + { + this.texture = this.scene.sys.textures.get(key); + + return this.setFrame(frame); + }, + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * + * @method Phaser.GameObjects.Components.Texture#setFrame + * @since 3.0.0 + * + * @param {(string|integer)} frame - The name or index of the frame within the Texture. + * @param {boolean} [updateSize=true] - Should this call adjust the size of the Game Object? + * @param {boolean} [updateOrigin=true] - Should this call adjust the origin of the Game Object? + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setFrame: function (frame, updateSize, updateOrigin) + { + if (updateSize === undefined) { updateSize = true; } + if (updateOrigin === undefined) { updateOrigin = true; } + + this.frame = this.texture.get(frame); + + if (!this.frame.cutWidth || !this.frame.cutHeight) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + + if (this._sizeComponent && updateSize) + { + this.setSizeToFrame(); + } + + if (this._originComponent && updateOrigin) + { + if (this.frame.customPivot) + { + this.setOrigin(this.frame.pivotX, this.frame.pivotY); + } + else + { + this.updateDisplayOrigin(); + } + } + + return this; + } + +}; + +module.exports = Texture; /***/ }), /* 927 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -123171,653 +123775,155 @@ module.exports = [ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var NumberTweenBuilder = __webpack_require__(361); -var PluginManager = __webpack_require__(12); -var TimelineBuilder = __webpack_require__(362); -var TWEEN_CONST = __webpack_require__(87); -var TweenBuilder = __webpack_require__(102); - -// Phaser.Tweens.TweenManager - /** - * @classdesc - * [description] - * - * @class TweenManager - * @memberOf Phaser.Tweens - * @constructor + * Provides methods used for getting and setting the size of a Game Object. + * + * @name Phaser.GameObjects.Components.Size * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] */ -var TweenManager = new Class({ - initialize: +var Size = { - function TweenManager (scene) - { - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; + /** + * A property indicating that a Game Object has this component. + * + * @name Phaser.GameObjects.Components.Size#_sizeComponent + * @type {boolean} + * @private + * @default true + * @since 3.2.0 + */ + _sizeComponent: true, - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; + /** + * The native (un-scaled) width of this Game Object. + * + * @name Phaser.GameObjects.Components.Size#width + * @type {number} + * @since 3.0.0 + */ + width: 0, - if (!scene.sys.settings.isBooted) + /** + * The native (un-scaled) height of this Game Object. + * + * @name Phaser.GameObjects.Components.Size#height + * @type {number} + * @since 3.0.0 + */ + height: 0, + + /** + * The displayed width of this Game Object. + * This value takes into account the scale factor. + * + * @name Phaser.GameObjects.Components.Size#displayWidth + * @type {number} + * @since 3.0.0 + */ + displayWidth: { + + get: function () { - scene.sys.events.once('boot', this.boot, this); + return this.scaleX * this.frame.realWidth; + }, + + set: function (value) + { + this.scaleX = value / this.frame.realWidth; } - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#timeScale - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#_add - * @type {array} - * @private - * @since 3.0.0 - */ - this._add = []; - - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#_pending - * @type {array} - * @private - * @since 3.0.0 - */ - this._pending = []; - - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#_active - * @type {array} - * @private - * @since 3.0.0 - */ - this._active = []; - - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#_destroy - * @type {array} - * @private - * @since 3.0.0 - */ - this._destroy = []; - - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#_toProcess - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - this._toProcess = 0; }, /** - * [description] - * - * @method Phaser.Tweens.TweenManager#boot + * The displayed height of this Game Object. + * This value takes into account the scale factor. + * + * @name Phaser.GameObjects.Components.Size#displayHeight + * @type {number} * @since 3.0.0 */ - boot: function () - { - var eventEmitter = this.systems.events; + displayHeight: { - eventEmitter.on('preupdate', this.preUpdate, this); - eventEmitter.on('update', this.update, this); - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); - - this.timeScale = 1; - }, - - /** - * Create a Tween Timeline and return it, but do NOT add it to the active or pending Tween lists. - * - * @method Phaser.Tweens.TweenManager#createTimeline - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.Tweens.Timeline} [description] - */ - createTimeline: function (config) - { - return TimelineBuilder(this, config); - }, - - /** - * Create a Tween Timeline and add it to the active Tween list/ - * - * @method Phaser.Tweens.TweenManager#timeline - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.Tweens.Timeline} [description] - */ - timeline: function (config) - { - var timeline = TimelineBuilder(this, config); - - if (!timeline.paused) + get: function () { - this._add.push(timeline); + return this.scaleY * this.frame.realHeight; + }, - this._toProcess++; + set: function (value) + { + this.scaleY = value / this.frame.realHeight; } - return timeline; }, /** - * Create a Tween and return it, but do NOT add it to the active or pending Tween lists. - * - * @method Phaser.Tweens.TweenManager#create + * Sets the size of this Game Object to be that of the given Frame. + * + * @method Phaser.GameObjects.Components.Size#setSizeToFrame * @since 3.0.0 * - * @param {object} config - [description] - * - * @return {Phaser.Tweens.Tween} [description] + * @param {Phaser.Textures.Frame} frame - The frame to base the size of this Game Object on. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. */ - create: function (config) + setSizeToFrame: function (frame) { - return TweenBuilder(this, config); - }, + if (frame === undefined) { frame = this.frame; } - /** - * Create a Tween and add it to the active Tween list. - * - * @method Phaser.Tweens.TweenManager#add - * @since 3.0.0 - * - * @param {[type]} config - [description] - * - * @return {Phaser.Tweens.Tween} [description] - */ - add: function (config) - { - var tween = TweenBuilder(this, config); - - this._add.push(tween); - - this._toProcess++; - - return tween; - }, - - /** - * Add an existing tween into the active Tween list. - * - * @method Phaser.Tweens.TweenManager#existing - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * - * @return {Phaser.Tweens.TweenManager} This Tween Manager object. - */ - existing: function (tween) - { - this._add.push(tween); - - this._toProcess++; + this.width = frame.realWidth; + this.height = frame.realHeight; return this; }, /** - * Create a Tween and add it to the active Tween list. - * - * @method Phaser.Tweens.TweenManager#addCounter + * Sets the size of this Game Object. + * + * @method Phaser.GameObjects.Components.Size#setSize * @since 3.0.0 * - * @param {object} config - [description] - * - * @return {Phaser.Tweens.Tween} [description] + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. */ - addCounter: function (config) + setSize: function (width, height) { - var tween = NumberTweenBuilder(this, config); - - this._add.push(tween); - - this._toProcess++; - - return tween; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#preUpdate - * @since 3.0.0 - */ - preUpdate: function () - { - if (this._toProcess === 0) - { - // Quick bail - return; - } - - var list = this._destroy; - var active = this._active; - var i; - var tween; - - // Clear the 'destroy' list - for (i = 0; i < list.length; i++) - { - tween = list[i]; - - // Remove from the 'active' array - var idx = active.indexOf(tween); - - if (idx !== -1) - { - tween.state = TWEEN_CONST.REMOVED; - active.splice(idx, 1); - } - } - - list.length = 0; - - // Process the addition list - // This stops callbacks and out of sync events from populating the active array mid-way during the update - - list = this._add; - - for (i = 0; i < list.length; i++) - { - tween = list[i]; - - // Return true if the Tween should be started right away, otherwise false - if (tween.init()) - { - tween.play(); - - this._active.push(tween); - } - else - { - this._pending.push(tween); - } - } - - list.length = 0; - - this._toProcess = 0; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#update - * @since 3.0.0 - * - * @param {number} timestamp - [description] - * @param {number} delta - [description] - */ - update: function (timestamp, delta) - { - // Process active tweens - var list = this._active; - var tween; - - // Scale the delta - delta *= this.timeScale; - - for (var i = 0; i < list.length; i++) - { - tween = list[i]; - - // If Tween.update returns 'true' then it means it has completed, - // so move it to the destroy list - if (tween.update(timestamp, delta)) - { - this._destroy.push(tween); - this._toProcess++; - } - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#makeActive - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * - * @return {Phaser.Tweens.TweenManager} This Tween Manager object. - */ - makeActive: function (tween) - { - if (this._add.indexOf(tween) !== -1 || this._active.indexOf(tween) !== -1) - { - return; - } - - var idx = this._pending.indexOf(tween); - - if (idx !== -1) - { - this._pending.splice(idx, 1); - } - - this._add.push(tween); - - tween.state = TWEEN_CONST.PENDING_ADD; - - this._toProcess++; + this.width = width; + this.height = height; return this; }, /** - * Passes all Tweens to the given callback. - * - * @method Phaser.Tweens.TweenManager#each + * Sets the display size of this Game Object. + * Calling this will adjust the scale. + * + * @method Phaser.GameObjects.Components.Size#setDisplaySize * @since 3.0.0 * - * @param {function} callback - [description] - * @param {object} [scope] - [description] - * @param {...*} [arguments] - [description] + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. */ - each: function (callback, scope) + setDisplaySize: function (width, height) { - var args = [ null ]; - - for (var i = 1; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - for (var texture in this.list) - { - args[0] = this.list[texture]; - - callback.apply(scope, args); - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#getAllTweens - * @since 3.0.0 - * - * @return {Phaser.Tweens.Tween[]} [description] - */ - getAllTweens: function () - { - var list = this._active; - var output = []; - - for (var i = 0; i < list.length; i++) - { - output.push(list[i]); - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#getGlobalTimeScale - * @since 3.0.0 - * - * @return {number} [description] - */ - getGlobalTimeScale: function () - { - return this.timeScale; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#getTweensOf - * @since 3.0.0 - * - * @param {object|array} target - [description] - * - * @return {Phaser.Tweens.Tween[]} [description] - */ - getTweensOf: function (target) - { - var list = this._active; - var tween; - var output = []; - var i; - - if (Array.isArray(target)) - { - for (i = 0; i < list.length; i++) - { - tween = list[i]; - - for (var t = 0; t < target.length; i++) - { - if (tween.hasTarget(target[t])) - { - output.push(tween); - } - } - } - } - else - { - for (i = 0; i < list.length; i++) - { - tween = list[i]; - - if (tween.hasTarget(target)) - { - output.push(tween); - } - } - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#isTweening - * @since 3.0.0 - * - * @param {object} target - [description] - * - * @return {boolean} [description] - */ - isTweening: function (target) - { - var list = this._active; - var tween; - - for (var i = 0; i < list.length; i++) - { - tween = list[i]; - - if (tween.hasTarget(target) && tween.isPlaying()) - { - return true; - } - } - - return false; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#killAll - * @since 3.0.0 - * - * @return {Phaser.Tweens.TweenManager} [description] - */ - killAll: function () - { - var tweens = this.getAllTweens(); - - for (var i = 0; i < tweens.length; i++) - { - tweens[i].stop(); - } + this.displayWidth = width; + this.displayHeight = height; return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#killTweensOf - * @since 3.0.0 - * - * @param {object|array} target - [description] - * - * @return {Phaser.Tweens.TweenManager} [description] - */ - killTweensOf: function (target) - { - var tweens = this.getTweensOf(target); - - for (var i = 0; i < tweens.length; i++) - { - tweens[i].stop(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#pauseAll - * @since 3.0.0 - * - * @return {Phaser.Tweens.TweenManager} [description] - */ - pauseAll: function () - { - var list = this._active; - - for (var i = 0; i < list.length; i++) - { - list[i].pause(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#resumeAll - * @since 3.0.0 - * - * @return {Phaser.Tweens.TweenManager} [description] - */ - resumeAll: function () - { - var list = this._active; - - for (var i = 0; i < list.length; i++) - { - list[i].resume(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#setGlobalTimeScale - * @since 3.0.0 - * - * @param {float} value - [description] - * - * @return {Phaser.Tweens.TweenManager} [description] - */ - setGlobalTimeScale: function (value) - { - this.timeScale = value; - - return this; - }, - - /** - * Scene that owns this manager is shutting down. - * - * @method Phaser.Tweens.TweenManager#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this.killAll(); - - this._add = []; - this._pending = []; - this._active = []; - this._destroy = []; - - this._toProcess = 0; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.shutdown(); } -}); +}; -PluginManager.register('TweenManager', TweenManager, 'tweens'); - -module.exports = TweenManager; +module.exports = Size; /***/ }), /* 928 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -123826,17 +123932,86 @@ module.exports = TweenManager; */ /** - * @namespace Phaser.Utils + * Provides methods used for getting and setting the Scroll Factor of a Game Object. + * + * @name Phaser.GameObjects.Components.ScrollFactor + * @since 3.0.0 */ -module.exports = { +var ScrollFactor = { - Array: __webpack_require__(929), - Objects: __webpack_require__(933), - String: __webpack_require__(937) + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorX + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scrollFactorX: 1, + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorY + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scrollFactorY: 1, + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * @method Phaser.GameObjects.Components.ScrollFactor#setScrollFactor + * @since 3.0.0 + * + * @param {number} x - The horizontal scroll factor of this Game Object. + * @param {number} [y] - The vertical scroll factor of this Game Object. If not set it will use the `x` value. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setScrollFactor: function (x, y) + { + if (y === undefined) { y = x; } + + this.scrollFactorX = x; + this.scrollFactorY = y; + + return this; + } }; +module.exports = ScrollFactor; + /***/ }), /* 929 */ @@ -123848,26 +124023,66 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var ScaleModes = __webpack_require__(80); + /** - * @namespace Phaser.Utils.Array + * Provides methods used for getting and setting the scale of a Game Object. + * + * @name Phaser.GameObjects.Components.ScaleMode + * @since 3.0.0 */ -module.exports = { +var ScaleMode = { - FindClosestInSorted: __webpack_require__(930), - GetRandomElement: __webpack_require__(140), - NumberArray: __webpack_require__(319), - NumberArrayStep: __webpack_require__(931), - QuickSelect: __webpack_require__(338), - Range: __webpack_require__(275), - RemoveRandomElement: __webpack_require__(932), - RotateLeft: __webpack_require__(192), - RotateRight: __webpack_require__(193), - Shuffle: __webpack_require__(80), - SpliceOne: __webpack_require__(364) + _scaleMode: ScaleModes.DEFAULT, + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * + * @name Phaser.GameObjects.Components.ScaleMode#scaleMode + * @type {integer} + * @since 3.0.0 + */ + scaleMode: { + + get: function () + { + return this._scaleMode; + }, + + set: function (value) + { + if (value === ScaleModes.LINEAR || value === ScaleModes.NEAREST) + { + this._scaleMode = value; + } + } + + }, + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * + * @method Phaser.GameObjects.Components.ScaleMode#setScaleMode + * @since 3.0.0 + * + * @param {integer} value - The Scale Mode to be used by this Game Object. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setScaleMode: function (value) + { + this.scaleMode = value; + + return this; + } }; +module.exports = ScaleMode; + /***/ }), /* 930 */ @@ -123880,46 +124095,201 @@ module.exports = { */ /** - * [description] - * - * @function Phaser.Utils.Array.FindClosestInSorted + * Provides methods used for getting and setting the origin of a Game Object. + * Values are normalized, given in the range 0 to 1. + * Display values contain the calculated pixel values. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Origin * @since 3.0.0 - * - * @param {number} value - The value to search for in the array. - * @param {array} array - The array to search, which must be sorted. - * - * @return {number} The nearest value found in the array. */ -var FindClosestInSorted = function (value, array) -{ - if (!array.length) + +var Origin = { + + /** + * A property indicating that a Game Object has this component. + * + * @name Phaser.GameObjects.Components.Origin#_originComponent + * @type {boolean} + * @private + * @default true + * @since 3.2.0 + */ + _originComponent: true, + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + * + * @name Phaser.GameObjects.Components.Origin#originX + * @type {float} + * @default 0.5 + * @since 3.0.0 + */ + originX: 0.5, + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + * + * @name Phaser.GameObjects.Components.Origin#originY + * @type {float} + * @default 0.5 + * @since 3.0.0 + */ + originY: 0.5, + + // private + read only + _displayOriginX: 0, + _displayOriginY: 0, + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * + * @name Phaser.GameObjects.Components.Origin#displayOriginX + * @type {float} + * @since 3.0.0 + */ + displayOriginX: { + + get: function () + { + return this._displayOriginX; + }, + + set: function (value) + { + this._displayOriginX = value; + this.originX = value / this.width; + } + + }, + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * + * @name Phaser.GameObjects.Components.Origin#displayOriginY + * @type {float} + * @since 3.0.0 + */ + displayOriginY: { + + get: function () + { + return this._displayOriginY; + }, + + set: function (value) + { + this._displayOriginY = value; + this.originY = value / this.height; + } + + }, + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * + * @method Phaser.GameObjects.Components.Origin#setOrigin + * @since 3.0.0 + * + * @param {number} [x=0.5] - The horizontal origin value. + * @param {number} [y=0.5] - The vertical origin value. If not defined it will be set to the value of `x`. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setOrigin: function (x, y) { - return NaN; - } - else if (array.length === 1 || value < array[0]) + if (x === undefined) { x = 0.5; } + if (y === undefined) { y = x; } + + this.originX = x; + this.originY = y; + + return this.updateDisplayOrigin(); + }, + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + * + * @method Phaser.GameObjects.Components.Origin#setOriginFromFrame + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setOriginFromFrame: function () { - return array[0]; + if (!this.frame || !this.frame.customPivot) + { + return this.setOrigin(); + } + else + { + this.originX = this.frame.pivotX; + this.originY = this.frame.pivotY; + } + + return this.updateDisplayOrigin(); + }, + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * + * @method Phaser.GameObjects.Components.Origin#setDisplayOrigin + * @since 3.0.0 + * + * @param {number} [x=0] - The horizontal display origin value. + * @param {number} [y=0] - The vertical display origin value. If not defined it will be set to the value of `x`. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setDisplayOrigin: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + + this.displayOriginX = x; + this.displayOriginY = y; + + return this; + }, + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + * + * @method Phaser.GameObjects.Components.Origin#updateDisplayOrigin + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + updateDisplayOrigin: function () + { + this._displayOriginX = Math.round(this.originX * this.width); + this._displayOriginY = Math.round(this.originY * this.height); + + return this; } - var i = 1; - - while (array[i] < value) - { - i++; - } - - var low = array[i - 1]; - var high = (i < array.length) ? array[i] : Number.POSITIVE_INFINITY; - - return ((high - value) <= (value - low)) ? high : low; }; -module.exports = FindClosestInSorted; +module.exports = Origin; /***/ }), /* 931 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -123927,71 +124297,282 @@ module.exports = FindClosestInSorted; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RoundAwayFromZero = __webpack_require__(325); - /** - * Create an array of numbers (positive and/or negative) progressing from `start` - * up to but not including `end` by advancing by `step`. - * - * If `start` is less than `end` a zero-length range is created unless a negative `step` is specified. - * - * Certain values for `start` and `end` (eg. NaN/undefined/null) are currently coerced to 0; - * for forward compatibility make sure to pass in actual numbers. + * Provides methods used for getting and setting the transform values of a Game Object. + * Should be applied as a mixin and not used directly. * - * @example - * NumberArrayStep(4); - * // => [0, 1, 2, 3] - * - * NumberArrayStep(1, 5); - * // => [1, 2, 3, 4] - * - * NumberArrayStep(0, 20, 5); - * // => [0, 5, 10, 15] - * - * NumberArrayStep(0, -4, -1); - * // => [0, -1, -2, -3] - * - * NumberArrayStep(1, 4, 0); - * // => [1, 1, 1] - * - * NumberArrayStep(0); - * // => [] - * - * @function Phaser.Utils.Array.NumberArrayStep - * @since 3.0.0 - * - * @param {number} [start=0] - The start of the range. - * @param {number} [end=null] - The end of the range. - * @param {number} [step=1] - The value to increment or decrement by. - * - * @return {number[]} [description] + * @name Phaser.GameObjects.Components.MatrixStack + * @since 3.2.0 */ -var NumberArrayStep = function (start, end, step) -{ - if (start === undefined) { start = 0; } - if (end === undefined) { end = null; } - if (step === undefined) { step = 1; } - if (end === null) +var MatrixStack = { + + /** + * [description] + * + * @name Phaser.GameObjects.Components.MatrixStack#matrixStack + * @type {Float32Array} + * @private + * @since 3.2.0 + */ + matrixStack: null, + + /** + * [description] + * + * @name Phaser.GameObjects.Components.MatrixStack#currentMatrix + * @type {Float32Array} + * @private + * @since 3.2.0 + */ + currentMatrix: null, + + /** + * [description] + * + * @name Phaser.GameObjects.Components.MatrixStack#currentMatrixIndex + * @type {integer} + * @private + * @since 3.2.0 + */ + currentMatrixIndex: 0, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.MatrixStack#initMatrixStack + * @since 3.2.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + initMatrixStack: function () { - end = start; - start = 0; + this.matrixStack = new Float32Array(6000); // up to 1000 matrices + this.currentMatrix = new Float32Array([ 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 ]); + this.currentMatrixIndex = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.MatrixStack#save + * @since 3.2.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + save: function () + { + if (this.currentMatrixIndex >= this.matrixStack.length) { return this; } + + var matrixStack = this.matrixStack; + var currentMatrix = this.currentMatrix; + var currentMatrixIndex = this.currentMatrixIndex; + this.currentMatrixIndex += 6; + + matrixStack[currentMatrixIndex + 0] = currentMatrix[0]; + matrixStack[currentMatrixIndex + 1] = currentMatrix[1]; + matrixStack[currentMatrixIndex + 2] = currentMatrix[2]; + matrixStack[currentMatrixIndex + 3] = currentMatrix[3]; + matrixStack[currentMatrixIndex + 4] = currentMatrix[4]; + matrixStack[currentMatrixIndex + 5] = currentMatrix[5]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.MatrixStack#restore + * @since 3.2.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + restore: function () + { + if (this.currentMatrixIndex <= 0) { return this; } + + this.currentMatrixIndex -= 6; + + var matrixStack = this.matrixStack; + var currentMatrix = this.currentMatrix; + var currentMatrixIndex = this.currentMatrixIndex; + + currentMatrix[0] = matrixStack[currentMatrixIndex + 0]; + currentMatrix[1] = matrixStack[currentMatrixIndex + 1]; + currentMatrix[2] = matrixStack[currentMatrixIndex + 2]; + currentMatrix[3] = matrixStack[currentMatrixIndex + 3]; + currentMatrix[4] = matrixStack[currentMatrixIndex + 4]; + currentMatrix[5] = matrixStack[currentMatrixIndex + 5]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.MatrixStack#loadIdentity + * @since 3.2.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + loadIdentity: function () + { + this.setTransform(1.0, 0.0, 0.0, 1.0, 0.0, 0.0); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.MatrixStack#transform + * @since 3.2.0 + * + * @param {number} a - [description] + * @param {number} b - [description] + * @param {number} c - [description] + * @param {number} d - [description] + * @param {number} tx - [description] + * @param {number} ty - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + transform: function (a, b, c, d, tx, ty) + { + var currentMatrix = this.currentMatrix; + var m0 = currentMatrix[0]; + var m1 = currentMatrix[1]; + var m2 = currentMatrix[2]; + var m3 = currentMatrix[3]; + var m4 = currentMatrix[4]; + var m5 = currentMatrix[5]; + + currentMatrix[0] = m0 * a + m2 * b; + currentMatrix[1] = m1 * a + m3 * b; + currentMatrix[2] = m0 * c + m2 * d; + currentMatrix[3] = m1 * c + m3 * d; + currentMatrix[4] = m0 * tx + m2 * ty + m4; + currentMatrix[5] = m1 * tx + m3 * ty + m5; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.MatrixStack#setTransform + * @since 3.2.0 + * + * @param {number} a - [description] + * @param {number} b - [description] + * @param {number} c - [description] + * @param {number} d - [description] + * @param {number} tx - [description] + * @param {number} ty - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setTransform: function (a, b, c, d, tx, ty) + { + var currentMatrix = this.currentMatrix; + + currentMatrix[0] = a; + currentMatrix[1] = b; + currentMatrix[2] = c; + currentMatrix[3] = d; + currentMatrix[4] = tx; + currentMatrix[5] = ty; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.MatrixStack#translate + * @since 3.2.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + translate: function (x, y) + { + var currentMatrix = this.currentMatrix; + var m0 = currentMatrix[0]; + var m1 = currentMatrix[1]; + var m2 = currentMatrix[2]; + var m3 = currentMatrix[3]; + var m4 = currentMatrix[4]; + var m5 = currentMatrix[5]; + + currentMatrix[4] = m0 * x + m2 * y + m4; + currentMatrix[5] = m1 * x + m3 * y + m5; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.MatrixStack#scale + * @since 3.2.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + scale: function (x, y) + { + var currentMatrix = this.currentMatrix; + var m0 = currentMatrix[0]; + var m1 = currentMatrix[1]; + var m2 = currentMatrix[2]; + var m3 = currentMatrix[3]; + + currentMatrix[0] = m0 * x; + currentMatrix[1] = m1 * x; + currentMatrix[2] = m2 * y; + currentMatrix[3] = m3 * y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Components.MatrixStack#rotate + * @since 3.2.0 + * + * @param {number} t - The angle of rotation, in radians. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + rotate: function (t) + { + var currentMatrix = this.currentMatrix; + var m0 = currentMatrix[0]; + var m1 = currentMatrix[1]; + var m2 = currentMatrix[2]; + var m3 = currentMatrix[3]; + var st = Math.sin(t); + var ct = Math.cos(t); + + currentMatrix[0] = m0 * ct + m2 * st; + currentMatrix[1] = m1 * ct + m3 * st; + currentMatrix[2] = m0 * -st + m2 * ct; + currentMatrix[3] = m1 * -st + m3 * ct; + + return this; } - var result = []; - - var total = Math.max(RoundAwayFromZero((end - start) / (step || 1)), 0); - - for (var i = 0; i < total; i++) - { - result.push(start); - start += step; - } - - return result; }; -module.exports = NumberArrayStep; +module.exports = MatrixStack; /***/ }), @@ -124004,37 +124585,193 @@ module.exports = NumberArrayStep; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var SpliceOne = __webpack_require__(364); +var Rectangle = __webpack_require__(10); +var RotateAround = __webpack_require__(350); +var Vector2 = __webpack_require__(6); /** - * Removes a random object from the given array and returns it. - * Will return null if there are no array items that fall within the specified range or if there is no item for the randomly chosen index. + * Provides methods used for obtaining the bounds of a Game Object. + * Should be applied as a mixin and not used directly. * - * @function Phaser.Utils.Array.RemoveRandomElement + * @name Phaser.GameObjects.Components.GetBounds * @since 3.0.0 - * - * @param {array} array - The array to removed a random element from. - * @param {integer} [start=0] - The array index to start the search from. - * @param {integer} [length=array.length] - Optional restriction on the number of elements to randomly select from. - * - * @return {object} The random element that was removed, or `null` if there were no array elements that fell within the given range. */ -var RemoveRandomElement = function (array, start, length) -{ - if (start === undefined) { start = 0; } - if (length === undefined) { length = array.length; } - var randomIndex = start + Math.floor(Math.random() * length); +var GetBounds = { + + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * + * @method Phaser.GameObjects.Components.GetBounds#getCenter + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|object)} [output] - An object to store the values in. If not provided a new Vector2 will be created. + * + * @return {(Phaser.Math.Vector2|object)} The values stored in the output object. + */ + getCenter: function (output) + { + if (output === undefined) { output = new Vector2(); } + + output.x = this.x - (this.displayWidth * this.originX) + (this.displayWidth / 2); + output.y = this.y - (this.displayHeight * this.originY) + (this.displayHeight / 2); + + return output; + }, + + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * + * @method Phaser.GameObjects.Components.GetBounds#getTopLeft + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|object)} [output] - An object to store the values in. If not provided a new Vector2 will be created. + * + * @return {(Phaser.Math.Vector2|object)} The values stored in the output object. + */ + getTopLeft: function (output) + { + if (output === undefined) { output = new Vector2(); } + + output.x = this.x - (this.displayWidth * this.originX); + output.y = this.y - (this.displayHeight * this.originY); + + if (this.rotation !== 0) + { + RotateAround(output, this.x, this.y, this.rotation); + } + + return output; + }, + + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * + * @method Phaser.GameObjects.Components.GetBounds#getTopRight + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|object)} [output] - An object to store the values in. If not provided a new Vector2 will be created. + * + * @return {(Phaser.Math.Vector2|object)} The values stored in the output object. + */ + getTopRight: function (output) + { + if (output === undefined) { output = new Vector2(); } + + output.x = (this.x - (this.displayWidth * this.originX)) + this.displayWidth; + output.y = this.y - (this.displayHeight * this.originY); + + if (this.rotation !== 0) + { + RotateAround(output, this.x, this.y, this.rotation); + } + + return output; + }, + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * + * @method Phaser.GameObjects.Components.GetBounds#getBottomLeft + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|object)} [output] - An object to store the values in. If not provided a new Vector2 will be created. + * + * @return {(Phaser.Math.Vector2|object)} The values stored in the output object. + */ + getBottomLeft: function (output) + { + if (output === undefined) { output = new Vector2(); } + + output.x = this.x - (this.displayWidth * this.originX); + output.y = (this.y - (this.displayHeight * this.originY)) + this.displayHeight; + + if (this.rotation !== 0) + { + RotateAround(output, this.x, this.y, this.rotation); + } + + return output; + }, + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * + * @method Phaser.GameObjects.Components.GetBounds#getBottomRight + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|object)} [output] - An object to store the values in. If not provided a new Vector2 will be created. + * + * @return {(Phaser.Math.Vector2|object)} The values stored in the output object. + */ + getBottomRight: function (output) + { + if (output === undefined) { output = new Vector2(); } + + output.x = (this.x - (this.displayWidth * this.originX)) + this.displayWidth; + output.y = (this.y - (this.displayHeight * this.originY)) + this.displayHeight; + + if (this.rotation !== 0) + { + RotateAround(output, this.x, this.y, this.rotation); + } + + return output; + }, + + /** + * Gets the bounds of this Game Object, regardless of origin. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * + * @method Phaser.GameObjects.Components.GetBounds#getBounds + * @since 3.0.0 + * + * @param {(Phaser.Geom.Rectangle|object)} [output] - An object to store the values in. If not provided a new Rectangle will be created. + * + * @return {(Phaser.Geom.Rectangle|object)} The values stored in the output object. + */ + getBounds: function (output) + { + if (output === undefined) { output = new Rectangle(); } + + // We can use the output object to temporarily store the x/y coords in: + + this.getTopLeft(output); + + var TLx = output.x; + var TLy = output.y; + + this.getTopRight(output); + + var TRx = output.x; + var TRy = output.y; + + this.getBottomLeft(output); + + var BLx = output.x; + var BLy = output.y; + + this.getBottomRight(output); + + var BRx = output.x; + var BRy = output.y; + + output.x = Math.min(TLx, TRx, BLx, BRx); + output.y = Math.min(TLy, TRy, BLy, BRy); + output.width = Math.max(TLx, TRx, BLx, BRx) - output.x; + output.height = Math.max(TLy, TRy, BLy, BRy) - output.y; + + return output; + } - return SpliceOne(array, randomIndex); }; -module.exports = RemoveRandomElement; +module.exports = GetBounds; /***/ }), /* 933 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -124043,30 +124780,146 @@ module.exports = RemoveRandomElement; */ /** - * @namespace Phaser.Utils.Object + * Provides methods used for visually flipping a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Flip + * @since 3.0.0 */ -module.exports = { +var Flip = { - Clone: __webpack_require__(53), - Extend: __webpack_require__(23), - GetAdvancedValue: __webpack_require__(10), - GetFastValue: __webpack_require__(2), - GetMinMaxValue: __webpack_require__(934), - GetValue: __webpack_require__(4), - HasAll: __webpack_require__(935), - HasAny: __webpack_require__(289), - HasValue: __webpack_require__(72), - IsPlainObject: __webpack_require__(170), - Merge: __webpack_require__(104), - MergeRight: __webpack_require__(936) + /** + * The horizontally flipped state of the Game Object. + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * + * @name Phaser.GameObjects.Components.Flip#flipX + * @type {boolean} + * @default false + * @since 3.0.0 + */ + flipX: false, + + /** + * The vertically flipped state of the Game Object. + * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * + * @name Phaser.GameObjects.Components.Flip#flipY + * @type {boolean} + * @default false + * @since 3.0.0 + */ + flipY: false, + + /** + * Toggles the horizontal flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#toggleFlipX + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + toggleFlipX: function () + { + this.flipX = !this.flipX; + + return this; + }, + + /** + * Toggles the vertical flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#toggleFlipY + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + toggleFlipY: function () + { + this.flipY = !this.flipY; + + return this; + }, + + /** + * Sets the horizontal flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#setFlipX + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setFlipX: function (value) + { + this.flipX = value; + + return this; + }, + + /** + * Sets the vertical flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#setFlipY + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setFlipY: function (value) + { + this.flipY = value; + + return this; + }, + + /** + * Sets the horizontal and vertical flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#setFlip + * @since 3.0.0 + * + * @param {boolean} x - The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param {boolean} y - The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setFlip: function (x, y) + { + this.flipX = x; + this.flipY = y; + + return this; + }, + + /** + * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. + * + * @method Phaser.GameObjects.Components.Flip#resetFlip + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + resetFlip: function () + { + this.flipX = false; + this.flipY = false; + + return this; + } }; +module.exports = Flip; + /***/ }), /* 934 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -124074,33 +124927,78 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetValue = __webpack_require__(4); -var Clamp = __webpack_require__(61); - /** - * [description] - * - * @function Phaser.Utils.Object.GetMinMaxValue + * Provides methods used for setting the depth of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Depth * @since 3.0.0 - * - * @param {[type]} source - [description] - * @param {string} key - [description] - * @param {number} min - [description] - * @param {number} max - [description] - * @param {number} defaultValue - [description] - * - * @return {number} [description] */ -var GetMinMaxValue = function (source, key, min, max, defaultValue) -{ - if (defaultValue === undefined) { defaultValue = min; } - var value = GetValue(source, key, defaultValue); +var Depth = { + + _depth: 0, + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * + * @name Phaser.GameObjects.Components.Depth#depth + * @type {number} + * @since 3.0.0 + */ + depth: { + + get: function () + { + return this._depth; + }, + + set: function (value) + { + this.scene.sys.queueDepthSort(); + this._depth = value; + } + + }, + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * + * @method Phaser.GameObjects.Components.Depth#setDepth + * @since 3.0.0 + * + * @param {integer} value - The depth of this Game Object. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setDepth: function (value) + { + if (value === undefined) { value = 0; } + + this.depth = value; + + return this; + } - return Clamp(value, min, max); }; -module.exports = GetMinMaxValue; +module.exports = Depth; /***/ }), @@ -124114,30 +125012,80 @@ module.exports = GetMinMaxValue; */ /** - * [description] - * - * @function Phaser.Utils.Object.HasAll + * Provides methods used for setting the blend mode of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.ComputedSize * @since 3.0.0 - * - * @param {object} source - [description] - * @param {string[]} keys - [description] - * - * @return {boolean} [description] */ -var HasAll = function (source, keys) -{ - for (var i = 0; i < keys.length; i++) - { - if (!source.hasOwnProperty(keys[i])) + +var ComputedSize = { + + /** + * The native (un-scaled) width of this Game Object. + * + * @name Phaser.GameObjects.Components.ComputedSize#width + * @type {number} + * @since 3.0.0 + */ + width: 0, + + /** + * The native (un-scaled) height of this Game Object. + * + * @name Phaser.GameObjects.Components.ComputedSize#height + * @type {number} + * @since 3.0.0 + */ + height: 0, + + /** + * The displayed width of this Game Object. + * This value takes into account the scale factor. + * + * @name Phaser.GameObjects.Components.ComputedSize#displayWidth + * @type {number} + * @since 3.0.0 + */ + displayWidth: { + + get: function () { - return false; + return this.scaleX * this.width; + }, + + set: function (value) + { + this.scaleX = value / this.width; } + + }, + + /** + * The displayed height of this Game Object. + * This value takes into account the scale factor. + * + * @name Phaser.GameObjects.Components.ComputedSize#displayHeight + * @type {number} + * @since 3.0.0 + */ + displayHeight: { + + get: function () + { + return this.scaleY * this.height; + }, + + set: function (value) + { + this.scaleY = value / this.height; + } + } - return true; }; -module.exports = HasAll; +module.exports = ComputedSize; /***/ }), @@ -124150,37 +125098,105 @@ module.exports = HasAll; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Clone = __webpack_require__(53); +var BlendModes = __webpack_require__(62); /** - * Creates a new Object using all values from obj1. - * - * Then scans obj2. If a property is found in obj2 that *also* exists in obj1, the value from obj2 is used, otherwise the property is skipped. + * Provides methods used for setting the blend mode of a Game Object. + * Should be applied as a mixin and not used directly. * - * @function Phaser.Utils.Object.MergeRight + * @name Phaser.GameObjects.Components.BlendMode * @since 3.0.0 - * - * @param {object} obj1 - [description] - * @param {object} obj2 - [description] - * - * @return {object} [description] */ -var MergeRight = function (obj1, obj2) -{ - var clone = Clone(obj1); - for (var key in obj2) - { - if (clone.hasOwnProperty(key)) +var BlendMode = { + + _blendMode: BlendModes.NORMAL, + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + * + * @name Phaser.GameObjects.Components.BlendMode#blendMode + * @type {(integer|string)} + * @since 3.0.0 + */ + blendMode: { + + get: function () { - clone[key] = obj2[key]; + return this._blendMode; + }, + + set: function (value) + { + if (typeof value === 'string') + { + value = BlendModes[value]; + } + + value |= 0; + + if (value >= 0) + { + this._blendMode = value; + } } + + }, + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + * + * @method Phaser.GameObjects.Components.BlendMode#setBlendMode + * @since 3.0.0 + * + * @param {(string|integer)} value - The BlendMode value. Either a string or a CONST. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + setBlendMode: function (value) + { + this.blendMode = value; + + return this; } - return clone; }; -module.exports = MergeRight; +module.exports = BlendMode; /***/ }), @@ -124193,680 +125209,244 @@ module.exports = MergeRight; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * @namespace Phaser.Utils.String - */ +var Clamp = __webpack_require__(64); -module.exports = { - - Format: __webpack_require__(938), - Pad: __webpack_require__(200), - Reverse: __webpack_require__(939), - UppercaseFirst: __webpack_require__(254) - -}; - - -/***/ }), -/* 938 */ -/***/ (function(module, exports) { +// bitmask flag for GameObject.renderMask +var _FLAG = 2; // 0010 /** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Takes a string and replaces instances of markers with values in the given array. - * The markers take the form of `%1`, `%2`, etc. I.e.: - * - * `Format("The %1 is worth %2 gold", [ 'Sword', 500 ])` - * - * @function Phaser.Utils.String.Format + * Provides methods used for setting the alpha properties of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Alpha * @since 3.0.0 - * - * @param {string} string - The string containing the replacement markers. - * @param {array} values - An array containing values that will replace the markers. If no value exists an empty string is inserted instead. - * - * @return {string} The string containing replaced values. - */ -var Format = function (string, values) -{ - return string.replace(/%([0-9]+)/g, function (s, n) - { - return values[Number(n) - 1]; - }); -}; - -module.exports = Format; - - -/***/ }), -/* 939 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * Takes the given string and reverses it, returning the reversed string. - * For example if given the string `Atari 520ST` it would return `TS025 iratA`. - * - * @function Phaser.Utils.String.ReverseString - * @since 3.0.0 - * - * @param {string} string - The string to be reversed. - * - * @return {string} The reversed string. - */ -var ReverseString = function (string) -{ - return string.split('').reverse().join(''); -}; +var Alpha = { -module.exports = ReverseString; + _alpha: 1, + _alphaTL: 1, + _alphaTR: 1, + _alphaBL: 1, + _alphaBR: 1, -/***/ }), -/* 940 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var COLLIDES = __webpack_require__(341); -var GetVelocity = __webpack_require__(961); -var TYPE = __webpack_require__(342); -var UpdateMotion = __webpack_require__(962); - -/** - * @classdesc - * An Impact.js compatible physics body. - * This re-creates the properties you'd get on an Entity and the math needed to update them. - * - * @class Body - * @memberOf Phaser.Physics.Impact - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Physics.Impact.World} world - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} [sx=16] - [description] - * @param {number} [sy=16] - [description] - */ -var Body = new Class({ - - initialize: - - function Body (world, x, y, sx, sy) + /** + * Clears all alpha values associated with this Game Object. + * Immediately sets the alpha levels back to 1 (fully opaque) + * + * @method Phaser.GameObjects.Components.Alpha#clearAlpha + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. + */ + clearAlpha: function () { - if (sx === undefined) { sx = 16; } - if (sy === undefined) { sy = sx; } - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#world - * @type {Phaser.Physics.Impact.World} - * @since 3.0.0 - */ - this.world = world; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#gameObject - * @type {Phaser.GameObjects.GameObject} - * @default null - * @since 3.0.0 - */ - this.gameObject = null; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#enabled - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.enabled = true; - - /** - * The ImpactBody, ImpactSprite or ImpactImage object that owns this Body, if any. - * - * @name Phaser.Physics.Impact.Body#parent - * @type {Phaser.Physics.Impact.ImpactBody|Phaser.Physics.Impact.ImpactImage|Phaser.Physics.Impact.ImpactSprite|null} - * @since 3.0.0 - */ - this.parent; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#id - * @type {integer} - * @since 3.0.0 - */ - this.id = world.getNextID(); - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#name - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.name = ''; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#size - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.size = { x: sx, y: sy }; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#offset - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.offset = { x: 0, y: 0 }; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#pos - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.pos = { x: x, y: y }; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#last - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.last = { x: x, y: y }; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#vel - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.vel = { x: 0, y: 0 }; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#accel - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.accel = { x: 0, y: 0 }; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#friction - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.friction = { x: 0, y: 0 }; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#maxVel - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.maxVel = { x: world.defaults.maxVelocityX, y: world.defaults.maxVelocityY }; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#standing - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.standing = false; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#gravityFactor - * @type {number} - * @since 3.0.0 - */ - this.gravityFactor = world.defaults.gravityFactor; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#bounciness - * @type {number} - * @since 3.0.0 - */ - this.bounciness = world.defaults.bounciness; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#minBounceVelocity - * @type {number} - * @since 3.0.0 - */ - this.minBounceVelocity = world.defaults.minBounceVelocity; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#accelGround - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.accelGround = 0; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#accelAir - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.accelAir = 0; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#jumpSpeed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.jumpSpeed = 0; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#type - * @type {Phaser.Physics.Impact.TYPE} - * @since 3.0.0 - */ - this.type = TYPE.NONE; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#checkAgainst - * @type {Phaser.Physics.Impact.TYPE} - * @since 3.0.0 - */ - this.checkAgainst = TYPE.NONE; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#collides - * @type {Phaser.Physics.Impact.COLLIDES} - * @since 3.0.0 - */ - this.collides = COLLIDES.NEVER; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#debugShowBody - * @type {boolean} - * @since 3.0.0 - */ - this.debugShowBody = world.defaults.debugShowBody; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#debugShowVelocity - * @type {boolean} - * @since 3.0.0 - */ - this.debugShowVelocity = world.defaults.debugShowVelocity; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#debugBodyColor - * @type {integer} - * @since 3.0.0 - */ - this.debugBodyColor = world.defaults.bodyDebugColor; - - /** - * [description] - * - * @name Phaser.Physics.Impact.Body#updateCallback - * @type {function} - * @since 3.0.0 - */ - this.updateCallback; - - /** - * min 44 deg, max 136 deg - * - * @name Phaser.Physics.Impact.Body#slopeStanding - * @type {{ min: number, max: number }} - * @since 3.0.0 - */ - this.slopeStanding = { min: 0.767944870877505, max: 2.3736477827122884 }; + return this.setAlpha(1); }, /** - * [description] + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. * - * @method Phaser.Physics.Impact.Body#reset + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * + * @method Phaser.GameObjects.Components.Alpha#setAlpha * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] + * + * @param {float} [topLeft=1] - The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. + * @param {float} [topRight] - The alpha value used for the top-right of the Game Object. WebGL only. + * @param {float} [bottomLeft] - The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param {float} [bottomRight] - The alpha value used for the bottom-right of the Game Object. WebGL only. + * + * @return {Phaser.GameObjects.GameObject} This Game Object instance. */ - reset: function (x, y) + setAlpha: function (topLeft, topRight, bottomLeft, bottomRight) { - this.pos = { x: x, y: y }; - this.last = { x: x, y: y }; - this.vel = { x: 0, y: 0 }; - this.accel = { x: 0, y: 0 }; - this.friction = { x: 0, y: 0 }; - this.maxVel = { x: 100, y: 100 }; + if (topLeft === undefined) { topLeft = 1; } - this.standing = false; - - this.gravityFactor = 1; - this.bounciness = 0; - this.minBounceVelocity = 40; - - this.accelGround = 0; - this.accelAir = 0; - this.jumpSpeed = 0; - - this.type = TYPE.NONE; - this.checkAgainst = TYPE.NONE; - this.collides = COLLIDES.NEVER; - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.Body#update - * @since 3.0.0 - * - * @param {number} delta - [description] - */ - update: function (delta) - { - var pos = this.pos; - - this.last.x = pos.x; - this.last.y = pos.y; - - this.vel.y += this.world.gravity * delta * this.gravityFactor; - - this.vel.x = GetVelocity(delta, this.vel.x, this.accel.x, this.friction.x, this.maxVel.x); - this.vel.y = GetVelocity(delta, this.vel.y, this.accel.y, this.friction.y, this.maxVel.y); - - var mx = this.vel.x * delta; - var my = this.vel.y * delta; - - var res = this.world.collisionMap.trace(pos.x, pos.y, mx, my, this.size.x, this.size.y); - - if (this.handleMovementTrace(res)) + // Treat as if there is only one alpha value for the whole Game Object + if (topRight === undefined) { - UpdateMotion(this, res); + this.alpha = topLeft; } - - var go = this.gameObject; - - if (go) + else { - go.x = (pos.x - this.offset.x) + go.displayOriginX * go.scaleX; - go.y = (pos.y - this.offset.y) + go.displayOriginY * go.scaleY; + this._alphaTL = Clamp(topLeft, 0, 1); + this._alphaTR = Clamp(topRight, 0, 1); + this._alphaBL = Clamp(bottomLeft, 0, 1); + this._alphaBR = Clamp(bottomRight, 0, 1); } - if (this.updateCallback) - { - this.updateCallback(this); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.Body#drawDebug - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphic - [description] - */ - drawDebug: function (graphic) - { - var pos = this.pos; - - if (this.debugShowBody) - { - graphic.lineStyle(1, this.debugBodyColor, 1); - graphic.strokeRect(pos.x, pos.y, this.size.x, this.size.y); - } - - if (this.debugShowVelocity) - { - var x = pos.x + this.size.x / 2; - var y = pos.y + this.size.y / 2; - - graphic.lineStyle(1, this.world.defaults.velocityDebugColor, 1); - graphic.lineBetween(x, y, x + this.vel.x, y + this.vel.y); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.Body#willDrawDebug - * @since 3.0.0 - * - * @return {boolean} [description] - */ - willDrawDebug: function () - { - return (this.debugShowBody || this.debugShowVelocity); - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.Body#skipHash - * @since 3.0.0 - * - * @return {boolean} [description] - */ - skipHash: function () - { - return (!this.enabled || (this.type === 0 && this.checkAgainst === 0 && this.collides === 0)); - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.Body#touches - * @since 3.0.0 - * - * @param {Phaser.Physics.Impact.Body} other - [description] - * - * @return {boolean} [description] - */ - touches: function (other) - { - return !( - this.pos.x >= other.pos.x + other.size.x || - this.pos.x + this.size.x <= other.pos.x || - this.pos.y >= other.pos.y + other.size.y || - this.pos.y + this.size.y <= other.pos.y - ); - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.Body#resetSize - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Physics.Impact.Body} This Body object. - */ - resetSize: function (x, y, width, height) - { - this.pos.x = x; - this.pos.y = y; - this.size.x = width; - this.size.y = height; - return this; }, /** - * [description] + * The alpha value of the Game Object. * - * @method Phaser.Physics.Impact.Body#toJSON + * This is a global value, impacting the entire Game Object, not just a region of it. + * + * @name Phaser.GameObjects.Components.Alpha#alpha + * @type {float} * @since 3.0.0 - * - * @return {object} [description] */ - toJSON: function () - { - var output = { - name: this.name, - size: { x: this.size.x, y: this.size.y }, - pos: { x: this.pos.x, y: this.pos.y }, - vel: { x: this.vel.x, y: this.vel.y }, - accel: { x: this.accel.x, y: this.accel.y }, - friction: { x: this.friction.x, y: this.friction.y }, - maxVel: { x: this.maxVel.x, y: this.maxVel.y }, - gravityFactor: this.gravityFactor, - bounciness: this.bounciness, - minBounceVelocity: this.minBounceVelocity, - type: this.type, - checkAgainst: this.checkAgainst, - collides: this.collides - }; + alpha: { - return output; - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.Body#fromJSON - * @todo Code it! - * @since 3.0.0 - * - * @param {object} config - [description] - */ - fromJSON: function () - { - }, - - /** - * Can be overridden by user code - * - * @method Phaser.Physics.Impact.Body#check - * @since 3.0.0 - * - * @param {Phaser.Physics.Impact.Body} other - [description] - */ - check: function () - { - }, - - /** - * Can be overridden by user code - * - * @method Phaser.Physics.Impact.Body#collideWith - * @since 3.0.0 - * - * @param {Phaser.Physics.Impact.Body} other - [description] - * @param {[type]} axis - [description] - */ - collideWith: function (other, axis) - { - if (this.parent && this.parent._collideCallback) + get: function () { - this.parent._collideCallback.call(this.parent._callbackScope, this, other, axis); + return this._alpha; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alpha = v; + this._alphaTL = v; + this._alphaTR = v; + this._alphaBL = v; + this._alphaBR = v; + + if (v === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } } + }, /** - * Can be overridden by user code but must return a boolean. - * - * @method Phaser.Physics.Impact.Body#handleMovementTrace + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaTopLeft + * @type {float} + * @webglOnly * @since 3.0.0 - * - * @param {[type]} res - [description] - * - * @return {boolean} [description] */ - handleMovementTrace: function () - { - return true; + alphaTopLeft: { + + get: function () + { + return this._alphaTL; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaTL = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + }, /** - * [description] - * - * @method Phaser.Physics.Impact.Body#destroy + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaTopRight + * @type {float} + * @webglOnly * @since 3.0.0 */ - destroy: function () - { - this.world.remove(this); + alphaTopRight: { - this.enabled = false; + get: function () + { + return this._alphaTR; + }, - this.world = null; + set: function (value) + { + var v = Clamp(value, 0, 1); - this.gameObject = null; + this._alphaTR = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaBottomLeft + * @type {float} + * @webglOnly + * @since 3.0.0 + */ + alphaBottomLeft: { + + get: function () + { + return this._alphaBL; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaBL = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaBottomRight + * @type {float} + * @webglOnly + * @since 3.0.0 + */ + alphaBottomRight: { + + get: function () + { + return this._alphaBR; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaBR = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } - this.parent = null; } -}); +}; -module.exports = Body; +module.exports = Alpha; /***/ }), -/* 941 */ +/* 938 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -124876,361 +125456,459 @@ module.exports = Body; */ var Class = __webpack_require__(0); -var DefaultDefs = __webpack_require__(963); /** * @classdesc * [description] * - * @class CollisionMap - * @memberOf Phaser.Physics.Impact + * @class RandomDataGenerator + * @memberOf Phaser.Math * @constructor * @since 3.0.0 * - * @param {integer} [tilesize=32] - [description] - * @param {array} data - [description] + * @param {string[]} [seeds] - [description] */ -var CollisionMap = new Class({ +var RandomDataGenerator = new Class({ initialize: - function CollisionMap (tilesize, data) + function RandomDataGenerator (seeds) { - if (tilesize === undefined) { tilesize = 32; } - /** - * [description] + * Internal var. * - * @name Phaser.Physics.Impact.CollisionMap#tilesize - * @type {integer} - * @default 32 - * @since 3.0.0 - */ - this.tilesize = tilesize; - - /** - * [description] - * - * @name Phaser.Physics.Impact.CollisionMap#data - * @type {array} - * @since 3.0.0 - */ - this.data = (Array.isArray(data)) ? data : []; - - /** - * [description] - * - * @name Phaser.Physics.Impact.CollisionMap#width + * @name Phaser.Math.RandomDataGenerator#c * @type {number} + * @default 1 + * @private * @since 3.0.0 */ - this.width = (Array.isArray(data)) ? data[0].length : 0; + this.c = 1; /** - * [description] + * Internal var. * - * @name Phaser.Physics.Impact.CollisionMap#height + * @name Phaser.Math.RandomDataGenerator#s0 * @type {number} + * @default 0 + * @private * @since 3.0.0 */ - this.height = (Array.isArray(data)) ? data.length : 0; + this.s0 = 0; + + /** + * Internal var. + * + * @name Phaser.Math.RandomDataGenerator#s1 + * @type {number} + * @default 0 + * @private + * @since 3.0.0 + */ + this.s1 = 0; + + /** + * Internal var. + * + * @name Phaser.Math.RandomDataGenerator#s2 + * @type {number} + * @default 0 + * @private + * @since 3.0.0 + */ + this.s2 = 0; + + /** + * Internal var. + * + * @name Phaser.Math.RandomDataGenerator#n + * @type {number} + * @default 0 + * @private + * @since 3.2.0 + */ + this.n = 0; /** * [description] * - * @name Phaser.Physics.Impact.CollisionMap#lastSlope - * @type {integer} - * @default 55 + * @name Phaser.Math.RandomDataGenerator#sign + * @type {number[]} * @since 3.0.0 */ - this.lastSlope = 55; + this.signs = [ -1, 1 ]; - /** - * [description] - * - * @name Phaser.Physics.Impact.CollisionMap#tiledef - * @type {object} - * @since 3.0.0 - */ - this.tiledef = DefaultDefs; + if (seeds) + { + this.init(seeds); + } + }, + + /** + * Private random helper. + * + * @method Phaser.Math.RandomDataGenerator#rnd + * @since 3.0.0 + * @private + * + * @return {number} [description] + */ + rnd: function () + { + var t = 2091639 * this.s0 + this.c * 2.3283064365386963e-10; // 2^-32 + + this.c = t | 0; + this.s0 = this.s1; + this.s1 = this.s2; + this.s2 = t - this.c; + + return this.s2; + }, + + /** + * Internal method that creates a seed hash. + * + * @method Phaser.Math.RandomDataGenerator#hash + * @since 3.0.0 + * @private + * + * @param {string} data - [description] + * + * @return {number} The hashed value. + */ + hash: function (data) + { + var h; + var n = this.n; + + data = data.toString(); + + for (var i = 0; i < data.length; i++) + { + n += data.charCodeAt(i); + h = 0.02519603282416938 * n; + n = h >>> 0; + h -= n; + h *= n; + n = h >>> 0; + h -= n; + n += h * 0x100000000;// 2^32 + } + + this.n = n; + + return (n >>> 0) * 2.3283064365386963e-10;// 2^-32 }, /** * [description] * - * @method Phaser.Physics.Impact.CollisionMap#trace + * @method Phaser.Math.RandomDataGenerator#init * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} vx - [description] - * @param {number} vy - [description] - * @param {number} objectWidth - [description] - * @param {number} objectHeight - [description] - * - * @return {boolean} [description] + * @param {(string|string[])} seeds - [description] */ - trace: function (x, y, vx, vy, objectWidth, objectHeight) + init: function (seeds) { - // Set up the trace-result - var res = { - collision: { x: false, y: false, slope: false }, - pos: { x: x + vx, y: y + vy }, - tile: { x: 0, y: 0 } - }; - - if (!this.data) + if (typeof seeds === 'string') { - return res; - } - - var steps = Math.ceil(Math.max(Math.abs(vx), Math.abs(vy)) / this.tilesize); - - if (steps > 1) - { - var sx = vx / steps; - var sy = vy / steps; - - for (var i = 0; i < steps && (sx || sy); i++) - { - this.step(res, x, y, sx, sy, objectWidth, objectHeight, vx, vy, i); - - x = res.pos.x; - y = res.pos.y; - - if (res.collision.x) - { - sx = 0; - vx = 0; - } - - if (res.collision.y) - { - sy = 0; - vy = 0; - } - - if (res.collision.slope) - { - break; - } - } + this.state(seeds); } else { - this.step(res, x, y, vx, vy, objectWidth, objectHeight, vx, vy, 0); + this.sow(seeds); } - - return res; }, /** - * [description] + * Reset the seed of the random data generator. * - * @method Phaser.Physics.Impact.CollisionMap#step + * _Note_: the seed array is only processed up to the first `undefined` (or `null`) value, should such be present. + * + * @method Phaser.Math.RandomDataGenerator#sow * @since 3.0.0 * - * @param {object} res - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} vx - [description] - * @param {number} vy - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} rvx - [description] - * @param {number} rvy - [description] - * @param {number} step - [description] + * @param {string[]} seeds - The array of seeds: the `toString()` of each value is used. */ - step: function (res, x, y, vx, vy, width, height, rvx, rvy, step) + sow: function (seeds) { - var t = 0; - var tileX; - var tileY; - var tilesize = this.tilesize; - var mapWidth = this.width; - var mapHeight = this.height; - - // Horizontal - if (vx) + // Always reset to default seed + this.n = 0xefc8249d; + this.s0 = this.hash(' '); + this.s1 = this.hash(' '); + this.s2 = this.hash(' '); + this.c = 1; + + if (!seeds) { - var pxOffsetX = (vx > 0 ? width : 0); - var tileOffsetX = (vx < 0 ? tilesize : 0); - - var firstTileY = Math.max(Math.floor(y / tilesize), 0); - var lastTileY = Math.min(Math.ceil((y + height) / tilesize), mapHeight); - - tileX = Math.floor((res.pos.x + pxOffsetX) / tilesize); - - var prevTileX = Math.floor((x + pxOffsetX) / tilesize); - - if (step > 0 || tileX === prevTileX || prevTileX < 0 || prevTileX >= mapWidth) - { - prevTileX = -1; - } - - if (tileX >= 0 && tileX < mapWidth) - { - for (tileY = firstTileY; tileY < lastTileY; tileY++) - { - if (prevTileX !== -1) - { - t = this.data[tileY][prevTileX]; - - if (t > 1 && t <= this.lastSlope && this.checkDef(res, t, x, y, rvx, rvy, width, height, prevTileX, tileY)) - { - break; - } - } - - t = this.data[tileY][tileX]; - - if (t === 1 || t > this.lastSlope || (t > 1 && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, tileY))) - { - if (t > 1 && t <= this.lastSlope && res.collision.slope) - { - break; - } - - res.collision.x = true; - res.tile.x = t; - res.pos.x = (tileX * tilesize) - pxOffsetX + tileOffsetX; - x = res.pos.x; - rvx = 0; - - break; - } - } - } + return; } - - // Vertical - if (vy) + + // Apply any seeds + for (var i = 0; i < seeds.length && (seeds[i] != null); i++) { - var pxOffsetY = (vy > 0 ? height : 0); - var tileOffsetY = (vy < 0 ? tilesize : 0); - - var firstTileX = Math.max(Math.floor(res.pos.x / tilesize), 0); - var lastTileX = Math.min(Math.ceil((res.pos.x + width) / tilesize), mapWidth); - - tileY = Math.floor((res.pos.y + pxOffsetY) / tilesize); - - var prevTileY = Math.floor((y + pxOffsetY) / tilesize); + var seed = seeds[i]; - if (step > 0 || tileY === prevTileY || prevTileY < 0 || prevTileY >= mapHeight) - { - prevTileY = -1; - } - - if (tileY >= 0 && tileY < mapHeight) - { - for (tileX = firstTileX; tileX < lastTileX; tileX++) - { - if (prevTileY !== -1) - { - t = this.data[prevTileY][tileX]; - - if (t > 1 && t <= this.lastSlope && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, prevTileY)) - { - break; - } - } - - t = this.data[tileY][tileX]; - - if (t === 1 || t > this.lastSlope || (t > 1 && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, tileY))) - { - if (t > 1 && t <= this.lastSlope && res.collision.slope) - { - break; - } - - res.collision.y = true; - res.tile.y = t; - res.pos.y = tileY * tilesize - pxOffsetY + tileOffsetY; - - break; - } - } - } + this.s0 -= this.hash(seed); + this.s0 += ~~(this.s0 < 0); + this.s1 -= this.hash(seed); + this.s1 += ~~(this.s1 < 0); + this.s2 -= this.hash(seed); + this.s2 += ~~(this.s2 < 0); } }, - + /** - * [description] + * Returns a random integer between 0 and 2^32. * - * @method Phaser.Physics.Impact.CollisionMap#checkDef + * @method Phaser.Math.RandomDataGenerator#integer * @since 3.0.0 * - * @param {object} res - [description] - * @param {number} t - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} vx - [description] - * @param {number} vy - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} tileX - [description] - * @param {number} tileY - [description] - * - * @return {boolean} [description] + * @return {number} A random integer between 0 and 2^32. */ - checkDef: function (res, t, x, y, vx, vy, width, height, tileX, tileY) + integer: function () { - var def = this.tiledef[t]; + // 2^32 + return this.rnd() * 0x100000000; + }, - if (!def) + /** + * Returns a random real number between 0 and 1. + * + * @method Phaser.Math.RandomDataGenerator#frac + * @since 3.0.0 + * + * @return {number} A random real number between 0 and 1. + */ + frac: function () + { + // 2^-53 + return this.rnd() + (this.rnd() * 0x200000 | 0) * 1.1102230246251565e-16; + }, + + /** + * Returns a random real number between 0 and 2^32. + * + * @method Phaser.Math.RandomDataGenerator#real + * @since 3.0.0 + * + * @return {number} A random real number between 0 and 2^32. + */ + real: function () + { + return this.integer() + this.frac(); + }, + + /** + * Returns a random integer between and including min and max. + * + * @method Phaser.Math.RandomDataGenerator#integerInRange + * @since 3.0.0 + * + * @param {number} min - The minimum value in the range. + * @param {number} max - The maximum value in the range. + * + * @return {number} A random number between min and max. + */ + integerInRange: function (min, max) + { + return Math.floor(this.realInRange(0, max - min + 1) + min); + }, + + /** + * Returns a random integer between and including min and max. + * This method is an alias for RandomDataGenerator.integerInRange. + * + * @method Phaser.Math.RandomDataGenerator#between + * @since 3.0.0 + * + * @param {number} min - The minimum value in the range. + * @param {number} max - The maximum value in the range. + * + * @return {number} A random number between min and max. + */ + between: function (min, max) + { + return Math.floor(this.realInRange(0, max - min + 1) + min); + }, + + /** + * Returns a random real number between min and max. + * + * @method Phaser.Math.RandomDataGenerator#realInRange + * @since 3.0.0 + * + * @param {number} min - The minimum value in the range. + * @param {number} max - The maximum value in the range. + * + * @return {number} A random number between min and max. + */ + realInRange: function (min, max) + { + return this.frac() * (max - min) + min; + }, + + /** + * Returns a random real number between -1 and 1. + * + * @method Phaser.Math.RandomDataGenerator#normal + * @since 3.0.0 + * + * @return {number} A random real number between -1 and 1. + */ + normal: function () + { + return 1 - (2 * this.frac()); + }, + + /** + * Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368 + * + * @method Phaser.Math.RandomDataGenerator#uuid + * @since 3.0.0 + * + * @return {string} A valid RFC4122 version4 ID hex string + */ + uuid: function () + { + var a = ''; + var b = ''; + + for (b = a = ''; a++ < 36; b += ~a % 5 | a * 3 & 4 ? (a ^ 15 ? 8 ^ this.frac() * (a ^ 20 ? 16 : 4) : 4).toString(16) : '-') { - return false; + // eslint-disable-next-line no-empty } - var tilesize = this.tilesize; - - var lx = (tileX + def[0]) * tilesize; - var ly = (tileY + def[1]) * tilesize; - var lvx = (def[2] - def[0]) * tilesize; - var lvy = (def[3] - def[1]) * tilesize; - var solid = def[4]; - - var tx = x + vx + (lvy < 0 ? width : 0) - lx; - var ty = y + vy + (lvx > 0 ? height : 0) - ly; - - if (lvx * ty - lvy * tx > 0) - { - if (vx * -lvy + vy * lvx < 0) - { - return solid; - } - - var length = Math.sqrt(lvx * lvx + lvy * lvy); - var nx = lvy / length; - var ny = -lvx / length; - - var proj = tx * nx + ty * ny; - var px = nx * proj; - var py = ny * proj; - - if (px * px + py * py >= vx * vx + vy * vy) - { - return solid || (lvx * (ty - vy) - lvy * (tx - vx) < 0.5); - } - - res.pos.x = x + vx - px; - res.pos.y = y + vy - py; - res.collision.slope = { x: lvx, y: lvy, nx: nx, ny: ny }; + return b; + }, - return true; + /** + * Returns a random element from within the given array. + * + * @method Phaser.Math.RandomDataGenerator#pick + * @since 3.0.0 + * + * @param {array} array - The array to pick a random element from. + * + * @return {*} A random member of the array. + */ + pick: function (array) + { + return array[this.integerInRange(0, array.length - 1)]; + }, + + /** + * Returns a sign to be used with multiplication operator. + * + * @method Phaser.Math.RandomDataGenerator#sign + * @since 3.0.0 + * + * @return {number} -1 or +1. + */ + sign: function () + { + return this.pick(this.signs); + }, + + /** + * Returns a random element from within the given array, favoring the earlier entries. + * + * @method Phaser.Math.RandomDataGenerator#weightedPick + * @since 3.0.0 + * + * @param {array} array - The array to pick a random element from. + * + * @return {*} A random member of the array. + */ + weightedPick: function (array) + { + return array[~~(Math.pow(this.frac(), 2) * (array.length - 1) + 0.5)]; + }, + + /** + * Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified. + * + * @method Phaser.Math.RandomDataGenerator#timestamp + * @since 3.0.0 + * + * @param {number} min - The minimum value in the range. + * @param {number} max - The maximum value in the range. + * + * @return {number} A random timestamp between min and max. + */ + timestamp: function (min, max) + { + return this.realInRange(min || 946684800000, max || 1577862000000); + }, + + /** + * Returns a random angle between -180 and 180. + * + * @method Phaser.Math.RandomDataGenerator#angle + * @since 3.0.0 + * + * @return {number} A random number between -180 and 180. + */ + angle: function () + { + return this.integerInRange(-180, 180); + }, + + /** + * Returns a random rotation in radians, between -3.141 and 3.141 + * + * @method Phaser.Math.RandomDataGenerator#rotation + * @since 3.0.0 + * + * @return {number} A random number between -3.141 and 3.141 + */ + rotation: function () + { + return this.realInRange(-3.1415926, 3.1415926); + }, + + /** + * Gets or Sets the state of the generator. This allows you to retain the values + * that the generator is using between games, i.e. in a game save file. + * + * To seed this generator with a previously saved state you can pass it as the + * `seed` value in your game config, or call this method directly after Phaser has booted. + * + * Call this method with no parameters to return the current state. + * + * If providing a state it should match the same format that this method + * returns, which is a string with a header `!rnd` followed by the `c`, + * `s0`, `s1` and `s2` values respectively, each comma-delimited. + * + * @method Phaser.Math.RandomDataGenerator#state + * @since 3.0.0 + * + * @param {string} [state] - Generator state to be set. + * + * @return {string} The current state of the generator. + */ + state: function (state) + { + if (typeof state === 'string' && state.match(/^!rnd/)) + { + state = state.split(','); + + this.c = parseFloat(state[1]); + this.s0 = parseFloat(state[2]); + this.s1 = parseFloat(state[3]); + this.s2 = parseFloat(state[4]); } - - return false; + + return [ '!rnd', this.c, this.s0, this.s1, this.s2 ].join(','); } }); -module.exports = CollisionMap; +module.exports = RandomDataGenerator; /***/ }), -/* 942 */ +/* 939 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -125239,139 +125917,271 @@ module.exports = CollisionMap; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var ImpactBody = __webpack_require__(943); -var ImpactImage = __webpack_require__(944); -var ImpactSprite = __webpack_require__(945); +var AlignIn = __webpack_require__(366); +var CONST = __webpack_require__(169); +var GetFastValue = __webpack_require__(2); +var NOOP = __webpack_require__(3); +var Zone = __webpack_require__(106); + +var tempZone = new Zone({ sys: { queueDepthSort: NOOP }}, 0, 0, 1, 1); /** - * @classdesc - * The Impact Physics Factory allows you to easily create Impact Physics enabled Game Objects. - * Objects that are created by this Factory are automatically added to the physics world. + * @typedef {object} GridAlignConfig * - * @class Factory - * @memberOf Phaser.Physics.Impact - * @constructor + * @property {integer} [width=-1] - The width of the grid in items (not pixels). -1 means lay all items out horizontally, regardless of quantity. + * If both this value and height are set to -1 then this value overrides it and the `height` value is ignored. + * @property {integer} [height=-1] - The height of the grid in items (not pixels). -1 means lay all items out vertically, regardless of quantity. + * If both this value and `width` are set to -1 then `width` overrides it and this value is ignored. + * @property {boolean} [cellWidth=1] - The width of the cell, in pixels, in which the item is positioned. + * @property {integer} [cellHeight=1] - The height of the cell, in pixels, in which the item is positioned. + * @property {integer} [position=0] - The alignment position. One of the Phaser.Display.Align consts such as `TOP_LEFT` or `RIGHT_CENTER`. + * @property {number} [x=0] - Optionally place the top-left of the final grid at this coordinate. + * @property {number} [y=0] - Optionally place the top-left of the final grid at this coordinate. + */ + +/** + * Takes an array of Game Objects, or any objects that have public `x` and `y` properties, + * and then aligns them based on the grid configuration given to this action. + * + * @function Phaser.Actions.GridAlign * @since 3.0.0 * - * @param {Phaser.Physics.Impact.World} world - [description] + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {GridAlignConfig} options - The GridAlign Configuration object. + * + * @return {array} The array of objects that were passed to this Action. */ -var Factory = new Class({ +var GridAlign = function (items, options) +{ + if (options === undefined) { options = {}; } - initialize: + var width = GetFastValue(options, 'width', -1); + var height = GetFastValue(options, 'height', -1); + var cellWidth = GetFastValue(options, 'cellWidth', 1); + var cellHeight = GetFastValue(options, 'cellHeight', cellWidth); + var position = GetFastValue(options, 'position', CONST.TOP_LEFT); + var x = GetFastValue(options, 'x', 0); + var y = GetFastValue(options, 'y', 0); - function Factory (world) + var cx = 0; + var cy = 0; + var w = (width * cellWidth); + var h = (height * cellHeight); + + tempZone.setPosition(x, y); + tempZone.setSize(cellWidth, cellHeight); + + for (var i = 0; i < items.length; i++) { - /** - * [description] - * - * @name Phaser.Physics.Impact.Factory#world - * @type {Phaser.Physics.Impact.World} - * @since 3.0.0 - */ - this.world = world; + AlignIn(items[i], tempZone, position); - /** - * A reference to the Scene.Systems this Impact Physics instance belongs to. - * - * @name Phaser.Physics.Impact.Factory#sys - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.sys = world.scene.sys; - }, + if (width === -1) + { + // We keep laying them out horizontally until we've done them all + cy += cellHeight; + tempZone.y += cellHeight; - /** - * [description] - * - * @method Phaser.Physics.Impact.Factory#body - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Physics.Impact.ImpactBody} The ImpactBody object that was created. - */ - body: function (x, y, width, height) - { - return new ImpactBody(this.world, x, y, width, height); - }, + if (cy === h) + { + cy = 0; + tempZone.x += cellWidth; + tempZone.y = y; + } + } + else if (height === -1) + { + // We keep laying them out vertically until we've done them all + cx += cellWidth; + tempZone.x += cellWidth; - /** - * Adds an Impact Physics Body to the given Game Object. - * - * @method Phaser.Physics.Impact.Factory#existing - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - * - * @return {Phaser.GameObjects.GameObject} The Game Object. - */ - existing: function (gameObject) - { - var x = gameObject.x - gameObject.frame.centerX; - var y = gameObject.y - gameObject.frame.centerY; - var w = gameObject.width; - var h = gameObject.height; + if (cx === w) + { + cx = 0; + tempZone.x = x; + tempZone.y += cellHeight; + } + } + else + { + // We keep laying them out until we hit the column limit + cx += cellWidth; + tempZone.x += cellWidth; - gameObject.body = this.world.create(x, y, w, h); + if (cx === w) + { + cx = 0; + cy += cellHeight; + tempZone.x = x; + tempZone.y += cellHeight; - gameObject.body.parent = gameObject; - gameObject.body.gameObject = gameObject; - - return gameObject; - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.Factory#image - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.Physics.Impact.ImpactImage} The ImpactImage object that was created. - */ - image: function (x, y, key, frame) - { - var image = new ImpactImage(this.world, x, y, key, frame); - - this.sys.displayList.add(image); - - return image; - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.Factory#sprite - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.Physics.Impact.ImpactSprite} The ImpactSprite object that was created. - */ - sprite: function (x, y, key, frame) - { - var sprite = new ImpactSprite(this.world, x, y, key, frame); - - this.sys.displayList.add(sprite); - this.sys.updateList.add(sprite); - - return sprite; + if (cy === h) + { + // We've hit the column limit, so return, even if there are items left + break; + } + } + } } -}); + return items; +}; -module.exports = Factory; +module.exports = GridAlign; + + +/***/ }), +/* 940 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes an array of objects and returns the last element in the array that has properties which match + * all of those specified in the `compare` object. For example, if the compare object was: `{ scaleX: 0.5, alpha: 1 }` + * then it would return the last item which had the property `scaleX` set to 0.5 and `alpha` set to 1. + * + * To use this with a Group: `GetLast(group.getChildren(), compare, index)` + * + * @function Phaser.Actions.GetLast + * @since 3.3.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be searched by this action. + * @param {object} compare - The comparison object. Each property in this object will be checked against the items of the array. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * + * @return {?(object|Phaser.GameObjects.GameObject)} The last object in the array that matches the comparison object, or `null` if no match was found. + */ +var GetLast = function (items, compare, index) +{ + if (index === undefined) { index = 0; } + + for (var i = index; i < items.length; i++) + { + var item = items[i]; + + var match = true; + + for (var property in compare) + { + if (item[property] !== compare[property]) + { + match = false; + } + } + + if (match) + { + return item; + } + } + + return null; +}; + +module.exports = GetLast; + + +/***/ }), +/* 941 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes an array of objects and returns the first element in the array that has properties which match + * all of those specified in the `compare` object. For example, if the compare object was: `{ scaleX: 0.5, alpha: 1 }` + * then it would return the first item which had the property `scaleX` set to 0.5 and `alpha` set to 1. + * + * To use this with a Group: `GetFirst(group.getChildren(), compare, index)` + * + * @function Phaser.Actions.GetFirst + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be searched by this action. + * @param {object} compare - The comparison object. Each property in this object will be checked against the items of the array. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * + * @return {?(object|Phaser.GameObjects.GameObject)} The first object in the array that matches the comparison object, or `null` if no match was found. + */ +var GetFirst = function (items, compare, index) +{ + if (index === undefined) { index = 0; } + + for (var i = index; i < items.length; i++) + { + var item = items[i]; + + var match = true; + + for (var property in compare) + { + if (item[property] !== compare[property]) + { + match = false; + } + } + + if (match) + { + return item; + } + } + + return null; +}; + +module.exports = GetFirst; + + +/***/ }), +/* 942 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @callback CallCallback + * + * @param {Phaser.GameObjects.GameObject} item - [description] + */ + +/** + * Takes an array of objects and passes each of them to the given callback. + * + * @function Phaser.Actions.Call + * @since 3.0.0 + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {CallCallback} callback - The callback to be invoked. It will be passed just one argument: the item from the array. + * @param {*} context - The scope in which the callback will be invoked. + * + * @return {array} The array of objects that was passed to this Action. + */ +var Call = function (items, callback, context) +{ + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + + callback.call(context, item); + } + + return items; +}; + +module.exports = Call; /***/ }), @@ -125384,305 +126194,2723 @@ module.exports = Factory; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Components = __webpack_require__(858); +var PropertyValueInc = __webpack_require__(25); /** - * @classdesc - * [description] + * Takes an array of Game Objects, or any objects that have a public `angle` property, + * and then adds the given value to each of their `angle` properties. * - * @class ImpactBody - * @memberOf Phaser.Physics.Impact - * @constructor + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `Angle(group.getChildren(), value, step)` + * + * @function Phaser.Actions.Angle * @since 3.0.0 * - * @extends Phaser.Physics.Impact.Components.Acceleration - * @extends Phaser.Physics.Impact.Components.BodyScale - * @extends Phaser.Physics.Impact.Components.BodyType - * @extends Phaser.Physics.Impact.Components.Bounce - * @extends Phaser.Physics.Impact.Components.CheckAgainst - * @extends Phaser.Physics.Impact.Components.Collides - * @extends Phaser.Physics.Impact.Components.Debug - * @extends Phaser.Physics.Impact.Components.Friction - * @extends Phaser.Physics.Impact.Components.Gravity - * @extends Phaser.Physics.Impact.Components.Offset - * @extends Phaser.Physics.Impact.Components.SetGameObject - * @extends Phaser.Physics.Impact.Components.Velocity + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `angle` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * - * @param {Phaser.Physics.Impact.World} world - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] + * @return {array} The array of objects that were passed to this Action. */ -var ImpactBody = new Class({ +var Angle = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'angle', value, step, index, direction); +}; - Mixins: [ - Components.Acceleration, - Components.BodyScale, - Components.BodyType, - Components.Bounce, - Components.CheckAgainst, - Components.Collides, - Components.Debug, - Components.Friction, - Components.Gravity, - Components.Offset, - Components.SetGameObject, - Components.Velocity - ], - - initialize: - - function ImpactBody (world, x, y, width, height) - { - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactBody#body - * @type {Phaser.Physics.Impact.Body} - * @since 3.0.0 - */ - this.body = world.create(x, y, width, height); - - this.body.parent = this; - - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactBody#size - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.size = this.body.size; - - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactBody#offset - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.offset = this.body.offset; - - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactBody#vel - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.vel = this.body.vel; - - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactBody#accel - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.accel = this.body.accel; - - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactBody#friction - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.friction = this.body.friction; - - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactBody#maxVel - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.maxVel = this.body.maxVel; - } - -}); - -module.exports = ImpactBody; +module.exports = Angle; /***/ }), /* 944 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(858); -var Image = __webpack_require__(70); - -/** - * @classdesc - * An Impact Physics Image Game Object. - * - * An Image is a light-weight Game Object useful for the display of static images in your game, - * such as logos, backgrounds, scenery or other non-animated elements. Images can have input - * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an - * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. - * - * @class ImpactImage - * @extends Phaser.GameObjects.Image - * @memberOf Phaser.Physics.Impact - * @constructor - * @since 3.0.0 - * - * @extends Phaser.Physics.Impact.Components.Acceleration - * @extends Phaser.Physics.Impact.Components.BodyScale - * @extends Phaser.Physics.Impact.Components.BodyType - * @extends Phaser.Physics.Impact.Components.Bounce - * @extends Phaser.Physics.Impact.Components.CheckAgainst - * @extends Phaser.Physics.Impact.Components.Collides - * @extends Phaser.Physics.Impact.Components.Debug - * @extends Phaser.Physics.Impact.Components.Friction - * @extends Phaser.Physics.Impact.Components.Gravity - * @extends Phaser.Physics.Impact.Components.Offset - * @extends Phaser.Physics.Impact.Components.SetGameObject - * @extends Phaser.Physics.Impact.Components.Velocity - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Physics.Impact.World} world - [description] - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var ImpactImage = new Class({ - - Extends: Image, - - Mixins: [ - Components.Acceleration, - Components.BodyScale, - Components.BodyType, - Components.Bounce, - Components.CheckAgainst, - Components.Collides, - Components.Debug, - Components.Friction, - Components.Gravity, - Components.Offset, - Components.SetGameObject, - Components.Velocity - ], - - initialize: - - function ImpactImage (world, x, y, texture, frame) +* Low-budget Float32Array knock-off, suitable for use with P2.js in IE9 +* Source: http://www.html5gamedevs.com/topic/5988-phaser-12-ie9/ +* Cameron Foale (http://www.kibibu.com) +*/ +if (typeof window.Uint32Array !== 'function' && typeof window.Uint32Array !== 'object') +{ + var CheapArray = function (fakeType) { - Image.call(this, world.scene, x, y, texture, frame); + var proto = new Array(); // jshint ignore:line - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactImage#body - * @type {Phaser.Physics.Impact.Body} - * @since 3.0.0 - */ - this.body = world.create(x - this.frame.centerX, y - this.frame.centerY, this.width, this.height); + window[fakeType] = function(arg) { - this.body.parent = this; - this.body.gameObject = this; + if (typeof(arg) === 'number') + { + Array.call(this, arg); - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactImage#size - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.size = this.body.size; + this.length = arg; - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactImage#offset - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.offset = this.body.offset; + for (var i = 0; i < this.length; i++) + { + this[i] = 0; + } + } + else + { + Array.call(this, arg.length); - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactImage#vel - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.vel = this.body.vel; + this.length = arg.length; - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactImage#accel - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.accel = this.body.accel; + for (var i = 0; i < this.length; i++) + { + this[i] = arg[i]; + } + } + }; - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactImage#friction - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.friction = this.body.friction; + window[fakeType].prototype = proto; + window[fakeType].constructor = window[fakeType]; + }; - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactImage#maxVel - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.maxVel = this.body.maxVel; - } - -}); - -module.exports = ImpactImage; + CheapArray('Float32Array'); // jshint ignore:line + CheapArray('Uint32Array'); // jshint ignore:line + CheapArray('Uint16Array'); // jshint ignore:line + CheapArray('Int16Array'); // jshint ignore:line + CheapArray('ArrayBuffer'); // jshint ignore:line +} /***/ }), /* 945 */ /***/ (function(module, exports, __webpack_require__) { +/* WEBPACK VAR INJECTION */(function(global) {// References: +// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ +// https://gist.github.com/1579671 +// http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision +// https://gist.github.com/timhall/4078614 +// https://github.com/Financial-Times/polyfill-service/tree/master/polyfills/requestAnimationFrame + +// Expected to be used with Browserfiy +// Browserify automatically detects the use of `global` and passes the +// correct reference of `global`, `self`, and finally `window` + +// Date.now +if (!(Date.now && Date.prototype.getTime)) { + Date.now = function now() { + return new Date().getTime(); + }; +} + +// performance.now +if (!(global.performance && global.performance.now)) { + var startTime = Date.now(); + if (!global.performance) { + global.performance = {}; + } + global.performance.now = function () { + return Date.now() - startTime; + }; +} + +// requestAnimationFrame +var lastTime = Date.now(); +var vendors = ['ms', 'moz', 'webkit', 'o']; + +for(var x = 0; x < vendors.length && !global.requestAnimationFrame; ++x) { + global.requestAnimationFrame = global[vendors[x] + 'RequestAnimationFrame']; + global.cancelAnimationFrame = global[vendors[x] + 'CancelAnimationFrame'] || + global[vendors[x] + 'CancelRequestAnimationFrame']; +} + +if (!global.requestAnimationFrame) { + global.requestAnimationFrame = function (callback) { + if (typeof callback !== 'function') { + throw new TypeError(callback + 'is not a function'); + } + + var currentTime = Date.now(), + delay = 16 + lastTime - currentTime; + + if (delay < 0) { + delay = 0; + } + + lastTime = currentTime; + + return setTimeout(function () { + lastTime = Date.now(); + callback(performance.now()); + }, delay); + }; +} + +if (!global.cancelAnimationFrame) { + global.cancelAnimationFrame = function(id) { + clearTimeout(id); + }; +} + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(369))) + +/***/ }), +/* 946 */ +/***/ (function(module, exports) { + +/** + * performance.now + */ +(function () { + + if ('performance' in window === false) + { + window.performance = {}; + } + + // Thanks IE8 + Date.now = (Date.now || function () { + return new Date().getTime(); + }); + + if ('now' in window.performance === false) + { + var nowOffset = Date.now(); + + if (performance.timing && performance.timing.navigationStart) + { + nowOffset = performance.timing.navigationStart; + } + + window.performance.now = function now () + { + return Date.now() - nowOffset; + } + } + +})(); + + +/***/ }), +/* 947 */ +/***/ (function(module, exports) { + +// ES6 Math.trunc - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc +if (!Math.trunc) { + Math.trunc = function trunc(x) { + return x < 0 ? Math.ceil(x) : Math.floor(x); + }; +} + + +/***/ }), +/* 948 */ +/***/ (function(module, exports) { + +/** +* A polyfill for Function.prototype.bind +*/ +if (!Function.prototype.bind) { + + /* jshint freeze: false */ + Function.prototype.bind = (function () { + + var slice = Array.prototype.slice; + + return function (thisArg) { + + var target = this, boundArgs = slice.call(arguments, 1); + + if (typeof target !== 'function') + { + throw new TypeError(); + } + + function bound() { + var args = boundArgs.concat(slice.call(arguments)); + target.apply(this instanceof bound ? this : thisArg, args); + } + + bound.prototype = (function F(proto) { + if (proto) + { + F.prototype = proto; + } + + if (!(this instanceof F)) + { + /* jshint supernew: true */ + return new F; + } + })(target.prototype); + + return bound; + }; + })(); +} + + + +/***/ }), +/* 949 */ +/***/ (function(module, exports) { + +/** + * Also fix for the absent console in IE9 + */ +if (!window.console) +{ + window.console = {}; + window.console.log = window.console.assert = function(){}; + window.console.warn = window.console.assert = function(){}; +} + + +/***/ }), +/* 950 */ +/***/ (function(module, exports) { + +/* Copyright 2013 Chris Wilson + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/* + +This monkeypatch library is intended to be included in projects that are +written to the proper AudioContext spec (instead of webkitAudioContext), +and that use the new naming and proper bits of the Web Audio API (e.g. +using BufferSourceNode.start() instead of BufferSourceNode.noteOn()), but may +have to run on systems that only support the deprecated bits. + +This library should be harmless to include if the browser supports +unprefixed "AudioContext", and/or if it supports the new names. + +The patches this library handles: +if window.AudioContext is unsupported, it will be aliased to webkitAudioContext(). +if AudioBufferSourceNode.start() is unimplemented, it will be routed to noteOn() or +noteGrainOn(), depending on parameters. + +The following aliases only take effect if the new names are not already in place: + +AudioBufferSourceNode.stop() is aliased to noteOff() +AudioContext.createGain() is aliased to createGainNode() +AudioContext.createDelay() is aliased to createDelayNode() +AudioContext.createScriptProcessor() is aliased to createJavaScriptNode() +AudioContext.createPeriodicWave() is aliased to createWaveTable() +OscillatorNode.start() is aliased to noteOn() +OscillatorNode.stop() is aliased to noteOff() +OscillatorNode.setPeriodicWave() is aliased to setWaveTable() +AudioParam.setTargetAtTime() is aliased to setTargetValueAtTime() + +This library does NOT patch the enumerated type changes, as it is +recommended in the specification that implementations support both integer +and string types for AudioPannerNode.panningModel, AudioPannerNode.distanceModel +BiquadFilterNode.type and OscillatorNode.type. + +*/ +(function (global, exports, perf) { + 'use strict'; + + function fixSetTarget(param) { + if (!param) // if NYI, just return + return; + if (!param.setTargetAtTime) + param.setTargetAtTime = param.setTargetValueAtTime; + } + + if (window.hasOwnProperty('webkitAudioContext') && + !window.hasOwnProperty('AudioContext')) { + window.AudioContext = webkitAudioContext; + + if (!AudioContext.prototype.hasOwnProperty('createGain')) + AudioContext.prototype.createGain = AudioContext.prototype.createGainNode; + if (!AudioContext.prototype.hasOwnProperty('createDelay')) + AudioContext.prototype.createDelay = AudioContext.prototype.createDelayNode; + if (!AudioContext.prototype.hasOwnProperty('createScriptProcessor')) + AudioContext.prototype.createScriptProcessor = AudioContext.prototype.createJavaScriptNode; + if (!AudioContext.prototype.hasOwnProperty('createPeriodicWave')) + AudioContext.prototype.createPeriodicWave = AudioContext.prototype.createWaveTable; + + + AudioContext.prototype.internal_createGain = AudioContext.prototype.createGain; + AudioContext.prototype.createGain = function() { + var node = this.internal_createGain(); + fixSetTarget(node.gain); + return node; + }; + + AudioContext.prototype.internal_createDelay = AudioContext.prototype.createDelay; + AudioContext.prototype.createDelay = function(maxDelayTime) { + var node = maxDelayTime ? this.internal_createDelay(maxDelayTime) : this.internal_createDelay(); + fixSetTarget(node.delayTime); + return node; + }; + + AudioContext.prototype.internal_createBufferSource = AudioContext.prototype.createBufferSource; + AudioContext.prototype.createBufferSource = function() { + var node = this.internal_createBufferSource(); + if (!node.start) { + node.start = function ( when, offset, duration ) { + if ( offset || duration ) + this.noteGrainOn( when || 0, offset, duration ); + else + this.noteOn( when || 0 ); + }; + } else { + node.internal_start = node.start; + node.start = function( when, offset, duration ) { + if( typeof duration !== 'undefined' ) + node.internal_start( when || 0, offset, duration ); + else + node.internal_start( when || 0, offset || 0 ); + }; + } + if (!node.stop) { + node.stop = function ( when ) { + this.noteOff( when || 0 ); + }; + } else { + node.internal_stop = node.stop; + node.stop = function( when ) { + node.internal_stop( when || 0 ); + }; + } + fixSetTarget(node.playbackRate); + return node; + }; + + AudioContext.prototype.internal_createDynamicsCompressor = AudioContext.prototype.createDynamicsCompressor; + AudioContext.prototype.createDynamicsCompressor = function() { + var node = this.internal_createDynamicsCompressor(); + fixSetTarget(node.threshold); + fixSetTarget(node.knee); + fixSetTarget(node.ratio); + fixSetTarget(node.reduction); + fixSetTarget(node.attack); + fixSetTarget(node.release); + return node; + }; + + AudioContext.prototype.internal_createBiquadFilter = AudioContext.prototype.createBiquadFilter; + AudioContext.prototype.createBiquadFilter = function() { + var node = this.internal_createBiquadFilter(); + fixSetTarget(node.frequency); + fixSetTarget(node.detune); + fixSetTarget(node.Q); + fixSetTarget(node.gain); + return node; + }; + + if (AudioContext.prototype.hasOwnProperty( 'createOscillator' )) { + AudioContext.prototype.internal_createOscillator = AudioContext.prototype.createOscillator; + AudioContext.prototype.createOscillator = function() { + var node = this.internal_createOscillator(); + if (!node.start) { + node.start = function ( when ) { + this.noteOn( when || 0 ); + }; + } else { + node.internal_start = node.start; + node.start = function ( when ) { + node.internal_start( when || 0); + }; + } + if (!node.stop) { + node.stop = function ( when ) { + this.noteOff( when || 0 ); + }; + } else { + node.internal_stop = node.stop; + node.stop = function( when ) { + node.internal_stop( when || 0 ); + }; + } + if (!node.setPeriodicWave) + node.setPeriodicWave = node.setWaveTable; + fixSetTarget(node.frequency); + fixSetTarget(node.detune); + return node; + }; + } + } + + if (window.hasOwnProperty('webkitOfflineAudioContext') && + !window.hasOwnProperty('OfflineAudioContext')) { + window.OfflineAudioContext = webkitOfflineAudioContext; + } + +}(window)); + + + +/***/ }), +/* 951 */ +/***/ (function(module, exports) { + +/** +* A polyfill for Array.isArray +*/ +if (!Array.isArray) +{ + Array.isArray = function (arg) + { + return Object.prototype.toString.call(arg) === '[object Array]'; + }; +} + + +/***/ }), +/* 952 */ +/***/ (function(module, exports) { + +/** +* A polyfill for Array.forEach +* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach +*/ +if (!Array.prototype.forEach) +{ + Array.prototype.forEach = function (fun /*, thisArg */) + { + 'use strict'; + + if (this === void 0 || this === null) + { + throw new TypeError(); + } + + var t = Object(this); + var len = t.length >>> 0; + + if (typeof fun !== 'function') + { + throw new TypeError(); + } + + var thisArg = arguments.length >= 2 ? arguments[1] : void 0; + + for (var i = 0; i < len; i++) + { + if (i in t) + { + fun.call(thisArg, t[i], i, t); + } + } + }; +} + + +/***/ }), +/* 953 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(952); +__webpack_require__(951); +__webpack_require__(950); +__webpack_require__(949); +__webpack_require__(948); +__webpack_require__(947); +__webpack_require__(946); +__webpack_require__(945); +__webpack_require__(944); + + +/***/ }), +/* 954 */ +/***/ (function(module, exports, __webpack_require__) { + /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +// Phaser.Physics.Matter.World + +var Bodies = __webpack_require__(92); var Class = __webpack_require__(0); -var Components = __webpack_require__(858); -var Sprite = __webpack_require__(37); +var Composite = __webpack_require__(120); +var Engine = __webpack_require__(955); +var EventEmitter = __webpack_require__(15); +var GetFastValue = __webpack_require__(2); +var GetValue = __webpack_require__(5); +var MatterBody = __webpack_require__(49); +var MatterEvents = __webpack_require__(171); +var MatterWorld = __webpack_require__(462); +var MatterTileBody = __webpack_require__(467); /** * @classdesc - * An Impact Physics Sprite Game Object. + * [description] + * + * @class World + * @extends EventEmitter + * @memberOf Phaser.Physics.Matter + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {object} config - [description] + */ +var World = new Class({ + + Extends: EventEmitter, + + initialize: + + function World (scene, config) + { + EventEmitter.call(this); + + /** + * [description] + * + * @name Phaser.Physics.Matter.World#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Physics.Matter.World#engine + * @type {Matter.Engine} + * @since 3.0.0 + */ + this.engine = Engine.create(config); + + /** + * A `World` composite object that will contain all simulated bodies and constraints. + * + * @name Phaser.Physics.Matter.World#localWorld + * @type {Matter.World} + * @since 3.0.0 + */ + this.localWorld = this.engine.world; + + var gravity = GetValue(config, 'gravity', null); + + if (gravity) + { + this.setGravity(gravity.x, gravity.y, gravity.scale); + } + + /** + * An object containing the 4 wall bodies that bound the physics world. + * + * @name Phaser.Physics.Matter.World#walls + * @type {object} + * @since 3.0.0 + */ + this.walls = { left: null, right: null, top: null, bottom: null }; + + if (GetFastValue(config, 'setBounds', false)) + { + var boundsConfig = config['setBounds']; + + if (typeof boundsConfig === 'boolean') + { + this.setBounds(); + } + else + { + var x = GetFastValue(boundsConfig, 'x', 0); + var y = GetFastValue(boundsConfig, 'y', 0); + var width = GetFastValue(boundsConfig, 'width', scene.sys.game.config.width); + var height = GetFastValue(boundsConfig, 'height', scene.sys.game.config.height); + var thickness = GetFastValue(boundsConfig, 'thickness', 64); + var left = GetFastValue(boundsConfig, 'left', true); + var right = GetFastValue(boundsConfig, 'right', true); + var top = GetFastValue(boundsConfig, 'top', true); + var bottom = GetFastValue(boundsConfig, 'bottom', true); + + this.setBounds(x, y, width, height, thickness, left, right, top, bottom); + } + } + + /** + * [description] + * + * @name Phaser.Physics.Matter.World#enabled + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.enabled = GetValue(config, 'enabled', true); + + /** + * [description] + * + * @name Phaser.Physics.Matter.World#drawDebug + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.drawDebug = GetValue(config, 'debug', false); + + /** + * [description] + * + * @name Phaser.Physics.Matter.World#debugGraphic + * @type {Phaser.GameObjects.Graphics} + * @since 3.0.0 + */ + this.debugGraphic; + + /** + * [description] + * + * @name Phaser.Physics.Matter.World#defaults + * @type {object} + * @since 3.0.0 + */ + this.defaults = { + debugShowBody: GetValue(config, 'debugShowBody', true), + debugShowStaticBody: GetValue(config, 'debugShowStaticBody', true), + debugShowVelocity: GetValue(config, 'debugShowVelocity', true), + bodyDebugColor: GetValue(config, 'debugBodyColor', 0xff00ff), + staticBodyDebugColor: GetValue(config, 'debugBodyColor', 0x0000ff), + velocityDebugColor: GetValue(config, 'debugVelocityColor', 0x00ff00) + }; + + if (this.drawDebug) + { + this.createDebugGraphic(); + } + + this.setEventsProxy(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#setEventsProxy + * @since 3.0.0 + */ + setEventsProxy: function () + { + var _this = this; + var engine = this.engine; + + MatterEvents.on(engine, 'beforeUpdate', function (event) + { + + _this.emit('beforeupdate', event); + + }); + + MatterEvents.on(engine, 'afterUpdate', function (event) + { + + _this.emit('afterupdate', event); + + }); + + MatterEvents.on(engine, 'collisionStart', function (event) + { + + var pairs = event.pairs; + var bodyA; + var bodyB; + + if (pairs.length > 0) + { + bodyA = pairs[0].bodyA; + bodyB = pairs[0].bodyB; + } + + _this.emit('collisionstart', event, bodyA, bodyB); + + }); + + MatterEvents.on(engine, 'collisionActive', function (event) + { + + var pairs = event.pairs; + var bodyA; + var bodyB; + + if (pairs.length > 0) + { + bodyA = pairs[0].bodyA; + bodyB = pairs[0].bodyB; + } + + _this.emit('collisionactive', event, bodyA, bodyB); + + }); + + MatterEvents.on(engine, 'collisionEnd', function (event) + { + + var pairs = event.pairs; + var bodyA; + var bodyB; + + if (pairs.length > 0) + { + bodyA = pairs[0].bodyA; + bodyB = pairs[0].bodyB; + } + + _this.emit('collisionend', event, bodyA, bodyB); + + }); + }, + + /** + * Sets the bounds of the Physics world to match the given world pixel dimensions. + * You can optionally set which 'walls' to create: left, right, top or bottom. + * If none of the walls are given it will default to use the walls settings it had previously. + * I.e. if you previously told it to not have the left or right walls, and you then adjust the world size + * the newly created bounds will also not have the left and right walls. + * Explicitly state them in the parameters to override this. + * + * @method Phaser.Physics.Matter.World#setBounds + * @since 3.0.0 + * + * @param {number} [x=0] - The x coordinate of the top-left corner of the bounds. + * @param {number} [y=0] - The y coordinate of the top-left corner of the bounds. + * @param {number} [width] - The width of the bounds. + * @param {number} [height] - The height of the bounds. + * @param {number} [thickness=128] - The thickness of each wall, in pixels. + * @param {boolean} [left=true] - If true will create the left bounds wall. + * @param {boolean} [right=true] - If true will create the right bounds wall. + * @param {boolean} [top=true] - If true will create the top bounds wall. + * @param {boolean} [bottom=true] - If true will create the bottom bounds wall. + * + * @return {Phaser.Physics.Matter.World} This Matter World object. + */ + setBounds: function (x, y, width, height, thickness, left, right, top, bottom) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = this.scene.sys.game.config.width; } + if (height === undefined) { height = this.scene.sys.game.config.height; } + if (thickness === undefined) { thickness = 128; } + if (left === undefined) { left = true; } + if (right === undefined) { right = true; } + if (top === undefined) { top = true; } + if (bottom === undefined) { bottom = true; } + + this.updateWall(left, 'left', x - thickness, y, thickness, height); + this.updateWall(right, 'right', x + width, y, thickness, height); + this.updateWall(top, 'top', x, y - thickness, width, thickness); + this.updateWall(bottom, 'bottom', x, y + height, width, thickness); + + return this; + }, + + // position = 'left', 'right', 'top' or 'bottom' + /** + * [description] + * + * @method Phaser.Physics.Matter.World#updateWall + * @since 3.0.0 + * + * @param {boolean} add - [description] + * @param {string} position - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + */ + updateWall: function (add, position, x, y, width, height) + { + var wall = this.walls[position]; + + if (add) + { + if (wall) + { + MatterWorld.remove(this.localWorld, wall); + } + + // adjust center + x += (width / 2); + y += (height / 2); + + this.walls[position] = this.create(x, y, width, height, { isStatic: true, friction: 0, frictionStatic: 0 }); + } + else + { + if (wall) + { + MatterWorld.remove(this.localWorld, wall); + } + + this.walls[position] = null; + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#createDebugGraphic + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} [description] + */ + createDebugGraphic: function () + { + var graphic = this.scene.sys.add.graphics({ x: 0, y: 0 }); + + graphic.setZ(Number.MAX_VALUE); + + this.debugGraphic = graphic; + + this.drawDebug = true; + + return graphic; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#disableGravity + * @since 3.0.0 + * + * @return {Phaser.Physics.Matter.World} This Matter World object. + */ + disableGravity: function () + { + this.localWorld.gravity.x = 0; + this.localWorld.gravity.y = 0; + this.localWorld.gravity.scale = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#setGravity + * @since 3.0.0 + * + * @param {number} [x=0] - [description] + * @param {number} [y=1] - [description] + * @param {number} [scale] - [description] + * + * @return {Phaser.Physics.Matter.World} This Matter World object. + */ + setGravity: function (x, y, scale) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 1; } + + this.localWorld.gravity.x = x; + this.localWorld.gravity.y = y; + + if (scale !== undefined) + { + this.localWorld.gravity.scale = scale; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#create + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {object} options - [description] + * + * @return {Matter.Body} [description] + */ + create: function (x, y, width, height, options) + { + var body = Bodies.rectangle(x, y, width, height, options); + + MatterWorld.add(this.localWorld, body); + + return body; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#add + * @since 3.0.0 + * + * @param {(object|object[])} object - Can be single or an array, and can be a body, composite or constraint + * + * @return {Phaser.Physics.Matter.World} This Matter World object. + */ + add: function (object) + { + MatterWorld.add(this.localWorld, object); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#remove + * @since 3.0.0 + * + * @param {object} object - The object to be removed from the world. + * @param {boolean} deep - [description] + * + * @return {Phaser.Physics.Matter.World} This Matter World object. + */ + remove: function (object, deep) + { + var body = (object.body) ? object.body : object; + + Composite.removeBody(this.localWorld, body, deep); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#removeConstraint + * @since 3.0.0 + * + * @param {Matter.Constraint} constraint - [description] + * @param {boolean} deep - [description] + * + * @return {Phaser.Physics.Matter.World} This Matter World object. + */ + removeConstraint: function (constraint, deep) + { + Composite.remove(this.localWorld, constraint, deep); + + return this; + }, + + /** + * Adds MatterTileBody instances for all the colliding tiles within the given tilemap layer. Set + * the appropriate tiles in your layer to collide before calling this method! + * + * @method Phaser.Physics.Matter.World#convertTilemapLayer + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.StaticTilemapLayer|Phaser.GameObjects.DynamicTilemapLayer)} tilemapLayer - + * An array of tiles. + * @param {object} [options] - Options to be passed to the MatterTileBody constructor. {@ee Phaser.Physics.Matter.TileBody} + * + * @return {Phaser.Physics.Matter.World} This Matter World object. + */ + convertTilemapLayer: function (tilemapLayer, options) + { + var layerData = tilemapLayer.layer; + var tiles = tilemapLayer.getTilesWithin(0, 0, layerData.width, layerData.height, {isColliding: true}); + + this.convertTiles(tiles, options); + + return this; + }, + + /** + * Adds MatterTileBody instances for the given tiles. This adds bodies regardless of whether the + * tiles are set to collide or not. + * + * @method Phaser.Physics.Matter.World#convertTiles + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Tile[]} tiles - An array of tiles. + * @param {object} [options] - Options to be passed to the MatterTileBody constructor. {@see Phaser.Physics.Matter.TileBody} + * + * @return {Phaser.Physics.Matter.World} This Matter World object. + */ + convertTiles: function (tiles, options) + { + if (tiles.length === 0) + { + return this; + } + + for (var i = 0; i < tiles.length; i++) + { + new MatterTileBody(this, tiles[i], options); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#nextGroup + * @since 3.0.0 + * + * @param {boolean} isNonColliding - [description] + * + * @return {number} [description] + */ + nextGroup: function (isNonColliding) + { + return MatterBody.nextGroup(isNonColliding); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#nextCategory + * @since 3.0.0 + * + * @return {number} [description] + */ + nextCategory: function () + { + return MatterBody.nextCategory(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#pause + * @since 3.0.0 + * + * @return {Phaser.Physics.Matter.World} This Matter World object. + */ + pause: function () + { + this.enabled = false; + + this.emit('pause'); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#resume + * @since 3.0.0 + * + * @return {Phaser.Physics.Matter.World} This Matter World object. + */ + resume: function () + { + this.enabled = true; + + this.emit('resume'); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#update + * @since 3.0.0 + * + * @param {number} time - [description] + * @param {number} delta - [description] + */ + update: function (time, delta) + { + if (this.enabled) + { + var correction = 1; + + Engine.update(this.engine, delta, correction); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#postUpdate + * @since 3.0.0 + */ + postUpdate: function () + { + if (!this.drawDebug) + { + return; + } + + var graphics = this.debugGraphic; + var bodies = Composite.allBodies(this.localWorld); + + graphics.clear(); + graphics.lineStyle(1, this.defaults.bodyDebugColor); + graphics.beginPath(); + + for (var i = 0; i < bodies.length; i++) + { + if (!bodies[i].render.visible) + { + return; + } + + // Handle drawing both single bodies and compound bodies. If compound, draw both the + // convex hull (first part) and the rest of the bodies. + for (var j = 0; j < bodies[i].parts.length; j++) + { + var body = bodies[i].parts[j]; + + var vertices = body.vertices; + + graphics.moveTo(vertices[0].x, vertices[0].y); + + for (var k = 1; k < vertices.length; k++) + { + graphics.lineTo(vertices[k].x, vertices[k].y); + } + + graphics.lineTo(vertices[0].x, vertices[0].y); + + graphics.strokePath(); + } + } + + graphics.closePath(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#fromPath + * @since 3.0.0 + * + * @param {string} path - [description] + * @param {array} points - [description] + * + * @return {array} [description] + */ + fromPath: function (path, points) + { + if (points === undefined) { points = []; } + + // var pathPattern = /L?\s*([-\d.e]+)[\s,]*([-\d.e]+)*/ig; + + // eslint-disable-next-line no-useless-escape + var pathPattern = /L?\s*([\-\d\.e]+)[\s,]*([\-\d\.e]+)*/ig; + + path.replace(pathPattern, function (match, x, y) + { + points.push({ x: parseFloat(x), y: parseFloat(y) }); + }); + + return points; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + MatterWorld.clear(this.localWorld, false); + + Engine.clear(this.engine); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + } + +}); + +module.exports = World; + + +/***/ }), +/* 955 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Engine` module contains methods for creating and manipulating engines. +* An engine is a controller that manages updating the simulation of the world. +* See `Matter.Runner` for an optional game loop utility. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Engine +*/ + +var Engine = {}; + +module.exports = Engine; + +var World = __webpack_require__(462); +var Sleeping = __webpack_require__(198); +var Resolver = __webpack_require__(956); +var Pairs = __webpack_require__(957); +var Metrics = __webpack_require__(982); +var Grid = __webpack_require__(958); +var Events = __webpack_require__(171); +var Composite = __webpack_require__(120); +var Constraint = __webpack_require__(170); +var Common = __webpack_require__(39); +var Body = __webpack_require__(49); + +(function() { + + /** + * Creates a new engine. The options parameter is an object that specifies any properties you wish to override the defaults. + * All properties have default values, and many are pre-calculated automatically based on other properties. + * See the properties section below for detailed information on what you can pass via the `options` object. + * @method create + * @param {object} [options] + * @return {engine} engine + */ + Engine.create = function(element, options) { + // options may be passed as the first (and only) argument + options = Common.isElement(element) ? options : element; + element = Common.isElement(element) ? element : null; + options = options || {}; + + if (element || options.render) { + Common.warn('Engine.create: engine.render is deprecated (see docs)'); + } + + var defaults = { + positionIterations: 6, + velocityIterations: 4, + constraintIterations: 2, + enableSleeping: false, + events: [], + plugin: {}, + timing: { + timestamp: 0, + timeScale: 1 + }, + broadphase: { + controller: Grid + } + }; + + var engine = Common.extend(defaults, options); + + /* + // @deprecated + if (element || engine.render) { + var renderDefaults = { + element: element, + controller: Render + }; + + engine.render = Common.extend(renderDefaults, engine.render); + } + + // @deprecated + if (engine.render && engine.render.controller) { + engine.render = engine.render.controller.create(engine.render); + } + + // @deprecated + if (engine.render) { + engine.render.engine = engine; + } + */ + + engine.world = options.world || World.create(engine.world); + engine.pairs = Pairs.create(); + engine.broadphase = engine.broadphase.controller.create(engine.broadphase); + engine.metrics = engine.metrics || { extended: false }; + + // @if DEBUG + engine.metrics = Metrics.create(engine.metrics); + // @endif + + return engine; + }; + + /** + * Moves the simulation forward in time by `delta` ms. + * The `correction` argument is an optional `Number` that specifies the time correction factor to apply to the update. + * This can help improve the accuracy of the simulation in cases where `delta` is changing between updates. + * The value of `correction` is defined as `delta / lastDelta`, i.e. the percentage change of `delta` over the last step. + * Therefore the value is always `1` (no correction) when `delta` constant (or when no correction is desired, which is the default). + * See the paper on Time Corrected Verlet for more information. + * + * Triggers `beforeUpdate` and `afterUpdate` events. + * Triggers `collisionStart`, `collisionActive` and `collisionEnd` events. + * @method update + * @param {engine} engine + * @param {number} [delta=16.666] + * @param {number} [correction=1] + */ + Engine.update = function(engine, delta, correction) { + delta = delta || 1000 / 60; + correction = correction || 1; + + var world = engine.world, + timing = engine.timing, + broadphase = engine.broadphase, + broadphasePairs = [], + i; + + // increment timestamp + timing.timestamp += delta * timing.timeScale; + + // create an event object + var event = { + timestamp: timing.timestamp + }; + + Events.trigger(engine, 'beforeUpdate', event); + + // get lists of all bodies and constraints, no matter what composites they are in + var allBodies = Composite.allBodies(world), + allConstraints = Composite.allConstraints(world); + + // @if DEBUG + // reset metrics logging + Metrics.reset(engine.metrics); + // @endif + + // if sleeping enabled, call the sleeping controller + if (engine.enableSleeping) + Sleeping.update(allBodies, timing.timeScale); + + // applies gravity to all bodies + _bodiesApplyGravity(allBodies, world.gravity); + + // update all body position and rotation by integration + _bodiesUpdate(allBodies, delta, timing.timeScale, correction, world.bounds); + + // update all constraints (first pass) + Constraint.preSolveAll(allBodies); + for (i = 0; i < engine.constraintIterations; i++) { + Constraint.solveAll(allConstraints, timing.timeScale); + } + Constraint.postSolveAll(allBodies); + + // broadphase pass: find potential collision pairs + if (broadphase.controller) { + // if world is dirty, we must flush the whole grid + if (world.isModified) + broadphase.controller.clear(broadphase); + + // update the grid buckets based on current bodies + broadphase.controller.update(broadphase, allBodies, engine, world.isModified); + broadphasePairs = broadphase.pairsList; + } else { + // if no broadphase set, we just pass all bodies + broadphasePairs = allBodies; + } + + // clear all composite modified flags + if (world.isModified) { + Composite.setModified(world, false, false, true); + } + + // narrowphase pass: find actual collisions, then create or update collision pairs + var collisions = broadphase.detector(broadphasePairs, engine); + + // update collision pairs + var pairs = engine.pairs, + timestamp = timing.timestamp; + Pairs.update(pairs, collisions, timestamp); + Pairs.removeOld(pairs, timestamp); + + // wake up bodies involved in collisions + if (engine.enableSleeping) + Sleeping.afterCollisions(pairs.list, timing.timeScale); + + // trigger collision events + if (pairs.collisionStart.length > 0) + Events.trigger(engine, 'collisionStart', { pairs: pairs.collisionStart }); + + // iteratively resolve position between collisions + Resolver.preSolvePosition(pairs.list); + for (i = 0; i < engine.positionIterations; i++) { + Resolver.solvePosition(pairs.list, allBodies, timing.timeScale); + } + Resolver.postSolvePosition(allBodies); + + // update all constraints (second pass) + Constraint.preSolveAll(allBodies); + for (i = 0; i < engine.constraintIterations; i++) { + Constraint.solveAll(allConstraints, timing.timeScale); + } + Constraint.postSolveAll(allBodies); + + // iteratively resolve velocity between collisions + Resolver.preSolveVelocity(pairs.list); + for (i = 0; i < engine.velocityIterations; i++) { + Resolver.solveVelocity(pairs.list, timing.timeScale); + } + + // trigger collision events + if (pairs.collisionActive.length > 0) + Events.trigger(engine, 'collisionActive', { pairs: pairs.collisionActive }); + + if (pairs.collisionEnd.length > 0) + Events.trigger(engine, 'collisionEnd', { pairs: pairs.collisionEnd }); + + // @if DEBUG + // update metrics log + Metrics.update(engine.metrics, engine); + // @endif + + // clear force buffers + _bodiesClearForces(allBodies); + + Events.trigger(engine, 'afterUpdate', event); + + return engine; + }; + + /** + * Merges two engines by keeping the configuration of `engineA` but replacing the world with the one from `engineB`. + * @method merge + * @param {engine} engineA + * @param {engine} engineB + */ + Engine.merge = function(engineA, engineB) { + Common.extend(engineA, engineB); + + if (engineB.world) { + engineA.world = engineB.world; + + Engine.clear(engineA); + + var bodies = Composite.allBodies(engineA.world); + + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i]; + Sleeping.set(body, false); + body.id = Common.nextId(); + } + } + }; + + /** + * Clears the engine including the world, pairs and broadphase. + * @method clear + * @param {engine} engine + */ + Engine.clear = function(engine) { + var world = engine.world; + + Pairs.clear(engine.pairs); + + var broadphase = engine.broadphase; + if (broadphase.controller) { + var bodies = Composite.allBodies(world); + broadphase.controller.clear(broadphase); + broadphase.controller.update(broadphase, bodies, engine, true); + } + }; + + /** + * Zeroes the `body.force` and `body.torque` force buffers. + * @method bodiesClearForces + * @private + * @param {body[]} bodies + */ + var _bodiesClearForces = function(bodies) { + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i]; + + // reset force buffers + body.force.x = 0; + body.force.y = 0; + body.torque = 0; + } + }; + + /** + * Applys a mass dependant force to all given bodies. + * @method bodiesApplyGravity + * @private + * @param {body[]} bodies + * @param {vector} gravity + */ + var _bodiesApplyGravity = function(bodies, gravity) { + var gravityScale = typeof gravity.scale !== 'undefined' ? gravity.scale : 0.001; + + if ((gravity.x === 0 && gravity.y === 0) || gravityScale === 0) { + return; + } + + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i]; + + if (body.ignoreGravity || body.isStatic || body.isSleeping) + continue; + + // apply gravity + body.force.y += body.mass * gravity.y * gravityScale; + body.force.x += body.mass * gravity.x * gravityScale; + } + }; + + /** + * Applys `Body.update` to all given `bodies`. + * @method updateAll + * @private + * @param {body[]} bodies + * @param {number} deltaTime + * The amount of time elapsed between updates + * @param {number} timeScale + * @param {number} correction + * The Verlet correction factor (deltaTime / lastDeltaTime) + * @param {bounds} worldBounds + */ + var _bodiesUpdate = function(bodies, deltaTime, timeScale, correction, worldBounds) { + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i]; + + if (body.isStatic || body.isSleeping) + continue; + + Body.update(body, deltaTime, timeScale, correction); + } + }; + + /** + * An alias for `Runner.run`, see `Matter.Runner` for more information. + * @method run + * @param {engine} engine + */ + + /** + * Fired just before an update + * + * @event beforeUpdate + * @param {} event An event object + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired after engine update and all collision events + * + * @event afterUpdate + * @param {} event An event object + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired after engine update, provides a list of all pairs that have started to collide in the current tick (if any) + * + * @event collisionStart + * @param {} event An event object + * @param {} event.pairs List of affected pairs + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired after engine update, provides a list of all pairs that are colliding in the current tick (if any) + * + * @event collisionActive + * @param {} event An event object + * @param {} event.pairs List of affected pairs + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired after engine update, provides a list of all pairs that have ended collision in the current tick (if any) + * + * @event collisionEnd + * @param {} event An event object + * @param {} event.pairs List of affected pairs + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /* + * + * Properties Documentation + * + */ + + /** + * An integer `Number` that specifies the number of position iterations to perform each update. + * The higher the value, the higher quality the simulation will be at the expense of performance. + * + * @property positionIterations + * @type number + * @default 6 + */ + + /** + * An integer `Number` that specifies the number of velocity iterations to perform each update. + * The higher the value, the higher quality the simulation will be at the expense of performance. + * + * @property velocityIterations + * @type number + * @default 4 + */ + + /** + * An integer `Number` that specifies the number of constraint iterations to perform each update. + * The higher the value, the higher quality the simulation will be at the expense of performance. + * The default value of `2` is usually very adequate. + * + * @property constraintIterations + * @type number + * @default 2 + */ + + /** + * A flag that specifies whether the engine should allow sleeping via the `Matter.Sleeping` module. + * Sleeping can improve stability and performance, but often at the expense of accuracy. + * + * @property enableSleeping + * @type boolean + * @default false + */ + + /** + * An `Object` containing properties regarding the timing systems of the engine. + * + * @property timing + * @type object + */ + + /** + * A `Number` that specifies the global scaling factor of time for all bodies. + * A value of `0` freezes the simulation. + * A value of `0.1` gives a slow-motion effect. + * A value of `1.2` gives a speed-up effect. + * + * @property timing.timeScale + * @type number + * @default 1 + */ + + /** + * A `Number` that specifies the current simulation-time in milliseconds starting from `0`. + * It is incremented on every `Engine.update` by the given `delta` argument. + * + * @property timing.timestamp + * @type number + * @default 0 + */ + + /** + * An instance of a `Render` controller. The default value is a `Matter.Render` instance created by `Engine.create`. + * One may also develop a custom renderer module based on `Matter.Render` and pass an instance of it to `Engine.create` via `options.render`. + * + * A minimal custom renderer object must define at least three functions: `create`, `clear` and `world` (see `Matter.Render`). + * It is also possible to instead pass the _module_ reference via `options.render.controller` and `Engine.create` will instantiate one for you. + * + * @property render + * @type render + * @deprecated see Demo.js for an example of creating a renderer + * @default a Matter.Render instance + */ + + /** + * An instance of a broadphase controller. The default value is a `Matter.Grid` instance created by `Engine.create`. + * + * @property broadphase + * @type grid + * @default a Matter.Grid instance + */ + + /** + * A `World` composite object that will contain all simulated bodies and constraints. + * + * @property world + * @type world + * @default a Matter.World instance + */ + + /** + * An object reserved for storing plugin-specific properties. + * + * @property plugin + * @type {} + */ + +})(); + + +/***/ }), +/* 956 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Resolver` module contains methods for resolving collision pairs. +* +* @class Resolver +*/ + +var Resolver = {}; + +module.exports = Resolver; + +var Vertices = __webpack_require__(91); +var Vector = __webpack_require__(90); +var Common = __webpack_require__(39); +var Bounds = __webpack_require__(89); + +(function() { + + Resolver._restingThresh = 4; + Resolver._restingThreshTangent = 6; + Resolver._positionDampen = 0.9; + Resolver._positionWarming = 0.8; + Resolver._frictionNormalMultiplier = 5; + + /** + * Prepare pairs for position solving. + * @method preSolvePosition + * @param {pair[]} pairs + */ + Resolver.preSolvePosition = function(pairs) { + var i, + pair, + activeCount; + + // find total contacts on each body + for (i = 0; i < pairs.length; i++) { + pair = pairs[i]; + + if (!pair.isActive) + continue; + + activeCount = pair.activeContacts.length; + pair.collision.parentA.totalContacts += activeCount; + pair.collision.parentB.totalContacts += activeCount; + } + }; + + /** + * Find a solution for pair positions. + * @method solvePosition + * @param {pair[]} pairs + * @param {number} timeScale + */ + Resolver.solvePosition = function(pairs, bodies, timeScale) { + var i, + normalX, + normalY, + pair, + collision, + bodyA, + bodyB, + normal, + separation, + penetration, + positionImpulseA, + positionImpulseB, + contactShare, + bodyBtoAX, + bodyBtoAY, + positionImpulse, + impulseCoefficient = timeScale * Resolver._positionDampen; + + for (i = 0; i < bodies.length; i++) { + var body = bodies[i]; + body.previousPositionImpulse.x = body.positionImpulse.x; + body.previousPositionImpulse.y = body.positionImpulse.y; + } + + // find impulses required to resolve penetration + for (i = 0; i < pairs.length; i++) { + pair = pairs[i]; + + if (!pair.isActive || pair.isSensor) + continue; + + collision = pair.collision; + bodyA = collision.parentA; + bodyB = collision.parentB; + normal = collision.normal; + + positionImpulseA = bodyA.previousPositionImpulse; + positionImpulseB = bodyB.previousPositionImpulse; + + penetration = collision.penetration; + + // bodyBtoA = positionImpulseB - positionImpulseA + penetration + bodyBtoAX = positionImpulseB.x - positionImpulseA.x + penetration.x; + bodyBtoAY = positionImpulseB.y - positionImpulseA.y + penetration.y; + + normalX = normal.x; + normalY = normal.y; + + // separation = dot(normal, bodyBtoA) + separation = normalX * bodyBtoAX + normalY * bodyBtoAY; + pair.separation = separation; + + positionImpulse = (separation - pair.slop) * impulseCoefficient; + + if (bodyA.isStatic || bodyB.isStatic) + positionImpulse *= 2; + + if (!(bodyA.isStatic || bodyA.isSleeping)) { + contactShare = positionImpulse / bodyA.totalContacts; + bodyA.positionImpulse.x += normalX * contactShare; + bodyA.positionImpulse.y += normalY * contactShare; + } + + if (!(bodyB.isStatic || bodyB.isSleeping)) { + contactShare = positionImpulse / bodyB.totalContacts; + bodyB.positionImpulse.x -= normalX * contactShare; + bodyB.positionImpulse.y -= normalY * contactShare; + } + } + }; + + /** + * Apply position resolution. + * @method postSolvePosition + * @param {body[]} bodies + */ + Resolver.postSolvePosition = function(bodies) { + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i]; + + // reset contact count + body.totalContacts = 0; + + if (body.positionImpulse.x !== 0 || body.positionImpulse.y !== 0) { + // update body geometry + for (var j = 0; j < body.parts.length; j++) { + var part = body.parts[j]; + Vertices.translate(part.vertices, body.positionImpulse); + Bounds.update(part.bounds, part.vertices, body.velocity); + part.position.x += body.positionImpulse.x; + part.position.y += body.positionImpulse.y; + } + + // move the body without changing velocity + body.positionPrev.x += body.positionImpulse.x; + body.positionPrev.y += body.positionImpulse.y; + + if (Vector.dot(body.positionImpulse, body.velocity) < 0) { + // reset cached impulse if the body has velocity along it + body.positionImpulse.x = 0; + body.positionImpulse.y = 0; + } else { + // warm the next iteration + body.positionImpulse.x *= Resolver._positionWarming; + body.positionImpulse.y *= Resolver._positionWarming; + } + } + } + }; + + /** + * Prepare pairs for velocity solving. + * @method preSolveVelocity + * @param {pair[]} pairs + */ + Resolver.preSolveVelocity = function(pairs) { + var i, + j, + pair, + contacts, + collision, + bodyA, + bodyB, + normal, + tangent, + contact, + contactVertex, + normalImpulse, + tangentImpulse, + offset, + impulse = Vector._temp[0], + tempA = Vector._temp[1]; + + for (i = 0; i < pairs.length; i++) { + pair = pairs[i]; + + if (!pair.isActive || pair.isSensor) + continue; + + contacts = pair.activeContacts; + collision = pair.collision; + bodyA = collision.parentA; + bodyB = collision.parentB; + normal = collision.normal; + tangent = collision.tangent; + + // resolve each contact + for (j = 0; j < contacts.length; j++) { + contact = contacts[j]; + contactVertex = contact.vertex; + normalImpulse = contact.normalImpulse; + tangentImpulse = contact.tangentImpulse; + + if (normalImpulse !== 0 || tangentImpulse !== 0) { + // total impulse from contact + impulse.x = (normal.x * normalImpulse) + (tangent.x * tangentImpulse); + impulse.y = (normal.y * normalImpulse) + (tangent.y * tangentImpulse); + + // apply impulse from contact + if (!(bodyA.isStatic || bodyA.isSleeping)) { + offset = Vector.sub(contactVertex, bodyA.position, tempA); + bodyA.positionPrev.x += impulse.x * bodyA.inverseMass; + bodyA.positionPrev.y += impulse.y * bodyA.inverseMass; + bodyA.anglePrev += Vector.cross(offset, impulse) * bodyA.inverseInertia; + } + + if (!(bodyB.isStatic || bodyB.isSleeping)) { + offset = Vector.sub(contactVertex, bodyB.position, tempA); + bodyB.positionPrev.x -= impulse.x * bodyB.inverseMass; + bodyB.positionPrev.y -= impulse.y * bodyB.inverseMass; + bodyB.anglePrev -= Vector.cross(offset, impulse) * bodyB.inverseInertia; + } + } + } + } + }; + + /** + * Find a solution for pair velocities. + * @method solveVelocity + * @param {pair[]} pairs + * @param {number} timeScale + */ + Resolver.solveVelocity = function(pairs, timeScale) { + var timeScaleSquared = timeScale * timeScale, + impulse = Vector._temp[0], + tempA = Vector._temp[1], + tempB = Vector._temp[2], + tempC = Vector._temp[3], + tempD = Vector._temp[4], + tempE = Vector._temp[5]; + + for (var i = 0; i < pairs.length; i++) { + var pair = pairs[i]; + + if (!pair.isActive || pair.isSensor) + continue; + + var collision = pair.collision, + bodyA = collision.parentA, + bodyB = collision.parentB, + normal = collision.normal, + tangent = collision.tangent, + contacts = pair.activeContacts, + contactShare = 1 / contacts.length; + + // update body velocities + bodyA.velocity.x = bodyA.position.x - bodyA.positionPrev.x; + bodyA.velocity.y = bodyA.position.y - bodyA.positionPrev.y; + bodyB.velocity.x = bodyB.position.x - bodyB.positionPrev.x; + bodyB.velocity.y = bodyB.position.y - bodyB.positionPrev.y; + bodyA.angularVelocity = bodyA.angle - bodyA.anglePrev; + bodyB.angularVelocity = bodyB.angle - bodyB.anglePrev; + + // resolve each contact + for (var j = 0; j < contacts.length; j++) { + var contact = contacts[j], + contactVertex = contact.vertex, + offsetA = Vector.sub(contactVertex, bodyA.position, tempA), + offsetB = Vector.sub(contactVertex, bodyB.position, tempB), + velocityPointA = Vector.add(bodyA.velocity, Vector.mult(Vector.perp(offsetA), bodyA.angularVelocity), tempC), + velocityPointB = Vector.add(bodyB.velocity, Vector.mult(Vector.perp(offsetB), bodyB.angularVelocity), tempD), + relativeVelocity = Vector.sub(velocityPointA, velocityPointB, tempE), + normalVelocity = Vector.dot(normal, relativeVelocity); + + var tangentVelocity = Vector.dot(tangent, relativeVelocity), + tangentSpeed = Math.abs(tangentVelocity), + tangentVelocityDirection = Common.sign(tangentVelocity); + + // raw impulses + var normalImpulse = (1 + pair.restitution) * normalVelocity, + normalForce = Common.clamp(pair.separation + normalVelocity, 0, 1) * Resolver._frictionNormalMultiplier; + + // coulomb friction + var tangentImpulse = tangentVelocity, + maxFriction = Infinity; + + if (tangentSpeed > pair.friction * pair.frictionStatic * normalForce * timeScaleSquared) { + maxFriction = tangentSpeed; + tangentImpulse = Common.clamp( + pair.friction * tangentVelocityDirection * timeScaleSquared, + -maxFriction, maxFriction + ); + } + + // modify impulses accounting for mass, inertia and offset + var oAcN = Vector.cross(offsetA, normal), + oBcN = Vector.cross(offsetB, normal), + share = contactShare / (bodyA.inverseMass + bodyB.inverseMass + bodyA.inverseInertia * oAcN * oAcN + bodyB.inverseInertia * oBcN * oBcN); + + normalImpulse *= share; + tangentImpulse *= share; + + // handle high velocity and resting collisions separately + if (normalVelocity < 0 && normalVelocity * normalVelocity > Resolver._restingThresh * timeScaleSquared) { + // high normal velocity so clear cached contact normal impulse + contact.normalImpulse = 0; + } else { + // solve resting collision constraints using Erin Catto's method (GDC08) + // impulse constraint tends to 0 + var contactNormalImpulse = contact.normalImpulse; + contact.normalImpulse = Math.min(contact.normalImpulse + normalImpulse, 0); + normalImpulse = contact.normalImpulse - contactNormalImpulse; + } + + // handle high velocity and resting collisions separately + if (tangentVelocity * tangentVelocity > Resolver._restingThreshTangent * timeScaleSquared) { + // high tangent velocity so clear cached contact tangent impulse + contact.tangentImpulse = 0; + } else { + // solve resting collision constraints using Erin Catto's method (GDC08) + // tangent impulse tends to -tangentSpeed or +tangentSpeed + var contactTangentImpulse = contact.tangentImpulse; + contact.tangentImpulse = Common.clamp(contact.tangentImpulse + tangentImpulse, -maxFriction, maxFriction); + tangentImpulse = contact.tangentImpulse - contactTangentImpulse; + } + + // total impulse from contact + impulse.x = (normal.x * normalImpulse) + (tangent.x * tangentImpulse); + impulse.y = (normal.y * normalImpulse) + (tangent.y * tangentImpulse); + + // apply impulse from contact + if (!(bodyA.isStatic || bodyA.isSleeping)) { + bodyA.positionPrev.x += impulse.x * bodyA.inverseMass; + bodyA.positionPrev.y += impulse.y * bodyA.inverseMass; + bodyA.anglePrev += Vector.cross(offsetA, impulse) * bodyA.inverseInertia; + } + + if (!(bodyB.isStatic || bodyB.isSleeping)) { + bodyB.positionPrev.x -= impulse.x * bodyB.inverseMass; + bodyB.positionPrev.y -= impulse.y * bodyB.inverseMass; + bodyB.anglePrev -= Vector.cross(offsetB, impulse) * bodyB.inverseInertia; + } + } + } + }; + +})(); + + +/***/ }), +/* 957 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Pairs` module contains methods for creating and manipulating collision pair sets. +* +* @class Pairs +*/ + +var Pairs = {}; + +module.exports = Pairs; + +var Pair = __webpack_require__(370); +var Common = __webpack_require__(39); + +(function() { + + var _pairMaxIdleLife = 1000; + + /** + * Creates a new pairs structure. + * @method create + * @param {object} options + * @return {pairs} A new pairs structure + */ + Pairs.create = function(options) { + return Common.extend({ + table: {}, + list: [], + collisionStart: [], + collisionActive: [], + collisionEnd: [] + }, options); + }; + + /** + * Updates pairs given a list of collisions. + * @method update + * @param {object} pairs + * @param {collision[]} collisions + * @param {number} timestamp + */ + Pairs.update = function(pairs, collisions, timestamp) { + var pairsList = pairs.list, + pairsTable = pairs.table, + collisionStart = pairs.collisionStart, + collisionEnd = pairs.collisionEnd, + collisionActive = pairs.collisionActive, + collision, + pairId, + pair, + i; + + // clear collision state arrays, but maintain old reference + collisionStart.length = 0; + collisionEnd.length = 0; + collisionActive.length = 0; + + for (i = 0; i < pairsList.length; i++) { + pairsList[i].confirmedActive = false; + } + + for (i = 0; i < collisions.length; i++) { + collision = collisions[i]; + + if (collision.collided) { + pairId = Pair.id(collision.bodyA, collision.bodyB); + + pair = pairsTable[pairId]; + + if (pair) { + // pair already exists (but may or may not be active) + if (pair.isActive) { + // pair exists and is active + collisionActive.push(pair); + } else { + // pair exists but was inactive, so a collision has just started again + collisionStart.push(pair); + } + + // update the pair + Pair.update(pair, collision, timestamp); + pair.confirmedActive = true; + } else { + // pair did not exist, create a new pair + pair = Pair.create(collision, timestamp); + pairsTable[pairId] = pair; + + // push the new pair + collisionStart.push(pair); + pairsList.push(pair); + } + } + } + + // deactivate previously active pairs that are now inactive + for (i = 0; i < pairsList.length; i++) { + pair = pairsList[i]; + if (!pair.confirmedActive) { + Pair.setActive(pair, false, timestamp); + collisionEnd.push(pair); + } + } + }; + + /** + * Finds and removes pairs that have been inactive for a set amount of time. + * @method removeOld + * @param {object} pairs + * @param {number} timestamp + */ + Pairs.removeOld = function(pairs, timestamp) { + var pairsList = pairs.list, + pairsTable = pairs.table, + indexesToRemove = [], + pair, + collision, + pairIndex, + i; + + for (i = 0; i < pairsList.length; i++) { + pair = pairsList[i]; + collision = pair.collision; + + // never remove sleeping pairs + if (collision.bodyA.isSleeping || collision.bodyB.isSleeping) { + pair.timeUpdated = timestamp; + continue; + } + + // if pair is inactive for too long, mark it to be removed + if (timestamp - pair.timeUpdated > _pairMaxIdleLife) { + indexesToRemove.push(i); + } + } + + // remove marked pairs + for (i = 0; i < indexesToRemove.length; i++) { + pairIndex = indexesToRemove[i] - i; + pair = pairsList[pairIndex]; + delete pairsTable[pair.id]; + pairsList.splice(pairIndex, 1); + } + }; + + /** + * Clears the given pairs structure. + * @method clear + * @param {pairs} pairs + * @return {pairs} pairs + */ + Pairs.clear = function(pairs) { + pairs.table = {}; + pairs.list.length = 0; + pairs.collisionStart.length = 0; + pairs.collisionActive.length = 0; + pairs.collisionEnd.length = 0; + return pairs; + }; + +})(); + + +/***/ }), +/* 958 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Grid` module contains methods for creating and manipulating collision broadphase grid structures. +* +* @class Grid +*/ + +var Grid = {}; + +module.exports = Grid; + +var Pair = __webpack_require__(370); +var Detector = __webpack_require__(466); +var Common = __webpack_require__(39); + +(function() { + + /** + * Creates a new grid. + * @method create + * @param {} options + * @return {grid} A new grid + */ + Grid.create = function(options) { + var defaults = { + controller: Grid, + detector: Detector.collisions, + buckets: {}, + pairs: {}, + pairsList: [], + bucketWidth: 48, + bucketHeight: 48 + }; + + return Common.extend(defaults, options); + }; + + /** + * The width of a single grid bucket. + * + * @property bucketWidth + * @type number + * @default 48 + */ + + /** + * The height of a single grid bucket. + * + * @property bucketHeight + * @type number + * @default 48 + */ + + /** + * Updates the grid. + * @method update + * @param {grid} grid + * @param {body[]} bodies + * @param {engine} engine + * @param {boolean} forceUpdate + */ + Grid.update = function(grid, bodies, engine, forceUpdate) { + var i, col, row, + world = engine.world, + buckets = grid.buckets, + bucket, + bucketId, + gridChanged = false; + + // @if DEBUG + var metrics = engine.metrics; + metrics.broadphaseTests = 0; + // @endif + + for (i = 0; i < bodies.length; i++) { + var body = bodies[i]; + + if (body.isSleeping && !forceUpdate) + continue; + + // don't update out of world bodies + if (body.bounds.max.x < world.bounds.min.x || body.bounds.min.x > world.bounds.max.x + || body.bounds.max.y < world.bounds.min.y || body.bounds.min.y > world.bounds.max.y) + continue; + + var newRegion = _getRegion(grid, body); + + // if the body has changed grid region + if (!body.region || newRegion.id !== body.region.id || forceUpdate) { + + // @if DEBUG + metrics.broadphaseTests += 1; + // @endif + + if (!body.region || forceUpdate) + body.region = newRegion; + + var union = _regionUnion(newRegion, body.region); + + // update grid buckets affected by region change + // iterate over the union of both regions + for (col = union.startCol; col <= union.endCol; col++) { + for (row = union.startRow; row <= union.endRow; row++) { + bucketId = _getBucketId(col, row); + bucket = buckets[bucketId]; + + var isInsideNewRegion = (col >= newRegion.startCol && col <= newRegion.endCol + && row >= newRegion.startRow && row <= newRegion.endRow); + + var isInsideOldRegion = (col >= body.region.startCol && col <= body.region.endCol + && row >= body.region.startRow && row <= body.region.endRow); + + // remove from old region buckets + if (!isInsideNewRegion && isInsideOldRegion) { + if (isInsideOldRegion) { + if (bucket) + _bucketRemoveBody(grid, bucket, body); + } + } + + // add to new region buckets + if (body.region === newRegion || (isInsideNewRegion && !isInsideOldRegion) || forceUpdate) { + if (!bucket) + bucket = _createBucket(buckets, bucketId); + _bucketAddBody(grid, bucket, body); + } + } + } + + // set the new region + body.region = newRegion; + + // flag changes so we can update pairs + gridChanged = true; + } + } + + // update pairs list only if pairs changed (i.e. a body changed region) + if (gridChanged) + grid.pairsList = _createActivePairsList(grid); + }; + + /** + * Clears the grid. + * @method clear + * @param {grid} grid + */ + Grid.clear = function(grid) { + grid.buckets = {}; + grid.pairs = {}; + grid.pairsList = []; + }; + + /** + * Finds the union of two regions. + * @method _regionUnion + * @private + * @param {} regionA + * @param {} regionB + * @return {} region + */ + var _regionUnion = function(regionA, regionB) { + var startCol = Math.min(regionA.startCol, regionB.startCol), + endCol = Math.max(regionA.endCol, regionB.endCol), + startRow = Math.min(regionA.startRow, regionB.startRow), + endRow = Math.max(regionA.endRow, regionB.endRow); + + return _createRegion(startCol, endCol, startRow, endRow); + }; + + /** + * Gets the region a given body falls in for a given grid. + * @method _getRegion + * @private + * @param {} grid + * @param {} body + * @return {} region + */ + var _getRegion = function(grid, body) { + var bounds = body.bounds, + startCol = Math.floor(bounds.min.x / grid.bucketWidth), + endCol = Math.floor(bounds.max.x / grid.bucketWidth), + startRow = Math.floor(bounds.min.y / grid.bucketHeight), + endRow = Math.floor(bounds.max.y / grid.bucketHeight); + + return _createRegion(startCol, endCol, startRow, endRow); + }; + + /** + * Creates a region. + * @method _createRegion + * @private + * @param {} startCol + * @param {} endCol + * @param {} startRow + * @param {} endRow + * @return {} region + */ + var _createRegion = function(startCol, endCol, startRow, endRow) { + return { + id: startCol + ',' + endCol + ',' + startRow + ',' + endRow, + startCol: startCol, + endCol: endCol, + startRow: startRow, + endRow: endRow + }; + }; + + /** + * Gets the bucket id at the given position. + * @method _getBucketId + * @private + * @param {} column + * @param {} row + * @return {string} bucket id + */ + var _getBucketId = function(column, row) { + return 'C' + column + 'R' + row; + }; + + /** + * Creates a bucket. + * @method _createBucket + * @private + * @param {} buckets + * @param {} bucketId + * @return {} bucket + */ + var _createBucket = function(buckets, bucketId) { + var bucket = buckets[bucketId] = []; + return bucket; + }; + + /** + * Adds a body to a bucket. + * @method _bucketAddBody + * @private + * @param {} grid + * @param {} bucket + * @param {} body + */ + var _bucketAddBody = function(grid, bucket, body) { + // add new pairs + for (var i = 0; i < bucket.length; i++) { + var bodyB = bucket[i]; + + if (body.id === bodyB.id || (body.isStatic && bodyB.isStatic)) + continue; + + // keep track of the number of buckets the pair exists in + // important for Grid.update to work + var pairId = Pair.id(body, bodyB), + pair = grid.pairs[pairId]; + + if (pair) { + pair[2] += 1; + } else { + grid.pairs[pairId] = [body, bodyB, 1]; + } + } + + // add to bodies (after pairs, otherwise pairs with self) + bucket.push(body); + }; + + /** + * Removes a body from a bucket. + * @method _bucketRemoveBody + * @private + * @param {} grid + * @param {} bucket + * @param {} body + */ + var _bucketRemoveBody = function(grid, bucket, body) { + // remove from bucket + bucket.splice(bucket.indexOf(body), 1); + + // update pair counts + for (var i = 0; i < bucket.length; i++) { + // keep track of the number of buckets the pair exists in + // important for _createActivePairsList to work + var bodyB = bucket[i], + pairId = Pair.id(body, bodyB), + pair = grid.pairs[pairId]; + + if (pair) + pair[2] -= 1; + } + }; + + /** + * Generates a list of the active pairs in the grid. + * @method _createActivePairsList + * @private + * @param {} grid + * @return [] pairs + */ + var _createActivePairsList = function(grid) { + var pairKeys, + pair, + pairs = []; + + // grid.pairs is used as a hashmap + pairKeys = Common.keys(grid.pairs); + + // iterate over grid.pairs + for (var k = 0; k < pairKeys.length; k++) { + pair = grid.pairs[pairKeys[k]]; + + // if pair exists in at least one bucket + // it is a pair that needs further collision testing so push it + if (pair[2] > 0) { + pairs.push(pair); + } else { + delete grid.pairs[pairKeys[k]]; + } + } + + return pairs; + }; + +})(); + + +/***/ }), +/* 959 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter` module is the top level namespace. It also includes a function for installing plugins on top of the library. +* +* @class Matter +*/ + +var Matter = {}; + +module.exports = Matter; + +var Plugin = __webpack_require__(463); +var Common = __webpack_require__(39); + +(function() { + + /** + * The library name. + * @property name + * @readOnly + * @type {String} + */ + Matter.name = 'matter-js'; + + /** + * The library version. + * @property version + * @readOnly + * @type {String} + */ + Matter.version = '0.13.1'; + + /** + * A list of plugin dependencies to be installed. These are normally set and installed through `Matter.use`. + * Alternatively you may set `Matter.uses` manually and install them by calling `Plugin.use(Matter)`. + * @property uses + * @type {Array} + */ + Matter.uses = []; + + /** + * The plugins that have been installed through `Matter.Plugin.install`. Read only. + * @property used + * @readOnly + * @type {Array} + */ + Matter.used = []; + + /** + * Installs the given plugins on the `Matter` namespace. + * This is a short-hand for `Plugin.use`, see it for more information. + * Call this function once at the start of your code, with all of the plugins you wish to install as arguments. + * Avoid calling this function multiple times unless you intend to manually control installation order. + * @method use + * @param ...plugin {Function} The plugin(s) to install on `base` (multi-argument). + */ + Matter.use = function() { + Plugin.use(Matter, Array.prototype.slice.call(arguments)); + }; + + /** + * Chains a function to excute before the original function on the given `path` relative to `Matter`. + * See also docs for `Common.chain`. + * @method before + * @param {string} path The path relative to `Matter` + * @param {function} func The function to chain before the original + * @return {function} The chained function that replaced the original + */ + Matter.before = function(path, func) { + path = path.replace(/^Matter./, ''); + return Common.chainPathBefore(Matter, path, func); + }; + + /** + * Chains a function to excute after the original function on the given `path` relative to `Matter`. + * See also docs for `Common.chain`. + * @method after + * @param {string} path The path relative to `Matter` + * @param {function} func The function to chain after the original + * @return {function} The chained function that replaced the original + */ + Matter.after = function(path, func) { + path = path.replace(/^Matter./, ''); + return Common.chainPathAfter(Matter, path, func); + }; + +})(); + + +/***/ }), +/* 960 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var AnimationComponent = __webpack_require__(381); +var Bodies = __webpack_require__(92); +var Class = __webpack_require__(0); +var Components = __webpack_require__(371); +var GameObject = __webpack_require__(1); +var GetFastValue = __webpack_require__(2); +var Pipeline = __webpack_require__(349); +var Sprite = __webpack_require__(40); +var Vector2 = __webpack_require__(6); + +/** + * @classdesc + * A Matter Physics Sprite Game Object. * * A Sprite Game Object is used for the display of both static and animated images in your game. * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled @@ -125692,24 +128920,24 @@ var Sprite = __webpack_require__(37); * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. * - * @class ImpactSprite + * @class Sprite * @extends Phaser.GameObjects.Sprite - * @memberOf Phaser.Physics.Impact + * @memberOf Phaser.Physics.Matter * @constructor * @since 3.0.0 * - * @extends Phaser.Physics.Impact.Components.Acceleration - * @extends Phaser.Physics.Impact.Components.BodyScale - * @extends Phaser.Physics.Impact.Components.BodyType - * @extends Phaser.Physics.Impact.Components.Bounce - * @extends Phaser.Physics.Impact.Components.CheckAgainst - * @extends Phaser.Physics.Impact.Components.Collides - * @extends Phaser.Physics.Impact.Components.Debug - * @extends Phaser.Physics.Impact.Components.Friction - * @extends Phaser.Physics.Impact.Components.Gravity - * @extends Phaser.Physics.Impact.Components.Offset - * @extends Phaser.Physics.Impact.Components.SetGameObject - * @extends Phaser.Physics.Impact.Components.Velocity + * @extends Phaser.Physics.Matter.Components.Bounce + * @extends Phaser.Physics.Matter.Components.Collision + * @extends Phaser.Physics.Matter.Components.Force + * @extends Phaser.Physics.Matter.Components.Friction + * @extends Phaser.Physics.Matter.Components.Gravity + * @extends Phaser.Physics.Matter.Components.Mass + * @extends Phaser.Physics.Matter.Components.Sensor + * @extends Phaser.Physics.Matter.Components.SetBody + * @extends Phaser.Physics.Matter.Components.Sleep + * @extends Phaser.Physics.Matter.Components.Static + * @extends Phaser.Physics.Matter.Components.Transform + * @extends Phaser.Physics.Matter.Components.Velocity * @extends Phaser.GameObjects.Components.Alpha * @extends Phaser.GameObjects.Components.Animation * @extends Phaser.GameObjects.Components.BlendMode @@ -125726,111 +128954,94 @@ var Sprite = __webpack_require__(37); * @extends Phaser.GameObjects.Components.Transform * @extends Phaser.GameObjects.Components.Visible * - * @param {Phaser.Physics.Impact.World} world - [description] + * @param {Phaser.Physics.Matter.World} world - [description] * @param {number} x - The horizontal position of this Game Object in the world. * @param {number} y - The vertical position of this Game Object in the world. * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {object} options - [description] */ -var ImpactSprite = new Class({ +var MatterSprite = new Class({ Extends: Sprite, Mixins: [ - Components.Acceleration, - Components.BodyScale, - Components.BodyType, Components.Bounce, - Components.CheckAgainst, - Components.Collides, - Components.Debug, + Components.Collision, + Components.Force, Components.Friction, Components.Gravity, - Components.Offset, - Components.SetGameObject, - Components.Velocity + Components.Mass, + Components.Sensor, + Components.SetBody, + Components.Sleep, + Components.Static, + Components.Transform, + Components.Velocity, + Pipeline ], initialize: - function ImpactSprite (world, x, y, texture, frame) + function MatterSprite (world, x, y, texture, frame, options) { - Sprite.call(this, world.scene, x, y, texture, frame); + GameObject.call(this, world.scene, 'Image'); + + this.anims = new AnimationComponent(this); + + this.setTexture(texture, frame); + this.setSizeToFrame(); + this.setOrigin(); /** * [description] * - * @name Phaser.Physics.Impact.ImpactSprite#body - * @type {Phaser.Physics.Impact.Body} + * @name Phaser.Physics.Matter.Image#world + * @type {Phaser.Physics.Matter.World} * @since 3.0.0 */ - this.body = world.create(x - this.frame.centerX, y - this.frame.centerY, this.width, this.height); - - this.body.parent = this; - this.body.gameObject = this; + this.world = world; /** * [description] * - * @name Phaser.Physics.Impact.ImpactSprite#size - * @type {{x: number, y: number}} + * @name Phaser.Physics.Matter.Image#_tempVec2 + * @type {Phaser.Math.Vector2} + * @private * @since 3.0.0 */ - this.size = this.body.size; + this._tempVec2 = new Vector2(x, y); - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactSprite#offset - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.offset = this.body.offset; + var shape = GetFastValue(options, 'shape', null); - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactSprite#vel - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.vel = this.body.vel; + if (!shape) + { + this.body = Bodies.rectangle(x, y, this.width, this.height, options); - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactSprite#accel - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.accel = this.body.accel; + this.body.gameObject = this; - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactSprite#friction - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.friction = this.body.friction; + if (GetFastValue(options, 'addToWorld', true)) + { + world.add(this.body); + } + } + else + { + this.setBody(shape, options); + } - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactSprite#maxVel - * @type {{x: number, y: number}} - * @since 3.0.0 - */ - this.maxVel = this.body.maxVel; + this.setPosition(x, y); + + this.initPipeline('TextureTintPipeline'); } }); -module.exports = ImpactSprite; +module.exports = MatterSprite; /***/ }), -/* 946 */ +/* 961 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -125839,17 +129050,1772 @@ module.exports = ImpactSprite; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Body = __webpack_require__(940); +var Bodies = __webpack_require__(92); var Class = __webpack_require__(0); -var COLLIDES = __webpack_require__(341); -var CollisionMap = __webpack_require__(941); -var EventEmitter = __webpack_require__(14); +var Components = __webpack_require__(371); +var GameObject = __webpack_require__(1); var GetFastValue = __webpack_require__(2); -var HasValue = __webpack_require__(72); -var Set = __webpack_require__(62); -var Solver = __webpack_require__(977); -var TILEMAP_FORMATS = __webpack_require__(22); -var TYPE = __webpack_require__(342); +var Image = __webpack_require__(72); +var Pipeline = __webpack_require__(349); +var Vector2 = __webpack_require__(6); + +/** + * @classdesc + * A Matter Physics Image Game Object. + * + * An Image is a light-weight Game Object useful for the display of static images in your game, + * such as logos, backgrounds, scenery or other non-animated elements. Images can have input + * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an + * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. + * + * @class Image + * @extends Phaser.GameObjects.Image + * @memberOf Phaser.Physics.Matter + * @constructor + * @since 3.0.0 + * + * @extends Phaser.Physics.Matter.Components.Bounce + * @extends Phaser.Physics.Matter.Components.Collision + * @extends Phaser.Physics.Matter.Components.Force + * @extends Phaser.Physics.Matter.Components.Friction + * @extends Phaser.Physics.Matter.Components.Gravity + * @extends Phaser.Physics.Matter.Components.Mass + * @extends Phaser.Physics.Matter.Components.Sensor + * @extends Phaser.Physics.Matter.Components.SetBody + * @extends Phaser.Physics.Matter.Components.Sleep + * @extends Phaser.Physics.Matter.Components.Static + * @extends Phaser.Physics.Matter.Components.Transform + * @extends Phaser.Physics.Matter.Components.Velocity + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Physics.Matter.World} world - [description] + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {object} options - [description] + */ +var MatterImage = new Class({ + + Extends: Image, + + Mixins: [ + Components.Bounce, + Components.Collision, + Components.Force, + Components.Friction, + Components.Gravity, + Components.Mass, + Components.Sensor, + Components.SetBody, + Components.Sleep, + Components.Static, + Components.Transform, + Components.Velocity, + Pipeline + ], + + initialize: + + function MatterImage (world, x, y, texture, frame, options) + { + GameObject.call(this, world.scene, 'Image'); + + this.setTexture(texture, frame); + this.setSizeToFrame(); + this.setOrigin(); + + /** + * [description] + * + * @name Phaser.Physics.Matter.Image#world + * @type {Phaser.Physics.Matter.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * [description] + * + * @name Phaser.Physics.Matter.Image#_tempVec2 + * @type {Phaser.Math.Vector2} + * @private + * @since 3.0.0 + */ + this._tempVec2 = new Vector2(x, y); + + var shape = GetFastValue(options, 'shape', null); + + if (!shape) + { + this.body = Bodies.rectangle(x, y, this.width, this.height, options); + + this.body.gameObject = this; + + if (GetFastValue(options, 'addToWorld', true)) + { + world.add(this.body); + } + } + else + { + this.setBody(shape, options); + } + + this.setPosition(x, y); + + this.initPipeline('TextureTintPipeline'); + } + +}); + +module.exports = MatterImage; + + +/***/ }), +/* 962 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Composites` module contains factory methods for creating composite bodies +* with commonly used configurations (such as stacks and chains). +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Composites +*/ + +var Composites = {}; + +module.exports = Composites; + +var Composite = __webpack_require__(120); +var Constraint = __webpack_require__(170); +var Common = __webpack_require__(39); +var Body = __webpack_require__(49); +var Bodies = __webpack_require__(92); + +(function() { + + /** + * Create a new composite containing bodies created in the callback in a grid arrangement. + * This function uses the body's bounds to prevent overlaps. + * @method stack + * @param {number} xx + * @param {number} yy + * @param {number} columns + * @param {number} rows + * @param {number} columnGap + * @param {number} rowGap + * @param {function} callback + * @return {composite} A new composite containing objects created in the callback + */ + Composites.stack = function(xx, yy, columns, rows, columnGap, rowGap, callback) { + var stack = Composite.create({ label: 'Stack' }), + x = xx, + y = yy, + lastBody, + i = 0; + + for (var row = 0; row < rows; row++) { + var maxHeight = 0; + + for (var column = 0; column < columns; column++) { + var body = callback(x, y, column, row, lastBody, i); + + if (body) { + var bodyHeight = body.bounds.max.y - body.bounds.min.y, + bodyWidth = body.bounds.max.x - body.bounds.min.x; + + if (bodyHeight > maxHeight) + maxHeight = bodyHeight; + + Body.translate(body, { x: bodyWidth * 0.5, y: bodyHeight * 0.5 }); + + x = body.bounds.max.x + columnGap; + + Composite.addBody(stack, body); + + lastBody = body; + i += 1; + } else { + x += columnGap; + } + } + + y += maxHeight + rowGap; + x = xx; + } + + return stack; + }; + + /** + * Chains all bodies in the given composite together using constraints. + * @method chain + * @param {composite} composite + * @param {number} xOffsetA + * @param {number} yOffsetA + * @param {number} xOffsetB + * @param {number} yOffsetB + * @param {object} options + * @return {composite} A new composite containing objects chained together with constraints + */ + Composites.chain = function(composite, xOffsetA, yOffsetA, xOffsetB, yOffsetB, options) { + var bodies = composite.bodies; + + for (var i = 1; i < bodies.length; i++) { + var bodyA = bodies[i - 1], + bodyB = bodies[i], + bodyAHeight = bodyA.bounds.max.y - bodyA.bounds.min.y, + bodyAWidth = bodyA.bounds.max.x - bodyA.bounds.min.x, + bodyBHeight = bodyB.bounds.max.y - bodyB.bounds.min.y, + bodyBWidth = bodyB.bounds.max.x - bodyB.bounds.min.x; + + var defaults = { + bodyA: bodyA, + pointA: { x: bodyAWidth * xOffsetA, y: bodyAHeight * yOffsetA }, + bodyB: bodyB, + pointB: { x: bodyBWidth * xOffsetB, y: bodyBHeight * yOffsetB } + }; + + var constraint = Common.extend(defaults, options); + + Composite.addConstraint(composite, Constraint.create(constraint)); + } + + composite.label += ' Chain'; + + return composite; + }; + + /** + * Connects bodies in the composite with constraints in a grid pattern, with optional cross braces. + * @method mesh + * @param {composite} composite + * @param {number} columns + * @param {number} rows + * @param {boolean} crossBrace + * @param {object} options + * @return {composite} The composite containing objects meshed together with constraints + */ + Composites.mesh = function(composite, columns, rows, crossBrace, options) { + var bodies = composite.bodies, + row, + col, + bodyA, + bodyB, + bodyC; + + for (row = 0; row < rows; row++) { + for (col = 1; col < columns; col++) { + bodyA = bodies[(col - 1) + (row * columns)]; + bodyB = bodies[col + (row * columns)]; + Composite.addConstraint(composite, Constraint.create(Common.extend({ bodyA: bodyA, bodyB: bodyB }, options))); + } + + if (row > 0) { + for (col = 0; col < columns; col++) { + bodyA = bodies[col + ((row - 1) * columns)]; + bodyB = bodies[col + (row * columns)]; + Composite.addConstraint(composite, Constraint.create(Common.extend({ bodyA: bodyA, bodyB: bodyB }, options))); + + if (crossBrace && col > 0) { + bodyC = bodies[(col - 1) + ((row - 1) * columns)]; + Composite.addConstraint(composite, Constraint.create(Common.extend({ bodyA: bodyC, bodyB: bodyB }, options))); + } + + if (crossBrace && col < columns - 1) { + bodyC = bodies[(col + 1) + ((row - 1) * columns)]; + Composite.addConstraint(composite, Constraint.create(Common.extend({ bodyA: bodyC, bodyB: bodyB }, options))); + } + } + } + } + + composite.label += ' Mesh'; + + return composite; + }; + + /** + * Create a new composite containing bodies created in the callback in a pyramid arrangement. + * This function uses the body's bounds to prevent overlaps. + * @method pyramid + * @param {number} xx + * @param {number} yy + * @param {number} columns + * @param {number} rows + * @param {number} columnGap + * @param {number} rowGap + * @param {function} callback + * @return {composite} A new composite containing objects created in the callback + */ + Composites.pyramid = function(xx, yy, columns, rows, columnGap, rowGap, callback) { + return Composites.stack(xx, yy, columns, rows, columnGap, rowGap, function(x, y, column, row, lastBody, i) { + var actualRows = Math.min(rows, Math.ceil(columns / 2)), + lastBodyWidth = lastBody ? lastBody.bounds.max.x - lastBody.bounds.min.x : 0; + + if (row > actualRows) + return; + + // reverse row order + row = actualRows - row; + + var start = row, + end = columns - 1 - row; + + if (column < start || column > end) + return; + + // retroactively fix the first body's position, since width was unknown + if (i === 1) { + Body.translate(lastBody, { x: (column + (columns % 2 === 1 ? 1 : -1)) * lastBodyWidth, y: 0 }); + } + + var xOffset = lastBody ? column * lastBodyWidth : 0; + + return callback(xx + xOffset + column * columnGap, y, column, row, lastBody, i); + }); + }; + + /** + * Creates a composite with a Newton's Cradle setup of bodies and constraints. + * @method newtonsCradle + * @param {number} xx + * @param {number} yy + * @param {number} number + * @param {number} size + * @param {number} length + * @return {composite} A new composite newtonsCradle body + */ + Composites.newtonsCradle = function(xx, yy, number, size, length) { + var newtonsCradle = Composite.create({ label: 'Newtons Cradle' }); + + for (var i = 0; i < number; i++) { + var separation = 1.9, + circle = Bodies.circle(xx + i * (size * separation), yy + length, size, + { inertia: Infinity, restitution: 1, friction: 0, frictionAir: 0.0001, slop: 1 }), + constraint = Constraint.create({ pointA: { x: xx + i * (size * separation), y: yy }, bodyB: circle }); + + Composite.addBody(newtonsCradle, circle); + Composite.addConstraint(newtonsCradle, constraint); + } + + return newtonsCradle; + }; + + /** + * Creates a composite with simple car setup of bodies and constraints. + * @method car + * @param {number} xx + * @param {number} yy + * @param {number} width + * @param {number} height + * @param {number} wheelSize + * @return {composite} A new composite car body + */ + Composites.car = function(xx, yy, width, height, wheelSize) { + var group = Body.nextGroup(true), + wheelBase = 20, + wheelAOffset = -width * 0.5 + wheelBase, + wheelBOffset = width * 0.5 - wheelBase, + wheelYOffset = 0; + + var car = Composite.create({ label: 'Car' }), + body = Bodies.rectangle(xx, yy, width, height, { + collisionFilter: { + group: group + }, + chamfer: { + radius: height * 0.5 + }, + density: 0.0002 + }); + + var wheelA = Bodies.circle(xx + wheelAOffset, yy + wheelYOffset, wheelSize, { + collisionFilter: { + group: group + }, + friction: 0.8 + }); + + var wheelB = Bodies.circle(xx + wheelBOffset, yy + wheelYOffset, wheelSize, { + collisionFilter: { + group: group + }, + friction: 0.8 + }); + + var axelA = Constraint.create({ + bodyB: body, + pointB: { x: wheelAOffset, y: wheelYOffset }, + bodyA: wheelA, + stiffness: 1, + length: 0 + }); + + var axelB = Constraint.create({ + bodyB: body, + pointB: { x: wheelBOffset, y: wheelYOffset }, + bodyA: wheelB, + stiffness: 1, + length: 0 + }); + + Composite.addBody(car, body); + Composite.addBody(car, wheelA); + Composite.addBody(car, wheelB); + Composite.addConstraint(car, axelA); + Composite.addConstraint(car, axelB); + + return car; + }; + + /** + * Creates a simple soft body like object. + * @method softBody + * @param {number} xx + * @param {number} yy + * @param {number} columns + * @param {number} rows + * @param {number} columnGap + * @param {number} rowGap + * @param {boolean} crossBrace + * @param {number} particleRadius + * @param {} particleOptions + * @param {} constraintOptions + * @return {composite} A new composite softBody + */ + Composites.softBody = function(xx, yy, columns, rows, columnGap, rowGap, crossBrace, particleRadius, particleOptions, constraintOptions) { + particleOptions = Common.extend({ inertia: Infinity }, particleOptions); + constraintOptions = Common.extend({ stiffness: 0.2, render: { type: 'line', anchors: false } }, constraintOptions); + + var softBody = Composites.stack(xx, yy, columns, rows, columnGap, rowGap, function(x, y) { + return Bodies.circle(x, y, particleRadius, particleOptions); + }); + + Composites.mesh(softBody, columns, rows, crossBrace, constraintOptions); + + softBody.label = 'Soft Body'; + + return softBody; + }; + +})(); + + +/***/ }), +/* 963 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +module.exports = { + decomp: polygonDecomp, + quickDecomp: polygonQuickDecomp, + isSimple: polygonIsSimple, + removeCollinearPoints: polygonRemoveCollinearPoints, + makeCCW: polygonMakeCCW +}; + +/** + * Compute the intersection between two lines. + * @static + * @method lineInt + * @param {Array} l1 Line vector 1 + * @param {Array} l2 Line vector 2 + * @param {Number} precision Precision to use when checking if the lines are parallel + * @return {Array} The intersection point. + */ +function lineInt(l1,l2,precision){ + precision = precision || 0; + var i = [0,0]; // point + var a1, b1, c1, a2, b2, c2, det; // scalars + a1 = l1[1][1] - l1[0][1]; + b1 = l1[0][0] - l1[1][0]; + c1 = a1 * l1[0][0] + b1 * l1[0][1]; + a2 = l2[1][1] - l2[0][1]; + b2 = l2[0][0] - l2[1][0]; + c2 = a2 * l2[0][0] + b2 * l2[0][1]; + det = a1 * b2 - a2*b1; + if (!scalar_eq(det, 0, precision)) { // lines are not parallel + i[0] = (b2 * c1 - b1 * c2) / det; + i[1] = (a1 * c2 - a2 * c1) / det; + } + return i; +} + +/** + * Checks if two line segments intersects. + * @method segmentsIntersect + * @param {Array} p1 The start vertex of the first line segment. + * @param {Array} p2 The end vertex of the first line segment. + * @param {Array} q1 The start vertex of the second line segment. + * @param {Array} q2 The end vertex of the second line segment. + * @return {Boolean} True if the two line segments intersect + */ +function lineSegmentsIntersect(p1, p2, q1, q2){ + var dx = p2[0] - p1[0]; + var dy = p2[1] - p1[1]; + var da = q2[0] - q1[0]; + var db = q2[1] - q1[1]; + + // segments are parallel + if((da*dy - db*dx) === 0){ + return false; + } + + var s = (dx * (q1[1] - p1[1]) + dy * (p1[0] - q1[0])) / (da * dy - db * dx); + var t = (da * (p1[1] - q1[1]) + db * (q1[0] - p1[0])) / (db * dx - da * dy); + + return (s>=0 && s<=1 && t>=0 && t<=1); +} + +/** + * Get the area of a triangle spanned by the three given points. Note that the area will be negative if the points are not given in counter-clockwise order. + * @static + * @method area + * @param {Array} a + * @param {Array} b + * @param {Array} c + * @return {Number} + */ +function triangleArea(a,b,c){ + return (((b[0] - a[0])*(c[1] - a[1]))-((c[0] - a[0])*(b[1] - a[1]))); +} + +function isLeft(a,b,c){ + return triangleArea(a,b,c) > 0; +} + +function isLeftOn(a,b,c) { + return triangleArea(a, b, c) >= 0; +} + +function isRight(a,b,c) { + return triangleArea(a, b, c) < 0; +} + +function isRightOn(a,b,c) { + return triangleArea(a, b, c) <= 0; +} + +var tmpPoint1 = [], + tmpPoint2 = []; + +/** + * Check if three points are collinear + * @method collinear + * @param {Array} a + * @param {Array} b + * @param {Array} c + * @param {Number} [thresholdAngle=0] Threshold angle to use when comparing the vectors. The function will return true if the angle between the resulting vectors is less than this value. Use zero for max precision. + * @return {Boolean} + */ +function collinear(a,b,c,thresholdAngle) { + if(!thresholdAngle){ + return triangleArea(a, b, c) === 0; + } else { + var ab = tmpPoint1, + bc = tmpPoint2; + + ab[0] = b[0]-a[0]; + ab[1] = b[1]-a[1]; + bc[0] = c[0]-b[0]; + bc[1] = c[1]-b[1]; + + var dot = ab[0]*bc[0] + ab[1]*bc[1], + magA = Math.sqrt(ab[0]*ab[0] + ab[1]*ab[1]), + magB = Math.sqrt(bc[0]*bc[0] + bc[1]*bc[1]), + angle = Math.acos(dot/(magA*magB)); + return angle < thresholdAngle; + } +} + +function sqdist(a,b){ + var dx = b[0] - a[0]; + var dy = b[1] - a[1]; + return dx * dx + dy * dy; +} + +/** + * Get a vertex at position i. It does not matter if i is out of bounds, this function will just cycle. + * @method at + * @param {Number} i + * @return {Array} + */ +function polygonAt(polygon, i){ + var s = polygon.length; + return polygon[i < 0 ? i % s + s : i % s]; +} + +/** + * Clear the polygon data + * @method clear + * @return {Array} + */ +function polygonClear(polygon){ + polygon.length = 0; +} + +/** + * Append points "from" to "to"-1 from an other polygon "poly" onto this one. + * @method append + * @param {Polygon} poly The polygon to get points from. + * @param {Number} from The vertex index in "poly". + * @param {Number} to The end vertex index in "poly". Note that this vertex is NOT included when appending. + * @return {Array} + */ +function polygonAppend(polygon, poly, from, to){ + for(var i=from; i v[br][0])) { + br = i; + } + } + + // reverse poly if clockwise + if (!isLeft(polygonAt(polygon, br - 1), polygonAt(polygon, br), polygonAt(polygon, br + 1))) { + polygonReverse(polygon); + } +} + +/** + * Reverse the vertices in the polygon + * @method reverse + */ +function polygonReverse(polygon){ + var tmp = []; + var N = polygon.length; + for(var i=0; i!==N; i++){ + tmp.push(polygon.pop()); + } + for(var i=0; i!==N; i++){ + polygon[i] = tmp[i]; + } +} + +/** + * Check if a point in the polygon is a reflex point + * @method isReflex + * @param {Number} i + * @return {Boolean} + */ +function polygonIsReflex(polygon, i){ + return isRight(polygonAt(polygon, i - 1), polygonAt(polygon, i), polygonAt(polygon, i + 1)); +} + +var tmpLine1=[], + tmpLine2=[]; + +/** + * Check if two vertices in the polygon can see each other + * @method canSee + * @param {Number} a Vertex index 1 + * @param {Number} b Vertex index 2 + * @return {Boolean} + */ +function polygonCanSee(polygon, a,b) { + var p, dist, l1=tmpLine1, l2=tmpLine2; + + if (isLeftOn(polygonAt(polygon, a + 1), polygonAt(polygon, a), polygonAt(polygon, b)) && isRightOn(polygonAt(polygon, a - 1), polygonAt(polygon, a), polygonAt(polygon, b))) { + return false; + } + dist = sqdist(polygonAt(polygon, a), polygonAt(polygon, b)); + for (var i = 0; i !== polygon.length; ++i) { // for each edge + if ((i + 1) % polygon.length === a || i === a){ // ignore incident edges + continue; + } + if (isLeftOn(polygonAt(polygon, a), polygonAt(polygon, b), polygonAt(polygon, i + 1)) && isRightOn(polygonAt(polygon, a), polygonAt(polygon, b), polygonAt(polygon, i))) { // if diag intersects an edge + l1[0] = polygonAt(polygon, a); + l1[1] = polygonAt(polygon, b); + l2[0] = polygonAt(polygon, i); + l2[1] = polygonAt(polygon, i + 1); + p = lineInt(l1,l2); + if (sqdist(polygonAt(polygon, a), p) < dist) { // if edge is blocking visibility to b + return false; + } + } + } + + return true; +} + +/** + * Copy the polygon from vertex i to vertex j. + * @method copy + * @param {Number} i + * @param {Number} j + * @param {Polygon} [targetPoly] Optional target polygon to save in. + * @return {Polygon} The resulting copy. + */ +function polygonCopy(polygon, i,j,targetPoly){ + var p = targetPoly || []; + polygonClear(p); + if (i < j) { + // Insert all vertices from i to j + for(var k=i; k<=j; k++){ + p.push(polygon[k]); + } + + } else { + + // Insert vertices 0 to j + for(var k=0; k<=j; k++){ + p.push(polygon[k]); + } + + // Insert vertices i to end + for(var k=i; k 0){ + return polygonSlice(polygon, edges); + } else { + return [polygon]; + } +} + +/** + * Slices the polygon given one or more cut edges. If given one, this function will return two polygons (false on failure). If many, an array of polygons. + * @method slice + * @param {Array} cutEdges A list of edges, as returned by .getCutEdges() + * @return {Array} + */ +function polygonSlice(polygon, cutEdges){ + if(cutEdges.length === 0){ + return [polygon]; + } + if(cutEdges instanceof Array && cutEdges.length && cutEdges[0] instanceof Array && cutEdges[0].length===2 && cutEdges[0][0] instanceof Array){ + + var polys = [polygon]; + + for(var i=0; i maxlevel){ + console.warn("quickDecomp: max level ("+maxlevel+") reached."); + return result; + } + + for (var i = 0; i < polygon.length; ++i) { + if (polygonIsReflex(poly, i)) { + reflexVertices.push(poly[i]); + upperDist = lowerDist = Number.MAX_VALUE; + + + for (var j = 0; j < polygon.length; ++j) { + if (isLeft(polygonAt(poly, i - 1), polygonAt(poly, i), polygonAt(poly, j)) && isRightOn(polygonAt(poly, i - 1), polygonAt(poly, i), polygonAt(poly, j - 1))) { // if line intersects with an edge + p = getIntersectionPoint(polygonAt(poly, i - 1), polygonAt(poly, i), polygonAt(poly, j), polygonAt(poly, j - 1)); // find the point of intersection + if (isRight(polygonAt(poly, i + 1), polygonAt(poly, i), p)) { // make sure it's inside the poly + d = sqdist(poly[i], p); + if (d < lowerDist) { // keep only the closest intersection + lowerDist = d; + lowerInt = p; + lowerIndex = j; + } + } + } + if (isLeft(polygonAt(poly, i + 1), polygonAt(poly, i), polygonAt(poly, j + 1)) && isRightOn(polygonAt(poly, i + 1), polygonAt(poly, i), polygonAt(poly, j))) { + p = getIntersectionPoint(polygonAt(poly, i + 1), polygonAt(poly, i), polygonAt(poly, j), polygonAt(poly, j + 1)); + if (isLeft(polygonAt(poly, i - 1), polygonAt(poly, i), p)) { + d = sqdist(poly[i], p); + if (d < upperDist) { + upperDist = d; + upperInt = p; + upperIndex = j; + } + } + } + } + + // if there are no vertices to connect to, choose a point in the middle + if (lowerIndex === (upperIndex + 1) % polygon.length) { + //console.log("Case 1: Vertex("+i+"), lowerIndex("+lowerIndex+"), upperIndex("+upperIndex+"), poly.size("+polygon.length+")"); + p[0] = (lowerInt[0] + upperInt[0]) / 2; + p[1] = (lowerInt[1] + upperInt[1]) / 2; + steinerPoints.push(p); + + if (i < upperIndex) { + //lowerPoly.insert(lowerPoly.end(), poly.begin() + i, poly.begin() + upperIndex + 1); + polygonAppend(lowerPoly, poly, i, upperIndex+1); + lowerPoly.push(p); + upperPoly.push(p); + if (lowerIndex !== 0){ + //upperPoly.insert(upperPoly.end(), poly.begin() + lowerIndex, poly.end()); + polygonAppend(upperPoly, poly,lowerIndex,poly.length); + } + //upperPoly.insert(upperPoly.end(), poly.begin(), poly.begin() + i + 1); + polygonAppend(upperPoly, poly,0,i+1); + } else { + if (i !== 0){ + //lowerPoly.insert(lowerPoly.end(), poly.begin() + i, poly.end()); + polygonAppend(lowerPoly, poly,i,poly.length); + } + //lowerPoly.insert(lowerPoly.end(), poly.begin(), poly.begin() + upperIndex + 1); + polygonAppend(lowerPoly, poly,0,upperIndex+1); + lowerPoly.push(p); + upperPoly.push(p); + //upperPoly.insert(upperPoly.end(), poly.begin() + lowerIndex, poly.begin() + i + 1); + polygonAppend(upperPoly, poly,lowerIndex,i+1); + } + } else { + // connect to the closest point within the triangle + //console.log("Case 2: Vertex("+i+"), closestIndex("+closestIndex+"), poly.size("+polygon.length+")\n"); + + if (lowerIndex > upperIndex) { + upperIndex += polygon.length; + } + closestDist = Number.MAX_VALUE; + + if(upperIndex < lowerIndex){ + return result; + } + + for (var j = lowerIndex; j <= upperIndex; ++j) { + if (isLeftOn(polygonAt(poly, i - 1), polygonAt(poly, i), polygonAt(poly, j)) && isRightOn(polygonAt(poly, i + 1), polygonAt(poly, i), polygonAt(poly, j))) { + d = sqdist(polygonAt(poly, i), polygonAt(poly, j)); + if (d < closestDist) { + closestDist = d; + closestIndex = j % polygon.length; + } + } + } + + if (i < closestIndex) { + polygonAppend(lowerPoly, poly,i,closestIndex+1); + if (closestIndex !== 0){ + polygonAppend(upperPoly, poly,closestIndex,v.length); + } + polygonAppend(upperPoly, poly,0,i+1); + } else { + if (i !== 0){ + polygonAppend(lowerPoly, poly,i,v.length); + } + polygonAppend(lowerPoly, poly,0,closestIndex+1); + polygonAppend(upperPoly, poly,closestIndex,i+1); + } + } + + // solve smallest poly first + if (lowerPoly.length < upperPoly.length) { + polygonQuickDecomp(lowerPoly,result,reflexVertices,steinerPoints,delta,maxlevel,level); + polygonQuickDecomp(upperPoly,result,reflexVertices,steinerPoints,delta,maxlevel,level); + } else { + polygonQuickDecomp(upperPoly,result,reflexVertices,steinerPoints,delta,maxlevel,level); + polygonQuickDecomp(lowerPoly,result,reflexVertices,steinerPoints,delta,maxlevel,level); + } + + return result; + } + } + result.push(polygon); + + return result; +} + +/** + * Remove collinear points in the polygon. + * @method removeCollinearPoints + * @param {Number} [precision] The threshold angle to use when determining whether two edges are collinear. Use zero for finest precision. + * @return {Number} The number of points removed + */ +function polygonRemoveCollinearPoints(polygon, precision){ + var num = 0; + for(var i=polygon.length-1; polygon.length>3 && i>=0; --i){ + if(collinear(polygonAt(polygon, i-1),polygonAt(polygon, i),polygonAt(polygon, i+1),precision)){ + // Remove the middle point + polygon.splice(i%polygon.length,1); + num++; + } + } + return num; +} + +/** + * Check if two scalars are equal + * @static + * @method eq + * @param {Number} a + * @param {Number} b + * @param {Number} [precision] + * @return {Boolean} + */ +function scalar_eq(a,b,precision){ + precision = precision || 0; + return Math.abs(a-b) < precision; +} + + +/***/ }), +/* 964 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Bodies = __webpack_require__(92); +var Class = __webpack_require__(0); +var Composites = __webpack_require__(962); +var Constraint = __webpack_require__(170); +var MatterGameObject = __webpack_require__(997); +var MatterImage = __webpack_require__(961); +var MatterSprite = __webpack_require__(960); +var MatterTileBody = __webpack_require__(467); +var PointerConstraint = __webpack_require__(984); + +/** + * @classdesc + * [description] + * + * @class Factory + * @memberOf Phaser.Physics.Matter + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Matter.World} world - [description] + */ +var Factory = new Class({ + + initialize: + + function Factory (world) + { + /** + * [description] + * + * @name Phaser.Physics.Matter.Factory#world + * @type {Phaser.Physics.Matter.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * [description] + * + * @name Phaser.Physics.Matter.Factory#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = world.scene; + + /** + * A reference to the Scene.Systems this Matter Physics instance belongs to. + * + * @name Phaser.Physics.Matter.Factory#sys + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.sys = world.scene.sys; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#rectangle + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {object} options - [description] + * + * @return {Matter.Body} A Matter JS Body. + */ + rectangle: function (x, y, width, height, options) + { + var body = Bodies.rectangle(x, y, width, height, options); + + this.world.add(body); + + return body; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#trapezoid + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {number} slope - [description] + * @param {object} options - [description] + * + * @return {Matter.Body} A Matter JS Body. + */ + trapezoid: function (x, y, width, height, slope, options) + { + var body = Bodies.trapezoid(x, y, width, height, slope, options); + + this.world.add(body); + + return body; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#circle + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} radius - [description] + * @param {object} options - [description] + * @param {number} maxSides - [description] + * + * @return {Matter.Body} A Matter JS Body. + */ + circle: function (x, y, radius, options, maxSides) + { + var body = Bodies.circle(x, y, radius, options, maxSides); + + this.world.add(body); + + return body; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#polygon + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} sides - [description] + * @param {number} radius - [description] + * @param {object} options - [description] + * + * @return {Matter.Body} A Matter JS Body. + */ + polygon: function (x, y, sides, radius, options) + { + var body = Bodies.polygon(x, y, sides, radius, options); + + this.world.add(body); + + return body; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#fromVertices + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {array} vertexSets - [description] + * @param {object} options - [description] + * @param {boolean} flagInternal - [description] + * @param {boolean} removeCollinear - [description] + * @param {number} minimumArea - [description] + * + * @return {Matter.Body} A Matter JS Body. + */ + fromVertices: function (x, y, vertexSets, options, flagInternal, removeCollinear, minimumArea) + { + var body = Bodies.fromVertices(x, y, vertexSets, options, flagInternal, removeCollinear, minimumArea); + + this.world.add(body); + + return body; + }, + + /** + * Create a new composite containing Matter Image objects created in a grid arrangement. + * This function uses the body bounds to prevent overlaps. + * + * @method Phaser.Physics.Matter.Factory#imageStack + * @since 3.0.0 + * + * @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {number} x - The horizontal position of this composite in the world. + * @param {number} y - The vertical position of this composite in the world. + * @param {number} columns - The number of columns in the grid. + * @param {number} rows - The number of rows in the grid. + * @param {number} columnGap - The distance between each column. + * @param {number} rowGap - The distance between each row. + * @param {object} options - [description] + * + * @return {Matter.Composite} A Matter JS Composite Stack. + */ + imageStack: function (key, frame, x, y, columns, rows, columnGap, rowGap, options) + { + if (columnGap === undefined) { columnGap = 0; } + if (rowGap === undefined) { rowGap = 0; } + if (options === undefined) { options = {}; } + + var world = this.world; + var displayList = this.sys.displayList; + + options.addToWorld = false; + + var stack = Composites.stack(x, y, columns, rows, columnGap, rowGap, function (x, y) + { + var image = new MatterImage(world, x, y, key, frame, options); + + displayList.add(image); + + return image.body; + }); + + world.add(stack); + + return stack; + }, + + /** + * Create a new composite containing bodies created in the callback in a grid arrangement. + * This function uses the body bounds to prevent overlaps. + * + * @method Phaser.Physics.Matter.Factory#stack + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this composite in the world. + * @param {number} y - The vertical position of this composite in the world. + * @param {number} columns - The number of columns in the grid. + * @param {number} rows - The number of rows in the grid. + * @param {number} columnGap - The distance between each column. + * @param {number} rowGap - The distance between each row. + * @param {function} callback - The callback that creates the stack. + * + * @return {Matter.Composite} A new composite containing objects created in the callback. + */ + stack: function (x, y, columns, rows, columnGap, rowGap, callback) + { + var stack = Composites.stack(x, y, columns, rows, columnGap, rowGap, callback); + + this.world.add(stack); + + return stack; + }, + + /** + * Create a new composite containing bodies created in the callback in a pyramid arrangement. + * This function uses the body bounds to prevent overlaps. + * + * @method Phaser.Physics.Matter.Factory#pyramid + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this composite in the world. + * @param {number} y - The vertical position of this composite in the world. + * @param {number} columns - The number of columns in the pyramid. + * @param {number} rows - The number of rows in the pyramid. + * @param {number} columnGap - The distance between each column. + * @param {number} rowGap - The distance between each row. + * @param {function} callback - [description] + * + * @return {Matter.Composite} A Matter JS Composite pyramid. + */ + pyramid: function (x, y, columns, rows, columnGap, rowGap, callback) + { + var stack = Composites.pyramid(x, y, columns, rows, columnGap, rowGap, callback); + + this.world.add(stack); + + return stack; + }, + + /** + * Chains all bodies in the given composite together using constraints. + * + * @method Phaser.Physics.Matter.Factory#chain + * @since 3.0.0 + * + * @param {Matter.Composite} composite - [description] + * @param {number} xOffsetA - [description] + * @param {number} yOffsetA - [description] + * @param {number} xOffsetB - [description] + * @param {number} yOffsetB - [description] + * @param {object} options - [description] + * + * @return {Matter.Composite} A new composite containing objects chained together with constraints. + */ + chain: function (composite, xOffsetA, yOffsetA, xOffsetB, yOffsetB, options) + { + return Composites.chain(composite, xOffsetA, yOffsetA, xOffsetB, yOffsetB, options); + }, + + /** + * Connects bodies in the composite with constraints in a grid pattern, with optional cross braces. + * + * @method Phaser.Physics.Matter.Factory#mesh + * @since 3.0.0 + * + * @param {Matter.Composite} composite - [description] + * @param {number} columns - [description] + * @param {number} rows - [description] + * @param {boolean} crossBrace - [description] + * @param {object} options - [description] + * + * @return {Matter.Composite} The composite containing objects meshed together with constraints. + */ + mesh: function (composite, columns, rows, crossBrace, options) + { + return Composites.mesh(composite, columns, rows, crossBrace, options); + }, + + /** + * Creates a composite with a Newton's Cradle setup of bodies and constraints. + * + * @method Phaser.Physics.Matter.Factory#newtonsCradle + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} number - [description] + * @param {number} size - [description] + * @param {number} length - [description] + * + * @return {Matter.Composite} A new composite newtonsCradle body. + */ + newtonsCradle: function (x, y, number, size, length) + { + var composite = Composites.newtonsCradle(x, y, number, size, length); + + this.world.add(composite); + + return composite; + }, + + /** + * Creates a composite with simple car setup of bodies and constraints. + * + * @method Phaser.Physics.Matter.Factory#car + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {number} wheelSize - [description] + * + * @return {Matter.Composite} A new composite car body. + */ + car: function (x, y, width, height, wheelSize) + { + var composite = Composites.car(x, y, width, height, wheelSize); + + this.world.add(composite); + + return composite; + }, + + /** + * Creates a simple soft body like object. + * + * @method Phaser.Physics.Matter.Factory#softBody + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this composite in the world. + * @param {number} y - The vertical position of this composite in the world. + * @param {number} columns - The number of columns in the Composite. + * @param {number} rows - The number of rows in the Composite. + * @param {number} columnGap - The distance between each column. + * @param {number} rowGap - The distance between each row. + * @param {boolean} crossBrace - [description] + * @param {number} particleRadius - [description] + * @param {object} particleOptions - [description] + * @param {object} constraintOptions - [description] + * + * @return {Matter.Composite} A new composite simple soft body. + */ + softBody: function (x, y, columns, rows, columnGap, rowGap, crossBrace, particleRadius, particleOptions, constraintOptions) + { + var composite = Composites.softBody(x, y, columns, rows, columnGap, rowGap, crossBrace, particleRadius, particleOptions, constraintOptions); + + this.world.add(composite); + + return composite; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#joint + * @since 3.0.0 + * + * @param {Matter.Body} bodyA - [description] + * @param {Matter.Body} bodyB - [description] + * @param {number} length - [description] + * @param {number} [stiffness=1] - [description] + * @param {object} [options={}] - [description] + * + * @return {Matter.Constraint} A Matter JS Constraint. + */ + joint: function (bodyA, bodyB, length, stiffness, options) + { + return this.constraint(bodyA, bodyB, length, stiffness, options); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#spring + * @since 3.0.0 + * + * @param {Matter.Body} bodyA - [description] + * @param {Matter.Body} bodyB - [description] + * @param {number} length - [description] + * @param {number} [stiffness=1] - [description] + * @param {object} [options={}] - [description] + * + * @return {Matter.Constraint} A Matter JS Constraint. + */ + spring: function (bodyA, bodyB, length, stiffness, options) + { + return this.constraint(bodyA, bodyB, length, stiffness, options); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#constraint + * @since 3.0.0 + * + * @param {Matter.Body} bodyA - [description] + * @param {Matter.Body} bodyB - [description] + * @param {number} length - [description] + * @param {number} [stiffness=1] - [description] + * @param {object} [options={}] - [description] + * + * @return {Matter.Constraint} A Matter JS Constraint. + */ + constraint: function (bodyA, bodyB, length, stiffness, options) + { + if (stiffness === undefined) { stiffness = 1; } + if (options === undefined) { options = {}; } + + options.bodyA = (bodyA.type === 'body') ? bodyA : bodyA.body; + options.bodyB = (bodyB.type === 'body') ? bodyB : bodyB.body; + options.length = length; + options.stiffness = stiffness; + + var constraint = Constraint.create(options); + + this.world.add(constraint); + + return constraint; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#worldConstraint + * @since 3.0.0 + * + * @param {Matter.Body} bodyB - [description] + * @param {number} length - [description] + * @param {number} [stiffness=1] - [description] + * @param {object} [options={}] - [description] + * + * @return {Matter.Constraint} A Matter JS Constraint. + */ + worldConstraint: function (bodyB, length, stiffness, options) + { + if (stiffness === undefined) { stiffness = 1; } + if (options === undefined) { options = {}; } + + options.bodyB = (bodyB.type === 'body') ? bodyB : bodyB.body; + options.length = length; + options.stiffness = stiffness; + + var constraint = Constraint.create(options); + + this.world.add(constraint); + + return constraint; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#mouseSpring + * @since 3.0.0 + * + * @param {object} options - [description] + * + * @return {Matter.Constraint} A Matter JS Constraint. + */ + mouseSpring: function (options) + { + return this.pointerConstraint(options); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#pointerConstraint + * @since 3.0.0 + * + * @param {object} options - [description] + * + * @return {Matter.Constraint} A Matter JS Constraint. + */ + pointerConstraint: function (options) + { + var pointerConstraint = new PointerConstraint(this.scene, this.world, options); + + this.world.add(pointerConstraint.constraint); + + return pointerConstraint; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#image + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {object} options - [description] + * + * @return {Phaser.Physics.Matter.MatterImage} [description] + */ + image: function (x, y, key, frame, options) + { + var image = new MatterImage(this.world, x, y, key, frame, options); + + this.sys.displayList.add(image); + + return image; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#tileBody + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Tile} tile - [description] + * @param {object} options - [description] + * + * @return {Phaser.Physics.Matter.MatterTileBody} [description] + */ + tileBody: function (tile, options) + { + var tileBody = new MatterTileBody(this.world, tile, options); + + return tileBody; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#sprite + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {object} options - [description] + * + * @return {Phaser.Physics.Matter.MatterSprite} [description] + */ + sprite: function (x, y, key, frame, options) + { + var sprite = new MatterSprite(this.world, x, y, key, frame, options); + + this.sys.displayList.add(sprite); + this.sys.updateList.add(sprite); + + return sprite; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#gameObject + * @since 3.3.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to inject the Matter Body in to. + * @param {object} options - [description] + * + * @return {Phaser.GameObjects.GameObject} The Game Object that had the Matter Body injected into it. + */ + gameObject: function (gameObject, options) + { + return MatterGameObject(this.world, gameObject, options); + } + +}); + +module.exports = Factory; + + +/***/ }), +/* 965 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Body = __webpack_require__(971); +var Class = __webpack_require__(0); +var COLLIDES = __webpack_require__(200); +var CollisionMap = __webpack_require__(970); +var EventEmitter = __webpack_require__(15); +var GetFastValue = __webpack_require__(2); +var HasValue = __webpack_require__(70); +var Set = __webpack_require__(63); +var Solver = __webpack_require__(1001); +var TILEMAP_FORMATS = __webpack_require__(24); +var TYPE = __webpack_require__(199); + +/** + * @typedef {object} ImpactWorldConfig + * + * @property {number} [gravity=0] - [description] + * @property {number} [cellSize=64] - [description] + * @property {number} [timeScale=1] - [description] + * @property {float} [maxStep=0.05] - [description] + * @property {number} [gravity=0] - [description] + * @property {boolean} [debug=false] - [description] + * @property {number} [maxVelocity=100] - [description] + * @property {boolean} [debugShowBody=true] - [description] + * @property {boolean} [debugShowVelocity=true] - [description] + * @property {number} [debugBodyColor=0xff00ff] - [description] + * @property {number} [debugVelocityColor=0x00ff00] - [description] + * @property {number} [maxVelocityX=maxVelocity] - [description] + * @property {number} [maxVelocityY=maxVelocity] - [description] + * @property {number} [minBounceVelocity=40] - [description] + * @property {number} [gravityFactor=1] - [description] + * @property {number} [bounciness=0] - [description] + * @property {(object|boolean)} [setBounds] - [description] + * @property {number} [setBounds.x=0] - [description] + * @property {number} [setBounds.y=0] - [description] + * @property {number} [setBounds.x=0] - [description] + * @property {number} [setBounds.width] - [description] + * @property {number} [setBounds.height] - [description] + * @property {number} [setBounds.thickness=64] - [description] + * @property {boolean} [setBounds.left=true] - [description] + * @property {boolean} [setBounds.right=true] - [description] + * @property {boolean} [setBounds.top=true] - [description] + * @property {boolean} [setBounds.bottom=true] - [description] + */ + +/** + * An object containing the 4 wall bodies that bound the physics world. + * @typedef {object} ImpactWorldDefaults + * + * @property {boolean} debugShowBody - [description] + * @property {boolean} debugShowVelocity - [description] + * @property {number} bodyDebugColor - [description] + * @property {number} velocityDebugColor - [description] + * @property {number} maxVelocityX - [description] + * @property {number} maxVelocityY - [description] + * @property {number} minBounceVelocity - [description] + * @property {number} gravityFactor - [description] + * @property {number} bounciness - [description] + */ + +/** + * @typedef {object} ImpactWorldWalls + * + * @property {?Phaser.Physics.Impact.Body} left - [description] + * @property {?Phaser.Physics.Impact.Body} right - [description] + * @property {?Phaser.Physics.Impact.Body} top - [description] + * @property {?Phaser.Physics.Impact.Body} bottom - [description] + */ /** * @classdesc @@ -125862,7 +130828,7 @@ var TYPE = __webpack_require__(342); * @since 3.0.0 * * @param {Phaser.Scene} scene - [description] - * @param {object} config - [description] + * @param {ImpactWorldConfig} config - [description] */ var World = new Class({ @@ -125975,7 +130941,7 @@ var World = new Class({ * [description] * * @name Phaser.Physics.Impact.World#defaults - * @type {object} + * @type {ImpactWorldDefaults} * @since 3.0.0 */ this.defaults = { @@ -125994,7 +130960,7 @@ var World = new Class({ * An object containing the 4 wall bodies that bound the physics world. * * @name Phaser.Physics.Impact.World#walls - * @type {object} + * @type {ImpactWorldWalls} * @since 3.0.0 */ this.walls = { left: null, right: null, top: null, bottom: null }; @@ -126057,12 +131023,12 @@ var World = new Class({ * @method Phaser.Physics.Impact.World#setCollisionMap * @since 3.0.0 * - * @param {string|integer[][]} key - Either a string key that corresponds to a Weltmeister level + * @param {(string|integer[][])} key - Either a string key that corresponds to a Weltmeister level * in the cache, or a 2D array of collision IDs. * @param {integer} tileSize - The size of a tile. This is optional if loading from a Weltmeister * level in the cache. * - * @return {CollisionMap|null} The newly created CollisionMap, or null if the method failed to + * @return {?Phaser.Physics.Impact.CollisionMap} The newly created CollisionMap, or null if the method failed to * create the CollisionMap. */ setCollisionMap: function (key, tileSize) @@ -126113,7 +131079,7 @@ var World = new Class({ * @method Phaser.Physics.Impact.World#setCollisionMapFromTilemapLayer * @since 3.0.0 * - * @param {StaticTilemapLayer|DynamicTilemapLayer} tilemapLayer - The tilemap layer to use. + * @param {(StaticTilemapLayer|DynamicTilemapLayer)} tilemapLayer - The tilemap layer to use. * @param {object} [options] - Options for controlling the mapping from tiles to slope IDs. * @param {string} [options.slopeTileProperty=null] - Slope IDs can be stored on tiles directly * using Tiled's tileset editor. If a tile has a property with the given slopeTileProperty string @@ -126821,7 +131787,7 @@ module.exports = World; /***/ }), -/* 947 */ +/* 966 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -126830,1686 +131796,13 @@ module.exports = World; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Bodies = __webpack_require__(92); var Class = __webpack_require__(0); -var Composites = __webpack_require__(949); -var Constraint = __webpack_require__(168); -var MatterImage = __webpack_require__(950); -var MatterSprite = __webpack_require__(951); -var MatterTileBody = __webpack_require__(861); -var PointerConstraint = __webpack_require__(993); +var Components = __webpack_require__(469); +var Sprite = __webpack_require__(40); /** * @classdesc - * [description] - * - * @class Factory - * @memberOf Phaser.Physics.Matter - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Physics.Matter.World} world - [description] - */ -var Factory = new Class({ - - initialize: - - function Factory (world) - { - /** - * [description] - * - * @name Phaser.Physics.Matter.Factory#world - * @type {Phaser.Physics.Matter.World} - * @since 3.0.0 - */ - this.world = world; - - /** - * [description] - * - * @name Phaser.Physics.Matter.Factory#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = world.scene; - - /** - * A reference to the Scene.Systems this Matter Physics instance belongs to. - * - * @name Phaser.Physics.Matter.Factory#sys - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.sys = world.scene.sys; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Factory#rectangle - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {object} options - [description] - * - * @return {object} A Matter JS Body. - */ - rectangle: function (x, y, width, height, options) - { - var body = Bodies.rectangle(x, y, width, height, options); - - this.world.add(body); - - return body; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Factory#trapezoid - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} slope - [description] - * @param {object} options - [description] - * - * @return {object} A Matter JS Body. - */ - trapezoid: function (x, y, width, height, slope, options) - { - var body = Bodies.trapezoid(x, y, width, height, slope, options); - - this.world.add(body); - - return body; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Factory#circle - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} radius - [description] - * @param {object} options - [description] - * @param {number} maxSides - [description] - * - * @return {object} A Matter JS Body. - */ - circle: function (x, y, radius, options, maxSides) - { - var body = Bodies.circle(x, y, radius, options, maxSides); - - this.world.add(body); - - return body; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Factory#polygon - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} sides - [description] - * @param {number} radius - [description] - * @param {object} options - [description] - * - * @return {object} A Matter JS Body. - */ - polygon: function (x, y, sides, radius, options) - { - var body = Bodies.polygon(x, y, sides, radius, options); - - this.world.add(body); - - return body; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Factory#fromVertices - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {array} vertexSets - [description] - * @param {object} options - [description] - * @param {boolean} flagInternal - [description] - * @param {boolean} removeCollinear - [description] - * @param {number} minimumArea - [description] - * - * @return {object} A Matter JS Body. - */ - fromVertices: function (x, y, vertexSets, options, flagInternal, removeCollinear, minimumArea) - { - var body = Bodies.fromVertices(x, y, vertexSets, options, flagInternal, removeCollinear, minimumArea); - - this.world.add(body); - - return body; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Factory#imageStack - * @since 3.0.0 - * - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * @param {number} x - The horizontal position of this composite in the world. - * @param {number} y - The vertical position of this composite in the world. - * @param {number} columns - The number of columns in the Composite. - * @param {number} rows - The number of rows in the Composite. - * @param {number} columnGap - The distance between each column. - * @param {number} rowGap - The distance between each row. - * @param {object} options - [description] - * - * @return {object} A Matter JS Composite Stack. - */ - imageStack: function (key, frame, x, y, columns, rows, columnGap, rowGap, options) - { - if (columnGap === undefined) { columnGap = 0; } - if (rowGap === undefined) { rowGap = 0; } - if (options === undefined) { options = {}; } - - var world = this.world; - var displayList = this.sys.displayList; - - options.addToWorld = false; - - var stack = Composites.stack(x, y, columns, rows, columnGap, rowGap, function (x, y) - { - var image = new MatterImage(world, x, y, key, frame, options); - - displayList.add(image); - - return image.body; - }); - - world.add(stack); - - return stack; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Factory#stack - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this composite in the world. - * @param {number} y - The vertical position of this composite in the world. - * @param {number} columns - The number of columns in the Composite. - * @param {number} rows - The number of rows in the Composite. - * @param {number} columnGap - The distance between each column. - * @param {number} rowGap - The distance between each row. - * @param {object} options - [description] - * @param {function} callback - [description] - * - * @return {object} A Matter JS Composite Stack. - */ - stack: function (x, y, columns, rows, columnGap, rowGap, callback) - { - var stack = Composites.stack(x, y, columns, rows, columnGap, rowGap, callback); - - this.world.add(stack); - - return stack; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Factory#pyramid - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this composite in the world. - * @param {number} y - The vertical position of this composite in the world. - * @param {number} columns - The number of columns in the Composite. - * @param {number} rows - The number of rows in the Composite. - * @param {number} columnGap - The distance between each column. - * @param {number} rowGap - The distance between each row. - * @param {function} callback - [description] - * - * @return {object} A Matter JS Composite pyramid. - */ - pyramid: function (x, y, columns, rows, columnGap, rowGap, callback) - { - var stack = Composites.pyramid(x, y, columns, rows, columnGap, rowGap, callback); - - this.world.add(stack); - - return stack; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Factory#chain - * @since 3.0.0 - * - * @param {[type]} composite - [description] - * @param {[type]} xOffsetA - [description] - * @param {[type]} yOffsetA - [description] - * @param {[type]} xOffsetB - [description] - * @param {[type]} yOffsetB - [description] - * @param {object} options - [description] - * - * @return {object} A Matter JS Composite. - */ - chain: function (composite, xOffsetA, yOffsetA, xOffsetB, yOffsetB, options) - { - return Composites.chain(composite, xOffsetA, yOffsetA, xOffsetB, yOffsetB, options); - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Factory#mesh - * @since 3.0.0 - * - * @param {[type]} composite - [description] - * @param {[type]} columns - [description] - * @param {[type]} rows - [description] - * @param {[type]} crossBrace - [description] - * @param {object} options - [description] - * - * @return {object} A Matter JS Composite. - */ - mesh: function (composite, columns, rows, crossBrace, options) - { - return Composites.mesh(composite, columns, rows, crossBrace, options); - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Factory#newtonsCradle - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} number - [description] - * @param {number} size - [description] - * @param {number} length - [description] - * - * @return {object} A Matter JS Composite. - */ - newtonsCradle: function (x, y, number, size, length) - { - var composite = Composites.newtonsCradle(x, y, number, size, length); - - this.world.add(composite); - - return composite; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Factory#car - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} wheelSize - [description] - * - * @return {object} A Matter JS Composite. - */ - car: function (x, y, width, height, wheelSize) - { - var composite = Composites.car(x, y, width, height, wheelSize); - - this.world.add(composite); - - return composite; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Factory#softBody - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this composite in the world. - * @param {number} y - The vertical position of this composite in the world. - * @param {number} columns - The number of columns in the Composite. - * @param {number} rows - The number of rows in the Composite. - * @param {number} columnGap - The distance between each column. - * @param {number} rowGap - The distance between each row. - * @param {[type]} crossBrace - [description] - * @param {number} particleRadius - [description] - * @param {object} particleOptions - [description] - * @param {object} constraintOptions - [description] - * - * @return {object} A Matter JS Composite. - */ - softBody: function (x, y, columns, rows, columnGap, rowGap, crossBrace, particleRadius, particleOptions, constraintOptions) - { - var composite = Composites.softBody(x, y, columns, rows, columnGap, rowGap, crossBrace, particleRadius, particleOptions, constraintOptions); - - this.world.add(composite); - - return composite; - }, - - // To help those used to Box2D - - /** - * [description] - * - * @method Phaser.Physics.Matter.Factory#joint - * @since 3.0.0 - * - * @param {[type]} bodyA - [description] - * @param {[type]} bodyB - [description] - * @param {[type]} length - [description] - * @param {[type]} stiffness - [description] - * @param {object} options - [description] - * - * @return {object} A Matter JS Constraint. - */ - joint: function (bodyA, bodyB, length, stiffness, options) - { - return this.constraint(bodyA, bodyB, length, stiffness, options); - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Factory#spring - * @since 3.0.0 - * - * @param {[type]} bodyA - [description] - * @param {[type]} bodyB - [description] - * @param {[type]} length - [description] - * @param {[type]} stiffness - [description] - * @param {object} options - [description] - * - * @return {object} A Matter JS Constraint. - */ - spring: function (bodyA, bodyB, length, stiffness, options) - { - return this.constraint(bodyA, bodyB, length, stiffness, options); - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Factory#constraint - * @since 3.0.0 - * - * @param {[type]} bodyA - [description] - * @param {[type]} bodyB - [description] - * @param {[type]} length - [description] - * @param {[type]} stiffness - [description] - * @param {object} options - [description] - * - * @return {object} A Matter JS Constraint. - */ - constraint: function (bodyA, bodyB, length, stiffness, options) - { - if (stiffness === undefined) { stiffness = 1; } - if (options === undefined) { options = {}; } - - options.bodyA = (bodyA.type === 'body') ? bodyA : bodyA.body; - options.bodyB = (bodyB.type === 'body') ? bodyB : bodyB.body; - options.length = length; - options.stiffness = stiffness; - - var constraint = Constraint.create(options); - - this.world.add(constraint); - - return constraint; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Factory#worldConstraint - * @since 3.0.0 - * - * @param {[type]} bodyB - [description] - * @param {[type]} length - [description] - * @param {[type]} stiffness - [description] - * @param {object} options - [description] - * - * @return {object} A Matter JS Constraint. - */ - worldConstraint: function (bodyB, length, stiffness, options) - { - if (stiffness === undefined) { stiffness = 1; } - if (options === undefined) { options = {}; } - - options.bodyB = (bodyB.type === 'body') ? bodyB : bodyB.body; - options.length = length; - options.stiffness = stiffness; - - var constraint = Constraint.create(options); - - this.world.add(constraint); - - return constraint; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Factory#mouseSpring - * @since 3.0.0 - * - * @param {object} options - [description] - * - * @return {object} A Matter JS Constraint. - */ - mouseSpring: function (options) - { - return this.pointerConstraint(options); - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Factory#pointerConstraint - * @since 3.0.0 - * - * @param {object} options - [description] - * - * @return {object} A Matter JS Constraint. - */ - pointerConstraint: function (options) - { - var pointerConstraint = new PointerConstraint(this.scene, this.world, options); - - this.world.add(pointerConstraint.constraint); - - return pointerConstraint; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Factory#image - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * @param {object} options - [description] - * - * @return {Phaser.Physics.Matter.MatterImage} [description] - */ - image: function (x, y, key, frame, options) - { - var image = new MatterImage(this.world, x, y, key, frame, options); - - this.sys.displayList.add(image); - - return image; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Factory#tileBody - * @since 3.0.0 - * - * @param {[type]} tile - [description] - * @param {object} options - [description] - * - * @return {Phaser.Physics.Matter.MatterTileBody} [description] - */ - tileBody: function (tile, options) - { - var tileBody = new MatterTileBody(this.world, tile, options); - - return tileBody; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Factory#sprite - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * @param {object} options - [description] - * - * @return {Phaser.Physics.Matter.MatterSprite} [description] - */ - sprite: function (x, y, key, frame, options) - { - var sprite = new MatterSprite(this.world, x, y, key, frame, options); - - this.sys.displayList.add(sprite); - this.sys.updateList.add(sprite); - - return sprite; - } - -}); - -module.exports = Factory; - - -/***/ }), -/* 948 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -module.exports = { - decomp: polygonDecomp, - quickDecomp: polygonQuickDecomp, - isSimple: polygonIsSimple, - removeCollinearPoints: polygonRemoveCollinearPoints, - makeCCW: polygonMakeCCW -}; - -/** - * Compute the intersection between two lines. - * @static - * @method lineInt - * @param {Array} l1 Line vector 1 - * @param {Array} l2 Line vector 2 - * @param {Number} precision Precision to use when checking if the lines are parallel - * @return {Array} The intersection point. - */ -function lineInt(l1,l2,precision){ - precision = precision || 0; - var i = [0,0]; // point - var a1, b1, c1, a2, b2, c2, det; // scalars - a1 = l1[1][1] - l1[0][1]; - b1 = l1[0][0] - l1[1][0]; - c1 = a1 * l1[0][0] + b1 * l1[0][1]; - a2 = l2[1][1] - l2[0][1]; - b2 = l2[0][0] - l2[1][0]; - c2 = a2 * l2[0][0] + b2 * l2[0][1]; - det = a1 * b2 - a2*b1; - if (!scalar_eq(det, 0, precision)) { // lines are not parallel - i[0] = (b2 * c1 - b1 * c2) / det; - i[1] = (a1 * c2 - a2 * c1) / det; - } - return i; -} - -/** - * Checks if two line segments intersects. - * @method segmentsIntersect - * @param {Array} p1 The start vertex of the first line segment. - * @param {Array} p2 The end vertex of the first line segment. - * @param {Array} q1 The start vertex of the second line segment. - * @param {Array} q2 The end vertex of the second line segment. - * @return {Boolean} True if the two line segments intersect - */ -function lineSegmentsIntersect(p1, p2, q1, q2){ - var dx = p2[0] - p1[0]; - var dy = p2[1] - p1[1]; - var da = q2[0] - q1[0]; - var db = q2[1] - q1[1]; - - // segments are parallel - if((da*dy - db*dx) === 0){ - return false; - } - - var s = (dx * (q1[1] - p1[1]) + dy * (p1[0] - q1[0])) / (da * dy - db * dx); - var t = (da * (p1[1] - q1[1]) + db * (q1[0] - p1[0])) / (db * dx - da * dy); - - return (s>=0 && s<=1 && t>=0 && t<=1); -} - -/** - * Get the area of a triangle spanned by the three given points. Note that the area will be negative if the points are not given in counter-clockwise order. - * @static - * @method area - * @param {Array} a - * @param {Array} b - * @param {Array} c - * @return {Number} - */ -function triangleArea(a,b,c){ - return (((b[0] - a[0])*(c[1] - a[1]))-((c[0] - a[0])*(b[1] - a[1]))); -} - -function isLeft(a,b,c){ - return triangleArea(a,b,c) > 0; -} - -function isLeftOn(a,b,c) { - return triangleArea(a, b, c) >= 0; -} - -function isRight(a,b,c) { - return triangleArea(a, b, c) < 0; -} - -function isRightOn(a,b,c) { - return triangleArea(a, b, c) <= 0; -} - -var tmpPoint1 = [], - tmpPoint2 = []; - -/** - * Check if three points are collinear - * @method collinear - * @param {Array} a - * @param {Array} b - * @param {Array} c - * @param {Number} [thresholdAngle=0] Threshold angle to use when comparing the vectors. The function will return true if the angle between the resulting vectors is less than this value. Use zero for max precision. - * @return {Boolean} - */ -function collinear(a,b,c,thresholdAngle) { - if(!thresholdAngle){ - return triangleArea(a, b, c) === 0; - } else { - var ab = tmpPoint1, - bc = tmpPoint2; - - ab[0] = b[0]-a[0]; - ab[1] = b[1]-a[1]; - bc[0] = c[0]-b[0]; - bc[1] = c[1]-b[1]; - - var dot = ab[0]*bc[0] + ab[1]*bc[1], - magA = Math.sqrt(ab[0]*ab[0] + ab[1]*ab[1]), - magB = Math.sqrt(bc[0]*bc[0] + bc[1]*bc[1]), - angle = Math.acos(dot/(magA*magB)); - return angle < thresholdAngle; - } -} - -function sqdist(a,b){ - var dx = b[0] - a[0]; - var dy = b[1] - a[1]; - return dx * dx + dy * dy; -} - -/** - * Get a vertex at position i. It does not matter if i is out of bounds, this function will just cycle. - * @method at - * @param {Number} i - * @return {Array} - */ -function polygonAt(polygon, i){ - var s = polygon.length; - return polygon[i < 0 ? i % s + s : i % s]; -} - -/** - * Clear the polygon data - * @method clear - * @return {Array} - */ -function polygonClear(polygon){ - polygon.length = 0; -} - -/** - * Append points "from" to "to"-1 from an other polygon "poly" onto this one. - * @method append - * @param {Polygon} poly The polygon to get points from. - * @param {Number} from The vertex index in "poly". - * @param {Number} to The end vertex index in "poly". Note that this vertex is NOT included when appending. - * @return {Array} - */ -function polygonAppend(polygon, poly, from, to){ - for(var i=from; i v[br][0])) { - br = i; - } - } - - // reverse poly if clockwise - if (!isLeft(polygonAt(polygon, br - 1), polygonAt(polygon, br), polygonAt(polygon, br + 1))) { - polygonReverse(polygon); - } -} - -/** - * Reverse the vertices in the polygon - * @method reverse - */ -function polygonReverse(polygon){ - var tmp = []; - var N = polygon.length; - for(var i=0; i!==N; i++){ - tmp.push(polygon.pop()); - } - for(var i=0; i!==N; i++){ - polygon[i] = tmp[i]; - } -} - -/** - * Check if a point in the polygon is a reflex point - * @method isReflex - * @param {Number} i - * @return {Boolean} - */ -function polygonIsReflex(polygon, i){ - return isRight(polygonAt(polygon, i - 1), polygonAt(polygon, i), polygonAt(polygon, i + 1)); -} - -var tmpLine1=[], - tmpLine2=[]; - -/** - * Check if two vertices in the polygon can see each other - * @method canSee - * @param {Number} a Vertex index 1 - * @param {Number} b Vertex index 2 - * @return {Boolean} - */ -function polygonCanSee(polygon, a,b) { - var p, dist, l1=tmpLine1, l2=tmpLine2; - - if (isLeftOn(polygonAt(polygon, a + 1), polygonAt(polygon, a), polygonAt(polygon, b)) && isRightOn(polygonAt(polygon, a - 1), polygonAt(polygon, a), polygonAt(polygon, b))) { - return false; - } - dist = sqdist(polygonAt(polygon, a), polygonAt(polygon, b)); - for (var i = 0; i !== polygon.length; ++i) { // for each edge - if ((i + 1) % polygon.length === a || i === a){ // ignore incident edges - continue; - } - if (isLeftOn(polygonAt(polygon, a), polygonAt(polygon, b), polygonAt(polygon, i + 1)) && isRightOn(polygonAt(polygon, a), polygonAt(polygon, b), polygonAt(polygon, i))) { // if diag intersects an edge - l1[0] = polygonAt(polygon, a); - l1[1] = polygonAt(polygon, b); - l2[0] = polygonAt(polygon, i); - l2[1] = polygonAt(polygon, i + 1); - p = lineInt(l1,l2); - if (sqdist(polygonAt(polygon, a), p) < dist) { // if edge is blocking visibility to b - return false; - } - } - } - - return true; -} - -/** - * Copy the polygon from vertex i to vertex j. - * @method copy - * @param {Number} i - * @param {Number} j - * @param {Polygon} [targetPoly] Optional target polygon to save in. - * @return {Polygon} The resulting copy. - */ -function polygonCopy(polygon, i,j,targetPoly){ - var p = targetPoly || []; - polygonClear(p); - if (i < j) { - // Insert all vertices from i to j - for(var k=i; k<=j; k++){ - p.push(polygon[k]); - } - - } else { - - // Insert vertices 0 to j - for(var k=0; k<=j; k++){ - p.push(polygon[k]); - } - - // Insert vertices i to end - for(var k=i; k 0){ - return polygonSlice(polygon, edges); - } else { - return [polygon]; - } -} - -/** - * Slices the polygon given one or more cut edges. If given one, this function will return two polygons (false on failure). If many, an array of polygons. - * @method slice - * @param {Array} cutEdges A list of edges, as returned by .getCutEdges() - * @return {Array} - */ -function polygonSlice(polygon, cutEdges){ - if(cutEdges.length === 0){ - return [polygon]; - } - if(cutEdges instanceof Array && cutEdges.length && cutEdges[0] instanceof Array && cutEdges[0].length===2 && cutEdges[0][0] instanceof Array){ - - var polys = [polygon]; - - for(var i=0; i maxlevel){ - console.warn("quickDecomp: max level ("+maxlevel+") reached."); - return result; - } - - for (var i = 0; i < polygon.length; ++i) { - if (polygonIsReflex(poly, i)) { - reflexVertices.push(poly[i]); - upperDist = lowerDist = Number.MAX_VALUE; - - - for (var j = 0; j < polygon.length; ++j) { - if (isLeft(polygonAt(poly, i - 1), polygonAt(poly, i), polygonAt(poly, j)) && isRightOn(polygonAt(poly, i - 1), polygonAt(poly, i), polygonAt(poly, j - 1))) { // if line intersects with an edge - p = getIntersectionPoint(polygonAt(poly, i - 1), polygonAt(poly, i), polygonAt(poly, j), polygonAt(poly, j - 1)); // find the point of intersection - if (isRight(polygonAt(poly, i + 1), polygonAt(poly, i), p)) { // make sure it's inside the poly - d = sqdist(poly[i], p); - if (d < lowerDist) { // keep only the closest intersection - lowerDist = d; - lowerInt = p; - lowerIndex = j; - } - } - } - if (isLeft(polygonAt(poly, i + 1), polygonAt(poly, i), polygonAt(poly, j + 1)) && isRightOn(polygonAt(poly, i + 1), polygonAt(poly, i), polygonAt(poly, j))) { - p = getIntersectionPoint(polygonAt(poly, i + 1), polygonAt(poly, i), polygonAt(poly, j), polygonAt(poly, j + 1)); - if (isLeft(polygonAt(poly, i - 1), polygonAt(poly, i), p)) { - d = sqdist(poly[i], p); - if (d < upperDist) { - upperDist = d; - upperInt = p; - upperIndex = j; - } - } - } - } - - // if there are no vertices to connect to, choose a point in the middle - if (lowerIndex === (upperIndex + 1) % polygon.length) { - //console.log("Case 1: Vertex("+i+"), lowerIndex("+lowerIndex+"), upperIndex("+upperIndex+"), poly.size("+polygon.length+")"); - p[0] = (lowerInt[0] + upperInt[0]) / 2; - p[1] = (lowerInt[1] + upperInt[1]) / 2; - steinerPoints.push(p); - - if (i < upperIndex) { - //lowerPoly.insert(lowerPoly.end(), poly.begin() + i, poly.begin() + upperIndex + 1); - polygonAppend(lowerPoly, poly, i, upperIndex+1); - lowerPoly.push(p); - upperPoly.push(p); - if (lowerIndex !== 0){ - //upperPoly.insert(upperPoly.end(), poly.begin() + lowerIndex, poly.end()); - polygonAppend(upperPoly, poly,lowerIndex,poly.length); - } - //upperPoly.insert(upperPoly.end(), poly.begin(), poly.begin() + i + 1); - polygonAppend(upperPoly, poly,0,i+1); - } else { - if (i !== 0){ - //lowerPoly.insert(lowerPoly.end(), poly.begin() + i, poly.end()); - polygonAppend(lowerPoly, poly,i,poly.length); - } - //lowerPoly.insert(lowerPoly.end(), poly.begin(), poly.begin() + upperIndex + 1); - polygonAppend(lowerPoly, poly,0,upperIndex+1); - lowerPoly.push(p); - upperPoly.push(p); - //upperPoly.insert(upperPoly.end(), poly.begin() + lowerIndex, poly.begin() + i + 1); - polygonAppend(upperPoly, poly,lowerIndex,i+1); - } - } else { - // connect to the closest point within the triangle - //console.log("Case 2: Vertex("+i+"), closestIndex("+closestIndex+"), poly.size("+polygon.length+")\n"); - - if (lowerIndex > upperIndex) { - upperIndex += polygon.length; - } - closestDist = Number.MAX_VALUE; - - if(upperIndex < lowerIndex){ - return result; - } - - for (var j = lowerIndex; j <= upperIndex; ++j) { - if (isLeftOn(polygonAt(poly, i - 1), polygonAt(poly, i), polygonAt(poly, j)) && isRightOn(polygonAt(poly, i + 1), polygonAt(poly, i), polygonAt(poly, j))) { - d = sqdist(polygonAt(poly, i), polygonAt(poly, j)); - if (d < closestDist) { - closestDist = d; - closestIndex = j % polygon.length; - } - } - } - - if (i < closestIndex) { - polygonAppend(lowerPoly, poly,i,closestIndex+1); - if (closestIndex !== 0){ - polygonAppend(upperPoly, poly,closestIndex,v.length); - } - polygonAppend(upperPoly, poly,0,i+1); - } else { - if (i !== 0){ - polygonAppend(lowerPoly, poly,i,v.length); - } - polygonAppend(lowerPoly, poly,0,closestIndex+1); - polygonAppend(upperPoly, poly,closestIndex,i+1); - } - } - - // solve smallest poly first - if (lowerPoly.length < upperPoly.length) { - polygonQuickDecomp(lowerPoly,result,reflexVertices,steinerPoints,delta,maxlevel,level); - polygonQuickDecomp(upperPoly,result,reflexVertices,steinerPoints,delta,maxlevel,level); - } else { - polygonQuickDecomp(upperPoly,result,reflexVertices,steinerPoints,delta,maxlevel,level); - polygonQuickDecomp(lowerPoly,result,reflexVertices,steinerPoints,delta,maxlevel,level); - } - - return result; - } - } - result.push(polygon); - - return result; -} - -/** - * Remove collinear points in the polygon. - * @method removeCollinearPoints - * @param {Number} [precision] The threshold angle to use when determining whether two edges are collinear. Use zero for finest precision. - * @return {Number} The number of points removed - */ -function polygonRemoveCollinearPoints(polygon, precision){ - var num = 0; - for(var i=polygon.length-1; polygon.length>3 && i>=0; --i){ - if(collinear(polygonAt(polygon, i-1),polygonAt(polygon, i),polygonAt(polygon, i+1),precision)){ - // Remove the middle point - polygon.splice(i%polygon.length,1); - num++; - } - } - return num; -} - -/** - * Check if two scalars are equal - * @static - * @method eq - * @param {Number} a - * @param {Number} b - * @param {Number} [precision] - * @return {Boolean} - */ -function scalar_eq(a,b,precision){ - precision = precision || 0; - return Math.abs(a-b) < precision; -} - - -/***/ }), -/* 949 */ -/***/ (function(module, exports, __webpack_require__) { - -/** -* The `Matter.Composites` module contains factory methods for creating composite bodies -* with commonly used configurations (such as stacks and chains). -* -* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). -* -* @class Composites -*/ - -var Composites = {}; - -module.exports = Composites; - -var Composite = __webpack_require__(152); -var Constraint = __webpack_require__(168); -var Common = __webpack_require__(38); -var Body = __webpack_require__(60); -var Bodies = __webpack_require__(92); - -(function() { - - /** - * Create a new composite containing bodies created in the callback in a grid arrangement. - * This function uses the body's bounds to prevent overlaps. - * @method stack - * @param {number} xx - * @param {number} yy - * @param {number} columns - * @param {number} rows - * @param {number} columnGap - * @param {number} rowGap - * @param {function} callback - * @return {composite} A new composite containing objects created in the callback - */ - Composites.stack = function(xx, yy, columns, rows, columnGap, rowGap, callback) { - var stack = Composite.create({ label: 'Stack' }), - x = xx, - y = yy, - lastBody, - i = 0; - - for (var row = 0; row < rows; row++) { - var maxHeight = 0; - - for (var column = 0; column < columns; column++) { - var body = callback(x, y, column, row, lastBody, i); - - if (body) { - var bodyHeight = body.bounds.max.y - body.bounds.min.y, - bodyWidth = body.bounds.max.x - body.bounds.min.x; - - if (bodyHeight > maxHeight) - maxHeight = bodyHeight; - - Body.translate(body, { x: bodyWidth * 0.5, y: bodyHeight * 0.5 }); - - x = body.bounds.max.x + columnGap; - - Composite.addBody(stack, body); - - lastBody = body; - i += 1; - } else { - x += columnGap; - } - } - - y += maxHeight + rowGap; - x = xx; - } - - return stack; - }; - - /** - * Chains all bodies in the given composite together using constraints. - * @method chain - * @param {composite} composite - * @param {number} xOffsetA - * @param {number} yOffsetA - * @param {number} xOffsetB - * @param {number} yOffsetB - * @param {object} options - * @return {composite} A new composite containing objects chained together with constraints - */ - Composites.chain = function(composite, xOffsetA, yOffsetA, xOffsetB, yOffsetB, options) { - var bodies = composite.bodies; - - for (var i = 1; i < bodies.length; i++) { - var bodyA = bodies[i - 1], - bodyB = bodies[i], - bodyAHeight = bodyA.bounds.max.y - bodyA.bounds.min.y, - bodyAWidth = bodyA.bounds.max.x - bodyA.bounds.min.x, - bodyBHeight = bodyB.bounds.max.y - bodyB.bounds.min.y, - bodyBWidth = bodyB.bounds.max.x - bodyB.bounds.min.x; - - var defaults = { - bodyA: bodyA, - pointA: { x: bodyAWidth * xOffsetA, y: bodyAHeight * yOffsetA }, - bodyB: bodyB, - pointB: { x: bodyBWidth * xOffsetB, y: bodyBHeight * yOffsetB } - }; - - var constraint = Common.extend(defaults, options); - - Composite.addConstraint(composite, Constraint.create(constraint)); - } - - composite.label += ' Chain'; - - return composite; - }; - - /** - * Connects bodies in the composite with constraints in a grid pattern, with optional cross braces. - * @method mesh - * @param {composite} composite - * @param {number} columns - * @param {number} rows - * @param {boolean} crossBrace - * @param {object} options - * @return {composite} The composite containing objects meshed together with constraints - */ - Composites.mesh = function(composite, columns, rows, crossBrace, options) { - var bodies = composite.bodies, - row, - col, - bodyA, - bodyB, - bodyC; - - for (row = 0; row < rows; row++) { - for (col = 1; col < columns; col++) { - bodyA = bodies[(col - 1) + (row * columns)]; - bodyB = bodies[col + (row * columns)]; - Composite.addConstraint(composite, Constraint.create(Common.extend({ bodyA: bodyA, bodyB: bodyB }, options))); - } - - if (row > 0) { - for (col = 0; col < columns; col++) { - bodyA = bodies[col + ((row - 1) * columns)]; - bodyB = bodies[col + (row * columns)]; - Composite.addConstraint(composite, Constraint.create(Common.extend({ bodyA: bodyA, bodyB: bodyB }, options))); - - if (crossBrace && col > 0) { - bodyC = bodies[(col - 1) + ((row - 1) * columns)]; - Composite.addConstraint(composite, Constraint.create(Common.extend({ bodyA: bodyC, bodyB: bodyB }, options))); - } - - if (crossBrace && col < columns - 1) { - bodyC = bodies[(col + 1) + ((row - 1) * columns)]; - Composite.addConstraint(composite, Constraint.create(Common.extend({ bodyA: bodyC, bodyB: bodyB }, options))); - } - } - } - } - - composite.label += ' Mesh'; - - return composite; - }; - - /** - * Create a new composite containing bodies created in the callback in a pyramid arrangement. - * This function uses the body's bounds to prevent overlaps. - * @method pyramid - * @param {number} xx - * @param {number} yy - * @param {number} columns - * @param {number} rows - * @param {number} columnGap - * @param {number} rowGap - * @param {function} callback - * @return {composite} A new composite containing objects created in the callback - */ - Composites.pyramid = function(xx, yy, columns, rows, columnGap, rowGap, callback) { - return Composites.stack(xx, yy, columns, rows, columnGap, rowGap, function(x, y, column, row, lastBody, i) { - var actualRows = Math.min(rows, Math.ceil(columns / 2)), - lastBodyWidth = lastBody ? lastBody.bounds.max.x - lastBody.bounds.min.x : 0; - - if (row > actualRows) - return; - - // reverse row order - row = actualRows - row; - - var start = row, - end = columns - 1 - row; - - if (column < start || column > end) - return; - - // retroactively fix the first body's position, since width was unknown - if (i === 1) { - Body.translate(lastBody, { x: (column + (columns % 2 === 1 ? 1 : -1)) * lastBodyWidth, y: 0 }); - } - - var xOffset = lastBody ? column * lastBodyWidth : 0; - - return callback(xx + xOffset + column * columnGap, y, column, row, lastBody, i); - }); - }; - - /** - * Creates a composite with a Newton's Cradle setup of bodies and constraints. - * @method newtonsCradle - * @param {number} xx - * @param {number} yy - * @param {number} number - * @param {number} size - * @param {number} length - * @return {composite} A new composite newtonsCradle body - */ - Composites.newtonsCradle = function(xx, yy, number, size, length) { - var newtonsCradle = Composite.create({ label: 'Newtons Cradle' }); - - for (var i = 0; i < number; i++) { - var separation = 1.9, - circle = Bodies.circle(xx + i * (size * separation), yy + length, size, - { inertia: Infinity, restitution: 1, friction: 0, frictionAir: 0.0001, slop: 1 }), - constraint = Constraint.create({ pointA: { x: xx + i * (size * separation), y: yy }, bodyB: circle }); - - Composite.addBody(newtonsCradle, circle); - Composite.addConstraint(newtonsCradle, constraint); - } - - return newtonsCradle; - }; - - /** - * Creates a composite with simple car setup of bodies and constraints. - * @method car - * @param {number} xx - * @param {number} yy - * @param {number} width - * @param {number} height - * @param {number} wheelSize - * @return {composite} A new composite car body - */ - Composites.car = function(xx, yy, width, height, wheelSize) { - var group = Body.nextGroup(true), - wheelBase = 20, - wheelAOffset = -width * 0.5 + wheelBase, - wheelBOffset = width * 0.5 - wheelBase, - wheelYOffset = 0; - - var car = Composite.create({ label: 'Car' }), - body = Bodies.rectangle(xx, yy, width, height, { - collisionFilter: { - group: group - }, - chamfer: { - radius: height * 0.5 - }, - density: 0.0002 - }); - - var wheelA = Bodies.circle(xx + wheelAOffset, yy + wheelYOffset, wheelSize, { - collisionFilter: { - group: group - }, - friction: 0.8 - }); - - var wheelB = Bodies.circle(xx + wheelBOffset, yy + wheelYOffset, wheelSize, { - collisionFilter: { - group: group - }, - friction: 0.8 - }); - - var axelA = Constraint.create({ - bodyB: body, - pointB: { x: wheelAOffset, y: wheelYOffset }, - bodyA: wheelA, - stiffness: 1, - length: 0 - }); - - var axelB = Constraint.create({ - bodyB: body, - pointB: { x: wheelBOffset, y: wheelYOffset }, - bodyA: wheelB, - stiffness: 1, - length: 0 - }); - - Composite.addBody(car, body); - Composite.addBody(car, wheelA); - Composite.addBody(car, wheelB); - Composite.addConstraint(car, axelA); - Composite.addConstraint(car, axelB); - - return car; - }; - - /** - * Creates a simple soft body like object. - * @method softBody - * @param {number} xx - * @param {number} yy - * @param {number} columns - * @param {number} rows - * @param {number} columnGap - * @param {number} rowGap - * @param {boolean} crossBrace - * @param {number} particleRadius - * @param {} particleOptions - * @param {} constraintOptions - * @return {composite} A new composite softBody - */ - Composites.softBody = function(xx, yy, columns, rows, columnGap, rowGap, crossBrace, particleRadius, particleOptions, constraintOptions) { - particleOptions = Common.extend({ inertia: Infinity }, particleOptions); - constraintOptions = Common.extend({ stiffness: 0.2, render: { type: 'line', anchors: false } }, constraintOptions); - - var softBody = Composites.stack(xx, yy, columns, rows, columnGap, rowGap, function(x, y) { - return Bodies.circle(x, y, particleRadius, particleOptions); - }); - - Composites.mesh(softBody, columns, rows, crossBrace, constraintOptions); - - softBody.label = 'Soft Body'; - - return softBody; - }; - -})(); - - -/***/ }), -/* 950 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Bodies = __webpack_require__(92); -var Class = __webpack_require__(0); -var Components = __webpack_require__(860); -var GameObject = __webpack_require__(1); -var GetFastValue = __webpack_require__(2); -var Image = __webpack_require__(70); -var Pipeline = __webpack_require__(189); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * A Matter Physics Image Game Object. - * - * An Image is a light-weight Game Object useful for the display of static images in your game, - * such as logos, backgrounds, scenery or other non-animated elements. Images can have input - * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an - * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. - * - * @class MatterImage - * @extends Phaser.GameObjects.Image - * @memberOf Phaser.Physics.Matter - * @constructor - * @since 3.0.0 - * - * @extends Phaser.Physics.Matter.Components.Bounce - * @extends Phaser.Physics.Matter.Components.Collision - * @extends Phaser.Physics.Matter.Components.Force - * @extends Phaser.Physics.Matter.Components.Friction - * @extends Phaser.Physics.Matter.Components.Gravity - * @extends Phaser.Physics.Matter.Components.Mass - * @extends Phaser.Physics.Matter.Components.Sensor - * @extends Phaser.Physics.Matter.Components.SetBody - * @extends Phaser.Physics.Matter.Components.Sleep - * @extends Phaser.Physics.Matter.Components.Static - * @extends Phaser.Physics.Matter.Components.Transform - * @extends Phaser.Physics.Matter.Components.Velocity - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Physics.Matter.World} world - [description] - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * @param {object} options - [description] - */ -var MatterImage = new Class({ - - Extends: Image, - - Mixins: [ - Components.Bounce, - Components.Collision, - Components.Force, - Components.Friction, - Components.Gravity, - Components.Mass, - Components.Sensor, - Components.SetBody, - Components.Sleep, - Components.Static, - Components.Transform, - Components.Velocity, - Pipeline - ], - - initialize: - - function MatterImage (world, x, y, texture, frame, options) - { - GameObject.call(this, world.scene, 'Image'); - - this.setTexture(texture, frame); - this.setSizeToFrame(); - this.setOrigin(); - - this.world = world; - - this._tempVec2 = new Vector2(x, y); - - var shape = GetFastValue(options, 'shape', null); - - if (!shape) - { - this.body = Bodies.rectangle(x, y, this.width, this.height, options); - - this.body.gameObject = this; - - if (GetFastValue(options, 'addToWorld', true)) - { - world.add(this.body); - } - } - else - { - this.setBody(shape, options); - } - - this.setPosition(x, y); - - this.initPipeline('TextureTintPipeline'); - } - -}); - -module.exports = MatterImage; - - -/***/ }), -/* 951 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var AnimationComponent = __webpack_require__(365); -var Bodies = __webpack_require__(92); -var Class = __webpack_require__(0); -var Components = __webpack_require__(860); -var GameObject = __webpack_require__(1); -var GetFastValue = __webpack_require__(2); -var Pipeline = __webpack_require__(189); -var Sprite = __webpack_require__(37); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * A Matter Physics Sprite Game Object. + * An Impact Physics Sprite Game Object. * * A Sprite Game Object is used for the display of both static and animated images in your game. * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled @@ -128519,24 +131812,24 @@ var Vector2 = __webpack_require__(6); * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. * - * @class MatterSprite + * @class ImpactSprite * @extends Phaser.GameObjects.Sprite - * @memberOf Phaser.Physics.Matter + * @memberOf Phaser.Physics.Impact * @constructor * @since 3.0.0 * - * @extends Phaser.Physics.Matter.Components.Bounce - * @extends Phaser.Physics.Matter.Components.Collision - * @extends Phaser.Physics.Matter.Components.Force - * @extends Phaser.Physics.Matter.Components.Friction - * @extends Phaser.Physics.Matter.Components.Gravity - * @extends Phaser.Physics.Matter.Components.Mass - * @extends Phaser.Physics.Matter.Components.Sensor - * @extends Phaser.Physics.Matter.Components.SetBody - * @extends Phaser.Physics.Matter.Components.Sleep - * @extends Phaser.Physics.Matter.Components.Static - * @extends Phaser.Physics.Matter.Components.Transform - * @extends Phaser.Physics.Matter.Components.Velocity + * @extends Phaser.Physics.Impact.Components.Acceleration + * @extends Phaser.Physics.Impact.Components.BodyScale + * @extends Phaser.Physics.Impact.Components.BodyType + * @extends Phaser.Physics.Impact.Components.Bounce + * @extends Phaser.Physics.Impact.Components.CheckAgainst + * @extends Phaser.Physics.Impact.Components.Collides + * @extends Phaser.Physics.Impact.Components.Debug + * @extends Phaser.Physics.Impact.Components.Friction + * @extends Phaser.Physics.Impact.Components.Gravity + * @extends Phaser.Physics.Impact.Components.Offset + * @extends Phaser.Physics.Impact.Components.SetGameObject + * @extends Phaser.Physics.Impact.Components.Velocity * @extends Phaser.GameObjects.Components.Alpha * @extends Phaser.GameObjects.Components.Animation * @extends Phaser.GameObjects.Components.BlendMode @@ -128553,2839 +131846,112 @@ var Vector2 = __webpack_require__(6); * @extends Phaser.GameObjects.Components.Transform * @extends Phaser.GameObjects.Components.Visible * - * @param {Phaser.Physics.Matter.World} world - [description] + * @param {Phaser.Physics.Impact.World} world - [description] * @param {number} x - The horizontal position of this Game Object in the world. * @param {number} y - The vertical position of this Game Object in the world. * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {string|integer} [frame] - An optional frame from the Texture this Game Object is rendering with. - * @param {object} options - [description] + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. */ -var MatterSprite = new Class({ +var ImpactSprite = new Class({ Extends: Sprite, Mixins: [ + Components.Acceleration, + Components.BodyScale, + Components.BodyType, Components.Bounce, - Components.Collision, - Components.Force, + Components.CheckAgainst, + Components.Collides, + Components.Debug, Components.Friction, Components.Gravity, - Components.Mass, - Components.Sensor, - Components.SetBody, - Components.Sleep, - Components.Static, - Components.Transform, - Components.Velocity, - Pipeline + Components.Offset, + Components.SetGameObject, + Components.Velocity ], initialize: - function MatterSprite (world, x, y, texture, frame, options) + function ImpactSprite (world, x, y, texture, frame) { - GameObject.call(this, world.scene, 'Image'); + Sprite.call(this, world.scene, x, y, texture, frame); - this.anims = new AnimationComponent(this); + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactSprite#body + * @type {Phaser.Physics.Impact.Body} + * @since 3.0.0 + */ + this.body = world.create(x - this.frame.centerX, y - this.frame.centerY, this.width, this.height); - this.setTexture(texture, frame); - this.setSizeToFrame(); - this.setOrigin(); + this.body.parent = this; + this.body.gameObject = this; - this.world = world; + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactSprite#size + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.size = this.body.size; - this._tempVec2 = new Vector2(x, y); + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactSprite#offset + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.offset = this.body.offset; - var shape = GetFastValue(options, 'shape', null); + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactSprite#vel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.vel = this.body.vel; - if (!shape) - { - this.body = Bodies.rectangle(x, y, this.width, this.height, options); + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactSprite#accel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.accel = this.body.accel; - this.body.gameObject = this; + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactSprite#friction + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.friction = this.body.friction; - if (GetFastValue(options, 'addToWorld', true)) - { - world.add(this.body); - } - } - else - { - this.setBody(shape, options); - } - - this.setPosition(x, y); - - this.initPipeline('TextureTintPipeline'); + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactSprite#maxVel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.maxVel = this.body.maxVel; } }); -module.exports = MatterSprite; - - -/***/ }), -/* 952 */ -/***/ (function(module, exports, __webpack_require__) { - -/** -* The `Matter` module is the top level namespace. It also includes a function for installing plugins on top of the library. -* -* @class Matter -*/ - -var Matter = {}; - -module.exports = Matter; - -var Plugin = __webpack_require__(865); -var Common = __webpack_require__(38); - -(function() { - - /** - * The library name. - * @property name - * @readOnly - * @type {String} - */ - Matter.name = 'matter-js'; - - /** - * The library version. - * @property version - * @readOnly - * @type {String} - */ - Matter.version = '0.13.1'; - - /** - * A list of plugin dependencies to be installed. These are normally set and installed through `Matter.use`. - * Alternatively you may set `Matter.uses` manually and install them by calling `Plugin.use(Matter)`. - * @property uses - * @type {Array} - */ - Matter.uses = []; - - /** - * The plugins that have been installed through `Matter.Plugin.install`. Read only. - * @property used - * @readOnly - * @type {Array} - */ - Matter.used = []; - - /** - * Installs the given plugins on the `Matter` namespace. - * This is a short-hand for `Plugin.use`, see it for more information. - * Call this function once at the start of your code, with all of the plugins you wish to install as arguments. - * Avoid calling this function multiple times unless you intend to manually control installation order. - * @method use - * @param ...plugin {Function} The plugin(s) to install on `base` (multi-argument). - */ - Matter.use = function() { - Plugin.use(Matter, Array.prototype.slice.call(arguments)); - }; - - /** - * Chains a function to excute before the original function on the given `path` relative to `Matter`. - * See also docs for `Common.chain`. - * @method before - * @param {string} path The path relative to `Matter` - * @param {function} func The function to chain before the original - * @return {function} The chained function that replaced the original - */ - Matter.before = function(path, func) { - path = path.replace(/^Matter./, ''); - return Common.chainPathBefore(Matter, path, func); - }; - - /** - * Chains a function to excute after the original function on the given `path` relative to `Matter`. - * See also docs for `Common.chain`. - * @method after - * @param {string} path The path relative to `Matter` - * @param {function} func The function to chain after the original - * @return {function} The chained function that replaced the original - */ - Matter.after = function(path, func) { - path = path.replace(/^Matter./, ''); - return Common.chainPathAfter(Matter, path, func); - }; - -})(); - - -/***/ }), -/* 953 */ -/***/ (function(module, exports, __webpack_require__) { - -/** -* The `Matter.Grid` module contains methods for creating and manipulating collision broadphase grid structures. -* -* @class Grid -*/ - -var Grid = {}; - -module.exports = Grid; - -var Pair = __webpack_require__(375); -var Detector = __webpack_require__(862); -var Common = __webpack_require__(38); - -(function() { - - /** - * Creates a new grid. - * @method create - * @param {} options - * @return {grid} A new grid - */ - Grid.create = function(options) { - var defaults = { - controller: Grid, - detector: Detector.collisions, - buckets: {}, - pairs: {}, - pairsList: [], - bucketWidth: 48, - bucketHeight: 48 - }; - - return Common.extend(defaults, options); - }; - - /** - * The width of a single grid bucket. - * - * @property bucketWidth - * @type number - * @default 48 - */ - - /** - * The height of a single grid bucket. - * - * @property bucketHeight - * @type number - * @default 48 - */ - - /** - * Updates the grid. - * @method update - * @param {grid} grid - * @param {body[]} bodies - * @param {engine} engine - * @param {boolean} forceUpdate - */ - Grid.update = function(grid, bodies, engine, forceUpdate) { - var i, col, row, - world = engine.world, - buckets = grid.buckets, - bucket, - bucketId, - gridChanged = false; - - // @if DEBUG - var metrics = engine.metrics; - metrics.broadphaseTests = 0; - // @endif - - for (i = 0; i < bodies.length; i++) { - var body = bodies[i]; - - if (body.isSleeping && !forceUpdate) - continue; - - // don't update out of world bodies - if (body.bounds.max.x < world.bounds.min.x || body.bounds.min.x > world.bounds.max.x - || body.bounds.max.y < world.bounds.min.y || body.bounds.min.y > world.bounds.max.y) - continue; - - var newRegion = _getRegion(grid, body); - - // if the body has changed grid region - if (!body.region || newRegion.id !== body.region.id || forceUpdate) { - - // @if DEBUG - metrics.broadphaseTests += 1; - // @endif - - if (!body.region || forceUpdate) - body.region = newRegion; - - var union = _regionUnion(newRegion, body.region); - - // update grid buckets affected by region change - // iterate over the union of both regions - for (col = union.startCol; col <= union.endCol; col++) { - for (row = union.startRow; row <= union.endRow; row++) { - bucketId = _getBucketId(col, row); - bucket = buckets[bucketId]; - - var isInsideNewRegion = (col >= newRegion.startCol && col <= newRegion.endCol - && row >= newRegion.startRow && row <= newRegion.endRow); - - var isInsideOldRegion = (col >= body.region.startCol && col <= body.region.endCol - && row >= body.region.startRow && row <= body.region.endRow); - - // remove from old region buckets - if (!isInsideNewRegion && isInsideOldRegion) { - if (isInsideOldRegion) { - if (bucket) - _bucketRemoveBody(grid, bucket, body); - } - } - - // add to new region buckets - if (body.region === newRegion || (isInsideNewRegion && !isInsideOldRegion) || forceUpdate) { - if (!bucket) - bucket = _createBucket(buckets, bucketId); - _bucketAddBody(grid, bucket, body); - } - } - } - - // set the new region - body.region = newRegion; - - // flag changes so we can update pairs - gridChanged = true; - } - } - - // update pairs list only if pairs changed (i.e. a body changed region) - if (gridChanged) - grid.pairsList = _createActivePairsList(grid); - }; - - /** - * Clears the grid. - * @method clear - * @param {grid} grid - */ - Grid.clear = function(grid) { - grid.buckets = {}; - grid.pairs = {}; - grid.pairsList = []; - }; - - /** - * Finds the union of two regions. - * @method _regionUnion - * @private - * @param {} regionA - * @param {} regionB - * @return {} region - */ - var _regionUnion = function(regionA, regionB) { - var startCol = Math.min(regionA.startCol, regionB.startCol), - endCol = Math.max(regionA.endCol, regionB.endCol), - startRow = Math.min(regionA.startRow, regionB.startRow), - endRow = Math.max(regionA.endRow, regionB.endRow); - - return _createRegion(startCol, endCol, startRow, endRow); - }; - - /** - * Gets the region a given body falls in for a given grid. - * @method _getRegion - * @private - * @param {} grid - * @param {} body - * @return {} region - */ - var _getRegion = function(grid, body) { - var bounds = body.bounds, - startCol = Math.floor(bounds.min.x / grid.bucketWidth), - endCol = Math.floor(bounds.max.x / grid.bucketWidth), - startRow = Math.floor(bounds.min.y / grid.bucketHeight), - endRow = Math.floor(bounds.max.y / grid.bucketHeight); - - return _createRegion(startCol, endCol, startRow, endRow); - }; - - /** - * Creates a region. - * @method _createRegion - * @private - * @param {} startCol - * @param {} endCol - * @param {} startRow - * @param {} endRow - * @return {} region - */ - var _createRegion = function(startCol, endCol, startRow, endRow) { - return { - id: startCol + ',' + endCol + ',' + startRow + ',' + endRow, - startCol: startCol, - endCol: endCol, - startRow: startRow, - endRow: endRow - }; - }; - - /** - * Gets the bucket id at the given position. - * @method _getBucketId - * @private - * @param {} column - * @param {} row - * @return {string} bucket id - */ - var _getBucketId = function(column, row) { - return 'C' + column + 'R' + row; - }; - - /** - * Creates a bucket. - * @method _createBucket - * @private - * @param {} buckets - * @param {} bucketId - * @return {} bucket - */ - var _createBucket = function(buckets, bucketId) { - var bucket = buckets[bucketId] = []; - return bucket; - }; - - /** - * Adds a body to a bucket. - * @method _bucketAddBody - * @private - * @param {} grid - * @param {} bucket - * @param {} body - */ - var _bucketAddBody = function(grid, bucket, body) { - // add new pairs - for (var i = 0; i < bucket.length; i++) { - var bodyB = bucket[i]; - - if (body.id === bodyB.id || (body.isStatic && bodyB.isStatic)) - continue; - - // keep track of the number of buckets the pair exists in - // important for Grid.update to work - var pairId = Pair.id(body, bodyB), - pair = grid.pairs[pairId]; - - if (pair) { - pair[2] += 1; - } else { - grid.pairs[pairId] = [body, bodyB, 1]; - } - } - - // add to bodies (after pairs, otherwise pairs with self) - bucket.push(body); - }; - - /** - * Removes a body from a bucket. - * @method _bucketRemoveBody - * @private - * @param {} grid - * @param {} bucket - * @param {} body - */ - var _bucketRemoveBody = function(grid, bucket, body) { - // remove from bucket - bucket.splice(bucket.indexOf(body), 1); - - // update pair counts - for (var i = 0; i < bucket.length; i++) { - // keep track of the number of buckets the pair exists in - // important for _createActivePairsList to work - var bodyB = bucket[i], - pairId = Pair.id(body, bodyB), - pair = grid.pairs[pairId]; - - if (pair) - pair[2] -= 1; - } - }; - - /** - * Generates a list of the active pairs in the grid. - * @method _createActivePairsList - * @private - * @param {} grid - * @return [] pairs - */ - var _createActivePairsList = function(grid) { - var pairKeys, - pair, - pairs = []; - - // grid.pairs is used as a hashmap - pairKeys = Common.keys(grid.pairs); - - // iterate over grid.pairs - for (var k = 0; k < pairKeys.length; k++) { - pair = grid.pairs[pairKeys[k]]; - - // if pair exists in at least one bucket - // it is a pair that needs further collision testing so push it - if (pair[2] > 0) { - pairs.push(pair); - } else { - delete grid.pairs[pairKeys[k]]; - } - } - - return pairs; - }; - -})(); - - -/***/ }), -/* 954 */ -/***/ (function(module, exports, __webpack_require__) { - -/** -* The `Matter.Pairs` module contains methods for creating and manipulating collision pair sets. -* -* @class Pairs -*/ - -var Pairs = {}; - -module.exports = Pairs; - -var Pair = __webpack_require__(375); -var Common = __webpack_require__(38); - -(function() { - - var _pairMaxIdleLife = 1000; - - /** - * Creates a new pairs structure. - * @method create - * @param {object} options - * @return {pairs} A new pairs structure - */ - Pairs.create = function(options) { - return Common.extend({ - table: {}, - list: [], - collisionStart: [], - collisionActive: [], - collisionEnd: [] - }, options); - }; - - /** - * Updates pairs given a list of collisions. - * @method update - * @param {object} pairs - * @param {collision[]} collisions - * @param {number} timestamp - */ - Pairs.update = function(pairs, collisions, timestamp) { - var pairsList = pairs.list, - pairsTable = pairs.table, - collisionStart = pairs.collisionStart, - collisionEnd = pairs.collisionEnd, - collisionActive = pairs.collisionActive, - collision, - pairId, - pair, - i; - - // clear collision state arrays, but maintain old reference - collisionStart.length = 0; - collisionEnd.length = 0; - collisionActive.length = 0; - - for (i = 0; i < pairsList.length; i++) { - pairsList[i].confirmedActive = false; - } - - for (i = 0; i < collisions.length; i++) { - collision = collisions[i]; - - if (collision.collided) { - pairId = Pair.id(collision.bodyA, collision.bodyB); - - pair = pairsTable[pairId]; - - if (pair) { - // pair already exists (but may or may not be active) - if (pair.isActive) { - // pair exists and is active - collisionActive.push(pair); - } else { - // pair exists but was inactive, so a collision has just started again - collisionStart.push(pair); - } - - // update the pair - Pair.update(pair, collision, timestamp); - pair.confirmedActive = true; - } else { - // pair did not exist, create a new pair - pair = Pair.create(collision, timestamp); - pairsTable[pairId] = pair; - - // push the new pair - collisionStart.push(pair); - pairsList.push(pair); - } - } - } - - // deactivate previously active pairs that are now inactive - for (i = 0; i < pairsList.length; i++) { - pair = pairsList[i]; - if (!pair.confirmedActive) { - Pair.setActive(pair, false, timestamp); - collisionEnd.push(pair); - } - } - }; - - /** - * Finds and removes pairs that have been inactive for a set amount of time. - * @method removeOld - * @param {object} pairs - * @param {number} timestamp - */ - Pairs.removeOld = function(pairs, timestamp) { - var pairsList = pairs.list, - pairsTable = pairs.table, - indexesToRemove = [], - pair, - collision, - pairIndex, - i; - - for (i = 0; i < pairsList.length; i++) { - pair = pairsList[i]; - collision = pair.collision; - - // never remove sleeping pairs - if (collision.bodyA.isSleeping || collision.bodyB.isSleeping) { - pair.timeUpdated = timestamp; - continue; - } - - // if pair is inactive for too long, mark it to be removed - if (timestamp - pair.timeUpdated > _pairMaxIdleLife) { - indexesToRemove.push(i); - } - } - - // remove marked pairs - for (i = 0; i < indexesToRemove.length; i++) { - pairIndex = indexesToRemove[i] - i; - pair = pairsList[pairIndex]; - delete pairsTable[pair.id]; - pairsList.splice(pairIndex, 1); - } - }; - - /** - * Clears the given pairs structure. - * @method clear - * @param {pairs} pairs - * @return {pairs} pairs - */ - Pairs.clear = function(pairs) { - pairs.table = {}; - pairs.list.length = 0; - pairs.collisionStart.length = 0; - pairs.collisionActive.length = 0; - pairs.collisionEnd.length = 0; - return pairs; - }; - -})(); - - -/***/ }), -/* 955 */ -/***/ (function(module, exports, __webpack_require__) { - -/** -* The `Matter.Resolver` module contains methods for resolving collision pairs. -* -* @class Resolver -*/ - -var Resolver = {}; - -module.exports = Resolver; - -var Vertices = __webpack_require__(93); -var Vector = __webpack_require__(94); -var Common = __webpack_require__(38); -var Bounds = __webpack_require__(95); - -(function() { - - Resolver._restingThresh = 4; - Resolver._restingThreshTangent = 6; - Resolver._positionDampen = 0.9; - Resolver._positionWarming = 0.8; - Resolver._frictionNormalMultiplier = 5; - - /** - * Prepare pairs for position solving. - * @method preSolvePosition - * @param {pair[]} pairs - */ - Resolver.preSolvePosition = function(pairs) { - var i, - pair, - activeCount; - - // find total contacts on each body - for (i = 0; i < pairs.length; i++) { - pair = pairs[i]; - - if (!pair.isActive) - continue; - - activeCount = pair.activeContacts.length; - pair.collision.parentA.totalContacts += activeCount; - pair.collision.parentB.totalContacts += activeCount; - } - }; - - /** - * Find a solution for pair positions. - * @method solvePosition - * @param {pair[]} pairs - * @param {number} timeScale - */ - Resolver.solvePosition = function(pairs, bodies, timeScale) { - var i, - normalX, - normalY, - pair, - collision, - bodyA, - bodyB, - normal, - separation, - penetration, - positionImpulseA, - positionImpulseB, - contactShare, - bodyBtoAX, - bodyBtoAY, - positionImpulse, - impulseCoefficient = timeScale * Resolver._positionDampen; - - for (i = 0; i < bodies.length; i++) { - var body = bodies[i]; - body.previousPositionImpulse.x = body.positionImpulse.x; - body.previousPositionImpulse.y = body.positionImpulse.y; - } - - // find impulses required to resolve penetration - for (i = 0; i < pairs.length; i++) { - pair = pairs[i]; - - if (!pair.isActive || pair.isSensor) - continue; - - collision = pair.collision; - bodyA = collision.parentA; - bodyB = collision.parentB; - normal = collision.normal; - - positionImpulseA = bodyA.previousPositionImpulse; - positionImpulseB = bodyB.previousPositionImpulse; - - penetration = collision.penetration; - - // bodyBtoA = positionImpulseB - positionImpulseA + penetration - bodyBtoAX = positionImpulseB.x - positionImpulseA.x + penetration.x; - bodyBtoAY = positionImpulseB.y - positionImpulseA.y + penetration.y; - - normalX = normal.x; - normalY = normal.y; - - // separation = dot(normal, bodyBtoA) - separation = normalX * bodyBtoAX + normalY * bodyBtoAY; - pair.separation = separation; - - positionImpulse = (separation - pair.slop) * impulseCoefficient; - - if (bodyA.isStatic || bodyB.isStatic) - positionImpulse *= 2; - - if (!(bodyA.isStatic || bodyA.isSleeping)) { - contactShare = positionImpulse / bodyA.totalContacts; - bodyA.positionImpulse.x += normalX * contactShare; - bodyA.positionImpulse.y += normalY * contactShare; - } - - if (!(bodyB.isStatic || bodyB.isSleeping)) { - contactShare = positionImpulse / bodyB.totalContacts; - bodyB.positionImpulse.x -= normalX * contactShare; - bodyB.positionImpulse.y -= normalY * contactShare; - } - } - }; - - /** - * Apply position resolution. - * @method postSolvePosition - * @param {body[]} bodies - */ - Resolver.postSolvePosition = function(bodies) { - for (var i = 0; i < bodies.length; i++) { - var body = bodies[i]; - - // reset contact count - body.totalContacts = 0; - - if (body.positionImpulse.x !== 0 || body.positionImpulse.y !== 0) { - // update body geometry - for (var j = 0; j < body.parts.length; j++) { - var part = body.parts[j]; - Vertices.translate(part.vertices, body.positionImpulse); - Bounds.update(part.bounds, part.vertices, body.velocity); - part.position.x += body.positionImpulse.x; - part.position.y += body.positionImpulse.y; - } - - // move the body without changing velocity - body.positionPrev.x += body.positionImpulse.x; - body.positionPrev.y += body.positionImpulse.y; - - if (Vector.dot(body.positionImpulse, body.velocity) < 0) { - // reset cached impulse if the body has velocity along it - body.positionImpulse.x = 0; - body.positionImpulse.y = 0; - } else { - // warm the next iteration - body.positionImpulse.x *= Resolver._positionWarming; - body.positionImpulse.y *= Resolver._positionWarming; - } - } - } - }; - - /** - * Prepare pairs for velocity solving. - * @method preSolveVelocity - * @param {pair[]} pairs - */ - Resolver.preSolveVelocity = function(pairs) { - var i, - j, - pair, - contacts, - collision, - bodyA, - bodyB, - normal, - tangent, - contact, - contactVertex, - normalImpulse, - tangentImpulse, - offset, - impulse = Vector._temp[0], - tempA = Vector._temp[1]; - - for (i = 0; i < pairs.length; i++) { - pair = pairs[i]; - - if (!pair.isActive || pair.isSensor) - continue; - - contacts = pair.activeContacts; - collision = pair.collision; - bodyA = collision.parentA; - bodyB = collision.parentB; - normal = collision.normal; - tangent = collision.tangent; - - // resolve each contact - for (j = 0; j < contacts.length; j++) { - contact = contacts[j]; - contactVertex = contact.vertex; - normalImpulse = contact.normalImpulse; - tangentImpulse = contact.tangentImpulse; - - if (normalImpulse !== 0 || tangentImpulse !== 0) { - // total impulse from contact - impulse.x = (normal.x * normalImpulse) + (tangent.x * tangentImpulse); - impulse.y = (normal.y * normalImpulse) + (tangent.y * tangentImpulse); - - // apply impulse from contact - if (!(bodyA.isStatic || bodyA.isSleeping)) { - offset = Vector.sub(contactVertex, bodyA.position, tempA); - bodyA.positionPrev.x += impulse.x * bodyA.inverseMass; - bodyA.positionPrev.y += impulse.y * bodyA.inverseMass; - bodyA.anglePrev += Vector.cross(offset, impulse) * bodyA.inverseInertia; - } - - if (!(bodyB.isStatic || bodyB.isSleeping)) { - offset = Vector.sub(contactVertex, bodyB.position, tempA); - bodyB.positionPrev.x -= impulse.x * bodyB.inverseMass; - bodyB.positionPrev.y -= impulse.y * bodyB.inverseMass; - bodyB.anglePrev -= Vector.cross(offset, impulse) * bodyB.inverseInertia; - } - } - } - } - }; - - /** - * Find a solution for pair velocities. - * @method solveVelocity - * @param {pair[]} pairs - * @param {number} timeScale - */ - Resolver.solveVelocity = function(pairs, timeScale) { - var timeScaleSquared = timeScale * timeScale, - impulse = Vector._temp[0], - tempA = Vector._temp[1], - tempB = Vector._temp[2], - tempC = Vector._temp[3], - tempD = Vector._temp[4], - tempE = Vector._temp[5]; - - for (var i = 0; i < pairs.length; i++) { - var pair = pairs[i]; - - if (!pair.isActive || pair.isSensor) - continue; - - var collision = pair.collision, - bodyA = collision.parentA, - bodyB = collision.parentB, - normal = collision.normal, - tangent = collision.tangent, - contacts = pair.activeContacts, - contactShare = 1 / contacts.length; - - // update body velocities - bodyA.velocity.x = bodyA.position.x - bodyA.positionPrev.x; - bodyA.velocity.y = bodyA.position.y - bodyA.positionPrev.y; - bodyB.velocity.x = bodyB.position.x - bodyB.positionPrev.x; - bodyB.velocity.y = bodyB.position.y - bodyB.positionPrev.y; - bodyA.angularVelocity = bodyA.angle - bodyA.anglePrev; - bodyB.angularVelocity = bodyB.angle - bodyB.anglePrev; - - // resolve each contact - for (var j = 0; j < contacts.length; j++) { - var contact = contacts[j], - contactVertex = contact.vertex, - offsetA = Vector.sub(contactVertex, bodyA.position, tempA), - offsetB = Vector.sub(contactVertex, bodyB.position, tempB), - velocityPointA = Vector.add(bodyA.velocity, Vector.mult(Vector.perp(offsetA), bodyA.angularVelocity), tempC), - velocityPointB = Vector.add(bodyB.velocity, Vector.mult(Vector.perp(offsetB), bodyB.angularVelocity), tempD), - relativeVelocity = Vector.sub(velocityPointA, velocityPointB, tempE), - normalVelocity = Vector.dot(normal, relativeVelocity); - - var tangentVelocity = Vector.dot(tangent, relativeVelocity), - tangentSpeed = Math.abs(tangentVelocity), - tangentVelocityDirection = Common.sign(tangentVelocity); - - // raw impulses - var normalImpulse = (1 + pair.restitution) * normalVelocity, - normalForce = Common.clamp(pair.separation + normalVelocity, 0, 1) * Resolver._frictionNormalMultiplier; - - // coulomb friction - var tangentImpulse = tangentVelocity, - maxFriction = Infinity; - - if (tangentSpeed > pair.friction * pair.frictionStatic * normalForce * timeScaleSquared) { - maxFriction = tangentSpeed; - tangentImpulse = Common.clamp( - pair.friction * tangentVelocityDirection * timeScaleSquared, - -maxFriction, maxFriction - ); - } - - // modify impulses accounting for mass, inertia and offset - var oAcN = Vector.cross(offsetA, normal), - oBcN = Vector.cross(offsetB, normal), - share = contactShare / (bodyA.inverseMass + bodyB.inverseMass + bodyA.inverseInertia * oAcN * oAcN + bodyB.inverseInertia * oBcN * oBcN); - - normalImpulse *= share; - tangentImpulse *= share; - - // handle high velocity and resting collisions separately - if (normalVelocity < 0 && normalVelocity * normalVelocity > Resolver._restingThresh * timeScaleSquared) { - // high normal velocity so clear cached contact normal impulse - contact.normalImpulse = 0; - } else { - // solve resting collision constraints using Erin Catto's method (GDC08) - // impulse constraint tends to 0 - var contactNormalImpulse = contact.normalImpulse; - contact.normalImpulse = Math.min(contact.normalImpulse + normalImpulse, 0); - normalImpulse = contact.normalImpulse - contactNormalImpulse; - } - - // handle high velocity and resting collisions separately - if (tangentVelocity * tangentVelocity > Resolver._restingThreshTangent * timeScaleSquared) { - // high tangent velocity so clear cached contact tangent impulse - contact.tangentImpulse = 0; - } else { - // solve resting collision constraints using Erin Catto's method (GDC08) - // tangent impulse tends to -tangentSpeed or +tangentSpeed - var contactTangentImpulse = contact.tangentImpulse; - contact.tangentImpulse = Common.clamp(contact.tangentImpulse + tangentImpulse, -maxFriction, maxFriction); - tangentImpulse = contact.tangentImpulse - contactTangentImpulse; - } - - // total impulse from contact - impulse.x = (normal.x * normalImpulse) + (tangent.x * tangentImpulse); - impulse.y = (normal.y * normalImpulse) + (tangent.y * tangentImpulse); - - // apply impulse from contact - if (!(bodyA.isStatic || bodyA.isSleeping)) { - bodyA.positionPrev.x += impulse.x * bodyA.inverseMass; - bodyA.positionPrev.y += impulse.y * bodyA.inverseMass; - bodyA.anglePrev += Vector.cross(offsetA, impulse) * bodyA.inverseInertia; - } - - if (!(bodyB.isStatic || bodyB.isSleeping)) { - bodyB.positionPrev.x -= impulse.x * bodyB.inverseMass; - bodyB.positionPrev.y -= impulse.y * bodyB.inverseMass; - bodyB.anglePrev -= Vector.cross(offsetB, impulse) * bodyB.inverseInertia; - } - } - } - }; - -})(); - - -/***/ }), -/* 956 */ -/***/ (function(module, exports, __webpack_require__) { - -/** -* The `Matter.Engine` module contains methods for creating and manipulating engines. -* An engine is a controller that manages updating the simulation of the world. -* See `Matter.Runner` for an optional game loop utility. -* -* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). -* -* @class Engine -*/ - -var Engine = {}; - -module.exports = Engine; - -var World = __webpack_require__(866); -var Sleeping = __webpack_require__(343); -var Resolver = __webpack_require__(955); -var Pairs = __webpack_require__(954); -var Metrics = __webpack_require__(995); -var Grid = __webpack_require__(953); -var Events = __webpack_require__(167); -var Composite = __webpack_require__(152); -var Constraint = __webpack_require__(168); -var Common = __webpack_require__(38); -var Body = __webpack_require__(60); - -(function() { - - /** - * Creates a new engine. The options parameter is an object that specifies any properties you wish to override the defaults. - * All properties have default values, and many are pre-calculated automatically based on other properties. - * See the properties section below for detailed information on what you can pass via the `options` object. - * @method create - * @param {object} [options] - * @return {engine} engine - */ - Engine.create = function(element, options) { - // options may be passed as the first (and only) argument - options = Common.isElement(element) ? options : element; - element = Common.isElement(element) ? element : null; - options = options || {}; - - if (element || options.render) { - Common.warn('Engine.create: engine.render is deprecated (see docs)'); - } - - var defaults = { - positionIterations: 6, - velocityIterations: 4, - constraintIterations: 2, - enableSleeping: false, - events: [], - plugin: {}, - timing: { - timestamp: 0, - timeScale: 1 - }, - broadphase: { - controller: Grid - } - }; - - var engine = Common.extend(defaults, options); - - /* - // @deprecated - if (element || engine.render) { - var renderDefaults = { - element: element, - controller: Render - }; - - engine.render = Common.extend(renderDefaults, engine.render); - } - - // @deprecated - if (engine.render && engine.render.controller) { - engine.render = engine.render.controller.create(engine.render); - } - - // @deprecated - if (engine.render) { - engine.render.engine = engine; - } - */ - - engine.world = options.world || World.create(engine.world); - engine.pairs = Pairs.create(); - engine.broadphase = engine.broadphase.controller.create(engine.broadphase); - engine.metrics = engine.metrics || { extended: false }; - - // @if DEBUG - engine.metrics = Metrics.create(engine.metrics); - // @endif - - return engine; - }; - - /** - * Moves the simulation forward in time by `delta` ms. - * The `correction` argument is an optional `Number` that specifies the time correction factor to apply to the update. - * This can help improve the accuracy of the simulation in cases where `delta` is changing between updates. - * The value of `correction` is defined as `delta / lastDelta`, i.e. the percentage change of `delta` over the last step. - * Therefore the value is always `1` (no correction) when `delta` constant (or when no correction is desired, which is the default). - * See the paper on Time Corrected Verlet for more information. - * - * Triggers `beforeUpdate` and `afterUpdate` events. - * Triggers `collisionStart`, `collisionActive` and `collisionEnd` events. - * @method update - * @param {engine} engine - * @param {number} [delta=16.666] - * @param {number} [correction=1] - */ - Engine.update = function(engine, delta, correction) { - delta = delta || 1000 / 60; - correction = correction || 1; - - var world = engine.world, - timing = engine.timing, - broadphase = engine.broadphase, - broadphasePairs = [], - i; - - // increment timestamp - timing.timestamp += delta * timing.timeScale; - - // create an event object - var event = { - timestamp: timing.timestamp - }; - - Events.trigger(engine, 'beforeUpdate', event); - - // get lists of all bodies and constraints, no matter what composites they are in - var allBodies = Composite.allBodies(world), - allConstraints = Composite.allConstraints(world); - - // @if DEBUG - // reset metrics logging - Metrics.reset(engine.metrics); - // @endif - - // if sleeping enabled, call the sleeping controller - if (engine.enableSleeping) - Sleeping.update(allBodies, timing.timeScale); - - // applies gravity to all bodies - _bodiesApplyGravity(allBodies, world.gravity); - - // update all body position and rotation by integration - _bodiesUpdate(allBodies, delta, timing.timeScale, correction, world.bounds); - - // update all constraints (first pass) - Constraint.preSolveAll(allBodies); - for (i = 0; i < engine.constraintIterations; i++) { - Constraint.solveAll(allConstraints, timing.timeScale); - } - Constraint.postSolveAll(allBodies); - - // broadphase pass: find potential collision pairs - if (broadphase.controller) { - // if world is dirty, we must flush the whole grid - if (world.isModified) - broadphase.controller.clear(broadphase); - - // update the grid buckets based on current bodies - broadphase.controller.update(broadphase, allBodies, engine, world.isModified); - broadphasePairs = broadphase.pairsList; - } else { - // if no broadphase set, we just pass all bodies - broadphasePairs = allBodies; - } - - // clear all composite modified flags - if (world.isModified) { - Composite.setModified(world, false, false, true); - } - - // narrowphase pass: find actual collisions, then create or update collision pairs - var collisions = broadphase.detector(broadphasePairs, engine); - - // update collision pairs - var pairs = engine.pairs, - timestamp = timing.timestamp; - Pairs.update(pairs, collisions, timestamp); - Pairs.removeOld(pairs, timestamp); - - // wake up bodies involved in collisions - if (engine.enableSleeping) - Sleeping.afterCollisions(pairs.list, timing.timeScale); - - // trigger collision events - if (pairs.collisionStart.length > 0) - Events.trigger(engine, 'collisionStart', { pairs: pairs.collisionStart }); - - // iteratively resolve position between collisions - Resolver.preSolvePosition(pairs.list); - for (i = 0; i < engine.positionIterations; i++) { - Resolver.solvePosition(pairs.list, allBodies, timing.timeScale); - } - Resolver.postSolvePosition(allBodies); - - // update all constraints (second pass) - Constraint.preSolveAll(allBodies); - for (i = 0; i < engine.constraintIterations; i++) { - Constraint.solveAll(allConstraints, timing.timeScale); - } - Constraint.postSolveAll(allBodies); - - // iteratively resolve velocity between collisions - Resolver.preSolveVelocity(pairs.list); - for (i = 0; i < engine.velocityIterations; i++) { - Resolver.solveVelocity(pairs.list, timing.timeScale); - } - - // trigger collision events - if (pairs.collisionActive.length > 0) - Events.trigger(engine, 'collisionActive', { pairs: pairs.collisionActive }); - - if (pairs.collisionEnd.length > 0) - Events.trigger(engine, 'collisionEnd', { pairs: pairs.collisionEnd }); - - // @if DEBUG - // update metrics log - Metrics.update(engine.metrics, engine); - // @endif - - // clear force buffers - _bodiesClearForces(allBodies); - - Events.trigger(engine, 'afterUpdate', event); - - return engine; - }; - - /** - * Merges two engines by keeping the configuration of `engineA` but replacing the world with the one from `engineB`. - * @method merge - * @param {engine} engineA - * @param {engine} engineB - */ - Engine.merge = function(engineA, engineB) { - Common.extend(engineA, engineB); - - if (engineB.world) { - engineA.world = engineB.world; - - Engine.clear(engineA); - - var bodies = Composite.allBodies(engineA.world); - - for (var i = 0; i < bodies.length; i++) { - var body = bodies[i]; - Sleeping.set(body, false); - body.id = Common.nextId(); - } - } - }; - - /** - * Clears the engine including the world, pairs and broadphase. - * @method clear - * @param {engine} engine - */ - Engine.clear = function(engine) { - var world = engine.world; - - Pairs.clear(engine.pairs); - - var broadphase = engine.broadphase; - if (broadphase.controller) { - var bodies = Composite.allBodies(world); - broadphase.controller.clear(broadphase); - broadphase.controller.update(broadphase, bodies, engine, true); - } - }; - - /** - * Zeroes the `body.force` and `body.torque` force buffers. - * @method bodiesClearForces - * @private - * @param {body[]} bodies - */ - var _bodiesClearForces = function(bodies) { - for (var i = 0; i < bodies.length; i++) { - var body = bodies[i]; - - // reset force buffers - body.force.x = 0; - body.force.y = 0; - body.torque = 0; - } - }; - - /** - * Applys a mass dependant force to all given bodies. - * @method bodiesApplyGravity - * @private - * @param {body[]} bodies - * @param {vector} gravity - */ - var _bodiesApplyGravity = function(bodies, gravity) { - var gravityScale = typeof gravity.scale !== 'undefined' ? gravity.scale : 0.001; - - if ((gravity.x === 0 && gravity.y === 0) || gravityScale === 0) { - return; - } - - for (var i = 0; i < bodies.length; i++) { - var body = bodies[i]; - - if (body.ignoreGravity || body.isStatic || body.isSleeping) - continue; - - // apply gravity - body.force.y += body.mass * gravity.y * gravityScale; - body.force.x += body.mass * gravity.x * gravityScale; - } - }; - - /** - * Applys `Body.update` to all given `bodies`. - * @method updateAll - * @private - * @param {body[]} bodies - * @param {number} deltaTime - * The amount of time elapsed between updates - * @param {number} timeScale - * @param {number} correction - * The Verlet correction factor (deltaTime / lastDeltaTime) - * @param {bounds} worldBounds - */ - var _bodiesUpdate = function(bodies, deltaTime, timeScale, correction, worldBounds) { - for (var i = 0; i < bodies.length; i++) { - var body = bodies[i]; - - if (body.isStatic || body.isSleeping) - continue; - - Body.update(body, deltaTime, timeScale, correction); - } - }; - - /** - * An alias for `Runner.run`, see `Matter.Runner` for more information. - * @method run - * @param {engine} engine - */ - - /** - * Fired just before an update - * - * @event beforeUpdate - * @param {} event An event object - * @param {number} event.timestamp The engine.timing.timestamp of the event - * @param {} event.source The source object of the event - * @param {} event.name The name of the event - */ - - /** - * Fired after engine update and all collision events - * - * @event afterUpdate - * @param {} event An event object - * @param {number} event.timestamp The engine.timing.timestamp of the event - * @param {} event.source The source object of the event - * @param {} event.name The name of the event - */ - - /** - * Fired after engine update, provides a list of all pairs that have started to collide in the current tick (if any) - * - * @event collisionStart - * @param {} event An event object - * @param {} event.pairs List of affected pairs - * @param {number} event.timestamp The engine.timing.timestamp of the event - * @param {} event.source The source object of the event - * @param {} event.name The name of the event - */ - - /** - * Fired after engine update, provides a list of all pairs that are colliding in the current tick (if any) - * - * @event collisionActive - * @param {} event An event object - * @param {} event.pairs List of affected pairs - * @param {number} event.timestamp The engine.timing.timestamp of the event - * @param {} event.source The source object of the event - * @param {} event.name The name of the event - */ - - /** - * Fired after engine update, provides a list of all pairs that have ended collision in the current tick (if any) - * - * @event collisionEnd - * @param {} event An event object - * @param {} event.pairs List of affected pairs - * @param {number} event.timestamp The engine.timing.timestamp of the event - * @param {} event.source The source object of the event - * @param {} event.name The name of the event - */ - - /* - * - * Properties Documentation - * - */ - - /** - * An integer `Number` that specifies the number of position iterations to perform each update. - * The higher the value, the higher quality the simulation will be at the expense of performance. - * - * @property positionIterations - * @type number - * @default 6 - */ - - /** - * An integer `Number` that specifies the number of velocity iterations to perform each update. - * The higher the value, the higher quality the simulation will be at the expense of performance. - * - * @property velocityIterations - * @type number - * @default 4 - */ - - /** - * An integer `Number` that specifies the number of constraint iterations to perform each update. - * The higher the value, the higher quality the simulation will be at the expense of performance. - * The default value of `2` is usually very adequate. - * - * @property constraintIterations - * @type number - * @default 2 - */ - - /** - * A flag that specifies whether the engine should allow sleeping via the `Matter.Sleeping` module. - * Sleeping can improve stability and performance, but often at the expense of accuracy. - * - * @property enableSleeping - * @type boolean - * @default false - */ - - /** - * An `Object` containing properties regarding the timing systems of the engine. - * - * @property timing - * @type object - */ - - /** - * A `Number` that specifies the global scaling factor of time for all bodies. - * A value of `0` freezes the simulation. - * A value of `0.1` gives a slow-motion effect. - * A value of `1.2` gives a speed-up effect. - * - * @property timing.timeScale - * @type number - * @default 1 - */ - - /** - * A `Number` that specifies the current simulation-time in milliseconds starting from `0`. - * It is incremented on every `Engine.update` by the given `delta` argument. - * - * @property timing.timestamp - * @type number - * @default 0 - */ - - /** - * An instance of a `Render` controller. The default value is a `Matter.Render` instance created by `Engine.create`. - * One may also develop a custom renderer module based on `Matter.Render` and pass an instance of it to `Engine.create` via `options.render`. - * - * A minimal custom renderer object must define at least three functions: `create`, `clear` and `world` (see `Matter.Render`). - * It is also possible to instead pass the _module_ reference via `options.render.controller` and `Engine.create` will instantiate one for you. - * - * @property render - * @type render - * @deprecated see Demo.js for an example of creating a renderer - * @default a Matter.Render instance - */ - - /** - * An instance of a broadphase controller. The default value is a `Matter.Grid` instance created by `Engine.create`. - * - * @property broadphase - * @type grid - * @default a Matter.Grid instance - */ - - /** - * A `World` composite object that will contain all simulated bodies and constraints. - * - * @property world - * @type world - * @default a Matter.World instance - */ - - /** - * An object reserved for storing plugin-specific properties. - * - * @property plugin - * @type {} - */ - -})(); - - -/***/ }), -/* 957 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Phaser.Physics.Matter.World - -var Bodies = __webpack_require__(92); -var Class = __webpack_require__(0); -var Composite = __webpack_require__(152); -var Engine = __webpack_require__(956); -var EventEmitter = __webpack_require__(14); -var GetFastValue = __webpack_require__(2); -var GetValue = __webpack_require__(4); -var MatterBody = __webpack_require__(60); -var MatterEvents = __webpack_require__(167); -var MatterWorld = __webpack_require__(866); -var MatterTileBody = __webpack_require__(861); - -/** - * @classdesc - * [description] - * - * @class World - * @extends EventEmitter - * @memberOf Phaser.Physics.Matter - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {object} config - [description] - */ -var World = new Class({ - - Extends: EventEmitter, - - initialize: - - function World (scene, config) - { - EventEmitter.call(this); - - /** - * [description] - * - * @name Phaser.Physics.Matter.World#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.Physics.Matter.World#engine - * @type {[type]} - * @since 3.0.0 - */ - this.engine = Engine.create(config); - - /** - * [description] - * - * @name Phaser.Physics.Matter.World#localWorld - * @type {[type]} - * @since 3.0.0 - */ - this.localWorld = this.engine.world; - - var gravity = GetValue(config, 'gravity', null); - - if (gravity) - { - this.setGravity(gravity.x, gravity.y, gravity.scale); - } - - /** - * An object containing the 4 wall bodies that bound the physics world. - * - * @name Phaser.Physics.Matter.World#walls - * @type {[type]} - * @since 3.0.0 - */ - this.walls = { left: null, right: null, top: null, bottom: null }; - - if (GetFastValue(config, 'setBounds', false)) - { - var boundsConfig = config['setBounds']; - - if (typeof boundsConfig === 'boolean') - { - this.setBounds(); - } - else - { - var x = GetFastValue(boundsConfig, 'x', 0); - var y = GetFastValue(boundsConfig, 'y', 0); - var width = GetFastValue(boundsConfig, 'width', scene.sys.game.config.width); - var height = GetFastValue(boundsConfig, 'height', scene.sys.game.config.height); - var thickness = GetFastValue(boundsConfig, 'thickness', 64); - var left = GetFastValue(boundsConfig, 'left', true); - var right = GetFastValue(boundsConfig, 'right', true); - var top = GetFastValue(boundsConfig, 'top', true); - var bottom = GetFastValue(boundsConfig, 'bottom', true); - - this.setBounds(x, y, width, height, thickness, left, right, top, bottom); - } - } - - /** - * [description] - * - * @name Phaser.Physics.Matter.World#enabled - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.enabled = GetValue(config, 'enabled', true); - - /** - * [description] - * - * @name Phaser.Physics.Matter.World#drawDebug - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.drawDebug = GetValue(config, 'debug', false); - - /** - * [description] - * - * @name Phaser.Physics.Matter.World#debugGraphic - * @type {Phaser.GameObjects.Graphics} - * @since 3.0.0 - */ - this.debugGraphic; - - /** - * [description] - * - * @name Phaser.Physics.Matter.World#defaults - * @type {object} - * @since 3.0.0 - */ - this.defaults = { - debugShowBody: GetValue(config, 'debugShowBody', true), - debugShowStaticBody: GetValue(config, 'debugShowStaticBody', true), - debugShowVelocity: GetValue(config, 'debugShowVelocity', true), - bodyDebugColor: GetValue(config, 'debugBodyColor', 0xff00ff), - staticBodyDebugColor: GetValue(config, 'debugBodyColor', 0x0000ff), - velocityDebugColor: GetValue(config, 'debugVelocityColor', 0x00ff00) - }; - - if (this.drawDebug) - { - this.createDebugGraphic(); - } - - this.setEventsProxy(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.World#setEventsProxy - * @since 3.0.0 - */ - setEventsProxy: function () - { - var _this = this; - var engine = this.engine; - - MatterEvents.on(engine, 'beforeUpdate', function (event) - { - - _this.emit('beforeupdate', event); - - }); - - MatterEvents.on(engine, 'afterUpdate', function (event) - { - - _this.emit('afterupdate', event); - - }); - - MatterEvents.on(engine, 'collisionStart', function (event) - { - - var pairs = event.pairs; - var bodyA; - var bodyB; - - if (pairs.length > 0) - { - bodyA = pairs[0].bodyA; - bodyB = pairs[0].bodyB; - } - - _this.emit('collisionstart', event, bodyA, bodyB); - - }); - - MatterEvents.on(engine, 'collisionActive', function (event) - { - - var pairs = event.pairs; - var bodyA; - var bodyB; - - if (pairs.length > 0) - { - bodyA = pairs[0].bodyA; - bodyB = pairs[0].bodyB; - } - - _this.emit('collisionactive', event, bodyA, bodyB); - - }); - - MatterEvents.on(engine, 'collisionEnd', function (event) - { - - var pairs = event.pairs; - var bodyA; - var bodyB; - - if (pairs.length > 0) - { - bodyA = pairs[0].bodyA; - bodyB = pairs[0].bodyB; - } - - _this.emit('collisionend', event, bodyA, bodyB); - - }); - }, - - /** - * Sets the bounds of the Physics world to match the given world pixel dimensions. - * You can optionally set which 'walls' to create: left, right, top or bottom. - * If none of the walls are given it will default to use the walls settings it had previously. - * I.e. if you previously told it to not have the left or right walls, and you then adjust the world size - * the newly created bounds will also not have the left and right walls. - * Explicitly state them in the parameters to override this. - * - * @method Phaser.Physics.Matter.World#setBounds - * @since 3.0.0 - * - * @param {number} x - The x coordinate of the top-left corner of the bounds. - * @param {number} y - The y coordinate of the top-left corner of the bounds. - * @param {number} width - The width of the bounds. - * @param {number} height - The height of the bounds. - * @param {number} [thickness=128] - The thickness of each wall, in pixels. - * @param {boolean} [left=true] - If true will create the left bounds wall. - * @param {boolean} [right=true] - If true will create the right bounds wall. - * @param {boolean} [top=true] - If true will create the top bounds wall. - * @param {boolean} [bottom=true] - If true will create the bottom bounds wall. - * - * @return {Phaser.Physics.Matter.World} This Matter World object. - */ - setBounds: function (x, y, width, height, thickness, left, right, top, bottom) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (width === undefined) { width = this.scene.sys.game.config.width; } - if (height === undefined) { height = this.scene.sys.game.config.height; } - if (thickness === undefined) { thickness = 128; } - if (left === undefined) { left = true; } - if (right === undefined) { right = true; } - if (top === undefined) { top = true; } - if (bottom === undefined) { bottom = true; } - - this.updateWall(left, 'left', x - thickness, y, thickness, height); - this.updateWall(right, 'right', x + width, y, thickness, height); - this.updateWall(top, 'top', x, y - thickness, width, thickness); - this.updateWall(bottom, 'bottom', x, y + height, width, thickness); - - return this; - }, - - // position = 'left', 'right', 'top' or 'bottom' - /** - * [description] - * - * @method Phaser.Physics.Matter.World#updateWall - * @since 3.0.0 - * - * @param {[type]} add - [description] - * @param {[type]} position - [description] - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} width - [description] - * @param {[type]} height - [description] - */ - updateWall: function (add, position, x, y, width, height) - { - var wall = this.walls[position]; - - if (add) - { - if (wall) - { - MatterWorld.remove(this.localWorld, wall); - } - - // adjust center - x += (width / 2); - y += (height / 2); - - this.walls[position] = this.create(x, y, width, height, { isStatic: true, friction: 0, frictionStatic: 0 }); - } - else - { - if (wall) - { - MatterWorld.remove(this.localWorld, wall); - } - - this.walls[position] = null; - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.World#createDebugGraphic - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} [description] - */ - createDebugGraphic: function () - { - var graphic = this.scene.sys.add.graphics({ x: 0, y: 0 }); - - graphic.setZ(Number.MAX_VALUE); - - this.debugGraphic = graphic; - - this.drawDebug = true; - - return graphic; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.World#disableGravity - * @since 3.0.0 - * - * @return {Phaser.Physics.Matter.World} This Matter World object. - */ - disableGravity: function () - { - this.localWorld.gravity.x = 0; - this.localWorld.gravity.y = 0; - this.localWorld.gravity.scale = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.World#setGravity - * @since 3.0.0 - * - * @param {number} [x=0] - [description] - * @param {number} [y] - [description] - * @param {number} [scale] - [description] - * - * @return {Phaser.Physics.Matter.World} This Matter World object. - */ - setGravity: function (x, y, scale) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 1; } - - this.localWorld.gravity.x = x; - this.localWorld.gravity.y = y; - - if (scale !== undefined) - { - this.localWorld.gravity.scale = scale; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.World#create - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} width - [description] - * @param {[type]} height - [description] - * @param {[type]} options - [description] - * - * @return {[type]} [description] - */ - create: function (x, y, width, height, options) - { - var body = Bodies.rectangle(x, y, width, height, options); - - MatterWorld.add(this.localWorld, body); - - return body; - }, - - // object can be single or an array, and can be a body, composite or constraint - /** - * [description] - * - * @method Phaser.Physics.Matter.World#add - * @since 3.0.0 - * - * @param {[type]} object - [description] - * - * @return {Phaser.Physics.Matter.World} This Matter World object. - */ - add: function (object) - { - MatterWorld.add(this.localWorld, object); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.World#remove - * @since 3.0.0 - * - * @param {[type]} object - [description] - * @param {boolean} deep - [description] - * - * @return {Phaser.Physics.Matter.World} This Matter World object. - */ - remove: function (object, deep) - { - var body = (object.body) ? object.body : object; - - Composite.removeBody(this.localWorld, body, deep); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.World#removeConstraint - * @since 3.0.0 - * - * @param {[type]} constraint - [description] - * @param {boolean} deep - [description] - * - * @return {Phaser.Physics.Matter.World} This Matter World object. - */ - removeConstraint: function (constraint, deep) - { - Composite.remove(this.localWorld, constraint, deep); - - return this; - }, - - /** - * Adds MatterTileBody instances for all the colliding tiles within the given tilemap layer. Set - * the appropriate tiles in your layer to collide before calling this method! - * - * @method Phaser.Physics.Matter.World#convertTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.GameObjects.StaticTilemapLayer|Phaser.GameObjects.DynamicTilemapLayer} tiles - - * An array of tiles. - * @param {object} [options] - Options to be passed to the MatterTileBody constructor. See - * Phaser.Physics.Matter.TileBody. - * - * @return {Phaser.Physics.Matter.World} This Matter World object. - */ - convertTilemapLayer: function (tilemapLayer, options) - { - var layerData = tilemapLayer.layer; - var tiles = tilemapLayer.getTilesWithin(0, 0, layerData.width, layerData.height, {isColliding: true}); - - this.convertTiles(tiles, options); - - return this; - }, - - /** - * Adds MatterTileBody instances for the given tiles. This adds bodies regardless of whether the - * tiles are set to collide or not. - * - * @method Phaser.Physics.Matter.World#convertTiles - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Tile[]} tiles - An array of tiles. - * @param {object} [options] - Options to be passed to the MatterTileBody constructor. See - * Phaser.Physics.Matter.TileBody. - * - * @return {Phaser.Physics.Matter.World} This Matter World object. - */ - convertTiles: function (tiles, options) - { - if (tiles.length === 0) - { - return this; - } - - for (var i = 0; i < tiles.length; i++) - { - new MatterTileBody(this, tiles[i], options); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.World#nextGroup - * @since 3.0.0 - * - * @param {[type]} isNonColliding - [description] - * - * @return {[type]} [description] - */ - nextGroup: function (isNonColliding) - { - return MatterBody.nextGroup(isNonColliding); - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.World#nextCategory - * @since 3.0.0 - * - * @return {[type]} [description] - */ - nextCategory: function () - { - return MatterBody.nextCategory(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.World#pause - * @since 3.0.0 - * - * @return {Phaser.Physics.Matter.World} This Matter World object. - */ - pause: function () - { - this.enabled = false; - - this.emit('pause'); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.World#resume - * @since 3.0.0 - * - * @return {Phaser.Physics.Matter.World} This Matter World object. - */ - resume: function () - { - this.enabled = true; - - this.emit('resume'); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.World#update - * @since 3.0.0 - * - * @param {number} time - [description] - * @param {number} delta - [description] - */ - update: function (time, delta) - { - if (this.enabled) - { - var correction = 1; - - Engine.update(this.engine, delta, correction); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.World#postUpdate - * @since 3.0.0 - */ - postUpdate: function () - { - if (!this.drawDebug) - { - return; - } - - var graphics = this.debugGraphic; - var bodies = Composite.allBodies(this.localWorld); - - graphics.clear(); - graphics.lineStyle(1, this.defaults.bodyDebugColor); - graphics.beginPath(); - - for (var i = 0; i < bodies.length; i++) - { - if (!bodies[i].render.visible) - { - return; - } - - // Handle drawing both single bodies and compound bodies. If compound, draw both the - // convex hull (first part) and the rest of the bodies. - for (var j = 0; j < bodies[i].parts.length; j++) - { - var body = bodies[i].parts[j]; - - var vertices = body.vertices; - - graphics.moveTo(vertices[0].x, vertices[0].y); - - for (var k = 1; k < vertices.length; k++) - { - graphics.lineTo(vertices[k].x, vertices[k].y); - } - - graphics.lineTo(vertices[0].x, vertices[0].y); - - graphics.strokePath(); - } - } - graphics.closePath(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.World#fromPath - * @since 3.0.0 - * - * @param {[type]} path - [description] - * @param {[type]} points - [description] - * - * @return {[type]} [description] - */ - fromPath: function (path, points) - { - if (points === undefined) { points = []; } - - // var pathPattern = /L?\s*([-\d.e]+)[\s,]*([-\d.e]+)*/ig; - - // eslint-disable-next-line no-useless-escape - var pathPattern = /L?\s*([\-\d\.e]+)[\s,]*([\-\d\.e]+)*/ig; - - path.replace(pathPattern, function (match, x, y) - { - points.push({ x: parseFloat(x), y: parseFloat(y) }); - }); - - return points; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.World#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - MatterWorld.clear(this.localWorld, false); - - Engine.clear(this.engine); - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.World#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.shutdown(); - } - -}); - -module.exports = World; - - -/***/ }), -/* 958 */ -/***/ (function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(global) {/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -__webpack_require__(376); - -var CONST = __webpack_require__(19); -var Extend = __webpack_require__(23); - -/** -* @namespace Phaser -*/ - -var Phaser = { - - Actions: __webpack_require__(171), - Animation: __webpack_require__(448), - Cache: __webpack_require__(449), - Cameras: __webpack_require__(450), - Class: __webpack_require__(0), - Create: __webpack_require__(461), - Curves: __webpack_require__(467), - Data: __webpack_require__(470), - Display: __webpack_require__(472), - DOM: __webpack_require__(505), - EventEmitter: __webpack_require__(507), - Game: __webpack_require__(508), - GameObjects: __webpack_require__(544), - Geom: __webpack_require__(294), - Input: __webpack_require__(761), - Loader: __webpack_require__(775), - Math: __webpack_require__(793), - Physics: __webpack_require__(959), - Renderer: __webpack_require__(1000), - Scene: __webpack_require__(253), - Scenes: __webpack_require__(867), - Sound: __webpack_require__(869), - Structs: __webpack_require__(870), - Textures: __webpack_require__(871), - Tilemaps: __webpack_require__(873), - Time: __webpack_require__(922), - Tweens: __webpack_require__(924), - Utils: __webpack_require__(928) - -}; - -// Merge in the consts - -Phaser = Extend(false, Phaser, CONST); - -// Export it - -module.exports = Phaser; - -global.Phaser = Phaser; - -/* - * "Documentation is like sex: when it is good, it is very, very good; - * and when it is bad, it is better than nothing." - * -- Dick Brandon - */ - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(169))) - -/***/ }), -/* 959 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Physics - */ - -module.exports = { - - Arcade: __webpack_require__(836), - Impact: __webpack_require__(960), - Matter: __webpack_require__(980) - -}; - - -/***/ }), -/* 960 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * An Impact.js compatible physics world, body and solver, for those who are used - * to the Impact way of defining and controlling physics bodies. Also works with - * the new Loader support for Weltmeister map data. - * - * World updated to run off the Phaser main loop. - * Body extended to support additional setter functions. - * - * To create the map data you'll need Weltmeister, which comes with Impact - * and can be purchased from http://impactjs.com - * - * My thanks to Dominic Szablewski for his permission to support Impact in Phaser. - * - * @namespace Phaser.Physics.Impact - */ - -module.exports = { - - Body: __webpack_require__(940), - COLLIDES: __webpack_require__(341), - CollisionMap: __webpack_require__(941), - Factory: __webpack_require__(942), - Image: __webpack_require__(944), - ImpactBody: __webpack_require__(943), - ImpactPhysics: __webpack_require__(976), - Sprite: __webpack_require__(945), - TYPE: __webpack_require__(342), - World: __webpack_require__(946) - -}; - - -/***/ }), -/* 961 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clamp = __webpack_require__(61); - -/** - * [description] - * - * @function Phaser.Physics.Impact.GetVelocity - * @since 3.0.0 - * - * @param {number} delta - [description] - * @param {number} vel - [description] - * @param {number} accel - [description] - * @param {number} friction - [description] - * @param {number} max - [description] - * - * @return {number} [description] - */ -var GetVelocity = function (delta, vel, accel, friction, max) -{ - if (accel) - { - return Clamp(vel + accel * delta, -max, max); - } - else if (friction) - { - var frictionDelta = friction * delta; - - if (vel - frictionDelta > 0) - { - return vel - frictionDelta; - } - else if (vel + frictionDelta < 0) - { - return vel + frictionDelta; - } - else - { - return 0; - } - } - - return Clamp(vel, -max, max); -}; - -module.exports = GetVelocity; - - -/***/ }), -/* 962 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Set up the trace-result - * var res = { - * collision: {x: false, y: false, slope: false}, - * pos: {x: x, y: y}, - * tile: {x: 0, y: 0} - * }; - * - * @function Phaser.Physics.Impact.UpdateMotion - * @since 3.0.0 - * - * @param {Phaser.Physics.Impact.Body} body - [description] - * @param {object} res - [description] - */ -var UpdateMotion = function (body, res) -{ - body.standing = false; - - // Y - if (res.collision.y) - { - if (body.bounciness > 0 && Math.abs(body.vel.y) > body.minBounceVelocity) - { - body.vel.y *= -body.bounciness; - } - else - { - if (body.vel.y > 0) - { - body.standing = true; - } - - body.vel.y = 0; - } - } - - // X - if (res.collision.x) - { - if (body.bounciness > 0 && Math.abs(body.vel.x) > body.minBounceVelocity) - { - body.vel.x *= -body.bounciness; - } - else - { - body.vel.x = 0; - } - } - - // SLOPE - if (res.collision.slope) - { - var s = res.collision.slope; - - if (body.bounciness > 0) - { - var proj = body.vel.x * s.nx + body.vel.y * s.ny; - - body.vel.x = (body.vel.x - s.nx * proj * 2) * body.bounciness; - body.vel.y = (body.vel.y - s.ny * proj * 2) * body.bounciness; - } - else - { - var lengthSquared = s.x * s.x + s.y * s.y; - var dot = (body.vel.x * s.x + body.vel.y * s.y) / lengthSquared; - - body.vel.x = s.x * dot; - body.vel.y = s.y * dot; - - var angle = Math.atan2(s.x, s.y); - - if (angle > body.slopeStanding.min && angle < body.slopeStanding.max) - { - body.standing = true; - } - } - } - - body.pos.x = res.pos.x; - body.pos.y = res.pos.y; -}; - -module.exports = UpdateMotion; - - -/***/ }), -/* 963 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var H = 0.5; -var N = 1 / 3; -var M = 2 / 3; - -// Tile ID to Slope defs. -// First 4 elements = line data, final = solid or non-solid behind the line - -module.exports = { - - 2: [ 0, 1, 1, 0, true ], - 3: [ 0, 1, 1, H, true ], - 4: [ 0, H, 1, 0, true ], - 5: [ 0, 1, 1, M, true ], - 6: [ 0, M, 1, N, true ], - 7: [ 0, N, 1, 0, true ], - 8: [ H, 1, 0, 0, true ], - 9: [ 1, 0, H, 1, true ], - 10: [ H, 1, 1, 0, true ], - 11: [ 0, 0, H, 1, true ], - 12: [ 0, 0, 1, 0, false ], - 13: [ 1, 1, 0, 0, true ], - 14: [ 1, H, 0, 0, true ], - 15: [ 1, 1, 0, H, true ], - 16: [ 1, N, 0, 0, true ], - 17: [ 1, M, 0, N, true ], - 18: [ 1, 1, 0, M, true ], - 19: [ 1, 1, H, 0, true ], - 20: [ H, 0, 0, 1, true ], - 21: [ 0, 1, H, 0, true ], - 22: [ H, 0, 1, 1, true ], - 23: [ 1, 1, 0, 1, false ], - 24: [ 0, 0, 1, 1, true ], - 25: [ 0, 0, 1, H, true ], - 26: [ 0, H, 1, 1, true ], - 27: [ 0, 0, 1, N, true ], - 28: [ 0, N, 1, M, true ], - 29: [ 0, M, 1, 1, true ], - 30: [ N, 1, 0, 0, true ], - 31: [ 1, 0, M, 1, true ], - 32: [ M, 1, 1, 0, true ], - 33: [ 0, 0, N, 1, true ], - 34: [ 1, 0, 1, 1, false ], - 35: [ 1, 0, 0, 1, true ], - 36: [ 1, H, 0, 1, true ], - 37: [ 1, 0, 0, H, true ], - 38: [ 1, M, 0, 1, true ], - 39: [ 1, N, 0, M, true ], - 40: [ 1, 0, 0, N, true ], - 41: [ M, 1, N, 0, true ], - 42: [ M, 0, N, 1, true ], - 43: [ N, 1, M, 0, true ], - 44: [ N, 0, M, 1, true ], - 45: [ 0, 1, 0, 0, false ], - 52: [ 1, 1, M, 0, true ], - 53: [ N, 0, 0, 1, true ], - 54: [ 0, 1, N, 0, true ], - 55: [ M, 0, 1, 1, true ] - -}; - - -/***/ }), -/* 964 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Impact.Components.Acceleration - * @since 3.0.0 - */ -var Acceleration = { - - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.Acceleration#setAccelerationX - * @since 3.0.0 - * - * @param {[type]} x - [description] - * - * @return {[type]} [description] - */ - setAccelerationX: function (x) - { - this.accel.x = x; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.Acceleration#setAccelerationY - * @since 3.0.0 - * - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setAccelerationY: function (y) - { - this.accel.y = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.Acceleration#setAcceleration - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setAcceleration: function (x, y) - { - this.accel.x = x; - this.accel.y = y; - - return this; - } - -}; - -module.exports = Acceleration; - - -/***/ }), -/* 965 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Impact.Components.BodyScale - * @since 3.0.0 - */ -var BodyScale = { - - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.BodyScale#setBodySize - * @since 3.0.0 - * - * @param {[type]} width - [description] - * @param {[type]} height - [description] - * - * @return {[type]} [description] - */ - setBodySize: function (width, height) - { - if (height === undefined) { height = width; } - - this.body.size.x = Math.round(width); - this.body.size.y = Math.round(height); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.BodyScale#setBodyScale - * @since 3.0.0 - * - * @param {[type]} scaleX - [description] - * @param {[type]} scaleY - [description] - * - * @return {[type]} [description] - */ - setBodyScale: function (scaleX, scaleY) - { - if (scaleY === undefined) { scaleY = scaleX; } - - var gameObject = this.body.gameObject; - - if (gameObject) - { - gameObject.setScale(scaleX, scaleY); - - return this.setBodySize(gameObject.width * gameObject.scaleX, gameObject.height * gameObject.scaleY); - } - else - { - return this.setBodySize(this.body.size.x * scaleX, this.body.size.y * scaleY); - } - } - -}; - -module.exports = BodyScale; - - -/***/ }), -/* 966 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var TYPE = __webpack_require__(342); - -/** - * [description] - * - * @name Phaser.Physics.Impact.Components.BodyType - * @since 3.0.0 - */ -var BodyType = { - - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.BodyType#getBodyType - * @since 3.0.0 - * - * @return {[type]} [description] - */ - getBodyType: function () - { - return this.body.type; - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.BodyType#setTypeNone - * @since 3.0.0 - * - * @return {[type]} [description] - */ - setTypeNone: function () - { - this.body.type = TYPE.NONE; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.BodyType#setTypeA - * @since 3.0.0 - * - * @return {[type]} [description] - */ - setTypeA: function () - { - this.body.type = TYPE.A; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.BodyType#setTypeB - * @since 3.0.0 - * - * @return {[type]} [description] - */ - setTypeB: function () - { - this.body.type = TYPE.B; - - return this; - } - -}; - -module.exports = BodyType; +module.exports = ImpactSprite; /***/ }), /* 967 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -131393,72 +131959,153 @@ module.exports = BodyType; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var Components = __webpack_require__(469); +var Image = __webpack_require__(72); + /** - * [description] + * @classdesc + * An Impact Physics Image Game Object. + * + * An Image is a light-weight Game Object useful for the display of static images in your game, + * such as logos, backgrounds, scenery or other non-animated elements. Images can have input + * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an + * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. * - * @name Phaser.Physics.Impact.Components.Bounce + * @class ImpactImage + * @extends Phaser.GameObjects.Image + * @memberOf Phaser.Physics.Impact + * @constructor * @since 3.0.0 + * + * @extends Phaser.Physics.Impact.Components.Acceleration + * @extends Phaser.Physics.Impact.Components.BodyScale + * @extends Phaser.Physics.Impact.Components.BodyType + * @extends Phaser.Physics.Impact.Components.Bounce + * @extends Phaser.Physics.Impact.Components.CheckAgainst + * @extends Phaser.Physics.Impact.Components.Collides + * @extends Phaser.Physics.Impact.Components.Debug + * @extends Phaser.Physics.Impact.Components.Friction + * @extends Phaser.Physics.Impact.Components.Gravity + * @extends Phaser.Physics.Impact.Components.Offset + * @extends Phaser.Physics.Impact.Components.SetGameObject + * @extends Phaser.Physics.Impact.Components.Velocity + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Physics.Impact.World} world - [description] + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. */ -var Bounce = { +var ImpactImage = new Class({ - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.Bounce#setBounce - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setBounce: function (value) + Extends: Image, + + Mixins: [ + Components.Acceleration, + Components.BodyScale, + Components.BodyType, + Components.Bounce, + Components.CheckAgainst, + Components.Collides, + Components.Debug, + Components.Friction, + Components.Gravity, + Components.Offset, + Components.SetGameObject, + Components.Velocity + ], + + initialize: + + function ImpactImage (world, x, y, texture, frame) { - this.body.bounciness = value; + Image.call(this, world.scene, x, y, texture, frame); - return this; - }, + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactImage#body + * @type {Phaser.Physics.Impact.Body} + * @since 3.0.0 + */ + this.body = world.create(x - this.frame.centerX, y - this.frame.centerY, this.width, this.height); - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.Bounce#setMinBounceVelocity - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setMinBounceVelocity: function (value) - { - this.body.minBounceVelocity = value; + this.body.parent = this; + this.body.gameObject = this; - return this; - }, + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactImage#size + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.size = this.body.size; - /** - * [description] - * - * @name Phaser.Physics.Impact.Components.Bounce#bounce - * @type {[type]} - * @since 3.0.0 - */ - bounce: { + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactImage#offset + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.offset = this.body.offset; - get: function () - { - return this.body.bounciness; - }, + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactImage#vel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.vel = this.body.vel; - set: function (value) - { - this.body.bounciness = value; - } + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactImage#accel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.accel = this.body.accel; + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactImage#friction + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.friction = this.body.friction; + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactImage#maxVel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.maxVel = this.body.maxVel; } -}; +}); -module.exports = Bounce; +module.exports = ImpactImage; /***/ }), @@ -131471,115 +132118,127 @@ module.exports = Bounce; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var TYPE = __webpack_require__(342); +var Class = __webpack_require__(0); +var Components = __webpack_require__(469); /** + * @classdesc * [description] * - * @name Phaser.Physics.Impact.Components.CheckAgainst + * @class ImpactBody + * @memberOf Phaser.Physics.Impact + * @constructor * @since 3.0.0 + * + * @extends Phaser.Physics.Impact.Components.Acceleration + * @extends Phaser.Physics.Impact.Components.BodyScale + * @extends Phaser.Physics.Impact.Components.BodyType + * @extends Phaser.Physics.Impact.Components.Bounce + * @extends Phaser.Physics.Impact.Components.CheckAgainst + * @extends Phaser.Physics.Impact.Components.Collides + * @extends Phaser.Physics.Impact.Components.Debug + * @extends Phaser.Physics.Impact.Components.Friction + * @extends Phaser.Physics.Impact.Components.Gravity + * @extends Phaser.Physics.Impact.Components.Offset + * @extends Phaser.Physics.Impact.Components.SetGameObject + * @extends Phaser.Physics.Impact.Components.Velocity + * + * @param {Phaser.Physics.Impact.World} world - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] */ -var CheckAgainst = { +var ImpactBody = new Class({ - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.CheckAgainst#setAvsB - * @since 3.0.0 - * - * @return {[type]} [description] - */ - setAvsB: function () + Mixins: [ + Components.Acceleration, + Components.BodyScale, + Components.BodyType, + Components.Bounce, + Components.CheckAgainst, + Components.Collides, + Components.Debug, + Components.Friction, + Components.Gravity, + Components.Offset, + Components.SetGameObject, + Components.Velocity + ], + + initialize: + + function ImpactBody (world, x, y, width, height) { - this.setTypeA(); + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactBody#body + * @type {Phaser.Physics.Impact.Body} + * @since 3.0.0 + */ + this.body = world.create(x, y, width, height); - return this.setCheckAgainstB(); - }, + this.body.parent = this; - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.CheckAgainst#setBvsA - * @since 3.0.0 - * - * @return {[type]} [description] - */ - setBvsA: function () - { - this.setTypeB(); + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactBody#size + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.size = this.body.size; - return this.setCheckAgainstA(); - }, + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactBody#offset + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.offset = this.body.offset; - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.CheckAgainst#setCheckAgainstNone - * @since 3.0.0 - * - * @return {[type]} [description] - */ - setCheckAgainstNone: function () - { - this.body.checkAgainst = TYPE.NONE; + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactBody#vel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.vel = this.body.vel; - return this; - }, + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactBody#accel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.accel = this.body.accel; - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.CheckAgainst#setCheckAgainstA - * @since 3.0.0 - * - * @return {[type]} [description] - */ - setCheckAgainstA: function () - { - this.body.checkAgainst = TYPE.A; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.CheckAgainst#setCheckAgainstB - * @since 3.0.0 - * - * @return {[type]} [description] - */ - setCheckAgainstB: function () - { - this.body.checkAgainst = TYPE.B; - - return this; - }, - - /** - * [description] - * - * @name Phaser.Physics.Impact.Components.CheckAgainst#checkAgainst - * @type {[type]} - * @since 3.0.0 - */ - checkAgainst: { - - get: function () - { - return this.body.checkAgainst; - }, - - set: function (value) - { - this.body.checkAgainst = value; - } + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactBody#friction + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.friction = this.body.friction; + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactBody#maxVel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.maxVel = this.body.maxVel; } -}; +}); -module.exports = CheckAgainst; +module.exports = ImpactBody; /***/ }), @@ -131592,146 +132251,144 @@ module.exports = CheckAgainst; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var COLLIDES = __webpack_require__(341); +var Class = __webpack_require__(0); +var ImpactBody = __webpack_require__(968); +var ImpactImage = __webpack_require__(967); +var ImpactSprite = __webpack_require__(966); /** - * [description] + * @classdesc + * The Impact Physics Factory allows you to easily create Impact Physics enabled Game Objects. + * Objects that are created by this Factory are automatically added to the physics world. * - * @name Phaser.Physics.Impact.Components.Collides + * @class Factory + * @memberOf Phaser.Physics.Impact + * @constructor * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.World} world - [description] */ -var Collides = { +var Factory = new Class({ - _collideCallback: null, - _callbackScope: null, + initialize: - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.Collides#setCollideCallback - * @since 3.0.0 - * - * @param {[type]} callback - [description] - * @param {[type]} scope - [description] - * - * @return {[type]} [description] - */ - setCollideCallback: function (callback, scope) + function Factory (world) { - this._collideCallback = callback; + /** + * [description] + * + * @name Phaser.Physics.Impact.Factory#world + * @type {Phaser.Physics.Impact.World} + * @since 3.0.0 + */ + this.world = world; - if (scope) - { - this._callbackScope = scope; - } - - return this; + /** + * A reference to the Scene.Systems this Impact Physics instance belongs to. + * + * @name Phaser.Physics.Impact.Factory#sys + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.sys = world.scene.sys; }, /** * [description] * - * @method Phaser.Physics.Impact.Components.Collides#setCollidesNever + * @method Phaser.Physics.Impact.Factory#body * @since 3.0.0 * - * @return {[type]} [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.Physics.Impact.ImpactBody} The ImpactBody object that was created. */ - setCollidesNever: function () + body: function (x, y, width, height) { - this.body.collides = COLLIDES.NEVER; + return new ImpactBody(this.world, x, y, width, height); + }, - return this; + /** + * Adds an Impact Physics Body to the given Game Object. + * + * @method Phaser.Physics.Impact.Factory#existing + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * + * @return {Phaser.GameObjects.GameObject} The Game Object. + */ + existing: function (gameObject) + { + var x = gameObject.x - gameObject.frame.centerX; + var y = gameObject.y - gameObject.frame.centerY; + var w = gameObject.width; + var h = gameObject.height; + + gameObject.body = this.world.create(x, y, w, h); + + gameObject.body.parent = gameObject; + gameObject.body.gameObject = gameObject; + + return gameObject; }, /** * [description] * - * @method Phaser.Physics.Impact.Components.Collides#setLite + * @method Phaser.Physics.Impact.Factory#image * @since 3.0.0 * - * @return {[type]} [description] + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Impact.ImpactImage} The ImpactImage object that was created. */ - setLite: function () + image: function (x, y, key, frame) { - this.body.collides = COLLIDES.LITE; + var image = new ImpactImage(this.world, x, y, key, frame); - return this; + this.sys.displayList.add(image); + + return image; }, /** * [description] * - * @method Phaser.Physics.Impact.Components.Collides#setPassive + * @method Phaser.Physics.Impact.Factory#sprite * @since 3.0.0 * - * @return {[type]} [description] + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Impact.ImpactSprite} The ImpactSprite object that was created. */ - setPassive: function () + sprite: function (x, y, key, frame) { - this.body.collides = COLLIDES.PASSIVE; + var sprite = new ImpactSprite(this.world, x, y, key, frame); - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.Collides#setActive - * @since 3.0.0 - * - * @return {[type]} [description] - */ - setActive: function () - { - this.body.collides = COLLIDES.ACTIVE; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.Collides#setFixed - * @since 3.0.0 - * - * @return {[type]} [description] - */ - setFixed: function () - { - this.body.collides = COLLIDES.FIXED; - - return this; - }, - - /** - * [description] - * - * @name Phaser.Physics.Impact.Components.Collides#collides - * @type {[type]} - * @since 3.0.0 - */ - collides: { - - get: function () - { - return this.body.collides; - }, - - set: function (value) - { - this.body.collides = value; - } + this.sys.displayList.add(sprite); + this.sys.updateList.add(sprite); + return sprite; } -}; +}); -module.exports = Collides; +module.exports = Factory; /***/ }), /* 970 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -131739,352 +132396,865 @@ module.exports = Collides; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var DefaultDefs = __webpack_require__(1015); + /** + * @classdesc * [description] * - * @name Phaser.Physics.Impact.Components.Debug + * @class CollisionMap + * @memberOf Phaser.Physics.Impact + * @constructor * @since 3.0.0 - */ -var Debug = { - - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.Debug#setDebug - * @since 3.0.0 - * - * @param {[type]} showBody - [description] - * @param {[type]} showVelocity - [description] - * @param {[type]} bodyColor - [description] - * - * @return {[type]} [description] - */ - setDebug: function (showBody, showVelocity, bodyColor) - { - this.debugShowBody = showBody; - this.debugShowVelocity = showVelocity; - this.debugBodyColor = bodyColor; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.Debug#setDebugBodyColor - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setDebugBodyColor: function (value) - { - this.body.debugBodyColor = value; - - return this; - }, - - /** - * [description] - * - * @name Phaser.Physics.Impact.Components.Debug#debugShowBody - * @type {[type]} - * @since 3.0.0 - */ - debugShowBody: { - - get: function () - { - return this.body.debugShowBody; - }, - - set: function (value) - { - this.body.debugShowBody = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Impact.Components.Debug#debugShowVelocity - * @type {[type]} - * @since 3.0.0 - */ - debugShowVelocity: { - - get: function () - { - return this.body.debugShowVelocity; - }, - - set: function (value) - { - this.body.debugShowVelocity = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Impact.Components.Debug#debugBodyColor - * @type {[type]} - * @since 3.0.0 - */ - debugBodyColor: { - - get: function () - { - return this.body.debugBodyColor; - }, - - set: function (value) - { - this.body.debugBodyColor = value; - } - - } - -}; - -module.exports = Debug; - - -/***/ }), -/* 971 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] * - * @name Phaser.Physics.Impact.Components.Friction - * @since 3.0.0 + * @param {integer} [tilesize=32] - [description] + * @param {array} data - [description] */ -var Friction = { +var CollisionMap = new Class({ - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.Friction#setFrictionX - * @since 3.0.0 - * - * @param {[type]} x - [description] - * - * @return {[type]} [description] - */ - setFrictionX: function (x) + initialize: + + function CollisionMap (tilesize, data) { - this.friction.x = x; + if (tilesize === undefined) { tilesize = 32; } - return this; + /** + * [description] + * + * @name Phaser.Physics.Impact.CollisionMap#tilesize + * @type {integer} + * @default 32 + * @since 3.0.0 + */ + this.tilesize = tilesize; + + /** + * [description] + * + * @name Phaser.Physics.Impact.CollisionMap#data + * @type {array} + * @since 3.0.0 + */ + this.data = (Array.isArray(data)) ? data : []; + + /** + * [description] + * + * @name Phaser.Physics.Impact.CollisionMap#width + * @type {number} + * @since 3.0.0 + */ + this.width = (Array.isArray(data)) ? data[0].length : 0; + + /** + * [description] + * + * @name Phaser.Physics.Impact.CollisionMap#height + * @type {number} + * @since 3.0.0 + */ + this.height = (Array.isArray(data)) ? data.length : 0; + + /** + * [description] + * + * @name Phaser.Physics.Impact.CollisionMap#lastSlope + * @type {integer} + * @default 55 + * @since 3.0.0 + */ + this.lastSlope = 55; + + /** + * [description] + * + * @name Phaser.Physics.Impact.CollisionMap#tiledef + * @type {object} + * @since 3.0.0 + */ + this.tiledef = DefaultDefs; }, /** * [description] * - * @method Phaser.Physics.Impact.Components.Friction#setFrictionY + * @method Phaser.Physics.Impact.CollisionMap#trace * @since 3.0.0 * - * @param {[type]} y - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} vx - [description] + * @param {number} vy - [description] + * @param {number} objectWidth - [description] + * @param {number} objectHeight - [description] * - * @return {[type]} [description] + * @return {boolean} [description] */ - setFrictionY: function (y) + trace: function (x, y, vx, vy, objectWidth, objectHeight) { - this.friction.y = y; + // Set up the trace-result + var res = { + collision: { x: false, y: false, slope: false }, + pos: { x: x + vx, y: y + vy }, + tile: { x: 0, y: 0 } + }; - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.Friction#setFriction - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setFriction: function (x, y) - { - this.friction.x = x; - this.friction.y = y; - - return this; - } - -}; - -module.exports = Friction; - - -/***/ }), -/* 972 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Impact.Components.Gravity - * @since 3.0.0 - */ -var Gravity = { - - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.Gravity#setGravity - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setGravity: function (value) - { - this.body.gravityFactor = value; - - return this; - }, - - /** - * [description] - * - * @name Phaser.Physics.Impact.Components.Gravity#gravity - * @type {[type]} - * @since 3.0.0 - */ - gravity: { - - get: function () + if (!this.data) { - return this.body.gravityFactor; - }, - - set: function (value) - { - this.body.gravityFactor = value; + return res; } + + var steps = Math.ceil(Math.max(Math.abs(vx), Math.abs(vy)) / this.tilesize); - } - -}; - -module.exports = Gravity; - - -/***/ }), -/* 973 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Impact.Components.Offset - * @since 3.0.0 - */ -var Offset = { - - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.Offset#setOffset - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} width - [description] - * @param {[type]} height - [description] - * - * @return {[type]} [description] - */ - setOffset: function (x, y, width, height) - { - this.body.offset.x = x; - this.body.offset.y = y; - - if (width) + if (steps > 1) { - this.setBodySize(width, height); - } - - return this; - } - -}; - -module.exports = Offset; - - -/***/ }), -/* 974 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Impact.Components.SetGameObject - * @since 3.0.0 - */ -var SetGameObject = { - - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.SetGameObject#setGameObject - * @since 3.0.0 - * - * @param {[type]} gameObject - [description] - * @param {[type]} sync - [description] - * - * @return {[type]} [description] - */ - setGameObject: function (gameObject, sync) - { - if (sync === undefined) { sync = true; } - - if (gameObject) - { - this.body.gameObject = gameObject; - - if (sync) + var sx = vx / steps; + var sy = vy / steps; + + for (var i = 0; i < steps && (sx || sy); i++) { - this.syncGameObject(); + this.step(res, x, y, sx, sy, objectWidth, objectHeight, vx, vy, i); + + x = res.pos.x; + y = res.pos.y; + + if (res.collision.x) + { + sx = 0; + vx = 0; + } + + if (res.collision.y) + { + sy = 0; + vy = 0; + } + + if (res.collision.slope) + { + break; + } } } else { - this.body.gameObject = null; + this.step(res, x, y, vx, vy, objectWidth, objectHeight, vx, vy, 0); } + + return res; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.CollisionMap#step + * @since 3.0.0 + * + * @param {object} res - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} vx - [description] + * @param {number} vy - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {number} rvx - [description] + * @param {number} rvy - [description] + * @param {number} step - [description] + */ + step: function (res, x, y, vx, vy, width, height, rvx, rvy, step) + { + var t = 0; + var tileX; + var tileY; + var tilesize = this.tilesize; + var mapWidth = this.width; + var mapHeight = this.height; + + // Horizontal + if (vx) + { + var pxOffsetX = (vx > 0 ? width : 0); + var tileOffsetX = (vx < 0 ? tilesize : 0); + + var firstTileY = Math.max(Math.floor(y / tilesize), 0); + var lastTileY = Math.min(Math.ceil((y + height) / tilesize), mapHeight); + + tileX = Math.floor((res.pos.x + pxOffsetX) / tilesize); + + var prevTileX = Math.floor((x + pxOffsetX) / tilesize); + + if (step > 0 || tileX === prevTileX || prevTileX < 0 || prevTileX >= mapWidth) + { + prevTileX = -1; + } + + if (tileX >= 0 && tileX < mapWidth) + { + for (tileY = firstTileY; tileY < lastTileY; tileY++) + { + if (prevTileX !== -1) + { + t = this.data[tileY][prevTileX]; + + if (t > 1 && t <= this.lastSlope && this.checkDef(res, t, x, y, rvx, rvy, width, height, prevTileX, tileY)) + { + break; + } + } + + t = this.data[tileY][tileX]; + + if (t === 1 || t > this.lastSlope || (t > 1 && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, tileY))) + { + if (t > 1 && t <= this.lastSlope && res.collision.slope) + { + break; + } + + res.collision.x = true; + res.tile.x = t; + res.pos.x = (tileX * tilesize) - pxOffsetX + tileOffsetX; + x = res.pos.x; + rvx = 0; + + break; + } + } + } + } + + // Vertical + if (vy) + { + var pxOffsetY = (vy > 0 ? height : 0); + var tileOffsetY = (vy < 0 ? tilesize : 0); + + var firstTileX = Math.max(Math.floor(res.pos.x / tilesize), 0); + var lastTileX = Math.min(Math.ceil((res.pos.x + width) / tilesize), mapWidth); + + tileY = Math.floor((res.pos.y + pxOffsetY) / tilesize); + + var prevTileY = Math.floor((y + pxOffsetY) / tilesize); + + if (step > 0 || tileY === prevTileY || prevTileY < 0 || prevTileY >= mapHeight) + { + prevTileY = -1; + } + + if (tileY >= 0 && tileY < mapHeight) + { + for (tileX = firstTileX; tileX < lastTileX; tileX++) + { + if (prevTileY !== -1) + { + t = this.data[prevTileY][tileX]; + + if (t > 1 && t <= this.lastSlope && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, prevTileY)) + { + break; + } + } + + t = this.data[tileY][tileX]; + + if (t === 1 || t > this.lastSlope || (t > 1 && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, tileY))) + { + if (t > 1 && t <= this.lastSlope && res.collision.slope) + { + break; + } + + res.collision.y = true; + res.tile.y = t; + res.pos.y = tileY * tilesize - pxOffsetY + tileOffsetY; + + break; + } + } + } + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.CollisionMap#checkDef + * @since 3.0.0 + * + * @param {object} res - [description] + * @param {number} t - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} vx - [description] + * @param {number} vy - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {number} tileX - [description] + * @param {number} tileY - [description] + * + * @return {boolean} [description] + */ + checkDef: function (res, t, x, y, vx, vy, width, height, tileX, tileY) + { + var def = this.tiledef[t]; + + if (!def) + { + return false; + } + + var tilesize = this.tilesize; + + var lx = (tileX + def[0]) * tilesize; + var ly = (tileY + def[1]) * tilesize; + var lvx = (def[2] - def[0]) * tilesize; + var lvy = (def[3] - def[1]) * tilesize; + var solid = def[4]; + + var tx = x + vx + (lvy < 0 ? width : 0) - lx; + var ty = y + vy + (lvx > 0 ? height : 0) - ly; + + if (lvx * ty - lvy * tx > 0) + { + if (vx * -lvy + vy * lvx < 0) + { + return solid; + } + + var length = Math.sqrt(lvx * lvx + lvy * lvy); + var nx = lvy / length; + var ny = -lvx / length; + + var proj = tx * nx + ty * ny; + var px = nx * proj; + var py = ny * proj; + + if (px * px + py * py >= vx * vx + vy * vy) + { + return solid || (lvx * (ty - vy) - lvy * (tx - vx) < 0.5); + } + + res.pos.x = x + vx - px; + res.pos.y = y + vy - py; + res.collision.slope = { x: lvx, y: lvy, nx: nx, ny: ny }; + + return true; + } + + return false; + } + +}); + +module.exports = CollisionMap; + + +/***/ }), +/* 971 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var COLLIDES = __webpack_require__(200); +var GetVelocity = __webpack_require__(1017); +var TYPE = __webpack_require__(199); +var UpdateMotion = __webpack_require__(1016); + +/** + * @callback BodyUpdateCallback + * + * @param {Phaser.Physics.Impact.Body} body - [description] + */ + +/** + * @typedef {object} JSONImpactBody + * @todo Replace object types + * + * @property {string} name - [description] + * @property {object} size - [description] + * @property {object} pos - [description] + * @property {object} vel - [description] + * @property {object} accel - [description] + * @property {object} friction - [description] + * @property {object} maxVel - [description] + * @property {number} gravityFactor - [description] + * @property {number} bounciness - [description] + * @property {number} minBounceVelocity - [description] + * @property {Phaser.Physics.Impact.TYPE} type - [description] + * @property {Phaser.Physics.Impact.TYPE} checkAgainst - [description] + * @property {Phaser.Physics.Impact.COLLIDES} collides - [description] + */ + +/** + * @classdesc + * An Impact.js compatible physics body. + * This re-creates the properties you'd get on an Entity and the math needed to update them. + * + * @class Body + * @memberOf Phaser.Physics.Impact + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.World} world - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} [sx=16] - [description] + * @param {number} [sy=16] - [description] + */ +var Body = new Class({ + + initialize: + + function Body (world, x, y, sx, sy) + { + if (sx === undefined) { sx = 16; } + if (sy === undefined) { sy = sx; } + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#world + * @type {Phaser.Physics.Impact.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#gameObject + * @type {Phaser.GameObjects.GameObject} + * @default null + * @since 3.0.0 + */ + this.gameObject = null; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#enabled + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.enabled = true; + + /** + * The ImpactBody, ImpactSprite or ImpactImage object that owns this Body, if any. + * + * @name Phaser.Physics.Impact.Body#parent + * @type {?(Phaser.Physics.Impact.ImpactBody|Phaser.Physics.Impact.ImpactImage|Phaser.Physics.Impact.ImpactSprite)} + * @since 3.0.0 + */ + this.parent; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#id + * @type {integer} + * @since 3.0.0 + */ + this.id = world.getNextID(); + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#size + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.size = { x: sx, y: sy }; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#offset + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.offset = { x: 0, y: 0 }; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#pos + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.pos = { x: x, y: y }; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#last + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.last = { x: x, y: y }; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#vel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.vel = { x: 0, y: 0 }; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#accel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.accel = { x: 0, y: 0 }; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#friction + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.friction = { x: 0, y: 0 }; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#maxVel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.maxVel = { x: world.defaults.maxVelocityX, y: world.defaults.maxVelocityY }; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#standing + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.standing = false; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#gravityFactor + * @type {number} + * @since 3.0.0 + */ + this.gravityFactor = world.defaults.gravityFactor; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#bounciness + * @type {number} + * @since 3.0.0 + */ + this.bounciness = world.defaults.bounciness; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#minBounceVelocity + * @type {number} + * @since 3.0.0 + */ + this.minBounceVelocity = world.defaults.minBounceVelocity; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#accelGround + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accelGround = 0; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#accelAir + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accelAir = 0; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#jumpSpeed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.jumpSpeed = 0; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#type + * @type {Phaser.Physics.Impact.TYPE} + * @since 3.0.0 + */ + this.type = TYPE.NONE; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#checkAgainst + * @type {Phaser.Physics.Impact.TYPE} + * @since 3.0.0 + */ + this.checkAgainst = TYPE.NONE; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#collides + * @type {Phaser.Physics.Impact.COLLIDES} + * @since 3.0.0 + */ + this.collides = COLLIDES.NEVER; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#debugShowBody + * @type {boolean} + * @since 3.0.0 + */ + this.debugShowBody = world.defaults.debugShowBody; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#debugShowVelocity + * @type {boolean} + * @since 3.0.0 + */ + this.debugShowVelocity = world.defaults.debugShowVelocity; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#debugBodyColor + * @type {integer} + * @since 3.0.0 + */ + this.debugBodyColor = world.defaults.bodyDebugColor; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#updateCallback + * @type {?BodyUpdateCallback} + * @since 3.0.0 + */ + this.updateCallback; + + /** + * min 44 deg, max 136 deg + * + * @name Phaser.Physics.Impact.Body#slopeStanding + * @type {{ min: number, max: number }} + * @since 3.0.0 + */ + this.slopeStanding = { min: 0.767944870877505, max: 2.3736477827122884 }; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Body#reset + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + */ + reset: function (x, y) + { + this.pos = { x: x, y: y }; + this.last = { x: x, y: y }; + this.vel = { x: 0, y: 0 }; + this.accel = { x: 0, y: 0 }; + this.friction = { x: 0, y: 0 }; + this.maxVel = { x: 100, y: 100 }; + + this.standing = false; + + this.gravityFactor = 1; + this.bounciness = 0; + this.minBounceVelocity = 40; + + this.accelGround = 0; + this.accelAir = 0; + this.jumpSpeed = 0; + + this.type = TYPE.NONE; + this.checkAgainst = TYPE.NONE; + this.collides = COLLIDES.NEVER; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Body#update + * @since 3.0.0 + * + * @param {number} delta - [description] + */ + update: function (delta) + { + var pos = this.pos; + + this.last.x = pos.x; + this.last.y = pos.y; + + this.vel.y += this.world.gravity * delta * this.gravityFactor; + + this.vel.x = GetVelocity(delta, this.vel.x, this.accel.x, this.friction.x, this.maxVel.x); + this.vel.y = GetVelocity(delta, this.vel.y, this.accel.y, this.friction.y, this.maxVel.y); + + var mx = this.vel.x * delta; + var my = this.vel.y * delta; + + var res = this.world.collisionMap.trace(pos.x, pos.y, mx, my, this.size.x, this.size.y); + + if (this.handleMovementTrace(res)) + { + UpdateMotion(this, res); + } + + var go = this.gameObject; + + if (go) + { + go.x = (pos.x - this.offset.x) + go.displayOriginX * go.scaleX; + go.y = (pos.y - this.offset.y) + go.displayOriginY * go.scaleY; + } + + if (this.updateCallback) + { + this.updateCallback(this); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Body#drawDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphic - [description] + */ + drawDebug: function (graphic) + { + var pos = this.pos; + + if (this.debugShowBody) + { + graphic.lineStyle(1, this.debugBodyColor, 1); + graphic.strokeRect(pos.x, pos.y, this.size.x, this.size.y); + } + + if (this.debugShowVelocity) + { + var x = pos.x + this.size.x / 2; + var y = pos.y + this.size.y / 2; + + graphic.lineStyle(1, this.world.defaults.velocityDebugColor, 1); + graphic.lineBetween(x, y, x + this.vel.x, y + this.vel.y); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Body#willDrawDebug + * @since 3.0.0 + * + * @return {boolean} [description] + */ + willDrawDebug: function () + { + return (this.debugShowBody || this.debugShowVelocity); + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Body#skipHash + * @since 3.0.0 + * + * @return {boolean} [description] + */ + skipHash: function () + { + return (!this.enabled || (this.type === 0 && this.checkAgainst === 0 && this.collides === 0)); + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Body#touches + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body} other - [description] + * + * @return {boolean} [description] + */ + touches: function (other) + { + return !( + this.pos.x >= other.pos.x + other.size.x || + this.pos.x + this.size.x <= other.pos.x || + this.pos.y >= other.pos.y + other.size.y || + this.pos.y + this.size.y <= other.pos.y + ); + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Body#resetSize + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.Physics.Impact.Body} This Body object. + */ + resetSize: function (x, y, width, height) + { + this.pos.x = x; + this.pos.y = y; + this.size.x = width; + this.size.y = height; return this; }, @@ -132092,31 +133262,117 @@ var SetGameObject = { /** * [description] * - * @method Phaser.Physics.Impact.Components.SetGameObject#syncGameObject + * @method Phaser.Physics.Impact.Body#toJSON * @since 3.0.0 * - * @return {[type]} [description] + * @return {JSONImpactBody} [description] */ - syncGameObject: function () + toJSON: function () { - var gameObject = this.body.gameObject; + var output = { + name: this.name, + size: { x: this.size.x, y: this.size.y }, + pos: { x: this.pos.x, y: this.pos.y }, + vel: { x: this.vel.x, y: this.vel.y }, + accel: { x: this.accel.x, y: this.accel.y }, + friction: { x: this.friction.x, y: this.friction.y }, + maxVel: { x: this.maxVel.x, y: this.maxVel.y }, + gravityFactor: this.gravityFactor, + bounciness: this.bounciness, + minBounceVelocity: this.minBounceVelocity, + type: this.type, + checkAgainst: this.checkAgainst, + collides: this.collides + }; - if (gameObject) + return output; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Body#fromJSON + * @todo Code it! + * @since 3.0.0 + * + * @param {object} config - [description] + */ + fromJSON: function () + { + }, + + /** + * Can be overridden by user code + * + * @method Phaser.Physics.Impact.Body#check + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body} other - [description] + */ + check: function () + { + }, + + /** + * Can be overridden by user code + * + * @method Phaser.Physics.Impact.Body#collideWith + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body} other - [description] + * @param {string} axis - [description] + */ + collideWith: function (other, axis) + { + if (this.parent && this.parent._collideCallback) { - this.setBodySize(gameObject.width * gameObject.scaleX, gameObject.height * gameObject.scaleY); + this.parent._collideCallback.call(this.parent._callbackScope, this, other, axis); } + }, - return this; + /** + * Can be overridden by user code but must return a boolean. + * + * @method Phaser.Physics.Impact.Body#handleMovementTrace + * @since 3.0.0 + * + * @param {number} res - [description] + * + * @return {boolean} [description] + */ + handleMovementTrace: function () + { + return true; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Body#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.world.remove(this); + + this.enabled = false; + + this.world = null; + + this.gameObject = null; + + this.parent = null; } -}; +}); -module.exports = SetGameObject; +module.exports = Body; /***/ }), -/* 975 */ -/***/ (function(module, exports) { +/* 972 */, +/* 973 */ +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -132125,92 +133381,76 @@ module.exports = SetGameObject; */ /** - * [description] - * - * @name Phaser.Physics.Impact.Components.Velocity - * @since 3.0.0 + * @namespace Phaser.Renderer.WebGL.Pipelines */ -var Velocity = { - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.Velocity#setVelocityX - * @since 3.0.0 - * - * @param {[type]} x - [description] - * - * @return {[type]} [description] - */ - setVelocityX: function (x) - { - this.vel.x = x; +module.exports = { - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.Velocity#setVelocityY - * @since 3.0.0 - * - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setVelocityY: function (y) - { - this.vel.y = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.Velocity#setVelocity - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setVelocity: function (x, y) - { - if (y === undefined) { y = x; } - - this.vel.x = x; - this.vel.y = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.Components.Velocity#setMaxVelocity - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setMaxVelocity: function (x, y) - { - if (y === undefined) { y = x; } - - this.maxVel.x = x; - this.maxVel.y = y; - - return this; - } + BitmapMaskPipeline: __webpack_require__(373), + FlatTintPipeline: __webpack_require__(372), + ForwardDiffuseLightPipeline: __webpack_require__(173), + TextureTintPipeline: __webpack_require__(172) }; -module.exports = Velocity; + +/***/ }), +/* 974 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Renderer.WebGL + */ + +module.exports = { + + Utils: __webpack_require__(44), + WebGLPipeline: __webpack_require__(108), + WebGLRenderer: __webpack_require__(375), + Pipelines: __webpack_require__(973), + + // Constants + BYTE: 0, + SHORT: 1, + UNSIGNED_BYTE: 2, + UNSIGNED_SHORT: 3, + FLOAT: 4 + +}; + + +/***/ }), +/* 975 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @callback SnapshotCallback + * + * @param {HTMLImageElement} snapshot - [description] + */ + +/** + * @namespace Phaser.Renderer.Snapshot + */ + +module.exports = { + + Canvas: __webpack_require__(378), + WebGL: __webpack_require__(374) + +}; /***/ }), @@ -132223,173 +133463,18 @@ module.exports = Velocity; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Factory = __webpack_require__(942); -var GetFastValue = __webpack_require__(2); -var Merge = __webpack_require__(104); -var PluginManager = __webpack_require__(12); -var World = __webpack_require__(946); - /** - * @classdesc - * [description] - * - * @class ImpactPhysics - * @memberOf Phaser.Physics.Impact - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] + * @namespace Phaser.Renderer.Canvas */ -var ImpactPhysics = new Class({ - initialize: +module.exports = { - function ImpactPhysics (scene) - { - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactPhysics#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; + CanvasRenderer: __webpack_require__(380), + BlitImage: __webpack_require__(379), + DrawImage: __webpack_require__(377), + GetBlendModes: __webpack_require__(376) - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactPhysics#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - if (!scene.sys.settings.isBooted) - { - scene.sys.events.once('boot', this.boot, this); - } - - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactPhysics#config - * @type {object} - * @since 3.0.0 - */ - this.config = this.getConfig(); - - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactPhysics#world - * @type {Phaser.Physics.Impact.World} - * @since 3.0.0 - */ - this.world; - - /** - * [description] - * - * @name Phaser.Physics.Impact.ImpactPhysics#add - * @type {Phaser.Physics.Impact.Factory} - * @since 3.0.0 - */ - this.add; - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.ImpactPhysics#getConfig - * @since 3.0.0 - * - * @return {object} [description] - */ - getConfig: function () - { - var gameConfig = this.systems.game.config.physics; - var sceneConfig = this.systems.settings.physics; - - var config = Merge( - GetFastValue(sceneConfig, 'impact', {}), - GetFastValue(gameConfig, 'impact', {}) - ); - - return config; - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.ImpactPhysics#boot - * @since 3.0.0 - */ - boot: function () - { - this.world = new World(this.scene, this.config); - this.add = new Factory(this.world); - - var eventEmitter = this.systems.events; - - eventEmitter.on('update', this.world.update, this.world); - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.ImpactPhysics#pause - * @since 3.0.0 - * - * @return {Phaser.Physics.Impact.World} The Impact World object. - */ - pause: function () - { - return this.world.pause(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.ImpactPhysics#resume - * @since 3.0.0 - * - * @return {Phaser.Physics.Impact.World} The Impact World object. - */ - resume: function () - { - return this.world.resume(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.ImpactPhysics#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this.world.shutdown(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Impact.ImpactPhysics#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.world.destroy(); - } - -}); - -PluginManager.register('ImpactPhysics', ImpactPhysics, 'impactPhysics'); - -module.exports = ImpactPhysics; +}; /***/ }), @@ -132402,209 +133487,352 @@ module.exports = ImpactPhysics; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var COLLIDES = __webpack_require__(341); -var SeperateX = __webpack_require__(978); -var SeperateY = __webpack_require__(979); +/** + * @typedef {object} RendererConfig + * + * @property {boolean} clearBeforeRender - [description] + * @property {boolean} pixelArt - [description] + * @property {Phaser.Display.Color} backgroundColor - [description] + * @property {number} resolution - [description] + * @property {boolean} autoResize - [description] + * @property {boolean} roundPixels - [description] + */ /** - * Impact Physics Solver - * - * @function Phaser.Physics.Impact.Solver - * @since 3.0.0 - * - * @param {Phaser.Physics.Impact.World} world - [description] - * @param {Phaser.Physics.Impact.Body} bodyA - [description] - * @param {Phaser.Physics.Impact.Body} bodyB - [description] + * @namespace Phaser.Renderer */ -var Solver = function (world, bodyA, bodyB) -{ - var weak = null; - if (bodyA.collides === COLLIDES.LITE || bodyB.collides === COLLIDES.FIXED) - { - weak = bodyA; - } - else if (bodyB.collides === COLLIDES.LITE || bodyA.collides === COLLIDES.FIXED) - { - weak = bodyB; - } +module.exports = { - if (bodyA.last.x + bodyA.size.x > bodyB.last.x && bodyA.last.x < bodyB.last.x + bodyB.size.x) - { - if (bodyA.last.y < bodyB.last.y) - { - SeperateY(world, bodyA, bodyB, weak); - } - else - { - SeperateY(world, bodyB, bodyA, weak); - } + Canvas: __webpack_require__(976), + Snapshot: __webpack_require__(975), + WebGL: __webpack_require__(974) - bodyA.collideWith(bodyB, 'y'); - bodyB.collideWith(bodyA, 'y'); - - world.emit('collide', bodyA, bodyB, 'y'); - } - else if (bodyA.last.y + bodyA.size.y > bodyB.last.y && bodyA.last.y < bodyB.last.y + bodyB.size.y) - { - if (bodyA.last.x < bodyB.last.x) - { - SeperateX(world, bodyA, bodyB, weak); - } - else - { - SeperateX(world, bodyB, bodyA, weak); - } - - bodyA.collideWith(bodyB, 'x'); - bodyB.collideWith(bodyA, 'x'); - - world.emit('collide', bodyA, bodyB, 'x'); - } }; -module.exports = Solver; - /***/ }), /* 978 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { + +var Matter = __webpack_require__(464); /** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + * A coordinate wrapping plugin for matter.js. + * See the readme for usage and examples. + * @module MatterWrap */ +var MatterWrap = { + // plugin meta + name: 'matter-wrap', // PLUGIN_NAME + version: '0.1.4', // PLUGIN_VERSION + for: 'matter-js@^0.13.1', + silent: true, // no console log please -/** - * [description] - * - * @function Phaser.Physics.Impact.SeperateX - * @since 3.0.0 - * - * @param {Phaser.Physics.Impact.World} world - [description] - * @param {Phaser.Physics.Impact.Body} left - [description] - * @param {Phaser.Physics.Impact.Body} right - [description] - * @param {Phaser.Physics.Impact.Body} [weak] - [description] - */ -var SeperateX = function (world, left, right, weak) -{ - var nudge = left.pos.x + left.size.x - right.pos.x; - - // We have a weak entity, so just move this one - if (weak) - { - var strong = (left === weak) ? right : left; + // installs the plugin where `base` is `Matter` + // you should not need to call this directly. + install: function(base) { + base.after('Engine.update', function() { + MatterWrap.Engine.update(this); + }); + }, - weak.vel.x = -weak.vel.x * weak.bounciness + strong.vel.x; - - var resWeak = world.collisionMap.trace(weak.pos.x, weak.pos.y, weak === left ? -nudge : nudge, 0, weak.size.x, weak.size.y); + Engine: { + /** + * Updates the engine by wrapping bodies and composites inside `engine.world`. + * This is called automatically by the plugin. + * @function MatterWrap.Engine.update + * @param {Matter.Engine} engine The engine to update. + * @returns {void} No return value. + */ + update: function(engine) { + var world = engine.world, + bodies = Matter.Composite.allBodies(world), + composites = Matter.Composite.allComposites(world); - weak.pos.x = resWeak.pos.x; + for (var i = 0; i < bodies.length; i += 1) { + var body = bodies[i]; + + if (body.plugin.wrap) { + MatterWrap.Body.wrap(body, body.plugin.wrap); + } + } + + for (i = 0; i < composites.length; i += 1) { + var composite = composites[i]; + + if (composite.plugin.wrap) { + MatterWrap.Composite.wrap(composite, composite.plugin.wrap); + } + } } - else - { - var v2 = (left.vel.x - right.vel.x) / 2; + }, - left.vel.x = -v2; - right.vel.x = v2; - - var resLeft = world.collisionMap.trace(left.pos.x, left.pos.y, -nudge / 2, 0, left.size.x, left.size.y); + Bounds: { + /** + * Returns a translation vector that wraps the `objectBounds` inside the `bounds`. + * @function MatterWrap.Bounds.wrap + * @param {Matter.Bounds} objectBounds The bounds of the object to wrap inside the bounds. + * @param {Matter.Bounds} bounds The bounds to wrap the body inside. + * @returns {?Matter.Vector} A translation vector (only if wrapping is required). + */ + wrap: function(objectBounds, bounds) { + var x = null, + y = null; - left.pos.x = Math.floor(resLeft.pos.x); - - var resRight = world.collisionMap.trace(right.pos.x, right.pos.y, nudge / 2, 0, right.size.x, right.size.y); + if (typeof bounds.min.x !== 'undefined' && typeof bounds.max.x !== 'undefined') { + if (objectBounds.min.x > bounds.max.x) { + x = bounds.min.x - objectBounds.max.x; + } else if (objectBounds.max.x < bounds.min.x) { + x = bounds.max.x - objectBounds.min.x; + } + } - right.pos.x = Math.ceil(resRight.pos.x); + if (typeof bounds.min.y !== 'undefined' && typeof bounds.max.y !== 'undefined') { + if (objectBounds.min.y > bounds.max.y) { + y = bounds.min.y - objectBounds.max.y; + } else if (objectBounds.max.y < bounds.min.y) { + y = bounds.max.y - objectBounds.min.y; + } + } + + if (x !== null || y !== null) { + return { + x: x || 0, + y: y || 0 + }; + } } + }, + + Body: { + /** + * Wraps the `body` position such that it always stays within the given bounds. + * Upon crossing a boundary the body will appear on the opposite side of the bounds, + * while maintaining its velocity. + * This is called automatically by the plugin. + * @function MatterWrap.Body.wrap + * @param {Matter.Body} body The body to wrap. + * @param {Matter.Bounds} bounds The bounds to wrap the body inside. + * @returns {?Matter.Vector} The translation vector that was applied (only if wrapping was required). + */ + wrap: function(body, bounds) { + var translation = MatterWrap.Bounds.wrap(body.bounds, bounds); + + if (translation) { + Matter.Body.translate(body, translation); + } + + return translation; + } + }, + + Composite: { + /** + * Returns the union of the bounds of all of the composite's bodies + * (not accounting for constraints). + * @function MatterWrap.Composite.bounds + * @param {Matter.Composite} composite The composite. + * @returns {Matter.Bounds} The composite bounds. + */ + bounds: function(composite) { + var bodies = Matter.Composite.allBodies(composite), + vertices = []; + + for (var i = 0; i < bodies.length; i += 1) { + var body = bodies[i]; + vertices.push(body.bounds.min, body.bounds.max); + } + + return Matter.Bounds.create(vertices); + }, + + /** + * Wraps the `composite` position such that it always stays within the given bounds. + * Upon crossing a boundary the composite will appear on the opposite side of the bounds, + * while maintaining its velocity. + * This is called automatically by the plugin. + * @function MatterWrap.Composite.wrap + * @param {Matter.Composite} composite The composite to wrap. + * @param {Matter.Bounds} bounds The bounds to wrap the composite inside. + * @returns {?Matter.Vector} The translation vector that was applied (only if wrapping was required). + */ + wrap: function(composite, bounds) { + var translation = MatterWrap.Bounds.wrap( + MatterWrap.Composite.bounds(composite), + bounds + ); + + if (translation) { + Matter.Composite.translate(composite, translation); + } + + return translation; + } + } }; -module.exports = SeperateX; +module.exports = MatterWrap; +/** + * @namespace Matter.Body + * @see http://brm.io/matter-js/docs/classes/Body.html + */ + +/** + * This plugin adds a new property `body.plugin.wrap` to instances of `Matter.Body`. + * This is a `Matter.Bounds` instance that specifies the wrapping region. + * @property {Matter.Bounds} body.plugin.wrap + * @memberof Matter.Body + */ + +/** + * This plugin adds a new property `composite.plugin.wrap` to instances of `Matter.Composite`. + * This is a `Matter.Bounds` instance that specifies the wrapping region. + * @property {Matter.Bounds} composite.plugin.wrap + * @memberof Matter.Composite + */ /***/ }), /* 979 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { + +var Matter = __webpack_require__(464); /** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + * An attractors plugin for matter.js. + * See the readme for usage and examples. + * @module MatterAttractors */ +var MatterAttractors = { + // plugin meta + name: 'matter-attractors', // PLUGIN_NAME + version: '0.1.7', // PLUGIN_VERSION + for: 'matter-js@^0.13.1', + silent: true, // no console log please -/** - * [description] - * - * @function Phaser.Physics.Impact.SeperateY - * @since 3.0.0 - * - * @param {Phaser.Physics.Impact.World} world - [description] - * @param {Phaser.Physics.Impact.Body} top - [description] - * @param {Phaser.Physics.Impact.Body} bottom - [description] - * @param {Phaser.Physics.Impact.Body} [weak] - [description] - */ -var SeperateY = function (world, top, bottom, weak) -{ - var nudge = (top.pos.y + top.size.y - bottom.pos.y); - var nudgeX; - var resTop; - - if (weak) - { - var strong = (top === weak) ? bottom : top; + // installs the plugin where `base` is `Matter` + // you should not need to call this directly. + install: function(base) { + base.after('Body.create', function() { + MatterAttractors.Body.init(this); + }); - weak.vel.y = -weak.vel.y * weak.bounciness + strong.vel.y; - - // Riding on a platform? - nudgeX = 0; + base.before('Engine.update', function(engine) { + MatterAttractors.Engine.update(engine); + }); + }, - if (weak === top && Math.abs(weak.vel.y - strong.vel.y) < weak.minBounceVelocity) - { - weak.standing = true; - nudgeX = strong.vel.x * world.delta; - } - - var resWeak = world.collisionMap.trace(weak.pos.x, weak.pos.y, nudgeX, weak === top ? -nudge : nudge, weak.size.x, weak.size.y); - - weak.pos.y = resWeak.pos.y; - weak.pos.x = resWeak.pos.x; + Body: { + /** + * Initialises the `body` to support attractors. + * This is called automatically by the plugin. + * @function MatterAttractors.Body.init + * @param {Matter.Body} body The body to init. + * @returns {void} No return value. + */ + init: function(body) { + body.plugin.attractors = body.plugin.attractors || []; } - else if (world.gravity && (bottom.standing || top.vel.y > 0)) - { - resTop = world.collisionMap.trace(top.pos.x, top.pos.y, 0, -(top.pos.y + top.size.y - bottom.pos.y), top.size.x, top.size.y); + }, - top.pos.y = resTop.pos.y; - - if (top.bounciness > 0 && top.vel.y > top.minBounceVelocity) - { - top.vel.y *= -top.bounciness; - } - else - { - top.standing = true; - top.vel.y = 0; + Engine: { + /** + * Applies all attractors for all bodies in the `engine`. + * This is called automatically by the plugin. + * @function MatterAttractors.Engine.update + * @param {Matter.Engine} engine The engine to update. + * @returns {void} No return value. + */ + update: function(engine) { + var world = engine.world, + bodies = Matter.Composite.allBodies(world); + + for (var i = 0; i < bodies.length; i += 1) { + var bodyA = bodies[i], + attractors = bodyA.plugin.attractors; + + if (attractors && attractors.length > 0) { + for (var j = i + 1; j < bodies.length; j += 1) { + var bodyB = bodies[j]; + + for (var k = 0; k < attractors.length; k += 1) { + var attractor = attractors[k], + forceVector = attractor; + + if (Matter.Common.isFunction(attractor)) { + forceVector = attractor(bodyA, bodyB); + } + + if (forceVector) { + Matter.Body.applyForce(bodyB, bodyB.position, forceVector); + } + } + } } + } } - else - { - var v2 = (top.vel.y - bottom.vel.y) / 2; + }, - top.vel.y = -v2; - bottom.vel.y = v2; - - nudgeX = bottom.vel.x * world.delta; + /** + * Defines some useful common attractor functions that can be used + * by pushing them to your body's `body.plugin.attractors` array. + * @namespace MatterAttractors.Attractors + * @property {number} gravityConstant The gravitational constant used by the gravity attractor. + */ + Attractors: { + gravityConstant: 0.001, - resTop = world.collisionMap.trace(top.pos.x, top.pos.y, nudgeX, -nudge / 2, top.size.x, top.size.y); + /** + * An attractor function that applies Newton's law of gravitation. + * Use this by pushing `MatterAttractors.Attractors.gravity` to your body's `body.plugin.attractors` array. + * The gravitational constant defaults to `0.001` which you can change + * at `MatterAttractors.Attractors.gravityConstant`. + * @function MatterAttractors.Attractors.gravity + * @param {Matter.Body} bodyA The first body. + * @param {Matter.Body} bodyB The second body. + * @returns {void} No return value. + */ + gravity: function(bodyA, bodyB) { + // use Newton's law of gravitation + var bToA = Matter.Vector.sub(bodyB.position, bodyA.position), + distanceSq = Matter.Vector.magnitudeSquared(bToA) || 0.0001, + normal = Matter.Vector.normalise(bToA), + magnitude = -MatterAttractors.Attractors.gravityConstant * (bodyA.mass * bodyB.mass / distanceSq), + force = Matter.Vector.mult(normal, magnitude); - top.pos.y = resTop.pos.y; - - var resBottom = world.collisionMap.trace(bottom.pos.x, bottom.pos.y, 0, nudge / 2, bottom.size.x, bottom.size.y); - - bottom.pos.y = resBottom.pos.y; + // to apply forces to both bodies + Matter.Body.applyForce(bodyA, bodyA.position, Matter.Vector.neg(force)); + Matter.Body.applyForce(bodyB, bodyB.position, force); } + } }; -module.exports = SeperateY; +module.exports = MatterAttractors; + +/** + * @namespace Matter.Body + * @see http://brm.io/matter-js/docs/classes/Body.html + */ + +/** + * This plugin adds a new property `body.plugin.attractors` to instances of `Matter.Body`. + * This is an array of callback functions that will be called automatically + * for every pair of bodies, on every engine update. + * @property {Function[]} body.plugin.attractors + * @memberof Matter.Body + */ + +/** + * An attractor function calculates the force to be applied + * to `bodyB`, it should either: + * - return the force vector to be applied to `bodyB` + * - or apply the force to the body(s) itself + * @callback AttractorFunction + * @param {Matter.Body} bodyA + * @param {Matter.Body} bodyB + * @returns {(Vector|undefined)} a force vector (optional) + */ /***/ }), @@ -132617,2078 +133845,17 @@ module.exports = SeperateY; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -/** - * @namespace Phaser.Physics.Matter - */ - -module.exports = { - - Factory: __webpack_require__(947), - Image: __webpack_require__(950), - Matter: __webpack_require__(864), - MatterPhysics: __webpack_require__(997), - PolyDecomp: __webpack_require__(948), - Sprite: __webpack_require__(951), - TileBody: __webpack_require__(861), - World: __webpack_require__(957) - -}; - - -/***/ }), -/* 981 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Matter.Components.Bounce - * @since 3.0.0 - */ -var Bounce = { - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Bounce#setBounce - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setBounce: function (value) - { - this.body.restitution = value; - - return this; - } - -}; - -module.exports = Bounce; - - -/***/ }), -/* 982 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Matter.Components.Collision - * @since 3.0.0 - */ -var Collision = { - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Collision#setCollisionCategory - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setCollisionCategory: function (value) - { - this.body.collisionFilter.category = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Collision#setCollisionGroup - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setCollisionGroup: function (value) - { - this.body.collisionFilter.group = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Collision#setCollidesWith - * @since 3.0.0 - * - * @param {[type]} categories - [description] - * - * @return {[type]} [description] - */ - setCollidesWith: function (categories) - { - var flags = 0; - - if (!Array.isArray(categories)) - { - flags = categories; - } - else - { - for (var i = 0; i < categories.length; i++) - { - flags |= categories[i]; - } - } - - this.body.collisionFilter.mask = flags; - - return this; - } - -}; - -module.exports = Collision; - - -/***/ }), -/* 983 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Body = __webpack_require__(60); - -/** - * [description] - * - * @name Phaser.Physics.Matter.Components.Force - * @since 3.0.0 - */ -var Force = { - - // force = vec2 / point - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Force#applyForce - * @since 3.0.0 - * - * @param {[type]} force - [description] - * - * @return {[type]} [description] - */ - applyForce: function (force) - { - this._tempVec2.set(this.body.position.x, this.body.position.y); - - Body.applyForce(this.body, this._tempVec2, force); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Force#applyForceFrom - * @since 3.0.0 - * - * @param {[type]} position - [description] - * @param {[type]} force - [description] - * - * @return {[type]} [description] - */ - applyForceFrom: function (position, force) - { - Body.applyForce(this.body, position, force); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Force#thrust - * @since 3.0.0 - * - * @param {[type]} speed - [description] - * - * @return {[type]} [description] - */ - thrust: function (speed) - { - var angle = this.body.angle; - - this._tempVec2.set(speed * Math.cos(angle), speed * Math.sin(angle)); - - Body.applyForce(this.body, { x: this.body.position.x, y: this.body.position.y }, this._tempVec2); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Force#thrustLeft - * @since 3.0.0 - * - * @param {[type]} speed - [description] - * - * @return {[type]} [description] - */ - thrustLeft: function (speed) - { - var angle = this.body.angle - Math.PI / 2; - - this._tempVec2.set(speed * Math.cos(angle), speed * Math.sin(angle)); - - Body.applyForce(this.body, { x: this.body.position.x, y: this.body.position.y }, this._tempVec2); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Force#thrustRight - * @since 3.0.0 - * - * @param {[type]} speed - [description] - * - * @return {[type]} [description] - */ - thrustRight: function (speed) - { - var angle = this.body.angle + Math.PI / 2; - - this._tempVec2.set(speed * Math.cos(angle), speed * Math.sin(angle)); - - Body.applyForce(this.body, { x: this.body.position.x, y: this.body.position.y }, this._tempVec2); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Force#thrustBack - * @since 3.0.0 - * - * @param {[type]} speed - [description] - * - * @return {[type]} [description] - */ - thrustBack: function (speed) - { - var angle = this.body.angle - Math.PI; - - this._tempVec2.set(speed * Math.cos(angle), speed * Math.sin(angle)); - - Body.applyForce(this.body, { x: this.body.position.x, y: this.body.position.y }, this._tempVec2); - - return this; - } - -}; - -module.exports = Force; - - -/***/ }), -/* 984 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Matter.Components.Friction - * @since 3.0.0 - */ -var Friction = { - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Friction#setFriction - * @since 3.0.0 - * - * @param {[type]} value - [description] - * @param {[type]} air - [description] - * @param {[type]} fstatic - [description] - * - * @return {[type]} [description] - */ - setFriction: function (value, air, fstatic) - { - this.body.friction = value; - - if (air !== undefined) - { - this.body.frictionAir = air; - } - - if (fstatic !== undefined) - { - this.body.frictionStatic = fstatic; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Friction#setFrictionAir - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setFrictionAir: function (value) - { - this.body.frictionAir = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Friction#setFrictionStatic - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setFrictionStatic: function (value) - { - this.body.frictionStatic = value; - - return this; - } - -}; - -module.exports = Friction; - - -/***/ }), -/* 985 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Matter.Components.Gravity - * @since 3.0.0 - */ -var Gravity = { - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Gravity#setIgnoreGravity - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setIgnoreGravity: function (value) - { - this.body.ignoreGravity = value; - - return this; - } - -}; - -module.exports = Gravity; - - -/***/ }), -/* 986 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Body = __webpack_require__(60); - -/** - * [description] - * - * @name Phaser.Physics.Matter.Components.Mass - * @since 3.0.0 - */ -var Mass = { - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Mass#setMass - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setMass: function (value) - { - Body.setMass(this.body, value); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Mass#setDensity - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setDensity: function (value) - { - Body.setDensity(this.body, value); - - return this; - } - -}; - -module.exports = Mass; - - -/***/ }), -/* 987 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Body = __webpack_require__(60); - -/** - * [description] - * - * @name Phaser.Physics.Matter.Components.Static - * @since 3.0.0 - */ -var Static = { - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Static#setStatic - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setStatic: function (value) - { - Body.setStatic(this.body, value); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Static#isStatic - * @since 3.0.0 - * - * @return {[type]} [description] - */ - isStatic: function () - { - return this.body.isStatic; - } - -}; - -module.exports = Static; - - -/***/ }), -/* 988 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Matter.Components.Sensor - * @since 3.0.0 - */ -var Sensor = { - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Sensor#setSensor - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setSensor: function (value) - { - this.body.isSensor = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Sensor#isSensor - * @since 3.0.0 - * - * @return {[type]} [description] - */ - isSensor: function () - { - return this.body.isSensor; - } - -}; - -module.exports = Sensor; - - -/***/ }), -/* 989 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Bodies = __webpack_require__(92); -var Body = __webpack_require__(60); -var GetFastValue = __webpack_require__(2); - -/** - * [description] - * - * @name Phaser.Physics.Matter.Components.SetBody - * @since 3.0.0 - */ -var SetBody = { - - // Calling any of these methods resets previous properties you may have set on the body, including plugins, mass, etc - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.SetBody#setRectangle - * @since 3.0.0 - * - * @param {[type]} width - [description] - * @param {[type]} height - [description] - * @param {[type]} options - [description] - * - * @return {[type]} [description] - */ - setRectangle: function (width, height, options) - { - return this.setBody({ type: 'rectangle', width: width, height: height }, options); - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.SetBody#setCircle - * @since 3.0.0 - * - * @param {[type]} radius - [description] - * @param {[type]} options - [description] - * - * @return {[type]} [description] - */ - setCircle: function (radius, options) - { - return this.setBody({ type: 'circle', radius: radius }, options); - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.SetBody#setPolygon - * @since 3.0.0 - * - * @param {[type]} radius - [description] - * @param {[type]} sides - [description] - * @param {[type]} options - [description] - * - * @return {[type]} [description] - */ - setPolygon: function (radius, sides, options) - { - return this.setBody({ type: 'polygon', sides: sides, radius: radius }, options); - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.SetBody#setTrapezoid - * @since 3.0.0 - * - * @param {[type]} width - [description] - * @param {[type]} height - [description] - * @param {[type]} slope - [description] - * @param {[type]} options - [description] - * - * @return {[type]} [description] - */ - setTrapezoid: function (width, height, slope, options) - { - return this.setBody({ type: 'trapezoid', width: width, height: height, slope: slope }, options); - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.SetBody#setExistingBody - * @since 3.0.0 - * - * @param {[type]} body - [description] - * @param {[type]} addToWorld - [description] - * - * @return {[type]} [description] - */ - setExistingBody: function (body, addToWorld) - { - if (addToWorld === undefined) - { - addToWorld = true; - } - - if (this.body) - { - this.world.remove(this.body); - } - - this.body = body; - this.body.gameObject = this; - - var _this = this; - - this.body.destroy = function () - { - _this.world.remove(_this.body); - _this.body.gameObject = null; - }; - - if (addToWorld) - { - this.world.add(this.body); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.SetBody#setBody - * @since 3.0.0 - * - * @param {[type]} config - [description] - * @param {[type]} options - [description] - * - * @return {[type]} [description] - */ - setBody: function (config, options) - { - if (!config) - { - return this; - } - - var body; - - // Allow them to do: shape: 'circle' instead of shape: { type: 'circle' } - if (typeof config === 'string') - { - // Using defaults - config = { type: config }; - } - - var shapeType = GetFastValue(config, 'type', 'rectangle'); - var bodyX = GetFastValue(config, 'x', this._tempVec2.x); - var bodyY = GetFastValue(config, 'y', this._tempVec2.y); - var bodyWidth = GetFastValue(config, 'width', this.width); - var bodyHeight = GetFastValue(config, 'height', this.height); - - switch (shapeType) - { - case 'rectangle': - body = Bodies.rectangle(bodyX, bodyY, bodyWidth, bodyHeight, options); - break; - - case 'circle': - var radius = GetFastValue(config, 'radius', Math.max(bodyWidth, bodyHeight) / 2); - var maxSides = GetFastValue(config, 'maxSides', 25); - body = Bodies.circle(bodyX, bodyY, radius, options, maxSides); - break; - - case 'trapezoid': - var slope = GetFastValue(config, 'slope', 0.5); - body = Bodies.trapezoid(bodyX, bodyY, bodyWidth, bodyHeight, slope, options); - break; - - case 'polygon': - var sides = GetFastValue(config, 'sides', 5); - var pradius = GetFastValue(config, 'radius', Math.max(bodyWidth, bodyHeight) / 2); - body = Bodies.polygon(bodyX, bodyY, sides, pradius, options); - break; - - case 'fromVertices': - case 'fromVerts': - var verts = GetFastValue(config, 'verts', []); - - if (this.body) - { - Body.setVertices(this.body, verts); - body = this.body; - } - else - { - var flagInternal = GetFastValue(config, 'flagInternal', false); - var removeCollinear = GetFastValue(config, 'removeCollinear', 0.01); - var minimumArea = GetFastValue(config, 'minimumArea', 10); - body = Bodies.fromVertices(bodyX, bodyY, verts, options, flagInternal, removeCollinear, minimumArea); - } - break; - } - - this.setExistingBody(body, config.addToWorld); - - return this; - } - -}; - -module.exports = SetBody; - - -/***/ }), -/* 990 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MatterEvents = __webpack_require__(167); - -/** - * [description] - * - * @name Phaser.Physics.Matter.Components.Sleep - * @since 3.0.0 - */ -var Sleep = { - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Sleep#setSleepThreshold - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setSleepThreshold: function (value) - { - if (value === undefined) { value = 60; } - - this.body.sleepThreshold = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Sleep#setSleepEvents - * @since 3.0.0 - * - * @param {[type]} start - [description] - * @param {[type]} end - [description] - * - * @return {[type]} [description] - */ - setSleepEvents: function (start, end) - { - this.setSleepStartEvent(start); - this.setSleepEndEvent(end); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Sleep#setSleepStartEvent - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setSleepStartEvent: function (value) - { - if (value) - { - var world = this.world; - - MatterEvents.on(this.body, 'sleepStart', function (event) - { - world.emit('sleepstart', event, this); - }); - } - else - { - MatterEvents.off(this.body, 'sleepStart'); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Sleep#setSleepEndEvent - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setSleepEndEvent: function (value) - { - if (value) - { - var world = this.world; - - MatterEvents.on(this.body, 'sleepEnd', function (event) - { - world.emit('sleepend', event, this); - }); - } - else - { - MatterEvents.off(this.body, 'sleepEnd'); - } - - return this; - } - -}; - -module.exports = Sleep; - - -/***/ }), -/* 991 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Body = __webpack_require__(60); -var MATH_CONST = __webpack_require__(16); -var WrapAngle = __webpack_require__(163); -var WrapAngleDegrees = __webpack_require__(164); - -// global bitmask flag for GameObject.renderMask (used by Scale) -var _FLAG = 4; // 0100 - -// Transform Component - -/** - * [description] - * - * @name Phaser.Physics.Matter.Components.Transform - * @since 3.0.0 - */ -var Transform = { - - /** - * [description] - * - * @name Phaser.Physics.Matter.Components.Transform#x - * @type {[type]} - * @since 3.0.0 - */ - x: { - - get: function () - { - return this.body.position.x; - }, - - set: function (value) - { - this._tempVec2.set(value, this.y); - - Body.setPosition(this.body, this._tempVec2); - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Matter.Components.Transform#y - * @type {[type]} - * @since 3.0.0 - */ - y: { - - get: function () - { - return this.body.position.y; - }, - - set: function (value) - { - this._tempVec2.set(this.x, value); - - Body.setPosition(this.body, this._tempVec2); - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Matter.Components.Transform#scaleX - * @type {[type]} - * @since 3.0.0 - */ - scaleX: { - - get: function () - { - return this._scaleX; - }, - - set: function (value) - { - this._scaleX = value; - - if (this._scaleX === 0) - { - this.renderFlags &= ~_FLAG; - } - else - { - this.renderFlags |= _FLAG; - } - - Body.scale(this.body, value, this._scaleY); - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Matter.Components.Transform#scaleY - * @type {[type]} - * @since 3.0.0 - */ - scaleY: { - - get: function () - { - return this._scaleY; - }, - - set: function (value) - { - this._scaleY = value; - - if (this._scaleY === 0) - { - this.renderFlags &= ~_FLAG; - } - else - { - this.renderFlags |= _FLAG; - } - - Body.scale(this.body, this._scaleX, value); - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Matter.Components.Transform#angle - * @type {[type]} - * @since 3.0.0 - */ - angle: { - - get: function () - { - return WrapAngleDegrees(this.body.angle * MATH_CONST.RAD_TO_DEG); - }, - - set: function (value) - { - // value is in degrees - this.rotation = WrapAngleDegrees(value) * MATH_CONST.DEG_TO_RAD; - } - }, - - /** - * [description] - * - * @name Phaser.Physics.Matter.Components.Transform#rotation - * @type {[type]} - * @since 3.0.0 - */ - rotation: { - - get: function () - { - return this.body.angle; - }, - - set: function (value) - { - // value is in radians - this._rotation = WrapAngle(value); - - Body.setAngle(this.body, this._rotation); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Transform#setPosition - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setPosition: function (x, y) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = x; } - - this._tempVec2.set(x, y); - - Body.setPosition(this.body, this._tempVec2); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Transform#setRotation - * @since 3.0.0 - * - * @param {[type]} radians - [description] - * - * @return {[type]} [description] - */ - setRotation: function (radians) - { - if (radians === undefined) { radians = 0; } - - this._rotation = WrapAngle(radians); - - Body.setAngle(this.body, radians); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Transform#setFixedRotation - * @since 3.0.0 - * - * @return {[type]} [description] - */ - setFixedRotation: function () - { - Body.setInertia(this.body, Infinity); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Transform#setAngle - * @since 3.0.0 - * - * @param {[type]} degrees - [description] - * - * @return {[type]} [description] - */ - setAngle: function (degrees) - { - if (degrees === undefined) { degrees = 0; } - - this.angle = degrees; - - Body.setAngle(this.body, this.rotation); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Transform#setScale - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * @param {[type]} point - [description] - * - * @return {[type]} [description] - */ - setScale: function (x, y, point) - { - if (x === undefined) { x = 1; } - if (y === undefined) { y = x; } - - this._scaleX = x; - this._scaleY = y; - - Body.scale(this.body, x, y, point); - - return this; - } - -}; - -module.exports = Transform; - - -/***/ }), -/* 992 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Body = __webpack_require__(60); - -/** - * [description] - * - * @name Phaser.Physics.Matter.Components.Velocity - * @since 3.0.0 - */ -var Velocity = { - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Velocity#setAngularVelocity - * @since 3.0.0 - * - * @param {[type]} value - [description] - * - * @return {[type]} [description] - */ - setAngularVelocity: function (value) - { - Body.setAngularVelocity(this.body, value); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Velocity#setVelocityX - * @since 3.0.0 - * - * @param {[type]} x - [description] - * - * @return {[type]} [description] - */ - setVelocityX: function (x) - { - this._tempVec2.set(x, this.body.velocity.y); - - Body.setVelocity(this.body, this._tempVec2); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Velocity#setVelocityY - * @since 3.0.0 - * - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setVelocityY: function (y) - { - this._tempVec2.set(this.body.velocity.x, y); - - Body.setVelocity(this.body, this._tempVec2); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.Components.Velocity#setVelocity - * @since 3.0.0 - * - * @param {[type]} x - [description] - * @param {[type]} y - [description] - * - * @return {[type]} [description] - */ - setVelocity: function (x, y) - { - this._tempVec2.set(x, y); - - Body.setVelocity(this.body, this._tempVec2); - - return this; - } - -}; - -module.exports = Velocity; - - -/***/ }), -/* 993 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Bounds = __webpack_require__(95); var Class = __webpack_require__(0); -var Composite = __webpack_require__(152); -var Constraint = __webpack_require__(168); -var Detector = __webpack_require__(862); +var Factory = __webpack_require__(964); var GetFastValue = __webpack_require__(2); -var Merge = __webpack_require__(104); -var Sleeping = __webpack_require__(343); -var Vector2 = __webpack_require__(6); -var Vertices = __webpack_require__(93); - -/** - * @classdesc - * [description] - * - * @class PointerConstraint - * @memberOf Phaser.Physics.Matter - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.Physics.Matter.World} world - [description] - * @param {object} options - [description] - */ -var PointerConstraint = new Class({ - - initialize: - - function PointerConstraint (scene, world, options) - { - if (options === undefined) { options = {}; } - - // Defaults - var defaults = { - label: 'Pointer Constraint', - pointA: { x: 0, y: 0 }, - pointB: { x: 0, y: 0 }, - damping: 0, - length: 0.01, - stiffness: 0.1, - angularStiffness: 1, - collisionFilter: { - category: 0x0001, - mask: 0xFFFFFFFF, - group: 0 - } - }; - - /** - * [description] - * - * @name Phaser.Physics.Matter.PointerConstraint#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.Physics.Matter.PointerConstraint#world - * @type {Phaser.Physics.Matter.World} - * @since 3.0.0 - */ - this.world = world; - - /** - * [description] - * - * @name Phaser.Physics.Matter.PointerConstraint#camera - * @type {Phaser.Cameras.Scene2D.Camera} - * @since 3.0.0 - */ - var camera = GetFastValue(options, 'camera', null); - - if (!camera) - { - this.camera = scene.sys.cameras.main; - } - else - { - this.camera = camera; - - delete options.camera; - } - - /** - * [description] - * - * @name Phaser.Physics.Matter.PointerConstraint#pointer - * @type {Phaser.Input.Pointer} - * @default null - * @since 3.0.0 - */ - this.pointer = null; - - /** - * [description] - * - * @name Phaser.Physics.Matter.PointerConstraint#active - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.active = true; - - /** - * The transformed position. - * - * @name Phaser.Physics.Matter.PointerConstraint#position - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.position = new Vector2(); - - /** - * [description] - * - * @name Phaser.Physics.Matter.PointerConstraint#constraint - * @type {object} - * @since 3.0.0 - */ - this.constraint = Constraint.create(Merge(options, defaults)); - - this.world.on('beforeupdate', this.update, this); - - scene.sys.input.on('pointerdown', this.onDown, this); - - scene.sys.input.on('pointerup', this.onUp, this); - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.PointerConstraint#onDown - * @since 3.0.0 - * - * @param {Phaser.Input.Pointer} pointer - [description] - */ - onDown: function (pointer) - { - this.pointer = pointer; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.PointerConstraint#onUp - * @since 3.0.0 - */ - onUp: function () - { - this.pointer = null; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.PointerConstraint#getBodyPart - * @since 3.0.0 - * - * @param {[type]} body - [description] - * @param {[type]} position - [description] - * - * @return {boolean} [description] - */ - getBodyPart: function (body, position) - { - var constraint = this.constraint; - - var start = (body.parts.length > 1) ? 1 : 0; - - for (var i = start; i < body.parts.length; i++) - { - var part = body.parts[i]; - - if (Vertices.contains(part.vertices, position)) - { - constraint.bodyB = body; - - constraint.pointA.x = position.x; - constraint.pointA.y = position.y; - - constraint.pointB.x = position.x - body.position.x; - constraint.pointB.y = position.y - body.position.y; - - constraint.angleB = body.angle; - - Sleeping.set(body, false); - - return true; - } - } - - return false; - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.PointerConstraint#update - * @since 3.0.0 - */ - update: function () - { - if (!this.active) - { - return; - } - - var pointer = this.pointer; - var constraint = this.constraint; - - if (!pointer) - { - // Pointer is up / released - if (constraint.bodyB) - { - constraint.bodyB = null; - } - } - else - { - var pos = this.position; - - this.camera.getWorldPoint(pointer.x, pointer.y, pos); - - if (constraint.bodyB) - { - // Pointer is down and we have bodyB, so wake it up - Sleeping.set(constraint.bodyB, false); - - constraint.pointA.x = pos.x; - constraint.pointA.y = pos.y; - } - else - { - var bodies = Composite.allBodies(this.world.localWorld); - - // Pointer is down and no bodyB, so check if we've hit anything - for (var i = 0; i < bodies.length; i++) - { - var body = bodies[i]; - - if (!body.ignorePointer && Bounds.contains(body.bounds, pos) && - Detector.canCollide(body.collisionFilter, constraint.collisionFilter)) - { - if (this.getBodyPart(body, pos)) - { - break; - } - } - } - } - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Matter.PointerConstraint#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.world.removeConstraint(this.constraint); - - this.constraint = null; - - this.world.off('beforeupdate', this.update); - - this.scene.sys.input.off('pointerdown', this.onDown, this); - - this.scene.sys.input.off('pointerup', this.onUp, this); - } - -}); - -module.exports = PointerConstraint; - - -/***/ }), -/* 994 */ -/***/ (function(module, exports, __webpack_require__) { - -/** -* The `Matter.Query` module contains methods for performing collision queries. -* -* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). -* -* @class Query -*/ - -var Query = {}; - -module.exports = Query; - -var Vector = __webpack_require__(94); -var SAT = __webpack_require__(863); -var Bounds = __webpack_require__(95); -var Bodies = __webpack_require__(92); -var Vertices = __webpack_require__(93); - -(function() { - - /** - * Casts a ray segment against a set of bodies and returns all collisions, ray width is optional. Intersection points are not provided. - * @method ray - * @param {body[]} bodies - * @param {vector} startPoint - * @param {vector} endPoint - * @param {number} [rayWidth] - * @return {object[]} Collisions - */ - Query.ray = function(bodies, startPoint, endPoint, rayWidth) { - rayWidth = rayWidth || 1e-100; - - var rayAngle = Vector.angle(startPoint, endPoint), - rayLength = Vector.magnitude(Vector.sub(startPoint, endPoint)), - rayX = (endPoint.x + startPoint.x) * 0.5, - rayY = (endPoint.y + startPoint.y) * 0.5, - ray = Bodies.rectangle(rayX, rayY, rayLength, rayWidth, { angle: rayAngle }), - collisions = []; - - for (var i = 0; i < bodies.length; i++) { - var bodyA = bodies[i]; - - if (Bounds.overlaps(bodyA.bounds, ray.bounds)) { - for (var j = bodyA.parts.length === 1 ? 0 : 1; j < bodyA.parts.length; j++) { - var part = bodyA.parts[j]; - - if (Bounds.overlaps(part.bounds, ray.bounds)) { - var collision = SAT.collides(part, ray); - if (collision.collided) { - collision.body = collision.bodyA = collision.bodyB = bodyA; - collisions.push(collision); - break; - } - } - } - } - } - - return collisions; - }; - - /** - * Returns all bodies whose bounds are inside (or outside if set) the given set of bounds, from the given set of bodies. - * @method region - * @param {body[]} bodies - * @param {bounds} bounds - * @param {bool} [outside=false] - * @return {body[]} The bodies matching the query - */ - Query.region = function(bodies, bounds, outside) { - var result = []; - - for (var i = 0; i < bodies.length; i++) { - var body = bodies[i], - overlaps = Bounds.overlaps(body.bounds, bounds); - if ((overlaps && !outside) || (!overlaps && outside)) - result.push(body); - } - - return result; - }; - - /** - * Returns all bodies whose vertices contain the given point, from the given set of bodies. - * @method point - * @param {body[]} bodies - * @param {vector} point - * @return {body[]} The bodies matching the query - */ - Query.point = function(bodies, point) { - var result = []; - - for (var i = 0; i < bodies.length; i++) { - var body = bodies[i]; - - if (Bounds.contains(body.bounds, point)) { - for (var j = body.parts.length === 1 ? 0 : 1; j < body.parts.length; j++) { - var part = body.parts[j]; - - if (Bounds.contains(part.bounds, point) - && Vertices.contains(part.vertices, point)) { - result.push(body); - break; - } - } - } - } - - return result; - }; - -})(); - - -/***/ }), -/* 995 */ -/***/ (function(module, exports, __webpack_require__) { - -// @if DEBUG -/** -* _Internal Class_, not generally used outside of the engine's internals. -* -*/ - -var Metrics = {}; - -module.exports = Metrics; - -var Composite = __webpack_require__(152); -var Common = __webpack_require__(38); - -(function() { - - /** - * Creates a new metrics. - * @method create - * @private - * @return {metrics} A new metrics - */ - Metrics.create = function(options) { - var defaults = { - extended: false, - narrowDetections: 0, - narrowphaseTests: 0, - narrowReuse: 0, - narrowReuseCount: 0, - midphaseTests: 0, - broadphaseTests: 0, - narrowEff: 0.0001, - midEff: 0.0001, - broadEff: 0.0001, - collisions: 0, - buckets: 0, - bodies: 0, - pairs: 0 - }; - - return Common.extend(defaults, false, options); - }; - - /** - * Resets metrics. - * @method reset - * @private - * @param {metrics} metrics - */ - Metrics.reset = function(metrics) { - if (metrics.extended) { - metrics.narrowDetections = 0; - metrics.narrowphaseTests = 0; - metrics.narrowReuse = 0; - metrics.narrowReuseCount = 0; - metrics.midphaseTests = 0; - metrics.broadphaseTests = 0; - metrics.narrowEff = 0; - metrics.midEff = 0; - metrics.broadEff = 0; - metrics.collisions = 0; - metrics.buckets = 0; - metrics.pairs = 0; - metrics.bodies = 0; - } - }; - - /** - * Updates metrics. - * @method update - * @private - * @param {metrics} metrics - * @param {engine} engine - */ - Metrics.update = function(metrics, engine) { - if (metrics.extended) { - var world = engine.world, - bodies = Composite.allBodies(world); - - metrics.collisions = metrics.narrowDetections; - metrics.pairs = engine.pairs.list.length; - metrics.bodies = bodies.length; - metrics.midEff = (metrics.narrowDetections / (metrics.midphaseTests || 1)).toFixed(2); - metrics.narrowEff = (metrics.narrowDetections / (metrics.narrowphaseTests || 1)).toFixed(2); - metrics.broadEff = (1 - (metrics.broadphaseTests / (bodies.length || 1))).toFixed(2); - metrics.narrowReuse = (metrics.narrowReuseCount / (metrics.narrowphaseTests || 1)).toFixed(2); - //var broadphase = engine.broadphase[engine.broadphase.current]; - //if (broadphase.instance) - // metrics.buckets = Common.keys(broadphase.instance.buckets).length; - } - }; - -})(); -// @endif - - -/***/ }), -/* 996 */ -/***/ (function(module, exports, __webpack_require__) { - -/** -* The `Matter.Svg` module contains methods for converting SVG images into an array of vector points. -* -* To use this module you also need the SVGPathSeg polyfill: https://github.com/progers/pathseg -* -* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). -* -* @class Svg -*/ - -var Svg = {}; - -module.exports = Svg; - -var Bounds = __webpack_require__(95); - -(function() { - - /** - * Converts an SVG path into an array of vector points. - * If the input path forms a concave shape, you must decompose the result into convex parts before use. - * See `Bodies.fromVertices` which provides support for this. - * Note that this function is not guaranteed to support complex paths (such as those with holes). - * @method pathToVertices - * @param {SVGPathElement} path - * @param {Number} [sampleLength=15] - * @return {Vector[]} points - */ - Svg.pathToVertices = function(path, sampleLength) { - // https://github.com/wout/svg.topoly.js/blob/master/svg.topoly.js - var i, il, total, point, segment, segments, - segmentsQueue, lastSegment, - lastPoint, segmentIndex, points = [], - lx, ly, length = 0, x = 0, y = 0; - - sampleLength = sampleLength || 15; - - var addPoint = function(px, py, pathSegType) { - // all odd-numbered path types are relative except PATHSEG_CLOSEPATH (1) - var isRelative = pathSegType % 2 === 1 && pathSegType > 1; - - // when the last point doesn't equal the current point add the current point - if (!lastPoint || px != lastPoint.x || py != lastPoint.y) { - if (lastPoint && isRelative) { - lx = lastPoint.x; - ly = lastPoint.y; - } else { - lx = 0; - ly = 0; - } - - var point = { - x: lx + px, - y: ly + py - }; - - // set last point - if (isRelative || !lastPoint) { - lastPoint = point; - } - - points.push(point); - - x = lx + px; - y = ly + py; - } - }; - - var addSegmentPoint = function(segment) { - var segType = segment.pathSegTypeAsLetter.toUpperCase(); - - // skip path ends - if (segType === 'Z') - return; - - // map segment to x and y - switch (segType) { - - case 'M': - case 'L': - case 'T': - case 'C': - case 'S': - case 'Q': - x = segment.x; - y = segment.y; - break; - case 'H': - x = segment.x; - break; - case 'V': - y = segment.y; - break; - } - - addPoint(x, y, segment.pathSegType); - }; - - // ensure path is absolute - _svgPathToAbsolute(path); - - // get total length - total = path.getTotalLength(); - - // queue segments - segments = []; - for (i = 0; i < path.pathSegList.numberOfItems; i += 1) - segments.push(path.pathSegList.getItem(i)); - - segmentsQueue = segments.concat(); - - // sample through path - while (length < total) { - // get segment at position - segmentIndex = path.getPathSegAtLength(length); - segment = segments[segmentIndex]; - - // new segment - if (segment != lastSegment) { - while (segmentsQueue.length && segmentsQueue[0] != segment) - addSegmentPoint(segmentsQueue.shift()); - - lastSegment = segment; - } - - // add points in between when curving - // TODO: adaptive sampling - switch (segment.pathSegTypeAsLetter.toUpperCase()) { - - case 'C': - case 'T': - case 'S': - case 'Q': - case 'A': - point = path.getPointAtLength(length); - addPoint(point.x, point.y, 0); - break; - - } - - // increment by sample value - length += sampleLength; - } - - // add remaining segments not passed by sampling - for (i = 0, il = segmentsQueue.length; i < il; ++i) - addSegmentPoint(segmentsQueue[i]); - - return points; - }; - - var _svgPathToAbsolute = function(path) { - // http://phrogz.net/convert-svg-path-to-all-absolute-commands - // Copyright (c) Gavin Kistner - // http://phrogz.net/js/_ReuseLicense.txt - // Modifications: tidy formatting and naming - var x0, y0, x1, y1, x2, y2, segs = path.pathSegList, - x = 0, y = 0, len = segs.numberOfItems; - - for (var i = 0; i < len; ++i) { - var seg = segs.getItem(i), - segType = seg.pathSegTypeAsLetter; - - if (/[MLHVCSQTA]/.test(segType)) { - if ('x' in seg) x = seg.x; - if ('y' in seg) y = seg.y; - } else { - if ('x1' in seg) x1 = x + seg.x1; - if ('x2' in seg) x2 = x + seg.x2; - if ('y1' in seg) y1 = y + seg.y1; - if ('y2' in seg) y2 = y + seg.y2; - if ('x' in seg) x += seg.x; - if ('y' in seg) y += seg.y; - - switch (segType) { - - case 'm': - segs.replaceItem(path.createSVGPathSegMovetoAbs(x, y), i); - break; - case 'l': - segs.replaceItem(path.createSVGPathSegLinetoAbs(x, y), i); - break; - case 'h': - segs.replaceItem(path.createSVGPathSegLinetoHorizontalAbs(x), i); - break; - case 'v': - segs.replaceItem(path.createSVGPathSegLinetoVerticalAbs(y), i); - break; - case 'c': - segs.replaceItem(path.createSVGPathSegCurvetoCubicAbs(x, y, x1, y1, x2, y2), i); - break; - case 's': - segs.replaceItem(path.createSVGPathSegCurvetoCubicSmoothAbs(x, y, x2, y2), i); - break; - case 'q': - segs.replaceItem(path.createSVGPathSegCurvetoQuadraticAbs(x, y, x1, y1), i); - break; - case 't': - segs.replaceItem(path.createSVGPathSegCurvetoQuadraticSmoothAbs(x, y), i); - break; - case 'a': - segs.replaceItem(path.createSVGPathSegArcAbs(x, y, seg.r1, seg.r2, seg.angle, seg.largeArcFlag, seg.sweepFlag), i); - break; - case 'z': - case 'Z': - x = x0; - y = y0; - break; - - } - } - - if (segType == 'M' || segType == 'm') { - x0 = x; - y0 = y; - } - } - }; - -})(); - -/***/ }), -/* 997 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Factory = __webpack_require__(947); -var GetFastValue = __webpack_require__(2); -var GetValue = __webpack_require__(4); -var MatterAttractors = __webpack_require__(998); -var MatterLib = __webpack_require__(952); -var MatterWrap = __webpack_require__(999); -var Merge = __webpack_require__(104); -var Plugin = __webpack_require__(865); +var GetValue = __webpack_require__(5); +var MatterAttractors = __webpack_require__(979); +var MatterLib = __webpack_require__(959); +var MatterWrap = __webpack_require__(978); +var Merge = __webpack_require__(107); +var Plugin = __webpack_require__(463); var PluginManager = __webpack_require__(12); -var World = __webpack_require__(957); +var World = __webpack_require__(954); /** * @classdesc @@ -134898,330 +134065,2153 @@ module.exports = MatterPhysics; /***/ }), -/* 998 */ +/* 981 */ /***/ (function(module, exports, __webpack_require__) { -var Matter = __webpack_require__(864); - /** - * An attractors plugin for matter.js. - * See the readme for usage and examples. - * @module MatterAttractors - */ -var MatterAttractors = { - // plugin meta - name: 'matter-attractors', // PLUGIN_NAME - version: '0.1.7', // PLUGIN_VERSION - for: 'matter-js@^0.13.1', - silent: true, // no console log please +* The `Matter.Svg` module contains methods for converting SVG images into an array of vector points. +* +* To use this module you also need the SVGPathSeg polyfill: https://github.com/progers/pathseg +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Svg +*/ - // installs the plugin where `base` is `Matter` - // you should not need to call this directly. - install: function(base) { - base.after('Body.create', function() { - MatterAttractors.Body.init(this); - }); +var Svg = {}; - base.before('Engine.update', function(engine) { - MatterAttractors.Engine.update(engine); - }); - }, +module.exports = Svg; + +var Bounds = __webpack_require__(89); + +(function() { - Body: { /** - * Initialises the `body` to support attractors. - * This is called automatically by the plugin. - * @function MatterAttractors.Body.init - * @param {Matter.Body} body The body to init. - * @returns {void} No return value. + * Converts an SVG path into an array of vector points. + * If the input path forms a concave shape, you must decompose the result into convex parts before use. + * See `Bodies.fromVertices` which provides support for this. + * Note that this function is not guaranteed to support complex paths (such as those with holes). + * @method pathToVertices + * @param {SVGPathElement} path + * @param {Number} [sampleLength=15] + * @return {Vector[]} points */ - init: function(body) { - body.plugin.attractors = body.plugin.attractors || []; - } - }, + Svg.pathToVertices = function(path, sampleLength) { + // https://github.com/wout/svg.topoly.js/blob/master/svg.topoly.js + var i, il, total, point, segment, segments, + segmentsQueue, lastSegment, + lastPoint, segmentIndex, points = [], + lx, ly, length = 0, x = 0, y = 0; - Engine: { - /** - * Applies all attractors for all bodies in the `engine`. - * This is called automatically by the plugin. - * @function MatterAttractors.Engine.update - * @param {Matter.Engine} engine The engine to update. - * @returns {void} No return value. - */ - update: function(engine) { - var world = engine.world, - bodies = Matter.Composite.allBodies(world); + sampleLength = sampleLength || 15; - for (var i = 0; i < bodies.length; i += 1) { - var bodyA = bodies[i], - attractors = bodyA.plugin.attractors; + var addPoint = function(px, py, pathSegType) { + // all odd-numbered path types are relative except PATHSEG_CLOSEPATH (1) + var isRelative = pathSegType % 2 === 1 && pathSegType > 1; - if (attractors && attractors.length > 0) { - for (var j = i + 1; j < bodies.length; j += 1) { - var bodyB = bodies[j]; + // when the last point doesn't equal the current point add the current point + if (!lastPoint || px != lastPoint.x || py != lastPoint.y) { + if (lastPoint && isRelative) { + lx = lastPoint.x; + ly = lastPoint.y; + } else { + lx = 0; + ly = 0; + } - for (var k = 0; k < attractors.length; k += 1) { - var attractor = attractors[k], - forceVector = attractor; + var point = { + x: lx + px, + y: ly + py + }; - if (Matter.Common.isFunction(attractor)) { - forceVector = attractor(bodyA, bodyB); - } - - if (forceVector) { - Matter.Body.applyForce(bodyB, bodyB.position, forceVector); - } + // set last point + if (isRelative || !lastPoint) { + lastPoint = point; + } + + points.push(point); + + x = lx + px; + y = ly + py; } - } + }; + + var addSegmentPoint = function(segment) { + var segType = segment.pathSegTypeAsLetter.toUpperCase(); + + // skip path ends + if (segType === 'Z') + return; + + // map segment to x and y + switch (segType) { + + case 'M': + case 'L': + case 'T': + case 'C': + case 'S': + case 'Q': + x = segment.x; + y = segment.y; + break; + case 'H': + x = segment.x; + break; + case 'V': + y = segment.y; + break; + } + + addPoint(x, y, segment.pathSegType); + }; + + // ensure path is absolute + _svgPathToAbsolute(path); + + // get total length + total = path.getTotalLength(); + + // queue segments + segments = []; + for (i = 0; i < path.pathSegList.numberOfItems; i += 1) + segments.push(path.pathSegList.getItem(i)); + + segmentsQueue = segments.concat(); + + // sample through path + while (length < total) { + // get segment at position + segmentIndex = path.getPathSegAtLength(length); + segment = segments[segmentIndex]; + + // new segment + if (segment != lastSegment) { + while (segmentsQueue.length && segmentsQueue[0] != segment) + addSegmentPoint(segmentsQueue.shift()); + + lastSegment = segment; + } + + // add points in between when curving + // TODO: adaptive sampling + switch (segment.pathSegTypeAsLetter.toUpperCase()) { + + case 'C': + case 'T': + case 'S': + case 'Q': + case 'A': + point = path.getPointAtLength(length); + addPoint(point.x, point.y, 0); + break; + + } + + // increment by sample value + length += sampleLength; } - } - } - }, - - /** - * Defines some useful common attractor functions that can be used - * by pushing them to your body's `body.plugin.attractors` array. - * @namespace MatterAttractors.Attractors - * @property {number} gravityConstant The gravitational constant used by the gravity attractor. - */ - Attractors: { - gravityConstant: 0.001, - /** - * An attractor function that applies Newton's law of gravitation. - * Use this by pushing `MatterAttractors.Attractors.gravity` to your body's `body.plugin.attractors` array. - * The gravitational constant defaults to `0.001` which you can change - * at `MatterAttractors.Attractors.gravityConstant`. - * @function MatterAttractors.Attractors.gravity - * @param {Matter.Body} bodyA The first body. - * @param {Matter.Body} bodyB The second body. - * @returns {void} No return value. - */ - gravity: function(bodyA, bodyB) { - // use Newton's law of gravitation - var bToA = Matter.Vector.sub(bodyB.position, bodyA.position), - distanceSq = Matter.Vector.magnitudeSquared(bToA) || 0.0001, - normal = Matter.Vector.normalise(bToA), - magnitude = -MatterAttractors.Attractors.gravityConstant * (bodyA.mass * bodyB.mass / distanceSq), - force = Matter.Vector.mult(normal, magnitude); + // add remaining segments not passed by sampling + for (i = 0, il = segmentsQueue.length; i < il; ++i) + addSegmentPoint(segmentsQueue[i]); - // to apply forces to both bodies - Matter.Body.applyForce(bodyA, bodyA.position, Matter.Vector.neg(force)); - Matter.Body.applyForce(bodyB, bodyB.position, force); - } - } -}; + return points; + }; -module.exports = MatterAttractors; + var _svgPathToAbsolute = function(path) { + // http://phrogz.net/convert-svg-path-to-all-absolute-commands + // Copyright (c) Gavin Kistner + // http://phrogz.net/js/_ReuseLicense.txt + // Modifications: tidy formatting and naming + var x0, y0, x1, y1, x2, y2, segs = path.pathSegList, + x = 0, y = 0, len = segs.numberOfItems; -/** - * @namespace Matter.Body - * @see http://brm.io/matter-js/docs/classes/Body.html - */ + for (var i = 0; i < len; ++i) { + var seg = segs.getItem(i), + segType = seg.pathSegTypeAsLetter; -/** - * This plugin adds a new property `body.plugin.attractors` to instances of `Matter.Body`. - * This is an array of callback functions that will be called automatically - * for every pair of bodies, on every engine update. - * @property {Function[]} body.plugin.attractors - * @memberof Matter.Body - */ + if (/[MLHVCSQTA]/.test(segType)) { + if ('x' in seg) x = seg.x; + if ('y' in seg) y = seg.y; + } else { + if ('x1' in seg) x1 = x + seg.x1; + if ('x2' in seg) x2 = x + seg.x2; + if ('y1' in seg) y1 = y + seg.y1; + if ('y2' in seg) y2 = y + seg.y2; + if ('x' in seg) x += seg.x; + if ('y' in seg) y += seg.y; -/** - * An attractor function calculates the force to be applied - * to `bodyB`, it should either: - * - return the force vector to be applied to `bodyB` - * - or apply the force to the body(s) itself - * @callback AttractorFunction - * @param {Matter.Body} bodyA - * @param {Matter.Body} bodyB - * @returns {Vector|undefined} a force vector (optional) - */ + switch (segType) { + + case 'm': + segs.replaceItem(path.createSVGPathSegMovetoAbs(x, y), i); + break; + case 'l': + segs.replaceItem(path.createSVGPathSegLinetoAbs(x, y), i); + break; + case 'h': + segs.replaceItem(path.createSVGPathSegLinetoHorizontalAbs(x), i); + break; + case 'v': + segs.replaceItem(path.createSVGPathSegLinetoVerticalAbs(y), i); + break; + case 'c': + segs.replaceItem(path.createSVGPathSegCurvetoCubicAbs(x, y, x1, y1, x2, y2), i); + break; + case 's': + segs.replaceItem(path.createSVGPathSegCurvetoCubicSmoothAbs(x, y, x2, y2), i); + break; + case 'q': + segs.replaceItem(path.createSVGPathSegCurvetoQuadraticAbs(x, y, x1, y1), i); + break; + case 't': + segs.replaceItem(path.createSVGPathSegCurvetoQuadraticSmoothAbs(x, y), i); + break; + case 'a': + segs.replaceItem(path.createSVGPathSegArcAbs(x, y, seg.r1, seg.r2, seg.angle, seg.largeArcFlag, seg.sweepFlag), i); + break; + case 'z': + case 'Z': + x = x0; + y = y0; + break; + + } + } + + if (segType == 'M' || segType == 'm') { + x0 = x; + y0 = y; + } + } + }; + +})(); /***/ }), -/* 999 */ +/* 982 */ /***/ (function(module, exports, __webpack_require__) { -var Matter = __webpack_require__(864); +// @if DEBUG +/** +* _Internal Class_, not generally used outside of the engine's internals. +* +*/ + +var Metrics = {}; + +module.exports = Metrics; + +var Composite = __webpack_require__(120); +var Common = __webpack_require__(39); + +(function() { + + /** + * Creates a new metrics. + * @method create + * @private + * @return {metrics} A new metrics + */ + Metrics.create = function(options) { + var defaults = { + extended: false, + narrowDetections: 0, + narrowphaseTests: 0, + narrowReuse: 0, + narrowReuseCount: 0, + midphaseTests: 0, + broadphaseTests: 0, + narrowEff: 0.0001, + midEff: 0.0001, + broadEff: 0.0001, + collisions: 0, + buckets: 0, + bodies: 0, + pairs: 0 + }; + + return Common.extend(defaults, false, options); + }; + + /** + * Resets metrics. + * @method reset + * @private + * @param {metrics} metrics + */ + Metrics.reset = function(metrics) { + if (metrics.extended) { + metrics.narrowDetections = 0; + metrics.narrowphaseTests = 0; + metrics.narrowReuse = 0; + metrics.narrowReuseCount = 0; + metrics.midphaseTests = 0; + metrics.broadphaseTests = 0; + metrics.narrowEff = 0; + metrics.midEff = 0; + metrics.broadEff = 0; + metrics.collisions = 0; + metrics.buckets = 0; + metrics.pairs = 0; + metrics.bodies = 0; + } + }; + + /** + * Updates metrics. + * @method update + * @private + * @param {metrics} metrics + * @param {engine} engine + */ + Metrics.update = function(metrics, engine) { + if (metrics.extended) { + var world = engine.world, + bodies = Composite.allBodies(world); + + metrics.collisions = metrics.narrowDetections; + metrics.pairs = engine.pairs.list.length; + metrics.bodies = bodies.length; + metrics.midEff = (metrics.narrowDetections / (metrics.midphaseTests || 1)).toFixed(2); + metrics.narrowEff = (metrics.narrowDetections / (metrics.narrowphaseTests || 1)).toFixed(2); + metrics.broadEff = (1 - (metrics.broadphaseTests / (bodies.length || 1))).toFixed(2); + metrics.narrowReuse = (metrics.narrowReuseCount / (metrics.narrowphaseTests || 1)).toFixed(2); + //var broadphase = engine.broadphase[engine.broadphase.current]; + //if (broadphase.instance) + // metrics.buckets = Common.keys(broadphase.instance.buckets).length; + } + }; + +})(); +// @endif + + +/***/ }), +/* 983 */ +/***/ (function(module, exports, __webpack_require__) { /** - * A coordinate wrapping plugin for matter.js. - * See the readme for usage and examples. - * @module MatterWrap +* The `Matter.Query` module contains methods for performing collision queries. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Query +*/ + +var Query = {}; + +module.exports = Query; + +var Vector = __webpack_require__(90); +var SAT = __webpack_require__(465); +var Bounds = __webpack_require__(89); +var Bodies = __webpack_require__(92); +var Vertices = __webpack_require__(91); + +(function() { + + /** + * Casts a ray segment against a set of bodies and returns all collisions, ray width is optional. Intersection points are not provided. + * @method ray + * @param {body[]} bodies + * @param {vector} startPoint + * @param {vector} endPoint + * @param {number} [rayWidth] + * @return {object[]} Collisions + */ + Query.ray = function(bodies, startPoint, endPoint, rayWidth) { + rayWidth = rayWidth || 1e-100; + + var rayAngle = Vector.angle(startPoint, endPoint), + rayLength = Vector.magnitude(Vector.sub(startPoint, endPoint)), + rayX = (endPoint.x + startPoint.x) * 0.5, + rayY = (endPoint.y + startPoint.y) * 0.5, + ray = Bodies.rectangle(rayX, rayY, rayLength, rayWidth, { angle: rayAngle }), + collisions = []; + + for (var i = 0; i < bodies.length; i++) { + var bodyA = bodies[i]; + + if (Bounds.overlaps(bodyA.bounds, ray.bounds)) { + for (var j = bodyA.parts.length === 1 ? 0 : 1; j < bodyA.parts.length; j++) { + var part = bodyA.parts[j]; + + if (Bounds.overlaps(part.bounds, ray.bounds)) { + var collision = SAT.collides(part, ray); + if (collision.collided) { + collision.body = collision.bodyA = collision.bodyB = bodyA; + collisions.push(collision); + break; + } + } + } + } + } + + return collisions; + }; + + /** + * Returns all bodies whose bounds are inside (or outside if set) the given set of bounds, from the given set of bodies. + * @method region + * @param {body[]} bodies + * @param {bounds} bounds + * @param {bool} [outside=false] + * @return {body[]} The bodies matching the query + */ + Query.region = function(bodies, bounds, outside) { + var result = []; + + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i], + overlaps = Bounds.overlaps(body.bounds, bounds); + if ((overlaps && !outside) || (!overlaps && outside)) + result.push(body); + } + + return result; + }; + + /** + * Returns all bodies whose vertices contain the given point, from the given set of bodies. + * @method point + * @param {body[]} bodies + * @param {vector} point + * @return {body[]} The bodies matching the query + */ + Query.point = function(bodies, point) { + var result = []; + + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i]; + + if (Bounds.contains(body.bounds, point)) { + for (var j = body.parts.length === 1 ? 0 : 1; j < body.parts.length; j++) { + var part = body.parts[j]; + + if (Bounds.contains(part.bounds, point) + && Vertices.contains(part.vertices, point)) { + result.push(body); + break; + } + } + } + } + + return result; + }; + +})(); + + +/***/ }), +/* 984 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var MatterWrap = { - // plugin meta - name: 'matter-wrap', // PLUGIN_NAME - version: '0.1.4', // PLUGIN_VERSION - for: 'matter-js@^0.13.1', - silent: true, // no console log please - // installs the plugin where `base` is `Matter` - // you should not need to call this directly. - install: function(base) { - base.after('Engine.update', function() { - MatterWrap.Engine.update(this); - }); - }, +var Bounds = __webpack_require__(89); +var Class = __webpack_require__(0); +var Composite = __webpack_require__(120); +var Constraint = __webpack_require__(170); +var Detector = __webpack_require__(466); +var GetFastValue = __webpack_require__(2); +var Merge = __webpack_require__(107); +var Sleeping = __webpack_require__(198); +var Vector2 = __webpack_require__(6); +var Vertices = __webpack_require__(91); - Engine: { - /** - * Updates the engine by wrapping bodies and composites inside `engine.world`. - * This is called automatically by the plugin. - * @function MatterWrap.Engine.update - * @param {Matter.Engine} engine The engine to update. - * @returns {void} No return value. - */ - update: function(engine) { - var world = engine.world, - bodies = Matter.Composite.allBodies(world), - composites = Matter.Composite.allComposites(world); +/** + * @classdesc + * [description] + * + * @class PointerConstraint + * @memberOf Phaser.Physics.Matter + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Physics.Matter.World} world - [description] + * @param {object} options - [description] + */ +var PointerConstraint = new Class({ - for (var i = 0; i < bodies.length; i += 1) { - var body = bodies[i]; + initialize: - if (body.plugin.wrap) { - MatterWrap.Body.wrap(body, body.plugin.wrap); - } - } + function PointerConstraint (scene, world, options) + { + if (options === undefined) { options = {}; } - for (i = 0; i < composites.length; i += 1) { - var composite = composites[i]; - - if (composite.plugin.wrap) { - MatterWrap.Composite.wrap(composite, composite.plugin.wrap); - } - } - } - }, - - Bounds: { - /** - * Returns a translation vector that wraps the `objectBounds` inside the `bounds`. - * @function MatterWrap.Bounds.wrap - * @param {Matter.Bounds} objectBounds The bounds of the object to wrap inside the bounds. - * @param {Matter.Bounds} bounds The bounds to wrap the body inside. - * @returns {?Matter.Vector} A translation vector (only if wrapping is required). - */ - wrap: function(objectBounds, bounds) { - var x = null, - y = null; - - if (typeof bounds.min.x !== 'undefined' && typeof bounds.max.x !== 'undefined') { - if (objectBounds.min.x > bounds.max.x) { - x = bounds.min.x - objectBounds.max.x; - } else if (objectBounds.max.x < bounds.min.x) { - x = bounds.max.x - objectBounds.min.x; - } - } - - if (typeof bounds.min.y !== 'undefined' && typeof bounds.max.y !== 'undefined') { - if (objectBounds.min.y > bounds.max.y) { - y = bounds.min.y - objectBounds.max.y; - } else if (objectBounds.max.y < bounds.min.y) { - y = bounds.max.y - objectBounds.min.y; - } - } - - if (x !== null || y !== null) { - return { - x: x || 0, - y: y || 0 + // Defaults + var defaults = { + label: 'Pointer Constraint', + pointA: { x: 0, y: 0 }, + pointB: { x: 0, y: 0 }, + damping: 0, + length: 0.01, + stiffness: 0.1, + angularStiffness: 1, + collisionFilter: { + category: 0x0001, + mask: 0xFFFFFFFF, + group: 0 + } }; - } - } - }, - Body: { - /** - * Wraps the `body` position such that it always stays within the given bounds. - * Upon crossing a boundary the body will appear on the opposite side of the bounds, - * while maintaining its velocity. - * This is called automatically by the plugin. - * @function MatterWrap.Body.wrap - * @param {Matter.Body} body The body to wrap. - * @param {Matter.Bounds} bounds The bounds to wrap the body inside. - * @returns {?Matter.Vector} The translation vector that was applied (only if wrapping was required). - */ - wrap: function(body, bounds) { - var translation = MatterWrap.Bounds.wrap(body.bounds, bounds); + /** + * [description] + * + * @name Phaser.Physics.Matter.PointerConstraint#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; - if (translation) { - Matter.Body.translate(body, translation); - } + /** + * [description] + * + * @name Phaser.Physics.Matter.PointerConstraint#world + * @type {Phaser.Physics.Matter.World} + * @since 3.0.0 + */ + this.world = world; - return translation; - } - }, + /** + * [description] + * + * @name Phaser.Physics.Matter.PointerConstraint#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @since 3.0.0 + */ + var camera = GetFastValue(options, 'camera', null); - Composite: { - /** - * Returns the union of the bounds of all of the composite's bodies - * (not accounting for constraints). - * @function MatterWrap.Composite.bounds - * @param {Matter.Composite} composite The composite. - * @returns {Matter.Bounds} The composite bounds. - */ - bounds: function(composite) { - var bodies = Matter.Composite.allBodies(composite), - vertices = []; - - for (var i = 0; i < bodies.length; i += 1) { - var body = bodies[i]; - vertices.push(body.bounds.min, body.bounds.max); - } + if (!camera) + { + this.camera = scene.sys.cameras.main; + } + else + { + this.camera = camera; - return Matter.Bounds.create(vertices); + delete options.camera; + } + + /** + * [description] + * + * @name Phaser.Physics.Matter.PointerConstraint#pointer + * @type {Phaser.Input.Pointer} + * @default null + * @since 3.0.0 + */ + this.pointer = null; + + /** + * [description] + * + * @name Phaser.Physics.Matter.PointerConstraint#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * The transformed position. + * + * @name Phaser.Physics.Matter.PointerConstraint#position + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.position = new Vector2(); + + /** + * [description] + * + * @name Phaser.Physics.Matter.PointerConstraint#constraint + * @type {object} + * @since 3.0.0 + */ + this.constraint = Constraint.create(Merge(options, defaults)); + + this.world.on('beforeupdate', this.update, this); + + scene.sys.input.on('pointerdown', this.onDown, this); + + scene.sys.input.on('pointerup', this.onUp, this); }, /** - * Wraps the `composite` position such that it always stays within the given bounds. - * Upon crossing a boundary the composite will appear on the opposite side of the bounds, - * while maintaining its velocity. - * This is called automatically by the plugin. - * @function MatterWrap.Composite.wrap - * @param {Matter.Composite} composite The composite to wrap. - * @param {Matter.Bounds} bounds The bounds to wrap the composite inside. - * @returns {?Matter.Vector} The translation vector that was applied (only if wrapping was required). + * [description] + * + * @method Phaser.Physics.Matter.PointerConstraint#onDown + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - [description] */ - wrap: function(composite, bounds) { - var translation = MatterWrap.Bounds.wrap( - MatterWrap.Composite.bounds(composite), - bounds - ); + onDown: function (pointer) + { + this.pointer = pointer; + }, - if (translation) { - Matter.Composite.translate(composite, translation); - } + /** + * [description] + * + * @method Phaser.Physics.Matter.PointerConstraint#onUp + * @since 3.0.0 + */ + onUp: function () + { + this.pointer = null; + }, - return translation; + /** + * [description] + * + * @method Phaser.Physics.Matter.PointerConstraint#getBodyPart + * @since 3.0.0 + * + * @param {Matter.Body} body - [description] + * @param {Phaser.Math.Vector2} position - [description] + * + * @return {boolean} [description] + */ + getBodyPart: function (body, position) + { + var constraint = this.constraint; + + var start = (body.parts.length > 1) ? 1 : 0; + + for (var i = start; i < body.parts.length; i++) + { + var part = body.parts[i]; + + if (Vertices.contains(part.vertices, position)) + { + constraint.bodyB = body; + + constraint.pointA.x = position.x; + constraint.pointA.y = position.y; + + constraint.pointB.x = position.x - body.position.x; + constraint.pointB.y = position.y - body.position.y; + + constraint.angleB = body.angle; + + Sleeping.set(body, false); + + return true; + } + } + + return false; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.PointerConstraint#update + * @since 3.0.0 + */ + update: function () + { + if (!this.active) + { + return; + } + + var pointer = this.pointer; + var constraint = this.constraint; + + if (!pointer) + { + // Pointer is up / released + if (constraint.bodyB) + { + constraint.bodyB = null; + } + } + else + { + var pos = this.position; + + this.camera.getWorldPoint(pointer.x, pointer.y, pos); + + if (constraint.bodyB) + { + // Pointer is down and we have bodyB, so wake it up + Sleeping.set(constraint.bodyB, false); + + constraint.pointA.x = pos.x; + constraint.pointA.y = pos.y; + } + else + { + var bodies = Composite.allBodies(this.world.localWorld); + + // Pointer is down and no bodyB, so check if we've hit anything + for (var i = 0; i < bodies.length; i++) + { + var body = bodies[i]; + + if (!body.ignorePointer && Bounds.contains(body.bounds, pos) && + Detector.canCollide(body.collisionFilter, constraint.collisionFilter)) + { + if (this.getBodyPart(body, pos)) + { + break; + } + } + } + } + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.PointerConstraint#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.world.removeConstraint(this.constraint); + + this.constraint = null; + + this.world.off('beforeupdate', this.update); + + this.scene.sys.input.off('pointerdown', this.onDown, this); + + this.scene.sys.input.off('pointerup', this.onUp, this); } - } -}; -module.exports = MatterWrap; +}); -/** - * @namespace Matter.Body - * @see http://brm.io/matter-js/docs/classes/Body.html - */ +module.exports = PointerConstraint; -/** - * This plugin adds a new property `body.plugin.wrap` to instances of `Matter.Body`. - * This is a `Matter.Bounds` instance that specifies the wrapping region. - * @property {Matter.Bounds} body.plugin.wrap - * @memberof Matter.Body - */ - -/** - * This plugin adds a new property `composite.plugin.wrap` to instances of `Matter.Composite`. - * This is a `Matter.Bounds` instance that specifies the wrapping region. - * @property {Matter.Bounds} composite.plugin.wrap - * @memberof Matter.Composite - */ /***/ }), -/* 1000 */ +/* 985 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Body = __webpack_require__(49); + +/** + * [description] + * + * @name Phaser.Physics.Matter.Components.Velocity + * @since 3.0.0 + */ +var Velocity = { + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Velocity#setAngularVelocity + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setAngularVelocity: function (value) + { + Body.setAngularVelocity(this.body, value); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Velocity#setVelocityX + * @since 3.0.0 + * + * @param {number} x - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setVelocityX: function (x) + { + this._tempVec2.set(x, this.body.velocity.y); + + Body.setVelocity(this.body, this._tempVec2); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Velocity#setVelocityY + * @since 3.0.0 + * + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setVelocityY: function (y) + { + this._tempVec2.set(this.body.velocity.x, y); + + Body.setVelocity(this.body, this._tempVec2); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Velocity#setVelocity + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setVelocity: function (x, y) + { + this._tempVec2.set(x, y); + + Body.setVelocity(this.body, this._tempVec2); + + return this; + } + +}; + +module.exports = Velocity; + + +/***/ }), +/* 986 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Body = __webpack_require__(49); +var MATH_CONST = __webpack_require__(16); +var WrapAngle = __webpack_require__(175); +var WrapAngleDegrees = __webpack_require__(174); + +// global bitmask flag for GameObject.renderMask (used by Scale) +var _FLAG = 4; // 0100 + +// Transform Component + +/** + * [description] + * + * @name Phaser.Physics.Matter.Components.Transform + * @since 3.0.0 + */ +var Transform = { + + /** + * [description] + * + * @name Phaser.Physics.Matter.Components.Transform#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.body.position.x; + }, + + set: function (value) + { + this._tempVec2.set(value, this.y); + + Body.setPosition(this.body, this._tempVec2); + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Matter.Components.Transform#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.body.position.y; + }, + + set: function (value) + { + this._tempVec2.set(this.x, value); + + Body.setPosition(this.body, this._tempVec2); + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Matter.Components.Transform#scaleX + * @type {number} + * @since 3.0.0 + */ + scaleX: { + + get: function () + { + return this._scaleX; + }, + + set: function (value) + { + this._scaleX = value; + + if (this._scaleX === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + + Body.scale(this.body, value, this._scaleY); + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Matter.Components.Transform#scaleY + * @type {number} + * @since 3.0.0 + */ + scaleY: { + + get: function () + { + return this._scaleY; + }, + + set: function (value) + { + this._scaleY = value; + + if (this._scaleY === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + + Body.scale(this.body, this._scaleX, value); + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Matter.Components.Transform#angle + * @type {number} + * @since 3.0.0 + */ + angle: { + + get: function () + { + return WrapAngleDegrees(this.body.angle * MATH_CONST.RAD_TO_DEG); + }, + + set: function (value) + { + // value is in degrees + this.rotation = WrapAngleDegrees(value) * MATH_CONST.DEG_TO_RAD; + } + }, + + /** + * [description] + * + * @name Phaser.Physics.Matter.Components.Transform#rotation + * @type {number} + * @since 3.0.0 + */ + rotation: { + + get: function () + { + return this.body.angle; + }, + + set: function (value) + { + // value is in radians + this._rotation = WrapAngle(value); + + Body.setAngle(this.body, this._rotation); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Transform#setPosition + * @since 3.0.0 + * + * @param {number} [x=0] - [description] + * @param {number} [y=x] - [description] + * + * @return{Phaser.GameObjects.GameObject} This Game Object. + */ + setPosition: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + + this._tempVec2.set(x, y); + + Body.setPosition(this.body, this._tempVec2); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Transform#setRotation + * @since 3.0.0 + * + * @param {number} [radians=0] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setRotation: function (radians) + { + if (radians === undefined) { radians = 0; } + + this._rotation = WrapAngle(radians); + + Body.setAngle(this.body, radians); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Transform#setFixedRotation + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setFixedRotation: function () + { + Body.setInertia(this.body, Infinity); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Transform#setAngle + * @since 3.0.0 + * + * @param {number} [degrees=0] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setAngle: function (degrees) + { + if (degrees === undefined) { degrees = 0; } + + this.angle = degrees; + + Body.setAngle(this.body, this.rotation); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Transform#setScale + * @since 3.0.0 + * + * @param {number} [x=1] - [description] + * @param {number} [y=x] - [description] + * @param {Phaser.Math.Vector2} [point] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setScale: function (x, y, point) + { + if (x === undefined) { x = 1; } + if (y === undefined) { y = x; } + + this._scaleX = x; + this._scaleY = y; + + Body.scale(this.body, x, y, point); + + return this; + } + +}; + +module.exports = Transform; + + +/***/ }), +/* 987 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MatterEvents = __webpack_require__(171); + +/** + * [description] + * + * @name Phaser.Physics.Matter.Components.Sleep + * @since 3.0.0 + */ +var Sleep = { + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Sleep#setSleepThreshold + * @since 3.0.0 + * + * @param {number} [value=60] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setSleepThreshold: function (value) + { + if (value === undefined) { value = 60; } + + this.body.sleepThreshold = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Sleep#setSleepEvents + * @since 3.0.0 + * + * @param {boolean} start - [description] + * @param {boolean} end - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setSleepEvents: function (start, end) + { + this.setSleepStartEvent(start); + this.setSleepEndEvent(end); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Sleep#setSleepStartEvent + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setSleepStartEvent: function (value) + { + if (value) + { + var world = this.world; + + MatterEvents.on(this.body, 'sleepStart', function (event) + { + world.emit('sleepstart', event, this); + }); + } + else + { + MatterEvents.off(this.body, 'sleepStart'); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Sleep#setSleepEndEvent + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setSleepEndEvent: function (value) + { + if (value) + { + var world = this.world; + + MatterEvents.on(this.body, 'sleepEnd', function (event) + { + world.emit('sleepend', event, this); + }); + } + else + { + MatterEvents.off(this.body, 'sleepEnd'); + } + + return this; + } + +}; + +module.exports = Sleep; + + +/***/ }), +/* 988 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Bodies = __webpack_require__(92); +var Body = __webpack_require__(49); +var GetFastValue = __webpack_require__(2); + +/** + * [description] + * + * @name Phaser.Physics.Matter.Components.SetBody + * @since 3.0.0 + */ +var SetBody = { + + // Calling any of these methods resets previous properties you may have set on the body, including plugins, mass, etc + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.SetBody#setRectangle + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * @param {object} options - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setRectangle: function (width, height, options) + { + return this.setBody({ type: 'rectangle', width: width, height: height }, options); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.SetBody#setCircle + * @since 3.0.0 + * + * @param {number} radius - [description] + * @param {object} options - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setCircle: function (radius, options) + { + return this.setBody({ type: 'circle', radius: radius }, options); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.SetBody#setPolygon + * @since 3.0.0 + * + * @param {number} radius - [description] + * @param {number} sides - [description] + * @param {object} options - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setPolygon: function (radius, sides, options) + { + return this.setBody({ type: 'polygon', sides: sides, radius: radius }, options); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.SetBody#setTrapezoid + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * @param {number} slope - [description] + * @param {object} options - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setTrapezoid: function (width, height, slope, options) + { + return this.setBody({ type: 'trapezoid', width: width, height: height, slope: slope }, options); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.SetBody#setExistingBody + * @since 3.0.0 + * + * @param {Phaser.Physics.Matter.Body} body - [description] + * @param {boolean} [addToWorld=true] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setExistingBody: function (body, addToWorld) + { + if (addToWorld === undefined) + { + addToWorld = true; + } + + if (this.body) + { + this.world.remove(this.body); + } + + this.body = body; + this.body.gameObject = this; + + var _this = this; + + this.body.destroy = function () + { + _this.world.remove(_this.body); + _this.body.gameObject = null; + }; + + if (addToWorld) + { + this.world.add(this.body); + } + + this.setOrigin(body.render.sprite.xOffset, body.render.sprite.yOffset); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.SetBody#setBody + * @since 3.0.0 + * + * @param {object} config - [description] + * @param {object} options - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setBody: function (config, options) + { + if (!config) + { + return this; + } + + var body; + + // Allow them to do: shape: 'circle' instead of shape: { type: 'circle' } + if (typeof config === 'string') + { + // Using defaults + config = { type: config }; + } + + var shapeType = GetFastValue(config, 'type', 'rectangle'); + var bodyX = GetFastValue(config, 'x', this._tempVec2.x); + var bodyY = GetFastValue(config, 'y', this._tempVec2.y); + var bodyWidth = GetFastValue(config, 'width', this.width); + var bodyHeight = GetFastValue(config, 'height', this.height); + + switch (shapeType) + { + case 'rectangle': + body = Bodies.rectangle(bodyX, bodyY, bodyWidth, bodyHeight, options); + break; + + case 'circle': + var radius = GetFastValue(config, 'radius', Math.max(bodyWidth, bodyHeight) / 2); + var maxSides = GetFastValue(config, 'maxSides', 25); + body = Bodies.circle(bodyX, bodyY, radius, options, maxSides); + break; + + case 'trapezoid': + var slope = GetFastValue(config, 'slope', 0.5); + body = Bodies.trapezoid(bodyX, bodyY, bodyWidth, bodyHeight, slope, options); + break; + + case 'polygon': + var sides = GetFastValue(config, 'sides', 5); + var pradius = GetFastValue(config, 'radius', Math.max(bodyWidth, bodyHeight) / 2); + body = Bodies.polygon(bodyX, bodyY, sides, pradius, options); + break; + + case 'fromVertices': + case 'fromVerts': + var verts = GetFastValue(config, 'verts', []); + + if (this.body) + { + Body.setVertices(this.body, verts); + body = this.body; + } + else + { + var flagInternal = GetFastValue(config, 'flagInternal', false); + var removeCollinear = GetFastValue(config, 'removeCollinear', 0.01); + var minimumArea = GetFastValue(config, 'minimumArea', 10); + body = Bodies.fromVertices(bodyX, bodyY, verts, options, flagInternal, removeCollinear, minimumArea); + } + break; + } + + this.setExistingBody(body, config.addToWorld); + + return this; + } + +}; + +module.exports = SetBody; + + +/***/ }), +/* 989 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Matter.Components.Sensor + * @since 3.0.0 + */ +var Sensor = { + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Sensor#setSensor + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setSensor: function (value) + { + this.body.isSensor = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Sensor#isSensor + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isSensor: function () + { + return this.body.isSensor; + } + +}; + +module.exports = Sensor; + + +/***/ }), +/* 990 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Body = __webpack_require__(49); + +/** + * [description] + * + * @name Phaser.Physics.Matter.Components.Static + * @since 3.0.0 + */ +var Static = { + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Static#setStatic + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setStatic: function (value) + { + Body.setStatic(this.body, value); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Static#isStatic + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isStatic: function () + { + return this.body.isStatic; + } + +}; + +module.exports = Static; + + +/***/ }), +/* 991 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Body = __webpack_require__(49); + +/** + * [description] + * + * @name Phaser.Physics.Matter.Components.Mass + * @since 3.0.0 + */ +var Mass = { + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Mass#setMass + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setMass: function (value) + { + Body.setMass(this.body, value); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Mass#setDensity + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setDensity: function (value) + { + Body.setDensity(this.body, value); + + return this; + } + +}; + +module.exports = Mass; + + +/***/ }), +/* 992 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Matter.Components.Gravity + * @since 3.0.0 + */ +var Gravity = { + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Gravity#setIgnoreGravity + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setIgnoreGravity: function (value) + { + this.body.ignoreGravity = value; + + return this; + } + +}; + +module.exports = Gravity; + + +/***/ }), +/* 993 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Matter.Components.Friction + * @since 3.0.0 + */ +var Friction = { + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Friction#setFriction + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} [air] - [description] + * @param {number} [fstatic] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setFriction: function (value, air, fstatic) + { + this.body.friction = value; + + if (air !== undefined) + { + this.body.frictionAir = air; + } + + if (fstatic !== undefined) + { + this.body.frictionStatic = fstatic; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Friction#setFrictionAir + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setFrictionAir: function (value) + { + this.body.frictionAir = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Friction#setFrictionStatic + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setFrictionStatic: function (value) + { + this.body.frictionStatic = value; + + return this; + } + +}; + +module.exports = Friction; + + +/***/ }), +/* 994 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Body = __webpack_require__(49); + +/** + * [description] + * + * @name Phaser.Physics.Matter.Components.Force + * @since 3.0.0 + */ +var Force = { + + // force = vec2 / point + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Force#applyForce + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} force - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + applyForce: function (force) + { + this._tempVec2.set(this.body.position.x, this.body.position.y); + + Body.applyForce(this.body, this._tempVec2, force); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Force#applyForceFrom + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} position - [description] + * @param {Phaser.Math.Vector2} force - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + applyForceFrom: function (position, force) + { + Body.applyForce(this.body, position, force); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Force#thrust + * @since 3.0.0 + * + * @param {number} speed - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + thrust: function (speed) + { + var angle = this.body.angle; + + this._tempVec2.set(speed * Math.cos(angle), speed * Math.sin(angle)); + + Body.applyForce(this.body, { x: this.body.position.x, y: this.body.position.y }, this._tempVec2); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Force#thrustLeft + * @since 3.0.0 + * + * @param {number} speed - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + thrustLeft: function (speed) + { + var angle = this.body.angle - Math.PI / 2; + + this._tempVec2.set(speed * Math.cos(angle), speed * Math.sin(angle)); + + Body.applyForce(this.body, { x: this.body.position.x, y: this.body.position.y }, this._tempVec2); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Force#thrustRight + * @since 3.0.0 + * + * @param {number} speed - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + thrustRight: function (speed) + { + var angle = this.body.angle + Math.PI / 2; + + this._tempVec2.set(speed * Math.cos(angle), speed * Math.sin(angle)); + + Body.applyForce(this.body, { x: this.body.position.x, y: this.body.position.y }, this._tempVec2); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Force#thrustBack + * @since 3.0.0 + * + * @param {number} speed - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + thrustBack: function (speed) + { + var angle = this.body.angle - Math.PI; + + this._tempVec2.set(speed * Math.cos(angle), speed * Math.sin(angle)); + + Body.applyForce(this.body, { x: this.body.position.x, y: this.body.position.y }, this._tempVec2); + + return this; + } + +}; + +module.exports = Force; + + +/***/ }), +/* 995 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Matter.Components.Collision + * @since 3.0.0 + */ +var Collision = { + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Collision#setCollisionCategory + * @since 3.0.0 + * + * @param {number} value - Unique category bitfield. + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setCollisionCategory: function (value) + { + this.body.collisionFilter.category = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Collision#setCollisionGroup + * @since 3.0.0 + * + * @param {number} value - Unique group index. + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setCollisionGroup: function (value) + { + this.body.collisionFilter.group = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Collision#setCollidesWith + * @since 3.0.0 + * + * @param {(number|number[])} categories - A unique category bitfield, or an array of them. + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setCollidesWith: function (categories) + { + var flags = 0; + + if (!Array.isArray(categories)) + { + flags = categories; + } + else + { + for (var i = 0; i < categories.length; i++) + { + flags |= categories[i]; + } + } + + this.body.collisionFilter.mask = flags; + + return this; + } + +}; + +module.exports = Collision; + + +/***/ }), +/* 996 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Matter.Components.Bounce + * @since 3.0.0 + */ +var Bounce = { + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Bounce#setBounce + * @since 3.0.0 + * + * @param {float} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setBounce: function (value) + { + this.body.restitution = value; + + return this; + } + +}; + +module.exports = Bounce; + + +/***/ }), +/* 997 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Components = __webpack_require__(371); +var GetFastValue = __webpack_require__(2); +var Vector2 = __webpack_require__(6); + +/** + * [description] + * + * @function hasGetterOrSetter + * @private + * + * @param {object} def - The object to check. + * + * @return {boolean} True if it has a getter or setter, otherwise false. + */ +function hasGetterOrSetter (def) +{ + return (!!def.get && typeof def.get === 'function') || (!!def.set && typeof def.set === 'function'); +} + +/** + * [description] + * + * @function Phaser.Physics.Matter.MatterGameObject + * @since 3.3.0 + * + * @param {Phaser.Physics.Matter.World} world - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * @param {object} options - [description] + * + * @return {Phaser.GameObjects.GameObject} [description] + */ +var MatterGameObject = function (world, gameObject, options) +{ + if (options === undefined) { options = {}; } + + var x = gameObject.x; + var y = gameObject.y; + + // Temp body pos to avoid body null checks + gameObject.body = { + position: { + x: x, + y: y + } + }; + + var mixins = [ + Components.Bounce, + Components.Collision, + Components.Force, + Components.Friction, + Components.Gravity, + Components.Mass, + Components.Sensor, + Components.SetBody, + Components.Sleep, + Components.Static, + Components.Transform, + Components.Velocity + ]; + + // First let's inject all of the components into the Game Object + mixins.forEach(function (mixin) + { + + for (var key in mixin) + { + if (hasGetterOrSetter(mixin[key])) + { + Object.defineProperty(gameObject, key, { + get: mixin[key].get, + set: mixin[key].set + }); + } + else + { + Object.defineProperty(gameObject, key, {value: mixin[key]}); + } + } + + }); + + gameObject.world = world; + + gameObject._tempVec2 = new Vector2(x, y); + + var shape = GetFastValue(options, 'shape', null); + + if (!shape) + { + shape = 'rectangle'; + } + + gameObject.setBody(shape, options); + + return gameObject; +}; + +module.exports = MatterGameObject; + + +/***/ }), +/* 998 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -135231,18 +136221,164 @@ module.exports = MatterWrap; */ /** - * @namespace Phaser.Renderer + * @namespace Phaser.Physics.Matter */ module.exports = { - Canvas: __webpack_require__(1001), - Snapshot: __webpack_require__(1002), - WebGL: __webpack_require__(1003) + Factory: __webpack_require__(964), + Image: __webpack_require__(961), + Matter: __webpack_require__(464), + MatterPhysics: __webpack_require__(980), + PolyDecomp: __webpack_require__(963), + Sprite: __webpack_require__(960), + TileBody: __webpack_require__(467), + World: __webpack_require__(954) }; +/***/ }), +/* 999 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Physics.Impact.SeperateY + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.World} world - [description] + * @param {Phaser.Physics.Impact.Body} top - [description] + * @param {Phaser.Physics.Impact.Body} bottom - [description] + * @param {Phaser.Physics.Impact.Body} [weak] - [description] + */ +var SeperateY = function (world, top, bottom, weak) +{ + var nudge = (top.pos.y + top.size.y - bottom.pos.y); + var nudgeX; + var resTop; + + if (weak) + { + var strong = (top === weak) ? bottom : top; + + weak.vel.y = -weak.vel.y * weak.bounciness + strong.vel.y; + + // Riding on a platform? + nudgeX = 0; + + if (weak === top && Math.abs(weak.vel.y - strong.vel.y) < weak.minBounceVelocity) + { + weak.standing = true; + nudgeX = strong.vel.x * world.delta; + } + + var resWeak = world.collisionMap.trace(weak.pos.x, weak.pos.y, nudgeX, weak === top ? -nudge : nudge, weak.size.x, weak.size.y); + + weak.pos.y = resWeak.pos.y; + weak.pos.x = resWeak.pos.x; + } + else if (world.gravity && (bottom.standing || top.vel.y > 0)) + { + resTop = world.collisionMap.trace(top.pos.x, top.pos.y, 0, -(top.pos.y + top.size.y - bottom.pos.y), top.size.x, top.size.y); + + top.pos.y = resTop.pos.y; + + if (top.bounciness > 0 && top.vel.y > top.minBounceVelocity) + { + top.vel.y *= -top.bounciness; + } + else + { + top.standing = true; + top.vel.y = 0; + } + } + else + { + var v2 = (top.vel.y - bottom.vel.y) / 2; + + top.vel.y = -v2; + bottom.vel.y = v2; + + nudgeX = bottom.vel.x * world.delta; + + resTop = world.collisionMap.trace(top.pos.x, top.pos.y, nudgeX, -nudge / 2, top.size.x, top.size.y); + + top.pos.y = resTop.pos.y; + + var resBottom = world.collisionMap.trace(bottom.pos.x, bottom.pos.y, 0, nudge / 2, bottom.size.x, bottom.size.y); + + bottom.pos.y = resBottom.pos.y; + } +}; + +module.exports = SeperateY; + + +/***/ }), +/* 1000 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Physics.Impact.SeperateX + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.World} world - [description] + * @param {Phaser.Physics.Impact.Body} left - [description] + * @param {Phaser.Physics.Impact.Body} right - [description] + * @param {Phaser.Physics.Impact.Body} [weak] - [description] + */ +var SeperateX = function (world, left, right, weak) +{ + var nudge = left.pos.x + left.size.x - right.pos.x; + + // We have a weak entity, so just move this one + if (weak) + { + var strong = (left === weak) ? right : left; + + weak.vel.x = -weak.vel.x * weak.bounciness + strong.vel.x; + + var resWeak = world.collisionMap.trace(weak.pos.x, weak.pos.y, weak === left ? -nudge : nudge, 0, weak.size.x, weak.size.y); + + weak.pos.x = resWeak.pos.x; + } + else + { + var v2 = (left.vel.x - right.vel.x) / 2; + + left.vel.x = -v2; + right.vel.x = v2; + + var resLeft = world.collisionMap.trace(left.pos.x, left.pos.y, -nudge / 2, 0, left.size.x, left.size.y); + + left.pos.x = Math.floor(resLeft.pos.x); + + var resRight = world.collisionMap.trace(right.pos.x, right.pos.y, nudge / 2, 0, right.size.x, right.size.y); + + right.pos.x = Math.ceil(resRight.pos.x); + } +}; + +module.exports = SeperateX; + + /***/ }), /* 1001 */ /***/ (function(module, exports, __webpack_require__) { @@ -135253,19 +136389,69 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var COLLIDES = __webpack_require__(200); +var SeperateX = __webpack_require__(1000); +var SeperateY = __webpack_require__(999); + /** - * @namespace Phaser.Renderer.Canvas + * Impact Physics Solver + * + * @function Phaser.Physics.Impact.Solver + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.World} world - [description] + * @param {Phaser.Physics.Impact.Body} bodyA - [description] + * @param {Phaser.Physics.Impact.Body} bodyB - [description] */ +var Solver = function (world, bodyA, bodyB) +{ + var weak = null; -module.exports = { + if (bodyA.collides === COLLIDES.LITE || bodyB.collides === COLLIDES.FIXED) + { + weak = bodyA; + } + else if (bodyB.collides === COLLIDES.LITE || bodyA.collides === COLLIDES.FIXED) + { + weak = bodyB; + } - CanvasRenderer: __webpack_require__(366), - BlitImage: __webpack_require__(367), - DrawImage: __webpack_require__(369), - GetBlendModes: __webpack_require__(370) + if (bodyA.last.x + bodyA.size.x > bodyB.last.x && bodyA.last.x < bodyB.last.x + bodyB.size.x) + { + if (bodyA.last.y < bodyB.last.y) + { + SeperateY(world, bodyA, bodyB, weak); + } + else + { + SeperateY(world, bodyB, bodyA, weak); + } + bodyA.collideWith(bodyB, 'y'); + bodyB.collideWith(bodyA, 'y'); + + world.emit('collide', bodyA, bodyB, 'y'); + } + else if (bodyA.last.y + bodyA.size.y > bodyB.last.y && bodyA.last.y < bodyB.last.y + bodyB.size.y) + { + if (bodyA.last.x < bodyB.last.x) + { + SeperateX(world, bodyA, bodyB, weak); + } + else + { + SeperateX(world, bodyB, bodyA, weak); + } + + bodyA.collideWith(bodyB, 'x'); + bodyB.collideWith(bodyA, 'x'); + + world.emit('collide', bodyA, bodyB, 'x'); + } }; +module.exports = Solver; + /***/ }), /* 1002 */ @@ -135277,21 +136463,178 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Class = __webpack_require__(0); +var Factory = __webpack_require__(969); +var GetFastValue = __webpack_require__(2); +var Merge = __webpack_require__(107); +var PluginManager = __webpack_require__(12); +var World = __webpack_require__(965); + /** - * @namespace Phaser.Renderer.Snapshot + * @classdesc + * [description] + * + * @class ImpactPhysics + * @memberOf Phaser.Physics.Impact + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] */ +var ImpactPhysics = new Class({ -module.exports = { + initialize: - Canvas: __webpack_require__(368), - WebGL: __webpack_require__(372) + function ImpactPhysics (scene) + { + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactPhysics#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; -}; + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactPhysics#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + if (!scene.sys.settings.isBooted) + { + scene.sys.events.once('boot', this.boot, this); + } + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactPhysics#config + * @type {object} + * @since 3.0.0 + */ + this.config = this.getConfig(); + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactPhysics#world + * @type {Phaser.Physics.Impact.World} + * @since 3.0.0 + */ + this.world; + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactPhysics#add + * @type {Phaser.Physics.Impact.Factory} + * @since 3.0.0 + */ + this.add; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.ImpactPhysics#getConfig + * @since 3.0.0 + * + * @return {object} [description] + */ + getConfig: function () + { + var gameConfig = this.systems.game.config.physics; + var sceneConfig = this.systems.settings.physics; + + var config = Merge( + GetFastValue(sceneConfig, 'impact', {}), + GetFastValue(gameConfig, 'impact', {}) + ); + + return config; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.ImpactPhysics#boot + * @since 3.0.0 + */ + boot: function () + { + this.world = new World(this.scene, this.config); + this.add = new Factory(this.world); + + var eventEmitter = this.systems.events; + + eventEmitter.on('update', this.world.update, this.world); + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.ImpactPhysics#pause + * @since 3.0.0 + * + * @return {Phaser.Physics.Impact.World} The Impact World object. + */ + pause: function () + { + return this.world.pause(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.ImpactPhysics#resume + * @since 3.0.0 + * + * @return {Phaser.Physics.Impact.World} The Impact World object. + */ + resume: function () + { + return this.world.resume(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.ImpactPhysics#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.world.shutdown(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.ImpactPhysics#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.world.destroy(); + } + +}); + +PluginManager.register('ImpactPhysics', ImpactPhysics, 'impactPhysics'); + +module.exports = ImpactPhysics; /***/ }), /* 1003 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -135300,28 +136643,1289 @@ module.exports = { */ /** - * @namespace Phaser.Renderer.WebGL + * [description] + * + * @name Phaser.Physics.Impact.Components.Velocity + * @since 3.0.0 + */ +var Velocity = { + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Velocity#setVelocityX + * @since 3.0.0 + * + * @param {number} x - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setVelocityX: function (x) + { + this.vel.x = x; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Velocity#setVelocityY + * @since 3.0.0 + * + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setVelocityY: function (y) + { + this.vel.y = y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Velocity#setVelocity + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setVelocity: function (x, y) + { + if (y === undefined) { y = x; } + + this.vel.x = x; + this.vel.y = y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Velocity#setMaxVelocity + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setMaxVelocity: function (x, y) + { + if (y === undefined) { y = x; } + + this.maxVel.x = x; + this.maxVel.y = y; + + return this; + } + +}; + +module.exports = Velocity; + + +/***/ }), +/* 1004 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +/** + * [description] + * + * @name Phaser.Physics.Impact.Components.SetGameObject + * @since 3.0.0 + */ +var SetGameObject = { + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.SetGameObject#setGameObject + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * @param {boolean} [sync=true] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setGameObject: function (gameObject, sync) + { + if (sync === undefined) { sync = true; } + + if (gameObject) + { + this.body.gameObject = gameObject; + + if (sync) + { + this.syncGameObject(); + } + } + else + { + this.body.gameObject = null; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.SetGameObject#syncGameObject + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + syncGameObject: function () + { + var gameObject = this.body.gameObject; + + if (gameObject) + { + this.setBodySize(gameObject.width * gameObject.scaleX, gameObject.height * gameObject.scaleY); + } + + return this; + } + +}; + +module.exports = SetGameObject; + + +/***/ }), +/* 1005 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Impact.Components.Offset + * @since 3.0.0 + */ +var Offset = { + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Offset#setOffset + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} [width] - [description] + * @param {number} [height] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setOffset: function (x, y, width, height) + { + this.body.offset.x = x; + this.body.offset.y = y; + + if (width) + { + this.setBodySize(width, height); + } + + return this; + } + +}; + +module.exports = Offset; + + +/***/ }), +/* 1006 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Impact.Components.Gravity + * @since 3.0.0 + */ +var Gravity = { + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Gravity#setGravity + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setGravity: function (value) + { + this.body.gravityFactor = value; + + return this; + }, + + /** + * [description] + * + * @name Phaser.Physics.Impact.Components.Gravity#gravity + * @type {number} + * @since 3.0.0 + */ + gravity: { + + get: function () + { + return this.body.gravityFactor; + }, + + set: function (value) + { + this.body.gravityFactor = value; + } + + } + +}; + +module.exports = Gravity; + + +/***/ }), +/* 1007 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Impact.Components.Friction + * @since 3.0.0 + */ +var Friction = { + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Friction#setFrictionX + * @since 3.0.0 + * + * @param {number} x - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setFrictionX: function (x) + { + this.friction.x = x; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Friction#setFrictionY + * @since 3.0.0 + * + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setFrictionY: function (y) + { + this.friction.y = y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Friction#setFriction + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setFriction: function (x, y) + { + this.friction.x = x; + this.friction.y = y; + + return this; + } + +}; + +module.exports = Friction; + + +/***/ }), +/* 1008 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Impact.Components.Debug + * @since 3.0.0 + */ +var Debug = { + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Debug#setDebug + * @since 3.0.0 + * + * @param {boolean} showBody - [description] + * @param {boolean} showVelocity - [description] + * @param {number} bodyColor - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setDebug: function (showBody, showVelocity, bodyColor) + { + this.debugShowBody = showBody; + this.debugShowVelocity = showVelocity; + this.debugBodyColor = bodyColor; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Debug#setDebugBodyColor + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setDebugBodyColor: function (value) + { + this.body.debugBodyColor = value; + + return this; + }, + + /** + * [description] + * + * @name Phaser.Physics.Impact.Components.Debug#debugShowBody + * @type {boolean} + * @since 3.0.0 + */ + debugShowBody: { + + get: function () + { + return this.body.debugShowBody; + }, + + set: function (value) + { + this.body.debugShowBody = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Impact.Components.Debug#debugShowVelocity + * @type {boolean} + * @since 3.0.0 + */ + debugShowVelocity: { + + get: function () + { + return this.body.debugShowVelocity; + }, + + set: function (value) + { + this.body.debugShowVelocity = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Impact.Components.Debug#debugBodyColor + * @type {number} + * @since 3.0.0 + */ + debugBodyColor: { + + get: function () + { + return this.body.debugBodyColor; + }, + + set: function (value) + { + this.body.debugBodyColor = value; + } + + } + +}; + +module.exports = Debug; + + +/***/ }), +/* 1009 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var COLLIDES = __webpack_require__(200); + +/** + * @callback CollideCallback + * + * @param {Phaser.Physics.Impact.Body} body - [description] + * @param {Phaser.Physics.Impact.Body} other - [description] + * @param {string} axis - [description] + */ + +/** + * [description] + * + * @name Phaser.Physics.Impact.Components.Collides + * @since 3.0.0 + */ +var Collides = { + + _collideCallback: null, + _callbackScope: null, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Collides#setCollideCallback + * @since 3.0.0 + * + * @param {CollideCallback} callback - [description] + * @param {*} scope - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setCollideCallback: function (callback, scope) + { + this._collideCallback = callback; + + if (scope) + { + this._callbackScope = scope; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Collides#setCollidesNever + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setCollidesNever: function () + { + this.body.collides = COLLIDES.NEVER; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Collides#setLite + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setLite: function () + { + this.body.collides = COLLIDES.LITE; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Collides#setPassive + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setPassive: function () + { + this.body.collides = COLLIDES.PASSIVE; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Collides#setActive + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setActive: function () + { + this.body.collides = COLLIDES.ACTIVE; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Collides#setFixed + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setFixed: function () + { + this.body.collides = COLLIDES.FIXED; + + return this; + }, + + /** + * [description] + * + * @name Phaser.Physics.Impact.Components.Collides#collides + * @type {number} + * @since 3.0.0 + */ + collides: { + + get: function () + { + return this.body.collides; + }, + + set: function (value) + { + this.body.collides = value; + } + + } + +}; + +module.exports = Collides; + + +/***/ }), +/* 1010 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TYPE = __webpack_require__(199); + +/** + * [description] + * + * @name Phaser.Physics.Impact.Components.CheckAgainst + * @since 3.0.0 + */ +var CheckAgainst = { + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.CheckAgainst#setAvsB + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setAvsB: function () + { + this.setTypeA(); + + return this.setCheckAgainstB(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.CheckAgainst#setBvsA + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setBvsA: function () + { + this.setTypeB(); + + return this.setCheckAgainstA(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.CheckAgainst#setCheckAgainstNone + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setCheckAgainstNone: function () + { + this.body.checkAgainst = TYPE.NONE; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.CheckAgainst#setCheckAgainstA + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setCheckAgainstA: function () + { + this.body.checkAgainst = TYPE.A; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.CheckAgainst#setCheckAgainstB + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setCheckAgainstB: function () + { + this.body.checkAgainst = TYPE.B; + + return this; + }, + + /** + * [description] + * + * @name Phaser.Physics.Impact.Components.CheckAgainst#checkAgainst + * @type {number} + * @since 3.0.0 + */ + checkAgainst: { + + get: function () + { + return this.body.checkAgainst; + }, + + set: function (value) + { + this.body.checkAgainst = value; + } + + } + +}; + +module.exports = CheckAgainst; + + +/***/ }), +/* 1011 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Impact.Components.Bounce + * @since 3.0.0 + */ +var Bounce = { + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Bounce#setBounce + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setBounce: function (value) + { + this.body.bounciness = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Bounce#setMinBounceVelocity + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setMinBounceVelocity: function (value) + { + this.body.minBounceVelocity = value; + + return this; + }, + + /** + * [description] + * + * @name Phaser.Physics.Impact.Components.Bounce#bounce + * @type {number} + * @since 3.0.0 + */ + bounce: { + + get: function () + { + return this.body.bounciness; + }, + + set: function (value) + { + this.body.bounciness = value; + } + + } + +}; + +module.exports = Bounce; + + +/***/ }), +/* 1012 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TYPE = __webpack_require__(199); + +/** + * [description] + * + * @name Phaser.Physics.Impact.Components.BodyType + * @since 3.0.0 + */ +var BodyType = { + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.BodyType#getBodyType + * @since 3.0.0 + * + * @return {number} [description] + */ + getBodyType: function () + { + return this.body.type; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.BodyType#setTypeNone + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setTypeNone: function () + { + this.body.type = TYPE.NONE; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.BodyType#setTypeA + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setTypeA: function () + { + this.body.type = TYPE.A; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.BodyType#setTypeB + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setTypeB: function () + { + this.body.type = TYPE.B; + + return this; + } + +}; + +module.exports = BodyType; + + +/***/ }), +/* 1013 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Impact.Components.BodyScale + * @since 3.0.0 + */ +var BodyScale = { + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.BodyScale#setBodySize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} [height=width] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setBodySize: function (width, height) + { + if (height === undefined) { height = width; } + + this.body.size.x = Math.round(width); + this.body.size.y = Math.round(height); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.BodyScale#setBodyScale + * @since 3.0.0 + * + * @param {number} scaleX - [description] + * @param {number} [scaleY] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setBodyScale: function (scaleX, scaleY) + { + if (scaleY === undefined) { scaleY = scaleX; } + + var gameObject = this.body.gameObject; + + if (gameObject) + { + gameObject.setScale(scaleX, scaleY); + + return this.setBodySize(gameObject.width * gameObject.scaleX, gameObject.height * gameObject.scaleY); + } + else + { + return this.setBodySize(this.body.size.x * scaleX, this.body.size.y * scaleY); + } + } + +}; + +module.exports = BodyScale; + + +/***/ }), +/* 1014 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Impact.Components.Acceleration + * @since 3.0.0 + */ +var Acceleration = { + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Acceleration#setAccelerationX + * @since 3.0.0 + * + * @param {number} x - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setAccelerationX: function (x) + { + this.accel.x = x; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Acceleration#setAccelerationY + * @since 3.0.0 + * + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setAccelerationY: function (y) + { + this.accel.y = y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Acceleration#setAcceleration + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setAcceleration: function (x, y) + { + this.accel.x = x; + this.accel.y = y; + + return this; + } + +}; + +module.exports = Acceleration; + + +/***/ }), +/* 1015 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var H = 0.5; +var N = 1 / 3; +var M = 2 / 3; + +// Tile ID to Slope defs. +// First 4 elements = line data, final = solid or non-solid behind the line + module.exports = { - Utils: __webpack_require__(41), - WebGLPipeline: __webpack_require__(103), - WebGLRenderer: __webpack_require__(371), - Pipelines: __webpack_require__(1004), - - // Constants - BYTE: 0, - SHORT: 1, - UNSIGNED_BYTE: 2, - UNSIGNED_SHORT: 3, - FLOAT: 4 + 2: [ 0, 1, 1, 0, true ], + 3: [ 0, 1, 1, H, true ], + 4: [ 0, H, 1, 0, true ], + 5: [ 0, 1, 1, M, true ], + 6: [ 0, M, 1, N, true ], + 7: [ 0, N, 1, 0, true ], + 8: [ H, 1, 0, 0, true ], + 9: [ 1, 0, H, 1, true ], + 10: [ H, 1, 1, 0, true ], + 11: [ 0, 0, H, 1, true ], + 12: [ 0, 0, 1, 0, false ], + 13: [ 1, 1, 0, 0, true ], + 14: [ 1, H, 0, 0, true ], + 15: [ 1, 1, 0, H, true ], + 16: [ 1, N, 0, 0, true ], + 17: [ 1, M, 0, N, true ], + 18: [ 1, 1, 0, M, true ], + 19: [ 1, 1, H, 0, true ], + 20: [ H, 0, 0, 1, true ], + 21: [ 0, 1, H, 0, true ], + 22: [ H, 0, 1, 1, true ], + 23: [ 1, 1, 0, 1, false ], + 24: [ 0, 0, 1, 1, true ], + 25: [ 0, 0, 1, H, true ], + 26: [ 0, H, 1, 1, true ], + 27: [ 0, 0, 1, N, true ], + 28: [ 0, N, 1, M, true ], + 29: [ 0, M, 1, 1, true ], + 30: [ N, 1, 0, 0, true ], + 31: [ 1, 0, M, 1, true ], + 32: [ M, 1, 1, 0, true ], + 33: [ 0, 0, N, 1, true ], + 34: [ 1, 0, 1, 1, false ], + 35: [ 1, 0, 0, 1, true ], + 36: [ 1, H, 0, 1, true ], + 37: [ 1, 0, 0, H, true ], + 38: [ 1, M, 0, 1, true ], + 39: [ 1, N, 0, M, true ], + 40: [ 1, 0, 0, N, true ], + 41: [ M, 1, N, 0, true ], + 42: [ M, 0, N, 1, true ], + 43: [ N, 1, M, 0, true ], + 44: [ N, 0, M, 1, true ], + 45: [ 0, 1, 0, 0, false ], + 52: [ 1, 1, M, 0, true ], + 53: [ N, 0, 0, 1, true ], + 54: [ 0, 1, N, 0, true ], + 55: [ M, 0, 1, 1, true ] }; /***/ }), -/* 1004 */ +/* 1016 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Set up the trace-result + * var res = { + * collision: {x: false, y: false, slope: false}, + * pos: {x: x, y: y}, + * tile: {x: 0, y: 0} + * }; + * + * @function Phaser.Physics.Impact.UpdateMotion + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body} body - [description] + * @param {object} res - [description] + */ +var UpdateMotion = function (body, res) +{ + body.standing = false; + + // Y + if (res.collision.y) + { + if (body.bounciness > 0 && Math.abs(body.vel.y) > body.minBounceVelocity) + { + body.vel.y *= -body.bounciness; + } + else + { + if (body.vel.y > 0) + { + body.standing = true; + } + + body.vel.y = 0; + } + } + + // X + if (res.collision.x) + { + if (body.bounciness > 0 && Math.abs(body.vel.x) > body.minBounceVelocity) + { + body.vel.x *= -body.bounciness; + } + else + { + body.vel.x = 0; + } + } + + // SLOPE + if (res.collision.slope) + { + var s = res.collision.slope; + + if (body.bounciness > 0) + { + var proj = body.vel.x * s.nx + body.vel.y * s.ny; + + body.vel.x = (body.vel.x - s.nx * proj * 2) * body.bounciness; + body.vel.y = (body.vel.y - s.ny * proj * 2) * body.bounciness; + } + else + { + var lengthSquared = s.x * s.x + s.y * s.y; + var dot = (body.vel.x * s.x + body.vel.y * s.y) / lengthSquared; + + body.vel.x = s.x * dot; + body.vel.y = s.y * dot; + + var angle = Math.atan2(s.x, s.y); + + if (angle > body.slopeStanding.min && angle < body.slopeStanding.max) + { + body.standing = true; + } + } + } + + body.pos.x = res.pos.x; + body.pos.y = res.pos.y; +}; + +module.exports = UpdateMotion; + + +/***/ }), +/* 1017 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(64); + +/** + * [description] + * + * @function Phaser.Physics.Impact.GetVelocity + * @since 3.0.0 + * + * @param {number} delta - [description] + * @param {number} vel - [description] + * @param {number} accel - [description] + * @param {number} friction - [description] + * @param {number} max - [description] + * + * @return {number} [description] + */ +var GetVelocity = function (delta, vel, accel, friction, max) +{ + if (accel) + { + return Clamp(vel + accel * delta, -max, max); + } + else if (friction) + { + var frictionDelta = friction * delta; + + if (vel - frictionDelta > 0) + { + return vel - frictionDelta; + } + else if (vel + frictionDelta < 0) + { + return vel + frictionDelta; + } + else + { + return 0; + } + } + + return Clamp(vel, -max, max); +}; + +module.exports = GetVelocity; + + +/***/ }), +/* 1018 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -135331,19 +137935,129 @@ module.exports = { */ /** - * @namespace Phaser.Renderer.WebGL.Pipelines + * An Impact.js compatible physics world, body and solver, for those who are used + * to the Impact way of defining and controlling physics bodies. Also works with + * the new Loader support for Weltmeister map data. + * + * World updated to run off the Phaser main loop. + * Body extended to support additional setter functions. + * + * To create the map data you'll need Weltmeister, which comes with Impact + * and can be purchased from http://impactjs.com + * + * My thanks to Dominic Szablewski for his permission to support Impact in Phaser. + * + * @namespace Phaser.Physics.Impact */ - module.exports = { - BitmapMaskPipeline: __webpack_require__(373), - FlatTintPipeline: __webpack_require__(374), - ForwardDiffuseLightPipeline: __webpack_require__(165), - TextureTintPipeline: __webpack_require__(166) + Body: __webpack_require__(971), + COLLIDES: __webpack_require__(200), + CollisionMap: __webpack_require__(970), + Factory: __webpack_require__(969), + Image: __webpack_require__(967), + ImpactBody: __webpack_require__(968), + ImpactPhysics: __webpack_require__(1002), + Sprite: __webpack_require__(966), + TYPE: __webpack_require__(199), + World: __webpack_require__(965) }; +/***/ }), +/* 1019 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Physics + */ + +module.exports = { + + Arcade: __webpack_require__(491), + Impact: __webpack_require__(1018), + Matter: __webpack_require__(998) + +}; + + +/***/ }), +/* 1020 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global) {/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +__webpack_require__(953); + +var CONST = __webpack_require__(21); +var Extend = __webpack_require__(18); + +/** +* @namespace Phaser +*/ + +var Phaser = { + + Actions: __webpack_require__(367), + Animation: __webpack_require__(879), + Cache: __webpack_require__(878), + Cameras: __webpack_require__(877), + Class: __webpack_require__(0), + Create: __webpack_require__(866), + Curves: __webpack_require__(860), + Data: __webpack_require__(857), + Display: __webpack_require__(855), + DOM: __webpack_require__(822), + EventEmitter: __webpack_require__(820), + Game: __webpack_require__(819), + GameObjects: __webpack_require__(783), + Geom: __webpack_require__(245), + Input: __webpack_require__(566), + Loader: __webpack_require__(552), + Math: __webpack_require__(534), + Physics: __webpack_require__(1019), + Renderer: __webpack_require__(977), + Scene: __webpack_require__(286), + Scenes: __webpack_require__(461), + Sound: __webpack_require__(459), + Structs: __webpack_require__(458), + Textures: __webpack_require__(457), + Tilemaps: __webpack_require__(455), + Time: __webpack_require__(406), + Tweens: __webpack_require__(404), + Utils: __webpack_require__(400) + +}; + +// Merge in the consts + +Phaser = Extend(false, Phaser, CONST); + +// Export it + +module.exports = Phaser; + +global.Phaser = Phaser; + +/* + * "Documentation is like sex: when it is good, it is very, very good; + * and when it is bad, it is better than nothing." + * -- Dick Brandon + */ + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(369))) + /***/ }) /******/ ]); }); \ No newline at end of file diff --git a/dist/phaser.min.js b/dist/phaser.min.js index 42f3460c4..07f6f7547 100644 --- a/dist/phaser.min.js +++ b/dist/phaser.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Phaser",[],e):"object"==typeof exports?exports.Phaser=e():t.Phaser=e()}("undefined"!=typeof self?self:this,function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=958)}([function(t,e){function i(t,e,i){var n=i?t[e]:Object.getOwnPropertyDescriptor(t,e);return!i&&n.value&&"object"==typeof n.value&&(n=n.value),!(!n||!function(t){return!!t.get&&"function"==typeof t.get||!!t.set&&"function"==typeof t.set}(n))&&(void 0===n.enumerable&&(n.enumerable=!0),void 0===n.configurable&&(n.configurable=!0),n)}function n(t,e){var i=Object.getOwnPropertyDescriptor(t,e);return!!i&&(i.value&&"object"==typeof i.value&&(i=i.value),!1===i.configurable)}function s(t,e,s,r){for(var a in e)if(e.hasOwnProperty(a)){var h=i(e,a,s);if(!1!==h){if(n((r||t).prototype,a)){if(o.ignoreFinals)continue;throw new Error("cannot override final property '"+a+"', set Class.ignoreFinals = true to skip")}Object.defineProperty(t.prototype,a,h)}else t.prototype[a]=e[a]}}function r(t,e){if(e){Array.isArray(e)||(e=[e]);for(var i=0;i0&&(i=1/Math.sqrt(i),this.x=t*i,this.y=e*i),this},normalizeRightHand:function(){var t=this.x;return this.x=-1*this.y,this.y=t,this},dot:function(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.x},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this},transformMat3:function(t){var e=this.x,i=this.y,n=t.val;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this},transformMat4:function(t){var e=this.x,i=this.y,n=t.val;return this.x=n[0]*e+n[4]*i+n[12],this.y=n[1]*e+n[5]*i+n[13],this},reset:function(){return this.x=0,this.y=0,this}});n.ZERO=new n,t.exports=n},function(t,e){var i={},n={install:function(t){for(var e in i)t[e]=i[e]},register:function(t,e){i[t]=e},destroy:function(){i={}}};t.exports=n},function(t,e,i){var n=i(0),s=i(33),r=i(107),o=i(187),a=i(108),h=new n({initialize:function(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x=t,this.y=e,this.width=i,this.height=n},contains:function(t,e){return s(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return a(this,t)},setTo:function(t,e,i,n){return this.x=t,this.y=e,this.width=i,this.height=n,this},setEmpty:function(){return this.setTo(0,0,0,0)},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setSize:function(t,e){return void 0===e&&(e=t),this.width=t,this.height=e,this},isEmpty:function(){return this.width<=0||this.height<=0},getLineA:function(){return{x1:this.x,y1:this.y,x2:this.right,y2:this.y}},getLineB:function(){return{x1:this.right,y1:this.y,x2:this.right,y2:this.bottom}},getLineC:function(){return{x1:this.right,y1:this.bottom,x2:this.x,y2:this.bottom}},getLineD:function(){return{x1:this.x,y1:this.bottom,x2:this.x,y2:this.y}},left:{get:function(){return this.x},set:function(t){t>=this.right?this.width=0:this.width=this.right-t,this.x=t}},right:{get:function(){return this.x+this.width},set:function(t){t<=this.x?this.width=0:this.width=t-this.x}},top:{get:function(){return this.y},set:function(t){t>=this.bottom?this.height=0:this.height=this.bottom-t,this.y=t}},bottom:{get:function(){return this.y+this.height},set:function(t){t<=this.y?this.height=0:this.height=t-this.y}},centerX:{get:function(){return this.x+this.width/2},set:function(t){this.x=t-this.width/2}},centerY:{get:function(){return this.y+this.height/2},set:function(t){this.y=t-this.height/2}}});t.exports=h},function(t,e,i){var n=i(0),s=i(12),r=new n({initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),this.displayList,this.updateList},boot:function(){this.displayList=this.systems.displayList,this.updateList=this.systems.updateList;var t=this.systems.events;t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},existing:function(t){return(t.renderCanvas||t.renderWebGL)&&this.displayList.add(t),t.preUpdate&&this.updateList.add(t),t},shutdown:function(){},destroy:function(){this.scene=null,this.displayList=null,this.updateList=null}});r.register=function(t,e){r.prototype.hasOwnProperty(t)||(r.prototype[t]=e)},s.register("GameObjectFactory",r,"add"),t.exports=r},function(t,e,i){var n=i(16),s=i(4);t.exports=function(t,e,i){var r=s(t,e,null);if(null===r)return i;if(Array.isArray(r))return n.RND.pick(r);if("object"==typeof r){if(r.hasOwnProperty("randInt"))return n.RND.integerInRange(r.randInt[0],r.randInt[1]);if(r.hasOwnProperty("randFloat"))return n.RND.realInRange(r.randFloat[0],r.randFloat[1])}else if("function"==typeof r)return r(e);return r}},function(t,e,i){t.exports={Alpha:i(391),Animation:i(365),BlendMode:i(392),ComputedSize:i(393),Depth:i(394),Flip:i(395),GetBounds:i(396),MatrixStack:i(397),Origin:i(398),Pipeline:i(189),ScaleMode:i(399),ScrollFactor:i(400),Size:i(401),Texture:i(402),Tint:i(403),ToJSON:i(404),Transform:i(405),TransformMatrix:i(190),Visible:i(406)}},function(t,e,i){var n=i(0),s={},r=new n({initialize:function(t){this.game=t,t.events.once("boot",this.boot,this)},boot:function(){this.game.events.once("destroy",this.destroy,this)},installGlobal:function(t,e){for(var i=t.game,n=t.scene,s=t.settings.map,r=0;ro.width&&(i=Math.max(o.width-t,0)),e+s>o.height&&(s=Math.max(o.height-e,0));for(var u=[],c=e;c0&&e>=t.left&&e<=t.right&&i>=t.top&&i<=t.bottom&&(t.x-e)*(t.x-e)+(t.y-i)*(t.y-i)<=t.radius*t.radius}},function(t,e){t.exports=function(t,e,i){return!(t.width<=0||t.height<=0)&&t.x<=e&&t.x+t.width>=e&&t.y<=i&&t.y+t.height>=i}},function(t,e,i){var n=i(97),s=i(15);t.exports=function(t,e,i,r,o){for(var a=null,h=null,l=null,u=null,c=s(t,e,i,r,null,o),d=0;d0;e--){var n=Math.floor(i.random()*(e+1)),s=t[e];t[e]=t[n],t[n]=s}return t},i.choose=function(t){return t[Math.floor(i.random()*t.length)]},i.isElement=function(t){return t instanceof HTMLElement},i.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},i.isFunction=function(t){return"function"==typeof t},i.isPlainObject=function(t){return"object"==typeof t&&t.constructor===Object},i.isString=function(t){return"[object String]"===Object.prototype.toString.call(t)},i.clamp=function(t,e,i){return ti?i:t},i.sign=function(t){return t<0?-1:1},i.now=function(){if(window.performance){if(window.performance.now)return window.performance.now();if(window.performance.webkitNow)return window.performance.webkitNow()}return new Date-i._nowStartTime},i.random=function(e,i){return i=void 0!==i?i:1,(e=void 0!==e?e:0)+t()*(i-e)};var t=function(){return i._seed=(9301*i._seed+49297)%233280,i._seed/233280};i.colorToNumber=function(t){return 3==(t=t.replace("#","")).length&&(t=t.charAt(0)+t.charAt(0)+t.charAt(1)+t.charAt(1)+t.charAt(2)+t.charAt(2)),parseInt(t,16)},i.logLevel=1,i.log=function(){console&&i.logLevel>0&&i.logLevel<=3&&console.log.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},i.info=function(){console&&i.logLevel>0&&i.logLevel<=2&&console.info.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},i.warn=function(){console&&i.logLevel>0&&i.logLevel<=3&&console.warn.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},i.nextId=function(){return i._nextId++},i.map=function(t,e){if(t.map)return t.map(e);for(var i=[],n=0;n>>0},getTintAppendFloatAlpha:function(t,e){return((255&(255*e|0))<<24|t)>>>0},getTintAppendFloatAlphaAndSwap:function(t,e){return((255&(255*e|0))<<24|(255&(0|t))<<16|(255&(t>>8|0))<<8|255&(t>>16|0))>>>0},getFloatsFromUintRGB:function(t){return[(255&(t>>16|0))/255,(255&(t>>8|0))/255,(255&(0|t))/255]},getComponentCount:function(t,e){for(var i=0,n=0;nthis.right||e>this.bottom)},copy:function(t){return this.index=t.index,this.alpha=t.alpha,this.properties=t.properties,this.visible=t.visible,this.setFlip(t.flipX,t.flipY),this.tint=t.tint,this.rotation=t.rotation,this.collideUp=t.collideUp,this.collideDown=t.collideDown,this.collideLeft=t.collideLeft,this.collideRight=t.collideRight,this.collisionCallback=t.collisionCallback,this.collisionCallbackContext=t.collisionCallbackContext,this},getCollisionGroup:function(){return this.tileset?this.tileset.getTileCollisionGroup(this.index):null},getTileData:function(){return this.tileset?this.tileset.getTileData(this.index):null},getLeft:function(t){var e=this.tilemapLayer;return e?e.tileToWorldX(this.x,t):this.x*this.baseWidth},getRight:function(t){var e=this.tilemapLayer;return e?this.getLeft(t)+this.width*e.scaleX:this.getLeft(t)+this.width},getTop:function(t){var e=this.tilemapLayer;return e?e.tileToWorldY(this.y,t)-(this.height-this.baseHeight)*e.scaleY:this.y*this.baseHeight-(this.height-this.baseHeight)},getBottom:function(t){var e=this.tilemapLayer;return e?this.getTop(t)+this.height*e.scaleY:this.getTop(t)+this.height},getBounds:function(t,e){return void 0===e&&(e=new r),e.x=this.getLeft(),e.y=this.getTop(),e.width=this.getRight()-e.x,e.height=this.getBottom()-e.y,e},getCenterX:function(t){return this.getLeft(t)+this.width/2},getCenterY:function(t){return this.getTop(t)+this.height/2},destroy:function(){this.collisionCallback=void 0,this.collisionCallbackContext=void 0,this.properties=void 0},intersects:function(t,e,i,n){return!(i<=this.pixelX||n<=this.pixelY||t>=this.right||e>=this.bottom)},isInteresting:function(t,e){return t&&e?this.canCollide||this.hasInterestingFace:t?this.collides:!!e&&this.hasInterestingFace},resetCollision:function(t){(void 0===t&&(t=!0),this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,t)&&(this.tilemapLayer&&this.tilemapLayer.calculateFacesAt(this.x,this.y));return this},resetFaces:function(){return this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,this},setCollision:function(t,e,i,n,s){(void 0===e&&(e=t),void 0===i&&(i=t),void 0===n&&(n=t),void 0===s&&(s=!0),this.collideLeft=t,this.collideRight=e,this.collideUp=i,this.collideDown=n,this.faceLeft=t,this.faceRight=e,this.faceTop=i,this.faceBottom=n,s)&&(this.tilemapLayer&&this.tilemapLayer.calculateFacesAt(this.x,this.y));return this},setCollisionCallback:function(t,e){return null===t?(this.collisionCallback=void 0,this.collisionCallbackContext=void 0):(this.collisionCallback=t,this.collisionCallbackContext=e),this},setSize:function(t,e,i,n){return void 0!==t&&(this.width=t),void 0!==e&&(this.height=e),void 0!==i&&(this.baseWidth=i),void 0!==n&&(this.baseHeight=n),this.updatePixelXY(),this},updatePixelXY:function(){return this.pixelX=this.x*this.baseWidth,this.pixelY=this.y*this.baseHeight-(this.height-this.baseHeight),this},canCollide:{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.collisionCallback}},collides:{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown}},hasInterestingFace:{get:function(){return this.faceTop||this.faceBottom||this.faceLeft||this.faceRight}},tileset:{get:function(){var t=this.tilemapLayer;return t?t.tileset:null}},tilemapLayer:{get:function(){return this.layer.tilemapLayer}},tilemap:{get:function(){var t=this.tilemapLayer;return t?t.tilemap:null}}});t.exports=o},function(t,e){t.exports={SKIP_CHECK:-1,NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16}},function(t,e){t.exports=function(t){return t.x-t.width*t.originX+.5*t.width}},function(t,e){t.exports=function(t,e){var i=t.width*t.originX;return t.x=e+i-.5*t.width,t}},function(t,e){t.exports=function(t,e){var i=t.height*t.originY;return t.y=e+i-.5*t.height,t}},function(t,e){t.exports=function(t){return t.y-t.height*t.originY+.5*t.height}},function(t,e){t.exports=function(t,e,i){var n=i-e;return e+((t-e)%n+n)%n}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i){"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0):(this.x=t||0,this.y=e||0,this.z=i||0)},up:function(){return this.x=0,this.y=1,this.z=0,this},clone:function(){return new n(this.x,this.y,this.z)},crossVectors:function(t,e){var i=t.x,n=t.y,s=t.z,r=e.x,o=e.y,a=e.z;return this.x=n*a-s*o,this.y=s*r-i*a,this.z=i*o-n*r,this},equals:function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this},set:function(t,e,i){return"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0):(this.x=t||0,this.y=e||0,this.z=i||0),this},add:function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this},subtract:function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z||0,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z||1,this},scale:function(t){return isFinite(t)?(this.x*=t,this.y*=t,this.z*=t):(this.x=0,this.y=0,this.z=0),this},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z||1,this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},distance:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0;return Math.sqrt(e*e+i*i+n*n)},distanceSq:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0;return e*e+i*i+n*n},length:function(){var t=this.x,e=this.y,i=this.z;return Math.sqrt(t*t+e*e+i*i)},lengthSq:function(){var t=this.x,e=this.y,i=this.z;return t*t+e*e+i*i},normalize:function(){var t=this.x,e=this.y,i=this.z,n=t*t+e*e+i*i;return n>0&&(n=1/Math.sqrt(n),this.x=t*n,this.y=e*n,this.z=i*n),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},cross:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z;return this.x=i*o-n*r,this.y=n*s-e*o,this.z=e*r-i*s,this},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this},transformMat3:function(t){var e=this.x,i=this.y,n=this.z,s=t.val;return this.x=e*s[0]+i*s[3]+n*s[6],this.y=e*s[1]+i*s[4]+n*s[7],this.z=e*s[2]+i*s[5]+n*s[8],this},transformMat4:function(t){var e=this.x,i=this.y,n=this.z,s=t.val;return this.x=s[0]*e+s[4]*i+s[8]*n+s[12],this.y=s[1]*e+s[5]*i+s[9]*n+s[13],this.z=s[2]*e+s[6]*i+s[10]*n+s[14],this},transformCoordinates:function(t){var e=this.x,i=this.y,n=this.z,s=t.val,r=e*s[0]+i*s[4]+n*s[8]+s[12],o=e*s[1]+i*s[5]+n*s[9]+s[13],a=e*s[2]+i*s[6]+n*s[10]+s[14],h=e*s[3]+i*s[7]+n*s[11]+s[15];return this.x=r/h,this.y=o/h,this.z=a/h,this},transformQuat:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z,a=t.w,h=a*e+r*n-o*i,l=a*i+o*e-s*n,u=a*n+s*i-r*e,c=-s*e-r*i-o*n;return this.x=h*a+c*-s+l*-o-u*-r,this.y=l*a+c*-r+u*-s-h*-o,this.z=u*a+c*-o+h*-r-l*-s,this},project:function(t){var e=this.x,i=this.y,n=this.z,s=t.val,r=s[0],o=s[1],a=s[2],h=s[3],l=s[4],u=s[5],c=s[6],d=s[7],f=s[8],p=s[9],g=s[10],v=s[11],y=s[12],m=s[13],x=s[14],b=1/(e*h+i*d+n*v+s[15]);return this.x=(e*r+i*l+n*f+y)*b,this.y=(e*o+i*u+n*p+m)*b,this.z=(e*a+i*c+n*g+x)*b,this},unproject:function(t,e){var i=t.x,n=t.y,s=t.z,r=t.w,o=this.x-i,a=r-this.y-1-n,h=this.z;return this.x=2*o/s-1,this.y=2*a/r-1,this.z=2*h-1,this.project(e)},reset:function(){return this.x=0,this.y=0,this.z=0,this}});t.exports=n},function(t,e,i){var n=i(0),s=i(122),r=i(8),o=i(6),a=new n({initialize:function(t){this.type=t,this.defaultDivisions=5,this.arcLengthDivisions=100,this.cacheArcLengths=[],this.needsUpdate=!0,this.active=!0,this._tmpVec2A=new o,this._tmpVec2B=new o},draw:function(t,e){return void 0===e&&(e=32),t.strokePoints(this.getPoints(e))},getBounds:function(t,e){t||(t=new r),void 0===e&&(e=16);var i=this.getLength();e>i&&(e=i/2);var n=Math.max(1,Math.round(i/e));return s(this.getSpacedPoints(n),t)},getDistancePoints:function(t){var e=this.getLength(),i=Math.max(1,e/t);return this.getSpacedPoints(i)},getEndPoint:function(t){return void 0===t&&(t=new o),this.getPointAt(1,t)},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,i=[],n=this.getPoint(0,this._tmpVec2A),s=0;i.push(0);for(var r=1;r<=t;r++)s+=(e=this.getPoint(r/t,this._tmpVec2B)).distance(n),i.push(s),n.copy(e);return this.cacheArcLengths=i,i},getPointAt:function(t,e){var i=this.getUtoTmapping(t);return this.getPoint(i,e)},getPoints:function(t){void 0===t&&(t=this.defaultDivisions);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return e},getRandomPoint:function(t){return void 0===t&&(t=new o),this.getPoint(Math.random(),t)},getSpacedPoints:function(t){void 0===t&&(t=this.defaultDivisions);for(var e=[],i=0;i<=t;i++){var n=this.getUtoTmapping(i/t,null,t);e.push(this.getPoint(n))}return e},getStartPoint:function(t){return void 0===t&&(t=new o),this.getPointAt(0,t)},getTangent:function(t,e){void 0===e&&(e=new o);var i=t-1e-4,n=t+1e-4;return i<0&&(i=0),n>1&&(n=1),this.getPoint(i,this._tmpVec2A),this.getPoint(n,e),e.subtract(this._tmpVec2A).normalize()},getTangentAt:function(t,e){var i=this.getUtoTmapping(t);return this.getTangent(i,e)},getTFromDistance:function(t,e){return t<=0?0:this.getUtoTmapping(0,t,e)},getUtoTmapping:function(t,e,i){var n,s=this.getLengths(i),r=0,o=s.length;n=e?Math.min(e,s[o-1]):t*s[o-1];for(var a,h=0,l=o-1;h<=l;)if((a=s[r=Math.floor(h+(l-h)/2)]-n)<0)h=r+1;else{if(!(a>0)){l=r;break}l=r-1}if(s[r=l]===n)return r/(o-1);var u=s[r];return(r+(n-u)/(s[r+1]-u))/(o-1)},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()}});t.exports=a},function(t,e){t.exports=function(t){var e={};for(var i in t)Array.isArray(t[i])?e[i]=t[i].slice(0):e[i]=t[i];return e}},function(t,e){t.exports=function(t,e,i){var n=t.x3-t.x1,s=t.y3-t.y1,r=t.x2-t.x1,o=t.y2-t.y1,a=e-t.x1,h=i-t.y1,l=n*n+s*s,u=n*r+s*o,c=n*a+s*h,d=r*r+o*o,f=r*a+o*h,p=l*d-u*u,g=0===p?0:1/p,v=(d*c-u*f)*g,y=(l*f-u*c)*g;return v>=0&&y>=0&&v+y<1}},function(t,e){t.exports=function(t){return Math.atan2(t.y2-t.y1,t.x2-t.x1)}},function(t,e,i){var n=i(0),s=i(54),r=i(309),o=i(310),a=i(112),h=new n({initialize:function(t,e,i,n,s,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===s&&(s=0),void 0===r&&(r=0),this.x1=t,this.y1=e,this.x2=i,this.y2=n,this.x3=s,this.y3=r},contains:function(t,e){return s(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return a(this,t)},setTo:function(t,e,i,n,s,r){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===s&&(s=0),void 0===r&&(r=0),this.x1=t,this.y1=e,this.x2=i,this.y2=n,this.x3=s,this.y3=r,this},getLineA:function(){return{x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2}},getLineB:function(){return{x1:this.x2,y1:this.y2,x2:this.x3,y2:this.y3}},getLineC:function(){return{x1:this.x3,y1:this.y3,x2:this.x1,y2:this.y1}},left:{get:function(){return Math.min(this.x1,this.x2,this.x3)},set:function(t){var e=0;e=this.x1<=this.x2&&this.x1<=this.x3?this.x1-t:this.x2<=this.x1&&this.x2<=this.x3?this.x2-t:this.x3-t,this.x1-=e,this.x2-=e,this.x3-=e}},right:{get:function(){return Math.max(this.x1,this.x2,this.x3)},set:function(t){var e=0;e=this.x1>=this.x2&&this.x1>=this.x3?this.x1-t:this.x2>=this.x1&&this.x2>=this.x3?this.x2-t:this.x3-t,this.x1-=e,this.x2-=e,this.x3-=e}},top:{get:function(){return Math.min(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1<=this.y2&&this.y1<=this.y3?this.y1-t:this.y2<=this.y1&&this.y2<=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}},bottom:{get:function(){return Math.max(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1>=this.y2&&this.y1>=this.y3?this.y1-t:this.y2>=this.y1&&this.y2>=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}}});t.exports=h},function(t,e,i){var n=i(0),s=i(17),r=i(18),o=i(7),a=i(2),h=new n({Extends:r,initialize:function(t,e,i,n){var o="string"==typeof t?t:a(t,"key",""),h={type:"json",extension:a(t,"extension","json"),responseType:"text",key:o,url:a(t,"file",e),path:i,xhrSettings:a(t,"xhr",n)};r.call(this,h),"object"==typeof h.url&&(this.data=h.url,this.state=s.FILE_POPULATED)},onProcess:function(t){this.state=s.FILE_PROCESSING,this.data=JSON.parse(this.xhrLoader.responseText),this.onComplete(),t(this)}});o.register("json",function(t,e,i){if(Array.isArray(t))for(var n=0;n0&&r.rotateAbout(o.position,i,t.position,o.position)}},n.setVelocity=function(t,e){t.positionPrev.x=t.position.x-e.x,t.positionPrev.y=t.position.y-e.y,t.velocity.x=e.x,t.velocity.y=e.y,t.speed=r.magnitude(t.velocity)},n.setAngularVelocity=function(t,e){t.anglePrev=t.angle-e,t.angularVelocity=e,t.angularSpeed=Math.abs(t.angularVelocity)},n.translate=function(t,e){n.setPosition(t,r.add(t.position,e))},n.rotate=function(t,e,i){if(i){var s=Math.cos(e),r=Math.sin(e),o=t.position.x-i.x,a=t.position.y-i.y;n.setPosition(t,{x:i.x+(o*s-a*r),y:i.y+(o*r+a*s)}),n.setAngle(t,t.angle+e)}else n.setAngle(t,t.angle+e)},n.scale=function(t,i,r,o){o=o||t.position;for(var a=0;a0&&(f.position.x+=t.velocity.x,f.position.y+=t.velocity.y),0!==t.angularVelocity&&(s.rotate(f.vertices,t.angularVelocity,t.position),l.rotate(f.axes,t.angularVelocity),d>0&&r.rotateAbout(f.position,t.angularVelocity,t.position,f.position)),h.update(f.bounds,f.vertices,t.velocity)}},n.applyForce=function(t,e,i){t.force.x+=i.x,t.force.y+=i.y;var n=e.x-t.position.x,s=e.y-t.position.y;t.torque+=n*i.y-s*i.x};var e=function(t){for(var e={mass:0,area:0,inertia:0,centre:{x:0,y:0}},i=1===t.parts.length?0:1;i-1&&this.entries.splice(e,1),this},dump:function(){console.group("Set");for(var t=0;t-1},union:function(t){var e=new n;return t.entries.forEach(function(t){e.set(t)}),this.entries.forEach(function(t){e.set(t)}),e},intersect:function(t){var e=new n;return this.entries.forEach(function(i){t.contains(i)&&e.set(i)}),e},difference:function(t){var e=new n;return this.entries.forEach(function(i){t.contains(i)||e.set(i)}),e},size:{get:function(){return this.entries.length},set:function(t){return this.entries.length=t}}});t.exports=n},function(t,e){t.exports={DEFAULT:0,LINEAR:0,NEAREST:1}},function(t,e,i){var n=i(0),s=i(32),r=i(184),o=i(185),a=i(106),h=new n({initialize:function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.x=t,this.y=e,this._radius=i,this._diameter=2*i},contains:function(t,e){return s(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return a(this,t)},setTo:function(t,e,i){return this.x=t,this.y=e,this._radius=i,this._diameter=2*i,this},setEmpty:function(){return this._radius=0,this._diameter=0,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},isEmpty:function(){return this._radius<=0},radius:{get:function(){return this._radius},set:function(t){this._radius=t,this._diameter=2*t}},diameter:{get:function(){return this._diameter},set:function(t){this._diameter=t,this._radius=.5*t}},left:{get:function(){return this.x-this._radius},set:function(t){this.x=t+this._radius}},right:{get:function(){return this.x+this._radius},set:function(t){this.x=t-this._radius}},top:{get:function(){return this.y-this._radius},set:function(t){this.y=t+this._radius}},bottom:{get:function(){return this.y+this._radius},set:function(t){this.y=t-this._radius}}});t.exports=h},function(t,e,i){var n=i(61);t.exports=function(t,e,i){return(i-e)*(t=n(t,0,1))}},function(t,e){t.exports=function(t){return Math.sqrt((t.x2-t.x1)*(t.x2-t.x1)+(t.y2-t.y1)*(t.y2-t.y1))}},function(t,e,i){(function(e){var i={android:!1,chromeOS:!1,cocoonJS:!1,cocoonJSApp:!1,cordova:!1,crosswalk:!1,desktop:!1,ejecta:!1,electron:!1,iOS:!1,iOSVersion:0,iPad:!1,iPhone:!1,kindle:!1,linux:!1,macOS:!1,node:!1,nodeWebkit:!1,pixelRatio:1,webApp:!1,windows:!1,windowsPhone:!1};t.exports=function(){var t=navigator.userAgent;/Windows/.test(t)?i.windows=!0:/Mac OS/.test(t)?i.macOS=!0:/Linux/.test(t)?i.linux=!0:/Android/.test(t)?i.android=!0:/iP[ao]d|iPhone/i.test(t)?(i.iOS=!0,navigator.appVersion.match(/OS (\d+)/),i.iOSVersion=parseInt(RegExp.$1,10)):/Kindle/.test(t)||/\bKF[A-Z][A-Z]+/.test(t)||/Silk.*Mobile Safari/.test(t)?i.kindle=!0:/CrOS/.test(t)&&(i.chromeOS=!0),(/Windows Phone/i.test(t)||/IEMobile/i.test(t))&&(i.android=!1,i.iOS=!1,i.macOS=!1,i.windows=!0,i.windowsPhone=!0);var n=/Silk/.test(t);if((i.windows||i.macOS||i.linux&&!n||i.chromeOS)&&(i.desktop=!0),(i.windowsPhone||/Windows NT/i.test(t)&&/Touch/i.test(t))&&(i.desktop=!1),navigator.standalone&&(i.webApp=!0),void 0!==window.cordova&&(i.cordova=!0),void 0!==e&&void 0!==e.versions.node&&(i.node=!0),i.node&&"object"==typeof e.versions&&(i.nodeWebkit=!!e.versions["node-webkit"],i.electron=!!e.versions.electron),navigator.isCocoonJS){i.cocoonJS=!0;try{i.cocoonJSApp="undefined"!=typeof CocoonJS}catch(t){i.cocoonJSApp=!1}}return void 0!==window.ejecta&&(i.ejecta=!0),/Crosswalk/.test(t)&&(i.crosswalk=!0),i.iPhone=-1!==t.toLowerCase().indexOf("iphone"),i.iPad=-1!==t.toLowerCase().indexOf("ipad"),i.pixelRatio=window.devicePixelRatio||1,i}()}).call(e,i(506))},function(t,e){t.exports=function(t,e,i){if(t.width<=0||t.height<=0)return!1;var n=(e-t.x)/t.width,s=(i-t.y)/t.height;return(n*=n)+(s*=s)<.25}},function(t,e,i){var n=i(171),s=i(0),r=i(2),o=i(4),a=i(275),h=i(62),l=i(37),u=new s({initialize:function(t,e,i){void 0!==i||Array.isArray(e)||"object"!=typeof e||(i=e,e=null),this.scene=t,this.children=new h(e),this.isParent=!0,this.classType=r(i,"classType",l),this.active=r(i,"active",!0),this.maxSize=r(i,"maxSize",-1),this.defaultKey=r(i,"defaultKey",null),this.defaultFrame=r(i,"defaultFrame",null),this.runChildUpdate=r(i,"runChildUpdate",!1),this.createCallback=r(i,"createCallback",null),this.removeCallback=r(i,"removeCallback",null),this.createMultipleCallback=r(i,"createMultipleCallback",null),i&&this.createMultiple(i)},create:function(t,e,i,n,s){if(void 0===i&&(i=this.defaultKey),void 0===n&&(n=this.defaultFrame),void 0===s&&(s=!0),this.isFull())return null;var r=new this.classType(this.scene,t,e,i,n);return this.scene.sys.displayList.add(r),r.preUpdate&&this.scene.sys.updateList.add(r),r.visible=s,this.add(r),r},createMultiple:function(t){Array.isArray(t)||(t=[t]);for(var e=[],i=0;i=0&&t=0&&e0){this.blockSet=!1;var i=this;if(this.events.emit("changedata",this.parent,t,e,function(e){i.blockSet=!0,i.list[t]=e,i.events.emit("setdata",i.parent,t,e)}),this.blockSet)return this}return this.list[t]=e,this.events.emit("setdata",this.parent,t,e),this},each:function(t,e){for(var i=[this.parent,null,void 0],n=1;n0;e--){var i=Math.floor(Math.random()*(e+1)),n=t[e];t[e]=t[i],t[i]=n}return t}},function(t,e,i){var n=i(0),s=i(1),r=i(37),o=i(6),a=i(120),h=new n({Extends:s,initialize:function(t,e,i,n,h,l){s.call(this,t,"Sprite3D"),this.gameObject=new r(t,0,0,h,l),this.position=new a(e,i,n),this.size=new o(this.gameObject.width,this.gameObject.height),this.scale=new o(1,1),this.adjustScaleX=!0,this.adjustScaleY=!0,this._visible=!0},project:function(t){var e=this.position,i=this.gameObject;t.project(e,i),t.getPointSize(e,this.size,this.scale),this.scale.x<=0||this.scale.y<=0?i.setVisible(!1):(i.visible||i.setVisible(!0),this.adjustScaleX&&(i.scaleX=this.scale.x),this.adjustScaleY&&(i.scaleY=this.scale.y),i.setDepth(-1*i.z))},setVisible:function(t){return this.visible=t,this},visible:{get:function(){return this._visible},set:function(t){this._visible=t,this.gameObject.visible=t}},x:{get:function(){return this.position.x},set:function(t){this.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t}},z:{get:function(){return this.position.z},set:function(t){this.position.z=t}}});t.exports=h},function(t,e,i){var n,s=i(67),r={chrome:!1,chromeVersion:0,edge:!1,firefox:!1,firefoxVersion:0,ie:!1,ieVersion:0,mobileSafari:!1,opera:!1,safari:!1,safariVersion:0,silk:!1,trident:!1,tridentVersion:0};t.exports=(n=navigator.userAgent,/Edge\/\d+/.test(n)?r.edge=!0:/Chrome\/(\d+)/.test(n)&&!s.windowsPhone?(r.chrome=!0,r.chromeVersion=parseInt(RegExp.$1,10)):/Firefox\D+(\d+)/.test(n)?(r.firefox=!0,r.firefoxVersion=parseInt(RegExp.$1,10)):/AppleWebKit/.test(n)&&s.iOS?r.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(n)?(r.ie=!0,r.ieVersion=parseInt(RegExp.$1,10)):/Opera/.test(n)?r.opera=!0:/Safari/.test(n)&&!s.windowsPhone?r.safari=!0:/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(n)&&(r.ie=!0,r.trident=!0,r.tridentVersion=parseInt(RegExp.$1,10),r.ieVersion=parseInt(RegExp.$3,10)),/Silk/.test(n)&&(r.silk=!0),r)},function(t,e){t.exports={PENDING:0,INIT:1,START:2,LOADING:3,CREATING:4,RUNNING:5,PAUSED:6,SLEEPING:7,SHUTDOWN:8,DESTROYED:9}},function(t,e,i){var n=i(0),s=i(14),r=i(3),o=new n({Extends:s,initialize:function(t){s.call(this),this.game=t,this.sounds=[],this.mute=!1,this.volume=1,this.pauseOnBlur=!0,t.events.on("blur",function(){this.pauseOnBlur&&this.onBlur()},this),t.events.on("focus",function(){this.pauseOnBlur&&this.onFocus()},this),t.events.once("destroy",this.destroy,this),this._rate=1,this._detune=0,this.locked=this.locked||!1,this.unlocked=!1,this.locked&&this.unlock()},add:r,addAudioSprite:function(t,e){var i=this.add(t,e);for(var n in i.spritemap=this.game.cache.json.get(t).spritemap,i.spritemap)if(i.spritemap.hasOwnProperty(n)){var s=i.spritemap[n];i.addMarker({name:n,start:s.start,duration:s.end-s.start,config:e})}return i},play:function(t,e){var i=this.add(t);return i.once("ended",i.destroy,i),e?e.name?(i.addMarker(e),i.play(e.name)):i.play(e):i.play()},playAudioSprite:function(t,e,i){var n=this.addAudioSprite(t);return n.once("ended",n.destroy,n),n.play(e,i)},remove:function(t){var e=this.sounds.indexOf(t);return-1!==e&&(t.destroy(),this.sounds.splice(e,1),!0)},removeByKey:function(t){for(var e=0,i=this.sounds.length-1;i>=0;i--){var n=this.sounds[i];n.key===t&&(n.destroy(),this.sounds.splice(i,1),e++)}return e},pauseAll:function(){this.forEachActiveSound(function(t){t.pause()}),this.emit("pauseall",this)},resumeAll:function(){this.forEachActiveSound(function(t){t.resume()}),this.emit("resumeall",this)},stopAll:function(){this.forEachActiveSound(function(t){t.stop()}),this.emit("stopall",this)},unlock:r,onBlur:r,onFocus:r,update:function(t,e){this.unlocked&&(this.unlocked=!1,this.locked=!1,this.emit("unlocked",this));for(var i=this.sounds.length-1;i>=0;i--)this.sounds[i].pendingRemove&&this.sounds.splice(i,1);this.sounds.forEach(function(i){i.update(t,e)})},destroy:function(){this.removeAllListeners(),this.forEachActiveSound(function(t){t.destroy()}),this.sounds.length=0,this.sounds=null,this.game=null},forEachActiveSound:function(t,e){var i=this;this.sounds.forEach(function(n,s){n.pendingRemove||t.call(e||i,n,s,i.sounds)})},rate:{get:function(){return this._rate},set:function(t){this._rate=t,this.forEachActiveSound(function(t){t.setRate()}),this.emit("rate",this,t)}},detune:{get:function(){return this._detune},set:function(t){this._detune=t,this.forEachActiveSound(function(t){t.setRate()}),this.emit("detune",this,t)}}});t.exports=o},function(t,e,i){var n=i(0),s=i(14),r=i(23),o=i(3),a=new n({Extends:s,initialize:function(t,e,i){s.call(this),this.manager=t,this.key=e,this.isPlaying=!1,this.isPaused=!1,this.totalRate=1,this.duration=this.duration||0,this.totalDuration=this.totalDuration||0,this.config={delay:0},this.currentConfig=this.config,this.mute=!1,this.volume=1,this.rate=1,this.detune=0,this.seek=0,this.loop=!1,this.config=r(this.config,i),this.markers={},this.currentMarker=null,this.pendingRemove=!1},addMarker:function(t){return!(!t||!t.name||"string"!=typeof t.name)&&(this.markers[t.name]?(console.error("addMarker - Marker with name '"+t.name+"' already exists for sound '"+this.key+"'!"),!1):(t=r(!0,{name:"",start:0,duration:this.totalDuration-(t.start||0),config:{mute:!1,volume:1,rate:1,detune:0,seek:0,loop:!1,delay:0}},t),this.markers[t.name]=t,!0))},updateMarker:function(t){return!(!t||!t.name||"string"!=typeof t.name)&&(this.markers[t.name]?(this.markers[t.name]=r(!0,this.markers[t.name],t),!0):(console.error("updateMarker - Marker with name '"+t.name+"' does not exist for sound '"+this.key+"'!"),!1))},removeMarker:function(t){var e=this.markers[t];return e?(this.markers[t]=null,e):null},play:function(t,e){if(void 0===t&&(t=""),"object"==typeof t&&(e=t,t=""),"string"!=typeof t)return console.error("Sound marker name has to be a string!"),!1;if(t){if(!this.markers[t])return console.error("No marker with name '"+t+"' found for sound '"+this.key+"'!"),!1;this.currentMarker=this.markers[t],this.currentConfig=this.currentMarker.config,this.duration=this.currentMarker.duration}else this.currentMarker=null,this.currentConfig=this.config,this.duration=this.totalDuration;return this.resetConfig(),this.currentConfig=r(this.currentConfig,e),this.isPlaying=!0,this.isPaused=!1,!0},pause:function(){return!(this.isPaused||!this.isPlaying)&&(this.isPlaying=!1,this.isPaused=!0,!0)},resume:function(){return!(!this.isPaused||this.isPlaying)&&(this.isPlaying=!0,this.isPaused=!1,!0)},stop:function(){return!(!this.isPaused&&!this.isPlaying)&&(this.isPlaying=!1,this.isPaused=!1,this.resetConfig(),!0)},applyConfig:function(){this.mute=this.currentConfig.mute,this.volume=this.currentConfig.volume,this.rate=this.currentConfig.rate,this.detune=this.currentConfig.detune,this.loop=this.currentConfig.loop},resetConfig:function(){this.currentConfig.seek=0,this.currentConfig.delay=0},update:o,destroy:function(){this.pendingRemove||(this.pendingRemove=!0,this.manager=null,this.key="",this.removeAllListeners(),this.isPlaying=!1,this.isPaused=!1,this.config=null,this.currentConfig=null,this.markers=null,this.currentMarker=null)},setRate:function(){var t=this.currentConfig.detune+this.manager.detune,e=Math.pow(1.0005777895065548,t);this.totalRate=this.currentConfig.rate*this.manager.rate*e}});Object.defineProperty(a.prototype,"rate",{get:function(){return this.currentConfig.rate},set:function(t){this.currentConfig.rate=t,this.setRate(),this.emit("rate",this,t)}}),Object.defineProperty(a.prototype,"detune",{get:function(){return this.currentConfig.detune},set:function(t){this.currentConfig.detune=t,this.setRate(),this.emit("detune",this,t)}}),t.exports=a},function(t,e,i){var n=new(i(0))({initialize:function(t){this.parent=t,this.list=[],this.position=0},add:function(t){return-1===this.getIndex(t)&&this.list.push(t),t},addAt:function(t,e){return void 0===e&&(e=0),0===this.list.length?this.add(t):(e>=0&&e<=this.list.length&&-1===this.getIndex(t)&&this.list.splice(e,0,t),t)},addMultiple:function(t){if(Array.isArray(t))for(var e=0;en?1:0},getByKey:function(t,e){for(var i=0;ithis.list.length)return null;var i=t+Math.floor(Math.random()*e);return this.list[i]},getFirst:function(t,e,i,n){void 0===i&&(i=0),void 0===n&&(n=this.list.length);for(var s=i;s=this.list.length)throw new Error("List.moveTo: The supplied index is out of bounds");return this.list.splice(i,1),this.list.splice(e,0,t),t},remove:function(t){var e=this.list.indexOf(t);return-1!==e&&this.list.splice(e,1),t},removeAt:function(t){var e=this.list[t];return e&&this.children.splice(t,1),e},removeBetween:function(t,e){void 0===t&&(t=0),void 0===e&&(e=this.list.length);var i=e-t;if(i>0&&i<=e)return this.list.splice(t,i);if(0===i&&0===this.list.length)return[];throw new Error("List.removeBetween: Range Error, numeric values are outside the acceptable range")},removeAll:function(){for(var t=this.list.length;t--;)this.remove(this.list[t]);return this},bringToTop:function(t){return this.getIndex(t)0&&(this.remove(t),this.addAt(t,0)),t},moveUp:function(t){var e=this.getIndex(t);if(-1!==e&&e0){var i=this.getAt(e-1);i&&this.swap(t,i)}return t},reverse:function(){return this.list.reverse(),this},shuffle:function(){for(var t=this.list.length-1;t>0;t--){var e=Math.floor(Math.random()*(t+1)),i=this.list[t];this.list[t]=this.list[e],this.list[e]=i}return this},replace:function(t,e){var i=this.getIndex(t);if(-1!==i)return this.remove(t),this.addAt(e,i),t},exists:function(t){return this.list.indexOf(t)>-1},setAll:function(t,e){for(var i=0;i0?this.list[0]:null}},last:{get:function(){return this.list.length>0?(this.position=this.list.length-1,this.list[this.position]):null}},next:{get:function(){return this.position0?(this.position--,this.list[this.position]):null}}});t.exports=n},function(t,e){t.exports={CREATED:0,INIT:1,DELAY:2,OFFSET_DELAY:3,PENDING_RENDER:4,PLAYING_FORWARD:5,PLAYING_BACKWARD:6,HOLD_DELAY:7,REPEAT_DELAY:8,COMPLETE:9,PENDING_ADD:20,PAUSED:21,LOOP_DELAY:22,ACTIVE:23,COMPLETE_DELAY:24,PENDING_REMOVE:25,REMOVED:26}},function(t,e,i){var n=i(0),s=i(11),r=i(1),o=i(657),a=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Flip,s.GetBounds,s.Origin,s.Pipeline,s.ScaleMode,s.Size,s.Texture,s.Transform,s.Visible,s.ScrollFactor,o],initialize:function(t,e,i,n,s,o,a,h,l){if(r.call(this,t,"Mesh"),this.setTexture(h,l),this.setPosition(e,i),this.setSizeToFrame(),this.setOrigin(),this.initPipeline("TextureTintPipeline"),n.length!==s.length)throw new Error("Mesh Vertex count must match UV count");var u,c=n.length/2|0;if(o.length>0&&o.length0&&a.length=0&&f<=1&&p>=0&&p<=1&&(i.x=s+f*(o-s),i.y=r+f*(a-r),!0)}},function(t,e){t.exports=function(t,e,i,n,s){return void 0===t&&(t=""),void 0===e&&(e=!0),void 0===i&&(i=""),void 0===n&&(n=""),void 0===s&&(s=0),{responseType:t,async:e,user:i,password:n,timeout:s,header:void 0,headerValue:void 0,overrideMimeType:void 0}}},function(t,e,i){var n=i(0),s=i(328),r=i(37),o=new n({Extends:r,Mixins:[s.Acceleration,s.Angular,s.Bounce,s.Debug,s.Drag,s.Enable,s.Friction,s.Gravity,s.Immovable,s.Mass,s.Size,s.Velocity],initialize:function(t,e,i,n,s){r.call(this,t,e,i,n,s)}});t.exports=o},function(t,e,i){var n={};t.exports=n;var s=i(93),r=i(38),o=i(60),a=i(95),h=i(94),l=i(948);n.rectangle=function(t,e,i,n,a){a=a||{};var h={label:"Rectangle Body",position:{x:t,y:e},vertices:s.fromPath("L 0 0 L "+i+" 0 L "+i+" "+n+" L 0 "+n)};if(a.chamfer){var l=a.chamfer;h.vertices=s.chamfer(h.vertices,l.radius,l.quality,l.qualityMin,l.qualityMax),delete a.chamfer}return o.create(r.extend({},h,a))},n.trapezoid=function(t,e,i,n,a,h){h=h||{};var l,u=i*(a*=.5),c=u+(1-2*a)*i,d=c+u;l=a<.5?"L 0 0 L "+u+" "+-n+" L "+c+" "+-n+" L "+d+" 0":"L 0 0 L "+c+" "+-n+" L "+d+" 0";var f={label:"Trapezoid Body",position:{x:t,y:e},vertices:s.fromPath(l)};if(h.chamfer){var p=h.chamfer;f.vertices=s.chamfer(f.vertices,p.radius,p.quality,p.qualityMin,p.qualityMax),delete h.chamfer}return o.create(r.extend({},f,h))},n.circle=function(t,e,i,s,o){s=s||{};var a={label:"Circle Body",circleRadius:i};o=o||25;var h=Math.ceil(Math.max(10,Math.min(o,i)));return h%2==1&&(h+=1),n.polygon(t,e,h,i,r.extend({},a,s))},n.polygon=function(t,e,i,a,h){if(h=h||{},i<3)return n.circle(t,e,a,h);for(var l=2*Math.PI/i,u="",c=.5*l,d=0;d0&&s.area(A)1?(f=o.create(r.extend({parts:p.slice(0)},n)),o.setPosition(f,{x:t,y:e}),f):p[0]}},function(t,e,i){var n={};t.exports=n;var s=i(94),r=i(38);n.create=function(t,e){for(var i=[],n=0;n0)return!1}return!0},n.scale=function(t,e,i,r){if(1===e&&1===i)return t;var o,a;r=r||n.centre(t);for(var h=0;h=0?h-1:t.length-1],u=t[h],c=t[(h+1)%t.length],d=e[h0&&(r|=2),3===r)return!1;return 0!==r||null},n.hull=function(t){var e,i,n=[],r=[];for((t=t.slice(0)).sort(function(t,e){var i=t.x-e.x;return 0!==i?i:t.y-e.y}),i=0;i=2&&s.cross3(r[r.length-2],r[r.length-1],e)<=0;)r.pop();r.push(e)}for(i=t.length-1;i>=0;i-=1){for(e=t[i];n.length>=2&&s.cross3(n[n.length-2],n[n.length-1],e)<=0;)n.pop();n.push(e)}return n.pop(),r.pop(),n.concat(r)}},function(t,e){var i={};t.exports=i,i.create=function(t,e){return{x:t||0,y:e||0}},i.clone=function(t){return{x:t.x,y:t.y}},i.magnitude=function(t){return Math.sqrt(t.x*t.x+t.y*t.y)},i.magnitudeSquared=function(t){return t.x*t.x+t.y*t.y},i.rotate=function(t,e,i){var n=Math.cos(e),s=Math.sin(e);i||(i={});var r=t.x*n-t.y*s;return i.y=t.x*s+t.y*n,i.x=r,i},i.rotateAbout=function(t,e,i,n){var s=Math.cos(e),r=Math.sin(e);n||(n={});var o=i.x+((t.x-i.x)*s-(t.y-i.y)*r);return n.y=i.y+((t.x-i.x)*r+(t.y-i.y)*s),n.x=o,n},i.normalise=function(t){var e=i.magnitude(t);return 0===e?{x:0,y:0}:{x:t.x/e,y:t.y/e}},i.dot=function(t,e){return t.x*e.x+t.y*e.y},i.cross=function(t,e){return t.x*e.y-t.y*e.x},i.cross3=function(t,e,i){return(e.x-t.x)*(i.y-t.y)-(e.y-t.y)*(i.x-t.x)},i.add=function(t,e,i){return i||(i={}),i.x=t.x+e.x,i.y=t.y+e.y,i},i.sub=function(t,e,i){return i||(i={}),i.x=t.x-e.x,i.y=t.y-e.y,i},i.mult=function(t,e){return{x:t.x*e,y:t.y*e}},i.div=function(t,e){return{x:t.x/e,y:t.y/e}},i.perp=function(t,e){return{x:(e=!0===e?-1:1)*-t.y,y:e*t.x}},i.neg=function(t){return{x:-t.x,y:-t.y}},i.angle=function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)},i._temp=[i.create(),i.create(),i.create(),i.create(),i.create(),i.create()]},function(t,e){var i={};t.exports=i,i.create=function(t){var e={min:{x:0,y:0},max:{x:0,y:0}};return t&&i.update(e,t),e},i.update=function(t,e,i){t.min.x=1/0,t.max.x=-1/0,t.min.y=1/0,t.max.y=-1/0;for(var n=0;nt.max.x&&(t.max.x=s.x),s.xt.max.y&&(t.max.y=s.y),s.y0?t.max.x+=i.x:t.min.x+=i.x,i.y>0?t.max.y+=i.y:t.min.y+=i.y)},i.contains=function(t,e){return e.x>=t.min.x&&e.x<=t.max.x&&e.y>=t.min.y&&e.y<=t.max.y},i.overlaps=function(t,e){return t.min.x<=e.max.x&&t.max.x>=e.min.x&&t.max.y>=e.min.y&&t.min.y<=e.max.y},i.translate=function(t,e){t.min.x+=e.x,t.max.x+=e.x,t.min.y+=e.y,t.max.y+=e.y},i.shift=function(t,e){var i=t.max.x-t.min.x,n=t.max.y-t.min.y;t.min.x=e.x,t.max.x=e.x+i,t.min.y=e.y,t.max.y=e.y+n}},function(t,e,i){t.exports={CalculateFacesAt:i(153),CalculateFacesWithin:i(34),Copy:i(874),CreateFromTiles:i(875),CullTiles:i(876),Fill:i(877),FilterTiles:i(878),FindByIndex:i(879),FindTile:i(880),ForEachTile:i(881),GetTileAt:i(97),GetTileAtWorldXY:i(882),GetTilesWithin:i(15),GetTilesWithinShape:i(883),GetTilesWithinWorldXY:i(884),HasTileAt:i(345),HasTileAtWorldXY:i(885),IsInLayerBounds:i(74),PutTileAt:i(154),PutTileAtWorldXY:i(886),PutTilesAt:i(887),Randomize:i(888),RemoveTileAt:i(346),RemoveTileAtWorldXY:i(889),RenderDebug:i(890),ReplaceByIndex:i(344),SetCollision:i(891),SetCollisionBetween:i(892),SetCollisionByExclusion:i(893),SetCollisionByProperty:i(894),SetCollisionFromCollisionGroup:i(895),SetTileIndexCallback:i(896),SetTileLocationCallback:i(897),Shuffle:i(898),SwapByIndex:i(899),TileToWorldX:i(98),TileToWorldXY:i(900),TileToWorldY:i(99),WeightedRandomize:i(901),WorldToTileX:i(39),WorldToTileXY:i(902),WorldToTileY:i(40)}},function(t,e,i){var n=i(74);t.exports=function(t,e,i,s){if(void 0===i&&(i=!1),n(t,e,s)){var r=s.data[e][t];return null===r?null:-1===r.index?i?r:null:r}return null}},function(t,e){t.exports=function(t,e,i){var n=i.baseTileWidth,s=i.tilemapLayer,r=0;return s&&(void 0===e&&(e=s.scene.cameras.main),r=s.x+e.scrollX*(1-s.scrollFactorX),n*=s.scaleX),r+t*n}},function(t,e){t.exports=function(t,e,i){var n=i.baseTileHeight,s=i.tilemapLayer,r=0;return s&&(void 0===e&&(e=s.scene.cameras.main),r=s.y+e.scrollY*(1-s.scrollFactorY),n*=s.scaleY),r+t*n}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r,o,a){(void 0===i||i<=0)&&(i=32),(void 0===n||n<=0)&&(n=32),void 0===s&&(s=0),void 0===r&&(r=0),void 0===o&&(o={}),void 0===a&&(a={}),this.name=t,this.firstgid=e,this.tileWidth=i,this.tileHeight=n,this.tileMargin=s,this.tileSpacing=r,this.tileProperties=o,this.tileData=a,this.image=null,this.rows=0,this.columns=0,this.total=0,this.texCoordinates=[]},getTileProperties:function(t){return this.containsTileIndex(t)?this.tileProperties[t-this.firstgid]:null},getTileData:function(t){return this.containsTileIndex(t)?this.tileData[t-this.firstgid]:null},getTileCollisionGroup:function(t){var e=this.getTileData(t);return e&&e.objectgroup?e.objectgroup:null},containsTileIndex:function(t){return t>=this.firstgid&&t=this.vertexCapacity},resize:function(t,e,i){return this.width=t*i,this.height=e*i,this},bind:function(){var t=this.gl,e=this.vertexBuffer,i=this.attributes,n=this.program,s=this.renderer,r=this.vertexSize;s.setProgram(n),s.setVertexBuffer(e);for(var o=0;o=0?(t.enableVertexAttribArray(h),t.vertexAttribPointer(h,a.size,a.type,a.normalized,r,a.offset)):t.disableVertexAttribArray(h)}return this},onBind:function(){return this},onPreRender:function(){return this},onRender:function(){return this},onPostRender:function(){return this},flush:function(){if(this.flushLocked)return this;this.flushLocked=!0;var t=this.gl,e=this.vertexCount,i=this.topology,n=this.vertexSize;if(0!==e)return t.bufferSubData(t.ARRAY_BUFFER,0,this.bytes.subarray(0,e*n)),t.drawArrays(i,0,e),this.vertexCount=0,this.flushLocked=!1,this;this.flushLocked=!1},destroy:function(){var t=this.gl;return t.deleteProgram(this.program),t.deleteBuffer(this.vertexBuffer),delete this.program,delete this.vertexBuffer,delete this.gl,this},setFloat1:function(t,e){return this.renderer.setFloat1(this.program,t,e),this},setFloat2:function(t,e,i){return this.renderer.setFloat2(this.program,t,e,i),this},setFloat3:function(t,e,i,n){return this.renderer.setFloat3(this.program,t,e,i,n),this},setFloat4:function(t,e,i,n,s){return this.renderer.setFloat4(this.program,t,e,i,n,s),this},setInt1:function(t,e){return this.renderer.setInt1(this.program,t,e),this},setInt2:function(t,e,i){return this.renderer.setInt2(this.program,t,e,i),this},setInt3:function(t,e,i,n){return this.renderer.setInt3(this.program,t,e,i,n),this},setInt4:function(t,e,i,n,s){return this.renderer.setInt4(this.program,t,e,i,n,s),this},setMatrix2:function(t,e,i){return this.renderer.setMatrix2(this.program,t,e,i),this},setMatrix3:function(t,e,i){return this.renderer.setMatrix3(this.program,t,e,i),this},setMatrix4:function(t,e,i){return this.renderer.setMatrix4(this.program,t,e,i),this}});t.exports=r},function(t,e,i){var n=i(53);t.exports=function(t,e){var i=n(t);for(var s in e)i.hasOwnProperty(s)||(i[s]=e[s]);return i}},function(t,e,i){var n=i(5);t.exports=function(t,e,i){return void 0===i&&(i=new n),i.x=t.x+t.radius*Math.cos(e),i.y=t.y+t.radius*Math.sin(e),i}},function(t,e,i){var n=i(5);t.exports=function(t,e){void 0===e&&(e=new n);var i=2*Math.PI*Math.random(),s=Math.random()+Math.random(),r=s>1?2-s:s,o=r*Math.cos(i),a=r*Math.sin(i);return e.x=t.x+o*t.radius,e.y=t.y+a*t.radius,e}},function(t,e,i){var n=i(78),s=i(5);t.exports=function(t,e,i){if(void 0===i&&(i=new s),e<=0||e>=1)return i.x=t.x,i.y=t.y,i;var r=n(t)*e;return e>.5?(r-=t.width+t.height)<=t.width?(i.x=t.right-r,i.y=t.bottom):(i.x=t.x,i.y=t.bottom-(r-t.width)):r<=t.width?(i.x=t.x+r,i.y=t.y):(i.x=t.right,i.y=t.y+(r-t.width)),i}},function(t,e,i){var n=i(5);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.x+Math.random()*t.width,e.y=t.y+Math.random()*t.height,e}},function(t,e,i){var n=i(66),s=i(5);t.exports=function(t,e,i,r){void 0===r&&(r=[]),e||(e=n(t)/i);for(var o=t.x1,a=t.y1,h=t.x2,l=t.y2,u=0;u=1&&(a=1-a,h=1-h),e.x=t.x1+(i*a+r*h),e.y=t.y1+(s*a+o*h),e}},function(t,e){t.exports=function(t,e,i,n,s){var r=n+Math.atan2(t.y-i,t.x-e);return t.x=e+s*Math.cos(r),t.y=i+s*Math.sin(r),t}},function(t,e,i){var n=new(i(0))({initialize:function(t){if(this.entries={},this.size=0,Array.isArray(t))for(var e=0;e-y||T>-m||w-y||A>-m||S-y||T>-m||w-y||A>-m||S-v&&A*n+C*r+h>-y&&(A+v)*i+(C+y)*s+a0?this:(this._fadeRed=e,this._fadeGreen=i,this._fadeBlue=n,t<=0&&(t=Number.MIN_VALUE),this._fadeDuration=t,this._fadeAlpha=Number.MIN_VALUE,this)},flash:function(t,e,i,n,s){return!s&&this._flashAlpha>0?this:(void 0===e&&(e=1),void 0===i&&(i=1),void 0===n&&(n=1),this._flashRed=e,this._flashGreen=i,this._flashBlue=n,t<=0&&(t=Number.MIN_VALUE),this._flashDuration=t,this._flashAlpha=1,this)},getWorldPoint:function(t,e,i){void 0===i&&(i=new h);var n=this.matrix.matrix,s=n[0],r=n[1],o=n[2],a=n[3],l=n[4],u=n[5],c=s*a-r*o;if(!c)return i.x=t,i.y=e,i;var d=a*(c=1/c),f=-r*c,p=-o*c,g=s*c,v=(o*u-a*l)*c,y=(r*l-s*u)*c,m=Math.cos(this.rotation),x=Math.sin(this.rotation),b=this.zoom,w=this.scrollX,T=this.scrollY,S=t+(w*m-T*x)*b,A=e+(w*x+T*m)*b;return i.x=S*d+A*p+v,i.y=S*f+A*g+y,i},ignore:function(t){if(t instanceof Array)for(var e=0;eu&&(this.scrollX=u),this.scrollYc&&(this.scrollY=c)}this.roundPixels&&(this.scrollX=Math.round(this.scrollX),this.scrollY=Math.round(this.scrollY)),r.loadIdentity(),r.scale(e,e),r.translate(this.x+o,this.y+a),r.rotate(this.rotation),r.scale(s,s),r.translate(-o,-a),r.translate(this._shakeOffsetX,this._shakeOffsetY)},removeBounds:function(){return this.useBounds=!1,this._bounds.setEmpty(),this},setAngle:function(t){return void 0===t&&(t=0),this.rotation=s(t),this},setBackgroundColor:function(t){return void 0===t&&(t="rgba(0,0,0,0)"),this.backgroundColor=a(t),this.transparent=0===this.backgroundColor.alpha,this},setBounds:function(t,e,i,n){return this._bounds.setTo(t,e,i,n),this.useBounds=!0,this},setName:function(t){return void 0===t&&(t=""),this.name=t,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setRotation:function(t){return void 0===t&&(t=0),this.rotation=t,this},setRoundPixels:function(t){return this.roundPixels=t,this},setScene:function(t){return this.scene=t,this},setScroll:function(t,e){return void 0===e&&(e=t),this.scrollX=t,this.scrollY=e,this},setSize:function(t,e){return void 0===e&&(e=t),this.width=t,this.height=e,this},setViewport:function(t,e,i,n){return this.x=t,this.y=e,this.width=i,this.height=n,this},setZoom:function(t){return void 0===t&&(t=1),this.zoom=t,this},shake:function(t,e,i){return void 0===e&&(e=.05),i||0===this._shakeOffsetX&&0===this._shakeOffsetY?(this._shakeDuration=t,this._shakeIntensity=e,this._shakeOffsetX=0,this._shakeOffsetY=0,this):this},startFollow:function(t,e){return this._follow=t,void 0!==e&&(this.roundPixels=e),this},stopFollow:function(){return this._follow=null,this},toJSON:function(){var t={name:this.name,x:this.x,y:this.y,width:this.width,height:this.height,zoom:this.zoom,rotation:this.rotation,roundPixels:this.roundPixels,scrollX:this.scrollX,scrollY:this.scrollY,backgroundColor:this.backgroundColor.rgba};return this.useBounds&&(t.bounds={x:this._bounds.x,y:this._bounds.y,width:this._bounds.width,height:this._bounds.height}),t},resetFX:function(){return this._flashAlpha=0,this._fadeAlpha=0,this._shakeOffsetX=0,this._shakeOffsetY=0,this._shakeDuration=0,this},update:function(t,e){if(this._flashAlpha>0&&(this._flashAlpha-=e/this._flashDuration,this._flashAlpha<0&&(this._flashAlpha=0)),this._fadeAlpha>0&&this._fadeAlpha<1&&(this._fadeAlpha+=e/this._fadeDuration,this._fadeAlpha>=1&&(this._fadeAlpha=1)),this._shakeDuration>0){var i=this._shakeIntensity;this._shakeDuration-=e,this._shakeDuration<=0?(this._shakeOffsetX=0,this._shakeOffsetY=0):(this._shakeOffsetX=(Math.random()*i*this.width*2-i*this.width)*this.zoom,this._shakeOffsetY=(Math.random()*i*this.height*2-i*this.height)*this.zoom,this.roundPixels&&(this._shakeOffsetX|=0,this._shakeOffsetY|=0))}},destroy:function(){this._bounds=void 0,this.matrix=void 0,this.culledObjects=[],this.scene=void 0}});t.exports=l},function(t,e,i){var n=i(203),s=i(205),r=i(207),o=i(208);t.exports=function(t){switch(typeof t){case"string":return"rgb"===t.substr(0,3).toLowerCase()?o(t):n(t);case"number":return s(t);case"object":return r(t)}}},function(t,e){t.exports=function(t,e,i){return t<<16|e<<8|i}},function(t,e,i){var n=i(0),s=i(119),r=i(209),o=i(210),a=i(211),h=i(62),l=i(81),u=i(6),c=i(51),d=i(120),f=new c,p=new d,g=new c,v=new c,y=new s,m=new n({initialize:function(t){this.scene=t,this.displayList=t.sys.displayList,this.updateList=t.sys.updateList,this.name="",this.direction=new c(0,0,-1),this.up=new c(0,1,0),this.position=new c,this.pixelScale=128,this.projection=new s,this.view=new s,this.combined=new s,this.invProjectionView=new s,this.near=1,this.far=100,this.ray={origin:new c,direction:new c},this.viewportWidth=0,this.viewportHeight=0,this.billboardMatrixDirty=!0,this.children=new h},setPosition:function(t,e,i){return this.position.set(t,e,i),this.update()},setScene:function(t){return this.scene=t,this},setPixelScale:function(t){return this.pixelScale=t,this.update()},add:function(t){return this.children.set(t),this.updateChildren(),t},remove:function(t){return this.displayList.remove(t.gameObject),this.updateList.remove(t.gameObject),this.children.delete(t),this},clear:function(){for(var t=this.getChildren(),e=0;e0&&(s=1/Math.sqrt(s),this.x=t*s,this.y=e*s,this.z=i*s,this.w=n*s),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z,r=this.w;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this.w=r+e*(t.w-r),this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z||1,this.w*=t.w||1,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z||1,this.w/=t.w||1,this},distance:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0,s=t.w-this.w||0;return Math.sqrt(e*e+i*i+n*n+s*s)},distanceSq:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0,s=t.w-this.w||0;return e*e+i*i+n*n+s*s},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},transformMat4:function(t){var e=this.x,i=this.y,n=this.z,s=this.w,r=t.val;return this.x=r[0]*e+r[4]*i+r[8]*n+r[12]*s,this.y=r[1]*e+r[5]*i+r[9]*n+r[13]*s,this.z=r[2]*e+r[6]*i+r[10]*n+r[14]*s,this.w=r[3]*e+r[7]*i+r[11]*n+r[15]*s,this},transformQuat:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z,a=t.w,h=a*e+r*n-o*i,l=a*i+o*e-s*n,u=a*n+s*i-r*e,c=-s*e-r*i-o*n;return this.x=h*a+c*-s+l*-o-u*-r,this.y=l*a+c*-r+u*-s-h*-o,this.z=u*a+c*-o+h*-r-l*-s,this},reset:function(){return this.x=0,this.y=0,this.z=0,this.w=0,this}});n.prototype.sub=n.prototype.subtract,n.prototype.mul=n.prototype.multiply,n.prototype.div=n.prototype.divide,n.prototype.dist=n.prototype.distance,n.prototype.distSq=n.prototype.distanceSq,n.prototype.len=n.prototype.length,n.prototype.lenSq=n.prototype.lengthSq,t.exports=n},function(t,e){var i,n="";t.exports={disable:function(t){return""===n&&(n=i(t)),n&&(t[n]=!1),t},enable:function(t){return""===n&&(n=i(t)),n&&(t[n]=!0),t},getPrefix:i=function(t){for(var e=["i","webkitI","msI","mozI","oI"],i=0;i0&&0==(t&t-1)&&e>0&&0==(e&e-1)}},function(t,e){t.exports={ARC:0,BEGIN_PATH:1,CLOSE_PATH:2,FILL_RECT:3,LINE_TO:4,MOVE_TO:5,LINE_STYLE:6,FILL_STYLE:7,FILL_PATH:8,STROKE_PATH:9,FILL_TRIANGLE:10,STROKE_TRIANGLE:11,LINE_FX_TO:12,MOVE_FX_TO:13,SAVE:14,RESTORE:15,TRANSLATE:16,SCALE:17,ROTATE:18}},function(t,e){t.exports={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PRINT_SCREEN:42,INSERT:45,DELETE:46,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,SEMICOLON:186,PLUS:187,COMMA:188,MINUS:189,PERIOD:190,FORWARD_SLASH:191,BACK_SLASH:220,QUOTES:222,BACKTICK:192,OPEN_BRACKET:219,CLOSED_BRACKET:221}},function(t,e,i){var n=i(0),s=i(83),r=i(530),o=i(531),a=i(236),h=i(255),l=new n({initialize:function(t,e){this.scene=t,this.game,this.config=e,this.settings=h.create(e),this.canvas,this.context,this.anims,this.cache,this.plugins,this.registry,this.sound,this.textures,this.add,this.cameras,this.displayList,this.events,this.make,this.scenePlugin,this.updateList},init:function(t){this.settings.status=s.INIT,this.game=t,this.canvas=t.canvas,this.context=t.context;var e=t.plugins;this.plugins=e,e.installGlobal(this,a.Global),e.installLocal(this,a.CoreScene),e.installLocal(this,o(this)),e.installLocal(this,r(this)),this.events.emit("boot",this),this.settings.isBooted=!0},install:function(t){Array.isArray(t)||(t=[t]),this.plugins.installLocal(this,t)},step:function(t,e){this.events.emit("preupdate",t,e),this.events.emit("update",t,e),this.scene.update.call(this.scene,t,e),this.events.emit("postupdate",t,e)},render:function(t){var e=this.displayList;e.depthSort(),this.cameras.render(t,e),this.events.emit("render",t)},queueDepthSort:function(){this.displayList.queueDepthSort()},depthSort:function(){this.displayList.depthSort()},pause:function(){return this.settings.active&&(this.settings.status=s.PAUSED,this.settings.active=!1,this.events.emit("pause",this)),this},resume:function(){return this.settings.active||(this.settings.status=s.RUNNING,this.settings.active=!0,this.events.emit("resume",this)),this},sleep:function(){return this.settings.status=s.SLEEPING,this.settings.active=!1,this.settings.visible=!1,this.events.emit("sleep",this),this},wake:function(){return this.settings.status=s.RUNNING,this.settings.active=!0,this.settings.visible=!0,this.events.emit("wake",this),this},isSleeping:function(){return this.settings.status===s.SLEEPING},isActive:function(){return this.settings.status===s.RUNNING},isVisible:function(){return this.settings.visible},setVisible:function(t){return this.settings.visible=t,this},setActive:function(t){return t?this.resume():this.pause()},start:function(t){this.settings.status=s.START,this.settings.data=t,this.settings.active=!0,this.settings.visible=!0,this.events.emit("start",this)},resize:function(t,e){this.events.emit("resize",t,e)},shutdown:function(){this.settings.status=s.SHUTDOWN,this.settings.active=!1,this.settings.visible=!1,this.events.emit("shutdown",this)},destroy:function(){this.settings.status=s.DESTROYED,this.settings.active=!1,this.settings.visible=!1,this.events.emit("destroy",this)}});t.exports=l},function(t,e,i){var n=i(0),s=i(23),r=new n({initialize:function(t,e,i,n,s,r,o){this.texture=t,this.name=e,this.source=t.source[i],this.sourceIndex=i,this.cutX=n,this.cutY=s,this.cutWidth=r,this.cutHeight=o,this.x=0,this.y=0,this.width=r,this.height=o,this.halfWidth=Math.floor(.5*r),this.halfHeight=Math.floor(.5*o),this.centerX=Math.floor(r/2),this.centerY=Math.floor(o/2),this.pivotX=0,this.pivotY=0,this.customPivot=!1,this.rotated=!1,this.autoRound=-1,this.customData={},this.data={cut:{x:n,y:s,w:r,h:o,r:n+r,b:s+o},trim:!1,sourceSize:{w:r,h:o},spriteSourceSize:{x:0,y:0,w:r,h:o},uvs:{x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},radius:.5*Math.sqrt(r*r+o*o),drawImage:{sx:n,sy:s,sWidth:r,sHeight:o,dWidth:r,dHeight:o}},this.updateUVs()},setTrim:function(t,e,i,n,s,r){var o=this.data,a=o.spriteSourceSize;return o.trim=!0,o.sourceSize.w=t,o.sourceSize.h=e,a.x=i,a.y=n,a.w=s,a.h=r,this.x=i,this.y=n,this.width=s,this.height=r,this.halfWidth=.5*s,this.halfHeight=.5*r,this.centerX=Math.floor(s/2),this.centerY=Math.floor(r/2),this.updateUVs()},updateUVs:function(){var t=this.cutX,e=this.cutY,i=this.cutWidth,n=this.cutHeight,s=this.data.drawImage;s.sWidth=i,s.sHeight=n,s.dWidth=i,s.dHeight=n;var r=this.source.width,o=this.source.height,a=this.data.uvs;return a.x0=t/r,a.y0=e/o,a.x1=t/r,a.y1=(e+n)/o,a.x2=(t+i)/r,a.y2=(e+n)/o,a.x3=(t+i)/r,a.y3=e/o,this},updateUVsInverted:function(){var t=this.source.width,e=this.source.height,i=this.data.uvs;return i.x3=(this.cutX+this.cutHeight)/t,i.y3=(this.cutY+this.cutWidth)/e,i.x2=this.cutX/t,i.y2=(this.cutY+this.cutWidth)/e,i.x1=this.cutX/t,i.y1=this.cutY/e,i.x0=(this.cutX+this.cutHeight)/t,i.y0=this.cutY/e,this},clone:function(){var t=new r(this.texture,this.name,this.sourceIndex);return t.cutX=this.cutX,t.cutY=this.cutY,t.cutWidth=this.cutWidth,t.cutHeight=this.cutHeight,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t.halfWidth=this.halfWidth,t.halfHeight=this.halfHeight,t.centerX=this.centerX,t.centerY=this.centerY,t.rotated=this.rotated,t.data=s(!0,t.data,this.data),t.updateUVs(),t},destroy:function(){this.texture=null,this.source=null},realWidth:{get:function(){return this.data.sourceSize.w}},realHeight:{get:function(){return this.data.sourceSize.h}},uvs:{get:function(){return this.data.uvs}},radius:{get:function(){return this.data.radius}},trimmed:{get:function(){return this.data.trim}},canvasData:{get:function(){return this.data.drawImage}}});t.exports=r},function(t,e,i){var n=i(10);t.exports=function(t,e){var i=n(e,"anims",null);if(null===i)return t;if("string"==typeof i)t.anims.play(i);else if("object"==typeof i){var s=t.anims,r=n(i,"key",void 0),o=n(i,"startFrame",void 0),a=n(i,"delay",0),h=n(i,"repeat",0),l=n(i,"repeatDelay",0),u=n(i,"yoyo",!1),c=n(i,"play",!1),d=n(i,"delayedPlay",0);s.delay(a),s.repeat(h),s.repeatDelay(l),s.yoyo(u),c?s.play(r,o):d>0?s.delayedPlay(d,r,o):s.load(r)}return t}},function(t,e,i){var n=i(0),s=i(11),r=i(1),o=i(268),a=i(547),h=i(548),l=i(549),u=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Origin,s.Pipeline,s.ScaleMode,s.Texture,s.Tint,s.Transform,s.Visible,s.ScrollFactor,l],initialize:function(t,e,i,n,s,o){void 0===s&&(s=""),r.call(this,t,"BitmapText"),this.font=n;var a=this.scene.sys.cache.bitmapFont.get(n);this.fontData=a.data,this.text=Array.isArray(s)?s.join("\n"):s,this.fontSize=o||this.fontData.size,this.setTexture(a.texture,a.frame),this.setPosition(e,i),this.setOrigin(0,0),this.initPipeline("TextureTintPipeline"),this._bounds=this.getTextBounds()},setFontSize:function(t){return this.fontSize=t,this},setText:function(t){return t||0===t||(t=""),Array.isArray(t)&&(t=t.join("\n")),t!==this.text&&(this.text=t.toString(),this.updateDisplayOrigin()),this},getTextBounds:function(t){return this._bounds=o(this,t),this._bounds},width:{get:function(){return this.getTextBounds(!1),this._bounds.global.width}},height:{get:function(){return this.getTextBounds(!1),this._bounds.global.height}},toJSON:function(){var t=s.ToJSON(this),e={font:this.font,text:this.text,fontSize:this.fontSize};return t.data=e,t}});u.ParseRetroFont=h,u.ParseFromAtlas=a,t.exports=u},function(t,e,i){var n=i(552),s=i(555),r=i(0),o=i(11),a=i(131),h=i(1),l=i(86),u=new r({Extends:h,Mixins:[o.Alpha,o.BlendMode,o.Depth,o.Pipeline,o.ScaleMode,o.ScrollFactor,o.Size,o.Texture,o.Transform,o.Visible,n],initialize:function(t,e,i,n,s){h.call(this,t,"Blitter"),this.setTexture(n,s),this.setPosition(e,i),this.initPipeline("TextureTintPipeline"),this.children=new l,this.renderList=[],this.dirty=!1},create:function(t,e,i,n,r){void 0===n&&(n=!0),void 0===r&&(r=this.children.length),void 0===i?i=this.frame:i instanceof a||(i=this.texture.get(i));var o=new s(this,t,e,i,n);return this.children.addAt(o,r,!1),this.dirty=!0,o},createFromCallback:function(t,e,i,n){for(var s=this.createMultiple(e,i,n),r=0;r0},getRenderList:function(){return this.dirty&&(this.renderList=this.children.list.filter(this.childCanRender,this),this.dirty=!1),this.renderList},clear:function(){this.children.removeAll(),this.dirty=!0}});t.exports=u},function(t,e,i){var n=i(0),s=i(11),r=i(1),o=i(268),a=i(556),h=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Origin,s.Pipeline,s.Texture,s.Tint,s.Transform,s.Visible,s.ScrollFactor,a],initialize:function(t,e,i,n,s,o){void 0===s&&(s=""),r.call(this,t,"DynamicBitmapText"),this.font=n;var a=this.scene.sys.cache.bitmapFont.get(n);this.fontData=a.data,this.text=Array.isArray(s)?s.join("\n"):s,this.fontSize=o||this.fontData.size,this.setTexture(a.texture,a.frame),this.setPosition(e,i),this.setOrigin(0,0),this.initPipeline("TextureTintPipeline"),this._bounds=this.getTextBounds(),this.scrollX=0,this.scrollY=0,this.cropWidth=0,this.cropHeight=0,this.displayCallback},setSize:function(t,e){return this.cropWidth=t,this.cropHeight=e,this},setDisplayCallback:function(t){return this.displayCallback=t,this},setFontSize:function(t){return this.fontSize=t,this},setText:function(t){return t||0===t||(t=""),Array.isArray(t)&&(t=t.join("\n")),t!==this.text&&(this.text=t.toString(),this.updateDisplayOrigin()),this},setScrollX:function(t){return this.scrollX=t,this},setScrollY:function(t){return this.scrollY=t,this},getTextBounds:function(t){return this._bounds=o(this,t),this._bounds},width:{get:function(){return this.getTextBounds(!1),this._bounds.global.width}},height:{get:function(){return this.getTextBounds(!1),this._bounds.global.height}},toJSON:function(){var t=s.ToJSON(this),e={font:this.font,text:this.text,fontSize:this.fontSize};return t.data=e,t}});t.exports=h},function(t,e,i){var n=i(115),s=i(0),r=i(128),o=i(11),a=i(270),h=i(1),l=i(4),u=i(16),c=i(568),d=new s({Extends:h,Mixins:[o.Alpha,o.BlendMode,o.Depth,o.Pipeline,o.Transform,o.Visible,o.ScrollFactor,c],initialize:function(t,e){var i=l(e,"x",0),n=l(e,"y",0);h.call(this,t,"Graphics"),this.setPosition(i,n),this.initPipeline("FlatTintPipeline"),this.displayOriginX=0,this.displayOriginY=0,this.commandBuffer=[],this.defaultFillColor=-1,this.defaultFillAlpha=1,this.defaultStrokeWidth=1,this.defaultStrokeColor=-1,this.defaultStrokeAlpha=1,this._lineWidth=1,this.setDefaultStyles(e)},setDefaultStyles:function(t){return l(t,"lineStyle",null)&&(this.defaultStrokeWidth=l(t,"lineStyle.width",1),this.defaultStrokeColor=l(t,"lineStyle.color",16777215),this.defaultStrokeAlpha=l(t,"lineStyle.alpha",1),this.lineStyle(this.defaultStrokeWidth,this.defaultStrokeColor,this.defaultStrokeAlpha)),l(t,"fillStyle",null)&&(this.defaultFillColor=l(t,"fillStyle.color",16777215),this.defaultFillAlpha=l(t,"fillStyle.alpha",1),this.fillStyle(this.defaultFillColor,this.defaultFillAlpha)),this},lineStyle:function(t,e,i){return void 0===i&&(i=1),this.commandBuffer.push(r.LINE_STYLE,t,e,i),this._lineWidth=t,this},fillStyle:function(t,e){return void 0===e&&(e=1),this.commandBuffer.push(r.FILL_STYLE,t,e),this},beginPath:function(){return this.commandBuffer.push(r.BEGIN_PATH),this},closePath:function(){return this.commandBuffer.push(r.CLOSE_PATH),this},fillPath:function(){return this.commandBuffer.push(r.FILL_PATH),this},strokePath:function(){return this.commandBuffer.push(r.STROKE_PATH),this},fillCircleShape:function(t){return this.fillCircle(t.x,t.y,t.radius)},strokeCircleShape:function(t){return this.strokeCircle(t.x,t.y,t.radius)},fillCircle:function(t,e,i){return this.beginPath(),this.arc(t,e,i,0,u.PI2),this.fillPath(),this},strokeCircle:function(t,e,i){return this.beginPath(),this.arc(t,e,i,0,u.PI2),this.strokePath(),this},fillRectShape:function(t){return this.fillRect(t.x,t.y,t.width,t.height)},strokeRectShape:function(t){return this.strokeRect(t.x,t.y,t.width,t.height)},fillRect:function(t,e,i,n){return this.commandBuffer.push(r.FILL_RECT,t,e,i,n),this},strokeRect:function(t,e,i,n){var s=this._lineWidth/2,r=t-s,o=t+s;return this.beginPath(),this.moveTo(t,e),this.lineTo(t,e+n),this.strokePath(),this.beginPath(),this.moveTo(t+i,e),this.lineTo(t+i,e+n),this.strokePath(),this.beginPath(),this.moveTo(r,e),this.lineTo(o+i,e),this.strokePath(),this.beginPath(),this.moveTo(r,e+n),this.lineTo(o+i,e+n),this.strokePath(),this},fillPointShape:function(t,e){return this.fillPoint(t.x,t.y,e)},fillPoint:function(t,e,i){return!i||i<1?i=1:(t-=i/2,e-=i/2),this.commandBuffer.push(r.FILL_RECT,t,e,i,i),this},fillTriangleShape:function(t){return this.fillTriangle(t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)},strokeTriangleShape:function(t){return this.strokeTriangle(t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)},fillTriangle:function(t,e,i,n,s,o){return this.commandBuffer.push(r.FILL_TRIANGLE,t,e,i,n,s,o),this},strokeTriangle:function(t,e,i,n,s,o){return this.commandBuffer.push(r.STROKE_TRIANGLE,t,e,i,n,s,o),this},strokeLineShape:function(t){return this.lineBetween(t.x1,t.y1,t.x2,t.y2)},lineBetween:function(t,e,i,n){return this.beginPath(),this.moveTo(t,e),this.lineTo(i,n),this.strokePath(),this},lineTo:function(t,e){return this.commandBuffer.push(r.LINE_TO,t,e),this},moveTo:function(t,e){return this.commandBuffer.push(r.MOVE_TO,t,e),this},lineFxTo:function(t,e,i,n){return this.commandBuffer.push(r.LINE_FX_TO,t,e,i,n,1),this},moveFxTo:function(t,e,i,n){return this.commandBuffer.push(r.MOVE_FX_TO,t,e,i,n,1),this},strokePoints:function(t,e,i){void 0===e&&(e=!1),void 0===i&&(i=t.length),this.beginPath(),this.moveTo(t[0].x,t[0].y);for(var n=1;n-1&&this.fillStyle(this.defaultFillColor,this.defaultFillAlpha),this.defaultStrokeColor>-1&&this.lineStyle(this.defaultStrokeWidth,this.defaultStrokeColor,this.defaultStrokeAlpha),this},generateTexture:function(t,e,i){var n,s,r=this.scene.sys;if(void 0===e&&(e=r.game.config.width),void 0===i&&(i=r.game.config.height),d.TargetCamera.setViewport(0,0,e,i),d.TargetCamera.scrollX=this.x,d.TargetCamera.scrollY=this.y,"string"==typeof t)if(r.textures.exists(t)){var o=(n=r.textures.get(t)).getSourceImage();o instanceof HTMLCanvasElement&&(s=o.getContext("2d"))}else s=(n=r.textures.createCanvas(t,e,i)).getSourceImage().getContext("2d");else t instanceof HTMLCanvasElement&&(s=t.getContext("2d"));return s&&(this.renderCanvas(r.game.renderer,this,0,d.TargetCamera,s),r.game.renderer.gl&&n&&(n.source[0].glTexture=r.game.renderer.canvasToTexture(s.canvas,n.source[0].glTexture,!0,0))),this}});d.TargetCamera=new n(0,0,0,0),t.exports=d},function(t,e,i){var n=i(0),s=i(68),r=i(271),o=i(272),a=i(110),h=new n({initialize:function(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x=t,this.y=e,this.width=i,this.height=n},contains:function(t,e){return s(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return a(this,t)},setTo:function(t,e,i,n){return this.x=t,this.y=e,this.width=i,this.height=n,this},setEmpty:function(){return this.width=0,this.height=0,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setSize:function(t,e){return void 0===e&&(e=t),this.width=t,this.height=e,this},isEmpty:function(){return this.width<=0||this.height<=0},getMinorRadius:function(){return Math.min(this.width,this.height)/2},getMajorRadius:function(){return Math.max(this.width,this.height)/2},left:{get:function(){return this.x-this.width/2},set:function(t){this.x=t+this.width/2}},right:{get:function(){return this.x+this.width/2},set:function(t){this.x=t-this.width/2}},top:{get:function(){return this.y-this.height/2},set:function(t){this.y=t+this.height/2}},bottom:{get:function(){return this.y+this.height/2},set:function(t){this.y=t-this.height/2}}});t.exports=h},function(t,e,i){var n=i(5);t.exports=function(t,e,i){void 0===i&&(i=new n);var s=t.width/2,r=t.height/2;return i.x=t.x+s*Math.cos(e),i.y=t.y+r*Math.sin(e),i}},function(t,e,i){var n=i(0),s=i(11),r=i(1),o=i(573),a=i(86),h=i(574),l=i(613),u=new n({Extends:r,Mixins:[s.Depth,s.Visible,s.Pipeline,l],initialize:function(t,e,i,n){if(r.call(this,t,"ParticleEmitterManager"),this.blendMode=-1,this.timeScale=1,this.texture=null,this.frame=null,this.frameNames=[],null===i||"object"!=typeof i&&!Array.isArray(i)||(n=i,i=null),this.setTexture(e,i),this.initPipeline("TextureTintPipeline"),this.emitters=new a(this),this.wells=new a(this),n){Array.isArray(n)||(n=[n]);for(var s=0;s0?e.defaultFrame=i[0]:e.defaultFrame=this.defaultFrame,this},addEmitter:function(t){return this.emitters.add(t)},createEmitter:function(t){return this.addEmitter(new h(this,t))},addGravityWell:function(t){return this.wells.add(t)},createGravityWell:function(t){return this.addGravityWell(new o(t))},emitParticle:function(t,e,i){for(var n=this.emitters.list,s=0;sl){if(0===c){for(var g=f;g.length&&(g=g.slice(0,-1),!((p=e.measureText(g).width)<=l)););if(!g.length)throw new Error("This text's wordWrapWidth setting is less than a single character!");var v=d.substr(g.length);u[c]=v,h+=g}var y=u[c].length?c:c+1,m=u.slice(y).join(" ").replace(/[ \n]*$/gi,"");s[o+1]=m+" "+(s[o+1]||""),r=s.length;break}h+=f,l-=p}n+=h.replace(/[ \n]*$/gi,"")+"\n"}}return n=n.replace(/[\s|\n]*$/gi,"")},basicWordWrap:function(t,e,i){for(var n="",s=t.split(this.splitRegExp),r=0;ro?(h>0&&(n+="\n"),n+=a[h]+" ",o=i-l):(o-=u,n+=a[h]+" ")}r0&&(a+=u.lineSpacing*p),i.rtl?o=d-o:"right"===i.align?o+=u.width-u.lineWidths[p]:"center"===i.align&&(o+=(u.width-u.lineWidths[p])/2),this.autoRound&&(o=Math.round(o),a=Math.round(a)),i.strokeThickness&&(this.style.syncShadow(e,i.shadowStroke),e.strokeText(h[p],o,a)),i.color&&(this.style.syncShadow(e,i.shadowFill),e.fillText(h[p],o,a));return e.restore(),this.dirty=!0,this},getTextMetrics:function(){return this.style.getTextMetrics()},toJSON:function(){var t=o.ToJSON(this),e={autoRound:this.autoRound,text:this.text,style:this.style.toJSON(),resolution:this.resolution,padding:{left:this.padding.left,right:this.padding.right,top:this.padding.top,bottom:this.padding.bottom}};return t.data=e,t},preDestroy:function(){this.style.rtl&&c(this.canvas),s.remove(this.canvas)}});t.exports=p},function(t,e,i){var n=i(21),s=i(0),r=i(11),o=i(19),a=i(1),h=i(291),l=i(627),u=new s({Extends:a,Mixins:[r.Alpha,r.BlendMode,r.Depth,r.Flip,r.GetBounds,r.Origin,r.Pipeline,r.ScaleMode,r.ScrollFactor,r.Size,r.Texture,r.Tint,r.Transform,r.Visible,l],initialize:function(t,e,i,s,r,l,u){var c=t.sys.game.renderer;a.call(this,t,"TileSprite"),this.tilePositionX=0,this.tilePositionY=0,this.dirty=!0,this.tileTexture=null,this.renderer=c,this.setTexture(l,u),this.setPosition(e,i),this.setSize(s,r),this.setOriginFromFrame(),this.initPipeline("TextureTintPipeline"),this.potWidth=h(this.frame.width),this.potHeight=h(this.frame.height),this.canvasPattern=null,this.canvasBuffer=n.create2D(null,this.potWidth,this.potHeight),this.canvasBufferCtx=this.canvasBuffer.getContext("2d"),this.oldFrame=null,this.updateTileTexture(),t.sys.game.config.renderType===o.WEBGL&&t.sys.game.renderer.onContextRestored(function(t){var e=t.gl;this.tileTexture=null,this.dirty=!0,this.tileTexture=t.createTexture2D(0,e.LINEAR,e.LINEAR,e.REPEAT,e.REPEAT,e.RGBA,this.canvasBuffer,this.potWidth,this.potHeight)},this)},updateTileTexture:function(){(this.dirty||this.oldFrame!==this.frame)&&(this.oldFrame=this.frame,this.canvasBufferCtx.clearRect(0,0,this.canvasBuffer.width,this.canvasBuffer.height),this.renderer.gl?(this.canvasBufferCtx.drawImage(this.frame.source.image,this.frame.cutX,this.frame.cutY,this.frame.cutWidth,this.frame.cutHeight,0,0,this.potWidth,this.potHeight),this.tileTexture=this.renderer.canvasToTexture(this.canvasBuffer,this.tileTexture,null===this.tileTexture,this.scaleMode)):(this.canvasBuffer.width=this.frame.cutWidth,this.canvasBuffer.height=this.frame.cutHeight,this.canvasBufferCtx.drawImage(this.frame.source.image,this.frame.cutX,this.frame.cutY,this.frame.cutWidth,this.frame.cutHeight,0,0,this.frame.cutWidth,this.frame.cutHeight),this.canvasPattern=this.canvasBufferCtx.createPattern(this.canvasBuffer,"repeat")),this.dirty=!1)},destroy:function(){this.renderer&&this.renderer.deleteTexture(this.tileTexture),n.remove(this.canvasBuffer),this.canvasPattern=null,this.canvasBufferCtx=null,this.canvasBuffer=null,this.renderer=null,this.visible=!1}});t.exports=u},function(t,e,i){var n=i(0),s=i(88),r=new n({Extends:s,initialize:function(t,e,i,n,r){s.call(this,t,e,i,[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,1,1,1,0,0,1,1,1,0],[16777215,16777215,16777215,16777215,16777215,16777215],[1,1,1,1,1,1],n,r),this.resetPosition()},topLeftX:{get:function(){return this.x+this.vertices[0]},set:function(t){this.vertices[0]=t-this.x,this.vertices[6]=t-this.x}},topLeftY:{get:function(){return this.y+this.vertices[1]},set:function(t){this.vertices[1]=t-this.y,this.vertices[7]=t-this.y}},topRightX:{get:function(){return this.x+this.vertices[10]},set:function(t){this.vertices[10]=t-this.x}},topRightY:{get:function(){return this.y+this.vertices[11]},set:function(t){this.vertices[11]=t-this.y}},bottomLeftX:{get:function(){return this.x+this.vertices[2]},set:function(t){this.vertices[2]=t-this.x}},bottomLeftY:{get:function(){return this.y+this.vertices[3]},set:function(t){this.vertices[3]=t-this.y}},bottomRightX:{get:function(){return this.x+this.vertices[4]},set:function(t){this.vertices[4]=t-this.x,this.vertices[8]=t-this.x}},bottomRightY:{get:function(){return this.y+this.vertices[5]},set:function(t){this.vertices[5]=t-this.y,this.vertices[9]=t-this.y}},topLeftAlpha:{get:function(){return this.alphas[0]},set:function(t){this.alphas[0]=t,this.alphas[3]=t}},topRightAlpha:{get:function(){return this.alphas[5]},set:function(t){this.alphas[5]=t}},bottomLeftAlpha:{get:function(){return this.alphas[1]},set:function(t){this.alphas[1]=t}},bottomRightAlpha:{get:function(){return this.alphas[2]},set:function(t){this.alphas[2]=t,this.alphas[4]=t}},topLeftColor:{get:function(){return this.colors[0]},set:function(t){this.colors[0]=t,this.colors[3]=t}},topRightColor:{get:function(){return this.colors[5]},set:function(t){this.colors[5]=t}},bottomLeftColor:{get:function(){return this.colors[1]},set:function(t){this.colors[1]=t}},bottomRightColor:{get:function(){return this.colors[2]},set:function(t){this.colors[2]=t,this.colors[4]=t}},setTopLeft:function(t,e){return this.topLeftX=t,this.topLeftY=e,this},setTopRight:function(t,e){return this.topRightX=t,this.topRightY=e,this},setBottomLeft:function(t,e){return this.bottomLeftX=t,this.bottomLeftY=e,this},setBottomRight:function(t,e){return this.bottomRightX=t,this.bottomRightY=e,this},resetPosition:function(){var t=this.x,e=this.y,i=Math.floor(this.width/2),n=Math.floor(this.height/2);return this.setTopLeft(t-i,e-n),this.setTopRight(t+i,e-n),this.setBottomLeft(t-i,e+n),this.setBottomRight(t+i,e+n),this},resetAlpha:function(){var t=this.alphas;return t[0]=1,t[1]=1,t[2]=1,t[3]=1,t[4]=1,t[5]=1,this},resetColors:function(){var t=this.colors;return t[0]=16777215,t[1]=16777215,t[2]=16777215,t[3]=16777215,t[4]=16777215,t[5]=16777215,this},reset:function(){return this.resetPosition(),this.resetAlpha(),this.resetColors()}});t.exports=r},function(t,e){t.exports=function(t,e,i,n){void 0===i&&(i=!1),void 0===n&&(n=[]);for(var s,r,o,a,h,l,u=t.x3-t.x1,c=t.y3-t.y1,d=t.x2-t.x1,f=t.y2-t.y1,p=u*u+c*c,g=u*d+c*f,v=d*d+f*f,y=p*v-g*g,m=0===y?0:1/y,x=t.x1,b=t.y1,w=0;w=0&&r>=0&&s+r<1&&(n.push({x:e[w].x,y:e[w].y}),i)));w++);return n}},function(t,e){t.exports=function(t,e,i,n){var s=Math.cos(n),r=Math.sin(n),o=t.x1-e,a=t.y1-i;return t.x1=o*s-a*r+e,t.y1=o*r+a*s+i,o=t.x2-e,a=t.y2-i,t.x2=o*s-a*r+e,t.y2=o*r+a*s+i,t}},function(t,e){t.exports=function(t,e,i){for(var n=!1,s=-1,r=t.points.length-1;++s0&&(n.totalDuration+=n.t2*n.repeat),n.totalDuration>t&&(t=n.totalDuration)}this.duration=t,this.loopCounter=-1===this.loop?999999999999:this.loop,this.loopCounter>0?this.totalDuration=this.duration+this.completeDelay+(this.duration+this.loopDelay)*this.loopCounter:this.totalDuration=this.duration+this.completeDelay},init:function(){for(var t=this.data,e=this.totalTargets,i=0;i0){this.elapsed=0,this.progress=0,this.loopCounter--;var t=this.callbacks.onLoop;t&&(t.params[1]=this.targets,t.func.apply(t.scope,t.params)),this.resetTweenData(!0),this.loopDelay>0?(this.countdown=this.loopDelay,this.state=o.LOOP_DELAY):this.state=o.ACTIVE}else if(this.completeDelay>0)this.countdown=this.completeDelay,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.PENDING_REMOVE}},pause:function(){if(this.state!==o.PAUSED)return this.paused=!0,this._pausedState=this.state,this.state=o.PAUSED,this},play:function(t){if(this.state!==o.ACTIVE){this.state!==o.PENDING_REMOVE&&this.state!==o.REMOVED||(this.init(),this.parent.makeActive(this),t=!0);var e=this.callbacks.onStart;this.parentIsTimeline?(this.resetTweenData(t),0===this.calculatedOffset?(e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.ACTIVE):(this.countdown=this.calculatedOffset,this.state=o.OFFSET_DELAY)):this.paused?(this.paused=!1,this.parent.makeActive(this)):(this.resetTweenData(t),this.state=o.ACTIVE,e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)))}},resetTweenData:function(t){for(var e=this.data,i=0;i0?(n.elapsed=n.delay,n.state=o.DELAY):n.state=o.PENDING_RENDER}},resume:function(){return this.state===o.PAUSED&&(this.paused=!1,this.state=this._pausedState),this},seek:function(t){for(var e=this.data,i=0;i=s.totalDuration?(r=1,o=s.duration):n>s.delay&&n<=s.t1?(r=(n=Math.max(0,n-s.delay))/s.t1,o=s.duration*r):n>s.t1&&ns.repeatDelay&&(r=n/s.t1,o=s.duration*r)),s.progress=r,s.elapsed=o;var a=s.ease(s.progress);s.current=s.start+(s.end-s.start)*a,s.target[s.key]=s.current}},setCallback:function(t,e,i,n){return this.callbacks[t]={func:e,scope:n,params:i},this},complete:function(t){if(void 0===t&&(t=0),t)this.countdown=t,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.PENDING_REMOVE}},stop:function(t){void 0!==t&&this.seek(t),this.state=o.PENDING_REMOVE},update:function(t,e){if(this.state===o.PAUSED)return!1;switch(this.useFrames&&(e=1*this.parent.timeScale),e*=this.timeScale,this.elapsed+=e,this.progress=Math.min(this.elapsed/this.duration,1),this.totalElapsed+=e,this.totalProgress=Math.min(this.totalElapsed/this.totalDuration,1),this.state){case o.ACTIVE:for(var i=!1,n=0;n0){e.repeatCounter--,e.elapsed=i,e.progress=i/e.duration,e.flipX&&e.target.toggleFlipX(),e.flipY&&e.target.toggleFlipY();var s=t.callbacks.onRepeat;return s&&(s.params[1]=e.target,s.func.apply(s.scope,s.params)),e.start=e.getStartValue(e.target,e.key,e.start),e.end=e.getEndValue(e.target,e.key,e.start),e.repeatDelay>0?(e.elapsed=e.repeatDelay-i,e.current=e.start,e.target[e.key]=e.current,o.REPEAT_DELAY):o.PLAYING_FORWARD}return o.COMPLETE},setStateFromStart:function(t,e,i){if(e.repeatCounter>0){e.repeatCounter--,e.elapsed=i,e.progress=i/e.duration,e.flipX&&e.target.toggleFlipX(),e.flipY&&e.target.toggleFlipY();var n=t.callbacks.onRepeat;return n&&(n.params[1]=e.target,n.func.apply(n.scope,n.params)),e.end=e.getEndValue(e.target,e.key,e.start),e.repeatDelay>0?(e.elapsed=e.repeatDelay-i,e.current=e.start,e.target[e.key]=e.current,o.REPEAT_DELAY):o.PLAYING_FORWARD}return o.COMPLETE},updateTweenData:function(t,e,i){switch(e.state){case o.PLAYING_FORWARD:case o.PLAYING_BACKWARD:if(!e.target){e.state=o.COMPLETE;break}var n=e.elapsed,s=e.duration,r=0;(n+=i)>s&&(r=n-s,n=s);var a,h=e.state===o.PLAYING_FORWARD,l=n/s;a=h?e.ease(l):e.ease(1-l),e.current=e.start+(e.end-e.start)*a,e.target[e.key]=e.current,e.elapsed=n,e.progress=l;var u=t.callbacks.onUpdate;u&&(u.params[1]=e.target,u.func.apply(u.scope,u.params)),1===l&&(h?e.hold>0?(e.elapsed=e.hold-r,e.state=o.HOLD_DELAY):e.state=this.setStateFromEnd(t,e,r):e.state=this.setStateFromStart(t,e,r));break;case o.DELAY:e.elapsed-=i,e.elapsed<=0&&(e.elapsed=Math.abs(e.elapsed),e.state=o.PENDING_RENDER);break;case o.REPEAT_DELAY:e.elapsed-=i,e.elapsed<=0&&(e.elapsed=Math.abs(e.elapsed),e.state=o.PLAYING_FORWARD);break;case o.HOLD_DELAY:e.elapsed-=i,e.elapsed<=0&&(e.state=this.setStateFromEnd(t,e,Math.abs(e.elapsed)));break;case o.PENDING_RENDER:e.target?(e.start=e.getStartValue(e.target,e.key,e.target[e.key]),e.end=e.getEndValue(e.target,e.key,e.start),e.current=e.start,e.target[e.key]=e.start,e.state=o.PLAYING_FORWARD):e.state=o.COMPLETE}return e.state!==o.COMPLETE}});a.TYPES=["onComplete","onLoop","onRepeat","onStart","onUpdate","onYoyo"],r.register("tween",function(t){return this.scene.sys.tweens.add(t)}),s.register("tween",function(t){return this.scene.sys.tweens.create(t)}),t.exports=a},function(t,e){t.exports=function(t,e,i,n,s,r,o,a,h,l,u,c,d){return{target:t,key:e,getEndValue:i,getStartValue:n,ease:s,duration:0,totalDuration:0,delay:0,yoyo:a,hold:0,repeat:0,repeatDelay:0,flipX:c,flipY:d,progress:0,elapsed:0,repeatCounter:0,start:0,current:0,end:0,t1:0,t2:0,gen:{delay:r,duration:o,hold:h,repeat:l,repeatDelay:u},state:0}}},function(t,e,i){var n=i(50);t.exports=function(t){return n(t,-Math.PI,Math.PI)}},function(t,e,i){var n=i(50);t.exports=function(t){return n(t,-180,180)}},function(t,e,i){var n=i(0),s=i(515),r=i(166),o=new n({Extends:r,initialize:function(t){t.fragShader=s.replace("%LIGHT_COUNT%",10..toString()),r.call(this,t)},onBind:function(){r.prototype.onBind.call(this);var t=this.renderer,e=this.program;return this.mvpUpdate(),t.setInt1(e,"uNormSampler",1),t.setFloat2(e,"uResolution",this.width,this.height),this},onRender:function(t,e){var i=t.sys.lights;if(!i)return this;if(i.culledLights.length=0,i.lights.length<=0||!i.active)return this;var n,s=this.renderer,r=this.program,o=i.cull(e),a=Math.min(o.length,10),h=e.matrix,l={x:0,y:0},u=s.height;for(n=0;n<10;++n)s.setFloat1(r,"uLights["+n+"].radius",0);if(a<=0)return this;for(s.setFloat4(r,"uCamera",e.x,e.y,e.rotation,e.zoom),s.setFloat3(r,"uAmbientLightColor",i.ambientColor.r,i.ambientColor.g,i.ambientColor.b),n=0;n0?(n.textures[e-1]&&n.textures[e-1]!==t&&this.pushBatch(),i[i.length-1].textures[e-1]=t):(null!==n.texture&&n.texture!==t&&this.pushBatch(),i[i.length-1].texture=t),this},pushBatch:function(){var t={first:this.vertexCount,texture:null,textures:[]};this.batches.push(t)},flush:function(){if(this.flushLocked)return this;this.flushLocked=!0;var t,e,i,n=this.gl,s=this.renderer,r=this.vertexCount,o=this.topology,a=this.vertexSize,h=this.batches,l=0,u=null;if(0===h.length||0===r)return this.flushLocked=!1,this;n.bufferSubData(n.ARRAY_BUFFER,0,this.bytes.subarray(0,r*a));for(var c=0;c0){for(e=0;e0){for(e=0;e0&&(s.setTexture2D(u.texture,0),n.drawArrays(o,u.first,l)),this.vertexCount=0,h.length=0,this.pushBatch(),this.flushLocked=!1,this},onBind:function(){return h.prototype.onBind.call(this),this.mvpUpdate(),0===this.batches.length&&this.pushBatch(),this},resize:function(t,e,i){return h.prototype.resize.call(this,t,e,i),this.projOrtho(0,this.width,this.height,0,-1e3,1e3),this},drawStaticTilemapLayer:function(t){if(t.vertexCount>0){var e=this.vertexBuffer,i=this.gl,n=this.renderer,s=t.tileset.image.get();n.currentPipeline&&n.currentPipeline.vertexCount>0&&n.flush(),this.vertexBuffer=t.vertexBuffer,n.setPipeline(this),n.setTexture2D(s.source.glTexture,0),i.drawArrays(this.topology,0,t.vertexCount),this.vertexBuffer=e}this.viewIdentity(),this.modelIdentity()},drawEmitterManager:function(t,e){this.renderer.setPipeline(this);var i=this.renderer.config.roundPixels,n=t.emitters.list,s=n.length,r=this.vertexViewF32,o=this.vertexViewU32,a=this.renderer,h=this.maxQuads,l=e.scrollX,u=e.scrollY,c=e.matrix.matrix,d=c[0],f=c[1],p=c[2],g=c[3],v=c[4],y=c[5],m=Math.sin,x=Math.cos,b=this.vertexComponentCount,w=this.vertexCapacity,T=t.defaultFrame.source.glTexture;this.setTexture2D(T,0);for(var S=0;S=w&&(this.flush(),this.setTexture2D(T,0));for(var k=0;k<_;++k){for(var F=Math.min(M,h),O=0;O=w&&(this.flush(),this.setTexture2D(T,0))}}}this.setTexture2D(T,0)},drawBlitter:function(t,e){this.renderer.setPipeline(this);for(var i=this.renderer.config.roundPixels,n=a.getTintAppendFloatAlpha,s=this.vertexViewF32,r=this.vertexViewU32,o=t.getRenderList(),h=o.length,l=e.matrix.matrix,u=l[0],c=l[1],d=l[2],f=l[3],p=l[4],g=l[5],v=e.scrollX*t.scrollFactorX,y=e.scrollY*t.scrollFactorY,m=Math.ceil(h/this.maxQuads),x=0,b=t.x-v,w=t.y-y,T=0;T=this.vertexCapacity&&this.flush()}x+=S,h-=S,this.vertexCount>=this.vertexCapacity&&this.flush()}},batchSprite:function(t,e){this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var i,n=this.renderer.config.roundPixels,s=a.getTintAppendFloatAlpha,r=this.vertexViewF32,o=this.vertexViewU32,h=e.matrix.matrix,l=t.frame,u=l.texture.source[l.sourceIndex].glTexture,c=!!u.isRenderTexture,d=t.flipX,f=t.flipY^c,p=l.uvs,g=l.width*(d?-1:1),v=l.height*(f?-1:1),y=-t.displayOriginX+l.x+l.width*(d?1:0),m=-t.displayOriginY+l.y+l.height*(f?1:0),x=(n?0|y:y)+g,b=(n?0|m:m)+v,w=t.x-e.scrollX*t.scrollFactorX,T=t.y-e.scrollY*t.scrollFactorY,S=t.scaleX,A=t.scaleY,C=-t.rotation,M=t._alphaTL,_=t._alphaTR,E=t._alphaBL,P=t._alphaBR,L=t._tintTL,k=t._tintTR,F=t._tintBL,O=t._tintBR,R=Math.sin(C),B=Math.cos(C),I=B*S,D=-R*S,Y=R*A,z=B*A,X=w,N=T,V=h[0],W=h[1],G=h[2],U=h[3],j=I*V+D*G,H=I*W+D*U,q=Y*V+z*G,K=Y*W+z*U,J=X*V+N*G+h[4],Z=X*W+N*U+h[5],Q=y*j+m*q+J,$=y*H+m*K+Z,tt=y*j+b*q+J,et=y*H+b*K+Z,it=x*j+b*q+J,nt=x*H+b*K+Z,st=x*j+m*q+J,rt=x*H+m*K+Z,ot=s(L,M),at=s(k,_),ht=s(F,E),lt=s(O,P);n&&(Q|=0,$|=0,tt|=0,et|=0,it|=0,nt|=0,st|=0,rt|=0),this.setTexture2D(u,0),r[(i=this.vertexCount*this.vertexComponentCount)+0]=Q,r[i+1]=$,r[i+2]=p.x0,r[i+3]=p.y0,o[i+4]=ot,r[i+5]=tt,r[i+6]=et,r[i+7]=p.x1,r[i+8]=p.y1,o[i+9]=ht,r[i+10]=it,r[i+11]=nt,r[i+12]=p.x2,r[i+13]=p.y2,o[i+14]=lt,r[i+15]=Q,r[i+16]=$,r[i+17]=p.x0,r[i+18]=p.y0,o[i+19]=ot,r[i+20]=it,r[i+21]=nt,r[i+22]=p.x2,r[i+23]=p.y2,o[i+24]=lt,r[i+25]=st,r[i+26]=rt,r[i+27]=p.x3,r[i+28]=p.y3,o[i+29]=at,this.vertexCount+=6},batchMesh:function(t,e){var i=t.vertices,n=i.length,s=n/2|0;this.renderer.setPipeline(this),this.vertexCount+s>this.vertexCapacity&&this.flush();var r=this.renderer.config.roundPixels,o=a.getTintAppendFloatAlpha,h=t.uv,l=t.colors,u=t.alphas,c=this.vertexViewF32,d=this.vertexViewU32,f=e.matrix.matrix,p=t.frame,g=t.texture.source[p.sourceIndex].glTexture,v=t.x-e.scrollX*t.scrollFactorX,y=t.y-e.scrollY*t.scrollFactorY,m=t.scaleX,x=t.scaleY,b=-t.rotation,w=Math.sin(b),T=Math.cos(b),S=T*m,A=-w*m,C=w*x,M=T*x,_=v,E=y,P=f[0],L=f[1],k=f[2],F=f[3],O=S*P+A*k,R=S*L+A*F,B=C*P+M*k,I=C*L+M*F,D=_*P+E*k+f[4],Y=_*L+E*F+f[5],z=0;this.setTexture2D(g,0),z=this.vertexCount*this.vertexComponentCount;for(var X=0,N=0;Xthis.vertexCapacity&&this.flush();var i,n,s,r,o,h,l,u,c=this.renderer.config.roundPixels,d=t.text,f=d.length,p=a.getTintAppendFloatAlpha,g=this.vertexViewF32,v=this.vertexViewU32,y=e.matrix.matrix,m=e.width+50,x=e.height+50,b=t.frame,w=t.texture.source[b.sourceIndex],T=e.scrollX*t.scrollFactorX,S=e.scrollY*t.scrollFactorY,A=t.fontData,C=A.lineHeight,M=t.fontSize/A.size,_=A.chars,E=t.alpha,P=p(t._tintTL,E),L=p(t._tintTR,E),k=p(t._tintBL,E),F=p(t._tintBR,E),O=t.x,R=t.y,B=b.cutX,I=b.cutY,D=w.width,Y=w.height,z=w.glTexture,X=0,N=0,V=0,W=0,G=null,U=0,j=0,H=0,q=0,K=0,J=0,Z=0,Q=0,$=0,tt=0,et=0,it=0,nt=null,st=0,rt=O-T+b.x,ot=R-S+b.y,at=-t.rotation,ht=t.scaleX,lt=t.scaleY,ut=Math.sin(at),ct=Math.cos(at),dt=ct*ht,ft=-ut*ht,pt=ut*lt,gt=ct*lt,vt=rt,yt=ot,mt=y[0],xt=y[1],bt=y[2],wt=y[3],Tt=dt*mt+ft*bt,St=dt*xt+ft*wt,At=pt*mt+gt*bt,Ct=pt*xt+gt*wt,Mt=vt*mt+yt*bt+y[4],_t=vt*xt+yt*wt+y[5],Et=0;this.setTexture2D(z,0);for(var Pt=0;Ptm||n<-50||n>x)&&(s<-50||s>m||r<-50||r>x)&&(o<-50||o>m||h<-50||h>x)&&(l<-50||l>m||u<-50||u>x)||(this.vertexCount+6>this.vertexCapacity&&this.flush(),c&&(i|=0,n|=0,s|=0,r|=0,o|=0,h|=0,l|=0,u|=0),g[(Et=this.vertexCount*this.vertexComponentCount)+0]=i,g[Et+1]=n,g[Et+2]=$,g[Et+3]=et,v[Et+4]=P,g[Et+5]=s,g[Et+6]=r,g[Et+7]=$,g[Et+8]=it,v[Et+9]=k,g[Et+10]=o,g[Et+11]=h,g[Et+12]=tt,g[Et+13]=it,v[Et+14]=F,g[Et+15]=i,g[Et+16]=n,g[Et+17]=$,g[Et+18]=et,v[Et+19]=P,g[Et+20]=o,g[Et+21]=h,g[Et+22]=tt,g[Et+23]=it,v[Et+24]=F,g[Et+25]=l,g[Et+26]=u,g[Et+27]=tt,g[Et+28]=et,v[Et+29]=L,this.vertexCount+=6))}}else X=0,V=0,N+=C,nt=null},batchDynamicBitmapText:function(t,e){this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var i,n,s,r,o,h,l,u,c,d,f,p,g,v,y=this.renderer.config.roundPixels,m=t.displayCallback,x=t.text,b=x.length,w=a.getTintAppendFloatAlpha,T=this.vertexViewF32,S=this.vertexViewU32,A=this.renderer,C=e.matrix.matrix,M=t.frame,_=t.texture.source[M.sourceIndex],E=e.scrollX*t.scrollFactorX,P=e.scrollY*t.scrollFactorY,L=t.scrollX,k=t.scrollY,F=t.fontData,O=F.lineHeight,R=t.fontSize/F.size,B=F.chars,I=t.alpha,D=w(t._tintTL,I),Y=w(t._tintTR,I),z=w(t._tintBL,I),X=w(t._tintBR,I),N=t.x,V=t.y,W=M.cutX,G=M.cutY,U=_.width,j=_.height,H=_.glTexture,q=0,K=0,J=0,Z=0,Q=null,$=0,tt=0,et=0,it=0,nt=0,st=0,rt=0,ot=0,at=0,ht=0,lt=0,ut=0,ct=null,dt=0,ft=N+M.x,pt=V+M.y,gt=-t.rotation,vt=t.scaleX,yt=t.scaleY,mt=Math.sin(gt),xt=Math.cos(gt),bt=xt*vt,wt=-mt*vt,Tt=mt*yt,St=xt*yt,At=ft,Ct=pt,Mt=C[0],_t=C[1],Et=C[2],Pt=C[3],Lt=bt*Mt+wt*Et,kt=bt*_t+wt*Pt,Ft=Tt*Mt+St*Et,Ot=Tt*_t+St*Pt,Rt=At*Mt+Ct*Et+C[4],Bt=At*_t+Ct*Pt+C[5],It=t.cropWidth>0||t.cropHeight>0,Dt=0;this.setTexture2D(H,0),It&&A.pushScissor(t.x,t.y,t.cropWidth*t.scaleX,t.cropHeight*t.scaleY);for(var Yt=0;Ytthis.vertexCapacity&&this.flush(),y&&(i|=0,n|=0,s|=0,r|=0,o|=0,h|=0,l|=0,u|=0),T[(Dt=this.vertexCount*this.vertexComponentCount)+0]=i,T[Dt+1]=n,T[Dt+2]=at,T[Dt+3]=lt,S[Dt+4]=D,T[Dt+5]=s,T[Dt+6]=r,T[Dt+7]=at,T[Dt+8]=ut,S[Dt+9]=z,T[Dt+10]=o,T[Dt+11]=h,T[Dt+12]=ht,T[Dt+13]=ut,S[Dt+14]=X,T[Dt+15]=i,T[Dt+16]=n,T[Dt+17]=at,T[Dt+18]=lt,S[Dt+19]=D,T[Dt+20]=o,T[Dt+21]=h,T[Dt+22]=ht,T[Dt+23]=ut,S[Dt+24]=X,T[Dt+25]=l,T[Dt+26]=u,T[Dt+27]=ht,T[Dt+28]=lt,S[Dt+29]=Y,this.vertexCount+=6}}}else q=0,J=0,K+=O,ct=null;It&&A.popScissor()},batchText:function(t,e){var i=a.getTintAppendFloatAlpha;this.batchTexture(t,t.canvasTexture,t.canvasTexture.width,t.canvasTexture.height,t.x,t.y,t.canvasTexture.width,t.canvasTexture.height,t.scaleX,t.scaleY,t.rotation,t.flipX,t.flipY,t.scrollFactorX,t.scrollFactorY,t.displayOriginX,t.displayOriginY,0,0,t.canvasTexture.width,t.canvasTexture.height,i(t._tintTL,t._alphaTL),i(t._tintTR,t._alphaTR),i(t._tintBL,t._alphaBL),i(t._tintBR,t._alphaBR),0,0,e)},batchDynamicTilemapLayer:function(t,e){for(var i=t.culledTiles,n=i.length,s=t.tileset.image.get().source.glTexture,r=t.tileset,o=t.scrollFactorX,h=t.scrollFactorY,l=t.alpha,u=t.x,c=t.y,d=t.scaleX,f=t.scaleY,p=a.getTintAppendFloatAlpha,g=0;gthis.vertexCapacity&&this.flush(),d^=e.isRenderTexture?1:0,u=-u;var E,P=this.renderer.config.roundPixels,L=this.vertexViewF32,k=this.vertexViewU32,F=_.matrix.matrix,O=o*(c?1:0)-g,R=a*(d?1:0)-v,B=O+o*(c?-1:1),I=R+a*(d?-1:1),D=s-_.scrollX*f,Y=r-_.scrollY*p,z=Math.sin(u),X=Math.cos(u),N=X*h,V=-z*h,W=z*l,G=X*l,U=D,j=Y,H=F[0],q=F[1],K=F[2],J=F[3],Z=N*H+V*K,Q=N*q+V*J,$=W*H+G*K,tt=W*q+G*J,et=U*H+j*K+F[4],it=U*q+j*J+F[5],nt=O*Z+R*$+et,st=O*Q+R*tt+it,rt=O*Z+I*$+et,ot=O*Q+I*tt+it,at=B*Z+I*$+et,ht=B*Q+I*tt+it,lt=B*Z+R*$+et,ut=B*Q+R*tt+it,ct=y/i+C,dt=m/n+M,ft=(y+x)/i+C,pt=(m+b)/n+M;this.setTexture2D(e,0),P&&(nt|=0,st|=0,rt|=0,ot|=0,at|=0,ht|=0,lt|=0,ut|=0),L[(E=this.vertexCount*this.vertexComponentCount)+0]=nt,L[E+1]=st,L[E+2]=ct,L[E+3]=dt,k[E+4]=w,L[E+5]=rt,L[E+6]=ot,L[E+7]=ct,L[E+8]=pt,k[E+9]=T,L[E+10]=at,L[E+11]=ht,L[E+12]=ft,L[E+13]=pt,k[E+14]=S,L[E+15]=nt,L[E+16]=st,L[E+17]=ct,L[E+18]=dt,k[E+19]=w,L[E+20]=at,L[E+21]=ht,L[E+22]=ft,L[E+23]=pt,k[E+24]=S,L[E+25]=lt,L[E+26]=ut,L[E+27]=ft,L[E+28]=dt,k[E+29]=A,this.vertexCount+=6},drawTexture:function(t,e,i,n,s,r,o,h,l,u){this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var c,d=this.renderer.config.roundPixels,f=this.vertexViewF32,p=this.vertexViewU32,g=e,v=i,y=g+h,m=v+l,x=u[0],b=u[1],w=u[2],T=u[3],S=u[4],A=u[5],C=g*x+v*w+S,M=g*b+v*T+A,_=g*x+m*w+S,E=g*b+m*T+A,P=y*x+m*w+S,L=y*b+m*T+A,k=y*x+v*w+S,F=y*b+v*T+A,O=t.width,R=t.height,B=r/O,I=o/R,D=(r+h)/O,Y=(o+l)/R;n=a.getTintAppendFloatAlpha(n,s),this.setTexture2D(t,0),d&&(C|=0,M|=0,_|=0,E|=0,P|=0,L|=0,k|=0,F|=0),f[(c=this.vertexCount*this.vertexComponentCount)+0]=C,f[c+1]=M,f[c+2]=B,f[c+3]=I,p[c+4]=n,f[c+5]=_,f[c+6]=E,f[c+7]=B,f[c+8]=Y,p[c+9]=n,f[c+10]=P,f[c+11]=L,f[c+12]=D,f[c+13]=Y,p[c+14]=n,f[c+15]=C,f[c+16]=M,f[c+17]=B,f[c+18]=I,p[c+19]=n,f[c+20]=P,f[c+21]=L,f[c+22]=D,f[c+23]=Y,p[c+24]=n,f[c+25]=k,f[c+26]=F,f[c+27]=D,f[c+28]=I,p[c+29]=n,this.vertexCount+=6,this.flush()},batchGraphics:function(){}});t.exports=l},function(t,e,i){var n={};t.exports=n;var s=i(38);n.on=function(t,e,i){for(var n,s=e.split(" "),r=0;r0?1:.7),e.damping=e.damping||0,e.angularStiffness=e.angularStiffness||0,e.angleA=e.bodyA?e.bodyA.angle:e.angleA,e.angleB=e.bodyB?e.bodyB.angle:e.angleB,e.plugin={};var o={visible:!0,lineWidth:2,strokeStyle:"#ffffff",type:"line",anchors:!0};return 0===e.length&&e.stiffness>.1?(o.type="pin",o.anchors=!1):e.stiffness<.9&&(o.type="spring"),e.render=l.extend(o,e.render),e},n.preSolveAll=function(t){for(var e=0;e0&&(c.position.x+=l.x,c.position.y+=l.y),0!==l.angle&&(s.rotate(c.vertices,l.angle,i.position),h.rotate(c.axes,l.angle),u>0&&r.rotateAbout(c.position,l.angle,i.position,c.position)),a.update(c.bounds,c.vertices,i.velocity)}l.angle*=n._warming,l.x*=n._warming,l.y*=n._warming}}}},function(t,e){var i;i=function(){return this}();try{i=i||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e){t.exports=function(t){if("object"!=typeof t||t.nodeType||t===t.window)return!1;try{if(t.constructor&&!{}.hasOwnProperty.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}return!0}},function(t,e,i){t.exports={Angle:i(386),Call:i(387),GetFirst:i(388),GridAlign:i(389),IncAlpha:i(407),IncX:i(408),IncXY:i(409),IncY:i(410),PlaceOnCircle:i(411),PlaceOnEllipse:i(412),PlaceOnLine:i(413),PlaceOnRectangle:i(414),PlaceOnTriangle:i(415),PlayAnimation:i(416),RandomCircle:i(417),RandomEllipse:i(418),RandomLine:i(419),RandomRectangle:i(420),RandomTriangle:i(421),Rotate:i(422),RotateAround:i(423),RotateAroundDistance:i(424),ScaleX:i(425),ScaleXY:i(426),ScaleY:i(427),SetAlpha:i(428),SetBlendMode:i(429),SetDepth:i(430),SetHitArea:i(431),SetOrigin:i(432),SetRotation:i(433),SetScale:i(434),SetScaleX:i(435),SetScaleY:i(436),SetTint:i(437),SetVisible:i(438),SetX:i(439),SetXY:i(440),SetY:i(441),ShiftPosition:i(442),Shuffle:i(443),SmootherStep:i(444),SmoothStep:i(445),Spread:i(446),ToggleVisible:i(447)}},function(t,e,i){var n=i(173),s=[];s[n.BOTTOM_CENTER]=i(174),s[n.BOTTOM_LEFT]=i(175),s[n.BOTTOM_RIGHT]=i(176),s[n.CENTER]=i(177),s[n.LEFT_CENTER]=i(179),s[n.RIGHT_CENTER]=i(180),s[n.TOP_CENTER]=i(181),s[n.TOP_LEFT]=i(182),s[n.TOP_RIGHT]=i(183);t.exports=function(t,e,i,n,r){return s[i](t,e,n,r)}},function(t,e){t.exports={TOP_LEFT:0,TOP_CENTER:1,TOP_RIGHT:2,LEFT_TOP:3,LEFT_CENTER:4,LEFT_BOTTOM:5,CENTER:6,RIGHT_TOP:7,RIGHT_CENTER:8,RIGHT_BOTTOM:9,BOTTOM_LEFT:10,BOTTOM_CENTER:11,BOTTOM_RIGHT:12}},function(t,e,i){var n=i(24),s=i(46),r=i(25),o=i(47);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(24),s=i(26),r=i(25),o=i(27);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(24),s=i(28),r=i(25),o=i(29);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(178),s=i(46),r=i(49);t.exports=function(t,e,i,o){return void 0===i&&(i=0),void 0===o&&(o=0),n(t,s(e)+i,r(e)+o),t}},function(t,e,i){var n=i(47),s=i(48);t.exports=function(t,e,i){return n(t,e),s(t,i)}},function(t,e,i){var n=i(49),s=i(26),r=i(48),o=i(27);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(49),s=i(28),r=i(48),o=i(29);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(46),s=i(30),r=i(47),o=i(31);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)-a),t}},function(t,e,i){var n=i(26),s=i(30),r=i(27),o=i(31);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)-i),o(t,s(e)-a),t}},function(t,e,i){var n=i(28),s=i(30),r=i(29),o=i(31);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)-a),t}},function(t,e,i){var n=i(105),s=i(65),r=i(16),o=i(5);t.exports=function(t,e,i){void 0===i&&(i=new o);var a=s(e,0,r.PI2);return n(t,a,i)}},function(t,e,i){var n=i(186),s=i(105),r=i(65),o=i(16);t.exports=function(t,e,i,a){void 0===a&&(a=[]),e||(e=n(t)/i);for(var h=0;h=t.right&&(h=1,a+=o-t.right,o=t.right);break;case 1:(a+=e)>=t.bottom&&(h=2,o-=a-t.bottom,a=t.bottom);break;case 2:(o-=e)<=t.left&&(h=3,a-=t.left-o,o=t.left);break;case 3:(a-=e)<=t.top&&(h=0,a=t.top)}return r}},function(t,e){t.exports=function(t,e){void 0===e&&(e=1);for(var i=null,n=0;n-h&&(c-=h,n+=l),f0){if(0===t)this.frames=i.concat(this.frames);else if(t===this.frames.length)this.frames=this.frames.concat(i);else{var n=this.frames.slice(0,t),s=this.frames.slice(t);this.frames=n.concat(i,s)}this.updateFrameSequence()}return this},checkFrame:function(t){return t0){o.isLast=!0,o.nextFrame=l[0],l[0].prevFrame=o;var v=1/(l.length-1);for(a=0;a=this.frames.length&&(e=0),t.currentAnim!==this&&(t.currentAnim=this,t._timeScale=1,t.frameRate=this.frameRate,t.duration=this.duration,t.msPerFrame=this.msPerFrame,t.skipMissedFrames=this.skipMissedFrames,t._delay=this.delay,t._repeat=this.repeat,t._repeatDelay=this.repeatDelay,t._yoyo=this.yoyo,t._callbackArgs[1]=this,t._updateParams=t._callbackArgs.concat(this.onUpdateParams)),t.updateFrame(this.frames[e])},nextFrame:function(t){var e=t.currentFrame;e.isLast?this.yoyo?(t.forward=!1,t.updateFrame(e.prevFrame),this.getNextTick(t)):t.repeatCounter>0?this.repeatAnimation(t):this.completeAnimation(t):(t.updateFrame(e.nextFrame),this.getNextTick(t))},previousFrame:function(t){var e=t.currentFrame;e.isFirst?t.repeatCounter>0?this.repeatAnimation(t):this.completeAnimation(t):(t.updateFrame(e.prevFrame),this.getNextTick(t))},removeFrame:function(t){var e=this.frames.indexOf(t);return-1!==e&&this.removeFrameAt(e),this},removeFrameAt:function(t){return this.frames.splice(t,1),this.updateFrameSequence(),this},repeatAnimation:function(t){t._repeatDelay>0&&!1===t.pendingRepeat?(t.pendingRepeat=!0,t.accumulator-=t.nextTick,t.nextTick+=1e3*t._repeatDelay):(t.repeatCounter--,t.forward=!0,t.updateFrame(t.currentFrame.nextFrame),this.getNextTick(t),t.pendingRepeat=!1,this.onRepeat&&this.onRepeat.apply(this.callbackScope,t._callbackArgs.concat(this.onRepeatParams)))},setFrame:function(t){t.forward?this.nextFrame(t):this.previousFrame(t)},toJSON:function(){var t={key:this.key,type:this.type,frames:[],frameRate:this.frameRate,duration:this.duration,skipMissedFrames:this.skipMissedFrames,delay:this.delay,repeat:this.repeat,repeatDelay:this.repeatDelay,yoyo:this.yoyo,showOnStart:this.showOnStart,hideOnComplete:this.hideOnComplete};return this.frames.forEach(function(e){t.frames.push(e.toJSON())}),t},updateFrameSequence:function(){for(var t=this.frames.length,e=1/(t-1),i=0;i1&&(n.prevFrame=this.frames[i-1],n.nextFrame=this.frames[i+1])}return this},pause:function(){return this.paused=!0,this},resume:function(){return this.paused=!1,this},destroy:function(){}});t.exports=o},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n){this.textureKey=t,this.textureFrame=e,this.index=i,this.frame=n,this.isFirst=!1,this.isLast=!1,this.prevFrame=null,this.nextFrame=null,this.duration=0,this.progress=0,this.onUpdate=null},toJSON:function(){return{key:this.textureKey,frame:this.textureFrame,duration:this.duration}},destroy:function(){this.frame=void 0,this.onUpdate=void 0}});t.exports=n},function(t,e,i){var n=i(197),s=i(0),r=i(114),o=i(14),a=i(4),h=i(200),l=new s({Extends:o,initialize:function(t){o.call(this),this.game=t,this.textureManager=null,this.globalTimeScale=1,this.anims=new r,this.paused=!1,this.name="AnimationManager",t.events.once("boot",this.boot,this)},boot:function(){this.textureManager=this.game.textures,this.game.events.once("destroy",this.destroy,this)},add:function(t,e){if(!this.anims.has(t))return e.key=t,this.anims.set(t,e),this.emit("add",t,e),this;console.warn("Animation with key",t,"already exists")},create:function(t){var e=t.key;if(e&&!this.anims.has(e)){var i=new n(this,e,t);return this.anims.set(e,i),this.emit("add",e,i),i}console.warn("Invalid Animation Key, or Key already in use: "+e)},fromJSON:function(t,e){void 0===e&&(e=!1),e&&this.anims.clear(),"string"==typeof t&&(t=JSON.parse(t));var i=[];if(t.hasOwnProperty("anims")&&Array.isArray(t.anims)){for(var n=0;n=(t=t.toString()).length)switch(n){case 1:t=new Array(e+1-t.length).join(i)+t;break;case 3:var r=Math.ceil((s=e-t.length)/2);t=new Array(s-r+1).join(i)+t+new Array(r+1).join(i);break;default:t+=new Array(e+1-t.length).join(i)}return t}},function(t,e,i){var n=i(0),s=i(114),r=i(14),o=new n({initialize:function(){this.entries=new s,this.events=new r},add:function(t,e){return this.entries.set(t,e),this.events.emit("add",this,t,e),this},has:function(t){return this.entries.has(t)},get:function(t){return this.entries.get(t)},remove:function(t){var e=this.get(t);return e&&(this.entries.delete(t),this.events.emit("remove",this,t,e.data)),this},destroy:function(){this.entries.clear(),this.events.removeAllListeners(),this.entries=null,this.events=null}});t.exports=o},function(t,e,i){var n=i(201),s=new(i(0))({initialize:function(t){this.game=t,this.binary=new n,this.bitmapFont=new n,this.json=new n,this.physics=new n,this.shader=new n,this.audio=new n,this.text=new n,this.obj=new n,this.tilemap=new n,this.xml=new n,this.custom={},this.game.events.once("destroy",this.destroy,this)},addCustom:function(t){return this.custom.hasOwnProperty(t)||(this.custom[t]=new n),this.custom[t]},destroy:function(){for(var t=["binary","bitmapFont","json","physics","shader","audio","text","obj","tilemap","xml"],e=0;e16777215?{a:t>>>24,r:t>>16&255,g:t>>8&255,b:255&t}:{a:255,r:t>>16&255,g:t>>8&255,b:255&t}}},function(t,e,i){var n=i(36);t.exports=function(t){return new n(t.r,t.g,t.b,t.a)}},function(t,e,i){var n=i(36);t.exports=function(t){var e=new n,i=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(t.toLowerCase());if(i){var s=parseInt(i[1],10),r=parseInt(i[2],10),o=parseInt(i[3],10),a=void 0!==i[4]?parseFloat(i[4]):1;e.setTo(s,r,o,255*a)}return e}},function(t,e){t.exports=function(t,e){void 0===e&&(e=1);var i=2*Math.random()*Math.PI,n=2*Math.random()-1,s=Math.sqrt(1-n*n)*e;return t.x=Math.cos(i)*s,t.y=Math.sin(i)*s,t.z=n*e,t}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1),t.x=(2*Math.random()-1)*e,t.y=(2*Math.random()-1)*e,t.z=(2*Math.random()-1)*e,t.w=(2*Math.random()-1)*e,t}},function(t,e,i){var n=i(51),s=i(119),r=i(212),o=new s,a=new r,h=new n;t.exports=function(t,e,i){return a.setAxisAngle(e,i),o.fromRotationTranslation(a,h.set(0,0,0)),t.transformMat4(o)}},function(t,e,i){var n=i(0),s=i(51),r=i(213),o=new Int8Array([1,2,0]),a=new Float32Array([0,0,0]),h=new s(1,0,0),l=new s(0,1,0),u=new s,c=new r,d=new n({initialize:function(t,e,i,n){"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this.w=t.w||0):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=n||0)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},set:function(t,e,i,n){return"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this.w=t.w||0):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=n||0),this},add:function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this},subtract:function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this},scale:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},length:function(){var t=this.x,e=this.y,i=this.z,n=this.w;return Math.sqrt(t*t+e*e+i*i+n*n)},lengthSq:function(){var t=this.x,e=this.y,i=this.z,n=this.w;return t*t+e*e+i*i+n*n},normalize:function(){var t=this.x,e=this.y,i=this.z,n=this.w,s=t*t+e*e+i*i+n*n;return s>0&&(s=1/Math.sqrt(s),this.x=t*s,this.y=e*s,this.z=i*s,this.w=n*s),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z,r=this.w;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this.w=r+e*(t.w-r),this},rotationTo:function(t,e){var i=t.x*e.x+t.y*e.y+t.z*e.z;return i<-.999999?(u.copy(h).cross(t).length()<1e-6&&u.copy(l).cross(t),u.normalize(),this.setAxisAngle(u,Math.PI)):i>.999999?(this.x=0,this.y=0,this.z=0,this.w=1,this):(u.copy(t).cross(e),this.x=u.x,this.y=u.y,this.z=u.z,this.w=1+i,this.normalize())},setAxes:function(t,e,i){var n=c.val;return n[0]=e.x,n[3]=e.y,n[6]=e.z,n[1]=i.x,n[4]=i.y,n[7]=i.z,n[2]=-t.x,n[5]=-t.y,n[8]=-t.z,this.fromMat3(c).normalize()},identity:function(){return this.x=0,this.y=0,this.z=0,this.w=1,this},setAxisAngle:function(t,e){e*=.5;var i=Math.sin(e);return this.x=i*t.x,this.y=i*t.y,this.z=i*t.z,this.w=Math.cos(e),this},multiply:function(t){var e=this.x,i=this.y,n=this.z,s=this.w,r=t.x,o=t.y,a=t.z,h=t.w;return this.x=e*h+s*r+i*a-n*o,this.y=i*h+s*o+n*r-e*a,this.z=n*h+s*a+e*o-i*r,this.w=s*h-e*r-i*o-n*a,this},slerp:function(t,e){var i=this.x,n=this.y,s=this.z,r=this.w,o=t.x,a=t.y,h=t.z,l=t.w,u=i*o+n*a+s*h+r*l;u<0&&(u=-u,o=-o,a=-a,h=-h,l=-l);var c=1-e,d=e;if(1-u>1e-6){var f=Math.acos(u),p=Math.sin(f);c=Math.sin((1-e)*f)/p,d=Math.sin(e*f)/p}return this.x=c*i+d*o,this.y=c*n+d*a,this.z=c*s+d*h,this.w=c*r+d*l,this},invert:function(){var t=this.x,e=this.y,i=this.z,n=this.w,s=t*t+e*e+i*i+n*n,r=s?1/s:0;return this.x=-t*r,this.y=-e*r,this.z=-i*r,this.w=n*r,this},conjugate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},rotateX:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o+s*r,this.y=i*o+n*r,this.z=n*o-i*r,this.w=s*o-e*r,this},rotateY:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o-n*r,this.y=i*o+s*r,this.z=n*o+e*r,this.w=s*o-i*r,this},rotateZ:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o+i*r,this.y=i*o-e*r,this.z=n*o+s*r,this.w=s*o-n*r,this},calculateW:function(){var t=this.x,e=this.y,i=this.z;return this.w=-Math.sqrt(Math.abs(1-t*t-e*e-i*i)),this},fromMat3:function(t){var e,i=t.val,n=i[0]+i[4]+i[8];if(n>0)e=Math.sqrt(n+1),this.w=.5*e,e=.5/e,this.x=(i[7]-i[5])*e,this.y=(i[2]-i[6])*e,this.z=(i[3]-i[1])*e;else{var s=0;i[4]>i[0]&&(s=1),i[8]>i[3*s+s]&&(s=2);var r=o[s],h=o[r];e=Math.sqrt(i[3*s+s]-i[3*r+r]-i[3*h+h]+1),a[s]=.5*e,e=.5/e,a[r]=(i[3*r+s]+i[3*s+r])*e,a[h]=(i[3*h+s]+i[3*s+h])*e,this.x=a[0],this.y=a[1],this.z=a[2],this.w=(i[3*h+r]-i[3*r+h])*e}return this}});t.exports=d},function(t,e,i){var n=new(i(0))({initialize:function(t){this.val=new Float32Array(9),t?this.copy(t):this.identity()},clone:function(){return new n(this)},set:function(t){return this.copy(t)},copy:function(t){var e=this.val,i=t.val;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this},fromMat4:function(t){var e=t.val,i=this.val;return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[4],i[4]=e[5],i[5]=e[6],i[6]=e[8],i[7]=e[9],i[8]=e[10],this},fromArray:function(t){var e=this.val;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],this},identity:function(){var t=this.val;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,this},transpose:function(){var t=this.val,e=t[1],i=t[2],n=t[5];return t[1]=t[3],t[2]=t[6],t[3]=e,t[5]=t[7],t[6]=i,t[7]=n,this},invert:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=l*r-o*h,c=-l*s+o*a,d=h*s-r*a,f=e*u+i*c+n*d;return f?(f=1/f,t[0]=u*f,t[1]=(-l*i+n*h)*f,t[2]=(o*i-n*r)*f,t[3]=c*f,t[4]=(l*e-n*a)*f,t[5]=(-o*e+n*s)*f,t[6]=d*f,t[7]=(-h*e+i*a)*f,t[8]=(r*e-i*s)*f,this):null},adjoint:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8];return t[0]=r*l-o*h,t[1]=n*h-i*l,t[2]=i*o-n*r,t[3]=o*a-s*l,t[4]=e*l-n*a,t[5]=n*s-e*o,t[6]=s*h-r*a,t[7]=i*a-e*h,t[8]=e*r-i*s,this},determinant:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8];return e*(l*r-o*h)+i*(-l*s+o*a)+n*(h*s-r*a)},multiply:function(t){var e=this.val,i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],h=e[6],l=e[7],u=e[8],c=t.val,d=c[0],f=c[1],p=c[2],g=c[3],v=c[4],y=c[5],m=c[6],x=c[7],b=c[8];return e[0]=d*i+f*r+p*h,e[1]=d*n+f*o+p*l,e[2]=d*s+f*a+p*u,e[3]=g*i+v*r+y*h,e[4]=g*n+v*o+y*l,e[5]=g*s+v*a+y*u,e[6]=m*i+x*r+b*h,e[7]=m*n+x*o+b*l,e[8]=m*s+x*a+b*u,this},translate:function(t){var e=this.val,i=t.x,n=t.y;return e[6]=i*e[0]+n*e[3]+e[6],e[7]=i*e[1]+n*e[4]+e[7],e[8]=i*e[2]+n*e[5]+e[8],this},rotate:function(t){var e=this.val,i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],h=Math.sin(t),l=Math.cos(t);return e[0]=l*i+h*r,e[1]=l*n+h*o,e[2]=l*s+h*a,e[3]=l*r-h*i,e[4]=l*o-h*n,e[5]=l*a-h*s,this},scale:function(t){var e=this.val,i=t.x,n=t.y;return e[0]=i*e[0],e[1]=i*e[1],e[2]=i*e[2],e[3]=n*e[3],e[4]=n*e[4],e[5]=n*e[5],this},fromQuat:function(t){var e=t.x,i=t.y,n=t.z,s=t.w,r=e+e,o=i+i,a=n+n,h=e*r,l=e*o,u=e*a,c=i*o,d=i*a,f=n*a,p=s*r,g=s*o,v=s*a,y=this.val;return y[0]=1-(c+f),y[3]=l+v,y[6]=u-g,y[1]=l-v,y[4]=1-(h+f),y[7]=d+p,y[2]=u+g,y[5]=d-p,y[8]=1-(h+c),this},normalFromMat4:function(t){var e=t.val,i=this.val,n=e[0],s=e[1],r=e[2],o=e[3],a=e[4],h=e[5],l=e[6],u=e[7],c=e[8],d=e[9],f=e[10],p=e[11],g=e[12],v=e[13],y=e[14],m=e[15],x=n*h-s*a,b=n*l-r*a,w=n*u-o*a,T=s*l-r*h,S=s*u-o*h,A=r*u-o*l,C=c*v-d*g,M=c*y-f*g,_=c*m-p*g,E=d*y-f*v,P=d*m-p*v,L=f*m-p*y,k=x*L-b*P+w*E+T*_-S*M+A*C;return k?(k=1/k,i[0]=(h*L-l*P+u*E)*k,i[1]=(l*_-a*L-u*M)*k,i[2]=(a*P-h*_+u*C)*k,i[3]=(r*P-s*L-o*E)*k,i[4]=(n*L-r*_+o*M)*k,i[5]=(s*_-n*P-o*C)*k,i[6]=(v*A-y*S+m*T)*k,i[7]=(y*w-g*A-m*b)*k,i[8]=(g*S-v*w+m*x)*k,this):null}});t.exports=n},function(t,e,i){var n=i(118),s=i(0),r=new(i(51)),o=new s({Extends:n,initialize:function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=0),n.call(this,t),this.viewportWidth=e,this.viewportHeight=i,this._zoom=1,this.near=0,this.update()},setToOrtho:function(t,e,i){void 0===e&&(e=this.viewportWidth),void 0===i&&(i=this.viewportHeight);var n=this.zoom;return this.up.set(0,t?-1:1,0),this.direction.set(0,0,t?1:-1),this.position.set(n*e/2,n*i/2,0),this.viewportWidth=e,this.viewportHeight=i,this.update()},update:function(){var t=this.viewportWidth,e=this.viewportHeight,i=Math.abs(this.near),n=Math.abs(this.far),s=this.zoom;return 0===t||0===e?this:(this.projection.ortho(s*-t/2,s*t/2,s*-e/2,s*e/2,i,n),r.copy(this.position).add(this.direction),this.view.lookAt(this.position,r,this.up),this.combined.copy(this.projection).multiply(this.view),this.invProjectionView.copy(this.combined).invert(),this.billboardMatrixDirty=!0,this.updateChildren(),this)},zoom:{get:function(){return this._zoom},set:function(t){this._zoom=t,this.update()}}});t.exports=o},function(t,e,i){var n=i(118),s=i(0),r=new(i(51)),o=new s({Extends:n,initialize:function(t,e,i,s){void 0===e&&(e=80),void 0===i&&(i=0),void 0===s&&(s=0),n.call(this,t),this.viewportWidth=i,this.viewportHeight=s,this.fieldOfView=e*Math.PI/180,this.update()},setFOV:function(t){return this.fieldOfView=t*Math.PI/180,this},update:function(){var t=this.viewportWidth/this.viewportHeight;return this.projection.perspective(this.fieldOfView,t,Math.abs(this.near),Math.abs(this.far)),r.copy(this.position).add(this.direction),this.view.lookAt(this.position,r,this.up),this.combined.copy(this.projection).multiply(this.view),this.invProjectionView.copy(this.combined).invert(),this.billboardMatrixDirty=!0,this.updateChildren(),this}});t.exports=o},function(t,e,i){var n=i(217),s=i(21),r=i(4);t.exports=function(t){var e=r(t,"data",[]),i=r(t,"canvas",null),o=r(t,"palette",n),a=r(t,"pixelWidth",1),h=r(t,"pixelHeight",a),l=r(t,"resizeCanvas",!0),u=r(t,"clearCanvas",!0),c=r(t,"preRender",null),d=r(t,"postRender",null),f=Math.floor(Math.abs(e[0].length*a)),p=Math.floor(Math.abs(e.length*h));i||(i=s.create2D(this,f,p),l=!1,u=!1),l&&(i.width=f,i.height=p);var g=i.getContext("2d");u&&g.clearRect(0,0,f,p),c&&c(i,g);for(var v=0;vi;)n-=i;ni.length-2?i.length-1:r+1],c=i[r>i.length-3?i.length-1:r+2];return e.set(n(a,h.x,l.x,u.x,c.x),n(a,h.y,l.y,u.y,c.y))},toJSON:function(){for(var t=[],e=0;e1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}}).call(e,i(496)(t))},function(t,e,i){var n=i(117);t.exports=function(t,e,i){void 0===e&&(e=1),void 0===i&&(i=1);var s=Math.floor(6*t),r=6*t-s,o=Math.floor(i*(1-e)*255),a=Math.floor(i*(1-r*e)*255),h=Math.floor(i*(1-(1-r)*e)*255),l={r:i=Math.floor(i*=255),g:i,b:i,color:0},u=s%6;return 0===u?(l.g=h,l.b=o):1===u?(l.r=a,l.b=o):2===u?(l.r=o,l.b=h):3===u?(l.r=o,l.g=a):4===u?(l.r=h,l.g=o):5===u&&(l.g=o,l.b=a),l.color=n(l.r,l.g,l.b),l}},function(t,e){t.exports=function(t,e){return Math.floor(Math.random()*(e-t+1)+t)}},function(t,e,i){var n=i(67);t.exports=function(t){if("complete"!==document.readyState&&"interactive"!==document.readyState){var e=function(){document.removeEventListener("deviceready",e,!0),document.removeEventListener("DOMContentLoaded",e,!0),window.removeEventListener("load",e,!0),t()};document.body?n.cordova&&!n.cocoonJS?document.addEventListener("deviceready",e,!1):(document.addEventListener("DOMContentLoaded",e,!0),window.addEventListener("load",e,!0)):window.setTimeout(e,20)}else t()}},function(t,e){t.exports=function(t){var e="";try{window.DOMParser?e=(new DOMParser).parseFromString(t,"text/xml"):(e=new ActiveXObject("Microsoft.XMLDOM")).loadXML(t)}catch(t){e=null}return e&&e.documentElement&&!e.getElementsByTagName("parsererror").length?e:null}},function(t,e){t.exports=function(t){t.parentNode&&t.parentNode.removeChild(t)}},function(t,e,i){var n=i(0),s=i(3),r=new n({initialize:function(){this.isRunning=!1,this.callback=s,this.tick=0,this.isSetTimeOut=!1,this.timeOutID=null,this.lastTime=0;var t=this;this.step=function e(i){t.lastTime=t.tick,t.tick=i,t.callback(i),t.timeOutID=window.requestAnimationFrame(e)},this.stepTimeout=function e(){var i=Date.now(),n=Math.max(16+t.lastTime-i,0);t.lastTime=t.tick,t.tick=i,t.callback(i),t.timeOutID=window.setTimeout(e,n)}},start:function(t,e){this.isRunning||(this.callback=t,this.isSetTimeOut=e,this.isRunning=!0,this.timeOutID=e?window.setTimeout(this.stepTimeout,0):window.requestAnimationFrame(this.step))},stop:function(){this.isRunning=!1,this.isSetTimeOut?clearTimeout(this.timeOutID):window.cancelAnimationFrame(this.timeOutID)},destroy:function(){this.stop(),this.callback=s}});t.exports=r},function(t,e){t.exports={Global:["anims","cache","registry","sound","textures"],CoreScene:["EventEmitter","CameraManager","GameObjectCreator","GameObjectFactory","ScenePlugin","DisplayList","UpdateList"],DefaultScene:["CameraManager3D","Clock","DataManagerPlugin","InputPlugin","Loader","TweenManager","LightsPlugin"]}},function(t,e,i){var n,s,r,o=i(21),a={supportInverseAlpha:!1,supportNewBlendModes:!1};t.exports=(void 0!==document&&(a.supportNewBlendModes=(n="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/",s="AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==",(r=new Image).onload=function(){var t=new Image;t.onload=function(){var e=o.create(t,6,1).getContext("2d");if(e.globalCompositeOperation="multiply",e.drawImage(r,0,0),e.drawImage(t,2,0),!e.getImageData(2,0,1,1))return!1;var i=e.getImageData(2,0,1,1).data;o.remove(t),a.supportNewBlendModes=255===i[0]&&0===i[1]&&0===i[2]},t.src=n+"/wCKxvRF"+s},r.src=n+"AP804Oa6"+s,!1),a.supportInverseAlpha=function(){var t=o.create(this,2,1).getContext("2d");t.fillStyle="rgba(10, 20, 30, 0.5)",t.fillRect(0,0,1,1);var e=t.getImageData(0,0,1,1);if(null===e)return!1;t.putImageData(e,1,0);var i=t.getImageData(1,0,1,1);return i.data[0]===e.data[0]&&i.data[1]===e.data[1]&&i.data[2]===e.data[2]&&i.data[3]===e.data[3]}()),a)},function(t,e,i){"use strict";function n(t,e,i){i=i||2;var n,a,h,l,u,f,g,v=e&&e.length,y=v?e[0]*i:t.length,m=s(t,0,y,i,!0),x=[];if(!m)return x;if(v&&(m=function(t,e,i,n){var o,a,h,l,u,f=[];for(o=0,a=e.length;o80*i){n=h=t[0],a=l=t[1];for(var b=i;bh&&(h=u),f>l&&(l=f);g=Math.max(h-n,l-a)}return o(m,x,i,n,a,g),x}function s(t,e,i,n,s){var r,o;if(s===C(t,e,i,n)>0)for(r=e;r=e;r-=n)o=T(r,t[r],t[r+1],o);return o&&m(o,o.next)&&(S(o),o=o.next),o}function r(t,e){if(!t)return t;e||(e=t);var i,n=t;do{if(i=!1,n.steiner||!m(n,n.next)&&0!==y(n.prev,n,n.next))n=n.next;else{if(S(n),(n=e=n.prev)===n.next)return null;i=!0}}while(i||n!==e);return e}function o(t,e,i,n,s,c,d){if(t){!d&&c&&function(t,e,i,n){var s=t;do{null===s.z&&(s.z=f(s.x,s.y,e,i,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){var e,i,n,s,r,o,a,h,l=1;do{for(i=t,t=null,r=null,o=0;i;){for(o++,n=i,a=0,e=0;e0||h>0&&n;)0!==a&&(0===h||!n||i.z<=n.z)?(s=i,i=i.nextZ,a--):(s=n,n=n.nextZ,h--),r?r.nextZ=s:t=s,s.prevZ=r,r=s;i=n}r.nextZ=null,l*=2}while(o>1)}(s)}(t,n,s,c);for(var p,g,v=t;t.prev!==t.next;)if(p=t.prev,g=t.next,c?h(t,n,s,c):a(t))e.push(p.i/i),e.push(t.i/i),e.push(g.i/i),S(t),t=g.next,v=g.next;else if((t=g)===v){d?1===d?o(t=l(t,e,i),e,i,n,s,c,2):2===d&&u(t,e,i,n,s,c):o(r(t),e,i,n,s,c,1);break}}}function a(t){var e=t.prev,i=t,n=t.next;if(y(e,i,n)>=0)return!1;for(var s=t.next.next;s!==t.prev;){if(g(e.x,e.y,i.x,i.y,n.x,n.y,s.x,s.y)&&y(s.prev,s,s.next)>=0)return!1;s=s.next}return!0}function h(t,e,i,n){var s=t.prev,r=t,o=t.next;if(y(s,r,o)>=0)return!1;for(var a=s.xr.x?s.x>o.x?s.x:o.x:r.x>o.x?r.x:o.x,u=s.y>r.y?s.y>o.y?s.y:o.y:r.y>o.y?r.y:o.y,c=f(a,h,e,i,n),d=f(l,u,e,i,n),p=t.nextZ;p&&p.z<=d;){if(p!==t.prev&&p!==t.next&&g(s.x,s.y,r.x,r.y,o.x,o.y,p.x,p.y)&&y(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=t.prevZ;p&&p.z>=c;){if(p!==t.prev&&p!==t.next&&g(s.x,s.y,r.x,r.y,o.x,o.y,p.x,p.y)&&y(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}function l(t,e,i){var n=t;do{var s=n.prev,r=n.next.next;!m(s,r)&&x(s,n,n.next,r)&&b(s,r)&&b(r,s)&&(e.push(s.i/i),e.push(n.i/i),e.push(r.i/i),S(n),S(n.next),n=t=r),n=n.next}while(n!==t);return n}function u(t,e,i,n,s,a){var h=t;do{for(var l=h.next.next;l!==h.prev;){if(h.i!==l.i&&v(h,l)){var u=w(h,l);return h=r(h,h.next),u=r(u,u.next),o(h,e,i,n,s,a),void o(u,e,i,n,s,a)}l=l.next}h=h.next}while(h!==t)}function c(t,e){return t.x-e.x}function d(t,e){if(e=function(t,e){var i,n=e,s=t.x,r=t.y,o=-1/0;do{if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){var a=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(a<=s&&a>o){if(o=a,a===s){if(r===n.y)return n;if(r===n.next.y)return n.next}i=n.x=n.x&&n.x>=u&&s!==n.x&&g(ri.x)&&b(n,t)&&(i=n,d=h),n=n.next;return i}(t,e)){var i=w(e,t);r(i,i.next)}}function f(t,e,i,n,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)/s)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)/s)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function p(t){var e=t,i=t;do{e.x=0&&(t-o)*(n-a)-(i-o)*(e-a)>=0&&(i-o)*(r-a)-(s-o)*(n-a)>=0}function v(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&x(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&b(t,e)&&b(e,t)&&function(t,e){var i=t,n=!1,s=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&i.next.y!==i.y&&s<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)}function y(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function m(t,e){return t.x===e.x&&t.y===e.y}function x(t,e,i,n){return!!(m(t,e)&&m(i,n)||m(t,n)&&m(i,e))||y(t,e,i)>0!=y(t,e,n)>0&&y(i,n,t)>0!=y(i,n,e)>0}function b(t,e){return y(t.prev,t,t.next)<0?y(t,e,t.next)>=0&&y(t,t.prev,e)>=0:y(t,e,t.prev)<0||y(t,t.next,e)<0}function w(t,e){var i=new A(t.i,t.x,t.y),n=new A(e.i,e.x,e.y),s=t.next,r=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,n.next=i,i.prev=n,r.next=n,n.prev=r,n}function T(t,e,i,n){var s=new A(t,e,i);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function S(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function A(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function C(t,e,i,n){for(var s=0,r=e,o=i-n;r0&&(n+=t[s-1].length,i.holes.push(n))}return i}},function(t,e){var i={modelMatrixDirty:!1,viewMatrixDirty:!1,projectionMatrixDirty:!1,modelMatrix:null,viewMatrix:null,projectionMatrix:null,mvpInit:function(){return this.modelMatrixDirty=!0,this.viewMatrixDirty=!0,this.projectionMatrixDirty=!0,this.modelMatrix=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),this.viewMatrix=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),this.projectionMatrix=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),this},mvpUpdate:function(){var t=this.program;return this.modelMatrixDirty&&(this.renderer.setMatrix4(t,"uModelMatrix",!1,this.modelMatrix),this.modelMatrixDirty=!1),this.viewMatrixDirty&&(this.renderer.setMatrix4(t,"uViewMatrix",!1,this.viewMatrix),this.viewMatrixDirty=!1),this.projectionMatrixDirty&&(this.renderer.setMatrix4(t,"uProjectionMatrix",!1,this.projectionMatrix),this.projectionMatrixDirty=!1),this},modelIdentity:function(){var t=this.modelMatrix;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this.modelMatrixDirty=!0,this},modelScale:function(t,e,i){var n=this.modelMatrix;return n[0]=n[0]*t,n[1]=n[1]*t,n[2]=n[2]*t,n[3]=n[3]*t,n[4]=n[4]*e,n[5]=n[5]*e,n[6]=n[6]*e,n[7]=n[7]*e,n[8]=n[8]*i,n[9]=n[9]*i,n[10]=n[10]*i,n[11]=n[11]*i,this.modelMatrixDirty=!0,this},modelTranslate:function(t,e,i){var n=this.modelMatrix;return n[12]=n[0]*t+n[4]*e+n[8]*i+n[12],n[13]=n[1]*t+n[5]*e+n[9]*i+n[13],n[14]=n[2]*t+n[6]*e+n[10]*i+n[14],n[15]=n[3]*t+n[7]*e+n[11]*i+n[15],this.modelMatrixDirty=!0,this},modelRotateX:function(t){var e=this.modelMatrix,i=Math.sin(t),n=Math.cos(t),s=e[4],r=e[5],o=e[6],a=e[7],h=e[8],l=e[9],u=e[10],c=e[11];return e[4]=s*n+h*i,e[5]=r*n+l*i,e[6]=o*n+u*i,e[7]=a*n+c*i,e[8]=h*n-s*i,e[9]=l*n-r*i,e[10]=u*n-o*i,e[11]=c*n-a*i,this.modelMatrixDirty=!0,this},modelRotateY:function(t){var e=this.modelMatrix,i=Math.sin(t),n=Math.cos(t),s=e[0],r=e[1],o=e[2],a=e[3],h=e[8],l=e[9],u=e[10],c=e[11];return e[0]=s*n-h*i,e[1]=r*n-l*i,e[2]=o*n-u*i,e[3]=a*n-c*i,e[8]=s*i+h*n,e[9]=r*i+l*n,e[10]=o*i+u*n,e[11]=a*i+c*n,this.modelMatrixDirty=!0,this},modelRotateZ:function(t){var e=this.modelMatrix,i=Math.sin(t),n=Math.cos(t),s=e[0],r=e[1],o=e[2],a=e[3],h=e[4],l=e[5],u=e[6],c=e[7];return e[0]=s*n+h*i,e[1]=r*n+l*i,e[2]=o*n+u*i,e[3]=a*n+c*i,e[4]=h*n-s*i,e[5]=l*n-r*i,e[6]=u*n-o*i,e[7]=c*n-a*i,this.modelMatrixDirty=!0,this},viewIdentity:function(){var t=this.viewMatrix;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this.viewMatrixDirty=!0,this},viewScale:function(t,e,i){var n=this.viewMatrix;return n[0]=n[0]*t,n[1]=n[1]*t,n[2]=n[2]*t,n[3]=n[3]*t,n[4]=n[4]*e,n[5]=n[5]*e,n[6]=n[6]*e,n[7]=n[7]*e,n[8]=n[8]*i,n[9]=n[9]*i,n[10]=n[10]*i,n[11]=n[11]*i,this.viewMatrixDirty=!0,this},viewTranslate:function(t,e,i){var n=this.viewMatrix;return n[12]=n[0]*t+n[4]*e+n[8]*i+n[12],n[13]=n[1]*t+n[5]*e+n[9]*i+n[13],n[14]=n[2]*t+n[6]*e+n[10]*i+n[14],n[15]=n[3]*t+n[7]*e+n[11]*i+n[15],this.viewMatrixDirty=!0,this},viewRotateX:function(t){var e=this.viewMatrix,i=Math.sin(t),n=Math.cos(t),s=e[4],r=e[5],o=e[6],a=e[7],h=e[8],l=e[9],u=e[10],c=e[11];return e[4]=s*n+h*i,e[5]=r*n+l*i,e[6]=o*n+u*i,e[7]=a*n+c*i,e[8]=h*n-s*i,e[9]=l*n-r*i,e[10]=u*n-o*i,e[11]=c*n-a*i,this.viewMatrixDirty=!0,this},viewRotateY:function(t){var e=this.viewMatrix,i=Math.sin(t),n=Math.cos(t),s=e[0],r=e[1],o=e[2],a=e[3],h=e[8],l=e[9],u=e[10],c=e[11];return e[0]=s*n-h*i,e[1]=r*n-l*i,e[2]=o*n-u*i,e[3]=a*n-c*i,e[8]=s*i+h*n,e[9]=r*i+l*n,e[10]=o*i+u*n,e[11]=a*i+c*n,this.viewMatrixDirty=!0,this},viewRotateZ:function(t){var e=this.viewMatrix,i=Math.sin(t),n=Math.cos(t),s=e[0],r=e[1],o=e[2],a=e[3],h=e[4],l=e[5],u=e[6],c=e[7];return e[0]=s*n+h*i,e[1]=r*n+l*i,e[2]=o*n+u*i,e[3]=a*n+c*i,e[4]=h*n-s*i,e[5]=l*n-r*i,e[6]=u*n-o*i,e[7]=c*n-a*i,this.viewMatrixDirty=!0,this},viewLoad2D:function(t){var e=this.viewMatrix;return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=0,e[4]=t[2],e[5]=t[3],e[6]=0,e[7]=0,e[8]=t[4],e[9]=t[5],e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this.viewMatrixDirty=!0,this},viewLoad:function(t){var e=this.viewMatrix;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],this.viewMatrixDirty=!0,this},projIdentity:function(){var t=this.projectionMatrix;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this.projectionMatrixDirty=!0,this},projOrtho:function(t,e,i,n,s,r){var o=this.projectionMatrix,a=1/(t-e),h=1/(i-n),l=1/(s-r);return o[0]=-2*a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=-2*h,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=2*l,o[11]=0,o[12]=(t+e)*a,o[13]=(n+i)*h,o[14]=(r+s)*l,o[15]=1,this.projectionMatrixDirty=!0,this},projPersp:function(t,e,i,n){var s=this.projectionMatrix,r=1/Math.tan(t/2),o=1/(i-n);return s[0]=r/e,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=r,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=(n+i)*o,s[11]=-1,s[12]=0,s[13]=0,s[14]=2*n*i*o,s[15]=0,this.projectionMatrixDirty=!0,this}};t.exports=i},function(t,e,i){var n=i(0),s=i(14),r=i(241),o=i(245),a=i(248),h=i(249),l=i(8),u=i(250),c=i(251),d=new n({initialize:function(t,e){this.game=t,this.canvas,this.config=e,this.enabled=!0,this.events=new s,this.queue=[],this.keyboard=new o(this),this.mouse=new a(this),this.touch=new u(this),this.gamepad=new r(this),this.activePointer=new h(this,0),this.scale={x:1,y:1},this.globalTopOnly=!0,this.ignoreEvents=!1,this.bounds=new l,this._tempPoint={x:0,y:0},this._tempHitTest=[],t.events.once("boot",this.boot,this)},boot:function(){this.canvas=this.game.canvas,this.updateBounds(),this.keyboard.boot(),this.mouse.boot(),this.touch.boot(),this.gamepad.boot(),this.game.events.once("destroy",this.destroy,this)},updateBounds:function(){var t=this.bounds,e=this.canvas.getBoundingClientRect();t.x=e.left+window.pageXOffset-document.documentElement.clientLeft,t.y=e.top+window.pageYOffset-document.documentElement.clientTop,t.width=e.width,t.height=e.height},resize:function(){this.updateBounds();var t=this.game.config.width,e=this.game.config.height,i=this.bounds.width,n=this.bounds.height;this.scale.x=t/i,this.scale.y=e/n},update:function(t){this.keyboard.update(),this.gamepad.update(),this.ignoreEvents=!1;var e=this.queue.length,i=this.activePointer;if(i.reset(),this.enabled&&0!==e){this.updateBounds(),this.scale.x=this.game.config.width/this.bounds.width,this.scale.y=this.game.config.height/this.bounds.height;for(var n=this.queue.splice(0,e),s=0;s=n.x&&e>=n.y&&t<=n.x+o&&e<=n.y+a))return s;n.getWorldPoint(t,e,r);for(var h=n.cull(i),l={x:0,y:0},u=0;u0?1:-1)}});t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.pad=t,this.events=t.events,this.index=e,this.value=0,this.threshold=0,this.pressed=!1},update:function(t){this.value=t.value,this.value>=this.threshold?this.pressed||(this.pressed=!0,this.events.emit("down",this.pad,this,this.value,t)):this.pressed&&(this.pressed=!1,this.events.emit("up",this.pad,this,this.value,t))}});t.exports=n},function(t,e,i){var n=i(0),s=i(14),r=i(246),o=i(129),a=i(247),h=i(527),l=i(528),u=i(529),c=new n({Extends:s,initialize:function(t){s.call(this),this.manager=t,this.enabled=!1,this.target,this.keys=[],this.combos=[],this.captures=[],this.queue=[],this.handler},boot:function(){var t=this.manager.config;this.enabled=t.inputKeyboard,this.target=t.inputKeyboardEventTarget,this.enabled&&this.startListeners()},startListeners:function(){var t=this.queue,e=this.captures,i=function(i){i.defaultPrevented||(t.push(i),e[i.keyCode]&&i.preventDefault())};this.handler=i,this.target.addEventListener("keydown",i,!1),this.target.addEventListener("keyup",i,!1)},stopListeners:function(){this.target.removeEventListener("keydown",this.handler),this.target.removeEventListener("keyup",this.handler)},createCursorKeys:function(){return this.addKeys({up:o.UP,down:o.DOWN,left:o.LEFT,right:o.RIGHT,space:o.SPACE,shift:o.SHIFT})},addKeys:function(t){var e={};for(var i in t)e[i]=this.addKey(t[i]);return e},addKey:function(t){var e=this.keys;return e[t]||(e[t]=new r(t),this.captures[t]=!0),e[t]},removeKey:function(t){this.keys[t]&&(this.keys[t]=void 0,this.captures[t]=!1)},addKeyCapture:function(t){Array.isArray(t)||(t=[t]);for(var e=0;e-1&&(this.keys[n]=void 0,this.scenes.splice(i,1),this._start.indexOf(n)>-1&&(i=this._start.indexOf(n),this._start.splice(i,1)),e.sys.destroy())}return this},bootScene:function(t){var e;t.init&&t.init.call(t,t.sys.settings.data),t.sys.load&&(e=t.sys.load).reset(),e&&t.preload?(t.preload.call(t),0===e.list.size?this.create(t):(t.sys.settings.status=s.LOADING,e.once("complete",this.loadComplete,this),e.start())):this.create(t)},loadComplete:function(t){var e=t.scene;this.create(e)},payloadComplete:function(t){this.bootScene(t.scene)},update:function(t,e){this.processQueue(),this._processing=1;for(var i=this.scenes.length-1;i>=0;i--){var n=this.scenes[i].sys;n.settings.status===s.RUNNING&&n.step(t,e)}},resize:function(t,e){for(var i=0;i=s.LOADING&&i.settings.status0){var i=this.getScene(t);this.scenes.splice(e,1),this.scenes.unshift(i)}}return this},moveDown:function(t){if(this._processing)this._queue.push({op:"moveDown",keyA:t,keyB:null});else{var e=this.getIndex(t);if(e>0){var i=e-1,n=this.getScene(t),s=this.getAt(i);this.scenes[e]=s,this.scenes[i]=n}}return this},moveUp:function(t){if(this._processing)this._queue.push({op:"moveUp",keyA:t,keyB:null});else{var e=this.getIndex(t);if(en&&-1!==i&&-1!==n){var s=this.getAt(n);this.scenes.splice(n,1),this.scenes.splice(i,0,s)}}return this},moveBelow:function(t,e){if(t===e)return this;if(this._processing)this._queue.push({op:"moveBelow",keyA:t,keyB:e});else{var i=this.getIndex(t),n=this.getIndex(e);if(i=0;t--){this.scenes[t].sys.destroy()}this.scenes=[],this._pending=[],this._start=[],this._queue=[],this.game=null}});t.exports=l},function(t,e,i){var n=i(0),s=i(130),r=new n({initialize:function(t){this.sys=new s(this,t)},update:function(){}});t.exports=r},function(t,e){t.exports=function(t){return t&&t[0].toUpperCase()+t.slice(1)}},function(t,e,i){var n=i(83),s=i(4),r=i(532),o={create:function(t){return"string"==typeof t?t={key:t}:void 0===t&&(t={}),{status:n.PENDING,key:s(t,"key",""),active:s(t,"active",!1),visible:s(t,"visible",!0),isBooted:!1,data:{},files:s(t,"files",!1),cameras:s(t,"cameras",null),map:s(t,"map",r),physics:s(t,"physics",{}),loader:s(t,"loader",{}),plugins:s(t,"plugins",!1)}}};t.exports=o},function(t,e,i){var n=i(257),s=i(259),r=i(261),o={create:function(t){var e=t.config.audio,i=t.device.audio;return e&&e.noAudio||!i.webAudio&&!i.audioData?new s(t):!i.webAudio||e&&e.disableWebAudio?new n(t):new r(t)}};t.exports=o},function(t,e,i){var n=i(84),s=i(0),r=i(258),o=new s({Extends:n,initialize:function(t){this.override=!0,this.audioPlayDelay=.1,this.loopEndOffset=.05,this.onBlurPausedSounds=[],this.locked="ontouchstart"in window,this.lockedActionsQueue=this.locked?[]:null,this._mute=!1,this._volume=1,n.call(this,t)},add:function(t,e){var i=new r(this,t,e);return this.sounds.push(i),i},unlock:function(){var t=this,e=!1,i=function(){e=!0},n=function(){if(t.game.cache.audio.entries.size)if(e)e=!1;else{document.body.removeEventListener("touchmove",i),document.body.removeEventListener("touchend",n);var s=[];t.game.cache.audio.entries.each(function(t,e){for(var i=0;i0)&&(!!s.prototype.pause.call(this)&&(this.currentConfig.seek=this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0),this.stopAndReleaseAudioTag(),this.emit("pause",this),!0)))},resume:function(){return!this.manager.isLocked(this,"resume")&&(!(this.startTime>0)&&(!!s.prototype.resume.call(this)&&(!!this.pickAndPlayAudioTag()&&(this.emit("resume",this),!0))))},stop:function(){return!this.manager.isLocked(this,"stop")&&(!!s.prototype.stop.call(this)&&(this.stopAndReleaseAudioTag(),this.emit("stop",this),!0))},pickAndPlayAudioTag:function(){if(!this.pickAudioTag())return this.reset(),!1;var t=this.currentConfig.seek,e=this.currentConfig.delay,i=(this.currentMarker?this.currentMarker.start:0)+t;return this.previousTime=i,this.audio.currentTime=i,this.applyConfig(),0===e?(this.startTime=0,this.audio.paused&&this.playCatchPromise()):(this.startTime=window.performance.now()+1e3*e,this.audio.paused||this.audio.pause()),this.resetConfig(),!0},pickAudioTag:function(){if(this.audio)return!0;for(var t=0;t0)this.startTime=n-this.manager.loopEndOffset?(this.audio.currentTime=i+Math.max(0,s-n),s=this.audio.currentTime):s=n)return this.reset(),this.stopAndReleaseAudioTag(),void this.emit("ended",this);this.previousTime=s}},destroy:function(){s.prototype.destroy.call(this),this.tags=null,this.audio&&this.stopAndReleaseAudioTag()},setMute:function(){this.audio&&(this.audio.muted=this.currentConfig.mute||this.manager.mute)},setVolume:function(){this.audio&&(this.audio.volume=this.currentConfig.volume*this.manager.volume)},setRate:function(){s.prototype.setRate.call(this),this.audio&&(this.audio.playbackRate=this.totalRate)}});Object.defineProperty(r.prototype,"mute",{get:function(){return this.currentConfig.mute},set:function(t){this.currentConfig.mute=t,this.manager.isLocked(this,"mute",t)||(this.setMute(),this.emit("mute",this,t))}}),Object.defineProperty(r.prototype,"volume",{get:function(){return this.currentConfig.volume},set:function(t){this.currentConfig.volume=t,this.manager.isLocked(this,"volume",t)||(this.setVolume(),this.emit("volume",this,t))}}),Object.defineProperty(r.prototype,"rate",{get:function(){return Object.getOwnPropertyDescriptor(s.prototype,"rate").get.call(this)},set:function(t){this.currentConfig.rate=t,this.manager.isLocked(this,"rate",t)||Object.getOwnPropertyDescriptor(s.prototype,"rate").set.call(this,t)}}),Object.defineProperty(r.prototype,"detune",{get:function(){return Object.getOwnPropertyDescriptor(s.prototype,"detune").get.call(this)},set:function(t){this.currentConfig.detune=t,this.manager.isLocked(this,"detune",t)||Object.getOwnPropertyDescriptor(s.prototype,"detune").set.call(this,t)}}),Object.defineProperty(r.prototype,"seek",{get:function(){return this.isPlaying?this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0):this.isPaused?this.currentConfig.seek:0},set:function(t){this.manager.isLocked(this,"seek",t)||this.startTime>0||(this.isPlaying||this.isPaused)&&(t=Math.min(Math.max(0,t),this.duration),this.isPlaying?(this.previousTime=t,this.audio.currentTime=t):this.isPaused&&(this.currentConfig.seek=t),this.emit("seek",this,t))}}),Object.defineProperty(r.prototype,"loop",{get:function(){return this.currentConfig.loop},set:function(t){this.currentConfig.loop=t,this.manager.isLocked(this,"loop",t)||(this.audio&&(this.audio.loop=t),this.emit("loop",this,t))}}),t.exports=r},function(t,e,i){var n=i(84),s=i(0),r=i(14),o=i(260),a=i(3),h=new s({Extends:r,initialize:function(t){r.call(this),this.game=t,this.sounds=[],this.mute=!1,this.volume=1,this.rate=1,this.detune=0,this.pauseOnBlur=!0,this.locked=!1},add:function(t,e){var i=new o(this,t,e);return this.sounds.push(i),i},addAudioSprite:function(t,e){var i=this.add(t,e);return i.spritemap={},i},play:function(t,e){return!1},playAudioSprite:function(t,e,i){return!1},remove:function(t){return n.prototype.remove.call(this,t)},removeByKey:function(t){return n.prototype.removeByKey.call(this,t)},pauseAll:a,resumeAll:a,stopAll:a,update:a,destroy:function(){n.prototype.destroy.call(this)},forEachActiveSound:function(t,e){n.prototype.forEachActiveSound.call(this,t,e)}});t.exports=h},function(t,e,i){var n=i(85),s=i(0),r=i(14),o=i(23),a=new s({Extends:r,initialize:function(t,e,i){void 0===i&&(i={}),r.call(this),this.manager=t,this.key=e,this.isPlaying=!1,this.isPaused=!1,this.totalRate=1,this.duration=0,this.totalDuration=0,this.config=o({mute:!1,volume:1,rate:1,detune:0,seek:0,loop:!1,delay:0},i),this.currentConfig=this.config,this.mute=!1,this.volume=1,this.rate=1,this.detune=0,this.seek=0,this.loop=!1,this.markers={},this.currentMarker=null,this.pendingRemove=!1},addMarker:function(t){return!1},updateMarker:function(t){return!1},removeMarker:function(t){return null},play:function(t,e){return!1},pause:function(){return!1},resume:function(){return!1},stop:function(){return!1},destroy:function(){this.manager.remove(this),n.prototype.destroy.call(this)}});t.exports=a},function(t,e,i){var n=i(84),s=i(0),r=i(262),o=new s({Extends:n,initialize:function(t){this.context=this.createAudioContext(t),this.masterMuteNode=this.context.createGain(),this.masterVolumeNode=this.context.createGain(),this.masterMuteNode.connect(this.masterVolumeNode),this.masterVolumeNode.connect(this.context.destination),this.destination=this.masterMuteNode,this.locked="suspended"===this.context.state&&"ontouchstart"in window,n.call(this,t)},createAudioContext:function(t){var e=t.config.audio;return e&&e.context?(e.context.resume(),e.context):new AudioContext},add:function(t,e){var i=new r(this,t,e);return this.sounds.push(i),i},unlock:function(){var t=this,e=function(){t.context.resume().then(function(){document.body.removeEventListener("touchstart",e),document.body.removeEventListener("touchend",e),t.unlocked=!0})};document.body.addEventListener("touchstart",e,!1),document.body.addEventListener("touchend",e,!1)},onBlur:function(){this.context.suspend()},onFocus:function(){this.context.resume()},destroy:function(){this.destination=null,this.masterVolumeNode.disconnect(),this.masterVolumeNode=null,this.masterMuteNode.disconnect(),this.masterMuteNode=null,this.game.config.audio&&this.game.config.audio.context?this.context.suspend():this.context.close(),this.context=null,n.prototype.destroy.call(this)},mute:{get:function(){return 0===this.masterMuteNode.gain.value},set:function(t){this.masterMuteNode.gain.setValueAtTime(t?0:1,0),this.emit("mute",this,t)}},volume:{get:function(){return this.masterVolumeNode.gain.value},set:function(t){this.masterVolumeNode.gain.setValueAtTime(t,0),this.emit("volume",this,t)}}});t.exports=o},function(t,e,i){var n=i(0),s=i(85),r=new n({Extends:s,initialize:function(t,e,i){void 0===i&&(i={}),this.audioBuffer=t.game.cache.audio.get(e),this.audioBuffer?(this.source=null,this.loopSource=null,this.muteNode=t.context.createGain(),this.volumeNode=t.context.createGain(),this.playTime=0,this.startTime=0,this.loopTime=0,this.rateUpdates=[],this.hasEnded=!1,this.hasLooped=!1,this.muteNode.connect(this.volumeNode),this.volumeNode.connect(t.destination),this.duration=this.audioBuffer.duration,this.totalDuration=this.audioBuffer.duration,s.call(this,t,e,i)):console.error("No audio loaded in cache with key: '"+e+"'!")},play:function(t,e){return!!s.prototype.play.call(this,t,e)&&(this.stopAndRemoveBufferSource(),this.createAndStartBufferSource(),this.emit("play",this),!0)},pause:function(){return!(this.manager.context.currentTime=0&&t<=o.width&&e>=0&&e<=o.height){t+=s.cutX,e+=s.cutY;var a=this._tempContext;a.clearRect(0,0,1,1),a.drawImage(o,t,e,1,1,0,0,1,1);var h=a.getImageData(0,0,1,1);return new r(h.data[0],h.data[1],h.data[2],h.data[3])}}return null},setTexture:function(t,e,i){return this.list[e]&&(t.texture=this.list[e],t.frame=t.texture.get(i)),t},each:function(t,e){for(var i=[null],n=1;nl&&(r=l),o>l&&(o=l),a=s,h=r;;)if(ay&&(s=y),r>m&&(r=m);var S=y+g-s,A=m+v-r;o0&&e.cameraFilter&r._id)){var h=r.scrollX*e.scrollFactorX,l=r.scrollY*e.scrollFactorY,u=e.x,c=e.y,d=e.scaleX,f=e.scaleY,p=e.rotation,g=e.commandBuffer,v=o||t.currentContext,y=1,m=1,x=0,b=0,w=1,T=0,S=0,A=0;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,v.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,v.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode),v.save(),v.translate(u-h,c-l),v.rotate(p),v.scale(d,f),v.fillStyle="#fff",v.globalAlpha=e.alpha;for(var C=0,M=g.length;C>>16,S=(65280&x)>>>8,A=255&x,v.strokeStyle="rgba("+T+","+S+","+A+","+y+")",v.lineWidth=w,C+=3;break;case n.FILL_STYLE:b=g[C+1],m=g[C+2],T=(16711680&b)>>>16,S=(65280&b)>>>8,A=255&b,v.fillStyle="rgba("+T+","+S+","+A+","+m+")",C+=2;break;case n.BEGIN_PATH:v.beginPath();break;case n.CLOSE_PATH:v.closePath();break;case n.FILL_PATH:a||v.fill();break;case n.STROKE_PATH:a||v.stroke();break;case n.FILL_RECT:a?v.rect(g[C+1],g[C+2],g[C+3],g[C+4]):v.fillRect(g[C+1],g[C+2],g[C+3],g[C+4]),C+=4;break;case n.FILL_TRIANGLE:v.beginPath(),v.moveTo(g[C+1],g[C+2]),v.lineTo(g[C+3],g[C+4]),v.lineTo(g[C+5],g[C+6]),v.closePath(),a||v.fill(),C+=6;break;case n.STROKE_TRIANGLE:v.beginPath(),v.moveTo(g[C+1],g[C+2]),v.lineTo(g[C+3],g[C+4]),v.lineTo(g[C+5],g[C+6]),v.closePath(),a||v.stroke(),C+=6;break;case n.LINE_TO:v.lineTo(g[C+1],g[C+2]),C+=2;break;case n.MOVE_TO:v.moveTo(g[C+1],g[C+2]),C+=2;break;case n.LINE_FX_TO:v.lineTo(g[C+1],g[C+2]),C+=5;break;case n.MOVE_FX_TO:v.moveTo(g[C+1],g[C+2]),C+=5;break;case n.SAVE:v.save();break;case n.RESTORE:v.restore();break;case n.TRANSLATE:v.translate(g[C+1],g[C+2]),C+=2;break;case n.SCALE:v.scale(g[C+1],g[C+2]),C+=2;break;case n.ROTATE:v.rotate(g[C+1]),C+=1}v.restore()}}},function(t,e,i){var n=i(4),s=i(80),r=function(t,e,i){for(var n=[],s=0;s0?(h=this.lightPool.pop()).set(t,e,i,a[0],a[1],a[2],r):h=new s(t,e,i,a[0],a[1],a[2],r),this.lights.push(h),h},removeLight:function(t){var e=this.lights.indexOf(t);return e>=0&&(this.lightPool.push(t),this.lights.splice(e,1)),this},shutdown:function(){for(;this.lights.length>0;)this.lightPool.push(this.lights.pop());this.ambientColor={r:.1,g:.1,b:.1},this.culledLights.length=0,this.lights.length=0},destroy:function(){this.shutdown()}});t.exports=a},function(t,e,i){t.exports={Circle:i(665),Ellipse:i(270),Intersects:i(295),Line:i(685),Point:i(703),Polygon:i(717),Rectangle:i(307),Triangle:i(746)}},function(t,e,i){t.exports={CircleToCircle:i(675),CircleToRectangle:i(676),GetRectangleIntersection:i(677),LineToCircle:i(297),LineToLine:i(89),LineToRectangle:i(678),PointToLine:i(298),PointToLineSegment:i(679),RectangleToRectangle:i(296),RectangleToTriangle:i(680),RectangleToValues:i(681),TriangleToCircle:i(682),TriangleToLine:i(683),TriangleToTriangle:i(684)}},function(t,e){t.exports=function(t,e){return!(t.width<=0||t.height<=0||e.width<=0||e.height<=0||t.righte.right||t.y>e.bottom)}},function(t,e,i){var n=i(32),s=new(i(5));t.exports=function(t,e,i){if(void 0===i&&(i=s),n(e,t.x1,t.y1))return i.x=t.x1,i.y=t.y1,!0;if(n(e,t.x2,t.y2))return i.x=t.x2,i.y=t.y2,!0;var r=t.x2-t.x1,o=t.y2-t.y1,a=e.x-t.x1,h=e.y-t.y1,l=r*r+o*o,u=r,c=o;if(l>0){var d=(a*r+h*o)/l;u*=d,c*=d}return i.x=t.x1+u,i.y=t.y1+c,u*u+c*c<=l&&u*r+c*o>=0&&n(e,i.x,i.y)}},function(t,e){t.exports=function(t,e){return(t.x-e.x1)*(e.y2-e.y1)==(e.x2-e.x1)*(t.y-e.y1)}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=[]),e.push({x:t.x,y:t.y}),e.push({x:t.right,y:t.y}),e.push({x:t.right,y:t.bottom}),e.push({x:t.x,y:t.bottom}),e}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=[]),e.push({x:t.x1,y:t.y1}),e.push({x:t.x2,y:t.y2}),e.push({x:t.x3,y:t.y3}),e}},function(t,e,i){var n=i(0),s=i(302),r=i(109),o=i(111),a=new n({initialize:function(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x1=t,this.y1=e,this.x2=i,this.y2=n},getPoint:function(t,e){return s(this,t,e)},getPoints:function(t,e,i){return r(this,t,e,i)},getRandomPoint:function(t){return o(this,t)},setTo:function(t,e,i,n){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x1=t,this.y1=e,this.x2=i,this.y2=n,this},getPointA:function(){return{x:this.x1,y:this.y1}},getPointB:function(){return{x:this.x2,y:this.y2}},left:{get:function(){return Math.min(this.x1,this.x2)},set:function(t){this.x1<=this.x2?this.x1=t:this.x2=t}},right:{get:function(){return Math.max(this.x1,this.x2)},set:function(t){this.x1>this.x2?this.x1=t:this.x2=t}},top:{get:function(){return Math.min(this.y1,this.y2)},set:function(t){this.y1<=this.y2?this.y1=t:this.y2=t}},bottom:{get:function(){return Math.max(this.y1,this.y2)},set:function(t){this.y1>this.y2?this.y1=t:this.y2=t}}});t.exports=a},function(t,e,i){var n=i(5);t.exports=function(t,e,i){return void 0===i&&(i=new n),i.x=t.x1+(t.x2-t.x1)*e,i.y=t.y1+(t.y2-t.y1)*e,i}},function(t,e,i){var n=i(16),s=i(50),r=i(55);t.exports=function(t){var e=r(t)-n.TAU;return s(e,-Math.PI,Math.PI)}},function(t,e){t.exports=function(t){return Math.sqrt(t.x*t.x+t.y*t.y)}},function(t,e){t.exports=function(t){return t.x*t.x+t.y*t.y}},function(t,e,i){var n=i(0),s=i(147),r=new n({initialize:function(t){this.area=0,this.points=[],t&&this.setTo(t)},contains:function(t,e){return s(this,t,e)},setTo:function(t){if(this.area=0,this.points=[],!Array.isArray(t))return this;for(var e,i=Number.MAX_VALUE,n=0;n=1)return i.x=r.x1,i.y=r.y1,i;var h=s(r),l=s(o),u=s(a),c=(h+l+u)*e,d=0;return ch+l?(d=(c-=h+l)/u,i.x=a.x1+(a.x2-a.x1)*d,i.y=a.y1+(a.y2-a.y1)*d):(d=(c-=h)/l,i.x=o.x1+(o.x2-o.x1)*d,i.y=o.y1+(o.y2-o.y1)*d),i}},function(t,e,i){var n=i(66),s=i(5);t.exports=function(t,e,i,r){void 0===r&&(r=[]);var o=t.getLineA(),a=t.getLineB(),h=t.getLineC(),l=n(o),u=n(a),c=n(h),d=l+u+c;e||(e=d/i);for(var f=0;fl+u?(g=(p-=l+u)/c,v.x=h.x1+(h.x2-h.x1)*g,v.y=h.y1+(h.y2-h.y1)*g):(g=(p-=l)/u,v.x=a.x1+(a.x2-a.x1)*g,v.y=a.y1+(a.y2-a.y1)*g),r.push(v)}return r}},function(t,e,i){var n=i(5);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=(t.x1+t.x2+t.x3)/3,e.y=(t.y1+t.y2+t.y3)/3,e}},function(t,e){t.exports=function(t,e,i){return t.x1+=e,t.y1+=i,t.x2+=e,t.y2+=i,t.x3+=e,t.y3+=i,t}},function(t,e,i){var n=i(5);function s(t,e,i,n){var s=t-i,r=e-n,o=s*s+r*r;return Math.sqrt(o)}t.exports=function(t,e){void 0===e&&(e=new n);var i=t.x1,r=t.y1,o=t.x2,a=t.y2,h=t.x3,l=t.y3,u=s(h,l,o,a),c=s(i,r,h,l),d=s(o,a,i,r),f=u+c+d;return e.x=(i*u+o*c+h*d)/f,e.y=(r*u+a*c+l*d)/f,e}},function(t,e){t.exports=function(t,e,i){return{gameObject:t,enabled:!0,draggable:!1,dropZone:!1,target:null,camera:null,hitArea:e,hitAreaCallback:i,localX:0,localY:0,dragState:0,dragStartX:0,dragStartY:0,dragX:0,dragY:0}}},function(t,e,i){var n=i(151);t.exports=function(t,e){var i=n(e,t.xhrSettings),s=new XMLHttpRequest;return s.open("GET",t.src,i.async,i.user,i.password),s.responseType=t.xhrSettings.responseType,s.timeout=i.timeout,i.header&&i.headerValue&&s.setRequestHeader(i.header,i.headerValue),i.overrideMimeType&&s.overrideMimeType(i.overrideMimeType),s.onload=t.onLoad.bind(t),s.onerror=t.onError.bind(t),s.onprogress=t.onProgress.bind(t),s.send(),s}},function(t,e,i){var n=i(0),s=i(19),r=i(18),o=i(7),a=i(2),h=i(317),l=new n({Extends:r,initialize:function(t,e,i,n,s){this.context=s;var o={type:"audio",extension:a(e,"type",""),responseType:"arraybuffer",key:t,url:a(e,"uri",e),path:i,xhrSettings:n};r.call(this,o)},onProcess:function(t){this.state=s.FILE_PROCESSING;var e=this;this.context.decodeAudioData(this.xhrLoader.response,function(i){e.data=i,e.onComplete(),t(e)},function(i){console.error("Error with decoding audio data for '"+this.key+"':",i.message),e.state=s.FILE_ERRORED,t(e)}),this.context=null}});l.create=function(t,e,i,n,s){var r=t.systems.game,o=r.config.audio,a=r.device.audio;if(o&&o.noAudio||!a.webAudio&&!a.audioData)return null;var u=l.findAudioURL(r,i);return u?!a.webAudio||o&&o.disableWebAudio?new h(e,u,t.path,n,r.sound.locked):new l(e,u,t.path,s,r.sound.context):null},o.register("audio",function(t,e,i,n){var s=l.create(this,t,e,i,n);return s&&this.addFile(s),this}),l.findAudioURL=function(t,e){e.constructor!==Array&&(e=[e]);for(var i=0;i=0?t:t+2*Math.PI}},function(t,e,i){var n=i(323);t.exports=function(t,e){return n(t)/n(e)/n(t-e)}},function(t,e){t.exports=function(t){if(0===t)return 1;for(var e=t;--t;)e*=t;return e}},function(t,e){t.exports=function(t,e){var i=t.x,n=t.y;return t.x=i*Math.cos(e)-n*Math.sin(e),t.y=i*Math.sin(e)+n*Math.cos(e),t}},function(t,e){t.exports=function(t){return t>0?Math.ceil(t):Math.floor(t)}},function(t,e,i){var n=i(327),s=i(91),r=i(0),o=i(59),a=i(329),h=i(330),l=new r({initialize:function(t){this.world=t,this.scene=t.scene,this.sys=t.scene.sys},collider:function(t,e,i,n,s){return this.world.addCollider(t,e,i,n,s)},overlap:function(t,e,i,n,s){return this.world.addOverlap(t,e,i,n,s)},existing:function(t,e){var i=e?o.STATIC_BODY:o.DYNAMIC_BODY;return this.world.enableBody(t,i),t},staticImage:function(t,e,i,s){var r=new n(this.scene,t,e,i,s);return this.sys.displayList.add(r),this.world.enableBody(r,o.STATIC_BODY),r},image:function(t,e,i,s){var r=new n(this.scene,t,e,i,s);return this.sys.displayList.add(r),this.world.enableBody(r,o.DYNAMIC_BODY),r},staticSprite:function(t,e,i,n){var r=new s(this.scene,t,e,i,n);return this.sys.displayList.add(r),this.sys.updateList.add(r),this.world.enableBody(r,o.STATIC_BODY),r},sprite:function(t,e,i,n){var r=new s(this.scene,t,e,i,n);return this.sys.displayList.add(r),this.sys.updateList.add(r),this.world.enableBody(r,o.DYNAMIC_BODY),r},staticGroup:function(t,e){return this.sys.updateList.add(new h(this.world,this.world.scene,t,e))},group:function(t,e){return this.sys.updateList.add(new a(this.world,this.world.scene,t,e))}});t.exports=l},function(t,e,i){var n=i(0),s=i(328),r=i(70),o=new n({Extends:r,Mixins:[s.Acceleration,s.Angular,s.Bounce,s.Debug,s.Drag,s.Enable,s.Friction,s.Gravity,s.Immovable,s.Mass,s.Size,s.Velocity],initialize:function(t,e,i,n,s){r.call(this,t,e,i,n,s)}});t.exports=o},function(t,e,i){t.exports={Acceleration:i(838),Angular:i(839),Bounce:i(840),Debug:i(841),Drag:i(842),Enable:i(843),Friction:i(844),Gravity:i(845),Immovable:i(846),Mass:i(847),Size:i(848),Velocity:i(849)}},function(t,e,i){var n=i(91),s=i(0),r=i(59),o=i(2),a=i(69),h=new s({Extends:a,initialize:function(t,e,i,s){void 0!==s||Array.isArray(i)||"object"!=typeof i?void 0===s&&(s={}):(s=i,i=null),this.world=t,s.createCallback=this.createCallback,s.removeCallback=this.removeCallback,s.classType=o(s,"classType",n),this.physicsType=r.DYNAMIC_BODY,this.defaults={setCollideWorldBounds:o(s,"collideWorldBounds",!1),setAccelerationX:o(s,"accelerationX",0),setAccelerationY:o(s,"accelerationY",0),setBounceX:o(s,"bounceX",0),setBounceY:o(s,"bounceY",0),setDragX:o(s,"dragX",0),setDragY:o(s,"dragY",0),setGravityX:o(s,"gravityX",0),setGravityY:o(s,"gravityY",0),setFrictionX:o(s,"frictionX",0),setFrictionY:o(s,"frictionY",0),setVelocityX:o(s,"velocityX",0),setVelocityY:o(s,"velocityY",0),setAngularVelocity:o(s,"angularVelocity",0),setAngularAcceleration:o(s,"angularAcceleration",0),setAngularDrag:o(s,"angularDrag",0),setMass:o(s,"mass",1),setImmovable:o(s,"immovable",!1)},a.call(this,e,i,s)},createCallback:function(t){t.body||this.world.enableBody(t,r.DYNAMIC_BODY);var e=t.body;for(var i in this.defaults)e[i](this.defaults[i])},removeCallback:function(t){t.body&&this.world.disableBody(t)},setVelocity:function(t,e,i){void 0===i&&(i=0);for(var n=this.getChildren(),s=0;s0){var l=this.tree,u=this.staticTree;for(o=(r=s.entries).length,t=0;t0?i-=s:i+s<0?i+=s:i=0),i>r?i=r:i<-r&&(i=-r),i},separate:function(t,e,i,n,s){if(!t.enable||!e.enable||t.checkCollision.none||e.checkCollision.none||!this.intersects(t,e))return!1;if(i&&!1===i.call(n,t.gameObject,e.gameObject))return!1;if(t.isCircle&&e.isCircle)return this.separateCircle(t,e,s);if(t.isCircle!==e.isCircle){var r=t.isCircle?e:t,o=t.isCircle?t:e,a={x:r.x,y:r.y,right:r.right,bottom:r.bottom},h=o.center;if((h.ya.bottom)&&(h.xa.right))return this.separateCircle(t,e,s)}var l=!1,u=!1;this.forceX||Math.abs(this.gravity.y+t.gravity.y)l.right&&(a=h(d.x,d.y,l.right,l.y)-d.radius):d.y>l.bottom&&(d.xl.right&&(a=h(d.x,d.y,l.right,l.bottom)-d.radius)),a*=-1}else a=t.halfWidth+e.halfWidth-h(t.center.x,t.center.y,e.center.x,e.center.y);if(i||0===a||t.immovable&&e.immovable||t.customSeparateX||e.customSeparateX)return 0!==a&&(t.onOverlap||e.onOverlap)&&this.emit("overlap",t.gameObject,e.gameObject,t,e),0!==a;var f=t.velocity.x,p=t.velocity.y,g=t.mass,v=e.velocity.x,y=e.velocity.y,m=e.mass,x=f*Math.cos(o)+p*Math.sin(o),b=f*Math.sin(o)-p*Math.cos(o),w=v*Math.cos(o)+y*Math.sin(o),T=v*Math.sin(o)-y*Math.cos(o),S=((g-m)*x+2*m*w)/(g+m),A=(2*g*x+(m-g)*w)/(g+m);return t.immovable||(t.velocity.x=(S*Math.cos(o)-b*Math.sin(o))*t.bounce.x,t.velocity.y=(b*Math.cos(o)+S*Math.sin(o))*t.bounce.y,f=t.velocity.x,p=t.velocity.y),e.immovable||(e.velocity.x=(A*Math.cos(o)-T*Math.sin(o))*e.bounce.x,e.velocity.y=(T*Math.cos(o)+A*Math.sin(o))*e.bounce.y,v=e.velocity.x,y=e.velocity.y),Math.abs(o)0&&!t.immovable&&v>f?t.velocity.x*=-1:v<0&&!e.immovable&&f0&&!t.immovable&&y>p?t.velocity.y*=-1:y<0&&!e.immovable&&pMath.PI/2&&(f<0&&!t.immovable&&v0&&!e.immovable&&f>v?e.velocity.x*=-1:p<0&&!t.immovable&&y0&&!e.immovable&&f>y&&(e.velocity.y*=-1)),t.immovable||(t.x+=t.velocity.x*this.delta-a*Math.cos(o),t.y+=t.velocity.y*this.delta-a*Math.sin(o)),e.immovable||(e.x+=e.velocity.x*this.delta+a*Math.cos(o),e.y+=e.velocity.y*this.delta+a*Math.sin(o)),(t.onCollide||e.onCollide)&&this.emit("collide",t.gameObject,e.gameObject,t,e),!0},intersects:function(t,e){return t!==e&&(t.isCircle?e.isCircle?h(t.center.x,t.center.y,e.center.x,e.center.y)<=t.halfWidth+e.halfWidth:this.circleBodyIntersects(t,e):e.isCircle?this.circleBodyIntersects(e,t):!(t.right<=e.position.x)&&(!(t.bottom<=e.position.y)&&(!(t.position.x>=e.right)&&!(t.position.y>=e.bottom))))},circleBodyIntersects:function(t,e){var i=s(t.center.x,e.left,e.right),n=s(t.center.y,e.top,e.bottom);return(t.center.x-i)*(t.center.x-i)+(t.center.y-n)*(t.center.y-n)<=t.halfWidth*t.halfWidth},overlap:function(t,e,i,n,s){return void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=i),this.collideObjects(t,e,i,n,s,!0)},collide:function(t,e,i,n,s){return void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=i),this.collideObjects(t,e,i,n,s,!1)},collideObjects:function(t,e,i,n,s,r){var o;t=t.isParent&&void 0===t.physicsType?t.children.entries:t,e=e.isParent&&void 0===e.physicsType?e.children.entries:e;var a=Array.isArray(t),h=Array.isArray(e);if(this._total=0,a||h)if(!a&&h)for(o=0;o0},collideHandler:function(t,e,i,n,s,r){if(void 0===e&&t.isParent)return this.collideGroupVsGroup(t,t,i,n,s,r);if(!t||!e)return!1;if(t.body){if(e.body)return this.collideSpriteVsSprite(t,e,i,n,s,r);if(e.isParent)return this.collideSpriteVsGroup(t,e,i,n,s,r);if(e.isTilemap)return this.collideSpriteVsTilemapLayer(t,e,i,n,s,r)}else if(t.isParent){if(e.body)return this.collideSpriteVsGroup(e,t,i,n,s,r);if(e.isParent)return this.collideGroupVsGroup(t,e,i,n,s,r);if(e.isTilemap)return this.collideGroupVsTilemapLayer(t,e,i,n,s,r)}else if(t.isTilemap){if(e.body)return this.collideSpriteVsTilemapLayer(e,t,i,n,s,r);if(e.isParent)return this.collideGroupVsTilemapLayer(e,t,i,n,s,r)}},collideSpriteVsSprite:function(t,e,i,n,s,r){return!(!t.body||!e.body)&&(this.separate(t.body,e.body,n,s,r)&&(i&&i.call(s,t,e),this._total++),!0)},collideSpriteVsGroup:function(t,e,i,n,s,r){var o=t.body;if(0!==e.length&&o){var h=this.treeMinMax;h.minX=o.left,h.minY=o.top,h.maxX=o.right,h.maxY=o.bottom;var l=e.physicsType===a.DYNAMIC_BODY?this.tree.search(h):this.staticTree.search(h);if(0!==l.length)for(var u=e.getChildren(),c=0;cc.baseTileWidth){var d=(c.tileWidth-c.baseTileWidth)*e.scaleX;a-=d,l+=d}c.tileHeight>c.baseTileHeight&&(u+=(c.tileHeight-c.baseTileHeight)*e.scaleY);var f,g=e.getTilesWithinWorldXY(a,h,l,u);if(0===g.length)return!1;for(var v={left:0,right:0,top:0,bottom:0},m=0;m0&&(this.facing=r.FACING_RIGHT),this._dy<0?this.facing=r.FACING_UP:this._dy>0&&(this.facing=r.FACING_DOWN),this.moves&&(0!==this.deltaMax.x&&0!==this._dx&&(this._dx<0&&this._dx<-this.deltaMax.x?this._dx=-this.deltaMax.x:this._dx>0&&this._dx>this.deltaMax.x&&(this._dx=this.deltaMax.x)),0!==this.deltaMax.y&&0!==this._dy&&(this._dy<0&&this._dy<-this.deltaMax.y?this._dy=-this.deltaMax.y:this._dy>0&&this._dy>this.deltaMax.y&&(this._dy=this.deltaMax.y)),this.gameObject.x+=this._dx,this.gameObject.y+=this._dy,this._reset=!0),this.updateCenter(),this.allowRotation&&(this.gameObject.angle+=this.deltaZ()),this.prev.x=this.position.x,this.prev.y=this.position.y)},checkWorldBounds:function(){var t=this.position,e=this.world.bounds,i=this.world.checkCollision,n=this.worldBounce?-this.worldBounce.x:-this.bounce.x,s=this.worldBounce?-this.worldBounce.y:-this.bounce.y;return t.xe.right&&i.right&&(t.x=e.right-this.width,this.velocity.x*=n,this.blocked.right=!0,this.blocked.none=!1),t.ye.bottom&&i.down&&(t.y=e.bottom-this.height,this.velocity.y*=s,this.blocked.down=!0,this.blocked.none=!1),!this.blocked.none},setOffset:function(t,e){return void 0===e&&(e=t),this.offset.set(t,e),this},setSize:function(t,e,i){void 0===i&&(i=!0);var n=this.gameObject;if(this.sourceWidth=t,this.sourceHeight=e,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter(),i&&n.getCenter){var s=n.displayWidth/2,r=n.displayHeight/2;this.offset.set(s-this.halfWidth,r-this.halfHeight)}return this.isCircle=!1,this.radius=0,this},setCircle:function(t,e,i){return void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.isCircle=!0,this.radius=t,this.sourceWidth=2*t,this.sourceHeight=2*t,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.set(e,i),this.updateCenter()):this.isCircle=!1,this},reset:function(t,e){this.stop();var i=this.gameObject;i.setPosition(t,e),i.getTopLeft(this.position),this.prev.copy(this.position),this.rotation=i.angle,this.preRotation=i.angle,this.updateBounds(),this.updateCenter()},stop:function(){return this.velocity.set(0),this.acceleration.set(0),this.speed=0,this.angularVelocity=0,this.angularAcceleration=0,this},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,e){return this.isCircle?n(this,t,e):a(this,t,e)},onFloor:function(){return this.blocked.down},onCeiling:function(){return this.blocked.up},onWall:function(){return this.blocked.left||this.blocked.right},deltaAbsX:function(){return this.deltaX()>0?this.deltaX():-this.deltaX()},deltaAbsY:function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},deltaX:function(){return this.position.x-this.prev.x},deltaY:function(){return this.position.y-this.prev.y},deltaZ:function(){return this.rotation-this.preRotation},destroy:function(){this.enable=!1,this.world.pendingDestroy.set(this)},drawDebug:function(t){var e=this.position,i=e.x+this.halfWidth,n=e.y+this.halfHeight;this.debugShowBody&&(t.lineStyle(1,this.debugBodyColor),this.isCircle?t.strokeCircle(i,n,this.radius):t.strokeRect(e.x,e.y,this.width,this.height)),this.debugShowVelocity&&(t.lineStyle(1,this.world.defaults.velocityDebugColor,1),t.lineBetween(i,n,i+this.velocity.x/2,n+this.velocity.y/2))},willDrawDebug:function(){return this.debugShowBody||this.debugShowVelocity},setCollideWorldBounds:function(t){return this.collideWorldBounds=t,this},setVelocity:function(t,e){return this.velocity.set(t,e),this},setVelocityX:function(t){return this.velocity.x=t,this},setVelocityY:function(t){return this.velocity.y=t,this},setBounce:function(t,e){return this.bounce.set(t,e),this},setBounceX:function(t){return this.bounce.x=t,this},setBounceY:function(t){return this.bounce.y=t,this},setAcceleration:function(t,e){return this.acceleration.set(t,e),this},setAccelerationX:function(t){return this.acceleration.x=t,this},setAccelerationY:function(t){return this.acceleration.y=t,this},setDrag:function(t,e){return this.drag.set(t,e),this},setDragX:function(t){return this.drag.x=t,this},setDragY:function(t){return this.drag.y=t,this},setGravity:function(t,e){return this.gravity.set(t,e),this},setGravityX:function(t){return this.gravity.x=t,this},setGravityY:function(t){return this.gravity.y=t,this},setFriction:function(t,e){return this.friction.set(t,e),this},setFrictionX:function(t){return this.friction.x=t,this},setFrictionY:function(t){return this.friction.y=t,this},setAngularVelocity:function(t){return this.angularVelocity=t,this},setAngularAcceleration:function(t){return this.angularAcceleration=t,this},setAngularDrag:function(t){return this.angularDrag=t,this},setMass:function(t){return this.mass=t,this},setImmovable:function(t){return this.immovable=t,this},x:{get:function(){return this.position.x},set:function(t){this.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t}},left:{get:function(){return this.position.x}},right:{get:function(){return this.position.x+this.width}},top:{get:function(){return this.position.y}},bottom:{get:function(){return this.position.y+this.height}}});t.exports=l},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r,o){this.world=t,this.name="",this.active=!0,this.overlapOnly=e,this.object1=i,this.object2=n,this.collideCallback=s,this.processCallback=r,this.callbackContext=o},setName:function(t){return this.name=t,this},update:function(){this.world.collideObjects(this.object1,this.object2,this.collideCallback,this.processCallback,this.callbackContext,this.overlapOnly)},destroy:function(){this.world.removeCollider(this),this.active=!1,this.world=null,this.object1=null,this.object2=null,this.collideCallback=null,this.processCallback=null,this.callbackContext=null}});t.exports=n},function(t,e){t.exports=function(t,e,i,n){var s=0,r=t.deltaAbsX()+e.deltaAbsX()+n;return 0===t.deltaX()&&0===e.deltaX()?(t.embedded=!0,e.embedded=!0):t.deltaX()>e.deltaX()?(s=t.right-e.x)>r&&!i||!1===t.checkCollision.right||!1===e.checkCollision.left?s=0:(t.touching.none=!1,t.touching.right=!0,e.touching.none=!1,e.touching.left=!0):t.deltaX()r&&!i||!1===t.checkCollision.left||!1===e.checkCollision.right?s=0:(t.touching.none=!1,t.touching.left=!0,e.touching.none=!1,e.touching.right=!0)),t.overlapX=s,e.overlapX=s,s}},function(t,e){t.exports=function(t,e,i,n){var s=0,r=t.deltaAbsY()+e.deltaAbsY()+n;return 0===t.deltaY()&&0===e.deltaY()?(t.embedded=!0,e.embedded=!0):t.deltaY()>e.deltaY()?(s=t.bottom-e.y)>r&&!i||!1===t.checkCollision.down||!1===e.checkCollision.up?s=0:(t.touching.none=!1,t.touching.down=!0,e.touching.none=!1,e.touching.up=!0):t.deltaY()r&&!i||!1===t.checkCollision.up||!1===e.checkCollision.down?s=0:(t.touching.none=!1,t.touching.up=!0,e.touching.none=!1,e.touching.down=!0)),t.overlapY=s,e.overlapY=s,s}},function(t,e,i){var n=new(i(0))({initialize:function(){this._pending=[],this._active=[],this._destroy=[],this._toProcess=0},add:function(t){return this._pending.push(t),this._toProcess++,this},remove:function(t){return this._destroy.push(t),this._toProcess++,this},update:function(){if(0===this._toProcess)return this._active;var t,e,i=this._destroy,n=this._active;for(t=0;t=t.minX&&e.maxY>=t.minY}function g(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function v(t,e,i,s,r){for(var o,a=[e,i];a.length;)(i=a.pop())-(e=a.pop())<=s||(o=e+Math.ceil((i-e)/s/2)*s,n(t,o,e,i,r),a.push(e,o,o,i))}s.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,i=[],n=this.toBBox;if(!p(t,e))return i;for(var s,r,o,a,h=[];e;){for(s=0,r=e.children.length;s=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(s,r,e)},_split:function(t,e){var i=t[e],n=i.children.length,s=this._minEntries;this._chooseSplitAxis(i,s,n);var r=this._chooseSplitIndex(i,s,n),a=g(i.children.splice(r,i.children.length-r));a.height=i.height,a.leaf=i.leaf,o(i,this.toBBox),o(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)},_splitRoot:function(t,e){this.data=g([t,e]),this.data.height=t.height+1,this.data.leaf=!1,o(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,i){var n,s,r,o,h,l,u,d,f,p,g,v,y,m;for(l=u=1/0,n=e;n<=i-e;n++)s=a(t,0,n,this.toBBox),r=a(t,n,i,this.toBBox),f=s,p=r,void 0,void 0,void 0,void 0,g=Math.max(f.minX,p.minX),v=Math.max(f.minY,p.minY),y=Math.min(f.maxX,p.maxX),m=Math.min(f.maxY,p.maxY),o=Math.max(0,y-g)*Math.max(0,m-v),h=c(s)+c(r),o=e;s--)r=t.children[s],h(u,t.leaf?o(r):r),c+=d(u);return c},_adjustParentBBoxes:function(t,e,i){for(var n=i;n>=0;n--)h(e[n],t)},_condense:function(t){for(var e,i=t.length-1;i>=0;i--)0===t[i].children.length?i>0?(e=t[i-1].children).splice(e.indexOf(t[i]),1):this.clear():o(t[i],this.toBBox)},_initFormat:function(t){var e=["return a"," - b",";"];this.compareMinX=new Function("a","b",e.join(t[0])),this.compareMinY=new Function("a","b",e.join(t[1])),this.toBBox=new Function("a","return {minX: a"+t[0]+", minY: a"+t[1]+", maxX: a"+t[2]+", maxY: a"+t[3]+"};")}},t.exports=s},function(t,e){var i=function(t,e,r,o,a){for(r=r||0,o=o||t.length-1,a=a||s;o>r;){if(o-r>600){var h=o-r+1,l=e-r+1,u=Math.log(h),c=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*c*(h-c)/h)*(l-h/2<0?-1:1),f=Math.max(r,Math.floor(e-l*c/h+d)),p=Math.min(o,Math.floor(e+(h-l)*c/h+d));i(t,e,f,p,a)}var g=t[e],v=r,y=o;for(n(t,r,e),a(t[o],g)>0&&n(t,r,o);v0;)y--}0===a(t[r],g)?n(t,r,y):n(t,++y,o),y<=e&&(r=y+1),e<=y&&(o=y-1)}};function n(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function s(t,e){return te?1:0}t.exports=i},function(t,e){t.exports=function(t,e){return!(e.right<=t.left||e.bottom<=t.top||e.position.x>=t.right||e.position.y>=t.bottom)}},function(t,e,i){var n=i(32),s=i(0),r=i(59),o=i(33),a=i(6),h=new s({initialize:function(t,e){this.world=t,this.gameObject=e,this.debugShowBody=t.defaults.debugShowStaticBody,this.debugBodyColor=t.defaults.staticBodyDebugColor,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new a,this.position=new a(e.x-e.displayOriginX,e.y-e.displayOriginY),this.width=e.displayWidth,this.height=e.displayHeight,this.halfWidth=Math.abs(this.width/2),this.halfHeight=Math.abs(this.height/2),this.center=new a(e.x+this.halfWidth,e.y+this.halfHeight),this.velocity=a.ZERO,this.allowGravity=!1,this.gravity=a.ZERO,this.bounce=a.ZERO,this.onWorldBounds=!1,this.onCollide=!1,this.onOverlap=!1,this.mass=1,this.immovable=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.overlapR=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision={none:!1,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.blocked={none:!0,up:!1,down:!1,left:!1,right:!1},this.physicsType=r.STATIC_BODY},setGameObject:function(t,e){return t&&t!==this.gameObject&&(this.gameObject.body=null,t.body=this,this.gameObject=t),e&&this.updateFromGameObject(),this},updateFromGameObject:function(){this.world.staticTree.remove(this);var t=this.gameObject;return t.getTopLeft(this.position),this.width=t.displayWidth,this.height=t.displayHeight,this.halfWidth=Math.abs(this.width/2),this.halfHeight=Math.abs(this.height/2),this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight),this.world.staticTree.insert(this),this},setSize:function(t,e,i,n){return void 0===i&&(i=this.offset.x),void 0===n&&(n=this.offset.y),this.world.staticTree.remove(this),this.width=t,this.height=e,this.halfWidth=Math.floor(t/2),this.halfHeight=Math.floor(e/2),this.offset.set(i,n),this.updateCenter(),this.isCircle=!1,this.radius=0,this.world.staticTree.insert(this),this},setCircle:function(t,e,i){return void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.world.staticTree.remove(this),this.isCircle=!0,this.radius=t,this.width=2*t,this.height=2*t,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.set(e,i),this.updateCenter(),this.world.staticTree.insert(this)):this.isCircle=!1,this},updateCenter:function(){this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},reset:function(t,e){var i=this.gameObject;void 0===t&&(t=i.x),void 0===e&&(e=i.y),this.world.staticTree.remove(this),i.getTopLeft(this.position),this.updateCenter(),this.world.staticTree.insert(this)},stop:function(){return this},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,e){return this.isCircle?n(this,t,e):o(this,t,e)},deltaAbsX:function(){return 0},deltaAbsY:function(){return 0},deltaX:function(){return 0},deltaY:function(){return 0},deltaZ:function(){return 0},destroy:function(){this.enable=!1,this.world.pendingDestroy.set(this)},drawDebug:function(t){var e=this.position;this.debugShowBody&&(t.lineStyle(1,this.debugBodyColor,1),t.strokeRect(e.x,e.y,this.width,this.height))},willDrawDebug:function(){return this.debugShowBody},setMass:function(t){return t<=0&&(t=.1),this.mass=t,this},x:{get:function(){return this.position.x},set:function(t){this.world.staticTree.remove(this),this.position.x=t,this.world.staticTree.insert(this)}},y:{get:function(){return this.position.y},set:function(t){this.world.staticTree.remove(this),this.position.y=t,this.world.staticTree.insert(this)}},left:{get:function(){return this.position.x}},right:{get:function(){return this.position.x+this.width}},top:{get:function(){return this.position.y}},bottom:{get:function(){return this.position.y+this.height}}});t.exports=h},function(t,e){t.exports={NEVER:0,LITE:1,PASSIVE:2,ACTIVE:4,FIXED:8}},function(t,e){t.exports={NONE:0,A:1,B:2,BOTH:3}},function(t,e,i){var n={};t.exports=n;var s=i(167);n._motionWakeThreshold=.18,n._motionSleepThreshold=.08,n._minBias=.9,n.update=function(t,e){for(var i=e*e*e,s=0;s0&&r.motion=r.sleepThreshold&&n.set(r,!0)):r.sleepCounter>0&&(r.sleepCounter-=1)}else n.set(r,!1)}},n.afterCollisions=function(t,e){for(var i=e*e*e,s=0;sn._motionWakeThreshold*i&&n.set(l,!1)}}}},n.set=function(t,e){var i=t.isSleeping;e?(t.isSleeping=!0,t.sleepCounter=t.sleepThreshold,t.positionImpulse.x=0,t.positionImpulse.y=0,t.positionPrev.x=t.position.x,t.positionPrev.y=t.position.y,t.anglePrev=t.angle,t.speed=0,t.angularSpeed=0,t.motion=0,i||s.trigger(t,"sleepStart")):(t.isSleeping=!1,t.sleepCounter=0,i&&s.trigger(t,"sleepEnd"))}},function(t,e,i){var n=i(15);t.exports=function(t,e,i,s,r,o,a){for(var h=n(i,s,r,o,null,a),l=0;l-1}return!1}},function(t,e,i){var n=i(44),s=i(74),r=i(153);t.exports=function(t,e,i,o,a){if(void 0===i&&(i=!1),void 0===o&&(o=!0),!s(t,e,a))return null;var h=a.data[e][t];return null===h?null:(a.data[e][t]=i?null:new n(a,-1,t,e,h.width,h.height),o&&h&&h.collides&&r(t,e,a),h)}},function(t,e,i){var n=i(22),s=i(156),r=i(348),o=i(349),a=i(354);t.exports=function(t,e,i,h,l,u){var c;switch(e){case n.ARRAY_2D:c=s(t,i,h,l,u);break;case n.CSV:c=r(t,i,h,l,u);break;case n.TILED_JSON:c=o(t,i,u);break;case n.WELTMEISTER:c=a(t,i,u);break;default:console.warn("Unrecognized tilemap data format: "+e),c=null}return c}},function(t,e,i){var n=i(22),s=i(156);t.exports=function(t,e,i,r,o){var a=e.trim().split("\n").map(function(t){return t.split(",")}),h=s(t,a,i,r,o);return h.format=n.CSV,h}},function(t,e,i){var n=i(22),s=i(76),r=i(904),o=i(906),a=i(907),h=i(909),l=i(910),u=i(911);t.exports=function(t,e,i){if("orthogonal"!==e.orientation)return console.warn("Only orthogonal map types are supported in this version of Phaser"),null;var c=new s({width:e.width,height:e.height,name:t,tileWidth:e.tilewidth,tileHeight:e.tileheight,orientation:e.orientation,format:n.TILED_JSON,version:e.version,properties:e.properties});c.layers=r(e,i),c.images=o(e);var d=a(e);return c.tilesets=d.tilesets,c.imageCollections=d.imageCollections,c.objects=h(e),c.tiles=l(c),u(c),c}},function(t,e){t.exports=function(t){var e=Boolean(2147483648&t),i=Boolean(1073741824&t),n=Boolean(536870912&t);t&=536870911;var s=0,r=!1;return e&&i&&n?(s=Math.PI/2,r=!0):e&&i&&!n?(s=Math.PI,r=!1):e&&!i&&n?(s=Math.PI/2,r=!1):!e||i||n?!e&&i&&n?(s=3*Math.PI/2,r=!1):e||!i||n?e||i||!n?e||i||n||(s=0,r=!1):(s=3*Math.PI/2,r=!0):(s=Math.PI,r=!0):(s=0,r=!0),{gid:t,flippedHorizontal:e,flippedVertical:i,flippedAntiDiagonal:n,rotation:s,flipped:r}}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r,o){(void 0===i||i<=0)&&(i=32),(void 0===n||n<=0)&&(n=32),void 0===s&&(s=0),void 0===r&&(r=0),this.name=t,this.firstgid=0|e,this.imageWidth=0|i,this.imageHeight=0|n,this.imageMargin=0|s,this.imageSpacing=0|r,this.properties=o||{},this.images=[],this.total=0},containsImageIndex:function(t){return t>=this.firstgid&&ta&&(a=e.layer[l].width),e.layer[l].height>h&&(h=e.layer[l].height);var u=new s({width:a,height:h,name:t,tileWidth:e.layer[0].tilesize,tileHeight:e.layer[0].tilesize,format:n.WELTMEISTER});return u.layers=r(e,i),u.tilesets=o(e),u}},function(t,e,i){var n=i(0),s=i(35),r=i(356),o=i(23),a=i(22),h=i(75),l=i(324),u=i(357),c=i(44),d=i(96),f=i(100),p=new n({initialize:function(t,e){this.scene=t,this.tileWidth=e.tileWidth,this.tileHeight=e.tileHeight,this.width=e.width,this.height=e.height,this.orientation=e.orientation,this.format=e.format,this.version=e.version,this.properties=e.properties,this.widthInPixels=e.widthInPixels,this.heightInPixels=e.heightInPixels,this.imageCollections=e.imageCollections,this.images=e.images,this.layers=e.layers,this.tilesets=e.tilesets,this.objects=e.objects,this.currentLayerIndex=0},addTilesetImage:function(t,e,i,n,s,r,o){if(void 0===t)return null;if(null==e&&(e=t),!this.scene.sys.textures.exists(e))return console.warn('Invalid image key given for tileset: "'+e+'"'),null;var h=this.scene.sys.textures.get(e),l=this.getTilesetIndex(t);if(null===l&&this.format===a.TILED_JSON)return console.warn('No data found in the JSON tilemap from Tiled matching the tileset name: "'+t+'"'),null;if(this.tilesets[l])return this.tilesets[l].setTileSize(i,n),this.tilesets[l].setSpacing(s,r),this.tilesets[l].setImage(h),this.tilesets[l];void 0===i&&(i=this.tileWidth),void 0===n&&(n=this.tileHeight),void 0===s&&(s=0),void 0===r&&(r=0),void 0===o&&(o=0);var u=new f(t,o,i,n,s,r);return u.setImage(h),this.tilesets.push(u),u},convertLayerToStatic:function(t){if(null===(t=this.getLayer(t)))return null;var e=t.tilemapLayer;if(!(e&&e instanceof r))return null;var i=new u(e.scene,e.tilemap,e.layerIndex,e.tileset,e.x,e.y);return this.scene.sys.displayList.add(i),e.destroy(),i},copy:function(t,e,i,n,s,r,o,a){return a=this.getLayer(a),this._isStaticCall(a,"copy")?this:(null!==a&&d.Copy(t,e,i,n,s,r,o,a),this)},createBlankDynamicLayer:function(t,e,i,n,s,o,a,l){if(void 0===a&&(a=e.tileWidth),void 0===l&&(l=e.tileHeight),void 0===s&&(s=this.width),void 0===o&&(o=this.height),void 0===i&&(i=0),void 0===n&&(n=0),null!==this.getLayerIndex(t))return console.warn("Cannot create blank layer: layer with matching name already exists "+t),null;for(var u,d=new h({name:t,tileWidth:a,tileHeight:l,width:s,height:o}),f=0;f0){var t=this.delay+this.delay*this.repeat;return(this.elapsed+this.delay*(this.repeat-this.repeatCount))/t}return this.getProgress()},getRepeatCount:function(){return this.repeatCount},getElapsed:function(){return this.elapsed},getElapsedSeconds:function(){return.001*this.elapsed},remove:function(t){void 0===t&&(t=!1),this.elapsed=this.delay,this.hasDispatched=!t,this.repeatCount=0},destroy:function(){this.callback=void 0,this.callbackScope=void 0,this.args=[]}});t.exports=r},function(t,e,i){var n=i(926);t.exports=function(t){var e,i=[];if(t.hasOwnProperty("props"))for(e in t.props)"_"!==e.substr(0,1)&&i.push({key:e,value:t.props[e]});else for(e in t)-1===n.indexOf(e)&&"_"!==e.substr(0,1)&&i.push({key:e,value:t[e]});return i}},function(t,e,i){var n=i(4);t.exports=function(t){var e=n(t,"tweens",null);return null===e?[]:("function"==typeof e&&(e=e.call()),Array.isArray(e)||(e=[e]),e)}},function(t,e,i){var n=i(160),s=i(10),r=i(73),o=i(71),a=i(101),h=i(4),l=i(159),u=i(161),c=i(162);t.exports=function(t,e,i){void 0===i&&(i=n);var d=h(e,"from",0),f=h(e,"to",1),p=[{value:d}],g=a(e,"delay",i.delay),v=a(e,"duration",i.duration),y=h(e,"easeParams",i.easeParams),m=o(h(e,"ease",i.ease),y),x=a(e,"hold",i.hold),b=a(e,"repeat",i.repeat),w=a(e,"repeatDelay",i.repeatDelay),T=r(e,"yoyo",i.yoyo),S=[],A=l("value",f),C=c(p[0],"value",A.getEnd,A.getStart,m,g,v,T,x,b,w,!1,!1);C.start=d,C.current=d,C.to=f,S.push(C);var M=new u(t,S,p);M.offset=s(e,"offset",null),M.completeDelay=s(e,"completeDelay",0),M.loop=Math.round(s(e,"loop",0)),M.loopDelay=Math.round(s(e,"loopDelay",0)),M.paused=r(e,"paused",!1),M.useFrames=r(e,"useFrames",!1);for(var _=h(e,"callbackScope",M),E=[M,null],P=u.TYPES,L=0;L0?Math.floor(v/p.length):h(e,"duration",g.duration),g.delay=h(e,"delay",g.delay),g.easeParams=c(e,"easeParams",g.easeParams),g.ease=a(c(e,"ease",g.ease),g.easeParams),g.hold=h(e,"hold",g.hold),g.repeat=h(e,"repeat",g.repeat),g.repeatDelay=h(e,"repeatDelay",g.repeatDelay),g.yoyo=o(e,"yoyo",g.yoyo),g.flipX=o(e,"flipX",g.flipX),g.flipY=o(e,"flipY",g.flipY);for(var y=0;y0?this.totalDuration=this.duration+this.completeDelay+(this.duration+this.loopDelay)*this.loopCounter:this.totalDuration=this.duration+this.completeDelay},init:function(){return this.calcDuration(),this.progress=0,this.totalProgress=0,!this.paused||(this.state=o.PAUSED,!1)},resetTweens:function(t){for(var e=0;e0){this.elapsed=0,this.progress=0,this.loopCounter--;var t=this.callbacks.onLoop;t&&t.func.apply(t.scope,t.params),this.emit("loop",this,this.loopCounter),this.resetTweens(!0),this.loopDelay>0?(this.countdown=this.loopDelay,this.state=o.LOOP_DELAY):this.state=o.ACTIVE}else if(this.completeDelay>0)this.countdown=this.completeDelay,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&e.func.apply(e.scope,e.params),this.emit("complete",this),this.state=o.PENDING_REMOVE}},update:function(t,e){if(this.state!==o.PAUSED){var i=e;switch(this.useFrames&&(e=1*this.manager.timeScale),e*=this.timeScale,this.elapsed+=e,this.progress=Math.min(this.elapsed/this.duration,1),this.totalElapsed+=e,this.totalProgress=Math.min(this.totalElapsed/this.totalDuration,1),this.state){case o.ACTIVE:for(var n=this.totalData,s=0;s=t.length)){for(var i=t.length-1,n=t[e],s=e;s=this.nextTick&&this.currentAnim.setFrame(this))},updateFrame:function(t){var e=this.parent;if(this.currentFrame=t,e.texture=t.frame.texture,e.frame=t.frame,this.isPlaying){t.setAlpha&&(e.alpha=t.alpha);var i=this.currentAnim;i.onUpdate&&i.onUpdate.apply(i.callbackScope,this._updateParams),t.onUpdate&&t.onUpdate(e,t)}},yoyo:function(t){return void 0===t?this._yoyo:(this._yoyo=t,this)},destroy:function(){}});t.exports=n},function(t,e,i){var n=i(367),s=i(368),r=i(0),o=i(19),a=i(369),h=i(370),l=i(63),u=i(121),c=new r({initialize:function(t){this.game=t,this.type=o.CANVAS,this.drawCount=0,this.width=t.config.width,this.height=t.config.height,this.config={clearBeforeRender:t.config.clearBeforeRender,pixelArt:t.config.pixelArt,backgroundColor:t.config.backgroundColor,resolution:t.config.resolution,autoResize:t.config.autoResize,roundPixels:t.config.roundPixels},this.scaleMode=t.config.pixelArt?l.NEAREST:l.LINEAR,this.gameCanvas=t.canvas,this.gameContext=this.gameCanvas.getContext("2d"),this.currentContext=this.gameContext,this.drawImage=a(this.config.roundPixels),this.blitImage=n(this.config.roundPixels),this.blendModes=h(),this.currentAlpha=1,this.currentBlendMode=0,this.currentScaleMode=0,this.snapshotCallback=null,this.snapshotType=null,this.snapshotEncoder=null,this.init()},init:function(){this.resize(this.width,this.height)},resize:function(t,e){var i=this.config.resolution;this.width=t*i,this.height=e*i,this.gameCanvas.width=this.width,this.gameCanvas.height=this.height,this.config.autoResize&&(this.gameCanvas.style.width=this.width/i+"px",this.gameCanvas.style.height=this.height/i+"px"),this.scaleMode===l.NEAREST&&u.disable(this.gameContext)},onContextLost:function(){},onContextRestored:function(){},resetTransform:function(){this.currentContext.setTransform(1,0,0,1,0,0)},setBlendMode:function(t){return this.currentBlendMode!==t&&(this.currentContext.globalCompositeOperation=t,this.currentBlendMode=t),this.currentBlendMode},setAlpha:function(t){return this.currentAlpha!==t&&(this.currentContext.globalAlpha=t,this.currentAlpha=t),this.currentAlpha},preRender:function(){var t=this.gameContext,e=this.config,i=this.width,n=this.height;e.clearBeforeRender&&t.clearRect(0,0,i,n),e.transparent||(t.fillStyle=e.backgroundColor.rgba,t.fillRect(0,0,i,n)),this.drawCount=0},render:function(t,e,i,n){var s=t.sys.context,r=0!==n.x||0!==n.y||n.width!==s.canvas.width||n.height!==s.canvas.height,o=e.list,a=this.config.resolution;this.currentContext=s,n.transparent||(s.fillStyle=n.backgroundColor.rgba,s.fillRect(n.x,n.y,n.width,n.height)),1!==this.currentAlpha&&(s.globalAlpha=1,this.currentAlpha=1),0!==this.currentBlendMode&&(s.globalCompositeOperation="source-over",this.currentBlendMode=0),this.currentScaleMode=0,this.drawCount+=o.length,r&&(s.save(),s.beginPath(),s.rect(n.x*a,n.y*a,n.width*a,n.height*a),s.clip());var h=n.matrix.matrix;s.setTransform(h[0],h[1],h[2],h[3],h[4],h[5]);for(var l=0;l0||n._flashAlpha>0)&&(s.globalCompositeOperation="source-over",s.fillStyle="rgb("+255*n._fadeRed+","+255*n._fadeGreen+","+255*n._fadeBlue+")",s.globalAlpha=n._fadeAlpha,s.fillRect(n.x,n.y,n.width,n.height),s.fillStyle="rgb("+255*n._flashRed+","+255*n._flashGreen+","+255*n._flashBlue+")",s.globalAlpha=n._flashAlpha,s.fillRect(n.x,n.y,n.width,n.height),s.globalAlpha=1),r&&s.restore()},postRender:function(){var t=this.gameContext;t.globalAlpha=1,t.globalCompositeOperation="source-over",this.currentAlpha=1,this.currentBlendMode=0,this.snapshotCallback&&(this.snapshotCallback(s(this.gameCanvas,this.snapshotType,this.snapshotEncoder)),this.snapshotCallback=null)},snapshot:function(t,e,i){this.snapshotCallback=t,this.snapshotType=e,this.snapshotEncoder=i},destroy:function(){this.gameCanvas=null,this.gameContext=null,this.game=null}});t.exports=c},function(t,e){var i=!1,n=function(t,e,n){var s=this.currentContext,r=n.canvasData;i&&(t|=0,e|=0),s.drawImage(n.source.image,r.sx,r.sy,r.sWidth,r.sHeight,t,e,r.dWidth,r.dHeight)};t.exports=function(t){return i=t,n}},function(t,e){t.exports=function(t,e,i){void 0===e&&(e="image/png"),void 0===i&&(i=.92);var n=t.toDataURL(e,i),s=new Image;return s.src=n,s}},function(t,e){var i=!1,n=function(t,e){var n=this.currentContext,s=t.frame,r=s.canvasData;this.currentBlendMode!==t.blendMode&&(this.currentBlendMode=t.blendMode,n.globalCompositeOperation=this.blendModes[t.blendMode]),this.currentAlpha!==t.alpha&&(this.currentAlpha=t.alpha,n.globalAlpha=t.alpha),this.currentScaleMode!==t.scaleMode&&(this.currentScaleMode=t.scaleMode);var o=s.x,a=s.y,h=1,l=1;t.flipX?(h=-1,o-=r.dWidth-t.displayOriginX):o-=t.displayOriginX,t.flipY?(l=-1,a-=r.dHeight-t.displayOriginY):a-=t.displayOriginY;var u=t.x-e.scrollX*t.scrollFactorX,c=t.y-e.scrollY*t.scrollFactorY;i&&(u|=0,c|=0,o|=0,a|=0),n.save(),n.translate(u,c),n.rotate(t.rotation),n.scale(t.scaleX,t.scaleY),n.scale(h,l),n.drawImage(s.source.image,r.sx,r.sy,r.sWidth,r.sHeight,o,a,r.dWidth,r.dHeight),n.restore()};t.exports=function(t){return i=t,n}},function(t,e,i){var n=i(45),s=i(237);t.exports=function(){var t=[],e=s.supportNewBlendModes;return t[n.NORMAL]="source-over",t[n.ADD]="lighter",t[n.MULTIPLY]=e?"multiply":"source-over",t[n.SCREEN]=e?"screen":"source-over",t[n.OVERLAY]=e?"overlay":"source-over",t[n.DARKEN]=e?"darken":"source-over",t[n.LIGHTEN]=e?"lighten":"source-over",t[n.COLOR_DODGE]=e?"color-dodge":"source-over",t[n.COLOR_BURN]=e?"color-burn":"source-over",t[n.HARD_LIGHT]=e?"hard-light":"source-over",t[n.SOFT_LIGHT]=e?"soft-light":"source-over",t[n.DIFFERENCE]=e?"difference":"source-over",t[n.EXCLUSION]=e?"exclusion":"source-over",t[n.HUE]=e?"hue":"source-over",t[n.SATURATION]=e?"saturation":"source-over",t[n.COLOR]=e?"color":"source-over",t[n.LUMINOSITY]=e?"luminosity":"source-over",t}},function(t,e,i){var n=i(0),s=i(19),r=i(127),o=i(41),a=i(372),h=i(373),l=i(374),u=i(165),c=i(166),d=new n({initialize:function(t){var e=this,i={alpha:t.config.transparent,depth:!1,antialias:t.config.antialias,premultipliedAlpha:t.config.transparent,stencil:!0,preserveDrawingBuffer:t.config.preserveDrawingBuffer,failIfMajorPerformanceCaveat:!1,powerPreference:t.config.powerPreference};this.config={clearBeforeRender:t.config.clearBeforeRender,pixelArt:t.config.pixelArt,backgroundColor:t.config.backgroundColor,contextCreation:i,resolution:t.config.resolution,autoResize:t.config.autoResize,roundPixels:t.config.roundPixels},this.game=t,this.type=s.WEBGL,this.width=t.config.width,this.height=t.config.height,this.canvas=t.canvas,this.lostContextCallbacks=[],this.restoredContextCallbacks=[],this.blendModes=[],this.nativeTextures=[],this.contextLost=!1,this.pipelines=null,this.snapshotState={callback:null,type:null,encoder:null},this.currentActiveTextureUnit=0,this.currentTextures=new Array(16),this.currentFramebuffer=null,this.currentPipeline=null,this.currentProgram=null,this.currentVertexBuffer=null,this.currentIndexBuffer=null,this.currentBlendMode=1/0,this.currentScissorEnabled=!1,this.currentScissor=new Uint32Array([0,0,this.width,this.height]),this.currentScissorIdx=0,this.scissorStack=new Uint32Array(4e3),this.canvas.addEventListener("webglcontextlost",function(t){e.contextLost=!0,t.preventDefault();for(var i=0;i=0&&n>=0;if(r[0]===t&&r[1]===e&&r[2]===i&&r[3]===n||this.flush(),r[0]=t,r[1]=e,r[2]=i,r[3]=n,this.currentScissorEnabled=o,!o)return s.enable(s.SCISSOR_TEST),s.scissor(t,s.drawingBufferHeight-e-n,i,n),this;s.disable(s.SCISSOR_TEST)},pushScissor:function(t,e,i,n){var s=this.scissorStack,r=this.currentScissorIdx,o=this.currentScissor;return s[r+0]=o[0],s[r+1]=o[1],s[r+2]=o[2],s[r+3]=o[3],this.currentScissorIdx+=4,this.setScissor(t,e,i,n),this},popScissor:function(){var t=this.scissorStack,e=this.currentScissorIdx-4,i=t[e+0],n=t[e+1],s=t[e+2],r=t[e+3];return this.currentScissorIdx=e,this.setScissor(i,n,s,r),this},setPipeline:function(t){return this.currentPipeline===t&&this.currentPipeline.vertexBuffer===this.currentVertexBuffer&&this.currentPipeline.program===this.currentProgram||(this.flush(),this.currentPipeline=t,this.currentPipeline.bind()),this.currentPipeline.onBind(),this.currentPipeline},setBlendMode:function(t){var e=this.gl,i=this.blendModes[t];return t!==s.BlendModes.SKIP_CHECK&&this.currentBlendMode!==t&&(this.flush(),e.enable(e.BLEND),e.blendEquation(i.equation),i.func.length>2?e.blendFuncSeparate(i.func[0],i.func[1],i.func[2],i.func[3]):e.blendFunc(i.func[0],i.func[1]),this.currentBlendMode=t),this},addBlendMode:function(t,e){return this.blendModes.push({func:t,equation:e})-1},updateBlendMode:function(t,e,i){return this.blendModes[t]&&(this.blendModes[t].func=e,i&&(this.blendModes[t].equation=i)),this},removeBlendMode:function(t){return t>16&&this.blendModes[t]&&this.blendModes.splice(t,1),this},setTexture2D:function(t,e){var i=this.gl;return t!==this.currentTextures[e]&&(this.flush(),this.currentActiveTextureUnit!==e&&(i.activeTexture(i.TEXTURE0+e),this.currentActiveTextureUnit=e),i.bindTexture(i.TEXTURE_2D,t),this.currentTextures[e]=t),this},setFramebuffer:function(t){var e=this.gl;return t!==this.currentFramebuffer&&(this.flush(),e.bindFramebuffer(e.FRAMEBUFFER,t),this.currentFramebuffer=t),this},setProgram:function(t){var e=this.gl;return t!==this.currentProgram&&(this.flush(),e.useProgram(t),this.currentProgram=t),this},setVertexBuffer:function(t){var e=this.gl;return t!==this.currentVertexBuffer&&(this.flush(),e.bindBuffer(e.ARRAY_BUFFER,t),this.currentVertexBuffer=t),this},setIndexBuffer:function(t){var e=this.gl;return t!==this.currentIndexBuffer&&(this.flush(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.currentIndexBuffer=t),this},createTextureFromSource:function(t,e,i,n){var o=this.gl,a=o.NEAREST,h=o.CLAMP_TO_EDGE;return e=t?t.width:e,i=t?t.height:i,r(e,i)&&(h=o.REPEAT),n===s.ScaleModes.LINEAR?a=o.LINEAR:(n===s.ScaleModes.NEAREST||this.config.pixelArt)&&(a=o.NEAREST),t||"number"!=typeof e||"number"!=typeof i?this.createTexture2D(0,a,a,h,h,o.RGBA,t):this.createTexture2D(0,a,a,h,h,o.RGBA,null,e,i)},createTexture2D:function(t,e,i,n,s,r,o,a,h,l){var u=this.gl,c=u.createTexture();return l=null==l||l,this.setTexture2D(c,0),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,e),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,i),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,s),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,n),u.pixelStorei(u.UNPACK_PREMULTIPLY_ALPHA_WEBGL,l),null==o?u.texImage2D(u.TEXTURE_2D,t,r,a,h,0,r,u.UNSIGNED_BYTE,null):(u.texImage2D(u.TEXTURE_2D,t,r,r,u.UNSIGNED_BYTE,o),a=o.width,h=o.height),this.setTexture2D(null,0),c.isAlphaPremultiplied=l,c.isRenderTexture=!1,c.width=a,c.height=h,this.nativeTextures.push(c),c},createFramebuffer:function(t,e,i,n){var s,r=this.gl,o=r.createFramebuffer();if(this.setFramebuffer(o),n){var a=r.createRenderbuffer();r.bindRenderbuffer(r.RENDERBUFFER,a),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t,e),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,a)}if(i.isRenderTexture=!0,i.isAlphaPremultiplied=!1,r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,i,0),(s=r.checkFramebufferStatus(r.FRAMEBUFFER))!==r.FRAMEBUFFER_COMPLETE){throw new Error("Framebuffer incomplete. Framebuffer status: "+{36054:"Incomplete Attachment",36055:"Missing Attachment",36057:"Incomplete Dimensions",36061:"Framebuffer Unsupported"}[s])}return o.renderTexture=i,this.setFramebuffer(null),o},createProgram:function(t,e){var i=this.gl,n=i.createProgram(),s=i.createShader(i.VERTEX_SHADER),r=i.createShader(i.FRAGMENT_SHADER);if(i.shaderSource(s,t),i.shaderSource(r,e),i.compileShader(s),i.compileShader(r),!i.getShaderParameter(s,i.COMPILE_STATUS))throw new Error("Failed to compile Vertex Shader:\n"+i.getShaderInfoLog(s));if(!i.getShaderParameter(r,i.COMPILE_STATUS))throw new Error("Failed to compile Fragment Shader:\n"+i.getShaderInfoLog(r));if(i.attachShader(n,s),i.attachShader(n,r),i.linkProgram(n),!i.getProgramParameter(n,i.LINK_STATUS))throw new Error("Failed to link program:\n"+i.getProgramInfoLog(n));return n},createVertexBuffer:function(t,e){var i=this.gl,n=i.createBuffer();return this.setVertexBuffer(n),i.bufferData(i.ARRAY_BUFFER,t,e),this.setVertexBuffer(null),n},createIndexBuffer:function(t,e){var i=this.gl,n=i.createBuffer();return this.setIndexBuffer(n),i.bufferData(i.ELEMENT_ARRAY_BUFFER,t,e),this.setIndexBuffer(null),n},deleteTexture:function(t){return this.gl.deleteTexture(t),this},deleteFramebuffer:function(t){return this.gl.deleteFramebuffer(t),this},deleteProgram:function(t){return this.gl.deleteProgram(t),this},deleteBuffer:function(t){return this.gl.deleteBuffer(t),this},preRenderCamera:function(t){var e=this.config.resolution;if(this.pushScissor(t.x*e,t.y*e,t.width*e,t.height*e),t.backgroundColor.alphaGL>0){var i=t.backgroundColor,n=this.pipelines.FlatTintPipeline;n.batchFillRect(0,0,1,1,0,t.x,t.y,t.width,t.height,o.getTintFromFloats(i.redGL,i.greenGL,i.blueGL,1),i.alphaGL,1,0,0,1,0,0,[1,0,0,1,0,0]),n.flush()}},postRenderCamera:function(t){if(t._fadeAlpha>0||t._flashAlpha>0){var e=this.pipelines.FlatTintPipeline;e.batchFillRect(0,0,1,1,0,t.x,t.y,t.width,t.height,o.getTintFromFloats(t._fadeRed,t._fadeGreen,t._fadeBlue,1),t._fadeAlpha,1,0,0,1,0,0,[1,0,0,1,0,0]),e.batchFillRect(0,0,1,1,0,t.x,t.y,t.width,t.height,o.getTintFromFloats(t._flashRed,t._flashGreen,t._flashBlue,1),t._flashAlpha,1,0,0,1,0,0,[1,0,0,1,0,0]),e.flush()}this.popScissor()},preRender:function(){if(!this.contextLost){var t=this.gl,e=this.config.backgroundColor,i=this.pipelines;for(var n in t.clearColor(e.redGL,e.greenGL,e.blueGL,e.alphaGL),this.config.clearBeforeRender&&t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT|t.STENCIL_BUFFER_BIT),i)i[n].onPreRender()}},render:function(t,e,i,n){if(!this.contextLost){var r=e.list,o=r.length,a=this.pipelines;for(var h in a)a[h].onRender(t,n);this.preRenderCamera(n);for(var l=0;lthis.vertexCapacity&&this.flush();var x=this.vertexViewF32,b=this.vertexViewU32,w=this.vertexCount*this.vertexComponentCount,T=r+a,S=o+h,A=m[0],C=m[1],M=m[2],_=m[3],E=d*A+f*M,P=d*C+f*_,L=p*A+g*M,k=p*C+g*_,F=v*A+y*M+m[4],O=v*C+y*_+m[5],R=r*E+o*L+F,B=r*P+o*k+O,I=r*E+S*L+F,D=r*P+S*k+O,Y=T*E+S*L+F,z=T*P+S*k+O,X=T*E+o*L+F,N=T*P+o*k+O,V=l.getTintAppendFloatAlphaAndSwap(u,c);x[w+0]=R,x[w+1]=B,b[w+2]=V,x[w+3]=I,x[w+4]=D,b[w+5]=V,x[w+6]=Y,x[w+7]=z,b[w+8]=V,x[w+9]=R,x[w+10]=B,b[w+11]=V,x[w+12]=Y,x[w+13]=z,b[w+14]=V,x[w+15]=X,x[w+16]=N,b[w+17]=V,this.vertexCount+=6},batchFillTriangle:function(t,e,i,n,s,r,o,a,h,u,c,d,f,p,g,v,y,m,x,b){this.renderer.setPipeline(this),this.vertexCount+3>this.vertexCapacity&&this.flush();var w=this.vertexViewF32,T=this.vertexViewU32,S=this.vertexCount*this.vertexComponentCount,A=b[0],C=b[1],M=b[2],_=b[3],E=p*A+g*M,P=p*C+g*_,L=v*A+y*M,k=v*C+y*_,F=m*A+x*M+b[4],O=m*C+x*_+b[5],R=r*E+o*L+F,B=r*P+o*k+O,I=a*E+h*L+F,D=a*P+h*k+O,Y=u*E+c*L+F,z=u*P+c*k+O,X=l.getTintAppendFloatAlphaAndSwap(d,f);w[S+0]=R,w[S+1]=B,T[S+2]=X,w[S+3]=I,w[S+4]=D,T[S+5]=X,w[S+6]=Y,w[S+7]=z,T[S+8]=X,this.vertexCount+=3},batchStrokeTriangle:function(t,e,i,n,s,r,o,a,h,l,u,c,d,f,p,g,v,y,m,x,b){var w=this.tempTriangle;w[0].x=r,w[0].y=o,w[0].width=c,w[0].rgb=d,w[0].alpha=f,w[1].x=a,w[1].y=h,w[1].width=c,w[1].rgb=d,w[1].alpha=f,w[2].x=l,w[2].y=u,w[2].width=c,w[2].rgb=d,w[2].alpha=f,w[3].x=r,w[3].y=o,w[3].width=c,w[3].rgb=d,w[3].alpha=f,this.batchStrokePath(t,e,i,n,s,w,c,d,f,p,g,v,y,m,x,!1,b)},batchFillPath:function(t,e,i,n,s,o,a,h,u,c,d,f,p,g,v){this.renderer.setPipeline(this);for(var y,m,x,b,w,T,S,A,C,M,_,E,P,L,k,F,O,R=o.length,B=this.polygonCache,I=this.vertexViewF32,D=this.vertexViewU32,Y=0,z=v[0],X=v[1],N=v[2],V=v[3],W=u*z+c*N,G=u*X+c*V,U=d*z+f*N,j=d*X+f*V,H=p*z+g*N+v[4],q=p*X+g*V+v[5],K=l.getTintAppendFloatAlphaAndSwap(a,h),J=0;Jthis.vertexCapacity&&this.flush(),Y=this.vertexCount*this.vertexComponentCount,E=(T=B[x+0])*W+(S=B[x+1])*U+H,P=T*G+S*j+q,L=(A=B[b+0])*W+(C=B[b+1])*U+H,k=A*G+C*j+q,F=(M=B[w+0])*W+(_=B[w+1])*U+H,O=M*G+_*j+q,I[Y+0]=E,I[Y+1]=P,D[Y+2]=K,I[Y+3]=L,I[Y+4]=k,D[Y+5]=K,I[Y+6]=F,I[Y+7]=O,D[Y+8]=K,this.vertexCount+=3;B.length=0},batchStrokePath:function(t,e,i,n,s,r,o,a,h,u,c,d,f,p,g,v,y){var m,x;this.renderer.setPipeline(this);for(var b,w,T,S,A=r.length,C=this.polygonCache,M=this.vertexViewF32,_=this.vertexViewU32,E=l.getTintAppendFloatAlphaAndSwap,P=0;P+1this.vertexCapacity&&this.flush(),b=C[L-1]||C[k-1],w=C[L],M[(T=this.vertexCount*this.vertexComponentCount)+0]=b[6],M[T+1]=b[7],_[T+2]=E(b[8],h),M[T+3]=b[0],M[T+4]=b[1],_[T+5]=E(b[2],h),M[T+6]=w[9],M[T+7]=w[10],_[T+8]=E(w[11],h),M[T+9]=b[0],M[T+10]=b[1],_[T+11]=E(b[2],h),M[T+12]=b[6],M[T+13]=b[7],_[T+14]=E(b[8],h),M[T+15]=w[3],M[T+16]=w[4],_[T+17]=E(w[5],h),this.vertexCount+=6;C.length=0},batchLine:function(t,e,i,n,s,r,o,a,h,u,c,d,f,p,g,v,y,m,x,b,w){this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var T=w[0],S=w[1],A=w[2],C=w[3],M=g*T+v*A,_=g*S+v*C,E=y*T+m*A,P=y*S+m*C,L=x*T+b*A+w[4],k=x*S+b*C+w[5],F=this.vertexViewF32,O=this.vertexViewU32,R=a-r,B=h-o,I=Math.sqrt(R*R+B*B),D=u*(h-o)/I,Y=u*(r-a)/I,z=c*(h-o)/I,X=c*(r-a)/I,N=a-z,V=h-X,W=r-D,G=o-Y,U=a+z,j=h+X,H=r+D,q=o+Y,K=N*M+V*E+L,J=N*_+V*P+k,Z=W*M+G*E+L,Q=W*_+G*P+k,$=U*M+j*E+L,tt=U*_+j*P+k,et=H*M+q*E+L,it=H*_+q*P+k,nt=l.getTintAppendFloatAlphaAndSwap,st=nt(d,p),rt=nt(f,p),ot=this.vertexCount*this.vertexComponentCount;return F[ot+0]=K,F[ot+1]=J,O[ot+2]=rt,F[ot+3]=Z,F[ot+4]=Q,O[ot+5]=st,F[ot+6]=$,F[ot+7]=tt,O[ot+8]=rt,F[ot+9]=Z,F[ot+10]=Q,O[ot+11]=st,F[ot+12]=et,F[ot+13]=it,O[ot+14]=st,F[ot+15]=$,F[ot+16]=tt,O[ot+17]=rt,this.vertexCount+=6,[K,J,f,Z,Q,d,$,tt,f,et,it,d]},batchGraphics:function(t,e){if(!(t.commandBuffer.length<=0)){this.renderer.setPipeline(this);var i,n,r=e.scrollX*t.scrollFactorX,o=e.scrollY*t.scrollFactorY,a=t.x-r,h=t.y-o,l=t.scaleX,u=t.scaleY,y=-t.rotation,m=t.commandBuffer,x=1,b=1,w=0,T=0,S=1,A=e.matrix.matrix,C=null,M=0,_=0,E=0,P=0,L=0,k=0,F=0,O=0,R=0,B=0,I=null,D=Math.sin,Y=Math.cos,z=2*Math.PI,X=D(y),N=Y(y),V=N*l,W=-X*l,G=X*u,U=N*u,j=a,H=h,q=A[0],K=A[1],J=A[2],Z=A[3],Q=V*q+W*J,$=V*K+W*Z,tt=G*q+U*J,et=G*K+U*Z,it=j*q+H*J+A[4],nt=j*K+H*Z+A[5];v.length=0;for(var st=0,rt=m.length;st0&&(R=R%z-z):R>z?R=z:R<0&&(R=z+R%z);M<1;)_=L+Y(P=R*M+O)*F,E=k+D(P)*F,C.points.push(new c(_,E,S,w,x)),M+=.01;_=L+Y(P=R+O)*F,E=k+D(P)*F,C.points.push(new c(_,E,S,w,x)),st+=6;break;case s.LINE_STYLE:S=m[st+1],w=m[st+2],x=m[st+3],st+=3;break;case s.FILL_STYLE:T=m[st+1],b=m[st+2],st+=2;break;case s.BEGIN_PATH:v.length=0,C=null;break;case s.CLOSE_PATH:C&&C.points.length&&C.points.push(C.points[0]);break;case s.FILL_PATH:for(i=0,n=v.length;i>>0;if("function"!=typeof t)throw new TypeError;for(var n=arguments.length>=2?arguments[1]:void 0,s=0;s>>0,i=(e*=i)>>>0,i+=4294967296*(e-=i);return this.n=i,2.3283064365386963e-10*(i>>>0)},init:function(t){"string"==typeof t?this.state(t):this.sow(t)},sow:function(t){if(this.n=4022871197,this.s0=this.hash(" "),this.s1=this.hash(" "),this.s2=this.hash(" "),this.c=1,t)for(var e=0;e=0&&(this._blendMode=t)}},setBlendMode:function(t){return this.blendMode=t,this}};t.exports=s},function(t,e){t.exports={width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.width},set:function(t){this.scaleX=t/this.width}},displayHeight:{get:function(){return this.scaleY*this.height},set:function(t){this.scaleY=t/this.height}}}},function(t,e){var i={_depth:0,depth:{get:function(){return this._depth},set:function(t){this.scene.sys.queueDepthSort(),this._depth=t}},setDepth:function(t){return void 0===t&&(t=0),this.depth=t,this}};t.exports=i},function(t,e){t.exports={flipX:!1,flipY:!1,toggleFlipX:function(){return this.flipX=!this.flipX,this},toggleFlipY:function(){return this.flipY=!this.flipY,this},setFlipX:function(t){return this.flipX=t,this},setFlipY:function(t){return this.flipY=t,this},setFlip:function(t,e){return this.flipX=t,this.flipY=e,this},resetFlip:function(){return this.flipX=!1,this.flipY=!1,this}}},function(t,e,i){var n=i(8),s=i(188),r=i(6),o={getCenter:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth/2,t.y=this.y-this.displayHeight*this.originY+this.displayHeight/2,t},getTopLeft:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY,0!==this.rotation&&s(t,this.x,this.y,this.rotation),t},getTopRight:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY,0!==this.rotation&&s(t,this.x,this.y,this.rotation),t},getBottomLeft:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,0!==this.rotation&&s(t,this.x,this.y,this.rotation),t},getBottomRight:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,0!==this.rotation&&s(t,this.x,this.y,this.rotation),t},getBounds:function(t){void 0===t&&(t=new n),this.getTopLeft(t);var e=t.x,i=t.y;this.getTopRight(t);var s=t.x,r=t.y;this.getBottomLeft(t);var o=t.x,a=t.y;this.getBottomRight(t);var h=t.x,l=t.y;return t.x=Math.min(e,s,o,h),t.y=Math.min(i,r,a,l),t.width=Math.max(e,s,o,h)-t.x,t.height=Math.max(i,r,a,l)-t.y,t}};t.exports=o},function(t,e){var i={matrixStack:null,currentMatrix:null,currentMatrixIndex:0,initMatrixStack:function(){return this.matrixStack=new Float32Array(6e3),this.currentMatrix=new Float32Array([1,0,0,1,0,0]),this.currentMatrixIndex=0,this},save:function(){if(this.currentMatrixIndex>=this.matrixStack.length)return this;var t=this.matrixStack,e=this.currentMatrix,i=this.currentMatrixIndex;return this.currentMatrixIndex+=6,t[i+0]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=e[3],t[i+4]=e[4],t[i+5]=e[5],this},restore:function(){if(this.currentMatrixIndex<=0)return this;this.currentMatrixIndex-=6;var t=this.matrixStack,e=this.currentMatrix,i=this.currentMatrixIndex;return e[0]=t[i+0],e[1]=t[i+1],e[2]=t[i+2],e[3]=t[i+3],e[4]=t[i+4],e[5]=t[i+5],this},loadIdentity:function(){return this.setTransform(1,0,0,1,0,0),this},transform:function(t,e,i,n,s,r){var o=this.currentMatrix,a=o[0],h=o[1],l=o[2],u=o[3],c=o[4],d=o[5];return o[0]=a*t+l*e,o[1]=h*t+u*e,o[2]=a*i+l*n,o[3]=h*i+u*n,o[4]=a*s+l*r+c,o[5]=h*s+u*r+d,this},setTransform:function(t,e,i,n,s,r){var o=this.currentMatrix;return o[0]=t,o[1]=e,o[2]=i,o[3]=n,o[4]=s,o[5]=r,this},translate:function(t,e){var i=this.currentMatrix,n=i[0],s=i[1],r=i[2],o=i[3],a=i[4],h=i[5];return i[4]=n*t+r*e+a,i[5]=s*t+o*e+h,this},scale:function(t,e){var i=this.currentMatrix,n=i[0],s=i[1],r=i[2],o=i[3];return i[0]=n*t,i[1]=s*t,i[2]=r*e,i[3]=o*e,this},rotate:function(t){var e=this.currentMatrix,i=e[0],n=e[1],s=e[2],r=e[3],o=Math.sin(t),a=Math.cos(t);return e[0]=i*a+s*o,e[1]=n*a+r*o,e[2]=i*-o+s*a,e[3]=n*-o+r*a,this}};t.exports=i},function(t,e){var i={_originComponent:!0,originX:.5,originY:.5,_displayOriginX:0,_displayOriginY:0,displayOriginX:{get:function(){return this._displayOriginX},set:function(t){this._displayOriginX=t,this.originX=t/this.width}},displayOriginY:{get:function(){return this._displayOriginY},set:function(t){this._displayOriginY=t,this.originY=t/this.height}},setOrigin:function(t,e){return void 0===t&&(t=.5),void 0===e&&(e=t),this.originX=t,this.originY=e,this.updateDisplayOrigin()},setOriginFromFrame:function(){return this.frame&&this.frame.customPivot?(this.originX=this.frame.pivotX,this.originY=this.frame.pivotY,this.updateDisplayOrigin()):this.setOrigin()},setDisplayOrigin:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.displayOriginX=t,this.displayOriginY=e,this},updateDisplayOrigin:function(){return this._displayOriginX=Math.round(this.originX*this.width),this._displayOriginY=Math.round(this.originY*this.height),this}};t.exports=i},function(t,e,i){var n=i(63),s={_scaleMode:n.DEFAULT,scaleMode:{get:function(){return this._scaleMode},set:function(t){t!==n.LINEAR&&t!==n.NEAREST||(this._scaleMode=t)}},setScaleMode:function(t){return this.scaleMode=t,this}};t.exports=s},function(t,e){var i={scrollFactorX:1,scrollFactorY:1,setScrollFactor:function(t,e){return void 0===e&&(e=t),this.scrollFactorX=t,this.scrollFactorY=e,this}};t.exports=i},function(t,e){var i={_sizeComponent:!0,width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.frame.realWidth},set:function(t){this.scaleX=t/this.frame.realWidth}},displayHeight:{get:function(){return this.scaleY*this.frame.realHeight},set:function(t){this.scaleY=t/this.frame.realHeight}},setSizeToFrame:function(t){return void 0===t&&(t=this.frame),this.width=t.realWidth,this.height=t.realHeight,this},setSize:function(t,e){return this.width=t,this.height=e,this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}};t.exports=i},function(t,e){var i={texture:null,frame:null,setTexture:function(t,e){return this.texture=this.scene.sys.textures.get(t),this.setFrame(e)},setFrame:function(t,e,i){return void 0===e&&(e=!0),void 0===i&&(i=!0),this.frame=this.texture.get(t),this.frame.cutWidth&&this.frame.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,this._sizeComponent&&e&&this.setSizeToFrame(),this._originComponent&&i&&(this.frame.customPivot?this.setOrigin(this.frame.pivotX,this.frame.pivotY):this.updateDisplayOrigin()),this}};t.exports=i},function(t,e){var i=function(t){return(t>>16)+(65280&t)+((255&t)<<16)},n={_tintTL:16777215,_tintTR:16777215,_tintBL:16777215,_tintBR:16777215,clearTint:function(){return this.setTint(16777215),this},setTint:function(t,e,n,s){return void 0===t&&(t=16777215),void 0===e&&(e=t,n=t,s=t),this._tintTL=i(t),this._tintTR=i(e),this._tintBL=i(n),this._tintBR=i(s),this},tintTopLeft:{get:function(){return this._tintTL},set:function(t){this._tintTL=i(t)}},tintTopRight:{get:function(){return this._tintTR},set:function(t){this._tintTR=i(t)}},tintBottomLeft:{get:function(){return this._tintBL},set:function(t){this._tintBL=i(t)}},tintBottomRight:{get:function(){return this._tintBR},set:function(t){this._tintBR=i(t)}},tint:{set:function(t){this.setTint(t,t,t,t)}}};t.exports=n},function(t,e){t.exports=function(t){var e={name:t.name,type:t.type,x:t.x,y:t.y,depth:t.depth,scale:{x:t.scaleX,y:t.scaleY},origin:{x:t.originX,y:t.originY},flipX:t.flipX,flipY:t.flipY,rotation:t.rotation,alpha:t.alpha,visible:t.visible,scaleMode:t.scaleMode,blendMode:t.blendMode,textureKey:"",frameKey:"",data:{}};return t.texture&&(e.textureKey=t.texture.key,e.frameKey=t.frame.name),e}},function(t,e,i){var n=i(16),s=i(163),r=i(164),o={_scaleX:1,_scaleY:1,_rotation:0,x:0,y:0,z:0,w:0,scaleX:{get:function(){return this._scaleX},set:function(t){this._scaleX=t,0===this._scaleX?this.renderFlags&=-5:this.renderFlags|=4}},scaleY:{get:function(){return this._scaleY},set:function(t){this._scaleY=t,0===this._scaleY?this.renderFlags&=-5:this.renderFlags|=4}},angle:{get:function(){return r(this._rotation*n.RAD_TO_DEG)},set:function(t){this.rotation=r(t)*n.DEG_TO_RAD}},rotation:{get:function(){return this._rotation},set:function(t){this._rotation=s(t)}},setPosition:function(t,e,i,n){return void 0===t&&(t=0),void 0===e&&(e=t),void 0===i&&(i=0),void 0===n&&(n=0),this.x=t,this.y=e,this.z=i,this.w=n,this},setRotation:function(t){return void 0===t&&(t=0),this.rotation=t,this},setAngle:function(t){return void 0===t&&(t=0),this.angle=t,this},setScale:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.scaleX=t,this.scaleY=e,this},setX:function(t){return void 0===t&&(t=0),this.x=t,this},setY:function(t){return void 0===t&&(t=0),this.y=t,this},setZ:function(t){return void 0===t&&(t=0),this.z=t,this},setW:function(t){return void 0===t&&(t=0),this.w=t,this}};t.exports=o},function(t,e){var i={_visible:!0,visible:{get:function(){return this._visible},set:function(t){t?(this._visible=!0,this.renderFlags|=1):(this._visible=!1,this.renderFlags&=-2)}},setVisible:function(t){return this.visible=t,this}};t.exports=i},function(t,e){t.exports=function(t,e){for(var i=0;i0?s(o,i):i<0&&r(o,Math.abs(i));for(var a=0;a1)if(0===s){var d=t.length-1;for(o=t[d].x,a=t[d].y,h=d-1;h>=0;h--)l=(c=t[h]).x,u=c.y,c.x=o,c.y=a,o=l,a=u;t[d].x=e,t[d].y=i}else{for(o=t[0].x,a=t[0].y,h=1;h0?(this._speedX-=this.dragX*t,this._speedX<0&&(this._speedX=0)):this._speedX<0&&(this._speedX+=this.dragX*t,this._speedX>0&&(this._speedX=0)),this._speedY>0?(this._speedY-=this.dragY*t,this._speedY<0&&(this._speedY=0)):this._speedY<0&&(this._speedY+=this.dragY*t,this._speedY>0&&(this._speedY=0)),this.up&&this.up.isDown?(this._speedY+=this.accelY,this._speedY>this.maxSpeedY&&(this._speedY=this.maxSpeedY)):this.down&&this.down.isDown&&(this._speedY-=this.accelY,this._speedY<-this.maxSpeedY&&(this._speedY=-this.maxSpeedY)),this.left&&this.left.isDown?(this._speedX+=this.accelX,this._speedX>this.maxSpeedX&&(this._speedX=this.maxSpeedX)):this.right&&this.right.isDown&&(this._speedX-=this.accelX,this._speedX<-this.maxSpeedX&&(this._speedX=-this.maxSpeedX)),this.zoomIn&&this.zoomIn.isDown?this._zoom=-this.zoomSpeed:this.zoomOut&&this.zoomOut.isDown?this._zoom=this.zoomSpeed:this._zoom=0,0!==this._speedX&&(e.scrollX-=this._speedX*t|0),0!==this._speedY&&(e.scrollY-=this._speedY*t|0),0!==this._zoom&&(e.zoom+=this._zoom,e.zoom<.1&&(e.zoom=.1))}},destroy:function(){this.camera=null,this.left=null,this.right=null,this.up=null,this.down=null,this.zoomIn=null,this.zoomOut=null}});t.exports=r},function(t,e,i){t.exports={Camera:i(115),CameraManager:i(455)}},function(t,e,i){var n=i(115),s=i(0),r=i(2),o=i(12),a=i(33),h=new s({initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),this.currentCameraId=1,this.cameras=[],this.cameraPool=[],t.sys.settings.cameras?this.fromJSON(t.sys.settings.cameras):this.add(),this.main=this.cameras[0],this.baseScale=1},boot:function(){var t=this.systems.events;t.on("update",this.update,this),t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},add:function(t,e,i,s,r,o){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.scene.sys.game.config.width),void 0===s&&(s=this.scene.sys.game.config.height),void 0===r&&(r=!1),void 0===o&&(o="");var a=null;return this.cameraPool.length>0?(a=this.cameraPool.pop()).setViewport(t,e,i,s):a=new n(t,e,i,s),a.setName(o),a.setScene(this.scene),this.cameras.push(a),r&&(this.main=a),a._id=this.currentCameraId,this.currentCameraId=this.currentCameraId<<1,a},addExisting:function(t){var e=this.cameras.indexOf(t),i=this.cameraPool.indexOf(t);return e<0&&i>=0?(this.cameras.push(t),this.cameraPool.slice(i,1),t):null},fromJSON:function(t){Array.isArray(t)||(t=[t]);for(var e=this.scene.sys.game.config.width,i=this.scene.sys.game.config.height,n=0;n=0;i--){var n=e[i];if(n.inputEnabled&&a(n,t.x,t.y))return n}},remove:function(t){var e=this.cameras.indexOf(t);e>=0&&this.cameras.length>1&&(this.cameraPool.push(this.cameras[e]),this.cameras.splice(e,1),this.main===t&&(this.main=this.cameras[0]))},render:function(t,e,i){for(var n=this.cameras,s=this.baseScale,r=0,o=n.length;r0;)this.cameraPool.push(this.cameras.pop());return this.main=this.add(),this.main},update:function(t,e){for(var i=0,n=this.cameras.length;i0&&e.cameraFilter&s._id||this.pipeline.batchSprite(e,s)}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||t.drawImage(e,s)}},function(t,e,i){var n=i(0),s=i(214),r=i(215),o=i(12),a=new n({initialize:function(t){this.scene=t,this.systems=t.sys,this.cameras=[],t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this)},boot:function(){var t=this.systems.events;t.on("update",this.update,this),t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},add:function(t,e,i){return this.addPerspectiveCamera(t,e,i)},addOrthographicCamera:function(t,e){var i=this.scene.sys.game.config;void 0===t&&(t=i.width),void 0===e&&(e=i.height);var n=new s(this.scene,t,e);return this.cameras.push(n),n},addPerspectiveCamera:function(t,e,i){var n=this.scene.sys.game.config;void 0===t&&(t=80),void 0===e&&(e=n.width),void 0===i&&(i=n.height);var s=new r(this.scene,t,e,i);return this.cameras.push(s),s},getCamera:function(t){return this.cameras.forEach(function(e){if(e.name===t)return e}),null},removeCamera:function(t){var e=this.cameras.indexOf(t);-1!==e&&this.cameras.splice(e,1)},removeAll:function(){for(;this.cameras.length>0;){this.cameras.pop().destroy()}return this.main},update:function(t,e){for(var i=0,n=this.cameras.length;i0?this.curves[this.curves.length-1].getPoint(1,t):t.copy(this.startPoint),t},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},getPoint:function(t,e){void 0===e&&(e=new d);for(var i=t*this.getLength(),n=this.getCurveLengths(),s=0;s=i){var r=n[s]-i,o=this.curves[s],a=o.getLength(),h=0===a?0:1-r/a;return o.getPointAt(h,e)}s++}return null},getPoints:function(t){void 0===t&&(t=12);for(var e,i=[],n=0;n1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i},getRandomPoint:function(t){return void 0===t&&(t=new d),this.getPoint(Math.random(),t)},getSpacedPoints:function(t){void 0===t&&(t=40);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return this.autoClose&&e.push(e[0]),e},getStartPoint:function(t){return void 0===t&&(t=new d),t.copy(this.startPoint)},lineTo:function(t,e){t instanceof d?this._tmpVec2B.copy(t):this._tmpVec2B.set(t,e);var i=this.getEndPoint(this._tmpVec2A);return this.add(new a([i.x,i.y,this._tmpVec2B.x,this._tmpVec2B.y]))},splineTo:function(t){return t.unshift(this.getEndPoint()),this.add(new c(t))},moveTo:function(t,e){return this.add(new h(t,e))},toJSON:function(){for(var t=[],e=0;e>16&255,g:t>>8&255,b:255&t,a:255};return t>16777215&&(e.a=t>>>24),e}},function(t,e,i){var n=i(36),s=i(229);t.exports=function(t,e,i){var r=i,o=i,a=i;if(0!==e){var h=i<.5?i*(1+e):i+e-i*e,l=2*i-h;r=s(l,h,t+1/3),o=s(l,h,t),a=s(l,h,t-1/3)}return(new n).setGLTo(r,o,a,1)}},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,i){var n=i(230);t.exports=function(t,e){void 0===t&&(t=1),void 0===e&&(e=1);for(var i=[],s=0;s<=359;s++)i.push(n(s/359,t,e));return i}},function(t,e,i){var n=i(124),s=function(t,e,i,s,r,o,a,h){void 0===a&&(a=100),void 0===h&&(h=0);var l=h/a;return{r:n(t,s,l),g:n(e,r,l),b:n(i,o,l)}};t.exports={RGBWithRGB:s,ColorWithRGB:function(t,e,i,n,r,o){return void 0===r&&(r=100),void 0===o&&(o=0),s(t.r,t.g,t.b,e,i,n,r,o)},ColorWithColor:function(t,e,i,n){return void 0===i&&(i=100),void 0===n&&(n=0),s(t.r,t.g,t.b,e.r,e.g,e.b,i,n)}}},function(t,e,i){var n=i(231),s=i(36);t.exports=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=255),new s(n(t,e),n(t,e),n(t,e))}},function(t,e){t.exports=function(t,e,i){t/=255,e/=255,i/=255;var n=Math.min(t,e,i),s=Math.max(t,e,i),r=s-n,o=0;return s!==n&&(s===t?o=(e-i)/r+(e1)for(var i=1;i=1)&&(r.touch=!0),(navigator.msPointerEnabled||navigator.pointerEnabled)&&(r.mspointer=!0),navigator.getGamepads&&(r.gamepads=!0),n.cocoonJS||("onwheel"in window||s.ie&&"WheelEvent"in window?r.wheelEvent="wheel":"onmousewheel"in window?r.wheelEvent="mousewheel":s.firefox&&"MouseScrollEvent"in window&&(r.wheelEvent="DOMMouseScroll")),r)},function(t,e,i){var n=i(82),s={audioData:!1,dolby:!1,m4a:!1,mp3:!1,ogg:!1,opus:!1,wav:!1,webAudio:!1,webm:!1};t.exports=function(){s.audioData=!!window.Audio,s.webAudio=!(!window.AudioContext&&!window.webkitAudioContext);var t=document.createElement("audio"),e=!!t.canPlayType;try{if(e&&(t.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(s.ogg=!0),(t.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,"")||t.canPlayType("audio/opus;").replace(/^no$/,""))&&(s.opus=!0),t.canPlayType("audio/mpeg;").replace(/^no$/,"")&&(s.mp3=!0),t.canPlayType('audio/wav; codecs="1"').replace(/^no$/,"")&&(s.wav=!0),(t.canPlayType("audio/x-m4a;")||t.canPlayType("audio/aac;").replace(/^no$/,""))&&(s.m4a=!0),t.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")&&(s.webm=!0),""!==t.canPlayType('audio/mp4;codecs="ec-3"')))if(n.edge)s.dolby=!0;else if(n.safari&&n.safariVersion>=9&&/Mac OS X (\d+)_(\d+)/.test(navigator.userAgent)){var i=parseInt(RegExp.$1,10),r=parseInt(RegExp.$2,10);(10===i&&r>=11||i>10)&&(s.dolby=!0)}}catch(t){}return s}()},function(t,e){var i={h264Video:!1,hlsVideo:!1,mp4Video:!1,oggVideo:!1,vp9Video:!1,webmVideo:!1};t.exports=function(){var t=document.createElement("video"),e=!!t.canPlayType;try{e&&(t.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,"")&&(i.oggVideo=!0),t.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,"")&&(i.h264Video=!0,i.mp4Video=!0),t.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")&&(i.webmVideo=!0),t.canPlayType('video/webm; codecs="vp9"').replace(/^no$/,"")&&(i.vp9Video=!0),t.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(/^no$/,"")&&(i.hlsVideo=!0))}catch(t){}return i}()},function(t,e){var i={available:!1,cancel:"",keyboard:!1,request:""};t.exports=function(){var t,e=["requestFullscreen","requestFullScreen","webkitRequestFullscreen","webkitRequestFullScreen","msRequestFullscreen","msRequestFullScreen","mozRequestFullScreen","mozRequestFullscreen"],n=document.createElement("div");for(t=0;t0&&e.maxKeyDelay>0){var r=e.timeLastMatched+e.maxKeyDelay;t.timeStamp<=r&&(s=!0,i=n(t,e))}else s=!0,i=n(t,e);return!s&&e.resetOnWrongKey&&(e.index=0,e.current=e.keyCodes[0]),i&&(e.timeLastMatched=t.timeStamp,e.matched=!0,e.timeMatched=t.timeStamp),i}},function(t,e){t.exports=function(t,e){return e.timeLastMatched=t.timeStamp,e.index++,e.index===e.size||(e.current=e.keyCodes[e.index],!1)}},function(t,e){t.exports=function(t){return t.current=t.keyCodes[0],t.index=0,t.timeLastMatched=0,t.matched=!1,t.timeMatched=0,t}},function(t,e,i){var n=i(129),s={};for(var r in n)s[n[r]]=r;t.exports=s},function(t,e){t.exports=function(t,e){if(t.originalEvent=e,t.preventDefault&&e.preventDefault(),t.enabled)return t.altKey=e.altKey,t.ctrlKey=e.ctrlKey,t.shiftKey=e.shiftKey,t.location=e.location,!1===t.isDown&&(t.isDown=!0,t.isUp=!1,t.timeDown=e.timeStamp,t.duration=0),t.repeats++,t._justDown=!0,t._justUp=!1,t}},function(t,e){t.exports=function(t,e){if(t.originalEvent=e,t.preventDefault&&e.preventDefault(),t.enabled)return t.isDown=!1,t.isUp=!0,t.timeUp=e.timeStamp,t.duration=t.timeUp-t.timeDown,t.repeats=0,t._justDown=!1,t._justUp=!0,t}},function(t,e,i){var n=i(2),s=i(254);t.exports=function(t){var e=t.game.config.defaultPhysicsSystem,i=n(t.settings,"physics",!1);if(e||i){var r=[];if(e&&r.push(s(e+"Physics")),i)for(var o in i)o=s(o.concat("Physics")),-1===r.indexOf(o)&&r.push(o);return r}}},function(t,e,i){var n=i(2);t.exports=function(t){var e=t.game.config.defaultPlugins,i=n(t.settings,"plugins",!1);return Array.isArray(i)?i:e||[]}},function(t,e){t.exports={game:"game",anims:"anims",cache:"cache",registry:"registry",sound:"sound",textures:"textures",events:"events",cameras:"cameras",cameras3d:"cameras3d",add:"add",make:"make",scenePlugin:"scene",displayList:"children",lights:"lights",data:"data",input:"input",load:"load",time:"time",tweens:"tweens",arcadePhysics:"physics",impactPhysics:"impact",matterPhysics:"matter"}},function(t,e){t.exports=function(t,e){var i=t.source[e];return t.add("__BASE",e,0,0,i.width,i.height),t}},function(t,e){t.exports=function(t,e){var i=t.source[e];return t.add("__BASE",e,0,0,i.width,i.height),t}},function(t,e,i){var n=i(53);t.exports=function(t,e,i){if(i.frames||i.textures){var s=t.source[e];t.add("__BASE",e,0,0,s.width,s.height);for(var r,o=Array.isArray(i.textures)?i.textures[e].frames:i.frames,a=0;ag||c<-g)&&(c=0),c<0&&(c=g+c),-1!==d&&(g=c+(d+1));for(var v=f,y=f,m=0,x=0,b=0;br&&(m=w-r),T>o&&(x=T-o),t.add(b,e,i+v,s+y,h-m,l-x),(v+=h+p)+h>r&&(v=f,y+=l+p)}return t}},function(t,e,i){var n=i(2);t.exports=function(t,e,i){var s=n(i,"frameWidth",null),r=n(i,"frameHeight",s);if(!s)throw new Error("TextureManager.SpriteSheetFromAtlas: Invalid frameWidth given.");var o,a=n(i,"startFrame",0),h=n(i,"endFrame",-1),l=n(i,"margin",0),u=n(i,"spacing",0),c=e.cutX,d=e.cutY,f=e.cutWidth,p=e.cutHeight,g=e.realWidth,v=e.realHeight,y=Math.floor((g-l+u)/(s+u)),m=Math.floor((v-l+u)/(r+u)),x=y*m,b=e.x,w=s-b,T=s-(g-f-b),S=e.y,A=r-S,C=r-(v-p-S);(a>x||a<-x)&&(a=0),a<0&&(a=x+a),-1!==h&&(x=a+(h+1));for(var M=l,_=l,E=0,P=e.sourceIndex,L=0;L0||!this.inFocus)&&(this._coolDown--,s=Math.min(s,this._target)),s>this._min&&(s=i[e],s=Math.min(s,this._min)),i[e]=s,this.deltaIndex++,this.deltaIndex>n&&(this.deltaIndex=0);for(var r=0,o=0;othis.nextFpsUpdate&&(this.actualFps=.25*this.framesThisSecond+.75*this.actualFps,this.nextFpsUpdate=t+1e3,this.framesThisSecond=0),this.framesThisSecond++;var a=r/this._target;this.callback(t,r,a),this.lastTime=t},tick:function(){this.step(window.performance.now())},sleep:function(){this.running&&(this.raf.stop(),this.running=!1)},wake:function(t){this.running?this.sleep():t&&(this.startTime+=-this.lastTime+(this.lastTime=window.performance.now())),this.raf.start(this.step.bind(this),this.useRAF),this.running=!0,this.step(window.performance.now())},stop:function(){return this.running=!1,this.started=!1,this.raf.stop(),this},destroy:function(){this.stop(),this.callback=r,this.raf=null,this.game=null}});t.exports=a},function(t,e){t.exports=function(t){var e;void 0!==document.hidden?e="visibilitychange":["webkit","moz","ms"].forEach(function(t){void 0!==document[t+"Hidden"]&&(document.hidden=function(){return document[t+"Hidden"]},e=t+"visibilitychange")});e&&document.addEventListener(e,function(e){document.hidden||"pause"===e.type?t.emit("hidden"):t.emit("visible")},!1),window.onblur=function(){t.emit("blur")},window.onfocus=function(){t.emit("focus")}}},function(t,e,i){var n={DisplayList:i(545),GameObjectCreator:i(13),GameObjectFactory:i(9),UpdateList:i(546),Components:i(11),BuildGameObject:i(20),BuildGameObjectAnimation:i(132),GameObject:i(1),BitmapText:i(133),Blitter:i(134),DynamicBitmapText:i(135),Graphics:i(136),Group:i(69),Image:i(70),Particles:i(139),PathFollower:i(290),RenderTexture:i(141),Sprite3D:i(81),Sprite:i(37),Text:i(142),TileSprite:i(143),Zone:i(77),Factories:{Blitter:i(630),DynamicBitmapText:i(631),Graphics:i(632),Group:i(633),Image:i(634),Particles:i(635),PathFollower:i(636),RenderTexture:i(637),Sprite3D:i(638),Sprite:i(639),StaticBitmapText:i(640),Text:i(641),TileSprite:i(642),Zone:i(643)},Creators:{Blitter:i(644),DynamicBitmapText:i(645),Graphics:i(646),Group:i(647),Image:i(648),Particles:i(649),RenderTexture:i(650),Sprite3D:i(651),Sprite:i(652),StaticBitmapText:i(653),Text:i(654),TileSprite:i(655),Zone:i(656)}};n.Mesh=i(88),n.Quad=i(144),n.Factories.Mesh=i(660),n.Factories.Quad=i(661),n.Creators.Mesh=i(662),n.Creators.Quad=i(663),n.Light=i(292),i(293),i(664),t.exports=n},function(t,e,i){var n=i(0),s=i(86),r=i(12),o=i(267),a=new n({Extends:s,initialize:function(t){s.call(this,t),this.sortChildrenFlag=!1,this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this)},boot:function(){var t=this.systems.events;t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},queueDepthSort:function(){this.sortChildrenFlag=!0},depthSort:function(){this.sortChildrenFlag&&(o.inplace(this.list,this.sortByDepth),this.sortChildrenFlag=!1)},sortByDepth:function(t,e){return t._depth-e._depth},sortGameObjects:function(t){return void 0===t&&(t=this.list),this.scene.sys.depthSort(),t.sort(this.sortIndexHandler.bind(this))},getTopGameObject:function(t){return this.sortGameObjects(t),t[t.length-1]}});r.register("DisplayList",a,"displayList"),t.exports=a},function(t,e,i){var n=i(0),s=i(12),r=new n({initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),this._list=[],this._pendingInsertion=[],this._pendingRemoval=[]},boot:function(){var t=this.systems.events;t.on("preupdate",this.preUpdate,this),t.on("update",this.update,this),t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},add:function(t){return-1===this._list.indexOf(t)&&-1===this._pendingInsertion.indexOf(t)&&this._pendingInsertion.push(t),t},preUpdate:function(){var t=this._pendingRemoval.length,e=this._pendingInsertion.length;if(0!==t||0!==e){var i,n;for(i=0;i-1&&this._list.splice(s,1)}this._list=this._list.concat(this._pendingInsertion.splice(0)),this._pendingRemoval.length=0,this._pendingInsertion.length=0}},update:function(t,e){for(var i=0;ia.length&&(f=a.length);for(var p=l,g=u,v={retroFont:!0,font:h,size:i,lineHeight:s,chars:{}},y=0,m=0;m?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",s.TEXT_SET2=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ",s.TEXT_SET3="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",s.TEXT_SET4="ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",s.TEXT_SET5="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789",s.TEXT_SET6="ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ",s.TEXT_SET7="AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39",s.TEXT_SET8="0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ",s.TEXT_SET9="ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!",s.TEXT_SET10="ABCDEFGHIJKLMNOPQRSTUVWXYZ",s.TEXT_SET11="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789",t.exports=s},function(t,e,i){var n=i(3),s=i(3);n=i(550),s=i(551),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){var r=e.text.length;n.RENDER_MASK!==e.renderFlags||0===r||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchBitmapText(this,s)}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){var r=e.text,o=r.length;if(!(n.RENDER_MASK!==e.renderFlags||0===o||e.cameraFilter>0&&e.cameraFilter&s._id)){var a=e.frame,h=e.fontData.chars,l=e.fontData.lineHeight,u=0,c=0,d=0,f=0,p=null,g=0,v=0,y=0,m=0,x=0,b=0,w=null,T=0,S=t.currentContext,A=e.frame.source.image,C=a.cutX,M=a.cutY,_=e.fontSize/e.fontData.size;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,S.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,S.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var E=t.config.roundPixels,P=e.x-s.scrollX*e.scrollFactorX+e.frame.x,L=e.y-s.scrollY*e.scrollFactorY+e.frame.y;E&&(P|=0,L|=0),S.save(),S.translate(P,L),S.rotate(e.rotation),S.translate(-e.displayOriginX,-e.displayOriginY),S.scale(e.scaleX,e.scaleY);for(var k=0;k0&&e.cameraFilter&s._id||this.pipeline.drawBlitter(e,s)}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){var r=e.getRenderList();t.setBlendMode(e.blendMode);for(var o=t.gameContext,a=e.x-s.scrollX*e.scrollFactorX,h=e.y-s.scrollY*e.scrollFactorY,l=0;l0&&e.cameraFilter&s._id||this.pipeline.batchDynamicBitmapText(e,s)}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){var r=e.text,o=r.length;if(!(n.RENDER_MASK!==e.renderFlags||0===o||e.cameraFilter>0&&e.cameraFilter&s._id)){var a=e.frame,h=e.displayCallback,l=s.scrollX*e.scrollFactorX,u=s.scrollY*e.scrollFactorY,c=e.fontData.chars,d=e.fontData.lineHeight,f=0,p=0,g=0,v=0,y=null,m=0,x=0,b=0,w=0,T=0,S=0,A=null,C=0,M=t.currentContext,_=e.frame.source.image,E=a.cutX,P=a.cutY,L=0,k=e.fontSize/e.fontData.size;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,M.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,M.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode),M.save(),M.translate(e.x,e.y),M.rotate(e.rotation),M.translate(-e.displayOriginX,-e.displayOriginY),M.scale(e.scaleX,e.scaleY),e.cropWidth>0&&e.cropHeight>0&&(M.save(),M.beginPath(),M.rect(0,0,e.cropWidth,e.cropHeight),M.clip());for(var F=t.config.roundPixels,O=0;O0&&e.cropHeight>0&&M.restore(),M.restore()}}},function(t,e){t.exports=function(t){return t.isEmpty()?0:t.getMajorRadius()*t.getMinorRadius()*Math.PI}},function(t,e,i){var n=i(137);t.exports=function(t){return new n(t.x,t.y,t.width,t.height)}},function(t,e,i){var n=i(68);t.exports=function(t,e){return n(t,e.x,e.y)}},function(t,e,i){var n=i(68);t.exports=function(t,e){return n(t,e.x,e.y)&&n(t,e.right,e.y)&&n(t,e.x,e.bottom)&&n(t,e.right,e.bottom)}},function(t,e){t.exports=function(t,e){return e.setTo(t.x,t.y,t.width,t.height)}},function(t,e){t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}},function(t,e,i){var n=i(8);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.left,e.y=t.top,e.width=t.width,e.height=t.height,e}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e,i){var n=i(3),s=i(3);n=i(569),s=i(274),s=i(274),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchGraphics(this,s)}},function(t,e,i){var n=i(3),s=i(3);n=i(571),s=i(572),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchSprite(e,s)}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||t.drawImage(e,s)}},function(t,e,i){var n=i(0),s=i(2),r=new n({initialize:function(t,e,i,n,r){if("object"==typeof t){var o=t;t=s(o,"x",0),e=s(o,"y",0),i=s(o,"power",0),n=s(o,"epsilon",100),r=s(o,"gravity",50)}else void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=100),void 0===r&&(r=50);this.x=t,this.y=e,this.active=!0,this._gravity=r,this._power=0,this._epsilon=0,this.power=i,this.epsilon=n},update:function(t,e){var i=this.x-t.x,n=this.y-t.y,s=i*i+n*n;if(0!==s){var r=Math.sqrt(s);s0&&this.getParticleCount()===this.maxParticles},onParticleEmit:function(t,e){return void 0===t?(this.emitCallback=null,this.emitCallbackScope=null):"function"==typeof t&&(this.emitCallback=t,e&&(this.emitCallbackScope=e)),this},onParticleDeath:function(t,e){return void 0===t?(this.deathCallback=null,this.deathCallbackScope=null):"function"==typeof t&&(this.deathCallback=t,e&&(this.deathCallbackScope=e)),this},killAll:function(){for(var t=this.dead,e=this.alive;e.length>0;)t.push(e.pop());return this},forEachAlive:function(t,e){for(var i=this.alive,n=i.length,s=0;s0?n.pop():new this.particleClass(this)).fire(e,i),this.particleBringToTop?this.alive.push(r):this.alive.unshift(r),this.emitCallback&&this.emitCallback.call(this.emitCallbackScope,r,this),this.atLimit())break}return r}},preUpdate:function(t,e){var i=(e*=this.timeScale)/1e3;this.trackVisible&&(this.visible=this.follow.visible);for(var n=this.manager.getProcessors(),s=this.alive,r=s.length,o=0;o0){var u=s.splice(s.length-l,l),c=this.deathCallback,d=this.deathCallbackScope;if(c)for(var f=0;f0&&(this._counter-=e,this._counter<=0&&(this.emitParticle(),this._counter=this.frequency-Math.abs(this._counter))))},depthSortCallback:function(t,e){return t.y-e.y},indexSortCallback:function(t,e){return t.index-e.index}});t.exports=x},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.source=t,this.killOnEnter=e},willKill:function(t){var e=this.source.contains(t.x,t.y);return e&&this.killOnEnter||!e&&!this.killOnEnter}});t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s){void 0===n&&(n=!1),void 0===s&&(s=!0),this.source=t,this.points=[],this.quantity=e,this.stepRate=i,this.yoyo=n,this.counter=-1,this.seamless=s,this._length=0,this._direction=0,this.updateSource()},updateSource:function(){if(this.points=this.source.getPoints(this.quantity,this.stepRate),this.seamless){var t=this.points[0],e=this.points[this.points.length-1];t.x===e.x&&t.y===e.y&&this.points.pop()}var i=this._length;return this._length=this.points.length,this._lengththis._length&&(this.counter=this._length-1),this},changeSource:function(t){return this.source=t,this.updateSource()},getPoint:function(t){0===this._direction?(this.counter++,this.counter>=this._length&&(this.yoyo?(this._direction=1,this.counter=this._length-1):this.counter=0)):(this.counter--,-1===this.counter&&(this.yoyo?(this._direction=0,this.counter=0):this.counter=this._length-1));var e=this.points[this.counter];e&&(t.x=e.x,t.y=e.y)}});t.exports=n},function(t,e,i){var n=i(0),s=i(276),r=i(71),o=i(2),a=i(50),h=new n({initialize:function(t,e,i,n){void 0===n&&(n=!1),this.propertyKey=e,this.propertyValue=i,this.defaultValue=i,this.steps=0,this.counter=0,this.start=0,this.end=0,this.ease,this.emitOnly=n,this.onEmit=this.defaultEmit,this.onUpdate=this.defaultUpdate,this.loadConfig(t)},loadConfig:function(t,e){void 0===t&&(t={}),e&&(this.propertyKey=e),this.propertyValue=o(t,this.propertyKey,this.defaultValue),this.setMethods(),this.emitOnly&&(this.onUpdate=this.defaultUpdate)},toJSON:function(){return JSON.stringify(this.propertyValue)},onChange:function(t){return this.propertyValue=t,this.setMethods()},setMethods:function(){var t=this.propertyValue,e=typeof t;if("number"===e)this.onEmit=this.staticValueEmit,this.onUpdate=this.staticValueUpdate;else if(Array.isArray(t))this.onEmit=this.randomStaticValueEmit;else if("function"===e)this.emitOnly?this.onEmit=t:this.onUpdate=t;else if("object"===e&&(this.has(t,"random")||this.hasBoth(t,"start","end")||this.hasBoth(t,"min","max"))){this.start=this.has(t,"start")?t.start:t.min,this.end=this.has(t,"end")?t.end:t.max;var i=this.hasBoth(t,"min","max")||this.has(t,"random");if(i){var n=t.random;Array.isArray(n)&&(this.start=n[0],this.end=n[1]),this.onEmit=this.randomRangedValueEmit}if(this.has(t,"steps"))this.steps=t.steps,this.counter=this.start,this.onEmit=this.steppedEmit;else{var s=this.has(t,"ease")?t.ease:"Linear";this.ease=r(s),i||(this.onEmit=this.easedValueEmit),this.onUpdate=this.easeValueUpdate}}else"object"===e&&this.hasEither(t,"onEmit","onUpdate")&&(this.has(t,"onEmit")&&(this.onEmit=t.onEmit),this.has(t,"onUpdate")&&(this.onUpdate=t.onUpdate));return this},has:function(t,e){return t.hasOwnProperty(e)},hasBoth:function(t,e,i){return t.hasOwnProperty(e)&&t.hasOwnProperty(i)},hasEither:function(t,e,i){return t.hasOwnProperty(e)||t.hasOwnProperty(i)},defaultEmit:function(t,e,i){return i},defaultUpdate:function(t,e,i,n){return n},staticValueEmit:function(){return this.propertyValue},staticValueUpdate:function(){return this.propertyValue},randomStaticValueEmit:function(){var t=Math.floor(Math.random()*this.propertyValue.length);return this.propertyValue[t]},randomRangedValueEmit:function(t,e){var i=s(this.start,this.end);return t&&t.data[e]&&(t.data[e].min=i),i},steppedEmit:function(){var t=this.counter,e=this.counter+(this.end-this.start)/this.steps;return this.counter=a(e,this.start,this.end),t},easedValueEmit:function(t,e){if(t&&t.data[e]){var i=t.data[e];i.min=this.start,i.max=this.end}return this.start},easeValueUpdate:function(t,e,i){var n=t.data[e];return(n.max-n.min)*this.ease(i)+n.min}});t.exports=h},function(t,e,i){var n=i(277),s=i(278),r=i(279),o=i(280),a=i(281),h=i(282),l=i(283),u=i(284),c=i(285),d=i(286),f=i(287),p=i(288);t.exports={Power0:l,Power1:u.Out,Power2:o.Out,Power3:c.Out,Power4:d.Out,Linear:l,Quad:u.Out,Cubic:o.Out,Quart:c.Out,Quint:d.Out,Sine:f.Out,Expo:h.Out,Circ:r.Out,Elastic:a.Out,Back:n.Out,Bounce:s.Out,Stepped:p,"Quad.easeIn":u.In,"Cubic.easeIn":o.In,"Quart.easeIn":c.In,"Quint.easeIn":d.In,"Sine.easeIn":f.In,"Expo.easeIn":h.In,"Circ.easeIn":r.In,"Elastic.easeIn":a.In,"Back.easeIn":n.In,"Bounce.easeIn":s.In,"Quad.easeOut":u.Out,"Cubic.easeOut":o.Out,"Quart.easeOut":c.Out,"Quint.easeOut":d.Out,"Sine.easeOut":f.Out,"Expo.easeOut":h.Out,"Circ.easeOut":r.Out,"Elastic.easeOut":a.Out,"Back.easeOut":n.Out,"Bounce.easeOut":s.Out,"Quad.easeInOut":u.InOut,"Cubic.easeInOut":o.InOut,"Quart.easeInOut":c.InOut,"Quint.easeInOut":d.InOut,"Sine.easeInOut":f.InOut,"Expo.easeInOut":h.InOut,"Circ.easeInOut":r.InOut,"Elastic.easeInOut":a.InOut,"Back.easeInOut":n.InOut,"Bounce.easeInOut":s.InOut}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1.70158),t*t*((e+1)*t-e)}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1.70158),--t*t*((e+1)*t+e)+1}},function(t,e){t.exports=function(t,e){void 0===e&&(e=1.70158);var i=1.525*e;return(t*=2)<1?t*t*((i+1)*t-i)*.5:.5*((t-=2)*t*((i+1)*t+i)+2)}},function(t,e){t.exports=function(t){return(t=1-t)<1/2.75?1-7.5625*t*t:t<2/2.75?1-(7.5625*(t-=1.5/2.75)*t+.75):t<2.5/2.75?1-(7.5625*(t-=2.25/2.75)*t+.9375):1-(7.5625*(t-=2.625/2.75)*t+.984375)}},function(t,e){t.exports=function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},function(t,e){t.exports=function(t){var e=!1;return t<.5?(t=1-2*t,e=!0):t=2*t-1,t<1/2.75?t*=7.5625*t:t=t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375,e?.5*(1-t):.5*t+.5}},function(t,e){t.exports=function(t){return 1-Math.sqrt(1-t*t)}},function(t,e){t.exports=function(t){return Math.sqrt(1- --t*t)}},function(t,e){t.exports=function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},function(t,e){t.exports=function(t){return t*t*t}},function(t,e){t.exports=function(t){return--t*t*t+1}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),-e*Math.pow(2,10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),e*Math.pow(2,-10*t)*Math.sin((t-n)*(2*Math.PI)/i)+1}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),(t*=2)<1?e*Math.pow(2,10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)*-.5:e*Math.pow(2,-10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)*.5+1}},function(t,e){t.exports=function(t){return Math.pow(2,10*(t-1))-.001}},function(t,e){t.exports=function(t){return 1-Math.pow(2,-10*t)}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*(t-1)))}},function(t,e){t.exports=function(t){return t}},function(t,e){t.exports=function(t){return t*t}},function(t,e){t.exports=function(t){return t*(2-t)}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},function(t,e){t.exports=function(t){return t*t*t*t}},function(t,e){t.exports=function(t){return 1- --t*t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},function(t,e){t.exports=function(t){return t*t*t*t*t}},function(t,e){t.exports=function(t){return--t*t*t*t*t+1}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:1-Math.cos(t*Math.PI/2)}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:Math.sin(t*Math.PI/2)}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:.5*(1-Math.cos(Math.PI*t))}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1),t<=0?0:t>=1?1:1/e*(1+(e*t|0))}},function(t,e,i){var n=i(0),s=i(35),r=i(42),o=new n({initialize:function(t){this.emitter=t,this.frame=null,this.index=0,this.x=0,this.y=0,this.velocityX=0,this.velocityY=0,this.accelerationX=0,this.accelerationY=0,this.maxVelocityX=1e4,this.maxVelocityY=1e4,this.bounce=0,this.scaleX=1,this.scaleY=1,this.alpha=1,this.angle=0,this.rotation=0,this.scrollFactorX=1,this.scrollFactorY=1,this.tint=4294967295,this.color=4294967295,this.life=1e3,this.lifeCurrent=1e3,this.delayCurrent=0,this.lifeT=0,this.data={tint:{min:16777215,max:16777215,current:16777215},alpha:{min:1,max:1},rotate:{min:0,max:0},scaleX:{min:1,max:1},scaleY:{min:1,max:1}}},isAlive:function(){return this.lifeCurrent>0},fire:function(t,e){var i=this.emitter;this.frame=i.getFrame(),i.emitZone&&i.emitZone.getPoint(this),void 0===t?(i.follow&&(this.x+=i.follow.x+i.followOffset.x),this.x+=i.x.onEmit(this,"x")):this.x+=t,void 0===e?(i.follow&&(this.y+=i.follow.y+i.followOffset.y),this.y+=i.y.onEmit(this,"y")):this.y+=e,this.life=i.lifespan.onEmit(this,"lifespan"),this.lifeCurrent=this.life,this.lifeT=0;var n=i.speedX.onEmit(this,"speedX"),o=i.speedY?i.speedY.onEmit(this,"speedY"):n;if(i.radial){var a=s(i.angle.onEmit(this,"angle"));this.velocityX=Math.cos(a)*Math.abs(n),this.velocityY=Math.sin(a)*Math.abs(o)}else if(i.moveTo){var h=i.moveToX.onEmit(this,"moveToX"),l=i.moveToY?i.moveToY.onEmit(this,"moveToY"):h,u=Math.atan2(l-this.y,h-this.x),c=r(this.x,this.y,h,l)/(this.life/1e3);this.velocityX=Math.cos(u)*c,this.velocityY=Math.sin(u)*c}else this.velocityX=n,this.velocityY=o;i.acceleration&&(this.accelerationX=i.accelerationX.onEmit(this,"accelerationX"),this.accelerationY=i.accelerationY.onEmit(this,"accelerationY")),this.maxVelocityX=i.maxVelocityX.onEmit(this,"maxVelocityX"),this.maxVelocityY=i.maxVelocityY.onEmit(this,"maxVelocityY"),this.delayCurrent=i.delay.onEmit(this,"delay"),this.scaleX=i.scaleX.onEmit(this,"scaleX"),this.scaleY=i.scaleY?i.scaleY.onEmit(this,"scaleY"):this.scaleX,this.angle=i.rotate.onEmit(this,"rotate"),this.rotation=s(this.angle),this.bounce=i.bounce.onEmit(this,"bounce"),this.alpha=i.alpha.onEmit(this,"alpha"),this.tint=i.tint.onEmit(this,"tint"),this.color=16777215&this.tint|(255*this.alpha|0)<<24,this.index=i.alive.length},computeVelocity:function(t,e,i,n){var s=this.velocityX,r=this.velocityY,o=this.accelerationX,a=this.accelerationY,h=this.maxVelocityX,l=this.maxVelocityY;s+=t.gravityX*i,r+=t.gravityY*i,o&&(s+=o*i),a&&(r+=a*i),s>h?s=h:s<-h&&(s=-h),r>l?r=l:r<-l&&(r=-l),this.velocityX=s,this.velocityY=r;for(var u=0;ue.right&&t.collideRight&&(this.x=e.right,this.velocityX*=i),this.ye.bottom&&t.collideBottom&&(this.y=e.bottom,this.velocityY*=i)},update:function(t,e,i){if(this.delayCurrent>0)return this.delayCurrent-=t,!1;var n=this.emitter,r=1-this.lifeCurrent/this.life;return this.lifeT=r,this.computeVelocity(n,t,e,i),this.x+=this.velocityX*e,this.y+=this.velocityY*e,n.bounds&&this.checkBounds(n),n.deathZone&&n.deathZone.willKill(this)?(this.lifeCurrent=0,!0):(this.scaleX=n.scaleX.onUpdate(this,"scaleX",r,this.scaleX),n.scaleY?this.scaleY=n.scaleY.onUpdate(this,"scaleY",r,this.scaleY):this.scaleY=this.scaleX,this.angle=n.rotate.onUpdate(this,"rotate",r,this.angle),this.rotation=s(this.angle),this.alpha=n.alpha.onUpdate(this,"alpha",r,this.alpha),this.tint=n.tint.onUpdate(this,"tint",r,this.tint),this.color=16777215&this.tint|(255*this.alpha|0)<<24,this.lifeCurrent-=t,this.lifeCurrent<=0)}});t.exports=o},function(t,e,i){var n=i(0),s=i(6),r=new n({initialize:function(t){this.source=t,this._tempVec=new s},getPoint:function(t){var e=this._tempVec;this.source.getRandomPoint(e),t.x=e.x,t.y=e.y}});t.exports=r},function(t,e,i){var n=i(3),s=i(3);n=i(614),s=i(615),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){0===e.emitters.length||n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.drawEmitterManager(e,s)}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){var r=e.emitters.list;if(!(0===r.length||n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id))for(var o=0;o>24&255)/255;if(!(y<=0)){var m=v.frame,x=.5*m.width,b=.5*m.height,w=m.canvasData,T=-x,S=-b,A=v.x-d*v.scrollFactorX,C=v.y-f*v.scrollFactorY;p&&(A|=0,C|=0),u.globalAlpha=y,u.save(),u.translate(A,C),u.rotate(v.rotation),u.scale(v.scaleX,v.scaleY),u.drawImage(m.source.image,w.sx,w.sy,w.sWidth,w.sHeight,T,S,w.dWidth,w.dHeight),u.restore()}}u.globalAlpha=c}}}},function(t,e,i){var n=i(3),s=i(3);n=i(617),s=i(618),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchTexture(e,e.texture,e.texture.width,e.texture.height,e.x,e.y,e.width,e.height,e.scaleX,e.scaleY,e.rotation,e.flipX,e.flipY,e.scrollFactorX,e.scrollFactorY,e.displayOriginX,e.displayOriginY,0,0,e.texture.width,e.texture.height,4294967295,4294967295,4294967295,4294967295,0,0,s)}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){var r=t.currentContext;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,r.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,r.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var o=0,a=0,h=1,l=1;e.flipX?(h=-1,o-=e.canvas.width-e.displayOriginX):o-=e.displayOriginX,e.flipY?(l=-1,a-=e.canvas.height-e.displayOriginY):a-=e.displayOriginY,r.save(),r.translate(e.x-s.scrollX*e.scrollFactorX,e.y-s.scrollY*e.scrollFactorY),r.rotate(e.rotation),r.scale(e.scaleX,e.scaleY),r.scale(h,l),r.drawImage(e.canvas,o,a),r.restore()}}},function(t,e){t.exports={fill:function(t){var e=255&(t>>16|0),i=255&(t>>8|0),n=255&(0|t);return this.context.fillStyle="rgb("+e+","+i+","+n+")",this.context.fillRect(0,0,this.canvas.width,this.canvas.height),this},clear:function(){return this.context.save(),this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.restore(),this},draw:function(t,e,i,n){var s=this.currentMatrix;return this.context.globalAlpha=this.globalAlpha,this.context.setTransform(s[0],s[1],s[2],s[3],s[4],s[5]),this.context.drawImage(t.source[e.sourceIndex].image,e.cutX,e.cutY,e.cutWidth,e.cutHeight,i,n,e.cutWidth,e.cutWidth),this}}},function(t,e){t.exports={fill:function(t){var e=255&(t>>16|0),i=255&(t>>8|0),n=255&(0|t);this.renderer.setFramebuffer(this.framebuffer);var s=this.gl;return s.clearColor(e/255,i/255,n/255,1),s.clear(s.COLOR_BUFFER_BIT),this.renderer.setFramebuffer(null),this},clear:function(){this.renderer.setFramebuffer(this.framebuffer);var t=this.gl;return t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),this.renderer.setFramebuffer(null),this},draw:function(t,e,i,n){var s=t.source[e.sourceIndex].glTexture,r=(this.globalTint>>16)+(65280&this.globalTint)+((255&this.globalTint)<<16);return this.renderer.setFramebuffer(this.framebuffer),this.renderer.pipelines.TextureTintPipeline.drawTexture(s,i,n,r,this.globalAlpha,e.cutX,e.cutY,e.cutWidth,e.cutHeight,this.currentMatrix),this.renderer.setFramebuffer(null),this}}},function(t,e){t.exports=function(t,e,i){var n=t.canvas,s=t.context,r=t.style,o=[],a=0,h=i.length;r.maxLines>0&&r.maxLinesc&&(f=-c),0!==f&&(d+=f>0?f*i.length:f*(i.length-1)),{width:a,height:d,lines:h,lineWidths:o,lineSpacing:f,lineHeight:c}}},function(t,e,i){var n=i(3),s=i(3);n=i(623),s=i(624),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||""===e.text||(e.dirty&&(e.canvasTexture=t.canvasToTexture(e.canvas,e.canvasTexture,!0,e.scaleMode),e.dirty=!1),this.pipeline.batchText(this,s))}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||""===e.text)){var r=t.currentContext;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,r.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,r.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var o=e.canvas;r.save();var a=e.x-s.scrollX*e.scrollFactorX,h=e.y-s.scrollY*e.scrollFactorY;t.config.roundPixels&&(a|=0,h|=0),r.translate(a,h),r.rotate(e.rotation),r.scale(e.scaleX,e.scaleY),r.translate(o.width*(e.flipX?1:0),o.height*(e.flipY?1:0)),r.scale(e.flipX?-1:1,e.flipY?-1:1),r.drawImage(o,0,0,o.width,o.height,-e.displayOriginX,-e.displayOriginY,o.width,o.height),r.restore()}}},function(t,e,i){var n=i(0),s=i(10),r=i(4),o=i(626),a={fontFamily:["fontFamily","Courier"],fontSize:["fontSize","16px"],fontStyle:["fontStyle",""],backgroundColor:["backgroundColor",null],color:["color","#fff"],stroke:["stroke","#fff"],strokeThickness:["strokeThickness",0],shadowOffsetX:["shadow.offsetX",0],shadowOffsetY:["shadow.offsetY",0],shadowColor:["shadow.color","#000"],shadowBlur:["shadow.blur",0],shadowStroke:["shadow.stroke",!1],shadowFill:["shadow.fill",!1],align:["align","left"],maxLines:["maxLines",0],fixedWidth:["fixedWidth",0],fixedHeight:["fixedHeight",0],rtl:["rtl",!1],testString:["testString","|MÉqgy"],wordWrapWidth:["wordWrap.width",null],wordWrapCallback:["wordWrap.callback",null],wordWrapCallbackScope:["wordWrap.callbackScope",null],wordWrapUseAdvanced:["wordWrap.useAdvancedWrap",!1]},h=new n({initialize:function(t,e){this.parent=t,this.fontFamily,this.fontSize,this.fontStyle,this.backgroundColor,this.color,this.stroke,this.strokeThickness,this.shadowOffsetX,this.shadowOffsetY,this.shadowColor,this.shadowBlur,this.shadowStroke,this.shadowFill,this.align,this.maxLines,this.fixedWidth,this.fixedHeight,this.rtl,this.testString,this._font,this.setStyle(e,!1);var i=r(e,"metrics",!1);this.metrics=i?{ascent:r(i,"ascent",0),descent:r(i,"descent",0),fontSize:r(i,"fontSize",0)}:o(this)},setStyle:function(t,e){for(var i in void 0===e&&(e=!0),t&&t.hasOwnProperty("fontSize")&&"number"==typeof t.fontSize&&(t.fontSize=t.fontSize.toString()+"px"),a)this[i]="wordWrapCallback"===i||"wordWrapCallbackScope"===i?r(t,a[i][0],a[i][1]):s(t,a[i][0],a[i][1]);var n=r(t,"font",null);this._font=null===n?[this.fontStyle,this.fontSize,this.fontFamily].join(" "):n;var o=r(t,"fill",null);return null!==o&&(this.color=o),e?this.update(!0):this.parent},syncFont:function(t,e){e.font=this._font},syncStyle:function(t,e){e.textBaseline="alphabetic",e.fillStyle=this.color,e.strokeStyle=this.stroke,e.lineWidth=this.strokeThickness,e.lineCap="round",e.lineJoin="round"},syncShadow:function(t,e){e?(t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY,t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur):(t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowColor=0,t.shadowBlur=0)},update:function(t){return t&&(this._font=[this.fontStyle,this.fontSize,this.fontFamily].join(" "),this.metrics=o(this)),this.parent.updateText()},setFont:function(t){return"string"==typeof t?(this.fontFamily=t,this.fontSize="",this.fontStyle=""):(this.fontFamily=r(t,"fontFamily","Courier"),this.fontSize=r(t,"fontSize","16px"),this.fontStyle=r(t,"fontStyle","")),this.update(!0)},setFontFamily:function(t){return this.fontFamily=t,this.update(!0)},setFontStyle:function(t){return this.fontStyle=t,this.update(!0)},setFontSize:function(t){return"number"==typeof t&&(t=t.toString()+"px"),this.fontSize=t,this.update(!0)},setTestString:function(t){return this.testString=t,this.update(!0)},setFixedSize:function(t,e){return this.fixedWidth=t,this.fixedHeight=e,t&&(this.parent.width=t),e&&(this.parent.height=e),this.update(!1)},setBackgroundColor:function(t){return this.backgroundColor=t,this.update(!1)},setFill:function(t){return this.color=t,this.update(!1)},setColor:function(t){return this.color=t,this.update(!1)},setStroke:function(t,e){return void 0===t?this.strokeThickness=0:(void 0===e&&(e=this.strokeThickness),this.stroke=t,this.strokeThickness=e),this.update(!0)},setShadow:function(t,e,i,n,s,r){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i="#000"),void 0===n&&(n=0),void 0===s&&(s=!1),void 0===r&&(r=!0),this.shadowOffsetX=t,this.shadowOffsetY=e,this.shadowColor=i,this.shadowBlur=n,this.shadowStroke=s,this.shadowFill=r,this.update(!1)},setShadowOffset:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.shadowOffsetX=t,this.shadowOffsetY=e,this.update(!1)},setShadowColor:function(t){return void 0===t&&(t="#000"),this.shadowColor=t,this.update(!1)},setShadowBlur:function(t){return void 0===t&&(t=0),this.shadowBlur=t,this.update(!1)},setShadowStroke:function(t){return this.shadowStroke=t,this.update(!1)},setShadowFill:function(t){return this.shadowFill=t,this.update(!1)},setWordWrapWidth:function(t,e){return void 0===e&&(e=!1),this.wordWrapWidth=t,this.wordWrapUseAdvanced=e,this.update(!1)},setWordWrapCallback:function(t,e){return void 0===e&&(e=null),this.wordWrapCallback=t,this.wordWrapCallbackScope=e,this.update(!1)},setAlign:function(t){return void 0===t&&(t="left"),this.align=t,this.update(!1)},setMaxLines:function(t){return void 0===t&&(t=0),this.maxLines=t,this.update(!1)},getTextMetrics:function(){var t=this.metrics;return{ascent:t.ascent,descent:t.descent,fontSize:t.fontSize}},toJSON:function(){var t={};for(var e in a)t[e]=this[e];return t.metrics=this.getTextMetrics(),t},destroy:function(){this.parent=void 0}});t.exports=h},function(t,e,i){var n=i(21);t.exports=function(t){var e=n.create(this),i=e.getContext("2d");t.syncFont(e,i);var s=Math.ceil(1.2*i.measureText(t.testString).width),r=s,o=2*r;r=1.4*r|0,e.width=s,e.height=o,i.fillStyle="#f00",i.fillRect(0,0,s,o),i.font=t._font,i.textBaseline="alphabetic",i.fillStyle="#000",i.fillText(t.testString,0,r);var a={ascent:0,descent:0,fontSize:0};if(!i.getImageData(0,0,s,o))return a.ascent=r,a.descent=r+6,a.fontSize=a.ascent+a.descent,n.remove(e),a;var h,l,u=i.getImageData(0,0,s,o).data,c=u.length,d=4*s,f=0,p=!1;for(h=0;hr;h--){for(l=0;l0&&e.cameraFilter&s._id||(e.updateTileTexture(),this.pipeline.batchTileSprite(this,s))}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){var r=t.currentContext,o=e.frame;e.updateTileTexture(),t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,r.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,r.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var a=o.x-e.originX*e.width,h=o.y-e.originY*e.height,l=e.x-s.scrollX*e.scrollFactorX,u=e.y-s.scrollY*e.scrollFactorY,c=1,d=1;e.flipX&&(c=-1,a+=e.width),e.flipY&&(d=-1,h+=e.height),t.config.roundPixels&&(a|=0,h|=0,l|=0,u|=0),r.save(),r.translate(a,h),r.translate(l,u),r.scale(c,d),r.translate(e.originX*e.width,e.originY*e.height),r.rotate(c*d*e.rotation),r.scale(this.scaleX,this.scaleY),r.translate(-e.originX*e.width,-e.originY*e.height),r.translate(-this.tilePositionX,-this.tilePositionY),r.fillStyle=e.canvasPattern,r.fillRect(this.tilePositionX,this.tilePositionY,e.width,e.height),r.restore()}}},function(t,e,i){var n=i(134);i(9).register("blitter",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(135);i(9).register("dynamicBitmapText",function(t,e,i,s,r){return this.displayList.add(new n(this.scene,t,e,i,s,r))})},function(t,e,i){var n=i(136);i(9).register("graphics",function(t){return this.displayList.add(new n(this.scene,t))})},function(t,e,i){var n=i(69);i(9).register("group",function(t,e){return"object"==typeof t&&void 0===e&&(e=t,t=[]),this.updateList.add(new n(this.scene,t,e))})},function(t,e,i){var n=i(70);i(9).register("image",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(9),s=i(139);n.register("particles",function(t,e,i){var n=new s(this.scene,t,e,i);return this.displayList.add(n),this.updateList.add(n),n})},function(t,e,i){var n=i(9),s=i(290);n.register("follower",function(t,e,i,n,r){var o=new s(this.scene,t,e,i,n,r);return this.displayList.add(o),this.updateList.add(o),o})},function(t,e,i){var n=i(9),s=i(141);n.register("renderTexture",function(t,e,i,n){return this.displayList.add(new s(this.scene,t,e,i,n))})},function(t,e,i){var n=i(81);i(9).register("sprite3D",function(t,e,i,s,r){var o=new n(this.scene,t,e,i,s,r);return this.displayList.add(o.gameObject),this.updateList.add(o.gameObject),o})},function(t,e,i){var n=i(9),s=i(37);n.register("sprite",function(t,e,i,n){var r=new s(this.scene,t,e,i,n);return this.displayList.add(r),this.updateList.add(r),r})},function(t,e,i){var n=i(133);i(9).register("bitmapText",function(t,e,i,s,r){return this.displayList.add(new n(this.scene,t,e,i,s,r))})},function(t,e,i){var n=i(142);i(9).register("text",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(143);i(9).register("tileSprite",function(t,e,i,s,r,o){return this.displayList.add(new n(this.scene,t,e,i,s,r,o))})},function(t,e,i){var n=i(77);i(9).register("zone",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(134),s=i(20),r=i(13),o=i(10);r.register("blitter",function(t){var e=o(t,"key",null),i=o(t,"frame",null),r=new n(this.scene,0,0,e,i);return s(this.scene,r,t),r})},function(t,e,i){var n=i(135),s=i(20),r=i(13),o=i(10);r.register("dynamicBitmapText",function(t){var e=o(t,"font",""),i=o(t,"text",""),r=o(t,"size",!1),a=o(t,"align","left"),h=new n(this.scene,0,0,e,i,r,a);return s(this.scene,h,t),h})},function(t,e,i){var n=i(13),s=i(136);n.register("graphics",function(t){return new s(this.scene,t)})},function(t,e,i){var n=i(13),s=i(69);n.register("group",function(t){return new s(this.scene,null,t)})},function(t,e,i){var n=i(20),s=i(13),r=i(10),o=i(70);s.register("image",function(t){var e=r(t,"key",null),i=r(t,"frame",null),s=new o(this.scene,0,0,e,i);return n(this.scene,s,t),s})},function(t,e,i){var n=i(13),s=i(10),r=i(2),o=i(139);n.register("particles",function(t){var e=s(t,"key",null),i=s(t,"frame",null),n=r(t,"emitters",null),a=new o(this.scene,e,i,n);return r(t,"add",!1)&&this.displayList.add(a),this.updateList.add(a),a})},function(t,e,i){var n=i(20),s=i(13),r=i(10),o=i(141);s.register("renderTexture",function(t){var e=r(t,"x",0),i=r(t,"y",0),s=r(t,"width",32),a=r(t,"height",32),h=new o(this.scene,e,i,s,a);return n(this.scene,h,t),h})},function(t,e,i){var n=i(20),s=i(132),r=i(13),o=i(10),a=i(81);r.register("sprite3D",function(t){var e=o(t,"key",null),i=o(t,"frame",null),r=new a(this.scene,0,0,e,i);return n(this.scene,r,t),s(r,t),r})},function(t,e,i){var n=i(20),s=i(132),r=i(13),o=i(10),a=i(37);r.register("sprite",function(t){var e=o(t,"key",null),i=o(t,"frame",null),r=new a(this.scene,0,0,e,i);return n(this.scene,r,t),s(r,t),r})},function(t,e,i){var n=i(133),s=i(20),r=i(13),o=i(10),a=i(4);r.register("bitmapText",function(t){var e=a(t,"font",""),i=o(t,"text",""),r=o(t,"size",!1),h=new n(this.scene,0,0,e,i,r);return s(this.scene,h,t),h})},function(t,e,i){var n=i(20),s=i(13),r=i(10),o=i(142);s.register("text",function(t){var e=r(t,"text",""),i=r(t,"style",null),s=r(t,"padding",null);null!==s&&(i.padding=s);var a=new o(this.scene,0,0,e,i);return n(this.scene,a,t),a.autoRound=r(t,"autoRound",!0),a.resolution=r(t,"resolution",1),a})},function(t,e,i){var n=i(20),s=i(13),r=i(10),o=i(143);s.register("tileSprite",function(t){var e=r(t,"x",0),i=r(t,"y",0),s=r(t,"width",512),a=r(t,"height",512),h=r(t,"key",""),l=r(t,"frame",""),u=new o(this.scene,e,i,s,a,h,l);return n(this.scene,u,t),u})},function(t,e,i){var n=i(13),s=i(10),r=i(77);n.register("zone",function(t){var e=s(t,"x",0),i=s(t,"y",0),n=s(t,"width",1),o=s(t,"height",n);return new r(this.scene,e,i,n,o)})},function(t,e,i){var n=i(3),s=i(3);n=i(658),s=i(659),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchMesh(e,s)}},function(t,e){t.exports=function(){}},function(t,e,i){var n=i(88);i(9).register("mesh",function(t,e,i,s,r,o,a,h){return this.displayList.add(new n(this.scene,t,e,i,s,r,o,a,h))})},function(t,e,i){var n=i(144);i(9).register("quad",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(20),s=i(13),r=i(10),o=i(4),a=i(88);s.register("mesh",function(t){var e=r(t,"key",null),i=r(t,"frame",null),s=o(t,"vertices",[]),h=o(t,"colors",[]),l=o(t,"alphas",[]),u=o(t,"uv",[]),c=new a(this.scene,0,0,s,u,h,l,e,i);return n(this.scene,c,t),c})},function(t,e,i){var n=i(20),s=i(13),r=i(10),o=i(144);s.register("quad",function(t){var e=r(t,"x",0),i=r(t,"y",0),s=r(t,"key",null),a=r(t,"frame",null),h=new o(this.scene,e,i,s,a);return n(this.scene,h,t),h})},function(t,e,i){var n=i(0),s=i(293),r=i(12),o=new n({Extends:s,initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),s.call(this)},boot:function(){var t=this.systems.events;t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},destroy:function(){this.shutdown(),this.scene=void 0,this.systems=void 0}});r.register("LightsPlugin",o,"lights"),t.exports=o},function(t,e,i){var n=i(64);n.Area=i(666),n.Circumference=i(186),n.CircumferencePoint=i(105),n.Clone=i(667),n.Contains=i(32),n.ContainsPoint=i(668),n.ContainsRect=i(669),n.CopyFrom=i(670),n.Equals=i(671),n.GetBounds=i(672),n.GetPoint=i(184),n.GetPoints=i(185),n.Offset=i(673),n.OffsetPoint=i(674),n.Random=i(106),t.exports=n},function(t,e){t.exports=function(t){return t.radius>0?Math.PI*t.radius*t.radius:0}},function(t,e,i){var n=i(64);t.exports=function(t){return new n(t.x,t.y,t.radius)}},function(t,e,i){var n=i(32);t.exports=function(t,e){return n(t,e.x,e.y)}},function(t,e,i){var n=i(32);t.exports=function(t,e){return n(t,e.x,e.y)&&n(t,e.right,e.y)&&n(t,e.x,e.bottom)&&n(t,e.right,e.bottom)}},function(t,e){t.exports=function(t,e){return e.setTo(t.x,t.y,t.radius)}},function(t,e){t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.radius===e.radius}},function(t,e,i){var n=i(8);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.left,e.y=t.top,e.width=t.diameter,e.height=t.diameter,e}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e,i){var n=i(42);t.exports=function(t,e){return n(t.x,t.y,e.x,e.y)<=t.radius+e.radius}},function(t,e){t.exports=function(t,e){var i=e.width/2,n=e.height/2,s=Math.abs(t.x-e.x-i),r=Math.abs(t.y-e.y-n),o=i+t.radius,a=n+t.radius;if(s>o||r>a)return!1;if(s<=i||r<=n)return!0;var h=s-i,l=r-n;return h*h+l*l<=t.radius*t.radius}},function(t,e,i){var n=i(8),s=i(296);t.exports=function(t,e,i){return void 0===i&&(i=new n),s(t,e)&&(i.x=Math.max(t.x,e.x),i.y=Math.max(t.y,e.y),i.width=Math.min(t.right,e.right)-i.x,i.height=Math.min(t.bottom,e.bottom)-i.y),i}},function(t,e){t.exports=function(t,e){var i=t.x1,n=t.y1,s=t.x2,r=t.y2,o=e.x,a=e.y,h=e.right,l=e.bottom,u=0;if(i>=o&&i<=h&&n>=a&&n<=l||s>=o&&s<=h&&r>=a&&r<=l)return!0;if(i=o){if((u=n+(r-n)*(o-i)/(s-i))>a&&u<=l)return!0}else if(i>h&&s<=h&&(u=n+(r-n)*(h-i)/(s-i))>=a&&u<=l)return!0;if(n=a){if((u=i+(s-i)*(a-n)/(r-n))>=o&&u<=h)return!0}else if(n>l&&r<=l&&(u=i+(s-i)*(l-n)/(r-n))>=o&&u<=h)return!0;return!1}},function(t,e,i){var n=i(298);t.exports=function(t,e){if(!n(t,e))return!1;var i=Math.min(e.x1,e.x2),s=Math.max(e.x1,e.x2),r=Math.min(e.y1,e.y2),o=Math.max(e.y1,e.y2);return t.x>=i&&t.x<=s&&t.y>=r&&t.y<=o}},function(t,e,i){var n=i(89),s=i(33),r=i(145),o=i(299);t.exports=function(t,e){if(e.left>t.right||e.rightt.bottom||e.bottom0}},function(t,e){t.exports=function(t,e,i,n,s,r){return void 0===r&&(r=0),!(e>t.right+r||it.bottom+r||se.right||t.righte.bottom||t.bottome.right||t.righte.bottom||t.bottom0||(c=s(e),(d=n(t,c,!0)).length>0)}},function(t,e,i){var n=i(301);n.Angle=i(55),n.BresenhamPoints=i(194),n.CenterOn=i(686),n.Clone=i(687),n.CopyFrom=i(688),n.Equals=i(689),n.GetMidPoint=i(690),n.GetNormal=i(691),n.GetPoint=i(302),n.GetPoints=i(109),n.Height=i(692),n.Length=i(66),n.NormalAngle=i(303),n.NormalX=i(693),n.NormalY=i(694),n.Offset=i(695),n.PerpSlope=i(696),n.Random=i(111),n.ReflectAngle=i(697),n.Rotate=i(698),n.RotateAroundPoint=i(699),n.RotateAroundXY=i(146),n.SetToAngle=i(700),n.Slope=i(701),n.Width=i(702),t.exports=n},function(t,e){t.exports=function(t,e,i){var n=e-(t.x1+t.x2)/2,s=i-(t.y1+t.y2)/2;return t.x1+=n,t.y1+=s,t.x2+=n,t.y2+=s,t}},function(t,e,i){var n=i(301);t.exports=function(t){return new n(t.x1,t.y1,t.x2,t.y2)}},function(t,e){t.exports=function(t,e){return e.setTo(t.x1,t.y1,t.x2,t.y2)}},function(t,e){t.exports=function(t,e){return t.x1===e.x1&&t.y1===e.y1&&t.x2===e.x2&&t.y2===e.y2}},function(t,e,i){var n=i(5);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=(t.x1+t.x2)/2,e.y=(t.y1+t.y2)/2,e}},function(t,e,i){var n=i(16),s=i(55),r=i(5);t.exports=function(t,e){void 0===e&&(e=new r);var i=s(t)-n.TAU;return e.x=Math.cos(i),e.y=Math.sin(i),e}},function(t,e){t.exports=function(t){return Math.abs(t.y1-t.y2)}},function(t,e,i){var n=i(16),s=i(55);t.exports=function(t){return Math.cos(s(t)-n.TAU)}},function(t,e,i){var n=i(16),s=i(55);t.exports=function(t){return Math.sin(s(t)-n.TAU)}},function(t,e){t.exports=function(t,e,i){return t.x1+=e,t.y1+=i,t.x2+=e,t.y2+=i,t}},function(t,e){t.exports=function(t){return-(t.x2-t.x1)/(t.y2-t.y1)}},function(t,e,i){var n=i(55),s=i(303);t.exports=function(t,e){return 2*s(e)-Math.PI-n(t)}},function(t,e,i){var n=i(146);t.exports=function(t,e){var i=(t.x1+t.x2)/2,s=(t.y1+t.y2)/2;return n(t,i,s,e)}},function(t,e,i){var n=i(146);t.exports=function(t,e,i){return n(t,e.x,e.y,i)}},function(t,e){t.exports=function(t,e,i,n,s){return t.x1=e,t.y1=i,t.x2=e+Math.cos(n)*s,t.y2=i+Math.sin(n)*s,t}},function(t,e){t.exports=function(t){return(t.y2-t.y1)/(t.x2-t.x1)}},function(t,e){t.exports=function(t){return Math.abs(t.x1-t.x2)}},function(t,e,i){var n=i(5);n.Ceil=i(704),n.Clone=i(705),n.CopyFrom=i(706),n.Equals=i(707),n.Floor=i(708),n.GetCentroid=i(709),n.GetMagnitude=i(304),n.GetMagnitudeSq=i(305),n.GetRectangleFromPoints=i(710),n.Interpolate=i(711),n.Invert=i(712),n.Negative=i(713),n.Project=i(714),n.ProjectUnit=i(715),n.SetMagnitude=i(716),t.exports=n},function(t,e){t.exports=function(t){return t.setTo(Math.ceil(t.x),Math.ceil(t.y))}},function(t,e,i){var n=i(5);t.exports=function(t){return new n(t.x,t.y)}},function(t,e){t.exports=function(t,e){return e.setTo(t.x,t.y)}},function(t,e){t.exports=function(t,e){return t.x===e.x&&t.y===e.y}},function(t,e){t.exports=function(t){return t.setTo(Math.floor(t.x),Math.floor(t.y))}},function(t,e,i){var n=i(5);t.exports=function(t,e){if(void 0===e&&(e=new n),!Array.isArray(t))throw new Error("GetCentroid points argument must be an array");var i=t.length;if(i<1)throw new Error("GetCentroid points array must not be empty");if(1===i)e.x=t[0].x,e.y=t[0].y;else{for(var s=0;si&&(i=h.x),h.xr&&(r=h.y),h.yt.width*t.height)&&e.x>t.x&&e.xt.x&&e.rightt.y&&e.yt.y&&e.bottomn(e)?t.setSize(e.height*i,e.height):t.setSize(e.width,e.width/i),t.setPosition(e.centerX-t.width/2,e.centerY-t.height/2)}},function(t,e){t.exports=function(t){return t.x=Math.floor(t.x),t.y=Math.floor(t.y),t}},function(t,e){t.exports=function(t){return t.x=Math.floor(t.x),t.y=Math.floor(t.y),t.width=Math.floor(t.width),t.height=Math.floor(t.height),t}},function(t,e,i){var n=i(5);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.centerX,e.y=t.centerY,e}},function(t,e,i){var n=i(5);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.width,e.y=t.height,e}},function(t,e,i){var n=i(308);t.exports=function(t,e,i){var s=t.centerX,r=t.centerY;return t.setSize(t.width+2*e,t.height+2*i),n(t,s,r)}},function(t,e){t.exports=function(t,e){for(var i=t.x,n=t.right,s=t.y,r=t.bottom,o=0;oe.x&&t.ye.y}},function(t,e,i){var n=i(5),s=i(35);t.exports=function(t,e,i){void 0===i&&(i=new n),e=s(e);var r=Math.sin(e),o=Math.cos(e),a=o>0?t.width/2:t.width/-2,h=r>0?t.height/2:t.height/-2;return Math.abs(a*r)-1&&(s.splice(a,1),this.clear(o))}t.length=0,this._list=s.concat(e.splice(0))}},clear:function(t){var e=t.input;e.gameObject=void 0,e.target=void 0,e.hitArea=void 0,e.hitAreaCallback=void 0,e.callbackContext=void 0,t.input=null;var i=this._draggable.indexOf(t);return i>-1&&this._draggable.splice(i,1),(i=this._drag[0].indexOf(t))>-1&&this._drag[0].splice(i,1),(i=this._over[0].indexOf(t))>-1&&this._over[0].splice(i,1),t},disable:function(t){t.input.enabled=!1},enable:function(t,e,i,n){return void 0===n&&(n=!1),t.input?t.input.enabled=!0:this.setHitArea(t,e,i),t.input.dropZone=n,this},hitTestPointer:function(t){var e=this.cameras.getCameraBelowPointer(t);if(e){t.camera=e;for(var i=this.manager.hitTest(t.x,t.y,this._list,e),n=0;n0?t.dragState=1:t.dragState>0&&!t.primaryDown&&t.justUp&&(t.dragState=5),1===t.dragState){var h=[];for(i=0;i1&&(this.sortGameObjects(h),this.topOnly&&h.splice(1)),this._drag[t.id]=h,0===this.dragDistanceThreshold&&0===this.dragTimeThreshold?t.dragState=3:t.dragState=2}if(2===t.dragState&&(this.dragDistanceThreshold>0&&o(t.x,t.y,t.downX,t.downY)>=this.dragDistanceThreshold&&(t.dragState=3),this.dragTimeThreshold>0&&e>=t.downTime+this.dragTimeThreshold&&(t.dragState=3)),3===t.dragState){for(s=this._drag[t.id],i=0;i0?(n.emit("dragleave",t,r.target),this.emit("dragleave",t,n,r.target),r.target=l[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target)):(n.emit("dragleave",t,r.target),this.emit("dragleave",t,n,r.target),l[0]?(r.target=l[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target)):r.target=null)}else!r.target&&l[0]&&(r.target=l[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target));var c=t.x-n.input.dragX,d=t.y-n.input.dragY;n.emit("drag",t,c,d),this.emit("drag",t,n,c,d)}}if(5===t.dragState){for(s=this._drag[t.id],i=0;i0},processMoveEvents:function(t){var e=this._temp;this.emit("pointermove",t,e);for(var i=0,n=0;n0)for(this.sortGameObjects(s),this.emit("pointerout",t,s),e=0;e0)for(this.sortGameObjects(r),this.emit("pointerover",t,r),e=0;e-1&&this._draggable.splice(s,1)}return this},setHitArea:function(t,e,i){if(void 0===e)return this.setHitAreaFromTexture(t);Array.isArray(t)||(t=[t]);for(var n=0;nn?-1:0},sortHandlerIO:function(t,e){var i=this.displayList.getIndex(t.gameObject),n=this.displayList.getIndex(e.gameObject);return in?-1:0},sortInteractiveObjects:function(t){return t.length<2?t:(this.scene.sys.depthSort(),t.sort(this.sortHandlerIO.bind(this)))},stopPropagation:function(){return this.manager.globalTopOnly&&(this.manager.ignoreEvents=!0),this},update:function(t,e){var i=this.manager;if(!i.globalTopOnly||!i.ignoreEvents){var n=i.activePointer,s=n.dirty||0===this.pollRate;if(this.pollRate>-1&&(this._pollTimer-=e,this._pollTimer<0&&(s=!0,this._pollTimer=this.pollRate)),s){this._tempZones=[],this._temp=this.hitTestPointer(n),this.sortGameObjects(this._temp),this.sortGameObjects(this._tempZones),this.topOnly&&(this._temp.length&&this._temp.splice(1),this._tempZones.length&&this._tempZones.splice(1));var r=this.processDragEvents(n,t);n.wasTouch||(r+=this.processOverOutEvents(n)),n.justDown&&(r+=this.processDownEvents(n)),n.justUp&&(r+=this.processUpEvents(n)),n.justMoved&&(r+=this.processMoveEvents(n)),r>0&&i.globalTopOnly&&(i.ignoreEvents=!0)}}},shutdown:function(){this._temp.length=0,this._list.length=0,this._draggable.length=0,this._pendingRemoval.length=0,this._pendingInsertion.length=0;for(var t=0;t<10;t++)this._drag[t]=[],this._over[t]=[];this.removeAllListeners()},destroy:function(){this.shutdown(),this.scene=void 0,this.cameras=void 0,this.manager=void 0,this.events=void 0,this.keyboard=void 0,this.mouse=void 0,this.gamepad=void 0},activePointer:{get:function(){return this.manager.activePointer}},x:{get:function(){return this.manager.activePointer.x}},y:{get:function(){return this.manager.activePointer.y}}});c.register("InputPlugin",v,"input"),t.exports=v},function(t,e,i){t.exports={KeyboardManager:i(245),Key:i(246),KeyCodes:i(129),KeyCombo:i(247),JustDown:i(769),JustUp:i(770),DownDuration:i(771),UpDuration:i(772)}},function(t,e){t.exports=function(t){var e=!1;return t.isDown&&(e=t._justDown,t._justDown=!1),e}},function(t,e){t.exports=function(t){var e=!1;return t.isDown&&(e=t._justUp,t._justUp=!1),e}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=50),t.isDown&&t.duration'),n.push(''),n.push(''),n.push(this.xhrLoader.responseText),n.push(""),n.push(""),n.push("");var o=[n.join("\n")],a=this;try{var h=new window.Blob(o,{type:"image/svg+xml;charset=utf-8"})}catch(e){return a.state=s.FILE_ERRORED,void t(a)}this.data=new Image,this.data.crossOrigin=this.crossOrigin,this.data.onload=function(){r.revokeObjectURL(a.data),a.onComplete(),t(a)},this.data.onerror=function(){r.revokeObjectURL(a.data),a.state=s.FILE_ERRORED,t(a)},r.createObjectURL(this.data,h,"image/svg+xml")}});o.register("html",function(t,e,i,n,s){if(Array.isArray(t))for(var r=0;r0?this.processLoadQueue():0===this.inflight.size&&this.finishedLoading()},finishedLoading:function(){this.state!==s.LOADER_PROCESSING&&(this.progress=1,this.state=s.LOADER_PROCESSING,this.storage.clear(),0===this.queue.size?this.processComplete():this.queue.each(function(t){t.onProcess(this.processUpdate.bind(this))},this))},processUpdate:function(t){if(t.state===s.FILE_ERRORED)return this.failed.set(t),t.linkFile&&this.queue.delete(t.linkFile),this.removeFromQueue(t);t.linkFile?t.state===s.FILE_COMPLETE&&t.linkFile.state===s.FILE_COMPLETE&&(this.storage.set({type:t.linkType,fileA:t,fileB:t.linkFile}),this.queue.delete(t.linkFile),this.removeFromQueue(t)):(this.storage.set(t),this.removeFromQueue(t))},removeFromQueue:function(t){this.queue.delete(t),0===this.queue.size&&this.state===s.LOADER_PROCESSING&&this.processComplete()},processComplete:function(){this.list.clear(),this.inflight.clear(),this.queue.clear(),this.processCallback(),this.state=s.LOADER_COMPLETE,this.emit("complete",this,this.storage.size,this.failed.size)},processCallback:function(){if(0!==this.storage.size){var t,e,i,n=this.scene.sys.cache,s=this.scene.sys.textures,r=this.scene.sys.anims;for(var o in this._multilist){for(var a=[],h=[],u=this._multilist[o],c=0;c0},file:function(t){var e,i=t.key;switch(t.type){case"spritesheet":e=this.spritesheet(i,t.url,t.config,t.xhrSettings);break;case"atlas":e=this.atlas(i,t.textureURL,t.atlasURL,t.textureXhrSettings,t.atlasXhrSettings);break;case"bitmapFont":e=this.bitmapFont(i,t.textureURL,t.xmlURL,t.textureXhrSettings,t.xmlXhrSettings);break;case"multiatlas":e=this.multiatlas(i,t.textureURLs,t.atlasURLs,t.textureXhrSettings,t.atlasXhrSettings);break;case"audioSprite":e=this.audioSprite(i,t.urls,t.json,t.config,t.audioXhrSettings,t.jsonXhrSettings);break;default:e=this[t.type](i,t.url,t.xhrSettings)}return e},shutdown:function(){this.reset(),this.state=s.LOADER_SHUTDOWN},destroy:function(){this.reset(),this.state=s.LOADER_DESTROYED}});u.register("Loader",d,"load"),t.exports=d},function(t,e,i){var n=i(16),s=i(23),r={Angle:i(794),Distance:i(802),Easing:i(805),Fuzzy:i(806),Interpolation:i(812),Pow2:i(816),Snap:i(818),Average:i(822),Bernstein:i(322),Between:i(231),CatmullRom:i(123),CeilTo:i(823),Clamp:i(61),DegToRad:i(35),Difference:i(824),Factorial:i(323),FloatBetween:i(276),FloorTo:i(825),FromPercent:i(65),GetSpeed:i(826),IsEven:i(827),IsEvenStrict:i(828),Linear:i(124),MaxAdd:i(829),MinSub:i(830),Percent:i(831),RadToDeg:i(221),RandomXY:i(832),RandomXYZ:i(209),RandomXYZW:i(210),Rotate:i(324),RotateAround:i(188),RotateAroundDistance:i(113),RoundAwayFromZero:i(325),RoundTo:i(833),SinCosTableGenerator:i(834),SmootherStep:i(195),SmoothStep:i(196),TransformXY:i(251),Within:i(835),Wrap:i(50),Vector2:i(6),Vector3:i(51),Vector4:i(120),Matrix3:i(213),Matrix4:i(119),Quaternion:i(212),RotateVec3:i(211)};r=s(!1,r,n),t.exports=r},function(t,e,i){t.exports={Between:i(795),BetweenY:i(796),BetweenPoints:i(797),BetweenPointsY:i(798),Reverse:i(799),RotateTo:i(800),ShortestBetween:i(801),Normalize:i(321),Wrap:i(163),WrapDegrees:i(164)}},function(t,e){t.exports=function(t,e,i,n){return Math.atan2(n-e,i-t)}},function(t,e){t.exports=function(t,e,i,n){return Math.atan2(i-t,n-e)}},function(t,e){t.exports=function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)}},function(t,e){t.exports=function(t,e){return Math.atan2(e.x-t.x,e.y-t.y)}},function(t,e,i){var n=i(321);t.exports=function(t){return n(t+Math.PI)}},function(t,e,i){var n=i(16);t.exports=function(t,e,i){return void 0===i&&(i=.05),t===e?t:(Math.abs(e-t)<=i||Math.abs(e-t)>=n.PI2-i?t=e:(Math.abs(e-t)>Math.PI&&(et?t+=i:ee-i}},function(t,e){t.exports=function(t,e,i){return void 0===i&&(i=1e-4),t1?t[i]-(n(s-i,t[i],t[i],t[i-1],t[i-1])-t[i]):n(s-r,t[r?r-1:0],t[r],t[i1?n(t[i],t[i-1],i-s):n(t[r],t[r+1>i?i:r+1],s-r)}},function(t,e,i){t.exports={GetNext:i(291),IsSize:i(127),IsValue:i(817)}},function(t,e){t.exports=function(t){return t>0&&0==(t&t-1)}},function(t,e,i){t.exports={Ceil:i(819),Floor:i(820),To:i(821)}},function(t,e){t.exports=function(t,e,i){return void 0===i&&(i=0),0===e?t:(t-=i,i+(t=e*Math.ceil(t/e)))}},function(t,e){t.exports=function(t,e,i){return void 0===i&&(i=0),0===e?t:(t-=i,i+(t=e*Math.floor(t/e)))}},function(t,e){t.exports=function(t,e,i){return void 0===i&&(i=0),0===e?t:(t-=i,i+(t=e*Math.round(t/e)))}},function(t,e){t.exports=function(t){for(var e=0,i=0;i1?void 0!==n?(s=(n-t)/(n-i))<0&&(s=0):s=1:s<0&&(s=0),s}},function(t,e){t.exports=function(t,e){void 0===e&&(e=1);var i=2*Math.random()*Math.PI;return t.x=Math.cos(i)*e,t.y=Math.sin(i)*e,t}},function(t,e){t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var n=Math.pow(i,-e);return Math.round(t*n)/n}},function(t,e){t.exports=function(t,e,i,n){void 0===e&&(e=1),void 0===i&&(i=1),void 0===n&&(n=1),n*=Math.PI/t;for(var s=[],r=[],o=0;o=0;o--){var a=e[o],h=l(s,r,a.x,a.y);h=0;o--){var a=e[o],h=l(s,r,a.x,a.y);h>i&&(n=a,i=h)}return n},moveTo:function(t,e,i,n,s){void 0===n&&(n=60),void 0===s&&(s=0);var r=Math.atan2(i-t.y,e-t.x);return s>0&&(n=l(t.x,t.y,e,i)/(s/1e3)),t.body.velocity.setToPolar(r,n),r},moveToObject:function(t,e,i,n){return this.moveTo(t,e.x,e.y,i,n)},velocityFromAngle:function(t,e,i){return void 0===e&&(e=60),i.setToPolar(u(t),e)},velocityFromRotation:function(t,e,i){return void 0===e&&(e=60),i.setToPolar(t,e)},shutdown:function(){this.world.shutdown()},destroy:function(){this.world.destroy()}});a.register("ArcadePhysics",c,"arcadePhysics"),t.exports=c},function(t,e){t.exports={setAcceleration:function(t,e){return this.body.acceleration.set(t,e),this},setAccelerationX:function(t){return this.body.acceleration.x=t,this},setAccelerationY:function(t){return this.body.acceleration.y=t,this}}},function(t,e){t.exports={setAngularVelocity:function(t){return this.body.angularVelocity=t,this},setAngularAcceleration:function(t){return this.body.angularAcceleration=t,this},setAngularDrag:function(t){return this.body.angularDrag=t,this}}},function(t,e){t.exports={setBounce:function(t,e){return this.body.bounce.set(t,e),this},setBounceX:function(t){return this.body.bounce.x=t,this},setBounceY:function(t){return this.body.bounce.y=t,this},setCollideWorldBounds:function(t){return this.body.collideWorldBounds=t,this}}},function(t,e){t.exports={setDebug:function(t,e,i){return this.debugShowBody=t,this.debugShowVelocity=e,this.debugBodyColor=i,this},setDebugBodyColor:function(t){return this.body.debugBodyColor=t,this},debugShowBody:{get:function(){return this.body.debugShowBody},set:function(t){this.body.debugShowBody=t}},debugShowVelocity:{get:function(){return this.body.debugShowVelocity},set:function(t){this.body.debugShowVelocity=t}},debugBodyColor:{get:function(){return this.body.debugBodyColor},set:function(t){this.body.debugBodyColor=t}}}},function(t,e){t.exports={setDrag:function(t,e){return this.body.drag.set(t,e),this},setDragX:function(t){return this.body.drag.x=t,this},setDragY:function(t){return this.body.drag.y=t,this}}},function(t,e){var i={enableBody:function(t,e,i,n,s){return t&&this.body.reset(e,i),n&&(this.body.gameObject.active=!0),s&&(this.body.gameObject.visible=!0),this.body.enable=!0,this},disableBody:function(t,e){return void 0===t&&(t=!1),void 0===e&&(e=!1),this.body.stop(),this.body.enable=!1,t&&(this.body.gameObject.active=!1),e&&(this.body.gameObject.visible=!1),this},refreshBody:function(){return this.body.updateFromGameObject(),this}};t.exports=i},function(t,e){t.exports={setFriction:function(t,e){return this.body.friction.set(t,e),this},setFrictionX:function(t){return this.body.friction.x=t,this},setFrictionY:function(t){return this.body.friction.y=t,this}}},function(t,e){t.exports={setGravity:function(t,e){return this.body.gravity.set(t,e),this},setGravityX:function(t){return this.body.gravity.x=t,this},setGravityY:function(t){return this.body.gravity.y=t,this}}},function(t,e){var i={setImmovable:function(t){return void 0===t&&(t=!0),this.body.immovable=t,this}};t.exports=i},function(t,e){t.exports={setMass:function(t){return this.body.mass=t,this}}},function(t,e){t.exports={setOffset:function(t,e){return this.body.setOffset(t,e),this},setSize:function(t,e,i){return this.body.setSize(t,e,i),this},setCircle:function(t,e,i){return this.body.setCircle(t,e,i),this}}},function(t,e){var i={setVelocity:function(t,e){return this.body.velocity.set(t,e),this},setVelocityX:function(t){return this.body.velocity.x=t,this},setVelocityY:function(t){return this.body.velocity.y=t,this},setMaxVelocity:function(t,e){return void 0===e&&(e=t),this.body.maxVelocity.set(t,e),this}};t.exports=i},function(t,e){t.exports=function(t,e){return t.collisionCallback?!t.collisionCallback.call(t.collisionCallbackContext,e,t):!t.layer.callbacks[t.index]||!t.layer.callbacks[t.index].callback.call(t.layer.callbacks[t.index].callbackContext,e,t)}},function(t,e,i){var n=i(852),s=i(854),r=i(339);t.exports=function(t,e,i,o,a,h){var l=o.left,u=o.top,c=o.right,d=o.bottom,f=i.faceLeft||i.faceRight,p=i.faceTop||i.faceBottom;if(!f&&!p)return!1;var g=0,v=0,y=0,m=1;if(e.deltaAbsX()>e.deltaAbsY()?y=-1:e.deltaAbsX()0&&!t.blocked.right&&e.collideLeft&&t.checkCollision.right&&e.faceLeft&&t.right>i&&(o=t.right-i)>r&&(o=0),0!==o&&(t.customSeparateX?t.overlapX=o:n(t,o)),o}},function(t,e){t.exports=function(t,e){e<0?t.blocked.left=!0:e>0&&(t.blocked.right=!0),t.position.x-=e,0===t.bounce.x?t.velocity.x=0:t.velocity.x=-t.velocity.x*t.bounce.x}},function(t,e,i){var n=i(855);t.exports=function(t,e,i,s,r){var o=0;return t.deltaY()<0&&!t.blocked.up&&e.collideDown&&t.checkCollision.up?e.faceBottom&&t.y0&&!t.blocked.down&&e.collideUp&&t.checkCollision.down&&e.faceTop&&t.bottom>i&&(o=t.bottom-i)>r&&(o=0),0!==o&&(t.customSeparateY?t.overlapY=o:n(t,o)),o}},function(t,e){t.exports=function(t,e){e<0?t.blocked.up=!0:e>0&&(t.blocked.down=!0),t.position.y-=e,0===t.bounce.y?t.velocity.y=0:t.velocity.y=-t.velocity.y*t.bounce.y}},function(t,e,i){var n=i(334);t.exports=function(t,e,i,s){var r=n(t,e,i,s);if(i||0===r||t.immovable&&e.immovable||t.customSeparateX||e.customSeparateX)return 0!==r||t.embedded&&e.embedded;var o=t.velocity.x,a=e.velocity.x;if(t.immovable||e.immovable)t.immovable?(e.x+=r,e.velocity.x=o-a*e.bounce.x,t.moves&&(e.y+=(t.y-t.prev.y)*t.friction.y)):(t.x-=r,t.velocity.x=a-o*t.bounce.x,e.moves&&(t.y+=(e.y-e.prev.y)*e.friction.y));else{r*=.5,t.x-=r,e.x+=r;var h=Math.sqrt(a*a*e.mass/t.mass)*(a>0?1:-1),l=Math.sqrt(o*o*t.mass/e.mass)*(o>0?1:-1),u=.5*(h+l);h-=u,l-=u,t.velocity.x=u+h*t.bounce.x,e.velocity.x=u+l*e.bounce.x}return!0}},function(t,e,i){var n=i(335);t.exports=function(t,e,i,s){var r=n(t,e,i,s);if(i||0===r||t.immovable&&e.immovable||t.customSeparateY||e.customSeparateY)return 0!==r||t.embedded&&e.embedded;var o=t.velocity.y,a=e.velocity.y;if(t.immovable||e.immovable)t.immovable?(e.y+=r,e.velocity.y=o-a*e.bounce.y,t.moves&&(e.x+=(t.x-t.prev.x)*t.friction.x)):(t.y-=r,t.velocity.y=a-o*t.bounce.y,e.moves&&(t.x+=(e.x-e.prev.x)*e.friction.x));else{r*=.5,t.y-=r,e.y+=r;var h=Math.sqrt(a*a*e.mass/t.mass)*(a>0?1:-1),l=Math.sqrt(o*o*t.mass/e.mass)*(o>0?1:-1),u=.5*(h+l);h-=u,l-=u,t.velocity.y=u+h*t.bounce.y,e.velocity.y=u+l*e.bounce.y}return!0}},function(t,e,i){t.exports={Acceleration:i(964),BodyScale:i(965),BodyType:i(966),Bounce:i(967),CheckAgainst:i(968),Collides:i(969),Debug:i(970),Friction:i(971),Gravity:i(972),Offset:i(973),SetGameObject:i(974),Velocity:i(975)}},function(t,e,i){var n={};t.exports=n;var s=i(94),r=i(38);n.fromVertices=function(t){for(var e={},i=0;i0?this.setFromTileCollision(i):this.setFromTileRectangle(i)}},setFromTileRectangle:function(t){void 0===t&&(t={}),h(t,"isStatic")||(t.isStatic=!0),h(t,"addToWorld")||(t.addToWorld=!0);var e=this.tile.getBounds(),i=e.x+e.width/2,s=e.y+e.height/2,r=n.rectangle(i,s,e.width,e.height,t);return this.setBody(r,t.addToWorld),this},setFromTileCollision:function(t){void 0===t&&(t={}),h(t,"isStatic")||(t.isStatic=!0),h(t,"addToWorld")||(t.addToWorld=!0);for(var e=this.tile.tilemapLayer.scaleX,i=this.tile.tilemapLayer.scaleY,r=this.tile.getLeft(),o=this.tile.getTop(),u=this.tile.getCollisionGroup(),c=a(u,"objects",[]),d=[],f=0;f1&&(t.parts=d,this.setBody(s.create(t),t.addToWorld)),this},setBody:function(t,e){return void 0===e&&(e=!0),this.body&&this.removeBody(),this.body=t,this.body.gameObject=this,e&&this.world.add(this.body),this},removeBody:function(){return this.body&&(this.world.remove(this.body),this.body.gameObject=void 0,this.body=void 0),this},destroy:function(){this.removeBody(),this.tile.physics.matterBody=void 0}});t.exports=u},function(t,e,i){var n={};t.exports=n;var s=i(863),r=i(375),o=i(95);n.collisions=function(t,e){for(var i=[],a=e.pairs.table,h=e.metrics,l=0;l1?1:0;d1?1:0;p0:0!=(t.mask&e.category)&&0!=(e.mask&t.category)}},function(t,e,i){var n={};t.exports=n;var s=i(93),r=i(94);!function(){n.collides=function(e,n,o){var a,h,l,u,c=!1;if(o){var d=e.parent,f=n.parent,p=d.speed*d.speed+d.angularSpeed*d.angularSpeed+f.speed*f.speed+f.angularSpeed*f.angularSpeed;c=o&&o.collided&&p<.2,u=o}else u={collided:!1,bodyA:e,bodyB:n};if(o&&c){var g=u.axisBody,v=g===e?n:e,y=[g.axes[o.axisNumber]];if(l=t(g.vertices,v.vertices,y),u.reused=!0,l.overlap<=0)return u.collided=!1,u}else{if((a=t(e.vertices,n.vertices,e.axes)).overlap<=0)return u.collided=!1,u;if((h=t(n.vertices,e.vertices,n.axes)).overlap<=0)return u.collided=!1,u;a.overlaps?s=a:a=0?o.index-1:u.length-1],l.x=s.x-c.x,l.y=s.y-c.y,h=-r.dot(i,l),a=s,s=u[(o.index+1)%u.length],l.x=s.x-c.x,l.y=s.y-c.y,(n=-r.dot(i,l))r?(s.warn("Plugin.register:",n.toString(e),"was upgraded to",n.toString(t)),n._registry[t.name]=t):i-1},n.isFor=function(t,e){var i=t.for&&n.dependencyParse(t.for);return!t.for||e.name===i.name&&n.versionSatisfies(e.version,i.range)},n.use=function(t,e){if(t.uses=(t.uses||[]).concat(e||[]),0!==t.uses.length){for(var i=n.dependencies(t),r=s.topologicalSort(i),o=[],a=0;a0&&!h.silent&&s.info(o.join(" "))}else s.warn("Plugin.use:",n.toString(t),"does not specify any dependencies to install.")},n.dependencies=function(t,e){var i=n.dependencyParse(t),r=i.name;if(!(r in(e=e||{}))){t=n.resolve(t)||t,e[r]=s.map(t.uses||[],function(e){n.isPlugin(e)&&n.register(e);var r=n.dependencyParse(e),o=n.resolve(e);return o&&!n.versionSatisfies(o.version,r.range)?(s.warn("Plugin.dependencies:",n.toString(o),"does not satisfy",n.toString(r),"used by",n.toString(i)+"."),o._warned=!0,t._warned=!0):o||(s.warn("Plugin.dependencies:",n.toString(e),"used by",n.toString(i),"could not be resolved."),t._warned=!0),r.name});for(var o=0;o=s[2];if("^"===i.operator)return s[0]>0?o[0]===s[0]&&r.number>=i.number:s[1]>0?o[1]===s[1]&&o[2]>=s[2]:o[2]===s[2]}return t===e||"*"===t}},function(t,e,i){var n={};t.exports=n;var s=i(152),r=(i(168),i(38));n.create=function(t){var e=s.create(),i={label:"World",gravity:{x:0,y:1,scale:.001},bounds:{min:{x:-1/0,y:-1/0},max:{x:1/0,y:1/0}}};return r.extend(e,i,t)}},function(t,e,i){t.exports={SceneManager:i(252),ScenePlugin:i(868),Settings:i(255),Systems:i(130)}},function(t,e,i){var n=i(0),s=i(83),r=i(12),o=new n({initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),this.settings=t.sys.settings,this.key=t.sys.settings.key,this.manager=t.sys.game.scene},boot:function(){var t=this.systems.events;t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},start:function(t,e){return void 0===t&&(t=this.key),this.settings.status!==s.RUNNING?(this.manager.queueOp("stop",this.key),this.manager.queueOp("start",t)):(this.manager.stop(this.key),this.manager.start(t,e)),this},add:function(t,e,i){return this.manager.add(t,e,i),this},launch:function(t,e){return t&&t!==this.key&&(this.settings.status!==s.RUNNING?this.manager.queueOp("start",t,e):this.manager.start(t,e)),this},pause:function(t){return void 0===t&&(t=this.key),this.manager.pause(t),this},resume:function(t){return void 0===t&&(t=this.key),this.manager.resume(t),this},sleep:function(t){return void 0===t&&(t=this.key),this.manager.sleep(t),this},wake:function(t){return void 0===t&&(t=this.key),this.manager.wake(t),this},switch:function(t){return t!==this.key&&(this.settings.status!==s.RUNNING?this.manager.queueOp("switch",this.key,t):this.manager.switch(this.key,t)),this},stop:function(t){return void 0===t&&(t=this.key),this.manager.stop(t),this},setActive:function(t){return this.settings.active=t,this},setVisible:function(t){return this.settings.visible=t,this},isSleeping:function(t){return void 0===t&&(t=this.key),this.manager.isSleeping(t)},isActive:function(t){return void 0===t&&(t=this.key),this.manager.isActive(t)},isVisible:function(t){return void 0===t&&(t=this.key),this.manager.isVisible(t)},swapPosition:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.swapPosition(t,e),this},moveAbove:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.moveAbove(t,e),this},moveBelow:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.moveBelow(t,e),this},remove:function(t){return void 0===t&&(t=this.key),this.manager.remove(t),this},moveUp:function(t){return void 0===t&&(t=this.key),this.manager.moveUp(t),this},moveDown:function(t){return void 0===t&&(t=this.key),this.manager.moveDown(t),this},bringToTop:function(t){return void 0===t&&(t=this.key),this.manager.bringToTop(t),this},sendToBack:function(t){return void 0===t&&(t=this.key),this.manager.sendToBack(t),this},get:function(t){return this.manager.getScene(t)},shutdown:function(){},destroy:function(){}});r.register("ScenePlugin",o,"scenePlugin"),t.exports=o},function(t,e,i){t.exports={SoundManagerCreator:i(256),BaseSound:i(85),BaseSoundManager:i(84),WebAudioSound:i(262),WebAudioSoundManager:i(261),HTML5AudioSound:i(258),HTML5AudioSoundManager:i(257),NoAudioSound:i(260),NoAudioSoundManager:i(259)}},function(t,e,i){t.exports={List:i(86),Map:i(114),ProcessQueue:i(336),RTree:i(337),Set:i(62)}},function(t,e,i){t.exports={Parsers:i(264),FilterMode:i(872),Frame:i(131),Texture:i(265),TextureManager:i(263),TextureSource:i(266)}},function(t,e){t.exports={LINEAR:0,NEAREST:1}},function(t,e,i){t.exports={Components:i(96),Parsers:i(903),Formats:i(22),ImageCollection:i(351),ParseToTilemap:i(157),Tile:i(44),Tilemap:i(355),TilemapCreator:i(920),TilemapFactory:i(921),Tileset:i(100),LayerData:i(75),MapData:i(76),ObjectLayer:i(353),DynamicTilemapLayer:i(356),StaticTilemapLayer:i(357)}},function(t,e,i){var n=i(15),s=i(34);t.exports=function(t,e,i,r,o,a,h,l){t<0&&(t=0),e<0&&(e=0),void 0===h&&(h=!0);for(var u=n(t,e,i,r,null,l),c=o-t,d=a-e,f=0;f=0&&p=0&&g-c&&y>-d&&v=0;r--)for(s=n.width-1;s>=0;s--)if((o=n.data[r][s])&&o.index===t){if(a===e)return o;a+=1}}else for(r=0;re)){for(var h=t;h<=e;h++)r(h,i,a);for(var l=0;l=t&&c.index<=e&&n(c,i)}o&&s(0,0,a.width,a.height,a)}}},function(t,e,i){var n=i(43),s=i(34),r=i(155);t.exports=function(t,e,i,o){void 0===e&&(e=!0),void 0===i&&(i=!0),Array.isArray(t)||(t=[t]);for(var a=0;a0&&n(a,t)}}e&&s(0,0,i.width,i.height,i)}},function(t,e){t.exports=function(t,e,i,n){if("number"==typeof t)n.callbacks[t]=null!==e?{callback:e,callbackContext:i}:void 0;else for(var s=0,r=t.length;s0){var y=new a(u,v.gid,c,f.length,t.tilewidth,t.tileheight);y.rotation=v.rotation,y.flipX=v.flipped,d.push(y)}else{var m=e?null:new a(u,-1,c,f.length,t.tilewidth,t.tileheight);d.push(m)}++c===l.width&&(f.push(d),c=0,d=[])}u.data=f,i.push(u)}}return i}},function(t,e){t.exports=function(t){for(var e=window.atob(t),i=e.length,n=new Array(i),s=0;s>>0;return n}},function(t,e,i){var n=i(2);t.exports=function(t){for(var e=[],i=0;i-1?new s(a,f,c,u,o.tilesize,o.tilesize):e?null:new s(a,-1,c,u,o.tilesize,o.tilesize),h.push(d)}l.push(h),h=[]}a.data=l,i.push(a)}return i}},function(t,e,i){var n=i(100);t.exports=function(t){for(var e=[],i=[],s=0;s0&&e.cameraFilter&s._id||(e.cull(s),this.pipeline.batchDynamicTilemapLayer(e,s))}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){e.cull(s);var r=e.culledTiles,o=r.length,a=e.tileset.image.getSourceImage(),h=this.tileset,l=e.x-s.scrollX*e.scrollFactorX,u=e.y-s.scrollY*e.scrollFactorY,c=t.gameContext;c.save(),c.translate(l,u),c.rotate(e.rotation),c.scale(e.scaleX,e.scaleY),c.scale(e.flipX?-1:1,e.flipY?-1:1);for(var d=0;d0&&e.cameraFilter&s._id||(e.upload(s),this.pipeline.drawStaticTilemapLayer(e,s))}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){e.cull(s);var r=e.culledTiles,o=this.tileset,a=t.gameContext,h=r.length,l=o.image.getSourceImage(),u=e.x-s.scrollX*e.scrollFactorX,c=e.y-s.scrollY*e.scrollFactorY;a.save(),a.translate(u,c),a.rotate(e.rotation),a.scale(e.scaleX,e.scaleY),a.scale(e.flipX?-1:1,e.flipY?-1:1),a.globalAlpha=e.alpha;for(var d=0;d-1&&this._active.splice(s,1),n.destroy()}for(i=0;i=n.delay)){var s=n.elapsed-n.delay;n.elapsed=n.delay,!n.hasDispatched&&n.callback&&(n.hasDispatched=!0,n.callback.apply(n.callbackScope,n.args)),n.repeatCount>0?(n.repeatCount--,n.elapsed=s,n.hasDispatched=!1):this._pendingRemoval.push(n)}}}},shutdown:function(){var t;for(t=0;t=t.pos.x+t.size.x||this.pos.x+this.size.x<=t.pos.x||this.pos.y>=t.pos.y+t.size.y||this.pos.y+this.size.y<=t.pos.y)},resetSize:function(t,e,i,n){return this.pos.x=t,this.pos.y=e,this.size.x=i,this.size.y=n,this},toJSON:function(){return{name:this.name,size:{x:this.size.x,y:this.size.y},pos:{x:this.pos.x,y:this.pos.y},vel:{x:this.vel.x,y:this.vel.y},accel:{x:this.accel.x,y:this.accel.y},friction:{x:this.friction.x,y:this.friction.y},maxVel:{x:this.maxVel.x,y:this.maxVel.y},gravityFactor:this.gravityFactor,bounciness:this.bounciness,minBounceVelocity:this.minBounceVelocity,type:this.type,checkAgainst:this.checkAgainst,collides:this.collides}},fromJSON:function(){},check:function(){},collideWith:function(t,e){this.parent&&this.parent._collideCallback&&this.parent._collideCallback.call(this.parent._callbackScope,this,t,e)},handleMovementTrace:function(){return!0},destroy:function(){this.world.remove(this),this.enabled=!1,this.world=null,this.gameObject=null,this.parent=null}});t.exports=h},function(t,e,i){var n=i(0),s=i(963),r=new n({initialize:function(t,e){void 0===t&&(t=32),this.tilesize=t,this.data=Array.isArray(e)?e:[],this.width=Array.isArray(e)?e[0].length:0,this.height=Array.isArray(e)?e.length:0,this.lastSlope=55,this.tiledef=s},trace:function(t,e,i,n,s,r){var o={collision:{x:!1,y:!1,slope:!1},pos:{x:t+i,y:e+n},tile:{x:0,y:0}};if(!this.data)return o;var a=Math.ceil(Math.max(Math.abs(i),Math.abs(n))/this.tilesize);if(a>1)for(var h=i/a,l=n/a,u=0;u0?r:0,y=n<0?f:0,m=Math.max(Math.floor(i/f),0),x=Math.min(Math.ceil((i+o)/f),g);u=Math.floor((t.pos.x+v)/f);var b=Math.floor((e+v)/f);if((l>0||u===b||b<0||b>=p)&&(b=-1),u>=0&&u1&&d<=this.lastSlope&&this.checkDef(t,d,e,i,a,h,r,o,b,c));c++)if(1===(d=this.data[c][u])||d>this.lastSlope||d>1&&this.checkDef(t,d,e,i,a,h,r,o,u,c)){if(d>1&&d<=this.lastSlope&&t.collision.slope)break;t.collision.x=!0,t.tile.x=d,t.pos.x=u*f-v+y,e=t.pos.x,a=0;break}}if(s){var w=s>0?o:0,T=s<0?f:0,S=Math.max(Math.floor(t.pos.x/f),0),A=Math.min(Math.ceil((t.pos.x+r)/f),p);c=Math.floor((t.pos.y+w)/f);var C=Math.floor((i+w)/f);if((l>0||c===C||C<0||C>=g)&&(C=-1),c>=0&&c1&&d<=this.lastSlope&&this.checkDef(t,d,e,i,a,h,r,o,u,C));u++)if(1===(d=this.data[c][u])||d>this.lastSlope||d>1&&this.checkDef(t,d,e,i,a,h,r,o,u,c)){if(d>1&&d<=this.lastSlope&&t.collision.slope)break;t.collision.y=!0,t.tile.y=d,t.pos.y=c*f-w+T;break}}},checkDef:function(t,e,i,n,s,r,o,a,h,l){var u=this.tiledef[e];if(!u)return!1;var c=this.tilesize,d=(h+u[0])*c,f=(l+u[1])*c,p=(u[2]-u[0])*c,g=(u[3]-u[1])*c,v=u[4],y=i+s+(g<0?o:0)-d,m=n+r+(p>0?a:0)-f;if(p*m-g*y>0){if(s*-g+r*p<0)return v;var x=Math.sqrt(p*p+g*g),b=g/x,w=-p/x,T=y*b+m*w,S=b*T,A=w*T;return S*S+A*A>=s*s+r*r?v||p*(m-r)-g*(y-s)<.5:(t.pos.x=i+s-S,t.pos.y=n+r-A,t.collision.slope={x:p,y:g,nx:b,ny:w},!0)}return!1}});t.exports=r},function(t,e,i){var n=i(0),s=i(943),r=i(944),o=i(945),a=new n({initialize:function(t){this.world=t,this.sys=t.scene.sys},body:function(t,e,i,n){return new s(this.world,t,e,i,n)},existing:function(t){var e=t.x-t.frame.centerX,i=t.y-t.frame.centerY,n=t.width,s=t.height;return t.body=this.world.create(e,i,n,s),t.body.parent=t,t.body.gameObject=t,t},image:function(t,e,i,n){var s=new r(this.world,t,e,i,n);return this.sys.displayList.add(s),s},sprite:function(t,e,i,n){var s=new o(this.world,t,e,i,n);return this.sys.displayList.add(s),this.sys.updateList.add(s),s}});t.exports=a},function(t,e,i){var n=i(0),s=i(858),r=new n({Mixins:[s.Acceleration,s.BodyScale,s.BodyType,s.Bounce,s.CheckAgainst,s.Collides,s.Debug,s.Friction,s.Gravity,s.Offset,s.SetGameObject,s.Velocity],initialize:function(t,e,i,n,s){this.body=t.create(e,i,n,s),this.body.parent=this,this.size=this.body.size,this.offset=this.body.offset,this.vel=this.body.vel,this.accel=this.body.accel,this.friction=this.body.friction,this.maxVel=this.body.maxVel}});t.exports=r},function(t,e,i){var n=i(0),s=i(858),r=i(70),o=new n({Extends:r,Mixins:[s.Acceleration,s.BodyScale,s.BodyType,s.Bounce,s.CheckAgainst,s.Collides,s.Debug,s.Friction,s.Gravity,s.Offset,s.SetGameObject,s.Velocity],initialize:function(t,e,i,n,s){r.call(this,t.scene,e,i,n,s),this.body=t.create(e-this.frame.centerX,i-this.frame.centerY,this.width,this.height),this.body.parent=this,this.body.gameObject=this,this.size=this.body.size,this.offset=this.body.offset,this.vel=this.body.vel,this.accel=this.body.accel,this.friction=this.body.friction,this.maxVel=this.body.maxVel}});t.exports=o},function(t,e,i){var n=i(0),s=i(858),r=i(37),o=new n({Extends:r,Mixins:[s.Acceleration,s.BodyScale,s.BodyType,s.Bounce,s.CheckAgainst,s.Collides,s.Debug,s.Friction,s.Gravity,s.Offset,s.SetGameObject,s.Velocity],initialize:function(t,e,i,n,s){r.call(this,t.scene,e,i,n,s),this.body=t.create(e-this.frame.centerX,i-this.frame.centerY,this.width,this.height),this.body.parent=this,this.body.gameObject=this,this.size=this.body.size,this.offset=this.body.offset,this.vel=this.body.vel,this.accel=this.body.accel,this.friction=this.body.friction,this.maxVel=this.body.maxVel}});t.exports=o},function(t,e,i){var n=i(940),s=i(0),r=i(341),o=i(941),a=i(14),h=i(2),l=i(72),u=i(62),c=i(977),d=i(22),f=i(342),p=new s({Extends:a,initialize:function(t,e){a.call(this),this.scene=t,this.bodies=new u,this.gravity=h(e,"gravity",0),this.cellSize=h(e,"cellSize",64),this.collisionMap=new o,this.timeScale=h(e,"timeScale",1),this.maxStep=h(e,"maxStep",.05),this.enabled=!0,this.drawDebug=h(e,"debug",!1),this.debugGraphic;var i=h(e,"maxVelocity",100);if(this.defaults={debugShowBody:h(e,"debugShowBody",!0),debugShowVelocity:h(e,"debugShowVelocity",!0),bodyDebugColor:h(e,"debugBodyColor",16711935),velocityDebugColor:h(e,"debugVelocityColor",65280),maxVelocityX:h(e,"maxVelocityX",i),maxVelocityY:h(e,"maxVelocityY",i),minBounceVelocity:h(e,"minBounceVelocity",40),gravityFactor:h(e,"gravityFactor",1),bounciness:h(e,"bounciness",0)},this.walls={left:null,right:null,top:null,bottom:null},this.delta=0,this._lastId=0,h(e,"setBounds",!1)){var n=e.setBounds;if("boolean"==typeof n)this.setBounds();else{var s=h(n,"x",0),r=h(n,"y",0),l=h(n,"width",t.sys.game.config.width),c=h(n,"height",t.sys.game.config.height),d=h(n,"thickness",64),f=h(n,"left",!0),p=h(n,"right",!0),g=h(n,"top",!0),v=h(n,"bottom",!0);this.setBounds(s,r,l,c,d,f,p,g,v)}}this.drawDebug&&this.createDebugGraphic()},setCollisionMap:function(t,e){if("string"==typeof t){var i=this.scene.cache.tilemap.get(t);if(!i||i.format!==d.WELTMEISTER)return console.warn("The specified key does not correspond to a Weltmeister tilemap: "+t),null;for(var n,s=i.data.layer,r=0;rr.ACTIVE&&c(this,t,e))},setCollidesNever:function(t){for(var e=0;e=0&&h<=1&&l>=0&&l<=1}function s(t,e,i){return(e[0]-t[0])*(i[1]-t[1])-(i[0]-t[0])*(e[1]-t[1])}function r(t,e,i){return s(t,e,i)>0}function o(t,e,i){return s(t,e,i)>=0}function a(t,e,i){return s(t,e,i)<0}function h(t,e,i){return s(t,e,i)<=0}t.exports={decomp:function(t){var e=function t(e){var i=[],n=[],s=[],r=[];var o=Number.MAX_VALUE;for(var a=0;a0?function t(e,i){if(0===i.length)return[e];if(i instanceof Array&&i.length&&i[0]instanceof Array&&2===i[0].length&&i[0][0]instanceof Array){for(var n=[e],s=0;su)return console.warn("quickDecomp: max level ("+u+") reached."),i;for(var k=0;kA&&(A+=e.length),S=Number.MAX_VALUE,A3&&n>=0;--n)c(f(t,n-1),f(t,n),f(t,n+1),e)&&(t.splice(n%t.length,1),i++);return i},makeCCW:function(t){for(var e=0,i=t,n=1;ni[e][0])&&(e=n);r(f(t,e-1),f(t,e),f(t,e+1))||function(t){for(var e=[],i=t.length,n=0;n!==i;n++)e.push(t.pop());for(var n=0;n!==i;n++)t[n]=e[n]}(t)}};var l=[],u=[];function c(t,e,i,n){if(n){var r=l,o=u;r[0]=e[0]-t[0],r[1]=e[1]-t[1],o[0]=i[0]-e[0],o[1]=i[1]-e[1];var a=r[0]*o[0]+r[1]*o[1],h=Math.sqrt(r[0]*r[0]+r[1]*r[1]),c=Math.sqrt(o[0]*o[0]+o[1]*o[1]);return Math.acos(a/(h*c))g&&(g=m),a.translate(y,{x:.5*x,y:.5*m}),c=y.bounds.max.x+r,s.addBody(u,y),l=y,f+=1}else c+=r}d+=g+o,c=t}return u},n.chain=function(t,e,i,n,a,h){for(var l=t.bodies,u=1;u0)for(l=0;l0&&(d=f[l-1+(h-1)*e],s.addConstraint(t,r.create(o.extend({bodyA:d,bodyB:c},a)))),n&&ld||o<(l=d-l)||o>i-1-l))return 1===c&&a.translate(u,{x:(o+(i%2==1?1:-1))*f,y:0}),h(t+(u?o*f:0)+o*r,n,o,l,u,c)})},n.newtonsCradle=function(t,e,i,n,o){for(var a=s.create({label:"Newtons Cradle"}),l=0;lv.bounds.max.x||b.bounds.max.yv.bounds.max.y)){var w=e(i,b);if(!b.region||w.id!==b.region.id||r){x.broadphaseTests+=1,b.region&&!r||(b.region=w);var T=t(w,b.region);for(d=T.startCol;d<=T.endCol;d++)for(f=T.startRow;f<=T.endRow;f++){p=y[g=a(d,f)];var S=d>=w.startCol&&d<=w.endCol&&f>=w.startRow&&f<=w.endRow,A=d>=b.region.startCol&&d<=b.region.endCol&&f>=b.region.startRow&&f<=b.region.endRow;!S&&A&&A&&p&&u(i,p,b),(b.region===w||S&&!A||r)&&(p||(p=h(y,g)),l(i,p,b))}b.region=w,m=!0}}}m&&(i.pairsList=c(i))},n.clear=function(t){t.buckets={},t.pairs={},t.pairsList=[]};var t=function(t,e){var n=Math.min(t.startCol,e.startCol),s=Math.max(t.endCol,e.endCol),r=Math.min(t.startRow,e.startRow),o=Math.max(t.endRow,e.endRow);return i(n,s,r,o)},e=function(t,e){var n=e.bounds,s=Math.floor(n.min.x/t.bucketWidth),r=Math.floor(n.max.x/t.bucketWidth),o=Math.floor(n.min.y/t.bucketHeight),a=Math.floor(n.max.y/t.bucketHeight);return i(s,r,o,a)},i=function(t,e,i,n){return{id:t+","+e+","+i+","+n,startCol:t,endCol:e,startRow:i,endRow:n}},a=function(t,e){return"C"+t+"R"+e},h=function(t,e){return t[e]=[]},l=function(t,e,i){for(var n=0;n0?n.push(i):delete t.pairs[e[s]];return n}}()},function(t,e,i){var n={};t.exports=n;var s=i(375),r=i(38);n.create=function(t){return r.extend({table:{},list:[],collisionStart:[],collisionActive:[],collisionEnd:[]},t)},n.update=function(t,e,i){var n,r,o,a,h=t.list,l=t.table,u=t.collisionStart,c=t.collisionEnd,d=t.collisionActive;for(u.length=0,c.length=0,d.length=0,a=0;a1e3&&h.push(r);for(r=0;rf.friction*f.frictionStatic*R*i&&(I=k,B=o.clamp(f.friction*F*i,-I,I));var D=r.cross(A,y),Y=r.cross(C,y),z=b/(g.inverseMass+v.inverseMass+g.inverseInertia*D*D+v.inverseInertia*Y*Y);if(O*=z,B*=z,P<0&&P*P>n._restingThresh*i)T.normalImpulse=0;else{var X=T.normalImpulse;T.normalImpulse=Math.min(T.normalImpulse+O,0),O=T.normalImpulse-X}if(L*L>n._restingThreshTangent*i)T.tangentImpulse=0;else{var N=T.tangentImpulse;T.tangentImpulse=o.clamp(T.tangentImpulse+B,-I,I),B=T.tangentImpulse-N}s.x=y.x*O+m.x*B,s.y=y.y*O+m.y*B,g.isStatic||g.isSleeping||(g.positionPrev.x+=s.x*g.inverseMass,g.positionPrev.y+=s.y*g.inverseMass,g.anglePrev+=r.cross(A,s)*g.inverseInertia),v.isStatic||v.isSleeping||(v.positionPrev.x-=s.x*v.inverseMass,v.positionPrev.y-=s.y*v.inverseMass,v.anglePrev-=r.cross(C,s)*v.inverseInertia)}}}}},function(t,e,i){var n={};t.exports=n;var s=i(866),r=i(343),o=i(955),a=i(954),h=i(995),l=i(953),u=i(167),c=i(152),d=i(168),f=i(38),p=i(60);!function(){n.create=function(t,e){e=(e=f.isElement(t)?e:t)||{},((t=f.isElement(t)?t:null)||e.render)&&f.warn("Engine.create: engine.render is deprecated (see docs)");var i={positionIterations:6,velocityIterations:4,constraintIterations:2,enableSleeping:!1,events:[],plugin:{},timing:{timestamp:0,timeScale:1},broadphase:{controller:l}},n=f.extend(i,e);return n.world=e.world||s.create(n.world),n.pairs=a.create(),n.broadphase=n.broadphase.controller.create(n.broadphase),n.metrics=n.metrics||{extended:!1},n.metrics=h.create(n.metrics),n},n.update=function(n,s,l){s=s||1e3/60,l=l||1;var f,p=n.world,g=n.timing,v=n.broadphase,y=[];g.timestamp+=s*g.timeScale;var m={timestamp:g.timestamp};u.trigger(n,"beforeUpdate",m);var x=c.allBodies(p),b=c.allConstraints(p);for(h.reset(n.metrics),n.enableSleeping&&r.update(x,g.timeScale),e(x,p.gravity),i(x,s,g.timeScale,l,p.bounds),d.preSolveAll(x),f=0;f0&&u.trigger(n,"collisionStart",{pairs:T.collisionStart}),o.preSolvePosition(T.list),f=0;f0&&u.trigger(n,"collisionActive",{pairs:T.collisionActive}),T.collisionEnd.length>0&&u.trigger(n,"collisionEnd",{pairs:T.collisionEnd}),h.update(n.metrics,n),t(x),u.trigger(n,"afterUpdate",m),n},n.merge=function(t,e){if(f.extend(t,e),e.world){t.world=e.world,n.clear(t);for(var i=c.allBodies(t.world),s=0;s0&&(i=s[0].bodyA,n=s[0].bodyB),t.emit("collisionstart",e,i,n)}),c.on(e,"collisionActive",function(e){var i,n,s=e.pairs;s.length>0&&(i=s[0].bodyA,n=s[0].bodyB),t.emit("collisionactive",e,i,n)}),c.on(e,"collisionEnd",function(e){var i,n,s=e.pairs;s.length>0&&(i=s[0].bodyA,n=s[0].bodyB),t.emit("collisionend",e,i,n)})},setBounds:function(t,e,i,n,s,r,o,a,h){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.scene.sys.game.config.width),void 0===n&&(n=this.scene.sys.game.config.height),void 0===s&&(s=128),void 0===r&&(r=!0),void 0===o&&(o=!0),void 0===a&&(a=!0),void 0===h&&(h=!0),this.updateWall(r,"left",t-s,e,s,n),this.updateWall(o,"right",t+i,e,s,n),this.updateWall(a,"top",t,e-s,i,s),this.updateWall(h,"bottom",t,e+n,i,s),this},updateWall:function(t,e,i,n,s,r){var o=this.walls[e];t?(o&&d.remove(this.localWorld,o),i+=s/2,n+=r/2,this.walls[e]=this.create(i,n,s,r,{isStatic:!0,friction:0,frictionStatic:0})):(o&&d.remove(this.localWorld,o),this.walls[e]=null)},createDebugGraphic:function(){var t=this.scene.sys.add.graphics({x:0,y:0});return t.setZ(Number.MAX_VALUE),this.debugGraphic=t,this.drawDebug=!0,t},disableGravity:function(){return this.localWorld.gravity.x=0,this.localWorld.gravity.y=0,this.localWorld.gravity.scale=0,this},setGravity:function(t,e,i){return void 0===t&&(t=0),void 0===e&&(e=1),this.localWorld.gravity.x=t,this.localWorld.gravity.y=e,void 0!==i&&(this.localWorld.gravity.scale=i),this},create:function(t,e,i,s,r){var o=n.rectangle(t,e,i,s,r);return d.add(this.localWorld,o),o},add:function(t){return d.add(this.localWorld,t),this},remove:function(t,e){var i=t.body?t.body:t;return r.removeBody(this.localWorld,i,e),this},removeConstraint:function(t,e){return r.remove(this.localWorld,t,e),this},convertTilemapLayer:function(t,e){var i=t.layer,n=t.getTilesWithin(0,0,i.width,i.height,{isColliding:!0});return this.convertTiles(n,e),this},convertTiles:function(t,e){if(0===t.length)return this;for(var i=0;i0?e-o:e+o<0?e+o:0}return n(e,-r,r)}},function(t,e){t.exports=function(t,e){if(t.standing=!1,e.collision.y&&(t.bounciness>0&&Math.abs(t.vel.y)>t.minBounceVelocity?t.vel.y*=-t.bounciness:(t.vel.y>0&&(t.standing=!0),t.vel.y=0)),e.collision.x&&(t.bounciness>0&&Math.abs(t.vel.x)>t.minBounceVelocity?t.vel.x*=-t.bounciness:t.vel.x=0),e.collision.slope){var i=e.collision.slope;if(t.bounciness>0){var n=t.vel.x*i.nx+t.vel.y*i.ny;t.vel.x=(t.vel.x-i.nx*n*2)*t.bounciness,t.vel.y=(t.vel.y-i.ny*n*2)*t.bounciness}else{var s=i.x*i.x+i.y*i.y,r=(t.vel.x*i.x+t.vel.y*i.y)/s;t.vel.x=i.x*r,t.vel.y=i.y*r;var o=Math.atan2(i.x,i.y);o>t.slopeStanding.min&&oi.last.x&&e.last.xi.last.y&&e.last.y0))r=t.collisionMap.trace(e.pos.x,e.pos.y,0,-(e.pos.y+e.size.y-i.pos.y),e.size.x,e.size.y),e.pos.y=r.pos.y,e.bounciness>0&&e.vel.y>e.minBounceVelocity?e.vel.y*=-e.bounciness:(e.standing=!0,e.vel.y=0);else{var l=(e.vel.y-i.vel.y)/2;e.vel.y=-l,i.vel.y=l,s=i.vel.x*t.delta,r=t.collisionMap.trace(e.pos.x,e.pos.y,s,-o/2,e.size.x,e.size.y),e.pos.y=r.pos.y;var u=t.collisionMap.trace(i.pos.x,i.pos.y,0,o/2,i.size.x,i.size.y);i.pos.y=u.pos.y}}},function(t,e,i){t.exports={Factory:i(947),Image:i(950),Matter:i(864),MatterPhysics:i(997),PolyDecomp:i(948),Sprite:i(951),TileBody:i(861),World:i(957)}},function(t,e){t.exports={setBounce:function(t){return this.body.restitution=t,this}}},function(t,e){var i={setCollisionCategory:function(t){return this.body.collisionFilter.category=t,this},setCollisionGroup:function(t){return this.body.collisionFilter.group=t,this},setCollidesWith:function(t){var e=0;if(Array.isArray(t))for(var i=0;i1?1:0;n1;if(!c||t!=c.x||e!=c.y){c&&n?(d=c.x,f=c.y):(d=0,f=0);var s={x:d+t,y:f+e};!n&&c||(c=s),p.push(s),v=d+t,y=f+e}},x=function(t){var e=t.pathSegTypeAsLetter.toUpperCase();if("Z"!==e){switch(e){case"M":case"L":case"T":case"C":case"S":case"Q":v=t.x,y=t.y;break;case"H":v=t.x;break;case"V":y=t.y}m(v,y,t.pathSegType)}};for(t(e),r=e.getTotalLength(),h=[],n=0;n0)for(var a=s+1;ae.max.x?i=e.min.x-t.max.x:t.max.xe.max.y?n=e.min.y-t.max.y:t.max.y0&&(i=1/Math.sqrt(i),this.x=t*i,this.y=e*i),this},normalizeRightHand:function(){var t=this.x;return this.x=-1*this.y,this.y=t,this},dot:function(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.x},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this},transformMat3:function(t){var e=this.x,i=this.y,n=t.val;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this},transformMat4:function(t){var e=this.x,i=this.y,n=t.val;return this.x=n[0]*e+n[4]*i+n[12],this.y=n[1]*e+n[5]*i+n[13],this},reset:function(){return this.x=0,this.y=0,this}});n.ZERO=new n,t.exports=n},function(t,e){var i={},n={install:function(t){for(var e in i)t[e]=i[e]},register:function(t,e){i[t]=e},destroy:function(){i={}}};t.exports=n},function(t,e,i){var n=i(16),s=i(5);t.exports=function(t,e,i){var r=s(t,e,null);if(null===r)return i;if(Array.isArray(r))return n.RND.pick(r);if("object"==typeof r){if(r.hasOwnProperty("randInt"))return n.RND.integerInRange(r.randInt[0],r.randInt[1]);if(r.hasOwnProperty("randFloat"))return n.RND.realInRange(r.randFloat[0],r.randFloat[1])}else if("function"==typeof r)return r(e);return r}},function(t,e,i){var n=i(0),s=i(12),r=new n({initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),this.displayList,this.updateList},boot:function(){this.displayList=this.systems.displayList,this.updateList=this.systems.updateList;var t=this.systems.events;t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},existing:function(t){return(t.renderCanvas||t.renderWebGL)&&this.displayList.add(t),t.preUpdate&&this.updateList.add(t),t},shutdown:function(){},destroy:function(){this.scene=null,this.displayList=null,this.updateList=null}});r.register=function(t,e){r.prototype.hasOwnProperty(t)||(r.prototype[t]=e)},s.register("GameObjectFactory",r,"add"),t.exports=r},function(t,e,i){var n=i(0),s=i(27),r=i(166),o=i(352),a=i(104),h=i(163),l=new n({initialize:function(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x=t,this.y=e,this.width=i,this.height=n},contains:function(t,e){return s(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return h(this,t)},setTo:function(t,e,i,n){return this.x=t,this.y=e,this.width=i,this.height=n,this},setEmpty:function(){return this.setTo(0,0,0,0)},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setSize:function(t,e){return void 0===e&&(e=t),this.width=t,this.height=e,this},isEmpty:function(){return this.width<=0||this.height<=0},getLineA:function(t){return void 0===t&&(t=new a),t.setTo(this.x,this.y,this.right,this.y),t},getLineB:function(t){return void 0===t&&(t=new a),t.setTo(this.right,this.y,this.right,this.bottom),t},getLineC:function(t){return void 0===t&&(t=new a),t.setTo(this.right,this.bottom,this.x,this.bottom),t},getLineD:function(t){return void 0===t&&(t=new a),t.setTo(this.x,this.bottom,this.x,this.y),t},left:{get:function(){return this.x},set:function(t){t>=this.right?this.width=0:this.width=this.right-t,this.x=t}},right:{get:function(){return this.x+this.width},set:function(t){t<=this.x?this.width=0:this.width=t-this.x}},top:{get:function(){return this.y},set:function(t){t>=this.bottom?this.height=0:this.height=this.bottom-t,this.y=t}},bottom:{get:function(){return this.y+this.height},set:function(t){t<=this.y?this.height=0:this.height=t-this.y}},centerX:{get:function(){return this.x+this.width/2},set:function(t){this.x=t-this.width/2}},centerY:{get:function(){return this.y+this.height/2},set:function(t){this.y=t-this.height/2}}});t.exports=l},function(t,e,i){var n=i(0),s=i(12),r=new n({initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),this.displayList,this.updateList},boot:function(){this.displayList=this.systems.displayList,this.updateList=this.systems.updateList;var t=this.systems.events;t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},shutdown:function(){},destroy:function(){this.scene=null,this.displayList=null,this.updateList=null}});r.register=function(t,e){r.prototype.hasOwnProperty(t)||(r.prototype[t]=e)},s.register("GameObjectCreator",r,"make"),t.exports=r},function(t,e,i){var n={},s=new(i(0))({initialize:function(t){this.game=t,t.events.once("boot",this.boot,this)},boot:function(){this.game.events.once("destroy",this.destroy,this)},installGlobal:function(t,e){for(var i=t.game,n=t.scene,s=t.settings.map,r=0;ro.width&&(i=Math.max(o.width-t,0)),e+s>o.height&&(s=Math.max(o.height-e,0));for(var u=[],c=e;c=0;o--)t[o][e]=i+a*n,a++;return t}},function(t,e,i){var n={VERSION:"3.3.0",BlendModes:i(62),ScaleModes:i(80),AUTO:0,CANVAS:1,WEBGL:2,HEADLESS:3,FOREVER:-1,NONE:4,UP:5,DOWN:6,LEFT:7,RIGHT:8};t.exports=n},function(t,e,i){var n=i(62),s=i(8),r=i(80);t.exports=function(t,e,i){e.x=s(i,"x",0),e.y=s(i,"y",0),e.depth=s(i,"depth",0),e.flipX=s(i,"flipX",!1),e.flipY=s(i,"flipY",!1);var o=s(i,"scale",null);"number"==typeof o?e.setScale(o):null!==o&&(e.scaleX=s(o,"x",1),e.scaleY=s(o,"y",1));var a=s(i,"scrollFactor",null);"number"==typeof a?e.setScrollFactor(a):null!==a&&(e.scrollFactorX=s(a,"x",1),e.scrollFactorY=s(a,"y",1)),e.rotation=s(i,"rotation",0);var h=s(i,"angle",null);null!==h&&(e.angle=h),e.alpha=s(i,"alpha",1);var l=s(i,"origin",null);if("number"==typeof l)e.setOrigin(l);else if(null!==l){var u=s(l,"x",.5),c=s(l,"y",.5);e.setOrigin(u,c)}return e.scaleMode=s(i,"scaleMode",r.DEFAULT),e.blendMode=s(i,"blendMode",n.NORMAL),e.visible=s(i,"visible",!0),s(i,"add",!0)&&t.sys.displayList.add(e),e.preUpdate&&t.sys.updateList.add(e),e}},function(t,e,i){var n,s,r,o=i(21),a=i(151),h=[],l=!1;t.exports={create2D:function(t,e,i){return n(t,e,i,o.CANVAS)},create:n=function(t,e,i,n){var r;void 0===e&&(e=1),void 0===i&&(i=1),void 0===n&&(n=o.CANVAS);var u=s(n);return null===u?(u={parent:t,canvas:document.createElement("canvas"),type:n},h.push(u),r=u.canvas):(u.parent=t,r=u.canvas),r.width=e,r.height=i,l&&n===o.CANVAS&&a.disable(r.getContext("2d")),r},createWebGL:function(t,e,i){return n(t,e,i,o.WEBGL)},disableSmoothing:function(){l=!0},enableSmoothing:function(){l=!1},first:s=function(t){return void 0===t&&(t=o.CANVAS),h.forEach(function(e){if(!e.parent&&e.type===t)return e}),null},free:function(){return h.length-r()},pool:h,remove:function(t){var e=t instanceof HTMLCanvasElement;h.forEach(function(i){(e&&i.canvas===t||!e&&i.parent===t)&&(i.parent=null,i.canvas.width=1,i.canvas.height=1)})},total:r=function(){var t=0;return h.forEach(function(e){e.parent&&t++}),t}}},function(t,e){t.exports={CSV:0,TILED_JSON:1,ARRAY_2D:2,WELTMEISTER:3}},function(t,e){t.exports=function(t,e,i,n,s,r){var o;void 0===n&&(n=0),void 0===s&&(s=0),void 0===r&&(r=1);var a=0,h=t.length;if(1===r)for(o=s;o=0;o--)t[o][e]+=i+a*n,a++;return t}},function(t,e,i){var n=i(87),s=i(14);t.exports=function(t,e,i,r,o){for(var a=null,h=null,l=null,u=null,c=s(t,e,i,r,null,o),d=0;d=e&&t.y<=i&&t.y+t.height>=i}},function(t,e){t.exports=function(t,e,i){return t.radius>0&&e>=t.left&&e<=t.right&&i>=t.top&&i<=t.bottom&&(t.x-e)*(t.x-e)+(t.y-i)*(t.y-i)<=t.radius*t.radius}},function(t,e){t.exports=function(t,e){return t.y=e+t.height*t.originY,t}},function(t,e){t.exports=function(t){return t.y-t.height*t.originY}},function(t,e){t.exports=function(t,e){return t.x=e-t.width+t.width*t.originX,t}},function(t,e){t.exports=function(t){return t.x+t.width-t.width*t.originX}},function(t,e){t.exports=function(t,e){return t.x=e+t.width*t.originX,t}},function(t,e){t.exports=function(t){return t.x-t.width*t.originX}},function(t,e){t.exports=function(t,e){return t.y=e-t.height+t.height*t.originY,t}},function(t,e){t.exports=function(t){return t.y+t.height-t.height*t.originY}},function(t,e){t.exports=function(t,e,i,n){void 0===e&&(e=!0);var s=n.baseTileHeight,r=n.tilemapLayer;return r&&(void 0===i&&(i=r.scene.cameras.main),t-=r.y+i.scrollY*(1-r.scrollFactorY),s*=r.scaleY),e?Math.floor(t/s):t/s}},function(t,e){t.exports=function(t,e,i,n){void 0===e&&(e=!0);var s=n.baseTileWidth,r=n.tilemapLayer;return r&&(void 0===i&&(i=r.scene.cameras.main),t-=r.x+i.scrollX*(1-r.scrollFactorX),s*=r.scaleX),e?Math.floor(t/s):t/s}},function(t,e){var i={};t.exports=i,function(){i._nextId=0,i._seed=0,i._nowStartTime=+new Date,i.extend=function(t,e){var n,s;"boolean"==typeof e?(n=2,s=e):(n=1,s=!0);for(var r=n;r0;e--){var n=Math.floor(i.random()*(e+1)),s=t[e];t[e]=t[n],t[n]=s}return t},i.choose=function(t){return t[Math.floor(i.random()*t.length)]},i.isElement=function(t){return t instanceof HTMLElement},i.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},i.isFunction=function(t){return"function"==typeof t},i.isPlainObject=function(t){return"object"==typeof t&&t.constructor===Object},i.isString=function(t){return"[object String]"===Object.prototype.toString.call(t)},i.clamp=function(t,e,i){return ti?i:t},i.sign=function(t){return t<0?-1:1},i.now=function(){if(window.performance){if(window.performance.now)return window.performance.now();if(window.performance.webkitNow)return window.performance.webkitNow()}return new Date-i._nowStartTime},i.random=function(e,i){return e=void 0!==e?e:0,i=void 0!==i?i:1,e+t()*(i-e)};var t=function(){return i._seed=(9301*i._seed+49297)%233280,i._seed/233280};i.colorToNumber=function(t){return 3==(t=t.replace("#","")).length&&(t=t.charAt(0)+t.charAt(0)+t.charAt(1)+t.charAt(1)+t.charAt(2)+t.charAt(2)),parseInt(t,16)},i.logLevel=1,i.log=function(){console&&i.logLevel>0&&i.logLevel<=3&&console.log.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},i.info=function(){console&&i.logLevel>0&&i.logLevel<=2&&console.info.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},i.warn=function(){console&&i.logLevel>0&&i.logLevel<=3&&console.warn.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},i.nextId=function(){return i._nextId++},i.map=function(t,e){if(t.map)return t.map(e);for(var i=[],n=0;n>>0},getTintAppendFloatAlpha:function(t,e){return((255&(255*e|0))<<24|t)>>>0},getTintAppendFloatAlphaAndSwap:function(t,e){return((255&(255*e|0))<<24|(255&(0|t))<<16|(255&(t>>8|0))<<8|255&(t>>16|0))>>>0},getFloatsFromUintRGB:function(t){return[(255&(t>>16|0))/255,(255&(t>>8|0))/255,(255&(0|t))/255]},getComponentCount:function(t,e){for(var i=0,n=0;nthis.right||e>this.bottom)},copy:function(t){return this.index=t.index,this.alpha=t.alpha,this.properties=t.properties,this.visible=t.visible,this.setFlip(t.flipX,t.flipY),this.tint=t.tint,this.rotation=t.rotation,this.collideUp=t.collideUp,this.collideDown=t.collideDown,this.collideLeft=t.collideLeft,this.collideRight=t.collideRight,this.collisionCallback=t.collisionCallback,this.collisionCallbackContext=t.collisionCallbackContext,this},getCollisionGroup:function(){return this.tileset?this.tileset.getTileCollisionGroup(this.index):null},getTileData:function(){return this.tileset?this.tileset.getTileData(this.index):null},getLeft:function(t){var e=this.tilemapLayer;return e?e.tileToWorldX(this.x,t):this.x*this.baseWidth},getRight:function(t){var e=this.tilemapLayer;return e?this.getLeft(t)+this.width*e.scaleX:this.getLeft(t)+this.width},getTop:function(t){var e=this.tilemapLayer;return e?e.tileToWorldY(this.y,t)-(this.height-this.baseHeight)*e.scaleY:this.y*this.baseHeight-(this.height-this.baseHeight)},getBottom:function(t){var e=this.tilemapLayer;return e?this.getTop(t)+this.height*e.scaleY:this.getTop(t)+this.height},getBounds:function(t,e){return void 0===e&&(e=new r),e.x=this.getLeft(),e.y=this.getTop(),e.width=this.getRight()-e.x,e.height=this.getBottom()-e.y,e},getCenterX:function(t){return this.getLeft(t)+this.width/2},getCenterY:function(t){return this.getTop(t)+this.height/2},destroy:function(){this.collisionCallback=void 0,this.collisionCallbackContext=void 0,this.properties=void 0},intersects:function(t,e,i,n){return!(i<=this.pixelX||n<=this.pixelY||t>=this.right||e>=this.bottom)},isInteresting:function(t,e){return t&&e?this.canCollide||this.hasInterestingFace:t?this.collides:!!e&&this.hasInterestingFace},resetCollision:function(t){(void 0===t&&(t=!0),this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,t)&&(this.tilemapLayer&&this.tilemapLayer.calculateFacesAt(this.x,this.y));return this},resetFaces:function(){return this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,this},setCollision:function(t,e,i,n,s){(void 0===e&&(e=t),void 0===i&&(i=t),void 0===n&&(n=t),void 0===s&&(s=!0),this.collideLeft=t,this.collideRight=e,this.collideUp=i,this.collideDown=n,this.faceLeft=t,this.faceRight=e,this.faceTop=i,this.faceBottom=n,s)&&(this.tilemapLayer&&this.tilemapLayer.calculateFacesAt(this.x,this.y));return this},setCollisionCallback:function(t,e){return null===t?(this.collisionCallback=void 0,this.collisionCallbackContext=void 0):(this.collisionCallback=t,this.collisionCallbackContext=e),this},setSize:function(t,e,i,n){return void 0!==t&&(this.width=t),void 0!==e&&(this.height=e),void 0!==i&&(this.baseWidth=i),void 0!==n&&(this.baseHeight=n),this.updatePixelXY(),this},updatePixelXY:function(){return this.pixelX=this.x*this.baseWidth,this.pixelY=this.y*this.baseHeight-(this.height-this.baseHeight),this},canCollide:{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.collisionCallback}},collides:{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown}},hasInterestingFace:{get:function(){return this.faceTop||this.faceBottom||this.faceLeft||this.faceRight}},tileset:{get:function(){var t=this.tilemapLayer;return t?t.tileset:null}},tilemapLayer:{get:function(){return this.layer.tilemapLayer}},tilemap:{get:function(){var t=this.tilemapLayer;return t?t.tilemap:null}}});t.exports=o},function(t,e){t.exports=function(t,e){e?t.setCollision(!0,!0,!0,!0,!1):t.resetCollision(!1)}},function(t,e){t.exports={DYNAMIC_BODY:0,STATIC_BODY:1,GROUP:2,TILEMAPLAYER:3,FACING_NONE:10,FACING_UP:11,FACING_DOWN:12,FACING_LEFT:13,FACING_RIGHT:14}},function(t,e){t.exports=function(t,e,i,n){var s=t-i,r=e-n;return Math.sqrt(s*s+r*r)}},function(t,e,i){var n={};t.exports=n;var s=i(91),r=i(90),o=i(198),a=i(39),h=i(89),l=i(468);!function(){n._inertiaScale=4,n._nextCollidingGroupId=1,n._nextNonCollidingGroupId=-1,n._nextCategory=1,n.create=function(e){var i={id:a.nextId(),type:"body",label:"Body",gameObject:null,parts:[],plugin:{},angle:0,vertices:s.fromPath("L 0 0 L 40 0 L 40 40 L 0 40"),position:{x:0,y:0},force:{x:0,y:0},torque:0,positionImpulse:{x:0,y:0},previousPositionImpulse:{x:0,y:0},constraintImpulse:{x:0,y:0,angle:0},totalContacts:0,speed:0,angularSpeed:0,velocity:{x:0,y:0},angularVelocity:0,isSensor:!1,isStatic:!1,isSleeping:!1,ignoreGravity:!1,ignorePointer:!1,motion:0,sleepThreshold:60,density:.001,restitution:0,friction:.1,frictionStatic:.5,frictionAir:.01,collisionFilter:{category:1,mask:4294967295,group:0},slop:.05,timeScale:1,render:{visible:!0,opacity:1,sprite:{xScale:1,yScale:1,xOffset:0,yOffset:0},lineWidth:0},events:null,bounds:null,chamfer:null,circleRadius:0,positionPrev:null,anglePrev:0,parent:null,axes:null,area:0,mass:0,inertia:0,_original:null},n=a.extend(i,e);return t(n,e),n},n.nextGroup=function(t){return t?n._nextNonCollidingGroupId--:n._nextCollidingGroupId++},n.nextCategory=function(){return n._nextCategory=n._nextCategory<<1,n._nextCategory};var t=function(t,e){e=e||{},n.set(t,{bounds:t.bounds||h.create(t.vertices),positionPrev:t.positionPrev||r.clone(t.position),anglePrev:t.anglePrev||t.angle,vertices:t.vertices,parts:t.parts||[t],isStatic:t.isStatic,isSleeping:t.isSleeping,parent:t.parent||t}),s.rotate(t.vertices,t.angle,t.position),l.rotate(t.axes,t.angle),h.update(t.bounds,t.vertices,t.velocity),n.set(t,{axes:e.axes||t.axes,area:e.area||t.area,mass:e.mass||t.mass,inertia:e.inertia||t.inertia});var i=t.isStatic?"#2e2b44":a.choose(["#006BA6","#0496FF","#FFBC42","#D81159","#8F2D56"]);t.render.fillStyle=t.render.fillStyle||i,t.render.strokeStyle=t.render.strokeStyle||"#000",t.render.sprite.xOffset+=-(t.bounds.min.x-t.position.x)/(t.bounds.max.x-t.bounds.min.x),t.render.sprite.yOffset+=-(t.bounds.min.y-t.position.y)/(t.bounds.max.y-t.bounds.min.y)};n.set=function(t,e){var i,s;for(i in"string"==typeof e&&(i=e,(e={})[i]=s),e)if(e.hasOwnProperty(i))switch(s=e[i],i){case"isStatic":n.setStatic(t,s);break;case"isSleeping":o.set(t,s);break;case"mass":n.setMass(t,s);break;case"density":n.setDensity(t,s);break;case"inertia":n.setInertia(t,s);break;case"vertices":n.setVertices(t,s);break;case"position":n.setPosition(t,s);break;case"angle":n.setAngle(t,s);break;case"velocity":n.setVelocity(t,s);break;case"angularVelocity":n.setAngularVelocity(t,s);break;case"parts":n.setParts(t,s);break;default:t[i]=s}},n.setStatic=function(t,e){for(var i=0;i0&&r.rotateAbout(o.position,i,t.position,o.position)}},n.setVelocity=function(t,e){t.positionPrev.x=t.position.x-e.x,t.positionPrev.y=t.position.y-e.y,t.velocity.x=e.x,t.velocity.y=e.y,t.speed=r.magnitude(t.velocity)},n.setAngularVelocity=function(t,e){t.anglePrev=t.angle-e,t.angularVelocity=e,t.angularSpeed=Math.abs(t.angularVelocity)},n.translate=function(t,e){n.setPosition(t,r.add(t.position,e))},n.rotate=function(t,e,i){if(i){var s=Math.cos(e),r=Math.sin(e),o=t.position.x-i.x,a=t.position.y-i.y;n.setPosition(t,{x:i.x+(o*s-a*r),y:i.y+(o*r+a*s)}),n.setAngle(t,t.angle+e)}else n.setAngle(t,t.angle+e)},n.scale=function(t,i,r,o){o=o||t.position;for(var a=0;a0&&(f.position.x+=t.velocity.x,f.position.y+=t.velocity.y),0!==t.angularVelocity&&(s.rotate(f.vertices,t.angularVelocity,t.position),l.rotate(f.axes,t.angularVelocity),d>0&&r.rotateAbout(f.position,t.angularVelocity,t.position,f.position)),h.update(f.bounds,f.vertices,t.velocity)}},n.applyForce=function(t,e,i){t.force.x+=i.x,t.force.y+=i.y;var n=e.x-t.position.x,s=e.y-t.position.y;t.torque+=n*i.y-s*i.x};var e=function(t){for(var e={mass:0,area:0,inertia:0,centre:{x:0,y:0}},i=1===t.parts.length?0:1;i=this.x2&&this.x1>=this.x3?this.x1-t:this.x2>=this.x1&&this.x2>=this.x3?this.x2-t:this.x3-t,this.x1-=e,this.x2-=e,this.x3-=e}},top:{get:function(){return Math.min(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1<=this.y2&&this.y1<=this.y3?this.y1-t:this.y2<=this.y1&&this.y2<=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}},bottom:{get:function(){return Math.max(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1>=this.y2&&this.y1>=this.y3?this.y1-t:this.y2>=this.y1&&this.y2>=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}}});t.exports=l},function(t,e){t.exports=function(t){return Math.atan2(t.y2-t.y1,t.x2-t.x1)}},function(t,e){t.exports=function(t,e,i){var n=t.x3-t.x1,s=t.y3-t.y1,r=t.x2-t.x1,o=t.y2-t.y1,a=e-t.x1,h=i-t.y1,l=n*n+s*s,u=n*r+s*o,c=n*a+s*h,d=r*r+o*o,f=r*a+o*h,p=l*d-u*u,g=0===p?0:1/p,v=(d*c-u*f)*g,y=(l*f-u*c)*g;return v>=0&&y>=0&&v+y<1}},function(t,e){t.exports=function(t){var e={};for(var i in t)Array.isArray(t[i])?e[i]=t[i].slice(0):e[i]=t[i];return e}},function(t,e,i){var n=i(0),s=i(150),r=i(10),o=i(6),a=new n({initialize:function(t){this.type=t,this.defaultDivisions=5,this.arcLengthDivisions=100,this.cacheArcLengths=[],this.needsUpdate=!0,this.active=!0,this._tmpVec2A=new o,this._tmpVec2B=new o},draw:function(t,e){return void 0===e&&(e=32),t.strokePoints(this.getPoints(e))},getBounds:function(t,e){t||(t=new r),void 0===e&&(e=16);var i=this.getLength();e>i&&(e=i/2);var n=Math.max(1,Math.round(i/e));return s(this.getSpacedPoints(n),t)},getDistancePoints:function(t){var e=this.getLength(),i=Math.max(1,e/t);return this.getSpacedPoints(i)},getEndPoint:function(t){return void 0===t&&(t=new o),this.getPointAt(1,t)},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,i=[],n=this.getPoint(0,this._tmpVec2A),s=0;i.push(0);for(var r=1;r<=t;r++)s+=(e=this.getPoint(r/t,this._tmpVec2B)).distance(n),i.push(s),n.copy(e);return this.cacheArcLengths=i,i},getPointAt:function(t,e){var i=this.getUtoTmapping(t);return this.getPoint(i,e)},getPoints:function(t){void 0===t&&(t=this.defaultDivisions);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return e},getRandomPoint:function(t){return void 0===t&&(t=new o),this.getPoint(Math.random(),t)},getSpacedPoints:function(t){void 0===t&&(t=this.defaultDivisions);for(var e=[],i=0;i<=t;i++){var n=this.getUtoTmapping(i/t,null,t);e.push(this.getPoint(n))}return e},getStartPoint:function(t){return void 0===t&&(t=new o),this.getPointAt(0,t)},getTangent:function(t,e){void 0===e&&(e=new o);var i=t-1e-4,n=t+1e-4;return i<0&&(i=0),n>1&&(n=1),this.getPoint(i,this._tmpVec2A),this.getPoint(n,e),e.subtract(this._tmpVec2A).normalize()},getTangentAt:function(t,e){var i=this.getUtoTmapping(t);return this.getTangent(i,e)},getTFromDistance:function(t,e){return t<=0?0:this.getUtoTmapping(0,t,e)},getUtoTmapping:function(t,e,i){var n,s=this.getLengths(i),r=0,o=s.length;n=e?Math.min(e,s[o-1]):t*s[o-1];for(var a,h=0,l=o-1;h<=l;)if((a=s[r=Math.floor(h+(l-h)/2)]-n)<0)h=r+1;else{if(!(a>0)){l=r;break}l=r-1}if(s[r=l]===n)return r/(o-1);var u=s[r];return(r+(n-u)/(s[r+1]-u))/(o-1)},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()}});t.exports=a},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i){"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0):(this.x=t||0,this.y=e||0,this.z=i||0)},up:function(){return this.x=0,this.y=1,this.z=0,this},clone:function(){return new n(this.x,this.y,this.z)},crossVectors:function(t,e){var i=t.x,n=t.y,s=t.z,r=e.x,o=e.y,a=e.z;return this.x=n*a-s*o,this.y=s*r-i*a,this.z=i*o-n*r,this},equals:function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this},set:function(t,e,i){return"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0):(this.x=t||0,this.y=e||0,this.z=i||0),this},add:function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this},subtract:function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z||0,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z||1,this},scale:function(t){return isFinite(t)?(this.x*=t,this.y*=t,this.z*=t):(this.x=0,this.y=0,this.z=0),this},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z||1,this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},distance:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0;return Math.sqrt(e*e+i*i+n*n)},distanceSq:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0;return e*e+i*i+n*n},length:function(){var t=this.x,e=this.y,i=this.z;return Math.sqrt(t*t+e*e+i*i)},lengthSq:function(){var t=this.x,e=this.y,i=this.z;return t*t+e*e+i*i},normalize:function(){var t=this.x,e=this.y,i=this.z,n=t*t+e*e+i*i;return n>0&&(n=1/Math.sqrt(n),this.x=t*n,this.y=e*n,this.z=i*n),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},cross:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z;return this.x=i*o-n*r,this.y=n*s-e*o,this.z=e*r-i*s,this},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this},transformMat3:function(t){var e=this.x,i=this.y,n=this.z,s=t.val;return this.x=e*s[0]+i*s[3]+n*s[6],this.y=e*s[1]+i*s[4]+n*s[7],this.z=e*s[2]+i*s[5]+n*s[8],this},transformMat4:function(t){var e=this.x,i=this.y,n=this.z,s=t.val;return this.x=s[0]*e+s[4]*i+s[8]*n+s[12],this.y=s[1]*e+s[5]*i+s[9]*n+s[13],this.z=s[2]*e+s[6]*i+s[10]*n+s[14],this},transformCoordinates:function(t){var e=this.x,i=this.y,n=this.z,s=t.val,r=e*s[0]+i*s[4]+n*s[8]+s[12],o=e*s[1]+i*s[5]+n*s[9]+s[13],a=e*s[2]+i*s[6]+n*s[10]+s[14],h=e*s[3]+i*s[7]+n*s[11]+s[15];return this.x=r/h,this.y=o/h,this.z=a/h,this},transformQuat:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z,a=t.w,h=a*e+r*n-o*i,l=a*i+o*e-s*n,u=a*n+s*i-r*e,c=-s*e-r*i-o*n;return this.x=h*a+c*-s+l*-o-u*-r,this.y=l*a+c*-r+u*-s-h*-o,this.z=u*a+c*-o+h*-r-l*-s,this},project:function(t){var e=this.x,i=this.y,n=this.z,s=t.val,r=s[0],o=s[1],a=s[2],h=s[3],l=s[4],u=s[5],c=s[6],d=s[7],f=s[8],p=s[9],g=s[10],v=s[11],y=s[12],m=s[13],x=s[14],b=1/(e*h+i*d+n*v+s[15]);return this.x=(e*r+i*l+n*f+y)*b,this.y=(e*o+i*u+n*p+m)*b,this.z=(e*a+i*c+n*g+x)*b,this},unproject:function(t,e){var i=t.x,n=t.y,s=t.z,r=t.w,o=this.x-i,a=r-this.y-1-n,h=this.z;return this.x=2*o/s-1,this.y=2*a/r-1,this.z=2*h-1,this.project(e)},reset:function(){return this.x=0,this.y=0,this.z=0,this}});t.exports=n},function(t,e){t.exports=function(t){return t.y-t.height*t.originY+.5*t.height}},function(t,e){t.exports=function(t,e){var i=t.height*t.originY;return t.y=e+i-.5*t.height,t}},function(t,e){t.exports=function(t,e){var i=t.width*t.originX;return t.x=e+i-.5*t.width,t}},function(t,e){t.exports=function(t){return t.x-t.width*t.originX+.5*t.width}},function(t,e){t.exports={SKIP_CHECK:-1,NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16}},function(t,e,i){var n=new(i(0))({initialize:function(t){if(this.entries=[],Array.isArray(t))for(var e=0;e-1&&this.entries.splice(e,1),this},dump:function(){console.group("Set");for(var t=0;t-1},union:function(t){var e=new n;return t.entries.forEach(function(t){e.set(t)}),this.entries.forEach(function(t){e.set(t)}),e},intersect:function(t){var e=new n;return this.entries.forEach(function(i){t.contains(i)&&e.set(i)}),e},difference:function(t){var e=new n;return this.entries.forEach(function(i){t.contains(i)||e.set(i)}),e},size:{get:function(){return this.entries.length},set:function(t){return this.entries.length=t}}});t.exports=n},function(t,e){t.exports=function(t,e,i){return Math.max(e,Math.min(i,t))}},function(t,e,i){var n=i(0),s=i(2),r=new n({initialize:function(t){void 0===t&&(t={}),this.name=s(t,"name","map"),this.width=s(t,"width",0),this.height=s(t,"height",0),this.tileWidth=s(t,"tileWidth",0),this.tileHeight=s(t,"tileHeight",0),this.widthInPixels=s(t,"widthInPixels",this.width*this.tileWidth),this.heightInPixels=s(t,"heightInPixels",this.height*this.tileHeight),this.format=s(t,"format",null),this.orientation=s(t,"orientation","orthogonal"),this.version=s(t,"version","1"),this.properties=s(t,"properties",{}),this.layers=s(t,"layers",[]),this.images=s(t,"images",[]),this.objects=s(t,"objects",{}),this.collision=s(t,"collision",{}),this.tilesets=s(t,"tilesets",[]),this.imageCollections=s(t,"imageCollections",[]),this.tiles=s(t,"tiles",[])}});t.exports=r},function(t,e,i){var n=i(0),s=i(2),r=new n({initialize:function(t){void 0===t&&(t={}),this.name=s(t,"name","layer"),this.x=s(t,"x",0),this.y=s(t,"y",0),this.width=s(t,"width",0),this.height=s(t,"height",0),this.tileWidth=s(t,"tileWidth",0),this.tileHeight=s(t,"tileHeight",0),this.baseTileWidth=s(t,"baseTileWidth",this.tileWidth),this.baseTileHeight=s(t,"baseTileHeight",this.tileHeight),this.widthInPixels=s(t,"widthInPixels",this.width*this.baseTileWidth),this.heightInPixels=s(t,"heightInPixels",this.height*this.baseTileHeight),this.alpha=s(t,"alpha",1),this.visible=s(t,"visible",!0),this.properties=s(t,"properties",{}),this.indexes=s(t,"indexes",[]),this.collideIndexes=s(t,"collideIndexes",[]),this.callbacks=s(t,"callbacks",[]),this.bodies=s(t,"bodies",[]),this.data=s(t,"data",[]),this.tilemapLayer=s(t,"tilemapLayer",null)}});t.exports=r},function(t,e){t.exports=function(t,e,i){return t>=0&&t=0&&e=this.firstgid&&tt.max.x&&(t.max.x=s.x),s.xt.max.y&&(t.max.y=s.y),s.y0?t.max.x+=i.x:t.min.x+=i.x,i.y>0?t.max.y+=i.y:t.min.y+=i.y)},i.contains=function(t,e){return e.x>=t.min.x&&e.x<=t.max.x&&e.y>=t.min.y&&e.y<=t.max.y},i.overlaps=function(t,e){return t.min.x<=e.max.x&&t.max.x>=e.min.x&&t.max.y>=e.min.y&&t.min.y<=e.max.y},i.translate=function(t,e){t.min.x+=e.x,t.max.x+=e.x,t.min.y+=e.y,t.max.y+=e.y},i.shift=function(t,e){var i=t.max.x-t.min.x,n=t.max.y-t.min.y;t.min.x=e.x,t.max.x=e.x+i,t.min.y=e.y,t.max.y=e.y+n}},function(t,e){var i={};t.exports=i,i.create=function(t,e){return{x:t||0,y:e||0}},i.clone=function(t){return{x:t.x,y:t.y}},i.magnitude=function(t){return Math.sqrt(t.x*t.x+t.y*t.y)},i.magnitudeSquared=function(t){return t.x*t.x+t.y*t.y},i.rotate=function(t,e,i){var n=Math.cos(e),s=Math.sin(e);i||(i={});var r=t.x*n-t.y*s;return i.y=t.x*s+t.y*n,i.x=r,i},i.rotateAbout=function(t,e,i,n){var s=Math.cos(e),r=Math.sin(e);n||(n={});var o=i.x+((t.x-i.x)*s-(t.y-i.y)*r);return n.y=i.y+((t.x-i.x)*r+(t.y-i.y)*s),n.x=o,n},i.normalise=function(t){var e=i.magnitude(t);return 0===e?{x:0,y:0}:{x:t.x/e,y:t.y/e}},i.dot=function(t,e){return t.x*e.x+t.y*e.y},i.cross=function(t,e){return t.x*e.y-t.y*e.x},i.cross3=function(t,e,i){return(e.x-t.x)*(i.y-t.y)-(e.y-t.y)*(i.x-t.x)},i.add=function(t,e,i){return i||(i={}),i.x=t.x+e.x,i.y=t.y+e.y,i},i.sub=function(t,e,i){return i||(i={}),i.x=t.x-e.x,i.y=t.y-e.y,i},i.mult=function(t,e){return{x:t.x*e,y:t.y*e}},i.div=function(t,e){return{x:t.x/e,y:t.y/e}},i.perp=function(t,e){return{x:(e=!0===e?-1:1)*-t.y,y:e*t.x}},i.neg=function(t){return{x:-t.x,y:-t.y}},i.angle=function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)},i._temp=[i.create(),i.create(),i.create(),i.create(),i.create(),i.create()]},function(t,e,i){var n={};t.exports=n;var s=i(90),r=i(39);n.create=function(t,e){for(var i=[],n=0;n0)return!1}return!0},n.scale=function(t,e,i,r){if(1===e&&1===i)return t;var o,a;r=r||n.centre(t);for(var h=0;h=0?h-1:t.length-1],u=t[h],c=t[(h+1)%t.length],d=e[h0&&(r|=2),3===r)return!1;return 0!==r||null},n.hull=function(t){var e,i,n=[],r=[];for((t=t.slice(0)).sort(function(t,e){var i=t.x-e.x;return 0!==i?i:t.y-e.y}),i=0;i=2&&s.cross3(r[r.length-2],r[r.length-1],e)<=0;)r.pop();r.push(e)}for(i=t.length-1;i>=0;i-=1){for(e=t[i];n.length>=2&&s.cross3(n[n.length-2],n[n.length-1],e)<=0;)n.pop();n.push(e)}return n.pop(),r.pop(),n.concat(r)}},function(t,e,i){var n={};t.exports=n;var s=i(91),r=i(39),o=i(49),a=i(89),h=i(90),l=i(963);n.rectangle=function(t,e,i,n,a){a=a||{};var h={label:"Rectangle Body",position:{x:t,y:e},vertices:s.fromPath("L 0 0 L "+i+" 0 L "+i+" "+n+" L 0 "+n)};if(a.chamfer){var l=a.chamfer;h.vertices=s.chamfer(h.vertices,l.radius,l.quality,l.qualityMin,l.qualityMax),delete a.chamfer}return o.create(r.extend({},h,a))},n.trapezoid=function(t,e,i,n,a,h){h=h||{};var l,u=i*(a*=.5),c=u+(1-2*a)*i,d=c+u;l=a<.5?"L 0 0 L "+u+" "+-n+" L "+c+" "+-n+" L "+d+" 0":"L 0 0 L "+c+" "+-n+" L "+d+" 0";var f={label:"Trapezoid Body",position:{x:t,y:e},vertices:s.fromPath(l)};if(h.chamfer){var p=h.chamfer;f.vertices=s.chamfer(f.vertices,p.radius,p.quality,p.qualityMin,p.qualityMax),delete h.chamfer}return o.create(r.extend({},f,h))},n.circle=function(t,e,i,s,o){s=s||{};var a={label:"Circle Body",circleRadius:i};o=o||25;var h=Math.ceil(Math.max(10,Math.min(o,i)));return h%2==1&&(h+=1),n.polygon(t,e,h,i,r.extend({},a,s))},n.polygon=function(t,e,i,a,h){if(h=h||{},i<3)return n.circle(t,e,a,h);for(var l=2*Math.PI/i,u="",c=.5*l,d=0;d0&&s.area(A)1?(f=o.create(r.extend({parts:p.slice(0)},n)),o.setPosition(f,{x:t,y:e}),f):p[0]}},function(t,e,i){var n=i(0),s=i(213),r=i(40),o=new n({Extends:r,Mixins:[s.Acceleration,s.Angular,s.Bounce,s.Debug,s.Drag,s.Enable,s.Friction,s.Gravity,s.Immovable,s.Mass,s.Size,s.Velocity],initialize:function(t,e,i,n,s){r.call(this,t,e,i,n,s)}});t.exports=o},function(t,e){t.exports=function(t,e,i,n,s){return void 0===t&&(t=""),void 0===e&&(e=!0),void 0===i&&(i=""),void 0===n&&(n=""),void 0===s&&(s=0),{responseType:t,async:e,user:i,password:n,timeout:s,header:void 0,headerValue:void 0,overrideMimeType:void 0}}},function(t,e,i){var n=i(4);t.exports=function(t,e,i){void 0===i&&(i=new n);var s=t.x1,r=t.y1,o=t.x2,a=t.y2,h=e.x1,l=e.y1,u=e.x2,c=e.y2,d=(u-h)*(r-l)-(c-l)*(s-h),f=(o-s)*(r-l)-(a-r)*(s-h),p=(c-l)*(o-s)-(u-h)*(a-r);if(0===p)return!1;var g=d/p,v=f/p;return g>=0&&g<=1&&v>=0&&v<=1&&(i.x=s+g*(o-s),i.y=r+g*(a-r),!0)}},function(t,e,i){var n=i(0),s=i(13),r=i(1),o=i(670),a=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Flip,s.GetBounds,s.Origin,s.Pipeline,s.ScaleMode,s.Size,s.Texture,s.Transform,s.Visible,s.ScrollFactor,o],initialize:function(t,e,i,n,s,o,a,h,l){if(r.call(this,t,"Mesh"),this.setTexture(h,l),this.setPosition(e,i),this.setSizeToFrame(),this.setOrigin(),this.initPipeline("TextureTintPipeline"),n.length!==s.length)throw new Error("Mesh Vertex count must match UV count");var u,c=n.length/2|0;if(o.length>0&&o.length0&&a.length=0&&e<=this.list.length&&-1===this.getIndex(t)&&this.list.splice(e,0,t),t)},addMultiple:function(t){if(Array.isArray(t))for(var e=0;en?1:0},getByKey:function(t,e){for(var i=0;ithis.list.length)return null;var i=t+Math.floor(Math.random()*e);return this.list[i]},getFirst:function(t,e,i,n){void 0===i&&(i=0),void 0===n&&(n=this.list.length);for(var s=i;s=this.list.length)throw new Error("List.moveTo: The supplied index is out of bounds");return this.list.splice(i,1),this.list.splice(e,0,t),t},remove:function(t){var e=this.list.indexOf(t);return-1!==e&&this.list.splice(e,1),t},removeAt:function(t){var e=this.list[t];return e&&this.children.splice(t,1),e},removeBetween:function(t,e){void 0===t&&(t=0),void 0===e&&(e=this.list.length);var i=e-t;if(i>0&&i<=e)return this.list.splice(t,i);if(0===i&&0===this.list.length)return[];throw new Error("List.removeBetween: Range Error, numeric values are outside the acceptable range")},removeAll:function(){for(var t=this.list.length;t--;)this.remove(this.list[t]);return this},bringToTop:function(t){return this.getIndex(t)0&&(this.remove(t),this.addAt(t,0)),t},moveUp:function(t){var e=this.getIndex(t);if(-1!==e&&e0){var i=this.getAt(e-1);i&&this.swap(t,i)}return t},reverse:function(){return this.list.reverse(),this},shuffle:function(){for(var t=this.list.length-1;t>0;t--){var e=Math.floor(Math.random()*(t+1)),i=this.list[t];this.list[t]=this.list[e],this.list[e]=i}return this},replace:function(t,e){var i=this.getIndex(t);if(-1!==i)return this.remove(t),this.addAt(e,i),t},exists:function(t){return this.list.indexOf(t)>-1},setAll:function(t,e){for(var i=0;i0?this.list[0]:null}},last:{get:function(){return this.list.length>0?(this.position=this.list.length-1,this.list[this.position]):null}},next:{get:function(){return this.position0?(this.position--,this.list[this.position]):null}}});t.exports=n},function(t,e,i){var n=i(0),s=i(15),r=i(18),o=i(3),a=new n({Extends:s,initialize:function(t,e,i){s.call(this),this.manager=t,this.key=e,this.isPlaying=!1,this.isPaused=!1,this.totalRate=1,this.duration=this.duration||0,this.totalDuration=this.totalDuration||0,this.config={delay:0},this.currentConfig=this.config,this.mute=!1,this.volume=1,this.rate=1,this.detune=0,this.seek=0,this.loop=!1,this.config=r(this.config,i),this.markers={},this.currentMarker=null,this.pendingRemove=!1},addMarker:function(t){return!(!t||!t.name||"string"!=typeof t.name)&&(this.markers[t.name]?(console.error("addMarker - Marker with name '"+t.name+"' already exists for sound '"+this.key+"'!"),!1):(t=r(!0,{name:"",start:0,duration:this.totalDuration-(t.start||0),config:{mute:!1,volume:1,rate:1,detune:0,seek:0,loop:!1,delay:0}},t),this.markers[t.name]=t,!0))},updateMarker:function(t){return!(!t||!t.name||"string"!=typeof t.name)&&(this.markers[t.name]?(this.markers[t.name]=r(!0,this.markers[t.name],t),!0):(console.error("updateMarker - Marker with name '"+t.name+"' does not exist for sound '"+this.key+"'!"),!1))},removeMarker:function(t){var e=this.markers[t];return e?(this.markers[t]=null,e):null},play:function(t,e){if(void 0===t&&(t=""),"object"==typeof t&&(e=t,t=""),"string"!=typeof t)return console.error("Sound marker name has to be a string!"),!1;if(t){if(!this.markers[t])return console.error("No marker with name '"+t+"' found for sound '"+this.key+"'!"),!1;this.currentMarker=this.markers[t],this.currentConfig=this.currentMarker.config,this.duration=this.currentMarker.duration}else this.currentMarker=null,this.currentConfig=this.config,this.duration=this.totalDuration;return this.resetConfig(),this.currentConfig=r(this.currentConfig,e),this.isPlaying=!0,this.isPaused=!1,!0},pause:function(){return!(this.isPaused||!this.isPlaying)&&(this.isPlaying=!1,this.isPaused=!0,!0)},resume:function(){return!(!this.isPaused||this.isPlaying)&&(this.isPlaying=!0,this.isPaused=!1,!0)},stop:function(){return!(!this.isPaused&&!this.isPlaying)&&(this.isPlaying=!1,this.isPaused=!1,this.resetConfig(),!0)},applyConfig:function(){this.mute=this.currentConfig.mute,this.volume=this.currentConfig.volume,this.rate=this.currentConfig.rate,this.detune=this.currentConfig.detune,this.loop=this.currentConfig.loop},resetConfig:function(){this.currentConfig.seek=0,this.currentConfig.delay=0},update:o,calculateRate:function(){var t=this.currentConfig.detune+this.manager.detune,e=Math.pow(1.0005777895065548,t);this.totalRate=this.currentConfig.rate*this.manager.rate*e},setRate:function(t){return this.rate=t,this},rate:{get:function(){return this.currentConfig.rate},set:function(t){this.currentConfig.rate=t,this.calculateRate(),this.emit("rate",this,t)}},setDetune:function(t){return this.detune=t,this},detune:{get:function(){return this.currentConfig.detune},set:function(t){this.currentConfig.detune=t,this.calculateRate(),this.emit("detune",this,t)}},destroy:function(){this.pendingRemove||(this.pendingRemove=!0,this.manager=null,this.key="",this.removeAllListeners(),this.isPlaying=!1,this.isPaused=!1,this.config=null,this.currentConfig=null,this.markers=null,this.currentMarker=null)}});t.exports=a},function(t,e,i){var n=i(0),s=i(15),r=i(3),o=new n({Extends:s,initialize:function(t){s.call(this),this.game=t,this.sounds=[],this.mute=!1,this.volume=1,this.pauseOnBlur=!0,t.events.on("blur",function(){this.pauseOnBlur&&this.onBlur()},this),t.events.on("focus",function(){this.pauseOnBlur&&this.onFocus()},this),t.events.once("destroy",this.destroy,this),this._rate=1,this._detune=0,this.locked=this.locked||!1,this.unlocked=!1,this.locked&&this.unlock()},add:r,addAudioSprite:function(t,e){var i=this.add(t,e);for(var n in i.spritemap=this.game.cache.json.get(t).spritemap,i.spritemap)if(i.spritemap.hasOwnProperty(n)){var s=i.spritemap[n];i.addMarker({name:n,start:s.start,duration:s.end-s.start,config:e})}return i},play:function(t,e){var i=this.add(t);return i.once("ended",i.destroy,i),e?e.name?(i.addMarker(e),i.play(e.name)):i.play(e):i.play()},playAudioSprite:function(t,e,i){var n=this.addAudioSprite(t);return n.once("ended",n.destroy,n),n.play(e,i)},remove:function(t){var e=this.sounds.indexOf(t);return-1!==e&&(t.destroy(),this.sounds.splice(e,1),!0)},removeByKey:function(t){for(var e=0,i=this.sounds.length-1;i>=0;i--){var n=this.sounds[i];n.key===t&&(n.destroy(),this.sounds.splice(i,1),e++)}return e},pauseAll:function(){this.forEachActiveSound(function(t){t.pause()}),this.emit("pauseall",this)},resumeAll:function(){this.forEachActiveSound(function(t){t.resume()}),this.emit("resumeall",this)},stopAll:function(){this.forEachActiveSound(function(t){t.stop()}),this.emit("stopall",this)},unlock:r,onBlur:r,onFocus:r,update:function(t,e){this.unlocked&&(this.unlocked=!1,this.locked=!1,this.emit("unlocked",this));for(var i=this.sounds.length-1;i>=0;i--)this.sounds[i].pendingRemove&&this.sounds.splice(i,1);this.sounds.forEach(function(i){i.update(t,e)})},destroy:function(){this.removeAllListeners(),this.forEachActiveSound(function(t){t.destroy()}),this.sounds.length=0,this.sounds=null,this.game=null},forEachActiveSound:function(t,e){var i=this;this.sounds.forEach(function(n,s){n.pendingRemove||t.call(e||i,n,s,i.sounds)})},setRate:function(t){return this.rate=t,this},rate:{get:function(){return this._rate},set:function(t){this._rate=t,this.forEachActiveSound(function(t){t.setRate()}),this.emit("rate",this,t)}},setDetune:function(t){return this.detune=t,this},detune:{get:function(){return this._detune},set:function(t){this._detune=t,this.forEachActiveSound(function(t){t.setRate()}),this.emit("detune",this,t)}}});t.exports=o},function(t,e,i){var n,s=i(76),r={chrome:!1,chromeVersion:0,edge:!1,firefox:!1,firefoxVersion:0,ie:!1,ieVersion:0,mobileSafari:!1,opera:!1,safari:!1,safariVersion:0,silk:!1,trident:!1,tridentVersion:0};t.exports=(n=navigator.userAgent,/Edge\/\d+/.test(n)?r.edge=!0:/Chrome\/(\d+)/.test(n)&&!s.windowsPhone?(r.chrome=!0,r.chromeVersion=parseInt(RegExp.$1,10)):/Firefox\D+(\d+)/.test(n)?(r.firefox=!0,r.firefoxVersion=parseInt(RegExp.$1,10)):/AppleWebKit/.test(n)&&s.iOS?r.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(n)?(r.ie=!0,r.ieVersion=parseInt(RegExp.$1,10)):/Opera/.test(n)?r.opera=!0:/Safari/.test(n)&&!s.windowsPhone?r.safari=!0:/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(n)&&(r.ie=!0,r.trident=!0,r.tridentVersion=parseInt(RegExp.$1,10),r.ieVersion=parseInt(RegExp.$3,10)),/Silk/.test(n)&&(r.silk=!0),r)},function(t,e,i){var n=i(0),s=i(1),r=i(40),o=i(6),a=i(152),h=new n({Extends:s,initialize:function(t,e,i,n,h,l){s.call(this,t,"Sprite3D"),this.gameObject=new r(t,0,0,h,l),this.position=new a(e,i,n),this.size=new o(this.gameObject.width,this.gameObject.height),this.scale=new o(1,1),this.adjustScaleX=!0,this.adjustScaleY=!0,this._visible=!0},project:function(t){var e=this.position,i=this.gameObject;t.project(e,i),t.getPointSize(e,this.size,this.scale),this.scale.x<=0||this.scale.y<=0?i.setVisible(!1):(i.visible||i.setVisible(!0),this.adjustScaleX&&(i.scaleX=this.scale.x),this.adjustScaleY&&(i.scaleY=this.scale.y),i.setDepth(-1*i.z))},setVisible:function(t){return this.visible=t,this},visible:{get:function(){return this._visible},set:function(t){this._visible=t,this.gameObject.visible=t}},x:{get:function(){return this.position.x},set:function(t){this.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t}},z:{get:function(){return this.position.z},set:function(t){this.position.z=t}}});t.exports=h},function(t,e){t.exports=function(t){for(var e=t.length-1;e>0;e--){var i=Math.floor(Math.random()*(e+1)),n=t[e];t[e]=t[i],t[i]=n}return t}},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.parent=t,this.events=e,e||(this.events=t.events?t.events:t),this.list={},this.blockSet=!1,this._frozen=!1,this.events.once("destroy",this.destroy,this)},get:function(t){return this.list[t]},getAll:function(){var t={};for(var e in this.list)this.list.hasOwnProperty(e)&&(t[e]=this.list[e]);return t},query:function(t){var e={};for(var i in this.list)this.list.hasOwnProperty(i)&&i.match(t)&&(e[i]=this.list[i]);return e},set:function(t,e){if(this._frozen)return this;if(this.events.listenerCount("changedata")>0){this.blockSet=!1;var i=this;if(this.events.emit("changedata",this.parent,t,e,function(e){i.blockSet=!0,i.list[t]=e,i.events.emit("setdata",i.parent,t,e)}),this.blockSet)return this}return this.list[t]=e,this.events.emit("setdata",this.parent,t,e),this},each:function(t,e){for(var i=[this.parent,null,void 0],n=1;nthis.x2?this.x1=t:this.x2=t}},top:{get:function(){return Math.min(this.y1,this.y2)},set:function(t){this.y1<=this.y2?this.y1=t:this.y2=t}},bottom:{get:function(){return Math.max(this.y1,this.y2)},set:function(t){this.y1>this.y2?this.y1=t:this.y2=t}}});t.exports=h},function(t,e){t.exports=function(t){return 2*(t.width+t.height)}},function(t,e,i){var n=i(62),s=i(79),r=i(28),o=i(0),a=i(13),h=i(1),l=i(10),u=i(27),c=new o({Extends:h,Mixins:[a.Depth,a.GetBounds,a.Origin,a.ScaleMode,a.Transform,a.ScrollFactor,a.Visible],initialize:function(t,e,i,s,r){void 0===s&&(s=1),void 0===r&&(r=s),h.call(this,t,"Zone"),this.setPosition(e,i),this.width=s,this.height=r,this.blendMode=n.NORMAL},displayWidth:{get:function(){return this.scaleX*this.width},set:function(t){this.scaleX=t/this.width}},displayHeight:{get:function(){return this.scaleY*this.height},set:function(t){this.scaleY=t/this.height}},setSize:function(t,e,i){return void 0===i&&(i=!0),this.width=t,this.height=e,i&&this.input&&this.input.hitArea instanceof l&&(this.input.hitArea.width=t,this.input.hitArea.height=e),this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this},setCircleDropZone:function(t){return this.setDropZone(new s(0,0,t),r)},setRectangleDropZone:function(t,e){var i=-t/2,n=-e/2;return this.setDropZone(new l(i,n,t,e),u)},setDropZone:function(t,e){return void 0===t?this.setRectangleDropZone(this.width,this.height):this.input||this.setInteractive(t,e,!0),this},renderCanvas:function(){},renderWebGL:function(){}});t.exports=c},function(t,e,i){var n=i(55);t.exports=function(t,e){var i=n(t);for(var s in e)i.hasOwnProperty(s)||(i[s]=e[s]);return i}},function(t,e,i){var n=i(0),s=i(44),r=new n({initialize:function(t){this.name="WebGLPipeline",this.game=t.game,this.view=t.game.canvas,this.resolution=t.game.config.resolution,this.width=t.game.config.width*this.resolution,this.height=t.game.config.height*this.resolution,this.gl=t.gl,this.vertexCount=0,this.vertexCapacity=t.vertexCapacity,this.renderer=t.renderer,this.vertexData=t.vertices?t.vertices:new ArrayBuffer(t.vertexCapacity*t.vertexSize),this.vertexBuffer=this.renderer.createVertexBuffer(t.vertices?t.vertices:this.vertexData.byteLength,this.gl.STREAM_DRAW),this.program=this.renderer.createProgram(t.vertShader,t.fragShader),this.attributes=t.attributes,this.vertexSize=t.vertexSize,this.topology=t.topology,this.bytes=new Uint8Array(this.vertexData),this.vertexComponentCount=s.getComponentCount(t.attributes,this.gl),this.flushLocked=!1},addAttribute:function(t,e,i,n,s){return this.attributes.push({name:t,size:e,type:this.renderer.glFormats[i],normalized:n,offset:s}),this},shouldFlush:function(){return this.vertexCount>=this.vertexCapacity},resize:function(t,e,i){return this.width=t*i,this.height=e*i,this},bind:function(){var t=this.gl,e=this.vertexBuffer,i=this.attributes,n=this.program,s=this.renderer,r=this.vertexSize;s.setProgram(n),s.setVertexBuffer(e);for(var o=0;o=0?(t.enableVertexAttribArray(h),t.vertexAttribPointer(h,a.size,a.type,a.normalized,r,a.offset)):t.disableVertexAttribArray(h)}return this},onBind:function(){return this},onPreRender:function(){return this},onRender:function(){return this},onPostRender:function(){return this},flush:function(){if(this.flushLocked)return this;this.flushLocked=!0;var t=this.gl,e=this.vertexCount,i=this.topology,n=this.vertexSize;if(0!==e)return t.bufferSubData(t.ARRAY_BUFFER,0,this.bytes.subarray(0,e*n)),t.drawArrays(i,0,e),this.vertexCount=0,this.flushLocked=!1,this;this.flushLocked=!1},destroy:function(){var t=this.gl;return t.deleteProgram(this.program),t.deleteBuffer(this.vertexBuffer),delete this.program,delete this.vertexBuffer,delete this.gl,this},setFloat1:function(t,e){return this.renderer.setFloat1(this.program,t,e),this},setFloat2:function(t,e,i){return this.renderer.setFloat2(this.program,t,e,i),this},setFloat3:function(t,e,i,n){return this.renderer.setFloat3(this.program,t,e,i,n),this},setFloat4:function(t,e,i,n,s){return this.renderer.setFloat4(this.program,t,e,i,n,s),this},setInt1:function(t,e){return this.renderer.setInt1(this.program,t,e),this},setInt2:function(t,e,i){return this.renderer.setInt2(this.program,t,e,i),this},setInt3:function(t,e,i,n){return this.renderer.setInt3(this.program,t,e,i,n),this},setInt4:function(t,e,i,n,s){return this.renderer.setInt4(this.program,t,e,i,n,s),this},setMatrix2:function(t,e,i){return this.renderer.setMatrix2(this.program,t,e,i),this},setMatrix3:function(t,e,i){return this.renderer.setMatrix3(this.program,t,e,i),this},setMatrix4:function(t,e,i){return this.renderer.setMatrix4(this.program,t,e,i),this}});t.exports=r},function(t,e){t.exports=function(t){if(!Array.isArray(t)||t.length<2||!Array.isArray(t[0]))return!1;for(var e=t[0].length,i=1;i0&&(n.totalDuration+=n.t2*n.repeat),n.totalDuration>t&&(t=n.totalDuration)}this.duration=t,this.loopCounter=-1===this.loop?999999999999:this.loop,this.loopCounter>0?this.totalDuration=this.duration+this.completeDelay+(this.duration+this.loopDelay)*this.loopCounter:this.totalDuration=this.duration+this.completeDelay},init:function(){for(var t=this.data,e=this.totalTargets,i=0;i0){this.elapsed=0,this.progress=0,this.loopCounter--;var t=this.callbacks.onLoop;t&&(t.params[1]=this.targets,t.func.apply(t.scope,t.params)),this.resetTweenData(!0),this.loopDelay>0?(this.countdown=this.loopDelay,this.state=o.LOOP_DELAY):this.state=o.ACTIVE}else if(this.completeDelay>0)this.countdown=this.completeDelay,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.PENDING_REMOVE}},pause:function(){if(this.state!==o.PAUSED)return this.paused=!0,this._pausedState=this.state,this.state=o.PAUSED,this},play:function(t){if(this.state!==o.ACTIVE){this.state!==o.PENDING_REMOVE&&this.state!==o.REMOVED||(this.init(),this.parent.makeActive(this),t=!0);var e=this.callbacks.onStart;this.parentIsTimeline?(this.resetTweenData(t),0===this.calculatedOffset?(e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.ACTIVE):(this.countdown=this.calculatedOffset,this.state=o.OFFSET_DELAY)):this.paused?(this.paused=!1,this.parent.makeActive(this)):(this.resetTweenData(t),this.state=o.ACTIVE,e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)))}},resetTweenData:function(t){for(var e=this.data,i=0;i0?(n.elapsed=n.delay,n.state=o.DELAY):n.state=o.PENDING_RENDER}},resume:function(){return this.state===o.PAUSED&&(this.paused=!1,this.state=this._pausedState),this},seek:function(t){for(var e=this.data,i=0;i=s.totalDuration?(r=1,o=s.duration):n>s.delay&&n<=s.t1?(r=(n=Math.max(0,n-s.delay))/s.t1,o=s.duration*r):n>s.t1&&ns.repeatDelay&&(r=n/s.t1,o=s.duration*r)),s.progress=r,s.elapsed=o;var a=s.ease(s.progress);s.current=s.start+(s.end-s.start)*a,s.target[s.key]=s.current}},setCallback:function(t,e,i,n){return this.callbacks[t]={func:e,scope:n,params:i},this},complete:function(t){if(void 0===t&&(t=0),t)this.countdown=t,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.PENDING_REMOVE}},stop:function(t){this.state===o.ACTIVE&&void 0!==t&&this.seek(t),this.state!==o.REMOVED&&(this.state=o.PENDING_REMOVE)},update:function(t,e){if(this.state===o.PAUSED)return!1;switch(this.useFrames&&(e=1*this.parent.timeScale),e*=this.timeScale,this.elapsed+=e,this.progress=Math.min(this.elapsed/this.duration,1),this.totalElapsed+=e,this.totalProgress=Math.min(this.totalElapsed/this.totalDuration,1),this.state){case o.ACTIVE:for(var i=!1,n=0;n0){e.repeatCounter--,e.elapsed=i,e.progress=i/e.duration,e.flipX&&e.target.toggleFlipX(),e.flipY&&e.target.toggleFlipY();var s=t.callbacks.onRepeat;return s&&(s.params[1]=e.target,s.func.apply(s.scope,s.params)),e.start=e.getStartValue(e.target,e.key,e.start),e.end=e.getEndValue(e.target,e.key,e.start),e.repeatDelay>0?(e.elapsed=e.repeatDelay-i,e.current=e.start,e.target[e.key]=e.current,o.REPEAT_DELAY):o.PLAYING_FORWARD}return o.COMPLETE},setStateFromStart:function(t,e,i){if(e.repeatCounter>0){e.repeatCounter--,e.elapsed=i,e.progress=i/e.duration,e.flipX&&e.target.toggleFlipX(),e.flipY&&e.target.toggleFlipY();var n=t.callbacks.onRepeat;return n&&(n.params[1]=e.target,n.func.apply(n.scope,n.params)),e.end=e.getEndValue(e.target,e.key,e.start),e.repeatDelay>0?(e.elapsed=e.repeatDelay-i,e.current=e.start,e.target[e.key]=e.current,o.REPEAT_DELAY):o.PLAYING_FORWARD}return o.COMPLETE},updateTweenData:function(t,e,i){switch(e.state){case o.PLAYING_FORWARD:case o.PLAYING_BACKWARD:if(!e.target){e.state=o.COMPLETE;break}var n=e.elapsed,s=e.duration,r=0;(n+=i)>s&&(r=n-s,n=s);var a,h=e.state===o.PLAYING_FORWARD,l=n/s;a=h?e.ease(l):e.ease(1-l),e.current=e.start+(e.end-e.start)*a,e.target[e.key]=e.current,e.elapsed=n,e.progress=l;var u=t.callbacks.onUpdate;u&&(u.params[1]=e.target,u.func.apply(u.scope,u.params)),1===l&&(h?e.hold>0?(e.elapsed=e.hold-r,e.state=o.HOLD_DELAY):e.state=this.setStateFromEnd(t,e,r):e.state=this.setStateFromStart(t,e,r));break;case o.DELAY:e.elapsed-=i,e.elapsed<=0&&(e.elapsed=Math.abs(e.elapsed),e.state=o.PENDING_RENDER);break;case o.REPEAT_DELAY:e.elapsed-=i,e.elapsed<=0&&(e.elapsed=Math.abs(e.elapsed),e.state=o.PLAYING_FORWARD);break;case o.HOLD_DELAY:e.elapsed-=i,e.elapsed<=0&&(e.state=this.setStateFromEnd(t,e,Math.abs(e.elapsed)));break;case o.PENDING_RENDER:e.target?(e.start=e.getStartValue(e.target,e.key,e.target[e.key]),e.end=e.getEndValue(e.target,e.key,e.start),e.current=e.start,e.target[e.key]=e.start,e.state=o.PLAYING_FORWARD):e.state=o.COMPLETE}return e.state!==o.COMPLETE}});a.TYPES=["onComplete","onLoop","onRepeat","onStart","onUpdate","onYoyo"],r.register("tween",function(t){return this.scene.sys.tweens.add(t)}),s.register("tween",function(t){return this.scene.sys.tweens.create(t)}),t.exports=a},function(t,e){t.exports={targets:null,delay:0,duration:1e3,ease:"Power0",easeParams:null,hold:0,repeat:0,repeatDelay:0,yoyo:!1,flipX:!1,flipY:!1}},function(t,e){function i(t){return!!t.getStart&&"function"==typeof t.getStart}function n(t){return!!t.getEnd&&"function"==typeof t.getEnd}var s=function(t,e){var r,o,a=function(t,e,i){return i},h=function(t,e,i){return i},l=typeof e;if("number"===l)a=function(){return e};else if("string"===l){var u=e[0],c=parseFloat(e.substr(2));switch(u){case"+":a=function(t,e,i){return i+c};break;case"-":a=function(t,e,i){return i-c};break;case"*":a=function(t,e,i){return i*c};break;case"/":a=function(t,e,i){return i/c};break;default:a=function(){return parseFloat(e)}}}else"function"===l?a=e:"object"===l&&(i(o=e)||n(o))?(n(e)&&(a=e.getEnd),i(e)&&(h=e.getStart)):e.hasOwnProperty("value")&&(r=s(t,e.value));return r||(r={getEnd:a,getStart:h}),r};t.exports=s},function(t,e,i){var n=i(5);t.exports=function(t){var e=n(t,"targets",null);return null===e?e:("function"==typeof e&&(e=e.call()),Array.isArray(e)||(e=[e]),e)}},function(t,e,i){var n=i(24),s=i(65),r=i(194),o=i(186);t.exports=function(t,e,i,a,h,l,u,c){void 0===i&&(i=32),void 0===a&&(a=32),void 0===h&&(h=10),void 0===l&&(l=10),void 0===c&&(c=!1);var d=null;if(Array.isArray(u))d=r(void 0!==e?e:"map",n.ARRAY_2D,u,i,a,c);else if(void 0!==e){var f=t.cache.tilemap.get(e);f?d=r(e,f.format,f.data,i,a,c):console.warn("No map data found for key "+e)}return null===d&&(d=new s({tileWidth:i,tileHeight:a,width:h,height:l})),new o(t,d)}},function(t,e,i){var n=i(24),s=i(66),r=i(65),o=i(45);t.exports=function(t,e,i,a,h){for(var l=new s({tileWidth:i,tileHeight:a}),u=new r({name:t,tileWidth:i,tileHeight:a,format:n.ARRAY_2D,layers:[l]}),c=[],d=e.length,f=0,p=0;p=0&&r>=0&&s+r<1&&(n.push({x:e[w].x,y:e[w].y}),i)));w++);return n}},function(t,e,i){var n=i(0),s=i(96),r=new n({Extends:s,initialize:function(t,e,i,n,r){s.call(this,t,e,i,[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,1,1,1,0,0,1,1,1,0],[16777215,16777215,16777215,16777215,16777215,16777215],[1,1,1,1,1,1],n,r),this.resetPosition()},topLeftX:{get:function(){return this.x+this.vertices[0]},set:function(t){this.vertices[0]=t-this.x,this.vertices[6]=t-this.x}},topLeftY:{get:function(){return this.y+this.vertices[1]},set:function(t){this.vertices[1]=t-this.y,this.vertices[7]=t-this.y}},topRightX:{get:function(){return this.x+this.vertices[10]},set:function(t){this.vertices[10]=t-this.x}},topRightY:{get:function(){return this.y+this.vertices[11]},set:function(t){this.vertices[11]=t-this.y}},bottomLeftX:{get:function(){return this.x+this.vertices[2]},set:function(t){this.vertices[2]=t-this.x}},bottomLeftY:{get:function(){return this.y+this.vertices[3]},set:function(t){this.vertices[3]=t-this.y}},bottomRightX:{get:function(){return this.x+this.vertices[4]},set:function(t){this.vertices[4]=t-this.x,this.vertices[8]=t-this.x}},bottomRightY:{get:function(){return this.y+this.vertices[5]},set:function(t){this.vertices[5]=t-this.y,this.vertices[9]=t-this.y}},topLeftAlpha:{get:function(){return this.alphas[0]},set:function(t){this.alphas[0]=t,this.alphas[3]=t}},topRightAlpha:{get:function(){return this.alphas[5]},set:function(t){this.alphas[5]=t}},bottomLeftAlpha:{get:function(){return this.alphas[1]},set:function(t){this.alphas[1]=t}},bottomRightAlpha:{get:function(){return this.alphas[2]},set:function(t){this.alphas[2]=t,this.alphas[4]=t}},topLeftColor:{get:function(){return this.colors[0]},set:function(t){this.colors[0]=t,this.colors[3]=t}},topRightColor:{get:function(){return this.colors[5]},set:function(t){this.colors[5]=t}},bottomLeftColor:{get:function(){return this.colors[1]},set:function(t){this.colors[1]=t}},bottomRightColor:{get:function(){return this.colors[2]},set:function(t){this.colors[2]=t,this.colors[4]=t}},setTopLeft:function(t,e){return this.topLeftX=t,this.topLeftY=e,this},setTopRight:function(t,e){return this.topRightX=t,this.topRightY=e,this},setBottomLeft:function(t,e){return this.bottomLeftX=t,this.bottomLeftY=e,this},setBottomRight:function(t,e){return this.bottomRightX=t,this.bottomRightY=e,this},resetPosition:function(){var t=this.x,e=this.y,i=Math.floor(this.width/2),n=Math.floor(this.height/2);return this.setTopLeft(t-i,e-n),this.setTopRight(t+i,e-n),this.setBottomLeft(t-i,e+n),this.setBottomRight(t+i,e+n),this},resetAlpha:function(){var t=this.alphas;return t[0]=1,t[1]=1,t[2]=1,t[3]=1,t[4]=1,t[5]=1,this},resetColors:function(){var t=this.colors;return t[0]=16777215,t[1]=16777215,t[2]=16777215,t[3]=16777215,t[4]=16777215,t[5]=16777215,this},reset:function(){return this.resetPosition(),this.resetAlpha(),this.resetColors()}});t.exports=r},function(t,e,i){var n=i(23),s=i(0),r=i(13),o=i(21),a=i(1),h=i(248),l=i(700),u=new s({Extends:a,Mixins:[r.Alpha,r.BlendMode,r.Depth,r.Flip,r.GetBounds,r.Origin,r.Pipeline,r.ScaleMode,r.ScrollFactor,r.Size,r.Texture,r.Tint,r.Transform,r.Visible,l],initialize:function(t,e,i,s,r,l,u){var c=t.sys.game.renderer;a.call(this,t,"TileSprite"),this.tilePositionX=0,this.tilePositionY=0,this.dirty=!0,this.tileTexture=null,this.renderer=c,this.setTexture(l,u),this.setPosition(e,i),this.setSize(s,r),this.setOriginFromFrame(),this.initPipeline("TextureTintPipeline"),this.potWidth=h(this.frame.width),this.potHeight=h(this.frame.height),this.canvasPattern=null,this.canvasBuffer=n.create2D(null,this.potWidth,this.potHeight),this.canvasBufferCtx=this.canvasBuffer.getContext("2d"),this.oldFrame=null,this.updateTileTexture(),t.sys.game.config.renderType===o.WEBGL&&t.sys.game.renderer.onContextRestored(function(t){var e=t.gl;this.tileTexture=null,this.dirty=!0,this.tileTexture=t.createTexture2D(0,e.LINEAR,e.LINEAR,e.REPEAT,e.REPEAT,e.RGBA,this.canvasBuffer,this.potWidth,this.potHeight)},this)},setTilePosition:function(t,e){return void 0!==t&&(this.tilePositionX=t),void 0!==e&&(this.tilePositionY=e),this},updateTileTexture:function(){(this.dirty||this.oldFrame!==this.frame)&&(this.oldFrame=this.frame,this.canvasBufferCtx.clearRect(0,0,this.canvasBuffer.width,this.canvasBuffer.height),this.renderer.gl?(this.canvasBufferCtx.drawImage(this.frame.source.image,this.frame.cutX,this.frame.cutY,this.frame.cutWidth,this.frame.cutHeight,0,0,this.potWidth,this.potHeight),this.tileTexture=this.renderer.canvasToTexture(this.canvasBuffer,this.tileTexture,null===this.tileTexture,this.scaleMode)):(this.canvasBuffer.width=this.frame.cutWidth,this.canvasBuffer.height=this.frame.cutHeight,this.canvasBufferCtx.drawImage(this.frame.source.image,this.frame.cutX,this.frame.cutY,this.frame.cutWidth,this.frame.cutHeight,0,0,this.frame.cutWidth,this.frame.cutHeight),this.canvasPattern=this.canvasBufferCtx.createPattern(this.canvasBuffer,"repeat")),this.dirty=!1)},destroy:function(){this.renderer&&this.renderer.deleteTexture(this.tileTexture),n.remove(this.canvasBuffer),this.canvasPattern=null,this.canvasBufferCtx=null,this.canvasBuffer=null,this.renderer=null,this.visible=!1}});t.exports=u},function(t,e,i){var n=i(147),s=i(23),r=i(0),o=i(13),a=i(21),h=i(1),l=i(706),u=i(5),c=i(305),d=i(705),f=i(702),p=new r({Extends:h,Mixins:[o.Alpha,o.BlendMode,o.ComputedSize,o.Depth,o.Flip,o.GetBounds,o.Origin,o.Pipeline,o.ScaleMode,o.ScrollFactor,o.Tint,o.Transform,o.Visible,d],initialize:function(t,e,i,n,r){void 0===e&&(e=0),void 0===i&&(i=0),h.call(this,t,"Text"),this.setPosition(e,i),this.setOrigin(0,0),this.initPipeline("TextureTintPipeline"),this.canvas=s.create(this),this.context=this.canvas.getContext("2d"),this.style=new f(this,r),this.autoRound=!0,this.splitRegExp=/(?:\r\n|\r|\n)/,this.text="",this.resolution=1,this.padding={left:0,right:0,top:0,bottom:0},this.width=1,this.height=1,this.canvasTexture=null,this.dirty=!1,this.initRTL(),r&&r.padding&&this.setPadding(r.padding),r&&r.lineSpacing&&(this._lineSpacing=r.lineSpacing),this.setText(n),t.sys.game.config.renderType===a.WEBGL&&t.sys.game.renderer.onContextRestored(function(){this.canvasTexture=null,this.dirty=!0},this)},initRTL:function(){this.style.rtl&&(this.canvas.dir="rtl",this.context.direction="rtl",this.canvas.style.display="none",n(this.canvas,this.scene.sys.canvas),this.originX=1)},runWordWrap:function(t){var e=this.style;if(e.wordWrapCallback){var i=e.wordWrapCallback.call(e.wordWrapCallbackScope,t,this);return Array.isArray(i)&&(i=i.join("\n")),i}return e.wordWrapWidth?e.wordWrapUseAdvanced?this.advancedWordWrap(t,this.context,this.style.wordWrapWidth):this.basicWordWrap(t,this.context,this.style.wordWrapWidth):t},advancedWordWrap:function(t,e,i){for(var n="",s=t.replace(/ +/gi," ").split(this.splitRegExp),r=s.length,o=0;ol){if(0===c){for(var g=f;g.length&&(g=g.slice(0,-1),!((p=e.measureText(g).width)<=l)););if(!g.length)throw new Error("This text's wordWrapWidth setting is less than a single character!");var v=d.substr(g.length);u[c]=v,h+=g}var y=u[c].length?c:c+1,m=u.slice(y).join(" ").replace(/[ \n]*$/gi,"");s[o+1]=m+" "+(s[o+1]||""),r=s.length;break}h+=f,l-=p}n+=h.replace(/[ \n]*$/gi,"")+"\n"}}return n=n.replace(/[\s|\n]*$/gi,"")},basicWordWrap:function(t,e,i){for(var n="",s=t.split(this.splitRegExp),r=0;ro?(h>0&&(n+="\n"),n+=a[h]+" ",o=i-l):(o-=u,n+=a[h]+" ")}r0&&(a+=u.lineSpacing*p),i.rtl?o=d-o:"right"===i.align?o+=u.width-u.lineWidths[p]:"center"===i.align&&(o+=(u.width-u.lineWidths[p])/2),this.autoRound&&(o=Math.round(o),a=Math.round(a)),i.strokeThickness&&(this.style.syncShadow(e,i.shadowStroke),e.strokeText(h[p],o,a)),i.color&&(this.style.syncShadow(e,i.shadowFill),e.fillText(h[p],o,a));return e.restore(),this.dirty=!0,this},getTextMetrics:function(){return this.style.getTextMetrics()},toJSON:function(){var t=o.ToJSON(this),e={autoRound:this.autoRound,text:this.text,style:this.style.toJSON(),resolution:this.resolution,padding:{left:this.padding.left,right:this.padding.right,top:this.padding.top,bottom:this.padding.bottom}};return t.data=e,t},preDestroy:function(){this.style.rtl&&c(this.canvas),s.remove(this.canvas)}});t.exports=p},function(t,e,i){var n=i(23),s=i(0),r=i(13),o=i(21),a=i(1),h=i(711),l=i(708),u=i(707),c=new s({Extends:a,Mixins:[r.Alpha,r.BlendMode,r.Depth,r.Flip,r.GetBounds,r.MatrixStack,r.Origin,r.Pipeline,r.ScaleMode,r.ScrollFactor,r.Size,r.Tint,r.Transform,r.Visible,h],initialize:function(t,e,i,s,r){if(void 0===s&&(s=32),void 0===r&&(r=32),a.call(this,t,"RenderTexture"),this.initMatrixStack(),this.renderer=t.sys.game.renderer,this.globalTint=16777215,this.globalAlpha=1,this.renderer.type===o.WEBGL){var h=this.renderer.gl;this.gl=h,this.fill=u.fill,this.clear=u.clear,this.draw=u.draw,this.drawFrame=u.drawFrame,this.texture=this.renderer.createTexture2D(0,h.NEAREST,h.NEAREST,h.CLAMP_TO_EDGE,h.CLAMP_TO_EDGE,h.RGBA,null,s,r,!1),this.framebuffer=this.renderer.createFramebuffer(s,r,this.texture,!1)}else this.renderer.type===o.CANVAS&&(this.fill=l.fill,this.clear=l.clear,this.draw=l.draw,this.drawFrame=l.drawFrame,this.canvas=n.create2D(null,s,r),this.context=this.canvas.getContext("2d"));this.setPosition(e,i),this.setSize(s,r),this.initPipeline("TextureTintPipeline")},destroy:function(){a.destroy.call(this),this.renderer.type===o.WEBGL&&(this.renderer.deleteTexture(this.texture),this.renderer.deleteFramebuffer(this.framebuffer))},setGlobalTint:function(t){return this.globalTint=t,this},setGlobalAlpha:function(t){return this.globalAlpha=t,this}});t.exports=c},function(t,e){t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=t.length);var n=e+Math.floor(Math.random()*i);return void 0===t[n]?null:t[n]}},function(t,e,i){var n=i(0),s=i(13),r=i(1),o=i(754),a=i(97),h=i(753),l=i(714),u=new n({Extends:r,Mixins:[s.Depth,s.Visible,s.Pipeline,l],initialize:function(t,e,i,n){if(r.call(this,t,"ParticleEmitterManager"),this.blendMode=-1,this.timeScale=1,this.texture=null,this.frame=null,this.frameNames=[],null===i||"object"!=typeof i&&!Array.isArray(i)||(n=i,i=null),this.setTexture(e,i),this.initPipeline("TextureTintPipeline"),this.emitters=new a(this),this.wells=new a(this),n){Array.isArray(n)||(n=[n]);for(var s=0;s0?e.defaultFrame=i[0]:e.defaultFrame=this.defaultFrame,this},addEmitter:function(t){return this.emitters.add(t)},createEmitter:function(t){return this.addEmitter(new h(this,t))},addGravityWell:function(t){return this.wells.add(t)},createGravityWell:function(t){return this.addGravityWell(new o(t))},emitParticle:function(t,e,i){for(var n=this.emitters.list,s=0;s-1&&this.fillStyle(this.defaultFillColor,this.defaultFillAlpha),this.defaultStrokeColor>-1&&this.lineStyle(this.defaultStrokeWidth,this.defaultStrokeColor,this.defaultStrokeAlpha),this},generateTexture:function(t,e,i){var n,s,r=this.scene.sys;if(void 0===e&&(e=r.game.config.width),void 0===i&&(i=r.game.config.height),d.TargetCamera.setViewport(0,0,e,i),d.TargetCamera.scrollX=this.x,d.TargetCamera.scrollY=this.y,"string"==typeof t)if(r.textures.exists(t)){var o=(n=r.textures.get(t)).getSourceImage();o instanceof HTMLCanvasElement&&(s=o.getContext("2d"))}else s=(n=r.textures.createCanvas(t,e,i)).getSourceImage().getContext("2d");else t instanceof HTMLCanvasElement&&(s=t.getContext("2d"));return s&&(this.renderCanvas(r.game.renderer,this,0,d.TargetCamera,s),r.game.renderer.gl&&n&&(n.source[0].glTexture=r.game.renderer.canvasToTexture(s.canvas,n.source[0].glTexture,!0,0))),this}});d.TargetCamera=new n(0,0,0,0),t.exports=d},function(t,e,i){var n=i(0),s=i(13),r=i(1),o=i(271),a=i(771),h=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Origin,s.Pipeline,s.ScrollFactor,s.Texture,s.Tint,s.Transform,s.Visible,a],initialize:function(t,e,i,n,s,o){void 0===s&&(s=""),r.call(this,t,"DynamicBitmapText"),this.font=n;var a=this.scene.sys.cache.bitmapFont.get(n);this.fontData=a.data,this.text=Array.isArray(s)?s.join("\n"):s,this.fontSize=o||this.fontData.size,this.setTexture(a.texture,a.frame),this.setPosition(e,i),this.setOrigin(0,0),this.initPipeline("TextureTintPipeline"),this._bounds=this.getTextBounds(),this.scrollX=0,this.scrollY=0,this.cropWidth=0,this.cropHeight=0,this.displayCallback},setSize:function(t,e){return this.cropWidth=t,this.cropHeight=e,this},setDisplayCallback:function(t){return this.displayCallback=t,this},setFontSize:function(t){return this.fontSize=t,this},setText:function(t){return t||0===t||(t=""),Array.isArray(t)&&(t=t.join("\n")),t!==this.text&&(this.text=t.toString(),this.updateDisplayOrigin()),this},setScrollX:function(t){return this.scrollX=t,this},setScrollY:function(t){return this.scrollY=t,this},getTextBounds:function(t){return this._bounds=o(this,t),this._bounds},width:{get:function(){return this.getTextBounds(!1),this._bounds.global.width}},height:{get:function(){return this.getTextBounds(!1),this._bounds.global.height}},toJSON:function(){var t=s.ToJSON(this),e={font:this.font,text:this.text,fontSize:this.fontSize};return t.data=e,t}});t.exports=h},function(t,e,i){var n=i(775),s=i(772),r=i(0),o=i(13),a=i(141),h=i(1),l=i(97),u=new r({Extends:h,Mixins:[o.Alpha,o.BlendMode,o.Depth,o.Pipeline,o.ScaleMode,o.ScrollFactor,o.Size,o.Texture,o.Transform,o.Visible,n],initialize:function(t,e,i,n,s){h.call(this,t,"Blitter"),this.setTexture(n,s),this.setPosition(e,i),this.initPipeline("TextureTintPipeline"),this.children=new l,this.renderList=[],this.dirty=!1},create:function(t,e,i,n,r){void 0===n&&(n=!0),void 0===r&&(r=this.children.length),void 0===i?i=this.frame:i instanceof a||(i=this.texture.get(i));var o=new s(this,t,e,i,n);return this.children.addAt(o,r,!1),this.dirty=!0,o},createFromCallback:function(t,e,i,n){for(var s=this.createMultiple(e,i,n),r=0;r0},getRenderList:function(){return this.dirty&&(this.renderList=this.children.list.filter(this.childCanRender,this),this.dirty=!1),this.renderList},clear:function(){this.children.removeAll(),this.dirty=!0}});t.exports=u},function(t,e,i){var n=i(0),s=i(13),r=i(1),o=i(271),a=i(780),h=i(779),l=i(778),u=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Origin,s.Pipeline,s.ScaleMode,s.ScrollFactor,s.Texture,s.Tint,s.Transform,s.Visible,l],initialize:function(t,e,i,n,s,o){void 0===s&&(s=""),r.call(this,t,"BitmapText"),this.font=n;var a=this.scene.sys.cache.bitmapFont.get(n);this.fontData=a.data,this.text=Array.isArray(s)?s.join("\n"):s,this.fontSize=o||this.fontData.size,this.setTexture(a.texture,a.frame),this.setPosition(e,i),this.setOrigin(0,0),this.initPipeline("TextureTintPipeline"),this._bounds=this.getTextBounds()},setFontSize:function(t){return this.fontSize=t,this},setText:function(t){return t||0===t||(t=""),Array.isArray(t)&&(t=t.join("\n")),t!==this.text&&(this.text=t.toString(),this.updateDisplayOrigin()),this},getTextBounds:function(t){return this._bounds=o(this,t),this._bounds},width:{get:function(){return this.getTextBounds(!1),this._bounds.global.width}},height:{get:function(){return this.getTextBounds(!1),this._bounds.global.height}},toJSON:function(){var t=s.ToJSON(this),e={font:this.font,text:this.text,fontSize:this.fontSize};return t.data=e,t}});u.ParseRetroFont=h,u.ParseFromAtlas=a,t.exports=u},function(t,e,i){var n=i(8);t.exports=function(t,e){var i=n(e,"anims",null);if(null===i)return t;if("string"==typeof i)t.anims.play(i);else if("object"==typeof i){var s=t.anims,r=n(i,"key",void 0),o=n(i,"startFrame",void 0),a=n(i,"delay",0),h=n(i,"repeat",0),l=n(i,"repeatDelay",0),u=n(i,"yoyo",!1),c=n(i,"play",!1),d=n(i,"delayedPlay",0);s.delay(a),s.repeat(h),s.repeatDelay(l),s.yoyo(u),c?s.play(r,o):d>0?s.delayedPlay(d,r,o):s.load(r)}return t}},function(t,e,i){var n=i(0),s=i(18),r=new n({initialize:function(t,e,i,n,s,r,o){this.texture=t,this.name=e,this.source=t.source[i],this.sourceIndex=i,this.cutX=n,this.cutY=s,this.cutWidth=r,this.cutHeight=o,this.x=0,this.y=0,this.width=r,this.height=o,this.halfWidth=Math.floor(.5*r),this.halfHeight=Math.floor(.5*o),this.centerX=Math.floor(r/2),this.centerY=Math.floor(o/2),this.pivotX=0,this.pivotY=0,this.customPivot=!1,this.rotated=!1,this.autoRound=-1,this.customData={},this.data={cut:{x:n,y:s,w:r,h:o,r:n+r,b:s+o},trim:!1,sourceSize:{w:r,h:o},spriteSourceSize:{x:0,y:0,w:r,h:o},uvs:{x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},radius:.5*Math.sqrt(r*r+o*o),drawImage:{sx:n,sy:s,sWidth:r,sHeight:o,dWidth:r,dHeight:o}},this.updateUVs()},setTrim:function(t,e,i,n,s,r){var o=this.data,a=o.spriteSourceSize;return o.trim=!0,o.sourceSize.w=t,o.sourceSize.h=e,a.x=i,a.y=n,a.w=s,a.h=r,this.x=i,this.y=n,this.width=s,this.height=r,this.halfWidth=.5*s,this.halfHeight=.5*r,this.centerX=Math.floor(s/2),this.centerY=Math.floor(r/2),this.updateUVs()},updateUVs:function(){var t=this.cutX,e=this.cutY,i=this.cutWidth,n=this.cutHeight,s=this.data.drawImage;s.sWidth=i,s.sHeight=n,s.dWidth=i,s.dHeight=n;var r=this.source.width,o=this.source.height,a=this.data.uvs;return a.x0=t/r,a.y0=e/o,a.x1=t/r,a.y1=(e+n)/o,a.x2=(t+i)/r,a.y2=(e+n)/o,a.x3=(t+i)/r,a.y3=e/o,this},updateUVsInverted:function(){var t=this.source.width,e=this.source.height,i=this.data.uvs;return i.x3=(this.cutX+this.cutHeight)/t,i.y3=(this.cutY+this.cutWidth)/e,i.x2=this.cutX/t,i.y2=(this.cutY+this.cutWidth)/e,i.x1=this.cutX/t,i.y1=this.cutY/e,i.x0=(this.cutX+this.cutHeight)/t,i.y0=this.cutY/e,this},clone:function(){var t=new r(this.texture,this.name,this.sourceIndex);return t.cutX=this.cutX,t.cutY=this.cutY,t.cutWidth=this.cutWidth,t.cutHeight=this.cutHeight,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t.halfWidth=this.halfWidth,t.halfHeight=this.halfHeight,t.centerX=this.centerX,t.centerY=this.centerY,t.rotated=this.rotated,t.data=s(!0,t.data,this.data),t.updateUVs(),t},destroy:function(){this.texture=null,this.source=null},realWidth:{get:function(){return this.data.sourceSize.w}},realHeight:{get:function(){return this.data.sourceSize.h}},uvs:{get:function(){return this.data.uvs}},radius:{get:function(){return this.data.radius}},trimmed:{get:function(){return this.data.trim}},canvasData:{get:function(){return this.data.drawImage}}});t.exports=r},function(t,e,i){var n=i(0),s=i(75),r=i(797),o=i(796),a=i(303),h=i(284),l=new n({initialize:function(t,e){this.scene=t,this.game,this.config=e,this.settings=h.create(e),this.canvas,this.context,this.anims,this.cache,this.plugins,this.registry,this.sound,this.textures,this.add,this.cameras,this.displayList,this.events,this.make,this.scenePlugin,this.updateList},init:function(t){this.settings.status=s.INIT,this.game=t,this.canvas=t.canvas,this.context=t.context;var e=t.plugins;this.plugins=e,e.installGlobal(this,a.Global),e.installLocal(this,a.CoreScene),e.installLocal(this,o(this)),e.installLocal(this,r(this)),this.events.emit("boot",this),this.settings.isBooted=!0},install:function(t){Array.isArray(t)||(t=[t]),this.plugins.installLocal(this,t)},step:function(t,e){this.events.emit("preupdate",t,e),this.events.emit("update",t,e),this.scene.update.call(this.scene,t,e),this.events.emit("postupdate",t,e)},render:function(t){var e=this.displayList;e.depthSort(),this.cameras.render(t,e),this.events.emit("render",t)},queueDepthSort:function(){this.displayList.queueDepthSort()},depthSort:function(){this.displayList.depthSort()},pause:function(){return this.settings.active&&(this.settings.status=s.PAUSED,this.settings.active=!1,this.events.emit("pause",this)),this},resume:function(){return this.settings.active||(this.settings.status=s.RUNNING,this.settings.active=!0,this.events.emit("resume",this)),this},sleep:function(){return this.settings.status=s.SLEEPING,this.settings.active=!1,this.settings.visible=!1,this.events.emit("sleep",this),this},wake:function(){return this.settings.status=s.RUNNING,this.settings.active=!0,this.settings.visible=!0,this.events.emit("wake",this),this},isSleeping:function(){return this.settings.status===s.SLEEPING},isActive:function(){return this.settings.status===s.RUNNING},isVisible:function(){return this.settings.visible},setVisible:function(t){return this.settings.visible=t,this},setActive:function(t){return t?this.resume():this.pause()},start:function(t){this.settings.status=s.START,this.settings.data=t,this.settings.active=!0,this.settings.visible=!0,this.events.emit("start",this)},resize:function(t,e){this.events.emit("resize",t,e)},shutdown:function(){this.settings.status=s.SHUTDOWN,this.settings.active=!1,this.settings.visible=!1,this.events.emit("shutdown",this)},destroy:function(){this.settings.status=s.DESTROYED,this.settings.active=!1,this.settings.visible=!1,this.events.emit("destroy",this)}});t.exports=l},function(t,e){t.exports={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PRINT_SCREEN:42,INSERT:45,DELETE:46,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,SEMICOLON:186,PLUS:187,COMMA:188,MINUS:189,PERIOD:190,FORWARD_SLASH:191,BACK_SLASH:220,QUOTES:222,BACKTICK:192,OPEN_BRACKET:219,CLOSED_BRACKET:221}},function(t,e){t.exports={ARC:0,BEGIN_PATH:1,CLOSE_PATH:2,FILL_RECT:3,LINE_TO:4,MOVE_TO:5,LINE_STYLE:6,FILL_STYLE:7,FILL_PATH:8,STROKE_PATH:9,FILL_TRIANGLE:10,STROKE_TRIANGLE:11,LINE_FX_TO:12,MOVE_FX_TO:13,SAVE:14,RESTORE:15,TRANSLATE:16,SCALE:17,ROTATE:18}},function(t,e){t.exports=function(t,e){return t>0&&0==(t&t-1)&&e>0&&0==(e&e-1)}},function(t,e,i){var n=i(76),s=i(100),r=i(23),o={canvas:!1,canvasBitBltShift:null,file:!1,fileSystem:!1,getUserMedia:!0,littleEndian:!1,localStorage:!1,pointerLock:!1,support32bit:!1,vibration:!1,webGL:!1,worker:!1};t.exports=function(){o.canvas=!!window.CanvasRenderingContext2D||n.cocoonJS;try{o.localStorage=!!localStorage.getItem}catch(t){o.localStorage=!1}o.file=!!(window.File&&window.FileReader&&window.FileList&&window.Blob),o.fileSystem=!!window.requestFileSystem;var t,e,i,a=!1;return o.webGL=function(){if(window.WebGLRenderingContext)try{var t=r.createWebGL(this);n.cocoonJS&&(t.screencanvas=!1);var e=t.getContext("webgl")||t.getContext("experimental-webgl"),i=r.create2D(this),s=i.getContext("2d").createImageData(1,1);return a=s.data instanceof Uint8ClampedArray,r.remove(t),r.remove(i),!!e}catch(t){return!1}return!1}(),o.worker=!!window.Worker,o.pointerLock="pointerLockElement"in document||"mozPointerLockElement"in document||"webkitPointerLockElement"in document,navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia||navigator.oGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,o.getUserMedia=o.getUserMedia&&!!navigator.getUserMedia&&!!window.URL,s.firefox&&s.firefoxVersion<21&&(o.getUserMedia=!1),!n.iOS&&(s.ie||s.firefox||s.chrome)&&(o.canvasBitBltShift=!0),(s.safari||s.mobileSafari)&&(o.canvasBitBltShift=!1),navigator.vibrate=navigator.vibrate||navigator.webkitVibrate||navigator.mozVibrate||navigator.msVibrate,navigator.vibrate&&(o.vibration=!0),"undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint32Array&&(o.littleEndian=(t=new ArrayBuffer(4),e=new Uint8Array(t),i=new Uint32Array(t),e[0]=161,e[1]=178,e[2]=195,e[3]=212,3569595041===i[0]||2712847316!==i[0]&&null)),o.support32bit="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof Int32Array&&null!==o.littleEndian&&a,o}()},function(t,e){t.exports=function(t,e,i){var n;return void 0===i&&(i=!0),e&&("string"==typeof e?n=document.getElementById(e):"object"==typeof e&&1===e.nodeType&&(n=e)),n||(n=document.body),i&&n.style&&(n.style.overflow="hidden"),n.appendChild(t),t}},function(t,e){t.exports=function(t,e,i){return(e-t)*i+t}},function(t,e){t.exports=function(t,e,i,n,s){var r=.5*(n-e),o=.5*(s-i),a=t*t;return(2*i-2*n+r+o)*(t*a)+(-3*i+3*n-2*r-o)*a+r*t+i}},function(t,e,i){var n=i(10);t.exports=function(t,e){if(void 0===e&&(e=new n),0===t.length)return e;for(var i,s,r,o=Number.MAX_VALUE,a=Number.MAX_VALUE,h=Number.MIN_SAFE_INTEGER,l=Number.MIN_SAFE_INTEGER,u=0;u0&&(s=1/Math.sqrt(s),this.x=t*s,this.y=e*s,this.z=i*s,this.w=n*s),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z,r=this.w;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this.w=r+e*(t.w-r),this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z||1,this.w*=t.w||1,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z||1,this.w/=t.w||1,this},distance:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0,s=t.w-this.w||0;return Math.sqrt(e*e+i*i+n*n+s*s)},distanceSq:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0,s=t.w-this.w||0;return e*e+i*i+n*n+s*s},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},transformMat4:function(t){var e=this.x,i=this.y,n=this.z,s=this.w,r=t.val;return this.x=r[0]*e+r[4]*i+r[8]*n+r[12]*s,this.y=r[1]*e+r[5]*i+r[9]*n+r[13]*s,this.z=r[2]*e+r[6]*i+r[10]*n+r[14]*s,this.w=r[3]*e+r[7]*i+r[11]*n+r[15]*s,this},transformQuat:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z,a=t.w,h=a*e+r*n-o*i,l=a*i+o*e-s*n,u=a*n+s*i-r*e,c=-s*e-r*i-o*n;return this.x=h*a+c*-s+l*-o-u*-r,this.y=l*a+c*-r+u*-s-h*-o,this.z=u*a+c*-o+h*-r-l*-s,this},reset:function(){return this.x=0,this.y=0,this.z=0,this.w=0,this}});n.prototype.sub=n.prototype.subtract,n.prototype.mul=n.prototype.multiply,n.prototype.div=n.prototype.divide,n.prototype.dist=n.prototype.distance,n.prototype.distSq=n.prototype.distanceSq,n.prototype.len=n.prototype.length,n.prototype.lenSq=n.prototype.lengthSq,t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t){this.val=new Float32Array(16),t?this.copy(t):this.identity()},clone:function(){return new n(this)},set:function(t){return this.copy(t)},copy:function(t){var e=this.val,i=t.val;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this},fromArray:function(t){var e=this.val;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],this},zero:function(){var t=this.val;return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=0,this},xyz:function(t,e,i){this.identity();var n=this.val;return n[12]=t,n[13]=e,n[14]=i,this},scaling:function(t,e,i){this.zero();var n=this.val;return n[0]=t,n[5]=e,n[10]=i,n[15]=1,this},identity:function(){var t=this.val;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},transpose:function(){var t=this.val,e=t[1],i=t[2],n=t[3],s=t[6],r=t[7],o=t[11];return t[1]=t[4],t[2]=t[8],t[3]=t[12],t[4]=e,t[6]=t[9],t[7]=t[13],t[8]=i,t[9]=s,t[11]=t[14],t[12]=n,t[13]=r,t[14]=o,this},invert:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],g=t[14],v=t[15],y=e*o-i*r,m=e*a-n*r,x=e*h-s*r,b=i*a-n*o,w=i*h-s*o,T=n*h-s*a,S=l*p-u*f,A=l*g-c*f,C=l*v-d*f,M=u*g-c*p,_=u*v-d*p,E=c*v-d*g,P=y*E-m*_+x*M+b*C-w*A+T*S;return P?(P=1/P,t[0]=(o*E-a*_+h*M)*P,t[1]=(n*_-i*E-s*M)*P,t[2]=(p*T-g*w+v*b)*P,t[3]=(c*w-u*T-d*b)*P,t[4]=(a*C-r*E-h*A)*P,t[5]=(e*E-n*C+s*A)*P,t[6]=(g*x-f*T-v*m)*P,t[7]=(l*T-c*x+d*m)*P,t[8]=(r*_-o*C+h*S)*P,t[9]=(i*C-e*_-s*S)*P,t[10]=(f*w-p*x+v*y)*P,t[11]=(u*x-l*w-d*y)*P,t[12]=(o*A-r*M-a*S)*P,t[13]=(e*M-i*A+n*S)*P,t[14]=(p*m-f*b-g*y)*P,t[15]=(l*b-u*m+c*y)*P,this):null},adjoint:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],g=t[14],v=t[15];return t[0]=o*(c*v-d*g)-u*(a*v-h*g)+p*(a*d-h*c),t[1]=-(i*(c*v-d*g)-u*(n*v-s*g)+p*(n*d-s*c)),t[2]=i*(a*v-h*g)-o*(n*v-s*g)+p*(n*h-s*a),t[3]=-(i*(a*d-h*c)-o*(n*d-s*c)+u*(n*h-s*a)),t[4]=-(r*(c*v-d*g)-l*(a*v-h*g)+f*(a*d-h*c)),t[5]=e*(c*v-d*g)-l*(n*v-s*g)+f*(n*d-s*c),t[6]=-(e*(a*v-h*g)-r*(n*v-s*g)+f*(n*h-s*a)),t[7]=e*(a*d-h*c)-r*(n*d-s*c)+l*(n*h-s*a),t[8]=r*(u*v-d*p)-l*(o*v-h*p)+f*(o*d-h*u),t[9]=-(e*(u*v-d*p)-l*(i*v-s*p)+f*(i*d-s*u)),t[10]=e*(o*v-h*p)-r*(i*v-s*p)+f*(i*h-s*o),t[11]=-(e*(o*d-h*u)-r*(i*d-s*u)+l*(i*h-s*o)),t[12]=-(r*(u*g-c*p)-l*(o*g-a*p)+f*(o*c-a*u)),t[13]=e*(u*g-c*p)-l*(i*g-n*p)+f*(i*c-n*u),t[14]=-(e*(o*g-a*p)-r*(i*g-n*p)+f*(i*a-n*o)),t[15]=e*(o*c-a*u)-r*(i*c-n*u)+l*(i*a-n*o),this},determinant:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],g=t[14],v=t[15];return(e*o-i*r)*(c*v-d*g)-(e*a-n*r)*(u*v-d*p)+(e*h-s*r)*(u*g-c*p)+(i*a-n*o)*(l*v-d*f)-(i*h-s*o)*(l*g-c*f)+(n*h-s*a)*(l*p-u*f)},multiply:function(t){var e=this.val,i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],h=e[6],l=e[7],u=e[8],c=e[9],d=e[10],f=e[11],p=e[12],g=e[13],v=e[14],y=e[15],m=t.val,x=m[0],b=m[1],w=m[2],T=m[3];return e[0]=x*i+b*o+w*u+T*p,e[1]=x*n+b*a+w*c+T*g,e[2]=x*s+b*h+w*d+T*v,e[3]=x*r+b*l+w*f+T*y,x=m[4],b=m[5],w=m[6],T=m[7],e[4]=x*i+b*o+w*u+T*p,e[5]=x*n+b*a+w*c+T*g,e[6]=x*s+b*h+w*d+T*v,e[7]=x*r+b*l+w*f+T*y,x=m[8],b=m[9],w=m[10],T=m[11],e[8]=x*i+b*o+w*u+T*p,e[9]=x*n+b*a+w*c+T*g,e[10]=x*s+b*h+w*d+T*v,e[11]=x*r+b*l+w*f+T*y,x=m[12],b=m[13],w=m[14],T=m[15],e[12]=x*i+b*o+w*u+T*p,e[13]=x*n+b*a+w*c+T*g,e[14]=x*s+b*h+w*d+T*v,e[15]=x*r+b*l+w*f+T*y,this},multiplyLocal:function(t){var e=[],i=this.val,n=t.val;return e[0]=i[0]*n[0]+i[1]*n[4]+i[2]*n[8]+i[3]*n[12],e[1]=i[0]*n[1]+i[1]*n[5]+i[2]*n[9]+i[3]*n[13],e[2]=i[0]*n[2]+i[1]*n[6]+i[2]*n[10]+i[3]*n[14],e[3]=i[0]*n[3]+i[1]*n[7]+i[2]*n[11]+i[3]*n[15],e[4]=i[4]*n[0]+i[5]*n[4]+i[6]*n[8]+i[7]*n[12],e[5]=i[4]*n[1]+i[5]*n[5]+i[6]*n[9]+i[7]*n[13],e[6]=i[4]*n[2]+i[5]*n[6]+i[6]*n[10]+i[7]*n[14],e[7]=i[4]*n[3]+i[5]*n[7]+i[6]*n[11]+i[7]*n[15],e[8]=i[8]*n[0]+i[9]*n[4]+i[10]*n[8]+i[11]*n[12],e[9]=i[8]*n[1]+i[9]*n[5]+i[10]*n[9]+i[11]*n[13],e[10]=i[8]*n[2]+i[9]*n[6]+i[10]*n[10]+i[11]*n[14],e[11]=i[8]*n[3]+i[9]*n[7]+i[10]*n[11]+i[11]*n[15],e[12]=i[12]*n[0]+i[13]*n[4]+i[14]*n[8]+i[15]*n[12],e[13]=i[12]*n[1]+i[13]*n[5]+i[14]*n[9]+i[15]*n[13],e[14]=i[12]*n[2]+i[13]*n[6]+i[14]*n[10]+i[15]*n[14],e[15]=i[12]*n[3]+i[13]*n[7]+i[14]*n[11]+i[15]*n[15],this.fromArray(e)},translate:function(t){var e=t.x,i=t.y,n=t.z,s=this.val;return s[12]=s[0]*e+s[4]*i+s[8]*n+s[12],s[13]=s[1]*e+s[5]*i+s[9]*n+s[13],s[14]=s[2]*e+s[6]*i+s[10]*n+s[14],s[15]=s[3]*e+s[7]*i+s[11]*n+s[15],this},scale:function(t){var e=t.x,i=t.y,n=t.z,s=this.val;return s[0]=s[0]*e,s[1]=s[1]*e,s[2]=s[2]*e,s[3]=s[3]*e,s[4]=s[4]*i,s[5]=s[5]*i,s[6]=s[6]*i,s[7]=s[7]*i,s[8]=s[8]*n,s[9]=s[9]*n,s[10]=s[10]*n,s[11]=s[11]*n,this},makeRotationAxis:function(t,e){var i=Math.cos(e),n=Math.sin(e),s=1-i,r=t.x,o=t.y,a=t.z,h=s*r,l=s*o;return this.set(h*r+i,h*o-n*a,h*a+n*o,0,h*o+n*a,l*o+i,l*a-n*r,0,h*a-n*o,l*a+n*r,s*a*a+i,0,0,0,0,1),this},rotate:function(t,e){var i=this.val,n=e.x,s=e.y,r=e.z,o=Math.sqrt(n*n+s*s+r*r);if(Math.abs(o)<1e-6)return null;n*=o=1/o,s*=o,r*=o;var a=Math.sin(t),h=Math.cos(t),l=1-h,u=i[0],c=i[1],d=i[2],f=i[3],p=i[4],g=i[5],v=i[6],y=i[7],m=i[8],x=i[9],b=i[10],w=i[11],T=n*n*l+h,S=s*n*l+r*a,A=r*n*l-s*a,C=n*s*l-r*a,M=s*s*l+h,_=r*s*l+n*a,E=n*r*l+s*a,P=s*r*l-n*a,L=r*r*l+h;return i[0]=u*T+p*S+m*A,i[1]=c*T+g*S+x*A,i[2]=d*T+v*S+b*A,i[3]=f*T+y*S+w*A,i[4]=u*C+p*M+m*_,i[5]=c*C+g*M+x*_,i[6]=d*C+v*M+b*_,i[7]=f*C+y*M+w*_,i[8]=u*E+p*P+m*L,i[9]=c*E+g*P+x*L,i[10]=d*E+v*P+b*L,i[11]=f*E+y*P+w*L,this},rotateX:function(t){var e=this.val,i=Math.sin(t),n=Math.cos(t),s=e[4],r=e[5],o=e[6],a=e[7],h=e[8],l=e[9],u=e[10],c=e[11];return e[4]=s*n+h*i,e[5]=r*n+l*i,e[6]=o*n+u*i,e[7]=a*n+c*i,e[8]=h*n-s*i,e[9]=l*n-r*i,e[10]=u*n-o*i,e[11]=c*n-a*i,this},rotateY:function(t){var e=this.val,i=Math.sin(t),n=Math.cos(t),s=e[0],r=e[1],o=e[2],a=e[3],h=e[8],l=e[9],u=e[10],c=e[11];return e[0]=s*n-h*i,e[1]=r*n-l*i,e[2]=o*n-u*i,e[3]=a*n-c*i,e[8]=s*i+h*n,e[9]=r*i+l*n,e[10]=o*i+u*n,e[11]=a*i+c*n,this},rotateZ:function(t){var e=this.val,i=Math.sin(t),n=Math.cos(t),s=e[0],r=e[1],o=e[2],a=e[3],h=e[4],l=e[5],u=e[6],c=e[7];return e[0]=s*n+h*i,e[1]=r*n+l*i,e[2]=o*n+u*i,e[3]=a*n+c*i,e[4]=h*n-s*i,e[5]=l*n-r*i,e[6]=u*n-o*i,e[7]=c*n-a*i,this},fromRotationTranslation:function(t,e){var i=this.val,n=t.x,s=t.y,r=t.z,o=t.w,a=n+n,h=s+s,l=r+r,u=n*a,c=n*h,d=n*l,f=s*h,p=s*l,g=r*l,v=o*a,y=o*h,m=o*l;return i[0]=1-(f+g),i[1]=c+m,i[2]=d-y,i[3]=0,i[4]=c-m,i[5]=1-(u+g),i[6]=p+v,i[7]=0,i[8]=d+y,i[9]=p-v,i[10]=1-(u+f),i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this},fromQuat:function(t){var e=this.val,i=t.x,n=t.y,s=t.z,r=t.w,o=i+i,a=n+n,h=s+s,l=i*o,u=i*a,c=i*h,d=n*a,f=n*h,p=s*h,g=r*o,v=r*a,y=r*h;return e[0]=1-(d+p),e[1]=u+y,e[2]=c-v,e[3]=0,e[4]=u-y,e[5]=1-(l+p),e[6]=f+g,e[7]=0,e[8]=c+v,e[9]=f-g,e[10]=1-(l+d),e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},frustum:function(t,e,i,n,s,r){var o=this.val,a=1/(e-t),h=1/(n-i),l=1/(s-r);return o[0]=2*s*a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=2*s*h,o[6]=0,o[7]=0,o[8]=(e+t)*a,o[9]=(n+i)*h,o[10]=(r+s)*l,o[11]=-1,o[12]=0,o[13]=0,o[14]=r*s*2*l,o[15]=0,this},perspective:function(t,e,i,n){var s=this.val,r=1/Math.tan(t/2),o=1/(i-n);return s[0]=r/e,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=r,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=(n+i)*o,s[11]=-1,s[12]=0,s[13]=0,s[14]=2*n*i*o,s[15]=0,this},perspectiveLH:function(t,e,i,n){var s=this.val;return s[0]=2*i/t,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=2*i/e,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=-n/(i-n),s[11]=1,s[12]=0,s[13]=0,s[14]=i*n/(i-n),s[15]=0,this},ortho:function(t,e,i,n,s,r){var o=this.val,a=t-e,h=i-n,l=s-r;return a=0===a?a:1/a,h=0===h?h:1/h,l=0===l?l:1/l,o[0]=-2*a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=-2*h,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=2*l,o[11]=0,o[12]=(t+e)*a,o[13]=(n+i)*h,o[14]=(r+s)*l,o[15]=1,this},lookAt:function(t,e,i){var n=this.val,s=t.x,r=t.y,o=t.z,a=i.x,h=i.y,l=i.z,u=e.x,c=e.y,d=e.z;if(Math.abs(s-u)<1e-6&&Math.abs(r-c)<1e-6&&Math.abs(o-d)<1e-6)return this.identity();var f=s-u,p=r-c,g=o-d,v=1/Math.sqrt(f*f+p*p+g*g),y=h*(g*=v)-l*(p*=v),m=l*(f*=v)-a*g,x=a*p-h*f;(v=Math.sqrt(y*y+m*m+x*x))?(y*=v=1/v,m*=v,x*=v):(y=0,m=0,x=0);var b=p*x-g*m,w=g*y-f*x,T=f*m-p*y;return(v=Math.sqrt(b*b+w*w+T*T))?(b*=v=1/v,w*=v,T*=v):(b=0,w=0,T=0),n[0]=y,n[1]=b,n[2]=f,n[3]=0,n[4]=m,n[5]=w,n[6]=p,n[7]=0,n[8]=x,n[9]=T,n[10]=g,n[11]=0,n[12]=-(y*s+m*r+x*o),n[13]=-(b*s+w*r+T*o),n[14]=-(f*s+p*r+g*o),n[15]=1,this},yawPitchRoll:function(t,e,i){this.zero(),s.zero(),r.zero();var n=this.val,o=s.val,a=r.val,h=Math.sin(i),l=Math.cos(i);return n[10]=1,n[15]=1,n[0]=l,n[1]=h,n[4]=-h,n[5]=l,h=Math.sin(e),l=Math.cos(e),o[0]=1,o[15]=1,o[5]=l,o[10]=l,o[9]=-h,o[6]=h,h=Math.sin(t),l=Math.cos(t),a[5]=1,a[15]=1,a[0]=l,a[2]=-h,a[8]=h,a[10]=l,this.multiplyLocal(s),this.multiplyLocal(r),this},setWorldMatrix:function(t,e,i,n,o){return this.yawPitchRoll(t.y,t.x,t.z),s.scaling(i.x,i.y,i.z),r.xyz(e.x,e.y,e.z),this.multiplyLocal(s),this.multiplyLocal(r),void 0!==n&&this.multiplyLocal(n),void 0!==o&&this.multiplyLocal(o),this}}),s=new n,r=new n;t.exports=n},function(t,e,i){var n=i(0),s=i(153),r=i(330),o=i(329),a=i(328),h=i(63),l=i(101),u=i(6),c=i(57),d=i(152),f=new c,p=new d,g=new c,v=new c,y=new s,m=new n({initialize:function(t){this.scene=t,this.displayList=t.sys.displayList,this.updateList=t.sys.updateList,this.name="",this.direction=new c(0,0,-1),this.up=new c(0,1,0),this.position=new c,this.pixelScale=128,this.projection=new s,this.view=new s,this.combined=new s,this.invProjectionView=new s,this.near=1,this.far=100,this.ray={origin:new c,direction:new c},this.viewportWidth=0,this.viewportHeight=0,this.billboardMatrixDirty=!0,this.children=new h},setPosition:function(t,e,i){return this.position.set(t,e,i),this.update()},setScene:function(t){return this.scene=t,this},setPixelScale:function(t){return this.pixelScale=t,this.update()},add:function(t){return this.children.set(t),this.updateChildren(),t},remove:function(t){return this.displayList.remove(t.gameObject),this.updateList.remove(t.gameObject),this.children.delete(t),this},clear:function(){for(var t=this.getChildren(),e=0;e-y||T>-m||w-y||A>-m||S-y||T>-m||w-y||A>-m||S-v&&A*n+C*r+h>-y&&(A+v)*i+(C+y)*s+a0?this:(this._fadeRed=e,this._fadeGreen=i,this._fadeBlue=n,this._fadeCallback=r,this._fadeDuration=t,this._fadeAlpha=Number.MIN_VALUE,this)},flash:function(t,e,i,n,s,r){return t||(t=Number.MIN_VALUE),void 0===e&&(e=1),void 0===i&&(i=1),void 0===n&&(n=1),void 0===s&&(s=!1),void 0===r&&(r=null),!s&&this._flashAlpha>0?this:(this._flashRed=e,this._flashGreen=i,this._flashBlue=n,this._flashCallback=r,this._flashDuration=t,this._flashAlpha=1,this)},shake:function(t,e,i,n){return t||(t=Number.MIN_VALUE),void 0===e&&(e=.05),void 0===i&&(i=!1),void 0===n&&(n=null),i||0===this._shakeOffsetX&&0===this._shakeOffsetY?(this._shakeDuration=t,this._shakeIntensity=e,this._shakeOffsetX=0,this._shakeOffsetY=0,this._shakeCallback=n,this):this},getWorldPoint:function(t,e,i){void 0===i&&(i=new h);var n=this.matrix.matrix,s=n[0],r=n[1],o=n[2],a=n[3],l=n[4],u=n[5],c=s*a-r*o;if(!c)return i.x=t,i.y=e,i;var d=a*(c=1/c),f=-r*c,p=-o*c,g=s*c,v=(o*u-a*l)*c,y=(r*l-s*u)*c,m=Math.cos(this.rotation),x=Math.sin(this.rotation),b=this.zoom,w=this.scrollX,T=this.scrollY,S=t+(w*m-T*x)*b,A=e+(w*x+T*m)*b;return i.x=S*d+A*p+v,i.y=S*f+A*g+y,i},ignore:function(t){if(t instanceof Array)for(var e=0;eu&&(this.scrollX=u),this.scrollYc&&(this.scrollY=c)}this.roundPixels&&(this.scrollX=Math.round(this.scrollX),this.scrollY=Math.round(this.scrollY)),r.loadIdentity(),r.scale(e,e),r.translate(this.x+o,this.y+a),r.rotate(this.rotation),r.scale(s,s),r.translate(-o,-a),r.translate(this._shakeOffsetX,this._shakeOffsetY)},removeBounds:function(){return this.useBounds=!1,this._bounds.setEmpty(),this},setAngle:function(t){return void 0===t&&(t=0),this.rotation=s(t),this},setBackgroundColor:function(t){return void 0===t&&(t="rgba(0,0,0,0)"),this.backgroundColor=a(t),this.transparent=0===this.backgroundColor.alpha,this},setBounds:function(t,e,i,n){return this._bounds.setTo(t,e,i,n),this.useBounds=!0,this},setName:function(t){return void 0===t&&(t=""),this.name=t,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setRotation:function(t){return void 0===t&&(t=0),this.rotation=t,this},setRoundPixels:function(t){return this.roundPixels=t,this},setScene:function(t){return this.scene=t,this},setScroll:function(t,e){return void 0===e&&(e=t),this.scrollX=t,this.scrollY=e,this},setSize:function(t,e){return void 0===e&&(e=t),this.width=t,this.height=e,this},setViewport:function(t,e,i,n){return this.x=t,this.y=e,this.width=i,this.height=n,this},setZoom:function(t){return void 0===t&&(t=1),this.zoom=t,this},startFollow:function(t,e){return void 0===e&&(e=!1),this._follow=t,this.roundPixels=e,this},stopFollow:function(){return this._follow=null,this},toJSON:function(){var t={name:this.name,x:this.x,y:this.y,width:this.width,height:this.height,zoom:this.zoom,rotation:this.rotation,roundPixels:this.roundPixels,scrollX:this.scrollX,scrollY:this.scrollY,backgroundColor:this.backgroundColor.rgba};return this.useBounds&&(t.bounds={x:this._bounds.x,y:this._bounds.y,width:this._bounds.width,height:this._bounds.height}),t},resetFX:function(){return this._flashAlpha=0,this._fadeAlpha=0,this._shakeOffsetX=0,this._shakeOffsetY=0,this._shakeDuration=0,this},update:function(t,e){if(this._flashAlpha>0&&(this._flashAlpha-=e/this._flashDuration,this._flashAlpha<=0&&(this._flashAlpha=0,this._flashCallback))){var i=this._flashCallback;this._flashCallback=null,i(this)}if(this._fadeAlpha>0&&this._fadeAlpha<1&&(this._fadeAlpha+=e/this._fadeDuration,this._fadeAlpha>=1&&(this._fadeAlpha=1,this._fadeCallback))){var n=this._fadeCallback;this._fadeCallback=null,n(this)}if(this._shakeDuration>0){var s=this._shakeIntensity;if(this._shakeDuration-=e,this._shakeDuration<=0){if(this._shakeOffsetX=0,this._shakeOffsetY=0,this._shakeCallback){var r=this._shakeCallback;this._shakeCallback=null,r(this)}}else this._shakeOffsetX=(Math.random()*s*this.width*2-s*this.width)*this.zoom,this._shakeOffsetY=(Math.random()*s*this.height*2-s*this.height)*this.zoom,this.roundPixels&&(this._shakeOffsetX|=0,this._shakeOffsetY|=0)}},destroy:function(){this._bounds=void 0,this.matrix=void 0,this.culledObjects=[],this.scene=void 0}});t.exports=l},function(t,e){t.exports=function(t,e,i,n){void 0===e&&(e=0),void 0===i&&(i=" "),void 0===n&&(n=3);var s=0;if(e+1>=(t=t.toString()).length)switch(n){case 1:t=new Array(e+1-t.length).join(i)+t;break;case 3:var r=Math.ceil((s=e-t.length)/2);t=new Array(s-r+1).join(i)+t+new Array(r+1).join(i);break;default:t+=new Array(e+1-t.length).join(i)}return t}},function(t,e,i){var n=new(i(0))({initialize:function(t){if(this.entries={},this.size=0,Array.isArray(t))for(var e=0;e=1&&(a=1-a,h=1-h),e.x=t.x1+(i*a+r*h),e.y=t.y1+(s*a+o*h),e}},function(t,e,i){var n=i(4);t.exports=function(t,e){void 0===e&&(e=new n);var i=Math.random()*Math.PI*2,s=Math.sqrt(Math.random());return e.x=t.x+s*Math.cos(i)*t.width/2,e.y=t.y+s*Math.sin(i)*t.height/2,e}},function(t,e,i){var n=i(4);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.x+Math.random()*t.width,e.y=t.y+Math.random()*t.height,e}},function(t,e,i){var n=i(4);t.exports=function(t,e){void 0===e&&(e=new n);var i=Math.random();return e.x=t.x1+i*(t.x2-t.x1),e.y=t.y1+i*(t.y2-t.y1),e}},function(t,e,i){var n=i(77),s=i(4);t.exports=function(t,e,i,r){void 0===r&&(r=[]),e||(e=n(t)/i);for(var o=t.x1,a=t.y1,h=t.x2,l=t.y2,u=0;u=1)return i.x=t.x,i.y=t.y,i;var r=n(t)*e;return e>.5?(r-=t.width+t.height)<=t.width?(i.x=t.right-r,i.y=t.bottom):(i.x=t.x,i.y=t.bottom-(r-t.width)):r<=t.width?(i.x=t.x+r,i.y=t.y):(i.x=t.right,i.y=t.y+(r-t.width)),i}},function(t,e,i){var n=i(4);t.exports=function(t,e){void 0===e&&(e=new n);var i=2*Math.PI*Math.random(),s=Math.random()+Math.random(),r=s>1?2-s:s,o=r*Math.cos(i),a=r*Math.sin(i);return e.x=t.x+o*t.radius,e.y=t.y+a*t.radius,e}},function(t,e,i){var n=i(4);t.exports=function(t,e,i){return void 0===i&&(i=new n),i.x=t.x+t.radius*Math.cos(e),i.y=t.y+t.radius*Math.sin(e),i}},function(t,e){t.exports={TOP_LEFT:0,TOP_CENTER:1,TOP_RIGHT:2,LEFT_TOP:3,LEFT_CENTER:4,LEFT_BOTTOM:5,CENTER:6,RIGHT_TOP:7,RIGHT_CENTER:8,RIGHT_BOTTOM:9,BOTTOM_LEFT:10,BOTTOM_CENTER:11,BOTTOM_RIGHT:12}},function(t,e,i){var n={};t.exports=n;var s=i(91),r=i(90),o=i(198),a=i(89),h=i(468),l=i(39);n._warming=.4,n._torqueDampen=1,n._minLength=1e-6,n.create=function(t){var e=t;e.bodyA&&!e.pointA&&(e.pointA={x:0,y:0}),e.bodyB&&!e.pointB&&(e.pointB={x:0,y:0});var i=e.bodyA?r.add(e.bodyA.position,e.pointA):e.pointA,n=e.bodyB?r.add(e.bodyB.position,e.pointB):e.pointB,s=r.magnitude(r.sub(i,n));e.length=void 0!==e.length?e.length:s,e.id=e.id||l.nextId(),e.label=e.label||"Constraint",e.type="constraint",e.stiffness=e.stiffness||(e.length>0?1:.7),e.damping=e.damping||0,e.angularStiffness=e.angularStiffness||0,e.angleA=e.bodyA?e.bodyA.angle:e.angleA,e.angleB=e.bodyB?e.bodyB.angle:e.angleB,e.plugin={};var o={visible:!0,lineWidth:2,strokeStyle:"#ffffff",type:"line",anchors:!0};return 0===e.length&&e.stiffness>.1?(o.type="pin",o.anchors=!1):e.stiffness<.9&&(o.type="spring"),e.render=l.extend(o,e.render),e},n.preSolveAll=function(t){for(var e=0;e0&&(c.position.x+=l.x,c.position.y+=l.y),0!==l.angle&&(s.rotate(c.vertices,l.angle,i.position),h.rotate(c.axes,l.angle),u>0&&r.rotateAbout(c.position,l.angle,i.position,c.position)),a.update(c.bounds,c.vertices,i.velocity)}l.angle*=n._warming,l.x*=n._warming,l.y*=n._warming}}}},function(t,e,i){var n={};t.exports=n;var s=i(39);n.on=function(t,e,i){for(var n,s=e.split(" "),r=0;r0?(n.textures[e-1]&&n.textures[e-1]!==t&&this.pushBatch(),i[i.length-1].textures[e-1]=t):(null!==n.texture&&n.texture!==t&&this.pushBatch(),i[i.length-1].texture=t),this},pushBatch:function(){var t={first:this.vertexCount,texture:null,textures:[]};this.batches.push(t)},flush:function(){if(this.flushLocked)return this;this.flushLocked=!0;var t,e,i,n=this.gl,s=this.renderer,r=this.vertexCount,o=this.topology,a=this.vertexSize,h=this.batches,l=0,u=null;if(0===h.length||0===r)return this.flushLocked=!1,this;n.bufferSubData(n.ARRAY_BUFFER,0,this.bytes.subarray(0,r*a));for(var c=0;c0){for(e=0;e0){for(e=0;e0&&(s.setTexture2D(u.texture,0),n.drawArrays(o,u.first,l)),this.vertexCount=0,h.length=0,this.pushBatch(),this.flushLocked=!1,this},onBind:function(){return h.prototype.onBind.call(this),this.mvpUpdate(),0===this.batches.length&&this.pushBatch(),this},resize:function(t,e,i){return h.prototype.resize.call(this,t,e,i),this.projOrtho(0,this.width,this.height,0,-1e3,1e3),this},drawStaticTilemapLayer:function(t){if(t.vertexCount>0){var e=this.vertexBuffer,i=this.gl,n=this.renderer,s=t.tileset.image.get();n.currentPipeline&&n.currentPipeline.vertexCount>0&&n.flush(),this.vertexBuffer=t.vertexBuffer,n.setPipeline(this),n.setTexture2D(s.source.glTexture,0),i.drawArrays(this.topology,0,t.vertexCount),this.vertexBuffer=e}this.viewIdentity(),this.modelIdentity()},drawEmitterManager:function(t,e){this.renderer.setPipeline(this);var i=this.renderer.config.roundPixels,n=t.emitters.list,s=n.length,r=this.vertexViewF32,o=this.vertexViewU32,a=this.renderer,h=this.maxQuads,l=e.scrollX,u=e.scrollY,c=e.matrix.matrix,d=c[0],f=c[1],p=c[2],g=c[3],v=c[4],y=c[5],m=Math.sin,x=Math.cos,b=this.vertexComponentCount,w=this.vertexCapacity,T=t.defaultFrame.source.glTexture;this.setTexture2D(T,0);for(var S=0;S=w&&(this.flush(),this.setTexture2D(T,0));for(var k=0;k<_;++k){for(var F=Math.min(M,h),O=0;O=w&&(this.flush(),this.setTexture2D(T,0))}}}this.setTexture2D(T,0)},drawBlitter:function(t,e){this.renderer.setPipeline(this);for(var i=this.renderer.config.roundPixels,n=a.getTintAppendFloatAlpha,s=this.vertexViewF32,r=this.vertexViewU32,o=t.getRenderList(),h=o.length,l=e.matrix.matrix,u=l[0],c=l[1],d=l[2],f=l[3],p=l[4],g=l[5],v=e.scrollX*t.scrollFactorX,y=e.scrollY*t.scrollFactorY,m=Math.ceil(h/this.maxQuads),x=0,b=t.x-v,w=t.y-y,T=0;T=this.vertexCapacity&&this.flush()}x+=S,h-=S,this.vertexCount>=this.vertexCapacity&&this.flush()}},batchSprite:function(t,e){this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var i,n=this.renderer.config.roundPixels,s=a.getTintAppendFloatAlpha,r=this.vertexViewF32,o=this.vertexViewU32,h=e.matrix.matrix,l=t.frame,u=l.texture.source[l.sourceIndex].glTexture,c=!!u.isRenderTexture,d=t.flipX,f=t.flipY^c,p=l.uvs,g=l.width*(d?-1:1),v=l.height*(f?-1:1),y=-t.displayOriginX+l.x+l.width*(d?1:0),m=-t.displayOriginY+l.y+l.height*(f?1:0),x=(n?0|y:y)+g,b=(n?0|m:m)+v,w=t.x-e.scrollX*t.scrollFactorX,T=t.y-e.scrollY*t.scrollFactorY,S=t.scaleX,A=t.scaleY,C=-t.rotation,M=t._alphaTL,_=t._alphaTR,E=t._alphaBL,P=t._alphaBR,L=t._tintTL,k=t._tintTR,F=t._tintBL,O=t._tintBR,R=Math.sin(C),B=Math.cos(C),I=B*S,D=-R*S,Y=R*A,z=B*A,X=w,N=T,V=h[0],W=h[1],G=h[2],U=h[3],j=I*V+D*G,H=I*W+D*U,q=Y*V+z*G,K=Y*W+z*U,J=X*V+N*G+h[4],Z=X*W+N*U+h[5],Q=y*j+m*q+J,$=y*H+m*K+Z,tt=y*j+b*q+J,et=y*H+b*K+Z,it=x*j+b*q+J,nt=x*H+b*K+Z,st=x*j+m*q+J,rt=x*H+m*K+Z,ot=s(L,M),at=s(k,_),ht=s(F,E),lt=s(O,P);n&&(Q|=0,$|=0,tt|=0,et|=0,it|=0,nt|=0,st|=0,rt|=0),this.setTexture2D(u,0),r[(i=this.vertexCount*this.vertexComponentCount)+0]=Q,r[i+1]=$,r[i+2]=p.x0,r[i+3]=p.y0,o[i+4]=ot,r[i+5]=tt,r[i+6]=et,r[i+7]=p.x1,r[i+8]=p.y1,o[i+9]=ht,r[i+10]=it,r[i+11]=nt,r[i+12]=p.x2,r[i+13]=p.y2,o[i+14]=lt,r[i+15]=Q,r[i+16]=$,r[i+17]=p.x0,r[i+18]=p.y0,o[i+19]=ot,r[i+20]=it,r[i+21]=nt,r[i+22]=p.x2,r[i+23]=p.y2,o[i+24]=lt,r[i+25]=st,r[i+26]=rt,r[i+27]=p.x3,r[i+28]=p.y3,o[i+29]=at,this.vertexCount+=6},batchMesh:function(t,e){var i=t.vertices,n=i.length,s=n/2|0;this.renderer.setPipeline(this),this.vertexCount+s>this.vertexCapacity&&this.flush();var r=this.renderer.config.roundPixels,o=a.getTintAppendFloatAlpha,h=t.uv,l=t.colors,u=t.alphas,c=this.vertexViewF32,d=this.vertexViewU32,f=e.matrix.matrix,p=t.frame,g=t.texture.source[p.sourceIndex].glTexture,v=t.x-e.scrollX*t.scrollFactorX,y=t.y-e.scrollY*t.scrollFactorY,m=t.scaleX,x=t.scaleY,b=-t.rotation,w=Math.sin(b),T=Math.cos(b),S=T*m,A=-w*m,C=w*x,M=T*x,_=v,E=y,P=f[0],L=f[1],k=f[2],F=f[3],O=S*P+A*k,R=S*L+A*F,B=C*P+M*k,I=C*L+M*F,D=_*P+E*k+f[4],Y=_*L+E*F+f[5],z=0;this.setTexture2D(g,0),z=this.vertexCount*this.vertexComponentCount;for(var X=0,N=0;Xthis.vertexCapacity&&this.flush();var i,n,s,r,o,h,l,u,c=this.renderer.config.roundPixels,d=t.text,f=d.length,p=a.getTintAppendFloatAlpha,g=this.vertexViewF32,v=this.vertexViewU32,y=e.matrix.matrix,m=e.width+50,x=e.height+50,b=t.frame,w=t.texture.source[b.sourceIndex],T=e.scrollX*t.scrollFactorX,S=e.scrollY*t.scrollFactorY,A=t.fontData,C=A.lineHeight,M=t.fontSize/A.size,_=A.chars,E=t.alpha,P=p(t._tintTL,E),L=p(t._tintTR,E),k=p(t._tintBL,E),F=p(t._tintBR,E),O=t.x,R=t.y,B=b.cutX,I=b.cutY,D=w.width,Y=w.height,z=w.glTexture,X=0,N=0,V=0,W=0,G=null,U=0,j=0,H=0,q=0,K=0,J=0,Z=0,Q=0,$=0,tt=0,et=0,it=0,nt=null,st=0,rt=O-T+b.x,ot=R-S+b.y,at=-t.rotation,ht=t.scaleX,lt=t.scaleY,ut=Math.sin(at),ct=Math.cos(at),dt=ct*ht,ft=-ut*ht,pt=ut*lt,gt=ct*lt,vt=rt,yt=ot,mt=y[0],xt=y[1],bt=y[2],wt=y[3],Tt=dt*mt+ft*bt,St=dt*xt+ft*wt,At=pt*mt+gt*bt,Ct=pt*xt+gt*wt,Mt=vt*mt+yt*bt+y[4],_t=vt*xt+yt*wt+y[5],Et=0;this.setTexture2D(z,0);for(var Pt=0;Ptm||n<-50||n>x)&&(s<-50||s>m||r<-50||r>x)&&(o<-50||o>m||h<-50||h>x)&&(l<-50||l>m||u<-50||u>x)||(this.vertexCount+6>this.vertexCapacity&&this.flush(),Et=this.vertexCount*this.vertexComponentCount,c&&(i|=0,n|=0,s|=0,r|=0,o|=0,h|=0,l|=0,u|=0),g[Et+0]=i,g[Et+1]=n,g[Et+2]=$,g[Et+3]=et,v[Et+4]=P,g[Et+5]=s,g[Et+6]=r,g[Et+7]=$,g[Et+8]=it,v[Et+9]=k,g[Et+10]=o,g[Et+11]=h,g[Et+12]=tt,g[Et+13]=it,v[Et+14]=F,g[Et+15]=i,g[Et+16]=n,g[Et+17]=$,g[Et+18]=et,v[Et+19]=P,g[Et+20]=o,g[Et+21]=h,g[Et+22]=tt,g[Et+23]=it,v[Et+24]=F,g[Et+25]=l,g[Et+26]=u,g[Et+27]=tt,g[Et+28]=et,v[Et+29]=L,this.vertexCount+=6))}}else X=0,V=0,N+=C,nt=null},batchDynamicBitmapText:function(t,e){this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var i,n,s,r,o,h,l,u,c,d,f,p,g,v,y=this.renderer.config.roundPixels,m=t.displayCallback,x=t.text,b=x.length,w=a.getTintAppendFloatAlpha,T=this.vertexViewF32,S=this.vertexViewU32,A=this.renderer,C=e.matrix.matrix,M=t.frame,_=t.texture.source[M.sourceIndex],E=e.scrollX*t.scrollFactorX,P=e.scrollY*t.scrollFactorY,L=t.scrollX,k=t.scrollY,F=t.fontData,O=F.lineHeight,R=t.fontSize/F.size,B=F.chars,I=t.alpha,D=w(t._tintTL,I),Y=w(t._tintTR,I),z=w(t._tintBL,I),X=w(t._tintBR,I),N=t.x,V=t.y,W=M.cutX,G=M.cutY,U=_.width,j=_.height,H=_.glTexture,q=0,K=0,J=0,Z=0,Q=null,$=0,tt=0,et=0,it=0,nt=0,st=0,rt=0,ot=0,at=0,ht=0,lt=0,ut=0,ct=null,dt=0,ft=N+M.x,pt=V+M.y,gt=-t.rotation,vt=t.scaleX,yt=t.scaleY,mt=Math.sin(gt),xt=Math.cos(gt),bt=xt*vt,wt=-mt*vt,Tt=mt*yt,St=xt*yt,At=ft,Ct=pt,Mt=C[0],_t=C[1],Et=C[2],Pt=C[3],Lt=bt*Mt+wt*Et,kt=bt*_t+wt*Pt,Ft=Tt*Mt+St*Et,Ot=Tt*_t+St*Pt,Rt=At*Mt+Ct*Et+C[4],Bt=At*_t+Ct*Pt+C[5],It=t.cropWidth>0||t.cropHeight>0,Dt=0;this.setTexture2D(H,0),It&&A.pushScissor(t.x,t.y,t.cropWidth*t.scaleX,t.cropHeight*t.scaleY);for(var Yt=0;Ytthis.vertexCapacity&&this.flush(),Dt=this.vertexCount*this.vertexComponentCount,y&&(i|=0,n|=0,s|=0,r|=0,o|=0,h|=0,l|=0,u|=0),T[Dt+0]=i,T[Dt+1]=n,T[Dt+2]=at,T[Dt+3]=lt,S[Dt+4]=D,T[Dt+5]=s,T[Dt+6]=r,T[Dt+7]=at,T[Dt+8]=ut,S[Dt+9]=z,T[Dt+10]=o,T[Dt+11]=h,T[Dt+12]=ht,T[Dt+13]=ut,S[Dt+14]=X,T[Dt+15]=i,T[Dt+16]=n,T[Dt+17]=at,T[Dt+18]=lt,S[Dt+19]=D,T[Dt+20]=o,T[Dt+21]=h,T[Dt+22]=ht,T[Dt+23]=ut,S[Dt+24]=X,T[Dt+25]=l,T[Dt+26]=u,T[Dt+27]=ht,T[Dt+28]=lt,S[Dt+29]=Y,this.vertexCount+=6}}}else q=0,J=0,K+=O,ct=null;It&&A.popScissor()},batchText:function(t,e){var i=a.getTintAppendFloatAlpha;this.batchTexture(t,t.canvasTexture,t.canvasTexture.width,t.canvasTexture.height,t.x,t.y,t.canvasTexture.width,t.canvasTexture.height,t.scaleX,t.scaleY,t.rotation,t.flipX,t.flipY,t.scrollFactorX,t.scrollFactorY,t.displayOriginX,t.displayOriginY,0,0,t.canvasTexture.width,t.canvasTexture.height,i(t._tintTL,t._alphaTL),i(t._tintTR,t._alphaTR),i(t._tintBL,t._alphaBL),i(t._tintBR,t._alphaBR),0,0,e)},batchDynamicTilemapLayer:function(t,e){for(var i=t.culledTiles,n=i.length,s=t.tileset.image.get().source.glTexture,r=t.tileset,o=t.scrollFactorX,h=t.scrollFactorY,l=t.alpha,u=t.x,c=t.y,d=t.scaleX,f=t.scaleY,p=a.getTintAppendFloatAlpha,g=0;gthis.vertexCapacity&&this.flush(),d^=e.isRenderTexture?1:0,u=-u;var E,P=this.renderer.config.roundPixels,L=this.vertexViewF32,k=this.vertexViewU32,F=_.matrix.matrix,O=o*(c?1:0)-g,R=a*(d?1:0)-v,B=O+o*(c?-1:1),I=R+a*(d?-1:1),D=s-_.scrollX*f,Y=r-_.scrollY*p,z=Math.sin(u),X=Math.cos(u),N=X*h,V=-z*h,W=z*l,G=X*l,U=D,j=Y,H=F[0],q=F[1],K=F[2],J=F[3],Z=N*H+V*K,Q=N*q+V*J,$=W*H+G*K,tt=W*q+G*J,et=U*H+j*K+F[4],it=U*q+j*J+F[5],nt=O*Z+R*$+et,st=O*Q+R*tt+it,rt=O*Z+I*$+et,ot=O*Q+I*tt+it,at=B*Z+I*$+et,ht=B*Q+I*tt+it,lt=B*Z+R*$+et,ut=B*Q+R*tt+it,ct=y/i+C,dt=m/n+M,ft=(y+x)/i+C,pt=(m+b)/n+M;this.setTexture2D(e,0),E=this.vertexCount*this.vertexComponentCount,P&&(nt|=0,st|=0,rt|=0,ot|=0,at|=0,ht|=0,lt|=0,ut|=0),L[E+0]=nt,L[E+1]=st,L[E+2]=ct,L[E+3]=dt,k[E+4]=w,L[E+5]=rt,L[E+6]=ot,L[E+7]=ct,L[E+8]=pt,k[E+9]=T,L[E+10]=at,L[E+11]=ht,L[E+12]=ft,L[E+13]=pt,k[E+14]=S,L[E+15]=nt,L[E+16]=st,L[E+17]=ct,L[E+18]=dt,k[E+19]=w,L[E+20]=at,L[E+21]=ht,L[E+22]=ft,L[E+23]=pt,k[E+24]=S,L[E+25]=lt,L[E+26]=ut,L[E+27]=ft,L[E+28]=dt,k[E+29]=A,this.vertexCount+=6},drawTexture:function(t,e,i,n,s,r,o,h,l,u){this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var c,d=this.renderer.config.roundPixels,f=this.vertexViewF32,p=this.vertexViewU32,g=e,v=i,y=g+h,m=v+l,x=u[0],b=u[1],w=u[2],T=u[3],S=u[4],A=u[5],C=g*x+v*w+S,M=g*b+v*T+A,_=g*x+m*w+S,E=g*b+m*T+A,P=y*x+m*w+S,L=y*b+m*T+A,k=y*x+v*w+S,F=y*b+v*T+A,O=t.width,R=t.height,B=r/O,I=o/R,D=(r+h)/O,Y=(o+l)/R;n=a.getTintAppendFloatAlpha(n,s),this.setTexture2D(t,0),c=this.vertexCount*this.vertexComponentCount,d&&(C|=0,M|=0,_|=0,E|=0,P|=0,L|=0,k|=0,F|=0),f[c+0]=C,f[c+1]=M,f[c+2]=B,f[c+3]=I,p[c+4]=n,f[c+5]=_,f[c+6]=E,f[c+7]=B,f[c+8]=Y,p[c+9]=n,f[c+10]=P,f[c+11]=L,f[c+12]=D,f[c+13]=Y,p[c+14]=n,f[c+15]=C,f[c+16]=M,f[c+17]=B,f[c+18]=I,p[c+19]=n,f[c+20]=P,f[c+21]=L,f[c+22]=D,f[c+23]=Y,p[c+24]=n,f[c+25]=k,f[c+26]=F,f[c+27]=D,f[c+28]=I,p[c+29]=n,this.vertexCount+=6,this.flush()},batchGraphics:function(){}});t.exports=l},function(t,e,i){var n=i(0),s=i(812),r=i(172),o=new n({Extends:r,initialize:function(t){t.fragShader=s.replace("%LIGHT_COUNT%",10..toString()),r.call(this,t)},onBind:function(){r.prototype.onBind.call(this);var t=this.renderer,e=this.program;return this.mvpUpdate(),t.setInt1(e,"uNormSampler",1),t.setFloat2(e,"uResolution",this.width,this.height),this},onRender:function(t,e){var i=t.sys.lights;if(!i)return this;if(i.culledLights.length=0,i.lights.length<=0||!i.active)return this;var n,s=this.renderer,r=this.program,o=i.cull(e),a=Math.min(o.length,10),h=e.matrix,l={x:0,y:0},u=s.height;for(n=0;n<10;++n)s.setFloat1(r,"uLights["+n+"].radius",0);if(a<=0)return this;for(s.setFloat4(r,"uCamera",e.x,e.y,e.rotation,e.zoom),s.setFloat3(r,"uAmbientLightColor",i.ambientColor.r,i.ambientColor.g,i.ambientColor.b),n=0;n=t.length)){for(var i=t.length-1,n=t[e],s=e;s-1;r--)n[s][r]=t[r][s]}return n}},function(t,e,i){var n=i(0),s=i(15),r=i(82),o=i(68),a=new n({Extends:s,initialize:function(t){s.call(this),this.manager=t,this.isTimeline=!0,this.data=[],this.totalData=0,this.useFrames=!1,this.timeScale=1,this.loop=0,this.loopDelay=0,this.loopCounter=0,this.completeDelay=0,this.countdown=0,this.state=o.PENDING_ADD,this._pausedState=o.PENDING_ADD,this.paused=!1,this.elapsed=0,this.totalElapsed=0,this.duration=0,this.progress=0,this.totalDuration=0,this.totalProgress=0,this.callbacks={onComplete:null,onLoop:null,onStart:null,onUpdate:null,onYoyo:null},this.callbackScope},setTimeScale:function(t){return this.timeScale=t,this},getTimeScale:function(){return this.timeScale},isPlaying:function(){return this.state===o.ACTIVE},add:function(t){return this.queue(r(this,t))},queue:function(t){return this.isPlaying()||(t.parent=this,t.parentIsTimeline=!0,this.data.push(t),this.totalData=this.data.length),this},hasOffset:function(t){return null!==t.offset},isOffsetAbsolute:function(t){return"number"==typeof t},isOffsetRelative:function(t){if("string"===typeof t){var e=t[0];if("-"===e||"+"===e)return!0}return!1},getRelativeOffset:function(t,e){var i=t[0],n=parseFloat(t.substr(2)),s=e;switch(i){case"+":s+=n;break;case"-":s-=n}return Math.max(0,s)},calcDuration:function(){for(var t=0,e=0,i=0,n=0;n0?this.totalDuration=this.duration+this.completeDelay+(this.duration+this.loopDelay)*this.loopCounter:this.totalDuration=this.duration+this.completeDelay},init:function(){return this.calcDuration(),this.progress=0,this.totalProgress=0,!this.paused||(this.state=o.PAUSED,!1)},resetTweens:function(t){for(var e=0;e0){this.elapsed=0,this.progress=0,this.loopCounter--;var t=this.callbacks.onLoop;t&&t.func.apply(t.scope,t.params),this.emit("loop",this,this.loopCounter),this.resetTweens(!0),this.loopDelay>0?(this.countdown=this.loopDelay,this.state=o.LOOP_DELAY):this.state=o.ACTIVE}else if(this.completeDelay>0)this.countdown=this.completeDelay,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&e.func.apply(e.scope,e.params),this.emit("complete",this),this.state=o.PENDING_REMOVE}},update:function(t,e){if(this.state!==o.PAUSED){var i=e;switch(this.useFrames&&(e=1*this.manager.timeScale),e*=this.timeScale,this.elapsed+=e,this.progress=Math.min(this.elapsed/this.duration,1),this.totalElapsed+=e,this.totalProgress=Math.min(this.totalElapsed/this.totalDuration,1),this.state){case o.ACTIVE:for(var n=this.totalData,s=0;s0?Math.floor(v/p.length):h(e,"duration",g.duration),g.delay=h(e,"delay",g.delay),g.easeParams=c(e,"easeParams",g.easeParams),g.ease=a(c(e,"ease",g.ease),g.easeParams),g.hold=h(e,"hold",g.hold),g.repeat=h(e,"repeat",g.repeat),g.repeatDelay=h(e,"repeatDelay",g.repeatDelay),g.yoyo=o(e,"yoyo",g.yoyo),g.flipX=o(e,"flipX",g.flipX),g.flipY=o(e,"flipY",g.flipY);for(var y=0;y0){var t=this.delay+this.delay*this.repeat;return(this.elapsed+this.delay*(this.repeat-this.repeatCount))/t}return this.getProgress()},getRepeatCount:function(){return this.repeatCount},getElapsed:function(){return this.elapsed},getElapsedSeconds:function(){return.001*this.elapsed},remove:function(t){void 0===t&&(t=!1),this.elapsed=this.delay,this.hasDispatched=!t,this.repeatCount=0},destroy:function(){this.callback=void 0,this.callbackScope=void 0,this.args=[]}});t.exports=r},function(t,e,i){var n=i(0),s=i(13),r=i(21),o=i(1),a=i(411),h=i(88),l=i(44),u=new n({Extends:o,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Flip,s.GetBounds,s.Origin,s.Pipeline,s.ScaleMode,s.Size,s.Transform,s.Visible,s.ScrollFactor,a],initialize:function(t,e,i,n,s,a){o.call(this,t,"StaticTilemapLayer"),this.isTilemap=!0,this.tilemap=e,this.layerIndex=i,this.layer=e.layers[i],this.layer.tilemapLayer=this,this.tileset=n,this.culledTiles=[],this.vertexBuffer=null,this.renderer=t.sys.game.renderer,this.bufferData=null,this.vertexViewF32=null,this.vertexViewU32=null,this.dirty=!0,this.vertexCount=0,this.setAlpha(this.layer.alpha),this.setPosition(s,a),this.setOrigin(),this.setSize(this.layer.tileWidth*this.layer.width,this.layer.tileHeight*this.layer.height),this.initPipeline("TextureTintPipeline"),t.sys.game.config.renderType===r.WEBGL&&t.sys.game.renderer.onContextRestored(function(){this.dirty=!0,this.vertexBuffer=null},this)},upload:function(t){var e,i,n,s,r=this.tileset,o=this.layer.width,a=this.layer.height,h=r.image.get().width,u=r.image.get().height,c=this.layer.data,d=this.renderer;if(d.gl){var f=d.pipelines.TextureTintPipeline;if(this.dirty){var p=d.gl,g=this.vertexBuffer,v=this.bufferData,y=0,m=0,x=o*a*f.vertexSize*6;null===v&&(v=new ArrayBuffer(x),this.bufferData=v,this.vertexViewF32=new Float32Array(v),this.vertexViewU32=new Uint32Array(v));var b=this.vertexViewF32,w=this.vertexViewU32;for(i=0;ia&&(a=e.layer[l].width),e.layer[l].height>h&&(h=e.layer[l].height);var u=new s({width:a,height:h,name:t,tileWidth:e.layer[0].tilesize,tileHeight:e.layer[0].tilesize,format:n.WELTMEISTER});return u.layers=r(e,i),u.tilesets=o(e),u}},function(t,e,i){var n=i(0),s=i(2),r=new n({initialize:function(t){void 0===t&&(t={}),this.name=s(t,"name","object layer"),this.opacity=s(t,"opacity",1),this.properties=s(t,"properties",{}),this.propertyTypes=s(t,"propertytypes",{}),this.type=s(t,"type","objectgroup"),this.visible=s(t,"visible",!0),this.objects=s(t,"objects",[])}});t.exports=r},function(t,e,i){var n=i(420),s=i(191),r=function(t){return{x:t.x,y:t.y}},o=["id","name","type","rotation","properties","visible","x","y","width","height"];t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=0);var a=n(t,o);if(a.x+=e,a.y+=i,t.gid){var h=s(t.gid);a.gid=h.gid,a.flippedHorizontal=h.flippedHorizontal,a.flippedVertical=h.flippedVertical,a.flippedAntiDiagonal=h.flippedAntiDiagonal}else t.polyline?a.polyline=t.polyline.map(r):t.polygon?a.polygon=t.polygon.map(r):t.ellipse?(a.ellipse=t.ellipse,a.width=t.width,a.height=t.height):t.text?(a.width=t.width,a.height=t.height,a.text=t.text):(a.rectangle=!0,a.width=t.width,a.height=t.height);return a}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r,o){(void 0===i||i<=0)&&(i=32),(void 0===n||n<=0)&&(n=32),void 0===s&&(s=0),void 0===r&&(r=0),this.name=t,this.firstgid=0|e,this.imageWidth=0|i,this.imageHeight=0|n,this.imageMargin=0|s,this.imageSpacing=0|r,this.properties=o||{},this.images=[],this.total=0},containsImageIndex:function(t){return t>=this.firstgid&&t-1}return!1}},function(t,e,i){var n=i(14);t.exports=function(t,e,i,s,r,o,a){for(var h=n(i,s,r,o,null,a),l=0;l0&&r.motion=r.sleepThreshold&&n.set(r,!0)):r.sleepCounter>0&&(r.sleepCounter-=1)}else n.set(r,!1)}},n.afterCollisions=function(t,e){for(var i=e*e*e,s=0;sn._motionWakeThreshold*i&&n.set(l,!1)}}}},n.set=function(t,e){var i=t.isSleeping;e?(t.isSleeping=!0,t.sleepCounter=t.sleepThreshold,t.positionImpulse.x=0,t.positionImpulse.y=0,t.positionPrev.x=t.position.x,t.positionPrev.y=t.position.y,t.anglePrev=t.angle,t.speed=0,t.angularSpeed=0,t.motion=0,i||s.trigger(t,"sleepStart")):(t.isSleeping=!1,t.sleepCounter=0,i&&s.trigger(t,"sleepEnd"))}},function(t,e){t.exports={NONE:0,A:1,B:2,BOTH:3}},function(t,e){t.exports={NEVER:0,LITE:1,PASSIVE:2,ACTIVE:4,FIXED:8}},function(t,e,i){var n=i(28),s=i(0),r=i(47),o=i(27),a=i(6),h=new s({initialize:function(t,e){this.world=t,this.gameObject=e,this.debugShowBody=t.defaults.debugShowStaticBody,this.debugBodyColor=t.defaults.staticBodyDebugColor,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new a,this.position=new a(e.x-e.displayOriginX,e.y-e.displayOriginY),this.width=e.displayWidth,this.height=e.displayHeight,this.halfWidth=Math.abs(this.width/2),this.halfHeight=Math.abs(this.height/2),this.center=new a(e.x+this.halfWidth,e.y+this.halfHeight),this.velocity=a.ZERO,this.allowGravity=!1,this.gravity=a.ZERO,this.bounce=a.ZERO,this.onWorldBounds=!1,this.onCollide=!1,this.onOverlap=!1,this.mass=1,this.immovable=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.overlapR=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision={none:!1,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.blocked={none:!0,up:!1,down:!1,left:!1,right:!1},this.physicsType=r.STATIC_BODY},setGameObject:function(t,e){return t&&t!==this.gameObject&&(this.gameObject.body=null,t.body=this,this.gameObject=t),e&&this.updateFromGameObject(),this},updateFromGameObject:function(){this.world.staticTree.remove(this);var t=this.gameObject;return t.getTopLeft(this.position),this.width=t.displayWidth,this.height=t.displayHeight,this.halfWidth=Math.abs(this.width/2),this.halfHeight=Math.abs(this.height/2),this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight),this.world.staticTree.insert(this),this},setSize:function(t,e,i,n){return void 0===i&&(i=this.offset.x),void 0===n&&(n=this.offset.y),this.world.staticTree.remove(this),this.width=t,this.height=e,this.halfWidth=Math.floor(t/2),this.halfHeight=Math.floor(e/2),this.offset.set(i,n),this.updateCenter(),this.isCircle=!1,this.radius=0,this.world.staticTree.insert(this),this},setCircle:function(t,e,i){return void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.world.staticTree.remove(this),this.isCircle=!0,this.radius=t,this.width=2*t,this.height=2*t,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.set(e,i),this.updateCenter(),this.world.staticTree.insert(this)):this.isCircle=!1,this},updateCenter:function(){this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},reset:function(t,e){var i=this.gameObject;void 0===t&&(t=i.x),void 0===e&&(e=i.y),this.world.staticTree.remove(this),i.getTopLeft(this.position),this.updateCenter(),this.world.staticTree.insert(this)},stop:function(){return this},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,e){return this.isCircle?n(this,t,e):o(this,t,e)},deltaAbsX:function(){return 0},deltaAbsY:function(){return 0},deltaX:function(){return 0},deltaY:function(){return 0},deltaZ:function(){return 0},destroy:function(){this.enable=!1,this.world.pendingDestroy.set(this)},drawDebug:function(t){var e=this.position;this.debugShowBody&&(t.lineStyle(1,this.debugBodyColor,1),t.strokeRect(e.x,e.y,this.width,this.height))},willDrawDebug:function(){return this.debugShowBody},setMass:function(t){return t<=0&&(t=.1),this.mass=t,this},x:{get:function(){return this.position.x},set:function(t){this.world.staticTree.remove(this),this.position.x=t,this.world.staticTree.insert(this)}},y:{get:function(){return this.position.y},set:function(t){this.world.staticTree.remove(this),this.position.y=t,this.world.staticTree.insert(this)}},left:{get:function(){return this.position.x}},right:{get:function(){return this.position.x+this.width}},top:{get:function(){return this.position.y}},bottom:{get:function(){return this.position.y+this.height}}});t.exports=h},function(t,e){t.exports=function(t,e){return!(e.right<=t.left||e.bottom<=t.top||e.position.x>=t.right||e.position.y>=t.bottom)}},function(t,e){var i=function(t,e,r,o,a){for(r=r||0,o=o||t.length-1,a=a||s;o>r;){if(o-r>600){var h=o-r+1,l=e-r+1,u=Math.log(h),c=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*c*(h-c)/h)*(l-h/2<0?-1:1),f=Math.max(r,Math.floor(e-l*c/h+d)),p=Math.min(o,Math.floor(e+(h-l)*c/h+d));i(t,e,f,p,a)}var g=t[e],v=r,y=o;for(n(t,r,e),a(t[o],g)>0&&n(t,r,o);v0;)y--}0===a(t[r],g)?n(t,r,y):n(t,++y,o),y<=e&&(r=y+1),e<=y&&(o=y-1)}};function n(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function s(t,e){return te?1:0}t.exports=i},function(t,e,i){var n=i(203);function s(t,e){if(!(this instanceof s))return new s(t,e);this._maxEntries=Math.max(4,t||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),e&&this._initFormat(e),this.clear()}function r(t,e,i){if(!i)return e.indexOf(t);for(var n=0;n=t.minX&&e.maxY>=t.minY}function g(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function v(t,e,i,s,r){for(var o,a=[e,i];a.length;)(i=a.pop())-(e=a.pop())<=s||(o=e+Math.ceil((i-e)/s/2)*s,n(t,o,e,i,r),a.push(e,o,o,i))}s.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,i=[],n=this.toBBox;if(!p(t,e))return i;for(var s,r,o,a,h=[];e;){for(s=0,r=e.children.length;s=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(s,r,e)},_split:function(t,e){var i=t[e],n=i.children.length,s=this._minEntries;this._chooseSplitAxis(i,s,n);var r=this._chooseSplitIndex(i,s,n),a=g(i.children.splice(r,i.children.length-r));a.height=i.height,a.leaf=i.leaf,o(i,this.toBBox),o(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)},_splitRoot:function(t,e){this.data=g([t,e]),this.data.height=t.height+1,this.data.leaf=!1,o(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,i){var n,s,r,o,h,l,u,d,f,p,g,v,y,m;for(l=u=1/0,n=e;n<=i-e;n++)s=a(t,0,n,this.toBBox),r=a(t,n,i,this.toBBox),f=s,p=r,void 0,void 0,void 0,void 0,g=Math.max(f.minX,p.minX),v=Math.max(f.minY,p.minY),y=Math.min(f.maxX,p.maxX),m=Math.min(f.maxY,p.maxY),o=Math.max(0,y-g)*Math.max(0,m-v),h=c(s)+c(r),o=e;s--)r=t.children[s],h(u,t.leaf?o(r):r),c+=d(u);return c},_adjustParentBBoxes:function(t,e,i){for(var n=i;n>=0;n--)h(e[n],t)},_condense:function(t){for(var e,i=t.length-1;i>=0;i--)0===t[i].children.length?i>0?(e=t[i-1].children).splice(e.indexOf(t[i]),1):this.clear():o(t[i],this.toBBox)},_initFormat:function(t){var e=["return a"," - b",";"];this.compareMinX=new Function("a","b",e.join(t[0])),this.compareMinY=new Function("a","b",e.join(t[1])),this.toBBox=new Function("a","return {minX: a"+t[0]+", minY: a"+t[1]+", maxX: a"+t[2]+", maxY: a"+t[3]+"};")}},t.exports=s},function(t,e,i){var n=new(i(0))({initialize:function(){this._pending=[],this._active=[],this._destroy=[],this._toProcess=0},add:function(t){return this._pending.push(t),this._toProcess++,this},remove:function(t){return this._destroy.push(t),this._toProcess++,this},update:function(){if(0===this._toProcess)return this._active;var t,e,i=this._destroy,n=this._active;for(t=0;te.deltaY()?(s=t.bottom-e.y)>r&&!i||!1===t.checkCollision.down||!1===e.checkCollision.up?s=0:(t.touching.none=!1,t.touching.down=!0,e.touching.none=!1,e.touching.up=!0):t.deltaY()r&&!i||!1===t.checkCollision.up||!1===e.checkCollision.down?s=0:(t.touching.none=!1,t.touching.up=!0,e.touching.none=!1,e.touching.down=!0)),t.overlapY=s,e.overlapY=s,s}},function(t,e){t.exports=function(t,e,i,n){var s=0,r=t.deltaAbsX()+e.deltaAbsX()+n;return 0===t.deltaX()&&0===e.deltaX()?(t.embedded=!0,e.embedded=!0):t.deltaX()>e.deltaX()?(s=t.right-e.x)>r&&!i||!1===t.checkCollision.right||!1===e.checkCollision.left?s=0:(t.touching.none=!1,t.touching.right=!0,e.touching.none=!1,e.touching.left=!0):t.deltaX()r&&!i||!1===t.checkCollision.left||!1===e.checkCollision.right?s=0:(t.touching.none=!1,t.touching.left=!0,e.touching.none=!1,e.touching.right=!0)),t.overlapX=s,e.overlapX=s,s}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r,o){this.world=t,this.name="",this.active=!0,this.overlapOnly=e,this.object1=i,this.object2=n,this.collideCallback=s,this.processCallback=r,this.callbackContext=o},setName:function(t){return this.name=t,this},update:function(){this.world.collideObjects(this.object1,this.object2,this.collideCallback,this.processCallback,this.callbackContext,this.overlapOnly)},destroy:function(){this.world.removeCollider(this),this.active=!1,this.world=null,this.object1=null,this.object2=null,this.collideCallback=null,this.processCallback=null,this.callbackContext=null}});t.exports=n},function(t,e,i){var n=i(28),s=i(0),r=i(47),o=i(10),a=i(27),h=i(6),l=new s({initialize:function(t,e){this.world=t,this.gameObject=e,this.debugShowBody=t.defaults.debugShowBody,this.debugShowVelocity=t.defaults.debugShowVelocity,this.debugBodyColor=t.defaults.bodyDebugColor,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new h,this.position=new h(e.x,e.y),this.prev=new h(this.position.x,this.position.y),this.allowRotation=!0,this.rotation=e.angle,this.preRotation=e.angle,this.width=e.width,this.height=e.height,this.sourceWidth=e.width,this.sourceHeight=e.height,e.frame&&(this.sourceWidth=e.frame.realWidth,this.sourceHeight=e.frame.realHeight),this.halfWidth=Math.abs(e.width/2),this.halfHeight=Math.abs(e.height/2),this.center=new h(e.x+this.halfWidth,e.y+this.halfHeight),this.velocity=new h,this.newVelocity=new h,this.deltaMax=new h,this.acceleration=new h,this.allowDrag=!0,this.drag=new h,this.allowGravity=!0,this.gravity=new h,this.bounce=new h,this.worldBounce=null,this.onWorldBounds=!1,this.onCollide=!1,this.onOverlap=!1,this.maxVelocity=new h(1e4,1e4),this.friction=new h(1,0),this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e3,this.mass=1,this.angle=0,this.speed=0,this.facing=r.FACING_NONE,this.immovable=!1,this.moves=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.overlapR=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision={none:!1,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.blocked={none:!0,up:!1,down:!1,left:!1,right:!1},this.dirty=!1,this.syncBounds=!1,this.isMoving=!1,this.stopVelocityOnCollide=!0,this.physicsType=r.DYNAMIC_BODY,this._reset=!0,this._sx=e.scaleX,this._sy=e.scaleY,this._dx=0,this._dy=0,this._bounds=new o},updateBounds:function(){var t=this.gameObject;if(this.syncBounds){var e=t.getBounds(this._bounds);e.width===this.width&&e.height===this.height||(this.width=e.width,this.height=e.height,this._reset=!0)}else{var i=Math.abs(t.scaleX),n=Math.abs(t.scaleY);i===this._sx&&n===this._sy||(this.width=this.sourceWidth*i,this.height=this.sourceHeight*n,this._sx=i,this._sy=n,this._reset=!0)}this._reset&&(this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter())},updateCenter:function(){this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},update:function(t){this.dirty=!0,this.wasTouching.none=this.touching.none,this.wasTouching.up=this.touching.up,this.wasTouching.down=this.touching.down,this.wasTouching.left=this.touching.left,this.wasTouching.right=this.touching.right,this.touching.none=!0,this.touching.up=!1,this.touching.down=!1,this.touching.left=!1,this.touching.right=!1,this.blocked.none=!0,this.blocked.up=!1,this.blocked.down=!1,this.blocked.left=!1,this.blocked.right=!1,this.overlapR=0,this.overlapX=0,this.overlapY=0,this.embedded=!1,this.updateBounds();var e=this.gameObject;this.position.x=e.x+e.scaleX*(this.offset.x-e.displayOriginX),this.position.y=e.y+e.scaleY*(this.offset.y-e.displayOriginY),this.updateCenter(),this.rotation=e.angle,this.preRotation=this.rotation,this._reset&&(this.prev.x=this.position.x,this.prev.y=this.position.y),this.moves&&(this.world.updateMotion(this),this.newVelocity.set(this.velocity.x*t,this.velocity.y*t),this.position.x+=this.newVelocity.x,this.position.y+=this.newVelocity.y,this.updateCenter(),this.position.x===this.prev.x&&this.position.y===this.prev.y||(this.angle=Math.atan2(this.velocity.y,this.velocity.x)),this.speed=Math.sqrt(this.velocity.x*this.velocity.x+this.velocity.y*this.velocity.y),this.collideWorldBounds&&this.checkWorldBounds()&&this.onWorldBounds&&this.world.emit("worldbounds",this,this.blocked.up,this.blocked.down,this.blocked.left,this.blocked.right)),this._dx=this.deltaX(),this._dy=this.deltaY(),this._reset=!1},postUpdate:function(){this.enable&&this.dirty&&(this.dirty=!1,this._dx=this.deltaX(),this._dy=this.deltaY(),this._dx<0?this.facing=r.FACING_LEFT:this._dx>0&&(this.facing=r.FACING_RIGHT),this._dy<0?this.facing=r.FACING_UP:this._dy>0&&(this.facing=r.FACING_DOWN),this.moves&&(0!==this.deltaMax.x&&0!==this._dx&&(this._dx<0&&this._dx<-this.deltaMax.x?this._dx=-this.deltaMax.x:this._dx>0&&this._dx>this.deltaMax.x&&(this._dx=this.deltaMax.x)),0!==this.deltaMax.y&&0!==this._dy&&(this._dy<0&&this._dy<-this.deltaMax.y?this._dy=-this.deltaMax.y:this._dy>0&&this._dy>this.deltaMax.y&&(this._dy=this.deltaMax.y)),this.gameObject.x+=this._dx,this.gameObject.y+=this._dy,this._reset=!0),this.updateCenter(),this.allowRotation&&(this.gameObject.angle+=this.deltaZ()),this.prev.x=this.position.x,this.prev.y=this.position.y)},checkWorldBounds:function(){var t=this.position,e=this.world.bounds,i=this.world.checkCollision,n=this.worldBounce?-this.worldBounce.x:-this.bounce.x,s=this.worldBounce?-this.worldBounce.y:-this.bounce.y;return t.xe.right&&i.right&&(t.x=e.right-this.width,this.velocity.x*=n,this.blocked.right=!0,this.blocked.none=!1),t.ye.bottom&&i.down&&(t.y=e.bottom-this.height,this.velocity.y*=s,this.blocked.down=!0,this.blocked.none=!1),!this.blocked.none},setOffset:function(t,e){return void 0===e&&(e=t),this.offset.set(t,e),this},setSize:function(t,e,i){void 0===i&&(i=!0);var n=this.gameObject;if(this.sourceWidth=t,this.sourceHeight=e,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter(),i&&n.getCenter){var s=n.displayWidth/2,r=n.displayHeight/2;this.offset.set(s-this.halfWidth,r-this.halfHeight)}return this.isCircle=!1,this.radius=0,this},setCircle:function(t,e,i){return void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.isCircle=!0,this.radius=t,this.sourceWidth=2*t,this.sourceHeight=2*t,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.set(e,i),this.updateCenter()):this.isCircle=!1,this},reset:function(t,e){this.stop();var i=this.gameObject;i.setPosition(t,e),i.getTopLeft(this.position),this.prev.copy(this.position),this.rotation=i.angle,this.preRotation=i.angle,this.updateBounds(),this.updateCenter()},stop:function(){return this.velocity.set(0),this.acceleration.set(0),this.speed=0,this.angularVelocity=0,this.angularAcceleration=0,this},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,e){return this.isCircle?n(this,t,e):a(this,t,e)},onFloor:function(){return this.blocked.down},onCeiling:function(){return this.blocked.up},onWall:function(){return this.blocked.left||this.blocked.right},deltaAbsX:function(){return this.deltaX()>0?this.deltaX():-this.deltaX()},deltaAbsY:function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},deltaX:function(){return this.position.x-this.prev.x},deltaY:function(){return this.position.y-this.prev.y},deltaZ:function(){return this.rotation-this.preRotation},destroy:function(){this.enable=!1,this.world.pendingDestroy.set(this)},drawDebug:function(t){var e=this.position,i=e.x+this.halfWidth,n=e.y+this.halfHeight;this.debugShowBody&&(t.lineStyle(1,this.debugBodyColor),this.isCircle?t.strokeCircle(i,n,this.width/2):t.strokeRect(e.x,e.y,this.width,this.height)),this.debugShowVelocity&&(t.lineStyle(1,this.world.defaults.velocityDebugColor,1),t.lineBetween(i,n,i+this.velocity.x/2,n+this.velocity.y/2))},willDrawDebug:function(){return this.debugShowBody||this.debugShowVelocity},setCollideWorldBounds:function(t){return this.collideWorldBounds=t,this},setVelocity:function(t,e){return this.velocity.set(t,e),this},setVelocityX:function(t){return this.velocity.x=t,this},setVelocityY:function(t){return this.velocity.y=t,this},setBounce:function(t,e){return this.bounce.set(t,e),this},setBounceX:function(t){return this.bounce.x=t,this},setBounceY:function(t){return this.bounce.y=t,this},setAcceleration:function(t,e){return this.acceleration.set(t,e),this},setAccelerationX:function(t){return this.acceleration.x=t,this},setAccelerationY:function(t){return this.acceleration.y=t,this},setDrag:function(t,e){return this.drag.set(t,e),this},setDragX:function(t){return this.drag.x=t,this},setDragY:function(t){return this.drag.y=t,this},setGravity:function(t,e){return this.gravity.set(t,e),this},setGravityX:function(t){return this.gravity.x=t,this},setGravityY:function(t){return this.gravity.y=t,this},setFriction:function(t,e){return this.friction.set(t,e),this},setFrictionX:function(t){return this.friction.x=t,this},setFrictionY:function(t){return this.friction.y=t,this},setAngularVelocity:function(t){return this.angularVelocity=t,this},setAngularAcceleration:function(t){return this.angularAcceleration=t,this},setAngularDrag:function(t){return this.angularDrag=t,this},setMass:function(t){return this.mass=t,this},setImmovable:function(t){return this.immovable=t,this},x:{get:function(){return this.position.x},set:function(t){this.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t}},left:{get:function(){return this.position.x}},right:{get:function(){return this.position.x+this.width}},top:{get:function(){return this.position.y}},bottom:{get:function(){return this.position.y+this.height}}});t.exports=l},function(t,e,i){var n=i(209),s=i(64),r=i(0),o=i(208),a=i(47),h=i(48),l=i(15),u=i(207),c=i(206),d=i(5),f=i(205),p=i(477),g=i(10),v=i(204),y=i(476),m=i(471),x=i(470),b=i(63),w=i(201),T=i(202),S=i(6),A=i(43),C=new r({Extends:l,initialize:function(t,e){l.call(this),this.scene=t,this.bodies=new b,this.staticBodies=new b,this.pendingDestroy=new b,this.colliders=new f,this.gravity=new S(d(e,"gravity.x",0),d(e,"gravity.y",0)),this.bounds=new g(d(e,"x",0),d(e,"y",0),d(e,"width",t.sys.game.config.width),d(e,"height",t.sys.game.config.height)),this.checkCollision={up:d(e,"checkCollision.up",!0),down:d(e,"checkCollision.down",!0),left:d(e,"checkCollision.left",!0),right:d(e,"checkCollision.right",!0)},this.OVERLAP_BIAS=d(e,"overlapBias",4),this.TILE_BIAS=d(e,"tileBias",16),this.forceX=d(e,"forceX",!1),this.isPaused=d(e,"isPaused",!1),this._total=0,this.drawDebug=d(e,"debug",!1),this.debugGraphic,this.defaults={debugShowBody:d(e,"debugShowBody",!0),debugShowStaticBody:d(e,"debugShowStaticBody",!0),debugShowVelocity:d(e,"debugShowVelocity",!0),bodyDebugColor:d(e,"debugBodyColor",16711935),staticBodyDebugColor:d(e,"debugStaticBodyColor",255),velocityDebugColor:d(e,"debugVelocityColor",65280)},this.maxEntries=d(e,"maxEntries",16),this.tree=new v(this.maxEntries,[".left",".top",".right",".bottom"]),this.staticTree=new v(this.maxEntries,[".left",".top",".right",".bottom"]),this.treeMinMax={minX:0,minY:0,maxX:0,maxY:0},this.drawDebug&&this.createDebugGraphic()},enable:function(t,e){void 0===e&&(e=a.DYNAMIC_BODY);var i=1;if(Array.isArray(t))for(i=t.length;i--;)t[i].hasOwnProperty("children")?this.enable(t[i].children.entries,e):this.enableBody(t[i],e);else t.hasOwnProperty("children")?this.enable(t.children.entries,e):this.enableBody(t,e)},enableBody:function(t,e){return null===t.body&&(e===a.DYNAMIC_BODY?(t.body=new n(this,t),this.bodies.set(t.body)):e===a.STATIC_BODY&&(t.body=new w(this,t),this.staticBodies.set(t.body),this.staticTree.insert(t.body))),t},remove:function(t){this.disableBody(t)},disable:function(t){var e=1;if(Array.isArray(t))for(e=t.length;e--;)t[e].hasOwnProperty("children")?this.disable(t[e].children.entries):this.disableGameObjectBody(t[e]);else t.hasOwnProperty("children")?this.disable(t.children.entries):this.disableGameObjectBody(t)},disableGameObjectBody:function(t){return t.body&&(t.body.physicsType===a.DYNAMIC_BODY?this.bodies.delete(t.body):t.body.physicsType===a.STATIC_BODY&&(this.staticBodies.delete(t.body),this.staticTree.remove(t.body)),t.body.enable=!1),t},disableBody:function(t){t.physicsType===a.DYNAMIC_BODY?(this.tree.remove(t),this.bodies.delete(t)):t.physicsType===a.STATIC_BODY&&(this.staticBodies.delete(t),this.staticTree.remove(t)),t.enable=!1},createDebugGraphic:function(){var t=this.scene.sys.add.graphics({x:0,y:0});return t.setDepth(Number.MAX_VALUE),this.debugGraphic=t,this.drawDebug=!0,t},setBounds:function(t,e,i,n,s,r,o,a){return this.bounds.setTo(t,e,i,n),void 0!==s&&this.setBoundsCollision(s,r,o,a),this},setBoundsCollision:function(t,e,i,n){return void 0===t&&(t=!0),void 0===e&&(e=!0),void 0===i&&(i=!0),void 0===n&&(n=!0),this.checkCollision.left=t,this.checkCollision.right=e,this.checkCollision.up=i,this.checkCollision.down=n,this},pause:function(){return this.isPaused=!0,this.emit("pause"),this},resume:function(){return this.isPaused=!1,this.emit("resume"),this},addCollider:function(t,e,i,n,s){void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=i);var r=new o(this,!1,t,e,i,n,s);return this.colliders.add(r),r},addOverlap:function(t,e,i,n,s){void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=i);var r=new o(this,!0,t,e,i,n,s);return this.colliders.add(r),r},removeCollider:function(t){return this.colliders.remove(t),this},update:function(t,e){if(!this.isPaused&&0!==this.bodies.size){var i,n;e/=1e3,this.delta=e;var s=this.bodies.entries,r=s.length;for(i=0;i0){var l=this.tree,u=this.staticTree;for(o=(r=s.entries).length,t=0;t0?i-=s:i+s<0?i+=s:i=0),i>r?i=r:i<-r&&(i=-r),i},separate:function(t,e,i,n,s){if(!t.enable||!e.enable||t.checkCollision.none||e.checkCollision.none||!this.intersects(t,e))return!1;if(i&&!1===i.call(n,t.gameObject,e.gameObject))return!1;if(t.isCircle&&e.isCircle)return this.separateCircle(t,e,s);if(t.isCircle!==e.isCircle){var r=t.isCircle?e:t,o=t.isCircle?t:e,a={x:r.x,y:r.y,right:r.right,bottom:r.bottom},h=o.center;if((h.ya.bottom)&&(h.xa.right))return this.separateCircle(t,e,s)}var l=!1,u=!1;this.forceX||Math.abs(this.gravity.y+t.gravity.y)l.right&&(a=h(d.x,d.y,l.right,l.y)-d.radius):d.y>l.bottom&&(d.xl.right&&(a=h(d.x,d.y,l.right,l.bottom)-d.radius)),a*=-1}else a=t.halfWidth+e.halfWidth-h(t.center.x,t.center.y,e.center.x,e.center.y);if(i||0===a||t.immovable&&e.immovable||t.customSeparateX||e.customSeparateX)return 0!==a&&(t.onOverlap||e.onOverlap)&&this.emit("overlap",t.gameObject,e.gameObject,t,e),0!==a;var f=t.velocity.x,p=t.velocity.y,g=t.mass,v=e.velocity.x,y=e.velocity.y,m=e.mass,x=f*Math.cos(o)+p*Math.sin(o),b=f*Math.sin(o)-p*Math.cos(o),w=v*Math.cos(o)+y*Math.sin(o),T=v*Math.sin(o)-y*Math.cos(o),S=((g-m)*x+2*m*w)/(g+m),A=(2*g*x+(m-g)*w)/(g+m);return t.immovable||(t.velocity.x=(S*Math.cos(o)-b*Math.sin(o))*t.bounce.x,t.velocity.y=(b*Math.cos(o)+S*Math.sin(o))*t.bounce.y,f=t.velocity.x,p=t.velocity.y),e.immovable||(e.velocity.x=(A*Math.cos(o)-T*Math.sin(o))*e.bounce.x,e.velocity.y=(T*Math.cos(o)+A*Math.sin(o))*e.bounce.y,v=e.velocity.x,y=e.velocity.y),Math.abs(o)0&&!t.immovable&&v>f?t.velocity.x*=-1:v<0&&!e.immovable&&f0&&!t.immovable&&y>p?t.velocity.y*=-1:y<0&&!e.immovable&&pMath.PI/2&&(f<0&&!t.immovable&&v0&&!e.immovable&&f>v?e.velocity.x*=-1:p<0&&!t.immovable&&y0&&!e.immovable&&f>y&&(e.velocity.y*=-1)),t.immovable||(t.x+=t.velocity.x*this.delta-a*Math.cos(o),t.y+=t.velocity.y*this.delta-a*Math.sin(o)),e.immovable||(e.x+=e.velocity.x*this.delta+a*Math.cos(o),e.y+=e.velocity.y*this.delta+a*Math.sin(o)),(t.onCollide||e.onCollide)&&this.emit("collide",t.gameObject,e.gameObject,t,e),!0},intersects:function(t,e){return t!==e&&(t.isCircle?e.isCircle?h(t.center.x,t.center.y,e.center.x,e.center.y)<=t.halfWidth+e.halfWidth:this.circleBodyIntersects(t,e):e.isCircle?this.circleBodyIntersects(e,t):!(t.right<=e.position.x)&&(!(t.bottom<=e.position.y)&&(!(t.position.x>=e.right)&&!(t.position.y>=e.bottom))))},circleBodyIntersects:function(t,e){var i=s(t.center.x,e.left,e.right),n=s(t.center.y,e.top,e.bottom);return(t.center.x-i)*(t.center.x-i)+(t.center.y-n)*(t.center.y-n)<=t.halfWidth*t.halfWidth},overlap:function(t,e,i,n,s){return void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=i),this.collideObjects(t,e,i,n,s,!0)},collide:function(t,e,i,n,s){return void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=i),this.collideObjects(t,e,i,n,s,!1)},collideObjects:function(t,e,i,n,s,r){var o;t=t.isParent&&void 0===t.physicsType?t.children.entries:t,e=e.isParent&&void 0===e.physicsType?e.children.entries:e;var a=Array.isArray(t),h=Array.isArray(e);if(this._total=0,a||h)if(!a&&h)for(o=0;o0},collideHandler:function(t,e,i,n,s,r){if(void 0===e&&t.isParent)return this.collideGroupVsGroup(t,t,i,n,s,r);if(!t||!e)return!1;if(t.body){if(e.body)return this.collideSpriteVsSprite(t,e,i,n,s,r);if(e.isParent)return this.collideSpriteVsGroup(t,e,i,n,s,r);if(e.isTilemap)return this.collideSpriteVsTilemapLayer(t,e,i,n,s,r)}else if(t.isParent){if(e.body)return this.collideSpriteVsGroup(e,t,i,n,s,r);if(e.isParent)return this.collideGroupVsGroup(t,e,i,n,s,r);if(e.isTilemap)return this.collideGroupVsTilemapLayer(t,e,i,n,s,r)}else if(t.isTilemap){if(e.body)return this.collideSpriteVsTilemapLayer(e,t,i,n,s,r);if(e.isParent)return this.collideGroupVsTilemapLayer(e,t,i,n,s,r)}},collideSpriteVsSprite:function(t,e,i,n,s,r){return!(!t.body||!e.body)&&(this.separate(t.body,e.body,n,s,r)&&(i&&i.call(s,t,e),this._total++),!0)},collideSpriteVsGroup:function(t,e,i,n,s,r){var o=t.body;if(0!==e.length&&o){var h=this.treeMinMax;h.minX=o.left,h.minY=o.top,h.maxX=o.right,h.maxY=o.bottom;var l=e.physicsType===a.DYNAMIC_BODY?this.tree.search(h):this.staticTree.search(h);if(0!==l.length)for(var u=e.getChildren(),c=0;cc.baseTileWidth){var d=(c.tileWidth-c.baseTileWidth)*e.scaleX;a-=d,l+=d}c.tileHeight>c.baseTileHeight&&(u+=(c.tileHeight-c.baseTileHeight)*e.scaleY);var f,g=e.getTilesWithinWorldXY(a,h,l,u);if(0===g.length)return!1;for(var v={left:0,right:0,top:0,bottom:0},m=0;m0?Math.ceil(t):Math.floor(t)}},function(t,e){t.exports=function(t,e){var i=t.x,n=t.y;return t.x=i*Math.cos(e)-n*Math.sin(e),t.y=i*Math.sin(e)+n*Math.cos(e),t}},function(t,e){t.exports=function(t){if(0===t)return 1;for(var e=t;--t;)e*=t;return e}},function(t,e,i){var n=i(218);t.exports=function(t,e){return n(t)/n(e)/n(t-e)}},function(t,e){t.exports=function(t){return(t%=2*Math.PI)>=0?t:t+2*Math.PI}},function(t,e,i){var n=i(0),s=i(17),r=i(19),o=i(7),a=new n({Extends:r,initialize:function(t,e,i,n){var s={type:"text",extension:"txt",responseType:"text",key:t,url:e,path:i,xhrSettings:n};r.call(this,s)},onProcess:function(t){this.state=s.FILE_PROCESSING,this.data=this.xhrLoader.responseText,this.onComplete(),t(this)}});o.register("text",function(t,e,i){if(Array.isArray(t))for(var n=0;nl+u?(g=(p-=l+u)/c,v.x=h.x1+(h.x2-h.x1)*g,v.y=h.y1+(h.y2-h.y1)*g):(g=(p-=l)/u,v.x=a.x1+(a.x2-a.x1)*g,v.y=a.y1+(a.y2-a.y1)*g),r.push(v)}return r}},function(t,e,i){var n=i(4),s=i(77);t.exports=function(t,e,i){void 0===i&&(i=new n);var r=t.getLineA(),o=t.getLineB(),a=t.getLineC();if(e<=0||e>=1)return i.x=r.x1,i.y=r.y1,i;var h=s(r),l=s(o),u=s(a),c=(h+l+u)*e,d=0;return ch+l?(d=(c-=h+l)/u,i.x=a.x1+(a.x2-a.x1)*d,i.y=a.y1+(a.y2-a.y1)*d):(d=(c-=h)/l,i.x=o.x1+(o.x2-o.x1)*d,i.y=o.y1+(o.y2-o.y1)*d),i}},function(t,e){t.exports=function(t,e,i){return t.x=e-t.width/2,t.y=i-t.height/2,t}},function(t,e,i){var n=i(10);n.Area=i(605),n.Ceil=i(604),n.CeilAll=i(603),n.CenterOn=i(233),n.Clone=i(602),n.Contains=i(27),n.ContainsPoint=i(601),n.ContainsRect=i(600),n.CopyFrom=i(599),n.Decompose=i(240),n.Equals=i(598),n.FitInside=i(597),n.FitOutside=i(596),n.Floor=i(595),n.FloorAll=i(594),n.FromPoints=i(150),n.GetAspectRatio=i(124),n.GetCenter=i(593),n.GetPoint=i(166),n.GetPoints=i(352),n.GetSize=i(592),n.Inflate=i(591),n.MarchingAnts=i(347),n.MergePoints=i(590),n.MergeRect=i(589),n.MergeXY=i(588),n.Offset=i(587),n.OffsetPoint=i(586),n.Overlaps=i(585),n.Perimeter=i(105),n.PerimeterPoint=i(584),n.Random=i(163),n.Scale=i(583),n.Union=i(582),t.exports=n},function(t,e,i){var n=i(0),s=i(125),r=new n({initialize:function(t){this.area=0,this.points=[],t&&this.setTo(t)},contains:function(t,e){return s(this,t,e)},setTo:function(t){if(this.area=0,this.points=[],!Array.isArray(t))return this;for(var e,i=Number.MAX_VALUE,n=0;n0){var d=(a*r+h*o)/l;u*=d,c*=d}return i.x=t.x1+u,i.y=t.y1+c,u*u+c*c<=l&&u*r+c*o>=0&&n(e,i.x,i.y)}},function(t,e){t.exports=function(t,e){return!(t.width<=0||t.height<=0||e.width<=0||e.height<=0||t.righte.right||t.y>e.bottom)}},function(t,e,i){t.exports={CircleToCircle:i(652),CircleToRectangle:i(651),GetRectangleIntersection:i(650),LineToCircle:i(242),LineToLine:i(95),LineToRectangle:i(649),PointToLine:i(241),PointToLineSegment:i(648),RectangleToRectangle:i(243),RectangleToTriangle:i(647),RectangleToValues:i(646),TriangleToCircle:i(645),TriangleToLine:i(644),TriangleToTriangle:i(643)}},function(t,e,i){t.exports={Circle:i(662),Ellipse:i(269),Intersects:i(244),Line:i(642),Point:i(624),Polygon:i(610),Rectangle:i(234),Triangle:i(581)}},function(t,e,i){var n=i(0),s=i(247),r=i(173),o=i(44),a=new n({initialize:function(){this.lightPool=[],this.lights=[],this.culledLights=[],this.ambientColor={r:.1,g:.1,b:.1},this.active=!1},enable:function(){return this.active=!0,this},disable:function(){return this.active=!1,this},cull:function(t){var e=this.lights,i=this.culledLights,n=e.length,s=t.x+t.width/2,o=t.y+t.height/2,a=(t.width+t.height)/2,h={x:0,y:0},l=t.matrix,u=this.systems.game.config.height;i.length=0;for(var c=0;c0?(h=this.lightPool.pop()).set(t,e,i,a[0],a[1],a[2],r):h=new s(t,e,i,a[0],a[1],a[2],r),this.lights.push(h),h},removeLight:function(t){var e=this.lights.indexOf(t);return e>=0&&(this.lightPool.push(t),this.lights.splice(e,1)),this},shutdown:function(){for(;this.lights.length>0;)this.lightPool.push(this.lights.pop());this.ambientColor={r:.1,g:.1,b:.1},this.culledLights.length=0,this.lights.length=0},destroy:function(){this.shutdown()}});t.exports=a},function(t,e,i){var n=i(0),s=i(44),r=new n({initialize:function(t,e,i,n,s,r,o){this.x=t,this.y=e,this.radius=i,this.r=n,this.g=s,this.b=r,this.intensity=o,this.scrollFactorX=1,this.scrollFactorY=1},set:function(t,e,i,n,s,r,o){return this.x=t,this.y=e,this.radius=i,this.r=n,this.g=s,this.b=r,this.intensity=o,this.scrollFactorX=1,this.scrollFactorY=1,this},setScrollFactor:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.scrollFactorX=t,this.scrollFactorY=e,this},setColor:function(t){var e=s.getFloatsFromUintRGB(t);return this.r=e[0],this.g=e[1],this.b=e[2],this},setIntensity:function(t){return this.intensity=t,this},setPosition:function(t,e){return this.x=t,this.y=e,this},setRadius:function(t){return this.radius=t,this}});t.exports=r},function(t,e){t.exports=function(t){var e=Math.log(t)/.6931471805599453;return 1<0&&e.cameraFilter&r._id)){var h=r.scrollX*e.scrollFactorX,l=r.scrollY*e.scrollFactorY,u=e.x,c=e.y,d=e.scaleX,f=e.scaleY,p=e.rotation,g=e.commandBuffer,v=o||t.currentContext,y=1,m=1,x=0,b=0,w=1,T=0,S=0,A=0;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,v.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,v.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode),v.save(),v.translate(u-h,c-l),v.rotate(p),v.scale(d,f),v.fillStyle="#fff",v.globalAlpha=e.alpha;for(var C=0,M=g.length;C>>16,S=(65280&x)>>>8,A=255&x,v.strokeStyle="rgba("+T+","+S+","+A+","+y+")",v.lineWidth=w,C+=3;break;case n.FILL_STYLE:b=g[C+1],m=g[C+2],T=(16711680&b)>>>16,S=(65280&b)>>>8,A=255&b,v.fillStyle="rgba("+T+","+S+","+A+","+m+")",C+=2;break;case n.BEGIN_PATH:v.beginPath();break;case n.CLOSE_PATH:v.closePath();break;case n.FILL_PATH:a||v.fill();break;case n.STROKE_PATH:a||v.stroke();break;case n.FILL_RECT:a?v.rect(g[C+1],g[C+2],g[C+3],g[C+4]):v.fillRect(g[C+1],g[C+2],g[C+3],g[C+4]),C+=4;break;case n.FILL_TRIANGLE:v.beginPath(),v.moveTo(g[C+1],g[C+2]),v.lineTo(g[C+3],g[C+4]),v.lineTo(g[C+5],g[C+6]),v.closePath(),a||v.fill(),C+=6;break;case n.STROKE_TRIANGLE:v.beginPath(),v.moveTo(g[C+1],g[C+2]),v.lineTo(g[C+3],g[C+4]),v.lineTo(g[C+5],g[C+6]),v.closePath(),a||v.stroke(),C+=6;break;case n.LINE_TO:v.lineTo(g[C+1],g[C+2]),C+=2;break;case n.MOVE_TO:v.moveTo(g[C+1],g[C+2]),C+=2;break;case n.LINE_FX_TO:v.lineTo(g[C+1],g[C+2]),C+=5;break;case n.MOVE_FX_TO:v.moveTo(g[C+1],g[C+2]),C+=5;break;case n.SAVE:v.save();break;case n.RESTORE:v.restore();break;case n.TRANSLATE:v.translate(g[C+1],g[C+2]),C+=2;break;case n.SCALE:v.scale(g[C+1],g[C+2]),C+=2;break;case n.ROTATE:v.rotate(g[C+1]),C+=1}v.restore()}}},function(t,e){t.exports=function(t){var e=t.width/2,i=t.height/2,n=Math.pow(e-i,2)/Math.pow(e+i,2);return Math.PI*(e+i)*(1+3*n/(10+Math.sqrt(4-3*n)))}},function(t,e,i){var n=i(266),s=i(134),r=i(78),o=i(16);t.exports=function(t,e,i,a){void 0===a&&(a=[]),e||(e=n(t)/i);for(var h=0;hy&&(s=y),r>m&&(r=m);var S=y+g-s,A=m+v-r;ol&&(r=l),o>l&&(o=l),a=s,h=r;;)if(a=0&&t<=o.width&&e>=0&&e<=o.height){t+=s.cutX,e+=s.cutY;var a=this._tempContext;a.clearRect(0,0,1,1),a.drawImage(o,t,e,1,1,0,0,1,1);var h=a.getImageData(0,0,1,1);return new r(h.data[0],h.data[1],h.data[2],h.data[3])}}return null},setTexture:function(t,e,i){return this.list[e]&&(t.texture=this.list[e],t.frame=t.texture.get(i)),t},each:function(t,e){for(var i=[null],n=1;n0)&&(!!s.prototype.pause.call(this)&&(this.currentConfig.seek=this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0),this.stopAndReleaseAudioTag(),this.emit("pause",this),!0)))},resume:function(){return!this.manager.isLocked(this,"resume")&&(!(this.startTime>0)&&(!!s.prototype.resume.call(this)&&(!!this.pickAndPlayAudioTag()&&(this.emit("resume",this),!0))))},stop:function(){return!this.manager.isLocked(this,"stop")&&(!!s.prototype.stop.call(this)&&(this.stopAndReleaseAudioTag(),this.emit("stop",this),!0))},pickAndPlayAudioTag:function(){if(!this.pickAudioTag())return this.reset(),!1;var t=this.currentConfig.seek,e=this.currentConfig.delay,i=(this.currentMarker?this.currentMarker.start:0)+t;return this.previousTime=i,this.audio.currentTime=i,this.applyConfig(),0===e?(this.startTime=0,this.audio.paused&&this.playCatchPromise()):(this.startTime=window.performance.now()+1e3*e,this.audio.paused||this.audio.pause()),this.resetConfig(),!0},pickAudioTag:function(){if(this.audio)return!0;for(var t=0;t0)this.startTime=n-this.manager.loopEndOffset?(this.audio.currentTime=i+Math.max(0,s-n),s=this.audio.currentTime):s=n)return this.reset(),this.stopAndReleaseAudioTag(),void this.emit("ended",this);this.previousTime=s}},destroy:function(){s.prototype.destroy.call(this),this.tags=null,this.audio&&this.stopAndReleaseAudioTag()},setMute:function(){this.audio&&(this.audio.muted=this.currentConfig.mute||this.manager.mute)},setVolume:function(){this.audio&&(this.audio.volume=this.currentConfig.volume*this.manager.volume)},setRate:function(){s.prototype.setRate.call(this),this.audio&&(this.audio.playbackRate=this.totalRate)}});Object.defineProperty(r.prototype,"mute",{get:function(){return this.currentConfig.mute},set:function(t){this.currentConfig.mute=t,this.manager.isLocked(this,"mute",t)||(this.setMute(),this.emit("mute",this,t))}}),Object.defineProperty(r.prototype,"volume",{get:function(){return this.currentConfig.volume},set:function(t){this.currentConfig.volume=t,this.manager.isLocked(this,"volume",t)||(this.setVolume(),this.emit("volume",this,t))}}),Object.defineProperty(r.prototype,"rate",{get:function(){return Object.getOwnPropertyDescriptor(s.prototype,"rate").get.call(this)},set:function(t){this.currentConfig.rate=t,this.manager.isLocked(this,"rate",t)||Object.getOwnPropertyDescriptor(s.prototype,"rate").set.call(this,t)}}),Object.defineProperty(r.prototype,"detune",{get:function(){return Object.getOwnPropertyDescriptor(s.prototype,"detune").get.call(this)},set:function(t){this.currentConfig.detune=t,this.manager.isLocked(this,"detune",t)||Object.getOwnPropertyDescriptor(s.prototype,"detune").set.call(this,t)}}),Object.defineProperty(r.prototype,"seek",{get:function(){return this.isPlaying?this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0):this.isPaused?this.currentConfig.seek:0},set:function(t){this.manager.isLocked(this,"seek",t)||this.startTime>0||(this.isPlaying||this.isPaused)&&(t=Math.min(Math.max(0,t),this.duration),this.isPlaying?(this.previousTime=t,this.audio.currentTime=t):this.isPaused&&(this.currentConfig.seek=t),this.emit("seek",this,t))}}),Object.defineProperty(r.prototype,"loop",{get:function(){return this.currentConfig.loop},set:function(t){this.currentConfig.loop=t,this.manager.isLocked(this,"loop",t)||(this.audio&&(this.audio.loop=t),this.emit("loop",this,t))}}),t.exports=r},function(t,e,i){var n=i(99),s=i(0),r=i(281),o=new s({Extends:n,initialize:function(t){this.override=!0,this.audioPlayDelay=.1,this.loopEndOffset=.05,this.onBlurPausedSounds=[],this.locked="ontouchstart"in window,this.lockedActionsQueue=this.locked?[]:null,this._mute=!1,this._volume=1,n.call(this,t)},add:function(t,e){var i=new r(this,t,e);return this.sounds.push(i),i},unlock:function(){var t=this,e=!1,i=function(){e=!0},n=function(){if(t.game.cache.audio.entries.size)if(e)e=!1;else{document.body.removeEventListener("touchmove",i),document.body.removeEventListener("touchend",n);var s=[];t.game.cache.audio.entries.each(function(t,e){for(var i=0;i-1&&(delete this.keys[n],this.scenes.splice(i,1),this._start.indexOf(n)>-1&&(i=this._start.indexOf(n),this._start.splice(i,1)),e.sys.destroy())}return this},bootScene:function(t){var e;t.init&&t.init.call(t,t.sys.settings.data),t.sys.load&&(e=t.sys.load).reset(),e&&t.preload?(t.preload.call(t),0===e.list.size?this.create(t):(t.sys.settings.status=s.LOADING,e.once("complete",this.loadComplete,this),e.start())):this.create(t)},loadComplete:function(t){var e=t.scene;this.create(e)},payloadComplete:function(t){this.bootScene(t.scene)},update:function(t,e){this.processQueue(),this._processing=1;for(var i=this.scenes.length-1;i>=0;i--){var n=this.scenes[i].sys;n.settings.status===s.RUNNING&&n.step(t,e)}},resize:function(t,e){for(var i=0;i=s.LOADING&&i.settings.status0){var i=this.getScene(t);this.scenes.splice(e,1),this.scenes.unshift(i)}}return this},moveDown:function(t){if(this._processing)this._queue.push({op:"moveDown",keyA:t,keyB:null});else{var e=this.getIndex(t);if(e>0){var i=e-1,n=this.getScene(t),s=this.getAt(i);this.scenes[e]=s,this.scenes[i]=n}}return this},moveUp:function(t){if(this._processing)this._queue.push({op:"moveUp",keyA:t,keyB:null});else{var e=this.getIndex(t);if(en&&-1!==i&&-1!==n){var s=this.getAt(n);this.scenes.splice(n,1),this.scenes.splice(i,0,s)}}return this},moveBelow:function(t,e){if(t===e)return this;if(this._processing)this._queue.push({op:"moveBelow",keyA:t,keyB:e});else{var i=this.getIndex(t),n=this.getIndex(e);if(i=0;t--){this.scenes[t].sys.destroy()}this.scenes=[],this._pending=[],this._start=[],this._queue=[],this.game=null}});t.exports=l},function(t,e,i){var n=i(6);t.exports=function(t,e,i,s,r,o,a,h){void 0===h&&(h=new n);var l=Math.sin(-r),u=Math.cos(-r),c=u*o,d=-l*o,f=l*a,p=u*a,g=c*p-d*f,v=p/g,y=-d/g,m=-f/g,x=c/g,b=(f*s-p*i)/g,w=-(c*s-d*i)/g;return h.x=t*v+e*m+b,h.y=t*y+e*x+w,h}},function(t,e,i){var n=new(i(0))({initialize:function(t){this.manager=t,this.capture=!0,this.enabled=!1,this.target,this.handler},boot:function(){var t=this.manager.config;this.enabled=t.inputTouch,this.target=t.inputTouchEventTarget,this.capture=t.inputTouchCapture,this.target||(this.target=this.manager.game.canvas),this.enabled&&this.startListeners()},startListeners:function(){var t,e=this.manager.queue,i=this.target,n={passive:!0},s={passive:!1};this.capture?(t=function(t){t.defaultPrevented||(e.push(t),t.preventDefault())},i.addEventListener("touchstart",t,s),i.addEventListener("touchmove",t,s),i.addEventListener("touchend",t,s)):(t=function(t){t.defaultPrevented||e.push(t)},i.addEventListener("touchstart",t,n),i.addEventListener("touchmove",t,n),i.addEventListener("touchend",t,n)),this.handler=t},stopListeners:function(){var t=this.target;t.removeEventListener("touchstart",this.handler),t.removeEventListener("touchmove",this.handler),t.removeEventListener("touchend",this.handler)},destroy:function(){this.stopListeners(),this.manager=null}});t.exports=n},function(t,e,i){var n=i(0),s=i(6),r=new n({initialize:function(t,e){this.manager=t,this.id=e,this.event,this.camera=null,this.buttons=0,this.position=new s,this.downX=0,this.downY=0,this.downTime=0,this.upX=0,this.upY=0,this.upTime=0,this.primaryDown=!1,this.dragState=0,this.isDown=!1,this.dirty=!1,this.justDown=!1,this.justUp=!1,this.justMoved=!1,this.wasTouch=!1,this.movementX=0,this.movementY=0},positionToCamera:function(t,e){return t.getWorldPoint(this.x,this.y,e)},x:{get:function(){return this.position.x},set:function(t){this.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t}},reset:function(){this.dirty=!1,this.justDown=!1,this.justUp=!1,this.justMoved=!1,this.movementX=0,this.movementY=0},touchmove:function(t){this.event=t,this.x=this.manager.transformX(t.changedTouches[0].pageX),this.y=this.manager.transformY(t.changedTouches[0].pageY),this.justMoved=!0,this.dirty=!0,this.wasTouch=!0},move:function(t){t.buttons&&(this.buttons=t.buttons),this.event=t,this.x=this.manager.transformX(t.pageX),this.y=this.manager.transformY(t.pageY),this.manager.mouse.locked&&(this.movementX+=t.movementX||t.mozMovementX||t.webkitMovementX||0,this.movementY+=t.movementY||t.mozMovementY||t.webkitMovementY||0),this.justMoved=!0,this.dirty=!0,this.wasTouch=!1},down:function(t,e){t.buttons&&(this.buttons=t.buttons),this.event=t,this.x=this.manager.transformX(t.pageX),this.y=this.manager.transformY(t.pageY),0===t.button&&(this.primaryDown=!0,this.downX=this.x,this.downY=this.y,this.downTime=e),this.justDown=!0,this.isDown=!0,this.dirty=!0,this.wasTouch=!1},touchstart:function(t,e){this.buttons=1,this.event=t,this.x=this.manager.transformX(t.changedTouches[0].pageX),this.y=this.manager.transformY(t.changedTouches[0].pageY),this.primaryDown=!0,this.downX=this.x,this.downY=this.y,this.downTime=e,this.justDown=!0,this.isDown=!0,this.dirty=!0,this.wasTouch=!0},up:function(t,e){t.buttons&&(this.buttons=t.buttons),this.event=t,this.x=this.manager.transformX(t.pageX),this.y=this.manager.transformY(t.pageY),0===t.button&&(this.primaryDown=!1,this.upX=this.x,this.upY=this.y,this.upTime=e),this.justUp=!0,this.isDown=!1,this.dirty=!0,this.wasTouch=!1},touchend:function(t,e){this.buttons=0,this.event=t,this.x=this.manager.transformX(t.changedTouches[0].pageX),this.y=this.manager.transformY(t.changedTouches[0].pageY),this.primaryDown=!1,this.upX=this.x,this.upY=this.y,this.upTime=e,this.justUp=!0,this.isDown=!1,this.dirty=!0,this.wasTouch=!0},noButtonDown:function(){return 0===this.buttons},leftButtonDown:function(){return 1&this.buttons},rightButtonDown:function(){return 2&this.buttons},middleButtonDown:function(){return 4&this.buttons},backButtonDown:function(){return 8&this.buttons},forwardButtonDown:function(){return 16&this.buttons},destroy:function(){this.camera=null,this.manager=null,this.position=null}});t.exports=r},function(t,e,i){var n=i(0),s=i(146),r=new n({initialize:function(t){this.manager=t,this.capture=!0,this.enabled=!1,this.target,this.handler,this.locked=!1},boot:function(){var t=this.manager.config;this.enabled=t.inputMouse,this.target=t.inputMouseEventTarget,this.capture=t.inputMouseCapture,this.target||(this.target=this.manager.game.canvas),t.disableContextMenu&&this.disableContextMenu(),this.enabled&&this.startListeners()},disableContextMenu:function(){return document.body.addEventListener("contextmenu",function(t){return t.preventDefault(),!1}),this},requestPointerLock:function(){if(s.pointerLock){var t=this.target;t.requestPointerLock=t.requestPointerLock||t.mozRequestPointerLock||t.webkitRequestPointerLock,t.requestPointerLock()}},pointerLockChange:function(t){var e=this.target;this.locked=document.pointerLockElement===e||document.mozPointerLockElement===e||document.webkitPointerLockElement===e,this.manager.queue.push(t)},releasePointerLock:function(){s.pointerLock&&(document.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock,document.exitPointerLock())},startListeners:function(){var t,e=this.manager.queue,i=this.target,n={passive:!0},r={passive:!1};this.capture?(t=function(t){t.defaultPrevented||(e.push(t),t.preventDefault())},i.addEventListener("mousemove",t,r),i.addEventListener("mousedown",t,r),i.addEventListener("mouseup",t,r)):(t=function(t){t.defaultPrevented||e.push(t)},i.addEventListener("mousemove",t,n),i.addEventListener("mousedown",t,n),i.addEventListener("mouseup",t,n)),this.handler=t,s.pointerLock&&(this.pointerLockChange=this.pointerLockChange.bind(this),document.addEventListener("pointerlockchange",this.pointerLockChange,!0),document.addEventListener("mozpointerlockchange",this.pointerLockChange,!0),document.addEventListener("webkitpointerlockchange",this.pointerLockChange,!0))},stopListeners:function(){var t=this.target;t.removeEventListener("mousemove",this.handler),t.removeEventListener("mousedown",this.handler),t.removeEventListener("mouseup",this.handler),s.pointerLock&&(document.removeEventListener("pointerlockchange",this.pointerLockChange,!0),document.removeEventListener("mozpointerlockchange",this.pointerLockChange,!0),document.removeEventListener("webkitpointerlockchange",this.pointerLockChange,!0))},destroy:function(){this.stopListeners(),this.manager=null}});t.exports=r},function(t,e,i){var n=i(0),s=i(2),r=i(803),o=i(801),a=new n({initialize:function(t,e,i){if(void 0===i&&(i={}),e.length<2)return!1;this.manager=t,this.enabled=!0,this.keyCodes=[];for(var n=0;n=this.threshold?this.pressed||(this.pressed=!0,this.events.emit("down",this.pad,this,this.value,t)):this.pressed&&(this.pressed=!1,this.events.emit("up",this.pad,this,this.value,t))}});t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.pad=t,this.events=t.events,this.index=e,this.value=0,this.threshold=.05},update:function(t){this.value=t},getValue:function(){var t=(Math.abs(this.value)-this.threshold)/(1-this.threshold);return t<0&&(t=0),t*(this.value>0?1:-1)}});t.exports=n},function(t,e,i){var n=i(296),s=i(295),r=new(i(0))({initialize:function(t,e,i){this.manager=t,this.events=t.events,this.id=e,this.index=i,this.connected=!0,this.timestamp=0,this.buttons=[],this.axes=[]},update:function(t){var e;this.timestamp=t.timestamp,this.connected=t.connected;var i=this.axes,r=this.buttons;for(e=0;e=n.x&&e>=n.y&&t<=n.x+o&&e<=n.y+a))return s;n.getWorldPoint(t,e,r);for(var h=n.cull(i),l={x:0,y:0},u=this.game.config.resolution,d=0;d80*i){n=h=t[0],a=l=t[1];for(var b=i;bh&&(h=u),f>l&&(l=f);g=Math.max(h-n,l-a)}return o(m,x,i,n,a,g),x}function s(t,e,i,n,s){var r,o;if(s===C(t,e,i,n)>0)for(r=e;r=e;r-=n)o=T(r,t[r],t[r+1],o);return o&&m(o,o.next)&&(S(o),o=o.next),o}function r(t,e){if(!t)return t;e||(e=t);var i,n=t;do{if(i=!1,n.steiner||!m(n,n.next)&&0!==y(n.prev,n,n.next))n=n.next;else{if(S(n),(n=e=n.prev)===n.next)return null;i=!0}}while(i||n!==e);return e}function o(t,e,i,n,s,c,d){if(t){!d&&c&&function(t,e,i,n){var s=t;do{null===s.z&&(s.z=f(s.x,s.y,e,i,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){var e,i,n,s,r,o,a,h,l=1;do{for(i=t,t=null,r=null,o=0;i;){for(o++,n=i,a=0,e=0;e0||h>0&&n;)0!==a&&(0===h||!n||i.z<=n.z)?(s=i,i=i.nextZ,a--):(s=n,n=n.nextZ,h--),r?r.nextZ=s:t=s,s.prevZ=r,r=s;i=n}r.nextZ=null,l*=2}while(o>1)}(s)}(t,n,s,c);for(var p,g,v=t;t.prev!==t.next;)if(p=t.prev,g=t.next,c?h(t,n,s,c):a(t))e.push(p.i/i),e.push(t.i/i),e.push(g.i/i),S(t),t=g.next,v=g.next;else if((t=g)===v){d?1===d?o(t=l(t,e,i),e,i,n,s,c,2):2===d&&u(t,e,i,n,s,c):o(r(t),e,i,n,s,c,1);break}}}function a(t){var e=t.prev,i=t,n=t.next;if(y(e,i,n)>=0)return!1;for(var s=t.next.next;s!==t.prev;){if(g(e.x,e.y,i.x,i.y,n.x,n.y,s.x,s.y)&&y(s.prev,s,s.next)>=0)return!1;s=s.next}return!0}function h(t,e,i,n){var s=t.prev,r=t,o=t.next;if(y(s,r,o)>=0)return!1;for(var a=s.xr.x?s.x>o.x?s.x:o.x:r.x>o.x?r.x:o.x,u=s.y>r.y?s.y>o.y?s.y:o.y:r.y>o.y?r.y:o.y,c=f(a,h,e,i,n),d=f(l,u,e,i,n),p=t.nextZ;p&&p.z<=d;){if(p!==t.prev&&p!==t.next&&g(s.x,s.y,r.x,r.y,o.x,o.y,p.x,p.y)&&y(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=t.prevZ;p&&p.z>=c;){if(p!==t.prev&&p!==t.next&&g(s.x,s.y,r.x,r.y,o.x,o.y,p.x,p.y)&&y(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}function l(t,e,i){var n=t;do{var s=n.prev,r=n.next.next;!m(s,r)&&x(s,n,n.next,r)&&b(s,r)&&b(r,s)&&(e.push(s.i/i),e.push(n.i/i),e.push(r.i/i),S(n),S(n.next),n=t=r),n=n.next}while(n!==t);return n}function u(t,e,i,n,s,a){var h=t;do{for(var l=h.next.next;l!==h.prev;){if(h.i!==l.i&&v(h,l)){var u=w(h,l);return h=r(h,h.next),u=r(u,u.next),o(h,e,i,n,s,a),void o(u,e,i,n,s,a)}l=l.next}h=h.next}while(h!==t)}function c(t,e){return t.x-e.x}function d(t,e){if(e=function(t,e){var i,n=e,s=t.x,r=t.y,o=-1/0;do{if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){var a=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(a<=s&&a>o){if(o=a,a===s){if(r===n.y)return n;if(r===n.next.y)return n.next}i=n.x=n.x&&n.x>=u&&s!==n.x&&g(ri.x)&&b(n,t)&&(i=n,d=h),n=n.next;return i}(t,e)){var i=w(e,t);r(i,i.next)}}function f(t,e,i,n,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)/s)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)/s)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function p(t){var e=t,i=t;do{e.x=0&&(t-o)*(n-a)-(i-o)*(e-a)>=0&&(i-o)*(r-a)-(s-o)*(n-a)>=0}function v(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&x(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&b(t,e)&&b(e,t)&&function(t,e){var i=t,n=!1,s=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&i.next.y!==i.y&&s<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)}function y(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function m(t,e){return t.x===e.x&&t.y===e.y}function x(t,e,i,n){return!!(m(t,e)&&m(i,n)||m(t,n)&&m(i,e))||y(t,e,i)>0!=y(t,e,n)>0&&y(i,n,t)>0!=y(i,n,e)>0}function b(t,e){return y(t.prev,t,t.next)<0?y(t,e,t.next)>=0&&y(t,t.prev,e)>=0:y(t,e,t.prev)<0||y(t,t.next,e)<0}function w(t,e){var i=new A(t.i,t.x,t.y),n=new A(e.i,e.x,e.y),s=t.next,r=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,n.next=i,i.prev=n,r.next=n,n.prev=r,n}function T(t,e,i,n){var s=new A(t,e,i);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function S(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function A(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function C(t,e,i,n){for(var s=0,r=e,o=i-n;r0&&(n+=t[s-1].length,i.holes.push(n))}return i}},function(t,e,i){var n,s,r,o=i(23),a={supportInverseAlpha:!1,supportNewBlendModes:!1};t.exports=(void 0!==document&&(a.supportNewBlendModes=(n="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/",s="AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==",(r=new Image).onload=function(){var t=new Image;t.onload=function(){var e=o.create(t,6,1).getContext("2d");if(e.globalCompositeOperation="multiply",e.drawImage(r,0,0),e.drawImage(t,2,0),!e.getImageData(2,0,1,1))return!1;var i=e.getImageData(2,0,1,1).data;o.remove(t),a.supportNewBlendModes=255===i[0]&&0===i[1]&&0===i[2]},t.src=n+"/wCKxvRF"+s},r.src=n+"AP804Oa6"+s,!1),a.supportInverseAlpha=function(){var t=o.create(this,2,1).getContext("2d");t.fillStyle="rgba(10, 20, 30, 0.5)",t.fillRect(0,0,1,1);var e=t.getImageData(0,0,1,1);if(null===e)return!1;t.putImageData(e,1,0);var i=t.getImageData(1,0,1,1);return i.data[0]===e.data[0]&&i.data[1]===e.data[1]&&i.data[2]===e.data[2]&&i.data[3]===e.data[3]}()),a)},function(t,e){t.exports={Global:["anims","cache","registry","sound","textures"],CoreScene:["EventEmitter","CameraManager","GameObjectCreator","GameObjectFactory","ScenePlugin","DisplayList","UpdateList"],DefaultScene:["CameraManager3D","Clock","DataManagerPlugin","InputPlugin","Loader","TweenManager","LightsPlugin"]}},function(t,e,i){var n=i(0),s=i(3),r=new n({initialize:function(){this.isRunning=!1,this.callback=s,this.tick=0,this.isSetTimeOut=!1,this.timeOutID=null,this.lastTime=0;var t=this;this.step=function e(i){t.lastTime=t.tick,t.tick=i,t.callback(i),t.timeOutID=window.requestAnimationFrame(e)},this.stepTimeout=function e(){var i=Date.now(),n=Math.max(16+t.lastTime-i,0);t.lastTime=t.tick,t.tick=i,t.callback(i),t.timeOutID=window.setTimeout(e,n)}},start:function(t,e){this.isRunning||(this.callback=t,this.isSetTimeOut=e,this.isRunning=!0,this.timeOutID=e?window.setTimeout(this.stepTimeout,0):window.requestAnimationFrame(this.step))},stop:function(){this.isRunning=!1,this.isSetTimeOut?clearTimeout(this.timeOutID):window.cancelAnimationFrame(this.timeOutID)},destroy:function(){this.stop(),this.callback=s}});t.exports=r},function(t,e){t.exports=function(t){t.parentNode&&t.parentNode.removeChild(t)}},function(t,e){t.exports=function(t){var e="";try{window.DOMParser?e=(new DOMParser).parseFromString(t,"text/xml"):(e=new ActiveXObject("Microsoft.XMLDOM")).loadXML(t)}catch(t){e=null}return e&&e.documentElement&&!e.getElementsByTagName("parsererror").length?e:null}},function(t,e,i){var n=i(76);t.exports=function(t){if("complete"!==document.readyState&&"interactive"!==document.readyState){var e=function(){document.removeEventListener("deviceready",e,!0),document.removeEventListener("DOMContentLoaded",e,!0),window.removeEventListener("load",e,!0),t()};document.body?n.cordova&&!n.cocoonJS?document.addEventListener("deviceready",e,!1):(document.addEventListener("DOMContentLoaded",e,!0),window.addEventListener("load",e,!0)):window.setTimeout(e,20)}else t()}},function(t,e){t.exports=function(t,e){return Math.floor(Math.random()*(e-t+1)+t)}},function(t,e,i){var n=i(155);t.exports=function(t,e,i){void 0===e&&(e=1),void 0===i&&(i=1);var s=Math.floor(6*t),r=6*t-s,o=Math.floor(i*(1-e)*255),a=Math.floor(i*(1-r*e)*255),h=Math.floor(i*(1-(1-r)*e)*255),l={r:i=Math.floor(i*=255),g:i,b:i,color:0},u=s%6;return 0===u?(l.g=h,l.b=o):1===u?(l.r=a,l.b=o):2===u?(l.r=o,l.b=h):3===u?(l.r=o,l.g=a):4===u?(l.r=h,l.g=o):5===u&&(l.g=o,l.b=a),l.color=n(l.r,l.g,l.b),l}},function(t,e,i){(function(t){t.export=function(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}}).call(this,i(831)(t))},function(t,e){t.exports=function(t){var e=t.toString(16);return 1===e.length?"0"+e:e}},function(t,e,i){var n=i(41);n.ColorToRGBA=i(833),n.ComponentToHex=i(311),n.GetColor=i(155),n.GetColor32=i(335),n.HexStringToColor=i(336),n.HSLToColor=i(832),n.HSVColorWheel=i(830),n.HSVToRGB=i(309),n.HueToComponent=i(310),n.IntegerToColor=i(334),n.IntegerToRGB=i(333),n.Interpolate=i(829),n.ObjectToColor=i(332),n.RandomRGB=i(828),n.RGBStringToColor=i(331),n.RGBToHSV=i(827),n.RGBToString=i(826),n.ValueToColor=i(156),t.exports=n},function(t,e){t.exports={setCrisp:function(t){return["optimizeSpeed","crisp-edges","-moz-crisp-edges","-webkit-optimize-contrast","optimize-contrast","pixelated"].forEach(function(e){t.style["image-rendering"]=e}),t.style.msInterpolationMode="nearest-neighbor",t},setBicubic:function(t){return t.style["image-rendering"]="auto",t.style.msInterpolationMode="bicubic",t}}},function(t,e,i){var n=i(149),s=i(0),r=i(56),o=i(6),a=new s({Extends:r,initialize:function(t){void 0===t&&(t=[]),r.call(this,"SplineCurve"),this.points=[],this.addPoints(t)},addPoints:function(t){for(var e=0;ei.length-2?i.length-1:r+1],c=i[r>i.length-3?i.length-1:r+2];return e.set(n(a,h.x,l.x,u.x,c.x),n(a,h.y,l.y,u.y,c.y))},toJSON:function(){for(var t=[],e=0;ei;)n-=i;n0&&(s=1/Math.sqrt(s),this.x=t*s,this.y=e*s,this.z=i*s,this.w=n*s),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z,r=this.w;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this.w=r+e*(t.w-r),this},rotationTo:function(t,e){var i=t.x*e.x+t.y*e.y+t.z*e.z;return i<-.999999?(u.copy(h).cross(t).length()<1e-6&&u.copy(l).cross(t),u.normalize(),this.setAxisAngle(u,Math.PI)):i>.999999?(this.x=0,this.y=0,this.z=0,this.w=1,this):(u.copy(t).cross(e),this.x=u.x,this.y=u.y,this.z=u.z,this.w=1+i,this.normalize())},setAxes:function(t,e,i){var n=c.val;return n[0]=e.x,n[3]=e.y,n[6]=e.z,n[1]=i.x,n[4]=i.y,n[7]=i.z,n[2]=-t.x,n[5]=-t.y,n[8]=-t.z,this.fromMat3(c).normalize()},identity:function(){return this.x=0,this.y=0,this.z=0,this.w=1,this},setAxisAngle:function(t,e){e*=.5;var i=Math.sin(e);return this.x=i*t.x,this.y=i*t.y,this.z=i*t.z,this.w=Math.cos(e),this},multiply:function(t){var e=this.x,i=this.y,n=this.z,s=this.w,r=t.x,o=t.y,a=t.z,h=t.w;return this.x=e*h+s*r+i*a-n*o,this.y=i*h+s*o+n*r-e*a,this.z=n*h+s*a+e*o-i*r,this.w=s*h-e*r-i*o-n*a,this},slerp:function(t,e){var i=this.x,n=this.y,s=this.z,r=this.w,o=t.x,a=t.y,h=t.z,l=t.w,u=i*o+n*a+s*h+r*l;u<0&&(u=-u,o=-o,a=-a,h=-h,l=-l);var c=1-e,d=e;if(1-u>1e-6){var f=Math.acos(u),p=Math.sin(f);c=Math.sin((1-e)*f)/p,d=Math.sin(e*f)/p}return this.x=c*i+d*o,this.y=c*n+d*a,this.z=c*s+d*h,this.w=c*r+d*l,this},invert:function(){var t=this.x,e=this.y,i=this.z,n=this.w,s=t*t+e*e+i*i+n*n,r=s?1/s:0;return this.x=-t*r,this.y=-e*r,this.z=-i*r,this.w=n*r,this},conjugate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},rotateX:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o+s*r,this.y=i*o+n*r,this.z=n*o-i*r,this.w=s*o-e*r,this},rotateY:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o-n*r,this.y=i*o+s*r,this.z=n*o+e*r,this.w=s*o-i*r,this},rotateZ:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o+i*r,this.y=i*o-e*r,this.z=n*o+s*r,this.w=s*o-n*r,this},calculateW:function(){var t=this.x,e=this.y,i=this.z;return this.w=-Math.sqrt(Math.abs(1-t*t-e*e-i*i)),this},fromMat3:function(t){var e,i=t.val,n=i[0]+i[4]+i[8];if(n>0)e=Math.sqrt(n+1),this.w=.5*e,e=.5/e,this.x=(i[7]-i[5])*e,this.y=(i[2]-i[6])*e,this.z=(i[3]-i[1])*e;else{var s=0;i[4]>i[0]&&(s=1),i[8]>i[3*s+s]&&(s=2);var r=o[s],h=o[r];e=Math.sqrt(i[3*s+s]-i[3*r+r]-i[3*h+h]+1),a[s]=.5*e,e=.5/e,a[r]=(i[3*r+s]+i[3*s+r])*e,a[h]=(i[3*h+s]+i[3*s+h])*e,this.x=a[0],this.y=a[1],this.z=a[2],this.w=(i[3*h+r]-i[3*r+h])*e}return this}});t.exports=d},function(t,e,i){var n=i(57),s=i(153),r=i(327),o=new s,a=new r,h=new n;t.exports=function(t,e,i){return a.setAxisAngle(e,i),o.fromRotationTranslation(a,h.set(0,0,0)),t.transformMat4(o)}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1),t.x=(2*Math.random()-1)*e,t.y=(2*Math.random()-1)*e,t.z=(2*Math.random()-1)*e,t.w=(2*Math.random()-1)*e,t}},function(t,e){t.exports=function(t,e){void 0===e&&(e=1);var i=2*Math.random()*Math.PI,n=2*Math.random()-1,s=Math.sqrt(1-n*n)*e;return t.x=Math.cos(i)*s,t.y=Math.sin(i)*s,t.z=n*e,t}},function(t,e,i){var n=i(41);t.exports=function(t){var e=new n,i=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(t.toLowerCase());if(i){var s=parseInt(i[1],10),r=parseInt(i[2],10),o=parseInt(i[3],10),a=void 0!==i[4]?parseFloat(i[4]):1;e.setTo(s,r,o,255*a)}return e}},function(t,e,i){var n=i(41);t.exports=function(t){return new n(t.r,t.g,t.b,t.a)}},function(t,e){t.exports=function(t){return t>16777215?{a:t>>>24,r:t>>16&255,g:t>>8&255,b:255&t}:{a:255,r:t>>16&255,g:t>>8&255,b:255&t}}},function(t,e,i){var n=i(41),s=i(333);t.exports=function(t){var e=s(t);return new n(e.r,e.g,e.b,e.a)}},function(t,e){t.exports=function(t,e,i,n){return n<<24|t<<16|e<<8|i}},function(t,e,i){var n=i(41);t.exports=function(t){var e=new n;t=t.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i,function(t,e,i,n){return e+e+i+i+n+n});var i=/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);if(i){var s=parseInt(i[1],16),r=parseInt(i[2],16),o=parseInt(i[3],16);e.setTo(s,r,o)}return e}},function(t,e,i){var n=i(338),s=new(i(0))({initialize:function(t){this.game=t,this.binary=new n,this.bitmapFont=new n,this.json=new n,this.physics=new n,this.shader=new n,this.audio=new n,this.text=new n,this.obj=new n,this.tilemap=new n,this.xml=new n,this.custom={},this.game.events.once("destroy",this.destroy,this)},addCustom:function(t){return this.custom.hasOwnProperty(t)||(this.custom[t]=new n),this.custom[t]},destroy:function(){for(var t=["binary","bitmapFont","json","physics","shader","audio","text","obj","tilemap","xml"],e=0;e0){if(0===t)this.frames=i.concat(this.frames);else if(t===this.frames.length)this.frames=this.frames.concat(i);else{var n=this.frames.slice(0,t),s=this.frames.slice(t);this.frames=n.concat(i,s)}this.updateFrameSequence()}return this},checkFrame:function(t){return t0){o.isLast=!0,o.nextFrame=l[0],l[0].prevFrame=o;var v=1/(l.length-1);for(a=0;a=this.frames.length&&(e=0),t.currentAnim!==this&&(t.currentAnim=this,t._timeScale=1,t.frameRate=this.frameRate,t.duration=this.duration,t.msPerFrame=this.msPerFrame,t.skipMissedFrames=this.skipMissedFrames,t._delay=this.delay,t._repeat=this.repeat,t._repeatDelay=this.repeatDelay,t._yoyo=this.yoyo,t._callbackArgs[1]=this,t._updateParams=t._callbackArgs.concat(this.onUpdateParams)),t.updateFrame(this.frames[e])},nextFrame:function(t){var e=t.currentFrame;e.isLast?this.yoyo?(t.forward=!1,t.updateFrame(e.prevFrame),this.getNextTick(t)):t.repeatCounter>0?this.repeatAnimation(t):this.completeAnimation(t):(t.updateFrame(e.nextFrame),this.getNextTick(t))},previousFrame:function(t){var e=t.currentFrame;e.isFirst?t.repeatCounter>0?this.repeatAnimation(t):this.completeAnimation(t):(t.updateFrame(e.prevFrame),this.getNextTick(t))},removeFrame:function(t){var e=this.frames.indexOf(t);return-1!==e&&this.removeFrameAt(e),this},removeFrameAt:function(t){return this.frames.splice(t,1),this.updateFrameSequence(),this},repeatAnimation:function(t){t._repeatDelay>0&&!1===t.pendingRepeat?(t.pendingRepeat=!0,t.accumulator-=t.nextTick,t.nextTick+=1e3*t._repeatDelay):(t.repeatCounter--,t.forward=!0,t.updateFrame(t.currentFrame.nextFrame),this.getNextTick(t),t.pendingRepeat=!1,this.onRepeat&&this.onRepeat.apply(this.callbackScope,t._callbackArgs.concat(this.onRepeatParams)))},setFrame:function(t){t.forward?this.nextFrame(t):this.previousFrame(t)},toJSON:function(){var t={key:this.key,type:this.type,frames:[],frameRate:this.frameRate,duration:this.duration,skipMissedFrames:this.skipMissedFrames,delay:this.delay,repeat:this.repeat,repeatDelay:this.repeatDelay,yoyo:this.yoyo,showOnStart:this.showOnStart,hideOnComplete:this.hideOnComplete};return this.frames.forEach(function(e){t.frames.push(e.toJSON())}),t},updateFrameSequence:function(){for(var t=this.frames.length,e=1/(t-1),i=0;i1&&(n.prevFrame=this.frames[i-1],n.nextFrame=this.frames[i+1])}return this},pause:function(){return this.paused=!0,this},resume:function(){return this.paused=!1,this},destroy:function(){}});t.exports=o},function(t,e){t.exports=function(t,e,i){return(t=Math.max(0,Math.min(1,(t-e)/(i-e))))*t*(3-2*t)}},function(t,e){t.exports=function(t,e,i){return(t=Math.max(0,Math.min(1,(t-e)/(i-e))))*t*t*(t*(6*t-15)+10)}},function(t,e){t.exports=function(t,e,i){void 0===e&&(e=1),void 0===i&&(i=[]);var n=Math.round(t.x1),s=Math.round(t.y1),r=Math.round(t.x2),o=Math.round(t.y2),a=Math.abs(r-n),h=Math.abs(o-s),l=n-h&&(c-=h,n+=l),f=t.right&&(h=1,a+=o-t.right,o=t.right);break;case 1:(a+=e)>=t.bottom&&(h=2,o-=a-t.bottom,a=t.bottom);break;case 2:(o-=e)<=t.left&&(h=3,a-=t.left-o,o=t.left);break;case 3:(a-=e)<=t.top&&(h=0,a=t.top)}return r}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===s&&(s=0),void 0===r&&(r=0),this.matrix=new Float32Array([t,e,i,n,s,r,0,0,1]),this.decomposedMatrix={translateX:0,translateY:0,scaleX:1,scaleY:1,rotation:0}},loadIdentity:function(){var t=this.matrix;return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,this},translate:function(t,e){var i=this.matrix;return i[4]=i[0]*t+i[2]*e+i[4],i[5]=i[1]*t+i[3]*e+i[5],this},scale:function(t,e){var i=this.matrix;return i[0]*=t,i[1]*=t,i[2]*=e,i[3]*=e,this},rotate:function(t){var e=Math.sin(t),i=Math.cos(t);return this.transform(i,e,-e,i,0,0)},multiply:function(t){var e=this.matrix,i=t.matrix,n=e[0],s=e[1],r=e[2],o=e[3],a=e[4],h=e[5],l=i[0],u=i[1],c=i[2],d=i[3],f=i[4],p=i[5];return e[0]=l*n+u*r,e[1]=l*s+u*o,e[2]=c*n+d*r,e[3]=c*s+d*o,e[4]=f*n+p*r+a,e[5]=f*s+p*o+h,this},transform:function(t,e,i,n,s,r){var o=this.matrix,a=o[0],h=o[1],l=o[2],u=o[3],c=o[4],d=o[5];return o[0]=t*a+e*l,o[1]=t*h+e*u,o[2]=i*a+n*l,o[3]=i*h+n*u,o[4]=s*a+r*l+c,o[5]=s*h+r*u+d,this},transformPoint:function(t,e,i){void 0===i&&(i={x:0,y:0});var n=this.matrix,s=n[0],r=n[1],o=n[2],a=n[3],h=n[4],l=n[5];return i.x=t*s+e*o+h,i.y=t*r+e*a+l,i},invert:function(){var t=this.matrix,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=e*s-i*n;return t[0]=s/a,t[1]=-i/a,t[2]=-n/a,t[3]=e/a,t[4]=(n*o-s*r)/a,t[5]=-(e*o-i*r)/a,this},setTransform:function(t,e,i,n,s,r){var o=this.matrix;return o[0]=t,o[1]=e,o[2]=i,o[3]=n,o[4]=s,o[5]=r,this},decomposeMatrix:function(){var t=this.decomposedMatrix,e=this.matrix,i=e[0],n=e[1],s=e[2],r=e[3],o=i*i,a=n*n,h=s*s,l=r*r,u=Math.sqrt(o+h),c=Math.sqrt(a+l);return t.translateX=e[4],t.translateY=e[5],t.scaleX=u,t.scaleY=c,t.rotation=Math.acos(i/u)*(Math.atan(-s/i)<0?-1:1),t},applyITRS:function(t,e,i,n,s){var r=this.matrix,o=Math.sin(i),a=Math.cos(i);return r[4]=t,r[5]=e,r[0]=a*n,r[1]=-o*n,r[2]=o*s,r[3]=a*s,this}});t.exports=n},function(t,e){t.exports={defaultPipeline:null,pipeline:null,initPipeline:function(t){var e=this.scene.sys.game.renderer;return!!(e&&e.gl&&e.hasPipeline(t))&&(this.defaultPipeline=e.getPipeline(t),this.pipeline=this.defaultPipeline,!0)},setPipeline:function(t){var e=this.scene.sys.game.renderer;return!!(e&&e.gl&&e.hasPipeline(t))&&(this.pipeline=e.getPipeline(t),!0)},resetPipeline:function(){return this.pipeline=this.defaultPipeline,null!==this.pipeline},getPipelineName:function(){return this.pipeline.name}}},function(t,e){t.exports=function(t,e,i,n){var s=Math.cos(n),r=Math.sin(n),o=t.x-e,a=t.y-i;return t.x=o*s-a*r+e,t.y=o*r+a*s+i,t}},function(t,e,i){var n=i(4);t.exports=function(t,e,i){return void 0===i&&(i=new n),i.x=t.x1+(t.x2-t.x1)*e,i.y=t.y1+(t.y2-t.y1)*e,i}},function(t,e,i){var n=i(166),s=i(105);t.exports=function(t,e,i,r){void 0===r&&(r=[]),e||(e=s(t)/i);for(var o=0;othis.vertexCapacity&&this.flush();var x=this.vertexViewF32,b=this.vertexViewU32,w=this.vertexCount*this.vertexComponentCount,T=r+a,S=o+h,A=m[0],C=m[1],M=m[2],_=m[3],E=d*A+f*M,P=d*C+f*_,L=p*A+g*M,k=p*C+g*_,F=v*A+y*M+m[4],O=v*C+y*_+m[5],R=r*E+o*L+F,B=r*P+o*k+O,I=r*E+S*L+F,D=r*P+S*k+O,Y=T*E+S*L+F,z=T*P+S*k+O,X=T*E+o*L+F,N=T*P+o*k+O,V=l.getTintAppendFloatAlphaAndSwap(u,c);x[w+0]=R,x[w+1]=B,b[w+2]=V,x[w+3]=I,x[w+4]=D,b[w+5]=V,x[w+6]=Y,x[w+7]=z,b[w+8]=V,x[w+9]=R,x[w+10]=B,b[w+11]=V,x[w+12]=Y,x[w+13]=z,b[w+14]=V,x[w+15]=X,x[w+16]=N,b[w+17]=V,this.vertexCount+=6},batchFillTriangle:function(t,e,i,n,s,r,o,a,h,u,c,d,f,p,g,v,y,m,x,b){this.renderer.setPipeline(this),this.vertexCount+3>this.vertexCapacity&&this.flush();var w=this.vertexViewF32,T=this.vertexViewU32,S=this.vertexCount*this.vertexComponentCount,A=b[0],C=b[1],M=b[2],_=b[3],E=p*A+g*M,P=p*C+g*_,L=v*A+y*M,k=v*C+y*_,F=m*A+x*M+b[4],O=m*C+x*_+b[5],R=r*E+o*L+F,B=r*P+o*k+O,I=a*E+h*L+F,D=a*P+h*k+O,Y=u*E+c*L+F,z=u*P+c*k+O,X=l.getTintAppendFloatAlphaAndSwap(d,f);w[S+0]=R,w[S+1]=B,T[S+2]=X,w[S+3]=I,w[S+4]=D,T[S+5]=X,w[S+6]=Y,w[S+7]=z,T[S+8]=X,this.vertexCount+=3},batchStrokeTriangle:function(t,e,i,n,s,r,o,a,h,l,u,c,d,f,p,g,v,y,m,x,b){var w=this.tempTriangle;w[0].x=r,w[0].y=o,w[0].width=c,w[0].rgb=d,w[0].alpha=f,w[1].x=a,w[1].y=h,w[1].width=c,w[1].rgb=d,w[1].alpha=f,w[2].x=l,w[2].y=u,w[2].width=c,w[2].rgb=d,w[2].alpha=f,w[3].x=r,w[3].y=o,w[3].width=c,w[3].rgb=d,w[3].alpha=f,this.batchStrokePath(t,e,i,n,s,w,c,d,f,p,g,v,y,m,x,!1,b)},batchFillPath:function(t,e,i,n,s,o,a,h,u,c,d,f,p,g,v){this.renderer.setPipeline(this);for(var y,m,x,b,w,T,S,A,C,M,_,E,P,L,k,F,O,R=o.length,B=this.polygonCache,I=this.vertexViewF32,D=this.vertexViewU32,Y=0,z=v[0],X=v[1],N=v[2],V=v[3],W=u*z+c*N,G=u*X+c*V,U=d*z+f*N,j=d*X+f*V,H=p*z+g*N+v[4],q=p*X+g*V+v[5],K=l.getTintAppendFloatAlphaAndSwap(a,h),J=0;Jthis.vertexCapacity&&this.flush(),Y=this.vertexCount*this.vertexComponentCount,E=(T=B[x+0])*W+(S=B[x+1])*U+H,P=T*G+S*j+q,L=(A=B[b+0])*W+(C=B[b+1])*U+H,k=A*G+C*j+q,F=(M=B[w+0])*W+(_=B[w+1])*U+H,O=M*G+_*j+q,I[Y+0]=E,I[Y+1]=P,D[Y+2]=K,I[Y+3]=L,I[Y+4]=k,D[Y+5]=K,I[Y+6]=F,I[Y+7]=O,D[Y+8]=K,this.vertexCount+=3;B.length=0},batchStrokePath:function(t,e,i,n,s,r,o,a,h,u,c,d,f,p,g,v,y){var m,x;this.renderer.setPipeline(this);for(var b,w,T,S,A=r.length,C=this.polygonCache,M=this.vertexViewF32,_=this.vertexViewU32,E=l.getTintAppendFloatAlphaAndSwap,P=0;P+1this.vertexCapacity&&this.flush(),b=C[L-1]||C[k-1],w=C[L],M[(T=this.vertexCount*this.vertexComponentCount)+0]=b[6],M[T+1]=b[7],_[T+2]=E(b[8],h),M[T+3]=b[0],M[T+4]=b[1],_[T+5]=E(b[2],h),M[T+6]=w[9],M[T+7]=w[10],_[T+8]=E(w[11],h),M[T+9]=b[0],M[T+10]=b[1],_[T+11]=E(b[2],h),M[T+12]=b[6],M[T+13]=b[7],_[T+14]=E(b[8],h),M[T+15]=w[3],M[T+16]=w[4],_[T+17]=E(w[5],h),this.vertexCount+=6;C.length=0},batchLine:function(t,e,i,n,s,r,o,a,h,u,c,d,f,p,g,v,y,m,x,b,w){this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var T=w[0],S=w[1],A=w[2],C=w[3],M=g*T+v*A,_=g*S+v*C,E=y*T+m*A,P=y*S+m*C,L=x*T+b*A+w[4],k=x*S+b*C+w[5],F=this.vertexViewF32,O=this.vertexViewU32,R=a-r,B=h-o,I=Math.sqrt(R*R+B*B),D=u*(h-o)/I,Y=u*(r-a)/I,z=c*(h-o)/I,X=c*(r-a)/I,N=a-z,V=h-X,W=r-D,G=o-Y,U=a+z,j=h+X,H=r+D,q=o+Y,K=N*M+V*E+L,J=N*_+V*P+k,Z=W*M+G*E+L,Q=W*_+G*P+k,$=U*M+j*E+L,tt=U*_+j*P+k,et=H*M+q*E+L,it=H*_+q*P+k,nt=l.getTintAppendFloatAlphaAndSwap,st=nt(d,p),rt=nt(f,p),ot=this.vertexCount*this.vertexComponentCount;return F[ot+0]=K,F[ot+1]=J,O[ot+2]=rt,F[ot+3]=Z,F[ot+4]=Q,O[ot+5]=st,F[ot+6]=$,F[ot+7]=tt,O[ot+8]=rt,F[ot+9]=Z,F[ot+10]=Q,O[ot+11]=st,F[ot+12]=et,F[ot+13]=it,O[ot+14]=st,F[ot+15]=$,F[ot+16]=tt,O[ot+17]=rt,this.vertexCount+=6,[K,J,f,Z,Q,d,$,tt,f,et,it,d]},batchGraphics:function(t,e){if(!(t.commandBuffer.length<=0)){this.renderer.setPipeline(this);var i,n,r=e.scrollX*t.scrollFactorX,o=e.scrollY*t.scrollFactorY,a=t.x-r,h=t.y-o,l=t.scaleX,u=t.scaleY,y=-t.rotation,m=t.commandBuffer,x=t.alpha,b=1,w=1,T=0,S=0,A=1,C=e.matrix.matrix,M=null,_=0,E=0,P=0,L=0,k=0,F=0,O=0,R=0,B=0,I=0,D=null,Y=Math.sin,z=Math.cos,X=2*Math.PI,N=Y(y),V=z(y),W=V*l,G=-N*l,U=N*u,j=V*u,H=a,q=h,K=C[0],J=C[1],Z=C[2],Q=C[3],$=W*K+G*Z,tt=W*J+G*Q,et=U*K+j*Z,it=U*J+j*Q,nt=H*K+q*Z+C[4],st=H*J+q*Q+C[5];v.length=0;for(var rt=0,ot=m.length;rt0&&(B=B%X-X):B>X?B=X:B<0&&(B=X+B%X);_<1;)E=k+z(L=B*_+R)*O,P=F+Y(L)*O,M.points.push(new c(E,P,A,T,b*x)),_+=.01;E=k+z(L=B+R)*O,P=F+Y(L)*O,M.points.push(new c(E,P,A,T,b*x)),rt+=6;break;case s.LINE_STYLE:A=m[rt+1],T=m[rt+2],b=m[rt+3],rt+=3;break;case s.FILL_STYLE:S=m[rt+1],w=m[rt+2],rt+=2;break;case s.BEGIN_PATH:v.length=0,M=null;break;case s.CLOSE_PATH:M&&M.points.length&&M.points.push(M.points[0]);break;case s.FILL_PATH:for(i=0,n=v.length;i=0&&n>=0;return r[0]===t&&r[1]===e&&r[2]===i&&r[3]===n||this.flush(),r[0]=t,r[1]=e,r[2]=i,r[3]=n,this.currentScissorEnabled=o,o?(s.disable(s.SCISSOR_TEST),this):(s.enable(s.SCISSOR_TEST),s.scissor(t,s.drawingBufferHeight-e-n,i,n),this)},pushScissor:function(t,e,i,n){var s=this.scissorStack,r=this.currentScissorIdx,o=this.currentScissor;return s[r+0]=o[0],s[r+1]=o[1],s[r+2]=o[2],s[r+3]=o[3],this.currentScissorIdx+=4,this.setScissor(t,e,i,n),this},popScissor:function(){var t=this.scissorStack,e=this.currentScissorIdx-4,i=t[e+0],n=t[e+1],s=t[e+2],r=t[e+3];return this.currentScissorIdx=e,this.setScissor(i,n,s,r),this},setPipeline:function(t){return this.currentPipeline===t&&this.currentPipeline.vertexBuffer===this.currentVertexBuffer&&this.currentPipeline.program===this.currentProgram||(this.flush(),this.currentPipeline=t,this.currentPipeline.bind()),this.currentPipeline.onBind(),this.currentPipeline},setBlendMode:function(t){var e=this.gl,i=this.blendModes[t];return t!==s.BlendModes.SKIP_CHECK&&this.currentBlendMode!==t&&(this.flush(),e.enable(e.BLEND),e.blendEquation(i.equation),i.func.length>2?e.blendFuncSeparate(i.func[0],i.func[1],i.func[2],i.func[3]):e.blendFunc(i.func[0],i.func[1]),this.currentBlendMode=t),this},addBlendMode:function(t,e){return this.blendModes.push({func:t,equation:e})-1},updateBlendMode:function(t,e,i){return this.blendModes[t]&&(this.blendModes[t].func=e,i&&(this.blendModes[t].equation=i)),this},removeBlendMode:function(t){return t>16&&this.blendModes[t]&&this.blendModes.splice(t,1),this},setTexture2D:function(t,e){var i=this.gl;return t!==this.currentTextures[e]&&(this.flush(),this.currentActiveTextureUnit!==e&&(i.activeTexture(i.TEXTURE0+e),this.currentActiveTextureUnit=e),i.bindTexture(i.TEXTURE_2D,t),this.currentTextures[e]=t),this},setFramebuffer:function(t){var e=this.gl;return t!==this.currentFramebuffer&&(this.flush(),e.bindFramebuffer(e.FRAMEBUFFER,t),this.currentFramebuffer=t),this},setProgram:function(t){var e=this.gl;return t!==this.currentProgram&&(this.flush(),e.useProgram(t),this.currentProgram=t),this},setVertexBuffer:function(t){var e=this.gl;return t!==this.currentVertexBuffer&&(this.flush(),e.bindBuffer(e.ARRAY_BUFFER,t),this.currentVertexBuffer=t),this},setIndexBuffer:function(t){var e=this.gl;return t!==this.currentIndexBuffer&&(this.flush(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.currentIndexBuffer=t),this},createTextureFromSource:function(t,e,i,n){var o=this.gl,a=o.NEAREST,h=o.CLAMP_TO_EDGE;return e=t?t.width:e,i=t?t.height:i,r(e,i)&&(h=o.REPEAT),n===s.ScaleModes.LINEAR?a=o.LINEAR:(n===s.ScaleModes.NEAREST||this.config.pixelArt)&&(a=o.NEAREST),t||"number"!=typeof e||"number"!=typeof i?this.createTexture2D(0,a,a,h,h,o.RGBA,t):this.createTexture2D(0,a,a,h,h,o.RGBA,null,e,i)},createTexture2D:function(t,e,i,n,s,r,o,a,h,l){var u=this.gl,c=u.createTexture();return l=void 0===l||null===l||l,this.setTexture2D(c,0),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,e),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,i),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,s),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,n),u.pixelStorei(u.UNPACK_PREMULTIPLY_ALPHA_WEBGL,l),null===o||void 0===o?u.texImage2D(u.TEXTURE_2D,t,r,a,h,0,r,u.UNSIGNED_BYTE,null):(u.texImage2D(u.TEXTURE_2D,t,r,r,u.UNSIGNED_BYTE,o),a=o.width,h=o.height),this.setTexture2D(null,0),c.isAlphaPremultiplied=l,c.isRenderTexture=!1,c.width=a,c.height=h,this.nativeTextures.push(c),c},createFramebuffer:function(t,e,i,n){var s,r=this.gl,o=r.createFramebuffer();if(this.setFramebuffer(o),n){var a=r.createRenderbuffer();r.bindRenderbuffer(r.RENDERBUFFER,a),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t,e),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,a)}if(i.isRenderTexture=!0,i.isAlphaPremultiplied=!1,r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,i,0),(s=r.checkFramebufferStatus(r.FRAMEBUFFER))!==r.FRAMEBUFFER_COMPLETE){throw new Error("Framebuffer incomplete. Framebuffer status: "+{36054:"Incomplete Attachment",36055:"Missing Attachment",36057:"Incomplete Dimensions",36061:"Framebuffer Unsupported"}[s])}return o.renderTexture=i,this.setFramebuffer(null),o},createProgram:function(t,e){var i=this.gl,n=i.createProgram(),s=i.createShader(i.VERTEX_SHADER),r=i.createShader(i.FRAGMENT_SHADER);if(i.shaderSource(s,t),i.shaderSource(r,e),i.compileShader(s),i.compileShader(r),!i.getShaderParameter(s,i.COMPILE_STATUS))throw new Error("Failed to compile Vertex Shader:\n"+i.getShaderInfoLog(s));if(!i.getShaderParameter(r,i.COMPILE_STATUS))throw new Error("Failed to compile Fragment Shader:\n"+i.getShaderInfoLog(r));if(i.attachShader(n,s),i.attachShader(n,r),i.linkProgram(n),!i.getProgramParameter(n,i.LINK_STATUS))throw new Error("Failed to link program:\n"+i.getProgramInfoLog(n));return n},createVertexBuffer:function(t,e){var i=this.gl,n=i.createBuffer();return this.setVertexBuffer(n),i.bufferData(i.ARRAY_BUFFER,t,e),this.setVertexBuffer(null),n},createIndexBuffer:function(t,e){var i=this.gl,n=i.createBuffer();return this.setIndexBuffer(n),i.bufferData(i.ELEMENT_ARRAY_BUFFER,t,e),this.setIndexBuffer(null),n},deleteTexture:function(t){return this.gl.deleteTexture(t),this},deleteFramebuffer:function(t){return this.gl.deleteFramebuffer(t),this},deleteProgram:function(t){return this.gl.deleteProgram(t),this},deleteBuffer:function(t){return this.gl.deleteBuffer(t),this},preRenderCamera:function(t){var e=this.config.resolution,i=Math.floor(t.x*e),n=Math.floor(t.y*e),s=Math.floor(t.width*e),r=Math.floor(t.height*e);if(this.pushScissor(i,n,s,r),t.backgroundColor.alphaGL>0){var a=t.backgroundColor,h=this.pipelines.FlatTintPipeline;h.batchFillRect(0,0,1,1,0,t.x,t.y,t.width,t.height,o.getTintFromFloats(a.redGL,a.greenGL,a.blueGL,1),a.alphaGL,1,0,0,1,0,0,[1,0,0,1,0,0]),h.flush()}},postRenderCamera:function(t){if(t._fadeAlpha>0||t._flashAlpha>0){var e=this.pipelines.FlatTintPipeline;e.batchFillRect(0,0,1,1,0,t.x,t.y,t.width,t.height,o.getTintFromFloats(t._fadeRed,t._fadeGreen,t._fadeBlue,1),t._fadeAlpha,1,0,0,1,0,0,[1,0,0,1,0,0]),e.batchFillRect(0,0,1,1,0,t.x,t.y,t.width,t.height,o.getTintFromFloats(t._flashRed,t._flashGreen,t._flashBlue,1),t._flashAlpha,1,0,0,1,0,0,[1,0,0,1,0,0]),e.flush()}this.popScissor()},preRender:function(){if(!this.contextLost){var t=this.gl,e=this.config.backgroundColor,i=this.pipelines;for(var n in t.clearColor(e.redGL,e.greenGL,e.blueGL,e.alphaGL),this.config.clearBeforeRender&&t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT|t.STENCIL_BUFFER_BIT),i)i[n].onPreRender()}},render:function(t,e,i,n){if(!this.contextLost){var r=e.list,o=r.length,a=this.pipelines;for(var h in a)a[h].onRender(t,n);this.preRenderCamera(n);for(var l=0;l0||n._flashAlpha>0)&&(s.globalCompositeOperation="source-over",s.fillStyle="rgb("+255*n._fadeRed+","+255*n._fadeGreen+","+255*n._fadeBlue+")",s.globalAlpha=n._fadeAlpha,s.fillRect(n.x,n.y,n.width,n.height),s.fillStyle="rgb("+255*n._flashRed+","+255*n._flashGreen+","+255*n._flashBlue+")",s.globalAlpha=n._flashAlpha,s.fillRect(n.x,n.y,n.width,n.height),s.globalAlpha=1),r&&s.restore()},postRender:function(){var t=this.gameContext;t.globalAlpha=1,t.globalCompositeOperation="source-over",this.currentAlpha=1,this.currentBlendMode=0,this.snapshotCallback&&(this.snapshotCallback(s(this.gameCanvas,this.snapshotType,this.snapshotEncoder)),this.snapshotCallback=null)},snapshot:function(t,e,i){this.snapshotCallback=t,this.snapshotType=e,this.snapshotEncoder=i},destroy:function(){this.gameCanvas=null,this.gameContext=null,this.game=null}});t.exports=c},function(t,e,i){var n=new(i(0))({initialize:function(t){this.parent=t,this.animationManager=t.scene.sys.anims,this.animationManager.once("remove",this.remove,this),this.isPlaying=!1,this.currentAnim=null,this.currentFrame=null,this._timeScale=1,this.frameRate=0,this.duration=0,this.msPerFrame=0,this.skipMissedFrames=!0,this._delay=0,this._repeat=0,this._repeatDelay=0,this._yoyo=!1,this.forward=!0,this.accumulator=0,this.nextTick=0,this.repeatCounter=0,this.pendingRepeat=!1,this._paused=!1,this._wasPlaying=!1,this._callbackArgs=[t,null],this._updateParams=[]},delay:function(t){return void 0===t?this._delay:(this._delay=t,this)},delayedPlay:function(t,e,i){return this.play(e,!0,i),this.nextTick+=1e3*t,this},getCurrentKey:function(){if(this.currentAnim)return this.currentAnim.key},load:function(t,e){return void 0===e&&(e=0),this.isPlaying&&this.stop(),this.animationManager.load(this,t,e),this},pause:function(t){return this._paused||(this._paused=!0,this._wasPlaying=this.isPlaying,this.isPlaying=!1),void 0!==t&&this.updateFrame(t),this},paused:function(t){return void 0!==t?t?this.pause():this.resume():this._paused},play:function(t,e,i){if(void 0===e&&(e=!1),void 0===i&&(i=0),e&&this.isPlaying&&this.currentAnim.key===t)return this;this.load(t,i);var n=this.currentAnim,s=this.parent;return this.repeatCounter=-1===this._repeat?Number.MAX_VALUE:this._repeat,n.getFirstTick(this),this.forward=!0,this.isPlaying=!0,this.pendingRepeat=!1,n.showOnStart&&(s.visible=!0),n.onStart&&n.onStart.apply(n.callbackScope,this._callbackArgs.concat(n.onStartParams)),s.setSizeToFrame(),s.updateDisplayOrigin(),this},progress:function(t){if(void 0===t){var e=this.currentFrame.progress;return this.forward||(e=1-e),e}return this},remove:function(t){if(void 0===t&&(t=this.currentAnim),this.isPlaying&&t.key===this.currentAnim.key){this.stop();var e=this.parent,i=this.currentAnim.frames[0];this.currentFrame=i,e.texture=i.frame.texture,e.frame=i.frame}},repeat:function(t){return void 0===t?this._repeat:(this._repeat=t,this.repeatCounter=0,this)},repeatDelay:function(t){return void 0===t?this._repeatDelay:(this._repeatDelay=t,this)},restart:function(t){return void 0===t&&(t=!1),this.currentAnim.getFirstTick(this,t),this.forward=!0,this.isPlaying=!0,this.pendingRepeat=!1,this._paused=!1,this.updateFrame(this.currentAnim.frames[0]),this},resume:function(t){return this._paused&&(this._paused=!1,this.isPlaying=this._wasPlaying),void 0!==t&&this.updateFrame(t),this},stop:function(t){void 0===t&&(t=!1),this.isPlaying=!1;var e=this.currentAnim;return t&&e.onComplete&&e.onComplete.apply(e.callbackScope,this._callbackArgs.concat(e.onCompleteParams)),this},timeScale:function(t){return void 0===t?this._timeScale:(this._timeScale=t,this)},totalFrames:function(){return this.currentAnim.frames.length},totalProgres:function(){},update:function(t,e){this.isPlaying&&!this.currentAnim.paused&&(this.accumulator+=e*this._timeScale,this.accumulator>=this.nextTick&&this.currentAnim.setFrame(this))},updateFrame:function(t){var e=this.parent;if(this.currentFrame=t,e.texture=t.frame.texture,e.frame=t.frame,this.isPlaying){t.setAlpha&&(e.alpha=t.alpha);var i=this.currentAnim;i.onUpdate&&i.onUpdate.apply(i.callbackScope,this._updateParams),t.onUpdate&&t.onUpdate(e,t)}},yoyo:function(t){return void 0===t?this._yoyo:(this._yoyo=t,this)},destroy:function(){}});t.exports=n},function(t,e){t.exports=function(t){return t.split("").reverse().join("")}},function(t,e){t.exports=function(t,e){return t.replace(/%([0-9]+)/g,function(t,i){return e[Number(i)-1]})}},function(t,e,i){t.exports={Format:i(383),Pad:i(158),Reverse:i(382),UppercaseFirst:i(285)}},function(t,e,i){var n=i(55);t.exports=function(t,e){var i=n(t);for(var s in e)i.hasOwnProperty(s)&&(i[s]=e[s]);return i}},function(t,e){t.exports=function(t,e){for(var i=0;i-1&&this._active.splice(s,1),n.destroy()}for(i=0;i=n.delay)){var s=n.elapsed-n.delay;n.elapsed=n.delay,!n.hasDispatched&&n.callback&&(n.hasDispatched=!0,n.callback.apply(n.callbackScope,n.args)),n.repeatCount>0?(n.repeatCount--,n.elapsed=s,n.hasDispatched=!1):this._pendingRemoval.push(n)}}}},shutdown:function(){var t;for(t=0;t0&&e.cameraFilter&s._id)){e.cull(s);var r=e.culledTiles,o=this.tileset,a=t.gameContext,h=r.length,l=o.image.getSourceImage(),u=e.x-s.scrollX*e.scrollFactorX,c=e.y-s.scrollY*e.scrollFactorY;a.save(),a.translate(u,c),a.rotate(e.rotation),a.scale(e.scaleX,e.scaleY),a.scale(e.flipX?-1:1,e.flipY?-1:1),a.globalAlpha=e.alpha;for(var d=0;d0&&e.cameraFilter&s._id||(e.upload(s),this.pipeline.drawStaticTilemapLayer(e,s))}},function(t,e,i){var n=i(3),s=i(3);n=i(410),s=i(409),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){e.cull(s);var r=e.culledTiles,o=r.length,a=e.tileset.image.getSourceImage(),h=this.tileset,l=e.x-s.scrollX*e.scrollFactorX,u=e.y-s.scrollY*e.scrollFactorY,c=t.gameContext;c.save(),c.translate(l,u),c.rotate(e.rotation),c.scale(e.scaleX,e.scaleY),c.scale(e.flipX?-1:1,e.flipY?-1:1);for(var d=0;d0&&e.cameraFilter&s._id||(e.cull(s),this.pipeline.batchDynamicTilemapLayer(e,s))}},function(t,e,i){var n=i(3),s=i(3);n=i(413),s=i(412),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(84);t.exports=function(t){for(var e=[],i=[],s=0;s-1?new s(a,f,c,u,o.tilesize,o.tilesize):e?null:new s(a,-1,c,u,o.tilesize,o.tilesize),h.push(d)}l.push(h),h=[]}a.data=l,i.push(a)}return i}},function(t,e,i){var n=i(18);t.exports=function(t){for(var e,i,s,r,o,a=0;a>>0;return n}},function(t,e,i){var n=i(423),s=i(2),r=i(66),o=i(191),a=i(45);t.exports=function(t,e){for(var i=[],h=0;h0){var y=new a(u,v.gid,c,f.length,t.tilewidth,t.tileheight);y.rotation=v.rotation,y.flipX=v.flipped,d.push(y)}else{var m=e?null:new a(u,-1,c,f.length,t.tilewidth,t.tileheight);d.push(m)}++c===l.width&&(f.push(d),c=0,d=[])}u.data=f,i.push(u)}}return i}},function(t,e,i){t.exports={Parse:i(194),Parse2DArray:i(116),ParseCSV:i(193),Impact:i(187),Tiled:i(192)}},function(t,e,i){var n=i(38),s=i(37),r=i(6);t.exports=function(t,e,i,o,a,h){return void 0===o&&(o=new r(0,0)),o.x=n(t,i,a,h),o.y=s(e,i,a,h),o}},function(t,e,i){var n=i(14);t.exports=function(t,e,i,s,r,o){if(void 0!==r){var a,h=n(t,e,i,s,null,o),l=0;for(a=0;a0&&n(a,t)}}e&&s(0,0,i.width,i.height,i)}},function(t,e,i){var n=i(46),s=i(26),r=i(70);t.exports=function(t,e,i,o){void 0===e&&(e=!0),void 0===i&&(i=!0);for(var a=0;ae)){for(var h=t;h<=e;h++)r(h,i,a);for(var l=0;l=t&&c.index<=e&&n(c,i)}o&&s(0,0,a.width,a.height,a)}}},function(t,e,i){var n=i(46),s=i(26),r=i(117);t.exports=function(t,e,i,o){void 0===e&&(e=!0),void 0===i&&(i=!0),Array.isArray(t)||(t=[t]);for(var a=0;a=0;r--)for(s=n.width-1;s>=0;s--)if((o=n.data[r][s])&&o.index===t){if(a===e)return o;a+=1}}else for(r=0;r-c&&y>-d&&v=0&&p=0&&gr?(s.warn("Plugin.register:",n.toString(e),"was upgraded to",n.toString(t)),n._registry[t.name]=t):i-1},n.isFor=function(t,e){var i=t.for&&n.dependencyParse(t.for);return!t.for||e.name===i.name&&n.versionSatisfies(e.version,i.range)},n.use=function(t,e){if(t.uses=(t.uses||[]).concat(e||[]),0!==t.uses.length){for(var i=n.dependencies(t),r=s.topologicalSort(i),o=[],a=0;a0&&!h.silent&&s.info(o.join(" "))}else s.warn("Plugin.use:",n.toString(t),"does not specify any dependencies to install.")},n.dependencies=function(t,e){var i=n.dependencyParse(t),r=i.name;if(!(r in(e=e||{}))){t=n.resolve(t)||t,e[r]=s.map(t.uses||[],function(e){n.isPlugin(e)&&n.register(e);var r=n.dependencyParse(e),o=n.resolve(e);return o&&!n.versionSatisfies(o.version,r.range)?(s.warn("Plugin.dependencies:",n.toString(o),"does not satisfy",n.toString(r),"used by",n.toString(i)+"."),o._warned=!0,t._warned=!0):o||(s.warn("Plugin.dependencies:",n.toString(e),"used by",n.toString(i),"could not be resolved."),t._warned=!0),r.name});for(var o=0;o=s[2];if("^"===i.operator)return s[0]>0?o[0]===s[0]&&r.number>=i.number:s[1]>0?o[1]===s[1]&&o[2]>=s[2]:o[2]===s[2]}return t===e||"*"===t}},function(t,e,i){var n=i(959);n.Body=i(49),n.Composite=i(120),n.World=i(462),n.Detector=i(466),n.Grid=i(958),n.Pairs=i(957),n.Pair=i(370),n.Query=i(983),n.Resolver=i(956),n.SAT=i(465),n.Constraint=i(170),n.Common=i(39),n.Engine=i(955),n.Events=i(171),n.Sleeping=i(198),n.Plugin=i(463),n.Bodies=i(92),n.Composites=i(962),n.Axes=i(468),n.Bounds=i(89),n.Svg=i(981),n.Vector=i(90),n.Vertices=i(91),n.World.add=n.Composite.add,n.World.remove=n.Composite.remove,n.World.addComposite=n.Composite.addComposite,n.World.addBody=n.Composite.addBody,n.World.addConstraint=n.Composite.addConstraint,n.World.clear=n.Composite.clear,t.exports=n},function(t,e,i){var n={};t.exports=n;var s=i(91),r=i(90);!function(){n.collides=function(e,n,o){var a,h,l,u,c=!1;if(o){var d=e.parent,f=n.parent,p=d.speed*d.speed+d.angularSpeed*d.angularSpeed+f.speed*f.speed+f.angularSpeed*f.angularSpeed;c=o&&o.collided&&p<.2,u=o}else u={collided:!1,bodyA:e,bodyB:n};if(o&&c){var g=u.axisBody,v=g===e?n:e,y=[g.axes[o.axisNumber]];if(l=t(g.vertices,v.vertices,y),u.reused=!0,l.overlap<=0)return u.collided=!1,u}else{if((a=t(e.vertices,n.vertices,e.axes)).overlap<=0)return u.collided=!1,u;if((h=t(n.vertices,e.vertices,n.axes)).overlap<=0)return u.collided=!1,u;a.overlaps?s=a:a=0?o.index-1:u.length-1],l.x=s.x-c.x,l.y=s.y-c.y,h=-r.dot(i,l),a=s,s=u[(o.index+1)%u.length],l.x=s.x-c.x,l.y=s.y-c.y,(n=-r.dot(i,l))1?1:0;d1?1:0;p0:0!=(t.mask&e.category)&&0!=(e.mask&t.category)}},function(t,e,i){var n=i(92),s=i(49),r=i(0),o=i(371),a=i(2),h=i(70),l=i(91),u=new r({Mixins:[o.Bounce,o.Collision,o.Friction,o.Gravity,o.Mass,o.Sensor,o.Sleep,o.Static],initialize:function(t,e,i){this.tile=e,this.world=t,e.physics.matterBody&&e.physics.matterBody.destroy(),e.physics.matterBody=this;var n=a(i,"body",null),s=a(i,"addToWorld",!0);if(n)this.setBody(n,s);else{var r=e.getCollisionGroup();a(r,"objects",[]).length>0?this.setFromTileCollision(i):this.setFromTileRectangle(i)}},setFromTileRectangle:function(t){void 0===t&&(t={}),h(t,"isStatic")||(t.isStatic=!0),h(t,"addToWorld")||(t.addToWorld=!0);var e=this.tile.getBounds(),i=e.x+e.width/2,s=e.y+e.height/2,r=n.rectangle(i,s,e.width,e.height,t);return this.setBody(r,t.addToWorld),this},setFromTileCollision:function(t){void 0===t&&(t={}),h(t,"isStatic")||(t.isStatic=!0),h(t,"addToWorld")||(t.addToWorld=!0);for(var e=this.tile.tilemapLayer.scaleX,i=this.tile.tilemapLayer.scaleY,r=this.tile.getLeft(),o=this.tile.getTop(),u=this.tile.getCollisionGroup(),c=a(u,"objects",[]),d=[],f=0;f1&&(t.parts=d,this.setBody(s.create(t),t.addToWorld)),this},setBody:function(t,e){return void 0===e&&(e=!0),this.body&&this.removeBody(),this.body=t,this.body.gameObject=this,e&&this.world.add(this.body),this},removeBody:function(){return this.body&&(this.world.remove(this.body),this.body.gameObject=void 0,this.body=void 0),this},destroy:function(){this.removeBody(),this.tile.physics.matterBody=void 0}});t.exports=u},function(t,e,i){var n={};t.exports=n;var s=i(90),r=i(39);n.fromVertices=function(t){for(var e={},i=0;i0?1:-1),l=Math.sqrt(o*o*t.mass/e.mass)*(o>0?1:-1),u=.5*(h+l);h-=u,l-=u,t.velocity.y=u+h*t.bounce.y,e.velocity.y=u+l*e.bounce.y}return!0}},function(t,e,i){var n=i(207);t.exports=function(t,e,i,s){var r=n(t,e,i,s);if(i||0===r||t.immovable&&e.immovable||t.customSeparateX||e.customSeparateX)return 0!==r||t.embedded&&e.embedded;var o=t.velocity.x,a=e.velocity.x;if(t.immovable||e.immovable)t.immovable?(e.x+=r,e.velocity.x=o-a*e.bounce.x,t.moves&&(e.y+=(t.y-t.prev.y)*t.friction.y)):(t.x-=r,t.velocity.x=a-o*t.bounce.x,e.moves&&(t.y+=(e.y-e.prev.y)*e.friction.y));else{r*=.5,t.x-=r,e.x+=r;var h=Math.sqrt(a*a*e.mass/t.mass)*(a>0?1:-1),l=Math.sqrt(o*o*t.mass/e.mass)*(o>0?1:-1),u=.5*(h+l);h-=u,l-=u,t.velocity.x=u+h*t.bounce.x,e.velocity.x=u+l*e.bounce.x}return!0}},function(t,e){t.exports=function(t,e){e<0?t.blocked.up=!0:e>0&&(t.blocked.down=!0),t.position.y-=e,0===t.bounce.y?t.velocity.y=0:t.velocity.y=-t.velocity.y*t.bounce.y}},function(t,e,i){var n=i(472);t.exports=function(t,e,i,s,r){var o=0;return t.deltaY()<0&&!t.blocked.up&&e.collideDown&&t.checkCollision.up?e.faceBottom&&t.y0&&!t.blocked.down&&e.collideUp&&t.checkCollision.down&&e.faceTop&&t.bottom>i&&(o=t.bottom-i)>r&&(o=0),0!==o&&(t.customSeparateY?t.overlapY=o:n(t,o)),o}},function(t,e){t.exports=function(t,e){e<0?t.blocked.left=!0:e>0&&(t.blocked.right=!0),t.position.x-=e,0===t.bounce.x?t.velocity.x=0:t.velocity.x=-t.velocity.x*t.bounce.x}},function(t,e,i){var n=i(474);t.exports=function(t,e,i,s,r){var o=0;return t.deltaX()<0&&!t.blocked.left&&e.collideRight&&t.checkCollision.left?e.faceRight&&t.x0&&!t.blocked.right&&e.collideLeft&&t.checkCollision.right&&e.faceLeft&&t.right>i&&(o=t.right-i)>r&&(o=0),0!==o&&(t.customSeparateX?t.overlapX=o:n(t,o)),o}},function(t,e,i){var n=i(475),s=i(473),r=i(202);t.exports=function(t,e,i,o,a,h){var l=o.left,u=o.top,c=o.right,d=o.bottom,f=i.faceLeft||i.faceRight,p=i.faceTop||i.faceBottom;if(!f&&!p)return!1;var g=0,v=0,y=0,m=1;if(e.deltaAbsX()>e.deltaAbsY()?y=-1:e.deltaAbsX()=0;o--){var a=e[o],h=l(s,r,a.x,a.y);h=0;o--){var a=e[o],h=l(s,r,a.x,a.y);h>i&&(n=a,i=h)}return n},moveTo:function(t,e,i,n,s){void 0===n&&(n=60),void 0===s&&(s=0);var r=Math.atan2(i-t.y,e-t.x);return s>0&&(n=l(t.x,t.y,e,i)/(s/1e3)),t.body.velocity.setToPolar(r,n),r},moveToObject:function(t,e,i,n){return this.moveTo(t,e.x,e.y,i,n)},velocityFromAngle:function(t,e,i){return void 0===e&&(e=60),i.setToPolar(u(t),e)},velocityFromRotation:function(t,e,i){return void 0===e&&(e=60),i.setToPolar(t,e)},shutdown:function(){this.world.shutdown()},destroy:function(){this.world.destroy()}});a.register("ArcadePhysics",c,"arcadePhysics"),t.exports=c},function(t,e,i){var n=i(47),s=i(18),r={ArcadePhysics:i(490),Body:i(209),Collider:i(208),Factory:i(215),Group:i(212),Image:i(214),Sprite:i(93),StaticBody:i(201),StaticGroup:i(211),World:i(210)};r=s(!1,r,n),t.exports=r},function(t,e){t.exports=function(t,e,i){return Math.abs(t-e)<=i}},function(t,e){t.exports=function(t,e,i,n){void 0===e&&(e=1),void 0===i&&(i=1),void 0===n&&(n=1),n*=Math.PI/t;for(var s=[],r=[],o=0;o1?void 0!==n?(s=(n-t)/(n-i))<0&&(s=0):s=1:s<0&&(s=0),s}},function(t,e){t.exports=function(t,e,i){return Math.max(t-e,i)}},function(t,e){t.exports=function(t,e,i){return Math.min(t+e,i)}},function(t,e){t.exports=function(t){return t===parseFloat(t)?!(t%2):void 0}},function(t,e){t.exports=function(t){return t==parseFloat(t)?!(t%2):void 0}},function(t,e){t.exports=function(t,e){return t/e/1e3}},function(t,e){t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var n=Math.pow(i,-e);return Math.floor(t*n)/n}},function(t,e){t.exports=function(t,e){return Math.abs(t-e)}},function(t,e){t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var n=Math.pow(i,-e);return Math.ceil(t*n)/n}},function(t,e){t.exports=function(t){for(var e=0,i=0;i0&&0==(t&t-1)}},function(t,e,i){t.exports={GetNext:i(248),IsSize:i(145),IsValue:i(510)}},function(t,e,i){var n=i(148);t.exports=function(t,e){var i=t.length-1,s=i*e,r=Math.floor(s);return e<0?n(t[0],t[1],s):e>1?n(t[i],t[i-1],i-s):n(t[r],t[r+1>i?i:r+1],s-r)}},function(t,e,i){var n=i(149);t.exports=function(t,e){var i=t.length-1,s=i*e,r=Math.floor(s);return t[0]===t[i]?(e<0&&(r=Math.floor(s=i*(1+e))),n(s-r,t[(r-1+i)%i],t[r],t[(r+1)%i],t[(r+2)%i])):e<0?t[0]-(n(-s,t[0],t[0],t[1],t[1])-t[0]):e>1?t[i]-(n(s-i,t[i],t[i],t[i-1],t[i-1])-t[i]):n(s-r,t[r?r-1:0],t[r],t[ie-i}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1e-4),Math.floor(t+e)}},function(t,e){t.exports=function(t,e,i){return void 0===i&&(i=1e-4),Math.abs(t-e)=n.PI2-i?t=e:(Math.abs(e-t)>Math.PI&&(et?t+=i:e0?this.processLoadQueue():0===this.inflight.size&&this.finishedLoading()},finishedLoading:function(){this.state!==s.LOADER_PROCESSING&&(this.progress=1,this.state=s.LOADER_PROCESSING,this.storage.clear(),0===this.queue.size?this.processComplete():this.queue.each(function(t){t.onProcess(this.processUpdate.bind(this))},this))},processUpdate:function(t){if(t.state===s.FILE_ERRORED)return this.failed.set(t),t.linkFile&&this.queue.delete(t.linkFile),this.removeFromQueue(t);t.linkFile?t.state===s.FILE_COMPLETE&&t.linkFile.state===s.FILE_COMPLETE&&(this.storage.set({type:t.linkType,fileA:t,fileB:t.linkFile}),this.queue.delete(t.linkFile),this.removeFromQueue(t)):(this.storage.set(t),this.removeFromQueue(t))},removeFromQueue:function(t){this.queue.delete(t),0===this.queue.size&&this.state===s.LOADER_PROCESSING&&this.processComplete()},processComplete:function(){this.list.clear(),this.inflight.clear(),this.queue.clear(),this.processCallback(),this.state=s.LOADER_COMPLETE,this.emit("complete",this,this.storage.size,this.failed.size)},processCallback:function(){if(0!==this.storage.size){var t,e,i,n=this.scene.sys.cache,s=this.scene.sys.textures,r=this.scene.sys.anims;for(var o in this._multilist){for(var a=[],h=[],u=this._multilist[o],c=0;c0},file:function(t){var e,i=t.key;switch(t.type){case"spritesheet":e=this.spritesheet(i,t.url,t.config,t.xhrSettings);break;case"atlas":e=this.atlas(i,t.textureURL,t.atlasURL,t.textureXhrSettings,t.atlasXhrSettings);break;case"bitmapFont":e=this.bitmapFont(i,t.textureURL,t.xmlURL,t.textureXhrSettings,t.xmlXhrSettings);break;case"multiatlas":e=this.multiatlas(i,t.textureURLs,t.atlasURLs,t.textureXhrSettings,t.atlasXhrSettings);break;case"audioSprite":e=this.audioSprite(i,t.urls,t.json,t.config,t.audioXhrSettings,t.jsonXhrSettings);break;default:e=this[t.type](i,t.url,t.xhrSettings)}return e},shutdown:function(){this.reset(),this.state=s.LOADER_SHUTDOWN},destroy:function(){this.reset(),this.state=s.LOADER_DESTROYED}});u.register("Loader",d,"load"),t.exports=d},function(t,e,i){var n=i(7),s=i(50),r=i(221),o=function(t,e,i,n,o,a){var h=new s(t,e,n,o),l=new r(t,i,n,a);return h.linkFile=l,l.linkFile=h,h.linkType="unityatlas",l.linkType="unityatlas",{texture:h,data:l}};n.register("unityAtlas",function(t,e,i,n,s){var r=new o(t,e,i,this.path,n,s);return this.addFile(r.texture),this.addFile(r.data),this}),t.exports=o},function(t,e,i){var n=i(7),s=i(51),r=i(24),o=function(t,e,i,n,r){var o=new s(t,e,i,r);return o.type="tilemapJSON",o.tilemapFormat=n,o};n.register("tilemapTiledJSON",function(t,e,i){if(Array.isArray(t))for(var n=0;n'),n.push(''),n.push(''),n.push(this.xhrLoader.responseText),n.push(""),n.push(""),n.push("");var o=[n.join("\n")],a=this;try{var h=new window.Blob(o,{type:"image/svg+xml;charset=utf-8"})}catch(e){return a.state=s.FILE_ERRORED,void t(a)}this.data=new Image,this.data.crossOrigin=this.crossOrigin,this.data.onload=function(){r.revokeObjectURL(a.data),a.onComplete(),t(a)},this.data.onerror=function(){r.revokeObjectURL(a.data),a.state=s.FILE_ERRORED,t(a)},r.createObjectURL(this.data,h,"image/svg+xml")}});o.register("html",function(t,e,i,n,s){if(Array.isArray(t))for(var r=0;r-1&&(s.splice(a,1),this.clear(o))}t.length=0,this._list=s.concat(e.splice(0))}},clear:function(t){var e=t.input;e.gameObject=void 0,e.target=void 0,e.hitArea=void 0,e.hitAreaCallback=void 0,e.callbackContext=void 0,t.input=null;var i=this._draggable.indexOf(t);return i>-1&&this._draggable.splice(i,1),(i=this._drag[0].indexOf(t))>-1&&this._drag[0].splice(i,1),(i=this._over[0].indexOf(t))>-1&&this._over[0].splice(i,1),t},disable:function(t){t.input.enabled=!1},enable:function(t,e,i,n){return void 0===n&&(n=!1),t.input?t.input.enabled=!0:this.setHitArea(t,e,i),t.input.dropZone=n,this},hitTestPointer:function(t){var e=this.cameras.getCameraBelowPointer(t);if(e){t.camera=e;for(var i=this.manager.hitTest(t.x,t.y,this._list,e),n=0;n0?t.dragState=1:t.dragState>0&&!t.primaryDown&&t.justUp&&(t.dragState=5),1===t.dragState){var h=[];for(i=0;i1&&(this.sortGameObjects(h),this.topOnly&&h.splice(1)),this._drag[t.id]=h,0===this.dragDistanceThreshold&&0===this.dragTimeThreshold?t.dragState=3:t.dragState=2}if(2===t.dragState&&(this.dragDistanceThreshold>0&&o(t.x,t.y,t.downX,t.downY)>=this.dragDistanceThreshold&&(t.dragState=3),this.dragTimeThreshold>0&&e>=t.downTime+this.dragTimeThreshold&&(t.dragState=3)),3===t.dragState){for(s=this._drag[t.id],i=0;i0?(n.emit("dragleave",t,r.target),this.emit("dragleave",t,n,r.target),r.target=l[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target)):(n.emit("dragleave",t,r.target),this.emit("dragleave",t,n,r.target),l[0]?(r.target=l[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target)):r.target=null)}else!r.target&&l[0]&&(r.target=l[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target));var c=t.x-n.input.dragX,d=t.y-n.input.dragY;n.emit("drag",t,c,d),this.emit("drag",t,n,c,d)}return s.length}if(5===t.dragState){for(s=this._drag[t.id],i=0;i0)for(this.sortGameObjects(s),this.emit("pointerout",t,s),e=0;e0)for(this.sortGameObjects(r),this.emit("pointerover",t,r),e=0;e-1&&this._draggable.splice(s,1)}return this},setHitArea:function(t,e,i){if(void 0===e)return this.setHitAreaFromTexture(t);Array.isArray(t)||(t=[t]);for(var n=0;nn?-1:0},sortHandlerIO:function(t,e){var i=this.displayList.getIndex(t.gameObject),n=this.displayList.getIndex(e.gameObject);return in?-1:0},sortInteractiveObjects:function(t){return t.length<2?t:(this.scene.sys.depthSort(),t.sort(this.sortHandlerIO.bind(this)))},stopPropagation:function(){return this.manager.globalTopOnly&&(this.manager.ignoreEvents=!0),this},update:function(t,e){var i=this.manager;if(!i.globalTopOnly||!i.ignoreEvents){var n=i.activePointer,s=n.dirty||0===this.pollRate;if(this.pollRate>-1&&(this._pollTimer-=e,this._pollTimer<0&&(s=!0,this._pollTimer=this.pollRate)),s){this._tempZones=[],this._temp=this.hitTestPointer(n),this.sortGameObjects(this._temp),this.sortGameObjects(this._tempZones),this.topOnly&&(this._temp.length&&this._temp.splice(1),this._tempZones.length&&this._tempZones.splice(1));var r=this.processDragEvents(n,t);n.wasTouch||(r+=this.processOverOutEvents(n)),n.justDown&&(r+=this.processDownEvents(n)),n.justUp&&(r+=this.processUpEvents(n)),n.justMoved&&(r+=this.processMoveEvents(n)),r>0&&i.globalTopOnly&&(i.ignoreEvents=!0)}}},shutdown:function(){this._temp.length=0,this._list.length=0,this._draggable.length=0,this._pendingRemoval.length=0,this._pendingInsertion.length=0;for(var t=0;t<10;t++)this._drag[t]=[],this._over[t]=[];this.removeAllListeners()},destroy:function(){this.shutdown(),this.scene=void 0,this.cameras=void 0,this.manager=void 0,this.events=void 0,this.keyboard=void 0,this.mouse=void 0,this.gamepad=void 0},activePointer:{get:function(){return this.manager.activePointer}},x:{get:function(){return this.manager.activePointer.x}},y:{get:function(){return this.manager.activePointer.y}}});c.register("InputPlugin",v,"input"),t.exports=v},function(t,e){t.exports={UP:12,DOWN:13,LEFT:14,RIGHT:15,MENU:16,A:0,B:1,X:2,Y:3,LB:4,RB:5,LT:6,RT:7,BACK:8,START:9,LS:10,RS:11,LEFT_STICK_H:0,LEFT_STICK_V:1,RIGHT_STICK_H:2,RIGHT_STICK_V:3}},function(t,e){t.exports={UP:12,DOWN:13,LEFT:14,RIGHT:15,SELECT:8,START:9,B:0,A:1,Y:2,X:3,LEFT_SHOULDER:4,RIGHT_SHOULDER:5}},function(t,e){t.exports={UP:12,DOWN:13,LEFT:14,RIGHT:15,SHARE:8,OPTIONS:9,PS:16,TOUCHBAR:17,X:0,CIRCLE:1,SQUARE:2,TRIANGLE:3,L1:4,R1:5,L2:6,R2:7,L3:10,R3:11,LEFT_STICK_H:0,LEFT_STICK_V:1,RIGHT_STICK_H:2,RIGHT_STICK_V:3}},function(t,e,i){t.exports={DUALSHOCK_4:i(563),SNES_USB:i(562),XBOX_360:i(561)}},function(t,e,i){t.exports={Axis:i(296),Button:i(295),Gamepad:i(297),GamepadManager:i(298),Configs:i(564)}},function(t,e,i){t.exports={Gamepad:i(565),InputManager:i(299),InputPlugin:i(560),InteractiveObject:i(227),Keyboard:i(559),Mouse:i(554),Pointer:i(290),Touch:i(553)}},function(t,e,i){var n=i(123);t.exports=function(t,e,i){return n(t,e.x,e.y,i)}},function(t,e,i){var n=i(123),s=i(228);t.exports=function(t,e){var i=s(t);return n(t,i.x,i.y,e)}},function(t,e,i){var n=i(77);t.exports=function(t){var e=t.getLineA(),i=t.getLineB(),s=t.getLineC();return n(e)+n(i)+n(s)}},function(t,e){t.exports=function(t,e){return t.x1===e.x1&&t.y1===e.y1&&t.x2===e.x2&&t.y2===e.y2&&t.x3===e.x3&&t.y3===e.y3}},function(t,e){t.exports=function(t,e){return e.setTo(t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)}},function(t,e,i){var n=i(54);t.exports=function(t,e){return n(t,e.x,e.y)}},function(t,e,i){var n=i(52);t.exports=function(t){return new n(t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)}},function(t,e,i){var n=i(79);t.exports=function(t,e){void 0===e&&(e=new n);var i,s,r=t.x1,o=t.y1,a=t.x2,h=t.y2,l=t.x3,u=t.y3,c=a-r,d=h-o,f=l-r,p=u-o,g=c*(r+a)+d*(o+h),v=f*(r+l)+p*(o+u),y=2*(c*(u-h)-d*(l-a));if(Math.abs(y)<1e-6){var m=Math.min(r,a,l),x=Math.min(o,h,u);i=.5*(Math.max(r,a,l)-m),s=.5*(Math.max(o,h,u)-x),e.x=m+i,e.y=x+s,e.radius=Math.sqrt(i*i+s*s)}else e.x=(p*g-d*v)/y,e.y=(c*v-f*g)/y,i=e.x-r,s=e.y-o,e.radius=Math.sqrt(i*i+s*s);return e}},function(t,e,i){var n=i(6);function s(t,e,i,n){return t*n-e*i}t.exports=function(t,e){void 0===e&&(e=new n);var i=t.x3,r=t.y3,o=t.x1-i,a=t.y1-r,h=t.x2-i,l=t.y2-r,u=2*s(o,a,h,l),c=s(a,o*o+a*a,l,h*h+l*l),d=s(o,o*o+a*a,h,h*h+l*l);return e.x=i-c/u,e.y=r+d/u,e}},function(t,e,i){var n=i(230),s=i(229);t.exports=function(t,e,i,r){void 0===r&&(r=n);var o=r(t),a=e-o.x,h=i-o.y;return s(t,a,h)}},function(t,e,i){var n=i(52);t.exports=function(t,e,i,s){return void 0===s&&(s=i),new n(t,e,t,e-s,t+i,e)}},function(t,e,i){var n=i(301),s=i(52);t.exports=function(t,e,i,r,o){void 0===e&&(e=null),void 0===i&&(i=1),void 0===r&&(r=1),void 0===o&&(o=[]);for(var a,h,l,u,c,d,f,p,g,v=n(t,e),y=0;y0?t.width/2:t.width/-2,h=r>0?t.height/2:t.height/-2;return Math.abs(a*r)e.x&&t.ye.y}},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e){t.exports=function(t,e,i){var n=Math.min(t.x,e),s=Math.max(t.right,e);t.x=n,t.width=s-n;var r=Math.min(t.y,i),o=Math.max(t.bottom,i);return t.y=r,t.height=o-r,t}},function(t,e){t.exports=function(t,e){var i=Math.min(t.x,e.x),n=Math.max(t.right,e.right);t.x=i,t.width=n-i;var s=Math.min(t.y,e.y),r=Math.max(t.bottom,e.bottom);return t.y=s,t.height=r-s,t}},function(t,e){t.exports=function(t,e){for(var i=t.x,n=t.right,s=t.y,r=t.bottom,o=0;on(e)?t.setSize(e.height*i,e.height):t.setSize(e.width,e.width/i),t.setPosition(e.centerX-t.width/2,e.centerY-t.height/2)}},function(t,e,i){var n=i(124);t.exports=function(t,e){var i=n(t);return it.width*t.height)&&e.x>t.x&&e.xt.x&&e.rightt.y&&e.yt.y&&e.bottomi&&(i=h.x),h.xr&&(r=h.y),h.ye.right||t.righte.bottom||t.bottom0||(c=s(e),(d=n(t,c,!0)).length>0)}},function(t,e,i){var n=i(54),s=i(95);t.exports=function(t,e){return!!(n(t,e.getPointA())||n(t,e.getPointB())||s(t.getLineA(),e)||s(t.getLineB(),e)||s(t.getLineC(),e))}},function(t,e,i){var n=i(242),s=i(54);t.exports=function(t,e){return!(t.left>e.right||t.righte.bottom||t.bottomt.right+r||it.bottom+r||st.right||e.rightt.bottom||e.bottom0}},function(t,e,i){var n=i(241);t.exports=function(t,e){if(!n(t,e))return!1;var i=Math.min(e.x1,e.x2),s=Math.max(e.x1,e.x2),r=Math.min(e.y1,e.y2),o=Math.max(e.y1,e.y2);return t.x>=i&&t.x<=s&&t.y>=r&&t.y<=o}},function(t,e){t.exports=function(t,e){var i=t.x1,n=t.y1,s=t.x2,r=t.y2,o=e.x,a=e.y,h=e.right,l=e.bottom,u=0;if(i>=o&&i<=h&&n>=a&&n<=l||s>=o&&s<=h&&r>=a&&r<=l)return!0;if(i=o){if((u=n+(r-n)*(o-i)/(s-i))>a&&u<=l)return!0}else if(i>h&&s<=h&&(u=n+(r-n)*(h-i)/(s-i))>=a&&u<=l)return!0;if(n=a){if((u=i+(s-i)*(a-n)/(r-n))>=o&&u<=h)return!0}else if(n>l&&r<=l&&(u=i+(s-i)*(l-n)/(r-n))>=o&&u<=h)return!0;return!1}},function(t,e,i){var n=i(10),s=i(243);t.exports=function(t,e,i){return void 0===i&&(i=new n),s(t,e)&&(i.x=Math.max(t.x,e.x),i.y=Math.max(t.y,e.y),i.width=Math.min(t.right,e.right)-i.x,i.height=Math.min(t.bottom,e.bottom)-i.y),i}},function(t,e){t.exports=function(t,e){var i=e.width/2,n=e.height/2,s=Math.abs(t.x-e.x-i),r=Math.abs(t.y-e.y-n),o=i+t.radius,a=n+t.radius;if(s>o||r>a)return!1;if(s<=i||r<=n)return!0;var h=s-i,l=r-n;return h*h+l*l<=t.radius*t.radius}},function(t,e,i){var n=i(48);t.exports=function(t,e){return n(t.x,t.y,e.x,e.y)<=t.radius+e.radius}},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e,i){var n=i(10);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.left,e.y=t.top,e.width=t.diameter,e.height=t.diameter,e}},function(t,e){t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.radius===e.radius}},function(t,e){t.exports=function(t,e){return e.setTo(t.x,t.y,t.radius)}},function(t,e,i){var n=i(28);t.exports=function(t,e){return n(t,e.x,e.y)&&n(t,e.right,e.y)&&n(t,e.x,e.bottom)&&n(t,e.right,e.bottom)}},function(t,e,i){var n=i(28);t.exports=function(t,e){return n(t,e.x,e.y)}},function(t,e,i){var n=i(79);t.exports=function(t){return new n(t.x,t.y,t.radius)}},function(t,e){t.exports=function(t){return t.radius>0?Math.PI*t.radius*t.radius:0}},function(t,e,i){var n=i(79);n.Area=i(661),n.Circumference=i(353),n.CircumferencePoint=i(168),n.Clone=i(660),n.Contains=i(28),n.ContainsPoint=i(659),n.ContainsRect=i(658),n.CopyFrom=i(657),n.Equals=i(656),n.GetBounds=i(655),n.GetPoint=i(355),n.GetPoints=i(354),n.Offset=i(654),n.OffsetPoint=i(653),n.Random=i(167),t.exports=n},function(t,e,i){var n=i(0),s=i(246),r=i(12),o=new n({Extends:s,initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),s.call(this)},boot:function(){var t=this.systems.events;t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},destroy:function(){this.shutdown(),this.scene=void 0,this.systems=void 0}});r.register("LightsPlugin",o,"lights"),t.exports=o},function(t,e,i){var n=i(22),s=i(11),r=i(8),o=i(128);s.register("quad",function(t){var e=r(t,"x",0),i=r(t,"y",0),s=r(t,"key",null),a=r(t,"frame",null),h=new o(this.scene,e,i,s,a);return n(this.scene,h,t),h})},function(t,e,i){var n=i(22),s=i(11),r=i(8),o=i(5),a=i(96);s.register("mesh",function(t){var e=r(t,"key",null),i=r(t,"frame",null),s=o(t,"vertices",[]),h=o(t,"colors",[]),l=o(t,"alphas",[]),u=o(t,"uv",[]),c=new a(this.scene,0,0,s,u,h,l,e,i);return n(this.scene,c,t),c})},function(t,e,i){var n=i(128);i(9).register("quad",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(96);i(9).register("mesh",function(t,e,i,s,r,o,a,h){return this.displayList.add(new n(this.scene,t,e,i,s,r,o,a,h))})},function(t,e){t.exports=function(){}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchMesh(e,s)}},function(t,e,i){var n=i(3),s=i(3);n=i(669),s=i(668),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(11),s=i(8),r=i(106);n.register("zone",function(t){var e=s(t,"x",0),i=s(t,"y",0),n=s(t,"width",1),o=s(t,"height",n);return new r(this.scene,e,i,n,o)})},function(t,e,i){var n=i(22),s=i(11),r=i(8),o=i(129);s.register("tileSprite",function(t){var e=r(t,"x",0),i=r(t,"y",0),s=r(t,"width",512),a=r(t,"height",512),h=r(t,"key",""),l=r(t,"frame",""),u=new o(this.scene,e,i,s,a,h,l);return n(this.scene,u,t),u})},function(t,e,i){var n=i(22),s=i(11),r=i(8),o=i(130);s.register("text",function(t){var e=r(t,"text",""),i=r(t,"style",null),s=r(t,"padding",null);null!==s&&(i.padding=s);var a=new o(this.scene,0,0,e,i);return n(this.scene,a,t),a.autoRound=r(t,"autoRound",!0),a.resolution=r(t,"resolution",1),a})},function(t,e,i){var n=i(139),s=i(22),r=i(11),o=i(8),a=i(5);r.register("bitmapText",function(t){var e=a(t,"font",""),i=o(t,"text",""),r=o(t,"size",!1),h=new n(this.scene,0,0,e,i,r);return s(this.scene,h,t),h})},function(t,e,i){var n=i(22),s=i(140),r=i(11),o=i(8),a=i(40);r.register("sprite",function(t){var e=o(t,"key",null),i=o(t,"frame",null),r=new a(this.scene,0,0,e,i);return n(this.scene,r,t),s(r,t),r})},function(t,e,i){var n=i(22),s=i(140),r=i(11),o=i(8),a=i(101);r.register("sprite3D",function(t){var e=o(t,"key",null),i=o(t,"frame",null),r=new a(this.scene,0,0,e,i);return n(this.scene,r,t),s(r,t),r})},function(t,e,i){var n=i(22),s=i(11),r=i(8),o=i(131);s.register("renderTexture",function(t){var e=r(t,"x",0),i=r(t,"y",0),s=r(t,"width",32),a=r(t,"height",32),h=new o(this.scene,e,i,s,a);return n(this.scene,h,t),h})},function(t,e,i){var n=i(11),s=i(8),r=i(2),o=i(133);n.register("particles",function(t){var e=s(t,"key",null),i=s(t,"frame",null),n=r(t,"emitters",null),a=new o(this.scene,e,i,n);return r(t,"add",!1)&&this.displayList.add(a),this.updateList.add(a),a})},function(t,e,i){var n=i(22),s=i(11),r=i(8),o=i(72);s.register("image",function(t){var e=r(t,"key",null),i=r(t,"frame",null),s=new o(this.scene,0,0,e,i);return n(this.scene,s,t),s})},function(t,e,i){var n=i(11),s=i(73);n.register("group",function(t){return new s(this.scene,null,t)})},function(t,e,i){var n=i(11),s=i(136);n.register("graphics",function(t){return new s(this.scene,t)})},function(t,e,i){var n=i(137),s=i(22),r=i(11),o=i(8);r.register("dynamicBitmapText",function(t){var e=o(t,"font",""),i=o(t,"text",""),r=o(t,"size",!1),a=o(t,"align","left"),h=new n(this.scene,0,0,e,i,r,a);return s(this.scene,h,t),h})},function(t,e,i){var n=i(138),s=i(22),r=i(11),o=i(8);r.register("blitter",function(t){var e=o(t,"key",null),i=o(t,"frame",null),r=new n(this.scene,0,0,e,i);return s(this.scene,r,t),r})},function(t,e,i){var n=i(106);i(9).register("zone",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(129);i(9).register("tileSprite",function(t,e,i,s,r,o){return this.displayList.add(new n(this.scene,t,e,i,s,r,o))})},function(t,e,i){var n=i(130);i(9).register("text",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(139);i(9).register("bitmapText",function(t,e,i,s,r){return this.displayList.add(new n(this.scene,t,e,i,s,r))})},function(t,e,i){var n=i(9),s=i(40);n.register("sprite",function(t,e,i,n){var r=new s(this.scene,t,e,i,n);return this.displayList.add(r),this.updateList.add(r),r})},function(t,e,i){var n=i(101);i(9).register("sprite3D",function(t,e,i,s,r){var o=new n(this.scene,t,e,i,s,r);return this.displayList.add(o.gameObject),this.updateList.add(o.gameObject),o})},function(t,e,i){var n=i(9),s=i(131);n.register("renderTexture",function(t,e,i,n){return this.displayList.add(new s(this.scene,t,e,i,n))})},function(t,e,i){var n=i(9),s=i(249);n.register("follower",function(t,e,i,n,r){var o=new s(this.scene,t,e,i,n,r);return this.displayList.add(o),this.updateList.add(o),o})},function(t,e,i){var n=i(9),s=i(133);n.register("particles",function(t,e,i){var n=new s(this.scene,t,e,i);return this.displayList.add(n),this.updateList.add(n),n})},function(t,e,i){var n=i(72);i(9).register("image",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(73);i(9).register("group",function(t,e){return"object"==typeof t&&void 0===e&&(e=t,t=[]),this.updateList.add(new n(this.scene,t,e))})},function(t,e,i){var n=i(136);i(9).register("graphics",function(t){return this.displayList.add(new n(this.scene,t))})},function(t,e,i){var n=i(137);i(9).register("dynamicBitmapText",function(t,e,i,s,r){return this.displayList.add(new n(this.scene,t,e,i,s,r))})},function(t,e,i){var n=i(138);i(9).register("blitter",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){var r=t.currentContext,o=e.frame;e.updateTileTexture(),t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,r.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,r.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var a=o.x-e.originX*e.width,h=o.y-e.originY*e.height,l=e.x-s.scrollX*e.scrollFactorX,u=e.y-s.scrollY*e.scrollFactorY,c=1,d=1;e.flipX&&(c=-1,a+=e.width),e.flipY&&(d=-1,h+=e.height),t.config.roundPixels&&(a|=0,h|=0,l|=0,u|=0),r.save(),r.translate(a,h),r.translate(l,u),r.scale(c,d),r.translate(e.originX*e.width,e.originY*e.height),r.rotate(c*d*e.rotation),r.scale(this.scaleX,this.scaleY),r.translate(-e.originX*e.width,-e.originY*e.height),r.translate(-this.tilePositionX,-this.tilePositionY),r.fillStyle=e.canvasPattern,r.fillRect(this.tilePositionX,this.tilePositionY,e.width,e.height),r.restore()}}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||(e.updateTileTexture(),this.pipeline.batchTileSprite(this,s))}},function(t,e,i){var n=i(3),s=i(3);n=i(699),s=i(698),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(23);t.exports=function(t){var e=n.create(this),i=e.getContext("2d");t.syncFont(e,i);var s=Math.ceil(i.measureText(t.testString).width*t.baselineX),r=s,o=2*r;r=r*t.baselineY|0,e.width=s,e.height=o,i.fillStyle="#f00",i.fillRect(0,0,s,o),i.font=t._font,i.textBaseline="alphabetic",i.fillStyle="#000",i.fillText(t.testString,0,r);var a={ascent:0,descent:0,fontSize:0};if(!i.getImageData(0,0,s,o))return a.ascent=r,a.descent=r+6,a.fontSize=a.ascent+a.descent,n.remove(e),a;var h,l,u=i.getImageData(0,0,s,o).data,c=u.length,d=4*s,f=0,p=!1;for(h=0;hr;h--){for(l=0;l0&&e.cameraFilter&s._id||""===e.text)){var r=t.currentContext;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,r.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,r.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var o=e.canvas;r.save();var a=e.x-s.scrollX*e.scrollFactorX,h=e.y-s.scrollY*e.scrollFactorY;t.config.roundPixels&&(a|=0,h|=0),r.translate(a,h),r.rotate(e.rotation),r.scale(e.scaleX,e.scaleY),r.translate(o.width*(e.flipX?1:0),o.height*(e.flipY?1:0)),r.scale(e.flipX?-1:1,e.flipY?-1:1),r.drawImage(o,0,0,o.width,o.height,-e.displayOriginX,-e.displayOriginY,o.width,o.height),r.restore()}}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||""===e.text||(e.dirty&&(e.canvasTexture=t.canvasToTexture(e.canvas,e.canvasTexture,!0,e.scaleMode),e.dirty=!1),this.pipeline.batchText(this,s))}},function(t,e,i){var n=i(3),s=i(3);n=i(704),s=i(703),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e){t.exports=function(t,e,i){var n=t.canvas,s=t.context,r=t.style,o=[],a=0,h=i.length;r.maxLines>0&&r.maxLinesc&&(f=-c),0!==f&&(d+=f>0?f*i.length:f*(i.length-1)),{width:a,height:d,lines:h,lineWidths:o,lineSpacing:f,lineHeight:c}}},function(t,e){t.exports={fill:function(t){var e=255&(t>>16|0),i=255&(t>>8|0),n=255&(0|t);this.renderer.setFramebuffer(this.framebuffer);var s=this.gl;return s.clearColor(e/255,i/255,n/255,1),s.clear(s.COLOR_BUFFER_BIT),this.renderer.setFramebuffer(null),this},clear:function(){this.renderer.setFramebuffer(this.framebuffer);var t=this.gl;return t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),this.renderer.setFramebuffer(null),this},draw:function(t,e,i,n){var s=t.source[e.sourceIndex].glTexture,r=(this.globalTint>>16)+(65280&this.globalTint)+((255&this.globalTint)<<16);return this.renderer.setFramebuffer(this.framebuffer),this.renderer.pipelines.TextureTintPipeline.drawTexture(s,i,n,r,this.globalAlpha,e.cutX,e.cutY,e.cutWidth,e.cutHeight,this.currentMatrix),this.renderer.setFramebuffer(null),this}}},function(t,e){t.exports={fill:function(t){var e=255&(t>>16|0),i=255&(t>>8|0),n=255&(0|t);return this.context.fillStyle="rgb("+e+","+i+","+n+")",this.context.fillRect(0,0,this.canvas.width,this.canvas.height),this},clear:function(){return this.context.save(),this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.restore(),this},draw:function(t,e,i,n){var s=this.currentMatrix;return this.context.globalAlpha=this.globalAlpha,this.context.setTransform(s[0],s[1],s[2],s[3],s[4],s[5]),this.context.drawImage(t.source[e.sourceIndex].image,e.cutX,e.cutY,e.cutWidth,e.cutHeight,i,n,e.cutWidth,e.cutWidth),this}}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){var r=t.currentContext;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,r.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,r.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var o=0,a=0,h=1,l=1;e.flipX?(h=-1,o-=e.canvas.width-e.displayOriginX):o-=e.displayOriginX,e.flipY?(l=-1,a-=e.canvas.height-e.displayOriginY):a-=e.displayOriginY,r.save(),r.translate(e.x-s.scrollX*e.scrollFactorX,e.y-s.scrollY*e.scrollFactorY),r.rotate(e.rotation),r.scale(e.scaleX,e.scaleY),r.scale(h,l),r.drawImage(e.canvas,o,a),r.restore()}}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchTexture(e,e.texture,e.texture.width,e.texture.height,e.x,e.y,e.width,e.height,e.scaleX,e.scaleY,e.rotation,e.flipX,e.flipY,e.scrollFactorX,e.scrollFactorY,e.displayOriginX,e.displayOriginY,0,0,e.texture.width,e.texture.height,4294967295,4294967295,4294967295,4294967295,0,0,s)}},function(t,e,i){var n=i(3),s=i(3);n=i(710),s=i(709),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){var r=e.emitters.list;if(!(0===r.length||n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id))for(var o=0;o>24&255)/255;if(!(y<=0)){var m=v.frame,x=.5*m.width,b=.5*m.height,w=m.canvasData,T=-x,S=-b,A=v.x-d*v.scrollFactorX,C=v.y-f*v.scrollFactorY;p&&(A|=0,C|=0),u.globalAlpha=y,u.save(),u.translate(A,C),u.rotate(v.rotation),u.scale(v.scaleX,v.scaleY),u.drawImage(m.source.image,w.sx,w.sy,w.sWidth,w.sHeight,T,S,w.dWidth,w.dHeight),u.restore()}}u.globalAlpha=c}}}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){0===e.emitters.length||n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.drawEmitterManager(e,s)}},function(t,e,i){var n=i(3),s=i(3);n=i(713),s=i(712),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(0),s=i(6),r=new n({initialize:function(t){this.source=t,this._tempVec=new s},getPoint:function(t){var e=this._tempVec;this.source.getRandomPoint(e),t.x=e.x,t.y=e.y}});t.exports=r},function(t,e,i){var n=i(0),s=i(42),r=i(48),o=new n({initialize:function(t){this.emitter=t,this.frame=null,this.index=0,this.x=0,this.y=0,this.velocityX=0,this.velocityY=0,this.accelerationX=0,this.accelerationY=0,this.maxVelocityX=1e4,this.maxVelocityY=1e4,this.bounce=0,this.scaleX=1,this.scaleY=1,this.alpha=1,this.angle=0,this.rotation=0,this.scrollFactorX=1,this.scrollFactorY=1,this.tint=4294967295,this.color=4294967295,this.life=1e3,this.lifeCurrent=1e3,this.delayCurrent=0,this.lifeT=0,this.data={tint:{min:16777215,max:16777215,current:16777215},alpha:{min:1,max:1},rotate:{min:0,max:0},scaleX:{min:1,max:1},scaleY:{min:1,max:1}}},isAlive:function(){return this.lifeCurrent>0},fire:function(t,e){var i=this.emitter;this.frame=i.getFrame(),i.emitZone&&i.emitZone.getPoint(this),void 0===t?(i.follow&&(this.x+=i.follow.x+i.followOffset.x),this.x+=i.x.onEmit(this,"x")):this.x+=t,void 0===e?(i.follow&&(this.y+=i.follow.y+i.followOffset.y),this.y+=i.y.onEmit(this,"y")):this.y+=e,this.life=i.lifespan.onEmit(this,"lifespan"),this.lifeCurrent=this.life,this.lifeT=0;var n=i.speedX.onEmit(this,"speedX"),o=i.speedY?i.speedY.onEmit(this,"speedY"):n;if(i.radial){var a=s(i.angle.onEmit(this,"angle"));this.velocityX=Math.cos(a)*Math.abs(n),this.velocityY=Math.sin(a)*Math.abs(o)}else if(i.moveTo){var h=i.moveToX.onEmit(this,"moveToX"),l=i.moveToY?i.moveToY.onEmit(this,"moveToY"):h,u=Math.atan2(l-this.y,h-this.x),c=r(this.x,this.y,h,l)/(this.life/1e3);this.velocityX=Math.cos(u)*c,this.velocityY=Math.sin(u)*c}else this.velocityX=n,this.velocityY=o;i.acceleration&&(this.accelerationX=i.accelerationX.onEmit(this,"accelerationX"),this.accelerationY=i.accelerationY.onEmit(this,"accelerationY")),this.maxVelocityX=i.maxVelocityX.onEmit(this,"maxVelocityX"),this.maxVelocityY=i.maxVelocityY.onEmit(this,"maxVelocityY"),this.delayCurrent=i.delay.onEmit(this,"delay"),this.scaleX=i.scaleX.onEmit(this,"scaleX"),this.scaleY=i.scaleY?i.scaleY.onEmit(this,"scaleY"):this.scaleX,this.angle=i.rotate.onEmit(this,"rotate"),this.rotation=s(this.angle),this.bounce=i.bounce.onEmit(this,"bounce"),this.alpha=i.alpha.onEmit(this,"alpha"),this.tint=i.tint.onEmit(this,"tint"),this.color=16777215&this.tint|(255*this.alpha|0)<<24,this.index=i.alive.length},computeVelocity:function(t,e,i,n){var s=this.velocityX,r=this.velocityY,o=this.accelerationX,a=this.accelerationY,h=this.maxVelocityX,l=this.maxVelocityY;s+=t.gravityX*i,r+=t.gravityY*i,o&&(s+=o*i),a&&(r+=a*i),s>h?s=h:s<-h&&(s=-h),r>l?r=l:r<-l&&(r=-l),this.velocityX=s,this.velocityY=r;for(var u=0;ue.right&&t.collideRight&&(this.x=e.right,this.velocityX*=i),this.ye.bottom&&t.collideBottom&&(this.y=e.bottom,this.velocityY*=i)},update:function(t,e,i){if(this.delayCurrent>0)return this.delayCurrent-=t,!1;var n=this.emitter,r=1-this.lifeCurrent/this.life;return this.lifeT=r,this.computeVelocity(n,t,e,i),this.x+=this.velocityX*e,this.y+=this.velocityY*e,n.bounds&&this.checkBounds(n),n.deathZone&&n.deathZone.willKill(this)?(this.lifeCurrent=0,!0):(this.scaleX=n.scaleX.onUpdate(this,"scaleX",r,this.scaleX),n.scaleY?this.scaleY=n.scaleY.onUpdate(this,"scaleY",r,this.scaleY):this.scaleY=this.scaleX,this.angle=n.rotate.onUpdate(this,"rotate",r,this.angle),this.rotation=s(this.angle),this.alpha=n.alpha.onUpdate(this,"alpha",r,this.alpha),this.tint=n.tint.onUpdate(this,"tint",r,this.tint),this.color=16777215&this.tint|(255*this.alpha|0)<<24,this.lifeCurrent-=t,this.lifeCurrent<=0)}});t.exports=o},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1),t<=0?0:t>=1?1:1/e*(1+(e*t|0))}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:.5*(1-Math.cos(Math.PI*t))}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:Math.sin(t*Math.PI/2)}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:1-Math.cos(t*Math.PI/2)}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},function(t,e){t.exports=function(t){return--t*t*t*t*t+1}},function(t,e){t.exports=function(t){return t*t*t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},function(t,e){t.exports=function(t){return 1- --t*t*t*t}},function(t,e){t.exports=function(t){return t*t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},function(t,e){t.exports=function(t){return t*(2-t)}},function(t,e){t.exports=function(t){return t*t}},function(t,e){t.exports=function(t){return t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*(t-1)))}},function(t,e){t.exports=function(t){return 1-Math.pow(2,-10*t)}},function(t,e){t.exports=function(t){return Math.pow(2,10*(t-1))-.001}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),(t*=2)<1?e*Math.pow(2,10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)*-.5:e*Math.pow(2,-10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)*.5+1}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),e*Math.pow(2,-10*t)*Math.sin((t-n)*(2*Math.PI)/i)+1}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),-e*Math.pow(2,10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},function(t,e){t.exports=function(t){return--t*t*t+1}},function(t,e){t.exports=function(t){return t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},function(t,e){t.exports=function(t){return Math.sqrt(1- --t*t)}},function(t,e){t.exports=function(t){return 1-Math.sqrt(1-t*t)}},function(t,e){t.exports=function(t){var e=!1;return t<.5?(t=1-2*t,e=!0):t=2*t-1,t<1/2.75?t*=7.5625*t:t=t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375,e?.5*(1-t):.5*t+.5}},function(t,e){t.exports=function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},function(t,e){t.exports=function(t){return(t=1-t)<1/2.75?1-7.5625*t*t:t<2/2.75?1-(7.5625*(t-=1.5/2.75)*t+.75):t<2.5/2.75?1-(7.5625*(t-=2.25/2.75)*t+.9375):1-(7.5625*(t-=2.625/2.75)*t+.984375)}},function(t,e){t.exports=function(t,e){void 0===e&&(e=1.70158);var i=1.525*e;return(t*=2)<1?t*t*((i+1)*t-i)*.5:.5*((t-=2)*t*((i+1)*t+i)+2)}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1.70158),--t*t*((e+1)*t+e)+1}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1.70158),t*t*((e+1)*t-e)}},function(t,e,i){var n=i(262),s=i(261),r=i(260),o=i(259),a=i(258),h=i(257),l=i(256),u=i(255),c=i(254),d=i(253),f=i(252),p=i(251);t.exports={Power0:l,Power1:u.Out,Power2:o.Out,Power3:c.Out,Power4:d.Out,Linear:l,Quad:u.Out,Cubic:o.Out,Quart:c.Out,Quint:d.Out,Sine:f.Out,Expo:h.Out,Circ:r.Out,Elastic:a.Out,Back:n.Out,Bounce:s.Out,Stepped:p,"Quad.easeIn":u.In,"Cubic.easeIn":o.In,"Quart.easeIn":c.In,"Quint.easeIn":d.In,"Sine.easeIn":f.In,"Expo.easeIn":h.In,"Circ.easeIn":r.In,"Elastic.easeIn":a.In,"Back.easeIn":n.In,"Bounce.easeIn":s.In,"Quad.easeOut":u.Out,"Cubic.easeOut":o.Out,"Quart.easeOut":c.Out,"Quint.easeOut":d.Out,"Sine.easeOut":f.Out,"Expo.easeOut":h.Out,"Circ.easeOut":r.Out,"Elastic.easeOut":a.Out,"Back.easeOut":n.Out,"Bounce.easeOut":s.Out,"Quad.easeInOut":u.InOut,"Cubic.easeInOut":o.InOut,"Quart.easeInOut":c.InOut,"Quint.easeInOut":d.InOut,"Sine.easeInOut":f.InOut,"Expo.easeInOut":h.InOut,"Circ.easeInOut":r.InOut,"Elastic.easeInOut":a.InOut,"Back.easeInOut":n.InOut,"Bounce.easeInOut":s.InOut}},function(t,e,i){var n=i(0),s=i(263),r=i(71),o=i(2),a=i(43),h=new n({initialize:function(t,e,i,n){void 0===n&&(n=!1),this.propertyKey=e,this.propertyValue=i,this.defaultValue=i,this.steps=0,this.counter=0,this.start=0,this.end=0,this.ease,this.emitOnly=n,this.onEmit=this.defaultEmit,this.onUpdate=this.defaultUpdate,this.loadConfig(t)},loadConfig:function(t,e){void 0===t&&(t={}),e&&(this.propertyKey=e),this.propertyValue=o(t,this.propertyKey,this.defaultValue),this.setMethods(),this.emitOnly&&(this.onUpdate=this.defaultUpdate)},toJSON:function(){return JSON.stringify(this.propertyValue)},onChange:function(t){return this.propertyValue=t,this.setMethods()},setMethods:function(){var t=this.propertyValue,e=typeof t;if("number"===e)this.onEmit=this.staticValueEmit,this.onUpdate=this.staticValueUpdate;else if(Array.isArray(t))this.onEmit=this.randomStaticValueEmit;else if("function"===e)this.emitOnly?this.onEmit=t:this.onUpdate=t;else if("object"===e&&(this.has(t,"random")||this.hasBoth(t,"start","end")||this.hasBoth(t,"min","max"))){this.start=this.has(t,"start")?t.start:t.min,this.end=this.has(t,"end")?t.end:t.max;var i=this.hasBoth(t,"min","max")||this.has(t,"random");if(i){var n=t.random;Array.isArray(n)&&(this.start=n[0],this.end=n[1]),this.onEmit=this.randomRangedValueEmit}if(this.has(t,"steps"))this.steps=t.steps,this.counter=this.start,this.onEmit=this.steppedEmit;else{var s=this.has(t,"ease")?t.ease:"Linear";this.ease=r(s),i||(this.onEmit=this.easedValueEmit),this.onUpdate=this.easeValueUpdate}}else"object"===e&&this.hasEither(t,"onEmit","onUpdate")&&(this.has(t,"onEmit")&&(this.onEmit=t.onEmit),this.has(t,"onUpdate")&&(this.onUpdate=t.onUpdate));return this},has:function(t,e){return t.hasOwnProperty(e)},hasBoth:function(t,e,i){return t.hasOwnProperty(e)&&t.hasOwnProperty(i)},hasEither:function(t,e,i){return t.hasOwnProperty(e)||t.hasOwnProperty(i)},defaultEmit:function(t,e,i){return i},defaultUpdate:function(t,e,i,n){return n},staticValueEmit:function(){return this.propertyValue},staticValueUpdate:function(){return this.propertyValue},randomStaticValueEmit:function(){var t=Math.floor(Math.random()*this.propertyValue.length);return this.propertyValue[t]},randomRangedValueEmit:function(t,e){var i=s(this.start,this.end);return t&&t.data[e]&&(t.data[e].min=i),i},steppedEmit:function(){var t=this.counter,e=this.counter+(this.end-this.start)/this.steps;return this.counter=a(e,this.start,this.end),t},easedValueEmit:function(t,e){if(t&&t.data[e]){var i=t.data[e];i.min=this.start,i.max=this.end}return this.start},easeValueUpdate:function(t,e,i){var n=t.data[e];return(n.max-n.min)*this.ease(i)+n.min}});t.exports=h},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s){void 0===n&&(n=!1),void 0===s&&(s=!0),this.source=t,this.points=[],this.quantity=e,this.stepRate=i,this.yoyo=n,this.counter=-1,this.seamless=s,this._length=0,this._direction=0,this.updateSource()},updateSource:function(){if(this.points=this.source.getPoints(this.quantity,this.stepRate),this.seamless){var t=this.points[0],e=this.points[this.points.length-1];t.x===e.x&&t.y===e.y&&this.points.pop()}var i=this._length;return this._length=this.points.length,this._lengththis._length&&(this.counter=this._length-1),this},changeSource:function(t){return this.source=t,this.updateSource()},getPoint:function(t){0===this._direction?(this.counter++,this.counter>=this._length&&(this.yoyo?(this._direction=1,this.counter=this._length-1):this.counter=0)):(this.counter--,-1===this.counter&&(this.yoyo?(this._direction=0,this.counter=0):this.counter=this._length-1));var e=this.points[this.counter];e&&(t.x=e.x,t.y=e.y)}});t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.source=t,this.killOnEnter=e},willKill:function(t){var e=this.source.contains(t.x,t.y);return e&&this.killOnEnter||!e&&!this.killOnEnter}});t.exports=n},function(t,e,i){var n=i(62),s=i(0),r=i(13),o=i(752),a=i(751),h=i(750),l=i(2),u=i(132),c=i(250),d=i(70),f=i(716),p=i(715),g=i(10),v=i(272),y=i(6),m=i(43),x=new s({Mixins:[r.BlendMode,r.ScrollFactor,r.Visible],initialize:function(t,e){this.manager=t,this.texture=t.texture,this.frames=[t.defaultFrame],this.defaultFrame=t.defaultFrame,this.configFastMap=["active","blendMode","collideBottom","collideLeft","collideRight","collideTop","deathCallback","deathCallbackScope","emitCallback","emitCallbackScope","follow","frequency","gravityX","gravityY","maxParticles","name","on","particleBringToTop","particleClass","radial","timeScale","trackVisible","visible"],this.configOpMap=["accelerationX","accelerationY","alpha","bounce","delay","lifespan","maxVelocityX","maxVelocityY","moveToX","moveToY","quantity","rotate","scaleX","scaleY","speedX","speedY","tint","x","y"],this.name="",this.particleClass=f,this.x=new h(e,"x",0),this.y=new h(e,"y",0),this.radial=!0,this.gravityX=0,this.gravityY=0,this.acceleration=!1,this.accelerationX=new h(e,"accelerationX",0,!0),this.accelerationY=new h(e,"accelerationY",0,!0),this.maxVelocityX=new h(e,"maxVelocityX",1e4,!0),this.maxVelocityY=new h(e,"maxVelocityY",1e4,!0),this.speedX=new h(e,"speedX",0,!0),this.speedY=new h(e,"speedY",0,!0),this.moveTo=!1,this.moveToX=new h(e,"moveToX",0,!0),this.moveToY=new h(e,"moveToY",0,!0),this.bounce=new h(e,"bounce",0,!0),this.scaleX=new h(e,"scaleX",1),this.scaleY=new h(e,"scaleY",1),this.tint=new h(e,"tint",4294967295),this.alpha=new h(e,"alpha",1),this.lifespan=new h(e,"lifespan",1e3),this.angle=new h(e,"angle",{min:0,max:360}),this.rotate=new h(e,"rotate",0),this.emitCallback=null,this.emitCallbackScope=null,this.deathCallback=null,this.deathCallbackScope=null,this.maxParticles=0,this.quantity=new h(e,"quantity",1,!0),this.delay=new h(e,"delay",0,!0),this.frequency=0,this.on=!0,this.particleBringToTop=!0,this.timeScale=1,this.emitZone=null,this.deathZone=null,this.bounds=null,this.collideLeft=!0,this.collideRight=!0,this.collideTop=!0,this.collideBottom=!0,this.active=!0,this.visible=!0,this.blendMode=n.NORMAL,this.follow=null,this.followOffset=new y,this.trackVisible=!1,this.currentFrame=0,this.randomFrame=!0,this.frameQuantity=1,this.dead=[],this.alive=[],this._counter=0,this._frameCounter=0,e&&this.fromJSON(e)},fromJSON:function(t){if(!t)return this;var e=0,i="";for(e=0;e0&&this.getParticleCount()===this.maxParticles},onParticleEmit:function(t,e){return void 0===t?(this.emitCallback=null,this.emitCallbackScope=null):"function"==typeof t&&(this.emitCallback=t,e&&(this.emitCallbackScope=e)),this},onParticleDeath:function(t,e){return void 0===t?(this.deathCallback=null,this.deathCallbackScope=null):"function"==typeof t&&(this.deathCallback=t,e&&(this.deathCallbackScope=e)),this},killAll:function(){for(var t=this.dead,e=this.alive;e.length>0;)t.push(e.pop());return this},forEachAlive:function(t,e){for(var i=this.alive,n=i.length,s=0;s0?n.pop():new this.particleClass(this)).fire(e,i),this.particleBringToTop?this.alive.push(r):this.alive.unshift(r),this.emitCallback&&this.emitCallback.call(this.emitCallbackScope,r,this),this.atLimit())break}return r}},preUpdate:function(t,e){var i=(e*=this.timeScale)/1e3;this.trackVisible&&(this.visible=this.follow.visible);for(var n=this.manager.getProcessors(),s=this.alive,r=s.length,o=0;o0){var u=s.splice(s.length-l,l),c=this.deathCallback,d=this.deathCallbackScope;if(c)for(var f=0;f0&&(this._counter-=e,this._counter<=0&&(this.emitParticle(),this._counter=this.frequency-Math.abs(this._counter))))},depthSortCallback:function(t,e){return t.y-e.y},indexSortCallback:function(t,e){return t.index-e.index}});t.exports=x},function(t,e,i){var n=i(0),s=i(2),r=new n({initialize:function(t,e,i,n,r){if("object"==typeof t){var o=t;t=s(o,"x",0),e=s(o,"y",0),i=s(o,"power",0),n=s(o,"epsilon",100),r=s(o,"gravity",50)}else void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=100),void 0===r&&(r=50);this.x=t,this.y=e,this.active=!0,this._gravity=r,this._power=0,this._epsilon=0,this.power=i,this.epsilon=n},update:function(t,e){var i=this.x-t.x,n=this.y-t.y,s=i*i+n*n;if(0!==s){var r=Math.sqrt(s);s0&&e.cameraFilter&s._id||t.drawImage(e,s)}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchSprite(e,s)}},function(t,e,i){var n=i(3),s=i(3);n=i(756),s=i(755),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchGraphics(this,s)}},function(t,e,i){var n=i(3),s=i(3);n=i(758),s=i(265),s=i(265),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e,i){var n=i(10);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.left,e.y=t.top,e.width=t.width,e.height=t.height,e}},function(t,e){t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}},function(t,e){t.exports=function(t,e){return e.setTo(t.x,t.y,t.width,t.height)}},function(t,e,i){var n=i(74);t.exports=function(t,e){return n(t,e.x,e.y)&&n(t,e.right,e.y)&&n(t,e.x,e.bottom)&&n(t,e.right,e.bottom)}},function(t,e,i){var n=i(74);t.exports=function(t,e){return n(t,e.x,e.y)}},function(t,e,i){var n=i(135);t.exports=function(t){return new n(t.x,t.y,t.width,t.height)}},function(t,e){t.exports=function(t){return t.isEmpty()?0:t.getMajorRadius()*t.getMinorRadius()*Math.PI}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){var r=e.text,o=r.length;if(!(n.RENDER_MASK!==e.renderFlags||0===o||e.cameraFilter>0&&e.cameraFilter&s._id)){var a=e.frame,h=e.displayCallback,l=s.scrollX*e.scrollFactorX,u=s.scrollY*e.scrollFactorY,c=e.fontData.chars,d=e.fontData.lineHeight,f=0,p=0,g=0,v=0,y=null,m=0,x=0,b=0,w=0,T=0,S=0,A=null,C=0,M=t.currentContext,_=e.frame.source.image,E=a.cutX,P=a.cutY,L=0,k=e.fontSize/e.fontData.size;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,M.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,M.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode),M.save(),M.translate(e.x,e.y),M.rotate(e.rotation),M.translate(-e.displayOriginX,-e.displayOriginY),M.scale(e.scaleX,e.scaleY),e.cropWidth>0&&e.cropHeight>0&&(M.save(),M.beginPath(),M.rect(0,0,e.cropWidth,e.cropHeight),M.clip());for(var F=t.config.roundPixels,O=0;O0&&e.cropHeight>0&&M.restore(),M.restore()}}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){var r=e.text.length;n.RENDER_MASK!==e.renderFlags||0===r||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchDynamicBitmapText(e,s)}},function(t,e,i){var n=i(3),s=i(3);n=i(770),s=i(769),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s){this.parent=t,this.x=e,this.y=i,this.frame=n,this.data={},this._visible=s,this._alpha=1,this.flipX=!1,this.flipY=!1},setFrame:function(t){return t=void 0===t?this.parent.frame:this.parent.texture.get(t),this},resetFlip:function(){return this.flipX=!1,this.flipY=!1,this},reset:function(t,e,i){return this.x=t,this.y=e,this.frame=i,this},setFlipX:function(t){return this.flipX=t,this},setFlipY:function(t){return this.flipY=t,this},setFlip:function(t,e){return this.flipX=t,this.flipY=e,this},setVisible:function(t){return this.visible=t,this},setAlpha:function(t){return this.alpha=t,this},destroy:function(){this.parent.dirty=!0,this.parent.children.remove(this),this.parent=void 0,this.frame=void 0,this.data=void 0},visible:{get:function(){return this._visible},set:function(t){this._visible=t,this.parent.dirty=!0}},alpha:{get:function(){return this._alpha},set:function(t){this._alpha=t,this.parent.dirty=!0}}});t.exports=n},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){var r=e.getRenderList();t.setBlendMode(e.blendMode);for(var o=t.gameContext,a=e.x-s.scrollX*e.scrollFactorX,h=e.y-s.scrollY*e.scrollFactorY,l=0;l0&&e.cameraFilter&s._id||this.pipeline.drawBlitter(e,s)}},function(t,e,i){var n=i(3),s=i(3);n=i(774),s=i(773),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){var r=e.text,o=r.length;if(!(n.RENDER_MASK!==e.renderFlags||0===o||e.cameraFilter>0&&e.cameraFilter&s._id)){var a=e.frame,h=e.fontData.chars,l=e.fontData.lineHeight,u=0,c=0,d=0,f=0,p=null,g=0,v=0,y=0,m=0,x=0,b=0,w=null,T=0,S=t.currentContext,A=e.frame.source.image,C=a.cutX,M=a.cutY,_=e.fontSize/e.fontData.size;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,S.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,S.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var E=t.config.roundPixels,P=e.x-s.scrollX*e.scrollFactorX+e.frame.x,L=e.y-s.scrollY*e.scrollFactorY+e.frame.y;E&&(P|=0,L|=0),S.save(),S.translate(P,L),S.rotate(e.rotation),S.translate(-e.displayOriginX,-e.displayOriginY),S.scale(e.scaleX,e.scaleY);for(var k=0;k0&&e.cameraFilter&s._id||this.pipeline.batchBitmapText(this,s)}},function(t,e,i){var n=i(3),s=i(3);n=i(777),s=i(776),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(5),s=function(t,e){var i=e.width,s=e.height,r=Math.floor(i/2),o=Math.floor(s/2),a=e.chars,h=n(e,"image",""),l=n(e,"offset.x",0),u=n(e,"offset.y",0),c=n(e,"spacing.x",0),d=n(e,"spacing.y",0),f=n(e,"charsPerRow",null);null===f&&(f=t.sys.textures.getFrame(h).width/i)>a.length&&(f=a.length);for(var p=l,g=u,v={retroFont:!0,font:h,size:i,lineHeight:s,chars:{}},y=0,m=0;m?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",s.TEXT_SET2=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ",s.TEXT_SET3="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",s.TEXT_SET4="ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",s.TEXT_SET5="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789",s.TEXT_SET6="ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ",s.TEXT_SET7="AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39",s.TEXT_SET8="0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ",s.TEXT_SET9="ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!",s.TEXT_SET10="ABCDEFGHIJKLMNOPQRSTUVWXYZ",s.TEXT_SET11="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789",t.exports=s},function(t,e,i){var n=i(270);t.exports=function(t,e,i,s,r,o,a){var h=t.sys.textures.getFrame(i,s),l=t.sys.cache.xml.get(r);if(h&&l){var u=n(l,o,a,h);return t.sys.cache.bitmapFont.add(e,{data:u,texture:i,frame:s}),!0}return!1}},function(t,e,i){var n=i(0),s=i(12),r=new n({initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),this._list=[],this._pendingInsertion=[],this._pendingRemoval=[]},boot:function(){var t=this.systems.events;t.on("preupdate",this.preUpdate,this),t.on("update",this.update,this),t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},add:function(t){return-1===this._list.indexOf(t)&&-1===this._pendingInsertion.indexOf(t)&&this._pendingInsertion.push(t),t},preUpdate:function(){var t=this._pendingRemoval.length,e=this._pendingInsertion.length;if(0!==t||0!==e){var i,n;for(i=0;i-1&&this._list.splice(s,1)}this._list=this._list.concat(this._pendingInsertion.splice(0)),this._pendingRemoval.length=0,this._pendingInsertion.length=0}},update:function(t,e){for(var i=0;i0||!this.inFocus)&&(this._coolDown--,s=Math.min(s,this._target)),s>this._min&&(s=i[e],s=Math.min(s,this._min)),i[e]=s,this.deltaIndex++,this.deltaIndex>n&&(this.deltaIndex=0);for(var r=0,o=0;othis.nextFpsUpdate&&(this.actualFps=.25*this.framesThisSecond+.75*this.actualFps,this.nextFpsUpdate=t+1e3,this.framesThisSecond=0),this.framesThisSecond++;var a=r/this._target;this.callback(t,r,a),this.lastTime=t},tick:function(){this.step(window.performance.now())},sleep:function(){this.running&&(this.raf.stop(),this.running=!1)},wake:function(t){this.running?this.sleep():t&&(this.startTime+=-this.lastTime+(this.lastTime=window.performance.now())),this.raf.start(this.step.bind(this),this.useRAF),this.running=!0,this.step(window.performance.now())},stop:function(){return this.running=!1,this.started=!1,this.raf.stop(),this},destroy:function(){this.stop(),this.callback=r,this.raf=null,this.game=null}});t.exports=a},function(t,e){var i=0,n=function(t,e,n,s){var r=i-s.y-s.height;t.add(n,e,s.x,r,s.width,s.height)};t.exports=function(t,e,s){var r=t.source[e];t.add("__BASE",e,0,0,r.width,r.height),i=r.height;for(var o=s.split("\n"),a=/^[ ]*(- )*(\w+)+[: ]+(.*)/,h="",l="",u={x:0,y:0,width:0,height:0},c=0;cx||a<-x)&&(a=0),a<0&&(a=x+a),-1!==h&&(x=a+(h+1));for(var M=l,_=l,E=0,P=e.sourceIndex,L=0;Lg||c<-g)&&(c=0),c<0&&(c=g+c),-1!==d&&(g=c+(d+1));for(var v=f,y=f,m=0,x=0,b=0;br&&(m=w-r),T>o&&(x=T-o),t.add(b,e,i+v,s+y,h-m,l-x),(v+=h+p)+h>r&&(v=f,y+=l+p)}return t}},function(t,e){t.exports=function(t,e){if(["layers","tilewidth","tileheight","tileswide","tileshigh"].forEach(function(t){e[t]}),1===e.layers.length){for(var i=new Phaser.FrameData,n=e.tileheight,s=e.tilewidth,r=e.layers[0].tiles,o=0;o0&&e.maxKeyDelay>0){var r=e.timeLastMatched+e.maxKeyDelay;t.timeStamp<=r&&(s=!0,i=n(t,e))}else s=!0,i=n(t,e);return!s&&e.resetOnWrongKey&&(e.index=0,e.current=e.keyCodes[0]),i&&(e.timeLastMatched=t.timeStamp,e.matched=!0,e.timeMatched=t.timeStamp),i}},function(t,e){var i={available:!1,cancel:"",keyboard:!1,request:""};t.exports=function(){var t,e=["requestFullscreen","requestFullScreen","webkitRequestFullscreen","webkitRequestFullScreen","msRequestFullscreen","msRequestFullScreen","mozRequestFullScreen","mozRequestFullscreen"],n=document.createElement("div");for(t=0;t=9&&/Mac OS X (\d+)_(\d+)/.test(navigator.userAgent)){var i=parseInt(RegExp.$1,10),r=parseInt(RegExp.$2,10);(10===i&&r>=11||i>10)&&(s.dolby=!0)}}catch(t){}return s}()},function(t,e,i){var n=i(76),s=i(100),r={gamepads:!1,mspointer:!1,touch:!1,wheelEvent:null};t.exports=(("ontouchstart"in document.documentElement||navigator.maxTouchPoints&&navigator.maxTouchPoints>=1)&&(r.touch=!0),(navigator.msPointerEnabled||navigator.pointerEnabled)&&(r.mspointer=!0),navigator.getGamepads&&(r.gamepads=!0),n.cocoonJS||("onwheel"in window||s.ie&&"WheelEvent"in window?r.wheelEvent="wheel":"onmousewheel"in window?r.wheelEvent="mousewheel":s.firefox&&"MouseScrollEvent"in window&&(r.wheelEvent="DOMMouseScroll")),r)},function(t,e,i){t.exports={os:i(76),browser:i(100),features:i(146),input:i(807),audio:i(806),video:i(805),fullscreen:i(804),canvasFeatures:i(302)}},function(t,e,i){var n=i(21);t.exports=function(t){var e=t.config;if(!e.hideBanner){var i="WebGL";e.renderType===n.CANVAS?i="Canvas":e.renderType===n.HEADLESS&&(i="Headless");var s,r=e.audio,o=t.device.audio;if(s=!o.webAudio||r&&r.disableWebAudio?r&&r.noAudio||!o.webAudio&&!o.audioData?"No Audio":"HTML5 Audio":"Web Audio",t.device.browser.ie)window.console&&console.log("Phaser v"+n.VERSION+" / https://phaser.io");else{var a,h="",l=[h];Array.isArray(e.bannerBackgroundColor)?(e.bannerBackgroundColor.forEach(function(t){h=h.concat("%c "),l.push("background: "+t),a=t}),l[l.length-1]="color: "+e.bannerTextColor+"; background: "+a):(h=h.concat("%c "),l.push("color: "+e.bannerTextColor+"; background: "+e.bannerBackgroundColor)),l.push("background: #fff"),e.gameTitle&&(h=h.concat(e.gameTitle),e.gameVersion&&(h=h.concat(" v"+e.gameVersion)),e.hidePhaser||(h=h.concat(" / "))),e.hidePhaser||(h=h.concat("Phaser v"+n.VERSION+" ("+i+" | "+s+")")),h=h.concat(" %c "+e.gameURL),l[0]=h,console.log.apply(console,l)}}}},function(t,e){t.exports="#define SHADER_NAME PHASER_TEXTURE_TINT_VS\r\n\r\nprecision mediump float;\r\n\r\nuniform mat4 uProjectionMatrix;\r\nuniform mat4 uViewMatrix;\r\nuniform mat4 uModelMatrix;\r\n\r\nattribute vec2 inPosition;\r\nattribute vec2 inTexCoord;\r\nattribute vec4 inTint;\r\n\r\nvarying vec2 outTexCoord;\r\nvarying vec4 outTint;\r\n\r\nvoid main () \r\n{\r\n gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);\r\n outTexCoord = inTexCoord;\r\n outTint = inTint;\r\n}\r\n\r\n"},function(t,e){t.exports="#define SHADER_NAME PHASER_TEXTURE_TINT_FS\r\n\r\nprecision mediump float;\r\n\r\nuniform sampler2D uMainSampler;\r\n\r\nvarying vec2 outTexCoord;\r\nvarying vec4 outTint;\r\n\r\nvoid main() \r\n{\r\n vec4 texel = texture2D(uMainSampler, outTexCoord);\r\n texel *= vec4(outTint.rgb * outTint.a, outTint.a);\r\n gl_FragColor = texel;\r\n}\r\n"},function(t,e){t.exports="#define SHADER_NAME PHASER_FORWARD_DIFFUSE_FS\r\n\r\nprecision mediump float;\r\n\r\nstruct Light\r\n{\r\n vec2 position;\r\n vec3 color;\r\n float intensity;\r\n float radius;\r\n};\r\n\r\nconst int kMaxLights = %LIGHT_COUNT%;\r\n\r\nuniform vec4 uCamera; /* x, y, rotation, zoom */\r\nuniform vec2 uResolution;\r\nuniform sampler2D uMainSampler;\r\nuniform sampler2D uNormSampler;\r\nuniform vec3 uAmbientLightColor;\r\nuniform Light uLights[kMaxLights];\r\n\r\nvarying vec2 outTexCoord;\r\nvarying vec4 outTint;\r\n\r\nvoid main()\r\n{\r\n vec3 finalColor = vec3(0.0, 0.0, 0.0);\r\n vec4 color = texture2D(uMainSampler, outTexCoord) * vec4(outTint.rgb * outTint.a, outTint.a);\r\n vec3 normalMap = texture2D(uNormSampler, outTexCoord).rgb;\r\n vec3 normal = normalize(vec3(normalMap * 2.0 - 1.0));\r\n vec2 res = vec2(min(uResolution.x, uResolution.y)) * uCamera.w;\r\n\r\n for (int index = 0; index < kMaxLights; ++index)\r\n {\r\n Light light = uLights[index];\r\n vec3 lightDir = vec3((light.position.xy / res) - (gl_FragCoord.xy / res), 0.1);\r\n vec3 lightNormal = normalize(lightDir);\r\n float distToSurf = length(lightDir) * uCamera.w;\r\n float diffuseFactor = max(dot(normal, lightNormal), 0.0);\r\n float radius = (light.radius / res.x * uCamera.w) * uCamera.w;\r\n float attenuation = clamp(1.0 - distToSurf * distToSurf / (radius * radius), 0.0, 1.0);\r\n vec3 diffuse = light.color * diffuseFactor;\r\n finalColor += (attenuation * diffuse) * light.intensity;\r\n }\r\n\r\n vec4 colorOutput = vec4(uAmbientLightColor + finalColor, 1.0);\r\n gl_FragColor = color * vec4(colorOutput.rgb * colorOutput.a, colorOutput.a);\r\n\r\n}\r\n"},function(t,e){t.exports="#define SHADER_NAME PHASER_FLAT_TINT_VS\r\n\r\nprecision mediump float;\r\n\r\nuniform mat4 uProjectionMatrix;\r\nuniform mat4 uViewMatrix;\r\nuniform mat4 uModelMatrix;\r\n\r\nattribute vec2 inPosition;\r\nattribute vec4 inTint;\r\n\r\nvarying vec4 outTint;\r\n\r\nvoid main () {\r\n gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);\r\n outTint = inTint;\r\n}\r\n"},function(t,e){t.exports="#define SHADER_NAME PHASER_FLAT_TINT_FS\r\n\r\nprecision mediump float;\r\n\r\nvarying vec4 outTint;\r\n\r\nvoid main() {\r\n gl_FragColor = vec4(outTint.rgb * outTint.a, outTint.a);\r\n}\r\n"},function(t,e){t.exports="#define SHADER_NAME PHASER_BITMAP_MASK_VS\r\n\r\nprecision mediump float;\r\n\r\nattribute vec2 inPosition;\r\n\r\nvoid main()\r\n{\r\n gl_Position = vec4(inPosition, 0.0, 1.0);\r\n}\r\n"},function(t,e){t.exports="#define SHADER_NAME PHASER_BITMAP_MASK_FS\r\n\r\nprecision mediump float;\r\n\r\nuniform vec2 uResolution;\r\nuniform sampler2D uMainSampler;\r\nuniform sampler2D uMaskSampler;\r\nuniform bool uInvertMaskAlpha;\r\n\r\nvoid main()\r\n{\r\n vec2 uv = gl_FragCoord.xy / uResolution;\r\n vec4 mainColor = texture2D(uMainSampler, uv);\r\n vec4 maskColor = texture2D(uMaskSampler, uv);\r\n float alpha = mainColor.a;\r\n\r\n if (!uInvertMaskAlpha)\r\n {\r\n alpha *= (maskColor.a);\r\n }\r\n else\r\n {\r\n alpha *= (1.0 - maskColor.a);\r\n }\r\n \r\n gl_FragColor = vec4(mainColor.rgb * alpha, alpha);\r\n}\r\n"},function(t,e,i){var n=i(313),s=i(23),r=i(21),o=i(146);t.exports=function(t){var e,a,h=t.config;if(h.renderType!==r.HEADLESS)if(h.renderType===r.CANVAS||h.renderType!==r.CANVAS&&!o.webGL){if(!o.canvas)throw new Error("Cannot create Canvas or WebGL context, aborting.");h.renderType=r.CANVAS}else h.renderType=r.WEBGL;h.pixelArt&&s.disableSmoothing(),h.canvas?t.canvas=h.canvas:t.canvas=s.create(t,h.width,h.height,h.renderType),h.canvasStyle&&(t.canvas.style=h.canvasStyle),h.pixelArt&&n.setCrisp(t.canvas),1!==h.zoom&&(t.canvas.style.width=(h.width*h.zoom).toString()+"px",t.canvas.style.height=(h.height*h.zoom).toString()+"px"),h.renderType!==r.HEADLESS&&(e=i(380),a=i(375),h.renderType===r.WEBGL?(t.renderer=new a(t),t.context=null):(t.renderer=new e(t),t.context=t.renderer.gameContext))}},function(t,e,i){var n=i(0),s=i(21),r=i(5),o=i(16),a=i(3),h=i(303),l=i(156),u=new n({initialize:function(t){void 0===t&&(t={});this.width=r(t,"width",1024),this.height=r(t,"height",768),this.zoom=r(t,"zoom",1),this.resolution=r(t,"resolution",1),this.renderType=r(t,"type",s.AUTO),this.parent=r(t,"parent",null),this.canvas=r(t,"canvas",null),this.canvasStyle=r(t,"canvasStyle",null),this.sceneConfig=r(t,"scene",null),this.seed=r(t,"seed",[(Date.now()*Math.random()).toString()]),o.RND.init(this.seed),this.gameTitle=r(t,"title",""),this.gameURL=r(t,"url","https://phaser.io"),this.gameVersion=r(t,"version",""),this.inputKeyboard=r(t,"input.keyboard",!0),this.inputKeyboardEventTarget=r(t,"input.keyboard.target",window),this.inputMouse=r(t,"input.mouse",!0),this.inputMouseEventTarget=r(t,"input.mouse.target",null),this.inputMouseCapture=r(t,"input.mouse.capture",!0),this.inputTouch=r(t,"input.touch",!0),this.inputTouchEventTarget=r(t,"input.touch.target",null),this.inputTouchCapture=r(t,"input.touch.capture",!0),this.inputGamepad=r(t,"input.gamepad",!1),this.disableContextMenu=r(t,"disableContextMenu",!1),this.audio=r(t,"audio"),this.hideBanner=!1===r(t,"banner",null),this.hidePhaser=r(t,"banner.hidePhaser",!1),this.bannerTextColor=r(t,"banner.text","#ffffff"),this.bannerBackgroundColor=r(t,"banner.background",["#ff0000","#ffff00","#00ff00","#00ffff","#000000"]),""===this.gameTitle&&this.hidePhaser&&(this.hideBanner=!0),this.fps=r(t,"fps",null);var e=r(t,"render",t);this.antialias=r(e,"antialias",!0),this.pixelArt=r(e,"pixelArt",!1),this.autoResize=r(e,"autoResize",!1),this.roundPixels=r(e,"roundPixels",!1),this.transparent=r(e,"transparent",!1),this.clearBeforeRender=r(e,"clearBeforeRender",!0),this.premultipliedAlpha=r(e,"premultipliedAlpha",!0),this.preserveDrawingBuffer=r(e,"preserveDrawingBuffer",!1),this.failIfMajorPerformanceCaveat=r(e,"failIfMajorPerformanceCaveat",!1),this.powerPreference=r(e,"powerPreference","default");var i=r(t,"backgroundColor",0);this.backgroundColor=l(i),0===i&&this.transparent&&(this.backgroundColor.alpha=0),this.preBoot=r(t,"callbacks.preBoot",a),this.postBoot=r(t,"callbacks.postBoot",a),this.physics=r(t,"physics",{}),this.defaultPhysicsSystem=r(this.physics,"default",!1),this.loaderBaseURL=r(t,"loader.baseURL",""),this.loaderPath=r(t,"loader.path",""),this.loaderEnableParallel=r(t,"loader.enableParallel",!0),this.loaderMaxParallelDownloads=r(t,"loader.maxParallelDownloads",4),this.loaderCrossOrigin=r(t,"loader.crossOrigin",void 0),this.loaderResponseType=r(t,"loader.responseType",""),this.loaderAsync=r(t,"loader.async",!0),this.loaderUser=r(t,"loader.user",""),this.loaderPassword=r(t,"loader.password",""),this.loaderTimeout=r(t,"loader.timeout",0),this.defaultPlugins=r(t,"plugins",h.DefaultScene);var n="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAg";this.defaultImage=r(t,"images.default",n+"AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=="),this.missingImage=r(t,"images.missing",n+"CAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==")}});t.exports=u},function(t,e,i){var n=i(147),s=i(339),r=i(337),o=i(23),a=i(0),h=i(818),l=i(817),u=i(103),c=i(809),d=i(808),f=i(307),p=i(15),g=i(299),v=i(3),y=i(12),m=i(287),x=i(283),b=i(276),w=i(785),T=i(784),S=new a({initialize:function(t){this.config=new h(t),this.renderer=null,this.canvas=null,this.context=null,this.isBooted=!1,this.isRunning=!1,this.events=new p,this.anims=new s(this),this.textures=new b(this),this.cache=new r(this),this.registry=new u(this),this.input=new g(this,this.config),this.scene=new m(this,this.config.sceneConfig),this.device=d,this.sound=x.create(this),this.loop=new w(this,this.config.fps),this.plugins=new y(this,this.config),this.onStepCallback=v,f(this.boot.bind(this))},boot:function(){this.isBooted=!0,this.config.preBoot(this),l(this),c(this),n(this.canvas,this.config.parent),this.events.emit("boot"),this.events.once("ready",this.start,this)},start:function(){this.isRunning=!0,this.config.postBoot(this),this.renderer?this.loop.start(this.step.bind(this)):this.loop.start(this.headlessStep.bind(this)),T(this.events),this.events.on("hidden",this.onHidden,this),this.events.on("visible",this.onVisible,this),this.events.on("blur",this.onBlur,this),this.events.on("focus",this.onFocus,this)},step:function(t,e){this.input.update(t,e),this.sound.update(t,e),this.onStepCallback(),this.scene.update(t,e);var i=this.renderer;i.preRender(),this.events.emit("prerender",i),this.scene.render(i),i.postRender(),this.events.emit("postrender",i)},headlessStep:function(t,e){this.input.update(t,e),this.sound.update(t,e),this.onStepCallback(),this.scene.update(t,e),this.events.emit("prerender"),this.events.emit("postrender")},onHidden:function(){this.loop.pause(),this.events.emit("pause")},onVisible:function(){this.loop.resume(),this.events.emit("resume")},onBlur:function(){this.loop.blur()},onFocus:function(){this.loop.focus()},resize:function(t,e){this.config.width=t,this.config.height=e,this.renderer.resize(t,e),this.input.resize(),this.scene.resize(t,e),this.events.emit("resize",t,e)},destroy:function(t){this.loop.destroy(),this.scene.destroy(),this.renderer.destroy(),this.events.emit("destroy"),this.events.removeAllListeners(),this.onStepCallback=null,t&&o.remove(this.canvas)}});t.exports=S},function(t,e,i){var n=i(0),s=i(15),r=i(12),o=new n({Extends:s,initialize:function(){s.call(this)},shutdown:function(){this.removeAllListeners()},destroy:function(){this.removeAllListeners()}});r.register("EventEmitter",o,"events"),t.exports=o},function(t,e){var i,n,s=t.exports={};function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(i===setTimeout)return setTimeout(t,0);if((i===r||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:r}catch(t){i=r}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(t){n=o}}();var h,l=[],u=!1,c=-1;function d(){u&&h&&(u=!1,h.length?l=h.concat(l):c=-1,l.length&&f())}function f(){if(!u){var t=a(d);u=!0;for(var e=l.length;e;){for(h=l,l=[];++c1)for(var i=1;i>16&255,g:t>>8&255,b:255&t,a:255};return t>16777215&&(e.a=t>>>24),e}},function(t,e){t.exports=function(t,e){void 0===e&&(e="none");return["-webkit-","-khtml-","-moz-","-ms-",""].forEach(function(i){t.style[i+"user-select"]=e}),t.style["-webkit-touch-callout"]=e,t.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",t}},function(t,e){t.exports=function(t,e){return void 0===e&&(e="none"),t.style.msTouchAction=e,t.style["ms-touch-action"]=e,t.style["touch-action"]=e,t}},function(t,e,i){t.exports={Interpolation:i(313),Pool:i(23),Smoothing:i(151),TouchAction:i(835),UserSelect:i(834)}},function(t,e){t.exports=function(t){return t.height*t.originY}},function(t,e){t.exports=function(t){return t.width*t.originX}},function(t,e,i){t.exports={CenterOn:i(361),GetBottom:i(36),GetCenterX:i(61),GetCenterY:i(58),GetLeft:i(34),GetOffsetX:i(838),GetOffsetY:i(837),GetRight:i(32),GetTop:i(30),SetBottom:i(35),SetCenterX:i(60),SetCenterY:i(59),SetLeft:i(33),SetRight:i(31),SetTop:i(29)}},function(t,e,i){var n=i(32),s=i(30),r=i(35),o=i(31);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)-a),t}},function(t,e,i){var n=i(34),s=i(30),r=i(35),o=i(33);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)-i),r(t,s(e)-a),t}},function(t,e,i){var n=i(61),s=i(30),r=i(35),o=i(60);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)-a),t}},function(t,e,i){var n=i(32),s=i(30),r=i(33),o=i(29);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)-a),t}},function(t,e,i){var n=i(58),s=i(32),r=i(59),o=i(33);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(36),s=i(32),r=i(35),o=i(33);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(34),s=i(30),r=i(31),o=i(29);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)-i),o(t,s(e)-a),t}},function(t,e,i){var n=i(58),s=i(34),r=i(59),o=i(31);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(36),s=i(34),r=i(35),o=i(31);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(36),s=i(32),r=i(31),o=i(29);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)+i),o(t,n(e)+a),t}},function(t,e,i){var n=i(36),s=i(34),r=i(33),o=i(29);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)-i),o(t,n(e)+a),t}},function(t,e,i){var n=i(36),s=i(61),r=i(60),o=i(29);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)+i),o(t,n(e)+a),t}},function(t,e,i){t.exports={BottomCenter:i(851),BottomLeft:i(850),BottomRight:i(849),LeftBottom:i(848),LeftCenter:i(847),LeftTop:i(846),RightBottom:i(845),RightCenter:i(844),RightTop:i(843),TopCenter:i(842),TopLeft:i(841),TopRight:i(840)}},function(t,e,i){t.exports={BottomCenter:i(365),BottomLeft:i(364),BottomRight:i(363),Center:i(362),LeftCenter:i(360),QuickSet:i(366),RightCenter:i(359),TopCenter:i(358),TopLeft:i(357),TopRight:i(356)}},function(t,e,i){var n=i(169),s=i(18),r={In:i(853),To:i(852)};r=s(!1,r,n),t.exports=r},function(t,e,i){t.exports={Align:i(854),Bounds:i(839),Canvas:i(836),Color:i(312),Masks:i(825)}},function(t,e,i){var n=i(0),s=i(103),r=i(12),o=new n({Extends:s,initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),s.call(this,this.scene,t.sys.events)},boot:function(){var t=this.systems.events;t.on("shutdown",this.shutdownPlugin,this),t.on("destroy",this.destroyPlugin,this)},shutdownPlugin:function(){},destroyPlugin:function(){this.destroy(),this.scene=void 0,this.systems=void 0}});r.register("DataManagerPlugin",o,"data"),t.exports=o},function(t,e,i){t.exports={DataManager:i(103),DataManagerPlugin:i(856)}},function(t,e,i){var n=i(0),s=i(6),r=new n({initialize:function(t,e){this.active=!1,this.p0=new s(t,e)},getPoint:function(t,e){return void 0===e&&(e=new s),e.copy(this.p0)},getPointAt:function(t,e){return this.getPoint(t,e)},getResolution:function(){return 1},getLength:function(){return 0},toJSON:function(){return{type:"MoveTo",points:[this.p0.x,this.p0.y]}}});t.exports=r},function(t,e,i){var n=i(0),s=i(321),r=i(319),o=i(9),a=i(317),h=i(858),l=i(316),u=i(10),c=i(314),d=i(6),f=new n({initialize:function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.name="",this.curves=[],this.cacheLengths=[],this.autoClose=!1,this.startPoint=new d,this._tmpVec2A=new d,this._tmpVec2B=new d,"object"==typeof t?this.fromJSON(t):this.startPoint.set(t,e)},add:function(t){return this.curves.push(t),this},circleTo:function(t,e,i){return void 0===e&&(e=!1),this.ellipseTo(t,t,0,360,e,i)},closePath:function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);return t.equals(e)||this.curves.push(new a(e,t)),this},cubicBezierTo:function(t,e,i,n,r,o){var a,h,l,u=this.getEndPoint();return t instanceof d?(a=t,h=e,l=i):(a=new d(i,n),h=new d(r,o),l=new d(t,e)),this.add(new s(u,a,h,l))},quadraticBezierTo:function(t,e,i,n){var s,r,o=this.getEndPoint();return t instanceof d?(s=t,r=e):(s=new d(i,n),r=new d(t,e)),this.add(new l(o,s,r))},draw:function(t,e){for(var i=0;i0?this.curves[this.curves.length-1].getPoint(1,t):t.copy(this.startPoint),t},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},getPoint:function(t,e){void 0===e&&(e=new d);for(var i=t*this.getLength(),n=this.getCurveLengths(),s=0;s=i){var r=n[s]-i,o=this.curves[s],a=o.getLength(),h=0===a?0:1-r/a;return o.getPointAt(h,e)}s++}return null},getPoints:function(t){void 0===t&&(t=12);for(var e,i=[],n=0;n1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i},getRandomPoint:function(t){return void 0===t&&(t=new d),this.getPoint(Math.random(),t)},getSpacedPoints:function(t){void 0===t&&(t=40);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return this.autoClose&&e.push(e[0]),e},getStartPoint:function(t){return void 0===t&&(t=new d),t.copy(this.startPoint)},lineTo:function(t,e){t instanceof d?this._tmpVec2B.copy(t):this._tmpVec2B.set(t,e);var i=this.getEndPoint(this._tmpVec2A);return this.add(new a([i.x,i.y,this._tmpVec2B.x,this._tmpVec2B.y]))},splineTo:function(t){return t.unshift(this.getEndPoint()),this.add(new c(t))},moveTo:function(t,e){return this.add(new h(t,e))},toJSON:function(){for(var t=[],e=0;e0;){this.cameras.pop().destroy()}return this.main},update:function(t,e){for(var i=0,n=this.cameras.length;i0&&e.cameraFilter&s._id||t.drawImage(e,s)}},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchSprite(e,s)}},function(t,e,i){var n=i(3),s=i(3);n=i(869),s=i(868),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){t.exports={Camera:i(154),CameraManager:i(867),OrthographicCamera:i(325),PerspectiveCamera:i(324)}},function(t,e,i){var n=i(157),s=i(0),r=i(2),o=i(12),a=i(27),h=new s({initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),this.currentCameraId=1,this.cameras=[],this.cameraPool=[],t.sys.settings.cameras?this.fromJSON(t.sys.settings.cameras):this.add(),this.main=this.cameras[0],this.baseScale=1},boot:function(){var t=this.systems.events;t.on("update",this.update,this),t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},add:function(t,e,i,s,r,o){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.scene.sys.game.config.width),void 0===s&&(s=this.scene.sys.game.config.height),void 0===r&&(r=!1),void 0===o&&(o="");var a=null;return this.cameraPool.length>0?(a=this.cameraPool.pop()).setViewport(t,e,i,s):a=new n(t,e,i,s),a.setName(o),a.setScene(this.scene),this.cameras.push(a),r&&(this.main=a),a._id=this.currentCameraId,this.currentCameraId=this.currentCameraId<<1,a},addExisting:function(t){var e=this.cameras.indexOf(t),i=this.cameraPool.indexOf(t);return e<0&&i>=0?(this.cameras.push(t),this.cameraPool.slice(i,1),t):null},fromJSON:function(t){Array.isArray(t)||(t=[t]);for(var e=this.scene.sys.game.config.width,i=this.scene.sys.game.config.height,n=0;n=0;i--){var n=e[i];if(n.inputEnabled&&a(n,t.x,t.y))return n}},remove:function(t){var e=this.cameras.indexOf(t);e>=0&&this.cameras.length>1&&(this.cameraPool.push(this.cameras[e]),this.cameras.splice(e,1),this.main===t&&(this.main=this.cameras[0]))},render:function(t,e,i){for(var n=this.cameras,s=this.baseScale,r=0,o=n.length;r0;)this.cameraPool.push(this.cameras.pop());return this.main=this.add(),this.main},update:function(t,e){for(var i=0,n=this.cameras.length;i0?(this._speedX-=this.dragX*t,this._speedX<0&&(this._speedX=0)):this._speedX<0&&(this._speedX+=this.dragX*t,this._speedX>0&&(this._speedX=0)),this._speedY>0?(this._speedY-=this.dragY*t,this._speedY<0&&(this._speedY=0)):this._speedY<0&&(this._speedY+=this.dragY*t,this._speedY>0&&(this._speedY=0)),this.up&&this.up.isDown?(this._speedY+=this.accelY,this._speedY>this.maxSpeedY&&(this._speedY=this.maxSpeedY)):this.down&&this.down.isDown&&(this._speedY-=this.accelY,this._speedY<-this.maxSpeedY&&(this._speedY=-this.maxSpeedY)),this.left&&this.left.isDown?(this._speedX+=this.accelX,this._speedX>this.maxSpeedX&&(this._speedX=this.maxSpeedX)):this.right&&this.right.isDown&&(this._speedX-=this.accelX,this._speedX<-this.maxSpeedX&&(this._speedX=-this.maxSpeedX)),this.zoomIn&&this.zoomIn.isDown?this._zoom=-this.zoomSpeed:this.zoomOut&&this.zoomOut.isDown?this._zoom=this.zoomSpeed:this._zoom=0,0!==this._speedX&&(e.scrollX-=this._speedX*t|0),0!==this._speedY&&(e.scrollY-=this._speedY*t|0),0!==this._zoom&&(e.zoom+=this._zoom,e.zoom<.1&&(e.zoom=.1))}},destroy:function(){this.camera=null,this.left=null,this.right=null,this.up=null,this.down=null,this.zoomIn=null,this.zoomOut=null}});t.exports=r},function(t,e,i){var n=i(0),s=i(5),r=new n({initialize:function(t){this.camera=s(t,"camera",null),this.left=s(t,"left",null),this.right=s(t,"right",null),this.up=s(t,"up",null),this.down=s(t,"down",null),this.zoomIn=s(t,"zoomIn",null),this.zoomOut=s(t,"zoomOut",null),this.zoomSpeed=s(t,"zoomSpeed",.01),this.speedX=0,this.speedY=0;var e=s(t,"speed",null);"number"==typeof e?(this.speedX=e,this.speedY=e):(this.speedX=s(t,"speed.x",0),this.speedY=s(t,"speed.y",0)),this._zoom=0,this.active=null!==this.camera},start:function(){return this.active=null!==this.camera,this},stop:function(){return this.active=!1,this},setCamera:function(t){return this.camera=t,this},update:function(t){if(this.active){void 0===t&&(t=1);var e=this.camera;this.up&&this.up.isDown?e.scrollY-=this.speedY*t|0:this.down&&this.down.isDown&&(e.scrollY+=this.speedY*t|0),this.left&&this.left.isDown?e.scrollX-=this.speedX*t|0:this.right&&this.right.isDown&&(e.scrollX+=this.speedX*t|0),this.zoomIn&&this.zoomIn.isDown?(e.zoom-=this.zoomSpeed,e.zoom<.1&&(e.zoom=.1)):this.zoomOut&&this.zoomOut.isDown&&(e.zoom+=this.zoomSpeed)}},destroy:function(){this.camera=null,this.left=null,this.right=null,this.up=null,this.down=null,this.zoomIn=null,this.zoomOut=null}});t.exports=r},function(t,e,i){t.exports={Fixed:i(875),Smoothed:i(874)}},function(t,e,i){t.exports={Controls:i(876),Scene2D:i(873),Sprite3D:i(871)}},function(t,e,i){t.exports={BaseCache:i(338),CacheManager:i(337)}},function(t,e,i){t.exports={Animation:i(341),AnimationFrame:i(340),AnimationManager:i(339)}},function(t,e,i){var n=i(43);t.exports=function(t,e,i){void 0===i&&(i=0);for(var s=0;s1)if(0===s){var d=t.length-1;for(o=t[d].x,a=t[d].y,h=d-1;h>=0;h--)l=(c=t[h]).x,u=c.y,c.x=o,c.y=a,o=l,a=u;t[d].x=e,t[d].y=i}else{for(o=t[0].x,a=t[0].y,h=1;h0?s(o,i):i<0&&r(o,Math.abs(i));for(var a=0;a>16)+(65280&t)+((255&t)<<16)},n={_tintTL:16777215,_tintTR:16777215,_tintBL:16777215,_tintBR:16777215,clearTint:function(){return this.setTint(16777215),this},setTint:function(t,e,n,s){return void 0===t&&(t=16777215),void 0===e&&(e=t,n=t,s=t),this._tintTL=i(t),this._tintTR=i(e),this._tintBL=i(n),this._tintBR=i(s),this},tintTopLeft:{get:function(){return this._tintTL},set:function(t){this._tintTL=i(t)}},tintTopRight:{get:function(){return this._tintTR},set:function(t){this._tintTR=i(t)}},tintBottomLeft:{get:function(){return this._tintBL},set:function(t){this._tintBL=i(t)}},tintBottomRight:{get:function(){return this._tintBR},set:function(t){this._tintBR=i(t)}},tint:{set:function(t){this.setTint(t,t,t,t)}}};t.exports=n},function(t,e){var i={texture:null,frame:null,setTexture:function(t,e){return this.texture=this.scene.sys.textures.get(t),this.setFrame(e)},setFrame:function(t,e,i){return void 0===e&&(e=!0),void 0===i&&(i=!0),this.frame=this.texture.get(t),this.frame.cutWidth&&this.frame.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,this._sizeComponent&&e&&this.setSizeToFrame(),this._originComponent&&i&&(this.frame.customPivot?this.setOrigin(this.frame.pivotX,this.frame.pivotY):this.updateDisplayOrigin()),this}};t.exports=i},function(t,e){var i={_sizeComponent:!0,width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.frame.realWidth},set:function(t){this.scaleX=t/this.frame.realWidth}},displayHeight:{get:function(){return this.scaleY*this.frame.realHeight},set:function(t){this.scaleY=t/this.frame.realHeight}},setSizeToFrame:function(t){return void 0===t&&(t=this.frame),this.width=t.realWidth,this.height=t.realHeight,this},setSize:function(t,e){return this.width=t,this.height=e,this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}};t.exports=i},function(t,e){var i={scrollFactorX:1,scrollFactorY:1,setScrollFactor:function(t,e){return void 0===e&&(e=t),this.scrollFactorX=t,this.scrollFactorY=e,this}};t.exports=i},function(t,e,i){var n=i(80),s={_scaleMode:n.DEFAULT,scaleMode:{get:function(){return this._scaleMode},set:function(t){t!==n.LINEAR&&t!==n.NEAREST||(this._scaleMode=t)}},setScaleMode:function(t){return this.scaleMode=t,this}};t.exports=s},function(t,e){var i={_originComponent:!0,originX:.5,originY:.5,_displayOriginX:0,_displayOriginY:0,displayOriginX:{get:function(){return this._displayOriginX},set:function(t){this._displayOriginX=t,this.originX=t/this.width}},displayOriginY:{get:function(){return this._displayOriginY},set:function(t){this._displayOriginY=t,this.originY=t/this.height}},setOrigin:function(t,e){return void 0===t&&(t=.5),void 0===e&&(e=t),this.originX=t,this.originY=e,this.updateDisplayOrigin()},setOriginFromFrame:function(){return this.frame&&this.frame.customPivot?(this.originX=this.frame.pivotX,this.originY=this.frame.pivotY,this.updateDisplayOrigin()):this.setOrigin()},setDisplayOrigin:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.displayOriginX=t,this.displayOriginY=e,this},updateDisplayOrigin:function(){return this._displayOriginX=Math.round(this.originX*this.width),this._displayOriginY=Math.round(this.originY*this.height),this}};t.exports=i},function(t,e){var i={matrixStack:null,currentMatrix:null,currentMatrixIndex:0,initMatrixStack:function(){return this.matrixStack=new Float32Array(6e3),this.currentMatrix=new Float32Array([1,0,0,1,0,0]),this.currentMatrixIndex=0,this},save:function(){if(this.currentMatrixIndex>=this.matrixStack.length)return this;var t=this.matrixStack,e=this.currentMatrix,i=this.currentMatrixIndex;return this.currentMatrixIndex+=6,t[i+0]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=e[3],t[i+4]=e[4],t[i+5]=e[5],this},restore:function(){if(this.currentMatrixIndex<=0)return this;this.currentMatrixIndex-=6;var t=this.matrixStack,e=this.currentMatrix,i=this.currentMatrixIndex;return e[0]=t[i+0],e[1]=t[i+1],e[2]=t[i+2],e[3]=t[i+3],e[4]=t[i+4],e[5]=t[i+5],this},loadIdentity:function(){return this.setTransform(1,0,0,1,0,0),this},transform:function(t,e,i,n,s,r){var o=this.currentMatrix,a=o[0],h=o[1],l=o[2],u=o[3],c=o[4],d=o[5];return o[0]=a*t+l*e,o[1]=h*t+u*e,o[2]=a*i+l*n,o[3]=h*i+u*n,o[4]=a*s+l*r+c,o[5]=h*s+u*r+d,this},setTransform:function(t,e,i,n,s,r){var o=this.currentMatrix;return o[0]=t,o[1]=e,o[2]=i,o[3]=n,o[4]=s,o[5]=r,this},translate:function(t,e){var i=this.currentMatrix,n=i[0],s=i[1],r=i[2],o=i[3],a=i[4],h=i[5];return i[4]=n*t+r*e+a,i[5]=s*t+o*e+h,this},scale:function(t,e){var i=this.currentMatrix,n=i[0],s=i[1],r=i[2],o=i[3];return i[0]=n*t,i[1]=s*t,i[2]=r*e,i[3]=o*e,this},rotate:function(t){var e=this.currentMatrix,i=e[0],n=e[1],s=e[2],r=e[3],o=Math.sin(t),a=Math.cos(t);return e[0]=i*a+s*o,e[1]=n*a+r*o,e[2]=i*-o+s*a,e[3]=n*-o+r*a,this}};t.exports=i},function(t,e,i){var n=i(10),s=i(350),r=i(6),o={getCenter:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth/2,t.y=this.y-this.displayHeight*this.originY+this.displayHeight/2,t},getTopLeft:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY,0!==this.rotation&&s(t,this.x,this.y,this.rotation),t},getTopRight:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY,0!==this.rotation&&s(t,this.x,this.y,this.rotation),t},getBottomLeft:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,0!==this.rotation&&s(t,this.x,this.y,this.rotation),t},getBottomRight:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,0!==this.rotation&&s(t,this.x,this.y,this.rotation),t},getBounds:function(t){void 0===t&&(t=new n),this.getTopLeft(t);var e=t.x,i=t.y;this.getTopRight(t);var s=t.x,r=t.y;this.getBottomLeft(t);var o=t.x,a=t.y;this.getBottomRight(t);var h=t.x,l=t.y;return t.x=Math.min(e,s,o,h),t.y=Math.min(i,r,a,l),t.width=Math.max(e,s,o,h)-t.x,t.height=Math.max(i,r,a,l)-t.y,t}};t.exports=o},function(t,e){t.exports={flipX:!1,flipY:!1,toggleFlipX:function(){return this.flipX=!this.flipX,this},toggleFlipY:function(){return this.flipY=!this.flipY,this},setFlipX:function(t){return this.flipX=t,this},setFlipY:function(t){return this.flipY=t,this},setFlip:function(t,e){return this.flipX=t,this.flipY=e,this},resetFlip:function(){return this.flipX=!1,this.flipY=!1,this}}},function(t,e){var i={_depth:0,depth:{get:function(){return this._depth},set:function(t){this.scene.sys.queueDepthSort(),this._depth=t}},setDepth:function(t){return void 0===t&&(t=0),this.depth=t,this}};t.exports=i},function(t,e){t.exports={width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.width},set:function(t){this.scaleX=t/this.width}},displayHeight:{get:function(){return this.scaleY*this.height},set:function(t){this.scaleY=t/this.height}}}},function(t,e,i){var n=i(62),s={_blendMode:n.NORMAL,blendMode:{get:function(){return this._blendMode},set:function(t){"string"==typeof t&&(t=n[t]),(t|=0)>=0&&(this._blendMode=t)}},setBlendMode:function(t){return this.blendMode=t,this}};t.exports=s},function(t,e,i){var n=i(64),s={_alpha:1,_alphaTL:1,_alphaTR:1,_alphaBL:1,_alphaBR:1,clearAlpha:function(){return this.setAlpha(1)},setAlpha:function(t,e,i,s){return void 0===t&&(t=1),void 0===e?this.alpha=t:(this._alphaTL=n(t,0,1),this._alphaTR=n(e,0,1),this._alphaBL=n(i,0,1),this._alphaBR=n(s,0,1)),this},alpha:{get:function(){return this._alpha},set:function(t){var e=n(t,0,1);this._alpha=e,this._alphaTL=e,this._alphaTR=e,this._alphaBL=e,this._alphaBR=e,0===e?this.renderFlags&=-3:this.renderFlags|=2}},alphaTopLeft:{get:function(){return this._alphaTL},set:function(t){var e=n(t,0,1);this._alphaTL=e,0!==e&&(this.renderFlags|=2)}},alphaTopRight:{get:function(){return this._alphaTR},set:function(t){var e=n(t,0,1);this._alphaTR=e,0!==e&&(this.renderFlags|=2)}},alphaBottomLeft:{get:function(){return this._alphaBL},set:function(t){var e=n(t,0,1);this._alphaBL=e,0!==e&&(this.renderFlags|=2)}},alphaBottomRight:{get:function(){return this._alphaBR},set:function(t){var e=n(t,0,1);this._alphaBR=e,0!==e&&(this.renderFlags|=2)}}};t.exports=s},function(t,e,i){var n=new(i(0))({initialize:function(t){this.c=1,this.s0=0,this.s1=0,this.s2=0,this.n=0,this.signs=[-1,1],t&&this.init(t)},rnd:function(){var t=2091639*this.s0+2.3283064365386963e-10*this.c;return this.c=0|t,this.s0=this.s1,this.s1=this.s2,this.s2=t-this.c,this.s2},hash:function(t){var e,i=this.n;t=t.toString();for(var n=0;n>>0,i=(e*=i)>>>0,i+=4294967296*(e-=i);return this.n=i,2.3283064365386963e-10*(i>>>0)},init:function(t){"string"==typeof t?this.state(t):this.sow(t)},sow:function(t){if(this.n=4022871197,this.s0=this.hash(" "),this.s1=this.hash(" "),this.s2=this.hash(" "),this.c=1,t)for(var e=0;e>>0;if("function"!=typeof t)throw new TypeError;for(var n=arguments.length>=2?arguments[1]:void 0,s=0;s0&&(i=s[0].bodyA,n=s[0].bodyB),t.emit("collisionstart",e,i,n)}),c.on(e,"collisionActive",function(e){var i,n,s=e.pairs;s.length>0&&(i=s[0].bodyA,n=s[0].bodyB),t.emit("collisionactive",e,i,n)}),c.on(e,"collisionEnd",function(e){var i,n,s=e.pairs;s.length>0&&(i=s[0].bodyA,n=s[0].bodyB),t.emit("collisionend",e,i,n)})},setBounds:function(t,e,i,n,s,r,o,a,h){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.scene.sys.game.config.width),void 0===n&&(n=this.scene.sys.game.config.height),void 0===s&&(s=128),void 0===r&&(r=!0),void 0===o&&(o=!0),void 0===a&&(a=!0),void 0===h&&(h=!0),this.updateWall(r,"left",t-s,e,s,n),this.updateWall(o,"right",t+i,e,s,n),this.updateWall(a,"top",t,e-s,i,s),this.updateWall(h,"bottom",t,e+n,i,s),this},updateWall:function(t,e,i,n,s,r){var o=this.walls[e];t?(o&&d.remove(this.localWorld,o),i+=s/2,n+=r/2,this.walls[e]=this.create(i,n,s,r,{isStatic:!0,friction:0,frictionStatic:0})):(o&&d.remove(this.localWorld,o),this.walls[e]=null)},createDebugGraphic:function(){var t=this.scene.sys.add.graphics({x:0,y:0});return t.setZ(Number.MAX_VALUE),this.debugGraphic=t,this.drawDebug=!0,t},disableGravity:function(){return this.localWorld.gravity.x=0,this.localWorld.gravity.y=0,this.localWorld.gravity.scale=0,this},setGravity:function(t,e,i){return void 0===t&&(t=0),void 0===e&&(e=1),this.localWorld.gravity.x=t,this.localWorld.gravity.y=e,void 0!==i&&(this.localWorld.gravity.scale=i),this},create:function(t,e,i,s,r){var o=n.rectangle(t,e,i,s,r);return d.add(this.localWorld,o),o},add:function(t){return d.add(this.localWorld,t),this},remove:function(t,e){var i=t.body?t.body:t;return r.removeBody(this.localWorld,i,e),this},removeConstraint:function(t,e){return r.remove(this.localWorld,t,e),this},convertTilemapLayer:function(t,e){var i=t.layer,n=t.getTilesWithin(0,0,i.width,i.height,{isColliding:!0});return this.convertTiles(n,e),this},convertTiles:function(t,e){if(0===t.length)return this;for(var i=0;i0&&u.trigger(n,"collisionStart",{pairs:T.collisionStart}),o.preSolvePosition(T.list),f=0;f0&&u.trigger(n,"collisionActive",{pairs:T.collisionActive}),T.collisionEnd.length>0&&u.trigger(n,"collisionEnd",{pairs:T.collisionEnd}),h.update(n.metrics,n),t(x),u.trigger(n,"afterUpdate",m),n},n.merge=function(t,e){if(f.extend(t,e),e.world){t.world=e.world,n.clear(t);for(var i=c.allBodies(t.world),s=0;sf.friction*f.frictionStatic*R*i&&(I=k,B=o.clamp(f.friction*F*i,-I,I));var D=r.cross(A,y),Y=r.cross(C,y),z=b/(g.inverseMass+v.inverseMass+g.inverseInertia*D*D+v.inverseInertia*Y*Y);if(O*=z,B*=z,P<0&&P*P>n._restingThresh*i)T.normalImpulse=0;else{var X=T.normalImpulse;T.normalImpulse=Math.min(T.normalImpulse+O,0),O=T.normalImpulse-X}if(L*L>n._restingThreshTangent*i)T.tangentImpulse=0;else{var N=T.tangentImpulse;T.tangentImpulse=o.clamp(T.tangentImpulse+B,-I,I),B=T.tangentImpulse-N}s.x=y.x*O+m.x*B,s.y=y.y*O+m.y*B,g.isStatic||g.isSleeping||(g.positionPrev.x+=s.x*g.inverseMass,g.positionPrev.y+=s.y*g.inverseMass,g.anglePrev+=r.cross(A,s)*g.inverseInertia),v.isStatic||v.isSleeping||(v.positionPrev.x-=s.x*v.inverseMass,v.positionPrev.y-=s.y*v.inverseMass,v.anglePrev-=r.cross(C,s)*v.inverseInertia)}}}}},function(t,e,i){var n={};t.exports=n;var s=i(370),r=i(39);n.create=function(t){return r.extend({table:{},list:[],collisionStart:[],collisionActive:[],collisionEnd:[]},t)},n.update=function(t,e,i){var n,r,o,a,h=t.list,l=t.table,u=t.collisionStart,c=t.collisionEnd,d=t.collisionActive;for(u.length=0,c.length=0,d.length=0,a=0;a1e3&&h.push(r);for(r=0;rv.bounds.max.x||b.bounds.max.yv.bounds.max.y)){var w=e(i,b);if(!b.region||w.id!==b.region.id||r){x.broadphaseTests+=1,b.region&&!r||(b.region=w);var T=t(w,b.region);for(d=T.startCol;d<=T.endCol;d++)for(f=T.startRow;f<=T.endRow;f++){p=y[g=a(d,f)];var S=d>=w.startCol&&d<=w.endCol&&f>=w.startRow&&f<=w.endRow,A=d>=b.region.startCol&&d<=b.region.endCol&&f>=b.region.startRow&&f<=b.region.endRow;!S&&A&&A&&p&&u(i,p,b),(b.region===w||S&&!A||r)&&(p||(p=h(y,g)),l(i,p,b))}b.region=w,m=!0}}}m&&(i.pairsList=c(i))},n.clear=function(t){t.buckets={},t.pairs={},t.pairsList=[]};var t=function(t,e){var n=Math.min(t.startCol,e.startCol),s=Math.max(t.endCol,e.endCol),r=Math.min(t.startRow,e.startRow),o=Math.max(t.endRow,e.endRow);return i(n,s,r,o)},e=function(t,e){var n=e.bounds,s=Math.floor(n.min.x/t.bucketWidth),r=Math.floor(n.max.x/t.bucketWidth),o=Math.floor(n.min.y/t.bucketHeight),a=Math.floor(n.max.y/t.bucketHeight);return i(s,r,o,a)},i=function(t,e,i,n){return{id:t+","+e+","+i+","+n,startCol:t,endCol:e,startRow:i,endRow:n}},a=function(t,e){return"C"+t+"R"+e},h=function(t,e){return t[e]=[]},l=function(t,e,i){for(var n=0;n0?n.push(i):delete t.pairs[e[s]];return n}}()},function(t,e,i){var n={};t.exports=n;var s=i(463),r=i(39);n.name="matter-js",n.version="0.13.1",n.uses=[],n.used=[],n.use=function(){s.use(n,Array.prototype.slice.call(arguments))},n.before=function(t,e){return t=t.replace(/^Matter./,""),r.chainPathBefore(n,t,e)},n.after=function(t,e){return t=t.replace(/^Matter./,""),r.chainPathAfter(n,t,e)}},function(t,e,i){var n=i(381),s=i(92),r=i(0),o=i(371),a=i(1),h=i(2),l=i(349),u=i(40),c=i(6),d=new r({Extends:u,Mixins:[o.Bounce,o.Collision,o.Force,o.Friction,o.Gravity,o.Mass,o.Sensor,o.SetBody,o.Sleep,o.Static,o.Transform,o.Velocity,l],initialize:function(t,e,i,r,o,l){a.call(this,t.scene,"Image"),this.anims=new n(this),this.setTexture(r,o),this.setSizeToFrame(),this.setOrigin(),this.world=t,this._tempVec2=new c(e,i);var u=h(l,"shape",null);u?this.setBody(u,l):(this.body=s.rectangle(e,i,this.width,this.height,l),this.body.gameObject=this,h(l,"addToWorld",!0)&&t.add(this.body)),this.setPosition(e,i),this.initPipeline("TextureTintPipeline")}});t.exports=d},function(t,e,i){var n=i(92),s=i(0),r=i(371),o=i(1),a=i(2),h=i(72),l=i(349),u=i(6),c=new s({Extends:h,Mixins:[r.Bounce,r.Collision,r.Force,r.Friction,r.Gravity,r.Mass,r.Sensor,r.SetBody,r.Sleep,r.Static,r.Transform,r.Velocity,l],initialize:function(t,e,i,s,r,h){o.call(this,t.scene,"Image"),this.setTexture(s,r),this.setSizeToFrame(),this.setOrigin(),this.world=t,this._tempVec2=new u(e,i);var l=a(h,"shape",null);l?this.setBody(l,h):(this.body=n.rectangle(e,i,this.width,this.height,h),this.body.gameObject=this,a(h,"addToWorld",!0)&&t.add(this.body)),this.setPosition(e,i),this.initPipeline("TextureTintPipeline")}});t.exports=c},function(t,e,i){var n={};t.exports=n;var s=i(120),r=i(170),o=i(39),a=i(49),h=i(92);n.stack=function(t,e,i,n,r,o,h){for(var l,u=s.create({label:"Stack"}),c=t,d=e,f=0,p=0;pg&&(g=m),a.translate(y,{x:.5*x,y:.5*m}),c=y.bounds.max.x+r,s.addBody(u,y),l=y,f+=1}else c+=r}d+=g+o,c=t}return u},n.chain=function(t,e,i,n,a,h){for(var l=t.bodies,u=1;u0)for(l=0;l0&&(d=f[l-1+(h-1)*e],s.addConstraint(t,r.create(o.extend({bodyA:d,bodyB:c},a)))),n&&ld||o<(l=d-l)||o>i-1-l))return 1===c&&a.translate(u,{x:(o+(i%2==1?1:-1))*f,y:0}),h(t+(u?o*f:0)+o*r,n,o,l,u,c)})},n.newtonsCradle=function(t,e,i,n,o){for(var a=s.create({label:"Newtons Cradle"}),l=0;l=0&&h<=1&&l>=0&&l<=1}function s(t,e,i){return(e[0]-t[0])*(i[1]-t[1])-(i[0]-t[0])*(e[1]-t[1])}function r(t,e,i){return s(t,e,i)>0}function o(t,e,i){return s(t,e,i)>=0}function a(t,e,i){return s(t,e,i)<0}function h(t,e,i){return s(t,e,i)<=0}t.exports={decomp:function(t){var e=function t(e){var i=[],n=[],s=[],r=[];var o=Number.MAX_VALUE;for(var a=0;a0?function t(e,i){if(0===i.length)return[e];if(i instanceof Array&&i.length&&i[0]instanceof Array&&2===i[0].length&&i[0][0]instanceof Array){for(var n=[e],s=0;su)return console.warn("quickDecomp: max level ("+u+") reached."),i;for(var k=0;kA&&(A+=e.length),S=Number.MAX_VALUE,A3&&n>=0;--n)c(f(t,n-1),f(t,n),f(t,n+1),e)&&(t.splice(n%t.length,1),i++);return i},makeCCW:function(t){for(var e=0,i=t,n=1;ni[e][0])&&(e=n);r(f(t,e-1),f(t,e),f(t,e+1))||function(t){for(var e=[],i=t.length,n=0;n!==i;n++)e.push(t.pop());for(var n=0;n!==i;n++)t[n]=e[n]}(t)}};var l=[],u=[];function c(t,e,i,n){if(n){var r=l,o=u;r[0]=e[0]-t[0],r[1]=e[1]-t[1],o[0]=i[0]-e[0],o[1]=i[1]-e[1];var a=r[0]*o[0]+r[1]*o[1],h=Math.sqrt(r[0]*r[0]+r[1]*r[1]),c=Math.sqrt(o[0]*o[0]+o[1]*o[1]);return Math.acos(a/(h*c))r.ACTIVE&&c(this,t,e))},setCollidesNever:function(t){for(var e=0;e1)for(var h=i/a,l=n/a,u=0;u0?r:0,y=n<0?f:0,m=Math.max(Math.floor(i/f),0),x=Math.min(Math.ceil((i+o)/f),g);u=Math.floor((t.pos.x+v)/f);var b=Math.floor((e+v)/f);if((l>0||u===b||b<0||b>=p)&&(b=-1),u>=0&&u1&&d<=this.lastSlope&&this.checkDef(t,d,e,i,a,h,r,o,b,c));c++)if(1===(d=this.data[c][u])||d>this.lastSlope||d>1&&this.checkDef(t,d,e,i,a,h,r,o,u,c)){if(d>1&&d<=this.lastSlope&&t.collision.slope)break;t.collision.x=!0,t.tile.x=d,t.pos.x=u*f-v+y,e=t.pos.x,a=0;break}}if(s){var w=s>0?o:0,T=s<0?f:0,S=Math.max(Math.floor(t.pos.x/f),0),A=Math.min(Math.ceil((t.pos.x+r)/f),p);c=Math.floor((t.pos.y+w)/f);var C=Math.floor((i+w)/f);if((l>0||c===C||C<0||C>=g)&&(C=-1),c>=0&&c1&&d<=this.lastSlope&&this.checkDef(t,d,e,i,a,h,r,o,u,C));u++)if(1===(d=this.data[c][u])||d>this.lastSlope||d>1&&this.checkDef(t,d,e,i,a,h,r,o,u,c)){if(d>1&&d<=this.lastSlope&&t.collision.slope)break;t.collision.y=!0,t.tile.y=d,t.pos.y=c*f-w+T;break}}},checkDef:function(t,e,i,n,s,r,o,a,h,l){var u=this.tiledef[e];if(!u)return!1;var c=this.tilesize,d=(h+u[0])*c,f=(l+u[1])*c,p=(u[2]-u[0])*c,g=(u[3]-u[1])*c,v=u[4],y=i+s+(g<0?o:0)-d,m=n+r+(p>0?a:0)-f;if(p*m-g*y>0){if(s*-g+r*p<0)return v;var x=Math.sqrt(p*p+g*g),b=g/x,w=-p/x,T=y*b+m*w,S=b*T,A=w*T;return S*S+A*A>=s*s+r*r?v||p*(m-r)-g*(y-s)<.5:(t.pos.x=i+s-S,t.pos.y=n+r-A,t.collision.slope={x:p,y:g,nx:b,ny:w},!0)}return!1}});t.exports=r},function(t,e,i){var n=i(0),s=i(200),r=i(1017),o=i(199),a=i(1016),h=new n({initialize:function(t,e,i,n,r){void 0===n&&(n=16),void 0===r&&(r=n),this.world=t,this.gameObject=null,this.enabled=!0,this.parent,this.id=t.getNextID(),this.name="",this.size={x:n,y:r},this.offset={x:0,y:0},this.pos={x:e,y:i},this.last={x:e,y:i},this.vel={x:0,y:0},this.accel={x:0,y:0},this.friction={x:0,y:0},this.maxVel={x:t.defaults.maxVelocityX,y:t.defaults.maxVelocityY},this.standing=!1,this.gravityFactor=t.defaults.gravityFactor,this.bounciness=t.defaults.bounciness,this.minBounceVelocity=t.defaults.minBounceVelocity,this.accelGround=0,this.accelAir=0,this.jumpSpeed=0,this.type=o.NONE,this.checkAgainst=o.NONE,this.collides=s.NEVER,this.debugShowBody=t.defaults.debugShowBody,this.debugShowVelocity=t.defaults.debugShowVelocity,this.debugBodyColor=t.defaults.bodyDebugColor,this.updateCallback,this.slopeStanding={min:.767944870877505,max:2.3736477827122884}},reset:function(t,e){this.pos={x:t,y:e},this.last={x:t,y:e},this.vel={x:0,y:0},this.accel={x:0,y:0},this.friction={x:0,y:0},this.maxVel={x:100,y:100},this.standing=!1,this.gravityFactor=1,this.bounciness=0,this.minBounceVelocity=40,this.accelGround=0,this.accelAir=0,this.jumpSpeed=0,this.type=o.NONE,this.checkAgainst=o.NONE,this.collides=s.NEVER},update:function(t){var e=this.pos;this.last.x=e.x,this.last.y=e.y,this.vel.y+=this.world.gravity*t*this.gravityFactor,this.vel.x=r(t,this.vel.x,this.accel.x,this.friction.x,this.maxVel.x),this.vel.y=r(t,this.vel.y,this.accel.y,this.friction.y,this.maxVel.y);var i=this.vel.x*t,n=this.vel.y*t,s=this.world.collisionMap.trace(e.x,e.y,i,n,this.size.x,this.size.y);this.handleMovementTrace(s)&&a(this,s);var o=this.gameObject;o&&(o.x=e.x-this.offset.x+o.displayOriginX*o.scaleX,o.y=e.y-this.offset.y+o.displayOriginY*o.scaleY),this.updateCallback&&this.updateCallback(this)},drawDebug:function(t){var e=this.pos;if(this.debugShowBody&&(t.lineStyle(1,this.debugBodyColor,1),t.strokeRect(e.x,e.y,this.size.x,this.size.y)),this.debugShowVelocity){var i=e.x+this.size.x/2,n=e.y+this.size.y/2;t.lineStyle(1,this.world.defaults.velocityDebugColor,1),t.lineBetween(i,n,i+this.vel.x,n+this.vel.y)}},willDrawDebug:function(){return this.debugShowBody||this.debugShowVelocity},skipHash:function(){return!this.enabled||0===this.type&&0===this.checkAgainst&&0===this.collides},touches:function(t){return!(this.pos.x>=t.pos.x+t.size.x||this.pos.x+this.size.x<=t.pos.x||this.pos.y>=t.pos.y+t.size.y||this.pos.y+this.size.y<=t.pos.y)},resetSize:function(t,e,i,n){return this.pos.x=t,this.pos.y=e,this.size.x=i,this.size.y=n,this},toJSON:function(){return{name:this.name,size:{x:this.size.x,y:this.size.y},pos:{x:this.pos.x,y:this.pos.y},vel:{x:this.vel.x,y:this.vel.y},accel:{x:this.accel.x,y:this.accel.y},friction:{x:this.friction.x,y:this.friction.y},maxVel:{x:this.maxVel.x,y:this.maxVel.y},gravityFactor:this.gravityFactor,bounciness:this.bounciness,minBounceVelocity:this.minBounceVelocity,type:this.type,checkAgainst:this.checkAgainst,collides:this.collides}},fromJSON:function(){},check:function(){},collideWith:function(t,e){this.parent&&this.parent._collideCallback&&this.parent._collideCallback.call(this.parent._callbackScope,this,t,e)},handleMovementTrace:function(){return!0},destroy:function(){this.world.remove(this),this.enabled=!1,this.world=null,this.gameObject=null,this.parent=null}});t.exports=h},,function(t,e,i){t.exports={BitmapMaskPipeline:i(373),FlatTintPipeline:i(372),ForwardDiffuseLightPipeline:i(173),TextureTintPipeline:i(172)}},function(t,e,i){t.exports={Utils:i(44),WebGLPipeline:i(108),WebGLRenderer:i(375),Pipelines:i(973),BYTE:0,SHORT:1,UNSIGNED_BYTE:2,UNSIGNED_SHORT:3,FLOAT:4}},function(t,e,i){t.exports={Canvas:i(378),WebGL:i(374)}},function(t,e,i){t.exports={CanvasRenderer:i(380),BlitImage:i(379),DrawImage:i(377),GetBlendModes:i(376)}},function(t,e,i){t.exports={Canvas:i(976),Snapshot:i(975),WebGL:i(974)}},function(t,e,i){var n=i(464),s={name:"matter-wrap",version:"0.1.4",for:"matter-js@^0.13.1",silent:!0,install:function(t){t.after("Engine.update",function(){s.Engine.update(this)})},Engine:{update:function(t){for(var e=t.world,i=n.Composite.allBodies(e),r=n.Composite.allComposites(e),o=0;oe.max.x?i=e.min.x-t.max.x:t.max.xe.max.y?n=e.min.y-t.max.y:t.max.y0)for(var a=s+1;a1;if(!c||t!=c.x||e!=c.y){c&&n?(d=c.x,f=c.y):(d=0,f=0);var s={x:d+t,y:f+e};!n&&c||(c=s),p.push(s),v=d+t,y=f+e}},x=function(t){var e=t.pathSegTypeAsLetter.toUpperCase();if("Z"!==e){switch(e){case"M":case"L":case"T":case"C":case"S":case"Q":v=t.x,y=t.y;break;case"H":v=t.x;break;case"V":y=t.y}m(v,y,t.pathSegType)}};for(t(e),r=e.getTotalLength(),h=[],n=0;n1?1:0;n0))r=t.collisionMap.trace(e.pos.x,e.pos.y,0,-(e.pos.y+e.size.y-i.pos.y),e.size.x,e.size.y),e.pos.y=r.pos.y,e.bounciness>0&&e.vel.y>e.minBounceVelocity?e.vel.y*=-e.bounciness:(e.standing=!0,e.vel.y=0);else{var l=(e.vel.y-i.vel.y)/2;e.vel.y=-l,i.vel.y=l,s=i.vel.x*t.delta,r=t.collisionMap.trace(e.pos.x,e.pos.y,s,-o/2,e.size.x,e.size.y),e.pos.y=r.pos.y;var u=t.collisionMap.trace(i.pos.x,i.pos.y,0,o/2,i.size.x,i.size.y);i.pos.y=u.pos.y}}},function(t,e){t.exports=function(t,e,i,n){var s=e.pos.x+e.size.x-i.pos.x;if(n){var r=e===n?i:e;n.vel.x=-n.vel.x*n.bounciness+r.vel.x;var o=t.collisionMap.trace(n.pos.x,n.pos.y,n===e?-s:s,0,n.size.x,n.size.y);n.pos.x=o.pos.x}else{var a=(e.vel.x-i.vel.x)/2;e.vel.x=-a,i.vel.x=a;var h=t.collisionMap.trace(e.pos.x,e.pos.y,-s/2,0,e.size.x,e.size.y);e.pos.x=Math.floor(h.pos.x);var l=t.collisionMap.trace(i.pos.x,i.pos.y,s/2,0,i.size.x,i.size.y);i.pos.x=Math.ceil(l.pos.x)}}},function(t,e,i){var n=i(200),s=i(1e3),r=i(999);t.exports=function(t,e,i){var o=null;e.collides===n.LITE||i.collides===n.FIXED?o=e:i.collides!==n.LITE&&e.collides!==n.FIXED||(o=i),e.last.x+e.size.x>i.last.x&&e.last.xi.last.y&&e.last.y0&&Math.abs(t.vel.y)>t.minBounceVelocity?t.vel.y*=-t.bounciness:(t.vel.y>0&&(t.standing=!0),t.vel.y=0)),e.collision.x&&(t.bounciness>0&&Math.abs(t.vel.x)>t.minBounceVelocity?t.vel.x*=-t.bounciness:t.vel.x=0),e.collision.slope){var i=e.collision.slope;if(t.bounciness>0){var n=t.vel.x*i.nx+t.vel.y*i.ny;t.vel.x=(t.vel.x-i.nx*n*2)*t.bounciness,t.vel.y=(t.vel.y-i.ny*n*2)*t.bounciness}else{var s=i.x*i.x+i.y*i.y,r=(t.vel.x*i.x+t.vel.y*i.y)/s;t.vel.x=i.x*r,t.vel.y=i.y*r;var o=Math.atan2(i.x,i.y);o>t.slopeStanding.min&&o0?e-o:e+o<0?e+o:0}return n(e,-r,r)}},function(t,e,i){t.exports={Body:i(971),COLLIDES:i(200),CollisionMap:i(970),Factory:i(969),Image:i(967),ImpactBody:i(968),ImpactPhysics:i(1002),Sprite:i(966),TYPE:i(199),World:i(965)}},function(t,e,i){t.exports={Arcade:i(491),Impact:i(1018),Matter:i(998)}},function(t,e,i){(function(e){i(953);var n=i(21),s=i(18),r={Actions:i(367),Animation:i(879),Cache:i(878),Cameras:i(877),Class:i(0),Create:i(866),Curves:i(860),Data:i(857),Display:i(855),DOM:i(822),EventEmitter:i(820),Game:i(819),GameObjects:i(783),Geom:i(245),Input:i(566),Loader:i(552),Math:i(534),Physics:i(1019),Renderer:i(977),Scene:i(286),Scenes:i(461),Sound:i(459),Structs:i(458),Textures:i(457),Tilemaps:i(455),Time:i(406),Tweens:i(404),Utils:i(400)};r=s(!1,r,n),t.exports=r,e.Phaser=r}).call(this,i(369))}])}); \ No newline at end of file